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

Sign up
Appearance settings

'printed' question #277

Open
Open
Labels
@jsmith173

Description

My protection function starts this way, so I'm appended the results = printed line to my code and returning with safe_globals["results"] at the end of this function. Is this the correct way to collect the print messages? Sometimes I have got error messages like this

"Line 2: SyntaxError: invalid syntax at statement: 'results = printed'"
However results = printed is not in the original code.

For the follwing input for example
@__builtins__

def interpret(code, my_dict, enable_exec=True):
	"""Interprets the given python code inside a safe execution environment"""
	warnings.filterwarnings('ignore') 
	 
	code += "\nresults = printed"
	byte_code = compile_restricted(
		code,
		filename="<string>",
		mode="exec",
	)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

        AltStyle によって変換されたページ (->オリジナル) /