Issue2416

classification
Title: os.system does not use changes to os.environ in subprocesses
Type: behaviour Severity: major
Components: Core Versions: Jython 2.7
Milestone: Jython 2.7.1
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: zyasoft Nosy List: irairdon, zyasoft
Priority: Keywords:

Created on 2015-10-26.17:54:49 by irairdon, last changed 2015-11-03.23:57:33 by zyasoft.

Messages
msg10382 (view) Author: Isaiah Rairdon (irairdon) Date: 2015-10-26.17:54:49
The issue seems to be in jython 2.5 os.environ you could set an environment variable to be used later by other command in the session. In my case I would use os.environ['ORACLE_HOME'] to set the home and then later run os.system commands that need the ORACLE_HOME set which worked fine in jython 2.5.2 and works in python 2.7 but doesn't seem to work for jython 2.7. I am testing this on RHEL 6. 

Follow these steps to reproduce:

jython 2.7
import os
os.environ['TESTING'] = 'VALUEFORTEST'
os.system('env')
msg10383 (view) Author: Jim Baker (zyasoft) Date: 2015-10-26.20:31:54
This is due to the rewrite of os.system (as implemented in subprocess._os_system) in #2238. At that time, we did not carry over the merge environment functionality found in the Jython-specific method _setup_env in the subprocess.Popen class.

Work around for now is to use subprocess; see this recipe in the subprocess docs: https://docs.python.org/2/library/subprocess.html#replacing-os-system

Should be a straightforward fix.
msg10386 (view) Author: Isaiah Rairdon (irairdon) Date: 2015-10-26.22:01:49
Is there any chance you might be fixing os.system anytime soon in a patch release? I understand the workaround, but the issue isn't that I can't change couple lines of code to use subprocess but our product allows customers to write custom code using jython and they will have used os.system with environment variables. This bug presents a really big issue for us being able to upgrade to 2.7 as it will likely break hundreds of customer environments across the globe when they upgrade to the newer version of our software using 2.7.
msg10387 (view) Author: Jim Baker (zyasoft) Date: 2015-10-26.22:05:19
Currently the milestone is 2.7.1, which is scheduled to be released in November, with a release candidate planned in 10 days.
msg10388 (view) Author: Jim Baker (zyasoft) Date: 2015-10-27.05:28:52
Fixed as of https://hg.python.org/jython/rev/cbdeff5f17f5
History
Date User Action Args
2015-11-03 23:57:33zyasoftsetstatus: pending -> closed
2015-10-27 20:12:41zyasoftsettitle: os.environ does not set session environment variable -> os.system does not use changes to os.environ in subprocesses
2015-10-27 05:28:52zyasoftsetstatus: open -> pending
resolution: accepted -> fixed
messages: + msg10388
2015-10-26 22:05:19zyasoftsetmessages: + msg10387
2015-10-26 22:01:49irairdonsetmessages: + msg10386
2015-10-26 20:31:55zyasoftsetassignee: zyasoft
resolution: accepted
messages: + msg10383
nosy: + zyasoft
milestone: Jython 2.7.1
2015-10-26 17:55:15irairdonsetseverity: normal -> major
versions: + Jython 2.7
2015-10-26 17:54:49irairdoncreate