Fixed an issue when the "pio pkg publish" command didn’t work with Python 3.6 // #4352

This commit is contained in:
Ivan Kravets
2022-07-13 14:46:40 +03:00
parent 6f8f2511c2
commit 4278574450
3 changed files with 12 additions and 1 deletions

View File

@ -17,6 +17,7 @@ PlatformIO Core 6
~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~
* Fixed a regression bug when `libArchive <https://docs.platformio.org/en/latest/manifests/library-json/fields/build/libarchive.html>`__ option declared in the `library.json <https://docs.platformio.org/en/latest/manifests/library-json/index.html>`__ manifest was ignored (`issue #4351 <https://github.com/platformio/platformio-core/issues/4351>`_) * Fixed a regression bug when `libArchive <https://docs.platformio.org/en/latest/manifests/library-json/fields/build/libarchive.html>`__ option declared in the `library.json <https://docs.platformio.org/en/latest/manifests/library-json/index.html>`__ manifest was ignored (`issue #4351 <https://github.com/platformio/platformio-core/issues/4351>`_)
* Fixed an issue when the `pio pkg publish <https://docs.platformio.org/en/latest/core/userguide/pkg/cmd_publish.html>`__ command didn't work with Python 3.6 (`issue #4352 <https://github.com/platformio/platformio-core/issues/4352>`_)
6.1.1 (2022-07-11) 6.1.1 (2022-07-11)
~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~

View File

@ -41,6 +41,15 @@ def is_bytes(x):
return isinstance(x, (bytes, memoryview, bytearray)) 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): def ci_strings_are_equal(a, b):
if a == b: if a == b:
return True return True

View File

@ -22,6 +22,7 @@ from tabulate import tabulate
from platformio import fs from platformio import fs
from platformio.account.client import AccountClient from platformio.account.client import AccountClient
from platformio.compat import isascii
from platformio.exception import UserSideException from platformio.exception import UserSideException
from platformio.package.manifest.parser import ManifestParserFactory from platformio.package.manifest.parser import ManifestParserFactory
from platformio.package.manifest.schema import ManifestSchema 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): def check_archive_file_names(archive_path):
with tarfile.open(archive_path, mode="r:gz") as tf: with tarfile.open(archive_path, mode="r:gz") as tf:
for name in tf.getnames(): for name in tf.getnames():
if not name.isascii(): if not isascii(name) or not name.isprintable():
click.secho( click.secho(
f"Warning! The `{name}` file contains non-ASCII chars and can " f"Warning! The `{name}` file contains non-ASCII chars and can "
"lead to the unpacking issues on a user machine", "lead to the unpacking issues on a user machine",