Stefan Krah
dce6502059
bpo-31279: Silence -Wstringop-overflow warning. ( #3207 )
2017-08-25 20:12:05 +02:00
INADA Naoki
a6296d34a4
bpo-31095: fix potential crash during GC (GH-2974)
2017-08-24 14:55:17 +09:00
Martijn Pieters
772d809a63
bpo-31161: only check for parens error for SyntaxError ( #3082 )
...
Subclasses such as IndentError and TabError should not have this message
applied.
2017-08-22 13:16:23 -07:00
Stefan Krah
f432a3234f
bpo-30923: Silence fall-through warnings included in -Wextra since gcc-7.0. ( #3157 )
2017-08-21 13:09:59 +02:00
Sanyam Khurana
a7c449b8c0
bpo-30721: Add missing '?' to new error message (GH-3131)
2017-08-18 22:18:14 +10:00
Sanyam Khurana
5e2eb35bbe
bpo-30721: Show correct syntax hint in Py3 when using Py2 redirection syntax ( #2345 )
2017-08-18 13:37:36 +03:00
INADA Naoki
778928b0c7
bpo-29304: Simplify dict lookup functions (GH-2407)
...
* remove hashpos parameter from lookdict functions.
* remove many duplicated code from lookdict functions.
2017-08-03 23:45:15 +09:00
Serhiy Storchaka
5075416b8f
bpo-30978: str.format_map() now passes key lookup exceptions through. ( #2790 )
...
Previously any exception was replaced with a KeyError exception.
2017-08-03 11:45:23 +03:00
Zackery Spytz
c6ea8974e2
bpo-30640: Fix undefined behavior in _PyFunction_FastCallDict() and PyEval_EvalCodeEx() ( #2919 )
...
k + 1 was calculated with k = NULL.
2017-07-31 17:24:37 +03:00
Serhiy Storchaka
64e461be09
bpo-22207: Add checks for possible integer overflows in unicodeobject.c. ( #2623 )
...
Based on patch by Victor Stinner.
2017-07-11 06:55:25 +03:00
Sylvain
9648088e6c
bpo-30878: Fix error message when keyword arguments are passed ( #2635 )
...
to staticmethod() and classmethod().
2017-07-09 06:45:06 +03:00
Serhiy Storchaka
378ebb6578
bpo-30789: Use a single memory block for co_extra. ( #2555 )
...
* bpo-30789: Use a single memory block for co_extra.
* Address review comments.
2017-07-04 14:06:16 +02:00
Serhiy Storchaka
6969eaf468
bpo-29464: Rename METH_FASTCALL to METH_FASTCALL|METH_KEYWORDS and make ( #1955 )
...
the bare METH_FASTCALL be used for functions with positional-only
parameters.
2017-07-03 21:20:15 +03:00
Serhiy Storchaka
f7eae0adfc
[security] bpo-13617: Reject embedded null characters in wchar* strings. ( #2302 )
...
Based on patch by Victor Stinner.
Add private C API function _PyUnicode_AsUnicode() which is similar to
PyUnicode_AsUnicode(), but checks for null characters.
2017-06-28 08:30:06 +03:00
Victor Stinner
23e7944eba
bpo-30704, bpo-30604: Fix memleak in code_dealloc() ( #2455 )
...
Free also co_extra->ce_extras, not only co_extra.
2017-06-28 02:12:00 +02:00
Serhiy Storchaka
e613e6add5
bpo-30708: Check for null characters in PyUnicode_AsWideCharString(). ( #2285 )
...
Raise a ValueError if the second argument is NULL and the wchar_t\*
string contains null characters.
2017-06-27 16:03:14 +03:00
INADA Naoki
870c286e27
bp-29304: Simplify dictobject.c (GH-2347)
...
replace `(i << 2) + 1` with `i*5`
2017-06-24 09:03:19 +09:00
Serhiy Storchaka
d174d24a5d
bpo-30730: Prevent environment variables injection in subprocess on Windows. ( #2325 )
...
Prevent passing other invalid environment variables and command arguments.
2017-06-23 19:39:27 +03:00
INADA Naoki
073ae487b3
bpo-29304: simplify lookdict_index() function. (GH-2273)
2017-06-23 15:22:50 +09:00
Benjamin Peterson
279a96206f
bpo-30736: upgrade to Unicode 10.0 ( #2344 )
...
Straightforward. While we're at it, though, strip trailing whitespace from generated tables.
2017-06-22 22:31:08 -07:00
Dino Viehland
f3cffd2b78
bpo-30604: clean up co_extra support ( #2144 )
...
bpo-30604: port fix from 3.6 dropping binary compatibility tweaks
2017-06-21 17:44:36 -04:00
Sanyam Khurana
3a7f03584a
bpo-30597: Show expected input in custom 'print' error message. ( #2009 )
2017-06-20 16:31:32 +03:00
Sylvain
7445381c60
bpo-30600: Fix error messages (condition order in Argument Clinic) ( #2051 )
...
The function '_PyArg_ParseStack()' and
'_PyArg_UnpackStack' were failing (with error
"XXX() takes Y argument (Z given)") before
the function '_PyArg_NoStackKeywords()' was called.
Thus, the latter did not raise its more meaningful
error : "XXX() takes no keyword arguments".
2017-06-10 07:51:48 +03:00
Lisa Roach
64505a1f6c
bpo-30486: Allow setting cell value ( #1840 )
...
The cell_contents attribute of the cell object is now writable.
2017-06-08 14:43:26 +03:00
Serhiy Storchaka
6cca5c8459
bpo-30592: Fixed error messages for some builtins. ( #1996 )
...
Error messages when pass keyword arguments to some builtins that
don't support keyword arguments contained double parenthesis: "()()".
The regression was introduced by bpo-30534.
2017-06-08 14:41:19 +03:00
Serhiy Storchaka
5eb788bf7f
bpo-30534: Fixed error messages when pass keyword arguments ( #1901 )
...
to functions implemented in C that don't support this.
Also unified error messages for functions that don't take positional or keyword
arguments.
2017-06-06 18:45:22 +03:00
Serhiy Storchaka
4e624ca50a
bpo-30509: Clean up calling type slots. ( #1883 )
...
Also speed up slot_sq_item.
2017-06-01 08:18:25 +03:00
Serhiy Storchaka
753bca3934
bpo-27945: Fixed various segfaults with dict. ( #1657 )
...
Based on patches by Duane Griffin and Tim Mitchell.
2017-05-20 12:30:02 +03:00
Serhiy Storchaka
d896985bb2
bpo-25794: Fix `type.__setattr__()` for non-interned attribute names. ( #1652 )
...
Based on patch by Eryk Sun.
2017-05-20 08:48:06 +03:00
Serhiy Storchaka
7e19dbc92e
bpo-28974: `object.__format__(x, '')` is now equivalent to `str(x)` ( #506 )
...
rather than `format(str(self), '')`.
2017-05-13 12:40:52 +03:00
Xiang Zhang
a66f9c6bb1
bpo-30341: Improve _PyTrash_thread_destroy_chain() a little bit ( #1545 )
...
* add a comment about why we need to increase trash_delete_nesting
* move increase and decrese outside of the loop
2017-05-13 13:36:14 +08:00
Xiang Zhang
2ddf5a19c3
bpo-30281: Fix the default value for stop in PySlice_Unpack() ( #1480 )
2017-05-10 18:19:41 +08:00
Serhiy Storchaka
1a5856bf92
bpo-29867: Add asserts in PyTuple_GET_SIZE, PyList_GET_SIZE and PySet_GET_SIZE. ( #751 )
2017-04-22 01:48:11 +02:00
Serhiy Storchaka
40db90c1ce
bpo-29802: Fix reference counting in module-level struct functions ( #1213 )
...
when pass arguments of wrong type.
2017-04-20 21:19:31 +03:00
Dong-hee Na
b4dc6af7a7
bpo-12414: Update code_sizeof() to take in account co_extra memory. ( #1168 )
2017-04-20 10:31:17 +03:00
Serhiy Storchaka
bf623ae884
bpo-30061: Check if PyObject_Size()/PySequence_Size()/PyMapping_Size() ( #1096 )
...
raised an error.
Replace them with using concrete types API that never fails if appropriate.
2017-04-19 20:03:52 +03:00
Xiang Zhang
8e1ddbd592
fix a refleak in slot_sq_length ( #1162 )
2017-04-17 00:54:21 +08:00
Serhiy Storchaka
55fe1ae970
bpo-30022: Get rid of using EnvironmentError and IOError (except test… ( #1051 )
2017-04-16 10:46:38 +03:00
Serhiy Storchaka
baf9f29811
bpo-29839: Raise ValueError rather than OverflowError in len() for negative values. ( #701 )
2017-04-16 09:37:18 +03:00
Serhiy Storchaka
813f943c59
bpo-29838: Add asserts for checking results of sq_length and mq_length slots. ( #700 )
...
Negative result should be returned only when an error is set.
2017-04-16 09:21:44 +03:00
Serhiy Storchaka
b785396ab4
bpo-29998: Pickling and copying ImportError now preserves name and path ( #1010 )
...
attributes.
2017-04-08 09:55:07 +03:00
Serhiy Storchaka
b879fe82e7
Expand the PySlice_GetIndicesEx macro. ( #1023 )
2017-04-08 09:53:51 +03:00
Serhiy Storchaka
205e00c5cf
bpo-29914: Fix default implementations of __reduce__ and __reduce_ex__(). ( #843 )
...
object.__reduce__() no longer takes arguments, object.__reduce_ex__() now
requires one argument.
2017-04-08 09:52:59 +03:00
Serhiy Storchaka
bae6881b42
Update Argument Clinic generated code for bpo-29878. ( #1001 )
2017-04-05 12:00:42 +03:00
Lisa Roach
43ba8861e0
bpo-29549: Fixes docstring for str.index ( #256 )
...
* Updates B.index documentation.
* Updates str.index documentation, makes it Argument Clinic compatible.
* Removes ArgumentClinic code.
* Finishes string.index documentation.
* Updates string.rindex documentation.
* Documents B.rindex.
2017-04-04 22:36:22 -07:00
INADA Naoki
e82cf8675b
bpo-29949: Fix set memory usage regression (GH-943)
...
Revert "Minor factoring: move redundant resize scaling logic into the resize function."
This reverts commit 4897300276
.
2017-04-01 17:20:25 +09:00
T. Wouters
06bb4873d6
Fix spurious MemoryError introduced by PR #886 . ( #930 )
...
Fix MemoryError caused by moving around code in PR #886 ; nbytes was sometimes used unitinitalized (in non-debug builds, when use_calloc was false and elsize was 0).
2017-03-31 10:10:19 -07:00
T. Wouters
a00c3fd12d
bpo-29941: Assert fixes ( #886 )
...
Make a non-Py_DEBUG, asserts-enabled build of CPython possible. This means
making sure helper functions are defined when NDEBUG is not defined, not
just when Py_DEBUG is defined.
Also fix a division-by-zero in obmalloc.c that went unnoticed because in Py_DEBUG mode, elsize is never zero.
2017-03-31 09:14:41 -07:00
Serhiy Storchaka
d4edfc9abf
bpo-29935: Fixed error messages in the index() method of tuple, list and deque ( #887 )
...
when pass indices of wrong type.
2017-03-30 18:29:23 +03:00
Serhiy Storchaka
918403cfc3
bpo-29816: Shift operation now has less opportunity to raise OverflowError. ( #680 )
...
ValueError always is raised rather than OverflowError for negative counts.
Shifting zero with non-negative count always returns zero.
2017-03-30 09:47:07 +03:00
Serhiy Storchaka
0a58f72762
bpo-24821: Fixed the slowing down to 25 times in the searching of some ( #505 )
...
unlucky Unicode characters.
2017-03-30 09:11:10 +03:00
Serhiy Storchaka
ba85d69a3e
bpo-29878: Add global instances of int for 0 and 1. ( #852 )
2017-03-30 09:09:41 +03:00
Louie Lu
c431854a09
bpo-29927: Remove duplicate BufferError init and unnecessary semicolons (GH-866)
2017-03-29 13:28:15 +08:00
Sylvain
d67a103702
bpo-29924: Remove useless argument ( #854 )
2017-03-27 23:36:08 +02:00
Serhiy Storchaka
671079ef60
bpo-29894: Deprecate returning an instance of complex subclass from __complex__. ( #798 )
...
In a future versions of Python this can be an error.
2017-03-24 21:28:43 +02:00
Serhiy Storchaka
fff9a31a91
bpo-29865: Use PyXXX_GET_SIZE macros rather than Py_SIZE for concrete types. ( #748 )
2017-03-21 08:53:25 +02:00
Serhiy Storchaka
c61ac1642d
Don't use Py_SIZE for dict object. ( #747 )
2017-03-21 08:52:38 +02:00
4kir4
e46fb86118
bpo-28876: bool of large range raises OverflowError ( #699 )
2017-03-20 08:44:46 +02:00
Serhiy Storchaka
6b5a9ec478
bpo-29116: Fix error messages for concatenating bytes and bytearray with unsupported type. ( #709 )
2017-03-19 19:47:02 +02:00
Serhiy Storchaka
004e03fb0c
bpo-29116: Improve error message for concatenating str with non-str. ( #710 )
2017-03-19 19:38:42 +02:00
Serhiy Storchaka
80ec8364f1
bpo-29748: Added the slice index converter in Argument Clinic. ( #549 )
2017-03-19 19:37:40 +02:00
Serhiy Storchaka
18b250f844
bpo-29793: Convert some builtin types constructors to Argument Clinic. ( #615 )
2017-03-19 08:51:07 +02:00
Serhiy Storchaka
0b5615926a
bpo-20186: Convert tuple object implementation to Argument Clinic. ( #614 )
2017-03-19 08:47:58 +02:00
Serhiy Storchaka
5c643a028e
bpo-20185: Convert typeobject.c to Argument Clinic. ( #544 )
...
Based on patch by Vajrasky Kok.
2017-03-19 08:46:44 +02:00
Victor Stinner
0f7b0b397e
bpo-29735: Optimize partial_call(): avoid tuple ( #516 )
...
* Add _PyObject_HasFastCall()
* partial_call() now avoids temporary tuple to pass positional
arguments if the callable supports the FASTCALL calling convention
for positional arguments.
* Fix also a performance regression in partial_call() if the callable
doesn't support FASTCALL.
2017-03-14 21:37:20 +01:00
Ivan Levkivskyi
9135275cba
bpo-28810: Update lnotab_notes.txt ( #665 )
2017-03-14 21:42:09 +02:00
INADA Naoki
aa289a59ff
bpo-29548: Recommend PyObject_Call APIs over PyEval_Call APIs. (GH-75)
...
PyEval_Call* APIs are not documented and they doesn't respect PY_SSIZE_T_CLEAN.
So add comment block which recommends PyObject_Call* APIs to ceval.h.
This commit also changes PyEval_CallMethod and PyEval_CallFunction
implementation same to PyObject_CallMethod and PyObject_CallFunction
to reduce future maintenance cost. Optimization to avoid temporary
tuple are copied too.
PyEval_CallFunction(callable, "i", (int)i) now calls callable(i) instead of
raising TypeError. But accepting this edge case is backward compatible.
2017-03-14 18:00:59 +09:00
Xiang Zhang
7e2a54cdd9
bpo-28856: Let %b format for bytes support objects that follow the buffer protocol (GH-546)
2017-03-14 15:07:15 +08:00
Oren Milman
004251059b
bpo-29730: replace some calls to PyNumber_Check and improve some error messages ( #650 )
2017-03-13 00:37:05 +02:00
Yury Selivanov
b7c9150b68
Fix wrapping into StopIteration of return values in generators and coroutines ( #644 )
2017-03-12 15:53:07 -04:00
Serhiy Storchaka
202fda55c2
bpo-24037: Add Argument Clinic converter `bool(accept={int})`. ( #485 )
2017-03-12 10:10:47 +02:00
Serhiy Storchaka
b5c51d3dd9
bpo-20185: Convert float object implementation to Argument Clinic. ( #543 )
...
Based on patch by Vajrasky Kok.
2017-03-11 09:21:05 +02:00
Serhiy Storchaka
fdd42c481e
bpo-20185: Convert list object implementation to Argument Clinic. ( #542 )
2017-03-11 09:19:20 +02:00
svelankar
390a0969c1
bpo-29749: Update int() docstring (GH-565)
...
The docstring did not properly represent the fact that the argument to int() was positional-only.
2017-03-08 16:29:01 -08:00
Serhiy Storchaka
370fd202f1
Use Py_RETURN_FALSE/Py_RETURN_TRUE rather than PyBool_FromLong(0)/PyBool_FromLong(1). ( #567 )
2017-03-08 20:47:48 +02:00
Serhiy Storchaka
9f8ad3f39e
bpo-29568: Disable any characters between two percents for escaped percent "%%" in the format string for classic string formatting. (GH-513)
2017-03-08 11:51:19 +08:00
Xiang Zhang
c393ee8589
bpo-24329: allow __qualname__ and __classcell__ in __slots__ (GH-495)
2017-03-08 11:18:49 +08:00
Serhiy Storchaka
98e80c2bab
bpo-29737: Optimize concatenating with empty tuple. ( #524 )
2017-03-06 23:39:35 +02:00
Serhiy Storchaka
2e5642422f
bpo-29695: Remove bad keyword parameters in int(), bool(), float(), list() and tuple(). ( #518 )
2017-03-06 17:01:06 +02:00
Xiang Zhang
b76ad5121e
bpo-29714: Fix a regression that bytes format may fail when containing zero bytes inside. (GH-499)
2017-03-06 17:17:05 +08:00
orenmn
86aa269646
remove 3 redundant casts in Objects/longobject.c ( #445 )
2017-03-06 08:42:47 +00:00
Serhiy Storchaka
58d23e6806
bpo-29695: Deprecated using bad named keyword arguments in builtings: ( #486 )
...
int(), bool(), float(), list() and tuple(). Specify the value as a
positional argument instead.
2017-03-06 00:53:39 +02:00
Brian Coleman
6a9122ce69
bpo-29683 - Fixes to _PyCode_SetExtra when co_extra->ce->extras is ( #376 )
...
allocated.
On PyMem_Realloc failure, _PyCode_SetExtra should free co_extra if
co_extra->ce_extras could not be allocated.
On PyMem_Realloc success, _PyCode_SetExtra should set all unused slots in
co_extra->ce_extras to NULL.
2017-03-02 11:32:18 +01:00
INADA Naoki
3824cd8fd4
bpo-29684: Fix regression of PyEval_CallObjectWithKeywords (GH-87)
...
It should raise TypeError when kwargs is not a dict.
2017-03-01 20:41:03 +09:00
Victor Stinner
561ca80cff
Document why functools.partial() must copy kwargs ( #253 )
...
Add a comment to prevent further attempts to avoid a copy for
optimization.
2017-02-23 18:26:43 +01:00
Xiang Zhang
4cee049f5b
bpo-27660: remove unnecessary overflow checks in list_resize (GH-189)
2017-02-22 12:32:30 +08:00
INADA Naoki
3e8d6cb189
bpo-29509: skip redundant intern (GH-197)
...
PyObject_GetAttrString intern temporary key string.
It's completely redudant.
2017-02-21 23:57:25 +09:00
Mark Dickinson
112ec38c15
bpo-29602: fix signed zero handling in complex constructor. ( #203 )
...
* Fix incorrect handling of signed zeros for complex-related classes.
* Add Misc/NEWS entry.
2017-02-20 20:28:15 +00:00
INADA Naoki
1b8df107f8
bpo-24274: fix erroneous comment in dictobject.c (GH-196)
...
lookdict_unicode() and lookdict_unicode_nodummy() may raise exception
when key is not unicode.
2017-02-20 22:48:10 +09:00
Xiang Zhang
d0e8212ed7
bpo-29347: Fix possibly dereferencing undefined pointers when creating weakref objects ( #128 )
2017-02-20 12:25:16 +08:00
INADA Naoki
72dccde884
bpo-29548: Fix some inefficient call API usage (GH-97)
2017-02-16 09:26:01 +09:00
Victor Stinner
c22bfaae83
bpo-29524: Add Objects/call.c file ( #12 )
...
* Move all functions to call objects in a new Objects/call.c file.
* Rename fast_function() to _PyFunction_FastCallKeywords().
* Copy null_error() from Objects/abstract.c
* Inline type_error() in call.c to not have to copy it, it was only
called once.
* Export _PyEval_EvalCodeWithName() since it is now called
from call.c.
2017-02-12 19:27:05 +01:00
INADA Naoki
2294f3aee1
bpo-29438: fixed use-after-free in key sharing dict ( #17 )
2017-02-12 13:51:30 +09:00
Victor Stinner
d2306cec4d
Backed out changeset f23fa1f7b68f
...
Sorry, I didn't want to push this change before the review :-( I was pushing a
change into the 2.7 branch.
2017-02-10 14:19:36 +01:00
Victor Stinner
766af559ad
Issue #29465 : Add Objects/call.c file
...
* Move all functions to call objects in a new Objects/call.c file.
* Rename fast_function() to _PyFunction_FastCallKeywords().
* Copy null_error() from Objects/abstract.c
* Inline type_error() in call.c to not have to copy it, it was only
called once.
* Export _PyEval_EvalCodeWithName() since it is now called
from call.c.
2017-02-10 13:32:29 +01:00
Victor Stinner
fe4ff83049
Issue #29507 : Fix _PyObject_CallFunctionVa()
...
is_size_t test was reversed. Bug spotted by INADA Naoki.
2017-02-10 00:41:06 +01:00
Victor Stinner
516b98161a
Optimize slots: avoid temporary PyMethodObject
...
Issue #29507 : Optimize slots calling Python methods. For Python methods, get
the unbound Python function and prepend arguments with self, rather than
calling the descriptor which creates a temporary PyMethodObject.
Add a new _PyObject_FastCall_Prepend() function used to call the unbound Python
method with self. It avoids the creation of a temporary tuple to pass
positional arguments.
Avoiding temporary PyMethodObject and avoiding temporary tuple makes Python
slots up to 1.46x faster. Microbenchmark on a __getitem__() method implemented
in Python:
Median +- std dev: 121 ns +- 5 ns -> 82.8 ns +- 1.0 ns: 1.46x faster (-31%)
Co-Authored-by: INADA Naoki <songofacandy@gmail.com>
2017-02-09 22:53:47 +01:00
Victor Stinner
12c5838dae
Fix PyCFunction_Call() performance issue
...
Issue #29259 , #29465 : PyCFunction_Call() doesn't create anymore a redundant
tuple to pass positional arguments for METH_VARARGS.
Add a new cfunction_call() subfunction.
2017-02-09 02:01:37 +01:00
Victor Stinner
620580f280
Fix refleaks if Py_EnterRecursiveCall() fails
...
Issue #29306 : Destroy argstuple and kwdict if Py_EnterRecursiveCall() fails.
2017-02-08 12:57:09 +01:00
Victor Stinner
7399a05965
Issue #29306 : Fix usage of Py_EnterRecursiveCall()
...
* *PyCFunction_*Call*() functions now call Py_EnterRecursiveCall().
* PyObject_Call() now calls directly _PyFunction_FastCallDict() and
PyCFunction_Call() to avoid calling Py_EnterRecursiveCall() twice per
function call
2017-02-08 12:06:00 +01:00
Serhiy Storchaka
68a001dd59
Issue #29460 : _PyArg_NoKeywords(), _PyArg_NoStackKeywords() and
...
_PyArg_NoPositional() now are macros.
2017-02-06 10:41:46 +02:00
Raymond Hettinger
5cd87a8d61
Reduce load factor (from 66% to 60%) to improve effectiveness of linear probing.
...
Decreased density gives better collision statistics (average of 2.5 probes in a
full table versus 3.0 previously) and fewer occurences of starting a second
possibly overlapping sequence of 10 linear probes. Makes resizes a little more
frequent but each with less work (fewer insertions and fewer collisions).
2017-02-04 02:43:42 -08:00
Serhiy Storchaka
19d2597ed5
Issue #29311 : Regenerate Argument Clinic.
2017-02-04 08:05:07 +02:00
INADA Naoki
5566bbb8d5
Issue #29263 : LOAD_METHOD support for C methods
...
Calling builtin method is at most 10% faster.
2017-02-03 07:43:03 +09:00
Raymond Hettinger
e1af6964b4
Remove unnecessary variables.
...
* so->used never gets changed during a resize
* so->filled only changes when dummies are present and being eliminated
2017-02-02 08:24:48 -08:00
Serhiy Storchaka
196a7bc1ea
Issue #29421 : Make int.to_bytes() and int.from_bytes() slightly faster
...
(10-20% for small integers).
2017-02-02 16:54:45 +02:00
Serhiy Storchaka
495e8808d7
Issue #20185 : Converted the int class to Argument Clinic.
...
Based on patch by Vajrasky Kok.
2017-02-01 23:12:20 +02:00
INADA Naoki
35a96a25ee
Issue #29383 : reduce temporary interned unicode
...
add_methods(), add_members(), and add_getset() used PyDict_SetItemString()
to register descriptor to the type's dict.
So descr_new() and PyDict_SetItemString() creates interned unicode from same
C string.
This patch takes interned unicode from descriptor, and use PyDict_SetItem()
instead of PyDict_SetItemString().
python_startup_no_site:
default: Median +- std dev: 12.7 ms +- 0.1 ms
patched: Median +- std dev: 12.5 ms +- 0.1 ms
2017-01-28 16:35:44 +09:00
Victor Stinner
bda5a2be37
Issue #29358 : Add postcondition checks on types
2017-01-25 23:33:27 +01:00
Serhiy Storchaka
6e08baf12d
Issue #27867 : Function PySlice_GetIndicesEx() is deprecated and replaced with
...
a macro if Py_LIMITED_API is not set or set to the value between 0x03050400
and 0x03060000 (not including) or 0x03060100 or higher. Added functions
PySlice_Unpack() and PySlice_AdjustIndices().
2017-01-25 13:27:44 +02:00
Serhiy Storchaka
512c57cb72
Issue #27867 : Function PySlice_GetIndicesEx() is replaced with a macro if
...
Py_LIMITED_API is not set or set to the value between 0x03050400
and 0x03060000 (not including) or 0x03060100 or higher.
2017-01-25 13:25:52 +02:00
Serhiy Storchaka
b2a5be0763
Issue #27867 : Function PySlice_GetIndicesEx() is replaced with a macro if
...
Py_LIMITED_API is not set or set to the value between 0x03050400
and 0x03060000 (not including) or 0x03060100 or higher.
2017-01-25 13:23:05 +02:00
Serhiy Storchaka
78d9e58f20
Issues #29311 , #29289 : Fixed and improved docstrings for dict and OrderedDict
...
methods.
2017-01-25 00:30:04 +02:00
Serhiy Storchaka
067cbd02bf
Issue #29337 : Fixed possible BytesWarning when compare the code objects.
...
Warnings could be emitted at compile time.
2017-01-24 20:54:07 +02:00
Serhiy Storchaka
4102d25b7e
Issue #29337 : Fixed possible BytesWarning when compare the code objects.
...
Warnings could be emitted at compile time.
2017-01-24 20:52:43 +02:00
Serhiy Storchaka
713640c4c9
Issue #29337 : Fixed possible BytesWarning when compare the code objects.
...
Warnings could be emitted at compile time.
2017-01-24 20:49:26 +02:00
Victor Stinner
c3858bd7c6
Issue #29360 : _PyStack_AsDict() doesn't check kwnames
...
Remove two assertions which can fail on legit code. Keyword arguments are
checked later with better tests and raise a regular (TypeError) exception.
2017-01-24 15:05:30 +01:00
Martin Panter
91a8866dc1
Fix grammar in doc string, RST markup
2017-01-24 00:30:06 +00:00
Serhiy Storchaka
d1302c0154
Issue #28999 : Use Py_RETURN_NONE, Py_RETURN_TRUE and Py_RETURN_FALSE wherever
...
possible but Coccinelle couldn't find opportunity.
2017-01-23 10:23:58 +02:00
Serhiy Storchaka
228b12edcc
Issue #28999 : Use Py_RETURN_NONE, Py_RETURN_TRUE and Py_RETURN_FALSE wherever
...
possible. Patch is writen with Coccinelle.
2017-01-23 09:47:21 +02:00
Serhiy Storchaka
2a404b63d4
Issue #28769 : The result of PyUnicode_AsUTF8AndSize() and PyUnicode_AsUTF8()
...
is now of type "const char *" rather of "char *".
2017-01-22 23:07:07 +02:00
Serhiy Storchaka
7cf8bebb07
Issue #29331 : Simplified argument parsing in sorted() and list.sort().
2017-01-21 23:05:00 +02:00
Serhiy Storchaka
a70eaf21e3
Issue #29289 : Argument Clinic generates reasonable name for the parameter "default".
2017-01-19 19:38:13 +02:00
Serhiy Storchaka
48088ee9ba
Issue #29311 : Argument Clinic generates reasonable name for the parameter "default".
2017-01-19 19:00:30 +02:00
Serhiy Storchaka
41baebd8b9
Issue #20186 : Converted builtins enumerate() and reversed() to Argument Clinic.
...
Patch by Tal Einat.
2017-01-19 18:48:17 +02:00
Victor Stinner
91f0d4aa2f
Add a note explaining why dict_update() doesn't use METH_FASTCALL
...
Issue #29312 .
2017-01-19 12:45:06 +01:00
Victor Stinner
7dc6a5f50a
dict.get() and dict.setdefault() now use AC
...
Issue #29311 : dict.get() and dict.setdefault() methods now use Argument Clinic
to parse arguments. Their calling convention changes from METH_VARARGS to
METH_FASTCALL which avoids the creation of a temporary tuple.
The signature of docstrings is also enhanced. For example,
get(...)
becomes:
get(self, key, default=None, /)
2017-01-19 12:37:13 +01:00
Victor Stinner
06d34393c2
_PyStack_AsDict() now checks kwnames != NULL
...
Issue #29259 .
2017-01-18 18:06:32 +01:00
Victor Stinner
0a2e46835d
Cleanup _PyMethodDef_RawFastCallDict()
...
Issue #29259 : use a different case for METH_VARARGS and
METH_VARARGS|METH_KEYWORDS to avoid testing again flags to decide if keywords
should be checked or not.
2017-01-18 14:16:57 +01:00
Victor Stinner
a8cb515a29
Rephrase !PyErr_Occurred() comment: may=>can
...
Issue #29259 .
2017-01-18 14:12:51 +01:00
Victor Stinner
98ccba8344
_PyObject_FastCallKeywords() now checks !PyErr_Occurred()
...
Issue #29259 . All other functions calling functions start with the similar
assertion.
2017-01-18 14:06:38 +01:00
Victor Stinner
c89ef828cf
PyCFunction_Call() now calls _PyCFunction_FastCallDict()
...
Issue #29259 . We had 3 versions of similar code:
* PyCFunction_Call()
* _PyCFunction_FastCallDict()
* _PyCFunction_FastCallKeywords()
PyCFunction_Call() now calls _PyCFunction_FastCallDict() to factorize the code.
2017-01-18 14:04:37 +01:00
Victor Stinner
250e4b0063
Fix _PyMethodDef_RawFastCallDict() argument parsing
...
Issue #29259 :
* Move also the !PyErr_Occurred() assertion to the top, similar to
other functions.
* Fix also comment/error messages: the function was renamed to
_PyMethodDef_RawFastCallDict()
2017-01-18 14:01:12 +01:00
Victor Stinner
2a1b676d1f
_PyObject_FastCallKeywords() now checks the result
...
Issue ##27830, Issue #29259 .
2017-01-18 11:27:22 +01:00
Victor Stinner
c52572319c
Optimize methoddescr_call(): avoid temporary PyCFunction
...
Issue #29259 , #29263 . methoddescr_call() creates a PyCFunction object, call it
and the destroy it. Add a new _PyMethodDef_RawFastCallDict() method to avoid
the temporary PyCFunction object.
2017-01-18 10:38:09 +01:00
Victor Stinner
35ecebe165
Remove unused func parameter of _PyStack_UnpackDict()
...
Issue #29259 .
2017-01-18 10:31:46 +01:00
Victor Stinner
b05cbac052
Convert some OrderedDict methods to Argument Clinic
...
Issue #29289 . Convert methods:
* fromkeys() class method
* setdefault()
* popitem()
* move_to_end()
2017-01-17 03:46:13 +01:00
Victor Stinner
0c4a828cad
Run Argument Clinic: METH_VARARGS=>METH_FASTCALL
...
Issue #29286 . Run Argument Clinic to get the new faster METH_FASTCALL calling
convention for functions using "boring" positional arguments.
Manually fix _elementtree: _elementtree_XMLParser_doctype() must remain
consistent with the clinic code.
2017-01-17 02:21:47 +01:00
Victor Stinner
259f0e4437
Run Argument Clinic: METH_VARARGS=>METH_FASTCALL
...
Issue #29286 . Run Argument Clinic to get the new faster METH_FASTCALL calling
convention for functions using only positional arguments.
2017-01-17 01:35:17 +01:00
Victor Stinner
998c20962c
_PyStack_UnpackDict() now returns -1 on error
...
Issue #29286 . Change _PyStack_UnpackDict() prototype to be able to notify of
failure when args is NULL.
2017-01-17 01:57:29 +01:00
Victor Stinner
3e1fad6913
Rename _PyArg_ParseStack to _PyArg_ParseStackAndKeywords
...
Issue #29286 .
2017-01-17 01:29:01 +01:00
Victor Stinner
d526cfe546
type_prepare() now uses fast call (METH_FASTCALL)
2017-01-16 23:52:00 +01:00
Victor Stinner
69de71b255
Add _PyStack_AsTupleSlice() helper
2017-01-16 23:50:53 +01:00
Victor Stinner
7fc252adfb
Optimize _PyCFunction_FastCallKeywords()
...
Issue #29259 : Write fast path in _PyCFunction_FastCallKeywords() for
METH_FASTCALL, avoid the creation of a temporary dictionary for keyword
arguments.
Cleanup also _PyCFunction_FastCallDict():
* Don't dereference func before checking that it's not NULL
* Move code to raise the "no keyword argument" exception into a new
no_keyword_error label.
Update python-gdb.py for the change.
2017-01-16 17:18:53 +01:00
INADA Naoki
15f94596b6
Issue #20180 : forgot to update AC output.
2017-01-16 21:49:13 +09:00
INADA Naoki
3ae2056512
Issue #20180 : convert unicode methods to AC.
2017-01-16 20:41:20 +09:00
Martin Panter
446a498a63
Merge doc fixes from 3.6
2017-01-14 09:56:00 +00:00
Martin Panter
4659ddc433
Merge doc fixes from 3.5
2017-01-14 09:54:57 +00:00
Martin Panter
536d70ed33
Fix grammar, typos and markup in documentation and code comments
...
* Indent versionchanged at method level, not class level
* Mark up ``--help`` to avoid generating an en dash
* Use forward slash in Unix command line with a dollar sign ($) prompt
2017-01-14 08:23:08 +00:00
Martin Panter
94b39ceb73
Issue #1621 : Overflow should not be possible in listextend()
2017-01-14 06:30:37 +00:00
Serhiy Storchaka
617c7753ce
Issue #28969 : Fixed race condition in C implementation of functools.lru_cache.
...
KeyError could be raised when cached function with full cache was
simultaneously called from differen threads with the same uncached arguments.
2017-01-12 19:42:20 +02:00
Serhiy Storchaka
42e1ea9a10
Issue #28969 : Fixed race condition in C implementation of functools.lru_cache.
...
KeyError could be raised when cached function with full cache was
simultaneously called from differen threads with the same uncached arguments.
2017-01-12 19:12:21 +02:00
Serhiy Storchaka
67796521dd
Issue #28969 : Fixed race condition in C implementation of functools.lru_cache.
...
KeyError could be raised when cached function with full cache was
simultaneously called from differen threads with the same uncached arguments.
2017-01-12 18:34:33 +02:00
Victor Stinner
b915bc354e
Disable _PyStack_AsTuple() inlining
...
Issue #29234 : Inlining _PyStack_AsTuple() into callers increases their stack
consumption, Disable inlining to optimize the stack consumption.
Add _Py_NO_INLINE: use __attribute__((noinline)) of GCC and Clang.
It reduces the stack consumption, bytes per call, before => after:
test_python_call: 1040 => 976 (-64 B)
test_python_getitem: 976 => 912 (-64 B)
test_python_iterator: 1120 => 1056 (-64 B)
=> total: 3136 => 2944 (- 192 B)
2017-01-11 01:07:03 +01:00
Victor Stinner
434723f94c
call_method() now uses _PyObject_FastCall()
...
Issue #29233 : Replace the inefficient _PyObject_VaCallFunctionObjArgs() with
_PyObject_FastCall() in call_method() and call_maybe().
Only a few functions call call_method() and call it with a fixed number of
arguments. Avoid the complex and expensive _PyObject_VaCallFunctionObjArgs()
function, replace it with an array allocated on the stack with the exact number
of argumlents.
It reduces the stack consumption, bytes per call, before => after:
test_python_call: 1168 => 1152 (-16 B)
test_python_getitem: 1344 => 1008 (-336 B)
test_python_iterator: 1568 => 1232 (-336 B)
Remove the _PyObject_VaCallFunctionObjArgs() function which became useless.
Rename it to object_vacall() and make it private.
2017-01-11 00:07:40 +01:00
Xiang Zhang
7a4da324dc
Issue #29145 : Merge 3.6.
2017-01-10 10:56:38 +08:00
Xiang Zhang
95403d74d7
Issue #29145 : Merge 3.5.
2017-01-10 10:54:19 +08:00
Xiang Zhang
b0541f4cdf
Issue #29145 : Fix overflow checks in str.replace() and str.join().
...
Based on patch by Martin Panter.
2017-01-10 10:52:00 +08:00
INADA Naoki
7ed28a8914
Merge 3.6
2017-01-06 17:44:43 +09:00
INADA Naoki
a634e23209
Issue #29159 : Fix regression in bytes(x) when x.__index__() raises Exception.
2017-01-06 17:32:01 +09:00
Victor Stinner
6f7c0ae46d
Issue #28839 : Optimize function_call()
...
function_call() now simply calls _PyFunction_FastCallDict().
_PyFunction_FastCallDict() is more efficient: it contains fast paths for the
common case (optimized code object and no keyword argument).
2017-01-03 01:58:17 +01:00
Stefan Krah
089a062da4
Merge 3.6.
2016-12-30 12:24:59 +01:00
Stefan Krah
a50006c977
Merge 3.5.
2016-12-30 12:24:23 +01:00
Stefan Krah
195319e6bb
Issue #29111 : Fix memoryview signature.
2016-12-30 12:23:35 +01:00
Serhiy Storchaka
c9ad8b7a23
Issue #29073 : bytearray formatting no longer truncates on first null byte.
2016-12-28 09:54:22 +02:00
Antoine Pitrou
c06ae208eb
Issue #28427 : old keys should not remove new values from
...
WeakValueDictionary when collecting from another thread.
2016-12-27 14:34:54 +01:00
Antoine Pitrou
d741ed492f
Issue #28427 : old keys should not remove new values from
...
WeakValueDictionary when collecting from another thread.
2016-12-27 14:23:43 +01:00
Antoine Pitrou
e10ca3a0fe
Issue #28427 : old keys should not remove new values from
...
WeakValueDictionary when collecting from another thread.
2016-12-27 14:19:20 +01:00
INADA Naoki
5a625d0aa6
Issue #29049 : Call _PyObject_GC_TRACK() lazily when calling Python function.
...
Calling function is up to 5% faster.
2016-12-24 20:19:08 +09:00
Xiang Zhang
62497d52d9
Issue #29044 : Merge 3.6.
2016-12-22 15:31:55 +08:00
Xiang Zhang
437a5d2c25
Issue #29044 : Merge 3.5.
2016-12-22 15:31:22 +08:00
Xiang Zhang
ea1cf87030
Issue #29044 : Fix a use-after-free in string '%c' formatter.
2016-12-22 15:30:47 +08:00
Xiang Zhang
b211068f5c
Issue #28822 : Adjust indices handling of PyUnicode_FindChar().
2016-12-20 22:52:33 +08:00
INADA Naoki
6165d55f13
Issue #28147 : Fix a memory leak in split-table dictionaries
...
setattr() must not convert combined table into split table.
2016-12-20 09:54:24 +09:00
Serhiy Storchaka
dd1da7f74a
Issue #28927 : bytes.fromhex() and bytearray.fromhex() now ignore all ASCII
...
whitespace, not only spaces. Patch by Robert Xiao.
2016-12-19 18:51:37 +02:00
Serhiy Storchaka
9d16b616d5
Issue #29000 : Fixed bytes formatting of octals with zero padding in alternate
...
form.
2016-12-17 22:15:10 +02:00
Serhiy Storchaka
025f8953f1
Issue #29000 : Fixed bytes formatting of octals with zero padding in alternate
...
form.
2016-12-17 22:13:05 +02:00
Serhiy Storchaka
b1a1619bf0
Issue #29000 : Fixed bytes formatting of octals with zero padding in alternate
...
form.
2016-12-17 21:48:03 +02:00
Serhiy Storchaka
5bb8b9134b
Issue #18896 : Python function can now have more than 255 parameters.
...
collections.namedtuple() now supports tuples with more than 255 elements.
2016-12-16 19:19:02 +02:00
Serhiy Storchaka
5ab81d787f
Issue #28959 : Added private macro PyDict_GET_SIZE for retrieving the size of dict.
2016-12-16 16:18:57 +02:00
Xavier de Gaye
31eaf49ed9
Merge 3.6.
2016-12-15 21:01:52 +01:00
Xavier de Gaye
76febd0792
Issue #26919 : On Android, operating system data is now always encoded/decoded
...
to/from UTF-8, instead of the locale encoding to avoid inconsistencies with
os.fsencode() and os.fsdecode() which are already using UTF-8.
2016-12-15 20:59:58 +01:00
Victor Stinner
5cc70c9935
Merge 3.6
2016-12-15 17:23:24 +01:00
Victor Stinner
3d3f264849
Fix a memory leak in split-table dictionaries
...
Issue #28147 : Fix a memory leak in split-table dictionaries: setattr() must not
convert combined table into split table.
Patch written by INADA Naoki.
2016-12-15 17:21:23 +01:00
Victor Stinner
944dbc6431
Use _PyDict_NewPresized() in _PyStack_AsDict()
...
Issue #27810 .
2016-12-15 16:59:40 +01:00
Victor Stinner
bc08ab4598
Add _PY_FASTCALL_SMALL_STACK constant
...
Issue #28870 : Add a new _PY_FASTCALL_SMALL_STACK constant, size of "small
stacks" allocated on the C stack to pass positional arguments to
_PyObject_FastCall().
_PyObject_Call_Prepend() now uses a small stack of 5 arguments (40 bytes)
instead of 8 (64 bytes), since it is modified to use _PY_FASTCALL_SMALL_STACK.
2016-12-15 12:40:53 +01:00
Victor Stinner
d1e35dd9ee
Fix _PyObject_CallFunctionVa(), use the small stack
...
Issue #28915 . Oops, I disabled the small stack to test both code paths. It's
now fixed.
2016-12-15 12:36:50 +01:00
Serhiy Storchaka
bdfc5ff17e
Merge from 3.6.
2016-12-14 19:56:53 +02:00
Serhiy Storchaka
386072ebe0
Merge from 3.6.
2016-12-14 19:54:38 +02:00
Serhiy Storchaka
49010ee323
Revert changeset 1f31bf3f76f5 (issue5322) except tests.
2016-12-14 19:52:17 +02:00
Yury Selivanov
f2392133eb
Issue #26110 : Add LOAD_METHOD/CALL_METHOD opcodes.
...
Special thanks to INADA Naoki for pushing the patch through
the last mile, Serhiy Storchaka for reviewing the code, and to
Victor Stinner for suggesting the idea (originally implemented
in the PyPy project).
2016-12-13 19:03:51 -05:00
Martin Panter
9bcaa37e1c
Issue #28820 : Merge typo fixes from 3.6
2016-12-10 05:39:12 +00:00
Martin Panter
186b204997
Fix typos in comment and documentation
2016-12-10 05:32:55 +00:00
Victor Stinner
59a73276e9
Backed out changeset 99c34e47348b
...
The change broke test_gdb.
2016-12-09 18:51:13 +01:00
Victor Stinner
0ca246c5e7
Inline PyEval_EvalFrameEx() in callers
...
The PEP 523 modified PyEval_EvalFrameEx(): it's now an indirection to
interp->eval_frame().
Inline the call in performance critical code. Leave PyEval_EvalFrame()
unchanged, this function is only kept for backward compatibility.
2016-12-09 17:12:17 +01:00
Victor Stinner
14e6d09547
Remove useless variable initialization
...
Don't initialize variables which are not used before they are assigned.
2016-12-09 17:08:59 +01:00
Victor Stinner
5abaa2b139
Use PyObject_CallFunctionObjArgs()
...
Issue #28915 : Replace PyObject_CallFunction() with
PyObject_CallFunctionObjArgs() when the format string was only made of "O"
formats, PyObject* arguments.
PyObject_CallFunctionObjArgs() avoids the creation of a temporary tuple and
doesn't have to parse a format string.
2016-12-09 16:22:32 +01:00
Victor Stinner
887b4307b6
Use _PyObject_FastCallVa() in type slots
...
Issue #28915 : Replace Py_VaBuildValue()+PyObject_Call() with
_PyObject_FastCallVa() to avoid the creation of temporary tuple.
2016-12-09 00:41:46 +01:00
Victor Stinner
7f39c0ccfc
Add _PyObject_VaCallFunctionObjArgs() private function
...
Issue #28915 : Similar to _PyObject_CallFunctionObjArgs() but use va_list to
pass arguments.
2016-12-09 00:40:33 +01:00
Victor Stinner
7e42541d08
Use _PyObject_CallMethodIdObjArgs()
...
Issue #28915 : Replace _PyObject_CallMethodId() with
_PyObject_CallMethodIdObjArgs() when the format string only use the format 'O'
for objects, like "(O)".
_PyObject_CallMethodIdObjArgs() avoids the code to parse a format string and
avoids the creation of a temporary tuple.
2016-12-09 00:36:19 +01:00