0001-Fixed-sensitive_variables-sensitive_post.patch 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. From d294b7679f2cb51c7231d6a7fb22e76eb74e49ec Mon Sep 17 00:00:00 2001
  2. From: Mariusz Felisiak <felisiak.mariusz@gmail.com>
  3. Date: Sat, 17 Feb 2024 08:15:59 +0100
  4. Subject: [PATCH] Fixed #35187 -- Fixed
  5. @sensitive_variables/sensitive_post_parameters decorators crash with
  6. .pyc-only builds.
  7. Thanks Jon Janzen for the implementation idea.
  8. Thanks Marcus Hoffmann for the report.
  9. Regression in 38e391e95fe5258bc6d2467332dc9cd44ce6ba52.
  10. Backport of d1be05b3e9209fd0787841c71a95819d81061187 from main
  11. Signed-off-by: Marcus Hoffmann <buildroot@bubu1.eu>
  12. Upstream: https://github.com/django/django/commit/41a4bba817f139f3cfd94f04e728e046560c9a18
  13. ---
  14. django/views/decorators/debug.py | 4 ++--
  15. 1 file changed, 2 insertions(+), 2 deletions(-)
  16. diff --git a/django/views/decorators/debug.py b/django/views/decorators/debug.py
  17. index 7ea8a540de..6540fc0651 100644
  18. --- a/django/views/decorators/debug.py
  19. +++ b/django/views/decorators/debug.py
  20. @@ -47,7 +47,6 @@ def sensitive_variables(*variables):
  21. try:
  22. file_path = inspect.getfile(wrapped_func)
  23. - _, first_file_line = inspect.getsourcelines(wrapped_func)
  24. except TypeError: # Raises for builtins or native functions.
  25. raise ValueError(
  26. f"{func.__name__} cannot safely be wrapped by "
  27. @@ -55,7 +54,8 @@ def sensitive_variables(*variables):
  28. "Python file (not a builtin or from a native extension)."
  29. )
  30. else:
  31. - key = hash(f"{file_path}:{first_file_line}")
  32. + first_line_number = wrapped_func.__code__.co_firstlineno
  33. + key = hash(f"{file_path}:{first_line_number}")
  34. if variables:
  35. coroutine_functions_to_sensitive_variables[key] = variables
  36. --
  37. 2.34.1