Include <unistd.h> in Python.h. Fixes #500924.
diff --git a/Include/Python.h b/Include/Python.h
index 0f07e36..9724fb7 100644
--- a/Include/Python.h
+++ b/Include/Python.h
@@ -49,6 +49,9 @@
 #ifdef HAVE_STDLIB_H
 #include <stdlib.h>
 #endif
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
 
 /* CAUTION:  Build setups should ensure that NDEBUG is defined on the
  * compiler command line when building Python in release mode; else
diff --git a/Modules/_hotshot.c b/Modules/_hotshot.c
index 03eafb1..ebaf37c 100644
--- a/Modules/_hotshot.c
+++ b/Modules/_hotshot.c
@@ -8,10 +8,6 @@
 #include "frameobject.h"
 #include "structmember.h"
 
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-
 /*
  * Which timer to use should be made more configurable, but that should not
  * be difficult.  This will do for now.
diff --git a/Modules/bsddbmodule.c b/Modules/bsddbmodule.c
index 05d2bf1..d51f3b4 100644
--- a/Modules/bsddbmodule.c
+++ b/Modules/bsddbmodule.c
@@ -18,10 +18,6 @@
 #include "pythread.h"
 #endif
 
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <fcntl.h>
diff --git a/Modules/fcntlmodule.c b/Modules/fcntlmodule.c
index 65c9d2b..9f84a2c 100644
--- a/Modules/fcntlmodule.c
+++ b/Modules/fcntlmodule.c
@@ -3,10 +3,6 @@
 
 #include "Python.h"
 
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-
 #ifdef HAVE_SYS_FILE_H
 #include <sys/file.h>
 #endif
diff --git a/Modules/getpath.c b/Modules/getpath.c
index 2c0b6f2..3ecdb9d 100644
--- a/Modules/getpath.c
+++ b/Modules/getpath.c
@@ -6,10 +6,6 @@
 #include <sys/types.h>
 #include <string.h>
 
-#if HAVE_UNISTD_H
-#include <unistd.h>
-#endif /* HAVE_UNISTD_H */
-
 #ifdef WITH_NEXT_FRAMEWORK
 #include <mach-o/dyld.h>
 #endif
diff --git a/Modules/linuxaudiodev.c b/Modules/linuxaudiodev.c
index dd462ef..fa2e441 100644
--- a/Modules/linuxaudiodev.c
+++ b/Modules/linuxaudiodev.c
@@ -16,10 +16,6 @@
 #include "Python.h"
 #include "structmember.h"
 
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-
 #ifdef HAVE_FCNTL_H
 #include <fcntl.h>
 #else
diff --git a/Modules/main.c b/Modules/main.c
index 5f71ee2..41c229f 100644
--- a/Modules/main.c
+++ b/Modules/main.c
@@ -4,10 +4,6 @@
 #include "osdefs.h"
 #include "compile.h" /* For CO_FUTURE_DIVISION */
 
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-
 #ifdef MS_WINDOWS
 #include <fcntl.h>
 #endif
diff --git a/Modules/mmapmodule.c b/Modules/mmapmodule.c
index 933e972..6e03b4b 100644
--- a/Modules/mmapmodule.c
+++ b/Modules/mmapmodule.c
@@ -36,7 +36,6 @@
 #endif
 
 #ifdef UNIX
-#include <unistd.h>
 #include <sys/mman.h>
 #include <sys/stat.h>
 
diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c
index 1290977..31b0dde 100644
--- a/Modules/posixmodule.c
+++ b/Modules/posixmodule.c
@@ -46,11 +46,6 @@
 #include <grp.h>
 #endif
 
-/* pick up declaration of confstr on some systems? */
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif /* HAVE_UNISTD_H */
-
 /* Various compilers have only certain posix functions */
 /* XXX Gosh I wish these were all moved into pyconfig.h */
 #if defined(PYCC_VACPP) && defined(PYOS_OS2)
@@ -112,10 +107,6 @@
 
 #ifndef _MSC_VER
 
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-
 #if defined(sun) && !defined(__SVR4)
 /* SunOS 4.1.4 doesn't have prototypes for these: */
 extern int rename(const char *, const char *);
diff --git a/Modules/readline.c b/Modules/readline.c
index fe653b8..fa4fc06 100644
--- a/Modules/readline.c
+++ b/Modules/readline.c
@@ -12,10 +12,6 @@
 #include <signal.h>
 #include <errno.h>
 
-#ifdef HAVE_UNISTD_H
-#include <unistd.h> /* For isatty() */
-#endif
-
 /* GNU readline definitions */
 #undef HAVE_CONFIG_H /* Else readline/chardefs.h includes strings.h */
 #include <readline/readline.h>
diff --git a/Modules/resource.c b/Modules/resource.c
index 43ed1de..45474be 100644
--- a/Modules/resource.c
+++ b/Modules/resource.c
@@ -2,7 +2,6 @@
 #include "Python.h"
 #include <sys/resource.h>
 #include <sys/time.h>
-#include <unistd.h>
 #include <string.h>
 #include <errno.h>
 
diff --git a/Modules/rgbimgmodule.c b/Modules/rgbimgmodule.c
index c8c42c2..304dbd6 100644
--- a/Modules/rgbimgmodule.c
+++ b/Modules/rgbimgmodule.c
@@ -28,9 +28,6 @@
 #endif
 #endif
 
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
 #include <string.h>
 
 /*
diff --git a/Modules/selectmodule.c b/Modules/selectmodule.c
index e5aa6eb..ceaf3fa 100644
--- a/Modules/selectmodule.c
+++ b/Modules/selectmodule.c
@@ -18,9 +18,6 @@
 #define FD_SETSIZE 512
 #endif 
 
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
 #if defined(HAVE_POLL_H)
 #include <poll.h>
 #elif defined(HAVE_SYS_POLL_H)
diff --git a/Modules/sgimodule.c b/Modules/sgimodule.c
index b19efe6..7ec43d3 100644
--- a/Modules/sgimodule.c
+++ b/Modules/sgimodule.c
@@ -5,7 +5,6 @@
 
 #include <sys/types.h>
 #include <sys/stat.h>
-#include <unistd.h>
 #include <fcntl.h>
 
 static PyObject *
diff --git a/Modules/signalmodule.c b/Modules/signalmodule.c
index 850221e..1053cf1 100644
--- a/Modules/signalmodule.c
+++ b/Modules/signalmodule.c
@@ -10,10 +10,6 @@
 #include <process.h>
 #endif
 
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-
 #include <signal.h>
 
 #ifndef SIG_ERR
diff --git a/Modules/socketmodule.c b/Modules/socketmodule.c
index 124353e..25912a4 100644
--- a/Modules/socketmodule.c
+++ b/Modules/socketmodule.c
@@ -115,10 +115,6 @@
 #include "pythread.h"
 #endif
 
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-
 #if defined(PYCC_VACPP)
 #include <types.h>
 #include <io.h>
diff --git a/Modules/sunaudiodev.c b/Modules/sunaudiodev.c
index e9ffd1f..78be842 100644
--- a/Modules/sunaudiodev.c
+++ b/Modules/sunaudiodev.c
@@ -8,10 +8,6 @@
 #define SOLARIS
 #endif
 
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-
 #ifdef HAVE_FCNTL_H
 #include <fcntl.h>
 #endif
diff --git a/Modules/termios.c b/Modules/termios.c
index c77dff3..3362e81 100644
--- a/Modules/termios.c
+++ b/Modules/termios.c
@@ -12,10 +12,6 @@
 #endif
 #include <sys/ioctl.h>
 
-#ifdef __BEOS__
-#include <unistd.h>
-#endif
-
 /* HP-UX requires that this be included to pick up MDCD, MCTS, MDSR,
  * MDTR, MRI, and MRTS (appearantly used internally by some things
  * defined as macros; these are not used here directly).
diff --git a/Modules/timemodule.c b/Modules/timemodule.c
index bcc53e0..a5d81fe 100644
--- a/Modules/timemodule.c
+++ b/Modules/timemodule.c
@@ -24,10 +24,6 @@
 #include <io.h>
 #endif
 
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-
 #ifdef HAVE_FTIME
 #include <sys/timeb.h>
 #if !defined(MS_WINDOWS) && !defined(PYOS_OS2)
diff --git a/Objects/fileobject.c b/Objects/fileobject.c
index 9af5ca9..125da70 100644
--- a/Objects/fileobject.c
+++ b/Objects/fileobject.c
@@ -8,10 +8,6 @@
 #include <sys/types.h>
 #endif /* DONT_HAVE_SYS_TYPES_H */
 
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-
 #ifdef MS_WIN32
 #define fileno _fileno
 /* can (almost fully) duplicate with _chsize, see file_truncate */
diff --git a/PC/getpathp.c b/PC/getpathp.c
index f736899..6695a70 100644
--- a/PC/getpathp.c
+++ b/PC/getpathp.c
@@ -66,10 +66,6 @@
 #include <sys/stat.h>
 #include <string.h>
 
-#if HAVE_UNISTD_H
-#include <unistd.h>
-#endif /* HAVE_UNISTD_H */
-
 /* Search in some common locations for the associated Python libraries.
  *
  * Py_GetPath() tries to return a sensible Python module search path.
diff --git a/Parser/intrcheck.c b/Parser/intrcheck.c
index 686e030..e2ca5b4 100644
--- a/Parser/intrcheck.c
+++ b/Parser/intrcheck.c
@@ -107,9 +107,6 @@
 #include <stdio.h>
 #include <string.h>
 #include <signal.h>
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
 
 static int interrupted;
 
diff --git a/Python/bltinmodule.c b/Python/bltinmodule.c
index f5ce749..c997ecf 100644
--- a/Python/bltinmodule.c
+++ b/Python/bltinmodule.c
@@ -9,10 +9,6 @@
 
 #include <ctype.h>
 
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-
 #ifdef RISCOS
 #include "unixstuff.h"
 #endif
diff --git a/Python/dynload_beos.c b/Python/dynload_beos.c
index 5de96c9..eec8592 100644
--- a/Python/dynload_beos.c
+++ b/Python/dynload_beos.c
@@ -4,7 +4,6 @@
 #include <kernel/image.h>
 #include <kernel/OS.h>
 #include <stdlib.h>
-#include <unistd.h>
 
 #include "Python.h"
 #include "importdl.h"
diff --git a/Python/frozenmain.c b/Python/frozenmain.c
index efc87d7..21724ef 100644
--- a/Python/frozenmain.c
+++ b/Python/frozenmain.c
@@ -9,15 +9,6 @@
 extern int PyInitFrozenExtensions(void);
 #endif
 
-#ifdef HAVE_UNISTD_H
-#include <unistd.h> /* For isatty() */
-#endif
-
-/* For isatty()'s proto. - [cjh] */
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-
 /* Main program */
 
 int
diff --git a/Python/import.c b/Python/import.c
index 0b4cd0f..ba7d5d5 100644
--- a/Python/import.c
+++ b/Python/import.c
@@ -15,10 +15,6 @@
 #include "macglue.h"
 #endif
 
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-
 #ifdef HAVE_FCNTL_H
 #include <fcntl.h>
 #endif
diff --git a/Python/pythonrun.c b/Python/pythonrun.c
index 4294c97..6b70739 100644
--- a/Python/pythonrun.c
+++ b/Python/pythonrun.c
@@ -13,10 +13,6 @@
 #include "eval.h"
 #include "marshal.h"
 
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-
 #ifdef HAVE_SIGNAL_H
 #include <signal.h>
 #endif
diff --git a/Python/sysmodule.c b/Python/sysmodule.c
index ff49adc..cdc728c 100644
--- a/Python/sysmodule.c
+++ b/Python/sysmodule.c
@@ -20,10 +20,6 @@
 
 #include "osdefs.h"
 
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-
 #ifdef MS_COREDLL
 extern void *PyWin_DLLhModule;
 /* A string loaded from the DLL at startup: */
diff --git a/Python/thread.c b/Python/thread.c
index df42f31..f9a4de9 100644
--- a/Python/thread.c
+++ b/Python/thread.c
@@ -5,7 +5,7 @@
    which is included by this file dependent on config settings.
    Stuff shared by all thread_*.h files is collected here. */
 
-#include "pyconfig.h"
+#include "Python.h"
 
 /* pyconfig.h may or may not define DL_IMPORT */
 #ifndef DL_IMPORT	/* declarations for DLL import/export */
@@ -24,10 +24,6 @@
 #endif
 #endif
 
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-
 #ifdef __DGUX
 #define _USING_POSIX4A_DRAFT6
 #endif
diff --git a/Python/thread_solaris.h b/Python/thread_solaris.h
index 4c958b9..8e24126 100644
--- a/Python/thread_solaris.h
+++ b/Python/thread_solaris.h
@@ -1,7 +1,6 @@
 
 #include <stdlib.h>
 #include <stdio.h>
-#include <unistd.h>
 #include <errno.h>
 #include </usr/include/thread.h>
 #undef _POSIX_THREADS