Commit Graph

2179 Commits

Author SHA1 Message Date
Benjamin Peterson da5eb5a31c don't expand the operand to Py_XINCREF/XDECREF/CLEAR/DECREF multiple times (closes #17206)
A patch from Illia Polosukhin.
2013-05-27 14:46:14 -07:00
Eli Bendersky 7b3022f24f Issue #13612: handle unknown encodings without a buffer overflow.
This affects pyexpat and _elementtree. PyExpat_CAPI now exposes a new
function - DefaultUnknownEncodingHandler.

Based on a patch by Serhiy Storchaka.
2013-05-25 05:27:10 -07:00
Serhiy Storchaka 447b6e3c6e Issue #16986: ElementTree now correctly parses a string input not only when
an internal XML encoding is UTF-8 or US-ASCII.
2013-05-22 17:21:06 +03:00
Antoine Pitrou fef34e3186 Issue #17937: Try harder to collect cyclic garbage at shutdown. 2013-05-19 01:11:58 +02:00
Benjamin Peterson e8e14591eb rather than passing locals to the class body, just execute the class body in the proper environment 2013-05-16 14:37:25 -05:00
Benjamin Peterson 312595ce3a hide the __class__ closure from the class body (#12370) 2013-05-15 15:26:42 -05:00
Georg Brandl c032f16d18 post-release update. 2013-05-15 19:42:39 +02:00
Antoine Pitrou 9396356948 Backout c89febab4648 following private feedback by Guido.
(Issue #17807: Generators can now be finalized even when they are part of a reference cycle)
2013-05-14 20:37:52 +02:00
Benjamin Peterson f6b687fcd4 remove support GCC PyArg_ParseTuple format patch, last seen in 2006 2013-05-12 23:08:28 -05:00
Georg Brandl 88f4dd6451 bump to 3.3.2 2013-05-12 12:51:38 +02:00
Charles-Francois Natali f28dfdd07b Issue #17912: Use a doubly linked-list for thread states. 2013-05-08 21:09:52 +02:00
Antoine Pitrou 04e70d19e7 Issue #17807: Generators can now be finalized even when they are part of a reference cycle. 2013-05-08 18:12:35 +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
Antoine Pitrou 8408cea0cd Issue #17094: Clear stale thread states after fork().
Note that this is a potentially disruptive change since it may
release some system resources which would otherwise remain
perpetually alive (e.g. database connections kept in thread-local
storage).
2013-05-05 23:47:09 +02:00
Antoine Pitrou df6931dbbc Issue #17408: Avoid using an obsolete instance of the copyreg module when the interpreter is shutdown and then started again. 2013-05-04 20:46:19 +02:00
Antoine Pitrou 957a23b088 Issue #17408: Avoid using an obsolete instance of the copyreg module when the interpreter is shutdown and then started again. 2013-05-04 20:45:02 +02:00
Alexandre Vassalotti 865eaa1b53 Closes #17892: Fix the name of _PyObject_CallMethodObjIdArgs 2013-05-02 10:44:04 -07:00
Benjamin Peterson 3b0431dc60 check local class namespace before reaching for cells (closes #17853) 2013-04-30 09:41:40 -04:00
Victor Stinner f476405503 fix typo in a comment 2013-04-18 23:21:19 +02:00
Victor Stinner 8f674ccd64 Close #17694: Add minimum length to _PyUnicodeWriter
* Add also min_char attribute to _PyUnicodeWriter structure (currently unused)
 * _PyUnicodeWriter_Init() has no more argument (except the writer itself):
   min_length and overallocate must be set explicitly
 * In error handlers, only enable overallocation if the replacement string
   is longer than 1 character
 * CJK decoders don't use overallocation anymore
 * Set min_length, instead of preallocating memory using
   _PyUnicodeWriter_Prepare(), in many decoders
 * _PyUnicode_DecodeUnicodeInternal() checks for integer overflow
2013-04-17 23:02:17 +02:00
Victor Stinner a0dd0213cc Close #17693: Rewrite CJK decoders to use the _PyUnicodeWriter API instead of
the legacy Py_UNICODE API.

Add also a new _PyUnicodeWriter_WriteChar() function.
2013-04-11 22:09:04 +02:00
Georg Brandl bf561020a7 Post-release update for 3.3.1 2013-04-06 16:43:06 +02:00
Georg Brandl 9aa23c5671 Bump to 3.3.1. 2013-04-06 09:40:02 +02:00
Victor Stinner cfc4c13b04 Add _PyUnicodeWriter_WriteSubstring() function
Write a function to enable more optimizations:

 * If the substring is the whole string and overallocation is disabled, just
   keep a reference to the string, don't copy characters
 * Avoid a call to the expensive _PyUnicode_FindMaxChar() function when
   possible
2013-04-03 01:48:39 +02:00
Georg Brandl d08d0b1c69 Bump to 3.3.1rc1. 2013-03-23 16:05:12 +01:00
Kristján Valur Jónsson 684cd0e643 Issue #17522: Add the PyGILState_Check() API. 2013-03-23 03:36:16 -07:00
Kristján Valur Jónsson d7009c6913 Issue #16475: Support object instancing, recursion and interned strings
in marshal
2013-03-19 18:02:10 -07:00
Benjamin Peterson cda75be02a unify some ast.argument's attrs; change Attribute column offset (closes #16795)
Patch from Sven Brauch.
2013-03-18 10:48:58 -07:00
Benjamin Peterson 7701e6ef93 make some freezing related stuff const 2013-03-13 14:06:39 -05:00
Terry Jan Reedy 8e7586bd44 Issue #17047: remove doubled words added in 3.4,
as reported by Serhiy Storchaka and Matthew Barnett.
2013-03-11 18:38:13 -04:00
Benjamin Peterson 00e9886bd9 Add PyDict_SetDefault. (closes #17327)
Patch by Stefan Behnel and I.
2013-03-07 22:16:29 -05:00
Serhiy Storchaka d7be03aafa Issue #1783: Remove declarations of nonexistent private variables. 2013-02-01 13:15:17 +02:00
Serhiy Storchaka 89fa86b035 Issue #1783: Remove declarations of nonexistent private variables. 2013-02-01 13:14:47 +02:00
Serhiy Storchaka 04d86c7c87 Issue #1783: Remove declarations of nonexistent private variables. 2013-02-01 13:14:20 +02:00
Serhiy Storchaka 441d30fac7 Issue #15989: Fix several occurrences of integer overflow
when result of PyLong_AsLong() narrowed to int without checks.

This is a backport of changesets 13e2e44db99d and 525407d89277.
2013-01-19 12:26:26 +02:00
Serhiy Storchaka 9101e23ff6 Issue #15989: Fix several occurrences of integer overflow
when result of PyLong_AsLong() narrowed to int without checks.

This is a backport of changesets 13e2e44db99d and 525407d89277.
2013-01-19 12:41:45 +02:00
Serhiy Storchaka 7898043868 Issue #15989: Fix several occurrences of integer overflow
when result of PyLong_AsLong() narrowed to int without checks.
2013-01-15 01:12:17 +02:00
Christian Heimes fb4b7b40e4 Issue #16881: Fix Py_ARRAY_LENGTH macro for GCC < 3.1. 2013-01-06 16:42:20 +01:00
Christian Heimes 61dbb00869 Issue #16881: Fix Py_ARRAY_LENGTH macro for GCC < 3.1. 2013-01-06 16:41:56 +01:00
Andrew Svetlov 192b10b371 Revert back PyCFunction_New macro. Keep PyCFunction_NewEx usage in python core modules (#15422) 2012-12-26 22:52:04 +02:00
Andrew Svetlov 3ba3a3ee56 Issue #15422: get rid of PyCFunction_New macro 2012-12-25 13:32:35 +02:00
Gregory P. Smith 27dc02e8c5 Fix the internals of our hash functions to used unsigned values during hash
computation as the overflow behavior of signed integers is undefined.

NOTE: This change is smaller compared to 3.2 as much of this cleanup had
already been done.  I added the comment that my change in 3.2 added so that the
code would match up.  Otherwise this just adds or synchronizes appropriate UL
designations on some constants to be pedantic.

In practice we require compiling everything with -fwrapv which forces overflow
to be defined as twos compliment but this keeps the code cleaner for checkers
or in the case where someone has compiled it without -fwrapv or their
compiler's equivalent.  We could work to get rid of the -fwrapv requirement
in 3.4 but that requires more planning.

Found by Clang trunk's Undefined Behavior Sanitizer (UBSan).

Cleanup only - no functionality or hash values change.
2012-12-10 19:51:29 -08:00
Gregory P. Smith c2176e46d7 Fix the internals of our hash functions to used unsigned values during hash
computation as the overflow behavior of signed integers is undefined.

NOTE: This change is smaller compared to 3.2 as much of this cleanup had
already been done.  I added the comment that my change in 3.2 added so that the
code would match up.  Otherwise this just adds or synchronizes appropriate UL
designations on some constants to be pedantic.

In practice we require compiling everything with -fwrapv which forces overflow
to be defined as twos compliment but this keeps the code cleaner for checkers
or in the case where someone has compiled it without -fwrapv or their
compiler's equivalent.

Found by Clang trunk's Undefined Behavior Sanitizer (UBSan).

Cleanup only - no functionality or hash values change.
2012-12-10 18:32:53 -08:00
Gregory P. Smith 27cbcd6241 Fix the internals of our hash functions to used unsigned values during hash
computation as the overflow behavior of signed integers is undefined.

In practice we require compiling everything with -fwrapv which forces overflow
to be defined as twos compliment but this keeps the code cleaner for checkers
or in the case where someone has compiled it without -fwrapv or their
compiler's equivalent.

Found by Clang trunk's Undefined Behavior Sanitizer (UBSan).

Cleanup only - no functionality or hash values change.
2012-12-10 18:15:46 -08:00
Gregory P. Smith e348c8d154 Using 'long double' to force this structure to be worst case aligned is no
longer required as of Python 2.5+ when the gc_refs changed from an int (4
bytes) to a Py_ssize_t (8 bytes) as the minimum size is 16 bytes.

The use of a 'long double' triggered a warning by Clang trunk's
Undefined-Behavior Sanitizer as on many platforms a long double requires
16-byte alignment but the Python memory allocator only guarantees 8 byte
alignment.

So our code would allocate and use these structures with technically improper
alignment.  Though it didn't matter since the 'dummy' field is never used.
This silences that warning.

Spelunking into code history, the double was added in 2001 to force better
alignment on some platforms and changed to a long double in 2002 to appease
Tru64.  That issue should no loner be present since the upgrade from int to
Py_ssize_t where the minimum structure size increased to 16 (unless anyone
knows of a platform where ssize_t is 4 bytes?) or 24 bytes depending on if the
build uses 4 or 8 byte pointers.

We can probably get rid of the double and this union hack all together today.
That is a slightly more invasive change that can be left for later.

A more correct non-hacky alternative if any alignment issues are still found
would be to use a compiler specific alignment declaration on the structure and
determine which value to use at configure time.
2012-12-10 18:05:05 -08:00
Antoine Pitrou f9d0b1256f Issue #13390: New function :func:`sys.getallocatedblocks()` returns the number of memory blocks currently allocated.
Also, the ``-R`` option to regrtest uses this function to guard against memory allocation leaks.
2012-12-09 14:28:26 +01:00
Antoine Pitrou 53f604c794 Issue #16602: When a weakref's target was part of a long deallocation chain, the object could remain reachable through its weakref even though its refcount had dropped to zero.
Thanks to Eugene Toder for diagnosing and reporting the issue.
2012-12-08 21:18:50 +01:00
Antoine Pitrou f93ed3fa67 Issue #16602: When a weakref's target was part of a long deallocation chain, the object could remain reachable through its weakref even though its refcount had dropped to zero.
Thanks to Eugene Toder for diagnosing and reporting the issue.
2012-12-08 21:17:03 +01:00
Antoine Pitrou 62a0d6ea40 Issue #16602: When a weakref's target was part of a long deallocation chain, the object could remain reachable through its weakref even though its refcount had dropped to zero.
Thanks to Eugene Toder for diagnosing and reporting the issue.
2012-12-08 21:15:26 +01:00
Benjamin Peterson 442f20996d create NameConstant AST class for None, True, and False literals (closes #16619) 2012-12-06 17:41:04 -05:00
Andrew Svetlov 746d0434ae Update comment: SAVE_EXC_STATE and SWAP_EXC_STATE macroses are saave_exc_state and swap_exc_state functions now. 2012-12-05 17:59:29 +02:00
Andrew Svetlov c37cfd6709 Update comment: SAVE_EXC_STATE and SWAP_EXC_STATE macroses are saave_exc_state and swap_exc_state functions now. 2012-12-05 17:59:10 +02:00
Victor Stinner d45c7f8d74 Issue #16455: On FreeBSD and Solaris, if the locale is C, the
ASCII/surrogateescape codec is now used, instead of the locale encoding, to
decode the command line arguments. This change fixes inconsistencies with
os.fsencode() and os.fsdecode() because these operating systems announces an
ASCII locale encoding, whereas the ISO-8859-1 encoding is used in practice.
2012-12-04 01:34:47 +01:00
Mark Dickinson 6e61d18891 Issue 10052: merge fix from 3.2. 2012-12-02 13:21:37 +00:00
Mark Dickinson ce31f66a6d Issue 10052: fix failed uint32_t / uint64_t / int32_t / int64_t detection on some platforms. 2012-12-02 13:20:22 +00:00
Mark Dickinson 983bc16c15 Issue 10052: fix failed uint32_t / uint64_t / int32_t / int64_t detection on some platforms. 2012-12-02 12:11:38 +00:00
Benjamin Peterson e5b45cc5e5 remove unused flag (closes #16505) 2012-11-18 20:49:39 -06:00
Stefan Krah 36f021621e Backport 9dd4638de73b. 2012-11-19 00:54:05 +01:00
Stefan Krah 2cbbed6541 Issue #6308: Try to fix the termios build failure on HP-UX. 2012-11-19 00:07:18 +01:00
Mark Dickinson ffdb2c21b3 Issue #16451: Refactor to remove duplication between range and slice in slice index computations. 2012-11-17 19:18:10 +00:00
Stefan Krah abaca8cb06 Merge 3.3. 2012-11-12 20:24:09 +01:00
Stefan Krah 6df5cae49a Issue #15835: Define PATH_MAX on HP-UX. 2012-11-12 20:14:36 +01:00
Nick Coghlan e69bfc3fb6 Issue #5765: Merge from 3.3 2012-11-04 23:53:15 +10:00
Nick Coghlan aab9c2b2ea Issue #5765: Apply a hard recursion limit in the compiler
Previously, excessive nesting in expressions would blow the
stack and segfault the interpreter. Now, a hard limit based
on the configured recursion limit and a hardcoded scaling
factor is applied.
2012-11-04 23:14:34 +10:00
Benjamin Peterson d9c8702c0f point errors related to nonlocals and globals to the statement declaring them (closes #10189) 2012-10-31 20:26:20 -04:00
Benjamin Peterson 742b2f8d7a make PyGrammar_LabelRepr return a const char * (closes #16369) 2012-10-31 13:36:13 -04:00
Victor Stinner 4ca1cf35fb Issue #16086: PyTypeObject.tp_flags and PyType_Spec.flags are now unsigned
... (unsigned long and unsigned int) to avoid an undefined behaviour with
Py_TPFLAGS_TYPE_SUBCLASS ((1 << 31). PyType_GetFlags() result type is now
unsigned too (unsigned long, instead of long).
2012-10-30 23:40:45 +01:00
Victor Stinner 76df43de30 Issue #16330: Use surrogate-related macros
Patch written by Serhiy Storchaka.
2012-10-30 01:42:39 +01:00
Georg Brandl 3962d5e892 Minor typo fix. 2012-10-28 08:48:28 +01:00
Benjamin Peterson d0845588b8 make _PyParser_TokenNames const 2012-10-24 08:21:52 -07:00
Christian Heimes 743e0cd6b5 Issue #16166: Add PY_LITTLE_ENDIAN and PY_BIG_ENDIAN macros and unified
endianess detection and handling.
2012-10-17 23:52:17 +02:00
Armin Ronacher 74b38b190f Issue #16148: Small improvements and cleanup. Added version information
to docs.
2012-10-07 10:29:32 +02:00
Victor Stinner e215d960be Issue #16147: Rewrite PyUnicode_FromFormatV() to use _PyUnicodeWriter API
* Simplify the code: replace 4 steps with one unique step using the
   _PyUnicodeWriter API. PyUnicode_Format() has the same design. It avoids to
   store intermediate results which require to allocate an array of pointers on
   the heap.
 * Use the _PyUnicodeWriter API for speed (and its convinient API):
   overallocate the buffer to reduce the number of "realloc()"
 * Implement "width" and "precision" in Python, don't rely on sprintf(). It
   avoids to need of a temporary buffer allocated on the heap: only use a small
   buffer allocated in the stack.
 * Add _PyUnicodeWriter_WriteCstr() function
 * Split PyUnicode_FromFormatV() into two functions: add
   unicode_fromformat_arg().
 * Inline parse_format_flags(): the format of an argument is now only parsed
   once, it's no more needed to have a subfunction.
 * Optimize PyUnicode_FromFormatV() for characters between two "%" arguments:
   search the next "%" and copy the substring in one chunk, instead of copying
   character per character.
2012-10-06 23:03:36 +02:00
Armin Ronacher aa9a79d279 Issue #16148: implemented PEP 424 2012-10-06 14:03:24 +02:00
Ezio Melotti 080a2c087e #16127: merge with 3.3. 2012-10-05 03:34:02 +03:00
Ezio Melotti e7f90375b1 #16127: remove outdated references to narrow builds. Patch by Serhiy Storchaka. 2012-10-05 03:33:31 +03:00
Jesus Cea b176203dda #16135: Removal of OS/2 support (C code and Docs) 2012-10-05 02:27:40 +02:00
Victor Stinner 90db9c47dc Enable also ptr==ptr optimization in PyUnicode_Compare()
It was already implemented in PyUnicode_RichCompare()
2012-10-04 21:53:50 +02:00
Benjamin Peterson 14fb44e1ba merge mostly from default 2012-09-29 14:14:19 -04:00
Georg Brandl ac76833033 Post-release update. 2012-09-29 14:21:25 +02:00
Georg Brandl 08a9012352 Bump version to 3.4.0 alpha 0. 2012-09-29 09:34:13 +02:00
Georg Brandl 99a247fd01 Merge with main repo default branch. 2012-09-29 09:27:15 +02:00
Georg Brandl c7dcd50e4e Bump version to 3.3.0 final. 2012-09-29 09:04:54 +02:00
Georg Brandl b5f91d7eb7 Merge with 3.3.0 release clone. 2012-09-24 07:46:35 +02:00
Georg Brandl f2487177eb Post-release updates. 2012-09-24 07:42:20 +02:00
Georg Brandl 8506d3591c Bump to 3.3.0rc3. 2012-09-23 17:15:21 +02:00
Christian Heimes fd0ddab97b GCC doesn't support typeof in strict ansi mode (e.g. -ansi or -std=c89) 2012-09-23 16:15:01 +02:00
Christian Heimes ab816b5c85 GCC doesn't support typeof in strict ansi mode (e.g. -ansi or -std=c89) 2012-09-23 16:15:01 +02:00
Antoine Pitrou ca8aa4acf6 Issue #15144: Fix possible integer overflow when handling pointers as integer values, by using Py_uintptr_t instead of size_t.
Patch by Serhiy Storchaka.
2012-09-20 20:56:47 +02:00
Georg Brandl 5497295917 Merge in changes from 3.3.0rc2 release clone. 2012-09-09 11:19:17 +02:00
Georg Brandl 05823f7d67 Post-release updates for 3.3.0rc2. 2012-09-09 11:16:41 +02:00
Antoine Pitrou 5b4faae307 Issue #13992: The trashcan mechanism is now thread-safe. This eliminates
sporadic crashes in multi-thread programs when several long deallocator
chains ran concurrently and involved subclasses of built-in container
types.

Note that the trashcan functions are part of the stable ABI, therefore
they have to be kept around for binary compatibility of extensions.
2012-09-06 01:17:42 +02:00
Antoine Pitrou 56cd62c04a Issue #13992: The trashcan mechanism is now thread-safe. This eliminates
sporadic crashes in multi-thread programs when several long deallocator
chains ran concurrently and involved subclasses of built-in container
types.

Because of this change, a couple extension modules compiled for 3.2.4
(those which use the trashcan mechanism, despite it being undocumented)
will not be loadable by 3.2.3 and earlier. However, extension modules
compiled for 3.2.3 and earlier will be loadable by 3.2.4.
2012-09-06 00:59:49 +02:00
Georg Brandl 02f66cbe87 Bump to 3.3.0rc2. 2012-09-09 08:56:46 +02:00
Antoine Pitrou 2b0218a259 Issue #13992: The trashcan mechanism is now thread-safe. This eliminates
sporadic crashes in multi-thread programs when several long deallocator
chains ran concurrently and involved subclasses of built-in container
types.

Because of this change, a couple extension modules compiled for 3.2.4
(those which use the trashcan mechanism, despite it being undocumented)
will not be loadable by 3.2.3 and earlier. However, extension modules
compiled for 3.2.3 and earlier will be loadable by 3.2.4.
2012-09-06 00:59:49 +02:00
Trent Nelson 81378c8296 Merge whitespace fix from 3.2. 2012-08-31 17:14:31 -04:00
Trent Nelson 2a0fb147ec Remove trailing whitespace in order to silence warnings on HP-UX. 2012-08-31 17:11:39 -04:00
Georg Brandl 3694401ad2 Post-release updates. 2012-08-25 21:33:08 +02:00
Georg Brandl 4ab4ec258c Bump to 3.3.0rc1. 2012-08-25 12:16:37 +02:00