Issue 8869: execfile does not work with UNC paths (original) (raw)

Created on 2010-06-01 14:40 by stier08, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Messages (4)
msg106841 - (view) Author: stier08 (stier08) Date: 2010-06-01 14:40
execfile() builtin function does not work with UNC paths on Windows platform (Windows 7 x64 has been tested, python 2.6.5) Since standard IO operations successfully process UNC paths, therefore this behavior of execfile() seems to be a bug. Code to reproduce (assuming drive c: is present and you have rw permissions) >>> a=u'\\\\?\\c:\\a.py' >>> open(a,"w").write("print 'hellow'") # successful write to UNC file >>> file(a).read() # successful read from UNC file "print 'hellow'" >>> execfile(a) # ERROR Traceback (most recent call last): File "", line 1, in IOError: [Errno 2] No such file or directory: '\\\\?\\c:\\a.py' See description of UNC naming convention at msdn http://msdn.microsoft.com/en-us/library/aa365247(VS.85).aspx at wikipedia http://en.wikipedia.org/wiki/Path_(computing)#Uniform_Naming_Convention
msg106842 - (view) Author: Tim Golden (tim.golden) * (Python committer) Date: 2010-06-01 14:54
Since execfile is basically shorthand for exec (open (filename).read ()), and since open (filename) *does* support the full range of filepath syntax on Windows, and since execfile has been removed in py3k in favour of exec (open ...)), and since Python 2.x is nearing its end-of-life, I doubt this issue will garner much sympathy. I haven't actually looked at the code to discover just *why* execfile doesn't support that style of filename. But is there any reason you can't use exec (open (...))?
msg106844 - (view) Author: Amaury Forgeot d'Arc (amaury.forgeotdarc) * (Python committer) Date: 2010-06-01 15:49
Reproduced on WinXP. execfile() does not work because it calls the system function stat(); this function does accept UNC paths (like \\machine\share\file), but not paths which contain a wildcard character ('?' or '*') I suggest to remove the leading '\\\\?\\'.
msg106850 - (view) Author: stier08 (stier08) Date: 2010-06-01 17:27
yep exec (open (...)) is OK here thanks
History
Date User Action Args
2022-04-11 14:57:01 admin set github: 53115
2010-06-22 08:09:02 tim.golden set status: open -> closedresolution: out of date
2010-06-01 17:27:54 stier08 set messages: +
2010-06-01 15:49:19 amaury.forgeotdarc set nosy: + amaury.forgeotdarcmessages: +
2010-06-01 14:54:13 tim.golden set nosy: + tim.goldenmessages: +
2010-06-01 14:40:36 stier08 create