[Django] #33580: Initialization of Django fails when emulated in Wine

2 views
Skip to first unread message

Django

unread,
Mar 16, 2022, 10:04:43 AM3/16/22
to django-...@googlegroups.com
#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.

Django

unread,
Mar 16, 2022, 10:18:45 AM3/16/22
to django-...@googlegroups.com
#33580: Initialization of Django fails when emulated in Wine
-------------------------------------+-------------------------------------
Reporter: jochemfranken | Owner:
| jochemfranken
Type: Bug | Status: assigned
Component: Core (Management | Version: 3.2
commands) |
Severity: Normal | Resolution:

Keywords: wine, color | Triage Stage:
| Unreviewed
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by jochemfranken):

* owner: nobody => jochemfranken
* status: new => assigned


Comment:

See pull request: [https://github.com/django/django/pull/15517]

--
Ticket URL: <https://code.djangoproject.com/ticket/33580#comment:1>

Django

unread,
Mar 16, 2022, 10:29:30 AM3/16/22
to django-...@googlegroups.com
#33580: Initialization of Django fails when emulated in Wine
-------------------------------------+-------------------------------------
Reporter: Jochem Franken | Owner: Jochem
| Franken

Type: Bug | Status: assigned
Component: Core (Management | Version: 3.2
commands) |
Severity: Normal | Resolution:
Keywords: wine, color | Triage Stage: Accepted

Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak):

* stage: Unreviewed => Accepted


Comment:

I didn't reproduce this issue locally, but it looks valid.

--
Ticket URL: <https://code.djangoproject.com/ticket/33580#comment:2>

Django

unread,
Mar 16, 2022, 10:58:16 AM3/16/22
to django-...@googlegroups.com
#33580: Initialization of Django fails when emulated in Wine
-------------------------------------+-------------------------------------
Reporter: Jochem Franken | Owner: Jochem
| Franken
Type: Bug | Status: assigned
Component: Core (Management | Version: 3.2
commands) |
Severity: Normal | Resolution:
Keywords: wine, color | Triage Stage: Ready for
| checkin

Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak):

* stage: Accepted => Ready for checkin


--
Ticket URL: <https://code.djangoproject.com/ticket/33580#comment:3>

Django

unread,
Mar 16, 2022, 11:17:29 AM3/16/22
to django-...@googlegroups.com
#33580: Initialization of Django fails when emulated in Wine
-------------------------------------+-------------------------------------
Reporter: Jochem Franken | Owner: Jochem
| Franken
Type: Bug | Status: closed

Component: Core (Management | Version: 3.2
commands) |
Severity: Normal | Resolution: fixed

Keywords: wine, color | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by GitHub <noreply@…>):

* status: assigned => closed
* resolution: => fixed


Comment:

In [changeset:"5f9ad17201981b7160df23747239cf3512a60edd" 5f9ad172]:
{{{
#!CommitTicketReference repository=""
revision="5f9ad17201981b7160df23747239cf3512a60edd"
Fixed #33580 -- Fixed crash when checking support for terminal colors on
Wine.

Regression in f1585c54d0242d71cdc63421f751528472b1c9c2.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/33580#comment:4>

Reply all
Reply to author
Forward
0 new messages