This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: cannot lanch python.exe via symbolic link if HAVE_BROKEN_MBSTOWCS
Type: Stage:
Components: Interpreter Core Versions: Python 3.0
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: amaury.forgeotdarc, ocean-city
Priority: deferred blocker Keywords: patch

Created on 2008-09-09 08:39 by ocean-city, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
py3k_getpath_v1.patch ocean-city, 2008-09-09 08:39 _Py_wreadlink won't terminate buf with NULL
py3k_getpath_v2.patch ocean-city, 2008-09-09 08:42 _Py_wreadlink will terminate buf with NULL (standard _readlink won't)
py3k_getpath_v3.patch ocean-city, 2008-09-09 13:25 probably final patch
Messages (5)
msg72831 - (view) Author: Hirokazu Yamamoto (ocean-city) * (Python committer) Date: 2008-09-09 08:39
On cygwin, py3k aborts if lanches it via symbolic link.

//////////// message beg /////////////////////////

Could not find platform independent libraries <prefix>
Could not find platform dependent libraries <exec_prefix>
Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]
Fatal Python error: Py_Initialize: can't initialize sys standard streams
ImportError: No module named encodings.utf_8
Aborted (core dumped)

//////////// message end  /////////////////////////

This is because mbstowcs() on cygwin is broken, so _Py_wreadlink() in
Modules/getpath.c is also broken. I'll attach two patches to fix this. I
don't know which is better.
msg72852 - (view) Author: Amaury Forgeot d'Arc (amaury.forgeotdarc) * (Python committer) Date: 2008-09-09 12:28
http://man.he.net/man3/readlink says: "Conforming applications should
not assume that the returned contents of the symbolic link are
null-terminated"

cygwin is not broken, but very (too much?) conforming in this case ;-)

I think your second patch is the correct one, just keep the "return
(int)r1;" because the return value is stored in a "linklen" variable.
msg72854 - (view) Author: Hirokazu Yamamoto (ocean-city) * (Python committer) Date: 2008-09-09 13:25
Oh, I misunderstood the reason...
readlink() can return non-null-terminated string, so mbstowcs may
convert illegual memory area. I've attached py3k_getpath_v3.patch.
msg72857 - (view) Author: Amaury Forgeot d'Arc (amaury.forgeotdarc) * (Python committer) Date: 2008-09-09 13:39
Your patch is OK for me. Please apply!
msg72862 - (view) Author: Hirokazu Yamamoto (ocean-city) * (Python committer) Date: 2008-09-09 13:59
Thanks, fixed in r66338(py3k).
History
Date User Action Args
2022-04-11 14:56:38adminsetgithub: 48063
2008-09-09 13:59:08ocean-citysetstatus: open -> closed
resolution: accepted -> fixed
messages: + msg72862
2008-09-09 13:39:30amaury.forgeotdarcsetkeywords: - needs review
resolution: accepted
messages: + msg72857
2008-09-09 13:25:36ocean-citysetfiles: + py3k_getpath_v3.patch
messages: + msg72854
2008-09-09 12:38:35amaury.forgeotdarcsetpriority: deferred blocker
keywords: + needs review
2008-09-09 12:28:31amaury.forgeotdarcsetnosy: + amaury.forgeotdarc
messages: + msg72852
2008-09-09 08:42:33ocean-citysetfiles: + py3k_getpath_v2.patch
2008-09-09 08:39:04ocean-citycreate