summaryrefslogtreecommitdiffstats
path: root/Objects
Commit message (Collapse)AuthorAgeFilesLines
* Introduce two new flag bits that can be set in a PyMethodDef methodFred Drake2002-03-282-3/+30
| | | | | | | | | | | | | | | | | | | descriptor, as used for the tp_methods slot of a type. These new flag bits are both optional, and mutually exclusive. Most methods will not use either. These flags are used to create special method types which exist in the same namespace as normal methods without having to use tedious construction code to insert the new special method objects in the type's tp_dict after PyType_Ready() has been called. If METH_CLASS is specified, the method will represent a class method like that returned by the classmethod() built-in. If METH_STATIC is specified, the method will represent a static method like that returned by the staticmethod() built-in. These flags may not be used in the PyMethodDef table for modules since these special method types are not meaningful in that case; a ValueError will be raised if these flags are found in that context.
* Remove weakref free list. This has the side effect of fixing a memoryNeil Schemenauer2002-03-271-26/+11
| | | | | management bug. Also, move some duplicated code into the new_weakref fucntion.
* Add missing methods iterkeys, itervalues and iteritems toWalter Dörwald2002-03-251-6/+26
| | | | | | dict-proxy objects. Add real docstrings to all methods.
* Fix whitespace.Walter Dörwald2002-03-251-15/+15
|
* _PyMalloc_DebugRealloc(): simplify decl of "fresh".Tim Peters2002-03-241-5/+15
| | | | | | Assorted: bump the serial number via a trivial new bumpserialno() function. The point is to give a single place to set a breakpoint when waiting for a specific serial number.
* Minor code cleanup -- no semantic changes.Tim Peters2002-03-231-22/+28
|
* Grow the string buffer at a mildly exponential rate for the getc versionNeil Schemenauer2002-03-231-13/+16
| | | | | | | | of get_line. This makes test_bufio finish in 1.7 seconds instead of 57 seconds on my machine (with Py_DEBUG defined). Also, rename the local variables n1 and n2 to used_v_size and total_v_size.
* Give Python a debug-mode pymalloc, much as sketched on Python-Dev.Tim Peters2002-03-232-25/+320
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When WITH_PYMALLOC is defined, define PYMALLOC_DEBUG to enable the debug allocator. This can be done independent of build type (release or debug). A debug build automatically defines PYMALLOC_DEBUG when pymalloc is enabled. It's a detected error to define PYMALLOC_DEBUG when pymalloc isn't enabled. Two debugging entry points defined only under PYMALLOC_DEBUG: + _PyMalloc_DebugCheckAddress(const void *p) can be used (e.g., from gdb) to sanity-check a memory block obtained from pymalloc. It sprays info to stderr (see next) and dies via Py_FatalError if the block is detectably damaged. + _PyMalloc_DebugDumpAddress(const void *p) can be used to spray info about a debug memory block to stderr. A tiny start at implementing "API family" checks isn't good for anything yet. _PyMalloc_DebugRealloc() has been optimized to do little when the new size is <= old size. However, if the new size is larger, it really can't call the underlying realloc() routine without either violating its contract, or knowing something non-trivial about how the underlying realloc() works. A memcpy is always done in this case. This was a disaster for (and only) one of the std tests: test_bufio creates single text file lines up to a million characters long. On Windows, fileobject.c's get_line() uses the horridly funky getline_via_fgets(), which keeps growing and growing a string object hoping to find a newline. It grew the string object 1000 bytes each time, so for a million-character string it took approximately forever (I gave up after a few minutes). So, also: fileobject.c, getline_via_fgets(): When a single line is outrageously long, grow the string object at a mildly exponential rate, instead of just 1000 bytes at a time. That's enough so that a debug-build test_bufio finishes in about 5 seconds on my Win98SE box. I'm curious to try this on Win2K, because it has very different memory behavior than Win9X, and test_bufio always took a factor of 10 longer to complete on Win2K. It *could* be that the endless reallocs were simply killing it on Win2K even in the release build.
* Check in (hopefully) corrected version of last change.Neil Schemenauer2002-03-231-0/+29
|
* Just whitespace fiddling.Tim Peters2002-03-231-10/+10
|
* Build obmalloc.c directly instead of #include'ing from object.c.Tim Peters2002-03-232-43/+50
| | | | | | | | Also move all _PyMalloc_XXX entry points into obmalloc.c. The Windows build works fine. The Unix build is changed here (Makefile.pre.in), but not tested. No other platform's build process has been fiddled.
* Undo last commit. It's causing the tests to file.Neil Schemenauer2002-03-221-28/+0
|
* Remove malloc hooks.Neil Schemenauer2002-03-221-69/+0
|
* Disallow open()ing of directories. Closes SF bug 487277.Neil Schemenauer2002-03-221-0/+28
|
* Use pymalloc if it's enabled.Neil Schemenauer2002-03-226-20/+20
|
* Add pymalloc object memory management functions. These must beNeil Schemenauer2002-03-221-0/+24
| | | | | available even if pymalloc is disabled since extension modules might use them.
* SF bug 533198: Complex power underflow raises exception.Tim Peters2002-03-221-3/+9
| | | | | | | | | | | | | | | | | | | | | | | Konrad was too kind. Not only did it raise an exception, the specific exception it raised made no sense. These are old bugs in complex_pow() and friends: 1. Raising 0 to a negative power isn't a range error, it's a domain error, so changed c_pow() to set errno to EDOM in that case instead of ERANGE. 2. Changed complex_pow() to: A. Used the Py_ADJUST_ERANGE2 macro to try to clear errno of a spurious ERANGE error due to underflow in the libm pow() called by c_pow(). B. Produced different exceptions depending on the errno value: i) For errno==EDOM, raise ZeroDivisionError instead of ValueError. This is for consistency with the non-complex cases 0.0**-2 and 0**-2 and 0L**-2. ii) For errno==ERANGE, raise OverflowError. Bugfix candidate.
* Do not insert characters for unicode-escape decoders if the error modeMartin v. Löwis2002-03-211-14/+24
| | | | is "ignore". Fixes #529104.
* Drop the PyCore_* memory API.Neil Schemenauer2002-03-182-22/+37
|
* Re-enable GC of method objects.Neil Schemenauer2002-03-181-7/+6
|
* Re-enable GC of iter objects.Neil Schemenauer2002-03-181-14/+12
|
* Simpilify PyCore_* macros by assuming the function prototypes forNeil Schemenauer2002-03-181-57/+21
| | | | malloc() and free() don't change.
* Fix for SF bug 528132 (Armin Rigo): classmethod().__get__() segfaultGuido van Rossum2002-03-181-0/+2
| | | | | | | | | | | The proper fix is not quite what was submitted; it's really better to take the class of the object passed rather than calling PyMethod_New with NULL pointer args, because that can then cause other core dumps later. I also added a testcase for the fix to classmethods() in test_descr.py. I've already applied this to the 2.2 branch.
* SF patch 530070: pydoc regression, from Martin and Guido.Tim Peters2002-03-171-3/+19
| | | | | Change the way __doc__ is handled, to avoid blowing up on non-string __doc__ values.
* Patch #530105: Allow file object may to be subtypedMartin v. Löwis2002-03-151-11/+0
|
* Patch #517521: Consider byte strings before Unicode stringsMartin v. Löwis2002-03-151-52/+60
| | | | in PyObject_Get/SetAttr.
* "Fix" for SF bug #520644: __slots__ are not pickled.Guido van Rossum2002-03-141-1/+37
| | | | | | | | | As promised in my response to the bug report, I'm not really fixing it; in fact, one could argule over what the proper fix should do. Instead, I'm adding a little magic that raises TypeError if you try to pickle an instance of a class that has __slots__ but doesn't define or override __getstate__. This is done by adding a bozo __getstate__ that always raises TypeError.
* Fix for SF bug #529050 - ModuleType.__new__ crash.Guido van Rossum2002-03-121-7/+19
| | | | | | | | | | There were several places that assumed the md_dict field was always set, but it needn't be. Fixed these to be more careful. I changed PyModule_GetDict() to initialize md_dict to a new dictionary if it's NULL. Bugfix candidate.
* Change Windows file.truncate() to (a) restore the original file position,Tim Peters2002-03-121-27/+40
| | | | | | | | | | | | and (b) stop trying to prevent file growth. Beef up the file.truncate() docs. Change test_largefile.py to stop assuming that f.truncate() moves the file pointer to the truncation point, and to verify instead that it leaves the file position alone. Remove the test for what happens when a specified size exceeds the original file size (it's ill-defined, according to the Single Unix Spec).
* file_truncate(): provide full "large file" support on Windows, byTim Peters2002-03-111-20/+55
| | | | | | | | | | | | | | | | | | | | dropping MS's inadequate _chsize() function. This was inspired by SF patch 498109 ("fileobject truncate support for win32"), which I rejected. libstdtypes.tex: Someone who knows should update the availability blurb. For example, if it's available on Linux, it would be good to say so. test_largefile: Uncommented the file.truncate() tests, and reworked to do more. The old comment about "permission errors" in the truncation tests under Windows was almost certainly due to that the file wasn't open for *write* access at this point, so of course MS wouldn't let you truncate it. I'd be appalled if a Unixish system did. CAUTION: Someone should run this test on Linux (etc) too. The truncation part was commented out before. Note that test_largefile isn't run by default.
* Bugfix candidate.Guido van Rossum2002-03-101-1/+1
| | | | | | | Adapter from SF patch 528038; fixes SF bug 527816. The wrapper for __nonzero__ should be wrap_inquiry rather than wrap_unaryfunc, since the slot returns an int, not a PyObject *.
* Patch #494047: removes 64-bit ?: to cope on plan9.Martin v. Löwis2002-03-091-2/+10
|
* SF bug 525705: [2.2] underflow raise OverflowException.Tim Peters2002-03-091-2/+2
| | | | | | | | | | | | | | | | | | | | Another year in the quest to out-guess random C behavior. Added macros Py_ADJUST_ERANGE1(X) and Py_ADJUST_ERANGE2(X, Y). The latter is useful for functions with complex results. Two corrections to errno- after-libm-call are attempted: 1. If the platform set errno to ERANGE due to underflow, clear errno. Some unknown subset of libm versions and link options do this. It's allowed by C89, but I never figured anyone would do it. 2. If the platform did not set errno but overflow occurred, force errno to ERANGE. C89 required setting errno to ERANGE, but C99 doesn't. Some unknown subset of libm versions and link options do it the C99 way now. Bugfix candidate, but hold off until some Linux people actually try it, with and without -lieee. I'll send a help plea to Python-Dev.
* Fix leak of NotImplemented in previous checkin to PyNumber_Add().Jeremy Hylton2002-03-081-4/+6
| | | | | If result == Py_NotImplemented, always DECREF it before assigning a new value to result.
* Fix for SF bug 516727: MyInt(2) + "3" -> NotImplementedJeremy Hylton2002-03-081-4/+3
| | | | | | PyNumber_Add() tries the nb_add slot first, then falls back to sq_concat. However, tt didn't check the return value of sq_concat. If sq_concat returns NotImplemented, raise the standard TypeError.
* Guido pointed out that I was missing a couple decrefs.Michael W. Hudson2002-03-071-1/+7
|
* Apply (my) patch:Michael W. Hudson2002-03-061-23/+76
| | | | | | | | | | | | | | | | | [ 526072 ] pickling os.stat results round II structseq's constructors can now take "invisible" fields in a dict. Gave the constructors better error messages. their __reduce__ method puts these fields in a dict. (this is all in aid of getting os.stat_result's to pickle portably) Also fixes [ 526039 ] devious code can crash structseqs Thought needed about how much of this counts as a bugfix. Certainly #526039 needs to be fixed.
* A fix & test forMichael W. Hudson2002-03-051-1/+30
| | | | | | | | [ 496873 ] structseqs unpicklable by adding a __reduce__ method to structseqs. Will also commit this to the 2.2.1 branch momentarily.
* Whether platform malloc(0) returns NULL has nothing to do with whetherTim Peters2002-03-021-5/+2
| | | | | | | | | | | platform realloc(p, 0) returns NULL, so MALLOC_ZERO_RETURNS_NULL can be correctly undefined yet realloc(p, 0) can return NULL anyway. Prevent realloc(p, 0) doing free(p) and returning NULL via a different hack. Would probably be better to get rid of MALLOC_ZERO_RETURNS_NULL entirely. Bugfix candidate.
* _PyLong_Copy(): was creating a copy of the absolute value, but shouldTim Peters2002-03-021-1/+1
| | | | | | copy the sign too. Added a test to test_descr to ensure that it does. Bugfix candidate.
* Revert the last odd change to PyNumber_Long: the problem it was tryingTim Peters2002-03-021-10/+2
| | | | to fix was almost certainly a bug in _PyLong_Copy (which I'll fix next).
* SF patch 514641 (Naofumi Honda) - Negative ob_size of LongObjectsGuido van Rossum2002-03-012-4/+18
| | | | | | | | | | Due to the bizarre definition of _PyLong_Copy(), creating an instance of a subclass of long with a negative value could cause core dumps later on. Unfortunately it looks like the behavior of _PyLong_Copy() is quite intentional, so the fix is more work than feels comfortable. This fix is almost, but not quite, the code that Naofumi Honda added; in addition, I added a test case.
* %#x/%#X format conversion cleanup (see patch #450267):Andrew MacIntyre2002-02-282-63/+74
| | | | | | Objects/ stringobject.c unicodeobject.c
* OS/2 EMX port changes (Objects part of patch #450267):Andrew MacIntyre2002-02-263-0/+23
| | | | | | | | | | | | Objects/ fileobject.c stringobject.c unicodeobject.c This commit doesn't include the cleanup patches for stringobject.c and unicodeobject.c which are shown separately in the patch manager. Those patches will be regenerated and applied in a subsequent commit, so as to preserve a fallback position (this commit to those files).
* Allow __doc__ to be of arbitrary type. Patch by James Henstridge,Martin v. Löwis2002-02-181-4/+16
| | | | fixes #504343. 2.2.1 candidate.
* Patch #508038: Do not use a type as a variable name.Martin v. Löwis2002-02-161-3/+3
|
* Declare real and imag as read-only attributes.Guido van Rossum2002-02-081-2/+2
| | | | | | | This fixes SF bug #514858 (Gregory Smith): complex not entirely immutable 2.2.1 Bugfix candidate!
* Fix to the UTF-8 encoder: it failed on 0-length input strings.Marc-André Lemburg2002-02-071-6/+17
| | | | | | | | | | | | | | Fix for the UTF-8 decoder: it will now accept isolated surrogates (previously it raised an exception which causes round-trips to fail). Added new tests for UTF-8 round-trip safety (we rely on UTF-8 for marshalling Unicode objects, so we better make sure it works for all Unicode code points, including isolated surrogates). Bumped the PYC magic in a non-standard way -- please review. This was needed because the old PYC format used illegal UTF-8 sequences for isolated high surrogates which now raise an exception.
* Cosmetics.Marc-André Lemburg2002-02-061-6/+6
|
* Whitespace fixes.Marc-André Lemburg2002-02-061-11/+11
|