summaryrefslogtreecommitdiffstats
path: root/Include
Commit message (Collapse)AuthorAgeFilesLines
* Add a low-level API to access interpreters, for David Beazley.Guido van Rossum2001-07-191-0/+7
| | | | SF patch #436376.
* Patch #412229: Add functions sys.getdlopenflags and sys.setdlopenflags.Martin v. Löwis2001-07-181-0/+3
| | | | Add dlopenflags to PyInterpreterState, and use it in dlopen calls.
* Ugly. A pile of new xxxFlags() functions, to communicate to the parserTim Peters2001-07-162-0/+11
| | | | | | | | | | | | | | | | | | | | | | | that 'yield' is a keyword. This doesn't help test_generators at all! I don't know why not. These things do work now (and didn't before this patch): 1. "from __future__ import generators" now works in a native shell. 2. Similarly "python -i xxx.py" now has generators enabled in the shell if xxx.py had them enabled. 3. This program (which was my doctest proxy) works fine: from __future__ import generators source = """\ def f(): yield 1 """ exec compile(source, "", "single") in globals() print type(f())
* Part way to allowing "from __future__ import generators" to communicateTim Peters2001-07-164-3/+20
| | | | | | | | | | that info to code dynamically compiled *by* code compiled with generators enabled. Doesn't yet work because there's still no way to tell the parser that "yield" is OK (unlike nested_scopes, the parser has its fingers in this too). Replaced PyEval_GetNestedScopes by a more-general PyEval_MergeCompilerFlags. Perhaps I should not have? I doubted it was *intended* to be part of the public API, so just did.
* Preliminary support for "from __future__ import generators" to enableGuido van Rossum2001-07-151-0/+3
| | | | | | | | the yield statement. I figure we have to have this in before I can release 2.2a1 on Wednesday. Note: test_generators is currently broken, I'm counting on Tim to fix this.
* Python.h: Don't attempt to redefine NDEBUG if it's already defined.Tim Peters2001-07-151-0/+2
| | | | Others: Remove redundant includes of assert.h.
* Define NDEBUG when Py_DEBUG undefined, to disable the assert macro.Guido van Rossum2001-07-151-0/+4
|
* Enable nested scopes by default.Guido van Rossum2001-07-121-1/+1
| | | | | | | | | | | Although this is a one-character change, more work needs to be done: the compiler can get rid of a lot of non-nested-scopes code, the documentation needs to be updated, the future statement can be simplified, etc. But this change enables the nested scope semantics everywhere, and that's the important part -- we can now test code for compatibility with nested scopes by default.
* Re-add 'advanced' xrange features, adding DeprecationWarnings as discussedThomas Wouters2001-07-091-1/+1
| | | | | on python-dev. The features will still vanish, however, just one release later.
* 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.