[issue18306] os.stat gives exception for Windows junctions in v3.3

2013-10-27 Thread John Jefferies

John Jefferies added the comment:

Hello Tim,

The fact that it works on 64-bit Python obviously reduces the priority. 
I will make a point of choosing the 64-bit version in the future.

FWIW. I'm dubious about the problem being solely attributable to WOWs 
handling of junctions because my Python 3.2 (that doesn't have the 
problem) is also 32-bit. There must be something else, even if that 
something isn't going to be fixed.

Thankyou for spending time on this.

John

On 24/10/2013 09:35, Tim Golden wrote:
> Tim Golden added the comment:
>
> Just revisited this to see if I could close off. One thing occurred to me 
> which should have come up before: this situation will be aggravated by WOW64 
> file redirection.
>
> If I run 64-bit Python on 64-bit Windows I can successfully stat links in 
> %windir%\system32 under 3.4 and 3.3. If I run 32-bit Python on 64-bit 
> Windows, I get the error you describe because Windows will silently redirect 
> the 32-bit Python process towards %windir%\SysWow64 where the junction (or, 
> possibly, its target) does not exist.
>
> Given that I'm able to stat %windir%\system32 junctions on both versions, I'm 
> going to close this as works-for-me. I think there's a case for a 
> bigger-picture look at the resolution of reparse points across the stdlib but 
> that would have to be its own issue.
>
> --
> assignee:  -> tim.golden
> resolution:  -> works for me
> stage: test needed -> committed/rejected
> status: open -> closed
>
> ___
> Python tracker 
> <http://bugs.python.org/issue18306>
> ___

--

___
Python tracker 
<http://bugs.python.org/issue18306>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue18306] os.stat gives exception for Windows junctions in v3.3

2013-08-01 Thread John Jefferies

John Jefferies added the comment:

On 01/08/2013 12:09, Tim Golden wrote:
> Tim Golden added the comment:
>
> I propose to close this one: using Python 3.3 on Win7 I can successfully stat 
> NTFS Junctions. Is there any remaining issue?
>
> --
>
> ___
> Python tracker 
> <http://bugs.python.org/issue18306>
> ___

The original issue remains for me on v3.3.2. I can stat junctions in my 
user directory, but not in system directories. In v3.2 I can do that 
provided I am running with elevated privilege. If it's fixed in the next 
version that's great.


Python 3.3.2 (v3.3.2:d047928ae3f6, May 16 2013, 00:03:43) [MSC v.1600 32 
bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
 >>>
 >>> import os
 >>> os.stat(r'C:\Windows\System32\config\systemprofile\SendTo')
Traceback (most recent call last):
   File "", line 1, in 
FileNotFoundError: [WinError 2] The system cannot find the file 
specified: 'C:\\Windows\\System32\\config\\systemprofile\\SendTo'
 >>>


Regards

John

--

___
Python tracker 
<http://bugs.python.org/issue18306>
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue18522] Error creating a raw string of r'\\?\'

2013-07-21 Thread John Jefferies

John Jefferies added the comment:

Yes, thankyou; I missed that. Another search reveals the issue has come up 
under 11451 and 1271 at least.

John

--

___
Python tracker 
<http://bugs.python.org/issue18522>
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue18522] Error creating a raw string of r'\\?\'

2013-07-21 Thread John Jefferies

New submission from John Jefferies:

I'm having trouble with a raw string of r'\\?\' as in the following session:

>>> a = r'\\?\'
  File "", line 1
a = r'\\?\'
  ^
SyntaxError: EOL while scanning string literal


which seems like a bug to me. I see the same behaviour in v3.3, v3.2, and v2.6. 
I have tried searching for such a bug but search engines don't work well with a 
string of non-alphanumerics.

Why is this string important? It's because the Win32 API functions throw an 
error with path names longer than 260 chars unless the path names are prefixed 
with this string, e.g:
shutil.copy2(r'\\?\C:\some\quite\long\path\name', dstname)
shutil.copy2(r'\\?\' + r'C:\some\quite\long\path\name', dstname)

where the first example throws an exception without the path name prefix; while 
the second example fails to compile.

FTR. I can create the desired string in various other ways:

>>> a = '?\\'
>>> a
'?\\'
>>> a = r'\\?\ '[0:4]
>>> a
'?\\'
>>>


Thanks

John

--
components: Interpreter Core
messages: 193462
nosy: John.Jefferies
priority: normal
severity: normal
status: open
title: Error creating a raw string of r'\\?\'
type: compile error
versions: Python 2.6, Python 3.2, Python 3.3

___
Python tracker 
<http://bugs.python.org/issue18522>
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue18306] os.stat gives exception for Windows junctions in v3.3

2013-06-26 Thread John Jefferies

John Jefferies added the comment:

On 26/06/2013 13:38, Christian Heimes wrote:
> Christian Heimes added the comment:
>
> On my Windows box (Win 7) I'm getting an error with Python 3.2 and 3.3. It 
> looks like I'm not allowed to enter the parent directory (Zugriff verweigert 
> == Permission Denied):

Ah. You need to be an administrator to look at the system directories? 
[I'm also on Win7].

> Neither os.stat() nor os.lstat() have failed with an exception. There 
> must be something different going on on your system. 

I didn't look closely enough; only the junctions in system folders are 
failing for me with an exception. The junctions in my user directory are 
not. I do hope I haven't wasted too much of your time in not describing 
the problem correctly.

> By the way junction points are soft links but not symbolic links. They 
> are implemented as a different kind of NTFS reparsing points. Python 
> should not treat a junction point as a link but have yet another check 
> for it. 

I realise there are differences between junctions and symlinks at the 
ntfs level, but the only things that seem relevant to the application 
are that junctions are limited to directories on a local volume. So I 
consider junctions to be a subset of symlinks. Regardless, any reliable 
indication that a directory is a junction would be useful, and the hack 
I've been using thus far appeared to work for all the junctions on my 
system.

> PS: You should use raw strings on Windows or escape the backslashes.

Yes, I'm ashamed, I did know that but missed it from the example.

Many thanks.

John

--

___
Python tracker 
<http://bugs.python.org/issue18306>
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue18306] os.stat gives exception for Windows junctions in v3.3

2013-06-26 Thread John Jefferies

New submission from John Jefferies:

If os.stat is executed on a Windows junction with Python 3.3 I see an exception:

>>> import os
>>> os.stat('C:\Windows\System32\config\systemprofile\SendTo')
Traceback (most recent call last):
  File "", line 1, in 
FileNotFoundError: [WinError 2] The system cannot find the file specified: 
'C:\\Windows\\System32\\config\\systemprofile\\SendTo'


whereas with Python 3.2 it works without error:

>>> import os
>>> os.stat('C:\Windows\System32\config\systemprofile\SendTo')
nt.stat_result(st_mode=16895, st_ino=281474977136630, st_dev=0, st_nlink=1, 
st_uid=0, st_gid=0, st_size=0, st_atime=1295885671, st_mtime=1295885671, 
st_ctime=1295885671)


FTR. Some background:
It's a pity that Python doesn't just treat Windows junctions as a normal soft 
link. But given that islink() returns False for a junction, I was able to work 
around that in Python 3.2 like this:

if os.path.islink(fullname) or \
os.stat(fullname)[stat.ST_INO] != os.lstat(fullname)[stat.ST_INO]:
# If it's not a link, it's probably a junction...


Many thanks for looking.

John

--
components: Library (Lib)
messages: 191899
nosy: John.Jefferies
priority: normal
severity: normal
status: open
title: os.stat gives exception for Windows junctions in v3.3
type: behavior
versions: Python 3.3

___
Python tracker 
<http://bugs.python.org/issue18306>
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com