use os.environ for setting and unsetting POSIXLY_CORRECT

os.putenv() and os.unsetenv() are not guaranteed to work, neither
does os.environ seem to be, but it appears to be safer.