From: Fredrik Tolf Date: Wed, 28 Mar 2018 15:51:47 +0000 (+0200) Subject: Classify trunacted input as its own exception type. X-Git-Url: http://git.dolda2000.com/gitweb/?a=commitdiff_plain;h=d30502c8fe37bedb30ad9f3ddecd5191c5b077fb;p=wrw.git Classify trunacted input as its own exception type. --- diff --git a/wrw/req.py b/wrw/req.py index b08afae..010e907 100644 --- a/wrw/req.py +++ b/wrw/req.py @@ -51,6 +51,10 @@ def fixcase(str): i += 1 return str +class shortinput(IOError, EOFError): + def __init__(self): + super().__init__("Unexpected EOF") + class limitreader(object): def __init__(self, back, limit): self.bk = back @@ -68,7 +72,7 @@ class limitreader(object): while len(self.buf) < ra: ret = self.bk.read(ra - len(self.buf)) if ret == b"": - raise IOError("Unexpected EOF") + raise shortinput() self.buf.extend(ret) self.rb += len(ret) ret = bytes(self.buf[:ra]) @@ -98,7 +102,7 @@ class limitreader(object): ra = min(ra, 1024) ret = self.bk.read(ra) if ret == b"": - raise IOError("Unpexpected EOF") + raise shortinput() self.buf.extend(ret) self.rb += len(ret)