Skip to content

Commit

Permalink
Backport PR #11962: Fix warnings with Python 3.10
Browse files Browse the repository at this point in the history
  • Loading branch information
pllim authored and saimn committed Oct 14, 2021
1 parent 469f91d commit dea513d
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 10 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/ci_cron_weekly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ jobs:
# that gives too many false positives due to URL timeouts. We also
# install all dependencies via pip here so we pick up the latest
# releases.
- name: Python 3.7 with dev version of key dependencies
- name: Python 3.10 with dev version of key dependencies
os: ubuntu-latest
python: 3.7
toxenv: py37-test-devdeps
python: '3.10.0-alpha - 3.10.0'
toxenv: py310-test-devdeps

- name: Documentation link check
os: ubuntu-latest
Expand Down
5 changes: 5 additions & 0 deletions .github/workflows/ci_workflows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@ jobs:
python: 3.9
toxenv: py39-test

- name: Python 3.10 with minimal dependencies
os: ubuntu-latest
python: '3.10.0-alpha - 3.10.0'
toxenv: py310-test-devdeps

# NOTE: In the build below we also check that tests do not open and
# leave open any files. This has a performance impact on running the
# tests, hence why it is not enabled by default.
Expand Down
6 changes: 5 additions & 1 deletion astropy/convolution/convolve.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import os
import ctypes
import warnings
from functools import partial

import numpy as np
Expand All @@ -22,7 +23,10 @@
LIBRARY_PATH = os.path.dirname(__file__)

try:
_convolve = load_library("_convolve", LIBRARY_PATH)
with warnings.catch_warnings():
# distutils.sysconfig module is deprecated in Python 3.10
warnings.simplefilter('ignore', DeprecationWarning)
_convolve = load_library("_convolve", LIBRARY_PATH)
except Exception:
raise ImportError("Convolution C extension is missing. Try re-building astropy.")

Expand Down
6 changes: 3 additions & 3 deletions astropy/io/fits/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,9 +210,9 @@ def ignore_sigint(func):
def wrapped(*args, **kwargs):
# Get the name of the current thread and determine if this is a single
# threaded application
curr_thread = threading.currentThread()
single_thread = (threading.activeCount() == 1 and
curr_thread.getName() == 'MainThread')
curr_thread = threading.current_thread()
single_thread = (threading.active_count() == 1 and
curr_thread.name == 'MainThread')

class SigintHandler:
def __init__(self):
Expand Down
2 changes: 1 addition & 1 deletion astropy/tests/tests/test_imports.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def onerror(name):

for imper, nm, ispkg in pkgutil.walk_packages(['astropy'], 'astropy.',
onerror=onerror):
imper.find_module(nm)
imper.find_spec(nm)


def test_toplevel_namespace():
Expand Down
2 changes: 1 addition & 1 deletion astropy/utils/console.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ def isatty(file):
ttys.
"""
if (multiprocessing.current_process().name != 'MainProcess' or
threading.current_thread().getName() != 'MainThread'):
threading.current_thread().name != 'MainThread'):
return False

if hasattr(file, 'isatty'):
Expand Down
1 change: 1 addition & 0 deletions docs/changes/11962.other.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix deprecation warnings with Python 3.10
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tox]
envlist =
py{37,38,39,dev}-test{,-alldeps,-oldestdeps,-devdeps,-numpy117,-numpy118,-numpy119}{,-cov}{,-clocale}
py{37,38,39,310,dev}-test{,-alldeps,-oldestdeps,-devdeps,-numpy117,-numpy118,-numpy119}{,-cov}{,-clocale}
build_docs
linkcheck
codestyle
Expand Down

0 comments on commit dea513d

Please sign in to comment.