Script: the Runestone Services archive is unpacked without a `tarfile` filter, which Python 3.12 and 3.13 deprecate

Aperta Adatta ai principianti
#3,283 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
78/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
python
Ambito
build-system

Direzione di ricerca

La chiamata si trova in _place_runestone_services in pretext/lib/pretext.py, intorno alla riga 3969, dove l'archivio viene aperto con tarfile.open e poi estratto con extractall(build_dir). Leggi questa funzione, poi riproduci il problema eseguendo una build HTML con python3 -W default su Python 3.12 o 3.13 e conferma la DeprecationWarning. Il lavoro è completo quando la chiamata passa filter="data" se tarfile.data_filter esiste, mantiene la chiamata semplice per le versioni precedenti 3.10 e 3.11, e l'avviso scompare con gli stessi file estratti.

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

Descrizione

What happens

_place_runestone_services in pretext/lib/pretext.py unpacks the Runestone Services archive with extractall() and no filter argument (line 3969 at 6bcb7736). Python 3.12 and 3.13 raise a DeprecationWarning for that call:

pretext/lib/pretext.py:3969: DeprecationWarning: Python 3.14 will, by default, filter extracted tar archives and reject files or modify their metadata. Use the filter argument to control this behavior.
  services_file.extractall(build_dir)

Nobody sees it in an ordinary build, because Python shows a DeprecationWarning only when it is raised from the main script, and this call is in a library module. As the warning says, from Python 3.14 the same call applies a filter by default, so what the script does there changes without the script changing.

Reproduce

Any HTML build that places Runestone Services in its own output (the default), with Python 3.12 or 3.13 told to show every warning:

python3 -W default pretext/pretext -c doc -f html -p publication.ptx -d out main.ptx

Suggested change

Name the filter where tarfile has one:

            services_file = tarfile.open(services_build_path)
            if hasattr(tarfile, "data_filter"):
                services_file.extractall(build_dir, filter="data")
            else:
                services_file.extractall(build_dir)

tarfile has the argument in Python 3.12 and later, and in the security releases 3.10.12 and 3.11.4. The script supports Python 3.10, so the earlier releases of 3.10 and 3.11 need the plain call.

Tried with Python 3.13.5 on dist-8.3.2.tgz, the two calls on their own and not inside the script: with filter="data" there is no warning, and the 450 files come out with the same names, the same contents and the same permissions as without it.

This was first noted inside #3249, which is about the same two lines and is otherwise independent.

Environment: commit 6bcb7736 (2026-10-07), Python 3.13.5, Debian 13.

Claude Opus 5.5, acting as a coding assistant for Rob Beezer

Lingua principale
XSLT
Stelle
466
Fork
251
Merge medio
4m
PR unite (30g)
13

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

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.

Altre issue di PreTeXtBook/pretext

Tutte le issue di PreTeXtBook/pretext

Issue simili

Altre issue su Build System

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.