@@ -53,14 +53,6 @@
|
53 | 53 | from time import monotonic as _time |
54 | 54 | import types |
55 | 55 | |
56 | | -try: |
57 | | -import pwd |
58 | | -except ImportError: |
59 | | -pwd = None |
60 | | -try: |
61 | | -import grp |
62 | | -except ImportError: |
63 | | -grp = None |
64 | 56 | try: |
65 | 57 | import fcntl |
66 | 58 | except ImportError: |
@@ -875,7 +867,9 @@ def __init__(self, args, bufsize=-1, executable=None,
|
875 | 867 | "current platform") |
876 | 868 | |
877 | 869 | elif isinstance(group, str): |
878 | | -if grp is None: |
| 870 | +try: |
| 871 | +import grp |
| 872 | +except ImportError: |
879 | 873 | raise ValueError("The group parameter cannot be a string " |
880 | 874 | "on systems without the grp module") |
881 | 875 | |
@@ -901,7 +895,9 @@ def __init__(self, args, bufsize=-1, executable=None,
|
901 | 895 | gids = [] |
902 | 896 | for extra_group in extra_groups: |
903 | 897 | if isinstance(extra_group, str): |
904 | | -if grp is None: |
| 898 | +try: |
| 899 | +import grp |
| 900 | +except ImportError: |
905 | 901 | raise ValueError("Items in extra_groups cannot be " |
906 | 902 | "strings on systems without the " |
907 | 903 | "grp module") |
@@ -927,10 +923,11 @@ def __init__(self, args, bufsize=-1, executable=None,
|
927 | 923 | "the current platform") |
928 | 924 | |
929 | 925 | elif isinstance(user, str): |
930 | | -if pwd is None: |
| 926 | +try: |
| 927 | +import pwd |
| 928 | +except ImportError: |
931 | 929 | raise ValueError("The user parameter cannot be a string " |
932 | 930 | "on systems without the pwd module") |
933 | | - |
934 | 931 | uid = pwd.getpwnam(user).pw_uid |
935 | 932 | elif isinstance(user, int): |
936 | 933 | uid = user |
|