# Buggy code
def __init__(self):
    self.hkeys = {
        "HKEY_CURRENT_USER": _winreg.HKEY_CURRENT_USER,
        "HKEY_LOCAL_MACHINE": _winreg.HKEY_LOCAL_MACHINE,
        "HKEY_USERS": _winreg.HKEY_USERS,
        "HKCU": _winreg.HKEY_CURRENT_USER,
        "HKLM": _winreg.HKEY_LOCAL_MACHINE,
        "HKU": _winreg.HKEY_USERS,
    }
    self.vtype = {
        "REG_BINARY": _winreg.REG_BINARY,
        "REG_DWORD": _winreg.REG_DWORD,
        "REG_EXPAND_SZ": _winreg.REG_EXPAND_SZ,
        "REG_MULTI_SZ": _winreg.REG_MULTI_SZ,
        "REG_SZ": _winreg.REG_SZ,
    }
    self.opttype = {
        "REG_OPTION_NON_VOLATILE": _winreg.REG_OPTION_NON_VOLATILE,
        "REG_OPTION_VOLATILE": _winreg.REG_OPTION_VOLATILE,
    }
    # Return Unicode due to from __future__ import unicode_literals
    self.vtype_reverse = {
        _winreg.REG_BINARY: "REG_BINARY",
        _winreg.REG_DWORD: "REG_DWORD",
        _winreg.REG_EXPAND_SZ: "REG_EXPAND_SZ",
        _winreg.REG_MULTI_SZ: "REG_MULTI_SZ",
        _winreg.REG_SZ: "REG_SZ",
    }
    self.opttype_reverse = {
        _winreg.REG_OPTION_NON_VOLATILE: "REG_OPTION_NON_VOLATILE",
        _winreg.REG_OPTION_VOLATILE: "REG_OPTION_VOLATILE",
    }
    # delete_key_recursive uses this to check the subkey contains enough \
    # as we do not want to remove all or most of the registry
    self.subkey_slash_check = {
        _winreg.HKEY_CURRENT_USER: 0,
        _winreg.HKEY_LOCAL_MACHINE: 1,
        _winreg.HKEY_USERS: 1,
    }

    self.registry_32 = {
        True: _winreg.KEY_READ | _winreg.KEY_WOW64_32KEY,
        False: _winreg.KEY_READ,
    }


# Traceback (CommandExecutionError)
windows_host:
----------
ID: lgpo_test
Function: lgpo.set
Result: False
Comment: An exception occurred in this state: Traceback (most recent call last):
File "c:\salt\bin\lib\site-packages\salt\state.py", line 1765, in call
**cdata['kwargs'])
File "c:\salt\bin\lib\site-packages\salt\loader.py", line 1705, in wrapper
return f(*args, **kwargs)
File "c:\salt\bin\lib\site-packages\salt\states\win_lgpo.py", line 294, in set_
adml_language=adml_language)
File "c:\salt\bin\lib\site-packages\salt\modules\win_lgpo.py", line 5348, in set_
raise CommandExecutionError(msg.format(regedit))
CommandExecutionError: Error while attempting to set policy Domain controller: Allow server operators to schedule tasks via the registry.  Some changes may not be applied as expected
Started: 15:33:50.693000
Duration: 1578.0 ms
Changes:

Summary for windoze
------------
Succeeded: 0
Failed:    1

# Fixed code
def __init__(self):
    self.hkeys = {
        "HKEY_CURRENT_USER": win32con.HKEY_CURRENT_USER,
        "HKEY_LOCAL_MACHINE": win32con.HKEY_LOCAL_MACHINE,
        "HKEY_USERS": win32con.HKEY_USERS,
        "HKCU": win32con.HKEY_CURRENT_USER,
        "HKLM": win32con.HKEY_LOCAL_MACHINE,
        "HKU": win32con.HKEY_USERS,
    }
    self.vtype = {
        "REG_BINARY": win32con.REG_BINARY,
        "REG_DWORD": win32con.REG_DWORD,
        "REG_EXPAND_SZ": win32con.REG_EXPAND_SZ,
        "REG_MULTI_SZ": win32con.REG_MULTI_SZ,
        "REG_SZ": win32con.REG_SZ,
        "REG_QWORD": win32con.REG_QWORD,
    }
    self.opttype = {"REG_OPTION_NON_VOLATILE": 0, "REG_OPTION_VOLATILE": 1}
    # Return Unicode due to from __future__ import unicode_literals
    self.vtype_reverse = {
        win32con.REG_BINARY: "REG_BINARY",
        win32con.REG_DWORD: "REG_DWORD",
        win32con.REG_EXPAND_SZ: "REG_EXPAND_SZ",
        win32con.REG_MULTI_SZ: "REG_MULTI_SZ",
        win32con.REG_SZ: "REG_SZ",
        win32con.REG_QWORD: "REG_QWORD",
    }
    self.opttype_reverse = {0: "REG_OPTION_NON_VOLATILE", 1: "REG_OPTION_VOLATILE"}
    # delete_key_recursive uses this to check the subkey contains enough \
    # as we do not want to remove all or most of the registry
    self.subkey_slash_check = {
        win32con.HKEY_CURRENT_USER: 0,
        win32con.HKEY_LOCAL_MACHINE: 1,
        win32con.HKEY_USERS: 1,
    }

    self.registry_32 = {
        True: win32con.KEY_READ | win32con.KEY_WOW64_32KEY,
        False: win32con.KEY_READ,
    }