Skip to content

Commit a21c13f

Browse files
committed
Allow ints to be used for REQ_QWORD registry values (fixes mhammond#1398)
1 parent 285c0ca commit a21c13f

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

win32/src/win32apimodule.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3508,12 +3508,13 @@ static BOOL PyWinObject_AsRegistryValue(PyObject *value, DWORD typ, BYTE **retDa
35083508
*(ULONGLONG *)*retDataBuf = 0;
35093509
return true;
35103510
}
3511-
*(ULONGLONG *)*retDataBuf = PyLong_AsUnsignedLongLong(value);
3512-
if (*(ULONGLONG *)*retDataBuf == -1 && PyErr_Occurred()) {
3511+
ULARGE_INTEGER uli;
3512+
if (!PyWinObject_AsULARGE_INTEGER(value, &uli)) {
35133513
PyMem_Free(*retDataBuf);
35143514
*retDataBuf = NULL;
35153515
return false;
35163516
}
3517+
*(ULONGLONG *)*retDataBuf = uli.QuadPart;
35173518
return true;
35183519
case REG_SZ:
35193520
case REG_EXPAND_SZ: {

win32/test/test_win32api.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ def testValues(self):
7171
('REG_MULTI_SZ', win32con.REG_MULTI_SZ, ['string 1','string 2','string 3','string 4']),
7272
('REG_MULTI_SZ_empty', win32con.REG_MULTI_SZ, []),
7373
('REG_DWORD', win32con.REG_DWORD, 666),
74+
('REG_QWORD_INT', win32con.REG_QWORD, 99),
7475
('REG_QWORD', win32con.REG_QWORD, 2**33),
7576
('REG_BINARY', win32con.REG_BINARY, str2bytes('\x00\x01\x02\x03\x04\x05\x06\x07\x08\x01\x00')),
7677
)

0 commit comments

Comments
 (0)