Repository navigation
Quote unprintable values through _message_text in three integer refusals (closes #2863) - #2865
Conversation
…als (closes btclib-org#2863) Signed-off-by: nosmile99 <nosmile99@users.noreply.github.com>
|
Thanks, @nosmile99. I approved the eight workflow runs waiting on c531ac5 after reading the diff, which touches nothing under |
|
Lint fix pushed (cfba123): the lint failure was mypy strict on the three new regression tests — they intentionally pass a Verified locally in the project env: |
fametrano
left a comment
There was a problem hiding this comment.
Thank you, @nosmile99. One thing holds this pull request: the second commit, cfba123, has no Signed-off-by: line.
The fix is right and meets ISS #2863's Done when. On main, var_int.serialize, var_int.parse(max_size=) and obfuscation.obfuscate(offset=) each raise a builtin ValueError ("Exceeds the limit (4300 digits)") for Fraction(10**4400, 3). With your change each raises BTClibTypeError with a Fraction str() cannot write. Both new tests fail on main and pass on your head, the # type: ignore[arg-type] follows the tree's precedent (tests/amount_test.py), and no other refusal in scope quotes an unprintable value.
main requires a Signed-off-by: trailer on every commit, added by its author: it is your attestation, so we cannot add it for you. cfba123 was committed as nosmile0110@gmail.com, so the trailer must name that address. It is the tip, so this is enough, followed by a force-push:
git -c user.email=nosmile0110@gmail.com commit --amend --no-edit -sThe suggestions below are optional. They make the tests match the whole description the fix writes, as tests/amount_test.py does (a Fraction str\(\) cannot write$), not only the message's prefix. Apply them with the sign-off, or leave them.
The new tests intentionally pass a Fraction where int is typed, to exercise the refusal path; mark the three call sites with the repo-standard type: ignore[arg-type] so strict mypy passes. Signed-off-by: nosmile99 <nosmile0110@gmail.com>
cfba123 to
06af90f
Compare
|
Thanks, @fametrano — both items are in, force-pushed as
|
fametrano
left a comment
There was a problem hiding this comment.
Thank you, @nosmile99. Approved at 06af90f.
The three refusals #2863 names now quote through _message_text. Each new test fails on the old code with the builtin ValueError: Exceeds the limit (4300 digits), and the max_size assertion catches a regression of that line on its own. Both commits are signed off, mypy is clean on the four touched files, and every check passed on this head.
Your second commit's message names only the type: ignore lines, so the squash body says what that commit also changed.
Closes #2863
Three integer refusals built their message with a plain f-string interpolation of the refused value, so a Fraction whose numerator runs past Python's 4300-digit str() limit left as a builtin ValueError instead of the library's BTClibTypeError. The three sites now quote through utils._message_text, which describes a value str() cannot write instead of quoting it:
Verification: reproduced all three as builtin ValueError on main, then confirmed BTClibTypeError after the fix. Two new regression tests pass Fraction(10**4400, 3) to each entry point and expect BTClibTypeError; both fail on the unfixed code (stashed-src comparison) and pass with the fix. The var_int, obfuscation, and integer-policy suites pass together, and ruff check plus ruff format are clean on the changed files.
Out of scope, noted for the maintainer: the negative-offset refusal in obfuscation quotes its value directly too, so a negative int past the digit limit would leave the same way (as a builtin ValueError instead of BTClibValueError). Left untouched since the issue scopes to the three integer refusals.