mirror of
https://github.com/python/cpython.git
synced 2025-08-23 10:16:01 +00:00
Issue #22831: Use "with" to avoid possible fd leaks.
This commit is contained in:
parent
ae2d667ae8
commit
46ba6c8563
10 changed files with 107 additions and 120 deletions
|
@ -1639,9 +1639,8 @@ def writedoc(thing, forceload=0):
|
|||
try:
|
||||
object, name = resolve(thing, forceload)
|
||||
page = html.page(describe(object), html.document(object, name))
|
||||
file = open(name + '.html', 'w', encoding='utf-8')
|
||||
file.write(page)
|
||||
file.close()
|
||||
with open(name + '.html', 'w', encoding='utf-8') as file:
|
||||
file.write(page)
|
||||
print('wrote', name + '.html')
|
||||
except (ImportError, ErrorDuringImport) as value:
|
||||
print(value)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue