Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Merged
Changes from all commits
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
18 changes: 16 additions & 2 deletions 18 Modules/arraymodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ typedef struct {
PyObject *str_write;
PyObject *str___dict__;
PyObject *str_iter;
PyObject *typecodes;
} array_state;

static array_state *
Expand Down Expand Up @@ -3153,8 +3154,18 @@ array_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
}
}
Py_XDECREF(it);
PyErr_SetString(PyExc_ValueError,
"bad typecode (must be b, B, u, w, h, H, i, I, l, L, q, Q, e, f, d, Zf or Zd)");

PyObject *sep = PyUnicode_FromString(", ");
if (sep == NULL) {
return NULL;
}
PyObject *msg = PyObject_CallMethod(sep, "join", "(O)", state->typecodes);
Py_DECREF(sep);
if (msg == NULL) {
return NULL;
}
PyErr_Format(PyExc_ValueError, "bad typecode (must be: %S)", msg);
Py_DECREF(msg);
return NULL;
}

Expand Down Expand Up @@ -3439,6 +3450,7 @@ array_traverse(PyObject *module, visitproc visit, void *arg)
Py_VISIT(state->ArrayType);
Py_VISIT(state->ArrayIterType);
Py_VISIT(state->array_reconstructor);
Py_VISIT(state->typecodes);
return 0;
}

Expand All @@ -3453,6 +3465,7 @@ array_clear(PyObject *module)
Py_CLEAR(state->str_write);
Py_CLEAR(state->str___dict__);
Py_CLEAR(state->str_iter);
Py_CLEAR(state->typecodes);
return 0;
}

Expand Down Expand Up @@ -3549,6 +3562,7 @@ array_modexec(PyObject *m)
if (tuple == NULL) {
return -1;
}
state->typecodes = Py_NewRef(tuple);
if (PyModule_Add(m, "typecodes", tuple) < 0) {
return -1;
}
Expand Down
Loading
Morty Proxy This is a proxified and sanitized view of the page, visit original site.