summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorSteven Bethard <steven.bethard@gmail.com>2008-03-18 22:08:20 (GMT)
committerSteven Bethard <steven.bethard@gmail.com>2008-03-18 22:08:20 (GMT)
commit6a644f92efb35e75f81d183aebfff3260b1454e2 (patch)
tree47f1242459fa09e9087f58fdf7b935042e8ec9d0 /Lib
parente8e22cf3c0d9e977bc9f13cfc535c026f92bc7aa (diff)
downloadcpython-6a644f92efb35e75f81d183aebfff3260b1454e2.zip
cpython-6a644f92efb35e75f81d183aebfff3260b1454e2.tar.gz
cpython-6a644f92efb35e75f81d183aebfff3260b1454e2.tar.bz2
Add py3k warnings for code and method inequality comparisons. This should resolve issue 2373. The codeobject.c and methodobject.c changes are both just backports of the Python 3 code.
Diffstat (limited to 'Lib')
-rw-r--r--Lib/test/test_py3kwarn.py29
1 files changed, 29 insertions, 0 deletions
diff --git a/Lib/test/test_py3kwarn.py b/Lib/test/test_py3kwarn.py
index 61de7a2..cdb1038 100644
--- a/Lib/test/test_py3kwarn.py
+++ b/Lib/test/test_py3kwarn.py
@@ -50,6 +50,35 @@ class TestPy3KWarnings(unittest.TestCase):
with catch_warning() as w:
self.assertWarning(cell0 < cell1, w, expected)
+ def test_code_inequality_comparisons(self):
+ expected = 'code inequality comparisons not supported in 3.x.'
+ def f(x):
+ pass
+ def g(x):
+ pass
+ with catch_warning() as w:
+ self.assertWarning(f.func_code < g.func_code, w, expected)
+ with catch_warning() as w:
+ self.assertWarning(f.func_code <= g.func_code, w, expected)
+ with catch_warning() as w:
+ self.assertWarning(f.func_code >= g.func_code, w, expected)
+ with catch_warning() as w:
+ self.assertWarning(f.func_code > g.func_code, w, expected)
+
+ def test_builtin_function_or_method_comparisons(self):
+ expected = ('builtin_function_or_method '
+ 'inequality comparisons not supported in 3.x.')
+ func = eval
+ meth = {}.get
+ with catch_warning() as w:
+ self.assertWarning(func < meth, w, expected)
+ with catch_warning() as w:
+ self.assertWarning(func > meth, w, expected)
+ with catch_warning() as w:
+ self.assertWarning(meth <= func, w, expected)
+ with catch_warning() as w:
+ self.assertWarning(meth >= func, w, expected)
+
def assertWarning(self, _, warning, expected_message):
self.assertEqual(str(warning.message), expected_message)