summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBarry Warsaw <barry@python.org>2003-05-29 19:39:33 +0000
committerBarry Warsaw <barry@python.org>2003-05-29 19:39:33 +0000
commitdb6888b7dfa25e2b298f6e419673f137fdcce347 (patch)
tree9996c27cf14bfc0e6f9e1956813f2bb92c61c32b
parent65f8cedd4a9820e5d069ece0194b7da0b1e4e33c (diff)
downloadcpython-git-db6888b7dfa25e2b298f6e419673f137fdcce347.tar.gz
_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
-rw-r--r--Lib/email/Generator.py8
-rw-r--r--Lib/email/__init__.py2
2 files changed, 7 insertions, 3 deletions
diff --git a/Lib/email/Generator.py b/Lib/email/Generator.py
index 9cce51c40b..6f17963d0f 100644
--- a/Lib/email/Generator.py
+++ b/Lib/email/Generator.py
@@ -5,6 +5,7 @@
"""
import re
+import sys
import time
import locale
import random
@@ -356,11 +357,14 @@ class DecodedGenerator(Generator):
# 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
diff --git a/Lib/email/__init__.py b/Lib/email/__init__.py
index d9462bcab5..b5d8d72eee 100644
--- a/Lib/email/__init__.py
+++ b/Lib/email/__init__.py
@@ -4,7 +4,7 @@
"""A package for parsing, handling, and generating email messages.
"""
-__version__ = '2.5.2'
+__version__ = '2.5.3'
__all__ = [
'base64MIME',