{"instance_id": "pydata__xarray-7393", "model_name_or_path": "cain-anthropic-e124", "model_patch": "diff --git a/xarray/core/indexing.py b/xarray/core/indexing.py\nindex ba937183..75fff129 100644\n--- a/xarray/core/indexing.py\n+++ b/xarray/core/indexing.py\n@@ -1532,7 +1532,11 @@ class PandasMultiIndexingAdapter(PandasIndexingAdapter):\n \n     def __array__(self, dtype: DTypeLike = None) -> np.ndarray:\n         if self.level is not None:\n-            return self.array.get_level_values(self.level).values\n+            if dtype is None:\n+                dtype = self.dtype\n+            return np.asarray(\n+                self.array.get_level_values(self.level).values, dtype=dtype\n+            )\n         else:\n             return super().__array__(dtype)\n \n", "model": "claude-haiku-5-5", "steps": 9, "finished": true, "patch_lines": 17, "candidates": [{"compile_ok": 0, "loc_hits": 0, "files": 1, "diff_lines": 17, "steps": 9}], "ms": 16299}
{"instance_id": "sphinx-doc__sphinx-10323", "model_name_or_path": "cain-anthropic-e124", "model_patch": "diff --git a/sphinx/directives/code.py b/sphinx/directives/code.py\nindex dc44ed314..9437fe9a5 100644\n--- a/sphinx/directives/code.py\n+++ b/sphinx/directives/code.py\n@@ -224,9 +224,9 @@ class LiteralIncludeReader:\n                        self.start_filter,\n                        self.end_filter,\n                        self.lines_filter,\n+                       self.dedent_filter,\n                        self.prepend_filter,\n-                       self.append_filter,\n-                       self.dedent_filter]\n+                       self.append_filter]\n             lines = self.read_file(self.filename, location=location)\n             for func in filters:\n                 lines = func(lines, location=location)\n", "model": "claude-sonnet-5-5", "steps": 6, "finished": true, "patch_lines": 16, "candidates": [{"compile_ok": 0, "loc_hits": 0, "files": 1, "diff_lines": 16, "steps": 6}], "ms": 12714}
{"instance_id": "sphinx-doc__sphinx-10435", "model_name_or_path": "cain-anthropic-e124", "model_patch": "diff --git a/sphinx/writers/latex.py b/sphinx/writers/latex.py\nindex e0c7d56f8..9659bd5a7 100644\n--- a/sphinx/writers/latex.py\n+++ b/sphinx/writers/latex.py\n@@ -1710,11 +1710,10 @@ class LaTeXTranslator(SphinxTranslator):\n         # TODO: Use nowrap option once LaTeX formatter supports it\n         # https://github.com/pygments/pygments/pull/1343\n         hlcode = hlcode.replace(r'\\begin{Verbatim}[commandchars=\\\\\\{\\}]',\n-                                r'\\sphinxcode{\\sphinxupquote{')\n+                                r'\\sphinxcode{\\sphinxupquote{%')\n         # get consistent trailer\n         hlcode = hlcode.rstrip()[:-14]  # strip \\end{Verbatim}\n-        self.body.append(hlcode)\n-        self.body.append('}}')\n+        self.body.append(hlcode.rstrip() + '%' + CR + '}}')\n         raise nodes.SkipNode\n \n     def depart_literal(self, node: Element) -> None:\ndiff --git a/tests/test_build_latex.py b/tests/test_build_latex.py\nindex dd0db8aef..709dce05d 100644\n--- a/tests/test_build_latex.py\n+++ b/tests/test_build_latex.py\n@@ -1623,7 +1623,7 @@ def test_latex_code_role(app):\n         r'\\PYG{p}{)}'\n         r'\\PYG{p}{:} '\n         r'\\PYG{k}{pass}')\n-    assert (r'Inline \\sphinxcode{\\sphinxupquote{' + '\\n' +\n-            common_content + '\\n}} code block') in content\n+    assert (r'Inline \\sphinxcode{\\sphinxupquote{%' + '\\n' +\n+            common_content + '%\\n}} code block') in content\n     assert (r'\\begin{sphinxVerbatim}[commandchars=\\\\\\{\\}]' +\n             '\\n' + common_content + '\\n' + r'\\end{sphinxVerbatim}') in content\n", "model": "claude-sonnet-5-5", "steps": 5, "finished": true, "patch_lines": 32, "candidates": [{"compile_ok": 0, "loc_hits": 1, "files": 2, "diff_lines": 32, "steps": 5}], "ms": 10606}
{"instance_id": "sphinx-doc__sphinx-10466", "model_name_or_path": "cain-anthropic-e124", "model_patch": "diff --git a/sphinx/builders/gettext.py b/sphinx/builders/gettext.py\nindex e8bc547b7..1b89abdfe 100644\n--- a/sphinx/builders/gettext.py\n+++ b/sphinx/builders/gettext.py\n@@ -32,9 +32,13 @@ class Message:\n     \"\"\"An entry of translatable message.\"\"\"\n     def __init__(self, text: str, locations: List[Tuple[str, int]], uuids: List[str]):\n         self.text = text\n-        self.locations = locations\n+        self.locations = self.unique_locations(locations)\n         self.uuids = uuids\n \n+    @staticmethod\n+    def unique_locations(locations: List[Tuple[str, int]]) -> List[Tuple[str, int]]:\n+        return list(dict.fromkeys(locations))\n+\n \n class Catalog:\n     \"\"\"Catalog of translatable messages.\"\"\"\n", "model": "claude-sonnet-5-5", "steps": 4, "finished": true, "patch_lines": 19, "candidates": [{"compile_ok": 0, "loc_hits": 0, "files": 1, "diff_lines": 19, "steps": 4}], "ms": 11305}
{"instance_id": "sphinx-doc__sphinx-10614", "model_name_or_path": "cain-anthropic-e124", "model_patch": "diff --git a/sphinx/ext/inheritance_diagram.py b/sphinx/ext/inheritance_diagram.py\nindex 6e3985512..2bb26b2c2 100644\n--- a/sphinx/ext/inheritance_diagram.py\n+++ b/sphinx/ext/inheritance_diagram.py\n@@ -33,6 +33,7 @@ from __future__ import annotations\n import builtins\n import hashlib\n import inspect\n+import posixpath\n import re\n from collections.abc import Iterable\n from importlib import import_module\n@@ -413,7 +414,14 @@ def html_visit_inheritance_diagram(self: HTML5Translator, node: inheritance_diag\n     for child in pending_xrefs:\n         if child.get('refuri') is not None:\n             if graphviz_output_format == 'SVG':\n-                urls[child['reftitle']] = \"../\" + child.get('refuri')\n+                refuri = child.get('refuri')\n+                if re.match(r'^([a-zA-Z][a-zA-Z0-9+.-]*:|/)', refuri):\n+                    urls[child['reftitle']] = refuri\n+                else:\n+                    # the SVG lives in the images dir at the output root, while\n+                    # refuri is relative to the directory of the current document\n+                    docdir = posixpath.dirname(self.builder.current_docname)\n+                    urls[child['reftitle']] = posixpath.join('..', docdir, refuri)\n             else:\n                 urls[child['reftitle']] = child.get('refuri')\n         elif child.get('refid') is not None:\n", "model": "claude-sonnet-5-5", "steps": 7, "finished": true, "patch_lines": 28, "candidates": [{"compile_ok": 0, "loc_hits": 1, "files": 1, "diff_lines": 28, "steps": 7}], "ms": 18741}
{"instance_id": "sphinx-doc__sphinx-10673", "model_name_or_path": "cain-anthropic-e124", "model_patch": "diff --git a/sphinx/directives/other.py b/sphinx/directives/other.py\nindex 35e16e623..b573d4bfb 100644\n--- a/sphinx/directives/other.py\n+++ b/sphinx/directives/other.py\n@@ -83,6 +83,8 @@ class TocTree(SphinxDirective):\n         all_docnames = self.env.found_docs.copy()\n         all_docnames.remove(self.env.docname)  # remove current document\n \n+        generated_docnames = frozenset(self.env.get_domain('std')._virtual_doc_names)\n+\n         ret: List[Node] = []\n         excluded = Matcher(self.config.exclude_patterns)\n         for entry in self.content:\n@@ -118,6 +120,8 @@ class TocTree(SphinxDirective):\n                 docname = docname_join(self.env.docname, docname)\n                 if url_re.match(ref) or ref == 'self':\n                     toctree['entries'].append((title, ref))\n+                elif ref in generated_docnames and docname not in self.env.found_docs:\n+                    toctree['entries'].append((title, ref))\n                 elif docname not in self.env.found_docs:\n                     if excluded(self.env.doc2path(docname, False)):\n                         message = __('toctree contains reference to excluded document %r')\ndiff --git a/sphinx/domains/std.py b/sphinx/domains/std.py\nindex b0d21b492..4ec6fef2f 100644\n--- a/sphinx/domains/std.py\n+++ b/sphinx/domains/std.py\n@@ -584,6 +584,14 @@ class StandardDomain(Domain):\n         'doc':     XRefRole(warn_dangling=True, innernodeclass=nodes.inline),\n     }\n \n+    # names usable in a toctree that refer to generated pages\n+    # name -> docname, labelid, title\n+    _virtual_doc_names: Dict[str, Tuple[str, str, str]] = {\n+        'genindex': ('genindex', '', _('Index')),\n+        'modindex': ('py-modindex', '', _('Module Index')),\n+        'search':   ('search', '', _('Search Page')),\n+    }\n+\n     initial_data = {\n         'progoptions': {},      # (program, name) -> docname, labelid\n         'objects': {},          # (type, name) -> docname, labelid\ndiff --git a/sphinx/environment/adapters/toctree.py b/sphinx/environment/adapters/toctree.py\nindex 9678e3c7c..26c6ac2bb 100644\n--- a/sphinx/environment/adapters/toctree.py\n+++ b/sphinx/environment/adapters/toctree.py\n@@ -111,6 +111,7 @@ class TocTree:\n                                   separate: bool = False, subtree: bool = False\n                                   ) -> List[Element]:\n             \"\"\"Return TOC entries for a toctree node.\"\"\"\n+            generated_docnames = self.env.get_domain('std')._virtual_doc_names\n             refs = [(e[0], e[1]) for e in toctreenode['entries']]\n             entries: List[Element] = []\n             for (title, ref) in refs:\n@@ -139,6 +140,16 @@ class TocTree:\n                         item = nodes.list_item('', para)\n                         # don't show subitems\n                         toc = nodes.bullet_list('', item)\n+                    elif ref in generated_docnames:\n+                        docname, _, sectionname = generated_docnames[ref]\n+                        if not title:\n+                            title = sectionname\n+                        reference = nodes.reference('', title, internal=True,\n+                                                    refuri=docname, anchorname='')\n+                        para = addnodes.compact_paragraph('', '', reference)\n+                        item = nodes.list_item('', para)\n+                        # don't show subitems\n+                        toc = nodes.bullet_list('', item)\n                     else:\n                         if ref in parents:\n                             logger.warning(__('circular toctree references '\n", "model": "claude-sonnet-5-5", "steps": 16, "finished": false, "patch_lines": 70, "candidates": [{"compile_ok": 0, "loc_hits": 2, "files": 3, "diff_lines": 70, "steps": 16}], "ms": 72109}
{"instance_id": "sphinx-doc__sphinx-11445", "model_name_or_path": "cain-anthropic-e124", "model_patch": "diff --git a/sphinx/util/rst.py b/sphinx/util/rst.py\nindex 7a1538325..78eee284a 100644\n--- a/sphinx/util/rst.py\n+++ b/sphinx/util/rst.py\n@@ -9,6 +9,7 @@ from typing import Generator\n from unicodedata import east_asian_width\n \n from docutils.parsers.rst import roles\n+from docutils.parsers.rst.states import Body\n from docutils.parsers.rst.languages import en as english\n from docutils.statemachine import StringList\n from docutils.utils import Reporter\n@@ -25,7 +26,7 @@ except ImportError:\n \n logger = logging.getLogger(__name__)\n \n-docinfo_re = re.compile(':\\\\w+:.*?')\n+docinfo_re = re.compile(Body.patterns['field_marker'])\n symbols_re = re.compile(r'([!-\\-/:-@\\[-`{-~])')  # symbols without dot(0x2e)\n SECTIONING_CHARS = ['=', '-', '~']\n \n", "model": "claude-sonnet-5-5", "steps": 8, "finished": true, "patch_lines": 21, "candidates": [{"compile_ok": 0, "loc_hits": 0, "files": 1, "diff_lines": 21, "steps": 8}], "ms": 20337}
{"instance_id": "sphinx-doc__sphinx-11510", "model_name_or_path": "cain-anthropic-e124", "model_patch": "diff --git a/sphinx/directives/other.py b/sphinx/directives/other.py\nindex 19f7c0a8d..0cac9a6f4 100644\n--- a/sphinx/directives/other.py\n+++ b/sphinx/directives/other.py\n@@ -8,6 +8,7 @@ from docutils.parsers.rst import directives\n from docutils.parsers.rst.directives.admonitions import BaseAdmonition\n from docutils.parsers.rst.directives.misc import Class\n from docutils.parsers.rst.directives.misc import Include as BaseInclude\n+from docutils.statemachine import StateMachine\n \n from sphinx import addnodes\n from sphinx.domains.changeset import VersionChange  # noqa: F401  # for compatibility\n@@ -369,6 +370,31 @@ class Include(BaseInclude, SphinxDirective):\n     \"\"\"\n \n     def run(self) -> list[Node]:\n+\n+        # To properly emit \"source-read\" events from included RST text,\n+        # we must patch the ``StateMachine.insert_input()`` method.\n+        def _insert_input(include_lines: list[str], source: str) -> None:\n+            # Combine the lines back into text to send with the event.\n+            # The last two lines are markers added by docutils; preserve\n+            # them and leave them out of the source-read event.\n+            text = \"\\n\".join(include_lines[:-2])\n+\n+            # The docname to pass into the source-read event\n+            docname = self.env.path2doc(source)\n+            arg = [text]\n+            self.env.events.emit(\"source-read\", docname, arg)\n+            text = arg[0]\n+\n+            # Split back into lines and reattach the two marker lines\n+            include_lines = text.splitlines() + include_lines[-2:]\n+\n+            # Call the class implementation (we patch only the instance).\n+            return StateMachine.insert_input(self.state_machine, include_lines, source)\n+\n+        # Only enable this patch if there are listeners for 'source-read'.\n+        if self.env.events.listeners.get('source-read'):\n+            self.state_machine.insert_input = _insert_input  # type: ignore[method-assign]\n+\n         if self.arguments[0].startswith('<') and \\\n            self.arguments[0].endswith('>'):\n             # docutils \"standard\" includes, do not do path processing\n", "model": "claude-sonnet-5-5", "steps": 15, "finished": false, "patch_lines": 44, "candidates": [{"compile_ok": 0, "loc_hits": 0, "files": 1, "diff_lines": 44, "steps": 15}], "ms": 172452}
{"instance_id": "sphinx-doc__sphinx-7440", "model_name_or_path": "cain-anthropic-e124", "model_patch": "diff --git a/sphinx/domains/std.py b/sphinx/domains/std.py\nindex d820cfe5c..197377c28 100644\n--- a/sphinx/domains/std.py\n+++ b/sphinx/domains/std.py\n@@ -305,7 +305,7 @@ def make_glossary_term(env: \"BuildEnvironment\", textnodes: Iterable[Node], index\n         term['ids'].append(node_id)\n \n     std = cast(StandardDomain, env.get_domain('std'))\n-    std.note_object('term', termtext.lower(), node_id, location=term)\n+    std.note_object('term', termtext, node_id, location=term)\n \n     # add an index entry too\n     indexnode = addnodes.index()\n@@ -565,7 +565,7 @@ class StandardDomain(Domain):\n         # links to tokens in grammar productions\n         'token':   TokenXRefRole(),\n         # links to terms in glossary\n-        'term':    XRefRole(lowercase=True, innernodeclass=nodes.inline,\n+        'term':    XRefRole(innernodeclass=nodes.inline,\n                             warn_dangling=True),\n         # links to headings or arbitrary labels\n         'ref':     XRefRole(lowercase=True, innernodeclass=nodes.inline,\n@@ -789,6 +789,8 @@ class StandardDomain(Domain):\n                           RemovedInSphinx40Warning)\n             domain = env.get_domain('citation')\n             return domain.resolve_xref(env, fromdocname, builder, typ, target, node, contnode)\n+        elif typ == 'term':\n+            resolver = self._resolve_term_xref\n         else:\n             resolver = self._resolve_obj_xref\n \n@@ -923,6 +925,22 @@ class StandardDomain(Domain):\n         return make_refnode(builder, fromdocname, docname,\n                             labelid, contnode)\n \n+    def _resolve_term_xref(self, env: \"BuildEnvironment\", fromdocname: str,\n+                           builder: \"Builder\", typ: str, target: str,\n+                           node: pending_xref, contnode: Element) -> Element:\n+        result = self._resolve_obj_xref(env, fromdocname, builder, typ,\n+                                        target, node, contnode)\n+        if result:\n+            return result\n+        # fall back to a case-insensitive match\n+        ltarget = target.lower()\n+        for objtype, term in self.objects:\n+            if objtype == 'term' and term.lower() == ltarget:\n+                docname, labelid = self.objects[objtype, term]\n+                return make_refnode(builder, fromdocname, docname,\n+                                    labelid, contnode)\n+        return None\n+\n     def _resolve_obj_xref(self, env: \"BuildEnvironment\", fromdocname: str,\n                           builder: \"Builder\", typ: str, target: str,\n                           node: pending_xref, contnode: Element) -> Element:\n@@ -951,10 +969,19 @@ class StandardDomain(Domain):\n                 results.append(('std:' + role, res))\n         # all others\n         for objtype in self.object_types:\n-            key = (objtype, target)\n             if objtype == 'term':\n-                key = (objtype, ltarget)\n-            if key in self.objects:\n+                # exact match first, then case-insensitive match\n+                key = None\n+                if (objtype, target) in self.objects:\n+                    key = (objtype, target)\n+                else:\n+                    for k in self.objects:\n+                        if k[0] == 'term' and k[1].lower() == ltarget:\n+                            key = k\n+                            break\n+            else:\n+                key = (objtype, target)\n+            if key is not None and key in self.objects:\n                 docname, labelid = self.objects[key]\n                 results.append(('std:' + self.role_for_objtype(objtype),\n                                 make_refnode(builder, fromdocname, docname,\n", "model": "claude-sonnet-5-5", "steps": 11, "finished": true, "patch_lines": 77, "candidates": [{"compile_ok": 0, "loc_hits": 1, "files": 1, "diff_lines": 77, "steps": 11}], "ms": 34895}
{"instance_id": "sphinx-doc__sphinx-7454", "model_name_or_path": "cain-anthropic-e124", "model_patch": "diff --git a/sphinx/domains/python.py b/sphinx/domains/python.py\nindex 893bb0a22..8c3f8d4cf 100644\n--- a/sphinx/domains/python.py\n+++ b/sphinx/domains/python.py\n@@ -71,8 +71,14 @@ pairindextypes = {\n def _parse_annotation(annotation: str) -> List[Node]:\n     \"\"\"Parse type annotation.\"\"\"\n     def make_xref(text: str) -> addnodes.pending_xref:\n+        if text == 'None':\n+            # None is not a type, so use obj role instead.\n+            reftype = 'obj'\n+        else:\n+            reftype = 'class'\n+\n         return pending_xref('', nodes.Text(text),\n-                            refdomain='py', reftype='class', reftarget=text)\n+                            refdomain='py', reftype=reftype, reftarget=text)\n \n     def unparse(node: ast.AST) -> List[Node]:\n         if isinstance(node, ast.Attribute):\n", "model": "claude-sonnet-5-5", "steps": 7, "finished": true, "patch_lines": 20, "candidates": [{"compile_ok": 0, "loc_hits": 0, "files": 1, "diff_lines": 20, "steps": 7}], "ms": 12973}
