Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Revert "string_lit_as_bytes"
This reverts commit f40f756.
  • Loading branch information
ShaharNaveh committed Jun 28, 2026
commit 8fe18a2c32781be7ef1cf0fc3261034a79c64118
1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,6 @@ redundant_clone = "warn"
search_is_some = "warn"
significant_drop_in_scrutinee = "warn"
single_option_map = "warn"
string_lit_as_bytes = "warn"
trait_duplication_in_bounds = "warn"
tuple_array_conversions = "warn"
type_repetition_in_bounds = "warn"
Expand Down
4 changes: 2 additions & 2 deletions crates/common/src/int.rs
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ mod tests {
fn bytes_to_int_invalid_base() {
for base in [1, 37] {
assert_eq!(
bytes_to_int(b"012345", base, DIGIT_LIMIT),
bytes_to_int("012345".as_bytes(), base, DIGIT_LIMIT),
Err(BytesToIntError::InvalidBase)
)
}
Expand All @@ -204,7 +204,7 @@ mod tests {
#[test]
fn bytes_to_int_digit_limit() {
assert_eq!(
bytes_to_int(b"012345", 10, 5),
bytes_to_int("012345".as_bytes(), 10, 5),
Err(BytesToIntError::DigitLimit { got: 6, limit: 5 })
);
}
Expand Down
16 changes: 8 additions & 8 deletions crates/stdlib/src/json.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,17 +146,17 @@ mod _json {

macro_rules! parse_const {
($s:literal, $val:expr) => {
if rest.starts_with($s) {
if rest.starts_with($s.as_bytes()) {
return Ok(PyIterReturn::Return(
vm.new_tuple(($val, char_idx + $s.len())).into(),
));
}
};
}

parse_const!(b"null", vm.ctx.none());
parse_const!(b"true", true);
parse_const!(b"false", false);
parse_const!("null", vm.ctx.none());
parse_const!("true", true);
parse_const!("false", false);

if let Some((res, len)) = self.parse_number(rest, vm) {
return Ok(PyIterReturn::Return(
Expand All @@ -166,7 +166,7 @@ mod _json {

macro_rules! parse_constant {
($s:literal) => {
if rest.starts_with($s) {
if rest.starts_with($s.as_bytes()) {
return Ok(PyIterReturn::Return(
vm.new_tuple((
self.parse_constant.call(($s,), vm)?,
Expand All @@ -178,9 +178,9 @@ mod _json {
};
}

parse_constant!(b"NaN");
parse_constant!(b"Infinity");
parse_constant!(b"-Infinity");
parse_constant!("NaN");
parse_constant!("Infinity");
parse_constant!("-Infinity");

Ok(PyIterReturn::StopIteration(Some(
vm.ctx.new_int(char_idx).into(),
Expand Down
13 changes: 0 additions & 13 deletions crates/vm/src/builtins/bytes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,18 +60,6 @@ impl ToPyObject for Vec<u8> {
}
}

impl<const N: usize> ToPyObject for [u8; N] {
fn to_pyobject(self, vm: &VirtualMachine) -> PyObjectRef {
vm.ctx.new_bytes(self.into()).into()
}
}

impl<const N: usize> ToPyObject for &[u8; N] {
fn to_pyobject(self, vm: &VirtualMachine) -> PyObjectRef {
vm.ctx.new_bytes(self.into()).into()
}
}

impl Deref for PyBytes {
type Target = [u8];

Expand All @@ -85,7 +73,6 @@ impl AsRef<[u8]> for PyBytes {
self.as_bytes()
}
}

impl AsRef<[u8]> for PyBytesRef {
fn as_ref(&self) -> &[u8] {
self.as_bytes()
Expand Down