This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Avoid using private function glob.glob1() in msi module and tools
Type: behavior Stage: resolved
Components: Library (Lib) Versions: Python 3.6, Python 3.5, Python 2.7
process
Status: closed Resolution: fixed
Dependencies: 8402 Superseder:
Assigned To: serhiy.storchaka Nosy List: berker.peksag, loewis, python-dev, rhettinger, serhiy.storchaka, steve.dower
Priority: normal Keywords: patch

Created on 2012-12-05 19:34 by serhiy.storchaka, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
issue16620.diff berker.peksag, 2013-02-27 15:04 review
msilib_no_glob1.patch serhiy.storchaka, 2016-01-02 15:51 review
Messages (8)
msg177001 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2012-12-05 19:34
Private function glob.glob1() used in Lib/msilib and Tools/msi to prevent unexpected globbing in parent directory name. ``glob.glob1(dirname, pattern)`` should be replaced by ``glob.glob(os.path.join(fnmatch.escape(dirname), pattern)`` in external code.
msg183433 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2013-03-04 12:04
I have added some comments on Rietveld.

Note that glob.glob() and glob.glob1() returns different filenames. The first returns full paths and the second returns bare filenames without a directory path. Workarounding this may require more in-depth changes to the code.

Actually this is a low priority issue. It is no so bad to use private functions from other modules inside Python stdlib. But it can be a bad example for a third party code.
msg222921 - (view) Author: Mark Lawrence (BreamoreBoy) * Date: 2014-07-13 12:33
Just a reminder that there are comments on Rietveld.
msg223005 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2014-07-14 09:01
Martin, this patch touches some of your code.  Do you care to take a look at it?
msg257348 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2016-01-02 15:51
For now there is only one place left that uses glob1(). Here is a patch that inlines glob1() in that place.
msg257349 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2016-01-02 15:54
The patch for issue25596 removes glob1(), so we should get rid of its usage.
msg258541 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2016-01-18 19:53
It looks to me that the glob() method of msilib.Directory is broken from the born. It uses the function from the glob module, but the glob module is not imported in this source file.

Even if add missed import, returned value is incorrect in Python 3. In Python 2 glob.glob1() always returned a list, but in in Python 3 it can return an empty list or an iterator. After iterating on it msilib.Directory returns an empty list or exhausted iterator.
msg258585 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2016-01-19 12:10
New changeset 652a50208e89 by Serhiy Storchaka in branch '3.5':
Issue #16620: Fixed AttributeError in msilib.Directory.glob().
https://hg.python.org/cpython/rev/652a50208e89

New changeset 158ae15f5809 by Serhiy Storchaka in branch '2.7':
Issue #16620: Fixed AttributeError in msilib.Directory.glob().
https://hg.python.org/cpython/rev/158ae15f5809

New changeset 84a50f14a266 by Serhiy Storchaka in branch 'default':
Issue #16620: Fixed AttributeError in msilib.Directory.glob().
https://hg.python.org/cpython/rev/84a50f14a266

New changeset f2586c381b0b by Serhiy Storchaka in branch 'default':
Issue #16620: Got rid of using undocumented function glob.glob1().
https://hg.python.org/cpython/rev/f2586c381b0b
History
Date User Action Args
2022-04-11 14:57:39adminsetgithub: 60824
2016-01-19 12:11:07serhiy.storchakasetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2016-01-19 12:10:42python-devsetnosy: + python-dev
messages: + msg258585
2016-01-19 09:43:32BreamoreBoysetnosy: - BreamoreBoy
2016-01-18 19:53:09serhiy.storchakasettype: enhancement -> behavior
messages: + msg258541
versions: + Python 2.7, Python 3.5
2016-01-02 15:54:04serhiy.storchakasetpriority: low -> normal

messages: + msg257349
2016-01-02 15:52:32serhiy.storchakalinkissue25596 dependencies
2016-01-02 15:51:35serhiy.storchakasetfiles: + msilib_no_glob1.patch
versions: + Python 3.6, - Python 3.5
messages: + msg257348

components: - Demos and Tools, Windows
stage: needs patch -> patch review
2016-01-02 15:24:23serhiy.storchakasetassignee: loewis -> serhiy.storchaka
2015-04-28 02:59:23BreamoreBoysetnosy: + steve.dower
2014-07-14 09:01:56rhettingersetassignee: loewis

messages: + msg223005
nosy: + loewis, rhettinger
2014-07-13 12:33:08BreamoreBoysetnosy: + BreamoreBoy

messages: + msg222921
versions: + Python 3.5, - Python 3.4
2013-03-04 12:04:33serhiy.storchakasetpriority: normal -> low

messages: + msg183433
components: + Windows
2013-02-27 15:04:58berker.peksagsetfiles: + issue16620.diff
nosy: + berker.peksag
keywords: + patch
2012-12-05 19:35:28serhiy.storchakasetdependencies: + Add a function to escape metacharacters in glob/fnmatch
2012-12-05 19:34:09serhiy.storchakacreate