@@ -6816,14 +6816,14 @@ def testSendAndRecvFds(self):
68166816 socket .send_fds (sock1 , [MSG ], self .rds )
68176817 # receive them on sock2
68186818 # allocate space for more data and file descriptors than expected
6819- msg , rds2 , flags , addr = socket .recv_fds (
6819+ msg , rds2 , msg_flags , addr = socket .recv_fds (
68206820 sock2 , len (MSG ) * 2 , len (self .rds ) * 2
68216821 )
68226822 self .addCleanup (self .close_fds , rds2 )
68236823
68246824 self .assertEqual (msg , MSG )
68256825 self .assertEqual (len (rds2 ), len (self .rds ))
6826- self .assertEqual (flags , 0 )
6826+ self .assertEqual (msg_flags , 0 )
68276827 # addr contains no useful info and is not checked
68286828 self .check_pipes_connected (self .wds , rds2 )
68296829
@@ -6837,33 +6837,40 @@ def testRecvFlags(self):
68376837 socket .send_fds (sock1 , [MSG ], self .rds )
68386838 # receive them on sock2, with socket.MSG_PEEK
68396839 # allocate space for more data and file descriptors than expected
6840- msg , rds2 , flags , addr = socket .recv_fds (
6840+ msg , rds2 , msg_flags , addr = socket .recv_fds (
68416841 sock2 , len (MSG ) * 2 , len (self .rds ) * 2 , socket .MSG_PEEK
68426842 )
68436843
68446844 self .assertEqual (msg , MSG )
68456845 self .assertEqual (len (rds2 ), len (self .rds ))
6846- # flags can be 0 or socket.MSG_PEEK:
6847- self .assertEqual (flags & ~ socket .MSG_PEEK , 0 )
6848- # don't test addr for anonymous socket pair
6849- # when PEEKing, rds2 are not open fds and should be all 0s
6850- self .assertEqual (rds2 , [0 ]* len (rds2 ))
6846+ # msg_flags can be 0 or socket.MSG_PEEK:
6847+ self .assertEqual (msg_flags & ~ socket .MSG_PEEK , 0 )
6848+ # addr contains no useful info and is not checked
6849+ if msg_flags == 0 :
6850+ # rds2 are open and connected
6851+ self .addCleanup (self .close_fds , rds2 )
6852+ self .check_pipes_connected (self .wds , rds2 )
6853+ elif msg_flags == socket .MSG_PEEK :
6854+ # rds2 are not open fds and should be all 0s
6855+ self .assertEqual (rds2 , [0 ]* len (rds2 ))
6856+ else :
6857+ assert False , "message msg_flags has unexpected value"
68516858
68526859 # receive again without socket.MSG_PEEK
6853- msg , rds2 , flags , addr = socket .recv_fds (
6860+ msg , rds2 , msg_flags , addr = socket .recv_fds (
68546861 sock2 , len (MSG ) * 2 , len (self .rds ) * 2
68556862 )
68566863 self .addCleanup (self .close_fds , rds2 )
68576864
68586865 self .assertEqual (msg , MSG )
68596866 self .assertEqual (len (rds2 ), len (self .rds ))
6860- self .assertEqual (flags , 0 )
6867+ self .assertEqual (msg_flags , 0 )
68616868 # addr contains no useful info and is not checked
68626869 self .check_pipes_connected (self .wds , rds2 )
68636870
68646871 # check that there is no more data waiting
68656872 with self .assertRaises (BlockingIOError ):
6866- msg , rds2 , flags , addr = socket .recv_fds (
6873+ msg , rds2 , msg_flags , addr = socket .recv_fds (
68676874 sock2 , len (MSG ) * 2 , len (self .rds ) * 2
68686875 )
68696876
@@ -6881,14 +6888,14 @@ def testSendAddress(self):
68816888 # send from sock2
68826889 socket .send_fds (sock2 , [MSG ], self .rds , address = sockpth )
68836890 # receive on sock1
6884- msg , rds2 , flags , addr = socket .recv_fds (
6891+ msg , rds2 , msg_flags , addr = socket .recv_fds (
68856892 sock1 , len (MSG ) * 2 , len (self .rds ) * 2
68866893 )
68876894 self .addCleanup (self .close_fds , rds2 )
68886895
68896896 self .assertEqual (msg , MSG )
68906897 self .assertEqual (len (rds2 ), len (self .rds ))
6891- self .assertEqual (flags , 0 )
6898+ self .assertEqual (msg_flags , 0 )
68926899 # addr contains no useful info and is not checked
68936900 self .check_pipes_connected (self .wds , rds2 )
68946901
0 commit comments