Victor Stinner [Fri, 19 Aug 2016 16:17:37 +0000 (18:17 +0200)]
Issue #27128: Cleanup slot_sq_item()
* Invert condition of test to avoid levels of indentation
* Remove useless Py_XDECREF(args) in the error block
* Replace Py_XDECREF(func) with Py_DECREF(func) in the error block: func cannot
be NULL when reaching the error block
Victor Stinner [Fri, 19 Aug 2016 16:05:37 +0000 (18:05 +0200)]
call_method() and call_maybe() now use fast call
Issue #27128. The call_method() and call_maybe() functions of typeobject.c now
use fast call for empty format string to avoid the creation of a temporary
empty tuple.
Victor Stinner [Fri, 19 Aug 2016 15:04:54 +0000 (17:04 +0200)]
Avoid call_function_tail() for empty format str
Issue #27128, PyObject_CallFunction(), _PyObject_FastCall() and callmethod():
if the format string of parameters is empty, avoid the creation of an empty
tuple: call _PyObject_FastCall() without parameters.
Victor Stinner [Fri, 19 Aug 2016 14:50:49 +0000 (16:50 +0200)]
Cleanup call_function_tail()
Make call_function_tail() less weird: don't decrement args reference counter,
the caller is now responsible to do that. The caller now also checks if args is
NULL.
Victor Stinner [Fri, 19 Aug 2016 14:42:42 +0000 (16:42 +0200)]
PyEval_CallObjectWithKeywords() uses fast call
Issue #27128: Modify PyEval_CallObjectWithKeywords() to use
_PyObject_FastCall() when args==NULL and kw==NULL. It avoids the creation of a
temporary empty tuple for positional arguments.
Victor Stinner [Fri, 19 Aug 2016 14:11:43 +0000 (16:11 +0200)]
Add _PyObject_FastCall()
Issue #27128: Add _PyObject_FastCall(), a new calling convention avoiding a
temporary tuple to pass positional parameters in most cases, but create a
temporary tuple if needed (ex: for the tp_call slot).
The API is prepared to support keyword parameters, but the full implementation
will come later (_PyFunction_FastCall() doesn't support keyword parameters
yet).
Add also:
* _PyStack_AsTuple() helper function: convert a "stack" of parameters to
a tuple.
* _PyCFunction_FastCall(): fast call implementation for C functions
* _PyFunction_FastCall(): fast call implementation for Python functions
Guido van Rossum [Thu, 18 Aug 2016 16:22:23 +0000 (09:22 -0700)]
Anti-registration of various ABC methods.
- Issue #25958: Support "anti-registration" of special methods from
various ABCs, like __hash__, __iter__ or __len__. All these (and
several more) can be set to None in an implementation class and the
behavior will be as if the method is not defined at all.
(Previously, this mechanism existed only for __hash__, to make
mutable classes unhashable.) Code contributed by Andrew Barnert and
Ivan Levkivskyi.
Victor Stinner [Thu, 18 Aug 2016 16:13:10 +0000 (18:13 +0200)]
Fix SystemError in "raise" statement
Issue #27558: Fix a SystemError in the implementation of "raise" statement.
In a brand new thread, raise a RuntimeError since there is no active
exception to reraise.
Ned Deily [Wed, 17 Aug 2016 21:18:33 +0000 (17:18 -0400)]
Issue #27594: Prevent assertion error when running test_ast with coverage
enabled: ensure code object has a valid first line number.
Patch suggested by Ivan Levkivskyi.
Victor Stinner [Wed, 17 Aug 2016 14:12:16 +0000 (16:12 +0200)]
regrtest: add a summary of the summary, "Result: xxx"
It's sometimes hard to check quickly if tests succeeded, failed or something
bad happened. I added a final "Result: xxx" line which summarizes all outputs
into a single line, written at the end (it should always be the last line of
the output).
Victor Stinner [Wed, 17 Aug 2016 12:00:58 +0000 (14:00 +0200)]
Issue #27726: Fix "make tags"
* Memove -t option of ctags. The option was kept for backward compatibility,
but it was completly removed recently. Patch written by Stéphane Wirtel.
* Set locale to C to call sort. vim expects that the tags file is sorted using
english collation, so it fails if the locale is french for example. Use
LC_ALL=C to force english sorting order. .
Victor Stinner [Wed, 17 Aug 2016 11:58:12 +0000 (13:58 +0200)]
Fix "make tags": set locale to C to call sort
vim expects that the tags file is sorted using english collation, so it fails
if the locale is french for example. Use LC_ALL=C to force english sorting
order. Issue #27726.
Victor Stinner [Wed, 17 Aug 2016 10:29:58 +0000 (12:29 +0200)]
script_helper: kill the subprocess on error
If Popen.communicate() raises an exception, kill the child process to not leave
a running child process in background and maybe create a zombi process.
This change fixes a ResourceWarning in Python 3.6 when unit tests are
interrupted by CTRL+c.
Victor Stinner [Tue, 16 Aug 2016 21:39:42 +0000 (23:39 +0200)]
Use Py_ssize_t in _PyEval_EvalCodeWithName()
Issue #27128, #18295: replace int type with Py_ssize_t for index variables used
for positional arguments. It should help to avoid integer overflow and help to
emit better machine code for "i++" (no trap needed for overflow).
Victor Stinner [Tue, 16 Aug 2016 21:40:29 +0000 (23:40 +0200)]
Issue #27128: Cleanup _PyEval_EvalCodeWithName()
* Add comments
* Add empty lines for readability
* PEP 7 style for if block
* Remove useless assert(globals != NULL); (globals is tested a few lines
before)
Modify py_getrandom() to not call PyErr_CheckSignals() if raise is zero.
_PyRandom_Init() is called very early in the Python initialization, so it's
safer to not call PyErr_CheckSignals().
Victor Stinner [Tue, 16 Aug 2016 13:23:58 +0000 (15:23 +0200)]
Issue #27776: Cleanup random.c
* Add pyurandom() helper function to factorize the code
* don't call Py_FatalError() in helper functions, but only in _PyRandom_Init()
if pyurandom() failed, to uniformize the code