[IronPython] Import decimal failure with Turkish Locale (IP 1.1)

Michael Foord michael.foord at resolversystems.com
Wed Oct 31 18:25:50 CET 2007


Hello all,

We've just had a user report an odd crash of Resolver. Importing the 
standard library module 'decimal.py' blows up, meaning that Resolver 
can't start.

We've eventually tracked it down. His machine has a Turkish locale. The 
decimal module looks up global names by taking method names and looking 
for an uppercase version (around line 2171 of the Python 2.4 standard 
library module):

rounding_functions = [name for name in Decimal.__dict__.keys() if 
name.startswith('_round_')]
for name in rounding_functions:
#name is like _round_half_even, goes to the global ROUND_HALF_EVEN value.
globalname = name[1:].upper()
val = globals()[globalname]
Decimal._pick_rounding_function[val] = name

The issue is because one of the method names is '_round_ceiling'. In the 
Turkish locale, the uppercase version of this is "ROUND_CEİLİNG" (in 
Turkish uppercase of "i" is "I" with a dot on top of it). Obviously the 
lookup of the corresponding global fails.

In CPython the name is a byte-string, and so '.upper' just uses the 
ascii uppercase rather than the locale sensitive version - so we see 
failing to import 'decimal.py' as an IronPython bug. As this badly 
impacts Resolver we would *love* to see this fixed soon...

Resolver is built on IronPython 1.1. Any word from you IP guys on how 
quickly you can turnaround a new release of the 1.1 branch that 
addresses this issue?

All the best,


Michael Foord
http://www.manning.com/foord
http://www.resolversystems.com/



More information about the Ironpython-users mailing list