Barney Gale added the comment:
Per discussion, expanduser('~other') is considered unreliable, and we shouldn't
add new functions that call through to it. Resolving as 'rejected'.
--
resolution: -> rejected
stage: patch review ->
New submission from Barney Gale :
Proposal:
- Introduce `os.path.fileuri()` function that produces a 'file://' URI
- Adjust `PurePosixPath.to_uri()` to call `posixpath.fileuri()`
- Adjust `PureWindowsPath.to_uri()` to call `ntpath.fileuri()`
- Adjust `nturl2path.pathname2url(
Change by Barney Gale :
--
pull_requests: +25298
pull_request: https://github.com/python/cpython/pull/26708
___
Python tracker
<https://bugs.python.org/issue24
Change by Barney Gale :
--
pull_requests: +25297
pull_request: https://github.com/python/cpython/pull/26708
___
Python tracker
<https://bugs.python.org/issue44
Change by Barney Gale :
--
keywords: +patch
pull_requests: +25296
stage: -> patch review
pull_request: https://github.com/python/cpython/pull/26708
___
Python tracker
<https://bugs.python.org/issu
Barney Gale added the comment:
Depends: bpo-39899, bpo-43757, bpo-44316, bpo-44403, bpo-44412
--
___
Python tracker
<https://bugs.python.org/issue44136>
___
___
Barney Gale added the comment:
`os.symlink()` and `pathlib.Path.symlink_to()` have reversed argument orders,
but in the repro steps you're supplying arguments in the same order.
--
nosy: +barneygale
___
Python tracker
<https://bugs.py
New submission from Barney Gale :
Whereas most calls to `os` functions from `pathlib.Path` methods happen via
`pathlib._Accessor` methods, retrieving the current working directory does not.
This problem occurs when calling the `pathlib.Path.cwd()`, `~resolve()` and
`~absolute()` methods
Barney Gale added the comment:
Those methods are non-pure, i.e. part of `Path` but not `PurePath`. Only impure
paths have accessors. The `_Accessor` docstring says: "an accessor implements a
particular (system-specific or not) way of accessing paths on the filesystem".
This abst
New submission from Barney Gale :
`pathlib.Path` objects can be used as context managers, but this functionality
is undocumented and makes little sense. Example:
>>> import pathlib
>>> root = pathlib.Path("/")
>>> with root:
... print(1)
Barney Gale added the comment:
Attempted fix shown here:
https://github.com/barneygale/cpython/commit/784630ef6ad05031abdefa523e61e0629b15e201
Note that I've already removed context manager support (and hence `_closed`) in
this branch.
--
nosy: +barne
Barney Gale added the comment:
Can I ask what sort of backwards-compatibility guarantees Python provides for
these cases? In the case of using a Path object as a context manager, I think
we can say:
- It's easy to do - there's no need to call any underscore-prefixed methods fo
Barney Gale added the comment:
Also, thank you Antoine for your explanation :-)
--
___
Python tracker
<https://bugs.python.org/issue39682>
___
___
Python-bug
Change by Barney Gale :
--
keywords: +patch
pull_requests: +18191
stage: -> patch review
pull_request: https://github.com/python/cpython/pull/18834
___
Python tracker
<https://bugs.python.org/issu
New submission from Barney Gale :
`Path.samefile()` calls `os.stat()` directly. It should use the path's accessor
object, as `Path.stat()` does.
--
components: Library (Lib)
messages: 363629
nosy: barneygale
priority: normal
severity: normal
status: open
title: `pathlib.Path.sam
Change by Barney Gale :
--
keywords: +patch
pull_requests: +18193
stage: -> patch review
pull_request: https://github.com/python/cpython/pull/18836
___
Python tracker
<https://bugs.python.org/issu
New submission from Barney Gale :
`Path.touch()` does a lot of os-specific /stuff/ that should probably live in
the accessor. Perhaps most importantly, is calls `os.close()` on whatever
`accessor.open()` returns, which is problematic for those wishing to write
their own accessor that doesn
Change by Barney Gale :
--
keywords: +patch
pull_requests: +18195
stage: -> patch review
pull_request: https://github.com/python/cpython/pull/18838
___
Python tracker
<https://bugs.python.org/issu
New submission from Barney Gale :
`pathlib.Path.is_mount()` calls `Path(self.parent)`, which:
- Is needless, as `self.parent` is already a Path instance!
- Prevents effective subclassing, as `self.parent` may be a `Path` subclass
with its own `stat()` implementation
--
components
Change by Barney Gale :
--
keywords: +patch
pull_requests: +18196
stage: -> patch review
pull_request: https://github.com/python/cpython/pull/18839
___
Python tracker
<https://bugs.python.org/issu
New submission from Barney Gale :
`pathlib.Path.expanduser()` does not call `os.path.expanduser()`, but instead
re-implements it. The implementations look pretty similar and I can't see a
good reason for the duplication. The only difference is that
`pathlib.Path.expanduser()` r
Barney Gale added the comment:
We can check whether `os.path.expanduser()` returned a path beginning with "~"
and raise a RuntimeError if so, right? On point #2, I'm not sure this
optimization alone justifies the duplicati
Change by Barney Gale :
--
keywords: +patch
pull_requests: +18198
stage: -> patch review
pull_request: https://github.com/python/cpython/pull/18841
___
Python tracker
<https://bugs.python.org/issu
New submission from Barney Gale :
`pathlib.Path.__bytes__()` calls `os.fsencode()` without using path's accessor.
To properly isolate Path objects from the underlying local filesystem, this
should be routed via the accessor object.
--
messages: 363638
nosy: barneygale
pri
Change by Barney Gale :
--
keywords: +patch
pull_requests: +18199
stage: -> patch review
pull_request: https://github.com/python/cpython/pull/18842
___
Python tracker
<https://bugs.python.org/issu
New submission from Barney Gale :
The implementations of `Path.owner()` and `Path.group()` directly import and
use the `pwd` and `grp` modules. Given these modules provide information about
the *local* system, I believe these implementations should instead live in
`pathlib._NormalAccessor
Change by Barney Gale :
--
keywords: +patch
pull_requests: +18201
stage: -> patch review
pull_request: https://github.com/python/cpython/pull/18844
___
Python tracker
<https://bugs.python.org/issu
Barney Gale added the comment:
I see no reason for the duplication, and I can point to one concrete bug
affecting your re-implementation of `expanduser` that doesn't affect the
original, i.e. that a `KeyError` is raised on Windows when `"USERNAME"` is not
present in `os.en
Change by Barney Gale :
--
keywords: +patch
pull_requests: +18203
stage: -> patch review
pull_request: https://github.com/python/cpython/pull/18846
___
Python tracker
<https://bugs.python.org/issu
Barney Gale added the comment:
The only design flaw mentioned in that thread is that `os.path.expanduser()`
returns the input unchanged if expansion fails, which is not very pythonic.
However, such a problem doesn't necessitate a rewrite of
`os.path.expanduser()`. Checking `result[:1
New submission from Barney Gale :
As of Python 3.3, `os.lstat()` and `os.lchmod()` are available as
`os.stat(follow_symlinks=False)` and `os.chmod(follow_symlinks=False)`, but an
equivalent change didn't make it into pathlib. I propose we add the
`follow_symlinks` argument to `Path
Change by Barney Gale :
--
keywords: +patch
pull_requests: +18221
stage: -> patch review
pull_request: https://github.com/python/cpython/pull/18864
___
Python tracker
<https://bugs.python.org/issu
Change by Barney Gale :
--
nosy: +barneygale
nosy_count: 5.0 -> 6.0
pull_requests: +18222
pull_request: https://github.com/python/cpython/pull/18864
___
Python tracker
<https://bugs.python.org/iss
New submission from Barney Gale :
`pathlib.Path.iterdir()` uses `os.listdir()` rather than `os.scandir()`. I
think this has a small performance cost, per PEP 471:
> It returns a generator instead of a list, so that scandir acts as a true
> iterator instead of returning the ful
Change by Barney Gale :
--
keywords: +patch
pull_requests: +18223
stage: -> patch review
pull_request: https://github.com/python/cpython/pull/18865
___
Python tracker
<https://bugs.python.org/issu
Barney Gale added the comment:
Ah, right you are! The globbing helpers call `list(os.scandir(...))` - perhaps
we should do the same here?
--
___
Python tracker
<https://bugs.python.org/issue39
Barney Gale added the comment:
Less reliable how? Doesn't appear any slower:
barney.gale@heilbron:~$ python3 -m timeit -s "import os;
os.listdir('/usr/local')"
1 loops, best of 3: 0.0108 usec per loop
barney.gale@heilbron:~$ python3 -m timeit -s "imp
Change by Barney Gale :
--
resolution: -> not a bug
stage: patch review -> resolved
status: open -> closed
___
Python tracker
<https://bugs.python.or
Barney Gale added the comment:
Thanks Rémi and Serhiy! Closing this ticket as the patch doesn't provide any
sort of improvement.
--
___
Python tracker
<https://bugs.python.org/is
Barney Gale added the comment:
Closing after @pitrou clarified the meaning of __fspath__() here:
https://discuss.python.org/t/make-pathlib-extensible/3428/12?u=barneygale
--
resolution: -> not a bug
stage: patch review -> resolved
status: open -&g
New submission from Barney Gale :
Small bug report encompassing some related issues in `pathlib._NormalAccessor`:
- `link_to()` should be named `link()` for consistency with other methods
- `symlink()` doesn't need to guard against `os.symlink()` not accepting
`target_is_directory` o
New submission from Barney Gale :
`mylink.symlink_to(target)` and `mylink.link_to(target)` should both create a
link (soft or hard) at *mylink* that points to *target*. But `link_to()` does
the opposite - it creates *target* and points it towards *mylink*.
Correct behaviour from `symlink_to
Barney Gale added the comment:
I'm not sure how it can be fixed on the documentation side - it's difficult to
explain that `a.link_to(b)` creates a link from B to A, and not vice-versa.
We could introduce a new method that does the right thing? `Path.h
Change by Barney Gale :
--
keywords: +patch
pull_requests: +18264
stage: -> patch review
pull_request: https://github.com/python/cpython/pull/18909
___
Python tracker
<https://bugs.python.org/issu
Barney Gale added the comment:
Good points! Do you know of an example of a community library that uses
`_Accessor.link`? Thanks
--
___
Python tracker
<https://bugs.python.org/issue39
Barney Gale added the comment:
Per discussion on the mailing list, I'd like to request that this bug be
re-opened.
https://mail.python.org/archives/list/python-...@python.org/thread/7QPLYW36ZK6QTW4SV4FI6C343KYWCPAT/
--
nosy: +barne
New submission from Barney Gale :
Per bpo-39291, the argument order for `pathlib.Path.link_to()` is inconsistent
with `symlink_to()` and its own documentation.
This ticket covers adding a new `hardlink_to()` method with the correct
argument order, and deprecating `link_to()`.
Discussion on
Change by Barney Gale :
--
keywords: +patch
pull_requests: +18321
stage: -> patch review
pull_request: https://github.com/python/cpython/pull/18909
___
Python tracker
<https://bugs.python.org/issu
New submission from Barney Gale :
`pathlib.Path._init()` accepts a 'template' argument that pathlib uses - in
some cases - to preserve the current accessor object when creating modified
path objects. This works for `resolve()`, `absolute()` and `readlink()`, *but
no other c
Barney Gale added the comment:
A question:
For my patch, I need to include a Python version where `Path.link_to()` will
become unavailable. I'm not entirely sure how this should be determined. Some
factors in play:
- `link_to()` was added in Python 3.8
- On github, I found these
Barney Gale added the comment:
I'm taking another look at making `pathlib` extensible. There's some discussion
here: https://discuss.python.org/t/make-pathlib-extensible/3428
List or preparatory bugfixes and tidy-ups:
https://docs.google.com/spre
New submission from Barney Gale :
This is one of a series of bug reports / PRs that lay the groundwork for making
pathlib extensible. See here for detail:
https://discuss.python.org/t/make-pathlib-extensible/3428
Currently `_Accessor.open()` is expected to function like `os.open()` and
Change by Barney Gale :
--
pull_requests: +18582
pull_request: https://github.com/python/cpython/pull/19220
___
Python tracker
<https://bugs.python.org/issue39
Change by Barney Gale :
--
keywords: +patch
pull_requests: +18706
stage: -> patch review
pull_request: https://github.com/python/cpython/pull/19342
___
Python tracker
<https://bugs.python.org/issu
Barney Gale added the comment:
Makes sense to me. Should I leave the documentation for `link_to` completely
alone? With the addition of a similar function, I wonder if that may in itself
cause confusion.
--
___
Python tracker
<ht
New submission from Barney Gale :
The `pathlib.Path.home()` function looks like:
@classmethod
def home(cls):
"""Return a new path pointing to the user's home directory (as
returned by os.path.expanduser('~')).
"""
Barney Gale added the comment:
I should add that this is part of a plan to spin out some `Path` methods into a
new `UserPath` class. Notably, in this case, `UserPath.expanduser()` will call
`self.home()` under-the-hood. This is done to reduce the surface area of
abstract methods that
New submission from Barney Gale :
Compare the documentation of `symlink_to()` and `link_to()`:
.. method:: Path.symlink_to(target, target_is_directory=False)
Make this path a symbolic link to *target*.
.. method:: Path.link_to(target)
Create a hard link pointing to a path named
Barney Gale added the comment:
I've logged bpo-42999 to cover fixing the existing `link_to()` docs issues. PR
incoming...
--
___
Python tracker
<https://bugs.python.org/is
Change by Barney Gale :
--
keywords: +patch
pull_requests: +23116
stage: -> patch review
pull_request: https://github.com/python/cpython/pull/18909
___
Python tracker
<https://bugs.python.org/issu
Change by Barney Gale :
--
pull_requests: +23117
pull_request: https://github.com/python/cpython/pull/24294
___
Python tracker
<https://bugs.python.org/issue42
New submission from Barney Gale :
Per Pitrou:
> The original intent for the “accessor” thing was to have a variant that did
> all accesses under a filesystem tree in a race condition-free way using
> openat and friends. It turned out to be much too hairy to actually implement,
101 - 162 of 162 matches
Mail list logo