summaryrefslogtreecommitdiffstats
path: root/Python/compile.c
Commit message (Collapse)AuthorAgeFilesLines
* - Removed FutureWarnings related to hex/oct literals and conversionsGuido van Rossum2003-11-291-13/+1
| | | | | | | | | | and left shifts. (Thanks to Kalle Svensson for SF patch 849227.) This addresses most of the remaining semantic changes promised by PEP 237, except for repr() of a long, which still shows the trailing 'L'. The PEP appears to promise warnings for operations that changed semantics compared to Python 2.3, but this is not implemented; we've suffered through enough warnings related to hex/oct literals and I think it's best to be silent now.
* Patch #792869: Clarify error message for parameters declared global,Martin v. Löwis2003-10-181-4/+3
| | | | rename LOCAL_GLOBAL to PARAM_GLOBAL.
* Simplify and speedup uses of Py_BuildValue():Raymond Hettinger2003-10-121-2/+2
| | | | | | * Py_BuildValue("(OOO)",a,b,c) --> PyTuple_Pack(3,a,b,c) * Py_BuildValue("()",a) --> PyTuple_New(0) * Py_BuildValue("O", a) --> Py_INCREF(a)
* Fix SF bug [ 808594 ] leak on lambda with duplicate arguments error.Jeremy Hylton2003-09-221-15/+16
| | | | | | | Refactor code so that one helper routine sets error location and increments st_errors. Bug fix candidate.
* Improve the leak fix so that PyTuple_New is only called when needed.Raymond Hettinger2003-09-161-9/+11
|
* Fix leak discovered in test_new by Michael Hudson.Raymond Hettinger2003-09-151-17/+14
| | | | Will backport to 2.3.1
* Fix for SF bug [ 784075 ] Fatal Python error: unknown scopeJeremy Hylton2003-08-281-4/+12
| | | | | Make sure the inner function is not compiled when there is a syntax error in the default arguments.
* SF patch 763201: handling of SyntaxErrors in symbol table buildJeremy Hylton2003-07-151-33/+47
| | | | | | | | | | | | | | Fixes for three related bugs, including errors that caused a script to be ignored without printing an error message. The key problem was a bad interaction between syntax warnings and syntax errors. If an exception was already set when a warning was issued, the warning could clobber the exception. The PyErr_Occurred() check in issue_warning() isn't entirely satisfying (the caller should know whether there was already an error), but a better solution isn't immediately obvious. Bug fix candidate.
* Removed bytecode transformation for sequence packing/unpacking.Raymond Hettinger2003-06-201-28/+0
| | | | | | | It depended on the previously removed basic block checker to prevent a jump into the middle of the transformed block. Clears SF 757818: tuple assignment -- SystemError: unknown opcode
* SF bug #644345, Poor error message for augmented assignNeal Norwitz2003-05-221-2/+2
| | | | Update error message. Hopefully this is clearer to some people.
* Use macro to get length of list.Jeremy Hylton2003-05-221-8/+2
| | | | Remove comment about how code used to work.
* Remove comment with very long lines that explained what the code usedJeremy Hylton2003-05-221-3/+3
| | | | | | | to do. XXX Please be careful when checking in patches to avoid checking in junk that explains what the patched code used to do.
* Fix for SF [ 734869 ] Lambda functions in list comprehensionsJeremy Hylton2003-05-211-14/+23
| | | | | | 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.
* cmp_type(): The grammar stopped allowing '=' as a comparison operatorTim Peters2003-05-121-3/+2
| | | | | about a decade ago. Put the code still allowing for it in cmp_type() out of its lonely misery.
* Patch #734231: Update RiscOS support. In particular, correctMartin v. Löwis2003-05-101-1/+1
| | | | riscospath.extsep, and use os.extsep throughout.
* Patch #708604: Check more function results. Will backport to 2.2.Martin v. Löwis2003-05-031-7/+37
|
* Use Tim's suggestion to fixMichael W. Hudson2003-04-291-1/+1
| | | | | | | | | [ 708901 ] Lineno calculation sometimes broken A one line patch to compile.c and a rather-more-than-one-line patch to test_dis. Hey ho. Possibly a backport candidate -- tho' lnotab is less used in 2.2...
* Revert the previous enhancement to the bytecode optimizer.Raymond Hettinger2003-04-241-83/+9
| | | | The additional code complexity and new NOP opcode were not worth it.
* Improved the bytecode optimizer.Raymond Hettinger2003-04-221-9/+83
| | | | | | | | | | | | | | * Can now test for basic blocks. * Optimize inverted comparisions. * Optimize unary_not followed by a conditional jump. * Added a new opcode, NOP, to keep code size constant. * Applied NOP to previous transformations where appropriate. Note, the NOP would not be necessary if other functions were added to re-target jump addresses and update the co_lnotab mapping. That would yield slightly faster and cleaner bytecode at the expense of optimizer simplicity and of keeping it decoupled from the line-numbering structure.
* Extend SF patch #707257: Improve code generationRaymond Hettinger2003-04-151-8/+20
| | | | | | to cover the case for: "x,y,z=1,2,3". Gives a 30% speed-up. Also, added FOR_ITER to the list of opcodes that can jump.
* Factored out test for absolute jumps.Raymond Hettinger2003-03-281-2/+3
|
* SF patch #707257: Improve code generationRaymond Hettinger2003-03-261-2/+94
| | | | | | | | | | Adds a single function to improve generated bytecode. Has a single line attachment point, so it is completely de-coupled from both the compiler and ceval.c. Makes three simple transforms that do not require a basic block analysis or re-ordering of code. Gives improved timings on pystone, pybench, and any code using either "while 1" or "x,y=y,x".
* symtable_cellvar_offsets(): This leaked references to little integersTim Peters2003-03-241-1/+5
| | | | | | in normal cases, and also in error cases. Bugfix candidate.
* 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.