summaryrefslogtreecommitdiffstats
path: root/Python/compile.c
Commit message (Collapse)AuthorAgeFilesLines
* SF #660455 : patch by NNorwitz.Guido van Rossum2003-02-121-1/+2
| | | | | | | | | | "Unsigned" (i.e., positive-looking, but really negative) hex/oct constants with a leading minus sign are once again properly negated. The micro-optimization for negated numeric constants did the wrong thing for such hex/oct constants. The patch avoids the optimization for all hex/oct constants. This needs to be backported to Python 2.2!
* patch #683515: "Add unicode support to compile(), eval() and exec"Just van Rossum2003-02-101-1/+3
| | | | Incorporated nnorwitz's comment re. Py__USING_UNICODE.
* Small function call optimization and special build option for call stats.Jeremy Hylton2003-02-051-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | -DCALL_PROFILE: Count the number of function calls executed. When this symbol is defined, the ceval mainloop and helper functions count the number of function calls made. It keeps detailed statistics about what kind of object was called and whether the call hit any of the special fast paths in the code. Optimization: When we take the fast_function() path, which seems to be taken for most function calls, and there is minimal frame setup to do, avoid call PyEval_EvalCodeEx(). The eval code ex function does a lot of work to handle keywords args and star args, free variables, generators, etc. The inlined version simply allocates the frame and copies the arguments values into the frame. The optimization gets a little help from compile.c which adds a CO_NOFREE flag to code objects that don't have free variables or cell variables. This change allows fast_function() to get into the fast path with fewer tests. I measure a couple of percent speedup in pystone with this change, but there's surely more that can be done.
* A. Lloyd Flanagan pointed out a spelling error on c.l.py.Michael W. Hudson2003-01-161-1/+1
|
* SF patch [ 597919 ] compiler package and SET_LINENOJeremy Hylton2002-12-311-0/+3
| | | | | | | | | | | | | | | | | A variety of changes from Michael Hudson to get the compiler working with 2.3. The primary change is the handling of SET_LINENO: # The set_lineno() function and the explicit emit() calls for # SET_LINENO below are only used to generate the line number table. # As of Python 2.3, the interpreter does not have a SET_LINENO # instruction. pyassem treats SET_LINENO opcodes as a special case. A few other small changes: - Remove unused code from pycodegen and pyassem. - Fix error handling in parsermodule. When PyParser_SimplerParseString() fails, it sets an exception with detailed info. The parsermodule was clobbering that exception and replacing it was a generic "could not parse string" exception. Keep the original exception.
* Oops. Roll back that last change. It wasn't ready for release. :-(Guido van Rossum2002-12-231-96/+30
|
* Add warning for assignment to None, True and False. This is patchGuido van Rossum2002-12-231-30/+96
| | | | 549213 by Jeremy (checking in for him since he's away and busy).
* SF # 654960, remove unnecessary static variableNeal Norwitz2002-12-181-9/+3
| | | | | The static variable (implicit) was not necessary. The c_globals can be None or True now.
* Fixing bugGustavo Niemeyer2002-12-161-2/+2
| | | | | | | | | | | | | | | | | | [#448679] Left to right * Python/compile.c (com_dictmaker): Reordered evaluation of dictionaries to follow strict LTR evaluation. * Lib/compiler/pycodegen.py (CodeGenerator.visitDict): Reordered evaluation of dictionaries to follow strict LTR evaluation. * Doc/ref/ref5.tex Documented the general LTR evaluation order idea. * Misc/NEWS Documented change in evaluation order of dictionaries.
* Constify filenames and scripts. Fixes #651362.Martin v. Löwis2002-12-111-11/+13
|
* Move three variables that are only used inside an if block into the block,Walter Dörwald2002-11-211-3/+3
| | | | so the --disable-unicode build doesn't complain about unused variables.
* Clamp code objects' tp_compare result to [-1, 1].Michael W. Hudson2002-10-031-3/+3
| | | | Bugfix candidate.
* Further SET_LINENO reomval fixes. See comments in patch #587933.Michael W. Hudson2002-08-301-3/+12
| | | | | | | | | | Use a slightly different strategy to determine when not to call the line trace function. This removes the need for the RETURN_NONE opcode, so that's gone again. Update docs and comments to match. Thanks to Neal and Armin! Also add a test suite. This should have come with the original patch...
* Add warnings for arguments named None. All set. (I could add aGuido van Rossum2002-08-161-1/+9
| | | | | | warning for 'global None', but that's either accompanied by an assignment to None, which will trigger a warning, or not, in which case it's harmless. :-)
* Add warning for None used as keyword argument name in function call.Guido van Rossum2002-08-161-0/+1
| | | | | Still to do: function definition arguments (including *None and **None).
* Add warnings for assignment or deletion of variables and attributesGuido van Rossum2002-08-161-0/+27
| | | | | named 'None'. Still to do: function definition parameter lists, and function call keyword arguments.
* Minor cleanup of parsename() and parsestr(): the 'struct compiling *'Guido van Rossum2002-08-161-13/+13
| | | | | | argument should be called 'c', like everywhere else. Renamed a complex variable 'c' to 'z' and moved it inside the only scope where it's used.
* This is my patchMichael W. Hudson2002-08-151-29/+16
| | | | | | | | [ 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.
* Added a FutureWarning for constructs that will change semantically inBarry Warsaw2002-08-141-1/+1
| | | | | the future. Changed PEP 237 hex constant warnings from DeprecationWarning to FutureWarning. Updated the documentation.
* Patch #505705: Remove eval in pickle and cPickle.Martin v. Löwis2002-08-141-98/+5
|
* Use PyErr_WarnExplicit() to warn about hex/oct constants, so theGuido van Rossum2002-08-121-4/+9
| | | | correct filename and line number are reported.
* Reset errno to zero after calling PyErr_Warn(). It can potentially doGuido van Rossum2002-08-111-0/+1
| | | | | a lot of work, including I/O (e.g. to import warnings.py), which might affect errno.
* Implement stage B0 of PEP 237: add warnings for operations thatGuido van Rossum2002-08-111-1/+9
| | | | | | | | | | currently return inconsistent results for ints and longs; in particular: hex/oct/%u/%o/%x/%X of negative short ints, and x<<n that either loses bits or changes sign. (No warnings for repr() of a long, though that will also change to lose the trailing 'L' eventually.) This introduces some warnings in the test suite; I'll take care of those later.
* Use Py_FatalError instead of abort.Martin v. Löwis2002-08-071-2/+3
|
* Fix PEP 263 code --without-unicode. Fixes #591943.Martin v. Löwis2002-08-071-0/+10
|
* Patch #534304: Implement phase 1 of PEP 263.Martin v. Löwis2002-08-041-10/+113
|
* SF patch #578297:Andrew MacIntyre2002-08-041-7/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Change the parser and compiler to use PyMalloc. Only the files implementing processes that will request memory allocations small enough for PyMalloc to be a win have been changed, which are:- - Python/compile.c - Parser/acceler.c - Parser/node.c - Parser/parsetok.c This augments the aggressive overallocation strategy implemented by Tim Peters in PyNode_AddChild() [Parser/node.c], in reducing the impact of platform malloc()/realloc()/free() corner case behaviour. Such corner cases are known to be triggered by test_longexp and test_import. Jeremy Hylton, in accepting this patch, recommended this as a bugfix candidate for 2.2. While the changes to Python/compile.c and Parser/node.c backport easily (and could go in), the changes to Parser/acceler.c and Parser/parsetok.c require other not insignificant changes as a result of the differences in the memory APIs between 2.3 and 2.2, which I'm not in a position to work through at the moment. This is a pity, as the Parser/parsetok.c changes are the most important after the Parser/node.c changes, due to the size of the memory requests involved and their frequency.
* remove spurious SET_LINENO from com_list_for and com_list_if. All they doSkip Montanaro2002-07-251-2/+0
| | | | | | | | | | | is slow things down unnecessarily and make tracing much more verbose. Something like def f(n): return [i for i in range(n) if i%2] should have at most two SET_LINENO instructions, not four. When tracing, the current line number should be printed once, not 2*n+1 times.
* SF 569257 -- Name mangle double underscored variable names in __slots__.Raymond Hettinger2002-06-201-6/+6
|
* SF patch 568629 by Oren Tirosh: types made callable.Guido van Rossum2002-06-141-2/+65
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | These built-in functions are replaced by their (now callable) type: slice() buffer() and these types can also be called (but have no built-in named function named after them) classobj (type name used to be "class") code function instance instancemethod (type name used to be "instance method") The module "new" has been replaced with a small backward compatibility placeholder in Python. A large portion of the patch simply removes the new module from various platform-specific build recipes. The following binary Mac project files still have references to it: Mac/Build/PythonCore.mcp Mac/Build/PythonStandSmall.mcp Mac/Build/PythonStandalone.mcp [I've tweaked the code layout and the doc strings here and there, and added a comment to types.py about StringTypes vs. basestring. --Guido]
* Fix SF bug [ 561825 ] Confusing error for "del f()"Jeremy Hylton2002-05-311-2/+6
| | | | In the error message, say del for del and assign for everything else.
* Accept u"..." literals even when Unicode is disabled. But theseGuido van Rossum2002-05-281-8/+13
| | | | | literals must not contain \u, \U or \N escapes. (XXX Should they also not contain non-ASCII characters?)
* Disambiguate the grammar for backtick.Guido van Rossum2002-05-241-0/+5
| | | | | | The old syntax suggested that a trailing comma was OK inside backticks, but in fact (due to ideosyncrasies of pgen) it was not. Fix the grammar to avoid the ambiguity. Fred: you may want to update the refman.
* If Py_OptimizeFlag is false then always evaluate assert conditions, don'tNeil Schemenauer2002-04-261-15/+7
| | | | test __debug__ at runtime. Closes SF patch #548833.
* Moving pymalloc along.Tim Peters2002-04-221-2/+2
| | | | | | | | | | | | | | | | | | + Redirect PyMem_{Del, DEL} to the object allocator's free() when pymalloc is enabled. Needed so old extensions can continue to mix PyObject_New with PyMem_DEL. + This implies that pgen needs to be able to see the PyObject_XYZ declarations too. pgenheaders.h now includes Python.h. An implication is that I expect obmalloc.o needs to get linked into pgen on non-Windows boxes. + When PYMALLOC_DEBUG is defined, *all* Py memory API functions now funnel through the debug allocator wrapper around pymalloc. This is the default in a debug build. + That caused compile.c to fail: it indirectly mixed PyMem_Malloc with raw platform free() in one place. This is verbotten.
* Patch #542659: Eliminate duplicate check for NULL of freevars/cellvars.Martin v. Löwis2002-04-141-4/+0
|
* Patch #50002: Display line information for bad \x escapes:Martin v. Löwis2002-03-031-14/+26
| | | | | | - recognize "SyntaxError"s by the print_file_and_line attribute. - add the syntaxerror attributes to all exceptions in compile.c. Fixes #221791
* Fix missing space between words. Bugfix candidate.Neal Norwitz2002-01-291-1/+1
|
* Fix spelling mistakes. Bugfix candidates.Neal Norwitz2002-01-291-1/+1
|
* A tentative fix for SF bug #503837 (Roeland Rengelink):Guido van Rossum2002-01-151-0/+3
| | | | | | | | | | | | | | | | type.__module__ problems (again?) This simply initializes the __module__ local in a class statement from the __name__ global. I'm not 100% sure that this is the correct fix, although it usually does the right thing. The problem is that if the class statement executes in a custom namespace, the __name__ global may be taken from __builtins__, in which case it would have the value __builtin__, or it may not exist at all (if the custom namespace also has a custom __builtins__), in which case the class statement will fail. Nevertheless, unless someone finds a better solution, this is a 2.2.1 bugfix too.
* Patch #494783: Rename cmp_op enumerators.Martin v. Löwis2002-01-011-14/+14
|
* Fix for SF bug [ #492403 ] exec() segfaults on closure's func_codeJeremy Hylton2001-12-131-3/+3
| | | | | | | | 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.
* SF bug #488687 reported by Neal NorwitzJeremy Hylton2001-12-041-1/+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.
* code_repr(), com_addop_varname(), com_list_comprehension(),Barry Warsaw2001-11-281-32/+42
| | | | | | | | com_arglist(), symtable_check_unoptimized(), symtable_params(), symtable_global(), symtable_list_comprehension(): Conversion of sprintf() to PyOS_snprintf() for buffer overrun avoidance.
* Fixes for possible buffer overflows in sprintf() usages.Marc-André Lemburg2001-11-281-1/+1
|
* Use PyObject_CheckReadBuffer().Jeremy Hylton2001-11-091-11/+2
|
* Fix SF buf #480096: Assign to __debug__ still allowedJeremy Hylton2001-11-091-2/+7
| | | | | | Easy enough to catch assignment in the compiler. The perverse user can still change the value of __debug__, but that may be the least he can do.
* Part of SF bug #478003 possible memory leaks in err handling.Tim Peters2001-11-041-1/+4
| | | | | PyNode_CompileSymtable: if symtable_init() fails, free the memory allocated for the PyFutureFeatures struct.
* Fix for SF bug [ #471928 ] global made w/nested list comprehensionsJeremy Hylton2001-10-181-19/+51
| | | | | | | | | | | | | | | | | | | | | | | | | | | | The symbol table pass didn't have an explicit case for the list_iter node which is used only for a nested list comprehension. As a result, the target of the list comprehension was treated as a use instead of an assignment. Fix is to add a case to symtable_node() to handle list_iter. Also, rework and document a couple of the subtler implementation issues in the symbol table pass. The symtable_node() switch statement depends on falling through the last several cases, in order to handle some of the more complicated nodes like atom. Add a comment explaining the behavior before the first fall through case. Add a comment /* fall through */ at the end of case so that it is explicitly marked as such. Move the for_stmt case out of the fall through logic, which simplifies both for_stmt and default. (The default used the local variable start to skip the first three nodes of a for_stmt when it fell through.) Rename the flag argument to symtable_assign() to def_flag and add a comment explaining its use: The third argument to symatble_assign() is a flag to be passed to symtable_add_def() if it is eventually called. The flag is useful to specify the particular type of assignment that should be recorded, e.g. an assignment caused by import.
* Fix computation of stack depth for classdef and closures.Jeremy Hylton2001-10-171-44/+44
| | | | | | | | | | | | | | | | | | | | | | Also minor tweaks to internal routines. Use PyCF_MASK instead of explicit list of flags. For the MAKE_CLOSURE opcode, the number of items popped off the stack depends on both the oparg and the number of free variables for the code object. Fix the code so it accounts for the free variables. In com_classdef(), record an extra pop to account for the STORE call after the BUILD_CLASS. Get rid of some commented out debugging code in com_push() and com_pop(). Factor string resize logic into helper routine com_check_size(). In com_addbyte(), remove redudant if statement after assert. (They test the same condition.) In several routines, use string macros instead of string functions.