Re: The opener parameter of Python 3 open() built-in

2012-09-05 Thread Tim Delaney
On 6 September 2012 16:34, Steven D'Aprano < steve+comp.lang.pyt...@pearwood.info> wrote: > On Thu, 06 Sep 2012 00:34:56 +, Antoine Pitrou wrote: > > Monkey-patching globals is not thread-safe: other threads will see your > > modification, which is risky and fragile. > > Isn't that assuming th

Re: The opener parameter of Python 3 open() built-in

2012-09-05 Thread Steven D'Aprano
On Thu, 06 Sep 2012 00:34:56 +, Antoine Pitrou wrote: > Chris Angelico gmail.com> writes: >> >> On Wed, Sep 5, 2012 at 5:16 AM, Terry Reedy udel.edu> >> wrote: >> > io.open depends on a function the returns an open file descriptor. >> > opener exposes that dependency so it can be replaced.

Re: The opener parameter of Python 3 open() built-in

2012-09-05 Thread Antoine Pitrou
Chris Angelico gmail.com> writes: > > On Wed, Sep 5, 2012 at 5:16 AM, Terry Reedy udel.edu> wrote: > > io.open depends on a function the returns an open file descriptor. opener > > exposes that dependency so it can be replaced. > > I skimmed the bug report comments but didn't find an answer to

Re: The opener parameter of Python 3 open() built-in

2012-09-04 Thread Terry Reedy
On 9/4/2012 6:18 PM, Chris Angelico wrote: On Wed, Sep 5, 2012 at 5:16 AM, Terry Reedy wrote: io.open depends on a function the returns an open file descriptor. opener exposes that dependency so it can be replaced. I skimmed the bug report comments but didn't find an answer to this: Why not j

Re: The opener parameter of Python 3 open() built-in

2012-09-04 Thread Chris Angelico
On Wed, Sep 5, 2012 at 5:16 AM, Terry Reedy wrote: > io.open depends on a function the returns an open file descriptor. opener > exposes that dependency so it can be replaced. I skimmed the bug report comments but didn't find an answer to this: Why not just monkey-patch? When a module function ca

Re: The opener parameter of Python 3 open() built-in

2012-09-04 Thread Terry Reedy
On 9/4/2012 8:58 AM, Serhiy Storchaka wrote: On 04.09.12 04:13, Steven D'Aprano wrote: Why does the open builtin need this added complexity? Why not just call os.open directly? Or for more complex openers, just call the opener directly? What is the rationale for complicating open instead of tel

Re: The opener parameter of Python 3 open() built-in

2012-09-04 Thread Serhiy Storchaka
On 03.09.12 15:32, Marco wrote: Does anyone have an example of utilisation? http://bugs.python.org/issue13424 -- http://mail.python.org/mailman/listinfo/python-list

Re: The opener parameter of Python 3 open() built-in

2012-09-04 Thread Serhiy Storchaka
On 04.09.12 04:13, Steven D'Aprano wrote: Why does the open builtin need this added complexity? Why not just call os.open directly? Or for more complex openers, just call the opener directly? What is the rationale for complicating open instead of telling people to just call their opener directly

Re: The opener parameter of Python 3 open() built-in

2012-09-03 Thread Ben Finney
Steven D'Aprano writes: > On Mon, 03 Sep 2012 23:19:51 -0400, Dennis Lee Bieber wrote: > > f = os.fdopen(os.open("newfile", flags | os.O_EXCL), "w") > > > > which does NOT look any cleaner to me... > > Well, I don't know about that. Once you start messing about with low- > level O_* flags,

Re: The opener parameter of Python 3 open() built-in

2012-09-03 Thread Steven D'Aprano
On Mon, 03 Sep 2012 23:19:51 -0400, Dennis Lee Bieber wrote: > On 04 Sep 2012 01:13:09 GMT, Steven D'Aprano > declaimed the following in > gmane.comp.python.general: > > > >> Why does the open builtin need this added complexity? Why not just call >> os.open directly? Or for more complex opener

Re: The opener parameter of Python 3 open() built-in

2012-09-03 Thread Ben Finney
Ben Finney writes: > So, having written the opener: > > > On Mon, 03 Sep 2012 15:29:05 +0200, Christian Heimes wrote: > > > import os > > > > > > def opener(file, flags): > > > return os.open(file, flags | os.O_EXCL) > > why not call that directly? > > f = opener(file, flags) Ah, becaus

Re: The opener parameter of Python 3 open() built-in

2012-09-03 Thread Ben Finney
Dennis Lee Bieber writes: > On 04 Sep 2012 01:13:09 GMT, Steven D'Aprano > declaimed the following in > gmane.comp.python.general: > > What is the rationale for complicating [the builtin] open instead of > > telling people to just call their opener directly? > > To avoid the new syntax wou

Re: The opener parameter of Python 3 open() built-in

2012-09-03 Thread Steven D'Aprano
On Mon, 03 Sep 2012 15:29:05 +0200, Christian Heimes wrote: > Am 03.09.2012 14:32, schrieb Marco: >> Does anyone have an example of utilisation? > > The opener argument is a new 3.3 feature. For example you can use the > feature to implement exclusive creation of a file to avoid symlink > attacks

Re: The opener parameter of Python 3 open() built-in

2012-09-03 Thread Serhiy Storchaka
On 03.09.12 16:29, Christian Heimes wrote: Am 03.09.2012 14:32, schrieb Marco: Does anyone have an example of utilisation? The opener argument is a new 3.3 feature. For example you can use the feature to implement exclusive creation of a file to avoid symlink attacks. Or you can use new dir_

Re: The opener parameter of Python 3 open() built-in

2012-09-03 Thread Marco
On 09/03/2012 03:05 PM, Dave Angel wrote: Does anyone have an example of utilisation? As of Python 3.2.3, there is no "opener" parameter in the open() function. http://docs.python.org/py3k/library/functions.html I don't know of any such parameter in earlier or later versions, but I coul

Re: The opener parameter of Python 3 open() built-in

2012-09-03 Thread Christian Heimes
Am 03.09.2012 14:32, schrieb Marco: > Does anyone have an example of utilisation? The opener argument is a new 3.3 feature. For example you can use the feature to implement exclusive creation of a file to avoid symlink attacks. import os def opener(file, flags): return os.open(file, flags |

Re: The opener parameter of Python 3 open() built-in

2012-09-03 Thread Dave Angel
On 09/03/2012 08:32 AM, Marco wrote: > Does anyone have an example of utilisation? As of Python 3.2.3, there is no "opener" parameter in the open() function. http://docs.python.org/py3k/library/functions.html I don't know of any such parameter in earlier or later versions, but I could be wron

The opener parameter of Python 3 open() built-in

2012-09-03 Thread Marco
Does anyone have an example of utilisation? -- http://mail.python.org/mailman/listinfo/python-list