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
64505a1f
Kaydet (Commit)
64505a1f
authored
Haz 08, 2017
tarafından
Lisa Roach
Kaydeden (comit)
Serhiy Storchaka
Haz 08, 2017
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
bpo-30486: Allow setting cell value (#1840)
The cell_contents attribute of the cell object is now writable.
üst
6cca5c84
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
41 additions
and
4 deletions
+41
-4
datamodel.rst
Doc/reference/datamodel.rst
+6
-0
test_funcattrs.py
Lib/test/test_funcattrs.py
+20
-0
NEWS
Misc/NEWS
+5
-3
cellobject.c
Objects/cellobject.c
+10
-1
No files found.
Doc/reference/datamodel.rst
Dosyayı görüntüle @
64505a1f
...
...
@@ -510,6 +510,9 @@ Callable types
| :attr:`__closure__` | ``None`` or a tuple of cells | Read-only |
| | that contain bindings for the | |
| | function's free variables. | |
| | See below for information on | |
| | the ``cell_contents`` | |
| | attribute. | |
+-------------------------+-------------------------------+-----------+
| :attr:`__annotations__` | A dict containing annotations | Writable |
| | of parameters. The keys of | |
...
...
@@ -530,6 +533,9 @@ Callable types
implementation only supports function attributes on user-defined functions.
Function attributes on built-in functions may be supported in the future.*
A cell object has the attribute ``cell_contents``. This can be used to get
the value of the cell, as well as set the value.
Additional information about a function's definition can be retrieved from its
code object; see the description of internal types below.
...
...
Lib/test/test_funcattrs.py
Dosyayı görüntüle @
64505a1f
...
...
@@ -93,6 +93,26 @@ class FunctionPropertiesTest(FuncAttrsTest):
self
.
fail
(
"shouldn't be able to read an empty cell"
)
a
=
12
def
test_set_cell
(
self
):
a
=
12
def
f
():
return
a
c
=
f
.
__closure__
c
[
0
]
.
cell_contents
=
9
self
.
assertEqual
(
c
[
0
]
.
cell_contents
,
9
)
self
.
assertEqual
(
f
(),
9
)
self
.
assertEqual
(
a
,
9
)
del
c
[
0
]
.
cell_contents
try
:
c
[
0
]
.
cell_contents
except
ValueError
:
pass
else
:
self
.
fail
(
"shouldn't be able to read an empty cell"
)
with
self
.
assertRaises
(
NameError
):
f
()
with
self
.
assertRaises
(
UnboundLocalError
):
print
(
a
)
def
test___name__
(
self
):
self
.
assertEqual
(
self
.
b
.
__name__
,
'b'
)
self
.
b
.
__name__
=
'c'
...
...
Misc/NEWS
Dosyayı görüntüle @
64505a1f
...
...
@@ -10,6 +10,11 @@ What's New in Python 3.7.0 alpha 1?
Core and Builtins
-----------------
- bpo-30486: Allows setting cell values for __closure__. Patch by Lisa Roach.
- bpo-30537: itertools.islice now accepts integer-like objects (having
an __index__ method) as start, stop, and slice arguments
- bpo-25324: Tokens needed for parsing in Python moved to C. ``COMMENT``,
``NL`` and ``ENCODING``. This way the tokens and tok_names in the token
module don'
t
get
changed
when
you
import
the
tokenize
module
.
...
...
@@ -128,9 +133,6 @@ Core and Builtins
-
bpo
-
29546
:
Improve
from
-
import
error
message
with
location
-
bpo
-
30537
:
itertools
.
islice
now
accepts
integer
-
like
objects
(
having
an
__index__
method
)
as
start
,
stop
,
and
slice
arguments
-
Issue
#
29319
:
Prevent
RunMainFromImporter
overwriting
sys
.
path
[
0
].
-
Issue
#
29337
:
Fixed
possible
BytesWarning
when
compare
the
code
objects
.
...
...
Objects/cellobject.c
Dosyayı görüntüle @
64505a1f
...
...
@@ -140,8 +140,17 @@ cell_get_contents(PyCellObject *op, void *closure)
return
op
->
ob_ref
;
}
int
cell_set_contents
(
PyCellObject
*
op
,
PyObject
*
obj
)
{
Py_XINCREF
(
obj
);
Py_XSETREF
(
op
->
ob_ref
,
obj
);
return
0
;
}
static
PyGetSetDef
cell_getsetlist
[]
=
{
{
"cell_contents"
,
(
getter
)
cell_get_contents
,
NULL
},
{
"cell_contents"
,
(
getter
)
cell_get_contents
,
(
setter
)
cell_set_contents
,
NULL
},
{
NULL
}
/* sentinel */
};
...
...
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