Skip to content

Commit 9c21864

Browse files
author
Kazuki Suzuki Przyborowski
committed
Update pyarchivefile.py
1 parent 8a211bb commit 9c21864

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

pyarchivefile.py

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3390,12 +3390,9 @@ def AppendFileHeaderWithContent(fp, filevalues=[], extradata=[], jsondata={}, fi
33903390
fjsontype = "json"
33913391
if(len(jsondata) > 0):
33923392
try:
3393-
fjsoncontent = base64.b64encode(json.dumps(jsondata, separators=(',', ':')).encode("UTF-8"))
3393+
fjsoncontent = json.dumps(jsondata, separators=(',', ':')).encode("UTF-8")
33943394
except (binascii.Error, json.decoder.JSONDecodeError, UnicodeDecodeError):
3395-
try:
3396-
fjsoncontent = json.dumps(jsondata.decode("UTF-8"))
3397-
except (binascii.Error, json.decoder.JSONDecodeError, UnicodeDecodeError):
3398-
fjsoncontent = "".encode("UTF-8")
3395+
fjsoncontent = "".encode("UTF-8")
33993396
else:
34003397
fjsoncontent = "".encode("UTF-8")
34013398
fjsonsize = format(len(fjsoncontent), 'x').lower()
@@ -7291,10 +7288,10 @@ def ArchiveFileValidate(infile, fmttype="auto", formatspecs=__file_format_multi_
72917288
outfprejsoncontent = fp.read(outfjsonsize).decode("UTF-8")
72927289
if(outfjsonsize > 0):
72937290
try:
7294-
outfjsoncontent = json.loads(base64.b64decode(outfprejsoncontent).decode("UTF-8"))
7291+
outfjsoncontent = json.loads(base64.b64decode(outfprejsoncontent.encode("UTF-8")).decode("UTF-8"))
72957292
except (binascii.Error, json.decoder.JSONDecodeError, UnicodeDecodeError):
72967293
try:
7297-
outfjsoncontent = json.loads(outfprejsoncontent.decode("UTF-8"))
7294+
outfjsoncontent = json.loads(outfprejsoncontent)
72987295
except (binascii.Error, json.decoder.JSONDecodeError, UnicodeDecodeError):
72997296
outfprejsoncontent = ""
73007297
outfjsoncontent = {}
@@ -7723,10 +7720,10 @@ def ArchiveFileToArray(infile, fmttype="auto", seekstart=0, seekend=0, listonly=
77237720
outfprejsoncontent = fp.read(outfjsonsize).decode("UTF-8")
77247721
if(outfjsonsize > 0):
77257722
try:
7726-
outfjsoncontent = json.loads(base64.b64decode(outfprejsoncontent).decode("UTF-8"))
7723+
outfjsoncontent = json.loads(base64.b64decode(outfprejsoncontent.encode("UTF-8")).decode("UTF-8"))
77277724
except (binascii.Error, json.decoder.JSONDecodeError, UnicodeDecodeError):
77287725
try:
7729-
outfjsoncontent = json.loads(outfprejsoncontent.decode("UTF-8"))
7726+
outfjsoncontent = json.loads(outfprejsoncontent)
77307727
except (binascii.Error, json.decoder.JSONDecodeError, UnicodeDecodeError):
77317728
outfprejsoncontent = ""
77327729
outfjsoncontent = {}

0 commit comments

Comments
 (0)