Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork32k
bpo-46398: posixshmem module shm_rename freebsd support.#30621
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
base:main
Are you sure you want to change the base?
Conversation
36de652
to4bec161
CompareThis PR is stale because it has been open for 30 days with no activity. |
This comment was marked as outdated.
This comment was marked as outdated.
Rename a shared memory object. | ||
Remove a shared memory object and relink to another path |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Removeasharedmemoryobjectandrelinktoanotherpath | |
Removeasharedmemoryobjectandrelinktoanotherpath. |
_posixshmem.shm_rename | ||
path_from: unicode | ||
path_to: unicode | ||
flags: int |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
flags:int | |
flags:int | |
/ |
I think it was mistake to make parameters keyword-or-positional in other functions. It is better to make them positional-only, it will help if we decide to rename parameters.
Lib/multiprocessing/shared_memory.py Outdated
With the SHM_RENAME_NOREPLACE flag, an error will be returned | ||
if the new name exists. | ||
""" | ||
if platform.system() != "FreeBSD": |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
It is better to usehasattr()
. If in futureshm_rename()
be added on other platforms, it will automatically add support of SharedMemory.rename().
const char *from = PyUnicode_AsUTF8(path_from); | ||
const char *to = PyUnicode_AsUTF8(path_to); | ||
if (from == NULL || to == NULL) { | ||
return NULL; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
This function has the same bug as shm_open() and shm_unlink() (see#115886). Please check the names for embedded null characters.
Lib/multiprocessing/shared_memory.py Outdated
if newname: | ||
newname = "/" + newname if self._prepend_leading_slash else newname | ||
r = _posixshmem.shm_rename(self._name, newname, flags) | ||
if r == None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
It is always true, isn't?
if platform.system() != "FreeBSD": | ||
raise OSError("Unsupported operation on this platform") | ||
if newname: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
So it simply returns False if newname is empty and returns True otherwise? Why add such check in this method?
With the SHM_RENAME_NOREPLACE flag, an error will be returned | ||
if the new name exists. | ||
""" | ||
if !platform.hasattr("shm_rename"): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
if!platform.hasattr("shm_rename"): | |
ifnotplatform.hasattr("shm_rename"): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
What is this platform.hasattr() function? Where does it come from?
Uh oh!
There was an error while loading.Please reload this page.
https://bugs.python.org/issue46398