reach-vb's picture
reach-vb HF staff
544099ee60f85f9b5462f64b19d52cabecc6d7f3e7dc75f037db0030e18c7d16
a7e4fab
raw
history blame
518 Bytes
# Copyright © 2023 Apple Inc.
import array
import reprlib
class FixedRepr(reprlib.Repr):
"""Only route python array instances to repr_array."""
def repr_array(self, x, maxlevel):
if isinstance(x, array.array):
return super().repr_array(x, maxlevel)
else:
return self.repr_instance(x, maxlevel)
# We need to monkey-patch reprlib so that we can use the debugger without
# renaming the array to something else
fixed_repr = FixedRepr()
reprlib.repr = fixed_repr.repr