summaryrefslogtreecommitdiff
path: root/Python/ceval.c
AgeCommit message (Collapse)AuthorLines
2003-06-29Backport:Neal Norwitz-0/+6
Fix SF #762455, segfault when sys.stdout is changed in getattr Note: in 2.2, the problem was an infinite loop (at least for me).
2002-10-07This is Armin Rigo's patch:Michael W. Hudson-9/+8
[ 617309 ] getframe hook (Psyco #1) Forward port candidate.
2002-10-07This is Armin Rigo's patch:Michael W. Hudson-0/+1
[ 617311 ] Tiny profiling info (Psyco #2) Forward port candidate.
2002-10-07This is Armin Rigo's patch:Michael W. Hudson-8/+15
[ 617312 ] debugger-controlled jumps (Psyco #3) Forward port candidate, I guess.
2002-10-02Fix for the recursion_level bug Armin Rigo reported in sfMichael W. Hudson-0/+4
patch #617312, both on the trunk and the 22-maint branch. Also added a test case, and ported the test_trace I wrote for HEAD to 2.2.2 (with all those horrible extra 'line' events ;-).
2002-08-05Remove calls to 2.1 GC API (they are noops).Neil Schemenauer-4/+2
2002-06-12Backport:Guido van Rossum-2/+2
SF bug 567538: Generator can crash the interpreter (Finn Bock). 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++. :-(
2002-03-28Backport to 2.2.1.Guido van Rossum-2/+10
Fix an issue that was reported in but unrelated to the main problem of 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!
2001-12-28Backport tim_one's checkin of version 2.302:Michael W. Hudson-11/+14
SF bug #496549 -Qnew and in-place division "/=". 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.
2001-12-19SF bug #494668: PUSH() should assert-fail on overflow.Tim Peters-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.
2001-12-18Patch #494384: Disable more Unicode API if Unicode is not used.Martin v. Löwis-0/+2
2001-12-16_PyEval_SliceIndex(): explain why a NULL argument is allowed (thanksTim Peters-4/+4
to Guido for the revelation).
2001-12-16_PyEval_SliceIndex(): Repaired the comments, and added XXX commentsTim Peters-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).
2001-12-13Fix for SF bug [ #492403 ] exec() segfaults on closure's func_codeJeremy Hylton-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.
2001-12-06Fix for SF bug #489671 (Neil Norwitz): memory leak in test_richcmp.Guido van Rossum-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.
2001-12-06Fix a typo (probably caused by autocompletion <blush>) that caused aGuido van Rossum-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).
2001-12-06SF bug #488514: -Qnew needs workTim Peters-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>.
2001-12-03Fix the final two issues in Armin Rigo's SF bug #488477: apply_slice()Guido van Rossum-4/+10
and assign_slice() weren't properly DECREF'ing the temporary slice object they created. (Shame on me. :-)
2001-12-03unpack_iterable(): Add a missing DECREF in an error case. Reported byGuido van Rossum-0/+1
Armin Rigo (SF bug #488477). Added a testcase to test_unpack_iter() in test_iter.py.
2001-11-27SF bug #483469: crash on unbounded recursion in __del__.Tim Peters-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.
2001-11-20Fix for bug #480188: printing unicode objectsMarc-André Lemburg-3/+13
2001-11-08Backing out the fast path for interned string compares again as requested.Marc-André Lemburg-15/+0
2001-11-07Add fast-path for comparing interned (true) string objects.Marc-André Lemburg-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).
2001-10-18SF Patch (but with no patch) 472555 Remove trailing common in enumeration.Tim Peters-1/+1
Some AIX compiler didn't like the trailing comma at the end of the why_code enum decl.
2001-10-17For debug build, check that the stack pointer never exceeds the stack size.Jeremy Hylton-1/+3
2001-10-15make getarray static - it's only called from ceval.c and is not anSkip Montanaro-1/+1
extern-able name.
2001-10-13Suppress a bunch of "value computed is not used" warnings when building inFred Drake-2/+2
debug mode (--with-pydebug).
2001-10-05Introduced the oddly-missing PyList_CheckExact(), and used it to replaceTim Peters-1/+1
a hard-coded type check.
2001-10-05Get rid of unique local ISSTRICTINT macro in favor of std PyInt_CheckExact.Tim Peters-9/+6
2001-10-04Fix bug in profiler modifications detected only in debug builds.Fred Drake-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.
2001-10-04Rationalize the events passed to the profiler (no changes for the tracer).Fred Drake-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.
2001-09-30SF bug [#466173] unpack TypeError unclearTim Peters-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".
2001-09-26Prevent a NULL pointer from being pushed onto the stack.Jeremy Hylton-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.
2001-09-24Don't swap the arguments to PyFrame_BlockSetup when recreating the recentlyThomas Wouters-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.
2001-09-20Add optional docstrings to member descriptors. For backwardsGuido van Rossum-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.
2001-09-13Admit that we'll never add the args for a "call" event to the profileFred Drake-3/+0
and trace functions; this now declares that None will be passed for the "call" event. This closes SF bug/suggestion #460315.
2001-09-12build_class(): one more (hopefully the last) step on the way toGuido van Rossum-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?).
2001-09-04Move call_trace(..., PyTrace_CALL, ...) call to top of eval_frame. ThatNeil Schemenauer-35/+35
way it's called each time a generator is resumed. The tracing of normal functions should be unaffected by this change.
2001-08-30Do the int inlining only if the type is really an int, not wheneverGuido van Rossum-6/+9
PyInt_Check() succeeds. That returns true for subtypes of int, which may override __add__ or __sub__.
2001-08-30Removed some unreachable break statements to silence SGI compiler.Sjoerd Mullender-3/+0
2001-08-23When an inlined operation on two small ints causes overflow, don'tGuido van Rossum-32/+24
raise the exception here -- call the generic function (which may convert the arguments to long and try again).
2001-08-18Fix SF bug #443600:Guido van Rossum-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.
2001-08-17ceval, PyEval_MergeCompilerFlags: wasn't merging in theTim Peters-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).
2001-08-16Patch #427190: Implement and use METH_NOARGS and METH_O.Martin v. Löwis-22/+49
2001-08-12Remove much dead code from ceval.cJeremy Hylton-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.)
2001-08-10Refactor future feature handlingJeremy Hylton-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.
2001-08-08Implement PEP 238 in its (almost) full glory.Guido van Rossum-0/+40
This introduces: - A new operator // that means floor division (the kind of division where 1/2 is 0). - The "future division" statement ("from __future__ import division) which changes the meaning of the / operator to implement "true division" (where 1/2 is 0.5). - New overloadable operators __truediv__ and __floordiv__. - New slots in the PyNumberMethods struct for true and floor division, new abstract APIs for them, new opcodes, and so on. I emphasize that without the future division statement, the semantics of / will remain unchanged until Python 3.0. Not yet implemented are warnings (default off) when / is used with int or long arguments. This has been on display since 7/31 as SF patch #443474. Flames to /dev/null.
2001-08-02Merge of descr-branch back into trunk.Tim Peters-109/+54
2001-07-16Part way to allowing "from __future__ import generators" to communicateTim Peters-13/+24
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.
2001-07-12GC for generator objects.Neil Schemenauer-4/+12