Convert parent handle to an int before setting environment variable

Should fix Windows & Python 2 test failures
Merge pull request #7121 from takluyver/windows-int-parent-handle

Convert parent handle to an int before setting environment variable