OS/2 EMX port changes (Python part of patch #450267):
  Python/
    dynload_shlib.c  // EMX port emulates dlopen() etc. for DL extensions
    import.c         // changes to support 8.3 DLL name limit (VACPP+EMX)
                     //  and case sensitive import semantics
    importdl.h
    thread_os2.h
diff --git a/Python/import.c b/Python/import.c
index e657b70..e106aad 100644
--- a/Python/import.c
+++ b/Python/import.c
@@ -900,6 +900,11 @@
 	static struct filedescr fd_builtin = {"", "", C_BUILTIN};
 	static struct filedescr fd_package = {"", "", PKG_DIRECTORY};
 	char name[MAXPATHLEN+1];
+#if defined(PYOS_OS2)
+	size_t saved_len;
+	size_t saved_namelen;
+	char *saved_buf = NULL;
+#endif
 
 	if (strlen(realname) > MAXPATHLEN) {
 		PyErr_SetString(PyExc_OverflowError,
@@ -1026,7 +1031,38 @@
 		fdp = PyMac_FindModuleExtension(buf, &len, name);
 		if (fdp) {
 #else
+#if defined(PYOS_OS2)
+		/* take a snapshot of the module spec for restoration
+		 * after the 8 character DLL hackery
+		 */
+		saved_buf = strdup(buf);
+		saved_len = len;
+		saved_namelen = namelen;
+#endif /* PYOS_OS2 */
 		for (fdp = _PyImport_Filetab; fdp->suffix != NULL; fdp++) {
+#if defined(PYOS_OS2)
+			/* OS/2 limits DLLs to 8 character names (w/o extension)
+			 * so if the name is longer than that and its a
+			 * dynamically loaded module we're going to try,
+			 * truncate the name before trying
+			 */
+			if (strlen(realname) > 8) {
+				/* is this an attempt to load a C extension? */
+				const struct filedescr *scan = _PyImport_DynLoadFiletab;
+				while (scan->suffix != NULL) {
+					if (strcmp(scan->suffix, fdp->suffix) == 0)
+						break;
+					else
+						scan++;
+				}
+				if (scan->suffix != NULL) {
+					/* yes, so truncate the name */
+					namelen = 8;
+					len -= strlen(realname) - namelen;
+					buf[len] = '\0';
+				}
+			}
+#endif /* PYOS_OS2 */
 			strcpy(buf+len, fdp->suffix);
 			if (Py_VerboseFlag > 1)
 				PySys_WriteStderr("# trying %s\n", buf);
@@ -1040,7 +1076,21 @@
 					fp = NULL;
 				}
 			}
+#if defined(PYOS_OS2)
+			/* restore the saved snapshot */
+			strcpy(buf, saved_buf);
+			len = saved_len;
+			namelen = saved_namelen;
+#endif
 		}
+#if defined(PYOS_OS2)
+		/* don't need/want the module name snapshot anymore */
+		if (saved_buf)
+		{
+			free(saved_buf);
+			saved_buf = NULL;
+		}
+#endif
 		if (fp != NULL)
 			break;
 	}
@@ -1099,6 +1149,12 @@
 #include <sys/types.h>
 #include <dirent.h>
 
+#elif defined(PYOS_OS2)
+#define INCL_DOS
+#define INCL_DOSERRORS
+#define INCL_NOPMAPI
+#include <os2.h>
+
 #elif defined(RISCOS)
 #include "oslib/osfscontrol.h"
 #endif
@@ -1255,6 +1311,26 @@
 
 	return 0;
 
+/* OS/2 */
+#elif defined(PYOS_OS2)
+	HDIR hdir = 1;
+	ULONG srchcnt = 1;
+	FILEFINDBUF3 ffbuf;
+	APIRET rc;
+
+	if (getenv("PYTHONCASEOK") != NULL)
+		return 1;
+
+	rc = DosFindFirst(buf,
+			  &hdir,
+			  FILE_READONLY | FILE_HIDDEN | FILE_SYSTEM | FILE_DIRECTORY,
+			  &ffbuf, sizeof(ffbuf),
+			  &srchcnt,
+			  FIL_STANDARD);
+	if (rc != NO_ERROR)
+		return 0;
+	return strncmp(ffbuf.achName, name, namelen) == 0;
+
 /* assuming it's a case-sensitive filesystem, so there's nothing to do! */
 #else
 	return 1;