Skip to content

Commit cbe216a

Browse files
committed
avoid calling os.getuid() twice
1 parent d2a13f6 commit cbe216a

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

Lib/netrc.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,9 +157,10 @@ def _parse(self, file, fp, default_netrc):
157157
def _security_check(self, fp, default_netrc, login):
158158
if _can_security_check() and default_netrc and login != "anonymous":
159159
prop = os.fstat(fp.fileno())
160-
if prop.st_uid != os.getuid():
160+
current_user_id = os.getuid()
161+
if prop.st_uid != current_user_id:
161162
fowner = _getpwuid(prop.st_uid)
162-
user = _getpwuid(os.getuid())
163+
user = _getpwuid(current_user_id)
163164
raise NetrcParseError(
164165
(f"~/.netrc file owner ({fowner}, {user}) does not match"
165166
" current user"))

0 commit comments

Comments
 (0)