PageRenderTime 102ms CodeModel.GetById 60ms app.highlight 3ms RepoModel.GetById 38ms app.codeStats 0ms

/pypy/rlib/rstruct/error.py

https://bitbucket.org/dac_io/pypy
Python | 22 lines | 15 code | 7 blank | 0 comment | 0 complexity | a33b02a2dbb7127626c438ce5827aa09 MD5 | raw file
 1
 2class StructError(Exception):
 3    "Interp-level error that gets mapped to an app-level struct.error."
 4
 5    def __init__(self, msg):
 6        self.msg = msg
 7
 8    def __str__(self):
 9        return self.msg
10
11    def at_applevel(self, space):
12        from pypy.interpreter.error import OperationError
13        w_module = space.getbuiltinmodule('struct')
14        w_error = space.getattr(w_module, space.wrap('error'))
15        return OperationError(w_error, space.wrap(self.msg))
16
17
18class StructOverflowError(StructError):
19
20    def at_applevel(self, space):
21        from pypy.interpreter.error import OperationError
22        return OperationError(space.w_OverflowError, space.wrap(self.msg))