[pypy-svn] r62027 - in pypy/trunk/pypy: module/_winreg module/_winreg/test rlib

afa at codespeak.net afa at codespeak.net
Thu Feb 19 20:17:29 CET 2009


Author: afa
Date: Thu Feb 19 20:17:28 2009
New Revision: 62027

Modified:
   pypy/trunk/pypy/module/_winreg/__init__.py
   pypy/trunk/pypy/module/_winreg/interp_winreg.py
   pypy/trunk/pypy/module/_winreg/test/test_winreg.py
   pypy/trunk/pypy/rlib/rwinreg.py
Log:
Add winreg.ConnectRegistry.

All of CPython's test_winreg test suite passes... on top of py.py
Now let's see if it translates...


Modified: pypy/trunk/pypy/module/_winreg/__init__.py
==============================================================================
--- pypy/trunk/pypy/module/_winreg/__init__.py	(original)
+++ pypy/trunk/pypy/module/_winreg/__init__.py	Thu Feb 19 20:17:28 2009
@@ -20,6 +20,7 @@
         'EnumKey'     : 'interp_winreg.EnumKey',
         'CloseKey': 'interp_winreg.CloseKey',
         'QueryInfoKey': 'interp_winreg.QueryInfoKey',
+        'ConnectRegistry': 'interp_winreg.ConnectRegistry',
     }
 
     for name, value in constants.iteritems():

Modified: pypy/trunk/pypy/module/_winreg/interp_winreg.py
==============================================================================
--- pypy/trunk/pypy/module/_winreg/interp_winreg.py	(original)
+++ pypy/trunk/pypy/module/_winreg/interp_winreg.py	Thu Feb 19 20:17:28 2009
@@ -399,3 +399,21 @@
     finally:
         lltype.free(nSubKeys, flavor='raw')
 QueryInfoKey.unwrap_spec = [ObjSpace, W_Root]
+
+def str_or_None_w(space, w_obj):
+    if space.is_w(w_obj, space.w_None):
+        return None
+    return space.str_w(w_obj)
+
+def ConnectRegistry(space, w_machine, w_hkey):
+    machine = str_or_None_w(space, w_machine)
+    hkey = hkey_w(w_hkey, space)
+    rethkey = lltype.malloc(rwinreg.PHKEY.TO, 1, flavor='raw')
+    try:
+        ret = rwinreg.RegConnectRegistry(machine, hkey, rethkey)
+        if ret != 0:
+            raiseWindowsError(space, ret, 'RegConnectRegistry')
+        return space.wrap(W_HKEY(rethkey[0]))
+    finally:
+        lltype.free(rethkey, flavor='raw')
+ConnectRegistry.unwrap_spec = [ObjSpace, W_Root, W_Root]

Modified: pypy/trunk/pypy/module/_winreg/test/test_winreg.py
==============================================================================
--- pypy/trunk/pypy/module/_winreg/test/test_winreg.py	(original)
+++ pypy/trunk/pypy/module/_winreg/test/test_winreg.py	Thu Feb 19 20:17:28 2009
@@ -115,3 +115,8 @@
             DeleteValue(sub_key, name)
 
         DeleteKey(key, "sub_key")
+
+    def test_connect(self):
+        from _winreg import ConnectRegistry, HKEY_LOCAL_MACHINE
+        h = ConnectRegistry(None, HKEY_LOCAL_MACHINE)
+        h.Close()

Modified: pypy/trunk/pypy/rlib/rwinreg.py
==============================================================================
--- pypy/trunk/pypy/rlib/rwinreg.py	(original)
+++ pypy/trunk/pypy/rlib/rwinreg.py	Thu Feb 19 20:17:28 2009
@@ -112,3 +112,8 @@
     'RegCloseKey',
     [HKEY],
     rffi.LONG)
+
+RegConnectRegistry = external(
+    'RegConnectRegistryA',
+    [rffi.CCHARP, HKEY, PHKEY],
+    rffi.LONG)



More information about the Pypy-commit mailing list