Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 30260a7

Browse files
committed
Add ready checks for make_compiled_pathname.
1 parent 2db7286 commit 30260a7

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

Python/import.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -929,7 +929,10 @@ rightmost_sep_obj(PyObject* o)
929929
for the compiled file, or NULL if there's no space in the buffer.
930930
Doesn't set an exception.
931931
932-
foo.py -> __pycache__/foo.<tag>.pyc */
932+
foo.py -> __pycache__/foo.<tag>.pyc
933+
934+
pathstr is assumed to be "ready".
935+
*/
933936

934937
static PyObject*
935938
make_compiled_pathname(PyObject *pathstr, int debug)
@@ -1458,6 +1461,8 @@ load_source_module(PyObject *name, PyObject *pathname, FILE *fp)
14581461
goto error;
14591462
}
14601463
#endif
1464+
if (PyUnicode_READY(pathname) < 0)
1465+
return NULL;
14611466
cpathname = make_compiled_pathname(pathname, !Py_OptimizeFlag);
14621467

14631468
if (cpathname != NULL)
@@ -3949,6 +3954,9 @@ imp_cache_from_source(PyObject *self, PyObject *args, PyObject *kws)
39493954
return NULL;
39503955
}
39513956

3957+
if (PyUnicode_READY(pathname) < 0)
3958+
return NULL;
3959+
39523960
cpathname = make_compiled_pathname(pathname, debug);
39533961
Py_DECREF(pathname);
39543962

0 commit comments

Comments
 (0)