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

Fix non-ASCII support for prettytoml #3176

Merged
merged 7 commits into from
Nov 7, 2018

Conversation

frostming
Copy link
Contributor

@frostming frostming commented Nov 6, 2018

Thank you for contributing to Pipenv!

The issue

Fix #2737 Prettytoml doens't support non-ASCII characters well.

The fix

Since the upstream doesn't seem to be maintained anymore, I create a patch for prettytoml. The fix works well on my machine(3.7, Windows/WSL)

The checklist

  • Associated issue
  • A news fragment in the news/ directory to describe this fix with the extension .bugfix, .feature, .behavior, .doc. .vendor. or .trivial (this will appear in the release changelog). Use semantic line breaks and name the file after the issue number or the PR #.

@frostming
Copy link
Contributor Author

Python2.7 is still not working when non-ASCII character exists in package name/path or virtualenv location. But I am not going to fix it in this PR. There are other issues tracking unicode support in Python 2.

@techalchemy
Copy link
Member

I have a different PR (I think me and @uranusjr are both working on seeing about switching to tomlkit) but would want to see if you can review, no idea if it will even work yet though

@frostming
Copy link
Contributor Author

That's good, I will take a look into that library.

@techalchemy
Copy link
Member

we should put in a good testing framework like hypothesis for cases like this, I'm using that over in vistir for path encodings:

https://github.com/sarugaku/vistir/blob/master/tests/strategies.py#L92

@given(legal_path_chars(), legal_path_chars())
@settings(suppress_health_check=(HealthCheck.filter_too_much,))
def test_mkdir_p(base_dir, subdir):
    assume(not any((dir_name in ["", ".", "./", ".."] for dir_name in [base_dir, subdir])))
    assume(not (os.path.relpath(subdir, start=base_dir) == "."))
    assume(os.path.abspath(base_dir) != os.path.abspath(os.path.join(base_dir, subdir)))
    with vistir.compat.TemporaryDirectory() as temp_dir:
        target = os.path.join(temp_dir.name, base_dir, subdir)
        assume(vistir.path.abspathu(target) != vistir.path.abspathu(os.path.join(temp_dir.name, base_dir)))
        target = vistir.misc.to_bytes(target, encoding="utf-8")
        vistir.path.mkdir_p(target)
        assert os.path.exists(target)

@techalchemy
Copy link
Member

I have no clue why this fixes anything but uh, i'll take it. Thank you for sorting this out, it could be a long time before we sort the issues with tomlkit out the rest of teh way.

@uranusjr, any reservations?

@techalchemy techalchemy merged commit 6b13d5a into pypa:master Nov 7, 2018
@frostming frostming deleted the non-ascii-toml branch November 8, 2018 03:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

prettytoml.tokens.errors.BadEscapeCharacter on Pipfile
2 participants