This issue tracker has been migrated to GitHub ,
and is currently read-only.
For more information,
see the GitHub FAQs in the Python's Developer Guide.
Created on 2001年02月15日 10:25 by hooft, last changed 2022年04月10日 16:03 by admin. This issue is now closed.
| Messages (4) | |||
|---|---|---|---|
| msg3371 - (view) | Author: Rob W.W. Hooft (hooft) | Date: 2001年02月15日 10:25 | |
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
|
|||
| msg3372 - (view) | Author: Guido van Rossum (gvanrossum) * (Python committer) | Date: 2001年02月15日 13:40 | |
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. |
|||
| msg3373 - (view) | Author: Rob W.W. Hooft (hooft) | Date: 2001年02月15日 15:28 | |
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.... |
|||
| msg162840 - (view) | Author: Sam Whitehead (Sam.W) | Date: 2012年06月15日 03:02 | |
This still seems to be the case in 3.2.
Python 3.2.3 (default, Apr 23 2012, 23:35:30)
[GCC 4.7.0 20120414 (prerelease)] on linux2
>>> from collections import UserString
>>> a = UserString("foooooop")
>>> import os.path
>>> os.path.exists(a)
Traceback (most recent call last):
File "<input>", line 1, in <module>
File "/usr/lib/python3.2/genericpath.py", line 18, in exists
os.stat(path)
TypeError: Can't convert 'UserString' object to str implicitly
|
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022年04月10日 16:03:45 | admin | set | github: 33931 |
| 2014年08月13日 06:47:14 | serhiy.storchaka | link | issue16773 superseder |
| 2012年06月15日 03:02:52 | Sam.W | set | nosy:
+ Sam.W messages: + msg162840 |
| 2001年02月15日 10:25:29 | hooft | create | |