mirror of
https://github.com/python/cpython.git
synced 2025-09-13 20:27:05 +00:00
SF patch 1179503: Fix typos in rpc.py
* Call to unpack_int() should have no arguments * Misspelled BadRPCVerspion exception * Replace <> with !=
This commit is contained in:
parent
d8d732e7d2
commit
c672f8c377
1 changed files with 18 additions and 16 deletions
|
@ -3,6 +3,8 @@
|
||||||
# XXX There should be separate exceptions for the various reasons why
|
# XXX There should be separate exceptions for the various reasons why
|
||||||
# XXX an RPC can fail, rather than using RuntimeError for everything
|
# XXX an RPC can fail, rather than using RuntimeError for everything
|
||||||
|
|
||||||
|
# XXX Need to use class based exceptions rather than string exceptions
|
||||||
|
|
||||||
# XXX The UDP version of the protocol resends requests when it does
|
# XXX The UDP version of the protocol resends requests when it does
|
||||||
# XXX not receive a timely reply -- use only for idempotent calls!
|
# XXX not receive a timely reply -- use only for idempotent calls!
|
||||||
|
|
||||||
|
@ -90,13 +92,13 @@ class Unpacker(xdr.Unpacker):
|
||||||
return (flavor, stuff)
|
return (flavor, stuff)
|
||||||
|
|
||||||
def unpack_callheader(self):
|
def unpack_callheader(self):
|
||||||
xid = self.unpack_uint(xid)
|
xid = self.unpack_uint()
|
||||||
temp = self.unpack_enum()
|
temp = self.unpack_enum()
|
||||||
if temp <> CALL:
|
if temp != CALL:
|
||||||
raise BadRPCFormat, 'no CALL but %r' % (temp,)
|
raise BadRPCFormat, 'no CALL but %r' % (temp,)
|
||||||
temp = self.unpack_uint()
|
temp = self.unpack_uint()
|
||||||
if temp <> RPCVERSION:
|
if temp != RPCVERSION:
|
||||||
raise BadRPCVerspion, 'bad RPC version %r' % (temp,)
|
raise BadRPCVersion, 'bad RPC version %r' % (temp,)
|
||||||
prog = self.unpack_uint()
|
prog = self.unpack_uint()
|
||||||
vers = self.unpack_uint()
|
vers = self.unpack_uint()
|
||||||
proc = self.unpack_uint()
|
proc = self.unpack_uint()
|
||||||
|
@ -108,7 +110,7 @@ class Unpacker(xdr.Unpacker):
|
||||||
def unpack_replyheader(self):
|
def unpack_replyheader(self):
|
||||||
xid = self.unpack_uint()
|
xid = self.unpack_uint()
|
||||||
mtype = self.unpack_enum()
|
mtype = self.unpack_enum()
|
||||||
if mtype <> REPLY:
|
if mtype != REPLY:
|
||||||
raise RuntimeError, 'no REPLY but %r' % (mtype,)
|
raise RuntimeError, 'no REPLY but %r' % (mtype,)
|
||||||
stat = self.unpack_enum()
|
stat = self.unpack_enum()
|
||||||
if stat == MSG_DENIED:
|
if stat == MSG_DENIED:
|
||||||
|
@ -123,7 +125,7 @@ class Unpacker(xdr.Unpacker):
|
||||||
raise RuntimeError, \
|
raise RuntimeError, \
|
||||||
'MSG_DENIED: AUTH_ERROR: %r' % (stat,)
|
'MSG_DENIED: AUTH_ERROR: %r' % (stat,)
|
||||||
raise RuntimeError, 'MSG_DENIED: %r' % (stat,)
|
raise RuntimeError, 'MSG_DENIED: %r' % (stat,)
|
||||||
if stat <> MSG_ACCEPTED:
|
if stat != MSG_ACCEPTED:
|
||||||
raise RuntimeError, \
|
raise RuntimeError, \
|
||||||
'Neither MSG_DENIED nor MSG_ACCEPTED: %r' % (stat,)
|
'Neither MSG_DENIED nor MSG_ACCEPTED: %r' % (stat,)
|
||||||
verf = self.unpack_auth()
|
verf = self.unpack_auth()
|
||||||
|
@ -139,7 +141,7 @@ class Unpacker(xdr.Unpacker):
|
||||||
raise RuntimeError, 'call failed: PROC_UNAVAIL'
|
raise RuntimeError, 'call failed: PROC_UNAVAIL'
|
||||||
if stat == GARBAGE_ARGS:
|
if stat == GARBAGE_ARGS:
|
||||||
raise RuntimeError, 'call failed: GARBAGE_ARGS'
|
raise RuntimeError, 'call failed: GARBAGE_ARGS'
|
||||||
if stat <> SUCCESS:
|
if stat != SUCCESS:
|
||||||
raise RuntimeError, 'call failed: %r' % (stat,)
|
raise RuntimeError, 'call failed: %r' % (stat,)
|
||||||
return xid, verf
|
return xid, verf
|
||||||
# Caller must get procedure-specific part of reply
|
# Caller must get procedure-specific part of reply
|
||||||
|
@ -329,7 +331,7 @@ def bindresvport(sock, host):
|
||||||
sock.bind((host, i))
|
sock.bind((host, i))
|
||||||
return last_resv_port_tried
|
return last_resv_port_tried
|
||||||
except socket.error, (errno, msg):
|
except socket.error, (errno, msg):
|
||||||
if errno <> 114:
|
if errno != 114:
|
||||||
raise socket.error, (errno, msg)
|
raise socket.error, (errno, msg)
|
||||||
raise RuntimeError, 'can\'t assign reserved port'
|
raise RuntimeError, 'can\'t assign reserved port'
|
||||||
|
|
||||||
|
@ -348,7 +350,7 @@ class RawTCPClient(Client):
|
||||||
u = self.unpacker
|
u = self.unpacker
|
||||||
u.reset(reply)
|
u.reset(reply)
|
||||||
xid, verf = u.unpack_replyheader()
|
xid, verf = u.unpack_replyheader()
|
||||||
if xid <> self.lastxid:
|
if xid != self.lastxid:
|
||||||
# Can't really happen since this is TCP...
|
# Can't really happen since this is TCP...
|
||||||
raise RuntimeError, 'wrong xid in reply %r instead of %r' % (
|
raise RuntimeError, 'wrong xid in reply %r instead of %r' % (
|
||||||
xid, self.lastxid)
|
xid, self.lastxid)
|
||||||
|
@ -387,7 +389,7 @@ class RawUDPClient(Client):
|
||||||
u = self.unpacker
|
u = self.unpacker
|
||||||
u.reset(reply)
|
u.reset(reply)
|
||||||
xid, verf = u.unpack_replyheader()
|
xid, verf = u.unpack_replyheader()
|
||||||
if xid <> self.lastxid:
|
if xid != self.lastxid:
|
||||||
## print 'BAD xid'
|
## print 'BAD xid'
|
||||||
continue
|
continue
|
||||||
break
|
break
|
||||||
|
@ -443,7 +445,7 @@ class RawBroadcastUDPClient(RawUDPClient):
|
||||||
u = self.unpacker
|
u = self.unpacker
|
||||||
u.reset(reply)
|
u.reset(reply)
|
||||||
xid, verf = u.unpack_replyheader()
|
xid, verf = u.unpack_replyheader()
|
||||||
if xid <> self.lastxid:
|
if xid != self.lastxid:
|
||||||
## print 'BAD xid'
|
## print 'BAD xid'
|
||||||
continue
|
continue
|
||||||
reply = unpack_func()
|
reply = unpack_func()
|
||||||
|
@ -678,11 +680,11 @@ class Server:
|
||||||
xid = self.unpacker.unpack_uint()
|
xid = self.unpacker.unpack_uint()
|
||||||
self.packer.pack_uint(xid)
|
self.packer.pack_uint(xid)
|
||||||
temp = self.unpacker.unpack_enum()
|
temp = self.unpacker.unpack_enum()
|
||||||
if temp <> CALL:
|
if temp != CALL:
|
||||||
return None # Not worthy of a reply
|
return None # Not worthy of a reply
|
||||||
self.packer.pack_uint(REPLY)
|
self.packer.pack_uint(REPLY)
|
||||||
temp = self.unpacker.unpack_uint()
|
temp = self.unpacker.unpack_uint()
|
||||||
if temp <> RPCVERSION:
|
if temp != RPCVERSION:
|
||||||
self.packer.pack_uint(MSG_DENIED)
|
self.packer.pack_uint(MSG_DENIED)
|
||||||
self.packer.pack_uint(RPC_MISMATCH)
|
self.packer.pack_uint(RPC_MISMATCH)
|
||||||
self.packer.pack_uint(RPCVERSION)
|
self.packer.pack_uint(RPCVERSION)
|
||||||
|
@ -691,11 +693,11 @@ class Server:
|
||||||
self.packer.pack_uint(MSG_ACCEPTED)
|
self.packer.pack_uint(MSG_ACCEPTED)
|
||||||
self.packer.pack_auth((AUTH_NULL, make_auth_null()))
|
self.packer.pack_auth((AUTH_NULL, make_auth_null()))
|
||||||
prog = self.unpacker.unpack_uint()
|
prog = self.unpacker.unpack_uint()
|
||||||
if prog <> self.prog:
|
if prog != self.prog:
|
||||||
self.packer.pack_uint(PROG_UNAVAIL)
|
self.packer.pack_uint(PROG_UNAVAIL)
|
||||||
return self.packer.get_buf()
|
return self.packer.get_buf()
|
||||||
vers = self.unpacker.unpack_uint()
|
vers = self.unpacker.unpack_uint()
|
||||||
if vers <> self.vers:
|
if vers != self.vers:
|
||||||
self.packer.pack_uint(PROG_MISMATCH)
|
self.packer.pack_uint(PROG_MISMATCH)
|
||||||
self.packer.pack_uint(self.vers)
|
self.packer.pack_uint(self.vers)
|
||||||
self.packer.pack_uint(self.vers)
|
self.packer.pack_uint(self.vers)
|
||||||
|
@ -812,7 +814,7 @@ class UDPServer(Server):
|
||||||
def session(self):
|
def session(self):
|
||||||
call, host_port = self.sock.recvfrom(8192)
|
call, host_port = self.sock.recvfrom(8192)
|
||||||
reply = self.handle(call)
|
reply = self.handle(call)
|
||||||
if reply <> None:
|
if reply != None:
|
||||||
self.sock.sendto(reply, host_port)
|
self.sock.sendto(reply, host_port)
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue