Skip to content

Commit

Permalink
Merge pull request #53 from sbraz/python312_sumport_imp
Browse files Browse the repository at this point in the history
Fix tests for Python 3.12: remove "imp", fixes #21, #44
  • Loading branch information
lxp authored May 18, 2024
2 parents ed2b4bb + a52dafb commit afab354
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions test/cfvtest.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
from builtins import object

import fnmatch
import imp
import importlib
import importlib.util
import os
import shlex
import sys
Expand Down Expand Up @@ -201,8 +201,14 @@ def setcfv(fn=None, internal=None):
cfv_compiled = compile(_cfv_code, cfvfn, 'exec')

with open(cfvfn, 'rt') as f:
# For spec_from_file_location to accept a file without the .py suffix ("cfv")
importlib.machinery.SOURCE_SUFFIXES.append('')
spec = importlib.util.spec_from_file_location('cfvwrapper', cfvfn)
module = importlib.util.module_from_spec(spec)
# This is so that the sys.path modification of the wrapper (if it has one) will be executed..
imp.load_source('cfvwrapper', cfvfn, f)
spec.loader.exec_module(module)
# Restore SOURCE_SUFFIXES to its default value
importlib.machinery.SOURCE_SUFFIXES.pop()

get_version_flags()

Expand Down

0 comments on commit afab354

Please sign in to comment.