plone / plone.recipe.zope2instance

zc.buildout recipe to setup and configure a Zope 2 instance.
https://pypi.org/project/plone.recipe.zope2instance
7 stars 23 forks source link

"run" command leaves spurios components in `sys.argv` #177

Open d-maurer opened 3 years ago

d-maurer commented 3 years ago

Using bin/client1 run ..., in the run script sys.argv starts with [".../interpreter", "-c"] (rather than the run script).

I observed this with version 6.7.5 (from Plone 5.2.2) under PY2 but according to the change log the problem does not seem to have been fixed in 6.10.0.

The bug seems to be located in ctl.ZopeCmd.do_run:

        # Remove -c and add script as sys.argv[0]
        script = tup[0]
        cmd = [
            "import sys",
            "sys.argv.pop()",
            "sys.argv.append(%r)" % script,
        ]

Of course, sys.argv.pop() does not guarantee that the following append adds component 0 (as it should). I suggest to replace it with del sys.argv[:].