# Buggy 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))


# Traceback (IndexError)
# Sphinx version: 1.5.1
# Python version: 2.7.9 (CPython)
# Docutils version: 0.13.1 release
# Jinja2 version: 2.9.3
# Last messages:
#   Running Sphinx v1.5.1
#   making output directory...
#   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%] locale/ja/LC_MESSAGES/index.mo
# Loaded extensions:
#   sphinx.domains.cpp (builtin) from /usr/local/lib/python2.7/site-packages/sphinx/domains/cpp.pyc
#   sphinx.builders.applehelp (builtin) from /usr/local/lib/python2.7/site-packages/sphinx/builders/applehelp.pyc
#   sphinx.directives (builtin) from /usr/local/lib/python2.7/site-packages/sphinx/directives/__init__.pyc
#   sphinx.builders.changes (builtin) from /usr/local/lib/python2.7/site-packages/sphinx/builders/changes.pyc
#   sphinx.builders.websupport (builtin) from /usr/local/lib/python2.7/site-packages/sphinx/builders/websupport.pyc
#   sphinx.domains.c (builtin) from /usr/local/lib/python2.7/site-packages/sphinx/domains/c.pyc
#   sphinx.builders.dummy (builtin) from /usr/local/lib/python2.7/site-packages/sphinx/builders/dummy.pyc
#   sphinx.builders.texinfo (builtin) from /usr/local/lib/python2.7/site-packages/sphinx/builders/texinfo.pyc
#   sphinx.builders.epub (builtin) from /usr/local/lib/python2.7/site-packages/sphinx/builders/epub.pyc
#   sphinx.builders.linkcheck (builtin) from /usr/local/lib/python2.7/site-packages/sphinx/builders/linkcheck.pyc
#   sphinx.domains.std (builtin) from /usr/local/lib/python2.7/site-packages/sphinx/domains/std.pyc
#   sphinx.directives.other (builtin) from /usr/local/lib/python2.7/site-packages/sphinx/directives/other.pyc
#   sphinx.builders.epub3 (builtin) from /usr/local/lib/python2.7/site-packages/sphinx/builders/epub3.pyc
#   sphinx.domains.javascript (builtin) from /usr/local/lib/python2.7/site-packages/sphinx/domains/javascript.pyc
#   sphinx.directives.code (builtin) from /usr/local/lib/python2.7/site-packages/sphinx/directives/code.pyc
#   alabaster (0.7.9) from /usr/local/lib/python2.7/site-packages/alabaster/__init__.pyc
#   sphinx.builders.text (builtin) from /usr/local/lib/python2.7/site-packages/sphinx/builders/text.pyc
#   sphinx.builders.qthelp (builtin) from /usr/local/lib/python2.7/site-packages/sphinx/builders/qthelp.pyc
#   sphinx.roles (builtin) from /usr/local/lib/python2.7/site-packages/sphinx/roles.pyc
#   sphinx.builders.htmlhelp (builtin) from /usr/local/lib/python2.7/site-packages/sphinx/builders/htmlhelp.pyc
#   sphinx.directives.patches (builtin) from /usr/local/lib/python2.7/site-packages/sphinx/directives/patches.pyc
#   sphinx.builders.latex (builtin) from /usr/local/lib/python2.7/site-packages/sphinx/builders/latex.pyc
#   sphinx.builders.html (builtin) from /usr/local/lib/python2.7/site-packages/sphinx/builders/html.pyc
#   sphinx.builders.devhelp (builtin) from /usr/local/lib/python2.7/site-packages/sphinx/builders/devhelp.pyc
#   sphinx.builders.gettext (builtin) from /usr/local/lib/python2.7/site-packages/sphinx/builders/gettext.pyc
#   sphinx.builders.xml (builtin) from /usr/local/lib/python2.7/site-packages/sphinx/builders/xml.pyc
#   sphinx.builders.manpage (builtin) from /usr/local/lib/python2.7/site-packages/sphinx/builders/manpage.pyc
#   sphinx.domains.rst (builtin) from /usr/local/lib/python2.7/site-packages/sphinx/domains/rst.pyc
#   sphinx.domains.python (builtin) from /usr/local/lib/python2.7/site-packages/sphinx/domains/python.pyc
Traceback (most recent call last):
File "/usr/local/lib/python2.7/site-packages/sphinx/cmdline.py", line 296, in main
app.build(opts.force_all, filenames)
File "/usr/local/lib/python2.7/site-packages/sphinx/application.py", line 332, in build
self.builder.compile_update_catalogs()
File "/usr/local/lib/python2.7/site-packages/sphinx/builders/__init__.py", line 205, in compile_update_catalogs
self.compile_catalogs(catalogs, message)
File "/usr/local/lib/python2.7/site-packages/sphinx/builders/__init__.py", line 170, in compile_catalogs
catalog.write_mo(self.config.language)
File "/usr/local/lib/python2.7/site-packages/sphinx/util/i18n.py", line 59, in write_mo
write_mo(mo, read_po(po, locale))
File "/usr/local/lib/python2.7/site-packages/babel/messages/pofile.py", line 244, in read_po
_process_message_line(lineno, line)
File "/usr/local/lib/python2.7/site-packages/babel/messages/pofile.py", line 186, in _process_message_line
_add_message()
File "/usr/local/lib/python2.7/site-packages/babel/messages/pofile.py", line 153, in _add_message
string = denormalize(translations[0][1])
IndexError: list index out of range

# Fixed code
def write_mo(self, locale, warnfunc):
    with io.open(self.po_path, "rt", encoding=self.charset) as file_po:
        try:
            po = read_po(file_po, locale)
        except Exception:
            warnfunc("reading error: %s" % self.po_path)
            return

    with io.open(self.mo_path, "wb") as file_mo:
        try:
            write_mo(file_mo, po)
        except Exception:
            warnfunc("writing error: %s" % self.mo_path)