Skip to content

Commit 8edc5cb

Browse files
ultramiraculousChris Williams
authored andcommitted
Avoid truncating floats in gyb
1 parent c8458ce commit 8edc5cb

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

utils/gyb.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -710,8 +710,10 @@ def execute(self, context):
710710
# If we got a result, the code was an expression, so append
711711
# its value
712712
if result is not None and result != '':
713+
from numbers import Number, Integral
714+
result_string = repr(result) if isinstance(result, Number) and not isinstance(result, Integral) else str(result)
713715
context.append_text(
714-
str(result), self.filename, self.start_line_number)
716+
result_string, self.filename, self.start_line_number)
715717

716718
def __str__(self, indent=''):
717719
source_lines = re.sub(r'^\n', '', strip_trailing_nl(

0 commit comments

Comments
 (0)