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-78724: raise RuntimeError's when calling methods on non-ready Struct()'s by skirpichev · Pull Request #143643 · python/cpython Conversation
|
| { | ||
| PyObject *self; | ||
|
|
||
| if (PyTuple_GET_SIZE(args) != 1 |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
I do not see how can this be useful.
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.
This is to trigger deprecation warning in a following scenario:
>>> import struct >>> class MyStruct(struct.Struct): ... def __init__(self): ... super().__init__('>h') ... >>> my_struct = MyStruct() <python-input-2>:1: DeprecationWarning: Struct().__new__() has one required argument
PS: deprecation part moved to #143659.
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.
I think it's already the case. We can move a bit s_size/s_len assignments, but as far as we interested only in s_codes - I'm not sure if it's worth. There should be no failures after |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Well, it does not matter. It would reduce the chance of race condition, but nobody should run |
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.
| self.assertRaises(RuntimeError, meth, spam) | ||
| self.assertRaises(RuntimeError, S.iter_unpack, 1) | ||
| self.assertRaises(RuntimeError, S.pack, 1) | ||
| self.assertRaises(RuntimeError, S.pack_into, 1) |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
S.pack_into(buffer, offset, v1, v2, ...)
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.
BTW, I think that argument processing in the struct's functions/methods should be refactored and transformed to the AC. E.g. S.pack_info could check required arguments before validation of the soself struct.
Though, this belongs to a separate issue.
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.
AC cleanup goes to #143673
Sorry, something went wrong.
There was an error while loading. Please reload this page.
I guess this belongs to the #143382 pr thread. |
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 a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
LGTM. 👍
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
Thanks @skirpichev for the PR, and @serhiy-storchaka for merging it 🌮🎉.. I'm working now to backport this PR to: 3.13, 3.14. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
…y Struct()'s (pythonGH-143643) (cherry picked from commit 515ae40) Co-authored-by: Sergey B Kirpichev <[email protected]>
|
Sorry, @skirpichev and @serhiy-storchaka, I could not cleanly backport this to |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
GH-143695 is a backport of this pull request to the 3.14 branch. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
GH-143714 is a backport of this pull request to the 3.13 branch. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
…dy Struct()'s (GH-143643) (GH-143695) (cherry picked from commit 515ae40) Co-authored-by: Sergey B Kirpichev <[email protected]>
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.