Commit Graph

1944 Commits

Author SHA1 Message Date
Raymond Hettinger f466793fcc SF patch 703666: Several objects don't decref tmp on failure in subtype_new
Submitted By: Christopher A. Craig

Fillin some missing decrefs.
2003-06-28 20:04:25 +00:00
Jeremy Hylton 3e3159ce6a Require that __nonzero__() return a bool or exactly an int. 2003-06-27 17:38:27 +00:00
Jeremy Hylton 090a3495b3 Check return type of __nonzero__() method.
The language reference says you must return an int or a bool.  This
fix limits the scope of SF bug 759227 (infinite recursion) to
subclasses of int.
2003-06-27 16:46:45 +00:00
Walter Dörwald 03f6c54359 Whitespace normalization. 2003-06-25 13:12:18 +00:00
Walter Dörwald 9ff3f03c3e Fix whitespace. 2003-06-18 14:17:01 +00:00
Raymond Hettinger be9715398b SF bug #753451: classmethod abuse --> SystemError
Check the argument to classmethod for callability.

Backport candidate.
2003-06-18 01:13:41 +00:00
Walter Dörwald 5ecd6c4db2 Fix typo in comment. 2003-06-17 20:22:24 +00:00
Walter Dörwald e8049befdf Use _PyEval_SliceIndex to handle list.index() calls with
huge start and stop arguments. Add tests.
2003-06-17 19:27:39 +00:00
Walter Dörwald e0a1bb6341 Whitespace normalization. 2003-06-17 15:48:11 +00:00
Guido van Rossum 2743d87d79 Fix sloppy index() implementation:
- don't use min() and max()
- interpret negative start/stop argument like negative slice indices
2003-06-17 14:25:14 +00:00
Raymond Hettinger d05abdec7b SF #754014: list.index() should accept optional start, end arguments
Also, modified UserList.index() to match and expanded the related tests.
2003-06-17 05:05:49 +00:00
Guido van Rossum 59195fdf40 - SF patch 751998 fixes an unwanted side effect of the previous fix
for SF bug 742860 (the next item).
2003-06-13 20:54:40 +00:00
Brett Cannon 10147f7d13 Fixed a comment. 2003-06-11 20:50:33 +00:00
Neil Schemenauer 4e3363e884 Warn about creating global variables by __setattr__ that shadow builtin
names.  Unfortunately, this is not bulletproof since the module
dictionary can be modified directly.
2003-06-09 18:42:19 +00:00
Neal Norwitz e2fdc61004 Fix SF #749831, copy raises SystemError when getstate raises exception 2003-06-08 13:19:58 +00:00
Guido van Rossum 1987c6693b Fix for SF 742911. We now clear the weakrefs *before* calling __del__
or emptying __dict__, just as we do for classic classes.
2003-05-29 14:29:23 +00:00
Raymond Hettinger e509b2ad24 Add notes on use cases with paired accesses to the same key. 2003-05-28 14:10:46 +00:00
Raymond Hettinger e8b0f0461b * Beefed-up tests
* Allow tuple re-use
* Call tp_iternext directly
2003-05-28 14:05:34 +00:00
Tim Peters e87568dd9a SF bug 705231: Assertion failed, python aborts.
float_pow():  Don't let the platform pow() raise -1.0 to an integer power
anymore; at least glibc gets it wrong in some cases.  Note that
math.pow() will continue to deliver wrong (but platform-native) results
in such cases.
2003-05-24 20:18:24 +00:00
Tim Peters 3cfe75470d PyType_Ready(): Complain if the type is a base type, and gc'able, and
tp_free is NULL or PyObject_Del at the end.  Because it's a base type
it must call tp_free in its dealloc function, and because it's gc'able
it must not call PyObject_Del.

inherit_slots():  Don't inherit tp_free unless the type and its base
agree about whether they're gc'able.  If the type is gc'able and the
base is not, and the base uses the default PyObject_Del for its
tp_free, give the type PyObject_GC_Del for its tp_free (the appropriate
default for a gc'able type).

cPickle.c:  The Pickler and Unpickler types claim to be base classes
and gc'able, but their dealloc functions didn't call tp_free.
Repaired that.  Also call PyType_Ready() on these typeobjects, so
that the correct (PyObject_GC_Del) default memory-freeing function
gets plugged into these types' tp_free slots.
2003-05-21 21:29:48 +00:00
Raymond Hettinger 6624e68546 SF bug #604716: faster [None]*n or []*n
Fulfilled request to special case repetitions of lists of length 0 or 1.
2003-05-21 05:58:46 +00:00
Brett Cannon be67d87e4d Fixing the previous patch to have the changes be to the proper docstrings. 2003-05-20 02:40:12 +00:00
Brett Cannon 154da9b7e2 Fix docstrings for __(get|set|del)slice__ to mention that negative indices are not supported. 2003-05-20 02:30:04 +00:00
Martin v. Löwis 415da6e0b2 Only encode Unicode objects when printing them raw. 2003-05-18 12:56:25 +00:00
Martin v. Löwis 9a3a9f7791 Consider \U-escapes in raw-unicode-escape. Fixes #444514. 2003-05-18 12:31:09 +00:00
Jim Fulton 19472b2075 Removed the out of date and no-longer-referenced xxobject.c example
type implementation.  Note that this same example lives in
Modules/xxmodule.c. (It is just as out of date there.)
2003-05-16 13:34:33 +00:00
Martin v. Löwis a94568a753 Patch #734231: Update RiscOS support. In particular, correct
riscospath.extsep, and use os.extsep throughout.
2003-05-10 07:36:56 +00:00
Martin v. Löwis 5467d4c0e3 Patch #612627: Add encoding attribute to file objects, and determine
the terminal encoding on Windows and Unix.
2003-05-10 07:10:12 +00:00
Raymond Hettinger 686b14d7ad SF bug #730296: Unexpected Changes in list Iterator
Reverted a Py2.3b1 change to iterator in subclasses of list and tuple.
They had been changed to use __getitem__ whenever it had been overriden
in the subclass.

This caused some usabilty and performance problems.  Also, it was
inconsistent with the rest of python where many container methods
access the underlying object directly without first checking for
an overridden getter.  Users needing a change in iterator behavior
should override it directly.
2003-05-07 01:28:47 +00:00
Raymond Hettinger c8d2290c8c SF patch #729395: Dictionary tuning
Adjust resize argument for dict.update() and dict.copy().
Extends the previous change to dict.__setitem__().
2003-05-07 00:49:40 +00:00
Raymond Hettinger 8657845e02 SF bug #692959: new.function ignores keyword arguments 2003-05-06 09:01:41 +00:00
Raymond Hettinger 3539f6b895 SF patch #729395: Dictionary tuning
* Increase dictionary growth rate resulting in more sparse dictionaries,
  fewer lookup collisions, increased memory use, and better cache
  performance.  For dicts with over 50k entries, keep the current
  growth rate in case an application is suffering from tight memory
  constraints.

* Set the most common case (no resize) to fall-through the test.
2003-05-05 22:22:10 +00:00
Raymond Hettinger 4887a12133 Add notes from python-dev about readonly dictionaries. 2003-05-05 21:31:51 +00:00
Tim Peters c7bc0b98e7 SF patch 730594: assert from longobject.c, line 1215.
Some version of gcc in the "RTEMS port running on the Coldfire (m5200)
processor" generates bad code for a loop in long_from_binary_base(),
comparing the wrong half of an int to a short.  The patch changes the
decl of the short temp to be an int temp instead.  This "simplifies"
the code enough that gcc no longer blows it.
2003-05-05 20:39:43 +00:00
Raymond Hettinger 258dfebfb4 * Note how dummy entry re-use benefits use cases with interspersed deletes
and adds.

* Note that dictionary iteration is negatively impacted by additional
  sparseness.
2003-05-04 21:25:19 +00:00
Tim Peters 015dd82136 Somewhere along the way, the softspace attr of file objects became read-
only.  Repaired, and added new tests to test_file.py.
2003-05-04 04:16:52 +00:00
Martin v. Löwis cd12bfc142 Patch #708604: Check more function results. Will backport to 2.2. 2003-05-03 10:53:08 +00:00
Raymond Hettinger 930427b892 Add a reference to dictnotes.txt. It does no good if you don't know it's
there or where to find it.
2003-05-03 06:51:59 +00:00
Raymond Hettinger 5466296f02 Research notes and explorations for optimizing Python dictionaries. 2003-05-02 20:11:29 +00:00
Jeremy Hylton fc61f9a36e Silence compiler warnings in VC 7. 2003-05-01 21:31:53 +00:00
Tim Peters 2af713c2f7 Squashed new compiler wngs about trying to compare pointers to
functions with different signatures.
2003-04-24 20:59:52 +00:00
Raymond Hettinger 9928571f3f SF bug 665835: filter() treatment of str and tuple inconsistent
As a side issue on this bug, it was noted that list and tuple iterators
used macros to directly access containers and would not recognize
__getitem__ overrides.  If the method is overridden, the patch returns
a generic sequence iterator which calls the __getitem__ method; otherwise,
it returns a high custom iterator with direct access to container elements.
2003-04-24 16:52:47 +00:00
Guido van Rossum 636688d470 Improve the message about metatype/metaclass conflicts. 2003-04-23 12:07:22 +00:00
Jeremy Hylton fbbe34789e Add a useful docstring to enumerate. 2003-04-21 20:26:25 +00:00
Guido van Rossum aa86e35c52 - bool() called without arguments now returns False rather than
raising an exception.  This is consistent with calling the
  constructors for the other builtin types -- called without argument
  they all return the false value of that type.  (SF patch #724135)
  Thanks to Alex Martelli.
2003-04-19 18:15:10 +00:00
Tim Peters 21d7d4d5ca _Py_PrintReferenceAddresses(): also print the type name. In real use
I'm finding some pretty baffling output, like reprs consisting entirely
of three left parens.  At least this will let us know what type the object
is (it's not str -- there's no quote character in the repr).

New tool combinerefs.py, to combine the two output blocks produced via
PYTHONDUMPREFS.
2003-04-18 00:45:59 +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
Thomas Heller a4ea603b05 SF # 595026: support for masks in getargs.c.
New functions:
  unsigned long PyInt_AsUnsignedLongMask(PyObject *);
  unsigned PY_LONG_LONG) PyInt_AsUnsignedLongLongMask(PyObject *);
  unsigned long PyLong_AsUnsignedLongMask(PyObject *);
  unsigned PY_LONG_LONG) PyLong_AsUnsignedLongLongMask(PyObject *);

New and changed format codes:

b unsigned char 0..UCHAR_MAX
B unsigned char none **
h unsigned short 0..USHRT_MAX
H unsigned short none **
i int INT_MIN..INT_MAX
I * unsigned int 0..UINT_MAX
l long LONG_MIN..LONG_MAX
k * unsigned long none
L long long LLONG_MIN..LLONG_MAX
K * unsigned long long none

Notes:

* New format codes.

** Changed from previous "range-and-a-half" to "none"; the
range-and-a-half checking wasn't particularly useful.

New test test_getargs2.py, to verify all this.
2003-04-17 18:55:45 +00:00
Guido van Rossum c1f6e8cbc1 - The repr() of a weakref object now shows the __name__ attribute of
the referenced object, if it has one.

Also use %p to format pointers consistently, and use <weakproxy ...>
in proxy_repr(), to match the type name.
2003-04-16 21:13:23 +00:00
Guido van Rossum 6cc5bb685d Sigh. The crucial change was still missing from the previous
checkin. :-(
2003-04-16 20:01:36 +00:00