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

Inconsistent behaviour between Cython and CPython (or lack of docs, or both) #991

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
31 changes: 31 additions & 0 deletions tests/test_url_parsing.py
Original file line number Diff line number Diff line change
Expand Up @@ -584,3 +584,34 @@ def test_empty_path(self):
assert u.path == ""
assert u.query_string == ""
assert u.fragment == ""

def test_truncated_utf_sequence(self):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If path is the only difference, could you parametrize the test?

raw_path = b"/P\xc3\xbcnktchen\xa0\xef\xb7#"
abspath, _hash_separator, frag = raw_path.decode(
"utf-8", "surrogateescape"
).partition("#")
u = URL.build(path=abspath, query_string="", fragment=frag, encoded=True)
u2 = URL("/P%C3%BCnktchen\udca0\udcef\udcb7")
assert u.scheme == ""
assert u.user is None
assert u.password is None
assert u.path == "/Pünktchen\udca0\udcef\udcb7"
assert u.query_string == ""
assert u.fragment == ""
assert u.path == u2.path

def test_truncated_utf_sequence_frag(self):
raw_path = b"/P\xc3\xbcnktchen\xa0\xef\xb7#P\xc3\xbcnktelchen\xa0\xef\xb6"
abspath, _hash_separator, frag = raw_path.decode(
"utf-8", "surrogateescape"
).partition("#")
u = URL.build(path=abspath, query_string="", fragment=frag, encoded=True)
u2 = URL("/P%C3%BCnktchen\udca0\udcef\udcb7#Pünktelchen\udca0\udcef\udcb6")
assert u.scheme == ""
assert u.user is None
assert u.password is None
assert u.path == "/Pünktchen\udca0\udcef\udcb7"
assert u.query_string == ""
assert u.fragment == "Pünktelchen\udca0\udcef\udcb6"
assert u.path == u2.path
# assert u.fragment == u2.fragment
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# assert u.fragment == u2.fragment