#33580: Initialization of Django fails when emulated in Wine
-------------------------------------+-------------------------------------
Reporter: | Owner: nobody
jochemfranken |
Type: Bug | Status: new
Component: Core | Version: 3.2
(Management commands) |
Severity: Normal | Keywords: wine, color
Triage Stage: | Has patch: 1
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
From version 3.2 and onwards, when running management commands, the
registry is searched for the key 'Console'. In emulated environments (via
Wine) this fails as the key is nonexistent.
{{{
Traceback (most recent call last):
File "C:\python38\lib\site-packages\django\core\management\__init__.py",
line 375, in execute
autoreload.check_errors(django.setup)()
File "C:\python38\lib\site-packages\django\utils\autoreload.py", line
64, in wrapper
fn(*args, **kwargs)
File "C:\python38\lib\site-packages\django\__init__.py", line 19, in
setup
configure_logging(settings.LOGGING_CONFIG, settings.LOGGING)
File "C:\python38\lib\site-packages\django\utils\log.py", line 71, in
configure_logging
logging.config.dictConfig(DEFAULT_LOGGING)
File "C:\python38\lib\logging\config.py", line 808, in dictConfig
dictConfigClass(config).configure()
File "C:\python38\lib\logging\config.py", line 545, in configure
raise ValueError('Unable to configure '
ValueError: Unable to configure formatter 'django.server'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "manage.py", line 22, in <module>
main()
File "manage.py", line 18, in main
execute_from_command_line(sys.argv)
File "C:\python38\lib\site-packages\django\core\management\__init__.py",
line 419, in execute_from_command_line
utility.execute()
File "C:\python38\lib\site-packages\django\core\management\__init__.py",
line 388, in execute
_parser = self.fetch_command('runserver').create_parser('django',
'runserver')
File "C:\python38\lib\site-packages\django\core\management\__init__.py",
line 257, in fetch_command
klass = load_command_class(app_name, subcommand)
File "C:\python38\lib\site-packages\django\core\management\__init__.py",
line 40, in load_command_class
return module.Command()
File "C:\python38\lib\site-packages\django\core\management\base.py",
line 251, in __init__
self.style = color_style(force_color)
File "C:\python38\lib\site-packages\django\core\management\color.py",
line 105, in color_style
if not force_color and not supports_color():
File "C:\python38\lib\site-packages\django\core\management\color.py",
line 55, in supports_color
vt_codes_enabled_in_windows_registry()
File "C:\python38\lib\site-packages\django\core\management\color.py",
line 36, in vt_codes_enabled_in_windows_registry
reg_key = winreg.OpenKey(winreg.HKEY_CURRENT_USER, 'Console')
FileNotFoundError: [WinError 2] File not found
}}}
The code block where the error happens is:
{{{
def vt_codes_enabled_in_windows_registry():
"""
Check the Windows Registry to see if VT code handling has been
enabled
by default, see https://superuser.com/a/1300251/447564.
"""
try:
# winreg is only available on Windows.
import winreg
except ImportError:
return False
else:
reg_key = winreg.OpenKey(winreg.HKEY_CURRENT_USER, "Console")
# ERROR
try:
reg_key_value, _ = winreg.QueryValueEx(reg_key,
"VirtualTerminalLevel")
except FileNotFoundError:
return False
else:
return reg_key_value == 1
}}}
Moving the indicated line into the try/except block fixes the error.
--
Ticket URL: <https://code.djangoproject.com/ticket/33580>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/0107017f930b84c5-473d0180-abbd-4b5e-83a9-82621264aef2-000000%40eu-central-1.amazonses.com.