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
8a8f7f98
Kaydet (Commit)
8a8f7f98
authored
Haz 09, 2014
tarafından
Serhiy Storchaka
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Issue #21677: Fixed chaining nonnormalized exceptions in io close() methods.
üst
b1f59cec
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
55 additions
and
0 deletions
+55
-0
test_io.py
Lib/test/test_io.py
+51
-0
NEWS
Misc/NEWS
+2
-0
bufferedio.c
Modules/_io/bufferedio.c
+1
-0
textio.c
Modules/_io/textio.c
+1
-0
No files found.
Lib/test/test_io.py
Dosyayı görüntüle @
8a8f7f98
...
@@ -792,9 +792,27 @@ class CommonBufferedTests:
...
@@ -792,9 +792,27 @@ class CommonBufferedTests:
with
self
.
assertRaises
(
OSError
)
as
err
:
# exception not swallowed
with
self
.
assertRaises
(
OSError
)
as
err
:
# exception not swallowed
b
.
close
()
b
.
close
()
self
.
assertEqual
(
err
.
exception
.
args
,
(
'close'
,))
self
.
assertEqual
(
err
.
exception
.
args
,
(
'close'
,))
self
.
assertIsInstance
(
err
.
exception
.
__context__
,
OSError
)
self
.
assertEqual
(
err
.
exception
.
__context__
.
args
,
(
'flush'
,))
self
.
assertEqual
(
err
.
exception
.
__context__
.
args
,
(
'flush'
,))
self
.
assertFalse
(
b
.
closed
)
self
.
assertFalse
(
b
.
closed
)
def
test_nonnormalized_close_error_on_close
(
self
):
# Issue #21677
raw
=
self
.
MockRawIO
()
def
bad_flush
():
raise
non_existing_flush
def
bad_close
():
raise
non_existing_close
raw
.
close
=
bad_close
b
=
self
.
tp
(
raw
)
b
.
flush
=
bad_flush
with
self
.
assertRaises
(
NameError
)
as
err
:
# exception not swallowed
b
.
close
()
self
.
assertIn
(
'non_existing_close'
,
str
(
err
.
exception
))
self
.
assertIsInstance
(
err
.
exception
.
__context__
,
NameError
)
self
.
assertIn
(
'non_existing_flush'
,
str
(
err
.
exception
.
__context__
))
self
.
assertFalse
(
b
.
closed
)
def
test_multi_close
(
self
):
def
test_multi_close
(
self
):
raw
=
self
.
MockRawIO
()
raw
=
self
.
MockRawIO
()
b
=
self
.
tp
(
raw
)
b
=
self
.
tp
(
raw
)
...
@@ -2576,6 +2594,39 @@ class TextIOWrapperTest(unittest.TestCase):
...
@@ -2576,6 +2594,39 @@ class TextIOWrapperTest(unittest.TestCase):
self
.
assertRaises
(
OSError
,
txt
.
close
)
# exception not swallowed
self
.
assertRaises
(
OSError
,
txt
.
close
)
# exception not swallowed
self
.
assertTrue
(
txt
.
closed
)
self
.
assertTrue
(
txt
.
closed
)
def
test_close_error_on_close
(
self
):
buffer
=
self
.
BytesIO
(
self
.
testdata
)
def
bad_flush
():
raise
OSError
(
'flush'
)
def
bad_close
():
raise
OSError
(
'close'
)
buffer
.
close
=
bad_close
txt
=
self
.
TextIOWrapper
(
buffer
,
encoding
=
"ascii"
)
txt
.
flush
=
bad_flush
with
self
.
assertRaises
(
OSError
)
as
err
:
# exception not swallowed
txt
.
close
()
self
.
assertEqual
(
err
.
exception
.
args
,
(
'close'
,))
self
.
assertIsInstance
(
err
.
exception
.
__context__
,
OSError
)
self
.
assertEqual
(
err
.
exception
.
__context__
.
args
,
(
'flush'
,))
self
.
assertFalse
(
txt
.
closed
)
def
test_nonnormalized_close_error_on_close
(
self
):
# Issue #21677
buffer
=
self
.
BytesIO
(
self
.
testdata
)
def
bad_flush
():
raise
non_existing_flush
def
bad_close
():
raise
non_existing_close
buffer
.
close
=
bad_close
txt
=
self
.
TextIOWrapper
(
buffer
,
encoding
=
"ascii"
)
txt
.
flush
=
bad_flush
with
self
.
assertRaises
(
NameError
)
as
err
:
# exception not swallowed
txt
.
close
()
self
.
assertIn
(
'non_existing_close'
,
str
(
err
.
exception
))
self
.
assertIsInstance
(
err
.
exception
.
__context__
,
NameError
)
self
.
assertIn
(
'non_existing_flush'
,
str
(
err
.
exception
.
__context__
))
self
.
assertFalse
(
txt
.
closed
)
def
test_multi_close
(
self
):
def
test_multi_close
(
self
):
txt
=
self
.
TextIOWrapper
(
self
.
BytesIO
(
self
.
testdata
),
encoding
=
"ascii"
)
txt
=
self
.
TextIOWrapper
(
self
.
BytesIO
(
self
.
testdata
),
encoding
=
"ascii"
)
txt
.
close
()
txt
.
close
()
...
...
Misc/NEWS
Dosyayı görüntüle @
8a8f7f98
...
@@ -22,6 +22,8 @@ Core and Builtins
...
@@ -22,6 +22,8 @@ Core and Builtins
Library
Library
-------
-------
- Issue #21677: Fixed chaining nonnormalized exceptions in io close() methods.
- Issue #11709: Fix the pydoc.help function to not fail when sys.stdin is not a
- Issue #11709: Fix the pydoc.help function to not fail when sys.stdin is not a
valid file.
valid file.
...
...
Modules/_io/bufferedio.c
Dosyayı görüntüle @
8a8f7f98
...
@@ -549,6 +549,7 @@ buffered_close(buffered *self, PyObject *args)
...
@@ -549,6 +549,7 @@ buffered_close(buffered *self, PyObject *args)
}
}
else
{
else
{
PyObject
*
val2
;
PyObject
*
val2
;
PyErr_NormalizeException
(
&
exc
,
&
val
,
&
tb
);
Py_DECREF
(
exc
);
Py_DECREF
(
exc
);
Py_XDECREF
(
tb
);
Py_XDECREF
(
tb
);
PyErr_Fetch
(
&
exc
,
&
val2
,
&
tb
);
PyErr_Fetch
(
&
exc
,
&
val2
,
&
tb
);
...
...
Modules/_io/textio.c
Dosyayı görüntüle @
8a8f7f98
...
@@ -2614,6 +2614,7 @@ textiowrapper_close(textio *self, PyObject *args)
...
@@ -2614,6 +2614,7 @@ textiowrapper_close(textio *self, PyObject *args)
}
}
else
{
else
{
PyObject
*
val2
;
PyObject
*
val2
;
PyErr_NormalizeException
(
&
exc
,
&
val
,
&
tb
);
Py_DECREF
(
exc
);
Py_DECREF
(
exc
);
Py_XDECREF
(
tb
);
Py_XDECREF
(
tb
);
PyErr_Fetch
(
&
exc
,
&
val2
,
&
tb
);
PyErr_Fetch
(
&
exc
,
&
val2
,
&
tb
);
...
...
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