# Buggy code
def _read_windows_registry(target_path):  # pragma: no cover
    # HKEY_LOCAL_MACHINE\Software\Microsoft\Command Processor\AutoRun
    # HKEY_CURRENT_USER\Software\Microsoft\Command Processor\AutoRun
    # returns value_value, value_type  -or-  None, None if target does not exist
    main_key, the_rest = target_path.split("\\", 1)
    subkey_str, value_name = the_rest.rsplit("\\", 1)
    main_key = getattr(winreg, main_key)

    try:
        key = winreg.OpenKey(main_key, subkey_str, 0, winreg.KEY_READ)
    except EnvironmentError as e:
        if e.errno != ENOENT:
            raise
        return None, None

    try:
        value_tuple = winreg.QueryValueEx(key, value_name)
        value_value = value_tuple[0].strip()
        value_type = value_tuple[1]
        return value_value, value_type
    except Exception:
        # [WinError 2] The system cannot find the file specified
        winreg.CloseKey(key)
        return None, None
    finally:
        winreg.CloseKey(key)


# Traceback (ValueError)
# >>>>>>>>>>>>>>>>>>>>>> ERROR REPORT <<<<<<<<<<<<<<<<<<<<<<

Traceback (most recent call last):
File "c:\users\wani\downloads\repos\conda\conda\exceptions.py", line 1001, in __call__
return func(*args, **kwargs)
File "c:\users\wani\downloads\repos\conda\conda\cli\main.py", line 84, in _main
exit_code = do_call(args, p)
File "c:\users\wani\downloads\repos\conda\conda\cli\conda_argparse.py", line 81, in do_call
exit_code = getattr(module, func_name)(args, parser)
File "c:\users\wani\downloads\repos\conda\conda\cli\main_init.py", line 52, in execute
anaconda_prompt)
File "c:\users\wani\downloads\repos\conda\conda\core\initialize.py", line 106, in initialize
run_plan(plan2)
File "c:\users\wani\downloads\repos\conda\conda\core\initialize.py", line 552, in run_plan
result = globals()[step['function']](*step.get('args', ()), **step.get('kwargs', {}))
File "c:\users\wani\downloads\repos\conda\conda\core\initialize.py", line 1196, in init_long_path
_write_windows_registry(target_path, "1", winreg.REG_DWORD)
File "c:\users\wani\downloads\repos\conda\conda\core\initialize.py", line 1143, in _write_windows_registry
winreg.SetValueEx(key, value_name, 0, value_type, value_value)
ValueError: Could not convert the data to the specified type.

`$ C:\ProgramData\MinicondaX\Scripts\conda-script.py init --system cmd.exe`

# Fixed code
def _read_windows_registry(target_path):  # pragma: no cover
    # HKEY_LOCAL_MACHINE\Software\Microsoft\Command Processor\AutoRun
    # HKEY_CURRENT_USER\Software\Microsoft\Command Processor\AutoRun
    # returns value_value, value_type  -or-  None, None if target does not exist
    main_key, the_rest = target_path.split("\\", 1)
    subkey_str, value_name = the_rest.rsplit("\\", 1)
    main_key = getattr(winreg, main_key)

    try:
        key = winreg.OpenKey(main_key, subkey_str, 0, winreg.KEY_READ)
    except EnvironmentError as e:
        if e.errno != ENOENT:
            raise
        return None, None

    try:
        value_tuple = winreg.QueryValueEx(key, value_name)
        value_value = value_tuple[0]
        if isinstance(value_value, str):
            value_value = value_value.strip()
        value_type = value_tuple[1]
        return value_value, value_type
    except Exception:
        # [WinError 2] The system cannot find the file specified
        winreg.CloseKey(key)
        return None, None
    finally:
        winreg.CloseKey(key)