File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -792,6 +792,36 @@ def test_pythontypes(self):
792792 # sys.flags
793793 check (sys .flags , size (vh ) + self .P * len (sys .flags ))
794794
795+ def test_getfilesystemencoding (self ):
796+ import codecs
797+
798+ def check_fsencoding (fs_encoding ):
799+ if sys .platform == 'darwin' :
800+ self .assertEqual (fs_encoding , 'utf-8' )
801+ elif fs_encoding is None :
802+ return
803+ codecs .lookup (fs_encoding )
804+
805+ fs_encoding = sys .getfilesystemencoding ()
806+ check_fsencoding (fs_encoding )
807+
808+ # Even in C locale
809+ try :
810+ sys .executable .encode ('ascii' )
811+ except UnicodeEncodeError :
812+ # Python doesn't start with ASCII locale if its path is not ASCII,
813+ # see issue #8611
814+ pass
815+ else :
816+ env = os .environ .copy ()
817+ env ['LANG' ] = 'C'
818+ output = subprocess .check_output (
819+ [sys .executable , "-c" ,
820+ "import sys; print(sys.getfilesystemencoding())" ],
821+ env = env )
822+ fs_encoding = output .rstrip ().decode ('ascii' )
823+ check_fsencoding (fs_encoding )
824+
795825 def test_setfilesystemencoding (self ):
796826 old = sys .getfilesystemencoding ()
797827 try :
You can’t perform that action at this time.
0 commit comments