gurudesh/pytracebugs huggingface dataset:
# Buggy code
def dumps(cls, env):
    # type: (BuildEnvironment) -> unicode
    io = StringIO()
    cls.dump(env, io)
    return io.getvalue()


# 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 dumps(cls, env):
    # type: (BuildEnvironment) -> unicode
    io = BytesIO()
    cls.dump(env, io)
    return io.getvalue()
# Buggy code
def add_latex_package(self, packagename, options=None):
    self.debug("[app] adding latex package: %r", packagename)
    self.builder.usepackages.append((packagename, options))


# Traceback (AttributeError)
# Sphinx version: 1.5.1
# Python version: 2.7.13 (CPython)
# Docutils version: 0.13.1 release
# Jinja2 version: 2.8.1
# Last messages:

# Loaded extensions:
Traceback (most recent call last):
File "/home/louis/.virtualenvs/sphinx-mwe/local/lib/python2.7/site-packages/sphinx/cmdline.py", line 295, in main
opts.warningiserror, opts.tags, opts.verbosity, opts.jobs)
File "/home/louis/.virtualenvs/sphinx-mwe/local/lib/python2.7/site-packages/sphinx/application.py", line 199, in __init__
self.setup_extension(extension)
File "/home/louis/.virtualenvs/sphinx-mwe/local/lib/python2.7/site-packages/sphinx/application.py", line 523, in setup_extension
ext_meta = mod.setup(self)
File "/home/louis/projets/_contrib/sphinx-bug-mwe/foo.py", line 2, in setup
app.add_latex_package("babel")
File "/home/louis/.virtualenvs/sphinx-mwe/local/lib/python2.7/site-packages/sphinx/application.py", line 809, in add_latex_package
self.builder.usepackages.append((packagename, options))
AttributeError: 'NoneType' object has no attribute 'usepackages'

# Fixed code
def add_latex_package(self, packagename, options=None):
    self.debug("[app] adding latex package: %r", packagename)
    if hasattr(self.builder, "usepackages"):  # only for LaTeX builder
        self.builder.usepackages.append((packagename, options))
# Buggy code
def ustrftime(format, *args):
    # if a locale is set, the time strings are encoded in the encoding
    # given by LC_TIME; if that is available, use it
    enc = locale.getlocale(locale.LC_TIME)[1] or "utf-8"
    return time.strftime(text_type(format).encode(enc), *args).decode(enc)


# Traceback (UnicodeEncodeError)
Traceback (most recent call last):
File "c:\Develop\pytools\sphinx-13\lib\site-packages\sphinx\cmdline.py", line 245, in main
app.build(opts.force_all, filenames)
File "c:\Develop\pytools\sphinx-13\lib\site-packages\sphinx\application.py", line 264, in build
self.builder.build_update()
File "c:\Develop\pytools\sphinx-13\lib\site-packages\sphinx\builders\__init__.py", line 245, in build_update
'out of date' % len(to_build))
File "c:\Develop\pytools\sphinx-13\lib\site-packages\sphinx\builders\__init__.py", line 259, in build
self.doctreedir, self.app))
File "c:\Develop\pytools\sphinx-13\lib\site-packages\sphinx\environment.py", line 618, in update
self._read_serial(docnames, app)
File "c:\Develop\pytools\sphinx-13\lib\site-packages\sphinx\environment.py", line 638, in _read_serial
self.read_doc(docname, app)
File "c:\Develop\pytools\sphinx-13\lib\site-packages\sphinx\environment.py", line 791, in read_doc
pub.publish()
File "c:\Develop\pytools\sphinx-13\lib\site-packages\docutils\core.py", line 218, in publish
self.apply_transforms()
File "c:\Develop\pytools\sphinx-13\lib\site-packages\docutils\core.py", line 199, in apply_transforms
self.document.transformer.apply_transforms()
File "c:\Develop\pytools\sphinx-13\lib\site-packages\docutils\transforms\__init__.py", line 171, in apply_transforms
transform.apply(**kwargs)
File "c:\Develop\pytools\sphinx-13\lib\site-packages\sphinx\transforms.py", line 59, in apply
text = ustrftime(config.today_fmt or _('%B %d, %Y'))
UnicodeEncodeError: 'locale' codec can't encode character '\u5e74' in position 3: Illegal byte sequence

# Fixed code
def ustrftime(format, *args):
    # On Windows, time.strftime() and Unicode characters will raise UnicodeEncodeError.
    # http://bugs.python.org/issue8304
    try:
        return time.strftime(format, *args)
    except UnicodeEncodeError:
        r = time.strftime(format.encode("unicode-escape").decode(), *args)
        return r.encode().decode("unicode-escape")
# Buggy code
def assemble_doctree(self):
    master = self.config.master_doc
    tree = self.env.get_doctree(master)
    tree = inline_all_toctrees(self, set(), master, tree, darkgreen)
    tree["docname"] = master
    self.env.resolve_references(tree, master, self)
    self.fix_refuris(tree)
    return tree


# Traceback (RuntimeError)
# Sphinx version: 1.2.2
# Python version: 2.7.7
# Docutils version: 0.12 release
# Jinja2 version: 2.7.3
# Loaded extensions:
#   sphinx.ext.oldcmarkup from /Users/tkomiya/.buildout/buildout-eggs/Sphinx-1.2.2-py2.7.egg/sphinx/ext/oldcmarkup.pyc
Traceback (most recent call last):
File "/Users/tkomiya/.buildout/buildout-eggs/Sphinx-1.2.2-py2.7.egg/sphinx/cmdline.py", line 254, in main
app.build(force_all, filenames)
File "/Users/tkomiya/.buildout/buildout-eggs/Sphinx-1.2.2-py2.7.egg/sphinx/application.py", line 212, in build
self.builder.build_update()
File "/Users/tkomiya/.buildout/buildout-eggs/Sphinx-1.2.2-py2.7.egg/sphinx/builders/__init__.py", line 209, in build_update
self.build(['__all__'], to_build)
File "/Users/tkomiya/.buildout/buildout-eggs/Sphinx-1.2.2-py2.7.egg/sphinx/builders/__init__.py", line 276, in build
self.write(docnames, list(updated_docnames), method)
File "/Users/tkomiya/.buildout/buildout-eggs/Sphinx-1.2.2-py2.7.egg/sphinx/builders/latex.py", line 97, in write
self.config.latex_appendices or []))
File "/Users/tkomiya/.buildout/buildout-eggs/Sphinx-1.2.2-py2.7.egg/sphinx/builders/latex.py", line 133, in assemble_doctree
self.env.resolve_references(largetree, indexfile, self)
File "/Users/tkomiya/.buildout/buildout-eggs/Sphinx-1.2.2-py2.7.egg/sphinx/environment.py", line 1327, in resolve_references
for node in doctree.traverse(addnodes.pending_xref):
File "/Users/tkomiya/.buildout/buildout-eggs/docutils-0.12-py2.7.egg/docutils/nodes.py", line 252, in traverse
return self._fast_traverse(condition)
File "/Users/tkomiya/.buildout/buildout-eggs/docutils-0.12-py2.7.egg/docutils/nodes.py", line 196, in _fast_traverse
result.extend(child._fast_traverse(cls))
File "/Users/tkomiya/.buildout/buildout-eggs/docutils-0.12-py2.7.egg/docutils/nodes.py", line 196, in _fast_traverse
result.extend(child._fast_traverse(cls))
...
File "/Users/tkomiya/.buildout/buildout-eggs/docutils-0.12-py2.7.egg/docutils/nodes.py", line 196, in _fast_traverse
result.extend(child._fast_traverse(cls))
File "/Users/tkomiya/.buildout/buildout-eggs/docutils-0.12-py2.7.egg/docutils/nodes.py", line 193, in _fast_traverse
if isinstance(self, cls):
RuntimeError: maximum recursion depth exceeded while calling a Python object

# Fixed code
def assemble_doctree(self):
    master = self.config.master_doc
    tree = self.env.get_doctree(master)
    tree = inline_all_toctrees(self, set(), master, tree, darkgreen, [master])
    tree["docname"] = master
    self.env.resolve_references(tree, master, self)
    self.fix_refuris(tree)
    return tree
# Buggy code
def compile_all_catalogs(self):
    catalogs = i18n.find_catalog_source_files(
        [path.join(self.srcdir, x) for x in self.config.locale_dirs],
        self.config.language,
        gettext_compact=self.config.gettext_compact,
        force_all=True,
    )
    message = "all of %d po files" % len(catalogs)
    self.compile_catalogs(catalogs, message)


# Traceback (UnicodeDecodeError)
D:\test>set SPHINXOPTS=-T

D:\test>make.bat html
Running Sphinx v1.3.1
loading translations [ja]... done
loading pickled environment... not yet created
building [mo]: targets for 1 po files that are out of date
writing output... [100%] D:\test\locale\ja\LC_MESSAGES\index.mo
Traceback (most recent call last):
File "C:\Develop\pytools\sphinx-13\lib\site-packages\sphinx\cmdline.py", line 245, in main
app.build(opts.force_all, filenames)
File "C:\Develop\pytools\sphinx-13\lib\site-packages\sphinx\application.py", line 263, in build
self.builder.compile_update_catalogs()
File "C:\Develop\pytools\sphinx-13\lib\site-packages\sphinx\builders\__init__.py", line 199, in compile_update_catalogs
self.compile_catalogs(catalogs, message)
File "C:\Develop\pytools\sphinx-13\lib\site-packages\sphinx\builders\__init__.py", line 167, in compile_catalogs
catalog.write_mo(self.config.language)
File "C:\Develop\pytools\sphinx-13\lib\site-packages\sphinx\util\i18n.py", line 51, in write_mo
write_mo(mo, read_po(po, locale))
File "C:\Develop\pytools\sphinx-13\lib\site-packages\babel\messages\pofile.py", line 204, in read_po
for lineno, line in enumerate(fileobj.readlines()):
UnicodeDecodeError: 'cp932' codec can't decode byte 0x86 in position 576: illegal multibyte sequence

Encoding error:
'cp932' codec can't decode byte 0x86 in position 576: illegal multibyte sequence
The full traceback has been saved in D:\Temp\sphinx-err-8vfmzqmf.log, if you want to report the issue to the developers.

# Fixed code
def compile_all_catalogs(self):
    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,
    )
    message = "all of %d po files" % len(catalogs)
    self.compile_catalogs(catalogs, message)
# Buggy code
def compile_specific_catalogs(self, specified_files):
    def to_domain(fpath):
        docname, _ = path.splitext(path_stabilize(fpath))
        dom = find_catalog(docname, self.config.gettext_compact)
        return dom

    specified_domains = set(map(to_domain, specified_files))
    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),
        gettext_compact=self.config.gettext_compact,
    )
    message = "targets for %d po files that are specified" % len(catalogs)
    self.compile_catalogs(catalogs, message)


# Traceback (UnicodeDecodeError)
D:\test>set SPHINXOPTS=-T

D:\test>make.bat html
Running Sphinx v1.3.1
loading translations [ja]... done
loading pickled environment... not yet created
building [mo]: targets for 1 po files that are out of date
writing output... [100%] D:\test\locale\ja\LC_MESSAGES\index.mo
Traceback (most recent call last):
File "C:\Develop\pytools\sphinx-13\lib\site-packages\sphinx\cmdline.py", line 245, in main
app.build(opts.force_all, filenames)
File "C:\Develop\pytools\sphinx-13\lib\site-packages\sphinx\application.py", line 263, in build
self.builder.compile_update_catalogs()
File "C:\Develop\pytools\sphinx-13\lib\site-packages\sphinx\builders\__init__.py", line 199, in compile_update_catalogs
self.compile_catalogs(catalogs, message)
File "C:\Develop\pytools\sphinx-13\lib\site-packages\sphinx\builders\__init__.py", line 167, in compile_catalogs
catalog.write_mo(self.config.language)
File "C:\Develop\pytools\sphinx-13\lib\site-packages\sphinx\util\i18n.py", line 51, in write_mo
write_mo(mo, read_po(po, locale))
File "C:\Develop\pytools\sphinx-13\lib\site-packages\babel\messages\pofile.py", line 204, in read_po
for lineno, line in enumerate(fileobj.readlines()):
UnicodeDecodeError: 'cp932' codec can't decode byte 0x86 in position 576: illegal multibyte sequence

Encoding error:
'cp932' codec can't decode byte 0x86 in position 576: illegal multibyte sequence
The full traceback has been saved in D:\Temp\sphinx-err-8vfmzqmf.log, if you want to report the issue to the developers.

# Fixed code
def compile_specific_catalogs(self, specified_files):
    def to_domain(fpath):
        docname, _ = path.splitext(path_stabilize(fpath))
        dom = find_catalog(docname, self.config.gettext_compact)
        return dom

    specified_domains = set(map(to_domain, specified_files))
    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,
    )
    message = "targets for %d po files that are specified" % len(catalogs)
    self.compile_catalogs(catalogs, message)
# Buggy code
def compile_update_catalogs(self):
    catalogs = i18n.find_catalog_source_files(
        [path.join(self.srcdir, x) for x in self.config.locale_dirs],
        self.config.language,
        gettext_compact=self.config.gettext_compact,
    )
    message = "targets for %d po files that are out of date" % len(catalogs)
    self.compile_catalogs(catalogs, message)


# Traceback (UnicodeDecodeError)
D:\test>set SPHINXOPTS=-T

D:\test>make.bat html
Running Sphinx v1.3.1
loading translations [ja]... done
loading pickled environment... not yet created
building [mo]: targets for 1 po files that are out of date
writing output... [100%] D:\test\locale\ja\LC_MESSAGES\index.mo
Traceback (most recent call last):
File "C:\Develop\pytools\sphinx-13\lib\site-packages\sphinx\cmdline.py", line 245, in main
app.build(opts.force_all, filenames)
File "C:\Develop\pytools\sphinx-13\lib\site-packages\sphinx\application.py", line 263, in build
self.builder.compile_update_catalogs()
File "C:\Develop\pytools\sphinx-13\lib\site-packages\sphinx\builders\__init__.py", line 199, in compile_update_catalogs
self.compile_catalogs(catalogs, message)
File "C:\Develop\pytools\sphinx-13\lib\site-packages\sphinx\builders\__init__.py", line 167, in compile_catalogs
catalog.write_mo(self.config.language)
File "C:\Develop\pytools\sphinx-13\lib\site-packages\sphinx\util\i18n.py", line 51, in write_mo
write_mo(mo, read_po(po, locale))
File "C:\Develop\pytools\sphinx-13\lib\site-packages\babel\messages\pofile.py", line 204, in read_po
for lineno, line in enumerate(fileobj.readlines()):
UnicodeDecodeError: 'cp932' codec can't decode byte 0x86 in position 576: illegal multibyte sequence

Encoding error:
'cp932' codec can't decode byte 0x86 in position 576: illegal multibyte sequence
The full traceback has been saved in D:\Temp\sphinx-err-8vfmzqmf.log, if you want to report the issue to the developers.

# Fixed code
def compile_update_catalogs(self):
    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,
    )
    message = "targets for %d po files that are out of date" % len(catalogs)
    self.compile_catalogs(catalogs, message)
# Buggy code
def write_mo(self, locale):
    with open(self.po_path, "rt") as po:
        with open(self.mo_path, "wb") as mo:
            write_mo(mo, read_po(po, locale))


# Traceback (UnicodeDecodeError)
D:\test>set SPHINXOPTS=-T

D:\test>make.bat html
Running Sphinx v1.3.1
loading translations [ja]... done
loading pickled environment... not yet created
building [mo]: targets for 1 po files that are out of date
writing output... [100%] D:\test\locale\ja\LC_MESSAGES\index.mo
Traceback (most recent call last):
File "C:\Develop\pytools\sphinx-13\lib\site-packages\sphinx\cmdline.py", line 245, in main
app.build(opts.force_all, filenames)
File "C:\Develop\pytools\sphinx-13\lib\site-packages\sphinx\application.py", line 263, in build
self.builder.compile_update_catalogs()
File "C:\Develop\pytools\sphinx-13\lib\site-packages\sphinx\builders\__init__.py", line 199, in compile_update_catalogs
self.compile_catalogs(catalogs, message)
File "C:\Develop\pytools\sphinx-13\lib\site-packages\sphinx\builders\__init__.py", line 167, in compile_catalogs
catalog.write_mo(self.config.language)
File "C:\Develop\pytools\sphinx-13\lib\site-packages\sphinx\util\i18n.py", line 51, in write_mo
write_mo(mo, read_po(po, locale))
File "C:\Develop\pytools\sphinx-13\lib\site-packages\babel\messages\pofile.py", line 204, in read_po
for lineno, line in enumerate(fileobj.readlines()):
UnicodeDecodeError: 'cp932' codec can't decode byte 0x86 in position 576: illegal multibyte sequence

Encoding error:
'cp932' codec can't decode byte 0x86 in position 576: illegal multibyte sequence
The full traceback has been saved in D:\Temp\sphinx-err-8vfmzqmf.log, if you want to report the issue to the developers.

# Fixed code
def write_mo(self, locale):
    with io.open(self.po_path, "rt", encoding=self.charset) as po:
        with io.open(self.mo_path, "wb") as mo:
            write_mo(mo, read_po(po, locale))
# Buggy code
def __init__(self_, *args, **kwds):
    # don't call sys.exit() on IOErrors
    kwds["handle_io_errors"] = False
    FileInput.__init__(self_, *args, **kwds)


# Traceback (UnicodeDecodeError)
#!python
# Sphinx version: 1.3a0
# Python version: 3.3.4
# Docutils version: 0.10 release
# Jinja2 version: 2.6
# Loaded extensions:
#   sphinx.ext.todo from C:\Python33\lib\site-packages\sphinx-1.3a0dev_20140728-py3.3.egg\sphinx\ext\todo.py
#   sphinx.ext.ifconfig from C:\Python33\lib\site-packages\sphinx-1.3a0dev_20140728-py3.3.egg\sphinx\ext\ifconfig.py
#   sphinx.ext.extlinks from C:\Python33\lib\site-packages\sphinx-1.3a0dev_20140728-py3.3.egg\sphinx\ext\extlinks.py
#   sphinx.ext.intersphinx from C:\Python33\lib\site-packages\sphinx-1.3a0dev_20140728-py3.3.egg\sphinx\ext\intersphinx.py
#   sphinx.ext.mathjax from C:\Python33\lib\site-packages\sphinx-1.3a0dev_20140728-py3.3.egg\sphinx\ext\mathjax.py
#   sphinx.ext.pngmath from C:\Python33\lib\site-packages\sphinx-1.3a0dev_20140728-py3.3.egg\sphinx\ext\pngmath.py
Traceback (most recent call last):
File "C:\Python33\lib\site-packages\sphinx-1.3a0dev_20140728-py3.3.egg\sphinx\cmdline.py", line 253, in main
app.build(force_all, filenames)
File "C:\Python33\lib\site-packages\sphinx-1.3a0dev_20140728-py3.3.egg\sphinx\application.py", line 223, in build
self.builder.build_update()
File "C:\Python33\lib\site-packages\sphinx-1.3a0dev_20140728-py3.3.egg\sphinx\builders\__init__.py", line 214, in build_update
'out of date' &amp;#37; len(to_build))
File "C:\Python33\lib\site-packages\sphinx-1.3a0dev_20140728-py3.3.egg\sphinx\builders\__init__.py", line 234, in build
purple, length):
File "C:\Python33\lib\site-packages\sphinx-1.3a0dev_20140728-py3.3.egg\sphinx\builders\__init__.py", line 134, in status_iterator
for item in iterable:
File "C:\Python33\lib\site-packages\sphinx-1.3a0dev_20140728-py3.3.egg\sphinx\environment.py", line 474, in update_generator
self.read_doc(docname, app=app)
File "C:\Python33\lib\site-packages\sphinx-1.3a0dev_20140728-py3.3.egg\sphinx\environment.py", line 621, in read_doc
pub.publish()
File "C:\Python33\lib\site-packages\docutils-0.10-py3.3.egg\docutils\core.py", line 217, in publish
self.settings)
File "C:\Python33\lib\site-packages\docutils-0.10-py3.3.egg\docutils\readers\__init__.py", line 71, in read
self.input = self.source.read()
File "C:\Python33\lib\site-packages\sphinx-1.3a0dev_20140728-py3.3.egg\sphinx\environment.py", line 601, in read
data = FileInput.read(self_)
File "C:\Python33\lib\site-packages\docutils-0.10-py3.3.egg\docutils\io.py", line 265, in read
data = self.source.read()
File "C:\Python33\lib\codecs.py", line 301, in decode
(result, consumed) = self._buffer_decode(data, self.errors, final)
File "C:\Python33\lib\encodings\utf_8_sig.py", line 69, in _buffer_decode
return codecs.utf_8_decode(input, errors, final)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xbb in position 760: invalid start byte

# Fixed code
def __init__(self_, *args, **kwds):
    # don't call sys.exit() on IOErrors
    kwds["handle_io_errors"] = False
    kwds["error_handler"] = "sphinx"  # py3: handle error on open.
    FileInput.__init__(self_, *args, **kwds)
# Buggy code
def decode(self_, data):
    if isinstance(data, text_type):
        return data
    return data.decode(self_.encoding, "sphinx")


# Traceback (UnicodeDecodeError)
#!python
# Sphinx version: 1.3a0
# Python version: 3.3.4
# Docutils version: 0.10 release
# Jinja2 version: 2.6
# Loaded extensions:
#   sphinx.ext.todo from C:\Python33\lib\site-packages\sphinx-1.3a0dev_20140728-py3.3.egg\sphinx\ext\todo.py
#   sphinx.ext.ifconfig from C:\Python33\lib\site-packages\sphinx-1.3a0dev_20140728-py3.3.egg\sphinx\ext\ifconfig.py
#   sphinx.ext.extlinks from C:\Python33\lib\site-packages\sphinx-1.3a0dev_20140728-py3.3.egg\sphinx\ext\extlinks.py
#   sphinx.ext.intersphinx from C:\Python33\lib\site-packages\sphinx-1.3a0dev_20140728-py3.3.egg\sphinx\ext\intersphinx.py
#   sphinx.ext.mathjax from C:\Python33\lib\site-packages\sphinx-1.3a0dev_20140728-py3.3.egg\sphinx\ext\mathjax.py
#   sphinx.ext.pngmath from C:\Python33\lib\site-packages\sphinx-1.3a0dev_20140728-py3.3.egg\sphinx\ext\pngmath.py
Traceback (most recent call last):
File "C:\Python33\lib\site-packages\sphinx-1.3a0dev_20140728-py3.3.egg\sphinx\cmdline.py", line 253, in main
app.build(force_all, filenames)
File "C:\Python33\lib\site-packages\sphinx-1.3a0dev_20140728-py3.3.egg\sphinx\application.py", line 223, in build
self.builder.build_update()
File "C:\Python33\lib\site-packages\sphinx-1.3a0dev_20140728-py3.3.egg\sphinx\builders\__init__.py", line 214, in build_update
'out of date' &amp;#37; len(to_build))
File "C:\Python33\lib\site-packages\sphinx-1.3a0dev_20140728-py3.3.egg\sphinx\builders\__init__.py", line 234, in build
purple, length):
File "C:\Python33\lib\site-packages\sphinx-1.3a0dev_20140728-py3.3.egg\sphinx\builders\__init__.py", line 134, in status_iterator
for item in iterable:
File "C:\Python33\lib\site-packages\sphinx-1.3a0dev_20140728-py3.3.egg\sphinx\environment.py", line 474, in update_generator
self.read_doc(docname, app=app)
File "C:\Python33\lib\site-packages\sphinx-1.3a0dev_20140728-py3.3.egg\sphinx\environment.py", line 621, in read_doc
pub.publish()
File "C:\Python33\lib\site-packages\docutils-0.10-py3.3.egg\docutils\core.py", line 217, in publish
self.settings)
File "C:\Python33\lib\site-packages\docutils-0.10-py3.3.egg\docutils\readers\__init__.py", line 71, in read
self.input = self.source.read()
File "C:\Python33\lib\site-packages\sphinx-1.3a0dev_20140728-py3.3.egg\sphinx\environment.py", line 601, in read
data = FileInput.read(self_)
File "C:\Python33\lib\site-packages\docutils-0.10-py3.3.egg\docutils\io.py", line 265, in read
data = self.source.read()
File "C:\Python33\lib\codecs.py", line 301, in decode
(result, consumed) = self._buffer_decode(data, self.errors, final)
File "C:\Python33\lib\encodings\utf_8_sig.py", line 69, in _buffer_decode
return codecs.utf_8_decode(input, errors, final)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xbb in position 760: invalid start byte

# Fixed code
def decode(self_, data):
    if isinstance(data, text_type):  # py3: `data` already decoded.
        return data
    return data.decode(self_.encoding, "sphinx")  # py2: decoding
# Buggy code
def visit_desc_parameterlist(self, node):
    self.body.append("<big>(</big>")
    self.first_param = 1
    self.optional_param_level = 0
    # How many required parameters are left.
    self.required_params_left = sum(
        [isinstance(c, addnodes.desc_parameter) for c in node.children]
    )
    self.param_separator = node.child_text_separator


# Traceback (AttributeError)
#!python

# Sphinx version: 1.2.1
# Python version: 2.7.5
# Docutils version: 0.11 release
# Jinja2 version: 2.7.2
# Loaded extensions:
#   djangodocs from /Users/reza/Workspaces/django/docs/_ext/djangodocs.pyc
#   sphinx.ext.oldcmarkup from /Library/Python/2.7/site-packages/sphinx/ext/oldcmarkup.pyc
#   sphinx.ext.intersphinx from /Library/Python/2.7/site-packages/sphinx/ext/intersphinx.pyc

Traceback (most recent call last):
File "/Library/Python/2.7/site-packages/sphinx/cmdline.py", line 254, in main
app.build(force_all, filenames)
File "/Library/Python/2.7/site-packages/sphinx/application.py", line 212, in build
self.builder.build_update()
File "/Library/Python/2.7/site-packages/sphinx/builders/__init__.py", line 214, in build_update
'out of date' &amp;#37; len(to_build))
File "/Library/Python/2.7/site-packages/sphinx/builders/__init__.py", line 276, in build
self.write(docnames, list(updated_docnames), method)
File "/Library/Python/2.7/site-packages/sphinx/builders/__init__.py", line 320, in write
self._write_serial(sorted(docnames), warnings)
File "/Library/Python/2.7/site-packages/sphinx/builders/__init__.py", line 333, in _write_serial
self.write_doc(docname, doctree)
File "/Library/Python/2.7/site-packages/sphinx/builders/html.py", line 433, in write_doc
self.docwriter.write(doctree, destination)
File "/Library/Python/2.7/site-packages/docutils/writers/__init__.py", line 80, in write
self.translate()
File "/Library/Python/2.7/site-packages/sphinx/writers/html.py", line 51, in translate
self.document.walkabout(visitor)
File "/Library/Python/2.7/site-packages/docutils/nodes.py", line 174, in walkabout
if child.walkabout(visitor):
... (5 more of the same)
File "/Library/Python/2.7/site-packages/docutils/nodes.py", line 174, in walkabout
if child.walkabout(visitor):
File "/Library/Python/2.7/site-packages/docutils/nodes.py", line 166, in walkabout
visitor.dispatch_visit(self)
File "/Library/Python/2.7/site-packages/docutils/nodes.py", line 1882, in dispatch_visit
return method(node)
File "/Library/Python/2.7/site-packages/sphinx/writers/html.py", line 153, in visit_desc_parameter
if self.optional_param_level == 0:
AttributeError: DjangoHTMLTranslator instance has no attribute 'optional_param_level'

# Fixed code
def visit_desc_parameterlist(self, node):
    self.body.append('<span class="sig-paren">(</span>')
    self.first_param = 1
    self.optional_param_level = 0
    # How many required parameters are left.
    self.required_params_left = sum(
        [isinstance(c, addnodes.desc_parameter) for c in node.children]
    )
    self.param_separator = node.child_text_separator
# Buggy code
def depart_desc_parameterlist(self, node):
    self.body.append("<big>)</big>")


# Traceback (AttributeError)
#!python

# Sphinx version: 1.2.1
# Python version: 2.7.5
# Docutils version: 0.11 release
# Jinja2 version: 2.7.2
# Loaded extensions:
#   djangodocs from /Users/reza/Workspaces/django/docs/_ext/djangodocs.pyc
#   sphinx.ext.oldcmarkup from /Library/Python/2.7/site-packages/sphinx/ext/oldcmarkup.pyc
#   sphinx.ext.intersphinx from /Library/Python/2.7/site-packages/sphinx/ext/intersphinx.pyc

Traceback (most recent call last):
File "/Library/Python/2.7/site-packages/sphinx/cmdline.py", line 254, in main
app.build(force_all, filenames)
File "/Library/Python/2.7/site-packages/sphinx/application.py", line 212, in build
self.builder.build_update()
File "/Library/Python/2.7/site-packages/sphinx/builders/__init__.py", line 214, in build_update
'out of date' &amp;#37; len(to_build))
File "/Library/Python/2.7/site-packages/sphinx/builders/__init__.py", line 276, in build
self.write(docnames, list(updated_docnames), method)
File "/Library/Python/2.7/site-packages/sphinx/builders/__init__.py", line 320, in write
self._write_serial(sorted(docnames), warnings)
File "/Library/Python/2.7/site-packages/sphinx/builders/__init__.py", line 333, in _write_serial
self.write_doc(docname, doctree)
File "/Library/Python/2.7/site-packages/sphinx/builders/html.py", line 433, in write_doc
self.docwriter.write(doctree, destination)
File "/Library/Python/2.7/site-packages/docutils/writers/__init__.py", line 80, in write
self.translate()
File "/Library/Python/2.7/site-packages/sphinx/writers/html.py", line 51, in translate
self.document.walkabout(visitor)
File "/Library/Python/2.7/site-packages/docutils/nodes.py", line 174, in walkabout
if child.walkabout(visitor):
... (5 more of the same)
File "/Library/Python/2.7/site-packages/docutils/nodes.py", line 174, in walkabout
if child.walkabout(visitor):
File "/Library/Python/2.7/site-packages/docutils/nodes.py", line 166, in walkabout
visitor.dispatch_visit(self)
File "/Library/Python/2.7/site-packages/docutils/nodes.py", line 1882, in dispatch_visit
return method(node)
File "/Library/Python/2.7/site-packages/sphinx/writers/html.py", line 153, in visit_desc_parameter
if self.optional_param_level == 0:
AttributeError: DjangoHTMLTranslator instance has no attribute 'optional_param_level'

# Fixed code
def depart_desc_parameterlist(self, node):
    self.body.append('<span class="sig-paren">)</span>')
# Buggy code
def depart_desc_signature(self, node):
    if node["ids"] and self.permalink_text and self.builder.add_permalinks:
        self.body.append(
            '<a class="headerlink" href="#%s" ' % node["ids"][0]
            + 'title="%s">%s</a>'
            % (_("Permalink to this definition"), self.permalink_text)
        )
    self.body.append("</dt>\n")


# Traceback (Exception)
raise Exception("Something went wrong!")
Traceback (most recent call last):
...
Exception: Something went wrong!

# Fixed code
def depart_desc_signature(self, node):
    self.add_permalink_ref(node, "definition")
    self.body.append("</dt>\n")
# Buggy code
def add_fignumber(self, node):
    def append_fignumber(figtype, figure_id):
        if figure_id in self.builder.fignumbers.get(figtype, {}):
            prefix = self.builder.config.numfig_prefix.get(figtype, "")
            numbers = self.builder.fignumbers[figtype][figure_id]
            self.body.append(prefix + ".".join(map(str, numbers)) + " ")

    if isinstance(node.parent, nodes.figure):
        append_fignumber("figure", node.parent["ids"][0])
    elif isinstance(node.parent, nodes.table):
        append_fignumber("table", node.parent["ids"][0])
    elif isinstance(node.parent, nodes.container):
        append_fignumber("code-block", node.parent["ids"][0])


# Traceback (Exception)
raise Exception("Something went wrong!")
Traceback (most recent call last):
...
Exception: Something went wrong!

# Fixed code
def add_fignumber(self, node):
    def append_fignumber(figtype, figure_id):
        if figure_id in self.builder.fignumbers.get(figtype, {}):
            self.body.append(self.starttag(node, "span", "", CLASS="caption-number"))
            prefix = self.builder.config.numfig_prefix.get(figtype, "")
            numbers = self.builder.fignumbers[figtype][figure_id]
            self.body.append(prefix + ".".join(map(str, numbers)) + " ")
            self.body.append("</span>")

    if isinstance(node.parent, nodes.figure):
        append_fignumber("figure", node.parent["ids"][0])
    elif isinstance(node.parent, nodes.table):
        append_fignumber("table", node.parent["ids"][0])
    elif isinstance(node.parent, nodes.container):
        append_fignumber("code-block", node.parent["ids"][0])
# Buggy code
def append_fignumber(figtype, figure_id):
    if figure_id in self.builder.fignumbers.get(figtype, {}):
        prefix = self.builder.config.numfig_prefix.get(figtype, "")
        numbers = self.builder.fignumbers[figtype][figure_id]
        self.body.append(prefix + ".".join(map(str, numbers)) + " ")


# Traceback (Exception)
raise Exception("Something went wrong!")
Traceback (most recent call last):
...
Exception: Something went wrong!

# Fixed code
def append_fignumber(figtype, figure_id):
    if figure_id in self.builder.fignumbers.get(figtype, {}):
        self.body.append(self.starttag(node, "span", "", CLASS="caption-number"))
        prefix = self.builder.config.numfig_prefix.get(figtype, "")
        numbers = self.builder.fignumbers[figtype][figure_id]
        self.body.append(prefix + ".".join(map(str, numbers)) + " ")
        self.body.append("</span>")
# Buggy code
def visit_title(self, node):
    BaseTranslator.visit_title(self, node)
    self.add_secnumber(node)
    self.add_fignumber(node)


# Traceback (Exception)
raise Exception("Something went wrong!")
Traceback (most recent call last):
...
Exception: Something went wrong!

# Fixed code
def visit_title(self, node):
    BaseTranslator.visit_title(self, node)
    self.add_secnumber(node)
    self.add_fignumber(node)
    if isinstance(node.parent, nodes.table):
        self.body.append(self.starttag(node, "span", "", CLASS="caption-text"))
# Buggy code
def visit_caption(self, node):
    if isinstance(node.parent, nodes.container) and node.parent.get("literal_block"):
        self.body.append(self.starttag(node, "div", "", CLASS="code-block-caption"))
    else:
        BaseTranslator.visit_caption(self, node)
    self.add_fignumber(node)


# Traceback (Exception)
raise Exception("Something went wrong!")
Traceback (most recent call last):
...
Exception: Something went wrong!

# Fixed code
def visit_caption(self, node):
    if isinstance(node.parent, nodes.container) and node.parent.get("literal_block"):
        self.body.append(self.starttag(node, "div", "", CLASS="code-block-caption"))
    else:
        BaseTranslator.visit_caption(self, node)
    self.add_fignumber(node)
    self.body.append(self.starttag(node, "span", "", CLASS="caption-text"))
# Buggy code
def depart_caption(self, node):
    if isinstance(node.parent, nodes.container) and node.parent.get("literal_block"):
        self.body.append("</div>\n")
    else:
        BaseTranslator.depart_caption(self, node)


# Traceback (Exception)
raise Exception("Something went wrong!")
Traceback (most recent call last):
...
Exception: Something went wrong!

# Fixed code
def depart_caption(self, node):
    self.body.append("</span>")

    # append permalink if available
    if isinstance(node.parent, nodes.container) and node.parent.get("literal_block"):
        self.add_permalink_ref(node.parent, "code")
    elif isinstance(node.parent, nodes.figure):
        self.add_permalink_ref(node.parent, "image")

    if isinstance(node.parent, nodes.container) and node.parent.get("literal_block"):
        self.body.append("</div>\n")
    else:
        BaseTranslator.depart_caption(self, node)
# Buggy code
def depart_title(self, node):
    close_tag = self.context[-1]
    if (
        self.permalink_text
        and self.builder.add_permalinks
        and node.parent.hasattr("ids")
        and node.parent["ids"]
    ):
        aname = node.parent["ids"][0]
        # add permalink anchor
        if close_tag.startswith("</h"):
            self.body.append(
                '<a class="headerlink" href="#%s" ' % aname
                + 'title="%s">%s</a>'
                % (_("Permalink to this headline"), self.permalink_text)
            )
        elif close_tag.startswith("</a></h"):
            self.body.append(
                '</a><a class="headerlink" href="#%s" ' % aname
                + 'title="%s">%s'
                % (_("Permalink to this headline"), self.permalink_text)
            )

    BaseTranslator.depart_title(self, node)


# Traceback (Exception)
raise Exception("Something went wrong!")
Traceback (most recent call last):
...
Exception: Something went wrong!

# Fixed code
def depart_title(self, node):
    close_tag = self.context[-1]
    if (
        self.permalink_text
        and self.builder.add_permalinks
        and node.parent.hasattr("ids")
        and node.parent["ids"]
    ):
        # add permalink anchor
        if close_tag.startswith("</h"):
            self.add_permalink_ref(node.parent, "headline")
        elif close_tag.startswith("</a></h"):
            self.body.append(
                '</a><a class="headerlink" href="#%s" ' % node.parent["ids"][0]
                + 'title="%s">%s'
                % (_("Permalink to this headline"), self.permalink_text)
            )
        elif isinstance(node.parent, nodes.table):
            self.body.append("</span>")
            self.add_permalink_ref(node.parent, "table")

    BaseTranslator.depart_title(self, node)
# Buggy code
def pinned_requirements(path):
    # type: (Path) -> Iterator[Tuple[str, str]]
    for line in path.read_text().splitlines():
        one, two = line.split("==", 1)
        name = one.strip()
        version = two.split("#")[0].strip()
        yield name, version


# Traceback (ValueError)
nox -s vendoring -- --upgrade
nox > Running session vendoring
nox > Re-using existing virtual environment at .nox\vendoring.
nox > python -m pip install vendoring>=0.3.0
nox > vendoring update . appdirs
Load configuration... Done!
Updating requirements... Done!
nox > vendoring update . CacheControl
Load configuration... Done!
Updating requirements...
[(2, ''), (4, ''), (6, ''), (8, ''), (10, ''), (12, ''), (14, ''), (16, ''), (18, ''), (20, ''), (22, ''), (24, ''), (26, ''), (28, ''), (30, ''), (32, ''), (34, ''), (36, ''), (38, ''), (40, ''), (42, ''), (44, ''), (46, '')]
nox > Session vendoring raised exception ValueError('not enough values to unpack (expected 2, got 1)')
Traceback (most recent call last):
File "c:\users\gustav\.local\pipx\venvs\nox\lib\site-packages\nox\sessions.py", line 549, in execute
self.func(session)
File "c:\users\gustav\.local\pipx\venvs\nox\lib\site-packages\nox\_decorators.py", line 53, in __call__
return self.func(*args, **kwargs)
File "D:\Work\Projects\pip\noxfile.py", line 182, in vendoring
for inner_name, inner_version in pinned_requirements(vendor_txt):
File "D:\Work\Projects\pip\noxfile.py", line 167, in pinned_requirements
one, two = line.split("==", 1)
ValueError: not enough values to unpack (expected 2, got 1)
nox > Session vendoring failed.

# Fixed code
def pinned_requirements(path):
    # type: (Path) -> Iterator[Tuple[str, str]]
    for line in path.read_text().splitlines(keepends=False):
        one, sep, two = line.partition("==")
        if not sep:
            continue
        name = one.strip()
        version = two.split("#", 1)[0].strip()
        if name and version:
            yield name, version
# Buggy code
def direct_url_as_pep440_direct_reference(direct_url, name):
    # type: (DirectUrl, str) -> str
    """Convert a DirectUrl to a pip requirement string."""
    direct_url.validate()  # if invalid, this is a pip bug
    requirement = name + " @ "
    fragments = []
    if isinstance(direct_url.info, VcsInfo):
        requirement += "{}+{}@{}".format(
            direct_url.info.vcs, direct_url.url, direct_url.info.commit_id
        )
    elif isinstance(direct_url.info, ArchiveInfo):
        requirement += direct_url.url
        if direct_url.info.hash:
            fragments.append(direct_url.info.hash)
    else:
        assert isinstance(direct_url.info, DirInfo)
        # pip should never reach this point for editables, since
        # pip freeze inspects the editable project location to produce
        # the requirement string
        assert not direct_url.info.editable
        requirement += direct_url.url
    if direct_url.subdirectory:
        fragments.append("subdirectory=" + direct_url.subdirectory)
    if fragments:
        requirement += "#" + "&".join(fragments)
    return requirement


# Traceback (AssertionError)
ERROR: Exception:
Traceback (most recent call last):
File "/Users/tbaker/venvs/dcapenv/lib/python3.8/site-packages/pip/_internal/cli/base_command.py", line 228, in _main
status = self.run(options, args)
File "/Users/tbaker/venvs/dcapenv/lib/python3.8/site-packages/pip/_internal/commands/freeze.py", line 101, in run
for line in freeze(**freeze_kwargs):
File "/Users/tbaker/venvs/dcapenv/lib/python3.8/site-packages/pip/_internal/operations/freeze.py", line 67, in freeze
req = FrozenRequirement.from_dist(dist)
File "/Users/tbaker/venvs/dcapenv/lib/python3.8/site-packages/pip/_internal/operations/freeze.py", line 257, in from_dist
req = direct_url_as_pep440_direct_reference(
File "/Users/tbaker/venvs/dcapenv/lib/python3.8/site-packages/pip/_internal/utils/direct_url_helpers.py", line 49, in direct_url_as_pep440_direct_reference
assert not direct_url.info.editable
AssertionError

# Fixed code
def direct_url_as_pep440_direct_reference(direct_url, name):
    # type: (DirectUrl, str) -> str
    """Convert a DirectUrl to a pip requirement string."""
    direct_url.validate()  # if invalid, this is a pip bug
    requirement = name + " @ "
    fragments = []
    if isinstance(direct_url.info, VcsInfo):
        requirement += "{}+{}@{}".format(
            direct_url.info.vcs, direct_url.url, direct_url.info.commit_id
        )
    elif isinstance(direct_url.info, ArchiveInfo):
        requirement += direct_url.url
        if direct_url.info.hash:
            fragments.append(direct_url.info.hash)
    else:
        assert isinstance(direct_url.info, DirInfo)
        requirement += direct_url.url
    if direct_url.subdirectory:
        fragments.append("subdirectory=" + direct_url.subdirectory)
    if fragments:
        requirement += "#" + "&".join(fragments)
    return requirement
# Buggy code
def get_installation_order(self, req_set):
    # type: (RequirementSet) -> List[InstallRequirement]
    """Get order for installation of requirements in RequirementSet.

    The returned list contains a requirement before another that depends on
    it. This helps ensure that the environment is kept consistent as they
    get installed one-by-one.

    The current implementation creates a topological ordering of the
    dependency graph, while breaking any cycles in the graph at arbitrary
    points. We make no guarantees about where the cycle would be broken,
    other than they would be broken.
    """
    assert self._result is not None, "must call resolve() first"

    graph = self._result.graph
    weights = get_topological_weights(graph)

    sorted_items = sorted(
        req_set.requirements.items(),
        key=functools.partial(_req_set_item_sorter, weights=weights),
        reverse=True,
    )
    return [ireq for _, ireq in sorted_items]


# Traceback (AssertionError)
ERROR: Exception:
Traceback (most recent call last):
File "/home/jahn/usr/src/pipmaster/src/pip/_internal/cli/base_command.py", line 222, in _main
status = self.run(options, args)
File "/home/jahn/usr/src/pipmaster/src/pip/_internal/cli/req_command.py", line 178, in wrapper
return func(self, options, args)
File "/home/jahn/usr/src/pipmaster/src/pip/_internal/commands/install.py", line 378, in run
requirement_set
File "/home/jahn/usr/src/pipmaster/src/pip/_internal/resolution/resolvelib/resolver.py", line 183, in get_installation_order
weights = get_topological_weights(graph)
File "/home/jahn/usr/src/pipmaster/src/pip/_internal/resolution/resolvelib/resolver.py", line 242, in get_topological_weights
assert len(weights) == len(graph)
AssertionError

# Fixed code
def get_installation_order(self, req_set):
    # type: (RequirementSet) -> List[InstallRequirement]
    """Get order for installation of requirements in RequirementSet.

    The returned list contains a requirement before another that depends on
    it. This helps ensure that the environment is kept consistent as they
    get installed one-by-one.

    The current implementation creates a topological ordering of the
    dependency graph, while breaking any cycles in the graph at arbitrary
    points. We make no guarantees about where the cycle would be broken,
    other than they would be broken.
    """
    assert self._result is not None, "must call resolve() first"

    graph = self._result.graph
    weights = get_topological_weights(
        graph,
        expected_node_count=len(self._result.mapping) + 1,
    )

    sorted_items = sorted(
        req_set.requirements.items(),
        key=functools.partial(_req_set_item_sorter, weights=weights),
        reverse=True,
    )
    return [ireq for _, ireq in sorted_items]
# Buggy code
def make_data_scheme_file(record_path):
    # type: (RecordPath) -> File
    normed_path = os.path.normpath(record_path)
    _, scheme_key, dest_subpath = normed_path.split(os.path.sep, 2)
    scheme_path = scheme_paths[scheme_key]
    dest_path = os.path.join(scheme_path, dest_subpath)
    assert_no_path_traversal(scheme_path, dest_path)
    return ZipBackedFile(record_path, dest_path, zip_file)


# Traceback (ValueError)
ERROR: Exception:
Traceback (most recent call last):
File "/tmp/venv/lib/python3.6/site-packages/pip/_internal/cli/base_command.py", line 216, in _main
status = self.run(options, args)
File "/tmp/venv/lib/python3.6/site-packages/pip/_internal/cli/req_command.py", line 182, in wrapper
return func(self, options, args)
File "/tmp/venv/lib/python3.6/site-packages/pip/_internal/commands/install.py", line 421, in run
pycompile=options.compile,
File "/tmp/venv/lib/python3.6/site-packages/pip/_internal/req/__init__.py", line 90, in install_given_reqs
pycompile=pycompile,
File "/tmp/venv/lib/python3.6/site-packages/pip/_internal/req/req_install.py", line 831, in install
requested=self.user_supplied,
File "/tmp/venv/lib/python3.6/site-packages/pip/_internal/operations/install/wheel.py", line 830, in install_wheel
requested=requested,
File "/tmp/venv/lib/python3.6/site-packages/pip/_internal/operations/install/wheel.py", line 658, in _install_wheel
for file in files:
File "/tmp/venv/lib/python3.6/site-packages/pip/_internal/operations/install/wheel.py", line 587, in make_data_scheme_file
_, scheme_key, dest_subpath = normed_path.split(os.path.sep, 2)
ValueError: not enough values to unpack (expected 3, got 2)

# Fixed code
def make_data_scheme_file(record_path):
    # type: (RecordPath) -> File
    normed_path = os.path.normpath(record_path)
    try:
        _, scheme_key, dest_subpath = normed_path.split(os.path.sep, 2)
    except ValueError:
        message = (
            "Unexpected file in {}: {!r}. .data directory contents"
            " should be named like: '<scheme key>/<path>'."
        ).format(wheel_path, record_path)
        raise InstallationError(message)

    try:
        scheme_path = scheme_paths[scheme_key]
    except KeyError:
        valid_scheme_keys = ", ".join(sorted(scheme_paths))
        message = (
            "Unknown scheme key used in {}: {} (for file {!r}). .data"
            " directory contents should be in subdirectories named"
            " with a valid scheme key ({})"
        ).format(wheel_path, scheme_key, record_path, valid_scheme_keys)
        raise InstallationError(message)

    dest_path = os.path.join(scheme_path, dest_subpath)
    assert_no_path_traversal(scheme_path, dest_path)
    return ZipBackedFile(record_path, dest_path, zip_file)