Serhiy Storchaka
191321d11b
Issue #20440 : More use of Py_SETREF.
...
This patch is manually crafted and contains changes that couldn't be handled
automatically.
2015-12-27 15:41:34 +02:00
Serhiy Storchaka
bdb908ea54
Issue #20440 : Applied yet one patch for using Py_SETREF.
...
The patch is automatically generated, it replaces the code that uses Py_CLEAR.
2015-12-27 12:38:28 +02:00
Serhiy Storchaka
4a1e70fc31
Issue #20440 : Applied yet one patch for using Py_SETREF.
...
The patch is automatically generated, it replaces the code that uses Py_CLEAR.
2015-12-27 12:36:18 +02:00
Serhiy Storchaka
f9253c96fd
Issue #22995 : Instances of extension types with a state that aren't
...
subclasses of list or dict and haven't implemented any pickle-related
methods (__reduce__, __reduce_ex__, __getnewargs__, __getnewargs_ex__,
or __getstate__), can no longer be pickled. Including memoryview.
2015-12-25 21:05:35 +02:00
Serhiy Storchaka
f81be8aa3f
Issue #22995 : Instances of extension types with a state that aren't
...
subclasses of list or dict and haven't implemented any pickle-related
methods (__reduce__, __reduce_ex__, __getnewargs__, __getnewargs_ex__,
or __getstate__), can no longer be pickled. Including memoryview.
2015-12-25 21:04:29 +02:00
Serhiy Storchaka
ef1585eb9a
Issue #25923 : Added more const qualifiers to signatures of static and private functions.
2015-12-25 20:01:53 +02:00
Serhiy Storchaka
2d06e84455
Issue #25923 : Added the const qualifier to static constant arrays.
2015-12-25 19:53:18 +02:00
Serhiy Storchaka
f006940351
Issue #20440 : Massive replacing unsafe attribute setting code with special
...
macro Py_SETREF.
2015-12-24 10:39:57 +02:00
Serhiy Storchaka
5a57ade58e
Issue #20440 : Massive replacing unsafe attribute setting code with special
...
macro Py_SETREF.
2015-12-24 10:35:59 +02:00
Serhiy Storchaka
3987e26e75
Issue #25914 : Fixed and simplified OrderedDict.__sizeof__.
2015-12-22 08:22:05 +02:00
Serhiy Storchaka
0ce7a3a34c
Issue #25914 : Fixed and simplified OrderedDict.__sizeof__.
2015-12-22 08:16:18 +02:00
Serhiy Storchaka
3182db356c
Issue #25766 : Special method __bytes__() now works in str subclasses.
2015-12-20 16:37:21 +02:00
Serhiy Storchaka
5aac3ed799
Issue #25766 : Special method __bytes__() now works in str subclasses.
2015-12-20 16:36:34 +02:00
Serhiy Storchaka
a9406e77fa
Issue #25421 : __sizeof__ methods of builtin types now use dynamic basic size.
...
This allows sys.getsize() to work correctly with their subclasses with
__slots__ defined.
2015-12-19 20:07:11 +02:00
Serhiy Storchaka
5c4064e8bd
Issue #25421 : __sizeof__ methods of builtin types now use dynamic basic size.
...
This allows sys.getsize() to work correctly with their subclasses with
__slots__ defined.
2015-12-19 20:05:25 +02:00
Serhiy Storchaka
42bb126f0a
Issue #25899 : Converted Objects/listsort.txt to UTF-8.
...
Original patch by Chris Angelico.
2015-12-18 13:23:33 +02:00
Serhiy Storchaka
9b3a2eec1c
Issues #25890 , #25891 , #25892 : Removed unused variables in Windows code.
...
Reported by Alexander Riccio.
2015-12-18 10:03:13 +02:00
Raymond Hettinger
e4495877dd
Minor tweek. Counting down rather than up reduces register pressure.
2015-12-15 00:42:30 -08:00
Raymond Hettinger
86d322f020
Undo inadvertent line swap
2015-12-13 19:27:17 -08:00
Raymond Hettinger
5088f6005f
Hoist constant expressions (so->table and so->mask) out of the inner-loop.
2015-12-13 18:45:01 -08:00
Serhiy Storchaka
7c088a9b5c
Issue #25709 : Fixed problem with in-place string concatenation and utf-8 cache.
2015-12-03 01:05:52 +02:00
Serhiy Storchaka
6648bf5661
Issue #25709 : Fixed problem with in-place string concatenation and utf-8 cache.
2015-12-03 01:04:37 +02:00
Serhiy Storchaka
7aa690860e
Issue #25709 : Fixed problem with in-place string concatenation and utf-8 cache.
2015-12-03 01:02:03 +02:00
Serhiy Storchaka
6a50e79130
Issue #24097 : Fixed crash in object.__reduce__() if slot name is freed inside
...
__getattr__. Original patch by Antoine Pitrou.
2015-11-25 18:35:15 +02:00
Serhiy Storchaka
670d78abc5
Issue #24097 : Fixed crash in object.__reduce__() if slot name is freed inside
...
__getattr__. Original patch by Antoine Pitrou.
2015-11-25 18:34:19 +02:00
Serhiy Storchaka
d28bb624d1
Issue #24097 : Fixed crash in object.__reduce__() if slot name is freed inside
...
__getattr__. Original patch by Antoine Pitrou.
2015-11-25 18:33:29 +02:00
Serhiy Storchaka
bb6e4a0b31
Issue #24731 : Fixed crash on converting objects with special methods
...
__bytes__, __trunc__, and __float__ returning instances of subclasses of
bytes, int, and float to subclasses of bytes, int, and float correspondingly.
2015-11-25 15:53:19 +02:00
Serhiy Storchaka
f9afda57ad
Issue #24731 : Fixed crash on converting objects with special methods
...
__bytes__, __trunc__, and __float__ returning instances of subclasses of
bytes, int, and float to subclasses of bytes, int, and float correspondingly.
2015-11-25 15:52:04 +02:00
Serhiy Storchaka
15095800a3
Issue #24731 : Fixed crash on converting objects with special methods
...
__bytes__, __trunc__, and __float__ returning instances of subclasses of
bytes, int, and float to subclasses of bytes, int, and float correspondingly.
2015-11-25 15:47:01 +02:00
Victor Stinner
b4efc963d6
Issue #25557 : Refactor _PyDict_LoadGlobal()
...
Don't fallback to PyDict_GetItemWithError() if the hash is unknown: compute the
hash instead. Add also comments to explain the optimization a little bit.
2015-11-20 09:24:02 +01:00
Raymond Hettinger
66f6238fca
Add assertion to verify the pre-condition in the comments.
2015-11-17 20:58:43 -08:00
Raymond Hettinger
6019c8ced0
Issue #25629 : Move set fill/used updates out of inner loop
2015-11-17 08:28:07 -08:00
Benjamin Peterson
d798dc1034
merge 3.5 ( #25630 )
2015-11-15 21:57:50 -08:00
Benjamin Peterson
a4d33b3428
make the PyUnicode_FSConverter cleanup set the decrefed argument to NULL ( closes #25630 )
2015-11-15 21:57:39 -08:00
Serhiy Storchaka
413fdcea21
Issue #24821 : Refactor STRINGLIB(fastsearch_memchr_1char) and split it on
...
STRINGLIB(find_char) and STRINGLIB(rfind_char) that can be used independedly
without special preconditions.
2015-11-14 15:42:17 +02:00
Serhiy Storchaka
1010921c71
Issue #25462 : The hash of the key now is calculated only once in most
...
operations in C implementation of OrderedDict.
2015-11-13 15:18:26 +02:00
Serhiy Storchaka
19a70e7f5d
Issue #25462 : The hash of the key now is calculated only once in most
...
operations in C implementation of OrderedDict.
2015-11-13 14:48:36 +02:00
Serhiy Storchaka
12ab296f82
Issue #22995 : Default implementation of __reduce__ and __reduce_ex__ now
...
rejects builtin types with not defined __new__.
Added tests for non-pickleable types.
2015-11-12 11:34:39 +02:00
Serhiy Storchaka
609a2e17ad
Issue #22995 : Default implementation of __reduce__ and __reduce_ex__ now
...
rejects builtin types with not defined __new__.
Added tests for non-pickleable types.
2015-11-12 11:31:51 +02:00
Serhiy Storchaka
d7a4415599
Issue #22995 : Default implementation of __reduce__ and __reduce_ex__ now
...
rejects builtin types with not defined __new__.
Added tests for non-pickleable types.
2015-11-12 11:23:04 +02:00
Stefan Krah
e2cf984384
Merge 3.5.
2015-11-10 18:35:47 +01:00
Stefan Krah
7c3f3859a5
Fix Visual Studio warning.
2015-11-10 18:35:19 +01:00
Stefan Krah
3407cc26cb
Merge 3.5.
2015-11-10 18:18:07 +01:00
Stefan Krah
0ce5b6e268
Iaaue #25598 : Fix memory_hex from #9951 for non-contiguous buffers.
2015-11-10 18:17:22 +01:00
Martin Panter
9513ba3b8f
Issue #24802 : Merge null termination fixes from 3.5
2015-11-07 03:15:32 +00:00
Martin Panter
61d6e4ae9d
Issue #24802 : Merge null termination fixes from 3.4 into 3.5
2015-11-07 02:56:11 +00:00
Martin Panter
eeb896c411
Issue #24802 : Copy bytes-like objects to null-terminated buffers if necessary
...
This avoids possible buffer overreads when int(), float(), compile(), exec()
and eval() are passed bytes-like objects. Similar code is removed from the
complex() constructor, where it was not reachable.
Patch by John Leitch, Serhiy Storchaka and Martin Panter.
2015-11-07 02:32:21 +00:00
Serhiy Storchaka
0c009bf3b5
Issue #25410 : Made testing that od_fast_nodes and dk_entries are in sync more
...
reliable.
2015-11-06 12:00:43 +02:00
Serhiy Storchaka
97f46db904
Issue #25410 : Made testing that od_fast_nodes and dk_entries are in sync more
...
reliable.
2015-11-06 12:00:03 +02:00
Serhiy Storchaka
3a811f272a
Issue #24726 : Revert setting the value on the dict if
...
_odict_add_new_node() fails.
2015-11-06 11:07:31 +02:00
Serhiy Storchaka
d5f353ec8d
Issue #24726 : Revert setting the value on the dict if
...
_odict_add_new_node() fails.
2015-11-06 11:07:11 +02:00
Serhiy Storchaka
6980be40bd
Issue #25558 : Refactoring OrderedDict iteration.
2015-11-06 10:40:05 +02:00
Serhiy Storchaka
9c967611e3
Issue #25558 : Refactoring OrderedDict iteration.
2015-11-06 10:39:51 +02:00
Victor Stinner
e20310fa19
Issue #25556 : Add assertions to PyObject_GetItem() to ensure that an exception
...
is raised when it returns NULL.
Simplify also ceval.c: rely on the fact that PyObject_GetItem() raised an
exception when it returns NULL.
2015-11-05 13:56:58 +01:00
Serhiy Storchaka
f83afa508f
Issue #25449 : Fixed a crash and leaking NULL in repr() of OrderedDict that
...
was mutated by direct calls of dict methods.
2015-11-04 22:33:33 +02:00
Serhiy Storchaka
710cd34bdb
Issue #25449 : Fixed a crash and leaking NULL in repr() of OrderedDict that
...
was mutated by direct calls of dict methods.
2015-11-04 22:33:07 +02:00
Serhiy Storchaka
161b6ff19c
Issue #25449 : Iterating OrderedDict with keys with unstable hash now raises
...
KeyError in C implementations as well as in Python implementation.
Added tests for OrderedDict subclasses.
2015-11-04 22:08:52 +02:00
Serhiy Storchaka
b45b7b2137
Issue #25449 : Iterating OrderedDict with keys with unstable hash now raises
...
KeyError in C implementations as well as in Python implementation.
Added tests for OrderedDict subclasses.
2015-11-04 22:05:38 +02:00
Serhiy Storchaka
4a7c03aab4
Issue #25523 : Merge a-to-an corrections from 3.5.
2015-11-02 14:44:29 +02:00
Serhiy Storchaka
a84f6c3dd3
Issue #25523 : Merge a-to-an corrections from 3.4.
2015-11-02 14:39:05 +02:00
Serhiy Storchaka
d65c9496da
Issue #25523 : Further a-to-an corrections.
2015-11-02 14:10:23 +02:00
Martin Panter
e56a919100
Issue #25523 : Merge a-to-an corrections from 3.5
2015-11-02 04:27:17 +00:00
Martin Panter
2eb819f7a8
Issue #25523 : Merge "a" to "an" fixes from 3.4 into 3.5
2015-11-02 04:04:57 +00:00
Martin Panter
7462b64911
Issue #25523 : Correct "a" article to "an" article
...
This changes the main documentation, doc strings, source code comments, and a
couple error messages in the test suite. In some cases the word was removed
or edited some other way to fix the grammar.
2015-11-02 03:37:02 +00:00
Serhiy Storchaka
9b69491901
Issue #25395 : Fixed crash when highly nested OrderedDict structures were
...
garbage collected.
2015-11-01 16:13:45 +02:00
Serhiy Storchaka
14eefe353e
Issue #25395 : Fixed crash when highly nested OrderedDict structures were
...
garbage collected.
2015-11-01 16:12:34 +02:00
Serhiy Storchaka
afbea7af02
Issue #25410 : C implementation of OrderedDict now uses type(self) instead of
...
self.__class__ in __repr__() and __reduce__() for simplicity and reliability.
2015-10-22 20:19:14 +03:00
Serhiy Storchaka
4575beba4b
Issue #25410 : C implementation of OrderedDict now uses type(self) instead of
...
self.__class__ in __repr__() and __reduce__() for simplicity and reliability.
2015-10-22 20:18:24 +03:00
Serhiy Storchaka
60a08929af
Issue #25410 : Fixed a memory leak in OrderedDict in the case when key's hash
...
calculation fails.
2015-10-20 18:22:36 +03:00
Serhiy Storchaka
d17427b7bd
Issue #25410 : Fixed a memory leak in OrderedDict in the case when key's hash
...
calculation fails.
2015-10-20 18:21:48 +03:00
Serhiy Storchaka
3e9f87782e
Issue #25410 : Cleaned up and fixed minor bugs in C implementation of OrderedDict.
2015-10-18 09:54:42 +03:00
Serhiy Storchaka
8003bafd7f
Issue #25410 : Cleaned up and fixed minor bugs in C implementation of OrderedDict.
2015-10-18 09:53:17 +03:00
Victor Stinner
91108f049f
Issue #25210 : Change error message of do_richcompare()
...
Don't add parenthesis to type names. Add also quotes around the type names.
Before:
TypeError: unorderable types: int() < NoneType()
After:
TypeError: '<' not supported between instances of 'int' and 'NoneType'
2015-10-14 18:25:31 +02:00
Serhiy Storchaka
dbb98c1443
Issue #25406 : Fixed a bug in C implementation of OrderedDict.move_to_end()
...
that caused segmentation fault or hang in iterating after moving several
items to the start of ordered dict.
2015-10-14 19:22:44 +03:00
Serhiy Storchaka
992ec46acc
Issue #25406 : Fixed a bug in C implementation of OrderedDict.move_to_end()
...
that caused segmentation fault or hang in iterating after moving several
items to the start of ordered dict.
2015-10-14 19:21:24 +03:00
Victor Stinner
c3d2bc19e4
Use _PyBytesWriter in _PyBytes_FromIterator()
2015-10-14 14:15:49 +02:00
Victor Stinner
c5c3ba4bec
Add _PyBytesWriter_Resize() function
...
This function gives a control to the buffer size without using min_size.
2015-10-14 13:56:47 +02:00
Victor Stinner
3c50ce39bf
Factorize _PyBytes_FromList() and _PyBytes_FromTuple() code using a C macro
2015-10-14 13:50:40 +02:00
Victor Stinner
f2eafa323b
Split PyBytes_FromObject() into subfunctions
2015-10-14 13:44:29 +02:00
Victor Stinner
2ec8063cc9
Modify _PyBytes_DecodeEscapeRecode() to use _PyBytesAPI
...
* Don't overallocate by 400% when recode is needed: only overallocate on demand
using _PyBytesWriter.
* Use _PyLong_DigitValue to convert hexadecimal digit to int
* Create _PyBytes_DecodeEscapeRecode() subfunction
2015-10-14 13:32:13 +02:00
Victor Stinner
1285e5c805
Fix compiler warnings (uninitialized variables), false alarms in fact
2015-10-14 12:10:20 +02:00
Victor Stinner
f6358a7e4c
_PyBytesWriter_Alloc(): only use 10 bytes of the small buffer in debug mode to
...
enhance code to detect buffer under- and overflow.
2015-10-14 12:02:39 +02:00
Victor Stinner
f091033b14
Issue #25401 : Remove now unused hex_digit_to_int() function
2015-10-14 11:59:46 +02:00
Victor Stinner
2bf8993db9
Optimize bytes.fromhex() and bytearray.fromhex()
...
Issue #25401 : Optimize bytes.fromhex() and bytearray.fromhex(): they are now
between 2x and 3.5x faster. Changes:
* Use a fast-path working on a char* string for ASCII string
* Use a slow-path for non-ASCII string
* Replace slow hex_digit_to_int() function with a O(1) lookup in
_PyLong_DigitValue precomputed table
* Use _PyBytesWriter API to handle the buffer
* Add unit tests to check the error position in error messages
2015-10-14 11:25:33 +02:00
Victor Stinner
772b2b09f2
Optimize bytearray % args
...
Issue #25399 : Don't create temporary bytes objects: modify _PyBytes_Format() to
create work directly on bytearray objects.
* Rename _PyBytes_Format() to _PyBytes_FormatEx() just in case if something
outside CPython uses it
* _PyBytes_FormatEx() now uses (char*, Py_ssize_t) for the input string, so
bytearray_format() doesn't need tot create a temporary input bytes object
* Add use_bytearray parameter to _PyBytes_FormatEx() which is passed to
_PyBytesWriter, to create a bytearray buffer instead of a bytes buffer
Most formatting operations are now between 2.5 and 5 times faster.
2015-10-14 09:56:53 +02:00
Victor Stinner
661aaccf9d
Add use_bytearray attribute to _PyBytesWriter
...
Issue #25399 : Add a new use_bytearray attribute to _PyBytesWriter to use a
bytearray buffer, instead of using a bytes object.
2015-10-14 09:41:48 +02:00
Victor Stinner
199c9a6f4b
Fix long_format_binary()
...
Issue #25399 : Fix long_format_binary(), allocate bytes for the bytes writer.
2015-10-14 09:47:23 +02:00
Victor Stinner
03dab786b2
Rewrite PyBytes_FromFormatV() using _PyBytesWriter API
...
* Add much more unit tests on PyBytes_FromFormatV()
* Remove the first loop to compute the length of the output string
* Use _PyBytesWriter to handle the bytes buffer, use overallocation
* Cleanup the code to make simpler and easier to review
2015-10-14 00:21:35 +02:00
Victor Stinner
358af13526
Issue #25353 : Optimize unicode escape and raw unicode escape encoders to use
...
the new _PyBytesWriter API.
2015-10-12 22:36:57 +02:00
Victor Stinner
e9aa5950bb
Fix compilation error in _PyBytesWriter_WriteBytes() on Windows
2015-10-12 13:57:47 +02:00
Victor Stinner
6c2cdae9e6
Writer APIs: use empty string singletons
...
Modify _PyBytesWriter_Finish() and _PyUnicodeWriter_Finish() to return the
empty bytes/Unicode string if the string is empty.
2015-10-12 13:29:43 +02:00
Victor Stinner
c29e29bed1
Relax _PyBytesWriter API
...
Don't require _PyBytesWriter pointer to be a "char *". Same change for
_PyBytesWriter_WriteBytes() parameter.
For example, binascii uses "unsigned char*".
2015-10-12 13:12:54 +02:00
Serhiy Storchaka
0d554d7ef1
Issue #24164 : Objects that need calling ``__new__`` with keyword arguments,
...
can now be pickled using pickle protocols older than protocol version 4.
2015-10-10 22:42:18 +03:00
Victor Stinner
0cdad1e2bc
Issue #25349 : Add fast path for b'%c' % int
...
Optimize also %% formater.
2015-10-09 22:50:36 +02:00
Victor Stinner
be75b8cf23
Issue #25349 : Optimize bytes % int
...
Optimize bytes.__mod__(args) for integere formats: %d (%i, %u), %o, %x and %X.
_PyBytesWriter is now used to format directly the integer into the writer
buffer, instead of using a temporary bytes object.
Formatting is between 30% and 50% faster on a microbenchmark.
2015-10-09 22:43:24 +02:00
Victor Stinner
6bd525b656
Optimize error handlers of ASCII and Latin1 encoders when the replacement
...
string is pure ASCII: use _PyBytesWriter_WriteBytes(), don't check individual
character.
Cleanup unicode_encode_ucs1():
* Rename repunicode to rep
* Clear rep object on error
* Factorize code between bytes and unicode path
2015-10-09 13:10:05 +02:00
Victor Stinner
ce179bf6ba
Add _PyBytesWriter_WriteBytes() to factorize the code
2015-10-09 12:57:22 +02:00
Victor Stinner
ad7715891e
_PyBytesWriter: simplify code to avoid "prealloc" parameters
...
Substract preallocate bytes from min_size before calling
_PyBytesWriter_Prepare().
2015-10-09 12:38:53 +02:00
Victor Stinner
53926a1ce2
_PyBytesWriter: rename size attribute to min_size
2015-10-09 12:37:03 +02:00
Victor Stinner
fa7762ec06
Issue #25349 : Optimize bytes % args using the new private _PyBytesWriter API
...
* Thanks to the _PyBytesWriter API, output smaller than 512 bytes are allocated
on the stack and so avoid calling _PyBytes_Resize(). Because of that, change
the default buffer size to fmtcnt instead of fmtcnt+100.
* Rely on _PyBytesWriter algorithm to overallocate the buffer instead of using
a custom code. For example, _PyBytesWriter uses a different overallocation
factor (25% or 50%) depending on the platform to get best performances.
* Disable overallocation for the last write.
* Replace C loops to fill characters with memset()
* Add also many comments to _PyBytes_Format()
* Remove unused FORMATBUFLEN constant
* Avoid the creation of a temporary bytes object when formatting a floating
point number (when no custom formatting option is used)
* Fix also reference leaks on error handling
* Use Py_MEMCPY() to copy bytes between two formatters (%)
2015-10-09 11:48:06 +02:00