-
-
Notifications
You must be signed in to change notification settings - Fork 33.3k
Minor edits to the Descriptor HowTo Guide #24901
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
58b799d
f77b0f9
1dbd876
d0d301e
e87fe37
52a06d0
2f9971b
2f335ca
4886dbb
705c577
c0e6432
81ec93c
34eef3a
ae8c622
1d5fb96
4671b91
0a132bf
62fe4fc
1252f4b
58ae977
5630c64
bfb33f7
5d45eaa
c853e6b
bcc9da0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -940,6 +940,8 @@ here is a pure Python equivalent: | |
| self._name = name | ||
|
|
||
| def __get__(self, obj, objtype=None): | ||
| if obj is None and objtype is None: | ||
| raise TypeError('__get__(None, None) is invalid') | ||
geryogam marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| if obj is None: | ||
| return self | ||
| if self.fget is None: | ||
|
|
@@ -1087,6 +1089,8 @@ during dotted lookup from an instance. Here's how it works: | |
|
|
||
| def __get__(self, obj, objtype=None): | ||
| "Simulate func_descr_get() in Objects/funcobject.c" | ||
| if obj is None and objtype is None: | ||
geryogam marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| raise TypeError('__get__(None, None) is invalid') | ||
geryogam marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| if obj is None: | ||
| return self | ||
| return MethodType(self, obj) | ||
|
|
@@ -1214,6 +1218,8 @@ Using the non-data descriptor protocol, a pure Python version of | |
| self.f = f | ||
|
|
||
| def __get__(self, obj, objtype=None): | ||
| if obj is None and objtype is None: | ||
| raise TypeError('__get__(None, None) is invalid') | ||
| return self.f | ||
|
|
||
|
|
||
|
|
@@ -1277,6 +1283,8 @@ Using the non-data descriptor protocol, a pure Python version of | |
| self.f = f | ||
|
|
||
| def __get__(self, obj, cls=None): | ||
| if obj is None and cls is None: | ||
| raise TypeError('__get__(None, None) is invalid') | ||
geryogam marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| if cls is None: | ||
| cls = type(obj) | ||
| if hasattr(self.f, '__get__'): | ||
|
||
|
|
@@ -1432,6 +1440,8 @@ by member descriptors: | |
| def __get__(self, obj, objtype=None): | ||
| 'Emulate member_get() in Objects/descrobject.c' | ||
| # Also see PyMember_GetOne() in Python/structmember.c | ||
| if obj is None and objtype is None: | ||
| raise TypeError('__get__(None, None) is invalid') | ||
geryogam marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| value = obj._slotvalues[self.offset] | ||
| if value is null: | ||
| raise AttributeError(self.name) | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.