--- Python-2.7.15/Modules/posixmodule.c.orig	2018-04-30 00:47:33.000000000 +0200
+++ Python-2.7.15/Modules/posixmodule.c	2018-12-26 13:46:37.307241303 +0100
@@ -35,6 +35,12 @@
 #    include <unixio.h>
 #endif /* defined(__VMS) */
 
+/* On android API level 21, 'AT_EACCESS' is not declared although
+ * HAVE_FACCESSAT is defined. */
+#ifdef __ANDROID__
+#undef HAVE_FACCESSAT
+#endif
+
 #ifdef __cplusplus
 extern "C" {
 #endif
@@ -3991,7 +3997,7 @@ posix_openpty(PyObject *self, PyObject *
     slave_fd = open(slave_name, O_RDWR | O_NOCTTY); /* open slave */
     if (slave_fd < 0)
         return posix_error();
-#if !defined(__CYGWIN__) && !defined(HAVE_DEV_PTC)
+#if !defined(__CYGWIN__) && !defined(__ANDROID__) && !defined(HAVE_DEV_PTC)
     ioctl(slave_fd, I_PUSH, "ptem"); /* push ptem */
     ioctl(slave_fd, I_PUSH, "ldterm"); /* push ldterm */
 #ifndef __hpux