Path.open() is not equivalent to built-in open()

Issue #10 resolved
July Tikhonov
created an issue

Though the Path.open() documentation states that it will "open the file pointed to by the path, like the built-in open() function does", in particular case behavior deviates:

july@julynote:~/tmp> python3 --version
Python 3.4.0a0
july@julynote:~/tmp> ls -l asdf
ls: cannot access asdf: No such file or directory
july@julynote:~/tmp> python3 -c "open('asdf', 'w').close()"
july@julynote:~/tmp> ls -l asdf
-rw-r--r-- 1 july users 0 Feb 16 17:06 asdf
july@julynote:~/tmp> rm asdf
july@julynote:~/tmp> python3 -c "import pathlib; pathlib.Path('asdf').open('w').close()"
july@julynote:~/tmp> ls -l asdf
-rwxr-xr-x 1 july users 0 Feb 16 17:07 asdf

On file creation, Path.open() makes a new file executable, while built-in open() not.

I suppose that either the difference should be mentioned in the documentation, or the Path._opener() should be altered to conform to the behavior of open().

Comments (2)

  1. Log in to comment