Movatterモバイル変換


[0]ホーム

URL:


homepage

Issue27079

This issue trackerhas been migrated toGitHub, and is currentlyread-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title:Bugs in curses.ascii predicates
Type:behaviorStage:resolved
Components:Library (Lib)Versions:Python 3.6, Python 3.5, Python 2.7
process
Status:closedResolution:fixed
Dependencies:Superseder:
Assigned To: serhiy.storchakaNosy List: akira, serhiy.storchaka, twouters
Priority:normalKeywords:patch

Created on2016-05-21 20:09 byserhiy.storchaka, last changed2022-04-11 14:58 byadmin. This issue is nowclosed.

Files
File nameUploadedDescriptionEdit
curses_ascii.patchserhiy.storchaka,2016-05-21 20:09review
Messages (5)
msg266020 -(view)Author: Serhiy Storchaka (serhiy.storchaka)*(Python committer)Date: 2016-05-21 20:09
Most curses.ascii predicates corresponds C functions declared in <ctype.h>. But there are some differences:1. isblank() returns True for space and backspace instead of space and tab.2. ispunct() returns True for non-ASCII and control characters.3. iscntrl() returns False for '\x7f'. Note that there is different function isctrl().These differences look as bugs. Proposed patch fixes them and adds tests for all curses.ascii functions.
msg268825 -(view)Author: Serhiy Storchaka (serhiy.storchaka)*(Python committer)Date: 2016-06-18 19:14
Committed with wrong commit message (damn two clipboards on X11) inac8338546ca8,d7b6c07bc713,d03c8d0a6a73.
msg269562 -(view)Author: Akira Li (akira)*Date: 2016-06-30 08:08
There is an overlapping issue from 2010: "curses.ascii.isblank() function is broken. It confuses backspace (BS 0x08) with tab (0x09)"http://bugs.python.org/issue9770 Your patch fixes it too (it should be closed). Note: the patch does not pass tests fromLib/test/test_curses_ascii.py attached toissue9770 (even if the code: `if char_class_name in ('cntrl', 'punct') test = unittest.expectedFailure(test)` is removed) e.g., iscntrl(-1) should be False but it returns True:  $ ./python  >>> import curses.ascii  >>> curses.ascii.iscntrl(-1) #XXX expected False  TrueIf we ignore negative ints then isblank, ispunct, iscntrl provided in the curses_ascii.patch are ok.
msg269573 -(view)Author: Serhiy Storchaka (serhiy.storchaka)*(Python committer)Date: 2016-06-30 10:50
Since screen.getch() can return -1, it looks reasonable to make curses.ascii predicates to work with negative integers.Do you want to open a new issue and write a patch Akira?
msg269679 -(view)Author: Akira Li (akira)*Date: 2016-07-01 16:59
I'm not sure anything should be done (e.g., it is "undefined behavior" to pass a negative value such as CHAR_MIN (if *char* type is signed) to a character classification function in C. Though EOF value (-1 traditionally) should be handled).If you want to explore it further; I've enumerated open questions in 2014 (inconsistent TypeError, ord(c) > 0x100, negative ints handling, etc)http://bugs.python.org/issue9770#msg221008
History
DateUserActionArgs
2022-04-11 14:58:31adminsetgithub: 71266
2016-07-01 16:59:23akirasetmessages: +msg269679
2016-06-30 10:50:56serhiy.storchakasetmessages: +msg269573
2016-06-30 08:08:44akirasetnosy: +akira
messages: +msg269562
2016-06-18 19:14:55serhiy.storchakasetstatus: open -> closed
resolution: fixed
messages: +msg268825

stage: patch review -> resolved
2016-06-18 19:01:02serhiy.storchakasetassignee:serhiy.storchaka
2016-05-21 20:09:59serhiy.storchakacreate
Supported byThe Python Software Foundation,
Powered byRoundup
Copyright © 1990-2022,Python Software Foundation
Legal Statements

[8]ページ先頭

©2009-2026 Movatter.jp