Merge pull request #50063 from twangboy/fix_50039

Use long when setting REG_QWORD
This commit is contained in:
Nicole Thomas 2018-10-25 09:45:02 -04:00 committed by GitHub
commit 9ad43f2b71
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 71 additions and 0 deletions

View File

@ -767,6 +767,9 @@ def cast_vdata(vdata=None, vtype='REG_SZ'):
# Make sure REG_MULTI_SZ is a list of strings
elif vtype_value == win32con.REG_MULTI_SZ:
return [_to_unicode(i) for i in vdata]
# Make sure REG_QWORD is a 64 bit integer
elif vtype_value == win32con.REG_QWORD:
return vdata if six.PY3 else long(vdata) # pylint: disable=W1699
# Everything else is int
else:
return int(vdata)

View File

@ -307,6 +307,74 @@ class WinFunctionsTestCase(TestCase):
finally:
win_reg.delete_key_recursive(hive='HKLM', key=FAKE_KEY)
@destructiveTest
def test_set_value_reg_dword(self):
'''
Test the set_value function on a unicode value
'''
try:
self.assertTrue(
win_reg.set_value(
hive='HKLM',
key=FAKE_KEY,
vname='dword_value',
vdata=123,
vtype='REG_DWORD'
)
)
expected = {
'hive': 'HKLM',
'key': FAKE_KEY,
'success': True,
'vdata': 123,
'vname': 'dword_value',
'vtype': 'REG_DWORD'
}
self.assertEqual(
win_reg.read_value(
hive='HKLM',
key=FAKE_KEY,
vname='dword_value'
),
expected
)
finally:
win_reg.delete_key_recursive(hive='HKLM', key=FAKE_KEY)
@destructiveTest
def test_set_value_reg_qword(self):
'''
Test the set_value function on a unicode value
'''
try:
self.assertTrue(
win_reg.set_value(
hive='HKLM',
key=FAKE_KEY,
vname='qword_value',
vdata=123,
vtype='REG_QWORD'
)
)
expected = {
'hive': 'HKLM',
'key': FAKE_KEY,
'success': True,
'vdata': 123,
'vname': 'qword_value',
'vtype': 'REG_QWORD'
}
self.assertEqual(
win_reg.read_value(
hive='HKLM',
key=FAKE_KEY,
vname='qword_value'
),
expected
)
finally:
win_reg.delete_key_recursive(hive='HKLM', key=FAKE_KEY)
@destructiveTest
def test_delete_value(self):
'''