Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

regression in subprocess.call() command quoting #54827

Closed
djc opened this issue Dec 3, 2010 · 7 comments
Closed

regression in subprocess.call() command quoting #54827

djc opened this issue Dec 3, 2010 · 7 comments
Assignees
Labels
stdlib Python modules in the Lib dir

Comments

@djc
Copy link
Member

djc commented Dec 3, 2010

BPO 10618
Nosy @birkenfeld, @tjguk, @benjaminp, @djc, @merwok, @bitdancer

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = 'https://github.com/tjguk'
closed_at = <Date 2010-12-15.03:32:06.100>
created_at = <Date 2010-12-03.20:21:44.916>
labels = ['library']
title = 'regression in subprocess.call() command quoting'
updated_at = <Date 2010-12-15.03:32:06.098>
user = 'https://github.com/djc'

bugs.python.org fields:

activity = <Date 2010-12-15.03:32:06.098>
actor = 'r.david.murray'
assignee = 'tim.golden'
closed = True
closed_date = <Date 2010-12-15.03:32:06.100>
closer = 'r.david.murray'
components = ['Library (Lib)']
creation = <Date 2010-12-03.20:21:44.916>
creator = 'djc'
dependencies = []
files = []
hgrepos = []
issue_num = 10618
keywords = []
message_count = 7.0
messages = ['123291', '123292', '123293', '123294', '123313', '123329', '124005']
nosy_count = 7.0
nosy_names = ['georg.brandl', 'tim.golden', 'benjamin.peterson', 'djc', 'kiilerix', 'eric.araujo', 'r.david.murray']
pr_nums = []
priority = 'normal'
resolution = 'wont fix'
stage = 'resolved'
status = 'closed'
superseder = None
type = None
url = 'https://bugs.python.org/issue10618'
versions = ['Python 2.7']

@djc
Copy link
Member Author

djc commented Dec 3, 2010

http://mercurial.selenic.com/bts/issue2534 is a regression in 2.7.1 relative to 2.7, around the way commands are called (it seems to concern subprocess.call()). The error seems to be raised from mercurial's util.system() call, which uses subprocess.call() or subprocess.Popen() depending on the circumstances.

@djc djc added the stdlib Python modules in the Lib dir label Dec 3, 2010
@birkenfeld
Copy link
Member

The culprit seems to be r83957, which was done to fix bpo-2304. Assigning to Tim, who committed that revision.

@birkenfeld
Copy link
Member

In util.system(), Mercurial adds its own pair of quotes:

    if os.name == 'nt':
        cmd = '"%s"' % cmd

That will result in one level of quoting too much.

Now it seems unfortunate that this change was done in a minor version.
It is definitely a bug fix, but one that many users have already worked around, probably in the same way as Mercurial.

Possible ways to resolve:

  • make addition of quotes Python-version-specific in Mercurial
  • revert to old behavior in Python 2.7.2 (ugly)
  • add a check for quotes around the string in Python 2.7.2, and refrain from adding another set of quotes

(Adding 2.7 release manager to nosy.)

@djc
Copy link
Member Author

djc commented Dec 3, 2010

Ask, Jesse, sorry, I got confused about multiprocessing and subprocess. Taking you out of the nosy now.

@benjaminp
Copy link
Contributor

2010/12/3 Georg Brandl <report@bugs.python.org>:

Georg Brandl <georg@python.org> added the comment:

In util.system(), Mercurial adds its own pair of quotes:

   if os.name == 'nt':
       cmd = '"%s"' % cmd

That will result in one level of quoting too much.

Now it seems unfortunate that this change was done in a minor version.
It is definitely a bug fix, but one that many users have already worked around, probably in the same way as Mercurial.

Possible ways to resolve:

  • make addition of quotes Python-version-specific in Mercurial
  • revert to old behavior in Python 2.7.2 (ugly)
  • add a check for quotes around the string in Python 2.7.2, and refrain from adding another set of quotes

I think we should just leave it alone. If it change the behavior again
in 2.7.2, it'll be even more consistent than before.

@tjguk
Copy link
Member

tjguk commented Dec 4, 2010

I'm not quite sure how anyone's supposed to determine
which bugs are likely to have been worked around and
which haven't :) I'm also unsure why a clear bugfix
shouldn't make it into a minor version release. Surely
this isn't the only one to do so...

I'm happy to repatch/test to strip quotes before adding,
but I see that Benjamin prefers to leave it alone.

@bitdancer
Copy link
Member

Tim: we just do our best to guess, and try to err on the conservative side. But things will always happen. Given benjamin's reply I'm closing the issue. Mercurial would have to add conditional code now anyway no matter what we do.

@ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stdlib Python modules in the Lib dir
Projects
None yet
Development

No branches or pull requests

5 participants