Karthikeyan Singaravelan <tir.kar...@gmail.com> added the comment:

This issue is still reproducible on master and below is a unittest. The patch 
looks reasonable to me and fixes the issue. @demian.brecht, would you like to 
convert the patch to a PR ?

diff --git a/Lib/test/test_http_cookiejar.py b/Lib/test/test_http_cookiejar.py
index 22bf41cf1d..3540a3d94f 100644
--- a/Lib/test/test_http_cookiejar.py
+++ b/Lib/test/test_http_cookiejar.py
@@ -585,6 +585,13 @@ class CookieTests(unittest.TestCase):
         # if expires is in future, keep cookie...
         c = CookieJar()
         future = time2netscape(time.time()+3600)
+
+        headers = ["Set-Cookie: CUSTOMER=WILE_E_COYOTE; path=/; 
expires={0}".format(future)]
+        req = urllib.request.Request("http://www.coyote.com/";)
+        res = FakeResponse(headers, "http://www.coyote.com/";)
+        cookies = c.make_cookies(res, req)
+
+        c = CookieJar()
         interact_netscape(c, "http://www.acme.com/";, 'spam="bar"; expires=%s' %
                           future)
         self.assertEqual(len(c), 1)

$ ./python.exe -m unittest -v test.test_http_cookiejar.CookieTests.test_expires
test_expires (test.test_http_cookiejar.CookieTests) ... 
/Users/karthikeyansingaravelan/stuff/python/cpython/Lib/http/cookiejar.py:1619: 
UserWarning: http.cookiejar bug!
Traceback (most recent call last):
  File 
"/Users/karthikeyansingaravelan/stuff/python/cpython/Lib/http/cookiejar.py", 
line 1616, in make_cookies
    ns_cookies = self._cookies_from_attrs_set(
  File 
"/Users/karthikeyansingaravelan/stuff/python/cpython/Lib/http/cookiejar.py", 
line 1574, in _cookies_from_attrs_set
    cookie = self._cookie_from_cookie_tuple(tup, request)
  File 
"/Users/karthikeyansingaravelan/stuff/python/cpython/Lib/http/cookiejar.py", 
line 1546, in _cookie_from_cookie_tuple
    elif expires <= self._now:
AttributeError: 'CookieJar' object has no attribute '_now'

  _warn_unhandled_exception()
ok

----------------------------------------------------------------------
Ran 1 test in 0.043s

OK

----------
nosy: +xtreak
versions: +Python 3.7, Python 3.8 -Python 3.4, Python 3.5

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue12144>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to