summaryrefslogtreecommitdiff
path: root/Objects/funcobject.c
AgeCommit message (Collapse)AuthorLines
2016-09-17Issue #28139: Fix messed up indentationMartin Panter-8/+12
Also update the classmethod and staticmethod doc strings and comments to match the RST documentation.
2016-04-10Issue #26200: Added Py_SETREF and replaced Py_XSETREF with Py_SETREFSerhiy Storchaka-1/+1
in places where Py_DECREF was used.
2016-04-06Issue #22570: Renamed Py_SETREF to Py_XSETREF.Serhiy Storchaka-3/+3
2015-12-24Issue #20440: Massive replacing unsafe attribute setting code with specialSerhiy Storchaka-6/+3
macro Py_SETREF.
2012-02-19use Py_CLEARBenjamin Peterson-3/+1
2010-05-09Untabify C files. Will watch buildbots.Antoine Pitrou-581/+581
2009-09-01remove the check that classmethod's argument is a callableBenjamin Peterson-6/+0
2009-06-25#2016 Fix a crash in function call when the **kwargs dictionary is mutatedAmaury Forgeot d'Arc-10/+11
during the function call setup. This even gives a slight speedup, probably because tuple allocation is faster than PyMem_NEW.
2009-05-29Issue 5982: Classmethod and staticmethod expose wrapped function with __func__.Raymond Hettinger-2/+12
2008-06-09This reverts r63675 based on the discussion in this thread:Gregory P. Smith-8/+8
http://mail.python.org/pipermail/python-dev/2008-June/079988.html Python 2.6 should stick with PyString_* in its codebase. The PyBytes_* names in the spirit of 3.0 are available via a #define only. See the email thread.
2008-05-26Renamed PyString to PyBytesChristian Heimes-8/+8
2007-12-19#1629: Renamed Py_Size, Py_Type and Py_Refcnt to Py_SIZE, Py_TYPE and ↵Christian Heimes-4/+4
Py_REFCNT. Macros for b/w compatibility are available.
2007-11-22Backport of the PCbuild9 directory from the py3k branch.Christian Heimes-3/+3
I've finished the last task for the PCbuild9 directory today. I don't think there is much left to do. Now you can all play around with the shiny new VS 2008 and try the PGO builds. I was able to get a speed improvement of about 10% on py3k. Have fun! :)
2007-07-21PEP 3123: Provide forward compatibility with Python 3.0, while keepingMartin v. Löwis-10/+7
backwards compatibility. Add Py_Refcnt, Py_Type, Py_Size, and PyVarObject_HEAD_INIT.
2007-05-27Add the new function object attribute names from py3k.Neal Norwitz-3/+10
2006-08-12Whoops, how did that get in there. :-) Revert all the parts of 51227 that ↵Neal Norwitz-3/+2
were not supposed to go it. Only Modules/_ctypes/cfields.c was supposed to be changed
2006-08-12Check returned pointer is valid.Neal Norwitz-2/+3
Klocwork #233
2006-07-27Closure can't be NULL at this point since we know it's a tuple.Neal Norwitz-1/+1
Reported by Klocwork # 74.
2006-07-16PyFunction_SetDefaults() is documented as taking None or a tuple.Neal Norwitz-2/+2
A NULL would crash the PyTuple_Check(). Now make NULL return a SystemError. Reported by Klocwork #73.
2006-04-15Use Py_VISIT in all tp_traverse methods, instead of traversing manually orThomas Wouters-47/+12
using a custom, nearly-identical macro. This probably changes how some of these functions are compiled, which may result in fractionally slower (or faster) execution. Considering the nature of traversal, visiting much of the address space in unpredictable patterns, I'd argue the code readability and maintainability is well worth it ;P
2006-04-15Use Py_CLEAR instead of in-place DECREF/XDECREF or custom macros, forThomas Wouters-3/+1
tp_clear methods.
2006-02-27Revert backwards-incompatible const changes.Martin v. Löwis-1/+1
2006-02-21Make staticmethod and classmethod complain about keyword args.Georg Brandl-0/+4
2006-02-16Revert 42400.Martin v. Löwis-2/+2
2006-02-16Support %zd in PyErr_Format and PyString_FromFormat.Martin v. Löwis-3/+3
2006-02-16Get rid of compiler warnings (gcc 3.3.4 on x86)Neal Norwitz-2/+2
2006-02-15Merge ssize_t branch.Martin v. Löwis-8/+8
2005-12-10Add const to several API functions that take char *.Jeremy Hylton-1/+1
In C++, it's an error to pass a string literal to a char* function without a const_cast(). Rather than require every C++ extension module to put a cast around string literals, fix the API to state the const-ness. I focused on parts of the API where people usually pass literals: PyArg_ParseTuple() and friends, Py_BuildValue(), PyMethodDef, the type slots, etc. Predictably, there were a large set of functions that needed to be fixed as a result of these changes. The most pervasive change was to make the keyword args list passed to PyArg_ParseTupleAndKewords() to be a const char *kwlist[]. One cast was required as a result of the changes: A type object mallocs the memory for its tp_doc slot and later frees it. PyTypeObject says that tp_doc is const char *; but if the type was created by type_new(), we know it is safe to cast to char *.
2005-10-20Merge ast-branch to headJeremy Hylton-2/+4
This change implements a new bytecode compiler, based on a transformation of the parse tree to an abstract syntax defined in Parser/Python.asdl. The compiler implementation is not complete, but it is in stable enough shape to run the entire test suite excepting two disabled tests.
2005-02-17FixMichael W. Hudson-2/+0
[ 1124295 ] Function's __name__ no longer accessible in restricted mode which I introduced with a bit of mindless copy-paste when making __name__ writable. You can't assign to __name__ in restricted mode, which I'm going to pretend was intentional :)
2004-10-28Wrote down the invariants of some common objects whose structure isArmin Rigo-0/+12
exposed in header files. Fixed a few comments in these headers. As we might have expected, writing down invariants systematically exposed a (minor) bug. In this case, function objects have a writeable func_code attribute, which could be set to code objects with the wrong number of free variables. Calling the resulting function segfaulted the interpreter. Added a corresponding test.
2004-08-12This is my patchMichael W. Hudson-4/+32
[ 1004703 ] Make func_name writable plus fixing a couple of nits in the documentation changes spotted by MvL and a Misc/NEWS entry.
2004-07-08Remove unused macros in .c filesNeal Norwitz-2/+0
2004-03-23Intern __name__.Martin v. Löwis-1/+9
2003-06-18SF bug #753451: classmethod abuse --> SystemErrorRaymond Hettinger-0/+6
Check the argument to classmethod for callability. Backport candidate.
2003-05-06SF bug #692959: new.function ignores keyword argumentsRaymond Hettinger-1/+4
2003-04-08Make staticmethods and classmethods participate in GC.Jeremy Hylton-8/+45
If a class was defined inside a function, used a static or class method, and used super() inside the method body, it would be caught in an uncollectable cycle. (Simplified version: The static/class method object would point to a function object with a closure that referred to the class.) Bugfix candidate.
2003-02-18Make __module__ writable except in restricted mode (like for classic classes).Guido van Rossum-1/+1
2003-02-18Make __module__ settable on functions and methods.Jeremy Hylton-1/+1
2003-01-31Provide __module__ attributes for functions defined in C and Python.Jeremy Hylton-0/+28
__module__ is the string name of the module the function was defined in, just like __module__ of classes. In some cases, particularly for C functions, the __module__ may be None. Change PyCFunction_New() from a function to a macro, but keep an unused copy of the function around so that we don't change the binary API. Change pickle's save_global() to use whichmodule() if __module__ is None, but add the __module__ logic to whichmodule() since it might be used outside of pickle.
2002-12-29SF patch #659536: Use PyArg_UnpackTuple where possible.Raymond Hettinger-2/+2
Obtain cleaner coding and a system wide performance boost by using the fast, pre-parsed PyArg_Unpack function instead of PyArg_ParseTuple function which is driven by a format string.
2002-07-11Extend function() to support an optional closure argument.Jeremy Hylton-12/+65
Also, simplify some ref counting for other optional arguments.
2002-06-14SF patch 568629 by Oren Tirosh: types made callable.Guido van Rossum-1/+50
These built-in functions are replaced by their (now callable) type: slice() buffer() and these types can also be called (but have no built-in named function named after them) classobj (type name used to be "class") code function instance instancemethod (type name used to be "instance method") The module "new" has been replaced with a small backward compatibility placeholder in Python. A large portion of the patch simply removes the new module from various platform-specific build recipes. The following binary Mac project files still have references to it: Mac/Build/PythonCore.mcp Mac/Build/PythonStandSmall.mcp Mac/Build/PythonStandalone.mcp [I've tweaked the code layout and the doc strings here and there, and added a comment to types.py about StringTypes vs. basestring. --Guido]
2002-06-13Patch #568124: Add doc string macros.Martin v. Löwis-4/+4
2002-04-12PyObject_Del can now be used as a function designator.Neil Schemenauer-2/+2
2002-04-03Fix the names of the classmethod and staticmethod constructors as passed toFred Drake-2/+2
PyArg_ParseTuple() as part of the format string.
2002-03-18Fix for SF bug 528132 (Armin Rigo): classmethod().__get__() segfaultGuido van Rossum-0/+2
The proper fix is not quite what was submitted; it's really better to take the class of the object passed rather than calling PyMethod_New with NULL pointer args, because that can then cause other core dumps later. I also added a testcase for the fix to classmethods() in test_descr.py. I've already applied this to the 2.2 branch.
2001-12-17Portability fix: Not every compiler implements the extension ofSjoerd Mullender-1/+1
unescaped newlines in strings.
2001-12-17SF patch #493452: docstrings for staticmethod/classmethod (SkipGuido van Rossum-2/+41
Montanaro) (With minor adjustments.)
2001-12-03function_call(): Remove a bogus (and I mean *really* bogus) call toGuido van Rossum-1/+0
Py_DECREF(arg) after the PyErr_NoMemory() call. (Armin Rigo, SF bug #488477.)