1. Pypy
  2. Untitled project
  3. pypy


Martin Matusiak  committed 5f46886

add missing lzma.LZMAError

  • Participants
  • Parent commits 1a0bf77
  • Branches py3.3

Comments (0)

Files changed (3)

File pypy/module/_lzma/__init__.py

View file
     interpleveldefs = {
         'LZMACompressor': 'interp_lzma.W_LZMACompressor',
         'LZMADecompressor': 'interp_lzma.W_LZMADecompressor',
+        'LZMAError': 'interp_lzma.W_LZMAError',
         '_encode_filter_properties': 'interp_lzma.encode_filter_properties',
         '_decode_filter_properties': 'interp_lzma.decode_filter_properties',
         'FORMAT_AUTO': 'space.wrap(interp_lzma.FORMAT_AUTO)',

File pypy/module/_lzma/interp_lzma.py

View file
     TypeDef, interp_attrproperty_bytes, interp_attrproperty)
 from pypy.interpreter.error import oefmt
 from pypy.interpreter.gateway import interp2app, unwrap_spec, WrappedDefault
+from pypy.module.exceptions.interp_exceptions import _new_exception, W_Exception
 from pypy.module.thread.os_lock import Lock
 from rpython.rlib.objectmodel import specialize
 from rpython.rlib.rarithmetic import LONGLONG_MASK, r_ulonglong
+W_LZMAError = _new_exception('LZMAError', W_Exception, 'Call to liblzma failed.')
 def encode_filter_properties(space, w_filter):
     """Return a bytes object encoding the options (properties) of the filter
        specified by *filter* (a dict).

File pypy/module/_lzma/test/test_lzma.py

View file
         decompressed = lzma.decompress(compressed)
         assert decompressed == b'Insert Data Here'
+    def test_exceptions(self):
+        import _lzma
+        import lzma
+        assert hasattr(_lzma, 'LZMAError')
+        assert hasattr(lzma, 'LZMAError')
+        assert _lzma.LZMAError is lzma.LZMAError
+        assert _lzma.LZMAError.__doc__ == 'Call to liblzma failed.'
+        exc = raises(_lzma.LZMAError, 'raise _lzma.LZMAError')
+        exc = raises(_lzma.LZMAError, 'raise _lzma.LZMAError("bad thing")')