Changeset 10 for python


Ignore:
Timestamp:
Sep 3, 2010, 5:33:06 PM (15 years ago)
Author:
Yuri Dario
Message:

python: merged offline changes.

Location:
python/trunk
Files:
1 added
38 edited

Legend:

Unmodified
Added
Removed
  • python/trunk/Include/osdefs.h

    r2 r10  
    2020#define MAXPATHLEN 256
    2121#endif
     22#define DRVSEP ':' /* (bird) */
    2223#define DELIM ';'
    2324#endif
     
    3435#ifndef SEP
    3536#define SEP '/'
     37#endif
     38
     39/* Test if `ch' is a filename separator (bird) */
     40#ifdef ALTSEP
     41#define IS_SEP(ch) ((ch) == SEP || (ch) == ALTSEP)
     42#else
     43#define IS_SEP(ch) ((ch) == SEP)
     44#endif
     45
     46/* Test if `path' has a drive letter or not. (bird) */
     47#ifdef DRVSEP
     48#define HAS_DRV(path) (*(path) && (path)[1] == DRVSEP)
     49#else
     50#define HAS_DRV(path) 0
     51#endif
     52
     53/* Test if `path' is absolute or not. (bird) */
     54#ifdef DRVSEP
     55#define IS_ABSPATH(path) (IS_SEP((path)[0]) || HAS_DRV(path))
     56#else
     57#define IS_ABSPATH(path) (IS_SEP((path)[0]))
     58#endif
     59
     60/* Test if `path' contains any of the path separators including drive letter. (bird) */
     61#ifdef ALTSEP
     62#define HAS_ANYSEP(path) ( strchr((path), SEP) || strchr((path), ALTSEP) || HAS_DRV(path) )
     63#else
     64#define HAS_ANYSEP(path) ( strchr((path), SEP) || HAS_DRV(path) )
    3665#endif
    3766
  • python/trunk/Include/pyport.h

    r2 r10  
    550550
    551551  BeOS and cygwin are the only other autoconf platform requiring special
    552   linkage handling and both of these use __declspec().
     552  linkage handling and both of these use __declspec(). Ditto for OS/2.
    553553*/
    554 #if defined(__CYGWIN__) || defined(__BEOS__)
     554#if defined(__CYGWIN__) || defined(__BEOS__) || defined(__OS2__)
    555555#       define HAVE_DECLSPEC_DLL
    556556#endif
     
    564564                        /* module init functions inside the core need no external linkage */
    565565                        /* except for Cygwin to handle embedding (FIXME: BeOS too?) */
    566 #                       if defined(__CYGWIN__)
     566#                       if defined(__CYGWIN__) || defined(__OS2__)
    567567#                               define PyMODINIT_FUNC __declspec(dllexport) void
    568568#                       else /* __CYGWIN__ */
     
    574574                        /* Under Cygwin, auto-import functions to prevent compilation */
    575575                        /* failures similar to http://python.org/doc/FAQ.html#3.24 */
    576 #                       if !defined(__CYGWIN__)
     576#                       if !defined(__CYGWIN__) && !defined(__OS2__)
    577577#                               define PyAPI_FUNC(RTYPE) __declspec(dllimport) RTYPE
    578578#                       endif /* !__CYGWIN__ */
     579#                       if !defined(__OS2__)
    579580#                       define PyAPI_DATA(RTYPE) extern __declspec(dllimport) RTYPE
     581#                       endif /* !__OS2__ */
    580582                        /* module init functions outside the core must be exported */
    581583#                       if defined(__cplusplus)
  • python/trunk/Lib/bsddb/dbshelve.py

    r2 r10  
    1 #!/bin/env python
     1#!/usr/bin/env python
    22#------------------------------------------------------------------------
    33#           Copyright (c) 1997-2001 by Total Control Software
  • python/trunk/Lib/cgi.py

    r2 r10  
    1 #! /usr/local/bin/python
     1#!/usr/bin/python
    22
    33# NOTE: the above "/usr/local/bin/python" is NOT a mistake.  It is
  • python/trunk/Lib/distutils/ccompiler.py

    r2 r10  
    983983    # compiler
    984984    ('cygwin.*', 'unix'),
     985    ('os2knix', 'emx'),
    985986    ('os2emx', 'emx'),
    986987
  • python/trunk/Lib/distutils/command/bdist_rpm.py

    r2 r10  
    200200                  "--python and --fix-python are mutually exclusive options"
    201201
    202         if os.name != 'posix':
     202        if os.name != 'posix' and os.name != 'os2':
    203203            raise DistutilsPlatformError, \
    204204                  ("don't know how to create RPM "
     
    323323        rpm_cmd = ['rpm']
    324324        if os.path.exists('/usr/bin/rpmbuild') or \
     325           os.path.exists('/usr/bin/rpmbuild.exe') or \
    325326           os.path.exists('/bin/rpmbuild'):
    326327            rpm_cmd = ['rpmbuild']
     
    346347        q_cmd = r"rpm -q --qf '%s %s\n' --specfile '%s'" % (
    347348            src_rpm, non_src_rpm, spec_path)
     349        if os.name == 'os2':
     350            q_cmd = q_cmd.replace( '%{', '%%{')
    348351
    349352        out = os.popen(q_cmd)
  • python/trunk/Lib/distutils/command/install.py

    r2 r10  
    284284
    285285        # Next, stuff that's wrong (or dubious) only on certain platforms.
    286         if os.name != "posix":
     286        if os.name != "posix" and os.name != "os2":
    287287            if self.exec_prefix:
    288288                self.warn("exec-prefix option ignored on this platform")
     
    299299        self.dump_dirs("pre-finalize_{unix,other}")
    300300
    301         if os.name == 'posix':
     301        if os.name == 'posix' or os.name == "os2":
    302302            self.finalize_unix()
    303303        else:
  • python/trunk/Lib/distutils/emxccompiler.py

    r2 r10  
    6464        # Hard-code GCC because that's what this is all about.
    6565        # XXX optimization, warnings etc. should be customizable.
    66         self.set_executables(compiler='gcc -Zomf -Zmt -O3 -fomit-frame-pointer -mprobe -Wall',
    67                              compiler_so='gcc -Zomf -Zmt -O3 -fomit-frame-pointer -mprobe -Wall',
    68                              linker_exe='gcc -Zomf -Zmt -Zcrtdll',
    69                              linker_so='gcc -Zomf -Zmt -Zcrtdll -Zdll')
     66        self.set_executables(compiler='gcc -g -O2 -march=i386 -mtune=i686 -fomit-frame-pointer -Wall',
     67                             compiler_so='gcc -g -O2 -march=i386 -mtune=i686 -fomit-frame-pointer -Wall',
     68                             linker_exe='gcc -Zomf -Zexe',
     69                             linker_so='gcc -Zomf -Zdll')
    7070
    7171        # want the gcc library statically linked (so that we don't have
     
    139139                "EXPORTS"]
    140140            for sym in export_symbols:
    141                 contents.append('  "%s"' % sym)
     141                contents.append('  "_%s"' % sym)
    142142            self.execute(write_file, (def_file, contents),
    143143                         "writing %s" % def_file)
     
    209209    # to deal with file naming/searching differences
    210210    def find_library_file(self, dirs, lib, debug=0):
    211         shortlib = '%s.lib' % lib
    212         longlib = 'lib%s.lib' % lib    # this form very rare
     211        try_names = [lib + ".lib", lib + ".a", "lib" + lib + ".lib", "lib" + lib + ".a"]
    213212
    214213        # get EMX's default library directory search path
     
    218217            emx_dirs = []
    219218
     219        #print "dirs:",dirs
    220220        for dir in dirs + emx_dirs:
    221             shortlibp = os.path.join(dir, shortlib)
    222             longlibp = os.path.join(dir, longlib)
    223             if os.path.exists(shortlibp):
    224                 return shortlibp
    225             elif os.path.exists(longlibp):
    226                 return longlibp
     221            for name in try_names:
     222                libfile = os.path.join(dir, name)
     223                #print "libfile:",libfile
     224                if os.path.exists(libfile):
     225                    return libfile
    227226
    228227        # Oops, didn't find it in *any* of 'dirs'
  • python/trunk/Lib/distutils/sysconfig.py

    r2 r10  
    9191            return os.path.join(prefix, "Include")
    9292    elif os.name == "os2":
    93         return os.path.join(prefix, "Include")
     93        if python_build:
     94            base = os.path.dirname(os.path.abspath(sys.executable))
     95            if plat_specific:
     96                inc_dir = base
     97            else:
     98                inc_dir = os.path.join(base, "Include")
     99                if not os.path.exists(inc_dir):
     100                    inc_dir = os.path.join(os.path.dirname(base), "Include")
     101            return inc_dir
     102        return os.path.join(prefix, "include", "python" + get_python_version())
    94103    else:
    95104        raise DistutilsPlatformError(
     
    145154
    146155    elif os.name == "os2":
     156        libpython = os.path.join(prefix,
     157                                 "lib", "python" + get_python_version())
    147158        if standard_lib:
    148             return os.path.join(prefix, "Lib")
    149         else:
    150             return os.path.join(prefix, "Lib", "site-packages")
     159            return libpython
     160        else:
     161            return os.path.join(libpython, "site-packages")
    151162
    152163    else:
     
    491502    """Initialize the module as appropriate for OS/2"""
    492503    g = {}
     504    # load the installed Makefile:
     505    try:
     506        filename = get_makefile_filename()
     507        parse_makefile(filename, g)
     508    except IOError, msg:
     509        my_msg = "invalid Python installation: unable to open %s" % filename
     510        if hasattr(msg, "strerror"):
     511            my_msg = my_msg + " (%s)" % msg.strerror
     512
     513        raise DistutilsPlatformError(my_msg)
     514
     515    # load the installed pyconfig.h:
     516    try:
     517        filename = get_config_h_filename()
     518        parse_config_h(file(filename), g)
     519    except IOError, msg:
     520        my_msg = "invalid Python installation: unable to open %s" % filename
     521        if hasattr(msg, "strerror"):
     522            my_msg = my_msg + " (%s)" % msg.strerror
     523
     524        raise DistutilsPlatformError(my_msg)
     525
     526    # On AIX, there are wrong paths to the linker scripts in the Makefile
     527    # -- these paths are relative to the Python source, but when installed
     528    # the scripts are in another directory.
     529    if python_build:
     530        g['LDSHARED'] = g['BLDSHARED']
     531
     532    # OS/2 module
     533
    493534    # set basic install directories
    494535    g['LIBDEST'] = get_python_lib(plat_specific=0, standard_lib=1)
  • python/trunk/Lib/distutils/unixccompiler.py

    r2 r10  
    140140    dylib_lib_extension = ".dylib"
    141141    static_lib_format = shared_lib_format = dylib_lib_format = "lib%s%s"
    142     if sys.platform == "cygwin":
     142    if sys.platform == "cygwin" or sys.platform == "os2emx" or sys.platform == "os2knix":
    143143        exe_extension = ".exe"
    144144
     
    284284        # we use this hack.
    285285        compiler = os.path.basename(sysconfig.get_config_var("CC"))
    286         if sys.platform[:6] == "darwin":
     286        if sys.platform[:6] == "darwin" or sys.platform[:7] == "os2knix":
    287287            # MacOSX's linker doesn't understand the -R flag at all
    288288            return "-L" + dir
  • python/trunk/Lib/os.py

    r2 r10  
    7575    except ImportError:
    7676        pass
    77     if sys.version.find('EMX GCC') == -1:
     77    if sys.platform == 'os2knix':
     78        import os2knixpath as path
     79    elif sys.version.find('EMX GCC') == -1:
    7880        import ntpath as path
    7981    else:
  • python/trunk/Lib/popen2.py

    r2 r10  
    135135
    136136
    137 if sys.platform[:3] == "win" or sys.platform == "os2emx":
     137if sys.platform[:3] == "win" or sys.platform == "os2emx" or sys.platform == "os2knix":
    138138    # Some things don't make sense on non-Unix platforms.
    139139    del Popen3, Popen4
  • python/trunk/Lib/site.py

    r2 r10  
    232232        return os.path.expanduser(os.path.join(*args))
    233233
    234     #if sys.platform in ('os2emx', 'riscos'):
     234    #if sys.platform in ('os2emx', 'os2knix', 'riscos'):
    235235    #    # Don't know what to put here
    236236    #    USER_BASE = ''
     
    263263        seen.append(prefix)
    264264
    265         if sys.platform in ('os2emx', 'riscos'):
     265        if sys.platform in ('os2emx', 'os2knix', 'riscos'):
    266266            sitedirs.append(os.path.join(prefix, "Lib", "site-packages"))
    267267        elif os.sep == '/':
     
    495495    known_paths = addusersitepackages(known_paths)
    496496    known_paths = addsitepackages(known_paths)
    497     if sys.platform == 'os2emx':
     497    if sys.platform == 'os2emx' or sys.platform == 'os2knix':
     498        if (sys.path and os.path.basename(sys.path[-1]) == "Modules"):
     499            addbuilddir()
    498500        setBEGINLIBPATH()
    499501    setquit()
  • python/trunk/Lib/tempfile.py

    r2 r10  
    388388    # the wrapper to do anything special.  We still use it so that
    389389    # file.name is useful (i.e. not "(fdopen)") with NamedTemporaryFile.
    390     if _os.name != 'nt':
     390    if _os.name != 'nt' and _os.name != 'os2':
    391391        # Cache the unlinker so we don't get spurious errors at
    392392        # shutdown when the module-level "os" is None'd out.  Note
     
    446446    return _TemporaryFileWrapper(file, name, delete)
    447447
    448 if _os.name != 'posix' or _os.sys.platform == 'cygwin':
     448if _os.name != 'posix' or _os.sys.platform == 'cygwin' or _os.sys.platform == 'os2emx' or _os.sys.platform == 'os2knix':
    449449    # On non-POSIX and Cygwin systems, assume that we cannot unlink a file
    450450    # while it is open.
  • python/trunk/Lib/test/regrtest.py

    r2 r10  
    10371037        test_signal
    10381038        """,
     1039    'os2knix':
     1040        """
     1041        test_al
     1042        test_applesingle
     1043        test_audioop
     1044        test_bsddb185
     1045        test_bsddb3
     1046        test_cd
     1047        test_cl
     1048        test_commands
     1049        test_dl
     1050        test_gl
     1051        test_imgfile
     1052        test_linuxaudiodev
     1053        test_mhlib
     1054        test_mmap
     1055        test_nis
     1056        test_openpty
     1057        test_ossaudiodev
     1058        test_pty
     1059        test_resource
     1060        test_sqlite
     1061        test_startfile
     1062        test_sunaudiodev
     1063        """,
    10391064    'freebsd4':
    10401065        """
  • python/trunk/Lib/test/test_tempfile.py

    r2 r10  
    260260        mode = stat.S_IMODE(os.stat(file.name).st_mode)
    261261        expected = 0600
    262         if sys.platform in ('win32', 'os2emx', 'mac'):
     262        if sys.platform in ('win32', 'os2emx', 'os2knix', 'mac'):
    263263            # There's no distinction among 'user', 'group' and 'world';
    264264            # replicate the 'user' bits.
     
    479479            mode &= 0777 # Mask off sticky bits inherited from /tmp
    480480            expected = 0700
    481             if sys.platform in ('win32', 'os2emx', 'mac'):
     481            if sys.platform in ('win32', 'os2emx', 'os2knix', 'mac'):
    482482                # There's no distinction among 'user', 'group' and 'world';
    483483                # replicate the 'user' bits.
  • python/trunk/Lib/test/test_unicodedata.py

    r2 r10  
    7272        # but the other test cases will still be run
    7373        import unicodedata
    74         self.db = unicodedata
    7574
    7675    def tearDown(self):
  • python/trunk/Lib/urllib2.py

    r2 r10  
    12751275        host = req.get_host()
    12761276        file = req.get_selector()
     1277
     1278        # YD hack: add again drive name
     1279        if os.name == 'os2' and len(host)>2 and host[1] == ':':
     1280            file = host + file
     1281            host = ""
     1282
    12771283        localfile = url2pathname(file)
    12781284        try:
  • python/trunk/Makefile.pre.in

    r2 r10  
    158158LDLIBRARYDIR=   @LDLIBRARYDIR@
    159159INSTSONAME=     @INSTSONAME@
     160CONDENSED_VERSION=      @CONDENSED_VERSION@
    160161
    161162
     
    454455        $(LN) -fsn Versions/Current/Resources $(PYTHONFRAMEWORKDIR)/Resources
    455456
     457ifneq ($(filter os2emx os2knix,$(MACHDEP)),) # bird hack!
     458$(DLLLIBRARY) $(LDLIBRARY): $(LIBRARY_OBJS)
     459        $(LDSHARED) -o $(DLLLIBRARY) $^ $(LIBS) $(MODLIBS) $(SYSLIBS)
     460        emximp -o $(LDLIBRARY) $(DLLLIBRARY)
     461
     462else # CYGWIN
    456463# This rule builds the Cygwin Python DLL and import library if configured
    457464# for a shared core library; otherwise, this rule is a noop.
     
    462469        else true; \
    463470        fi
     471endif # end bird hack! 
    464472
    465473
     
    533541
    534542$(AST_H): $(AST_ASDL) $(ASDLGEN_FILES)
     543ifndef BOOTSTRAPPING_PYTHON
    535544        $(ASDLGEN) -h $(AST_H_DIR) $(AST_ASDL)
     545endif
    536546
    537547$(AST_C): $(AST_ASDL) $(ASDLGEN_FILES)
     548ifndef BOOTSTRAPPING_PYTHON
    538549        $(ASDLGEN) -c $(AST_C_DIR) $(AST_ASDL)
     550endif
    539551
    540552Python/compile.o Python/symtable.o: $(GRAMMAR_H) $(AST_H)
     
    764776        -rm -f $(DESTDIR)$(BINDIR)/python-config
    765777        (cd $(DESTDIR)$(BINDIR); $(LN) -s python$(VERSION)-config python-config)
     778        rm -f $(DESTDIR)$(BINDIR)/$(PYTHON); \
     779        $(INSTALL_PROGRAM) $(BUILDPYTHON) $(DESTDIR)$(BINDIR)/$(PYTHON); \
     780        $(INSTALL_DATA) $(LDLIBRARY) $(DLLLIBRARY) $(DESTDIR)$(LIBDIR); \
    766781
    767782# Install the interpreter with $(VERSION) affixed
     
    906921                ./$(BUILDPYTHON) -Wi -t -c "import lib2to3.pygram, lib2to3.patcomp;lib2to3.patcomp.PatternCompiler()"
    907922
     923ifneq ($(filter os2emx os2knix,$(MACHDEP)),) # bird hack!
     924PATH_SEPARATOR = ;
     925else
     926PATH_SEPARATOR = :
     927endif
     928                                 
    908929# Create the PLATDIR source directory, if one wasn't distributed..
    909930$(srcdir)/Lib/$(PLATDIR):
    910931        mkdir $(srcdir)/Lib/$(PLATDIR)
    911932        cp $(srcdir)/Lib/plat-generic/regen $(srcdir)/Lib/$(PLATDIR)/regen
    912         export PATH; PATH="`pwd`:$$PATH"; \
     933        export PATH; PATH="`pwd`$(PATH_SEPARATOR)$$PATH"; \
    913934        export PYTHONPATH; PYTHONPATH="`pwd`/Lib"; \
    914935        export DYLD_FRAMEWORK_PATH; DYLD_FRAMEWORK_PATH="`pwd`"; \
     
    10061027                --install-scripts=$(BINDIR) \
    10071028                --install-platlib=$(DESTSHARED) \
    1008                 --root=/$(DESTDIR)
     1029                --root=$(DESTDIR)
    10091030
    10101031# Here are a couple of targets for MacOSX again, to install a full
  • python/trunk/Misc/python-config.in

    r2 r10  
    4545elif opt in ('--libs', '--ldflags'):
    4646    libs = getvar('LIBS').split() + getvar('SYSLIBS').split()
     47    # YD ignore libs
     48    libs = getvar('SYSLIBS').split()
    4749    libs.append('-lpython'+pyver)
    4850    # add the prefix/lib/pythonX.Y/config dir, but only if there is no
  • python/trunk/Modules/Setup.dist

    r2 r10  
    113113# setup.py script in the root of the Python source tree.
    114114
    115 posix posixmodule.c             # posix (UNIX) system calls
     115os2 posixmodule.c               # posix (UNIX) system calls
    116116errno errnomodule.c             # posix (UNIX) errno values
    117117pwd pwdmodule.c                 # this is needed to find out the user's home dir
  • python/trunk/Modules/_hotshot.c

    r2 r10  
    16051605
    16061606
     1607#ifdef __OS2__
     1608PyMODINIT_FUNC
     1609#else
    16071610void
     1611#endif
    16081612init_hotshot(void)
    16091613{
  • python/trunk/Modules/_multiprocessing/multiprocessing.c

    r2 r10  
    8787#else /* !MS_WINDOWS */
    8888
    89 #if HAVE_FD_TRANSFER
     89#if defined(HAVE_FD_TRANSFER)
    9090
    9191/* Functions for transferring file descriptors between processes.
  • python/trunk/Modules/_multiprocessing/multiprocessing.h

    r2 r10  
    2828#  include <sys/uio.h>
    2929#  include <arpa/inet.h>             /* htonl() and ntohl() */
     30#ifndef __EMX__
    3031#  if HAVE_SEM_OPEN
    3132#    include <semaphore.h>
    3233     typedef sem_t *SEM_HANDLE;
    3334#  endif
     35#else
     36#  define SEM_HANDLE HANDLE
     37#endif
    3438#  define HANDLE int
    3539#  define SOCKET int
  • python/trunk/Modules/cjkcodecs/cjkcodecs.h

    r2 r10  
    387387#endif
    388388
     389#ifdef __OS2__
     390#define I_AM_A_MODULE_FOR(loc)                                          \
     391        PyMODINIT_FUNC                                                          \
     392        init_codecs_##loc(void)                                         \
     393        {                                                               \
     394                PyObject *m = Py_InitModule("_codecs_" #loc, __methods);\
     395                if (m != NULL)                                          \
     396                        (void)register_maps(m);                         \
     397        }
     398#else   
    389399#define I_AM_A_MODULE_FOR(loc)                                          \
    390400        void                                                            \
     
    395405                        (void)register_maps(m);                         \
    396406        }
    397 
    398 #endif
     407#endif
     408
     409#endif
  • python/trunk/Modules/fcntlmodule.c

    r2 r10  
    316316            return NULL;
    317317
    318 #if defined(PYOS_OS2) && defined(PYCC_GCC)
     318#if defined(PYOS_OS2) && defined(PYCC_GCC) && !defined(__KLIBC__)
    319319        PyErr_SetString(PyExc_NotImplementedError,
    320320                        "lockf not supported on OS/2 (EMX)");
     
    374374        Py_INCREF(Py_None);
    375375        return Py_None;
    376 #endif  /* defined(PYOS_OS2) && defined(PYCC_GCC) */
     376#endif  /* defined(PYOS_OS2) && defined(PYCC_GCC) && !defined(__KLIBC__)*/
    377377}
    378378
  • python/trunk/Modules/getpath.c

    r2 r10  
    117117#endif
    118118
     119#ifndef __EMX__
    119120#ifndef PYTHONPATH
    120121#define PYTHONPATH PREFIX "/lib/python" VERSION ":" \
    121122              EXEC_PREFIX "/lib/python" VERSION "/lib-dynload"
     123#endif
     124#else
     125//#define PYTHONPATH    "./Lib;./Lib/plat-" PLATFORM \
     126//                      ";./Lib/lib-dynload;./Lib/site-packages"
     127// force unixroot
     128#define PYTHONPATH PREFIX "/lib/python" VERSION ";" \
     129              EXEC_PREFIX "/lib/python" VERSION "/lib-" PLATFORM ";" \
     130              EXEC_PREFIX "/lib/python" VERSION "/site-packages" ";" \
     131              EXEC_PREFIX "/lib/python" VERSION "/lib-dynload" ";" \
     132/* now local (for building) */ \
     133              "./lib" ";" \
     134              "./lib/plat-" PLATFORM ";" \
     135              "./lib/site-packages" ";" \
     136              "./lib/lib-dynload"
    122137#endif
    123138
     
    136151{
    137152    size_t i = strlen(dir);
    138     while (i > 0 && dir[i] != SEP)
     153    while (i > 0 && !IS_SEP(dir[i]))
    139154        --i;
    140155    dir[i] = '\0';
     
    209224{
    210225    size_t n, k;
    211     if (stuff[0] == SEP)
     226    if (IS_ABSPATH(stuff))
    212227        n = 0;
    213228    else {
    214229        n = strlen(buffer);
    215         if (n > 0 && buffer[n-1] != SEP && n < MAXPATHLEN)
     230        if (n > 0 && !IS_SEP(buffer[n-1]) && n < MAXPATHLEN)
    216231            buffer[n++] = SEP;
    217232    }
     
    230245copy_absolute(char *path, char *p)
    231246{
    232     if (p[0] == SEP)
     247    if (IS_ABSPATH(p)) {
    233248        strcpy(path, p);
     249#ifdef ALTSEP
     250        p = path;
     251        while ((p = strchr(p, ALTSEP)))
     252            *p++ = SEP;
     253#endif
     254    }
    234255    else {
    235256        getcwd(path, MAXPATHLEN);
    236         if (p[0] == '.' && p[1] == SEP)
     257        if (p[0] == '.' && IS_SEP(p[1]))
    237258            p += 2;
    238259        joinpath(path, p);
     
    246267    char buffer[MAXPATHLEN + 1];
    247268
    248     if (path[0] == SEP)
     269    if (IS_ABSPATH(path)) {
     270#ifdef ALTSEP
     271        while ((path = strchr(path, ALTSEP)))
     272            *path++ = SEP;
     273#endif
    249274        return;
     275    }
    250276    copy_absolute(buffer, path);
    251277    strcpy(path, buffer);
     
    399425         * $PATH isn't exported, you lose.
    400426         */
    401         if (strchr(prog, SEP))
     427        if (HAS_ANYSEP(prog))
    402428                strncpy(progpath, prog, MAXPATHLEN);
    403429#ifdef __APPLE__
     
    442468        else
    443469                progpath[0] = '\0';
    444         if (progpath[0] != SEP)
     470#ifndef ALTSEP
     471        if (!IS_ABSPATH(progpath))
     472#endif
    445473                absolutize(progpath);
    446474        strncpy(argv0_path, progpath, MAXPATHLEN);
     
    488516            /* It's not null terminated! */
    489517            tmpbuffer[linklen] = '\0';
    490             if (tmpbuffer[0] == SEP)
     518            if (IS_ABSPATH(tmpbuffer))
    491519                /* tmpbuffer should never be longer than MAXPATHLEN,
    492520                   but extra check does not hurt */
     
    553581
    554582    while (1) {
    555         char *delim = strchr(defpath, DELIM);
    556 
    557         if (defpath[0] != SEP)
     583        char *delim = strchr(defpath, ':'); /* bird: hardcoded DELIM in default path. */
     584
     585        if (!IS_ABSPATH(defpath))
    558586            /* Paths are relative to prefix */
    559587            bufsz += prefixsz;
     
    598626        defpath = pythonpath;
    599627        while (1) {
    600             char *delim = strchr(defpath, DELIM);
    601 
    602             if (defpath[0] != SEP) {
     628            char *delim = strchr(defpath, ':'); /* bird: hardcoded DELIM in default path. */
     629
     630            if (!IS_ABSPATH(defpath)) {
    603631                strcat(buf, prefix);
    604632                strcat(buf, separator);
     
    606634
    607635            if (delim) {
    608                 size_t len = delim - defpath + 1;
     636                size_t len = delim - defpath;
    609637                size_t end = strlen(buf) + len;
    610638                strncat(buf, defpath, len);
    611                 *(buf + end) = '\0';
     639                *(buf + end) = DELIM;   /* bird: correct the DELIM char. */
     640                *(buf + end + 1) = '\0';
    612641            }
    613642            else {
  • python/trunk/Modules/posixmodule.c

    r2 r10  
    3434#    include <unixio.h>
    3535#endif /* defined(__VMS) */
     36
     37#if defined(__KLIBC__)
     38#include <sys/socket.h>
     39#endif
    3640
    3741#ifdef __cplusplus
     
    132136#define fsync _commit
    133137#else
    134 #if defined(PYOS_OS2) && defined(PYCC_GCC) || defined(__VMS)
     138#if (defined(PYOS_OS2) && defined(PYCC_GCC) && !defined(__KLIBC__)) || defined(__VMS)
    135139/* Everything needed is defined in PC/os2emx/pyconfig.h or vms/pyconfig.h */
    136140#else                   /* all other compilers */
     
    428432            Py_DECREF(v);
    429433        }
     434#ifdef LIBPATHSTRICT
     435        buffer[0] = buffer[1] = buffer[2] = buffer[3] = '\0';
     436        rc = DosQueryExtLIBPATH(buffer, LIBPATHSTRICT);
     437        if (rc == NO_ERROR) { /* (not a typo, envname is NOT 'LIBPATH_STRICT') */
     438            PyObject *v = PyString_FromString(buffer);
     439                    PyDict_SetItemString(d, "LIBPATHSTRICT", v);
     440            Py_DECREF(v);
     441        }
     442#endif
    430443    }
    431444#endif
     
    16501663#ifdef MS_WINDOWS
    16511664        return win32_1str(args, "chdir", "s:chdir", win32_chdir, "U:chdir", win32_wchdir);
    1652 #elif defined(PYOS_OS2) && defined(PYCC_GCC)
    1653         return posix_1str(args, "et:chdir", _chdir2);
    16541665#elif defined(__VMS)
    16551666        return posix_1str(args, "et:chdir", (int (*)(const char *))chdir);
     
    19871998                        break;
    19881999                }
    1989 #if defined(PYOS_OS2) && defined(PYCC_GCC)
    1990                 res = _getcwd2(tmpbuf, bufsize);
    1991 #else
    19922000                res = getcwd(tmpbuf, bufsize);
    1993 #endif
    19942001
    19952002                if (res == NULL) {
     
    20512058
    20522059        Py_BEGIN_ALLOW_THREADS
    2053 #if defined(PYOS_OS2) && defined(PYCC_GCC)
    2054         res = _getcwd2(buf, sizeof buf);
    2055 #else
    20562060        res = getcwd(buf, sizeof buf);
    2057 #endif
    20582061        Py_END_ALLOW_THREADS
    20592062        if (res == NULL)
     
    22452248        return d;
    22462249
    2247 #elif defined(PYOS_OS2)
     2250#elif defined(PYOS_OS2_00) // YD os2 api does not support path rewriting
    22482251
    22492252#ifndef MAX_PATH
     
    31173120#if defined(PYOS_OS2)
    31183121        /* Omit Pseudo-Env Vars that Would Confuse Programs if Passed On */
    3119         if (stricmp(k, "BEGINLIBPATH") != 0 && stricmp(k, "ENDLIBPATH") != 0) {
     3122        if (stricmp(k, "BEGINLIBPATH") != 0 && stricmp(k, "ENDLIBPATH") != 0
     3123         && stricmp(k, "LIBPATHSTRICT") != 0) {
    31203124#endif
    31213125                len = PyString_Size(key) + PyString_Size(val) + 2;
     
    42164220        char *mode = "r";
    42174221        int bufsize = -1;
     4222        int unset_emxshell = 0;
    42184223        FILE *fp;
    42194224        PyObject *f;
    42204225        if (!PyArg_ParseTuple(args, "s|si:popen", &name, &mode, &bufsize))
    42214226                return NULL;
     4227        /* a little hack for making sure commands.getstatusoutput works
     4228         * (ASSUMES that COMSPEC isn't a posix shell.) */
     4229        if (name[0] == '{' && !getenv("EMXSHELL")) {
     4230                char path[512];
     4231                _searchenv("sh.exe", "PATH", path);
     4232                if (!path[0])
     4233                        _searchenv("ash.exe", "PATH", path);
     4234                if (!path[0])
     4235                        _searchenv("bash.exe", "PATH", path);
     4236                if (path[0])
     4237                        unset_emxshell = setenv("EMXSHELL", path, 0) == 0;
     4238        }
    42224239        Py_BEGIN_ALLOW_THREADS
    42234240        fp = popen(name, mode);
    42244241        Py_END_ALLOW_THREADS
     4242        if (unset_emxshell)
     4243                unsetenv("EMXSHELL");
    42254244        if (fp == NULL)
    42264245                return posix_error();
     
    43724391        FILE *p_s[3];
    43734392        int file_count, i, pipe_err;
    4374         pid_t pipe_pid;
     4393        pid_t pipe_pid = -1;
    43754394        char *shell, *sh_name, *opt, *rd_mode, *wr_mode;
    43764395        PyObject *f, *p_f[3];
     
    43914410        if ((shell = getenv("EMXSHELL")) == NULL)
    43924411                if ((shell = getenv("COMSPEC")) == NULL)
     4412                        if ((shell = getenv("SHELL")) == NULL)
     4413                                if ((shell = getenv("OS2_SHELL")) == NULL)
    43934414                {
    43944415                        errno = ENOENT;
     
    44294450        i = pipe_err = 0;
    44304451        while ((pipe_err == 0) && (i < file_count))
     4452#ifndef __KLIBC__
    44314453                pipe_err = pipe((int *)&p_fd[i++]);
     4454#else
     4455                pipe_err = socketpair(AF_UNIX, SOCK_STREAM,0,(int *)&p_fd[i++]);
     4456#endif
    44324457        if (pipe_err < 0)
    44334458        {
     
    65906615posix_pipe(PyObject *self, PyObject *noargs)
    65916616{
    6592 #if defined(PYOS_OS2)
     6617#if defined(PYOS_OS2) && !defined(__KLIBC__)
    65936618    HFILE read, write;
    65946619    APIRET rc;
     
    66066631        int res;
    66076632        Py_BEGIN_ALLOW_THREADS
     6633#ifndef __KLIBC__
    66086634        res = pipe(fds);
     6635#else
     6636        res = socketpair(AF_UNIX, SOCK_STREAM,0, fds);
     6637#endif
    66096638        Py_END_ALLOW_THREADS
    66106639        if (res != 0)
     
    67966825        if (rc != NO_ERROR)
    67976826            return os2_error(rc);
     6827#ifdef LIBPATHSTRICT
     6828    } else if (stricmp(s1, "LIBPATHSTRICT") == 0) {
     6829        APIRET rc;
     6830
     6831        rc = DosSetExtLIBPATH(s2, LIBPATHSTRICT);
     6832        if (rc != NO_ERROR)
     6833            return os2_error(rc);
     6834#endif
    67986835    } else {
    6799 #endif
     6836#endif /* OS2 */
    68006837
    68016838        /* XXX This can leak memory -- not easy to fix :-( */
     
    84298466}
    84308467#endif
     8468
     8469#ifdef __EMX__
     8470/* Use openssl random routine */
     8471#include <openssl/rand.h>
     8472PyDoc_STRVAR(os2_urandom__doc__,
     8473"urandom(n) -> str\n\n\
     8474Return a string of n random bytes suitable for cryptographic use.");
     8475
     8476static PyObject*
     8477os2_urandom(PyObject *self, PyObject *args)
     8478{
     8479        int howMany;
     8480        PyObject* result;
     8481
     8482        /* Read arguments */
     8483        if (! PyArg_ParseTuple(args, "i:urandom", &howMany))
     8484                return NULL;
     8485        if (howMany < 0)
     8486                return PyErr_Format(PyExc_ValueError,
     8487                                    "negative argument not allowed");
     8488
     8489        /* Allocate bytes */
     8490        result = PyString_FromStringAndSize(NULL, howMany);
     8491        if (result != NULL) {
     8492                /* Get random data */
     8493                if (RAND_pseudo_bytes((unsigned char*)
     8494                                      PyString_AS_STRING(result),
     8495                                      howMany) < 0) {
     8496                        Py_DECREF(result);
     8497                        return PyErr_Format(PyExc_ValueError,
     8498                                            "RAND_pseudo_bytes");
     8499                }
     8500        }
     8501        return result;
     8502}
     8503#endif
     8504
    84318505
    84328506static PyMethodDef posix_methods[] = {
     
    87408814        {"urandom", vms_urandom, METH_VARARGS, vms_urandom__doc__},
    87418815 #endif
     8816 #ifdef __EMX__
     8817        {"urandom", os2_urandom, METH_VARARGS, os2_urandom__doc__},
     8818 #endif
    87428819        {NULL,          NULL}            /* Sentinel */
    87438820};
     
    87568833    APIRET    rc;
    87578834    ULONG     values[QSV_MAX+1];
    8758     PyObject *v;
    87598835    char     *ver, tmp[50];
    87608836
     
    87858861    default:
    87868862        PyOS_snprintf(tmp, sizeof(tmp),
    8787                       "%d-%d", values[QSV_VERSION_MAJOR],
     8863                      "%ld-%ld", values[QSV_VERSION_MAJOR],
    87888864                      values[QSV_VERSION_MINOR]);
    87898865        ver = &tmp[0];
  • python/trunk/Modules/resource.c

    r2 r10  
    6969                return NULL;
    7070
     71#ifndef __OS2__
    7172        if (getrusage(who, &ru) == -1) {
    7273                if (errno == EINVAL) {
     
    7879                return NULL;
    7980        }
    80 
     81#endif
    8182        result = PyStructSequence_New(&StructRUsageType);
    8283        if (!result)
  • python/trunk/Objects/exceptions.c

    r2 r10  
    11471147        return "???";
    11481148    while (*cp != '\0') {
    1149         if (*cp == SEP)
     1149        if (IS_SEP(*cp))
    11501150            result = cp + 1;
    11511151        ++cp;
  • python/trunk/Python/dynload_shlib.c

    r2 r10  
    2121#else
    2222#if defined(PYOS_OS2) && defined(PYCC_GCC)
     23#ifdef __KLIBC__
     24#error "kLIBC has dlfcn.h and shouldn't get here!"
     25#endif
    2326#include "dlfcn.h"
    2427#endif
    2528#endif
    2629
    27 #if (defined(__OpenBSD__) || defined(__NetBSD__)) && !defined(__ELF__)
     30#if ((defined(__OpenBSD__) || defined(__NetBSD__)) && !defined(__ELF__)) \
     31    || (defined(__OS2__) && defined(__KLIBC__))
    2832#define LEAD_UNDERSCORE "_"
    2933#else
     
    3741        {"module.dll", "rb", C_EXTENSION},
    3842#else
    39 #if defined(PYOS_OS2) && defined(PYCC_GCC)
     43#if (defined(PYOS_OS2) && defined(PYCC_GCC)) || (defined(__OS2__) && defined(__KLIBC__))
    4044        {".pyd", "rb", C_EXTENSION},
    4145        {".dll", "rb", C_EXTENSION},
     
    128132#endif
    129133
     134#if (defined(PYOS_OS2) && defined(PYCC_GCC))
     135        // resolve unixroot
     136        if (_realrealpath( pathname, pathbuf, sizeof(pathbuf))!=0)
     137                pathname = pathbuf;
     138#endif
     139
    130140        handle = dlopen(pathname, dlopenflags);
    131141
  • python/trunk/Python/import.c

    r2 r10  
    15641564#include <dirent.h>
    15651565
     1566#elif defined(__KLIBC__)
     1567#include <stdlib.h>
     1568
    15661569#elif defined(PYOS_OS2)
    15671570#define INCL_DOS
     
    16831686
    16841687/* OS/2 */
     1688#elif defined(__KLIBC__)
     1689        char canon[MAXPATHLEN+1];
     1690        size_t canonlen;
     1691        char *p, *p2;
     1692
     1693        if (Py_GETENV("PYTHONCASEOK") != NULL)
     1694                return 1;
     1695
     1696        /* This resolves case differences and return and native OS/2
     1697           path. Unfortunately, it'll also resolve symbolic links
     1698           while of course will screw up a bit... */
     1699        if (!_realrealpath(buf, canon, sizeof(canon)))
     1700                return 0;
     1701        canonlen = strlen(canon);
     1702        if (canonlen < namelen)
     1703                return 0;
     1704        p = strrchr(canon, SEP);
     1705        p2 = strrchr(p ? p : canon, ALTSEP);
     1706        if (p2)
     1707                p = p2;
     1708
     1709        return strncmp(p ? p + 1 : canon, name, namelen) == 0;
     1710
    16851711#elif defined(PYOS_OS2)
    16861712        HDIR hdir = 1;
  • python/trunk/Python/pystrtod.c

    r2 r10  
    33#include <Python.h>
    44#include <locale.h>
     5#ifdef __EMX__
     6#include <float.h>
     7#endif
     8
    59
    610/* ascii character tests (as opposed to locale tests) */
     
    4145PyOS_ascii_strtod(const char *nptr, char **endptr)
    4246{
     47#ifdef __EMX__
     48_control87(MCW_EM, MCW_EM);
     49#endif
    4350        char *fail_pos;
    4451        double val = -1.0;
     
    173180        }
    174181        else {
     182//sigfpe here
    175183                val = strtod(digits_pos, &fail_pos);
    176184        }
  • python/trunk/Python/sysmodule.c

    r2 r10  
    15561556                        /* It's a symlink */
    15571557                        link[nr] = '\0';
    1558                         if (link[0] == SEP)
     1558                        if (IS_ABSPATH(link))
    15591559                                argv0 = link; /* Link to absolute path */
    1560                         else if (strchr(link, SEP) == NULL)
     1560                        else if (!HAS_ANYSEP(link))
    15611561                                ; /* Link without path */
    15621562                        else {
    15631563                                /* Must join(dirname(argv0), link) */
    15641564                                char *q = strrchr(argv0, SEP);
     1565#ifdef ALTSEP
     1566                                char *q2 = strrchr(q ? q : argv0, ALTSEP);
     1567                                if (q2)
     1568                                        q = q2;
     1569#endif
     1570#ifdef DRVSEP
     1571                                if (!q && HAS_DRV(argv0))
     1572                                        q = strchr(argv0, DRVSEP);
     1573#endif
     1574
    15651575                                if (q == NULL)
    15661576                                        argv0 = link; /* argv0 without path */
     
    15681578                                        /* Must make a copy */
    15691579                                        strcpy(argv0copy, argv0);
    1570                                         q = strrchr(argv0copy, SEP);
     1580                                        q = &argv0copy[q - argv0];
    15711581                                        strcpy(q+1, link);
    15721582                                        argv0 = argv0copy;
     
    16091619#endif
    16101620                        p = strrchr(argv0, SEP);
     1621#ifdef ALTSEP
     1622                        {
     1623                                char *p2 = strrchr(p ? p : argv0, ALTSEP);
     1624                                if (p2 != NULL)
     1625                                        p = p2;
     1626                        }
     1627#endif
     1628#ifdef DRVSEP
     1629                        if (p == NULL && HAS_DRV(argv0))
     1630                                p = strchr(argv0, DRVSEP);
     1631#endif
    16111632                }
    16121633                if (p != NULL) {
  • python/trunk/Python/traceback.c

    r2 r10  
    158158                                        if (strlen(namebuf) != len)
    159159                                                continue; /* v contains '\0' */
    160                                         if (len > 0 && namebuf[len-1] != SEP)
     160                                        if (len > 0 && IS_SEP(namebuf[len-1]))
    161161                                                namebuf[len++] = SEP;
    162162                                        strcpy(namebuf+len, tail);
  • python/trunk/configure

    r2 r10  
    698698LDLIBRARYDIR
    699699INSTSONAME
     700CONDENSED_VERSION
    700701RUNSHARED
    701702LINKCC
     
    21062107        atheos*) MACHDEP="atheos";;
    21072108        irix646) MACHDEP="irix6";;
     2109        os2*|OS/2*|emx*) MACHDEP="os2knix";;
    21082110        '')     MACHDEP="unknown";;
    21092111        esac
     
    40134015LDLIBRARYDIR=''
    40144016RUNSHARED=''
     4017CONDENSED_VERSION=`echo "${VERSION}" | tr -d .,"`
    40154018
    40164019# LINKCC is the command that links the python executable -- default is $(CC).
     
    40564059then
    40574060  case $ac_sys_system in
    4058   CYGWIN* | atheos*)
     4061  CYGWIN* | atheos* | *OS/2* | *emx* | *os2*)
    40594062    enable_shared="yes";;
    40604063  *)
     
    42054208        RUNSHARED='DYLD_LIBRARY_PATH=`pwd`:${DYLD_LIBRARY_PATH}'
    42064209        ;;
     4210    OS/2*|os2*|*emx*)
     4211        LDLIBRARY='python$(VERSION)_dll.a'
     4212        BLDLIBRARY='-L. -lpython$(VERSION)'
     4213        RUNSHARED=BEGINLIBPATH="'`pwd`;$BEGINLIBPATH'"
     4214        DLLLIBRARY='python${CONDENSED_VERSION}.dll'
     4215        ;;
    42074216
    42084217  esac
     
    45334542                CYGWIN*) LN="ln -s";;
    45344543                atheos*) LN="ln -s";;
     4544                OS/2*|os2*|*emx*) LN="ln -s";;
    45354545                *) LN=ln;;
    45364546        esac
     
    1319213202                ;;
    1319313203        CYGWIN*)   SO=.dll;;
     13204        OS/2*|os2*|*emx*) SO=.dll;;
    1319413205        *)         SO=.so;;
    1319513206        esac
     
    1332213333        CYGWIN*) LDSHARED="gcc -shared -Wl,--enable-auto-image-base";;
    1332313334        atheos*) LDSHARED="gcc -shared";;
     13335        OS/2*|os2*|*emx*) LDSHARED="gcc -Zdll -Zomf";;
    1332413336        *)      LDSHARED="ld";;
    1332513337        esac
     
    2591125923INSTSONAME!$INSTSONAME$ac_delim
    2591225924RUNSHARED!$RUNSHARED$ac_delim
     25925CONDENSED_VERSION!$CONDENSED_VERSION$ac_delim
    2591325926LINKCC!$LINKCC$ac_delim
    2591425927RANLIB!$RANLIB$ac_delim
     
    2592825941_ACEOF
    2592925942
    25930   if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 97; then
     25943  if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 98; then
    2593125944    break
    2593225945  elif $ac_last_try; then
  • python/trunk/pyconfig.h.in

    r2 r10  
    10921092#endif
    10931093
     1094#if defined(__EMX__)
     1095#define PLATFORM "os2knix"
     1096#define PYOS_OS2 1
     1097#define PYCC_GCC 1
     1098#undef HAVE_LINK // YD not working but available
     1099#endif
     1100
    10941101#endif /*Py_PYCONFIG_H*/
    10951102
  • python/trunk/setup.py

    r2 r10  
    383383            inc_dirs += os.getenv('C_INCLUDE_PATH', '').split(os.pathsep)
    384384
     385        # Check for OS/2 which may have libraries in non-standard locations
     386        if platform == 'os2knix':
     387            lib_dirs += os.getenv('LIBRARY_PATH', '').split(os.pathsep)
     388            inc_dirs += os.getenv('C_INCLUDE_PATH', '').split(os.pathsep)
    385389        # OSF/1 and Unixware have some stuff in /usr/ccs/lib (like -ldb)
    386390        if platform in ['osf1', 'unixware7', 'openunix8']:
     
    517521
    518522        # Memory-mapped files (also works on Win32).
    519         if platform not in ['atheos', 'mac']:
     523        if platform not in ['atheos', 'mac', 'os2knix']:
    520524            exts.append( Extension('mmap', ['mmapmodule.c']) )
    521525        else:
     
    868872            db_incs = [db_incdir]
    869873            dblibs = [dblib]
     874            # YD add required libs
     875            if os.name == "os2":
     876                dblibs += ["mmap", "pthread"]
    870877            # We add the runtime_library_dirs argument because the
    871878            # BerkeleyDB lib we're linking against often isn't in the
     
    10691076
    10701077            # Sun yellow pages. Some systems have the functions in libc.
    1071             if (platform not in ['cygwin', 'atheos', 'qnx6'] and
     1078            if (platform not in ['cygwin', 'atheos', 'qnx6', 'os2knix'] and
    10721079                find_file('rpcsvc/yp_prot.h', inc_dirs, []) is not None):
    10731080                if (self.compiler.find_library_file(lib_dirs, 'nsl')):
     
    12881295            libraries = []
    12891296
     1297        elif platform in ('os2knix'):
     1298            # FreeBSD's P1003.1b semaphore support is very experimental
     1299            # and has many known problems. (as of June 2008)
     1300            macros = dict(                  # FreeBSD
     1301                HAVE_SEM_OPEN=0,
     1302                HAVE_SEM_TIMEDWAIT=0,
     1303                )
     1304            libraries = []
    12901305        elif platform.startswith('openbsd'):
    12911306            macros = dict(                  # OpenBSD
Note: See TracChangeset for help on using the changeset viewer.