-
-
Notifications
You must be signed in to change notification settings - Fork 30.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
mailbox does not support new Path object #85198
Comments
The mailbox library, in particular the Mailbox class I'm using, does not support the new Path object requiring a clumsy It currently blows up if passed a Path directly (does not support startswith) - perhaps a simple solution is to coerce whatever is passed into a string inside Could this support be added? I feel that strings representing paths should be discouraged as a general principal now we have a truly portable object to represent paths, and supporting Path in all places it makes logical sense (without breaking backwards compatibility, if implemented as I suggest with coercion by |
Sorry, should read "in particular the Maildir class I'm using"... Same applies to mbox, however. |
Hi Laurence, Maildir predates pathlib so it's not surprising it hasn't been updated yet. Could you open a PR to add this? BTW, you should use os.fspath() instead of str() here. |
Hi Rémi, I understand why it is the case, I just thought it would be a nice enhancement and quick win to add the support. RE "you should use os.fspath() instead of str()": I'm following in the pathlib docuementation (https://docs.python.org/3/library/pathlib.html):
Is the pathlib documentation wrong/out-of-date? I Googled your suggestion of I'm trying to setup a build environment to create a PR for this issue as I type... Thanks, Laurence |
I have patched the module to accept a path-like object, however it still follows the pre-pathlib ways of doing things elsewhere. There's quite a bit of work to do to modernise the whole module, but this patch at least adds support to pass a Path to the classes it provides so external code can use pathlib and interface with it. |
The problem with using The documentation for pathlib also predates the addition of |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: