File tree 1 file changed +5
-13
lines changed
1 file changed +5
-13
lines changed Original file line number Diff line number Diff line change @@ -670,13 +670,11 @@ def _get_origin() -> str | None:
670
670
671
671
# Try to use topmost `self.origin` first (Django 1.9+, and with
672
672
# TEMPLATE_DEBUG)..
673
- for f in stack [2 :]:
674
- func = f [3 ]
675
- if func == "render" :
676
- frame = f [0 ]
673
+ for frame_info in stack [2 :]:
674
+ if frame_info .function == "render" :
677
675
origin : str | None
678
676
try :
679
- origin = frame .f_locals ["self" ].origin
677
+ origin = frame_info . frame .f_locals ["self" ].origin
680
678
except (AttributeError , KeyError ):
681
679
origin = None
682
680
if origin is not None :
@@ -686,16 +684,10 @@ def _get_origin() -> str | None:
686
684
687
685
# finding the ``render`` needle in the stack
688
686
frameinfo = reduce (
689
- lambda x , y : y [ 3 ] == "render" and "base.py" in y [ 1 ] and y or x , stack
687
+ lambda x , y : y if y . function == "render" and "base.py" in y . filename else x , stack
690
688
)
691
- # assert 0, stack
692
- frame = frameinfo [0 ]
693
- # finding only the frame locals in all frame members
694
- f_locals = reduce (
695
- lambda x , y : y [0 ] == "f_locals" and y or x , inspect .getmembers (frame )
696
- )[1 ]
697
689
# ``django.template.base.Template``
698
- template = f_locals ["self" ]
690
+ template = frameinfo . frame . f_locals ["self" ]
699
691
if isinstance (template , Template ):
700
692
name : str = template .name
701
693
return name
You can’t perform that action at this time.
0 commit comments