Skip to content

fix an error message and a comment in _testcapimodule.c #392

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

Merged
merged 1 commit into from
Mar 2, 2017

Conversation

orenmn
Copy link
Contributor

@orenmn orenmn commented Mar 2, 2017

fix two mistakes in Modules/_testcapimodule.c:

  • in the function comment of test_k_code
  • in an error message in test_k_code

(note that I mentioned these mistakes in bpo-27298, but only as a side note.)

Just in case, I ran the test module on my Windows 10, and as expected, it seems that this minor patch doesn't break anything.

@methane methane merged commit 698845e into python:master Mar 2, 2017
@methane
Copy link
Member

methane commented Mar 2, 2017

thanks

@@ -1205,7 +1205,8 @@ test_k_code(PyObject *self)
value = PyLong_AsUnsignedLongMask(num);
if (value != (unsigned long)-0x42)
return raiseTestError("test_k_code",
"PyLong_AsUnsignedLongMask() returned wrong value for long 0xFFF...FFF");
"PyLong_AsUnsignedLongMask() returned wrong "
"value for long -0xFFF..000042");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

0xFFF...000042 looks strange. Is this really the right value? (And what does the ... mean here?)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

first we have:
num = PyLong_FromString("-FFFFFFFF000000000000000042", NULL, 16);
and then the check is whether PyLong_AsUnsignedLongMask returned -0x42,
i.e. truncated num as expected.
so yes, IMHO -0xFFF..000042 is the right value.

and I guess the .. means a big enough amount of zeros, such that the
truncation would indeed result in -0x42.
ISTM the original author felt this would be more elegant than writing
-0xFFFFFFFF000000000000000042 again...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair enough. Given that it's just an error message, and that that error message is at least unique enough to identify exactly what's failing, it's probably good enough. Sorry for the bikeshedding.

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.

4 participants