Skip to content

Commit

Permalink
merge with multiply int by bytes and bytearray
Browse files Browse the repository at this point in the history
  • Loading branch information
italomaia committed Oct 18, 2016
2 parents 3744922 + a47aaab commit 4752182
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
11 changes: 10 additions & 1 deletion python/common/org/python/types/Int.java
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,16 @@ public org.python.Object __mul__(org.python.Object other) {
for(int i=0; i < value; i++){
System.arraycopy(other_value, 0, bytes, i * len, len);
}
return new org.python.types.ByteArray(bytes);
return new org.python.types.ByteArray(bytes);
} else if (other instanceof org.python.types.Bytes) {
byte[] other_value = ((org.python.types.Bytes) other).value;
int value = Math.max(0, (int) this.value);
int len = other_value.length;
byte[] bytes = new byte[value * len];
for(int i=0; i < value; i++){
System.arraycopy(other_value, 0, bytes, i * len, len);
}
return new org.python.types.Bytes(bytes);
}
throw new org.python.exceptions.TypeError("unsupported operand type(s) for *: 'int' and '" + other.typeName() + "'");
}
Expand Down
1 change: 0 additions & 1 deletion tests/datatypes/test_int.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ class BinaryIntOperationTests(BinaryOperationTestCase, TranspileTestCase):
'test_modulo_complex',
'test_modulo_frozenset',

'test_multiply_bytes',
'test_multiply_class',
'test_multiply_complex',
'test_multiply_frozenset',
Expand Down

0 comments on commit 4752182

Please sign in to comment.