[docs] [issue25841] In FancyURLopener error in example with http address.

Martin Panter report at bugs.python.org
Fri Dec 11 22:21:58 EST 2015


Martin Panter added the comment:

Assuming you meant http://www.python.org/ (added the www), I cannot produce any error with any example that requests directly to the site. The “http:” server already redirects to “https:”, so there is no problem. Obviously the examples that depend on made-up servers like proxy.example.com are going to fail.

In particular, the second FancyURLopener example works for me. Modified slightly to avoid copious output:

$ python3.5 -bWall
Python 3.5.0 (default, Sep 20 2015, 11:28:25) 
[GCC 5.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import urllib.request
>>> opener = urllib.request.FancyURLopener({})
__main__:1: DeprecationWarning: FancyURLopener style of invoking requests is deprecated. Use newer urlopen functions/methods
>>> with opener.open("http://www.python.org/") as f:
...     response = f.read().decode('utf-8')
... 
>>> response[:100]
'<!doctype html>\n<!--[if lt IE 7]>   <html class="no-js ie6 lt-ie7 lt-ie8 lt-ie9">   <![endif]-->\n<!-'

Please try this in the plain Python interpreter rather than I-Python, or be more specific about what you are trying to do and what the result is.

BTW I dunno what the FancyUrlopener example is doing there. In the Python 3 documentation, FancyURLopener is not introduced until the “Legacy interface” section later on. Perhaps the example should be moved.

----------
nosy: +martin.panter

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue25841>
_______________________________________


More information about the docs mailing list