[Python-checkins] r86688 - in python/branches/py3k-cdecimal: Lib/test/decimal_tests.py Modules/cdecimal/cdecimal.c
stefan.krah
python-checkins at python.org
Mon Nov 22 12:21:20 CET 2010
Author: stefan.krah
Date: Mon Nov 22 12:21:20 2010
New Revision: 86688
Log:
Issue #10356: TypeError is more practical.
Modified:
python/branches/py3k-cdecimal/Lib/test/decimal_tests.py
python/branches/py3k-cdecimal/Modules/cdecimal/cdecimal.c
Modified: python/branches/py3k-cdecimal/Lib/test/decimal_tests.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/test/decimal_tests.py (original)
+++ python/branches/py3k-cdecimal/Lib/test/decimal_tests.py Mon Nov 22 12:21:20 2010
@@ -1671,7 +1671,7 @@
#the same hash that to an int
self.assertEqual(hashit(Decimal(23)), hashit(23))
- self.assertRaises(ValueError, hash, Decimal('sNaN'))
+ self.assertRaises(TypeError, hash, Decimal('sNaN'))
self.assertTrue(hashit(Decimal('Inf')))
self.assertTrue(hashit(Decimal('-Inf')))
Modified: python/branches/py3k-cdecimal/Modules/cdecimal/cdecimal.c
==============================================================================
--- python/branches/py3k-cdecimal/Modules/cdecimal/cdecimal.c (original)
+++ python/branches/py3k-cdecimal/Modules/cdecimal/cdecimal.c Mon Nov 22 12:21:20 2010
@@ -3947,7 +3947,7 @@
if (mpd_isspecial(a->dec)) {
if (mpd_isnan(a->dec)) {
- PyErr_SetString(PyExc_ValueError,
+ PyErr_SetString(PyExc_TypeError,
"cannot hash a NaN value");
result = -1;
}
@@ -4075,8 +4075,9 @@
if (mpd_isspecial(DecAddr(v))) {
if (mpd_issnan(DecAddr(v))) {
- return value_error_int(
+ PyErr_SetString(PyExc_TypeError,
"Cannot hash a signaling NaN value.");
+ return -1;
}
else if (mpd_isnan(DecAddr(v))) {
return py_hash_nan;
More information about the Python-checkins
mailing list