Author: Amaury Forgeot d'Arc <[email protected]>
Branch: py3.3
Changeset: r74253:e269c75fba51
Date: 2014-10-26 23:02 +0100
http://bitbucket.org/pypy/pypy/changeset/e269c75fba51/

Log:    lzma: all constants needed to import the test module. Also replace
        RPython crashes with nicer applevel exceptions.

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
@@ -11,11 +11,17 @@
         '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)',
-        'FORMAT_XZ': 'space.wrap(interp_lzma.FORMAT_XZ)',
-        'FORMAT_ALONE': 'space.wrap(interp_lzma.FORMAT_ALONE)',
-        'FORMAT_RAW': 'space.wrap(interp_lzma.FORMAT_RAW)',
     }
 
+    for name in 'AUTO XZ ALONE RAW'.split():
+        interpleveldefs['FORMAT_%s' % name] = (
+            'space.wrap(interp_lzma.FORMAT_%s)' % name)
+    for name in 'DEFAULT EXTREME'.split():
+        interpleveldefs['PRESET_%s' % name] = (
+            'space.wrap(interp_lzma.LZMA_PRESET_%s)' % name)
+    for name in 'LZMA1 LZMA2 DELTA X86 IA64 ARM ARMTHUMB SPARC 
POWERPC'.split():
+        interpleveldefs['FILTER_%s' % name] = (
+            'space.wrap(interp_lzma.LZMA_FILTER_%s)' % name)
+
     appleveldefs = {
     }
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
@@ -54,6 +54,10 @@
     LZMA_PRESET_DEFAULT
     LZMA_CHECK_ID_MAX
     LZMA_TELL_ANY_CHECK LZMA_TELL_NO_CHECK
+    LZMA_FILTER_LZMA1 LZMA_FILTER_LZMA2 LZMA_FILTER_DELTA
+    LZMA_FILTER_IA64 LZMA_FILTER_X86 LZMA_FILTER_ARM LZMA_FILTER_ARMTHUMB
+    LZMA_FILTER_SPARC LZMA_FILTER_POWERPC
+    LZMA_PRESET_DEFAULT LZMA_PRESET_EXTREME
     '''.split()
 for name in constant_names:
     setattr(CConfig, name, platform.ConstantInteger(name))
@@ -187,7 +191,7 @@
                     raise_error(space, "Invalid compression preset: %d", 
preset)
                 lzret = lzma_alone_encoder(self.lzs, options)
         else:
-            raise NotImplementedError
+            raise oefmt(space.w_NotImplementedError, "Filter specs")
         _catch_lzma_error(space, lzret)
 
     @staticmethod
@@ -209,7 +213,7 @@
         if format == FORMAT_ALONE:
             self._init_alone(space, preset, w_filters)
         else:
-            raise NotImplementedError
+            raise oefmt(space.w_NotImplementedError, "Format %d", format)
 
         return w_self
 
@@ -294,7 +298,7 @@
             lzret = lzma_auto_decoder(self.lzs, memlimit, decoder_flags)
             _catch_lzma_error(space, lzret)
         else:
-            raise NotImplementedError
+            raise oefmt(space.w_NotImplementedError, "Format %d", format)
 
         return w_self
 
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to