Title: new PythonInterpreters don't import site
Type: behaviour Severity: normal
Components: Core Versions: Jython 2.7
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: zyasoft Nosy List: amak, fwierzbicki, pjenvey, ssteiner, zyasoft
Priority: Keywords:

Created on 2010-02-09.14:34:08 by ssteiner, last changed 2014-07-10.00:00:28 by zyasoft.

msg5509 (view) Author: simon steiner (ssteiner) Date: 2010-02-09.14:34:07
<script language="jython" setbeans="false">
import sys
for x in sys.path:
    print x
msg5661 (view) Author: Philip Jenvey (pjenvey) Date: 2010-04-11.17:48:19
This is a problem in other places that create an embedded jython via the Java API (new PythonInterpreter()), like modjy and likely the jsr223 support as well

The new PythonInterpreter doesn't import site like the command line does. Alan Kennedy and I agreed that we should change this (mostly for modjy's sake) and create a flag to disable the behavior. CPython already acts this way when you create an embedded interpreter via its C API

Unfortunately I forgot to change this before the 2.5 release. It's a fairly significant change so it'll have to wait for 2.6
msg7016 (view) Author: Alan Kennedy (amak) Date: 2012-04-01.18:54:09
Deferring this breaking change to 2.7
msg7715 (view) Author: Frank Wierzbicki (fwierzbicki) Date: 2013-02-20.00:42:37
Alan, Philip: was this done for 2.7? Can this be closed?
msg7718 (view) Author: Philip Jenvey (pjenvey) Date: 2013-02-20.01:17:13
AFAIK it has not been done yet
msg7723 (view) Author: Alan Kennedy (amak) Date: 2013-02-20.08:58:53
This issue is about 'import'ing site into all embedded interpreters, by default, which does not happen right now, and should.

Back when the issue was reported, I put special coding into modjy to handle this.

Now that we're changing major versions (2.5 to 2.7 is major), it's time to put that right, and remove that support from modjy and push it down into PySystemState.

Question is, how do we enable the user to switch it off, akin to the "-S" command line option?

I think we need a new registry property for this, the default value of which causes loading of

Possibilities include

A: "", a brand new property, which defaults to "true".
B: "", a brand new property, which defaults to "true".

I will undertake the relevant work.

When this is complete, this is a fairly major change that will affect all users who embed jython, a very substantial part of our user base, I believe.

So we'll have to get our messaging right on this.
msg8179 (view) Author: Jim Baker (zyasoft) Date: 2013-11-20.20:34:14
There's an outstanding pull request that we should apply. Note that it does not yet also change org.python.core.Options such that this default can be changed. Per other such option settings, I would suggest we use python.options.importSite as the actual setting name.
msg8326 (view) Author: Jim Baker (zyasoft) Date: 2014-05-04.20:10:03
Should be part of beta 4 at the latest
msg8815 (view) Author: Jim Baker (zyasoft) Date: 2014-06-24.18:29:16
So the PR is fine, we just need to add some testing to get it into trunk. We will control with the importSite option.
msg8831 (view) Author: Jim Baker (zyasoft) Date: 2014-06-28.03:20:27
Fixed as of
Date User Action Args
2014-07-10 00:00:28zyasoftsetstatus: pending -> closed
2014-06-28 03:20:27zyasoftsetstatus: open -> pending
resolution: accepted -> fixed
messages: + msg8831
2014-06-24 18:29:17zyasoftsetassignee: amak -> zyasoft
messages: + msg8815
2014-05-04 20:10:03zyasoftsetmessages: + msg8326
2013-11-20 20:34:15zyasoftsetnosy: + zyasoft
messages: + msg8179
2013-02-20 08:58:53amaksetassignee: amak
resolution: later -> accepted
messages: + msg7723
2013-02-20 01:17:13pjenveysetmessages: + msg7718
2013-02-20 00:42:37fwierzbickisetnosy: + fwierzbicki
messages: + msg7715
versions: + Jython 2.7, - 2.7a1
2012-04-01 18:54:09amaksetmessages: + msg7016
versions: + 2.7a1, - 2.5.1
2010-04-25 20:16:01zyasoftsetresolution: later
2010-04-11 17:48:21pjenveysetnosy: + pjenvey, amak
messages: + msg5661
title: not imported when running from ant -> new PythonInterpreters don't import site
2010-02-09 14:34:08ssteinercreate