Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
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
Prev Previous commit
Next Next commit
Address code review
  • Loading branch information
corona10 committed Dec 10, 2025
commit bd02cc584f9aa7c3606c82d8ce09f30d77caabd0
2 changes: 1 addition & 1 deletion Lib/test/test_mmap.py
Original file line number Diff line number Diff line change
Expand Up @@ -1165,7 +1165,7 @@ def test_flush_parameters(self):
m.flush(PAGESIZE)
m.flush(PAGESIZE, PAGESIZE)

@unittest.skipUnless(hasattr(mmap, 'MAP_ANONYMOUS'), 'requires MAP_ANONYMOUS')
@unittest.skipUnless(hasattr(mmap, 'MAP_ANONYMOUS') and sys.platform == "linux", 'requires MAP_ANONYMOUS and should be linux')
def test_set_name(self):
# Test setting name on anonymous mmap
m = mmap.mmap(-1, PAGESIZE)
Expand Down
8 changes: 4 additions & 4 deletions Modules/mmapmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -1131,14 +1131,14 @@ static PyObject *
mmap_mmap_set_name_impl(mmap_object *self, const char *name)
/*[clinic end generated code: output=1edaf4fd51277760 input=6c7dd91cad205f07]*/
{
const char* prefix = "cpython:mmap:";
#if defined(MAP_ANONYMOUS) && defined(__linux__)
const char *prefix = "cpython:mmap:";
Comment thread
corona10 marked this conversation as resolved.
if (strlen(name) + strlen(prefix) > 80) {
PyErr_SetString(PyExc_ValueError, "name is too long");
return NULL;
}
#ifdef MAP_ANONYMOUS
if (self->flags & MAP_ANONYMOUS) {
char buf[80] = {0, };
char buf[81] = {0, };
Comment thread
corona10 marked this conversation as resolved.
Outdated
sprintf(buf, "%s%s", prefix, name);
_PyAnnotateMemoryMap(self->data, self->size, buf);
Comment thread
vstinner marked this conversation as resolved.
Outdated
}
Expand All @@ -1150,7 +1150,7 @@ mmap_mmap_set_name_impl(mmap_object *self, const char *name)
}
#else
/* naming not supported on this platform */
PyErr_SetString(PyExc_ValueError,
PyErr_SetString(NotImplementedError,
"Annotation of mmap is not supported on this platform");
return NULL;
#endif
Expand Down