New submission from Masahiro Konishi:

int x = PyOS_mystricmp("foo", "none");
expected: x < 0
actual:   x == 0

    while (*s1 && (tolower((unsigned)*s1++) == tolower((unsigned)*s2++))) {
        ;
    }
    return (tolower((unsigned)*s1) - tolower((unsigned)*s2));

The while-loop is finished when *s1 != *s2 (ex. *s1 == 'f', *s2 == 'n'), but s1 
and s2 already point to next characters (ex. *s1 == 'o', *s2 == 'o'), so 
PyOS_mystricmp returns difference between these characters.

----------
components: Interpreter Core
files: pystrcmp.c.patch
keywords: patch
messages: 226303
nosy: kakkoko
priority: normal
severity: normal
status: open
title: PyOS_mystricmp is broken
type: behavior
versions: Python 3.4
Added file: http://bugs.python.org/file36529/pystrcmp.c.patch

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue22330>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to