summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_import
Commit message (Collapse)AuthorAgeFilesLines
* [3.8] bpo-37409: fix relative import with no parent (GH-14956) (GH-15913)Miss Islington (bot)2019-09-111-0/+5
| | | | | | | | | | | | | | | | | | | Relative imports use resolve_name to get the absolute target name, which first seeks the current module's absolute package name from the globals: If __package__ (and __spec__.parent) are missing then import uses __name__, truncating the last segment if the module is a submodule rather than a package __init__.py (which it guesses from whether __path__ is defined). The __name__ attempt should fail if there is no parent package (top level modules), if __name__ is '__main__' (-m entry points), or both (scripts). That is, if both __name__ has no subcomponents and the module does not seem to be a package __init__ module then import should fail.. (cherry picked from commit 92420b3e679959a7d0ce875875601a4cee45231e) Co-authored-by: Ben Lewis <benjimin@users.noreply.github.com> (cherry picked from commit 0a6693a469cfb1dd5c8048d8cb4231a7b5883251) Co-authored-by: Brett Cannon <54418+brettcannon@users.noreply.github.com>
* Revert "Remove unused imports in tests (GH-14518) (GH-14522)" (GH-14555)Victor Stinner2019-07-021-3/+4
| | | This reverts commit e34b5f4d6483187969d5149c801d056b72ef2ddb.
* Remove unused imports in tests (GH-14518) (GH-14522)Victor Stinner2019-07-011-4/+3
| | | (cherry picked from commit 8f4ef3b019ce380022018587571b0f970e668de3)
* bpo-33465: Use an unlikely to be built-in C extension in a test (GH-6797) ↵Miss Islington (bot)2018-05-151-5/+6
| | | | | | | (#6869) (cherry picked from commit 8709b236fc997077d24b4802320db287640f82e2) Co-authored-by: Barry Warsaw <barry@python.org>
* bpo-33053: -m now adds *starting* directory to sys.path (GH-6231) (#6236)Nick Coghlan2018-03-251-2/+5
| | | | | | | | | | | | | | Historically, -m added the empty string as sys.path zero, meaning it resolved imports against the current working directory, the same way -c and the interactive prompt do. This changes the sys.path initialisation to add the *starting* working directory as sys.path[0] instead, such that changes to the working directory while the program is running will have no effect on imports when using the -m switch. (cherry picked from commit d5d9e02dd3c6df06a8dd9ce75ee9b52976420a8b)
* closes bpo-31650: PEP 552 (Deterministic pycs) implementation (#4575)Benjamin Peterson2017-12-091-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | Python now supports checking bytecode cache up-to-dateness with a hash of the source contents rather than volatile source metadata. See the PEP for details. While a fairly straightforward idea, quite a lot of code had to be modified due to the pervasiveness of pyc implementation details in the codebase. Changes in this commit include: - The core changes to importlib to understand how to read, validate, and regenerate hash-based pycs. - Support for generating hash-based pycs in py_compile and compileall. - Modifications to our siphash implementation to support passing a custom key. We then expose it to importlib through _imp. - Updates to all places in the interpreter, standard library, and tests that manually generate or parse pyc files to grok the new format. - Support in the interpreter command line code for long options like --check-hash-based-pycs. - Tests and documentation for all of the above.
* bpo-31492: Fix assertion failures in case of a module with a bad __name__ ↵Oren Milman2017-09-191-0/+12
| | | | attribute. (#3620)
* bpo-31286, bpo-30024: Fixed stack usage in absolute imports with (#3217)Serhiy Storchaka2017-08-291-0/+17
| | | binding a submodule to a name.
* bpo-30876: Relative import from unloaded package now reimports the package ↵Serhiy Storchaka2017-07-123-3/+21
| | | | | | | | | (#2639) instead of failing with SystemError. Relative import from non-package now fails with ImportError rather than SystemError.
* bpo-30814: Fixed a race condition when import a submodule from a package. ↵Serhiy Storchaka2017-07-063-0/+30
| | | | (#2580)
* Fix skipping test_UNC_path on AppVeyor due to a different error being raised ↵Segev Finer2017-06-021-1/+1
| | | | | | (#1920) We get `ERROR_BAD_NETPATH` (53) on AppVeyor which is translated to ENOENT (2).
* bpo-30024: Circular imports involving absolute imports with binding (#1264)Serhiy Storchaka2017-05-093-0/+8
| | | a submodule to a name are now supported.
* bpo-29693: Fix for DeprecationWarning in test_import (#421)Anish Shah2017-03-031-2/+2
| | | Patch by Anish Shah.
* use select instead of _opcode for import test (#372)Benjamin Peterson2017-03-011-5/+5
|
* weaken test_from_import_missing_attr_has_name_and_path regular expression (#371)Benjamin Peterson2017-03-011-1/+1
| | | Windows uses backslashes for separators.
* bpo-29546: Improve from-import error message with location (#103)Matthias Bussonnier2017-02-221-1/+13
| | | | bpo-29546: Improve from-import error message with location
* bpo-29546: Set 'path' on ImportError for ``from ... import ...`` (GH-91)Matthias Bussonnier2017-02-151-0/+19
|
* Remove unused imports.Serhiy Storchaka2016-12-161-1/+0
|
* Issue #15767: Use ModuleNotFoundError.Eric Snow2016-09-071-0/+12
|
* Issue #26583: Skip test_timestamp_overflow in test_import if bytecodeNed Deily2016-03-171-0/+1
| | | | files cannot be written.
* Issue #24492: make sure that ``from ... import ...` raises anBrett Cannon2015-08-121-0/+13
| | | | | | ImportError if __name__ is not defined on a package. Thanks to Armin Rigo for the bug report and diagnosing the cause.
* Issue #9517: Move script_helper to the support package.Berker Peksag2015-05-061-3/+4
| | | | Patch by Christie Wilson.
* Issue #23911: Move path-based bootstrap code to a separate frozen module.Eric Snow2015-05-031-6/+14
|
* Issue #21483: Skip test_timestamp_overflow on NFS.Berker Peksag2015-04-221-1/+2
| | | | Patch by Isaac Schwabacher.
* Issue #23731: Implement PEP 488.Brett Cannon2015-04-131-21/+16
| | | | | | 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.
* WhitespaceAntoine Pitrou2014-10-137-7/+7
|
* Issue #17636: Circular imports involving relative imports are now supported.Antoine Pitrou2014-10-1311-0/+1134