[pypy-commit] pypy split-rpython: Fixed rstruct for the split
Aquana
noreply at buildbot.pypy.org
Fri Jan 11 20:45:42 CET 2013
Author: Alexander Hesse <webmaster at aquanasoft.de>
Branch: split-rpython
Changeset: r59969:b60e1c94763c
Date: 2013-01-11 20:44 +0100
http://bitbucket.org/pypy/pypy/changeset/b60e1c94763c/
Log: Fixed rstruct for the split
diff --git a/pypy/module/struct/interp_struct.py b/pypy/module/struct/interp_struct.py
--- a/pypy/module/struct/interp_struct.py
+++ b/pypy/module/struct/interp_struct.py
@@ -1,4 +1,5 @@
from pypy.interpreter.gateway import unwrap_spec
+from pypy.interpreter.error import OperationError
from pypy.module.struct.formatiterator import PackFormatIterator, UnpackFormatIterator
from rpython.rlib import jit
from rpython.rlib.rstruct.error import StructError
@@ -13,8 +14,12 @@
fmtiter = CalcSizeFormatIterator()
try:
fmtiter.interpret(format)
+ except StructOverflowError, e:
+ raise OperationError(space.w_OverflowError, space.wrap(self.msg))
except StructError, e:
- raise e.at_applevel(space)
+ w_module = space.getbuiltinmodule('struct')
+ w_error = space.getattr(w_module, space.wrap('error'))
+ raise OperationError(w_error, space.wrap(e.msg))
return fmtiter.totalsize
@unwrap_spec(format=str)
@@ -26,8 +31,12 @@
fmtiter = PackFormatIterator(space, args_w, size)
try:
fmtiter.interpret(format)
+ except StructOverflowError, e:
+ raise OperationError(space.w_OverflowError, space.wrap(self.msg))
except StructError, e:
- raise e.at_applevel(space)
+ w_module = space.getbuiltinmodule('struct')
+ w_error = space.getattr(w_module, space.wrap('error'))
+ raise OperationError(w_error, space.wrap(e.msg))
return space.wrap(fmtiter.result.build())
@@ -36,6 +45,10 @@
fmtiter = UnpackFormatIterator(space, input)
try:
fmtiter.interpret(format)
+ except StructOverflowError, e:
+ raise OperationError(space.w_OverflowError, space.wrap(self.msg))
except StructError, e:
- raise e.at_applevel(space)
+ w_module = space.getbuiltinmodule('struct')
+ w_error = space.getattr(w_module, space.wrap('error'))
+ raise OperationError(w_error, space.wrap(e.msg))
return space.newtuple(fmtiter.result_w[:])
diff --git a/rpython/rlib/rstruct/error.py b/rpython/rlib/rstruct/error.py
--- a/rpython/rlib/rstruct/error.py
+++ b/rpython/rlib/rstruct/error.py
@@ -1,22 +1,11 @@
class StructError(Exception):
- "Interp-level error that gets mapped to an app-level struct.error."
-
def __init__(self, msg):
self.msg = msg
def __str__(self):
return self.msg
- def at_applevel(self, space):
- from pypy.interpreter.error import OperationError
- w_module = space.getbuiltinmodule('struct')
- w_error = space.getattr(w_module, space.wrap('error'))
- return OperationError(w_error, space.wrap(self.msg))
-
class StructOverflowError(StructError):
-
- def at_applevel(self, space):
- from pypy.interpreter.error import OperationError
- return OperationError(space.w_OverflowError, space.wrap(self.msg))
+ pass
More information about the pypy-commit
mailing list