alexa / alexa-skills-kit-sdk-for-python

The Alexa Skills Kit SDK for Python helps you get a skill up and running quickly, letting you focus on skill logic instead of boilerplate code.
https://developer.amazon.com/en-US/docs/alexa/alexa-skills-kit-sdk-for-python/overview.html
Apache License 2.0
812 stars 206 forks source link

"with urlopen(cert_url) as cert_response" does not work in Python 2.7 #122

Closed pawelmat closed 5 years ago

pawelmat commented 5 years ago

I'm submitting a...


[ ] Regression (a behavior that used to work and stopped working in a new release)
[X] Bug report  
[ ] Performance issue
[ ] Feature request
[ ] Documentation issue or request
[ ] Other... Please describe:

In ask-sdk-webservice-support, in verifier.py, in _load_cert_chain(), there is the following line: "with urlopen(cert_url) as cert_response:".

Expected Behavior

urlopen() should read the document from the provided URL into cert_response

Current Behavior

This does not work in Python 2.7 and causes an "AttributeError:addinfourl instance has no attribute 'exit'" exception. This is because you can't use any random object in a with ... as statement and there isn't any context manager implemented for urlopen (unlike in Python3 where there is one)

Possible Solution

// Not required, but suggest a fix/reason for the bug,
// or ideas how to implement the addition or change

The line in question should therefore be replaced by e.g. "cert_response = urlopen(cert_url)" and the following section should have the indent changed accordingly.

Steps to Reproduce (for bugs)

// Provide a self-contained, concise snippet of code
// For more complex issues provide a repo with the smallest sample that reproduces the bug
// Including business logic or unrelated code makes diagnosis more difficult

Just run on Python 2.7

Context

The crash does not allow to use ask-sdk-webservice-support out of the box

Your Environment

Python version info