Commit 53639dd5 authored by Miss Islington (bot)'s avatar Miss Islington (bot) Committed by GitHub

closes bpo-37675: Use pkgutil.iter_modules to find fixers in a package rather than listdir. (14942)

(cherry picked from commit 93e8aa62)
Co-authored-by: default avatarBenjamin Peterson <benjamin@python.org>
parent 46c2eff5
......@@ -15,6 +15,7 @@ __author__ = "Guido van Rossum <guido@python.org>"
# Python imports
import os
import pkgutil
import sys
import logging
import operator
......@@ -33,13 +34,12 @@ from . import btm_matcher as bm
def get_all_fix_names(fixer_pkg, remove_prefix=True):
"""Return a sorted list of all available fix names in the given package."""
pkg = __import__(fixer_pkg, [], [], ["*"])
fixer_dir = os.path.dirname(pkg.__file__)
fix_names = []
for name in sorted(os.listdir(fixer_dir)):
if name.startswith("fix_") and name.endswith(".py"):
for finder, name, ispkg in pkgutil.iter_modules(pkg.__path__):
if name.startswith("fix_"):
if remove_prefix:
name = name[4:]
fix_names.append(name[:-3])
fix_names.append(name)
return fix_names
......
2to3 now works when run from a zipped standard library.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment