summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTim Peters <tim.peters@gmail.com>2006-02-19 04:05:39 (GMT)
committerTim Peters <tim.peters@gmail.com>2006-02-19 04:05:39 (GMT)
commit313fcd41abdb9f31f745e6554828de5a6cb5d150 (patch)
tree3b22ac8175a4279f512eefe979c8d4c255284168
parentd9ab979f3696cec37fd51cfa5a45ec898a133698 (diff)
downloadcpython-313fcd41abdb9f31f745e6554828de5a6cb5d150.zip
cpython-313fcd41abdb9f31f745e6554828de5a6cb5d150.tar.gz
cpython-313fcd41abdb9f31f745e6554828de5a6cb5d150.tar.bz2
PyEnumKey(): Stop including the trailing NUL byte
in the returned string (logic error introduced by recent patch).
-rw-r--r--PC/_winreg.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/PC/_winreg.c b/PC/_winreg.c
index b80271d..007885c 100644
--- a/PC/_winreg.c
+++ b/PC/_winreg.c
@@ -832,9 +832,9 @@ Py2Reg(PyObject *value, DWORD typ, BYTE **retDataBuf, DWORD *retDataSize)
void *src_buf;
PyBufferProcs *pb = value->ob_type->tp_as_buffer;
if (pb==NULL) {
- PyErr_Format(PyExc_TypeError,
+ PyErr_Format(PyExc_TypeError,
"Objects of type '%s' can not "
- "be used as binary registry values",
+ "be used as binary registry values",
value->ob_type->tp_name);
return FALSE;
}
@@ -1039,14 +1039,13 @@ PyEnumKey(PyObject *self, PyObject *args)
return NULL;
if (!PyHKEY_AsHKEY(obKey, &hKey, FALSE))
return NULL;
-
+
Py_BEGIN_ALLOW_THREADS
rc = RegEnumKeyEx(hKey, index, tmpbuf, &len, NULL, NULL, NULL, NULL);
Py_END_ALLOW_THREADS
if (rc != ERROR_SUCCESS)
return PyErr_SetFromWindowsErrWithFunction(rc, "RegEnumKeyEx");
-
- ++len; /* include null terminator */
+
retStr = PyString_FromStringAndSize(tmpbuf, len);
return retStr; /* can be NULL */
}