mirror of
https://github.com/panda3d/panda3d.git
synced 2025-09-29 16:20:11 -04:00
loader: a few additional checks for Python loader plug-ins
This commit is contained in:
parent
d5a576f3cb
commit
c2f49f4c4a
@ -83,10 +83,27 @@ init(PyObject *loader) {
|
||||
// it must occur in the list.
|
||||
PyObject *extensions = PyObject_GetAttrString(loader, "extensions");
|
||||
if (extensions != nullptr) {
|
||||
if (PyUnicode_Check(extensions)
|
||||
#if PY_MAJOR_VERSION < 3
|
||||
|| PyString_Check(extensions)
|
||||
#endif
|
||||
) {
|
||||
Dtool_Raise_TypeError("extensions list should be a list or tuple");
|
||||
Py_DECREF(extensions);
|
||||
return false;
|
||||
}
|
||||
|
||||
PyObject *sequence = PySequence_Fast(extensions, "extensions must be a sequence");
|
||||
PyObject **items = PySequence_Fast_ITEMS(sequence);
|
||||
Py_ssize_t num_items = PySequence_Fast_GET_SIZE(sequence);
|
||||
Py_DECREF(extensions);
|
||||
|
||||
if (num_items == 0) {
|
||||
PyErr_SetString(PyExc_ValueError, "extensions list may not be empty");
|
||||
Py_DECREF(sequence);
|
||||
return false;
|
||||
}
|
||||
|
||||
bool found_extension = false;
|
||||
|
||||
for (Py_ssize_t i = 0; i < num_items; ++i) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user