Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Python: Bugs

[issue4057] Popen(..., cwd=...) does not set PWD environment variable

 

 

Python bugs RSS feed   Index | Next | Previous | View Threaded


report at bugs

Nov 26, 2009, 2:21 AM

Post #1 of 9 (699 views)
Permalink
[issue4057] Popen(..., cwd=...) does not set PWD environment variable

Changes by Geoffrey Bache <gjb1002 [at] users>:


----------
nosy: +gjb1002

_______________________________________
Python tracker <report [at] bugs>
<http://bugs.python.org/issue4057>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com


report at bugs

Nov 26, 2009, 8:02 AM

Post #2 of 9 (684 views)
Permalink
[issue4057] Popen(..., cwd=...) does not set PWD environment variable [In reply to]

Ronald Oussoren <ronaldoussoren [at] mac> added the comment:

In most shells $PWD is a magic variable that is maintained by the shell
itself.

IMHO python has no reason to mess with variables that happen to be defined
by some shells. If subprocess were to set $PWD, os.setuid should set $UID,
and there may be other magic variables as well.

----------
nosy: +ronaldoussoren

_______________________________________
Python tracker <report [at] bugs>
<http://bugs.python.org/issue4057>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com


report at bugs

Nov 26, 2009, 10:27 AM

Post #3 of 9 (674 views)
Permalink
[issue4057] Popen(..., cwd=...) does not set PWD environment variable [In reply to]

Geoffrey Bache <gjb1002 [at] users> added the comment:

I can see your point, though I think particularly in this case it's
(unfortunately) fairly common that scripts on POSIX platforms read $PWD
instead of finding the current working directory properly.

I'm probably not the first person that has had to set PWD explicitly in
a python program for this reason. Yes, it's really the fault of the
people who maintain the script I'm calling, but I don't think setting
PWD on POSIX could have any bad effects and should surely be easy to do?

----------

_______________________________________
Python tracker <report [at] bugs>
<http://bugs.python.org/issue4057>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com


report at bugs

Nov 26, 2009, 11:23 PM

Post #4 of 9 (668 views)
Permalink
[issue4057] Popen(..., cwd=...) does not set PWD environment variable [In reply to]

Ronald Oussoren <ronaldoussoren [at] mac> added the comment:

On 26 Nov, 2009, at 19:27, Geoffrey Bache wrote:

>
> Geoffrey Bache <gjb1002 [at] users> added the comment:
>
> I can see your point, though I think particularly in this case it's
> (unfortunately) fairly common that scripts on POSIX platforms read $PWD
> instead of finding the current working directory properly.
>
> I'm probably not the first person that has had to set PWD explicitly in
> a python program for this reason. Yes, it's really the fault of the
> people who maintain the script I'm calling, but I don't think setting
> PWD on POSIX could have any bad effects and should surely be easy to do?

Shouldn't the script set $PWD itself? AFAIK shells like bash will set $PWD regardless of whether they are running as an interactive shell or as a shellscript.

Reading os.environ['PWD'] in a Python script not a good example of whey the proposed functionality might be useful because there are a number of ways to change the current working directory without affecting os.environ. For example using os.chdir, or even an extensions that calls the chdir system call directly.

Ronald

----------
Added file: http://bugs.python.org/file15404/smime.p7s

_______________________________________
Python tracker <report [at] bugs>
<http://bugs.python.org/issue4057>
_______________________________________
Attachments: smime.p7s (3.48 KB)


report at bugs

Nov 27, 2009, 10:42 AM

Post #5 of 9 (667 views)
Permalink
[issue4057] Popen(..., cwd=...) does not set PWD environment variable [In reply to]

Geoffrey Bache <gjb1002 [at] users> added the comment:

You misunderstand: I am not reading $PWD. I need to call a C program as
a subprocess, which is written by a third party and which determines its
current working directory by reading $PWD. os.chdir will not have any
effect on this script, nor will passing "cwd" to "subprocess.call". I
have to write os.environ["PWD"] = os.getcwd() in my code before it will
work.

Not only that, but of course I have to know about $PWD and the fact that
some people use it. Otherwise it just seems like Python isn't correctly
passing on the current working directory.

----------

_______________________________________
Python tracker <report [at] bugs>
<http://bugs.python.org/issue4057>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com


report at bugs

Nov 27, 2009, 1:24 PM

Post #6 of 9 (665 views)
Permalink
[issue4057] Popen(..., cwd=...) does not set PWD environment variable [In reply to]

Antoine Pitrou <pitrou [at] free> added the comment:

What if you pass shell=True to the subprocess call?

----------
nosy: +pitrou

_______________________________________
Python tracker <report [at] bugs>
<http://bugs.python.org/issue4057>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com


report at bugs

Nov 30, 2009, 11:45 AM

Post #7 of 9 (631 views)
Permalink
[issue4057] Popen(..., cwd=...) does not set PWD environment variable [In reply to]

Geoffrey Bache <gjb1002 [at] users> added the comment:

I tried that and it didn't work, though not for this reason. I'm also
trying to read the output from the subprocess via a pipe and that wasn't
being collected for some reason. I didn't really track down why so far,
if it makes or breaks this bug I can do so though.

----------

_______________________________________
Python tracker <report [at] bugs>
<http://bugs.python.org/issue4057>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com


report at bugs

Nov 30, 2009, 11:50 AM

Post #8 of 9 (635 views)
Permalink
[issue4057] Popen(..., cwd=...) does not set PWD environment variable [In reply to]

Jean-Paul Calderone <exarkun [at] divmod> added the comment:

`Popen` is the wrong place to implement this functionality. It may be
reasonable to introduce a higher-level wrapper API which does this sort
of thing. Consider that if `Popen` itself does it, though, then there
is no way to launch a process with a particular working directory
*without* PWD set in its environment.

----------
nosy: +exarkun

_______________________________________
Python tracker <report [at] bugs>
<http://bugs.python.org/issue4057>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com


report at bugs

Dec 1, 2009, 11:27 AM

Post #9 of 9 (630 views)
Permalink
[issue4057] Popen(..., cwd=...) does not set PWD environment variable [In reply to]

R. David Murray <rdmurray [at] bitdance> added the comment:

I agree that this is not something that Popen should be doing. If you
need the environment variable set, the correct thing to do is what you
did: set it in the environment you pass to Popen.

----------
nosy: +r.david.murray
priority: -> normal
resolution: -> rejected
stage: -> committed/rejected
status: open -> closed
type: -> feature request

_______________________________________
Python tracker <report [at] bugs>
<http://bugs.python.org/issue4057>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com

Python bugs RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.