Skip to content

Commit

Permalink
revert global var
Browse files Browse the repository at this point in the history
  • Loading branch information
Fidget-Spinner committed Jun 15, 2024
1 parent 990b050 commit 1fe6cfe
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 11 deletions.
1 change: 0 additions & 1 deletion Include/cpython/pystate.h
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,6 @@ struct _ts {
int fileutils_ioctl_works;
int fileutils_skiproot_initialized;
int fileutils_combineex_initialized;
int fileutils__Py_open_cloexec_works;
};

#ifdef Py_DEBUG
Expand Down
21 changes: 11 additions & 10 deletions Python/fileutils.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,16 @@ extern int winerror_to_errno(int);
# include <fcntl.h> // fcntl(F_GETFD)
#endif

#ifdef O_CLOEXEC
/* Does open() support the O_CLOEXEC flag? Possible values:
-1: unknown
0: open() ignores O_CLOEXEC flag, ex: Linux kernel older than 2.6.23
1: open() supports O_CLOEXEC flag, close-on-exec is set
The flag is used by _Py_open(), _Py_open_noraise(), io.FileIO
and os.open(). */
int _Py_open_cloexec_works = -1;
#endif

// The value must be the same in unicodeobject.c.
#define MAX_UNICODE 0x10ffff

Expand Down Expand Up @@ -1614,16 +1624,7 @@ _Py_open_impl(const char *pathname, int flags, int gil_held)
#ifdef MS_WINDOWS
flags |= O_NOINHERIT;
#elif defined(O_CLOEXEC)
PyThreadState *tstate = PyThreadState_Get();
/* Does open() support the O_CLOEXEC flag? Possible values:
-1: unknown
0: open() ignores O_CLOEXEC flag, ex: Linux kernel older than 2.6.23
1: open() supports O_CLOEXEC flag, close-on-exec is set
The flag is used by _Py_open(), _Py_open_noraise(), io.FileIO
and os.open(). */
atomic_flag_works = &tstate->fileutils__Py_open_cloexec_works;
atomic_flag_works = &_Py_open_cloexec_works;
flags |= O_CLOEXEC;
#else
atomic_flag_works = NULL;
Expand Down
4 changes: 4 additions & 0 deletions Tools/c-analyzer/TODO
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ Objects/bytesobject.c:_Py_onel_strings Py_ssize_t _Py_
Objects/dictobject.c:empty_keys_struct static PyDictKeysObject empty_keys_struct


# "initialized"
Python/fileutils.c:_Py_open_cloexec_works int _Py_open_cloexec_works


# other non-object (40)
Modules/_tracemalloc.c:allocators static struct { PyMemAllocatorEx mem; PyMemAllocatorEx raw; PyMemAllocatorEx obj; } allocators
Modules/_tracemalloc.c:tables_lock static PyThread_type_lock tables_lock
Expand Down

0 comments on commit 1fe6cfe

Please sign in to comment.