@@ -22,6 +22,12 @@ interface).
2222Extensions peculiar to a particular operating system are also available through
2323the :mod: `os ` module, but using them is of course a threat to portability!
2424
25+ .. note ::
26+
27+ All functions accepting path or file names accept both bytes and string
28+ objects, and result in an object of the same type, if a path or file name is
29+ returned.
30+
2531.. note ::
2632
2733 If not separately noted, all functions that claim "Availability: Unix" are
@@ -693,15 +699,16 @@ Files and Directories
693699
694700.. function :: getcwd()
695701
696- Return a string representing the current working directory.
697- May raise UnicodeDecodeError if the current directory path fails
698- to decode in the file system encoding.
699- Availability: Unix, Windows.
702+ Return a string representing the current working directory. On Unix
703+ platforms, this function may raise :exc: `UnicodeDecodeError ` if the name of
704+ the current directory is not decodable in the file system encoding. Use
705+ :func: `getcwdb ` if you need the call to never fail. Availability: Unix,
706+ Windows.
700707
701708
702709.. function :: getcwdb()
703710
704- Return a bytestring representing the current working directory.
711+ Return a bytestring representing the current working directory.
705712 Availability: Unix, Windows.
706713
707714
@@ -798,15 +805,15 @@ Files and Directories
798805
799806.. function :: listdir(path)
800807
801- Return a list containing the names of the entries in the directory. The list is
802- in arbitrary order. It does not include the special entries ``'.' `` and
803- ``'..' `` even if they are present in the directory. Availability:
804- Unix, Windows.
808+ Return a list containing the names of the entries in the directory. The list
809+ is in arbitrary order. It does not include the special entries ``. `` and
810+ ``.. `` even if they are present in the directory. Availability: Unix,
811+ Windows.
805812
806- If * path * is a Unicode object, the result will be a list of Unicode objects.
807- If a filename can not be decoded to unicode, it is skipped. If * path * is a
808- bytes string, the result will be list of bytes objects included files
809- skipped by the unicode version .
813+ This function can be called with a bytes or string argument. In the bytes
814+ case, all filenames will be listed as returned by the underlying API. In the
815+ string case, filenames will be decoded using the file system encoding, and
816+ skipped if a decoding error occurs .
810817
811818
812819.. function :: lstat(path)
@@ -920,9 +927,9 @@ Files and Directories
920927 be converted to an absolute pathname using ``os.path.join(os.path.dirname(path),
921928 result) ``.
922929
923- If the *path * is an Unicode object, the result will also be a Unicode object
924- and may raise an UnicodeDecodeError. If the *path * is a bytes object, the
925- result will be a bytes object.
930+ If the *path * is a string object, the result will also be a string object,
931+ and the call may raise an UnicodeDecodeError. If the *path * is a bytes
932+ object, the result will be a bytes object.
926933
927934 Availability: Unix.
928935
0 commit comments