cpython: 691fba640266 (original) (raw)
Mercurial > cpython
changeset 100605:691fba640266
Issue #26567: enhance ResourceWarning example [#26567]
Victor Stinner victor.stinner@gmail.com | |
---|---|
date | Sat, 19 Mar 2016 10:33:25 +0100 |
parents | 543639cdfdb9 |
children | 71c55c89d4f1 |
files | Doc/whatsnew/3.6.rst |
diffstat | 1 files changed, 12 insertions(+), 9 deletions(-)[+] [-] Doc/whatsnew/3.6.rst 21 |
line wrap: on
line diff
--- a/Doc/whatsnew/3.6.rst
+++ b/Doc/whatsnew/3.6.rst
@@ -272,24 +272,27 @@ used to try to retrieve the traceback wh
Example with the script example.py
::
f = open(__file__)[](#l1.10)
f = None[](#l1.11)
return open(__file__)[](#l1.12)
Output of the command python3.6 -Wd -X tracemalloc=5 example.py
::
- example.py:7: ResourceWarning: unclosed file <_io.TextIOWrapper name='example.py' mode='r' encoding='UTF-8'> f = None Object allocated at (most recent call first):
File "example.py", lineno 2[](#l1.24)
f = open(__file__)[](#l1.25)
File "example.py", lineno 5[](#l1.26)
func()[](#l1.27)
File "example.py", lineno 4[](#l1.28)
return open(__file__)[](#l1.29)
File "example.py", lineno 6[](#l1.30)
f = func()[](#l1.31)
The "Object allocated at" traceback is new and only displayed if
-:mod:tracemalloc
is tracing Python memory allocations.
+:mod:tracemalloc
is tracing Python memory allocations and if the
+:mod:warnings
was already imported.
zipfile