Skip to content

gh-124022: Revert previous commits to see if they are causing build errors on AMD #124075

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
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
5 changes: 1 addition & 4 deletions Include/internal/pycore_compile.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ extern "C" {
# error "this header requires Py_BUILD_CORE define"
#endif

#include <stdbool.h>

#include "pycore_ast.h" // mod_ty
#include "pycore_symtable.h" // _Py_SourceLocation
#include "pycore_instruction_sequence.h"
Expand Down Expand Up @@ -174,8 +172,7 @@ int _PyCompile_AddDeferredAnnotaion(struct _PyCompiler *c, stmt_ty s);
int _PyCodegen_AddReturnAtEnd(struct _PyCompiler *c, int addNone);
int _PyCodegen_EnterAnonymousScope(struct _PyCompiler* c, mod_ty mod);
int _PyCodegen_Expression(struct _PyCompiler *c, expr_ty e);
int _PyCodegen_Body(struct _PyCompiler *c, _Py_SourceLocation loc, asdl_stmt_seq *stmts,
bool is_interactive);
int _PyCodegen_Body(struct _PyCompiler *c, _Py_SourceLocation loc, asdl_stmt_seq *stmts);

/* Utility for a number of growing arrays used in the compiler */
int _PyCompile_EnsureArrayLargeEnough(
Expand Down
35 changes: 6 additions & 29 deletions Lib/test/test_compile.py
Original file line number Diff line number Diff line change
Expand Up @@ -902,28 +902,6 @@ def with_const_expression():
self.assertIsNone(ns['with_fstring'].__doc__)
self.assertIsNone(ns['with_const_expression'].__doc__)

@support.cpython_only
def test_docstring_interactive_mode(self):
srcs = [
"""def with_docstring():
"docstring"
""",
"""class with_docstring:
"docstring"
""",
]

for opt in [0, 1, 2]:
for src in srcs:
with self.subTest(opt=opt, src=src):
code = compile(textwrap.dedent(src), "<test>", "single", optimize=opt)
ns = {}
exec(code, ns)
if opt < 2:
self.assertEqual(ns['with_docstring'].__doc__, "docstring")
else:
self.assertIsNone(ns['with_docstring'].__doc__)

@support.cpython_only
def test_docstring_omitted(self):
# See gh-115347
Expand All @@ -941,13 +919,12 @@ class C:
return h
""")
for opt in [-1, 0, 1, 2]:
for mode in ["exec", "single"]:
with self.subTest(opt=opt, mode=mode):
code = compile(src, "<test>", mode, optimize=opt)
output = io.StringIO()
with contextlib.redirect_stdout(output):
dis.dis(code)
self.assertNotIn('NOP', output.getvalue())
with self.subTest(opt=opt):
code = compile(src, "<test>", "exec", optimize=opt)
output = io.StringIO()
with contextlib.redirect_stdout(output):
dis.dis(code)
self.assertNotIn('NOP' , output.getvalue())

def test_dont_merge_constants(self):
# Issue #25843: compile() must not merge constants which are equal
Expand Down

This file was deleted.

6 changes: 3 additions & 3 deletions Python/codegen.c
Original file line number Diff line number Diff line change
Expand Up @@ -746,7 +746,7 @@ _PyCodegen_Expression(compiler *c, expr_ty e)
and for annotations. */

int
_PyCodegen_Body(compiler *c, location loc, asdl_stmt_seq *stmts, bool is_interactive)
_PyCodegen_Body(compiler *c, location loc, asdl_stmt_seq *stmts)
{
/* If from __future__ import annotations is active,
* every annotated class and module should have __annotations__.
Expand All @@ -758,7 +758,7 @@ _PyCodegen_Body(compiler *c, location loc, asdl_stmt_seq *stmts, bool is_interac
return SUCCESS;
}
Py_ssize_t first_instr = 0;
if (!is_interactive) { /* A string literal on REPL prompt is not a docstring */
if (!IS_INTERACTIVE(c)) {
PyObject *docstring = _PyAST_GetDocString(stmts);
if (docstring) {
first_instr = 1;
Expand Down Expand Up @@ -1432,7 +1432,7 @@ codegen_class_body(compiler *c, stmt_ty s, int firstlineno)
ADDOP_N_IN_SCOPE(c, loc, STORE_DEREF, &_Py_ID(__classdict__), cellvars);
}
/* compile the body proper */
RETURN_IF_ERROR_IN_SCOPE(c, _PyCodegen_Body(c, loc, s->v.ClassDef.body, false));
RETURN_IF_ERROR_IN_SCOPE(c, _PyCodegen_Body(c, loc, s->v.ClassDef.body));
PyObject *static_attributes = _PyCompile_StaticAttributesAsTuple(c);
if (static_attributes == NULL) {
_PyCompile_ExitScope(c);
Expand Down
4 changes: 2 additions & 2 deletions Python/compile.c
Original file line number Diff line number Diff line change
Expand Up @@ -790,13 +790,13 @@ compiler_codegen(compiler *c, mod_ty mod)
switch (mod->kind) {
case Module_kind: {
asdl_stmt_seq *stmts = mod->v.Module.body;
RETURN_IF_ERROR(_PyCodegen_Body(c, start_location(stmts), stmts, false));
RETURN_IF_ERROR(_PyCodegen_Body(c, start_location(stmts), stmts));
break;
}
case Interactive_kind: {
c->c_interactive = 1;
asdl_stmt_seq *stmts = mod->v.Interactive.body;
RETURN_IF_ERROR(_PyCodegen_Body(c, start_location(stmts), stmts, true));
RETURN_IF_ERROR(_PyCodegen_Body(c, start_location(stmts), stmts));
break;
}
case Expression_kind: {
Expand Down
Loading