[New-bugs-announce] [issue12995] Different behaviours with <class str> between v3.1.2 and v3.2.2
Vincent Vande Vyvre
report at bugs.python.org
Fri Sep 16 19:50:14 CEST 2011
New submission from Vincent Vande Vyvre <vincent.vandevyvre at swing.be>:
Hi,
Trying this code:
------------------------------
# -*- coding: utf-8 -*-
import os
import sys
import platform
print('\nPython version: ', sys.version.split()[0])
print(platform.platform())
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:
------------------------------------
vincent at tiemoko:~/Python/oqapy/devel$ python3 test_string.py
Python version: 3.1.2
Linux-2.6.32-33-generic-i686-with-Ubuntu-10.04-lucid
<class 'str'>
/home/vincent/image.jpg
File exists
1316179838.94
open > Must have exactly one of read/write/append mode
<class 'str'>
/home/vincent/àéèîö.jpg
File exists
1316179838.81
open > Must have exactly one of read/write/append mode
vincent at tiemoko:~/Python/oqapy/devel$
------------------------------------------------
on python 3.2.2:
------------------------------------------------
[vincent at myhost ~]$ python test_string.py
Python version: 3.2.2
Linux-3.0-ARCH-x86_64-Pentium-R-_Dual-Core_CPU_T4500_ at _2.30GHz-with-glibc2.2.5
<class 'str'>
/home/vincent/image.jpg
File exists
1316187109.6772401
open > Must have exactly one of read/write/append mode and at most one plus
<class 'str'>
print > 'ascii' codec can't encode characters in position 14-18: ordinal not in range(128)
os.path.exist > 'ascii' codec can't encode characters in position 14-18: ordinal not in range(128)
os.stat > 'ascii' codec can't encode characters in position 14-18: ordinal not in range(128)
open > 'ascii' codec can't encode characters in position 14-18: ordinal not in range(128)
[vincent at myhost ~]$
-------------------------------------------------------------------
Any 'path = path.decode('utf-8')', 'encode(bhla)', 'sys.getfilesystemencoding()', 'magic_transform(abracadabra)'
don't change anythings.
Thanks for yours advice.
vince
----------
components: Unicode
messages: 144143
nosy: VinsS
priority: normal
severity: normal
status: open
title: Different behaviours with <class str> between v3.1.2 and v3.2.2
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue12995>
_______________________________________
More information about the New-bugs-announce
mailing list