sync some patches from community
This commit is contained in:
parent
990245bf8e
commit
fb7fdfeb3f
61
Introduce-invariant-that-_invalid_pofile-takes-unico.patch
Normal file
61
Introduce-invariant-that-_invalid_pofile-takes-unico.patch
Normal file
@ -0,0 +1,61 @@
|
||||
From f4f6653e6aa053724d2c6dc0ee71dcb928013352 Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Niklas=20Hamb=C3=BCchen?= <mail@nh2.me>
|
||||
Date: Tue, 28 Jan 2020 02:46:25 +0100
|
||||
Subject: [PATCH] Introduce invariant that _invalid_pofile() takes unicode
|
||||
line.
|
||||
|
||||
This makes debugging and reasoning about the code easier;
|
||||
otherwise it is surprising that sometimes `line` is a unicode
|
||||
and sometimes not.
|
||||
|
||||
So far, when it was not, it could either be only `""` or
|
||||
`'Algo esta mal'`; thus this commit makes those two u"" strings.
|
||||
In all other cases, it was guaranteed that it's unicode,
|
||||
because all code paths leading to `_invalid_pofile()` went through
|
||||
|
||||
if not isinstance(line, text_type):
|
||||
line = line.decode(self.catalog.charset)
|
||||
|
||||
before.
|
||||
---
|
||||
babel/messages/pofile.py | 3 ++-
|
||||
tests/messages/test_pofile.py | 2 +-
|
||||
2 files changed, 3 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/babel/messages/pofile.py b/babel/messages/pofile.py
|
||||
index 93b0697..f6771be 100644
|
||||
--- a/babel/messages/pofile.py
|
||||
+++ b/babel/messages/pofile.py
|
||||
@@ -178,7 +178,7 @@ class PoFileParser(object):
|
||||
string = ['' for _ in range(self.catalog.num_plurals)]
|
||||
for idx, translation in self.translations:
|
||||
if idx >= self.catalog.num_plurals:
|
||||
- self._invalid_pofile("", self.offset, "msg has more translations than num_plurals of catalog")
|
||||
+ self._invalid_pofile(u"", self.offset, "msg has more translations than num_plurals of catalog")
|
||||
continue
|
||||
string[idx] = translation.denormalize()
|
||||
string = tuple(string)
|
||||
@@ -319,6 +319,7 @@ class PoFileParser(object):
|
||||
self._add_message()
|
||||
|
||||
def _invalid_pofile(self, line, lineno, msg):
|
||||
+ assert isinstance(line, text_type)
|
||||
if self.abort_invalid:
|
||||
raise PoFileError(msg, self.catalog, line, lineno)
|
||||
print("WARNING:", msg)
|
||||
diff --git a/tests/messages/test_pofile.py b/tests/messages/test_pofile.py
|
||||
index e77fa6e..214ddf5 100644
|
||||
--- a/tests/messages/test_pofile.py
|
||||
+++ b/tests/messages/test_pofile.py
|
||||
@@ -480,7 +480,7 @@ msgstr[2] "Vohs [text]"
|
||||
def test_invalid_pofile_with_abort_flag(self):
|
||||
parser = pofile.PoFileParser(None, abort_invalid=True)
|
||||
lineno = 10
|
||||
- line = 'Algo esta mal'
|
||||
+ line = u'Algo esta mal'
|
||||
msg = 'invalid file'
|
||||
with self.assertRaises(pofile.PoFileError) as e:
|
||||
parser._invalid_pofile(line, lineno, msg)
|
||||
--
|
||||
1.8.3.1
|
||||
|
||||
34
Replace-usage-of-parser.suite-with-ast.parse.patch
Normal file
34
Replace-usage-of-parser.suite-with-ast.parse.patch
Normal file
@ -0,0 +1,34 @@
|
||||
From 4fa749b918810b52a63b312d82e4003e24db0406 Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Miro=20Hron=C4=8Dok?= <miro@hroncok.cz>
|
||||
Date: Mon, 6 Jan 2020 00:37:39 +0100
|
||||
Subject: [PATCH] Replace usage of parser.suite with ast.parse
|
||||
|
||||
Replaced usage of the long-superseded "parser.suite" module in the
|
||||
mako.util package for parsing the python magic encoding comment with the
|
||||
"ast.parse" function introduced many years ago in Python 2.5, as
|
||||
"parser.suite" is emitting deprecation warnings in Python 3.9.
|
||||
|
||||
Fixes https://github.com/sqlalchemy/mako/issues/310
|
||||
See also https://github.com/sqlalchemy/mako/commit/2dae7d2c3da73653e6de329dc15c55056a0b9ab6
|
||||
---
|
||||
babel/util.py | 4 ++--
|
||||
1 file changed, 2 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/babel/util.py b/babel/util.py
|
||||
index 73a9051..c371bad 100644
|
||||
--- a/babel/util.py
|
||||
+++ b/babel/util.py
|
||||
@@ -68,8 +68,8 @@ def parse_encoding(fp):
|
||||
m = PYTHON_MAGIC_COMMENT_re.match(line1)
|
||||
if not m:
|
||||
try:
|
||||
- import parser
|
||||
- parser.suite(line1.decode('latin-1'))
|
||||
+ import ast
|
||||
+ ast.parse(line1.decode('latin-1'))
|
||||
except (ImportError, SyntaxError, UnicodeEncodeError):
|
||||
# Either it's a real syntax error, in which case the source is
|
||||
# not valid python source, or line2 is a continuation of line1,
|
||||
--
|
||||
1.8.3.1
|
||||
|
||||
11
babel.spec
11
babel.spec
@ -1,11 +1,15 @@
|
||||
Name: babel
|
||||
Version: 2.8.0
|
||||
Release: 1
|
||||
Release: 2
|
||||
Summary: Tools for internationalizing and localizing Python applications
|
||||
License: BSD
|
||||
URL: http://babel.pocoo.org/
|
||||
Source0: https://files.pythonhosted.org/packages/source/B/Babel/Babel-%{version}.tar.gz
|
||||
Patch0: babel-2.3.4-remove-pytz-version.patch
|
||||
Patch0000: babel-2.3.4-remove-pytz-version.patch
|
||||
Patch0001: Replace-usage-of-parser.suite-with-ast.parse.patch
|
||||
Patch0002: Introduce-invariant-that-_invalid_pofile-takes-unico.patch
|
||||
Patch0003: catalog.rst-Add-__iter__-to-Catalog-documentation.patch
|
||||
Patch0004: stop-using-deprecated-ElementTree-methods-getchildre.patch
|
||||
|
||||
BuildArch: noarch
|
||||
|
||||
@ -99,6 +103,9 @@ export TZ=Asia/Shanghai
|
||||
%doc built-docs/html/*
|
||||
|
||||
%changelog
|
||||
* Sun Jun 28 2020 linwei<linwei54@huawei.com> - 2.8.0-2
|
||||
- sync some patches from community
|
||||
|
||||
* Mon May 11 2020 openEuler Buildteam <buildteam@openeuler.org> - 2.8.0-1
|
||||
- update to 2.8.0-1
|
||||
|
||||
|
||||
29
catalog.rst-Add-__iter__-to-Catalog-documentation.patch
Normal file
29
catalog.rst-Add-__iter__-to-Catalog-documentation.patch
Normal file
@ -0,0 +1,29 @@
|
||||
From 0cfa69e087a24364ba788ff9d862949b65f0ff12 Mon Sep 17 00:00:00 2001
|
||||
From: CyanNani123 <f.st@live.de>
|
||||
Date: Mon, 13 Jan 2020 23:13:01 +0100
|
||||
Subject: [PATCH] catalog.rst: Add __iter__ to Catalog documentation
|
||||
|
||||
The declaration of __iter__ under the special-members
|
||||
directive makes it visible in the documentation.
|
||||
The docstring describing __iter__ already exists.
|
||||
|
||||
Closes https://github.com/python-babel/babel/issues/128
|
||||
---
|
||||
docs/api/messages/catalog.rst | 1 +
|
||||
1 file changed, 1 insertion(+)
|
||||
|
||||
diff --git a/docs/api/messages/catalog.rst b/docs/api/messages/catalog.rst
|
||||
index 8a905bc..8cb6375 100644
|
||||
--- a/docs/api/messages/catalog.rst
|
||||
+++ b/docs/api/messages/catalog.rst
|
||||
@@ -12,6 +12,7 @@ Catalogs
|
||||
|
||||
.. autoclass:: Catalog
|
||||
:members:
|
||||
+ :special-members: __iter__
|
||||
|
||||
Messages
|
||||
--------
|
||||
--
|
||||
1.8.3.1
|
||||
|
||||
104
stop-using-deprecated-ElementTree-methods-getchildre.patch
Normal file
104
stop-using-deprecated-ElementTree-methods-getchildre.patch
Normal file
@ -0,0 +1,104 @@
|
||||
From 167b71421f113e2210e4deefef5020402492e5be Mon Sep 17 00:00:00 2001
|
||||
From: Felix Schwarz <felix.schwarz@oss.schwarz.eu>
|
||||
Date: Tue, 5 May 2020 09:58:01 +0200
|
||||
Subject: [PATCH] stop using deprecated ElementTree methods "getchildren()" and
|
||||
"getiterator()"
|
||||
|
||||
Both methods were removed in Python 3.9 as mentioned in the release notes:
|
||||
|
||||
> Methods getchildren() and getiterator() of classes ElementTree and Element in
|
||||
> the ElementTree module have been removed. They were deprecated in Python 3.2.
|
||||
> Use iter(x) or list(x) instead of x.getchildren() and x.iter() or
|
||||
> list(x.iter()) instead of x.getiterator().
|
||||
---
|
||||
scripts/import_cldr.py | 18 +++++++++---------
|
||||
1 file changed, 9 insertions(+), 9 deletions(-)
|
||||
|
||||
diff --git a/scripts/import_cldr.py b/scripts/import_cldr.py
|
||||
index 8993b68..2ed3af9 100755
|
||||
--- a/scripts/import_cldr.py
|
||||
+++ b/scripts/import_cldr.py
|
||||
@@ -598,7 +598,7 @@ def parse_calendar_months(data, calendar):
|
||||
for width in ctxt.findall('monthWidth'):
|
||||
width_type = width.attrib['type']
|
||||
widths = ctxts.setdefault(width_type, {})
|
||||
- for elem in width.getiterator():
|
||||
+ for elem in width.iter():
|
||||
if elem.tag == 'month':
|
||||
_import_type_text(widths, elem, int(elem.attrib['type']))
|
||||
elif elem.tag == 'alias':
|
||||
@@ -616,7 +616,7 @@ def parse_calendar_days(data, calendar):
|
||||
for width in ctxt.findall('dayWidth'):
|
||||
width_type = width.attrib['type']
|
||||
widths = ctxts.setdefault(width_type, {})
|
||||
- for elem in width.getiterator():
|
||||
+ for elem in width.iter():
|
||||
if elem.tag == 'day':
|
||||
_import_type_text(widths, elem, weekdays[elem.attrib['type']])
|
||||
elif elem.tag == 'alias':
|
||||
@@ -634,7 +634,7 @@ def parse_calendar_quarters(data, calendar):
|
||||
for width in ctxt.findall('quarterWidth'):
|
||||
width_type = width.attrib['type']
|
||||
widths = ctxts.setdefault(width_type, {})
|
||||
- for elem in width.getiterator():
|
||||
+ for elem in width.iter():
|
||||
if elem.tag == 'quarter':
|
||||
_import_type_text(widths, elem, int(elem.attrib['type']))
|
||||
elif elem.tag == 'alias':
|
||||
@@ -649,7 +649,7 @@ def parse_calendar_eras(data, calendar):
|
||||
for width in calendar.findall('eras/*'):
|
||||
width_type = NAME_MAP[width.tag]
|
||||
widths = eras.setdefault(width_type, {})
|
||||
- for elem in width.getiterator():
|
||||
+ for elem in width.iter():
|
||||
if elem.tag == 'era':
|
||||
_import_type_text(widths, elem, type=int(elem.attrib.get('type')))
|
||||
elif elem.tag == 'alias':
|
||||
@@ -676,7 +676,7 @@ def parse_calendar_periods(data, calendar):
|
||||
def parse_calendar_date_formats(data, calendar):
|
||||
date_formats = data.setdefault('date_formats', {})
|
||||
for format in calendar.findall('dateFormats'):
|
||||
- for elem in format.getiterator():
|
||||
+ for elem in format.iter():
|
||||
if elem.tag == 'dateFormatLength':
|
||||
type = elem.attrib.get('type')
|
||||
if _should_skip_elem(elem, type, date_formats):
|
||||
@@ -696,7 +696,7 @@ def parse_calendar_date_formats(data, calendar):
|
||||
def parse_calendar_time_formats(data, calendar):
|
||||
time_formats = data.setdefault('time_formats', {})
|
||||
for format in calendar.findall('timeFormats'):
|
||||
- for elem in format.getiterator():
|
||||
+ for elem in format.iter():
|
||||
if elem.tag == 'timeFormatLength':
|
||||
type = elem.attrib.get('type')
|
||||
if _should_skip_elem(elem, type, time_formats):
|
||||
@@ -717,7 +717,7 @@ def parse_calendar_datetime_skeletons(data, calendar):
|
||||
datetime_formats = data.setdefault('datetime_formats', {})
|
||||
datetime_skeletons = data.setdefault('datetime_skeletons', {})
|
||||
for format in calendar.findall('dateTimeFormats'):
|
||||
- for elem in format.getiterator():
|
||||
+ for elem in format.iter():
|
||||
if elem.tag == 'dateTimeFormatLength':
|
||||
type = elem.attrib.get('type')
|
||||
if _should_skip_elem(elem, type, datetime_formats):
|
||||
@@ -880,7 +880,7 @@ def parse_interval_formats(data, tree):
|
||||
interval_formats[None] = elem.text
|
||||
elif elem.tag == "intervalFormatItem":
|
||||
skel_data = interval_formats.setdefault(elem.attrib["id"], {})
|
||||
- for item_sub in elem.getchildren():
|
||||
+ for item_sub in elem:
|
||||
if item_sub.tag == "greatestDifference":
|
||||
skel_data[item_sub.attrib["id"]] = split_interval_pattern(item_sub.text)
|
||||
else:
|
||||
@@ -903,7 +903,7 @@ def parse_currency_formats(data, tree):
|
||||
type = '%s:%s' % (type, curr_length_type)
|
||||
if _should_skip_elem(elem, type, currency_formats):
|
||||
continue
|
||||
- for child in elem.getiterator():
|
||||
+ for child in elem.iter():
|
||||
if child.tag == 'alias':
|
||||
currency_formats[type] = Alias(
|
||||
_translate_alias(['currency_formats', elem.attrib['type']],
|
||||
--
|
||||
1.8.3.1
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user