# Buggy code
def warn(self, docname, msg, lineno=None, **kwargs):
    # type: (unicode, unicode, int, Any) -> None
    """Emit a warning.

    This differs from using ``app.warn()`` in that the warning may not
    be emitted instantly, but collected for emitting all warnings after
    the update of the environment.
    """
    # strange argument order is due to backwards compatibility
    self._warnfunc(msg, (docname, lineno), **kwargs)


# Traceback (TypeError)
ribos:~/.../openstack/nova-test/nova(master)> cat /tmp/sphinx-err-Oa6KmO.log
# Sphinx version: 1.6.2
# Python version: 2.7.13 (CPython)
# Docutils version: 0.13.1 release
# Jinja2 version: 2.9.6
# Last messages:
#   Running Sphinx v1.6.2
#   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 1 source files that are out of date
#   updating environment:
#   1 added, 0 changed, 0 removed
#   reading sources... [100%] index
# Loaded extensions:
#   os_api_ref (1.3.0) from /home/sdague/code/openstack/nova-test/nova/.tox/api-ref/local/lib/python2.7/site-packages/os_api_ref/__init__.pyc
#   alabaster (0.7.10) from /home/sdague/code/openstack/nova-test/nova/.tox/api-ref/local/lib/python2.7/site-packages/alabaster/__init__.pyc
Traceback (most recent call last):
File "/home/sdague/code/openstack/nova-test/nova/.tox/api-ref/local/lib/python2.7/site-packages/sphinx/cmdline.py", line 306, in main
app.build(opts.force_all, filenames)
File "/home/sdague/code/openstack/nova-test/nova/.tox/api-ref/local/lib/python2.7/site-packages/sphinx/application.py", line 339, in build
self.builder.build_update()
File "/home/sdague/code/openstack/nova-test/nova/.tox/api-ref/local/lib/python2.7/site-packages/sphinx/builders/__init__.py", line 328, in build_update
'out of date' % len(to_build))
File "/home/sdague/code/openstack/nova-test/nova/.tox/api-ref/local/lib/python2.7/site-packages/sphinx/builders/__init__.py", line 341, in build
updated_docnames = set(self.env.update(self.config, self.srcdir, self.doctreedir))
File "/home/sdague/code/openstack/nova-test/nova/.tox/api-ref/local/lib/python2.7/site-packages/sphinx/environment/__init__.py", line 584, in update
self._read_serial(docnames, self.app)
File "/home/sdague/code/openstack/nova-test/nova/.tox/api-ref/local/lib/python2.7/site-packages/sphinx/environment/__init__.py", line 603, in _read_serial
self.read_doc(docname, app)
File "/home/sdague/code/openstack/nova-test/nova/.tox/api-ref/local/lib/python2.7/site-packages/sphinx/environment/__init__.py", line 724, in read_doc
pub.publish()
File "/home/sdague/code/openstack/nova-test/nova/.tox/api-ref/local/lib/python2.7/site-packages/docutils/core.py", line 217, in publish
self.settings)
File "/home/sdague/code/openstack/nova-test/nova/.tox/api-ref/local/lib/python2.7/site-packages/sphinx/io.py", line 74, in read
self.parse()
File "/home/sdague/code/openstack/nova-test/nova/.tox/api-ref/local/lib/python2.7/site-packages/docutils/readers/__init__.py", line 78, in parse
self.parser.parse(self.input, document)
File "/home/sdague/code/openstack/nova-test/nova/.tox/api-ref/local/lib/python2.7/site-packages/docutils/parsers/rst/__init__.py", line 185, in parse
self.statemachine.run(inputlines, document, inliner=self.inliner)
File "/home/sdague/code/openstack/nova-test/nova/.tox/api-ref/local/lib/python2.7/site-packages/docutils/parsers/rst/states.py", line 170, in run
input_source=document['source'])
File "/home/sdague/code/openstack/nova-test/nova/.tox/api-ref/local/lib/python2.7/site-packages/docutils/statemachine.py", line 239, in run
context, state, transitions)
File "/home/sdague/code/openstack/nova-test/nova/.tox/api-ref/local/lib/python2.7/site-packages/docutils/statemachine.py", line 460, in check_line
return method(match, context, next_state)
File "/home/sdague/code/openstack/nova-test/nova/.tox/api-ref/local/lib/python2.7/site-packages/docutils/parsers/rst/states.py", line 2980, in text
self.section(title.lstrip(), source, style, lineno + 1, messages)
File "/home/sdague/code/openstack/nova-test/nova/.tox/api-ref/local/lib/python2.7/site-packages/docutils/parsers/rst/states.py", line 326, in section
self.new_subsection(title, lineno, messages)
File "/home/sdague/code/openstack/nova-test/nova/.tox/api-ref/local/lib/python2.7/site-packages/docutils/parsers/rst/states.py", line 394, in new_subsection
node=section_node, match_titles=True)
File "/home/sdague/code/openstack/nova-test/nova/.tox/api-ref/local/lib/python2.7/site-packages/docutils/parsers/rst/states.py", line 281, in nested_parse
node=node, match_titles=match_titles)
File "/home/sdague/code/openstack/nova-test/nova/.tox/api-ref/local/lib/python2.7/site-packages/docutils/parsers/rst/states.py", line 195, in run
results = StateMachineWS.run(self, input_lines, input_offset)
File "/home/sdague/code/openstack/nova-test/nova/.tox/api-ref/local/lib/python2.7/site-packages/docutils/statemachine.py", line 239, in run
context, state, transitions)
File "/home/sdague/code/openstack/nova-test/nova/.tox/api-ref/local/lib/python2.7/site-packages/docutils/statemachine.py", line 460, in check_line
return method(match, context, next_state)
File "/home/sdague/code/openstack/nova-test/nova/.tox/api-ref/local/lib/python2.7/site-packages/docutils/parsers/rst/states.py", line 2745, in underline
self.section(title, source, style, lineno - 1, messages)
File "/home/sdague/code/openstack/nova-test/nova/.tox/api-ref/local/lib/python2.7/site-packages/docutils/parsers/rst/states.py", line 326, in section
self.new_subsection(title, lineno, messages)
File "/home/sdague/code/openstack/nova-test/nova/.tox/api-ref/local/lib/python2.7/site-packages/docutils/parsers/rst/states.py", line 394, in new_subsection
node=section_node, match_titles=True)
File "/home/sdague/code/openstack/nova-test/nova/.tox/api-ref/local/lib/python2.7/site-packages/docutils/parsers/rst/states.py", line 281, in nested_parse
node=node, match_titles=match_titles)
File "/home/sdague/code/openstack/nova-test/nova/.tox/api-ref/local/lib/python2.7/site-packages/docutils/parsers/rst/states.py", line 195, in run
results = StateMachineWS.run(self, input_lines, input_offset)
File "/home/sdague/code/openstack/nova-test/nova/.tox/api-ref/local/lib/python2.7/site-packages/docutils/statemachine.py", line 239, in run
context, state, transitions)
File "/home/sdague/code/openstack/nova-test/nova/.tox/api-ref/local/lib/python2.7/site-packages/docutils/statemachine.py", line 460, in check_line
return method(match, context, next_state)
File "/home/sdague/code/openstack/nova-test/nova/.tox/api-ref/local/lib/python2.7/site-packages/docutils/parsers/rst/states.py", line 2745, in underline
self.section(title, source, style, lineno - 1, messages)
File "/home/sdague/code/openstack/nova-test/nova/.tox/api-ref/local/lib/python2.7/site-packages/docutils/parsers/rst/states.py", line 326, in section
self.new_subsection(title, lineno, messages)
File "/home/sdague/code/openstack/nova-test/nova/.tox/api-ref/local/lib/python2.7/site-packages/docutils/parsers/rst/states.py", line 394, in new_subsection
node=section_node, match_titles=True)
File "/home/sdague/code/openstack/nova-test/nova/.tox/api-ref/local/lib/python2.7/site-packages/docutils/parsers/rst/states.py", line 281, in nested_parse
node=node, match_titles=match_titles)
File "/home/sdague/code/openstack/nova-test/nova/.tox/api-ref/local/lib/python2.7/site-packages/docutils/parsers/rst/states.py", line 195, in run
results = StateMachineWS.run(self, input_lines, input_offset)
File "/home/sdague/code/openstack/nova-test/nova/.tox/api-ref/local/lib/python2.7/site-packages/docutils/statemachine.py", line 239, in run
context, state, transitions)
File "/home/sdague/code/openstack/nova-test/nova/.tox/api-ref/local/lib/python2.7/site-packages/docutils/statemachine.py", line 460, in check_line
return method(match, context, next_state)
File "/home/sdague/code/openstack/nova-test/nova/.tox/api-ref/local/lib/python2.7/site-packages/docutils/parsers/rst/states.py", line 2318, in explicit_markup
nodelist, blank_finish = self.explicit_construct(match)
File "/home/sdague/code/openstack/nova-test/nova/.tox/api-ref/local/lib/python2.7/site-packages/docutils/parsers/rst/states.py", line 2330, in explicit_construct
return method(self, expmatch)
File "/home/sdague/code/openstack/nova-test/nova/.tox/api-ref/local/lib/python2.7/site-packages/docutils/parsers/rst/states.py", line 2073, in directive
directive_class, match, type_name, option_presets)
File "/home/sdague/code/openstack/nova-test/nova/.tox/api-ref/local/lib/python2.7/site-packages/docutils/parsers/rst/states.py", line 2122, in run_directive
result = directive_instance.run()
File "/home/sdague/code/openstack/nova-test/nova/.tox/api-ref/local/lib/python2.7/site-packages/os_api_ref/__init__.py", line 379, in run
self.yaml_from_file(self.yaml_file)
File "/home/sdague/code/openstack/nova-test/nova/.tox/api-ref/local/lib/python2.7/site-packages/os_api_ref/__init__.py", line 350, in yaml_from_file
% param.rstrip('}').lstrip('{')))
File "/home/sdague/code/openstack/nova-test/nova/.tox/api-ref/local/lib/python2.7/site-packages/sphinx/environment/__init__.py", line 304, in warn
self._warnfunc(msg, (docname, lineno), **kwargs)
TypeError: 'NoneType' object is not callable

# Fixed code
def warn(self, docname, msg, lineno=None, **kwargs):
    # type: (unicode, unicode, int, Any) -> None
    """Emit a warning.

    This differs from using ``app.warn()`` in that the warning may not
    be emitted instantly, but collected for emitting all warnings after
    the update of the environment.
    """
    self.app.warn(msg, location=(docname, lineno), **kwargs)