[pypy-svn] r44056 - pypy/branch/kill-ctypes/pypy/module/_curses
fijal at codespeak.net
fijal at codespeak.net
Wed Jun 6 16:11:48 CEST 2007
Author: fijal
Date: Wed Jun 6 16:11:47 2007
New Revision: 44056
Modified:
pypy/branch/kill-ctypes/pypy/module/_curses/__init__.py
pypy/branch/kill-ctypes/pypy/module/_curses/fficurses.py
pypy/branch/kill-ctypes/pypy/module/_curses/interp_curses.py
Log:
Kill another hack
Modified: pypy/branch/kill-ctypes/pypy/module/_curses/__init__.py
==============================================================================
--- pypy/branch/kill-ctypes/pypy/module/_curses/__init__.py (original)
+++ pypy/branch/kill-ctypes/pypy/module/_curses/__init__.py Wed Jun 6 16:11:47 2007
@@ -21,13 +21,6 @@
'tparm' : 'interp_curses.tparm',
}
- def startup(self, space):
- # XXX nasty annotation trick
- try:
- raise interp_curses.curses_error(NonConstant("xxx"))
- except _curses.error, e:
- pass
-
import _curses
for i in dir(_curses):
val = getattr(_curses, i)
Modified: pypy/branch/kill-ctypes/pypy/module/_curses/fficurses.py
==============================================================================
--- pypy/branch/kill-ctypes/pypy/module/_curses/fficurses.py (original)
+++ pypy/branch/kill-ctypes/pypy/module/_curses/fficurses.py Wed Jun 6 16:11:47 2007
@@ -93,7 +93,7 @@
l[7], l[8], l[9])
lltype.free(ll_s, flavor='raw')
# XXX - how to make this happy?
- # lltype.free(ll_res, flavor.raw)
+ #lltype.free(ll_res, flavor.raw)
return rffi.charp2str(ll_res)
register_external(interp_curses._curses_tparm, [str, [int]], str,
Modified: pypy/branch/kill-ctypes/pypy/module/_curses/interp_curses.py
==============================================================================
--- pypy/branch/kill-ctypes/pypy/module/_curses/interp_curses.py (original)
+++ pypy/branch/kill-ctypes/pypy/module/_curses/interp_curses.py Wed Jun 6 16:11:47 2007
@@ -10,12 +10,18 @@
module_info = ModuleInfo()
-class curses_error(_curses.error):
+class curses_error(Exception):
def __init__(self, msg):
- self.args = [msg]
+ self.msg = msg
+
+from pypy.annotation.classdef import FORCE_ATTRIBUTES_INTO_CLASSES
+from pypy.annotation.model import SomeString
+
+# this is necessary due to annmixlevel
+FORCE_ATTRIBUTES_INTO_CLASSES[curses_error] = {'msg': SomeString()}
def convert_error(space, error):
- msg = error.args[0]
+ msg = error.msg
w_module = space.getbuiltinmodule('_curses')
w_exception_class = space.getattr(w_module, space.wrap('error'))
w_exception = space.call_function(w_exception_class, space.wrap(msg))
@@ -23,11 +29,17 @@
def _curses_setupterm_null(fd):
# NOT_RPYTHON
- _curses.setupterm(None, fd)
+ try:
+ _curses.setupterm(None, fd)
+ except _curses.error, e:
+ raise curses_error(e.args[0])
def _curses_setupterm(termname, fd):
# NOT_RPYTHON
- _curses.setupterm(termname, fd)
+ try:
+ _curses.setupterm(termname, fd)
+ except _curses.error, e:
+ raise curses_error(e.args[0])
def setupterm(space, w_termname=None, fd=-1):
if fd == -1:
@@ -40,7 +52,7 @@
_curses_setupterm_null(fd)
else:
_curses_setupterm(space.str_w(w_termname), fd)
- except _curses.error, e:
+ except curses_error, e:
raise convert_error(space, e)
setupterm.unwrap_spec = [ObjSpace, W_Root, int]
@@ -49,21 +61,27 @@
def _curses_tigetstr(capname):
# NOT_RPYTHON
- res = _curses.tigetstr(capname)
+ try:
+ res = _curses.tigetstr(capname)
+ except _curses.error, e:
+ raise curses_error(e.args[0])
if res is None:
raise TermError
return res
def _curses_tparm(s, args):
# NOT_RPYTHON
- return _curses.tparm(s, *args)
+ try:
+ return _curses.tparm(s, *args)
+ except _curses.error, e:
+ raise curses_error(e.args[0])
def tigetstr(space, capname):
try:
result = _curses_tigetstr(capname)
except TermError:
return space.w_None
- except _curses.error, e:
+ except curses_error, e:
raise convert_error(space, e)
return space.wrap(result)
tigetstr.unwrap_spec = [ObjSpace, str]
@@ -72,6 +90,6 @@
args = [space.int_w(a) for a in args_w]
try:
return space.wrap(_curses_tparm(s, args))
- except _curses.error, e:
+ except curses_error, e:
raise convert_error(space, e)
tparm.unwrap_spec = [ObjSpace, str, 'args_w']
More information about the Pypy-commit
mailing list