Merge lp:~songofacandy/bzr/fix-524560 into lp:bzr/2.0
| Status: | Merged | ||||
|---|---|---|---|---|---|
| Merged at revision: | not available | ||||
| Proposed branch: | lp:~songofacandy/bzr/fix-524560 | ||||
| Merge into: | lp:bzr/2.0 | ||||
| Diff against target: |
117 lines (+52/-7) 3 files modified
bzrlib/atomicfile.py (+1/-1) bzrlib/osutils.py (+47/-2) bzrlib/transport/local.py (+4/-4) |
||||
| To merge this branch: | bzr merge lp:~songofacandy/bzr/fix-524560 | ||||
| Related bugs: |
|
| Reviewer | Review Type | Date Requested | Status |
|---|---|---|---|
| Vincent Ladeuil | 2010-02-20 | Approve on 2010-03-03 | |
| Martin Packman (community) | Approve on 2010-03-03 | ||
| Andrew Bennetts | 2010-02-19 | Approve on 2010-02-20 | |
|
Review via email:
|
|||
- 4737. By INADA Naoki on 2010-02-22
-
Add osutils.open() that uses O_NOINHERIT on Win32.
- 4738. By INADA Naoki on 2010-02-22
-
Add bufsize argument in osutils.open()
- 4739. By INADA Naoki on 2010-02-22
-
Fix easy miss in previous commit.
- 4740. By INADA Naoki on 2010-02-22
-
Use O_NOINHERIT flag in AtomicFile.
- 4741. By INADA Naoki on 2010-02-22
-
Add comment to osutils.open()
- 4742. By INADA Naoki on 2010-02-22
-
Add missing flags. (O_CREAT, O_TRUNC, etc...)
| INADA Naoki (songofacandy) wrote : | # |
I've found open with mode="wbN" is enough.
mode 'N' means NOINHERIT on win32 and ignored on Linux.
Should I remove osutils.open and add 'N' flag directly?
- 4743. By INADA Naoki on 2010-02-22
-
Change osutils.open implementation. Just add 'N' to mode.
| John A Meinel (jameinel) wrote : | # |
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
INADA Naoki wrote:
> I've found open with mode="wbN" is enough.
> mode 'N' means NOINHERIT on win32 and ignored on Linux.
>
> Should I remove osutils.open and add 'N' flag directly?
If that works, I would recommend it. But we need to make sure that it
doesn't cause problems with Python 2.4.
John
=:->
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Cygwin)
Comment: Using GnuPG with Mozilla - http://
iEYEARECAAYFAku
ZogAn1zgWNTubK4
=UidF
-----END PGP SIGNATURE-----
| INADA Naoki (songofacandy) wrote : | # |
> INADA Naoki wrote:
> > I've found open with mode="wbN" is enough.
> > mode 'N' means NOINHERIT on win32 and ignored on Linux.
> >
> > Should I remove osutils.open and add 'N' flag directly?
>
> If that works, I would recommend it. But we need to make sure that it
> doesn't cause problems with Python 2.4.
>
> John
> =:->
I confirmed that glibc doesn't use 'N' for mode so it just ignore the 'N'.
But I don't know about other libc. (on Solaris, FreeBSD, MacOS, etc...)
So I think using 'N' only on win32 is safe.
Python 2.4 uses msvcrt71 (VC++2003?) and msdn doesn't document 'N' mode
and O_NOINHERIT. But os module in Python 2.4 have O_NOINHERIT so fcntl.h in
VC++2003 should have O_NOINHERIT.
I don't know the file is inherited to child process or not.
But I installed Python 2.4 and ``open('foo', 'wbN').
| Martin Packman (gz) wrote : | # |
Some general comments:
* Adding O_NOINHERIT to the default flags bzr uses seems sensible.
* Don't like the style of having shadows in osutils that are almost-
> Python 2.4 uses msvcrt71 (VC++2003?) and msdn doesn't document 'N' mode
> and O_NOINHERIT. But os module in Python 2.4 have O_NOINHERIT so fcntl.h in
> VC++2003 should have O_NOINHERIT.
> I don't know the file is inherited to child process or not.
> But I installed Python 2.4 and ``open('foo', 'wbN').
MSDN is correct, it does *not* work on Pythons compiled with VS < 2005. The open succeeds but the flag is ignored. I threw together some quick tests that show this, and don't think this change should go in untested or this lightly documented.
| INADA Naoki (songofacandy) wrote : | # |
> * Don't like the style of having shadows in osutils that are almost-but-not-
> quite builtins or standard library functions.
So, which name is suitable?
* open_noinherit()
* open_noshare()
* or other name...
> > Python 2.4 uses msvcrt71 (VC++2003?) and msdn doesn't document 'N' mode
> > and O_NOINHERIT. But os module in Python 2.4 have O_NOINHERIT so fcntl.h in
> > VC++2003 should have O_NOINHERIT.
> > I don't know the file is inherited to child process or not.
> > But I installed Python 2.4 and ``open('foo', 'wbN').
> works.
>
> MSDN is correct, it does *not* work on Pythons compiled with VS < 2005. The
> open succeeds but the flag is ignored. I threw together some quick tests that
> show this, and don't think this change should go in untested or this lightly
> documented.
Should we support this case on Python 2.4 on Windows?
If should, using os.fdopen(
http://
| Martin Pool (mbp) wrote : | # |
On 23 February 2010 12:54, INADA Naoki <email address hidden> wrote:
>> * Don't like the style of having shadows in osutils that are almost-but-not-
>> quite builtins or standard library functions.
>
> So, which name is suitable?
>
> * open_noinherit()
> * open_noshare()
> * or other name...
open_file.
I agree with gzlist that using exactly the same name is likely to
cause confusion, but the fact that you want noinherit seems more like
an option than an entirely different function. Or would it be
feasible to just pass the right option to plain open()?
--
Martin <http://
| Martin Packman (gz) wrote : | # |
> > * Don't like the style of having shadows in osutils that are almost-but-not-
> > quite builtins or standard library functions.
Just realised there's a clash with another current merge proposal here:
<https:/
Which I guess proves my point.
> So, which name is suitable?
>
> * open_noinherit()
> * open_noshare()
> * or other name...
I like the first one best there, but pine for a better way...
> Should we support this case on Python 2.4 on Windows?
> If should, using os.fdopen(
> http://
Python 2.5 is also pre-VS2005. Using O_NOINHERIT does work on everything, though if it's the best option I don't know.
- 4744. By INADA Naoki on 2010-02-23
-
Revert to previous implementation using os.fdopen(
os.open( )) - 4745. By INADA Naoki on 2010-02-23
-
Change name from osutils.open to osutils.open_file
| Martin Packman (gz) wrote : | # |
> I like the first one best there, but pine for a better way...
Nope, can't find one. Only vile hacks and Vista-or-later functionality.
Personally, I wouldn't object to putting 'N' in the open flags of any long-lived file bazaar uses, and documenting that people should expect things to break with Python < 2.6 if they don't use paramiko. About the only person that'll harm will be me, and I've not run into this bug yet.
| INADA Naoki (songofacandy) wrote : | # |
> On 23 February 2010 12:54, INADA Naoki <email address hidden> wrote:
> >> * Don't like the style of having shadows in osutils that are almost-but-
> not-
> >> quite builtins or standard library functions.
> >
> > So, which name is suitable?
> >
> > * open_noinherit()
> > * open_noshare()
> > * or other name...
>
> open_file.
>
> I agree with gzlist that using exactly the same name is likely to
> cause confusion, but the fact that you want noinherit seems more like
> an option than an entirely different function. Or would it be
> feasible to just pass the right option to plain open()?
>
OK, I agree open_file is good.
I've changed the name.
| INADA Naoki (songofacandy) wrote : | # |
> > > * Don't like the style of having shadows in osutils that are almost-but-
> not-
> > > quite builtins or standard library functions.
>
> Just realised there's a clash with another current merge proposal here:
> <https:/
> ownership/
Thanks for point it.
open_file() should fixes this and it.
> > Should we support this case on Python 2.4 on Windows?
> > If should, using os.fdopen(
> > http://
>
> Python 2.5 is also pre-VS2005. Using O_NOINHERIT does work on everything,
> though if it's the best option I don't know.
OK. I should use O_NOINHERIT flag instead of 'N' mode.
I've fixed it now.
- 4746. By INADA Naoki on 2010-02-23
-
Follow renaming open to open_file in transport.local
- 4747. By INADA Naoki on 2010-02-23
-
small clean up.
| Martin Packman (gz) wrote : | # |
Okay, I think some version of this should go in.
I've got a competing branch that does the minimal 'N' flag adding here:
<https:/
But I was under the impression that the all-in-one installer used the latest Python. As it's still on 2.5 my branch wouldn't actually fix the edge case in the bug for most people.
| Vincent Ladeuil (vila) wrote : | # |
@Martin [gz], damn, our messages crossed on the wire, I had already sent the pqm submission long before I saw your message...
Can you do a merge proposal explaining your branch intent or
is it now irrelevant (you said "some version of should go in"
and Naoki's version hs landed in 2.0 now) ?
| Martin Packman (gz) wrote : | # |
What you've landed is fine Vincent, Naoki's more complicated version is needed for the older Python versions.
I don't see it on bzr.dev yet though, it needs upmerging still?
| Vincent Ladeuil (vila) wrote : | # |
yes, I'll will do that (merging 2.0 in 2.1 and 2.1 into bzr.dev) asap.
| Vincent Ladeuil (vila) wrote : | # |
Done.

It would be nice to have a test for this, but I'm not sure what that would look like.
This looks like a good candidate for the 2.0 branch, so thanks for preparing it against that.