Skip to content

Commit 325730c

Browse files
authored
Merge pull request #14 from ngoldbaum/fix-gil-handling
acquire GIL for error condition in unicode to ascii cast
2 parents 92353e5 + 816a89c commit 325730c

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

asciidtype/asciidtype/src/casts.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,9 +135,12 @@ unicode_to_ascii(PyArrayMethod_Context *context, char *const data[],
135135
for (int i = 0; i < copy_size; i++) {
136136
Py_UCS4 c = ((Py_UCS4 *)in)[i];
137137
if (c > 127) {
138+
PyGILState_STATE gstate;
139+
gstate = PyGILState_Ensure();
138140
PyErr_SetString(
139141
PyExc_TypeError,
140142
"Can only store ASCII text in a ASCIIDType array.");
143+
PyGILState_Release(gstate);
141144
return -1;
142145
}
143146
// UCS4 character is ascii, so casting to Py_UCS1 does not truncate

0 commit comments

Comments
 (0)