Pewarta Proxy

📋 Server Request & Proxy Logs

Loading active proxy settings...
Developed by Khairul Adha (adhexa.id)
Mengambil log server...

⚙️ Pengaturan Proxy Target

Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Factor out _PyRuntimeState.audit_hooks.
  • Loading branch information
ericsnowcurrently committed Jun 7, 2023
commit 0cc4ffe38d546a19fef5d79b39a776794ce6634a
4 changes: 3 additions & 1 deletion Include/internal/pycore_runtime.h
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,9 @@ typedef struct pyruntimestate {
// is called multiple times.
Py_OpenCodeHookFunction open_code_hook;
void *open_code_userdata;
_Py_AuditHookEntry *audit_hook_head;
struct {
_Py_AuditHookEntry *head;
} audit_hooks;

struct _py_object_runtime_state object_state;
struct _Py_float_runtime_state float_state;
Expand Down
4 changes: 2 additions & 2 deletions Python/pystate.c
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,7 @@ init_runtime(_PyRuntimeState *runtime,

runtime->open_code_hook = open_code_hook;
runtime->open_code_userdata = open_code_userdata;
runtime->audit_hook_head = audit_hook_head;
runtime->audit_hooks.head = audit_hook_head;

PyPreConfig_InitPythonConfig(&runtime->preconfig);

Expand All @@ -458,7 +458,7 @@ _PyRuntimeState_Init(_PyRuntimeState *runtime)
initialization and interpreter initialization. */
void *open_code_hook = runtime->open_code_hook;
void *open_code_userdata = runtime->open_code_userdata;
_Py_AuditHookEntry *audit_hook_head = runtime->audit_hook_head;
_Py_AuditHookEntry *audit_hook_head = runtime->audit_hooks.head;
// bpo-42882: Preserve next_index value if Py_Initialize()/Py_Finalize()
// is called multiple times.
Py_ssize_t unicode_next_index = runtime->unicode_state.ids.next_index;
Expand Down
12 changes: 6 additions & 6 deletions Python/sysmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ should_audit(PyInterpreterState *interp)
if (!interp) {
return 0;
}
return (interp->runtime->audit_hook_head
return (interp->runtime->audit_hooks.head
|| interp->audit_hooks
|| PyDTrace_AUDIT_ENABLED());
}
Expand Down Expand Up @@ -225,7 +225,7 @@ sys_audit_tstate(PyThreadState *ts, const char *event,
}

/* Call global hooks */
_Py_AuditHookEntry *e = is->runtime->audit_hook_head;
_Py_AuditHookEntry *e = is->runtime->audit_hooks.head;
for (; e; e = e->next) {
if (e->hookCFunction(event, eventArgs, e->userData) < 0) {
goto exit;
Expand Down Expand Up @@ -353,8 +353,8 @@ _PySys_ClearAuditHooks(PyThreadState *ts)
_PySys_Audit(ts, "cpython._PySys_ClearAuditHooks", NULL);
_PyErr_Clear(ts);

_Py_AuditHookEntry *e = runtime->audit_hook_head, *n;
runtime->audit_hook_head = NULL;
_Py_AuditHookEntry *e = runtime->audit_hooks.head, *n;
runtime->audit_hooks.head = NULL;
while (e) {
n = e->next;
PyMem_RawFree(e);
Expand Down Expand Up @@ -389,10 +389,10 @@ PySys_AddAuditHook(Py_AuditHookFunction hook, void *userData)
}
}

_Py_AuditHookEntry *e = runtime->audit_hook_head;
_Py_AuditHookEntry *e = runtime->audit_hooks.head;
if (!e) {
e = (_Py_AuditHookEntry*)PyMem_RawMalloc(sizeof(_Py_AuditHookEntry));
runtime->audit_hook_head = e;
runtime->audit_hooks.head = e;
} else {
while (e->next) {
e = e->next;
Expand Down