]> git.ipfire.org Git - thirdparty/babel.git/commitdiff
Escape unicode literals
authorBoris Verkhovskiy <boris.verk@gmail.com>
Thu, 16 Jan 2025 10:45:05 +0000 (03:45 -0700)
committerBoris Verkhovskiy <boris.verk@gmail.com>
Mon, 30 Jun 2025 09:22:45 +0000 (03:22 -0600)
babel/core.py
babel/dates.py
babel/numbers.py
babel/support.py

index 47e89f1518f6544c4c9c0441d60ddf86f8466f4a..17bc04236dc46388cef3492070fd173c8948f524 100644 (file)
@@ -937,7 +937,7 @@ class Locale:
                   Babel versions.
 
         >>> Locale('en', 'US').time_formats['short']
-        <DateTimePattern 'h:mm\u202fa'>
+        <DateTimePattern 'h:mm\\u202fa'>
         >>> Locale('fr', 'FR').time_formats['long']
         <DateTimePattern 'HH:mm:ss z'>
         """
@@ -981,7 +981,7 @@ class Locale:
         smallest changing component:
 
         >>> Locale('fi_FI').interval_formats['MEd']['d']
-        ['E d.\u2009–\u2009', 'E d.M.']
+        ['E d.\\u2009–\\u2009', 'E d.M.']
 
         .. seealso::
 
index 0dc98ee83a54afbcc55230648f9bdca35cf10e45..6988e5433cf862b37798682386874558ed97f8e9 100644 (file)
@@ -398,7 +398,7 @@ def get_time_format(
     format.
 
     >>> get_time_format(locale='en_US')
-    <DateTimePattern 'h:mm:ss\u202fa'>
+    <DateTimePattern 'h:mm:ss\\u202fa'>
     >>> get_time_format('full', locale='de_DE')
     <DateTimePattern 'HH:mm:ss zzzz'>
 
@@ -1057,7 +1057,7 @@ def format_interval(
     '12:12–16:16'
 
     >>> format_interval(time(5, 12), time(16, 16), "hm", locale="en_US")
-    '5:12\u202fAM\u2009–\u20094:16\u202fPM'
+    '5:12\\u202fAM\\u2009–\\u20094:16\\u202fPM'
 
     >>> format_interval(time(16, 18), time(16, 24), "Hm", locale="it")
     '16:18–16:24'
@@ -1076,7 +1076,7 @@ def format_interval(
     '16:18:00~16:24:00'
 
     >>> format_interval(date(2016, 1, 15), date(2016, 1, 17), "xxx", locale="de")
-    '15.01.2016\u2009–\u200917.01.2016'
+    '15.01.2016\\u2009–\\u200917.01.2016'
 
     :param start: First instant (datetime/date/time)
     :param end: Second instant (datetime/date/time)
index 947cc2f260b0cf76e0338f42cbeb6e77f0dd4c3e..aad1583a139cdfc5fcdc8a0e9997dad0b11b2dea 100644 (file)
@@ -376,9 +376,9 @@ def get_plus_sign_symbol(
     >>> get_plus_sign_symbol('en_US')
     '+'
     >>> get_plus_sign_symbol('ar_EG', numbering_system='default')
-    '\u061c+'
+    '\\u061c+'
     >>> get_plus_sign_symbol('ar_EG', numbering_system='latn')
-    '\u200e+'
+    '\\u200e+'
 
     :param locale: the `Locale` object or locale identifier. Defaults to the system numeric locale.
     :param numbering_system: The numbering system used for fetching the symbol. Defaults to "latn".
@@ -399,9 +399,9 @@ def get_minus_sign_symbol(
     >>> get_minus_sign_symbol('en_US')
     '-'
     >>> get_minus_sign_symbol('ar_EG', numbering_system='default')
-    '\u061c-'
+    '\\u061c-'
     >>> get_minus_sign_symbol('ar_EG', numbering_system='latn')
-    '\u200e-'
+    '\\u200e-'
 
     :param locale: the `Locale` object or locale identifier. Defaults to the system numeric locale.
     :param numbering_system: The numbering system used for fetching the symbol. Defaults to "latn".
@@ -609,7 +609,7 @@ def format_compact_decimal(
     >>> format_compact_decimal(21000000, format_type="long", locale="mk")
     '21 милион'
     >>> format_compact_decimal(12345, format_type="short", locale='ar_EG', fraction_digits=2, numbering_system='default')
-    '12٫34\xa0ألف'
+    '12٫34\\xa0ألف'
 
     :param number: the number to format
     :param format_type: Compact format to use ("short" or "long")
@@ -694,16 +694,16 @@ def format_currency(
     >>> format_currency(1099.98, 'EUR', locale='de_DE')
     '1.099,98\\xa0\\u20ac'
     >>> format_currency(1099.98, 'EGP', locale='ar_EG', numbering_system='default')
-    '\u200f1٬099٫98\xa0ج.م.\u200f'
+    '\\u200f1٬099٫98\\xa0ج.م.\\u200f'
 
     The format can also be specified explicitly.  The currency is
     placed with the '¤' sign.  As the sign gets repeated the format
     expands (¤ being the symbol, ¤¤ is the currency abbreviation and
     ¤¤¤ is the full name of the currency):
 
-    >>> format_currency(1099.98, 'EUR', '\xa4\xa4 #,##0.00', locale='en_US')
+    >>> format_currency(1099.98, 'EUR', '\\xa4\\xa4 #,##0.00', locale='en_US')
     'EUR 1,099.98'
-    >>> format_currency(1099.98, 'EUR', '#,##0.00 \xa4\xa4\xa4', locale='en_US')
+    >>> format_currency(1099.98, 'EUR', '#,##0.00 \\xa4\\xa4\\xa4', locale='en_US')
     '1,099.98 euros'
 
     Currencies usually have a specific number of decimal digits. This function
@@ -861,7 +861,7 @@ def format_compact_currency(
     >>> format_compact_currency(123456789, 'USD', locale='en_US', fraction_digits=2)
     '$123.46M'
     >>> format_compact_currency(123456789, 'EUR', locale='de_DE', fraction_digits=1)
-    '123,5\xa0Mio.\xa0€'
+    '123,5\\xa0Mio.\\xa0€'
 
     :param number: the number to format
     :param currency: the currency code
@@ -920,7 +920,7 @@ def format_percent(
 
     The format pattern can also be specified explicitly:
 
-    >>> format_percent(25.1234, '#,##0\u2030', locale='en_US')
+    >>> format_percent(25.1234, '#,##0\\u2030', locale='en_US')
     '25,123‰'
 
     By default the locale is allowed to truncate and round a high-precision
index fc0034883f84a8fdd6534c5636e02a93103d9868..24ffd069b42bc2be1d034fb131fd7c9f3932dc61 100644 (file)
@@ -92,7 +92,7 @@ class Format:
         >>> from babel.dates import get_timezone
         >>> fmt = Format('en_US', tzinfo=get_timezone('US/Eastern'))
         >>> fmt.datetime(datetime(2007, 4, 1, 15, 30))
-        'Apr 1, 2007, 11:30:00\u202fAM'
+        'Apr 1, 2007, 11:30:00\\u202fAM'
         """
         return format_datetime(datetime, format, tzinfo=self.tzinfo, locale=self.locale)
 
@@ -107,7 +107,7 @@ class Format:
         >>> from babel.dates import get_timezone
         >>> fmt = Format('en_US', tzinfo=get_timezone('US/Eastern'))
         >>> fmt.time(datetime(2007, 4, 1, 15, 30))
-        '11:30:00\u202fAM'
+        '11:30:00\\u202fAM'
         """
         return format_time(time, format, tzinfo=self.tzinfo, locale=self.locale)