[New-bugs-announce] [issue3824] test_tarfile fails on cygwin (unicode decode error)

Hirokazu Yamamoto report at bugs.python.org
Tue Sep 9 22:42:09 CEST 2008

New submission from Hirokazu Yamamoto <ocean-city at m2.ccsnet.ne.jp>:

I noticed test_tarfile on py3k fails like this.

ERROR: test_directory_size (__main__.WriteTest)
Traceback (most recent call last):
  File "test_tarfile.py", line 598, in test_directory_size
    tarinfo = tar.gettarinfo(path)
  File "/home/WhiteRabbit/python-dev/py3k/Lib/tarfile.py", line 1869, in
    tarinfo.gname = grp.getgrgid(tarinfo.gid)[0]
UnicodeDecodeError: 'utf8' codec can't decode byte 0x82 in position 0:
d code byte


And I noticed PyUnicode_FromString supposes input as UTF-8, but actually
member of struct grp is MBCS or CP932 on cygwin.

After patched following workaround, test passed. I don't know how to fix
this... Does python have system encoding or something?
(I experienced similar error on test_grp and test_pwd)

Index: Modules/grpmodule.c
--- Modules/grpmodule.c	(revision 66345)
+++ Modules/grpmodule.c	(working copy)
@@ -32,6 +32,8 @@
 static int initialized;
 static PyTypeObject StructGrpType;
+#define PyUnicode_FromString(s) PyUnicode_DecodeMBCS(s, strlen(s),
 static PyObject *
 mkgrent(struct group *p)
@@ -83,6 +85,8 @@
     return v;
+#undef PyUnicode_FromString
 static PyObject *
 grp_getgrgid(PyObject *self, PyObject *pyo_id)

messages: 72907
nosy: ocean-city
severity: normal
status: open
title: test_tarfile fails on cygwin (unicode decode error)
versions: Python 3.0

Python tracker <report at bugs.python.org>

More information about the New-bugs-announce mailing list