[pypy-svn] r16519 - in pypy/dist/pypy/interpreter: pyparser stablecompiler test
arigo at codespeak.net
arigo at codespeak.net
Thu Aug 25 18:23:03 CEST 2005
Author: arigo
Date: Thu Aug 25 18:23:01 2005
New Revision: 16519
Modified:
pypy/dist/pypy/interpreter/pyparser/pythonutil.py
pypy/dist/pypy/interpreter/stablecompiler/transformer.py
pypy/dist/pypy/interpreter/test/test_compiler.py
Log:
* in the pyparser, use the single_input grammar target.
* in the st->ast transformer, produce the correct ast for single_input.
* enable the now-passing test_toplevel_docstring().
* this introduces some failures in test_astbuilder because it is comparing
its own output with the above-mentioned st->ast transformer, so it is
mimicking the bug. Will try to fix astbuilder.py...
Modified: pypy/dist/pypy/interpreter/pyparser/pythonutil.py
==============================================================================
--- pypy/dist/pypy/interpreter/pyparser/pythonutil.py (original)
+++ pypy/dist/pypy/interpreter/pyparser/pythonutil.py Thu Aug 25 18:23:01 2005
@@ -12,7 +12,7 @@
TARGET_DICT = {
'exec' : "file_input",
'eval' : "eval_input",
- 'single' : "file_input",
+ 'single' : "single_input",
}
## convenience functions around CPython's parser functions
Modified: pypy/dist/pypy/interpreter/stablecompiler/transformer.py
==============================================================================
--- pypy/dist/pypy/interpreter/stablecompiler/transformer.py (original)
+++ pypy/dist/pypy/interpreter/stablecompiler/transformer.py Thu Aug 25 18:23:01 2005
@@ -175,13 +175,13 @@
raise WalkerError, ('unexpected node type', n)
def single_input(self, node):
- ### do we want to do anything about being "interactive" ?
# NEWLINE | simple_stmt | compound_stmt NEWLINE
n = node[0][0]
if n != token.NEWLINE:
- return self.com_stmt(node[0])
-
- return Pass()
+ stmt = self.com_stmt(node[0])
+ else:
+ stmt = Pass()
+ return Module(None, stmt)
def file_input(self, nodelist):
doc = self.get_docstring(nodelist, symbol.file_input)
Modified: pypy/dist/pypy/interpreter/test/test_compiler.py
==============================================================================
--- pypy/dist/pypy/interpreter/test/test_compiler.py (original)
+++ pypy/dist/pypy/interpreter/test/test_compiler.py Thu Aug 25 18:23:01 2005
@@ -116,15 +116,15 @@
ex = e.value
assert ex.match(self.space, self.space.w_SyntaxError)
- def INPROGRESS_test_toplevel_docstring(self):
+ def test_toplevel_docstring(self):
space = self.space
- import pdb; pdb.set_trace()
code = self.compiler.compile('"spam"; "bar"; x=5', '<hello>', 'exec', 0)
- assert space.eq_w(code.co_consts_w[0], space.wrap("spam"))
w_locals = space.newdict([])
code.exec_code(space, space.newdict([]), w_locals)
w_x = space.getitem(w_locals, space.wrap('x'))
assert space.eq_w(w_x, space.wrap(5))
+ w_doc = space.getitem(w_locals, space.wrap('__doc__'))
+ assert space.eq_w(w_doc, space.wrap("spam"))
#
code = self.compiler.compile('"spam"; "bar"; x=5',
'<hello>', 'single', 0)
@@ -132,6 +132,8 @@
code.exec_code(space, space.newdict([]), w_locals)
w_x = space.getitem(w_locals, space.wrap('x'))
assert space.eq_w(w_x, space.wrap(5))
+ w_doc = space.call_method(w_locals, 'get', space.wrap('__doc__'))
+ assert space.is_w(w_doc, space.w_None) # "spam" is not a docstring
def test_barestringstmts_disappear(self):
space = self.space
More information about the Pypy-commit
mailing list