Meta: Why the use of os.fsdecode in dodo.py #113
-
Hey! Forgive the completely unrelated question, I had never heard of doit before seeing you use it here. I've started playing with it and I love it, I'm intending to use it much as you have here, to automate project maintenance stuff. Just one quick question if you have a sec: How come you use Thanks for the help and all the work on python! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
It's to prevent potential errors from me. 😄 When you take something like a pathlib object, it can have either a string or bytes representation of the path. Since the Python Launcher only supports file paths that can be decoded to a string, I made sure I only supported strings as There's also the issue of what if I messed up and passed in something that has a string representation for You can read https://www.python.org/dev/peps/pep-0519/ for the historical details of this. |
Beta Was this translation helpful? Give feedback.
It's to prevent potential errors from me. 😄 When you take something like a pathlib object, it can have either a string or bytes representation of the path. Since the Python Launcher only supports file paths that can be decoded to a string, I made sure I only supported strings as
os.fsdecode()
will fail if it can't translate a file path.There's also the issue of what if I messed up and passed in something that has a string representation for
VENV_EXECUTABLE
, likeNone
?os.fsdecode()
will throw an exception, but just relying on string translation forNone
will always succeed, leading to potentially subtle errors.You can read https://www.python.org/dev/peps/pep-0519/ for the historical det…