This just get's stranger and stranger. Regenerating psp_parser.c from the current psp_parser.l has caused my psp pages to go completely pair-shaped. Things that rendered correctly before now puke up hairballs.

For example the psp code (where my_link = 'some_url'):
    <a href="<%= my_link %>">My Link</a>
used to render as:
    <a href="some_url">My Link</a>
but now renders as:
    <a href=,0); req.write(str( my_link ),0); req.write(r>My Link</a>

Changing the double quote to a single quote fixes the problem.
    <a href='<%= my_link %>'>My Link</a>
renders as
    <a href='some_url'>My Link</a>

I don't want to refactor *all* of my psp pages, so I guess we'll need to fix psp_parser. ;)

Jim

Jim Gallacher wrote:
Ok, this is weird.

I tried Grisha's suggested fix, but instead of getting the expected '\n' character string in the test output I got '\\n'. So I reverted psp_parser.l and recompiled. Now, rather than the error Anton was seeing (ie newline character), the output is correct. Aaaaaaahhhhhh! I'm just guessing here, but it looks like at some point psp_parser.l changed, but the corresponding psp_parser.c file was either not re-generated or not committed.

Just to make sure I'm not loosing my mind, could someone grab a copy of 3.2.4b (or svn trunk), delete src/psp_parser.c, compile and run the simple test shown in http://issues.apache.org/jira/browse/MODPYTHON-87? You'll need flex version 2.5.31. Anton might be a good candidate for this since he is using debian unstable which has the correct flex.

I've created a unit test but I want to make sure I understand what's going on before I commit it.

Jim

Jim Gallacher wrote:

I'll give it a try, and create a unit test at the same time. Should the unit tests cover other possibilites such as \t, \r and so on?

Jim

Gregory (Grisha) Trubetskoy wrote:


I think the fix to that may be inserting


<TEXT>"\\n" {
    psp_string_appendl(&PSP_PG(pycode), STATIC_STR("\\\\n"));
}


into psp_parser.l - could someone try it?

The explanation is that it looks like compile() treats '\n' specially. BTW, there may be other sequnces that it treats specially, e.g. \t ?

s = 'print """TEST\n\\n\nTEST2\n\n"""\n'
c = compile(s, "blah", "exec")
c



<code object ? at 0xb7ce5a20, file "blah", line 1>

exec c



TEST


TEST2


s2 = 'print """TEST\n\\\\n\nTEST2\n\n"""\n'
c2 = compile(s2, "blah", "exec")
exec c2



TEST
\n
TEST2



Grisha


On Tue, 8 Nov 2005, Anton Kuzmin (JIRA) wrote:

LF character
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit

psp_parser: replaces "\n" on \n
LF character
---------------------------------------------

        Key: MODPYTHON-87
        URL: http://issues.apache.org/jira/browse/MODPYTHON-87
    Project: mod_python
       Type: Bug
   Versions: 3.2
Environment: Debian unstable, mod_python/3.2.0b Python/2.3.5
   Reporter: Anton Kuzmin


$ cat mptest.psp
<html>
<body>

You see (&#92;n) in the test result. If you see () then the test fails.<br />

BEGIN TEST<br />
(\n)
<br />END TEST

</body>
</html>

The result on the screen is:
You see (\n) in the test result. If you see () then the test fails.
BEGIN TEST
( )
END TEST

$ cat .htaccess
AddHandler mod_python .psp
PythonHandler mod_python.psp
PythonDebug On

--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
  http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
  http://www.atlassian.com/software/jira







Reply via email to