# Buggy code
def get_win_os_version():
    """
    Get's the OS major and minor versions.  Returns a tuple of
    (OS_MAJOR, OS_MINOR).
    """
    import ctypes

    class _OSVERSIONINFOEXW(ctypes.Structure):
        _fields_ = [
            ("dwOSVersionInfoSize", ctypes.c_ulong),
            ("dwMajorVersion", ctypes.c_ulong),
            ("dwMinorVersion", ctypes.c_ulong),
            ("dwBuildNumber", ctypes.c_ulong),
            ("dwPlatformId", ctypes.c_ulong),
            ("szCSDVersion", ctypes.c_wchar * 128),
            ("wServicePackMajor", ctypes.c_ushort),
            ("wServicePackMinor", ctypes.c_ushort),
            ("wSuiteMask", ctypes.c_ushort),
            ("wProductType", ctypes.c_byte),
            ("wReserved", ctypes.c_byte),
        ]

    os_version = _OSVERSIONINFOEXW()
    os_version.dwOSVersionInfoSize = ctypes.sizeof(os_version)
    retcode = ctypes.windll.Ntdll.RtlGetVersion(ctypes.byref(os_version))
    if retcode != 0:
        return None

    return Version("%d.%d" % (os_version.dwMajorVersion, os_version.dwMinorVersion))


# Traceback (AttributeError)
$ conan profile new xxx --detect
ERROR: Error detecting os_info
Traceback (most recent call last):
File "/usr/lib/python3.6/site-packages/conans/client/command.py", line 1495, in run
method(args[0][1:])
File "/usr/lib/python3.6/site-packages/conans/client/command.py", line 1307, in profile
self._conan.create_profile(profile, args.detect)
File "/usr/lib/python3.6/site-packages/conans/client/conan_api.py", line 88, in wrapper
return f(*args, **kwargs)
File "/usr/lib/python3.6/site-packages/conans/client/conan_api.py", line 894, in create_profile
self._user_io.out, detect)
File "/usr/lib/python3.6/site-packages/conans/client/cmd/profile.py", line 41, in cmd_profile_create
settings = detect_defaults_settings(output)
File "/usr/lib/python3.6/site-packages/conans/client/conf/detect.py", line 200, in detect_defaults_settings
_detect_os_arch(result, output)
File "/usr/lib/python3.6/site-packages/conans/client/conf/detect.py", line 178, in _detect_os_arch
the_os = detected_os()
File "/usr/lib/python3.6/site-packages/conans/client/tools/oss.py", line 37, in detected_os
if OSInfo().is_macos:
File "/usr/lib/python3.6/site-packages/conans/client/tools/oss.py", line 115, in __init__
self.os_version = self.get_win_os_version()
File "/usr/lib/python3.6/site-packages/conans/client/tools/oss.py", line 187, in get_win_os_version
retcode = ctypes.windll.Ntdll.RtlGetVersion(ctypes.byref(os_version))
AttributeError: module 'ctypes' has no attribute 'windll'

# Fixed code
def get_win_os_version():
    """
    Get's the OS major and minor versions.  Returns a tuple of
    (OS_MAJOR, OS_MINOR).
    """
    import ctypes

    class _OSVERSIONINFOEXW(ctypes.Structure):
        _fields_ = [
            ("dwOSVersionInfoSize", ctypes.c_ulong),
            ("dwMajorVersion", ctypes.c_ulong),
            ("dwMinorVersion", ctypes.c_ulong),
            ("dwBuildNumber", ctypes.c_ulong),
            ("dwPlatformId", ctypes.c_ulong),
            ("szCSDVersion", ctypes.c_wchar * 128),
            ("wServicePackMajor", ctypes.c_ushort),
            ("wServicePackMinor", ctypes.c_ushort),
            ("wSuiteMask", ctypes.c_ushort),
            ("wProductType", ctypes.c_byte),
            ("wReserved", ctypes.c_byte),
        ]

    os_version = _OSVERSIONINFOEXW()
    os_version.dwOSVersionInfoSize = ctypes.sizeof(os_version)
    if not hasattr(ctypes, "windll"):
        return None
    retcode = ctypes.windll.Ntdll.RtlGetVersion(ctypes.byref(os_version))
    if retcode != 0:
        return None

    return Version("%d.%d" % (os_version.dwMajorVersion, os_version.dwMinorVersion))