mirror of
https://github.com/RustPython/RustPython.git
synced 2026-10-29 19:24:57 +08:00
Fix Context.new_bytes (#6989)
This commit is contained in:
1 parent
c045593e4e
commit
2c417d5bb1
2 files changed
+5
-2
No files matched your search
Vendored
-1
@@ -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):
|
||||
|
||||
@@ -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]
|
||||
|
||||
Reference in new issue
Block a user