[Python-checkins] CVS: python/dist/src/Lib asyncore.py,1.12,1.13 posixfile.py,1.20,1.21

Fred L. Drake fdrake@users.sourceforge.net
Thu, 10 May 2001 08:33:33 -0700


Update of /cvsroot/python/python/dist/src/Lib
In directory usw-pr-cvs1:/tmp/cvs-serv20268

Modified Files:
	asyncore.py posixfile.py 
Log Message:

Remove all remaining uses of the FCNTL module from the standard library.


Index: asyncore.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/asyncore.py,v
retrieving revision 1.12
retrieving revision 1.13
diff -C2 -r1.12 -r1.13
*** asyncore.py	2001/05/02 05:54:44	1.12
--- asyncore.py	2001/05/10 15:33:31	1.13
***************
*** 511,515 ****
  if os.name == 'posix':
      import fcntl
-     import FCNTL
  
      class file_wrapper:
--- 511,514 ----
***************
*** 539,545 ****
              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)
              self.set_file (fd)
  
--- 538,544 ----
              self.connected = 1
              # set it to non-blocking mode
!             flags = fcntl.fcntl (fd, fcntl.F_GETFL, 0)
!             flags = flags | os.O_NONBLOCK
!             fcntl.fcntl (fd, fcntl.F_SETFL, flags)
              self.set_file (fd)
  

Index: posixfile.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/posixfile.py,v
retrieving revision 1.20
retrieving revision 1.21
diff -C2 -r1.20 -r1.21
*** posixfile.py	2001/04/10 15:44:33	1.20
--- posixfile.py	2001/05/10 15:33:31	1.21
***************
*** 108,112 ****
  
      def flags(self, *which):
!         import fcntl, FCNTL
  
          if which:
--- 108,112 ----
  
      def flags(self, *which):
!         import fcntl
  
          if which:
***************
*** 117,158 ****
  
          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
  
          file = self._file_
  
          if '=' not in which:
!             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)
  
          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)
  
          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:
                  which = which + 'c'
!             if FCNTL.O_NDELAY & l_flags: which = which + 'n'
!             if FCNTL.O_SYNC & l_flags: which = which + 's'
              return which
  
      def lock(self, how, *args):
!         import struct, fcntl, 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
          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
  
          l_whence = 0
--- 117,158 ----
  
          l_flags = 0
!         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)
              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)
  
          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)
  
          if '?' in which:
              which = ''                  # Return current flags
!             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 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
  
!         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
  
          l_whence = 0
***************
*** 204,209 ****
                      struct.unpack('hhllhh', flock)
  
!             if l_type != FCNTL.F_UNLCK:
!                 if l_type == FCNTL.F_RDLCK:
                      return 'r', l_len, l_start, l_whence, l_pid
                  else:
--- 204,209 ----
                      struct.unpack('hhllhh', flock)
  
!             if l_type != fcntl.F_UNLCK:
!                 if l_type == fcntl.F_RDLCK:
                      return 'r', l_len, l_start, l_whence, l_pid
                  else: