summaryrefslogtreecommitdiffstats
path: root/Python/symtable.c
Commit message (Collapse)AuthorAgeFilesLines
* uhh PySTEntry->ste_unoptimized has to be exposed tooBenjamin Peterson2008-08-171-0/+1
|
* expose PySTEntry.nested so the symtable module will workBenjamin Peterson2008-08-171-0/+1
|
* PySTEntry's constructor is static; there's no point in a fancy API nameBenjamin Peterson2008-08-161-4/+4
|
* include filename and line number in SyntaxErrorBenjamin Peterson2008-08-161-0/+3
|
* This reverts r63675 based on the discussion in this thread:Gregory P. Smith2008-06-091-14/+14
| | | | | | | http://mail.python.org/pipermail/python-dev/2008-June/079988.html Python 2.6 should stick with PyString_* in its codebase. The PyBytes_* names in the spirit of 3.0 are available via a #define only. See the email thread.
* Renamed PyString to PyBytesChristian Heimes2008-05-261-14/+14
|
* Patch #2511: Give the "excepthandler" AST item proper attributes by making ↵Georg Brandl2008-03-301-5/+5
| | | | it a Sum.
* Handle memory allocation failure. Found by Adam OlsenNeal Norwitz2008-03-151-2/+3
|
* Patch #1759: Backport of PEP 3129 class decoratorsChristian Heimes2008-02-231-2/+4
| | | | with some help from Georg
* PEP 3123: Provide forward compatibility with Python 3.0, while keepingMartin v. Löwis2007-07-211-2/+1
| | | | | backwards compatibility. Add Py_Refcnt, Py_Type, Py_Size, and PyVarObject_HEAD_INIT.
* Handle PyString_FromInternedString() failing (unlikely, but possible).Neal Norwitz2006-08-191-9/+8
| | | | | | Klocwork #325 (I'm not backporting this, but if someone wants to, feel free.)
* Klocwork made another run and found a bunch more problems.Neal Norwitz2006-08-121-1/+6
| | | | | | | This is the first batch of fixes that should be easy to verify based on context. This fixes problem numbers: 220 (ast), 323-324 (symtable), 321-322 (structseq), 215 (array), 210 (hotshot), 182 (codecs), 209 (etree).
* Handle more mem alloc issues found with failmallocNeal Norwitz2006-07-231-0/+2
|
* Fix more memory allocation issues found with failmalloc.Neal Norwitz2006-07-221-1/+1
|
* Handle more memory allocation failures without crashing.Neal Norwitz2006-07-211-2/+10
|
* Patch #1346214: correctly optimize away "if 0"-style stmtsGeorg Brandl2006-06-041-1/+20
| | | | (thanks to Neal for review)
* Make symtable.c safe for C++ compilers. Changed macros in the same way asAnthony Baxter2006-04-121-11/+13
| | | | compile.c to add a cast.
* No need to export PySTEntry_New, it is only used in symtable.cNeal Norwitz2006-02-281-1/+2
|
* PEP 343 -- the with-statement.Guido van Rossum2006-02-271-14/+30
| | | | | | | | | | | | | This was started by Mike Bland and completed by Guido (with help from Neal). This still needs a __future__ statement added; Thomas is working on Michael's patch for that aspect. There's a small amount of code cleanup and refactoring in ast.c, compile.c and ceval.c (I fixed the lltrace behavior when EXT_POP is used -- however I had to make lltrace a static global).
* PEP 308 implementation, including minor refdocs and some testcases. ItThomas Wouters2006-02-271-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | breaks the parser module, because it adds the if/else construct as well as two new grammar rules for backward compatibility. If no one else fixes parsermodule, I guess I'll go ahead and fix it later this week. The TeX code was checked with texcheck.py, but not rendered. There is actually a slight incompatibility: >>> (x for x in lambda:0) Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: iteration over non-sequence changes into >>> (x for x in lambda: 0) File "<stdin>", line 1 (x for x in lambda: 0) ^ SyntaxError: invalid syntax Since there's no way the former version can be useful, it's probably a bugfix ;)
* Use Py_ssize_t to count theMartin v. Löwis2006-02-161-1/+1
|
* Merge ssize_t branch.Martin v. Löwis2006-02-151-3/+5
|
* analyze_cells(): This no longer compiled under VC 7.1.Tim Peters2006-01-081-1/+2
| | | | Move declaration of local `flags` to top of block.
* Fix icc warnings: conversion from "long" to "int" may lose significant bitsNeal Norwitz2006-01-081-10/+11
|
* Fix icc warnings: shadowing local variable (i) and complex is set but not ↵Neal Norwitz2006-01-071-3/+2
| | | | used, so remove
* Bug #889500, fix line number on SyntaxWarning for global declarations.Neal Norwitz2005-12-191-7/+10
|
* Fix a few more ref leaks. Backport candidateNeal Norwitz2005-11-241-1/+3
|
* Last batch of ref leaks in new AST code.Neal Norwitz2005-11-191-4/+8
| | | | | | Also converted a bunch of assert(0) to SystemError's. There are still printfs, etc that need to be cleaned up.
* Bring handling of genexpr in line with other anonymous scope namesNick Coghlan2005-11-161-4/+3
|
* Fix a lot of memory and ref leaks in error paths.Neal Norwitz2005-11-131-33/+75
| | | | | | (Call symtable_exit_block or compiler_exit_scope as appropriate) Use PyMem_Free on c_future since it was allocated with PyMem_Malloc
* Do not pollute name block_ty, prefix with _Py_Neal Norwitz2005-10-241-3/+3
|
* Fix check_unoptimized() function. The only optimized namespaces areNeil Schemenauer2005-10-231-1/+1
| | | | | in function blocks. This elimiates spurious warnings about "import *" and related statements at the class level.
* Fix private name mangling. The symtable also must do mangles so thatNeil Schemenauer2005-10-231-14/+30
| | | | the scope of names can be correctly determined.
* 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
* ANSI-C-ify the placement of local var declarations.Armin Rigo2005-10-211-2/+4
|
* Merge ast-branch to headJeremy Hylton2005-10-201-63/+1178
| | | | | | | | | | 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 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.