File tree Expand file tree Collapse file tree 1 file changed +11
-8
lines changed Expand file tree Collapse file tree 1 file changed +11
-8
lines changed Original file line number Diff line number Diff line change @@ -2541,12 +2541,10 @@ _PyBytes_FromHex(PyObject *string, int use_bytearray)
25412541        }
25422542        str ++ ;
25432543
2544-         /* Check if we have a second digit*/ 
2544+         /* Check if we have a second digit  */ 
25452545        if  (str  >= end ) {
2546-             PyErr_SetString (PyExc_ValueError ,
2547-                            "fromhex() arg must be of even length" );
2548-             _PyBytesWriter_Dealloc (& writer );
2549-             return  NULL ;
2546+             invalid_char  =  -2 ;
2547+             goto error ;
25502548        }
25512549
25522550        bot  =  _PyLong_DigitValue [* str ];
@@ -2562,9 +2560,14 @@ _PyBytes_FromHex(PyObject *string, int use_bytearray)
25622560    return  _PyBytesWriter_Finish (& writer , buf );
25632561
25642562  error :
2565-     PyErr_Format (PyExc_ValueError ,
2566-                  "non-hexadecimal number found in " 
2567-                  "fromhex() arg at position %zd" , invalid_char );
2563+     if  (invalid_char  ==  -2 ) {
2564+         PyErr_SetString (PyExc_ValueError ,
2565+                         "fromhex() arg must be of even length" );
2566+     } else  {
2567+         PyErr_Format (PyExc_ValueError ,
2568+                      "non-hexadecimal number found in " 
2569+                      "fromhex() arg at position %zd" , invalid_char );
2570+     }
25682571    _PyBytesWriter_Dealloc (& writer );
25692572    return  NULL ;
25702573}
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments