Skip to content

Stop raising exceptions on unexpected ]]] characters#69

Merged
nedbat merged 1 commit into
nedbat:mainfrom
kurtmckee:fix-crash-on-python-in-github-workflows-issue-52
Jan 26, 2026
Merged

Stop raising exceptions on unexpected ]]] characters#69
nedbat merged 1 commit into
nedbat:mainfrom
kurtmckee:fix-crash-on-python-in-github-workflows-issue-52

Conversation

@kurtmckee
Copy link
Copy Markdown
Contributor

This addresses errors that occur on valid files, like GitHub workflows that contain both cog usage and embedded Python with accurate type annotations. For example:

on:
  push:
jobs:
  demo:
    runs-on: ubuntu-latest
    steps:
      - run: |
          # [[[cog cog.outl("echo 'hello'") ]]]
          echo 'hello'
          # [[[end]]]
      - shell: python
        run: |
          def demo() -> tuple[tuple[tuple[str]]]:
              #                              ^^^
              # This caused a failure        |||
              #
              return ((("hello world",),),)
          print(demo()[0][0][0])

Fixes #52

@nedbat
Copy link
Copy Markdown
Owner

nedbat commented Jan 26, 2026

This makes sense. When cog started, I didn't imagine ]]] would occur in the wild!

@nedbat nedbat merged commit ca46694 into nedbat:main Jan 26, 2026
19 checks passed
@kurtmckee kurtmckee deleted the fix-crash-on-python-in-github-workflows-issue-52 branch January 26, 2026 23:47
@kurtmckee
Copy link
Copy Markdown
Contributor Author

Thanks for reviewing and merging this, @nedbat!

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.

Error when file has end-spec string (]]]) somewhere outside the cog spec

2 participants