summaryrefslogtreecommitdiffstats
path: root/Lib/warnings.py
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2001-02-28 21:43:40 (GMT)
committerGuido van Rossum <guido@python.org>2001-02-28 21:43:40 (GMT)
commit9e2631897539a95f1413df00847544487fb3b827 (patch)
tree1a31c6f471d05f148c0b907a5fe642354d0a8582 /Lib/warnings.py
parentd6a1d79d167db2bed280d055039afdb1a91e5e57 (diff)
downloadcpython-9e2631897539a95f1413df00847544487fb3b827.zip
cpython-9e2631897539a95f1413df00847544487fb3b827.tar.gz
cpython-9e2631897539a95f1413df00847544487fb3b827.tar.bz2
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.
Diffstat (limited to 'Lib/warnings.py')
-rw-r--r--Lib/warnings.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/Lib/warnings.py b/Lib/warnings.py
index 9763dc6..9de64bb 100644
--- a/Lib/warnings.py
+++ b/Lib/warnings.py
@@ -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