summaryrefslogtreecommitdiffstats
path: root/Python/importlib.h
Commit message (Collapse)AuthorAgeFilesLines
* - Issue #22966: Fix __pycache__ pyc file name clobber when pyc_compile isBarry Warsaw2014-12-011-3611/+3612
| | | | | asked to compile a source file containing multiple dots in the source file name.
* Issue #21226: Set all attrs in PyImport_ExecCodeModuleObject.Eric Snow2014-05-121-4248/+4275
|
* Issue #20763: Fix importlib.machinery.PathFinder to supportBrett Cannon2014-02-261-1/+1
| | | | | | PathEntryFinder instances which only define find_module(). Reported by Yukihiro Nakadaira.
* update magic number for #20625Benjamin Peterson2014-02-191-160/+160
|
* Issue 19713: Remove PEP 451-related code that should have been factored out.Eric Snow2014-01-081-1216/+1187
| | | | | | This code was an artifact of issuing a DeprecationWarning for the lack of loader.exec_module(). However, we have deferred such warnings to later Python versions.
* Issue #20141: Improved Argument Clinic's support for the PyArg_Parse "O!"Larry Hastings2014-01-071-4357/+4342
| | | | format unit.
* Issue 19713: Add PEP 451-related deprecations.Eric Snow2014-01-071-3943/+4031
|
* Issue #19927: Add __eq__ to path-based loaders in importlib.Eric Snow2014-01-041-619/+659
|
* Issue #20097: Fix bad use of "self" in importlib's WindowsRegistryFinder.Eric Snow2014-01-031-1860/+1860
|
* Remove some dead code in importlib, introduced with the PEP 451 patch.Eric Snow2013-12-191-986/+980
| | | | | | | Early in the PEP 451 implementation some of the importlib loaders had their own _get_spec() methods to simplify accommodating them. However, later implementations removed the need. They simply failed to remove this code at the same time. :)
* Issue #18864: Add a setter for ModuleSpec.has_location.Eric Snow2013-12-111-2909/+2918
|
* Issue #19698: Remove exec_module() from the built-in and extensionBrett Cannon2013-11-291-4160/+4195
| | | | | | | | | | | | | module loaders. Due to the fact that the call signatures for extension modules and built-in modules does not allow for the specifying of what module to initialize and that on Windows all extension modules are built-in modules, work to clean up built-in and extension module initialization will have to wait until Python 3.5. Because of this the semantics of exec_module() would be incorrect, so removing the methods for now is the best option; load_module() is still used as a fallback by importlib and so this won't affect semantics.
* User the repr for a module name in more placesBrett Cannon2013-11-221-3282/+3283
|
* Remove a commented-out lineBrett Cannon2013-11-221-125/+125
|
* Don't assume trying to find a builtin will succeed (e.g. posix isn't on Windows)Brett Cannon2013-11-221-194/+198
|
* Implement PEP 451 (ModuleSpec).Eric Snow2013-11-221-3322/+4083
|
* Abstract out stat calls in importlib for easier experimentation.Brett Cannon2013-11-011-2733/+2747
|
* Issue #19410: Put back in special-casing of '' forBrett Cannon2013-11-011-793/+793
| | | | | | | | | importlib.machinery.FileFinder. While originally moved to stop special-casing '' as PathFinder farther up the typical call chain now uses the cwd in the instance of '', it was deemed an unnecessary risk to breaking subclasses of FileFinder to take the special-casing out.
* Issue #19413: Restore pre-3.3 reload() semantics of re-finding modules.Eric Snow2013-11-011-503/+508
|
* cleanup the construction of __qualname__ (closes #19301 again)Benjamin Peterson2013-10-201-135/+135
|
* give explicitly global functions and classes a global __qualname__ (closes ↵Benjamin Peterson2013-10-191-3433/+3210
| | | | #19301)
* Issue #18810: Be optimistic with stat calls when seeing if a directoryBrett Cannon2013-10-181-769/+768
| | | | | | | | | | | | | | | | | | | exists when checking for a package. Before there was an isdir check and then various isfile checks for possible __init__ files when looking for a package. This change drops the isdir check by leaning on the assumption that a directory will not contain something named after the module being imported which is not a directory. If the module is a package then it saves a stat call. If there is nothing in the directory with the potential package name it also saves a stat call. Only if there is something in the directory named the same thing as the potential package will the number of stat calls increase (due to more wasteful __init__ checks). Semantically there is no change as the isdir check moved down so that namespace packages continue to have no chance of accidentally collecting non-existent directories.
* Issue #18416: Fix various os calls in importlib.machinery.FileFinderBrett Cannon2013-10-181-776/+778
| | | | now that self.path is no longer forced to '.'.
* Issue #18416: Have importlib.machinery.PathFinder treat '' as the cwdBrett Cannon2013-10-181-3219/+3442
| | | | | | | | | | | | | | | | | | | and stop importlib.machinery.FileFinder treating '' as '.'. Previous PathFinder transformed '' into '.' which led to __file__ for modules imported from the cwd to always be relative paths. This meant the values of the attribute were wrong as soon as the cwd changed. This change now means that as long as the site module is run (which makes all entries in sys.path absolute) then all values for __file__ will also be absolute unless it's for __main__ when specified by file path in a relative way (modules imported by runpy will have an absolute path). Now that PathFinder is no longer treating '' as '.' it only makes sense for FileFinder to stop doing so as well. Now no transformation is performed for the directory given to the __init__ method. Thanks to Madison May for the initial patch.
* Issue #19219: Speed up marshal.loads(), and make pyc files slightly (5% to ↵Antoine Pitrou2013-10-121-3423/+3200
| | | | 10%) smaller.
* [issue19152] Add ExtensionFileLoader.get_filename().Eric Snow2013-10-031-1348/+1362
|
* [issue19951] Fix docstring and use of _get_suppported_file_loaders() to ↵Eric Snow2013-10-031-1931/+1929
| | | | reflect 2-tuples.
* Issue #16826: Revert fix while Windows issues are being worked out.Meador Inge2013-09-041-3119/+3115
|\
| * Issue #16826: Revert fix while Windows issues are being worked out.Meador Inge2013-09-041-4206/+4201
| |
* | Issue #16826: Don't check for PYTHONCASEOK when using -E.Meador Inge2013-09-031-3115/+3119
|\ \ | |/ | | | | | | This commit fixes a regression that sneaked into Python 3.3 where importlib was not respecting -E when checking for the PYTHONCASEOK environment variable.
| * Issue #16826: Don't check for PYTHONCASEOK when using -E.Meador Inge2013-09-031-4201/+4206
| | | | | | | | | | This commit fixes a regression that sneaked into Python 3.3 where importlib was not respecting -E when checking for the PYTHONCASEOK environment variable.
* | Issue #18415: Normalize what type of quotes are used with stringBrett Cannon2013-07-121-6/+6
| | | | | | | | | | | | | | constants in importlib._bootstrap. Along the way clean up from string interpolation to use the repr explicitly. Initial patch by Madison May.
* | merge for issue #18351.Brett Cannon2013-07-061-801/+799
|\ \ | |/
| * Issue #18351: Fix various issues withBrett Cannon2013-07-061-3369/+3367
| | | | | | | | | | | | | | | | | | importlib._bootstrap._get_sourcefile(). Thanks to its only use by the C API, it was never properly tested until now. Thanks to Neal Norwitz for discovering the bug and Madison May for the patch.
| * Fix a misnaming of a method and an argumentBrett Cannon2013-06-161-1071/+1071
| |
* | Issue #18364: Stop using the ImportError._not_found hack.Brett Cannon2013-07-061-3547/+3547
| | | | | | | | | | | | The private attribute was leaking out of importlib and led to at least one person noticing it. Switch to another hack which won't leak outside of importlib and is nearly as robust.
* | Issue #15767: back out 8a0ed9f63c6e, finishing the removal ofBrett Cannon2013-07-041-370/+374
| | | | | | | | ModuleNotFoundError.
* | Issue #15767: Revert 3a50025f1900 for ModuleNotFoundErrorBrett Cannon2013-07-041-794/+793
| |
* | Issue #18076: Introduce imoportlib.util.decode_source().Brett Cannon2013-06-161-3549/+3566
| | | | | | | | | | | | | | The helper function makes it easier to implement imoprtlib.abc.InspectLoader.get_source() by making that function require just the raw bytes for source code and handling all other details.
* | importlib.abc.SourceLoader.get_source() was re-raising SyntaxError andBrett Cannon2013-06-161-1719/+1703
| | | | | | | | | | | | | | | | | | UnicodeDecodeError as ImportError. That was over-reaching the point of raising ImportError in get_source() (which is to signal the source code was not found when it should have). Conflating the two exceptions with ImportError could lead to masking errors with the source which should be known outside of whether there was an error simply getting the source to begin with.
* | Issue #18115: Abstract out managing the cleanup of modules to use inBrett Cannon2013-06-161-2437/+2468
| | | | | | | | loaders where C code provides the loaded module.
* | Issues #18058, 18057: Make importlib._bootstrap.NamespaceLoaderBrett Cannon2013-06-161-1072/+1113
| | | | | | | | | | conform the the InspectLoader ABC. Perk of this is that runpy/-m can now work with namespace packages.
* | Issue #17907: touch up the code for imp.new_module().Brett Cannon2013-06-151-3532/+3519
| |
* | Issue #18192: Introduce importlib.util.MAGIC_NUMBER and document theBrett Cannon2013-06-141-2/+2
| | | | | | | | deprecation of imp.get_magic().
* | Issue #15767: Touch up ModuleNotFoundError usage by import.Brett Cannon2013-06-131-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | Forgot to raise ModuleNotFoundError when None is found in sys.modules. This led to introducing the C function PyErr_SetImportErrorSubclass() to make setting ModuleNotFoundError easier. Also updated the reference docs to mention ModuleNotFoundError appropriately. Updated the docs for ModuleNotFoundError to mention the None in sys.modules case. Lastly, it was noticed that PyErr_SetImportError() was not setting an exception when returning None in one case. That issue is now fixed.
* | Issue #15767: Introduce ModuleNotFoundError, a subclass ofBrett Cannon2013-06-121-370/+367
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ImportError. The exception is raised by import when a module could not be found. Technically this is defined as no viable loader could be found for the specified module. This includes ``from ... import`` statements so that the module usage is consistent for all situations where import couldn't find what was requested. This should allow for the common idiom of:: try: import something except ImportError: pass to be updated to using ModuleNotFoundError and not accidentally mask ImportError messages that should propagate (e.g. issues with a loader). This work was driven by the fact that the ``from ... import`` statement needed to be able to tell the difference between an ImportError that simply couldn't find a module (and thus silence the exception so that ceval can raise it) and an ImportError that represented an actual problem.
* | tweak exception message (again)Brett Cannon2013-06-051-2304/+2305
| |
* | Tweak at the suggestion of Ezio Melotti for exception messages whenBrett Cannon2013-06-041-2300/+2302
| | | | | | | | EOF is hit while trying to read the header of a bytecode file.
* | Issues #18088, 18089: IntroduceBrett Cannon2013-05-311-3519/+3511
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | importlib.abc.Loader.init_module_attrs() and implement importlib.abc.InspectLoader.load_module(). The importlib.abc.Loader.init_module_attrs() method sets the various attributes on the module being loaded. It is done unconditionally to support reloading. Typically people used importlib.util.module_for_loader, but since that's a decorator there was no way to override it's actions, so init_module_attrs() came into existence to allow for overriding. This is also why module_for_loader is now pending deprecation (having its other use replaced by importlib.util.module_to_load). All of this allowed for importlib.abc.InspectLoader.load_module() to be implemented. At this point you can now implement a loader with nothing more than get_code() (which only requires get_source(); package support requires is_package()). Thanks to init_module_attrs() the implementation of load_module() is basically a context manager containing 2 methods calls, a call to exec(), and a return statement.
* | Rename importlib.util.ModuleManager to module_to_load so that the nameBrett Cannon2013-05-301-3509/+3522
| | | | | | | | explains better what the context manager is providing.