Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
c943265b
Kaydet (Commit)
c943265b
authored
Eyl 07, 2016
tarafından
Eric Snow
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Issue #15767: Add ModuleNotFoundError.
üst
86a76684
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
42 additions
and
2 deletions
+42
-2
exceptions.rst
Doc/c-api/exceptions.rst
+2
-0
exceptions.rst
Doc/library/exceptions.rst
+11
-2
pyerrors.h
Include/pyerrors.h
+1
-0
_compat_pickle.py
Lib/_compat_pickle.py
+7
-0
exception_hierarchy.txt
Lib/test/exception_hierarchy.txt
+1
-0
test_pickle.py
Lib/test/test_pickle.py
+8
-0
NEWS
Misc/NEWS
+3
-0
exceptions.c
Objects/exceptions.c
+9
-0
No files found.
Doc/c-api/exceptions.rst
Dosyayı görüntüle @
c943265b
...
@@ -782,6 +782,8 @@ the variables:
...
@@ -782,6 +782,8 @@ the variables:
+-----------------------------------------+---------------------------------+----------+
+-----------------------------------------+---------------------------------+----------+
| :c:data:`PyExc_ImportError` | :exc:`ImportError` | |
| :c:data:`PyExc_ImportError` | :exc:`ImportError` | |
+-----------------------------------------+---------------------------------+----------+
+-----------------------------------------+---------------------------------+----------+
| :c:data:`PyExc_ModuleNotFoundError` | :exc:`ModuleNotFoundError` | |
+-----------------------------------------+---------------------------------+----------+
| :c:data:`PyExc_IndexError` | :exc:`IndexError` | |
| :c:data:`PyExc_IndexError` | :exc:`IndexError` | |
+-----------------------------------------+---------------------------------+----------+
+-----------------------------------------+---------------------------------+----------+
| :c:data:`PyExc_InterruptedError` | :exc:`InterruptedError` | |
| :c:data:`PyExc_InterruptedError` | :exc:`InterruptedError` | |
...
...
Doc/library/exceptions.rst
Dosyayı görüntüle @
c943265b
...
@@ -170,8 +170,9 @@ The following exceptions are the exceptions that are usually raised.
...
@@ -170,8 +170,9 @@ The following exceptions are the exceptions that are usually raised.
.. exception:: ImportError
.. exception:: ImportError
Raised when an :keyword:`import` statement fails to find the module definition
Raised when the :keyword:`import` statement has troubles trying to
or when a ``from ... import`` fails to find a name that is to be imported.
load a module. Also raised when the "from list" in ``from ... import``
has a name that cannot be found.
The :attr:`name` and :attr:`path` attributes can be set using keyword-only
The :attr:`name` and :attr:`path` attributes can be set using keyword-only
arguments to the constructor. When set they represent the name of the module
arguments to the constructor. When set they represent the name of the module
...
@@ -181,6 +182,14 @@ The following exceptions are the exceptions that are usually raised.
...
@@ -181,6 +182,14 @@ The following exceptions are the exceptions that are usually raised.
.. versionchanged:: 3.3
.. versionchanged:: 3.3
Added the :attr:`name` and :attr:`path` attributes.
Added the :attr:`name` and :attr:`path` attributes.
.. exception:: ModuleNotFoundError
A subclass of :exc:`ImportError` which is raised by :keyword:`import`
when a module could not be located. It is also raised when ``None``
is found in :data:`sys.modules`.
.. versionadded:: 3.6
.. exception:: IndexError
.. exception:: IndexError
...
...
Include/pyerrors.h
Dosyayı görüntüle @
c943265b
...
@@ -160,6 +160,7 @@ PyAPI_DATA(PyObject *) PyExc_EOFError;
...
@@ -160,6 +160,7 @@ PyAPI_DATA(PyObject *) PyExc_EOFError;
PyAPI_DATA
(
PyObject
*
)
PyExc_FloatingPointError
;
PyAPI_DATA
(
PyObject
*
)
PyExc_FloatingPointError
;
PyAPI_DATA
(
PyObject
*
)
PyExc_OSError
;
PyAPI_DATA
(
PyObject
*
)
PyExc_OSError
;
PyAPI_DATA
(
PyObject
*
)
PyExc_ImportError
;
PyAPI_DATA
(
PyObject
*
)
PyExc_ImportError
;
PyAPI_DATA
(
PyObject
*
)
PyExc_ModuleNotFoundError
;
PyAPI_DATA
(
PyObject
*
)
PyExc_IndexError
;
PyAPI_DATA
(
PyObject
*
)
PyExc_IndexError
;
PyAPI_DATA
(
PyObject
*
)
PyExc_KeyError
;
PyAPI_DATA
(
PyObject
*
)
PyExc_KeyError
;
PyAPI_DATA
(
PyObject
*
)
PyExc_KeyboardInterrupt
;
PyAPI_DATA
(
PyObject
*
)
PyExc_KeyboardInterrupt
;
...
...
Lib/_compat_pickle.py
Dosyayı görüntüle @
c943265b
...
@@ -242,3 +242,10 @@ PYTHON3_OSERROR_EXCEPTIONS = (
...
@@ -242,3 +242,10 @@ PYTHON3_OSERROR_EXCEPTIONS = (
for
excname
in
PYTHON3_OSERROR_EXCEPTIONS
:
for
excname
in
PYTHON3_OSERROR_EXCEPTIONS
:
REVERSE_NAME_MAPPING
[(
'builtins'
,
excname
)]
=
(
'exceptions'
,
'OSError'
)
REVERSE_NAME_MAPPING
[(
'builtins'
,
excname
)]
=
(
'exceptions'
,
'OSError'
)
PYTHON3_IMPORTERROR_EXCEPTIONS
=
(
'ModuleNotFoundError'
,
)
for
excname
in
PYTHON3_IMPORTERROR_EXCEPTIONS
:
REVERSE_NAME_MAPPING
[(
'builtins'
,
excname
)]
=
(
'exceptions'
,
'ImportError'
)
Lib/test/exception_hierarchy.txt
Dosyayı görüntüle @
c943265b
...
@@ -14,6 +14,7 @@ BaseException
...
@@ -14,6 +14,7 @@ BaseException
+-- BufferError
+-- BufferError
+-- EOFError
+-- EOFError
+-- ImportError
+-- ImportError
+-- ModuleNotFoundError
+-- LookupError
+-- LookupError
| +-- IndexError
| +-- IndexError
| +-- KeyError
| +-- KeyError
...
...
Lib/test/test_pickle.py
Dosyayı görüntüle @
c943265b
...
@@ -335,6 +335,9 @@ class CompatPickleTests(unittest.TestCase):
...
@@ -335,6 +335,9 @@ class CompatPickleTests(unittest.TestCase):
if
(
module2
,
name2
)
==
(
'exceptions'
,
'OSError'
):
if
(
module2
,
name2
)
==
(
'exceptions'
,
'OSError'
):
attr
=
getattribute
(
module3
,
name3
)
attr
=
getattribute
(
module3
,
name3
)
self
.
assertTrue
(
issubclass
(
attr
,
OSError
))
self
.
assertTrue
(
issubclass
(
attr
,
OSError
))
elif
(
module2
,
name2
)
==
(
'exceptions'
,
'ImportError'
):
attr
=
getattribute
(
module3
,
name3
)
self
.
assertTrue
(
issubclass
(
attr
,
ImportError
))
else
:
else
:
module
,
name
=
mapping
(
module2
,
name2
)
module
,
name
=
mapping
(
module2
,
name2
)
if
module3
[:
1
]
!=
'_'
:
if
module3
[:
1
]
!=
'_'
:
...
@@ -401,6 +404,11 @@ class CompatPickleTests(unittest.TestCase):
...
@@ -401,6 +404,11 @@ class CompatPickleTests(unittest.TestCase):
if
exc
is
not
OSError
and
issubclass
(
exc
,
OSError
):
if
exc
is
not
OSError
and
issubclass
(
exc
,
OSError
):
self
.
assertEqual
(
reverse_mapping
(
'builtins'
,
name
),
self
.
assertEqual
(
reverse_mapping
(
'builtins'
,
name
),
(
'exceptions'
,
'OSError'
))
(
'exceptions'
,
'OSError'
))
elif
exc
is
not
ImportError
and
issubclass
(
exc
,
ImportError
):
self
.
assertEqual
(
reverse_mapping
(
'builtins'
,
name
),
(
'exceptions'
,
'ImportError'
))
self
.
assertEqual
(
mapping
(
'exceptions'
,
name
),
(
'exceptions'
,
name
))
else
:
else
:
self
.
assertEqual
(
reverse_mapping
(
'builtins'
,
name
),
self
.
assertEqual
(
reverse_mapping
(
'builtins'
,
name
),
(
'exceptions'
,
name
))
(
'exceptions'
,
name
))
...
...
Misc/NEWS
Dosyayı görüntüle @
c943265b
...
@@ -8043,6 +8043,9 @@ Core and Builtins
...
@@ -8043,6 +8043,9 @@ Core and Builtins
- Issue #18137: Detect integer overflow on precision in float.__format__()
- Issue #18137: Detect integer overflow on precision in float.__format__()
and complex.__format__().
and complex.__format__().
- Issue #15767: Introduce ModuleNotFoundError which is raised when a module
could not be found.
- Issue #18183: Fix various unicode operations on strings with large unicode
- Issue #18183: Fix various unicode operations on strings with large unicode
codepoints.
codepoints.
...
...
Objects/exceptions.c
Dosyayı görüntüle @
c943265b
...
@@ -705,6 +705,13 @@ ComplexExtendsException(PyExc_Exception, ImportError,
...
@@ -705,6 +705,13 @@ ComplexExtendsException(PyExc_Exception, ImportError,
"Import can't find module, or can't find name in "
"Import can't find module, or can't find name in "
"module."
);
"module."
);
/*
* ModuleNotFoundError extends ImportError
*/
MiddlingExtendsException
(
PyExc_ImportError
,
ModuleNotFoundError
,
ImportError
,
"Module not found."
);
/*
/*
* OSError extends Exception
* OSError extends Exception
*/
*/
...
@@ -2469,6 +2476,7 @@ _PyExc_Init(PyObject *bltinmod)
...
@@ -2469,6 +2476,7 @@ _PyExc_Init(PyObject *bltinmod)
PRE_INIT
(
SystemExit
)
PRE_INIT
(
SystemExit
)
PRE_INIT
(
KeyboardInterrupt
)
PRE_INIT
(
KeyboardInterrupt
)
PRE_INIT
(
ImportError
)
PRE_INIT
(
ImportError
)
PRE_INIT
(
ModuleNotFoundError
)
PRE_INIT
(
OSError
)
PRE_INIT
(
OSError
)
PRE_INIT
(
EOFError
)
PRE_INIT
(
EOFError
)
PRE_INIT
(
RuntimeError
)
PRE_INIT
(
RuntimeError
)
...
@@ -2541,6 +2549,7 @@ _PyExc_Init(PyObject *bltinmod)
...
@@ -2541,6 +2549,7 @@ _PyExc_Init(PyObject *bltinmod)
POST_INIT
(
SystemExit
)
POST_INIT
(
SystemExit
)
POST_INIT
(
KeyboardInterrupt
)
POST_INIT
(
KeyboardInterrupt
)
POST_INIT
(
ImportError
)
POST_INIT
(
ImportError
)
POST_INIT
(
ModuleNotFoundError
)
POST_INIT
(
OSError
)
POST_INIT
(
OSError
)
INIT_ALIAS
(
EnvironmentError
,
OSError
)
INIT_ALIAS
(
EnvironmentError
,
OSError
)
INIT_ALIAS
(
IOError
,
OSError
)
INIT_ALIAS
(
IOError
,
OSError
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment