remove silly special nested EOF exception
This commit is contained in:
parent
9699a6e611
commit
b837384672
|
@ -74,10 +74,7 @@ class Context:
|
|||
@contextmanager
|
||||
def enter(self, entry: PathElement, type: 'Type') -> Generator:
|
||||
self.path.append((entry, type))
|
||||
try:
|
||||
yield
|
||||
except EOFError as e:
|
||||
raise EOF(self, e) from e
|
||||
yield
|
||||
self.path.pop()
|
||||
|
||||
@contextmanager
|
||||
|
@ -198,9 +195,6 @@ class Error(Exception):
|
|||
self.exception = exception
|
||||
self.context = context.copy()
|
||||
|
||||
class EOF(Error):
|
||||
pass
|
||||
|
||||
|
||||
PossibleType = U[Type, list, tuple, Callable[[O[Any]], Type]]
|
||||
|
||||
|
|
|
@ -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, EOF
|
||||
from ..core.base import PossibleDynamic as D, Type, Context, PathElement
|
||||
from ..core.io import Stream, add_sizes
|
||||
from ..core import to_type
|
||||
|
||||
|
@ -28,15 +28,11 @@ class Arr(G[T], Type[List[T]]):
|
|||
break
|
||||
c = to_type(child)
|
||||
with context.enter(i, c):
|
||||
pos = stream.tell()
|
||||
start = stream.tell()
|
||||
try:
|
||||
elem = context.parse(c, stream)
|
||||
except EOFError:
|
||||
if count is None and stop is None:
|
||||
break
|
||||
raise
|
||||
except EOF:
|
||||
if count is None and stop is None and pos == stream.tell():
|
||||
if count is None and stop is None and start == stream.tell():
|
||||
break
|
||||
raise
|
||||
if stop is not None:
|
||||
|
|
Loading…
Reference in New Issue