summaryrefslogtreecommitdiffstats
path: root/Objects/frameobject.c
Commit message (Collapse)AuthorAgeFilesLines
* Merge ssize_t branch.Martin v. Löwis2006-02-151-11/+11
|
* Fix a bunch of imports to use code.h instead of compile.h.Jeremy Hylton2005-10-211-1/+0
| | | | Remove duplicate declarations from compile.h
* Merge ast-branch to headJeremy Hylton2005-10-201-0/+1
| | | | | | | | | | This change implements a new bytecode compiler, based on a transformation of the parse tree to an abstract syntax defined in Parser/Python.asdl. The compiler implementation is not complete, but it is in stable enough shape to run the entire test suite excepting two disabled tests.
* SF Bug #215126: Over restricted type checking on eval() functionRaymond Hettinger2004-07-021-6/+9
| | | | | | The builtin eval() function now accepts any mapping for the locals argument. Time sensitive steps guarded by PyDict_CheckExact() to keep from slowing down the normal case. My timings so no measurable impact.
* memset() with small memory sizes just kill us.Armin Rigo2004-03-201-2/+4
|
* Two forgotten Py_DECREF() for two out-of-memory conditions.Armin Rigo2004-01-271-2/+6
|
* Removing bogus Py_DECREF() reported by Armin Rigo (SF bug 812353).Jeremy Hylton2003-10-211-1/+0
| | | | | Even if a new dict is generated for locals, it is stored in f->f_locals.
* Fix indentation.Jeremy Hylton2003-10-211-1/+1
|
* Fix silly typo in comment.Michael W. Hudson2003-08-111-1/+1
|
* Refactor the logic for setting f_builtins.Jeremy Hylton2003-02-051-24/+31
| | | | | | | For the case where the current globals match the previous frame's globals, eliminates three tests in two if statements. For the case where we just get __builtins__ from a module, eliminate a couple of tests.
* Since the *_Init() are private, prefix with _, suggested by SkipNeal Norwitz2002-12-311-1/+1
|
* SF #561244, Micro optimizationsNeal Norwitz2002-12-301-9/+13
| | | | | | Initialize the small integers and __builtins__ in startup. This removes some if conditions. Change XDECREF to DECREF for values which shouldn't be NULL.
* Fix bug introduced by SF patch #643835, Set Next Statement for Python debuggersNeal Norwitz2002-12-191-4/+12
| | | | | | blockstack_top could be 0 when blockstack[blockstack_top-1] was referenced (ie blockstack[-1]) which crashed on hpux. Patch & fix by Richie Hindle
* Undefine MIN and MAX before definingNeal Norwitz2002-12-181-0/+2
| | | | Some systems (HPUX at least) already define MIN/MAX for us
* This is Richie Hindle's patchMichael W. Hudson2002-12-171-1/+259
| | | | | | | | [ 643835 ] Set Next Statement for Python debuggers with a few tweaks by me: adding an unsigned or two, mentioning that not all jumps are allowed in the doc for pdb, adding a NEWS item and a note to whatsnew, and AuCTeX doing something cosmetic to libpdb.tex.
* A slight change to SET_LINENO-less tracing.Michael W. Hudson2002-09-111-2/+36
| | | | | This makes things a touch more like 2.2. Read the comments in Python/ceval.c for more details.
* SF #561244: micro optimizations, builtins cannot be NULL, so use Py_INCREFNeal Norwitz2002-08-291-1/+1
|
* Check in my ultra-shortlived patch #597220.Michael W. Hudson2002-08-191-3/+3
| | | | | | Move some debugging checks inside Py_DEBUG. They were causing cache misses according to cachegrind.
* This is my patchMichael W. Hudson2002-08-151-2/+12
| | | | | | | | [ 587993 ] SET_LINENO killer Remove SET_LINENO. Tracing is now supported by inspecting co_lnotab. Many sundry changes to document and adapt to this change.
* Tim found that once test_longexp has run, test_sort takes very muchGuido van Rossum2002-08-011-5/+3
| | | | | | | | | | | | longer to run than normal. A profiler run showed that this was due to PyFrame_New() taking up an unreasonable amount of time. A little thinking showed that this was due to the while loop clearing the space available for the stack. The solution is to only clear the local variables (and cells and free variables), not the space available for the stack, since anything beyond the stack top is considered to be garbage anyway. Also, use memset() instead of a while loop counting backwards. This should be a time savings for normal code too! (By a probably unmeasurable amount. :-)
* Fix SF bug #505315: Make free and cell vars show up consistently in locals().Jeremy Hylton2002-04-201-6/+7
| | | | | | | | | | PyFrame_FastToLocals() and PyFrame_LocalsToFast() had a return if f_nlocals was 0. I think this was a holdover from the pre 2.1 days when regular locals were the only kind of local variables. The change makes it possible to use a free variable in eval or exec if it the variable is also used elsewhere in the same block, which is what the documentation says.
* SF bug 543148: Memory leak with stackframes + inspect.Tim Peters2002-04-131-2/+17
| | | | | | | | Put a bound on the number of frameobjects that can live in the frameobject free_list. Am also backporting to 2.2. I don't intend to backport to 2.1 (too much work -- lots of cyclic structures leak there, and the GC API).
* This is Neil's fix for SF bug 535905 (Evil Trashcan and GC interaction).Guido van Rossum2002-03-281-1/+1
| | | | | | | | The fix makes it possible to call PyObject_GC_UnTrack() more than once on the same object, and then move the PyObject_GC_UnTrack() call to *before* the trashcan code is invoked. BUGFIX CANDIDATE!
* Fix memory leak in dict_to_map(), SF bug [ #485152 ] memory leak in test_scope.Jeremy Hylton2001-12-061-8/+11
| | | | | | | | | | | | PyCell_Set() incremenets the reference count, so the earlier XINCREF causes a leak. Also make a number of small performance improvements to the code on the assumption that most of the time variables are not rebound across a FastToLocals() / LocalsToFast() pair. Replace uses of PyCell_Set() and PyCell_Get() with PyCell_SET() and PyCell_GET(), since the frame is guaranteed to contain cells.
* Add optional docstrings to getset descriptors. Fortunately, there'sGuido van Rossum2001-09-201-1/+1
| | | | | | | | | | no backwards compatibility to worry about, so I just pushed the 'closure' struct member to the back -- it's never used in the current code base (I may eliminate it, but that's more work because the getter and setter signatures would have to change.) As examples, I added actual docstrings to the getset attributes of a few types: file.closed, xxsubtype.spamdict.state.
* 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.
* Squash new compiler wng in debug build.Tim Peters2001-08-301-1/+1
|
* Make frames a PyVarObject. Use new GC API.Neil Schemenauer2001-08-291-30/+14
|
* Merge of descr-branch back into trunk.Tim Peters2001-08-021-14/+21
|
* GC for frame objects.Neil Schemenauer2001-07-121-12/+101
|
* PyFrameObject: rename f_stackbottom to f_stacktop, since it points toTim Peters2001-06-231-3/+5
| | | | | | | | 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.
* Merging the gen-branch into the main line, at Guido's direction. Yay!Tim Peters2001-06-181-0/+6
| | | | | Bugfix candidate in inspect.py: it was referencing "self" outside of a method.
* SF patch 419176 from MvL; fixed bug 418977Jeremy Hylton2001-05-081-6/+3
| | | | Two errors in dict_to_map() helper used by PyFrame_LocalsToFast().
* Make one more private symbol static.Guido van Rossum2001-04-141-1/+1
|
* Make some private symbols static.Guido van Rossum2001-04-141-1/+1
|
* Fix PyFrame_FastToLocals() and counterpart to deal with cells andJeremy Hylton2001-03-211-20/+68
| | | | | | | | | | | | | | frees. Note there doesn't seem to be any way to test LocalsToFast(), because the instructions that trigger it are illegal in nested scopes with free variables. Fix allocation strategy for cells that are also formal parameters. Instead of emitting LOAD_FAST / STORE_DEREF pairs for each parameter, have the argument handling code in eval_code2() do the right thing. A side-effect of this change is that cell variables that are also arguments are listed at the front of co_cellvars in the order they appear in the argument list.
* Variety of small INC/DECREF patches that fix reported memory leaksJeremy Hylton2001-03-131-3/+4
| | | | | | | | | | | | | | | | | | | | | with free variables. Thanks to Martin v. Loewis for finding two of the problems. This fixes SF buf 405583. There is also a C API change: PyFrame_New() is reverting to its pre-2.1 signature. The change introduced by nested scopes was a mistake. XXX Is this okay between beta releases? cell_clear(), the GC helper, must decref its reference to break cycles. frame_dealloc() must dealloc all cell vars and free vars in addition to locals. eval_code2() setup code must INCREF cells it copies out of the closure. The STORE_DEREF opcode implementation must DECREF the object it passes to PyCell_Set().
* Remove f_closure slot of frameobject and use f_localsplus instead.Jeremy Hylton2001-01-291-23/+14
| | | | | | | | | | | | This change eliminates an extra malloc/free when a frame with free variables is created. Any cell vars or free vars are stored in f_localsplus after the locals and before the stack. eval_code2() fills in the appropriate values after handling initialization of locals. To track the size the frame has an f_size member that tracks the total size of f_localsplus. It used to be implicitly f_nlocals + f_stacksize.
* PEP 227 implementationJeremy Hylton2001-01-251-3/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The majority of the changes are in the compiler. The mainloop changes primarily to implement the new opcodes and to pass a function's closure to eval_code2(). Frames and functions got new slots to hold the closure. Include/compile.h Add co_freevars and co_cellvars slots to code objects. Update PyCode_New() to take freevars and cellvars as arguments Include/funcobject.h Add func_closure slot to function objects. Add GetClosure()/SetClosure() functions (and corresponding macros) for getting at the closure. Include/frameobject.h PyFrame_New() now takes a closure. Include/opcode.h Add four new opcodes: MAKE_CLOSURE, LOAD_CLOSURE, LOAD_DEREF, STORE_DEREF. Remove comment about old requirement for opcodes to fit in 7 bits. compile.c Implement changes to code objects for co_freevars and co_cellvars. Modify symbol table to use st_cur_name (string object for the name of the current scope) and st_cur_children (list of nested blocks). Also define st_nested, which might more properly be called st_cur_nested. Add several DEF_XXX flags to track def-use information for free variables. New or modified functions of note: com_make_closure(struct compiling *, PyCodeObject *) Emit LOAD_CLOSURE opcodes as needed to pass cells for free variables into nested scope. com_addop_varname(struct compiling *, int, char *) Emits opcodes for LOAD_DEREF and STORE_DEREF. get_ref_type(struct compiling *, char *name) Return NAME_CLOSURE if ref type is FREE or CELL symtable_load_symbols(struct compiling *) Decides what variables are cell or free based on def-use info. Can now raise SyntaxError if nested scopes are mixed with exec or from blah import *. make_scope_info(PyObject *, PyObject *, int, int) Helper functions for symtable scope stack. symtable_update_free_vars(struct symtable *) After a code block has been analyzed, it must check each of its children for free variables that are not defined in the block. If a variable is free in a child and not defined in the parent, then it is defined by block the enclosing the current one or it is a global. This does the right logic. symtable_add_use() is now a macro for symtable_add_def() symtable_assign(struct symtable *, node *) Use goto instead of for (;;) Fixed bug in symtable where name of keyword argument in function call was treated as assignment in the scope of the call site. Ex: def f(): g(a=2) # a was considered a local of f ceval.c eval_code2() now take one more argument, a closure. Implement LOAD_CLOSURE, LOAD_DEREF, STORE_DEREF, MAKE_CLOSURE> Also: When name error occurs for global variable, report that the name was global in the error mesage. Objects/frameobject.c Initialize f_closure to be a tuple containing space for cellvars and freevars. f_closure is NULL if neither are present. Objects/funcobject.c Add support for func_closure. Python/import.c Change the magic number. Python/marshal.c Track changes to code objects.
* REMOVED all CWI, CNRI and BeOpen copyright markings.Guido van Rossum2000-09-011-9/+0
| | | | This should match the situation in the 1.6b1 tree.
* ANSI-fication of the sources.Fred Drake2000-07-091-27/+10
|
* Change copyright notice - 2nd try.Guido van Rossum2000-06-301-6/+0
|
* Change copyright notice.Guido van Rossum2000-06-301-21/+6
|
* Vladimir Marangozov's long-awaited malloc restructuring.Guido van Rossum2000-05-031-9/+8
| | | | | | | | | | For more comments, read the patches@python.org archives. For documentation read the comments in mymalloc.h and objimpl.h. (This is not exactly what Vladimir posted to the patches list; I've made a few changes, and Vladimir sent me a fix in private email for a problem that only occurs in debug mode. I'm also holding back on his change to main.c, which seems unnecessary to me.)
* Christian Tismer's "trashcan" patch:Guido van Rossum2000-03-131-0/+2
| | | | | | | | Added wrapping macros to dictobject.c, listobject.c, tupleobject.c, frameobject.c, traceback.c that safely prevends core dumps on stack overflow. Macros and functions in object.c, object.h. The method is an "elevator destructor" that turns cascading deletes into tail recursive behavior when some limit is hit.
* The rest of the changes by Trent Mick and Dale Nagata for warning-freeGuido van Rossum2000-01-201-2/+2
| | | | compilation on NT Alpha. Mostly added casts etc.
* A Py_DECREF(f) is missing in PyFrame_New for the error case whenGuido van Rossum1998-10-191-4/+4
| | | | the `builtins' initialization fails. Vladimir Marangozov.
* In PyFrame_New(), don't set extras to something derived from codeGuido van Rossum1998-09-251-1/+2
| | | | | before code has been checked for validity. Discovered by Vladimir Marangozov.
* Since PyDict_GetItem() can't raise an exception any more, there's noGuido van Rossum1998-05-141-4/+1
| | | | need to cxall PyErr_Clear() when it returns NULL.
* Vladimir Marangozov' performance hack: copy f_builtins from ancestorGuido van Rossum1998-02-191-3/+14
| | | | | | | if the globals are the same. Also, when creating a dummy builtins dictionary, add "None" to it, just to be kind.