summaryrefslogtreecommitdiffstats
path: root/Python/symtable.c
Commit message (Collapse)AuthorAgeFilesLines
* SF patch #872326: Generator expression implementationRaymond Hettinger2004-05-191-0/+2
| | | | | | | | | | | | | | (Code contributed by Jiwon Seo.) The documentation portion of the patch is being re-worked and will be checked-in soon. Likewise, PEP 289 will be updated to reflect Guido's rationale for the design decisions on binding behavior (as described in in his patch comments and in discussions on python-dev). The test file, test_genexps.py, is written in doctest format and is meant to exercise all aspects of the the patch. Further additions are welcome from everyone. Please stress test this new feature as much as possible before the alpha release.
* Fix for SF [ 734869 ] Lambda functions in list comprehensionsJeremy Hylton2003-05-211-0/+1
| | | | | | The compiler was reseting the list comprehension tmpname counter for each function, but the symtable was using the same counter for the entire module. Repair by move tmpname into the symtable entry. Bugfix candidate.
* Add a comment explaining the st_symbols cache.Jeremy Hylton2001-12-101-1/+15
|
* PySymtableEntry_New(): I'm not sure what this routine is doing, but itTim Peters2001-12-081-0/+1
| | | | | | | | was obviously leaking an int object when whatever the heck it's looking for was found. Repaired that. This accounts for why entering function and class definitions at an interactive prompt leaked a reference to the integer 1 each time. Bugfix candidate.
* SF bug #488687 reported by Neal NorwitzJeremy Hylton2001-12-041-0/+1
| | | | | | | | | The error for assignment to __debug__ used ste->ste_opt_lineno instead of n->n_lineno. The latter was at best incorrect; often the slot was uninitialized. Two fixes here: Use the correct lineno for the error. Initialize ste_opt_lineno in PySymtable_New(); while there are no current cases where it is referenced unless it has already been assigned to, there is no harm in initializing it.
* ste_repr(): Conversion of sprintf() to PyOS_snprintf() for bufferBarry Warsaw2001-11-281-4/+5
| | | | overrun avoidance.
* Add optional docstrings to member descriptors. For backwardsGuido van Rossum2001-09-201-9/+20
| | | | | | | | | | | | | | | 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.
* Merging the gen-branch into the main line, at Guido's direction. Yay!Tim Peters2001-06-181-0/+1
| | | | | Bugfix candidate in inspect.py: it was referencing "self" outside of a method.
* Improved __future__ parser; still more to doJeremy Hylton2001-02-271-0/+1
| | | | | | | | | | | | | | | Makefile.pre.in: add target future.o Include/compile.h: define PyFutureFeaters and PyNode_Future() add c_future slot to struct compiling Include/symtable.h: add st_future slot to struct symtable Python/future.c: implementation of PyNode_Future() Python/compile.c: use PyNode_Future() for nested_scopes support Python/symtable.c: include compile.h to pick up PyFutureFeatures decl
* Preliminary support for future nested scopesJeremy Hylton2001-02-271-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | compile.h: #define NESTED_SCOPES_DEFAULT 0 for Python 2.1 __future__ feature name: "nested_scopes" symtable.h: Add st_nested_scopes slot. Define flags to track exec and import star. Lib/test/test_scope.py: requires nested scopes compile.c: Fiddle with error messages. Reverse the sense of ste_optimized flag on PySymtableEntryObjects. If it is true, there is an optimization conflict. Modify get_ref_type to respect st_nested_scopes flags. Refactor symtable_load_symbols() into several smaller functions, which use struct symbol_info to share variables. In new function symtable_update_flags(), raise an error or warning for import * or bare exec that conflicts with nested scopes. Also, modify handle for free variables to respect st_nested_scopes flag. In symtable_init() assign st_nested_scopes flag to NESTED_SCOPES_DEFAULT (defined in compile.h). Add preliminary and often incorrect implementation of symtable_check_future(). Add symtable_lookup() helper for future use.
* Fix for bug 133489: compiler leaks memoryJeremy Hylton2001-02-231-3/+5
| | | | | | | | | | | | | | | | | | | | Two different but related problems: 1. PySymtable_Free() must explicitly DECREF(st->st_cur), which should always point to the global symtable entry. This entry is setup by the first enter_scope() call, but there is never a corresponding exit_scope() call. Since each entry has a reference to scopes defined within it, the missing DECREF caused all symtable entries to be leaked. 2. The leak here masked a separate problem with PySymtableEntry_New(). When the requested entry was found in st->st_symbols, the entry was returned without doing an INCREF. And problem c) The ste_children slot was getting two copies of each child entry, because it was populating the slot on the first and second passes. Now only populate on the first pass.
* Relax the rules for using 'from ... import *' and exec in the presenceJeremy Hylton2001-02-091-0/+147
of nested functions. Either is allowed in a function if it contains no defs or lambdas or the defs and lambdas it contains have no free variables. If a function is itself nested and has free variables, either is illegal. Revise the symtable to use a PySymtableEntryObject, which holds all the revelent information for a scope, rather than using a bunch of st_cur_XXX pointers in the symtable struct. The changes simplify the internal management of the current symtable scope and of the stack. Added new C source file: Python/symtable.c. (Does the Windows build process need to be updated?) As part of these changes, the initial _symtable module interface introduced in 2.1a2 is replaced. A dictionary of PySymtableEntryObjects are returned.