diff options
author | Éric Araujo <merwok@netwok.org> | 2012-11-03 21:39:45 (GMT) |
---|---|---|
committer | Éric Araujo <merwok@netwok.org> | 2012-11-03 21:39:45 (GMT) |
commit | 309b0432377f2f7159fa4f407859db9d6d5fdc39 (patch) | |
tree | c24f2c371c8489aeb84ebcae36ccedfbbedf811d | |
parent | a113e018fced52ace2157b6fe9af9f731af0e9ac (diff) | |
download | cpython-309b0432377f2f7159fa4f407859db9d6d5fdc39.zip cpython-309b0432377f2f7159fa4f407859db9d6d5fdc39.tar.gz cpython-309b0432377f2f7159fa4f407859db9d6d5fdc39.tar.bz2 |
Avoid fd leak in example. Caught by Serhiy.
-rw-r--r-- | Doc/library/functions.rst | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/Doc/library/functions.rst b/Doc/library/functions.rst index 5df7b67..5885fe2 100644 --- a/Doc/library/functions.rst +++ b/Doc/library/functions.rst @@ -958,12 +958,13 @@ are always available. They are listed here in alphabetical order. ... dir_fd = os.open(dirname, os.O_RDONLY) ... def opener(path, flags): ... return os.open(path, flags, dir_fd=dir_fd) - ... return opener + ... return opener, dir_fd ... - >>> opener = open_relative('somedir') + >>> opener, dir_fd = open_relative('somedir') >>> with open('spamspam.txt', 'w', opener=opener) as f: ... print('This will be written to somedir/spamspam.txt', file=f) ... + >>> os.close(dir_fd) # don't leak a file descriptor .. versionchanged:: 3.3 The *opener* parameter was added. |