summaryrefslogtreecommitdiffstats
path: root/Objects
Commit message (Collapse)AuthorAgeFilesLines
* proxy_compare(): Make sure that we unwrap both objects being compared ifFred Drake2001-12-191-6/+13
| | | | both are proxy objects.
* - PyType_Ready(): Initialize the ob_type field to &PyType_Type if it'sGuido van Rossum2001-12-171-0/+16
| | | | | | | | NULL, so that you can call PyType_Ready() to initialize a type that is to be separately compiled with C on Windows. inherit_special(): Add a long comment explaining that you have to set tp_new if your base class is PyBaseObject_Type.
* Portability fix: Not every compiler implements the extension ofSjoerd Mullender2001-12-171-1/+1
| | | | unescaped newlines in strings.
* SF patch #493452: docstrings for staticmethod/classmethod (SkipGuido van Rossum2001-12-171-2/+41
| | | | | | Montanaro) (With minor adjustments.)
* SF bug #493561: incorrect format string descrobject.c (Neal Norwitz)Guido van Rossum2001-12-151-2/+2
| | | | %300s should be %.300s, twice.
* (Merge into trunk.)Guido van Rossum2001-12-141-1/+3
| | | | | | | | | | | | | | | | | Fix for SF bug #492345. (I could've sworn I checked this in, but apparently I didn't!) This code: class Classic: pass class New(Classic): __metaclass__ = type attempts to create a new-style class with only classic bases -- but it doesn't work right. Attempts to fix it so it works caused problems elsewhere, so I'm now raising a TypeError in this case.
* Ensure that complex() only accepts a string argument as the first arg,Fred Drake2001-12-131-1/+13
| | | | | and only if there is no second arg. This closes SF patch #479551.
* float_floor_div: An expression like 3.//1j crashed the interpreter, orTim Peters2001-12-111-9/+12
| | | | | | | delivered bizarre results. Check float_divmod for a Py_NotImplemented return and pass it along (instead of treating Py_NotImplemented as a 2-tuple). CONVERT_TO_DOUBLE: Added comments; this macro is obscure.
* float_int_div(): For clarity, move this closer to the other floatTim Peters2001-12-111-16/+16
| | | | division functions, and rename to float_floor_div.
* SF bug #491415 PyDict_UpdateFromSeq2() unusedTim Peters2001-12-111-8/+2
| | | | | | | PyDict_UpdateFromSeq2(): removed it. PyDict_MergeFromSeq2(): made it public and documented it. PyDict_Merge() docs: updated to reveal <wink> that the second argument can be any mapping object.
* Make sure that when we invoke callback functions associated with weakFred Drake2001-12-101-20/+24
| | | | | | references, we do not allow any outstanding exceptions "leak" into the callback's execution state. This closes SF bug #478534.
* Well what do you know. The Python implementation contained the sameGuido van Rossum2001-12-101-2/+2
| | | | bug as the C code. :-(
* Fix the Python property class in a comment right.Guido van Rossum2001-12-101-22/+23
|
* property_descr_get(): Fix a curious bug in the property() type: whenGuido van Rossum2001-12-101-5/+5
| | | | | | | | | | no get function was defined, the property's doc string was inaccessible. This was because the test for prop_get was made *before* the test for a NULL/None object argument. Also changed the property class defined in Python in a comment to test for NULL to decide between get and delete; this makes it less Python but then, assigning None to a property doesn't delete it!
* SF patch #491049 (David Jacobs): Small PyString_FromString optimizationGuido van Rossum2001-12-101-1/+1
| | | | | | PyString_FromString(): Since the length of the string is already being stored in size, changed the strcpy() to a memcpy() for a small speed improvement.
* _PyTuple_Resize(): this dumped core on tuple(globals()) for me. TurnsGuido van Rossum2001-12-071-6/+8
| | | | | | | | | | | out the for loop at the end intended to zero out new items wasn't doing anything, because sv->ob_size was already equal to newsize. The fix slightly refactors the function, introducing a variable oldsize and doing away with sizediff (which was used only once), and using oldsize and newsize consistently. I also added comments explaining what the two for loops do. (Looking at the CVS annotation of this function, it's no miracle a bug crept in -- this has been patched by many different folks! :-)
* PyString_FromString: this requires its argument be non-NULL, but doesn'tTim Peters2001-12-061-1/+4
| | | | check it. Added an assert() to that effect.
* Fix for #489669 (Neil Norwitz): memory leak in test_descr (unicode).Guido van Rossum2001-12-061-6/+3
| | | | | | | | | | | | | | This is best reproduced by while 1: class U(unicode): pass U(u"xxxxxx") The unicode_dealloc() code wasn't properly freeing the str and defenc fields of the Unicode object when freeing a subtype instance. Fixed this by a subtle refactoring that actually reduces the amount of code slightly.
* Fix memory leak in dict_to_map(), SF bug [ #485152 ] memory leak in test_scope.Jeremy Hylton2001-12-061-8/+11
| | | | | | | | | | | | PyCell_Set() incremenets the reference count, so the earlier XINCREF causes a leak. Also make a number of small performance improvements to the code on the assumption that most of the time variables are not rebound across a FastToLocals() / LocalsToFast() pair. Replace uses of PyCell_Set() and PyCell_Get() with PyCell_SET() and PyCell_GET(), since the frame is guaranteed to contain cells.
* Little stuff.Jeremy Hylton2001-12-061-8/+9
| | | | | | | | | | | Add a missing DECREF in an obscure corner. If the str() or repr() of an object passed to a string interpolation -- e.g. "%s" % obj -- returns a non-string, the returned object was leaked. Repair an indentation glitch. Replace a bunch of PyString_AsString() calls (and their ilk) with macros.
* The previous checkin to clear __slots__ variables did a little bit ofGuido van Rossum2001-12-061-20/+20
| | | | | the work each time it found another base class. All the work is contiguous, so we might as well do it all at once at the end.
* Fix SF bug #489581: __slots__ leak.Guido van Rossum2001-12-051-2/+22
| | | | | | It was easier than I thought, assuming that no other things contribute to the instance size besides slots -- a pretty good bet. With a test suite, no less!
* At the PythonLabs meeting someone mentioned it would make Jim reallyGuido van Rossum2001-12-051-2/+2
| | | | | | | | | happy if one could delete the __dict__ attribute of an instance. I love to make Jim happy, so here goes... - New-style objects now support deleting their __dict__. This is for all intents and purposes equivalent to assigning a brand new empty dictionary, but saves space if the object is not used further.
* SF bug #488480: integer multiply to return -max_int-1.Tim Peters2001-12-041-127/+63
| | | | | | | int_mul(): new and vastly simpler overflow checking. Whether it's faster or slower will likely vary across platforms, favoring boxes with fast floating point. OTOH, we no longer have to worry about people shipping broken LONG_BIT definitions <0.9 wink>.
* Fix SF bug #486144: Uninitialized __slot__ vrbl is None.Guido van Rossum2001-12-041-2/+4
| | | | | | | There's now a new structmember code, T_OBJECT_EX, which is used for all __slot__ variables (except __weakref__, which has special behavior anyway). This new code raises AttributeError when the variable is NULL rather than converting NULL to None.
* long_mul(): The PyNumber_Multiply() call can return a long if theGuido van Rossum2001-12-041-0/+6
| | | | | result would overflow an int. Check for this. (SF bug #488482, Armin Rigo.)
* PyObject_Generic{Get,Set}Attr(): ensure that the attribute name is aGuido van Rossum2001-12-041-20/+72
| | | | | | | string object (or a Unicode that's trivially converted to ASCII). PyObject_GetAttr(): add an 'else' to the Unicode test like PyObject_SetAttr() already has.
* function_call(): Remove a bogus (and I mean *really* bogus) call toGuido van Rossum2001-12-031-1/+0
| | | | | Py_DECREF(arg) after the PyErr_NoMemory() call. (Armin Rigo, SF bug #488477.)
* Fix of SF bug #475877 (Mutable subtype instances are hashable).Guido van Rossum2001-12-032-3/+17
| | | | | | | | | | | | | | | | | Rather than tweaking the inheritance of type object slots (which turns out to be too messy to try), this fix adds a __hash__ to the list and dict types (the only mutable types I'm aware of) that explicitly raises an error. This has the advantage that list.__hash__([]) also raises an error (previously, this would invoke object.__hash__([]), returning the argument's address); ditto for dict.__hash__. The disadvantage for this fix is that 3rd party mutable types aren't automatically fixed. This should be added to the rules for creating subclassable extension types: if you don't want your object to be hashable, add a tp_hash function that raises an exception. Also, it's possible that I've forgotten about other mutable types for which this should be done.
* Address SF patch #480716 as well as related issues.Guido van Rossum2001-12-031-17/+36
| | | | | | | | | | | | | | | | | | | SF patch #480716 by Greg Chapman fixes the problem that super's __get__ method always returns an instance of super, even when the instance whose __get__ method is called is an instance of a subclass of super. Other issues fixed: - super(C, C()).__class__ would return the __class__ attribute of C() rather than the __class__ attribute of the super object. This is confusing. To fix this, I decided to change the semantics of super so that it only applies to code attributes, not to data attributes. After all, overriding data attributes is not supported anyway. - While super(C, x) carefully checked that x is an instance of C, super(C).__get__(x) made no such check, allowing for a loophole. This is now fixed.
* Add more inline documentation, as contributed in #487906.Martin v. Löwis2001-12-031-3/+8
|
* PyString_FromFormatV, string_repr: document why these use sprintfTim Peters2001-12-031-5/+16
| | | | instead of PyOS_snprintf; add some relevant comments and asserts.
* Fix for SF bug #485678.Guido van Rossum2001-12-031-1/+1
| | | | | | | | slot_tp_descr_set(): When deleting an attribute described by a descriptor implemented in Python, the descriptor's __del__ method is called by the slot_tp_descr_set dispatch function. This is bogus -- __del__ already has a different meaning. Renaming this use of __del__ is renamed to __delete__.
* Patch 487906: update inline docs.Martin v. Löwis2001-12-021-13/+21
|
* SF bug #487743: test_builtin fails on 64 bit platform.Tim Peters2001-12-011-1/+1
| | | | | | | | Bugfix candidate. int_repr(): we've never had a buffer big enough to hold the largest possible result on a 64-bit box. Now that we're using snprintf instead of sprintf, this can lead to nonsense results instead of random stack corruption.
* Merged changes made on r22b2-branch between r22b2 and r22b2-mac (theJack Jansen2001-11-301-2/+7
| | | | changes from start of branch upto r22b2 were already merged, of course).
* PyFloat_AsStringEx(): This function takes an output char* but doesn'tTim Peters2001-11-281-8/+24
| | | | | | | pass the buffer length. Stop using it. It should be deprecated, but too late in the release cycle to do that now. New static format_float() does the same thing but requires passing the buffer length too. Use it instead.
* PyFile_WriteString(): change prototype so that the string arg isTim Peters2001-11-281-1/+1
| | | | | | const char* instead of char*. The change is conceptually correct, and indirectly fixes a compiler wng introduced when somebody else innocently passed a const char* to this function.
* weakref_repr(), proxy_repr(): Conversion of sprintf() toBarry Warsaw2001-11-281-8/+11
| | | | PyOS_snprintf() for buffer overrun avoidance.
* formatfloat(), formatint(): Conversion of sprintf() to PyOS_snprintf()Barry Warsaw2001-11-281-4/+6
| | | | for buffer overrun avoidance.
* structseq_new(): Conversion of sprintf() to PyOS_snprintf() for bufferBarry Warsaw2001-11-281-1/+2
| | | | overrun avoidance.
* PyInt_FromString(), int_repr(), int_oct(), int_hex(): Conversion ofBarry Warsaw2001-11-281-5/+7
| | | | sprintf() to PyOS_snprintf() for buffer overrun avoidance.
* PyFloat_FromString(): Conversion of sprintf() to PyOS_snprintf() forBarry Warsaw2001-11-281-2/+4
| | | | buffer overrun avoidance.
* complex_to_buf(), complex_subtype_from_c_complex(): Conversion ofBarry Warsaw2001-11-281-8/+10
| | | | | | | sprintf() to PyOS_snprintf() for buffer overrun avoidance. complex_print(), complex_repr(), complex_str(): Call complex_to_buf() passing in sizeof(buf).
* sprintf -> PyOS_snprintf in some "obviously safe" cases.Tim Peters2001-11-281-4/+8
| | | | | Also changed <>-style #includes to ""-style in some places where the former didn't make sense.
* Fix for bug #485951: repr diff between string and unicode.Marc-André Lemburg2001-11-281-1/+1
|
* Fixes for possible buffer overflows in sprintf() usages.Marc-André Lemburg2001-11-281-1/+1
|
* PyObject_GetItem(), PyObject_SetItem(), PyObject_DelItem(): Fix a fewGuido van Rossum2001-11-241-5/+10
| | | | | | | confusing error messages. If a new-style class has no sequence or mapping behavior, attempting to use the indexing notation with a non-integer key would complain that the sequence index must be an integer, rather than complaining that the operation is not supported.
* Fix for bug #438164: %-formatting using Unicode objects.Marc-André Lemburg2001-11-201-0/+4
| | | | | This patch also does away with an incompatibility between Jython and CPython.
* Changing diapers reminded Guido that he wanted to allow for some measureTim Peters2001-11-141-29/+97
| | | | | | of multiple inheritance from a mix of new- and classic-style classes. This is his patch, plus a start at some test cases from me. Will check in more, plus a NEWS blurb, later tonight.