classification
Title: Invalid flag for some code page decoders
Type: behavior Stage: resolved
Components: Interpreter Core, Windows Versions: Python 3.8, Python 3.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: serhiy.storchaka Nosy List: doerwalter, lemburg, miss-islington, paul.moore, serhiy.storchaka, steve.dower, tim.golden, zach.ware
Priority: normal Keywords: patch

Created on 2019-03-16 08:59 by serhiy.storchaka, last changed 2019-03-21 15:47 by serhiy.storchaka. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 12369 merged serhiy.storchaka, 2019-03-16 15:00
PR 12475 merged miss-islington, 2019-03-20 19:45
Messages (3)
msg338067 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2019-03-16 08:59
From https://docs.microsoft.com/en-us/windows/desktop/api/stringapiset/nf-stringapiset-multibytetowidechar:

For the code pages listed below, dwFlags must be set to 0. Otherwise, the function fails with ERROR_INVALID_FLAGS.

    50220
    50221
    50222
    50225
    50227
    50229
    57002 through 57011
    65000 (UTF-7)
    42 (Symbol)

But currently in PyUnicode_DecodeCodePageStateful() it is set to MB_ERR_INVALID_CHARS for all code pages except CP_UTF7. This causes an error for all other code pages list above.

>>> codecs.code_page_decode(50220, b'abc')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
OSError: [WinError 1004] Invalid flags
msg338507 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2019-03-20 19:45
New changeset c1e2c288f41cdc1c6e6e09d9a5277a58232ceb03 by Serhiy Storchaka in branch 'master':
bpo-36312: Fix decoders for some code pages. (GH-12369)
https://github.com/python/cpython/commit/c1e2c288f41cdc1c6e6e09d9a5277a58232ceb03
msg338522 - (view) Author: miss-islington (miss-islington) Date: 2019-03-21 04:32
New changeset 74829b7323642739cdc439c2c88d406daf92075b by Miss Islington (bot) in branch '3.7':
bpo-36312: Fix decoders for some code pages. (GH-12369)
https://github.com/python/cpython/commit/74829b7323642739cdc439c2c88d406daf92075b
History
Date User Action Args
2019-03-21 15:47:41serhiy.storchakasetstatus: open -> closed
stage: patch review -> resolved
resolution: fixed
versions: - Python 2.7
2019-03-21 04:32:00miss-islingtonsetnosy: + miss-islington
messages: + msg338522
2019-03-20 19:45:40miss-islingtonsetpull_requests: + pull_request12427
2019-03-20 19:45:21serhiy.storchakasetmessages: + msg338507
2019-03-16 15:00:32serhiy.storchakasetkeywords: + patch
stage: patch review
pull_requests: + pull_request12332
2019-03-16 09:22:38serhiy.storchakasetassignee: serhiy.storchaka
2019-03-16 08:59:08serhiy.storchakacreate