|
1 | 1 | #include "Python.h" |
2 | 2 | #include "pycore_fileutils.h" // fileutils definitions |
3 | 3 | #include "pycore_runtime.h" // _PyRuntime |
| 4 | +#include "pycore_pystate.h" // _Py_AssertHoldsTstate |
4 | 5 | #include "osdefs.h" // SEP |
5 | 6 |
|
6 | 7 | #include <stdlib.h> // mbstowcs() |
@@ -1311,7 +1312,7 @@ _Py_fstat(int fd, struct _Py_stat_struct *status) |
1311 | 1312 | { |
1312 | 1313 | int res; |
1313 | 1314 |
|
1314 | | - assert(PyGILState_Check()); |
| 1315 | + _Py_AssertHoldsTstate(); |
1315 | 1316 |
|
1316 | 1317 | Py_BEGIN_ALLOW_THREADS |
1317 | 1318 | res = _Py_fstat_noraise(fd, status); |
@@ -1691,7 +1692,7 @@ int |
1691 | 1692 | _Py_open(const char *pathname, int flags) |
1692 | 1693 | { |
1693 | 1694 | /* _Py_open() must be called with the GIL held. */ |
1694 | | - assert(PyGILState_Check()); |
| 1695 | + _Py_AssertHoldsTstate(); |
1695 | 1696 | return _Py_open_impl(pathname, flags, 1); |
1696 | 1697 | } |
1697 | 1698 |
|
@@ -1770,7 +1771,7 @@ _Py_fopen_obj(PyObject *path, const char *mode) |
1770 | 1771 | wchar_t wmode[10]; |
1771 | 1772 | int usize; |
1772 | 1773 |
|
1773 | | - assert(PyGILState_Check()); |
| 1774 | + _Py_AssertHoldsTstate(); |
1774 | 1775 |
|
1775 | 1776 | if (PySys_Audit("open", "Osi", path, mode, 0) < 0) { |
1776 | 1777 | return NULL; |
@@ -1806,7 +1807,7 @@ _Py_fopen_obj(PyObject *path, const char *mode) |
1806 | 1807 | PyObject *bytes; |
1807 | 1808 | const char *path_bytes; |
1808 | 1809 |
|
1809 | | - assert(PyGILState_Check()); |
| 1810 | + _Py_AssertHoldsTstate(); |
1810 | 1811 |
|
1811 | 1812 | if (!PyUnicode_FSConverter(path, &bytes)) |
1812 | 1813 | return NULL; |
@@ -1862,7 +1863,7 @@ _Py_read(int fd, void *buf, size_t count) |
1862 | 1863 | int err; |
1863 | 1864 | int async_err = 0; |
1864 | 1865 |
|
1865 | | - assert(PyGILState_Check()); |
| 1866 | + _Py_AssertHoldsTstate(); |
1866 | 1867 |
|
1867 | 1868 | /* _Py_read() must not be called with an exception set, otherwise the |
1868 | 1869 | * caller may think that read() was interrupted by a signal and the signal |
@@ -2028,7 +2029,7 @@ _Py_write_impl(int fd, const void *buf, size_t count, int gil_held) |
2028 | 2029 | Py_ssize_t |
2029 | 2030 | _Py_write(int fd, const void *buf, size_t count) |
2030 | 2031 | { |
2031 | | - assert(PyGILState_Check()); |
| 2032 | + _Py_AssertHoldsTstate(); |
2032 | 2033 |
|
2033 | 2034 | /* _Py_write() must not be called with an exception set, otherwise the |
2034 | 2035 | * caller may think that write() was interrupted by a signal and the signal |
@@ -2656,7 +2657,7 @@ _Py_dup(int fd) |
2656 | 2657 | HANDLE handle; |
2657 | 2658 | #endif |
2658 | 2659 |
|
2659 | | - assert(PyGILState_Check()); |
| 2660 | + _Py_AssertHoldsTstate(); |
2660 | 2661 |
|
2661 | 2662 | #ifdef MS_WINDOWS |
2662 | 2663 | handle = _Py_get_osfhandle(fd); |
|
0 commit comments