@@ -816,7 +816,7 @@ def test_keyboard_interrupt_exit_status(self):
816816 cli = runpy .run_path (self .SCRIPT )
817817 args = [self .SCRIPT , '/a' , os .path .join (self .dir , 'a.json' )]
818818 with mock .patch .object (sys , 'argv' , args ), \
819- mock .patch ('json.load ' , side_effect = KeyboardInterrupt ):
819+ mock .patch ('json.loads ' , side_effect = KeyboardInterrupt ):
820820 with self .assertRaises (SystemExit ) as caught :
821821 cli ['main' ]()
822822 self .assertEqual (caught .exception .code , 130 )
@@ -836,6 +836,20 @@ def test_utf8_pointer_file_without_utf8_mode(self):
836836 self .assertEqual (json .loads (proc .stdout ), 'expected' )
837837 self .assertEqual (proc .stderr , '' )
838838
839+ def test_utf8_piped_input_with_legacy_stdio_encoding (self ):
840+ self ._write ('unicode.json' , json .dumps ({'ä' : 'expected' , 'ä' : 'wrong' }))
841+ env = dict (os .environ , PYTHONPATH = self .ROOT , PYTHONUTF8 = '0' ,
842+ PYTHONIOENCODING = 'cp1252' )
843+ for args , stdin in ((['/ä' , '-' ], '{"ä": "expected"}' ),
844+ (['-f' , '-' , 'unicode.json' ], '/ä\n ' )):
845+ with self .subTest (args = args ):
846+ proc = subprocess .run ([sys .executable , self .SCRIPT ] + args ,
847+ cwd = self .dir , env = env , capture_output = True ,
848+ input = stdin .encode ('utf-8' ))
849+ self .assertEqual (proc .returncode , 0 , proc .stderr )
850+ self .assertEqual (json .loads (proc .stdout ), 'expected' )
851+ self .assertEqual (proc .stderr , b'' )
852+
839853 def test_positional_pointer (self ):
840854 proc = self ._run ('/a' , 'a.json' , 'b.json' )
841855 self .assertEqual (proc .returncode , 0 , proc .stderr )
0 commit comments