Message168814
| Author |
trent |
| Recipients |
larry, trent |
| Date |
2012年08月21日.22:28:57 |
| SpamBayes Score |
-1.0 |
| Marked as misclassified |
Yes |
| Message-id |
<1345588137.71.0.308322500564.issue15748@psf.upfronthosting.co.za> |
| In-reply-to |
| Content |
Well, bugger me, check this out:
import os
import stat
import tempfile
d = tempfile.mkdtemp()
src = os.path.join(d, 'foo')
dst = os.path.join(d, 'bar')
src_link = os.path.join(d, 'baz')
dst_link = os.path.join(d, 'qux')
sf = open(dst, 'w')
sf.write('foo')
sf.flush()
sf.close()
df = open(dst, 'w')
df.write('bar')
df.flush()
df.close()
os.symlink(src, src_link)
os.symlink(dst, dst_link)
os.lchmod(src_link, stat.S_IRWXU | stat.S_IRWXO)
os.readlink(dst_link)
os.readlink(src_link)
Results of the last two calls:
>>> os.readlink(dst_link)
path 1: /tmp/tmpfz5v6h/qux, length 1: 18, buf 1: /tmp/tmpfz5v6h/bar
path 2: /tmp/tmpfz5v6h/qux, length 2: 18, buf 2: /tmp/tmpfz5v6h/bar
'/tmp/tmpfz5v6h/bar'
[73299 refs]
>>> os.readlink(src_link)
path 1: /tmp/tmpfz5v6h/baz, length 1: 24, buf 1: /tmp/tmpfz5v6h/foo
path 2: /tmp/tmpfz5v6h/baz, length 2: 24, buf 2: /tmp/tmpfz5v6h/foo
'/tmp/tmpfz5v6h/foo\x00\x00\x00\x00\x00\x00'
[73299 refs]
So, without the os.lchmod() call, the length is returned correctly. With it, it gets returned as 24. Looks like an OS bug. |
|
History
|
|---|
| Date |
User |
Action |
Args |
| 2012年08月21日 22:28:57 | trent | set | recipients:
+ trent, larry |
| 2012年08月21日 22:28:57 | trent | set | messageid: <1345588137.71.0.308322500564.issue15748@psf.upfronthosting.co.za> |
| 2012年08月21日 22:28:57 | trent | link | issue15748 messages |
| 2012年08月21日 22:28:57 | trent | create |
|