[Mailman-Developers] Re: tempfile bug or doc bug

Guido van Rossum guido@CNRI.Reston.VA.US
Wed, 14 Oct 1998 09:58:28 -0400


Scott,

I propose the following patch to tempfile.py, which should take care
of your problems...

Index: tempfile.py
===================================================================
RCS file: /projects/cvsroot/python/dist/src/Lib/tempfile.py,v
retrieving revision 1.15
diff -c -r1.15 tempfile.py
*** tempfile.py	1998/04/28 16:03:34	1.15
--- tempfile.py	1998/10/14 13:56:04
***************
*** 60,70 ****
  
  # Function to calculate a prefix of the filename to use
  
  def gettempprefix():
!     global template
!     if template == None:
          if os.name == 'posix':
!             template = '@' + `os.getpid()` + '.'
          elif os.name == 'nt':
              template = '~' + `os.getpid()` + '-'
          elif os.name == 'mac':
--- 60,76 ----
  
  # Function to calculate a prefix of the filename to use
  
+ _pid = None
+ 
  def gettempprefix():
!     global template, _pid
!     if os.name == 'posix' and _pid and _pid != os.getpid():
!         # Our pid changed; we must have forked -- zap the template
!         template = None
!     if template is None:
          if os.name == 'posix':
!             _pid = os.getpid()
!             template = '@' + `_pid` + '.'
          elif os.name == 'nt':
              template = '~' + `os.getpid()` + '-'
          elif os.name == 'mac':

--Guido van Rossum (home page: http://www.python.org/~guido/)