issue #408: fix test fallout.

issue510
David Wilson 6 years ago
parent b7add60097
commit fd90834944

@ -145,9 +145,8 @@ LOAD_CONST = dis.opname.index('LOAD_CONST')
IMPORT_NAME = dis.opname.index('IMPORT_NAME') IMPORT_NAME = dis.opname.index('IMPORT_NAME')
def _getarg(c): def _getarg(nextb, c):
if c < dis.HAVE_ARGUMENT: if c > dis.HAVE_ARGUMENT:
return nextb()
return nextb() | (nextb() << 8) return nextb() | (nextb() << 8)
@ -156,13 +155,13 @@ if sys.version_info < (3, 0):
# Yield `(op, oparg)` tuples from the code object `co`. # Yield `(op, oparg)` tuples from the code object `co`.
ordit = imap(ord, co.co_code) ordit = imap(ord, co.co_code)
nextb = ordit.next nextb = ordit.next
return ((c, _getarg(c)) for c in ordit) return ((c, _getarg(nextb, c)) for c in ordit)
elif sys.version_info < (3, 6): elif sys.version_info < (3, 6):
def iter_opcodes(co): def iter_opcodes(co):
# Yield `(op, oparg)` tuples from the code object `co`. # Yield `(op, oparg)` tuples from the code object `co`.
ordit = iter(co.co_code) ordit = iter(co.co_code)
nextb = ordit.__next__ nextb = ordit.__next__
return ((c, _getarg(c)) for c in ordit) return ((c, _getarg(nextb, c)) for c in ordit)
else: else:
def iter_opcodes(co): def iter_opcodes(co):
# Yield `(op, oparg)` tuples from the code object `co`. # Yield `(op, oparg)` tuples from the code object `co`.

@ -508,6 +508,7 @@ def write_all(fd, s, deadline=None):
class IteratingRead(object): class IteratingRead(object):
def __init__(self, fds, deadline=None): def __init__(self, fds, deadline=None):
self.deadline = deadline self.deadline = deadline
self.timeout = None
self.poller = PREFERRED_POLLER() self.poller = PREFERRED_POLLER()
for fd in fds: for fd in fds:
self.poller.start_receive(fd) self.poller.start_receive(fd)
@ -524,11 +525,11 @@ class IteratingRead(object):
def next(self): def next(self):
while self.poller.readers: while self.poller.readers:
if self.deadline is not None: if self.deadline is not None:
timeout = max(0, self.deadline - time.time()) self.timeout = max(0, self.deadline - time.time())
if timeout == 0: if self.timeout == 0:
break break
for fd in self.poller.poll(timeout): for fd in self.poller.poll(self.timeout):
s, disconnected = mitogen.core.io_op(os.read, fd, 4096) s, disconnected = mitogen.core.io_op(os.read, fd, 4096)
if disconnected or not s: if disconnected or not s:
IOLOG.debug('iter_read(%r) -> disconnected', fd) IOLOG.debug('iter_read(%r) -> disconnected', fd)
@ -538,7 +539,7 @@ class IteratingRead(object):
self.bits.append(s) self.bits.append(s)
return s return s
if not poller.readers: if not self.poller.readers:
raise EofError(u'EOF on stream; last 300 bytes received: %r' % raise EofError(u'EOF on stream; last 300 bytes received: %r' %
(b('').join(self.bits)[-300:].decode('latin1'),)) (b('').join(self.bits)[-300:].decode('latin1'),))

Loading…
Cancel
Save