[issue18695] os.statvfs() not working well with unicode paths

Giampaolo Rodola' report at bugs.python.org
Fri Aug 9 14:06:43 CEST 2013


New submission from Giampaolo Rodola':

From: https://code.google.com/p/psutil/issues/detail?id=416


# -*- coding: utf-8 -*-
from __future__ import unicode_literals
import os, errno
name = "ƒőő"
try:
    os.mkdir(name)
except OSError as err:
    if err.errno != errno.EEXIST:
        raise
os.statvfs(name)


The script above works fine on Python 3.3 but on 2.7 you'll get:

Traceback (most recent call last):
  File "foo.py", line 10, in <module>
    os.statvfs(name)
UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-2: ordinal not in range(128)

Patch in attachment fixes the issue.

----------
components: Unicode
files: statvfs.patch
keywords: needs review, patch
messages: 194726
nosy: ezio.melotti, giampaolo.rodola
priority: normal
severity: normal
status: open
title: os.statvfs() not working well with unicode paths
versions: Python 2.7
Added file: http://bugs.python.org/file31207/statvfs.patch

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue18695>
_______________________________________


More information about the Python-bugs-list mailing list