New submission from Felipe Rodrigues <fel...@felipevr.com>:
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 <rep...@bugs.python.org> <https://bugs.python.org/issue42062> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com