# Buggy code
def write_buildinfo(self):
    # type: () -> None
    # write build info file
    with open(path.join(self.outdir, ".buildinfo"), "w") as fp:
        fp.write(
            "# Sphinx build info version 1\n"
            "# This file hashes the configuration used when building"
            " these files. When it is not found, a full rebuild will"
            " be done.\nconfig: %s\ntags: %s\n" % (self.config_hash, self.tags_hash)
        )


# Traceback (IOError)
# Sphinx version: 1.5.5
# Python version: 2.7.13 (CPython)
# Docutils version: 0.13.1 release
# Jinja2 version: 2.9.6
# Last messages:
#   copying images... [ 84%] images/nukestudio/showreel/clips_after_deleting.png
#   copying images... [ 88%] images/nukestudio/showreel/new_conform_folder.png
#   copying images... [ 92%] images/nukestudio/showreel/sg_sequences.png
#   copying images... [ 96%] images/nukestudio/showreel/sg_shots.png
#   copying images... [100%] images/nukestudio/nukestudio_export_sequence_00.gif
#
#   copying static files...
#   done
#   copying extra files...
#   done
# Loaded extensions:
#   sphinx.ext.mathjax (1.5.5) from c:\python27\lib\site-packages\sphinx\ext\mathjax.pyc
#   sphinx.ext.coverage (1.5.5) from c:\python27\lib\site-packages\sphinx\ext\coverage.pyc
#   sphinx.ext.graphviz (1.5.5) from c:\python27\lib\site-packages\sphinx\ext\graphviz.pyc
#   sphinx.ext.viewcode (1.5.5) from c:\python27\lib\site-packages\sphinx\ext\viewcode.pyc
#   sphinx.ext.todo (1.5.5) from c:\python27\lib\site-packages\sphinx\ext\todo.pyc
#   sphinx.ext.autodoc (1.5.5) from c:\python27\lib\site-packages\sphinx\ext\autodoc.pyc
#   sphinx.ext.intersphinx (1.5.5) from c:\python27\lib\site-packages\sphinx\ext\intersphinx.pyc
#   sphinx.ext.doctest (1.5.5) from c:\python27\lib\site-packages\sphinx\ext\doctest.pyc
#   alabaster (0.7.10) from c:\python27\lib\site-packages\alabaster\__init__.pyc
Traceback (most recent call last):
File "c:\python27\lib\site-packages\sphinx\cmdline.py", line 296, in main
app.build(opts.force_all, filenames)
File "c:\python27\lib\site-packages\sphinx\application.py", line 333, in build
self.builder.build_update()
File "c:\python27\lib\site-packages\sphinx\builders\__init__.py", line 251, in build_update
'out of date' % len(to_build))
File "c:\python27\lib\site-packages\sphinx\builders\__init__.py", line 325, in build
self.finish()
File "c:\python27\lib\site-packages\sphinx\builders\html.py", line 477, in finish
self.finish_tasks.add_task(self.write_buildinfo)
File "c:\python27\lib\site-packages\sphinx\util\parallel.py", line 40, in add_task
res = task_func()
File "c:\python27\lib\site-packages\sphinx\builders\html.py", line 667, in write_buildinfo
with open(path.join(self.outdir, '.buildinfo'), 'w') as fp:
IOError: [Errno 13] Permission denied: u'Z:\\dev\\release\\docs\\_build\\html\\.buildinfo'

# Fixed code
def write_buildinfo(self):
    # type: () -> None
    # write build info file
    try:
        with open(path.join(self.outdir, ".buildinfo"), "w") as fp:
            fp.write(
                "# Sphinx build info version 1\n"
                "# This file hashes the configuration used when building"
                " these files. When it is not found, a full rebuild will"
                " be done.\nconfig: %s\ntags: %s\n" % (self.config_hash, self.tags_hash)
            )
    except IOError as exc:
        logger.warning("Failed to write build info file: %r", exc)