Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.debian.maint.python > #11803
| From | Michael Kesper <mkesper@schokokeks.org> |
|---|---|
| Newsgroups | linux.debian.maint.python |
| Subject | Re: [Help] Re: Bug#939181: cycle: Python2 removal in sid/bullseye |
| Date | 2019-09-12 21:10 +0200 |
| Message-ID | <yFCDD-1Fz-1@gated-at.bofh.it> (permalink) |
| References | (2 earlier) <yFbDr-ee-7@gated-at.bofh.it> <yFbWN-lQ-9@gated-at.bofh.it> <yFryx-2BZ-1@gated-at.bofh.it> <yFt7j-3w7-9@gated-at.bofh.it> <yFxXj-6ZH-7@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
[Multipart message — attachments visible in raw view] - view raw
Hi,
On 12.09.19 16:09, Andreas Tille wrote:
> May be some final helping hint could be how to fix leaving the
> program that leads to:
>
>
> Traceback (most recent call last): File "/usr/bin/cycle", line 83,
> in OnCloseWindow Save_Cycle(cycle.name, cycle.passwd, cycle.file)
> File "/usr/share/cycle/save_load.py", line 27, in Save_Cycle
> m.update(passwd) TypeError: Unicode-objects must be encoded before
> hashing
>
>
> I tried
>
> m.update(passwd.encode())
>
> but this leads later to
>
> Traceback (most recent call last): File "cycle.py", line 83, in
> OnCloseWindow Save_Cycle(cycle.name, cycle.passwd, cycle.file) File
> "/home/andreas/debian-maintain/salsa/med-team/cycle/save_load.py",
> line 46, in Save_Cycle tmp=rt.encrypt( 'Cycle'+pickle.dumps(objSave)
> ) TypeError: can only concatenate str (not "bytes") to str
>
>
> Since I do not have much experience with hashlib I'd be happy if
> someone might be able to proof-read `def Save_Cycle` in
> save_load.py.
This does not have anything to do with hashlib per se.
It's just the usual mess of mixing bytestrings with strings.
You often don't notice in Python2, it just introduces subtle bugs.
Python3 is more strict here and doesn't allow it.
Try this:
tmp = rt.encrypt('Cycle{}'.format(pickle.dumps(objSave)))
As an explanation:
Python 3.7.3 (default, Apr 3 2019, 05:39:12)
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import pickle
>>> s = 'abc123üöß'
>>> objSave = pickle.dumps(s)
>>> objSave
b'\x80\x03X\x0c\x00\x00\x00abc123\xc3\xbc\xc3\xb6\xc3\x9fq\x00.'
>>> type(objSave)
<class 'bytes'>
>>> print('Cycle'+pickle.dumps(objSave))
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: can only concatenate str (not "bytes") to str
>>> print('Cycle{}'.format(pickle.dumps(objSave)))
Cycleb'\x80\x03C\x16\x80\x03X\x0c\x00\x00\x00abc123\xc3\xbc\xc3\xb6\xc3\x9fq\x00.q\x00.'
Best wishes
Michael
P.S.: The code is in a bad state regarding whitespace / indentation.
This is critical to get right in Python (e.g. after a for there _has to_
be an indentation added, Python normally uses four spaces, no tabs).
Back to linux.debian.maint.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Bug#939181: [Help] Re: Bug#939181: cycle: Python2 removal in sid/bullseye Andreas Tille <andreas@an3as.eu> - 2019-09-11 16:20 +0200
Bug#939181: [Help] Re: Bug#939181: cycle: Python2 removal in sid/bullseye Andrey Rahmatullin <wrar@debian.org> - 2019-09-11 17:10 +0200
Bug#939181: [Help] Re: Bug#939181: cycle: Python2 removal in sid/bullseye Andreas Tille <tille@debian.org> - 2019-09-12 09:30 +0200
Bug#939181: [Help] Re: Bug#939181: cycle: Python2 removal in sid/bullseye Andrey Rahmatullin <wrar@debian.org> - 2019-09-12 11:10 +0200
Re: [Help] Re: Bug#939181: cycle: Python2 removal in sid/bullseye Andreas Tille <andreas@an3as.eu> - 2019-09-12 16:10 +0200
Re: [Help] Re: Bug#939181: cycle: Python2 removal in sid/bullseye Michael Kesper <mkesper@schokokeks.org> - 2019-09-12 21:10 +0200
Bug#939181: [Help] Re: Bug#939181: cycle: Python2 removal in sid/bullseye Andreas Tille <tille@debian.org> - 2019-09-13 12:10 +0200
csiph-web