Commit Graph

563 Commits

Author SHA1 Message Date
Brett Cannon 82da8886cc Issue #15767: Revert 3a50025f1900 for ModuleNotFoundError 2013-07-04 17:48:16 -04:00
Christian Heimes 582cfbbf74 import.c does neither need mode_t nor _mkdir() anymore 2013-06-23 15:53:09 +02:00
Brett Cannon 8f5ac5106e Issue #15767: Touch up ModuleNotFoundError usage by import.
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.
2013-06-12 23:29:18 -04:00
Brett Cannon 3e0651b5fa Issue #18065: For frozen packages set __path__ to [].
Previously __path__ was set to [__name__], but that could lead to bad
results if someone managed to circumvent the frozen importer and
somehow ended up with a finder that thought __name__ was a legit
directory/location.
2013-05-31 23:18:39 -04:00
Antoine Pitrou fef34e3186 Issue #17937: Try harder to collect cyclic garbage at shutdown. 2013-05-19 01:11:58 +02:00
Antoine Pitrou 070cb3c9be Issue #1545463: At shutdown, defer finalization of codec modules so that stderr remains usable.
(should fix Windows buildbot failures on test_gc)
2013-05-08 13:23:25 +02:00
Antoine Pitrou 5f454a07a0 Issue #1545463: Global variables caught in reference cycles are now garbage-collected at shutdown. 2013-05-06 21:15:57 +02:00
Alexandre Vassalotti 865eaa1b53 Closes #17892: Fix the name of _PyObject_CallMethodObjIdArgs 2013-05-02 10:44:04 -07:00
Benjamin Peterson 5c089314ef merge 3.3 2013-04-29 09:08:33 -04:00
Benjamin Peterson 7d110042c5 raise an ImportError (rather than fatal) when __import__ is not found in __builtins__ (closes #17867) 2013-04-29 09:08:14 -04:00
Benjamin Peterson 6fba3dbce0 sprinkle const 2013-03-18 23:13:31 -07:00
Antoine Pitrou ad8c461e2c Add sanity assertions in some import lock code (issue #15599). 2012-12-18 22:18:58 +01:00
Antoine Pitrou 202b60640b Add sanity assertions in some import lock code (issue #15599). 2012-12-18 22:18:17 +01:00
Benjamin Peterson 5cb8a31dc4 cleanup and fix refleaks 2012-12-15 00:05:16 -05:00
Andrew Svetlov 6b2cbeba58 Issue #16421: allow to load multiple modules from the same shared object.
Patch by Václav Šmilauer.
2012-12-14 17:04:59 +02:00
Brett Cannon e4710cfced Issue #15894: Document why we don't worry about re-acquiring the
global import lock after forking.
2012-11-15 21:39:36 -05:00
Antoine Pitrou 0398985920 Issue #15781: Fix two small race conditions in import's module locking. 2012-08-28 00:24:52 +02:00
Brett Cannon ecfefb7956 Fix a spelling mistake in a comment. 2012-08-05 19:24:57 -04:00
Antoine Pitrou c4d974d3fa Remove unused variable `trim_get_code`. 2012-08-04 23:26:25 +02:00
Nick Coghlan 42c0766a53 Close #15486: Simplify the mechanism used to remove importlib frames from tracebacks when they just introduce irrelevant noise 2012-07-31 21:14:18 +10:00
Nick Coghlan 5ee9892406 Close #15425: Eliminate more importlib related traceback noise 2012-07-29 20:30:36 +10:00
Brett Cannon a6473f9cfd Issues #15169, #14599: Make PyImport_ExecCodeModuleWithPathnames() use
Lib/imp.py for imp.source_from_cache() instead of its own C version.

Also change PyImport_ExecCodeModuleObject() to not infer the source
path from the bytecode path like
PyImport_ExecCodeModuleWithPathnames() does. This makes the function
less magical.

This also has the side-effect of removing all uses of MAXPATHLEN in
Python/import.c which can cause failures on really long filenames.
2012-07-13 13:57:03 -04:00
Antoine Pitrou 44b4b6a9a5 Fix compilation under Windows 2012-07-10 18:27:54 +02:00
Benjamin Peterson 66f3659c9e fix refleak 2012-07-09 22:21:55 -07:00
Benjamin Peterson fa873704a4 initialize variable for compiler happiness 2012-07-09 13:43:53 -07:00
Brett Cannon 77b2abd094 Issue #15167 (as part of #13959): imp.get_magic() is no implemented in
Lib/imp.py.
2012-07-09 16:09:00 -04:00
Brett Cannon 3adc7b75a5 Issue #15242: Have PyImport_GetMagicTag() return a const char *
defined in sysmodule.c instead of straight out of a Unicode object.

Thanks to Amaury Forgeot d'Arc for noticing the bug and Eric Snow for
writing the patch.
2012-07-09 14:22:12 -04:00
Antoine Pitrou bc07a5c913 Issue #15110: Fix the tracebacks generated by "import xxx" to not show the importlib stack frames. 2012-07-08 12:01:27 +02:00
Brett Cannon 98979b85e7 Issue #15166: Re-implement imp.get_tag() using sys.implementation.
Also eliminates some C code in Python/import.c as well.

Patch by Eric Snow with verification by comparing against another
patch from Jeff Knupp.
2012-07-02 15:13:11 -04:00
Victor Stinner 81c39a88a4 get_sourcefile(): use PyUnicode_READ() to avoid the creation of a temporary
Py_UCS4 buffer
2012-06-16 03:22:05 +02:00
Nick Coghlan 0b43bcf528 Close #14857: fix regression in references to PEP 3135 implicit __class__ closure variable. Reopens issue #12370, but also updates unittest.mock to workaround that issue 2012-05-27 18:17:07 +10:00
Antoine Pitrou ea3eb88bca Issue #9260: A finer-grained import lock.
Most of the import sequence now uses per-module locks rather than the
global import lock, eliminating well-known issues with threads and imports.
2012-05-17 18:55:59 +02:00
Antoine Pitrou 6efa50a384 Issue #14583: Fix importlib bug when a package's __init__.py would first import one of its modules then raise an error. 2012-05-07 21:41:59 +02:00
Antoine Pitrou b78174c010 Fix too early decrefs. 2012-05-06 17:15:23 +02:00
Nadeem Vawda 8f46d655b9 Fix typo in changeset eb5c5c23ca9b. 2012-05-05 12:27:30 +02:00
Antoine Pitrou f3a42dee9a Simplify code for load_dynamic() 2012-05-04 22:40:25 +02:00
Brett Cannon 0429e1a57d Issue #13959: Move module type constants to Lib/imp.py. 2012-05-04 16:13:30 -04:00
Brett Cannon 6b9b727695 Remove dead Windows code which no longer will compile. 2012-05-04 16:04:14 -04:00
Brett Cannon 2657df4744 Issue #13959: Re-implement imp.get_suffixes() in Lib/imp.py.
This introduces a new function, imp.extension_suffixes(), which is
currently undocumented. That is forthcoming once issue #14657 is
resolved and how to expose file suffixes is decided.
2012-05-04 15:20:40 -04:00
Brett Cannon 62228dbd6c Issues #13959, 14647: Re-implement imp.reload() in Lib/imp.py.
Thanks to Eric Snow for the patch.
2012-04-29 14:38:11 -04:00
Brett Cannon acf85cd131 Issue #13959: Re-implement imp.NullImporter in Lib/imp.py. 2012-04-29 12:50:03 -04:00
Brett Cannon aa93642a35 Issue #14605: Use None in sys.path_importer_cache to represent no
finder instead of using some (now non-existent) implicit finder.
2012-04-27 15:30:58 -04:00
Victor Stinner 8f825060f1 Check newly created consistency using _PyUnicode_CheckConsistency(str, 1)
* In debug mode, fill the string data with invalid characters
 * Simplify also reference counting in PyCodec_BackslashReplaceErrors()
   and PyCodec_XMLCharRefReplaceError()
2012-04-27 13:55:39 +02:00
Brett Cannon 8923a4d4c5 Issue #14605: Insert to the front of sys.path_hooks instead of appending. 2012-04-24 22:03:46 -04:00
Brett Cannon e69f0df45b Issue #13959: Re-implement imp.find_module() in Lib/imp.py.
Thanks to Eric Snow for taking an initial stab at the implementation.
2012-04-21 21:09:46 -04:00
Brett Cannon a64faf0771 Issue #13959: Re-implement imp.source_from_cache() in Lib/imp.py. 2012-04-21 18:52:52 -04:00
Brett Cannon ea59dbff16 Issue #13959: Re-implement imp.cache_from_source() in Lib/imp.py. 2012-04-20 21:44:46 -04:00
Benjamin Peterson d76bc7abac rollback 005fd1fe31ab (see #14609 and #14582)
Being able to overload a sys.module entry during import of a module was broken
by this changeset.
2012-04-18 10:55:43 -04:00
Brett Cannon 64befe939c Issue #13959: Re-implement imp.load_compiled() in imp.py. 2012-04-17 19:14:26 -04:00
Brett Cannon 273323cf68 Issue #14592: A relative import will raise a KeyError if __package__
or __name__ are not set in globals.

Thanks to Stefan Behnel for the bug report.
2012-04-17 19:05:11 -04:00