summaryrefslogtreecommitdiffstats
path: root/Objects
Commit message (Collapse)AuthorAgeFilesLines
* Return the orginal string only if it's a real str or unicodeWalter Dörwald2002-04-152-4/+18
| | | | instance, otherwise make a copy.
* Remove 'const' from local variable declaration in string_zfill() -- itGuido van Rossum2002-04-151-71/+80
| | | | | | | | isn't constant, so why bother. Folded long lines. Whitespace normalization.
* Apply the second version of SF patch http://www.python.org/sf/536241Walter Dörwald2002-04-152-3/+44
| | | | | | | | | | Add a method zfill to str, unicode and UserString and change Lib/string.py accordingly. This activates the zfill version in unicodeobject.c that was commented out and implements the same in stringobject.c. It also adds the test for unicode support in Lib/string.py back in and uses repr() instead() of str() (as it was before Lib/string.py 1.62)
* Deprecate % as well. The message for deprecation of //, % and divmodGuido van Rossum2002-04-151-1/+6
| | | | is the same in all three cases (mostly because // calls divmod :-).
* SF bug #543387.Guido van Rossum2002-04-151-0/+5
| | | | | | | | | Complex numbers implement divmod() and //, neither of which makes one lick of sense. Unfortunately this is documented, so I'm adding a deprecation warning now, so we can delete this silliness, oh, around 2005 or so. Bugfix candidate (At least for 2.2.2, I think.)
* SF bug #541883 (Vincent Fiack).Guido van Rossum2002-04-151-0/+5
| | | | | | | A stupid bug in object_set_class(): didn't check for value==NULL before checking its type. Bugfix candidate.
* SF bug 543840: complex(string) accepts strings with \0Tim Peters2002-04-141-1/+1
| | | | | | | complex_subtype_from_string(): this stopped parsing at the first 0 byte, as if that were the end of the input string. Bugfix candidate.
* Mass checkin of universal newline support.Jack Jansen2002-04-141-17/+294
| | | | | | | | Highlights: import and friends will understand any of \r, \n and \r\n as end of line. Python file input will do the same if you use mode 'U'. Everything can be disabled by configuring with --without-universal-newlines. See PEP278 for details.
* Fold long lines. (Walter, please take note! :-)Guido van Rossum2002-04-131-9/+18
|
* _PyObject_DebugDumpStats: renamed to _PyObject_DebugMallocStats.Tim Peters2002-04-131-4/+8
| | | | | | Added code to call this when PYMALLOC_DEBUG is enabled, and envar PYTHONMALLOCSTATS is set, whenever a new arena is obtained and once late in the Python shutdown process.
* SF bug 543148: Memory leak with stackframes + inspect.Tim Peters2002-04-131-2/+17
| | | | | | | | Put a bound on the number of frameobjects that can live in the frameobject free_list. Am also backporting to 2.2. I don't intend to backport to 2.1 (too much work -- lots of cyclic structures leak there, and the GC API).
* Partially implement SF feature request 444708.Guido van Rossum2002-04-131-15/+86
| | | | | | | | | | | | | Add optional arg to string methods strip(), lstrip(), rstrip(). The optional arg specifies characters to delete. Also for UserString. Still to do: - Misc/NEWS - LaTeX docs (I did the docstrings though) - Unicode methods, and Unicode support in the string methods.
* Small anal correctness tweaks:Tim Peters2002-04-121-2/+2
| | | | | | | | | | _PyObject_DebugMalloc: explicitly cast PyObject_Malloc's result to the target pointer type. _PyObject_DebugDumpStats: change decl of arena_alignment from unsigned int to unsigned long. This is for the 2.3 release only (it's new code).
* Add Raymond Hettinger's d.pop(). See SF patch 539949.Guido van Rossum2002-04-121-0/+38
|
* _PyObject_DebugRealloc(): rewritten to let the underlying realloc doTim Peters2002-04-121-27/+30
| | | | | | | | | | most of the work. In particular, if the underlying realloc is able to grow the memory block in place, great (this routine used to do a fresh malloc + memcpy every time a block grew). BTW, I'm not so keen here on avoiding possible quadratic-time realloc patterns as I am on making the debug pymalloc more invisible (the more it uses memory "just like" the underlying allocator, the better the chance that a suspected memory corruption bug won't vanish when the debug malloc is turned on).
* _PyObject_DebugDumpAddress(): clarify an output message.Tim Peters2002-04-121-1/+1
|
* PYMALLOC_{CLEAN, DEAD, FORBIDDEN}BYTE symbols: remove the PYMALLOC_Tim Peters2002-04-121-34/+39
| | | | | prefix. These symbols are private to the file, and the PYMALLOC_ gets in the way (overly long code lines, comments, and error messages).
* First stab at rationalizing the PyMem_ API. Mixing PyObject_xyz withTim Peters2002-04-121-6/+1
| | | | | | | | | | | | | | | | | | | | | | | | PyMem_{Del, DEL} doesn't work yet (compilation problems). pyport.h: _PyMem_EXTRA is gone. pmem.h: Repaired comments. PyMem_{Malloc, MALLOC} and PyMem_{Realloc, REALLOC} now make the same x-platform guarantees when asking for 0 bytes, and when passing a NULL pointer to the latter. object.c: PyMem_{Malloc, Realloc} just call their macro versions now, since the latter take care of the x-platform 0 and NULL stuff by themselves now. pypcre.c, grow_stack(): So sue me. On two lines, this called PyMem_RESIZE to grow a "const" area. It's not legit to realloc a const area, so the compiler warned given the new expansion of PyMem_RESIZE. It would have gotten the same warning before if it had used PyMem_Resize() instead; the older macro version, but not the function version, silently cast away the constness. IMO that was a wrong thing to do, and the docs say the macro versions of PyMem_xyz are deprecated anyway. If somebody else is resizing const areas with the macro spelling, they'll get a warning when they recompile now too.
* Move PyObject_Malloc and PyObject_Free here from object.c. RemoveNeil Schemenauer2002-04-121-61/+33
| | | | | PyMalloc_ prefix and use PyObject_ instead. I'm not sure about the debugging functions. Perhaps they should stay as PyMalloc_.
* Move PyObject_Malloc and PyObject_Free to obmalloc.c.Neil Schemenauer2002-04-121-21/+2
|
* Remove PyMalloc_*.Neil Schemenauer2002-04-121-5/+5
|
* Change signature of _PyObject_GC_Malloc to match PyObject_MALLOC.Neil Schemenauer2002-04-121-6/+6
| | | | | PyObject_Del and PyObject_GC_Del can now be used as a function designators.
* PyObject_GC_Del can now be used as a function designator.Neil Schemenauer2002-04-121-1/+1
|
* Remove PyMalloc_New and PyMalloc_Del.Neil Schemenauer2002-04-122-4/+4
|
* Remove PyMalloc_New, _PyMalloc_MALLOC, and PyMalloc_Del.Neil Schemenauer2002-04-121-7/+7
|
* Remove PyMalloc_New and PyMalloc_Del.Neil Schemenauer2002-04-121-2/+2
|
* PyObject_GC_Del can now be used as a function designator.Neil Schemenauer2002-04-123-3/+3
|
* PyObject_Del can now be used as a function designator.Neil Schemenauer2002-04-124-5/+5
|
* PyObject_GC_Del and PyObject_Del can now be used as a functionNeil Schemenauer2002-04-121-3/+3
| | | | | | designators. Remove PyMalloc_New.
* SF bug 542181: Realloc behaviorTim Peters2002-04-111-12/+16
| | | | | | | | | | | The bug report pointed out a bogosity in the comment block explaining thread safety for arena management. Repaired that comment, repaired a couple others while I was at it, and added an assert. _PyMalloc_DebugRealloc: If this needed to get more memory, but couldn't, it erroneously freed the original memory. Repaired that. This is for 2.3 only (unless we decide to backport the new pymalloc).
* Bug fix for UTF-8 encoding bug (buffer overrun) #541828.Marc-André Lemburg2002-04-101-39/+46
|
* Added test case for UTF-8 encoding bug #541828.Marc-André Lemburg2002-04-101-2/+2
|
* SF bug 538827: Python open w/ MSVC6: bad error msgs.Tim Peters2002-04-081-2/+15
| | | | | | | open_the_file: Some (not all) flavors of Windows set errno to EINVAL when passed a syntactically invalid filename. Python turned that into an incomprehensible complaint about the mode string. Fixed by special-casing MSVC.
* - A type can now inherit its metatype from its base type. Previously,Guido van Rossum2002-04-081-6/+6
| | | | | | | | | | when PyType_Ready() was called, if ob_type was found to be NULL, it was always set to &PyType_Type; now it is set to base->ob_type, where base is tp_base, defaulting to &PyObject_Type. - PyType_Ready() accidentally did not inherit tp_is_gc; now it does. Bugfix candidate.
* isatty() should return a bool.Guido van Rossum2002-04-071-1/+1
|
* Minor improvements to the stats output dump, including adding commas toTim Peters2002-04-061-10/+34
| | | | the big numbers.
* - Changed new-style class instantiation so that when C's __new__Guido van Rossum2002-04-061-0/+4
| | | | | method returns something that's not a C instance, its __init__ is not called. [SF bug #537450]
* Don't inherit tp_new! This is a retraction of half of the previousGuido van Rossum2002-04-051-1/+0
| | | | | | checkin. And since that one was, this one is also a: Bugfix candidate.
* Inherit tp_new and tp_is_gc.Guido van Rossum2002-04-051-0/+2
| | | | Bugfix candidate.
* Repair an incomprehensible comment.Tim Peters2002-04-051-2/+2
|
* _PyMalloc_DebugDumpStats(): vastly improved the output, and it nowTim Peters2002-04-051-21/+58
| | | | accounts for every byte.
* Widespread, but mostly in _PyMalloc_Malloc: optimize away all expensiveTim Peters2002-04-051-40/+39
| | | | | | | | runtime multiplications and divisions, via the scheme developed with Vladimir Marangozov on Python-Dev. The pool_header struct loses its capacity member, but gains nextoffset and maxnextoffset members; this still leaves it at 32 bytes on a 32-bit box (it has to be padded to a multiple of 8 bytes).
* A much revised version of SF patch 514662, by Naofumi Honda. ThisGuido van Rossum2002-04-041-99/+128
| | | | | | | | | speeds up __getitem__ and __setitem__ in subclasses of built-in sequences. It's much revised because I took the opportunity to refactor the code somewhat (moving a large section of duplicated code to a helper function) and added comments to a series of functions.
* Clarifying code rearrangement and comments by David Abrahams. I'veGuido van Rossum2002-04-041-28/+46
| | | | | got to admit that I haven't reviewed this carefully, but it looks okay from 30,000 views, and doesn't break anything. (SF patch 536407.)
* _PyMalloc_Realloc(): removed a now-pointless cast.Tim Peters2002-04-041-1/+1
|
* _PyMalloc_{Malloc, Realloc}: Strive to meet the doc's promises aboutTim Peters2002-04-041-42/+44
| | | | | | | | | | | | | | | | | | | what these do given a 0 size argument. This is so that when pymalloc is enabled, we don't need to wrap pymalloc calls in goofy little routines special-casing 0. Note that it's virtually impossible to meet the doc's promise that malloc(0) will never return NULL; this makes a best effort, but not an insane effort. The code does promise that realloc(not-NULL, 0) will never return NULL (malloc(0) is much harder). _PyMalloc_Realloc: Changed to take over all requests for 0 bytes, and rearranged to be a little quicker in expected cases. All over the place: when resorting to the platform allocator, call free/malloc/realloc directly, without indirecting thru macros. This should avoid needing a nightmarish pile of #ifdef-ery if PYMALLOC_DEBUG is changed so that pymalloc takes over all Py(Mem, Object} memory operations (which would add useful debugging info to PyMem_xyz allocations too).
* As Neal pointed out, bool_print was an order of magnitude too complex.Guido van Rossum2002-04-041-12/+1
|
* Oops. Here are the new files. My apologies.Guido van Rossum2002-04-031-0/+212
|
* Add the 'bool' type and its values 'False' and 'True', as described inGuido van Rossum2002-04-036-152/+143
| | | | | | | | | | | | | PEP 285. Everything described in the PEP is here, and there is even some documentation. I had to fix 12 unit tests; all but one of these were printing Boolean outcomes that changed from 0/1 to False/True. (The exception is test_unicode.py, which did a type(x) == type(y) style comparison. I could've fixed that with a single line using issubtype(x, type(y)), but instead chose to be explicit about those places where a bool is expected. Still to do: perhaps more documentation; change standard library modules to return False/True from predicates.
* Fix the names of the classmethod and staticmethod constructors as passed toFred Drake2002-04-031-2/+2
| | | | PyArg_ParseTuple() as part of the format string.