1 diff -ru Python-2.6.7-orig/configure.in Python-2.6.7/configure.in
   2 --- Python-2.6.7-orig/configure.in      2010-05-25 02:27:03.000000000 +0000
   3 +++ Python-2.6.7/configure.in   2012-02-15 19:54:28.504282041 +0000
   4 @@ -17,8 +17,44 @@
   5  AH_TOP([
   6  #ifndef Py_PYCONFIG_H
   7  #define Py_PYCONFIG_H
   8 +
   9  ])
  10  AH_BOTTOM([
  11 +
  12 +#include <sys/isa_defs.h>
  13 +
  14 +/*
  15 + * Python originally defined these statically, which prevents a 32-64 python
  16 + * from working at all.
  17 + */
  18 +
  19 +#define SIZEOF_SHORT 2
  20 +#define SIZEOF_INT 4
  21 +#define SIZEOF_LONG_LONG 8
  22 +#define SIZEOF_FPOS_T 8
  23 +#define SIZEOF_OFF_T 8
  24 +#define SIZEOF_PTHREAD_T 4
  25 +
  26 +#ifdef _LP64
  27 +#define SIZEOF_LONG 8
  28 +#define SIZEOF_UINTPTR_T 8
  29 +#define SIZEOF_VOID_P 8
  30 +#define SIZEOF_TIME_T 8
  31 +#define SIZEOF_SIZE_T 8
  32 +#define SIZEOF_LONG_DOUBLE 16
  33 +#else
  34 +#define SIZEOF_LONG 4
  35 +#define SIZEOF_UINTPTR_T 4
  36 +#define SIZEOF_VOID_P 4
  37 +#define SIZEOF_TIME_T 4
  38 +#define SIZEOF_SIZE_T 4
  39 +#if defined(__i386)
  40 +#define SIZEOF_LONG_DOUBLE 12
  41 +#else
  42 +#define SIZEOF_LONG_DOUBLE 16
  43 +#endif
  44 +#endif
  45 +
  46  /* Define the macros needed if on a UnixWare 7.x system. */
  47  #if defined(__USLC__) && defined(__SCO_VERSION__)
  48  #define STRICT_SYSV_CURSES /* Don't use ncurses extensions */
  49 @@ -65,6 +101,26 @@
  50  
  51  define_xopen_source=yes
  52  
  53 +# AC_CHECK_SIZEOF without the AC_DEFINE_UNQUOTED
  54 +AC_DEFUN([PY_CHECK_SIZEOF],
  55 +[AS_LITERAL_IF([$1], [],
  56 +               [AC_FATAL([$0: requires literal arguments])])dnl
  57 +AC_CHECK_TYPE([$1], [], [], [$3])
  58 +AC_CACHE_CHECK([size of $1], AS_TR_SH([ac_cv_sizeof_$1]),
  59 +[if test "$AS_TR_SH([ac_cv_type_$1])" = yes; then
  60 +  # The cast to unsigned long works around a bug in the HP C Compiler
  61 +  # version HP92453-01 B.11.11.23709.GP, which incorrectly rejects
  62 +  # declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'.
  63 +  # This bug is HP SR number 8606223364.
  64 +  _AC_COMPUTE_INT([(long) (sizeof ($1))],
  65 +                  [AS_TR_SH([ac_cv_sizeof_$1])],
  66 +                  [AC_INCLUDES_DEFAULT([$3])],
  67 +                  [AC_MSG_FAILURE([cannot compute sizeof ($1), 77])])
  68 +else
  69 +  AS_TR_SH([ac_cv_sizeof_$1])=0
  70 +fi])dnl
  71 +])# PY_CHECK_SIZEOF
  72 +
  73  # Arguments passed to configure.
  74  AC_SUBST(CONFIG_ARGS)
  75  CONFIG_ARGS="$ac_configure_args"
  76 @@ -1436,14 +1492,10 @@
  77  
  78  # Sizes of various common basic types
  79  # ANSI C requires sizeof(char) == 1, so no need to check it
  80 -AC_CHECK_SIZEOF(int, 4)
  81 -AC_CHECK_SIZEOF(long, 4)
  82 -AC_CHECK_SIZEOF(void *, 4)
  83  AC_CHECK_SIZEOF(short, 2)
  84  AC_CHECK_SIZEOF(float, 4)
  85  AC_CHECK_SIZEOF(double, 8)
  86 -AC_CHECK_SIZEOF(fpos_t, 4)
  87 -AC_CHECK_SIZEOF(size_t, 4)
  88 +AC_CHECK_SIZEOF(short)
  89  AC_CHECK_SIZEOF(pid_t, 4)
  90  
  91  AC_MSG_CHECKING(for long long support)
  92 @@ -1453,9 +1505,6 @@
  93    have_long_long=yes
  94  ])
  95  AC_MSG_RESULT($have_long_long)
  96 -if test "$have_long_long" = yes ; then
  97 -AC_CHECK_SIZEOF(long long, 8)
  98 -fi
  99  
 100  AC_MSG_CHECKING(for long double support)
 101  have_long_double=no
 102 @@ -1463,10 +1512,6 @@
 103    AC_DEFINE(HAVE_LONG_DOUBLE, 1, [Define this if you have the type long double.])
 104    have_long_double=yes
 105  ])
 106 -AC_MSG_RESULT($have_long_double)
 107 -if test "$have_long_double" = yes ; then
 108 -AC_CHECK_SIZEOF(long double, 12)
 109 -fi
 110  
 111  AC_MSG_CHECKING(for _Bool support)
 112  have_c99_bool=no
 113 @@ -1480,106 +1525,25 @@
 114  fi
 115  
 116  AC_CHECK_TYPES(uintptr_t, 
 117 -   [AC_CHECK_SIZEOF(uintptr_t, 4)], 
 118 +   [],
 119     [], [#ifdef HAVE_STDINT_H
 120          #include <stdint.h>
 121          #endif])
 122  
 123 -
 124 -# Hmph. AC_CHECK_SIZEOF() doesn't include <sys/types.h>.
 125 -AC_MSG_CHECKING(size of off_t)
 126 -AC_CACHE_VAL(ac_cv_sizeof_off_t,
 127 -[AC_TRY_RUN([#include <stdio.h>
 128 +PY_CHECK_SIZEOF(off_t,4,[
 129 +#include <stdio.h>
 130 +#include <stdlib.h>
 131  #include <sys/types.h>
 132 -main()
 133 -{
 134 -  FILE *f=fopen("conftestval", "w");
 135 -  if (!f) exit(1);
 136 -  fprintf(f, "%d\n", sizeof(off_t));
 137 -  exit(0);
 138 -}],
 139 -ac_cv_sizeof_off_t=`cat conftestval`,
 140 -ac_cv_sizeof_off_t=0,
 141 -ac_cv_sizeof_off_t=4)
 142 -])
 143 -AC_MSG_RESULT($ac_cv_sizeof_off_t)
 144 -AC_DEFINE_UNQUOTED(SIZEOF_OFF_T, $ac_cv_sizeof_off_t,
 145 -[The number of bytes in an off_t.])
 146 -
 147 -AC_MSG_CHECKING(whether to enable large file support)
 148 -if test "$have_long_long" = yes
 149 -then
 150 -if test "$ac_cv_sizeof_off_t" -gt "$ac_cv_sizeof_long" -a \
 151 -       "$ac_cv_sizeof_long_long" -ge "$ac_cv_sizeof_off_t"; then
 152 -  AC_DEFINE(HAVE_LARGEFILE_SUPPORT, 1, 
 153 -  [Defined to enable large file support when an off_t is bigger than a long
 154 -   and long long is available and at least as big as an off_t. You may need
 155 -   to add some flags for configuration and compilation to enable this mode.
 156 -   (For Solaris and Linux, the necessary defines are already defined.)])
 157 -  AC_MSG_RESULT(yes)
 158 -else
 159 -  AC_MSG_RESULT(no)
 160 -fi
 161 -else
 162 -  AC_MSG_RESULT(no)
 163 -fi
 164 -
 165 -# AC_CHECK_SIZEOF() doesn't include <time.h>.
 166 -AC_MSG_CHECKING(size of time_t)
 167 -AC_CACHE_VAL(ac_cv_sizeof_time_t,
 168 -[AC_TRY_RUN([#include <stdio.h>
 169 -#include <time.h>
 170 -main()
 171 -{
 172 -  FILE *f=fopen("conftestval", "w");
 173 -  if (!f) exit(1);
 174 -  fprintf(f, "%d\n", sizeof(time_t));
 175 -  exit(0);
 176 -}],
 177 -ac_cv_sizeof_time_t=`cat conftestval`,
 178 -ac_cv_sizeof_time_t=0,
 179 -ac_cv_sizeof_time_t=4)
 180  ])
 181 -AC_MSG_RESULT($ac_cv_sizeof_time_t)
 182 -AC_DEFINE_UNQUOTED(SIZEOF_TIME_T, $ac_cv_sizeof_time_t, 
 183 -[The number of bytes in a time_t.])
 184  
 185 +AC_MSG_CHECKING(whether to enable large file support)
 186  
 187 -# if have pthread_t then define SIZEOF_PTHREAD_T
 188 -ac_save_cc="$CC"
 189 -if test "$ac_cv_kpthread" = "yes"
 190 -then CC="$CC -Kpthread"
 191 -elif test "$ac_cv_kthread" = "yes"
 192 -then CC="$CC -Kthread"
 193 -elif test "$ac_cv_pthread" = "yes"
 194 -then CC="$CC -pthread"
 195 -fi
 196 -AC_MSG_CHECKING(for pthread_t)
 197 -have_pthread_t=no
 198 -AC_TRY_COMPILE([#include <pthread.h>], [pthread_t x; x = *(pthread_t*)0;], have_pthread_t=yes)
 199 -AC_MSG_RESULT($have_pthread_t)
 200 -if test "$have_pthread_t" = yes ; then
 201 -  # AC_CHECK_SIZEOF() doesn't include <pthread.h>.
 202 -  AC_MSG_CHECKING(size of pthread_t)
 203 -  AC_CACHE_VAL(ac_cv_sizeof_pthread_t,
 204 -  [AC_TRY_RUN([#include <stdio.h>
 205 -#include <pthread.h>
 206 -  main()
 207 -  {
 208 -    FILE *f=fopen("conftestval", "w");
 209 -    if (!f) exit(1);
 210 -    fprintf(f, "%d\n", sizeof(pthread_t));
 211 -    exit(0);
 212 -  }],
 213 -  ac_cv_sizeof_pthread_t=`cat conftestval`,
 214 -  ac_cv_sizeof_pthread_t=0,
 215 -  ac_cv_sizeof_pthread_t=4)
 216 -  ])
 217 -  AC_MSG_RESULT($ac_cv_sizeof_pthread_t)
 218 -  AC_DEFINE_UNQUOTED(SIZEOF_PTHREAD_T, $ac_cv_sizeof_pthread_t,
 219 -   [The number of bytes in a pthread_t.])
 220 -fi
 221 -CC="$ac_save_cc"
 222 +AC_DEFINE(HAVE_LARGEFILE_SUPPORT, 1,
 223 +[Defined to enable large file support when an off_t is bigger than a long
 224 + and long long is available and at least as big as an off_t. You may need
 225 + to add some flags for configuration and compilation to enable this mode.
 226 + (For Solaris and Linux, the necessary defines are already defined.)])
 227 +AC_MSG_RESULT(yes)
 228  
 229  AC_MSG_CHECKING(for --enable-toolbox-glue)
 230  AC_ARG_ENABLE(toolbox-glue,
 231 @@ -1873,12 +1837,6 @@
 232  if test -z "$CCSHARED"
 233  then
 234         case $ac_sys_system/$ac_sys_release in
 235 -       SunOS*) if test "$GCC" = yes;
 236 -               then CCSHARED="-fPIC";
 237 -               elif test `uname -p` = sparc;
 238 -               then CCSHARED="-xcode=pic32";
 239 -               else CCSHARED="-Kpic";
 240 -               fi;;
 241         hp*|HP*) if test "$GCC" = yes;
 242                  then CCSHARED="-fPIC";
 243                  else CCSHARED="+z";
 244 @@ -3383,12 +3341,6 @@
 245  wchar_h="no"
 246  )
 247  
 248 -# determine wchar_t size
 249 -if test "$wchar_h" = yes
 250 -then
 251 -  AC_CHECK_SIZEOF(wchar_t, 4, [#include <wchar.h>])
 252 -fi
 253 -
 254  AC_MSG_CHECKING(for UCS-4 tcl)
 255  have_ucs4_tcl=no
 256  AC_TRY_COMPILE([
 257 @@ -3419,6 +3371,11 @@
 258    ac_cv_wchar_t_signed=no,
 259    ac_cv_wchar_t_signed=yes)])
 260    AC_MSG_RESULT($ac_cv_wchar_t_signed)
 261 + 
 262 +  PY_CHECK_SIZEOF(wchar_t, 4, [
 263 +  #include <wchar.h>
 264 +  #include <stdlib.h
 265 +  ])
 266  fi
 267    
 268  AC_MSG_CHECKING(what type to use for unicode)
 269 diff -ru Python-2.6.7-orig/Lib/distutils/command/build_ext.py Python-2.6.7/Lib/distutils/command/build_ext.py
 270 --- Python-2.6.7-orig/Lib/distutils/command/build_ext.py        2010-08-02 20:26:41.000000000 +0000
 271 +++ Python-2.6.7/Lib/distutils/command/build_ext.py     2012-02-15 19:44:22.648098190 +0000
 272 @@ -636,6 +636,8 @@
 273          modpath = fullname.split('.')
 274          filename = self.get_ext_filename(ext_name)
 275          filename = os.path.split(filename)[-1]
 276 +        if sys.maxint != 2147483647L:
 277 +            filename = os.path.join("64", filename)
 278  
 279          if not self.inplace:
 280              # no further work needed
 281 @@ -677,7 +679,13 @@
 282          so_ext = get_config_var('SO')
 283          if os.name == 'nt' and self.debug:
 284              return os.path.join(*ext_path) + '_d' + so_ext
 285 -        return os.path.join(*ext_path) + so_ext
 286 +        # .so extensions are word-size specific
 287 +        path = apply(os.path.join, ext_path)
 288 +        if sys.maxint == 2147483647L:
 289 +            return path + so_ext
 290 +        dirname = os.path.dirname(path);
 291 +        basename = os.path.basename(path);
 292 +        return os.path.join(dirname, "64", basename + so_ext)
 293  
 294      def get_export_symbols (self, ext):
 295          """Return the list of symbols that a shared extension has to
 296 diff -ru Python-2.6.7-orig/Makefile.pre.in Python-2.6.7/Makefile.pre.in
 297 --- Python-2.6.7-orig/Makefile.pre.in   2010-08-01 22:05:31.000000000 +0000
 298 +++ Python-2.6.7/Makefile.pre.in        2012-02-15 19:50:05.628985496 +0000
 299 @@ -94,11 +94,11 @@
 300  SCRIPTDIR=     $(prefix)/lib
 301  
 302  # Detailed destination directories
 303 -BINLIBDEST=    $(LIBDIR)/python$(VERSION)
 304 +BINLIBDEST=    $(LIBDIR)/python$(VERSION)
 305  LIBDEST=       $(SCRIPTDIR)/python$(VERSION)
 306  INCLUDEPY=     $(INCLUDEDIR)/python$(VERSION)
 307  CONFINCLUDEPY= $(CONFINCLUDEDIR)/python$(VERSION)
 308 -LIBP=          $(LIBDIR)/python$(VERSION)
 309 +LIBP=          $(exec_prefix)/lib/python$(VERSION)
 310  
 311  # Symbols used for using shared libraries
 312  SO=            @SO@
 313 diff -ru Python-2.6.7-orig/Python/import.c Python-2.6.7/Python/import.c
 314 --- Python-2.6.7-orig/Python/import.c   2010-05-20 18:41:08.000000000 +0000
 315 +++ Python-2.6.7/Python/import.c        2012-02-15 19:47:30.346908983 +0000
 316 @@ -1193,6 +1193,57 @@
 317  static int find_init_module(char *); /* Forward */
 318  static struct filedescr importhookdescr = {"", "", IMP_HOOK};
 319  
 320 +#ifdef HAVE_STAT
 321 +static char *
 322 +insert_64dir(char *buf, size_t buflen)
 323 +{
 324 +       char *base;
 325 +       char *cp;
 326 +       size_t blen;
 327 +
 328 +       if ((blen = strlen(buf)) == 0)
 329 +               return (NULL);
 330 +
 331 +       cp = &buf[blen - 1];
 332 +       while (cp != buf && *cp != SEP)
 333 +               cp--;
 334 +
 335 +       if (cp != buf)
 336 +               cp++;
 337 +
 338 +       if (blen + strlen("64/") + 1 >= buflen)
 339 +               return NULL;
 340 +
 341 +       base = strdup(cp);
 342 +       sprintf(cp, "64%c%s", SEP, base);
 343 +       free(base);
 344 +
 345 +       return buf;
 346 +}
 347 +
 348 +/*
 349 + * If we're on a 64-bit platform, modify lookups for shared object files.
 350 + */
 351 +static size_t modify_path(struct filedescr *fdp, char *buf, size_t buflen)
 352 +{
 353 +       struct stat statbuf;
 354 +
 355 +       if (sizeof(void *) != 8)
 356 +               return 0;
 357 +
 358 +       if (stat(buf, &statbuf) == 0 && S_ISDIR(statbuf.st_mode))
 359 +               return 0;
 360 +
 361 +       if (fdp->type != C_EXTENSION)
 362 +               return 0;
 363 +
 364 +       if (insert_64dir(buf, buflen) == NULL)
 365 +               return 0;
 366 +
 367 +       return strlen("64/");
 368 +}
 369 +#endif
 370 +
 371  static struct filedescr *
 372  find_module(char *fullname, char *subname, PyObject *path, char *buf,
 373              size_t buflen, FILE **p_fp, PyObject **p_loader)
 374 @@ -1210,11 +1261,10 @@
 375      static struct filedescr fd_builtin = {"", "", C_BUILTIN};
 376      static struct filedescr fd_package = {"", "", PKG_DIRECTORY};
 377      char name[MAXPATHLEN+1];
 378 -#if defined(PYOS_OS2)
 379      size_t saved_len;
 380      size_t saved_namelen;
 381      char *saved_buf = NULL;
 382 -#endif
 383 +
 384      if (p_loader != NULL)
 385          *p_loader = NULL;
 386  
 387 @@ -1433,15 +1483,18 @@
 388          }
 389  #endif
 390  #endif
 391 -#if defined(PYOS_OS2)
 392 +
 393          /* take a snapshot of the module spec for restoration
 394           * after the 8 character DLL hackery
 395           */
 396          saved_buf = strdup(buf);
 397          saved_len = len;
 398          saved_namelen = namelen;
 399 -#endif /* PYOS_OS2 */
 400 +
 401          for (fdp = _PyImport_Filetab; fdp->suffix != NULL; fdp++) {
 402 +#ifdef HAVE_STAT
 403 +            len += modify_path(fdp, buf, buflen);
 404 +#endif
 405  #if defined(PYOS_OS2) && defined(HAVE_DYNAMIC_LOADING)
 406              /* OS/2 limits DLLs to 8 character names (w/o
 407                 extension)
 408 @@ -1482,21 +1535,18 @@
 409                      fp = NULL;
 410                  }
 411              }
 412 -#if defined(PYOS_OS2)
 413 +
 414              /* restore the saved snapshot */
 415              strcpy(buf, saved_buf);
 416              len = saved_len;
 417              namelen = saved_namelen;
 418 -#endif
 419          }
 420 -#if defined(PYOS_OS2)
 421          /* don't need/want the module name snapshot anymore */
 422          if (saved_buf)
 423          {
 424              free(saved_buf);
 425              saved_buf = NULL;
 426          }
 427 -#endif
 428          Py_XDECREF(copy);
 429          if (fp != NULL)
 430              break;
 431 diff -ru Python-2.6.7-orig/Python/importdl.h Python-2.6.7/Python/importdl.h
 432 --- Python-2.6.7-orig/Python/importdl.h 2010-05-09 15:15:40.000000000 +0000
 433 +++ Python-2.6.7/Python/importdl.h      2012-02-15 19:42:25.199289001 +0000
 434 @@ -31,8 +31,9 @@
 435  extern PyObject *_PyImport_LoadDynamicModule(char *name, char *pathname,
 436                                               FILE *);
 437  
 438 -/* Max length of module suffix searched for -- accommodates "module.slb" */
 439 -#define MAXSUFFIXSIZE 12
 440 +/* Max length of module suffix searched for -- accommodates "module.slb"
 441 +   and "64/" */
 442 +#define MAXSUFFIXSIZE 15
 443  
 444  #ifdef MS_WINDOWS
 445  #include <windows.h>
 446 Only in Python-2.6.7/Python: importdl.h.orig