@@ -645,8 +645,7 @@ system.
645
645
cannot contain embedded null characters.
646
646
647
647
Use :c:func:`PyUnicode_DecodeFSDefaultAndSize` to decode a string from
648
- :c:data:`Py_FileSystemDefaultEncoding` (the locale encoding read at
649
- Python startup).
648
+ the :term:`filesystem encoding and error handler`.
650
649
651
650
This function ignores the :ref:`Python UTF-8 Mode <utf8-mode>`.
652
651
@@ -680,9 +679,8 @@ system.
680
679
*errors* is ``NULL``. Return a :class:`bytes` object. *unicode* cannot
681
680
contain embedded null characters.
682
681
683
- Use :c:func:`PyUnicode_EncodeFSDefault` to encode a string to
684
- :c:data:`Py_FileSystemDefaultEncoding` (the locale encoding read at
685
- Python startup).
682
+ Use :c:func:`PyUnicode_EncodeFSDefault` to encode a string to the
683
+ :term:`filesystem encoding and error handler`.
686
684
687
685
This function ignores the :ref:`Python UTF-8 Mode <utf8-mode>`.
688
686
@@ -703,12 +701,12 @@ system.
703
701
File System Encoding
704
702
""""""""""""""""""""
705
703
706
- To encode and decode file names and other environment strings,
707
- :c:data:`Py_FileSystemDefaultEncoding` should be used as the encoding, and
708
- :c:data:`Py_FileSystemDefaultEncodeErrors` should be used as the error handler
709
- ( :pep: ` 383 ` and :pep: ` 529 `). To encode file names to :class:`bytes` during
710
- argument parsing, the ``"O&"`` converter should be used, passing
711
- :c:func:`PyUnicode_FSConverter` as the conversion function:
704
+ Functions encoding to and decoding from the :term:`filesystem encoding and
705
+ error handler` ( :pep: ` 383 ` and :pep: ` 529 `).
706
+
707
+ To encode file names to :class:`bytes` during argument parsing, the ``"O&"``
708
+ converter should be used, passing :c:func:`PyUnicode_FSConverter` as the
709
+ conversion function:
712
710
713
711
.. c:function:: int PyUnicode_FSConverter(PyObject* obj, void* result)
714
712
@@ -745,49 +743,39 @@ conversion function:
745
743
746
744
Decode a string from the :term: `filesystem encoding and error handler `.
747
745
748
- If :c:data: `Py_FileSystemDefaultEncoding ` is not set, fall back to the
749
- locale encoding.
750
-
751
- :c:data: `Py_FileSystemDefaultEncoding ` is initialized at startup from the
752
- locale encoding and cannot be modified later. If you need to decode a string
753
- from the current locale encoding, use
746
+ If you need to decode a string from the current locale encoding, use
754
747
:c:func: `PyUnicode_DecodeLocaleAndSize `.
755
748
756
749
.. seealso ::
757
750
758
751
The :c:func: `Py_DecodeLocale ` function.
759
752
760
753
.. versionchanged :: 3.6
761
- Use :c:data: `Py_FileSystemDefaultEncodeErrors ` error handler.
754
+ The :term: `filesystem error handler <filesystem encoding and error
755
+ handler> ` is now used.
762
756
763
757
764
758
.. c :function :: PyObject* PyUnicode_DecodeFSDefault (const char *s)
765
759
766
760
Decode a null-terminated string from the :term: `filesystem encoding and
767
761
error handler `.
768
762
769
- If :c:data: `Py_FileSystemDefaultEncoding ` is not set, fall back to the
770
- locale encoding.
771
-
772
- Use :c:func: `PyUnicode_DecodeFSDefaultAndSize ` if you know the string length.
763
+ If the string length is known, use
764
+ :c:func: `PyUnicode_DecodeFSDefaultAndSize `.
773
765
774
766
.. versionchanged :: 3.6
775
- Use :c:data: `Py_FileSystemDefaultEncodeErrors ` error handler.
767
+ The :term: `filesystem error handler <filesystem encoding and error
768
+ handler> ` is now used.
776
769
777
770
778
771
.. c :function :: PyObject* PyUnicode_EncodeFSDefault (PyObject *unicode)
779
772
780
- Encode a Unicode object to :c:data: `Py_FileSystemDefaultEncoding ` with the
781
- :c:data: `Py_FileSystemDefaultEncodeErrors ` error handler, and return
782
- :class: `bytes `. Note that the resulting :class: `bytes ` object may contain
783
- null bytes.
784
-
785
- If :c:data: `Py_FileSystemDefaultEncoding ` is not set, fall back to the
786
- locale encoding.
773
+ Encode a Unicode object to the :term: `filesystem encoding and error
774
+ handler `, and return :class: `bytes `. Note that the resulting :class: `bytes `
775
+ object can contain null bytes.
787
776
788
- :c:data: `Py_FileSystemDefaultEncoding ` is initialized at startup from the
789
- locale encoding and cannot be modified later. If you need to encode a string
790
- to the current locale encoding, use :c:func: `PyUnicode_EncodeLocale `.
777
+ If you need to encode a string to the current locale encoding, use
778
+ :c:func: `PyUnicode_EncodeLocale `.
791
779
792
780
.. seealso ::
793
781
@@ -796,7 +784,8 @@ conversion function:
796
784
.. versionadded :: 3.2
797
785
798
786
.. versionchanged :: 3.6
799
- Use :c:data: `Py_FileSystemDefaultEncodeErrors ` error handler.
787
+ The :term: `filesystem error handler <filesystem encoding and error
788
+ handler> ` is now used.
800
789
801
790
wchar_t Support
802
791
"""""""""""""""
@@ -861,10 +850,7 @@ constructor.
861
850
Setting encoding to ``NULL`` causes the default encoding to be used
862
851
which is UTF-8. The file system calls should use
863
852
:c:func:`PyUnicode_FSConverter` for encoding file names. This uses the
864
- variable :c:data:`Py_FileSystemDefaultEncoding` internally. This
865
- variable should be treated as read-only: on some systems, it will be a
866
- pointer to a static string, on others, it will change at run-time
867
- (such as when the application invokes setlocale).
853
+ :term:`filesystem encoding and error handler` internally.
868
854
869
855
Error handling is set by errors which may also be set to ``NULL`` meaning to use
870
856
the default handling defined for the codec. Default error handling for all
0 commit comments