
This issue trackerhas been migrated toGitHub, and is currentlyread-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.
Created on2013-06-14 20:34 byjwilk, last changed2022-04-11 14:57 byadmin. This issue is nowclosed.
| Files | ||||
|---|---|---|---|---|
| File name | Uploaded | Description | Edit | |
| messages.mo | jwilk,2013-06-14 20:34 | |||
| gettext-mo-version.patch | Aaron1011,2014-10-06 19:01 | review | ||
| gettext-mo-fixup.patch | Aaron1011,2014-10-18 04:42 | review | ||
| Messages (14) | |||
|---|---|---|---|
| msg191151 -(view) | Author: Jakub Wilk (jwilk) | Date: 2013-06-14 20:34 | |
The MO file format specification[0] reads:"A program seeing an unexpected major revision number should stop reading the MO file entirely"But Python doesn't pay attention to versions at all.As a test-case I attached a MO file with a bogus major revision number. msgunfmt correcly rejects such a file:$ msgunfmt messages.mo msgunfmt: file "messages.mo" is not in GNU .mo formatYet Python opens it happily:>>> import gettext>>> t = gettext.GNUTranslations(open("messages.mo", "rb"))>>> t.gettext("foo")'bar'[0]http://www.gnu.org/software/gettext/manual/html_node/MO-Files.html | |||
| msg228418 -(view) | Author: Mark Lawrence (BreamoreBoy)* | Date: 2014-10-04 00:30 | |
@Jakub does this apply to all Python versions and OSes? | |||
| msg228662 -(view) | Author: Jakub Wilk (jwilk) | Date: 2014-10-06 11:44 | |
I believe so, yes. | |||
| msg228761 -(view) | Author: Jakub Wilk (jwilk) | Date: 2014-10-07 09:57 | |
The patch hardcodes 5 as version number in the exception message.The specifiction also says that "an unexpected minor revision number means that the file can be read but will not reveal its full contents, when parsed by a program that supports only smaller minor revision numbers". So I think a reasonable thing to do is to accept MO files with an expected major revision but an unexpected minor revision. | |||
| msg228768 -(view) | Author: Aaron Hill (Aaron1011)* | Date: 2014-10-07 15:12 | |
That sounds good. Should a warning be thrown for an unexpected minor revision? | |||
| msg229571 -(view) | Author: Aaron Hill (Aaron1011)* | Date: 2014-10-17 09:56 | |
Does anyone have any thoughts about throwing a warning for an unexpected minor revision? | |||
| msg229591 -(view) | Author: Antoine Pitrou (pitrou)*![]() | Date: 2014-10-17 18:05 | |
The linked docs say: """an unexpected minor revision number means that the file can be read but will not reveal its full contents, when parsed by a program that supports only smaller minor revision numbers""".Unless there an important piece of contents that can be missed, I would say a warning is more of a distraction here. | |||
| msg229628 -(view) | Author: Aaron Hill (Aaron1011)* | Date: 2014-10-18 03:12 | |
Okay, then. I'll just leave it out. | |||
| msg229629 -(view) | Author: Aaron Hill (Aaron1011)* | Date: 2014-10-18 04:42 | |
I've added a second patch, which properly distinguishes between major and minor revisions, and updates the docs to account for the new behavior. | |||
| msg230000 -(view) | Author: Aaron Hill (Aaron1011)* | Date: 2014-10-25 13:51 | |
Is there anything that needs to be changed? | |||
| msg230167 -(view) | Author: Antoine Pitrou (pitrou)*![]() | Date: 2014-10-28 19:14 | |
Aaron, the patch looks fine, I'm going to commit it. | |||
| msg230168 -(view) | Author: Roundup Robot (python-dev)![]() | Date: 2014-10-28 19:20 | |
New changeset3b26a0983a3c by Antoine Pitrou in branch 'default':Issue#18216: gettext now raises an error when a .mo file has an unsupported major version number. Patch by Aaron Hill.https://hg.python.org/cpython/rev/3b26a0983a3c | |||
| msg230169 -(view) | Author: Antoine Pitrou (pitrou)*![]() | Date: 2014-10-28 19:22 | |
I've pushed it to 3.5 only. I don't think it's worth risking compatibility breakage in bugfix branches. Thank you for your contribution! | |||
| msg230171 -(view) | Author: Aaron Hill (Aaron1011)* | Date: 2014-10-28 19:24 | |
Awesome! Thanks! | |||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022-04-11 14:57:46 | admin | set | github: 62416 |
| 2014-10-28 19:24:29 | Aaron1011 | set | messages: +msg230171 |
| 2014-10-28 19:22:39 | pitrou | set | status: open -> closed resolution: fixed messages: +msg230169 stage: patch review -> resolved |
| 2014-10-28 19:20:44 | python-dev | set | nosy: +python-dev messages: +msg230168 |
| 2014-10-28 19:14:58 | pitrou | set | messages: +msg230167 versions: - Python 2.7, Python 3.4 |
| 2014-10-25 13:51:01 | Aaron1011 | set | messages: +msg230000 |
| 2014-10-18 04:42:58 | Aaron1011 | set | messages: +msg229629 |
| 2014-10-18 04:42:17 | Aaron1011 | set | files: +gettext-mo-fixup.patch |
| 2014-10-18 04:35:30 | Aaron1011 | set | files: -gettext-mo-fix-minor-version.patch |
| 2014-10-18 04:33:55 | Aaron1011 | set | files: +gettext-mo-fix-minor-version.patch |
| 2014-10-18 03:12:44 | Aaron1011 | set | messages: +msg229628 |
| 2014-10-17 18:05:31 | pitrou | set | nosy: +pitrou messages: +msg229591 |
| 2014-10-17 09:56:20 | Aaron1011 | set | messages: +msg229571 |
| 2014-10-07 15:12:52 | Aaron1011 | set | messages: +msg228768 |
| 2014-10-07 09:57:25 | jwilk | set | messages: +msg228761 |
| 2014-10-07 03:58:43 | berker.peksag | set | nosy: +berker.peksag stage: patch review type: behavior versions: + Python 2.7, Python 3.4, Python 3.5 |
| 2014-10-06 19:01:06 | Aaron1011 | set | files: +gettext-mo-version.patch nosy: +Aaron1011 keywords: +patch |
| 2014-10-06 11:44:08 | jwilk | set | messages: +msg228662 |
| 2014-10-04 00:30:00 | BreamoreBoy | set | nosy: +loewis,BreamoreBoy messages: +msg228418 |
| 2013-06-14 20:34:41 | jwilk | create | |