[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Python-Dev] Normalisation of unicode and keywords


On 18.05.2018 14:46, Steven D'Aprano wrote:
> Stephan Houben noticed that Python apparently allows identifiers to be
> keywords, if you use Unicode "mathematical bold" letters. His
> explanation is that the identifier is normalised, but not until after
> keywords are checked for. So this works:
>
> class Spam:
>      locals()['if'] = 1
>
>
> Spam.??    # U+1D422 U+1D41F
> # returns 1
>
>
> Of course Spam.if fails with SyntaxError.
>
> Should this work? Is this a bug, a feature, or an accident of
> implementation we can ignore?
Voting for bug:
Either those identifiers should be considered equal, or they shouldn't. 
They can't be considered "partially" equal.
>
>

-- 
Regards,
Ivan