Error under Python 3 in generate_encryption_key
Opened this issue · 1 comments
Under python 3.5.2, I get the following when trying to generate an encryption key:
$ ./manage.py generate_encryption_key
Traceback (most recent call last):
File "./manage.py", line 23, in
execute_from_command_line(sys.argv)
File "/home/ssharkey/.pyenv/versions/conestoga/lib/python3.5/site-packages/django/core/management/init.py", line 367, in execute_from_command_line
utility.execute()
File "/home/ssharkey/.pyenv/versions/conestoga/lib/python3.5/site-packages/django/core/management/init.py", line 359, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/home/ssharkey/.pyenv/versions/conestoga/lib/python3.5/site-packages/django/core/management/base.py", line 294, in run_from_argv
self.execute(*args, **cmd_options)
File "/home/ssharkey/.pyenv/versions/conestoga/lib/python3.5/site-packages/django/core/management/base.py", line 345, in execute
output = self.handle(*args, **options)
File "/home/ssharkey/.pyenv/versions/conestoga/lib/python3.5/site-packages/cryptographic_fields/management/commands/generate_encryption_key.py", line 12, in handle
self.stdout.write(key)
File "/home/ssharkey/.pyenv/versions/conestoga/lib/python3.5/site-packages/django/core/management/base.py", line 107, in write
if ending and not msg.endswith(ending):
TypeError: endswith first arg must be bytes or a tuple of bytes, not str
The default ending in self.write() from django's management base.py is ending='\n'
IF I change line 11 of generate_encryption_key.py to:
self.stdout.write(key, ending=b'\n')
then it works.
Exact same error using Django 2.1, Py 3.6.4 but edit did not fix. used print()
and grabbed in terminal before the exception.