[issue42062] Usage of HTTPResponse.url

2020-10-17 Thread Martin Panter


Martin Panter  added the comment:

There is a comment in the HTTPResponse class regarding these methods:

# For compatibility with old-style urllib responses.

They were there for the "urlopen" API in "urllib.request", not for the 
"http.client" module on its own. I expect the "url" attribute is set by the 
"urlopen" code.

However more recently (Issue 12707) the "url" attribute and "geturl" method 
were documented in the HTTPResponse documentation, which is awkward.

--
nosy: +martin.panter

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue42062] Usage of HTTPResponse.url

2020-10-17 Thread Felipe Rodrigues


Change by Felipe Rodrigues :


--
keywords: +patch
pull_requests: +21701
stage:  -> patch review
pull_request: https://github.com/python/cpython/pull/22738

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue42062] Usage of HTTPResponse.url

2020-10-17 Thread Felipe Rodrigues


New submission from Felipe Rodrigues :

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

--
components: Library (Lib)
messages: 378814
nosy: fbidu
priority: normal
severity: normal
status: open
title: Usage of HTTPResponse.url

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com