diff --git a/stdlib/internal/format.codon b/stdlib/internal/format.codon index c7fb1769..145ac1ee 100644 --- a/stdlib/internal/format.codon +++ b/stdlib/internal/format.codon @@ -8,7 +8,7 @@ class int: def __format__(self, format_spec: str) -> str: err = False ret = _C.seq_str_int(self, format_spec, __ptr__(err)) - if err: + if format_spec and err: _format_error(ret) return ret @@ -17,7 +17,7 @@ class Int: def __format__(self, format_spec: str) -> str: err = False ret = _C.seq_str_int(self.__int__(), format_spec, __ptr__(err)) - if err: + if format_spec and err: _format_error(ret) return ret @@ -26,7 +26,7 @@ class UInt: def __format__(self, format_spec: str) -> str: err = False ret = _C.seq_str_uint(self.__int__(), format_spec, __ptr__(err)) - if err: + if format_spec and err: _format_error(ret) return ret @@ -35,7 +35,7 @@ class float: def __format__(self, format_spec: str) -> str: err = False ret = _C.seq_str_float(self, format_spec, __ptr__(err)) - if err: + if format_spec and err: _format_error(ret) return ret if ret != "-nan" else "nan" @@ -44,7 +44,7 @@ class str: def __format__(self, format_spec: str) -> str: err = False ret = _C.seq_str_str(self, format_spec, __ptr__(err)) - if err: + if format_spec and err: _format_error(ret) return ret @@ -53,6 +53,6 @@ class Ptr: def __format__(self, format_spec: str) -> str: err = False ret = _C.seq_str_ptr(self.as_byte(), format_spec, __ptr__(err)) - if err: + if format_spec and err: _format_error(ret) return ret