Skip to content

Conversation

@serhiy-storchaka
Copy link
Member

@serhiy-storchaka serhiy-storchaka commented Dec 9, 2018

if (PyDict_SetItem(d, k, v) != 0)
PyErr_Clear();
if (PyDict_GetItemWithError(d, k) == NULL) {
if (PyErr_Occurred() || PyDict_SetItem(d, k, v) != 0) {
Copy link
Contributor

Choose a reason for hiding this comment

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

These two ifs could be merged.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, but the resulting condition will be too complex and will need more parentheses and line breaks in any case. I do not think it will look better.

if ((PyDict_GetItemWithError(d, k) == NULL) &&
    (PyErr_Occurred() || PyDict_SetItem(d, k, v) != 0))
{

@serhiy-storchaka serhiy-storchaka merged commit 6fef0f1 into python:master Dec 10, 2018
@serhiy-storchaka serhiy-storchaka deleted the convertenviron-errors branch December 10, 2018 10:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants