diff options
Diffstat (limited to 'subcmds/sync.py')
-rw-r--r-- | subcmds/sync.py | 29 |
1 files changed, 16 insertions, 13 deletions
diff --git a/subcmds/sync.py b/subcmds/sync.py index 6191a3c3..ad0ecdf4 100644 --- a/subcmds/sync.py +++ b/subcmds/sync.py | |||
@@ -905,19 +905,22 @@ class PersistentTransport(xmlrpc.client.Transport): | |||
905 | # Python doesn't understand cookies with the #HttpOnly_ prefix | 905 | # Python doesn't understand cookies with the #HttpOnly_ prefix |
906 | # Since we're only using them for HTTP, copy the file temporarily, | 906 | # Since we're only using them for HTTP, copy the file temporarily, |
907 | # stripping those prefixes away. | 907 | # stripping those prefixes away. |
908 | tmpcookiefile = tempfile.NamedTemporaryFile() | 908 | if cookiefile: |
909 | try: | 909 | tmpcookiefile = tempfile.NamedTemporaryFile() |
910 | with open(cookiefile) as f: | 910 | try: |
911 | for line in f: | 911 | with open(cookiefile) as f: |
912 | if line.startswith("#HttpOnly_"): | 912 | for line in f: |
913 | line = line[len("#HttpOnly_"):] | 913 | if line.startswith("#HttpOnly_"): |
914 | tmpcookiefile.write(line) | 914 | line = line[len("#HttpOnly_"):] |
915 | tmpcookiefile.flush() | 915 | tmpcookiefile.write(line) |
916 | 916 | tmpcookiefile.flush() | |
917 | cookiejar = cookielib.MozillaCookieJar(tmpcookiefile.name) | 917 | |
918 | cookiejar.load() | 918 | cookiejar = cookielib.MozillaCookieJar(tmpcookiefile.name) |
919 | finally: | 919 | cookiejar.load() |
920 | tmpcookiefile.close() | 920 | finally: |
921 | tmpcookiefile.close() | ||
922 | else: | ||
923 | cookiejar = cookielib.CookieJar() | ||
921 | 924 | ||
922 | proxyhandler = urllib.request.ProxyHandler | 925 | proxyhandler = urllib.request.ProxyHandler |
923 | if proxy: | 926 | if proxy: |