Issue 1602133: non-framework python fails to define os.environ properly (original) (raw)

Created on 2006-11-24 07:38 by ihavetopee, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
wooo.diff ihavetopee,2006-11-24 07:38 finally, python works for me and i can die in peace review
1602133.patch ronaldoussoren,2013-01-14 18:29
Messages (16)
msg51411 - (view) Author: paul (ihavetopee) Date: 2006-11-24 07:38
but no one but me seems to build python the unix-y way on darwin/macosx anymore so i guess i'm the only one that cares btw, python without environ defined makes all third party python bindings segfault this has been pissing me off for months only tracked it down yesterday here's my lackluster patch feel free to find something more apropos to conditionalize the diff with and commit it or not i don't care anymore
msg51412 - (view) Author: Adrian Silva (skiolding) Date: 2007-04-19 09:41
Wich MacOsx/python version does this affect? Python from svn trunk (r54849) on a Tiger (10.4.9) seems to define os.environ properly, with and without the patch.
msg51413 - (view) Author: paul (ihavetopee) Date: 2007-04-19 19:40
right now, i'm using macosx 10.2/python 2.4 but this should affect any macosx/darwin that's building python as a library instead of a framework meaning the symbol _environ will be completely undefined and no third party python bindings will work from posixmodule.c /* On Darwin/MacOSX a shared library or framework has no access to ** environ directly, we must obtain it with _NSGetEnviron(). */ however, the #ifdef that comment is contained in only takes the framework into consideration
msg66125 - (view) Author: Ronald Oussoren (ronaldoussoren) * (Python committer) Date: 2008-05-02 22:22
The patch looks sane, I'm assigning the bug to myself to help me remember that I should take a closer look.
msg78794 - (view) Author: Ronald Oussoren (ronaldoussoren) * (Python committer) Date: 2009-01-02 13:21
I won't commit this patch because I cannot reproduce the problem. The python trunk works fine for my in these build configurations: unix- build (static library), unix-build (shared library), framework build. All of this on OSX 10.5. Can you please provide more information on how to reproduce the problem (os releases, which version of python, how to build, what should I do to get the segfault you mention)?
msg86162 - (view) Author: Ronald Oussoren (ronaldoussoren) * (Python committer) Date: 2009-04-19 10:45
I can reproduce this with a unix build of python2.5: * Install a unix build of python 2.5 (--with-pydebug) as /opt/python2.5-dbg * Install pyobjc 2.2-dev (from PyObjC's subversion repository) * Build the addressbook plugin example in pyobjc-framework-AddressBook * Install said plugin and open the AddressBook application * The plugin won't load, and the console will mention that _environ cannot be found. I haven't tested this with python 2.6 or later yet, 2.5 happens to be the version of Python I test PyObjC with.
msg114912 - (view) Author: Mark Lawrence (BreamoreBoy) * Date: 2010-08-25 14:23
@Ronald is this still a problem or can this be closed?
msg114918 - (view) Author: Ronald Oussoren (ronaldoussoren) * (Python committer) Date: 2010-08-25 15:01
This is still a problem. Technically this only works accidently with a framework build, code that expects that '_environ' is defined in a shared library on OSX is broken.
msg138473 - (view) Author: John Whitney (jjw) Date: 2011-06-16 21:24
I have also been experiencing this problem with _environ (using the latest Python - 2.7.2), and this patch works great. I'd love to see it committed so that I don't have to patch Python.
msg140533 - (view) Author: Andrew Dalke (dalke) * (Python committer) Date: 2011-07-17 19:04
I confirm that under Python 2.7.2 while trying to build a 3rd-party package (from rdkit.org) I get the error Linking CXX shared library ../../lib/libRDBoost.dylib ld: warning: path '/usr/local/lib/libpython2.7.a' following -L not a directory Undefined symbols: "_environ", referenced from: _initposix in libpython2.7.a(posixmodule.o) (maybe you meant: cstring=ignore_environment) ld: symbol(s) not found collect2: ld returned 1 exit status My Python-2.7 was configured with "./configure" and is not a framework install. I applied the patch to my local 2.7 copy and the third party package builds without a problem.
msg141197 - (view) Author: Dan Colish (dcolish) Date: 2011-07-26 23:52
I can also confirm this patch is required to build py2cairo on OSX with Python2.7.2 when --enable-framework is not used.
msg179830 - (view) Author: Ronald Oussoren (ronaldoussoren) * (Python committer) Date: 2013-01-12 21:09
I appear to be running into this as well in py2app, with the current 2.7 tree and a --enable-shared build py2app's updates to the environment (with setenv from C code) won't be seen by Python, even though Python is initialized after the call to setenv. The patch doesn't work for me though: with the patch the build fails because os.environ no longer contains 'PATH'. I'm looking into this issue. The basic idea of the patch seems sane, both posixmodule.c and crt_externs.h mention that the call is needed for shared libraries.
msg179941 - (view) Author: Ronald Oussoren (ronaldoussoren) * (Python committer) Date: 2013-01-14 13:28
The patch didn't work for me because I manually applied and missed a bit. The patches fixes <https://bitbucket.org/ronaldoussoren/py2app/issue/81> for me, and the environ(7) manpage also indicates that the call to _NSEnvironment is needed in shared libraries. I've attached a slightly different version of the patch that only enabled the _NSGetEnvironment path for shared library builds (--enable-shared and --enable-framework) and doesn't change anything for the default static builds. Ned: I think this is a bugfix and should be merged into all active branches. Do you agree? If so, I'll apply the patch.
msg179965 - (view) Author: Ned Deily (ned.deily) * (Python committer) Date: 2013-01-14 18:28
Ronald: the patch?
msg179981 - (view) Author: Ned Deily (ned.deily) * (Python committer) Date: 2013-01-14 21:55
LGTM and I agree that it should be considered a bug fix.
msg180598 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2013-01-25 17:03
New changeset 864b9836dae6 by Ronald Oussoren in branch '2.7': Issue #1602133: 'environ' is not really available with shared libraries on OSX http://hg.python.org/cpython/rev/864b9836dae6 New changeset ea9fd9c9c677 by Ronald Oussoren in branch '3.2': Issue #1602133: 'environ' is not really available with shared libraries on OSX http://hg.python.org/cpython/rev/ea9fd9c9c677 New changeset 106d1d79c853 by Ronald Oussoren in branch '3.3': Issue #1602133: 'environ' is not really available with shared libraries on OSX (merge from 3.2) http://hg.python.org/cpython/rev/106d1d79c853 New changeset b41e3e2bd4cc by Ronald Oussoren in branch 'default': Issue #1602133: 'environ' is not really available with shared libraries on OSX (merge from 3.3) http://hg.python.org/cpython/rev/b41e3e2bd4cc
History
Date User Action Args
2022-04-11 14:56:21 admin set github: 44271
2013-01-25 17:04:15 ronaldoussoren set status: open -> closedtype: behaviorstage: commit review -> resolved
2013-01-25 17:03:21 python-dev set nosy: + python-devmessages: +
2013-01-14 21:55:42 ned.deily set messages: +
2013-01-14 18:29:22 ronaldoussoren set files: + 1602133.patch
2013-01-14 18:28:43 ned.deily set nosy: - BreamoreBoymessages: +
2013-01-14 13:28:36 ronaldoussoren set nosy: + ned.deilymessages: + versions: + Python 3.4
2013-01-12 21:09:37 ronaldoussoren set messages: +
2011-07-26 23:52:36 dcolish set nosy: + dcolishmessages: +
2011-07-19 13:01:45 eric.araujo set title: non-framework built python fails to define environ properly -> non-framework python fails to define os.environ properlystage: commit reviewversions: + Python 3.3, - Python 3.1
2011-07-17 19:04:43 dalke set nosy: + dalkemessages: +
2011-06-16 21:24:01 jjw set nosy: + jjwmessages: +
2010-08-25 15:01:43 ronaldoussoren set messages: +
2010-08-25 14:23:30 BreamoreBoy set versions: + Python 3.1, Python 2.7, Python 3.2nosy: + BreamoreBoymessages: + components: + Build
2009-04-19 10:45:22 ronaldoussoren set status: pending -> openresolution: works for me -> acceptedmessages: +
2009-01-02 13:21:23 ronaldoussoren set status: open -> pendingresolution: works for memessages: +
2008-05-02 22:22:55 ronaldoussoren set assignee: jackjansen -> ronaldoussorenmessages: + nosy: + ronaldoussoren
2006-11-24 07:38:32 ihavetopee create