Commit graph

147 commits

Author SHA1 Message Date
Nick Coghlan
93602e3af7 [3.5] bpo-29537: Tolerate legacy invalid bytecode (#169)
bpo-27286 fixed a problem where BUILD_MAP_UNPACK_WITH_CALL could
be emitted with an incorrect oparg value, causing the eval loop
to access the wrong stack entry when attempting to read the
function name.

The associated magic number change caused significant problems when
attempting to upgrade to 3.5.3 for anyone that relies on pre-cached
bytecode remaining valid across maintenance releases.

This patch restores the ability to import legacy bytecode generated
by 3.5.0, 3.5.1 or 3.5.2, and modifies the eval loop to
avoid any harmful consequences from the potentially malformed legacy
bytecode.

Original import patch by Petr Viktorin, eval loop patch by Serhiy Storchaka,
and tests and integration by Nick Coghlan.
2017-03-08 16:41:01 +10:00
Martin Panter
0be894b2f6 Issue #27895: Spelling fixes (Contributed by Ville Skyttä). 2016-09-07 12:03:06 +00:00
Senthil Kumaran
32d374215a [backport to 3.5] - issue26896 - Disambiguate uses of "importer" with "finder". 2016-09-07 00:52:20 -07:00
Nick Coghlan
8682f578c1 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.
2016-08-21 17:41:56 +10:00
Brett Cannon
7ca63cb7cc Fix regressions introduced by fixes for issue #27083. 2016-07-16 10:44:13 -07:00
Brett Cannon
a47a7a5bf8 Issue #27083: Respect the PYTHONCASEOK environment variable under
Windows.

Originally only b'PYTHONCASEOK' was being checked for in os.environ,
but that won't work under Windows where all environment variables are
strings (on OS X they are bytes).

Thanks to Eryk Sun for the bug report.
2016-07-15 11:54:38 -07:00
Brett Cannon
e92dc9c23d Fix a scoping issue where an UnboundLocalError was triggered if a
lazy-loaded module was already in sys.modules.
2016-06-25 10:47:53 -07:00
Serhiy Storchaka
e431d3c9aa Issue #26581: Use the first coding cookie on a line, not the last one. 2016-03-20 23:36:29 +02:00
Brett Cannon
558823a0cf Issue #26186: Remove an invalid type check in
importlib.util.LazyLoader.

The class was checking its argument as to whether its implementation
of create_module() came directly from importlib.abc.Loader. The
problem is that the classes coming from imoprtlib.machinery do not
directly inherit from the ABC as they come from _frozen_importlib.
Because the documentation has always said that create_module() was
ignored, the check has simply been removed.
2016-02-20 18:35:41 -08:00
Brett Cannon
4f38cb41fe Issue #26367: Have importlib.__init__() raise RuntimeError when
'level' is specified but no __package__.

This brings the function inline with builtins.__import__(). Thanks to
Manuel Jacob for the patch.
2016-02-20 12:52:06 -08:00
Serhiy Storchaka
35abe19c24 Issue #25595: Fixed test_deleted_cwd in test_importlib on AIX. 2015-11-11 08:26:59 +02:00
Benjamin Peterson
3d1151d2c0 use assert method in another place 2015-05-30 00:02:17 -05:00
Benjamin Peterson
0a3297d7d4 use assert method (#24328) 2015-05-29 18:44:45 -05:00
Benjamin Peterson
e20056c8f7 fix importing one char extension modules (closes #24328) 2015-05-29 17:10:30 -05:00
Nick Coghlan
55871f04bf Issue #24285: fix importing extensions from packages 2015-05-26 21:48:17 +10:00
Nick Coghlan
d5cacbb1d9 PEP 489: Multi-phase extension module initialization
Known limitations of the current implementation:

- documentation changes are incomplete
- there's a reference leak I haven't tracked down yet

The leak is most visible by running:

  ./python -m test -R3:3 test_importlib

However, you can also see it by running:

  ./python -X showrefcount

Importing the array or _testmultiphase modules, and
then deleting them from both sys.modules and the local
namespace shows significant increases in the total
number of active references each cycle. By contrast,
with _testcapi (which continues to use single-phase
initialisation) the global refcounts stabilise after
a couple of cycles.
2015-05-23 22:24:10 +10:00
Serhiy Storchaka
041dd8eef1 Issue #15836: assertRaises(), assertRaisesRegex(), assertWarns() and
assertWarnsRegex() assertments now check the type of the first argument
to prevent possible user error.  Based on patch by Daniel Wagner-Hall.
2015-05-21 20:15:40 +03:00
Eric Snow
183a941bc1 Issue #24192: Fix namespace package imports. 2015-05-15 21:54:59 -06:00
Eric Snow
32439d6eb6 Issue #23911: Move path-based bootstrap code to a separate frozen module. 2015-05-02 19:15:18 -06:00
Brett Cannon
f299abdafa Issue #23731: Implement PEP 488.
The concept of .pyo files no longer exists. Now .pyc files have an
optional `opt-` tag which specifies if any extra optimizations beyond
the peepholer were applied.
2015-04-13 14:21:02 -04:00
Brett Cannon
ac9591a44a Remove a dead test for a never-launched API 2015-03-27 14:21:26 -04:00
Brett Cannon
8004e8577c Issue #22834: Drop a redundant comment and use errno instead of an
integer.

Thanks to Serhiy Storchaka and Martin Panter for the suggestions.
2015-02-27 12:13:35 -05:00
Brett Cannon
16cd19c8a2 Issue #22834: Fix a failing test under Solaris due to the platform not
allowing the deletion of the cwd.

Thanks to Martin Panter for the initial fix.
2015-02-20 09:48:18 -05:00
Brett Cannon
02d8454002 Issue #23014: Make importlib.abc.Loader.create_module() required when
importlib.abc.Loader.exec_module() is also defined.

Before this change, create_module() was optional **and** could return
None to trigger default semantics. This change now reduces the
options for choosing default semantics to one and in the most
backporting-friendly way (define create_module() to return None).
2015-01-09 11:39:21 -05:00
Steve Dower
03a144bb6a #22980 Adds platform and version tags to .pyd files 2014-12-15 20:45:23 -08:00
Zachary Ware
513112b229 Issue #22834: cwd can't not exist on Windows, skip the test 2014-11-22 17:03:46 -06:00
Brett Cannon
b6e2556d8f Issue #22834: Have import suppress FileNotFoundError when the current
working directory no longer exists.

Thanks to Martin Panter for the bug report.
2014-11-21 12:19:28 -05:00
Brett Cannon
7c08b19f86 Issue #19714: Tests for importlib.machinery.WindowsRegistryFinder.
Patch by Claudiu Popa, review by Martin v. Löwis.
2014-08-22 10:28:42 -04:00
Zachary Ware
f886697659 Closes #22002: Merge with 3.4 2014-07-23 12:06:47 -05:00
Zachary Ware
f012ba42fe Issue #22002: Make full use of test discovery in test sub-packages.
Adds `load_package_tests` function to test.support, uses it in test_asyncio,
test_email, test_json, test_tools, test_importlib and all test_importlib
sub-packages to implement test discovery.
2014-07-23 12:00:29 -05:00
Serhiy Storchaka
f2c4ba1207 Issue #19593: Use specific asserts in importlib tests. 2014-07-07 14:09:43 +03:00
Serhiy Storchaka
344f8316fd Issue #19593: Use specific asserts in importlib tests. 2014-07-07 14:08:19 +03:00
Berker Peksag
f7eaa0c63c Issue #21755: Skip {Frozen,Source}_DeadlockAvoidanceTests tests when
Python is built without threads.
2014-07-03 06:25:10 +03:00
Brett Cannon
2a17bde930 Issue #20383: Introduce importlib.util.module_from_spec().
Along the way, dismantle importlib._bootstrap._SpecMethods as it was
no longer relevant and constructing the new function required
partially dismantling the class anyway.
2014-05-30 14:55:29 -04:00
Raymond Hettinger
62f4dad816 Issue 21137: Better repr for threading.Lock() 2014-05-25 18:22:35 -07:00
Eric Snow
3497c0bf95 Issue #21503: Use test_both() consistently in test_importlib. 2014-05-16 11:40:40 -06:00
Eric Snow
d50cee2045 Fix a small typo in test_importlib. 2014-05-16 11:22:05 -06:00
Eric Snow
e1c9e5270a Merge from 3.4 (for #21499). 2014-05-13 12:18:07 -06:00
Eric Snow
2f46a0e8be Issue #21499: Ignore __builtins__ in several test_importlib.test_api tests. 2014-05-13 12:15:42 -06:00
Brett Cannon
732ac654c8 Issue #19721: Consolidate test_importlib utility code into a single
module.
2014-05-09 14:32:57 -04:00
Brett Cannon
91795c8e34 Issue #20776: Flesh out tests for importlib.machinery.PathFinder. 2014-05-09 13:38:11 -04:00
Brett Cannon
a04dbe4fe7 Issue #17621: Introduce importlib.util.LazyLoader. 2014-04-04 13:53:38 -04:00
Eric Snow
f269cc6b14 Issue #21097: Move test_namespace_pkgs into test_importlib. 2014-03-29 15:57:44 -06:00
Eric Snow
c4bbd7a492 Issue #21097: Move test_namespace_pkgs into test_importlib. 2014-03-29 15:57:44 -06:00
Benjamin Peterson
85736a7d2c merge 3.3 (#20796) 2014-02-27 13:50:28 -05:00
Benjamin Peterson
3673670b67 fix importlib test failure when bytecode writing is disabled (closes #20796)
Patch by Berker Peksag.
2014-02-27 13:49:34 -05:00
Brett Cannon
d3acef9bf4 Issue #20763: Fix importlib.machinery.PathFinder to support
PathEntryFinder instances which only define find_module().

Reported by Yukihiro Nakadaira.
2014-02-26 18:26:49 -05:00
Eric Snow
6029e08691 Issue 19944: Fix importlib.find_spec() so it imports parents as needed.
The function is also moved to importlib.util.
2014-01-25 15:32:46 -07:00
Brett Cannon
8d942296bb Issue #19719: Update various finder and loader ABCs such that their
old methods now provide implementations when PEP 451 APIs are present.

This should help with backwards-compatibility with code which has not
been updated to work with PEP 451.
2014-01-07 15:52:42 -05:00
Eric Snow
1500d49c22 Issue 19713: Add PEP 451-related deprecations. 2014-01-06 20:49:04 -07:00