One function

is_confusable in vhf/confusable_homoglyphs

The author described this change as Fix #11: work as expected when char not found in datafiles. It counts as a record because the check below fails on the code as it stood at 0fcfb2b77 and passes on 785aee669, with nothing else changed between the two runs.

Fix saved2018-08-31
Sharing licenceMIT · LICENSE
Change size+3 1

What the code was meant to do, written into the code itself as a docstring

Checks if `string` contains characters which might be confusable with characters from `preferred_aliases`. If `greedy=False`, it will only return the first confusable character found without looking at the rest of the string, `greedy=True` returns all of them. `preferred_aliases=[]` can take an array of unicode block aliases to be considered as your 'base' unicode blocks: - considering `paρa`, - with `preferred_aliases=['latin']`, the 3rd character `ρ` would be returned because this greek letter can be confused with latin `p`. - with `preferred_aliases=['greek']`, the 1st character `p` would be returned because this latin letter can be confused with greek `ρ`. - with `preferred_aliases=[]` and `greedy=True`, you'll discover the 29 characters that can be confused with `p`, the 23 characters that look like `a`, and the one that looks like `ρ` (which is, of course, *p* aka *LATIN SMALL LETTER P*). :param string: A unicode string :type string: str :param greedy: Don't stop on finding one confusable character - find all of them. :type greedy: bool :param preferred_aliases: Script blocks aliases which we don't want `string`'s characters to be confused with. :type preferred_aliases: list(str) :return: False if not confusable, all confusable characters and with what they are confusable otherwise. :rtype: bool or list

The change

6060 # it's safe if the character might be confusable with homoglyphs from other
6161 # categories than our preferred categories (=aliases)
6262 continue
63- found = confusables_data.get(char)
63+ found = confusables_data.get(char, False)
64+ if found is False:
65+ continue
6466 # character λ is considered confusable if λ can be confused with a character from
6567 # preferred_aliases, e.g. if 'LATIN', 'ρ' is confusable with 'p' from LATIN.
6668 # if 'LATIN', 'Γ' is not confusable because in all the characters confusable with Γ,

The check that tells the two apart

failpass·tests/test_confusables.py::TestConfusables::test_char_not_found

Check file tests/test_confusables.py, taken without changes from the fix and copied onto the older code, so the exact same check runs against both versions.

Origin and history

The code before it0fcfb2b773e5431586c2621048af95dd5f8e7090
Broken version dated2018-05-15
Moduleconfusable_homoglyphs.confusables
Units changedis_confusable
Fingerprinte67c42879a9f9dd7
Checked2026-08-18 by goldset/0.1

Every field above is generated by our program. None of it is written by hand.