It's a chunk from D26390
tempdir method is used to be a default value for parent directory of the output directory. The implementation was following the Perl scan-build implementation. It tries to come up with a meaningful (most probably writable) place on the filesystem. The very same functionality is implemented in python tempfile module. It's tested better, it works on multiple platform and requires no additional code to use it.