This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: 2to3: commands varible replaced by subprocess
Type: Stage:
Components: 2to3 (2.x to 3.x conversion tool) Versions:
process
Status: closed Resolution: wont fix
Dependencies: Superseder:
Assigned To: collinwinter Nosy List: benjamin.peterson, collinwinter, vstinner
Priority: normal Keywords:

Created on 2008-08-19 22:05 by vstinner, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (4)
msg71490 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2008-08-19 22:05
I tried 2to3 on my python-ptrace project and with minor changes, it 
works fine. One of the minor changes is to replace 
subprocess.split(";") by commands.split(";"). The original code was:

   commands = command
   ok = True
   for command in commands.split(";"):
      command = command.strip()
      ok &= self.execute(command)

I don't import subprocess and I don't use this module in my code. It 
is possible to reproduce the bug only with two lines:

   commands = "a;b;c"
   x = commands.split(";")

So 2to3 doesn't care if commands is a module or variable, it just 
replaced the text pattern... It looks like the change is done 
by "fixes/fix_imports.py", maybe this pattern:

   # Find usages of module members in code e.g. urllib.foo(bar)
   yield """power< (%s)
            trailer<'.' any > any* >
         """ % mod_name_list
msg71491 - (view) Author: Benjamin Peterson (benjamin.peterson) * (Python committer) Date: 2008-08-19 22:07
Yes, this is because some of the commands module's functions have moved
to subprocess in py3k. This is probably a won't fix.
msg71494 - (view) Author: Collin Winter (collinwinter) * (Python committer) Date: 2008-08-19 22:46
Victor: that's a common problem in most fixers. The analysis needed to
statically determine whether a given identifier is a module or not is
expensive and heuristic.

One of our Summer of Code students has been working on adding a new
feature to 2to3 whereby fixers can apply confidence estimates to the
changes they make, allowing you to say "if 2to3 is 95+% confident, apply
the fix, otherwise, let me see a diff first". This could be
theoretically extended to allow other annotations, such as "changing an
identifier", which you could filter on.
msg72808 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2008-09-08 23:43
Ok, no problem. So you can close this (invalid) issue.
History
Date User Action Args
2022-04-11 14:56:37adminsetgithub: 47856
2008-09-08 23:54:50benjamin.petersonsetstatus: open -> closed
resolution: wont fix
2008-09-08 23:43:37vstinnersetmessages: + msg72808
2008-08-19 22:46:12collinwintersetmessages: + msg71494
2008-08-19 22:07:21benjamin.petersonsetnosy: + benjamin.peterson
messages: + msg71491
2008-08-19 22:05:40vstinnercreate