Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for Python 3.7 #102

Merged
merged 5 commits into from Jun 20, 2018
Merged

Add support for Python 3.7 #102

merged 5 commits into from Jun 20, 2018

Conversation

avylove
Copy link
Collaborator

@avylove avylove commented May 23, 2018

Python 3.7 is scheduled for release on June 15th so I've started testing some of my projects for compatibility. I ran into some issues running blessed due to changes in the the re module. I also added 3.6 and 3.7 to tox and travis and included changes needed to ensure all the tests pass. Summary of the changes is below.

Python 3.7 compatibility

  • re.sub: Unknown escapes in repl consisting of '' and an ASCII letter now are errors.

    • blessed/sequences.py
    • Workaround by making repl a function
      pattern = re.sub(r'\d+', _numeric_regex, _outp)
      becomes
      pattern = re.sub(r'\d+', lambda x: _numeric_regex, _outp)
  • re.escape: Only characters that can have special meaning in a regular expression are escaped.

    • blessed/sequences.py (affects behavior)
    • blessed/tests/test_core.py (changes)
    • Only test that failed was test_termcap_repr()
      • Returned
        r"<Termcap cursor_up:'\x1b\\[A'>"
        instead of
        r"<Termcap cursor_up:'\\\x1b\\[A'>"
      • Assuming new output is valid since primary purpose is to feed regex and all other tests pass
      • Updated test to expect new output (along with existing)

Fixes for Travis

  • Not related to Python 3.7
  • Ctrl-C test was inconsistent and configured to be skipped on Travis, but the TRAVIS environment variable was not being passed to tox
    • Added TRAVIS variable to tox environment
  • There were some issues in the Travis environment due to the default Python
    • Changed global python to 3.6 before install
    • The Travis environment should be updated soon and we won't need this anymore

Fix issues with static analysis

  • Not related to Python 3.7
  • Forced prospector not to use external config files
    • This prevents it from using any pylintrc and similar files it finds in it's environment
  • Disabled two docstring checks:
    • D212: Multi-line docstring summary should start at the first line
    • D401: First line should be in imperative mood
  • Code cleanup to resolve other errors and warnings

Temporarily disabled display-maxcanon.py

  • Not related to Python 3.7
  • On my system and in Travis, this seems to run forever.
    • Unsure if this is due to a change in pexpect or Linux
    • Considered adding limits, but you're the expert in this, so figured you would know better

@jquast
Copy link
Owner

jquast commented May 23, 2018

My sincere thanks, I'll incorporate this very soon. You are a very kind and careful person, thank you for the good quality!

@avylove
Copy link
Collaborator Author

avylove commented Jun 19, 2018

Any progress on this? Fedora is already starting to build packages against 3.7 in prep for the release at the end of the month.

@jquast
Copy link
Owner

jquast commented Jun 20, 2018

apologies, will push for release immediately, will comment again soon when complete

@jquast jquast merged commit 465f384 into jquast:master Jun 20, 2018
@jquast
Copy link
Owner

jquast commented Jun 20, 2018

should be released...

https://pypi.org/project/blessed/

@avylove
Copy link
Collaborator Author

avylove commented Jun 20, 2018

Awesome! Thanks!

@serhiy-storchaka
Copy link

Workaround by making repl a function

Other workaround: duplicate backslashes in the replacement string.

pattern = re.sub(r'\d+', _numeric_regex, _outp)

becomes

pattern = re.sub(r'\d+', _numeric_regex.replace('\\', r'\\'), _outp)

And since r'(\d+)' means the same as r'\d+' in re.sub(), you don't need two branches at lines 131-135.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants