summaryrefslogtreecommitdiffstats
path: root/Python/bltinmodule.c
Commit message (Collapse)AuthorAgeFilesLines
* Correct check of PyUnicode_Resize() return value.Jeremy Hylton2003-09-161-1/+2
|
* Reflow long lines and reformat.Jeremy Hylton2003-09-161-13/+13
|
* Fix a crash: when sq_item failed the code continued blindly and used theWalter Dörwald2003-08-181-3/+10
| | | | | | NULL pointer. (Detected by Michael Hudson, patch provided by Neal Norwitz). Fix refcounting leak in filtertuple().
* Make filter(bool, ...) as fast as filter(None, ...).Neil Schemenauer2003-08-141-1/+1
|
* As discussed on python-dev, changed builtin.zip() to handle zero argumentsRaymond Hettinger2003-08-021-5/+3
| | | | by returning an empty list instead of raising a TypeError.
* some more error-message enhancementsAlex Martelli2003-04-231-10/+10
|
* complete and clarify some error messages for range()Alex Martelli2003-04-231-5/+5
|
* fixed a potential refcount bug (thanks Raymond!).Alex Martelli2003-04-221-1/+1
|
* Adding new built-in function sum, with docs and tests.Alex Martelli2003-04-221-0/+61
|
* Some errors from range() should be TypeError, not ValueError.Guido van Rossum2003-04-151-3/+3
|
* Prompted by Tim's comment, when handle_range_longs() sees anGuido van Rossum2003-04-141-9/+9
| | | | | unexpected type, report the actual type rather than 'float'. (It's hard to even reach this code with a float. :-)
* handle_range_longs(): refcount handling is very delicate here, andTim Peters2003-04-131-31/+50
| | | | | | | the code erroneously decrefed the istep argument in an error case. This caused a co_consts tuple to lose a float constant prematurely, which eventually caused gc to try executing static data in floatobject.c (don't ask <wink>). So reworked this extensively to ensure refcount correctness.
* Patch by Chad Netzer (with significant change):Guido van Rossum2003-04-111-5/+190
| | | | | | | - range() now works even if the arguments are longs with magnitude larger than sys.maxint, as long as the total length of the sequence fits. E.g., range(2**100, 2**101, 2**100) is the following list: [1267650600228229401496703205376L]. (SF patch #707427.)
* SF patch #701494: more apply removalsRaymond Hettinger2003-04-061-1/+4
|
* Improved new Py_TRACE_REFS gimmicks.Tim Peters2003-03-231-2/+16
| | | | | | | | | | | Arranged that all the objects exposed by __builtin__ appear in the list of all objects. I basically peed away two days tracking down a mystery leak in sys.gettotalrefcount() in a ZODB app (== tons of code), because the object leaking the references didn't appear in the sys.getobjects(0) list. The object happened to be False. Now False is in the list, along with other popular & previously missing leak candidates (like None). Alas, we still don't have a choke point covering *all* Python objects, so the list of all objects may still be incomplete.
* Fix SF bug #690435, apply fails to check if warning raises exceptionNeal Norwitz2003-02-231-3/+4
| | | | (patch provided by Greg Chapman)
* - Finally fixed the bug in compile() and exec where a string endingGuido van Rossum2003-02-131-1/+3
| | | | | | | | | with an indented code block but no newline would raise SyntaxError. This would have been a four-line change in parsetok.c... Except codeop.py depends on this behavior, so a compilation flag had to be invented that causes the tokenizer to revert to the old behavior; this required extra changes to 2 .h files, 2 .c files, and 2 .py files. (Fixes SF bug #501622.)
* Change filtertuple() to use tp_as_sequence->sq_itemWalter Dörwald2003-02-101-1/+6
| | | | | instead of PyTuple_GetItem, so an overwritten __getitem__ in a tuple subclass works. SF bug #665835.
* Squashed compiler wng about signed/unsigned clash in comparison.Tim Peters2003-02-101-1/+1
|
* Change filterstring() and filterunicode(): If theWalter Dörwald2003-02-101-43/+48
| | | | | | | | | | | | object is not a real str or unicode but an instance of a subclass, construct the output via looping over __getitem__. This guarantees that the result is the same for function==None and function==lambda x:x This doesn't happen for tuples, because filtertuple() uses PyTuple_GetItem(). (This was discussed on SF bug #665835).
* My previous checkin caused compile() to no longer accept buffers, as notedJust van Rossum2003-02-101-5/+7
| | | | | my MAL. Fixed. (Btw. eval() still doesn't take buffers, but that was so even before my patch.)
* patch #683515: "Add unicode support to compile(), eval() and exec"Just van Rossum2003-02-101-6/+40
| | | | Incorporated nnorwitz's comment re. Py__USING_UNICODE.
* Make sure filter() never returns tuple, str or unicodeWalter Dörwald2003-02-041-5/+22
| | | | subclasses. (Discussed in SF patch #665835)
* PyUnicode_Resize() doesn't free its argument in case of a failure,Walter Dörwald2003-02-041-1/+1
| | | | | so we can jump to the error handling code that does. (Spotted by Neal Norwitz)
* filterstring() and filterunicode() in Python/bltinmodule.cWalter Dörwald2003-02-041-8/+70
| | | | | | | | | | | | | blindly assumed that tp_as_sequence->sq_item always returns a str or unicode object. This might fail with str or unicode subclasses. This patch checks whether the object returned from __getitem__ is a str/unicode object and raises a TypeError if not (and the filter function returned true). Furthermore the result for __getitem__ can be more than one character long, so checks for enough memory have to be done.
* SF #661437, apply() should get PendingDeprecationNeal Norwitz2003-02-031-0/+3
|
* Patch #636005: Filter unicode into unicode.Martin v. Löwis2003-01-251-0/+62
|
* SF bug #655271: Slightly modify locals() docRaymond Hettinger2003-01-041-1/+1
| | | | Clarify the operation of locals().
* Make error message more specific for min() and max().Raymond Hettinger2002-12-291-1/+1
| | | | Suggested by MvL.
* SF patch #659536: Use PyArg_UnpackTuple where possible.Raymond Hettinger2002-12-291-18/+18
| | | | | | | Obtain cleaner coding and a system wide performance boost by using the fast, pre-parsed PyArg_Unpack function instead of PyArg_ParseTuple function which is driven by a format string.
* Enhance issubclass() and PyObject_IsSubclass() so that a tuple isWalter Dörwald2002-12-121-1/+3
| | | | | | | | | | | supported as the second argument. This has the same meaning as for isinstance(), i.e. issubclass(X, (A, B)) is equivalent to issubclass(X, A) or issubclass(X, B). Compared to isinstance(), this patch does not search the tuple recursively for classes, i.e. any entry in the tuple that is not a class, will result in a TypeError. This closes SF patch #649608.
* Patch #512981: Update readline input stream on sys.stdin/out change.Martin v. Löwis2002-10-261-3/+5
|
* execfile should call PyErr_SetFromErrnoWithFilename instead ofPeter Schneider-Kamp2002-08-271-1/+1
| | | | | | simply PyErr_SetFromErrno This closes bug 599163.
* A nice little speed-up for filter():Guido van Rossum2002-08-161-13/+17
| | | | | | | | | | - Use PyObject_Call() instead of PyEval_CallObject(), saves several layers of calls and checks. - Pre-allocate the argument tuple rather than calling Py_BuildValue() each time round the loop. - For filter(None, seq), avoid an INCREF and a DECREF.
* Patch #550192: Set softspace to 0 in raw_input().Martin v. Löwis2002-08-141-18/+22
|
* Add C API PyUnicode_FromOrdinal() which exposes unichr() at C level.Marc-André Lemburg2002-08-111-34/+1
| | | | | | | u'%c' will now raise a ValueError in case the argument is an integer outside the valid range of Unicode code point ordinals. Closes SF bug #593581.
* Patch #569753: Remove support for WIN16.Martin v. Löwis2002-06-301-1/+1
| | | | Rename all occurrences of MS_WIN32 to MS_WINDOWS.
* SF patch 568629 by Oren Tirosh: types made callable.Guido van Rossum2002-06-141-48/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | These built-in functions are replaced by their (now callable) type: slice() buffer() and these types can also be called (but have no built-in named function named after them) classobj (type name used to be "class") code function instance instancemethod (type name used to be "instance method") The module "new" has been replaced with a small backward compatibility placeholder in Python. A large portion of the patch simply removes the new module from various platform-specific build recipes. The following binary Mac project files still have references to it: Mac/Build/PythonCore.mcp Mac/Build/PythonStandSmall.mcp Mac/Build/PythonStandalone.mcp [I've tweaked the code layout and the doc strings here and there, and added a comment to types.py about StringTypes vs. basestring. --Guido]
* Patch #568124: Add doc string macros.Martin v. Löwis2002-06-131-92/+92
|
* Skip Montanaro's patch, SF 559833, exposing xrange type in builtins.Raymond Hettinger2002-06-051-43/+1
| | | | | Also, added more regression tests to cover the new type and test its conformity with range().
* Change name from string to basestringNeal Norwitz2002-05-311-1/+1
|
* - A new type object, 'string', is added. This is a common base typeGuido van Rossum2002-05-241-0/+1
| | | | | | | for 'str' and 'unicode', and can be used instead of types.StringTypes, e.g. to test whether something is "a string": isinstance(x, string) is True for Unicode and 8-bit strings. This is an abstract base class and cannot be instantiated directly.
* SF bug 555042: zip() may trigger MemoryError.Tim Peters2002-05-121-2/+7
| | | | | NOT a bugfix candidate: this is a fix to an optimization introduced in 2.3.
* builtin_zip(): Take a good guess at how big the result list will be,Tim Peters2002-04-291-15/+42
| | | | | | | and allocate it in one gulp. This isn't a bugfix, it's just a minor optimization that may or may not pay off.
* Repair widespread misuse of _PyString_Resize. Since it's clear peopleTim Peters2002-04-271-2/+2
| | | | | | | | | | | | | | | | | | | | | | don't understand how this function works, also beefed up the docs. The most common usage error is of this form (often spread out across gotos): if (_PyString_Resize(&s, n) < 0) { Py_DECREF(s); s = NULL; goto outtahere; } The error is that if _PyString_Resize runs out of memory, it automatically decrefs the input string object s (which also deallocates it, since its refcount must be 1 upon entry), and sets s to NULL. So if the "if" branch ever triggers, it's an error to call Py_DECREF(s): s is already NULL! A correct way to write the above is the simpler (and intended) if (_PyString_Resize(&s, n) < 0) goto outtahere; Bugfix candidate.
* - New builtin function enumerate(x), from PEP 279. Example:Guido van Rossum2002-04-261-0/+1
| | | | | enumerate("abc") is an iterator returning (0,"a"), (1,"b"), (2,"c"). The argument can be an arbitrary iterable object.
* Mass checkin of universal newline support.Jack Jansen2002-04-141-1/+1
| | | | | | | | 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.
* Add the 'bool' type and its values 'False' and 'True', as described inGuido van Rossum2002-04-031-8/+11
| | | | | | | | | | | | | 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.
* Patch #494045: patches errno and stat to cope on plan9.Martin v. Löwis2002-03-091-15/+27
|
* Docstring for filter(): Someone on the Tutor list reasonably complainedTim Peters2002-03-091-5/+5
| | | | | that it didn't tell enough of the truth. Bugfix candidate (I guess -- it helps and it's harmless).