[issue13424] Add examples for open’s new opener argument
Roundup Robot added the comment: New changeset bf1bf3bf3fe2 by Éric Araujo in branch '3.3': Address reviews for open’s opener argument doc patch (#13424). http://hg.python.org/cpython/rev/bf1bf3bf3fe2 New changeset 8ca6f4953c4b by Éric Araujo in branch 'default': Merge #13424 followup from 3.3 http://hg.python.org/cpython/rev/8ca6f4953c4b -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13424 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13424] Add examples for open’s new opener argument
Éric Araujo added the comment: Thanks for all comments. If you think of a better example to show the usage of the argument, feel free to change it. -- assignee: docs@python - eric.araujo resolution: - fixed stage: commit review - committed/rejected status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13424 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13424] Add examples for open’s new opener argument
Ezio Melotti added the comment: There's also a Sphinx warning that should be fixed: 3.3/Doc/library/functions.rst:955: WARNING: undefined label: dir_fd (if the link has no caption the label must precede a section header) -- nosy: +ezio.melotti ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13424 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13424] Add examples for open’s new opener argument
Serhiy Storchaka added the comment: Isn't it be clearer? import os dir_fd = os.open('somedir', os.O_RDONLY) def opener(path, flags): ... return os.open(path, flags, dir_fd=dir_fd) ... 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 Or if you want stronger example: import os, contextlib, functools @contextlib.contextmanager ... def open_relative(dirname): ... dir_fd = os.open(dirname, os.O_RDONLY) ... def opener(path, flags): ... return os.open(path, flags, dir_fd=dir_fd) ... try: ... yield functools.partial(open, opener=opener) ... finally: ... os.close(dir_fd) ... with open_relative('somedir') as open: ... with open('spamspam.txt', 'w') as f: ... print('This will be written to somedir/spamspam.txt', file=f) ... Frankly speaking, all of these examples looks unconvincing to me. Even the second example could be implemented without an opener argument. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13424 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13424] Add examples for open’s new opener argument
Guillaume P added the comment: Here is a proposed patch to the documentation. -- keywords: +patch nosy: +guillaumep Added file: http://bugs.python.org/file27866/13424.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13424 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13424] Add examples for open’s new opener argument
Roundup Robot added the comment: New changeset 17b094c08600 by Éric Araujo in branch '3.3': Add examples for opener argument of open (#13424). http://hg.python.org/cpython/rev/17b094c08600 -- nosy: +python-dev ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13424 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13424] Add examples for open’s new opener argument
Éric Araujo added the comment: Fixed, thanks! -- resolution: - fixed stage: needs patch - committed/rejected status: open - closed versions: +Python 3.4 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13424 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13424] Add examples for open’s new opener argument
Serhiy Storchaka added the comment: See my comments in Rietveld. -- nosy: +serhiy.storchaka type: - enhancement ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13424 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13424] Add examples for open’s new opener argument
Changes by Éric Araujo mer...@netwok.org: -- resolution: fixed - stage: committed/rejected - commit review status: closed - open ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13424 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13424] Add examples for open’s new opener argument
Éric Araujo added the comment: fd leak fixed in 95ea024f0569. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13424 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13424] Add examples for open’s new opener argument
Changes by Ezio Melotti ezio.melo...@gmail.com: -- keywords: +easy stage: - needs patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13424 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13424] Add examples for open’s new opener argument
New submission from Éric Araujo mer...@netwok.org: The new opener argument to open and TextIOWrapper closed two bugs on this tracker: using O_CLOEXEC and replacing the unofficial 'c' mode (O_CREATE). I think it’d be nice to have these as examples (maybe not in the docs of TextIOWrapper which are already huge, but for example in the os docs after the O_* constants). -- assignee: docs@python components: Documentation messages: 147840 nosy: docs@python, eric.araujo priority: normal severity: normal status: open title: Add examples for open’s new opener argument versions: Python 3.3 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13424 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13424] Add examples for open’s new opener argument
Éric Araujo mer...@netwok.org added the comment: s/TextIOWrapper/FileIO/ -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13424 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13424] Add examples for open’s new opener argument
Changes by Ross Lagerwall rosslagerw...@gmail.com: -- nosy: +rosslagerwall ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13424 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com