Skip to content

Commit ee4efd4

Browse files
authored
Merge pull request RustPython#3768 from redbopo/add_context_empty_bytes
Add Context::empty_bytes
2 parents 3d345d7 + c0999a9 commit ee4efd4

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

vm/src/vm/context.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ use crate::{
66
getset::{IntoPyGetterFunc, IntoPySetterFunc, PyGetSet},
77
object, pystr,
88
type_::PyAttributes,
9-
PyBaseException, PyComplex, PyDict, PyDictRef, PyEllipsis, PyFloat, PyFrozenSet, PyInt,
10-
PyIntRef, PyList, PyListRef, PyNone, PyNotImplemented, PyStr, PyStrInterned, PyTuple,
11-
PyTupleRef, PyType, PyTypeRef,
9+
PyBaseException, PyBytes, PyComplex, PyDict, PyDictRef, PyEllipsis, PyFloat, PyFrozenSet,
10+
PyInt, PyIntRef, PyList, PyListRef, PyNone, PyNotImplemented, PyStr, PyStrInterned,
11+
PyTuple, PyTupleRef, PyType, PyTypeRef,
1212
},
1313
class::{PyClassImpl, StaticType},
1414
common::rc::PyRc,
@@ -30,6 +30,7 @@ pub struct Context {
3030
pub empty_tuple: PyTupleRef,
3131
pub empty_frozenset: PyRef<PyFrozenSet>,
3232
pub empty_str: PyRef<PyStr>,
33+
pub empty_bytes: PyRef<PyBytes>,
3334
pub ellipsis: PyRef<PyEllipsis>,
3435
pub not_implemented: PyRef<PyNotImplemented>,
3536

@@ -273,14 +274,15 @@ impl Context {
273274
.into();
274275

275276
let empty_str = unsafe { string_pool.intern("", types.str_type.to_owned()) }.to_owned();
276-
277+
let empty_bytes = create_object(PyBytes::from(Vec::new()), types.bytes_type);
277278
let context = Context {
278279
true_value,
279280
false_value,
280281
none,
281282
empty_tuple,
282283
empty_frozenset,
283284
empty_str,
285+
empty_bytes,
284286

285287
ellipsis,
286288
not_implemented,

0 commit comments

Comments
 (0)