Skip to content
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

fix broken sys.stdout.write on modern python #12

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
12 changes: 5 additions & 7 deletions tinyboot.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@
interpreting its text, given that initial state.

"""
import sys, cgitb
cgitb.enable(format='text')
import sys

def debug(text):
sys.stderr.write(text + "\n")
Expand Down Expand Up @@ -171,8 +170,7 @@ def write_out():
count = stack.pop()
address = stack.pop()
debug('writing address %d, count %d' % (address, count))
sys.stdout.write(''.join([chr(memory[ii])
for ii in range(address, address+count)]))
sys.stdout.buffer.write(bytes(memory[address:address+count]))

def quit():
sys.exit(0)
Expand Down Expand Up @@ -274,11 +272,11 @@ def tbfrun():
while True:
run_time_dispatch[get_token()]()

def main(infile):
def main():
global program
program = infile.read()
with open(sys.argv[1], 'r') as infile: program = infile.read()
tbfcompile()
tbfrun()
assert False, "tbfrun returned"

if __name__ == '__main__': main(file(sys.argv[1]))
if __name__ == '__main__': main()