MCPcopy Index your code
hub / github.com/RustPython/RustPython / fsencode

Function fsencode

Lib/os.py:851–861  ·  view source on GitHub ↗

Encode filename (an os.PathLike, bytes, or str) to the filesystem encoding with 'surrogateescape' error handler, return bytes unchanged. On Windows, use 'strict' error handler if the file system encoding is 'mbcs' (which is the default encoding).

(filename)

Source from the content-addressed store, hash-verified

849 errors = sys.getfilesystemencodeerrors()
850
851 def fsencode(filename):
852 """Encode filename (an os.PathLike, bytes, or str) to the filesystem
853 encoding with 'surrogateescape' error handler, return bytes unchanged.
854 On Windows, use 'strict' error handler if the file system encoding is
855 'mbcs' (which is the default encoding).
856 """
857 filename = fspath(filename) # Does type-checking of `filename`.
858 if isinstance(filename, str):
859 return filename.encode(encoding, errors)
860 else:
861 return filename
862
863 def fsdecode(filename):
864 """Decode filename (an os.PathLike, bytes, or str) from the filesystem

Callers 3

_fwalkFunction · 0.85
_execvpeFunction · 0.85
_iterdirFunction · 0.85

Calls 3

isinstanceFunction · 0.85
fspathFunction · 0.70
encodeMethod · 0.45

Tested by

no test coverage detected