-
Notifications
You must be signed in to change notification settings - Fork 958
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Renames problem to slug, fixes pexpect hanging-related bugs #131
Conversation
@@ -139,18 +140,15 @@ def authenticate(org): | |||
pass | |||
authenticate.SOCKET = os.path.join(cache, ORG) | |||
|
|||
spawn = pexpect.spawn if sys.version_info < (3, 0) else pexpect.spawnu |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not needed if not logging to stdout
it seems? http://pexpect.readthedocs.io/en/stable/api/pexpect.html#spawn-class
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Per this section, if spawn
is used in python3, the arguments to expect
are expected to be bytestrings as well. When run under python3 with credentials cached I get TypeError: cannot use a string pattern on a bytes-like object
EDIT: Actually, I was wrong about the cause of the issue. expect
can take unicode strings even bytes mode for compatibility reasons. The real issue (as I should have gathered from the text of the error) is that the regex we are using is a string and we are trying to match the bytestring returned by pexpect. Conditionally using spawnu
fixes this, but so too would adding a EDIT2: making the regex a bytestring doesn't work either since then b
before the regexpassword
is a bytestring which is a problem since we use spawnu
in run
on python3.
|
||
if child.expect(["Username:", pexpect.EOF]): | ||
# Credentials are already cached | ||
if child.expect(["Username:", "Password:", pexpect.EOF]) == 2: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Password:
can happen if username
is configured in .gitconfig
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice catch!
run("git credential-osxkeychain erase", lines=["host=github.com", "protocol=https", ""]) | ||
except Error: | ||
pass | ||
if platform.system() == "Darwin": |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Else error shows up on non-Macs in -v
mode.
res = child.expect(["Password for '.*': ", pexpect.EOF]) | ||
if res == 0: | ||
i = child.expect(["Password for '.*': ", pexpect.EOF]) | ||
if i == 0: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consistency. Also more clear an index.
|
||
if child.expect(["Username:", pexpect.EOF]): | ||
# Credentials are already cached | ||
if child.expect(["Username:", "Password:", pexpect.EOF]) == 2: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice catch!
@@ -139,18 +140,15 @@ def authenticate(org): | |||
pass | |||
authenticate.SOCKET = os.path.join(cache, ORG) | |||
|
|||
spawn = pexpect.spawn if sys.version_info < (3, 0) else pexpect.spawnu |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Per this section, if spawn
is used in python3, the arguments to expect
are expected to be bytestrings as well. When run under python3 with credentials cached I get TypeError: cannot use a string pattern on a bytes-like object
EDIT: Actually, I was wrong about the cause of the issue. expect
can take unicode strings even bytes mode for compatibility reasons. The real issue (as I should have gathered from the text of the error) is that the regex we are using is a string and we are trying to match the bytestring returned by pexpect. Conditionally using spawnu
fixes this, but so too would adding a EDIT2: making the regex a bytestring doesn't work either since then b
before the regexpassword
is a bytestring which is a problem since we use spawnu
in run
on python3.
In writing up docs, I realized that "problem" doesn't quite work for quizzes, tests, projects, etc. Also fixes #130.