Commit Graph

676 Commits

Author SHA1 Message Date
Serhiy Storchaka 398ef5c08f Issue #29327: Fixed a crash when pass the iterable keyword argument to sorted(). 2017-01-20 08:33:06 +02:00
INADA Naoki bd584f169f Issue #29296: convert print() to METH_FASTCALL
* Replace PyArg_ParseTupleAndKeywords() with _PyArg_ParseStackAndKeywords()
  which is more efficient to parse keywords, since it decodes only keywords
  (char*) from UTF-8 once, instead of decoding at each call.
* METH_FASTCALL avoids the creation of a temporary tuple to pass positional
  arguments.

Patch written by INADA Naoki, pushed by Victor Stinner.
2017-01-19 12:50:34 +01:00
Victor Stinner 5a60ecaa7a sorted() uses METH_FASTCALL 2017-01-17 15:17:49 +01:00
Victor Stinner fda6d0acf0 next() uses FASTCALL 2017-01-17 04:09:14 +01:00
Victor Stinner 84b388bb80 getattr() uses METH_FASTCALL 2017-01-17 03:52:27 +01:00
Victor Stinner 773dc6dd06 __build_class__() builtin uses METH_FASTCALL 2017-01-16 23:46:26 +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 f17c3de263 Use _PyObject_CallNoArg()
Replace:
    PyObject_CallFunctionObjArgs(callable, NULL)
with:
    _PyObject_CallNoArg(callable)
2016-12-06 18:46:19 +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 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 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 06515833fe Replaced outdated macros _PyUnicode_AsString and _PyUnicode_AsStringAndSize
with PyUnicode_AsUTF8 and PyUnicode_AsUTF8AndSize.
2016-11-20 09:13:07 +02: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
Eric Snow 4f29e75289 Issue #24254: Drop cls.__definition_order__. 2016-09-08 15:11:11 -07:00
Raymond Hettinger f0f1c239e4 Issue 27936: Fix inconsistent round() behavior between float and int 2016-09-03 01:55:11 -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
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
Eric Snow 92a6c170e6 Issue #24254: Preserve class attribute definition order. 2016-09-05 14:50:11 -07:00
Raymond Hettinger 3b09cd64e0 Merge 2016-09-03 01:55:39 -07: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 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 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 2990fa11bc Issue #27809: Use _PyObject_FastCallDict()
Modify:

* builtin_sorted()
* classmethoddescr_call()
* methoddescr_call()
* wrapperdescr_call()
2016-08-22 23:21:55 +02:00
Serhiy Storchaka 2954f83999 - Issue #27332: Fixed the type of the first argument of module-level functions
generated by Argument Clinic.  Patch by Petr Viktorin.
2016-07-07 18:20:03 +03:00
Serhiy Storchaka 1a2b24f02d Issue #27332: Fixed the type of the first argument of module-level functions
generated by Argument Clinic.  Patch by Petr Viktorin.
2016-07-07 17:35:15 +03:00
Serhiy Storchaka cfdfbb4d3c Issue #27342: Replaced some Py_XDECREFs with Py_DECREFs.
Patch by Xiang Zhang.
2016-06-18 09:44:03 +03:00
Serhiy Storchaka 24182a3aaa Restored parameter name "self" since gdb needs exact specific parameter names. 2016-05-05 16:21:35 +03:00
Serhiy Storchaka 7a9579c0ce Got rid of redundand "self" parameter declarations.
Argument Clinic is now able to infer all needed information.
2016-05-02 13:45:20 +03:00
Serhiy Storchaka 2e310b4c38 Regenerate Argument Clinic code for issue #26874. 2016-05-01 20:34:00 +03:00
Serhiy Storchaka df071730bb Regenerate Argument Clinic code for issue #26874. 2016-05-01 20:33:24 +03:00
Zachary Ware 5031a67821 Closes #26874: Merge with 3.5 2016-04-28 14:40:08 -05:00
Zachary Ware 7f227d9087 Issue #26874: Simplify the divmod docstring 2016-04-28 14:39:50 -05:00
Zachary Ware 54559b6511 Closes #26874: Merge with 3.5 2016-04-28 14:25:32 -05:00
Zachary Ware 4d4160af6a Issue #26874: Fix divmod docstring 2016-04-28 14:24:55 -05:00
Serhiy Storchaka 21a663ea28 Issue #26057: Got rid of nonneeded use of PyUnicode_FromObject(). 2016-04-13 15:37:23 +03:00
Martin Panter 9513ba3b8f Issue #24802: Merge null termination fixes from 3.5 2015-11-07 03:15:32 +00:00
Martin Panter 61d6e4ae9d Issue #24802: Merge null termination fixes from 3.4 into 3.5 2015-11-07 02:56:11 +00:00
Martin Panter eeb896c411 Issue #24802: Copy bytes-like objects to null-terminated buffers if necessary
This avoids possible buffer overreads when int(), float(), compile(), exec()
and eval() are passed bytes-like objects. Similar code is removed from the
complex() constructor, where it was not reachable.

Patch by John Leitch, Serhiy Storchaka and Martin Panter.
2015-11-07 02:32:21 +00:00
Martin Panter 5344da5c0d Issue #24402: Merge input() fix from 3.5 2015-10-10 02:09:41 +00:00
Martin Panter e02f8fc44d Issue #24402: Merge input() fix from 3.4 into 3.5 2015-10-10 01:55:23 +00:00
Martin Panter c9a6ab56cf Issue #24402: Fix input() when stdout.fileno() fails; diagnosed by Eryksun
Also factored out some test cases into a new PtyTests class.
2015-10-10 01:25:38 +00:00
Raymond Hettinger bd5f0e8c1c Hoist constant expression out of the inner loop. 2015-10-09 01:34:08 -04:00
Raymond Hettinger 5098b58381 Make comparison more consistent 2015-10-09 00:42:47 -04:00
Raymond Hettinger 501b4a7398 Use PyTuple_GET_SIZE like the adjacent code does. 2015-08-18 08:07:16 -07:00
Raymond Hettinger f109414094 Inline PyIter_Next() matching the other itertools code. 2015-08-18 00:20:20 -07:00
Serhiy Storchaka 8b2e8b6cce Specify default values of semantic booleans in Argument Clinic generated signatures as booleans. 2015-05-30 11:30:39 +03:00
Serhiy Storchaka 7e810a6e3d Use converter names instead of format units in Argument Clinic descriptions
in builtin and _crypt modules.
2015-05-30 11:09:35 +03:00
Larry Hastings 89964c48d1 Issue #23944: Argument Clinic now wraps long impl prototypes at column 78. 2015-04-14 18:07:59 -04:00
Serhiy Storchaka 1009bf18b3 Issue #23501: Argumen Clinic now generates code into separate files by default. 2015-04-03 23:53:51 +03:00
Victor Stinner 0c39b1b970 Initialize variables to prevent GCC warnings 2015-03-18 15:02:06 +01:00
Serhiy Storchaka 3dd3e26680 Issue #22896: Avoid to use PyObject_AsCharBuffer(), PyObject_AsReadBuffer()
and PyObject_AsWriteBuffer().
2015-02-03 01:25:42 +02:00
Serhiy Storchaka 4fdb68491e Issue #22896: Avoid to use PyObject_AsCharBuffer(), PyObject_AsReadBuffer()
and PyObject_AsWriteBuffer().
2015-02-03 01:21:08 +02:00
Serhiy Storchaka d8a1447c99 Issue #22215: Now ValueError is raised instead of TypeError when str or bytes
argument contains not permitted null character or byte.
2014-09-06 20:07:17 +03:00
Nick Coghlan f9e227e5a9 Issue #20184: Add signature introspection for 30 of the builtins
Also adds a test to test_inspect to track progress on builtin
introspection support, to ensure it doesn't regress in the future.
2014-08-17 14:01:19 +10:00
Victor Stinner 98ea54c35c Issue #22156: Fix "comparison between signed and unsigned integers" compiler
warnings in the Python/ subdirectory.
2014-08-15 23:30:40 +02:00
Zachary Ware 9b33872812 Issue #22146: Fix typo in __build_class__ error message 2014-08-05 14:01:10 -05:00
Terry Jan Reedy f2fb73f675 Issue #19362: Tweek len() doc and docstring to expand the indicated range of
arguments. Original patch by Gareth Rees.
2014-06-16 03:05:37 -04:00
Raymond Hettinger 2a54582d72 Issue 20620: Update the min()/max() docs for the new default argument.
Patch provided by Berker Peksag.
2014-05-19 22:20:52 +01:00
Benjamin Peterson 5edbb7b7a4 correct len signature in docstring (closes #21294) 2014-04-18 01:03:59 -04:00
Larry Hastings 5c66189e88 Issue #20189: Four additional builtin types (PyTypeObject,
PyMethodDescr_Type, _PyMethodWrapper_Type, and PyWrapperDescr_Type)
have been modified to provide introspection information for builtins.
Also: many additional Lib, test suite, and Argument Clinic fixes.
2014-01-24 06:17:25 -08:00
Benjamin Peterson d45a46b60d merge 3.3 (#19910) 2013-12-06 20:12:51 -05:00
Benjamin Peterson 933142a8f2 document that compile() can take bytes (closes #19910) 2013-12-06 20:12:39 -05:00
Zachary Ware a4b7a7548c Issue #3158: doctest can now find doctests in functions and methods
written in C.

As a part of this, a few doctests have been added to the builtins module
(on hex(), oct(), and bin()), a doctest has been fixed (hopefully on all
platforms) on float, and test_builtins now runs doctests in builtins.
2013-11-24 01:19:09 -06:00
Victor Stinner bd303c165b Issue #19512, #19515: remove shared identifiers, move identifiers where they
are used.

Move also _Py_IDENTIFIER() defintions to the top in modified files to remove
identifiers duplicated in the same file.
2013-11-07 23:07:29 +01:00
Victor Stinner eaa2883d15 Issue #19512: builtin print() function uses an identifier instead of literal
string "flush" to call the flush method
2013-11-07 00:01:51 +01:00
Victor Stinner ae9f161b43 Issue #19512: __build_class() builtin now uses an identifier for the "metaclass" string 2013-11-06 22:46:51 +01:00
Victor Stinner 090543736f Issue #19512: add some common identifiers to only create common strings once,
instead of creating temporary Unicode string objects

Add also more identifiers in pythonrun.c to avoid temporary Unicode string
objets for the interactive interpreter.
2013-11-06 22:41:44 +01:00
Victor Stinner b44562b6b9 Issue #19512: eval() and exec() now use an identifier for "__builtins__" string 2013-11-06 19:03:11 +01:00
Victor Stinner 41bb43a71e Issue #18408: Add a new PyFrame_FastToLocalsWithError() function to handle
exceptions when merging fast locals into f_locals of a frame.
PyEval_GetLocals() now raises an exception and return NULL on failure.
2013-10-29 01:19:37 +01:00
Serhiy Storchaka c679227e31 Issue #1772673: The type of `char*` arguments now changed to `const char*`. 2013-10-19 21:03:34 +03:00
Serhiy Storchaka 46e1ce214b Issue #18783: Removed existing mentions of Python long type in docstrings,
error messages and comments.
2013-08-27 20:17:03 +03:00
Serhiy Storchaka 9594942716 Issue #18783: Removed existing mentions of Python long type in docstrings,
error messages and comments.
2013-08-27 19:40:23 +03:00
Victor Stinner 14e461d5b9 Close #11619: The parser and the import machinery do not encode Unicode
filenames anymore on Windows.
2013-08-26 22:28:21 +02:00
Christian Heimes 4ebf6d7c3c Issue #18560: Fix potential NULL pointer dereference in sum() 2013-07-26 22:50:01 +02:00
Christian Heimes 704e2d374f Issue #18560: Fix potential NULL pointer dereference in sum() 2013-07-26 22:49:26 +02:00
Victor Stinner 1e53bbaced Issue #18408: handle PySys_GetObject() failure, raise a RuntimeError 2013-07-16 22:26:05 +02:00
R David Murray acb362e29f Merge: #18424: PEP8ify the tense of the sum docstring. 2013-07-10 16:22:59 -04:00
R David Murray 87ead1138d #18424: PEP8ify the tense of the sum docstring. 2013-07-10 16:22:14 -04:00
Raymond Hettinger 4d6018fe45 Issue 18111: Add a default argument to min() and max() 2013-06-24 22:43:02 -07:00
Benjamin Peterson e8e14591eb rather than passing locals to the class body, just execute the class body in the proper environment 2013-05-16 14:37:25 -05:00
Benjamin Peterson 214a7d2674 properly lookup the __round__ special method (closes #17722) 2013-04-13 17:19:01 -04:00
Serhiy Storchaka ee57f159af Revert a premature patch for issue #14010 (changeset 846bd418aee5). 2013-04-06 22:55:12 +03:00
Serhiy Storchaka 278d03bd66 Revert a premature patch for issue #14010 (changeset aaaf36026511). 2013-04-06 22:52:34 +03:00
Serhiy Storchaka aac81e2780 Issue #14010: Fix a crash when iterating or deleting deeply nested filters
(builting and in itertools module, i.e. map(), itertools.chain(), etc).
2013-04-06 21:20:30 +03:00
Serhiy Storchaka e8f706eda7 Issue #14010: Fix a crash when iterating or deleting deeply nested filters
(builting and in itertools module, i.e. map(), itertools.chain(), etc).
2013-04-06 21:14:43 +03:00
Richard Oudkerk eea1f5c2e4 Merge 2013-04-03 13:49:36 +01:00
Richard Oudkerk 614c578dec Issue #17619: Make input() check for Ctrl-C correctly on Windows. 2013-04-03 13:44:50 +01:00
Ezio Melotti 178e6fef9e #17178: merge with 3.3. 2013-02-15 23:38:23 +02:00
Ezio Melotti 293ab9728a #17178: merge with 3.2. 2013-02-15 23:38:05 +02:00
Ezio Melotti b19ed57d8d #17178: update any()/all() docstrings to document their behavior with empty iterables. Patch by Ankur Ankan. 2013-02-15 23:35:14 +02:00
Philip Jenvey f76f0eea5c compile doesn't accept code objects 2012-12-13 15:44:18 -08:00
Benjamin Peterson 42124a727d initialize map/filter/zip in _PyBuiltin_Init rather than the catch-all function 2012-10-30 23:41:54 -04:00
Stefan Krah 66d1eb23d4 Merge 3.2. 2012-08-20 17:20:46 +02:00