This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: In FancyURLopener error in example with http address.
Type: Stage: resolved
Components: Documentation Versions: Python 3.6, Python 3.5, Python 2.7
process
Status: closed Resolution: works for me
Dependencies: Superseder:
Assigned To: docs@python Nosy List: Denis Savenko, docs@python, martin.panter
Priority: normal Keywords:

Created on 2015-12-11 15:42 by Denis Savenko, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Messages (2)
msg256221 - (view) Author: Denis Savenko (Denis Savenko) Date: 2015-12-11 15:42
In documentation from this page https://docs.python.org/3.5/library/urllib.request.html#examples in examples uses default address to python site with http. ( http://python.org/ ). But now python.org use https. When i try use example in ipython i get I/0 error, but error is very simple - http change by https. I found this error on many pages, where use http://python.org/ address, but on FancyURLopener example compiller error very difficult for understanding.
msg256253 - (view) Author: Martin Panter (martin.panter) * (Python committer) Date: 2015-12-12 03:21
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.
History
Date User Action Args
2022-04-11 14:58:24adminsetgithub: 70028
2017-03-07 19:03:00serhiy.storchakasetstatus: pending -> closed
stage: needs patch -> resolved
2016-05-14 11:14:55martin.pantersetstatus: open -> pending
resolution: works for me
2015-12-12 03:21:58martin.pantersetnosy: + martin.panter
messages: + msg256253
2015-12-11 15:47:56r.david.murraysetstage: needs patch
versions: + Python 2.7, - Python 3.3, Python 3.4
2015-12-11 15:42:25Denis Savenkocreate