[Python-checkins] python/dist/src/Lib/email Generator.py,1.19,1.20 __init__.py,1.28,1.29

bwarsaw@users.sourceforge.net bwarsaw@users.sourceforge.net
Thu, 29 May 2003 12:39:37 -0700


Update of /cvsroot/python/python/dist/src/Lib/email
In directory sc8-pr-cvs1:/tmp/cvs-serv20867/Lib/email

Modified Files:
	Generator.py __init__.py 
Log Message:
_make_boundary(): Fix for SF bug #745478, broken boundary calculation
in some locales.  This code simplifies the boundary algorithm to use
randint() which is what we wanted anyway.

Bump package version to 2.5.3.

Backport candidate for Python 2.2.3


Index: Generator.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/email/Generator.py,v
retrieving revision 1.19
retrieving revision 1.20
diff -C2 -d -r1.19 -r1.20
*** Generator.py	7 Mar 2003 15:43:17 -0000	1.19
--- Generator.py	29 May 2003 19:39:33 -0000	1.20
***************
*** 6,9 ****
--- 6,10 ----
  
  import re
+ import sys
  import time
  import locale
***************
*** 357,365 ****
  
  # Helper
  def _make_boundary(text=None):
      # Craft a random boundary.  If text is given, ensure that the chosen
      # boundary doesn't appear in the text.
!     dp = locale.localeconv().get('decimal_point', '.')
!     boundary = ('=' * 15) + repr(random.random()).split(dp)[1] + '=='
      if text is None:
          return boundary
--- 358,369 ----
  
  # Helper
+ _width = len(repr(sys.maxint-1))
+ _fmt = '%%0%dd' % _width
+ 
  def _make_boundary(text=None):
      # Craft a random boundary.  If text is given, ensure that the chosen
      # boundary doesn't appear in the text.
!     token = random.randint(0, sys.maxint-1)
!     boundary = ('=' * 15) + (_fmt % token) + '=='
      if text is None:
          return boundary

Index: __init__.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/email/__init__.py,v
retrieving revision 1.28
retrieving revision 1.29
diff -C2 -d -r1.28 -r1.29
*** __init__.py	8 May 2003 03:34:58 -0000	1.28
--- __init__.py	29 May 2003 19:39:33 -0000	1.29
***************
*** 5,9 ****
  """
  
! __version__ = '2.5.2'
  
  __all__ = [
--- 5,9 ----
  """
  
! __version__ = '2.5.3'
  
  __all__ = [