summaryrefslogtreecommitdiffstats
path: root/Objects
Commit message (Collapse)AuthorAgeFilesLines
* Christian Tismer -- total rewrite on trashcan code.Guido van Rossum2000-04-241-15/+61
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Improvements: - does no longer need any extra memory - has no relationship to tstate - works in debug mode - can easily be modified for free threading (hi Greg:) Side effects: Trashcan does change the order of object destruction. Prevending that would be quite an immense effort, as my attempts have shown. This version works always the same, with debug mode or not. The slightly changed destruction order should therefore be no problem. Algorithm: While the old idea of delaying the destruction of some obejcts at a certain recursion level was kept, we now no longer aloocate an object to hold these objects. The delayed objects are instead chained together via their ob_type field. The type is encoded via ob_refcnt. When it comes to the destruction of the chain of waiting objects, the topmost object is popped off the chain and revived with type and refcount 1, then it gets a normal Py_DECREF. I am confident that this solution is near optimum for minimizing side effects and code bloat.
* Patch by Charles G Waldman to avoid a sneaky memory leak inGuido van Rossum2000-04-211-16/+59
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | _PyTuple_Resize(). In addition, a change suggested by Jeremy Hylton to limit the size of the free lists is also merged into this patch. Charles wrote initially: """ Test Case: run the following code: class Nothing: def __len__(self): return 5 def __getitem__(self, i): if i < 3: return i else: raise IndexError, i def g(a,*b,**c): return for x in xrange(1000000): g(*Nothing()) and watch Python's memory use go up and up. Diagnosis: The analysis begins with the call to PySequence_Tuple at line 1641 in ceval.c - the argument to g is seen to be a sequence but not a tuple, so it needs to be converted from an abstract sequence to a concrete tuple. PySequence_Tuple starts off by creating a new tuple of length 5 (line 1122 in abstract.c). Then at line 1149, since only 3 elements were assigned, _PyTuple_Resize is called to make the 5-tuple into a 3-tuple. When we're all done the 3-tuple is decrefed, but rather than being freed it is placed on the free_tuples cache. The basic problem is that the 3-tuples are being added to the cache but never picked up again, since _PyTuple_Resize doesn't make use of the free_tuples cache. If you are resizing a 5-tuple to a 3-tuple and there is already a 3-tuple in free_tuples[3], instead of using this tuple, _PyTuple_Resize will realloc the 5-tuple to a 3-tuple. It would more efficient to use the existing 3-tuple and cache the 5-tuple. By making _PyTuple_Resize aware of the free_tuples (just as PyTuple_New), we not only save a few calls to realloc, but also prevent this misbehavior whereby tuples are being added to the free_tuples list but never properly "recycled". """ And later: """ This patch replaces my submission of Sun, 16 Apr and addresses Jeremy Hylton's suggestions that we also limit the size of the free tuple list. I chose 2000 as the maximum number of tuples of any particular size to save. There was also a problem with the previous version of this patch causing a core dump if Python was built with Py_TRACE_REFS. This is fixed in the below version of the patch, which uses tupledealloc instead of _Py_Dealloc. """
* Fix PR#7 comparisons of recursive objectsJeremy Hylton2000-04-141-3/+112
| | | | | Note that comparisons of deeply nested objects can still dump core in extreme cases.
* Marc-Andre Lemburg:Guido van Rossum2000-04-111-11/+14
| | | | | | | | | The maxsplit functionality in .splitlines() was replaced by the keepends functionality which allows keeping the line end markers together with the string. Added support for '%r' % obj: this inserts repr(obj) rather than str(obj).
* Marc-Andre Lemburg:Guido van Rossum2000-04-111-2/+6
| | | | | Added a few missing whitespace Unicode char mappings. Thanks to Brian Hooper.
* Marc-Andre Lemburg:Guido van Rossum2000-04-111-13/+13
| | | | | | The maxsplit functionality in .splitlines() was replaced by the keepends functionality which allows keeping the line end markers together with the string.
* Simple optimization by Christian Tismer, who gives credit to LennyGuido van Rossum2000-04-101-0/+9
| | | | | Kneler for reporting this issue: long_mult() is faster when the smaller argument is on the left. Swap the arguments accordingly.
* Marc-Andre Lemburg:Guido van Rossum2000-04-101-22/+79
| | | | | | | | | | | | | | | | | | | * New exported API PyUnicode_Resize() * The experimental Keep-Alive optimization was turned back on after some tweaks to the implementation. It should now work without causing core dumps... this has yet to tested though (switching it off is easy: see the unicodeobject.c file for details). * Fixed a memory leak in the Unicode freelist cleanup code. * Added tests to correctly process the return code from _PyUnicode_Resize(). * Fixed a bug in the 'ignore' error handling routines of some builtin codecs. Added test cases for these to test_unicode.py.
* Marc-Andre Lemburg:Guido van Rossum2000-04-101-3/+52
| | | | | | | | | | | | | * string_contains now calls PyUnicode_Contains() only when the other operand is a Unicode string (not whenever it's not a string). * New format style '%r' inserts repr(arg) instead of str(arg). * '...%s...' % u"abc" now coerces to Unicode just like string methods. Care is taken not to reevaluate already formatted arguments -- only the first Unicode object appearing in the argument mapping is looked up twice. Added test cases for this to test_unicode.py.
* Marc-Andre Lemburg:Guido van Rossum2000-04-101-2/+15
| | | | | | * TypeErrors during comparing of mixed type arguments including a Unicode object are now masked (just like they are for all other combinations).
* Mark Hammond:Guido van Rossum2000-04-101-1/+4
| | | | | | | | In line with a similar checkin to object.c a while ago, this patch gives a more descriptive error message for an attribute error on a class instance. The message now looks like: AttributeError: 'Descriptor' instance has no attribute 'GetReturnType'
* Skip Montanaro: add string precisions to calls to PyErr_FormatGuido van Rossum2000-04-102-24/+24
| | | | to prevent possible buffer overruns.
* Conrad Huang points out that "if (0 < ch < 256)", while legal C,Guido van Rossum2000-04-061-1/+1
| | | | doesn't mean what the Python programmer thought...
* Fredrik Lundh: eliminate a MSVC compiler warning.Guido van Rossum2000-04-051-1/+1
|
* Marc-Andre's third try at this bulk patch seems to work (except thatGuido van Rossum2000-04-055-53/+183
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | his copy of test_contains.py seems to be broken -- the lines he deleted were already absent). Checkin messages: New Unicode support for int(), float(), complex() and long(). - new APIs PyInt_FromUnicode() and PyLong_FromUnicode() - added support for Unicode to PyFloat_FromString() - new encoding API PyUnicode_EncodeDecimal() which converts Unicode to a decimal char* string (used in the above new APIs) - shortcuts for calls like int(<int object>) and float(<float obj>) - tests for all of the above Unicode compares and contains checks: - comparing Unicode and non-string types now works; TypeErrors are masked, all other errors such as ValueError during Unicode coercion are passed through (note that PyUnicode_Compare does not implement the masking -- PyObject_Compare does this) - contains now works for non-string types too; TypeErrors are masked and 0 returned; all other errors are passed through Better testing support for the standard codecs. Misc minor enhancements, such as an alias dbcs for the mbcs codec. Changes: - PyLong_FromString() now applies the same error checks as does PyInt_FromString(): trailing garbage is reported as error and not longer silently ignored. The only characters which may be trailing the digits are 'L' and 'l' -- these are still silently ignored. - string.ato?() now directly interface to int(), long() and float(). The error strings are now a little different, but the type still remains the same. These functions are now ready to get declared obsolete ;-) - PyNumber_Int() now also does a check for embedded NULL chars in the input string; PyNumber_Long() already did this (and still does) Followed by: Looks like I've gone a step too far there... (and test_contains.py seem to have a bug too). I've changed back to reporting all errors in PyUnicode_Contains() and added a few more test cases to test_contains.py (plus corrected the join() NameError).
* Some blank lines.Guido van Rossum2000-03-311-0/+3
|
* Add PyDict_Copy() function to C API for dicts. It returns a newJeremy Hylton2000-03-301-1/+15
| | | | dictionary that contains the same key/value pairs as p.
* MBCS codecs. (Win32 only.) By Mark Hammond.Guido van Rossum2000-03-281-0/+59
|
* Christian Tismer:Guido van Rossum2000-03-251-2/+8
| | | | | | Added "better safe than sorry" patch to the new trashcan code in object.c, to ensure that tstate is not touched when it might be undefined.
* On 17-Mar-2000, Marc-Andre Lemburg said:Barry Warsaw2000-03-202-23/+26
| | | | | | | | | | | | | Attached you find an update of the Unicode implementation. The patch is against the current CVS version. I would appreciate if someone with CVS checkin permissions could check the changes in. The patch contains all bugs and patches sent this week and also fixes a leak in the codecs code and a bug in the free list code for Unicode objects (which only shows up when compiling Python with Py_DEBUG; thanks to MarkH for spotting this one).
* Checking in the new, improve file.writelines() code.Guido van Rossum2000-03-131-24/+78
| | | | | | This (1) avoids thread unsafety whereby another thread could zap the list while we were using it, and (2) now supports writing arbitrary sequences of strings.
* Christian Tismer's "trashcan" patch:Guido van Rossum2000-03-135-1/+55
| | | | | | | | Added wrapping macros to dictobject.c, listobject.c, tupleobject.c, frameobject.c, traceback.c that safely prevends core dumps on stack overflow. Macros and functions in object.c, object.h. The method is an "elevator destructor" that turns cascading deletes into tail recursive behavior when some limit is hit.
* Fix typo in replace() detected by Mark Hammond and fixed by Marc-Andre.Guido van Rossum2000-03-131-2/+4
|
* Add sq_contains implementation.Guido van Rossum2000-03-131-0/+44
|
* Added Christian Tismer's patch to allow list.append(a,b,c) back --Guido van Rossum2000-03-131-4/+18
| | | | | with a twist: you have to define NO_STRICT_LIST_APPEND manually to enable multi-arg append().
* Marc-AAndre Lemburg: add new unicode filesGuido van Rossum2000-03-101-2/+6
|
* Many changes for Unicode, by Marc-Andre Lemburg.Guido van Rossum2000-03-106-197/+942
|
* Unicode implementation by Marc-Andre Lemburg based on original code byGuido van Rossum2000-03-101-0/+4440
| | | | Fredrik Lundh.
* Unicode character type helpers, written by Marc-Andre Lemburg.Guido van Rossum2000-03-101-0/+5043
|
* Patch by Moshe Zadka: remove the string special case inGuido van Rossum2000-03-071-18/+0
| | | | | PySequence_Contains() now that string objects have this code in their tp_contains.
* Patch by Moshe Zadka: move the string special case from abstract.cGuido van Rossum2000-03-071-0/+22
| | | | | | here. [Patch modified by GvR to keep the original exception.]
* string_join(): Fix memory leaks discovered by Charles Waldman (and aBarry Warsaw2000-03-061-5/+15
| | | | few other paths through the function that leaked).
* Massive patch by Skip Montanaro to add ":name" to as manyGuido van Rossum2000-02-293-20/+20
| | | | PyArg_ParseTuple() format string arguments as possible.
* Patch by Mozhe Zadka, for __contains__ (overloading 'in'). This addsGuido van Rossum2000-02-281-0/+56
| | | | | | an instance method instance_contains as sq_contains. It looks for __contains__ and if not found falls back to previous behaviour. Done.
* Patch by Mozhe Zadka, for __contains__ (overloading 'in'). ThisGuido van Rossum2000-02-281-1/+8
| | | | | patches PySequence_Contains() to check for a valid sq_contains field. More to follow.
* OKOK, Greg's right, I should've used the :name option in the argumentGuido van Rossum2000-02-241-9/+9
| | | | format strings.
* Made all list methods use PyArg_ParseTuple(), for more accurateGuido van Rossum2000-02-241-30/+29
| | | | | | | | diagnostics. *** INCOMPATIBLE CHANGE: This changes append(), remove(), index(), and *** count() to require exactly one argument -- previously, multiple *** arguments were silently assumed to be a tuple.
* Allow using long integers as arguments to PyObject_GetItem(), _SetItem(),Andrew M. Kuchling2000-02-231-1/+19
| | | | | | and _DelItem(). In sequence multiplication by a long, only call PyErr_Occurred() when the value returned is -1.
* dict_has_key(): Accept only one parameter. PR#210 reported byFred Drake2000-02-231-4/+4
| | | | Andreas Jung <ajung@sz-sb.de>.
* In response to one particular complaint on edu-sig, change some errorGuido van Rossum2000-02-151-3/+3
| | | | | | messages from "OverflowError: integer pow()" to "OverflowError: integer exponentiation". (Not that this takes care of the complaint in general that the error messages could be greatly improved. :-)
* Make multiplying a sequence by a long integer (5L * 'b') legalAndrew M. Kuchling2000-02-141-2/+13
|
* The rest of the changes by Trent Mick and Dale Nagata for warning-freeGuido van Rossum2000-01-2010-19/+21
| | | | compilation on NT Alpha. Mostly added casts etc.
* On Linux, one sometimes sees spurious errors after interruptingGuido van Rossum2000-01-121-0/+1
| | | | | previous output. Call clearerr() to prevent past errors affecting our ferror() test later, in PyObject_Print(). Suggested by Marc Lemburg.
* Implement the other easy thing: repr() of a float now uses %.17g,Guido van Rossum1999-12-231-6/+43
| | | | while str() uses %.12g as before.
* long_format(): Now takes a third parameter, addL; iff true, aFred Drake1999-12-231-9/+19
| | | | | | | | | | | | | | | trailing 'L' is appended to the representation, otherwise not. All existing call sites are modified to pass true for addL. Remove incorrect statement about external use of this function from elsewhere; it's static! long_str(): Handler for the tp_str slot in the type object. Identical to long_repr(), but passes false as the addL parameter of long_format().
* do_strip(): Fixed cut-and-paste error; this function should check forBarry Warsaw1999-12-151-3/+1
| | | | zero arguments (found by Marc Lemburg).
* Mainlining the string_methods branch. See branch revision logBarry Warsaw1999-10-124-120/+1199
| | | | messages for specific changes.
* Fix PR#66. Solution: add error checking around l_divmod() calls inGuido van Rossum1999-10-111-4/+18
| | | | long_pow().
* Fix for PR#98 (Adrian Eyre) -- in instancemethod_repr, the funcnameGuido van Rossum1999-10-111-1/+1
| | | | object is DECREFed too early.
* Patch by Tim Peters fixing PR#88:Guido van Rossum1999-09-271-1/+7
| | | | Integer division can crash under Windows.