Python3: Is this a bug in urllib?

Johannes Bauer dfnsonfsduifb at gmx.de
Thu Oct 21 12:05:57 EDT 2010


Am 20.10.2010 14:32, schrieb Justin Ezequiel:
> On Oct 20, 12:47 am, Johannes Bauer <dfnsonfsdu... at gmx.de> wrote:
>>
>>>>> from urllib import request; request.URLopener().open("http://google.de")
>
> aren't you supposed to call read on the return value of open?
> i.e.,
> request.URLopener().open("http://google.de").read()

If open blocks, a appended "read()" will never be executed. In order to
demonstrate the problem, I reduced the call to the least amount of code
needed to trigger it. Had I appended read(), it would not have been
clear if the read() actually hangs or the open(). The way I posted it,
it is clear.

Regards,
Johannes

-- 
>> Wo hattest Du das Beben nochmal GENAU vorhergesagt?
> Zumindest nicht öffentlich!
Ah, der neueste und bis heute genialste Streich unsere großen
Kosmologen: Die Geheim-Vorhersage.
 - Karl Kaos über Rüdiger Thomas in dsa <hidbv3$om2$1 at speranza.aioe.org>



More information about the Python-list mailing list