Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.15-dev
2 changes: 2 additions & 0 deletions Doc/library/token-list.inc

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Grammar/Tokens
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ RARROW '->'
ELLIPSIS '...'
COLONEQUAL ':='
EXCLAMATION '!'
LFBRACE 'f{'

OP
TYPE_IGNORE
Expand Down
23 changes: 21 additions & 2 deletions Grammar/python.gram
Original file line number Diff line number Diff line change
Expand Up @@ -902,6 +902,7 @@ atom[expr_ty]:
| &'(' (genexp | tuple | group)
| &'[' (listcomp | list)
| &'{' (dictcomp | setcomp | dict | set)
| &'f{' (frozendictcomp | frozensetcomp | frozendict | frozenset)
| '...' { _PyAST_Constant(Py_Ellipsis, NULL, EXTRA) }

group[expr_ty]:
Expand Down Expand Up @@ -1023,6 +1024,8 @@ tuple[expr_ty]:

set[expr_ty]: '{' a=star_named_expressions_sequence '}' { _PyAST_Set(a, EXTRA) }

frozenset[expr_ty]: 'f{' a=star_named_expressions_sequence '}' { _PyAST_FrozenSet(a, EXTRA) }

# Dicts
# -----

Expand All @@ -1034,6 +1037,14 @@ dict[expr_ty]:
EXTRA) }
| '{' invalid_double_starred_kvpairs '}'

frozendict[expr_ty]:
| 'f{' a=[double_starred_kvpairs] '}' {
_PyAST_FrozenDict(
CHECK(asdl_expr_seq*, _PyPegen_get_keys(p, a)),
CHECK(asdl_expr_seq*, _PyPegen_get_values(p, a)),
EXTRA) }
| 'f{' invalid_double_starred_kvpairs '}'

double_starred_kvpairs[asdl_seq*]: a=','.double_starred_kvpair+ [','] { a }

double_starred_kvpair[KeyValuePair*]:
Expand Down Expand Up @@ -1064,6 +1075,10 @@ setcomp[expr_ty]:
| '{' a=star_named_expression b=for_if_clauses '}' { _PyAST_SetComp(a, b, EXTRA) }
| invalid_comprehension

frozensetcomp[expr_ty]:
| 'f{' a=star_named_expression b=for_if_clauses '}' { _PyAST_FrozenSetComp(a, b, EXTRA) }
| invalid_comprehension

genexp[expr_ty]:
| '(' a=( assignment_expression | expression !':=' | starred_expression ) b=for_if_clauses ')' { _PyAST_GeneratorExp(a, b, EXTRA) }
| invalid_comprehension
Expand All @@ -1072,6 +1087,10 @@ dictcomp[expr_ty]:
| '{' a=kvpair b=for_if_clauses '}' { _PyAST_DictComp(a->key, a->value, b, EXTRA) }
| '{' '**' a=expression b=for_if_clauses '}' { _PyAST_DictComp(a, NULL, b, EXTRA) }

frozendictcomp[expr_ty]:
| 'f{' a=kvpair b=for_if_clauses '}' { _PyAST_FrozenDictComp(a->key, a->value, b, EXTRA) }
| 'f{' '**' a=expression b=for_if_clauses '}' { _PyAST_FrozenDictComp(a, NULL, b, EXTRA) }

# FUNCTION CALL ARGUMENTS
# =======================

Expand Down Expand Up @@ -1353,10 +1372,10 @@ invalid_comprehension:
RAISE_SYNTAX_ERROR_KNOWN_RANGE(a, b, "cannot use dict unpacking in list comprehension") }
| '(' a='**' b=expression for_if_clauses {
RAISE_SYNTAX_ERROR_KNOWN_RANGE(a, b, "cannot use dict unpacking in generator expression") }
| ('[' | '{') a=star_named_expression ',' b=star_named_expressions for_if_clauses {
| ('[' | '{' | 'f{') a=star_named_expression ',' b=star_named_expressions for_if_clauses {
RAISE_SYNTAX_ERROR_KNOWN_RANGE(a, PyPegen_last_item(b, expr_ty),
"did you forget parentheses around the comprehension target?") }
| ('[' | '{') a=star_named_expression b=',' for_if_clauses {
| ('[' | '{' | 'f{') a=star_named_expression b=',' for_if_clauses {
RAISE_SYNTAX_ERROR_KNOWN_RANGE(a, b, "did you forget parentheses around the comprehension target?") }
invalid_parameters:
| a="/" ',' {
Expand Down
49 changes: 41 additions & 8 deletions Include/internal/pycore_ast.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions Include/internal/pycore_ast_state.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions Include/internal/pycore_ceval.h
Original file line number Diff line number Diff line change
Expand Up @@ -472,6 +472,12 @@ _Py_BuildMap_StackRefSteal(
_PyStackRef *arguments,
int half_args);

PyAPI_FUNC(int)
_Py_BuildSet_StackRefSteal(
PyObject *set_o,
_PyStackRef *values,
int oparg);

PyAPI_FUNC(void)
_Py_assert_within_stack_bounds(
_PyInterpreterFrame *frame, _PyStackRef *stack_pointer,
Expand Down
2 changes: 2 additions & 0 deletions Include/internal/pycore_global_objects_fini_generated.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions Include/internal/pycore_global_strings.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ extern "C" {
struct _Py_global_strings {
struct {
STRUCT_FOR_STR(anon_dictcomp, "<dictcomp>")
STRUCT_FOR_STR(anon_frozendictcomp, "<frozendictcomp>")
STRUCT_FOR_STR(anon_frozensetcomp, "<frozensetcomp>")
STRUCT_FOR_STR(anon_genexpr, "<genexpr>")
STRUCT_FOR_STR(anon_lambda, "<lambda>")
STRUCT_FOR_STR(anon_listcomp, "<listcomp>")
Expand Down
3 changes: 2 additions & 1 deletion Include/internal/pycore_magic_number.h
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,7 @@ Known values:
Python 3.16a0 3701 (Add CONSTANT_EMPTY_TUPLE to LOAD_COMMON_CONSTANT)
Python 3.16a1 3702 (Replace DELETE_NAME with PUSH_NULL; STORE_NAME)
Python 3.16a1 3703 (Replace DELETE_GLOBAL with PUSH_NULL; STORE_GLOBAL)
Python 3.16a1 3704 (Add BUILD_FROZENSET and BUILD_FROZENDICT)
Python 3.17 will start with 3750
Expand All @@ -314,7 +315,7 @@ PC/launcher.c must also be updated.
*/

#define PYC_MAGIC_NUMBER 3703
#define PYC_MAGIC_NUMBER 3704
/* This is equivalent to converting PYC_MAGIC_NUMBER to 2 bytes
(little-endian) and then appending b'\r\n'. */
#define PYC_MAGIC_NUMBER_TOKEN \
Expand Down
20 changes: 16 additions & 4 deletions Include/internal/pycore_opcode_metadata.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions Include/internal/pycore_runtime_init_generated.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion Include/internal/pycore_symtable.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,10 @@ typedef enum _comprehension_type {
ListComprehension = 1,
DictComprehension = 2,
SetComprehension = 3,
GeneratorExpression = 4 } _Py_comprehension_ty;
GeneratorExpression = 4,
FrozenDictComprehension = 5,
FrozenSetComprehension = 6,
} _Py_comprehension_ty;

/* source location information */
typedef struct {
Expand Down
29 changes: 15 additions & 14 deletions Include/internal/pycore_token.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,20 +68,21 @@ extern "C" {
#define ELLIPSIS 52
#define COLONEQUAL 53
#define EXCLAMATION 54
#define OP 55
#define TYPE_IGNORE 56
#define TYPE_COMMENT 57
#define SOFT_KEYWORD 58
#define FSTRING_START 59
#define FSTRING_MIDDLE 60
#define FSTRING_END 61
#define TSTRING_START 62
#define TSTRING_MIDDLE 63
#define TSTRING_END 64
#define COMMENT 65
#define NL 66
#define ERRORTOKEN 67
#define N_TOKENS 69
#define LFBRACE 55
#define OP 56
#define TYPE_IGNORE 57
#define TYPE_COMMENT 58
#define SOFT_KEYWORD 59
#define FSTRING_START 60
#define FSTRING_MIDDLE 61
#define FSTRING_END 62
#define TSTRING_START 63
#define TSTRING_MIDDLE 64
#define TSTRING_END 65
#define COMMENT 66
#define NL 67
#define ERRORTOKEN 68
#define N_TOKENS 70
#define NT_OFFSET 256

/* Special definitions for cooperation with parser */
Expand Down
8 changes: 8 additions & 0 deletions Include/internal/pycore_unicodeobject_generated.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading