Message168749
Looks like os.readlink() is busted:
> /home/trent/src/cpython/Lib/shutil.py(107)copyfile()
-> os.symlink(os.readlink(src), dst)
(Pdb) s
TypeError: embedded NUL character
> /home/trent/src/cpython/Lib/shutil.py(107)copyfile()
-> os.symlink(os.readlink(src), dst)
(Pdb) os.readlink(src)
'/tmp/tmpr3obfj/foo\x00\x00\x00\x00\x00\x00'
(Pdb) p src
'/tmp/tmpr3obfj/baz'
(Pdb) l
102 # XXX What about other special files? (sockets, devices...)
103 if stat.S_ISFIFO(st.st_mode):
104 raise SpecialFileError("`%s` is a named pipe" % fn)
105
106 if not follow_symlinks and os.path.islink(src):
107 -> os.symlink(os.readlink(src), dst)
108 else:
109 with open(src, 'rb') as fsrc:
110 with open(dst, 'wb') as fdst:
111 copyfileobj(fsrc, fdst)
112 return dst
> /home/trent/src/cpython/Lib/shutil.py(107)copyfile()
-> os.symlink(os.readlink(src), dst)
(Pdb) s
TypeError: embedded NUL character
> /home/trent/src/cpython/Lib/shutil.py(107)copyfile()
-> os.symlink(os.readlink(src), dst)
(Pdb) os.readlink(src)
'/tmp/tmpr3obfj/foo\x00\x00\x00\x00\x00\x00'
(Pdb) p src
'/tmp/tmpr3obfj/baz'
(Pdb) l
102 # XXX What about other special files? (sockets, devices...)
103 if stat.S_ISFIFO(st.st_mode):
104 raise SpecialFileError("`%s` is a named pipe" % fn)
105
106 if not follow_symlinks and os.path.islink(src):
107 -> os.symlink(os.readlink(src), dst)
108 else:
109 with open(src, 'rb') as fsrc:
110 with open(dst, 'wb') as fdst:
111 copyfileobj(fsrc, fdst)
112 return dst
i.e.:
(Pdb) os.readlink(src)
'/tmp/tmpr3obfj/foo\x00\x00\x00\x00\x00\x00'
Started another session with gdb, set a breakpoint at posix_readlink:
Breakpoint 1, posix_readlink (self=0x800909858, args=0x805ec2840, kwargs=0x0)
at ./Modules/posixmodule.c:7007
7007 int dir_fd = DEFAULT_DIR_FD;
(gdb) l
7002
7003 static PyObject *
7004 posix_readlink(PyObject *self, PyObject *args, PyObject *kwargs)
7005 {
7006 path_t path;
7007 int dir_fd = DEFAULT_DIR_FD;
7008 char buffer[MAXPATHLEN];
7009 ssize_t length;
7010 PyObject *return_value = NULL;
7011 static char *keywords[] = {"path", "dir_fd", NULL};
(gdb) n
7013 memset(&path, 0, sizeof(path));
(gdb)
7014 if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O&|$O&:readlink", keywords,
(gdb)
7024 Py_BEGIN_ALLOW_THREADS
(gdb)
7026 if (dir_fd != DEFAULT_DIR_FD)
(gdb) p path
$1 = {function_name = 0x0, argument_name = 0x0, nullable = 0, allow_fd = 0,
wide = 0x0, narrow = 0x805ec0f10 "/tmp/tmpko8vo_/baz", fd = -1, length = 18,
object = 0x805e30d60, cleanup = 0x805ec0ee0}
path.narrow and length are correct at that point.
(gdb) p dir_fd
$2 = -100
(gdb) n
7024 Py_BEGIN_ALLOW_THREADS
(gdb) n
7026 if (dir_fd != DEFAULT_DIR_FD)
(gdb) n
7030 length = readlink(path.narrow, buffer, sizeof(buffer));
(gdb) n
7031 Py_END_ALLOW_THREADS
(gdb) p length
$3 = 24
(gdb) p sizeof(buffer)
$7 = 1024
(gdb) p buffer
$9 = "/tmp/tmpko8vo_/foo\000\000\000\000\000\000ͤ\r\001\b\000\000\000\000\000\000\000??????A", '\0' <repeats 77 times>, "??\203\000\b\000\000\000?v???\177\000\000??A", '\0' <repeats 13 times>, "f\023J", '\0' <repeats 13 times>, "??A\000\000\000\000\000\001\000\000\000\000\000\000\000\030u???\177\000\000 u???\177\000\000RCJ\000\000\000\000\000\000\001\000\000\000\000\000\000??A\000\000\000\000\000?v???\177\000\000?(?\005\b\000\000\0000?L\002\b\000\000\000\210N?\005\b\000\000\000\001\000\000\000\000\000\000\000??A\000\000\000\000\000?"...
No idea why readlink is returning 24. Need to look into it more. |
|
Date |
User |
Action |
Args |
2012-08-21 07:28:57 | trent | set | recipients:
+ trent |
2012-08-21 07:28:56 | trent | set | messageid: <1345534136.96.0.164004654743.issue15748@psf.upfronthosting.co.za> |
2012-08-21 07:28:56 | trent | link | issue15748 messages |
2012-08-21 07:28:53 | trent | create | |
|