@@ -974,9 +974,9 @@ winreg_CreateKeyEx_impl(PyObject *module, HKEY key, const wchar_t *sub_key,
974974 long rc ;
975975 DWORD disposition ;
976976
977- if (PySys_Audit ("winreg.CreateKey" , "nun " ,
977+ if (PySys_Audit ("winreg.CreateKey" , "nunii " ,
978978 (Py_ssize_t )key , sub_key ,
979- (Py_ssize_t )access ) < 0 ) {
979+ (Py_ssize_t )access , options , create_only ) < 0 ) {
980980 return NULL ;
981981 }
982982 rc = RegCreateKeyExW (key , sub_key , reserved , NULL , options ,
@@ -985,19 +985,21 @@ winreg_CreateKeyEx_impl(PyObject *module, HKEY key, const wchar_t *sub_key,
985985 PyErr_SetFromWindowsErrWithFunction (rc , "CreateKeyEx" );
986986 return NULL ;
987987 }
988- if (PySys_Audit ("winreg.OpenKey/result" , "n" ,
989- (Py_ssize_t )retKey ) < 0 ) {
990- return NULL ;
991- }
992988 if (create_only == TRUE) {
993989 if (disposition == REG_OPENED_EXISTING_KEY ) {
994990 PyErr_SetString (PyExc_FileExistsError , "" );
995991 if (retKey != key ) {
992+ // This is predefined key and doesn't need close.
996993 RegCloseKey (key );
997994 }
995+ PySys_Audit ("winreg.OpenKey/result" , "n" , NULL0 ;
998996 return NULL ;
999997 }
1000998 }
999+ if (PySys_Audit ("winreg.OpenKey/result" , "n" ,
1000+ (Py_ssize_t )retKey ) < 0 ) {
1001+ return NULL ;
1002+ }
10011003 return retKey ;
10021004}
10031005
@@ -1427,9 +1429,9 @@ winreg_OpenKey_impl(PyObject *module, HKEY key, const wchar_t *sub_key,
14271429 HKEY retKey ;
14281430 long rc ;
14291431
1430- if (PySys_Audit ("winreg.OpenKey" , "nun " ,
1432+ if (PySys_Audit ("winreg.OpenKey" , "nuni " ,
14311433 (Py_ssize_t )key , sub_key ,
1432- (Py_ssize_t )access ) < 0 ) {
1434+ (Py_ssize_t )access , options ) < 0 ) {
14331435 return NULL ;
14341436 }
14351437 if (options != 0 ) {
0 commit comments