Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VCRConnection does not support Python 3.6 - 'encode_chunked' #293

Closed
derekbekoe opened this issue Jan 23, 2017 · 0 comments
Closed

VCRConnection does not support Python 3.6 - 'encode_chunked' #293

derekbekoe opened this issue Jan 23, 2017 · 0 comments

Comments

@derekbekoe
Copy link
Contributor

In Python 3.6 http.client.HTTPConnection.request, a new keyword argument of encode_chunked was added. Currently, it doesn't look like VCR does not support this change so you get a stacktrace.
https://docs.python.org/3.6/library/http.client.html#http.client.HTTPConnection.request

When VCR patches HTTPConnection with vcr.patch.VCRHTTPSConnection, it does not accept this new keyword argument and so you see the following stacktrace for example:

  File "/usr/local/lib/python3.6/urllib/request.py", line 223, in urlopen
    return opener.open(url, data, timeout)
  File "/usr/local/lib/python3.6/urllib/request.py", line 526, in open
    response = self._open(req, data)
  File "/usr/local/lib/python3.6/urllib/request.py", line 544, in _open
    '_open', req)
  File "/usr/local/lib/python3.6/urllib/request.py", line 504, in _call_chain
    result = func(*args)
  File "/usr/local/lib/python3.6/urllib/request.py", line 1361, in https_open
    context=self._context, check_hostname=self._check_hostname)
  File "/usr/local/lib/python3.6/urllib/request.py", line 1318, in do_open
    encode_chunked=req.has_header('Transfer-encoding'))
TypeError: request() got an unexpected keyword argument 'encode_chunked'

Similar to: boto/botocore#1079 where the solution was in PR boto/botocore#1107 (accept the kwargs but don't use them).


More info:

In the do_open method of /usr/local/lib/python3.6/urllib/request.py, a http_class class is expected. VCR passes in the class vcr.patch.VCRHTTPSConnection (an instance of VCRConnection) for this.

In do_open, Python calls http_class(...).request(..., encode_chunked). Since VCR uses VCRHTTPSConnection here, VCRHTTPSConnection.request(). This method (https://github.com/kevin1024/vcrpy/blob/master/vcr/stubs/__init__.py#L156) does not accept the encode_chunked keyword and so we get TypeError: request() got an unexpected keyword argument 'encode_chunked'.

derekbekoe added a commit to derekbekoe/vcrpy that referenced this issue Jan 23, 2017
derekbekoe added a commit to derekbekoe/azure-cli that referenced this issue Jan 23, 2017
- Do not run pylint on 3.6 as pylint doesn’t support 3.6 yet
- Add Python 3.6 to package classifiers
derekbekoe added a commit to Azure/azure-cli that referenced this issue Jan 24, 2017
* Add Python 3.6 to CI

* Workaround for kevin1024/vcrpy#293
- Do not run pylint on 3.6 as pylint doesn’t support 3.6 yet
- Add Python 3.6 to package classifiers
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant