summaryrefslogtreecommitdiffstats
path: root/Objects/funcobject.c
Commit message (Collapse)AuthorAgeFilesLines
* remove the check that classmethod's argument is a callableBenjamin Peterson2009-09-011-6/+0
|
* #2016 Fix a crash in function call when the **kwargs dictionary is mutatedAmaury Forgeot d'Arc2009-06-251-10/+11
| | | | | | | during the function call setup. This even gives a slight speedup, probably because tuple allocation is faster than PyMem_NEW.
* Issue 5982: Classmethod and staticmethod expose wrapped function with __func__.Raymond Hettinger2009-05-291-2/+12
|
* This reverts r63675 based on the discussion in this thread:Gregory P. Smith2008-06-091-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.
* Renamed PyString to PyBytesChristian Heimes2008-05-261-8/+8
|
* #1629: Renamed Py_Size, Py_Type and Py_Refcnt to Py_SIZE, Py_TYPE and ↵Christian Heimes2007-12-191-4/+4
| | | | Py_REFCNT. Macros for b/w compatibility are available.
* Backport of the PCbuild9 directory from the py3k branch.Christian Heimes2007-11-221-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! :)
* PEP 3123: Provide forward compatibility with Python 3.0, while keepingMartin v. Löwis2007-07-211-10/+7
| | | | | backwards compatibility. Add Py_Refcnt, Py_Type, Py_Size, and PyVarObject_HEAD_INIT.
* Add the new function object attribute names from py3k.Neal Norwitz2007-05-271-3/+10
|
* Whoops, how did that get in there. :-) Revert all the parts of 51227 that ↵Neal Norwitz2006-08-121-3/+2
| | | | were not supposed to go it. Only Modules/_ctypes/cfields.c was supposed to be changed
* Check returned pointer is valid.Neal Norwitz2006-08-121-2/+3
| | | | Klocwork #233
* Closure can't be NULL at this point since we know it's a tuple.Neal Norwitz2006-07-271-1/+1
| | | | Reported by Klocwork # 74.
* PyFunction_SetDefaults() is documented as taking None or a tuple.Neal Norwitz2006-07-161-2/+2
| | | | | | A NULL would crash the PyTuple_Check(). Now make NULL return a SystemError. Reported by Klocwork #73.
* Use Py_VISIT in all tp_traverse methods, instead of traversing manually orThomas Wouters2006-04-151-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
* Use Py_CLEAR instead of in-place DECREF/XDECREF or custom macros, forThomas Wouters2006-04-151-3/+1
| | | | tp_clear methods.
* Revert backwards-incompatible const changes.Martin v. Löwis2006-02-271-1/+1
|
* Make staticmethod and classmethod complain about keyword args.Georg Brandl2006-02-211-0/+4
|
* Revert 42400.Martin v. Löwis2006-02-161-2/+2
|
* Support %zd in PyErr_Format and PyString_FromFormat.Martin v. Löwis2006-02-161-3/+3
|
* Get rid of compiler warnings (gcc 3.3.4 on x86)Neal Norwitz2006-02-161-2/+2
|
* Merge ssize_t branch.Martin v. Löwis2006-02-151-8/+8
|
* Add const to several API functions that take char *.Jeremy Hylton2005-12-101-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 *.
* Merge ast-branch to headJeremy Hylton2005-10-201-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.
* FixMichael W. Hudson2005-02-171-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 :)
* Wrote down the invariants of some common objects whose structure isArmin Rigo2004-10-281-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.
* This is my patchMichael W. Hudson2004-08-121-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.
* Remove unused macros in .c filesNeal Norwitz2004-07-081-2/+0
|
* Intern __name__.Martin v. Löwis2004-03-231-1/+9
|
* SF bug #753451: classmethod abuse --> SystemErrorRaymond Hettinger2003-06-181-0/+6
| | | | | | Check the argument to classmethod for callability. Backport candidate.
* SF bug #692959: new.function ignores keyword argumentsRaymond Hettinger2003-05-061-1/+4
|
* Make staticmethods and classmethods participate in GC.Jeremy Hylton2003-04-081-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.
* Make __module__ writable except in restricted mode (like for classic classes).Guido van Rossum2003-02-181-1/+1
|
* Make __module__ settable on functions and methods.Jeremy Hylton2003-02-181-1/+1
|
* Provide __module__ attributes for functions defined in C and Python.Jeremy Hylton2003-01-311-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.
* SF patch #659536: Use PyArg_UnpackTuple where possible.Raymond Hettinger2002-12-291-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.
* Extend function() to support an optional closure argument.Jeremy Hylton2002-07-111-12/+65
| | | | Also, simplify some ref counting for other optional arguments.
* SF patch 568629 by Oren Tirosh: types made callable.Guido van Rossum2002-06-141-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]
* Patch #568124: Add doc string macros.Martin v. Löwis2002-06-131-4/+4
|
* PyObject_Del can now be used as a function designator.Neil Schemenauer2002-04-121-2/+2
|
* Fix the names of the classmethod and staticmethod constructors as passed toFred Drake2002-04-031-2/+2
| | | | PyArg_ParseTuple() as part of the format string.
* Fix for SF bug 528132 (Armin Rigo): classmethod().__get__() segfaultGuido van Rossum2002-03-181-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.
* Portability fix: Not every compiler implements the extension ofSjoerd Mullender2001-12-171-1/+1
| | | | unescaped newlines in strings.
* SF patch #493452: docstrings for staticmethod/classmethod (SkipGuido van Rossum2001-12-171-2/+41
| | | | | | Montanaro) (With minor adjustments.)
* function_call(): Remove a bogus (and I mean *really* bogus) call toGuido van Rossum2001-12-031-1/+0
| | | | | Py_DECREF(arg) after the PyErr_NoMemory() call. (Armin Rigo, SF bug #488477.)
* Be smarter about clearing the weakref lists for instances, instance methods,Fred Drake2001-10-261-1/+2
| | | | | | and functions: we only need to call PyObject_ClearWeakRefs() if the weakref list is non-NULL. Since these objects are common but weakrefs are still unusual, saving the call at deallocation time makes a lot of sense.
* Enable GC for new-style instances. This touches lots of files, sinceGuido van Rossum2001-10-051-2/+4
| | | | | | | | | | | | | | | | | | | | | | many types were subclassable but had a xxx_dealloc function that called PyObject_DEL(self) directly instead of deferring to self->ob_type->tp_free(self). It is permissible to set tp_free in the type object directly to _PyObject_Del, for non-GC types, or to _PyObject_GC_Del, for GC types. Still, PyObject_DEL was a tad faster, so I'm fearing that our pystone rating is going down again. I'm not sure if doing something like void xxx_dealloc(PyObject *self) { if (PyXxxCheckExact(self)) PyObject_DEL(self); else self->ob_type->tp_free(self); } is any faster than always calling the else branch, so I haven't attempted that -- however those types whose own dealloc is fancier (int, float, unicode) do use this pattern.
* Add optional docstrings to getset descriptors. Fortunately, there'sGuido van Rossum2001-09-201-1/+1
| | | | | | | | | | no backwards compatibility to worry about, so I just pushed the 'closure' struct member to the back -- it's never used in the current code base (I may eliminate it, but that's more work because the getter and setter signatures would have to change.) As examples, I added actual docstrings to the getset attributes of a few types: file.closed, xxsubtype.spamdict.state.
* Add optional docstrings to member descriptors. For backwardsGuido van Rossum2001-09-201-1/+1
| | | | | | | | | | | | | | | compatibility, this required all places where an array of "struct memberlist" structures was declared that is referenced from a type's tp_members slot to change the type of the structure to PyMemberDef; "struct memberlist" is now only used by old code that still calls PyMember_Get/Set. The code in PyObject_GenericGetAttr/SetAttr now calls the new APIs PyMember_GetOne/SetOne, which take a PyMemberDef argument. As examples, I added actual docstrings to the attributes of a few types: file, complex, instance method, super, and xxsubtype.spamlist. Also converted the symtable to new style getattr.
* Rewrite function attributes to use the generic routines properly.Guido van Rossum2001-09-171-72/+118
| | | | | This uses the new "restricted" feature of structmember, and getset descriptors for some of the type checks.
* Use new GC API.Neil Schemenauer2001-08-291-7/+6
|