forked from python/cpython
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Modules/_testcapi/util.h header (pythonGH-108774)
It contains common macros used in C API tests.
- Loading branch information
1 parent
578ebc5
commit 0e01fac
Showing
7 changed files
with
49 additions
and
94 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#define NULLABLE(x) do { \ | ||
if (x == Py_None) { \ | ||
x = NULL; \ | ||
} \ | ||
} while (0); | ||
|
||
#define RETURN_INT(value) do { \ | ||
int _ret = (value); \ | ||
if (_ret == -1) { \ | ||
assert(PyErr_Occurred()); \ | ||
return NULL; \ | ||
} \ | ||
assert(!PyErr_Occurred()); \ | ||
return PyLong_FromLong(_ret); \ | ||
} while (0) | ||
|
||
#define RETURN_SIZE(value) do { \ | ||
Py_ssize_t _ret = (value); \ | ||
if (_ret == -1) { \ | ||
assert(PyErr_Occurred()); \ | ||
return NULL; \ | ||
} \ | ||
assert(!PyErr_Occurred()); \ | ||
return PyLong_FromSsize_t(_ret); \ | ||
} while (0) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters