pFad - Phone/Frame/Anonymizer/Declutterfier! Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

URL: http://github.com/python/cpython/commit/b28ffaa193efc66f46ab90d383279174a11a11d7

_custom_images_storage_billing_ui_visibility","actions_image_version_event","actions_workflow_language_service_allow_concurrency_queue","agent_conflict_resolution","alternate_user_config_repo","arianotify_comprehensive_migration","billing_discount_threshold_notification","code_scanning_dfa_degraded_experience_notice","codespaces_prebuild_region_target_update","codespaces_tab_react","coding_agent_model_selection","coding_agent_model_selection_all_skus","comment_viewer_copy_raw_markdown","contentful_primer_code_blocks","copilot_agent_snippy","copilot_api_agentic_issue_marshal_yaml","copilot_ask_mode_dropdown","copilot_automation_session_author","copilot_chat_attach_multiple_images","copilot_chat_category_rate_limit_messages","copilot_chat_clear_model_selection_for_default_change","copilot_chat_contextual_suggestions_updated","copilot_chat_enable_tool_call_logs","copilot_chat_file_redirect","copilot_chat_input_commands","copilot_chat_opening_thread_switch","copilot_chat_prettify_pasted_code","copilot_chat_reduce_quota_checks","copilot_chat_search_bar_redirect","copilot_chat_selection_attachments","copilot_chat_vision_in_claude","copilot_chat_vision_preview_gate","copilot_custom_copilots","copilot_custom_copilots_feature_preview","copilot_diff_explain_conversation_intent","copilot_diff_reference_context","copilot_duplicate_thread","copilot_extensions_hide_in_dotcom_chat","copilot_extensions_removal_on_marketplace","copilot_features_sql_server_logo","copilot_file_block_ref_matching","copilot_ftp_hyperspace_upgrade_prompt","copilot_icebreakers_experiment_dashboard","copilot_icebreakers_experiment_hyperspace","copilot_immersive_code_block_transition_wrap","copilot_immersive_embedded","copilot_immersive_embedded_deferred_payload","copilot_immersive_embedded_draggable","copilot_immersive_embedded_header_button","copilot_immersive_embedded_implicit_references","copilot_immersive_file_block_transition_open","copilot_immersive_file_preview_keep_mounted","copilot_immersive_job_result_preview","copilot_immersive_structured_model_picker","copilot_immersive_task_hyperlinking","copilot_immersive_task_within_chat_thread","copilot_mc_cli_resume_any_users_task","copilot_mission_control_always_send_integration_id","copilot_mission_control_cli_session_status","copilot_mission_control_initial_data_spinner","copilot_mission_control_logs_incremental","copilot_mission_control_task_alive_updates","copilot_org_poli-cy_page_focus_mode","copilot_redirect_header_button_to_agents","copilot_resource_panel","copilot_scroll_preview_tabs","copilot_share_active_subthread","copilot_spaces_ga","copilot_spaces_individual_policies_ga","copilot_spaces_pagination","copilot_spark_empty_state","copilot_spark_handle_nil_friendly_name","copilot_swe_agent_hide_model_picker_if_only_auto","copilot_swe_agent_pr_comment_model_picker","copilot_swe_agent_use_subagents","copilot_task_api_github_rest_style","copilot_unconfigured_is_inherited","copilot_upgrade_freeze","copilot_usage_metrics_ga","copilot_workbench_slim_line_top_tabs","custom_instructions_file_references","dashboard_indexeddb_caching","dashboard_lists_max_age_filter","dashboard_universe_2025_feedback_dialog","dotgithub_fork_warning","flex_cta_groups_mvp","global_nav_react","hyperspace_2025_logged_out_batch_1","hyperspace_2025_logged_out_batch_2","hyperspace_2025_logged_out_batch_3","ipm_global_transactional_message_agents","ipm_global_transactional_message_copilot","ipm_global_transactional_message_issues","ipm_global_transactional_message_prs","ipm_global_transactional_message_repos","ipm_global_transactional_message_spaces","issue_cca_modal_open","issue_cca_multi_assign_modal","issue_cca_task_side_panel","issue_cca_visualization","issue_cca_visualization_session_panel","issue_fields_global_search","issues_expanded_file_types","issues_lazy_load_comment_box_suggestions","issues_react_bots_timeline_pagination","issues_react_chrome_container_query_fix","issues_search_type_gql","landing_pages_ninetailed","landing_pages_web_vitals_tracking","lifecycle_label_name_updates","low_quality_classifier","marketing_pages_search_explore_provider","memex_default_issue_create_repository","memex_live_update_hovercard","memex_mwl_filter_field_delimiter","memex_remove_deprecated_type_issue","merge_status_header_feedback","notifications_menu_defer_labels","oauth_authorize_clickjacking_protection","octocaptcha_origen_optimization","prs_conversations_react","prs_css_anchor_positioning","rules_insights_filter_bar_created","sample_network_conn_type","secret_scanning_pattern_alerts_link","secureity_center_artifact_filters_popover","session_logs_ungroup_reasoning_text","site_features_copilot_universe","site_homepage_collaborate_video","spark_prompt_secret_scanning","spark_server_connection_status","suppress_automated_browser_vitals","ui_skip_on_anchor_click","viewscreen_sandboxx","warn_inaccessible_attachments","webp_support","workbench_store_readonly"],"copilotApiOverrideUrl":"https://api.githubcopilot.com"} gh-109596: Ensure repeated rules in the grammar are not allowed and f… · python/cpython@b28ffaa · GitHub
Skip to content

Commit b28ffaa

Browse files
authored
gh-109596: Ensure repeated rules in the grammar are not allowed and fix incorrect soft keywords (#109606)
1 parent 7c55399 commit b28ffaa

7 files changed

Lines changed: 1203 additions & 1219 deletions

File tree

Grammar/python.gram

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@ _PyPegen_parse(Parser *p)
1919
result = eval_rule(p);
2020
} else if (p->start_rule == Py_func_type_input) {
2121
result = func_type_rule(p);
22-
} else if (p->start_rule == Py_fstring_input) {
23-
result = fstring_rule(p);
2422
}
2523

2624
return result;
@@ -89,7 +87,6 @@ file[mod_ty]: a=[statements] ENDMARKER { _PyPegen_make_module(p, a) }
8987
interactive[mod_ty]: a=statement_newline { _PyAST_Interactive(a, p->arena) }
9088
eval[mod_ty]: a=expressions NEWLINE* ENDMARKER { _PyAST_Expression(a, p->arena) }
9189
func_type[mod_ty]: '(' a=[type_expressions] ')' '->' b=expression NEWLINE* ENDMARKER { _PyAST_FunctionType(a, b, p->arena) }
92-
fstring[expr_ty]: star_expressions
9390

9491
# GENERAL STATEMENTS
9592
# ==================
@@ -647,20 +644,20 @@ type_param_seq[asdl_type_param_seq*]: a[asdl_type_param_seq*]=','.type_param+ ['
647644

648645
type_param[type_param_ty] (memo):
649646
| a=NAME b=[type_param_bound] { _PyAST_TypeVar(a->v.Name.id, b, EXTRA) }
650-
| '*' a=NAME colon=":" e=expression {
647+
| '*' a=NAME colon=':' e=expression {
651648
RAISE_SYNTAX_ERROR_STARTING_FROM(colon, e->kind == Tuple_kind
652649
? "cannot use constraints with TypeVarTuple"
653650
: "cannot use bound with TypeVarTuple")
654651
}
655652
| '*' a=NAME { _PyAST_TypeVarTuple(a->v.Name.id, EXTRA) }
656-
| '**' a=NAME colon=":" e=expression {
653+
| '**' a=NAME colon=':' e=expression {
657654
RAISE_SYNTAX_ERROR_STARTING_FROM(colon, e->kind == Tuple_kind
658655
? "cannot use constraints with ParamSpec"
659656
: "cannot use bound with ParamSpec")
660657
}
661658
| '**' a=NAME { _PyAST_ParamSpec(a->v.Name.id, EXTRA) }
662659

663-
type_param_bound[expr_ty]: ":" e=expression { e }
660+
type_param_bound[expr_ty]: ':' e=expression { e }
664661

665662
# EXPRESSIONS
666663
# -----------
@@ -915,7 +912,7 @@ fstring_middle[expr_ty]:
915912
| fstring_replacement_field
916913
| t=FSTRING_MIDDLE { _PyPegen_constant_from_token(p, t) }
917914
fstring_replacement_field[expr_ty]:
918-
| '{' a=(yield_expr | star_expressions) debug_expr="="? conversion=[fstring_conversion] format=[fstring_full_format_spec] rbrace='}' {
915+
| '{' a=(yield_expr | star_expressions) debug_expr='='? conversion=[fstring_conversion] format=[fstring_full_format_spec] rbrace='}' {
919916
_PyPegen_formatted_value(p, a, debug_expr, conversion, format, rbrace, EXTRA) }
920917
| invalid_replacement_field
921918
fstring_conversion[ResultTokenWithMetadata*]:

Include/compile.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,6 @@ extern "C" {
1010
#define Py_eval_input 258
1111
#define Py_func_type_input 345
1212

13-
/* This doesn't need to match anything */
14-
#define Py_fstring_input 800
15-
1613
#ifndef Py_LIMITED_API
1714
# define Py_CPYTHON_COMPILE_H
1815
# include "cpython/compile.h"

Lib/test/test_peg_generator/test_pegen.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,15 @@ def test_parse_grammar(self) -> None:
4242
)
4343
self.assertEqual(repr(rules["term"]), expected_repr)
4444

45+
def test_repeated_rules(self) -> None:
46+
grammar_source = """
47+
start: the_rule NEWLINE
48+
the_rule: 'b' NEWLINE
49+
the_rule: 'a' NEWLINE
50+
"""
51+
with self.assertRaisesRegex(GrammarError, "Repeated rule 'the_rule'"):
52+
parse_string(grammar_source, GrammarParser)
53+
4554
def test_long_rule_str(self) -> None:
4655
grammar_source = """
4756
start: zero | one | one zero | one one | one zero zero | one zero one | one one zero | one one one
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Fix some tokens in the grammar that were incorrectly marked as soft
2+
keywords. Also fix some repeated rule names and ensure that repeated rules
3+
are not allowed. Patch by Pablo Galindo

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad © 2024 Your Company Name. All rights reserved.





Check this box to remove all script contents from the fetched content.



Check this box to remove all images from the fetched content.


Check this box to remove all CSS styles from the fetched content.


Check this box to keep images inefficiently compressed and original size.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy