summaryrefslogtreecommitdiff
path: root/Objects/funcobject.c
AgeCommit message (Collapse)AuthorLines
2010-05-09Recorded merge of revisions 81029 via svnmerge fromAntoine Pitrou-582/+582
svn+ssh://pythondev@svn.python.org/python/trunk ........ r81029 | antoine.pitrou | 2010-05-09 16:46:46 +0200 (dim., 09 mai 2010) | 3 lines Untabify C files. Will watch buildbots. ........
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.)
2001-10-26Be smarter about clearing the weakref lists for instances, instance methods,Fred Drake-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.
2001-10-05Enable GC for new-style instances. This touches lots of files, sinceGuido van Rossum-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.
2001-09-20Add optional docstrings to getset descriptors. Fortunately, there'sGuido van Rossum-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.
2001-09-20Add optional docstrings to member descriptors. For backwardsGuido van Rossum-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.
2001-09-17Rewrite function attributes to use the generic routines properly.Guido van Rossum-72/+118
This uses the new "restricted" feature of structmember, and getset descriptors for some of the type checks.
2001-08-29Use new GC API.Neil Schemenauer-7/+6
2001-08-24repr's converted to using PyString_FromFormat() instead of sprintf'ingBarry Warsaw-7/+4
into a hardcoded char* buffer. Closes patch #454743.
2001-08-14func_getattro(), func_setattro(): Implement the new semantics forBarry Warsaw-8/+22
setting and deleting a function's __dict__ attribute. Deleting it, or setting it to a non-dictionary result in a TypeError. Note that getting it the first time magically initializes it to an empty dict so that func.__dict__ will always appear to be a dictionary (never None). Closes SF bug #446645.