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

Error under Python 3 in generate_encryption_key #21

Open
lanshark opened this issue Mar 9, 2017 · 1 comment
Open

Error under Python 3 in generate_encryption_key #21

lanshark opened this issue Mar 9, 2017 · 1 comment

Comments

@lanshark
Copy link

lanshark commented Mar 9, 2017

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.

@datamafia
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants