#35187: @sensitive_variables/sensitive_post_parameters decorators crash with 
.pyc-
only builds.
---------------------------------+------------------------------------
     Reporter:  Marcus Hoffmann  |                    Owner:  nobody
         Type:  Bug              |                   Status:  new
    Component:  Core (Other)     |                  Version:  5.0
     Severity:  Release blocker  |               Resolution:
     Keywords:                   |             Triage Stage:  Accepted
    Has patch:  0                |      Needs documentation:  0
  Needs tests:  0                |  Patch needs improvement:  0
Easy pickings:  0                |                    UI/UX:  0
---------------------------------+------------------------------------
Comment (by Marcus Hoffmann):

 Replying to [comment:7 Mariusz Felisiak]:
 > 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
 >
 > }}}

 Thanks for the patch, I'll try and test this tomorrow!
-- 
Ticket URL: <https://code.djangoproject.com/ticket/35187#comment:9>
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/0107018dae5c5e0e-056123f6-0f8f-4bda-ae70-6357c4995c04-000000%40eu-central-1.amazonses.com.

Reply via email to