Christian Heimes
26532f7519
Check return value of PyType_Ready(&EncodingMapType)
...
CID 486654
2013-07-20 14:57:16 +02:00
Christian Heimes
de4d183955
Issue #18327 : Fix argument order in call to compatible_for_assignment(oldto, newto, attr).
...
The fix only affects the error message of __class__ assignment. CID 983564
2013-07-20 14:19:46 +02:00
Victor Stinner
2c40f640d9
Issue #18408 : Fix list_ass_slice(), handle list_resize() failure
...
I tested the patch manually by injecting a fault using gdb: list items are
correctly restored on failure.
2013-07-19 23:06:21 +02:00
Victor Stinner
8e47832737
Issue #18408 : PyObject_Str(), PyObject_Repr() and type_call() now fail with an
...
assertion error if they are called with an exception set (PyErr_Occurred()).
As PyEval_EvalFrameEx(), they may clear the current exception and so the caller
looses its exception.
2013-07-18 01:49:30 +02:00
Victor Stinner
f97dfd7b59
Issue #18408 : Fix dict_repr(), don't call PyObject_Repr() with an exception set
...
PyObject_Repr() can removes the current exception. For example, module_repr()
calls PyErr_Clear() if calling loader.module_repr(mod) failed.
2013-07-18 01:00:45 +02:00
Victor Stinner
08a80b11ad
longobject.c: add an assertion to ensure that MEDIUM_VALUE() is only called on
...
small integers (0 or 1 digit)
2013-07-17 22:33:42 +02:00
Victor Stinner
8aed6f1c7d
Issue #18408 : Rewrite NEGATE() macro in longobject.c to handle PyLong_FromLong() failure
2013-07-17 22:31:17 +02:00
Victor Stinner
5967bf4928
Issue #18408 : Fix PyType_Ready(), handle _PyDict_SetItemId() failure
2013-07-17 22:01:37 +02:00
Victor Stinner
e901d1fbdf
Issue #18408 : Fix Py_ReprEnter(), handle PyList_Append() failure
2013-07-17 21:58:41 +02:00
Victor Stinner
095d99ffff
Issue #18408 : Fix listpop(), handle list_ass_slice() failure
2013-07-17 21:58:01 +02:00
Victor Stinner
9a146eeadb
Issue #18408 : Fix structseq_reduce(), handle PyDict_SetItemString() failure
2013-07-17 13:41:39 +02:00
Victor Stinner
26f91999b4
Close #18469 : Replace PyDict_GetItemString() with _PyDict_GetItemId() in structseq.c
...
_PyDict_GetItemId() is more efficient: it only builds the Unicode string once.
Identifiers (dictionary keys) are now created at Python initialization, and if
the creation failed, Python does exit with a fatal error.
Before, PyDict_GetItemString() failure was not handled: structseq_new() could
call PyObject_GC_NewVar() with a negative size, and structseq_dealloc() could
also crash.
2013-07-17 01:22:45 +02:00
Victor Stinner
3997cfdb7f
Cleanup type_call() to ease debug
...
It was easy to miss the call to type->tp_init because it was done in a long
conditional expression. Split the long expression in multiple lines to make the
debug step by step easier.
2013-07-16 22:51:21 +02:00
Victor Stinner
1b63493ed1
Issue #18408 : Py_ReprLeave() now saves/restores the current exception,
...
and ignores exceptions raised during the call
2013-07-16 22:24:44 +02:00
Victor Stinner
ac2a4fe8a2
Issue #18408 : dict_new() now fails on new_keys_object() error
...
Pass the MemoryError exception to the caller, instead of using empty keys.
2013-07-16 22:19:00 +02:00
Victor Stinner
a9f61a5a23
Cleanup dictobject.c
2013-07-16 22:17:26 +02:00
Victor Stinner
fdcbab9602
Issue #18408 : Fix PyDict_GetItemString(), suppress PyUnicode_FromString() error
...
As PyDict_GetItem(), PyDict_GetItemString() suppresses all errors that may
occur for historical reasons.
2013-07-16 22:16:05 +02:00
Victor Stinner
32fd6eab1e
Issue #18408 : Fix list.extend(), handle list_resize() failure
2013-07-16 21:45:58 +02:00
Victor Stinner
f243ee4055
Issue #18408 : add more assertions on PyErr_Occurred() in ceval.c to detect bugs
...
earlier
2013-07-16 01:02:12 +02:00
Victor Stinner
53510cda59
Issue #18408 : type_new() and PyType_FromSpecWithBases() now raise MemoryError
...
on memory allocation failure
2013-07-15 19:34:20 +02:00
Victor Stinner
e699e5a218
Issue #18408 : Don't check unicode consistency in _PyUnicode_HAS_UTF8_MEMORY()
...
and _PyUnicode_HAS_WSTR_MEMORY() macros
These macros are called in unicode_dealloc(), whereas the unicode object can be
"inconsistent" if the creation of the object failed.
For example, when unicode_subtype_new() fails on a memory allocation,
_PyUnicode_CheckConsistency() fails with an assertion error because data is
NULL.
2013-07-15 18:22:47 +02:00
Victor Stinner
3de5869864
Issue #18408 : PyObject_Call() now fails with an assertion error in debug mode
...
if the function called failed whereas no exception was raised, to detect bugs
earlier.
2013-07-15 17:50:07 +02:00
Victor Stinner
a41f085144
Issue #18408 : pmerge() help of mro_implementation() now raises MemoryError on
...
memory allocation failure
Replace also PyMem_Free() with PyMem_FREE() to be consistent with the rest of
the function.
2013-07-12 00:42:14 +02:00
Victor Stinner
9035ad932b
Issue #18408 : In debug mode, PyCFunction_Call() now checks if an exception was
...
raised if the result is NULL to help to find bugs in C mode (get the error
earlier than the SystemError in ceval.c).
2013-07-11 23:44:46 +02:00
Victor Stinner
2e8474ddde
Issue #18408 : slot_tp_str() must not fallback on slot_tp_repr() on error
...
type->tp_str must not point to slot_tp_str() if type has no __str__ attribute,
so there is no reason for slot_tp_str() to fallback on slot_tp_str() on lookup
error. Moreover, calling PyErr_Clear() may hide a real bug like MemoryError.
If __str__ attribute is removed, slots must be updated (which is done by
type_setattro()).
2013-07-11 22:46:11 +02:00
Victor Stinner
54e4ca76c9
typeobject.c: remove trailing spaces
2013-07-11 22:42:25 +02:00
Victor Stinner
c4266360fc
Issue #18408 : Fix _PyMem_DebugRealloc()
...
Don't mark old extra memory dead before calling realloc(). realloc() can fail
and realloc() must not touch the original buffer on failure.
So mark old extra memory dead only on success if the new buffer did not move
(has the same address).
2013-07-09 00:44:43 +02:00
Victor Stinner
9e6b4d715c
Issue #18408 : _PyUnicodeWriter_Finish() now clears its buffer attribute in all
...
cases, so _PyUnicodeWriter_Dealloc() can be called after finish.
2013-07-09 00:37:24 +02:00
Victor Stinner
15a0bd3965
Issue #18408 : Fix _PyUnicodeWriter_Finish(): clear writer->buffer,
...
so _PyUnicodeWriter_Dealloc() can be called on the writer after finish.
2013-07-08 22:29:55 +02:00
Victor Stinner
9812af8e72
Issue #18408 : Fix PyType_Ready() and type.__bases__ setter to handle
...
PyWeakref_NewRef() failure (ex: MemoryError).
2013-07-08 22:25:48 +02:00
Victor Stinner
b27cd3e5ad
Issue #18408 : Fix list.pop() to handle list_resize() failure (MemoryError).
2013-07-08 22:20:44 +02:00
Victor Stinner
c9b7f51ec2
Issue #18408 : Fix PyDict_New() to handle correctly new_keys_object() failure
...
(MemoryError).
2013-07-08 22:19:20 +02:00
Victor Stinner
49fc8ece81
Issue #18203 : Add _PyMem_RawStrdup() and _PyMem_Strdup()
...
Replace strdup() with _PyMem_RawStrdup() or _PyMem_Strdup(), depending if the
GIL is held or not.
2013-07-07 23:30:24 +02:00
Victor Stinner
6f8eeee7b9
Issue #18203 : Fix _Py_DecodeUTF8_surrogateescape(), use PyMem_RawMalloc() as _Py_char2wchar()
2013-07-07 22:57:45 +02:00
Victor Stinner
0e2d3cf2cb
Issue #18203 : Replace malloc() with PyMem_Malloc() in _PySequence_BytesToCharpArray()
2013-07-07 17:22:41 +02:00
Victor Stinner
1a7425f67a
Issue #18203 : Replace malloc() with PyMem_RawMalloc() at Python initialization
...
* Replace malloc() with PyMem_RawMalloc()
* Replace PyMem_Malloc() with PyMem_RawMalloc() where the GIL is not held.
* _Py_char2wchar() now returns a buffer allocated by PyMem_RawMalloc(), instead
of PyMem_Malloc()
2013-07-07 16:25:15 +02:00
Victor Stinner
725e668ac8
Issue #3329 : Fix _PyObject_ArenaVirtualFree()
...
According to VirtualFree() documentation, the size must be zero if the "free
type" is MEM_RELEASE.
2013-07-07 03:06:16 +02:00
Victor Stinner
0507bf56f0
Issue #3329 : Implement the PEP 445
...
Add new enum:
* PyMemAllocatorDomain
Add new structures:
* PyMemAllocator
* PyObjectArenaAllocator
Add new functions:
* PyMem_RawMalloc(), PyMem_RawRealloc(), PyMem_RawFree()
* PyMem_GetAllocator(), PyMem_SetAllocator()
* PyObject_GetArenaAllocator(), PyObject_SetArenaAllocator()
* PyMem_SetupDebugHooks()
Changes:
* PyMem_Malloc()/PyObject_Realloc() now always call malloc()/realloc(), instead
of calling PyObject_Malloc()/PyObject_Realloc() in debug mode.
* PyObject_Malloc()/PyObject_Realloc() now falls back to
PyMem_Malloc()/PyMem_Realloc() for allocations larger than 512 bytes.
* Redesign debug checks on memory block allocators as hooks, instead of using C
macros
2013-07-07 02:05:46 +02:00
Brett Cannon
679ecb565b
Issue #15767 : back out 8a0ed9f63c6e, finishing the removal of
...
ModuleNotFoundError.
2013-07-04 17:51:50 -04:00
Christian Heimes
d47802eef7
Fix ref leak in error case of unicode find, count, formatlong
...
CID 983315: Resource leak (RESOURCE_LEAK)
CID 983316: Resource leak (RESOURCE_LEAK)
CID 983317: Resource leak (RESOURCE_LEAK)
2013-06-29 21:33:36 +02:00
Christian Heimes
d47a0456b1
Fix ref leak in error case of unicode index
...
CID 983319 (#1 of 2): Resource leak (RESOURCE_LEAK)
leaked_storage: Variable substring going out of scope leaks the storage it points to.
2013-06-29 21:21:37 +02:00
Christian Heimes
ea71a525c3
Fix ref leak in error case of unicode rindex and rfind
...
CID 983320: Resource leak (RESOURCE_LEAK)
CID 983321: Resource leak (RESOURCE_LEAK)
leaked_storage: Variable substring going out of scope leaks the storage it points to.
2013-06-29 21:17:34 +02:00
Christian Heimes
305e49e17e
Fix memory leak in endswith
...
CID 1040368 (#1 of 1): Resource leak (RESOURCE_LEAK)
leaked_storage: Variable substring going out of scope leaks the storage it points to.
2013-06-29 20:41:06 +02:00
Martin v. Löwis
cd83fa8c3e
Issue #13483 : Use VirtualAlloc in obmalloc on Windows.
2013-06-27 12:23:29 +02:00
Victor Stinner
14b9b11098
If MS_WIN64 is defined, MS_WINDOWS is also defined: #ifdef can be simplified.
2013-06-25 00:37:25 +02:00
Victor Stinner
7660b880a5
Issue #9566 : More long/Py_ssize_t fixes in tuple and list iterators (it_index)
2013-06-24 23:59:24 +02:00
Victor Stinner
2199c38729
Issue #9566 : Fix a compiler warning in tupleiter_setstate() on Windows x64
2013-06-24 23:31:48 +02:00
Serhiy Storchaka
c89533f72f
Issue #18184 : PyUnicode_FromFormat() and PyUnicode_FromFormatV() now raise
...
OverflowError when an argument of %c format is out of range.
2013-06-23 20:21:16 +03:00
Serhiy Storchaka
8eeae2126c
Issue #18184 : PyUnicode_FromFormat() and PyUnicode_FromFormatV() now raise
...
OverflowError when an argument of %c format is out of range.
2013-06-23 20:12:14 +03:00
Antoine Pitrou
5e946bacef
Fix compilation warning with gcc 4.8 (unused typedef)
2013-06-18 23:28:18 +02:00
Victor Stinner
36f01ad9ac
Revert changeset 6661a8154eb3: Issue #3329 : Add new APIs to customize memory allocators
...
The new API require more discussion.
2013-06-15 03:37:01 +02:00
Victor Stinner
4d7056258b
Issue #3329 : Add new APIs to customize memory allocators
...
* Add a new PyMemAllocators structure
* New functions:
- PyMem_RawMalloc(), PyMem_RawRealloc(), PyMem_RawFree(): GIL-free memory
allocator functions
- PyMem_GetRawAllocators(), PyMem_SetRawAllocators()
- PyMem_GetAllocators(), PyMem_SetAllocators()
- PyMem_SetupDebugHooks()
- _PyObject_GetArenaAllocators(), _PyObject_SetArenaAllocators()
* Add unit test for PyMem_Malloc(0) and PyObject_Malloc(0)
* Add unit test for new get/set allocators functions
* PyObject_Malloc() now falls back on PyMem_Malloc() instead of malloc() if
size is bigger than SMALL_REQUEST_THRESHOLD, and PyObject_Realloc() falls
back on PyMem_Realloc() instead of realloc()
* PyMem_Malloc() and PyMem_Realloc() now always call malloc() and realloc(),
instead of calling PyObject_Malloc() and PyObject_Realloc() in debug mode
2013-06-15 00:37:46 +02:00
Brett Cannon
b1611e2772
Issue #15767 : Introduce ModuleNotFoundError, a subclass of
...
ImportError.
The exception is raised by import when a module could not be found.
Technically this is defined as no viable loader could be found for the
specified module. This includes ``from ... import`` statements so that
the module usage is consistent for all situations where import
couldn't find what was requested.
This should allow for the common idiom of::
try:
import something
except ImportError:
pass
to be updated to using ModuleNotFoundError and not accidentally mask
ImportError messages that should propagate (e.g. issues with a
loader).
This work was driven by the fact that the ``from ... import``
statement needed to be able to tell the difference between an
ImportError that simply couldn't find a module (and thus silence the
exception so that ceval can raise it) and an ImportError that
represented an actual problem.
2013-06-12 16:59:46 -04:00
Benjamin Peterson
3164f5d565
merge 3.3 ( #18183 )
2013-06-10 09:24:01 -07:00
Benjamin Peterson
7e30373126
remove MAX_MAXCHAR because it's unsafe for computing maximum codepoitn value (see #18183 )
2013-06-10 09:19:46 -07:00
Victor Stinner
9f067f490f
Issue #9566 : Fix compiler warning on Windows 64-bit
2013-06-05 00:21:31 +02:00
Victor Stinner
9d77664e01
Issue #9566 : Fix a compiler warning on Windows 64-bit in namespace_init()
...
The result type is int, return -1 to avoid a compiler warning (cast Py_ssize_t
to int). PyObject_Size() can only fail with -1, and anyway a constructor
should return -1 on error, not an arbitrary negative number.
2013-06-05 00:13:51 +02:00
Victor Stinner
a2d56984c7
Issuse #17932 : Fix an integer overflow issue on Windows 64-bit in tuple
...
iterators: change the C type of tupleiterobject.it_index from long to
Py_ssize_t.
2013-06-05 00:11:34 +02:00
Victor Stinner
640c35ce13
Reuse Py_MIN and Py_MAX macros: remove duplicate MIN/MAX macros
...
multiprocessing.h: remove unused MIN and MAX macros
2013-06-04 23:14:37 +02:00
Victor Stinner
e0b99ba140
Close #17932 : Fix an integer overflow issue on Windows 64-bit in iterators:
...
change the C type of seqiterobject.it_index from long to Py_ssize_t.
2013-06-04 23:02:46 +02:00
Benjamin Peterson
d2b58a9880
only recursively expand in the format spec ( closes #17644 )
2013-05-17 17:34:30 -05:00
Raymond Hettinger
36f74aa7f7
Issue #17563 : Fix dict resize performance regression.
2013-05-17 03:01:13 -07:00
Serhiy Storchaka
1cfebc73e0
Issue #9369 : The types of `char*` arguments of PyObject_CallFunction() and
...
PyObject_CallMethod() now changed to `const char*`.
Based on patches by Jörg Müller and Lars Buitinck.
2013-05-29 18:50:54 +03:00
Benjamin Peterson
4d94474ba3
rewrite the parsing of field names to be more consistent wrt recursive expansion
2013-05-17 18:22:31 -05:00
Benjamin Peterson
48953632df
merge 3.3
2013-05-17 17:35:28 -05:00
Raymond Hettinger
2f6fe51860
merge
2013-05-17 03:24:54 -07:00
Benjamin Peterson
e1b4cbc422
when arguments are cells clear the locals slot (backport of #17927 )
2013-05-14 22:31:26 -05: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
159ae41da6
when an argument is a cell, set the local copy to NULL (see #17927 )
2013-05-12 18:16:06 -05:00
Brett Cannon
f27541653b
Touch up grammar for dict.update() docstring.
2013-05-11 14:46:48 -04:00
Antoine Pitrou
7ce35a1816
Issue #17237 : Fix crash in the ASCII decoder on m68k.
2013-05-11 15:59:37 +02:00
Antoine Pitrou
8b0e98426d
Issue #17237 : Fix crash in the ASCII decoder on m68k.
2013-05-11 15:58:34 +02:00
Guido van Rossum
6832c81d5d
#17927 : Keep frame from referencing cell-ified arguments.
2013-05-10 08:47:42 -07: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
Victor Stinner
6f75a3e89e
Use Py_intptr_t to store the difference between two pointers, instead of int
...
Fix a compiler warning on Windows 64-bit
2013-05-08 00:44:15 +02:00
Victor Stinner
f4f24248dc
Fix uninitialized value in charmap_decode_mapping()
2013-05-07 01:01:31 +02:00
Victor Stinner
8cecc8c262
Issue #7330 : Implement width and precision (ex: "%5.3s") for the format string
...
of PyUnicode_FromFormat() function, original patch written by Ysj Ray.
2013-05-06 23:11:54 +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
Brett Cannon
4c14b5de1c
#17115,17116: Have modules initialize the __package__ and __loader__
...
attributes to None.
The long-term goal is for people to be able to rely on these
attributes existing and checking for None to see if they have been
set. Since import itself sets these attributes when a loader does not
the only instances when the attributes are None are from someone
overloading __import__() and not using a loader or someone creating a
module from scratch.
This patch also unifies module initialization. Before you could have
different attributes with default values depending on how the module
object was created. Now the only way to not get the same default set
of attributes is to circumvent initialization by calling
ModuleType.__new__() directly.
2013-05-04 13:56:58 -04:00
Alexandre Vassalotti
865eaa1b53
Closes #17892 : Fix the name of _PyObject_CallMethodObjIdArgs
2013-05-02 10:44:04 -07:00
Ezio Melotti
5263c13801
Merge removal of trailing whitespace from 3.3.
2013-04-21 04:08:18 +03:00
Ezio Melotti
6b02772c13
Remove trailing whitespace.
2013-04-21 04:07:51 +03:00
Victor Stinner
bb4503f61e
Partial revert of changeset 9744b2df134c
...
PyUnicode_Append() cannot call directly resize_compact(): I forgot that a
string can be ready *and* not compact (a legacy string can also be ready).
2013-04-18 09:41:34 +02:00
Victor Stinner
fb161b1b6d
Split PyUnicode_DecodeCharmap() into subfunction for readability
2013-04-18 01:44:27 +02:00
Victor Stinner
170ca6f84b
Fix bug in Unicode decoders related to _PyUnicodeWriter
...
Bug introduced by changesets 7ed9993d53b4 and edf029fc9591.
2013-04-18 00:25:28 +02:00
Victor Stinner
376cfa122d
Fix typo in unicode_decode_call_errorhandler_writer()
...
Bug introduced by changeset 7ed9993d53b4.
2013-04-17 23:58:16 +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
77282cb4f8
Cleanup PyUnicode_Contains()
...
* No need to double-check that strings are ready: test already done by
PyUnicode_FromObject()
* Remove useless kind variable (use kind1 instead)
2013-04-14 19:22:47 +02:00
Victor Stinner
d92e078c8d
Minor change: fix character in do_strip() for the ASCII case
2013-04-14 19:17:42 +02:00
Victor Stinner
f033510fee
Cleanup PyUnicode_Append()
...
* Check also that right is a Unicode object
* call directly resize_compact() instead of unicode_resize() for a more
explicit error handling, and to avoid testing some properties twice
(ex: unicode_modifiable())
2013-04-14 19:13:03 +02:00
Victor Stinner
4560f9c63f
PyUnicode_Join(): move use_memcpy test out of the loop to cleanup and optimize the code
2013-04-14 18:56:46 +02:00
Victor Stinner
55c08781e8
Optimize repr(str): use _PyUnicode_FastCopyCharacters() when no character is escaped
2013-04-14 18:45:39 +02:00
Victor Stinner
af03757d20
Optimize ascii(str): don't encode/decode repr if repr is already ASCII
2013-04-14 18:44:10 +02:00
Victor Stinner
76b3b2726c
stringlib: remove unused STRINGLIB_RESIZE macro
2013-04-14 16:29:09 +02:00
Victor Stinner
8a1a6cffd6
Add _PyUnicodeWriter_WriteCharInline()
2013-04-14 02:35:33 +02:00
Serhiy Storchaka
e2cef885a2
Issue #16061 : Speed up str.replace() for replacing 1-character strings.
2013-04-13 22:45:04 +03:00
Mark Dickinson
93196eb44f
Issue #17715 : Merge fix from 3.3.
2013-04-13 17:46:04 +01:00
Mark Dickinson
c9734484ca
Issue #17715 : Add missing NULL Check to PyNumber_Long.
2013-04-13 17:44:44 +01:00
Mark Dickinson
556e94b8fe
Issue #17643 : Add __callback__ attribute to weakref.ref.
2013-04-13 15:45:44 +01:00
Mark Dickinson
548677bb8c
Issue #16447 : Merge fix from 3.3.
2013-04-13 15:30:16 +01:00
Mark Dickinson
64aafeb4de
Issue #16447 : Fix potential segfault when setting __name__ on a class.
2013-04-13 15:26:58 +01: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
Antoine Pitrou
dc040f099d
Fix supernumerary 's' in sys._debugmallocstats() output.
2013-04-11 21:02:20 +02:00
Antoine Pitrou
36b045f4db
Fix supernumerary 's' in sys._debugmallocstats() output.
2013-04-11 21:01:40 +02:00
Benjamin Peterson
34ad84d80a
merge 3.3 ( #17669 )
2013-04-10 17:01:38 -04:00
Benjamin Peterson
c9314d9e08
don't run frame if it has no stack ( closes #17669 )
2013-04-10 17:00:56 -04:00
Victor Stinner
247109e74d
Issue #17615 : On Windows (VS2010), Performances of wmemcmp() to compare Unicode
...
strings are not convincing. For UCS2 (16-bit wchar_t type), use a dummy loop
instead of wmemcmp(). The dummy loop is as fast, or a little bit faster.
wchar_t is only 16-bit long on Windows. wmemcmp() is still used for 32-bit
wchar_t.
2013-04-09 23:53:26 +02:00
Victor Stinner
0cff4b16d9
replace(): only call PyUnicode_DATA(u) once
2013-04-09 22:52:48 +02:00
Victor Stinner
cc7af72192
Write super-fast version of str.strip(), str.lstrip() and str.rstrip() for pure ASCII
2013-04-09 22:39:24 +02:00
Victor Stinner
f50a4e9bc9
Don't calls macros in PyUnicode_WRITE() parameters
...
PyUnicode_WRITE() expands some parameters twice or more.
2013-04-09 22:38:52 +02:00
Victor Stinner
9c79e41fc5
Fix do_strip(): don't call PyUnicode_READ() in Py_UNICODE_ISSPACE() to not call
...
it twice
2013-04-09 22:21:08 +02:00
Victor Stinner
b3a6014504
Fix _PyUnicode_XStrip()
...
Inline the BLOOM_MEMBER() to only call PyUnicode_READ() only once (per loop
iteration). Store also the length of the seperator in a variable to avoid calls
to PyUnicode_GET_LENGTH().
2013-04-09 22:19:21 +02:00
Victor Stinner
63d5c1a14a
Optimize PyUnicode_DecodeCharmap()
...
Avoid expensive PyUnicode_READ() and PyUnicode_WRITE(), manipulate pointers
instead.
2013-04-09 22:13:33 +02:00
Victor Stinner
a85af502a4
Optimize make_bloom_mask(), used by str.strip(), str.lstrip() and str.rstrip()
...
Write specialized functions per Unicode kind to avoid the expensive
PyUnicode_READ() macro.
2013-04-09 21:53:54 +02:00
Victor Stinner
69ed0f4c86
Use PyUnicode_READ() instead of PyUnicode_READ_CHAR()
...
"PyUnicode_READ_CHAR() is less efficient than PyUnicode_READ() because it calls
PyUnicode_KIND() and might call it twice." according to its documentation.
2013-04-09 21:48:24 +02:00
Victor Stinner
03c3e35d42
Add fast-path in PyUnicode_DecodeCharmap() for pure 8 bit encodings:
...
cp037, cp500 and iso8859_1 codecs
2013-04-09 21:53:09 +02:00
Victor Stinner
cd777eaf53
Issue #17615 : Comparing two Unicode strings now uses wmemcmp() when possible
...
wmemcmp() is twice faster than a dummy loop (342 usec vs 744 usec) on Fedora
18/x86_64, GCC 4.7.2.
2013-04-08 22:43:44 +02:00
Victor Stinner
c1302bba4c
Issue #17615 : Expand expensive PyUnicode_READ() macro in unicode_compare():
...
write specialized functions for each combination of Unicode kinds.
2013-04-08 21:50:54 +02:00
Victor Stinner
7efa3b8242
Close #13126 : "Simplify" FASTSEARCH() code to help the compiler to emit more
...
efficient machine code. Patch written by Antoine Pitrou.
Without this change, str.find() was 10% slower than str.rfind() in the worst
case.
2013-04-08 00:26:43 +02:00
Serhiy Storchaka
ee57f159af
Revert a premature patch for issue #14010 (changeset 846bd418aee5).
2013-04-06 22:55:12 +03:00
Serhiy Storchaka
278d03bd66
Revert a premature patch for issue #14010 (changeset aaaf36026511).
2013-04-06 22:52:34 +03:00
Serhiy Storchaka
aac81e2780
Issue #14010 : Fix a crash when iterating or deleting deeply nested filters
...
(builting and in itertools module, i.e. map(), itertools.chain(), etc).
2013-04-06 21:20:30 +03:00
Serhiy Storchaka
e8f706eda7
Issue #14010 : Fix a crash when iterating or deleting deeply nested filters
...
(builting and in itertools module, i.e. map(), itertools.chain(), etc).
2013-04-06 21:14:43 +03:00
Antoine Pitrou
0aaaa62200
Issue #17469 : Fix _Py_GetAllocatedBlocks() and sys.getallocatedblocks() when running on valgrind.
2013-04-06 01:15:30 +02:00
Victor Stinner
207dd38726
fix unused variable
2013-04-03 03:14:58 +02:00
Victor Stinner
eb4b5ac8af
Close #16757 : Avoid calling the expensive _PyUnicode_FindMaxChar() function
...
when possible
2013-04-03 02:02:33 +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
Benjamin Peterson
d3f41fe121
merge 3.3 ( #17610 )
2013-04-01 17:43:30 -04:00
Benjamin Peterson
6395241471
list slotdefs in offset order rather than sorting them ( closes #17610 )
...
This means we can remove our usage of qsort() than relied on undefined behavior.
2013-04-01 17:41:41 -04:00
Antoine Pitrou
7faf70512a
Issue #17591 : Use lowercase filenames when including Windows header files.
...
Patch by Roumen Petrov.
2013-03-31 22:48:04 +02:00
Raymond Hettinger
51612fd803
merge
2013-03-23 08:21:52 -07:00
Raymond Hettinger
378170d5d9
Issue 17447: Clarify that str.isidentifier doesn't check for reserved keywords.
2013-03-23 08:21:12 -07:00
Benjamin Peterson
5589850c14
fix warning ( closes #17327 )
2013-03-08 08:36:49 -05:00
Benjamin Peterson
00e9886bd9
Add PyDict_SetDefault. ( closes #17327 )
...
Patch by Stefan Behnel and I.
2013-03-07 22:16:29 -05:00
Victor Stinner
fb84b5d48d
(Merge 3.3) _PyUnicode_Writer() now also reuses Unicode singletons:
...
empty string and latin1 single character
2013-03-06 19:29:09 +01:00
Victor Stinner
2cb16aa3cb
_PyUnicode_Writer() now also reuses Unicode singletons:
...
empty string and latin1 single character
2013-03-06 19:28:37 +01:00
Victor Stinner
cf77da9fb5
Backed out changeset b9f7b1bf36aa
2013-03-06 01:09:24 +01:00
Victor Stinner
313cac88c5
Issue #17223 : Fix PyUnicode_FromUnicode() on Windows (16-bit wchar_t type)
...
to reject invalid UTF-16 surrogate.
2013-03-06 00:41:50 +01:00
Benjamin Peterson
42f382facd
merge 3.3 ( #17328 )
2013-03-04 09:48:30 -05:00
Benjamin Peterson
b1efa53662
fix possible setdefault refleak ( closes #17328 )
2013-03-04 09:47:50 -05:00
R David Murray
1cb0cb2fcd
#17296 : backport fix for issue 1692335, naive exception pickling.
2013-02-27 08:57:09 -05:00
Victor Stinner
36025478bf
(Merge 3.3) Issue #17223 : Fix PyUnicode_FromUnicode() for string of 1 character
...
outside the range U+0000-U+10ffff.
2013-02-26 00:16:57 +01:00
Victor Stinner
d21b58c05d
Issue #17223 : Fix PyUnicode_FromUnicode() for string of 1 character outside
...
the range U+0000-U+10ffff.
2013-02-26 00:15:54 +01:00
Serhiy Storchaka
06b16f879f
Remove unused defines.
2013-02-23 14:49:09 +02:00
Serhiy Storchaka
18809fa94e
Remove unused defines.
2013-02-23 14:48:16 +02:00
Benjamin Peterson
abe40c2528
merge 3.3 ( #17228 )
2013-02-20 16:56:06 -05:00
Benjamin Peterson
2dba1ee3e6
fix building without pymalloc ( closes #17228 )
2013-02-20 16:54:30 -05:00
Stefan Krah
5e06d1d0b9
Merge 3.3.
2013-02-19 14:02:59 +01:00
Stefan Krah
674a42b114
Fix error messages.
2013-02-19 13:44:49 +01:00
R David Murray
aaf16b9cfb
Merge: #7963 : fix error message when 'object' called with arguments.
2013-02-18 21:44:03 -05:00
R David Murray
702a5dc1ed
#7963 : fix error message when 'object' called with arguments.
2013-02-18 21:39:18 -05:00
R David Murray
6b30759022
#7963 : fix error message when 'object' called with arguments.
...
Patch by Alexander Belopolsky.
2013-02-18 21:20:08 -05:00
Eric Snow
9d05c8c0e0
Issue #15022 : Ensure all pickle protocols are supported.
2013-02-16 18:20:32 -07:00
Eric Snow
b5c8f92782
Issue #15022 : Add pickle and comparison support to types.SimpleNamespace.
2013-02-16 16:32:39 -07:00
Serhiy Storchaka
b8cbba5877
Issue #12983 : Bytes literals with invalid \x escape now raise a SyntaxError
...
and a full traceback including line number.
2013-02-10 17:43:25 +02:00
Serhiy Storchaka
801d955f04
Issue #12983 : Bytes literals with invalid \x escape now raise a SyntaxError
...
and a full traceback including line number.
2013-02-10 17:42:01 +02:00
Serhiy Storchaka
5e61f14c6d
Issue #12983 : Bytes literals with invalid \x escape now raise a SyntaxError
...
and a full traceback including line number.
2013-02-10 17:36:00 +02:00
Antoine Pitrou
8ad5b07ccb
Issue #17173 : Remove uses of locale-dependent C functions (isalpha() etc.) in the interpreter.
...
I've left a couple of them in: zlib (third-party lib), getaddrinfo.c
(doesn't include Python.h, and probably obsolete), _sre.c (legitimate
use for the re.LOCALE flag), mpdecimal (needs to build without Python.h).
2013-02-09 23:16:51 +01:00
Antoine Pitrou
c73c561181
Issue #17173 : Remove uses of locale-dependent C functions (isalpha() etc.) in the interpreter.
...
I've left a couple of them in: zlib (third-party lib), getaddrinfo.c
(doesn't include Python.h, and probably obsolete), _sre.c (legitimate
use for the re.LOCALE flag), mpdecimal (needs to build without Python.h).
2013-02-09 23:14:42 +01:00
Antoine Pitrou
4de7457009
Issue #17173 : Remove uses of locale-dependent C functions (isalpha() etc.) in the interpreter.
...
I've left a couple of them in: zlib (third-party lib), getaddrinfo.c
(doesn't include Python.h, and probably obsolete), _sre.c (legitimate
use for the re.LOCALE flag).
2013-02-09 23:11:27 +01:00
Victor Stinner
cfd2c1b4cc
(Merge 3.3) Issue #17137 : When an Unicode string is resized, the internal wide
...
character string (wstr) format is now cleared.
2013-02-07 23:17:34 +01:00
Victor Stinner
bbbac2ec34
Issue #17137 : When an Unicode string is resized, the internal wide character
...
string (wstr) format is now cleared.
2013-02-07 23:12:46 +01:00
Serhiy Storchaka
d0c79dcda5
Issue #17043 : The unicode-internal decoder no longer read past the end of
...
input buffer.
2013-02-07 16:26:55 +02:00
Serhiy Storchaka
03ee12ed72
Issue #17043 : The unicode-internal decoder no longer read past the end of
...
input buffer.
2013-02-07 16:25:25 +02:00
Serhiy Storchaka
3fd4ab356d
Issue #17043 : The unicode-internal decoder no longer read past the end of
...
input buffer.
2013-02-07 16:23:21 +02:00
Serhiy Storchaka
8911ef5b6d
Issue #17034 : Use Py_CLEAR() in bytesobject.c.
2013-02-02 18:46:19 +02:00
Serhiy Storchaka
d357a3f841
Issue #17034 : Use Py_CLEAR() in bytesobject.c.
2013-02-02 18:45:54 +02:00
Serhiy Storchaka
f458a03617
Issue #17034 : Use Py_CLEAR() in bytesobject.c.
2013-02-02 18:45:22 +02:00
Gregory P. Smith
ce9e3c3af9
Silence a -Wformat-extra-argument warning when compiling.
2013-02-01 16:14:00 -08:00
Serhiy Storchaka
2aee6a6460
Issue #16971 : Fix a refleak in the charmap decoder.
2013-01-29 12:16:57 +02:00
Serhiy Storchaka
afb1cb5579
Issue #16971 : Fix a refleak in the charmap decoder.
2013-01-29 12:13:22 +02:00
Serhiy Storchaka
8fe5a9f9c3
Issue #16979 : Fix error handling bugs in the unicode-escape-decode decoder.
2013-01-29 10:37:39 +02:00
Serhiy Storchaka
24193debd4
Issue #16979 : Fix error handling bugs in the unicode-escape-decode decoder.
2013-01-29 10:28:07 +02:00
Serhiy Storchaka
d679377be7
Issue #16979 : Fix error handling bugs in the unicode-escape-decode decoder.
2013-01-29 10:20:44 +02:00
Mark Dickinson
07c7136524
Issue #16772 : in int(x, base), non-integer bases must have an __index__ method.
2013-01-27 10:17:52 +00:00
Ezio Melotti
3a62e45b97
Merge typo fixes from 3.3.
2013-01-27 06:20:51 +02:00
Ezio Melotti
3f5db3940f
Fix a few typos and a double semicolon. Patch by Eitan Adler.
2013-01-27 06:20:14 +02:00
Serhiy Storchaka
ed3c4128c0
Issue #10156 : In the interpreter's initialization phase, unicode globals
...
are now initialized dynamically as needed.
2013-01-26 12:18:17 +02:00
Serhiy Storchaka
678db84b37
Issue #10156 : In the interpreter's initialization phase, unicode globals
...
are now initialized dynamically as needed.
2013-01-26 12:16:36 +02:00
Serhiy Storchaka
059972535f
Issue #10156 : In the interpreter's initialization phase, unicode globals
...
are now initialized dynamically as needed.
2013-01-26 12:14:02 +02:00
Serhiy Storchaka
570c5b2354
Issue #16980 : Fix processing of escaped non-ascii bytes in the
...
unicode-escape-decode decoder.
2013-01-25 23:53:29 +02:00
Serhiy Storchaka
73e38809e0
Issue #16980 : Fix processing of escaped non-ascii bytes in the
...
unicode-escape-decode decoder.
2013-01-25 23:52:21 +02:00
Serhiy Storchaka
f584aba3a5
Issue #16975 : Fix error handling bug in the escape-decode bytes decoder.
2013-01-25 23:33:22 +02:00
Serhiy Storchaka
e58785b200
Issue #16975 : Fix error handling bug in the escape-decode bytes decoder.
2013-01-25 23:32:41 +02:00
Serhiy Storchaka
ace3ad3bf7
Issue #16975 : Fix error handling bug in the escape-decode bytes decoder.
2013-01-25 23:31:43 +02:00
Serhiy Storchaka
6481bfb2b5
Issue #16335 : Fix integer overflow in unicode-escape decoder.
2013-01-21 11:44:40 +02:00
Serhiy Storchaka
c35f3a9f61
Issue #16335 : Fix integer overflow in unicode-escape decoder.
2013-01-21 11:42:57 +02:00
Serhiy Storchaka
4f5f0e54e0
Issue #16335 : Fix integer overflow in unicode-escape decoder.
2013-01-21 11:38:00 +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
55e2cb497b
Issue #14850 : Now a chamap decoder treates U+FFFE as "undefined mapping"
...
in any mapping, not only in an unicode string.
2013-01-15 15:30:04 +02:00
Serhiy Storchaka
45d16d9924
Issue #14850 : Now a chamap decoder treates U+FFFE as "undefined mapping"
...
in any mapping, not only in an unicode string.
2013-01-15 15:01:20 +02:00
Serhiy Storchaka
4fb8caee87
Issue #14850 : Now a chamap decoder treates U+FFFE as "undefined mapping"
...
in any mapping, not only in an unicode string.
2013-01-15 14:43:21 +02:00
Serhiy Storchaka
b946af5897
Check for NULL before the pointer aligning in fastsearch_memchr_1char.
...
There is no guarantee that NULL is aligned.
2013-01-15 13:32:41 +02:00
Serhiy Storchaka
18ba40b945
Check for NULL before the pointer aligning in fastsearch_memchr_1char.
...
There is no guarantee that NULL is aligned.
2013-01-15 13:27:28 +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
Benjamin Peterson
0b32a480bd
merge 3.3 ( #16906 )
2013-01-09 09:52:22 -06:00
Benjamin Peterson
0c270a8bb7
correct static string clearing loop ( closes #16906 )
2013-01-09 09:52:01 -06:00
Serhiy Storchaka
24a3ef6999
Issue #11461 : Fix the incremental UTF-16 decoder. Original patch by
...
Amaury Forgeot d'Arc. Added tests for partial decoding of non-BMP
characters.
2013-01-08 23:41:55 +02:00
Serhiy Storchaka
ae3b32ad6b
Issue #11461 : Fix the incremental UTF-16 decoder. Original patch by
...
Amaury Forgeot d'Arc. Added tests for partial decoding of non-BMP
characters.
2013-01-08 23:40:52 +02:00
Serhiy Storchaka
48e188e573
Issue #11461 : Fix the incremental UTF-16 decoder. Original patch by
...
Amaury Forgeot d'Arc. Added tests for partial decoding of non-BMP
characters.
2013-01-08 23:14:24 +02:00
Serhiy Storchaka
dec798eb46
Fix out of bound read in UTF-32 decoder on "narrow Unicode" builds.
2013-01-08 22:45:42 +02:00
Christian Heimes
34bdeb5d81
Add a comment about *not* caching the hash value. Issue #9685 suggested to memorize the hash value, but the feature request was rejected because no speed ups were found.
2013-01-07 21:24:18 +01:00
Serhiy Storchaka
4e02538bf3
Issue #16856 : Fix a segmentation fault from calling repr() on a dict with
...
a key whose repr raise an exception.
2013-01-04 12:40:35 +02:00
Serhiy Storchaka
6c83e739d7
Issue #16856 : Fix a segmentation fault from calling repr() on a dict with
...
a key whose repr raise an exception.
2013-01-04 12:39:34 +02:00
Victor Stinner
18aa4477d3
Close #16281 : handle tailmatch() failure and remove useless comment
...
"honor direction and do a forward or backwards search": the runtime speed may
be different, but I consider that it doesn't really matter in practice. The
direction was never honored before: Python 2.7 uses memcmp() for the str type
for example.
2013-01-03 03:18:09 +01:00
Victor Stinner
7ae320d667
(Merge 3.2) 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.
2013-01-03 01:21:07 +01:00
Victor Stinner
20b654acb5
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.
2013-01-03 01:08:58 +01:00
Antoine Pitrou
a2678f3eb6
Fix the advertised size of PyCFunctionObjects in sys._debugmallocstats().
2012-12-30 22:46:56 +01:00
Antoine Pitrou
0811f98e10
Fix the advertised size of PyCFunctionObjects in sys._debugmallocstats().
2012-12-30 22:46:04 +01:00
Serhiy Storchaka
c819b077bb
Issue #16761 : Raise TypeError when int() called with base argument only.
2012-12-28 10:09:54 +02:00
Serhiy Storchaka
00e2843115
Issue #16761 : Raise TypeError when int() called with base argument only.
2012-12-28 10:02:42 +02:00
Serhiy Storchaka
0b386d5247
Issue #16761 : Raise TypeError when int() called with base argument only.
2012-12-28 09:42:11 +02:00
Benjamin Peterson
513762fe9c
use more specific type
2012-12-26 16:43:33 -06:00
Andrew Svetlov
4de2924dab
Fix compilation error for #15422
2012-12-26 23:08:54 +02:00
Gregory P. Smith
a689e524e7
Test for issue16772 and redoes the previous fix to accept __index__-aware
...
objects as the base by using PyNumber_AsSsize_t similar to round().
2012-12-25 22:38:32 -08:00
Gregory P. Smith
4fbbf8c0a3
Fixes issue #16772 : int() constructor second argument (base) must be an int.
...
Consistent with the behavior in Python 2.
2012-12-25 13:05:31 -08:00
Andrew Svetlov
3ba3a3ee56
Issue #15422 : get rid of PyCFunction_New macro
2012-12-25 13:32:35 +02:00
Andrew Svetlov
2cd8ce4690
Issue #9856 : Replace deprecation warinigs to raising TypeError in object.__format__
...
Patch by Florent Xicluna.
2012-12-23 14:27:17 +02:00
Benjamin Peterson
7643c92cdd
merge 3.3 ( #16722 )
2012-12-19 15:28:46 -06:00
Benjamin Peterson
5ff3f73d94
try to call __bytes__ before __index__ ( closes #16722 )
2012-12-19 15:27:41 -06:00
Andrew Svetlov
2606a6f197
Issue #16719 : Get rid of WindowsError. Use OSError instead
...
Patch by Serhiy Storchaka.
2012-12-19 14:33:35 +02:00
Antoine Pitrou
928405303d
Following issue #13390 , fix compilation --without-pymalloc, and make sys.getallocatedblocks() return 0 in that situation.
2012-12-17 23:05:59 +01: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
a6be61ec71
Keep y a Py_hash_t instead of Py_uhash_t as it is compared with == -1 and the
...
compiler logic will do the right thing with just x as a Py_uhash_t. This
matches what was already done in the 3.3 version.
cleanup only - no functionality or hash values change.
2012-12-10 18:34:09 -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
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
Chris Jerdonek
e7f2186f99
Issue #16495 : remove extraneous NULL encoding check from bytes_decode().
...
The NULL encoding check in bytes_decode() was unnecessary because this case
is already taken care of by the call to _Py_normalize_encoding() inside
PyUnicode_Decode().
2012-12-07 15:51:53 -08:00
Victor Stinner
8dbd421b4d
Cleanup unicodeobject.c
...
* Remove micro-optization:
(errors == "surrogateescape" || strcmp(errors, "surrogateescape") == 0).
Only use strcmp()
* Initialize 'arg' members in unicode_format_arg() to help the compiler to
diagnose real bugs and also make the code simpler to read
2012-12-04 09:30:24 +01: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
Victor Stinner
2660e427d1
(Merge 3.2) Issue #16416 : On Mac OS X, operating system data are now always
...
encoded/decoded to/from UTF-8/surrogateescape, instead of the locale encoding
(which may be ASCII if no locale environment variable is set), to avoid
inconsistencies with os.fsencode() and os.fsdecode() functions which are
already using UTF-8/surrogateescape.
2012-12-03 12:48:53 +01:00
Victor Stinner
27b1ca29cc
Issue #16416 : On Mac OS X, operating system data are now always
...
encoded/decoded to/from UTF-8/surrogateescape, instead of the locale encoding
(which may be ASCII if no locale environment variable is set), to avoid
inconsistencies with os.fsencode() and os.fsdecode() functions which are
already using UTF-8/surrogateescape.
2012-12-03 12:47:59 +01:00
Antoine Pitrou
0e9958b543
Issue #16562 : Optimize dict equality testing.
...
Patch by Serhiy Storchaka (reviewed by Martin and Raymond).
2012-12-02 19:10:07 +01:00
Christian Heimes
5f7e8dab11
Issue #16592 : stringlib_bytes_join doesn't raise MemoryError on allocation failure
2012-12-02 07:56:42 +01:00
Antoine Pitrou
5439458a2a
Issue #16215 : Fix potential double memory free in str.replace().
...
Patch by Serhiy Storchaka.
2012-11-17 23:29:28 +01:00
Antoine Pitrou
6d5ad227a5
Issue #16215 : Fix potential double memory free in str.replace().
...
Patch by Serhiy Storchaka.
2012-11-17 23:28:17 +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
Mark Dickinson
d20fb82195
Issue #16290 : __complex__ must now always return an instance of complex.
2012-11-14 17:08:31 +00:00
Victor Stinner
0d92c4f667
Issue #16416 : Fix error handling in _Py_wchar2char() _Py_char2wchar() functions
2012-11-12 23:32:21 +01:00
Antoine Pitrou
898347056a
Issue #16453 : Fix equality testing of dead weakref objects.
...
Also add tests for ordering and hashing.
2012-11-11 19:39:35 +01:00
Antoine Pitrou
f6a50cfa07
Issue #16453 : Fix equality testing of dead weakref objects.
...
Also add tests for ordering and hashing.
2012-11-11 19:37:41 +01:00
Antoine Pitrou
e11fecb5a9
Issue #16453 : Fix equality testing of dead weakref objects.
...
Also add tests for ordering and hashing.
2012-11-11 19:36:51 +01:00
Mark Dickinson
c8a6967ea8
Issue #14794 : slice.indices no longer returns OverflowError for out-of-range start, stop, step or length.
2012-11-10 14:52:10 +00:00
Victor Stinner
fc009eff9e
Close #16311 : Use the _PyUnicodeWriter API in text decoders
...
* Remove unicode_widen(): replaced with _PyUnicodeWriter_Prepare()
* Remove unicode_putchar(): replaced with
PyUnicodeWriter_Prepare() + PyUnicode_WRITER()
* When handling an decoding error, only overallocate the buffer by +25%
instead of +100%
2012-11-07 00:36:38 +01:00
Victor Stinner
6caa6fb535
(Merge 3.3) Issue #8271 : Fix compilation on Windows
2012-11-05 00:00:50 +01:00
Victor Stinner
ab60de478d
Issue #8271 : Fix compilation on Windows
2012-11-04 23:59:15 +01:00
Ezio Melotti
cfa9636404
#8271 : merge with 3.3.
2012-11-04 23:23:09 +02:00
Ezio Melotti
f7ed5d111b
#8271 : the utf-8 decoder now outputs the correct number of U+FFFD characters when used with the "replace" error handler on invalid utf-8 sequences. Patch by Serhiy Storchaka, tests by Ezio Melotti.
2012-11-04 23:21:38 +02:00
Mark Dickinson
c992fafddc
Issue #16402 : Merge fix from 3.3
2012-11-04 11:47:47 +00:00
Mark Dickinson
1321edaa55
Issue #16402 : Merge fix from 3.2
2012-11-04 11:47:05 +00:00
Mark Dickinson
8cd1c7681d
Issue #16402 : In range slicing, fix shadowing of exceptions from __index__ method.
2012-11-04 11:46:17 +00:00
Christian Heimes
e9d08cf450
Fix compilation on Windows
2012-11-03 23:08:27 +01:00
Christian Heimes
d081fbba58
Fix compilation on Windows
2012-11-03 23:08:18 +01:00
Christian Heimes
6d26ade920
Fix compilation on Windows
2012-11-03 23:07:59 +01:00
Ezio Melotti
212843b29f
#8401 : merge with 3.3.
2012-11-03 21:24:47 +02:00
Ezio Melotti
7376801f61
#8401 : merge with 3.2.
2012-11-03 21:22:41 +02:00
Ezio Melotti
c64bcbec4b
#8401 : assigning an int to a bytearray slice (e.g. b[3:4] = 5) now raises an error.
2012-11-03 21:19:06 +02:00
Stefan Krah
c38c816ea1
Merge 3.3.
2012-11-02 17:55:11 +01:00
Stefan Krah
4af77a0276
Issue #15814 : Use hash function that is compatible with the equality
...
definition from #15573 .
2012-11-02 17:49:22 +01:00
Benjamin Peterson
8781d4a84c
merge 3.3
2012-10-31 14:22:31 -04:00
Benjamin Peterson
591c921411
merge 3.2
2012-10-31 14:22:25 -04:00
Benjamin Peterson
9892f52145
avoid a function call with redundant checks for dict size
2012-10-31 14:22:12 -04:00
Benjamin Peterson
7503e08588
merge 3.3 ( #16345 )
2012-10-31 14:10:04 -04:00
Benjamin Peterson
d97eb0d338
merge 3.2 ( #16345 )
2012-10-31 14:09:11 -04:00
Benjamin Peterson
d1f2cb37a2
only fast-path fromkeys() when the constructor returns a empty dict ( closes #16345 )
2012-10-31 14:05:55 -04:00
Benjamin Peterson
3cb90241fc
merge 3.3
2012-10-31 00:04:42 -04:00
Benjamin Peterson
2c05a2e01b
do safety checks on __qualname__ assignment
2012-10-31 00:01:15 -04:00
Benjamin Peterson
8afa7fa510
don't shadow the __qualname__ descriptor with __qualname__ in the class's __dict__ ( closes #16271 )
2012-10-30 23:51:03 -04:00
Benjamin Peterson
42124a727d
initialize map/filter/zip in _PyBuiltin_Init rather than the catch-all function
2012-10-30 23:41:54 -04:00
Benjamin Peterson
7ff2094bc7
merge 3.3 ( #16369 )
2012-10-30 23:31:12 -04:00
Benjamin Peterson
e8ea97fffb
merge 3.2 ( #16369 )
2012-10-30 23:27:52 -04:00
Benjamin Peterson
c43112823b
initialize more global type objects ( closes #16369 )
2012-10-30 23:21:10 -04:00
Victor Stinner
7a6d7cf3db
Issue #9566 : Use the right type to fix a compiler warnings on Win64
2012-10-31 00:37:41 +01: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
e64322e034
Close #14625 : Rewrite the UTF-32 decoder. It is now 3x to 4x faster
...
Patch written by Serhiy Storchaka.
2012-10-30 23:12:47 +01:00
Victor Stinner
76df43de30
Issue #16330 : Use surrogate-related macros
...
Patch written by Serhiy Storchaka.
2012-10-30 01:42:39 +01:00
Mark Dickinson
fb90c0934c
Issue #14700 : Fix buggy overflow checks for large precision and width in new-style and old-style formatting.
2012-10-28 10:18:03 +00:00
Victor Stinner
c6cf1ba29e
Replace usage of the deprecated Py_UNICODE_COPY() with Py_MEMCPY() in resize_copy()
2012-10-23 02:54:47 +02:00
Victor Stinner
fe75fb4b3e
Optimize _PyUnicode_HasNULChars(): use findchar() instead of PyUnicode_Contains()
2012-10-23 02:52:18 +02:00
Victor Stinner
6fa627578a
Inline raise_translate_exception(): it is only used once
2012-10-23 02:51:50 +02:00
Victor Stinner
e5567ad236
Optimize PyUnicode_RichCompare() for Py_EQ and Py_NE: always use memcmp()
2012-10-23 02:48:49 +02:00
Antoine Pitrou
6f7b0da6bc
Issue #12805 : Make bytes.join and bytearray.join faster when the separator is empty.
...
Patch by Serhiy Storchaka.
2012-10-20 23:08:34 +02:00
Mark Dickinson
e453e4c007
Issue 16280: Drop questionable special-casing of null pointer in PyLong_FromVoidPtr.
2012-10-18 22:18:42 +01:00
Mark Dickinson
5cb65917e1
Issue #16277 : merge fix from 3.3
2012-10-18 19:53:45 +01:00
Mark Dickinson
44362a88ad
Issue #16277 : merge fix from 3.2
2012-10-18 19:53:28 +01:00
Mark Dickinson
91044799f7
Issue #16277 : in PyLong_FromVoidPtr, add missing branch for sizeof(void*) <= sizeof(long).
2012-10-18 19:21:43 +01: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
Eric Snow
42da889fec
merge for issue #16160 : Subclass support now works for types.SimpleNamespace.
2012-10-16 22:45:49 -07:00
Eric Snow
547298c94c
Close #16160 : Subclass support now works for types.SimpleNamespace. Thanks to RDM for noticing.
2012-10-16 22:35:38 -07:00
Antoine Pitrou
cfc22b4a9b
Issue #15958 : bytes.join and bytearray.join now accept arbitrary buffer objects.
2012-10-16 21:07:23 +02:00
Chris Jerdonek
4a7df9aba9
Issue #14783 : Merge changes from 3.3.
2012-10-07 15:02:16 -07:00
Chris Jerdonek
042fa653ab
Issue #14783 : Merge changes from 3.2.
2012-10-07 14:56:27 -07:00
Chris Jerdonek
83fe2e1c22
Issue #14783 : Improve int() docstring and also str(), range(), and slice().
...
This commit rewrites the docstring for int() to incorporate the documentation
changes made in issue #16036 . It also switches the docstrings for int(),
str(), range(), and slice() to use multi-line signatures.
2012-10-07 14:48:36 -07: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
4c63a972d1
Cleanup PyUnicode_FromFormatV() for zero padding
...
Skip the "0" instead of parsing it twice: detect zero padding and then parsed
as a digit of the width.
2012-10-06 23:55:33 +02:00