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-111089: PyUnicode_AsUTF8AndSize() sets size on error by vstinner · Pull Request #111106 · python/cpython Conversation
|
|
See also PR #111100: Add tests for failing PyUnicode_AsUTF8AndSize() with psize=NULL. |
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.
LGTM. See also #110865.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
|
||
| In the case of an error, ``NULL`` is returned with an exception set and no | ||
| *size* is stored. | ||
| On error, set an exception, set *size* to 0 (if it's not NULL) and return |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
| On error, set an exception, set *size* to 0 (if it's not NULL) and return | |
| On error, set an exception, set *size* to ``0`` (if it's not ``NULL``) and return |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Why set size to 0, and not to -1? There is larger chance to miss error. For example |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
On error, PyUnicode_AsUTF8AndSize() now sets the size argument to -1, to avoid undefined value.
585158d to
ae7734d
Compare
That's a very good idea! I updated my PR to set size of -1 on error. I just picked 0 randomly. I forgot that size can be negative. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Oh, tests failed with: |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
I failed to reproduce the Sphinx crash locally. And the test passed when run again. I merged my PR, thanks for review Serhiy. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
…#111106) On error, PyUnicode_AsUTF8AndSize() now sets the size argument to -1, to avoid undefined value.
…#111106) On error, PyUnicode_AsUTF8AndSize() now sets the size argument to -1, to avoid undefined value.
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.