Reject package (extension) names that can't be valid Python identifiers (#3679)

* Reject package names that can't be valid Python identifiers

* Add info to `[p](re)load`

* Improve internal consistency of package vs cog
This commit is contained in:
jack1142
2020-08-03 15:17:27 +02:00
committed by GitHub
parent 1a3e264b2a
commit 775528ce9b
3 changed files with 103 additions and 23 deletions

View File

@@ -2,6 +2,7 @@ from __future__ import annotations
import asyncio
import functools
import keyword
import os
import pkgutil
import shlex
@@ -495,6 +496,9 @@ class Repo(RepoJSONMixin):
)
"""
for file_finder, name, is_pkg in pkgutil.iter_modules(path=[str(self.folder_path)]):
if not name.isidentifier() or keyword.iskeyword(name):
# reject package names that can't be valid python identifiers
continue
if is_pkg:
curr_modules.append(
Installable(location=self.folder_path / name, repo=self, commit=self.commit)