You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Smelly exports (global symbols in python not prefixed with Py or _Py) #48805
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
assignee='https://github.com/davidmalcolm'closed_at=<Date2013-10-12.21:08:22.424>created_at=<Date2008-12-06.01:29:10.017>labels= ['interpreter-core', 'performance']
title='Smelly exports (global symbols in python not prefixed with Py or _Py)'updated_at=<Date2013-10-12.21:08:22.423>user='https://github.com/tiran'
I just suggest that somebody should look into it. I neither know how
critical the issue is nor how to change them. This bug report serves as
a reminder.
For Python 2.x you cannot change the "main" function name of C
extensions, since this is used by the Python import mechanism.
loewis commented on Dec 8, 2008
loewismannequin
Mannequin
More actions
I guess you *could* change the name of extensions that become builtin
modules. However, I think it is not worth the trouble, especially since PEP-3121 solves the problem for good, for Python 3.
I propose to simply filter out init[_a-z]+ from the set of "bad" symbols.
That leaves us with asdl_*seq_new, and _add_one_to_index; the latter
is already reported as bpo-3101.
loewis commented on Dec 10, 2008
loewismannequin
Mannequin
More actions
There is no proposed patch yet, so removing 2.5.3 from the target versions.
I propose to simply filter out init[_a-z]+ from the set of "bad"
symbols.
I'm attaching a patch (to trunk) to Makefile.pre.in which filters out such symbols.
Relevant part of output of "make smelly" on my svn build with this patch:
nm -p libpython2.7.a | \
sed -n "/ [TDB] /s/.* //p" | grep -v "^_*Py" | \
grep -v -E "^init[_a-z]+" | sort -u; \
Patch to py3k which adds the "_Py" prefix to the four listed symbols.
With this, the output from "make smelly" is clean (odorless, perhaps?).
However, adding _Py does seem to go against this comment in Include/asdl.h:
/* It would be nice if the code generated by asdl_c.py was completely
independent of Python, but it is a goal the requires too much work
at this stage. So, for example, I'll represent identifiers as
interned Python strings.
*/
For Python 3.3 and 3.4 make smelly still lists two exported symbols.
asdl_int_seq_new
asdl_seq_new
Do we have to check the modules, too? Some of them like _ctypes and _decimal export a lot of symbols. Here is a small shell snippet for Makefile.
for MOD in find $(srcdir)/build -name '*.s[ol]' ; do
EXPORT=nm -p $$MOD | sed -n "/ [TDB] /s/.* //p" | \ grep -E -v "^_*Py|^_init|^_fini" | sort -u;
if [ -n "$$EXPORT" ]; then
echo $$MOD;
echo $$EXPORT;
fi
done
loewis commented on Nov 27, 2012
loewismannequin
Mannequin
More actions
I'd like to focus this issue; it has been open long enough, and deserves to get closed once the original issue is resolved - which was that "make smelly" reports symbols. I think dmalcolm's patch is quite a good start for that.
It may well be that other modules need to be considered - but PLEASE not in this issue. For Unix with shared libraries, the extension modules certainly cause problems, in particular if Python gets embedded in a context (e.g. Apache) that also loads separate copies of the same libraries, and may cause problems if one of our functions collide with some library. However, I see *two* issues falling out of this: one to extend the "make smelly" target to include extension modules, and the other to then fix the extension modules - preferably with one issue per extension module.
Activity
tiran commentedon Dec 6, 2008
I just found about the smelly build target. It checks for smelly exports.
asdl_int_seq_new
asdl_seq_new
init_ast
init_codecs
initerrno
initgc
initimp
initposix
initpwd
initsignal
init_sre
init_symtable
initthread
initxxsubtype
initzipimport
nm -p libpython3.0.a | \
sed -n "/ [TDB] /s/.* //p" | grep -v "^_*Py" | sort -u; \
_add_one_to_index_C
_add_one_to_index_F
asdl_int_seq_new
asdl_seq_new
These should be checked and fixed.
loewis commentedon Dec 6, 2008
Are you suggesting that the init* functions in Python 2.6 should not
longer be exported? Why? And how?
tiran commentedon Dec 6, 2008
I just suggest that somebody should look into it. I neither know how
critical the issue is nor how to change them. This bug report serves as
a reminder.
malemburg commentedon Dec 8, 2008
For Python 2.x you cannot change the "main" function name of C
extensions, since this is used by the Python import mechanism.
loewis commentedon Dec 8, 2008
I guess you *could* change the name of extensions that become builtin
modules. However, I think it is not worth the trouble, especially since
PEP-3121 solves the problem for good, for Python 3.
I propose to simply filter out init[_a-z]+ from the set of "bad" symbols.
That leaves us with asdl_*seq_new, and _add_one_to_index; the latter
is already reported as bpo-3101.
loewis commentedon Dec 10, 2008
There is no proposed patch yet, so removing 2.5.3 from the target versions.
pitrou commentedon Mar 29, 2009
bpo-5591 is a duplicate of this.
pitrou commentedon Oct 9, 2009
In trunk:
_add_one_to_index_C
_add_one_to_index_F
asdl_int_seq_new
asdl_seq_new
init_ast
init_codecs
initerrno
initgc
initimp
initposix
initpwd
initsignal
init_sre
init_symtable
initthread
initxxsubtype
initzipimport
In py3k:
_add_one_to_index_C
_add_one_to_index_F
asdl_int_seq_new
asdl_seq_new
davidmalcolm commentedon Jan 13, 2010
Re: msg bpo-77350:
I'm attaching a patch (to trunk) to Makefile.pre.in which filters out such symbols.
Relevant part of output of "make smelly" on my svn build with this patch:
nm -p libpython2.7.a | \
sed -n "/ [TDB] /s/.* //p" | grep -v "^_*Py" | \
grep -v -E "^init[_a-z]+" | sort -u; \
_add_one_to_index_C
_add_one_to_index_F
asdl_int_seq_new
asdl_seq_new
davidmalcolm commentedon Jul 20, 2010
py3k is much cleaner than python 2, due to the change in the module API.
Here's "make smelly"'s output on a recent py3k checkout:
nm -p libpython3.2.a | \
sed -n "/ [TDB] /s/.* //p" | grep -v "^_*Py" | sort -u; \
_add_one_to_index_C
_add_one_to_index_F
asdl_int_seq_new
asdl_seq_new
[-]Smelly exports[/-][+]Smelly exports (global symbols in python not prefixed with Py or _Py)[/+]davidmalcolm commentedon Jul 20, 2010
Patch to py3k which adds the "_Py" prefix to the four listed symbols.
With this, the output from "make smelly" is clean (odorless, perhaps?).
However, adding _Py does seem to go against this comment in Include/asdl.h:
/* It would be nice if the code generated by asdl_c.py was completely
independent of Python, but it is a goal the requires too much work
at this stage. So, for example, I'll represent identifiers as
interned Python strings.
*/
tiran commentedon Nov 26, 2012
For Python 3.3 and 3.4 make smelly still lists two exported symbols.
asdl_int_seq_new
asdl_seq_new
Do we have to check the modules, too? Some of them like _ctypes and _decimal export a lot of symbols. Here is a small shell snippet for Makefile.
for MOD in
find $(srcdir)/build -name '*.s[ol]'; doEXPORT=
nm -p $$MOD | sed -n "/ [TDB] /s/.* //p" | \ grep -E -v "^_*Py|^_init|^_fini" | sort -u;if [ -n "$$EXPORT" ]; then
echo $$MOD;
echo $$EXPORT;
fi
done
loewis commentedon Nov 27, 2012
I'd like to focus this issue; it has been open long enough, and deserves to get closed once the original issue is resolved - which was that "make smelly" reports symbols. I think dmalcolm's patch is quite a good start for that.
It may well be that other modules need to be considered - but PLEASE not in this issue. For Unix with shared libraries, the extension modules certainly cause problems, in particular if Python gets embedded in a context (e.g. Apache) that also loads separate copies of the same libraries, and may cause problems if one of our functions collide with some library. However, I see *two* issues falling out of this: one to extend the "make smelly" target to include extension modules, and the other to then fix the extension modules - preferably with one issue per extension module.
pitrou commentedon Dec 15, 2012
This very simple patch should certainly be applied.
python-dev commentedon Oct 12, 2013
New changeset 142c62a490ce by Antoine Pitrou in branch 'default':
Issue bpo-4555: All exported C symbols are now prefixed with either "Py" or "_Py".
http://hg.python.org/cpython/rev/142c62a490ce