]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
bpo-39336: Allow packages to not let their child modules be set on them (#18006)
authorDino Viehland <dinoviehland@gmail.com>
Thu, 23 Jan 2020 00:42:38 +0000 (16:42 -0800)
committerGitHub <noreply@github.com>
Thu, 23 Jan 2020 00:42:38 +0000 (16:42 -0800)
commit9b6fec46513006d7b06fcb645cca6e4f5bf7c7b8
treed159d657c67c4f4ef7a961a5e73a119644de8d3e
parentd3ae95e1e945ed20297e1c38ba43a18b7a868ab6
bpo-39336: Allow packages to not let their child modules be set on them (#18006)

* bpo-39336: Allow setattr to fail on modules which aren't assignable

When attaching a child module to a package if the object in sys.modules raises an AttributeError (e.g. because it is immutable) it causes the whole import to fail.  This now allows immutable packages to exist and an ImportWarning is reported and the AttributeError exception is ignored.
Lib/importlib/_bootstrap.py
Lib/test/test_import/__init__.py
Lib/test/test_import/data/unwritable/__init__.py [new file with mode: 0644]
Lib/test/test_import/data/unwritable/x.py [new file with mode: 0644]
Misc/NEWS.d/next/Core and Builtins/2020-01-15-01-39-29.bpo-39336.nJ7W9I.rst [new file with mode: 0644]
Python/importlib.h