[Python-checkins] r84500 - in python/branches/py3k: Lib/warnings.py Misc/NEWS Python/_warnings.c
brett.cannon
python-checkins at python.org
Sat Sep 4 20:24:04 CEST 2010
Author: brett.cannon
Date: Sat Sep 4 20:24:04 2010
New Revision: 84500
Log:
_warnings exposed two variables with the name 'default_action' and
'once_registry'. This is bad as the warnings module had variables named
'defaultaction' and 'onceregistry' which are what people should be looking at
(technically those variables shouldn't be mucked with as they are undocumented,
but we all know better than to believe that isn't happening). So the variables
from _warnings have been renamed to come off as private and to avoid confusion
over what variable should be used.
Closes issue #9766. Thanks to Antoine Pitrou for the discovery.
Modified:
python/branches/py3k/Lib/warnings.py
python/branches/py3k/Misc/NEWS
python/branches/py3k/Python/_warnings.c
Modified: python/branches/py3k/Lib/warnings.py
==============================================================================
--- python/branches/py3k/Lib/warnings.py (original)
+++ python/branches/py3k/Lib/warnings.py Sat Sep 4 20:24:04 2010
@@ -357,10 +357,10 @@
# If either if the compiled regexs are None, match anything.
_warnings_defaults = False
try:
- from _warnings import (filters, default_action, once_registry,
+ from _warnings import (filters, _defaultaction, _onceregistry,
warn, warn_explicit)
- defaultaction = default_action
- onceregistry = once_registry
+ defaultaction = _defaultaction
+ onceregistry = _onceregistry
_warnings_defaults = True
except ImportError:
filters = []
Modified: python/branches/py3k/Misc/NEWS
==============================================================================
--- python/branches/py3k/Misc/NEWS (original)
+++ python/branches/py3k/Misc/NEWS Sat Sep 4 20:24:04 2010
@@ -12,6 +12,9 @@
Core and Builtins
-----------------
+- Issue #9766: Rename poorly named variables exposed by _warnings to prevent
+ confusion with the proper variables names from 'warnings' itself.
+
- Issue #9212: dict_keys and dict_items now provide the isdisjoint()
method, to conform to the Set ABC. Patch by Daniel Urban.
Modified: python/branches/py3k/Python/_warnings.c
==============================================================================
--- python/branches/py3k/Python/_warnings.c (original)
+++ python/branches/py3k/Python/_warnings.c Sat Sep 4 20:24:04 2010
@@ -945,13 +945,13 @@
if (_once_registry == NULL)
return NULL;
Py_INCREF(_once_registry);
- if (PyModule_AddObject(m, "once_registry", _once_registry) < 0)
+ if (PyModule_AddObject(m, "_onceregistry", _once_registry) < 0)
return NULL;
_default_action = PyUnicode_FromString("default");
if (_default_action == NULL)
return NULL;
- if (PyModule_AddObject(m, "default_action", _default_action) < 0)
+ if (PyModule_AddObject(m, "_defaultaction", _default_action) < 0)
return NULL;
return m;
}
More information about the Python-checkins
mailing list