Commit Graph

6083 Commits

Author SHA1 Message Date
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