[Python-bugs-list] [Bug #132493] UserString can not be used as string in calls to C routines

noreply@sourceforge.net noreply@sourceforge.net
Thu, 15 Feb 2001 07:28:38 -0800


Bug #132493, was updated on 2001-Feb-15 02:25
Here is a current snapshot of the bug.

Project: Python
Category: Python Library
Status: Closed
Resolution: Later
Bug Group: Feature Request
Priority: 5
Submitted by: hooft
Assigned to : gvanrossum
Summary: UserString can not be used as string in calls to C routines

Details: schol[53]:ccd>cat uss.py
import os,UserString

a=UserString.UserString('/etc/passwd')

print os.path.exists(a)
schol[54]:ccd>python uss.py
Traceback (most recent call last):
  File "uss.py", line 5, in ?
    print os.path.exists(a)
  File "/usr/local/nonius/lib/python2.0/posixpath.py", line 166, in
exists
    st = os.stat(path)
TypeError: stat, argument 1: expected string, instance found


Follow-Ups:

Date: 2001-Feb-15 07:28
By: hooft

Comment:
When I submitted the bug, I thought it was very difficult. But
I think there is a bit hackish way to solve it for the UserString.

PyArg_ParseTuple could check for UserString objects if 
a "s" variable is asked for, and return the .data attribute.

Sorry for even proposing it. I'll wait for 3000....
-------------------------------------------------------

Date: 2001-Feb-15 05:40
By: gvanrossum

Comment:
Alas, this is true.  The same holds for UserDict and UserList.

There is no easy fix.

Fixing this will be a major project, probably for Python 3000.

I'm adding a reminder to PEP 42, and closing the bug report.
-------------------------------------------------------

For detailed info, follow this link:
http://sourceforge.net/bugs/?func=detailbug&bug_id=132493&group_id=5470