1. Joe Amenta
  2. lib3to2
  3. Issues
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/fix_imports.py", 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 }}} {{{ --- 3to2-success.py (original) +++ 3to2-success.py (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