Skip to content

Python koans no longer completes on Python 3.14 #295

@millerabel

Description

@millerabel

On macOS 15.7.1 (24G231), running the koans in Python 3.12 as...

env python3.12 -B contemplate_koans

runs to completion...

You have completed 304 (100 %) koans and 37 (out of 37) lessons.

Nobody ever expects the Spanish Inquisition.

**************************************************

That was the last one, well done!

If you want more, take a look at about_extra_credit.py

However, the koans do not complete in Python 3.14...

env python3.14 -B contemplate_koans

Does not complete, yet produces no "failed" tests. It just stops short of enlightenment...

You have completed 196 (64 %) koans and 24 (out of 37) lessons.
You are now 108 koans and 13 lessons away from reaching enlightenment.

Readability counts.

The following syntax warnings are produced...

python_koans % python3.14 -B contemplate_koans.py
/Users/miller/Develop/Samples/python_koans/runner/sensei.py:63: SyntaxWarning: "\d" is an invalid escape sequence. Such sequences will not work in the future. Did you mean "\\d"? A raw string is also an option.
  m = re.search("(?<= line )\d+" ,err)
/Users/miller/Develop/Samples/python_koans/runner/sensei.py:149: SyntaxWarning: "\w" is an invalid escape sequence. Such sequences will not work in the future. Did you mean "\\w"? A raw string is also an option.
  m = re.search("^    \w(\w)+.*$",line)
/Users/miller/Develop/Samples/python_koans/libs/colorama/ansitowin32.py:43: SyntaxWarning: "\[" is an invalid escape sequence. Such sequences will not work in the future. Did you mean "\\["? A raw string is also an option.
  ANSI_RE = re.compile('\033\[((?:\d|;)*)([a-zA-Z])')
/Users/miller/Develop/Samples/python_koans/koans/about_none.py:50: SyntaxWarning: "is not" with 'int' literal. Did you mean "!="?
  self.assertEqual(True, None is not 0)

The first three warnings are all fixed by using a raw string for the re pattern. For example, in sensei.py:

63 m = re.search(r"(?<= line )\d+" ,err)

The last warning is for using an int literal as a target of is or is not. Because of how CPython allocates (and reuses) integer objects, results of such comparisons could be inconsistent. However, that would never be a problem with None, which is a singleton and would never match an int literal. Nevertheless, the syntax warning suggests the best practice is to use != instead.

I've proposed two pull requests to fix these issues.

UPDATE

After clearing the syntax warnings, the problem between Python 3.12 and 3.14 remains. The new version does not run all of the tests. It drops out two tests from about_method_bindings.py:

Thinking AboutMethodBindings
  test_functions_can_have_inner_functions has expanded your awareness.
  test_get_descriptor_resolves_attribute_binding has expanded your awareness.
  test_inner_functions_are_unbound has expanded your awareness.
  test_methods_are_also_bound_to_a_function has expanded your awareness.
  test_methods_are_bound_to_an_object has expanded your awareness.
  test_set_descriptor_changes_behavior_of_attribute_assignment has expanded your awareness.
  test_setting_attributes_on_a_bound_method_directly has expanded your awareness.
  test_setting_attributes_on_an_unbound_function has expanded your awareness.
  test_setting_attributes_on_methods_by_accessing_the_inner_function has expanded your awareness.

test_functions_have_attributes and test_methods_have_different_attributes are skipped without warning or error.

When I run a fresh download of the koans, no error output is produced. It seems the stderr wrapped output is disappearing.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions