@@ -2814,8 +2814,41 @@ def test_invalid_family_win32(self):
28142814 with self .assertRaises (ValueError ):
28152815 multiprocessing .connection .Listener ('/var/test.pipe' )
28162816
2817+ #
2818+ # Issue 12098: check sys.flags of child matches that for parent
2819+ #
2820+
2821+ class TestFlags (unittest .TestCase ):
2822+ @classmethod
2823+ def run_in_grandchild (cls , conn ):
2824+ conn .send (tuple (sys .flags ))
2825+
2826+ @classmethod
2827+ def run_in_child (cls ):
2828+ import json
2829+ r , w = multiprocessing .Pipe (duplex = False )
2830+ p = multiprocessing .Process (target = cls .run_in_grandchild , args = (w ,))
2831+ p .start ()
2832+ grandchild_flags = r .recv ()
2833+ p .join ()
2834+ r .close ()
2835+ w .close ()
2836+ flags = (tuple (sys .flags ), grandchild_flags )
2837+ print (json .dumps (flags ))
2838+
2839+ def test_flags (self ):
2840+ import json , subprocess
2841+ # start child process using unusual flags
2842+ prog = ('from test.test_multiprocessing import TestFlags; ' +
2843+ 'TestFlags.run_in_child()' )
2844+ data = subprocess .check_output (
2845+ [sys .executable , '-E' , '-S' , '-O' , '-c' , prog ])
2846+ child_flags , grandchild_flags = json .loads (data .decode ('ascii' ))
2847+ self .assertEqual (child_flags , grandchild_flags )
2848+
28172849testcases_other = [OtherTest , TestInvalidHandle , TestInitializers ,
2818- TestStdinBadfiledescriptor , TestWait , TestInvalidFamily ]
2850+ TestStdinBadfiledescriptor , TestWait , TestInvalidFamily ,
2851+ TestFlags ]
28192852
28202853#
28212854#
0 commit comments