summaryrefslogtreecommitdiffstats
path: root/Python/importlib.h
Commit message (Collapse)AuthorAgeFilesLines
...
| * 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.
* | Issue #18070: importlib.util.module_for_loader() now sets __loader__Brett Cannon2013-05-281-3432/+3413
| | | | | | | | | | and __package__ unconditionally in order to do the right thing for reloading.
* | Update importlib.hBrett Cannon2013-05-281-2676/+2675
| |
* | Introduce importlib.util.ModuleManager which is a context manager toBrett Cannon2013-05-281-3328/+3400
| | | | | | | | | | | | | | | | handle providing (and cleaning up if needed) the module to be loaded. A future commit will use the context manager in Lib/importlib/_bootstrap.py and thus why the code is placed there instead of in Lib/importlib/util.py.
* | rather than passing locals to the class body, just execute the class body in ↵Benjamin Peterson2013-05-161-3131/+3121
| | | | | | | | the proper environment
* | hide the __class__ closure from the class body (#12370)Benjamin Peterson2013-05-151-119/+119
| |
* | #17115,17116: Have modules initialize the __package__ and __loader__Brett Cannon2013-05-041-181/+182
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | attributes to None. The long-term goal is for people to be able to rely on these attributes existing and checking for None to see if they have been set. Since import itself sets these attributes when a loader does not the only instances when the attributes are None are from someone overloading __import__() and not using a loader or someone creating a module from scratch. This patch also unifies module initialization. Before you could have different attributes with default values depending on how the module object was created. Now the only way to not get the same default set of attributes is to circumvent initialization by calling ModuleType.__new__() directly.
* | check local class namespace before reaching for cells (closes #17853)Benjamin Peterson2013-04-301-119/+119
| |
* | Issue #17244: Don't mask exceptions raised during the creation ofBrett Cannon2013-04-141-3467/+3479
| | | | | | | | | | | | bytecode files in py_compile. Thanks to Arfrever Frehtes Taifersar Arahesis for the bug report.
* | Issue #17093,17566,17567: Methods from classes in importlib.abc now raise/returnBrett Cannon2013-04-091-1769/+1776
| | | | | | | | | | | | | | | | | | | | the default exception/value when called instead of raising/returning NotimplementedError/NotImplemented (except where appropriate). This should allow for the ABCs to act as the bottom/end of the MRO with expected default results. As part of this work, also make importlib.abc.Loader.module_repr() optional instead of an abstractmethod.
* | mergeBrett Cannon2013-04-011-3448/+3457
|\ \ | |/
| * Issue #17357: Add missing verbosity messages when running underBrett Cannon2013-04-011-4268/+4281
| | | | | | | | -v/-vv that were lost in the transition to importlib.
* | update importlib.hBenjamin Peterson2013-03-271-117/+117
| |
* | copy 2.7 magic numbers for historical interestBenjamin Peterson2013-03-221-4092/+3158
| |
* | make some freezing related stuff constBenjamin Peterson2013-03-131-1/+1
| |
* | Issue #17117: Have both import itself and importlib.util.set_loader()Brett Cannon2013-03-131-3325/+3320
| | | | | | | | | | | | set __loader__ on a module when set to None. Thanks to Gökcen Eraslan for the fix.
* | Issue #17220: two fixes for changeset 2528e4aea338.Brett Cannon2013-02-251-4190/+4192
| | | | | | | | | | | | | | | | | | First, because the mtime can exceed 4 bytes, make sure to mask it down to 4 bytes before getting its little-endian representation for writing out to a .pyc file. Two, cap an rsplit() call to 1 split, else can lead to too many values being returned for unpacking.
* | Issue #17220: Little cleanup of _bootstrap.py.Serhiy Storchaka2013-02-251-4314/+4296
| |
* | Merge importlib.h rebuild from 3.3 after the changes introduced in 65eaac000147.Ezio Melotti2013-02-201-1087/+1084
|\ \ | |/
| * Rebuild importlib.h after the changes introduced in 0f65bf6063ca.Ezio Melotti2013-02-201-1092/+1089
| |
* | evaluate lambda keyword-only defaults after positional defaults (#16967 again)Benjamin Peterson2013-02-101-1/+1
| |
* | evaluate positional defaults before keyword-only defaults (closes #16967)Benjamin Peterson2013-02-101-119/+119
| |
* | Merge w/ 3.3 more fixes thanks to issue #17098Brett Cannon2013-02-011-269/+282
|\ \ | |/
| * Issue #17098: Be more stringent of setting __loader__ on early importedBrett Cannon2013-02-011-292/+299
| | | | | | | | modules. Also made test more rigorous.
| * Issue #17098: Make sure every module has __loader__ defined.Brett Cannon2013-02-011-283/+289
| | | | | | | | Thanks to Thomas Heller for the bug report.
* | Tweak an exception messageBrett Cannon2013-01-271-2943/+2943
| |
* | Port py_compile over to importlibBrett Cannon2013-01-261-4269/+4295
| |
* | Touch up exception messagingBrett Cannon2013-01-251-2921/+2923
| |
* | Issue #15031: Refactor some code in importlib pertaining to validatingBrett Cannon2013-01-111-4226/+4262
| | | | | | | | | | | | | | and compiling bytecode. Thanks to Ronan Lamy for pointing the redundancy and taking an initial stab at the refactor (as did Nick Coghlan).
* | Merge from 3.3 for fix for issue #16730Brett Cannon2013-01-111-938/+941
|\ \ | |/
| * Issue #16730: Don't raise an exception inBrett Cannon2013-01-111-943/+946
| | | | | | | | | | | | | | | | importlib.machinery.FileFinder when the directory has become unreadable or a file. This brings semantics in line with Python 3.2 import. Reported and diagnosed by David Pritchard.
* | Replace IOError with OSError (#16715)Andrew Svetlov2012-12-251-2/+2
| |
* | update importlib.hBenjamin Peterson2012-12-191-2633/+2632
| |
* | Issue #16706: get rid of os.errorAndrew Svetlov2012-12-181-4034/+3999
| |
* | Issue #15627: This is simply an update to the name of a new method recently ↵Eric Snow2012-12-051-8/+8
| | | | | | | | | | | | added to importlib.abc.SourceLoader.