[pypy-commit] pypy py3k: _winreg -> winreg, and some fixes

pjenvey noreply at buildbot.pypy.org
Thu Apr 18 22:37:39 CEST 2013


Author: Philip Jenvey <pjenvey at underboss.org>
Branch: py3k
Changeset: r63486:5cfe1e61a672
Date: 2013-04-18 13:36 -0700
http://bitbucket.org/pypy/pypy/changeset/5cfe1e61a672/

Log:	_winreg -> winreg, and some fixes

diff --git a/pypy/module/_winreg/__init__.py b/pypy/module/_winreg/__init__.py
--- a/pypy/module/_winreg/__init__.py
+++ b/pypy/module/_winreg/__init__.py
@@ -38,6 +38,8 @@
 Many constants are defined - see the documentation for each function
 to see what constants are used, and where."""
 
+    applevel_name = 'winreg'
+
     appleveldefs = {
     }
     interpleveldefs = {
diff --git a/pypy/module/_winreg/interp_winreg.py b/pypy/module/_winreg/interp_winreg.py
--- a/pypy/module/_winreg/interp_winreg.py
+++ b/pypy/module/_winreg/interp_winreg.py
@@ -109,14 +109,9 @@
     elif isinstance(w_hkey, W_HKEY):
         return w_hkey.hkey
     elif space.isinstance_w(w_hkey, space.w_int):
-        try:
-            value = space.int_w(w_hkey)
-        except OperationError, e:
-            if not e.match(space, space.w_TypeError):
-                raise
-            return rffi.cast(rwinreg.HKEY, space.uint_w(w_hkey))
-        else:
+        if space.is_true(space.lt(w_hkey, space.wrap(0))):
             return rffi.cast(rwinreg.HKEY, space.int_w(w_hkey))
+        return rffi.cast(rwinreg.HKEY, space.uint_w(w_hkey))
     else:
         errstring = space.wrap("The object is not a PyHKEY object")
         raise OperationError(space.w_TypeError, errstring)
@@ -373,7 +368,7 @@
         return space.newlist(l)
 
     else: # REG_BINARY and all other types
-        return space.wrap(rffi.charpsize2str(buf, buflen))
+        return space.wrapbytes(rffi.charpsize2str(buf, buflen))
 
 @unwrap_spec(value_name=str, typ=int)
 def SetValueEx(space, w_hkey, value_name, w_reserved, typ, w_value):
diff --git a/pypy/module/_winreg/test/test_winreg.py b/pypy/module/_winreg/test/test_winreg.py
--- a/pypy/module/_winreg/test/test_winreg.py
+++ b/pypy/module/_winreg/test/test_winreg.py
@@ -45,9 +45,12 @@
             ("Unicode Value", u"A unicode Value", _winreg.REG_SZ),
             ("Str Expand", "The path is %path%", _winreg.REG_EXPAND_SZ),
             ("Multi Str", ["Several", "string", u"values"], _winreg.REG_MULTI_SZ),
-            ("Raw data", "binary"+chr(0)+"data", _winreg.REG_BINARY),
             ]
-        cls.w_test_data = space.wrap(test_data)
+        cls.w_test_data = w_test_data = space.wrap(test_data)
+        w_btest = space.newtuple([space.wrap("Raw data"),
+                                  space.wrapbytes("binary\x00data"),
+                                  space.wrap(_winreg.REG_BINARY)])
+        w_test_data.append(w_btest)
 
     def teardown_class(cls):
         import _winreg


More information about the pypy-commit mailing list