Brett Cannon
f5fe13099e
Update importlib.h
2013-05-28 17:50:04 -04:00
Brett Cannon
a3687f0d68
Introduce importlib.util.ModuleManager which is a context manager to
...
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.
2013-05-28 17:29:34 -04:00
Benjamin Peterson
e8e14591eb
rather than passing locals to the class body, just execute the class body in the proper environment
2013-05-16 14:37:25 -05:00
Benjamin Peterson
312595ce3a
hide the __class__ closure from the class body ( #12370 )
2013-05-15 15:26:42 -05:00
Brett Cannon
4c14b5de1c
#17115,17116: Have modules initialize the __package__ and __loader__
...
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.
2013-05-04 13:56:58 -04:00
Benjamin Peterson
3b0431dc60
check local class namespace before reaching for cells ( closes #17853 )
2013-04-30 09:41:40 -04:00
Brett Cannon
edfd6ae79c
Issue #17244 : Don't mask exceptions raised during the creation of
...
bytecode files in py_compile.
Thanks to Arfrever Frehtes Taifersar Arahesis for the bug report.
2013-04-14 12:48:15 -04:00
Brett Cannon
100883f0cb
Issue #17093,17566,17567: Methods from classes in importlib.abc now raise/return
...
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.
2013-04-09 16:59:39 -04:00
Brett Cannon
daf4daa295
merge
2013-04-01 13:25:40 -04:00
Brett Cannon
f8ffec0617
Issue #17357 : Add missing verbosity messages when running under
...
-v/-vv that were lost in the transition to importlib.
2013-04-01 13:10:51 -04:00
Benjamin Peterson
d0924b3d38
update importlib.h
2013-03-27 17:53:17 -04:00
Benjamin Peterson
440282ba8a
copy 2.7 magic numbers for historical interest
2013-03-21 23:04:45 -05:00
Benjamin Peterson
7701e6ef93
make some freezing related stuff const
2013-03-13 14:06:39 -05:00
Brett Cannon
4802becb16
Issue #17117 : Have both import itself and importlib.util.set_loader()
...
set __loader__ on a module when set to None.
Thanks to Gökcen Eraslan for the fix.
2013-03-13 10:41:36 -07:00
Brett Cannon
c190389834
Issue #17220 : two fixes for changeset 2528e4aea338.
...
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.
2013-02-25 17:10:11 -05:00
Serhiy Storchaka
39e47f94ec
Issue #17220 : Little cleanup of _bootstrap.py.
2013-02-25 15:40:33 +02:00
Ezio Melotti
92bd4ef640
Merge importlib.h rebuild from 3.3 after the changes introduced in 65eaac000147.
2013-02-20 22:15:47 +02:00
Ezio Melotti
795c10b3b6
Rebuild importlib.h after the changes introduced in 0f65bf6063ca.
2013-02-20 21:42:46 +02:00
Benjamin Peterson
419d9a83d5
evaluate lambda keyword-only defaults after positional defaults ( #16967 again)
2013-02-10 09:48:22 -05:00
Benjamin Peterson
1ef876cd28
evaluate positional defaults before keyword-only defaults ( closes #16967 )
2013-02-10 09:29:59 -05:00
Brett Cannon
85ae3566d1
Merge w/ 3.3 more fixes thanks to issue #17098
2013-02-01 16:36:29 -05:00
Brett Cannon
da9cf0eef8
Issue #17098 : Be more stringent of setting __loader__ on early imported
...
modules. Also made test more rigorous.
2013-02-01 15:31:49 -05:00
Brett Cannon
0ecd30b4af
Issue #17098 : Make sure every module has __loader__ defined.
...
Thanks to Thomas Heller for the bug report.
2013-02-01 14:04:12 -05:00
Brett Cannon
f3220d6af7
Tweak an exception message
2013-01-27 13:04:56 -05:00
Brett Cannon
14581d5dc4
Port py_compile over to importlib
2013-01-26 08:48:36 -05:00
Brett Cannon
686e880f20
Touch up exception messaging
2013-01-25 13:49:19 -05:00
Brett Cannon
569ff4fbbc
Issue #15031 : Refactor some code in importlib pertaining to validating
...
and compiling bytecode.
Thanks to Ronan Lamy for pointing the redundancy and taking an initial
stab at the refactor (as did Nick Coghlan).
2013-01-11 18:09:25 -05:00
Brett Cannon
c57f9f9419
Merge from 3.3 for fix for issue #16730
2013-01-11 15:42:30 -05:00
Brett Cannon
a9976b3e32
Issue #16730 : Don't raise an exception in
...
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.
2013-01-11 15:40:12 -05:00
Andrew Svetlov
f7a17b48d7
Replace IOError with OSError ( #16715 )
2012-12-25 16:47:37 +02:00
Benjamin Peterson
fc8f5c5e0f
update importlib.h
2012-12-19 15:16:51 -06:00
Andrew Svetlov
ad28c7f9da
Issue #16706 : get rid of os.error
2012-12-18 22:02:39 +02:00
Eric Snow
a6cfb28bd2
Issue #15627 : This is simply an update to the name of a new method recently added
...
to importlib.abc.SourceLoader.
2012-12-04 23:43:43 -08:00
Barry Warsaw
b72c10996e
- Issue #16514 : Fix regression causing a traceback when sys.path[0] is None
...
(actually, any non-string or non-bytes type).
2012-11-20 15:35:27 -05:00
Barry Warsaw
82c1c781c7
- Issue #16514 : Fix regression causing a traceback when sys.path[0] is None
...
(actually, any non-string or non-bytes type).
2012-11-20 15:22:51 -05:00
Brett Cannon
540187f719
Regen importlib.h
2012-11-18 10:27:12 -05:00
Brett Cannon
5650e4f41c
Issue #15627 : Add the compile_source() method to
...
importlib.abc.SourceLoader.
This provides an easy hook into the import system to allow for source
transformations, AST optimizations, etc.
2012-11-18 10:03:31 -05:00
Benjamin Peterson
c7a8a210d6
merge 3.3 (sort of)
2012-11-12 17:04:28 -05:00
Benjamin Peterson
2a0e226131
recompile importlib.h
2012-11-12 17:02:32 -05:00
Nick Coghlan
d4f5ad6c6e
Merge fix from #6074 from 3.3
2012-10-19 23:36:15 +10:00
Nick Coghlan
eb8d627bbd
Issue #6074 : Apply an appropriate fix for importlib based imports
2012-10-19 23:32:00 +10:00
Trent Nelson
744faddae8
Merge issue #15833 : don't raise an exception if importlib can't write
...
byte-compiled files.
This fixes a regression introduced by 3.3.
Patch by Charles-François Natali.
2012-10-16 08:03:21 -04:00
Trent Nelson
d783c8ed00
Issue #15833 : don't raise an exception if importlib can't write byte-compiled
...
files.
This fixes a regression introduced by 3.3. Patch by Charles-François Natali.
2012-10-16 07:47:34 -04:00
Brett Cannon
6072e0bf42
Remove uses of % with str.format.
2012-10-12 10:00:34 -04:00
Brett Cannon
9407d50208
Merge fix for issue #15111 .
2012-10-10 19:18:37 -04:00
Brett Cannon
a6ce4fd426
Closes issue #15111 : Calling __import__ with a module specified in
...
fromlist which causes its own ImportError (e.g. the module tries to
import a non-existent module) should have that exception propagate.
2012-10-10 19:03:46 -04:00
Jesus Cea
f01d695ccd
Closes #16135 : Removal of OS/2 support
2012-10-05 03:36:11 +02:00
Brett Cannon
8ed677db12
Add some comments.
2012-09-28 16:41:39 -04:00
Benjamin Peterson
feaa54f537
don't depend on __debug__ because it's baked in at freeze time (issue #16046 )
2012-09-25 11:22:59 -04:00
Antoine Pitrou
4f0338cab7
Issue #15781 : Fix two small race conditions in import's module locking.
2012-08-28 00:24:52 +02:00