@@ -1453,16 +1453,19 @@ features:
1453
1453
.. _path_fd :
1454
1454
1455
1455
* **specifying a file descriptor: **
1456
- For some functions, the *path * argument can be not only a string giving a path
1457
- name, but also a file descriptor. The function will then operate on the file
1458
- referred to by the descriptor. (For POSIX systems, Python will call the
1459
- ``f... `` version of the function.)
1460
-
1461
- You can check whether or not *path * can be specified as a file descriptor on
1462
- your platform using :data: `os.supports_fd `. If it is unavailable, using it
1463
- will raise a :exc: `NotImplementedError `.
1456
+ Normally the *path * argument provided to functions in the :mod: `os ` module
1457
+ must be a string specifying a file path. However, some functions now
1458
+ alternatively accept an open file descriptor for their *path * argument.
1459
+ The function will then operate on the file referred to by the descriptor.
1460
+ (For POSIX systems, Python will call the variant of the function prefixed
1461
+ with ``f `` (e.g. call ``fchdir `` instead of ``chdir ``).)
1462
+
1463
+ You can check whether or not *path * can be specified as a file descriptor
1464
+ for a particular function on your platform using :data: `os.supports_fd `.
1465
+ If this functionality is unavailable, using it will raise a
1466
+ :exc: `NotImplementedError `.
1464
1467
1465
- If the function also supports *dir_fd * or *follow_symlinks * arguments, it is
1468
+ If the function also supports *dir_fd * or *follow_symlinks * arguments, it's
1466
1469
an error to specify one of those when supplying *path * as a file descriptor.
1467
1470
1468
1471
.. _dir_fd :
@@ -1471,23 +1474,24 @@ features:
1471
1474
should be a file descriptor referring to a directory, and the path to operate
1472
1475
on should be relative; path will then be relative to that directory. If the
1473
1476
path is absolute, *dir_fd * is ignored. (For POSIX systems, Python will call
1474
- the ``...at `` or ``f...at `` version of the function.)
1477
+ the variant of the function with an ``at `` suffix and possibly prefixed with
1478
+ ``f `` (e.g. call ``faccessat `` instead of ``access ``).
1475
1479
1476
- You can check whether or not *dir_fd * is supported on your platform using
1477
- :data: `os.supports_dir_fd `. If it is unavailable, using it will raise a
1478
- :exc: `NotImplementedError `.
1480
+ You can check whether or not *dir_fd * is supported for a particular function
1481
+ on your platform using :data: `os.supports_dir_fd `. If it's unavailable,
1482
+ using it will raise a :exc: `NotImplementedError `.
1479
1483
1480
1484
.. _follow_symlinks :
1481
1485
1482
1486
* **not following symlinks: ** If *follow_symlinks * is
1483
1487
``False ``, and the last element of the path to operate on is a symbolic link,
1484
- the function will operate on the symbolic link itself instead of the file the
1485
- link points to . (For POSIX systems, Python will call the ``l... `` version of
1486
- the function.)
1488
+ the function will operate on the symbolic link itself rather than the file
1489
+ pointed to by the link . (For POSIX systems, Python will call the ``l... ``
1490
+ variant of the function.)
1487
1491
1488
- You can check whether or not *follow_symlinks * is supported on your platform
1489
- using :data: `os.supports_follow_symlinks `. If it is unavailable, using it
1490
- will raise a :exc: `NotImplementedError `.
1492
+ You can check whether or not *follow_symlinks * is supported for a particular
1493
+ function on your platform using :data: `os.supports_follow_symlinks `.
1494
+ If it's unavailable, using it will raise a :exc: `NotImplementedError `.
1491
1495
1492
1496
1493
1497
@@ -1662,7 +1666,7 @@ features:
1662
1666
.. availability :: Unix.
1663
1667
1664
1668
.. versionadded :: 3.3
1665
- Added support for specifying an open file descriptor for * path * ,
1669
+ Added support for specifying * path * as an open file descriptor,
1666
1670
and the *dir_fd * and *follow_symlinks * arguments.
1667
1671
1668
1672
.. versionchanged :: 3.6
@@ -1781,7 +1785,7 @@ features:
1781
1785
The *path * parameter became optional.
1782
1786
1783
1787
.. versionadded :: 3.3
1784
- Added support for specifying an open file descriptor for * path * .
1788
+ Added support for specifying * path * as an open file descriptor.
1785
1789
1786
1790
.. versionchanged :: 3.6
1787
1791
Accepts a :term: `path-like object `.
@@ -2593,7 +2597,7 @@ features:
2593
2597
The :const: `ST_RDONLY ` and :const: `ST_NOSUID ` constants were added.
2594
2598
2595
2599
.. versionadded :: 3.3
2596
- Added support for specifying an open file descriptor for * path * .
2600
+ Added support for specifying * path * as an open file descriptor.
2597
2601
2598
2602
.. versionchanged :: 3.4
2599
2603
The :const: `ST_NODEV `, :const: `ST_NOEXEC `, :const: `ST_SYNCHRONOUS `,
@@ -2610,59 +2614,61 @@ features:
2610
2614
2611
2615
.. data :: supports_dir_fd
2612
2616
2613
- A :class: `~collections.abc.Set ` object indicating which functions in the
2614
- :mod: `os ` module permit use of their *dir_fd * parameter. Different platforms
2615
- provide different functionality, and an option that might work on one might
2616
- be unsupported on another. For consistency's sakes, functions that support
2617
- *dir_fd * always allow specifying the parameter, but will raise an exception
2618
- if the functionality is not actually available.
2619
-
2620
- To check whether a particular function permits use of its *dir_fd *
2621
- parameter, use the ``in `` operator on ``supports_dir_fd ``. As an example,
2622
- this expression determines whether the *dir_fd * parameter of :func: `os.stat `
2623
- is locally available::
2617
+ A :class: `set ` object indicating which functions in the :mod: `os `
2618
+ module accept an open file descriptor for their *dir_fd * parameter.
2619
+ Different platforms provide different features, and the underlying
2620
+ functionality Python uses to implement the *dir_fd * parameter is not
2621
+ available on all platforms Python supports. For consistency's sake,
2622
+ functions that may support *dir_fd * always allow specifying the
2623
+ parameter, but will throw an exception if the functionality is used
2624
+ when it's not locally available. (Specifying ``None `` for *dir_fd *
2625
+ is always supported on all platforms.)
2626
+
2627
+ To check whether a particular function accepts an open file descriptor
2628
+ for its *dir_fd * parameter, use the ``in `` operator on ``supports_dir_fd ``.
2629
+ As an example, this expression evaluates to ``True `` if :func: `os.stat `
2630
+ accepts open file descriptors for *dir_fd * on the local platform::
2624
2631
2625
2632
os.stat in os.supports_dir_fd
2626
2633
2627
- Currently *dir_fd * parameters only work on Unix platforms; none of them work
2628
- on Windows.
2634
+ Currently *dir_fd * parameters only work on Unix platforms;
2635
+ none of them work on Windows.
2629
2636
2630
2637
.. versionadded :: 3.3
2631
2638
2632
2639
2633
2640
.. data :: supports_effective_ids
2634
2641
2635
- A :class: `~collections.abc.Set ` object indicating which functions in the
2636
- :mod: `os ` module permit use of the *effective_ids * parameter for
2637
- :func: `os.access `. If the local platform supports it, the collection will
2638
- contain :func: `os.access `, otherwise it will be empty.
2642
+ A :class: `set ` object indicating whether :func: `os.access ` permits
2643
+ specifying ``True `` for its *effective_ids * parameter on the local platform.
2644
+ (Specifying ``False `` for *effective_ids * is always supported on all
2645
+ platforms.) If the local platform supports it, the collection will contain
2646
+ :func: `os.access `; otherwise it will be empty.
2639
2647
2640
- To check whether you can use the *effective_ids * parameter for
2641
- :func: `os.access `, use the ``in `` operator on ``supports_effective_ids ``,
2642
- like so::
2648
+ This expression evaluates to ``True `` if :func: `os.access ` supports
2649
+ ``effective_ids=True `` on the local platform::
2643
2650
2644
2651
os.access in os.supports_effective_ids
2645
2652
2646
- Currently *effective_ids * only works on Unix platforms; it does not work on
2647
- Windows.
2653
+ Currently *effective_ids * is only supported on Unix platforms;
2654
+ it does not work on Windows.
2648
2655
2649
2656
.. versionadded :: 3.3
2650
2657
2651
2658
2652
2659
.. data :: supports_fd
2653
2660
2654
- A :class: `~collections.abc.Set ` object indicating which functions in the
2661
+ A :class: `set ` object indicating which functions in the
2655
2662
:mod: `os ` module permit specifying their *path * parameter as an open file
2656
- descriptor. Different platforms provide different functionality, and an
2657
- option that might work on one might be unsupported on another. For
2658
- consistency's sakes, functions that support *fd * always allow specifying
2659
- the parameter, but will raise an exception if the functionality is not
2660
- actually available.
2663
+ descriptor on the local platform. Different platforms provide different
2664
+ features, and the underlying functionality Python uses to accept open file
2665
+ descriptors as *path * arguments is not available on all platforms Python
2666
+ supports.
2661
2667
2662
- To check whether a particular function permits specifying an open file
2668
+ To determine whether a particular function permits specifying an open file
2663
2669
descriptor for its *path * parameter, use the ``in `` operator on
2664
- ``supports_fd ``. As an example, this expression determines whether
2665
- :func: `os.chdir ` accepts open file descriptors when called on your local
2670
+ ``supports_fd ``. As an example, this expression evaluates to `` True `` if
2671
+ :func: `os.chdir ` accepts open file descriptors for * path * on your local
2666
2672
platform::
2667
2673
2668
2674
os.chdir in os.supports_fd
@@ -2672,17 +2678,21 @@ features:
2672
2678
2673
2679
.. data :: supports_follow_symlinks
2674
2680
2675
- A :class: `~collections.abc.Set ` object indicating which functions in the
2676
- :mod: `os ` module permit use of their *follow_symlinks * parameter. Different
2677
- platforms provide different functionality, and an option that might work on
2678
- one might be unsupported on another. For consistency's sakes, functions that
2679
- support *follow_symlinks * always allow specifying the parameter, but will
2680
- raise an exception if the functionality is not actually available.
2681
-
2682
- To check whether a particular function permits use of its *follow_symlinks *
2683
- parameter, use the ``in `` operator on ``supports_follow_symlinks ``. As an
2684
- example, this expression determines whether the *follow_symlinks * parameter
2685
- of :func: `os.stat ` is locally available::
2681
+ A :class: `set ` object indicating which functions in the :mod: `os ` module
2682
+ accept ``False `` for their *follow_symlinks * parameter on the local platform.
2683
+ Different platforms provide different features, and the underlying
2684
+ functionality Python uses to implement *follow_symlinks * is not available
2685
+ on all platforms Python supports. For consistency's sake, functions that
2686
+ may support *follow_symlinks * always allow specifying the parameter, but
2687
+ will throw an exception if the functionality is used when it's not locally
2688
+ available. (Specifying ``True `` for *follow_symlinks * is always supported
2689
+ on all platforms.)
2690
+
2691
+ To check whether a particular function accepts ``False `` for its
2692
+ *follow_symlinks * parameter, use the ``in `` operator on
2693
+ ``supports_follow_symlinks ``. As an example, this expression evaluates
2694
+ to ``True `` if you may specify ``follow_symlinks=False `` when calling
2695
+ :func: `os.stat ` on the local platform::
2686
2696
2687
2697
os.stat in os.supports_follow_symlinks
2688
2698
@@ -2801,7 +2811,7 @@ features:
2801
2811
following symlinks <follow_symlinks>`.
2802
2812
2803
2813
.. versionadded :: 3.3
2804
- Added support for specifying an open file descriptor for * path * ,
2814
+ Added support for specifying * path * as an open file descriptor,
2805
2815
and the *dir_fd *, *follow_symlinks *, and *ns * parameters.
2806
2816
2807
2817
.. versionchanged :: 3.6
@@ -3162,7 +3172,7 @@ to be ignored.
3162
3172
.. availability :: Unix, Windows.
3163
3173
3164
3174
.. versionadded :: 3.3
3165
- Added support for specifying an open file descriptor for * path *
3175
+ Added support for specifying * path * as an open file descriptor
3166
3176
for :func: `execve `.
3167
3177
3168
3178
.. versionchanged :: 3.6
0 commit comments