33# XXX There should be separate exceptions for the various reasons why
44# XXX an RPC can fail, rather than using RuntimeError for everything
55
6+ # XXX Need to use class based exceptions rather than string exceptions
7+
68# XXX The UDP version of the protocol resends requests when it does
79# XXX not receive a timely reply -- use only for idempotent calls!
810
@@ -90,13 +92,13 @@ def unpack_auth(self):
9092 return (flavor , stuff )
9193
9294 def unpack_callheader (self ):
93- xid = self .unpack_uint (xid )
95+ xid = self .unpack_uint ()
9496 temp = self .unpack_enum ()
95- if temp <> CALL :
97+ if temp != CALL :
9698 raise BadRPCFormat , 'no CALL but %r' % (temp ,)
9799 temp = self .unpack_uint ()
98- if temp <> RPCVERSION :
99- raise BadRPCVerspion , 'bad RPC version %r' % (temp ,)
100+ if temp != RPCVERSION :
101+ raise BadRPCVersion , 'bad RPC version %r' % (temp ,)
100102 prog = self .unpack_uint ()
101103 vers = self .unpack_uint ()
102104 proc = self .unpack_uint ()
@@ -108,7 +110,7 @@ def unpack_callheader(self):
108110 def unpack_replyheader (self ):
109111 xid = self .unpack_uint ()
110112 mtype = self .unpack_enum ()
111- if mtype <> REPLY :
113+ if mtype != REPLY :
112114 raise RuntimeError , 'no REPLY but %r' % (mtype ,)
113115 stat = self .unpack_enum ()
114116 if stat == MSG_DENIED :
@@ -123,7 +125,7 @@ def unpack_replyheader(self):
123125 raise RuntimeError , \
124126 'MSG_DENIED: AUTH_ERROR: %r' % (stat ,)
125127 raise RuntimeError , 'MSG_DENIED: %r' % (stat ,)
126- if stat <> MSG_ACCEPTED :
128+ if stat != MSG_ACCEPTED :
127129 raise RuntimeError , \
128130 'Neither MSG_DENIED nor MSG_ACCEPTED: %r' % (stat ,)
129131 verf = self .unpack_auth ()
@@ -139,7 +141,7 @@ def unpack_replyheader(self):
139141 raise RuntimeError , 'call failed: PROC_UNAVAIL'
140142 if stat == GARBAGE_ARGS :
141143 raise RuntimeError , 'call failed: GARBAGE_ARGS'
142- if stat <> SUCCESS :
144+ if stat != SUCCESS :
143145 raise RuntimeError , 'call failed: %r' % (stat ,)
144146 return xid , verf
145147 # Caller must get procedure-specific part of reply
@@ -329,7 +331,7 @@ def bindresvport(sock, host):
329331 sock .bind ((host , i ))
330332 return last_resv_port_tried
331333 except socket .error , (errno , msg ):
332- if errno <> 114 :
334+ if errno != 114 :
333335 raise socket .error , (errno , msg )
334336 raise RuntimeError , 'can\' t assign reserved port'
335337
@@ -348,7 +350,7 @@ def do_call(self):
348350 u = self .unpacker
349351 u .reset (reply )
350352 xid , verf = u .unpack_replyheader ()
351- if xid <> self .lastxid :
353+ if xid != self .lastxid :
352354 # Can't really happen since this is TCP...
353355 raise RuntimeError , 'wrong xid in reply %r instead of %r' % (
354356 xid , self .lastxid )
@@ -387,7 +389,7 @@ def do_call(self):
387389 u = self .unpacker
388390 u .reset (reply )
389391 xid , verf = u .unpack_replyheader ()
390- if xid <> self .lastxid :
392+ if xid != self .lastxid :
391393## print 'BAD xid'
392394 continue
393395 break
@@ -443,7 +445,7 @@ def dummy(): pass
443445 u = self .unpacker
444446 u .reset (reply )
445447 xid , verf = u .unpack_replyheader ()
446- if xid <> self .lastxid :
448+ if xid != self .lastxid :
447449## print 'BAD xid'
448450 continue
449451 reply = unpack_func ()
@@ -678,11 +680,11 @@ def handle(self, call):
678680 xid = self .unpacker .unpack_uint ()
679681 self .packer .pack_uint (xid )
680682 temp = self .unpacker .unpack_enum ()
681- if temp <> CALL :
683+ if temp != CALL :
682684 return None # Not worthy of a reply
683685 self .packer .pack_uint (REPLY )
684686 temp = self .unpacker .unpack_uint ()
685- if temp <> RPCVERSION :
687+ if temp != RPCVERSION :
686688 self .packer .pack_uint (MSG_DENIED )
687689 self .packer .pack_uint (RPC_MISMATCH )
688690 self .packer .pack_uint (RPCVERSION )
@@ -691,11 +693,11 @@ def handle(self, call):
691693 self .packer .pack_uint (MSG_ACCEPTED )
692694 self .packer .pack_auth ((AUTH_NULL , make_auth_null ()))
693695 prog = self .unpacker .unpack_uint ()
694- if prog <> self .prog :
696+ if prog != self .prog :
695697 self .packer .pack_uint (PROG_UNAVAIL )
696698 return self .packer .get_buf ()
697699 vers = self .unpacker .unpack_uint ()
698- if vers <> self .vers :
700+ if vers != self .vers :
699701 self .packer .pack_uint (PROG_MISMATCH )
700702 self .packer .pack_uint (self .vers )
701703 self .packer .pack_uint (self .vers )
@@ -812,7 +814,7 @@ def loop(self):
812814 def session (self ):
813815 call , host_port = self .sock .recvfrom (8192 )
814816 reply = self .handle (call )
815- if reply <> None :
817+ if reply != None :
816818 self .sock .sendto (reply , host_port )
817819
818820
0 commit comments