0

I'm using python 3.2.2. If I try to do:

urllib.request.urlopen('https://pypi.python.org/simple/babel')

I get following error message:

  Traceback (most recent call last):
    File "solver.py", line 93, in <module>
      generateMetadata('babel')
    File "solver.py", line 76, in generateMetadata
      linklist = parseURL(name)
    File "solver.py", line 20, in parseURL
      resp = opener.open(REP_URL+name+'/')
    File "/usr/lib/python3.2/urllib/request.py", line 375, in open
      response = meth(req, response)
    File "/usr/lib/python3.2/urllib/request.py", line 487, in http_response
      'http', request, response, code, msg, hdrs)
    File "/usr/lib/python3.2/urllib/request.py", line 407, in error
      result = self._call_chain(*args)
    File "/usr/lib/python3.2/urllib/request.py", line 347, in _call_chain
      result = func(*args)
    File "/usr/lib/python3.2/urllib/request.py", line 560, in http_error_302
      headers, fp)
  urllib.error.HTTPError: HTTP Error 301: Moved Permanently - Redirection to url '/simple/Babel' is not allowed

After searching I found that it should handle redirects automatically.

7
  • 1
    I cannot reproduce this with Python 3.2.3. Commented Mar 19, 2013 at 13:57
  • 1
    Just before that exception is the line if urlparts.scheme not in ('http', 'https', 'ftp', ''):. Your URL must be dodgy, check that it uses the correct scheme. Commented Mar 19, 2013 at 14:04
  • I tested the same line with python 3.2.3 and 3.3 and both worked. It can't be that i hit the one bug, that exists in only my subversion, can it? Commented Mar 19, 2013 at 14:12
  • What URL are you passing in when you get this error? Look at repr(url) to make sure you catch any special characters. Commented Mar 19, 2013 at 14:14
  • Hrm, looking at the source code again I suspect that the response was corrupted instead. Commented Mar 19, 2013 at 14:23

1 Answer 1

2

So it seems, there is a bug in the Python Versions 3.2.0 to 3.2.2.

If you know the user of your program are gonna use this version, you can try monkey patching. (Overwriting the Module with the patched one from 3.2.3 if they're using one of the faulted versions)

Theres the corresponding Bug report: http://bugs.python.org/issue13696

Sign up to request clarification or add additional context in comments.

1 Comment

You may want to include a link to the bug report I gave you.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.