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

glob.glob inconsistent #45322

Open
norbidur mannequin opened this issue Aug 18, 2007 · 10 comments
Open

glob.glob inconsistent #45322

norbidur mannequin opened this issue Aug 18, 2007 · 10 comments
Labels
stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error

Comments

@norbidur
Copy link
Mannequin

norbidur mannequin commented Aug 18, 2007

BPO 1776674
Nosy @amauryfa, @ezio-melotti, @merwok, @serhiy-storchaka
Files
  • glob_preserve_sep.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 = None
    closed_at = None
    created_at = <Date 2007-08-18.00:14:50.000>
    labels = ['type-bug', 'library']
    title = 'glob.glob inconsistent'
    updated_at = <Date 2015-02-09.17:40:03.988>
    user = 'https://bugs.python.org/norbidur'

    bugs.python.org fields:

    activity = <Date 2015-02-09.17:40:03.988>
    actor = 'serhiy.storchaka'
    assignee = 'none'
    closed = False
    closed_date = None
    closer = None
    components = ['Library (Lib)']
    creation = <Date 2007-08-18.00:14:50.000>
    creator = 'norbidur'
    dependencies = []
    files = ['18284']
    hgrepos = []
    issue_num = 1776674
    keywords = ['patch']
    message_count = 10.0
    messages = ['32653', '108627', '111727', '111728', '112151', '172970', '172972', '172974', '208324', '235622']
    nosy_count = 6.0
    nosy_names = ['amaury.forgeotdarc', 'norbidur', 'kveretennicov', 'ezio.melotti', 'eric.araujo', 'serhiy.storchaka']
    pr_nums = []
    priority = 'low'
    resolution = None
    stage = 'needs patch'
    status = 'open'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue1776674'
    versions = ['Python 2.7', 'Python 3.3', 'Python 3.4']

    @norbidur
    Copy link
    Mannequin Author

    norbidur mannequin commented Aug 18, 2007

    On windows, glob.glob gives different results if you use a wildcard or not and if you use unix-style paths.

    exemple :
    import glob
    print glob.glob("c:/tmp/3691674.jpg")
    print glob.glob("c:/tmp/3691674.jpg*")
    print glob.glob("c:/res.txt")
    print glob.glob("c:/res.txt*")

    gives :
    ['c:/tmp/3691674.jpg']
    ['c:/tmp\\3691674.jpg']
    ['c:/res.txt']
    ['c:/res.txt']

    the two first calls give the same result but one with a platform specific separator, and not the other.
    One can think that if there is no wildcard, this is normal behavior to return the path given to glob.glob but then I have the second inconsitency : in that case the last result should be c:\\res.txt.

    @norbidur norbidur mannequin added stdlib Python modules in the Lib dir labels Aug 18, 2007
    @devdanzin devdanzin mannequin added OS-windows type-bug An unexpected behavior, bug, or error labels Apr 7, 2009
    @BreamoreBoy
    Copy link
    Mannequin

    BreamoreBoy mannequin commented Jun 25, 2010

    Hardly a show stopper. It's actually a problem(?) with ntpath.py. It could be patched but is it worth it, as this would be yet more work for you guys doing the build/release process? I'd close this on the grounds that it's not worth the effort.

    @BreamoreBoy
    Copy link
    Mannequin

    BreamoreBoy mannequin commented Jul 27, 2010

    As no response to msg108627 I'll close this unless there are any objections.

    @merwok
    Copy link
    Member

    merwok commented Jul 27, 2010

    Some bugs take a long time to get fixed. I agree that three years is not a good score, but this really needs a test in order to get closed or fixed, so I’m reopening. Maybe the OP or you could add a test? :)

    @amauryfa
    Copy link
    Member

    Here is a test + patch, to preserve the separator. Of course this changes the current behaviour, like:
    >>> glob.glob('/tmp/////foo*')
    ['/tmp/////foo1', '/tmp/////foo2']

    @serhiy-storchaka
    Copy link
    Member

    The question is what result desirable for glob.glob("c:/tmp///3691674.jpg*"), ['c:/tmp///3691674.jpg'] or ['c:\\tmp\\3691674.jpg']?

    @serhiy-storchaka
    Copy link
    Member

    I have added some comments in Rietveld.

    @serhiy-storchaka
    Copy link
    Member

    Shell preserves the separators. Well, in any case we always can apply os.path.normpath() to result.

    @serhiy-storchaka
    Copy link
    Member

    Amaury, could you provide corrected patch?

    @serhiy-storchaka
    Copy link
    Member

    Ping.

    @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
    Status: No status
    Development

    No branches or pull requests

    3 participants