# Buggy code
def start(self, workspace_folder):
    # Needed to handle an error caused by the inotify limit reached.
    # See spyder-ide/spyder#10478
    try:
        self.observer = Observer()
        self.observer.schedule(self.event_handler, workspace_folder, recursive=True)
        self.observer.start()
    except OSError as e:
        if "inotify" in e:
            QMessageBox.warning(
                self.parent(),
                "Spyder",
                _(
                    "File system changes for this project can't be tracked "
                    "because it contains too many files. To fix this you "
                    "need to increase the inotify limit in your system, "
                    "with the following command:"
                    "<br><br>"
                    "<code>"
                    "sudo sysctl -n -w fs.inotify.max_user_watches=524288"
                    "</code>"
                    "<br><br>For a permanent solution you need to add to"
                    "<code>/etc/sysctl.conf</code>"
                    "the following line:<br><br>"
                    "<code>"
                    "fs.inotify.max_user_watches=524288"
                    "</code>"
                    "<br><br>"
                    "After doing that, you need to close and start Spyder "
                    "again so those changes can take effect."
                ),
            )
            self.observer = None
        else:
            raise e


# Traceback (OSError)
2019-11-09 15:18:46,085 [DEBUG] [urllib3.connectionpool] -> http://127.0.0.1:46624 "POST /clientapi/editor/event HTTP/1.1" 200 0
inotify_add_watch(/home/kai/Projects/solbeg/papi-aiohttp) failed: (No space left on device)
Traceback (most recent call last):
File "/home/kai/Projects/spyder/git/spyder/spyder/plugins/projects/utils/watcher.py", line 100, in start
self.observer.start()
File "/home/kai/Projects/spyder/git/venv/lib/python3.7/site-packages/watchdog/observers/api.py", line 255, in start
emitter.start()
File "/home/kai/Projects/spyder/git/venv/lib/python3.7/site-packages/watchdog/utils/__init__.py", line 110, in start
self.on_thread_start()
File "/home/kai/Projects/spyder/git/venv/lib/python3.7/site-packages/watchdog/observers/inotify.py", line 121, in on_thread_start
self._inotify = InotifyBuffer(path, self.watch.is_recursive)
File "/home/kai/Projects/spyder/git/venv/lib/python3.7/site-packages/watchdog/observers/inotify_buffer.py", line 35, in __init__
self._inotify = Inotify(path, recursive)
File "/home/kai/Projects/spyder/git/venv/lib/python3.7/site-packages/watchdog/observers/inotify_c.py", line 199, in __init__
self._add_dir_watch(path, recursive, event_mask)
File "/home/kai/Projects/spyder/git/venv/lib/python3.7/site-packages/watchdog/observers/inotify_c.py", line 380, in _add_dir_watch
self._add_watch(path, mask)
File "/home/kai/Projects/spyder/git/venv/lib/python3.7/site-packages/watchdog/observers/inotify_c.py", line 401, in _add_watch
Inotify._raise_error()
File "/home/kai/Projects/spyder/git/venv/lib/python3.7/site-packages/watchdog/observers/inotify_c.py", line 413, in _raise_error
raise OSError("inotify watch limit reached")
OSError: inotify watch limit reached

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/home/kai/Projects/spyder/git/spyder/spyder/app/mainwindow.py", line 3657, in main
mainwindow = run_spyder(app, options, args)
File "/home/kai/Projects/spyder/git/spyder/spyder/app/mainwindow.py", line 3508, in run_spyder
main.post_visible_setup()
File "/home/kai/Projects/spyder/git/spyder/spyder/app/mainwindow.py", line 1416, in post_visible_setup
self.projects.reopen_last_project()
File "/home/kai/Projects/spyder/git/spyder/spyder/plugins/projects/plugin.py", line 404, in reopen_last_project
save_previous_files=False)
File "/home/kai/Projects/spyder/git/spyder/spyder/plugins/projects/plugin.py", line 322, in open_project
self.watcher.start(path)
File "/home/kai/Projects/spyder/git/spyder/spyder/plugins/projects/utils/watcher.py", line 102, in start
if u'inotify' in e:
TypeError: argument of type 'OSError' is not iterable

# Fixed code
def start(self, workspace_folder):
    # Needed to handle an error caused by the inotify limit reached.
    # See spyder-ide/spyder#10478
    try:
        self.observer = Observer()
        self.observer.schedule(self.event_handler, workspace_folder, recursive=True)
        self.observer.start()
    except OSError as e:
        if "inotify" in to_text_string(e):
            QMessageBox.warning(
                self.parent(),
                "Spyder",
                _(
                    "File system changes for this project can't be tracked "
                    "because it contains too many files. To fix this you "
                    "need to increase the inotify limit in your system, "
                    "with the following command:"
                    "<br><br>"
                    "<code>"
                    "sudo sysctl -n -w fs.inotify.max_user_watches=524288"
                    "</code>"
                    "<br><br>For a permanent solution you need to add to"
                    "<code>/etc/sysctl.conf</code>"
                    "the following line:<br><br>"
                    "<code>"
                    "fs.inotify.max_user_watches=524288"
                    "</code>"
                    "<br><br>"
                    "After doing that, you need to close and start Spyder "
                    "again so those changes can take effect."
                ),
            )
            self.observer = None
        else:
            raise e