[pypy-commit] pypy py3.3: add missing lzma.LZMAError
numerodix
noreply at buildbot.pypy.org
Wed Aug 20 22:09:23 CEST 2014
Author: Martin Matusiak <numerodix at gmail.com>
Branch: py3.3
Changeset: r72938:5f4688671d8e
Date: 2014-08-20 22:08 +0200
http://bitbucket.org/pypy/pypy/changeset/5f4688671d8e/
Log: add missing lzma.LZMAError
diff --git a/pypy/module/_lzma/__init__.py b/pypy/module/_lzma/__init__.py
--- a/pypy/module/_lzma/__init__.py
+++ b/pypy/module/_lzma/__init__.py
@@ -8,6 +8,7 @@
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)',
diff --git a/pypy/module/_lzma/interp_lzma.py b/pypy/module/_lzma/interp_lzma.py
--- a/pypy/module/_lzma/interp_lzma.py
+++ b/pypy/module/_lzma/interp_lzma.py
@@ -3,6 +3,7 @@
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
@@ -346,6 +347,9 @@
)
+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).
diff --git a/pypy/module/_lzma/test/test_lzma.py b/pypy/module/_lzma/test/test_lzma.py
--- a/pypy/module/_lzma/test/test_lzma.py
+++ b/pypy/module/_lzma/test/test_lzma.py
@@ -15,3 +15,16 @@
b't\x9e\xdfI]\xff\xf4\x9d\x80\x00')
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")')
More information about the pypy-commit
mailing list