Skip to content

bpo-29248: Fix readlink bug os#5577

Merged
berkerpeksag merged 8 commits into
python:masterfrom
SSE4:fix-issue-29248
Feb 12, 2018
Merged

bpo-29248: Fix readlink bug os#5577
berkerpeksag merged 8 commits into
python:masterfrom
SSE4:fix-issue-29248

Conversation

@SSE4

@SSE4 SSE4 commented Feb 7, 2018

Copy link
Copy Markdown
Contributor

see https://bugs.python.org/issue29248

a year already has passed since patch was provided. what should be done to make this into python release?

/cc @gvanrossum @berkerpeksag @asvetlov

https://bugs.python.org/issue29248

Signed-off-by: SSE4 <tomskside@gmail.com>
@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 might be simply due to a missing "GitHub Name" entry in your b.p.o account settings). 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!

Signed-off-by: SSE4 <tomskside@gmail.com>

@gvanrossum gvanrossum left a comment

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.

Otherwise looks good.

Comment thread Lib/test/test_os.py
and os.path.exists(r'C:\ProgramData'),
'Test directories not found')
def test_29248(self):
target = os.readlink(r'C:\Users\All Users')

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.

I would add the explanation from the tracker issue (why we're using this link instead of creating a fresh one to test) here as a comment.

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.

done

@berkerpeksag

Copy link
Copy Markdown
Member

@SSE4 please let us know when you sign the CLA form so we can merge this PR.

@SSE4

SSE4 commented Feb 7, 2018

Copy link
Copy Markdown
Contributor Author

@berkerpeksag I already did earlier today

@@ -0,0 +1 @@
fix os.readlink() on Windows

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.

Please make the news entry more descriptive and add "Patch by Craig Holmquist and Your Name."

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.

done

Comment thread Modules/posixmodule.c Outdated
}
print_name = rdb->SymbolicLinkReparseBuffer.PathBuffer +
rdb->SymbolicLinkReparseBuffer.PrintNameOffset;
(rdb->SymbolicLinkReparseBuffer.PrintNameOffset / 2);

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.

Can PrintNameOffset be odd?

@eryksun eryksun Feb 8, 2018

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.

PathBuffer is of type wchar_t. Strictly this should use sizeof(wchar_t) instead of 2. Alternatively it can use two casts to have the compiler do the work: (wchar_t *)((char *)rdb->SymbolicLinkReparseBuffer.PathBuffer + rdb->SymbolicLinkReparseBuffer.PrintNameOffset).

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.

done

Comment thread Modules/posixmodule.c Outdated
(rdb->SymbolicLinkReparseBuffer.PrintNameOffset / 2);

result = PyUnicode_FromWideChar(print_name,
rdb->SymbolicLinkReparseBuffer.PrintNameLength/2);

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.

Strictly this should also use sizeof(wchar_t) instead of hard coding 2.

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.

done

@SSE4

SSE4 commented Feb 9, 2018

Copy link
Copy Markdown
Contributor Author

/cc @DinoV @zooba can please take a look at this issue related to Microsoft Windows?

@berkerpeksag berkerpeksag left a comment

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.

All review comments have been addressed and this looks good to me. I will wait for a day or two to give everyone a chance to look at the patch and merge it. Thanks!

@SSE4

SSE4 commented Feb 12, 2018

Copy link
Copy Markdown
Contributor Author

@berkerpeksag okay, 3 days passed already, what's the next action to be done?

@miss-islington

Copy link
Copy Markdown
Contributor

Thanks @SSE4 for the PR, and @berkerpeksag for merging it 🌮🎉.. I'm working now to backport this PR to: 3.6, 3.7.
🐍🍒⛏🤖

@bedevere-bot

Copy link
Copy Markdown

GH-5640 is a backport of this pull request to the 3.6 branch.

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Feb 12, 2018
The PrintNameOffset field of the reparse data buffer
was treated as a number of characters instead of bytes.
(cherry picked from commit 3c34aad)

Co-authored-by: SSE4 <tomskside@gmail.com>
berkerpeksag pushed a commit that referenced this pull request Feb 12, 2018
The PrintNameOffset field of the reparse data buffer
was treated as a number of characters instead of bytes.

(cherry picked from commit 3c34aad)

Co-authored-by: SSE4 <tomskside@gmail.com>
@berkerpeksag

Copy link
Copy Markdown
Member

@Mariatta do I need to backport this to 3.7 branch manually or is there some sort of queue?

@miss-islington

Copy link
Copy Markdown
Contributor

Thanks @SSE4 for the PR, and @berkerpeksag for merging it 🌮🎉.. I'm working now to backport this PR to: 3.7.
🐍🍒⛏🤖

@bedevere-bot

Copy link
Copy Markdown

GH-5644 is a backport of this pull request to the 3.7 branch.

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Feb 12, 2018
The PrintNameOffset field of the reparse data buffer
was treated as a number of characters instead of bytes.
(cherry picked from commit 3c34aad)

Co-authored-by: SSE4 <tomskside@gmail.com>
@Mariatta

Copy link
Copy Markdown
Member

@berkerpeksag I think this was merged at the same time miss-islington was being deployed, so it missed that webhook event. I've reapplied the label to trigger the backport.

@berkerpeksag

Copy link
Copy Markdown
Member

@Mariatta thanks!

miss-islington added a commit that referenced this pull request Feb 12, 2018
The PrintNameOffset field of the reparse data buffer
was treated as a number of characters instead of bytes.
(cherry picked from commit 3c34aad)

Co-authored-by: SSE4 <tomskside@gmail.com>
@merwok merwok changed the title bpo-29248: Fix readlink bug os s/merwokbpo-29248: Fix readlink bug os Feb 18, 2018
@merwok merwok changed the title s/merwokbpo-29248: Fix readlink bug os bpo-29248: Fix readlink bug os Feb 18, 2018
@merwok

merwok commented Feb 18, 2018

Copy link
Copy Markdown
Member

@berkerpeksag I noticed that the news file is the only one in the repo to use CRLF.

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.

10 participants