classification
Title: python cannot parse tcl value
Type: behavior Stage: resolved
Components: Tkinter Versions: Python 3.4, Python 3.5, Python 2.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: serhiy.storchaka Nosy List: python-dev, schwab, serhiy.storchaka
Priority: normal Keywords: patch

Created on 2014-06-29 19:38 by schwab, last changed 2014-07-07 12:29 by serhiy.storchaka. This issue is now closed.

Files
File name Uploaded Description Edit
test_tcl_nan.patch serhiy.storchaka, 2014-07-05 07:42 review
Messages (10)
msg221887 - (view) Author: Andreas Schwab (schwab) * Date: 2014-06-29 19:38
Lib/test/test_tcl.py fails with:

test test_tcl failed -- Traceback (most recent call last):
  File "/home/abuild/rpmbuild/BUILD/Python-2.7.7/Lib/test/test_tcl.py", line 430
, in test_user_command
    check(float('nan'), 'NaN', eq=nan_eq)
  File "/home/abuild/rpmbuild/BUILD/Python-2.7.7/Lib/test/test_tcl.py", line 397
, in check
    eq(result[0], expected2)
  File "/home/abuild/rpmbuild/BUILD/Python-2.7.7/Lib/test/test_tcl.py", line 405
, in nan_eq
    actual = float(actual)
ValueError: invalid literal for float(): NaN(7ffffffffffff)
msg221947 - (view) Author: Ned Deily (ned.deily) * (Python committer) Date: 2014-06-30 08:07
What version of Tcl are you using and on what platform?
msg221973 - (view) Author: Andreas Schwab (schwab) * Date: 2014-06-30 18:22
You will see this on any architecture where the canonical NaN has all bits set (or a subset of them).  This include mips and m68k.
msg222297 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2014-07-04 17:35
Interesting, what result of getdouble?

>>> import _tkinter
>>> tk = _tkinter.create()
>>> nan = float('nan')
>>> tk.getdouble(nan)
nan

What returns getdouble() (note that _tkinter is imported instead of tkinter!) for NaN value?
msg222299 - (view) Author: Andreas Schwab (schwab) * Date: 2014-07-04 18:06
>>> _tkinter.create().getdouble(float('nan'))
nan
msg222340 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2014-07-05 07:42
Here is a patch which omits using of float() to convert Tcl's NaN values.
msg222345 - (view) Author: Andreas Schwab (schwab) * Date: 2014-07-05 10:11
Thanks, this is working now.
msg222445 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2014-07-07 10:48
New changeset 4514804d0e50 by Serhiy Storchaka in branch '2.7':
Issue #21881: Be more tolerant in test_tcl to not parsable by float() NaN
http://hg.python.org/cpython/rev/4514804d0e50

New changeset 4879f6337ef6 by Serhiy Storchaka in branch '3.4':
Issue #21881: Be more tolerant in test_tcl to not parsable by float() NaN
http://hg.python.org/cpython/rev/4879f6337ef6

New changeset 72289f574664 by Serhiy Storchaka in branch 'default':
Issue #21881: Be more tolerant in test_tcl to not parsable by float() NaN
http://hg.python.org/cpython/rev/72289f574664
msg222455 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2014-07-07 12:20
New changeset 01ec8bb7187f by Serhiy Storchaka in branch '2.7':
Issue #21881: Just omit tests for platform-specific NaN representation in test_tcl.
http://hg.python.org/cpython/rev/01ec8bb7187f

New changeset 5ac811cbec87 by Serhiy Storchaka in branch '3.4':
Issue #21881: Just omit tests for platform-specific NaN representation in test_tcl.
http://hg.python.org/cpython/rev/5ac811cbec87

New changeset f138a74ee611 by Serhiy Storchaka in branch 'default':
Issue #21881: Just omit tests for platform-specific NaN representation in test_tcl.
http://hg.python.org/cpython/rev/f138a74ee611
msg222456 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2014-07-07 12:29
On some platforms NaN representation has a minus before "nan" (see http://buildbot.python.org/all/builders/x86%20OpenIndiana%202.7/builds/2384/steps/test/logs/stdio). So it is easier just omit tests for these platform-specific values.

Regardless of the fact that it is very unlikely to get NaN in Tk, in future we should fix getdouble() (it should work with Tcl_Obj) and use it everywhere in tkinter instead of float().
History
Date User Action Args
2014-07-07 12:29:41serhiy.storchakasetstatus: open -> closed
resolution: fixed
messages: + msg222456

stage: patch review -> resolved
2014-07-07 12:20:20python-devsetmessages: + msg222455
2014-07-07 10:48:30python-devsetnosy: + python-dev
messages: + msg222445
2014-07-05 10:11:38schwabsetmessages: + msg222345
2014-07-05 07:42:14serhiy.storchakasetfiles: + test_tcl_nan.patch
keywords: + patch
messages: + msg222340

stage: needs patch -> patch review
2014-07-04 18:06:10schwabsetmessages: + msg222299
2014-07-04 17:35:46serhiy.storchakasetassignee: serhiy.storchaka
messages: + msg222297
2014-06-30 19:18:44ned.deilysetnosy: - ned.deily
stage: needs patch

versions: + Python 3.4, Python 3.5
2014-06-30 18:22:14schwabsetmessages: + msg221973
2014-06-30 08:07:25ned.deilysetnosy: + serhiy.storchaka, ned.deily
messages: + msg221947
2014-06-29 19:38:46schwabcreate