Skip to content
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

Suggestion: support for pathlib.Path object #235

Open
Magnusm94 opened this issue Mar 21, 2023 · 0 comments
Open

Suggestion: support for pathlib.Path object #235

Magnusm94 opened this issue Mar 21, 2023 · 0 comments

Comments

@Magnusm94
Copy link

In the __init__ method of configobj.ConfigObj, would it take a lot to be able to accept a pathlib.Path object without causing any other errors? I was testing out by adding a few lines of code above infile = infile or [] at lineno 1192:

if infile and not isinstance(infile, str):
    if type(infile).__base__.__name__ == 'Path':
        infile = str(infile)
infile = infile or []

I'm a bit unsure if this could cause any other issues, or if it works in every case, or if actually importing pathlib.Path would be required if the isinstance() check. Or maybe some other smart way? :)

from pathlib import Path

if isinstance(infile, Path):
    infile = str(infile)
infile = infile or []
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant