[pypy-dev] Question about cookielib in PyPy

Jeff Doran jdoran at lexmachina.com
Fri May 27 17:45:57 EDT 2016


I'm working on an ongoing task to test our existing code on PyPy.   My
latest exploration was is using PyPy 5.1 along with lxml 3.6.0 and of
partuclar relevance to my question, requests 2.9.1 and betamax 0.7.0

Our test suite completes without incident on Python 2.7.9, but on PyPy
5.1.0 we encounter errors trying to match an http request to a recorded
session in betamax. This process fails when trying to match a request
against the correct recorded session due to a failure in the header
comparison when we include a cookie string.   This is a comparison of 2
dicts and the contents are the same, except for the Cookie string.   We
created the Cookie using cookielib.Cookie and add the various items via the
Cookie.__init__() method.   The resulting strings comes from Cookie.__str__
I believe and the comparison in requests is a simple dict1 == dict2.

Any thoughts on where this difference might lie (dictionary comparison
issues,  string comparison issues, or ...)? I'd like to avoid having to
have a different set of tests for PyPy vs CPython as that defeats the idea
of verifying compatibility.

Thanks for any input.

- Jeff Doran


This comes from cookielib.Cookie under PyPY.

request.headers: %s {
'User-Agent': 'python-requests/2.9.1',
'Accept-Encoding': 'gzip,
deflate', 'Accept': '*/*',
'Connection': 'keep-alive',
'Cookie':
'NextGenCSO=8MWACYK5f24yllbpMwVpocfsyGYIBUXl4aWQvo7nUcWz2OwU7p4Dy40bxiyjGS5es8hBv5LxPT8PqBnWNzaBNo0k0PGffpQTDI4xBGc9WwQevnzyUCmq7WaXMTOTSpKM;
PacerClientCode=dev;
PacerSession=8MWACYK5f24yllbpMwVpocfsyGYIBUXl4aWQvo7nUcWz2OwU7p4Dy40bxiyjGS5es8hBv5LxPT8PqBnWNzaBNo0k0PGffpQTDI4xBGc9WwQevnzyUCmq7WaXMTOTSpKM;
domain=.uscourts.gov; path=/; PacerPref="receipt=Y"'
}

This was recorded previously using Python 2.7.9

recorded headers: %s {
u'Connection': u'keep-alive',
u'Cookie': u'PacerClientCode=dev; path=/;
NextGenCSO=8MWACYK5f24yllbpMwVpocfsyGYIBUXl4aWQvo7nUcWz2OwU7p4Dy40bxiyjGS5es8hBv5LxPT8PqBnWNzaBNo0k0PGffpQTDI4xBGc9WwQevnzyUCmq7WaXMTOTSpKM;
domain=.uscourts.gov;
PacerSession=8MWACYK5f24yllbpMwVpocfsyGYIBUXl4aWQvo7nUcWz2OwU7p4Dy40bxiyjGS5es8hBv5LxPT8PqBnWNzaBNo0k0PGffpQTDI4xBGc9WwQevnzyUCmq7WaXMTOTSpKM;
PacerPref="receipt=Y"',
u'Accept-Encoding': u'gzip,
deflate', u'Accept': u'*/*',
u'User-Agent': u'python-requests/2.9.1'
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/pypy-dev/attachments/20160527/61044519/attachment.html>


More information about the pypy-dev mailing list