[Python-checkins] r68908 - in python/branches/py3k: Lib/pickletools.py Lib/test/pickletester.py Misc/NEWS Modules/_pickle.c

mark.dickinson python-checkins at python.org
Sat Jan 24 22:46:34 CET 2009


Author: mark.dickinson
Date: Sat Jan 24 22:46:33 2009
New Revision: 68908
Log:
Merged revisions 68903,68906 via svnmerge from 
svn+ssh://pythondev@svn.python.org/python/trunk
........
 r68903 | mark.dickinson | 2009年01月24日 16:40:29 +0000 (2009年1月24日) | 5 lines
 
 Issue #1672332: Fix unpickling of subnormal floats, which was raising
 ValueError on some platforms as a result of the platform strtod setting
 errno on underflow.
........
 r68906 | mark.dickinson | 2009年01月24日 21:08:38 +0000 (2009年1月24日) | 2 lines
 
 Issue #3657: fix occasional test_pickletools failures.
........
Modified:
 python/branches/py3k/ (props changed)
 python/branches/py3k/Lib/pickletools.py
 python/branches/py3k/Lib/test/pickletester.py
 python/branches/py3k/Misc/NEWS
 python/branches/py3k/Modules/_pickle.c
Modified: python/branches/py3k/Lib/pickletools.py
==============================================================================
--- python/branches/py3k/Lib/pickletools.py	(original)
+++ python/branches/py3k/Lib/pickletools.py	Sat Jan 24 22:46:33 2009
@@ -2128,11 +2128,11 @@
 
 Exercise the INST/OBJ/BUILD family.
 
->>> import random
->>> dis(pickle.dumps(random.getrandbits, 0))
- 0: c GLOBAL 'random getrandbits'
- 20: p PUT 0
- 23: . STOP
+>>> import pickletools
+>>> dis(pickle.dumps(pickletools.dis, 0))
+ 0: c GLOBAL 'pickletools dis'
+ 17: p PUT 0
+ 20: . STOP
 highest protocol among opcodes = 0
 
 >>> from pickletools import _Example
Modified: python/branches/py3k/Lib/test/pickletester.py
==============================================================================
--- python/branches/py3k/Lib/test/pickletester.py	(original)
+++ python/branches/py3k/Lib/test/pickletester.py	Sat Jan 24 22:46:33 2009
@@ -545,6 +545,16 @@
 got = self.loads(p)
 self.assertEqual(n, got)
 
+ def test_float(self):
+ test_values = [0.0, 4.94e-324, 1e-310, 7e-308, 6.626e-34, 0.1, 0.5,
+ 3.14, 263.44582062374053, 6.022e23, 1e30]
+ test_values = test_values + [-x for x in test_values]
+ for proto in protocols:
+ for value in test_values:
+ pickle = self.dumps(value, proto)
+ got = self.loads(pickle)
+ self.assertEqual(value, got)
+
 @run_with_locale('LC_ALL', 'de_DE', 'fr_FR')
 def test_float_format(self):
 # make sure that floats are formatted locale independent with proto 0
Modified: python/branches/py3k/Misc/NEWS
==============================================================================
--- python/branches/py3k/Misc/NEWS	(original)
+++ python/branches/py3k/Misc/NEWS	Sat Jan 24 22:46:33 2009
@@ -139,6 +139,9 @@
 Library
 -------
 
+- Issue #1672332: fix unpickling of subnormal floats, which was
+ producing a ValueError on some platforms.
+
 - Issue #3881: Help Tcl to load even when started through the
 unreadable local symlink to "Program Files" on Vista.
 
Modified: python/branches/py3k/Modules/_pickle.c
==============================================================================
--- python/branches/py3k/Modules/_pickle.c	(original)
+++ python/branches/py3k/Modules/_pickle.c	Sat Jan 24 22:46:33 2009
@@ -2958,7 +2958,8 @@
 errno = 0;
 d = PyOS_ascii_strtod(s, &endptr);
 
- if (errno || (endptr[0] != '\n') || (endptr[1] != '0円')) {
+ if ((errno == ERANGE && !(fabs(d) <= 1.0)) ||
+ (endptr[0] != '\n') || (endptr[1] != '0円')) {
 PyErr_SetString(PyExc_ValueError, "could not convert string to float");
 return -1;
 }


More information about the Python-checkins mailing list

AltStyle によって変換されたページ (->オリジナル) /