Commit Graph

171 Commits

Author SHA1 Message Date
Benjamin Peterson 08c5c0bb55 Merged revisions 71163 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk

........
  r71163 | benjamin.peterson | 2009-04-04 11:05:51 -0500 (Sat, 04 Apr 2009) | 1 line

  revert r71159 since it broke the build
........
2009-04-04 16:10:42 +00:00
Matthias Klose db5d6dc6de Merged revisions 71159 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk

........
  r71159 | matthias.klose | 2009-04-04 17:51:23 +0200 (Sa, 04 Apr 2009) | 2 lines

  - Py_DECREF: Add `do { ... } while (0)' to avoid compiler warnings.
........
2009-04-04 15:52:50 +00:00
Benjamin Peterson 14cb6bcf2b sort of backport 66038 by aliasing PyObject_Bytes to PyObject_Str 2008-08-26 17:08:40 +00:00
Guido van Rossum 69ed1011aa Hopeful fix for issue 1878: remove Py_TPFLAGS_HAVE_VERSION_TAG from
Py_TPFLAGS_DEFAULT when not building the core.
2008-08-19 20:13:02 +00:00
Martin v. Löwis f91d46a17d Issue #3139: Make buffer-interface thread-safe wrt. PyArg_ParseTuple,
by denying s# to parse objects that have a releasebuffer procedure,
and introducing s*.

More module might need to get converted to use s*.
2008-08-12 14:49:50 +00:00
Nick Coghlan 53663a695e Issue 2235: __hash__ is once again inherited by default, but inheritance can be blocked explicitly so that collections.Hashable remains meaningful 2008-07-15 14:27:37 +00:00
Alexandre Vassalotti 8d412f36b5 Issue #3274: Use a less common identifier for the temporary variable
in Py_CLEAR().
2008-07-13 20:42:44 +00:00
Raymond Hettinger 9c437af4eb Revert 64424, 64438, and 64439. 2008-06-24 22:46:07 +00:00
Raymond Hettinger e3ae655edf Make bin() implementation parallel oct() and hex() so that int/long subclasses can override or so that other classes can support. 2008-06-20 04:18:15 +00:00
Gregory P. Smith dd96db63f6 This reverts r63675 based on the discussion in this thread:
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-06-09 04:58:54 +00:00
Travis E. Oliphant 0144f27602 Remove locking part of new buffer protocol. 2008-06-06 22:39:47 +00:00
Georg Brandl 74a1deaab3 #2989: add PyType_Modified(). 2008-05-28 11:21:39 +00:00
Christian Heimes 593daf545b Renamed PyString to PyBytes 2008-05-26 12:51:38 +00:00
Martin v. Löwis 19dfa3e71a Remove Py_Refcnt, Py_Type, Py_Size, as they were added only
for backwards compatibility, yet 2.5 did not have them at all.
2008-04-24 13:16:36 +00:00
Benjamin Peterson a45ab9f37d NIL => NULL 2008-03-28 23:11:01 +00:00
Travis E. Oliphant 33451d8ab1 Add necessary headers to back-port new buffer protocol to Python 2.6 2008-03-17 17:36:12 +00:00
Jeffrey Yasskin 960b9b7a2f Move abc._Abstract into object by adding a new flag Py_TPFLAGS_IS_ABSTRACT,
which forbids constructing types that have it set. The effect is to speed

  ./python.exe -m timeit -s 'import abc' -s 'class Foo(object): __metaclass__ = abc.ABCMeta' 'Foo()'

up from 2.5us to 0.201us. This fixes issue 1762.
2008-02-28 04:45:36 +00:00
Christian Heimes 908caac52e Added clear cache methods to clear the internal type lookup cache for ref leak test runs. 2008-01-27 23:34:59 +00:00
Amaury Forgeot d'Arc e4c270c2a8 Re-apply patch #1700288 (first applied in r59931, rolled back in r59940)
now that ctypes uses a more supported method to create types:

Method cache optimization, by Armin Rigo, ported to 2.6 by Kevin Jacobs.
2008-01-14 00:29:41 +00:00
Georg Brandl d1c131a6e3 Back out r59931 - test_ctypes fails with it. 2008-01-13 15:04:05 +00:00
Georg Brandl 27e26ec418 Patch #1700288: Method cache optimization, by Armin Rigo, ported to
2.6 by Kevin Jacobs.
2008-01-12 13:47:57 +00:00
Christian Heimes e93237dfcc #1629: Renamed Py_Size, Py_Type and Py_Refcnt to Py_SIZE, Py_TYPE and Py_REFCNT. Macros for b/w compatibility are available. 2007-12-19 02:37:44 +00:00
Martin v. Löwis 6819210b9e PEP 3123: Provide forward compatibility with Python 3.0, while keeping
backwards compatibility. Add Py_Refcnt, Py_Type, Py_Size, and
PyVarObject_HEAD_INIT.
2007-07-21 06:55:02 +00:00
Neal Norwitz ee3a1b5244 Variation of patch # 1624059 to speed up checking if an object is a subclass
of some of the common builtin types.

Use a bit in tp_flags for each common builtin type.  Check the bit
to determine if any instance is a subclass of these common types.
The check avoids a function call and O(n) search of the base classes.
The check is done in the various Py*_Check macros rather than calling
PyType_IsSubtype().

All the bits are set in tp_flags when the type is declared
in the Objects/*object.c files because PyType_Ready() is not called
for all the types.  Should PyType_Ready() be called for all types?
If so and the change is made, the changes to the Objects/*object.c files
can be reverted (remove setting the tp_flags).  Objects/typeobject.c
would also have to be modified to add conditions
for Py*_CheckExact() in addition to each the PyType_IsSubtype check.
2007-02-25 19:44:48 +00:00
Neal Norwitz 8a87f5d37e Patch #1538606, Patch to fix __index__() clipping.
I modified this patch some by fixing style, some error checking, and adding
XXX comments.  This patch requires review and some changes are to be expected.
I'm checking in now to get the greatest possible review and establish a
baseline for moving forward.  I don't want this to hold up release if possible.
2006-08-12 17:03:09 +00:00
Martin v. Löwis 45294a9562 Remove types from type_list if they have no objects
and unlist_types_without_objects is set.
Give dump_counts a FILE* argument.
2006-04-18 06:24:08 +00:00
Tim Peters 9d2ced8fa0 There were no comments explaining what Py_CLEAR() did or
why it's important.  Now there are ;-)

If someone else hasn't already, I'll add a Py_CLEAR cleanup
task to the TODO Wiki next.
2006-04-15 02:14:03 +00:00
Armin Rigo e170937af6 Ignore the references to the dummy objects used as deleted keys
in dicts and sets when computing the total number of references.
2006-04-12 17:06:05 +00:00
Guido van Rossum 38fff8c4e4 Checking in the code for PEP 357.
This was mostly written by Travis Oliphant.
I've inspected it all; Neal Norwitz and MvL have also looked at it
(in an earlier incarnation).
2006-03-07 18:50:55 +00:00
Neal Norwitz 4281cef205 Use Py_ssize_t for _Py_RefTotal.
I tried to handle Win64 properly, but please review.
2006-03-04 19:58:13 +00:00
Martin v. Löwis e36dce69dd Make ob_refcnt and tp_maxalloc (and friends) Py_ssize_t. 2006-03-01 04:02:43 +00:00
Martin v. Löwis 15e62742fa Revert backwards-incompatible const changes. 2006-02-27 16:46:16 +00:00
Georg Brandl c255c7bef7 Bug #1086854: Rename PyHeapType members adding ht_ prefix. 2006-02-20 22:27:28 +00:00
Martin v. Löwis 97c65a8068 Use Py_ssize_t for field sizes and offsets. 2006-02-16 14:24:38 +00:00
Martin v. Löwis 18e165558b Merge ssize_t branch. 2006-02-15 17:27:45 +00:00
Jeremy Hylton af68c874a6 Add const to several API functions that take char *.
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-12-10 18:50:16 +00:00
Neil Schemenauer cf52c07843 Change the %s format specifier for str objects so that it returns a
unicode instance if the argument is not an instance of basestring and
calling __str__ on the argument returns a unicode instance.
2005-08-12 17:34:58 +00:00
Tim Peters f4aca755bc A static swapped_op[] array was defined in 3 different C files, & I think
I need to define it again.  Bite the bullet and define it once as an
extern, _Py_SwappedOp[].
2004-09-23 02:39:37 +00:00
Raymond Hettinger 75ccea3777 SF patch #1020188: Use Py_CLEAR where necessary to avoid crashes
(Contributed by Dima Dorfman)
2004-09-01 07:02:44 +00:00
Tim Peters 5980ff2d92 SF bug 994255: Py_RETURN_NONE causes too much warnings
Rewrote Py_RETURN_{NONE, TRUE, FALSE} to expand to comma expressions
rather than "do {} while(0)" thingies.  The OP complained because he
likes using MS /W4 sometimes, and then all his uses of these things
generate nuisance warnings about testing a constant expression (in
the "while(0)" part).  Comma expressions don't have this problem
(although it's a lucky accident that comma expressions suffice for these
macros!).
2004-07-22 01:46:43 +00:00
Jim Fulton 8c5aeaa277 Implemented a new Py_CLEAR macro. This macro should be used when
decrementing the refcount of variables that might be accessed as a
result of calling Python
2004-07-14 19:07:35 +00:00
Thomas Heller 1328b52c6f Two new public API functions, Py_IncRef and Py_DecRef. Useful for
dynamic embedders of Python.
2004-04-22 17:23:49 +00:00
Alex Martelli 721b776175 fixed buggy comment as per SF bug #827856
(same as commit of Sun Nov 2 to the release23-maint branch)
2003-11-09 16:38:39 +00:00
Brett Cannon 4b17e3993b Modify the Py_RETURN_* macros to be of the form ``do {...} while (0)`` in order
to handle situations like ``if (foo) Py_RETURN_NONE else ...``.
2003-10-19 22:58:11 +00:00
Brett Cannon 26b3a7b82c Modified the Py_RETURN_* macros by having the statements surrounded by {} in
order to prevent any unexpected surprises from someone using them in a
conditional without using curly braces (e.g., ``if (foo) Py_RETURN_TRUE``.
2003-10-19 21:31:43 +00:00
Brett Cannon d05235ec49 Defined macros Py_RETURN_(TRUE|FALSE|NONE) as helper functions for returning
the specified value.  All three Py_INCREF the singleton and then return it.
2003-10-19 21:19:40 +00:00
Christian Tismer 661a9e3e5b After Raymond's remark, I changed the Stackless bits to
two fixed bits, position 15 and 16. It is right, why should these
be elsewhere.
2003-05-23 12:47:36 +00:00
Christian Tismer c26ff41d3d Generalized my type flags structure extension without being specific about
the purpose. Increased my claim to two bits, hoping that nobody
will complain about it. I'm taking the highest two bits, whatever
the integer word size may be.
2003-05-23 03:33:35 +00:00
Christian Tismer 6695ba89de Preserved one bit in type objects for Stackless.
The presence of this bit controls, whether there
are special fields for non-recursive calls.
2003-05-20 15:14:31 +00:00
Tim Peters 269b2a6797 _Py_PrintReferences(): Changed to print object address at start of each
new line.

New pvt API function _Py_PrintReferenceAddresses():  Prints only the
addresses and refcnts of the live objects.  This is always safe to call,
because it has no dependence on Python's C API.

Py_Finalize():  If envar PYTHONDUMPREFS is set, call (the new)
_Py_PrintReferenceAddresses() right before dumping final pymalloc stats.
We can't print the reprs of the objects here because too much of the
interpreter has been shut down.  You need to correlate the addresses
displayed here with the object reprs printed by the earlier
PYTHONDUMPREFS call to _Py_PrintReferences().
2003-04-17 19:52:29 +00:00