Commit Graph

4332 Commits

Author SHA1 Message Date
Serhiy Storchaka c679227e31 Issue #1772673: The type of `char*` arguments now changed to `const char*`. 2013-10-19 21:03:34 +03:00
Brett Cannon 58f5680462 Issue #18810: Be optimistic with stat calls when seeing if a directory
exists when checking for a package.

Before there was an isdir check and then various isfile checks for
possible __init__ files when looking for a package.
This change drops the isdir check by leaning
on the assumption that a directory will not contain something named
after the module being imported which is not a directory. If the module
is a package then it saves a stat call. If there is nothing in the
directory with the potential package name it also saves a stat call.
Only if there is something in the directory named the same thing as
the potential package will the number of stat calls increase
(due to more wasteful __init__ checks).

Semantically there is no change as the isdir check moved
down so that namespace packages continue to have no chance of
accidentally collecting non-existent directories.
2013-10-18 13:24:13 -04:00
Brett Cannon bb9e481efa Issue #18416: Fix various os calls in importlib.machinery.FileFinder
now that self.path is no longer forced to '.'.
2013-10-18 12:01:06 -04:00
Brett Cannon 27e27f7ee1 Issue #18416: Have importlib.machinery.PathFinder treat '' as the cwd
and stop importlib.machinery.FileFinder treating '' as '.'.

Previous PathFinder transformed '' into '.' which led to __file__ for
modules imported from the cwd to always be relative paths. This meant
the values of the attribute were wrong as soon as the cwd changed.
This change now means that as long as the site module is run (which
makes all entries in sys.path absolute) then all values for __file__
will also be absolute unless it's for __main__ when specified by file
path in a relative way (modules imported by runpy will have an
absolute path).

Now that PathFinder is no longer treating '' as '.' it only makes
sense for FileFinder to stop doing so as well. Now no transformation
is performed for the directory given to the __init__ method.

Thanks to Madison May for the initial patch.
2013-10-18 11:39:04 -04:00
Nick Coghlan 1805a62f1f Issue #16129: Py_SetStandardStreamEncoding cleanups
- don't call PyErr_NoMemory with interpreter is not initialised
- note that it's OK to call _PyMem_RawStrDup here
- don't include this in the limited API
- capitalise "IO"
- be explicit that a non-zero return indicates an error
- include versionadded marker in docs
2013-10-18 23:11:47 +10:00
Nick Coghlan 7d270ee05d Issue #16129: Add `Py_SetStandardStreamEncoding`
This new pre-initialization API allows embedding
applications like Blender to force a particular
encoding and error handler for the standard IO streams.

Also refactors Modules/_testembed.c to let us start
testing multiple embedding scenarios.

(Initial patch by Bastien Montagne)
2013-10-17 22:35:35 +10:00
Antoine Pitrou 42c25f5581 Close #19260: remove outdated comment in marshal.c 2013-10-14 20:50:32 +02:00
Georg Brandl 142ad666dc Re #18521: move array bounds check before array access. 2013-10-14 07:01:11 +02:00
Georg Brandl 6083a4bc1c Re #18521: remove assignments of variables that are immediately reassigned. 2013-10-14 06:51:46 +02:00
Antoine Pitrou 6039db8de3 Issue #18776: atexit callbacks now display their full traceback when they raise an exception. 2013-10-13 21:54:15 +02:00
Antoine Pitrou 24201d497c Issue #18776: atexit callbacks now display their full traceback when they raise an exception. 2013-10-13 21:53:13 +02:00
Kristján Valur Jónsson 0a7697b718 Catch a few extra error cases in marshal.c 2013-10-13 15:19:56 +00:00
Kristján Valur Jónsson 5983258bf2 Issue #19219 Remove a lot of "retval = NULL" statements, now that retval
is pre-initialized to that value.  Test show a 5% speedup as a bonus.
2013-10-13 13:41:59 +00:00
Christian Heimes 3572842c19 Issue #19219: retval may be used uninitialized value
CID 486239: Uninitialized pointer read (UNINIT)
2013-10-13 02:29:06 +02:00
Antoine Pitrou b30f271299 Try to fix weird assertion error on the Fedora buildbot. 2013-10-12 23:14:47 +02:00
Antoine Pitrou d01d396e7f Issue #4555: All exported C symbols are now prefixed with either "Py" or "_Py".
("make smelly" now clean)
2013-10-12 22:52:43 +02:00
Antoine Pitrou 409b53840b Don't export internal symbols ("make smelly") 2013-10-12 22:41:17 +02:00
Antoine Pitrou 1164dfcb86 Issue #19219: Speed up marshal.loads(), and make pyc files slightly (5% to 10%) smaller. 2013-10-12 22:25:39 +02:00
Victor Stinner 8d19767403 Close #19199: Remove ``PyThreadState.tick_counter`` field 2013-10-09 14:53:01 +02:00
Antoine Pitrou 1cfa0ba883 Fix macro expansion of _PyErr_OCCURRED(), and make sure to use it in at least one place so as to avoid regressions. 2013-10-07 20:40:59 +02:00
Antoine Pitrou 59c900d3bf Fix macro expansion of _PyErr_OCCURRED(), and make sure to use it in at least one place so as to avoid regressions. 2013-10-07 20:38:51 +02:00
Georg Brandl af1edb7f45 merge with 3.3 2013-10-06 18:48:30 +02:00
Georg Brandl c6a2c9b466 Closes #15213: update comment for _PyOS_URandom 2013-10-06 18:43:19 +02:00
Eric Snow 5c4b4c530f [issue19152] Revert 832579dbafd6. 2013-10-03 15:03:29 -06:00
Eric Snow af8566c847 [issue19152] Add ExtensionFileLoader.get_filename(). 2013-10-03 12:08:55 -06:00
Eric Snow 5179445520 [issue19152] Add ExtensionFileLoader.get_filename(). 2013-10-03 12:08:55 -06:00
Eric Snow efbc475278 [issue19151] Fix docstring and use of _get_suppported_file_loaders() to reflect 2-tuples. 2013-10-03 12:08:55 -06:00
Eric Snow e8bbfebee0 [issue19951] Fix docstring and use of _get_suppported_file_loaders() to reflect 2-tuples. 2013-10-03 12:08:55 -06:00
Benjamin Peterson c30d05855a merge 3.3 (#19098) 2013-09-26 22:21:41 -04:00
Benjamin Peterson 305e5aac85 don't scale compiler stack frames if the recursion limit is huge (closes #19098) 2013-09-26 22:17:45 -04:00
Serhiy Storchaka bf28d2dcad Issue #18818: The "encodingname" part of PYTHONIOENCODING is now optional. 2013-09-13 11:46:24 +03:00
Antoine Pitrou 7b4769937f Issue #18808: Thread.join() now waits for the underlying thread state to be destroyed before returning.
This prevents unpredictable aborts in Py_EndInterpreter() when some non-daemon threads are still running.
2013-09-07 23:38:37 +02:00
Victor Stinner b034eee711 Close #18954: Fix some typo in fileutils.c comments
Patch written by Vajrasky Kok.
2013-09-07 10:36:04 +02:00
Meador Inge 3c56145638 Issue #16826: Revert fix while Windows issues are being worked out. 2013-09-03 19:54:40 -05:00
Meador Inge c9e1dcdd53 Issue #16826: Revert fix while Windows issues are being worked out. 2013-09-03 19:43:49 -05:00
Meador Inge 9ab358ad7c Issue #16826: Don't check for PYTHONCASEOK when using -E.
This commit fixes a regression that sneaked into Python 3.3 where importlib
was not respecting -E when checking for the PYTHONCASEOK environment variable.
2013-09-03 16:53:22 -05:00
Meador Inge d151da9ef7 Issue #16826: Don't check for PYTHONCASEOK when using -E.
This commit fixes a regression that sneaked into Python 3.3 where importlib
was not respecting -E when checking for the PYTHONCASEOK environment variable.
2013-09-03 16:37:26 -05:00
Raymond Hettinger 69492dab07 Factor-out the common code for setting a KeyError. 2013-09-02 15:59:26 -07:00
Antoine Pitrou 4879a963d4 Issue #18756: os.urandom() now uses a lazily-opened persistent file descriptor, so as to avoid using many file descriptors when run in parallel from multiple threads. 2013-08-31 00:26:02 +02:00
Victor Stinner 55a1220bdb pythonrun.c: use MAXPATHLEN instead of PATH_MAX
PATH_MAX is not available on "MIPS IRIX 6.5.30 [SB] 3.x" buildbot
2013-08-28 01:47:46 +02:00
Victor Stinner daf455554b Issue #18571: Implementation of the PEP 446: file descriptors and file handles
are now created non-inheritable; add functions os.get/set_inheritable(),
os.get/set_handle_inheritable() and socket.socket.get/set_inheritable().
2013-08-28 00:53:59 +02:00
Serhiy Storchaka 46e1ce214b Issue #18783: Removed existing mentions of Python long type in docstrings,
error messages and comments.
2013-08-27 20:17:03 +03:00
Serhiy Storchaka 9594942716 Issue #18783: Removed existing mentions of Python long type in docstrings,
error messages and comments.
2013-08-27 19:40:23 +03:00
Victor Stinner 14e461d5b9 Close #11619: The parser and the import machinery do not encode Unicode
filenames anymore on Windows.
2013-08-26 22:28:21 +02:00
Victor Stinner c82bfd871f Issue #18664, #18408: Rewrite PyErr_WriteUnraisable() to handle errors
* Catch PyFile_WriteString() and PyFile_WriteObject() errors
 * Clear the current exception on _PyObject_GetAttrId() failure
 * Use PyUnicode_CompareWithASCIIString() and PyFile_WriteObject() instead of
   _PyUnicode_AsString() and strcmp() to avoid Unicode encoding error. stderr
   has a more tolerant error handler than utf-8/strict.
2013-08-26 14:04:10 +02:00
Ezio Melotti 0e1e04301b #18839: merge with 3.3. 2013-08-26 14:01:29 +03:00
Ezio Melotti 4af4d273bd #18839: document that sys.exit() will not accept a non-integer numeric value as exit status. 2013-08-26 14:00:39 +03:00
Antoine Pitrou 7eaf3f7080 Issue #18808: Non-daemon threads are now automatically joined when a sub-interpreter is shutdown (it would previously dump a fatal error). 2013-08-25 19:48:18 +02:00
Benjamin Peterson 3a7dffa4ce remove support for compiling on systems without getcwd()
Do we need a fallback implementation of getcwd() from 1991 that claims to
support "really old Unix systems"? I don't think so.
2013-08-23 21:01:48 -05:00
Victor Stinner cba2e3c2e9 remove unused declaration 2013-08-22 02:23:13 +02:00