#205: When copying files, don’t copy full stat info, only modification times.

41 views
Skip to first unread message

Justin Rosen

unread,
Oct 28, 2009, 10:06:54 PM10/28/09
to sphin...@googlegroups.com
Was this bug actually fixed?  I was originally getting this error with 0.6.2

Exception occurred:
  File "/data/app/cent5_x86_64/Python/2.5.2/python/lib/python2.5/shutil.py", line 67, in copystat
    os.utime(dst, (st.st_atime, st.st_mtime))
OSError: [Errno 1] Operation not permitted: '/data/studio/tool/docs/sphinx/html/_sources/index.txt'
The full traceback has been saved in /tmp/sphinx-err-H49Cbk.log, if you want to report the issue to the author.
Please also report this if it was a user error, so that a better error message can be provided next time.
Send reports to sphin...@googlegroups.com. Thanks!

Contents of /tmp/sphinx-err-H49Cbk.log
Traceback (most recent call last):
  File "/data/app/python/cent5_x86_64/site-packages/Sphinx-Package/sphinx/cmdline.py", line 172, in main
    app.build(all_files, filenames)
  File "/data/app/python/cent5_x86_64/site-packages/Sphinx-Package/sphinx/application.py", line 126, in build
    self.builder.build_all()
  File "/data/app/python/cent5_x86_64/site-packages/Sphinx-Package/sphinx/builders/__init__.py", line 228, in build_all
    self.build(None, summary='all source files', method='all')
  File "/data/app/python/cent5_x86_64/site-packages/Sphinx-Package/sphinx/builders/__init__.py", line 320, in build
    self.write(docnames, list(updated_docnames), method)
  File "/data/app/python/cent5_x86_64/site-packages/Sphinx-Package/sphinx/builders/__init__.py", line 359, in write
    self.write_doc(docname, doctree)
  File "/data/app/python/cent5_x86_64/site-packages/Sphinx-Package/sphinx/builders/html.py", line 350, in write_doc
    self.handle_page(docname, ctx, event_arg=doctree)
  File "/data/app/python/cent5_x86_64/site-packages/Sphinx-Package/sphinx/builders/html.py", line 673, in handle_page
    copyfile(self.env.doc2path(pagename), source_name)
  File "/data/app/python/cent5_x86_64/site-packages/Sphinx-Package/sphinx/util/__init__.py", line 399, in copyfile
    try: shutil.copystat(source, dest)
  File "/data/app/cent5_x86_64/Python/2.5.2/python/lib/python2.5/shutil.py", line 67, in copystat
    os.utime(dst, (st.st_atime, st.st_mtime))
OSError: [Errno 1] Operation not permitted: '/data/studio/tool/docs/sphinx/html/_sources/index.txt'

I then found that this was a potential bug and updated to 0.6.3 but got the same error

Exception occurred:
  File "/data/app/python/cent5_x86_64/site-packages/Sphinx-Package/0.6.3/sphinx/util/__init__.py", line 408, in copytimes
    os.utime(dest, (st.st_atime, st.st_mtime))
OSError: [Errno 1] Operation not permitted: '/data/studio/tool/docs/sphinx/html/_sources/index.txt'
The full traceback has been saved in /tmp/sphinx-err-On8RAa.log, if you want to report the issue to the author.

Contents of /tmp/sphinx-err-On8RAa.log
# Sphinx version: 0.6.3
# Docutils version: 0.5 release
Traceback (most recent call last):
  File "/data/app/python/cent5_x86_64/site-packages/Sphinx-Package/0.6.3/sphinx/cmdline.py", line 172, in main
    app.build(all_files, filenames)
  File "/data/app/python/cent5_x86_64/site-packages/Sphinx-Package/0.6.3/sphinx/application.py", line 130, in build
    self.builder.build_update()
  File "/data/app/python/cent5_x86_64/site-packages/Sphinx-Package/0.6.3/sphinx/builders/__init__.py", line 265, in build_update
    'out of date' % len(to_build))
  File "/data/app/python/cent5_x86_64/site-packages/Sphinx-Package/0.6.3/sphinx/builders/__init__.py", line 320, in build
    self.write(docnames, list(updated_docnames), method)
  File "/data/app/python/cent5_x86_64/site-packages/Sphinx-Package/0.6.3/sphinx/builders/__init__.py", line 359, in write
    self.write_doc(docname, doctree)
  File "/data/app/python/cent5_x86_64/site-packages/Sphinx-Package/0.6.3/sphinx/builders/html.py", line 350, in write_doc
    self.handle_page(docname, ctx, event_arg=doctree)
  File "/data/app/python/cent5_x86_64/site-packages/Sphinx-Package/0.6.3/sphinx/builders/html.py", line 673, in handle_page
    copyfile(self.env.doc2path(pagename), source_name)
  File "/data/app/python/cent5_x86_64/site-packages/Sphinx-Package/0.6.3/sphinx/util/__init__.py", line 416, in copyfile
    copytimes(source, dest)
  File "/data/app/python/cent5_x86_64/site-packages/Sphinx-Package/0.6.3/sphinx/util/__init__.py", line 408, in copytimes
    os.utime(dest, (st.st_atime, st.st_mtime))
OSError: [Errno 1] Operation not permitted: '/data/studio/tool/docs/sphinx/html/_sources/index.txt'

Looking at the code /data/app/python/cent5_x86_64/site-packages/Sphinx-Package/0.6.3/sphinx/util/__init__.py

def copyfile(source, dest):
    """Copy a file and its modification times, if possible."""
    shutil.copyfile(source, dest)
    try:
        # don't do full copystat because the source may be read-only
        copytimes(source, dest)
    except shutil.Error:
        pass

There's a try/except on copytimes where it's catching shutil.Error.  But, copytimes doesn't use shutil, it uses os.utime!  When this fails it raises an OSError.  I've changed the try/except and everything seems to work now.

def copyfile(source, dest):
    """Copy a file and its modification times, if possible."""
    shutil.copyfile(source, dest)
    try:
        # don't do full copystat because the source may be read-only
        copytimes(source, dest)
    except OSError:
        pass

Will this cause any issues I may not be aware of due to the fact that certain files modification times aren't being updated?

Cheers,
Justin

Georg Brandl

unread,
Nov 8, 2009, 10:22:11 AM11/8/09
to sphin...@googlegroups.com
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Justin Rosen schrieb:


> Was this bug actually fixed? I was originally getting this error with 0.6.2
>
> Exception occurred:
> File
> "/data/app/cent5_x86_64/Python/2.5.2/python/lib/python2.5/shutil.py",
> line 67, in copystat
> os.utime(dst, (st.st_atime, st.st_mtime))
> OSError: [Errno 1] Operation not permitted:
> '/data/studio/tool/docs/sphinx/html/_sources/index.txt'
> The full traceback has been saved in /tmp/sphinx-err-H49Cbk.log, if you
> want to report the issue to the author.
> Please also report this if it was a user error, so that a better error
> message can be provided next time.
> Send reports to sphin...@googlegroups.com

> <mailto:sphin...@googlegroups.com>. Thanks!

Since the original intent was catching errors from copytimes(), I don't
think there's any problem with the change; I've now committed it to
the 0.6 branch and trunk.

Thanks,
Georg

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.11 (GNU/Linux)

iEYEARECAAYFAkr24iMACgkQN9GcIYhpnLCQbACgjnJ3IruYYAp8qd93eTANwUcz
nqIAn1KFaL30GEla6DqBIIu0y+qbnXdh
=3b4+
-----END PGP SIGNATURE-----

Reply all
Reply to author
Forward
0 new messages