]> granicus.if.org Git - python/commitdiff
PyEnumKey(): Stop including the trailing NUL byte
authorTim Peters <tim.peters@gmail.com>
Sun, 19 Feb 2006 04:05:39 +0000 (04:05 +0000)
committerTim Peters <tim.peters@gmail.com>
Sun, 19 Feb 2006 04:05:39 +0000 (04:05 +0000)
in the returned string (logic error introduced by
recent patch).

PC/_winreg.c

index b80271d6039401063182fc69cdd2af68b941ac81..007885c679de1f5324742ab78f9003091eb562e9 100644 (file)
@@ -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 */
 }