[Baypiggies] TypeError in os.path.realpath
Aahz
aahz at pythoncraft.com
Thu May 31 16:21:13 CEST 2012
On Wed, May 30, 2012, Lincoln Peters wrote:
>
> I'm developing a Python tool to monitor some of our Linux servers (running
> RHEL 5.6 and Python 2.4). In some cases, I need to track down the
> executable file for a running process, which I should be able to by
> resolving the symlink at /proc/<PID>/cmd. When I use the "readlink"
> command at the shell, it works correctly, but sometimes when I call
> os.path.realpath with the exact same path, I get a TypeError the following
> traceback (note: copied by hand since the servers have no Internet access):
>
> File "/usr/lib64/python2.4/posixpath.py", line 423, in realpath
> resolved = _resolve_link(component)
> File "/usr/lib64/python2.4/posixpath.py", line 440, in _resolve_link
> while islink(path):
> File "/usr/lib64/python2.4/posixpath.py", line 159, in islink
> st = os.lstat(path)
> TypeError: lstat() argument 1 must be (encoded string without NULL bytes),
> not str
How do you know it's the same path? Any chance you could be having
unicode issues?
--
Aahz (aahz at pythoncraft.com) <*> http://www.pythoncraft.com/
https://en.wikipedia.org/wiki/Mary_Anning
More information about the Baypiggies
mailing list