Lines Matching +full:hook +full:- +full:run +full:- +full:in +full:- +full:context
11 """Hook to write a warning to a file; replace if you like."""
25 # sys.stderr is None when run with pythonw.exe:
32 # the file (probably stderr) is invalid - this warning gets lost.
74 for frame in tb:
97 """Hook to write a warning to a file; replace if you like."""
134 'action' -- one of "error", "ignore", "always", "default", "module",
136 'message' -- a regex that the warning message must match
137 'category' -- a class that the warning must be a subclass of
138 'module' -- a regex that the module name must match
139 'lineno' -- an integer line number, 0 matches all warnings
140 'append' -- if true, append to the list of filters
142 assert action in ("error", "ignore", "always", "default", "module",
169 'action' -- one of "error", "ignore", "always", "default", "module",
171 'category' -- a class that the warning must be a subclass of
172 'lineno' -- an integer line number, 0 matches all warnings
173 'append' -- if true, append to the list of filters
175 assert action in ("error", "ignore", "always", "default", "module",
183 # in correct place. If append=True and duplicate exists, do nothing.
191 if item not in filters:
204 # Helper to process -W options passed via sys.warnoptions
206 for arg in args:
210 print("Invalid -W option ignored:", msg, file=sys.stderr)
220 for s in parts]
245 for a in ('default', 'always', 'ignore', 'module', 'once', 'error'):
254 if '.' not in category:
275 return 'importlib' in filename and '_bootstrap' in filename
298 # Get context information
301 # If frame is too small to care or if the warning originated in
307 for x in range(stacklevel-1):
319 if '__name__' in globals:
333 if module[-3:].lower() == ".py":
334 module = module[:-3] # XXX What about leading pathname?
351 for item in filters:
364 # Prime the linecache for formatting, in case the
365 # "file" is actually in a zipfile or something.
391 "Unrecognized action (%r) in warnings.filters:\n %s" %
393 # Print message and context
422 """A context manager that copies and restores the warnings filter upon
423 exiting the context.
427 returned by the context manager. Otherwise None is returned by the context
442 keyword-only.
494 for filename, lineno, funcname in reversed(coro.cr_origin):
504 # partially-redundant tracebacks. If we wanted to be clever we could
509 # filters contains a sequence of filter 5-tuples
510 # The components of the 5-tuple are:
511 # - an action: error, ignore, always, default, module, or once
512 # - a compiled regex that must match the warning message
513 # - a class representing the warning category
514 # - a compiled regex that must match the module that is being warned
515 # - a line number for the line being warning, or 0 to mean any line
540 # Several warning categories are ignored by default in regular builds