summaryrefslogtreecommitdiff
path: root/Python/ceval.c
AgeCommit message (Collapse)AuthorLines
1997-12-31Last-minute fix for Jim H: don't die after del sys.stdoutGuido van Rossum-2/+11
1997-12-26Plug the most annoying recursive printing problem -- reset '_' to NoneGuido van Rossum-3/+8
before printing and set it to the printed variable *after* printing (and only when printing is successful).
1997-11-19Give more detailed error message when the argument count isn't right.Guido van Rossum-4/+6
1997-11-11Fix memory leak in exec statement with code object -- the None returnedGuido van Rossum-2/+4
by PyEval_EvalCode() on success was never DECREF'ed. Fix by Bernhard Herzog.
1997-09-30Change PyEval_SaveThread() and PyEval_RestoreThread() to always do theGuido van Rossum-12/+9
tstate swapping. Only the acquiring and releasing of the lock is conditional (twice, under ``#ifdef WITH_THREAD'' and inside ``if (interpreter_lock)'').
1997-09-05First part of package support.Guido van Rossum-10/+4
This doesn't yet support "import a.b.c" or "from a.b.c import x", but it does recognize directories. When importing a directory, it initializes __path__ to a list containing the directory name, and loads the __init__ module if found. The (internal) find_module() and load_module() functions are restructured so that they both also handle built-in and frozen modules and Mac resources (and directories of course). The imp module's find_module() and (new) load_module() also have this functionality. Moreover, imp unconditionally defines constants for all module types, and has two more new functions: find_module_in_package() and find_module_in_directory(). There's also a new API function, PyImport_ImportModuleEx(), which takes all four __import__ arguments (name, globals, locals, fromlist). The last three may be NULL. This is currently the same as PyImport_ImportModule() but in the future it will be able to do relative dotted-path imports. Other changes: - bltinmodule.c: in __import__, call PyImport_ImportModuleEx(). - ceval.c: always pass the fromlist to __import__, even if it is a C function, so PyImport_ImportModuleEx() is useful. - getmtime.c: the function has a second argument, the FILE*, on which it applies fstat(). According to Sjoerd this is much faster. The first (pathname) argument is ignored, but remains for backward compatibility (so the Mac version still works without changes). By cleverly combining the new imp functionality, the full support for dotted names in Python (mini.py, not checked in) is now about 7K, lavishly commented (vs. 14K for ni plus 11K for ihooks, also lavishly commented). Good night!
1997-08-30Inline PyObject_CallObject (Marc-Andre Lemburg).Guido van Rossum-0/+5
1997-08-28eval_code2(), set_exc_info(): Call PyErr_NormalizeException() theBarry Warsaw-2/+2
former rather than the latter, since PyErr_NormalizeException takes PyObject** and I didn't want to change the interface for set_exc_info (but I did want the changes propagated to eval_code2!).
1997-08-25unpack_sequence(): In finally clause, watch out for Py_DECREFBarry Warsaw-2/+2
evaluating its arguments twice.
1997-08-25eval_code2(): collapsed the implementations of UNPACK_TUPLE andBarry Warsaw-33/+74
UNPACK_LIST byte codes and added a third code path that allows generalized sequence unpacking. Now both syntaxes: a, b, c = seq [a, b, c] = seq can be used to unpack any sequence with the exact right number of items. unpack_sequence(): out-lined implementation of generalized sequence unpacking. tuple and list unpacking are still inlined.
1997-08-22cmp_exception gets promoted (essentially) to the C API functionBarry Warsaw-59/+10
PyErr_GivenExceptionMatches(). set_exc_info(): make sure to normalize exceptions. do_raise(): Use PyErr_NormalizeException() if type is a class. loop_subscript(): Use PyErr_ExceptionMatches() instead of raw pointer compare for PyExc_IndexError.
1997-08-22Reverse the search order for the Don Beaudry hook so that the firstGuido van Rossum-4/+3
class wins. Makes more sense.
1997-08-05Renamed a local label that was accidentally grandly renamed toGuido van Rossum-3/+3
'Py_Cleanup' back to 'cleanup'.
1997-08-02The last of the mass checkins for separate (sub)interpreters.Guido van Rossum-9/+20
Everything should now work again. See the comments for the .h files mass checkin (e.g. pystate.h) for more detail.
1997-07-31Extend the "Don Beaudry hack" with "Guido's corollary" -- if the baseGuido van Rossum-10/+27
class has a __class__ attribute, call that to create the new class. This allows us to write metaclasses purely in C!
1997-07-19Moved PyEval_{Acquire,Release}Thread() to within the same #ifdefGuido van Rossum-21/+23
WITH_THREAD as PyEval_InitThreads(). Removed use of Py_SuppressPrintingFlag.
1997-07-18PyEval_SaveThread() and PyEval_RestoreThread() now return/take aGuido van Rossum-6/+28
PyThreadState pointer instead of a (frame) PyObject pointer. This makes much more sense. It is backward incompatible, but that's no problem, because (a) the heaviest users are the Py_{BEGIN,END}_ ALLOW_THREADS macros here, which have been fixed too; (b) there are very few direct users; (c) those who use it are there will probably appreciate the change. Also, added new functions PyEval_AcquireThread() and PyEval_ReleaseThread() which allows the threads created by the thread module as well threads created by others (!) to set/reset the current thread, and at the same time acquire/release the interpreter lock. Much saner.
1997-07-17Huge speedup by inlining some common integer operations:Guido van Rossum-5/+75
int+int, int-int, int <compareop> int, and list[int]. (Unfortunately, int*int is way too much code to inline.) Also corrected a NULL that should have been a zero.
1997-05-23PyObject_Compare can raise an exception now.Guido van Rossum-0/+7
1997-05-22Py_FlushLine and PyFile_WriteString now return error indicatorsGuido van Rossum-12/+24
instead of calling PyErr_Clear(). Add checking of those errors.
1997-05-20Plug leak of stack frame object in exception handling code.Guido van Rossum-9/+26
Also delay DECREF calls until after the structures have been updated (for reentrancy awareness).
1997-05-20Logic for enabling mac-specific signal handling fixed (Jack)Guido van Rossum-1/+1
1997-05-13(int) cast for strlen() to keep picky compilers happy.Guido van Rossum-1/+1
1997-05-07Instead of importing graminit.h whenever one of the three grammar 'root'Guido van Rossum-3/+3
symbols is needed, define these in Python.h with a Py_ prefix.
1997-05-06Used operators from abstract.h where possible (arithmetic operators,Guido van Rossum-420/+30
get/set/del item). This removes a pile of duplication. There's no abstract operator for 'not' but I removed the function call for it anyway -- it's a little faster in-line.
1997-05-05Massive changes for separate thread state management.Guido van Rossum-150/+262
All per-thread globals are moved into a struct which is manipulated separately.
1997-04-29Quickly renamed.Guido van Rossum-798/+797
1997-03-10Clarify error message for unexpected keyword parameter.Guido van Rossum-1/+4
1997-02-14*Don't* kill all local variables on function exit. This will be doneGuido van Rossum-12/+0
by the frameobject dealloc when it is time for the locals to go. When there's still a traceback object referencing this stack frame, we don't want the local variables to disappear yet. (Hmm... Shouldn't they be copied to the f_locals dictionary?)
1997-01-27Two small changes:Guido van Rossum-5/+3
- Use co->... instead of f->f_code->...; save an extra lookup of what we already have in a local variable). - Remove test for nlocals > 0 before setting fastlocals to f->f_localsplus; 0 is a rare case and the assignment is safe even then.
1997-01-27Plug a leak with calling something other than a function or method isGuido van Rossum-4/+3
called with keyword arguments -- the keyword and value were leaked. This affected for instance with a __call__() method. Bug reported and fix supplied by Jim Fulton.
1997-01-24Patches for (two forms of) optional dynamic execution profiling --Guido van Rossum-0/+68
i.e., counting opcode frequencies, or (with DXPAIRS defined) opcode pair frequencies. Define DYNAMIC_EXECUTION_PROFILE on the command line (for this file and for sysmodule.c) to enable.
1997-01-24Change the control flow for error handling in the function prelude toGuido van Rossum-23/+17
jump to the "Kill locals" section at the end. Add #ifdef macintosh bandaid to make sure we call sigcheck() on the Mac.
1997-01-21Kill all local variables on function return. This closes a giganticGuido van Rossum-0/+12
leak of memory and file descriptors (thanks for Roj for reporting that!). Alas, the speed goes down by 5%. :-(
1997-01-21Only call sigcheck() at the ticker code if we don't have true signals.Guido van Rossum-2/+6
This is safe now that both intrcheck() and signalmodule.c schedule a sigcheck() call via Py_AddPendingCall(). This gives another 7% speedup (never run such a test twice ;-).
1997-01-21Cleanup:Guido van Rossum-222/+10
- fix bug in Py_MakePendingCalls() with threading - fix return type of do_raise - remove build_slice (same as PySlice_New) - remove code inside #if 0 - remove code inside #ifdef CHECK_STACK - remove code inside #ifdef SUPPORT_OBSOLETE_ACCESS - comment about newimp.py should refer to ni.py
1997-01-20Changes for frame object speedup:Guido van Rossum-14/+2
- get fastlocals differently - call newframeobject() with fewer arguments - toss getowner(), which was unused anyway
1997-01-18Add "if (x != NULL) continue;" (or similar for err==0) before theGuido van Rossum-18/+60
break to most cases, as suggested by Tim Peters. This gives another 8-10% speedup.
1997-01-17Use the stack size from the code object and the CO_MAXBLOCKS constantGuido van Rossum-2/+10
from compile.h. Remove all eval stack overflow checks.
1996-12-30Rename DEBUG macro to Py_DEBUGGuido van Rossum-3/+3
1996-12-10Moved the raise logic out of the main interpreter loop to a separate function.Guido van Rossum-60/+127
The raise logic has one additional feature: if you raise <class>, <value> where <value> is not an instance, it will construct an instance using <value> as argument. If <value> is None, <class> is instantiated without arguments. If <value> is a tuple, it is used as the argument list. This feature is intended to make it easier to upgrade code from using string exceptions to using class exceptions; without this feature, you'd have to change every raise statement from ``raise X'' to ``raise X()'' and from ``raise X, y'' to ``raise X(y)''. The latter is still the recommended form (because it has no ambiguities about the number of arguments), but this change makes the transition less painful.
1996-12-05Change the Don Beaudry hack into the Don B + Jim F hack; now, if *any*Guido van Rossum-28/+26
base class is special it gets invoked. Make gcc -Wall happy.
1996-10-25New permission notice, includes CNRI.Guido van Rossum-12/+19
1996-08-19Raise TypeError, not KeyError, on unknown keyword argument.Guido van Rossum-2/+1
1996-08-16Don't test here for negative number to float power; that belongs inGuido van Rossum-9/+0
floatobject.c.
1996-08-12Disable support for access statementGuido van Rossum-0/+28
1996-07-30Better error message if stride used on normal sequence objectGuido van Rossum-2/+10
1996-07-30Changes for slice and ellipsesGuido van Rossum-13/+67
1996-06-19Renamed static pow() to powerop() to avoid name conflict in some compilers.Guido van Rossum-4/+4
1996-05-24Removed some done "to do" items.Guido van Rossum-9/+3
Changed #ifdef DEBUG slightly.