the content is in a loop because it is getting redirected again and again <div><br></div><div>and the interrupt exception is perfectly ok when you press ctrl +c <br><br><div class="gmail_quote">On Tue, Oct 19, 2010 at 10:17 PM, Johannes Bauer <span dir="ltr"><<a href="mailto:dfnsonfsduifb@gmx.de">dfnsonfsduifb@gmx.de</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">Hi,<br>
<br>
I've experienced the following behavior with Python3 of which I do not<br>
know if it's a bug or not. On two Python3.1 implementations, Python's<br>
urllib hangs when encountering a HTTP 301 (Redirect).<br>
<br>
The code to reproduce is a one-liner (actually, two-liner), Python from<br>
Ubuntu tree:<br>
<br>
Python 3.1.2 (r312:79147, Apr 15 2010, 15:35:48)<br>
[GCC 4.4.3] on linux2<br>
Type "help", "copyright", "credits" or "license" for more information.<br>
>>> from urllib import request; request.URLopener().open("<a href="http://google.de" target="_blank">http://google.de</a>")<br>
<br>
Also occurs on another Python version (Gentoo):<br>
<br>
Python 3.1.2 (release31-maint, Jun  9 2010, 23:58:21)<br>
[GCC 4.3.4] on linux2<br>
<br>
The exchanged HTTP is:<br>
<br>
GET <a href="http://google.de" target="_blank">http://google.de</a> HTTP/1.1<br>
Accept-Encoding: identity<br>
Host: <a href="http://google.de" target="_blank">google.de</a><br>
User-Agent: Python-urllib/3.1<br>
<br>
HTTP/1.1 301 Moved Permanently<br>
Via: 1.1 IMMPWISA01<br>
Connection: Keep-Alive<br>
Proxy-Connection: Keep-Alive<br>
Content-Length: 218<br>
Expires: Thu, 18 Nov 2010 15:18:40 GMT<br>
Date: Tue, 19 Oct 2010 15:18:40 GMT<br>
Location: <a href="http://www.google.de/" target="_blank">http://www.google.de/</a><br>
Content-Type: text/html; charset=UTF-8<br>
Server: gws<br>
Cache-Control: public, max-age=2592000<br>
X-XSS-Protection: 1; mode=block<br>
<br>
<HTML><HEAD><meta http-equiv="content-type"<br>
content="text/html;charset=utf-8"><br>
<TITLE>301 Moved</TITLE></HEAD><BODY><br>
<H1>301 Moved</H1><br>
The document has moved<br>
<A HREF="<a href="http://www.google.de/" target="_blank">http://www.google.de/</a>">here</A>.<br>
</BODY></HTML><br>
<br>
Although the content might indicate looping forever, it just hangs with<br>
no web traffic whatsoever (the TCP connection stays open, however).<br>
<br>
When interrupting with Ctrl-C, this is the calltrace:<br>
<br>
Traceback (most recent call last):<br>
  File "<stdin>", line 1, in <module><br>
  File "/usr/lib/python3.1/urllib/request.py", line 1454, in open<br>
    return getattr(self, name)(url)<br>
  File "/usr/lib/python3.1/urllib/request.py", line 1628, in open_http<br>
    return self._open_generic_http(http.client.HTTPConnection, url, data)<br>
  File "/usr/lib/python3.1/urllib/request.py", line 1624, in<br>
_open_generic_http<br>
    response.status, response.reason, response.msg, data)<br>
  File "/usr/lib/python3.1/urllib/request.py", line 1644, in http_error<br>
    return self.http_error_default(url, fp, errcode, errmsg, headers)<br>
  File "/usr/lib/python3.1/urllib/request.py", line 1648, in<br>
http_error_default<br>
    void = fp.read()<br>
  File "/usr/lib/python3.1/socket.py", line 214, in readinto<br>
    return self._sock.recv_into(b)<br>
KeyboardInterrupt<br>
<br>
Can anyone tell me if this is a bug or expected behavior?<br>
<br>
Regards,<br>
Johannes<br>
<br>
--<br>
>> Wo hattest Du das Beben nochmal GENAU vorhergesagt?<br>
> Zumindest nicht öffentlich!<br>
Ah, der neueste und bis heute genialste Streich unsere großen<br>
Kosmologen: Die Geheim-Vorhersage.<br>
 - Karl Kaos über Rüdiger Thomas in dsa <hidbv3$om2$<a href="mailto:1@speranza.aioe.org">1@speranza.aioe.org</a>><br>
<font color="#888888">--<br>
<a href="http://mail.python.org/mailman/listinfo/python-list" target="_blank">http://mail.python.org/mailman/listinfo/python-list</a><br>
</font></blockquote></div><br><br clear="all"><br>-- <br>Nitin Pawar<br><br>
</div>