Most of the time, you can just use "for x in foo: yield foo", so you really don't need a workaround. But when that's not appropriate (e.g., for performance reasons), you generally have to implement things pretty differently anyway. You're already writing the code twice; fooling yourself into thinking otherwise doesn't help.
More importantly, you don't have to duplicate the entire module. Factor out the part that's version dependent, and create two tiny modules for the two different implementations. It ends up being two more lines of code, one level less indented, and more readable. Where's the harm?