Christian Heimes added the comment:
Please open an interactive interpreter shell and show us the output of
import shutil
print shutil.__file__
print dir(shutil)
--
nosy: +christian.heimes
___
Python tracker rep...@bugs.python.org
Saurabh Gupta added the comment:
import shutil
shutil.__file__
'C:\\Python26\\lib\\shutil.pyc'
dir(shutil)
['Error', '__all__', '__builtins__', '__doc__', '__file__', '__name__',
'__package__', '_basename', '_samefile', 'abspath', 'copy', 'copy2',
'copyfile', 'copyfileobj', 'copymode',
Saurabh Gupta added the comment:
And, the same thing on linux:
import shutil
print shutil.__file__
/software/package/linux64_centos6/python/2.6.7/lib/python2.6/shutil.pyc
print dir(shutil)
['Error', 'WindowsError', '__all__', '__builtins__', '__doc__', '__file__', '__n
ame__', '__package__',
Christian Heimes added the comment:
Seems legit ... I don't have access to a Windows system right now so I can't
test it.
WindowsError is globally available on Windows. You don't have to import it from
shutil. Portable application should use OSError instead of WindowsError.
WindowsError is a
Saurabh Gupta added the comment:
I have a legacy software that has things like:
try:
some stuff
except OSError, why:
if WindowsError is not None and isinstance(why, WindowsError):
do something
else:
do something else
So I'd ideally like
Ronald Oussoren added the comment:
WindowsError is not part of the documented interface of shutil, but is an
implementation detail.
from shutil import WindowsUtil works on Unix platforms because shutil
contains a compatibility definition:
try:
WindowsError
except NameError:
Tim Golden added the comment:
Really this should be a wont-fix: the fact that it's possible to import
WindowsError from shutil (on Linux) is an accident of its internal
implementation. It's certainly not documented as such.
Saurabh: WindowsError is a builtin on Windows. If you want to mimic
Ronald Oussoren added the comment:
I agree that this should be closed.
--
resolution: - wont fix
status: open - closed
versions: +Python 2.7, Python 3.3
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue18525
Saurabh Gupta added the comment:
Thank you all for your inputs!
Now I understand what the issue really is would be fixing it by removing the
imports in the legacy software.
I agree with the won't fix resolution of the ticket.
--
___
Python tracker
New submission from Saurabh Gupta:
I've observed that shutil fails to import WindowsError on our windows 7 systems:
from shutil import WindowsError
File file, line no, in module
from shutil import WindowsError
ImportError: cannot import name WindowsError
The same statement
10 matches
Mail list logo