Issue2294
Created on 2015-03-19.12:41:22 by Arfrever, last changed 2019-07-21.05:55:16 by jeff.allen.
msg9676 (view) |
Author: Arfrever Frehtes Taifersar Arahesis (Arfrever) |
Date: 2015-03-19.12:41:22 |
|
$ mkdir /tmp/ćśź
$ touch /tmp/ćśź/{a,b}.py
$ cat test.py
# coding: utf-8
import sys
sys.path.append("/tmp/ćśź")
print("sys.path[-1]: %r" % sys.path[-1])
import a
print(a)
sys.path[-1] = u"/tmp/ćśź"
print("sys.path[-1]: %r" % sys.path[-1])
import b
print(b)
$ python2.7 test.py
sys.path[-1]: '/tmp/\xc4\x87\xc5\x9b\xc5\xba'
<module 'a' from '/tmp/ćśź/a.py'>
sys.path[-1]: u'/tmp/\u0107\u015b\u017a'
<module 'b' from '/tmp/ćśź/b.py'>
$ jython2.7 test.py
sys.path[-1]: '/tmp/\xc4\x87\xc5\x9b\xc5\xba'
Traceback (most recent call last):
File "test.py", line 5, in <module>
import a
ImportError: No module named a
|
msg11809 (view) |
Author: Jeff Allen (jeff.allen) |
Date: 2018-03-16.20:27:56 |
|
In Jython 2.7.2a1, this now works:
PS iss2294> jython test.py
sys.path[-1]: '\xc4\x87\xc5\x9b\xc5\xba'
<module 'a' from '膰艣藕\a.py'>
sys.path[-1]: u'\u0107\u015b\u017a'
<module 'b' from '膰艣藕\b.py'>
Or nearly works, apart from the encoding of the directory name for console output. See also #2295.
Interestingly, CPython 2.7.14 fails on my Windows machine:
PS iss2294> python test.py
sys.path[-1]: '\xc4\x87\xc5\x9b\xc5\xba'
Traceback (most recent call last):
File "test.py", line 8, in <module>
import a
ImportError: No module named a
This is because the first path actually consists of utf-8 bytes (source encoding) while the FS-encoding is ms936.
|
msg12480 (view) |
Author: Jeff Allen (jeff.allen) |
Date: 2019-05-02.05:50:47 |
|
Given the previous comment, I think this should not still be open.
|
|
Date |
User |
Action |
Args |
2019-07-21 05:55:16 | jeff.allen | set | status: pending -> closed |
2019-05-02 05:50:47 | jeff.allen | set | status: open -> pending resolution: fixed messages:
+ msg12480 |
2018-03-16 20:27:57 | jeff.allen | set | nosy:
+ jeff.allen messages:
+ msg11809 |
2015-03-19 12:41:22 | Arfrever | create | |
|