Skip to content

Commit 781590d

Browse files
committed
Merge remote-tracking branch 'upstream/main' into pythongh-116168-remove-extra-_check_stack_space-ops
2 parents 1b1d8e1 + 48c0b05 commit 781590d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+2785
-1618
lines changed

.pre-commit-config.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
repos:
22
- repo: https://github.com/astral-sh/ruff-pre-commit
3-
rev: v0.2.0
3+
rev: v0.3.4
44
hooks:
55
- id: ruff
66
name: Run Ruff on Lib/test/
@@ -14,6 +14,8 @@ repos:
1414
- repo: https://github.com/pre-commit/pre-commit-hooks
1515
rev: v4.5.0
1616
hooks:
17+
- id: check-case-conflict
18+
- id: check-merge-conflict
1719
- id: check-toml
1820
exclude: ^Lib/test/test_tomllib/
1921
- id: check-yaml

Doc/tools/templates/indexcontent.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,11 @@ <h1>{{ docstitle|e }}</h1>
5858
<td width="50%">
5959
<p class="biglink"><a class="biglink" href="{{ pathto("bugs") }}">{% trans %}Reporting issues{% endtrans %}</a></p>
6060
<p class="biglink"><a class="biglink" href="https://devguide.python.org/docquality/#helping-with-documentation">{% trans %}Contributing to Docs{% endtrans %}</a></p>
61-
<p class="biglink"><a class="biglink" href="{{ pathto("about") }}">{% trans %}About the documentation{% endtrans %}</a></p>
61+
<p class="biglink"><a class="biglink" href="{{ pathto("download") }}">{% trans %}Download the documentation{% endtrans %}</a></p>
6262
</td><td width="50%">
6363
<p class="biglink"><a class="biglink" href="{{ pathto("license") }}">{% trans %}History and license of Python{% endtrans %}</a></p>
6464
<p class="biglink"><a class="biglink" href="{{ pathto("copyright") }}">{% trans %}Copyright{% endtrans %}</a></p>
65-
<p class="biglink"><a class="biglink" href="{{ pathto("download") }}">{% trans %}Download the documentation{% endtrans %}</a></p>
65+
<p class="biglink"><a class="biglink" href="{{ pathto("about") }}">{% trans %}About the documentation{% endtrans %}</a></p>
6666
</td></tr>
6767
</table>
6868
{% endblock %}

Grammar/python.gram

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -778,6 +778,7 @@ bitwise_and[expr_ty]:
778778
shift_expr[expr_ty]:
779779
| a=shift_expr '<<' b=sum { _PyAST_BinOp(a, LShift, b, EXTRA) }
780780
| a=shift_expr '>>' b=sum { _PyAST_BinOp(a, RShift, b, EXTRA) }
781+
| invalid_arithmetic
781782
| sum
782783

783784
# Arithmetic operators
@@ -794,6 +795,7 @@ term[expr_ty]:
794795
| a=term '//' b=factor { _PyAST_BinOp(a, FloorDiv, b, EXTRA) }
795796
| a=term '%' b=factor { _PyAST_BinOp(a, Mod, b, EXTRA) }
796797
| a=term '@' b=factor { CHECK_VERSION(expr_ty, 5, "The '@' operator is", _PyAST_BinOp(a, MatMult, b, EXTRA)) }
798+
| invalid_factor
797799
| factor
798800

799801
factor[expr_ty] (memo):
@@ -1415,3 +1417,8 @@ invalid_replacement_field:
14151417
invalid_conversion_character:
14161418
| '!' &(':' | '}') { RAISE_SYNTAX_ERROR_ON_NEXT_TOKEN("f-string: missing conversion character") }
14171419
| '!' !NAME { RAISE_SYNTAX_ERROR_ON_NEXT_TOKEN("f-string: invalid conversion character") }
1420+
1421+
invalid_arithmetic:
1422+
| sum ('+'|'-'|'*'|'/'|'%'|'//'|'@') a='not' b=inversion { RAISE_SYNTAX_ERROR_KNOWN_RANGE(a, b, "'not' after an operator must be parenthesized") }
1423+
invalid_factor:
1424+
| ('+' | '-' | '~') a='not' b=factor { RAISE_SYNTAX_ERROR_KNOWN_RANGE(a, b, "'not' after an operator must be parenthesized") }

Include/cpython/optimizer.h

Lines changed: 49 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,16 +30,63 @@ typedef struct {
3030
PyCodeObject *code; // Weak (NULL if no corresponding ENTER_EXECUTOR).
3131
} _PyVMData;
3232

33+
#define UOP_FORMAT_TARGET 0
34+
#define UOP_FORMAT_EXIT 1
35+
#define UOP_FORMAT_JUMP 2
36+
#define UOP_FORMAT_UNUSED 3
37+
38+
/* Depending on the format,
39+
* the 32 bits between the oparg and operand are:
40+
* UOP_FORMAT_TARGET:
41+
* uint32_t target;
42+
* UOP_FORMAT_EXIT
43+
* uint16_t exit_index;
44+
* uint16_t error_target;
45+
* UOP_FORMAT_JUMP
46+
* uint16_t jump_target;
47+
* uint16_t error_target;
48+
*/
3349
typedef struct {
34-
uint16_t opcode;
50+
uint16_t opcode:14;
51+
uint16_t format:2;
3552
uint16_t oparg;
3653
union {
3754
uint32_t target;
38-
uint32_t exit_index;
55+
struct {
56+
union {
57+
uint16_t exit_index;
58+
uint16_t jump_target;
59+
};
60+
uint16_t error_target;
61+
};
3962
};
4063
uint64_t operand; // A cache entry
4164
} _PyUOpInstruction;
4265

66+
static inline uint32_t uop_get_target(const _PyUOpInstruction *inst)
67+
{
68+
assert(inst->format == UOP_FORMAT_TARGET);
69+
return inst->target;
70+
}
71+
72+
static inline uint16_t uop_get_exit_index(const _PyUOpInstruction *inst)
73+
{
74+
assert(inst->format == UOP_FORMAT_EXIT);
75+
return inst->exit_index;
76+
}
77+
78+
static inline uint16_t uop_get_jump_target(const _PyUOpInstruction *inst)
79+
{
80+
assert(inst->format == UOP_FORMAT_JUMP);
81+
return inst->jump_target;
82+
}
83+
84+
static inline uint16_t uop_get_error_target(const _PyUOpInstruction *inst)
85+
{
86+
assert(inst->format != UOP_FORMAT_TARGET);
87+
return inst->error_target;
88+
}
89+
4390
typedef struct _exit_data {
4491
uint32_t target;
4592
int16_t temperature;

Include/internal/pycore_gc.h

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,19 @@ static inline void _PyObject_GC_SET_SHARED_INLINE(PyObject *op) {
113113
/* Bit 1 is set when the object is in generation which is GCed currently. */
114114
#define _PyGC_PREV_MASK_COLLECTING 2
115115

116-
/* Bit 0 is set if the object belongs to old space 1 */
116+
/* Bit 0 in _gc_next is the old space bit.
117+
* It is set as follows:
118+
* Young: gcstate->visited_space
119+
* old[0]: 0
120+
* old[1]: 1
121+
* permanent: 0
122+
*
123+
* During a collection all objects handled should have the bit set to
124+
* gcstate->visited_space, as objects are moved from the young gen
125+
* and the increment into old[gcstate->visited_space].
126+
* When object are moved from the pending space, old[gcstate->visited_space^1]
127+
* into the increment, the old space bit is flipped.
128+
*/
117129
#define _PyGC_NEXT_MASK_OLD_SPACE_1 1
118130

119131
#define _PyGC_PREV_SHIFT 2

Include/internal/pycore_global_objects_fini_generated.h

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Include/internal/pycore_global_strings.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,7 @@ struct _Py_global_strings {
213213
STRUCT_FOR_ID(__slotnames__)
214214
STRUCT_FOR_ID(__slots__)
215215
STRUCT_FOR_ID(__spec__)
216+
STRUCT_FOR_ID(__static_attributes__)
216217
STRUCT_FOR_ID(__str__)
217218
STRUCT_FOR_ID(__sub__)
218219
STRUCT_FOR_ID(__subclasscheck__)

Include/internal/pycore_object.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -318,8 +318,8 @@ static inline void _PyObject_GC_TRACK(
318318
PyGC_Head *last = (PyGC_Head*)(generation0->_gc_prev);
319319
_PyGCHead_SET_NEXT(last, gc);
320320
_PyGCHead_SET_PREV(gc, last);
321-
_PyGCHead_SET_NEXT(gc, generation0);
322-
assert((gc->_gc_next & _PyGC_NEXT_MASK_OLD_SPACE_1) == 0);
321+
/* Young objects will be moved into the visited space during GC, so set the bit here */
322+
gc->_gc_next = ((uintptr_t)generation0) | interp->gc.visited_space;
323323
generation0->_gc_prev = (uintptr_t)gc;
324324
#endif
325325
}

0 commit comments

Comments
 (0)