No. A unix filename is just a bunch of bytes (two of them being off-limits). There is no requirement that it be in any encoding.
You can always use a fallback encoding (an iso-8859) to get something out of the garbage, but it's just that, garbage.
Windows has a similar issue, NTFS paths are sequences of UCS2 code units, but there's no guarantee that they form any sort of valid UTF-16 string, you can find random lone surrogates for instance.
And I'm sure network filesystems have invented their own even worse issues, because being awful is what they do.
> Why wouldn’t Python just always use the same encoding as the OS it’s running on?
1. because OS don't really have encodings, Python has a function to try and retrieve FS encoding[0] but per the above there's no requirement that it is correct for any file, let alone the one you actually want to open (hell technically speaking it's not even a property of the FS)
2. because OS lie and user configurations are garbage, you can't even trust the user's locale to be configured properly for reading files (an other mistake Python 3 made, incidentally)
3. because the user may not even have created the file, it might come from a broken archive, or some random download from someone having fun with filenames, or from fetching crap from an FTP or network share
There are a few FS / FS configurations which are reliable, in that case they either error or pre-mangle the files on intake.
IIRC ZFS can be configured to only accept valid UTF-8 filenames, HFS(+) requires valid unicode (stored as UTF-16) and APFS does as well (stored as UTF-8).
[0] https://docs.python.org/3/library/sys.html#sys.getfilesystem...
> touch `echo 00: DEADBEEF | xxd -r`
> ls
'ޭ'$'\276\357'