File tree Expand file tree Collapse file tree 2 files changed +17
-0
lines changed Expand file tree Collapse file tree 2 files changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -4878,6 +4878,19 @@ def test_interrupted_write_retry_buffered(self):
4878
4878
def test_interrupted_write_retry_text (self ):
4879
4879
self .check_interrupted_write_retry ("x" , mode = "w" , encoding = "latin1" )
4880
4880
4881
+ def test_read_non_blocking (self ):
4882
+ import os
4883
+
4884
+ r , w = os .pipe ()
4885
+ try :
4886
+ os .set_blocking (r , False )
4887
+ with open (r , 'r' ) as textfile :
4888
+ r = None
4889
+ self .assertIsNone (textfile .read ())
4890
+ finally :
4891
+ if r is not None :
4892
+ os .close (r )
4893
+ os .close (w )
4881
4894
4882
4895
class CSignalsTest (SignalsTest ):
4883
4896
io = io
Original file line number Diff line number Diff line change @@ -1992,6 +1992,10 @@ _io_TextIOWrapper_read_impl(textio *self, Py_ssize_t n)
1992
1992
if (bytes == NULL )
1993
1993
goto fail ;
1994
1994
1995
+ if (bytes == Py_None ) {
1996
+ return Py_None ;
1997
+ }
1998
+
1995
1999
_PyIO_State * state = self -> state ;
1996
2000
if (Py_IS_TYPE (self -> decoder , state -> PyIncrementalNewlineDecoder_Type ))
1997
2001
decoded = _PyIncrementalNewlineDecoder_decode (self -> decoder ,
You can’t perform that action at this time.
0 commit comments