]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Fix error in docstrings in bisect module (GH-21422)
authorSergey Golitsynskiy <sgolitsynskiy@gmail.com>
Sat, 11 Jul 2020 23:18:31 +0000 (19:18 -0400)
committerGitHub <noreply@github.com>
Sat, 11 Jul 2020 23:18:31 +0000 (20:18 -0300)
The docstrings for `bisect_right()` and `bisect_left()` contain sample
code that has a bug: `a.insert(x)` should be `a.insert(i, x)`.

Lib/bisect.py

index 8f3f6a3fe35ffea711796e6f7c2a19f5add1342d..8336a4ed9ca0f8d8ea445f7b961cb191aa8d4083 100644 (file)
@@ -16,7 +16,7 @@ def bisect_right(a, x, lo=0, hi=None):
     """Return the index where to insert item x in list a, assuming a is sorted.
 
     The return value i is such that all e in a[:i] have e <= x, and all e in
-    a[i:] have e > x.  So if x already appears in the list, a.insert(x) will
+    a[i:] have e > x.  So if x already appears in the list, a.insert(i, x) will
     insert just after the rightmost x already there.
 
     Optional args lo (default 0) and hi (default len(a)) bound the
@@ -51,7 +51,7 @@ def bisect_left(a, x, lo=0, hi=None):
     """Return the index where to insert item x in list a, assuming a is sorted.
 
     The return value i is such that all e in a[:i] have e < x, and all e in
-    a[i:] have e >= x.  So if x already appears in the list, a.insert(x) will
+    a[i:] have e >= x.  So if x already appears in the list, a.insert(i, x) will
     insert just before the leftmost x already there.
 
     Optional args lo (default 0) and hi (default len(a)) bound the