Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

urllib2.py: HTTPResponse instance has no attribute 'code' #48500

Closed
jbperez mannequin opened this issue Nov 2, 2008 · 2 comments
Closed

urllib2.py: HTTPResponse instance has no attribute 'code' #48500

jbperez mannequin opened this issue Nov 2, 2008 · 2 comments
Labels
stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error

Comments

@jbperez
Copy link
Mannequin

jbperez mannequin commented Nov 2, 2008

BPO 4250
Nosy @terryjreedy

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = None
closed_at = <Date 2008-11-08.17:28:12.356>
created_at = <Date 2008-11-02.14:57:16.545>
labels = ['type-bug', 'library']
title = "urllib2.py: HTTPResponse instance has no attribute 'code'"
updated_at = <Date 2008-11-08.17:28:12.356>
user = 'https://bugs.python.org/jbperez'

bugs.python.org fields:

activity = <Date 2008-11-08.17:28:12.356>
actor = 'benjamin.peterson'
assignee = 'none'
closed = True
closed_date = <Date 2008-11-08.17:28:12.356>
closer = 'benjamin.peterson'
components = ['Library (Lib)']
creation = <Date 2008-11-02.14:57:16.545>
creator = 'jbperez'
dependencies = []
files = []
hgrepos = []
issue_num = 4250
keywords = []
message_count = 2.0
messages = ['75455', '75616']
nosy_count = 2.0
nosy_names = ['terry.reedy', 'jbperez']
pr_nums = []
priority = 'normal'
resolution = 'duplicate'
stage = None
status = 'closed'
superseder = None
type = 'behavior'
url = 'https://bugs.python.org/issue4250'
versions = ['Python 2.5', 'Python 2.4']

@jbperez
Copy link
Mannequin Author

jbperez mannequin commented Nov 2, 2008

In http_response() in HTTPErrorProcessor in urllib2.py, the following line

code, msg, hdrs = response.code, response.msg, response.info()

results in an error because response.code is not a valid
attribute, changing it to response.status works, but is
this the correct bug fix?

See
http://www.linuxquestions.org/questions/linux-newbie-8/problem-with-yum-fedora-9-670586/

Traceback (most recent call last):
File "/usr/bin/yum", line 30, in <module>
yummain.main(sys.argv[1:])
File "/usr/share/yum/yummain.py", line 233, in main
clientStuff.get_package_info_from_servers(serverlist, HeaderInfo)
File "/usr/share/yum/clientStuff.py", line 846, in
get_package_info_from_servers
progress_obj=None)
File "/usr/share/yum/clientStuff.py", line 1327, in grab
bandwidth, conf.retries, retrycodes, checkfunc)
File "/usr/share/yum/urlgrabber.py", line 237, in retrygrab
progress_obj, throttle, bandwidth)
File "/usr/share/yum/urlgrabber.py", line 314, in urlgrab
fo = urllib2.urlopen(url)
File "/usr/lib/python2.5/urllib2.py", line 121, in urlopen
return _opener.open(url, data)
File "/usr/lib/python2.5/urllib2.py", line 380, in open
response = meth(req, response)
File "/usr/lib/python2.5/urllib2.py", line 487, in http_response
code, msg, hdrs = response.code, response.msg, response.info()
AttributeError: HTTPResponse instance has no attribute 'code'

@jbperez jbperez mannequin added stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error labels Nov 2, 2008
@terryjreedy
Copy link
Member

This appears to be a duplicate of bpo-1507166, with essentially the same
title. I found it by searching all issues for "response.code
HTTPResponse". That was closed because "The problem came from an
external module (urlgrabber) which aparently was not up to date."

@ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

2 participants