Author: martin.v.loewis
Date: Mon Jun 18 05:17:19 2007
New Revision: 56015

Modified:
   python/branches/p3yk/PC/_winreg.c
Log:
Expect long objects for DWORD values.

Modified: python/branches/p3yk/PC/_winreg.c
==============================================================================
--- python/branches/p3yk/PC/_winreg.c   (original)
+++ python/branches/p3yk/PC/_winreg.c   Mon Jun 18 05:17:19 2007
@@ -693,9 +693,10 @@
 Py2Reg(PyObject *value, DWORD typ, BYTE **retDataBuf, DWORD *retDataSize)
 {
        int i,j;
+       DWORD d;
        switch (typ) {
                case REG_DWORD:
-                       if (value != Py_None && !PyInt_Check(value))
+                       if (value != Py_None && !PyLong_Check(value))
                                return FALSE;
                        *retDataBuf = (BYTE *)PyMem_NEW(DWORD, 1);
                        if (*retDataBuf==NULL){
@@ -707,10 +708,10 @@
                                DWORD zero = 0;
                                memcpy(*retDataBuf, &zero, sizeof(DWORD));
                        }
-                       else
-                               memcpy(*retDataBuf,
-                                      &PyInt_AS_LONG((PyIntObject *)value),
-                                      sizeof(DWORD));
+                       else {
+                               d = PyLong_AsLong(value);
+                               memcpy(*retDataBuf, &d, sizeof(DWORD));
+                       }
                        break;
                case REG_SZ:
                case REG_EXPAND_SZ:
_______________________________________________
Python-3000-checkins mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-3000-checkins

Reply via email to