From: Kanishk Pachauri Date: Tue, 18 Mar 2025 09:27:05 +0000 (+0000) Subject: gh-130132: properly free resources in `urrlib.urlopen` examples (#130280) X-Git-Tag: v3.14.0a7~332 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=77d2fd441320ca365c34e21c475d3878f3d5d833;p=thirdparty%2FPython%2Fcpython.git gh-130132: properly free resources in `urrlib.urlopen` examples (#130280) Co-authored-by: sobolevn Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com> --- diff --git a/Doc/library/urllib.request.rst b/Doc/library/urllib.request.rst index b3efde3f1895..969e7daea710 100644 --- a/Doc/library/urllib.request.rst +++ b/Doc/library/urllib.request.rst @@ -1249,7 +1249,10 @@ It is also possible to achieve the same result without using the >>> import urllib.request >>> f = urllib.request.urlopen('http://www.python.org/') - >>> print(f.read(100).decode('utf-8')) + >>> try: + ... print(f.read(100).decode('utf-8')) + ... finally: + ... f.close()