Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion lib/astunparse/unparser.py
Original file line number Diff line number Diff line change
Expand Up @@ -708,7 +708,10 @@ def _Attribute(self,t):
# Special case: 3.__abs__() is a syntax error, so if t.value
# is an integer literal then we need to either parenthesize
# it or add an extra space to get 3 .__abs__().
if isinstance(t.value, getattr(ast, 'Constant', getattr(ast, 'Num', None))) and isinstance(t.value.n, int):
ast_Num = getattr(ast, 'Num', None)
ast_Constant = getattr(ast, 'Constant', None)
if ((ast_Num and isinstance(t.value, ast_Num) and isinstance(t.value.n, int))
or (ast_Constant and isinstance(t.value, ast_Constant) and isinstance(t.value.value, int))):
self.write(" ")
self.write(".")
self.write(t.attr)
Expand Down
1 change: 0 additions & 1 deletion tests/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,6 @@ def test_unary_parens(self):
self.check_roundtrip("not True or False")
self.check_roundtrip("True or not False")

@unittest.skipUnless(sys.version_info < (3, 6), "Only works for Python < 3.6")
def test_integer_parens(self):
self.check_roundtrip("3 .__abs__()")

Expand Down