From miked at dewhirst.com.au Sat Feb 15 00:18:47 2014 From: miked at dewhirst.com.au (Mike Dewhirst) Date: Fri, 14 Feb 2014 23:18:47 -0000 Subject: [Python-porting] edge case Message-ID: <52FE9F60.1000500@dewhirst.com.au> While porting a project - all modules at once - futurize threw a traceback without contextual clues for which of my modules it found problematic. Traceback (most recent call last): ... (snipped) File "c:\users\miked\env\xxdx\lib\site-packages\libfuturize\fixer_util.py", line 373, in check_future_import assert 0, "strange import" AssertionError: strange import Rather than start again one module at a time I rummaged around line 373 in fixer_util.py to see what it was trying to do. I hacked it as follows: --- C:/users/miked/env/xxdx/Lib/site-packages/libfuturize/fixer_util.py~ Sat Feb 15 09:33:01 2014 +++ C:/users/miked/env/xxdx/Lib/site-packages/libfuturize/fixer_util.py Sat Feb 15 09:33:17 2014 @@ -341,6 +341,7 @@ def check_future_import(node): """If this is a future import, return set of symbols that are imported, else return None.""" # node should be the import statement here + savenode = node if not (node.type == syms.simple_stmt and node.children): return set() node = node.children[0] @@ -370,6 +371,6 @@ def check_future_import(node): elif node.type == token.NAME: return set([node.value]) else: - assert 0, "strange import" + assert 0, "strange import: %s" % savenode Then I ran futurize again and got a clue ... Traceback (most recent call last): ... (snipped) File "c:\users\miked\env\xxdx\lib\site-packages\libfuturize\fixer_util.py", line 374, in check_future_import assert 0, "strange import: %s" % savenode AssertionError: strange import: from __future__ import (unicode_literals, division) Whereupon I searched for the offending text and removed the parentheses from the import line and all was well. Lovely software - thanks Ed Mike