Skip to content

Replace deprecated imp module with importlib #145

@hugovk

Description

@hugovk

This project's tests use the imp module which has been deprecated since Python 3.4 and removed in 3.12:

Python 3.12 is set for release on 2023-10-02 and this library is one of the top 5,000 most-downloaded from PyPI.

Please could you upgrade to use importlib? The imp docs have suggestions on what to use to replace each function and constant.

imp.acquire_lock()
lock_held.set()
test_complete.wait()
imp.release_lock()
t = threading.Thread(target=other_thread)
t.start()
lock_held.wait()
# While the imp lock is held by the other thread, we can't
# allow exceptions/assertions to happen because trial will
# try to do an import causing a deadlock instead of a
# failure. We collect all assertion pairs (result, expected),
# wait for the import lock to be released, and then check our
# assertions at the end of the test.
assertions = []
# we want to run .wait while the other thread has the lock acquired
assertions.append((imp.lock_held(), True))
try:
assertions.append((er.wait(0.1), 123))
finally:
test_complete.set()
assertions.append((imp.lock_held(), True))

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions