[issue40271] Allow shell like paths in

2020-04-16 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

If add such option to zipfile.is_zipfile(), why not add it to other functions? 
There are many tens or hundreds of functions and methods in the stdlib which 
accept a file path. Adding such option to all of them is not practical. And 
zipfile.is_zipfile() does not look special.

Also, there are other options which you may want to add to 
zipfile.is_zipfile(). What about expandvars()? Or support URIs with the 
file:/// scheme? Or maybe someone want to replace ~ with the project directory 
instead of the home directory.

It is better to provide functions for every tiny feature and combine them as 
you want than add an infinite number of options to all functions.

--
resolution:  -> rejected
stage:  -> resolved
status: open -> closed

___
Python tracker 

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



[issue40271] Allow shell like paths in

2020-04-16 Thread Massimo Sala


Massimo Sala  added the comment:

Gavin, zipfile works on all the operating systems where python runs.
Your request is OS dependent... BSD? linux?

The tilde isn't into the ZIP file specifications.
I have to agree with Serhiy: the correct solution is
os.path.expanduser("~/stuff")

--
nosy: +massimosala

___
Python tracker 

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



[issue40271] Allow shell like paths in

2020-04-14 Thread Gavin D'souza


Gavin D'souza  added the comment:

@serhiy.storchaka That makes perfect sense. Could we do something to add a 
parameter perhaps, to evaluate literal paths to not bread existing code? 
although this isn't "needed" but it'd be neat to handle this internally

--

___
Python tracker 

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



[issue40271] Allow shell like paths in

2020-04-13 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

How would you work with a file in the "~" directory?

Python is a programming language. It provides you builtin blocks which you can 
combine to get the desired behavior. If you what "~" at the start of the path 
be expanded to your home directory, you call os.path.expanduser() explicitly. 
If you want it mean the literal "~" directory, you do not call 
os.path.expanduser(). Calling it implicitly would break existing code, require 
you to use ugly workarounds if you don't want to expand "~", and introduce 
possible security issues.

--
nosy: +serhiy.storchaka

___
Python tracker 

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



[issue40271] Allow shell like paths in

2020-04-13 Thread Gavin D'souza


Gavin D'souza  added the comment:

Thank you @xtreak, I'm aware of "os.path.expanduser" and have used it 
extensively; I created this issue if we could do something about handling this 
internally in zipfile too.

--

___
Python tracker 

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



[issue40271] Allow shell like paths in

2020-04-13 Thread Karthikeyan Singaravelan


Karthikeyan Singaravelan  added the comment:

You can use os.path.expanduser to expand tilde. Other os functions don't do it 
implicitly.

>>> import os
>>> os.path.exists("~/stuff")
False
>>> os.path.exists(os.path.expanduser("~/stuff"))
True

--
nosy: +xtreak

___
Python tracker 

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



[issue40271] Allow shell like paths in

2020-04-13 Thread Gavin D'souza


New submission from Gavin D'souza :

Related library: zipfile

Since zipfile allows relative dotted paths too, should shell-like paths, 
specifically with ~ (tilde) be allowed too?

This feels like unexpected behaviour and confusing for users as method 
"is_zipfile" returns False in case path doesn't exist as well. So, 
zipfile.is_zipfile("~/incorrect/path/to/zip") as well as 
zipfile.is_zipfile("~/path/to/zip") will return False

--
components: Library (Lib)
messages: 366297
nosy: gavin
priority: normal
severity: normal
status: open
title: Allow shell like paths in
type: behavior
versions: Python 2.7, Python 3.5, Python 3.6, Python 3.7, Python 3.8, Python 3.9

___
Python tracker 

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