Skip to content

gh-133256: Add _Py_NONSTRING macro #133257

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 1, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Include/internal/pycore_debug_offsets.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ extern "C" {


typedef struct _Py_DebugOffsets {
char cookie[8];
char cookie[8] _Py_NONSTRING;
uint64_t version;
uint64_t free_threaded;
// Runtime state offset;
Expand Down
15 changes: 15 additions & 0 deletions Include/pyport.h
Original file line number Diff line number Diff line change
Expand Up @@ -685,4 +685,19 @@ extern "C" {
#endif


// _Py_NONSTRING: The nonstring variable attribute specifies that an object or
// member declaration with type array of char, signed char, or unsigned char,
// or pointer to such a type is intended to store character arrays that do not
// necessarily contain a terminating NUL.
//
// Usage:
//
// char name [8] _Py_NONSTRING;
#if _Py__has_attribute(nonstring)
# define _Py_NONSTRING __attribute__((nonstring))
#else
# define _Py_NONSTRING
#endif


#endif /* Py_PYPORT_H */
2 changes: 1 addition & 1 deletion Modules/fcntlmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

#define GUARDSZ 8
// NUL followed by random bytes.
static const char guard[GUARDSZ] = "\x00\xfa\x69\xc4\x67\xa3\x6c\x58";
static const char guard[GUARDSZ] _Py_NONSTRING = "\x00\xfa\x69\xc4\x67\xa3\x6c\x58";

/*[clinic input]
module fcntl
Expand Down
Loading