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
e59e2bab
Kaydet (Commit)
e59e2bab
authored
May 03, 2003
tarafından
Martin v. Löwis
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Patch #711902: Cause pydoc to show data descriptor __doc__ strings.
üst
e86a59af
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
43 additions
and
2 deletions
+43
-2
libinspect.tex
Doc/lib/libinspect.tex
+25
-0
inspect.py
Lib/inspect.py
+10
-0
pydoc.py
Lib/pydoc.py
+2
-2
test_inspect.py
Lib/test/test_inspect.py
+3
-0
NEWS
Misc/NEWS
+3
-0
No files found.
Doc/lib/libinspect.tex
Dosyayı görüntüle @
e59e2bab
...
...
@@ -161,6 +161,31 @@ Note:
Return true if the object is a user-defined or built-in function or method.
\end{funcdesc}
\begin{funcdesc}
{
ismethoddescriptor
}{
object
}
Return true if the object is a method descriptor, but not if ismethod() or
isclass() or isfunction() are true.
This is new as of Python 2.2, and, for example, is true of int.
__
add
__
.
An object passing this test has a
__
get
__
attribute but not a
__
set
__
attribute, but beyond that the set of attributes varies.
__
name
__
is
usually sensible, and
__
doc
__
often is.
Methods implemented via descriptors that also pass one of the other
tests return false from the ismethoddescriptor() test, simply because
the other tests promise more -- you can, e.g., count on having the
im
_
func attribute (etc) when an object passes ismethod().
\end{funcdesc}
\begin{funcdesc}
{
isdatadescriptor
}{
object
}
Return true if the object is a data descriptor.
Data descriptors have both a
__
get
__
and a
__
set
__
attribute. Examples are
properties (defined in Python) and getsets and members (defined in C).
Typically, data descriptors will also have
__
name
__
and
__
doc
__
attributes
(properties, getsets, and members have both of these attributes), but this
is not guaranteed.
\end{funcdesc}
\subsection
{
Retrieving source code
\label
{
inspect-source
}}
...
...
Lib/inspect.py
Dosyayı görüntüle @
e59e2bab
...
...
@@ -78,6 +78,16 @@ def ismethoddescriptor(object):
and
not
isfunction
(
object
)
and
not
isclass
(
object
))
def
isdatadescriptor
(
object
):
"""Return true if the object is a data descriptor.
Data descriptors have both a __get__ and a __set__ attribute. Examples are
properties (defined in Python) and getsets and members (defined in C).
Typically, data descriptors will also have __name__ and __doc__ attributes
(properties, getsets, and members have both of these attributes), but this
is not guaranteed."""
return
(
hasattr
(
object
,
"__set__"
)
and
hasattr
(
object
,
"__get__"
))
def
isfunction
(
object
):
"""Return true if the object is a user-defined function.
...
...
Lib/pydoc.py
Dosyayı görüntüle @
e59e2bab
...
...
@@ -686,7 +686,7 @@ class HTMLDoc(Doc):
push
(
msg
)
for
name
,
kind
,
homecls
,
value
in
ok
:
base
=
self
.
docother
(
getattr
(
object
,
name
),
name
,
mod
)
if
callable
(
value
):
if
callable
(
value
)
or
inspect
.
isdatadescriptor
(
value
)
:
doc
=
getattr
(
value
,
"__doc__"
,
None
)
else
:
doc
=
None
...
...
@@ -1087,7 +1087,7 @@ class TextDoc(Doc):
hr
.
maybe
()
push
(
msg
)
for
name
,
kind
,
homecls
,
value
in
ok
:
if
callable
(
value
):
if
callable
(
value
)
or
inspect
.
isdatadescriptor
(
value
)
:
doc
=
getattr
(
value
,
"__doc__"
,
None
)
else
:
doc
=
None
...
...
Lib/test/test_inspect.py
Dosyayı görüntüle @
e59e2bab
...
...
@@ -61,6 +61,7 @@ class FesteringGob(MalodorousPervert, ParrotDroppings):
# isbuiltin, isroutine, getmembers, getdoc, getfile, getmodule,
# getsourcefile, getcomments, getsource, getclasstree, getargspec,
# getargvalues, formatargspec, formatargvalues, currentframe, stack, trace
# isdatadescriptor
from
test.test_support
import
TestFailed
,
TESTFN
import
sys
,
imp
,
os
,
string
...
...
@@ -104,6 +105,8 @@ istest(inspect.ismethod, 'mod.StupidGit.abuse')
istest
(
inspect
.
ismethod
,
'git.argue'
)
istest
(
inspect
.
ismodule
,
'mod'
)
istest
(
inspect
.
istraceback
,
'tb'
)
istest
(
inspect
.
isdatadescriptor
,
'__builtins__.file.closed'
)
istest
(
inspect
.
isdatadescriptor
,
'__builtins__.file.softspace'
)
test
(
inspect
.
isroutine
(
mod
.
spam
),
'isroutine(mod.spam)'
)
test
(
inspect
.
isroutine
([]
.
count
),
'isroutine([].count)'
)
...
...
Misc/NEWS
Dosyayı görüntüle @
e59e2bab
...
...
@@ -21,6 +21,9 @@ Extension modules
Library
-------
- inspect.is{method|data}descriptor was added, to allow pydoc display
__doc__ of data descriptors.
- Fixed socket speed loss caused by use of the _socketobject wrapper class
in socket.py.
...
...
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