Title: ntpath contains imports inside functions
Type: behavior Stage: resolved
Components: Extension Modules, Windows Versions: Python 3.2
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: brian.curtin Nosy List: brian.curtin, ncoghlan, pitrou
Priority: normal Keywords: patch

Created on 2010-09-07 13:44 by brian.curtin, last changed 2010-09-24 13:57 by brian.curtin. This issue is now closed.

File name Uploaded Description Edit
review_email.txt brian.curtin, 2010-09-07 13:44
issue9790_fix.diff brian.curtin, 2010-09-23 23:50
Messages (6)
msg115761 - (view) Author: Brian Curtin (brian.curtin) * (Python committer) Date: 2010-09-07 13:44
As pointed out by Nick Coghlan on python-dev, ntpath.samefile and ntpath.sameopenfile are vulnerable to deadlock because they contain imports.
msg117232 - (view) Author: Brian Curtin (brian.curtin) * (Python committer) Date: 2010-09-23 20:39
Committed to py3k in r84988 using Nick's second suggestion.
msg117247 - (view) Author: Brian Curtin (brian.curtin) * (Python committer) Date: 2010-09-23 23:50
Nick noticed another issue with this, and it actually won't work on pre-Vista versions since we load GetFinalPathNameByHandle at runtime, which is why we had that NotImplementedError.

Attaching a patch which should handle this. We only try the import on Windows 6.0 or above now, and otherwise (XP, other OS'es) use the fallback method.
msg117283 - (view) Author: Nick Coghlan (ncoghlan) * (Python committer) Date: 2010-09-24 13:37
Yeah, I realised shortly after I sent my email in response to the checkin that the original version was covering more cases in that first try-block.

I'll defer to you when it comes to exactly which case that NotImplementedError was covering - patch looks good given the explanation.
msg117284 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2010-09-24 13:56
Patch looks ok, and it would hopefully fix build errors on the XP buildbots :)
msg117285 - (view) Author: Brian Curtin (brian.curtin) * (Python committer) Date: 2010-09-24 13:57
Committed in r84992. Thanks for having a look.
Date User Action Args
2010-09-24 13:57:55brian.curtinsetstatus: open -> closed
resolution: fixed
messages: + msg117285

stage: patch review -> resolved
2010-09-24 13:56:05pitrousetnosy: + pitrou
messages: + msg117284
2010-09-24 13:37:46ncoghlansetmessages: + msg117283
2010-09-23 23:50:16brian.curtinsetstatus: closed -> open
files: + issue9790_fix.diff

keywords: + patch
nosy: + ncoghlan
messages: + msg117247
resolution: fixed -> (no value)
stage: resolved -> patch review
2010-09-23 20:41:13brian.curtinsetstatus: open -> closed
2010-09-23 20:39:54brian.curtinsetresolution: fixed
messages: + msg117232
stage: needs patch -> resolved
2010-09-07 13:44:01brian.curtincreate