Message168749
| Author |
trent |
| Recipients |
trent |
| Date |
2012年08月21日.07:28:53 |
| SpamBayes Score |
-1.0 |
| Marked as misclassified |
Yes |
| Message-id |
<1345534136.96.0.164004654743.issue15748@psf.upfronthosting.co.za> |
| In-reply-to |
| Content |
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_/foo000円000円000円000円000円000円ͤ\r001円\b000円000円000円000円000円000円000円??????A", '0円' <repeats 77 times>, "??203円000円\b000円000円000円?v???177円000円000円??A", '0円' <repeats 13 times>, "f023円J", '0円' <repeats 13 times>, "??A000円000円000円000円000円001円000円000円000円000円000円000円000円030円u???177円000円000円 u???177円000円000円RCJ000円000円000円000円000円000円001円000円000円000円000円000円000円??A000円000円000円000円000円?v???177円000円000円?(?005円\b000円000円0000円?L002円\b000円000円000円210円N?005円\b000円000円000円001円000円000円000円000円000円000円000円??A000円000円000円000円000円?"...
No idea why readlink is returning 24. Need to look into it more. |
|
History
|
|---|
| 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 |
|