-
-
Notifications
You must be signed in to change notification settings - Fork 30k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Different behaviours with <class str> between v3.1.2 and v3.2.2 #57204
Comments
Hi, Trying this code: ------------------------------ # -- coding: utf-8 -- import os
import sys
import platform print('\nPython version: ', sys.version.split()[0]) paths = ['/home/vincent/image.jpg', '/home/vincent/àéèîö.jpg']
for path in paths:
print('\n', type(path))
try:
print(path)
except UnicodeEncodeError as why:
print('print > {0}'.format(why))
try:
if not os.path.exists(path):
print('File not found!')
else:
print('File exists')
except UnicodeEncodeError as why:
print('os.path.exist > {0}'.format(why))
try:
stats = os.stat(path)
print(stats.st_atime)
except UnicodeEncodeError as why:
print('os.stat > {0}'.format(why))
try:
f = open(path, 'b')
f.close()
except Exception as why:
print('open > {0}'.format(why)) on python 3.1.2: ------------------------------------ Python version: 3.1.2 <class 'str'> <class 'str'> ------------------------------------------------ on python 3.2.2: ------------------------------------------------ Python version: 3.2.2 ------------------------------------------------------------------- Any 'path = path.decode('utf-8')', 'encode(bhla)', 'sys.getfilesystemencoding()', 'magic_transform(abracadabra)' Thanks for yours advice. vince |
This is because how the filesystem encoding is determined has changed. You probably need to explicity discover how non-ascii characters like those in '/home/vincent/àéèîö.jpg' are encoded in your filesystem. |
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:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: