View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0000337 | ascend | pygtk gui | public | 2007-08-19 16:57 | 2011-04-04 15:36 |
Reporter | SocratesF | ||||
Assigned To | |||||
Priority | urgent | Severity | minor | Reproducibility | always |
Status | acknowledged | Resolution | open | ||
Product Version | 0.9.5.x | ||||
Target Version | 1.0 | Fixed in Version | |||
Summary | 0000337: Incompatibility with various number formats in Regional Settings | ||||
Description | When playing with the model of the vessel (first example in the manual), I got the message "Solution(s) for 'H' in 'HD_definition' out of bounds, Rejected solution=3,5' In Greece the format for the numbers is 123456789,00 (',' instead of '.' for the decimal point). After I changed the regional settings (Control Panel-->Regional Settings) standard and formats to English USA the program worked fine. This problem applies for other countries as well that use ',' instead of '.' for the decimal point. | ||||
Tags | No tags attached. | ||||
|
Thanks for the bug report. I'll need to learn a little about i18n before I can fix this bug. Can you just clarify for me whether this bug was with the PyGTK or Tcl/Tk GUI for ASCEND? Thanks -- JP. Also, are you using Windows or Linux? |
|
I am using Windows XP. This bug happened to me when using the PyGTK. The Tcl/Tk works without problems. I think that you are using some function to convert from a numeric value to string (or the opposite) that takes account of the country selected in the regional settings(like CDbl() in Visual Basic) |
|
Valery Vuillerme has reported experiencing problems with this bug. We need a solution quickly. |
|
Valéry has said that a work-around is to set the user locale to en_us.UTF8. |
|
Looks like UNITS_RE from the file pygtk/varentry.py might be the problem here (although I imagine that variable output could also need attention?) |
|
The problem is bigger than this. We need to identify all the places that float-to-string and string-to-float conversions take place, and apply locale-specific routines in all those places. ascpy.i:182: getConvertedValue varentry.py:8: UNITS_RE varentry.py:44: varentry.py:75 and others too, because even after changing the above, values are still output with their decimals chopped. A workaround could be to pop up a dialog when the program starts, if the locale requires a decimal_point that's not equal to ".". Patch i18n.patch attached. |
|
i18n.patch (1,738 bytes)
Index: ascxx/ascpy.i =================================================================== --- ascxx/ascpy.i (revision 3345) +++ ascxx/ascpy.i (working copy) @@ -176,13 +176,14 @@ %include "dimensions.h" %include "units.h" +import locale %extend UnitsM{ %pythoncode{ def getConvertedValue(self,si_value): """Return an SI value converted to self's units of measurement.""" _v = si_value / self.getConversion() - _s = str(_v) + _s = locale.str(_v) _n = self.getName().toString() if _n=="1": return _s Index: pygtk/varentry.py =================================================================== --- pygtk/varentry.py (revision 3345) +++ pygtk/varentry.py (working copy) @@ -4,10 +4,12 @@ import re import ascpy - +import locale # RE for units matching -UNITS_RE = re.compile("([-+]?(\d+(\.\d*)?|\d*\.d+)([eE][-+]?\d+)?)\s*(.*)"); +dot = locale.localeconv()['decimal_point'] +UNITS_RE = re.compile("([-+]?(\\d+(\\" + dot + "\\d*)?|\\d*\\" + dot + "\\d+)([eE][-+]?\\d+)?)\\s*(.*)"); + class InputError(Exception): def __init__(self,msg): self.msg = msg; @@ -42,7 +44,8 @@ # parse the units, throw an error if no good try: - _val = float(_val) + print "CONVERTING '%s' TO FLOAT..." % _vals + _val = locale.atof(_val) except RuntimeError: raise InputError("Unable to convert number part '%s' to float" % _val) @@ -73,7 +76,7 @@ raise InputError("Incompatible units '%s' (must fit with '%s')" % (self.units, _my_dims.getName().toString()) ) - _conv = float(_u.getConversion()) + _conv = _u.getConversion() # self.reporter.reportNote("Converting: multiplying '%s %s' by factor %s to get SI units" % (_val, _units, _conv) ) self.value = _val * _conv; |
|
Added a locale warning in changeset 3353. |
|
Changing to target version 1.0, as warning/error message reporting this problem for users has been added and tested. |
Date Modified | Username | Field | Change |
---|---|---|---|
2007-08-19 16:57 | SocratesF | New Issue | |
2007-08-19 16:57 | SocratesF | Status | new => assigned |
2007-08-19 16:57 | SocratesF | Assigned To | => john |
2007-09-04 11:35 | john | Target release | => 0.9.6 |
2007-09-04 11:35 | john | Note Added: 0000432 | |
2007-09-04 11:35 | john | Severity | major => minor |
2007-09-04 11:35 | john | Projection | none => minor fix |
2007-09-04 11:35 | john | Category | build-windows => pygtk gui |
2007-09-04 11:35 | john | ETA | none => > 1 month |
2007-09-06 16:34 | SocratesF | Note Added: 0000433 | |
2009-05-01 16:53 | john | Target Version | => 0.9.7 |
2009-05-01 17:58 | john | Target Version | 0.9.7 => 1.0 |
2009-05-01 18:03 | john | Target Version | 1.0 => 0.9.7 |
2010-03-22 12:13 | john | Assigned To | john => |
2010-03-22 12:13 | john | Status | assigned => acknowledged |
2010-03-23 10:00 | john | Priority | normal => urgent |
2010-03-23 10:00 | john | Target Version | 0.9.7 => 0.9.8 |
2010-03-23 10:02 | john | Note Added: 0000585 | |
2010-03-24 15:57 | john | Note Added: 0000593 | |
2010-07-11 18:15 | john | Relationship added | related to 0000461 |
2011-02-22 17:34 | john | Target Version | 0.9.8 => 1.0 |
2011-02-22 17:35 | john | Target Version | 1.0 => 0.9.8 |
2011-03-15 18:30 | john | Summary | Incopatibility with various number formats in Regional Settings => Incompatibility with various number formats in Regional Settings |
2011-03-22 15:12 | john | Note Added: 0000694 | |
2011-03-28 18:19 | john | Note Added: 0000702 | |
2011-03-28 18:22 | john | File Added: i18n.patch | |
2011-03-28 18:22 | john | Note Edited: 0000702 | View Revisions |
2011-04-04 14:29 | john | Note Added: 0000706 | |
2011-04-04 14:33 | john | Relationship replaced | has duplicate 0000461 |
2011-04-04 15:36 | john | Note Added: 0000711 | |
2011-04-04 15:36 | john | Target Version | 0.9.8 => 1.0 |