summaryrefslogtreecommitdiffstats
path: root/Objects/methodobject.c
Commit message (Collapse)AuthorAgeFilesLines
* bpo-33012: Fix invalid function cast warnings with gcc 8 for METH_NOARGS. ↵Siddhesh Poyarekar2018-04-291-1/+1
| | | | | | | | | (GH-6030) METH_NOARGS functions need only a single argument but they are cast into a PyCFunction, which takes two arguments. This triggers an invalid function cast warning in gcc8 due to the argument mismatch. Fix this by adding a dummy unused argument.
* bpo-30860: Consolidate stateful runtime globals. (#3397)Eric Snow2017-09-081-0/+2
| | | | | | | * group the (stateful) runtime globals into various topical structs * consolidate the topical structs under a single top-level _PyRuntimeState struct * add a check-c-globals.py script that helps identify runtime globals Other globals are excluded (see globals.txt and check-c-globals.py).
* bpo-29524: Add Objects/call.c file (#12)Victor Stinner2017-02-121-323/+0
| | | | | | | | | * 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.
* Backed out changeset f23fa1f7b68fVictor Stinner2017-02-101-0/+323
| | | | | Sorry, I didn't want to push this change before the review :-( I was pushing a change into the 2.7 branch.
* Issue #29465: Add Objects/call.c fileVictor Stinner2017-02-101-323/+0
| | | | | | | | | | * 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.
* Fix PyCFunction_Call() performance issueVictor Stinner2017-02-091-4/+50
| | | | | | | 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.
* Issue #29306: Fix usage of Py_EnterRecursiveCall()Victor Stinner2017-02-081-25/+36
| | | | | | | * *PyCFunction_*Call*() functions now call Py_EnterRecursiveCall(). * PyObject_Call() now calls directly _PyFunction_FastCallDict() and PyCFunction_Call() to avoid calling Py_EnterRecursiveCall() twice per function call
* Issue #29263: LOAD_METHOD support for C methodsINADA Naoki2017-02-021-23/+30
| | | | Calling builtin method is at most 10% faster.
* Cleanup _PyMethodDef_RawFastCallDict()Victor Stinner2017-01-181-11/+9
| | | | | | Issue #29259: use a different case for METH_VARARGS and METH_VARARGS|METH_KEYWORDS to avoid testing again flags to decide if keywords should be checked or not.
* Rephrase !PyErr_Occurred() comment: may=>canVictor Stinner2017-01-181-1/+1
| | | | Issue #29259.
* PyCFunction_Call() now calls _PyCFunction_FastCallDict()Victor Stinner2017-01-181-70/+5
| | | | | | | | | | Issue #29259. We had 3 versions of similar code: * PyCFunction_Call() * _PyCFunction_FastCallDict() * _PyCFunction_FastCallKeywords() PyCFunction_Call() now calls _PyCFunction_FastCallDict() to factorize the code.
* Fix _PyMethodDef_RawFastCallDict() argument parsingVictor Stinner2017-01-181-14/+16
| | | | | | | | | Issue #29259: * Move also the !PyErr_Occurred() assertion to the top, similar to other functions. * Fix also comment/error messages: the function was renamed to _PyMethodDef_RawFastCallDict()
* Optimize methoddescr_call(): avoid temporary PyCFunctionVictor Stinner2017-01-181-15/+24
| | | | | | Issue #29259, #29263. methoddescr_call() creates a PyCFunction object, call it and the destroy it. Add a new _PyMethodDef_RawFastCallDict() method to avoid the temporary PyCFunction object.
* Remove unused func parameter of _PyStack_UnpackDict()Victor Stinner2017-01-181-2/+1
| | | | Issue #29259.
* _PyStack_UnpackDict() now returns -1 on errorVictor Stinner2017-01-171-2/+2
| | | | | Issue #29286. Change _PyStack_UnpackDict() prototype to be able to notify of failure when args is NULL.
* Optimize _PyCFunction_FastCallKeywords()Victor Stinner2017-01-161-36/+131
| | | | | | | | | | | | | | Issue #29259: Write fast path in _PyCFunction_FastCallKeywords() for METH_FASTCALL, avoid the creation of a temporary dictionary for keyword arguments. Cleanup also _PyCFunction_FastCallDict(): * Don't dereference func before checking that it's not NULL * Move code to raise the "no keyword argument" exception into a new no_keyword_error label. Update python-gdb.py for the change.
* Issue #28959: Added private macro PyDict_GET_SIZE for retrieving the size of ↵Serhiy Storchaka2016-12-161-4/+5
| | | | dict.
* Fix warning in _PyCFunction_FastCallKeywords()Victor Stinner2016-09-121-2/+1
| | | | Issue #28105.
* Document kwnames in _PyObject_FastCallKeywords() and _PyStack_AsDict()Victor Stinner2016-09-121-0/+5
| | | | Issue #27213.
* Revert change f860b7a775c5Victor Stinner2016-09-121-1/+1
| | | | | Revert change "Issue #27213: Reintroduce checks in _PyStack_AsDict()", pushed by mistake.
* ssue #27213: Reintroduce checks in _PyStack_AsDict()Victor Stinner2016-09-121-1/+1
|
* Issue #27213: Fixed different issues with reworked CALL_FUNCTION* opcodes.Serhiy Storchaka2016-09-111-1/+1
| | | | | | | | | | | * 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.
* Add METH_FASTCALL calling conventionVictor Stinner2016-09-101-0/+24
| | | | | | | | | | | 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.
* Issue #27810: Add _PyCFunction_FastCallKeywords()Victor Stinner2016-09-091-0/+26
| | | | | 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.
* Use Py_ssize_t type for number of argumentsVictor Stinner2016-08-241-2/+7
| | | | | Issue #27848: use Py_ssize_t rather than C int for the number of function positional and keyword arguments.
* _PyFunction_FastCallDict() supports keyword argsVictor Stinner2016-08-221-3/+3
| | | | | | | | Issue #27809: * Rename _PyFunction_FastCall() to _PyFunction_FastCallDict() * Rename _PyCFunction_FastCall() to _PyCFunction_FastCallDict() * _PyFunction_FastCallDict() now supports keyword arguments
* Add _PyObject_FastCall()Victor Stinner2016-08-191-0/+93
| | | | | | | | | | | | | | | | | 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
* More typos in 3.5 documentation and commentsMartin Panter2015-10-071-1/+1
|
* Merge 3.4Andrew Svetlov2015-04-271-1/+1
|\
| * Issue #21354: PyCFunction_New function is exposed by python DLL again.Andrew Svetlov2015-04-271-1/+1
| |
* | Issue #23571: _Py_CheckFunctionResult() now gives the name of the functionVictor Stinner2015-03-211-1/+1
| | | | | | | | | | | | | | | | | | | | | | which returned an invalid result (result+error or no result without error) in the exception message. Add also unit test to check that the exception contains the name of the function. Special case: the final _PyEval_EvalFrameEx() check doesn't mention the function since it didn't execute a single function but a whole frame.
* | Issue #23571: PyObject_Call(), PyCFunction_Call() and call_function() nowVictor Stinner2015-03-061-49/+52
| | | | | | | | | | | | | | | | | | | | | | raise a SystemError if a function returns a result and raises an exception. The SystemError is chained to the previous exception. Refactor also PyObject_Call() and PyCFunction_Call() to make them more readable. Remove some checks which became useless (duplicate checks). Change reviewed by Serhiy Storchaka.
* | Issue #22116: C functions and methods (of the 'builtin_function_or_method' ↵Antoine Pitrou2014-08-061-1/+5
|/ | | | type) can now be weakref'ed. Patch by Wei Wu.
* Issue #20530: Argument Clinic's signature format has been revised again.Larry Hastings2014-02-091-2/+2
| | | | | | | The new syntax is highly human readable while still preventing false positives. The syntax also extends Python syntax to denote "self" and positional-only parameters, allowing inspect.Signature objects to be totally accurate for all supported builtins in Python 3.4.
* Issue #20326: Argument Clinic now uses a simple, unique signature toLarry Hastings2014-01-281-6/+2
| | | | | | | | | | annotate text signatures in docstrings, resulting in fewer false positives. "self" parameters are also explicitly marked, allowing inspect.Signature() to authoritatively detect (and skip) said parameters. Issue #20326: Argument Clinic now generates separate checksums for the input and output sections of the block, allowing external tools to verify that the input has not changed (and thus the output is not out-of-date).
* Issue #20189: Four additional builtin types (PyTypeObject,Larry Hastings2014-01-241-61/+6
| | | | | | 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.
* Silence expression result unused warnings with clang.Christian Heimes2013-12-041-1/+1
| | | | | | | | | | | | The PyObject_INIT() macros returns obj: ../cpython/Objects/methodobject.c:32:23: warning: expression result unused [-Wunused-value] PyObject_INIT(op, &PyCFunction_Type); ^~ ../cpython/Include/objimpl.h:139:69: note: expanded from macro 'PyObject_INIT' ( Py_TYPE(op) = (typeobj), _Py_NewReference((PyObject *)(op)), (op) ) ^ 1 warning generated.
* Make built-in methods picklable through the reduce protocol.Alexandre Vassalotti2013-11-241-1/+21
|
* Issue #19674: inspect.signature() now produces a correct signatureLarry Hastings2013-11-231-5/+66
| | | | for some builtins.
* Issue #18408: In debug mode, PyCFunction_Call() now checks if an exception wasVictor Stinner2013-07-111-7/+23
| | | | | raised if the result is NULL to help to find bugs in C mode (get the error earlier than the SystemError in ceval.c).
* Fix supernumerary 's' in sys._debugmallocstats() output.Antoine Pitrou2013-04-111-1/+1
|\
| * Fix supernumerary 's' in sys._debugmallocstats() output.Antoine Pitrou2013-04-111-1/+1
| |
* | Fix the advertised size of PyCFunctionObjects in sys._debugmallocstats().Antoine Pitrou2012-12-301-2/+2
|\ \ | |/
| * Fix the advertised size of PyCFunctionObjects in sys._debugmallocstats().Antoine Pitrou2012-12-301-2/+2
| |
* | Fix compilation error for #15422Andrew Svetlov2012-12-261-0/+3
| |
* | Issue #15422: get rid of PyCFunction_New macroAndrew Svetlov2012-12-251-14/+6
|/
* Issue #14785: Add sys._debugmallocstats() to help debug low-level memory ↵David Malcolm2012-06-221-0/+9
| | | | allocation issues
* Issue #13577: Built-in methods and functions now have a __qualname__.Antoine Pitrou2011-12-231-4/+40
| | | | Patch by sbt.
* Replace Py_NotImplemented returns with the macro form Py_RETURN_NOTIMPLEMENTED.Brian Curtin2011-08-111-2/+1
| | | | The macro was introduced in #12724.
* make hashes always the size of pointers; introduce Py_hash_t #9778Benjamin Peterson2010-10-171-2/+2
|