Bug report
Bug description:
> import glob
> glob.translate('[][!]')
(?s:[][!])\Z
This specific example is explicitly mentioned in man glob
:
The string enclosed by the
brackets cannot be empty; therefore ']' can be allowed between the
brackets, provided that it is the first character. (Thus, "[][!]"
matches the three characters '[', ']', and '!'.)
Therefore, the expected regex would be (?s:[\[\]!])\Z
, while the actual one simplifies to just (?s:!)\Z
, only matching literal '!'
.
Related to #130942 , where character classes do not correctly handle path separator.
CPython versions tested on:
3.13
Operating systems tested on:
Linux