python / python/mypy

mypyc: Any subclass of BytesIO will always generate an exception when instantiated

Aperta
#16,209 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

bug topic-mypyc
Lingua principale
Python
Stelle
20.6k
Fork
3.3k
Metriche di merge delle PR
Metriche PR in attesa

Descrizione

Bug Report

Any subclass of BytesIO will always generate the following exception when instantiated:
BufferError: Existing exports of data: object cannot be re-sized

To Reproduce

1. Run TestSubclassingBytesIO.py and notice it prints two instances (one of BytesIO and the other of SubBytesIO)
2. Using mypyc compile the 4 line file: SubclassingBytesIO.py
3. Then again run the tiny TestSubclassingBytesIO.py
4. The run will crash with the mentioned exception.

TestSubclassingBytesIO.zip

Expected Behavior
Running TestSubclassingBytesIO.py after compiling with mypyc should work just like running it before compiling. It should print:
<_io.BytesIO object at 0x0000026903075BC0>
<SubclassingBytesIO.SubBytesIO object at 0x00000269030A0630>

Actual Behavior
<_io.BytesIO object at 0x00000238D1D95BC0>
Traceback (most recent call last):
File "c:\Projects\mypycbug\TestSubclassingBytesIO.py", line 7, in
x = SubBytesIO()
^^^^^^^^^^^^
BufferError: Existing exports of data: object cannot be re-sized

Your Environment

  • Mypy version used: 1.5.1
  • Mypy command-line flags: None
  • Mypy configuration options from mypy.ini (and other config files): None
  • Python version used: 3.11.4

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Direzione di ricerca

Inizia estraendo TestSubclassingBytesIO.zip ed eseguendo TestSubclassingBytesIO.py prima e dopo aver compilato SubclassingBytesIO.py con mypyc. Confronta i percorsi di istanziazione di BytesIO e SubBytesIO; il lavoro è completato quando lo script compilato stampa entrambe le istanze senza generare BufferError.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
python
Ambito
compilers
Tipo di issue
Bug
Difficoltà
4/5
Tempo stimato
3-5 giorni
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
35/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.