Skip to content

Commit

Permalink
Remove six import from src/pip/_internal/req/req_install.py
Browse files Browse the repository at this point in the history
Use Python 3 `raise exc from ...` semantics to replace the use of
six.reraise.
  • Loading branch information
jdufresne committed Aug 8, 2021
1 parent d3a78eb commit cf7183d
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 7 deletions.
Empty file.
8 changes: 3 additions & 5 deletions src/pip/_internal/operations/install/legacy.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

import logging
import os
import sys
from distutils.util import change_root
from typing import List, Optional, Sequence

Expand All @@ -20,8 +19,7 @@


class LegacyInstallFailure(Exception):
def __init__(self) -> None:
self.parent = sys.exc_info()
pass


def write_installed_files_from_setuptools_record(
Expand Down Expand Up @@ -111,9 +109,9 @@ def install(
# Signal to the caller that we didn't install the new package
return False

except Exception:
except Exception as e:
# Signal to the caller that we didn't install the new package
raise LegacyInstallFailure
raise LegacyInstallFailure from e

# At this point, we have successfully installed the requirement.

Expand Down
4 changes: 2 additions & 2 deletions src/pip/_internal/req/req_install.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import zipfile
from typing import Any, Dict, Iterable, List, Optional, Sequence, Union

from pip._vendor import pkg_resources, six
from pip._vendor import pkg_resources
from pip._vendor.packaging.markers import Marker
from pip._vendor.packaging.requirements import Requirement
from pip._vendor.packaging.specifiers import SpecifierSet
Expand Down Expand Up @@ -795,7 +795,7 @@ def install(
)
except LegacyInstallFailure as exc:
self.install_succeeded = False
six.reraise(*exc.parent)
raise exc.__cause__
except Exception:
self.install_succeeded = True
raise
Expand Down

0 comments on commit cf7183d

Please sign in to comment.