Kaydet (Commit) 9e263189 authored tarafından Guido van Rossum's avatar Guido van Rossum

Add a new API:

    warn_explicit(message, category, filename, lineno, module, registry)

The regular warn() call calculates a bunch of values and calls
warn_explicit() with these.

This will be used to issue better syntax warnings.
üst d6a1d79d
......@@ -34,6 +34,16 @@ def warn(message, category=None, stacklevel=1):
filename = module
# Quick test for common case
registry = globals.setdefault("__warningregistry__", {})
warn_explicit(message, category, filename, lineno, module, registry)
def warn_explicit(message, category, filename, lineno,
module=None, registry=None):
if module is None:
module = filename
if module[-3:].lower() == ".py":
module = module[:-3] # XXX What about leading pathname?
if registry is None:
registry = {}
key = (message, category, lineno)
if registry.get(key):
return
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment