This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: TypeError in error handling in distutils.dir_util.copy_tree
Type: behavior Stage: resolved
Components: Distutils Versions: Python 3.4, Python 3.5
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: jaraco Nosy List: Claudiu.Popa, dstufft, eric.araujo, jaraco, python-dev
Priority: normal Keywords: patch

Created on 2014-08-31 15:15 by jaraco, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
7304b9b95438.diff jaraco, 2014-08-31 19:18 review
Repositories containing patches
http://hg.python.org/jaraco/issue22315#3.4
Messages (7)
msg226182 - (view) Author: Jason R. Coombs (jaraco) * (Python committer) Date: 2014-08-31 15:15
This morning, I was running an install of a package on Python 3.4.1 when I encountered this error:

C:\Users\jaraco\projects\jaraco.financial [default tip]> ./setup install
running install
running bdist_egg
running egg_info
writing namespace_packages to jaraco.financial.egg-info\namespace_packages.txt
writing jaraco.financial.egg-info\PKG-INFO
writing top-level names to jaraco.financial.egg-info\top_level.txt
writing requirements to jaraco.financial.egg-info\requires.txt
writing dependency_links to jaraco.financial.egg-info\dependency_links.txt
writing entry points to jaraco.financial.egg-info\entry_points.txt
writing manifest file 'jaraco.financial.egg-info\SOURCES.txt'
installing library code to build\bdist.win-amd64\egg
running install_lib
running build_py
copying jaraco\financial\records.py -> build\lib\jaraco\financial
creating build\bdist.win-amd64\egg
creating build\bdist.win-amd64\egg\jaraco
creating build\bdist.win-amd64\egg\jaraco\financial
copying build\lib\jaraco\financial\ledger.py -> build\bdist.win-amd64\egg\jaraco\financial
copying build\lib\jaraco\financial\qif.py -> build\bdist.win-amd64\egg\jaraco\financial
copying build\lib\jaraco\financial\merchant.py -> build\bdist.win-amd64\egg\jaraco\financial
Traceback (most recent call last):
  File "C:\Program Files\Python34\lib\distutils\dir_util.py", line 126, in copy_tree
    names = os.listdir(src)
OSError: [WinError 59] An unexpected network error occurred: 'build\\lib\\jaraco\\financial\\records.py'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\jaraco\projects\jaraco.financial\setup.py", line 72, in <module>
    setuptools.setup(**setup_params)
  File "C:\Program Files\Python34\lib\distutils\core.py", line 148, in setup
    dist.run_commands()
  File "C:\Program Files\Python34\lib\distutils\dist.py", line 955, in run_commands
    self.run_command(cmd)
  File "C:\Program Files\Python34\lib\distutils\dist.py", line 974, in run_command
    cmd_obj.run()
  File "C:\Program Files\Python34\lib\site-packages\setuptools-5.7-py3.4.egg\setuptools\command\install.py", line 67, in run
  File "C:\Program Files\Python34\lib\site-packages\setuptools-5.7-py3.4.egg\setuptools\command\install.py", line 109, in do_egg_install
  File "C:\Program Files\Python34\lib\distutils\cmd.py", line 313, in run_command
    self.distribution.run_command(command)
  File "C:\Program Files\Python34\lib\distutils\dist.py", line 974, in run_command
    cmd_obj.run()
  File "C:\Program Files\Python34\lib\site-packages\setuptools-5.7-py3.4.egg\setuptools\command\bdist_egg.py", line 161, in run
  File "C:\Program Files\Python34\lib\site-packages\setuptools-5.7-py3.4.egg\setuptools\command\bdist_egg.py", line 147, in call_command
  File "C:\Program Files\Python34\lib\distutils\cmd.py", line 313, in run_command
    self.distribution.run_command(command)
  File "C:\Program Files\Python34\lib\distutils\dist.py", line 974, in run_command
    cmd_obj.run()
  File "C:\Program Files\Python34\lib\site-packages\setuptools-5.7-py3.4.egg\setuptools\command\install_lib.py", line 10, in run
  File "C:\Program Files\Python34\lib\distutils\command\install_lib.py", line 111, in install
    outfiles = self.copy_tree(self.build_dir, self.install_dir)
  File "C:\Program Files\Python34\lib\site-packages\setuptools-5.7-py3.4.egg\setuptools\command\install_lib.py", line 38, in copy_tree
  File "C:\Program Files\Python34\lib\distutils\cmd.py", line 357, in copy_tree
    not self.force, dry_run=self.dry_run)
  File "C:\Program Files\Python34\lib\distutils\dir_util.py", line 160, in copy_tree
    verbose=verbose, dry_run=dry_run))
  File "C:\Program Files\Python34\lib\distutils\dir_util.py", line 160, in copy_tree
    verbose=verbose, dry_run=dry_run))
  File "C:\Program Files\Python34\lib\distutils\dir_util.py", line 160, in copy_tree
    verbose=verbose, dry_run=dry_run))
  File "C:\Program Files\Python34\lib\distutils\dir_util.py", line 128, in copy_tree
    (errno, errstr) = e
TypeError: 'OSError' object is not iterable

The original traceback indicates a network error occurred. The secondary error occurs when the error is assumed to be an iterable of two elements. I suspect this issue arises from the conversion of WindowsError to OSError or similar.

I plan to look at this in more depth later.
msg226183 - (view) Author: Jason R. Coombs (jaraco) * (Python committer) Date: 2014-08-31 15:16
On a second attempt, the operation completed successfully, so a transient network error was necessary to elicit the bug.
msg226187 - (view) Author: Jason R. Coombs (jaraco) * (Python committer) Date: 2014-08-31 19:19
I've started work on a test to capture the failure. Patch 7304b9 is attached. Any comments on the test before I proceed with the fix? I haven't been able to run the test, so if someone could do that, it would be most appreciated.
msg226188 - (view) Author: PCManticore (Claudiu.Popa) * (Python triager) Date: 2014-08-31 19:40
A similar issue was fixed a couple of days ago in file_util.py, with f01413758114. It would be nice to have similar tests.
msg226189 - (view) Author: PCManticore (Claudiu.Popa) * (Python triager) Date: 2014-08-31 19:42
I'm referring to the "TypeError: 'OSError' object is not iterable" failure.
msg226194 - (view) Author: Jason R. Coombs (jaraco) * (Python committer) Date: 2014-08-31 22:01
Claudiu, thanks for the tip. That was quite helpful. I did not realize that unittest included a mock implementation. I've updated the test to use the same technique. I've furthermore verified that the test captures the failure and adjusted the implementation to match that expectation.
msg226195 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2014-08-31 22:02
New changeset 7304b9b95438 by Jason R. Coombs in branch '3.4':
#22315: Add test to capture the failure.
http://hg.python.org/cpython/rev/7304b9b95438

New changeset 300cd36eb25c by Jason R. Coombs in branch '3.4':
#22315: Use technique outlined in test_file_util
http://hg.python.org/cpython/rev/300cd36eb25c

New changeset 3402813338db by Jason R. Coombs in branch '3.4':
#22315: Provide an actual directory during test invocation.
http://hg.python.org/cpython/rev/3402813338db

New changeset ddb0f90620b7 by Jason R. Coombs in branch '3.4':
#22315: Use an existent directory for 'src' to trigger appropriate behavior.
http://hg.python.org/cpython/rev/ddb0f90620b7

New changeset 75a5cc4ef31c by Jason R. Coombs in branch '3.4':
#22315: Use advertised API for OSError
http://hg.python.org/cpython/rev/75a5cc4ef31c

New changeset 640c575ab3e1 by Jason R. Coombs in branch 'default':
Merge with 3.4; Closes #22315
http://hg.python.org/cpython/rev/640c575ab3e1
History
Date User Action Args
2022-04-11 14:58:07adminsetgithub: 66511
2014-09-01 06:10:34berker.peksagsetstatus: open -> closed
type: behavior
stage: resolved
2014-08-31 22:03:23jaracosetstatus: closed -> open
stage: resolved -> (no value)
2014-08-31 22:02:54python-devsetstatus: open -> closed

nosy: + python-dev
messages: + msg226195

resolution: fixed
stage: resolved
2014-08-31 22:01:33jaracosetmessages: + msg226194
2014-08-31 19:42:05Claudiu.Popasetmessages: + msg226189
2014-08-31 19:40:52Claudiu.Popasetnosy: + Claudiu.Popa
messages: + msg226188
2014-08-31 19:19:27jaracosetmessages: + msg226187
2014-08-31 19:18:30jaracosetfiles: + 7304b9b95438.diff
keywords: + patch
2014-08-31 19:13:47jaracosethgrepos: + hgrepo272
2014-08-31 15:16:07jaracosetmessages: + msg226183
2014-08-31 15:15:05jaracocreate