Commits

Victor Stinner committed e5917f1

Namespace: allow duplicate aliases

Comments (0)

Files changed (2)

astoptimizer/optimizer.py

         if name in self._removed_aliases:
             return
         if name in self.qualnames:
+            if self.qualnames[name] == qualname:
+                return
             self._removed_aliases.add(name)
             del self.qualnames[name]
             return

astoptimizer/tests.py

 
     def test_ImportFrom(self):
         self.check_qualnames('from math import trunc as M', {'M': 'math.trunc'})
+        self.check_qualnames('from math import pow; from math import pow',
+                             {'pow': 'math.pow'})
         code = '\n'.join((
             'try:',
             '    from StringIO import StringIO as BUFFER',