Skip to content

gh-141444:fix broken URLs and examples in urllib.request.rst#144863

Open
tangyuan0821 wants to merge 2 commits intopython:mainfrom
tangyuan0821:141444
Open

gh-141444:fix broken URLs and examples in urllib.request.rst#144863
tangyuan0821 wants to merge 2 commits intopython:mainfrom
tangyuan0821:141444

Conversation

@tangyuan0821
Copy link
Contributor

@tangyuan0821 tangyuan0821 commented Feb 16, 2026

Summary

  • Replace dead/unreliable URLs: musi‑cal.comhttps://www.python.org, requestb.inhttps://httpbin.org/post
  • Fix doc issues: ProxyHandler({}}) ProxyHandler({}), correct urlretrieve indentation
  • Switch applicable examples to HTTPS — docs-only change in urllib.request.rst

📚 Documentation preview 📚: https://cpython-previews--144863.org.readthedocs.build/en/144863/library/urllib.request.html

@python-cla-bot
Copy link

python-cla-bot bot commented Feb 16, 2026

All commit authors signed the Contributor License Agreement.

CLA signed

>>> with urllib.request.urlopen('https://www.python.org/') as f:
... print(f.read(300))
...
b'<!doctype html>\n<!--[if lt IE 7]> <html class="no-js ie6 lt-ie7 lt-ie8 lt-ie9"> <![endif]-->\n<!--[if IE 7]> <html class="no-js ie7 lt-ie8 lt-ie9"> <![endif]-->\n<!--[if IE 8]> <html class="no-js ie8 lt-ie9">
Copy link
Member

@StanFromIreland StanFromIreland Feb 18, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This example doesn’t work like this any more, the content gzip compressed:

... with urllib.request.urlopen("https://www.python.org/") as f:
...     print(f.headers["Content-Encoding"])
... 
gzip

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, I'll update it right away.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This example doesn’t work like this any more, the content gzip compressed:

... with urllib.request.urlopen("https://www.python.org/") as f:
...     print(f.headers["Content-Encoding"])
... 
gzip

I have made the revisions. Could you please confirm if this is what you wanted?

>>> with urllib.request.urlopen('https://www.python.org/') as f:
... print(f.read(100).decode('utf-8'))
...
<!doctype html>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similarly for this one.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting review docs Documentation in the Doc dir skip news

Projects

Status: Todo

Development

Successfully merging this pull request may close these issues.

2 participants