Skip to content

Commit 6d1bfe8

Browse files
committed
base: Change default cookie format back to Mozilla
We switched to LWP a long time ago to facilitate NovellBugzilla. However I'm pretty sure that code doesn't work anymore, and a future change is going to require us to carry cookies around in Mozilla format.
1 parent 1a107b3 commit 6d1bfe8

2 files changed

Lines changed: 13 additions & 14 deletions

File tree

bugzilla/base.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ def _decode_rfc2231_value(val):
6363

6464

6565
def _build_cookiejar(cookiefile):
66-
cj = cookielib.LWPCookieJar(cookiefile)
66+
cj = cookielib.MozillaCookieJar(cookiefile)
6767
if cookiefile is None:
6868
return cj
6969
if not os.path.exists(cookiefile):
@@ -73,22 +73,22 @@ def _build_cookiejar(cookiefile):
7373
cj.save()
7474
return cj
7575

76-
# We always want to use LWP cookies, but we previously accepted
77-
# Mozilla cookies. If we see Mozilla, convert it to LWP
76+
# We always want to use Mozilla cookies, but we previously accepted
77+
# LWP cookies. If we see the latter, convert it to former
7878
try:
7979
cj.load()
8080
return cj
8181
except cookielib.LoadError:
8282
pass
8383

8484
try:
85-
cj = cookielib.MozillaCookieJar(cookiefile)
85+
cj = cookielib.LWPCookieJar(cookiefile)
8686
cj.load()
8787
except cookielib.LoadError:
8888
raise BugzillaError("cookiefile=%s not in LWP or Mozilla format" %
8989
cookiefile)
9090

91-
retcj = cookielib.LWPCookieJar(cookiefile)
91+
retcj = cookielib.MozillaCookieJar(cookiefile)
9292
for cookie in cj:
9393
retcj.set_cookie(cookie)
9494
retcj.save()

tests/misc.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -68,18 +68,17 @@ def testCookies(self):
6868
cookiesbad = os.path.join(os.getcwd(), "tests/data/cookies-bad.txt")
6969
cookieslwp = os.path.join(os.getcwd(), "tests/data/cookies-lwp.txt")
7070
cookiesmoz = os.path.join(os.getcwd(), "tests/data/cookies-moz.txt")
71-
cookiesnewmoz = os.path.join(os.getcwd(),
72-
"tests/data/cookies-moz.txt.new")
71+
cookiesnew = cookieslwp + ".new"
7372

7473
def cleanup():
75-
if os.path.exists(cookiesnewmoz):
76-
os.unlink(cookiesnewmoz)
74+
if os.path.exists(cookiesnew):
75+
os.unlink(cookiesnew)
7776
atexit.register(cleanup)
78-
shutil.copy(cookiesmoz, cookiesnewmoz)
77+
shutil.copy(cookieslwp, cookiesnew)
7978

8079
# Mozilla should be converted inplace to LWP
81-
bugzilla.Bugzilla3(url=None, cookiefile=cookiesnewmoz)
82-
self.assertEquals(file(cookieslwp).read(), file(cookiesnewmoz).read())
80+
bugzilla.Bugzilla3(url=None, cookiefile=cookiesnew)
81+
self.assertEquals(file(cookiesmoz).read(), file(cookiesnew).read())
8382

8483
# Make sure bad cookies raise an error
8584
try:
@@ -90,8 +89,8 @@ def cleanup():
9089
# Expected result
9190
pass
9291

93-
# LWP should 'just work'
94-
bugzilla.Bugzilla3(url=None, cookiefile=cookieslwp)
92+
# Mozilla should 'just work'
93+
bugzilla.Bugzilla3(url=None, cookiefile=cookiesmoz)
9594

9695
def testPostTranslation(self):
9796
def _testPostCompare(bz, indict, outexpect):

0 commit comments

Comments
 (0)