changeset: 96301:55e6f3f94b99 branch: 3.5 parent: 96297:2f59747dba6c user: Nick Coghlan date: Tue May 26 21:48:17 2015 +1000 files: Lib/test/test_importlib/extension/test_loader.py Misc/NEWS Python/importdl.c description: Issue #24285: fix importing extensions from packages diff -r 2f59747dba6c -r 55e6f3f94b99 Lib/test/test_importlib/extension/test_loader.py --- a/Lib/test/test_importlib/extension/test_loader.py Tue May 26 10:25:48 2015 +0300 +++ b/Lib/test/test_importlib/extension/test_loader.py Tue May 26 21:48:17 2015 +1000 @@ -170,6 +170,13 @@ loader.exec_module(module) return module + def test_load_submodule(self): + '''Test loading a simulated submodule''' + module = self.load_module_by_name('pkg.' + self.name) + self.assertIsInstance(module, types.ModuleType) + self.assertEqual(module.__name__, 'pkg.' + self.name) + self.assertEqual(module.str_const, 'something different') + def test_load_twice(self): '''Test that 2 loads result in 2 module objects''' module1 = self.load_module_by_name(self.name) diff -r 2f59747dba6c -r 55e6f3f94b99 Misc/NEWS --- a/Misc/NEWS Tue May 26 10:25:48 2015 +0300 +++ b/Misc/NEWS Tue May 26 21:48:17 2015 +1000 @@ -10,6 +10,9 @@ Core and Builtins ----------------- +- Issue #24285: Fixed regression that prevented importing extension modules + from inside packages. Patch by Petr Viktorin. + Library ------- @@ -24,7 +27,8 @@ - Issue #24276: Fixed optimization of property descriptor getter. -- Issue #24268: PEP 489: Multi-phase extension module initialization +- Issue #24268: PEP 489: Multi-phase extension module initialization. + Patch by Petr Viktorin. - Issue #23955: Add pyvenv.cfg option to suppress registry/environment lookup for generating sys.path on Windows. diff -r 2f59747dba6c -r 55e6f3f94b99 Python/importdl.c --- a/Python/importdl.c Tue May 26 10:25:48 2015 +0300 +++ b/Python/importdl.c Tue May 26 21:48:17 2015 +1000 @@ -45,7 +45,7 @@ if (lastdot < -1) { return NULL; } else if (lastdot >= 0) { - tmp = PyUnicode_Substring(name, lastdot, name_len); + tmp = PyUnicode_Substring(name, lastdot + 1, name_len); if (tmp == NULL) return NULL; name = tmp;