# Buggy code
def __init__(self):
    self.sheets = []  # list of BaseSheet; all sheets on the sheet stack
    self.allSheets = (
        weakref.WeakKeyDictionary()
    )  # [BaseSheet] -> sheetname (all non-precious sheets ever pushed)
    self.statuses = (
        collections.OrderedDict()
    )  # (priority, statusmsg) -> num_repeats; shown until next action
    self.statusHistory = []  # list of [priority, statusmsg, repeats] for all status messages ever
    self.lastErrors = []
    self.keystrokes = ""
    self.prefixWaiting = False
    self.scr = None  # curses scr
    self.mousereg = []
    self.cmdlog = None  # CommandLog


# Traceback (AttributeError)
$ vd --debug -b -p newCol.vd
Think about what you're doing
opening newCol as vd
"."
opening . as dir
"1"
c=addColumn(SettableColumn("", width=options.default_width), cursorColIndex+1); draw(vd.scr); cursorVisibleColIndex=visibleCols.index(c); c.name=editCell(cursorVisibleColIndex, -1); c.width=None
AttributeError: 'NoneType' object has no attribute 'erase'
AttributeError: 'NoneType' object has no attribute 'erase'
Traceback (most recent call last):
File "/usr/local/bin/vd", line 4, in <module>
__import__('pkg_resources').run_script('visidata==1.6.dev0', 'vd')
File "/home/cwarden/.local/lib/python3.6/site-packages/pkg_resources/__init__.py", line 664, in run_script
self.require(requires)[0].run_script(script_name, ns)
File "/home/cwarden/.local/lib/python3.6/site-packages/pkg_resources/__init__.py", line 1451, in run_script
exec(script_code, namespace, namespace)
File "/usr/local/lib/python3.6/dist-packages/visidata-1.6.dev0-py3.6.egg/EGG-INFO/scripts/vd", line 169, in <module>
File "/usr/local/lib/python3.6/dist-packages/visidata-1.6.dev0-py3.6.egg/EGG-INFO/scripts/vd", line 152, in main
File "/usr/local/lib/python3.6/dist-packages/visidata-1.6.dev0-py3.6.egg/visidata/cmdlog.py", line 289, in replay_sync
File "/usr/local/lib/python3.6/dist-packages/visidata-1.6.dev0-py3.6.egg/visidata/vdtui/__init__.py", line 455, in exceptionCaught
File "/usr/local/lib/python3.6/dist-packages/visidata-1.6.dev0-py3.6.egg/visidata/cmdlog.py", line 284, in replay_sync
File "/usr/local/lib/python3.6/dist-packages/visidata-1.6.dev0-py3.6.egg/visidata/cmdlog.py", line 264, in replayOne
File "/usr/local/lib/python3.6/dist-packages/visidata-1.6.dev0-py3.6.egg/visidata/vdtui/__init__.py", line 1132, in exec_command
File "/usr/local/lib/python3.6/dist-packages/visidata-1.6.dev0-py3.6.egg/visidata/vdtui/__init__.py", line 1126, in exec_command
File "<string>", line 1, in <module>
File "/usr/local/lib/python3.6/dist-packages/visidata-1.6.dev0-py3.6.egg/visidata/vdtui/_sheet.py", line 566, in draw
AttributeError: 'NoneType' object has no attribute 'erase'

# Fixed code
def __init__(self):
    self.sheets = []  # list of BaseSheet; all sheets on the sheet stack
    self.allSheets = (
        weakref.WeakKeyDictionary()
    )  # [BaseSheet] -> sheetname (all non-precious sheets ever pushed)
    self.statuses = (
        collections.OrderedDict()
    )  # (priority, statusmsg) -> num_repeats; shown until next action
    self.statusHistory = []  # list of [priority, statusmsg, repeats] for all status messages ever
    self.lastErrors = []
    self.keystrokes = ""
    self.prefixWaiting = False
    self.scr = mock.MagicMock(
        __bool__=mock.Mock(return_value=False)
    )  # disable curses in batch mode
    self.mousereg = []
    self.cmdlog = None  # CommandLog