fix(wechat): check the real terminal for QR login, not the log file#597
Open
kevinchennewbee wants to merge 1 commit into
Open
fix(wechat): check the real terminal for QR login, not the log file#597kevinchennewbee wants to merge 1 commit into
kevinchennewbee wants to merge 1 commit into
Conversation
__main__ redirects sys.stdout to the log file before the isatty() check, so the check always sees a file (never a tty) and the QR login path is unreachable — running 'python frontends/wechatapp.py' in a terminal exits with 'no token and not interactive'. Check sys.__stdout__ (the original terminal) instead; None-guarded for pythonw. Verified on a headless Ubuntu box where first-time QR binding previously required a separate login script.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
现象:终端里跑
python frontends/wechatapp.py永远打出no token and not interactive退出,首次扫码绑定走不通。根因:
__main__先把sys.stdout重定向到日志文件,之后才isatty()—— 检查对象是日志文件,永远非 tty。修法:改查
sys.__stdout__(真实终端),加 None 防护(pythonw 场景)。+1/−1。实测:无头 Ubuntu 服务器,此前必须单写脚本调
WxBotClient().login_qr()才能绑定,修后主入口直接可扫码。