summaryrefslogtreecommitdiffstats
path: root/Python/bltinmodule.c
Commit message (Collapse)AuthorAgeFilesLines
* Cruft cleanup: Removed the unused last_is_sticky argument from the internalTim Peters2001-05-281-1/+1
| | | | _PyTuple_Resize().
* SF bug #425836: Reference leak in filter().Tim Peters2001-05-211-0/+1
| | | | | Mark Hammond claimed that the iterized filter() forgot to decref the iterator upon return. He was right!
* Fix the Py_FileSystemDefaultEncoding checkin - declare the variable in a ↵Mark Hammond2001-05-141-1/+8
| | | | fileobject.h, and initialize it in bltinmodule.
* Add support for Windows using "mbcs" as the default Unicode encoding when ↵Mark Hammond2001-05-131-2/+6
| | | | dealing with the file system. As discussed on python-dev and in patch 410465.
* Generalize zip() to work with iterators.Tim Peters2001-05-061-18/+44
| | | | | | | | NEEDS DOC CHANGES. More AttributeErrors transmuted into TypeErrors, in test_b2.py, and, again, this strikes me as a good thing. This checkin completes the iterator generalization work that obviously needed to be done. Can anyone think of others that should be changed?
* Make PyIter_Next() a little smarter (wrt its knowledge of iteratorTim Peters2001-05-051-47/+14
| | | | internals) so clients can be a lot dumber (wrt their knowledge).
* Generalize reduce() to work with iterators.Tim Peters2001-05-041-12/+19
| | | | NEEDS DOC CHANGES.
* Generalize map() to work with iterators.Tim Peters2001-05-031-66/+68
| | | | | | | | | | | NEEDS DOC CHANGES. Possibly contentious: The first time s.next() yields StopIteration (for a given map argument s) is the last time map() *tries* s.next(). That is, if other sequence args are longer, s will never again contribute anything but None values to the result, even if trying s.next() again could yield another result. This is the same behavior map() used to have wrt IndexError, so it's the only way to be wholly backward-compatible. I'm not a fan of letting StopIteration mean "try again later" anyway.
* Generalize max(seq) and min(seq) to work with iterators.Tim Peters2001-05-031-15/+24
| | | | NEEDS DOC CHANGES.
* Generalize filter(f, seq) to work with iterators. This also generalizesTim Peters2001-05-021-40/+54
| | | | | filter() to no longer insist that len(seq) be defined. NEEDS DOC CHANGES.
* Fix buglet reported on c.l.py: map(fnc, file.xreadlines()) blows up.Tim Peters2001-04-281-9/+19
| | | | | | | | | Also a 2.1 bugfix candidate (am I supposed to do something with those?). Took away map()'s insistence that sequences support __len__, and cleaned up the convoluted code that made it *look* like it really cared about __len__ (in fact the old ->len field was only *used* as a flag bit, as the main loop only looked at its sign bit, setting the field to -1 when IndexError got raised; renamed the field to ->saw_IndexError instead).
* Iterators phase 1. This comprises:Guido van Rossum2001-04-201-0/+27
| | | | | | | | | | | | | | | | | | | | | | new slot tp_iter in type object, plus new flag Py_TPFLAGS_HAVE_ITER new C API PyObject_GetIter(), calls tp_iter new builtin iter(), with two forms: iter(obj), and iter(function, sentinel) new internal object types iterobject and calliterobject new exception StopIteration new opcodes for "for" loops, GET_ITER and FOR_ITER (also supported by dis.py) new magic number for .pyc files new special method for instances: __iter__() returns an iterator iteration over dictionaries: "for x in dict" iterates over the keys iteration over files: "for x in file" iterates over lines TODO: documentation test suite decide whether to use a different way to spell iter(function, sentinal) decide whether "for key in dict" is a good idea use iterators in map/filter/reduce, min/max, and elsewhere (in/not in?) speed tuning (make next() a slot tp_next???)
* SF patch #413552 - Premature decref on objectTim Peters2001-04-071-3/+7
| | | | | | | | | Jeffery Collins pointed out that filterstring decrefs a character object before it's done using it. This works by accident today because another module always happens to have an active reference too at the time. The accident doesn't work after his Pippy modifications, and since it *is* an accident even in the mainline Python, it should work by design there too. The patch accomplishes that.
* Extend support for from __future__ import nested_scopesJeremy Hylton2001-03-221-2/+14
| | | | | | | | | | | | | | | | | | | If a module has a future statement enabling nested scopes, they are also enable for the exec statement and the functions compile() and execfile() if they occur in the module. If Python is run with the -i option, which enters interactive mode after executing a script, and the script it runs enables nested scopes, they are also enabled in interactive mode. XXX The use of -i with -c "from __future__ import nested_scopes" is not supported. What's the point? To support these changes, many function variants have been added to pythonrun.c. All the variants names end with Flags and they take an extra PyCompilerFlags * argument. It is possible that this complexity will be eliminated in a future version of the interpreter in which nested scopes are not optional.
* Move the code implementing isinstance() and issubclass() to new CGuido van Rossum2001-03-211-96/+6
| | | | | APIs, PyObject_IsInstance() and PyObject_IsSubclass() -- both returning an int, or -1 for errors.
* Backed out the unistr() builtin.Marc-André Lemburg2001-01-191-18/+0
|
* clearer error messages for apply() and "no locals"Jeremy Hylton2001-01-191-4/+6
|
* Fix for the bug in complex() just reported by Ping.Guido van Rossum2001-01-191-1/+7
|
* This patch adds a new builtin unistr() which behaves like str()Marc-André Lemburg2001-01-171-0/+18
| | | | | | | | | | except that it always returns Unicode objects. A new C API PyObject_Unicode() is also provided. This closes patch #101664. Written by Marc-Andre Lemburg. Copyright assigned to Guido van Rossum.
* Use rich comparisons in min and max.Guido van Rossum2001-01-171-9/+9
|
* Update the docstring for apply() so that "args" is marked as optionalFred Drake2001-01-121-1/+1
| | | | (since it is).
* (Modified) patch by Ping - SF Patch #102681.Guido van Rossum2001-01-121-27/+33
| | | | | | | | | - Make error messages from issubclass() and isinstance() a bit more descriptive (Ping, modified by Guido) - Couple of tiny fixes to other docstrings (Ping) - Get rid of trailing whitespace (Guido)
* Add NotImplemented to the builtin module.Neil Schemenauer2001-01-041-0/+3
|
* CHange error messages for ord(), using "string" instead of "string or Unicode"Andrew M. Kuchling2000-12-231-2/+3
|
* Whoops! Two stray characters crept in to my last check-inAndrew M. Kuchling2000-12-201-1/+1
|
* Patch #102955, fixing one of the warnings in bug #121479:Andrew M. Kuchling2000-12-201-5/+7
| | | | | Simplifies ord()'s logic at the cost of some code duplication, removing a " `ord' might be used uninitialized in this function" warning
* Make isinstance() more permissive in what types of arguments itNeil Schemenauer2000-12-041-17/+9
| | | | | accepts. Clarify exception messages for isinstance() and issubclass(). Closes bug #124106.
* Ka-Ping Yee <ping@lfw.org>:Fred Drake2000-10-241-26/+26
| | | | | | Changes to error messages to increase consistency & clarity. This (mostly) closes SourceForge patch #101839.
* Rationalize use of limits.h, moving the inclusion to Python.h.Fred Drake2000-09-261-3/+0
| | | | | | | | Add definitions of INT_MAX and LONG_MAX to pyport.h. Remove includes of limits.h and conditional definitions of INT_MAX and LONG_MAX elsewhere. This closes SourceForge patch #101659 and bug #115323.
* This patch adds a new Python C API called PyString_AsStringAndSize()Marc-André Lemburg2000-09-191-6/+3
| | | | | | | | | | | | | which implements the automatic conversion from Unicode to a string object using the default encoding. The new API is then put to use to have eval() and exec accept Unicode objects as code parameter. This closes bugs #110924 and #113890. As side-effect, the traditional C APIs PyString_Size() and PyString_AsString() will also accept Unicode objects as parameters.
* Deferred the attribute name object type checking to the underlyingMarc-André Lemburg2000-09-181-4/+4
| | | | | | PyObject_Set/GetAttr() calls. This patch fixes bug #113829.
* REMOVED all CWI, CNRI and BeOpen copyright markings.Guido van Rossum2000-09-011-9/+0
| | | | This should match the situation in the 1.6b1 tree.
* Add three new APIs: PyRun_AnyFileEx(), PyRun_SimpleFileEx(),Guido van Rossum2000-08-271-4/+1
| | | | | | | | | | | | | | PyRun_FileEx(). These are the same as their non-Ex counterparts but have an extra argument, a flag telling them to close the file when done. Then this is used by Py_Main() and execfile() to close the file after it is parsed but before it is executed. Adding APIs seems strange given the feature freeze but it's the only way I see to close the bug report without incompatible changes. [ Bug #110616 ] source file stays open after parsing is done (PR#209)
* comples_from_string(): Move s_buffer[] up to the top-level functionBarry Warsaw2000-08-181-2/+1
| | | | | | scope. Previously, s_buffer[] was defined inside the PyUnicode_Check() scope, but referred to in the outer scope via assignment to s. This quiets an Insure portability warning.
* Clean up a couple of warnings on Win64. The downcast of the strlen size_tTrent Mick2000-08-121-1/+1
| | | | | return value to int is safe here because in each case it previouls checked that there will be no overflow.
* Both PEP 201 Lockstep Iteration and SF patch #101030 have beenBarry Warsaw2000-08-031-0/+56
| | | | | | | | | | | accepted by the BDFL. builtin_zip(): New function to implement the zip() function described in the above proposal. zip_doc[]: Docstring for zip(). builtin_methods[]: added entry for zip()
* merge Include/my*.h into Include/pyport.hPeter Schneider-Kamp2000-07-311-2/+0
| | | | marked my*.h as obsolete
* Another missed ansification.Thomas Wouters2000-07-231-4/+1
|
* Mass ANSIfication of function definitions. Doesn't cover all 'extern'Thomas Wouters2000-07-221-179/+60
| | | | declarations yet, those come later.
* replace PyXXX_Length calls with PyXXX_Size callsJeremy Hylton2000-07-121-1/+1
|
* Nuke all remaining occurrences of Py_PROTO and Py_FPROTO.Tim Peters2000-07-091-4/+4
|
* Get rid of unused vars in builtin_unicode (they were causingTim Peters2000-07-091-2/+0
| | | | legit warnings).
* Fixed unicode() to use the new API PyUnicode_FromEncodedObject().Marc-André Lemburg2000-07-071-14/+1
| | | | | | | This adds support for instance to the constructor (instances have to define __str__ and can return Unicode objects via that hook; string return values are decoded into Unicode using the current default encoding).
* Include limits.h if we have it.Jack Jansen2000-07-031-0/+3
|
* Change copyright notice - 2nd try.Guido van Rossum2000-06-301-6/+0
|
* Change copyright notice.Guido van Rossum2000-06-301-22/+7
|
* Trent Mick:Guido van Rossum2000-06-281-3/+10
| | | | | | | | | | | | | | | | | | | | | | | | Various small fixes to the builtin module to ensure no buffer overflows. - chunk #1: Proper casting to ensure no truncation, and hence no surprises, in the comparison. - chunk #2: The id() function guarantees a unique return value for different objects. It does this by returning the pointer to the object. By returning a PyInt, on Win64 (sizeof(long) < sizeof(void*)) the pointer is truncated and the guarantee may be proven false. The appropriate return function is PyLong_FromVoidPtr, this returns a PyLong if that is necessary to return the pointer without truncation. [GvR: note that this means that id() can now return a long on Win32 platforms. This *might* break some code...] - chunk #3: Ensure no overflow in raw_input(). Granted the user would have to pass in >2GB of data but it *is* a possible buffer overflow condition.
* Christopher Fandrich <cfandrich@8cs.com>:Fred Drake2000-06-201-3/+6
| | | | Fix memory leak in initializing __debug__.
* All the exception building related stuff has been moved out of thisBarry Warsaw2000-05-251-190/+1
| | | | | | | | | | | | module and into _exceptions.c. This includes all the PyExc_* globals, the bltin_exc table, init_class_exc(), fini_instances(), finierrors(). Renamed _PyBuiltin_Init_1() to _PyBuiltin_Init() since the two phase initializations are necessary any more. Removed as obsolete _PyBuiltin_Init_2(), _PyBuiltin_Fini_1() and _PyBuiltin_Fini_2().
* bltin_exc: Removed the leaf_exc flag in the structure, which was onlyBarry Warsaw2000-05-251-35/+29
| | | | used to build the fallback string-based exception.