# Buggy code
def readSaxFile(self, theFile, fileName, silent, inClipboard, reassignIndices, s=None):
    """Read the entire .leo file using the sax parser."""
    dump = False and not g.unitTesting
    fc = self
    c = fc.c
    # Pass one: create the intermediate nodes.
    saxRoot = fc.parse_leo_file(
        theFile, fileName, silent=silent, inClipboard=inClipboard, s=s
    )
    if dump:
        fc.dumpSaxTree(saxRoot, dummy=True)
    # Pass two: create the tree of vnodes from the intermediate nodes.
    if saxRoot:
        parent_v = c.hiddenRootNode
        children = fc.createSaxChildren(saxRoot, parent_v)
        assert c.hiddenRootNode.children == children
        v = children and children[0] or None
        return v
    else:
        return None


# Traceback (TypeError)
$ python launchLeo.py

setting leoID from os.getenv('USER'): '<user>'
reading settings in /Users/<user>/build-dirs/leo-editor/leo/config/leoSettings.leo
reading settings in /Users/<user>/.leo/myLeoSettings.leo
Using default leo file name:
/Users/<user>/.leo/workbook.leo

** isPython3: True
Leo 5.4, build 20170301100728, Wed Mar  1 10:07:28 CST 2017
Git repo info: branch = master, commit = 8f01f57131ae
Python 3.5.3, PyQt version 5.6.2
darwin
reading settings in /Users/<user>/build-dirs/leo-editor/leo/doc/CheatSheet.leo
wrote recent file: /Users/<user>/.leo/.leoRecentFiles.txt
reading settings in /Users/<user>/.leo/myLeoSettings.leo
read only: unl:///Users/<user>/build-dirs/leo-editor/leo/config/leoSettings.leo
error parsing unl:///Users/<user>/build-dirs/leo-editor/leo/config/leoSettings.leo
Traceback (most recent call last):

File "/Users/<user>/build-dirs/leo-editor/leo/core/leoFileCommands.py", line 1243, in parse_leo_file
s = str(s, encoding='utf-8')

TypeError: coercing to str: need a bytes-like object, NoneType found

exception executing command
Traceback (most recent call last):

File "/Users/<user>/build-dirs/leo-editor/leo/core/leoCommands.py", line 5501, in doCommand
val = command(event)

File "/Users/<user>/build-dirs/leo-editor/leo/core/leoConfig.py", line 2149, in f
self.find_setting(setting)

File "/Users/<user>/build-dirs/leo-editor/leo/core/leoConfig.py", line 2112, in find_setting
unl = self.copy_to_my_settings(unl, which=2)

File "/Users/<user>/build-dirs/leo-editor/leo/core/leoConfig.py", line 2068, in copy_to_my_settings
c2 = g.app.loadManager.openSettingsFile(path)

File "/Users/<user>/build-dirs/leo-editor/leo/core/leoApp.py", line 1903, in openSettingsFile
readAtFileNodesFlag=False, silent=True)

File "/Users/<user>/build-dirs/leo-editor/leo/core/leoFileCommands.py", line 833, in openLeoFile
silent=silent,

File "/Users/<user>/build-dirs/leo-editor/leo/core/leoFileCommands.py", line 698, in getLeoFile
theFile.close()

AttributeError: 'NoneType' object has no attribute 'close'

# Fixed code
def readSaxFile(self, theFile, fileName, silent, inClipboard, reassignIndices, s=None):
    """Read the entire .leo file using the sax parser."""
    dump = False and not g.unitTesting
    fc = self
    c = fc.c
    # Pass one: create the intermediate nodes.
    saxRoot = fc.parse_leo_file(
        theFile, fileName, silent=silent, inClipboard=inClipboard, s=s
    )
    # Pass two: create the tree of vnodes from the intermediate nodes.
    if saxRoot:
        if dump:
            fc.dumpSaxTree(saxRoot, dummy=True)
        parent_v = c.hiddenRootNode
        children = fc.createSaxChildren(saxRoot, parent_v)
        assert c.hiddenRootNode.children == children
        v = children and children[0] or None
        return v
    else:
        return None