[issue30267] Deprecate os.path.commonprefix

2022-02-15 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

For now, there are three uses of commonprefix() in the stdlib:

1. In urllib.request it causes a security issue (see issue46756). commonpath() 
or just str.startswith() should be used instead.

2. In lib2to3.main. The code contains a workaround around commonprefix(). It 
could be simplified by using commonpath().

3. In unittest.util. This is the only correct use of commonprefix(). It cannot 
be replaced by commonpath().

I think that we should add commonprefix() in the string module (or maybe in a 
new module for operations on sequences), deprecate os.path.commonprefix() in 
documentation only, several versions later add a deprecation warning in 
os.path.commonprefix(), and several versions later remove 
os.path.commonprefix().

--

___
Python tracker 

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



[issue30267] Deprecate os.path.commonprefix

2017-05-06 Thread Raymond Hettinger

Raymond Hettinger added the comment:

The ``os.path.commonprefix`` function has been around for a very long time.  
Deprecating it will just cause unnecessary pain for users and make it harder to 
upgrade to Python 3.  The function isn't broken, the only issue here is that a 
new function was added with a similar name.

--
nosy: +rhettinger
priority: normal -> low

___
Python tracker 

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



[issue30267] Deprecate os.path.commonprefix

2017-05-05 Thread Brett Cannon

Brett Cannon added the comment:

I agree with Serhiy that it might be time to create a seqtools module.

--
nosy: +brett.cannon

___
Python tracker 

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



[issue30267] Deprecate os.path.commonprefix

2017-05-04 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

We shouldn't deprecate a function until add an alternative. There is a working 
alternative for paths, but commonprefix() is used in the wild for non-paths 
(for example in unittest.util). The problem is that there is no right place for 
this function. The string module is wrong place because commonprefix() supports 
not only strings. Perhaps the new seqtools module would be a right place.

--
nosy: +serhiy.storchaka

___
Python tracker 

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



[issue30267] Deprecate os.path.commonprefix

2017-05-04 Thread STINNER Victor

STINNER Victor added the comment:

Ned Batchelder wrote an article about this function in 2010 :-)

https://nedbatchelder.com/blog/201003/whats_the_point_of_ospathcommonprefix.html

"""
The docs helpfully include the warning:

Note that this may return invalid paths because it works a character at a 
time.

But it should say:

This function is in the wrong place, and has nothing to do with paths, 
don't use it if you are interested in file paths!
"""

--
nosy: +haypo, nedbat

___
Python tracker 

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



[issue30267] Deprecate os.path.commonprefix

2017-05-04 Thread ProgVal

New submission from ProgVal:

The function os.path.commonprefix computes the longest prefix of strings (any 
iterable, actually), regardless of their meaning as paths.

I do not see any reason to use this function for paths, and keeping it in the 
os.path module makes it prone to be confused with os.path.commonpath (which was 
introduced in Python 3.5).

I believe making this function raise a DeprecationWarning would help avoid 
having this kind of bugs.

--
components: Library (Lib)
messages: 292993
nosy: Valentin.Lorentz
priority: normal
severity: normal
status: open
title: Deprecate os.path.commonprefix

___
Python tracker 

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