summaryrefslogtreecommitdiffstats
path: root/Python
Commit message (Collapse)AuthorAgeFilesLines
* Temporarily disable the message to stderr. Jeremy will know what to doMarc-André Lemburg2001-06-131-1/+3
| | | | about this...
* SF bug 430991: wrong co_lnotabTim Peters2001-06-091-10/+54
| | | | | | | | | Armin Rigo pointed out that the way the line-# table got built didn't work for lines generating more than 255 bytes of bytecode. Fixed as he suggested, plus corresponding changes to pyassem.py, plus added some long overdue docs about this subtle table to compile.c. Bugfix candidate (line numbers may be off in tracebacks under -O).
* call_trace(): Add an additional parameter -- pointer to a PyObject*Fred Drake2001-06-081-13/+36
| | | | | | | | | | | | | | | that should be used to cache an interned version of the event string passed to the profile/trace function. call_trace() will create interned strings and cache them in using the storage specified by this additional parameter, avoiding a lot of string object creation at runtime when using the profiling or tracing functions. All call sites are modified to pass the additional parameter, and four static PyObject* variables are allocated to cache the interned string objects. This closes SF patch #431257.
* PyErr_Occurred(): Use PyThreadState_GET(), which saves a tiny function callTim Peters2001-05-301-1/+1
| | | | | | | | in release builds. Suggested by Martin v. Loewis. I'm half tempted to macroize PyErr_Occurred too, as the whole thing could collapse to just _PyThreadState_Current->curexc_type
* Change cascaded if stmts to switch stmt in vgetargs1().Jeremy Hylton2001-05-291-19/+25
| | | | | | | | In the default branch, keep three ifs that are used if level == 0, the most common case. Note that first if here is a slight optimization for the 'O' format. Second part of SF patch 426072.
* Internal refactoring of convertsimple() and friends.Jeremy Hylton2001-05-291-515/+514
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Note that lots of code was re-indented. Replace two-step of convertsimple() and convertsimple1() with convertsimple() and helper converterr(), which is called to format error messages when convertsimple() fails. The old code did all the real work in convertsimple1(), but deferred error message formatting to conversimple(). The result was paying the price of a second function call on every call just to format error messages in the failure cases. Factor out of the buffer-handling code in convertsimple() and package it as convertbuffer(). Add two macros to ease readability of Unicode coversions, UNICODE_DEFAULT_ENCODING() and CONV_UNICODE, an error string. The convertsimple() routine had awful indentation problems, primarily because there were two tabs between the case line and the body of the case statements. This patch reformats the entire function to have a single tab between case line and case body, which makes the code easier to read (and consistent with ceval). The introduction of converterr() exacerbated the problem and prompted this fix. Also, eliminate non-standard whitespace after opening paren and before closing paren in a few if statements. (This checkin is part of SF patch 426072.)
* Fix bug reported by Tim Peters on python-dev:Jeremy Hylton2001-05-291-6/+5
| | | | | | | | | | | | | | | Keyword arguments passed to builtin functions that don't take them are ignored. >>> {}.clear(x=2) >>> instead of >>> {}.clear(x=2) Traceback (most recent call last): File "<stdin>", line 1, in ? TypeError: clear() takes no keyword arguments
* 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 whitespace botch.Fred Drake2001-05-181-1/+1
|
* vgetargs1() and vgetargskeywords(): Replace uses of PyTuple_Size() andJeremy Hylton2001-05-181-10/+8
| | | | | PyTuple_GetItem() with PyTuple_GET_SIZE() and PyTuple_GET_ITEM(). The code has already done a PyTuple_Check().
* Add a second special case to the inline function call code in eval_code2().Jeremy Hylton2001-05-181-1/+7
| | | | | | If we have a PyCFunction (builtin) and it is METH_VARARGS only, load the args and dispatch to call_cfunction() directly. This provides a small speedup for perhaps the most common function calls -- builtins.
* 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-132-3/+7
| | | | dealing with the file system. As discussed on python-dev and in patch 410465.
* SF patch #416249, from Mark Favas: 2.1c1 compile: unused vrbl cleanupTim Peters2001-05-091-2/+0
|
* Always pass a full path name to LoadLibraryEx(). Fixes some Windows 9x ↵Mark Hammond2001-05-091-17/+14
| | | | problems. As discussed on python-dev
* SF bug #422177: Results from .pyc differs from .pyTim Peters2001-05-081-5/+3
| | | | | | | | 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.
* Several small changes. Mostly reformatting, adding parens.Jeremy Hylton2001-05-081-10/+11
| | | | | | | | | Check for free in class and method only if nested scopes are enabled. Add assertion to verify that no free variables occur when nested scopes are disabled. XXX When should nested scopes by made non-optional on the trunk?
* 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-052-52/+17
| | | | 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.
* Added new parser markers 'et' and 'et#' which do not recode stringMarc-André Lemburg2001-05-021-4/+20
| | | | | | | objects but instead assume that they use the requested encoding. This is needed on Windows to enable opening files by passing in Unicode file names.
* 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.
* SF bug #417093: Case sensitive import: dir and .py file w/ same nameTim Peters2001-04-291-8/+5
| | | | | | | | | | | | | | | | Directory containing Spam.py spam/__init__.py Then "import Spam" caused a SystemError, because code checking for the existence of "Spam/__init__.py" finds it on a case-insensitive filesystem, but then bails because the directory it finds it in doesn't match case, and then old code assumed that was still an error even though it isn't anymore. Changed the code to just continue looking in this case (instead of calling it an error). So import Spam and import spam both work now.
* 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).
* Fix 2.1 nested scopes crash reported by Evan SimpsonJeremy Hylton2001-04-271-6/+20
| | | | | | | | The new test case demonstrates the bug. Be more careful in symtable_resolve_free() to add a var to cells or frees only if it won't be added under some other rule. XXX Add new assertion that will catch this bug.
* improved error message-- names the type of the unexpected objectJeremy Hylton2001-04-271-2/+3
|
* Mondo changes to the iterator stuff, without changing how Python codeGuido van Rossum2001-04-231-27/+16
| | | | | | | | | | | | | | | | | | | | | | | | 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.
* SF but #417587: compiler warnings compiling 2.1.Tim Peters2001-04-211-1/+0
| | | | Repaired *some* of the SGI compiler warnings Sjoerd Mullender reported.
* Iterators phase 1. This comprises:Guido van Rossum2001-04-205-19/+82
| | | | | | | | | | | | | | | | | | | | | | 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???)
* Make some private symbols static.Guido van Rossum2001-04-142-3/+4
|
* split long lineJeremy Hylton2001-04-131-1/+2
|
* Change error message raised when free variable is not yet bound. ItJeremy Hylton2001-04-131-10/+16
| | | | | | | | | now raises NameError instead of UnboundLocalError, because the var in question is definitely not local. (This affects test_scope.py) Also update the recent fix by Ping using get_func_name(). Replace tests of get_func_name() return value with call to get_func_desc() to match all the other uses.
* Patch by Ping (SF bug 415879, Exception.__init__() causes segfault):Guido van Rossum2001-04-131-3/+2
| | | | | | | | | | | | Calling an unbound method on a C extension class without providing an instance can yield a segfault. Try "Exception.__init__()" or "ValueError.__init__()". This is a simple fix. The error-reporting bits in call_method mistakenly treat the misleadingly-named variable "func" as a function, when in fact it is a method. If we let get_func_name take care of the work, all is fine.
* Because this code was derived from Python 1.6.1 (amongst others), theGuido van Rossum2001-04-121-1/+1
| | | | CNRI copyright should be updated to include 2001.
* Update copyright to PSF.Guido van Rossum2001-04-121-1/+1
|
* Fix exception handling for non-PyFunction objects, SF bug 414743.Jeremy Hylton2001-04-111-16/+54
| | | | | | | | Fix based on patch #414750 by Michael Hudson. New functions get_func_name() and get_func_desc() return reasonable names and descriptions for all objects. XXX Even objects that aren't actually callable.
* Updated version of RISCOS support. SF patch 411213 by Dietmar SchwertbergerGuido van Rossum2001-04-101-0/+4
|
* test_pickle works on sizeof(long)==8 boxes again.Tim Peters2001-04-101-1/+1
| | | | | | | | | | pickle.py The code implicitly assumed that all ints fit in 4 bytes, causing all sorts of mischief (from nonsense results to corrupted pickles). Repaired that. marshal.c The int marshaling code assumed that right shifts of signed longs sign-extend. Repaired that.
* Warn when assigning to __debug__ instead of raising an error.Jeremy Hylton2001-04-091-7/+2
|
* 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.
* Bug fix: compile() called from a nested-scopes-enable Python was notJeremy Hylton2001-03-261-1/+1
| | | | | using nested scopes to compile its argument. Pass compiler flags through to underlying compile call.
* Finishing touch to Ping's changes. This is a patch that Ping sent meGuido van Rossum2001-03-231-11/+11
| | | | | | | | but apparently he had to go to school, so I am checking it in for him. This makes PyRun_HandleSystemExit() a static instead, called handle_system_exit(), and let it use the current exception rather than passing in an exception. This slightly simplifies the code.
* call_sys_exitfunc(): Remove unused variable f.Fred Drake2001-03-231-1/+1
|
* Allow sys.excepthook and sys.exitfunc to quietly exit with a sys.exit().Ka-Ping Yee2001-03-231-32/+37
| | | | sys.exitfunc gets the last word on the exit status of the program.
* Make it illegal to assign to __debug__ as per Guido's request.Jeremy Hylton2001-03-231-1/+12
|
* Fix memory leak with SyntaxError. (The DECREF was originally hiddenGuido van Rossum2001-03-231-0/+1
| | | | | inside a piece of code that was deemed reduntant; the DECREF was unfortunately *not* redundant!)
* Add sys.excepthook.Ka-Ping Yee2001-03-232-20/+83
| | | | | | | | 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__.