-
-
Notifications
You must be signed in to change notification settings - Fork 33.7k
bpo-26103 resolve Data descriptor contradiction #1959
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
bpo-26103 resolve Data descriptor contradiction #1959
Conversation
|
@aaronchall, thanks for your PR! By analyzing the history of the files in this pull request, we identified @zestyping, @ethanfurman and @birkenfeld to be potential reviewers. |
…l/cpython into datadescrcontradiction
…l/cpython into datadescrcontradiction must add tests
Lib/test/test_inspect.py
Outdated
| class TestIsDataDescriptor(unittest.TestCase): | ||
|
|
||
| def test_custom_descriptors(self): | ||
| class NonDataDescriptor(object): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do you specify the object class for the parent ? it is not required https://docs.python.org/3/reference/compound_stmts.html#class-definitions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could be backported to 2, it is ostensibly fixing an incorrect implementation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Keep the Python 3 code clear. Add the object class in a backport to Python 2.
|
As it currently stands I am perfectly happy with this revision, but I am more than willing to consider change requests. |
Lib/test/test_inspect.py
Outdated
| class TestIsDataDescriptor(unittest.TestCase): | ||
|
|
||
| def test_custom_descriptors(self): | ||
| class NonDataDescriptor(object): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Keep the Python 3 code clear. Add the object class in a backport to Python 2.
Lib/test/test_inspect.py
Outdated
|
|
||
| def test_functions(self): | ||
| class Test(object): | ||
| def instance_method(self): '' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use pass for empty body.
Lib/test/test_inspect.py
Outdated
| a_lambda = lambda: '' | ||
| self.assertFalse(inspect.isdatadescriptor(type(Test().instance_method)), | ||
| 'a instance method is not a data descriptor') | ||
| self.assertFalse(inspect.isdatadescriptor(classmethod), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why you test classmethod? Note that the type of class method is not classmethod.
Lib/test/test_inspect.py
Outdated
| 'a instance method is not a data descriptor') | ||
| self.assertFalse(inspect.isdatadescriptor(classmethod), | ||
| 'a class method is not a data descriptor') | ||
| self.assertFalse(inspect.isdatadescriptor(staticmethod), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ditto.
| attrs = [a[0] for a in inspect.getmembers(C)] | ||
| self.assertNotIn('missing', attrs) | ||
|
|
||
| class TestIsDataDescriptor(unittest.TestCase): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These tests are not ran. Add the test class in run_unittest() list below.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added
Lib/test/test_inspect.py
Outdated
| def __delete__(self, name): "" | ||
| class DataDescriptor2(object): | ||
| __set__ = None | ||
| self.assertFalse(inspect.isdatadescriptor(NonDataDescriptor), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This returns False because NonDataDescriptor is a class.
Lib/test/test_inspect.py
Outdated
| __set__ = None | ||
| self.assertFalse(inspect.isdatadescriptor(NonDataDescriptor), | ||
| 'class with only __get__ not a data descriptor') | ||
| self.assertTrue(inspect.isdatadescriptor(DataDescriptor0), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test would fail if TestIsDataDescriptor run.
|
A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated. Once you have made the requested changes, please leave a comment on this pull request containing the phrase |
|
I thought it was, "I didn't expect a kind of Spanish Inquisition!" not, I didn't expect the Spanish Inquisition! |
|
Nobody expects the Spanish Inquisition! @serhiy-storchaka: please review the changes made to this pull request. |
|
@serhiy-storchaka Do you want an entry in the Misc/NEWS.d directory? If I do that, should I remove the entry in Misc/NEWS? |
|
|
serhiy-storchaka
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you @aaronchall! LGTM. But since this is related to delicate matters, it would be nice if yet one core dev will take a look.
|
In general, this seems fine. My one nit is that rather than "and/or", let's just say "or". "and/or" is jargony. |
|
@benjaminp done, however, the "appveyor" build failed - not sure why, appears to be irrelevant. |
https://bugs.python.org/issue26103