[pypy-commit] pypy py3.3: A minimal _lzma module, allows to import lzma.py.
amauryfa
noreply at buildbot.pypy.org
Tue Jul 29 01:43:44 CEST 2014
Author: Amaury Forgeot d'Arc <amauryfa at gmail.com>
Branch: py3.3
Changeset: r72596:5ff448f5dc64
Date: 2014-07-28 18:20 +0200
http://bitbucket.org/pypy/pypy/changeset/5ff448f5dc64/
Log: A minimal _lzma module, allows to import lzma.py. Test suite will
fail...
diff --git a/pypy/config/pypyoption.py b/pypy/config/pypyoption.py
--- a/pypy/config/pypyoption.py
+++ b/pypy/config/pypyoption.py
@@ -37,7 +37,7 @@
"binascii", "_multiprocessing", '_warnings', "_collections",
"_multibytecodec", "_continuation", "_cffi_backend",
"_csv", "_pypyjson", "_posixsubprocess", # "cppyy", "micronumpy"
- "faulthandler",
+ "faulthandler", "_lzma",
])
translation_modules = default_modules.copy()
@@ -106,6 +106,7 @@
"_hashlib" : ["pypy.module._ssl.interp_ssl"],
"_minimal_curses": ["pypy.module._minimal_curses.fficurses"],
"_continuation": ["rpython.rlib.rstacklet"],
+ "_lzma" : ["pypy.module._lzma.interp_lzma"],
}
def get_module_validator(modname):
diff --git a/pypy/module/_lzma/__init__.py b/pypy/module/_lzma/__init__.py
new file mode 100644
--- /dev/null
+++ b/pypy/module/_lzma/__init__.py
@@ -0,0 +1,20 @@
+from pypy.interpreter.mixedmodule import MixedModule
+
+class Module(MixedModule):
+ # The private part of the lzma module.
+
+ applevel_name = '_lzma'
+
+ interpleveldefs = {
+ 'LZMACompressor': 'interp_lzma.W_LZMACompressor',
+ 'LZMADecompressor': 'interp_lzma.W_LZMADecompressor',
+ '_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)',
+ }
+
+ appleveldefs = {
+ }
diff --git a/pypy/module/_lzma/interp_lzma.py b/pypy/module/_lzma/interp_lzma.py
new file mode 100644
--- /dev/null
+++ b/pypy/module/_lzma/interp_lzma.py
@@ -0,0 +1,32 @@
+from pypy.interpreter.baseobjspace import W_Root
+from pypy.interpreter.typedef import TypeDef
+
+FORMAT_AUTO, FORMAT_XZ, FORMAT_ALONE, FORMAT_RAW = range(4)
+
+
+class W_LZMACompressor(W_Root):
+ pass
+
+W_LZMACompressor.typedef = TypeDef("LZMACompressor",
+)
+
+
+class W_LZMADecompressor(W_Root):
+ pass
+
+W_LZMADecompressor.typedef = TypeDef("LZMADecompressor",
+)
+
+
+def encode_filter_properties(space, w_filter):
+ """Return a bytes object encoding the options (properties) of the filter
+ specified by *filter* (a dict).
+
+ The result does not include the filter ID itself, only the options.
+ """
+
+def decode_filter_properties(space, w_filter_id, w_encoded_props):
+ """Return a dict describing a filter with ID *filter_id*, and options
+ (properties) decoded from the bytes object *encoded_props*.
+ """
+
diff --git a/pypy/module/_lzma/test/test_lzma.py b/pypy/module/_lzma/test/test_lzma.py
new file mode 100644
--- /dev/null
+++ b/pypy/module/_lzma/test/test_lzma.py
@@ -0,0 +1,7 @@
+class AppTestBZ2File:
+ spaceconfig = {
+ "usemodules": ["_lzma"]
+ }
+
+ def test_module(self):
+ import lzma
More information about the pypy-commit
mailing list