[pypy-svn] pypy interplevel-exception-classes: termios.error at interp-level

amauryfa commits-noreply at bitbucket.org
Fri Feb 18 13:12:58 CET 2011


Author: Amaury Forgeot d'Arc <amauryfa at gmail.com>
Branch: interplevel-exception-classes
Changeset: r42147:7b9198ad3e51
Date: 2011-02-18 13:02 +0100
http://bitbucket.org/pypy/pypy/changeset/7b9198ad3e51/

Log:	termios.error at interp-level

diff --git a/pypy/module/termios/__init__.py b/pypy/module/termios/__init__.py
--- a/pypy/module/termios/__init__.py
+++ b/pypy/module/termios/__init__.py
@@ -14,7 +14,6 @@
     sys.stdin.fileno(), or a file object, such as sys.stdin itself."
 
     appleveldefs = {
-        'error'       : 'app_termios.error',
     }
     
     interpleveldefs = {
@@ -24,6 +23,7 @@
         'tcgetattr'   : 'interp_termios.tcgetattr',
         'tcsendbreak' : 'interp_termios.tcsendbreak',
         'tcsetattr'   : 'interp_termios.tcsetattr',
+        'error'       : 'space.fromcache(interp_termios.Cache).w_error',
     }
 
 import termios

diff --git a/pypy/module/termios/app_termios.py b/pypy/module/termios/app_termios.py
deleted file mode 100644
--- a/pypy/module/termios/app_termios.py
+++ /dev/null
@@ -1,3 +0,0 @@
-
-class error(Exception):
-    pass

diff --git a/pypy/module/termios/interp_termios.py b/pypy/module/termios/interp_termios.py
--- a/pypy/module/termios/interp_termios.py
+++ b/pypy/module/termios/interp_termios.py
@@ -11,13 +11,12 @@
 from pypy.rlib import rtermios
 import termios
 
-# proper semantics are to have termios.error, but since it's not documented
-# anyway, let's have it as OSError on interplevel. We need to have
-# some details what is missing in RPython modules though
+class Cache:
+    def __init__(self):
+        self.w_error = space.new_exception_class("termios.error")
 
 def convert_error(space, error):
-    w_module = space.getbuiltinmodule('termios')
-    w_exception_class = space.getattr(w_module, space.wrap('error'))
+    w_exception_class = space.fromcache(Cache).w_error
     return wrap_oserror(space, error, w_exception_class=w_exception_class)
 
 @unwrap_spec(fd=int, when=int)


More information about the Pypy-commit mailing list