Victor Stinner
4202456cd4
Issue #18408 : _pickle.c: Add missing PyErr_NoMemory() on memory allocation failures
2013-07-12 00:53:57 +02:00
Victor Stinner
8ca72e2e3d
Issue #18408 : _PyMemoTable_ResizeTable() now restores the old table if
...
allocating a bigger table failed
PyMemoTable destructor does crash if mt_table is NULL.
2013-07-12 00:53:26 +02:00
Victor Stinner
c31df04234
Issue #18408 : Oh, I was wrong: Pickler_New() must call Py_DECREF() to destroy
...
the newly created pickler, and not PyObject_GC_Del().
2013-07-12 00:08:59 +02:00
Victor Stinner
71c8b7ec04
Issue #18408 : Different fixes in _elementtree.c to handle correctly MemoryError
...
* create_new_element() initializes all attributes before handling errors,
to fix a crash in the destructor
* create_new_element() calls PyObject_GC_Del() on error, instead of
PyObject_Del(), because the object was created by PyObject_GC_New()
* subelement() now handles create_new_element() failure
* element_getattro() now handles element_get_text() failure
* makeuniversal() now handles PyBytes_FromStringAndSize() failure
2013-07-11 23:08:39 +02:00
Victor Stinner
4d46343340
Cleanup _elementtree.c
2013-07-11 23:05:03 +02:00
Victor Stinner
5f0af23f5e
Issue #18408 : _elementtree.c now handles create_extra() failure
2013-07-11 23:01:36 +02:00
Victor Stinner
68c8ea25f1
Issue #18408 : Fix _Pickler_New() and _Unpickler_New(): initialize all
...
attributes before handling errors
_Pickler_New() now calls PyObject_GC_Del() instead of Py_DECREF() on error,
because the pickle object is created using PyObject_GC_New().
Fix a crash in the destructor when an attribute is not initiallized.
2013-07-11 22:56:25 +02:00
Serhiy Storchaka
50ae3f680b
Issue #18101 : Tcl.split() now process strings nested in a tuple as it
...
do with byte strings.
Added tests for Tcl.split() and Tcl.splitline().
2013-07-11 20:36:00 +03:00
Serhiy Storchaka
275d5fdbe4
Issue #18101 : Tcl.split() now process strings nested in a tuple as it
...
do with byte strings.
Added tests for Tcl.split() and Tcl.splitline().
2013-07-11 20:34:47 +03:00
Serhiy Storchaka
e3ed4edb94
Issue #18338 : `python --version` now prints version string to stdout, and
...
not to stderr. Patch by Berker Peksag and Michael Dickens.
2013-07-11 20:01:17 +03:00
R David Murray
609142ef05
Merge: #18399 : fix comment typo.
2013-07-10 11:57:39 -04:00
R David Murray
296b73c83d
#18399 : fix comment typo.
...
Patch by Andrew Rowe.
2013-07-10 10:57:39 -04:00
Raymond Hettinger
d9c116ca40
Add a spacing saving heuristic to deque's extend methods
2013-07-09 00:13:21 -07:00
Victor Stinner
bbf8ce5b87
Issue #18408 : Fix select.select() to handle PyList_New() failure (MemoryError)
...
in set2list()
2013-07-09 00:49:03 +02:00
Victor Stinner
7979926616
Issue #18408 : Fix usage of _PyBytes_Resize()
...
_PyBytes_Resize(&v, new_size) sets v to NULL on error, so v cannot be used
anymore. Replace "Py_DECREF(v); v = NULL;" with "Py_CLEAR(v);".
2013-07-09 00:35:22 +02:00
Victor Stinner
bf2e2f9bdf
Issue #18408 : Fix zlib.compressobj() to handle PyThread_allocate_lock() failure
...
(MemoryError).
2013-07-09 00:29:03 +02:00
Victor Stinner
3f15cf0961
Issue #18408 : Fix ConvParam() of the ctypes module to handle paramfunc failure
...
(MemoryError).
2013-07-09 00:27:12 +02:00
Victor Stinner
064bbdc79b
fix indentation
2013-07-08 22:28:27 +02:00
Victor Stinner
5d1866c78a
Issue #18408 : PyObject_GC_NewVar() now raises SystemError exception if nitems
...
is negative
2013-07-08 22:17:52 +02:00
Victor Stinner
c1eb26cd2f
gcmodule.c: strip trailing spaces
2013-07-08 22:15:05 +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
Christian Heimes
fa535f5220
Issue #18227 : pyexpat now uses a static XML_Memory_Handling_Suite. cElementTree uses the same approach since at least Python 2.6
2013-07-07 17:35:11 +02:00
Victor Stinner
b7f1f65f1c
Issue #18227 : "Free" function of bz2, lzma and zlib modules has no return value (void)
2013-07-07 17:10:34 +02:00
Victor Stinner
11ebff2757
Issue #18203 : Replace malloc() with PyMem_Malloc() in _ssl for the password
2013-07-07 17:07:52 +02:00
Victor Stinner
5064a52bcb
Issue #18227 : Use PyMem_RawAlloc() in bz2, lzma and zlib modules
2013-07-07 16:50:27 +02:00
Victor Stinner
6ce0dbf460
Fix a compiler warning in posix_sendfile() on FreeBSD:
...
Modules/posixmodule.c: In function 'posix_sendfile':
Modules/posixmodule.c:7700: warning: ISO C90 forbids mixed declarations and code
2013-07-07 16:32:36 +02:00
Victor Stinner
b64049183c
Issue #18203 : Replace malloc() with PyMem_Malloc() in Python modules
...
Replace malloc() with PyMem_Malloc() when the GIL is held, or with
PyMem_RawMalloc() otherwise.
2013-07-07 16:21: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
Raymond Hettinger
b385529ddf
Fix #ifdef
2013-07-07 02:07:23 -10:00
Raymond Hettinger
82df925451
Use macros for marking and checking endpoints in the doubly-linked list of blocks.
...
* Add comment explaining the endpoint checks
* Only do the checks in a debug build
* Simplify newblock() to only require a length argument
and leave the link updates to the calling code.
* Also add comment for the freelisting logic.
2013-07-07 01:43:42 -10:00
Raymond Hettinger
ef9b47f0b8
merge
2013-07-06 17:50:01 -10:00
Raymond Hettinger
f3a67b7e57
Improve variable names in deque_count()
2013-07-06 17:49:06 -10: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
Raymond Hettinger
df715ba54d
Apply the PyObject_VAR_HEAD and Py_SIZE macros
...
to be consistent with practices in other modules.
2013-07-06 13:01:13 -10:00
Raymond Hettinger
5bfa8671bc
Refactor deque_traverse().
...
Hoist conditional expression out of the loop.
Use rightblock as the guard instead of checking for NULL.
2013-07-06 11:58:09 -10:00
Raymond Hettinger
98054b4c1b
Remove unnecessary branches from count() and reverse().
2013-07-06 09:07:06 -10:00
Raymond Hettinger
de68e0cf0e
Speed-up deque indexing by changing the deque block length to a power of two.
...
The division and modulo calculation in deque_item() can be compiled
to fast bitwise operations when the BLOCKLEN is a power of two.
Timing before:
~/cpython $ py -m timeit -r7 -s 'from collections import deque' -s 'd=deque(range(10))' 'd[5]'
10000000 loops, best of 7: 0.0627 usec per loop
Timing after:
~/cpython $ py -m timeit -r7 -s 'from collections import deque' -s 'd=deque(range(10))' 'd[5]'
10000000 loops, best of 7: 0.0581 usec per loop
2013-07-05 18:05:29 -10:00
Victor Stinner
0857ab4c77
(Merge 3.3) Issue #18343 : faulthandler.register() now keeps the previous signal
...
handler when the function is called twice, so faulthandler.unregister()
restores correctly the original signal handler.
2013-07-02 00:17:14 +02:00
Victor Stinner
8d3795474e
Issue #18343 : faulthandler.register() now keeps the previous signal handler
...
when the function is called twice, so faulthandler.unregister() restores
correctly the original signal handler.
2013-07-02 00:14:56 +02:00
Christian Heimes
54882bfc18
Singular form just like the other error message.
2013-07-01 15:23:48 +02:00
Christian Heimes
8087879349
Singular form just like the other error message.
2013-07-01 15:23:39 +02:00
Christian Heimes
bfafab1849
Issue #18339 : Negative ints keys in unpickler.memo dict no longer cause a
...
segfault inside the _pickle C extension.
2013-07-01 15:18:49 +02:00
Christian Heimes
a24b4d260b
Issue #18339 : Negative ints keys in unpickler.memo dict no longer cause a
...
segfault inside the _pickle C extension.
2013-07-01 15:17:45 +02:00
Christian Heimes
721724270d
Fix segfault in pyexpat.c caused by 84375
...
u can be NULL, use XDECREF
2013-06-29 21:49:27 +02:00
Christian Heimes
82e6b94b95
Fix resource leak in pickle module
...
CID 983309 (#1 of 1): Resource leak (RESOURCE_LEAK)
leaked_storage: Variable unicode_str going out of scope leaks the storage it points to.
2013-06-29 21:37:34 +02:00
Christian Heimes
b91ffaa1d8
Fix NULL ptr dereferencing in local_timezone(). nameo can be NULL
...
CID 1040362 (#1 of 1): Explicit null dereferenced (FORWARD_NULL)
var_deref_op: Dereferencing null pointer _py_decref_tmp.
2013-06-29 20:52:33 +02:00
Christian Heimes
b582155789
Fix memory leak in pyexpat PyUnknownEncodingHandler
...
CID 1040367 (#1 of 1): Resource leak (RESOURCE_LEAK)
leaked_storage: Variable u going out of scope leaks the storage it points to.
2013-06-29 20:43:13 +02:00
Victor Stinner
dd3a6a5533
Fix os.confstr(): the result type of the C function is size_t, not int
2013-06-25 23:13:47 +02:00
Victor Stinner
93037498d1
Fix time.mktime() and datetime.datetime.timestamp() on AIX
...
On AIX, the C function mktime() alwaysd sets tm_wday, even on error. So tm_wday
cannot be used as a sentinel to detect an error, we can only check if the
result is (time_t)-1.
2013-06-25 22:54:35 +02:00
Victor Stinner
d7a034bd75
(Merge 3.3) Fix time.strftime("%Y") on AIX: raise a ValueError for year > 9999
...
time.strtime("%Y") returned "2345" when formatting year 12345.
2013-06-25 02:34:13 +02:00