Valentín valentin.depa...@gmail.com added the comment:
I think this one is solved now. I recommend just to put as solved and kill it
from the list ;)
--
nosy: +Val
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue1545
Changes by Benjamin Peterson benja...@python.org:
--
resolution: - fixed
status: open - closed
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue1545
___
Raghuram Devarakonda [EMAIL PROTECTED] added the comment:
WindowsError issue is now fixed in r65644.
___
Python tracker [EMAIL PROTECTED]
http://bugs.python.org/issue1545
___
___
Raghuram Devarakonda [EMAIL PROTECTED] added the comment:
I have submitted a patch (http://codereview.appspot.com/2384) for
WindowsError issue as it is reported in two other bugs #3134 and #2549.
I have only tested on Linux so I would appreciate if some one who have
access to windows can test it
Raghuram Devarakonda added the comment:
There is a mistake in the patch. The line if WindowsError is not None
and isinstance(err, WindowsError): in copytree() should use the name
'why' and not 'err'. Unfortunately I can't test on windows, but you
didn't get NameError when you tested copytree()
ianaré added the comment:
OK I see that now. For what it's worth, I tested the code on win2000,
XP, and ubuntu using the shutil.move command on files and folders (so
that it uses either copy2 or copytree). Apart from the original bug in
ubuntu (copy from ext3 to ntfs-3g) it is fine.
I've made
ianaré added the comment:
sorry, should have clarified, I tested with this code:
copy2
try:
copystat(src, dst)
except OSError, err:
if WindowsError is not None and isinstance(err, WindowsError):
pass
else:
raise
copytree
try:
copystat(src, dst)
except OSError,
Raghuram Devarakonda added the comment:
The change looks fine as per yesterday's discussion. Can you submit
the actual patch? it needs to include check for WindowsError name.
BTW, I would put a comment when the exception is being ignored on
windows.
__
Tracker
ianaré added the comment:
Sorry about that. Here is the output from $ svn diff
I've also made modifications to allow to ignore the permission errors
(defaults to no) - should I post here or file new report?
Added file: http://bugs.python.org/file8876/shutil.diff
Christian Heimes added the comment:
Better patch:
import errno
try:
copystat(src, dst)
except OSError, err:
# can't change stats on NTFS partition even if
# OS supports it
if err.errno != errno.EPERM:
raise
--
keywords: +patch
nosy: +tiran
priority: - normal
Facundo Batista added the comment:
But is ok to hide the problem?
I mean, there *is* an error: the operation is not permitted (even if
it's not Python fault), so why to not have the exception?
--
nosy: +facundobatista
__
Tracker [EMAIL PROTECTED]
Raghuram Devarakonda added the comment:
I agree with Facundo that it is not good to hide the error. It should be
up to the caller to ignore the error.
--
nosy: +draghuram
__
Tracker [EMAIL PROTECTED]
http://bugs.python.org/issue1545
Amaury Forgeot d'Arc added the comment:
This reminds me of an option in os.walk:
By default errors from the os.listdir() call are ignored. If optional
argument onerror is specified, it should be a function; it will be
called with one argument, an OSError instance. It can report the error
to
Facundo Batista added the comment:
os.walk has an error handling mechanism because it goes through a
collection of files, so it's nice to have, for example, a function
applied if errors appear in some of those files.
As this operation is applicable only to one file, this is not useful at
all:
ianaré added the comment:
I agree, the best would be to have the option of ignoring errors.
However, I think there should be a way to differentiate between errors
that prevent a file from being copied, and one that only affects
permissions.
__
Tracker [EMAIL
ianaré added the comment:
I must respectfully disagree. This bug also occurs during the copytree
command, so it can apply to more than one file. And if using from move
then the original file never gets deleted.
As far as working around it, it is obviously doable, however this
requires
Facundo Batista added the comment:
I'm -1 to the library ignore errors without specific indication from the
user, specially when it's so easy to do it in the calling code.
We agree that copytree could grow an option like the one in os.walk.
Feel free to open an issue for it (this discussion
Guido van Rossum added the comment:
There's already an except clause for copystat() that ignores
WindowsError in copytree(). If copying this same code into copy2() makes
the OP happy I think we can place a similar except clause around the
copystat() call in copy2().
--
nosy: +gvanrossum
ianaré added the comment:
The problem with WindowsError is that it is not included in Linux. So if
there is an exception, it fails without showing the actual error. See
here (ubuntu 7.10 default install):
try: print a
... except WindowsError:
... print 'b'
...
Traceback (most recent call
Guido van Rossum added the comment:
Hm, that means there's a bug in the existing copytree() code too!
Can you check whether WindowsError derives from OSError? If it does,
your proposal won't fly.
--
resolution: rejected -
status: closed - open
__
ianaré added the comment:
Yes, it is a sub-class of OSError. So then only catching OSError should
be sufficient? Or am I missing something?
__
Tracker [EMAIL PROTECTED]
http://bugs.python.org/issue1545
__
Guido van Rossum added the comment:
Not quite, because we only want to ignore WindowsError.
Maybe this would work?
try:
WindowsError
except NameError:
WindowsError = None
try:
except os.error, err:
if WindowsError is not None or not isinstance(err, WindowsError):
raise #
Raghuram Devarakonda added the comment:
try:
except os.error, err:
if WindowsError is not None or not isinstance(err, WindowsError):
raise # Pretend we didn't catch it
pass # Ignore it
All the double negations are hurting when I try to understand above
conditions. How
Guido van Rossum added the comment:
You're right, my code was wrong. Yours will be be correct if you add
else: in front of the raise. I also still prefer WindowsError is
not None over just WindowsError.
On Dec 3, 2007 2:25 PM, Raghuram Devarakonda [EMAIL PROTECTED] wrote:
Raghuram Devarakonda
Raghuram Devarakonda added the comment:
You're right, my code was wrong. Yours will be be correct if you add
else: in front of the raise. I also still prefer WindowsError is
Yeah. I was just about to correct my code when I saw your response. I
should not post just before leaving work for home
ianaré added the comment:
Rather than try in copytree and try again in copy2, why not add this to
the root of the issue - copystat. Something like this?
def copystat(src, dst, ignore_permission_err=False):
Copy all stat info (mode bits, atime and mtime) from src to dst
st =
Guido van Rossum added the comment:
Look at the except clause in copytree(); it does a bit more,
collecting the errors and raising them later.
__
Tracker [EMAIL PROTECTED]
http://bugs.python.org/issue1545
__
New submission from ianaré:
When using shutil.copy2 or copytree where the source is on a filesystem
that has octal permissions (ie ext3) and the destination is on an NTFS
partition mounted rw, the operation fails with
OSError: [Errno 1] Operation not permitted
I am attaching a version of
28 matches
Mail list logo