Skip to content

How can sep parameter be used? Is it broken? #26

Open

Description

@oprypin

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?

python-glob2/glob2/impl.py

Lines 211 to 215 in ef4b58f

def _join_paths(paths, sep=None):
path = join(*paths)
if sep:
path = re.sub(r'\/', sep, path) # cached internally
return path

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.

Activity

  1. oprypin commented on Dec 5, 2020

    @oprypin
    Author
  2. ankostis commented on Dec 11, 2020

    @ankostis
    Contributor

    Just looking at the suspicious backslash seems like a bug.
    Cannot help further, because the functioning of this project has slipped my mind after all this time.

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

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions