File tree Expand file tree Collapse file tree 2 files changed +11
-1
lines changed Expand file tree Collapse file tree 2 files changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -39,6 +39,14 @@ def test_compilation(self):
3939
4040                    self .assertDictEqual (actual ._catalog , expected ._catalog )
4141
42+     def  test_po_with_bom (self ):
43+         with  temp_cwd ():
44+             Path ('bom.po' ).write_bytes (b'\xef \xbb \xbf msgid "Python"\n msgstr "Pioton"\n ' )
45+ 
46+             res  =  assert_python_failure (msgfmt , 'bom.po' )
47+             err  =  res .err .decode ('utf-8' )
48+             self .assertIn ('The file bom.po starts with a UTF-8 BOM' , err )
49+ 
4250    def  test_invalid_msgid_plural (self ):
4351        with  temp_cwd ():
4452            Path ('invalid.po' ).write_text ('''\  
Original file line number Diff line number Diff line change 3535
3636__version__  =  "1.2" 
3737
38+ import  codecs 
39+ 
3840MESSAGES  =  {}
3941
4042
@@ -117,7 +119,7 @@ def make(filename, outfile):
117119        sys .exit (1 )
118120
119121    # Check for UTF-8 BOM 
120-     if  lines [0 ].startswith (b' \xef \xbb \xbf '  ):
122+     if  lines [0 ].startswith (codecs . BOM_UTF8 ):
121123        print (
122124            f"The file { infile }   starts with a UTF-8 BOM which is not allowed in .po files.\n " 
123125            "Please save the file without a BOM and try again." ,
    
 
   
 
     
   
   
          
     
  
    
     
 
    
      
     
 
     
    You can’t perform that action at this time.
  
 
    
  
     
    
      
        
     
 
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments