File tree Expand file tree Collapse file tree 1 file changed +27
-1
lines changed Expand file tree Collapse file tree 1 file changed +27
-1
lines changed Original file line number Diff line number Diff line change 11/* Common code for use by all hashlib related modules. */ 
22
3- #include  "pycore_lock.h"         // PyMutex 
3+ #include  "pycore_lock.h"             // PyMutex 
4+ #include  "pycore_moduleobject.h"     // _PyModule_GetDef() 
5+ 
6+ #ifndef  NDEBUG 
7+ /* 
8+  * Assert that a type cannot be subclassed and that 
9+  * its associated module definition matches 'moddef'. 
10+  * 
11+  * Use this helper to ensure that _PyType_GetModuleState() can be safely used. 
12+  */ 
13+ static  inline  void 
14+ _Py_hashlib_check_exported_type (PyTypeObject  * type , PyModuleDef  * moddef )
15+ {
16+     assert (type  !=  NULL );
17+     assert (moddef  !=  NULL );
18+     /* ensure that the type is a final heap type */ 
19+     assert (PyType_Check (type ));
20+     assert (type -> tp_flags  &  Py_TPFLAGS_HEAPTYPE );
21+     assert (!(type -> tp_flags  &  Py_TPFLAGS_BASETYPE ));
22+     /* ensure that the associated module definition matches 'moddef' */ 
23+     PyHeapTypeObject  * ht  =  (PyHeapTypeObject  * )type ;
24+     assert (ht -> ht_module  !=  NULL );
25+     assert (moddef  ==  _PyModule_GetDef (ht -> ht_module ));
26+ }
27+ #else 
28+ #define  _Py_hashlib_check_exported_type (_TYPE , _MODDEF )
29+ #endif 
430
531/* 
632 * Given a PyObject* obj, fill in the Py_buffer* viewp with the result 
    
 
   
 
     
   
   
          
     
  
    
     
 
    
      
     
 
     
    You can’t perform that action at this time.
  
 
    
  
     
    
      
        
     
 
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments