Commits

Anonymous committed fd95f93

pycore: ignoring from imports inside functions

  • Participants
  • Parent commits 8a9f72a

Comments (0)

Files changed (2)

File rope/base/pyobjectsdef.py

         imported_module = pynames.ImportedModule(self.get_module(),
                                                  node.module, level)
         if len(node.names) == 1 and node.names[0].name == '*':
-            self.owner_object.star_imports.append(
-                pynames.StarImport(imported_module))
+            if isinstance(self.owner_object, PyModule):
+                self.owner_object.star_imports.append(
+                    pynames.StarImport(imported_module))
         else:
             for imported_name in node.names:
                 imported = imported_name.name

File ropetest/pycoretest.py

         mod = self.pycore.get_string_module('from samplemod import *')
         self.assertTrue('_underlined_func' not in mod.get_attributes())
 
+    def test_from_import_star_imports_in_functions(self):
+        mod = self.pycore.get_string_module('def f():\n    from os import *\n')
+        mod['f'].get_object().get_scope().get_names()
+
     def test_from_package_import_mod(self):
         mod = self.pycore.get_string_module('from package import nestedmod\n')
         self.assertEquals(get_base_type('Module'),