Skip to content

Commit 3000762

Browse files
committed
Escape unicode literals
1 parent 5c8b75a commit 3000762

4 files changed

Lines changed: 17 additions & 17 deletions

File tree

babel/core.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -937,7 +937,7 @@ def time_formats(self) -> localedata.LocaleDataDict:
937937
Babel versions.
938938
939939
>>> Locale('en', 'US').time_formats['short']
940-
<DateTimePattern 'h:mm\u202fa'>
940+
<DateTimePattern 'h:mm\\u202fa'>
941941
>>> Locale('fr', 'FR').time_formats['long']
942942
<DateTimePattern 'HH:mm:ss z'>
943943
"""
@@ -981,7 +981,7 @@ def interval_formats(self) -> localedata.LocaleDataDict:
981981
smallest changing component:
982982
983983
>>> Locale('fi_FI').interval_formats['MEd']['d']
984-
['E d.\u2009\u2009', 'E d.M.']
984+
['E d.\\u2009–\\u2009', 'E d.M.']
985985
986986
.. seealso::
987987

babel/dates.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,7 @@ def get_time_format(
398398
format.
399399
400400
>>> get_time_format(locale='en_US')
401-
<DateTimePattern 'h:mm:ss\u202fa'>
401+
<DateTimePattern 'h:mm:ss\\u202fa'>
402402
>>> get_time_format('full', locale='de_DE')
403403
<DateTimePattern 'HH:mm:ss zzzz'>
404404
@@ -1055,7 +1055,7 @@ def format_interval(
10551055
'12:12–16:16'
10561056
10571057
>>> format_interval(time(5, 12), time(16, 16), "hm", locale="en_US")
1058-
'5:12\u202fAM\u2009\u20094:16\u202fPM'
1058+
'5:12\\u202fAM\\u2009–\\u20094:16\\u202fPM'
10591059
10601060
>>> format_interval(time(16, 18), time(16, 24), "Hm", locale="it")
10611061
'16:18–16:24'
@@ -1074,7 +1074,7 @@ def format_interval(
10741074
'16:18:00~16:24:00'
10751075
10761076
>>> format_interval(date(2016, 1, 15), date(2016, 1, 17), "xxx", locale="de")
1077-
'15.01.2016\u2009\u200917.01.2016'
1077+
'15.01.2016\\u2009–\\u200917.01.2016'
10781078
10791079
:param start: First instant (datetime/date/time)
10801080
:param end: Second instant (datetime/date/time)

babel/numbers.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -374,9 +374,9 @@ def get_plus_sign_symbol(
374374
>>> get_plus_sign_symbol('en_US')
375375
'+'
376376
>>> get_plus_sign_symbol('ar_EG', numbering_system='default')
377-
'\u061c+'
377+
'\\u061c+'
378378
>>> get_plus_sign_symbol('ar_EG', numbering_system='latn')
379-
'\u200e+'
379+
'\\u200e+'
380380
381381
:param locale: the `Locale` object or locale identifier. Defaults to the system numeric locale.
382382
:param numbering_system: The numbering system used for fetching the symbol. Defaults to "latn".
@@ -397,9 +397,9 @@ def get_minus_sign_symbol(
397397
>>> get_minus_sign_symbol('en_US')
398398
'-'
399399
>>> get_minus_sign_symbol('ar_EG', numbering_system='default')
400-
'\u061c-'
400+
'\\u061c-'
401401
>>> get_minus_sign_symbol('ar_EG', numbering_system='latn')
402-
'\u200e-'
402+
'\\u200e-'
403403
404404
:param locale: the `Locale` object or locale identifier. Defaults to the system numeric locale.
405405
:param numbering_system: The numbering system used for fetching the symbol. Defaults to "latn".
@@ -607,7 +607,7 @@ def format_compact_decimal(
607607
>>> format_compact_decimal(21000000, format_type="long", locale="mk")
608608
'21 милион'
609609
>>> format_compact_decimal(12345, format_type="short", locale='ar_EG', fraction_digits=2, numbering_system='default')
610-
'12٫34\xa0ألف'
610+
'12٫34\\xa0ألف'
611611
612612
:param number: the number to format
613613
:param format_type: Compact format to use ("short" or "long")
@@ -692,16 +692,16 @@ def format_currency(
692692
>>> format_currency(1099.98, 'EUR', locale='de_DE')
693693
'1.099,98\\xa0\\u20ac'
694694
>>> format_currency(1099.98, 'EGP', locale='ar_EG', numbering_system='default')
695-
'\u200f1٬099٫98\xa0ج.م.\u200f'
695+
'\\u200f1٬099٫98\\xa0ج.م.\\u200f'
696696
697697
The format can also be specified explicitly. The currency is
698698
placed with the '¤' sign. As the sign gets repeated the format
699699
expands (¤ being the symbol, ¤¤ is the currency abbreviation and
700700
¤¤¤ is the full name of the currency):
701701
702-
>>> format_currency(1099.98, 'EUR', '\xa4\xa4 #,##0.00', locale='en_US')
702+
>>> format_currency(1099.98, 'EUR', '\\xa4\\xa4 #,##0.00', locale='en_US')
703703
'EUR 1,099.98'
704-
>>> format_currency(1099.98, 'EUR', '#,##0.00 \xa4\xa4\xa4', locale='en_US')
704+
>>> format_currency(1099.98, 'EUR', '#,##0.00 \\xa4\\xa4\\xa4', locale='en_US')
705705
'1,099.98 euros'
706706
707707
Currencies usually have a specific number of decimal digits. This function
@@ -858,7 +858,7 @@ def format_compact_currency(
858858
>>> format_compact_currency(123456789, 'USD', locale='en_US', fraction_digits=2)
859859
'$123.46M'
860860
>>> format_compact_currency(123456789, 'EUR', locale='de_DE', fraction_digits=1)
861-
'123,5\xa0Mio.\xa0€'
861+
'123,5\\xa0Mio.\\xa0€'
862862
863863
:param number: the number to format
864864
:param currency: the currency code
@@ -916,7 +916,7 @@ def format_percent(
916916
917917
The format pattern can also be specified explicitly:
918918
919-
>>> format_percent(25.1234, '#,##0\u2030', locale='en_US')
919+
>>> format_percent(25.1234, '#,##0\\u2030', locale='en_US')
920920
'25,123‰'
921921
922922
By default the locale is allowed to truncate and round a high-precision

babel/support.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ def datetime(
9494
>>> from babel.dates import get_timezone
9595
>>> fmt = Format('en_US', tzinfo=get_timezone('US/Eastern'))
9696
>>> fmt.datetime(datetime(2007, 4, 1, 15, 30))
97-
'Apr 1, 2007, 11:30:00\u202fAM'
97+
'Apr 1, 2007, 11:30:00\\u202fAM'
9898
"""
9999
return format_datetime(datetime, format, tzinfo=self.tzinfo, locale=self.locale)
100100

@@ -109,7 +109,7 @@ def time(
109109
>>> from babel.dates import get_timezone
110110
>>> fmt = Format('en_US', tzinfo=get_timezone('US/Eastern'))
111111
>>> fmt.time(datetime(2007, 4, 1, 15, 30))
112-
'11:30:00\u202fAM'
112+
'11:30:00\\u202fAM'
113113
"""
114114
return format_time(time, format, tzinfo=self.tzinfo, locale=self.locale)
115115

0 commit comments

Comments
 (0)