bpo-26103 resolve Data descriptor contradiction#1959
bpo-26103 resolve Data descriptor contradiction#1959serhiy-storchaka merged 20 commits intopython:masterfrom
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.
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.
This could be backported to 2, it is ostensibly fixing an incorrect implementation.
There was a problem hiding this comment.
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.
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.
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.
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), |
| attrs = [a[0] for a in inspect.getmembers(C)] | ||
| self.assertNotIn('missing', attrs) | ||
|
|
||
| class TestIsDataDescriptor(unittest.TestCase): |
There was a problem hiding this comment.
These tests are not ran. Add the test class in run_unittest() list below.
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.
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.
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.
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