import Random: NV_MAGICCONST deviates too much.

Marijn Vriens marijn at sanity.dhs.org
Fri Mar 1 11:07:43 EST 2002


Michael Hudson wrote:
> marijn at sanity.dhs.org (marijn Vriens) writes:
> 
> 
>>Hi all...
>>
>>I have get a strange exception when importing random. 
>>I brought it down to:
>>
>>Python 2.1.2 (#1, Jan 18 2002, 18:05:45) 
>>[GCC 2.95.4  (Debian prerelease)] on linux2
>>Type "copyright", "credits" or "license" for more information.
>>
>>>>>import gnome.ui
>>>>>import random
>>>>>
>>Traceback (most recent call last):
>>  File "<stdin>", line 1, in ?
>>  File "/usr/lib/python2.1/random.py", line 93, in ?
>>    _verify('NV_MAGICCONST', 1.71552776992141)
>>  File "/usr/lib/python2.1/random.py", line 88, in _verify
>>    raise ValueError(
>>ValueError: computed value for NV_MAGICCONST deviates too much
>>(computed 2,82843, expected 1)
>>
>>If I first import random and then gnome.ui I have no problems. my
>>distr is debian woody with the standard python packages (not
>>self-compiled) on an
>>AMD-K6 
>>
>>Anybody know what's going on ?
>>
> 
> At a guess, something in gnome.ui is buggering around with locale
> settings.  Don't know if this actually helps -- I can't see quite how
> it could produce the above error...
> 

The work-around for this is to set the LC_NUMERIC locale after importing 
gnome.ui. like so:

 >>> import locale
 >>> import gnome.ui
 >>> locale.setlocale(locale.LC_NUMERIC, 'C')
'C'
 >>> import random
 >>>

Thanks for the people at #python for helping with this issue!

Cheers,
      Marijn




More information about the Python-list mailing list