poppopjmp / shedskin

Automatically exported from code.google.com/p/shedskin
0 stars 0 forks source link

os.popen2 doesn't work with list as cmd #158

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
os.popen2 doesn't work with an argv:

---
#!/usr/bin/env python

import os
child_stdin, child_stdout = os.popen2(["ls", "-l"], "r")
#print(child_stdout.read())

---

(It does work with one long string but that isn't exactly safe...)

Original issue reported on code.google.com by danny.m...@gmail.com on 9 Oct 2011 at 5:58

GoogleCodeExporter commented 8 years ago
(in CPython, it does work with both)

Original comment by danny.m...@gmail.com on 9 Oct 2011 at 5:58

GoogleCodeExporter commented 8 years ago
thanks ;-) fixed in GIT by doing a ' '.join on the command sequence. leaving 
the issue open, because this is quite probably not the correct fix, I didn't 
update popen3 etc, and there are probably a few more issues here. one is that 
popen2 doesn't seem to use its two optional arguments..

Original comment by mark.duf...@gmail.com on 11 Oct 2011 at 4:28

GoogleCodeExporter commented 8 years ago
ah yes, my fix is stupid. looking at the popen implementation, we can probably 
just pass through an arg list to the internal call to 'execvp'.. will look at 
it again later this week, if nobody beats me to it..

Original comment by mark.duf...@gmail.com on 11 Oct 2011 at 4:32

GoogleCodeExporter commented 8 years ago

Original comment by mark.duf...@gmail.com on 23 Nov 2011 at 1:42

GoogleCodeExporter commented 8 years ago

Original comment by mark.duf...@gmail.com on 11 Jan 2012 at 5:57

GoogleCodeExporter commented 8 years ago
Patch and Unit test attached :-)

Original comment by danny.m...@gmail.com on 11 Apr 2012 at 1:04

Attachments:

GoogleCodeExporter commented 8 years ago
awesome, thanks! :) will have a look later today. have you read this in the 
meantime..?

http://www.washingtonpost.com/business/technology/jack-tramiel-hard-driving-comm
odore-computer-visionary-dies-at-84/2012/04/10/gIQAJERX9S_story.html

Original comment by mark.duf...@gmail.com on 11 Apr 2012 at 1:45

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
Yeah. After John McCarthy, Dennis Ritchie and Steve Jobs, now Jack Tramiel. 
Sad. I read an interview once where the interviewer said the C64 was the way so 
many people learnt how to program and Jack Tramiel boasted and said yes, that's 
because he made sure it would be that way. 
If so, he's been a big part of why I'm programming right now...

Original comment by danny.m...@gmail.com on 11 Apr 2012 at 3:12

GoogleCodeExporter commented 8 years ago
patch committed, thanks again ;) I re-added the 'pyseq' type, because popen2 
also accepts tuples and other sequence types.. hm, perhaps even iterables, 
haven't checked. 

we could throw an IndexError as cpython does for an empty list/sequence, but I 
don't think this is very important for now.. 

it's been a while since I last received a patch, so thanks for that! ;) I'm 
planning on doing a 0.9.2 within a few weeks..

I can safely say that the commodore 64 has been one of the best things that 
have happened to me, and tramiel had a very big part in that. if you haven't 
read 'on the edge' yet, I can highly recommend it ;-)

Original comment by mark.duf...@gmail.com on 11 Apr 2012 at 8:45

GoogleCodeExporter commented 8 years ago
Yeah, I only removed the pyseq thing because I couldn't figure out how to make 
it work :-) Good that you re-added it.

Aha, I haven't read "On The Edge" yet. I should do that soon ^^

Original comment by danny.m...@gmail.com on 18 Apr 2012 at 5:51