Commit Graph

4529 Commits

Author SHA1 Message Date
Brett Cannon 18fc4e70f3 Issue #20942: PyImport_ImportFrozenModuleObject() no longer sets
__file__.

This causes _frozen_importlib to no longer have __file__ set as well
as any frozen module imported using imp.init_frozen() (which is
deprecated).
2014-04-04 10:01:46 -04:00
Benjamin Peterson 9381343948 undefine SET_SYS_FROM_STRING_BORROW after its done being used (closes #21089) 2014-03-28 18:52:45 -04:00
Georg Brandl 2fc8f773e1 Issue #20404: reject non-text encodings early in TextIOWrapper. 2014-03-02 09:18:31 +01:00
Brett Cannon d3acef9bf4 Issue #20763: Fix importlib.machinery.PathFinder to support
PathEntryFinder instances which only define find_module().

Reported by Yukihiro Nakadaira.
2014-02-26 18:26:49 -05:00
Serhiy Storchaka 94ee389308 Issue #19619: Blacklist non-text codecs in method API
str.encode, bytes.decode and bytearray.decode now use an
internal API to throw LookupError for known non-text encodings,
rather than attempting the encoding or decoding operation and
then throwing a TypeError for an unexpected output type.

The latter mechanism remains in place for third party non-text
encodings.

Backported changeset d68df99d7a57.
2014-02-24 14:43:03 +02:00
Benjamin Peterson 45d8e7b920 update magic number for #20625 2014-02-19 18:05:36 -05:00
Victor Stinner 065efc3072 Issue #20625: Fix compilation issue 2014-02-18 22:07:56 +01:00
Yury Selivanov 34ce99f66d Mangle __parameters in __annotations__ dict properly. Issue #20625. 2014-02-18 12:49:41 -05:00
Victor Stinner 3c1b379ebd Issue #20320: select.select() and select.kqueue.control() now round the timeout
aways from zero, instead of rounding towards zero.

It should make test_asyncio more reliable, especially test_timeout_rounding() test.
2014-02-17 00:02:43 +01:00
Benjamin Peterson 0714b8b6ab set line and column numbers for keyword-only arg nodes (closes #20619) 2014-02-13 19:22:14 -05:00
Victor Stinner 15054c16c8 Issue #20526, #19466: Revert changes of issue #19466 which introduces a
regression: don't clear anymore the state of Python threads early during the
Python shutdown.
2014-02-13 12:48:54 +01:00
Benjamin Peterson 40be9e5100 remove dynamic initializer lists for c89 compliance (closes #20595) 2014-02-11 10:09:27 -05:00
Benjamin Peterson 42ec031fe7 merge 3.3 (#20588) 2014-02-10 22:41:40 -05:00
Benjamin Peterson c2f665e721 don't put runtime values in array initializer for C89 compliance (closes #20588) 2014-02-10 22:19:02 -05:00
Serhiy Storchaka d667d72cb7 Temporary silence test broken by issue19255.
Remove unused variables.
2014-02-10 19:09:19 +02:00
Serhiy Storchaka 87a5c515d0 Issue #19255: The builtins module is restored to initial value before
cleaning other modules.  The sys and builtins modules are cleaned last.
2014-02-10 18:21:34 +02:00
Larry Hastings 8f9f0f12e8 Issue #20517: Removed unnecessary new (short-lived) functions from PyErr. 2014-02-10 03:43:57 -08:00
Larry Hastings b082731fbb Issue #20517: Functions in the os module that accept two filenames
now register both filenames in the exception on failure.
This required adding new C API functions allowing OSError exceptions
to reference two filenames instead of one.
2014-02-09 22:05:19 -08:00
Benjamin Peterson 665a2bcdf8 bump Python-ast.c 2014-02-19 23:05:26 -05:00
Serhiy Storchaka dfe98a102e Issue #20437: Fixed 22 potential bugs when deleting objects references. 2014-02-09 13:46:20 +02:00
Serhiy Storchaka 505ff755d7 Issue #20437: Fixed 21 potential bugs when deleting objects references. 2014-02-09 13:33:53 +02:00
Larry Hastings 2623c8c23c Issue #20530: Argument Clinic's signature format has been revised again.
The new syntax is highly human readable while still preventing false
positives.  The syntax also extends Python syntax to denote "self" and
positional-only parameters, allowing inspect.Signature objects to be
totally accurate for all supported builtins in Python 3.4.
2014-02-08 22:15:29 -08:00
Nick Coghlan d979e4335d Close #20500: Don't trigger PyObject_Str assertion at shutdown 2014-02-09 10:43:21 +10:00
Nick Coghlan a9b15241c6 Close #20404: blacklist non-text encodings in io.TextIOWrapper
- io.TextIOWrapper (and hence the open() builtin) now use the
  internal codec marking system added for issue #19619
- also tweaked the C code to only look up the encoding once,
  rather than multiple times
- the existing output type checks remain in place to deal with
  unmarked third party codecs.
2014-02-04 22:11:18 +10:00
Larry Hastings 7726ac9163 #Issue 20456: Several improvements and bugfixes for Argument Clinic,
including correctly generating code for Clinic blocks inside C
preprocessor conditional blocks.
2014-01-31 22:03:12 -08:00
Victor Stinner a17b6bb5fe Issue #20162: Fix an alignment issue in the siphash24() hash function which
caused a crash on PowerPC 64-bit (ppc64).
2014-02-01 03:38:56 +01:00
Larry Hastings 581ee3618c Issue #20326: Argument Clinic now uses a simple, unique signature to
annotate text signatures in docstrings, resulting in fewer false
positives.  "self" parameters are also explicitly marked, allowing
inspect.Signature() to authoritatively detect (and skip) said parameters.

Issue #20326: Argument Clinic now generates separate checksums for the
input and output sections of the block, allowing external tools to verify
that the input has not changed (and thus the output is not out-of-date).
2014-01-28 05:00:08 -08:00
Larry Hastings 5c66189e88 Issue #20189: Four additional builtin types (PyTypeObject,
PyMethodDescr_Type, _PyMethodWrapper_Type, and PyWrapperDescr_Type)
have been modified to provide introspection information for builtins.
Also: many additional Lib, test suite, and Argument Clinic fixes.
2014-01-24 06:17:25 -08:00
Serhiy Storchaka 2bd59daf58 Issue #2382: SyntaxError cursor "^" now is written at correct position in most
cases when multibyte characters are in line (before "^").  This still not
works correctly with wide East Asian characters.
2014-01-21 22:29:47 +02:00
Serhiy Storchaka 65fd0592fb Issue #2382: SyntaxError cursor "^" now is written at correct position in most
cases when multibyte characters are in line (before "^").  This still not
works correctly with wide East Asian characters.
2014-01-21 22:26:52 +02:00
Victor Stinner 2d854c8e7b Issue #20024: Py_BuildValue() now saves/restores the current exception before
building an item if the build of a previous item failed.
2014-01-21 20:52:17 +01:00
Stefan Krah 34e4628453 Merge from 3.3. 2014-01-20 15:35:38 +01:00
Stefan Krah 6c01e38677 Issue #19036: Including locale.h should not depend on HAVE_LANGINFO_H. 2014-01-20 15:31:08 +01:00
Larry Hastings b7ccb20423 Issue #20294: Argument Clinic now supports argument parsing for __new__ and
__init__ functions.
2014-01-18 23:50:21 -08:00
Larry Hastings bebf73511a Issue #20287: Argument Clinic's output is now configurable, allowing
delaying its output or even redirecting it to a separate file.
2014-01-17 17:47:17 -08:00
Brett Cannon a6dec2e744 Remove an unneeded cast. 2014-01-10 07:43:55 -05:00
Brett Cannon 4caa61d20e Issue #20152: import.c now uses Argument Clinic. 2014-01-09 19:03:32 -05:00
Eric Snow e4314e05d5 Issue 19713: Remove PEP 451-related code that should have been factored out.
This code was an artifact of issuing a DeprecationWarning for the lack
of loader.exec_module().  However, we have deferred such warnings to
later Python versions.
2014-01-07 23:29:19 -07:00
Larry Hastings 77561cccb2 Issue #20141: Improved Argument Clinic's support for the PyArg_Parse "O!"
format unit.
2014-01-07 12:13:13 -08:00
Eric Snow 1500d49c22 Issue 19713: Add PEP 451-related deprecations. 2014-01-06 20:49:04 -07:00
Eric Snow d749c7ae68 Issue #19927: Add __eq__ to path-based loaders in importlib. 2014-01-04 15:06:49 -07:00
Eric Snow fbc785188d Issue #20097: Fix bad use of "self" in importlib's WindowsRegistryFinder. 2014-01-02 22:25:00 -07:00
Benjamin Peterson a015bb1e2b merge 3.3 2013-12-31 22:02:41 -06:00
Benjamin Peterson fa10ae0978 update copyright year 2013-12-31 22:02:22 -06:00
Christian Heimes af01f66817 Issue #16136: Remove VMS support and VMS-related code 2013-12-21 16:19:10 +01:00
Victor Stinner ed0b87d73c Fix the C definition of the sys._debugmallocstats() function: the function has
no parameter
2013-12-19 17:16:42 +01:00
Victor Stinner 5272fa9c57 Fix _Py_DisplaySourceLine(), if PyTokenizer_FindEncodingFilename() fails, clear
the exception to not call open() with an exception set.
2013-12-19 13:39:32 +01:00
Eric Snow 61e851baca Remove some dead code in importlib, introduced with the PEP 451 patch.
Early in the PEP 451 implementation some of the importlib loaders had
their own _get_spec() methods to simplify accommodating them.  However,
later implementations removed the need.  They simply failed to remove
this code at the same time. :)
2013-12-18 23:35:15 -07:00
Serhiy Storchaka 85c2497950 Issue #16404: Add checks for return value of PyLong_FromLong() in
sys.getwindowsversion() and ossaudiodev.setparameters().
Reported by Ned Batchelder.
2013-12-17 15:12:46 +02:00
Serhiy Storchaka 48d761e2b4 Issue #16404: Add checks for return value of PyLong_FromLong() in
sys.getwindowsversion() and ossaudiodev.setparameters().
Reported by Ned Batchelder.
2013-12-17 15:11:24 +02:00
Serhiy Storchaka 11ee080ea7 Fixed leak in sys.flags initialization. 2013-12-17 15:00:53 +02:00
Serhiy Storchaka 87a854dc73 Fixed leak in sys.flags initialization. 2013-12-17 14:59:42 +02:00
Victor Stinner 590cebe391 Issue #19787: PyThread_set_key_value() now always set the value
In Python 3.3, PyThread_set_key_value() did nothing if the key already exists
(if the current value is a non-NULL pointer).

When _PyGILState_NoteThreadState() is called twice on the same thread with a
different Python thread state, it still keeps the old Python thread state to
keep the old behaviour. Replacing the Python thread state with the new state
introduces new bugs: see issues #10915 and #15751.
2013-12-13 11:08:56 +01:00
Victor Stinner 441adb8c57 Backout changeset 46393019b650
test_capi is failing and the fix is not trivial, I prefer to revert
2013-12-13 04:14:41 +01:00
Victor Stinner cd0cb8ccd3 Close #19787: PyThread_set_key_value() now always set the value. In Python 3.3,
the function did nothing if the key already exists (if the current value is a
non-NULL pointer).

_testcapi.run_in_subinterp() now correctly sets the new Python thread state of
the current thread when a subinterpreter is created.
2013-12-13 03:22:00 +01:00
Victor Stinner fdeb6ec45a Issue #14432: Remove the thread state field from the frame structure. Fix a
crash when a generator is created in a C thread that is destroyed while the
generator is still used. The issue was that a generator contains a frame, and
the frame kept a reference to the Python state of the destroyed C thread. The
crash occurs when a trace function is setup.
2013-12-13 02:01:38 +01:00
Victor Stinner 62ca10051b Close #19576: PyGILState_Ensure() now initializes threads. At startup, Python
has no concrete GIL. If PyGILState_Ensure() is called from a new thread for the
first time and PyEval_InitThreads() was not called yet, a GIL needs to be
created.
2013-12-13 01:46:43 +01:00
Eric Snow b282b3d804 Issue #18864: Add a setter for ModuleSpec.has_location. 2013-12-10 22:16:41 -07:00
Victor Stinner 52ce3b04d0 Issue #19817: Fix print_exception(), clear the exception on error 2013-12-09 02:10:08 +01:00
Benjamin Peterson d45a46b60d merge 3.3 (#19910) 2013-12-06 20:12:51 -05:00
Benjamin Peterson 933142a8f2 document that compile() can take bytes (closes #19910) 2013-12-06 20:12:39 -05:00
Christian Heimes 724b828e79 upcast int to size_t to silence two autological-constant-out-of-range-compare warnings with clang. 2013-12-04 08:42:46 +01:00
Victor Stinner be0708f066 Closes #19831: Stop tracemalloc later at Python shutdown to be able to use
tracemalloc in objects destructor

Replace atexit handler with an harcoded C function _PyTraceMalloc_Fini().
2013-12-01 10:03:26 +01:00
Brett Cannon d2476c6e4b Issue #19698: Remove exec_module() from the built-in and extension
module loaders.

Due to the fact that the call signatures for extension modules and
built-in modules does not allow for the specifying of what module to
initialize and that on Windows all extension modules are built-in
modules, work to clean up built-in and extension module initialization
will have to wait until Python 3.5. Because of this the semantics of
exec_module() would be incorrect, so removing the methods for now is
the best option; load_module() is still used as a fallback by
importlib and so this won't affect semantics.
2013-11-29 11:00:11 -05:00
Mark Dickinson 1df88677e9 Issue #19638: Merge from 3.3 2013-11-26 16:19:38 +00:00
Mark Dickinson f45bbb6211 Issue #19638: Raise ValueError instead of crashing when converting billion character strings to float. 2013-11-26 16:19:13 +00:00
Zachary Ware a4b7a7548c Issue #3158: doctest can now find doctests in functions and methods
written in C.

As a part of this, a few doctests have been added to the builtins module
(on hex(), oct(), and bin()), a doctest has been fixed (hopefully on all
platforms) on float, and test_builtins now runs doctests in builtins.
2013-11-24 01:19:09 -06:00
Larry Hastings 3a9079742f Issue #19722: Added opcode.stack_effect(), which accurately
computes the stack effect of bytecode instructions.
2013-11-23 14:49:22 -08:00
Antoine Pitrou 8933521b3d Fix refleak introduced by 4f730c045f5f (issue #18408) and unveiled by 95eea8624d05 (issue #16596). 2013-11-23 14:05:23 +01:00
Victor Stinner ed3b0bca3e Issue #18874: Implement the PEP 454 (tracemalloc) 2013-11-23 12:27:24 +01:00
Brett Cannon 224b261258 User the repr for a module name in more places 2013-11-22 14:52:36 -05:00
Brett Cannon 175e7257b1 Remove a commented-out line 2013-11-22 12:07:43 -05:00
Brett Cannon fddc311fe8 Don't assume trying to find a builtin will succeed (e.g. posix isn't on Windows) 2013-11-22 11:58:17 -05:00
Eric Snow b523f8433a Implement PEP 451 (ModuleSpec). 2013-11-22 09:05:39 -07:00
Nick Coghlan c72e4e6dcc Issue #19619: Blacklist non-text codecs in method API
str.encode, bytes.decode and bytearray.decode now use an
internal API to throw LookupError for known non-text encodings,
rather than attempting the encoding or decoding operation and
then throwing a TypeError for an unexpected output type.

The latter mechanism remains in place for third party non-text
encodings.
2013-11-22 22:39:36 +10:00
Guido van Rossum 8820c239f7 Better behavior when stepping over yield[from]. Fixes issue 16596. By Xavier de Gaye. 2013-11-21 11:30:06 -08:00
Christian Heimes a5bcd7c0ee Issue #19183: too many tests depend on the sort order of repr().
The bitshift and xor op for 32bit builds has changed the order of hash values.
2013-11-20 12:49:05 +01:00
Christian Heimes 985ecdcfc2 ssue #19183: Implement PEP 456 'secure and interchangeable hash algorithm'.
Python now uses SipHash24 on all major platforms.
2013-11-20 11:46:18 +01:00
Victor Stinner f8e3221fa5 Issue #9566, #19617: Fix more compiler warnings in compile.c on Windows 64-bit 2013-11-19 23:56:34 +01:00
Victor Stinner 85fe8a645e Issue #9566, #19617: New try to fix compilation on Windows
Some compilers (ex: Visual Studio) decode -2147483648 as a unsigned integer
instead of an signed integer.
2013-11-19 23:03:25 +01:00
Victor Stinner b679a2eb78 Issue #9566, #19617: Fix compilation on Windows
INT32_MIN and INT32_MAX constants are unknown on Windows.
2013-11-19 22:28:01 +01:00
Victor Stinner ad9a066050 Issue #9566: compile.c uses Py_ssize_t instead of int to store sizes to fix
compiler warnings on Windows 64-bit. Use Py_SAFE_DOWNCAST() where the final
downcast is needed.

The bytecode doesn't support integer parameters larger than 32-bit yet.
2013-11-19 22:23:20 +01:00
Victor Stinner 4a58707a34 Add _PyUnicodeWriter_WriteASCIIString() function 2013-11-19 12:54:53 +01:00
Serhiy Storchaka 58cf607d13 Issue #12892: The utf-16* and utf-32* codecs now reject (lone) surrogates.
The utf-16* and utf-32* encoders no longer allow surrogate code points
(U+D800-U+DFFF) to be encoded.
The utf-32* decoders no longer decode byte sequences that correspond to
surrogate code points.
The surrogatepass error handler now works with the utf-16* and utf-32* codecs.

Based on patches by Victor Stinner and Kang-Hao (Kenny) Lu.
2013-11-19 11:32:41 +02:00
Victor Stinner cb29ec5f74 PY_FORMAT_SIZE_T should not be used with PyErr_Format(), PyErr_Format("%zd") is
portable
2013-11-18 02:05:31 +01:00
Victor Stinner 74387f5cac Use Py_ssize_t type for sizes in getargs.c
Fix compiler warnings on Windows 64-bit
2013-11-18 01:21:12 +01:00
Victor Stinner b11d6cb711 fileutils.c: use MAXPATHLEN instead of PATH_MAX
PATH_MAX is not declared on IRIX nor Windows.
2013-11-15 18:14:11 +01:00
Victor Stinner 2384714819 sysmodule.c: fix sys_update_path(), use Py_ARRAY_LENGTH() to get the size of
the fullpath buffer, not PATH_MAX. fullpath is declared using MAXPATHLEN or
MAX_PATH depending on the OS, and PATH_MAX is not declared on IRIX.
2013-11-15 17:33:43 +01:00
Victor Stinner 2f5bbc6a12 pythonrun.c: fix Py_GetPythonHome(), use Py_ARRAY_LENGTH() to get the size of
the env_home buffer, not PATH_MAX+1. env_home is declared using MAXPATHLEN+1,
and PATH_MAX is not declared on IRIX.
2013-11-15 17:09:24 +01:00
Victor Stinner da062558db Fix compiler warning (on Windows 64-bit): explicit cast Py_ssize_t to unsigned
char, n is in range [0; 255] (a tuple cannot have a negative length)
2013-11-16 00:13:29 +01:00
Victor Stinner 0c083461a5 Fix compiler warning in win32_urandom(): explicit cast to DWORD in
CryptGenRandom()
2013-11-15 23:26:25 +01:00
Victor Stinner c31ebb60f9 (Merge 3.3) fileutils.c: use MAXPATHLEN instead of PATH_MAX
PATH_MAX is not declared on IRIX nor Windows.
2013-11-15 18:14:33 +01:00
Victor Stinner 50e0157013 (Merge 3.3) sysmodule.c: fix sys_update_path(), use Py_ARRAY_LENGTH() to get
the size of the fullpath buffer, not PATH_MAX. fullpath is declared using
MAXPATHLEN or MAX_PATH depending on the OS, and PATH_MAX is not declared on
IRIX.
2013-11-15 17:35:31 +01:00
Victor Stinner b5a7a0aa3f (Merge 3.3) pythonrun.c: fix Py_GetPythonHome(), use Py_ARRAY_LENGTH() to get
the size of the env_home buffer, not PATH_MAX+1. env_home is declared using
MAXPATHLEN+1, and PATH_MAX is not declared on IRIX.
2013-11-15 17:12:14 +01:00
Nick Coghlan c4c2580d43 Close 19609: narrow scope of codec exc chaining 2013-11-15 21:47:37 +10:00
Victor Stinner 5eb4f59cd9 Issue #19437: Fix init_builtin(), handle _PyImport_FindExtensionObject()
failure
2013-11-14 22:38:52 +01:00
Stefan Krah 49d0479357 Add unused third arg for the benefit of Valgrind. 2013-11-14 15:35:47 +01:00
Victor Stinner c82729e44f Issue #19437: Fix fold_unaryops_on_constants() of the peephole optimizer, clear
the exception when PyList_Append() fails
2013-11-14 01:21:00 +01:00
Nick Coghlan 8b097b4ed7 Close #17828: better handling of codec errors
- output type errors now redirect users to the type-neutral
  convenience functions in the codecs module
- stateless errors that occur during encoding and decoding
  will now be automatically wrapped in exceptions that give
  the name of the codec involved
2013-11-13 23:49:21 +10:00
Victor Stinner 22af2599a9 Issue #19437: Fix PyImport_ImportModuleLevelObject(), handle
PyUnicode_Substring() failure (ex: MemoryError)
2013-11-13 12:11:36 +01:00