Skip to content

Commit

Permalink
Handle TypeError fixes backported to Python 3.5.4
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
whydoubt committed Nov 4, 2017
1 parent 6acc30b commit 1f4f2be
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions python/common/org/python/types/ByteArray.java
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ public org.python.Object __add__(org.python.Object other) {
System.arraycopy(other_bytes, 0, new_bytes, this.value.length, other_bytes.length);
return new ByteArray(new_bytes);
}
if (org.Python.VERSION < 0x03060200) {
if (org.Python.VERSION < 0x03050400 || (org.Python.VERSION >= 0x03060000 && org.Python.VERSION < 0x03060200)) {
throw new org.python.exceptions.TypeError("can't concat " + this.typeName() + " to " + other.typeName());
} else {
throw new org.python.exceptions.TypeError("can't concat " + other.typeName() + " to " + this.typeName());
Expand All @@ -259,7 +259,7 @@ public org.python.Object __iadd__(org.python.Object other) {
try {
return super.__iadd__(other);
} catch (org.python.exceptions.TypeError ae) {
if (org.Python.VERSION < 0x03060200) {
if (org.Python.VERSION < 0x03050400 || (org.Python.VERSION >= 0x03060000 && org.Python.VERSION < 0x03060200)) {
throw new org.python.exceptions.TypeError("can't concat " + other.typeName() + " to " + this.typeName());
} else {
throw ae;
Expand Down
2 changes: 1 addition & 1 deletion python/common/org/python/types/Bytes.java
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ public org.python.Object __add__(org.python.Object other) {
System.arraycopy(other_bytes, 0, new_bytes, this.value.length, other_bytes.length);
return new Bytes(new_bytes);
}
if (org.Python.VERSION < 0x03060200) {
if (org.Python.VERSION < 0x03050400 || (org.Python.VERSION >= 0x03060000 && org.Python.VERSION < 0x03060200)) {
throw new org.python.exceptions.TypeError("can't concat bytes to " + other.typeName());
} else {
throw new org.python.exceptions.TypeError("can't concat " + other.typeName() + " to bytes");
Expand Down

0 comments on commit 1f4f2be

Please sign in to comment.