The `bytearray()` value set to `bytes.partition()` and `bytes.rpartition()` is not converted to a `bytes()` value, keeping a `bytearray()` value in a tuple
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- Python
- Sterne
- 77.2k
- Forks
- 35.9k
- PR-Merge-Kennzahlen
- PR-Kennzahlen ausstehend
Beschreibung
Bug report
Bug description:
The bytearray() value set to bytes.partition() and bytes.rpartition() is not converted to a bytes() value, keeping a bytearray() value in a tuple as shown below:
v = bytes(b'ABCD')
# ↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓ # ↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓
print(v.partition(bytearray(b'BC'))) # (b'A', bytearray(b'BC'), b'D')
print(v.rpartition(bytearray(b'BC'))) # (b'A', bytearray(b'BC'), b'D')
# ↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑ # ↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑
The bytearray() value set to bytes.partition() and bytes.rpartition() should be converted to a bytes() value, not keeping a bytearray() value in a tuple because they are bytes functions and because of readability and consistency as shown below:
v = bytes(b'ABCD')
# ↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓ # ↓↓↓↓↓
print(v.partition(bytearray(b'BC'))) # (b'A', b'BC', b'D')
print(v.rpartition(bytearray(b'BC'))) # (b'A', b'BC', b'D')
# ↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑ # ↑↑↑↑↑
In addition, the bytes() value set to bytearray.partition() and bytearray.rpartition() is converted to a bytearray() value, not keeping a bytes() value in a tuple as shown below:
v = bytearray(b'ABCD')
# ↓↓↓↓↓↓↓↓↓↓↓↓ # ↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓
print(v.partition(bytes(b'BC'))) # (bytearray(b'A'), bytearray(b'BC'), bytearray(b'D'))
print(v.rpartition(bytes(b'BC'))) # (bytearray(b'A'), bytearray(b'BC'), bytearray(b'D'))
# ↑↑↑↑↑↑↑↑↑↑↑↑ # ↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑
CPython versions tested on:
3.12
Operating systems tested on:
Windows
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Führen Sie zuerst die bereitgestellten Python-Beispiele aus und suchen Sie anschließend die Implementierungen von bytes.partition(), bytes.rpartition(), bytearray.partition() und bytearray.rpartition() sowie deren Tests. Die Aufgabe ist erledigt, wenn die Elemente des zurückgegebenen Tupels durchgehend dem Typ des Objekts entsprechen, auf dem die Partitionierung aufgerufen wird, mit Regressionstests für beide Richtungen und beide Argumenttypen.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- python
- Bereich
- backend
- Issue-Typ
- Bug
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 35/100