update to 2.11.0

This commit is contained in:
Felix Schwarz 2023-01-01 12:32:33 +01:00
parent f9732cabc3
commit 40200005a9
3 changed files with 6 additions and 81 deletions

View File

@ -1,75 +0,0 @@
From 965523b6c61263f48a20f1cbe8862e460c1b4853 Mon Sep 17 00:00:00 2001
From: Aarni Koskela <akx@iki.fi>
Date: Tue, 10 May 2022 15:36:47 +0300
Subject: [PATCH] Use email.Message for pofile header parsing
cgi.parse_header is due to be deprecated
Fixes #873
---
babel/messages/catalog.py | 12 +++++++++---
tests/messages/test_pofile.py | 11 +++++++++++
2 files changed, 20 insertions(+), 3 deletions(-)
diff --git a/babel/messages/catalog.py b/babel/messages/catalog.py
index 564b2c7c..e43a28c0 100644
--- a/babel/messages/catalog.py
+++ b/babel/messages/catalog.py
@@ -10,7 +10,6 @@
import re
-from cgi import parse_header
from collections import OrderedDict
from datetime import datetime, time as time_
from difflib import get_close_matches
@@ -225,6 +224,13 @@ class TranslationError(Exception):
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#"""
+def parse_separated_header(value: str):
+ # Adapted from https://peps.python.org/pep-0594/#cgi
+ from email.message import Message
+ m = Message()
+ m['content-type'] = value
+ return dict(m.get_params())
+
class Catalog:
"""Representation of a message catalog."""
@@ -424,11 +430,11 @@ def _set_mime_headers(self, headers):
elif name == 'language-team':
self.language_team = value
elif name == 'content-type':
- mimetype, params = parse_header(value)
+ params = parse_separated_header(value)
if 'charset' in params:
self.charset = params['charset'].lower()
elif name == 'plural-forms':
- _, params = parse_header(' ;' + value)
+ params = parse_separated_header(' ;' + value)
self._num_plurals = int(params.get('nplurals', 2))
self._plural_expr = params.get('plural', '(n != 1)')
elif name == 'pot-creation-date':
diff --git a/tests/messages/test_pofile.py b/tests/messages/test_pofile.py
index 632efe7b..118960ab 100644
--- a/tests/messages/test_pofile.py
+++ b/tests/messages/test_pofile.py
@@ -68,6 +68,17 @@ def test_applies_specified_encoding_during_read(self):
catalog = pofile.read_po(buf, locale='de_DE')
self.assertEqual(u'bär', catalog.get('foo').string)
+ def test_encoding_header_read(self):
+ buf = BytesIO(b'msgid ""\nmsgstr ""\n"Content-Type: text/plain; charset=mac_roman\\n"\n')
+ catalog = pofile.read_po(buf, locale='xx_XX')
+ assert catalog.charset == 'mac_roman'
+
+ def test_plural_forms_header_parsed(self):
+ buf = BytesIO(b'msgid ""\nmsgstr ""\n"Plural-Forms: nplurals=42; plural=(n % 11);\\n"\n')
+ catalog = pofile.read_po(buf, locale='xx_XX')
+ assert catalog.plural_expr == '(n % 11)'
+ assert catalog.num_plurals == 42
+
def test_read_multiline(self):
buf = StringIO(r'''msgid ""
"Here's some text that\n"

View File

@ -7,16 +7,13 @@
%bcond_with bootstrap
Name: babel
Version: 2.10.3
Release: 3%{?dist}
Version: 2.11.0
Release: 1%{?dist}
Summary: Tools for internationalizing Python applications
License: BSD
URL: https://babel.pocoo.org/
Source0: %{pypi_source}
# patch present in upstream master (commit 965523b6) but not in
# 2.10.x branch
Patch0: babel-remove-cgi-deprecation-warning.patch
BuildArch: noarch
@ -127,6 +124,9 @@ export TZ=UTC
%endif
%changelog
* Sun Jan 01 2023 Felix Schwarz <fschwarz@fedoraproject.org> - 2.11.0-1
- update to 2.11.0
* Wed Jul 20 2022 Fedora Release Engineering <releng@fedoraproject.org> - 2.10.3-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_37_Mass_Rebuild

View File

@ -1 +1 @@
SHA512 (Babel-2.10.3.tar.gz) = 72a5759d2cfa239df56f3d2809b23367b9691e21de92535b30f9b3455d253682f6c18ca919f3fb039deed2663db9276307f6343cbbab56fca96ff1ac9c214fa7
SHA512 (Babel-2.11.0.tar.gz) = 526368dc5e44f2d93c52f2fcb544130eea6c6b7c78325bd56c6d9a6706890a4cd9daa1498d639aab65059801d87977da626e64585083c58c4b328001991eea0b