﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
35187	@sensitive_variables/sensitive_post_parameters decorators crash with .pyc-only builds.	Marcus Hoffmann	Mariusz Felisiak	"Since upgrading django to version 5.0.1 (5.0 untested currently) in [https://buildroot.org/ buildroot] (an embedded rootfs build toolkit) django stopped working correctly in the buildroot default configuration. By default buildroot compiles all installed python modules to .pyc files and removes the .py files.

There's been some discussion around this but the conclusion seems to be, that this is an officially supported way of running cpython: https://github.com/python/cpython/issues/95827

Here's a test run output of creating a new django project and invoking manage.py from it inside a minmal buildroot created image: https://gitlab.com/buildroot.org/buildroot/-/jobs/6148209453#L181

Creating the project works but manage.py fails with:

{{{
Traceback (most recent call last):
  File ""/opt/testsite/./manage.py"", line 22, in <module>
    main()
  File ""/opt/testsite/./manage.py"", line 18, in main
    execute_from_command_line(sys.argv)
  File ""/usr/lib/python3.12/site-packages/django/core/management/__init__.py"", line 442, in execute_from_command_line
  File ""/usr/lib/python3.12/site-packages/django/core/management/__init__.py"", line 416, in execute
  File ""/usr/lib/python3.12/site-packages/django/__init__.py"", line 24, in setup
  File ""/usr/lib/python3.12/site-packages/django/apps/registry.py"", line 91, in populate
  File ""/usr/lib/python3.12/site-packages/django/apps/config.py"", line 193, in create
  File ""/usr/lib/python3.12/importlib/__init__.py"", line 90, in import_module
  File ""<frozen importlib._bootstrap>"", line 1387, in _gcd_import
  File ""<frozen importlib._bootstrap>"", line 1360, in _find_and_load
  File ""<frozen importlib._bootstrap>"", line 1331, in _find_and_load_unlocked
  File ""<frozen importlib._bootstrap>"", line 935, in _load_unlocked
  File ""<frozen importlib._bootstrap_external>"", line 994, in exec_module
  File ""<frozen importlib._bootstrap>"", line 488, in _call_with_frames_removed
  File ""/usr/lib/python3.12/site-packages/django/contrib/admin/__init__.py"", line 2, in <module>
  File ""/usr/lib/python3.12/site-packages/django/contrib/admin/filters.py"", line 12, in <module>
  File ""/usr/lib/python3.12/site-packages/django/contrib/admin/options.py"", line 33, in <module>
  File ""/usr/lib/python3.12/site-packages/django/contrib/auth/__init__.py"", line 96, in <module>
  File ""/usr/lib/python3.12/site-packages/django/views/decorators/debug.py"", line 50, in decorator
  File ""/usr/lib/python3.12/inspect.py"", line 1264, in getsourcelines
  File ""/usr/lib/python3.12/inspect.py"", line 1093, in findsource
OSError: could not get source code
}}}

This seems to specifically fail somewhere in loading contrib.auth, if I remove (in a local test) both the 'django.contrib.admin' and 'django.contrib.auth' apps from the list of installed apps then manage.py starts to work correctly."	Bug	closed	Core (Other)	5.0	Release blocker	fixed		Marcus Hoffmann William Schwartz Jon Janzen	Accepted	1	0	0	0	0	0
