Skip to content

修复:交互模式最后楼层校验放行了 0#7

Open
joy717 wants to merge 1 commit into
linux-do:masterfrom
joy717:fix/last-floor-validation
Open

修复:交互模式最后楼层校验放行了 0#7
joy717 wants to merge 1 commit into
linux-do:masterfrom
joy717:fix/last-floor-validation

Conversation

@joy717

@joy717 joy717 commented Jun 17, 2026

Copy link
Copy Markdown

问题

lottery.py 交互模式校验最后楼层:

if not last_floor.isdigit() or int(last_floor) < 0:
    print("错误: 最后楼层必须为大于0的整数")
    continue

str.isdigit() 已经排除了负数,所以 int(last_floor) < 0 是永远不成立的死分支;结果 0 能通过校验,但提示语写的是「必须为大于0的整数」。楼层 0 本身也没有意义(会截掉所有楼层)。

修改

if not last_floor.isdigit() or int(last_floor) < 1:

校验改为 < 1,与提示语一致,拦掉 0

🤖 Generated with Claude Code

Interactive input rejected `< 0`, but `str.isdigit()` already excludes
negatives, so that branch was dead code and `0` slipped through despite
the message stating "必须为大于0的整数". Validate `< 1` so the check
matches the message and disallows a meaningless floor 0.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant