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

Replace deprecated imp module with importlib #1

Closed
hugovk opened this issue Apr 29, 2023 · 3 comments · Fixed by #2
Closed

Replace deprecated imp module with importlib #1

hugovk opened this issue Apr 29, 2023 · 3 comments · Fixed by #2
Assignees
Labels
enhancement New feature or request

Comments

@hugovk
Copy link

hugovk commented Apr 29, 2023

This project uses 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.

@mdmintz
Copy link
Owner

mdmintz commented Apr 29, 2023

@hugovk where do you see import imp in this codebase? The pynose repo already fixed the issues of the older nose repo.

@hugovk
Copy link
Author

hugovk commented Apr 29, 2023

It's here:

from imp import find_module, load_module, acquire_lock, release_lock

pynose/nose/importer.py

Lines 65 to 81 in 4e0d2bb

fh, filename, desc = find_module(part, path)
old = sys.modules.get(part_fqname)
if old is not None:
log.debug("sys.modules has %s as %s", part_fqname, old)
if (self.sameModule(old, filename)
or (self.config.firstPackageWins and
getattr(old, '__path__', None))):
mod = old
else:
del sys.modules[part_fqname]
mod = load_module(part_fqname, fh, filename, desc)
else:
mod = load_module(part_fqname, fh, filename, desc)
finally:
if fh:
fh.close()
release_lock()

@mdmintz mdmintz self-assigned this Apr 29, 2023
@mdmintz mdmintz closed this as completed in #2 May 2, 2023
@mdmintz
Copy link
Owner

mdmintz commented May 2, 2023

Fixed in 1.4.3 - https://github.com/mdmintz/pynose/releases/tag/v1.4.3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants