File tree Expand file tree Collapse file tree 1 file changed +7
-9
lines changed Expand file tree Collapse file tree 1 file changed +7
-9
lines changed Original file line number Diff line number Diff line change @@ -174,18 +174,16 @@ _testcapi_float_set_snan(PyObject *module, PyObject *obj)
174174        PyErr_SetString (PyExc_ValueError , "float-point number expected" );
175175        return  NULL ;
176176    }
177-     PyObject  * ret  =  PyNumber_Positive (obj );
178-     if  (!ret ) {
179-         return  NULL ;
180-     }
181-     double  * d  =  & ((PyFloatObject  * )ret )-> ob_fval ;
182-     if  (!isnan (* d )) {
177+     double  d  =  ((PyFloatObject  * )obj )-> ob_fval ;
178+     if  (!isnan (d )) {
183179        PyErr_SetString (PyExc_ValueError , "nan expected" );
184180        return  NULL ;
185181    }
186-     uint64_t  * v  =  (uint64_t  * )d ;
187-     * v  &= ~(1ULL <<51 ); /* make sNaN */ 
188-     return  ret ;
182+     uint64_t  v ;
183+     memcpy (& v , & d , 8 );
184+     v  &= ~(1ULL <<51 ); /* make sNaN */ 
185+     memcpy (& d , & v , 8 );
186+     return  PyFloat_FromDouble (d );
189187}
190188
191189static  PyMethodDef  test_methods [] =  {
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments