Commit Graph

5469 Commits

Author SHA1 Message Date
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 29d39cc8f5 Add _PyArg_NoStackKeywords() helper function
Issue #29286. Similar to _PyArg_NoKeywords(), but expects a tuple of keyword
names, instead of a dict.
2017-01-17 01:40:01 +01:00
Victor Stinner 6518a93cb1 Add _PyArg_ParseStack() helper function
Issue #29286. Function similar to PyArg_ParseTuple(), but uses a C array of
PyObject* to pass arguments. Don't support the compatibility mode.
2017-01-17 01:29:49 +01:00
Victor Stinner 3e1fad6913 Rename _PyArg_ParseStack to _PyArg_ParseStackAndKeywords
Issue #29286.
2017-01-17 01:29:01 +01:00
Victor Stinner c0083fc47d Rename keywords to kwargs in getargs.c
Issue #29029. Patch written by Serhiy Storchaka.
2017-01-17 00:37:42 +01:00
Victor Stinner 80ab22fa2c Cleanup getargs.c
Factorize argument checks in:

* vgetargskeywordsfast()
* vgetargskeywordsfast_impl()
2017-01-16 23:16:47 +01:00
Victor Stinner 773dc6dd06 __build_class__() builtin uses METH_FASTCALL 2017-01-16 23:46:26 +01:00
INADA Naoki 015bce64b3 Issue #26110: Add document for LOAD_METHOD and CALL_METHOD opcode.
Changed stack layout bit for "easy to explain."
2017-01-16 17:23:30 +09:00
Victor Stinner 231d1f3439 _PyEval_EvalCodeWithName(): remove redundant check
Replace the runtime check with an assertion (just in case).
2017-01-11 02:12:06 +01:00
Victor Stinner 415c5107be Inline call_function()
Issue #29227: Inline call_function() into _PyEval_EvalFrameDefault() using
Py_LOCAL_INLINE to reduce the stack consumption.

It reduces the stack consumption, bytes per call, before => after:

test_python_call: 1152 => 1040 (-112 B)
test_python_getitem: 1008 => 976 (-32 B)
test_python_iterator: 1232 => 1120 (-112 B)

=> total: 3392 => 3136 (- 256 B)
2017-01-11 00:54:57 +01:00
Victor Stinner 035ba5da3e Issue #29157: Prefer getrandom() over getentropy()
Copy and then adapt Python/random.c from default branch. Difference between 3.5
and default branches:

* Python 3.5 only uses getrandom() in non-blocking mode: flags=GRND_NONBLOCK
* If getrandom() fails with EAGAIN: py_getrandom() immediately fails and
  remembers that getrandom() doesn't work.
* Python 3.5 has no _PyOS_URandomNonblock() function: _PyOS_URandom()
  works in non-blocking mode on Python 3.5
2017-01-09 11:18:53 +01:00
Victor Stinner ff558f5aba Issue #29157: Prefer getrandom() over getentropy()
* dev_urandom() now calls py_getentropy(). Prepare the fallback to support
  getentropy() failure and falls back on reading from /dev/urandom.
* Simplify dev_urandom(). pyurandom() is now responsible to call getentropy()
  or getrandom(). Enhance also dev_urandom() and pyurandom() documentation.
* getrandom() is now preferred over getentropy(). The glibc 2.24 now implements
  getentropy() on Linux using the getrandom() syscall.  But getentropy()
  doesn't support non-blocking mode. Since getrandom() is tried first, it's not
  more needed to explicitly exclude getentropy() on Solaris. Replace:
  "if defined(HAVE_GETENTROPY) && !defined(sun)"
  with "if defined(HAVE_GETENTROPY)"
* Enhance py_getrandom() documentation. py_getentropy() now supports ENOSYS,
  EPERM & EINTR
2017-01-07 00:07:45 +01:00
Victor Stinner b27df6faa5 Issue #29157: enhance py_getrandom() documentation 2017-01-06 11:39:15 +01:00
Victor Stinner de2f1ea124 py_getentropy() now supports ENOSYS, EPERM & EINTR
Issue #29157.
2017-01-06 11:33:18 +01:00
Victor Stinner 2f7964393d Issue #29157: getrandom() is now preferred over getentropy()
The glibc now implements getentropy() on Linux using the getrandom() syscall.
But getentropy() doesn't support non-blocking mode.

Since getrandom() is tried first, it's not more needed to explicitly exclude
getentropy() on Solaris. Replace:

    if defined(HAVE_GETENTROPY) && !defined(sun)

with

    if defined(HAVE_GETENTROPY)
2017-01-06 11:26:01 +01:00
Victor Stinner a49a2078e8 Issue #29157: Simplify dev_urandom()
pyurandom() is now responsible to call getentropy() or getrandom().

Enhance also dev_urandom() and pyurandom() documentation.
2017-01-06 11:17:52 +01:00
Victor Stinner dcdb60e4b3 Issue #29157: dev_urandom() now calls py_getentropy()
Prepare the fallback to support getentropy() failure and falls back on reading
from /dev/urandom.
2017-01-06 11:16:20 +01:00
Victor Stinner 865a0f621f Optimize _PyFunction_FastCallDict() when kwargs is {}
Issue #28839: Optimize _PyFunction_FastCallDict() when kwargs is an empty
dictionary, avoid the creation of an useless empty tuple.
2017-01-03 02:01:42 +01:00
Benjamin Peterson 646bf754e3 merge 3.6 (#29057) 2017-01-01 22:30:35 -06:00
Benjamin Peterson 46322587ec merge 3.5 (#29057) 2017-01-01 22:30:26 -06:00
Benjamin Peterson 493ac1bbe0 only include sys/random.h if it seems like it might have something useful (#29057) 2017-01-01 22:29:36 -06:00
Benjamin Peterson 6784be1d00 merge 3.6 2017-01-01 22:08:51 -06:00
Benjamin Peterson 5848e72ee1 merge 3.5 2017-01-01 22:08:44 -06:00
Benjamin Peterson 4365833d11 merge 3.4 2017-01-01 22:08:33 -06:00
Benjamin Peterson b6e2142b0c merge 3.3 2017-01-01 22:07:37 -06:00
Benjamin Peterson e527dd34bc ring in 2017 for Python 2017-01-01 22:04:13 -06:00
INADA Naoki 9c15776fac Issue #29049: Remove unnecessary Py_DECREF 2016-12-26 18:52:46 +09:00
INADA Naoki 6a3cedf8dd Issue #29049: Fix refleak introduced by f5eb0c4f5d37. 2016-12-26 18:01:46 +09: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
Benjamin Peterson 38f225dd48 merge 3.6 (#28932) 2016-12-19 23:55:24 -08:00
Benjamin Peterson b0eb986eb2 merge 3.5 (#28932) 2016-12-19 23:54:57 -08:00
Benjamin Peterson fb2ae15c67 add a specific configure check for sys/random.h (closes #28932) 2016-12-19 23:54:25 -08:00
Martin Panter b46edf35f3 Issue #25677: Merge SyntaxError caret positioning from 3.6 2016-12-19 06:46:12 +00:00
Martin Panter 619555d77b Issue #25677: Merge SyntaxError caret positioning from 3.5 2016-12-19 06:46:01 +00: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 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
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
Steve Dower 21e033466b Issue #28896: Disable WindowsRegistryFinder by default. 2016-12-12 11:19:03 -08:00
Steve Dower 10beb3cfef Issue #28896: Disable WindowsRegistryFinder by default. 2016-12-12 11:17:59 -08:00
Serhiy Storchaka 0f6373c34f Issue #28739: f-string expressions no longer accepted as docstrings and
by ast.literal_eval() even if they do not include subexpressions.
2016-12-11 19:39:36 +02:00
Serhiy Storchaka 4cc30ae313 Issue #28739: f-string expressions no longer accepted as docstrings and
by ast.literal_eval() even if they do not include subexpressions.
2016-12-11 19:37:19 +02:00
Serhiy Storchaka 26817a8490 Issue #28512: Fixed setting the offset attribute of SyntaxError by
PyErr_SyntaxLocationEx() and PyErr_SyntaxLocationObject().
2016-12-11 14:44:21 +02:00
Serhiy Storchaka 8114f21668 Issue #28512: Fixed setting the offset attribute of SyntaxError by
PyErr_SyntaxLocationEx() and PyErr_SyntaxLocationObject().
2016-12-11 14:43:18 +02:00
Serhiy Storchaka 8b58339eb2 Issue #28512: Fixed setting the offset attribute of SyntaxError by
PyErr_SyntaxLocationEx() and PyErr_SyntaxLocationObject().
2016-12-11 14:39:01 +02:00
Martin Panter ca3263c50c Issue #25677: Correct syntax error caret for indented blocks.
Based on patch by Michael Layzell.
2016-12-11 00:18:36 +00:00
Victor Stinner 59a73276e9 Backed out changeset 99c34e47348b
The change broke test_gdb.
2016-12-09 18:51:13 +01:00
Victor Stinner 22f18750a5 Issue #20185: Convert _warnings.warn() to Argument Clinic
Fix warn_explicit(): interpret source=None as source=NULL.
2016-12-09 18:08:18 +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 55ba38a480 Use _PyObject_CallMethodIdObjArgs()
Issue #28915: Replace _PyObject_CallMethodId() with
_PyObject_CallMethodIdObjArgs() in various modules when the format string was
only made of "O" formats, PyObject* arguments.

_PyObject_CallMethodIdObjArgs() avoids the creation of a temporary tuple and
doesn't have to parse a format string.
2016-12-09 16:09:30 +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
Victor Stinner e9abde4642 Add _Py_VaBuildStack() function
Issue #28915: Similar to Py_VaBuildValue(), but work on a C array of PyObject*,
instead of creating a tuple.
2016-12-09 00:29:49 +01:00
Victor Stinner b551b6c9f0 modsupport: replace int with Py_ssize_t
Issue #28915: Py_ssize_t type is better for indexes. The compiler might emit
more efficient code for i++. Py_ssize_t is the type of a PyTuple index for
example.

Replace also "int endchar" with "char endchar".
2016-12-09 00:27:22 +01:00
Victor Stinner e9aae2dcc5 modsupport: replace int with Py_ssize_t
Issue #28915.
2016-12-09 00:24:47 +01:00
Victor Stinner f17c3de263 Use _PyObject_CallNoArg()
Replace:
    PyObject_CallFunctionObjArgs(callable, NULL)
with:
    _PyObject_CallNoArg(callable)
2016-12-06 18:46:19 +01:00
Victor Stinner a5ed5f000a Use _PyObject_CallNoArg()
Replace:
    PyObject_CallObject(callable, NULL)
with:
    _PyObject_CallNoArg(callable)
2016-12-06 18:45:50 +01:00
Victor Stinner 2d0eb65f45 Uniformize argument names of "call" functions
Issue #28838: Rename parameters of the "calls" functions of the Python C API.

* Rename 'callable_object' and 'func' to 'callable': any Python callable object
  is accepted, not only Python functions
* Rename 'method' and 'nameid' to 'name' (method name)
* Rename 'o' to 'obj'
* Move, fix and update documentation of PyObject_CallXXX() functions
  in abstract.h
* Update also the documentaton of the C API (update parameter names)
2016-12-06 16:27:24 +01:00
Victor Stinner 7bfb42d5b7 Issue #28858: Remove _PyObject_CallArg1() macro
Replace
   _PyObject_CallArg1(func, arg)
with
   PyObject_CallFunctionObjArgs(func, arg, NULL)

Using the _PyObject_CallArg1() macro increases the usage of the C stack, which
was unexpected and unwanted. PyObject_CallFunctionObjArgs() doesn't have this
issue.
2016-12-05 17:04:32 +01:00
Nick Coghlan d77e5b7211 Merge #23722 from 3.6 2016-12-05 16:59:22 +10:00
Nick Coghlan 19d246745d Issue #23722: improve __classcell__ compatibility
Handling zero-argument super() in __init_subclass__ and
__set_name__ involved moving __class__ initialisation to
type.__new__. This requires cooperation from custom
metaclasses to ensure that the new __classcell__ entry
is passed along appropriately.

The initial implementation of that change resulted in abruptly
broken zero-argument super() support in metaclasses that didn't
adhere to the new requirements (such as Django's metaclass for
Model definitions).

The updated approach adopted here instead emits a deprecation
warning for those cases, and makes them work the same way they
did in Python 3.5.

This patch also improves the related class machinery documentation
to cover these details and to include more reader-friendly
cross-references and index entries.
2016-12-05 16:47:55 +10:00
Victor Stinner de4ae3d486 Backed out changeset b9c9691c72c5
Issue #28858: The change b9c9691c72c5 introduced a regression. It seems like
_PyObject_CallArg1() uses more stack memory than
PyObject_CallFunctionObjArgs().
2016-12-04 22:59:09 +01:00
Victor Stinner d6958ac6c0 Add sys.getandroidapilevel()
Issue #28740: Add sys.getandroidapilevel(): return the build time
API version of Android as an integer.

Function only available on Android.
2016-12-02 01:13:46 +01:00
Victor Stinner 4778eab1f2 Replace PyObject_CallFunction() with fastcall
Replace
    PyObject_CallFunction(func, "O", arg)
and
    PyObject_CallFunction(func, "O", arg, NULL)
with
    _PyObject_CallArg1(func, arg)

Replace
    PyObject_CallFunction(func, NULL)
with
    _PyObject_CallNoArg(func)

_PyObject_CallNoArg() and _PyObject_CallArg1() are simpler and don't allocate
memory on the C stack.
2016-12-01 14:51:04 +01:00
Victor Stinner 842cfff321 WITH_CLEANUP_START uses fastcall
Modify WITH_CLEANUP_START bytecode: replace PyObject_CallFunctionObjArgs() with
_PyObject_FastCall().
2016-12-01 14:45:31 +01:00
Victor Stinner 27580c1fb5 Replace PyObject_CallFunctionObjArgs() with fastcall
* PyObject_CallFunctionObjArgs(func, NULL) => _PyObject_CallNoArg(func)
* PyObject_CallFunctionObjArgs(func, arg, NULL) => _PyObject_CallArg1(func, arg)

PyObject_CallFunctionObjArgs() allocates 40 bytes on the C stack and requires
extra work to "parse" C arguments to build a C array of PyObject*.

_PyObject_CallNoArg() and _PyObject_CallArg1() are simpler and don't allocate
memory on the C stack.

This change is part of the fastcall project. The change on listsort() is
related to the issue #23507.
2016-12-01 14:43:22 +01:00
Serhiy Storchaka 3d85fae91f Issue #28823: Simplified compiling with opcode BUILD_MAP_UNPACK. 2016-11-28 20:56:37 +02:00
Victor Stinner b69ee8c386 call_function(): document PyMethod optimization 2016-11-28 18:32:31 +01:00
Victor Stinner 048afd98b3 Remove CALL_PROFILE special build
Issue #28799:

* Remove the PyEval_GetCallStats() function.
* Deprecate the untested and undocumented sys.callstats() function.
* Remove the CALL_PROFILE special build

Use the sys.setprofile() function, cProfile or profile module to profile
function calls.
2016-11-28 11:59:04 +01:00
Serhiy Storchaka 214678e44b Issue #12844: More than 255 arguments can now be passed to a function. 2016-11-28 10:52:05 +02:00
Victor Stinner ed6de7345e Merge 3.6 2016-11-24 22:33:49 +01:00
Victor Stinner f7d199ff32 Fix _PyGen_yf()
Issue #28782: Fix a bug in the implementation ``yield from`` when checking
if the next instruction is YIELD_FROM. Regression introduced by WORDCODE
(issue #26647).

Reviewed by Serhiy Storchaka and Yury Selivanov.
2016-11-24 22:33:01 +01:00
Raymond Hettinger 3fa28fd075 merge 2016-11-22 11:50:56 -08:00
Raymond Hettinger 64e2f9ac86 Issue #27100: Fix ref leak 2016-11-22 11:50:40 -08:00
Raymond Hettinger 9af740b99a merge 2016-11-21 17:24:58 -08:00
Raymond Hettinger a3fec1543d Issue #27100: With statement reports missing __enter__ before __exit__. (Contributed by Jonathan Ellington.) 2016-11-21 17:24:23 -08:00
Serhiy Storchaka b57d9eac41 Issue #28748: Private variable _Py_PackageContext is now of type "const char *"
rather of "char *".
2016-11-21 10:25:54 +02:00
Serhiy Storchaka 460bd0d284 Issue #19569: Compiler warnings are now emitted if use most of deprecated
functions.
2016-11-20 12:16:46 +02:00
Serhiy Storchaka 85b0f5beb1 Added the const qualifier to char* variables that refer to readonly internal
UTF-8 represenatation of Unicode objects.
2016-11-20 10:16:47 +02:00
Serhiy Storchaka a98c4a984b Replaced outdated macros _PyUnicode_AsString and _PyUnicode_AsStringAndSize
with PyUnicode_AsUTF8 and PyUnicode_AsUTF8AndSize.
2016-11-20 09:13:40 +02:00
Serhiy Storchaka 06515833fe Replaced outdated macros _PyUnicode_AsString and _PyUnicode_AsStringAndSize
with PyUnicode_AsUTF8 and PyUnicode_AsUTF8AndSize.
2016-11-20 09:13:07 +02:00
Serhiy Storchaka f6f1591808 Issue #28715: Added error checks for PyUnicode_AsUTF8(). 2016-11-20 08:48:30 +02:00
Serhiy Storchaka e20973926a Issue #28715: Added error checks for PyUnicode_AsUTF8(). 2016-11-20 08:48:07 +02:00
Serhiy Storchaka 144f77a981 Issue #28715: Added error checks for PyUnicode_AsUTF8(). 2016-11-20 08:47:21 +02:00
Xavier de Gaye 002d61fea7 Issue #28746: Merge 3.6 2016-11-19 16:20:31 +01:00
Xavier de Gaye ec5d3cd533 Issue #28746: Fix the set_inheritable() file descriptor method on platforms
that do not have the ioctl FIOCLEX and FIONCLEX commands
2016-11-19 16:19:29 +01:00
Serhiy Storchaka 29a5447360 Issue #28701: Replace _PyUnicode_CompareWithId with _PyUnicode_EqualToASCIIId.
The latter function is more readable, faster and doesn't raise exceptions.

Based on patch by Xiang Zhang.
2016-11-16 15:41:31 +02:00
Serhiy Storchaka fab6acd9f5 Issue #28701: Replace _PyUnicode_CompareWithId with _PyUnicode_EqualToASCIIId.
The latter function is more readable, faster and doesn't raise exceptions.

Based on patch by Xiang Zhang.
2016-11-16 15:41:11 +02:00
Serhiy Storchaka f5894dd646 Issue #28701: Replace _PyUnicode_CompareWithId with _PyUnicode_EqualToASCIIId.
The latter function is more readable, faster and doesn't raise exceptions.

Based on patch by Xiang Zhang.
2016-11-16 15:40:39 +02:00
Serhiy Storchaka 1a73bf365e Issue #28701: Replace PyUnicode_CompareWithASCIIString with _PyUnicode_EqualToASCIIString.
The latter function is more readable, faster and doesn't raise exceptions.
2016-11-16 10:19:57 +02:00
Serhiy Storchaka 3b73ea1278 Issue #28701: Replace PyUnicode_CompareWithASCIIString with _PyUnicode_EqualToASCIIString.
The latter function is more readable, faster and doesn't raise exceptions.
2016-11-16 10:19:20 +02:00
Serhiy Storchaka f4934ea77d Issue #28701: Replace PyUnicode_CompareWithASCIIString with _PyUnicode_EqualToASCIIString.
The latter function is more readable, faster and doesn't raise exceptions.
2016-11-16 10:17:58 +02:00
Xavier de Gaye afa94a5a3e Issue #26920: Merge 3.6 2016-11-16 07:26:10 +01:00
Xavier de Gaye b445ad7b04 Issue #26920: Fix not getting the locale's charset upon initializing the interpreter,
on platforms that do not have langinfo
2016-11-16 07:24:20 +01:00
Victor Stinner d5f599a392 Merge 3.6 2016-11-15 09:12:36 +01:00
Victor Stinner f9cca365c7 Fix warn_invalid_escape_sequence()
Issue #28691: Fix warn_invalid_escape_sequence(): handle correctly
DeprecationWarning raised as an exception. First clear the current exception to
replace the DeprecationWarning exception with a SyntaxError exception.

Unit test written by Serhiy Storchaka.
2016-11-15 09:12:10 +01:00
Ned Deily cf767ab4da Issue #28676: merge from 3.6 2016-11-12 16:39:52 -05:00
Ned Deily 7d895d3c37 Issue #28676: merge from 3.5 2016-11-12 16:38:03 -05:00
Ned Deily 7ae4112649 Issue #28676: Prevent missing 'getentropy' declaration warning on macOS.
Patch by Gareth Rees.
2016-11-12 16:35:48 -05:00
Raymond Hettinger c32f9db846 Issue #28665: Use macro form of PyCell_GET/SET 2016-11-12 04:10:35 -05:00
Raymond Hettinger b2b154374d merge 2016-11-11 04:32:11 -08:00
Raymond Hettinger 13527123a1 Issue #28665: Harmonize STORE_DEREF with STORE_FAST and LOAD_DEREF giving a 40% speedup. 2016-11-11 04:31:18 -08:00
Victor Stinner c6944e7edc Issue #28618: Make hot functions using __attribute__((hot))
When Python is not compiled with PGO, the performance of Python on call_simple
and call_method microbenchmarks depend highly on the code placement. In the
worst case, the performance slowdown can be up to 70%.

The GCC __attribute__((hot)) attribute helps to keep hot code close to reduce
the risk of such major slowdown. This attribute is ignored when Python is
compiled with PGO.

The following functions are considered as hot according to statistics collected
by perf record/perf report:

* _PyEval_EvalFrameDefault()
* call_function()
* _PyFunction_FastCall()
* PyFrame_New()
* frame_dealloc()
* PyErr_Occurred()
2016-11-11 02:13:35 +01:00
Victor Stinner 0cae609847 Use PyThreadState_GET() in performance critical code
It seems like _PyThreadState_UncheckedGet() is not inlined as expected, even
when using gcc -O3.
2016-11-11 01:43:56 +01:00
Yury Selivanov 228722ad20 Merge 3.6 (issue #26182) 2016-11-08 16:54:39 -05:00
Yury Selivanov 1a9d687a49 Issue #26182: Fix ia refleak in code that raises DeprecationWarning. 2016-11-08 16:54:18 -05:00
Serhiy Storchaka 818b5cc6db Fixed possible abort in ceval loop if _PyUnicode_FromId() fails.
Every opcode should end with DISPATCH() or goto error.
2016-11-08 23:14:00 +02:00
Serhiy Storchaka 4678b2f448 Fixed possible abort in ceval loop if _PyUnicode_FromId() fails.
Every opcode should end with DISPATCH() or goto error.
2016-11-08 23:13:36 +02:00
Serhiy Storchaka 70b72f0f96 Fixed possible abort in ceval loop if _PyUnicode_FromId() fails.
Every opcode should end with DISPATCH() or goto error.
2016-11-08 23:12:46 +02:00
Yury Selivanov 0ee446c894 Merge 3.6 (issue #27243) 2016-11-08 15:15:42 -05:00
Yury Selivanov 2edd8a1e2c Issue #27243: Change PendingDeprecationWarning -> DeprecationWarning.
As it was agreed in the issue, __aiter__ returning an awaitable
should result in PendingDeprecationWarning in 3.5 and in
DeprecationWarning in 3.6.
2016-11-08 15:13:07 -05:00
Eric V. Smith 9a8e569865 Merge from 3.6. 2016-11-07 17:57:48 -05:00
Eric V. Smith 9b88fdf4f0 Fixed issue #28633: segfault when concatenating bytes literal and f-string. 2016-11-07 17:54:01 -05:00
Ned Deily 7d76c906f7 Issue #28616: merge from 3.5 2016-11-04 17:07:06 -04:00
Ned Deily da4887a88d Issue #28616: Correct help for sys.version_info releaselevel component.
Patch by Anish Tambe.
2016-11-04 17:03:34 -04:00
Eric V. Smith 5646648678 Issue 28128: Print out better error/warning messages for invalid string escapes. Backport to 3.6. 2016-10-31 14:46:26 -04:00
Ned Deily e37c1cbf66 Issue #28616: merge from 3.6 2016-11-04 17:07:47 -04:00
Eric V. Smith 42454af094 Issue 28128: Print out better error/warning messages for invalid string escapes. 2016-10-31 09:22:08 -04:00
Serhiy Storchaka 42bcbf76f7 Issue #28517: Fixed of-by-one error in the peephole optimizer that caused
keeping unreachable code.
2016-10-25 09:32:04 +03:00
Serhiy Storchaka 7db3c48833 Issue #28517: Fixed of-by-one error in the peephole optimizer that caused
keeping unreachable code.
2016-10-25 09:30:43 +03:00
Serhiy Storchaka cb33a01bbc Issue #28510: Clean up decoding error handlers.
Since PyUnicodeDecodeError_GetObject() always returns bytes, following
PyBytes_AsString() can be replaced with PyBytes_AS_STRING().
2016-10-23 09:44:50 +03:00
Serhiy Storchaka 14ab277632 Issue #28410: Added _PyErr_FormatFromCause() -- the helper for raising
new exception with setting current exception as __cause__.

_PyErr_FormatFromCause(exception, format, args...) is equivalent to Python

    raise exception(format % args) from sys.exc_info()[1]
2016-10-21 17:10:42 +03:00
Serhiy Storchaka 467ab194fc Issue #28410: Added _PyErr_FormatFromCause() -- the helper for raising
new exception with setting current exception as __cause__.

_PyErr_FormatFromCause(exception, format, args...) is equivalent to Python

    raise exception(format % args) from sys.exc_info()[1]
2016-10-21 17:09:17 +03:00
Serhiy Storchaka c4189a04a8 Issue #28410: Keep the traceback of original exception in _PyErr_ChainExceptions(). 2016-10-21 16:21:02 +03:00
Serhiy Storchaka b0426cd8c4 Issue #28410: Keep the traceback of original exception in _PyErr_ChainExceptions(). 2016-10-21 16:20:43 +03:00
Serhiy Storchaka 9e373be1bc Issue #28410: Keep the traceback of original exception in _PyErr_ChainExceptions(). 2016-10-21 16:19:59 +03:00
Benjamin Peterson a2bc46da14 merge 3.6 2016-10-20 22:39:39 -07:00
Benjamin Peterson 4510e6de9d mark dtrace stubs as static inline; remove stubs
C99 inline semantics don't work everywhere. (https://bugs.python.org/issue28092)
We don't want these to have external visibility anyway.
2016-10-20 22:37:00 -07:00
Victor Stinner d65f42a132 Issue #21955: Please don't try to optimize int+int 2016-10-20 12:18:10 +02:00
Serhiy Storchaka 60c838b27c Issue #23782: Fixed possible memory leak in _PyTraceback_Add() and exception
loss in PyTraceBack_Here().
2016-10-18 13:27:54 +03:00
Serhiy Storchaka df0fd74ae8 Issue #23782: Fixed possible memory leak in _PyTraceback_Add() and exception
loss in PyTraceBack_Here().
2016-10-18 13:26:25 +03:00
Serhiy Storchaka 04eb777279 Issue #23782: Fixed possible memory leak in _PyTraceback_Add() and exception
loss in PyTraceBack_Here().
2016-10-18 13:23:18 +03:00
Raymond Hettinger 4186222e63 Minor fix-up to apply the stack adjustment macros consistent with the other opcodes 2016-10-15 19:03:06 -07:00
Serhiy Storchaka 5665301bae Issue #28257: Improved error message when pass a non-mapping as a var-keyword
argument.
2016-10-07 23:32:41 +03:00
Serhiy Storchaka 579de19228 Issue #24098: Fixed possible crash when AST is changed in process of
compiling it.
2016-10-07 21:56:24 +03:00
Serhiy Storchaka 5e80855af3 Issue #24098: Fixed possible crash when AST is changed in process of
compiling it.
2016-10-07 21:55:49 +03:00
Serhiy Storchaka cf3806026b Issue #24098: Fixed possible crash when AST is changed in process of
compiling it.
2016-10-07 21:51:28 +03:00
Berker Peksag 419968c235 Issue #27358: Merge from 3.6 2016-10-02 13:08:47 +03:00
Berker Peksag 8e9045d0d8 Issue #27358: Fix typo in error message 2016-10-02 13:08:25 +03:00
Serhiy Storchaka 2e84de3638 Issue #27358: Optimized merging var-keyword arguments and improved error
message when pass a non-mapping as a var-keyword argument.
2016-10-02 11:07:29 +03:00
Serhiy Storchaka e036ef8fa2 Issue #27358: Optimized merging var-keyword arguments and improved error
message when pass a non-mapping as a var-keyword argument.
2016-10-02 11:06:43 +03:00
Serhiy Storchaka 775a0ea0da Issue #28257: Improved error message when pass a non-iterable as
a var-positional argument.  Added opcode BUILD_TUPLE_UNPACK_WITH_CALL.
2016-10-02 10:34:46 +03:00
Serhiy Storchaka 7344285c19 Issue #28257: Improved error message when pass a non-iterable as
a var-positional argument.  Added opcode BUILD_TUPLE_UNPACK_WITH_CALL.
2016-10-02 10:33:46 +03:00
Serhiy Storchaka be9cddb302 Issue #27942: String constants now interned recursively in tuples and frozensets. 2016-09-30 10:36:15 +03:00
Serhiy Storchaka 3738c2d8ae Issue #27942: String constants now interned recursively in tuples and frozensets. 2016-09-30 10:23:01 +03:00
Serhiy Storchaka 00a0fc1144 Issue #27942: String constants now interned recursively in tuples and frozensets. 2016-09-30 10:07:26 +03:00
Alexander Belopolsky 3e7a3cb903 Issue #28148: Stop using localtime() and gmtime() in the time module.
Introduced platform independent _PyTime_localtime API that is similar
to POSIX localtime_r, but available on all platforms.  Patch by Ed
Schouten.
2016-09-28 17:31:35 -04:00
Alexander Belopolsky 9f518cd01a Merged from 3.6 2016-09-28 17:32:31 -04:00
Serhiy Storchaka c019158a4c Issue #27703: Got rid of unnecessary NULL checks in do_raise() in release mode.
Patch by Xiang Zhang.
2016-09-27 11:37:10 +03:00