seq: handle EOF more leniently on Arr

This commit is contained in:
Shiz 2021-06-26 05:30:27 +02:00
parent 02dcfe0d92
commit 4c00689442
1 changed files with 7 additions and 2 deletions

View File

@ -1,7 +1,7 @@
from typing import Optional as O, Union as U, Callable, Any, List, Sequence, Mapping, Generic as G, TypeVar, Tuple as Tu
from types import FunctionType
from ..core.base import PossibleDynamic as D, Type, Context, PathElement
from ..core.base import PossibleDynamic as D, Type, Context, PathElement, EOF
from ..core.io import Stream, add_sizes
from ..core import to_type
@ -28,10 +28,15 @@ class Arr(G[T], Type[List[T]]):
break
c = to_type(child)
with context.enter(i, c):
pos = stream.tell()
try:
elem = context.parse(c, stream)
except EOFError:
if count is None:
if count is None and stop is None:
break
raise
except EOF:
if count is None and stop is None and pos == stream.tell():
break
raise
if stop is not None: