[issue35144] TemporaryDirectory clean-up fails with unsearchable directories

2020-09-22 Thread Vidar Fauske


Vidar Fauske  added the comment:

A somewhat easy repro:

Create the temporary directory, add a subdir (not sure if subdir truly 
necessary at this point), use `os.chdir()` to set the cwd to that subdir. Clean 
up the temp dir. The cwd should prevent the deletion because it will be "in 
use".

--

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



[issue35144] TemporaryDirectory clean-up fails with unsearchable directories

2020-09-22 Thread Vidar Fauske


Vidar Fauske  added the comment:

On Python 3.8.5 on Windows using the code from the above patch I recently got a 
stack overflow:

Thread 0x2054 (most recent call first):
  File "...\lib\concurrent\futures\thread.py", line 78 in _worker
  File "...\lib\threading.py", line 870 in run
  File "...\lib\threading.py", line 932 in _bootstrap_inner
  File "...\lib\threading.py", line 890 in _bootstrap

Thread 0x0de4 (most recent call first):
  File "...\lib\concurrent\futures\thread.py", line 78 in _worker
  File "...\lib\threading.py", line 870 in run
  File "...\lib\threading.py", line 932 in _bootstrap_inner
  File "...\lib\threading.py", line 890 in _bootstrap

Current thread 0x4700 (most recent call first):
  File "...\lib\tempfile.py", line 803 in onerror
  File "...\lib\shutil.py", line 619 in _rmtree_unsafe
  File "...\lib\shutil.py", line 737 in rmtree
  File "...\lib\tempfile.py", line 814 in _rmtree
  File "...\lib\tempfile.py", line 806 in onerror
  File "...\lib\shutil.py", line 619 in _rmtree_unsafe
  File "...\lib\shutil.py", line 737 in rmtree
  ... repeating

---


In my case, the outer `exc_info` from rmtree is:

PermissionError(13, 'The process cannot access the file because it is being 
used by another process')


And the inner exception from `_os.unlink(path)` is:

PermissionError(13, 'Access is denied')



I would say that expected behavior in this case would be to let the 'file is in 
use' error raise, instead of killing the process with an SO.

--
nosy: +vidartf

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



[issue26660] tempfile.TemporaryDirectory() cleanup exception if nonwriteable or non-searchable files or directories created

2020-03-12 Thread Vidar Fauske


Vidar Fauske  added the comment:

Seems as if this was resolved by the linked PR in 3.8, or am I missing 
something?

--
nosy: +vidartf

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



[issue26024] Non-ascii Windows locale names

2019-08-23 Thread Vidar Fauske


Vidar Fauske  added the comment:

Thanks. Note that the failing with `
locale.setlocale(locale.LC_ALL, locale.getdefaultlocale())` I mentioned above 
is a different problem, that is tracked in a much older issue: 
https://bugs.python.org/issue10466

--

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



[issue10466] locale.py resetlocale throws exception on Windows (getdefaultlocale returns value not usable in setlocale)

2019-08-23 Thread Vidar Fauske


Vidar Fauske  added the comment:

Note that this is still an issue on Windows:

>>> import locale
>>> locale.getdefaultlocale()
('en_US', 'cp1252')
>>> locale.setlocale(locale.getdefaultlocale())
Error: unsupported locale setting

--
components: +Windows
nosy: +paul.moore, steve.dower, vidartf, zach.ware
versions: +Python 3.7 -Python 3.1, Python 3.2

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



[issue31226] shutil.rmtree fails when target has an internal directory junction (Windows)

2019-08-08 Thread Vidar Fauske


Vidar Fauske  added the comment:

Thanks for the detailed explanation Eryk. While it is a little annoying that it 
comes 2 years after the initial proposed solution, I'll happily take that if 
the end result is a better fix :)

That being said, this fix seems quite a bit more involved to implement than the 
previous one. While I am now slightly more experienced in contributing to 
Python than previously, I'm not sure if I can commit to implementing the 
outlined changes without some help. Some things that would help out a lot:
- An extracted checklist from the rather longer comment?
- Writing up the requirements as tests cases so that I can do test-driven 
development (I'm not very familiar with the testing suite).

If somebody else would want to either do it themselves, or help out with 
certain parts, I'd be very open to that (I'm not trying to "own" this).

--

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



[issue31226] shutil.rmtree fails when target has an internal directory junction (Windows)

2019-04-10 Thread Vidar Fauske


Vidar Fauske  added the comment:

I think the submitted PR could need a pair of eyes now. I've sorted the merge 
conflicts, and addressed the previous review points by eryksun.

--

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



[issue26024] Non-ascii Windows locale names

2019-02-11 Thread Vidar Fauske


Vidar Fauske  added the comment:

This issue can still be triggered for Python 3.7 by the following line (running 
on a Windows machine with a Norwegian locale as default):

locale.setlocale(locale.LC_ALL, locale.getdefaultlocale())

--
versions: +Python 3.7

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



[issue31512] Add non-elevated symlink support for dev mode Windows 10

2018-11-27 Thread Vidar Fauske


Vidar Fauske  added the comment:

Thanks! I addressed the comment, so hopefully this should be OK now.

--

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



[issue31512] Add non-elevated symlink support for dev mode Windows 10

2018-11-23 Thread Vidar Fauske


Vidar Fauske  added the comment:

The PR has been sitting for a while now with all previous concerns addressed. 
There has been a few pings on the PR without anything new happening, so I 
thought I would ping this issue as well: are there any other concerns about 
this PR, or anything else that is preventing it from being merged?

--

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



[issue31226] shutil.rmtree fails when target has an internal directory junction (Windows)

2018-04-13 Thread Vidar Fauske

Vidar Fauske <vida...@gmail.com> added the comment:

A PR that fixes the issue according to the feedback from Eryk Sun is available. 
It does seem to have stranded a bit on the review side. That being said, would 
a bugfix for shutil.rmtree be appropriate? It is very annoying when junction 
points made by other tools break pip source install of packages (since pip 
calls shutil.rmtree on its temporary directory after a build).

--

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



[issue31226] shutil.rmtree fails when target has an internal directory junction (Windows)

2018-03-05 Thread Vidar Fauske via Python-bugs-list

Change by Vidar Fauske <vida...@gmail.com>:


--
keywords: +patch
pull_requests: +5764
stage: test needed -> patch review

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



[issue31512] Add non-elevated symlink support for dev mode Windows 10

2017-09-21 Thread Vidar Fauske

Vidar Fauske added the comment:

Thanks for the informative comments. I opened a PR based on this feedback. 
Would you mind checking if it conforms to what you had in mind?

--

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



[issue31512] Add non-elevated symlink support for dev mode Windows 10

2017-09-19 Thread Vidar Fauske

Changes by Vidar Fauske <vida...@gmail.com>:


--
pull_requests: +3645
stage:  -> patch review

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



[issue31512] Add non-elevated symlink support for dev mode Windows 10

2017-09-18 Thread Vidar Fauske

New submission from Vidar Fauske:

As explained in this Microsoft blogpost 
(https://blogs.windows.com/buildingapps/2016/12/02/symlinks-windows-10/), it is 
possible on newer versions of Windows 10 for non-privileged users to create 
symlinks when the machine is in developer mode. However, to ensure backwards 
compatibility, this behavior requires a flag to be passed to the 
CreateSymbolicLink function.

I think this is something that Python can benefit from having. It would go from 
"symlinks on Windows rarely work" to "symlinks on Windows work in developer 
mode (and rarely otherwise)".

I've attached a proof of concept patch to enable this behavior (a Windows 10 
machine with the 'Creators Update' is required to test it). In summary, it 
enables the flag by default, and updates enable_symlink to prevent lacking 
privilege from disabling symlinks on machines in developer mode.

--
components: Library (Lib), Windows
files: devsymlink.patch
keywords: patch
messages: 302482
nosy: paul.moore, steve.dower, tim.golden, vidartf, zach.ware
priority: normal
severity: normal
status: open
title: Add non-elevated symlink support for dev mode Windows 10
type: enhancement
versions: Python 3.6, Python 3.7
Added file: https://bugs.python.org/file47150/devsymlink.patch

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



[issue31226] shutil.rmtree fails when target has an internal directory junction (Windows)

2017-08-17 Thread Vidar Fauske

New submission from Vidar Fauske:

On Windows (Windows 10 in my case), given the following directory structure:
- rootfolder
 - a
 - b
  - junc (directory junction to ../a)

a call to `shutil.rmtree('root')` will fail with an exception 
`FileNotFoundError: [WinError 3]`, in a call to `os.listdir()` in 
`_rmtree_unsafe`. See attached minimal working example.

Note that sorting order is important: A link in 'a' pointing to 'b' does not 
fail. This is because `os.listdir()` raises an exception for 'b/junc' when its 
target ('a') has already been deleted.

Also, note that this is only for junctions, not directory links (`mklink /J` vs 
`mklink /D`), because:
 - Directory links flag false in the `stat.S_ISDIR(os.lstat('b/junc').st_mode)` 
test while junctions do not.
 - `os.islink()` returns false for both junctions, while directory links do not.

Indicated Python versions are those which I have personally tested on, and 
observed this behavior.

Current use case: Deleting a folder tree generated by an external tool, which 
creates junction links as part of its normal operation ('lerna' tool for the 
'npm' javascript package manager).

--
components: IO, Library (Lib), Windows
files: mwe.py
messages: 300424
nosy: paul.moore, steve.dower, tim.golden, vidartf, zach.ware
priority: normal
severity: normal
status: open
title: shutil.rmtree fails when target has an internal directory junction 
(Windows)
versions: Python 3.3, Python 3.6
Added file: http://bugs.python.org/file47090/mwe.py

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



[issue26024] Non-ascii Windows locale names

2016-01-06 Thread Vidar Fauske

New submission from Vidar Fauske:

The Norwegian locale on Windows has the honor of having the only locale name 
with a non-ASCII character ('Norwegian Bokmål_Norway', see e.g. 
https://wiki.postgresql.org/wiki/Changes_To_Norwegian_Locale). It does not seem 
like python 3 is able to handle this properly, as the following code 
demonstrates:

>python
Python 3.4.3 (v3.4.3:9b73f1c3e601, Feb 24 2015, 22:44:40) [MSC v.1600 64 bit 
(AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import locale
>>> locale.setlocale(locale.LC_TIME, 'swedish')
'Swedish_Sweden.1252'
>>> loc_sw = locale.getlocale(locale.LC_TIME)
>>> locale.setlocale(locale.LC_TIME, 'norwegian')
'Norwegian Bokmål_Norway.1252'
>>> loc_no = locale.getlocale(locale.LC_TIME)
>>> locale.setlocale(locale.LC_TIME, loc_sw)
'Swedish_Sweden.1252'
>>> locale.setlocale(locale.LC_TIME, loc_no)
Traceback (most recent call last):
  File "", line 1, in 
  File "C:\prog\WinPython-64bit-3.4.3.7\python-3.4.3.amd64\lib\locale.py", line 
593, in setlocale
return _setlocale(category, locale)
locale.Error: unsupported locale setting


As can be seen, this can be worked around when setting the locale manually, but 
if the locale has already been set to Norwegian, the value returned from 
getlocale is invalid when passed to setlocale.

Following the example of postgres in the link above, I suggest changing the 
behavior of locale.getlocale to alias 'Norwegian Bokmål_Norway.1252' as 
'Norwegian_Norway.1252', which is completely ASCII, and therefore fine.

--
components: Unicode, Windows
messages: 257608
nosy: ezio.melotti, haypo, paul.moore, steve.dower, tim.golden, vidartf, 
zach.ware
priority: normal
severity: normal
status: open
title: Non-ascii Windows locale names
type: behavior
versions: Python 3.4

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