Skip to content

Commit 57e6a1a

Browse files
committed
Escape unicode literals
1 parent f170ee3 commit 57e6a1a

File tree

4 files changed

+17
-17
lines changed

4 files changed

+17
-17
lines changed

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
@@ -1057,7 +1057,7 @@ def format_interval(
10571057
'12:12–16:16'
10581058
10591059
>>> format_interval(time(5, 12), time(16, 16), "hm", locale="en_US")
1060-
'5:12\u202fAM\u2009\u20094:16\u202fPM'
1060+
'5:12\\u202fAM\\u2009–\\u20094:16\\u202fPM'
10611061
10621062
>>> format_interval(time(16, 18), time(16, 24), "Hm", locale="it")
10631063
'16:18–16:24'
@@ -1076,7 +1076,7 @@ def format_interval(
10761076
'16:18:00~16:24:00'
10771077
10781078
>>> format_interval(date(2016, 1, 15), date(2016, 1, 17), "xxx", locale="de")
1079-
'15.01.2016\u2009\u200917.01.2016'
1079+
'15.01.2016\\u2009–\\u200917.01.2016'
10801080
10811081
:param start: First instant (datetime/date/time)
10821082
:param end: Second instant (datetime/date/time)

babel/numbers.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -376,9 +376,9 @@ def get_plus_sign_symbol(
376376
>>> get_plus_sign_symbol('en_US')
377377
'+'
378378
>>> get_plus_sign_symbol('ar_EG', numbering_system='default')
379-
'\u061c+'
379+
'\\u061c+'
380380
>>> get_plus_sign_symbol('ar_EG', numbering_system='latn')
381-
'\u200e+'
381+
'\\u200e+'
382382
383383
:param locale: the `Locale` object or locale identifier. Defaults to the system numeric locale.
384384
:param numbering_system: The numbering system used for fetching the symbol. Defaults to "latn".
@@ -399,9 +399,9 @@ def get_minus_sign_symbol(
399399
>>> get_minus_sign_symbol('en_US')
400400
'-'
401401
>>> get_minus_sign_symbol('ar_EG', numbering_system='default')
402-
'\u061c-'
402+
'\\u061c-'
403403
>>> get_minus_sign_symbol('ar_EG', numbering_system='latn')
404-
'\u200e-'
404+
'\\u200e-'
405405
406406
:param locale: the `Locale` object or locale identifier. Defaults to the system numeric locale.
407407
:param numbering_system: The numbering system used for fetching the symbol. Defaults to "latn".
@@ -609,7 +609,7 @@ def format_compact_decimal(
609609
>>> format_compact_decimal(21000000, format_type="long", locale="mk")
610610
'21 милион'
611611
>>> format_compact_decimal(12345, format_type="short", locale='ar_EG', fraction_digits=2, numbering_system='default')
612-
'12٫34\xa0ألف'
612+
'12٫34\\xa0ألف'
613613
614614
:param number: the number to format
615615
:param format_type: Compact format to use ("short" or "long")
@@ -694,16 +694,16 @@ def format_currency(
694694
>>> format_currency(1099.98, 'EUR', locale='de_DE')
695695
'1.099,98\\xa0\\u20ac'
696696
>>> format_currency(1099.98, 'EGP', locale='ar_EG', numbering_system='default')
697-
'\u200f1٬099٫98\xa0ج.م.\u200f'
697+
'\\u200f1٬099٫98\\xa0ج.م.\\u200f'
698698
699699
The format can also be specified explicitly. The currency is
700700
placed with the '¤' sign. As the sign gets repeated the format
701701
expands (¤ being the symbol, ¤¤ is the currency abbreviation and
702702
¤¤¤ is the full name of the currency):
703703
704-
>>> format_currency(1099.98, 'EUR', '\xa4\xa4 #,##0.00', locale='en_US')
704+
>>> format_currency(1099.98, 'EUR', '\\xa4\\xa4 #,##0.00', locale='en_US')
705705
'EUR 1,099.98'
706-
>>> format_currency(1099.98, 'EUR', '#,##0.00 \xa4\xa4\xa4', locale='en_US')
706+
>>> format_currency(1099.98, 'EUR', '#,##0.00 \\xa4\\xa4\\xa4', locale='en_US')
707707
'1,099.98 euros'
708708
709709
Currencies usually have a specific number of decimal digits. This function
@@ -861,7 +861,7 @@ def format_compact_currency(
861861
>>> format_compact_currency(123456789, 'USD', locale='en_US', fraction_digits=2)
862862
'$123.46M'
863863
>>> format_compact_currency(123456789, 'EUR', locale='de_DE', fraction_digits=1)
864-
'123,5\xa0Mio.\xa0€'
864+
'123,5\\xa0Mio.\\xa0€'
865865
866866
:param number: the number to format
867867
:param currency: the currency code
@@ -920,7 +920,7 @@ def format_percent(
920920
921921
The format pattern can also be specified explicitly:
922922
923-
>>> format_percent(25.1234, '#,##0\u2030', locale='en_US')
923+
>>> format_percent(25.1234, '#,##0\\u2030', locale='en_US')
924924
'25,123‰'
925925
926926
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
@@ -92,7 +92,7 @@ def datetime(
9292
>>> from babel.dates import get_timezone
9393
>>> fmt = Format('en_US', tzinfo=get_timezone('US/Eastern'))
9494
>>> fmt.datetime(datetime(2007, 4, 1, 15, 30))
95-
'Apr 1, 2007, 11:30:00\u202fAM'
95+
'Apr 1, 2007, 11:30:00\\u202fAM'
9696
"""
9797
return format_datetime(datetime, format, tzinfo=self.tzinfo, locale=self.locale)
9898

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

0 commit comments

Comments
 (0)