Lines Matching +full:helper +full:- +full:module +full:- +full:imports
3 # Note: function level imports should *not* be used
4 # in this module as it may cause import lock deadlock.
18 Warnings are omitted unless Python is started with the -3 option.
30 # sys.stderr is None - warnings get lost
35 pass # the file (probably stderr) is invalid - this warning gets lost.
67 def filterwarnings(action, message="", category=Warning, module="", lineno=0, argument
71 'action' -- one of "error", "ignore", "always", "default", "module",
73 'message' -- a regex that the warning message must match
74 'category' -- a class that the warning must be a subclass of
75 'module' -- a regex that the module name must match
76 'lineno' -- an integer line number, 0 matches all warnings
77 'append' -- if true, append to the list of filters
80 assert action in ("error", "ignore", "always", "default", "module",
86 assert isinstance(module, basestring), "module must be a string"
90 re.compile(module), int(lineno))
100 'action' -- one of "error", "ignore", "always", "default", "module",
102 'category' -- a class that the warning must be a subclass of
103 'lineno' -- an integer line number, 0 matches all warnings
104 'append' -- if true, append to the list of filters
106 assert action in ("error", "ignore", "always", "default", "module",
124 # Helper to process -W options passed via sys.warnoptions
130 print >>sys.stderr, "Invalid -W option ignored:", msg
132 # Helper for _processoptions()
140 action, message, category, module, lineno = [s.strip()
145 module = re.escape(module)
146 if module:
147 module = module + '$'
157 filterwarnings(action, message, category, module, lineno)
159 # Helper for _setoption()
164 for a in ('default', 'always', 'ignore', 'module', 'once', 'error'):
169 # Helper for _setoption()
174 if re.match("^[a-zA-Z0-9_]+$", category):
181 module = category[:i]
184 m = __import__(module, None, None, [klass])
186 raise _OptionError("invalid module name: %r" % (module,))
216 module = globals['__name__']
218 module = "<string>"
223 filename = filename[:-1]
225 if module == "__main__":
232 filename = module
234 warn_explicit(message, category, filename, lineno, module, registry,
238 module=None, registry=None, module_globals=None): argument
240 if module is None:
241 module = filename or "<unknown>"
242 if module[-3:].lower() == ".py":
243 module = module[:-3] # XXX What about leading pathname?
261 (mod is None or mod.match(module)) and
286 elif action == "module":
337 The 'module' argument is to specify an alternative module to the module
339 when testing the warnings module itself.
343 def __init__(self, record=False, module=None): argument
344 """Specify whether to record warnings and if an alternative module
348 keyword-only.
352 self._module = sys.modules['warnings'] if module is None else module
360 args.append("module=%r" % self._module)
387 # filters contains a sequence of filter 5-tuples
388 # The components of the 5-tuple are:
389 # - an action: error, ignore, always, default, module, or once
390 # - a compiled regex that must match the warning message
391 # - a class representing the warning category
392 # - a compiled regex that must match the module that is being warned
393 # - a line number for the line being warning, or 0 to mean any line
408 # Module initialization
412 # Don't silence DeprecationWarning if -3 or -Q was used.