diff options
author | Nick Coghlan <ncoghlan@gmail.com> | 2016-08-21 07:41:56 (GMT) |
---|---|---|
committer | Nick Coghlan <ncoghlan@gmail.com> | 2016-08-21 07:41:56 (GMT) |
commit | 8682f578c1c8fd0486c886b001729907a5409a9f (patch) | |
tree | 2f54886ef578b7faf94e26fe32e24fbb258b896a /Lib/test/test_importlib/extension | |
parent | 9c8aa9bffe755fe6126dc72dfd037c6b20e65906 (diff) | |
download | cpython-8682f578c1c8fd0486c886b001729907a5409a9f.zip cpython-8682f578c1c8fd0486c886b001729907a5409a9f.tar.gz cpython-8682f578c1c8fd0486c886b001729907a5409a9f.tar.bz2 |
Issue #27782: Fix m_methods handling in multiphase init
Multi-phase extension module import now correctly allows the
``m_methods`` field to be used to add module level functions
to instances of non-module types returned from ``Py_create_mod``.
Patch by Xiang Zhang.
Diffstat (limited to 'Lib/test/test_importlib/extension')
-rw-r--r-- | Lib/test/test_importlib/extension/test_loader.py | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/Lib/test/test_importlib/extension/test_loader.py b/Lib/test/test_importlib/extension/test_loader.py index 154a793..8d20040 100644 --- a/Lib/test/test_importlib/extension/test_loader.py +++ b/Lib/test/test_importlib/extension/test_loader.py @@ -212,6 +212,15 @@ class MultiPhaseExtensionModuleTests(abc.LoaderTests): self.assertNotEqual(type(mod), type(unittest)) self.assertEqual(mod.three, 3) + # issue 27782 + def test_nonmodule_with_methods(self): + '''Test creating a non-module object with methods defined''' + name = self.name + '_nonmodule_with_methods' + mod = self.load_module_by_name(name) + self.assertNotEqual(type(mod), type(unittest)) + self.assertEqual(mod.three, 3) + self.assertEqual(mod.bar(10, 1), 9) + def test_null_slots(self): '''Test that NULL slots aren't a problem''' name = self.name + '_null_slots' |