miracle2k / miracle2k/python-glob2

How can `sep` parameter be used? Is it broken?

Open
#26 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
125
Forks
20
PR merge metrics
No merged PRs in 30d

Description

I'm using a custom globber that internally uses only forward slashes and I also consistently specify sep='/' to iglob etc., and yet, on Windows I can still get paths joined by '\'.

I see that this sep is only being passed to _join_paths, and inside it all that happens is that / gets replaced with this character. What about replacing \, though?

https://github.com/miracle2k/python-glob2/blob/ef4b58f0d2a6eb0197446ab4b047cc45e4c60500/glob2/impl.py#L211-L215

There's also a suspicious backslash (that has no effect at all) inside the pattern 🤔

It's strange that os.path.join is being used for this library, which strives to fully abstract this operation -- and currently seems like I have no better option but to map all its outputs through pathlib.Path(p).to_posix(). This particular operation is not overridable.

So, my use case doesn't work, but I also find it difficult to understand how sep can be used at all, as on Windows it will always just be skipped.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with glob2/impl.py around lines 211-215 and reproduce the custom-globber case on Windows with sep='/'. Trace how _join_paths and os.path.join handle separators, then define and test the expected sep behavior, including the suspicious backslash noted in the issue.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
28/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.