File: min-gettext-optparse.diff

package info (click to toggle)
python3.14 3.14.0-5
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 169,680 kB
  • sloc: python: 751,968; ansic: 717,163; xml: 31,250; sh: 5,989; cpp: 4,063; makefile: 1,995; objc: 787; lisp: 502; javascript: 136; asm: 75; csh: 12
file content (30 lines) | stat: -rw-r--r-- 799 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
Description: Debian: Degrade optparse gracefully without gettext
 python3.X-minimal includes optparse but not gettext. Use a fallback noop
 gettext, if it can't be imported.

Forwarded: not-needed

--- a/Lib/optparse.py
+++ b/Lib/optparse.py
@@ -74,7 +74,20 @@
 """
 
 import sys, os
-from gettext import gettext as _, ngettext
+try:
+    from gettext import gettext as _, ngettext
+except ImportError:
+    # Debian shims, only used by python3.X-minimal when the full stdlib is not
+    # installed
+    def gettext(message):
+        return message
+    _ = gettext  # avoid the definition above looking like a translated string
+    del gettext
+    def ngettext(singular,plural,n):
+        if n == 1:
+            return singular
+        else:
+            return plural
 
 
 def _repr(self):