Skip to content

Commit bf049a7

Browse files
committed
fix(string): Py_Version is only available on Python 3.11+
1 parent 2c1d11c commit bf049a7

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/StrType.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ PyObject *StrType::proxifyString(JSContext *cx, JS::HandleValue strVal) {
135135

136136
if (JS::LinearStringHasLatin1Chars(lstr)) { // latin1 spidermonkey, latin1 python
137137
const JS::Latin1Char *chars = JS::GetLatin1LinearStringChars(nogc, lstr);
138-
if (Py_Version >= 0x030d0000) { // Python version is greater than 3.13
138+
if ((PY_VERSION_HEX) >= 0x030d0000) { // Python version is greater than 3.13
139139
// Short path to temporarily fix the issue with Python 3.13+ compact unicode representation.
140140
// It would error with `ValueError: embedded null character`, which is caused by the fact that
141141
// most Python C APIs assume the string buffer is null-terminated, so we need to create a copy.
@@ -165,7 +165,7 @@ 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 >= 0x030d0000) { // Python 3.13+, see above
168+
if ((PY_VERSION_HEX) >= 0x030d0000) { // Python 3.13+, see above
169169
PyObject *copied = PyUnicode_FromObject((PyObject *)pyString); // create a copy when it's not a true Unicode object
170170
Py_DECREF(pyString);
171171
return copied;

0 commit comments

Comments
 (0)