This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: os.O_SHLOCK and os.O_EXLOCK are not available on Linux
Type: behavior Stage: resolved
Components: Documentation Versions: Python 3.6, Python 3.5, Python 2.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: docs@python Nosy List: Sworddragon, docs@python, matrixise, python-dev, r.david.murray, vinay.sajip
Priority: normal Keywords: easy, patch

Created on 2014-12-23 14:38 by Sworddragon, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
issue23105.diff matrixise, 2016-08-06 12:38 review
Messages (12)
msg233048 - (view) Author: (Sworddragon) Date: 2014-12-23 14:38
From the documentation:

"
os.O_DSYNC
os.O_RSYNC
os.O_SYNC
os.O_NDELAY
os.O_NONBLOCK
os.O_NOCTTY
os.O_SHLOCK
os.O_EXLOCK
os.O_CLOEXEC

    These constants are only available on Unix.
"

But os.O_SHLOCK and os.O_EXLOCK are not available on my system (Linux 3.16.7-ckt1 x86_64):

sworddragon@ubuntu:~$ python3
Python 3.4.2 (default, Dec  4 2014, 09:34:20) 
[GCC 4.9.2] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> os.O_SHLOCK
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute 'O_SHLOCK'
>>> os.O_EXLOCK
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute 'O_EXLOCK'
>>> exit()
msg233050 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2014-12-23 15:39
The documentation says "Some of them are not available on all platforms. For descriptions of their availability and use, consult the open(2) manual page on Unix or the MSDN on Windows.".  The important bit there being "consult the open(2) manual page on Unix" for availability.

That said, since the options are grouped and labeled with per-platform availability...but with a slightly different meaning of the word platform...I think the docs could be clarified.  Do you have a suggestion for rewording that sentence to make it clearer?
msg233051 - (view) Author: (Sworddragon) Date: 2014-12-23 16:11
I have missed the first part of the documentation and am not sure if something needs really to be changed. But if you think so maybe comments like "These constants are only available on Unix." could be extended by the word "commonly" like "These constants are commonly only available on Unix.".
msg272090 - (view) Author: Stéphane Wirtel (matrixise) * (Python committer) Date: 2016-08-06 11:04
If you read the documentation from glibc-2.24, these options are only available on BSD and not on Linux.

"""
The remaining operating modes are BSD extensions. They exist only on some systems. On other systems, these macros are not defined.

Macro: int O_SHLOCK
Acquire a shared lock on the file, as with flock. See File Locks.

If O_CREAT is specified, the locking is done atomically when creating the file. You are guaranteed that no other process will get the lock on the new file first.

Macro: int O_EXLOCK
Acquire an exclusive lock on the file, as with flock. See File Locks. This is atomic like O_SHLOCK.
"""

With my fedora 24, and glibc 2.23 I don't find any reference to these macros.
msg272091 - (view) Author: Stéphane Wirtel (matrixise) * (Python committer) Date: 2016-08-06 11:04
Link to the documentation of glibc:

http://www.gnu.org/software/libc/manual/html_node/Open_002dtime-Flags.html
msg272093 - (view) Author: Stéphane Wirtel (matrixise) * (Python committer) Date: 2016-08-06 11:19
I am working on it.
msg272097 - (view) Author: Stéphane Wirtel (matrixise) * (Python committer) Date: 2016-08-06 12:38
patch for 3.6 with the comment of Sworddragon.
msg272108 - (view) Author: (Sworddragon) Date: 2016-08-06 20:36
If we decide to word it this way eventually the sentence for "Windows only" needs to be updated too. Not sure about the other sentences as they sound a bit if they would guarantee what they say. Maybe somebody else knows more.
msg272112 - (view) Author: Stéphane Wirtel (matrixise) * (Python committer) Date: 2016-08-07 07:32
Which sentence with "Windows only" ?

Thanks
msg272136 - (view) Author: (Sworddragon) Date: 2016-08-07 23:14
Maybe it sounded a bit confusing but this text was not to be meant as a direct match against the documentation.
msg273650 - (view) Author: Vinay Sajip (vinay.sajip) * (Python committer) Date: 2016-08-25 13:56
The existing docs have a section "These constants are GNU extensions and not present if they are not defined by the C library."

There could be a corresponding section for BSD extensions to which O_EXLOCK and O_SHLOCK are moved, or the word "GNU" can removed from the existing section and these two flags moved to it. How does that sound? My preference would be for the latter.
msg275796 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2016-09-11 14:17
New changeset 5ca4c545dfe4 by Vinay Sajip in branch '2.7':
Issue #23105: Updated documentation on open() flag constants.
https://hg.python.org/cpython/rev/5ca4c545dfe4

New changeset f1427491a8a5 by Vinay Sajip in branch '3.5':
Issue #23105: Updated documentation on open() flag constants.
https://hg.python.org/cpython/rev/f1427491a8a5

New changeset 64610bcd326f by Vinay Sajip in branch 'default':
Closes #23105: Merged update from 3.5.
https://hg.python.org/cpython/rev/64610bcd326f
History
Date User Action Args
2022-04-11 14:58:11adminsetgithub: 67294
2016-09-11 14:17:07python-devsetstatus: open -> closed

nosy: + python-dev
messages: + msg275796

resolution: fixed
stage: patch review -> resolved
2016-08-25 13:56:15vinay.sajipsetnosy: + vinay.sajip
messages: + msg273650
2016-08-07 23:14:22Sworddragonsetmessages: + msg272136
2016-08-07 07:32:49matrixisesetmessages: + msg272112
2016-08-06 20:36:11Sworddragonsetmessages: + msg272108
2016-08-06 12:38:25matrixisesetfiles: + issue23105.diff
keywords: + patch
messages: + msg272097

stage: needs patch -> patch review
2016-08-06 11:19:58matrixisesetmessages: + msg272093
2016-08-06 11:04:46matrixisesetmessages: + msg272091
2016-08-06 11:04:25matrixisesetnosy: + matrixise
messages: + msg272090
2016-08-06 10:41:35berker.peksagsetkeywords: + easy
stage: needs patch
versions: + Python 3.6, - Python 3.4
2014-12-23 16:11:22Sworddragonsetmessages: + msg233051
2014-12-23 15:39:44r.david.murraysetversions: + Python 2.7, Python 3.5
nosy: + r.david.murray, docs@python

messages: + msg233050

assignee: docs@python
components: + Documentation, - Library (Lib)
2014-12-23 14:39:27Sworddragonsetcomponents: + Library (Lib)
2014-12-23 14:39:17Sworddragonsettype: behavior
2014-12-23 14:38:55Sworddragoncreate