[pypy-svn] r55163 - pypy/dist/pypy/rlib/rstruct

fijal at codespeak.net fijal at codespeak.net
Sat May 24 00:08:50 CEST 2008


Author: fijal
Date: Sat May 24 00:08:48 2008
New Revision: 55163

Added:
   pypy/dist/pypy/rlib/rstruct/error.py
      - copied, changed from r55150, pypy/dist/pypy/module/struct/error.py
   pypy/dist/pypy/rlib/rstruct/ieee.py
      - copied unchanged from r55150, pypy/dist/pypy/module/struct/ieee.py
   pypy/dist/pypy/rlib/rstruct/nativefmttable.py
      - copied, changed from r55150, pypy/dist/pypy/module/struct/nativefmttable.py
   pypy/dist/pypy/rlib/rstruct/standardfmttable.py
      - copied, changed from r55150, pypy/dist/pypy/module/struct/standardfmttable.py
   pypy/dist/pypy/rlib/rstruct/unichar.py
      - copied unchanged from r55150, pypy/dist/pypy/module/struct/unichar.py
Modified:
   pypy/dist/pypy/rlib/rstruct/   (props changed)
   pypy/dist/pypy/rlib/rstruct/__init__.py
Log:
Factor out rpython-only pieces of struct module


Modified: pypy/dist/pypy/rlib/rstruct/__init__.py
==============================================================================
--- pypy/dist/pypy/rlib/rstruct/__init__.py	(original)
+++ pypy/dist/pypy/rlib/rstruct/__init__.py	Sat May 24 00:08:48 2008
@@ -1,2 +1,14 @@
 
 from struct import pack, unpack
+from pypy.rpython.extregistry import ExtRegistryEntry
+
+class UnpackEntry(ExtRegistryEntry):
+    _about_ = unpack
+
+    def compute_result_annotation(self, s_fmt, s_s):
+        from pypy.annotation import model as annmodel
+        if not isinstance(s_s, annmodel.SomeString):
+            raise TypeError("Got %s, string expected" % (s_s,))
+        if not s_fmt.is_constant():
+            raise ValueError("Can only use struct.unpack with first argument constant in RPython")
+        



More information about the Pypy-commit mailing list