diff --git a/construct/core.py b/construct/core.py index 8f5919f0..d55d9ef8 100644 --- a/construct/core.py +++ b/construct/core.py @@ -4727,6 +4727,17 @@ def _parse(self, stream, context, path): if stream.read(1): raise TerminatedError("expected end of stream", path=path) + def _emitparse(self, code): + code.append(""" + def Terminated(io): + if io.read(1): + raise TerminatedError("expected end of stream") + """) + return "Terminated(io)" + + def _emitbuild(self, code): + return "None" + def _build(self, obj, stream, context, path): return obj