summaryrefslogtreecommitdiffstats
path: root/Python/ceval.c
Commit message (Collapse)AuthorAgeFilesLines
* Now FOR_LOOP is gone, loop_subscript can go too.Michael W. Hudson2002-06-141-19/+0
| | | | make -s rules :-)
* The opcode FOR_LOOP no longer exists.Guido van Rossum2002-06-131-31/+0
|
* SF bug 567538: Generator can crash the interpreter (Finn Bock).Guido van Rossum2002-06-121-2/+2
| | | | | | | | | | This was a simple typo. Strange that the compiler didn't catch it! Instead of WHY_CONTINUE, two tests used CONTINUE_LOOP, which isn't a why_code at all, but an opcode; but even though 'why' is declared as an enum, comparing it to an int is apparently not even worth a warning -- not in gcc, and not in VC++. :-( Will fix in 2.2 too.
* Fix forMichael W. Hudson2002-05-201-1/+1
| | | | | | | | | | | [ 558249 ] softspace vs --disable-unicode And #endif was in the wrong place. Bugfix candidate, almost surely. I think I will embark on squashing test failures in --disable-unicode builds -- a Real Bug was hiding under them.
* ceval.c/do_raise(): Tighten the test to disallow raising an instance ofTim Peters2002-04-181-1/+4
| | | | | | | | a str subclass. test_descr.py/string_exceptions(): New sub-test. For 2.3 only. Guido doesn't want this backported.
* Fix an issue that was reported in but unrelated to the main problem ofGuido van Rossum2002-03-281-2/+10
| | | | | | | | | | | | | SF bug 535905 (Evil Trashcan and GC interaction). The SETLOCAL() macro should not DECREF the local variable in-place and then store the new value; it should copy the old value to a temporary value, then store the new value, and then DECREF the temporary value. This is because it is possible that during the DECREF the frame is accessed by other code (e.g. a __del__ method or gc.collect()) and the variable would be pointing to already-freed memory. BUGFIX CANDIDATE!
* SF bug 480215: softspace confused in nested printTim Peters2002-03-241-10/+12
| | | | | | | | | | This fixes the symptom, but PRINT_ITEM has no way to know what (if anything) PyFile_WriteObject() writes unless the object being printed is a string. When the object isn't a string, this fix retains the guess that softspace should be set after PyFile_WriteObject(). We might want to say that it's the job of filelike-object write methods to leave the file's softspace in the correct state. That would probably be better -- but everyone relies on PRINT_ITEM to guess for them now.
* Disable the parser hacks that enabled the "yield" keyword using a futureNeil Schemenauer2002-03-221-0/+2
| | | | statement.
* Re-enable GC of generator objects.Neil Schemenauer2002-03-181-6/+6
|
* Move some opcodes to top of big eval_frame switch statement. SkipNeil Schemenauer2002-02-171-44/+45
| | | | | things_to_do block for a few common opcodes that don't do any real work. Closes SF patch #512256.
* LOAD_FAST: rearrange branches to favor the expected case, and getTim Peters2002-02-121-10/+7
| | | | rid of a redundant NULL-pointer check in the expected case.
* Patch #494783: Rename cmp_op enumerators.Martin v. Löwis2002-01-011-15/+19
|
* SF bug #496549 -Qnew and in-place division "/=".Tim Peters2001-12-251-11/+14
| | | | | | | | eval_frame(): Under -Qnew, INPLACE_DIVIDE wasn't getting handed off to INPLACE_TRUE_DIVIDE (like BINARY_DIVIDE was getting handed off to BINARY_TRUE_DIVIDE). Bugfix candidate.
* SF bug #494668: PUSH() should assert-fail on overflow.Tim Peters2001-12-191-2/+4
| | | | | eval_frame(): Added asserts to the top of the eval loop, to verify that the eval stack pointer is in bounds, plus some comments.
* Patch #494384: Disable more Unicode API if Unicode is not used.Martin v. Löwis2001-12-181-0/+2
|
* _PyEval_SliceIndex(): explain why a NULL argument is allowed (thanksTim Peters2001-12-161-4/+4
| | | | to Guido for the revelation).
* _PyEval_SliceIndex(): Repaired the comments, and added XXX commentsTim Peters2001-12-161-6/+11
| | | | | about its dubious treatment of NULL (also opened a bug report on that, but don't want to risk changing it this late in the 2.2 game).
* Fix for SF bug [ #492403 ] exec() segfaults on closure's func_codeJeremy Hylton2001-12-131-1/+6
| | | | | | | | Based on the patch from Danny Yoo. The fix is in exec_statement() in ceval.c. There are also changes to introduce use of PyCode_GetNumFree() in several places.
* Fix for SF bug #489671 (Neil Norwitz): memory leak in test_richcmp.Guido van Rossum2001-12-061-0/+8
| | | | | | Had nothing to do with rich comparisons -- some stack cleanup code was lost as a result of merging in Neil Schemenauer's generators patch. Reinserted the stack cleanup code, skipping it when yielding.
* Fix a typo (probably caused by autocompletion <blush>) that caused aGuido van Rossum2001-12-061-1/+1
| | | | | | leak when a class defined a __metaclass__. This fixes the problem reported on python-dev by Ping; I dunno if it's the same as SF bug #489669 (since that mentions Unicode).
* SF bug #488514: -Qnew needs workTim Peters2001-12-061-11/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Big Hammer to implement -Qnew as PEP 238 says it should work (a global option affecting all instances of "/"). pydebug.h, main.c, pythonrun.c: define a private _Py_QnewFlag flag, true iff -Qnew is passed on the command line. This should go away (as the comments say) when true division becomes The Rule. This is deliberately not exposed to runtime inspection or modification: it's a one-way one-shot switch to pretend you're using Python 3. ceval.c: when _Py_QnewFlag is set, treat BINARY_DIVIDE as BINARY_TRUE_DIVIDE. test_{descr, generators, zipfile}.py: fiddle so these pass under -Qnew too. This was just a matter of s!/!//! in test_generators and test_zipfile. test_descr was trickier, as testbinop() is passed assumptions that "/" is the same as calling a "__div__" method; put a temporary hack there to call "__truediv__" instead when the method name is "__div__" and 1/2 evaluates to 0.5. Three standard tests still fail under -Qnew (on Windows; somebody please try the Linux tests with -Qnew too! Linux runs a whole bunch of tests Windows doesn't): test_augassign test_class test_coercion I can't stay awake longer to stare at this (be my guest). Offhand cures weren't obvious, nor was it even obvious that cures are possible without major hackery. Question: when -Qnew is in effect, should calls to __div__ magically change into calls to __truediv__? See "major hackery" at tail end of last paragraph <wink>.
* Fix the final two issues in Armin Rigo's SF bug #488477: apply_slice()Guido van Rossum2001-12-031-4/+10
| | | | | and assign_slice() weren't properly DECREF'ing the temporary slice object they created. (Shame on me. :-)
* unpack_iterable(): Add a missing DECREF in an error case. Reported byGuido van Rossum2001-12-031-0/+1
| | | | | Armin Rigo (SF bug #488477). Added a testcase to test_unpack_iter() in test_iter.py.
* SF bug #483469: crash on unbounded recursion in __del__.Tim Peters2001-11-271-0/+8
| | | | | | | | | | | | | PyEval_EvalCodeEx(): increment tstate->recursion_depth around the decref of the frame, because the C stack for this call is still in use and the decref can lead to __del__ methods getting called. While this gives tstate->recursion_depth a value proportional to the depth of the C stack (instead of a small constant no matter how deeply __del__s recurse), it's not enough to stop the reported crash when using the default recursion limit on Windows. Bugfix candidate.
* Fix for bug #480188: printing unicode objectsMarc-André Lemburg2001-11-201-3/+13
|
* Backing out the fast path for interned string compares again as requested.Marc-André Lemburg2001-11-081-15/+0
|
* Add fast-path for comparing interned (true) string objects.Marc-André Lemburg2001-11-071-0/+15
| | | | | | This patch boosts performance for comparing identical string object by some 20% on my machine while not causing any noticable slow-down for other operations (according to tests done with pybench).
* SF Patch (but with no patch) 472555 Remove trailing common in enumeration.Tim Peters2001-10-181-1/+1
| | | | | Some AIX compiler didn't like the trailing comma at the end of the why_code enum decl.
* For debug build, check that the stack pointer never exceeds the stack size.Jeremy Hylton2001-10-171-1/+3
|
* make getarray static - it's only called from ceval.c and is not anSkip Montanaro2001-10-151-1/+1
| | | | extern-able name.
* Suppress a bunch of "value computed is not used" warnings when building inFred Drake2001-10-131-2/+2
| | | | debug mode (--with-pydebug).
* Introduced the oddly-missing PyList_CheckExact(), and used it to replaceTim Peters2001-10-051-1/+1
| | | | a hard-coded type check.
* Get rid of unique local ISSTRICTINT macro in favor of std PyInt_CheckExact.Tim Peters2001-10-051-9/+6
|
* Fix bug in profiler modifications detected only in debug builds.Fred Drake2001-10-041-3/+26
| | | | | | | | | The new profiler event stream includes a "return" event even when an exception is being propogated, but the machinery that called the profile hook did not save & restore the exception. In debug mode, the exception was detected during the execution of the profile callback, which did not have the proper internal flags set for the exception. Saving & restoring the exception state solves the problem.
* Rationalize the events passed to the profiler (no changes for the tracer).Fred Drake2001-10-041-10/+4
| | | | | | | | | | | | | | | | | | | | | | | | The profiler does not need to know anything about the exception state, so we no longer call it when an exception is raised. We do, however, make sure we *always* call the profiler when we exit a frame. This ensures that timing events are more easily isolated by a profiler and finally clauses that do a lot of work don't have their time mis-allocated. When an exception is propogated out of the frame, the C callback for the profiler now receives a PyTrace_RETURN event with an arg of NULL; the Python-level profile hook function will see a 'return' event with an arg of None. This means that from Python it is impossible for the profiler to determine if the frame exited with an exception or if it returned None, but this doesn't matter for profiling. A C-based profiler could tell the difference, but this doesn't seem important. ceval.c:eval_frame(): Simplify the code in two places so that the profiler is called for every exit from a frame and not for exceptions. sysmodule.c:profile_trampoline(): Make sure we don't expose Python code to NULL; use None instead.
* SF bug [#466173] unpack TypeError unclearTim Peters2001-09-301-1/+5
| | | | | | Replaced 3 instances of "iter() of non-sequence" with "iteration over non-sequence". Restored "unpack non-sequence" for stuff like "a, b = 1".
* Prevent a NULL pointer from being pushed onto the stack.Jeremy Hylton2001-09-261-1/+5
| | | | | | | | | | | | It's possible for PyErr_NormalizeException() to set the traceback pointer to NULL. I'm not sure how to provoke this directly from Python, although it may be possible. The error occurs when an exception is set using PyErr_SetObject() and another exception occurs while PyErr_NormalizeException() is creating the exception instance. XXX As a result of this change, it's possible for an exception to occur but sys.last_traceback to be left undefined. Not sure if this is a problem.
* Don't swap the arguments to PyFrame_BlockSetup when recreating the recentlyThomas Wouters2001-09-241-2/+2
| | | | | | | | | popped frame-block. What an embarrassing bug! Especially for Jeremy, since he accepted the patch :-) This fixes SF bugs #463359 and #462937, and possibly other, *very* obscure bugs with very deeply nested loops that continue the loop and then break out of it or raise an exception.
* Add optional docstrings to member descriptors. For backwardsGuido van Rossum2001-09-201-1/+1
| | | | | | | | | | | | | | | compatibility, this required all places where an array of "struct memberlist" structures was declared that is referenced from a type's tp_members slot to change the type of the structure to PyMemberDef; "struct memberlist" is now only used by old code that still calls PyMember_Get/Set. The code in PyObject_GenericGetAttr/SetAttr now calls the new APIs PyMember_GetOne/SetOne, which take a PyMemberDef argument. As examples, I added actual docstrings to the attributes of a few types: file, complex, instance method, super, and xxsubtype.spamlist. Also converted the symtable to new style getattr.
* Admit that we'll never add the args for a "call" event to the profileFred Drake2001-09-131-3/+0
| | | | | | and trace functions; this now declares that None will be passed for the "call" event. This closes SF bug/suggestion #460315.
* build_class(): one more (hopefully the last) step on the way toGuido van Rossum2001-09-121-14/+21
| | | | | | | | | backwards compatibility. When using the class of the first base as the metaclass, use its __class__ attribute in preference over its ob_type slot. This ensures that we can still use classic classes as metaclasse, as shown in the original "Metaclasses" essay. This also makes all the examples in Demo/metaclasses/ work again (maybe these should be turned into a test suite?).
* Move call_trace(..., PyTrace_CALL, ...) call to top of eval_frame. ThatNeil Schemenauer2001-09-041-35/+35
| | | | | way it's called each time a generator is resumed. The tracing of normal functions should be unaffected by this change.
* Do the int inlining only if the type is really an int, not wheneverGuido van Rossum2001-08-301-6/+9
| | | | | PyInt_Check() succeeds. That returns true for subtypes of int, which may override __add__ or __sub__.
* Removed some unreachable break statements to silence SGI compiler.Sjoerd Mullender2001-08-301-3/+0
|
* When an inlined operation on two small ints causes overflow, don'tGuido van Rossum2001-08-231-32/+24
| | | | | raise the exception here -- call the generic function (which may convert the arguments to long and try again).
* Fix SF bug #443600:Guido van Rossum2001-08-181-15/+46
| | | | | | | | Change to get/set/del slice operations so that if the object doesn't support slicing, *or* if either of the slice arguments is not an int or long, we construct a slice object and call the get/set/del item operation instead. This makes it possible to design classes that support slice arguments of non-integral types.
* ceval, PyEval_MergeCompilerFlags: wasn't merging in theTim Peters2001-08-171-6/+3
| | | | | | | | | | | | | | CO_FUTURE_DIVISION flag. Redid this to use Jeremy's PyCF_MASK #define instead, so we dont have to remember to fiddle individual feature names here again. pythonrun.h: Also #define a PyCF_MASK_OBSOLETE mask. This isn't used yet, but will be as part of the PEP 264 implementation (compile() mustn't raise an error just because old code uses a flag name that's become obsolete; a warning may be appropriate, but not an error; so compile() has to know about obsolete flags too, but nobody is going to remember to update compile() with individual obsolete flag names across releases either -- i.e., this is the flip side of PyEval_MergeCompilerFlags's oversight).
* Patch #427190: Implement and use METH_NOARGS and METH_O.Martin v. Löwis2001-08-161-23/+50
|
* Remove much dead code from ceval.cJeremy Hylton2001-08-121-220/+18
| | | | | | | | | | | | | | The descr changes moved the dispatch for calling objects from call_object() in ceval.c to PyObject_Call() in abstract.c. call_object() and the many functions it used in ceval.c were no longer used, but were not removed. Rename meth_call() as PyCFunction_Call() so that it can be called by the CALL_FUNCTION opcode in ceval.c. Also, fix error message that referred to PyEval_EvalCodeEx() by its old name eval_code2(). (I'll probably refer to it by its old name, too.)
* Refactor future feature handlingJeremy Hylton2001-08-101-2/+2
| | | | | | | | | | | Replace uses of PyCF_xxx with CO_xxx. Replace individual feature slots in PyFutureFeatures with single bitmask ff_features. When flags must be transfered among the three parts of the interpreter that care about them -- the pythonrun layer, the compiler, and the future feature parser -- can simply or (|) the definitions.