TabViewer / tabview

Python curses command line CSV and tabular data viewer
Other
460 stars 49 forks source link

LC_ALL and python2 #129

Open wavexx opened 9 years ago

wavexx commented 9 years ago

When running tabview as a module in ipython, I get the following:

<ipython-input-20-0e05cb7859ca> in <module>()
----> 1 tv(r)

/usr/local/lib/python2.7/dist-packages/tabview/tabview.py in view(data, enc, start_pos, column_width, column_gap, trunc_char, column_widths, search_str, double_width, delimiter)
   1214     """
   1215     if sys.version_info.major < 3:
-> 1216         lc_all = locale.getlocale(locale.LC_ALL)
   1217         locale.setlocale(locale.LC_ALL, '')
   1218     else:

/usr/lib/python2.7/locale.pyc in getlocale(category)
    559     localename = _setlocale(category)
    560     if category == LC_ALL and ';' in localename:
--> 561         raise TypeError, 'category LC_ALL is not supported'
    562     return _parse_localename(localename)
    563 
wavexx commented 9 years ago

I think we need to set/restore only LC_CTYPE here.

firecat53 commented 9 years ago

Hrm, I can't reproduce this...works fine for me in ipython2 and ipython3 using the sample files from the project.

In [1]: import tabview.tabview as t
In [2]: t.view("sample/test_latin-1.csv")
Out[2]: 0
In [7]: locale.getlocale(locale.LC_ALL)
Out[7]: (None, None)

Is there anything odd in your environment at all?

Scott

wavexx commented 9 years ago

On 14/09/15 21:31, Scott Hansen wrote:

Hrm, I can't reproduce this...works fine for me in ipython2 and ipython3 using the sample files from the project.

|In [1]: import tabview.tabview as t In [2]: t.view("sample/test_latin-1.csv") Out[2]: 0 In [7]: locale.getlocale(locale.LC_ALL) Out[7]: (None, None) |

Is there anything odd in your environment at all?

Hrrm, indeed. It happens only when I load matplotlib as well.

Here's the minimal example that triggers this behavior for me:

import matplotlib.pyplot as plt plt.close(plt.figure()) import tabview as t t.view([[1]])