Skip to content
Snippets Groups Projects
Commit 198c2961 authored by Stefano Rivera's avatar Stefano Rivera
Browse files

Patch: Add support for Python 3.11 (Closes: #1025117)

parent 9a22af1d
No related branches found
No related tags found
No related merge requests found
python-pyramid (2.0+dfsg-2) UNRELEASED; urgency=medium
* Patch: Add support for Python 3.11 (Closes: #1025117)
-- Stefano Rivera <stefanor@debian.org> Sun, 25 Dec 2022 14:24:19 -0400
python-pyramid (2.0+dfsg-1) unstable; urgency=medium
[ Chris Lamb ]
......
From: Stefano Rivera <stefano@rivera.za.net>
Date: Sun, 25 Dec 2022 13:42:29 -0400
Subject: Drop support for l*gettext() from pyramid.i18n on Python >= 3.11
Python 3.8 deprecated l*gettext() (bpo-33710), and it was removed from Python in
3.11 (bpo-44235). In most cases on Python 3, the l variants aren't
useful, and difficult to use correctly.
This adds support for Python 3.11.
Bug-Debian: https://bugs.debian.org/1025117
Forwarded: https://github.com/Pylons/pyramid/pull/3717
---
src/pyramid/i18n.py | 29 +++++++++++++++++------------
tests/test_i18n.py | 3 +++
2 files changed, 20 insertions(+), 12 deletions(-)
diff --git a/src/pyramid/i18n.py b/src/pyramid/i18n.py
index 793b250..42cb9bf 100644
--- a/src/pyramid/i18n.py
+++ b/src/pyramid/i18n.py
@@ -1,5 +1,6 @@
import gettext
import os
+import sys
from translationstring import Pluralizer, Translator
from translationstring import TranslationString # API
from translationstring import TranslationStringFactory # API
@@ -335,12 +336,6 @@ class Translations(gettext.GNUTranslations):
"""
return self._domains.get(domain, self).gettext(message)
- def ldgettext(self, domain, message):
- """Like ``lgettext()``, but look the message up in the specified
- domain.
- """
- return self._domains.get(domain, self).lgettext(message)
-
def dugettext(self, domain, message):
"""Like ``ugettext()``, but look the message up in the specified
domain.
@@ -353,18 +348,28 @@ class Translations(gettext.GNUTranslations):
"""
return self._domains.get(domain, self).ngettext(singular, plural, num)
- def ldngettext(self, domain, singular, plural, num):
- """Like ``lngettext()``, but look the message up in the specified
- domain.
- """
- return self._domains.get(domain, self).lngettext(singular, plural, num)
-
def dungettext(self, domain, singular, plural, num):
"""Like ``ungettext()`` but look the message up in the specified
domain.
"""
return self._domains.get(domain, self).ngettext(singular, plural, num)
+ if sys.version_info < (3, 11):
+
+ def ldgettext(self, domain, message):
+ """Like ``lgettext()``, but look the message up in the specified
+ domain.
+ """
+ return self._domains.get(domain, self).lgettext(message)
+
+ def ldngettext(self, domain, singular, plural, num):
+ """Like ``lngettext()``, but look the message up in the specified
+ domain.
+ """
+ return self._domains.get(domain, self).lngettext(
+ singular, plural, num
+ )
+
class LocalizerRequestMixin:
@reify
diff --git a/tests/test_i18n.py b/tests/test_i18n.py
index 206eea2..01c4271 100644
--- a/tests/test_i18n.py
+++ b/tests/test_i18n.py
@@ -1,5 +1,6 @@
import os
import unittest
+import sys
from pyramid import testing
@@ -421,6 +422,7 @@ class TestTranslations(unittest.TestCase):
self.assertEqual(t.dgettext('messages', 'foo'), 'Voh')
self.assertEqual(t.dgettext('messages1', 'foo'), 'VohD')
+ @unittest.skipIf(sys.version_info >= (3, 11), 'droppd in 3.11')
def test_ldgettext(self):
t = self._makeOne()
self.assertEqual(t.ldgettext('messages', 'foo'), b'Voh')
@@ -436,6 +438,7 @@ class TestTranslations(unittest.TestCase):
self.assertEqual(t.dngettext('messages', 'foo1', 'foos1', 1), 'Voh1')
self.assertEqual(t.dngettext('messages1', 'foo1', 'foos1', 1), 'VohD1')
+ @unittest.skipIf(sys.version_info >= (3, 11), 'droppd in 3.11')
def test_ldngettext(self):
t = self._makeOne()
self.assertEqual(t.ldngettext('messages', 'foo1', 'foos1', 1), b'Voh1')
python-3.11
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment