Georg Brandl
944f684ce6
Allow multiple context managers in one with statement, as proposed
...
in http://codereview.appspot.com/53094 and accepted by Guido.
The construct is transformed into multiple With AST nodes so that
there should be no problems with the semantics.
2009-05-25 21:02:56 +00:00
Jeffrey Yasskin
68d6852006
Backport r69961 to trunk, replacing JUMP_IF_{TRUE,FALSE} with
...
POP_JUMP_IF_{TRUE,FALSE} and JUMP_IF_{TRUE,FALSE}_OR_POP. This avoids executing
a POP_TOP on each conditional and sometimes allows the peephole optimizer to
skip a JUMP_ABSOLUTE entirely. It speeds up list comprehensions significantly.
2009-02-28 19:03:21 +00:00
Neil Schemenauer
92c3b2190b
Issue #999042 : The Python compiler now handles explict global statements
...
correctly (should be assigned using STORE_GLOBAL opcode). This was done by
having the system table differentiate between explict and implicit globals.
2009-02-07 00:54:41 +00:00
Neil Schemenauer
98c3b85bc4
Make names generated for 'with' variables match the built-in compiler.
2009-02-07 00:13:39 +00:00
Neil Schemenauer
4db626f95d
Overhaul Lib/compiler block ordering. The previous code was filled with
...
hacks. The new code is based on issue #2472 posted by Antoine Pitrou. I
did some further cleanups of the pyassem code and optimized the block
ordering pass.
2009-02-06 21:08:52 +00:00
Antoine Pitrou
d0c3515bc5
Issue #2183 : Simplify and optimize bytecode for list comprehensions.
2008-12-17 00:38:28 +00:00
Georg Brandl
2d2fe572a4
#4578 : fix has_key() usage in compiler package.
2008-12-15 08:58:59 +00:00
Amaury Forgeot d'Arc
67f24f1ed6
follow-up of issue3473: update the compiler package to recognize the new syntax.
2008-08-20 00:08:47 +00:00
Brett Cannon
6192df10b6
Deprecate the compiler package for removal in 3.0.
2008-05-10 02:58:26 +00:00
Neal Norwitz
311d071541
Fix test_compiler after adding unicode_literals
2008-03-27 05:02:57 +00:00
Eric Smith
5d5c63f462
Fixed compiler module so __future__ print_function is compilable.
2008-03-19 02:11:30 +00:00
Nick Coghlan
7af53be66f
Speed up with statements by storing the __exit__ method on the stack instead of in a temp variable (bumps the magic number for pyc files)
2008-03-07 14:13:28 +00:00
Facundo Batista
4219da4bd0
Issue 2117. Update compiler module to handle class decorators.
...
Thanks Thomas Herve
2008-02-25 18:06:00 +00:00
Christian Heimes
c5f05e45cf
Patch #2167 from calvin: Remove unused imports
2008-02-23 17:40:11 +00:00
Christian Heimes
c756d00cf2
Replaced import of the 'new' module with 'types' module and added a deprecation warning to the 'new' module.
2007-11-27 21:34:01 +00:00
Collin Winter
6290305e67
Backport PEP 3110's new 'except' syntax to 2.6.
2007-05-18 23:11:24 +00:00
Georg Brandl
ab49684f55
Patch #1638243 : the compiler package is now able to correctly compile
...
a with statement; previously, executing code containing a with statement
compiled by the compiler package crashed the interpreter.
2007-01-27 17:43:02 +00:00
Georg Brandl
fe9c71bcd3
Remove trailing comma.
2006-10-29 09:01:01 +00:00
Georg Brandl
5addf70078
Bug #1586448 : the compiler module now emits the same bytecode for
...
list comprehensions as the builtin compiler, using the LIST_APPEND
opcode.
2006-10-29 08:53:06 +00:00
Neil Schemenauer
4c6b0d5bec
Fix a bug in the ``compiler`` package that caused invalid code to be
...
generated for generator expressions.
2006-08-16 23:38:05 +00:00
Neil Schemenauer
06ded09d40
Fix the 'compiler' package to generate correct code for MAKE_CLOSURE.
...
In the 2.5 development cycle, MAKE_CLOSURE as changed to take free
variables as a tuple rather than as individual items on the stack.
Closes patch #1534084 .
2006-08-04 16:20:30 +00:00
Georg Brandl
afcd838f1f
Revert rev 42617, it was introduced to work around bug #1441397 .
...
test_compiler now passes again.
2006-07-29 10:25:46 +00:00
Georg Brandl
edd9b0dfb3
Bug #1441397 : The compiler module now recognizes module and function
...
docstrings correctly as it did in Python 2.4.
2006-07-29 09:33:26 +00:00
Tim Peters
3249d00f4d
Whitespace normalization.
2006-06-27 11:52:49 +00:00
Georg Brandl
c3f49ca558
Set lineno correctly on list, tuple and dict literals.
2006-06-22 14:46:17 +00:00
Georg Brandl
ad29e637d8
fix [ 1509132 ] compiler module builds incorrect AST for TryExceptFinally
2006-06-21 17:45:17 +00:00
Neal Norwitz
6aaccc6b55
Fix errors found by pychecker
2006-06-11 08:35:14 +00:00
Georg Brandl
1bb6230930
Bug #1385040 : don't allow "def foo(a=1, b): pass" in the compiler package.
2006-05-03 18:18:32 +00:00
Guido van Rossum
da5b701aee
Get rid of __context__, per the latest changes to PEP 343 and python-dev
...
discussion.
There are two places of documentation that still mention __context__:
Doc/lib/libstdtypes.tex -- I wasn't quite sure how to rewrite that without
spending a whole lot of time thinking about it; and whatsnew, which Andrew
usually likes to change himself.
2006-05-02 19:47:52 +00:00
Neal Norwitz
b902f4e401
Use absolute imports
2006-04-03 04:45:34 +00:00
Nick Coghlan
cb35b95f86
Teach the compiler module about augmented assignment to tuple subscripts
2006-03-14 13:21:14 +00:00
Guido van Rossum
f669436189
Um, I thought I'd already checked this in.
...
Anyway, this is the changes to the with-statement
so that __exit__ must return a true value in order
for a pending exception to be ignored.
The PEP (343) is already updated.
2006-03-10 02:28:35 +00:00
Tim Peters
39e11fb104
Whitespace normalization.
2006-03-04 02:43:44 +00:00
Neal Norwitz
10be2ea85d
SF bug 1442442: LIST_APPEND optimization got lost in the AST merge.
...
Add it back.
2006-03-03 20:29:11 +00:00
Neal Norwitz
d4e3035701
Fix compiler breakage related to absolute imports
2006-03-03 20:21:48 +00:00
Neal Norwitz
eaed39f303
Hopefully this removes all vestiges of CO_GENERATOR_ALLOWED that can
...
be removed in 2.x.
2006-03-03 19:12:58 +00:00
Thomas Wouters
fa0cf4f3ae
Add support for absolute/relative imports and if/else expressions:
...
- regenerate ast.py
- add future flags for absolute-import and with-statement so they
(hopefully) properly get set in code-object flags
- try out if/else expressions in actual code for the hell of it.
Seems to generate the same kind of bytecode as the normal compiler.
2006-03-03 18:16:20 +00:00
Guido van Rossum
5bde08dba3
Fix failure of test_compiler.py when compiling test_contextlib.py.
...
The culprit was an expression-less yield -- the first apparently in
the standard library. I added a unit test for this.
Also removed the hack to force compilation of test_with.py.
2006-03-02 04:24:01 +00:00
Thomas Wouters
34aa7ba114
from __future__ import with_statement addon for 'with', mostly written by
...
Neal.
2006-02-28 19:02:24 +00:00
Tim Peters
710ab3b5f8
Whitespace normalization.
2006-02-28 18:30:36 +00:00
Guido van Rossum
baf3eb2410
Forgot to explain the effect of the new opcode.
...
Sigh -- we really should have one place for all opcode metadata.
2006-02-28 00:40:16 +00:00
Guido van Rossum
7ad94f011e
Update the compiler package to compile the with-statement.
...
Jeremy, please review!
2006-02-28 00:32:16 +00:00
Guido van Rossum
c2e20744b2
PEP 343 -- the with-statement.
...
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).
2006-02-27 22:32:47 +00:00
Martin v. Löwis
59977a677c
Make or_test similar to test, not testlist.
2006-02-27 19:57:01 +00:00
Martin v. Löwis
415ed937c2
Skip over doc strings.
2006-02-27 19:56:30 +00:00
Martin v. Löwis
16c7f71380
Handle testlist_safe and or_test like testlist.
2006-02-27 16:11:03 +00:00
Martin v. Löwis
49a1302952
Alias non-terminals introduced for backwards compatibility.
2006-02-27 16:03:39 +00:00
Neal Norwitz
212a575242
Remove unused _callers member. No need for types, use isinstance
2005-11-25 03:19:29 +00:00
Neal Norwitz
ef260c0803
Stop looping to do nothing, just pass.
2005-11-25 03:18:58 +00:00
Neal Norwitz
d752f7d8e8
No need for types, use isinstance
2005-11-25 03:17:59 +00:00