Issue #32 new

fix_import aborts on certain comma separated imports

David Gabor Bodor
created an issue

Running 3to2 on the following file, I get an unhandled exception: {{{


import urllib.request, urllib.error, urllib.parse }}} {{{ Traceback (most recent call last): ... File "/lib/python3.2/site-packages/lib3to2/fixes/", line 145, in fix_simple_name assert node.type == token.NAME, repr(node) AttributeError: 'NoneType' object has no attribute 'type' }}}

(Test file and full traceback are attached.)

Splitting the line in question into separate import statements fixes the problem.

This seems to be a problem that only shows up with urllib (and possibly other) modules, as the substitution rules are compicated for this package.

For reference, here is a working input file and generated diff: {{{


import urllib.request import urllib.error import urllib.parse }}} {{{ --- (original) +++ (refactored) @@ -1,3 +1,3 @@ -import urllib.request -import urllib.error -import urllib.parse +import urllib2, urllib +import urllib2, urllib +import urllib2, urllib, urlparse }}}

Comments (1)

  1. Log in to comment