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.

Title: Path.read_bytes() failed when path contains chinese character
Type: behavior Stage: resolved
Components: IO Versions: Python 3.7
Status: closed Resolution: third party
Dependencies: Superseder:
Assigned To: Nosy List: meowmeowmeowcat, russiavk, steven.daprano, terry.reedy
Priority: normal Keywords:

Created on 2021-08-12 09:45 by russiavk, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Messages (8)
msg399435 - (view) Author: russiavk (russiavk) Date: 2021-08-12 09:45
Path.read_bytes() failed when this path contains chinese character
msg399436 - (view) Author: russiavk (russiavk) Date: 2021-08-12 09:49
It give me error :FileNotFoundError [errno 2] No such file or directory
msg399438 - (view) Author: Steven D'Aprano (steven.daprano) * (Python committer) Date: 2021-08-12 10:26
How did you enter the Chinese characters?

It works for me:

>>> filename = 'Beijing 北京市'
>>> with open(filename, 'w') as f:
...     f.write('data')
>>> from pathlib import Path
>>> p = Path(filename)
>>> p.read_bytes()

Please provide a *minimal reproducible example*
msg399439 - (view) Author: Steven D'Aprano (steven.daprano) * (Python committer) Date: 2021-08-12 10:27
Also, we need to know the version of Python and your OS.
msg399570 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2021-08-13 23:09
If there is no file or directory by the name you give, then the exception is correct and there is no bug in CPython.  A failing example should look like Steven's, with the filename in a string that is use to both create and access the file.
msg399585 - (view) Author: russiavk (russiavk) Date: 2021-08-14 08:02
Sorry.I found it only happen in pypy3
My os is win10 64,and pypy version is "PyPy 7.3.6-alpha0 with MSC v.1929 64 bit"

  File "C:\Program Files\pypy-c-jit-102746-9515a976b2ea-win64\lib-python\3\", line 1229, in read_bytes
    with'rb') as f:
  File "C:\Program Files\pypy-c-jit-102746-9515a976b2ea-win64\lib-python\3\", line 1223, in open
  File "C:\Program Files\pypy-c-jit-102746-9515a976b2ea-win64\lib-python\3\", line 1078, in _opener
    return, flags, mode)
FileNotFoundError: [Errno 2] No such file or directory: WindowsPath('D:/somepath contains chinese character')
msg399586 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2021-08-14 08:43
pypy is a separate group of people and tracker.  cpython 3.7 only gets security patches.
msg399587 - (view) Author: Steven D'Aprano (steven.daprano) * (Python committer) Date: 2021-08-14 09:47
You're still not giving a reproducible example. The PyPy people will be 
unable to resolve this unless you give them a reproducable example.

'D:/somepath contains chinese character' is not a path with Chinese 
characters in it. If you refuse to give enough information to debug the 
problem, all that anyone can do is close the issue. You are wasting your 
time, and our time, by giving false information in your bug reports, and 
if you do the same to PyPy, you will be wasting their time too.
Date User Action Args
2022-04-11 14:59:48adminsetgithub: 89061
2021-08-14 09:47:39steven.dapranosetmessages: + msg399587
2021-08-14 08:43:00terry.reedysetstatus: open -> closed
resolution: third party
messages: + msg399586

stage: resolved
2021-08-14 08:02:09russiavksetmessages: + msg399585
versions: + Python 3.7
2021-08-13 23:09:49terry.reedysetnosy: + terry.reedy
messages: + msg399570
2021-08-12 10:35:14meowmeowmeowcatsetnosy: + meowmeowmeowcat
2021-08-12 10:27:28steven.dapranosetmessages: + msg399439
2021-08-12 10:26:49steven.dapranosetnosy: + steven.daprano
messages: + msg399438
2021-08-12 09:49:39russiavksetmessages: + msg399436
2021-08-12 09:45:35russiavkcreate