We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 03770db commit ef625b0Copy full SHA for ef625b0
src/libfuturize/fixes/fix_division_safe.py
@@ -40,7 +40,8 @@ def _is_floaty(expr):
40
return const_re.match(expr.value)
41
elif isinstance(expr, Node):
42
# If the expression is a node, let's see if it's a direct cast to float
43
- return expr.children[0].value == u'float'
+ if isinstance(expr.children[0], Leaf):
44
+ return expr.children[0].value == u'float'
45
return False
46
47
@@ -79,7 +80,6 @@ def transform(self, node, results):
79
80
return
81
future_import(u"division", node)
82
- touch_import_top(u'past.utils', u'old_div', node)
83
expr1, expr2 = results[0].clone(), results[1].clone()
84
# Strip any leading space for the first number:
85
expr1.prefix = u''
@@ -88,5 +88,6 @@ def transform(self, node, results):
88
# should be the same in 2 or 3
89
if _is_floaty(expr1) or _is_floaty(expr2):
90
91
+ touch_import_top(u'past.utils', u'old_div', node)
92
return wrap_in_fn_call("old_div", (expr1, expr2), prefix=node.prefix)
93
0 commit comments