pythonizer
pythonizer copied to clipboard
unless expression loses the required parenthesis for proper code generation
The perl "unless" construct generated an "if not" in python, but it fails to keep the parenthesis so it's probably wrong code:
unless (($area_hidden) || ($area_rtr_hidden) ||
($intf_hidden) || ($link_hidden)) {
generates:
if not (area_hidden) or (area_rtr_hidden) or (link_hidden):
but the "not" only applies to the first part of the expression - it needs to be applied to the whole thing.
Fix in sub control of pythonizer:
gen_chunk($ValPy[$begin]); # gen initial keyword
if( $ValPerl[$begin] eq 'unless' ) { gen_chunk('('); } # issue 20
$k=expression($start,$limit,0); # last bracket was erased.
return -255 if ($k<0);
if( $ValPerl[$begin] eq 'unless' ) { gen_chunk(')'); } # issue 20
gen_chunk(':');
Fixed in https://github.com/snoopyjc/pythonizer