Python 3: make decoding shapefile fields more lenient...
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 35/100
Direzione di ricerca
Inizia in shapefile.py, nell’helper di decodifica dei campi per Python 3, e riproduci il failure con la shape network.zip collegata. Verifica che i campi contenenti bytes non decodificabili non impediscano più il disegno della shape, mentre la gestione esistente delle stringhe e dei valori non-byte rimane invariata.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
In python 3, field values of shapefile are parsed in shapefile.py, as shown below:
def u(v):
if PYTHON3:
if isinstance(v, bytes):
# For python 3 decode bytes to str.
return v.decode('utf-8')
elif isinstance(v, str):
# Already str.
return v
else:
# Error.
raise Exception('Unknown input type')
else:
# For python 2 assume str passed in and return str.
return v
But in the case v.decode fails in the first if (when v is an instance of bytes), then the file won't be drawn. I propose to change it as follows (to make it work):
def u(v):
if PYTHON3:
if isinstance(v, bytes):
# For python 3 decode bytes to str.
return v.decode('utf-8', errors='ignore')
elif isinstance(v, str):
# Already str.
return v
else:
# Error.
raise Exception('Unknown input type')
else:
# For python 2 assume str passed in and return str.
return v
Here is the link to the shape on which the original version fails and the changed one works:
https://dl.dropboxusercontent.com/u/4629759/network.zip
Cheers
- Lingua principale
- Python
- Stelle
- 817
- Fork
- 395
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Guida per i contributori
Nessuna guida per i contributori indicizzata per questo repository
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di matplotlib/basemap
-
small bug in drawmapscale Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
matplotlib/basemap#368 ·
-
Python 3.14 wheels Aperta
Difficoltà 4/5 3-5 giorni Idoneità per principianti 48/100
matplotlib/basemap#652 · 2 commenti · 5 reazioni ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 45/100
matplotlib/basemap#649 · 2 reazioni ·
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 35/100
matplotlib/basemap#646 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 48/100
matplotlib/basemap#645 · 2 commenti ·
Tutte le issue di matplotlib/basemap
Issue simili
-
triage/confirmed
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
agentscope-ai/agentscope#2775 ·
-
comp/desktop P3 type/bug
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 92/100
NousResearch/hermes-agent#118866 ·
-
bug
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 90/100
apache/cloudstack#14222 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100