[Numpy-tickets] [NumPy] #643: Traceback when imported after gtk

NumPy numpy-tickets@scipy....
Thu Jan 10 14:40:07 CST 2008


#643: Traceback when imported after gtk
--------------------+-------------------------------------------------------
 Reporter:  marco   |        Owner:  rkern   
     Type:  defect  |       Status:  assigned
 Priority:  normal  |    Milestone:  1.0.5   
Component:  Other   |      Version:  none    
 Severity:  normal  |   Resolution:          
 Keywords:          |  
--------------------+-------------------------------------------------------
Changes (by rkern):

  * status:  new => assigned
  * owner:  somebody => rkern

Old description:

> The following result in a traceback. I suspect it might be related to the
> fact that importing gtk changes the default encoding to utf-8. I'm using
> python 2.5.1 and numpy 1.0.3.1
>
> LANG=tr_TR.UTF-8 python -c "import gtk, numpy"
>
> Traceback (most recent call last):
>   File "<string>", line 1, in <module>
>   File "/usr/lib64/python2.5/site-packages/numpy/__init__.py", line 39,
> in <module>
>     import core
>   File "/usr/lib64/python2.5/site-packages/numpy/core/__init__.py", line
> 8, in <module>
>     import numerictypes as nt
>   File "/usr/lib64/python2.5/site-packages/numpy/core/numerictypes.py",
> line 241, in <module>
>     void = allTypes['void']
> KeyError: 'void'

New description:

 The following result in a traceback. I suspect it might be related to the
 fact that importing gtk changes the default encoding to utf-8. I'm using
 python 2.5.1 and numpy 1.0.3.1

 LANG=tr_TR.UTF-8 python -c "import gtk, numpy"

 {{{

 Traceback (most recent call last):
   File "<string>", line 1, in <module>
   File "/usr/lib64/python2.5/site-packages/numpy/__init__.py", line 39, in
 <module>
     import core
   File "/usr/lib64/python2.5/site-packages/numpy/core/__init__.py", line
 8, in <module>
     import numerictypes as nt
   File "/usr/lib64/python2.5/site-packages/numpy/core/numerictypes.py",
 line 241, in <module>
     void = allTypes['void']
 KeyError: 'void'
 }}}

Comment:

 I cannot replicate this on Ubuntu with numpy 1.0.3.1 and python-gtk
 2.10.4-ubuntu3.

 {{{
 $ LANG=tr_TR.UTF-8 python -c "import gtk, numpy"
 $ LANG=tr_TR.UTF-8 python -c "import
 sys;reload(sys);sys.setdefaultencoding('utf-8');import numpy"
 $
 }}}

 I can replicate it on my XO after importing GTK, but not simply setting
 the default encoding. I have not yet set up a development environment to
 compile a new version of numpy, though.

 It appears that 'i' characters in the keys are getting capitalized, for
 some reason. If you are familiar with Turkish, you might be able to tell
 me why. We do call .lower() on some of these type names from an all-
 uppercase version of the name. It is possible that a locale-dependent
 transformation is being installed, and 'I' happens to be a valid lowercase
 character in Turkish. The wrong keys are 'voId', 'unIcode', 'uIntp',
 'uInt', 'strIng', 'signedInteger', 'Intp', 'Integer', 'Int', and
 'Inexact'. Interestingly, the bit-width-precise variants of these are
 fine, e.g. 'void0'; consequently, we can isolate the problem down to the
 function {{{_add_types()}}}. The smallest test case is as follows:

 {{{
 $ LANG=tr_TR.UTF-8 python -c "import gtk;print 'VOID'.lower()"
 voId
 $ LANG=tr_TR.UTF-8 python -c "print 'VOID'.lower()"
 void
 $ LANG=tr_TR.UTF-8 python -c "import
 sys;reload(sys);sys.setdefaultencoding('utf-8');print 'VOID'.lower()"
 void
 }}}

 AFAICT, there is nothing wrong with numpy, and there is little that we can
 do in numpy to work around this. Something in GTK is messing with the way
 .lower() works beyond the different locale and the setdefaultencoding()
 abuse. If there is a locale such that {{{'VOID'.lower() != 'void'}}}, I'm
 happy to revise this assessment, but it looks like something in GTK is the
 source of the problem.

-- 
Ticket URL: <http://scipy.org/scipy/numpy/ticket/643#comment:3>
NumPy <http://projects.scipy.org/scipy/numpy>
The fundamental package needed for scientific computing with Python.


More information about the Numpy-tickets mailing list