From 1fbce300a7933b8801b94bc2a1ad26cede1e4917 Mon Sep 17 00:00:00 2001 From: pierreluctg Date: Tue, 16 Jul 2019 13:07:16 -0400 Subject: [PATCH] Opening the pickle file in binary mode MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Opening the pickle file in binary mode because you can’t be sure if the ASCII or binary format is use --- devpi_rss/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/devpi_rss/__init__.py b/devpi_rss/__init__.py index 80cf365..a3c0640 100755 --- a/devpi_rss/__init__.py +++ b/devpi_rss/__init__.py @@ -109,7 +109,7 @@ def devpiserver_on_upload(stage, project, version, link): if pickle_file.exists(): debug("loading pickle file: %s" % pickle_file.strpath) - with open(pickle_file.strpath, "r") as f: + with open(pickle_file.strpath, "rb") as f: rss = pickle.load(f) else: debug("pickle file doesn't exist yet") @@ -146,7 +146,7 @@ def devpiserver_on_upload(stage, project, version, link): debug("writing xml file: %s" % xml_file.strpath) rss.write_xml(open(xml_file.strpath, "w"), encoding="utf-8") - with open(pickle_file.strpath, "w") as f: + with open(pickle_file.strpath, "wb") as f: debug("writing pickle file: %s" % pickle_file.strpath) s = StringIO() pickle.dump(rss, s)