PageRenderTime 49ms CodeModel.GetById 24ms RepoModel.GetById 0ms app.codeStats 0ms

/pypy/rlib/rstruct/error.py

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