diff --git a/sphinx/environment/collectors/toctree.py b/sphinx/environment/collectors/toctree.py index 772591e97..da9c45255 100644 --- a/sphinx/environment/collectors/toctree.py +++ b/sphinx/environment/collectors/toctree.py @@ -201,7 +201,7 @@ class TocTreeCollector(EnvironmentCollector): numstack[-1] += 1 reference = cast(nodes.reference, subnode[0]) if depth > 0: - number = list(numstack) + number = numstack.copy() secnums[reference['anchorname']] = tuple(numstack) else: number = None diff --git a/sphinx/ext/autodoc/importer.py b/sphinx/ext/autodoc/importer.py index 84bfee58e..3e36ff741 100644 --- a/sphinx/ext/autodoc/importer.py +++ b/sphinx/ext/autodoc/importer.py @@ -97,7 +97,7 @@ def import_object(modname: str, objpath: list[str], objtype: str = '', try: module = None exc_on_importing = None - objpath = list(objpath) + objpath = objpath.copy() while module is None: try: original_module_names = frozenset(sys.modules) diff --git a/sphinx/ext/napoleon/docstring.py b/sphinx/ext/napoleon/docstring.py index ea8a85f04..df2ccdfd8 100644 --- a/sphinx/ext/napoleon/docstring.py +++ b/sphinx/ext/napoleon/docstring.py @@ -1286,7 +1286,7 @@ class NumpyDocstring(GoogleDocstring): if not name: return name, role = parse_item_name(name) - items.append((name, list(rest), role)) + items.append((name, rest.copy(), role)) del rest[:] def translate(func, description, role): diff --git a/sphinx/jinja2glue.py b/sphinx/jinja2glue.py index cfe92b075..fba394ab1 100644 --- a/sphinx/jinja2glue.py +++ b/sphinx/jinja2glue.py @@ -60,7 +60,7 @@ def _todim(val: int | str) -> str: def _slice_index(values: list, slices: int) -> Iterator[list]: - seq = list(values) + seq = values.copy() length = 0 for value in values: length += 1 + len(value[1][1]) # count includes subitems