gurudesh/pytracebugs huggingface dataset:
# Buggy code
def import_object(self) -> bool:
    """Import the object given by *self.modname* and *self.objpath* and set
    it as *self.object*.

    Returns True if successful, False if an error occurred.
    """
    with mock(self.env.config.autodoc_mock_imports):
        try:
            ret = import_object(
                self.modname,
                self.objpath,
                self.objtype,
                attrgetter=self.get_attr,
                warningiserror=self.env.config.autodoc_warningiserror,
            )
            self.module, self.parent, self.object_name, self.object = ret
            return True
        except ImportError as exc:
            logger.warning(exc.args[0], type="autodoc", subtype="import_object")
            self.env.note_reread()
            return False


# Traceback (AttributeError)
Traceback (most recent call last):
File "/home/simon/.virtualenvs/tinycss/lib/python3.2/site-packages/sphinx/util/inspect.py", line 64, in safe_getattr
return getattr(obj, name, *defargs)
AttributeError: type object 'Stylesheet' has no attribute 'rules'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/home/simon/.virtualenvs/tinycss/lib/python3.2/site-packages/sphinx/ext/autodoc.py", line 326, in import_object
obj = self.get_attr(obj, part)
File "/home/simon/.virtualenvs/tinycss/lib/python3.2/site-packages/sphinx/ext/autodoc.py", line 232, in get_attr
return safe_getattr(obj, name, *defargs)
File "/home/simon/.virtualenvs/tinycss/lib/python3.2/site-packages/sphinx/util/inspect.py", line 70, in safe_getattr
raise AttributeError(name)
AttributeError: rules

/home/simon/projects/tinycss/docs/parsing.rst:25: WARNING: autodoc can't import/find attribute 'tinycss.css21.Stylesheet.rules', it reported error: "rules", please check your spelling and sys.path

# Fixed code
def import_object(self, raiseerror: bool = False) -> bool:
    """Import the object given by *self.modname* and *self.objpath* and set
    it as *self.object*.

    Returns True if successful, False if an error occurred.
    """
    with mock(self.env.config.autodoc_mock_imports):
        try:
            ret = import_object(
                self.modname,
                self.objpath,
                self.objtype,
                attrgetter=self.get_attr,
                warningiserror=self.env.config.autodoc_warningiserror,
            )
            self.module, self.parent, self.object_name, self.object = ret
            return True
        except ImportError as exc:
            if raiseerror:
                raise
            else:
                logger.warning(exc.args[0], type="autodoc", subtype="import_object")
                self.env.note_reread()
                return False
# Buggy code
def import_object(self) -> Any:
    def is_valid_module_all(__all__: Any) -> bool:
        """Check the given *__all__* is valid for a module."""
        if isinstance(__all__, (list, tuple)) and all(
            isinstance(e, str) for e in __all__
        ):
            return True
        else:
            return False

    ret = super().import_object()

    if not self.options.ignore_module_all:
        __all__ = getattr(self.object, "__all__", None)
        if is_valid_module_all(__all__):
            # valid __all__ found. copy it to self.__all__
            self.__all__ = __all__
        elif __all__:
            # invalid __all__ found.
            logger.warning(
                __(
                    "__all__ should be a list of strings, not %r "
                    "(in module %s) -- ignoring __all__"
                )
                % (__all__, self.fullname),
                type="autodoc",
            )

    return ret


# Traceback (AttributeError)
Traceback (most recent call last):
File "/home/simon/.virtualenvs/tinycss/lib/python3.2/site-packages/sphinx/util/inspect.py", line 64, in safe_getattr
return getattr(obj, name, *defargs)
AttributeError: type object 'Stylesheet' has no attribute 'rules'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/home/simon/.virtualenvs/tinycss/lib/python3.2/site-packages/sphinx/ext/autodoc.py", line 326, in import_object
obj = self.get_attr(obj, part)
File "/home/simon/.virtualenvs/tinycss/lib/python3.2/site-packages/sphinx/ext/autodoc.py", line 232, in get_attr
return safe_getattr(obj, name, *defargs)
File "/home/simon/.virtualenvs/tinycss/lib/python3.2/site-packages/sphinx/util/inspect.py", line 70, in safe_getattr
raise AttributeError(name)
AttributeError: rules

/home/simon/projects/tinycss/docs/parsing.rst:25: WARNING: autodoc can't import/find attribute 'tinycss.css21.Stylesheet.rules', it reported error: "rules", please check your spelling and sys.path

# Fixed code
def import_object(self, raiseerror: bool = False) -> bool:
    def is_valid_module_all(__all__: Any) -> bool:
        """Check the given *__all__* is valid for a module."""
        if isinstance(__all__, (list, tuple)) and all(
            isinstance(e, str) for e in __all__
        ):
            return True
        else:
            return False

    ret = super().import_object(raiseerror)

    if not self.options.ignore_module_all:
        __all__ = getattr(self.object, "__all__", None)
        if is_valid_module_all(__all__):
            # valid __all__ found. copy it to self.__all__
            self.__all__ = __all__
        elif __all__:
            # invalid __all__ found.
            logger.warning(
                __(
                    "__all__ should be a list of strings, not %r "
                    "(in module %s) -- ignoring __all__"
                )
                % (__all__, self.fullname),
                type="autodoc",
            )

    return ret
# Buggy code
def import_object(self) -> Any:
    ret = super().import_object()
    # if the class is documented under another name, document it
    # as data/attribute
    if ret:
        if hasattr(self.object, "__name__"):
            self.doc_as_attr = self.objpath[-1] != self.object.__name__
        else:
            self.doc_as_attr = True
    return ret


# Traceback (AttributeError)
Traceback (most recent call last):
File "/home/simon/.virtualenvs/tinycss/lib/python3.2/site-packages/sphinx/util/inspect.py", line 64, in safe_getattr
return getattr(obj, name, *defargs)
AttributeError: type object 'Stylesheet' has no attribute 'rules'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/home/simon/.virtualenvs/tinycss/lib/python3.2/site-packages/sphinx/ext/autodoc.py", line 326, in import_object
obj = self.get_attr(obj, part)
File "/home/simon/.virtualenvs/tinycss/lib/python3.2/site-packages/sphinx/ext/autodoc.py", line 232, in get_attr
return safe_getattr(obj, name, *defargs)
File "/home/simon/.virtualenvs/tinycss/lib/python3.2/site-packages/sphinx/util/inspect.py", line 70, in safe_getattr
raise AttributeError(name)
AttributeError: rules

/home/simon/projects/tinycss/docs/parsing.rst:25: WARNING: autodoc can't import/find attribute 'tinycss.css21.Stylesheet.rules', it reported error: "rules", please check your spelling and sys.path

# Fixed code
def import_object(self, raiseerror: bool = False) -> bool:
    ret = super().import_object(raiseerror)
    # if the class is documented under another name, document it
    # as data/attribute
    if ret:
        if hasattr(self.object, "__name__"):
            self.doc_as_attr = self.objpath[-1] != self.object.__name__
        else:
            self.doc_as_attr = True
    return ret
# Buggy code
def import_object(self) -> bool:
    """Never import anything."""
    # disguise as a data
    self.objtype = "data"
    self.object = UNINITIALIZED_ATTR
    try:
        # import module to obtain type annotation
        self.parent = importlib.import_module(self.modname)
    except ImportError:
        pass

    return True


# Traceback (AttributeError)
Traceback (most recent call last):
File "/home/simon/.virtualenvs/tinycss/lib/python3.2/site-packages/sphinx/util/inspect.py", line 64, in safe_getattr
return getattr(obj, name, *defargs)
AttributeError: type object 'Stylesheet' has no attribute 'rules'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/home/simon/.virtualenvs/tinycss/lib/python3.2/site-packages/sphinx/ext/autodoc.py", line 326, in import_object
obj = self.get_attr(obj, part)
File "/home/simon/.virtualenvs/tinycss/lib/python3.2/site-packages/sphinx/ext/autodoc.py", line 232, in get_attr
return safe_getattr(obj, name, *defargs)
File "/home/simon/.virtualenvs/tinycss/lib/python3.2/site-packages/sphinx/util/inspect.py", line 70, in safe_getattr
raise AttributeError(name)
AttributeError: rules

/home/simon/projects/tinycss/docs/parsing.rst:25: WARNING: autodoc can't import/find attribute 'tinycss.css21.Stylesheet.rules', it reported error: "rules", please check your spelling and sys.path

# Fixed code
def import_object(self, raiseerror: bool = False) -> bool:
    """Never import anything."""
    # disguise as a data
    self.objtype = "data"
    self.object = UNINITIALIZED_ATTR
    try:
        # import module to obtain type annotation
        self.parent = importlib.import_module(self.modname)
    except ImportError:
        pass

    return True
# Buggy code
def import_object(self) -> Any:
    ret = super().import_object()
    if not ret:
        return ret

    # to distinguish classmethod/staticmethod
    obj = self.parent.__dict__.get(self.object_name)
    if obj is None:
        obj = self.object

    if inspect.isclassmethod(obj) or inspect.isstaticmethod(
        obj, cls=self.parent, name=self.object_name
    ):
        # document class and static members before ordinary ones
        self.member_order = self.member_order - 1

    return ret


# Traceback (AttributeError)
Traceback (most recent call last):
File "/home/simon/.virtualenvs/tinycss/lib/python3.2/site-packages/sphinx/util/inspect.py", line 64, in safe_getattr
return getattr(obj, name, *defargs)
AttributeError: type object 'Stylesheet' has no attribute 'rules'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/home/simon/.virtualenvs/tinycss/lib/python3.2/site-packages/sphinx/ext/autodoc.py", line 326, in import_object
obj = self.get_attr(obj, part)
File "/home/simon/.virtualenvs/tinycss/lib/python3.2/site-packages/sphinx/ext/autodoc.py", line 232, in get_attr
return safe_getattr(obj, name, *defargs)
File "/home/simon/.virtualenvs/tinycss/lib/python3.2/site-packages/sphinx/util/inspect.py", line 70, in safe_getattr
raise AttributeError(name)
AttributeError: rules

/home/simon/projects/tinycss/docs/parsing.rst:25: WARNING: autodoc can't import/find attribute 'tinycss.css21.Stylesheet.rules', it reported error: "rules", please check your spelling and sys.path

# Fixed code
def import_object(self, raiseerror: bool = False) -> bool:
    ret = super().import_object(raiseerror)
    if not ret:
        return ret

    # to distinguish classmethod/staticmethod
    obj = self.parent.__dict__.get(self.object_name)
    if obj is None:
        obj = self.object

    if inspect.isclassmethod(obj) or inspect.isstaticmethod(
        obj, cls=self.parent, name=self.object_name
    ):
        # document class and static members before ordinary ones
        self.member_order = self.member_order - 1

    return ret
# Buggy code
def import_object(self) -> Any:
    ret = super().import_object()
    if inspect.isenumattribute(self.object):
        self.object = self.object.value
    if inspect.isattributedescriptor(self.object):
        self._datadescriptor = True
    else:
        # if it's not a data descriptor
        self._datadescriptor = False
    return ret


# Traceback (AttributeError)
Traceback (most recent call last):
File "/home/simon/.virtualenvs/tinycss/lib/python3.2/site-packages/sphinx/util/inspect.py", line 64, in safe_getattr
return getattr(obj, name, *defargs)
AttributeError: type object 'Stylesheet' has no attribute 'rules'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/home/simon/.virtualenvs/tinycss/lib/python3.2/site-packages/sphinx/ext/autodoc.py", line 326, in import_object
obj = self.get_attr(obj, part)
File "/home/simon/.virtualenvs/tinycss/lib/python3.2/site-packages/sphinx/ext/autodoc.py", line 232, in get_attr
return safe_getattr(obj, name, *defargs)
File "/home/simon/.virtualenvs/tinycss/lib/python3.2/site-packages/sphinx/util/inspect.py", line 70, in safe_getattr
raise AttributeError(name)
AttributeError: rules

/home/simon/projects/tinycss/docs/parsing.rst:25: WARNING: autodoc can't import/find attribute 'tinycss.css21.Stylesheet.rules', it reported error: "rules", please check your spelling and sys.path

# Fixed code
def import_object(self, raiseerror: bool = False) -> bool:
    try:
        ret = super().import_object(raiseerror=True)
        if inspect.isenumattribute(self.object):
            self.object = self.object.value
        if inspect.isattributedescriptor(self.object):
            self._datadescriptor = True
        else:
            # if it's not a data descriptor
            self._datadescriptor = False
    except ImportError as exc:
        if self.isinstanceattribute():
            self.object = INSTANCEATTR
            self._datadescriptor = False
            ret = True
        elif raiseerror:
            raise
        else:
            logger.warning(exc.args[0], type="autodoc", subtype="import_object")
            self.env.note_reread()
            ret = False

    return ret
# Buggy code
def import_object(self) -> bool:
    """Never import anything."""
    # disguise as an attribute
    self.objtype = "attribute"
    self.object = INSTANCEATTR
    self._datadescriptor = False
    return True


# Traceback (AttributeError)
Traceback (most recent call last):
File "/home/simon/.virtualenvs/tinycss/lib/python3.2/site-packages/sphinx/util/inspect.py", line 64, in safe_getattr
return getattr(obj, name, *defargs)
AttributeError: type object 'Stylesheet' has no attribute 'rules'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/home/simon/.virtualenvs/tinycss/lib/python3.2/site-packages/sphinx/ext/autodoc.py", line 326, in import_object
obj = self.get_attr(obj, part)
File "/home/simon/.virtualenvs/tinycss/lib/python3.2/site-packages/sphinx/ext/autodoc.py", line 232, in get_attr
return safe_getattr(obj, name, *defargs)
File "/home/simon/.virtualenvs/tinycss/lib/python3.2/site-packages/sphinx/util/inspect.py", line 70, in safe_getattr
raise AttributeError(name)
AttributeError: rules

/home/simon/projects/tinycss/docs/parsing.rst:25: WARNING: autodoc can't import/find attribute 'tinycss.css21.Stylesheet.rules', it reported error: "rules", please check your spelling and sys.path

# Fixed code
def import_object(self, raiseerror: bool = False) -> bool:
    """Never import anything."""
    # disguise as an attribute
    self.objtype = "attribute"
    self.object = INSTANCEATTR
    self._datadescriptor = False
    return True
# Buggy code
def import_object(self) -> Any:
    """Never import anything."""
    # disguise as an attribute
    self.objtype = "attribute"
    self._datadescriptor = True

    with mock(self.env.config.autodoc_mock_imports):
        try:
            ret = import_object(
                self.modname,
                self.objpath[:-1],
                "class",
                attrgetter=self.get_attr,
                warningiserror=self.env.config.autodoc_warningiserror,
            )
            self.module, _, _, self.parent = ret
            return True
        except ImportError as exc:
            logger.warning(exc.args[0], type="autodoc", subtype="import_object")
            self.env.note_reread()
            return False


# Traceback (AttributeError)
Traceback (most recent call last):
File "/home/simon/.virtualenvs/tinycss/lib/python3.2/site-packages/sphinx/util/inspect.py", line 64, in safe_getattr
return getattr(obj, name, *defargs)
AttributeError: type object 'Stylesheet' has no attribute 'rules'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/home/simon/.virtualenvs/tinycss/lib/python3.2/site-packages/sphinx/ext/autodoc.py", line 326, in import_object
obj = self.get_attr(obj, part)
File "/home/simon/.virtualenvs/tinycss/lib/python3.2/site-packages/sphinx/ext/autodoc.py", line 232, in get_attr
return safe_getattr(obj, name, *defargs)
File "/home/simon/.virtualenvs/tinycss/lib/python3.2/site-packages/sphinx/util/inspect.py", line 70, in safe_getattr
raise AttributeError(name)
AttributeError: rules

/home/simon/projects/tinycss/docs/parsing.rst:25: WARNING: autodoc can't import/find attribute 'tinycss.css21.Stylesheet.rules', it reported error: "rules", please check your spelling and sys.path

# Fixed code
def import_object(self, raiseerror: bool = False) -> bool:
    """Never import anything."""
    # disguise as an attribute
    self.objtype = "attribute"
    self._datadescriptor = True

    with mock(self.env.config.autodoc_mock_imports):
        try:
            ret = import_object(
                self.modname,
                self.objpath[:-1],
                "class",
                attrgetter=self.get_attr,
                warningiserror=self.env.config.autodoc_warningiserror,
            )
            self.module, _, _, self.parent = ret
            return True
        except ImportError as exc:
            if raiseerror:
                raise
            else:
                logger.warning(exc.args[0], type="autodoc", subtype="import_object")
                self.env.note_reread()
                return False
# Buggy code
def add_overload_entry(self, func: ast.FunctionDef) -> None:
    qualname = self.get_qualname_for(func.name)
    if qualname:
        overloads = self.overloads.setdefault(".".join(qualname), [])
        overloads.append(signature_from_ast(func))


# Traceback (ImportError)
LANG=C "/home/circleci/repo/venv/bin/python" -msphinx -WT --keep-going -t scipyorg  -b html -d build/doctrees  "-j2" source build/html-scipyorg
Running Sphinx v3.1.0

Traceback (most recent call last):
File "/home/circleci/repo/venv/lib/python3.7/site-packages/sphinx/config.py", line 319, in eval_config_file
execfile_(filename, namespace)
File "/home/circleci/repo/venv/lib/python3.7/site-packages/sphinx/util/pycompat.py", line 88, in execfile_
exec(code, _globals)
File "/home/circleci/repo/doc/source/conf.py", line 21, in <module>
from sphinx.util import inspect
File "/home/circleci/repo/venv/lib/python3.7/site-packages/sphinx/util/inspect.py", line 28, in <module>
from sphinx.pycode.ast import ast  # for py35-37
File "/home/circleci/repo/venv/lib/python3.7/site-packages/sphinx/pycode/__init__.py", line 23, in <module>
from sphinx.pycode.parser import Parser
File "/home/circleci/repo/venv/lib/python3.7/site-packages/sphinx/pycode/parser.py", line 22, in <module>
from sphinx.util.inspect import signature_from_ast
ImportError: cannot import name 'signature_from_ast' from 'sphinx.util.inspect' (/home/circleci/repo/venv/lib/python3.7/site-packages/sphinx/util/inspect.py)

# Fixed code
def add_overload_entry(self, func: ast.FunctionDef) -> None:
    # avoid circular import problem
    from sphinx.util.inspect import signature_from_ast

    qualname = self.get_qualname_for(func.name)
    if qualname:
        overloads = self.overloads.setdefault(".".join(qualname), [])
        overloads.append(signature_from_ast(func))
# Buggy code
def is_builtin_class_method(obj: Any, attr_name: str) -> bool:
    """If attr_name is implemented at builtin class, return True.

        >>> is_builtin_class_method(int, '__init__')
        True

    Why this function needed? CPython implements int.__init__ by Descriptor
    but PyPy implements it by pure Python code.
    """
    classes = [c for c in inspect.getmro(obj) if attr_name in c.__dict__]
    cls = classes[0] if classes else object

    if not hasattr(builtins, safe_getattr(cls, "__name__", "")):
        return False
    return getattr(builtins, safe_getattr(cls, "__name__", "")) is cls


# Traceback (TypeError)
WARNING: error while formatting arguments for errno.EINTR:
Traceback (most recent call last):
File "/Users/tkomiya/work/sphinx/sphinx/ext/autodoc/__init__.py", line 1049, in format_args
sig = inspect.signature(unwrapped)
File "/Users/tkomiya/work/sphinx/sphinx/util/inspect.py", line 406, in signature
signature = inspect.signature(subject)
File "/Users/tkomiya/.pyenv/versions/3.8.2/lib/python3.8/inspect.py", line 3093, in signature
return Signature.from_callable(obj, follow_wrapped=follow_wrapped)
File "/Users/tkomiya/.pyenv/versions/3.8.2/lib/python3.8/inspect.py", line 2842, in from_callable
return _signature_from_callable(obj, sigcls=cls,
File "/Users/tkomiya/.pyenv/versions/3.8.2/lib/python3.8/inspect.py", line 2216, in _signature_from_callable
raise TypeError('{!r} is not a callable object'.format(obj))
TypeError: 4 is not a callable object

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/Users/tkomiya/work/sphinx/sphinx/ext/autodoc/__init__.py", line 395, in format_signature
args = self.format_args(**kwargs)
File "/Users/tkomiya/work/sphinx/sphinx/ext/autodoc/__init__.py", line 1052, in format_args
if (inspect.is_builtin_class_method(unwrapped, '__new__') and
File "/Users/tkomiya/work/sphinx/sphinx/util/inspect.py", line 392, in is_builtin_class_method
classes = [c for c in inspect.getmro(obj) if attr_name in c.__dict__]
File "/Users/tkomiya/.pyenv/versions/3.8.2/lib/python3.8/inspect.py", line 489, in getmro
return cls.__mro__
AttributeError: 'int' object has no attribute '__mro__'

# Fixed code
def is_builtin_class_method(obj: Any, attr_name: str) -> bool:
    """If attr_name is implemented at builtin class, return True.

        >>> is_builtin_class_method(int, '__init__')
        True

    Why this function needed? CPython implements int.__init__ by Descriptor
    but PyPy implements it by pure Python code.
    """
    try:
        mro = inspect.getmro(obj)
    except AttributeError:
        # no __mro__, assume the object has no methods as we know them
        return False

    try:
        cls = next(c for c in mro if attr_name in safe_getattr(c, "__dict__", {}))
    except StopIteration:
        return False

    try:
        name = safe_getattr(cls, "__name__")
    except AttributeError:
        return False

    return getattr(builtins, name, None) is cls
# Buggy code
def format_args(self, **kwargs: Any) -> str:
    if self.env.config.autodoc_typehints in ("none", "description"):
        kwargs.setdefault("show_annotation", False)

    unwrapped = inspect.unwrap(self.object)
    try:
        self.env.app.emit("autodoc-before-process-signature", unwrapped, False)
        sig = inspect.signature(unwrapped)
        args = stringify_signature(sig, **kwargs)
    except TypeError:
        args = ""

    if self.env.config.strip_signature_backslash:
        # escape backslashes for reST
        args = args.replace("\\", "\\\\")
    return args


# Traceback (TypeError)
WARNING: error while formatting arguments for errno.EINTR:
Traceback (most recent call last):
File "/Users/tkomiya/work/sphinx/sphinx/ext/autodoc/__init__.py", line 1049, in format_args
sig = inspect.signature(unwrapped)
File "/Users/tkomiya/work/sphinx/sphinx/util/inspect.py", line 406, in signature
signature = inspect.signature(subject)
File "/Users/tkomiya/.pyenv/versions/3.8.2/lib/python3.8/inspect.py", line 3093, in signature
return Signature.from_callable(obj, follow_wrapped=follow_wrapped)
File "/Users/tkomiya/.pyenv/versions/3.8.2/lib/python3.8/inspect.py", line 2842, in from_callable
return _signature_from_callable(obj, sigcls=cls,
File "/Users/tkomiya/.pyenv/versions/3.8.2/lib/python3.8/inspect.py", line 2216, in _signature_from_callable
raise TypeError('{!r} is not a callable object'.format(obj))
TypeError: 4 is not a callable object

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/Users/tkomiya/work/sphinx/sphinx/ext/autodoc/__init__.py", line 395, in format_signature
args = self.format_args(**kwargs)
File "/Users/tkomiya/work/sphinx/sphinx/ext/autodoc/__init__.py", line 1052, in format_args
if (inspect.is_builtin_class_method(unwrapped, '__new__') and
File "/Users/tkomiya/work/sphinx/sphinx/util/inspect.py", line 392, in is_builtin_class_method
classes = [c for c in inspect.getmro(obj) if attr_name in c.__dict__]
File "/Users/tkomiya/.pyenv/versions/3.8.2/lib/python3.8/inspect.py", line 489, in getmro
return cls.__mro__
AttributeError: 'int' object has no attribute '__mro__'

# Fixed code
def format_args(self, **kwargs: Any) -> str:
    if self.env.config.autodoc_typehints in ("none", "description"):
        kwargs.setdefault("show_annotation", False)

    unwrapped = inspect.unwrap(self.object)
    try:
        self.env.app.emit("autodoc-before-process-signature", unwrapped, False)
        sig = inspect.signature(unwrapped)
        args = stringify_signature(sig, **kwargs)
    except TypeError as exc:
        logger.warning(
            __("Failed to get a function signature for %s: %s"), self.fullname, exc
        )
        return None
    except ValueError:
        args = ""

    if self.env.config.strip_signature_backslash:
        # escape backslashes for reST
        args = args.replace("\\", "\\\\")
    return args
# Buggy code
def __init__(self) -> None:
    self.registry = SphinxComponentRegistry()
    self.messagelog = []  # type: List[str]
    self.translator = None
    self.verbosity = 0
    self._warncount = 0
    self.warningiserror = False


# Traceback (jinja2.exceptions.UndefinedError)
$ sphinx-autogen example.py
[autosummary] example.py の autosummary を生成中
Traceback (most recent call last):
File "/Users/tkomiya/work/tmp/bin/sphinx-autogen", line 11, in <module>
load_entry_point('Sphinx', 'console_scripts', 'sphinx-autogen')()
File "/Users/tkomiya/work/sphinx/sphinx/ext/autosummary/generate.py", line 517, in main
generate_autosummary_docs(args.source_file, args.output_dir,
File "/Users/tkomiya/work/sphinx/sphinx/ext/autosummary/generate.py", line 304, in generate_autosummary_docs
content = generate_autosummary_content(name, obj, parent, template, entry.template,
File "/Users/tkomiya/work/sphinx/sphinx/ext/autosummary/generate.py", line 245, in generate_autosummary_content
return template.render(template_name, ns)
File "/Users/tkomiya/work/sphinx/sphinx/ext/autosummary/generate.py", line 144, in render
return self.env.get_template(template_name).render(context)
File "/Users/tkomiya/.pyenv/versions/3.8.1/lib/python3.8/site-packages/Jinja2-3.0.0a1-py3.8.egg/jinja2/environment.py", line 1045, in render
self.environment.handle_exception()
File "/Users/tkomiya/.pyenv/versions/3.8.1/lib/python3.8/site-packages/Jinja2-3.0.0a1-py3.8.egg/jinja2/environment.py", line 787, in handle_exception
raise rewrite_traceback_stack(source=source)
File "/Users/tkomiya/work/sphinx/sphinx/ext/autosummary/templates/autosummary/module.rst", line 5, in top-level template code
{% block functions %}
File "/Users/tkomiya/work/sphinx/sphinx/ext/autosummary/templates/autosummary/module.rst", line 7, in block 'functions'
.. rubric:: {{ _('Functions') }}
File "/Users/tkomiya/.pyenv/versions/3.8.1/lib/python3.8/site-packages/Jinja2-3.0.0a1-py3.8.egg/jinja2/sandbox.py", line 410, in call
if not __self.is_safe_callable(__obj):
File "/Users/tkomiya/.pyenv/versions/3.8.1/lib/python3.8/site-packages/Jinja2-3.0.0a1-py3.8.egg/jinja2/sandbox.py", line 310, in is_safe_callable
getattr(obj, "unsafe_callable", False) or getattr(obj, "alters_data", False)
jinja2.exceptions.UndefinedError: '_' is undefined

# Fixed code
def __init__(self, translator: NullTranslations) -> None:
    self.registry = SphinxComponentRegistry()
    self.messagelog = []  # type: List[str]
    self.translator = translator
    self.verbosity = 0
    self._warncount = 0
    self.warningiserror = False
# Buggy code
def __init__(self) -> None:
    self.registry = SphinxComponentRegistry()
    self.messagelog = []  # type: List[str]
    self.verbosity = 0
    self._warncount = 0
    self.warningiserror = False


# Traceback (jinja2.exceptions.TemplateNotFound)
$ sphinx-autogen -t . example.py
[autosummary] example.py の autosummary を生成中
Traceback (most recent call last):
File "/Users/tkomiya/work/tmp/bin/sphinx-autogen", line 11, in <module>
load_entry_point('Sphinx', 'console_scripts', 'sphinx-autogen')()
File "/Users/tkomiya/work/sphinx/sphinx/ext/autosummary/generate.py", line 495, in main
generate_autosummary_docs(args.source_file, args.output_dir,
File "/Users/tkomiya/work/sphinx/sphinx/ext/autosummary/generate.py", line 290, in generate_autosummary_docs
content = generate_autosummary_content(name, obj, parent, template, entry.template,
File "/Users/tkomiya/work/sphinx/sphinx/ext/autosummary/generate.py", line 231, in generate_autosummary_content
return template.render(template_name, ns)
File "/Users/tkomiya/work/sphinx/sphinx/ext/autosummary/generate.py", line 142, in render
return self.env.get_template(template_name).render(context)
File "/Users/tkomiya/.pyenv/versions/3.8.1/lib/python3.8/site-packages/Jinja2-3.0.0a1-py3.8.egg/jinja2/environment.py", line 1045, in render
self.environment.handle_exception()
File "/Users/tkomiya/.pyenv/versions/3.8.1/lib/python3.8/site-packages/Jinja2-3.0.0a1-py3.8.egg/jinja2/environment.py", line 787, in handle_exception
raise rewrite_traceback_stack(source=source)
File "./autosummary/module.rst", line 1, in top-level template code
{% extends "!autosummary/module.rst" %}
File "/Users/tkomiya/.pyenv/versions/3.8.1/lib/python3.8/site-packages/Jinja2-3.0.0a1-py3.8.egg/jinja2/loaders.py", line 189, in get_source
raise TemplateNotFound(template)
jinja2.exceptions.TemplateNotFound: !autosummary/module.rst

# Fixed code
def __init__(self) -> None:
    self.registry = SphinxComponentRegistry()
    self.messagelog = []  # type: List[str]
    self.translator = None
    self.verbosity = 0
    self._warncount = 0
    self.warningiserror = False
# Buggy code
def main(argv: List[str] = sys.argv[1:]) -> None:
    sphinx.locale.setlocale(locale.LC_ALL, "")
    sphinx.locale.init_console(os.path.join(package_dir, "locale"), "sphinx")

    app = DummyApplication()
    logging.setup(app, sys.stdout, sys.stderr)  # type: ignore
    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 (jinja2.exceptions.TemplateNotFound)
$ sphinx-autogen -t . example.py
[autosummary] example.py の autosummary を生成中
Traceback (most recent call last):
File "/Users/tkomiya/work/tmp/bin/sphinx-autogen", line 11, in <module>
load_entry_point('Sphinx', 'console_scripts', 'sphinx-autogen')()
File "/Users/tkomiya/work/sphinx/sphinx/ext/autosummary/generate.py", line 495, in main
generate_autosummary_docs(args.source_file, args.output_dir,
File "/Users/tkomiya/work/sphinx/sphinx/ext/autosummary/generate.py", line 290, in generate_autosummary_docs
content = generate_autosummary_content(name, obj, parent, template, entry.template,
File "/Users/tkomiya/work/sphinx/sphinx/ext/autosummary/generate.py", line 231, in generate_autosummary_content
return template.render(template_name, ns)
File "/Users/tkomiya/work/sphinx/sphinx/ext/autosummary/generate.py", line 142, in render
return self.env.get_template(template_name).render(context)
File "/Users/tkomiya/.pyenv/versions/3.8.1/lib/python3.8/site-packages/Jinja2-3.0.0a1-py3.8.egg/jinja2/environment.py", line 1045, in render
self.environment.handle_exception()
File "/Users/tkomiya/.pyenv/versions/3.8.1/lib/python3.8/site-packages/Jinja2-3.0.0a1-py3.8.egg/jinja2/environment.py", line 787, in handle_exception
raise rewrite_traceback_stack(source=source)
File "./autosummary/module.rst", line 1, in top-level template code
{% extends "!autosummary/module.rst" %}
File "/Users/tkomiya/.pyenv/versions/3.8.1/lib/python3.8/site-packages/Jinja2-3.0.0a1-py3.8.egg/jinja2/loaders.py", line 189, in get_source
raise TemplateNotFound(template)
jinja2.exceptions.TemplateNotFound: !autosummary/module.rst

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

    app = DummyApplication()
    logging.setup(app, sys.stdout, sys.stderr)  # type: ignore
    setup_documenters(app)
    args = get_parser().parse_args(argv)
    builder = DummyBuilder(app, args.templates)
    generate_autosummary_docs(
        args.source_file,
        args.output_dir,
        "." + args.suffix,
        builder=builder,  # type: ignore
        imported_members=args.imported_members,
        app=app,
    )
# Buggy code
def __init__(
    self, template_path: Union[str, List[str]] = None, language: str = None
) -> None:  # NOQA
    super().__init__(template_path)

    # add language to environment
    self.env.extend(language=language)

    # use texescape as escape filter
    self.env.filters["e"] = rst.escape
    self.env.filters["escape"] = rst.escape
    self.env.filters["heading"] = rst.heading


# Traceback (jinja2.exceptions.TemplateNotFound)
$ sphinx-autogen -t . example.py
[autosummary] example.py の autosummary を生成中
Traceback (most recent call last):
File "/Users/tkomiya/work/tmp/bin/sphinx-autogen", line 11, in <module>
load_entry_point('Sphinx', 'console_scripts', 'sphinx-autogen')()
File "/Users/tkomiya/work/sphinx/sphinx/ext/autosummary/generate.py", line 495, in main
generate_autosummary_docs(args.source_file, args.output_dir,
File "/Users/tkomiya/work/sphinx/sphinx/ext/autosummary/generate.py", line 290, in generate_autosummary_docs
content = generate_autosummary_content(name, obj, parent, template, entry.template,
File "/Users/tkomiya/work/sphinx/sphinx/ext/autosummary/generate.py", line 231, in generate_autosummary_content
return template.render(template_name, ns)
File "/Users/tkomiya/work/sphinx/sphinx/ext/autosummary/generate.py", line 142, in render
return self.env.get_template(template_name).render(context)
File "/Users/tkomiya/.pyenv/versions/3.8.1/lib/python3.8/site-packages/Jinja2-3.0.0a1-py3.8.egg/jinja2/environment.py", line 1045, in render
self.environment.handle_exception()
File "/Users/tkomiya/.pyenv/versions/3.8.1/lib/python3.8/site-packages/Jinja2-3.0.0a1-py3.8.egg/jinja2/environment.py", line 787, in handle_exception
raise rewrite_traceback_stack(source=source)
File "./autosummary/module.rst", line 1, in top-level template code
{% extends "!autosummary/module.rst" %}
File "/Users/tkomiya/.pyenv/versions/3.8.1/lib/python3.8/site-packages/Jinja2-3.0.0a1-py3.8.egg/jinja2/loaders.py", line 189, in get_source
raise TemplateNotFound(template)
jinja2.exceptions.TemplateNotFound: !autosummary/module.rst

# Fixed code
def __init__(
    self, confdir: str, templates_paths: List[str], system_templates_paths: List[str]
) -> None:
    self.loaders = []
    self.sysloaders = []

    for templates_path in templates_paths:
        loader = SphinxFileSystemLoader(path.join(confdir, templates_path))
        self.loaders.append(loader)

    for templates_path in system_templates_paths:
        loader = SphinxFileSystemLoader(templates_path)
        self.loaders.append(loader)
        self.sysloaders.append(loader)
# Buggy code
def setup(app: "Sphinx") -> Dict[str, Any]:
    app.connect("config-inited", convert_source_suffix)
    app.connect("config-inited", init_numfig_format)
    app.connect("config-inited", correct_copyright_year)
    app.connect("config-inited", check_confval_types)
    app.connect("config-inited", check_primary_domain)
    app.connect("env-get-outdated", check_master_doc)

    return {
        "version": "builtin",
        "parallel_read_safe": True,
        "parallel_write_safe": True,
    }


# Traceback (ValueError)
# Sphinx version: 2.0.1
# Python version: 3.7.6 (CPython)
# Docutils version: 0.15.2 release
# Jinja2 version: 2.11.1
# Last messages:

# Loaded extensions:
Traceback (most recent call last):
File "/usr/lib/python3.7/site-packages/sphinx/cmd/build.py", line 283, in build_main
args.tags, args.verbosity, args.jobs, args.keep_going)
File "/usr/lib/python3.7/site-packages/sphinx/application.py", line 260, in __init__
self._init_builder()
File "/usr/lib/python3.7/site-packages/sphinx/application.py", line 321, in _init_builder
self.emit('builder-inited')
File "/usr/lib/python3.7/site-packages/sphinx/application.py", line 440, in emit
return self.events.emit(event, self, *args)
File "/usr/lib/python3.7/site-packages/sphinx/events.py", line 76, in emit
results.append(callback(*args))
File "/usr/lib/python3.7/site-packages/sphinx/ext/intersphinx.py", line 207, in load_mappings
for key, (name, (uri, invs)) in app.config.intersphinx_mapping.items():
ValueError: too many values to unpack (expected 2)

# Fixed code
def setup(app: "Sphinx") -> Dict[str, Any]:
    app.connect("config-inited", convert_source_suffix, priority=800)
    app.connect("config-inited", init_numfig_format, priority=800)
    app.connect("config-inited", correct_copyright_year, priority=800)
    app.connect("config-inited", check_confval_types, priority=800)
    app.connect("config-inited", check_primary_domain, priority=800)
    app.connect("env-get-outdated", check_master_doc)

    return {
        "version": "builtin",
        "parallel_read_safe": True,
        "parallel_write_safe": True,
    }
# Buggy code
def setup(app: Sphinx) -> Dict[str, Any]:
    app.add_config_value("intersphinx_mapping", {}, True)
    app.add_config_value("intersphinx_cache_limit", 5, False)
    app.add_config_value("intersphinx_timeout", None, False)
    app.connect("config-inited", normalize_intersphinx_mapping)
    app.connect("builder-inited", load_mappings)
    app.connect("missing-reference", missing_reference)
    return {
        "version": sphinx.__display_version__,
        "env_version": 1,
        "parallel_read_safe": True,
    }


# Traceback (ValueError)
# Sphinx version: 2.0.1
# Python version: 3.7.6 (CPython)
# Docutils version: 0.15.2 release
# Jinja2 version: 2.11.1
# Last messages:

# Loaded extensions:
Traceback (most recent call last):
File "/usr/lib/python3.7/site-packages/sphinx/cmd/build.py", line 283, in build_main
args.tags, args.verbosity, args.jobs, args.keep_going)
File "/usr/lib/python3.7/site-packages/sphinx/application.py", line 260, in __init__
self._init_builder()
File "/usr/lib/python3.7/site-packages/sphinx/application.py", line 321, in _init_builder
self.emit('builder-inited')
File "/usr/lib/python3.7/site-packages/sphinx/application.py", line 440, in emit
return self.events.emit(event, self, *args)
File "/usr/lib/python3.7/site-packages/sphinx/events.py", line 76, in emit
results.append(callback(*args))
File "/usr/lib/python3.7/site-packages/sphinx/ext/intersphinx.py", line 207, in load_mappings
for key, (name, (uri, invs)) in app.config.intersphinx_mapping.items():
ValueError: too many values to unpack (expected 2)

# Fixed code
def setup(app: Sphinx) -> Dict[str, Any]:
    app.add_config_value("intersphinx_mapping", {}, True)
    app.add_config_value("intersphinx_cache_limit", 5, False)
    app.add_config_value("intersphinx_timeout", None, False)
    app.connect("config-inited", normalize_intersphinx_mapping, priority=800)
    app.connect("builder-inited", load_mappings)
    app.connect("missing-reference", missing_reference)
    return {
        "version": sphinx.__display_version__,
        "env_version": 1,
        "parallel_read_safe": True,
    }
# Buggy code
def setup(app: "Sphinx") -> Dict[str, Any]:
    app.connect("config-inited", verify_needs_extensions)

    return {
        "version": "builtin",
        "parallel_read_safe": True,
        "parallel_write_safe": True,
    }


# Traceback (ValueError)
# Sphinx version: 2.0.1
# Python version: 3.7.6 (CPython)
# Docutils version: 0.15.2 release
# Jinja2 version: 2.11.1
# Last messages:

# Loaded extensions:
Traceback (most recent call last):
File "/usr/lib/python3.7/site-packages/sphinx/cmd/build.py", line 283, in build_main
args.tags, args.verbosity, args.jobs, args.keep_going)
File "/usr/lib/python3.7/site-packages/sphinx/application.py", line 260, in __init__
self._init_builder()
File "/usr/lib/python3.7/site-packages/sphinx/application.py", line 321, in _init_builder
self.emit('builder-inited')
File "/usr/lib/python3.7/site-packages/sphinx/application.py", line 440, in emit
return self.events.emit(event, self, *args)
File "/usr/lib/python3.7/site-packages/sphinx/events.py", line 76, in emit
results.append(callback(*args))
File "/usr/lib/python3.7/site-packages/sphinx/ext/intersphinx.py", line 207, in load_mappings
for key, (name, (uri, invs)) in app.config.intersphinx_mapping.items():
ValueError: too many values to unpack (expected 2)

# Fixed code
def setup(app: "Sphinx") -> Dict[str, Any]:
    app.connect("config-inited", verify_needs_extensions, priority=800)

    return {
        "version": "builtin",
        "parallel_read_safe": True,
        "parallel_write_safe": True,
    }
# Buggy code
def setup(app: "Sphinx") -> Dict[str, Any]:
    app.connect("config-inited", merge_source_suffix)

    return {
        "version": "builtin",
        "parallel_read_safe": True,
        "parallel_write_safe": True,
    }


# Traceback (ValueError)
# Sphinx version: 2.0.1
# Python version: 3.7.6 (CPython)
# Docutils version: 0.15.2 release
# Jinja2 version: 2.11.1
# Last messages:

# Loaded extensions:
Traceback (most recent call last):
File "/usr/lib/python3.7/site-packages/sphinx/cmd/build.py", line 283, in build_main
args.tags, args.verbosity, args.jobs, args.keep_going)
File "/usr/lib/python3.7/site-packages/sphinx/application.py", line 260, in __init__
self._init_builder()
File "/usr/lib/python3.7/site-packages/sphinx/application.py", line 321, in _init_builder
self.emit('builder-inited')
File "/usr/lib/python3.7/site-packages/sphinx/application.py", line 440, in emit
return self.events.emit(event, self, *args)
File "/usr/lib/python3.7/site-packages/sphinx/events.py", line 76, in emit
results.append(callback(*args))
File "/usr/lib/python3.7/site-packages/sphinx/ext/intersphinx.py", line 207, in load_mappings
for key, (name, (uri, invs)) in app.config.intersphinx_mapping.items():
ValueError: too many values to unpack (expected 2)

# Fixed code
def setup(app: "Sphinx") -> Dict[str, Any]:
    app.connect("config-inited", merge_source_suffix, priority=800)

    return {
        "version": "builtin",
        "parallel_read_safe": True,
        "parallel_write_safe": True,
    }
# Buggy code
def indexentries(self) -> Dict[str, List[Tuple[str, str, str, str, str]]]:
    warnings.warn(
        "env.indexentries() is deprecated. Please use IndexDomain instead.",
        RemovedInSphinx40Warning,
        stacklevel=2,
    )
    from sphinx.domains.index import IndexDomain

    domain = cast(IndexDomain, self.get_domain("index"))
    return domain.entries


# Traceback (KeyError)
Traceback (most recent call last):
File "/home/sarah/sphinxProject/env/lib64/python3.6/site-packages/rst2pdf/pdfbuilder.py", line 216, in assemble_doctree
self.env.indexentries={docname:self.env.indexentries[docname+'-gen']}
KeyError: 'index-gen'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/home/sarah/sphinxProject/env/lib64/python3.6/site-packages/rst2pdf/pdfbuilder.py", line 141, in write
appendices=opts.get('pdf_appendices', self.config.pdf_appendices) or [])
File "/home/sarah/sphinxProject/env/lib64/python3.6/site-packages/rst2pdf/pdfbuilder.py", line 218, in assemble_doctree
self.env.indexentries={}
AttributeError: can't set attribute
FAILED
build succeeded.

# Fixed code
def indexentries(
    self, entries: Dict[str, List[Tuple[str, str, str, str, str]]]
) -> None:
    warnings.warn(
        "env.indexentries() is deprecated. Please use IndexDomain instead.",
        RemovedInSphinx40Warning,
        stacklevel=2,
    )
    from sphinx.domains.index import IndexDomain

    domain = cast(IndexDomain, self.get_domain("index"))
    domain.data["entries"] = entries
# Buggy code
def __exit__(
    self, exc_type: Type[Exception], exc_value: Exception, traceback: Any
) -> bool:  # NOQA
    self.disable()
    return True


# Traceback (UnboundLocalError)
Traceback (most recent call last):
File "/Users/tkomiya/work/sphinx/sphinx/cmd/build.py", line 284, in build_main
app.build(args.force_all, filenames)
File "/Users/tkomiya/work/sphinx/sphinx/application.py", line 345, in build
self.builder.build_update()
File "/Users/tkomiya/work/sphinx/sphinx/builders/__init__.py", line 298, in build_update
len(to_build))
File "/Users/tkomiya/work/sphinx/sphinx/builders/__init__.py", line 310, in build
updated_docnames = set(self.read())
File "/Users/tkomiya/work/sphinx/sphinx/builders/__init__.py", line 415, in read
self._read_serial(docnames)
File "/Users/tkomiya/work/sphinx/sphinx/builders/__init__.py", line 436, in _read_serial
self.read_doc(docname)
File "/Users/tkomiya/work/sphinx/sphinx/builders/__init__.py", line 489, in read_doc
self.write_doctree(docname, doctree)
UnboundLocalError: local variable 'doctree' referenced before assignment

# Fixed code
def __exit__(
    self, exc_type: Type[Exception], exc_value: Exception, traceback: Any
) -> bool:  # NOQA
    self.disable()
    return False
# Buggy code
def run(self):
    # type: () -> List[nodes.Node]
    latex = "\n".join(self.content)
    if self.arguments and self.arguments[0]:
        latex = self.arguments[0] + "\n\n" + latex
    node = nodes.math_block(
        latex,
        latex,
        docname=self.state.document.settings.env.docname,
        number=self.options.get("name"),
        label=self.options.get("label"),
        nowrap="nowrap" in self.options,
    )
    ret = [node]
    set_source_info(self, node)
    self.add_target(ret)
    return ret


# Traceback (IndexError)
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 341, in build
self.builder.build_update()
File "/Users/tkomiya/work/sphinx/sphinx/builders/__init__.py", line 347, in build_update
len(to_build))
File "/Users/tkomiya/work/sphinx/sphinx/builders/__init__.py", line 412, in build
self.write(docnames, list(updated_docnames), method)
File "/Users/tkomiya/work/sphinx/sphinx/builders/__init__.py", line 593, in write
self._write_serial(sorted(docnames))
File "/Users/tkomiya/work/sphinx/sphinx/builders/__init__.py", line 604, in _write_serial
self.write_doc(docname, doctree)
File "/Users/tkomiya/work/sphinx/sphinx/builders/html.py", line 731, in write_doc
self.docwriter.write(doctree, destination)
File "/Users/tkomiya/work/tmp/lib/python3.6/site-packages/docutils/writers/__init__.py", line 80, in write
self.translate()
File "/Users/tkomiya/work/sphinx/sphinx/writers/html.py", line 58, in translate
self.document.walkabout(visitor)
File "/Users/tkomiya/work/tmp/lib/python3.6/site-packages/docutils/nodes.py", line 174, in walkabout
if child.walkabout(visitor):
File "/Users/tkomiya/work/tmp/lib/python3.6/site-packages/docutils/nodes.py", line 174, in walkabout
if child.walkabout(visitor):
File "/Users/tkomiya/work/tmp/lib/python3.6/site-packages/docutils/nodes.py", line 166, in walkabout
visitor.dispatch_visit(self)
File "/Users/tkomiya/work/tmp/lib/python3.6/site-packages/docutils/nodes.py", line 1894, in dispatch_visit
return method(node)
File "/Users/tkomiya/work/sphinx/sphinx/writers/html.py", line 886, in visit_math_block
visit(self, node)
File "/Users/tkomiya/work/sphinx/sphinx/ext/mathjax.py", line 49, in html_visit_displaymath
number = get_node_equation_number(self, node)
File "/Users/tkomiya/work/sphinx/sphinx/util/math.py", line 28, in get_node_equation_number
id = node['ids'][0]
IndexError: list index out of range

# Fixed code
def run(self):
    # type: () -> List[nodes.Node]
    latex = "\n".join(self.content)
    if self.arguments and self.arguments[0]:
        latex = self.arguments[0] + "\n\n" + latex
    label = self.options.get("label", self.options.get("name"))
    node = nodes.math_block(
        latex,
        latex,
        docname=self.state.document.settings.env.docname,
        number=None,
        label=label,
        nowrap="nowrap" in self.options,
    )
    self.add_name(node)
    set_source_info(self, node)

    ret = [node]
    self.add_target(ret)
    return ret