File tree Expand file tree Collapse file tree 1 file changed +5
-5
lines changed Expand file tree Collapse file tree 1 file changed +5
-5
lines changed Original file line number Diff line number Diff line change @@ -165,11 +165,6 @@ PyObject *StrType::proxifyString(JSContext *cx, JS::HandleValue strVal) {
165
165
}
166
166
else { // utf16 spidermonkey, ucs2 python
167
167
const char16_t *chars = JS::GetTwoByteLinearStringChars (nogc, lstr);
168
- if ((PY_VERSION_HEX) >= 0x030d0000 ) { // Python 3.13+, see above
169
- PyObject *copied = PyUnicode_FromKindAndData (PyUnicode_2BYTE_KIND, chars, length);
170
- Py_DECREF (pyString);
171
- return copied;
172
- }
173
168
174
169
PY_UNICODE_OBJECT_DATA_ANY (pyString) = (void *)chars;
175
170
PY_UNICODE_OBJECT_KIND (pyString) = PyUnicode_2BYTE_KIND;
@@ -202,6 +197,11 @@ PyObject *StrType::proxifyString(JSContext *cx, JS::HandleValue strVal) {
202
197
Py_DECREF (pyString);
203
198
return ucs4Obj;
204
199
}
200
+ if ((PY_VERSION_HEX) >= 0x030d0000 ) { // Python 3.13+, fix `ValueError: embedded null character`
201
+ PyObject *copied = PyUnicode_FromKindAndData (PyUnicode_2BYTE_KIND, chars, length); // create a copy of the string buffer
202
+ Py_DECREF (pyString);
203
+ return copied;
204
+ }
205
205
}
206
206
207
207
return (PyObject *)pyString;
You can’t perform that action at this time.
0 commit comments