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
5d6fbe82
Kaydet (Commit)
5d6fbe82
authored
Eki 12, 2011
tarafından
Antoine Pitrou
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Instantiate the OS-related exception as soon as we raise it, so that
"except" works properly.
üst
1e4fe702
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
6 deletions
+22
-6
test_pep3151.py
Lib/test/test_pep3151.py
+12
-0
errors.c
Python/errors.c
+10
-6
No files found.
Lib/test/test_pep3151.py
Dosyayı görüntüle @
5d6fbe82
...
...
@@ -79,6 +79,18 @@ class HierarchyTest(unittest.TestCase):
e
=
SubOSError
(
EEXIST
,
"Bad file descriptor"
)
self
.
assertIs
(
type
(
e
),
SubOSError
)
def
test_try_except
(
self
):
# This checks that try .. except checks the concrete exception
# (FileNotFoundError) and not the base type specified when
# PyErr_SetFromErrnoWithFilenameObject was called.
# (it is therefore deliberate that it doesn't use assertRaises)
try
:
open
(
"some_hopefully_non_existing_file"
)
except
FileNotFoundError
:
pass
else
:
self
.
fail
(
"should have raised a FileNotFoundError"
)
class
AttributesTest
(
unittest
.
TestCase
):
...
...
Python/errors.c
Dosyayı görüntüle @
5d6fbe82
...
...
@@ -341,7 +341,7 @@ PyObject *
PyErr_SetFromErrnoWithFilenameObject
(
PyObject
*
exc
,
PyObject
*
filenameObject
)
{
PyObject
*
message
;
PyObject
*
v
;
PyObject
*
v
,
*
args
;
int
i
=
errno
;
#ifndef MS_WINDOWS
char
*
s
;
...
...
@@ -410,14 +410,18 @@ PyErr_SetFromErrnoWithFilenameObject(PyObject *exc, PyObject *filenameObject)
}
if
(
filenameObject
!=
NULL
)
v
=
Py_BuildValue
(
"(iOO)"
,
i
,
message
,
filenameObject
);
args
=
Py_BuildValue
(
"(iOO)"
,
i
,
message
,
filenameObject
);
else
v
=
Py_BuildValue
(
"(iO)"
,
i
,
message
);
args
=
Py_BuildValue
(
"(iO)"
,
i
,
message
);
Py_DECREF
(
message
);
if
(
v
!=
NULL
)
{
PyErr_SetObject
(
exc
,
v
);
Py_DECREF
(
v
);
if
(
args
!=
NULL
)
{
v
=
PyObject_Call
(
exc
,
args
,
NULL
);
Py_DECREF
(
args
);
if
(
v
!=
NULL
)
{
PyErr_SetObject
((
PyObject
*
)
Py_TYPE
(
v
),
v
);
Py_DECREF
(
v
);
}
}
#ifdef MS_WINDOWS
LocalFree
(
s_buf
);
...
...
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