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
822b87f2
Kaydet (Commit)
822b87f2
authored
May 29, 2009
tarafından
Raymond Hettinger
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Deprecate contextlib.nested(). The with-statement now provides this functionality directly.
üst
b4d2d318
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
11 additions
and
2 deletions
+11
-2
contextlib.rst
Doc/library/contextlib.rst
+2
-0
contextlib.py
Lib/contextlib.py
+3
-0
test_contextlib.py
Lib/test/test_contextlib.py
+4
-1
NEWS
Misc/NEWS
+2
-1
No files found.
Doc/library/contextlib.rst
Dosyayı görüntüle @
822b87f2
...
@@ -83,6 +83,8 @@ Functions provided:
...
@@ -83,6 +83,8 @@ Functions provided:
:meth:`__exit__` methods should avoid raising exceptions, and in particular they
:meth:`__exit__` methods should avoid raising exceptions, and in particular they
should not re-raise a passed-in exception.
should not re-raise a passed-in exception.
.. deprecated:: 2.7
The with-statement now supports this functionality directly.
.. function:: closing(thing)
.. function:: closing(thing)
...
...
Lib/contextlib.py
Dosyayı görüntüle @
822b87f2
...
@@ -2,6 +2,7 @@
...
@@ -2,6 +2,7 @@
import
sys
import
sys
from
functools
import
wraps
from
functools
import
wraps
from
warnings
import
warn
__all__
=
[
"contextmanager"
,
"nested"
,
"closing"
]
__all__
=
[
"contextmanager"
,
"nested"
,
"closing"
]
...
@@ -101,6 +102,8 @@ def nested(*managers):
...
@@ -101,6 +102,8 @@ def nested(*managers):
<body>
<body>
"""
"""
warn
(
"With-statements now directly support multiple context managers"
,
DeprecationWarning
,
2
)
exits
=
[]
exits
=
[]
vars
=
[]
vars
=
[]
exc
=
(
None
,
None
,
None
)
exc
=
(
None
,
None
,
None
)
...
...
Lib/test/test_contextlib.py
Dosyayı görüntüle @
822b87f2
...
@@ -9,6 +9,7 @@ import unittest
...
@@ -9,6 +9,7 @@ import unittest
import
threading
import
threading
from
contextlib
import
*
# Tests __all__
from
contextlib
import
*
# Tests __all__
from
test
import
test_support
from
test
import
test_support
import
warnings
class
ContextManagerTestCase
(
unittest
.
TestCase
):
class
ContextManagerTestCase
(
unittest
.
TestCase
):
...
@@ -331,7 +332,9 @@ class LockContextTestCase(unittest.TestCase):
...
@@ -331,7 +332,9 @@ class LockContextTestCase(unittest.TestCase):
# This is needed to make the test actually run under regrtest.py!
# This is needed to make the test actually run under regrtest.py!
def
test_main
():
def
test_main
():
test_support
.
run_unittest
(
__name__
)
with
warnings
.
catch_warnings
():
warnings
.
simplefilter
(
'ignore'
)
test_support
.
run_unittest
(
__name__
)
if
__name__
==
"__main__"
:
if
__name__
==
"__main__"
:
test_main
()
test_main
()
Misc/NEWS
Dosyayı görüntüle @
822b87f2
...
@@ -12,7 +12,8 @@ What's New in Python 2.7 alpha 1
...
@@ -12,7 +12,8 @@ What's New in Python 2.7 alpha 1
Core and Builtins
Core and Builtins
-----------------
-----------------
- Added support for multiple context managers in the same with statement.
- Added support for multiple context managers in the same with-statement.
Deprecated contextlib.nested() which is no longer needed.
- Issue #6101: A new opcode, SETUP_WITH, has been added to speed up the with
- Issue #6101: A new opcode, SETUP_WITH, has been added to speed up the with
statement and correctly lookup the __enter__ and __exit__ special methods.
statement and correctly lookup the __enter__ and __exit__ special methods.
...
...
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