summaryrefslogtreecommitdiff
path: root/Objects/methodobject.c
AgeCommit message (Collapse)AuthorLines
2018-12-11bpo-35444: Fix error handling when fail to look up builtin "getattr". ↵Serhiy Storchaka-5/+2
(GH-11047) (GH-11107) (cherry picked from commit bb86bf4c4eaa30b1f5192dab9f389ce0bb61114d)
2017-09-07bpo-30860: Consolidate stateful runtime globals. (#3397)Eric Snow-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).
2017-02-12bpo-29524: Add Objects/call.c file (#12)Victor Stinner-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.
2017-02-10Backed out changeset f23fa1f7b68fVictor Stinner-0/+323
Sorry, I didn't want to push this change before the review :-( I was pushing a change into the 2.7 branch.
2017-02-10Issue #29465: Add Objects/call.c fileVictor Stinner-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.
2017-02-09Fix PyCFunction_Call() performance issueVictor Stinner-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.
2017-02-08Issue #29306: Fix usage of Py_EnterRecursiveCall()Victor Stinner-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
2017-02-03Issue #29263: LOAD_METHOD support for C methodsINADA Naoki-23/+30
Calling builtin method is at most 10% faster.
2017-01-18Cleanup _PyMethodDef_RawFastCallDict()Victor Stinner-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.
2017-01-18Rephrase !PyErr_Occurred() comment: may=>canVictor Stinner-1/+1
Issue #29259.
2017-01-18PyCFunction_Call() now calls _PyCFunction_FastCallDict()Victor Stinner-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.
2017-01-18Fix _PyMethodDef_RawFastCallDict() argument parsingVictor Stinner-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()
2017-01-18Optimize methoddescr_call(): avoid temporary PyCFunctionVictor Stinner-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.
2017-01-18Remove unused func parameter of _PyStack_UnpackDict()Victor Stinner-2/+1
Issue #29259.
2017-01-17_PyStack_UnpackDict() now returns -1 on errorVictor Stinner-2/+2
Issue #29286. Change _PyStack_UnpackDict() prototype to be able to notify of failure when args is NULL.
2017-01-16Optimize _PyCFunction_FastCallKeywords()Victor Stinner-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.
2016-12-16Issue #28959: Added private macro PyDict_GET_SIZE for retrieving the size of ↵Serhiy Storchaka-4/+5
dict.
2016-09-12Fix warning in _PyCFunction_FastCallKeywords()Victor Stinner-2/+1
Issue #28105.
2016-09-12Document kwnames in _PyObject_FastCallKeywords() and _PyStack_AsDict()Victor Stinner-0/+5
Issue #27213.
2016-09-12Revert change f860b7a775c5Victor Stinner-1/+1
Revert change "Issue #27213: Reintroduce checks in _PyStack_AsDict()", pushed by mistake.
2016-09-12ssue #27213: Reintroduce checks in _PyStack_AsDict()Victor Stinner-1/+1
2016-09-12Issue #27213: Fixed different issues with reworked CALL_FUNCTION* opcodes.Serhiy Storchaka-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.
2016-09-09Add METH_FASTCALL calling conventionVictor Stinner-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.
2016-09-09Issue #27810: Add _PyCFunction_FastCallKeywords()Victor Stinner-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.
2016-08-25Use Py_ssize_t type for number of argumentsVictor Stinner-2/+7
Issue #27848: use Py_ssize_t rather than C int for the number of function positional and keyword arguments.
2016-08-22_PyFunction_FastCallDict() supports keyword argsVictor Stinner-3/+3
Issue #27809: * Rename _PyFunction_FastCall() to _PyFunction_FastCallDict() * Rename _PyCFunction_FastCall() to _PyCFunction_FastCallDict() * _PyFunction_FastCallDict() now supports keyword arguments
2016-08-19Add _PyObject_FastCall()Victor Stinner-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
2015-10-07More typos in 3.5 documentation and commentsMartin Panter-1/+1
2015-04-27Merge 3.4Andrew Svetlov-1/+1
2015-04-27Issue #21354: PyCFunction_New function is exposed by python DLL again.Andrew Svetlov-1/+1
2015-03-21Issue #23571: _Py_CheckFunctionResult() now gives the name of the functionVictor Stinner-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.
2015-03-06Issue #23571: PyObject_Call(), PyCFunction_Call() and call_function() nowVictor Stinner-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.
2014-08-06Issue #22116: C functions and methods (of the 'builtin_function_or_method' ↵Antoine Pitrou-1/+5
type) can now be weakref'ed. Patch by Wei Wu.
2014-02-08Issue #20530: Argument Clinic's signature format has been revised again.Larry Hastings-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.
2014-01-28Issue #20326: Argument Clinic now uses a simple, unique signature toLarry Hastings-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).
2014-01-24Issue #20189: Four additional builtin types (PyTypeObject,Larry Hastings-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.
2013-12-04Silence expression result unused warnings with clang.Christian Heimes-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.
2013-11-24Make built-in methods picklable through the reduce protocol.Alexandre Vassalotti-1/+21
2013-11-23Issue #19674: inspect.signature() now produces a correct signatureLarry Hastings-5/+66
for some builtins.
2013-07-11Issue #18408: In debug mode, PyCFunction_Call() now checks if an exception wasVictor Stinner-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).
2013-04-11Fix supernumerary 's' in sys._debugmallocstats() output.Antoine Pitrou-1/+1
2013-04-11Fix supernumerary 's' in sys._debugmallocstats() output.Antoine Pitrou-1/+1
2012-12-30Fix the advertised size of PyCFunctionObjects in sys._debugmallocstats().Antoine Pitrou-2/+2
2012-12-30Fix the advertised size of PyCFunctionObjects in sys._debugmallocstats().Antoine Pitrou-2/+2
2012-12-26Fix compilation error for #15422Andrew Svetlov-0/+3
2012-12-25Issue #15422: get rid of PyCFunction_New macroAndrew Svetlov-14/+6
2012-06-22Issue #14785: Add sys._debugmallocstats() to help debug low-level memory ↵David Malcolm-0/+9
allocation issues
2011-12-23Issue #13577: Built-in methods and functions now have a __qualname__.Antoine Pitrou-4/+40
Patch by sbt.
2011-08-10Replace Py_NotImplemented returns with the macro form Py_RETURN_NOTIMPLEMENTED.Brian Curtin-2/+1
The macro was introduced in #12724.
2010-10-17make hashes always the size of pointers; introduce Py_hash_t #9778Benjamin Peterson-2/+2