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

subprocess (Replacing popen) - add a warning / hint #47196

Closed
HWJ mannequin opened this issue May 22, 2008 · 4 comments
Closed

subprocess (Replacing popen) - add a warning / hint #47196

HWJ mannequin opened this issue May 22, 2008 · 4 comments
Assignees
Labels
docs Documentation in the Doc dir easy type-feature A feature request or enhancement

Comments

@HWJ
Copy link
Mannequin

HWJ mannequin commented May 22, 2008

BPO 2947
Nosy @birkenfeld, @bitdancer
Files
  • issue2947-doc.patch
  • 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/bitdancer'
    closed_at = <Date 2009-06-09.00:47:38.997>
    created_at = <Date 2008-05-22.15:17:54.047>
    labels = ['easy', 'type-feature', 'docs']
    title = 'subprocess (Replacing popen) - add a warning / hint'
    updated_at = <Date 2009-06-09.00:47:38.996>
    user = 'https://bugs.python.org/HWJ'

    bugs.python.org fields:

    activity = <Date 2009-06-09.00:47:38.996>
    actor = 'r.david.murray'
    assignee = 'r.david.murray'
    closed = True
    closed_date = <Date 2009-06-09.00:47:38.997>
    closer = 'r.david.murray'
    components = ['Documentation']
    creation = <Date 2008-05-22.15:17:54.047>
    creator = 'HWJ'
    dependencies = []
    files = ['14218']
    hgrepos = []
    issue_num = 2947
    keywords = ['patch', 'easy']
    message_count = 4.0
    messages = ['67195', '89047', '89068', '89131']
    nosy_count = 3.0
    nosy_names = ['georg.brandl', 'HWJ', 'r.david.murray']
    pr_nums = []
    priority = 'normal'
    resolution = 'accepted'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'enhancement'
    url = 'https://bugs.python.org/issue2947'
    versions = ['Python 2.6', 'Python 3.0', 'Python 3.1', 'Python 2.7']

    @HWJ
    Copy link
    Mannequin Author

    HWJ mannequin commented May 22, 2008

    Background:
    I (as many others, too) have used the following code in the past

    ARC='MyDumpFile'
    tar_inp= os.popen('/bin/tar cjf '+ARC+' -T -','w')
    ....
    tar_exit_code= tar_inp.close()
    if  tar_exit_code != None and tar_exit_code % 256 :
      print "some error messages"

    When replacing this - as suggested - by

    TAR= Popen(('/bin/tar','cjf',ARC,'-T','-'),stdin=PIPE)
    tar_inp= TAR.stdin
    ....
    tar_inp.close() always returns None which was an indication
    of NO ERROR when used together with popen.

    So this has proabaly to be replaced by

    tar_inp.close()
    tar_exit_code= TAR.wait()
    
    if  tar_exit_code != 0 :
      print "some error messages"

    I suggest a warning / hint to change checking for errors
    when upgrading to subprocess.Popen

    @HWJ HWJ mannequin assigned birkenfeld May 22, 2008
    @HWJ HWJ mannequin added the docs Documentation in the Doc dir label May 22, 2008
    @bitdancer
    Copy link
    Member

    Patch attached that adds an example that shows how to translate return
    code handling, loosely based on Helmut's example. I also turned the
    function references in the section titles into links because I think
    that would be very useful to someone wanting to do a translation
    (provides easy access to the docs for the old functions). The font size
    looks a bit weird in the generated docs, though, so perhaps that is why
    this wasn't done originally. If putting references in section titles is
    a no-no let me know and I'll remove them from the patch.

    Also included in the patch is a fix for the cross reference link from
    the os.spawn section to the 'replacing functions' section of the
    subprocess docs.

    @bitdancer bitdancer added easy type-feature A feature request or enhancement labels Jun 7, 2009
    @birkenfeld
    Copy link
    Member

    Patch looks good, except for strange code indentation in the replaced
    example.

    @birkenfeld birkenfeld assigned bitdancer and unassigned birkenfeld Jun 8, 2009
    @bitdancer
    Copy link
    Member

    Applied (with spacing fix) in r73313.

    @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
    docs Documentation in the Doc dir easy type-feature A feature request or enhancement
    Projects
    None yet
    Development

    No branches or pull requests

    2 participants