changeset ee4d7565f16f in modules/country:default
details: https://hg.tryton.org/modules/country?cmd=changeset&node=ee4d7565f16f
description:
Use TextIOWrapper instead of encode/decode bytes with StringIO
issue10554
review344471003
diffstat:
scripts/import_postal_codes.py | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diffs (21 lines):
diff -r af5b02aa340e -r ee4d7565f16f scripts/import_postal_codes.py
--- a/scripts/import_postal_codes.py Sun Jul 04 17:54:46 2021 +0200
+++ b/scripts/import_postal_codes.py Thu Jul 22 00:05:32 2021 +0200
@@ -12,7 +12,7 @@
import zipfile
from argparse import ArgumentParser
-from io import BytesIO, StringIO
+from io import BytesIO, TextIOWrapper
try:
from progressbar import ProgressBar, Bar, ETA, SimpleProgress
@@ -76,7 +76,7 @@
widgets=[SimpleProgress(), Bar(), ETA()])
else:
pbar = iter
- f = StringIO(data.decode('utf-8'))
+ f = TextIOWrapper(BytesIO(data), encoding='utf-8')
codes = []
for row in pbar(list(csv.DictReader(
f, fieldnames=_fieldnames, delimiter='\t'))):