sqlalchemy / mako

Mako Templates for Python
https://www.makotemplates.org
MIT License
353 stars 60 forks source link

%% anywhere in input is now replaced with % #384

Closed kroeschl closed 7 months ago

kroeschl commented 7 months ago

Starting with Mako 1.3.1, %% anywhere in input now renders to %. This is a change in behavior from previous releases.

It's unclear to me if this is intended. The documentation says that %% can be used to render a % at the start of a line, but it doesn't explicitly state how %% is handled elsewhere in a line. My first interpretation was that %% elsewhere in a line wouldn't be changed.

Simple reproducing case:

$ pip install mako==1.3.0
...
Successfully installed mako-1.3.0
$ mako-render - <<< foo%%bar
foo%%bar
$ pip install mako==1.3.1
...
Successfully installed mako-1.3.1
$ mako-render - <<< foo%%bar
foo%bar

This is related to #383. From the discussion there, it seems like this was expected to possibly break users, but it's not clear to me if it was expected to break all use of %% not at the start of a line or just %% at the start of a line after whitespace (which I would expect).

zzzeek commented 7 months ago

hi -

I just read your case more closely, and I deleted what I wrote since I assumed you were referring to the simple behavioral change of % as the first non-whitespace character.

I will evaluate your case, but I am leaning towards releasing this as Mako 1.4.0 with a stronger note and backwards compatibility note, revoking 1.3.1

zzzeek commented 7 months ago

I've yanked the release and reverted the change.

kroeschl commented 7 months ago

Perfect, thanks for the quick response!

zzzeek commented 7 months ago

please note that the fix will still impact double percent signs as the first non whitespace character on a line

zzzeek commented 7 months ago

a new version of this fix is merged in 1d6c58e7124653bc11b0a4f153bdbaab41622854 and I'm going to put 1.3.2 out with it. since it's the only change again, if more issues we can keep reverting until we get it right (I haven't spent much time on Mako in over a decade)