Merge #14984: only import pwd on POSIX.
Since we have fine grained import locks in 3.4, I moved the import to where it is actually needed.
This commit is contained in:
commit
6bd3e444f5
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
# Module and documentation by Eric S. Raymond, 21 Dec 1998
|
# Module and documentation by Eric S. Raymond, 21 Dec 1998
|
||||||
|
|
||||||
import io, os, shlex, stat, pwd
|
import os, shlex, stat
|
||||||
|
|
||||||
__all__ = ["netrc", "NetrcParseError"]
|
__all__ = ["netrc", "NetrcParseError"]
|
||||||
|
|
||||||
|
@ -90,6 +90,7 @@ class netrc:
|
||||||
if os.name == 'posix' and default_netrc:
|
if os.name == 'posix' and default_netrc:
|
||||||
prop = os.fstat(fp.fileno())
|
prop = os.fstat(fp.fileno())
|
||||||
if prop.st_uid != os.getuid():
|
if prop.st_uid != os.getuid():
|
||||||
|
import pwd
|
||||||
try:
|
try:
|
||||||
fowner = pwd.getpwuid(prop.st_uid)[0]
|
fowner = pwd.getpwuid(prop.st_uid)[0]
|
||||||
except KeyError:
|
except KeyError:
|
||||||
|
|
Loading…
Reference in New Issue