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
cc4cffb8
Commit
cc4cffb8
authored
Jul 09, 2012
by
Terry Jan Reedy
Browse files
Options
Browse Files
Download
Plain Diff
Merge with 3.2 Issue 12510
parents
612a8158
44dea9d0
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
14 deletions
+20
-14
Lib/idlelib/CallTips.py
Lib/idlelib/CallTips.py
+20
-14
No files found.
Lib/idlelib/CallTips.py
View file @
cc4cffb8
...
@@ -117,7 +117,7 @@ def get_entity(expression):
...
@@ -117,7 +117,7 @@ def get_entity(expression):
return
None
return
None
# The following are used in both get_argspec and tests
# The following are used in both get_argspec and tests
_
self_pat
=
re
.
compile
(
'self
\
,?
\
s*'
)
_
first_param
=
re
.
compile
(
'(?<=
\
()
\
w*
\
,?
\
s*'
)
_default_callable_argspec
=
"No docstring, see docs."
_default_callable_argspec
=
"No docstring, see docs."
def
get_argspec
(
ob
):
def
get_argspec
(
ob
):
...
@@ -141,7 +141,7 @@ def get_argspec(ob):
...
@@ -141,7 +141,7 @@ def get_argspec(ob):
argspec
=
inspect
.
formatargspec
(
*
inspect
.
getfullargspec
(
fob
))
argspec
=
inspect
.
formatargspec
(
*
inspect
.
getfullargspec
(
fob
))
if
(
isinstance
(
ob
,
(
type
,
types
.
MethodType
))
or
if
(
isinstance
(
ob
,
(
type
,
types
.
MethodType
))
or
isinstance
(
ob
.
__call__
,
types
.
MethodType
)):
isinstance
(
ob
.
__call__
,
types
.
MethodType
)):
argspec
=
_
self_pat
.
sub
(
""
,
argspec
)
argspec
=
_
first_param
.
sub
(
""
,
argspec
)
if
isinstance
(
ob
.
__call__
,
types
.
MethodType
):
if
isinstance
(
ob
.
__call__
,
types
.
MethodType
):
doc
=
ob
.
__call__
.
__doc__
doc
=
ob
.
__call__
.
__doc__
...
@@ -169,8 +169,7 @@ def main():
...
@@ -169,8 +169,7 @@ def main():
def
t2
(
a
,
b
=
None
):
"(a, b=None)"
def
t2
(
a
,
b
=
None
):
"(a, b=None)"
def
t3
(
a
,
*
args
):
"(a, *args)"
def
t3
(
a
,
*
args
):
"(a, *args)"
def
t4
(
*
args
):
"(*args)"
def
t4
(
*
args
):
"(*args)"
def
t5
(
a
,
*
args
):
"(a, *args)"
def
t5
(
a
,
b
=
None
,
*
args
,
**
kw
):
"(a, b=None, *args, **kw)"
def
t6
(
a
,
b
=
None
,
*
args
,
**
kw
):
"(a, b=None, *args, **kw)"
class
TC
(
object
):
class
TC
(
object
):
"(ai=None, *b)"
"(ai=None, *b)"
...
@@ -179,13 +178,13 @@ def main():
...
@@ -179,13 +178,13 @@ def main():
def
t2
(
self
,
ai
,
b
=
None
):
"(self, ai, b=None)"
def
t2
(
self
,
ai
,
b
=
None
):
"(self, ai, b=None)"
def
t3
(
self
,
ai
,
*
args
):
"(self, ai, *args)"
def
t3
(
self
,
ai
,
*
args
):
"(self, ai, *args)"
def
t4
(
self
,
*
args
):
"(self, *args)"
def
t4
(
self
,
*
args
):
"(self, *args)"
def
t5
(
self
,
ai
,
*
args
):
"(self, ai, *args
)"
def
t5
(
self
,
ai
,
b
=
None
,
*
args
,
**
kw
):
"(self, ai, b=None, *args, **kw
)"
def
t6
(
self
,
ai
,
b
=
None
,
*
args
,
**
kw
):
"(self, ai, b=None, *args, **kw
)"
def
t6
(
no
,
self
):
"(no, self
)"
@
classmethod
@
classmethod
def
cm
(
cls
,
a
):
"(cls, a)"
def
cm
(
cls
,
a
):
"(cls, a)"
@
staticmethod
@
staticmethod
def
sm
(
b
):
"(b)"
def
sm
(
b
):
"(b)"
def
__call__
(
self
,
ci
):
"(ci)"
def
__call__
(
self
,
ci
):
"(
self,
ci)"
tc
=
TC
()
tc
=
TC
()
...
@@ -228,19 +227,26 @@ def main():
...
@@ -228,19 +227,26 @@ def main():
test
(
'SB()'
,
_default_callable_argspec
)
test
(
'SB()'
,
_default_callable_argspec
)
def
test_funcs
():
def
test_funcs
():
for
func
in
(
t1
,
t2
,
t3
,
t4
,
t5
,
t6
,
TC
,):
for
func
in
(
t1
,
t2
,
t3
,
t4
,
t5
,
TC
,):
fdoc
=
func
.
__doc__
fdoc
=
func
.
__doc__
test
(
func
.
__name__
,
fdoc
+
"
\
n
"
+
fdoc
)
test
(
func
.
__name__
,
fdoc
+
"
\
n
"
+
fdoc
)
for
func
in
(
TC
.
t1
,
TC
.
t2
,
TC
.
t3
,
TC
.
t4
,
TC
.
t5
,
TC
.
t6
,
TC
.
cm
,
TC
.
sm
):
for
func
in
(
TC
.
t1
,
TC
.
t2
,
TC
.
t3
,
TC
.
t4
,
TC
.
t5
,
TC
.
t6
,
TC
.
sm
,
TC
.
__call__
):
fdoc
=
func
.
__doc__
fdoc
=
func
.
__doc__
test
(
'TC.'
+
func
.
__name__
,
fdoc
+
"
\
n
"
+
fdoc
)
test
(
'TC.'
+
func
.
__name__
,
fdoc
+
"
\
n
"
+
fdoc
)
fdoc
=
TC
.
cm
.
__func__
.
__doc__
test
(
'TC.cm.__func__'
,
fdoc
+
"
\
n
"
+
fdoc
)
def
test_methods
():
def
test_methods
():
for
func
in
(
tc
.
t1
,
tc
.
t2
,
tc
.
t3
,
tc
.
t4
,
tc
.
t5
,
tc
.
t6
):
# test that first parameter is correctly removed from argspec
fdoc
=
func
.
__doc__
# using _first_param re to calculate expected masks re errors
test
(
'tc.'
+
func
.
__name__
,
_self_pat
.
sub
(
""
,
fdoc
)
+
"
\
n
"
+
fdoc
)
for
meth
,
mdoc
in
((
tc
.
t1
,
"()"
),
(
tc
.
t4
,
"(*args)"
),
(
tc
.
t6
,
"(self)"
),
fdoc
=
tc
.
__call__
.
__doc__
(
TC
.
cm
,
"(a)"
),):
test
(
'tc'
,
fdoc
+
"
\
n
"
+
fdoc
)
test
(
'tc.'
+
meth
.
__name__
,
mdoc
+
"
\
n
"
+
meth
.
__doc__
)
test
(
'tc'
,
"(ci)"
+
"
\
n
"
+
tc
.
__call__
.
__doc__
)
# directly test that re works to delete unicode parameter name
uni
=
"(A
\
u0391
\
u0410
\
u05d0
\
u0627
\
u0905
\
u1e00
\
u3042
, a)"
# various As
assert
_first_param
.
sub
(
''
,
uni
)
==
'(a)'
def
test_non_callables
():
def
test_non_callables
():
# expression evaluates, but not to a callable
# expression evaluates, but not to a callable
...
...
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