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
c91210c0
Kaydet (Commit)
c91210c0
authored
May 15, 2008
tarafından
Georg Brandl
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
#2863: add gen.__name__ and add this name to generator repr().
üst
b3465130
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
49 additions
and
3 deletions
+49
-3
test_generators.py
Lib/test/test_generators.py
+11
-0
test_genexps.py
Lib/test/test_genexps.py
+1
-1
NEWS
Misc/NEWS
+5
-0
genobject.c
Objects/genobject.c
+32
-2
No files found.
Lib/test/test_generators.py
Dosyayı görüntüle @
c91210c0
...
...
@@ -917,6 +917,17 @@ StopIteration
>>> g.gi_code is f.func_code
True
Test the __name__ attribute and the repr()
>>> def f():
... yield 5
...
>>> g = f()
>>> g.__name__
'f'
>>> repr(g) # doctest: +ELLIPSIS
'<f generator object at ...>'
"""
# conjoin is a simple backtracking generator, named in honor of Icon's
...
...
Lib/test/test_genexps.py
Dosyayı görüntüle @
c91210c0
...
...
@@ -92,7 +92,7 @@ Verify that parenthesis are required when used as a keyword argument value
Verify that parenthesis are required when used as a keyword argument value
>>> dict(a = (i for i in xrange(10))) #doctest: +ELLIPSIS
{'a': <generator object at ...>}
{'a': <
<genexp>
generator object at ...>}
Verify early binding for the outermost for-expression
...
...
Misc/NEWS
Dosyayı görüntüle @
c91210c0
...
...
@@ -12,6 +12,11 @@ What's New in Python 2.6 beta 1?
Core and Builtins
-----------------
- Issue #2863: generators now have a ``gen.__name__`` attribute that equals
``gen.gi_code.co_name``, like ``func.__name___`` that equals
``func.func_code.co_name``. The repr() of a generator now also contains
this name.
- Issue #2831: enumerate() now has a ``start`` argument.
- Issue #2801: fix bug in the float.is_integer method where a ValueError
...
...
Objects/genobject.c
Dosyayı görüntüle @
c91210c0
...
...
@@ -281,6 +281,36 @@ gen_iternext(PyGenObject *gen)
}
static
PyObject
*
gen_repr
(
PyGenObject
*
gen
)
{
char
*
code_name
;
code_name
=
PyString_AsString
(((
PyCodeObject
*
)
gen
->
gi_code
)
->
co_name
);
if
(
code_name
==
NULL
)
return
NULL
;
return
PyString_FromFormat
(
"<%.200s generator object at %p>"
,
code_name
,
gen
);
}
static
PyObject
*
gen_get_name
(
PyGenObject
*
gen
)
{
PyObject
*
name
=
((
PyCodeObject
*
)
gen
->
gi_code
)
->
co_name
;
Py_INCREF
(
name
);
return
name
;
}
PyDoc_STRVAR
(
gen__name__doc__
,
"Return the name of the generator's associated code object."
);
static
PyGetSetDef
gen_getsetlist
[]
=
{
{
"__name__"
,
(
getter
)
gen_get_name
,
NULL
,
NULL
,
gen__name__doc__
},
{
NULL
}
};
static
PyMemberDef
gen_memberlist
[]
=
{
{
"gi_frame"
,
T_OBJECT
,
offsetof
(
PyGenObject
,
gi_frame
),
RO
},
{
"gi_running"
,
T_INT
,
offsetof
(
PyGenObject
,
gi_running
),
RO
},
...
...
@@ -306,7 +336,7 @@ PyTypeObject PyGen_Type = {
0
,
/* tp_getattr */
0
,
/* tp_setattr */
0
,
/* tp_compare */
0
,
/* tp_repr */
(
reprfunc
)
gen_repr
,
/* tp_repr */
0
,
/* tp_as_number */
0
,
/* tp_as_sequence */
0
,
/* tp_as_mapping */
...
...
@@ -326,7 +356,7 @@ PyTypeObject PyGen_Type = {
(
iternextfunc
)
gen_iternext
,
/* tp_iternext */
gen_methods
,
/* tp_methods */
gen_memberlist
,
/* tp_members */
0
,
/* tp_getset */
gen_getsetlist
,
/* tp_getset */
0
,
/* tp_base */
0
,
/* tp_dict */
...
...
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