Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid using private function glob.glob1() in msi module and tools #60824

Closed
serhiy-storchaka opened this issue Dec 5, 2012 · 8 comments
Closed
Assignees
Labels
stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error

Comments

@serhiy-storchaka
Copy link
Member

BPO 16620
Nosy @loewis, @rhettinger, @berkerpeksag, @serhiy-storchaka, @zooba
Dependencies
  • bpo-8402: Add a function to escape metacharacters in glob/fnmatch
  • Files
  • issue16620.diff
  • msilib_no_glob1.patch
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = 'https://github.com/serhiy-storchaka'
    closed_at = <Date 2016-01-19.12:11:07.526>
    created_at = <Date 2012-12-05.19:34:09.210>
    labels = ['type-bug', 'library']
    title = 'Avoid using private function glob.glob1() in msi module and tools'
    updated_at = <Date 2016-01-19.12:11:07.526>
    user = 'https://github.com/serhiy-storchaka'

    bugs.python.org fields:

    activity = <Date 2016-01-19.12:11:07.526>
    actor = 'serhiy.storchaka'
    assignee = 'serhiy.storchaka'
    closed = True
    closed_date = <Date 2016-01-19.12:11:07.526>
    closer = 'serhiy.storchaka'
    components = ['Library (Lib)']
    creation = <Date 2012-12-05.19:34:09.210>
    creator = 'serhiy.storchaka'
    dependencies = ['8402']
    files = ['29263', '41475']
    hgrepos = []
    issue_num = 16620
    keywords = ['patch']
    message_count = 8.0
    messages = ['177001', '183433', '222921', '223005', '257348', '257349', '258541', '258585']
    nosy_count = 6.0
    nosy_names = ['loewis', 'rhettinger', 'python-dev', 'berker.peksag', 'serhiy.storchaka', 'steve.dower']
    pr_nums = []
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue16620'
    versions = ['Python 2.7', 'Python 3.5', 'Python 3.6']

    @serhiy-storchaka
    Copy link
    Member Author

    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.

    @serhiy-storchaka serhiy-storchaka added type-feature A feature request or enhancement stdlib Python modules in the Lib dir labels Dec 5, 2012
    @serhiy-storchaka
    Copy link
    Member Author

    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.

    @BreamoreBoy
    Copy link
    Mannequin

    BreamoreBoy mannequin commented Jul 13, 2014

    Just a reminder that there are comments on Rietveld.

    @rhettinger
    Copy link
    Contributor

    Martin, this patch touches some of your code. Do you care to take a look at it?

    @serhiy-storchaka
    Copy link
    Member Author

    For now there is only one place left that uses glob1(). Here is a patch that inlines glob1() in that place.

    @serhiy-storchaka
    Copy link
    Member Author

    The patch for bpo-25596 removes glob1(), so we should get rid of its usage.

    @serhiy-storchaka
    Copy link
    Member Author

    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.

    @serhiy-storchaka serhiy-storchaka added type-bug An unexpected behavior, bug, or error and removed type-feature A feature request or enhancement labels Jan 18, 2016
    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented Jan 19, 2016

    New changeset 652a50208e89 by Serhiy Storchaka in branch '3.5':
    Issue bpo-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 bpo-16620: Fixed AttributeError in msilib.Directory.glob().
    https://hg.python.org/cpython/rev/158ae15f5809

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

    New changeset f2586c381b0b by Serhiy Storchaka in branch 'default':
    Issue bpo-16620: Got rid of using undocumented function glob.glob1().
    https://hg.python.org/cpython/rev/f2586c381b0b

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    2 participants