Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
6108bf5e
Commit
6108bf5e
authored
Oct 04, 2010
by
Éric Araujo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix interaction of custom translation classes and caching (#9042)
parent
70176169
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
35 additions
and
1 deletion
+35
-1
Lib/gettext.py
Lib/gettext.py
+1
-1
Lib/test/test_gettext.py
Lib/test/test_gettext.py
+31
-0
Misc/NEWS
Misc/NEWS
+3
-0
No files found.
Lib/gettext.py
View file @
6108bf5e
...
...
@@ -419,7 +419,7 @@ def translation(domain, localedir=None, languages=None,
# once.
result
=
None
for
mofile
in
mofiles
:
key
=
os
.
path
.
abspath
(
mofile
)
key
=
(
class_
,
os
.
path
.
abspath
(
mofile
)
)
t
=
_translations
.
get
(
key
)
if
t
is
None
:
with
open
(
mofile
,
'rb'
)
as
fp
:
...
...
Lib/test/test_gettext.py
View file @
6108bf5e
...
...
@@ -335,6 +335,37 @@ class WeirdMetadataTest(GettextBaseTest):
'John Doe <jdoe@example.com>
\
n
Jane Foobar <jfoobar@example.com>'
)
class
DummyGNUTranslations
(
gettext
.
GNUTranslations
):
def
foo
(
self
):
return
'foo'
class
GettextCacheTestCase
(
GettextBaseTest
):
def
test_cache
(
self
):
self
.
localedir
=
os
.
curdir
self
.
mofile
=
MOFILE
self
.
assertEqual
(
len
(
gettext
.
_translations
),
0
)
t
=
gettext
.
translation
(
'gettext'
,
self
.
localedir
)
self
.
assertEqual
(
len
(
gettext
.
_translations
),
1
)
t
=
gettext
.
translation
(
'gettext'
,
self
.
localedir
,
class_
=
DummyGNUTranslations
)
self
.
assertEqual
(
len
(
gettext
.
_translations
),
2
)
self
.
assertEqual
(
t
.
__class__
,
DummyGNUTranslations
)
# Calling it again doesn't add to the cache
t
=
gettext
.
translation
(
'gettext'
,
self
.
localedir
,
class_
=
DummyGNUTranslations
)
self
.
assertEqual
(
len
(
gettext
.
_translations
),
2
)
self
.
assertEqual
(
t
.
__class__
,
DummyGNUTranslations
)
def
test_main
():
support
.
run_unittest
(
__name__
)
...
...
Misc/NEWS
View file @
6108bf5e
...
...
@@ -88,6 +88,9 @@ Core and Builtins
Library
-------
- Issue #9042: Fix interaction of custom translation classes and caching in
gettext.
- Issue 6706: asyncore.dispatcher now provides a handle_accepted() method
returning a (sock, addr) pair which is called when a connection has been
established with a new remote endpoint. This is supposed to be used as a
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment