Kotaimen / awscfncli

Friendly AWS CloudFormation CLI
MIT License
59 stars 12 forks source link

Version 2.1.5 not compatible with python3.6+ #70

Open edransjsuarez opened 5 years ago

edransjsuarez commented 5 years ago

Hi,

Testing the new version 2.1.5::

>test/bin/cfn-cli
Traceback (most recent call last):
  File "test/bin/cfn-cli", line 7, in <module>
    from awscfncli2.__main__ import main
  File "/home/yyy/test/lib/python3.6/site-packages/awscfncli2/__main__.py", line 26, in <module>
    from .cli import cfn_cli
  File "/home/yyy/test/lib/python3.6/site-packages/awscfncli2/cli/__init__.py", line 2, in <module>
    from .main import cfn_cli
  File "/home/yyy/test/lib/python3.6/site-packages/awscfncli2/cli/main.py", line 10, in <module>
    from .context import ClickContext
  File "/home/yyy/test/lib/python3.6/site-packages/awscfncli2/cli/context.py", line 3, in <module>
    from ..runner import Boto3Profile, Boto3RunBook, StackSelector
  File "/home/yyy/test/lib/python3.6/site-packages/awscfncli2/runner/__init__.py", line 1, in <module>
    from .commands.drift_detect_command import DriftDetectOptions, \
  File "/home/yyy/test/lib/python3.6/site-packages/awscfncli2/runner/commands/drift_detect_command.py", line 5, in <module>
    from .command import Command
  File "/home/yyy/test/lib/python3.6/site-packages/awscfncli2/runner/commands/command.py", line 1, in <module>
    from ...cli.utils import StackPrettyPrinter
  File "/home/yyy/test/lib/python3.6/site-packages/awscfncli2/cli/utils/__init__.py", line 2, in <module>
    from .deco import command_exception_handler
  File "/home/yyy/test/lib/python3.6/site-packages/awscfncli2/cli/utils/deco.py", line 7, in <module>
    from ...config import ConfigError
  File "/home/yyy/test/lib/python3.6/site-packages/awscfncli2/config/__init__.py", line 4, in <module>
    from .config import load_config, ConfigError
  File "/home/yyy/test/lib/python3.6/site-packages/awscfncli2/config/config.py", line 7, in <module>
    from .formats import load_format
  File "/home/yyy/test/lib/python3.6/site-packages/awscfncli2/config/formats.py", line 212, in <module>
    class ParamReferenceTemplate(string.Template):
  File "/usr/lib/python3.6/string.py", line 74, in __init__
    cls.pattern = _re.compile(pattern, cls.flags | _re.VERBOSE)
  File "/usr/lib/python3.6/re.py", line 233, in compile
    return _compile(pattern, flags)
  File "/usr/lib/python3.6/re.py", line 301, in _compile
    p = sre_compile.compile(pattern, flags)
  File "/usr/lib/python3.6/sre_compile.py", line 562, in compile
    p = sre_parse.parse(p, flags)
  File "/usr/lib/python3.6/sre_parse.py", line 855, in parse
    p = _parse_sub(source, pattern, flags & SRE_FLAG_VERBOSE, 0)
  File "/usr/lib/python3.6/sre_parse.py", line 416, in _parse_sub
    not nested and not items))
  File "/usr/lib/python3.6/sre_parse.py", line 765, in _parse
    p = _parse_sub(source, state, sub_verbose, nested + 1)
  File "/usr/lib/python3.6/sre_parse.py", line 416, in _parse_sub
    not nested and not items))
  File "/usr/lib/python3.6/sre_parse.py", line 765, in _parse
    p = _parse_sub(source, state, sub_verbose, nested + 1)
  File "/usr/lib/python3.6/sre_parse.py", line 416, in _parse_sub
    not nested and not items))
  File "/usr/lib/python3.6/sre_parse.py", line 734, in _parse
    flags = _parse_flags(source, state, char)
  File "/usr/lib/python3.6/sre_parse.py", line 803, in _parse_flags
    raise source.error("bad inline flags: cannot turn on global flag", 1)
sre_constants.error: bad inline flags: cannot turn on global flag at position 92 (line 4, column 20)

Distributor ID: Ubuntu Description: Ubuntu 18.04.1 LTS Release: 18.04 Codename: bionic Python 3.6.7 pip 9.0.1 from /usr/lib/python3/dist-packages (python 3.6)

Regards, Jesús A Suárez

Kotaimen commented 5 years ago

Hi @GlieseRay:

Please take a look at this again... and use 3.6, home-brew defaults to 3.7 now.

Update:

Here's what's in py3.6's string.Template:

    # r'[a-z]' matches to non-ASCII letters when used with IGNORECASE,
    # but without ASCII flag.  We can't add re.ASCII to flags because of
    # backward compatibility.  So we use local -i flag and [a-zA-Z] pattern.
    # See https://bugs.python.org/issue31672
    idpattern = r'(?-i:[_a-zA-Z][_a-zA-Z0-9]*)'

So, I'm changing this to:

r'(?-i:[a-zA-Z_][-a-zA-Z0-9_]*\.[a-zA-Z_][-a-zA-Z0-9_]*\.[a-zA-Z_][-a-zA-Z0-9_]*)'
Kotaimen commented 5 years ago

Note this fix does not work with 2.7 yet.

GlieseRay commented 5 years ago

@Kotaimen will change the implementation in next release to accommodate both 2.7 and 3.6