File tree Expand file tree Collapse file tree 1 file changed +9
-16
lines changed Expand file tree Collapse file tree 1 file changed +9
-16
lines changed Original file line number Diff line number Diff line change @@ -2542,19 +2542,6 @@ _PyBytes_FromHex(PyObject *string, int use_bytearray)
25422542        }
25432543        str ++ ;
25442544
2545-         /* Skip spaces after first digit */ 
2546-         while  (str  <  end  &&  Py_ISSPACE (* str )) {
2547-             str ++ ;
2548-         }
2549- 
2550-         /* Check if we have a second digit*/ 
2551-         if  (str  >= end ) {
2552-             PyErr_SetString (PyExc_ValueError ,
2553-                            "fromhex() arg must be of even length" );
2554-             _PyBytesWriter_Dealloc (& writer );
2555-             return  NULL ;
2556-         }
2557- 
25582545        /* Check second hex digit */ 
25592546        bot  =  _PyLong_DigitValue [* str ];
25602547        if  (bot  >= 16 ) {
@@ -2569,9 +2556,15 @@ _PyBytes_FromHex(PyObject *string, int use_bytearray)
25692556    return  _PyBytesWriter_Finish (& writer , buf );
25702557
25712558  error :
2572-     PyErr_Format (PyExc_ValueError ,
2573-                  "non-hexadecimal number found in " 
2574-                  "fromhex() arg at position %zd" , invalid_char );
2559+     if  (str  >= end ) {
2560+         PyErr_SetString (PyExc_ValueError ,
2561+                         "fromhex() arg must be of even length" );
2562+     }
2563+     else  {
2564+         PyErr_Format (PyExc_ValueError ,
2565+                      "non-hexadecimal number found in " 
2566+                      "fromhex() arg at position %zd" , invalid_char );
2567+     }
25752568    _PyBytesWriter_Dealloc (& writer );
25762569    return  NULL ;
25772570}
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments