summaryrefslogtreecommitdiffstats
path: root/Python/bltinmodule.c
Commit message (Collapse)AuthorAgeFilesLines
* 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).
* Include <unistd.h> in Python.h. Fixes #500924.Martin v. Löwis2002-01-121-4/+0
|
* Fix for SF bug [ #492403 ] exec() segfaults on closure's func_codeJeremy Hylton2001-12-131-1/+1
| | | | | | | | Based on the patch from Danny Yoo. The fix is in exec_statement() in ceval.c. There are also changes to introduce use of PyCode_GetNumFree() in several places.
* Use PyOS_snprintf instead of sprintf.Jeremy Hylton2001-11-281-1/+1
|
* SF patch 473749 compile under OS/2 VA C++, from Michael Muller.Tim Peters2001-11-051-0/+4
| | | | Changes enabling Python to compile under OS/2 Visual Age C++.
* Rename "dictionary" (type and constructor) to "dict".Tim Peters2001-10-291-1/+1
|
* SF patch #474590 -- RISC OS supportGuido van Rossum2001-10-241-0/+15
|
* SF patch #471852 (anonymous) notes that getattr(obj, name, default)Guido van Rossum2001-10-161-1/+3
| | | | masks any exception, not just AttributeError. Fix this.
* Implement isinstance(x, (A, B, ...)). Note that we only allow tuples,Guido van Rossum2001-10-071-2/+4
| | | | | not other sequences (then we'd have to except strings, and we'd still be susceptible to recursive attacks).
* Get rid of builtin_open() entirely (the C code and docstring, not theTim Peters2001-09-131-20/+3
| | | | | builtin function); Guido pointed out that it could be just another name in the __builtin__ dict for the file constructor now.
* _PyBuiltin_Init(): For clarity, macroize this purely repetitive code.Tim Peters2001-09-131-49/+25
|
* SF bug [#460467] file objects should be subclassable.Tim Peters2001-09-131-22/+13
| | | | Preliminary support. What's here works, but needs fine-tuning.
* Rename 'getset' to 'property'.Guido van Rossum2001-09-061-2/+2
|
* builtin_execfile(): initialize another local that the GCC on leroyGuido van Rossum2001-09-051-1/+1
| | | | found it necessary to warn about.
* At Guido's suggestion, here's a new C API function, PyObject_Dir(), likeTim Peters2001-09-041-137/+1
| | | | __builtin__.dir(). Moved the guts from bltinmodule.c to object.c.
* builtin_dir(): Treat classic classes like types. Use PyDict_Keys insteadTim Peters2001-09-041-17/+20
| | | | | | | | | | | | | | of PyMapping_Keys because we know we have a real dict. Tolerate that objects may have an attr named "__dict__" that's not a dict (Py_None popped up during testing). test_descr.py, test_dir(): Test the new classic-class behavior; beef up the new-style class test similarly. test_pyclbr.py, checkModule(): dir(C) is no longer a synonym for C.__dict__.keys() when C is a classic class (looks like the same thing that burned distutils! -- should it be *made* a synoym again? Then it would be inconsistent with new-style class behavior.).