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) {
165165 }
166166 else { // utf16 spidermonkey, ucs2 python
167167 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- }
173168
174169 PY_UNICODE_OBJECT_DATA_ANY (pyString) = (void *)chars;
175170 PY_UNICODE_OBJECT_KIND (pyString) = PyUnicode_2BYTE_KIND;
@@ -202,6 +197,11 @@ PyObject *StrType::proxifyString(JSContext *cx, JS::HandleValue strVal) {
202197 Py_DECREF (pyString);
203198 return ucs4Obj;
204199 }
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+ }
205205 }
206206
207207 return (PyObject *)pyString;
You can’t perform that action at this time.
0 commit comments