@@ -113,18 +113,14 @@ def test_getcode(self):
113113 self .assertEqual (code , 404 )
114114
115115 def test_fileno (self ):
116- if (sys .platform in ('win32' ,) or
117- not hasattr (os , 'fdopen' )):
116+ if sys .platform in ('win32' ,):
118117 # On Windows, socket handles are not file descriptors; this
119118 # test can't pass on Windows.
120119 return
121120 # Make sure fd returned by fileno is valid.
122121 open_url = self .urlopen ("http://www.python.org/" )
123122 fd = open_url .fileno ()
124- # XXX(nnorwitz): There is currently no way to pass errors, encoding,
125- # etc to fdopen. :-(
126- FILE = os .fdopen (fd )
127- FILE ._errors = 'ignore'
123+ FILE = os .fdopen (fd , encoding = 'utf-8' )
128124 try :
129125 self .assert_ (FILE .read (), "reading from file created using fd "
130126 "returned by fileno failed" )
@@ -156,7 +152,7 @@ def test_basic(self):
156152 file_location ,info = self .urlretrieve ("http://www.python.org/" )
157153 self .assert_ (os .path .exists (file_location ), "file location returned by"
158154 " urlretrieve is not a valid path" )
159- FILE = open (file_location , errors = 'ignore ' )
155+ FILE = open (file_location , encoding = 'utf-8 ' )
160156 try :
161157 self .assert_ (FILE .read (), "reading from the file location returned"
162158 " by urlretrieve failed" )
@@ -170,7 +166,7 @@ def test_specified_path(self):
170166 support .TESTFN )
171167 self .assertEqual (file_location , support .TESTFN )
172168 self .assert_ (os .path .exists (file_location ))
173- FILE = open (file_location , errors = 'ignore ' )
169+ FILE = open (file_location , encoding = 'utf-8 ' )
174170 try :
175171 self .assert_ (FILE .read (), "reading from temporary file failed" )
176172 finally :
0 commit comments