experiment: try to autocast when possible

This commit is contained in:
Romain Dorgueil
2018-07-16 12:12:15 +02:00
parent 7b365e014d
commit 71cd606fad

View File

@ -286,11 +286,17 @@ class NodeExecutionContext(BaseContext, WithStatistics):
if self._input_type is None: if self._input_type is None:
self._input_type = type(input_bag) self._input_type = type(input_bag)
elif type(input_bag) is not self._input_type: elif type(input_bag) is not self._input_type:
try:
if type(self._input_type) == tuple:
input_bag = self._input_type(tuple)
else:
input_bag = self._input_type(*input_bag)
except Exception as exc:
raise UnrecoverableTypeError( raise UnrecoverableTypeError(
'Input type changed between calls to {!r}.\nGot {!r} which is not of type {!r}.'.format( 'Input type changed to incompatible type between calls to {!r}.\nGot {!r} which is not of type {!r}.'.format(
self.wrapped, input_bag, self._input_type self.wrapped, input_bag, self._input_type
) )
) ) from exc
# Store or check input length, which is a soft fallback in case we're just using tuples # Store or check input length, which is a soft fallback in case we're just using tuples
if self._input_length is None: if self._input_length is None: