FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

gh-59705: Make PYTHREAD_NAME_MAXLEN macro private by vstinner · Pull Request #128945 · python/cpython · GitHub

/ cpython Public
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .ac  (1) .c  (1) .in  (2) No extension  (1) All 4 file types selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
20 changes: 10 additions & 10 deletions Modules/_threadmodule.c
This file contains hidden or 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
Expand Up @@ -2450,12 +2450,12 @@ _thread_set_name_impl(PyObject *module, PyObject *name_obj)
return NULL;
}

#ifdef PYTHREAD_NAME_MAXLEN
// Truncate to PYTHREAD_NAME_MAXLEN bytes + the NUL byte if needed
if (PyBytes_GET_SIZE(name_encoded) > PYTHREAD_NAME_MAXLEN) {
#ifdef _PYTHREAD_NAME_MAXLEN
// Truncate to _PYTHREAD_NAME_MAXLEN bytes + the NUL byte if needed
if (PyBytes_GET_SIZE(name_encoded) > _PYTHREAD_NAME_MAXLEN) {
PyObject *truncated;
truncated = PyBytes_FromStringAndSize(PyBytes_AS_STRING(name_encoded),
PYTHREAD_NAME_MAXLEN);
_PYTHREAD_NAME_MAXLEN);
if (truncated == NULL) {
Py_DECREF(name_encoded);
return NULL;
Expand Down Expand Up @@ -2490,14 +2490,14 @@ _thread_set_name_impl(PyObject *module, PyObject *name_obj)
return NULL;
}

if (len > PYTHREAD_NAME_MAXLEN) {
if (len > _PYTHREAD_NAME_MAXLEN) {
// Truncate the name
Py_UCS4 ch = name[PYTHREAD_NAME_MAXLEN-1];
Py_UCS4 ch = name[_PYTHREAD_NAME_MAXLEN-1];
if (Py_UNICODE_IS_HIGH_SURROGATE(ch)) {
name[PYTHREAD_NAME_MAXLEN-1] = 0;
name[_PYTHREAD_NAME_MAXLEN-1] = 0;
}
else {
name[PYTHREAD_NAME_MAXLEN] = 0;
name[_PYTHREAD_NAME_MAXLEN] = 0;
}
}

Expand Down Expand Up @@ -2645,9 +2645,9 @@ thread_module_exec(PyObject *module)

llist_init(&state->shutdown_handles);

#ifdef PYTHREAD_NAME_MAXLEN
#ifdef _PYTHREAD_NAME_MAXLEN
if (PyModule_AddIntConstant(module, "_NAME_MAXLEN",
PYTHREAD_NAME_MAXLEN) < 0) {
_PYTHREAD_NAME_MAXLEN) < 0) {
return -1;
}
#endif
Expand Down
5 changes: 2 additions & 3 deletions PC/pyconfig.h.in
Comment thread
vstinner marked this conversation as resolved.
This file contains hidden or 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
Expand Up @@ -753,8 +753,7 @@ Py_NO_ENABLE_SHARED to find out. Also support MS_NO_COREDLL for b/w compat */
/* Define if libssl has X509_VERIFY_PARAM_set1_host and related function */
#define HAVE_X509_VERIFY_PARAM_SET1_HOST 1

// Truncate the thread name to 64 characters. The OS limit is 32766 wide
// characters, but long names aren't of practical use.
#define PYTHREAD_NAME_MAXLEN 32766
// Truncate the thread name to 32766 characters.
#define _PYTHREAD_NAME_MAXLEN 32766

#endif /* !Py_CONFIG_H */
20 changes: 10 additions & 10 deletions configure

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 10 additions & 10 deletions configure.ac
This file contains hidden or 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
Expand Up @@ -7539,19 +7539,19 @@ _RESTORE_VAR([CPPFLAGS])

# gh-59705: Maximum length in bytes of a thread name
case "$ac_sys_system" in
Linux*) PYTHREAD_NAME_MAXLEN=15;; # Linux and Android
SunOS*) PYTHREAD_NAME_MAXLEN=31;;
NetBSD*) PYTHREAD_NAME_MAXLEN=31;;
Darwin) PYTHREAD_NAME_MAXLEN=63;;
iOS) PYTHREAD_NAME_MAXLEN=63;;
FreeBSD*) PYTHREAD_NAME_MAXLEN=98;;
*) PYTHREAD_NAME_MAXLEN=;;
Linux*) _PYTHREAD_NAME_MAXLEN=15;; # Linux and Android
SunOS*) _PYTHREAD_NAME_MAXLEN=31;;
NetBSD*) _PYTHREAD_NAME_MAXLEN=31;;
Darwin) _PYTHREAD_NAME_MAXLEN=63;;
iOS) _PYTHREAD_NAME_MAXLEN=63;;
FreeBSD*) _PYTHREAD_NAME_MAXLEN=98;;
*) _PYTHREAD_NAME_MAXLEN=;;
esac
if test -n "$PYTHREAD_NAME_MAXLEN"; then
AC_DEFINE_UNQUOTED([PYTHREAD_NAME_MAXLEN], [$PYTHREAD_NAME_MAXLEN],
if test -n "$_PYTHREAD_NAME_MAXLEN"; then
AC_DEFINE_UNQUOTED([_PYTHREAD_NAME_MAXLEN], [$_PYTHREAD_NAME_MAXLEN],
[Maximum length in bytes of a thread name])
fi
AC_SUBST([PYTHREAD_NAME_MAXLEN])
AC_SUBST([_PYTHREAD_NAME_MAXLEN])


# stdlib
Expand Down
6 changes: 3 additions & 3 deletions pyconfig.h.in
This file contains hidden or 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
Expand Up @@ -1662,9 +1662,6 @@
/* Define as the preferred size in bits of long digits */
#undef PYLONG_BITS_IN_DIGIT

/* Maximum length in bytes of a thread name */
#undef PYTHREAD_NAME_MAXLEN

/* enabled builtin hash modules */
#undef PY_BUILTIN_HASHLIB_HASHES

Expand Down Expand Up @@ -1980,6 +1977,9 @@
/* framework name */
#undef _PYTHONFRAMEWORK

/* Maximum length in bytes of a thread name */
#undef _PYTHREAD_NAME_MAXLEN

/* Define to force use of thread-safe errno, h_errno, and other functions */
#undef _REENTRANT

Expand Down

Back | FazBrowse Home | New Git URL