Skip to content

Commit d62ecbf

Browse files
committed
Merged revisions 85728,85731,85735,85766-85771,85773,85777 via svnmerge from
svn+ssh://svn.python.org/python/branches/py3k ........ r85728 | georg.brandl | 2010-10-19 20:54:25 +0200 (Di, 19 Okt 2010) | 1 line #10092: Properly reset locale in Locale*Calendar classes. The context manager was buggy because setlocale() returns the *new* locale, not the old. Also add a test for this. ........ r85731 | georg.brandl | 2010-10-19 23:07:16 +0200 (Di, 19 Okt 2010) | 1 line Be consistent in the spelling of thread-safe(ty). ........ r85735 | georg.brandl | 2010-10-20 08:50:19 +0200 (Mi, 20 Okt 2010) | 1 line Fix r85728: use "" to mean the system default locale, which should work on more systems. ........ r85766 | georg.brandl | 2010-10-21 09:40:03 +0200 (Do, 21 Okt 2010) | 1 line #10159: sort completion matches before comparing to dir() result. ........ r85767 | georg.brandl | 2010-10-21 14:49:28 +0200 (Do, 21 Okt 2010) | 1 line #9095, #8912, #8999: add support in patchcheck for Mercurial checkouts, C file reindenting, and docs whitespace fixing. ........ r85768 | georg.brandl | 2010-10-21 14:59:14 +0200 (Do, 21 Okt 2010) | 1 line #9919: fix off-by-one error in lineno command in Misc/gdbinit; also add newline to its output. ........ r85769 | georg.brandl | 2010-10-21 15:01:23 +0200 (Do, 21 Okt 2010) | 1 line Fix missing import. ........ r85770 | georg.brandl | 2010-10-21 15:29:10 +0200 (Do, 21 Okt 2010) | 1 line #3077: fix h2py substitution of character literals. ........ r85771 | georg.brandl | 2010-10-21 15:34:51 +0200 (Do, 21 Okt 2010) | 1 line #1203650: allow larger list of files in windows makefile for freeze. ........ r85773 | georg.brandl | 2010-10-21 15:45:52 +0200 (Do, 21 Okt 2010) | 1 line #4829: better error message for invalid file mode ........ r85777 | georg.brandl | 2010-10-21 17:44:51 +0200 (Do, 21 Okt 2010) | 1 line Add .hgeol file for the Mercurial EOL extension. ........
1 parent ab32fec commit d62ecbf

18 files changed

Lines changed: 195 additions & 80 deletions

.hgeol

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
[patterns]
2+
** = native
3+
4+
**.bat = CRLF
5+
**.def = CRLF
6+
**.dsp = CRLF
7+
**.dsw = CRLF
8+
**.mak = CRLF
9+
**.mk = CRLF
10+
**.rc = CRLF
11+
**.sln = CRLF
12+
**.vcproj = CRLF
13+
**.vsprops = CRLF
14+
15+
**.aif = BIN
16+
**.au = BIN
17+
**.bmp = BIN
18+
**.db = BIN
19+
**.exe = BIN
20+
**.icns = BIN
21+
**.gif = BIN
22+
**.ico = BIN
23+
**.info = BIN
24+
**.jpg = BIN
25+
**.pck = BIN
26+
**.png = BIN
27+
**.psd = BIN
28+
**.tar = BIN
29+
**.xar = BIN
30+
**.zip = BIN
31+
32+
Lib/email/test/data/msg_26.txt = BIN
33+
Lib/test/sndhdrdata/sndhdr.* = BIN
34+
35+
[repository]
36+
native = LF

Doc/c-api/init.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -416,7 +416,7 @@ Thread State and the Global Interpreter Lock
416416
single: interpreter lock
417417
single: lock, interpreter
418418

419-
The Python interpreter is not fully thread safe. In order to support
419+
The Python interpreter is not fully thread-safe. In order to support
420420
multi-threaded Python programs, there's a global lock, called the :dfn:`global
421421
interpreter lock` or :dfn:`GIL`, that must be held by the current thread before
422422
it can safely access Python objects. Without the lock, even the simplest

Doc/library/calendar.rst

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -170,9 +170,9 @@ it's the base calendar for all computations.
170170
.. class:: LocaleTextCalendar(firstweekday=0, locale=None)
171171

172172
This subclass of :class:`TextCalendar` can be passed a locale name in the
173-
constructor and will return month and weekday names in the specified
174-
locale. If this locale includes an encoding all strings containing month and
175-
weekday names will be returned as unicode.
173+
constructor and will return month and weekday names in the specified locale.
174+
If this locale includes an encoding all strings containing month and weekday
175+
names will be returned as unicode.
176176

177177

178178
.. class:: LocaleHTMLCalendar(firstweekday=0, locale=None)
@@ -182,6 +182,12 @@ it's the base calendar for all computations.
182182
locale. If this locale includes an encoding all strings containing month and
183183
weekday names will be returned as unicode.
184184

185+
.. note::
186+
187+
The :meth:`formatweekday` and :meth:`formatmonthname` methods of these two
188+
classes temporarily change the current locale to the given *locale*. Because
189+
the current locale is a process-wide setting, they are not thread-safe.
190+
185191

186192
For simple text calendars this module provides the following functions.
187193

Doc/library/locale.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ The :mod:`locale` module defines the following exception and functions:
3939
If *locale* is omitted or ``None``, the current setting for *category* is
4040
returned.
4141

42-
:func:`setlocale` is not thread safe on most systems. Applications typically
42+
:func:`setlocale` is not thread-safe on most systems. Applications typically
4343
start with a call of ::
4444

4545
import locale

Doc/library/multiprocessing.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ However, if you really do need to use some shared data then
214214
The ``'d'`` and ``'i'`` arguments used when creating ``num`` and ``arr`` are
215215
typecodes of the kind used by the :mod:`array` module: ``'d'`` indicates a
216216
double precision float and ``'i'`` indicates a signed integer. These shared
217-
objects will be process and thread safe.
217+
objects will be process and thread-safe.
218218

219219
For more flexibility in using shared memory one can use the
220220
:mod:`multiprocessing.sharedctypes` module which supports the creation of

Doc/library/threading.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -753,9 +753,9 @@ Currently, :class:`Lock`, :class:`RLock`, :class:`Condition`,
753753
Importing in threaded code
754754
--------------------------
755755

756-
While the import machinery is thread safe, there are two key
757-
restrictions on threaded imports due to inherent limitations in the way
758-
that thread safety is provided:
756+
While the import machinery is thread-safe, there are two key restrictions on
757+
threaded imports due to inherent limitations in the way that thread-safety is
758+
provided:
759759

760760
* Firstly, other than in the main module, an import should not have the
761761
side effect of spawning a new thread and then waiting for that thread in

Lib/calendar.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -486,8 +486,8 @@ def __init__(self, locale):
486486
self.locale = locale
487487

488488
def __enter__(self):
489-
self.oldlocale = _locale.setlocale(_locale.LC_TIME, self.locale)
490-
#return _locale.getlocale(_locale.LC_TIME)[1]
489+
self.oldlocale = _locale.getlocale(_locale.LC_TIME)
490+
_locale.setlocale(_locale.LC_TIME, self.locale)
491491

492492
def __exit__(self, *args):
493493
_locale.setlocale(_locale.LC_TIME, self.oldlocale)

Lib/test/test_calendar.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import unittest
33

44
from test import support
5+
import locale
56

67

78
result_2004_text = """
@@ -250,6 +251,19 @@ def test_months(self):
250251
# verify it "acts like a sequence" in two forms of iteration
251252
self.assertEqual(value[::-1], list(reversed(value)))
252253

254+
def test_localecalendars(self):
255+
# ensure that Locale{Text,HTML}Calendar resets the locale properly
256+
# (it is still not thread-safe though)
257+
old_october = calendar.TextCalendar().formatmonthname(2010, 10, 10)
258+
try:
259+
calendar.LocaleTextCalendar(locale='').formatmonthname(2010, 10, 10)
260+
except locale.Error:
261+
# cannot set the system default locale -- skip rest of test
262+
return
263+
calendar.LocaleHTMLCalendar(locale='').formatmonthname(2010, 10)
264+
new_october = calendar.TextCalendar().formatmonthname(2010, 10, 10)
265+
self.assertEquals(old_october, new_october)
266+
253267

254268
class MonthCalendarTestCase(unittest.TestCase):
255269
def setUp(self):

Lib/test/test_rlcompleter.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@ class B(list):
3131

3232
def test_global_matches(self):
3333
# test with builtins namespace
34-
self.assertEqual(self.stdcompleter.global_matches('di'),
34+
self.assertEqual(sorted(self.stdcompleter.global_matches('di')),
3535
[x+'(' for x in dir(builtins) if x.startswith('di')])
36-
self.assertEqual(self.stdcompleter.global_matches('st'),
36+
self.assertEqual(sorted(self.stdcompleter.global_matches('st')),
3737
[x+'(' for x in dir(builtins) if x.startswith('st')])
3838
self.assertEqual(self.stdcompleter.global_matches('akaksajadhak'), [])
3939

Misc/NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ Library
1818

1919
- Issue #10459: Update CJK character names to Unicode 5.1.
2020

21+
- Issue #10092: Properly reset locale in calendar.Locale*Calendar classes.
22+
2123
- Issue #6098: Don't claim DOM level 3 conformance in minidom.
2224

2325
- Issue #5762: Fix AttributeError raised by ``xml.dom.minidom`` when an empty

0 commit comments

Comments
 (0)