mirror of
https://github.com/python/cpython.git
synced 2025-08-03 16:39:00 +00:00
_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
This commit is contained in:
parent
65f8cedd4a
commit
db6888b7df
2 changed files with 7 additions and 3 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue