remove 2.2 and 2.6 compat code (closes #22200)

Patch from Thomas Kluyver.
merge 3.4 (closes #22200)