Repository: Pylons/pyramid

Issue:
gettext related deprecation warnings 

## Bug Report


**Describe the bug**

Several gettext related functions that are from Python 2 were deprecated in Python 3.8 and were set for removal in Python 3.10 . But these were not removed in Python 3.10 but it will be good to fix them. Straightforward replacement is not possible since the pyramid APIs return bytes and the replacements return string. 

**To Reproduce**

```
PYTHONWARNINGS=always tox -e py39 tests/test_i18n.py
GLOB sdist-make: /home/karthikeyan/stuff/python/pyramid/setup.py
py39 inst-nodeps: /home/karthikeyan/stuff/python/pyramid/.tox/.tmp/package/1/pyramid-2.1.dev0.zip
py39 installed: attrs==21.2.0,beautifulsoup4==4.9.3,coverage==5.5,hupper==1.10.3,iniconfig==1.1.1,packaging==21.0,PasteDeploy==2.1.1,plaster==1.0,plaster-pastedeploy==0.7,pluggy==0.13.1,py==1.10.0,pyparsing==2.4.7,pyramid @ file:///home/karthikeyan/stuff/python/pyramid/.tox/.tmp/package/1/pyramid-2.1.dev0.zip,pytest==6.2.4,pytest-cov==2.12.1,soupsieve==2.2.1,toml==0.10.2,translationstring==1.4,venusian==3.0.0,waitress==2.0.0,WebOb==1.8.7,WebTest==3.0.0,zope.component==5.0.1,zope.deprecation==4.4.0,zope.event==4.5.0,zope.hookable==5.1.0,zope.interface==5.4.0
py39 run-test-pre: PYTHONHASHSEED='2877923452'
py39 run-test: commands[0] | python --version
Python 3.9.5
py39 run-test: commands[1] | pytest tests/test_i18n.py
============================== test session starts ===============================
platform linux -- Python 3.9.5, pytest-6.2.4, py-1.10.0, pluggy-0.13.1
cachedir: .tox/py39/.pytest_cache
rootdir: /home/karthikeyan/stuff/python/pyramid, configfile: setup.cfg
plugins: cov-2.12.1
collected 46 items                                                               

tests/test_i18n.py ..............................................          [100%]

================================ warnings summary ================================
tests/test_i18n.py::TestTranslations::test_ldgettext
tests/test_i18n.py::TestTranslations::test_ldgettext
  /home/karthikeyan/stuff/python/pyramid/.tox/py39/lib/python3.9/site-packages/pyramid/i18n.py:342: DeprecationWarning: lgettext() is deprecated, use gettext() instead
    return self._domains.get(domain, self).lgettext(message)

tests/test_i18n.py::TestTranslations::test_ldngettext
tests/test_i18n.py::TestTranslations::test_ldngettext
  /home/karthikeyan/stuff/python/pyramid/.tox/py39/lib/python3.9/site-packages/pyramid/i18n.py:360: DeprecationWarning: lngettext() is deprecated, use ngettext() instead
    return self._domains.get(domain, self).lngettext(singular, plural, num)

-- Docs: https://docs.pytest.org/en/stable/warnings.html
========================= 46 passed, 4 warnings in 0.27s =========================
____________________________________ summary _____________________________________
  py39: commands succeeded
  congratulations :)
```

**Expected behavior**
A clear and concise description of what you expected to happen.

**Screenshots**
If applicable, add screenshots to help explain the issue.

**Additional context**

https://github.com/python/cpython/pull/10139



Discussion:
@tirkarthi thank you for the report. I agree. Would you please submit a PR for review?
I haven't verified but it feels like this will require changes to translationstring as well.
A quick search indicates that [translationstring uses only `gettext`](https://github.com/Pylons/translationstring/search?q=gettext).
It looks like these were actually removed [in Python 3.11](https://docs.python.org/3.11/whatsnew/3.11.html). Fedora Linux has a [downstream bug](https://bugzilla.redhat.com/show_bug.cgi?id=2078518) about this.

Resolving patch:
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -78,6 +78,7 @@ def readfile(name):
         "Programming Language :: Python :: 3.8",
         "Programming Language :: Python :: 3.9",
         "Programming Language :: Python :: 3.10",
+        "Programming Language :: Python :: 3.11",
         "Programming Language :: Python :: Implementation :: CPython",
         "Programming Language :: Python :: Implementation :: PyPy",
         "Framework :: Pyramid",
diff --git a/src/pyramid/i18n.py b/src/pyramid/i18n.py
--- a/src/pyramid/i18n.py
+++ b/src/pyramid/i18n.py
@@ -335,12 +335,6 @@ def dgettext(self, domain, message):
         """
         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,12 +347,6 @@ def dngettext(self, domain, singular, plural, num):
         """
         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.


Test patch:
diff --git a/tests/test_i18n.py b/tests/test_i18n.py
--- a/tests/test_i18n.py
+++ b/tests/test_i18n.py
@@ -421,11 +421,6 @@ def test_dgettext(self):
         self.assertEqual(t.dgettext('messages', 'foo'), 'Voh')
         self.assertEqual(t.dgettext('messages1', 'foo'), 'VohD')
 
-    def test_ldgettext(self):
-        t = self._makeOne()
-        self.assertEqual(t.ldgettext('messages', 'foo'), b'Voh')
-        self.assertEqual(t.ldgettext('messages1', 'foo'), b'VohD')
-
     def test_dugettext(self):
         t = self._makeOne()
         self.assertEqual(t.dugettext('messages', 'foo'), 'Voh')
@@ -436,13 +431,6 @@ def test_dngettext(self):
         self.assertEqual(t.dngettext('messages', 'foo1', 'foos1', 1), 'Voh1')
         self.assertEqual(t.dngettext('messages1', 'foo1', 'foos1', 1), 'VohD1')
 
-    def test_ldngettext(self):
-        t = self._makeOne()
-        self.assertEqual(t.ldngettext('messages', 'foo1', 'foos1', 1), b'Voh1')
-        self.assertEqual(
-            t.ldngettext('messages1', 'foo1', 'foos1', 1), b'VohD1'
-        )
-
     def test_dungettext(self):
         t = self._makeOne()
         self.assertEqual(t.dungettext('messages', 'foo1', 'foos1', 1), 'Voh1')