]> granicus.if.org Git - python/commitdiff
_make_boundary(): Fix for SF bug #745478, broken boundary calculation
authorBarry Warsaw <barry@python.org>
Thu, 29 May 2003 19:39:33 +0000 (19:39 +0000)
committerBarry Warsaw <barry@python.org>
Thu, 29 May 2003 19:39:33 +0000 (19:39 +0000)
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

Lib/email/Generator.py
Lib/email/__init__.py

index 9cce51c40b557b0ce81509fc3a274d6ee61732be..6f17963d0f18fc1895cc7cf0f41b080137c73488 100644 (file)
@@ -5,6 +5,7 @@
 """
 
 import re
+import sys
 import time
 import locale
 import random
@@ -356,11 +357,14 @@ class DecodedGenerator(Generator):
 
 \f
 # 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.
-    dp = locale.localeconv().get('decimal_point', '.')
-    boundary = ('=' * 15) + repr(random.random()).split(dp)[1] + '=='
+    token = random.randint(0, sys.maxint-1)
+    boundary = ('=' * 15) + (_fmt % token) + '=='
     if text is None:
         return boundary
     b = boundary
index d9462bcab568977675184c66a78419a5acad3e5a..b5d8d72eee7d9fd864dad1fde12e45ed22ed6192 100644 (file)
@@ -4,7 +4,7 @@
 """A package for parsing, handling, and generating email messages.
 """
 
-__version__ = '2.5.2'
+__version__ = '2.5.3'
 
 __all__ = [
     'base64MIME',