Skip to content

LibCST drops whitespace before : in except / except* handlers without as #1457

Description

@fraglantia

Version
LibCST 1.8.6 on Python 3.12

Reproducer:

import libcst as cst

src = "try: pass\nexcept A :\n pass\n"
out = cst.parse_module(src).code

print(repr(out))
assert out == src

Actual Output
'try: pass\nexcept A:\n pass\n'

Expected Output
'try: pass\nexcept A :\n pass\n'

The issue also reproduces with the following input:

try: pass
except* A :
 pass

But this form appears to preserve correctly:

try: pass
except A as e :
 pass

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions