Skip to content

Conversation

@corona10
Copy link
Member

@corona10 corona10 commented Dec 9, 2025

@corona10 corona10 requested a review from encukou December 10, 2025 00:09
}
#else
/* naming not supported on this platform */
PyErr_SetString(PyExc_ValueError,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In ssl.c we usually raise a NotImplementedError in such cases. If you always want to raise the same error, I suggest that you document this ValueError.

result = m.set_name(long_name)
self.assertIsNone(result)

# Test name too long
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a test with NUL bytes inside it?

mmap_mmap_set_name_impl(mmap_object *self, const char *name)
/*[clinic end generated code: output=1edaf4fd51277760 input=6c7dd91cad205f07]*/
{
const char* prefix = "cpython:mmap:";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const char* prefix = "cpython:mmap:";
const char *prefix = "cpython:mmap:";

Alternatively you can use a macro and in the printf have MACRO "%s" as a format string instead. Same idea as usages of PRI* macros

m = mmap.mmap(-1, PAGESIZE)
self.addCleanup(m.close)
result = m.set_name('test_mapping')
self.assertIsNone(result)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be possible to add a functional test? Read /proc/pid/maps and check if it contains the string.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to check kernel version and kernel configuration. So it would emit falsy result.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the Linux version, you can use @requires_linux_version(x, y, z) decorator. What do you mean by configuration? The feature can be disabled when Linux is configured?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As I said before this feature is not enabled for Fedora by default even the kernel version is satisfied

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you prefer adding a kernel-configuration checking utility that reads from /proc/config.gz, /proc/config, or /proc/config-$(uname -r)?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Other thing: Do you know how to inject -X dev while running unittest through CI explicitly?

@corona10
Copy link
Member Author

@picnixz @vstinner PTAL :)

@corona10 corona10 requested a review from picnixz December 11, 2025 01:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants