-
Notifications
You must be signed in to change notification settings - Fork 420
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
Accept pathlib.Path as a valid path #1027
Conversation
Hello? Plz? |
I think this would be more appropriately handled with |
Done |
src/OpenSSL/_util.py
Outdated
return s.encode(sys.getfilesystemencoding()) | ||
try: | ||
strpath = os.fspath(s) | ||
except Exception: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need to catch exceptions here? What case is that handling?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In [2]: os.fspath(1)
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-2-b00c080840d9> in <module>
----> 1 os.fspath(1)
TypeError: expected str, bytes or os.PathLike object, not int
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just because you seem to want to provide your own message. I'd be fine to not handle it and remove the else case later on as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I think allowing the exception from os.fspath
to propagate is fine.
And also whatever supports the protocol. Way more pythonic now!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
And also whatever can be converted to bytes.
Way more pythonic now!