lib.data: no loop required, we return or die.
This commit is contained in:
parent
cdf8fcc32f
commit
f4b013ac73
|
@ -674,14 +674,13 @@ class View(ValueCastable):
|
||||||
value = self.__target[field.offset:field.offset + field.width]
|
value = self.__target[field.offset:field.offset + field.width]
|
||||||
# Field guarantees that the shape-castable object is well-formed, so there is no need
|
# Field guarantees that the shape-castable object is well-formed, so there is no need
|
||||||
# to handle erroneous cases here.
|
# to handle erroneous cases here.
|
||||||
while isinstance(shape, ShapeCastable):
|
if isinstance(shape, ShapeCastable):
|
||||||
if hasattr(shape, "__call__"):
|
value = shape(value)
|
||||||
value = shape(value)
|
if not isinstance(value, (Value, ValueCastable)):
|
||||||
if not isinstance(value, (Value, ValueCastable)):
|
raise TypeError("{!r}.__call__() must return a value or "
|
||||||
raise TypeError("{!r}.__call__() must return a value or "
|
"a value-castable object, not {!r}"
|
||||||
"a value-castable object, not {!r}"
|
.format(shape, value))
|
||||||
.format(shape, value))
|
return value
|
||||||
return value
|
|
||||||
if Shape.cast(shape).signed:
|
if Shape.cast(shape).signed:
|
||||||
return value.as_signed()
|
return value.as_signed()
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Reference in a new issue