| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| Fix :exc:`TypeError` when a :class:`ctypes.Structure` has a field size | ||
| that doesn't fit into an unsigned 16-bit integer. | ||
| Instead, the maximum number of *bits* is :data:`sys.maxsize`. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| Expand Up | @@ -292,7 +292,7 @@ PyCStructUnionType_update_stginfo(PyObject *type, PyObject *fields, int isStruct | |
| if (!tmp) { | ||
| goto error; | ||
| } | ||
| Py_ssize_t total_align = PyLong_AsInt(tmp); | ||
| Py_ssize_t total_align = PyLong_AsSsize_t(tmp); | ||
| Py_DECREF(tmp); | ||
| if (total_align < 0) { | ||
| if (!PyErr_Occurred()) { | ||
| Expand All | @@ -306,7 +306,7 @@ PyCStructUnionType_update_stginfo(PyObject *type, PyObject *fields, int isStruct | |
| if (!tmp) { | ||
| goto error; | ||
| } | ||
| Py_ssize_t total_size = PyLong_AsInt(tmp); | ||
| Py_ssize_t total_size = PyLong_AsSsize_t(tmp); | ||
|
Comment thread
Copy link
Copy Markdown
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityWhat was a reason for using PyLong_AsInt(). This is a new API, so it unlikely was accident. Is there a limitation on total_size to be in the range of int?
Sorry, something went wrong.
All reactions
Copy link
Copy Markdown
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityIt was an accident -- my mistake.
Sorry, something went wrong.
All reactions
|
||
| Py_DECREF(tmp); | ||
| if (total_size < 0) { | ||
| if (!PyErr_Occurred()) { | ||
| Expand Down | ||
| Back | FazBrowse Home | New Git URL |
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.
Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityCan this be guaranteed? What if bit_size_obj is not None and is not an int?
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
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.
Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityIt can.
The implementation is split between internal Python code in ctypes._layout, and C code here. They are currently tightly coupled. The assert also verifies the Python part.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.