internlm/SWE-Fixer-Train-110K huggingface dataset:
Repository: sagemath/sage

Issue:
Fix doctest in sage/schemes/elliptic_curves/ell_number_field.py
<div id="comment:0"></div>

A "long" annotation is missing in a doctest introduced in #34537, causing:

```
sage -t --random-seed=257591867899933130420640722238032668369 sage/schemes/elliptic_curves/ell_number_field.py
**********************************************************************
File "sage/schemes/elliptic_curves/ell_number_field.py", line 2304, in sage.schemes.elliptic_curves.ell_number_field.EllipticCurve_number_field.gens
Failed example:
    P=gg[0]; P.order()
Exception raised:
    Traceback (most recent call last):
      File "/__w/sagetrac-mirror/sagetrac-mirror/src/sage/doctest/forker.py", line 695, in _run
        self.compile_and_execute(example, compiler, test.globs)
      File "/__w/sagetrac-mirror/sagetrac-mirror/src/sage/doctest/forker.py", line 1093, in compile_and_execute
        exec(compiled, globs)
      File "<doctest sage.schemes.elliptic_curves.ell_number_field.EllipticCurve_number_field.gens[7]>", line 1, in <module>
        P=gg[Integer(0)]; P.order()
    NameError: name 'gg' is not defined
```

CC:  @dimpase

Component: **doctest coverage**

_Issue created by migration from https://trac.sagemath.org/ticket/34959_




Discussion:
I came across this too while working on #22697.  I think that all the automated testing is done with --long so this sort of thing gets missed.

Although I have a fix i my branch, I will make a PR for this now.

Resolving patch:
diff --git a/src/sage/schemes/elliptic_curves/ell_number_field.py b/src/sage/schemes/elliptic_curves/ell_number_field.py
--- a/src/sage/schemes/elliptic_curves/ell_number_field.py
+++ b/src/sage/schemes/elliptic_curves/ell_number_field.py
@@ -2301,9 +2301,9 @@ def gens(self, **kwds):
 
         Check that the the point found has infinite order, and that it is on the curve::
 
-            sage: P=gg[0]; P.order()
+            sage: P=gg[0]; P.order()  # long time
             +Infinity
-            sage: E.defining_polynomial()(*P)
+            sage: E.defining_polynomial()(*P)  # long time
             0
 
         Here is a curve of rank 2::


Test patch:
Repository: sagemath/sage

Issue:
SkewTableaux are unhashable
### Is there an existing issue for this?

- [X] I have searched the existing issues for a bug report that matches the one I want to file, without success.

### Did you read the documentation and troubleshoot guide?

- [X] I have read the documentation and troubleshoot guide

### Environment

```markdown
- **OS**: any
- **Sage Version**: 10.0.beta0
```


### Steps To Reproduce

```
sage: hash(SkewTableau([[1]]))
```

### Expected Behavior

Should be a hash.

### Actual Behavior

Fails

### Additional Information

This is because it overrides equality, see

https://groups.google.com/u/2/g/sage-devel/c/DrxRHl3dQOU


Discussion:

Resolving patch:
diff --git a/src/sage/combinat/skew_tableau.py b/src/sage/combinat/skew_tableau.py
--- a/src/sage/combinat/skew_tableau.py
+++ b/src/sage/combinat/skew_tableau.py
@@ -148,11 +148,11 @@ def __eq__(self, other):
 
         INPUT:
 
-        ``other`` -- the element that ``self`` is compared to
+        - ``other`` -- the element that ``self`` is compared to
 
         OUTPUT:
 
-        A Boolean.
+        A boolean.
 
         TESTS::
 
@@ -161,6 +161,10 @@ def __eq__(self, other):
             False
             sage: t == SkewTableaux()([[None,1,2]])
             True
+            sage: t == [(None,1,2)]
+            True
+            sage: t == [[None,1,2]]
+            True
 
             sage: s = SkewTableau([[1,2]])
             sage: s == 0
@@ -171,7 +175,7 @@ def __eq__(self, other):
         if isinstance(other, (Tableau, SkewTableau)):
             return list(self) == list(other)
         else:
-            return list(self) == other
+            return list(self) == other or list(list(row) for row in self) == other
 
     def __ne__(self, other):
         r"""
@@ -181,22 +185,33 @@ def __ne__(self, other):
 
         INPUT:
 
-        ``other`` -- the element that ``self`` is compared to
+        - ``other`` -- the element that ``self`` is compared to
 
         OUTPUT:
 
-        A Boolean.
+        A boolean.
 
         TESTS::
 
-            sage: t = Tableau([[2,3],[1]])
+            sage: t = SkewTableau([[None,1,2]])
             sage: t != []
             True
         """
-        if isinstance(other, (Tableau, SkewTableau)):
-            return list(self) != list(other)
-        else:
-            return list(self) != other
+        return not (self == other)
+
+    def __hash__(self):
+        """
+        Return the hash of ``self``.
+
+        EXAMPLES:
+
+        Check that :trac:`35137` is fixed::
+
+            sage: t = SkewTableau([[None,1,2]])
+            sage: hash(t) == hash(tuple(t))
+            True
+        """
+        return hash(tuple(self))
 
     def check(self):
         r"""


Test patch:
Repository: sagemath/sage

Issue:
arrow((0,0), (0,0), linestyle='dashed') raises list index out of range
With SageMath version 9.8.beta1, Release Date: 2022-09-29, this works:

```
sage: arrow((0,0), (0,0))
Launched png viewer for Graphics object consisting of 1 graphics primitive
```

but this is broken:

```
sage: arrow((0,0), (0,0), linestyle='dashed')
/home/slabbe/GitBox/sage/src/sage/repl/rich_output/display_manager.py:610: RichReprWarning: Exception in _rich_repr_ while displaying object: list index out of range
  warnings.warn(
Graphics object consisting of 1 graphics primitive
```



Discussion:
@seblabbe One way to work around this issue is to use the linetypes option instead of linestyle to specify the type of line used for the arrow. 
`sage: arrow((0,0), (0,0), linetypes=['dashed'])`

Resolving patch:
diff --git a/src/sage/plot/arrow.py b/src/sage/plot/arrow.py
--- a/src/sage/plot/arrow.py
+++ b/src/sage/plot/arrow.py
@@ -413,7 +413,10 @@ def get_paths(self, renderer):
                     return paths
 
                 def __call__(self, renderer, gc, tpath, affine, rgbFace):
-                    path = self.get_paths(renderer)[self._n]
+                    paths = self.get_paths(renderer)
+                    if self._n >= len(paths):
+                        return False
+                    path = paths[self._n]
                     vert1, code1 = path.vertices, path.codes
                     import numpy as np
 
@@ -470,6 +473,13 @@ def arrow(tailpoint=None, headpoint=None, **kwds):
 
         sphinx_plot(arrow((0,0,1), (1,1,1)))
 
+    TESTS:
+
+    Check that :trac:`35031` is fixed::
+
+        sage: arrow((0,0), (0,0), linestyle='dashed')
+        Graphics object consisting of 1 graphics primitive
+
     """
     try:
         return arrow2d(tailpoint, headpoint, **kwds)


Test patch:
Repository: sagemath/sage

Issue:
Description of inputs for primes is misleading.
<div id="comment:0"></div>

The description of the input parameters for the "primes" function is incorrect:

```

- ``start`` - an integer - lower bound for the primes
- ``stop`` - an integer (or infinity) optional argument -
  giving upper (open) bound for the primes
```

The current description states that "stop" is optional and "start" is required, when in fact it is the opposite.

Component: **basic arithmetic**

Keywords: **primes**

Branch/Commit: **[u/gh-Eloitor/primes_fix](https://github.com/sagemath/sagetrac-mirror/tree/u/gh-Eloitor/primes_fix) @ [`05734dc`](https://github.com/sagemath/sagetrac-mirror/commit/05734dc21240dcee47ad789ec8960940813e74ae)**

_Issue created by migration from https://trac.sagemath.org/ticket/34920_




Discussion:

Resolving patch:
diff --git a/src/sage/arith/misc.py b/src/sage/arith/misc.py
--- a/src/sage/arith/misc.py
+++ b/src/sage/arith/misc.py
@@ -1010,7 +1010,7 @@ def eratosthenes(n):
     return [ZZ(2)] + [ZZ(x) for x in s if x and x <= n]
 
 
-def primes(start, stop=None, proof=None):
+def primes(start=2, stop=None, proof=None):
     r"""
     Return an iterator over all primes between start and stop-1,
     inclusive. This is much slower than ``prime_range``, but
@@ -1027,10 +1027,11 @@ def primes(start, stop=None, proof=None):
 
     INPUT:
 
-    - ``start`` - an integer - lower bound for the primes
+    - ``start`` - an integer (default: 2) optional argument -
+      giving lower bound for the primes
 
-    - ``stop`` - an integer (or infinity) optional argument -
-      giving upper (open) bound for the primes
+    - ``stop`` - an integer (or infinity) - giving upper (open) bound for the
+      primes
 
     - ``proof`` - bool or None (default: None)  If True, the function
       yields only proven primes.  If False, the function uses a


Test patch:
Repository: sagemath/sage

Issue:
multivar polynomials over poly fraction fields don't simplify
<div id="comment:0"></div>


```
sage: F=FractionField(PolynomialRing(QQ,'t'))
sage: R=PolynomialRing(F,'x,y')
sage: R.inject_variables() 
Defining x, y
sage: x/x 
x/x
```
whereas simpler fraction fields for F yield 1

CC:  @sagetrac-jakobkroeker

Component: **commutative algebra**

_Issue created by migration from https://trac.sagemath.org/ticket/15971_




Discussion:
<div id="comment:3" align="right">comment:3</div>

Seems fixed now. Needs a test, then review

Resolving patch:
diff --git a/src/sage/rings/fraction_field.py b/src/sage/rings/fraction_field.py
--- a/src/sage/rings/fraction_field.py
+++ b/src/sage/rings/fraction_field.py
@@ -55,6 +55,18 @@
     sage: F = FractionField(PolynomialRing(RationalField(),2,'x'))
     sage: F == loads(dumps(F))
     True
+
+Test that :trac:`15971` is fixed::
+
+    sage: for B in [QQ['t'], QQ['s, t'], ZZ['t'], ZZ['s, t']]:
+    ....:     F = B.fraction_field()
+    ....:     R = F['x, y']
+    ....:     x = R.gen(0)
+    ....:     print(x / x)
+    1
+    1
+    1
+    1
 """
 # ****************************************************************************
 #


Test patch:
Repository: sagemath/sage

Issue:
Docs: use sphinx-copybutton
https://sphinx-copybutton.readthedocs.io/en/latest/

It can strip prompts and remove output.
It also can [remove comments](https://sphinx-copybutton.readthedocs.io/en/latest/use.html#exclude-text-from-being-copied) – we can use this as an improvement for doctests with lots of `# optional` doctest annotations.


Discussion:

Resolving patch:
diff --git a/src/sage_docbuild/conf.py b/src/sage_docbuild/conf.py
--- a/src/sage_docbuild/conf.py
+++ b/src/sage_docbuild/conf.py
@@ -46,6 +46,7 @@
     'sphinx.ext.todo',
     'sphinx.ext.extlinks',
     'sphinx.ext.mathjax',
+    'sphinx_copybutton',
     'IPython.sphinxext.ipython_directive',
     'matplotlib.sphinxext.plot_directive',
     'jupyter_sphinx',
@@ -255,6 +256,12 @@ def set_intersphinx_mappings(app, config):
 # By default document are not master.
 multidocs_is_master = True
 
+# https://sphinx-copybutton.readthedocs.io/en/latest/use.html
+copybutton_prompt_text = r"sage: |[.][.][.][.]: |\$ "
+copybutton_prompt_is_regexp = True
+copybutton_exclude = '.linenos, .c1'  # exclude single comments (in particular, # optional!)
+copybutton_only_copy_prompt_lines = True
+
 # Options for HTML output
 # -----------------------
 


Test patch:
Repository: sagemath/sage

Issue:
Reenable broken doctests in #15473 and #15476 when #10963 is merged
<div id="comment:0"></div>

This branch activates two combinat doctests which were disabled due to unexplainable bugs that were fixed in #10963:

```
            The following doctest is disabled pending :trac:`10963`::

                sage: s = SymmetricFunctions(Zmod(14)).s() # not tested
                sage: s.is_integral_domain() # not tested
                False
```
and

```
                    sage: def descent_test(n):
                    ....:     DA = DescentAlgebra(QQ, n)
                    ....:     NSym = NonCommutativeSymmetricFunctions(QQ)
                    ....:     S = NSym.S()
                    ....:     DAD = DA.D()
                    ....:     w_n = DAD(set(range(1, n)))
                    ....:     for I in Compositions(n):
                    ....:         if not (S[I].star_involution()
                    ....:                 == w_n * S[I].to_descent_algebra(n) * w_n):
                    ....:             return False
                    ....:         return True
                    sage: all( descent_test(i) for i in range(4) ) # not tested
                    True
                    sage: all( descent_test(i) for i in range(6) ) # not tested
                    True

                .. TODO::

                    Once :trac:`10963` is in, remove the first "not tested" above,
                    and replace the second one by "long time".
```
Also, a few typos in the c3_controlled doc are fixed.

Disregard the attachment.

Depends on #10963
Depends on #15473
Depends on #15476
Depends on #16678

CC:  @nthiery @simon-king-jena @tscrim @sagetrac-sage-combinat

Component: **categories**

Keywords: **10963, c3, transitivity, descent algebras, symmetric functions**

Branch/Commit: **[public/categories/15475](https://github.com/sagemath/sagetrac-mirror/tree/public/categories/15475) @ [`bf34154`](https://github.com/sagemath/sagetrac-mirror/commit/bf3415442124b6778afdb799016efa4343c677b8)**

_Issue created by migration from https://trac.sagemath.org/ticket/15475_




Discussion:
just documentation typos that i fixed when i was reading it

Resolving patch:
diff --git a/src/sage/combinat/sf/sfa.py b/src/sage/combinat/sf/sfa.py
--- a/src/sage/combinat/sf/sfa.py
+++ b/src/sage/combinat/sf/sfa.py
@@ -403,10 +403,8 @@ def is_integral_domain(self, proof=True):
                 sage: s.is_integral_domain()
                 True
 
-            The following doctest is disabled pending :trac:`15475`::
-
-                sage: s = SymmetricFunctions(Zmod(14)).s() # not tested
-                sage: s.is_integral_domain() # not tested
+                sage: s = SymmetricFunctions(Zmod(14)).s()
+                sage: s.is_integral_domain()
                 False
             """
             return self.base_ring().is_integral_domain()


Test patch:
Repository: sagemath/sage

Issue:
`sage.quadratic_forms`: Fix use of `staticmethod` for Python < 3.10
from https://groups.google.com/g/sage-release/c/32jPICGAkVU/m/f-5KX1xbAgAJ

https://docs.python.org/3/library/functions.html#staticmethod



Discussion:

Resolving patch:
diff --git a/src/sage/quadratic_forms/genera/genus.py b/src/sage/quadratic_forms/genera/genus.py
--- a/src/sage/quadratic_forms/genera/genus.py
+++ b/src/sage/quadratic_forms/genera/genus.py
@@ -121,7 +121,8 @@ def genera(sig_pair, determinant, max_scale=None, even=False):
     return genera
 
 
-genera = staticmethod(genera)
+# #35557: In Python < 3.10, a staticmethod cannot be called directly
+_genera_staticmethod = staticmethod(genera)
 
 
 def _local_genera(p, rank, det_val, max_scale, even):
diff --git a/src/sage/quadratic_forms/quadratic_form.py b/src/sage/quadratic_forms/quadratic_form.py
--- a/src/sage/quadratic_forms/quadratic_form.py
+++ b/src/sage/quadratic_forms/quadratic_form.py
@@ -502,9 +502,8 @@ class QuadraticForm(SageObject):
         ])
 
     # Genus
-    lazy_import("sage.quadratic_forms.genera.genus", [
-            "genera"
-        ])
+    lazy_import("sage.quadratic_forms.genera.genus",
+                "_genera_staticmethod", as_="genera")
 
     def __init__(self, R, n=None, entries=None, unsafe_initialization=False, number_of_automorphisms=None, determinant=None):
         """


Test patch:
Repository: sagemath/sage

Issue:
Installation manual: In all-conda install, explain how to docbuild
In this mode, `make` is not used, so there will be no initial build of the documentation as part of `make all`.

https://doc.sagemath.org/html/en/developer/sage_manuals.html does not explain how to run a full build of the documentation.



Discussion:
An issue - the documentation of pplpy cannot be installed using `conda` or `pip`.
Workaround:
- #35536

A second issue – Sphinx does not seem to install copies of mathjax in the `_static` directories.

Confirmed workaround (thanks @xuluze) `export SAGE_USE_CDNS=yes`.

Currently, we do not install mathjax in conda at all, so without `SAGE_USE_CDNS=yes` it's broken.
We should probably do some of the following:
- in `conf.py`, check whether MATHJAX_DIR exists and looks reasonable (done in #35602)
- add `build/pkgs/mathjax/distros/conda.txt` 
- #30296


Resolving patch:
diff --git a/src/sage_docbuild/__main__.py b/src/sage_docbuild/__main__.py
--- a/src/sage_docbuild/__main__.py
+++ b/src/sage_docbuild/__main__.py
@@ -59,6 +59,7 @@
 import logging
 import argparse
 import os
+import shlex
 import sys
 import sphinx.ext.intersphinx
 from sage.env import SAGE_DOC_SRC
@@ -441,6 +442,9 @@ def main():
     if not name or not typ:
         parser.print_help()
         sys.exit(1)
+    elif name == 'all':
+        sys.exit(os.system(f'cd {shlex.quote(SAGE_DOC_SRC)} '
+                           f'&& ${{MAKE:-make}} -j${{SAGE_NUM_THREADS_PARALLEL:-1}} doc-{typ}'))
 
     # Set up module-wide logging.
     setup_logger(args.verbose, args.color)


Test patch:
Repository: sagemath/sage

Issue:
Implement octonions and split octonions
<div id="comment:0"></div>



CC:  @slel

Component: **algebra**

Keywords: **octonions**

_Issue created by migration from https://trac.sagemath.org/ticket/32940_




Discussion:

Resolving patch:
diff --git a/src/sage/algebras/all.py b/src/sage/algebras/all.py
--- a/src/sage/algebras/all.py
+++ b/src/sage/algebras/all.py
@@ -48,6 +48,8 @@
 
 lazy_import('sage.algebras.jordan_algebra', 'JordanAlgebra')
 
+lazy_import('sage.algebras.octonion_algebra', 'OctonionAlgebra')
+
 lazy_import('sage.algebras.shuffle_algebra', 'ShuffleAlgebra')
 
 from .clifford_algebra import CliffordAlgebra, ExteriorAlgebra
diff --git a/src/sage/algebras/catalog.py b/src/sage/algebras/catalog.py
--- a/src/sage/algebras/catalog.py
+++ b/src/sage/algebras/catalog.py
@@ -48,6 +48,7 @@
 - :class:`algebras.MalvenutoReutenauer <sage.combinat.fqsym.FreeQuasisymmetricFunctions>`
 - :class:`algebras.NilCoxeter
   <sage.algebras.nil_coxeter_algebra.NilCoxeterAlgebra>`
+- :class:`algebras.Octonion <sage.algebras.octonion_algebra.OctonionAlgebra>`
 - :class:`algebras.OrlikTerao
   <sage.algebras.orlik_terao.OrlikTeraoAlgebra>`
 - :class:`algebras.OrlikSolomon
@@ -137,5 +138,6 @@
            'ACEQuantumOnsagerAlgebra', 'AlternatingCentralExtensionQuantumOnsager')
 lazy_import('sage.algebras.down_up_algebra', 'DownUpAlgebra', 'DownUp')
 lazy_import('sage.algebras.yangian', 'Yangian')
+lazy_import('sage.algebras.octonion_algebra', 'OctonionAlgebra', 'Octonion')
 
 del lazy_import  # We remove the object from here so it doesn't appear under tab completion


Test patch:
Repository: sagemath/sage

Issue:
CI doc-build: Include links to changed HTML files
for example by running a diff against the HTML files on the Docker image



Discussion:

Resolving patch:
diff --git a/src/sage/doctest/control.py b/src/sage/doctest/control.py
--- a/src/sage/doctest/control.py
+++ b/src/sage/doctest/control.py
@@ -791,7 +791,7 @@ def add_files(self):
         # SAGE_ROOT_GIT can be None on distributions which typically
         # only have the SAGE_LOCAL install tree but not SAGE_ROOT
         if SAGE_ROOT_GIT is not None:
-            have_git = os.path.isdir(SAGE_ROOT_GIT)
+            have_git = os.path.exists(SAGE_ROOT_GIT)
         else:
             have_git = False
 
@@ -866,11 +866,12 @@ def all_doc_sources():
                 data = line.strip().split(' ')
                 status, filename = data[0], data[-1]
                 if (set(status).issubset("MARCU")
-                    and filename.startswith("src/sage")
-                    and (filename.endswith(".py") or
-                         filename.endswith(".pyx") or
-                         filename.endswith(".rst"))):
-                    self.files.append(os.path.relpath(opj(SAGE_ROOT,filename)))
+                        and filename.startswith("src/sage")
+                        and (filename.endswith(".py") or
+                             filename.endswith(".pyx") or
+                             filename.endswith(".rst"))
+                        and not skipfile(opj(SAGE_ROOT, filename), self.options.optional)):
+                    self.files.append(os.path.relpath(opj(SAGE_ROOT, filename)))
 
     def expand_files_into_sources(self):
         r"""


Test patch:
diff --git a/src/sage/doctest/test.py b/src/sage/doctest/test.py
--- a/src/sage/doctest/test.py
+++ b/src/sage/doctest/test.py
@@ -251,17 +251,24 @@
 
 Even though the doctester master process has exited, the child process
 is still alive, but it should be killed automatically
-after the `die_timeout` given above (10 seconds)::
+after the ``die_timeout`` given above (10 seconds)::
 
     sage: pid = int(open(F).read())    # long time
     sage: time.sleep(2)                # long time
     sage: os.kill(pid, signal.SIGQUIT) # long time; 2 seconds passed => still alive
     sage: time.sleep(8)                # long time
-    sage: os.kill(pid, signal.SIGQUIT) # long time; 10 seconds passed => dead
+    sage: os.kill(pid, signal.SIGQUIT) # long time; 10 seconds passed => dead  # random
     Traceback (most recent call last):
     ...
     ProcessLookupError: ...
 
+If the child process is dead and removed, the last output should be as above.
+However, the child process interrupted its parent process (see
+``"interrupt_diehard.rst"``), and became an orphan process. Depending on the
+system, an orphan process may eventually become a zombie process instead of
+being removed, and then the last output would just be a blank. Hence the ``#
+random`` tag.
+
 Test a doctest failing with ``abort()``::
 
     sage: subprocess.call(["sage", "-t", "--warn-long", "0",    # long time
Repository: sagemath/sage

Issue:
OrderedSetPartitions() fails for the empty set
### Is there an existing issue for this?

- [X] I have searched the existing issues for a bug report that matches the one I want to file, without success.

### Did you read the documentation and troubleshoot guide?

- [X] I have read the documentation and troubleshoot guide

### Environment

```markdown
- **OS**: Ubuntu 22.04
- **Sage Version**: 9.8.rc0
```


### Steps To Reproduce

`OrderedSetPartitions()` well supports parts of zero size.
For example, `OrderedSetPartitions({1,2},[1,1,0,0]).list()` gives:
> [[{1}, {2}, {}, {}], [{2}, {1}, {}, {}]]

However, it does not work when the input set is empty. 

### Expected Behavior

For example, calling `OrderedSetPartitions(set(),[0,0,0]).list()` should produce the partition of the empty set into empty (sub)sets:
> [[{}, {}, {}]]

### Actual Behavior

However, at the moment it results in the error:
> IndexError: list index out of range

### Additional Information

_No response_


Discussion:

Resolving patch:
diff --git a/src/sage/combinat/set_partition_ordered.py b/src/sage/combinat/set_partition_ordered.py
--- a/src/sage/combinat/set_partition_ordered.py
+++ b/src/sage/combinat/set_partition_ordered.py
@@ -1114,6 +1114,13 @@ def __iter__(self):
              [{1, 3}, {2}],
              [{2, 3}, {1}],
              [{1, 2, 3}]]
+
+        TESTS:
+
+        Test for :issue:`35654`::
+
+            sage: OrderedSetPartitions(set(),[0,0,0]).list()
+            [[{}, {}, {}]]
         """
         for x in Compositions(len(self._set)):
             for z in OrderedSetPartitions(self._set, x):
@@ -1379,11 +1386,18 @@ def multiset_permutation_next_lex(l):
         [2, 1, 0, 0, 1]
         [2, 1, 0, 1, 0]
         [2, 1, 1, 0, 0]
+
+    TESTS:
+
+    Test for :issue:`35654`::
+
+        sage: multiset_permutation_next_lex([])
+        0
     """
     i = len(l) - 2
     while i >= 0 and l[i] >= l[i + 1]:
         i -= 1
-    if i == -1:
+    if i <= -1:
         return 0
     j = len(l) - 1
     while l[j] <= l[i]:


Test patch: