Return C{path} as a string of L{unicode} suitable for use on this system's filesystem. @param path: The path to be made suitable. @type path: L{bytes} or L{unicode} @param encoding: The encoding to use if coercing to L{unicode}. If none is given, L{sys.getfilesystemenc
(path: bytes | str, encoding: str | None = None)
| 711 | |
| 712 | |
| 713 | def _asFilesystemText(path: bytes | str, encoding: str | None = None) -> str: |
| 714 | """ |
| 715 | Return C{path} as a string of L{unicode} suitable for use on this system's |
| 716 | filesystem. |
| 717 | |
| 718 | @param path: The path to be made suitable. |
| 719 | @type path: L{bytes} or L{unicode} |
| 720 | |
| 721 | @param encoding: The encoding to use if coercing to L{unicode}. If none |
| 722 | is given, L{sys.getfilesystemencoding} is used. |
| 723 | |
| 724 | @return: L{unicode} |
| 725 | """ |
| 726 | if isinstance(path, str): |
| 727 | return path |
| 728 | else: |
| 729 | if encoding is None: |
| 730 | encoding = sys.getfilesystemencoding() |
| 731 | return path.decode(encoding, errors="surrogateescape") |
| 732 | |
| 733 | |
| 734 | def _coerceToFilesystemEncoding( |
no test coverage detected