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
9af740b9
Kaydet (Commit)
9af740b9
authored
Kas 22, 2016
tarafından
Raymond Hettinger
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Sade Fark
merge
üst
21fb9f17
a3fec154
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
20 additions
and
7 deletions
+20
-7
test_with.py
Lib/test/test_with.py
+12
-3
NEWS
Misc/NEWS
+4
-0
ceval.c
Python/ceval.c
+4
-4
No files found.
Lib/test/test_with.py
Dosyayı görüntüle @
9af740b9
...
...
@@ -109,7 +109,7 @@ class FailureTestCase(unittest.TestCase):
with
foo
:
pass
self
.
assertRaises
(
NameError
,
fooNotDeclared
)
def
testEnterAttributeError
(
self
):
def
testEnterAttributeError
1
(
self
):
class
LacksEnter
(
object
):
def
__exit__
(
self
,
type
,
value
,
traceback
):
pass
...
...
@@ -117,7 +117,16 @@ class FailureTestCase(unittest.TestCase):
def
fooLacksEnter
():
foo
=
LacksEnter
()
with
foo
:
pass
self
.
assertRaises
(
AttributeError
,
fooLacksEnter
)
self
.
assertRaisesRegexp
(
AttributeError
,
'__enter__'
,
fooLacksEnter
)
def
testEnterAttributeError2
(
self
):
class
LacksEnterAndExit
(
object
):
pass
def
fooLacksEnterAndExit
():
foo
=
LacksEnterAndExit
()
with
foo
:
pass
self
.
assertRaisesRegexp
(
AttributeError
,
'__enter__'
,
fooLacksEnterAndExit
)
def
testExitAttributeError
(
self
):
class
LacksExit
(
object
):
...
...
@@ -127,7 +136,7 @@ class FailureTestCase(unittest.TestCase):
def
fooLacksExit
():
foo
=
LacksExit
()
with
foo
:
pass
self
.
assertRaises
(
AttributeError
,
fooLacksExit
)
self
.
assertRaises
Regexp
(
AttributeError
,
'__exit__'
,
fooLacksExit
)
def
assertRaisesSyntaxError
(
self
,
codestr
):
def
shouldRaiseSyntaxError
(
s
):
...
...
Misc/NEWS
Dosyayı görüntüle @
9af740b9
...
...
@@ -15,6 +15,10 @@ Core and Builtins
- Issue #28532: Show sys.version when -V option is supplied twice.
- Issue #27100: The with-statement now checks for __enter__ before it
checks for __exit__. This gives less confusing error messages when
both methods are missing. Patch by Jonathan Ellington.
- Issue #28746: Fix the set_inheritable() file descriptor method on platforms
that do not have the ioctl FIOCLEX and FIONCLEX commands.
...
...
Python/ceval.c
Dosyayı görüntüle @
9af740b9
...
...
@@ -3141,15 +3141,15 @@ _PyEval_EvalFrameDefault(PyFrameObject *f, int throwflag)
_Py_IDENTIFIER
(
__exit__
);
_Py_IDENTIFIER
(
__enter__
);
PyObject
*
mgr
=
TOP
();
PyObject
*
e
xit
=
special_lookup
(
mgr
,
&
PyId___exit__
),
*
enter
;
PyObject
*
e
nter
=
special_lookup
(
mgr
,
&
PyId___enter__
),
*
exit
;
PyObject
*
res
;
if
(
enter
==
NULL
)
goto
error
;
exit
=
special_lookup
(
mgr
,
&
PyId___exit__
);
if
(
exit
==
NULL
)
goto
error
;
SET_TOP
(
exit
);
enter
=
special_lookup
(
mgr
,
&
PyId___enter__
);
Py_DECREF
(
mgr
);
if
(
enter
==
NULL
)
goto
error
;
res
=
PyObject_CallFunctionObjArgs
(
enter
,
NULL
);
Py_DECREF
(
enter
);
if
(
res
==
NULL
)
...
...
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