summaryrefslogtreecommitdiffstats
path: root/Objects
Commit message (Collapse)AuthorAgeFilesLines
* SF bug #439104: Tuple richcompares has code-typo.Tim Peters2001-07-062-2/+2
| | | | | Symptom: (1, 2, 3) <= (1, 2) returned 1. Also an isomorphic error was in the list richcompare code.
* Backport of Tim's checkin 2.57:Thomas Wouters2001-06-271-23/+17
| | | | | | | | | SF bug 434186: 0x80000000/2 != 0x80000000>>1 i_divmod: New and simpler algorithm. Old one returned gibberish on most boxes when the numerator was -sys.maxint-1. Oddly enough, it worked in the release (not debug) build on Windows, because the compiler optimized away some tricky sign manipulations that were incorrect in this case. Makes you wonder <wink> ...
* _PyTuple_Resize: guard against PyTuple_New() returning NULL, using Tim'sThomas Wouters2001-05-291-1/+1
| | | | suggestion (modulo style).
* _PyTuple_Resize: take into account the empty tuple. There can be only one.Thomas Wouters2001-05-281-2/+11
| | | | | | | Instead of raising a SystemError, just create a new tuple of the desired size. This fixes (at least) SF bug #420343.
* Backport Tim's checkin 2.84:Thomas Wouters2001-05-231-34/+95
| | | | | | | SF bug #422121 Insecurities in dict comparison. Fixed a half dozen ways in which general dict comparison could crash Python (even cause Win98SE to reboot) in the presence of kay and/or value comparison routines that mutate the dict during dict comparison.
* Net result of Tim's checkins to stropmodule.c (2.78, 2.79, 2.80, 2.81),Thomas Wouters2001-05-231-28/+35
| | | | | | | | stringobject.c (2.114, 2.115) and test_strop.py (1.11, 1.12). Fixes 'replace' behaviour on systems on which 'malloc(0)' returns NULL (together with previous checkins) and re-synchs the string-operation code in stringobject.c and stropmodule.c, with the exception of 'replace', which has the old semantics in stropmodule but the new semantics in stringobjects.
* Backport Jeremy's checkins (frameobject.c:2.50, test_scope.py:1.16,Thomas Wouters2001-05-231-6/+3
| | | | | | | test_scope:1.8): SF patch 419176 from MvL; fixed bug 418977 Two errors in dict_to_map() helper used by PyFrame_LocalsToFast().
* Backport Tim's checkin 2.130:Thomas Wouters2001-05-231-1/+7
| | | | | | SF bug #422108 - Error in rich comparisons. Fix a bad (albeit unlikely) return value in try_rich_to_3way_compare(). Also document do_cmp()'s return values.
* Backport MAL's checkin 2.105:Thomas Wouters2001-05-231-2/+3
| | | | Fix for bug #417030: "print '%*s' fails for unicode string"
* Net result of Guido's checkins of object.c (2.125 and 2.126), classobject.cThomas Wouters2001-05-233-31/+42
| | | | | | | (2.128) and stringobject.c (2.105), which reworks PyObject_Str() and PyObject_Repr() so strings and instances aren't special-cased, and print >> file, instance works like expected in all cases.
* Backport of Tim's checkin 2.88:Thomas Wouters2001-05-231-4/+15
| | | | | | | | | | | | A different approach to the problem reported in Patch #419651: Metrowerks on Mac adds 0x itself C std says %#x and %#X conversion of 0 do not add the 0x/0X base marker. Metrowerks apparently does. Mark Favas reported the same bug under a Compaq compiler on Tru64 Unix, but no other libc broken in this respect is known (known to be OK under MSVC and gcc). So just try the damn thing at runtime and see what the platform does. Note that we've always had bugs here, but never knew it before because a relevant test case didn't exist before 2.1.
* Backport Tim's checkin 2.104:Thomas Wouters2001-05-231-2/+6
| | | | | | | | | | | | A different approach to the problem reported in Patch #419651: Metrowerks on Mac adds 0x itself C std says %#x and %#X conversion of 0 do not add the 0x/0X base marker. Metrowerks apparently does. Mark Favas reported the same bug under a Compaq compiler on Tru64 Unix, but no other libc broken in this respect is known (known to be OK under MSVC and gcc). So just try the damn thing at runtime and see what the platform does. Note that we've always had bugs here, but never knew it before because a relevant test case didn't exist before 2.1.
* The weakref support in PyObject_InitVar() as well; this should have come outFred Drake2001-05-031-4/+0
| | | | at the same time as it did from PyObject_Init() .
* Remove unnecessary intialization for the case of weakly-referencable objects;Fred Drake2001-05-031-4/+0
| | | | | | | the code necessary to accomplish this is simpler and faster if confined to the object implementations, so we only do this there. This causes no behaviorial changes beyond a (very slight) speedup.
* Tim pointed out a remaining vulnerability in popitem(): theGuido van Rossum2001-04-161-5/+6
| | | | | | | | | | | PyTuple_New() could *conceivably* clear the dict, so move the test for an empty dict after the tuple allocation. It means that we waste time allocating and deallocating a 2-tuple when the dict is empty, but who cares. It also means that when the dict is empty *and* there's no memory to allocate a 2-tuple, we raise MemoryError, not KeyError -- but that may actually a good idea: if there's no room for a lousy 2-tuple, what are the chances that there's room for a KeyError instance?
* Tentative fix for a problem that Tim discovered at the last moment,Guido van Rossum2001-04-151-61/+110
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | and reported to python-dev: because we were calling dict_resize() in PyDict_Next(), and because GC's dict_traverse() uses PyDict_Next(), and because PyTuple_New() can cause GC, and because dict_items() calls PyTuple_New(), it was possible for dict_items() to have the dict resized right under its nose. The solution is convoluted, and touches several places: keys(), values(), items(), popitem(), PyDict_Next(), and PyDict_SetItem(). There are two parts to it. First, we no longer call dict_resize() in PyDict_Next(), which seems to solve the immediate problem. But then PyDict_SetItem() must have a different policy about when *it* calls dict_resize(), because we want to guarantee (e.g. for an algorithm that Jeremy uses in the compiler) that you can loop over a dict using PyDict_Next() and make changes to the dict as long as those changes are only value replacements for existing keys using PyDict_SetItem(). This is done by resizing *after* the insertion instead of before, and by remembering the size before we insert the item, and if the size is still the same, we don't bother to even check if we might need to resize. An additional detail is that if the dict starts out empty, we must still resize it before the insertion. That was the first part. :-) The second part is to make keys(), values(), items(), and popitem() safe against side effects on the dict caused by allocations, under the assumption that if the GC can cause arbitrary Python code to run, it can cause other threads to run, and it's not inconceivable that our dict could be resized -- it would be insane to write code that relies on this, but not all code is sane. Now, I have this nagging feeling that the loops in lookdict probably are blissfully assuming that doing a simple key comparison does not change the dict's size. This is not necessarily true (the keys could be class instances after all). But that's a battle for another day.
* Make one more private symbol static.Guido van Rossum2001-04-141-1/+1
|
* Make some private symbols static.Guido van Rossum2001-04-142-3/+3
|
* Bug 415514 reported that e.g.Tim Peters2001-04-122-38/+43
| | | | | | | | | | | | "%#x" % 0 blew up, at heart because C sprintf supplies a base marker if and only if the value is not 0. I then fixed that, by tolerating C's inconsistency when it does %#x, and taking away that *Python* produced 0x0 when formatting 0L (the "long" flavor of 0) under %#x itself. But after talking with Guido, we agreed it would be better to supply 0x for the short int case too, despite that it's inconsistent with C, because C is inconsistent with itself and with Python's hex(0) (plus, while "%#x" % 0 didn't work before, "%#x" % 0L *did*, and returned "0x0"). Similarly for %#X conversion.
* Fix for SF bug #415514: "%#x" % 0 caused assertion failure/abort.Tim Peters2001-04-122-25/+37
| | | | | | | | | | | | | http://sourceforge.net/tracker/index.php?func=detail&aid=415514&group_id=5470&atid=105470 For short ints, Python defers to the platform C library to figure out what %#x should do. The code asserted that the platform C returned a string beginning with "0x". However, that's not true when-- and only when --the *value* being formatted is 0. Changed the code to live with C's inconsistency here. In the meantime, the problem does not arise if you format a long 0 (0L) instead. However, that's because the code *we* wrote to do %#x conversions on longs produces a leading "0x" regardless of value. That's probably wrong too: we should drop leading "0x", for consistency with C, when (& only when) formatting 0L. So I changed the long formatting code to do that too.
* Fixed ref count bug. Patch #411191. Found by Walter Dörwald.Marc-André Lemburg2001-03-251-1/+3
|
* Add support for weak references to the function and method types.Fred Drake2001-03-232-3/+13
|
* A small change to the C API for weakly-referencable types: Such typesFred Drake2001-03-221-0/+1
| | | | | | | | must now initialize the extra field used by the weak-ref machinery to NULL themselves, to avoid having to require PyObject_INIT() to check if the type supports weak references and do it there. This causes less work to be done for all objects (the type object does not need to be consulted to check for the Py_TPFLAGS_HAVE_WEAKREFS bit).
* Make PyDict_Next safe to use for loops that merely modify the valuesTim Peters2001-03-211-8/+32
| | | | | | associated with existing dict keys. This is a variant of part of Michael Hudson's patch #409864 "lazy fix for Pings bizarre scoping crash".
* Move the code implementing isinstance() and issubclass() to new CGuido van Rossum2001-03-211-0/+112
| | | | | APIs, PyObject_IsInstance() and PyObject_IsSubclass() -- both returning an int, or -1 for errors.
* Fix PyFrame_FastToLocals() and counterpart to deal with cells andJeremy Hylton2001-03-211-20/+68
| | | | | | | | | | | | | | frees. Note there doesn't seem to be any way to test LocalsToFast(), because the instructions that trigger it are illegal in nested scopes with free variables. Fix allocation strategy for cells that are also formal parameters. Instead of emitting LOAD_FAST / STORE_DEREF pairs for each parameter, have the argument handling code in eval_code2() do the right thing. A side-effect of this change is that cell variables that are also arguments are listed at the front of co_cellvars in the order they appear in the argument list.
* SF patch #408326 by Robin Thomas: slice objects comparable, notGuido van Rossum2001-03-201-3/+23
| | | | | | | | | | | | | | | | | | hashable This patch changes the behavior of slice objects in the following manner: - Slice objects are now comparable with other slice objects as though they were logically tuples of (start,stop,step). The tuple is not created in the comparison function, but the comparison behavior is logically equivalent. - Slice objects are not hashable. With the above change to being comparable, slice objects now cannot be used as keys in dictionaries. [I've edited the patch for style. Note that this fixes the problem that dict[i:j] seemed to work but was meaningless. --GvR]
* SF bug [ #409448 ] Complex division is braindeadTim Peters2001-03-181-8/+58
| | | | | | http://sourceforge.net/tracker/?func=detail&aid=409448&group_id=5470&atid=105470 Now less braindead. Also added test_complex.py, which doesn't test much, but fails without this patch.
* Variety of small INC/DECREF patches that fix reported memory leaksJeremy Hylton2001-03-132-3/+5
| | | | | | | | | | | | | | | | | | | | | with free variables. Thanks to Martin v. Loewis for finding two of the problems. This fixes SF buf 405583. There is also a C API change: PyFrame_New() is reverting to its pre-2.1 signature. The change introduced by nested scopes was a mistake. XXX Is this okay between beta releases? cell_clear(), the GC helper, must decref its reference to break cycles. frame_dealloc() must dealloc all cell vars and free vars in addition to locals. eval_code2() setup code must INCREF cells it copies out of the closure. The STORE_DEREF opcode implementation must DECREF the object it passes to PyCell_Set().
* Identifiers matching _[A-Z_]\w* are reserved for C implementations.Tim Peters2001-03-111-6/+6
| | | | | | May or may not be related to bug 407680 (obmalloc.c - looks like it's corrupted). This repairs the illegal vrbl names, but leaves a pile of illegal macro names (_THIS_xxx, _SYSTEM_xxx, _SET_HOOKS, _FETCH_HOOKS).
* When 1.6 boosted the # of digits produced by repr(float), repr(complex)Tim Peters2001-03-112-9/+32
| | | | apparently forgot to play along. Make complex act like float.
* Avoid giving prototypes on Solaris.Martin v. Löwis2001-03-061-1/+1
|
* Use Py_CHARMASK for ctype macros. Fixes bug #232787.Martin v. Löwis2001-03-061-1/+1
|
* Two improvements to large file support:Guido van Rossum2001-03-011-30/+18
| | | | | | | | | | | | | | - In _portable_ftell(), try fgetpos() before ftello() and ftell64(). I ran into a situation on a 64-bit capable Linux where the C library's ftello() and ftell64() returned negative numbers despite fpos_t and off_t both being 64-bit types; fgetpos() did the right thing. - Define a new typedef, Py_off_t, which is either fpos_t or off_t, depending on which one is 64 bits. This removes the need for a lot of #ifdefs later on. (XXX Should this be moved to pyport.h? That file currently seems oblivious to large fille support, so for now I'll leave it here where it's needed.)
* Visit the closure during traversal and XDECREF it on during deallocation.Jeremy Hylton2001-03-011-0/+6
|
* Fix SF buf 404774 submitted by Gregory H. BallJeremy Hylton2001-02-281-1/+1
| | | | | A user program could delete a function's func_closure, which would cause it to crash when called.
* Add Vladimir Marangozov's object allocator. It is disabled by default. ThisNeil Schemenauer2001-02-272-0/+747
| | | | closes SF patch #401229.
* The return value from PyObject_ClearWeakRefs() is no longer meaningful,Fred Drake2001-02-262-5/+4
| | | | so make it void.
* instancemethod_setattro(): Raise TypeError if an attempt is made toBarry Warsaw2001-02-261-15/+2
| | | | | | set a function attribute on a method (either bound or unbound). This reverts to Python 2.0 behavior that no attributes of the method are writable, but provides a more informative error message.
* _Py_ReleaseInternedStrings(): Private API function to decref andBarry Warsaw2001-02-231-0/+10
| | | | | | release the interned string dictionary. This is useful for memory use debugging because it eliminates a huge source of noise from the reports. Only defined when INTERN_STRINGS is defined.
* _PyObject_Dump(): If argument is NULL, print "NULL" instead ofBarry Warsaw2001-02-221-3/+7
| | | | crashing.
* In try_3way_to_rich_compare(), swap the call to default_3way_compare()Guido van Rossum2001-02-221-2/+2
| | | | | | and the test for errors, so that an error in the default compare doesn't go undetected. This fixes SF Bug #132933 (submitted by effbot) -- list.sort doesn't detect comparision errors.
* reorganized PyUnicode_DecodeUnicodeEscape a bit (in order to make itFredrik Lundh2001-02-181-110/+69
| | | | less likely that bug #132817 ever appears again)
* Fix core dump whenever PyList_Reverse() was called.Guido van Rossum2001-02-121-11/+14
| | | | | | | | | | | This fixes SF bug #132008, reported by Warren J. Hack. The copyright for this patch (and this patch only) belongs to CNRI, as part of the (yet to be issued) 1.6.1 release. This is now checked into the HEAD branch. Tim will check in a test case to check for this specific bug, and an assertion in PyArgs_ParseTuple() to catch similar bugs in the future.
* Superseded by $(srcdir)/Makefile.pre.in.Neil Schemenauer2001-02-031-104/+0
|
* SF patch 103543 from tg@freebsd.org:Jeremy Hylton2001-02-011-1/+1
| | | | PyFPE_END_PROTECT() was called on undefined var
* PEP 205, Weak References -- initial checkin.Fred Drake2001-02-012-0/+28
|
* Rename dubiously named local variable 'cmpfunc' -- this is also aGuido van Rossum2001-01-291-5/+5
| | | | | | typedef, and at least one compiler choked on this. (SF patch #103457, by bquinlan)
* Remove f_closure slot of frameobject and use f_localsplus instead.Jeremy Hylton2001-01-291-23/+14
| | | | | | | | | | | | This change eliminates an extra malloc/free when a frame with free variables is created. Any cell vars or free vars are stored in f_localsplus after the locals and before the stack. eval_code2() fills in the appropriate values after handling initialization of locals. To track the size the frame has an f_size member that tracks the total size of f_localsplus. It used to be implicitly f_nlocals + f_stacksize.
* fix indentation glitchJeremy Hylton2001-01-291-1/+1
|