Commit Graph

124 Commits

Author SHA1 Message Date
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