Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Closed
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
2 changes: 1 addition & 1 deletion 2 Lib/importlib/_bootstrap_external.py
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,7 @@ def _write_atomic(path, data, mode=0o666):
# Whenever MAGIC_NUMBER is changed, the ranges in the magic_values array
# in PC/launcher.c must also be updated.

MAGIC_NUMBER = (3566).to_bytes(2, 'little') + b'\r\n'
MAGIC_NUMBER = (3678).to_bytes(2, 'little') + b'\r\n'

_RAW_MAGIC_NUMBER = int.from_bytes(MAGIC_NUMBER, 'little') # For import.c

Expand Down
49 changes: 19 additions & 30 deletions 49 Python/flowgraph.c
Original file line number Diff line number Diff line change
Expand Up @@ -504,6 +504,23 @@ no_redundant_jumps(cfg_builder *g) {
return true;
}

static bool
no_exits_without_lineno(basicblock *entryblock) {
for (basicblock *b = entryblock; b != NULL; b = b->b_next) {
cfg_instr *last = basicblock_last_instr(b);
if (last == NULL) {
continue;
}
if (last->i_loc.lineno < 0) {
if (last->i_opcode == RETURN_VALUE) {
assert(0);
return false;
}
}
}
return true;
}

#endif

/***** CFG preprocessing (jump targets and exceptions) *****/
Expand Down Expand Up @@ -2368,40 +2385,12 @@ propagate_line_numbers(basicblock *entryblock) {
}
}

/* Make sure that all returns have a line number, even if early passes
* have failed to propagate a correct line number.
* The resulting line number may not be correct according to PEP 626,
* but should be "good enough", and no worse than in older versions. */
static void
guarantee_lineno_for_exits(basicblock *entryblock, int firstlineno) {
int lineno = firstlineno;
assert(lineno > 0);
for (basicblock *b = entryblock; b != NULL; b = b->b_next) {
cfg_instr *last = basicblock_last_instr(b);
if (last == NULL) {
continue;
}
if (last->i_loc.lineno < 0) {
if (last->i_opcode == RETURN_VALUE) {
for (int i = 0; i < b->b_iused; i++) {
assert(b->b_instr[i].i_loc.lineno < 0);

b->b_instr[i].i_loc.lineno = lineno;
}
}
}
else {
lineno = last->i_loc.lineno;
}
}
}

static int
resolve_line_numbers(cfg_builder *g, int firstlineno)
{
RETURN_IF_ERROR(duplicate_exits_without_lineno(g));
propagate_line_numbers(g->g_entryblock);
guarantee_lineno_for_exits(g->g_entryblock, firstlineno);
RETURN_IF_ERROR(duplicate_exits_without_lineno(g));
assert(no_exits_without_lineno(g->g_entryblock));
return SUCCESS;
}

Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.