Commit Graph

3976 Commits

Author SHA1 Message Date
Benjamin Peterson 2e2c903700 prevert ast errors from being normalized before ast_error_finish is called (closes #15846) 2012-09-02 14:23:15 -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
Brett Cannon 12c6bda4f0 Issue #15316: Let exceptions raised during imports triggered by the
fromlist of __import__ propagate.

The problem previously was that if something listed in fromlist didn't
exist then that's okay. The fix for that was too broad in terms of
catching ImportError.

The trick with the solution to this issue is that the proper
refactoring of import thanks to importlib doesn't allow for a way to
distinguish (portably) between an ImportError because finders couldn't
find a loader, or a loader raised the exception. In Python 3.4 the
hope is to introduce a new exception (e.g. ModuleNotFound) to make it
clean to differentiate why ImportError was raised.
2012-08-24 18:25:59 -04:00
Brett Cannon ba0a3edd26 Issue #2051: Tweak last commit for this issue to pass in mode instead
of source path to set_data() and make the new argument private until
possible API changes can be discussed more thoroughly in Python 3.4.
2012-08-24 13:48:39 -04:00
Nick Coghlan a508770e20 Close #2501: Permission bits are once again correctly copied from the source file to the cached bytecode file. Test by Eric Snow. 2012-08-24 18:32:40 +10:00
Victor Stinner ad54c6d82e Issue #15766: Fix a crash in imp.load_dynamic() on PyUnicode_FromString() failure 2012-08-22 17:45:52 +02:00
Antoine Pitrou 35503c9c14 Issue #15726: Fix incorrect bounds checking in PyState_FindModule.
Patch by Robin Schreiber.
2012-08-20 19:31:52 +02:00
Antoine Pitrou 75506e8b7c Issue #15726: Fix incorrect bounds checking in PyState_FindModule.
Patch by Robin Schreiber.
2012-08-20 19:30:46 +02:00
Stefan Krah 66d1eb23d4 Merge 3.2. 2012-08-20 17:20:46 +02:00
Stefan Krah 07795df683 Issue #15741: Fix potential NULL dereference. Found by Coverity. 2012-08-20 17:19:50 +02:00
Stefan Krah 28a2ad556a Check return value of asdl_seq_new(). Found by Coverity. 2012-08-20 16:07:38 +02:00
Nick Coghlan 48fec05391 Close #14846: Handle a sys.path entry going away 2012-08-20 13:18:15 +10:00
Brett Cannon 7385adc84c Issue #15715: Ignore failed imports triggered by the use of fromlist.
When the fromlist argument is specified for __import__() and the
attribute doesn't already exist, an import is attempted. If that fails
(e.g. module doesn't exist), the ImportError will now be silenced (for
backwards-compatibility). This *does not* affect
``from ... import ...`` statements.

Thanks to Eric Snow for the patch and Simon Feltman for reporting the
regression.
2012-08-17 13:21:16 -04:00
Antoine Pitrou 721738fbee Issue #15604: Update uses of PyObject_IsTrue() to check for and handle errors correctly.
Patch by Serhiy Storchaka.
2012-08-15 23:20:39 +02:00
Antoine Pitrou 6f430e4963 Issue #15604: Update uses of PyObject_IsTrue() to check for and handle errors correctly.
Patch by Serhiy Storchaka.
2012-08-15 23:18:25 +02:00
Brett Cannon b428f47cf6 Don't overwrite a __path__ value from extension modules if already
set.
2012-08-11 19:43:29 -04:00
Philip Jenvey 688a551ca0 fix docstring wording 2012-08-10 16:21:35 -07:00
Brett Cannon f410ce8c09 Issue #15502: Refactor some code. 2012-08-10 17:41:23 -04:00
Senthil Kumaran e9175bd0af Fix issue #15607: Update the print builtin function docstring with the new flush keyword.
Patch contributed by Daniel Ellis.
2012-08-10 13:53:45 -07:00
Philip Jenvey 731d48a65f update docstring per the extension package fix, refactor 2012-08-10 11:53:54 -07:00
Brett Cannon ac9f2f3de3 Issue #15576: Allow extension modules to be a package's __init__
module again. Also took the opportunity to stop accidentally exporting
_imp.extension_suffixes() as public.
2012-08-10 13:47:54 -04:00
Brett Cannon f4dc9204cc Issue #15502: Finish bringing importlib.abc in line with the current
state of the import system. Also make importlib.invalidate_caches()
work with sys.meta_path instead of sys.path_importer_cache to
completely separate the path-based import system from the overall
import system.

Patch by Eric Snow.
2012-08-10 12:21:12 -04:00
Victor Stinner 2d6266d5f1 Remove now unused IntOrLongToString type 2012-08-09 21:38:23 +02:00
Benjamin Peterson 0ed05059de merge heads 2012-08-06 17:53:19 -07:00
Benjamin Peterson b37df519c7 fix yield from return value on custom iterators (closes #15568) 2012-08-06 17:53:09 -07:00
Brett Cannon cb4996afe4 Issue #15471: Don't use mutable object as default values for the
parameters of importlib.__import__().
2012-08-06 16:34:44 -04: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
Victor Stinner 90ef747e04 Close #13119: use "\r\n" newline for sys.stdout/err on Windows
sys.stdout and sys.stderr are now using "\r\n" newline on Windows, as Python 2.
2012-08-04 01:37:32 +02:00
Victor Stinner 7b3f0fa68e Close #13119: use "\r\n" newline for sys.stdout/err on Windows
sys.stdout and sys.stderr are now using "\r\n" newline on Windows, as Python 2.
2012-08-04 01:28:00 +02:00
Nick Coghlan 4941774f59 Issue #15502: Bring the importlib.PathFinder docs and docstring more in line with the new import system documentation, and fix various parts of the new docs that weren't quite right given PEP 420 or were otherwise a bit misleading. Also note the key terminology problem still being discussed in the issue 2012-08-02 23:03:58 +10:00
Nick Coghlan ff79486bb5 Close #15519: Properly expose WindowsRegistryFinder in importlib and bring the name into line with normal import terminology. Original patch by Eric Snow 2012-08-02 21:45:24 +10: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
Victor Stinner d5698cbbca Fix initialization of the faulthandler module
faulthandler requires the importlib if "-X faulthandler" option is present on
the command line, so initialize faulthandler after importlib.

Add also an unit test.
2012-07-31 02:55:49 +02:00
Brett Cannon 722d3aec2e Issue #15508: Fix the docstring for __import__ to not mention negative
'level' values and set its document default value to 0.

Thanks to Arfrever Frehtes Taifersar Arahesis for filing the bug.
2012-07-30 17:45:54 -04:00
Victor Stinner 54f939b9ae Issue #15463: the faulthandler module truncates strings to 500 characters,
instead of 100, to be able to display long file paths
2012-07-30 13:08:58 +02:00
Nick Coghlan 5ee9892406 Close #15425: Eliminate more importlib related traceback noise 2012-07-29 20:30:36 +10:00
Martin v. Löwis e3010a8d12 Issue #14578: Support modules registered in the Windows registry again.
Patch by Amaury Forgeot d'Arc.
2012-07-28 21:33:05 +02:00
Martin v. Löwis 7e39572aa8 Issue #15466: Stop using TYPE_INT64 in marshal,
to make importlib.h (and other byte code files) equal between 32-bit
and 64-bit systems.
2012-07-28 19:44:05 +02:00
Kristján Valur Jónsson c5963d3842 Issue #15365: Make traceback reporting ignore any errors when printing out
the source line.  Such errors can't be reported anyway.  This makes error
reporting work, even if the "io" module can't be loaded.
2012-07-19 21:02:03 +00:00
Meador Inge 996ae04943 remove unused variable 2012-07-18 17:57:46 -05:00
Benjamin Peterson 51ab2830bb remove unused variable 2012-07-18 15:12:47 -07:00
Meador Inge 9544aa38d9 Issue #15368: fixing variable typo. 2012-07-18 16:49:07 -05:00
Meador Inge f69e24e3c6 Issue #15368: fixing variable typo. 2012-07-18 16:41:03 -05:00
Meador Inge 1f336adc8f Issue #15368: make bytecode generation deterministic. 2012-07-18 14:28:55 -05:00
Meador Inge 2ca6315d15 Issue #15368: make bytecode generation deterministic. 2012-07-18 14:20:11 -05:00
Nick Coghlan b7a5894c64 Refcounting fixes 2012-07-15 23:21:08 +10:00
Nick Coghlan ceda83c6a9 Make set_main_loader static (noticed by Antoine Pitrou) 2012-07-15 23:18:08 +10:00
Nick Coghlan 2824cb507d Issue #15343: A lot more than just unicode decoding can go wrong when retrieving a source file 2012-07-15 22:12:14 +10:00
Nick Coghlan 3f94cbf9eb Actually initialize __main__.__loader__ with loader instances, not the corresponding type objects 2012-07-15 19:10:39 +10:00
Nick Coghlan 85e729ec3b Take the first step in resolving the messy pkgutil vs importlib edge cases by basing pkgutil explicitly on importlib, deprecating its internal import emulation and setting __main__.__loader__ correctly so that runpy still works (Affects #15343, #15314, #15357) 2012-07-15 18:09:52 +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
Brett Cannon 461c813164 Issue #15111: When a module was imported using a 'from import'
statement (e.g. ``from distutils import msvc9compiler``) that triggers
an ImportError of its own (e.g. the non-existence of winreg), let that
exception propagate instead of raising a generic ImportError for the
module being requested (e.g. msvc9compiler).
2012-07-10 10:05:00 -04: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
Brett Cannon 19a2f5961c Issue #15056: imp.cache_from_source() and source_from_cache() raise
NotimplementedError when sys.implementation.cache_tag is None.

Thanks to Pranav Ravichandran for taking an initial stab at the patch.
2012-07-09 13:58:07 -04:00
Amaury Forgeot d'Arc ae7b8f07c1 Issue #15110: Also hide importlib frames when importing a builtin module fails. 2012-07-08 20:52:38 +02:00
Benjamin Peterson 8107176f9b add gc support to the AST base type (closes #15293) 2012-07-08 11:03:46 -07:00
Antoine Pitrou 507507473e Issue #15291: Fix a memory leak where AST nodes where not properly deallocated. 2012-07-08 12:43:32 +02: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
Antoine Pitrou bc1a7ddc9b Check-in compiled importlib changes (you must run "make" after modifying the importlib sources). 2012-07-07 19:49:44 +02:00
Antoine Pitrou 74de153681 Issue #15020: The program name used to search for Python's path is now python3 under Unix, not python. 2012-07-05 20:57:33 +02:00
Antoine Pitrou 01cca5e451 Issue #15020: The program name used to search for Python's path is now "python3" under Unix, not "python". 2012-07-05 20:56:30 +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
Brett Cannon 8a250fac15 Comment out a dead increment.
Found by Clang's static analyzer.
2012-06-25 16:13:44 -04:00
Antoine Pitrou 0ab5cf9b46 Issue #15181: importlib bytecode is unsigned and shouldn't have negative numbers.
This fixes a compiler warning with suncc.
2012-06-25 17:32:43 +02:00
Eric V. Smith e51a36922f Fixes issue 15039: namespace packages are no longer imported in preference to modules of the same name. 2012-06-24 19:13:55 -04:00
Antoine Pitrou edc601855d Remove outdated statement 2012-06-23 14:19:58 +02:00
Antoine Pitrou 310f95b04d A better repr() for FileFinder 2012-06-23 02:12:56 +02:00
David Malcolm 49526f48fc Issue #14785: Add sys._debugmallocstats() to help debug low-level memory allocation issues 2012-06-22 14:55:41 -04:00
Martin v. Löwis 7800f75827 Issue #15042: Add PyState_AddModule and PyState_RemoveModule.
Add version  guard for Py_LIMITED_API additions.
Issue #15081: Document PyState_FindModule.
Patch by Robin Schreiber.
2012-06-22 12:20:55 +02:00
doko@ubuntu.com 39378f7f4f format_obj: make it static 2012-06-21 12:12:20 +02:00
Antoine Pitrou e67f48ce5e Issue #14928: Fix importlib bootstrap issues by using a custom executable (Modules/_freeze_importlib) to build Python/importlib.h. 2012-06-19 22:29:35 +02:00
Kristjan Valur Jonsson 0006aacb9d Issue #15038: Document caveats with the emulated condition variables. 2012-06-19 16:30:28 +00:00
Antoine Pitrou 1d25b6f04a Issue #15103: remove the NUL character (serving as a Mercurial binary marker) from Python/importlib.h.
Instead the email notification hook uses a configuration option to omit importlib.h diffs.
2012-06-19 16:33:39 +02:00
Kristjan Valur Jonsson 1617077bcc Issue #15038:
Fix incorrect test of the condition variable state, spotted by
Richard Oudkerk.  This could cause the internal condition variable
to grow without bounds.
2012-06-19 10:10:09 +00:00
Kristján Valur Jónsson e75ff35af2 Issue #15038: Optimize python Locks on Windows
Extract cross-platform condition variable support into a separate file and
provide user-mode non-recursive locks for Windows.
2012-06-18 20:30:44 +00:00
Nick Coghlan c40bc09942 Issue #13783: the PEP 380 implementation no longer expands the public C API 2012-06-17 15:15:49 +10:00
Antoine Pitrou 2d9db1dfce Try to fix issue #15086: build failure on Ubuntu shared buildbot. 2012-06-17 00:27:30 +02: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
Victor Stinner c9d369f1bf Optimize _PyUnicode_FastCopyCharacters() when maxchar(from) > maxchar(to) 2012-06-16 02:22:37 +02:00
Brett Cannon 24aa693c7e Merge 2012-06-15 19:04:29 -04:00
Victor Stinner 2b89fdf7eb PEP 418: Rename adjusted attribute to adjustable in time.get_clock_info() result
Fix also its value on Windows and Linux according to its documentation:
"adjustable" indicates if the clock *can be* adjusted, not if it is or was
adjusted.

In most cases, it is not possible to indicate if a clock is or was adjusted.
2012-06-12 22:46:37 +02:00
Brett Cannon 99d776fdf4 Update importlib.h by touching Lib/importlib/_bootstrap.py. 2012-06-11 11:02:53 -04:00
Kristján Valur Jónsson 187aa54516 Signal condition variables with the mutex held. Destroy condition variables
before their mutexes.
2012-06-05 22:17:42 +00:00
Barry Warsaw 409da157d7 Eric Snow's implementation of PEP 421.
Issue 14673: Add sys.implementation
2012-06-03 16:18:47 -04:00
Benjamin Peterson 3a37b8393c merge 3.2 2012-06-01 23:57:50 -07:00
Benjamin Peterson 8e8fbeae27 don't leak if the __class__ closure is set 2012-06-01 23:57:36 -07:00
Benjamin Peterson d1ab6089ff check return for error 2012-06-01 11:18:22 -07:00
Victor Stinner d3f0882dfb Issue #14744: Use the new _PyUnicodeWriter internal API to speed up str%args and str.format(args)
* Formatting string, int, float and complex use the _PyUnicodeWriter API. It
   avoids a temporary buffer in most cases.
 * Add _PyUnicodeWriter_WriteStr() to restore the PyAccu optimization: just
   keep a reference to the string if the output is only composed of one string
 * Disable overallocation when formatting the last argument of str%args and
   str.format(args)
 * Overallocation allocates at least 100 characters: add min_length attribute
   to the _PyUnicodeWriter structure
 * Add new private functions: _PyUnicode_FastCopyCharacters(),
   _PyUnicode_FastFill() and _PyUnicode_FromASCII()

The speed up is around 20% in average.
2012-05-29 12:57:52 +02:00
Victor Stinner a1b0c9fc4d PyArg_Parse*("U"): ensure that the Unicode string is ready 2012-05-29 12:30:29 +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
Nick Coghlan 5c6eba3a93 Tweak importlib._bootstrap to avoid zero-argument super so I can work on issue #14857 without breaking imports 2012-05-27 17:49:58 +10:00
Brett Cannon d785cb3955 Remove some redundant decorators. 2012-05-26 14:28:21 -04:00
Vinay Sajip 7ded1f0f69 Implemented PEP 405 (Python virtual environments). 2012-05-26 03:45:29 +01:00
Eric V. Smith 984b11f88f issue 14660: Implement PEP 420, namespace packages. 2012-05-24 20:21:04 -04: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