Path: csiph.com!aioe.org!bofh.it!news.nic.it!robomod From: peter green Newsgroups: linux.debian.bugs.dist,linux.debian.maint.python Subject: Bug#939181: [Help] Re: Bug#939181: cycle: Python2 removal in sid/bullseye Date: Thu, 12 Sep 2019 21:50:02 +0200 Message-ID: References: X-Mailbox-Line: From debian-bugs-dist-request@lists.debian.org Thu Sep 12 19:45:12 2019 Old-Return-Path: X-Spam-Flag: NO X-Spam-Score: -3.95 Reply-To: peter green , 939181@bugs.debian.org Resent-To: debian-bugs-dist@lists.debian.org Resent-Cc: Debian Med Packaging Team X-Debian-Pr-Message: followup 939181 X-Debian-Pr-Package: src:cycle X-Debian-Pr-Keywords: help sid bullseye X-Debian-Pr-Source: cycle X-Spam-Bayes: score:0.0000 Tokens: new, 19; hammy, 150; neutral, 74; spammy, 0. spammytokens: hammytokens:0.000-+--python3, 0.000-+--H*u:60.0, 0.000-+--Hx-spam-relays-external:!IPv6, 0.000-+--Python2, 0.000-+--H*RU:!IPv6 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.7.2 MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="------------ADFFC86D114349F8BB90CD1A" Content-Language: en-US X-Debian-Message: from BTS X-Mailing-List: archive/latest/1558303 List-ID: List-URL: Approved: robomod@news.nic.it Lines: 89 Organization: linux.* mail to news gateway Sender: robomod@news.nic.it X-Original-Date: Thu, 12 Sep 2019 20:41:51 +0100 X-Original-Message-ID: X-Original-References: Xref: csiph.com linux.debian.bugs.dist:974900 linux.debian.maint.python:11804 This is a multi-part message in MIME format. --------------ADFFC86D114349F8BB90CD1A Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit > 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 String handling changed significantly between python2 and python3. Python 2 is "byte strings by default", type "str" was used for byte strings and type "unicode" was used for unicode strings. Implicit conversions between the two were allowed. Python 3 is "unicode by default", type "bytes" is used for byte strings and type "str" is used for unicode strings. There is no implict conversion between unicode strings and byte strings. "pickle.dumps" returned a bytes object, and you tried to concatenate it to a str object. You need to change 'Cycle' to b'Cycle'. Also python 3 bytes objects behave a bit differently from python 2 str objects. To accommodate this I believe you need the following changes in p_rotor.py "|for c in map(ord, buf):|" -> "|for c in buf:|" "|return ''.join(map(chr, outbuf))|" -> "|return bytes(outbuf)|" "|for c in map(ord, key):|" -> "for c in key:" --------------ADFFC86D114349F8BB90CD1A Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: 7bit

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
String handling changed significantly between python2 and python3. Python 2 is "byte strings by default", type "str" was used for byte strings and type "unicode" was used for unicode strings. Implicit conversions between the two were allowed.

Python 3 is "unicode by default", type "bytes" is used for byte strings and type "str" is used for unicode strings. There is no implict conversion between unicode strings and byte strings.

"pickle.dumps" returned a bytes object, and you tried to concatenate it to a str object. You need to change 'Cycle' to b'Cycle'.

Also python 3 bytes objects behave a bit differently from python 2 str objects. To accommodate this I believe you need the following changes in p_rotor.py

"for c in map(ord, buf):" -> "for c in buf:"
"return ''.join(map(chr, outbuf))" -> "return bytes(outbuf)"
"for c in map(ord, key):" -> "for c in key:"

--------------ADFFC86D114349F8BB90CD1A--