1. Joe Amenta
  2. lib3to2
Issue #38 resolved

"queue" attribute incorrectly refactored to "Queue"

Christopher Foo
created an issue

This code:

import collections
import queue

MyTuple = collections.namedtuple('MyTuple', ['queue', 'queue1'])

tuple_instance = MyTuple(queue.Queue(), queue.Queue())

tuple_instance.queue.put(1)
tuple_instanec.queue1.put(1)

is incorrectly refactored to tuple_instance.Queue.put(1):

--- queuetest.py    (original)
+++ queuetest.py    (refactored)
@@ -1,9 +1,10 @@
+from __future__ import absolute_import
 import collections
-import queue
+import Queue

-MyTuple = collections.namedtuple('MyTuple', ['queue', 'queue1'])
+MyTuple = collections.namedtuple(u'MyTuple', [u'queue', u'queue1'])

-tuple_instance = MyTuple(queue.Queue(), queue.Queue())
+tuple_instance = MyTuple(Queue.Queue(), Queue.Queue())

-tuple_instance.queue.put(1)
+tuple_instance.Queue.put(1)
 tuple_instance.queue1.put(1)

on commit ae7407b0dc28