linux-nfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/6] pynfs: python3 support plan: print -> print()
@ 2018-07-22  9:27 jiyin
  2018-07-22  9:27 ` [PATCH 2/6] pynfs: python3 support plan: exec -> exec() jiyin
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: jiyin @ 2018-07-22  9:27 UTC (permalink / raw)
  To: bfields; +Cc: linux-nfs, Jianhong.Yin

From: "Jianhong.Yin" <yin-jianhong@163.com>

'/print / {:lop /[^\\]$/! {N; b lop}; s/print /print(/; s/$/)/; }'

Signed-off-by: Jianhong Yin <yin-jianhong@163.com>
---
 nfs4.0/lib/rpc/rpc.py                      |  56 +++----
 nfs4.0/lib/rpc/rpcsec/sec_auth_gss.py      |   8 +-
 nfs4.0/nfs4acl.py                          |   2 +-
 nfs4.0/nfs4client.py                       |  14 +-
 nfs4.0/nfs4lib.py                          |  18 +--
 nfs4.0/nfs4server.py                       | 168 ++++++++++-----------
 nfs4.0/nfs4state.py                        |  32 ++--
 nfs4.0/servertests/environment.py          |  14 +-
 nfs4.0/servertests/st_delegation.py        |   6 +-
 nfs4.0/servertests/st_fslocations.py       |  22 +--
 nfs4.0/servertests/st_getattr.py           |  10 +-
 nfs4.0/servertests/st_reboot.py            |   2 +-
 nfs4.0/testserver.py                       |  30 ++--
 nfs4.1/block.py                            |   8 +-
 nfs4.1/client41tests/ct_reboot.py          |  10 +-
 nfs4.1/client41tests/environment.py        |   4 +-
 nfs4.1/config.py                           |  10 +-
 nfs4.1/errorparser.py                      |   2 +-
 nfs4.1/locking.py                          |   6 +-
 nfs4.1/nfs4lib.py                          |   6 +-
 nfs4.1/nfs4proxy.py                        |   2 +-
 nfs4.1/nfs4server.py                       |  14 +-
 nfs4.1/server41tests/environment.py        |   8 +-
 nfs4.1/server41tests/st_block.py           |  24 +--
 nfs4.1/server41tests/st_create_session.py  |   6 +-
 nfs4.1/server41tests/st_debug.py           |  10 +-
 nfs4.1/server41tests/st_destroy_session.py |   2 +-
 nfs4.1/server41tests/st_exchange_id.py     |   4 +-
 nfs4.1/server41tests/st_getdevicelist.py   |  14 +-
 nfs4.1/server41tests/st_secinfo_no_name.py |   2 +-
 nfs4.1/setup.py                            |   6 +-
 nfs4.1/testclient.py                       |  30 ++--
 nfs4.1/testmod.py                          |  29 ++--
 nfs4.1/testserver.py                       |  30 ++--
 rpc/rpc.py                                 |   4 +-
 setup.py                                   |   4 +-
 showresults.py                             |   3 +-
 xdr/xdrgen.py                              |  34 ++---
 38 files changed, 329 insertions(+), 325 deletions(-)

diff --git a/nfs4.0/lib/rpc/rpc.py b/nfs4.0/lib/rpc/rpc.py
index 5ef2e3e..48e3093 100644
--- a/nfs4.0/lib/rpc/rpc.py
+++ b/nfs4.0/lib/rpc/rpc.py
@@ -1,6 +1,6 @@
 # rpc.py - based on RFC 1831
 #
-# Requires python 2.3
+# Requires python 2.7
 # 
 # Written by Fred Isaman <iisaman@citi.umich.edu>
 # Copyright (C) 2004 University of Michigan, Center for 
@@ -230,7 +230,7 @@ class RPCClient(object):
                 if why[0] == errno.EADDRINUSE:
                     port += 1
                 else:
-                    print "Could not use low port"
+                    print("Could not use low port")
                     return
 
     def getsocket(self):
@@ -326,13 +326,13 @@ class RPCClient(object):
         header, cred = self.get_call_header(xid, program, version, procedure)
         data = self.security.secure_data(data, cred)
         try:
-            if self.debug: print "send %i" % xid
+            if self.debug: print("send %i" % xid)
             self.socket.send_record(header + data)
         except socket.timeout:
             raise
         except socket.error, e:
-            print "Got error:", e
-            if self.debug: print "resend", xid
+            print("Got error:", e)
+            if self.debug: print("resend", xid)
             try:
                 self.reconnect().send_record(header + data)
             except socket.error:
@@ -346,7 +346,7 @@ class RPCClient(object):
         # If xid not on list, return error.
         # Listen until get reply with given xid.  Cache others received
         # on list.  Return error if get one not on list.
-        if self.debug: print "listen", xid
+        if self.debug: print("listen", xid)
         list = self.get_outstanding_xids()
         if xid not in list:
             raise
@@ -361,8 +361,8 @@ class RPCClient(object):
             except socket.timeout:
                 raise
             except socket.error, e:
-                print "Got error:", e
-                if self.debug: print "relisten", xid
+                print("Got error:", e)
+                if self.debug: print("relisten", xid)
                 try:
                     s = self.reconnect()
                     s.send_record(list[xid].header + list[xid].data)
@@ -472,21 +472,21 @@ class Server(object):
 
     def run(self, debug=0):
         while 1:
-            if debug: print "%s: Calling poll" % self.name
+            if debug: print("%s: Calling poll" % self.name)
             res = self.p.poll()
-            if debug: print "%s: %s" % (self.name, res)
+            if debug: print("%s: %s" % (self.name, res))
             for fd, event in res:
                 if debug:
-                    print "%s: Handling fd=%i, event=%x" % \
-                          (self.name, fd, event)
+                    print("%s: Handling fd=%i, event=%x" % \
+                          (self.name, fd, event))
                 if event & select.POLLHUP:
                     self.event_hup(fd)
                 elif event & select.POLLNVAL:
-                    if debug: print "%s: POLLNVAL for fd=%i" % (self.name, fd)
+                    if debug: print("%s: POLLNVAL for fd=%i" % (self.name, fd))
                     self.p.unregister(fd)
                 elif event & ~(select.POLLIN | select.POLLOUT):
-                    print "%s: ERROR: event %i for fd %i" % \
-                          (self.name, event, fd)
+                    print("%s: ERROR: event %i for fd %i" % \
+                          (self.name, event, fd))
                     self.event_error(fd)
                 else:
                     if event & select.POLLOUT:
@@ -534,9 +534,9 @@ class RPCServer(Server):
         csock, caddr = self.s.accept()
         csock.setblocking(0)
         if debug:
-            print "SERVER: got connection from %s, " \
+            print("SERVER: got connection from %s, " \
                   "assigned to fd=%i" % \
-                  (csock.getpeername(), csock.fileno())
+                  (csock.getpeername(), csock.fileno()))
         self.p.register(csock, _readmask)
         cfd = csock.fileno()
         self.readbufs[cfd] = ''
@@ -550,7 +550,7 @@ class RPCServer(Server):
 
         Also responds to command codes sent as encoded integers
         """
-        if debug: print "SERVER: In read event for %i" % fd
+        if debug: print("SERVER: In read event for %i" % fd)
         self.readbufs[fd] += data
         loop = True
         while loop:
@@ -566,7 +566,7 @@ class RPCServer(Server):
                     if self.readbufs[fd]:
                         loop = True # We've received data past last 
                     if last:
-                        if debug: print "SERVER: Received record from %i" % fd
+                        if debug: print("SERVER: Received record from %i" % fd)
                         recv_data = ''.join(self.packetbufs[fd])
                         self.packetbufs[fd] = []
                         if len(recv_data) == 4:
@@ -579,14 +579,14 @@ class RPCServer(Server):
                             self.p.register(fd, _bothmask)
 
     def event_write(self, fd, chunksize=2048, debug=0):
-        if debug: print "SERVER: In write event for %i" % fd
+        if debug: print("SERVER: In write event for %i" % fd)
         if self.writebufs[fd]:
-            if debug: print "  writing from writebuf"
+            if debug: print("  writing from writebuf")
             count = self.sockets[fd].send(self.writebufs[fd])
             self.writebufs[fd] = self.writebufs[fd][count:]
             # check if done?
         elif self.recordbufs[fd]:
-            if debug: print "  writing from recordbuf"
+            if debug: print("  writing from recordbuf")
             data = self.recordbufs[fd][0]
             chunk = data[:chunksize]
             if len(data) > chunksize:
@@ -601,12 +601,12 @@ class RPCServer(Server):
             count = self.sockets[fd].send(self.writebufs[fd])
             self.writebufs[fd] = self.writebufs[fd][count:]
         else:
-            if debug: print "  done writing"
+            if debug: print("  done writing")
             self.p.register(fd, _readmask)
 
     def event_command(self, cfd, comm, debug=0):
         if debug:
-            print "SERVER: command = %i, cfd = %i" % (comm, cfd)
+            print("SERVER: command = %i, cfd = %i" % (comm, cfd))
         if comm == 0: # Turn off server
             self.compute_reply = lambda x: None
             return '\0'*4
@@ -616,7 +616,7 @@ class RPCServer(Server):
 
     def event_close(self, fd, debug=0):
         if debug:
-            print "SERVER: closing %i" % fd
+            print("SERVER: closing %i" % fd)
         self.event_error(fd)
 
     def event_error(self, fd):
@@ -636,16 +636,16 @@ class RPCServer(Server):
         try:
             recv_msg = self.rpcunpacker.unpack_rpc_msg()
         except xdrlib.Error, e:
-            print "XDRError", e
+            print("XDRError", e)
             return
         if recv_msg.body.mtype != CALL:
-            print "Received a REPLY, expected a CALL"
+            print("Received a REPLY, expected a CALL")
             return
         # Check for reasons to deny the call
         call = recv_msg.body.cbody
         cred = call.cred
         flavor = cred.flavor
-        #print call
+        #print(call)
         reply_stat = MSG_ACCEPTED
         areply = rreply = None
         proc_response = ''
diff --git a/nfs4.0/lib/rpc/rpcsec/sec_auth_gss.py b/nfs4.0/lib/rpc/rpcsec/sec_auth_gss.py
index 314924b..2c68875 100644
--- a/nfs4.0/lib/rpc/rpcsec/sec_auth_gss.py
+++ b/nfs4.0/lib/rpc/rpcsec/sec_auth_gss.py
@@ -204,7 +204,7 @@ class SecAuthGss(SecFlavor):
             p.done()
             d = gssapi.acceptSecContext(token, body.handle)
             if d["major"] == GSS_S_COMPLETE:
-                print "SUCCESS!"
+                print("SUCCESS!")
                 class C(object):
                     pass
                 out = C()
@@ -223,11 +223,11 @@ class SecAuthGss(SecFlavor):
             else:
                 out = hint_string(d)
                 if out is not None:
-                    print out
+                    print(out)
                 return rpc.GARBAGE_ARGS, ''
         else:
             # Stub
-            print "Unable to handle gss_proc==%i" % body.gss_proc
+            print("Unable to handle gss_proc==%i" % body.gss_proc)
             return rpc.GARBAGE_ARGS, ''
     def make_verf(self, data):
         """Verifier sent with each RPC call
@@ -374,7 +374,7 @@ class SecAuthGss(SecFlavor):
             p.reset()
             p.pack_uint(cred.seq_num)
             d = gssapi.verifyMIC(self.gss_context, p.get_buffer(), rverf.body)
-            #print "Verify(%i):"%cred.seq_num, show_major(d['major']), show_minor(d['minor'])
+            #print("Verify(%i):"%cred.seq_num, show_major(d['major']), show_minor(d['minor']))
             
         else:
             pass
diff --git a/nfs4.0/nfs4acl.py b/nfs4.0/nfs4acl.py
index 8ae32e2..91a0316 100644
--- a/nfs4.0/nfs4acl.py
+++ b/nfs4.0/nfs4acl.py
@@ -214,6 +214,6 @@ def printableacl(acl):
     for ace in acl:
         out += "<type=%6s, flag=%2x, access=%8x, who=%s>\n" % \
                (type_str[ace.type], ace.flag, ace.access_mask, ace.who)
-    #print "leaving printableacl with out = %s" % out
+    #print("leaving printableacl with out = %s" % out)
     return out
     
diff --git a/nfs4.0/nfs4client.py b/nfs4.0/nfs4client.py
index 90c8d2c..5916dcc 100755
--- a/nfs4.0/nfs4client.py
+++ b/nfs4.0/nfs4client.py
@@ -9,8 +9,8 @@
 #
 
 import sys
-if sys.hexversion < 0x02030000:
-    print "Requires python 2.3 or higher"
+if sys.hexversion < 0x02070000:
+    print("Requires python 2.7 or higher")
     sys.exit(1)
 import os
 # Allow to be run stright from package root
@@ -22,7 +22,7 @@ import readline
 try:
     import readline
 except ImportError:
-    print "Module readline not available."
+    print("Module readline not available.")
 #else:
 #    import rlcompleter
 #    readline.parse_and_bind("tab: complete")
@@ -75,11 +75,11 @@ class PyShell(code.InteractiveConsole):
                 return self.locals[attr]
             else:
                 return getattr(inst, attr)
-        #print "\nCalled complete(%s, %i)" % (text, state)
+        #print("\nCalled complete(%s, %i)" % (text, state))
         if text.startswith('.'):
             # XXX TODO - handle array indexing
             line = readline.get_line_buffer()
-            # print "Line: ", repr(line)
+            # print("Line: ", repr(line))
             return None
         vars = text.split('.')
         base = vars[:-1]
@@ -88,7 +88,7 @@ class PyShell(code.InteractiveConsole):
             try:
                 inst = eval('.'.join(base), self.locals)
             except:
-                print "\nFAIL"
+                print("\nFAIL")
                 traceback.print_exc()
                 return None
         else:
@@ -125,7 +125,7 @@ class PyShell(code.InteractiveConsole):
 def main(server):
     c = PyShell(server)
     c.interact("Try COMPOUND([PUTROOTFH()])")
-    print "Goodbye!"
+    print("Goodbye!")
         
 if __name__ == "__main__":
     main(sys.argv[1])
diff --git a/nfs4.0/nfs4lib.py b/nfs4.0/nfs4lib.py
index 600bce0..a0fdce1 100644
--- a/nfs4.0/nfs4lib.py
+++ b/nfs4.0/nfs4lib.py
@@ -1,7 +1,7 @@
 #!/usr/bin/env python
 # nfs4lib.py - NFS4 library for Python
 #
-# Requires python 2.3
+# Requires python 2.7
 # 
 # Written by Fred Isaman <iisaman@citi.umich.edu>
 # Copyright (C) 2004 University of Michigan, Center for 
@@ -199,7 +199,7 @@ class CBServer(rpc.RPCServer):
         rpc.RPCServer.run(self)
 
     def handle_0(self, data, cred):
-        #print "*****CB received NULL******"
+        #print("*****CB received NULL******")
         if data != '':
             return rpc.GARBAGE_ARGS, ''
         else:
@@ -207,7 +207,7 @@ class CBServer(rpc.RPCServer):
     
     def handle_1(self, data, cred):
         """Deal with CB_COMPOUND"""
-        print "*****CB received COMPOUND******"
+        print("*****CB received COMPOUND******")
         self.nfs4unpacker.reset(data)
         ok, results, tag = self.O_CB_Compound()
         try:
@@ -245,7 +245,7 @@ class CBServer(rpc.RPCServer):
         
     # FIXME
     def O_CB_GetAttr(self, op, cbid):
-        print "******* CB_Getattr *******"
+        print("******* CB_Getattr *******")
         self.opcounts[OP_CB_GETATTR] += 1
         if not self.curr_fh:
             return self.simple_status(NFS4ERR_NOFILEHANDLE)
@@ -254,7 +254,7 @@ class CBServer(rpc.RPCServer):
 
     # FIXME
     def O_CB_Recall(self, op, cbid):
-        print "******* CB_Recall (id=%i)********" % cbid
+        print("******* CB_Recall (id=%i)********" % cbid)
         self.opcounts[OP_CB_RECALL] += 1
         if self.recall_funct.get(cbid, None) is not None:
             res = self.recall_funct[cbid](self.client, op, cbid)
@@ -301,7 +301,7 @@ class NFS4Client(rpc.RPCClient):
                 self.cb_control.connect(('127.0.0.1', self.cb_server.port))
                 break
             except socket.error:
-                print "Waiting for Callback server to start"
+                print("Waiting for Callback server to start")
 
     def cb_command(self, comm):
         self.cb_control.sendall('\x80\x00\x00\x04\x00\x00\x00%s' % chr(comm))
@@ -327,7 +327,7 @@ class NFS4Client(rpc.RPCClient):
                                      minorversion=minorversion)
         if SHOW_TRAFFIC:
             print
-            print compoundargs
+            print(compoundargs)
         p = self.nfs4packer
         un_p = self.nfs4unpacker
         p.reset()
@@ -336,7 +336,7 @@ class NFS4Client(rpc.RPCClient):
         un_p.reset(res)
         res = un_p.unpack_COMPOUND4res()
         if SHOW_TRAFFIC:
-            print res
+            print(res)
         un_p.done()
 
         # Do some error checking
@@ -688,7 +688,7 @@ class NFS4Client(rpc.RPCClient):
         #expect = attrs.keys()
         #expect.sort()
         #if attrlist != expect:
-        #    print "WARNING: OPENresok.attrset mismatches requested attrs"
+        #    print("WARNING: OPENresok.attrset mismatches requested attrs")
         fhandle = res.resarray[-1].switch.switch.object
         stateid = res.resarray[-2].switch.switch.stateid
         rflags = res.resarray[-2].switch.switch.rflags
diff --git a/nfs4.0/nfs4server.py b/nfs4.0/nfs4server.py
index 37c1528..d5aea34 100755
--- a/nfs4.0/nfs4server.py
+++ b/nfs4.0/nfs4server.py
@@ -16,8 +16,8 @@ except:
     pass
 
 import sys
-if sys.hexversion < 0x02030000:
-    print "Requires python 2.3 or higher"
+if sys.hexversion < 0x02070000:
+    print("Requires python 2.7 or higher")
     sys.exit(1)
 import os
 # Allow to be run stright from package root
@@ -107,15 +107,15 @@ class NFS4Server(rpc.RPCServer):
 
     def handle_0(self, data, cred):
         print
-        print "******** TCP RPC NULL CALL ********"
-        print "  flavor = %i" % cred.flavor
+        print("******** TCP RPC NULL CALL ********")
+        print("  flavor = %i" % cred.flavor)
         if cred.flavor == rpc.RPCSEC_GSS:
             gss = self.security[cred.flavor]
             body = gss.read_cred(cred.body)
             if body.gss_proc:
                 return gss.handle_proc(body, data)
         if data != '':
-            print "  ERROR - unexpected data"
+            print("  ERROR - unexpected data")
             return rpc.GARBAGE_ARGS, ''
         else:
             return rpc.SUCCESS, ''
@@ -123,12 +123,12 @@ class NFS4Server(rpc.RPCServer):
     def handle_1(self, data, cred):
         self.nfs4unpacker.reset(data)
         print
-        print "********** TCP RPC CALL ***********"
+        print("********** TCP RPC CALL ***********")
         ok, results, tag = self.O_Compound()
         try:
             self.nfs4unpacker.done()
         except XDRError:
-            print repr(self.nfs4unpacker.get_buffer())
+            print(repr(self.nfs4unpacker.get_buffer()))
             
             raise
             return rpc.GARBAGE_ARGS, ''
@@ -166,11 +166,11 @@ class NFS4Server(rpc.RPCServer):
             cmp4args = self.nfs4unpacker.unpack_COMPOUND4args()
             tag = cmp4args.tag
         except: # [XDRError, StandardError]:
-            #print "ERROR"
+            #print("ERROR")
             #raise
             return NFS4ERR_BADXDR, [], tag
-        print "TCP NFSv4 COMPOUND call, tag: %s, n_ops: %d" % \
-              (repr(tag), len(cmp4args.argarray))
+        print("TCP NFSv4 COMPOUND call, tag: %s, n_ops: %d" % \
+              (repr(tag), len(cmp4args.argarray)))
         if cmp4args.minorversion <> 0:
             return NFS4ERR_MINOR_VERS_MISMATCH, [], tag
         if not verify_utf8(tag):
@@ -180,26 +180,26 @@ class NFS4Server(rpc.RPCServer):
         ok = NFS4_OK
         for op in cmp4args.argarray:
             opname = nfs_opnum4.get(op.argop, 'op_illegal')
-            print "*** %s (%d) ***" % (opname, op.argop)
+            print("*** %s (%d) ***" % (opname, op.argop))
             ok, result = getattr(self, opname.lower())(op)
             results += [ result ]
             if ok <> NFS4_OK:
-                print " ! error %s" % nfsstat4[ok]
+                print(" ! error %s" % nfsstat4[ok])
                 break
-        print "Replying. Status %s (%d)" % (nfsstat4[ok], ok)
+        print("Replying. Status %s (%d)" % (nfsstat4[ok], ok))
         return (ok, results, tag)
 
     # FIXME
     def op_access(self, op):
-        print "  CURRENT FILEHANDLE: %s" % self.curr_fh
-        print "  REQUESTED ACCESS: %s" % access2string(op.opaccess.access)
+        print("  CURRENT FILEHANDLE: %s" % self.curr_fh)
+        print("  REQUESTED ACCESS: %s" % access2string(op.opaccess.access))
         if not self.curr_fh:
             return simple_error(NFS4ERR_NOFILEHANDLE)
         all = ACCESS4_READ | ACCESS4_LOOKUP | ACCESS4_MODIFY | \
             ACCESS4_EXTEND | ACCESS4_DELETE | ACCESS4_EXECUTE
         all = ~all
         if op.opaccess.access & all > 0:
-            print "!!!! Received invalid ACCESS bits in op.opaccess.access"
+            print("!!!! Received invalid ACCESS bits in op.opaccess.access")
             return simple_error(NFS4ERR_INVAL)
         a4_supported = self.curr_fh.supported_access()
         # according to page 140 of 3530, we only return the supported
@@ -207,25 +207,25 @@ class NFS4Server(rpc.RPCServer):
         a4_supported = op.opaccess.access & a4_supported
         a4_access = self.curr_fh.evaluate_access()
         a4_access = op.opaccess.access & a4_access # bitwise and
-        print "  RESULT SUPPORTED: %s" % access2string(a4_supported)
-        print "  RESULT ACCESS: %s" % access2string(a4_access)
+        print("  RESULT SUPPORTED: %s" % access2string(a4_supported))
+        print("  RESULT ACCESS: %s" % access2string(a4_access))
         a4resok = ACCESS4resok(a4_supported, a4_access)
         return simple_error(NFS4_OK, a4resok)
 
     def op_close(self, op):
-        print "  CURRENT FILEHANDLE: %s" % repr(self.curr_fh)
-        print "  SEQID: %i" % op.opclose.seqid
+        print("  CURRENT FILEHANDLE: %s" % repr(self.curr_fh))
+        print("  SEQID: %i" % op.opclose.seqid)
         stateid = op.opclose.open_stateid
         try:
             replay = self.state.check_seqid(stateid, op.opclose.seqid)
             if replay:
                 self.curr_fh, args = self.check_replay(op, replay)
-                print "Replay args = %s"%str(args)
+                print("Replay args = %s"%str(args))
                 return simple_error(*args)
             # Note must cache response, so need to call raise instead of return
             if not self.curr_fh:
                 raise NFS4Error(NFS4ERR_NOFILEHANDLE)
-            print "  CLOSE fh", self.curr_fh.handle
+            print("  CLOSE fh", self.curr_fh.handle)
             self.state.close(stateid)
         except NFS4Error, e:
             self.state.advance_seqid(stateid, op, (e.code,))
@@ -238,7 +238,7 @@ class NFS4Server(rpc.RPCServer):
     # Note: since currently using ram based fs, we lie here (and in write)
     # and pretend all operations are FILE_SYNC4
     def op_commit(self, op):
-        print "  CURRENT FILEHANDLE: %s" % repr(self.curr_fh)
+        print("  CURRENT FILEHANDLE: %s" % repr(self.curr_fh))
         if not self.curr_fh:
             return simple_error(NFS4ERR_NOFILEHANDLE)
         if self.curr_fh.get_type() == NF4DIR:
@@ -251,7 +251,7 @@ class NFS4Server(rpc.RPCServer):
         return simple_error(NFS4_OK, c4resok)
 
     def op_create(self, op):
-        print "  CURRENT FILEHANDLE: %s" % repr(self.curr_fh)
+        print("  CURRENT FILEHANDLE: %s" % repr(self.curr_fh))
         if not self.curr_fh:
             return simple_error(NFS4ERR_NOFILEHANDLE)
         e = verify_name(op.opcreate.objname)
@@ -265,7 +265,7 @@ class NFS4Server(rpc.RPCServer):
         try:
             old_cinfo = self.curr_fh.fattr4_change
             attrs = op.opcreate.createattrs
-            print attrs
+            print(attrs)
             attrset = self.curr_fh.create(op.opcreate.objname, op.opcreate.objtype, attrs)
             new_cinfo = self.curr_fh.fattr4_change
             self.curr_fh = self.curr_fh.lookup(op.opcreate.objname)
@@ -284,7 +284,7 @@ class NFS4Server(rpc.RPCServer):
         return simple_error(NFS4ERR_NOTSUPP)
 
     def op_getattr(self, op):
-        print "  ATTRMASK: %s" % [nfs4lib.get_attr_name(bit) for bit in nfs4lib.bitmap2list(op.opgetattr.attr_request)]
+        print("  ATTRMASK: %s" % [nfs4lib.get_attr_name(bit) for bit in nfs4lib.bitmap2list(op.opgetattr.attr_request)])
         try:
             if not self.curr_fh:
                 return simple_error(NFS4ERR_NOFILEHANDLE)
@@ -298,15 +298,15 @@ class NFS4Server(rpc.RPCServer):
     def op_getfh(self, op):
         if not self.curr_fh:
             return simple_error(NFS4ERR_NOFILEHANDLE)
-        print "  FILEHANDLE %s" % self.curr_fh.handle
+        print("  FILEHANDLE %s" % self.curr_fh.handle)
         # XXX BUG - fhcache not set on getattr or readdir(getattr)
         self.fhcache[self.curr_fh.handle] = self.curr_fh
         confirmres = GETFH4resok(str(self.curr_fh.handle))
         return simple_error(NFS4_OK, confirmres)
 
     def op_link(self, op):
-        print "  CURRENT FILEHANDLE %s" % repr(self.curr_fh)
-        print "  SOURCE OBJECT %s" % op.oplink.newname
+        print("  CURRENT FILEHANDLE %s" % repr(self.curr_fh))
+        print("  SOURCE OBJECT %s" % op.oplink.newname)
         if self.curr_fh is None or self.saved_fh is None:
             return simple_error(NFS4ERR_NOFILEHANDLE)
         if self.curr_fh.get_type() != NF4DIR:
@@ -325,7 +325,7 @@ class NFS4Server(rpc.RPCServer):
         return simple_error(NFS4_OK, l4resok)
 
     def op_lock(self, op):
-        print "  CURRENT FILEHANDLE %s" % repr(self.curr_fh)
+        print("  CURRENT FILEHANDLE %s" % repr(self.curr_fh))
         try:
             replay = None
             if op.oplock.locker.new_lock_owner:
@@ -364,7 +364,7 @@ class NFS4Server(rpc.RPCServer):
         return simple_error(NFS4_OK, l4resok)
 
     def op_lockt(self, op):
-        print "  CURRENT FILEHANDLE %s" % repr(self.curr_fh)
+        print("  CURRENT FILEHANDLE %s" % repr(self.curr_fh))
 
         if not self.curr_fh:
             return simple_error(NFS4ERR_NOFILEHANDLE)
@@ -381,7 +381,7 @@ class NFS4Server(rpc.RPCServer):
         return simple_error(NFS4_OK)
 
     def op_locku(self, op):
-        print "  CURRENT FILEHANDLE %s" % repr(self.curr_fh)
+        print("  CURRENT FILEHANDLE %s" % repr(self.curr_fh))
         stateid = op.oplocku.lock_stateid
         try:
             replay = self.state.check_seqid(stateid, op.oplocku.seqid)
@@ -400,8 +400,8 @@ class NFS4Server(rpc.RPCServer):
         return simple_error(NFS4_OK, sid)
 
     def op_lookup(self, op):
-        print "  CURRENT FILEHANDLE %s" % repr(self.curr_fh)
-        print "  REQUESTED OBJECT %s" % op.oplookup.objname
+        print("  CURRENT FILEHANDLE %s" % repr(self.curr_fh))
+        print("  REQUESTED OBJECT %s" % op.oplookup.objname)
         
         if not self.curr_fh:
             return simple_error(NFS4ERR_NOFILEHANDLE)
@@ -418,19 +418,19 @@ class NFS4Server(rpc.RPCServer):
         return simple_error(NFS4_OK)
 
     def op_lookupp(self, op):
-        print "  CURRENT FILEHANDLE %s" % repr(self.curr_fh)
+        print("  CURRENT FILEHANDLE %s" % repr(self.curr_fh))
         if not self.curr_fh:
             return simple_error(NFS4ERR_NOFILEHANDLE)
         if self.curr_fh.get_type() != NF4DIR:
             return simple_error(NFS4ERR_NOTDIR)
         self.curr_fh = self.curr_fh.do_lookupp()
-        print "  PARENT FILEHANDLE %s" % repr(self.curr_fh)
+        print("  PARENT FILEHANDLE %s" % repr(self.curr_fh))
         if self.curr_fh is None:
             return simple_error(NFS4ERR_NOENT)
         return simple_error(NFS4_OK)
 
     def op_nverify(self, op):
-        print "  CURRENT FILEHANDLE: %s" % repr(self.curr_fh)
+        print("  CURRENT FILEHANDLE: %s" % repr(self.curr_fh))
         if not self.curr_fh:
             return simple_error(NFS4ERR_NOFILEHANDLE)
         try:
@@ -446,11 +446,11 @@ class NFS4Server(rpc.RPCServer):
             return simple_error(NFS4_OK)
 
     def op_open(self, op):
-        print "  CURRENT FILEHANDLE: %s" % repr(self.curr_fh)
-        print "  SEQID: %i" % op.opopen.seqid
+        print("  CURRENT FILEHANDLE: %s" % repr(self.curr_fh))
+        print("  SEQID: %i" % op.opopen.seqid)
         owner = op.opopen.owner
-        print "  CLIENTID: %d" % owner.clientid
-        print "  OWNER: '%s'" % repr(owner.owner)
+        print("  CLIENTID: %d" % owner.clientid)
+        print("  OWNER: '%s'" % repr(owner.owner))
         try:
             if not self.state.confirmed.exists(c=owner.clientid):
                 if self.state.unconfirmed.exists(c=owner.clientid):
@@ -471,14 +471,14 @@ class NFS4Server(rpc.RPCServer):
             if self.curr_fh.get_type() != NF4DIR:
                 raise NFS4Error(NFS4ERR_NOTDIR)
             filename = op.opopen.claim.file
-            print "  FILE %s" % filename
+            print("  FILE %s" % filename)
             e = verify_name(filename)
             if e: raise NFS4Error(e)
             # At this point we know it is CLAIM_NULL with valid filename and cfh
             attrset = 0L
             ci_old = self.curr_fh.fattr4_change
             if op.opopen.openhow.opentype == OPEN4_CREATE:
-                print "  CREATING FILE."
+                print("  CREATING FILE.")
                 type_reg = createtype4(NF4REG)
                 existing = self.curr_fh.lookup(filename)
                 if existing is not None:
@@ -511,7 +511,7 @@ class NFS4Server(rpc.RPCServer):
                         attrset = self.curr_fh.create(filename, type_reg, attrs)
                         existing = self.curr_fh.lookup(filename)
             else:
-                print "  OPENING EXISTING FILE."
+                print("  OPENING EXISTING FILE.")
                 existing = self.curr_fh.lookup(filename)
                 if existing is None:
                     raise NFS4Error(NFS4ERR_NOENT)
@@ -525,7 +525,7 @@ class NFS4Server(rpc.RPCServer):
             sid, flags = self.state.open(existing, owner,
                                   op.opopen.share_access, op.opopen.share_deny)
         except NFS4Error, e:
-            print "Open error"
+            print("Open error")
             self.state.advance_seqid(owner, op, (e.code,))
             return simple_error(e.code)
         ci_new = self.curr_fh.fattr4_change
@@ -539,12 +539,12 @@ class NFS4Server(rpc.RPCServer):
 
     # FIXME: actually open the attr directory, change the filehandle
     def op_openattr(self, op):
-        print "  CURRENT FILEHANDLE: %s" % repr(self.curr_fh)
+        print("  CURRENT FILEHANDLE: %s" % repr(self.curr_fh))
         return simple_error(NFS4ERR_NOTSUPP)
 
     def op_open_confirm(self, op):
-        print "  CURRENT FILEHANDLE: %s" % repr(self.curr_fh)
-        print "  SEQID: %i" % op.opopen_confirm.seqid
+        print("  CURRENT FILEHANDLE: %s" % repr(self.curr_fh))
+        print("  SEQID: %i" % op.opopen_confirm.seqid)
         stateid = op.opopen_confirm.open_stateid
         try:
             replay = self.state.check_seqid(stateid, op.opopen_confirm.seqid,
@@ -568,7 +568,7 @@ class NFS4Server(rpc.RPCServer):
         return simple_error(NFS4_OK, oc4resok)
 
     def op_open_downgrade(self, op):
-        print "  CURRENT FILEHANDLE: %s" % repr(self.curr_fh)
+        print("  CURRENT FILEHANDLE: %s" % repr(self.curr_fh))
         stateid = op.opopen_downgrade.open_stateid
         try:
             replay = self.state.check_seqid(stateid, op.opopen_downgrade.seqid)
@@ -591,7 +591,7 @@ class NFS4Server(rpc.RPCServer):
         return simple_error(NFS4_OK, od4resok)
 
     def op_putfh(self, op):
-        print "  FILEHANDLE '%s'" % repr(op.opputfh.object)
+        print("  FILEHANDLE '%s'" % repr(op.opputfh.object))
         # check access!
         if not self.fhcache.has_key(op.opputfh.object):
             return simple_error(NFS4ERR_BADHANDLE)
@@ -599,22 +599,22 @@ class NFS4Server(rpc.RPCServer):
         return simple_error(NFS4_OK)
 
     def op_putpubfh(self, op):
-        print "  NEW FILEHANDLE %s" % repr(self.curr_fh)
+        print("  NEW FILEHANDLE %s" % repr(self.curr_fh))
         if self.pubfh is None:
             return simple_error(NFS4ERR_NOTSUPP)
         self.curr_fh = self.pubfh
         return simple_error(NFS4_OK)
 
     def op_putrootfh(self, op):
-        print "  NEW FILEHANDLE %s" % repr(self.curr_fh)
+        print("  NEW FILEHANDLE %s" % repr(self.curr_fh))
         self.curr_fh = self.rootfh
         return simple_error(NFS4_OK)
 
     def op_read(self, op):
         offset = op.opread.offset
         count = op.opread.count
-        print "  CURRENT FILEHANDLE %s" % repr(self.curr_fh)
-        print "  OFFSET: %d COUNT %d" % (offset, count)
+        print("  CURRENT FILEHANDLE %s" % repr(self.curr_fh))
+        print("  OFFSET: %d COUNT %d" % (offset, count))
         if not self.curr_fh:
             return simple_error(NFS4ERR_NOFILEHANDLE)
         if self.curr_fh.get_type() == NF4DIR:
@@ -625,7 +625,7 @@ class NFS4Server(rpc.RPCServer):
             self.state.check_read(self.curr_fh, op.opread.stateid,
                                   offset, count)
             read_data = self.curr_fh.read(offset, count)
-            print "  READ DATA: len=%i" % len(read_data)
+            print("  READ DATA: len=%i" % len(read_data))
         except NFS4Error, e:
             return simple_error(e.code)
         if len(read_data) < count:
@@ -637,10 +637,10 @@ class NFS4Server(rpc.RPCServer):
 
     def op_readdir(self, op):
         # We ignore dircount hint
-        print "  CURRENT FILEHANDLE %s" % repr(self.curr_fh)
-        print "  COOKIEVERF: %s, %s" % ( repr(op.opreaddir.cookieverf), repr(op.opreaddir.cookie))
-        print "  DIRCOUNT: %d MAXCOUNT: %d" % ( op.opreaddir.dircount, op.opreaddir.maxcount)
-        print "  ATTRMASK: %s" % [nfs4lib.get_attr_name(bit) for bit in nfs4lib.bitmap2list(op.opreaddir.attr_request)]
+        print("  CURRENT FILEHANDLE %s" % repr(self.curr_fh))
+        print("  COOKIEVERF: %s, %s" % ( repr(op.opreaddir.cookieverf), repr(op.opreaddir.cookie)))
+        print("  DIRCOUNT: %d MAXCOUNT: %d" % ( op.opreaddir.dircount, op.opreaddir.maxcount))
+        print("  ATTRMASK: %s" % [nfs4lib.get_attr_name(bit) for bit in nfs4lib.bitmap2list(op.opreaddir.attr_request)])
         if not self.curr_fh:
             return simple_error(NFS4ERR_NOFILEHANDLE)
         if self.curr_fh.get_type() != NF4DIR:
@@ -699,19 +699,19 @@ class NFS4Server(rpc.RPCServer):
         return simple_error(NFS4_OK, rdresok)
 
     def op_readlink(self, op):
-        print "  CURRENT FILEHANDLE: %s" % repr(self.curr_fh)
+        print("  CURRENT FILEHANDLE: %s" % repr(self.curr_fh))
         if not self.curr_fh:
             return simple_error(NFS4ERR_NOFILEHANDLE)
         if self.curr_fh.get_type() != NF4LNK:
             return simple_error(NFS4ERR_INVAL)
         link_text = self.curr_fh.read_link()
-        print "  LINK_TEXT: %s" % link_text
+        print("  LINK_TEXT: %s" % link_text)
         rl4resok = READLINK4resok(link_text)
         return simple_error(NFS4_OK, rl4resok)
 
     def op_remove(self, op):
-        print "  CURRENT FILEHANDLE: %s" % repr(self.curr_fh)
-        print "  TARGET: %s" % op.opremove.target
+        print("  CURRENT FILEHANDLE: %s" % repr(self.curr_fh))
+        print("  TARGET: %s" % op.opremove.target)
         #XXX: CHECK ACCESS
         if self.curr_fh is None:
             return simple_error(NFS4ERR_NOFILEHANDLE)
@@ -732,10 +732,10 @@ class NFS4Server(rpc.RPCServer):
         return simple_error(NFS4_OK, r4resok)
 
     def op_rename(self, op):
-        print "  SAVED FILEHANDLE: %s" % repr(self.saved_fh)  # old dir
-        print "  CURRENT FILEHANDLE: %s" % repr(self.curr_fh) # new dir
-        print "  OLD NAME: %s" % op.oprename.oldname
-        print "  NEW NAME: %s" % op.oprename.newname
+        print("  SAVED FILEHANDLE: %s" % repr(self.saved_fh)  # old dir)
+        print("  CURRENT FILEHANDLE: %s" % repr(self.curr_fh) # new dir)
+        print("  OLD NAME: %s" % op.oprename.oldname)
+        print("  NEW NAME: %s" % op.oprename.newname)
         if self.curr_fh is None or self.saved_fh is None:
             return simple_error(NFS4ERR_NOFILEHANDLE)
         oldname = op.oprename.oldname
@@ -782,14 +782,14 @@ class NFS4Server(rpc.RPCServer):
         return simple_error(NFS4_OK)
 
     def op_restorefh(self, op):
-        print "  SAVED FILEHANDLE: %s" % repr(self.saved_fh)
+        print("  SAVED FILEHANDLE: %s" % repr(self.saved_fh))
         if not self.saved_fh:
             return simple_error(NFS4ERR_RESTOREFH)
         self.curr_fh = self.saved_fh
         return simple_error(NFS4_OK)
 
     def op_savefh(self, op):
-        print "  CURRENT FILEHANDLE: %s" % repr(self.curr_fh)
+        print("  CURRENT FILEHANDLE: %s" % repr(self.curr_fh))
         if not self.curr_fh:
             return simple_error(NFS4ERR_NOFILEHANDLE)
         self.saved_fh = self.curr_fh
@@ -798,7 +798,7 @@ class NFS4Server(rpc.RPCServer):
     # FIXME: no idea how to set up NFS4_OK conditions; actually get sec information
     def op_secinfo(self, op):
         # STUB
-        print "  CURRENT FILEHANDLE: %s" % repr(self.curr_fh)
+        print("  CURRENT FILEHANDLE: %s" % repr(self.curr_fh))
         if not self.curr_fh:
             return simple_error(NFS4ERR_NOFILEHANDLE)
         if self.curr_fh.get_type() != NF4DIR:
@@ -809,8 +809,8 @@ class NFS4Server(rpc.RPCServer):
         return simple_error(NFS4_OK, resok)
 
     def op_setattr(self, op):
-        print "  CURRENT FILEHANDLE: %s" % repr(self.curr_fh)
-        print op.opsetattr.obj_attributes
+        print("  CURRENT FILEHANDLE: %s" % repr(self.curr_fh))
+        print(op.opsetattr.obj_attributes)
         if not self.curr_fh:
             return simple_error(NFS4ERR_NOFILEHANDLE, 0L)
         try:
@@ -835,7 +835,7 @@ class NFS4Server(rpc.RPCServer):
         return simple_error(NFS4_OK, attrset)
 
     def op_setclientid(self, op):
-        print "  ID: %s" % ( op.opsetclientid.client.id)
+        print("  ID: %s" % ( op.opsetclientid.client.id))
         x = op.opsetclientid.client.id
         v = op.opsetclientid.client.verifier
         k = (op.opsetclientid.callback, op.opsetclientid.callback_ident)
@@ -860,7 +860,7 @@ class NFS4Server(rpc.RPCServer):
             # This should never happen
             return simple_error(NFS4ERR_INVAL)
         s = self.nextverf()
-        print "   VERIFIER: %s" % repr(s)
+        print("   VERIFIER: %s" % repr(s))
         self.state.unconfirmed.add(v,x,c,k,s,p)
         resok = SETCLIENTID4resok(c, s)
         return simple_error(NFS4_OK, resok)
@@ -869,7 +869,7 @@ class NFS4Server(rpc.RPCServer):
         c = op.opsetclientid_confirm.clientid
         s = op.opsetclientid_confirm.setclientid_confirm
         p = "Stub" # Principal
-        print "  ARGS, clientid %s, verifier %s" % (c, printverf(s))
+        print("  ARGS, clientid %s, verifier %s" % (c, printverf(s)))
         # NOTE this makes the assumption that only one entry can match c=c
         entry = self.state.confirmed.find(c=c)
         entry2 = self.state.unconfirmed.find(c=c)
@@ -900,7 +900,7 @@ class NFS4Server(rpc.RPCServer):
         return simple_error(NFS4_OK)
             
     def op_verify(self, op):
-        print "  CURRENT FILEHANDLE %s" % repr(self.curr_fh)
+        print("  CURRENT FILEHANDLE %s" % repr(self.curr_fh))
         if not self.curr_fh:
             return simple_error(NFS4ERR_NOFILEHANDLE)
         try:
@@ -920,21 +920,21 @@ class NFS4Server(rpc.RPCServer):
     def op_write(self, op):
         offset = op.opwrite.offset
         data = op.opwrite.data
-        print "  CURRENT FILEHANDLE %s" % repr(self.curr_fh)
-        print "  OFFSET: %d COUNT %d" % (offset, len(data))
-        print "  STATEID { seqid: %s other: %s}" % (repr(op.opwrite.stateid.seqid), repr(op.opwrite.stateid.other))
+        print("  CURRENT FILEHANDLE %s" % repr(self.curr_fh))
+        print("  OFFSET: %d COUNT %d" % (offset, len(data)))
+        print("  STATEID { seqid: %s other: %s}" % (repr(op.opwrite.stateid.seqid), repr(op.opwrite.stateid.other)))
         if not self.curr_fh:
             return simple_error(NFS4ERR_NOFILEHANDLE)
         if self.curr_fh.get_type() == NF4DIR:
             return simple_error(NFS4ERR_ISDIR)
         if self.curr_fh.get_type() != NF4REG:
             return simple_error(NFS4ERR_INVAL)
-        #print "  DATA: %s" % op.opwrite.data
+        #print("  DATA: %s" % op.opwrite.data)
         try:
             self.state.check_write(self.curr_fh, op.opwrite.stateid,
                                    offset, len(data))
             count = self.curr_fh.write(offset, data)
-            print "  wrote %i bytes" % count
+            print("  wrote %i bytes" % count)
         except NFS4Error, e:
             return simple_error(e.code)
         w4resok = WRITE4resok(count, FILE_SYNC4, self.state.write_verifier)
@@ -956,10 +956,10 @@ def startup(host, port):
             raise
         #server.register()
     except:
-        print "!! unable to register with portmap"
+        print("!! unable to register with portmap")
         pass
-    print "Python NFSv4 Server, (c) CITI, Regents of the University of Michigan"
-    print "Starting Server, root handle: %s" % rootfh 
+    print("Python NFSv4 Server, (c) CITI, Regents of the University of Michigan")
+    print("Starting Server, root handle: %s" % rootfh )
     server.run()
     try:
         server.unregister()
diff --git a/nfs4.0/nfs4state.py b/nfs4.0/nfs4state.py
index d32da29..fb3fd5c 100755
--- a/nfs4.0/nfs4state.py
+++ b/nfs4.0/nfs4state.py
@@ -244,14 +244,14 @@ class NFSServerState:
         See RFC 3530 sec 8.1.5
         """
         # This is getting too complicated.  Should split off creation
-        #print "  check_seqid: Entered"
+        #print("  check_seqid: Entered")
         if isinstance(obj, stateid4):
             mustexist = True
         try:
             info = self.__getinfo(obj, allownew=not mustexist)
         except ValueError, e:
             if mustexist: raise
-        #print "  check_seqid: %s" % info
+        #print("  check_seqid: %s" % info)
         if info is None:
             # A reserved stateid
             raise NFS4Error(NFS4ERR_BAD_STATEID)
@@ -267,9 +267,9 @@ class NFSServerState:
             info.lastseqid = mod32(-1)
             return
         lastseq = info.lastseqid
-        #print "  check_seqid: new: %s, last: %s" % (seqid, lastseq)
+        #print("  check_seqid: new: %s, last: %s" % (seqid, lastseq))
         if lastseq == seqid:
-            print " ***REPLAY*** "
+            print(" ***REPLAY*** ")
             return info.cached_response
         if not info.confirmed and not open_confirm:
             # RFC 3530 sec 14.2.18
@@ -294,7 +294,7 @@ class NFSServerState:
             # FIXME - does this behave correctly for reserved stateids?
             return
         info.cached_response = (cfh, args, op)
-        #print "  advance_seqid - went from: %s" % info.lastseqid
+        #print("  advance_seqid - went from: %s" % info.lastseqid)
         if args[0] not in [NFS4ERR_STALE_CLIENTID, NFS4ERR_STALE_STATEID,
                            NFS4ERR_BAD_STATEID, NFS4ERR_BAD_SEQID,
                            NFS4ERR_BADXDR, NFS4ERR_RESOURCE,
@@ -303,7 +303,7 @@ class NFSServerState:
                 info.lastseqid = 0
             else:
                 info.lastseqid = mod32(info.lastseqid + 1)
-        #print "  advance_seqid -        to: %s" % info.lastseqid
+        #print("  advance_seqid -        to: %s" % info.lastseqid)
 
     def confirm(self, fh, stateid):
         """Confirm an open"""
@@ -352,7 +352,7 @@ class NFSServerState:
             raise NFS4Error(NFS4ERR_BAD_STATEID)
         info = self.state[id].owner
         fh = self.__getfh(id)
-        #print "Close fh from id", fh.handle
+        #print("Close fh from id", fh.handle)
         # Remove locks from file and deal with associated lockowners
         for lockinfo in info.lockowners:
             if fh.handle in lockinfo.files:
@@ -412,7 +412,7 @@ class NFSServerState:
         except KeyError:
             if not allownew:
                 raise ValueError, "File %s not open for %s" % (fh.name, info)
-            #print "Creating new id %i for fh %s" % (self.next_id, fh.handle)
+            #print("Creating new id %i for fh %s" % (self.next_id, fh.handle))
             id = info.files[fh.handle] = self.next_id
             self.next_id += 1
             self.state[id] = self.StateIDInfo(fh, info)
@@ -434,7 +434,7 @@ class NFSServerState:
             info = ownerdict[owner.clientid][owner.owner]
         except KeyError:
             if not allownew: raise ValueError, "Unknown owner %s" % str(owner)
-            #print "Creating new info"
+            #print("Creating new info")
             info = self.OwnerInfo(owner)
             if owner.clientid in ownerdict:
                 ownerdict[owner.clientid][owner.owner] = info
@@ -853,14 +853,14 @@ class NFSFileState:
                list[i].type == list[i-1].type:
                   list[i-1].end = list[i].end
                   del list[i]
-        print list
+        print(list)
 
     def removeposixlock(self, list, type, start, end):
         """Removes lock from sorted list, splitting existing locks as necessary
         """
         self.__removerange(list, start, end)
         list.sort()
-        print list
+        print(list)
 
     def __removerange(self, list, start, end):
         """Removes locks in given range, shrinking locks that half-overlap"""
@@ -1171,9 +1171,9 @@ class VirtualHandle(NFSFileHandle):
             try:
                 nfs4acl.maps_to_posix(acl)
             except nfs4acl.ACLError, e:
-                print "*"*50
-                print e
-                print "*"*50
+                print("*"*50)
+                print(e)
+                print("*"*50)
                 raise NFS4Error(NFS4ERR_INVAL)
         self.fattr4_acl = acl
         self.fattr4_mode = nfs4acl.acl2mode(acl)
@@ -1257,7 +1257,7 @@ class VirtualHandle(NFSFileHandle):
         # FRED - Note this currently does nothing -
         #      - and should do nothing if link count is positive
         if self.fattr4_numlinks > 0: return
-        #print "destructing: %s" % repr(self)
+        #print("destructing: %s" % repr(self))
         if self.fattr4_type == NF4DIR:
             for subfile in self.dirent.values():
                 subfile.destruct()
@@ -1324,7 +1324,7 @@ class VirtualHandle(NFSFileHandle):
         self.fattr4_change += 1
         try: self.file.seek(offset)
         except MemoryError:
-            print "MemError, offset=%s, count=%s" % (str(offset), str(len(data)))
+            print("MemError, offset=%s, count=%s" % (str(offset), str(len(data))))
             raise
         self.file.write(data)
         self.file.seek(0, 2) # Seek to eof
diff --git a/nfs4.0/servertests/environment.py b/nfs4.0/servertests/environment.py
index 4f37d0f..a848ed4 100644
--- a/nfs4.0/servertests/environment.py
+++ b/nfs4.0/servertests/environment.py
@@ -1,7 +1,7 @@
 #
 # environment.py
 #
-# Requires python 2.3
+# Requires python 2.7
 # 
 # Written by Fred Isaman <iisaman@citi.umich.edu>
 # Copyright (C) 2004 University of Michigan, Center for 
@@ -183,7 +183,7 @@ class Environment(testmod.Environment):
             path = tree + [name[type]]
             res = c.create_obj(path, type)
             if res.status != NFS4_OK:
-                print "WARNING - could not create /%s" % '/'.join(path)
+                print("WARNING - could not create /%s" % '/'.join(path))
         c.init_connection()
         fh, stateid = c.create_confirm('maketree', tree + ['file'],
                                        deny=OPEN4_SHARE_DENY_NONE)
@@ -209,18 +209,18 @@ class Environment(testmod.Environment):
 
     def sleep(self, sec, msg=''):
         """Sleep for given seconds"""
-        print "Sleeping for %g seconds:" % sec, msg
+        print("Sleeping for %g seconds:" % sec, msg)
         time.sleep(sec)
-        print "Woke up"
+        print("Woke up")
 
     def serverhelper(self, args):
         """Perform a special operation on the server side (such as
         rebooting the server)"""
         if self.opts.serverhelper is None:
-            print "Manual operation required on server:"
-            print args + " and hit ENTER when done"
+            print("Manual operation required on server:")
+            print(args + " and hit ENTER when done")
             sys.stdin.readline()
-            print "Continuing with test"
+            print("Continuing with test")
         else:
             cmd = self.opts.serverhelper
             if self.opts.serverhelperarg:
diff --git a/nfs4.0/servertests/st_delegation.py b/nfs4.0/servertests/st_delegation.py
index bc4effa..a2bce04 100644
--- a/nfs4.0/servertests/st_delegation.py
+++ b/nfs4.0/servertests/st_delegation.py
@@ -22,7 +22,7 @@ class _handle_error(object):
             try:
                 self.c.compound(ops)
             except Exception, e:
-                print "CALLBACK error in _recall:", e
+                print("CALLBACK error in _recall:", e)
                 pass
             _lock.release()
             
@@ -34,7 +34,7 @@ def _recall(c, thisop, cbid):
     try:
         res = c.compound(ops)
     except Exception, e:
-        print "CALLBACK error in _recall:", e
+        print("CALLBACK error in _recall:", e)
         res = None
     _lock.release()
     if res is not None and res.status != NFS4_OK:
@@ -260,7 +260,7 @@ def testManyReaddeleg(t, env, funct=_recall, response=NFS4_OK):
             cbids.append(c.cbid)
     if not cbids:
         t.pass_warn("Could not get any read delegations")
-    print "Got %i out of %i read delegations" % (len(cbids), count)
+    print("Got %i out of %i read delegations" % (len(cbids), count))
     # Cause them to be recalled
     fh2, stateid2 = _cause_recall(t, env)
     miss_count = 0
diff --git a/nfs4.0/servertests/st_fslocations.py b/nfs4.0/servertests/st_fslocations.py
index 102db52..442d5a2 100644
--- a/nfs4.0/servertests/st_fslocations.py
+++ b/nfs4.0/servertests/st_fslocations.py
@@ -20,7 +20,7 @@ def testReference(t, env):
     res = c.compound(ops)
     check(res, NFS4ERR_MOVED, "GETFH of path indicated by --usespecial")
     locs = c.do_getattr(FATTR4_FS_LOCATIONS, path)
-    print "After NFS4ERR_MOVED, GETATTR(fs_locations) = %s" % locs
+    print("After NFS4ERR_MOVED, GETATTR(fs_locations) = %s" % locs)
 
 def testReference2(t, env):
     """FSLOCATION test of referral node
@@ -33,7 +33,7 @@ def testReference2(t, env):
     c = env.c1
     path = env.opts.usespecial
     locs = c.do_getattr(FATTR4_FS_LOCATIONS, path)
-    print "After NFS4ERR_MOVED, GETATTR(fs_locations) = %s" % locs
+    print("After NFS4ERR_MOVED, GETATTR(fs_locations) = %s" % locs)
 
 def testReference3(t, env):
     """FSLOCATION test of referral node
@@ -46,7 +46,7 @@ def testReference3(t, env):
     c = env.c1
     path = env.opts.usespecial
     locs = c.do_getattr(FATTR4_FS_LOCATIONS, c.homedir)
-    print "After NFS4ERR_MOVED, GETATTR(fs_locations) = %s" % locs
+    print("After NFS4ERR_MOVED, GETATTR(fs_locations) = %s" % locs)
 
 def testAttr1a(t, env):
     """GETATTR with attributes should return _MOVED
@@ -104,10 +104,10 @@ def testAttr2b(t, env):
     attrlist = [FATTR4_SIZE, FATTR4_FILEHANDLE, FATTR4_RDATTR_ERROR, FATTR4_FSID]
     entries = c.do_readdir(path, attr_request=attrlist)
     moved = [e for e in entries if e.attrdict[FATTR4_RDATTR_ERROR] == NFS4ERR_MOVED]
-    print "RDATTR==MOVED for:", [e.name for e in moved]
+    print("RDATTR==MOVED for:", [e.name for e in moved])
     for e in moved:
         if len(e.attrdict) != 2:
-            print e.attrdict
+            print(e.attrdict)
             t.fail("Expected 2 attrs returned for file %s, got %i" % (e.name, len(e.attrdict)))
         
 def testAttr3a(t, env):
@@ -137,7 +137,7 @@ def testAttr3b(t, env):
     entries = c.do_readdir(path, attr_request=attrlist)
     moved = [e for e in entries if e.name == env.opts.usespecial[-1]][0]
     if len(moved.attrdict) != 3:
-        print moved.attrdict
+        print(moved.attrdict)
         t.fail("Expected 3 attrs returned for file %s, got %i" % (moved.name, len(moved.attrdict)))
         
 def testAttr4a(t, env):
@@ -150,7 +150,7 @@ def testAttr4a(t, env):
     path = env.opts.usespecial
     attrlist = [FATTR4_SIZE, FATTR4_FILEHANDLE, FATTR4_RDATTR_ERROR, FATTR4_FSID, FATTR4_FS_LOCATIONS]
     d = c.do_getattrdict(path, attrlist)
-    print d
+    print(d)
     if len(d) != 3:
         t.fail("Expected 3 attrs returned, got %i" % len(d))
 
@@ -167,10 +167,10 @@ def testAttr4b(t, env):
     attrlist = [FATTR4_SIZE, FATTR4_FILEHANDLE, FATTR4_RDATTR_ERROR, FATTR4_FSID, FATTR4_FS_LOCATIONS]
     entries = c.do_readdir(path, attr_request=attrlist)
     moved = [e for e in entries if e.attrdict[FATTR4_RDATTR_ERROR] == NFS4ERR_MOVED]
-    print "RDATTR==MOVED for:", [e.name for e in moved]
+    print("RDATTR==MOVED for:", [e.name for e in moved])
     for e in moved:
         if len(e.attrdict) != 3:
-            print e.attrdict
+            print(e.attrdict)
             t.fail("Expected 3 attrs returned for file %s, got %i" % (e.name, len(e.attrdict)))
         
 def testAttr5a(t, env):
@@ -183,7 +183,7 @@ def testAttr5a(t, env):
     path = env.opts.usespecial
     attrlist = [FATTR4_SIZE, FATTR4_FILEHANDLE, FATTR4_FSID, FATTR4_FS_LOCATIONS]
     d = c.do_getattrdict(path, attrlist)
-    print d
+    print(d)
     if len(d) != 2:
         t.fail("Expected 3 attrs returned, got %i" % len(d))
 
@@ -201,6 +201,6 @@ def testAttr5b(t, env):
     entries = c.do_readdir(path, attr_request=attrlist)
     moved = [e for e in entries if e.name == env.opts.usespecial[-1]][0]
     if len(moved.attrdict) != 2:
-        print moved.attrdict
+        print(moved.attrdict)
         t.fail("Expected 2 attrs returned for file %s, got %i" % (moved.name, len(moved.attrdict)))
         
diff --git a/nfs4.0/servertests/st_getattr.py b/nfs4.0/servertests/st_getattr.py
index eeffa77..500542d 100644
--- a/nfs4.0/servertests/st_getattr.py
+++ b/nfs4.0/servertests/st_getattr.py
@@ -486,7 +486,7 @@ def testFSLocations(t, env):
     check(res, [NFS4_OK, NFS4ERR_ATTRNOTSUPP], "GETATTR(fs_locations)")
     if res.status == NFS4ERR_ATTRNOTSUPP:
         t.fail_support("fs_locations not a supported attribute")
-    # print res.resarray[-1].obj_attributes
+    # print(res.resarray[-1].obj_attributes)
 
 def testLotsofGetattrsFile(t, env):
     """Send lots of getattrs
@@ -517,7 +517,7 @@ def testOwnerName(t, env):
     check(res, [NFS4_OK, NFS4ERR_ATTRNOTSUPP], "GETATTR(owner)")
     if res.status == NFS4ERR_ATTRNOTSUPP:
         t.fail_support("owner not a supported attribute")
-    # print res.resarray[-1].obj_attributes
+    # print(res.resarray[-1].obj_attributes)
 
 
 ####################################################
@@ -541,9 +541,9 @@ def testOwnerName(t, env):
         res = self.ncl.do_ops(ops)
         self.assert_OK(res)
         print
-        print "From Getattr / - ", res.resarray[-3].obj_attributes
+        print("From Getattr / - ", res.resarray[-3].obj_attributes)
         print
-        print "From Getattr /unix - ", res.resarray[-1].obj_attributes
+        print("From Getattr /unix - ", res.resarray[-1].obj_attributes)
 
         ops = [op.putrootfh()]
         attrmask = nfs4lib.list2bitmap(request)
@@ -561,6 +561,6 @@ def testOwnerName(t, env):
             if not entry.nextentry:
                 self.fail("Could not find mountpoint /unix")
             entry = entry.nextentry[0]
-        print "From Readdir / - ", entry.attrs
+        print("From Readdir / - ", entry.attrs)
         
 
diff --git a/nfs4.0/servertests/st_reboot.py b/nfs4.0/servertests/st_reboot.py
index ecfc61f..33c3a4a 100644
--- a/nfs4.0/servertests/st_reboot.py
+++ b/nfs4.0/servertests/st_reboot.py
@@ -217,7 +217,7 @@ def testRootSquash(t, env):
     oldname = oldowner.split('@')[0]
     if oldname == 'root':
         t.fail_support("No root squashing detected")
-    print "Detected root squashing: root -> %s" % oldname
+    print("Detected root squashing: root -> %s" % oldname)
     
     # Wait for grace period to have *just* expired
     _waitForReboot(c, env)
diff --git a/nfs4.0/testserver.py b/nfs4.0/testserver.py
index 9af7703..c049a5a 100755
--- a/nfs4.0/testserver.py
+++ b/nfs4.0/testserver.py
@@ -27,7 +27,7 @@
 
 import sys
 if sys.hexversion < 0x02050000:
-    print "Requires python 2.5 or higher"
+    print("Requires python 2.5 or higher")
     sys.exit(1)
 import os
 # Allow to be run stright from package root
@@ -217,16 +217,16 @@ def printflags(list):
     command_names = [s.lower()[3:].replace('_', '') \
                      for s in nfs_opnum4.values()]
     list.sort()
-    # First print command names
+    # First print(command names)
     print
     for s in list:
         if s in command_names:
-            print s
+            print(s)
     # Then everything else
     print
     for s in list:
         if s not in command_names:
-            print s
+            print(s)
     
 def main():
     nfail = -1
@@ -251,14 +251,14 @@ def main():
         codes = cdict.keys()
         codes.sort()
         for c in codes:
-            print c
+            print(c)
         sys.exit(0)
 
     if opt.showcodesflags:
         codes = cdict.keys()
         codes.sort()
         for c in codes:
-            print c, "FLAGS:", ', '.join(cdict[c].flags_list)
+            print(c, "FLAGS:", ', '.join(cdict[c].flags_list))
         sys.exit(0)
 
     # Grab server info and set defaults
@@ -285,14 +285,14 @@ def main():
     for attr in dir(opt):
         if attr.startswith('use') and attr != "usefh":
             path = getattr(opt, attr)
-            #print attr, path
+            #print(attr, path)
             if path is None:
                 path = opt.path + ['tree', attr[3:]]
             else:
                 # FIXME - have funct that checks path validity
                 if path[0] != '/':
                     p.error("Need to use absolute path for --%s" % attr)
-                # print path
+                # print(path)
                 if path[-1] == '/' and attr != 'usedir':
                     p.error("Can't use dir for --%s" %attr)
                 try:
@@ -337,21 +337,21 @@ def main():
     # Place tests in desired order
     tests.sort() # FIXME - add options for random sort
 
-    # Run the tests and save/print results
+    # Run the tests and save/print(results)
     try:
         env = environment.Environment(opt)
         env.init()
     except socket.gaierror, e:
         if e.args[0] == -2:
-            print "Unknown server '%s'" % opt.server
-        print sys.exc_info()[1]
+            print("Unknown server '%s'" % opt.server)
+        print(sys.exc_info()[1])
         sys.exit(1)
     except Exception, e:
-        print "Initialization failed, no tests run."
+        print("Initialization failed, no tests run.")
         if not opt.maketree:
-            print "Perhaps you need to use the --maketree option"
+            print("Perhaps you need to use the --maketree option")
         raise
-        print sys.exc_info()[1]
+        print(sys.exc_info()[1])
         sys.exit(1)
     if opt.outfile is not None:
         fd = file(opt.outfile, 'w')
@@ -371,7 +371,7 @@ def main():
         fail = True
     nfail = testmod.printresults(tests, opt)
     if fail:
-        print "\nWARNING: could not clean testdir due to:\n%s\n" % str(e)
+        print("\nWARNING: could not clean testdir due to:\n%s\n" % str(e))
 
     if opt.xmlout is not None:
         testmod.xml_printresults(tests, opt.xmlout)
diff --git a/nfs4.1/block.py b/nfs4.1/block.py
index f37bd9b..5ce5ccb 100644
--- a/nfs4.1/block.py
+++ b/nfs4.1/block.py
@@ -159,7 +159,7 @@ class Simple(Volume):
         return pnfs_block_volume4(PNFS_BLOCK_VOLUME_SIMPLE, bv_simple_info=info)
 
     def resolve(self, i):
-        # print "resolve(%i) %r" % (i, self)
+        # print("resolve(%i) %r" % (i, self))
         if i < 0 or i >= self._size:
             raise ValueError("Asked for %i of %i" % (i, self._size))
         return (self, i)
@@ -186,8 +186,8 @@ class Slice(Volume):
         return pnfs_block_volume4(PNFS_BLOCK_VOLUME_SLICE, bv_slice_info=info)
 
     def resolve(self, i):
-        # print "resolve(%i) %r" % (i, self)
-        # print self.start, self._size, self.length
+        # print("resolve(%i) %r" % (i, self))
+        # print(self.start, self._size, self.length)
         if i < 0 or i >= self._size:
             raise ValueError("Asked for %i of %i" % (i, self._size))
         return self.volumes[0].resolve(self.start + i)
@@ -212,7 +212,7 @@ class Concat(Volume):
         return "Concat %i of %r" % (self.id, [v.id for v in self.volumes])
 
     def resolve(self, i):
-        # print "resolve(%i) %r" % (i, self)
+        # print("resolve(%i) %r" % (i, self))
         if i < 0 or i >= self._size:
             raise ValueError("Asked for %i of %i" % (i, self._size))
         sum = 0
diff --git a/nfs4.1/client41tests/ct_reboot.py b/nfs4.1/client41tests/ct_reboot.py
index a5d54a1..3bd241b 100644
--- a/nfs4.1/client41tests/ct_reboot.py
+++ b/nfs4.1/client41tests/ct_reboot.py
@@ -204,12 +204,12 @@ def testTwoValueSetupOrCleanup(t, env):
     echo "Messagetype value value" > $CONFIG/ops/<operation>
 
     """
-    #print 'env.opts.useparams ', env.opts.useparams
+    #print('env.opts.useparams ', env.opts.useparams)
     if len(env.opts.useparams) != 4:
-        print 'TWO_VALUE_SETUP_OR_CLEANUP requires '
-        print 'testclient.py --useparams'
-        print 'Example: --useparams=sequence:ERROR:NFS4ERR_SEQ_MISORDERED:50 '
-        print 'which returns NFS4ERR_SEQ_MISORDERED every 50th sequence op'
+        print('TWO_VALUE_SETUP_OR_CLEANUP requires ')
+        print('testclient.py --useparams')
+        print('Example: --useparams=sequence:ERROR:NFS4ERR_SEQ_MISORDERED:50 ')
+        print('which returns NFS4ERR_SEQ_MISORDERED every 50th sequence op')
         fail("Bad Input to test")
 
     operation = env.opts.useparams[0]
diff --git a/nfs4.1/client41tests/environment.py b/nfs4.1/client41tests/environment.py
index 262c812..6b48d12 100644
--- a/nfs4.1/client41tests/environment.py
+++ b/nfs4.1/client41tests/environment.py
@@ -1,7 +1,7 @@
 #
 # environment.py
 #
-# Requires python 2.3
+# Requires python 2.7
 # 
 # Written by Fred Isaman <iisaman@citi.umich.edu>
 # Copyright (C) 2004 University of Michigan, Center for 
@@ -144,7 +144,7 @@ class Environment(testmod.Environment):
         path = os.path.join(self.root, "config", "ops", opname)
         fd = open(path, "w")
         fd.write(data)
-        print "wait for leasetime: ", lease[1], "seconds"
+        print("wait for leasetime: ", lease[1], "seconds")
         fd.close()
         time.sleep(int(lease[1]))
 
diff --git a/nfs4.1/config.py b/nfs4.1/config.py
index 4747f73..1dbb2ac 100644
--- a/nfs4.1/config.py
+++ b/nfs4.1/config.py
@@ -49,23 +49,23 @@ def _opline(value):
     message-type of error has this form: "ERROR NFS4ERR_code ceiling"
     new message types and more values can be added
     """
-    print '**************** OPLINE typevalue ', type(value)
+    print('**************** OPLINE typevalue ', type(value))
     if type(value) is str:
         l = value.strip().split()
     elif type(value) is list:
         l = value
     else:
-        print '                 OPLINE type ', type(value)
+        print('                 OPLINE type ', type(value))
         raise TypeError, 'Only type list or str accepted'
     if l[0] == "ERROR":
         if not len(l) == 3:
-            print '                 OPLINE length ', len
+            print('                 OPLINE length ', len)
             raise ValueError("ERROR messages only accepts 3 entries")
-        print 'OPLINE len ', len(l)
+        print('OPLINE len ', len(l))
         value = [l[0], _statcode(l[1]), int(l[2])]
     else:
         raise ValueError("Only message-type ERROR accepted")
-    print '**************** OPLINE return ', value
+    print('**************** OPLINE return ', value)
     return value
 
 ###################################################
diff --git a/nfs4.1/errorparser.py b/nfs4.1/errorparser.py
index 3de2052..328fe8d 100755
--- a/nfs4.1/errorparser.py
+++ b/nfs4.1/errorparser.py
@@ -112,7 +112,7 @@ class ErrorParser():
             except IndexError: # function
                 functions = Errors()
                 func = getattr(functions, random.choice(err.function))
-                print func
+                print(func)
                 if callable(func):
                     func(opname, arg, env)
 
diff --git a/nfs4.1/locking.py b/nfs4.1/locking.py
index 7330bbc..1dc428f 100644
--- a/nfs4.1/locking.py
+++ b/nfs4.1/locking.py
@@ -32,7 +32,7 @@ def _collect_acq_data(suffix=""):
     def _deco(acquire):
         def wrapper(self):
             suf = ("" if not suffix else "_%s" % suffix)
-            print "ACQUIRE%s tried for lock %s" % (suf.upper(), self.name)
+            print("ACQUIRE%s tried for lock %s" % (suf.upper(), self.name))
             t = threading.currentThread()
             try:
                 t.locks[self.name] = "waiting%s" % suf
@@ -40,7 +40,7 @@ def _collect_acq_data(suffix=""):
                 t.locks = {self.name: "waiting%s" % suf}
             acquire(self)
             t.locks[self.name] = "holding%s" % suf
-            print "ACQUIRE%s succeeded for lock %s" % (suf.upper(), self.name)
+            print("ACQUIRE%s succeeded for lock %s" % (suf.upper(), self.name))
         return wrapper
     return _deco
 
@@ -49,7 +49,7 @@ def _collect_rel_data(suffix=""):
     def _deco(release):
         def wrapper(self, *args, **kwargs):
             suf = ("" if not suffix else "_%s" % suffix)
-            print "RELEASE%s lock %s" % (suf.upper(), self.name)
+            print("RELEASE%s lock %s" % (suf.upper(), self.name))
             t = threading.currentThread()
             t.locks[self.name] = "released%s" % suf
             release(self, *args, **kwargs)
diff --git a/nfs4.1/nfs4lib.py b/nfs4.1/nfs4lib.py
index 02352e1..96752c2 100644
--- a/nfs4.1/nfs4lib.py
+++ b/nfs4.1/nfs4lib.py
@@ -208,7 +208,7 @@ class FancyNFS4Packer(NFS4Packer):
         """Change simple list of entry4 into strange chain structure"""
         out = []
         for e in data.entries[::-1]:
-            # print "handle", e
+            # print("handle", e)
             # This reverses the direction of the list, so start with reversed
             out = [xdrdef.nfs4_type.entry4(e.cookie, e.name, e.attrs, out)]
         # Must not modify original data structure
@@ -297,10 +297,10 @@ def bitmap2list(bitmap):
 def printhex(str, pretty=True):
     """Print string as hex digits"""
     if pretty:
-        print "".join(["%02x " % ord(c) for c in str])
+        print("".join(["%02x " % ord(c) for c in str]))
     else:
         # Can copy/paste this string
-        print "".join(["\\x%02x" % ord(c) for c in str])
+        print("".join(["\\x%02x" % ord(c) for c in str]))
 
 def str_xor(a, b):
     """xor two string which represent binary data"""
diff --git a/nfs4.1/nfs4proxy.py b/nfs4.1/nfs4proxy.py
index 58c26cb..efb6744 100755
--- a/nfs4.1/nfs4proxy.py
+++ b/nfs4.1/nfs4proxy.py
@@ -69,7 +69,7 @@ class NFS4Proxy(rpc.Server):
             while True:
                 try:
                     server_address = (self.dserver, self.dport)
-                    print server_address
+                    print(server_address)
                     pipe = self.connect(server_address)
                 except:
                     traceback.print_exc(file=sys.stdout)
diff --git a/nfs4.1/nfs4server.py b/nfs4.1/nfs4server.py
index 7ca4d92..8856a82 100755
--- a/nfs4.1/nfs4server.py
+++ b/nfs4.1/nfs4server.py
@@ -521,7 +521,7 @@ class SummaryOutput:
         print_summary_line = True
         if summary_line != self._last or role != self._last_role:
             if self._last and self._repeat_count:
-                print "  (repeated %u times)" % self._repeat_count
+                print("  (repeated %u times)" % self._repeat_count)
             self._last = summary_line
             self._repeat_count = 0
         else:
@@ -530,11 +530,11 @@ class SummaryOutput:
 
         if self._last_role != role:
             print
-            print role
+            print(role)
             self._last_role = role
 
         if print_summary_line:
-            print summary_line
+            print(summary_line)
 
 
 ##################################################
@@ -613,7 +613,7 @@ class NFS4Server(rpc.Server):
 
         Note that order matters, since the mount hides anything beneath it.
         """
-        print "Mounting %r on %r" % (fs.fsid, path)
+        print("Mounting %r on %r" % (fs.fsid, path))
         # Find directory object on which to mount fs
         dir = self.root
         principal = nfs4lib.NFS4Principal("root", system=True)
@@ -1964,14 +1964,14 @@ class NFS4Server(rpc.Server):
                 calls.append(call)
             if arg.dir & xdrdef.sctrl_const.DIR_REPLY:
                 replies.append(reply)
-        #print calls
-        #print replies
+        #print(calls)
+        #print(replies)
         grabres = xdrdef.sctrl_type.GRABres(calls, replies)
         return xdrdef.sctrl_const.CTRLSTAT_OK, \
                xdrdef.sctrl_type.resdata_t(arg.ctrlop, grab = grabres)
 
     def ctrl_illegal(self, arg):
-        #print "ILLEGAL"
+        #print("ILLEGAL")
         return xdrdef.sctrl_const.CTRLSTAT_ILLEGAL, xdrdef.sctrl_type.resdata_t(arg.ctrlop)
         
     def op_setclientid(self, arg, env):
diff --git a/nfs4.1/server41tests/environment.py b/nfs4.1/server41tests/environment.py
index a910a69..1a837ee 100644
--- a/nfs4.1/server41tests/environment.py
+++ b/nfs4.1/server41tests/environment.py
@@ -1,7 +1,7 @@
 #
 # environment.py
 #
-# Requires python 2.3
+# Requires python 2.7
 # 
 # Written by Fred Isaman <iisaman@citi.umich.edu>
 # Copyright (C) 2004 University of Michigan, Center for 
@@ -225,10 +225,10 @@ class Environment(testmod.Environment):
         """Perform a special operation on the server side (such as
         rebooting the server)"""
         if self.opts.serverhelper is None:
-            print "Manual operation required on server:"
-            print args + " and hit ENTER when done"
+            print("Manual operation required on server:")
+            print(args + " and hit ENTER when done")
             sys.stdin.readline()
-            print "Continuing with test"
+            print("Continuing with test")
         else:
             cmd = self.opts.serverhelper
             if self.opts.serverhelperarg:
diff --git a/nfs4.1/server41tests/st_block.py b/nfs4.1/server41tests/st_block.py
index bf968f9..2041de3 100644
--- a/nfs4.1/server41tests/st_block.py
+++ b/nfs4.1/server41tests/st_block.py
@@ -22,14 +22,14 @@ def testStateid1(t, env):
     # Get layout 1
     fh = res.resarray[-1].object
     open_stateid = res.resarray[-2].stateid
-    print open_stateid
+    print(open_stateid)
     ops = [op.putfh(fh),
            op.layoutget(False, LAYOUT4_BLOCK_VOLUME, LAYOUTIOMODE4_RW,
                         0, 8192, 8192, open_stateid, 0xffff)]
     res = sess.compound(ops)
     check(res)
     lo_stateid = res.resarray[-1].logr_stateid
-    print lo_stateid
+    print(lo_stateid)
     if lo_stateid.seqid != 1:
         # From draft23 12.5.2 "The first successful LAYOUTGET processed by
         # the server using a non-layout stateid as an argument MUST have the
@@ -43,7 +43,7 @@ def testStateid1(t, env):
         res = sess.compound(ops)
         check(res)
         lo_stateid = res.resarray[-1].logr_stateid
-        print lo_stateid
+        print(lo_stateid)
         if lo_stateid.seqid != i + 2:
             # From draft23 12.5.3 "After the layout stateid is established,
             # the server increments by one the value of the "seqid" in each
@@ -63,7 +63,7 @@ def testStateid2(t, env):
     # Get layout 1
     fh = res.resarray[-1].object
     open_stateid = res.resarray[-2].stateid
-    print open_stateid
+    print(open_stateid)
     ops = [op.putfh(fh),
            op.layoutget(False, LAYOUT4_BLOCK_VOLUME, LAYOUTIOMODE4_RW,
                         0, 8192, 8192, open_stateid, 0xffff)]
@@ -71,7 +71,7 @@ def testStateid2(t, env):
     check(res)
     # Get layout 2
     lo_stateid1 = res.resarray[-1].logr_stateid
-    print lo_stateid1
+    print(lo_stateid1)
     ops = [op.putfh(fh),
            op.layoutget(False, LAYOUT4_BLOCK_VOLUME, LAYOUTIOMODE4_RW,
                         8192, 8192, 8192, lo_stateid1, 0xffff)]
@@ -79,14 +79,14 @@ def testStateid2(t, env):
     check(res)
     # Get layout 3 (merge of prior two)
     lo_stateid2 = res.resarray[-1].logr_stateid
-    print lo_stateid2
+    print(lo_stateid2)
     ops = [op.putfh(fh),
            op.layoutget(False, LAYOUT4_BLOCK_VOLUME, LAYOUTIOMODE4_RW,
                         0, 2*8192, 2*8192, lo_stateid2, 0xffff)]
     res = sess.compound(ops)
     check(res)
     lo_stateid3 = res.resarray[-1].logr_stateid
-    print lo_stateid3
+    print(lo_stateid3)
     # lo_stateid3.seqid = 3 # BUG - work around emc problem
     # Parse opaque to get info for commit
     # STUB not very general
@@ -122,7 +122,7 @@ def testEmptyCommit(t, env):
     # Get layout 1
     fh = res.resarray[-1].object
     open_stateid = res.resarray[-2].stateid
-    print open_stateid
+    print(open_stateid)
     ops = [op.putfh(fh),
            op.layoutget(False, LAYOUT4_BLOCK_VOLUME, LAYOUTIOMODE4_RW,
                         0, 8192, 8192, open_stateid, 0xffff)]
@@ -130,14 +130,14 @@ def testEmptyCommit(t, env):
     check(res)
     # Get layout 2
     lo_stateid1 = res.resarray[-1].logr_stateid
-    print lo_stateid1
+    print(lo_stateid1)
     ops = [op.putfh(fh),
            op.layoutget(False, LAYOUT4_BLOCK_VOLUME, LAYOUTIOMODE4_RW,
                         8192, 8192, 8192, lo_stateid1, 0xffff)]
     res = sess.compound(ops)
     check(res)
     lo_stateid2 = res.resarray[-1].logr_stateid
-    print lo_stateid2
+    print(lo_stateid2)
     # Parse opaque to get info for commit
     # STUB not very general
     layout = res.resarray[-1].logr_layout[-1]
@@ -183,7 +183,7 @@ def testSplitCommit(t, env):
     # Get layout 1
     fh = res.resarray[-1].object
     open_stateid = res.resarray[-2].stateid
-    print open_stateid
+    print(open_stateid)
     ops = [op.putfh(fh),
            op.layoutget(False, LAYOUT4_BLOCK_VOLUME, LAYOUTIOMODE4_RW,
                         0, 2*8192, 2*8192, open_stateid, 0xffff)]
@@ -191,7 +191,7 @@ def testSplitCommit(t, env):
     check(res)
 
     lo_stateid1 = res.resarray[-1].logr_stateid
-    print lo_stateid1
+    print(lo_stateid1)
     # Parse opaque to get info for commit
     # STUB not very general
     layout = res.resarray[-1].logr_layout[-1]
diff --git a/nfs4.1/server41tests/st_create_session.py b/nfs4.1/server41tests/st_create_session.py
index bf1eefc..2ab8ba0 100644
--- a/nfs4.1/server41tests/st_create_session.py
+++ b/nfs4.1/server41tests/st_create_session.py
@@ -310,7 +310,7 @@ def testRdmaArray2(t, env):
     xid = c.compound_async(ops, checks=False)
     try:
         res = c.listen(xid)
-        print res
+        print(res)
     except RPCAcceptError, e:
         if e.stat == GARBAGE_ARGS:
             # Legitimate return
@@ -339,7 +339,7 @@ def testCallbackProgram(t, env):
     cb_occurred = threading.Event()
     transient = 0x40000004
     def mycheck(prog):
-        print "Got call using prog=0x%x" % prog
+        print("Got call using prog=0x%x" % prog)
         cb_occurred.prog = prog
         cb_occurred.set()
         return True;
@@ -366,7 +366,7 @@ def testCallbackVersion(t, env):
     cb_occurred = threading.Event()
     transient = 0x40000000
     def mycheck(low, hi, vers):
-        print "Got call using version=%i" % vers
+        print("Got call using version=%i" % vers)
         cb_occurred.low = low
         cb_occurred.hi = hi
         cb_occurred.vers = vers
diff --git a/nfs4.1/server41tests/st_debug.py b/nfs4.1/server41tests/st_debug.py
index 532ee7a..e34d03f 100644
--- a/nfs4.1/server41tests/st_debug.py
+++ b/nfs4.1/server41tests/st_debug.py
@@ -31,7 +31,7 @@ def testSupported2(t, env):
                       owner, how, claim)
     res = sess2.compound(env.home + [open_op])
     # STUB - since we are not handling callback, deleg_return never gets done
-    print res
+    print(res)
     check(res)
     fh2 = res.resarray[-1].object
     stateid2 = res.resarray[-2].stateid
@@ -55,16 +55,16 @@ def testReadWrite(t, env):
                       owner, how, claim)
     fh_op = op.putrootfh()
     res = sess1.compound([fh_op, open_op, op.getfh()]) # OPEN
-    print res
+    print(res)
     check(res)
     fh = res.resarray[-1].object
     stateid = res.resarray[-2].stateid
     stateid.seqid = 0
     res = sess1.compound([op.putfh(fh), op.write(stateid, 5, FILE_SYNC4, "write test data")])
-    print res
+    print(res)
     check(res)
     res = sess1.compound([op.putfh(fh), op.read(stateid, 0, 1000)])
-    print res
+    print(res)
     check(res)
     res = close_file(sess1, fh, stateid=stateid)
     check(res)
@@ -95,7 +95,7 @@ def testDeadlock(t, env):
     for xid in xids:
         res = sess1.listen(xid)
         check(res)
-        print res
+        print(res)
     res = close_file(sess1, fh, stateid=stateid)
     check(res)
 
diff --git a/nfs4.1/server41tests/st_destroy_session.py b/nfs4.1/server41tests/st_destroy_session.py
index c48d144..466845d 100644
--- a/nfs4.1/server41tests/st_destroy_session.py
+++ b/nfs4.1/server41tests/st_destroy_session.py
@@ -109,7 +109,7 @@ def testDestroy3(t, env):
     check(res)
     fh = res.resarray[-1].object
     deleg = res.resarray[-2].delegation
-    print "OPEN fh =", repr(fh)
+    print("OPEN fh =", repr(fh))
     if deleg.delegation_type == OPEN_DELEGATE_NONE:
         fail("Could not get delegation")
     recall.happened = False
diff --git a/nfs4.1/server41tests/st_exchange_id.py b/nfs4.1/server41tests/st_exchange_id.py
index b0ab99c..68f3b09 100644
--- a/nfs4.1/server41tests/st_exchange_id.py
+++ b/nfs4.1/server41tests/st_exchange_id.py
@@ -91,7 +91,7 @@ def testSSV(t, env):
     # This should fail if not using GSS?  What about E_ID?
 
     res = sess.set_ssv('\x5a' * c.protect.context.ssv_len)
-    print res
+    print(res)
     
 def testNoImplId(t, env):
     """Do a simple EXCHANGE_ID w/o setting client impl_id
@@ -118,7 +118,7 @@ def testLongArray(t, env):
     xid = c.compound_async(ops, checks=False)
     try:
         res = c.listen(xid)
-        print res
+        print(res)
     except RPCAcceptError, e:
         if e.stat == GARBAGE_ARGS:
             # Legitimate return
diff --git a/nfs4.1/server41tests/st_getdevicelist.py b/nfs4.1/server41tests/st_getdevicelist.py
index a556ce0..edf5fe4 100644
--- a/nfs4.1/server41tests/st_getdevicelist.py
+++ b/nfs4.1/server41tests/st_getdevicelist.py
@@ -28,7 +28,7 @@ def testGetDevList(t, env):
         check(res)
         # STUB - check block stuff
         dev_list = res.resarray[-1].gdlr_deviceid_list
-        print dev_list
+        print(dev_list)
 
 def testGetDevInfo(t, env):
     """Check devlist
@@ -60,7 +60,7 @@ def testGetDevInfo(t, env):
                 p.reset(res.resarray[-1].da_addr_body)
                 decode = p.unpack_pnfs_block_deviceaddr4()
                 p.done()
-                print decode
+                print(decode)
 
 
 ## def xxxtestLayout(t, env):
@@ -110,7 +110,7 @@ def testGetLayout(t, env):
             p = BlockUnpacker(layout.loc_body)
             opaque = p.unpack_pnfs_block_layout4()
             p.done()
-            print opaque
+            print(opaque)
 
 def testEMCGetLayout(t, env):
     """Verify layout handling
@@ -142,7 +142,7 @@ def testEMCGetLayout(t, env):
             p = BlockUnpacker(layout.loc_body)
             opaque = p.unpack_pnfs_block_layout4()
             p.done()
-            print opaque
+            print(opaque)
 
 def testLayoutReturnFile(t, env):
     """
@@ -257,9 +257,9 @@ def testLayoutCommit(t, env):
         p = BlockUnpacker(layout.loc_body)
         opaque = p.unpack_pnfs_block_layout4()
         p.done()
-        print opaque
+        print(opaque)
     final_extent = opaque.blo_extents[-1]
-    print final_extent
+    print(final_extent)
     if final_extent.bex_state != PNFS_BLOCK_INVALID_DATA:
         fail("Expected INVALID_DATA in extent")
     # LAYOUTCOMMIT
@@ -276,6 +276,6 @@ def testLayoutCommit(t, env):
                            layoutupdate4(LAYOUT4_BLOCK_VOLUME, p.get_buffer()))]
     res = sess.compound(ops)
     check(res)
-    print res
+    print(res)
          
     
diff --git a/nfs4.1/server41tests/st_secinfo_no_name.py b/nfs4.1/server41tests/st_secinfo_no_name.py
index 4c8cb57..9cd6bd3 100644
--- a/nfs4.1/server41tests/st_secinfo_no_name.py
+++ b/nfs4.1/server41tests/st_secinfo_no_name.py
@@ -32,7 +32,7 @@ def testSupported2(t, env):
 
     # GETFH after do a SECINFO_NO_NAME should get error NFS4ERR_NOFILEHANDLE
     res = sess.compound([op.putrootfh(), op.secinfo_no_name(0), op.getfh()])
-    print res
+    print(res)
     check(res, NFS4ERR_NOFILEHANDLE)
 
 def testSupported3(t, env):
diff --git a/nfs4.1/setup.py b/nfs4.1/setup.py
index 5c3a0df..37b99a0 100644
--- a/nfs4.1/setup.py
+++ b/nfs4.1/setup.py
@@ -31,10 +31,10 @@ class build_py(_build_py):
                 self.build_module(module, module_file, package)
 
     def expand_xdr(self, dir):
-        print "expand = %r" % dir
+        print("expand = %r" % dir)
         cwd = os.getcwd()
         xdrdir = os.path.join(cwd, dir, 'xdrdef')
-        print "xdrdir = %r" % xdrdir
+        print("xdrdir = %r" % xdrdir)
         if os.path.exists(xdrdir):
             try:
                 os.chdir(xdrdir)
@@ -47,7 +47,7 @@ class build_py(_build_py):
                         os.remove("parser.out")
                         os.remove("parsetab.py")
                     except:
-                        print "Remove parse* failed"
+                        print("Remove parse* failed")
             finally:
                 os.chdir(cwd)
 
diff --git a/nfs4.1/testclient.py b/nfs4.1/testclient.py
index 95e90e1..8a1be9f 100755
--- a/nfs4.1/testclient.py
+++ b/nfs4.1/testclient.py
@@ -24,7 +24,7 @@
 import use_local # HACK so don't have to rebuild constantly
 import sys
 if sys.hexversion < 0x02050000:
-    print "Requires python 2.5 or higher"
+    print("Requires python 2.5 or higher")
     sys.exit(1)
 import os
 
@@ -197,16 +197,16 @@ def printflags(list):
     command_names = [s.lower()[3:].replace('_', '') \
                      for s in nfs_opnum4.values()]
     list.sort()
-    # First print command names
+    # First print(command names)
     print
     for s in list:
         if s in command_names:
-            print s
+            print(s)
     # Then everything else
     print
     for s in list:
         if s not in command_names:
-            print s
+            print(s)
     
 def main():
     p = OptionParser("%prog SERVER:/PATH [options] flags|testcodes\n"
@@ -228,16 +228,16 @@ def main():
         codes = cdict.keys()
         codes.sort()
         for c in codes:
-            print c
+            print(c)
         sys.exit(0)
 
     # Grab server info and set defaults
     if not args:
         p.error("Need a server")
     url = args.pop(0)
-    print "url", url
+    print("url", url)
     opt.path = nfs4lib.path_components(url)
-    print "Set opt.path", opt.path
+    print("Set opt.path", opt.path)
 
     # Check --use* options are valid
     for attr in dir(opt):
@@ -245,14 +245,14 @@ def main():
             opt.useparams = parse_useparams(opt.useparams)
         elif attr.startswith('use') and attr != "usefh":
             path = getattr(opt, attr)
-            #print attr, path
+            #print(attr, path)
             if path is None:
                 path = opt.path + ['tree', attr[3:]]
             else:
                 # FIXME - have funct that checks path validity
                 if path[0] != '/':
                     p.error("Need to use absolute path for --%s" % attr)
-                # print path
+                # print(path)
                 if path[-1] == '/' and attr != 'usedir':
                     p.error("Can't use dir for --%s" %attr)
                 try:
@@ -297,20 +297,20 @@ def main():
     # Place tests in desired order
     tests.sort() # FIXME - add options for random sort
 
-    # Run the tests and save/print results
+    # Run the tests and save/print(results)
     try:
         env = environment.Environment(opt)
         env.init()
     except socket.gaierror, e:
         if e.args[0] == -2:
-            print "Unknown server '%s'" % opt.server
+            print("Unknown server '%s'" % opt.server)
         sys.exit(1)
     except Exception, e:
-        print "Initialization failed, no tests run."
+        print("Initialization failed, no tests run.")
         if not opt.maketree:
-            print "Perhaps you need to use the --maketree option"
+            print("Perhaps you need to use the --maketree option")
         raise
-        print sys.exc_info()[1]
+        print(sys.exc_info()[1])
         sys.exit(1)
     if opt.outfile is not None:
         fd = file(opt.outfile, 'w')
@@ -330,7 +330,7 @@ def main():
         fail = True
     testmod.printresults(tests, opt)
     if fail:
-        print "\nWARNING: could not clean testdir due to:\n%s\n" % str(e)
+        print("\nWARNING: could not clean testdir due to:\n%s\n" % str(e))
 
 if __name__ == "__main__":
     main()
diff --git a/nfs4.1/testmod.py b/nfs4.1/testmod.py
index c5ca0fe..a8b4a82 100644
--- a/nfs4.1/testmod.py
+++ b/nfs4.1/testmod.py
@@ -6,6 +6,7 @@
 # Copyright (C) 2004 University of Michigan, Center for 
 #                    Information Technology Integration
 #
+from __future__ import print_function
 from __future__ import with_statement
 import nfs4lib
 import re
@@ -212,11 +213,11 @@ class Test(object):
 
     def run(self, environment, verbose=False):
         """Run self.runtest, storing result"""
-        #print "*********Running test %s (%s)" % (self.name, self.code)
+        #print("*********Running test %s (%s)" % (self.name, self.code))
         self.result = self._run_result
         start_time = time.time()
         if verbose:
-            print repr(self)
+            print(repr(self))
         try:
             environment.startUp()
             self.runtest(self, environment)
@@ -245,7 +246,7 @@ class Test(object):
         self.time_taken = stop_time - start_time
 
         if verbose:
-            print repr(self)
+            print(repr(self))
 
 class Environment(object):
     """Base class for a test environment"""
@@ -419,8 +420,8 @@ def printresults(tests, opts, file=None):
     count = [0] * 6
     for t in tests:
         if not hasattr(t, "result"):
-            print dir(t)
-            print t.__dict__
+            print(dir(t))
+            print(t.__dict__)
             raise
         if t.result == TEST_NOTRUN:
             count[NOTRUN] += 1
@@ -434,7 +435,7 @@ def printresults(tests, opts, file=None):
             count[WARN] += 1
         elif t.result == TEST_PASS:
             count[PASS] += 1
-    print >> file, "*"*50 
+    print("*"*50, file=file)
     for t in tests:
         if t.result == TEST_NOTRUN:
             continue
@@ -448,16 +449,16 @@ def printresults(tests, opts, file=None):
             continue
         if (not opts.showfail) and t.result == TEST_FAIL:
             continue
-        print >> file, t.display(0,0)
-    print >> file, "*"*50
+        print(t.display(0,0), file=file)
+    print("*"*50, file=file)
     if count[NOTRUN]:
-        print >> file, "Tests interrupted! Only %i tests run" % \
-              sum(count[SKIP:])
+        print("Tests interrupted! Only %i tests run" % \
+              sum(count[SKIP:]), file=file)
     else:
-        print >> file, "Command line asked for %i of %i tests" % \
-              (sum(count[SKIP:]), len(tests))
-    print >> file, "Of those: %i Skipped, %i Failed, %i Warned, %i Passed" % \
-          (count[SKIP], count[FAIL], count[WARN], count[PASS])
+        print("Command line asked for %i of %i tests" % \
+              (sum(count[SKIP:]), len(tests)), file=file)
+    print("Of those: %i Skipped, %i Failed, %i Warned, %i Passed" % \
+          (count[SKIP], count[FAIL], count[WARN], count[PASS]), file=file)
     return count[FAIL]
 
 def xml_printresults(tests, file_name, suite='all'):
diff --git a/nfs4.1/testserver.py b/nfs4.1/testserver.py
index 9c2133e..70b4f62 100755
--- a/nfs4.1/testserver.py
+++ b/nfs4.1/testserver.py
@@ -28,7 +28,7 @@
 import use_local # HACK so don't have to rebuild constantly
 import sys
 if sys.hexversion < 0x02050000:
-    print "Requires python 2.5 or higher"
+    print("Requires python 2.5 or higher")
     sys.exit(1)
 import os
 
@@ -196,16 +196,16 @@ def printflags(list):
     command_names = [s.lower()[3:].replace('_', '') \
                      for s in nfs_opnum4.values()]
     list.sort()
-    # First print command names
+    # First print(command names)
     print
     for s in list:
         if s in command_names:
-            print s
+            print(s)
     # Then everything else
     print
     for s in list:
         if s not in command_names:
-            print s
+            print(s)
     
 def main():
     p = OptionParser("%prog SERVER:/PATH [options] flags|testcodes\n"
@@ -229,14 +229,14 @@ def main():
         codes = cdict.keys()
         codes.sort()
         for c in codes:
-            print c
+            print(c)
         sys.exit(0)
 
     if opt.showcodesflags:
         codes = cdict.keys()
         codes.sort()
         for c in codes:
-            print c, "FLAGS:", ', '.join(cdict[c].flags_list)
+            print(c, "FLAGS:", ', '.join(cdict[c].flags_list))
         sys.exit(0)
 
     # Grab server info and set defaults
@@ -257,14 +257,14 @@ def main():
     for attr in dir(opt):
         if attr.startswith('use') and attr != "usefh":
             path = getattr(opt, attr)
-            #print attr, path
+            #print(attr, path)
             if path is None:
                 path = opt.path + ['tree', attr[3:]]
             else:
                 # FIXME - have funct that checks path validity
                 if path[0] != '/':
                     p.error("Need to use absolute path for --%s" % attr)
-                # print path
+                # print(path)
                 if path[-1] == '/' and attr != 'usedir':
                     p.error("Can't use dir for --%s" %attr)
                 try:
@@ -316,21 +316,21 @@ def main():
     # Place tests in desired order
     tests.sort() # FIXME - add options for random sort
 
-    # Run the tests and save/print results
+    # Run the tests and save/print(results)
     try:
         env = environment.Environment(opt)
         env.init()
     except socket.gaierror, e:
         if e.args[0] == -2:
-            print "Unknown server '%s'" % opt.server
-        print sys.exc_info()[1]
+            print("Unknown server '%s'" % opt.server)
+        print(sys.exc_info()[1])
         sys.exit(1)
     except Exception, e:
-        print "Initialization failed, no tests run."
+        print("Initialization failed, no tests run.")
         if not opt.maketree:
-            print "Perhaps you need to use the --maketree option"
+            print("Perhaps you need to use the --maketree option")
         raise
-        print sys.exc_info()[1]
+        print(sys.exc_info()[1])
         sys.exit(1)
     if opt.outfile is not None:
         fd = file(opt.outfile, 'w')
@@ -350,7 +350,7 @@ def main():
         fail = True
     testmod.printresults(tests, opt)
     if fail:
-        print "\nWARNING: could not clean testdir due to:\n%s\n" % str(e)
+        print("\nWARNING: could not clean testdir due to:\n%s\n" % str(e))
 
     if opt.xmlout is not None:
         testmod.xml_printresults(tests, opt.xmlout)
diff --git a/rpc/rpc.py b/rpc/rpc.py
index 1a3ca38..e06dbbf 100644
--- a/rpc/rpc.py
+++ b/rpc/rpc.py
@@ -878,8 +878,8 @@ class ConnectionHandler(object):
     def listen(self, pipe, xid):
         # STUB - should be overwritten by subclass
         header, data = pipe.listen(xid)
-        print "HEADER", header
-        print "DATA", repr(data)
+        print("HEADER", header)
+        print("DATA", repr(data))
 
 #################################################
 
diff --git a/setup.py b/setup.py
index a032afe..ace0ab5 100755
--- a/setup.py
+++ b/setup.py
@@ -1,5 +1,7 @@
 #!/usr/bin/env python
 
+from __future__ import print_function
+
 from distutils.core import setup
 
 import sys
@@ -19,7 +21,7 @@ def setup(*args, **kwargs):
     cwd = os.getcwd()
     command = " ".join(sys.argv)
     for dir in DIRS:
-        print "\n\nMoving to %s" % dir 
+        print("\n\nMoving to %s" % dir )
         os.chdir(join(cwd, dir))
         os.system("python %s" % command)
     os.chdir(cwd)
diff --git a/showresults.py b/showresults.py
index b843a5f..962407d 100755
--- a/showresults.py
+++ b/showresults.py
@@ -1,13 +1,14 @@
 #!/usr/bin/env python
 # showresults.py - redisplay results from nfsv4 server tester output file
 #
-# Requires python 2.3
+# Requires python 2.7
 # 
 # Written by Fred Isaman <iisaman@citi.umich.edu>
 # Copyright (C) 2004 University of Michigan, Center for 
 #                    Information Technology Integration
 #
 
+from __future__ import print_function
 
 # Allow to be run stright from package root
 if  __name__ == "__main__":
diff --git a/xdr/xdrgen.py b/xdr/xdrgen.py
index 4eb5b16..6353835 100755
--- a/xdr/xdrgen.py
+++ b/xdr/xdrgen.py
@@ -300,7 +300,7 @@ def t_linecomment(t):
     t.lexer.lineno += 1
 
 def t_error(t):
-    print "Illegal character %s at %d type %s" % (repr(t.value[0]), t.lexer.lineno, t.type)
+    print("Illegal character %s at %d type %s" % (repr(t.value[0]), t.lexer.lineno, t.type))
     t.lexer.skip(1)
     
 # Build the lexer
@@ -371,7 +371,7 @@ def p_optional_value(t):
     if msg:
         global error_occurred
         error_occurred = True
-        print "ERROR - %s near line %i" % (msg, t.lineno(1))
+        print("ERROR - %s near line %i" % (msg, t.lineno(1)))
 
 def p_type_def_1(t):
     '''type_def : TYPEDEF declaration SEMI'''
@@ -382,7 +382,7 @@ def p_type_def_1(t):
     if d.type == 'void':
         global error_occurred
         error_occurred = True
-        print "ERROR - can't use void in typedef at line %i" % lineno
+        print("ERROR - can't use void in typedef at line %i" % lineno)
         return
     d.lineno = lineno
     if id_unique(d.id, d.type, lineno):
@@ -560,11 +560,11 @@ def p_enum_constant(t):
             # We have a name instead of a constant, make sure it is defined
             if value not in name_dict:
                 error_occurred = True
-                print "ERROR - can't derefence %s at line %s" % (value, lineno)
+                print("ERROR - can't derefence %s at line %s" % (value, lineno))
             elif not isinstance(name_dict[value], const_info):
                 error_occurred = True
-                print "ERROR - reference to %s at line %s is not a constant" %\
-                      (value, lineno)
+                print("ERROR - reference to %s at line %s is not a constant" %\
+                      (value, lineno))
             else:
                 info.positive = name_dict[value].positive
         t[0] = [info]
@@ -586,9 +586,9 @@ def p_error(t):
     global error_occurred
     error_occurred = True
     if t:
-        print "Syntax error at '%s' (lineno %d)" % (t.value, t.lineno)
+        print("Syntax error at '%s' (lineno %d)" % (t.value, t.lineno))
     else:
-        print "Syntax error: unexpectedly hit EOF"
+        print("Syntax error: unexpectedly hit EOF")
 
 #
 # RPC specific routines follow
@@ -596,7 +596,7 @@ def p_error(t):
 
 def p_program_def(t):
     '''program_def : PROGRAM ID LBRACE version_def version_def_list RBRACE EQUALS constant SEMI'''
-    print "Ignoring program %s = %s" % (t[2], t[8])
+    print("Ignoring program %s = %s" % (t[2], t[8]))
     global name_dict
     id = t[2]
     value = t[8]
@@ -666,8 +666,8 @@ def id_unique(id, name, lineno):
     if id in name_dict:
         global error_occurred
         error_occurred = True
-        print "ERROR - %s definition %s at line %s conflicts with %s" % \
-              (name, id, lineno, name_dict[id])
+        print("ERROR - %s definition %s at line %s conflicts with %s" % \
+              (name, id, lineno, name_dict[id]))
         return False
     else:
         return True
@@ -1391,7 +1391,7 @@ def run(infile, filters=True, pass_attrs=True, debug=False):
     global use_filters, allow_attr_passthrough
     use_filters = filters
     allow_attr_passthrough = pass_attrs
-    print "Input file is", infile
+    print("Input file is", infile)
 
     # Create output file names (without .py)
     global constants_file, types_file, packer_file
@@ -1399,8 +1399,8 @@ def run(infile, filters=True, pass_attrs=True, debug=False):
     constants_file = name_base + "_const"
     types_file = name_base + "_type"
     packer_file = name_base + "_pack"
-    print "Will use output files %s.py, %s.py, and %s.py" % \
-          (constants_file, types_file, packer_file)
+    print("Will use output files %s.py, %s.py, and %s.py" % \
+          (constants_file, types_file, packer_file))
 
     # Parse the input data with yacc
     global name_dict
@@ -1414,7 +1414,7 @@ def run(infile, filters=True, pass_attrs=True, debug=False):
 
     if error_occurred:
         print
-        print "Error occurred, did not write output files"
+        print("Error occurred, did not write output files")
         return 1
 
     comment_string = "# Generated by rpcgen.py from %s on %s\n" % \
@@ -1433,7 +1433,7 @@ def run(infile, filters=True, pass_attrs=True, debug=False):
     type_list = name_dict.values()
     type_list.sort()
     for value in type_list:
-        #print value
+        #print(value)
         output = value.const_output()
         if output is not None:
             #const_fd.write("# **** %s ****\n" % value.id)
@@ -1465,7 +1465,7 @@ def run(infile, filters=True, pass_attrs=True, debug=False):
 #
 if __name__ == "__main__":
     if len(sys.argv) < 2:
-        print "Usage: %s <filename>" % sys.argv[0]
+        print("Usage: %s <filename>" % sys.argv[0])
         sys.exit(1)
 
     run(sys.argv[1])
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 2/6] pynfs: python3 support plan: exec -> exec()
  2018-07-22  9:27 [PATCH 1/6] pynfs: python3 support plan: print -> print() jiyin
@ 2018-07-22  9:27 ` jiyin
  2018-07-22  9:27 ` [PATCH 3/6] pynfs: python3 support plan: "except E,e:" -> "except E as e:" jiyin
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: jiyin @ 2018-07-22  9:27 UTC (permalink / raw)
  To: bfields; +Cc: linux-nfs, Jianhong.Yin

From: "Jianhong.Yin" <yin-jianhong@163.com>

'/exec / {:loop /[^\\]$/! {N; b loop}; s/exec /exec(/; s/$/)/; }'

Signed-off-by: Jianhong Yin <yin-jianhong@163.com>
---
 nfs4.1/nfs4commoncode.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/nfs4.1/nfs4commoncode.py b/nfs4.1/nfs4commoncode.py
index cadd237..3c9c811 100644
--- a/nfs4.1/nfs4commoncode.py
+++ b/nfs4.1/nfs4commoncode.py
@@ -190,8 +190,8 @@ class %(CompoundState)s(object):
 '''
 
 # Create normal code
-exec code_str % _d
+exec(code_str % _d)
 
 # Create callback code
-exec code_str % _cb_d
+exec(code_str % _cb_d)
 
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 3/6] pynfs: python3 support plan: "except E,e:" -> "except E as e:"
  2018-07-22  9:27 [PATCH 1/6] pynfs: python3 support plan: print -> print() jiyin
  2018-07-22  9:27 ` [PATCH 2/6] pynfs: python3 support plan: exec -> exec() jiyin
@ 2018-07-22  9:27 ` jiyin
  2018-07-22  9:27 ` [PATCH 4/6] pynfs: python3 support plan: "raise E, args:" -> "raise E(args)" jiyin
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: jiyin @ 2018-07-22  9:27 UTC (permalink / raw)
  To: bfields; +Cc: linux-nfs, Jianhong.Yin

From: "Jianhong.Yin" <yin-jianhong@163.com>

s/except  *([^,]+), *([^ ]+):/except \1 as \2:/

Signed-off-by: Jianhong Yin <yin-jianhong@163.com>
---
 nfs4.0/lib/rpc/rpc.py                     |  8 +++---
 nfs4.0/lib/rpc/rpcsec/sec_auth_sys.py     |  2 +-
 nfs4.0/nfs4server.py                      | 32 +++++++++++------------
 nfs4.0/nfs4state.py                       |  8 +++---
 nfs4.0/servertests/st_compound.py         |  4 +--
 nfs4.0/servertests/st_create.py           |  2 +-
 nfs4.0/servertests/st_delegation.py       |  4 +--
 nfs4.0/servertests/st_gss.py              | 28 ++++++++++----------
 nfs4.0/servertests/st_link.py             |  2 +-
 nfs4.0/servertests/st_lookup.py           |  6 ++---
 nfs4.0/servertests/st_readdir.py          |  6 ++---
 nfs4.0/servertests/st_remove.py           |  4 +--
 nfs4.0/servertests/st_rename.py           |  6 ++---
 nfs4.0/testserver.py                      |  8 +++---
 nfs4.1/config.py                          |  2 +-
 nfs4.1/fs.py                              |  4 +--
 nfs4.1/nfs4client.py                      |  6 ++---
 nfs4.1/nfs4server.py                      | 24 ++++++++---------
 nfs4.1/server41tests/st_compound.py       |  2 +-
 nfs4.1/server41tests/st_create_session.py |  2 +-
 nfs4.1/server41tests/st_exchange_id.py    |  2 +-
 nfs4.1/server41tests/st_lookup.py         |  4 +--
 nfs4.1/testclient.py                      |  8 +++---
 nfs4.1/testmod.py                         |  8 +++---
 nfs4.1/testserver.py                      |  8 +++---
 rpc/rpc.py                                | 16 ++++++------
 rpc/rpclib.py                             |  4 +--
 rpc/security.py                           |  8 +++---
 28 files changed, 109 insertions(+), 109 deletions(-)

diff --git a/nfs4.0/lib/rpc/rpc.py b/nfs4.0/lib/rpc/rpc.py
index 48e3093..83a51c4 100644
--- a/nfs4.0/lib/rpc/rpc.py
+++ b/nfs4.0/lib/rpc/rpc.py
@@ -226,7 +226,7 @@ class RPCClient(object):
             try:
                 sock.bind(('', port))
                 return
-            except socket.error, why:
+            except socket.error as why:
                 if why[0] == errno.EADDRINUSE:
                     port += 1
                 else:
@@ -330,7 +330,7 @@ class RPCClient(object):
             self.socket.send_record(header + data)
         except socket.timeout:
             raise
-        except socket.error, e:
+        except socket.error as e:
             print("Got error:", e)
             if self.debug: print("resend", xid)
             try:
@@ -360,7 +360,7 @@ class RPCClient(object):
                 reply = self.socket.recv_record()
             except socket.timeout:
                 raise
-            except socket.error, e:
+            except socket.error as e:
                 print("Got error:", e)
                 if self.debug: print("relisten", xid)
                 try:
@@ -635,7 +635,7 @@ class RPCServer(Server):
         self.rpcunpacker.reset(recv_data)
         try:
             recv_msg = self.rpcunpacker.unpack_rpc_msg()
-        except xdrlib.Error, e:
+        except xdrlib.Error as e:
             print("XDRError", e)
             return
         if recv_msg.body.mtype != CALL:
diff --git a/nfs4.0/lib/rpc/rpcsec/sec_auth_sys.py b/nfs4.0/lib/rpc/rpcsec/sec_auth_sys.py
index 5b5691d..27fc52e 100644
--- a/nfs4.0/lib/rpc/rpcsec/sec_auth_sys.py
+++ b/nfs4.0/lib/rpc/rpcsec/sec_auth_sys.py
@@ -18,7 +18,7 @@ class SecAuthSys(SecFlavor):
             p.pack_uint(gid)
             p.pack_array(gids, p.pack_uint)
             self.cred = p.get_buffer()
-        except Error, e:
+        except Error as e:
             raise SecError("Packing error: %s", str(e))
         self.uid = uid
         self.gid = gid
diff --git a/nfs4.0/nfs4server.py b/nfs4.0/nfs4server.py
index d5aea34..cb3ea72 100755
--- a/nfs4.0/nfs4server.py
+++ b/nfs4.0/nfs4server.py
@@ -227,7 +227,7 @@ class NFS4Server(rpc.RPCServer):
                 raise NFS4Error(NFS4ERR_NOFILEHANDLE)
             print("  CLOSE fh", self.curr_fh.handle)
             self.state.close(stateid)
-        except NFS4Error, e:
+        except NFS4Error as e:
             self.state.advance_seqid(stateid, op, (e.code,))
             return simple_error(e.code)
         # Return a garbage state id
@@ -269,7 +269,7 @@ class NFS4Server(rpc.RPCServer):
             attrset = self.curr_fh.create(op.opcreate.objname, op.opcreate.objtype, attrs)
             new_cinfo = self.curr_fh.fattr4_change
             self.curr_fh = self.curr_fh.lookup(op.opcreate.objname)
-        except NFS4Error, e:
+        except NFS4Error as e:
             return simple_error(e.code)
         cin4 = change_info4(before=old_cinfo, after=new_cinfo, atomic=1)
         c4resok = CREATE4resok(cinfo=cin4, attrset = attrset)
@@ -290,7 +290,7 @@ class NFS4Server(rpc.RPCServer):
                 return simple_error(NFS4ERR_NOFILEHANDLE)
             attrs = nfs4lib.bitmap2list(op.opgetattr.attr_request)
             attrvals = self.curr_fh.get_attributes(attrs)
-        except NFS4Error, e:
+        except NFS4Error as e:
             return simple_error(e.code)
         garesok = GETATTR4resok(attrvals)
         return simple_error(NFS4_OK, garesok)
@@ -351,7 +351,7 @@ class NFS4Server(rpc.RPCServer):
                 self.state.new_lockowner(op.oplock.locker.open_owner)
             stateid = self.state.lock(self.curr_fh, owner, op.oplock.locktype,
                                       op.oplock.offset, op.oplock.length)
-        except NFS4Error, e:
+        except NFS4Error as e:
             if op.oplock.locker.new_lock_owner:
                 # FIXME - a bug? compare with replay=check_seqid() above
                 self.state.advance_seqid(openstateid, op, (e.code,))
@@ -376,7 +376,7 @@ class NFS4Server(rpc.RPCServer):
             self.state.testlock(self.curr_fh,
                                 op.oplockt.owner, op.oplockt.locktype,
                                 op.oplockt.offset, op.oplockt.length)
-        except NFS4Error, e:
+        except NFS4Error as e:
             return simple_error(e.code, e.lock_denied)
         return simple_error(NFS4_OK)
 
@@ -393,7 +393,7 @@ class NFS4Server(rpc.RPCServer):
                 raise NFS4Error(NFS4ERR_NOFILEHANDLE)
             sid = self.state.unlock(self.curr_fh, stateid, op.oplocku.locktype,
                                     op.oplocku.offset, op.oplocku.length)
-        except NFS4Error, e:
+        except NFS4Error as e:
             self.state.advance_seqid(stateid, op, (e.code,))
             return simple_error(e.code)
         self.state.advance_seqid(stateid, op, (NFS4_OK, sid), self.curr_fh)
@@ -438,7 +438,7 @@ class NFS4Server(rpc.RPCServer):
             if FATTR4_RDATTR_ERROR in attrreq:
                 return simple_error(NFS4ERR_INVAL)
             attrvals = self.curr_fh.get_attributes(attrreq.keys(), ignore=False)
-        except NFS4Error, e:
+        except NFS4Error as e:
             return simple_error(e.code)
         if attrvals == attrreq:
             return simple_error(NFS4ERR_SAME)
@@ -524,7 +524,7 @@ class NFS4Server(rpc.RPCServer):
             # 'existing'  now points to a valid file, so check and set shares
             sid, flags = self.state.open(existing, owner,
                                   op.opopen.share_access, op.opopen.share_deny)
-        except NFS4Error, e:
+        except NFS4Error as e:
             print("Open error")
             self.state.advance_seqid(owner, op, (e.code,))
             return simple_error(e.code)
@@ -560,7 +560,7 @@ class NFS4Server(rpc.RPCServer):
             if self.curr_fh.get_type() != NF4REG:
                 raise NFS4Error(NFS4ERR_INVAL)
             sid = self.state.confirm(self.curr_fh, stateid)
-        except NFS4Error, e:
+        except NFS4Error as e:
             self.state.advance_seqid(stateid, op, (e.code,))
             return simple_error(e.code)
         oc4resok = OPEN_CONFIRM4resok(sid)
@@ -583,7 +583,7 @@ class NFS4Server(rpc.RPCServer):
             sid = self.state.downgrade(self.curr_fh, stateid,
                                        op.opopen_downgrade.share_access,
                                        op.opopen_downgrade.share_deny)
-        except NFS4Error, e:
+        except NFS4Error as e:
             self.state.advance_seqid(stateid, op, (e.code,))
             return simple_error(e.code)
         od4resok = OPEN_DOWNGRADE4resok(sid)
@@ -626,7 +626,7 @@ class NFS4Server(rpc.RPCServer):
                                   offset, count)
             read_data = self.curr_fh.read(offset, count)
             print("  READ DATA: len=%i" % len(read_data))
-        except NFS4Error, e:
+        except NFS4Error as e:
             return simple_error(e.code)
         if len(read_data) < count:
             read_eof = 1
@@ -693,7 +693,7 @@ class NFS4Server(rpc.RPCServer):
                 d4 = dirlist4(e4, eof=0)
             else:
                 d4 = dirlist4(e4, eof=1)
-        except NFS4Error, e:
+        except NFS4Error as e:
             return simple_error(e.code)
         rdresok = READDIR4resok(cookieverf=verifier, reply=d4)
         return simple_error(NFS4_OK, rdresok)
@@ -777,7 +777,7 @@ class NFS4Server(rpc.RPCServer):
     def op_renew(self, op):
         try:
             self.state.renew(op.oprenew.clientid)
-        except NFS4Error, e:
+        except NFS4Error as e:
             return simple_error(e.code)
         return simple_error(NFS4_OK)
 
@@ -830,7 +830,7 @@ class NFS4Server(rpc.RPCServer):
                 self.state.check_write(self.curr_fh, op.opsetattr.stateid,
                                        offset, length)
             attrset = self.curr_fh.set_attributes(attrdict)
-        except NFS4Error, e:
+        except NFS4Error as e:
             return simple_error(e.code, e.attrs)
         return simple_error(NFS4_OK, attrset)
 
@@ -908,7 +908,7 @@ class NFS4Server(rpc.RPCServer):
             if FATTR4_RDATTR_ERROR in attrreq:
                 return simple_error(NFS4ERR_INVAL)
             attrvals = self.curr_fh.get_attributes(attrreq.keys(), ignore=False)
-        except NFS4Error, e:
+        except NFS4Error as e:
             return simple_error(e.code)
         if attrvals == attrreq:
             return simple_error(NFS4_OK)
@@ -935,7 +935,7 @@ class NFS4Server(rpc.RPCServer):
                                    offset, len(data))
             count = self.curr_fh.write(offset, data)
             print("  wrote %i bytes" % count)
-        except NFS4Error, e:
+        except NFS4Error as e:
             return simple_error(e.code)
         w4resok = WRITE4resok(count, FILE_SYNC4, self.state.write_verifier)
         return simple_error(NFS4_OK, w4resok)
diff --git a/nfs4.0/nfs4state.py b/nfs4.0/nfs4state.py
index fb3fd5c..064aadd 100755
--- a/nfs4.0/nfs4state.py
+++ b/nfs4.0/nfs4state.py
@@ -249,7 +249,7 @@ class NFSServerState:
             mustexist = True
         try:
             info = self.__getinfo(obj, allownew=not mustexist)
-        except ValueError, e:
+        except ValueError as e:
             if mustexist: raise
         #print("  check_seqid: %s" % info)
         if info is None:
@@ -286,7 +286,7 @@ class NFSServerState:
         # RFC 3530 sec 8.1.5
         try:
             info = self.__getinfo(owner)
-        except (ValueError, NFS4Error):
+        except (ValueError as NFS4Error):
             # An unknown owner, do nothing
             return
         if info is None:
@@ -1132,7 +1132,7 @@ class VirtualHandle(NFSFileHandle):
             except AttributeError:
                 # Otherwise, just set the variable
                 setattr(self, name, attrdict[attr])
-            except NFS4Error, e:
+            except NFS4Error as e:
                 # Note attributes set so far in any error that occurred
                 e.attrs = mapping(ret_list)
                 raise
@@ -1170,7 +1170,7 @@ class VirtualHandle(NFSFileHandle):
         if POSIXACL:
             try:
                 nfs4acl.maps_to_posix(acl)
-            except nfs4acl.ACLError, e:
+            except nfs4acl.ACLError as e:
                 print("*"*50)
                 print(e)
                 print("*"*50)
diff --git a/nfs4.0/servertests/st_compound.py b/nfs4.0/servertests/st_compound.py
index 4919289..59a279d 100644
--- a/nfs4.0/servertests/st_compound.py
+++ b/nfs4.0/servertests/st_compound.py
@@ -82,7 +82,7 @@ def testUndefined(t, env):
             try:
                 res = c.compound([nfs_argop4(argop=opnum)])
                 check(res, NFS4ERR_OP_ILLEGAL, "Sent illegal op=%i" % opnum)
-            except RPCError, e:
+            except RPCError as e:
                 t.fail("COMPOUND with illegal op=%i got %s, "
                        "expected NFS4ERR_OP_ILLEGAL" % (opnum,e))
     finally:
@@ -106,6 +106,6 @@ def testLongCompound(t, env):
                       "COMPOUND with len=%i argarry" % (3*count))
             if res.status == NFS4ERR_RESOURCE:
                 return
-    except RPCError, e:
+    except RPCError as e:
         t.fail("COMPOUND with len=%i argarry got %s, "
                "expected NFS4ERR_RESOURCE" % (3*count, e))
diff --git a/nfs4.0/servertests/st_create.py b/nfs4.0/servertests/st_create.py
index 7017fdf..ac57aaf 100644
--- a/nfs4.0/servertests/st_create.py
+++ b/nfs4.0/servertests/st_create.py
@@ -290,5 +290,5 @@ def testLongName(t, env):
             (x, rejected_names_create) = self.try_file_names(creator=self.create_via_create)
             self.failIf(rejected_names_open != rejected_names_create,
                         "CREATE does not obey OPEN naming policy")
-        except SkipException, e:
+        except SkipException as e:
             self.skip(e)
diff --git a/nfs4.0/servertests/st_delegation.py b/nfs4.0/servertests/st_delegation.py
index a2bce04..8e0d891 100644
--- a/nfs4.0/servertests/st_delegation.py
+++ b/nfs4.0/servertests/st_delegation.py
@@ -21,7 +21,7 @@ class _handle_error(object):
             _lock.acquire()
             try:
                 self.c.compound(ops)
-            except Exception, e:
+            except Exception as e:
                 print("CALLBACK error in _recall:", e)
                 pass
             _lock.release()
@@ -33,7 +33,7 @@ def _recall(c, thisop, cbid):
     _lock.acquire()
     try:
         res = c.compound(ops)
-    except Exception, e:
+    except Exception as e:
         print("CALLBACK error in _recall:", e)
         res = None
     _lock.release()
diff --git a/nfs4.0/servertests/st_gss.py b/nfs4.0/servertests/st_gss.py
index c67a802..414883e 100644
--- a/nfs4.0/servertests/st_gss.py
+++ b/nfs4.0/servertests/st_gss.py
@@ -109,11 +109,11 @@ def testInconsistentGssSeqnum(t, env):
         try:
             res = c.compound([op.putrootfh()])
             e = "operation erroneously suceeding"
-        except rpc.RPCAcceptError, e:
+        except rpc.RPCAcceptError as e:
             if e.stat == rpc.GARBAGE_ARGS:
                 # This is correct response
                 return
-        except Exception, e:
+        except Exception as e:
             pass
         t.fail("Using inconsistent gss_seq_nums in header and body of message "
                "should return GARBAGE_ARGS, instead got %s" % e)
@@ -138,11 +138,11 @@ def testBadVerfChecksum(t, env):
         try:
             res = c.compound([op.putrootfh()])
             e = "peration erroneously suceeding"
-        except rpc.RPCDeniedError, e:
+        except rpc.RPCDeniedError as e:
             if e.stat == rpc.AUTH_ERROR and e.astat == rpc.RPCSEC_GSS_CREDPROBLEM:
                 # This is correct response
                 return
-        except Exception, e:
+        except Exception as e:
             pass
         t.fail("Using bad verifier checksum in header "
                "should return RPCSEC_GSS_CREDPROBLEM, instead got %s" % e)
@@ -174,11 +174,11 @@ def testBadDataChecksum(t, env):
         try:
             res = c.compound([op.putrootfh()])
             e = "operation erroneously suceeding"
-        except rpc.RPCAcceptError, e:
+        except rpc.RPCAcceptError as e:
             if e.stat == rpc.GARBAGE_ARGS:
                 # This is correct response
                 return
-        except Exception, e:
+        except Exception as e:
             pass
         t.fail("Using bad data checksum for body of message "
                "should return GARBAGE_ARGS, instead got %s" % e)
@@ -214,11 +214,11 @@ def testBadVersion(t, env):
             try:
                 res = c.compound([op.putrootfh()])
                 e = "operation erroneously suceeding"
-            except rpc.RPCDeniedError, e:
+            except rpc.RPCDeniedError as e:
                 if e.stat == rpc.AUTH_ERROR and e.astat == rpc.AUTH_BADCRED:
                     # This is correct response
                     e = None
-            except Exception, e:
+            except Exception as e:
                 pass
             if e is not None:
                 t.fail("Using bad gss version number %i "
@@ -241,11 +241,11 @@ def testHighSeqNum(t, env):
         try:
             res = c.compound([op.putrootfh()])
             e = "operation erroneously suceeding"
-        except rpc.RPCDeniedError, e:
+        except rpc.RPCDeniedError as e:
             if e.stat == rpc.AUTH_ERROR and e.astat == rpc.RPCSEC_GSS_CTXPROBLEM:
                 # This is correct response
                 return
-        except Exception, e:
+        except Exception as e:
             pass
         t.fail("Using gss_seq_num over MAXSEQ "
                "should return RPCSEC_GSS_CTXPROBLEM, instead got %s" % e)
@@ -279,11 +279,11 @@ def testBadProcedure(t, env):
             try:
                 res = c.compound([op.putrootfh()])
                 e = "operation erroneously suceeding"
-            except rpc.RPCDeniedError, e:
+            except rpc.RPCDeniedError as e:
                 if e.stat == rpc.AUTH_ERROR and e.astat == rpc.AUTH_BADCRED:
                     # This is correct response
                     e = None
-            except Exception, e:
+            except Exception as e:
                 pass
             if e is not None:
                 t.fail("Using bad gss procedure number %i "
@@ -321,11 +321,11 @@ def testBadService(t, env):
             try:
                 res = c.compound([op.putrootfh()])
                 e = "operation erroneously suceeding"
-            except rpc.RPCDeniedError, e:
+            except rpc.RPCDeniedError as e:
                 if e.stat == rpc.AUTH_ERROR and e.astat == rpc.AUTH_BADCRED:
                     # This is correct response
                     e = None
-            except Exception, e:
+            except Exception as e:
                 pass
             if e is not None:
                 t.fail("Using bad gss service number %i "
diff --git a/nfs4.0/servertests/st_link.py b/nfs4.0/servertests/st_link.py
index 49e0538..feddf1e 100644
--- a/nfs4.0/servertests/st_link.py
+++ b/nfs4.0/servertests/st_link.py
@@ -264,6 +264,6 @@ def testDots(t, env):
             (x, rejected_names_link) = self.try_file_names(creator=self.create_via_link)
             self.failIf(rejected_names_open != rejected_names_link,
                         "LINK does not obey OPEN naming policy")
-        except SkipException, e:
+        except SkipException as e:
             self.skip(e)
 
diff --git a/nfs4.0/servertests/st_lookup.py b/nfs4.0/servertests/st_lookup.py
index c3203f9..cd1b93c 100644
--- a/nfs4.0/servertests/st_lookup.py
+++ b/nfs4.0/servertests/st_lookup.py
@@ -312,7 +312,7 @@ def testBadOpaque(t, env):
         res = c.compound([op.putrootfh(), op.lookup("setlength=0xcccccccc")])
         e = "operation erroneously suceeding"
         check(res, NFS4ERR_BADXDR)
-    except rpc.RPCAcceptError, e:
+    except rpc.RPCAcceptError as e:
         if e.stat == rpc.GARBAGE_ARGS:
             # This is correct response
             return
@@ -336,7 +336,7 @@ def testBadOpaque(t, env):
         # Saved files for LOOKUP
         try:
             (accepted_names, rejected_names) = self.try_file_names(0)
-        except SkipException, e:
+        except SkipException as e:
             self.skip(e)
 
         # Ok, lets try LOOKUP on all accepted names
@@ -363,7 +363,7 @@ def testBadOpaque(t, env):
 
         try:
             (accepted_names, rejected_names) = self.try_file_names()
-        except SkipException, e:
+        except SkipException as e:
             self.skip(e)
 
         # Ok, lets try LOOKUP on all rejected names
diff --git a/nfs4.0/servertests/st_readdir.py b/nfs4.0/servertests/st_readdir.py
index a88c370..5a70145 100644
--- a/nfs4.0/servertests/st_readdir.py
+++ b/nfs4.0/servertests/st_readdir.py
@@ -272,7 +272,7 @@ def testUnaccessibleDirAttrs(t, env):
         
         try:
             (accepted_names, rejected_names) = self.try_file_names(remove_files=0)
-        except SkipException, e:
+        except SkipException as e:
             self.skip(e)
 
         fh = self.do_rpc(self.ncl.do_getfh, self.tmp_dir) 
@@ -309,11 +309,11 @@ def testUnaccessibleDirAttrs(t, env):
         
         try:
             (accepted_names, rejected_names) = self.small_try_file_names(remove_files=0)
-        except SkipException, e:
+        except SkipException as e:
             self.skip(e)
 
         try: self.clean_dir(self.tmp_dir)
-        except SkipException, e:
+        except SkipException as e:
             self.fail(e)
 
     def small_try_file_names(self, remove_files=1, creator=None):
diff --git a/nfs4.0/servertests/st_remove.py b/nfs4.0/servertests/st_remove.py
index 076ca41..5f531f4 100644
--- a/nfs4.0/servertests/st_remove.py
+++ b/nfs4.0/servertests/st_remove.py
@@ -274,7 +274,7 @@ def testNotEmpty(t, env):
         # Save files for REMOVE
         try:
             (accepted_names, rejected_names) = self.try_file_names(remove_files=0)
-        except SkipException, e:
+        except SkipException as e:
             self.skip(e)
 
         # Ok, lets try REMOVE on all accepted names
@@ -299,7 +299,7 @@ def testNotEmpty(t, env):
         self.init_connection()
         try:
             (accepted_names, rejected_names) = self.try_file_names()
-        except SkipException, e:
+        except SkipException as e:
             self.skip(e)
 
         # Ok, lets try REMOVE on all rejected names
diff --git a/nfs4.0/servertests/st_rename.py b/nfs4.0/servertests/st_rename.py
index 5698a8c..8f41763 100644
--- a/nfs4.0/servertests/st_rename.py
+++ b/nfs4.0/servertests/st_rename.py
@@ -534,7 +534,7 @@ def testLinkRename(t, env):
             (x, rejected_names_rename) = self.try_file_names(creator=self.create_via_rename)
             self.failIf(rejected_names_open != rejected_names_rename,
                         "RENAME does not obey OPEN naming policy")
-        except SkipException, e:
+        except SkipException as e:
             self.skip(e)
 
     def testValidNames(t, env):
@@ -550,7 +550,7 @@ def testLinkRename(t, env):
         # Saved files for 
         try:
             (accepted_names, rejected_names) = self.try_file_names(remove_files=0)
-        except SkipException, e:
+        except SkipException as e:
             self.skip(e)
 
         # Ok, lets try RENAME on all accepted names
@@ -573,7 +573,7 @@ def testLinkRename(t, env):
 
         try:
             (accepted_names, rejected_names) = self.try_file_names()
-        except SkipException, e:
+        except SkipException as e:
             self.skip(e)
 
         # Ok, lets try RENAME on all rejected names
diff --git a/nfs4.0/testserver.py b/nfs4.0/testserver.py
index c049a5a..96012a1 100755
--- a/nfs4.0/testserver.py
+++ b/nfs4.0/testserver.py
@@ -297,7 +297,7 @@ def main():
                     p.error("Can't use dir for --%s" %attr)
                 try:
                     path = unixpath2comps(path)
-                except Exception, e:
+                except Exception as e:
                     p.error(e)
             setattr(opt, attr, [comp for comp in path if comp])
 
@@ -341,12 +341,12 @@ def main():
     try:
         env = environment.Environment(opt)
         env.init()
-    except socket.gaierror, e:
+    except socket.gaierror as e:
         if e.args[0] == -2:
             print("Unknown server '%s'" % opt.server)
         print(sys.exc_info()[1])
         sys.exit(1)
-    except Exception, e:
+    except Exception as e:
         print("Initialization failed, no tests run.")
         if not opt.maketree:
             print("Perhaps you need to use the --maketree option")
@@ -367,7 +367,7 @@ def main():
     try:
         fail = False
         env.finish()
-    except Exception, e:
+    except Exception as e:
         fail = True
     nfail = testmod.printresults(tests, opt)
     if fail:
diff --git a/nfs4.1/config.py b/nfs4.1/config.py
index 1dbb2ac..23b5b9a 100644
--- a/nfs4.1/config.py
+++ b/nfs4.1/config.py
@@ -74,7 +74,7 @@ class ConfigLine(object):
     def _set_value(self, value):
         try:
             self._value = self.verify(value)
-        except ConfigAction, e:
+        except ConfigAction as e:
             e.name = self.name
             e.value = value
             raise
diff --git a/nfs4.1/fs.py b/nfs4.1/fs.py
index 8947014..d9b58f2 100644
--- a/nfs4.1/fs.py
+++ b/nfs4.1/fs.py
@@ -323,7 +323,7 @@ class FSObject(object):
                     base = self.meta
                 try:
                     setattr(base, name, attrs[attr])
-                except NFS4Error, e:
+                except NFS4Error as e:
                     # Note attributes set so far in any error that occurred
                     e.attrs = bitmap
                     raise
@@ -747,7 +747,7 @@ class ConfigObj(FSObject):
             return
         try:
             self.configline.value = lines[0]
-        except ConfigAction, e:
+        except ConfigAction as e:
             if e.name == "reboot":
                 self.fs.server.reboot()
         except:
diff --git a/nfs4.1/nfs4client.py b/nfs4.1/nfs4client.py
index 3e28103..708850d 100644
--- a/nfs4.1/nfs4client.py
+++ b/nfs4.1/nfs4client.py
@@ -161,7 +161,7 @@ class NFS4Client(rpc.Client, rpc.Server):
                                                        env.results.cache.results))
                 env.cache.data = p.get_buffer()
                 env.cache.valid.set()
-        except NFS4Replay, e:
+        except NFS4Replay as e:
             log_cb.info("Replay...waiting for valid data")
             e.cache.valid.wait()
             log_cb.info("Replay...sending data")
@@ -183,7 +183,7 @@ class NFS4Client(rpc.Client, rpc.Server):
                 return env
         try:
             self.check_utf8str_cs(args.tag)
-        except NFS4Errror, e:
+        except NFS4Errror as e:
             env.results.set_empty_return(e.status, "Invalid utf8 tag")
             return env
         # Handle the individual operations
@@ -202,7 +202,7 @@ class NFS4Client(rpc.Client, rpc.Server):
                 try:
                     # Otherwise, call the function
                     result = funct(arg, env)
-                except NFS4Error, e:
+                except NFS4Error as e:
                     # XXX NOTE this only works for error returns that
                     # include no data.  Must ensure others (eg setattr)
                     # catch error themselves to encode properly.
diff --git a/nfs4.1/nfs4server.py b/nfs4.1/nfs4server.py
index 8856a82..f8bd251 100755
--- a/nfs4.1/nfs4server.py
+++ b/nfs4.1/nfs4server.py
@@ -350,7 +350,7 @@ class ClientRecord(object):
                         state.delete()
                     # STUB - what about LAYOUT?
                     # STUB - config whether DELEG OK or not
-            except StandardError, e:
+            except StandardError as e:
                 log_41.exception("Ignoring problem during state removal")
         self.state = {}
         self.lastused = time.time()
@@ -721,7 +721,7 @@ class NFS4Server(rpc.Server):
                                                  env.results.cache.results))
                 env.cache.data = p.get_buffer()
                 env.cache.valid.set()
-        except NFS4Replay, e:
+        except NFS4Replay as e:
             log_41.info("Replay...waiting for valid data")
             e.cache.valid.wait()
             log_41.info("Replay...sending data")
@@ -808,7 +808,7 @@ class NFS4Server(rpc.Server):
             return env
         try:
             self.check_utf8str_cs(args.tag)
-        except NFS4Errror, e:
+        except NFS4Errror as e:
             env.results.set_empty_return(e.status, "Invalid utf8 tag")
             return env
         # Handle the individual operations
@@ -828,7 +828,7 @@ class NFS4Server(rpc.Server):
                 try:
                     # Otherwise, call the function
                     result = funct(arg, env)
-                except NFS4Error, e:
+                except NFS4Error as e:
                     # XXX NOTE this only works for error returns that
                     # include no data.  Must ensure others (eg setattr)
                     # catch error themselves to encode properly.
@@ -876,7 +876,7 @@ class NFS4Server(rpc.Server):
         # We have a session. Check for injected errors
         try:
             self.check_opsconfig(env, "sequence")
-        except NFS4Error, e:
+        except NFS4Error as e:
             self.error_set_session(session, arg.sa_sessionid, e.status)
 
         # Check connection binding
@@ -962,7 +962,7 @@ class NFS4Server(rpc.Server):
                 self.cb_null(session.cb_prog, connection, credinfo=None)
                 flags |= CREATE_SESSION4_FLAG_CONN_BACK_CHAN
                 cb_channel.connections.append(connection)
-            except rpc.RPCError, e:
+            except rpc.RPCError as e:
                 log_41.warn("cb_null failed with %r, no backchannel created", e)
                 # STUB: backchannel is down: set sequence bits, disable layouts, etc.
                 pass
@@ -1604,7 +1604,7 @@ class NFS4Server(rpc.Server):
                 finally:
                     state.mark_done_writing()
             return encode_status(NFS4_OK, bitmap)
-        except NFS4Error, e:
+        except NFS4Error as e:
             # SETATTR failure does not encode just status
             return encode_status(e.status, e.attrs)
 
@@ -1702,7 +1702,7 @@ class NFS4Server(rpc.Server):
             if FATTR4_RDATTR_ERROR in attrreq:
                 raise NFS4Error(NFS4ERR_INVAL)
             attrvals = self.get_attributes(env.cfh, attrreq.keys(), ignore=False)
-        except NFS4Error, e:
+        except NFS4Error as e:
             return encode_status(e.code)
         if attrvals == attrreq:
             return encode_status(NFS4ERR_SAME)
@@ -1717,7 +1717,7 @@ class NFS4Server(rpc.Server):
             if FATTR4_RDATTR_ERROR in attrreq:
                 raise NFS4Error(NFS4ERR_INVAL)
             attrvals = self.get_attributes(env.cfh, attrreq.keys(), ignore=False)
-        except NFS4Error, e:
+        except NFS4Error as e:
             return encode_status(e.code)
         if attrvals != attrreq:
             return encode_status(NFS4ERR_NOT_SAME)
@@ -1806,7 +1806,7 @@ class NFS4Server(rpc.Server):
                 with find_state(env, arg.lock_stateid, allow_0=False) as state:
                     state.add_lock(arg.locktype, arg.offset, end)
                     stateid = state.get_id()
-        except NFS4Error, e:
+        except NFS4Error as e:
             return encode_status(e.status, denied=e.lock_denied)
         l4resok = LOCK4resok(stateid)
         return encode_status(NFS4_OK, l4resok)
@@ -1820,7 +1820,7 @@ class NFS4Server(rpc.Server):
             with env.cfh.state:
                 env.cfh.state.test_lock(env.session.client, arg.owner.owner,
                                         arg.locktype, arg.offset, end)
-        except NFS4Error, e:
+        except NFS4Error as e:
             return encode_status(e.status, denied=e.lock_denied)
         return encode_status(NFS4_OK)
 
@@ -1904,7 +1904,7 @@ class NFS4Server(rpc.Server):
                 return_on_close = False
                 res = LAYOUTGET4resok(return_on_close, entry.get_id(), [layout])
                 return encode_status(NFS4_OK, res)
-        except NFS4Error, e:
+        except NFS4Error as e:
             # LAYOUTGET failure does not encode just status
             if e.status == NFS4ERR_LAYOUTTRYLATER:
                 return encode_status(e.status, None, False)
diff --git a/nfs4.1/server41tests/st_compound.py b/nfs4.1/server41tests/st_compound.py
index 05ad5b3..3915dd8 100644
--- a/nfs4.1/server41tests/st_compound.py
+++ b/nfs4.1/server41tests/st_compound.py
@@ -118,7 +118,7 @@ def testUndefined(t, env):
             check(res, NFS4ERR_OP_ILLEGAL)
             if res.resarray[-1].resop != OP_ILLEGAL:
                 t.fail('Server echoed invalid opcode: Should return OP_ILLEGAL')
-        except RPCAcceptError, e:
+        except RPCAcceptError as e:
             if e.stat == GARBAGE_ARGS:
                 pass
             else:
diff --git a/nfs4.1/server41tests/st_create_session.py b/nfs4.1/server41tests/st_create_session.py
index 2ab8ba0..5018ec6 100644
--- a/nfs4.1/server41tests/st_create_session.py
+++ b/nfs4.1/server41tests/st_create_session.py
@@ -311,7 +311,7 @@ def testRdmaArray2(t, env):
     try:
         res = c.listen(xid)
         print(res)
-    except RPCAcceptError, e:
+    except RPCAcceptError as e:
         if e.stat == GARBAGE_ARGS:
             # Legitimate return
             return
diff --git a/nfs4.1/server41tests/st_exchange_id.py b/nfs4.1/server41tests/st_exchange_id.py
index 68f3b09..9becec6 100644
--- a/nfs4.1/server41tests/st_exchange_id.py
+++ b/nfs4.1/server41tests/st_exchange_id.py
@@ -119,7 +119,7 @@ def testLongArray(t, env):
     try:
         res = c.listen(xid)
         print(res)
-    except RPCAcceptError, e:
+    except RPCAcceptError as e:
         if e.stat == GARBAGE_ARGS:
             # Legitimate return
             return
diff --git a/nfs4.1/server41tests/st_lookup.py b/nfs4.1/server41tests/st_lookup.py
index 7ba6918..9f50004 100644
--- a/nfs4.1/server41tests/st_lookup.py
+++ b/nfs4.1/server41tests/st_lookup.py
@@ -360,7 +360,7 @@ if 0:
             # Saved files for LOOKUP
             try:
                 (accepted_names, rejected_names) = self.try_file_names(0)
-            except SkipException, e:
+            except SkipException as e:
                 self.skip(e)
 
             # Ok, lets try LOOKUP on all accepted names
@@ -387,7 +387,7 @@ if 0:
 
             try:
                 (accepted_names, rejected_names) = self.try_file_names()
-            except SkipException, e:
+            except SkipException as e:
                 self.skip(e)
 
             # Ok, lets try LOOKUP on all rejected names
diff --git a/nfs4.1/testclient.py b/nfs4.1/testclient.py
index 8a1be9f..1027fa6 100755
--- a/nfs4.1/testclient.py
+++ b/nfs4.1/testclient.py
@@ -257,7 +257,7 @@ def main():
                     p.error("Can't use dir for --%s" %attr)
                 try:
                     path = nfs4lib.path_components(path)
-                except Exception, e:
+                except Exception as e:
                     p.error(e)
             setattr(opt, attr, [comp for comp in path if comp])
 
@@ -301,11 +301,11 @@ def main():
     try:
         env = environment.Environment(opt)
         env.init()
-    except socket.gaierror, e:
+    except socket.gaierror as e:
         if e.args[0] == -2:
             print("Unknown server '%s'" % opt.server)
         sys.exit(1)
-    except Exception, e:
+    except Exception as e:
         print("Initialization failed, no tests run.")
         if not opt.maketree:
             print("Perhaps you need to use the --maketree option")
@@ -326,7 +326,7 @@ def main():
     try:
         fail = False
         env.finish()
-    except Exception, e:
+    except Exception as e:
         fail = True
     testmod.printresults(tests, opt)
     if fail:
diff --git a/nfs4.1/testmod.py b/nfs4.1/testmod.py
index a8b4a82..8108a23 100644
--- a/nfs4.1/testmod.py
+++ b/nfs4.1/testmod.py
@@ -226,19 +226,19 @@ class Test(object):
 	    environment.clean_clients()
         except KeyboardInterrupt:
             raise
-        except TestException, e:
+        except TestException as e:
             self.result = Result(e.type, e, sys.exc_info())
-        except StandardError, e:
+        except StandardError as e:
             if verbose:
                 print_exc()
             self.result = Result(TEST_FAIL, '', sys.exc_info())
             self.result.msg = self.result.tb[-1]
-        except Exception, e:
+        except Exception as e:
             self.result = Result(TEST_FAIL, e, sys.exc_info())
             self.result.msg = self.result.tb[-1]
         try:
             environment.shutDown()
-        except StandardError, e:
+        except StandardError as e:
             self.result = Result(TEST_FAIL, '', sys.exc_info())
             self.result.msg = self.result.tb[-1]
 
diff --git a/nfs4.1/testserver.py b/nfs4.1/testserver.py
index 70b4f62..101cfb1 100755
--- a/nfs4.1/testserver.py
+++ b/nfs4.1/testserver.py
@@ -269,7 +269,7 @@ def main():
                     p.error("Can't use dir for --%s" %attr)
                 try:
                     path = nfs4lib.path_components(path)
-                except Exception, e:
+                except Exception as e:
                     p.error(e)
             setattr(opt, attr, [comp for comp in path if comp])
 
@@ -320,12 +320,12 @@ def main():
     try:
         env = environment.Environment(opt)
         env.init()
-    except socket.gaierror, e:
+    except socket.gaierror as e:
         if e.args[0] == -2:
             print("Unknown server '%s'" % opt.server)
         print(sys.exc_info()[1])
         sys.exit(1)
-    except Exception, e:
+    except Exception as e:
         print("Initialization failed, no tests run.")
         if not opt.maketree:
             print("Perhaps you need to use the --maketree option")
@@ -346,7 +346,7 @@ def main():
     try:
         fail = False
         env.finish()
-    except Exception, e:
+    except Exception as e:
         fail = True
     testmod.printresults(tests, opt)
     if fail:
diff --git a/rpc/rpc.py b/rpc/rpc.py
index e06dbbf..834fedd 100644
--- a/rpc/rpc.py
+++ b/rpc/rpc.py
@@ -169,7 +169,7 @@ class Alarm(object):
         self._s.setblocking(0)
         try:
             self._s.connect(address)
-        except socket.error, e:
+        except socket.error as e:
             if e.args[0] in [EINPROGRESS, EWOULDBLOCK]:
                 # address has not yet called accept, since this is done in a
                 # single thread, so get "op in progress error".  When the
@@ -330,7 +330,7 @@ class Pipe(object):
             raise RuntimeError
         try:
             count = self._s.send(self._write_buf)
-        except socket.error, e:
+        except socket.error as e:
             log_p.error("flush_pipe got exception %s" % str(e))
             return True # This is to stop retries
         self._write_buf = self._write_buf[count:]
@@ -513,13 +513,13 @@ class ConnectionHandler(object):
             for fd in w:
                 try:
                     self._event_write(fd)
-                except socket.error, e:
+                except socket.error as e:
                     self._event_close(fd)
             for fd in r:
                 if fd in self.listeners:
                     try:
                         self._event_connect_incoming(fd)
-                    except socket.error, e:
+                    except socket.error as e:
                         self._event_close(fd)
                 elif fd == self._alarm_poll.fileno():
                     commands = self._alarm_poll.recv(self.rsize)
@@ -527,7 +527,7 @@ class ConnectionHandler(object):
                         data = self._alarm.pop()
                         try:
                             switch[c](data)
-                        except socket.error, e:
+                        except socket.error as e:
                             self._event_close(fd)
                 else:
                     try:
@@ -557,7 +557,7 @@ class ConnectionHandler(object):
                 s.setblocking(0)
             else:
                 csock, caddr = s.accept()
-        except socket.error, e:
+        except socket.error as e:
             log_p.error("accept() got error %s" % str(e))
             return
         csock.setblocking(0)
@@ -700,7 +700,7 @@ class ConnectionHandler(object):
             # Silently drop the request
             self._notify_drop()
             return
-        except rpclib.RPCFlowContol, e:
+        except rpclib.RPCFlowContol as e:
             body, data = e.body()
         except Exception:
             log_t.warn("Unexpected exception", exc_info=True)
@@ -832,7 +832,7 @@ class ConnectionHandler(object):
             try:
                 s.bind(('', using))
                 return
-            except socket.error, why:
+            except socket.error as why:
                 if why[0] == errno.EADDRINUSE:
                     using += 1
                     if port < 1024 <= using:
diff --git a/rpc/rpclib.py b/rpc/rpclib.py
index e7bb965..e738870 100644
--- a/rpc/rpclib.py
+++ b/rpc/rpclib.py
@@ -33,7 +33,7 @@ class RPCDeniedReply(RPCFlowContol):
             else:
                 # Something has gone haywire
                 rreply = rejected_reply(AUTH_ERROR, astat=AUTH_FAILED)
-        except Exception, e:
+        except Exception as e:
             log.critical("Oops, encountered bug", exc_info=True)
             rreply = rejected_reply(AUTH_ERROR, astat=AUTH_FAILED)
         return reply_body(MSG_DENIED, rreply=rreply), ''
@@ -52,7 +52,7 @@ class RPCUnsuccessfulReply(RPCFlowContol):
                 data = rpc_reply_data(self.stat)
             if self.stat == PROG_MISMATCH:
                 data.mismatch_info = rpc_mismatch_info(*self.statdata)
-        except Exception, e:
+        except Exception as e:
             log.critical("Oops, encountered bug", exc_info=True)
             data = rpc_reply_data(SYSTEM_ERR)
         areply = accepted_reply(NULL_CRED, data)
diff --git a/rpc/security.py b/rpc/security.py
index 1bfb920..896d7a2 100644
--- a/rpc/security.py
+++ b/rpc/security.py
@@ -379,7 +379,7 @@ class AuthGss(AuthNone):
             else:
                 # Can't get here, but doesn't hurt
                 log_gss.error("Unknown service %i for RPCSEC_GSS" % cred.service)
-        except gssapi.Error, e:
+        except gssapi.Error as e:
             log_gss.warn("unsecure_data: gssapi call returned %s" % e.name)
             raise rpclib.RPCUnsuccessfulReply(GARBAGE_ARGS)
         return data
@@ -413,7 +413,7 @@ class AuthGss(AuthNone):
             else:
                 # Can't get here, but doesn't hurt
                 log_gss.error("Unknown service %i for RPCSEC_GSS" % cred.service)
-        except gssapi.Error, e:
+        except gssapi.Error as e:
             # XXX What now?
             log_gss.warn("secure_data: gssapi call returned %s" % e.name)
             raise
@@ -449,7 +449,7 @@ class AuthGss(AuthNone):
             data = self.partially_packed_header(xid, body)
             try:
                 qop = self._get_context(body.cred.body.handle).verifyMIC(data, body.verf.body)
-            except gssapi.Error, e:
+            except gssapi.Error as e:
                 log_gss.warn("Verifier checksum failed verification with %s" %
                              e.name)
                 return False
@@ -522,7 +522,7 @@ class AuthGss(AuthNone):
             context = self._get_context(cred.body.handle)
         try:
             token = context.accept(token)
-        except gssapi.Error, e:
+        except gssapi.Error as e:
             log_gss.debug("RPCSEC_GSS_INIT failed (%s, %i)!" %
                           (e.name, e.minor))
             res = rpc_gss_init_res('', e.major, e.minor, 0, '')
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 4/6] pynfs: python3 support plan: "raise E, args:" -> "raise E(args)"
  2018-07-22  9:27 [PATCH 1/6] pynfs: python3 support plan: print -> print() jiyin
  2018-07-22  9:27 ` [PATCH 2/6] pynfs: python3 support plan: exec -> exec() jiyin
  2018-07-22  9:27 ` [PATCH 3/6] pynfs: python3 support plan: "except E,e:" -> "except E as e:" jiyin
@ 2018-07-22  9:27 ` jiyin
  2018-07-22  9:27 ` [PATCH 5/6] pynfs: python3 support plan: remove suffix 'L' of long integer jiyin
  2018-07-22  9:27 ` [PATCH 6/6] pynfs: python3 support plan: octal literal 0644 -> 0o644 jiyin
  4 siblings, 0 replies; 6+ messages in thread
From: jiyin @ 2018-07-22  9:27 UTC (permalink / raw)
  To: bfields; +Cc: linux-nfs, Jianhong.Yin

From: "Jianhong.Yin" <yin-jianhong@163.com>

'/raise / { :loop /[^\\]$/! {N; b loop};
  s/\<raise  *([[:alnum:]]+), *(.+)$/raise \1(\2)/;
  s/%sraise  *([[:alnum:]]+), *([^"]+)\\n"/%sraise \1(\2)\\n"/; }'

Signed-off-by: Jianhong Yin <yin-jianhong@163.com>
---
 nfs4.0/lib/rpc/rpcsec/sec_auth_gss.py | 52 +++++++++++++--------------
 nfs4.0/nfs4state.py                   | 28 +++++++--------
 nfs4.1/config.py                      |  2 +-
 nfs4.1/nfs4state.py                   |  4 +--
 xdr/xdrgen.py                         | 22 ++++++------
 5 files changed, 54 insertions(+), 54 deletions(-)

diff --git a/nfs4.0/lib/rpc/rpcsec/sec_auth_gss.py b/nfs4.0/lib/rpc/rpcsec/sec_auth_gss.py
index 2c68875..6351355 100644
--- a/nfs4.0/lib/rpc/rpcsec/sec_auth_gss.py
+++ b/nfs4.0/lib/rpc/rpcsec/sec_auth_gss.py
@@ -127,8 +127,8 @@ class SecAuthGss(SecFlavor):
         self.gss_seq_num = 0
         d = gssapi.importName("nfs@%s" % client.remotehost)
         if d['major'] != gssapi.GSS_S_COMPLETE:
-            raise SecError, "gssapi.importName returned: %s" % \
-                  show_major(d['major'])
+            raise SecError("gssapi.importName returned: %s" % \
+                  show_major(d['major']))
         name = d['name']
         # We need to send NULLPROCs with token from initSecContext
         good_major = [gssapi.GSS_S_COMPLETE, gssapi.GSS_S_CONTINUE_NEEDED]
@@ -141,11 +141,11 @@ class SecAuthGss(SecFlavor):
             major = d['major']
             context = d['context']
             if major not in good_major:
-                raise SecError, "gssapi.initSecContext returned: %s" % \
-                      show_major(major)
+                raise SecError("gssapi.initSecContext returned: %s" % \
+                      show_major(major))
             if (major == gssapi.GSS_S_CONTINUE_NEEDED) and \
                    (reply_major == gssapi.GSS_S_COMPLETE):
-                raise SecError, "Unexpected GSS_S_COMPLETE from server"
+                raise SecError("Unexpected GSS_S_COMPLETE from server")
             token = d['token']
             if reply_major != gssapi.GSS_S_COMPLETE:
                 # FRED - sec 5.2.2 of RFC 2203 mentions possibility that
@@ -161,13 +161,13 @@ class SecAuthGss(SecFlavor):
                 up.done()
                 reply_major = res.gss_major
                 if reply_major not in good_major:
-                    raise SecError, "Server returned: %s" % \
-                          show_major(reply_major)
+                    raise SecError("Server returned: %s" % \
+                          show_major(reply_major))
                 self.init = 2
                 reply_token = res.gss_token
             if major == gssapi.GSS_S_COMPLETE:
                 if reply_major != gssapi.GSS_S_COMPLETE:
-                    raise SecError, "Unexpected COMPLETE from client"
+                    raise SecError("Unexpected COMPLETE from client")
                 break
         self.gss_context = context
         self.gss_handle = res.handle
@@ -240,8 +240,8 @@ class SecAuthGss(SecFlavor):
             d = gssapi.getMIC(self.gss_context, data)
             major = d['major']
             if major != gssapi.GSS_S_COMPLETE:
-                raise SecError, "gssapi.getMIC returned: %s" % \
-                      show_major(major)
+                raise SecError("gssapi.getMIC returned: %s" % \
+                      show_major(major))
             return opaque_auth(RPCSEC_GSS, d['token'])
         
     def _make_cred_gss(self, handle, service, gss_proc=RPCSEC_GSS_DATA, seq=0):
@@ -266,8 +266,8 @@ class SecAuthGss(SecFlavor):
             data = p.get_buffer() + data
             d = gssapi.getMIC(self.gss_context, data)
             if d['major'] != gssapi.GSS_S_COMPLETE:
-                raise SecError, "gssapi.getMIC returned: %s" % \
-                      show_major(d['major'])
+                raise SecError("gssapi.getMIC returned: %s" % \
+                      show_major(d['major']))
             p.reset()
             p.pack_opaque(data)
             p.pack_opaque(d['token'])
@@ -280,14 +280,14 @@ class SecAuthGss(SecFlavor):
             data = p.get_buffer() + data
             d = gssapi.wrap(self.gss_context, data)
             if d['major'] != gssapi.GSS_S_COMPLETE:
-                raise SecError, "gssapi.wrap returned: %s" % \
-                      show_major(d['major'])
+                raise SecError("gssapi.wrap returned: %s" % \
+                      show_major(d['major']))
             p.reset()
             p.pack_opaque(d['msg'])
             data = p.get_buffer()
         else:
             # Not really necessary, should have already raised XDRError
-            raise SecError, "Unknown service %i for RPCSEC_GSS" % gss_cred.service
+            raise SecError("Unknown service %i for RPCSEC_GSS" % gss_cred.service)
         return data
 
     def unsecure_data(self, data, cred):
@@ -305,14 +305,14 @@ class SecAuthGss(SecFlavor):
             p.done()
             d = gssapi.verifyMIC(self.gss_context, data, checksum)
             if d['major'] != gssapi.GSS_S_COMPLETE:
-                raise SecError, "gssapi.verifyMIC returned: %s" % \
-                      show_major(d['major'])
+                raise SecError("gssapi.verifyMIC returned: %s" % \
+                      show_major(d['major']))
             p.reset(data)
             seqnum = p.unpack_uint()
             if seqnum != gss_cred.seq_num:
-                raise SecError, \
+                raise SecError(\
                       "Mismatched seqnum in reply: got %i, expected %i" % \
-                      (seqnum, gss_cred.seq_num)
+                      (seqnum, gss_cred.seq_num))
             data = p.get_buffer()[p.get_position():]
         elif gss_cred.service == rpc_gss_svc_privacy:
             # data = opaque[wrap([gss_seq_num+data])]
@@ -322,18 +322,18 @@ class SecAuthGss(SecFlavor):
             p.done()
             d = gssapi.unwrap(self.gss_context, data)
             if d['major'] != gssapi.GSS_S_COMPLETE:
-                raise SecError, "gssapi.unwrap returned %s" % \
-                      show_major(d['major'])
+                raise SecError("gssapi.unwrap returned %s" % \
+                      show_major(d['major']))
             p.reset(d['msg'])
             seqnum = p.unpack_uint()
             if seqnum != gss_cred.seq_num:
-                raise SecError, \
+                raise SecError(\
                       "Mismatched seqnum in reply: got %i, expected %i" % \
-                      (seqnum, self.gss_cred.seq_num)
+                      (seqnum, self.gss_cred.seq_num))
             data = p.get_buffer()[p.get_position():]
         else:
             # Not really necessary, should have already raised XDRError
-            raise SecError, "Unknown service %i for RPCSEC_GSS" % gss_cred.service
+            raise SecError("Unknown service %i for RPCSEC_GSS" % gss_cred.service)
         return data
 
     def _gss_cred_from_opaque_auth(self, auth):
@@ -361,8 +361,8 @@ class SecAuthGss(SecFlavor):
         p.pack_uint(i)
         d = gssapi.getMIC(self.gss_context, p.get_buffer())
         if d['major'] != gssapi.GSS_S_COMPLETE:
-            raise SecError, "gssapi.getMIC returned: %s" % \
-                  show_major(d['major'])
+            raise SecError("gssapi.getMIC returned: %s" % \
+                  show_major(d['major']))
         return opaque_auth(RPCSEC_GSS, d['token'])
 
     def check_verf(self, rverf, cred):
diff --git a/nfs4.0/nfs4state.py b/nfs4.0/nfs4state.py
index 064aadd..e854b3b 100755
--- a/nfs4.0/nfs4state.py
+++ b/nfs4.0/nfs4state.py
@@ -146,7 +146,7 @@ class NFSServerState:
 
         def addentry(self, entry):
             if not isinstance(entry, self.CacheEntry):
-                raise TypeError, "Bad entry: %s" % str(entry)
+                raise TypeError("Bad entry: %s" % str(entry))
             if self.exists(x=entry.x) or self.exists(c=entry.c):
                 raise "Bad Cache"
             self.list.append(entry)
@@ -200,7 +200,7 @@ class NFSServerState:
             elif isinstance(owner, lock_owner4):
                 self.openid = openid
             else:
-                raise TypeError, "Passed in owner = %s" % str(owner)
+                raise TypeError("Passed in owner = %s" % str(owner))
             # An owner is confirmed with OpenConfirm, a lock by sending stateid
             self.confirmed = False
             self.owner = owner
@@ -323,7 +323,7 @@ class NFSServerState:
         Conflict will raise NFS4Error.
         """
         if not isinstance(owner, open_owner4):
-            raise TypeError, "Owner was given as %s" % str(owner)
+            raise TypeError("Owner was given as %s" % str(owner))
         info = self.__getinfo(owner)
         if not info.confirmed:
             # Remove any pending open (RFC 3530 sec 14.2.18)
@@ -380,7 +380,7 @@ class NFSServerState:
     def __state2id(self, stateid, checkseq=False):
         """Translate nfs4 stateid to internal id"""
         if not isinstance(stateid, stateid4):
-            raise TypeError, "State was given as %s" % str(stateid)
+            raise TypeError("State was given as %s" % str(stateid))
         # Check for special stateids
         if stateid.seqid==0 and stateid.other==chr(0)*12:
             return 0
@@ -407,11 +407,11 @@ class NFSServerState:
         info = self.__owner2info(owner, allownew)
         try:
             if fh is None:
-                raise ValueError, "File is None"
+                raise ValueError("File is None")
             return info.files[fh.handle]
         except KeyError:
             if not allownew:
-                raise ValueError, "File %s not open for %s" % (fh.name, info)
+                raise ValueError("File %s not open for %s" % (fh.name, info))
             #print("Creating new id %i for fh %s" % (self.next_id, fh.handle))
             id = info.files[fh.handle] = self.next_id
             self.next_id += 1
@@ -428,12 +428,12 @@ class NFSServerState:
         elif isinstance(owner, lock_owner4):
             ownerdict = self.lockowners
         else:
-            raise TypeError, "Gave owner as %s" % str(owner)
+            raise TypeError("Gave owner as %s" % str(owner))
         self.__check_clientid(owner.clientid)
         try:
             info = ownerdict[owner.clientid][owner.owner]
         except KeyError:
-            if not allownew: raise ValueError, "Unknown owner %s" % str(owner)
+            if not allownew: raise ValueError("Unknown owner %s" % str(owner))
             #print("Creating new info")
             info = self.OwnerInfo(owner)
             if owner.clientid in ownerdict:
@@ -694,8 +694,8 @@ class NFSFileState:
             self.start = start
             self.end = end
             if start < 0 or end < start:
-                raise ValueError, "Bad values for start and end (%s, %s)" % \
-                                  (start, end)
+                raise ValueError("Bad values for start and end (%s, %s)" % \
+                                  (start, end))
 
         def __repr__(self):
             if self.type & 1: str = "READ"
@@ -1478,7 +1478,7 @@ class DirList:
         for x in self.list:
             if x.name == name:
                 return x.fh
-        raise KeyError, "Invalid key %s" % name
+        raise KeyError("Invalid key %s" % name)
 
     def __setitem__(self, name, fh):
         """Allows self[name] = fh"""
@@ -1499,18 +1499,18 @@ class DirList:
             if x.name == name:
                 self.list.remove(x)
                 return
-        raise KeyError, "Invalid key %s" % name
+        raise KeyError("Invalid key %s" % name)
 
     def getcookie(self, name):
         for x in self.list:
             if x.name == name:
                 return x.cookie
-        raise KeyError, "Invalid key %s" % name
+        raise KeyError("Invalid key %s" % name)
 
     def readdir(self, cookie):
         """Returns DirEnt list containing all entries larger than cookie"""
         if cookie < 0 or cookie > self.__lastcookie:
-            raise IndexError, "Invalid cookie %i" % cookie
+            raise IndexError("Invalid cookie %i" % cookie)
         i = None
         for x in self.list:
             if x.cookie > cookie:
diff --git a/nfs4.1/config.py b/nfs4.1/config.py
index 23b5b9a..b4a45d7 100644
--- a/nfs4.1/config.py
+++ b/nfs4.1/config.py
@@ -56,7 +56,7 @@ def _opline(value):
         l = value
     else:
         print('                 OPLINE type ', type(value))
-        raise TypeError, 'Only type list or str accepted'
+        raise TypeError('Only type list or str accepted')
     if l[0] == "ERROR":
         if not len(l) == 3:
             print('                 OPLINE length ', len)
diff --git a/nfs4.1/nfs4state.py b/nfs4.1/nfs4state.py
index 2214c0d..95f84df 100644
--- a/nfs4.1/nfs4state.py
+++ b/nfs4.1/nfs4state.py
@@ -99,8 +99,8 @@ class ByteLock(object):
         self.start = start
         self.end = end
         if start < 0 or end < start:
-            raise ValueError, "Bad values for start and end (%s, %s)" % \
-                              (start, end)
+            raise ValueError("Bad values for start and end (%s, %s)" % \
+                              (start, end))
 
     def __repr__(self):
         str = ("WRITE" if self.iswrite else "READ")
diff --git a/xdr/xdrgen.py b/xdr/xdrgen.py
index 6353835..0aa1a52 100755
--- a/xdr/xdrgen.py
+++ b/xdr/xdrgen.py
@@ -819,7 +819,7 @@ class Info(object):
                         (prefix, self.id)
                 if self.len is not None:
                     limit = "%sif len(data) > %s:\n" \
-                            "%s%sraise XDRError, 'array length too long'\n" %\
+                            "%s%sraise XDRError('array length too long')\n" %\
                             (prefix, self.fullname(self.len), prefix, varindent)
                     array = limit + array
         else:
@@ -846,7 +846,7 @@ class Info(object):
                          (prefix, newdata, self.id)
                 if self.len is not None:
                     limit = "%sif len(%s) > %s:\n" \
-                            "%s%sraise XDRError, 'array length too long'\n" %\
+                            "%s%sraise XDRError('array length too long')\n" %\
                             (prefix, newdata, self.fullname(self.len), prefix, indent)
                     array += limit
             newdata = 'data'
@@ -858,7 +858,7 @@ class Info(object):
         prefix, data, subheader, array = self._array_pack(prefix, data)
         varlist = ["const.%s" % l.id for l in self.body]
         check = "%sif self.check_enum and %s not in [%s]:\n" \
-                "%s%sraise XDRError, 'value=%%s not in enum %s' %% %s\n" % \
+                "%s%sraise XDRError('value=%%s not in enum %s' %% %s)\n" % \
                 (prefix, data, ', '.join(varlist),
                  prefix, indent, self.id, data)
         pack = check + "%sself.pack_int(%s)\n" % (prefix, data)
@@ -868,7 +868,7 @@ class Info(object):
         prefix, data, subheader, array = self._array_unpack(prefix, data)
         varlist = ["const.%s" % l.id for l in self.body]
         check = "%sif self.check_enum and %s not in [%s]:\n" \
-                "%s%sraise XDRError, 'value=%%s not in enum %s' %% %s\n" % \
+                "%s%sraise XDRError('value=%%s not in enum %s' %% %s)\n" % \
                 (prefix, data, ', '.join(varlist),
                  prefix, indent, self.id, data)
         unpack = "%s%s = self.unpack_int()\n" % (prefix, data)
@@ -908,7 +908,7 @@ class Info(object):
         if default != []:
             pack += default[0].packout(prefix + indent, data)
         else:
-            pack += "%s%sraise XDRError, 'bad switch=%%s' %% %s.%s\n" % \
+            pack += "%s%sraise XDRError('bad switch=%%s' %% %s.%s)\n" % \
                     (prefix, indent, data, switch.id)
         return subheader + pack + array
 
@@ -950,7 +950,7 @@ class Info(object):
 ##                       (prefix, indent, data, data, default[0].id)
 ##             unpack += arm
         else:
-            unpack += "%s%sraise XDRError, 'bad switch=%%s' %% %s.%s\n" % \
+            unpack += "%s%sraise XDRError('bad switch=%%s' %% %s.%s)\n" % \
                       (prefix, indent, data, switch.id)
             
         return subheader + unpack + array
@@ -1220,7 +1220,7 @@ class type_info(Info):
 
     def packout(self, prefix='', data='data'):
         check = "%sif %s.%s is None:\n" \
-                "%s%sraise TypeError, '%s.%s == None'\n" % \
+                "%s%sraise TypeError('%s.%s == None')\n" % \
                 (prefix, data, self.id, prefix, indent, data, self.id)
         if self.type == 'void':
             return prefix + 'pass\n'
@@ -1279,8 +1279,8 @@ class type_info(Info):
             limit = ''
         else:
             limit = "%sif len(%s) > %s and self.check_array:\n" \
-                    "%s%sraise XDRError, " \
-                    "'array length too long for %s'\n" % \
+                    "%s%sraise XDRError(" \
+                    "'array length too long for %s')\n" % \
                     (prefix, data, self.fullname(self.len), prefix, indent, data)
         if self.fixed:
             fixchar = 'f'
@@ -1303,8 +1303,8 @@ class type_info(Info):
             limit = ''
         else:
             limit = "%sif len(%s) > %s and self.check_array:\n" \
-                    "%s%sraise XDRError, " \
-                    "'array length too long for %s'\n" % \
+                    "%s%sraise XDRError(" \
+                    "'array length too long for %s')\n" % \
                     (prefix, data, self.fullname(self.len), prefix, indent, data)
         if self.fixed:
             fixchar = 'f'
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 5/6] pynfs: python3 support plan: remove suffix 'L' of long integer
  2018-07-22  9:27 [PATCH 1/6] pynfs: python3 support plan: print -> print() jiyin
                   ` (2 preceding siblings ...)
  2018-07-22  9:27 ` [PATCH 4/6] pynfs: python3 support plan: "raise E, args:" -> "raise E(args)" jiyin
@ 2018-07-22  9:27 ` jiyin
  2018-07-22  9:27 ` [PATCH 6/6] pynfs: python3 support plan: octal literal 0644 -> 0o644 jiyin
  4 siblings, 0 replies; 6+ messages in thread
From: jiyin @ 2018-07-22  9:27 UTC (permalink / raw)
  To: bfields; +Cc: linux-nfs, Jianhong.Yin

From: "Jianhong.Yin" <yin-jianhong@163.com>

s/(0x[[:xdigit:]]+)L\>/\1/g
s/(\<[[:digit:]]+)L\>/\1/g

Signed-off-by: Jianhong Yin <yin-jianhong@163.com>
---
 nfs4.0/lib/rpc/rpc.py                 | 14 +++++++-------
 nfs4.0/lib/rpc/rpcsec/sec_auth_gss.py |  2 +-
 nfs4.0/nfs4lib.py                     |  8 ++++----
 nfs4.0/nfs4server.py                  |  6 +++---
 nfs4.0/nfs4state.py                   |  4 ++--
 nfs4.0/servertests/environment.py     |  2 +-
 nfs4.0/servertests/st_commit.py       |  8 ++++----
 nfs4.1/client41tests/environment.py   |  2 +-
 nfs4.1/dataserver.py                  |  2 +-
 nfs4.1/fs.py                          |  2 +-
 nfs4.1/nfs4client.py                  |  2 +-
 nfs4.1/nfs4lib.py                     | 10 +++++-----
 nfs4.1/nfs4server.py                  |  4 ++--
 nfs4.1/server41tests/environment.py   |  4 ++--
 nfs4.1/server41tests/st_debug.py      |  2 +-
 nfs4.1/testmod.py                     |  2 +-
 rpc/rpc.py                            |  8 ++++----
 17 files changed, 41 insertions(+), 41 deletions(-)

diff --git a/nfs4.0/lib/rpc/rpc.py b/nfs4.0/lib/rpc/rpc.py
index 83a51c4..d9c1401 100644
--- a/nfs4.0/lib/rpc/rpc.py
+++ b/nfs4.0/lib/rpc/rpc.py
@@ -157,9 +157,9 @@ def _recv_record(self):
     while not last:
         rec_mark = self.recv_all(4)
         count = struct.unpack('>L', rec_mark)[0]
-        last = count & 0x80000000L
+        last = count & 0x80000000
         if last:
-            count &= 0x7fffffffL
+            count &= 0x7fffffff
         data += self.recv_all(count)
     return data
 
@@ -171,7 +171,7 @@ def _send_record(self, data, chunksize=2048):
         chunk = data[i:i+chunksize]
         i += chunksize
         if i >= dlen:
-            last = 0x80000000L
+            last = 0x80000000
         mark = struct.pack('>L', last | len(chunk))
         self.sendall(mark + chunk)
 
@@ -202,7 +202,7 @@ class RPCClient(object):
         self._rpcunpacker = {t : rpc_pack.RPCUnpacker('')}
         self.default_prog = program
         self.default_vers = version
-        self.xid = 0L
+        self.xid = 0
         self._xidlist = {}
         if sec_list is None:
             sec_list = [SecAuthNone()]
@@ -558,8 +558,8 @@ class RPCServer(Server):
             str = self.readbufs[fd]
             if len(str) >= 4:
                 packetlen = struct.unpack('>L', str[0:4])[0]
-                last = 0x80000000L & packetlen
-                packetlen &= 0x7fffffffL
+                last = 0x80000000 & packetlen
+                packetlen &= 0x7fffffff
                 if len(str) >= 4 + packetlen:
                     self.packetbufs[fd].append(str[4:4 + packetlen])
                     self.readbufs[fd] = str[4 + packetlen:]
@@ -593,7 +593,7 @@ class RPCServer(Server):
                 last = 0
                 self.recordbufs[fd][0] = data[chunksize:]
             else:
-                last = 0x80000000L
+                last = 0x80000000
                 del self.recordbufs[fd][0]
             mark = struct.pack('>L', last | len(chunk))
             self.writebufs[fd] = (mark + chunk)
diff --git a/nfs4.0/lib/rpc/rpcsec/sec_auth_gss.py b/nfs4.0/lib/rpc/rpcsec/sec_auth_gss.py
index 6351355..ee6ad53 100644
--- a/nfs4.0/lib/rpc/rpcsec/sec_auth_gss.py
+++ b/nfs4.0/lib/rpc/rpcsec/sec_auth_gss.py
@@ -72,7 +72,7 @@ def show_major(m):
     """Return string corresponding to major code"""
     if m == 0:
         return gss_major_codes[0]
-    call = m & 0xff000000L
+    call = m & 0xff000000
     routine = m & 0xff0000
     supp = m & 0xffff
     out = []
diff --git a/nfs4.0/nfs4lib.py b/nfs4.0/nfs4lib.py
index a0fdce1..d255eb7 100644
--- a/nfs4.0/nfs4lib.py
+++ b/nfs4.0/nfs4lib.py
@@ -93,7 +93,7 @@ class FancyNFS4Packer(nfs4_pack.NFS4Packer):
     def filter_bitmap4(self, data):
         out = []
         while data:
-            out.append(data & 0xffffffffL)
+            out.append(data & 0xffffffff)
             data >>= 32
         return out
 
@@ -108,7 +108,7 @@ class FancyNFS4Packer(nfs4_pack.NFS4Packer):
 class FancyNFS4Unpacker(nfs4_pack.NFS4Unpacker):
     def filter_bitmap4(self, data):
         """Put bitmap into single long, instead of array of 32bit chunks"""
-        out = 0L
+        out = 0
         shift = 0
         for i in data:
             out |= (long(i) << shift)
@@ -1006,9 +1006,9 @@ def fattr2dict(obj):
 
 def list2bitmap(list):
     """Construct a bitmap from a list of bit numbers"""
-    mask = 0L
+    mask = 0
     for bit in list:
-        mask |= 1L << bit
+        mask |= 1 << bit
     return mask
 
 def bitmap2list(bitmap):
diff --git a/nfs4.0/nfs4server.py b/nfs4.0/nfs4server.py
index cb3ea72..163bd60 100755
--- a/nfs4.0/nfs4server.py
+++ b/nfs4.0/nfs4server.py
@@ -475,7 +475,7 @@ class NFS4Server(rpc.RPCServer):
             e = verify_name(filename)
             if e: raise NFS4Error(e)
             # At this point we know it is CLAIM_NULL with valid filename and cfh
-            attrset = 0L
+            attrset = 0
             ci_old = self.curr_fh.fattr4_change
             if op.opopen.openhow.opentype == OPEN4_CREATE:
                 print("  CREATING FILE.")
@@ -812,13 +812,13 @@ class NFS4Server(rpc.RPCServer):
         print("  CURRENT FILEHANDLE: %s" % repr(self.curr_fh))
         print(op.opsetattr.obj_attributes)
         if not self.curr_fh:
-            return simple_error(NFS4ERR_NOFILEHANDLE, 0L)
+            return simple_error(NFS4ERR_NOFILEHANDLE, 0)
         try:
             attrdict = op.opsetattr.obj_attributes
             if FATTR4_SIZE in attrdict:
                 # This counts as a write, so must do some checking
                 if self.curr_fh.get_type() != NF4REG:
-                    return simple_error(NFS4ERR_BAD_STATEID, 0L)
+                    return simple_error(NFS4ERR_BAD_STATEID, 0)
                 oldsize = self.curr_fh.fattr4_size
                 newsize = attrdict[FATTR4_SIZE]
                 if oldsize <= newsize:
diff --git a/nfs4.0/nfs4state.py b/nfs4.0/nfs4state.py
index e854b3b..484a284 100755
--- a/nfs4.0/nfs4state.py
+++ b/nfs4.0/nfs4state.py
@@ -26,7 +26,7 @@ POSIXLOCK = True # If True, allow locks to be split/joined automatically
 POSIXACL = True # If True, forces acls to follow posix mapping rules
 
 class NFS4Error(Exception):
-    def __init__(self, code, msg=None, attrs=0L, lock_denied=None):
+    def __init__(self, code, msg=None, attrs=0, lock_denied=None):
         self.code = code
         self.name = nfsstat4[code]
         if msg is None:
@@ -384,7 +384,7 @@ class NFSServerState:
         # Check for special stateids
         if stateid.seqid==0 and stateid.other==chr(0)*12:
             return 0
-        if stateid.seqid==0xffffffffL and stateid.other==chr(0xff)*12:
+        if stateid.seqid==0xffffffff and stateid.other==chr(0xff)*12:
             return 1
         # Check for self consistency
         if stateid.other[:4] != self.instance:
diff --git a/nfs4.0/servertests/environment.py b/nfs4.0/servertests/environment.py
index a848ed4..a5cfe60 100644
--- a/nfs4.0/servertests/environment.py
+++ b/nfs4.0/servertests/environment.py
@@ -119,7 +119,7 @@ class Environment(testmod.Environment):
         self.filedata = "This is the file test data."
         self.linkdata = "/etc/X11"
         self.stateid0 = stateid4(0, '')
-        self.stateid1 = stateid4(0xffffffffL, '\xff'*12)
+        self.stateid1 = stateid4(0xffffffff, '\xff'*12)
 
     def _get_security(self, opts):
         if opts.security == 'none':
diff --git a/nfs4.0/servertests/st_commit.py b/nfs4.0/servertests/st_commit.py
index e903739..eecf2c8 100644
--- a/nfs4.0/servertests/st_commit.py
+++ b/nfs4.0/servertests/st_commit.py
@@ -42,7 +42,7 @@ def testCommitOffsetMax1(t, env):
     DEPEND: MKFILE
     CODE: CMT1c
     """
-    _commit(t, env.c1, 0xffffffffffffffffL, statlist=[NFS4_OK, NFS4ERR_INVAL])
+    _commit(t, env.c1, 0xffffffffffffffff, statlist=[NFS4_OK, NFS4ERR_INVAL])
 
 def testCommitOffsetMax2(t, env):
     """COMMIT
@@ -51,7 +51,7 @@ def testCommitOffsetMax2(t, env):
     DEPEND: MKFILE
     CODE: CMT1d
     """
-    _commit(t, env.c1, 0xfffffffffffffffeL, statlist=[NFS4_OK, NFS4ERR_INVAL])
+    _commit(t, env.c1, 0xfffffffffffffffe, statlist=[NFS4_OK, NFS4ERR_INVAL])
 
 def testCommitCount1(t, env):
     """COMMIT
@@ -69,7 +69,7 @@ def testCommitCountMax(t, env):
     DEPEND: MKFILE
     CODE: CMT1f
     """
-    _commit(t, env.c1, 0, 0xffffffffL)
+    _commit(t, env.c1, 0, 0xffffffff)
 
 def testLink(t, env):
     """COMMIT
@@ -159,5 +159,5 @@ def testCommitOverflow(t, env):
     fh, stateid = c.create_confirm(t.code)
     res = c.write_file(fh, _text, 0, stateid, how=UNSTABLE4)
     check(res, msg="WRITE with how=UNSTABLE4")
-    res = c.commit_file(fh, 0xfffffffffffffff0L, 64)
+    res = c.commit_file(fh, 0xfffffffffffffff0, 64)
     check(res, NFS4ERR_INVAL, "COMMIT with offset + count overflow")
diff --git a/nfs4.1/client41tests/environment.py b/nfs4.1/client41tests/environment.py
index 6b48d12..7c7bb0c 100644
--- a/nfs4.1/client41tests/environment.py
+++ b/nfs4.1/client41tests/environment.py
@@ -373,7 +373,7 @@ def clean_dir(sess, path):
             res = sess.compound(ops)
         check(res, msg="Trying to remove %s" % repr(e.name))
 
-def do_readdir(sess, file, cookie=0, cookieverf='', attrs=0L,
+def do_readdir(sess, file, cookie=0, cookieverf='', attrs=0,
                dircount=4096, maxcount=4096):
     # Since we may not get whole directory listing in one readdir request,
     # loop until we do. For each request result, create a flat list
diff --git a/nfs4.1/dataserver.py b/nfs4.1/dataserver.py
index f32f3d7..80179f8 100644
--- a/nfs4.1/dataserver.py
+++ b/nfs4.1/dataserver.py
@@ -206,7 +206,7 @@ class DataServer41(DataServer):
 
     def get_size(self, fh):
         ops = [op4.putfh(fh),
-               op4.getattr(1L << const4.FATTR4_SIZE)]
+               op4.getattr(1 << const4.FATTR4_SIZE)]
         res = self._execute(ops)
         attrdict = res.resarray[-1].obj_attributes
         return attrdict.get(const4.FATTR4_SIZE, 0)
diff --git a/nfs4.1/fs.py b/nfs4.1/fs.py
index d9b58f2..b0b06d5 100644
--- a/nfs4.1/fs.py
+++ b/nfs4.1/fs.py
@@ -306,7 +306,7 @@ class FSObject(object):
         # STUB - need to check principal, and set owner/group if needed
         log_o.log(5, "FSObject.set_attrs(%r)" % attrs)
         info = nfs4lib.attr_info
-        bitmap = 0L
+        bitmap = 0
         try:
             for attr in attrs:
                 if self.fs.fattr4_supported_attrs & attr == 0:
diff --git a/nfs4.1/nfs4client.py b/nfs4.1/nfs4client.py
index 708850d..135981d 100644
--- a/nfs4.1/nfs4client.py
+++ b/nfs4.1/nfs4client.py
@@ -611,7 +611,7 @@ sha256 = '`\x86H\x01e\x03\x04\x02\x01'
 binding_opts = conn_binding4args(True, ["gibberish", sha256])
 fore_attrs = channel_attrs4(4096,4096,4096,128,8,[])
 cb_sec= callback_sec_parms4(0)
-C.compound([C.create_session_op(0,1,0L,0,binding_opts, fore_attrs, fore_attrs,123,[cb_sec])])
+C.compound([C.create_session_op(0,1,0,0,binding_opts, fore_attrs, fore_attrs,123,[cb_sec])])
 """
 
 """ SEQUENCE
diff --git a/nfs4.1/nfs4lib.py b/nfs4.1/nfs4lib.py
index 96752c2..20eae0f 100644
--- a/nfs4.1/nfs4lib.py
+++ b/nfs4.1/nfs4lib.py
@@ -194,7 +194,7 @@ class FancyNFS4Packer(NFS4Packer):
     def filter_bitmap4(self, data):
         out = []
         while data:
-            out.append(data & 0xffffffffL)
+            out.append(data & 0xffffffff)
             data >>= 32
         return out
 
@@ -217,7 +217,7 @@ class FancyNFS4Packer(NFS4Packer):
 class FancyNFS4Unpacker(NFS4Unpacker):
     def filter_bitmap4(self, data):
         """Put bitmap into single long, instead of array of 32bit chunks"""
-        out = 0L
+        out = 0
         shift = 0
         for i in data:
             out |= (long(i) << shift)
@@ -276,9 +276,9 @@ def fattr2dict(obj):
 
 def list2bitmap(list):
     """Construct a bitmap from a list of bit numbers"""
-    mask = 0L
+    mask = 0
     for bit in list:
-        mask |= 1L << bit
+        mask |= 1 << bit
     return mask
 
 def bitmap2list(bitmap):
@@ -565,7 +565,7 @@ def attr_name(bitnum):
     return bitnum2attr.get(bitnum, "unknown_%r" % bitnum)
 
 class NFS4Error(Exception):
-    def __init__(self, status, attrs=0L, lock_denied=None, tag=None, check_msg=None):
+    def __init__(self, status, attrs=0, lock_denied=None, tag=None, check_msg=None):
         self.status = status
         self.name = xdrdef.nfs4_const.nfsstat4[status]
         if check_msg is None:
diff --git a/nfs4.1/nfs4server.py b/nfs4.1/nfs4server.py
index f8bd251..cd78082 100755
--- a/nfs4.1/nfs4server.py
+++ b/nfs4.1/nfs4server.py
@@ -212,7 +212,7 @@ class ClientList(object):
     def __init__(self):
         self._data = {}
         self.lock = Lock("ClientList")
-        self._nextid = 0L
+        self._nextid = 0
 
     def __getitem__(self, key):
         return self._data.get(key)
@@ -1381,7 +1381,7 @@ class NFS4Server(rpc.Server):
 
     def open_claim_null(self, arg, env):
         """Simulated switch function from op_open that handles CLAIM_NULL"""
-        bitmask = 0L
+        bitmask = 0
         # cfh holds dir, claim.file holds name
         if not env.cfh.isdir:
             raise NFS4Error(NFS4ERR_NOTDIR)
diff --git a/nfs4.1/server41tests/environment.py b/nfs4.1/server41tests/environment.py
index 1a837ee..823dfe3 100644
--- a/nfs4.1/server41tests/environment.py
+++ b/nfs4.1/server41tests/environment.py
@@ -139,7 +139,7 @@ class Environment(testmod.Environment):
         self.filedata = "This is the file test data."
         self.linkdata = "/etc/X11"
         self.stateid0 = stateid4(0, '')
-        self.stateid1 = stateid4(0xffffffffL, '\xff'*12)
+        self.stateid1 = stateid4(0xffffffff, '\xff'*12)
 
         log.info("Created client to %s, %i" % (opts.server, opts.port))
 
@@ -429,7 +429,7 @@ def clean_dir(sess, path):
             res = sess.compound(ops)
         check(res, msg="Trying to remove %s" % repr(e.name))
 
-def do_readdir(sess, file, cookie=0, cookieverf='', attrs=0L,
+def do_readdir(sess, file, cookie=0, cookieverf='', attrs=0,
                dircount=4096, maxcount=4096):
     # Since we may not get whole directory listing in one readdir request,
     # loop until we do. For each request result, create a flat list
diff --git a/nfs4.1/server41tests/st_debug.py b/nfs4.1/server41tests/st_debug.py
index e34d03f..345fc77 100644
--- a/nfs4.1/server41tests/st_debug.py
+++ b/nfs4.1/server41tests/st_debug.py
@@ -89,7 +89,7 @@ def testDeadlock(t, env):
     def ops(i):
         return [op.putfh(fh),
                 op.write(stateid, i*1000, UNSTABLE4, chr(97+i)*100),
-                op.getattr(42950721818L)
+                op.getattr(42950721818)
                 ]
     xids = [sess1.compound_async(ops(i), slot=i) for i in range(4)]
     for xid in xids:
diff --git a/nfs4.1/testmod.py b/nfs4.1/testmod.py
index 8108a23..21e9915 100644
--- a/nfs4.1/testmod.py
+++ b/nfs4.1/testmod.py
@@ -374,7 +374,7 @@ def createtests(testdir):
     # Reduce doc string info into format easier to work with
     used_codes = {}
     flag_dict = {}
-    bit = 1L
+    bit = 1
     for t in tests:
 ##         if not t.flags_list:
 ##             raise RuntimeError("%s has no flags" % t.fullname)
diff --git a/rpc/rpc.py b/rpc/rpc.py
index 834fedd..af2b325 100644
--- a/rpc/rpc.py
+++ b/rpc/rpc.py
@@ -265,8 +265,8 @@ class Pipe(object):
                 # We don't even have the packet length yet, wait for more data
                 break
             packetlen = struct.unpack('>L', buf[0:4])[0]
-            last = 0x80000000L & packetlen
-            packetlen &= 0x7fffffffL
+            last = 0x80000000 & packetlen
+            packetlen &= 0x7fffffff
             packetlen += 4 # Include size of record mark
             if len(buf) < packetlen:
                 # We don't have a full packet yet, wait for more data
@@ -310,7 +310,7 @@ class Pipe(object):
                 chunk = record[i: i + count]
                 i += count
                 if i >= dlen:
-                    last = 0x80000000L
+                    last = 0x80000000
                 mark = struct.pack('>L', last | len(chunk))
                 out += mark + chunk
             return out
@@ -351,7 +351,7 @@ class RpcPipe(Pipe):
         Pipe.__init__(self, *args, **kwargs)
         self._pending = {} # {xid:defer}
         self._lock = threading.Lock() # Protects fields below
-        self._xid = random.randint(0, 0x7fffffffL)
+        self._xid = random.randint(0, 0x7fffffff)
         self.set_active()
 
     def _get_xid(self):
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 6/6] pynfs: python3 support plan: octal literal 0644 -> 0o644
  2018-07-22  9:27 [PATCH 1/6] pynfs: python3 support plan: print -> print() jiyin
                   ` (3 preceding siblings ...)
  2018-07-22  9:27 ` [PATCH 5/6] pynfs: python3 support plan: remove suffix 'L' of long integer jiyin
@ 2018-07-22  9:27 ` jiyin
  4 siblings, 0 replies; 6+ messages in thread
From: jiyin @ 2018-07-22  9:27 UTC (permalink / raw)
  To: bfields; +Cc: linux-nfs, Jianhong.Yin

From: "Jianhong.Yin" <yin-jianhong@163.com>

s/\<0([0-9]{3})\>/0o\1/g
s/\<0([0-9]{2})\>/0o\1/g

Signed-off-by: Jianhong Yin <yin-jianhong@163.com>
---
 nfs4.0/nfs4acl.py                   |  8 ++++----
 nfs4.0/nfs4lib.py                   | 10 +++++-----
 nfs4.0/nfs4state.py                 |  4 ++--
 nfs4.0/servertests/st_close.py      |  4 ++--
 nfs4.0/servertests/st_create.py     |  2 +-
 nfs4.0/servertests/st_delegation.py |  2 +-
 nfs4.0/servertests/st_lock.py       |  2 +-
 nfs4.0/servertests/st_locku.py      |  2 +-
 nfs4.0/servertests/st_lookup.py     | 10 +++++-----
 nfs4.0/servertests/st_open.py       | 18 +++++++++---------
 nfs4.0/servertests/st_read.py       |  4 ++--
 nfs4.0/servertests/st_readdir.py    |  8 ++++----
 nfs4.0/servertests/st_reboot.py     |  4 ++--
 nfs4.0/servertests/st_setattr.py    | 18 +++++++++---------
 nfs4.0/servertests/st_write.py      | 16 ++++++++--------
 nfs4.1/client41tests/environment.py |  8 ++++----
 nfs4.1/dataserver.py                |  6 +++---
 nfs4.1/fs.py                        |  2 +-
 nfs4.1/nfs4client.py                |  2 +-
 nfs4.1/server41tests/environment.py | 14 +++++++-------
 nfs4.1/server41tests/st_lookup.py   |  4 ++--
 21 files changed, 74 insertions(+), 74 deletions(-)

diff --git a/nfs4.0/nfs4acl.py b/nfs4.0/nfs4acl.py
index 91a0316..b7f033e 100644
--- a/nfs4.0/nfs4acl.py
+++ b/nfs4.0/nfs4acl.py
@@ -66,9 +66,9 @@ def mode2acl(mode, dir=False):
     """Translate a 3-digit octal mode into a posix compatible acl"""
     if dir: modes = DMODES
     else:   modes = MODES
-    owner = modes[(mode & 0700)//0100] | FLAG_ALL | FLAG_OWN
-    group = modes[(mode & 0070)//010] | FLAG_ALL
-    other = modes[(mode & 0007)] | FLAG_ALL
+    owner = modes[(mode & 0o700)//0o100] | FLAG_ALL | FLAG_OWN
+    group = modes[(mode & 0o070)//0o10] | FLAG_ALL
+    other = modes[(mode & 0o007)] | FLAG_ALL
 
     return [ nfsace4(ALLOWED, 0, owner, "OWNER@"),
              nfsace4(DENIED, 0, negate(owner), "OWNER@"),
@@ -102,7 +102,7 @@ def acl2mode(acl):
     for key in perms:
         if perms[key] is None:
             perm[keys] = 0
-    return perms["OWNER@"]*0100 + perms["GROUP@"]*010 + perms["EVERYONE@"]
+    return perms["OWNER@"]*0o100 + perms["GROUP@"]*0o10 + perms["EVERYONE@"]
         
 def maps_to_posix(acl):
     """Raises ACLError if acl does not map to posix """
diff --git a/nfs4.0/nfs4lib.py b/nfs4.0/nfs4lib.py
index d255eb7..5c9e853 100644
--- a/nfs4.0/nfs4lib.py
+++ b/nfs4.0/nfs4lib.py
@@ -463,7 +463,7 @@ class NFS4Client(rpc.RPCClient):
         return self.compound(ops)
 
     def open(self, owner, name=None, type=OPEN4_NOCREATE,
-             mode=UNCHECKED4, attrs={FATTR4_MODE:0644}, verf=None,
+             mode=UNCHECKED4, attrs={FATTR4_MODE:0o644}, verf=None,
              access=OPEN4_SHARE_ACCESS_READ,
              deny=OPEN4_SHARE_DENY_WRITE,
              claim_type=CLAIM_NULL, deleg_type=None, deleg_cur_info=None):
@@ -568,7 +568,7 @@ class NFS4Client(rpc.RPCClient):
         for e in entries:
             # We separate setattr and remove to avoid an inode locking bug
             ops = [op4.putfh(fh), op4.lookup(e.name)]
-            ops += [op4.setattr(stateid, {FATTR4_MODE:0755})]
+            ops += [op4.setattr(stateid, {FATTR4_MODE:0o755})]
             res = self.compound(ops)
             check_result(res, "Making sure %s is writable" % repr(e.name))
             ops = [op4.putfh(fh), op4.remove(e.name)]
@@ -589,7 +589,7 @@ class NFS4Client(rpc.RPCClient):
         d = self.do_getattrdict([], [FATTR4_LEASE_TIME])
         return d[FATTR4_LEASE_TIME]
 
-    def create_obj(self, path, type=NF4DIR, attrs={FATTR4_MODE:0755},
+    def create_obj(self, path, type=NF4DIR, attrs={FATTR4_MODE:0o755},
                    linkdata="/etc/X11"):
         if __builtins__['type'](path) is str:
             path = self.homedir + [path]
@@ -613,7 +613,7 @@ class NFS4Client(rpc.RPCClient):
         ops += [op4.rename(oldpath[-1], newpath[-1])]
         return self.compound(ops)
 
-    def create_file(self, owner, path=None, attrs={FATTR4_MODE: 0644},
+    def create_file(self, owner, path=None, attrs={FATTR4_MODE: 0o644},
                     access=OPEN4_SHARE_ACCESS_BOTH,
                     deny=OPEN4_SHARE_DENY_WRITE,
                     mode=UNCHECKED4, verifier=None,
@@ -702,7 +702,7 @@ class NFS4Client(rpc.RPCClient):
         return (fhandle, stateid)
         
 
-    def create_confirm(self, owner, path=None, attrs={FATTR4_MODE: 0644},
+    def create_confirm(self, owner, path=None, attrs={FATTR4_MODE: 0o644},
                        access=OPEN4_SHARE_ACCESS_BOTH,
                        deny=OPEN4_SHARE_DENY_WRITE,
                        mode=GUARDED4):
diff --git a/nfs4.0/nfs4state.py b/nfs4.0/nfs4state.py
index 484a284..180e642 100755
--- a/nfs4.0/nfs4state.py
+++ b/nfs4.0/nfs4state.py
@@ -953,7 +953,7 @@ class VirtualHandle(NFSFileHandle):
 
         if self.fattr4_type == NF4DIR:
             self.dirent = DirList()
-            self.fattr4_mode = 0755
+            self.fattr4_mode = 0o755
         if self.fattr4_type == NF4REG:
             self.file = StringIO.StringIO()
             self.state = NFSFileState()
@@ -987,7 +987,7 @@ class VirtualHandle(NFSFileHandle):
         self.fattr4_maxname = 128 # Are these enforced?
         self.fattr4_maxread = 1000 # Are these enforced?
         self.fattr4_maxwrite = 1000 # Are these enforced?
-        self.fattr4_mode = 0644 # Currently no access restrictions enforced
+        self.fattr4_mode = 0o644 # Currently no access restrictions enforced
         self.fattr4_acl = nfs4acl.mode2acl(self.fattr4_mode,
                                            self.fattr4_type == NF4DIR)
         self.fattr4_numlinks = 1 # Updated? - Yes
diff --git a/nfs4.0/servertests/st_close.py b/nfs4.0/servertests/st_close.py
index 1690fad..89ccbba 100644
--- a/nfs4.0/servertests/st_close.py
+++ b/nfs4.0/servertests/st_close.py
@@ -110,7 +110,7 @@ def testTimedoutClose1(t, env):
     sleeptime = c.getLeaseTime() * 2
     c.init_connection()
     fh, stateid = c.create_confirm(t.code, deny=OPEN4_SHARE_DENY_WRITE,
-                                   attrs={FATTR4_MODE: 0666})
+                                   attrs={FATTR4_MODE: 0o666})
     env.sleep(sleeptime)
     # Conflicting open should force server to drop state
     c2 = env.c2
@@ -132,7 +132,7 @@ def testTimedoutClose2(t, env):
     sleeptime = c.getLeaseTime() * 2
     c.init_connection()
     fh, stateid = c.create_confirm(t.code, deny=OPEN4_SHARE_DENY_WRITE,
-                                   attrs={FATTR4_MODE: 0666})
+                                   attrs={FATTR4_MODE: 0o666})
     res = c.lock_file(t.code, fh, stateid)
     check(res)
     env.sleep(sleeptime)
diff --git a/nfs4.0/servertests/st_create.py b/nfs4.0/servertests/st_create.py
index ac57aaf..c7256e5 100644
--- a/nfs4.0/servertests/st_create.py
+++ b/nfs4.0/servertests/st_create.py
@@ -8,7 +8,7 @@ def getDefaultAttr(c):
     attr = {}
     #attr[FATTR4_OWNER] = c.security.get_owner()
     #attr[FATTR4_OWNER_GROUP] = c.security.get_group()
-    attr[FATTR4_MODE] = 0755
+    attr[FATTR4_MODE] = 0o755
     return attr
 
 def _test_create(t, env, type, name, **keywords):
diff --git a/nfs4.0/servertests/st_delegation.py b/nfs4.0/servertests/st_delegation.py
index 8e0d891..937d95f 100644
--- a/nfs4.0/servertests/st_delegation.py
+++ b/nfs4.0/servertests/st_delegation.py
@@ -706,7 +706,7 @@ def testServerChmod(t, env):
     c.init_connection('pynfs%i_%s' % (os.getpid(), t.code), cb_ident=0)
     c.create_confirm(t.code, path=c.homedir + [t.code + '-2'])
     _get_deleg(t, c, c.homedir + [t.code], _recall, NFS4_OK)
-    env.serverhelper("chmod 0777 " + _listToPath(c.homedir + [t.code]))
+    env.serverhelper("chmod 0o777 " + _listToPath(c.homedir + [t.code]))
     _verify_cb_occurred(t, c, count)
 
 def testServerSelfConflict(t, env):
diff --git a/nfs4.0/servertests/st_lock.py b/nfs4.0/servertests/st_lock.py
index 1cdbea3..060236a 100644
--- a/nfs4.0/servertests/st_lock.py
+++ b/nfs4.0/servertests/st_lock.py
@@ -529,7 +529,7 @@ def testReadLocks2(t, env):
     file = c1.homedir + [t.code]
     # Client1 creates a file
     fh1, stateid1 = c1.create_confirm('owner1', file,
-                                      attrs={FATTR4_MODE: 0666},
+                                      attrs={FATTR4_MODE: 0o666},
                                       access=OPEN4_SHARE_ACCESS_BOTH,
                                       deny=OPEN4_SHARE_DENY_NONE)
     # Client2 opens the file
diff --git a/nfs4.0/servertests/st_locku.py b/nfs4.0/servertests/st_locku.py
index 3006445..74b464a 100644
--- a/nfs4.0/servertests/st_locku.py
+++ b/nfs4.0/servertests/st_locku.py
@@ -256,7 +256,7 @@ def testTimedoutUnlock(t, env):
     c = env.c1
     sleeptime = c.getLeaseTime() * 3 // 2
     c.init_connection()
-    fh, stateid = c.create_confirm(t.code, attrs={FATTR4_MODE: 0666})
+    fh, stateid = c.create_confirm(t.code, attrs={FATTR4_MODE: 0o666})
     res1 = c.lock_file(t.code, fh, stateid)
     check(res1)
     env.sleep(sleeptime)
diff --git a/nfs4.0/servertests/st_lookup.py b/nfs4.0/servertests/st_lookup.py
index cd1b93c..a57d4cb 100644
--- a/nfs4.0/servertests/st_lookup.py
+++ b/nfs4.0/servertests/st_lookup.py
@@ -206,7 +206,7 @@ def testNonAccessable(t, env):
     DEPEND: MKDIR
     CODE: LOOK6
     """
-    # Create dir/foo, and set mode of dir to 000
+    # Create dir/foo, and set mode of dir to 0o000
     c = env.c1
     dir = c.homedir + [t.code]
     res = c.create_obj(dir)
@@ -220,9 +220,9 @@ def testNonAccessable(t, env):
     check(res)
     res = c.compound(c.use_obj(dir + ['foo']))
     if env.opts.uid == 0:
-	    check(res, [NFS4_OK, NFS4ERR_ACCESS], "LOOKUP object in a dir with mode=000")
+	    check(res, [NFS4_OK, NFS4ERR_ACCESS], "LOOKUP object in a dir with mode=0o000")
     else:
-	    check(res, NFS4ERR_ACCESS, "LOOKUP object in a dir with mode=000")
+	    check(res, NFS4ERR_ACCESS, "LOOKUP object in a dir with mode=0o000")
 
 def testInvalidUtf8(t, env):
     """LOOKUP with bad UTF-8 name strings should return NFS4ERR_INVAL
@@ -283,9 +283,9 @@ def testUnaccessibleDir(t, env):
     check(res, msg="Setting mode=0 on directory %s" % t.code)
     res = c.compound(c.use_obj(path + ['hidden']))
     if env.opts.uid == 0:
-	    check(res, [NFS4_OK, NFS4ERR_ACCESS], "LOOKUP off of dir with mode=000")
+	    check(res, [NFS4_OK, NFS4ERR_ACCESS], "LOOKUP off of dir with mode=0o000")
     else:
-	    check(res, NFS4ERR_ACCESS, "LOOKUP off of dir with mode=000")
+	    check(res, NFS4ERR_ACCESS, "LOOKUP off of dir with mode=0o000")
 
 def testBadOpaque(t, env):
     """LOOKUP with a path component that has an incorrect array length
diff --git a/nfs4.0/servertests/st_open.py b/nfs4.0/servertests/st_open.py
index 437fb67..12db5df 100644
--- a/nfs4.0/servertests/st_open.py
+++ b/nfs4.0/servertests/st_open.py
@@ -25,7 +25,7 @@ def testCreateUncheckedFile(t, env):
     c.init_connection()
 
     # Create the file
-    orig_attrs = { FATTR4_MODE: 0644, FATTR4_SIZE: 32 }
+    orig_attrs = { FATTR4_MODE: 0o644, FATTR4_SIZE: 32 }
     res = c.create_file(t.code, attrs=orig_attrs,  deny=OPEN4_SHARE_DENY_NONE)
     check(res, msg="Trying to create file %s" % t.code)
     fh, stateid = c.confirm(t.code, res)
@@ -33,7 +33,7 @@ def testCreateUncheckedFile(t, env):
     checkdict(orig_attrs, rcvd_attrs, get_bitnumattr_dict(),
               "Checking attrs on creation")
     # Create the file again...it should ignore attrs
-    attrs = { FATTR4_MODE: 0600, FATTR4_SIZE: 16 }
+    attrs = { FATTR4_MODE: 0o600, FATTR4_SIZE: 16 }
     res = c.create_file(t.code, attrs=attrs,  deny=OPEN4_SHARE_DENY_NONE)
     check(res, msg="Trying to recreate file %s" % t.code)
     fh, stateid = c.confirm(t.code, res)
@@ -41,12 +41,12 @@ def testCreateUncheckedFile(t, env):
     checkdict(orig_attrs, rcvd_attrs, get_bitnumattr_dict(),
               "Attrs on recreate should be ignored")
     # Create the file again, should truncate size to 0 and ignore other attrs
-    attrs = { FATTR4_MODE: 0600, FATTR4_SIZE: 0 }
+    attrs = { FATTR4_MODE: 0o600, FATTR4_SIZE: 0 }
     res = c.create_file(t.code, attrs=attrs,  deny=OPEN4_SHARE_DENY_NONE)
     check(res, msg="Trying to truncate file %s" % t.code)
     fh, stateid = c.confirm(t.code, res)
     rcvd_attrs = c.do_getattrdict(fh, orig_attrs.keys())
-    expect = { FATTR4_MODE: 0644, FATTR4_SIZE: 0 }
+    expect = { FATTR4_MODE: 0o644, FATTR4_SIZE: 0 }
     checkdict(expect, rcvd_attrs, get_bitnumattr_dict(),
               "Attrs on recreate should be ignored, except for size")
         
@@ -327,13 +327,13 @@ def testModeChange(t, env):
     check(res)
     ops = c.use_obj(fh) + [c.setattr({FATTR4_MODE:0})]
     res = c.compound(ops)
-    check(res, msg="Setting mode of file %s to 000" % t.code)
+    check(res, msg="Setting mode of file %s to 0o000" % t.code)
     res = c.open_file(t.code, access=OPEN4_SHARE_ACCESS_BOTH,
                       deny=OPEN4_SHARE_DENY_NONE)
     if env.opts.uid == 0:
-	    check(res, [NFS4_OK, NFS4ERR_ACCESS], "Opening file %s with mode=000" % t.code)
+	    check(res, [NFS4_OK, NFS4ERR_ACCESS], "Opening file %s with mode=0o000" % t.code)
     else:
-	    check(res, NFS4ERR_ACCESS, "Opening file %s with mode=000" % t.code)
+	    check(res, NFS4ERR_ACCESS, "Opening file %s with mode=0o000" % t.code)
 
 def testShareConflict1(t, env):
     """OPEN conflicting with previous share
@@ -361,13 +361,13 @@ def testFailedOpen(t, env):
     c1.init_connection()
     # Client 1: create a file and deny others access
     fh, stateid = c1.create_confirm(t.code)
-    ops = c1.use_obj(fh) + [c1.setattr({FATTR4_MODE: 0700})]
+    ops = c1.use_obj(fh) + [c1.setattr({FATTR4_MODE: 0o700})]
     check(c1.compound(ops))
     # Client 2: try to open the file
     c2 = env.c2
     c2.init_connection()
     res = c2.open_file(t.code)
-    check(res, NFS4ERR_ACCESS, "Opening file with mode 0700 as 'other'")
+    check(res, NFS4ERR_ACCESS, "Opening file with mode 0o700 as 'other'")
     # Client 1: try to use fh, stateid
     res1 = c1.lock_file(t.code, fh, stateid)
     check(res1, msg="Locking file after another client had a failed open")
diff --git a/nfs4.0/servertests/st_read.py b/nfs4.0/servertests/st_read.py
index 9b2203b..15f8795 100644
--- a/nfs4.0/servertests/st_read.py
+++ b/nfs4.0/servertests/st_read.py
@@ -74,7 +74,7 @@ def testLargeCount(t, env):
     c = env.c1
     c.init_connection()
     fh, stateid = c.create_confirm(t.code, attrs={FATTR4_SIZE: 10000000,
-                                                  FATTR4_MODE: 0644})
+                                                  FATTR4_MODE: 0o644})
     res = c.read_file(fh, 0, 9000000, stateid)
     check(res, msg="Reading file %s" % t.code)
     _compare(t, res, '\x00'*9000000, False)
@@ -234,7 +234,7 @@ def testStolenStateid(t, env):
     """
     c = env.c1
     c.init_connection()
-    res = c.create_file(t.code, attrs={FATTR4_MODE: 0600})
+    res = c.create_file(t.code, attrs={FATTR4_MODE: 0o600})
     fh, stateid = c.confirm(t.code, res)
     security=c.security
     c.security=rpc.SecAuthSys(0, "whatever", 3912, 2422, [])
diff --git a/nfs4.0/servertests/st_readdir.py b/nfs4.0/servertests/st_readdir.py
index 5a70145..fb484b6 100644
--- a/nfs4.0/servertests/st_readdir.py
+++ b/nfs4.0/servertests/st_readdir.py
@@ -232,9 +232,9 @@ def testUnaccessibleDir(t, env):
     ops = c.use_obj(path) + [c.readdir()]
     res = c.compound(ops)
     if env.opts.uid == 0:
-	    check(res, [NFS4_OK, NFS4ERR_ACCESS], "READDIR of directory with mode=000")
+	    check(res, [NFS4_OK, NFS4ERR_ACCESS], "READDIR of directory with mode=0o000")
     else:
-	    check(res, NFS4ERR_ACCESS, "READDIR of directory with mode=000")
+	    check(res, NFS4ERR_ACCESS, "READDIR of directory with mode=0o000")
    
 def testUnaccessibleDirAttrs(t, env):
     """READDIR with (cfh) in unaccessible directory requesting attrs
@@ -253,9 +253,9 @@ def testUnaccessibleDirAttrs(t, env):
           [c.readdir(attr_request=[FATTR4_RDATTR_ERROR, FATTR4_TYPE])]
     res = c.compound(ops)
     if env.opts.uid == 0:
-	    check(res, [NFS4_OK, NFS4ERR_ACCESS], "READDIR of directory with mode=000")
+	    check(res, [NFS4_OK, NFS4ERR_ACCESS], "READDIR of directory with mode=0o000")
     else:
-	    check(res, NFS4ERR_ACCESS, "READDIR of directory with mode=000")
+	    check(res, NFS4ERR_ACCESS, "READDIR of directory with mode=0o000")
    
 ###########################################
 
diff --git a/nfs4.0/servertests/st_reboot.py b/nfs4.0/servertests/st_reboot.py
index 33c3a4a..16cb008 100644
--- a/nfs4.0/servertests/st_reboot.py
+++ b/nfs4.0/servertests/st_reboot.py
@@ -116,7 +116,7 @@ def testEdge1(t, env):
     c1 = env.c1
     c1.init_connection()
     # Client 1: lock file
-    fh1, stateid1 = c1.create_confirm(t.code, attrs={FATTR4_MODE:0666},
+    fh1, stateid1 = c1.create_confirm(t.code, attrs={FATTR4_MODE:0o666},
                                       access=OPEN4_SHARE_ACCESS_BOTH,
                                       deny=OPEN4_SHARE_DENY_NONE)
     res1 = c1.lock_file(t.code, fh1, stateid1)
@@ -161,7 +161,7 @@ def testEdge2(t, env):
     c1 = env.c1
     c1.init_connection()
     # Client 1: lock file
-    fh1, stateid1 = c1.create_confirm(t.code, attrs={FATTR4_MODE:0666},
+    fh1, stateid1 = c1.create_confirm(t.code, attrs={FATTR4_MODE:0o666},
                                       access=OPEN4_SHARE_ACCESS_BOTH,
                                       deny=OPEN4_SHARE_DENY_NONE)
     res1 = c1.lock_file(t.code, fh1, stateid1)
diff --git a/nfs4.0/servertests/st_setattr.py b/nfs4.0/servertests/st_setattr.py
index 4a80f65..aa7123b 100644
--- a/nfs4.0/servertests/st_setattr.py
+++ b/nfs4.0/servertests/st_setattr.py
@@ -7,7 +7,7 @@ op = nfs_ops.NFS4ops()
 
 def _set_mode(t, c, file, stateid=None, msg=" using stateid=0",
               warnlist=[]):
-    mode = 0740
+    mode = 0o740
     dict = {FATTR4_MODE: mode}
     ops = c.use_obj(file) + [c.setattr(dict, stateid)]
     res = c.compound(ops)
@@ -399,7 +399,7 @@ def testInvalidAttr1(t, env):
     path = c.homedir + [t.code]
     res = c.create_obj(path)
     check(res)
-    badattr = dict2fattr({FATTR4_MODE: 0644})
+    badattr = dict2fattr({FATTR4_MODE: 0o644})
     badattr.attr_vals = ''
     res = c.compound(c.use_obj(path) + [op.setattr(env.stateid0, badattr)])
     check(res, NFS4ERR_BADXDR, "SETATTR(FATTR4_MODE) with no data")
@@ -418,7 +418,7 @@ def testInvalidAttr2(t, env):
     path = c.homedir + [t.code]
     res = c.create_obj(path)
     check(res)
-    badattr = dict2fattr({FATTR4_MODE: 0644})
+    badattr = dict2fattr({FATTR4_MODE: 0o644})
     badattr.attr_vals += 'Garbage data'
     res = c.compound(c.use_obj(path) + [op.setattr(env.stateid0, badattr)])
     check(res, NFS4ERR_BADXDR,
@@ -674,7 +674,7 @@ def testInodeLocking(t, env):
     
     # In a single compound statement, setattr on dir and then
     # do a state operation on a file in dir (like write or remove)
-    ops = c.use_obj(basedir) + [c.setattr({FATTR4_MODE:0754})]
+    ops = c.use_obj(basedir) + [c.setattr({FATTR4_MODE:0o754})]
     ops += [op.lookup('file'), op.write(stateid, 0, 0, 'blahblah')]
     res = c.compound(ops)
     check(res, msg="SETATTR on dir and state operation on file in dir")
@@ -690,7 +690,7 @@ def testChange(t, env):
     c.init_connection()
     fh, stateid = c.create_confirm(t.code)
     change = c.do_getattr(FATTR4_CHANGE, fh)
-    ops = c.use_obj(fh) + [c.setattr({FATTR4_MODE: 0740})]
+    ops = c.use_obj(fh) + [c.setattr({FATTR4_MODE: 0o740})]
     res = c.compound(ops)
     check(res)
     change2 = c.do_getattr(FATTR4_CHANGE, fh)
@@ -708,10 +708,10 @@ def testChangeGranularity(t, env):
     c.init_connection()
     fh, stateid = c.create_confirm(t.code)
     ops = c.use_obj(fh) + [c.getattr([FATTR4_CHANGE])] \
-        + [c.setattr({FATTR4_MODE: 0740})] + [c.getattr([FATTR4_CHANGE])] \
-        + [c.setattr({FATTR4_MODE: 0741})] + [c.getattr([FATTR4_CHANGE])] \
-        + [c.setattr({FATTR4_MODE: 0742})] + [c.getattr([FATTR4_CHANGE])] \
-        + [c.setattr({FATTR4_MODE: 0743})] + [c.getattr([FATTR4_CHANGE])]
+        + [c.setattr({FATTR4_MODE: 0o740})] + [c.getattr([FATTR4_CHANGE])] \
+        + [c.setattr({FATTR4_MODE: 0o741})] + [c.getattr([FATTR4_CHANGE])] \
+        + [c.setattr({FATTR4_MODE: 0o742})] + [c.getattr([FATTR4_CHANGE])] \
+        + [c.setattr({FATTR4_MODE: 0o743})] + [c.getattr([FATTR4_CHANGE])]
     res = c.compound(ops)
     check(res)
     chattr1 = res.resarray[1].obj_attributes
diff --git a/nfs4.0/servertests/st_write.py b/nfs4.0/servertests/st_write.py
index 2f73cbb..4777e1b 100644
--- a/nfs4.0/servertests/st_write.py
+++ b/nfs4.0/servertests/st_write.py
@@ -38,7 +38,7 @@ def testSimpleWrite(t, env):
     """
     c = env.c1
     c.init_connection()
-    attrs = {FATTR4_SIZE: 32, FATTR4_MODE: 0644}
+    attrs = {FATTR4_SIZE: 32, FATTR4_MODE: 0o644}
     fh, stateid = c.create_confirm(t.code, attrs=attrs,
                                    deny=OPEN4_SHARE_DENY_NONE)
     res = c.write_file(fh, _text, how=UNSTABLE4)
@@ -55,7 +55,7 @@ def testSimpleWrite2(t, env):
     """
     c = env.c1
     c.init_connection()
-    attrs = {FATTR4_SIZE: 32, FATTR4_MODE: 0644}
+    attrs = {FATTR4_SIZE: 32, FATTR4_MODE: 0o644}
     fh, stateid = c.create_confirm(t.code, attrs=attrs,
                                    deny=OPEN4_SHARE_DENY_NONE)
     res = c.write_file(fh, _text, 30)
@@ -72,7 +72,7 @@ def testStateidOne(t, env):
     """
     c = env.c1
     c.init_connection()
-    attrs = {FATTR4_SIZE: 32, FATTR4_MODE: 0644}
+    attrs = {FATTR4_SIZE: 32, FATTR4_MODE: 0o644}
     fh, stateid = c.create_confirm(t.code, attrs=attrs,
                                    deny=OPEN4_SHARE_DENY_NONE)
     res = c.write_file(fh, _text, 5, env.stateid1, DATA_SYNC4)
@@ -91,7 +91,7 @@ def testWithOpen(t, env):
     """
     c = env.c1
     c.init_connection()
-    attrs = {FATTR4_SIZE: 32, FATTR4_MODE: 0644}
+    attrs = {FATTR4_SIZE: 32, FATTR4_MODE: 0o644}
     fh, stateid = c.create_confirm(t.code, attrs=attrs)
     res = c.write_file(fh, _text, 50, stateid, FILE_SYNC4)
     check(res, msg="WRITE with openstateid and FILE_SYNC4")
@@ -109,7 +109,7 @@ def testNoData(t, env):
     """
     c = env.c1
     c.init_connection()
-    attrs = {FATTR4_SIZE: 32, FATTR4_MODE: 0644}
+    attrs = {FATTR4_SIZE: 32, FATTR4_MODE: 0o644}
     fh, stateid = c.create_confirm(t.code, attrs=attrs)
     time_prior = c.do_getattr(FATTR4_TIME_MODIFY, fh)
     env.sleep(1)
@@ -281,7 +281,7 @@ def testOpenMode(t, env):
     """
     c = env.c1
     c.init_connection()
-    attrs = {FATTR4_SIZE: 32, FATTR4_MODE: 0644}
+    attrs = {FATTR4_SIZE: 32, FATTR4_MODE: 0o644}
     fh, stateid = c.create_confirm(t.code, attrs=attrs,
                                    access=OPEN4_SHARE_ACCESS_READ)
     res = c.write_file(fh, _text, 0, stateid)
@@ -298,7 +298,7 @@ def testShareDeny(t, env):
     """
     c = env.c1
     c.init_connection()
-    attrs = {FATTR4_SIZE: 32, FATTR4_MODE: 0644}
+    attrs = {FATTR4_SIZE: 32, FATTR4_MODE: 0o644}
     fh, stateid = c.create_confirm(t.code, attrs=attrs,
                                    deny=OPEN4_SHARE_DENY_WRITE)
     res = c.write_file(fh, _text)
@@ -520,7 +520,7 @@ def testStolenStateid(t, env):
     """
     c = env.c1
     c.init_connection()
-    res = c.create_file(t.code, attrs={FATTR4_MODE: 0600})
+    res = c.create_file(t.code, attrs={FATTR4_MODE: 0o600})
     fh, stateid = c.confirm(t.code, res)
     security=c.security
     c.security=rpc.SecAuthSys(0, "whatever", 3912, 2422, [])
diff --git a/nfs4.1/client41tests/environment.py b/nfs4.1/client41tests/environment.py
index 7c7bb0c..933264c 100644
--- a/nfs4.1/client41tests/environment.py
+++ b/nfs4.1/client41tests/environment.py
@@ -362,7 +362,7 @@ def clean_dir(sess, path):
     for e in entries:
         # We separate setattr and remove to avoid an inode locking bug
         ops = use_obj(path + [e.name])
-        ops += [op.setattr(stateid, {FATTR4_MODE:0755})]
+        ops += [op.setattr(stateid, {FATTR4_MODE:0o755})]
         res = sess.compound(ops)
         check(res, msg="Setting mode on %s" % repr(e.name))
         ops = use_obj(path)
@@ -405,7 +405,7 @@ def use_obj(file):
     else:
         return [op.putrootfh()] + [op.lookup(comp) for comp in file]
 
-def create_obj(sess, path, kind=NF4DIR, attrs={FATTR4_MODE:0755}):
+def create_obj(sess, path, kind=NF4DIR, attrs={FATTR4_MODE:0o755}):
     """Return ops needed to create given non-file object"""
     # Ensure using createtype4
     if not hasattr(kind, "type"):
@@ -413,7 +413,7 @@ def create_obj(sess, path, kind=NF4DIR, attrs={FATTR4_MODE:0755}):
     ops = use_obj(path[:-1]) + [op.create(kind, path[-1], attrs)]
     return sess.compound(ops)
 
-def create_file(sess, owner, path=None, attrs={FATTR4_MODE: 0644},
+def create_file(sess, owner, path=None, attrs={FATTR4_MODE: 0o644},
                 access=OPEN4_SHARE_ACCESS_BOTH,
                 deny=OPEN4_SHARE_DENY_NONE,
                 mode=GUARDED4, verifier=None, want_deleg=False):
@@ -434,7 +434,7 @@ def create_file(sess, owner, path=None, attrs={FATTR4_MODE: 0644},
                       open_claim4(CLAIM_NULL, name))
     return sess.compound(use_obj(dir) + [open_op, op.getfh()])
 
-def create_confirm(sess, owner, path=None, attrs={FATTR4_MODE: 0644},
+def create_confirm(sess, owner, path=None, attrs={FATTR4_MODE: 0o644},
                    access=OPEN4_SHARE_ACCESS_BOTH,
                    deny=OPEN4_SHARE_DENY_NONE,
                    mode=GUARDED4):
diff --git a/nfs4.1/dataserver.py b/nfs4.1/dataserver.py
index 80179f8..af0e35a 100644
--- a/nfs4.1/dataserver.py
+++ b/nfs4.1/dataserver.py
@@ -130,7 +130,7 @@ class DataServer41(DataServer):
         self.sess.compound([op4.reclaim_complete(const4.FALSE)])
 
     def make_root(self):
-        attrs = {const4.FATTR4_MODE:0777}
+        attrs = {const4.FATTR4_MODE:0o777}
         existing_path = []
         kind = type4.createtype4(const4.NF4DIR)
         for comp in self.path:
@@ -153,7 +153,7 @@ class DataServer41(DataServer):
         seqid=0
         access = const4.OPEN4_SHARE_ACCESS_BOTH
         deny = const4.OPEN4_SHARE_DENY_NONE
-        attrs = {const4.FATTR4_MODE: 0777}
+        attrs = {const4.FATTR4_MODE: 0o777}
         owner = "mds"
         mode = const4.GUARDED4
         verifier = self.sess.c.verifier
@@ -257,7 +257,7 @@ class DataServer3(DataServer):
     def open_file(self, mds_fh):
         name = self.fh_to_name(mds_fh)
         where = type3.diropargs3(self.rootfh, name)
-        attr = type3.sattr3(mode=type3.set_mode3(True, 0777),
+        attr = type3.sattr3(mode=type3.set_mode3(True, 0o777),
                             uid=type3.set_uid3(True, 0),
                             gid=type3.set_gid3(True, 0),
                             size=type3.set_size3(False),
diff --git a/nfs4.1/fs.py b/nfs4.1/fs.py
index b0b06d5..e2c7eca 100644
--- a/nfs4.1/fs.py
+++ b/nfs4.1/fs.py
@@ -25,7 +25,7 @@ class MetaData(object):
         self.refcnt = 0
         self.createverf = ""
         self.owner = ""
-        self.mode = 0777
+        self.mode = 0o777
         self.time_access = self.time_modify = self.time_create = nfs4lib.get_nfstime()
         if 1:
             self.parent = 0
diff --git a/nfs4.1/nfs4client.py b/nfs4.1/nfs4client.py
index 135981d..5288942 100644
--- a/nfs4.1/nfs4client.py
+++ b/nfs4.1/nfs4client.py
@@ -560,7 +560,7 @@ class SessionRecord(object):
         return res
 
 ##     def open(self, owner, name=None, type=OPEN4_NOCREATE,
-##              mode=UNCHECKED4, attrs={FATTR4_MODE:0644}, verf=None,
+##              mode=UNCHECKED4, attrs={FATTR4_MODE:0o644}, verf=None,
 ##              access=OPEN4_SHARE_ACCESS_READ,
 ##              deny=OPEN4_SHARE_DENY_WRITE,
 ##              claim_type=CLAIM_NULL, deleg_type=None, deleg_cur_info=None):
diff --git a/nfs4.1/server41tests/environment.py b/nfs4.1/server41tests/environment.py
index 823dfe3..3020371 100644
--- a/nfs4.1/server41tests/environment.py
+++ b/nfs4.1/server41tests/environment.py
@@ -418,7 +418,7 @@ def clean_dir(sess, path):
     for e in entries:
         # We separate setattr and remove to avoid an inode locking bug
         ops = use_obj(path + [e.name])
-        ops += [op.setattr(stateid, {FATTR4_MODE:0755})]
+        ops += [op.setattr(stateid, {FATTR4_MODE:0o755})]
         res = sess.compound(ops)
         check(res, msg="Setting mode on %s" % repr(e.name))
         ops = use_obj(path)
@@ -460,7 +460,7 @@ def do_getattrdict(sess, file, attrlist):
     check(res)
     return res.resarray[-1].obj_attributes
 
-def create_obj(sess, path, kind=NF4DIR, attrs={FATTR4_MODE:0755}):
+def create_obj(sess, path, kind=NF4DIR, attrs={FATTR4_MODE:0o755}):
     """Return ops needed to create given non-file object"""
     # Ensure using createtype4
     if not hasattr(kind, "type"):
@@ -468,7 +468,7 @@ def create_obj(sess, path, kind=NF4DIR, attrs={FATTR4_MODE:0755}):
     ops = use_obj(path[:-1]) + [op.create(kind, path[-1], attrs)]
     return sess.compound(ops)
 
-def open_create_file(sess, owner, path=None, attrs={FATTR4_MODE: 0644},
+def open_create_file(sess, owner, path=None, attrs={FATTR4_MODE: 0o644},
                      access=OPEN4_SHARE_ACCESS_BOTH,
                      deny=OPEN4_SHARE_DENY_NONE,
 		     mode=GUARDED4, verifier=None,
@@ -483,7 +483,7 @@ def open_create_file(sess, owner, path=None, attrs={FATTR4_MODE: 0644},
 
     return sess.compound(open_op)
 
-def open_create_file_op(sess, owner, path=None, attrs={FATTR4_MODE: 0644},
+def open_create_file_op(sess, owner, path=None, attrs={FATTR4_MODE: 0o644},
                      access=OPEN4_SHARE_ACCESS_BOTH,
                      deny=OPEN4_SHARE_DENY_NONE,
 		     mode=GUARDED4, verifier=None,
@@ -526,7 +526,7 @@ def open_create_file_op(sess, owner, path=None, attrs={FATTR4_MODE: 0644},
 
     return fh_op + [open_op, op.getfh()]
 
-def create_file(sess, owner, path=None, attrs={FATTR4_MODE: 0644},
+def create_file(sess, owner, path=None, attrs={FATTR4_MODE: 0o644},
                 access=OPEN4_SHARE_ACCESS_BOTH,
                 deny=OPEN4_SHARE_DENY_NONE,
                 mode=GUARDED4, verifier=None, want_deleg=False,
@@ -559,7 +559,7 @@ def open_file(sess, owner, path=None,
                             verifier, claim_type, want_deleg, deleg_type,
                             open_create, seqid, clientid)
 
-def create_confirm(sess, owner, path=None, attrs={FATTR4_MODE: 0644},
+def create_confirm(sess, owner, path=None, attrs={FATTR4_MODE: 0o644},
                    access=OPEN4_SHARE_ACCESS_BOTH,
                    deny=OPEN4_SHARE_DENY_NONE,
                    mode=GUARDED4):
@@ -572,7 +572,7 @@ def create_confirm(sess, owner, path=None, attrs={FATTR4_MODE: 0644},
     fh = res.resarray[-1].object
     return fh, res.resarray[-2].stateid
 
-def create_close(sess, owner, path=None, attrs={FATTR4_MODE: 0644},
+def create_close(sess, owner, path=None, attrs={FATTR4_MODE: 0o644},
                    access=OPEN4_SHARE_ACCESS_BOTH,
                    deny=OPEN4_SHARE_DENY_NONE,
                    mode=GUARDED4):
diff --git a/nfs4.1/server41tests/st_lookup.py b/nfs4.1/server41tests/st_lookup.py
index 9f50004..3899425 100644
--- a/nfs4.1/server41tests/st_lookup.py
+++ b/nfs4.1/server41tests/st_lookup.py
@@ -270,7 +270,7 @@ if 0:
         DEPEND: MKDIR
         CODE: LOOK6
         """
-        # Create dir/foo, and set mode of dir to 000
+        # Create dir/foo, and set mode of dir to 0o000
         c = env.c1
         dir = c.homedir + [t.code]
         res = c.create_obj(dir)
@@ -283,7 +283,7 @@ if 0:
         res = c.compound(c.use_obj(dir))
         check(res)
         res = c.compound(c.use_obj(dir + ['foo']))
-        check(res, NFS4ERR_ACCESS, "LOOKUP object in a dir with mode=000")
+        check(res, NFS4ERR_ACCESS, "LOOKUP object in a dir with mode=0o000")
 
     def testInvalidUtf8(t, env):
         """LOOKUP with bad UTF-8 name strings should return NFS4ERR_INVAL
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2018-07-22 10:23 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-07-22  9:27 [PATCH 1/6] pynfs: python3 support plan: print -> print() jiyin
2018-07-22  9:27 ` [PATCH 2/6] pynfs: python3 support plan: exec -> exec() jiyin
2018-07-22  9:27 ` [PATCH 3/6] pynfs: python3 support plan: "except E,e:" -> "except E as e:" jiyin
2018-07-22  9:27 ` [PATCH 4/6] pynfs: python3 support plan: "raise E, args:" -> "raise E(args)" jiyin
2018-07-22  9:27 ` [PATCH 5/6] pynfs: python3 support plan: remove suffix 'L' of long integer jiyin
2018-07-22  9:27 ` [PATCH 6/6] pynfs: python3 support plan: octal literal 0644 -> 0o644 jiyin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).