diff options
Diffstat (limited to 'Lib/os.py')
-rw-r--r-- | Lib/os.py | 11 |
1 files changed, 11 insertions, 0 deletions
@@ -504,6 +504,17 @@ if name not in ('os2', 'nt'): return environb.get(key, default) __all__.append("getenvb") +if name != 'nt': + def fsencode(value): + """Encode value for use in the file system, environment variables + or the command line.""" + if isinstance(value, bytes): + return value + elif isinstance(value, str): + return value.encode(sys.getfilesystemencoding(), 'surrogateescape') + else: + raise TypeError("expect bytes or str, not %s" % type(value).__name__) + def _exists(name): return name in globals() |