File tree Expand file tree Collapse file tree 1 file changed +20
-11
lines changed
Filter options
Expand file tree Collapse file tree 1 file changed +20
-11
lines changed
Original file line number Diff line number Diff line change @@ -986,6 +986,25 @@ hashtable_destroy_str(void *ptr)
986
986
987
987
#define HTSEP ':'
988
988
989
+ static int
990
+ _extensions_cache_init (void )
991
+ {
992
+ _Py_hashtable_allocator_t alloc = {PyMem_RawMalloc , PyMem_RawFree };
993
+ EXTENSIONS .hashtable = _Py_hashtable_new_full (
994
+ hashtable_hash_str ,
995
+ hashtable_compare_str ,
996
+ hashtable_destroy_str , // key
997
+ /* There's no need to decref the def since it's immortal. */
998
+ NULL , // value
999
+ & alloc
1000
+ );
1001
+ if (EXTENSIONS .hashtable == NULL ) {
1002
+ PyErr_NoMemory ();
1003
+ return -1 ;
1004
+ }
1005
+ return 0 ;
1006
+ }
1007
+
989
1008
static PyModuleDef *
990
1009
_extensions_cache_get (PyObject * filename , PyObject * name )
991
1010
{
@@ -1023,17 +1042,7 @@ _extensions_cache_set(PyObject *filename, PyObject *name, PyModuleDef *def)
1023
1042
extensions_lock_acquire ();
1024
1043
1025
1044
if (EXTENSIONS .hashtable == NULL ) {
1026
- _Py_hashtable_allocator_t alloc = {PyMem_RawMalloc , PyMem_RawFree };
1027
- EXTENSIONS .hashtable = _Py_hashtable_new_full (
1028
- hashtable_hash_str ,
1029
- hashtable_compare_str ,
1030
- hashtable_destroy_str , // key
1031
- /* There's no need to decref the def since it's immortal. */
1032
- NULL , // value
1033
- & alloc
1034
- );
1035
- if (EXTENSIONS .hashtable == NULL ) {
1036
- PyErr_NoMemory ();
1045
+ if (_extensions_cache_init () < 0 ) {
1037
1046
goto finally ;
1038
1047
}
1039
1048
}
You can’t perform that action at this time.
0 commit comments