Author fbidu
Recipients fbidu
Date 2020-10-17.14:13:56
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1602944036.34.0.151561478116.issue42062@roundup.psfhosted.org>
In-reply-to
Content
Hello all,

While testing some static analysis tools on HTTP/client.py, Pylint pointed
me to HTTPResponse.geturl() method with a "no-member" error for the `url`
attribute. I tried invoking the `geturl` method and reading the
`HTTPResponse.url` attribute using a sample code from the official docs:

```
import http.client
conn = http.client.HTTPSConnection("www.python.org")
conn.request("GET", "/")
r1 = conn.getresponse()
print(r1.status, r1.reason)

r1.geturl()
r1.url
```
```
import http.client
conn = http.client.HTTPSConnection("www.python.org")
conn.request("GET", "/")
r1 = conn.getresponse()
data1 = r1.read()

conn.request("GET", "/")
r1 = conn.getresponse()
while chunk := r1.read(200):
    print(repr(chunk))
r1.geturl()
r1.url
```

Both of those examples will raise an `AttributeError: 'HTTPResponse' object has no attribute 'url'`.

I tried searching through this module's history from when this line originally appeared,
https://github.com/python/cpython/commit/6c5e28c383bf587f80d01e52f887801be200200d but
I wasn't able to find this attribute being set internally by the class, even
though there is an `url` attribute at __init__.

So, I wonder if this attribute was intended to be set externally as in `r1.url = 'something'`
or if it is just a bug
History
Date User Action Args
2020-10-17 14:13:56fbidusetrecipients: + fbidu
2020-10-17 14:13:56fbidusetmessageid: <1602944036.34.0.151561478116.issue42062@roundup.psfhosted.org>
2020-10-17 14:13:56fbidulinkissue42062 messages
2020-10-17 14:13:56fbiducreate