]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Remove all remaining uses of the FCNTL module from the standard library.
authorFred Drake <fdrake@acm.org>
Thu, 10 May 2001 15:33:31 +0000 (15:33 +0000)
committerFred Drake <fdrake@acm.org>
Thu, 10 May 2001 15:33:31 +0000 (15:33 +0000)
Lib/asyncore.py
Lib/lib-old/lockfile.py
Lib/posixfile.py

index 548ce430704e6e6f97d21aceb60420f2091c4758..4411048c0b5a6651b0093f10f369bc73ccb50cc0 100644 (file)
@@ -510,7 +510,6 @@ def close_all (map=None):
 import os
 if os.name == 'posix':
     import fcntl
-    import FCNTL
 
     class file_wrapper:
         # here we override just enough to make a file
@@ -538,9 +537,9 @@ if os.name == 'posix':
             dispatcher.__init__ (self)
             self.connected = 1
             # set it to non-blocking mode
-            flags = fcntl.fcntl (fd, FCNTL.F_GETFL, 0)
-            flags = flags | FCNTL.O_NONBLOCK
-            fcntl.fcntl (fd, FCNTL.F_SETFL, flags)
+            flags = fcntl.fcntl (fd, fcntl.F_GETFL, 0)
+            flags = flags | os.O_NONBLOCK
+            fcntl.fcntl (fd, fcntl.F_SETFL, flags)
             self.set_file (fd)
 
         def set_file (self, fd):
index 3a251d720b09d0b8c6d4fe63f1aae928c4c57a5e..3aaeac09166b9d6da5eec7c6aaa90eedfa26807d 100644 (file)
@@ -1,15 +1,15 @@
-import struct, fcntl, FCNTL
+import struct, fcntl
 
 def writelock(f):
-       _lock(f, FCNTL.F_WRLCK)
+       _lock(f, fcntl.F_WRLCK)
 
 def readlock(f):
-       _lock(f, FCNTL.F_RDLCK)
+       _lock(f, fcntl.F_RDLCK)
 
 def unlock(f):
-       _lock(f, FCNTL.F_UNLCK)
+       _lock(f, fcntl.F_UNLCK)
 
 def _lock(f, op):
-       dummy = fcntl.fcntl(f.fileno(), FCNTL.F_SETLKW,
+       dummy = fcntl.fcntl(f.fileno(), fcntl.F_SETLKW,
                            struct.pack('2h8l', op,
                                        0, 0, 0, 0, 0, 0, 0, 0, 0))
index 1df0cc816bfcca65e67031e3c8b1f10293669ec3..b16b892794c3ddd4e70d6bac05567547a32a380b 100644 (file)
@@ -107,7 +107,7 @@ class _posixfile_:
         return posix.fdopen(fd, self._file_.mode)
 
     def flags(self, *which):
-        import fcntl, FCNTL
+        import fcntl
 
         if which:
             if len(which) > 1:
@@ -116,44 +116,44 @@ class _posixfile_:
         else: which = '?'
 
         l_flags = 0
-        if 'n' in which: l_flags = l_flags | FCNTL.O_NDELAY
-        if 'a' in which: l_flags = l_flags | FCNTL.O_APPEND
-        if 's' in which: l_flags = l_flags | FCNTL.O_SYNC
+        if 'n' in which: l_flags = l_flags | os.O_NDELAY
+        if 'a' in which: l_flags = l_flags | os.O_APPEND
+        if 's' in which: l_flags = l_flags | os.O_SYNC
 
         file = self._file_
 
         if '=' not in which:
-            cur_fl = fcntl.fcntl(file.fileno(), FCNTL.F_GETFL, 0)
+            cur_fl = fcntl.fcntl(file.fileno(), fcntl.F_GETFL, 0)
             if '!' in which: l_flags = cur_fl & ~ l_flags
             else: l_flags = cur_fl | l_flags
 
-        l_flags = fcntl.fcntl(file.fileno(), FCNTL.F_SETFL, l_flags)
+        l_flags = fcntl.fcntl(file.fileno(), fcntl.F_SETFL, l_flags)
 
         if 'c' in which:
             arg = ('!' not in which)    # 0 is don't, 1 is do close on exec
-            l_flags = fcntl.fcntl(file.fileno(), FCNTL.F_SETFD, arg)
+            l_flags = fcntl.fcntl(file.fileno(), fcntl.F_SETFD, arg)
 
         if '?' in which:
             which = ''                  # Return current flags
-            l_flags = fcntl.fcntl(file.fileno(), FCNTL.F_GETFL, 0)
-            if FCNTL.O_APPEND & l_flags: which = which + 'a'
-            if fcntl.fcntl(file.fileno(), FCNTL.F_GETFD, 0) & 1:
+            l_flags = fcntl.fcntl(file.fileno(), fcntl.F_GETFL, 0)
+            if os.O_APPEND & l_flags: which = which + 'a'
+            if fcntl.fcntl(file.fileno(), fcntl.F_GETFD, 0) & 1:
                 which = which + 'c'
-            if FCNTL.O_NDELAY & l_flags: which = which + 'n'
-            if FCNTL.O_SYNC & l_flags: which = which + 's'
+            if os.O_NDELAY & l_flags: which = which + 'n'
+            if os.O_SYNC & l_flags: which = which + 's'
             return which
 
     def lock(self, how, *args):
-        import struct, fcntl, FCNTL
+        import struct, fcntl
 
-        if 'w' in how: l_type = FCNTL.F_WRLCK
-        elif 'r' in how: l_type = FCNTL.F_RDLCK
-        elif 'u' in how: l_type = FCNTL.F_UNLCK
+        if 'w' in how: l_type = fcntl.F_WRLCK
+        elif 'r' in how: l_type = fcntl.F_RDLCK
+        elif 'u' in how: l_type = fcntl.F_UNLCK
         else: raise TypeError, 'no type of lock specified'
 
-        if '|' in how: cmd = FCNTL.F_SETLKW
-        elif '?' in how: cmd = FCNTL.F_GETLK
-        else: cmd = FCNTL.F_SETLK
+        if '|' in how: cmd = fcntl.F_SETLKW
+        elif '?' in how: cmd = fcntl.F_GETLK
+        else: cmd = fcntl.F_SETLK
 
         l_whence = 0
         l_start = 0
@@ -203,8 +203,8 @@ class _posixfile_:
                 l_type, l_whence, l_start, l_len, l_sysid, l_pid = \
                     struct.unpack('hhllhh', flock)
 
-            if l_type != FCNTL.F_UNLCK:
-                if l_type == FCNTL.F_RDLCK:
+            if l_type != fcntl.F_UNLCK:
+                if l_type == fcntl.F_RDLCK:
                     return 'r', l_len, l_start, l_whence, l_pid
                 else:
                     return 'w', l_len, l_start, l_whence, l_pid