Nick Coghlan
c72e4e6dcc
Issue #19619 : Blacklist non-text codecs in method API
str.encode, bytes.decode and bytearray.decode now use an
internal API to throw LookupError for known non-text encodings,
rather than attempting the encoding or decoding operation and
then throwing a TypeError for an unexpected output type.
The latter mechanism remains in place for third party non-text
encodings.
12 years ago
Victor Stinner
8455723cfb
Close #19568 : Fix bytearray_setslice_linear(), fix handling of
PyByteArray_Resize() failure: leave the bytearray object in an consistent state.
If growth < 0, handling the memory allocation failure is tricky here because
the bytearray object has already been modified. If lo != 0, the operation is
completed, but a MemoryError is still raised and the memory block is not
shrinked. If lo == 0, the bytearray is restored in its previous state and a
MemoryError is raised.
12 years ago
Victor Stinner
35f2803a24
Close #19578 : Fix list_ass_subscript(), handle list_resize() failure
Notify the caller of the failure (MemoryError exception).
12 years ago
Christian Heimes
985ecdcfc2
ssue #19183 : Implement PEP 456 'secure and interchangeable hash algorithm'.
Python now uses SipHash24 on all major platforms.
12 years ago
Serhiy Storchaka
dc2fd5101a
Remove dead code committed in issue #12892 .
12 years ago
Nick Coghlan
f1de55fb33
Also chain codec exceptions that allow weakrefs
The zlib and hex codecs throw custom exception types with
weakref support if the input type is valid, but the data
fails validation. Make sure the exception chaining in the
codec infrastructure can wrap those as well.
12 years ago
Victor Stinner
f91929b1d8
Issue #19646 : repr(dict) now uses _PyUnicodeWriter API for better performances
12 years ago
Victor Stinner
88a9cd9b57
Issue #19513 : repr(tuple) now uses _PyUnicodeWriter for better performances
12 years ago
Victor Stinner
4a58707a34
Add _PyUnicodeWriter_WriteASCIIString() function
12 years ago
Victor Stinner
4d3f109ad3
Issue #19513 : Disable overallocation of the PyUnicodeWriter before the last write
12 years ago
Serhiy Storchaka
58cf607d13
Issue #12892 : The utf-16* and utf-32* codecs now reject (lone) surrogates.
The utf-16* and utf-32* encoders no longer allow surrogate code points
(U+D800-U+DFFF) to be encoded.
The utf-32* decoders no longer decode byte sequences that correspond to
surrogate code points.
The surrogatepass error handler now works with the utf-16* and utf-32* codecs.
Based on patches by Victor Stinner and Kang-Hao (Kenny) Lu.
12 years ago
Victor Stinner
b8fb197aa0
Issue #19513 : Simplify list_repr()
12 years ago
Victor Stinner
5c733473f2
Issue #19513 : repr(list) now uses the PyUnicodeWriter API, it is faster than
the PyAccu API
12 years ago
Victor Stinner
6989ba0174
Issue #19581 : Change the overallocation factor of _PyUnicodeWriter on Windows
On Windows, a factor of 50% gives best performances.
12 years ago
Larry Hastings
ed4a1c5703
Argument Clinic: rename "self" to "module" for module-level functions.
12 years ago
Ezio Melotti
745d54d2fa
#17806 : Added keyword-argument support for "tabsize" to str/bytes.expandtabs().
12 years ago
Nick Coghlan
4b9b936429
Don't decref exc too soon
12 years ago
Victor Stinner
46ef31953e
Issue #19429 , #19437 : fix error handling in the OSError constructor
12 years ago
Benjamin Peterson
e109ee8205
fix refleaks
12 years ago
Benjamin Peterson
079c998872
adjust style
12 years ago
Christian Heimes
6a3db25c70
Issue #17828 : _PyObject_GetDictPtr() may return NULL instead of a PyObject**
CID 1128792: Dereference null return value (NULL_RETURNS)
12 years ago
Christian Heimes
507eabdf11
Issue #17828 : va_start() must be accompanied by va_end()
CID 1128793: Missing varargs init or cleanup (VARARGS)
12 years ago
Nick Coghlan
8b097b4ed7
Close #17828 : better handling of codec errors
- output type errors now redirect users to the type-neutral
convenience functions in the codecs module
- stateless errors that occur during encoding and decoding
will now be automatically wrapped in exceptions that give
the name of the codec involved
12 years ago
Victor Stinner
59799a8399
Don't use deprecated function PyUnicode_GET_SIZE()
Replace it with PyUnicode_GET_LENGTH() or PyUnicode_AsUnicodeAndSize()
12 years ago
Victor Stinner
3f36a5736b
Issue #19515 : Remove identifiers duplicated in the same file.
Patch written by Andrei Dorian Duma.
12 years ago
Victor Stinner
66b3270975
_Py_normalize_encoding(): explain how the value 6 was computed
12 years ago
Victor Stinner
bd303c165b
Issue #19512 , #19515 : remove shared identifiers, move identifiers where they
are used.
Move also _Py_IDENTIFIER() defintions to the top in modified files to remove
identifiers duplicated in the same file.
12 years ago
Victor Stinner
07e9e380f9
frameobject.c: Use an identifer instead of creating explicitly an interned
string for "__builtins__" literal string
12 years ago
Victor Stinner
df23e30bea
Fix _Py_normalize_encoding(): ensure that buffer is big enough to store "utf-8"
if the input string is NULL
12 years ago
Martin v. Löwis
e75fc14813
Issue #19514 : Deduplicate some _Py_IDENTIFIER declarations.
Patch by Andrei Dorian Duma.
12 years ago
Ezio Melotti
a5b9599538
#17080 : improve error message of float/complex when the wrong type is passed.
12 years ago
Victor Stinner
53e9ec48e5
Issue #19512 : Use the new _PyId_builtins identifier
12 years ago
Victor Stinner
ad14ccd047
Issue #19512 : add _PyUnicode_CompareWithId() function
_PyUnicode_CompareWithId() is faster than PyUnicode_CompareWithASCIIString()
when both strings are equal and interned.
Add also _PyId_builtins identifier for "builtins" common string.
12 years ago
Victor Stinner
3688aa9a04
Issue #19512 : type_abstractmethods() and type_set_abstractmethods() now use an
identifier for the "__abstractmethods__" string
12 years ago
Victor Stinner
5fd2e5ae8a
Issue #19512 : Add a new _PyDict_DelItemId() function, similar to
PyDict_DelItemString() but using an identifier for the key
12 years ago
Victor Stinner
7a07e451a4
Issue #19512 : Py_ReprEnter() and Py_ReprLeave() now use an identifier for the
"Py_Repr" dictionary key
12 years ago
Victor Stinner
21ea21ef6d
Issue #19424 : PyUnicode_CompareWithASCIIString() normalizes memcmp() result
to -1, 0, 1
12 years ago
Victor Stinner
f0c7b2af05
Issue #16286 : remove duplicated identity check from unicode_compare()
Move the test to PyUnicode_Compare()
12 years ago
Victor Stinner
fd9e44db37
Issue #16286 : optimize PyUnicode_RichCompare() for identical strings (same
pointer) for any operator, not only Py_EQ and Py_NE.
Code of bytes_richcompare() and PyUnicode_RichCompare() is now closer.
12 years ago
Victor Stinner
c8bc5377ac
Issue #16286 : write a new subfunction bytes_compare_eq()
* cleanup bytes_richcompare()
* PyUnicode_RichCompare(): replace a test with a XOR
12 years ago
Victor Stinner
e1b1592fd4
Issue #19424 : Fix a compiler warning on comparing signed/unsigned size_t
Patch written by Zachary Ware.
12 years ago
Victor Stinner
a6b9b071a3
Issue #19424 : Fix a compiler warning
memcmp() just takes raw pointers
12 years ago
Victor Stinner
602f7cf0b9
Issue #19424 : Optimize PyUnicode_CompareWithASCIIString()
Use fast memcmp() instead of a loop using the slow PyUnicode_READ() macro.
strlen() is still necessary to check Unicode string containing null bytes.
12 years ago
Antoine Pitrou
84745ab464
Issue #17936 : Fix O(n**2) behaviour when adding or removing many subclasses of a given type.
12 years ago
Victor Stinner
68b674c9d4
Issue #19437 : Fix _PyUnicode_New() (constructor of legacy string), set all
attributes before checking for error. The destructor expects all attributes to
be set. It is now safe to call Py_DECREF(unicode) in the constructor.
12 years ago
Victor Stinner
0b0c867178
Issue #19437 : Fix PyObject_CallFunction(), handle Py_VaBuildValue() and
PyTuple_New() failure
12 years ago
Victor Stinner
fa3ba4c3bc
Issue #18609 : Add a fast-path for "iso8859-1" encoding
On AIX, the locale encoding may be "iso8859-1", which was not a known syntax of
the legacy ISO 8859-1 encoding.
Using a C codec instead of a Python codec is faster but also avoids tricky
issues during Python startup or complex code.
12 years ago
Victor Stinner
bebba5059c
fix indent
12 years ago
Victor Stinner
cc64eb5b9f
Issue #18408 : Fix bytearrayiter.partition()/rpartition(), handle
PyByteArray_FromStringAndSize() failure (ex: on memory allocation failure)
12 years ago
Victor Stinner
986e224d5a
Issue #18408 : Fix error handling in PyBytes_FromObject()
_PyBytes_Resize(&new) sets new to NULL on error, don't call Py_DECREF() with NULL.
12 years ago