[LinuxCNC/linuxcnc PR#221] stdglue.py: turn `change_epilog()` into generator function

未分类 bolang 4个月前 (10-15) 26次浏览

Issue #221 | 状态: 已关闭 | 作者: zultron | 创建时间: 2017-01-04


The functionality to return INTERPEXECUTEFINISH in a python
remap function has always existed, but was broken until PR #135.

The fix revealed a bug in the standard remap change_epilog()
function, which was not written as a python generator function.

Thanks to @dhwiezel for discovering and reporting this bug. Fixes
#217.

Signed-off-by: John Morris john@zultron.com


评论 (2)

#1 – jepler 于 2017-01-04

looks like the docs may benefit from an update in this area as well, they propose changeprologue / changeepilogue functions which are not generators.


#2 – zultron 于 2017-01-04

@jepler, when a python remap function returns an INTERPOK or INTERPERROR result, there’s no need to reenter the routine: it’s done. I haven’t tried to understand why the remap function doesn’t need to be a generator in these cases, although it does seem to work correctly.

Only when a remap function returns INTERPEXECUTEFINISH, the function must be a generator. The error @dhwiezel saw is the result of asking for the next result from a non-generator function (and that case could probably return a more useful error message if it can be detected).

I did grep around in the source and found no other python functions incorrectly using INTERPEXECUTEFINISH except in configs/sim/axis/orphans/pysubs/remap.py.

So, if one thinks all remap functions must be generators, there’s a lot of search and replace that needs doing in both the source and docs. Otherwise they should be ok, and the docs do discuss the yield INTERPEXECUTEFINISH issue.


原始Issue: https://github.com/LinuxCNC/linuxcnc/pull/221

喜欢 (0)