summaryrefslogtreecommitdiffstats
path: root/Include
Commit message (Collapse)AuthorAgeFilesLines
* Rip out the fancy behaviors of xrange that nobody uses: repeat, slice,Guido van Rossum2001-07-051-1/+1
| | | | | contains, tolist(), and the start/stop/step attributes. This includes removing the 4th ('repeat') argument to PyRange_New().
* This change adjusts the profiling/tracing support so that the commonFred Drake2001-07-031-0/+1
| | | | | | | | | | | | | | | | path (with no profile/trace function) through eval_code2() and eval_frame() avoids several checks. In the common cases of calls, returns, and exception propogation, eval_code2() and eval_frame() used to test two values in the thread-state: the profiling function and the tracing function. With this change, a flag is set in the thread-state if either of these is active, allowing a single check to suffice when both are NULL. This also simplifies the code needed when either function is in use but is already active (to avoid profiling/tracing the profiler/tracer); the flag is set to 0 when the profile/trace code is entered, allowing the same check to suffice for "already in the tracer" for call/return/ exception events.
* removed "register const" from scalar arguments to the unicodeFredrik Lundh2001-06-271-15/+15
| | | | predicates
* Revise the interface to the profiling and tracing support for theFred Drake2001-06-272-2/+16
| | | | | | | | | | | | | | | Python interpreter. This change adds two new C-level APIs: PyEval_SetProfile() and PyEval_SetTrace(). These can be used to install profile and trace functions implemented in C, which can operate at much higher speeds than Python-based functions. The overhead for calling a C-based profile function is a very small fraction of a percent of the overhead involved in calling a Python-based function. The machinery required to call a Python-based profile or trace function been moved to sysmodule.c, where sys.setprofile() and sys.setprofile() simply become users of the new interface.
* use Py_UNICODE_WIDE instead of USE_UCS4_STORAGE and Py_UNICODE_SIZEFredrik Lundh2001-06-271-6/+7
| | | | tests.
* Encode surrogates in UTF-8 even for a wide Py_UNICODE.Martin v. Löwis2001-06-271-0/+3
| | | | | | | Implement sys.maxunicode. Explicitly wrap around upper/lower computations for wide Py_UNICODE. When decoding large characters with UTF-8, represent expected test results using the \U notation.
* Make Unicode work a bit better on Windows...Fredrik Lundh2001-06-261-0/+8
|
* Support using UCS-4 as the Py_UNICODE type:Martin v. Löwis2001-06-261-30/+23
| | | | | | | | | | Add configure option --enable-unicode. Add config.h macros Py_USING_UNICODE, PY_UNICODE_TYPE, Py_UNICODE_SIZE, SIZEOF_WCHAR_T. Define Py_UCS2. Encode and decode large UTF-8 characters into single Py_UNICODE values for wide Unicode types; likewise for UTF-16. Remove test whether sizeof Py_UNICODE is two.
* experimental UCS-4 support: added USE_UCS4_STORAGE define toFredrik Lundh2001-06-261-12/+19
| | | | | | unicodeobject.h, which forces sizeof(Py_UNICODE) == sizeof(Py_UCS4). (this may be good enough for platforms that doesn't have a 16-bit type. the UTF-16 codecs don't work, though)
* PyFrameObject: rename f_stackbottom to f_stacktop, since it points toTim Peters2001-06-231-2/+4
| | | | | | | | the next free valuestack slot, not to the base (in America, stacks push and pop at the top -- they mutate at the bottom in Australia <winK>). eval_frame(): assert that f_stacktop isn't NULL upon entry. frame_delloc(): avoid ordered pointer comparisons involving f_stacktop when f_stacktop is NULL.
* Somehow, under certain circumstances, config.h and rename1.h would pop back up.Guido van Rossum2001-06-212-442/+0
| | | | Try to see if 'cvs delete' fixes this.
* Merging the gen-branch into the main line, at Guido's direction. Yay!Tim Peters2001-06-185-44/+50
| | | | | Bugfix candidate in inspect.py: it was referencing "self" outside of a method.
* SF bug 433228: repr(list) woes when len(list) big.Tim Peters2001-06-161-0/+4
| | | | | | | | | | | | Gave Python linear-time repr() implementations for dicts, lists, strings. This means, e.g., that repr(range(50000)) is no longer 50x slower than pprint.pprint() in 2.2 <wink>. I don't consider this a bugfix candidate, as it's a performance boost. Added _PyString_Join() to the internal string API. If we want that in the public API, fine, but then it requires runtime error checks instead of asserts.
* Two new private longobject API functions,Tim Peters2001-06-111-0/+40
| | | | | | | | | | _PyLong_FromByteArray _PyLong_AsByteArray Untested and probably buggy -- they compile OK, but nothing calls them yet. Will soon be called by the struct module, to implement x-platform 'q' and 'Q'. If other people have uses for them, we could move them into the public API. See longobject.h for usage details.
* Cast the result of xxxPyCObject_Import to PycStringIO_CAPI*.Martin v. Löwis2001-06-091-1/+1
| | | | This fixes bug #431557.
* Wrap with extern "C". Fixes bug #428419.Martin v. Löwis2001-06-051-0/+11
| | | | Also protect against multiple inclusion.
* Cruft cleanup: Removed the unused last_is_sticky argument from the internalTim Peters2001-05-281-1/+1
| | | | _PyTuple_Resize().
* Patch #424335: Implement string_richcompare, remove string_compare.Martin v. Löwis2001-05-241-0/+1
| | | | Use new _PyString_Eq in lookdict_string.
* This patch changes the behaviour of the UTF-16 codec family. Only theMarc-André Lemburg2001-05-211-4/+5
| | | | | | | | | UTF-16 codec will now interpret and remove a *leading* BOM mark. Sub- sequent BOM characters are no longer interpreted and removed. UTF-16-LE and -BE pass through all BOM mark characters. These changes should get the UTF-16 codec more in line with what the Unicode FAQ recommends w/r to BOM marks.
* This patch changes the way the string .encode() method works slightlyMarc-André Lemburg2001-05-151-3/+40
| | | | | | | | | | | | | | | | | | | | | | | | | and introduces a new method .decode(). The major change is that strg.encode() will no longer try to convert Unicode returns from the codec into a string, but instead pass along the Unicode object as-is. The same is now true for all other codec return types. The underlying C APIs were changed accordingly. Note that even though this does have the potential of breaking existing code, the chances are low since conversion from Unicode previously took place using the default encoding which is normally set to ASCII rendering this auto-conversion mechanism useless for most Unicode encodings. The good news is that you can now use .encode() and .decode() with much greater ease and that the door was opened for better accessibility of the builtin codecs. As demonstration of the new feature, the patch includes a few new codecs which allow string to string encoding and decoding (rot13, hex, zip, uu, base64). Written by Marc-Andre Lemburg. Copyright assigned to the PSF.
* SF patch #418147 Fixes to allow compiling w/ Borland, from Stephen Hansen.Tim Peters2001-05-141-0/+9
|
* Fix the Py_FileSystemDefaultEncoding checkin - declare the variable in a ↵Mark Hammond2001-05-141-0/+5
| | | | fileobject.h, and initialize it in bltinmodule.
* SF bug #422177: Results from .pyc differs from .pyTim Peters2001-05-081-3/+22
| | | | | | | | Store floats and doubles to full precision in marshal. Test that floats read from .pyc/.pyo closely match those read from .py. Declare PyFloat_AsString() in floatobject header file. Add new PyFloat_AsReprString() API function. Document the functions declared in floatobject.h.
* Reimplement PySequence_Contains() and instance_contains(), so they workTim Peters2001-05-051-1/+11
| | | | | | | | | safely together and don't duplicate logic (the common logic was factored out into new private API function _PySequence_IterContains()). Visible change: some_complex_number in some_instance no longer blows up if some_instance has __getitem__ but neither __contains__ nor __iter__. test_iter changed to ensure that remains true.
* Generalize tuple() to work nicely with iterators.Tim Peters2001-05-051-1/+1
| | | | | | | | | | | | | | | | | | | | | NEEDS DOC CHANGES. This one surprised me! While I expected tuple() to be a no-brainer, turns out it's actually dripping with consequences: 1. It will *allow* the popular PySequence_Fast() to work with any iterable object (code for that not yet checked in, but should be trivial). 2. It caused two std tests to fail. This because some places used PyTuple_Sequence() (the C spelling of tuple()) as an indirect way to test whether something *is* a sequence. But tuple() code only looked for the existence of sq->item to determine that, and e.g. an instance passed that test whether or not it supported the other operations tuple() needed (e.g., __len__). So some things the tests *expected* to fail with an AttributeError now fail with a TypeError instead. This looks like an improvement to me; e.g., test_coercion used to produce 559 TypeErrors and 2 AttributeErrors, and now they're all TypeErrors. The error details are more informative too, because the places calling this were *looking* for TypeErrors in order to replace the generic tuple() "not a sequence" msg with their own more specific text, and AttributeErrors snuck by that.
* Make PyIter_Next() a little smarter (wrt its knowledge of iteratorTim Peters2001-05-051-3/+2
| | | | internals) so clients can be a lot dumber (wrt their knowledge).
* This patch originated from an idea by Martin v. Loewis who submitted aMarc-André Lemburg2001-04-231-2/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | patch for sharing single character Unicode objects. Martin's patch had to be reworked in a number of ways to take Unicode resizing into consideration as well. Here's what the updated patch implements: * Single character Unicode strings in the Latin-1 range are shared (not only ASCII chars as in Martin's original patch). * The ASCII and Latin-1 codecs make use of this optimization, providing a noticable speedup for single character strings. Most Unicode methods can use the optimization as well (by virtue of using PyUnicode_FromUnicode()). * Some code cleanup was done (replacing memcpy with Py_UNICODE_COPY) * The PyUnicode_Resize() can now also handle the case of resizing unicode_empty which previously resulted in an error. * Modified the internal API _PyUnicode_Resize() and the public PyUnicode_Resize() API to handle references to shared objects correctly. The _PyUnicode_Resize() signature changed due to this. * Callers of PyUnicode_FromUnicode() may now only modify the Unicode object contents of the returned object in case they called the API with NULL as content template. Note that even though this patch passes the regression tests, there may still be subtle bugs in the sharing code.
* Mondo changes to the iterator stuff, without changing how Python codeGuido van Rossum2001-04-233-3/+18
| | | | | | | | | | | | | | | | | | | | | | | | sees it (test_iter.py is unchanged). - Added a tp_iternext slot, which calls the iterator's next() method; this is much faster for built-in iterators over built-in types such as lists and dicts, speeding up pybench's ForLoop with about 25% compared to Python 2.1. (Now there's a good argument for iterators. ;-) - Renamed the built-in sequence iterator SeqIter, affecting the C API functions for it. (This frees up the PyIter prefix for generic iterator operations.) - Added PyIter_Check(obj), which checks that obj's type has a tp_iternext slot and that the proper feature flag is set. - Added PyIter_Next(obj) which calls the tp_iternext slot. It has a somewhat complex return condition due to the need for speed: when it returns NULL, it may not have set an exception condition, meaning the iterator is exhausted; when the exception StopIteration is set (or a derived exception class), it means the same thing; any other exception means some other error occurred.
* Adding iterobject.[ch], which were accidentally not added. Sorry\!Guido van Rossum2001-04-201-0/+13
|
* Iterators phase 1. This comprises:Guido van Rossum2001-04-205-4/+19
| | | | | | | | | | | | | | | | | | | | | | 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???)
* Change the version to 2.2a0. This may look strange, but indicatesGuido van Rossum2001-04-181-4/+4
| | | | it's 2.2 before the first alpha release.
* Update the version to 2.1final (again :-).Guido van Rossum2001-04-161-4/+4
|
* We need another release candidate after so many "small" changes.Guido van Rossum2001-04-161-2/+2
| | | | DO NOT CHECK ANYTHHING IN FROM NOW ON WITHOUT ASKING ME.
* Prepare for release candidate 1... aka 2.1c1.Guido van Rossum2001-04-121-3/+3
|
* Add the necessary field for weak reference support to the function andFred Drake2001-03-232-0/+2
| | | | method types.
* Add sys.excepthook.Ka-Ping Yee2001-03-231-0/+1
| | | | | | | | Update docstring and library reference section on 'sys' module. New API PyErr_Display, just for displaying errors, called by excepthook. Uncaught exceptions now call sys.excepthook; if that fails, we fall back to calling PyErr_Display directly. Also comes with sys.__excepthook__ and sys.__displayhook__.
* A small change to the C API for weakly-referencable types: Such typesFred Drake2001-03-221-5/+1
| | | | | | | | must now initialize the extra field used by the weak-ref machinery to NULL themselves, to avoid having to require PyObject_INIT() to check if the type supports weak references and do it there. This causes less work to be done for all objects (the type object does not need to be consulted to check for the Py_TPFLAGS_HAVE_WEAKREFS bit).
* Set the line number correctly for a nested function with an exec orJeremy Hylton2001-03-221-0/+1
| | | | import *. Mark the offending stmt rather than the function def line.
* Extend support for from __future__ import nested_scopesJeremy Hylton2001-03-221-0/+13
| | | | | | | | | | | | | | | | | | | 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.
* If a code object is compiled with nested scopes, define the CO_NESTED flag.Jeremy Hylton2001-03-222-0/+2
| | | | | Add PyEval_GetNestedScopes() which returns a non-zero value if the code for the current interpreter frame has CO_NESTED defined.
* Move the code implementing isinstance() and issubclass() to new CGuido van Rossum2001-03-211-0/+7
| | | | | APIs, PyObject_IsInstance() and PyObject_IsSubclass() -- both returning an int, or -1 for errors.
* Bump version to 2.1b2.Guido van Rossum2001-03-201-3/+3
|
* Variety of small INC/DECREF patches that fix reported memory leaksJeremy Hylton2001-03-131-2/+1
| | | | | | | | | | | | | | | | | | | | | with free variables. Thanks to Martin v. Loewis for finding two of the problems. This fixes SF buf 405583. There is also a C API change: PyFrame_New() is reverting to its pre-2.1 signature. The change introduced by nested scopes was a mistake. XXX Is this okay between beta releases? cell_clear(), the GC helper, must decref its reference to break cycles. frame_dealloc() must dealloc all cell vars and free vars in addition to locals. eval_code2() setup code must INCREF cells it copies out of the closure. The STORE_DEREF opcode implementation must DECREF the object it passes to PyCell_Set().
* RISCOS patch by dschwertbergerGuido van Rossum2001-03-021-0/+7
|
* Useful future statement support for the interactive interpreterJeremy Hylton2001-03-012-0/+7
| | | | | | | | | | | | | | | | | | | | | | | | (Also remove warning about module-level global decl, because we can't distinguish from code passed to exec.) Define PyCompilerFlags type contains a single element, cf_nested_scopes, that is true if a nested scopes future statement has been entered at the interactive prompt. New API functions: PyNode_CompileFlags() PyRun_InteractiveOneFlags() -- same as their non Flags counterparts except that the take an optional PyCompilerFlags pointer compile.c: In jcompile() use PyCompilerFlags argument. If cf_nested_scopes is true, compile code with nested scopes. If it is false, but the code has a valid future nested scopes statement, set it to true. pythonrun.c: Create a new PyCompilerFlags object in PyRun_InteractiveLoop() and thread it through to PyRun_InteractiveOneFlags().
* Here we go again, another round of version bumping...Guido van Rossum2001-03-011-4/+4
|
* add DEF_BOUNDJeremy Hylton2001-02-281-1/+3
|
* Add declaration for PyErr_WarnExplicit().Guido van Rossum2001-02-281-0/+2
|
* Improve SyntaxErrors for bad future statements. Set file and locationJeremy Hylton2001-02-281-0/+4
| | | | | | | for errors raised in future.c. Move some helper functions from compile.c to errors.c and make them API functions: PyErr_SyntaxLocation() and PyErr_ProgramText().
* Presumed correct compiler pass for future statementsJeremy Hylton2001-02-281-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | XXX still need to integrate into symtable API compile.h: Remove ff_n_simple_stmt; obsolete. Add ff_found_docstring used internally to skip one and only one string at the beginning of a module. compile.c: Add check for from __future__ imports to far into the file. In symtable_global() check for -1 returned from symtable_lookup(), which signifies name not defined. Add missing DECERF in symtable_add_def. Free c->c_future. future.c: Add special handling for multiple statements joined on a single line using one or more semicolons; this form can include an illegal future statement that would otherwise be hard to detect. Add support for detecting and skipping doc strings.