[issue12995] Different behaviours with class str between v3.1.2 and v3.2.2

2011-09-16 Thread Vincent Vande Vyvre

New submission from Vincent Vande Vyvre vincent.vandevy...@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@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@tiemoko:~/Python/oqapy/devel$ 



on python 3.2.2:


[vincent@myhost ~]$ python test_string.py

Python version:  3.2.2
Linux-3.0-ARCH-x86_64-Pentium-R-_Dual-Core_CPU_T4500_@_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@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 rep...@bugs.python.org
http://bugs.python.org/issue12995
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue12995] Different behaviours with class str between v3.1.2 and v3.2.2

2011-09-16 Thread Benjamin Peterson

Benjamin Peterson benja...@python.org added the comment:

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.

--
nosy: +benjamin.peterson
resolution:  - invalid
status: open - closed

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue12995
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com