[pypy-svn] r68819 - in pypy/branch/shrink-multidict/pypy/module/sys: . test
cfbolz at codespeak.net
cfbolz at codespeak.net
Wed Oct 28 15:02:42 CET 2009
Author: cfbolz
Date: Wed Oct 28 15:02:40 2009
New Revision: 68819
Modified:
pypy/branch/shrink-multidict/pypy/module/sys/__init__.py
pypy/branch/shrink-multidict/pypy/module/sys/test/test_sysmodule.py
Log:
bah, there were no tests for sys.exc_value, .exc_type and .exc_traceback
Modified: pypy/branch/shrink-multidict/pypy/module/sys/__init__.py
==============================================================================
--- pypy/branch/shrink-multidict/pypy/module/sys/__init__.py (original)
+++ pypy/branch/shrink-multidict/pypy/module/sys/__init__.py Wed Oct 28 15:02:40 2009
@@ -100,12 +100,11 @@
w_modules = self.get('modules')
self.space.setitem(w_modules, w_name, w_module)
- def getdictvalue(self, space, w_attr):
+ def getdictvalue_w(self, space, attr):
""" specialize access to dynamic exc_* attributes. """
- value = MixedModule.getdictvalue(self, space, w_attr)
+ value = MixedModule.getdictvalue_w(self, space, attr)
if value is not None:
return value
- attr = space.str_w(w_attr)
if attr == 'exc_type':
operror = space.getexecutioncontext().sys_exc_info()
if operror is None:
@@ -126,6 +125,9 @@
return space.wrap(operror.application_traceback)
return None
+ def getdictvalue(self, space, w_attr):
+ return self.getdictvalue_w(space, space.str_w(w_attr))
+
def get_w_default_encoder(self):
if self.w_default_encoder is not None:
# XXX is this level of caching ok? CPython has some shortcuts
Modified: pypy/branch/shrink-multidict/pypy/module/sys/test/test_sysmodule.py
==============================================================================
--- pypy/branch/shrink-multidict/pypy/module/sys/test/test_sysmodule.py (original)
+++ pypy/branch/shrink-multidict/pypy/module/sys/test/test_sysmodule.py Wed Oct 28 15:02:40 2009
@@ -65,6 +65,26 @@
assert exc_val2 ==e2
assert tb2.tb_lineno - tb.tb_lineno == 5
+ def test_dynamic_attributes(self):
+ try:
+ raise Exception
+ except Exception,e:
+ import sys
+ exc_type = sys.exc_type
+ exc_val = sys.exc_value
+ tb = sys.exc_traceback
+ try:
+ raise Exception # 7 lines below the previous one
+ except Exception,e2:
+ exc_type2 = sys.exc_type
+ exc_val2 = sys.exc_value
+ tb2 = sys.exc_traceback
+ assert exc_type ==Exception
+ assert exc_val ==e
+ assert exc_type2 ==Exception
+ assert exc_val2 ==e2
+ assert tb2.tb_lineno - tb.tb_lineno == 7
+
def test_exc_info_normalization(self):
import sys
try:
More information about the Pypy-commit
mailing list