[pypy-svn] r45068 - in pypy/dist/pypy/interpreter: . test
justas at codespeak.net
justas at codespeak.net
Sat Jul 14 13:52:52 CEST 2007
Author: justas
Date: Sat Jul 14 13:52:50 2007
New Revision: 45068
Modified:
pypy/dist/pypy/interpreter/pycompiler.py
pypy/dist/pypy/interpreter/test/test_compiler.py
pypy/dist/pypy/interpreter/test/test_syntax.py
Log:
(Arlo, Justas)
Ate trailing whitespace
Modified: pypy/dist/pypy/interpreter/pycompiler.py
==============================================================================
--- pypy/dist/pypy/interpreter/pycompiler.py (original)
+++ pypy/dist/pypy/interpreter/pycompiler.py Sat Jul 14 13:52:50 2007
@@ -148,42 +148,42 @@
def _warn_explicit(self, message, category, filename, lineno,
module=None, registry=None):
if hasattr(category, '__bases__') and \
- issubclass(category, SyntaxWarning):
+ issubclass(category, SyntaxWarning):
assert isinstance(message, str)
space = self.space
w_mod = space.sys.getmodule('warnings')
- if w_mod is not None:
- w_dict = w_mod.getdict()
- w_reg = space.call_method(w_dict, 'setdefault',
- space.wrap("__warningregistry__"),
+ if w_mod is not None:
+ w_dict = w_mod.getdict()
+ w_reg = space.call_method(w_dict, 'setdefault',
+ space.wrap("__warningregistry__"),
space.newdict())
- try:
- space.call_method(w_mod, 'warn_explicit',
- space.wrap(message),
- space.w_SyntaxWarning,
- space.wrap(filename),
- space.wrap(lineno),
- space.w_None,
- space.w_None)
- except OperationError, e:
- if e.match(space, space.w_SyntaxWarning):
+ try:
+ space.call_method(w_mod, 'warn_explicit',
+ space.wrap(message),
+ space.w_SyntaxWarning,
+ space.wrap(filename),
+ space.wrap(lineno),
+ space.w_None,
+ space.w_None)
+ except OperationError, e:
+ if e.match(space, space.w_SyntaxWarning):
raise OperationError(
- space.w_SyntaxError,
+ space.w_SyntaxError,
space.wrap(message))
- raise
+ raise
def setup_warn_explicit(self, warnings):
"""
- this is a hack until we have our own parsing/compiling
- in place: we bridge certain warnings to the applevel
+ this is a hack until we have our own parsing/compiling
+ in place: we bridge certain warnings to the applevel
warnings module to let it decide what to do with
- a syntax warning ...
- """
+ a syntax warning ...
+ """
# there is a hack to make the flow space happy:
# 'warnings' should not look like a Constant
- old_warn_explicit = warnings.warn_explicit
+ old_warn_explicit = warnings.warn_explicit
warnings.warn_explicit = self._warn_explicit
- return old_warn_explicit
+ return old_warn_explicit
def restore_warn_explicit(self, warnings, old_warn_explicit):
warnings.warn_explicit = old_warn_explicit
@@ -204,7 +204,7 @@
PyCodeCompiler.__init__(self, space)
self.parser = PYTHON_PARSER
self.additional_rules = {}
-
+
def compile(self, source, filename, mode, flags):
from pyparser.error import SyntaxError
@@ -285,7 +285,7 @@
break
space.default_compiler.additional_rules = buildfuncs
space.default_compiler.parser.insert_rule(rule)
-
+
# XXX cyclic import
#from pypy.interpreter.baseobjspace import ObjSpace
#insert_grammar_rule.unwrap_spec = [ObjSpace, str, dict]
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 Sat Jul 14 13:52:50 2007
@@ -76,14 +76,14 @@
assert space.int_w(w_a) == 1
def test_scope_unoptimized_clash1(self):
- # mostly taken from test_scope.py
+ # mostly taken from test_scope.py
e = py.test.raises(OperationError, self.compiler.compile, """if 1:
def unoptimized_clash1(strip):
def f(s):
from string import *
return strip(s) # ambiguity: free or local
return f""", '', 'exec', 0)
- ex = e.value
+ ex = e.value
assert ex.match(self.space, self.space.w_SyntaxError)
def test_scope_unoptimized_clash1_b(self):
@@ -91,14 +91,14 @@
# by the interpreter so a SyntaxError is not required, but
# let's give one anyway for "compatibility"...
- # mostly taken from test_scope.py
+ # mostly taken from test_scope.py
e = py.test.raises(OperationError, self.compiler.compile, """if 1:
def unoptimized_clash1(strip):
def f():
from string import *
return s # ambiguity: free or local (? no, global or local)
return f""", '', 'exec', 0)
- ex = e.value
+ ex = e.value
assert ex.match(self.space, self.space.w_SyntaxError)
def test_scope_exec_in_nested(self):
@@ -108,7 +108,7 @@
exec "z=3"
return x
return f""", '', 'exec', 0)
- ex = e.value
+ ex = e.value
assert ex.match(self.space, self.space.w_SyntaxError)
def test_scope_exec_with_nested_free(self):
@@ -118,17 +118,17 @@
def f():
return x
return f""", '', 'exec', 0)
- ex = e.value
+ ex = e.value
assert ex.match(self.space, self.space.w_SyntaxError)
def test_scope_importstar_in_nested(self):
e = py.test.raises(OperationError, self.compiler.compile, """if 1:
def unoptimized_clash1(x):
def f():
- from string import *
+ from string import *
return x
return f""", '', 'exec', 0)
- ex = e.value
+ ex = e.value
assert ex.match(self.space, self.space.w_SyntaxError)
def test_scope_importstar_with_nested_free(self):
@@ -138,7 +138,7 @@
def f(s):
return strip(s)
return f""", '', 'exec', 0)
- ex = e.value
+ ex = e.value
assert ex.match(self.space, self.space.w_SyntaxError)
def test_toplevel_docstring(self):
@@ -209,7 +209,7 @@
ex = e.value
ex.normalize_exception(self.space)
assert ex.match(self.space, self.space.w_SyntaxError)
-
+
def test_debug_assignment(self):
code = '__debug__ = 1'
e = py.test.raises(OperationError, self.compiler.compile, code, '', 'single', 0)
@@ -302,7 +302,7 @@
w_filterwarnings = space.getattr(w_mod, space.wrap('filterwarnings'))
filter_arg = Arguments(space, [ space.wrap('error') ],
dict(module=space.wrap('<tmp>')))
-
+
for code in ('''
def wrong1():
a = 1
@@ -323,7 +323,7 @@
space.call_args(w_filterwarnings, filter_arg)
e = py.test.raises(OperationError, self.compiler.compile,
code, '<tmp>', 'exec', 0)
- space.call_method(w_mod, 'resetwarnings')
+ space.call_method(w_mod, 'resetwarnings')
ex = e.value
ex.normalize_exception(space)
assert ex.match(space, space.w_SyntaxError)
@@ -580,7 +580,7 @@
class Folder:
def defaultvisit(self, node):
return node
-
+
def __getattr__(self, attrname):
if attrname.startswith('visit'):
return self.defaultvisit
@@ -597,7 +597,7 @@
def hook(ast, enc, filename):
return ast.mutate(Folder())
-
+
parser.install_compiler_hook(hook)
code = compile("1+2", "", "eval")
parser.install_compiler_hook(None)
@@ -611,5 +611,5 @@
sys.stdout = so
output = s.getvalue()
assert 'BINARY_ADD' not in output
-
-
+
+
Modified: pypy/dist/pypy/interpreter/test/test_syntax.py
==============================================================================
--- pypy/dist/pypy/interpreter/test/test_syntax.py (original)
+++ pypy/dist/pypy/interpreter/test/test_syntax.py Sat Jul 14 13:52:50 2007
@@ -278,7 +278,7 @@
def test_with_simple(self):
s = """from __future__ import with_statement
-if 1:
+if 1:
class Context:
def __init__(self):
self.calls = list()
@@ -288,7 +288,7 @@
def __exit__(self, exc_type, exc_value, exc_tb):
self.calls.append('__exit__')
-
+
acontext = Context()
with acontext:
pass
@@ -296,7 +296,7 @@
exec s
assert acontext.calls == '__enter__ __exit__'.split()
-
+
def test_with_as_var(self):
s = """from __future__ import with_statement
@@ -308,7 +308,7 @@
def __enter__(self):
self.calls.append('__enter__')
return self.calls
-
+
def __exit__(self, exc_type, exc_value, exc_tb):
self.calls.append('__exit__')
self.exit_params = (exc_type, exc_value, exc_tb)
@@ -322,7 +322,7 @@
assert acontextfact.exit_params == (None, None, None)
assert acontextfact.calls == '__enter__ __body__ __exit__'.split()
-
+
def test_with_raise_exception(self):
s = """from __future__ import with_statement
@@ -334,7 +334,7 @@
def __enter__(self):
self.calls.append('__enter__')
return self.calls
-
+
def __exit__(self, exc_type, exc_value, exc_tb):
self.calls.append('__exit__')
self.exit_params = (exc_type, exc_value, exc_tb)
@@ -369,7 +369,7 @@
def __enter__(self):
self.calls.append('__enter__')
return self.calls
-
+
def __exit__(self, exc_type, exc_value, exc_tb):
self.calls.append('__exit__')
self.exit_params = (exc_type, exc_value, exc_tb)
@@ -400,7 +400,7 @@
def __enter__(self):
self.calls.append('__enter__')
return self.calls
-
+
def __exit__(self, exc_type, exc_value, exc_tb):
self.calls.append('__exit__')
self.exit_params = (exc_type, exc_value, exc_tb)
@@ -419,7 +419,7 @@
assert acontextfact.calls == '__enter__ __body__ __exit__'.split()
assert acontextfact.exit_params == (None, None, None)
-
+
def test_with_continue(self):
s = """from __future__ import with_statement
@@ -431,7 +431,7 @@
def __enter__(self):
self.calls.append('__enter__')
return self.calls
-
+
def __exit__(self, exc_type, exc_value, exc_tb):
self.calls.append('__exit__')
self.exit_params = (exc_type, exc_value, exc_tb)
@@ -450,7 +450,7 @@
assert acontextfact.calls == '__enter__ __body__ __exit__ __continue__'.split()
assert acontextfact.exit_params == (None, None, None)
-
+
def test_with_return(self):
s = """from __future__ import with_statement
if 1:
@@ -461,7 +461,7 @@
def __enter__(self):
self.calls.append('__enter__')
return self.calls
-
+
def __exit__(self, exc_type, exc_value, exc_tb):
self.calls.append('__exit__')
self.exit_params = (exc_type, exc_value, exc_tb)
@@ -479,7 +479,7 @@
assert acontextfact.calls == '__enter__ __body__ __exit__ __return__'.split()
assert acontextfact.exit_params == (None, None, None)
-
+
def test_with_as_identifier(self):
exec "with = 9"
@@ -490,7 +490,7 @@
pass
else:
assert False, 'Assignment to with did not raise SyntaxError'
-
+
def test_with_as_keyword_and_docstring(self):
try:
exec "'Docstring'\nfrom __future__ import with_statement\nwith = 9"
@@ -498,7 +498,7 @@
pass
else:
assert False, 'Assignment to with did not raise SyntaxError'
-
+
def test_with_as_keyword_compound(self):
try:
exec "from __future__ import generators, with_statement\nwith = 9"
@@ -506,7 +506,7 @@
pass
else:
assert False, 'Assignment to with did not raise SyntaxError'
-
+
def test_with_as_keyword_multiple(self):
try:
exec "from __future__ import generators\nfrom __future__ import with_statement\nwith = 9"
@@ -514,11 +514,11 @@
pass
else:
assert False, 'Assignment to with did not raise SyntaxError'
-
+
def test_as_as_identifier(self):
exec "as = 9"
exec "import sys as foo"
-
+
def test_as_as_keyword(self):
try:
exec "from __future__ import with_statement\nas = 9"
More information about the Pypy-commit
mailing list