Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 250075
Collapse All | Expand All

(-)Python-2.5.2.orig/Lib/decimal.py (-1 / +8 lines)
Lines 146-151 Link Here
146
ROUND_HALF_DOWN = 'ROUND_HALF_DOWN'
146
ROUND_HALF_DOWN = 'ROUND_HALF_DOWN'
147
ROUND_05UP = 'ROUND_05UP'
147
ROUND_05UP = 'ROUND_05UP'
148
148
149
import string
150
151
def ascii_upper(s):
152
    trans_table = string.maketrans(string.ascii_lowercase, string.ascii_uppercase)
153
    return s.translate(trans_table)
154
155
149
# Errors
156
# Errors
150
157
151
class DecimalException(ArithmeticError):
158
class DecimalException(ArithmeticError):
Lines 3354-3360 Link Here
3354
                                    if name.startswith('_round_')]
3361
                                    if name.startswith('_round_')]
3355
for name in rounding_functions:
3362
for name in rounding_functions:
3356
    # name is like _round_half_even, goes to the global ROUND_HALF_EVEN value.
3363
    # name is like _round_half_even, goes to the global ROUND_HALF_EVEN value.
3357
    globalname = name[1:].upper()
3364
    globalname = ascii_upper(name[1:])
3358
    val = globals()[globalname]
3365
    val = globals()[globalname]
3359
    Decimal._pick_rounding_function[val] = name
3366
    Decimal._pick_rounding_function[val] = name
3360
3367
(-)Python-2.5.2.orig/Lib/email/__init__.py (-2 / +5 lines)
Lines 109-123 Link Here
109
    'Text',
109
    'Text',
110
    ]
110
    ]
111
111
112
import string
113
lower_map = string.maketrans(string.ascii_uppercase, string.ascii_lowercase)
114
112
for _name in _LOWERNAMES:
115
for _name in _LOWERNAMES:
113
    importer = LazyImporter(_name.lower())
116
    importer = LazyImporter(_name.translate(lower_map))
114
    sys.modules['email.' + _name] = importer
117
    sys.modules['email.' + _name] = importer
115
    setattr(sys.modules['email'], _name, importer)
118
    setattr(sys.modules['email'], _name, importer)
116
119
117
120
118
import email.mime
121
import email.mime
119
for _name in _MIMENAMES:
122
for _name in _MIMENAMES:
120
    importer = LazyImporter('mime.' + _name.lower())
123
    importer = LazyImporter('mime.' + _name.translate(lower_map))
121
    sys.modules['email.MIME' + _name] = importer
124
    sys.modules['email.MIME' + _name] = importer
122
    setattr(sys.modules['email'], 'MIME' + _name, importer)
125
    setattr(sys.modules['email'], 'MIME' + _name, importer)
123
    setattr(sys.modules['email.mime'], _name, importer)
126
    setattr(sys.modules['email.mime'], _name, importer)
(-)Python-2.5.2.orig/Lib/locale.py (-1 / +10 lines)
Lines 278-283 Link Here
278
# overridden below)
278
# overridden below)
279
_setlocale = setlocale
279
_setlocale = setlocale
280
280
281
# Avoid relying on the locale-dependent .lower() method
282
# (see bug #1813).
283
_ascii_lower_map = ''.join(
284
    chr(x + 32 if x >= ord('A') and x <= ord('Z') else x)
285
    for x in range(256)
286
)
287
288
289
281
def normalize(localename):
290
def normalize(localename):
282
291
283
    """ Returns a normalized locale code for the given locale
292
    """ Returns a normalized locale code for the given locale
Lines 295-301 Link Here
295
304
296
    """
305
    """
297
    # Normalize the locale name and extract the encoding
306
    # Normalize the locale name and extract the encoding
298
    fullname = localename.lower()
307
    fullname = localename.translate(_ascii_lower_map)
299
    if ':' in fullname:
308
    if ':' in fullname:
300
        # ':' is sometimes used as encoding delimiter.
309
        # ':' is sometimes used as encoding delimiter.
301
        fullname = fullname.replace(':', '.')
310
        fullname = fullname.replace(':', '.')
(-)Python-2.5.2.orig/Lib/test/test_codecs.py (+11 lines)
Lines 1-6 Link Here
1
from __future__ import with_statement
1
from __future__ import with_statement
2
from test import test_support
2
from test import test_support
3
import unittest
3
import unittest
4
import locale
4
import codecs
5
import codecs
5
import sys, StringIO, _testcapi
6
import sys, StringIO, _testcapi
6
7
Lines 938-943 Link Here
938
        self.assertRaises(LookupError, codecs.lookup, "__spam__")
939
        self.assertRaises(LookupError, codecs.lookup, "__spam__")
939
        self.assertRaises(LookupError, codecs.lookup, " ")
940
        self.assertRaises(LookupError, codecs.lookup, " ")
940
941
942
    def test_lookup_with_locale(self):
943
        # Bug #1813: when normalizing codec name, lowercasing must be locale
944
        # agnostic, otherwise the looked up codec name might end up wrong.
945
        try:
946
            locale.setlocale(locale.LC_CTYPE, 'tr')
947
        except locale.Error:
948
            # SKIPped test
949
            return
950
        codecs.lookup('ISO8859_1')
951
941
    def test_getencoder(self):
952
    def test_getencoder(self):
942
        self.assertRaises(TypeError, codecs.getencoder)
953
        self.assertRaises(TypeError, codecs.getencoder)
943
        self.assertRaises(LookupError, codecs.getencoder, "__spam__")
954
        self.assertRaises(LookupError, codecs.getencoder, "__spam__")
(-)Python-2.5.2.orig/Python/codecs.c (-1 / +7 lines)
Lines 45-50 Link Here
45
    return -1;
45
    return -1;
46
}
46
}
47
47
48
/* isupper() forced into the ASCII Locale */
49
#define ascii_isupper(x) (((x) >= 0x41) && ((x) <= 0x5A))
50
/* tolower() forced into the ASCII Locale */
51
#define ascii_tolower(x) (ascii_isupper(x) ? ((x) + 0x20) : (x))
52
53
48
/* Convert a string to a normalized Python string: all characters are
54
/* Convert a string to a normalized Python string: all characters are
49
   converted to lower case, spaces are replaced with underscores. */
55
   converted to lower case, spaces are replaced with underscores. */
50
56
Lines 70-76 Link Here
70
        if (ch == ' ')
76
        if (ch == ' ')
71
            ch = '-';
77
            ch = '-';
72
        else
78
        else
73
            ch = tolower(Py_CHARMASK(ch));
79
            ch = ascii_tolower(Py_CHARMASK(ch));
74
	p[i] = ch;
80
	p[i] = ch;
75
    }
81
    }
76
    return v;
82
    return v;

Return to bug 250075