From db4d8c2c3924dd975229794a5d76415689cc2389 Mon Sep 17 00:00:00 2001 From: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com> Date: Fri, 28 Jan 2022 17:22:15 +0530 Subject: [PATCH 1/3] add comment --- Include/cpython/import.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Include/cpython/import.h b/Include/cpython/import.h index 5ec637e7ab3b8c..a2597711f95107 100644 --- a/Include/cpython/import.h +++ b/Include/cpython/import.h @@ -32,7 +32,7 @@ struct _frozen { const char *name; /* ASCII encoded string */ const unsigned char *code; int size; - PyObject *(*get_code)(void); + PyObject *(*get_code)(void); /* Returns strong ref */ }; /* Embedding apps may change this pointer to point to their favorite From 68cacb39389c517b9437e43768959c5696743437 Mon Sep 17 00:00:00 2001 From: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com> Date: Fri, 28 Jan 2022 12:21:54 +0000 Subject: [PATCH 2/3] remove comment --- Include/cpython/import.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Include/cpython/import.h b/Include/cpython/import.h index a2597711f95107..5ec637e7ab3b8c 100644 --- a/Include/cpython/import.h +++ b/Include/cpython/import.h @@ -32,7 +32,7 @@ struct _frozen { const char *name; /* ASCII encoded string */ const unsigned char *code; int size; - PyObject *(*get_code)(void); /* Returns strong ref */ + PyObject *(*get_code)(void); }; /* Embedding apps may change this pointer to point to their favorite From 14e6a58194ecf8429c961ed0a6ef9b229888f6eb Mon Sep 17 00:00:00 2001 From: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com> Date: Fri, 28 Jan 2022 17:09:05 +0530 Subject: [PATCH 3/3] add more assertions --- Python/import.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Python/import.c b/Python/import.c index 51b779ca17c526..148f3f7179b517 100644 --- a/Python/import.c +++ b/Python/import.c @@ -1321,6 +1321,9 @@ unmarshal_frozen_code(struct frozen_info *info) if (info->get_code) { PyObject *code = info->get_code(); assert(code != NULL); + assert(PyCode_Check(code)); + // refcnt should be consistent + assert(Py_REFCNT(code) == 1000000000); return code; } PyObject *co = PyMarshal_ReadObjectFromString(info->data, info->size);