#35187: Django 5.0+ doesn't work with pyc files only ---------------------------------+-------------------------------------- Reporter: Marcus Hoffmann | Owner: nobody Type: Bug | Status: new Component: Core (Other) | Version: 5.0 Severity: Normal | Resolution: Keywords: | Triage Stage: Unreviewed Has patch: 0 | Needs documentation: 0 Needs tests: 0 | Patch needs improvement: 0 Easy pickings: 0 | UI/UX: 0 ---------------------------------+-------------------------------------- Comment (by Mariusz Felisiak):
Replying to [comment:6 Jon Janzen]: > I think there are alternatives, I don't really have time to explore them right now but: > > 1. Use a different cache key, like swap the line number for the function name perhaps Great idea! Marcus, does it work for you? {{{#!diff diff --git a/django/views/decorators/debug.py b/django/views/decorators/debug.py index 7ea8a540de..6540fc0651 100644 --- a/django/views/decorators/debug.py +++ b/django/views/decorators/debug.py @@ -47,7 +47,6 @@ def sensitive_variables(*variables): try: file_path = inspect.getfile(wrapped_func) - _, first_file_line = inspect.getsourcelines(wrapped_func) except TypeError: # Raises for builtins or native functions. raise ValueError( f"{func.__name__} cannot safely be wrapped by " @@ -55,7 +54,8 @@ def sensitive_variables(*variables): "Python file (not a builtin or from a native extension)." ) else: - key = hash(f"{file_path}:{first_file_line}") + first_line_number = wrapped_func.__code__.co_firstlineno + key = hash(f"{file_path}:{first_line_number}") if variables: coroutine_functions_to_sensitive_variables[key] = variables }}} -- Ticket URL: <https://code.djangoproject.com/ticket/35187#comment:7> 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 django-updates+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/0107018dab2e2642-2bbe3354-8d46-4a28-83ad-9b07005a73a5-000000%40eu-central-1.amazonses.com.