summaryrefslogtreecommitdiff
path: root/Objects
AgeCommit message (Collapse)AuthorLines
2003-09-17Backport: Double-fix of crash in Unicode freelist handling.Jeremy Hylton-1/+14
2003-07-13Backport of rhettinger's funcobject.c 2.63, bugfix for SF bug 753451Anthony Baxter-0/+6
Check the argument of classmethod is callable. (prevents classmethod(classmethod(func)) from bombing out.
2003-06-16Backport 2.237 by Guido:Neal Norwitz-5/+14
- SF patch 751998 fixes an unwanted side effect of the previous fix for SF bug 742860 (the next item).
2003-05-29Backport patch 2.206:Barry Warsaw-0/+9
---------------------------- revision 2.206 date: 2003/02/11 16:25:43; author: gvanrossum; state: Exp; lines: +9 -0 Add basic arg sanity checking to wrap_descr_get(). This is called when Python code calls a descriptor's __get__ method. It should translate None to NULL in both argument positions, and insist that at least one of the argument positions is not NULL after this transformation. ---------------------------- which fixes SF bug # 736892, forcing function to act like an unbound method dumps core.
2003-05-29Fix for SF 742911. We now clear the weakrefs *before* calling __del__Guido van Rossum-8/+8
or emptying __dict__, just as we do for classic classes.
2003-05-22Backport fix for SF bug 692776.Jeremy Hylton-1/+106
Add a tp_new slot to function objects that handles the case of a function requiring a closure. Put the function type in the new module, rather than having a function new.function(). Add tests.
2003-05-21PyType_Ready(): Complain if the type is a base type, and gc'able, andTim Peters-2/+32
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-20Change docstrings for __(get|set|del)slice__ to note that negative indices ↵Brett Cannon-3/+9
are not supported.
2003-05-09Backport fixes to make more types collectable.Jeremy Hylton-8/+44
classmethod, staticmethod, cPickle.Pickler, cPickle.UNpickler
2003-05-03Patch #708604: Check more function results.Martin v. Löwis-1/+8
2003-04-30file_truncate(): Backported 2.3 code so that file.truncate(n) works onTim Peters-20/+68
Windows when n is too big to fit in a 32-bit int. This was a hole in 2.2's large file support on Windows, and turns out it's a bad hole at least for ZODB.
2003-04-25Backport the Carlo Verre fix.Guido van Rossum-0/+22
2003-04-11Backport:Neal Norwitz-18/+18
Fix SF bug #697220, string.strip implementation/doc mismatch Attempt to make all the various string/unicode *strip methods the same. * Doc - add doc for when functions were added * UserString * string/unicode object methods * string module functions 'chars' is used for the last parameter everywhere.
2003-04-09Backport from trunk:Guido van Rossum-0/+1
property_traverse() should also traverse into prop_doc -- there's no typecheck that guarantees it's a string, and BTW string subclasses could hide references.
2003-04-08Added private API function _PyInstance_Lookup(). This is part ofTim Peters-8/+29
backporting fixes so that garbage collection doesn't have to trigger execution of arbitrary Python code just to figure out whether an object has a __del__ method.
2003-04-01Remove trailing newline.Fred Drake-1/+0
2003-03-23Backport Tim's checkin 2.218:Neal Norwitz-9/+10
slot_sq_contains(): This leaked a reference to the result of calling __contains__().
2003-03-04Backported fix to [521782] unreliable file.read() error handling.Gustavo Niemeyer-3/+30
2003-02-19Backport of rev 2.199 from trunk.Guido van Rossum-2/+4
PyObject_Generic{Get,Set}Attr: Don't access tp_descr_{get,set} of a descriptor without checking the flag bits of the descriptor's type. While we know that the main type (the type of the object whose attribute is being accessed) has all the right flag bits (or else PyObject_Generic{Get,Set}Attr wouldn't be called), we don't know that for its class attributes!
2003-02-11Backport: Add more missing PyErr_NoMemory() after failled memory allocsNeal Norwitz-1/+1
2003-02-02backport:Neal Norwitz-10/+13
revision 2.196 date: 2002/12/07 21:39:16; author: tim_one; state: Exp; lines: +27 -28 slot_nb_nonzero(): Another leak uncovered by the sandbox datetime tests. I found the logic too confusing to follow here, so rewrote more than was likely absolutely necessary.
2003-02-02backport:Neal Norwitz-14/+13
revision 2.164 date: 2002/10/29 18:36:40; author: gvanrossum; state: Exp; lines: +12 -13 Since properties are supported here, is possible that instance_getattr2() raises an exception. Fix all code that made this assumption.
2003-02-02backport:Neal Norwitz-0/+5
revision 1.11 date: 2002/12/18 23:20:39; author: nnorwitz; state: Exp; lines: +6 -2 SF # 654974, fix unchecked return values in structseq Check return values after memory allocation.
2003-01-28backport:Neal Norwitz-1/+4
Fix SF bug# 676155, RuntimeWarning with tp_compare Check return value of PyLong_AsDouble(), it can return an error.
2003-01-19Backport SF # 669553, fix memory (ref) leaksNeal Norwitz-1/+8
2003-01-13Backport:Neal Norwitz-3/+16
Fix SF bug #667147, Segmentation fault printing str subclass Fix infinite recursion which occurred when printing an object whose __str__() returned self.
2003-01-07Backport typeobject.c revision 2.201 plus associated tests from 2.3:Guido van Rossum-1/+36
Add a refinement to SLOT1BINFULL() that fixes the problem reported in SF bug #623669: only try (e.g.) __rdiv__ before __div__ if the right class actually overrides it.
2003-01-02Backport MAL's patch for bug #659709: bogus computation of float lengthRaymond Hettinger-16/+37
2002-12-29SF Bug 645777: list.extend() works with any iterable and is no longerRaymond Hettinger-1/+1
experimental.
2002-12-24Fix SF #658106, Setting __class__ to NoneTypeNeal Norwitz-6/+9
Backport Guido's checkin 2.171: Disallow class assignment completely unless both old and new are heap types. This prevents nonsense like 2.__class__ = bool or True.__class__ = int.
2002-12-16try_3way_compare() was returning -1 in one case where it should returnGuido van Rossum-1/+1
-2 (i.e. an exception was set). (This was already fixed in 2.3 through a different refactoring.) Worth the release of Pyton 2.2.3? Eventually, I guess...
2002-12-07Fix typo in abstract.c which caused __rpow__ to not be invoked.Raymond Hettinger-1/+1
Added related testcase. Closes SF bug #643260.
2002-12-07Backport from head.Tim Peters-3/+3
slot_tp_hash(): In the normal path, this leaked a reference to the integer hash object returned by __hash__().
2002-11-20Backport Neil Schemenauer's fix for SF #529750,Neal Norwitz-2/+0
Circular reference makes Py_Init crash Modified to keep _Py_ResetReferences() API, but make it a no-op. It's not called now (for 2.3 it was completely removed).
2002-11-07Backport 2.173:Neal Norwitz-3/+1
Fix for bug #626172: crash using unicode latin1 single char
2002-10-18Backport:Neal Norwitz-1/+5
Fix SF # 624982, Potential AV in slot_sq_item, by Greg Chapman Don't crash when getting value of a property raises an exception
2002-10-18Fix (real! :-) memory leaks in half_cmp and half_binop.Guido van Rossum-1/+4
Perhaps found by NealN and valgrind. Will forward port.
2002-10-18Sigh. That wasn't a memory leak, that was Guido committing beforeGuido van Rossum-5/+2
running tests. Withdraw 2.183 and its backport.
2002-10-18Backport of 2.183:Guido van Rossum-2/+5
Fix memory leak in add_subclass() found by NealN with valgrind.
2002-10-11Darn! Don't divide by zero. Bad fix. :-)Guido van Rossum-1/+1
2002-10-11Backport listobject.c 2.137 and tupleobject.c 2.75:Guido van Rossum-0/+6
Add checks for size overflow on list*n, list+list, tuple+tuple.
2002-10-11Backport 2.193:Guido van Rossum-10/+4
PyObject_Init[Var] is almost always called from the PyObject_NEW[_VAR] macros. The 'op' argument is then the result from PyObject_MALLOC, and that can of course be NULL. In that case, PyObject_Init[Var] would raise a SystemError with "NULL object passed to PyObject_Init[Var]". But there's nothing the caller of the macro can do about this. So PyObject_Init[Var] should call just PyErr_NoMemory.
2002-10-11Backport stringobject.c 2.194 and unicodeobject.c 2.172:Guido van Rossum-4/+12
Fix a nasty endcase reported by Armin Rigo in SF bug 618623: '%2147483647d' % -123 segfaults. This was because an integer overflow in a comparison caused the string resize to be skipped. After fixing the overflow, this could call _PyString_Resize() with a negative size, so I (1) test for that and raise MemoryError instead; (2) also added a test for negative newsize to _PyString_Resize(), raising SystemError as for all bad arguments. An identical bug existed in unicodeobject.c, of course.
2002-10-11New in 2.2.2!Guido van Rossum-1/+0
In inherit_slots(), get rid of the COPYSLOT(tp_dictoffset). Copying the offset from a non-dominant base makes no sense: either the non-dominant base has a nonzero tp_dictoffset, and then we should have already copied it from the dominant base (at the very end of inherit_special()), or the non-dominant base has no tp_dictoffset and for some reason type_new() decided not to add one. The tp_dictoffset from a non-dominant base is likely to conflict with the instance layout of the dominant base, so copying the tp_dictoffset from the non-dominant base would be a really bad idea in that case. This bug can only be triggered by multiple inheritance from an extension class that doesn't set tp_dictoffset and a new-style user-level class that does have one. There are no such extension classes in the distribution, but there are 3rd party ones. (Zope3 now has one, that's how I found this. :-) I've asked a few heavy users of new-style classes, extension classes and metaclasses (David Abrahams and Kevin Jacobs), and neither of them found any problems in their test suite after applying this fix, so I assume it's safe.
2002-10-11Backport the relevant part of 2.192:Guido van Rossum-1/+2
The string formatting code has a test to switch to Unicode when %s sees a Unicode argument. Unfortunately this test was also executed for %r, because %s and %r share almost all of their code. This meant that, if u is a unicode object while repr(u) is an 8-bit string containing ASCII characters, '%r' % u is a *unicode* string containing only ASCII characters! Fixed by executing the test only for %s.
2002-10-07Backport, at the reqest of Kevin Jacobs:Guido van Rossum-0/+4
- Changed new-style class instantiation so that when C's __new__ method returns something that's not a C instance, its __init__ is not called. [SF bug #537450] XXX This is arguably a semantic change, but it's hard to imagine a reason for wanting to depend on the old behavior. If problems with this are reported within a week of the release of 2.2.2 beta 1, we may revert this change.
2002-10-07Backport:Michael W. Hudson-1/+55
2002/08/11 12:23:04 lemburg Python/bltinmodule.c 2.262 2002/08/11 12:23:04 lemburg Objects/unicodeobject.c 2.162 2002/08/11 12:23:03 lemburg Misc/NEWS 1.461 2002/08/11 12:23:03 lemburg Lib/test/test_unicode.py 1.65 2002/08/11 12:23:03 lemburg Include/unicodeobject.h 2.39 Add C API PyUnicode_FromOrdinal() which exposes unichr() at C level. u'%c' will now raise a ValueError in case the argument is an integer outside the valid range of Unicode code point ordinals. Closes SF bug #593581.
2002-10-05Backport 2.103:Raymond Hettinger-2/+2
Made conversion failure error messages consistent between types.
2002-10-05Backport 2.63 and 2.60:Raymond Hettinger-27/+24
Call me anal, but there was a particular phrase that was speading to comments everywhere that bugged me: /* Foo is inlined */ instead of /* Inline Foo */. Somehow the "is inlined" phrase always confused me for half a second (thinking, "No it isn't" until I added the missing "here"). The new phrase is hopefully unambiguous. Close SF bug 563740. complex() now finds __complex__() in new style classes. Made conversion failure error messages consistent between types. Added related unittests.
2002-09-25Fix typo in xreadlines() docstring. This does not apply to the trunk.Fred Drake-1/+1
Closes SF bug #614542.