diff --git a/HISTORY.rst b/HISTORY.rst index 3be873ee..51bd288e 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -17,6 +17,7 @@ PlatformIO Core 6 ~~~~~~~~~~~~~~~~~~ * Fixed a regression bug when `libArchive `__ option declared in the `library.json `__ manifest was ignored (`issue #4351 `_) +* Fixed an issue when the `pio pkg publish `__ command didn't work with Python 3.6 (`issue #4352 `_) 6.1.1 (2022-07-11) ~~~~~~~~~~~~~~~~~~ diff --git a/platformio/compat.py b/platformio/compat.py index 43eb98dd..cdce3939 100644 --- a/platformio/compat.py +++ b/platformio/compat.py @@ -41,6 +41,15 @@ def is_bytes(x): return isinstance(x, (bytes, memoryview, bytearray)) +def isascii(text): + if sys.version_info >= (3, 7): + return text.isascii() + for c in text or "": + if ord(c) > 127: + return False + return True + + def ci_strings_are_equal(a, b): if a == b: return True diff --git a/platformio/package/commands/publish.py b/platformio/package/commands/publish.py index 8d282fa0..58230eef 100644 --- a/platformio/package/commands/publish.py +++ b/platformio/package/commands/publish.py @@ -22,6 +22,7 @@ from tabulate import tabulate from platformio import fs from platformio.account.client import AccountClient +from platformio.compat import isascii from platformio.exception import UserSideException from platformio.package.manifest.parser import ManifestParserFactory from platformio.package.manifest.schema import ManifestSchema @@ -155,7 +156,7 @@ def package_publish_cmd( # pylint: disable=too-many-arguments, too-many-locals def check_archive_file_names(archive_path): with tarfile.open(archive_path, mode="r:gz") as tf: for name in tf.getnames(): - if not name.isascii(): + if not isascii(name) or not name.isprintable(): click.secho( f"Warning! The `{name}` file contains non-ASCII chars and can " "lead to the unpacking issues on a user machine",