backport to 2.7, not working yet