[issue13424] Add examples for open’s new opener argument

2012-11-21 Thread Roundup Robot

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

2012-11-21 Thread Éric Araujo

É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

2012-11-17 Thread Ezio Melotti

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

2012-11-04 Thread Serhiy Storchaka

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

2012-11-03 Thread Guillaume P

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

2012-11-03 Thread Roundup Robot

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

2012-11-03 Thread Éric Araujo

É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

2012-11-03 Thread Serhiy Storchaka

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

2012-11-03 Thread Éric Araujo

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

2012-11-03 Thread Éric Araujo

É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

2011-11-19 Thread Ezio Melotti

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

2011-11-18 Thread Éric Araujo

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

2011-11-18 Thread Éric Araujo

É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

2011-11-18 Thread Ross Lagerwall

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