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

Created on 2011-06-28 07:38 by djc, last changed 2015-04-13 17:38 by ned.deily.

Files
File name Uploaded Description Edit
issue12425.patch akuchling, 2015-04-13 15:08
Messages (4)
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
History
Date User Action Args
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