GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||
GeezerVison is showing github.com — gh-143715: deprecate incomplete initialization of struct.Struct() by skirpichev · Pull Request #143659 · python/cpython Conversation
|
|
The evil plan is to remove custom |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
This make format argument in the __init__() - optional. If it's missing, the object must be already initialized in __new__().
|
CC @meadori per experts index. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Co-authored-by: Victor Stinner <[email protected]>
@serhiy-storchaka, this seems too complex for me. Look, we are going to that state: #94532. (I did a working patch to play with in skirpichev#17.) That means, eventually the Struct's Thus, we should warn users on this pattern: explicit call of the CC @vstinner |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
This catch current pattern for Struct's subclassing like
class MyStruct(Struct):
def __init__(self):
super().__init__('>h')
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
The overall change LGTM, but I have a few more minor comments.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Co-authored-by: Victor Stinner <[email protected]>
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
@serhiy-storchaka: Do you want to review this change?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
I tried to fix corner cases, but since all code and tests were rewritten, I created a separate PR #145580. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Ah, I forgot that |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Apparently, this overflowed my bandwidth. I'm happy to see the issue is in more qualified hands now. The #145580 looks ok for me, but I worry that such approach is much more complex just to satisfy the constraint:
Transition could be handled with, say: if sys.version_info < (3, 15): # old idiom: class MyStruct(struct.Struct): def __init__(self): super().__init__('>h') else: # new idiom: class MyStruct2(struct.Struct): def __new__(cls): self = super().__new__(cls, '>h') return self Thanks for reviews! |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.