Skip to content

Raise with message for 3.5.2 and earlier #27288

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions pandas/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
# flake8: noqa
import sys

if sys.version_info[:3] <= (3, 5, 2):
msg = "pandas requires Python >=3.5.3 but {}.{}.{} is installed.".format(
*sys.version_info[:3]
)
raise ImportError(msg)

del sys

__docformat__ = "restructuredtext"

Expand Down
8 changes: 8 additions & 0 deletions pandas/tests/test_downstream.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,3 +150,11 @@ def test_missing_required_dependency():
output = exc.value.stdout.decode()
for name in ["numpy", "pytz", "dateutil"]:
assert name in output


def test_old_python_raises():
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we could move the import of just pandas.compat at the beginning of init and define PY35 there (and import here); would put the code more logically together.

code = "import sys; sys.version_info = (3, 5, 2); import pandas"
# match = 'pandas requires Python >=3.5.3 but 3.5.2 is installed'
out = subprocess.run(["python", "-c", code], check=False, capture_output=True)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

capture_output I don't think is available until 3.7 so source of CI errors. Maybe not needed at all?

stderr = out.stderr.decode()
assert "pandas requires Python >=3.5.3 but 3.5.2 is installed." in stderr