Fix Context.new_bytes (#6989)

This commit is contained in:
Jeong, YunWon authored and GitHub committed 2026-02-04 13:07:16 +09:00
1 parent c045593e4e
commit 2c417d5bb1
2 files changed
+5 -2

No files matched your search

-1
View File
@@ -2663,7 +2663,6 @@ class ConstantTests(unittest.TestCase):
self.assertEqual(str(cm.exception),
"got an invalid type in Constant: list")
@unittest.expectedFailure # TODO: RUSTPYTHON; b'' is not b''
def test_singletons(self):
for const in (None, False, True, Ellipsis, b''):
with self.subTest(const=const):
+5 -1
View File
@@ -455,7 +455,11 @@ impl Context {
#[inline]
pub fn new_bytes(&self, data: Vec<u8>) -> PyRef<PyBytes> {
PyBytes::from(data).into_ref(self)
if data.is_empty() {
self.empty_bytes.clone()
} else {
PyBytes::from(data).into_ref(self)
}
}
#[inline]