[pypy-svn] r9265 - pypy/branch/dist-interpapp/pypy/module/sys2

hpk at codespeak.net hpk at codespeak.net
Thu Feb 17 11:26:49 CET 2005


Author: hpk
Date: Thu Feb 17 11:26:49 2005
New Revision: 9265

Modified:
   pypy/branch/dist-interpapp/pypy/module/sys2/__init__.py
Log:
specialize the new sys module to provide 
the dynamic attributes exc_value/exc_type/exc_traceback. 
(the module app/interplevel-defs cannot deal with dynamic
values, should they?) 



Modified: pypy/branch/dist-interpapp/pypy/module/sys2/__init__.py
==============================================================================
--- pypy/branch/dist-interpapp/pypy/module/sys2/__init__.py	(original)
+++ pypy/branch/dist-interpapp/pypy/module/sys2/__init__.py	Thu Feb 17 11:26:49 2005
@@ -52,3 +52,28 @@
         '__excepthook__'        : 'app.__excepthook__', 
         'exit'                  : 'app.exit', 
     }
+
+    def getdictvalue(self, space, attr): 
+        """ specialize access to dynamic exc_* attributes. """ 
+        value = ExtModule.getdictvalue(self, space, attr) 
+        if value is not None: 
+            return value 
+        if attr == 'exc_type':
+            operror = space.getexecutioncontext().sys_exc_info()
+            if operror is None:
+                return space.w_None
+            else:
+                return operror.w_type
+        elif attr == 'exc_value':
+            operror = space.getexecutioncontext().sys_exc_info()
+            if operror is None:
+                return space.w_None
+            else:
+                return operror.w_value
+        elif attr == 'exc_traceback':
+            operror = space.getexecutioncontext().sys_exc_info()
+            if operror is None:
+                return space.w_None
+            else:
+                return space.wrap(operror.application_traceback)
+        return None 



More information about the Pypy-commit mailing list