Commit Graph

3748 Commits

Author SHA1 Message Date
Antoine Pitrou
22a1d17bb5 Fix another refleak 2012-04-16 22:06:21 +02:00
Antoine Pitrou
538ba2afb5 Fix a refleak 2012-04-16 21:52:45 +02:00
Antoine Pitrou
71382cb64b Fix reference loss on Py_None when None is encountered in sys.modules. 2012-04-16 18:48:49 +02:00
Antoine Pitrou
a938c74751 Avoid compiler warning due to stray \x00 2012-04-16 18:30:54 +02:00
Brian Curtin
b206a80dab Fix #10854. Make use of the new path and name attributes on ImportError
for extension modules on Windows.
2012-04-16 00:10:17 -05:00
Brett Cannon
2ee61422ed Issue #13959: Re-implement imp.load_package() in imp.py.
Thanks to Eric Snow for helping with imp.load_module() (previous
commit) which led to the removal of a bunch of C code.
2012-04-15 22:28:28 -04:00
Brett Cannon
01a76171a0 Issue #13959: Re-implement imp.load_module() in imp.py. 2012-04-15 20:25:23 -04:00
Brett Cannon
c1b3f63653 Try to get hg to treat importlib.h as binary. 2012-04-15 19:05:31 -04:00
Brett Cannon
8a1d04c643 Issue #13959: Simplify imp.reload() by relying on a module's
__loader__.

Since import now sets __loader__ on all modules it creates and
imp.reload() already relied on the attribute for modules that import
didn't create, the only potential compatibility issue is if people
were deleting the attribute on modules and expecting imp.reload() to
continue to work.
2012-04-15 17:56:09 -04:00
Brett Cannon
7ceedb8c1e Update importlib.h 2012-04-15 17:47:19 -04:00
Brett Cannon
6f44d66bc4 Issue #13959: Rename imp to _imp and add Lib/imp.py and begin
rewriting functionality in pure Python.

To start, imp.new_module() has been rewritten in pure Python, put into
importlib (privately) and then publicly exposed in imp.
2012-04-15 16:08:47 -04:00
Brett Cannon
881535b726 Issue #14582: Import returns the module returned by a loader instead
of sys.modules when possible.

This is being done for two reasons. One is to gain a little bit of
performance by skipping an unnecessary dict lookup in sys.modules. But
the other (and main) reason is to be a little bit more clear in how
things should work from the perspective of import's interactions with
loaders. Otherwise loaders can easily forget to return the module even
though PEP 302 explicitly states they are expected to return the module
they loaded.
2012-04-15 15:24:04 -04:00
Brett Cannon
27fc52877c Set ImportError.name when raising the exception in the case of None
found in sys.modules.
2012-04-15 14:15:31 -04:00
Brett Cannon
fc9ca274b8 Plug a refleak. 2012-04-15 01:35:05 -04:00
Brett Cannon
49f8d8b016 Handle importing pkg.mod by executing
__import__('mod', {'__packaging__': 'pkg', level=1) w/o properly (and
thus not segfaulting).
2012-04-14 21:50:00 -04:00
Brett Cannon
59f9c3affc Rebuild importlib.h to incorporate added comments. 2012-04-14 21:18:48 -04:00
Brian Curtin
e6b299faf5 Fix Windows build 2012-04-14 14:19:33 -05:00
Brett Cannon
740fce0e38 Undo a C99 idiom. 2012-04-14 14:23:49 -04:00
Brett Cannon
fd0741555b Issue #2377: Make importlib the implementation of __import__().
importlib._bootstrap is now frozen into Python/importlib.h and stored
as _frozen_importlib in sys.modules. Py_Initialize() loads the frozen
code along with sys and imp and then uses _frozen_importlib._install()
to set builtins.__import__() w/ _frozen_importlib.__import__().
2012-04-14 14:10:13 -04:00
Benjamin Peterson
780b66b3e6 merge 3.2 2012-04-13 18:06:42 -04:00
Benjamin Peterson
3bf01757b6 move outside WITH_THREAD conditional 2012-04-13 18:06:36 -04:00
Benjamin Peterson
899ee613f7 merge 3.2 2012-04-13 11:59:52 -04:00
Benjamin Peterson
43162b8a02 take linkage def outside of WITH_THREAD conditional (closes #14569) 2012-04-13 11:58:27 -04:00
Brett Cannon
79ec55e980 Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Currently import does not use these attributes as they are planned
for use by importlib (which will be another commit).

Thanks to Filip Gruszczyński for the initial patch and Brian Curtin
for refining it.
2012-04-12 20:24:54 -04:00
Kristján Valur Jónsson
31668b8f7a Issue #14288: Serialization support for builtin iterators. 2012-04-03 10:49:41 +00:00