[Zope-Perl] Re: Weird output in pyperl

Felix Schwarz Felix.Schwarz at web.de
Mon Jul 11 15:16:54 EDT 2005


Hi Jeff,

Jeff Bachtel wrote:
> On Mon, Jul 11, 2005 at 07:24:29PM +0100, Felix Schwarz wrote:
>>
>> Where would you start looking given my bug description?

> I'd check for some error being returned by popen. I'd have callee
> touch a file (inside Perl) to make sure evaluation was happening
> properly. Given all of that, I'd start looking to see what file
> descriptors were being given to child processes and piped, to see if
> that was getting mangled.

Thanks for your comments. After some tests I found out, that...
* perl.eval is being executed. "system('touch pyperl.felix.log');"
  creates a new file as expected.
* My problem has something to do with buffering. After eval'ing this
  code
    print 'Perl\n';
    system('touch pyperl.felix.log');
  the "Perl" string appeared in caller.py. I figured out that "$| = 1;"
  before the Perl print has the same effect.

Therefore I think that pyperl should force the Perl interpreter to
flush all buffers before returning to Python. And there is another
bug: The order of the items is reversed.

I expected
  Python
  Perl
  eval exit code: ...
The first and the last one are printed by Python code the last one by
Perl code. But the output is:
  Perl
  Python
  eval exit code: ...

That means that all Python buffers should be flushed before entering
the Perl eval, right?

Does anybody have any experience with Un*x popen and buffering? If I
run callee.py separately the order of the items is okay. Only
executing it with popen reveals the bug.
    
-- 
Felix



More information about the Zope-perl mailing list