Issue #20444: Reduced code duplication. Thanks to dongwm for the report and patch.
Idle test: 2nd try at suppressing compile time warning (hint by Nick Coghlan).