new runtest option and dirty locale fix method
Bernhard Reiter
bernhard at intevation.de
Sun Sep 24 21:11:16 CEST 2006
With Revision 2705 I just completed a debugging session about
decimal_point != ".\0" robustness.
+ * test/runtests.py: Added new option ---setdecimalcommalocale
+ to run all tests with an LC_NUMERIC that uses comma as decimal_point.
This enabled me to run all tests under the new conditions and I discovered
that dbflib is having a problem as well:
FAIL: test_transientdb.TestTransientTable.test_transient_table
----------------------------------------------------------------------
Traceback (most recent call last):
File
"/mobilehome/bernhard/hacking/thuban/root/trunk/thuban-on-sid/test/test_t
ransientdb.py", line 111, in test_transient_table
self.run_iceland_political_tests(table)
File
"/mobilehome/bernhard/hacking/thuban/root/trunk/thuban-on-sid/test/test_t
ransientdb.py", line 72, in run_iceland_political_tests
{'POPYCOUN': 'IC', 'POPYADMIN': '', 'PONET_': 146,
AssertionError: {'PERIMETER': 88.0, 'AREA': 19.0, 'POPYCOUN': u'IC',
'PONET_ID': 145, 'POPYTYPE': 1, 'POPYREG': u'1', 'PONET_': 146, 'POPYADMIN':
u''} != {'PERIMETER': 88.518000000000001, 'AREA': 19.462, 'POPYCOUN': 'IC',
'PONET_ID': 145, 'POPYTYPE': 1, 'POPYREG': '1', 'PONET_': 146, 'POPYADMIN':
''}
So I have added a dirty workaround.
What do you think about it?
Here are the details:
Modified:
trunk/thuban/libraries/shapelib/dbfopen.c
trunk/thuban/libraries/shapelib/shapefil.h
Log:
Introduced a pointer atof_function which is called by DBFReadAttribute() now.
Default value is &atof, but DBFSetatof_function() can now be used
to change this during runtime.
Reasoning:
+/* This makes it possible to initialise a different atof() function */
+/* which might be necessary because the standard atof() might be */
+/* sensitive to locale settings. */
+/* */
+/* If the calling application uses a locale with different decimal_point*/
+/* it should better also give us a locale agnostic atof() function. */
+/* */
+/* As far as I can see from Python PEP331 and GNU libc documentation */
+/* there is no standard for such a function yet. */
Next I hardcoded the new Python function.
(This still needs a check for the Python version to be compatible with Python
< 2.4.)
+ * dbflib_wrap.c: Added call DBFSetatof_function(&PyOS_ascii_atof);
+ to initdbflibc().
This is a hack, but I envision that there will be locale agnostic
functions around and putting your own into shapelib probably
is creating more need for maintenance.
There already are some in glib, Python C/API and even on glibc
you can easily create one using strtod_l().
Would this be a good solution for gdal as well?
shapelib is easy as Thuban already ships its own version.
Bernhard
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://www.intevation.de/pipermail/thuban-devel/attachments/20060924/310e2f51/attachment.bin
More information about the Thuban-devel
mailing list
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)