[pypy-issue] Issue #1920: grp.getgrnam() incorrectly throws a TypeError when given a unicode string (pypy/pypy)

Andrew Dunham issues-reply at bitbucket.org
Mon Nov 3 03:46:12 CET 2014


New issue 1920: grp.getgrnam() incorrectly throws a TypeError when given a unicode string
https://bitbucket.org/pypy/pypy/issue/1920/grpgetgrnam-incorrectly-throws-a-typeerror

Andrew Dunham:

As the title says :-)  I tried this on CPython 2.7.8, and the behaviour is not present:


```
Python 2.7.8 (default, Sep 24 2014, 18:26:21) 
[GCC 4.9.1 20140903 (prerelease)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import grp
>>> grp.getgrnam('root')
grp.struct_group(gr_name='root', gr_passwd='x', gr_gid=0, gr_mem=['root'])
>>> grp.getgrnam(u'root')
grp.struct_group(gr_name='root', gr_passwd='x', gr_gid=0, gr_mem=['root'])
```

Behaviour on PyPy 2.4.0:

```
Python 2.7.8 (c6ad44ecf5d8, Oct 16 2014, 02:14:27)
[PyPy 2.4.0 with GCC 4.9.1 20140903 (prerelease)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import grp
>>> grp.getgrnam('root')
(gr_name='root', gr_passwd='x', gr_gid=0, gr_mem=['root'])
>>> grp.getgrnam(u'root')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/opt/pypy/lib_pypy/grp.py", line 70, in getgrnam
    raise TypeError("expected string")
TypeError: expected string
```

Among other things, this breaks using [Ansible](http://www.ansible.com/home) with PyPy.




More information about the pypy-issue mailing list