[issue10647] scrollbar crash in non-US locale format settings

2011-07-01 Thread Hans Bering

Hans Bering  added the comment:

I have been able to reproduce this problem with a current Python 3.2 + tcl/tk 
on Ubuntu. I have attached a script which should crash with the following 
output & stacktrace (you might have to find & set a suitable locale depending 
on your OS):

locale = ('de_DE', 'UTF8')
Traceback (most recent call last):
  File "tkinterCrash.py", line 20, in 
tkcanvas = Canvas(master=master, width=w, height=2, borderwidth=4)
  File "/usr/lib/python3.2/tkinter/__init__.py", line 2101, in __init__
Widget.__init__(self, master, 'canvas', cnf, kw)
  File "/usr/lib/python3.2/tkinter/__init__.py", line 1961, in __init__
(widgetName, self._w) + extra + self._options(cnf))
_tkinter.TclError: bad screen distance "10.0"

The problem seems to stem from the fact that tkinter passes the "width" option 
through regardless of what it is (you can set w to the string "hello" to get 
the same error), and somewhere below (in tk, I guess?), the option argument is 
tentatively parsed as a number using the system's numeric locale.

Originally, we stumbled over this problem when using matplotlib, which 
passes/passed down float types as width arguments on occasions. It has been 
fixed there since (see https://github.com/matplotlib/matplotlib/pull/387).

It's the locale dependency which can make this difficult to debug when it 
occurs. In our setup, we had a program running on one machine, and then it 
crashed on the next, which we believed to have an identical setup; it took us a 
day to figure out what the difference was.

--
nosy: +hans.bering
Added file: http://bugs.python.org/file22535/tkinterCrash.py

___
Python tracker 
<http://bugs.python.org/issue10647>
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue10647] scrollbar crash in non-US locale format settings

2011-07-05 Thread Hans Bering

Hans Bering  added the comment:

I'm sorry, but it seems the issue described in my previous edit (msg139566) is 
perhaps not related to the original Scrollbar problem. I had thought they were 
because of the superficial resemblance (i.e., crashes due to locale-dependent 
float handling for integer arguments), but I cannot reproduce the Scollbar 
problem.

Sorry for any inconvenience; is it possible to delete my entries? I would then 
submit them as an independent issue.

--

___
Python tracker 
<http://bugs.python.org/issue10647>
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue10647] scrollbar crash in non-US locale format settings

2011-07-07 Thread Hans Bering

Hans Bering  added the comment:

Ok, _now_ I have run into the same problem. I have attached a small script 
similar to the original entry (but shorter) which will reliably crash with 
Python 3.1.4 on Windows 7 (64bit) when using a locale with a comma decimal 
fraction marker (e.g., German). The stacktrace is as follows:

Exception in Tkinter callback
Traceback (most recent call last):
  File "C:\Python31\lib\tkinter\__init__.py", line 1400, in __call__
return self.func(*args)
  File "C:\Python31\lib\tkinter\__init__.py", line 2799, in set
self.tk.call((self._w, 'set') + args)
_tkinter.TclError: expected floating-point number but got "0,2"

The script runs fine with an English locale. It also runs fine with Python 3.2 
on the same machine & Windows & German locale.

The reason seems to be that the Scrollbar lets its self.tk compute fractions 
which self.tk returns as locale-dependent strings; the Scrollbar runs into 
problems when converting these strings into floats.

--
Added file: http://bugs.python.org/file22603/scrollbarCrash1.py

___
Python tracker 
<http://bugs.python.org/issue10647>
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue10647] scrollbar crash in non-US locale format settings

2011-07-07 Thread Hans Bering

Changes by Hans Bering :


Removed file: http://bugs.python.org/file22535/tkinterCrash.py

___
Python tracker 
<http://bugs.python.org/issue10647>
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue12558] Locale-dependent crash for float width argument to Tkinter widget constructor

2011-07-14 Thread Hans Bering

New submission from Hans Bering :

The attached script will crash on a current Ubuntu with Python 3.2 + tcl/tk 
when using a locale which uses a comma as a decimal separator (e.g., German). 
It will not crash when using a locale which uses a dot as the decimal separator 
(e.g., English). In case of the crash, the output and stacktrace are as follows:

locale = ('de_DE', 'UTF8')
Traceback (most recent call last):
  File "tkinterCrash.py", line 20, in 
tkcanvas = Canvas(master=master, width=w, height=2, borderwidth=4)
  File "/usr/lib/python3.2/tkinter/__init__.py", line 2101, in __init__
Widget.__init__(self, master, 'canvas', cnf, kw)
  File "/usr/lib/python3.2/tkinter/__init__.py", line 1961, in __init__
(widgetName, self._w) + extra + self._options(cnf))
_tkinter.TclError: bad screen distance "10.0"

Originally, we stumbled over this problem when using matplotlib, which 
passes/passed down float types as width arguments on occasions. It has been 
fixed there since (see https://github.com/matplotlib/matplotlib/pull/387).

The locale dependency can make this problem difficult to debug when it occurs. 
In our setup, we had a program work on one machine, but it crashed on the next 
machine, which we believed to have an identical setup; it took us a day to 
figure out what the difference was. We would expect the constructor to either 
always work with float arguments, or to always reject them, regardless of 
locale.

We have been able to reproduce this issue both with Python 2.7.2 and Python 
3.2, both under a current Ubuntu and Windows 7.

--
components: Tkinter
files: badScreenSizeTk.py
messages: 140338
nosy: hans.bering
priority: normal
severity: normal
status: open
title: Locale-dependent crash for float width argument to Tkinter widget 
constructor
type: crash
versions: Python 2.7, Python 3.2
Added file: http://bugs.python.org/file22653/badScreenSizeTk.py

___
Python tracker 
<http://bugs.python.org/issue12558>
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue12558] Locale-dependent crash for float width argument to Tkinter widget constructor

2011-07-14 Thread Hans Bering

Hans Bering  added the comment:

Sorry for the misclassification, and thanks for correcting that.

I agree, this issue is most likely related to issue 10647; but at some level I 
think they must be different, because issue 10647 seems to be specific to 
Python 3.1 under Windows; I could not reproduce that issue neither under Ubuntu 
nor with Python 3.2 in Windows. This behaviour on the other hand I could 
reproduce with Python 2.7 and Python 3.2 in both Ubuntu and Windows. The 
underlying problem in both cases, I believe, is similar: That int/float 
arguments are somewhere turned into locale-dependent string representations and 
later parsed back using a potentially different locale.

Which brings me to why I consider this to be a bug - sorry for not having made 
that point clearer: The handling of the float argument depends on the system 
locale. If you change the example script to run with an English locale, you do 
not get an error; instead, the float is implicitly used as an int, and 
everything is fine. Only if you use German or a similar locale, will the float 
trigger an error. So the behaviour is at the very least inconsistent. If 
treating a float argument as an error is deemed acceptable, then this error 
should not be locale-dependent.

--

___
Python tracker 
<http://bugs.python.org/issue12558>
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com