aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.hgtags3
-rw-r--r--pypy/module/_locale/test/test_locale.py7
-rw-r--r--pypy/module/_winreg/interp_winreg.py95
-rw-r--r--pypy/module/_winreg/test/test_winreg.py19
-rw-r--r--pypy/module/cpyext/api.py1
-rw-r--r--pypy/module/posix/interp_posix.py29
-rw-r--r--pypy/module/posix/moduledef.py4
-rw-r--r--pypy/module/posix/test/test_posix2.py49
-rw-r--r--pypy/tool/pytest/apptest.py3
-rw-r--r--rpython/rlib/rwinreg.py40
10 files changed, 137 insertions, 113 deletions
diff --git a/.hgtags b/.hgtags
index 642614bde9..a7138fad73 100644
--- a/.hgtags
+++ b/.hgtags
@@ -92,3 +92,6 @@ d38cd66c14b86430155e2a122e59648e93011cc0 release-pypy3.6-v7.3.2rc3
6abe2e00c51df8ca4524cd7107b9a2b520574481 release-pypy2.7-v7.3.2
d38cd66c14b86430155e2a122e59648e93011cc0 release-pypy3.6-v7.3.2
87875bf2dfd8fe682a49e010f6636a871b1308e6 release-pypy3.7-v7.3.2
+a29ef73f9b32953753d0dd6d2a56255fa2892e24 release-pypy2.7-v7.3.3rc1
+fab92f174c7754272e9bef31d2a6d66d8d45188b release-pypy3.6-v7.3.3rc1
+6cf8fa20a7f6fc61dc07402e1e859cf31bf977ad release-pypy3.7-v7.3.3rc1
diff --git a/pypy/module/_locale/test/test_locale.py b/pypy/module/_locale/test/test_locale.py
index 6b87e68864..db32cbd508 100644
--- a/pypy/module/_locale/test/test_locale.py
+++ b/pypy/module/_locale/test/test_locale.py
@@ -1,4 +1,4 @@
-import py
+import pytest
import sys
@@ -35,7 +35,7 @@ class AppTestLocaleTrivia:
_locale.setlocale(_locale.LC_ALL,
cls.space.utf8_w(cls.w_language_pl))
except _locale.Error:
- py.test.skip("necessary locales not installed")
+ pytest.skip("necessary locales not installed")
# Windows forbids the UTF-8 character set since Windows XP.
try:
@@ -310,6 +310,9 @@ class AppTestLocaleTrivia:
assert encoding.startswith('cp')
def test_lc_numeric_basic(self):
+ import _locale
+ if sys.platform == 'win32':
+ skip("No nl_langinfo to test")
from _locale import (setlocale, nl_langinfo, Error, LC_NUMERIC,
LC_CTYPE, RADIXCHAR, THOUSEP, localeconv)
# Test nl_langinfo against localeconv
diff --git a/pypy/module/_winreg/interp_winreg.py b/pypy/module/_winreg/interp_winreg.py
index 627bee19a8..cd15c23298 100644
--- a/pypy/module/_winreg/interp_winreg.py
+++ b/pypy/module/_winreg/interp_winreg.py
@@ -191,9 +191,9 @@ The docs imply key must be in the HKEY_USER or HKEY_LOCAL_MACHINE tree"""
# XXX should filename use space.fsencode_w?
hkey = hkey_w(w_hkey, space)
with rffi.scoped_unicode2wcharp(subkey) as wide_subkey:
- c_subkey = rffi.cast(rffi.CCHARP, wide_subkey)
+ c_subkey = rffi.cast(rffi.CWCHARP, wide_subkey)
with rffi.scoped_unicode2wcharp(filename) as wide_filename:
- c_filename = rffi.cast(rffi.CCHARP, wide_filename)
+ c_filename = rffi.cast(rffi.CWCHARP, wide_filename)
ret = rwinreg.RegLoadKeyW(hkey, c_subkey, c_filename)
if ret != 0:
raiseWindowsError(space, ret, 'RegLoadKey')
@@ -217,7 +217,7 @@ The caller of this method must possess the SeBackupPrivilege security
privilege. This function passes NULL for security_attributes to the API."""
hkey = hkey_w(w_hkey, space)
with rffi.scoped_unicode2wcharp(filename) as wide_filename:
- c_filename = rffi.cast(rffi.CCHARP, wide_filename)
+ c_filename = rffi.cast(rffi.CWCHARP, wide_filename)
ret = rwinreg.RegSaveKeyW(hkey, c_filename, None)
if ret != 0:
raiseWindowsError(space, ret, 'RegSaveKey')
@@ -256,9 +256,9 @@ KEY_SET_VALUE access."""
# Add an offset to remove the BOM from the native utf16 wstr
with rffi.scoped_nonmovingbuffer(subkeyW) as subkeyP0:
- subkeyP = rffi.ptradd(subkeyP0, 2)
+ subkeyP = rffi.cast(rffi.CWCHARP, rffi.ptradd(subkeyP0, 2))
with rffi.scoped_nonmovingbuffer(valueW) as valueP0:
- valueP = rffi.ptradd(valueP0, 2)
+ valueP = rffi.cast(rffi.CWCHARP, rffi.ptradd(valueP0, 2))
ret = rwinreg.RegSetValueW(hkey, subkeyP, rwinreg.REG_SZ,
valueP, valueL)
if ret != 0:
@@ -283,29 +283,22 @@ But the underlying API call doesn't return the type: Lame, DONT USE THIS!!!"""
else:
subkey = space.utf8_w(w_subkey).decode('utf8')
with rffi.scoped_unicode2wcharp(subkey) as wide_subkey:
- c_subkey = rffi.cast(rffi.CCHARP, wide_subkey)
+ c_subkey = rffi.cast(rffi.CWCHARP, wide_subkey)
with lltype.scoped_alloc(rwin32.PLONG.TO, 1) as bufsize_p:
+ bufsize_p[0] = 0
ret = rwinreg.RegQueryValueW(hkey, c_subkey, None, bufsize_p)
- bufSize = intmask(bufsize_p[0])
- if ret == rwinreg.ERROR_MORE_DATA:
- bufSize = 256
- elif ret != 0:
+ if ret == 0 and intmask(bufsize_p[0]) == 0:
+ return space.newtext('', 0)
+ elif ret != 0 and ret != rwinreg.ERROR_MORE_DATA:
raiseWindowsError(space, ret, 'RegQueryValue')
-
- while True:
- buf = ByteBuffer(bufSize)
- bufP = rffi.cast(rffi.CCHARP, buf.get_raw_address())
- ret = rwinreg.RegQueryValueW(hkey, c_subkey, bufP, bufsize_p)
- if ret == rwinreg.ERROR_MORE_DATA:
- # Resize and retry
- bufSize *= 2
- bufsize_p[0] = bufSize
- continue
-
- if ret != 0:
- raiseWindowsError(space, ret, 'RegQueryValue')
- utf8, lgt = wbuf_to_utf8(space, buf[0:intmask(bufsize_p[0])])
- return space.newtext(utf8, lgt)
+ # Add extra space for a NULL ending
+ buf = ByteBuffer(intmask(bufsize_p[0]) * 2 + 2)
+ bufP = rffi.cast(rwin32.LPWSTR, buf.get_raw_address())
+ ret = rwinreg.RegQueryValueW(hkey, c_subkey, bufP, bufsize_p)
+ if ret != 0:
+ raiseWindowsError(space, ret, 'RegQueryValue')
+ utf8, lgt = wbuf_to_utf8(space, buf[0:intmask(bufsize_p[0])])
+ return space.newtext(utf8, lgt)
def convert_to_regdata(space, w_value, typ):
@@ -389,7 +382,7 @@ def convert_to_regdata(space, w_value, typ):
buf = rffi.str2charp(value)
if buf is not None:
- return rffi.cast(rffi.CCHARP, buf), buflen
+ return rffi.cast(rffi.CWCHARP, buf), buflen
raise oefmt(space.w_ValueError,
"Could not convert the data to the specified type")
@@ -489,7 +482,7 @@ the configuration registry. This helps the registry perform efficiently."""
buf, buflen = convert_to_regdata(space, w_value, typ)
try:
with rffi.scoped_unicode2wcharp(value_name) as wide_vn:
- c_vn = rffi.cast(rffi.CCHARP, wide_vn)
+ c_vn = rffi.cast(rffi.CWCHARP, wide_vn)
ret = rwinreg.RegSetValueExW(hkey, c_vn, 0, typ, buf, buflen)
finally:
lltype.free(buf, flavor='raw')
@@ -511,19 +504,19 @@ value_name is a string indicating the value to query"""
subkey = space.utf8_w(w_subkey).decode('utf8')
null_dword = lltype.nullptr(rwin32.LPDWORD.TO)
with rffi.scoped_unicode2wcharp(subkey) as wide_subkey:
- c_subkey = rffi.cast(rffi.CCHARP, wide_subkey)
+ c_subkey = rffi.cast(rffi.CWCHARP, wide_subkey)
with lltype.scoped_alloc(rwin32.LPDWORD.TO, 1) as dataSize:
ret = rwinreg.RegQueryValueExW(hkey, c_subkey, null_dword,
null_dword, None, dataSize)
bufSize = intmask(dataSize[0])
if ret == rwinreg.ERROR_MORE_DATA:
+ # Copy CPython behaviour, otherwise bufSize can be 0
bufSize = 256
elif ret != 0:
- raiseWindowsError(space, ret, 'RegQueryValueEx')
-
+ raiseWindowsError(space, ret, 'RegQueryValue')
while True:
dataBuf = ByteBuffer(bufSize)
- dataBufP = rffi.cast(rffi.CCHARP, dataBuf.get_raw_address())
+ dataBufP = rffi.cast(rffi.CWCHARP, dataBuf.get_raw_address())
with lltype.scoped_alloc(rwin32.LPDWORD.TO, 1) as retType:
ret = rwinreg.RegQueryValueExW(hkey, c_subkey, null_dword,
@@ -558,7 +551,7 @@ The return value is the handle of the opened key.
If the function fails, an exception is raised."""
hkey = hkey_w(w_hkey, space)
with rffi.scoped_unicode2wcharp(subkey) as wide_subkey:
- c_subkey = rffi.cast(rffi.CCHARP, wide_subkey)
+ c_subkey = rffi.cast(rffi.CWCHARP, wide_subkey)
with lltype.scoped_alloc(rwinreg.PHKEY.TO, 1) as rethkey:
ret = rwinreg.RegCreateKeyW(hkey, c_subkey, rethkey)
if ret != 0:
@@ -581,7 +574,7 @@ The return value is the handle of the opened key.
If the function fails, an exception is raised."""
hkey = hkey_w(w_key, space)
with rffi.scoped_unicode2wcharp(sub_key) as wide_sub_key:
- c_subkey = rffi.cast(rffi.CCHARP, wide_sub_key)
+ c_subkey = rffi.cast(rffi.CWCHARP, wide_sub_key)
with lltype.scoped_alloc(rwinreg.PHKEY.TO, 1) as rethkey:
ret = rwinreg.RegCreateKeyExW(hkey, c_subkey, reserved, None, 0,
access, None, rethkey,
@@ -606,7 +599,7 @@ If the method succeeds, the entire key, including all of its values,
is removed. If the method fails, an EnvironmentError exception is raised."""
hkey = hkey_w(w_hkey, space)
with rffi.scoped_unicode2wcharp(subkey) as wide_subkey:
- c_subkey = rffi.cast(rffi.CCHARP, wide_subkey)
+ c_subkey = rffi.cast(rffi.CWCHARP, wide_subkey)
ret = rwinreg.RegDeleteKeyW(hkey, c_subkey)
if ret != 0:
raiseWindowsError(space, ret, 'RegDeleteKey')
@@ -620,7 +613,7 @@ key is an already open key, or any one of the predefined HKEY_* constants.
value is a string that identifies the value to remove."""
hkey = hkey_w(w_hkey, space)
with rffi.scoped_unicode2wcharp(subkey) as wide_subkey:
- c_subkey = rffi.cast(rffi.CCHARP, wide_subkey)
+ c_subkey = rffi.cast(rffi.CWCHARP, wide_subkey)
ret = rwinreg.RegDeleteValueW(hkey, c_subkey)
if ret != 0:
raiseWindowsError(space, ret, 'RegDeleteValue')
@@ -645,7 +638,7 @@ If the function fails, an EnvironmentError exception is raised."""
errh = state.encode_error_handler
subkeyW = utf8_encode_utf_16(utf8 + '\x00', 'strict', errh, allow_surrogates=False)
with rffi.scoped_nonmovingbuffer(subkeyW) as subkeyP0:
- subkeyP = rffi.ptradd(subkeyP0, 2)
+ subkeyP = rffi.cast(rffi.CWCHARP, rffi.ptradd(subkeyP0, 2))
with lltype.scoped_alloc(rwinreg.PHKEY.TO, 1) as rethkey:
ret = rwinreg.RegOpenKeyExW(hkey, subkeyP, reserved, access,
rethkey)
@@ -688,7 +681,7 @@ data_type is an integer that identifies the type of the value data."""
bufValueSize = intmask(valueSize[0] * 2)
valueBuf = ByteBuffer(bufValueSize)
- valueBufP = rffi.cast(rffi.CCHARP, valueBuf.get_raw_address())
+ valueBufP = rffi.cast(rffi.CWCHARP, valueBuf.get_raw_address())
while True:
dataBuf = ByteBuffer(bufDataSize)
dataBufP = rffi.cast(rffi.CCHARP, dataBuf.get_raw_address())
@@ -741,8 +734,8 @@ raised, indicating no more values are available."""
# create a 256 character key that is missing the terminating
# nul. RegEnumKeyEx requires a 257 character buffer to
# retrieve such a key name.
- buf = ByteBuffer(257)
- bufP = rffi.cast(rffi.CCHARP, buf.get_raw_address())
+ buf = ByteBuffer(257 * 2)
+ bufP = rffi.cast(rwin32.LPWSTR, buf.get_raw_address())
with lltype.scoped_alloc(rwin32.LPDWORD.TO, 1) as valueSize:
valueSize[0] = r_uint(257) # includes NULL terminator
ret = rwinreg.RegEnumKeyExW(hkey, index, bufP, valueSize,
@@ -796,13 +789,25 @@ key is the predefined handle to connect to.
The return value is the handle of the opened key.
If the function fails, an EnvironmentError exception is raised."""
- machine = space.text_or_none_w(w_machine)
hkey = hkey_w(w_hkey, space)
- with lltype.scoped_alloc(rwinreg.PHKEY.TO, 1) as rethkey:
- ret = rwinreg.RegConnectRegistryW(machine, hkey, rethkey)
- if ret != 0:
- raiseWindowsError(space, ret, 'RegConnectRegistry')
- return W_HKEY(space, rethkey[0])
+ if space.is_none(w_machine):
+ with lltype.scoped_alloc(rwinreg.PHKEY.TO, 1) as rethkey:
+ ret = rwinreg.RegConnectRegistryW(None, hkey, rethkey)
+ if ret != 0:
+ raiseWindowsError(space, ret, 'RegConnectRegistry')
+ return W_HKEY(space, rethkey[0])
+ else:
+ utf8 = space.utf8_w(w_machine)
+ state = space.fromcache(CodecState)
+ errh = state.encode_error_handler
+ machineW = utf8_encode_utf_16(utf8 + '\x00', 'strict', errh, allow_surrogates=False)
+ with rffi.scoped_nonmovingbuffer(machineW) as machineP0:
+ machineP = rffi.cast(rwin32.LPWSTR, rffi.ptradd(machineP0, 2))
+ with lltype.scoped_alloc(rwinreg.PHKEY.TO, 1) as rethkey:
+ ret = rwinreg.RegConnectRegistryW(machineP, hkey, rethkey)
+ if ret != 0:
+ raiseWindowsError(space, ret, 'RegConnectRegistry')
+ return W_HKEY(space, rethkey[0])
def ExpandEnvironmentStrings(space, w_source):
diff --git a/pypy/module/_winreg/test/test_winreg.py b/pypy/module/_winreg/test/test_winreg.py
index 409e671932..809e26388e 100644
--- a/pypy/module/_winreg/test/test_winreg.py
+++ b/pypy/module/_winreg/test/test_winreg.py
@@ -38,6 +38,7 @@ class AppTestFfi:
cls.w_test_key_name = space.wrap(cls.test_key_name)
cls.w_canSaveKey = space.wrap(canSaveKey)
cls.w_tmpfilename = space.wrap(str(udir.join('winreg-temp')))
+ cls.w_runappdirect = space.wrap(cls.runappdirect)
test_data = [
("Int Value", 0xFEDCBA98, winreg.REG_DWORD),
@@ -57,8 +58,6 @@ class AppTestFfi:
try:
_winreg.DeleteKey(cls.root_key, cls.test_key_name)
except WindowsError as e:
- print('could not delete key')
- print(str(e))
pass
def test_constants(self):
@@ -247,7 +246,7 @@ class AppTestFfi:
def test_dynamic_key(self):
from winreg import EnumValue, QueryValueEx, HKEY_PERFORMANCE_DATA
if not self.runappdirect:
- skip('crashes untranslated')
+ skip('very slow untranslated')
try:
EnumValue(HKEY_PERFORMANCE_DATA, 0)
except WindowsError as e:
@@ -258,20 +257,6 @@ class AppTestFfi:
raise
QueryValueEx(HKEY_PERFORMANCE_DATA, 'Global')
- def test_reflection_unsupported(self):
- import sys
- if sys.getwindowsversion() >= (5, 2):
- skip("Requires Windows XP")
- from winreg import (
- CreateKey, DisableReflectionKey, EnableReflectionKey,
- QueryReflectionKey, DeleteKeyEx)
- with CreateKey(self.root_key, self.test_key_name) as key:
- raises(NotImplementedError, DisableReflectionKey, key)
- raises(NotImplementedError, EnableReflectionKey, key)
- raises(NotImplementedError, QueryReflectionKey, key)
- raises(NotImplementedError, DeleteKeyEx, self.root_key,
- self.test_key_name)
-
def test_named_arguments(self):
from winreg import KEY_ALL_ACCESS, CreateKeyEx, DeleteKey, OpenKeyEx
with CreateKeyEx(key=self.root_key, sub_key=self.test_key_name,
diff --git a/pypy/module/cpyext/api.py b/pypy/module/cpyext/api.py
index 6fa06cead3..d3cc1fefe4 100644
--- a/pypy/module/cpyext/api.py
+++ b/pypy/module/cpyext/api.py
@@ -622,6 +622,7 @@ SYMBOLS_C = [
'PyStructSequence_InitType', 'PyStructSequence_InitType2',
'PyStructSequence_New', 'PyStructSequence_UnnamedField',
+ 'PyStructSequence_NewType',
'PyFunction_Type', 'PyMethod_Type', 'PyRange_Type', 'PyTraceBack_Type',
diff --git a/pypy/module/posix/interp_posix.py b/pypy/module/posix/interp_posix.py
index 4f72b8d6bf..1b5e0016af 100644
--- a/pypy/module/posix/interp_posix.py
+++ b/pypy/module/posix/interp_posix.py
@@ -823,21 +823,20 @@ dir_fd may not be implemented on your platform.
except OSError as e:
raise wrap_oserror2(space, e, path.w_path, eintr_retry=False)
-def _getfullpathname(space, w_path):
- """helper for ntpath.abspath """
- try:
- if space.isinstance_w(w_path, space.w_unicode):
- path = FileEncoder(space, w_path)
- fullpath = rposix.getfullpathname(path)
- w_fullpath = u2utf8(space, fullpath)
- else:
- path = space.bytesbuf0_w(w_path)
- fullpath = rposix.getfullpathname(path)
- w_fullpath = space.newbytes(fullpath)
- except OSError as e:
- raise wrap_oserror2(space, e, w_path, eintr_retry=False)
- else:
- return w_fullpath
+if _WIN32:
+ @unwrap_spec(path=path_or_fd(allow_fd=False, nullable=False))
+ def _getfullpathname(space, path):
+ """helper for ntpath.abspath """
+ try:
+ if path.as_unicode is not None:
+ result = rposix.getfullpathname(path.as_unicode)
+ return u2utf8(space, result)
+ else:
+ result = rposix.getfullpathname(path.as_bytes)
+ return space.newbytes(result)
+ except OSError as e:
+ raise wrap_oserror2(space, e, path.w_path, eintr_retry=False)
+
def getcwdb(space):
"""Return the current working directory."""
diff --git a/pypy/module/posix/moduledef.py b/pypy/module/posix/moduledef.py
index f3a47191d9..484172c1a1 100644
--- a/pypy/module/posix/moduledef.py
+++ b/pypy/module/posix/moduledef.py
@@ -180,11 +180,9 @@ corresponding Unix manual entries for more information on calls."""
'getresuid', 'getresgid', 'setresuid', 'setresgid']:
if hasattr(os, name):
interpleveldefs[name] = 'interp_posix.%s' % (name,)
- # not visible via os, inconsistency in nt:
- if hasattr(posix, '_getfullpathname'):
- interpleveldefs['_getfullpathname'] = 'interp_posix._getfullpathname'
if os.name == 'nt':
interpleveldefs.update({
+ '_getfullpathname': 'interp_posix._getfullpathname',
'_getfileinformation': 'interp_posix._getfileinformation',
'_getfinalpathname': 'interp_posix._getfinalpathname',
'get_handle_inheritable': 'interp_posix.get_handle_inheritable',
diff --git a/pypy/module/posix/test/test_posix2.py b/pypy/module/posix/test/test_posix2.py
index 899bf77e1c..131dafd2fb 100644
--- a/pypy/module/posix/test/test_posix2.py
+++ b/pypy/module/posix/test/test_posix2.py
@@ -12,9 +12,7 @@ from pypy.interpreter.gateway import interp2app
from rpython.translator.c.test.test_extfunc import need_sparse_files
from rpython.rlib import rposix
-USEMODULES = ['binascii', 'posix', 'signal', 'struct', 'time']
-if os.name != 'nt':
- USEMODULES += ['_socket']
+USEMODULES = ['binascii', 'posix', 'signal', 'struct', 'time', '_socket']
def setup_module(mod):
mod.space = gettestobjspace(usemodules=USEMODULES)
@@ -525,16 +523,6 @@ class AppTestPosix:
_, status = os.waitpid(childpid, 0)
assert status >> 8 == 42
- if hasattr(__import__(os.name), '_getfullpathname'):
- def test__getfullpathname(self):
- # nt specific
- posix = self.posix
- sysdrv = posix.environ.get("SystemDrive", "C:")
- # just see if it does anything
- path = sysdrv + 'hubber'
- assert '\\' in posix._getfullpathname(path)
- assert type(posix._getfullpathname(b'C:')) is bytes
-
def test_utime(self):
os = self.posix
# XXX utimes & float support
@@ -1671,6 +1659,15 @@ class AppTestNt(object):
def setup_class(cls):
cls.w_path = space.wrap(str(path))
cls.w_posix = space.appexec([], GET_POSIX)
+ cls.w_Path = space.appexec([], """():
+ class Path:
+ def __init__(self, _path):
+ self._path =_path
+ def __fspath__(self):
+ return self._path
+ return Path
+ """)
+
def test_handle_inheritable(self):
import _socket
@@ -1682,6 +1679,32 @@ class AppTestNt(object):
posix.set_handle_inheritable(s.fileno(), True)
assert posix.get_handle_inheritable(s.fileno())
+ def test__getfullpathname(self):
+ # issue 3343
+ nt = self.posix
+ path = nt._getfullpathname(self.path)
+ assert self.path in path
+ path = nt._getfullpathname(self.Path(self.path))
+ assert self.path in path
+
+ # now as bytes
+ bpath = self.path.encode()
+ path = nt._getfullpathname(bpath)
+ assert bpath in path
+ path = nt._getfullpathname(self.Path(bpath))
+ assert bpath in path
+
+ with raises(TypeError):
+ nt._getfullpathname(None)
+
+ with raises(TypeError):
+ nt._getfullpathname(1)
+
+ sysdrv = nt.environ.get("SystemDrive", "C:")
+ # just see if it does anything
+ path = sysdrv + 'hubber'
+ assert '\\' in nt._getfullpathname(path)
+ assert type(nt._getfullpathname(b'C:')) is bytes
class AppTestEnvironment(object):
def setup_class(cls):
diff --git a/pypy/tool/pytest/apptest.py b/pypy/tool/pytest/apptest.py
index 8ed3584817..da3e3a7ffe 100644
--- a/pypy/tool/pytest/apptest.py
+++ b/pypy/tool/pytest/apptest.py
@@ -31,6 +31,9 @@ RENAMED_USEMODULES = {
'signal': '_signal',
'imp': '_imp'}
+if sys.platform == 'win32':
+ RENAMED_USEMODULES['posix'] = 'nt'
+
class AppError(Exception):
def __init__(self, excinfo):
self.excinfo = excinfo
diff --git a/rpython/rlib/rwinreg.py b/rpython/rlib/rwinreg.py
index 7f45088ba3..4628804faf 100644
--- a/rpython/rlib/rwinreg.py
+++ b/rpython/rlib/rwinreg.py
@@ -49,71 +49,75 @@ PHKEY = rffi.CArrayPtr(HKEY)
REGSAM = rwin32.DWORD
def get_traits(suffix):
+ if suffix == 'A':
+ strp = rffi.CCHARP
+ else:
+ strp = rffi.CWCHARP
RegSetValue = external(
'RegSetValue' + suffix,
- [HKEY, rffi.CCHARP, rwin32.DWORD, rffi.CCHARP, rwin32.DWORD],
+ [HKEY, strp, rwin32.DWORD, strp, rwin32.DWORD],
rffi.LONG)
RegSetValueEx = external(
'RegSetValueEx' + suffix,
- [HKEY, rffi.CCHARP, rwin32.DWORD,
- rwin32.DWORD, rffi.CCHARP, rwin32.DWORD],
+ [HKEY, strp, rwin32.DWORD,
+ rwin32.DWORD, strp, rwin32.DWORD],
rffi.LONG)
RegQueryValue = external(
'RegQueryValue' + suffix,
- [HKEY, rffi.CCHARP, rffi.CCHARP, rwin32.PLONG],
+ [HKEY, strp, strp, rwin32.PLONG],
rffi.LONG)
RegQueryValueEx = external(
'RegQueryValueEx' + suffix,
- [HKEY, rffi.CCHARP, rwin32.LPDWORD, rwin32.LPDWORD,
- rffi.CCHARP, rwin32.LPDWORD],
+ [HKEY, strp, rwin32.LPDWORD, rwin32.LPDWORD,
+ strp, rwin32.LPDWORD],
rffi.LONG)
RegCreateKey = external(
'RegCreateKey' + suffix,
- [HKEY, rffi.CCHARP, PHKEY],
+ [HKEY, strp, PHKEY],
rffi.LONG)
RegCreateKeyEx = external(
'RegCreateKeyEx' + suffix,
- [HKEY, rffi.CCHARP, rwin32.DWORD, rffi.CCHARP, rwin32.DWORD,
+ [HKEY, strp, rwin32.DWORD, strp, rwin32.DWORD,
REGSAM, rffi.VOIDP, PHKEY, rwin32.LPDWORD],
rffi.LONG)
RegDeleteValue = external(
'RegDeleteValue' + suffix,
- [HKEY, rffi.CCHARP],
+ [HKEY, strp],
rffi.LONG)
RegDeleteKey = external(
'RegDeleteKey' + suffix,
- [HKEY, rffi.CCHARP],
+ [HKEY, strp],
rffi.LONG)
RegOpenKeyEx = external(
'RegOpenKeyEx' + suffix,
- [HKEY, rffi.CCHARP, rwin32.DWORD, REGSAM, PHKEY],
+ [HKEY, strp, rwin32.DWORD, REGSAM, PHKEY],
rffi.LONG)
RegEnumValue = external(
'RegEnumValue' + suffix,
- [HKEY, rwin32.DWORD, rffi.CCHARP,
+ [HKEY, rwin32.DWORD, strp,
rwin32.LPDWORD, rwin32.LPDWORD, rwin32.LPDWORD,
rffi.CCHARP, rwin32.LPDWORD],
rffi.LONG)
RegEnumKeyEx = external(
'RegEnumKeyEx' + suffix,
- [HKEY, rwin32.DWORD, rffi.CCHARP,
+ [HKEY, rwin32.DWORD, strp,
rwin32.LPDWORD, rwin32.LPDWORD,
- rffi.CCHARP, rwin32.LPDWORD, rwin32.PFILETIME],
+ strp, rwin32.LPDWORD, rwin32.PFILETIME],
rffi.LONG)
RegQueryInfoKey = external(
'RegQueryInfoKey' + suffix,
- [HKEY, rffi.CCHARP, rwin32.LPDWORD, rwin32.LPDWORD,
+ [HKEY, strp, rwin32.LPDWORD, rwin32.LPDWORD,
rwin32.LPDWORD, rwin32.LPDWORD, rwin32.LPDWORD,
rwin32.LPDWORD, rwin32.LPDWORD, rwin32.LPDWORD,
rwin32.LPDWORD, rwin32.PFILETIME],
@@ -121,17 +125,17 @@ def get_traits(suffix):
RegLoadKey = external(
'RegLoadKey' + suffix,
- [HKEY, rffi.CCHARP, rffi.CCHARP],
+ [HKEY, strp, strp],
rffi.LONG)
RegSaveKey = external(
'RegSaveKey' + suffix,
- [HKEY, rffi.CCHARP, rffi.VOIDP],
+ [HKEY, strp, rffi.VOIDP],
rffi.LONG)
RegConnectRegistry = external(
'RegConnectRegistry' + suffix,
- [rffi.CCHARP, HKEY, PHKEY],
+ [strp, HKEY, PHKEY],
rffi.LONG)
return (RegSetValue, RegSetValueEx, RegQueryValue, RegQueryValueEx,