Skip to content

Commit

Permalink
Merge pull request #352 from 0x0elliot/0x0elliot/weird_print_bug
Browse files Browse the repository at this point in the history
Fixing #351: Overwriting the existing print() statement
  • Loading branch information
frikky committed Jul 3, 2023
2 parents 985e380 + b0dde8d commit d3ae697
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions shuffle-tools/1.2.0/src/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -529,10 +529,14 @@ def execute_python(self, code):
# 2. Subprocess execute file?
try:
f = StringIO()
with redirect_stdout(f):
exec(code) # nosec :(
def custom_print(*args, **kwargs):
return print(*args, file=f, **kwargs)

with redirect_stdout(f): # just in case
exec(code, {"print": custom_print})

s = f.getvalue()
f.close() # why: https://www.youtube.com/watch?v=6SA6S9Ca5-U

#try:
# s = s.encode("utf-8")
Expand Down

0 comments on commit d3ae697

Please sign in to comment.