View Issue Details

IDProjectCategoryView StatusLast Update
0000337ascendpygtk guipublic2011-04-04 15:36
ReporterSocratesF 
Assigned To 
PriorityurgentSeverityminorReproducibilityalways
Status acknowledgedResolutionopen 
Product Version0.9.5.x 
Target Version1.0Fixed in Version 
Summary0000337: Incompatibility with various number formats in Regional Settings
DescriptionWhen 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.
TagsNo tags attached.

Relationships

has duplicate 0000461 resolvedjohn On MAC OS X Ascend Ignores decimal places - 0.12345 becomes 0.00000 

Activities

john

2007-09-04 11:35

administrator   ~0000432

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?

SocratesF

2007-09-06 16:34

reporter   ~0000433

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)

john

2010-03-23 10:02

administrator   ~0000585

Valery Vuillerme has reported experiencing problems with this bug. We need a solution quickly.

john

2010-03-24 15:57

administrator   ~0000593

Valéry has said that a work-around is to set the user locale to en_us.UTF8.

john

2011-03-22 15:12

administrator   ~0000694

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?)

john

2011-03-28 18:19

administrator   ~0000702

Last edited: 2011-03-28 18:22

View 2 revisions

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.

john

2011-03-28 18:22

administrator  

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;
 
i18n.patch (1,738 bytes)

john

2011-04-04 14:29

administrator   ~0000706

Added a locale warning in changeset 3353.

john

2011-04-04 15:36

administrator   ~0000711

Changing to target version 1.0, as warning/error message reporting this problem for users has been added and tested.

Issue History

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