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

Different glob() results for strings and bytes #60822

Closed
serhiy-storchaka opened this issue Dec 5, 2012 · 12 comments
Closed

Different glob() results for strings and bytes #60822

serhiy-storchaka opened this issue Dec 5, 2012 · 12 comments
Labels
stdlib Python modules in the Lib dir tests Tests in the Lib/test dir type-bug An unexpected behavior, bug, or error

Comments

@serhiy-storchaka
Copy link
Member

BPO 16618
Nosy @jcea, @pitrou, @hynek, @serhiy-storchaka
Files
  • glob_dotfiles.patch
  • glob_tests-2.7.patch: Tests only for 2.7
  • glob_dotfiles_2.patch
  • glob_tests-2.7_2.patch
  • glob_dotfiles_3.patch
  • glob_tests-2.7_3.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 = <Date 2012-12-27.09:40:54.558>
    created_at = <Date 2012-12-05.17:09:02.434>
    labels = ['tests', 'type-bug', 'library']
    title = 'Different glob() results for strings and bytes'
    updated_at = <Date 2012-12-27.09:40:54.556>
    user = 'https://github.com/serhiy-storchaka'

    bugs.python.org fields:

    activity = <Date 2012-12-27.09:40:54.556>
    actor = 'hynek'
    assignee = 'none'
    closed = True
    closed_date = <Date 2012-12-27.09:40:54.558>
    closer = 'hynek'
    components = ['Library (Lib)', 'Tests']
    creation = <Date 2012-12-05.17:09:02.434>
    creator = 'serhiy.storchaka'
    dependencies = []
    files = ['28211', '28212', '28338', '28339', '28398', '28399']
    hgrepos = []
    issue_num = 16618
    keywords = ['patch']
    message_count = 12.0
    messages = ['176991', '176992', '177597', '177617', '177619', '177621', '177623', '177944', '177948', '177949', '178284', '178285']
    nosy_count = 5.0
    nosy_names = ['jcea', 'pitrou', 'python-dev', 'hynek', 'serhiy.storchaka']
    pr_nums = []
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue16618'
    versions = ['Python 2.7', 'Python 3.2', 'Python 3.3', 'Python 3.4']

    @serhiy-storchaka
    Copy link
    Member Author

    glob ignores names which starts with dot if pattern is not starts with dot. But this is wrong for bytes pattern in Python 3.

    >>> import glob
    >>> glob.glob('*hg')
    []
    >>> glob.glob(b'*hg')
    [b'.hg']

    The proposed patch fixes this inconsistency. Also it contains new tests for this and some other possible cases.

    @serhiy-storchaka serhiy-storchaka added stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error labels Dec 5, 2012
    @serhiy-storchaka
    Copy link
    Member Author

    Python 2.7 is not needed the fix, however additional tests can be useful. Here is a patch.

    @serhiy-storchaka serhiy-storchaka added the tests Tests in the Lib/test dir label Dec 5, 2012
    @pitrou
    Copy link
    Member

    pitrou commented Dec 16, 2012

    See also bpo-16696.

    @pitrou
    Copy link
    Member

    pitrou commented Dec 16, 2012

    The patch doesn't apply cleanly.

    @serhiy-storchaka
    Copy link
    Member Author

    Patches updated to resolve conflicts with recent commits. Some minor test
    errors fixed.

    @serhiy-storchaka
    Copy link
    Member Author

    Patches updated. Unrelated changes removed.

    @serhiy-storchaka
    Copy link
    Member Author

    Yet one attempt.

    @hynek
    Copy link
    Member

    hynek commented Dec 22, 2012

    Serhiy, are you going to update your patches? I can implement the feedback of our Q4 Community Service Award awardee too in case you’re busy.

    @serhiy-storchaka
    Copy link
    Member Author

    Aha! It's OS/2 where glob('*/') returns result without trailing slash. Here also glob() can return str (on 2.7) result for unicode pattern.

    @serhiy-storchaka
    Copy link
    Member Author

    Here is an updated patches. I hope it satisfies Antoine's comments.

    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented Dec 27, 2012

    New changeset 62f67a52b0c2 by Hynek Schlawack in branch '3.2':
    bpo-16618: Make glob.glob match consistently across strings and bytes
    http://hg.python.org/cpython/rev/62f67a52b0c2

    New changeset fa8c4f96d990 by Hynek Schlawack in branch '3.3':
    bpo-16618: Make glob.glob match consistently across strings and bytes
    http://hg.python.org/cpython/rev/fa8c4f96d990

    New changeset eae2a42603ee by Hynek Schlawack in branch 'default':
    bpo-16618: Make glob.glob match consistently across strings and bytes
    http://hg.python.org/cpython/rev/eae2a42603ee

    New changeset 44609ff7e53c by Hynek Schlawack in branch '2.7':
    bpo-16618: Add more glob regression tests
    http://hg.python.org/cpython/rev/44609ff7e53c

    @hynek
    Copy link
    Member

    hynek commented Dec 27, 2012

    Thanks Serhiy!

    @hynek hynek closed this as completed Dec 27, 2012
    @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 tests Tests in the Lib/test dir type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    3 participants