Skip to content

gh-126505: Fix bugs in compiling case-insensitive character classes #126557

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

Merged
merged 1 commit into from
Nov 11, 2024

Conversation

serhiy-storchaka
Copy link
Member

@serhiy-storchaka serhiy-storchaka commented Nov 7, 2024

  • upper-case non-BMP character was ignored
  • the ASCII flag was ignored when matching a character range whose upper bound is beyond the BMP region

…sses

* upper-case non-BMP character was ignored
* the ASCII flag was ignored when matching a character range whose
  upper bound is beyond the BMP region
@serhiy-storchaka serhiy-storchaka added needs backport to 3.12 only security fixes needs backport to 3.13 bugs and security fixes labels Nov 7, 2024
@serhiy-storchaka serhiy-storchaka merged commit 819830f into python:main Nov 11, 2024
42 checks passed
@miss-islington-app
Copy link

Thanks @serhiy-storchaka for the PR 🌮🎉.. I'm working now to backport this PR to: 3.12, 3.13.
🐍🍒⛏🤖

@serhiy-storchaka serhiy-storchaka deleted the re-charset-nonbmp branch November 11, 2024 16:27
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Nov 11, 2024
…sses (pythonGH-126557)

* upper-case non-BMP character was ignored
* the ASCII flag was ignored when matching a character range whose
  upper bound is beyond the BMP region
(cherry picked from commit 819830f)

Co-authored-by: Serhiy Storchaka <[email protected]>
@bedevere-app
Copy link

bedevere-app bot commented Nov 11, 2024

GH-126689 is a backport of this pull request to the 3.13 branch.

@bedevere-app bedevere-app bot removed the needs backport to 3.13 bugs and security fixes label Nov 11, 2024
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Nov 11, 2024
…sses (pythonGH-126557)

* upper-case non-BMP character was ignored
* the ASCII flag was ignored when matching a character range whose
  upper bound is beyond the BMP region
(cherry picked from commit 819830f)

Co-authored-by: Serhiy Storchaka <[email protected]>
@bedevere-app
Copy link

bedevere-app bot commented Nov 11, 2024

GH-126690 is a backport of this pull request to the 3.12 branch.

@bedevere-app bedevere-app bot removed the needs backport to 3.12 only security fixes label Nov 11, 2024
serhiy-storchaka added a commit that referenced this pull request Nov 11, 2024
…asses (GH-126557) (GH-126690)

* upper-case non-BMP character was ignored
* the ASCII flag was ignored when matching a character range whose
  upper bound is beyond the BMP region
(cherry picked from commit 819830f)

Co-authored-by: Serhiy Storchaka <[email protected]>
serhiy-storchaka added a commit that referenced this pull request Nov 11, 2024
…asses (GH-126557) (GH-126689)

* upper-case non-BMP character was ignored
* the ASCII flag was ignored when matching a character range whose
  upper bound is beyond the BMP region
(cherry picked from commit 819830f)

Co-authored-by: Serhiy Storchaka <[email protected]>
@wjssz
Copy link

wjssz commented Nov 15, 2024

    if fixup: # IGNORECASE and not LOCALE
        av = fixup(av)
        charmap[av] = 1

The charmap index, sometimes is fixup(av), sometimes is fixup(fixup(av)). Perhaps the result is the same, but it's not a good style.

You can fixup(av) in below, so that the code above doesn't need to be modified:

			if op is RANGE:
				if fixes: # not ASCII
					op = RANGE_UNI_IGNORE
				hascased = True
			else:
				assert op is LITERAL
				if not hascased and iscased(av):
					hascased = True
				av = fixup(av)  # <- fixup() here
		tail.append((op, av))
	break

@serhiy-storchaka
Copy link
Member Author

fixup() is only called twice when we get a non-BMP character when len(charmap) == 256. Are you talking about this situation? Than it occurs only once, and since fixup(fixup(av)) is equal to fixup(av), it does not matter. In contrary, if write the code in a way you proposed (this is how I wrote it initially too), fixup(av) will be called twice for every non-BMP literal. The difference may be not large, but this is clearly less efficient.

@wjssz
Copy link

wjssz commented Nov 16, 2024

Ok, this is not an important issue.

picnixz pushed a commit to picnixz/cpython that referenced this pull request Dec 8, 2024
…sses (pythonGH-126557)

* upper-case non-BMP character was ignored
* the ASCII flag was ignored when matching a character range whose
  upper bound is beyond the BMP region
ebonnal pushed a commit to ebonnal/cpython that referenced this pull request Jan 12, 2025
…sses (pythonGH-126557)

* upper-case non-BMP character was ignored
* the ASCII flag was ignored when matching a character range whose
  upper bound is beyond the BMP region
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.

2 participants