Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
bdf6b910
Commit
bdf6b910
authored
Mar 19, 2017
by
Serhiy Storchaka
Committed by
GitHub
Mar 19, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bpo-29776: Use decorator syntax for properties. (#585)
parent
c85a2662
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
52 additions
and
33 deletions
+52
-33
Lib/_pydecimal.py
Lib/_pydecimal.py
+2
-2
Lib/lib2to3/pytree.py
Lib/lib2to3/pytree.py
+8
-8
Lib/multiprocessing/connection.py
Lib/multiprocessing/connection.py
+7
-2
Lib/multiprocessing/dummy/__init__.py
Lib/multiprocessing/dummy/__init__.py
+7
-3
Lib/multiprocessing/dummy/connection.py
Lib/multiprocessing/dummy/connection.py
+3
-1
Lib/multiprocessing/managers.py
Lib/multiprocessing/managers.py
+3
-1
Lib/pydoc.py
Lib/pydoc.py
+7
-2
Lib/tarfile.py
Lib/tarfile.py
+10
-6
Lib/test/test_pyclbr.py
Lib/test/test_pyclbr.py
+1
-1
Lib/tkinter/ttk.py
Lib/tkinter/ttk.py
+4
-7
No files found.
Lib/_pydecimal.py
View file @
bdf6b910
...
...
@@ -1674,13 +1674,13 @@ class Decimal(object):
__trunc__
=
__int__
@
property
def
real
(
self
):
return
self
real
=
property
(
real
)
@
property
def
imag
(
self
):
return
Decimal
(
0
)
imag
=
property
(
imag
)
def
conjugate
(
self
):
return
self
...
...
Lib/lib2to3/pytree.py
View file @
bdf6b910
...
...
@@ -271,7 +271,8 @@ class Node(Base):
for
child
in
self
.
children
:
yield
from
child
.
pre_order
()
def
_prefix_getter
(
self
):
@
property
def
prefix
(
self
):
"""
The whitespace and comments preceding this node in the input.
"""
...
...
@@ -279,12 +280,11 @@ class Node(Base):
return
""
return
self
.
children
[
0
].
prefix
def
_prefix_setter
(
self
,
prefix
):
@
prefix
.
setter
def
prefix
(
self
,
prefix
):
if
self
.
children
:
self
.
children
[
0
].
prefix
=
prefix
prefix
=
property
(
_prefix_getter
,
_prefix_setter
)
def
set_child
(
self
,
i
,
child
):
"""
Equivalent to 'node.children[i] = child'. This method also sets the
...
...
@@ -380,18 +380,18 @@ class Leaf(Base):
"""Return a pre-order iterator for the tree."""
yield
self
def
_prefix_getter
(
self
):
@
property
def
prefix
(
self
):
"""
The whitespace and comments preceding this token in the input.
"""
return
self
.
_prefix
def
_prefix_setter
(
self
,
prefix
):
@
prefix
.
setter
def
prefix
(
self
,
prefix
):
self
.
changed
()
self
.
_prefix
=
prefix
prefix
=
property
(
_prefix_getter
,
_prefix_setter
)
def
convert
(
gr
,
raw_node
):
"""
Convert raw node information to a Node or Leaf instance.
...
...
Lib/multiprocessing/connection.py
View file @
bdf6b910
...
...
@@ -465,8 +465,13 @@ class Listener(object):
self
.
_listener
=
None
listener
.
close
()
address
=
property
(
lambda
self
:
self
.
_listener
.
_address
)
last_accepted
=
property
(
lambda
self
:
self
.
_listener
.
_last_accepted
)
@
property
def
address
(
self
):
return
self
.
_listener
.
_address
@
property
def
last_accepted
(
self
):
return
self
.
_listener
.
_last_accepted
def
__enter__
(
self
):
return
self
...
...
Lib/multiprocessing/dummy/__init__.py
View file @
bdf6b910
...
...
@@ -98,11 +98,15 @@ class Value(object):
def
__init__
(
self
,
typecode
,
value
,
lock
=
True
):
self
.
_typecode
=
typecode
self
.
_value
=
value
def
_get
(
self
):
@
property
def
value
(
self
):
return
self
.
_value
def
_set
(
self
,
value
):
@
value
.
setter
def
value
(
self
,
value
):
self
.
_value
=
value
value
=
property
(
_get
,
_set
)
def
__repr__
(
self
):
return
'<%s(%r, %r)>'
%
(
type
(
self
).
__name__
,
self
.
_typecode
,
self
.
_value
)
...
...
Lib/multiprocessing/dummy/connection.py
View file @
bdf6b910
...
...
@@ -26,7 +26,9 @@ class Listener(object):
def
close
(
self
):
self
.
_backlog_queue
=
None
address
=
property
(
lambda
self
:
self
.
_backlog_queue
)
@
property
def
address
(
self
):
return
self
.
_backlog_queue
def
__enter__
(
self
):
return
self
...
...
Lib/multiprocessing/managers.py
View file @
bdf6b910
...
...
@@ -628,7 +628,9 @@ class BaseManager(object):
except
KeyError
:
pass
address
=
property
(
lambda
self
:
self
.
_address
)
@
property
def
address
(
self
):
return
self
.
_address
@
classmethod
def
register
(
cls
,
typeid
,
callable
=
None
,
proxytype
=
None
,
exposed
=
None
,
...
...
Lib/pydoc.py
View file @
bdf6b910
...
...
@@ -1868,8 +1868,13 @@ class Helper:
self
.
_input
=
input
self
.
_output
=
output
input
=
property
(
lambda
self
:
self
.
_input
or
sys
.
stdin
)
output
=
property
(
lambda
self
:
self
.
_output
or
sys
.
stdout
)
@
property
def
input
(
self
):
return
self
.
_input
or
sys
.
stdin
@
property
def
output
(
self
):
return
self
.
_output
or
sys
.
stdout
def
__repr__
(
self
):
if
inspect
.
stack
()[
1
][
3
]
==
'?'
:
...
...
Lib/tarfile.py
View file @
bdf6b910
...
...
@@ -761,17 +761,21 @@ class TarInfo(object):
# In pax headers the "name" and "linkname" field are called
# "path" and "linkpath".
def
_getpath
(
self
):
@
property
def
path
(
self
):
return
self
.
name
def
_setpath
(
self
,
name
):
@
path
.
setter
def
path
(
self
,
name
):
self
.
name
=
name
path
=
property
(
_getpath
,
_setpath
)
def
_getlinkpath
(
self
):
@
property
def
linkpath
(
self
):
return
self
.
linkname
def
_setlinkpath
(
self
,
linkname
):
@
linkpath
.
setter
def
linkpath
(
self
,
linkname
):
self
.
linkname
=
linkname
linkpath
=
property
(
_getlinkpath
,
_setlinkpath
)
def
__repr__
(
self
):
return
"<%s %r at %#x>"
%
(
self
.
__class__
.
__name__
,
self
.
name
,
id
(
self
))
...
...
Lib/test/test_pyclbr.py
View file @
bdf6b910
...
...
@@ -160,7 +160,7 @@ class PyclbrTest(TestCase):
cm
(
'aifc'
,
ignore
=
(
'openfp'
,
'_aifc_params'
))
# set with = in module
cm
(
'sre_parse'
,
ignore
=
(
'dump'
,
'groups'
,
'pos'
))
# from sre_constants import *; property
cm
(
'pdb'
)
cm
(
'pydoc'
)
cm
(
'pydoc'
,
ignore
=
(
'input'
,
'output'
,))
# properties
# Tests for modules inside packages
cm
(
'email.parser'
)
...
...
Lib/tkinter/ttk.py
View file @
bdf6b910
...
...
@@ -1577,20 +1577,17 @@ class LabeledScale(Frame):
self
.
label
[
'text'
]
=
newval
self
.
after_idle
(
adjust_label
)
def
_get_
value
(
self
):
@
property
def
value
(
self
):
"""Return current scale value."""
return
self
.
_variable
.
get
()
def
_set_
value
(
self
,
val
):
@
value
.
setter
def
value
(
self
,
val
):
"""Set new scale value."""
self
.
_variable
.
set
(
val
)
value
=
property
(
_get_value
,
_set_value
)
class
OptionMenu
(
Menubutton
):
"""Themed OptionMenu, based after tkinter's OptionMenu, which allows
the user to select a value from a menu."""
...
...
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