[issue39544] Pathlib PureWindowsPath sorting incorrect (is not natural sort)

2020-02-03 Thread tegavu

New submission from tegavu :

Wrong behavior in pathlib.PureWindowsPath - sorting does not use natural sort.

Everything below was written based on W7x64 & Python 3.8.1 
(tags/v3.8.1:1b293b6, Dec 18 2019, 23:11:46) [MSC v.1916 64 bit (AMD64)] on 
win32.

The documentation 
(https://docs.python.org/3/library/pathlib.html#general-properties) states: 
"Paths of a same flavour are comparable and orderable."

This can be done like this:

from pathlib import *
print( PureWindowsPath('C:\\1') < PureWindowsPath('C:\\a') )

This returns True. This is expected because 1 is sorted before a on Windows.

This sorting also works well for harder cases where other sorting functions 
fail: !1 should be before 1 and !a should be before a.

But it fails with natural sorting:

from pathlib import *
print( PureWindowsPath('C:\\15') < PureWindowsPath('C:\\100') )

This returns False.

This is a bug in my opinion, since PureWindowsPath should sort like 
Windows(Explorer) would sort. 

Right now PureWindowsPath does probably something like NTFS sorting, but NTFS 
is not Windows and from a function called 'WindowsPath' I expect a path that 
would be given in Windows Explorer.

In case a simple `dir` on Windows sorts by NTFS names (I am not sure!), 
PureWindowsPath also fails, since (for example) "[" < "a" should be False.

See this image for comparison:
https://i.imgur.com/GjBhWsS.png

Here is a string that can be used directly as a list to check sorting:

test_list = ['15', '100', '1', '!', '#', '$', '%', '&', "'", '(', ')', '+', 
'+1', '+a', ',', '-', ';', '=', '@', '[', ']', '^', '_', '`', 'a', 
'foo0', 'foo_0', '{', '}', '~', '§', '°', '´', 'µ', '€']

--
messages: 361315
nosy: tegavu
priority: normal
severity: normal
status: open
title: Pathlib PureWindowsPath sorting incorrect (is not natural sort)
type: behavior
versions: Python 3.8

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



[issue18877] tkinter askopenfilenames does not work in Windows library folder

2013-08-29 Thread tegavu

New submission from tegavu:

Using Python 3.3 on W7x64 I wanted to create a file dialog that allows me to 
select multiple files.
The code below is an example of how to re-create the bug.

# -*- coding: iso-8859-15 -*-
# Python 3

import tkinter 
import tkinter.filedialog  

def callback():
name = tkinter.filedialog.askopenfilenames() 
print(name)
 
tkinter.Button(text='File Open', command=callback).pack()
tkinter.mainloop()


-
THE PROBLEM:
When selecting any file in the windows library\* folders (those: 
http://beingpc.com/wp-content/uploads/2011/05/How-to-Change-the-Windows-7-Library-Icon.jpg
 ) the return value that will be printed is always {}.
tkinter.filedialog.askopenfilename() (without the 's') works fine also in those 
directories.

Can anyone reproduce this behavior?

--
components: Tkinter, Windows
messages: 196479
nosy: tegavu
priority: normal
severity: normal
status: open
title: tkinter askopenfilenames does not work in Windows library folder
type: behavior
versions: Python 3.3

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



[issue22744] os.path.join on Windows creates invalid paths with spaces

2014-10-27 Thread tegavu

New submission from tegavu:

Windows does not like/permit folders with spaces in the beginning or folders 
and files with a tailing space character, as this will cause problems.
The python functions for os.mkdir will solve this by eliminating the blanks 
automatically.
But os.path.join() will give wrong results.

Example:

#Python 3.4.0 (v3.4.0:04f714765c13, Mar 16 2014, 19:25:23)
import os
dir1 = "c:\\"
dir2 = "test   "
file = "test.txt" 

os.mkdir( os.path.join(dir1, dir2) )
# this will correctly create c:\test\
f = open( os.path.join(dir1, dir2, file) ,"wb")
# this will fail with 'FileNotFoundError: [Errno 2] No such file or 
directory: 'c:\\test \\test.txt''
print("__" + os.path.join(dir1, dir2, file) + "__")   
# this will incorrectly show 'c:\test \test.txt'
# or if you chose to also have spaces at the end of "test.txt " will 
show them

--
messages: 230082
nosy: tegavu
priority: normal
severity: normal
status: open
title: os.path.join on Windows creates invalid paths with spaces
type: behavior
versions: Python 3.4

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



[issue22744] os.mkdir on Windows silently strips trailing blanks from directory names

2014-10-27 Thread tegavu

tegavu added the comment:

Well then the bug is also for example in the open() to create a file, beause it 
will also remove tailing spaces (files can have spaces in the front, while 
folders cannot have spces on either side).

Although I still think an API to create a path should warn if this path cannot 
be valid.

--

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