use exc.winerror not exc[0] to avoid python3 TypeError

Fixes #50413
This commit is contained in:
Friedmund Lassmann 2018-11-07 12:31:29 +01:00
parent ef4509e779
commit 20fff15e89

View File

@ -310,8 +310,8 @@ def runas_system(cmd, username, password):
except win32security.error as exc:
# User doesn't have admin, use existing token
if exc[0] == winerror.ERROR_NO_SUCH_LOGON_SESSION \
or exc[0] == winerror.ERROR_PRIVILEGE_NOT_HELD:
if exc.winerror == winerror.ERROR_NO_SUCH_LOGON_SESSION \
or exc.winerror == winerror.ERROR_PRIVILEGE_NOT_HELD:
elevated_token = token
else:
raise