Mercurial > cpython-lru_cache-weakref
annotate Python/pystrcmp.c @ 84103:8a0ed9f63c6e
Issue #15767: Introduce ModuleNotFoundError, a subclass of
ImportError.
The exception is raised by import when a module could not be found.
Technically this is defined as no viable loader could be found for the
specified module. This includes ``from ... import`` statements so that
the module usage is consistent for all situations where import
couldn't find what was requested.
This should allow for the common idiom of::
try:
import something
except ImportError:
pass
to be updated to using ModuleNotFoundError and not accidentally mask
ImportError messages that should propagate (e.g. issues with a
loader).
This work was driven by the fact that the ``from ... import``
statement needed to be able to tell the difference between an
ImportError that simply couldn't find a module (and thus silence the
exception so that ceval can raise it) and an ImportError that
represented an actual problem.
| author | Brett Cannon <brett@python.org> |
|---|---|
| date | Wed, 12 Jun 2013 16:59:46 -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 } |
