Skip to content

glob.glob inconsistent #45322

Open
Open

Description

@norbidur
mannequin
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']

    Linked PRs

    Activity

    1. norbidur commented on Aug 18, 2007

      norbidurmannequin
      MannequinAuthor

      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.

    2. added
      stdlib
      on Aug 18, 2007
    3. added
      type-bug
      on Apr 7, 2009
    4. BreamoreBoy commented on Jun 25, 2010

      BreamoreBoymannequin
      Mannequin

      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.

    5. BreamoreBoy commented on Jul 27, 2010

      BreamoreBoymannequin
      Mannequin

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

    6. merwok commented on Jul 27, 2010

      @merwok
      Member

      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? :)

    7. amauryfa commented on Jul 31, 2010

      @amauryfa
      Contributor
      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']
    8. serhiy-storchaka commented on Oct 15, 2012

      @serhiy-storchaka
      Member

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

    9. serhiy-storchaka commented on Oct 15, 2012

      @serhiy-storchaka
      Member

      I have added some comments in Rietveld.

    10. serhiy-storchaka commented on Oct 15, 2012

      @serhiy-storchaka
      Member

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

    11. serhiy-storchaka commented on Jan 17, 2014

      @serhiy-storchaka
      Member

      Amaury, could you provide corrected patch?

    12. serhiy-storchaka commented on Feb 9, 2015

      @serhiy-storchaka
      Member

      Ping.

    13. transferred this issue fromon Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Metadata

    Metadata

    Assignees

    No one assigned

      Labels

      stdlibtype-bug

      Projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions