summaryrefslogtreecommitdiffstats
path: root/Objects
Commit message (Collapse)AuthorAgeFilesLines
* Add checks for size overflow on list*n, list+list, tuple+tuple.Guido van Rossum2002-10-112-0/+6
| | | | Will backport.
* PyObject_Init[Var] is almost always called from the PyObject_NEW[_VAR]Guido van Rossum2002-10-111-10/+4
| | | | | | | | | | macros. The 'op' argument is then the result from PyObject_MALLOC, and that can of course be NULL. In that case, PyObject_Init[Var] would raise a SystemError with "NULL object passed to PyObject_Init[Var]". But there's nothing the caller of the macro can do about this. So PyObject_Init[Var] should call just PyErr_NoMemory. Will backport.
* Back out #479898.Martin v. Löwis2002-10-111-69/+15
|
* Fix a nasty endcase reported by Armin Rigo in SF bug 618623:Guido van Rossum2002-10-112-4/+12
| | | | | | | | | | | | | '%2147483647d' % -123 segfaults. This was because an integer overflow in a comparison caused the string resize to be skipped. After fixing the overflow, this could call _PyString_Resize() with a negative size, so I (1) test for that and raise MemoryError instead; (2) also added a test for negative newsize to _PyString_Resize(), raising SystemError as for all bad arguments. An identical bug existed in unicodeobject.c, of course. Will backport to 2.2.2.
* Undo this part of the previous checkin:Guido van Rossum2002-10-091-3/+4
| | | | | | | | | Also fixed an error message -- %s argument has non-string str() doesn't make sense for %r, so the error message now differentiates between %s and %r. because PyObject_Repr() and PyObject_Str() ensure that this can never happen. Added a helpful comment instead.
* The string formatting code has a test to switch to Unicode when %sGuido van Rossum2002-10-091-2/+5
| | | | | | | | | | | | | | sees a Unicode argument. Unfortunately this test was also executed for %r, because %s and %r share almost all of their code. This meant that, if u is a unicode object while repr(u) is an 8-bit string containing ASCII characters, '%r' % u is a *unicode* string containing only ASCII characters! Fixed by executing the test only for %s. Also fixed an error message -- %s argument has non-string str() doesn't make sense for %r, so the error message now differentiates between %s and %r.
* Include wctype.h.Martin v. Löwis2002-10-071-1/+2
|
* Patch #479898: Use multibyte C library for printing strings if available.Martin v. Löwis2002-10-071-15/+68
|
* Patch 594001: PEP 277 - Unicode file name support for Windows NT.Mark Hammond2002-10-031-13/+83
|
* Add cast to avoid compiler warning.Marc-André Lemburg2002-09-241-1/+1
|
* Fix part of SF bug # 544248 gcc warning in unicodeobject.cNeal Norwitz2002-09-131-1/+1
| | | | When --enable-unicode=ucs4, need to cast Py_UNICODE to a char
* Fix warnings on 64-bit platforms about casts from pointers to ints.Guido van Rossum2002-09-123-3/+5
| | | | Two of these were real bugs.
* Fix for platforms where int != long.Michael W. Hudson2002-09-121-1/+1
|
* Insert an overflow check when the sequence repetition count is outsideGuido van Rossum2002-09-111-3/+30
| | | | | | | the range of ints. The old code would pass random truncated bits to sq_repeat() on a 64-bit machine. Backport candidate.
* Untested code for 64-bit platforms. range_length() is declared as intGuido van Rossum2002-09-111-1/+8
| | | | | | | | | | but returns r->len which is a long. This doesn't even cause a warning on 32-bit platforms, but can return bogus values on 64-bit platforms (and should cause a compiler warning). Fix this by inserting a range check when LONG_MAX != INT_MAX, and adding an explicit cast to (int) when the test passes. When r->len is out of range, PySequence_Size() and hence len() will report an error (but an iterator will still work).
* A slight change to SET_LINENO-less tracing.Michael W. Hudson2002-09-111-2/+36
| | | | | This makes things a touch more like 2.2. Read the comments in Python/ceval.c for more details.
* Fix escaping of non-ASCII characters.Martin v. Löwis2002-09-091-2/+4
|
* PyObject_RichCompareBool() already returns -1, 0, or 1, so return its valueNeal Norwitz2002-09-052-10/+2
|
* Micro-optimization for list_contains. Factored double if testRaymond Hettinger2002-09-051-7/+6
| | | | out of the loop.
* Micro-optimization for list_contains. Factored double if testRaymond Hettinger2002-09-051-8/+7
| | | | out of the loop.
* Change the unicode.translate docstring to document thatWalter Dörwald2002-09-041-2/+3
| | | | | | | | | | Unicode strings (with arbitrary length) are allowed as entries in the unicode.translate mapping. Add a test case for multicharacter replacements. (Multicharacter replacements were enabled by the PEP 293 patch)
* In doc strings, use 'k in D' rather than D.has_key(k).Guido van Rossum2002-09-041-2/+2
|
* replace thread state objects' ticker and checkinterval fields with twoSkip Montanaro2002-09-031-4/+2
| | | | | | | | | | globals, _Py_Ticker and _Py_CheckInterval. This also implements Jeremy's shortcut in Py_AddPendingCall that zeroes out _Py_Ticker. This allows the test in the main loop to only test a single value. The gory details are at http://python.org/sf/602191
* Check whether a string resize is necessary at the endWalter Dörwald2002-09-031-3/+4
| | | | | | | | | of PyString_DecodeEscape(). This prevents a call to _PyString_Resize() for the empty string, which would result in a PyErr_BadInternalCall(), because the empty string has more than one reference. This closes SF bug http://www.python.org/sf/603937
* PEP 293 implemention (from SF patch http://www.python.org/sf/432401)Walter Dörwald2002-09-022-554/+1246
|
* Added comparison functions to dict proxies.Raymond Hettinger2002-08-311-2/+14
| | | | | Now all non-mutating dict methods are in the proxy also. Inspired by SF bug #602232,
* SF #561244: micro optimizations, builtins cannot be NULL, so use Py_INCREFNeal Norwitz2002-08-291-1/+1
|
* complex() was the only numeric constructor that created a new instanceRaymond Hettinger2002-08-291-0/+9
| | | | when given its own type as an argument.
* string_contains(): speed up by avoiding function calls whereGuido van Rossum2002-08-241-9/+12
| | | | | | possible. This always called PyUnicode_Check() and PyString_Check(), at least one of which would call PyType_IsSubtype(). Also, this would call PyString_Size() on known string objects.
* Speedup for PyObject_IsTrue(): check for True and False first.Guido van Rossum2002-08-241-0/+4
| | | | | Because all built-in tests return bools now, this is the most common path!
* Speedup for PyObject_RichCompareBool(): PyObject_RichCompare() almostGuido van Rossum2002-08-241-1/+4
| | | | | always returns a bool, so avoid calling PyObject_IsTrue() in that case.
* Fix SF bug 599128, submitted by Inyeol Lee: .replace() would do theGuido van Rossum2002-08-231-3/+9
| | | | | | | | | | | | | wrong thing for a unicode subclass when there were zero string replacements. The example given in the SF bug report was only one way to trigger this; replacing a string of length >= 2 that's not found is another. The code would actually write outside allocated memory if replacement string was longer than the search string. (I wonder how many more of these are lurking? The unicode code base is full of wonders.) Bugfix candidate; this same bug is present in 2.2.1.
* Code by Inyeol Lee, submitted to SF bug 595350, to implementGuido van Rossum2002-08-232-38/+53
| | | | | the string/unicode method .replace() with a zero-lengt first argument. Inyeol contributed tests for this too.
* long_format(), long_lshift(): Someone on c.l.py is trying to boostTim Peters2002-08-201-2/+2
| | | | | | | | | | | | SHIFT and MASK, and widen digit. One problem is that code of the form digit << small_integer implicitly assumes that the result fits in an int or unsigned int (platform-dependent, but "int sized" in any case), since digit is promoted "just" to int or unsigned via the usual integer promotions. But if digit is typedef'ed as unsigned int, this loses information. The cure for this is just to cast digit to twodigits first.
* Fix some endcase bugs in unicode rfind()/rindex() and endswith().Guido van Rossum2002-08-202-4/+4
| | | | | | These were reported and fixed by Inyeol Lee in SF bug 595350. The endswith() bug was already fixed in 2.3, but this adds some more test cases.
* getinstclassname(): Squash new compiler wng in assert (comparison ofTim Peters2002-08-201-1/+1
| | | | signed vs unsigned).
* SF patch 576101, by Oren Tirosh: alternative implementation ofGuido van Rossum2002-08-193-100/+135
| | | | | | | | interning. I modified Oren's patch significantly, but the basic idea and most of the implementation is unchanged. Interned strings created with PyString_InternInPlace() are now mortal, and you must keep a reference to the resulting string around; use the new function PyString_InternImmortal() to create immortal interned strings.
* Call me anal, but there was a particular phrase that was speading toGuido van Rossum2002-08-196-8/+8
| | | | | | | comments everywhere that bugged me: /* Foo is inlined */ instead of /* Inline Foo */. Somehow the "is inlined" phrase always confused me for half a second (thinking, "No it isn't" until I added the missing "here"). The new phrase is hopefully unambiguous.
* Another modest speedup in PyObject_GenericGetAttr(): inline the callGuido van Rossum2002-08-191-2/+26
| | | | to _PyType_Lookup().
* Make PyDescr_IsData() a macro. It's too simple to be a function.Guido van Rossum2002-08-191-6/+0
| | | | Should save 4% on slot lookups.
* Check in my ultra-shortlived patch #597220.Michael W. Hudson2002-08-191-3/+3
| | | | | | Move some debugging checks inside Py_DEBUG. They were causing cache misses according to cachegrind.
* Inline call to _PyObject_GetDictPtr() in PyObject_GenericGetAttr().Guido van Rossum2002-08-191-3/+20
| | | | This causes a modest speedup.
* Simple but important optimization for descr_check(): instead of theGuido van Rossum2002-08-191-1/+1
| | | | | | | expensive and overly general PyObject_IsInstance(), call PyObject_TypeCheck() which is a macro that often avoids a call, and if it does make a call, calls the much more efficient PyType_IsSubtype(). This saved 6% on a benchmark for slot lookups.
* Get this to compile again if Py_USING_UNICODE is not defined.Neal Norwitz2002-08-161-1/+1
| | | | com_error() is static in Python/compile.c.
* Squash a few calls to the hideously expensive PyObject_CallObject(o,a)Guido van Rossum2002-08-163-8/+22
| | | | | | | -- replace then with slightly faster PyObject_Call(o,a,NULL). (The difference is that the latter requires a to be a tuple; the former allows other values and wraps them in a tuple if necessary; it involves two more levels of C function calls to accomplish all that.)
* Fix SF bug 595838 -- buffer in type_new() should not be static. MovedGuido van Rossum2002-08-161-1/+1
| | | | to inner scope, too.
* Illustrating by example one good reason not to trust a proof <wink>.Tim Peters2002-08-151-3/+3
|
* k_mul() comments: In honor of Dijkstra, made the proof that "t3 fits"Tim Peters2002-08-151-34/+37
| | | | | | | rigorous instead of hoping for testing not to turn up counterexamples. Call me heretical, but despite that I'm wholly confident in the proof, and have done it two different ways now, I still put more faith in testing ...
* long_mul(): Simplified exit code. In particular, k_mul() returns aTim Peters2002-08-151-9/+3
| | | | | normalized result, so no point to normalizing it again. The number of test+branches was also excessive.
* This is my patchMichael W. Hudson2002-08-151-2/+12
| | | | | | | | [ 587993 ] SET_LINENO killer Remove SET_LINENO. Tracing is now supported by inspecting co_lnotab. Many sundry changes to document and adapt to this change.