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
41cb0bae
Unverified
Kaydet (Commit)
41cb0bae
authored
Haz 28, 2018
tarafından
Yury Selivanov
Kaydeden (comit)
GitHub
Haz 28, 2018
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
bpo-33985: Implement ContextVar.name attribute. (GH-7980)
üst
9b9d58f0
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
15 additions
and
2 deletions
+15
-2
contextvars.rst
Doc/library/contextvars.rst
+2
-0
test_context.py
Lib/test/test_context.py
+7
-2
2018-06-27-18-56-41.bpo-33985.ILJ3Af.rst
...ore and Builtins/2018-06-27-18-56-41.bpo-33985.ILJ3Af.rst
+1
-0
context.c
Python/context.c
+5
-0
No files found.
Doc/library/contextvars.rst
Dosyayı görüntüle @
41cb0bae
...
...
@@ -48,6 +48,8 @@ Context Variables
The name of the variable. This is a read-only property.
.. versionadded:: 3.7.1
.. method:: get([default])
Return a value for the context variable for the current context.
...
...
Lib/test/test_context.py
Dosyayı görüntüle @
41cb0bae
...
...
@@ -30,8 +30,13 @@ class ContextTest(unittest.TestCase):
with
self
.
assertRaisesRegex
(
TypeError
,
'must be a str'
):
contextvars
.
ContextVar
(
1
)
c
=
contextvars
.
ContextVar
(
'a'
)
self
.
assertNotEqual
(
hash
(
c
),
hash
(
'a'
))
c
=
contextvars
.
ContextVar
(
'aaa'
)
self
.
assertEqual
(
c
.
name
,
'aaa'
)
with
self
.
assertRaises
(
AttributeError
):
c
.
name
=
'bbb'
self
.
assertNotEqual
(
hash
(
c
),
hash
(
'aaa'
))
def
test_context_var_new_2
(
self
):
self
.
assertIsNone
(
contextvars
.
ContextVar
[
int
])
...
...
Misc/NEWS.d/next/Core and Builtins/2018-06-27-18-56-41.bpo-33985.ILJ3Af.rst
0 → 100644
Dosyayı görüntüle @
41cb0bae
Implement contextvars.ContextVar.name attribute.
Python/context.c
Dosyayı görüntüle @
41cb0bae
...
...
@@ -940,6 +940,10 @@ contextvar_cls_getitem(PyObject *self, PyObject *args)
Py_RETURN_NONE
;
}
static
PyMemberDef
PyContextVar_members
[]
=
{
{
"name"
,
T_OBJECT
,
offsetof
(
PyContextVar
,
var_name
),
READONLY
},
{
NULL
}
};
static
PyMethodDef
PyContextVar_methods
[]
=
{
_CONTEXTVARS_CONTEXTVAR_GET_METHODDEF
...
...
@@ -955,6 +959,7 @@ PyTypeObject PyContextVar_Type = {
"ContextVar"
,
sizeof
(
PyContextVar
),
.
tp_methods
=
PyContextVar_methods
,
.
tp_members
=
PyContextVar_members
,
.
tp_dealloc
=
(
destructor
)
contextvar_tp_dealloc
,
.
tp_getattro
=
PyObject_GenericGetAttr
,
.
tp_flags
=
Py_TPFLAGS_DEFAULT
|
Py_TPFLAGS_HAVE_GC
,
...
...
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