Skip to content

Commit 1f4f2be

Browse files
committed
Handle TypeError fixes backported to Python 3.5.4
See beeware#595 for the original problem. As the fix done in Python 3.6.2 was also backported to 3.5.4, extend the version checks made in beeware#607. See also python/cpython#724.
1 parent 6acc30b commit 1f4f2be

2 files changed

Lines changed: 3 additions & 3 deletions

File tree

‎python/common/org/python/types/ByteArray.java‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ public org.python.Object __add__(org.python.Object other) {
244244
System.arraycopy(other_bytes, 0, new_bytes, this.value.length, other_bytes.length);
245245
return new ByteArray(new_bytes);
246246
}
247-
if (org.Python.VERSION < 0x03060200) {
247+
if (org.Python.VERSION < 0x03050400 || (org.Python.VERSION >= 0x03060000 && org.Python.VERSION < 0x03060200)) {
248248
throw new org.python.exceptions.TypeError("can't concat " + this.typeName() + " to " + other.typeName());
249249
} else {
250250
throw new org.python.exceptions.TypeError("can't concat " + other.typeName() + " to " + this.typeName());
@@ -259,7 +259,7 @@ public org.python.Object __iadd__(org.python.Object other) {
259259
try {
260260
return super.__iadd__(other);
261261
} catch (org.python.exceptions.TypeError ae) {
262-
if (org.Python.VERSION < 0x03060200) {
262+
if (org.Python.VERSION < 0x03050400 || (org.Python.VERSION >= 0x03060000 && org.Python.VERSION < 0x03060200)) {
263263
throw new org.python.exceptions.TypeError("can't concat " + other.typeName() + " to " + this.typeName());
264264
} else {
265265
throw ae;

‎python/common/org/python/types/Bytes.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ public org.python.Object __add__(org.python.Object other) {
128128
System.arraycopy(other_bytes, 0, new_bytes, this.value.length, other_bytes.length);
129129
return new Bytes(new_bytes);
130130
}
131-
if (org.Python.VERSION < 0x03060200) {
131+
if (org.Python.VERSION < 0x03050400 || (org.Python.VERSION >= 0x03060000 && org.Python.VERSION < 0x03060200)) {
132132
throw new org.python.exceptions.TypeError("can't concat bytes to " + other.typeName());
133133
} else {
134134
throw new org.python.exceptions.TypeError("can't concat " + other.typeName() + " to bytes");

0 commit comments

Comments
 (0)