summaryrefslogtreecommitdiffstats
path: root/Objects
Commit message (Collapse)AuthorAgeFilesLines
* Replace outdated optimization with clearer code that compiles better.Raymond Hettinger2013-08-061-3/+3
| | | | | | | | | | | | | | | | | | | | | Letting the compiler decide how to optimize the multiply by five gives it the freedom to make better choices for the best technique for a given target machine. For example, GCC on x86_64 produces a little bit better code: Old-way (3 steps with a data dependency between each step): shrq $5, %r13 leaq 1(%rbx,%r13), %rax leaq (%rax,%rbx,4), %rbx New-way (3 steps with no dependency between the first two steps which can be run in parallel): leaq (%rbx,%rbx,4), %rax # i*5 shrq $5, %r13 # perturb >>= PERTURB_SHIFT leaq 1(%r13,%rax), %rbx # 1 + perturb + i*5
* Issue #17934: Add a clear() method to frame objects, to help clean up ↵Antoine Pitrou2013-08-052-5/+31
| | | | expensive details (local variables) and break reference cycles.
* mergeRaymond Hettinger2013-08-041-1/+1
|\
| * Silence compiler warning about an uninitialized variableRaymond Hettinger2013-08-041-1/+1
| |
* | Issue #16741: Fix an error reporting in int().Serhiy Storchaka2013-08-032-52/+64
|\ \ | |/
| * Issue #16741: Fix an error reporting in int().Serhiy Storchaka2013-08-032-51/+67
| |
* | Minor consistency fixes for some longobject.c exception messages:Mark Dickinson2013-08-031-4/+4
| | | | | | | | | | | | - replace 'long int' / 'long' by 'int' - fix capitalization of "Python" in PyLong_AsUnsignedLong - "is too large" -> "too large", for consistency with other messages.
* | Issue #18214: Improve finalization of Python modules to avoid setting their ↵Antoine Pitrou2013-07-311-8/+21
| | | | | | | | globals to None, in most cases.
* | Issue #18112: PEP 442 implementation (safe object finalization).Antoine Pitrou2013-07-303-123/+147
| |
* | Issue #18520: Fix _PyDict_GetItemId(), suppress _PyUnicode_FromId() errorVictor Stinner2013-07-221-1/+3
| | | | | | | | | | As PyDict_GetItem(), _PyDict_GetItemId() suppresses all errors that may occur, for historical reasons.
* | Issue #18520: Fix PyFunction_NewWithQualName() error handlingVictor Stinner2013-07-221-10/+9
| |
* | Reindent PyFunction_NewWithQualName()Victor Stinner2013-07-221-49/+49
| |
* | Issue #18520: Add a new PyStructSequence_InitType2() function, same thanVictor Stinner2013-07-223-15/+37
| | | | | | | | | | | | | | | | PyStructSequence_InitType() except that it has a return value (0 on success, -1 on error). * PyStructSequence_InitType2() now raises MemoryError on memory allocation failure * Fix also some calls to PyDict_SetItemString(): handle error
* | Propagate error when PyByteArray_Resize() fails in bytearray_translate()Christian Heimes2013-07-211-1/+4
|\ \ | |/ | | | | CID 715334
| * Propagate error when PyByteArray_Resize() fails in bytearray_translate()Christian Heimes2013-07-211-1/+4
| | | | | | | | CID 715334
* | Check return value of PyType_Ready(&EncodingMapType)Christian Heimes2013-07-201-1/+2
|\ \ | |/ | | | | CID 486654
| * Check return value of PyType_Ready(&EncodingMapType)Christian Heimes2013-07-201-1/+2
| | | | | | | | CID 486654
* | Issue #18327: Fix argument order in call to compatible_for_assignment(oldto, ↵Christian Heimes2013-07-201-1/+1
| | | | | | | | | | | | newto, attr). The fix only affects the error message of __class__ assignment. CID 983564
* | Issue #18408: Fix list_ass_slice(), handle list_resize() failureVictor Stinner2013-07-191-3/+8
| | | | | | | | | | I tested the patch manually by injecting a fault using gdb: list items are correctly restored on failure.
* | Issue #18408: PyObject_Str(), PyObject_Repr() and type_call() now fail with anVictor Stinner2013-07-172-0/+23
| | | | | | | | | | | | | | 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.
* | Issue #18408: Fix dict_repr(), don't call PyObject_Repr() with an exception setVictor Stinner2013-07-171-0/+3
| | | | | | | | | | PyObject_Repr() can removes the current exception. For example, module_repr() calls PyErr_Clear() if calling loader.module_repr(mod) failed.
* | longobject.c: add an assertion to ensure that MEDIUM_VALUE() is only called onVictor Stinner2013-07-171-1/+2
| | | | | | | | small integers (0 or 1 digit)
* | Issue #18408: Rewrite NEGATE() macro in longobject.c to handle ↵Victor Stinner2013-07-171-24/+51
| | | | | | | | PyLong_FromLong() failure
* | Issue #18408: Fix PyType_Ready(), handle _PyDict_SetItemId() failureVictor Stinner2013-07-171-3/+7
| |
* | Issue #18408: Fix Py_ReprEnter(), handle PyList_Append() failureVictor Stinner2013-07-171-1/+2
| |
* | Issue #18408: Fix listpop(), handle list_ass_slice() failureVictor Stinner2013-07-171-6/+4
| |
* | Issue #18408: Fix structseq_reduce(), handle PyDict_SetItemString() failureVictor Stinner2013-07-171-11/+13
| |
* | Close #18469: Replace PyDict_GetItemString() with _PyDict_GetItemId() in ↵Victor Stinner2013-07-161-5/+20
| | | | | | | | | | | | | | | | | | | | | | | | 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.
* | Cleanup type_call() to ease debugVictor Stinner2013-07-161-4/+6
| | | | | | | | | | | | 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.
* | Issue #18408: Py_ReprLeave() now saves/restores the current exception,Victor Stinner2013-07-161-2/+11
| | | | | | | | and ignores exceptions raised during the call
* | Issue #18408: dict_new() now fails on new_keys_object() errorVictor Stinner2013-07-161-10/+9
| | | | | | | | Pass the MemoryError exception to the caller, instead of using empty keys.
* | Cleanup dictobject.cVictor Stinner2013-07-161-17/+19
| |
* | Issue #18408: Fix PyDict_GetItemString(), suppress PyUnicode_FromString() errorVictor Stinner2013-07-161-1/+3
| | | | | | | | | | As PyDict_GetItem(), PyDict_GetItemString() suppresses all errors that may occur for historical reasons.
* | Issue #18408: Fix list.extend(), handle list_resize() failureVictor Stinner2013-07-161-2/+4
| |
* | Issue #18408: add more assertions on PyErr_Occurred() in ceval.c to detect bugsVictor Stinner2013-07-151-2/+1
| | | | | | | | earlier
* | Issue #18408: type_new() and PyType_FromSpecWithBases() now raise MemoryErrorVictor Stinner2013-07-151-2/+6
| | | | | | | | on memory allocation failure
* | Issue #18408: Don't check unicode consistency in _PyUnicode_HAS_UTF8_MEMORY()Victor Stinner2013-07-151-4/+2
| | | | | | | | | | | | | | | | | | | | | | 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.
* | Issue #18408: PyObject_Call() now fails with an assertion error in debug modeVictor Stinner2013-07-151-1/+7
| | | | | | | | | | if the function called failed whereas no exception was raised, to detect bugs earlier.
* | Issue #18408: pmerge() help of mro_implementation() now raises MemoryError onVictor Stinner2013-07-111-2/+4
| | | | | | | | | | | | | | memory allocation failure Replace also PyMem_Free() with PyMem_FREE() to be consistent with the rest of the function.
* | Issue #18408: In debug mode, PyCFunction_Call() now checks if an exception wasVictor Stinner2013-07-111-7/+23
| | | | | | | | | | raised if the result is NULL to help to find bugs in C mode (get the error earlier than the SystemError in ceval.c).
* | Issue #18408: slot_tp_str() must not fallback on slot_tp_repr() on errorVictor Stinner2013-07-111-19/+2
| | | | | | | | | | | | | | | | | | 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()).
* | typeobject.c: remove trailing spacesVictor Stinner2013-07-111-3/+3
| |
* | Issue #18408: Fix _PyMem_DebugRealloc()Victor Stinner2013-07-081-6/+8
| | | | | | | | | | | | | | | | 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).
* | Issue #18408: _PyUnicodeWriter_Finish() now clears its buffer attribute in allVictor Stinner2013-07-081-3/+6
| | | | | | | | cases, so _PyUnicodeWriter_Dealloc() can be called after finish.
* | Issue #18408: Fix _PyUnicodeWriter_Finish(): clear writer->buffer,Victor Stinner2013-07-081-2/+5
| | | | | | | | so _PyUnicodeWriter_Dealloc() can be called on the writer after finish.
* | Issue #18408: Fix PyType_Ready() and type.__bases__ setter to handleVictor Stinner2013-07-081-0/+2
| | | | | | | | PyWeakref_NewRef() failure (ex: MemoryError).
* | Issue #18408: Fix list.pop() to handle list_resize() failure (MemoryError).Victor Stinner2013-07-081-2/+4
| |
* | Issue #18408: Fix PyDict_New() to handle correctly new_keys_object() failureVictor Stinner2013-07-081-1/+5
| | | | | | | | (MemoryError).
* | Issue #18203: Add _PyMem_RawStrdup() and _PyMem_Strdup()Victor Stinner2013-07-071-0/+28
| | | | | | | | | | Replace strdup() with _PyMem_RawStrdup() or _PyMem_Strdup(), depending if the GIL is held or not.
* | Issue #18203: Fix _Py_DecodeUTF8_surrogateescape(), use PyMem_RawMalloc() as ↵Victor Stinner2013-07-071-2/+2
| | | | | | | | _Py_char2wchar()