Skip to content

Fix error message for non-numeric pull request numbers - #42

Open
christophebedard wants to merge 1 commit into
mainfrom
christophebedard/fix-pr-number-int-except
Open

christophebedard wants to merge 1 commit into
mainfrom
christophebedard/fix-pr-number-int-except

Conversation

@christophebedard

Copy link
Copy Markdown
Member

int() raises ValueError when it gets a string that does not correspond to a number, not TypeError:

$ python3 -c "print(int('123'))"
123
$ python3 -c "print(int('1bc'))"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
ValueError: invalid literal for int() with base 10: '1bc'

Therefore, the nice "isn't a number" error message was never printed.

I used Claude Opus 5.5 to implement this. I verified that it was right about ValueError (see above).

`int()` raises [`ValueError`](https://docs.python.org/3/builtins/exceptions.html#ValueError)
when it gets a string that does not correspond to a number, not
[`TypeError`](https://docs.python.org/3/builtins/exceptions.html#TypeError):

```
$ python3 -c "print(int('123'))"
123
$ python3 -c "print(int('1bc'))"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
ValueError: invalid literal for int() with base 10: '1bc'
```

Therefore, the nice "isn't a number" error message was never printed.

Signed-off-by: Christophe Bedard <bedard.christophe@gmail.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