Add support for C-style block comments (/* */) in tokenizer#149098
Add support for C-style block comments (/* */) in tokenizer#149098VashuTheGreat wants to merge 1 commit into
Conversation
|
Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool. If this change has little impact on Python users, wait for a maintainer to apply the |
|
Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool. If this change has little impact on Python users, wait for a maintainer to apply the |
|
Please don't use AI to generate PRs. This feature has already been discussed and rejected several times: |
|
Thank you for the feedback and for sharing the prior discussions. I understand that similar proposals have been considered before and rejected primarily on design grounds rather than technical limitations. In this PR, my intention is not to challenge those decisions, but to demonstrate a minimal, backward-compatible tokenizer-level implementation and gather concrete feedback on its behavior. The current implementation:
I have tested several edge cases (including usage inside expressions and nested code structures), and the behavior appears consistent with expectations. That said, I fully understand that acceptance depends on language design philosophy, not just technical correctness. I would appreciate any specific concerns regarding:
If this feature is fundamentally out of scope for Python, I am happy to close the PR. Otherwise, I would be glad to refine the implementation or formalize it further (e.g., via a PEP) if there is any interest. Thanks again for your time and review. |
|
Yes, please don't do this. Getting new features, especially changes to syntax, in a major programming language is very difficult. For Python, our process is as follows:
This process is all documented in PEP 1. As a side note, please review our AI policy. Responses that are fully generated by AI, such as yours, are often factually incorrect. It's much nicer to use your own words :) |
Title
Add optional support for C-style block comments (/* ... */)
Summary
This PR introduces support for C-style block comments (/* ... */) at the tokenizer level.
The implementation:
Motivation
Many developers coming from C/C++/Java backgrounds expect block comments.
This change improves accessibility without impacting existing code.
Implementation Details
Compatibility
Tests
Manually tested with:
Notes
This is a minimal tokenizer-level enhancement and does not modify parser or runtime behavior.
Additional Testing
The implementation has been validated against multiple edge cases, including:
Implementation Details
/* ... */sequenceslinenoupdates)/operator using tokenizer backupNo changes were made to:
Compatibility
Additional Testing
The implementation has been validated against multiple edge cases, including:
Comments inside indented blocks:
Comments inside list :
Multiple consecutive comments:
Comments combined with division operator:
Strings containing comment-like patterns (ensuring no false positives):
Unterminated comment detection:
All tested scenarios behaved as expected without breaking existing syntax.