X Tutup
Skip to content

Crash when creating default config #497

@jhaarden

Description

@jhaarden

It seems pkgutil.get_data() returns a byte array, which is not accepted by file.write() in Python 3, so when a default bpython configuration file is created, bpython crashes.

As can be seen below, I am running Python 3.4 and have compiled bpython from master.

I guess that line 1071 i repl.py could be changed from:

default_config = pkgutil.get_data('bpython', ...
to:
default_config = str(pkgutil.get_data('bpython', ...

But I haven't digged deep enough into the code to see if there could be consequences regarding Python2/3 compatibility or something like that.

Config file does not exist - create new from default? (y/N) # Typed 'y'
Traceback (most recent call last):
  File "/sysroot/bin/bpython", line 9, in <module>
    load_entry_point('bpython==0.15.dev61', 'console_scripts', 'bpython')()
  File "/sysroot/lib/python3.4/site-packages/bpython/curtsies.py", line 81, in main
    interactive=(not exec_args))
  File "/sysroot/lib/python3.4/site-packages/bpython/curtsies.py", line 179, in mainloop
    process_event(e)
  File "/sysroot/lib/python3.4/site-packages/bpython/curtsies.py", line 140, in process_event
    repl.process_event(e)
  File "/sysroot/lib/python3.4/site-packages/bpython/curtsiesfrontend/repl.py", line 530, in process_event
    return self.process_key_event(e)
  File "/sysroot/lib/python3.4/site-packages/bpython/curtsiesfrontend/repl.py", line 598, in process_key_event
    return self.status_bar.process_event(e)
  File "/sysroot/lib/python3.4/site-packages/bpython/curtsiesfrontend/interaction.py", line 98, in process_event
    self.request_greenlet.switch(True)
  File "/sysroot/lib/python3.4/site-packages/bpython/repl.py", line 1079, in edit_config
    f.write(default_config)
TypeError: must be str, not bytes

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      X Tutup