File tree Expand file tree Collapse file tree 1 file changed +9
-9
lines changed Expand file tree Collapse file tree 1 file changed +9
-9
lines changed Original file line number Diff line number Diff line change @@ -504,17 +504,17 @@ def __enter__(self):
504504 self ._module ._filters_mutated_lock_held ()
505505 self ._showwarning = self ._module .showwarning
506506 self ._showwarnmsg_impl = self ._module ._showwarnmsg_impl
507+ if self ._record :
508+ log = []
509+ self ._module ._showwarnmsg_impl = log .append
510+ # Reset showwarning() to the default implementation to make sure
511+ # that _showwarnmsg() calls _showwarnmsg_impl()
512+ self ._module .showwarning = self ._module ._showwarning_orig
513+ else :
514+ log = None
507515 if self ._filter is not None :
508516 simplefilter (* self ._filter )
509- if self ._record :
510- log = []
511- self ._module ._showwarnmsg_impl = log .append
512- # Reset showwarning() to the default implementation to make sure
513- # that _showwarnmsg() calls _showwarnmsg_impl()
514- self ._module .showwarning = self ._module ._showwarning_orig
515- return log
516- else :
517- return None
517+ return log
518518
519519 def __exit__ (self , * exc_info ):
520520 if not self ._entered :
You can’t perform that action at this time.
0 commit comments