Ticket #815: process.patch

File process.patch, 1.9 KB (added by marienz, 17 years ago)
  • twisted/internet/process.py

     
    229229            mapping that opens the usual stdin/stdout/stderr pipes.
    230230        """
    231231
     232        # These are all checks done by the C implementation of
     233        # os.execvpe in the posix module. Duplicate them here, because
     234        # the forking makes it difficult to get exceptions later on.
     235        assert isinstance(args, (tuple, list)), "args must be a tuple or list"
     236        assert args, "args must not be empty"
     237        # it is likely this is not entirely correct. C uses
     238        # PyArg_Parse with an "et" format here, which wants a "string,
     239        # Unicode object or character buffer compatible object". But
     240        # what is a "character buffer compatible object"?
     241        for arg in args:
     242            assert isinstance(arg, (str, unicode)), \
     243                "args must contain only strings"
     244       
     245        if environment is not None:
     246            # C does a PyMapping_Check here. I'm not sure how to do
     247            # this from python. So let's just hope that something we
     248            # can do items() on is sufficiently dict-like.
     249            for key, val in environment.items():
     250                assert isinstance(key, (str, unicode)), \
     251                    "env contains a non-string key"
     252                assert isinstance(val, (str, unicode)), \
     253                    "env contains a non-string value"
     254        # perhaps we should also check whether command is executable?
     255        # that would require some PATH-walking though (see _execvpe in
     256        # os.py) if we don't want to complain about things execvpe
     257        # handles.
     258       
    232259        if not proto:
    233260            assert 'r' not in childFDs.values()
    234261            assert 'w' not in childFDs.values()