Skip to content

bpo-30291 Changes to launcher so as to allow py -3-32,...#1488

Merged
zooba merged 9 commits intopython:masterfrom
GadgetSteve:fix-issue-30291
May 12, 2017
Merged

bpo-30291 Changes to launcher so as to allow py -3-32,...#1488
zooba merged 9 commits intopython:masterfrom
GadgetSteve:fix-issue-30291

Conversation

@GadgetSteve
Copy link
Copy Markdown
Contributor

… etc.

@the-knights-who-say-ni
Copy link
Copy Markdown

Hello, and thanks for your contribution!

I'm a bot set up to make sure that the project can legally accept your contribution by verifying you have signed the PSF contributor agreement (CLA).

Unfortunately we couldn't find an account corresponding to your GitHub username on bugs.python.org (b.p.o) to verify you have signed the CLA. This is necessary for legal reasons before we can look at your contribution. Please follow the steps outlined in the CPython devguide to rectify this issue.

Thanks again to your contribution and we look forward to looking at it!

@GadgetSteve
Copy link
Copy Markdown
Contributor Author

Note: CLA Signed but not processed yet.

Comment thread PC/launcher.c Outdated
*/
BOOL result = (p != NULL) && *p; /* Default to false if empty string or null pointer. */

while (result && isdigit(*p)) /* Require a major version */{
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

You're not requiring a major version -- just skipping leading digits. What if the version string is ".7-32"? ISTM, you should initially set BOOL result = p && isdigit(*p); . Then you can skip remaining digits.

Also, this should be calling iswdigit. The debug CRT raises an exception if isdigit is passed a value greater than 255. As things stand I think py.exe always links statically with a non-debug implementation, but it's still not a good practice to use isdigit with 16-bit wchar_t values.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the feedback, initial check for digit added & all isdigit calls in my changed sections replaced with iswdigit.

Comment thread PC/launcher.c Outdated
if (result && (*p == L'.')) /* Allow . for major minor separator.*/
{
result = isdigit(*++p); /* Must be at least one digit */
while (isdigit(*++p)) ; /* Skip an more Digits */
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

What if *++p in the previous statement on 1071 was the trailing null and result is false, i.e. the version string is something like "2."? Now you're reading past the end of the string.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good point - addressed.

Comment thread PC/launcher.c Outdated
3.6-64
3-64
*/
BOOL result = (p != NULL) && *p &&!iswdigit(*p); /* Default to false if empty string or null pointer. */
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

result should be true if the first character is a digit, and false for a NULL pointer or empty string, e.g. result = (p != NULL) && iswdigit(*p). You don't need to check *p separately since iswdigit is false for a nul character, but it doesn't hurt if you want to keep that in. I'm just not understanding why you would negate the value of iswdigit(*p).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

That is what I get for not re-running the tests, typo.

@GadgetSteve
Copy link
Copy Markdown
Contributor Author

It looks like the-knights-who-say-ni are getting a little over enthusiastic @brettcannon

@brettcannon brettcannon removed the CLA not signed label 6 hours ago
@the-knights-who-say-ni the-knights-who-say-ni added the CLA not signed label 6 hours ago

@GadgetSteve
Copy link
Copy Markdown
Contributor Author

Issue with the-knights-who-say-ni was the missing GitHub User Name in my profile. Resolved on minor change to ensure that help messages don't wrap on 80 col displays.

@brettcannon brettcannon requested a review from zooba May 10, 2017 19:02
Comment thread PC/launcher.c Outdated
BOOL result = (p != NULL) && *p && iswdigit(*p); /* Default to false if empty string or null pointer. */

while (result && iswdigit(*p)) /* Require a major version */{
++p; /* Skip leading digit(s) */}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Really don't like where the braces are here. No braces would be fine, or put them on separate lines so they are more obvious, but currently I think it's a serious comprehension issue.

@zooba
Copy link
Copy Markdown
Member

zooba commented May 11, 2017

Just the one style comment from me, but I'm going to insist it should be fixed (broken window syndrome and all that). Otherwise, it looks fine.

@GadgetSteve
Copy link
Copy Markdown
Contributor Author

GadgetSteve commented May 11, 2017

Added response to review by @zooba + removed a number of C++ style comments in the original code (converted to C comments - also broken window syndrome).

@zooba
Copy link
Copy Markdown
Member

zooba commented May 11, 2017

C99 comments are totally fine in master these days, so don't start fixing them everywhere (different if code is going to be backported), but it seems like you didn't actually fix the braces that I mentioned.

@GadgetSteve
Copy link
Copy Markdown
Contributor Author

@zooba You were quite right about the obscurity of the braces - I didn't see them when looking to fix and thought that the problem was with the mixed parenthesis style of the previous line.

@zooba zooba merged commit 870f6a1 into python:master May 12, 2017
@GadgetSteve GadgetSteve deleted the fix-issue-30291 branch May 14, 2017 05:22
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.

5 participants