Mercurial > cpython-lru_cache-weakref
annotate Python/pystrcmp.c @ 84172:e353f64dfd95
importlib.abc.SourceLoader.get_source() was re-raising SyntaxError and
UnicodeDecodeError as ImportError. That was over-reaching the point of
raising ImportError in get_source() (which is to signal the source
code was not found when it should have). Conflating the two exceptions
with ImportError could lead to masking errors with the source which
should be known outside of whether there was an error simply getting
the source to begin with.
| author | Brett Cannon <brett@python.org> |
|---|---|
| date | Sun, 16 Jun 2013 18:05:54 -0400 |
| parents | fd25030223b0 |
| children |
| rev | line source |
|---|---|
|
46034
0a485593ae1c
Merged revisions 61724-61725,61731-61735,61737,61739,61741,61743-61744,61753,61761,61765-61767,61769,61773,61776-61778,61780-61783,61788,61793,61796,61807,61813 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
44349
diff
changeset
|
1 /* Cross platform case insensitive string compare functions |
|
44349
4dc01402d78a
Merged revisions 59541-59561 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
diff
changeset
|
2 */ |
|
4dc01402d78a
Merged revisions 59541-59561 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
diff
changeset
|
3 |
|
4dc01402d78a
Merged revisions 59541-59561 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
diff
changeset
|
4 #include "Python.h" |
|
4dc01402d78a
Merged revisions 59541-59561 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
diff
changeset
|
5 |
|
4dc01402d78a
Merged revisions 59541-59561 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
diff
changeset
|
6 int |
|
4dc01402d78a
Merged revisions 59541-59561 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
diff
changeset
|
7 PyOS_mystrnicmp(const char *s1, const char *s2, Py_ssize_t size) |
|
4dc01402d78a
Merged revisions 59541-59561 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
diff
changeset
|
8 { |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
46034
diff
changeset
|
9 if (size == 0) |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
46034
diff
changeset
|
10 return 0; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
46034
diff
changeset
|
11 while ((--size > 0) && |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
46034
diff
changeset
|
12 (tolower((unsigned)*s1) == tolower((unsigned)*s2))) { |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
46034
diff
changeset
|
13 if (!*s1++ || !*s2++) |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
46034
diff
changeset
|
14 break; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
46034
diff
changeset
|
15 } |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
46034
diff
changeset
|
16 return tolower((unsigned)*s1) - tolower((unsigned)*s2); |
|
44349
4dc01402d78a
Merged revisions 59541-59561 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
diff
changeset
|
17 } |
|
4dc01402d78a
Merged revisions 59541-59561 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
diff
changeset
|
18 |
|
4dc01402d78a
Merged revisions 59541-59561 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
diff
changeset
|
19 int |
|
4dc01402d78a
Merged revisions 59541-59561 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
diff
changeset
|
20 PyOS_mystricmp(const char *s1, const char *s2) |
|
4dc01402d78a
Merged revisions 59541-59561 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
diff
changeset
|
21 { |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
46034
diff
changeset
|
22 while (*s1 && (tolower((unsigned)*s1++) == tolower((unsigned)*s2++))) { |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
46034
diff
changeset
|
23 ; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
46034
diff
changeset
|
24 } |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
46034
diff
changeset
|
25 return (tolower((unsigned)*s1) - tolower((unsigned)*s2)); |
|
44349
4dc01402d78a
Merged revisions 59541-59561 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
diff
changeset
|
26 } |
