summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTres Seaver <tseaver@palladion.com>2012-05-22 20:00:35 +0000
committerTres Seaver <tseaver@palladion.com>2012-05-22 20:00:35 +0000
commit5147747a00d7b680e0972a2e80098c4273a88289 (patch)
tree04b585f906569242046f7e1c68d0fa0fb2821a86
parent74c589cd62c6c204fbe6c7836577fa127f2a3b19 (diff)
downloadzope-interface-5147747a00d7b680e0972a2e80098c4273a88289.tar.gz
Drop explicit DeprecationWarnings for "class advice" APIS
These APIs are still deprecated under Python 2.x, and still raise an exception under Python 3.x, but no longer cause a warning to be emitted under Python 2.x.
-rw-r--r--CHANGES.txt5
-rw-r--r--src/zope/interface/declarations.py9
-rw-r--r--src/zope/interface/tests/test_declarations.py28
3 files changed, 13 insertions, 29 deletions
diff --git a/CHANGES.txt b/CHANGES.txt
index 7f08db6..1b1d919 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -4,7 +4,10 @@
4.0.1 (unreleased)
------------------
-- TBA
+- Dropped explicit ``DeprecationWarnings`` for "class advice" APIS (these
+ APIs are still deprecated under Python 2.x, and still raise an exception
+ under Python 3.x, but no longer cause a warning to be emitted under
+ Python 2.x).
4.0.0 (2012-05-16)
------------------
diff --git a/src/zope/interface/declarations.py b/src/zope/interface/declarations.py
index 8ed43b3..0992adc 100644
--- a/src/zope/interface/declarations.py
+++ b/src/zope/interface/declarations.py
@@ -402,9 +402,6 @@ def implements(*interfaces):
# the coverage for this block there. :(
if PYTHON3: #pragma NO COVER
raise TypeError(_ADVICE_ERROR % 'implementer')
- else:
- warnings.warn(_ADVICE_WARNING % ('implements', 'implementer'),
- DeprecationWarning, 2)
_implements("implements", interfaces, classImplements)
def implementsOnly(*interfaces):
@@ -433,9 +430,6 @@ def implementsOnly(*interfaces):
# the coverage for this block there. :(
if PYTHON3: #pragma NO COVER
raise TypeError(_ADVICE_ERROR % 'implementer_only')
- else:
- warnings.warn(_ADVICE_WARNING % ('implementsOnly', 'implementer_only'),
- DeprecationWarning, 2)
_implements("implementsOnly", interfaces, classImplementsOnly)
##############################################################################
@@ -642,9 +636,6 @@ def classProvides(*interfaces):
if PYTHON3: #pragma NO COVER
raise TypeError(_ADVICE_ERROR % 'provider')
- else:
- warnings.warn(_ADVICE_WARNING % ('classProvides', 'provider'),
- DeprecationWarning, 2)
frame = sys._getframe(1)
locals = frame.f_locals
diff --git a/src/zope/interface/tests/test_declarations.py b/src/zope/interface/tests/test_declarations.py
index a2f120e..49991d0 100644
--- a/src/zope/interface/tests/test_declarations.py
+++ b/src/zope/interface/tests/test_declarations.py
@@ -34,17 +34,14 @@ class _Py3ClassAdvice(object):
def _run_generated_code(self, code, globs, locs,
fails_under_py3k=True,
- warnings_under_py2=1):
+ ):
import warnings
from zope.interface._compat import PYTHON3
with warnings.catch_warnings(record=True) as log:
warnings.resetwarnings()
if not PYTHON3:
exec(code, globs, locs)
- if warnings_under_py2:
- self.assertEqual(len(log), warnings_under_py2)
- for entry in log:
- self.assertEqual(entry.category, DeprecationWarning)
+ self.assertEqual(len(log), 0) # no longer warn
return True
else:
try:
@@ -677,8 +674,7 @@ class Test_implementsOnly(_SilencePy3Deprecations, _Py3ClassAdvice):
Foo = locs['Foo']
spec = Foo.__implemented__
self.assertEqual(list(spec), [IFoo])
- self.assertEqual(len(log), 1)
- self.assertEqual(log[0].category, DeprecationWarning)
+ self.assertEqual(len(log), 0) # no longer warn
def test_called_once_from_class_w_bases(self):
from zope.interface.declarations import implements
@@ -698,7 +694,7 @@ class Test_implementsOnly(_SilencePy3Deprecations, _Py3ClassAdvice):
'class Bar(Foo):'
' implementsOnly(IBar)',
])
- if self._run_generated_code(CODE, globs, locs, warnings_under_py2=2):
+ if self._run_generated_code(CODE, globs, locs):
Bar = locs['Bar']
spec = Bar.__implemented__
self.assertEqual(list(spec), [IBar])
@@ -721,13 +717,12 @@ class Test_implements(_SilencePy3Deprecations, _Py3ClassAdvice):
'def foo():',
' implements(IFoo)'
])
- if self._run_generated_code(CODE, globs, locs, False, 0):
+ if self._run_generated_code(CODE, globs, locs, False):
foo = locs['foo']
with warnings.catch_warnings(record=True) as log:
warnings.resetwarnings()
self.assertRaises(TypeError, foo)
- self.assertEqual(len(log), 1)
- self.assertEqual(log[0].category, DeprecationWarning)
+ self.assertEqual(len(log), 0) # no longer warn
def test_called_twice_from_class(self):
import warnings
@@ -749,9 +744,7 @@ class Test_implements(_SilencePy3Deprecations, _Py3ClassAdvice):
exec(CODE, globs, locs)
except TypeError:
if not PYTHON3:
- self.assertEqual(len(log), 2)
- for entry in log:
- self.assertEqual(entry.category, DeprecationWarning)
+ self.assertEqual(len(log), 0) # no longer warn
else:
self.fail("Didn't raise TypeError")
@@ -1155,8 +1148,7 @@ class Test_classProvides(_SilencePy3Deprecations, _Py3ClassAdvice):
warnings.resetwarnings()
self.assertRaises(TypeError, foo)
if not PYTHON3:
- self.assertEqual(len(log), 1)
- self.assertEqual(log[0].category, DeprecationWarning)
+ self.assertEqual(len(log), 0) # no longer warn
def test_called_twice_from_class(self):
import warnings
@@ -1178,9 +1170,7 @@ class Test_classProvides(_SilencePy3Deprecations, _Py3ClassAdvice):
exec(CODE, globs, locs)
except TypeError:
if not PYTHON3:
- self.assertEqual(len(log), 2)
- for entry in log:
- self.assertEqual(entry.category, DeprecationWarning)
+ self.assertEqual(len(log), 0) # no longer warn
else:
self.fail("Didn't raise TypeError")