Skip to content
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

Remove deprecated imp module (issue #510) #511

Merged
merged 2 commits into from
Apr 30, 2023
Merged
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
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
- [pull #502] Replace deprecated `optparse` with `argparse`
- [pull #506] Fix `_uniform_outdent` failing with empty strings (issue #505)
- [pull #509] Fix HTML elements not unhashing correctly (issue 508)
- [pull #511] Remove deprecated `imp` module (issue #510)


## python-markdown2 2.4.8
Expand Down
7 changes: 3 additions & 4 deletions test/testlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,14 @@


import os
from os.path import join, basename, dirname, abspath, splitext, \
from os.path import join, basename, abspath, splitext, \
isfile, isdir, normpath, exists
import sys
import getopt
import glob
import time
import unittest
import imp
import importlib
import logging
import textwrap
import traceback
Expand Down Expand Up @@ -234,13 +234,12 @@ def testmods_from_testdir(testdir):
testmod_name = splitext(basename(testmod_path))[0]
log.debug("import test module '%s'", testmod_path)
try:
iinfo = imp.find_module(testmod_name, [dirname(testmod_path)])
testabsdir = abspath(testdir)
sys.path.insert(0, testabsdir)
old_dir = os.getcwd()
os.chdir(testdir)
try:
testmod = imp.load_module(testmod_name, *iinfo)
testmod = importlib.import_module(testmod_name)
finally:
os.chdir(old_dir)
sys.path.remove(testabsdir)
Expand Down