This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author matrixise
Recipients docs@python, matrixise, sylye
Date 2019-02-21.10:53:34
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1550746414.75.0.284228790522.issue36064@roundup.psfhosted.org>
In-reply-to
Content
Hi Lye,

I am not sure it's a bug because I don't have any problem with your script.

Here is your script.

import urllib
import urllib.request

my_url = "https://api.foo.com"
my_headers = { "Content-Type" : "application/x-www-form-urlencoded" }
my_data = {
        "client_id" : "ppp",
        "client_secret" : "000",
        "grant_type" : "client_credentials" }

req = urllib.request.Request(url=my_url, data=my_data, headers=my_headers)
response = urllib.request.urlopen(req)
html = response.read()
print(html)

and here is the result with the version 3.6 of Python:

> docker run --rm -v $PWD:/src -it python:3.6 python /src/demo.py
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/urllib/request.py", line 1318, in do_open
    encode_chunked=req.has_header('Transfer-encoding'))
  ...
  File "/usr/local/lib/python3.6/socket.py", line 713, in create_connection
    sock.connect(sa)
ConnectionRefusedError: [Errno 111] Connection refused

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/src/demo.py", line 12, in <module>
    response = urllib.request.urlopen(req)
  ...
  File "/usr/local/lib/python3.6/urllib/request.py", line 1320, in do_open
    raise URLError(err)
urllib.error.URLError: <urlopen error [Errno 111] Connection refused>

I don't get your error. 

and the version of this docker image is 3.6.8

> docker run --rm -v $PWD:/src -it python:3.6 python --version
Python 3.6.8
History
Date User Action Args
2019-02-21 10:53:34matrixisesetrecipients: + matrixise, docs@python, sylye
2019-02-21 10:53:34matrixisesetmessageid: <1550746414.75.0.284228790522.issue36064@roundup.psfhosted.org>
2019-02-21 10:53:34matrixiselinkissue36064 messages
2019-02-21 10:53:34matrixisecreate