gurudesh/pytracebugs huggingface dataset:
# Buggy code
def using_user_docutils_conf(confdir):
    # type: (unicode) -> Generator[None, None, None]
    """Let docutils know the location of ``docutils.conf`` for Sphinx."""
    try:
        docutilsconfig = os.environ.get("DOCUTILSCONFIG", None)
        if confdir:
            os.environ["DOCUTILSCONFIG"] = path.join(
                path.abspath(confdir), "docutils.conf"
            )  # type: ignore  # NOQA

        yield
    finally:
        if docutilsconfig is None:
            os.environ.pop("DOCUTILSCONFIG")
        else:
            os.environ["DOCUTILSCONFIG"] = docutilsconfig


# Traceback (KeyError)
# Sphinx version: 1.8.3
# Python version: 3.5.2 (CPython)
# Docutils version: 0.14
# Jinja2 version: 2.8
# Last messages:

# Loaded extensions:
Traceback (most recent call last):
File "/home/dima/.local/lib/python3.5/site-packages/sphinx/cmd/build.py", line 305, in build_main
return app.statuscode
File "/usr/lib/python3.5/contextlib.py", line 77, in __exit__
self.gen.throw(type, value, traceback)
File "/home/dima/.local/lib/python3.5/site-packages/sphinx/util/docutils.py", line 144, in patch_docutils
yield
File "/usr/lib/python3.5/contextlib.py", line 77, in __exit__
self.gen.throw(type, value, traceback)
File "/home/dima/.local/lib/python3.5/site-packages/sphinx/util/docutils.py", line 134, in using_user_docutils_conf
os.environ.pop('DOCUTILSCONFIG')
File "/usr/lib/python3.5/_collections_abc.py", line 727, in pop
value = self[key]
File "/usr/lib/python3.5/os.py", line 725, in __getitem__
raise KeyError(key) from None
KeyError: 'DOCUTILSCONFIG'

# Fixed code
def using_user_docutils_conf(confdir):
    # type: (unicode) -> Generator[None, None, None]
    """Let docutils know the location of ``docutils.conf`` for Sphinx."""
    try:
        docutilsconfig = os.environ.get("DOCUTILSCONFIG", None)
        if confdir:
            os.environ["DOCUTILSCONFIG"] = path.join(
                path.abspath(confdir), "docutils.conf"
            )  # type: ignore  # NOQA

        yield
    finally:
        if docutilsconfig is None:
            os.environ.pop("DOCUTILSCONFIG", None)
        else:
            os.environ["DOCUTILSCONFIG"] = docutilsconfig
# Buggy code
def main(argv=sys.argv[1:]):  # type: ignore
    # type: (List[unicode]) -> int
    locale.setlocale(locale.LC_ALL, "")
    sphinx.locale.init_console(os.path.join(package_dir, "locale"), "sphinx")

    if argv[:1] == ["-M"]:
        return make_main(argv)
    else:
        return build_main(argv)


# Traceback (locale.Error)
Traceback (most recent call last):
File "/private/tmp/issue/venv/bin/sphinx-quickstart", line 11, in <module>
sys.exit(main())
File "/private/tmp/issue/venv/lib/python3.7/site-packages/sphinx/cmd/quickstart.py", line 616, in main
locale.setlocale(locale.LC_ALL, '')
File "/opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/locale.py", line 604, in setlocale
return _setlocale(category, locale)
locale.Error: unsupported locale setting

# Fixed code
def main(argv=sys.argv[1:]):  # type: ignore
    # type: (List[unicode]) -> int
    sphinx.locale.setlocale(locale.LC_ALL, "")
    sphinx.locale.init_console(os.path.join(package_dir, "locale"), "sphinx")

    if argv[:1] == ["-M"]:
        return make_main(argv)
    else:
        return build_main(argv)
# Buggy code
def main(argv=sys.argv[1:]):
    # type: (List[str]) -> None
    locale.setlocale(locale.LC_ALL, "")
    sphinx.locale.init_console(os.path.join(package_dir, "locale"), "sphinx")

    app = DummyApplication()
    setup_documenters(app)
    args = get_parser().parse_args(argv)
    generate_autosummary_docs(
        args.source_file,
        args.output_dir,
        "." + args.suffix,
        template_dir=args.templates,
        imported_members=args.imported_members,
        app=app,
    )


# Traceback (locale.Error)
Traceback (most recent call last):
File "/private/tmp/issue/venv/bin/sphinx-quickstart", line 11, in <module>
sys.exit(main())
File "/private/tmp/issue/venv/lib/python3.7/site-packages/sphinx/cmd/quickstart.py", line 616, in main
locale.setlocale(locale.LC_ALL, '')
File "/opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/locale.py", line 604, in setlocale
return _setlocale(category, locale)
locale.Error: unsupported locale setting

# Fixed code
def main(argv=sys.argv[1:]):
    # type: (List[str]) -> None
    sphinx.locale.setlocale(locale.LC_ALL, "")
    sphinx.locale.init_console(os.path.join(package_dir, "locale"), "sphinx")

    app = DummyApplication()
    setup_documenters(app)
    args = get_parser().parse_args(argv)
    generate_autosummary_docs(
        args.source_file,
        args.output_dir,
        "." + args.suffix,
        template_dir=args.templates,
        imported_members=args.imported_members,
        app=app,
    )
# Buggy code
def encode_uri(uri):
    # type: (unicode) -> unicode
    split = list(urlsplit(uri))  # type: Any
    split[1] = split[1].encode("idna").decode("ascii")
    split[2] = quote_plus(split[2].encode("utf-8"), "/").decode("ascii")
    query = list((q, quote_plus(v.encode("utf-8"))) for (q, v) in parse_qsl(split[3]))
    split[3] = urlencode(query).decode("ascii")
    return urlunsplit(split)


# Traceback (UnicodeEncodeError)
Exception in thread Thread-1:
Traceback (most recent call last):
File "/Users/tkomiya/work/sphinx/sphinx/builders/linkcheck.py", line 132, in check_uri
req_url.encode('ascii')
UnicodeEncodeError: 'ascii' codec can't encode characters in position 20-27: ordinal not in range(128)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/Users/tkomiya/.pyenv/versions/3.6.5/lib/python3.6/threading.py", line 916, in _bootstrap_inner
self.run()
File "/Users/tkomiya/.pyenv/versions/3.6.5/lib/python3.6/threading.py", line 864, in run
self._target(*self._args, **self._kwargs)
File "/Users/tkomiya/work/sphinx/sphinx/builders/linkcheck.py", line 217, in check_thread
status, info, code = check()
File "/Users/tkomiya/work/sphinx/sphinx/builders/linkcheck.py", line 200, in check
status, info, code = check_uri()
File "/Users/tkomiya/work/sphinx/sphinx/builders/linkcheck.py", line 134, in check_uri
req_url = encode_uri(req_url)
File "/Users/tkomiya/work/sphinx/sphinx/util/__init__.py", line 604, in encode_uri
split[2] = quote_plus(split[2].encode('utf-8'), '/').decode('ascii')
AttributeError: 'str' object has no attribute 'decode'

# Fixed code
def encode_uri(uri):
    # type: (unicode) -> unicode
    split = list(urlsplit(uri))  # type: List[unicode]
    split[1] = split[1].encode("idna").decode("ascii")
    split[2] = quote_plus(split[2].encode("utf-8"), "/")
    query = list((q, v.encode("utf-8")) for (q, v) in parse_qsl(split[3]))
    split[3] = urlencode(query)
    return urlunsplit(split)
# Buggy code
def compile_all_catalogs(self):
    # type: () -> None
    catalogs = i18n.find_catalog_source_files(
        [path.join(self.srcdir, x) for x in self.config.locale_dirs],
        self.config.language,
        charset=self.config.source_encoding,
        gettext_compact=self.config.gettext_compact,
        force_all=True,
        excluded=Matcher(["**/.?**"]),
    )
    message = __("all of %d po files") % len(catalogs)
    self.compile_catalogs(catalogs, message)


# Traceback (FileNotFoundError)
# Sphinx version: 2.0.0+
# Python version: 3.6.5 (CPython)
# Docutils version: 0.14
# Jinja2 version: 2.10
# Last messages:
#   loading translations [en]...
#
#   done
#
#   making output directory...
#
#   building [mo]: targets for 1 po files that are out of date
#
#   writing output... [100%] locales/en/LC_MESSAGES/sphinx.mo
#
# Loaded extensions:
#   sphinx.ext.mathjax (2.0.0+) from /Users/tkomiya/work/sphinx/sphinx/ext/mathjax.py
#   alabaster (0.7.10) from /Users/tkomiya/work/tmp/lib/python3.6/site-packages/alabaster-0.7.10-py3.6.egg/alabaster/__init__.py
Traceback (most recent call last):
File "/Users/tkomiya/work/sphinx/sphinx/cmd/build.py", line 304, in build_main
app.build(args.force_all, filenames)
File "/Users/tkomiya/work/sphinx/sphinx/application.py", line 340, in build
self.builder.compile_update_catalogs()
File "/Users/tkomiya/work/sphinx/sphinx/builders/__init__.py", line 281, in compile_update_catalogs
self.compile_catalogs(catalogs, message)
File "/Users/tkomiya/work/sphinx/sphinx/builders/__init__.py", line 236, in compile_catalogs
catalog.write_mo(self.config.language)
File "/Users/tkomiya/work/sphinx/sphinx/util/i18n.py", line 71, in write_mo
with io.open(self.po_path, 'rt', encoding=self.charset) as file_po:
FileNotFoundError: [Errno 2] No such file or directory: '/Users/tkomiya/work/tmp/doc/test/locales/en/LC_MESSAGES/sphinx.po'

# Fixed code
def compile_all_catalogs(self):
    # type: () -> None
    catalogs = i18n.find_catalog_source_files(
        [path.join(self.srcdir, x) for x in self.config.locale_dirs],
        self.config.language,
        charset=self.config.source_encoding,
        force_all=True,
        excluded=Matcher(["**/.?**"]),
    )
    message = __("all of %d po files") % len(catalogs)
    self.compile_catalogs(catalogs, message)
# Buggy code
def compile_specific_catalogs(self, specified_files):
    # type: (List[unicode]) -> None
    def to_domain(fpath):
        # type: (unicode) -> unicode
        docname = self.env.path2doc(path.abspath(fpath))
        if docname:
            return find_catalog(docname, self.config.gettext_compact)
        else:
            return None

    specified_domains = set(map(to_domain, specified_files))
    specified_domains.discard(None)
    catalogs = i18n.find_catalog_source_files(
        [path.join(self.srcdir, x) for x in self.config.locale_dirs],
        self.config.language,
        domains=list(specified_domains),
        charset=self.config.source_encoding,
        gettext_compact=self.config.gettext_compact,
        excluded=Matcher(["**/.?**"]),
    )
    message = __("targets for %d po files that are specified") % len(catalogs)
    self.compile_catalogs(catalogs, message)


# Traceback (FileNotFoundError)
# Sphinx version: 2.0.0+
# Python version: 3.6.5 (CPython)
# Docutils version: 0.14
# Jinja2 version: 2.10
# Last messages:
#   loading translations [en]...
#
#   done
#
#   making output directory...
#
#   building [mo]: targets for 1 po files that are out of date
#
#   writing output... [100%] locales/en/LC_MESSAGES/sphinx.mo
#
# Loaded extensions:
#   sphinx.ext.mathjax (2.0.0+) from /Users/tkomiya/work/sphinx/sphinx/ext/mathjax.py
#   alabaster (0.7.10) from /Users/tkomiya/work/tmp/lib/python3.6/site-packages/alabaster-0.7.10-py3.6.egg/alabaster/__init__.py
Traceback (most recent call last):
File "/Users/tkomiya/work/sphinx/sphinx/cmd/build.py", line 304, in build_main
app.build(args.force_all, filenames)
File "/Users/tkomiya/work/sphinx/sphinx/application.py", line 340, in build
self.builder.compile_update_catalogs()
File "/Users/tkomiya/work/sphinx/sphinx/builders/__init__.py", line 281, in compile_update_catalogs
self.compile_catalogs(catalogs, message)
File "/Users/tkomiya/work/sphinx/sphinx/builders/__init__.py", line 236, in compile_catalogs
catalog.write_mo(self.config.language)
File "/Users/tkomiya/work/sphinx/sphinx/util/i18n.py", line 71, in write_mo
with io.open(self.po_path, 'rt', encoding=self.charset) as file_po:
FileNotFoundError: [Errno 2] No such file or directory: '/Users/tkomiya/work/tmp/doc/test/locales/en/LC_MESSAGES/sphinx.po'

# Fixed code
def compile_specific_catalogs(self, specified_files):
    # type: (List[unicode]) -> None
    def to_domain(fpath):
        # type: (unicode) -> unicode
        docname = self.env.path2doc(path.abspath(fpath))
        if docname:
            return find_catalog(docname, self.config.gettext_compact)
        else:
            return None

    specified_domains = set(map(to_domain, specified_files))
    specified_domains.discard(None)
    catalogs = i18n.find_catalog_source_files(
        [path.join(self.srcdir, x) for x in self.config.locale_dirs],
        self.config.language,
        domains=list(specified_domains),
        charset=self.config.source_encoding,
        excluded=Matcher(["**/.?**"]),
    )
    message = __("targets for %d po files that are specified") % len(catalogs)
    self.compile_catalogs(catalogs, message)
# Buggy code
def compile_update_catalogs(self):
    # type: () -> None
    catalogs = i18n.find_catalog_source_files(
        [path.join(self.srcdir, x) for x in self.config.locale_dirs],
        self.config.language,
        charset=self.config.source_encoding,
        gettext_compact=self.config.gettext_compact,
        excluded=Matcher(["**/.?**"]),
    )
    message = __("targets for %d po files that are out of date") % len(catalogs)
    self.compile_catalogs(catalogs, message)


# Traceback (FileNotFoundError)
# Sphinx version: 2.0.0+
# Python version: 3.6.5 (CPython)
# Docutils version: 0.14
# Jinja2 version: 2.10
# Last messages:
#   loading translations [en]...
#
#   done
#
#   making output directory...
#
#   building [mo]: targets for 1 po files that are out of date
#
#   writing output... [100%] locales/en/LC_MESSAGES/sphinx.mo
#
# Loaded extensions:
#   sphinx.ext.mathjax (2.0.0+) from /Users/tkomiya/work/sphinx/sphinx/ext/mathjax.py
#   alabaster (0.7.10) from /Users/tkomiya/work/tmp/lib/python3.6/site-packages/alabaster-0.7.10-py3.6.egg/alabaster/__init__.py
Traceback (most recent call last):
File "/Users/tkomiya/work/sphinx/sphinx/cmd/build.py", line 304, in build_main
app.build(args.force_all, filenames)
File "/Users/tkomiya/work/sphinx/sphinx/application.py", line 340, in build
self.builder.compile_update_catalogs()
File "/Users/tkomiya/work/sphinx/sphinx/builders/__init__.py", line 281, in compile_update_catalogs
self.compile_catalogs(catalogs, message)
File "/Users/tkomiya/work/sphinx/sphinx/builders/__init__.py", line 236, in compile_catalogs
catalog.write_mo(self.config.language)
File "/Users/tkomiya/work/sphinx/sphinx/util/i18n.py", line 71, in write_mo
with io.open(self.po_path, 'rt', encoding=self.charset) as file_po:
FileNotFoundError: [Errno 2] No such file or directory: '/Users/tkomiya/work/tmp/doc/test/locales/en/LC_MESSAGES/sphinx.po'

# Fixed code
def compile_update_catalogs(self):
    # type: () -> None
    catalogs = i18n.find_catalog_source_files(
        [path.join(self.srcdir, x) for x in self.config.locale_dirs],
        self.config.language,
        charset=self.config.source_encoding,
        excluded=Matcher(["**/.?**"]),
    )
    message = __("targets for %d po files that are out of date") % len(catalogs)
    self.compile_catalogs(catalogs, message)
# Buggy code
def object_description(object):
    # type: (Any) -> unicode
    """A repr() implementation that returns text safe to use in reST context."""
    if isinstance(object, dict):
        try:
            sorted_keys = sorted(object)
        except TypeError:
            pass  # Cannot sort dict keys, fall back to generic repr
        else:
            items = ("%r: %r" % (key, object[key]) for key in sorted_keys)
            return "{%s}" % ", ".join(items)
    try:
        s = repr(object)
    except Exception:
        raise ValueError
    if isinstance(s, binary_type):
        s = force_decode(s, None)  # type: ignore
    # Strip non-deterministic memory addresses such as
    # ``<__main__.A at 0x7f68cb685710>``
    s = memory_address_re.sub("", s)
    return s.replace("\n", " ")


# Traceback (KeyError)
Traceback (most recent call last):
......
File "/usr/lib/python2.7/site-packages/sphinx/ext/autodoc/__init__.py", line 1252, in add_directive_header
objrepr = object_description(self.object)
File "/usr/lib/python2.7/site-packages/sphinx/util/inspect.py", line 243, in object_description
sorted_keys = sorted(object)
File "/opt/fabrix/fabrix/config.py", line 59, in __iter__
return self.__super__getitem__(env.host_string).__iter__()
KeyError: None

# Fixed code
def object_description(object):
    # type: (Any) -> unicode
    """A repr() implementation that returns text safe to use in reST context."""
    if isinstance(object, dict):
        try:
            sorted_keys = sorted(object)
        except Exception:
            pass  # Cannot sort dict keys, fall back to generic repr
        else:
            items = ("%r: %r" % (key, object[key]) for key in sorted_keys)
            return "{%s}" % ", ".join(items)
    try:
        s = repr(object)
    except Exception:
        raise ValueError
    if isinstance(s, binary_type):
        s = force_decode(s, None)  # type: ignore
    # Strip non-deterministic memory addresses such as
    # ``<__main__.A at 0x7f68cb685710>``
    s = memory_address_re.sub("", s)
    return s.replace("\n", " ")
# Buggy code
def compile_catalogs(self, catalogs, message):
    # type: (Set[CatalogInfo], unicode) -> None
    if not self.config.gettext_auto_build:
        return

    def cat2relpath(cat):
        # type: (CatalogInfo) -> unicode
        return path.relpath(cat.mo_path, self.env.srcdir).replace(path.sep, SEP)

    logger.info(bold("building [mo]: ") + message)
    for catalog in status_iterator(
        catalogs,
        "writing output... ",
        "darkgreen",
        len(catalogs),
        self.app.verbosity,
        stringify_func=cat2relpath,
    ):
        catalog.write_mo(self.config.language)


# Traceback (ValueError)
sphinx-err-847fe2th.log

# Sphinx version: 1.7.2
# Python version: 3.6.5rc1 (CPython)
# Docutils version: 0.14
# Jinja2 version: 2.10
# Last messages:
#   done
#
#   dumping object inventory...
#
#   done
#
#   build succeeded.
#
#
#
# Loaded extensions:
#   alabaster (0.7.10) from c:\users\user\appdata\local\programs\python\python36\lib\site-packages\alabaster\__init__.py
Traceback (most recent call last):
File "c:\users\user\appdata\local\programs\python\python36\lib\site-packages\sphinx\cmdline.py", line 304, in main
app.build(args.force_all, filenames)
File "c:\users\user\appdata\local\programs\python\python36\lib\site-packages\sphinx\application.py", line 345, in build
'outdir': path.relpath(self.outdir),
File "c:\users\user\appdata\local\programs\python\python36\lib\ntpath.py", line 586, in relpath
path_drive, start_drive))
ValueError: path is on mount 'C:', start on mount 'D:'

# Fixed code
def compile_catalogs(self, catalogs, message):
    # type: (Set[CatalogInfo], unicode) -> None
    if not self.config.gettext_auto_build:
        return

    def cat2relpath(cat):
        # type: (CatalogInfo) -> unicode
        return relpath(cat.mo_path, self.env.srcdir).replace(path.sep, SEP)

    logger.info(bold("building [mo]: ") + message)
    for catalog in status_iterator(
        catalogs,
        "writing output... ",
        "darkgreen",
        len(catalogs),
        self.app.verbosity,
        stringify_func=cat2relpath,
    ):
        catalog.write_mo(self.config.language)
# Buggy code
def cat2relpath(cat):
    # type: (CatalogInfo) -> unicode
    return path.relpath(cat.mo_path, self.env.srcdir).replace(path.sep, SEP)


# Traceback (ValueError)
sphinx-err-847fe2th.log

# Sphinx version: 1.7.2
# Python version: 3.6.5rc1 (CPython)
# Docutils version: 0.14
# Jinja2 version: 2.10
# Last messages:
#   done
#
#   dumping object inventory...
#
#   done
#
#   build succeeded.
#
#
#
# Loaded extensions:
#   alabaster (0.7.10) from c:\users\user\appdata\local\programs\python\python36\lib\site-packages\alabaster\__init__.py
Traceback (most recent call last):
File "c:\users\user\appdata\local\programs\python\python36\lib\site-packages\sphinx\cmdline.py", line 304, in main
app.build(args.force_all, filenames)
File "c:\users\user\appdata\local\programs\python\python36\lib\site-packages\sphinx\application.py", line 345, in build
'outdir': path.relpath(self.outdir),
File "c:\users\user\appdata\local\programs\python\python36\lib\ntpath.py", line 586, in relpath
path_drive, start_drive))
ValueError: path is on mount 'C:', start on mount 'D:'

# Fixed code
def cat2relpath(cat):
    # type: (CatalogInfo) -> unicode
    return relpath(cat.mo_path, self.env.srcdir).replace(path.sep, SEP)
# Buggy code
def path2doc(self, filename):
    # type: (unicode) -> Optional[unicode]
    """Return the docname for the filename if the file is document.

    *filename* should be absolute or relative to the source directory.
    """
    if filename.startswith(self.srcdir):
        filename = os.path.relpath(filename, self.srcdir)
    for suffix in self.config.source_suffix:
        if filename.endswith(suffix):
            return filename[: -len(suffix)]
    return None


# Traceback (ValueError)
sphinx-err-847fe2th.log

# Sphinx version: 1.7.2
# Python version: 3.6.5rc1 (CPython)
# Docutils version: 0.14
# Jinja2 version: 2.10
# Last messages:
#   done
#
#   dumping object inventory...
#
#   done
#
#   build succeeded.
#
#
#
# Loaded extensions:
#   alabaster (0.7.10) from c:\users\user\appdata\local\programs\python\python36\lib\site-packages\alabaster\__init__.py
Traceback (most recent call last):
File "c:\users\user\appdata\local\programs\python\python36\lib\site-packages\sphinx\cmdline.py", line 304, in main
app.build(args.force_all, filenames)
File "c:\users\user\appdata\local\programs\python\python36\lib\site-packages\sphinx\application.py", line 345, in build
'outdir': path.relpath(self.outdir),
File "c:\users\user\appdata\local\programs\python\python36\lib\ntpath.py", line 586, in relpath
path_drive, start_drive))
ValueError: path is on mount 'C:', start on mount 'D:'

# Fixed code
def path2doc(self, filename):
    # type: (unicode) -> Optional[unicode]
    """Return the docname for the filename if the file is document.

    *filename* should be absolute or relative to the source directory.
    """
    if filename.startswith(self.srcdir):
        filename = relpath(filename, self.srcdir)
    for suffix in self.config.source_suffix:
        if filename.endswith(suffix):
            return filename[: -len(suffix)]
    return None
# Buggy code
def find_catalog_files(docname, srcdir, locale_dirs, lang, compaction):
    # type: (unicode, unicode, List[unicode], unicode, bool) -> List[unicode]
    if not (lang and locale_dirs):
        return []

    domain = find_catalog(docname, compaction)
    files = [
        gettext.find(domain, path.join(srcdir, dir_), [lang])  # type: ignore
        for dir_ in locale_dirs
    ]
    files = [path.relpath(f, srcdir) for f in files if f]  # type: ignore
    return files  # type: ignore


# Traceback (ValueError)
sphinx-err-847fe2th.log

# Sphinx version: 1.7.2
# Python version: 3.6.5rc1 (CPython)
# Docutils version: 0.14
# Jinja2 version: 2.10
# Last messages:
#   done
#
#   dumping object inventory...
#
#   done
#
#   build succeeded.
#
#
#
# Loaded extensions:
#   alabaster (0.7.10) from c:\users\user\appdata\local\programs\python\python36\lib\site-packages\alabaster\__init__.py
Traceback (most recent call last):
File "c:\users\user\appdata\local\programs\python\python36\lib\site-packages\sphinx\cmdline.py", line 304, in main
app.build(args.force_all, filenames)
File "c:\users\user\appdata\local\programs\python\python36\lib\site-packages\sphinx\application.py", line 345, in build
'outdir': path.relpath(self.outdir),
File "c:\users\user\appdata\local\programs\python\python36\lib\ntpath.py", line 586, in relpath
path_drive, start_drive))
ValueError: path is on mount 'C:', start on mount 'D:'

# Fixed code
def find_catalog_files(docname, srcdir, locale_dirs, lang, compaction):
    # type: (unicode, unicode, List[unicode], unicode, bool) -> List[unicode]
    if not (lang and locale_dirs):
        return []

    domain = find_catalog(docname, compaction)
    files = [
        gettext.find(domain, path.join(srcdir, dir_), [lang])  # type: ignore
        for dir_ in locale_dirs
    ]
    files = [relpath(f, srcdir) for f in files if f]  # type: ignore
    return files  # type: ignore
# Buggy code
def build_latexpdf(self):
    # type: () -> int
    if self.run_generic_build("latex") > 0:
        return 1
    with cd(self.builddir_join("latex")):
        return subprocess.call([self.makecmd, "all-pdf"])


# Traceback (WindowsError)
Running Sphinx v1.7.1
loading translations [ja]... done
loading pickled environment... done
building [mo]: targets for 0 po files that are out of date
building [latex]: all documents
updating environment: [config changed] 1 added, 0 changed, 0 removed
reading sources... [100%] index
looking for now-outdated files... none found
pickling environment... done
checking consistency... done
processing second_document.tex...index
resolving references...
writing... done
copying TeX support files...
done
build succeeded.

The LaTeX files are in _build\latex.
Traceback (most recent call last):
File "C:\Users\hosoyyui\AppData\Local\Continuum\anaconda3\envs\py27\Scripts\sp
load_entry_point('Sphinx==1.7.1', 'console_scripts', 'sphinx-build')()
File "C:\Users\hosoyyui\AppData\Local\Continuum\anaconda3\envs\py27\lib\site-p
return make_main(argv)
File "C:\Users\hosoyyui\AppData\Local\Continuum\anaconda3\envs\py27\lib\site-p
return make_mode.run_make_mode(argv[1:])  # type: ignore
File "C:\Users\hosoyyui\AppData\Local\Continuum\anaconda3\envs\py27\lib\site-p
return getattr(make, run_method)()
File "C:\Users\hosoyyui\AppData\Local\Continuum\anaconda3\envs\py27\lib\site-p
return subprocess.call([self.makecmd, 'all-pdf'])
File "C:\Users\hosoyyui\AppData\Local\Continuum\anaconda3\envs\py27\lib\subpro
return Popen(*popenargs, **kwargs).wait()
File "C:\Users\hosoyyui\AppData\Local\Continuum\anaconda3\envs\py27\lib\subpro
errread, errwrite)
File "C:\Users\hosoyyui\AppData\Local\Continuum\anaconda3\envs\py27\lib\subpro
startupinfo)
WindowsError: [Error 2] *The system cannot find the file specified*

Note: The last line is translated sentence from Japanese.

# Fixed code
def build_latexpdf(self):
    # type: () -> int
    if self.run_generic_build("latex") > 0:
        return 1
    try:
        with cd(self.builddir_join("latex")):
            return subprocess.call([self.makecmd, "all-pdf"])
    except OSError:
        print("Error: Failed to run: %s" % self.makecmd)
        return 1
# Buggy code
def build_latexpdfja(self):
    # type: () -> int
    if self.run_generic_build("latex") > 0:
        return 1
    with cd(self.builddir_join("latex")):
        return subprocess.call([self.makecmd, "all-pdf-ja"])


# Traceback (WindowsError)
Running Sphinx v1.7.1
loading translations [ja]... done
loading pickled environment... done
building [mo]: targets for 0 po files that are out of date
building [latex]: all documents
updating environment: [config changed] 1 added, 0 changed, 0 removed
reading sources... [100%] index
looking for now-outdated files... none found
pickling environment... done
checking consistency... done
processing second_document.tex...index
resolving references...
writing... done
copying TeX support files...
done
build succeeded.

The LaTeX files are in _build\latex.
Traceback (most recent call last):
File "C:\Users\hosoyyui\AppData\Local\Continuum\anaconda3\envs\py27\Scripts\sp
load_entry_point('Sphinx==1.7.1', 'console_scripts', 'sphinx-build')()
File "C:\Users\hosoyyui\AppData\Local\Continuum\anaconda3\envs\py27\lib\site-p
return make_main(argv)
File "C:\Users\hosoyyui\AppData\Local\Continuum\anaconda3\envs\py27\lib\site-p
return make_mode.run_make_mode(argv[1:])  # type: ignore
File "C:\Users\hosoyyui\AppData\Local\Continuum\anaconda3\envs\py27\lib\site-p
return getattr(make, run_method)()
File "C:\Users\hosoyyui\AppData\Local\Continuum\anaconda3\envs\py27\lib\site-p
return subprocess.call([self.makecmd, 'all-pdf'])
File "C:\Users\hosoyyui\AppData\Local\Continuum\anaconda3\envs\py27\lib\subpro
return Popen(*popenargs, **kwargs).wait()
File "C:\Users\hosoyyui\AppData\Local\Continuum\anaconda3\envs\py27\lib\subpro
errread, errwrite)
File "C:\Users\hosoyyui\AppData\Local\Continuum\anaconda3\envs\py27\lib\subpro
startupinfo)
WindowsError: [Error 2] *The system cannot find the file specified*

Note: The last line is translated sentence from Japanese.

# Fixed code
def build_latexpdfja(self):
    # type: () -> int
    if self.run_generic_build("latex") > 0:
        return 1
    try:
        with cd(self.builddir_join("latex")):
            return subprocess.call([self.makecmd, "all-pdf-ja"])
    except OSError:
        print("Error: Failed to run: %s" % self.makecmd)
        return 1
# Buggy code
def build_info(self):
    # type: () -> int
    if self.run_generic_build("texinfo") > 0:
        return 1
    with cd(self.builddir_join("texinfo")):
        return subprocess.call([self.makecmd, "info"])


# Traceback (WindowsError)
Running Sphinx v1.7.1
loading translations [ja]... done
loading pickled environment... done
building [mo]: targets for 0 po files that are out of date
building [latex]: all documents
updating environment: [config changed] 1 added, 0 changed, 0 removed
reading sources... [100%] index
looking for now-outdated files... none found
pickling environment... done
checking consistency... done
processing second_document.tex...index
resolving references...
writing... done
copying TeX support files...
done
build succeeded.

The LaTeX files are in _build\latex.
Traceback (most recent call last):
File "C:\Users\hosoyyui\AppData\Local\Continuum\anaconda3\envs\py27\Scripts\sp
load_entry_point('Sphinx==1.7.1', 'console_scripts', 'sphinx-build')()
File "C:\Users\hosoyyui\AppData\Local\Continuum\anaconda3\envs\py27\lib\site-p
return make_main(argv)
File "C:\Users\hosoyyui\AppData\Local\Continuum\anaconda3\envs\py27\lib\site-p
return make_mode.run_make_mode(argv[1:])  # type: ignore
File "C:\Users\hosoyyui\AppData\Local\Continuum\anaconda3\envs\py27\lib\site-p
return getattr(make, run_method)()
File "C:\Users\hosoyyui\AppData\Local\Continuum\anaconda3\envs\py27\lib\site-p
return subprocess.call([self.makecmd, 'all-pdf'])
File "C:\Users\hosoyyui\AppData\Local\Continuum\anaconda3\envs\py27\lib\subpro
return Popen(*popenargs, **kwargs).wait()
File "C:\Users\hosoyyui\AppData\Local\Continuum\anaconda3\envs\py27\lib\subpro
errread, errwrite)
File "C:\Users\hosoyyui\AppData\Local\Continuum\anaconda3\envs\py27\lib\subpro
startupinfo)
WindowsError: [Error 2] *The system cannot find the file specified*

Note: The last line is translated sentence from Japanese.

# Fixed code
def build_info(self):
    # type: () -> int
    if self.run_generic_build("texinfo") > 0:
        return 1
    try:
        with cd(self.builddir_join("texinfo")):
            return subprocess.call([self.makecmd, "info"])
    except OSError:
        print("Error: Failed to run: %s" % self.makecmd)
        return 1
# Buggy code
def build_main(argv=sys.argv):
    """Sphinx build "main" command-line entry."""
    warnings.warn(
        "`sphinx.build_main()` has moved to `sphinx.cmd.build.build_main()`.",
        RemovedInSphinx20Warning,
        stacklevel=2,
    )
    return build.build_main(
        argv[1:]
    )  # skip first argument to adjust arguments (refs: #4615)


# Traceback (NameError)
Traceback (most recent call last):
File "./build-deploy.py", line 141, in <module>
errno = build_html(args.sourcedir, args.outputdir, args.branch, args.nitpicky, args.force)
File "./build-deploy.py", line 65, in build_html
errno = _sphinx_build(arglist)
File "./build-deploy.py", line 44, in _sphinx_build
return sphinx.make_main(arglist)
File "/usr/local/lib/python3.6/site-packages/sphinx/__init__.py", line 91, in make_main
return build.make_main(argv[1:])  # skip first argument to adjust arguments (refs: #4615)
NameError: name 'build' is not defined

# Fixed code
def build_main(argv=sys.argv):
    """Sphinx build "main" command-line entry."""
    from .cmd import build

    warnings.warn(
        "`sphinx.build_main()` has moved to `sphinx.cmd.build.build_main()`.",
        RemovedInSphinx20Warning,
        stacklevel=2,
    )
    return build.build_main(
        argv[1:]
    )  # skip first argument to adjust arguments (refs: #4615)
# Buggy code
def main(*args, **kwargs):
    from .cmd import build

    warnings.warn(
        "`sphinx.main()` has moved to `sphinx.cmd.build.main()`.",
        RemovedInSphinx20Warning,
        stacklevel=2,
    )
    return build.main(*args, **kwargs)


# Traceback (AttributeError)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: module 'sphinx' has no attribute 'build_main'

# Fixed code
def main(*args, **kwargs):
    from .cmd import build

    warnings.warn(
        "`sphinx.main()` has moved to `sphinx.cmd.build.main()`.",
        RemovedInSphinx20Warning,
        stacklevel=2,
    )
    args = args[1:]  # skip first argument to adjust arguments (refs: #4615)
    return build.main(*args, **kwargs)
# Buggy code
def main(*args, **kwargs):
    warnings.warn(
        "`sphinx.apidoc.main()` has moved to `sphinx.ext.apidoc.main()`.",
        RemovedInSphinx20Warning,
        stacklevel=2,
    )
    _main(*args, **kwargs)


# Traceback (AttributeError)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: module 'sphinx' has no attribute 'build_main'

# Fixed code
def main(*args, **kwargs):
    warnings.warn(
        "`sphinx.apidoc.main()` has moved to `sphinx.ext.apidoc.main()`.",
        RemovedInSphinx20Warning,
        stacklevel=2,
    )
    args = args[1:]  # skip first argument to adjust arguments (refs: #4615)
    _main(*args, **kwargs)
# Buggy code
def main(*args, **kwargs):
    warnings.warn(
        "`sphinx.quickstart.main()` has moved to `sphinx.cmd.quickstart.main()`.",
        RemovedInSphinx20Warning,
        stacklevel=2,
    )
    _main(*args, **kwargs)


# Traceback (AttributeError)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: module 'sphinx' has no attribute 'build_main'

# Fixed code
def main(*args, **kwargs):
    warnings.warn(
        "`sphinx.quickstart.main()` has moved to `sphinx.cmd.quickstart.main()`.",
        RemovedInSphinx20Warning,
        stacklevel=2,
    )
    args = args[1:]  # skip first argument to adjust arguments (refs: #4615)
    _main(*args, **kwargs)
# Buggy code
def __init__(self, app):
    # type: (Sphinx) -> None
    self.srcdir = app.srcdir
    self.confdir = app.confdir
    self.outdir = app.outdir
    self.doctreedir = app.doctreedir
    if not path.isdir(self.doctreedir):
        os.makedirs(self.doctreedir)

    self.app = app  # type: Sphinx
    self.env = None  # type: BuildEnvironment
    self.warn = app.warn  # type: Callable
    self.info = app.info  # type: Callable
    self.config = app.config  # type: Config
    self.tags = app.tags  # type: Tags
    self.tags.add(self.format)
    self.tags.add(self.name)
    self.tags.add("format_%s" % self.format)
    self.tags.add("builder_%s" % self.name)
    # compatibility aliases
    self.status_iterator = app.status_iterator
    self.old_status_iterator = app.old_status_iterator

    # images that need to be copied over (source -> dest)
    self.images = {}  # type: Dict[unicode, unicode]
    # basename of images directory
    self.imagedir = ""
    # relative path to image directory from current docname (used at writing docs)
    self.imgpath = ""  # type: unicode

    # these get set later
    self.parallel_ok = False
    self.finish_tasks = None  # type: Any


# Traceback (OSError)
# Sphinx version: 1.6.3
# Python version: 2.7.14 (CPython)
# Docutils version: 0.12 release
# Jinja2 version: 2.9.5
# Last messages:

# Loaded extensions:
Traceback (most recent call last):
File "/usr/lib/python2.7/site-packages/sphinx/cmdline.py", line 305, in main
opts.warningiserror, opts.tags, opts.verbosity, opts.jobs)
File "/usr/lib/python2.7/site-packages/sphinx/application.py", line 163, in __init__
os.makedirs(outdir)
File "/usr/lib/python2.7/os.py", line 157, in makedirs
mkdir(name, mode)
OSError: [Errno 17] File exists: '/var/tmp/portage/sys-devel/llvm-9999/work/llvm-9999-abi_x86_32.x86/docs/man'

# Fixed code
def __init__(self, app):
    # type: (Sphinx) -> None
    self.srcdir = app.srcdir
    self.confdir = app.confdir
    self.outdir = app.outdir
    self.doctreedir = app.doctreedir
    ensuredir(self.doctreedir)

    self.app = app  # type: Sphinx
    self.env = None  # type: BuildEnvironment
    self.warn = app.warn  # type: Callable
    self.info = app.info  # type: Callable
    self.config = app.config  # type: Config
    self.tags = app.tags  # type: Tags
    self.tags.add(self.format)
    self.tags.add(self.name)
    self.tags.add("format_%s" % self.format)
    self.tags.add("builder_%s" % self.name)
    # compatibility aliases
    self.status_iterator = app.status_iterator
    self.old_status_iterator = app.old_status_iterator

    # images that need to be copied over (source -> dest)
    self.images = {}  # type: Dict[unicode, unicode]
    # basename of images directory
    self.imagedir = ""
    # relative path to image directory from current docname (used at writing docs)
    self.imgpath = ""  # type: unicode

    # these get set later
    self.parallel_ok = False
    self.finish_tasks = None  # type: Any
# Buggy code
def convert_serializable(records):
    # type: (List[logging.LogRecord]) -> None
    """Convert LogRecord serializable."""
    for r in records:
        # extract arguments to a message and clear them
        r.msg = r.getMessage()
        r.args = ()


# Traceback (PicklingError)
$ sphinx-build -j 2 -b html source build
Running Sphinx v1.6.5
making output directory...
loading pickled environment... not yet created
building [mo]: targets for 0 po files that are out of date
building [html]: targets for 2 source files that are out of date
updating environment: 2 added, 0 changed, 0 removed
reading sources... [ 50%] foo
reading sources... [100%] index

looking for now-outdated files... none found
pickling environment... done
checking consistency... /private/tmp/docs/source/foo.rst: WARNING: document isn't included in any toctree
done
preparing documents... done
writing output... [100%] index

waiting for workers...
Process Process-1:
Traceback (most recent call last):
File "/Users/sfranklin/Python/Python-2.7.13/lib/python2.7/multiprocessing/process.py", line 258, in _bootstrap
self.run()
File "/Users/sfranklin/Python/Python-2.7.13/lib/python2.7/multiprocessing/process.py", line 114, in run
self._target(*self._args, **self._kwargs)
File "/Users/sfranklin/.virtualenvs/sphinx/lib/python2.7/site-packages/sphinx/util/parallel.py", line 94, in _process
pipe.send((failed, collector.logs, ret))
PicklingError: Can't pickle <type 'function'>: attribute lookup __builtin__.function failed

# Fixed code
def convert_serializable(records):
    # type: (List[logging.LogRecord]) -> None
    """Convert LogRecord serializable."""
    for r in records:
        # extract arguments to a message and clear them
        r.msg = r.getMessage()
        r.args = ()

        location = getattr(r, "location", None)
        if isinstance(location, nodes.Node):
            r.location = get_node_location(location)  # type: ignore
# Buggy code
def filter(self, record):
    # type: (logging.LogRecord) -> bool
    if getattr(record, "skip_warningsiserror", False):
        # disabled by DisableWarningIsErrorFilter
        return True
    elif self.app.warningiserror:
        location = getattr(record, "location", "")
        if location:
            raise SphinxWarning(location + ":" + record.msg % record.args)
        else:
            raise SphinxWarning(record.msg % record.args)
    else:
        return True


# Traceback (RuntimeError)
python -msphinx -b html -d _build/doctrees  -W . _build/html
Running Sphinx v1.6.3
loading translations [en]... done
loading pickled environment... not yet created
building [mo]: targets for 0 po files that are out of date
building [html]: targets for 2 source files that are out of date
updating environment: 2 added, 0 changed, 0 removed
reading sources... [100%] pkg

Warning, treated as error:
/tmp/foo/doc/pkg.rst:7: (WARNING/2) autodoc: failed to import module 'pkg'; the following exception was raised:
Traceback (most recent call last):
File "/usr/lib/python3.6/site-packages/sphinx/ext/autodoc.py", line 657, in import_object
__import__(self.modname)
File "/tmp/foo/pkg/__init__.py", line 1, in <module>
raise RuntimeError("oops")
RuntimeError: oops
make: *** [Makefile:55: html] Error 1

# Fixed code
def filter(self, record):
    # type: (logging.LogRecord) -> bool
    if getattr(record, "skip_warningsiserror", False):
        # disabled by DisableWarningIsErrorFilter
        return True
    elif self.app.warningiserror:
        location = getattr(record, "location", "")
        message = record.msg.replace("%", "%%")
        if location:
            raise SphinxWarning(location + ":" + message % record.args)
        else:
            raise SphinxWarning(message % record.args)
    else:
        return True
# Buggy code
def __init__(self, names):
    # type: (List[str]) -> None
    self.base_packages = set()  # type: Set[str]
    for n in names:
        # Convert module names:
        #     ['a.b.c', 'd.e']
        # to a set of base packages:
        #     set(['a', 'd'])
        self.base_packages.add(n.split(".")[0])
    self.mocked_modules = []  # type: List[str]
    self.orig_meta_path = sys.meta_path
    # enable hook by adding itself to meta_path
    sys.meta_path = sys.meta_path + [self]


# Traceback (ImportError)
WARNING: /home/vagrant/reprod/index.rst:3: (WARNING/2) autodoc: failed to import module 'django.utils.six.moves'; the following exception was raised:
Traceback (most recent call last):
File "/home/vagrant/.virtualenvs/pulp/lib/python3.5/site-packages/sphinx/ext/autodoc.py", line 658, in import_object
__import__(self.modname)
ImportError: No module named 'django.utils.six.moves'

# Fixed code
def __init__(self, names):
    # type: (List[str]) -> None
    self.base_packages = set()  # type: Set[str]
    for n in names:
        # Convert module names:
        #     ['a.b.c', 'd.e']
        # to a set of base packages:
        #     set(['a', 'd'])
        self.base_packages.add(n.split(".")[0])
    self.mocked_modules = []  # type: List[str]
    # enable hook by adding itself to meta_path
    sys.meta_path = sys.meta_path + [self]
# Buggy code
def disable(self):
    # restore original meta_path to disable import hook
    sys.meta_path = self.orig_meta_path
    # remove mocked modules from sys.modules to avoid side effects after
    # running auto-documenter
    for m in self.mocked_modules:
        if m in sys.modules:
            del sys.modules[m]


# Traceback (ImportError)
WARNING: /home/vagrant/reprod/index.rst:3: (WARNING/2) autodoc: failed to import module 'django.utils.six.moves'; the following exception was raised:
Traceback (most recent call last):
File "/home/vagrant/.virtualenvs/pulp/lib/python3.5/site-packages/sphinx/ext/autodoc.py", line 658, in import_object
__import__(self.modname)
ImportError: No module named 'django.utils.six.moves'

# Fixed code
def disable(self):
    # remove `self` from `sys.meta_path` to disable import hook
    sys.meta_path = [i for i in sys.meta_path if i is not self]
    # remove mocked modules from sys.modules to avoid side effects after
    # running auto-documenter
    for m in self.mocked_modules:
        if m in sys.modules:
            del sys.modules[m]
# Buggy code
def __iadd__(self, other):
    warnings.warn(
        "builder.css_files is deprecated. Please use app.add_stylesheet() instead.",
        RemovedInSphinx20Warning,
    )
    for item in other:
        self.append(item)


# Traceback (TypeError)
Traceback (most recent call last):
File
"/usr/local/src/py3_virtual/lib/python3.5/site-packages/sphinx/cmdline.py",
line 306, in main
app.build(opts.force_all, filenames)
File
"/usr/local/src/py3_virtual/lib/python3.5/site-packages/sphinx/application.py",
line 338, in build
self.builder.build_update()
File
"/usr/local/src/py3_virtual/lib/python3.5/site-packages/sphinx/builders/__init__.py",
line 328, in build_update
'out of date' % len(to_build))
File
"/usr/local/src/py3_virtual/lib/python3.5/site-packages/sphinx/builders/__init__.py",
line 394, in build
self.write(docnames, list(updated_docnames), method)
File
"/usr/local/src/py3_virtual/lib/python3.5/site-packages/sphinx/builders/__init__.py",
line 431, in write
self._write_serial(sorted(docnames))
File
"/usr/local/src/py3_virtual/lib/python3.5/site-packages/sphinx/builders/__init__.py",
line 440, in _write_serial
self.write_doc(docname, doctree)
File
"/usr/local/src/py3_virtual/lib/python3.5/site-packages/sphinx/builders/html.py",
line 556, in write_doc
self.handle_page(docname, ctx, event_arg=doctree)
File
"/usr/local/src/py3_virtual/lib/python3.5/site-packages/sphinx/builders/html.py",
line 940, in handle_page
output = self.templates.render(templatename, ctx)
File
"/usr/local/src/py3_virtual/lib/python3.5/site-packages/sphinx/jinja2glue.py",
line 176, in render
return self.environment.get_template(template).render(context)
File
"/usr/local/src/py3_virtual/lib/python3.5/site-packages/jinja2/environment.py",
line 1008, in render
return self.environment.handle_exception(exc_info, True)
File
"/usr/local/src/py3_virtual/lib/python3.5/site-packages/jinja2/environment.py",
line 780, in handle_exception
reraise(exc_type, exc_value, tb)
File
"/usr/local/src/py3_virtual/lib/python3.5/site-packages/jinja2/_compat.py",
line 37, in reraise
raise value.with_traceback(tb)
File
"/usr/local/src/py3_virtual/lib/python3.5/site-packages/sphinx/themes/basic/page.html",
line 10, in top-level template code
{%- extends "layout.html" %}
File "/usr/local/src/pcav/faunalia-website/_templates/layout.html",
line 39, in top-level template code
{% block languageswitch %}
File
"/usr/local/src/py3_virtual/lib/python3.5/site-packages/sphinx_bootstrap_theme/bootstrap/layout.html",
line 40, in top-level template code
{% set css_files = css_files + theme_css_files +
bootswatch_css_custom %}
TypeError: unsupported operand type(s) for +: 'NoneType' and 'list'

/usr/local/src/py3_virtual/lib/python3.5/site-packages/sphinx_bootstrap_theme/bootstrap/layout.html(40)top-level
template code()
-> {% set css_files = css_files + theme_css_files + bootswatch_css_custom %}

# Fixed code
def __iadd__(self, other):
    warnings.warn(
        "builder.css_files is deprecated. Please use app.add_stylesheet() instead.",
        RemovedInSphinx20Warning,
    )
    for item in other:
        self.append(item)
    return self
# Buggy code
def loads(cls, string, app=None):
    # type: (unicode, Sphinx) -> BuildEnvironment
    io = StringIO(string)
    return cls.load(io, app)


# Traceback (sphinx.errors.SphinxParallelError)
→ sphinx-build -j4 -b html -d tmp docs docs/build/_html -v > 1.log                                                                   ~/PycharmProjects/pytrip

Traceback (most recent call last):
File "/usr/lib/python3.6/site-packages/sphinx/cmdline.py", line 306, in main
app.build(opts.force_all, filenames)
File "/usr/lib/python3.6/site-packages/sphinx/application.py", line 338, in build
self.builder.build_update()
File "/usr/lib/python3.6/site-packages/sphinx/builders/__init__.py", line 328, in build_update
'out of date' % len(to_build))
File "/usr/lib/python3.6/site-packages/sphinx/builders/__init__.py", line 341, in build
updated_docnames = set(self.env.update(self.config, self.srcdir, self.doctreedir))
File "/usr/lib/python3.6/site-packages/sphinx/environment/__init__.py", line 581, in update
self._read_parallel(docnames, self.app, nproc=self.app.parallel)
File "/usr/lib/python3.6/site-packages/sphinx/environment/__init__.py", line 633, in _read_parallel
tasks.join()
File "/usr/lib/python3.6/site-packages/sphinx/util/parallel.py", line 112, in join
self._join_one()
File "/usr/lib/python3.6/site-packages/sphinx/util/parallel.py", line 120, in _join_one
raise SphinxParallelError(*result)
sphinx.errors.SphinxParallelError: TypeError: string argument expected, got 'bytes'

Sphinx parallel build error:
TypeError: string argument expected, got 'bytes'

# Fixed code
def loads(cls, string, app=None):
    # type: (unicode, Sphinx) -> BuildEnvironment
    io = BytesIO(string)
    return cls.load(io, app)