remove 2.2 and 2.6 compat code (closes #22200)

Patch from Thomas Kluyver.