Commits

Anonymous committed cc99a03

pynames: getting the definition location of builtin modules

  • Participants
  • Parent commits 4656463

Comments (0)

Files changed (2)

File rope/base/pynames.py

         return self._get_pymodule()
 
     def get_definition_location(self):
-        if self._get_pymodule() is None:
+        pymodule = self._get_pymodule()
+        if not isinstance(pymodule, rope.base.pyobjects.PyDefinedObject):
             return (None, None)
-        return (self._get_pymodule().get_module(), 1)
+        return (pymodule.get_module(), 1)
 
 
 class prevent_recursion(object):

File ropetest/contrib/codeassisttest.py

                                          len(code) - 2, mod2)
         self.assertEquals((mod1, 1), result)
 
+    def test_get_definition_location_for_builtins(self):
+        code = 'import sys\n'
+        result = get_definition_location(self.project, code,
+                                         len(code) - 2)
+        self.assertEquals((None, None), result)
+
     def test_get_doc_on_relative_imports(self):
         pkg = testutils.create_package(self.project, 'pkg')
         mod1 = testutils.create_module(self.project, 'mod1', pkg)