Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions Lib/http/cookiejar.py
Original file line number Diff line number Diff line change
Expand Up @@ -1798,7 +1798,9 @@ def load(self, filename=None, ignore_discard=False, ignore_expires=False):
if self.filename is not None: filename = self.filename
else: raise ValueError(MISSING_FILENAME_TEXT)

with open(filename) as f:
# We use latin-1 here because WSGI uses latin-1 for HTTP headers too.
# See gh-87888 for more info.
with open(filename, encoding="latin1") as f:
self._really_load(f, filename, ignore_discard, ignore_expires)

def revert(self, filename=None,
Expand Down Expand Up @@ -1890,7 +1892,7 @@ def save(self, filename=None, ignore_discard=False, ignore_expires=False):
if self.filename is not None: filename = self.filename
else: raise ValueError(MISSING_FILENAME_TEXT)

with open(filename, "w") as f:
with open(filename, "w", encoding="latin1") as f:
# There really isn't an LWP Cookies 2.0 format, but this indicates
# that there is extra information in here (domain_dot and
# port_spec) while still being compatible with libwww-perl, I hope.
Expand Down Expand Up @@ -2086,7 +2088,7 @@ def save(self, filename=None, ignore_discard=False, ignore_expires=False):
if self.filename is not None: filename = self.filename
else: raise ValueError(MISSING_FILENAME_TEXT)

with open(filename, "w") as f:
with open(filename, "w", encoding="latin1") as f:
f.write(NETSCAPE_HEADER_TEXT)
now = time.time()
for cookie in self:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Changed encoding used by :class:`http.cookiejar.FileCookieJar` and its
subclasses from locale encoding to "latin-1".