Closed atticus-lv closed 3 years ago
Can I have your image path? I tried some unicode filenames but still can't reproduce on my end.
By the way it's an unexpected behavior so I think it should be a bug.
You can try to rename the image as 测试图像.jpg
I think it may cause to the encoding of the system.
I am using windows with the Simple Chinese language. Its coding is GBK.
import locale
locale.getdefaultlocale()
# return ('zh_CN', 'cp936')
I think the issue might related to the locale as you pointed out.
The error IndexError: list index out of range
from subprocess
module is very vague due to this Python issue. As we can see, the stdout
and stderr
could be empty during a timeout on Windows and then cause the error. So we should redirect towards the PowerShell scripts.
Could you help me collect the outputs from this PowerShell script (PowerShell 5.1 in C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
), running after copying an image, both in Chinese name and in another ASCII normalized name:
$files = Get-Clipboard -Format FileDropList
if ($files) { $files.fullname }
it show the correct path of the image:
PS C:\Windows\System32\WindowsPowerShell\v1.0> $files = Get-Clipboard -Format FIleDropList
PS C:\Windows\System32\WindowsPowerShell\v1.0> if($files) { $files.fullname}
C:\Users\atticus\Desktop\啊啊.png
PS C:\Windows\System32\WindowsPowerShell\v1.0> $files = Get-Clipboard -Format FIleDropList
PS C:\Windows\System32\WindowsPowerShell\v1.0> if($files) { $files.fullname}
C:\Users\atticus\Desktop\aaa.png
The output looks fine. I think the encoding is unlikely to be an issue since utf-8
has already been passed to subprocess
.
I suppose I have to go back and try to reproduce it first. I'll update you if I find something. Thank you for your support.
Fix! After clone reading the code(I want to use it to import models, too), I find out that it is due to the coding system. Just get the coding of the shell then use it to encode the scripts
Oh, it turns out that we should use the system encoding instead of forcing it to utf-8
. I'm having a look to the PR now.
Problem
when I copy a local image with Chinese name, it shows this error
Solution
Not yet
Screenshot/Screencast
Additional context