TabViewer / tabview

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

"_curses.error: addstr() returned ERR" issue when printing tsv files that has long width #132

Open njql007 opened 8 years ago

njql007 commented 8 years ago

Hello there,

After opening a tsv file, when scrolling right, the app crashed and I got this exception.

$ tabview ~/test
Traceback (most recent call last):
  File "/home/lqu/.local/bin/tabview", line 5, in <module>
    pkg_resources.run_script('tabview==1.4.2', 'tabview')
  File "/packages/encap/py_setuptools-0.6c11_py2.7/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg/pkg_resources.py", line 489, in run_script
  File "/packages/encap/py_setuptools-0.6c11_py2.7/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg/pkg_resources.py", line 1207, in run_script
  File "/home/lqu/.local/lib/python2.7/site-packages/tabview-1.4.2-py2.7.egg/EGG-INFO/scripts/tabview", line 108, in <module>
    delimiter=args.delimiter, quoting=args.quoting)
  File "/home/lqu/.local/lib/python2.7/site-packages/tabview-1.4.2-py2.7.egg/tabview/tabview.py", line 1332, in view
    info=info)
  File "/usr/local/lib/python2.7/curses/wrapper.py", line 43, in wrapper
    return func(stdscr, *args, **kwds)
  File "/home/lqu/.local/lib/python2.7/site-packages/tabview-1.4.2-py2.7.egg/tabview/tabview.py", line 1253, in main
    Viewer(stdscr, *args, **kwargs).run()
  File "/home/lqu/.local/lib/python2.7/site-packages/tabview-1.4.2-py2.7.egg/tabview/tabview.py", line 700, in run
    self.display()
  File "/home/lqu/.local/lib/python2.7/site-packages/tabview-1.4.2-py2.7.egg/tabview/tabview.py", line 856, in display
    addstr(self.scr, yc, xc, s, attr)
  File "/home/lqu/.local/lib/python2.7/site-packages/tabview-1.4.2-py2.7.egg/tabview/tabview.py", line 39, in addstr
    return scr.addstr(*args)
_curses.error: addstr() returned ERR

It happens only when the tsv file is at least full screen height, and the width is long enough.

I changed this line to if yc == self.max_y - 1:, (which probably means always use insstr() for rendering bottom line of the window?), then it will go through for any files for me.

firecat53 commented 8 years ago

Any chance you could supply a sample file that triggers this crash? I open lots of big CSV files that are wider and taller than the screen without errors.

Also, what platform and terminal are you running on?

Thanks! Scott

njql007 commented 8 years ago

Hello, I can't upload the file so I put it here. If you open the file using tabview in some specific window width & height combination, it will crash. You can try opening the file through tabview and then use the mouse to resize the window of your terminal.

I'm running Mac OS X El Capitan on a Macbook Pro, using iTerm and ssh'ed to a CentOS box (release 5.6).

Thanks!

firecat53 commented 8 years ago

Well hrm. I can't get it to fail at all. I've tried both urxvt and xterm. I tried the file you sent and I tried my weirdest unicode test file (in the sample directory...and I made it bigger and wider too). I tried resizing the terminals. Nothing made it quit. I tried with the change you made and it also didn't crash.

I'm a little hesitant to permanently change the line you modified since it was added when we added double-width character support (#92). @wavexx, any thoughts?

Scott

wavexx commented 8 years ago

As a suggestion, when you make it crash with the correct terminal settings, just

echo $LINES $COLUMNS env | egrep 'LC_|LANG'

so that we can try to reproduce it.

njql007 commented 8 years ago

Hello, thanks for helping me out! It happens when I'm reducing the height of the window (so that the characters will fill up the window, and that's why I put 73 lines in the file).

$ echo $LINES $COLUMNS
73 181

$ env | egrep 'LC_|LANG'
LANG=en_US.UTF-8
wavexx commented 8 years ago

@firecat53 I'm bit busy right now, but this should be enough to trigger it again.