bpo-23578: Show which offset raise error when using struct.pack by louisom · Pull Request #291 · python/cpython · GitHub
Skip to content

bpo-23578: Show which offset raise error when using struct.pack - #291

Closed
louisom wants to merge 7 commits into
python:masterfrom
louisom:bpo-23578
Closed

louisom wants to merge 7 commits into
python:masterfrom
louisom:bpo-23578

Conversation

@louisom

@louisom louisom commented Feb 25, 2017

Copy link
Copy Markdown
Contributor

Adding PyErr_SetString and PyErr_Format wrapper, with a global offset
variable to handle this.

struct.pack('!h', 0x8FFFF)
Traceback (most recent call last):
  File "tests.py", line 5, in <module>
    struct.pack('!h', 0x8FFFF)
struct.error: Raise at offset 1, 'h' format requires -32768 <= number <= 32767

@rhettinger

Copy link
Copy Markdown
Contributor

@louisom

louisom commented Apr 5, 2017

Copy link
Copy Markdown
Contributor Author

@rhettinger I'm not sure about the global variable. Is there any way to test if global variable has the defect when using threads?

louisom added 5 commits April 16, 2017 18:56
Adding PyErr_SetString and PyErr_Format wrapper, with a global offset
variable to handle this.

>>> struct.pack('!h', 0x8FFFF)
Traceback (most recent call last):
  File "tests.py", line 5, in <module>
    struct.pack('!h', 0x8FFFF)
struct.error: Raise at offset 1, 'h' format requires -32768 <= number <= 32767
@louisom

louisom commented Apr 16, 2017

Copy link
Copy Markdown
Contributor Author

@serhiy-storchaka I removed the global offset variable, and add a new parameter pos to corresponding function. Not sure this kind of big change is better than global variable or not.

Could you help me review this? Thanks.

@serhiy-storchaka
serhiy-storchaka self-requested a review April 16, 2017 16:45
@serhiy-storchaka serhiy-storchaka added the type-feature A feature request or enhancement label Dec 8, 2018

@auvipy auvipy left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

plz re base

@csabella

Copy link
Copy Markdown
Contributor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting core review type-feature A feature request or enhancement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants