Skip to content

Commit b0906cf

Browse files
Zach Olsteintimfel
authored andcommitted
Add boxed specializations of BytesBuiltin.FindNode
Prior to this commit, pytz.timezone fails with an UnsupportedSpecializationException because it calls bytes.find with a (boxed) Long rather than an int for the argument `start`. To fix this, I've added new specializations that expect a Number, which should allow this method to work when passed in boxed number types.
1 parent a8d9914 commit b0906cf

File tree

1 file changed

+10
-0
lines changed
  • graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/bytes

1 file changed

+10
-0
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/bytes/BytesBuiltins.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -704,11 +704,21 @@ int find(VirtualFrame frame, PIBytesLike self, Object sub, int start, @SuppressW
704704
return find(frame, self, sub, start, getLength(self.getSequenceStorage()));
705705
}
706706

707+
@Specialization
708+
int find (VirtualFrame frame, PIBytesLike self, Object sub, Number start, @SuppressWarnings("unused") PNone end) {
709+
return find(frame, self, sub, start, getLength(self.getSequenceStorage()));
710+
}
711+
707712
@Specialization
708713
int find(VirtualFrame frame, PIBytesLike self, Object sub, int start, int ending) {
709714
return getFindNode().execute(frame, self, sub, start, ending);
710715
}
711716

717+
@Specialization
718+
int find(VirtualFrame frame, PIBytesLike self, Object sub, Number start, Number ending) {
719+
return getFindNode().execute(frame, self, sub, start, ending);
720+
}
721+
712722
private BytesNodes.FindNode getFindNode() {
713723
if (findNode == null) {
714724
CompilerDirectives.transferToInterpreterAndInvalidate();

0 commit comments

Comments
 (0)