Commit Graph

5454 Commits

Author SHA1 Message Date
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
Christian Heimes 517507c6d5 Issue #28100: Refactor error messages, patch by Ivan Levkivskyi 2016-09-23 20:26:30 +02:00
Serhiy Storchaka 208bbd29d3 Silence GCC warning.
The code was correct, but GCC is not enough clever.
2016-09-22 19:59:46 +03:00
Serhiy Storchaka 63dc548109 Issue #28086: Single var-positional argument of tuple subtype was passed
unscathed to the C-defined function.  Now it is converted to exact tuple.
2016-09-22 19:41:20 +03:00
Christian Heimes 2f2fee19ec va_end() all va_copy()ed va_lists. 2016-09-21 11:37:27 +02:00
Benjamin Peterson 0c21214f3e replace usage of Py_VA_COPY with the (C99) standard va_copy 2016-09-20 20:39:33 -07:00
Victor Stinner 75024c6589 (Merge 3.5) Catch EPERM error in py_getrandom()
Issue #27955: Fallback on reading /dev/urandom device when the getrandom()
syscall fails with EPERM, for example when blocked by SECCOMP.
2016-09-20 22:49:52 +02:00
Victor Stinner 6d8bc46cc0 Catch EPERM error in py_getrandom()
Issue #27955: Fallback on reading /dev/urandom device when the getrandom()
syscall fails with EPERM, for example when blocked by SECCOMP.
2016-09-20 22:46:02 +02:00
Victor Stinner af59732102 Cleanup random.c
Issue #27955: modify py_getrnadom() and dev_urandom()

* Add comments from Python 3.7
* PEP 7 style: add {...}
2016-09-20 22:26:18 +02:00
Benjamin Peterson 286987bbac delete dead code 2016-09-18 23:49:51 -07:00
Steve Dower 74f4af7ac3 Issue #27932: Prevent memory leak in win32_ver(). 2016-09-17 17:27:48 -07:00
Steve Dower 1ec262be80 Issue #27932: Prevent memory leak in win32_ver(). 2016-09-17 17:25:42 -07:00
Yury Selivanov 8987c9d219 Issue #26182: Raise DeprecationWarning for improper use of async/await keywords 2016-09-15 12:50:23 -04:00
Benjamin Peterson 995026a8a9 merge 3.5 (#28119) 2016-09-13 22:46:15 -07:00
Benjamin Peterson 59e5e0dca2 improve type-safe of and prevent double-frees in get_locale_info (#28119) 2016-09-13 22:43:45 -07:00
Christian Heimes f051e43b22 Issue #28126: Replace Py_MEMCPY with memcpy(). Visual Studio can properly optimize memcpy(). 2016-09-13 20:22:02 +02:00
Victor Stinner 57f91ac95a Document kwnames in _PyObject_FastCallKeywords() and _PyStack_AsDict()
Issue #27213.
2016-09-12 13:37:07 +02:00
Victor Stinner eece2229e2 Issue #27213: Fix reference leaks 2016-09-12 11:16:37 +02:00
Eric V. Smith 09835dcdbb Make an f-string error message more exact and consistent. 2016-09-11 18:58:20 -04:00
Serhiy Storchaka b72810583e Issue #27213: Fixed different issues with reworked CALL_FUNCTION* opcodes.
* BUILD_TUPLE_UNPACK and BUILD_MAP_UNPACK_WITH_CALL no longer generated with
  single tuple or dict.
* Restored more informative error messages for incorrect var-positional and
  var-keyword arguments.
* Removed code duplications in _PyEval_EvalCodeWithName().
* Removed redundant runtime checks and parameters in _PyStack_AsDict().
* Added a workaround and enabled previously disabled test in test_traceback.
* Removed dead code from the dis module.
2016-09-12 00:52:40 +03:00
Guido van Rossum 015d874626 Issue #28076: Variable annotations should be mangled for private names.
By Ivan Levkivskyi.
2016-09-11 09:45:24 -07:00
Serhiy Storchaka a1e9ab34a9 Fixed refactoring bug in dd046963bd42 (issue27129). 2016-09-11 15:19:12 +03:00
Serhiy Storchaka ab8740058a Issue #27129: Replaced wordcode related magic constants with macros. 2016-09-11 13:48:15 +03:00
Nick Coghlan 944368e1cc Issue #23722: Initialize __class__ from type.__new__()
The __class__ cell used by zero-argument super() is now initialized
from type.__new__ rather than __build_class__, so class methods
relying on that will now work correctly when called from metaclass
methods during class creation.

Patch by Martin Teichmann.
2016-09-11 14:45:49 +10:00
Benjamin Peterson 4eef505064 Backed out changeset 3934e070c9db 2016-09-10 17:04:36 -07:00
Victor Stinner 54de2b1edd Fix check_force_ascii()
Issue #27938: Normalize aliases of the ASCII encoding, because
_Py_normalize_encoding() now correctly normalize encoding names.
2016-09-09 23:11:52 -07:00
Łukasz Langa fef7e94fa1 Don't run garbage collection on interpreter exit if it was explicitly disabled
by the user.
2016-09-09 21:47:46 -07:00
Victor Stinner c7454ff5fc Issue #27810: Fix getargs.c compilation on Windows 2016-09-09 20:56:52 -07:00
Benjamin Peterson 819a46f33a fix export of size_t parse stack function 2016-09-09 20:45:06 -07:00
Victor Stinner 37e4ef7b17 Issue #27810: Rerun Argument Clinic on all modules 2016-09-09 20:00:13 -07:00
Victor Stinner f0ccbbbc57 Emit METH_FASTCALL code in Argument Clinic
Issue #27810:

* Modify vgetargskeywordsfast() to work on a C array of PyObject* rather than
  working on a tuple directly.
* Add _PyArg_ParseStack()
* Argument Clinic now emits code using the new METH_FASTCALL calling convention
2016-09-09 17:40:38 -07:00
Victor Stinner a9efb2f56e Add METH_FASTCALL calling convention
Issue #27810: Add a new calling convention for C functions:

    PyObject* func(PyObject *self, PyObject **args,
                   Py_ssize_t nargs, PyObject *kwnames);

Where args is a C array of positional arguments followed by values of keyword
arguments. nargs is the number of positional arguments, kwnames are keys of
keyword arguments. kwnames can be NULL.
2016-09-09 17:40:22 -07:00
Benjamin Peterson eb0dfa9251 make invalid_comma_and_underscore a real prototype 2016-09-09 20:14:05 -07:00
Eric V. Smith 89e1b1aae0 Issue 27080: PEP 515: add '_' formatting option. 2016-09-09 23:06:47 -04:00
Benjamin Peterson f5781958af add dtrace inline stubs 2016-09-09 19:48:47 -07:00
Benjamin Peterson 4ba5c88a3f just start with an int rather than casting 2016-09-09 19:31:12 -07:00
Eric V. Smith 451d0e38fc Issue 27948: Allow backslashes in the literal string portion of f-strings, but not in the expressions. Also, require expressions to begin and end with literal curly braces. 2016-09-09 21:56:20 -04:00
Łukasz Langa a785c87d6e DTrace support: function calls, GC activity, line execution
Tested on macOS 10.11 dtrace, Ubuntu 16.04 SystemTap, and libbcc.

Largely based by an initial patch by Jesús Cea Avión, with some
influence from Dave Malcolm's SystemTap patch and Nikhil Benesch's
unification patch.

Things deliberately left out for simplicity:
- ustack helpers, I have no way of testing them at this point since
they are Solaris-specific
- PyFrameObject * in function__entry/function__return, this is
SystemTap-specific
- SPARC support
- dynamic tracing
- sys module dtrace facility introspection

All of those might be added later.
2016-09-09 17:37:37 -07:00
Benjamin Peterson 75f94a7dff remove more READ_TIMESTAMP 2016-09-09 15:03:18 -07:00
Benjamin Peterson 1cfe1d1f53 remove READ_TIMESTAMP macro 2016-09-09 15:02:11 -07:00
Benjamin Peterson 4fd64b9a6a remove ceval timestamp support 2016-09-09 14:57:58 -07:00
Brett Cannon a721abac29 Issue #26331: Implement the parsing part of PEP 515.
Thanks to Georg Brandl for the patch.
2016-09-09 14:57:09 -07:00
Victor Stinner ae8b69c410 Issue #27810: Add _PyCFunction_FastCallKeywords()
Use _PyCFunction_FastCallKeywords() in ceval.c: it allows to remove a lot of
code from ceval.c which was only used to call C functions.
2016-09-09 14:07:44 -07:00
Eric Snow 50fd89806f Issue #24320: Drop an old setuptools-induced hack. 2016-09-09 13:30:54 -07:00
Victor Stinner d873572095 Add _PyObject_FastCallKeywords()
Issue #27830: Add _PyObject_FastCallKeywords(): avoid the creation of a
temporary dictionary for keyword arguments.

Other changes:

* Cleanup call_function() and fast_function() (ex: rename nk to nkwargs)
* Remove now useless do_call(), replaced with _PyObject_FastCallKeywords()
2016-09-09 12:36:44 -07:00
Victor Stinner f9b760f48a Rework CALL_FUNCTION* opcodes
Issue #27213: Rework CALL_FUNCTION* opcodes to produce shorter and more
efficient bytecode:

* CALL_FUNCTION now only accepts position arguments
* CALL_FUNCTION_KW accepts position arguments and keyword arguments, but keys
  of keyword arguments are packed into a constant tuple.
* CALL_FUNCTION_EX is the most generic, it expects a tuple and a dict for
  positional and keyword arguments.

CALL_FUNCTION_VAR and CALL_FUNCTION_VAR_KW opcodes have been removed.

2 tests of test_traceback are currently broken: skip test, the issue #28050 was
created to track the issue.

Patch by Demur Rumed, design by Serhiy Storchaka, reviewed by Serhiy Storchaka
and Victor Stinner.
2016-09-09 10:17:08 -07:00
Yury Selivanov 52c4e7cc84 Issue #28008: Implement PEP 530 -- asynchronous comprehensions. 2016-09-09 10:36:01 -07:00
Guido van Rossum 6cff8744a0 Issue #27999: Make "global after use" a SyntaxError, and ditto for nonlocal.
Patch by Ivan Levkivskyi.
2016-09-09 09:36:26 -07:00
Yury Selivanov 87672d777a Issue #28003: Fix a compiler warning 2016-09-09 00:05:42 -07:00
Yury Selivanov 50c584f50b ceval: tighten the code of STORE_ANNOTATION 2016-09-08 23:38:21 -07:00
Yury Selivanov eb6364557f Issue #28003: Implement PEP 525 -- Asynchronous Generators. 2016-09-08 22:01:51 -07:00
Yury Selivanov f8cb8a16a3 Issue #27985: Implement PEP 526 -- Syntax for Variable Annotations.
Patch by Ivan Levkivskyi.
2016-09-08 20:50:03 -07:00
Christian Heimes a78b627e2b Fix potential NULL pointer dereference in _imp_create_builtin
PyModule_GetDef() can return NULL. Let's check the return value properly
like in the other five cases.

CID 1299590
2016-09-09 00:25:03 +02:00
Eric Snow 4f29e75289 Issue #24254: Drop cls.__definition_order__. 2016-09-08 15:11:11 -07:00
Christian Heimes 45af0c83da Fix potential NULL pointer dereference in update_symbols()
symtable_analyze() calls analyze_block() with bound=NULL. Theoretically
that NULL can be passed down to update_symbols(). update_symbols() may
deference NULL and pass it to PySet_Contains()
2016-09-09 00:22:28 +02:00
Raymond Hettinger 4c483ad52b Merge 2016-09-08 14:45:40 -07:00
Raymond Hettinger 262b6793e0 Issue #26020: Fix evaluation order for set literals 2016-09-08 14:40:36 -07:00
Martin Panter 0be894b2f6 Issue #27895: Spelling fixes (Contributed by Ville Skyttä). 2016-09-07 12:03:06 +00:00
Senthil Kumaran 32d374215a [backport to 3.5] - issue26896 - Disambiguate uses of "importer" with "finder". 2016-09-07 00:52:20 -07:00
Raymond Hettinger f0f1c239e4 Issue 27936: Fix inconsistent round() behavior between float and int 2016-09-03 01:55:11 -07:00
Raymond Hettinger f0afe77c52 Issue #27909: Fix INCREF for possible NULL value 2016-08-31 08:44:11 -07:00
Steve Dower 3929499914 Issue #1602: Windows console doesn't input or print Unicode (PEP 528)
Closes #17602: Adds a readline implementation for the Windows console
2016-08-30 21:22:36 -07:00
Steve Dower 940f33a50f Issue #23524: Finish removing _PyVerify_fd from sources 2016-09-08 11:21:54 -07:00
Eric Snow f3fd06a2e4 Issue #28026: Raise ImportError when exec_module() exists but create_module() is missing. 2016-09-08 11:12:31 -07:00
Steve Dower cc16be85c0 Issue #27781: Change file system encoding on Windows to UTF-8 (PEP 529) 2016-09-08 10:35:16 -07:00
Brett Cannon 035a100382 Issue #26667: Add path-like object support to importlib.util. 2016-09-07 18:39:18 -07:00
Brett Cannon 52794db825 Issue #27911: Remove some unnecessary error checks in import.c.
Thanks to Xiang Zhang for the patch.
2016-09-07 17:00:43 -07:00
Eric Snow 46f97b85a8 Issue #15767: Use ModuleNotFoundError. 2016-09-07 16:56:15 -07:00
Brett Cannon 5c4de2863b Add the co_extra field and accompanying APIs to code objects.
This completes PEP 523.
2016-09-07 11:16:41 -07:00
Benjamin Peterson 2f8bfef158 replace PY_SIZE_MAX with SIZE_MAX 2016-09-07 09:26:18 -07:00
Victor Stinner e66987e626 os.urandom() now blocks on Linux
Issue #27776: The os.urandom() function does now block on Linux 3.17 and newer
until the system urandom entropy pool is initialized to increase the security.

This change is part of the PEP 524.
2016-09-06 16:33:52 -07:00
Brett Cannon eaecc692df Issue #27974: Remove importlib._bootstrap._ManageReload.
Class was dead code. Thanks to Xiang Zhang for the patch.
2016-09-06 16:20:46 -07:00
Benjamin Peterson ca47063998 replace Py_(u)intptr_t with the c99 standard types 2016-09-06 13:47:26 -07:00
Benjamin Peterson 9b3d77052f replace Python aliases for standard integer types with the standard integer types (#17884) 2016-09-06 13:24:00 -07:00
Benjamin Peterson 5d75f441ef dtoa.c: remove code for platforms with 64-bit integers (#17884) 2016-09-06 12:44:21 -07:00
Serhiy Storchaka ea525a2d1a Issue #27078: Added BUILD_STRING opcode. Optimized f-strings evaluation. 2016-09-06 22:07:53 +03:00
Benjamin Peterson 4fe55106d1 require standard int types to be defined (#17884) 2016-09-06 11:58:01 -07:00
Benjamin Peterson af580dff4a replace PY_LONG_LONG with long long 2016-09-06 10:46:49 -07:00
Victor Stinner 3466bde1cc Avoid calling functions with an empty string as format string
Directly pass NULL rather than an empty string.
2016-09-05 18:16:01 -07:00
Victor Stinner ad8c83ad6b Avoid inefficient way to call functions without argument
Don't pass "()" format to PyObject_CallXXX() to call a function without
argument: pass NULL as the format string instead. It avoids to have to parse a
string to produce 0 argument.
2016-09-05 17:53:15 -07:00
Benjamin Peterson ed4aa83ff7 require a long long data type (closes #27961) 2016-09-05 17:44:18 -07:00
Brett Cannon 3cebf93872 Implement the frame evaluation API aspect of PEP 523. 2016-09-05 15:33:46 -07:00
Larry Hastings 10108a7b9a Issue #27355: Removed support for Windows CE. It was never finished,
and Windows CE is no longer a relevant platform for Python.
2016-09-05 15:11:23 -07:00
Eric Snow 92a6c170e6 Issue #24254: Preserve class attribute definition order. 2016-09-05 14:50:11 -07:00
Eric V. Smith 6a4efce7a5 Closes issue 27921: Disallow backslashes anywhere in f-strings. This is a temporary restriction. In 3.6 beta 2, the plan is to again allow backslashes in the string parts of f-strings, but disallow them in the expression parts. 2016-09-03 09:18:34 -04:00
Raymond Hettinger 3b09cd64e0 Merge 2016-09-03 01:55:39 -07:00
Raymond Hettinger 74942c9252 Merge 2016-08-31 08:44:26 -07:00
Raymond Hettinger 15f44ab043 Issue #27895: Spelling fixes (Contributed by Ville Skyttä). 2016-08-30 10:47:49 -07:00
Serhiy Storchaka 1f9326196e Issue #27818: Speed up parsing width and precision in format() strings for
numbers.  Patch by Stefan Behnel.
2016-08-29 15:57:26 +03:00
Raymond Hettinger f74c33ad5c Merge 2016-08-25 21:12:16 -07:00
Raymond Hettinger 7ea386e56e Issue 19504: Change "customise" to "customize" American spelling. 2016-08-25 21:11:50 -07:00
Victor Stinner e90bdb19f2 Issue #27830: Revert, remove _PyFunction_FastCallKeywords() 2016-08-25 23:26:50 +02:00
Victor Stinner 577e1f8cb4 Add _PyObject_FastCallKeywords()
Issue #27830: Similar to _PyObject_FastCallDict(), but keyword arguments are
also passed in the same C array than positional arguments, rather than being
passed as a Python dict.
2016-08-25 00:29:32 +02:00
Victor Stinner 74319ae219 Use Py_ssize_t type for number of arguments
Issue #27848: use Py_ssize_t rather than C int for the number of function
positional and keyword arguments.
2016-08-25 00:04:09 +02:00
Victor Stinner cdb5cee980 Issue #27809: map_next() uses fast call
Use a small stack allocated in the C stack for up to 5 iterator functions,
otherwise allocates a stack on the heap memory.
2016-08-24 01:45:13 +02:00
Victor Stinner f0cba67d0b Backed out changeset 70f88b097f60 (map_next) 2016-08-24 00:54:47 +02:00
Victor Stinner a9ba1ab21b Issue #27809: map_next() uses fast call
Use a small stack allocated in the C stack for up to 5 iterator functions,
otherwise allocates a stack on the heap memory.
2016-08-23 17:56:06 +02:00
Victor Stinner d1c2a8e2b5 Issue #27809: builtin___build_class__() uses fast call 2016-08-23 01:34:35 +02:00
Victor Stinner 6e2333dfdf PyEval_CallObjectWithKeywords() doesn't inc/decref
Issue #27809: PyEval_CallObjectWithKeywords() doesn't increment temporary the
reference counter of the args tuple (positional arguments). The caller already
holds a strong reference to it.
2016-08-23 00:25:01 +02:00
Victor Stinner f45a56150b Issue #27809: PyErr_SetImportError() uses fast call 2016-08-23 00:04:41 +02:00
Victor Stinner 3a84097291 Add _PyErr_CreateException()
Issue #27809: Helper function optimized to create an exception: use fastcall
whenever possible.
2016-08-22 23:59:08 +02:00
Victor Stinner 463b86a881 Issue #27809: Use _PyObject_FastCallDict()
Modify:

* init_subclass()
* builtin___build_class__()

Fix also a bug in init_subclass(): check for super() failure.
2016-08-22 23:33:13 +02:00
Victor Stinner 155ea65e5c PyEval_CallObjectWithKeywords() uses fast call with kwargs
Issue #27809. _PyObject_FastCallDict() now supports keyword arguments, and so
the args==NULL fast-path can also be used when kwargs is not NULL.
2016-08-22 23:26:00 +02:00
Victor Stinner 2990fa11bc Issue #27809: Use _PyObject_FastCallDict()
Modify:

* builtin_sorted()
* classmethoddescr_call()
* methoddescr_call()
* wrapperdescr_call()
2016-08-22 23:21:55 +02:00
Victor Stinner 6fea7f7ffc Issue #27809: Cleanup _PyEval_EvalCodeWithName()
* Rename nm to name
* PEP 7: add { ... } to if/else blocks
2016-08-22 23:17:30 +02:00
Victor Stinner b900939186 _PyFunction_FastCallDict() supports keyword args
Issue #27809:

* Rename _PyFunction_FastCall() to _PyFunction_FastCallDict()
* Rename _PyCFunction_FastCall() to _PyCFunction_FastCallDict()
*  _PyFunction_FastCallDict() now supports keyword arguments
2016-08-22 23:15:44 +02:00
Victor Stinner 559bb6a713 Rename _PyObject_FastCall() to _PyObject_FastCallDict()
Issue #27809:

* Rename _PyObject_FastCall() function to _PyObject_FastCallDict()
* Add _PyObject_FastCall(), _PyObject_CallNoArg() and _PyObject_CallArg1()
  macros calling _PyObject_FastCallDict()
2016-08-22 22:48:54 +02:00
Berker Peksag c98afb7a26 Issue #27587: Merge from 3.5 2016-08-22 18:07:02 +03:00
Berker Peksag 4b7b565c58 Issue #27587: Move null pointer check earlier in _PyState_AddModule()
This was found by PVS-Studio:

V595 The 'def' pointer was utilized before it was verified
against nullptr. Check lines: 286, 292. pystate.c 286

Initial patch by Christian Heimes.
2016-08-22 18:05:56 +03:00
Victor Stinner 2eedc119c2 Optimize call to Python function without argument
Issue #27128. When a Python function is called with no arguments, but all
parameters have a default value: use default values as arguments for the fast
path.
2016-08-22 12:29:42 +02:00
Victor Stinner a88b2f4e5e Fix reference leak in tb_printinternal()
Issue #26823.
2016-08-20 03:05:13 +02:00
Victor Stinner c3ccaae6f3 sys_pyfile_write_unicode() now uses fast call
Issue #27128.
2016-08-20 01:24:22 +02:00
Victor Stinner 78da82bf3e call_trampoline() now uses fast call
Issue #27128.
2016-08-20 01:22:57 +02:00
Victor Stinner 71cb64acc2 PyErr_PrintEx() now uses fast call
Issue #27128.
2016-08-20 00:57:43 +02:00
Victor Stinner df142fdc4b import_name() now uses fast call
Issue #27128: import_name() now calls _PyObject_FastCall() to avoid the
creation of a temporary tuple.
2016-08-20 00:44:42 +02:00
Victor Stinner 8a31c82093 Fix PyObject_Call() parameter names
Issue #27128: arg=>args, kw=>kwargs.

Same change for PyEval_CallObjectWithKeywords().
2016-08-19 17:12:23 +02:00