This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Unsupported provider

classification
Title: gettext breaks on empty plural-forms value
Type: behavior Stage: patch review
Components: Library (Lib) Versions: Python 3.3, Python 3.4, Python 2.7
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: Arfrever, akuchling, bkabrda, djc, eric.araujo, lemburg, loewis, ned.deily, serhiy.storchaka
Priority: normal Keywords: needs review, patch

Created on 2011-06-28 07:38 by djc, last changed 2022-04-11 14:57 by admin.

Files
File name Uploaded Description Edit
issue12425.patch akuchling, 2015-04-13 15:08
Messages (5)
msg139347 - (view) Author: Dirkjan Ochtman (djc) * (Python committer) Date: 2011-06-28 07:38
See https://bugzilla.redhat.com/show_bug.cgi?id=692632 for more details and a proposed patch.
msg139435 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2011-06-29 16:02
IIUC, this comes up with invalid po files, so this report is about graceful error handling, not strictly a bug.

If https://bugzilla.redhat.com/attachment.cgi?id=489427 was applied, gettext would not fail anymore, but the invalid line would not be reported IIUC.  I think we should print an error message, to let libs/apps find the mistake.
msg240618 - (view) Author: A.M. Kuchling (akuchling) * (Python committer) Date: 2015-04-13 15:08
Here's a patch against 3.5. This patch is atop the fix for #17898, so it won't apply cleanly to a stock 3.5.

The patch uses warnings.warn() to issue a warning if the plural header is empty. There seems to be precedent for issuing warnings in the case of odd incoming data or behaviour, so I'm comfortable doing this; I think that warnings need not be only for Python language features, like deprecated things.

But this does mean that importing gettext will also import warnings as a result, increasing memory usage.  Probably this doesn't matter -- on any sizable program, you probably already have the warnings module imported.  Otherwise we could print to sys.stderr.
msg240679 - (view) Author: Ned Deily (ned.deily) * (Python committer) Date: 2015-04-13 17:38
LGTM
msg302802 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2017-09-23 19:56
Sorry, I don't see a value of issuing warning if the following line of the code is failed. Why not raise an exception instead?

A warning can be issued in the case of lacking nplurals= which is not used in Python implementation.

I think additional checks should be added in msgfmt.py. GNU msgfmt checks that plural= and nplurals= are specified if there are plural form translations.
History
Date User Action Args
2022-04-11 14:57:19adminsetgithub: 56634
2017-09-23 19:56:11serhiy.storchakasetnosy: + serhiy.storchaka
messages: + msg302802
2015-04-13 17:38:57ned.deilysetnosy: + ned.deily
messages: + msg240679
2015-04-13 15:08:35akuchlingsetfiles: + issue12425.patch
nosy: + akuchling
messages: + msg240618

2013-05-31 07:34:58bkabrdasetnosy: + bkabrda
2013-05-10 19:07:51terry.reedysetversions: + Python 3.4, - Python 3.2
2011-06-29 16:02:17eric.araujosettype: behavior
versions: + Python 3.3, - Python 3.1
keywords: + patch, needs review
nosy: + loewis, eric.araujo, lemburg

messages: + msg139435
stage: patch review
2011-06-28 13:44:37Arfreversetnosy: + Arfrever
2011-06-28 07:38:27djccreate