Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.debian.maint.python > #11784 > unrolled thread

Bug#939181: [Help] Re: Bug#939181: cycle: Python2 removal in sid/bullseye

Started byAndreas Tille <andreas@an3as.eu>
First post2019-09-11 16:20 +0200
Last post2019-09-13 12:10 +0200
Articles 7 — 4 participants

Back to article view | Back to linux.debian.maint.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  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

#11784 — Bug#939181: [Help] Re: Bug#939181: cycle: Python2 removal in sid/bullseye

FromAndreas Tille <andreas@an3as.eu>
Date2019-09-11 16:20 +0200
SubjectBug#939181: [Help] Re: Bug#939181: cycle: Python2 removal in sid/bullseye
Message-ID<yFbDr-ee-7@gated-at.bofh.it>
Control: tags -1 help

On Wed, Sep 11, 2019 at 09:33:54AM -0300, Antonio Terceiro wrote:
> E: Sub-process /usr/bin/dpkg returned an error code (1)
> ~[100]$ cycle
>   File "/usr/bin/cycle", line 29
>     if lang_find:
>                 ^
> TabError: inconsistent use of tabs and spaces in indentation

Argh.  That's fixed via autopep8 in Git[1] now.  However, when calling
cycle I get

$ cycle
Traceback (most recent call last):
  File "/usr/bin/cycle", line 12, in <module>
    from dialogs import *
  File "/usr/share/cycle/dialogs.py", line 8, in <module>
    from cal_year import cycle, Val
  File "/usr/share/cycle/cal_year.py", line 9, in <module>
    from dialogs import Note_Dlg
ImportError: cannot import name 'Note_Dlg' from 'dialogs' (/usr/share/cycle/dialogs.py)


Any idea how to fix this?

Kind regards

     Andreas.


[1]  https://salsa.debian.org/med-team/cycle

-- 
http://fam-tille.de

[toc] | [next] | [standalone]


#11785

FromAndrey Rahmatullin <wrar@debian.org>
Date2019-09-11 17:10 +0200
Message-ID<yFbWN-lQ-9@gated-at.bofh.it>
In reply to#11784

[Multipart message — attachments visible in raw view] — view raw

On Wed, Sep 11, 2019 at 04:12:34PM +0200, Andreas Tille wrote:
> Control: tags -1 help
> 
> On Wed, Sep 11, 2019 at 09:33:54AM -0300, Antonio Terceiro wrote:
> > E: Sub-process /usr/bin/dpkg returned an error code (1)
> > ~[100]$ cycle
> >   File "/usr/bin/cycle", line 29
> >     if lang_find:
> >                 ^
> > TabError: inconsistent use of tabs and spaces in indentation
> 
> Argh.  That's fixed via autopep8 in Git[1] now.  However, when calling
> cycle I get
> 
> $ cycle
> Traceback (most recent call last):
>   File "/usr/bin/cycle", line 12, in <module>
>     from dialogs import *
>   File "/usr/share/cycle/dialogs.py", line 8, in <module>
>     from cal_year import cycle, Val
>   File "/usr/share/cycle/cal_year.py", line 9, in <module>
>     from dialogs import Note_Dlg
> ImportError: cannot import name 'Note_Dlg' from 'dialogs' (/usr/share/cycle/dialogs.py)
There are circular imports in the code so you most likely broke that by
reordering imports in various files.
"from cal_year import *; from dialogs import *" works, the reverse
doesn't, so the /usr/bin/cycle code is definitely problematic, not sure
about other changes.

-- 
WBR, wRAR

[toc] | [prev] | [next] | [standalone]


#11789

FromAndreas Tille <tille@debian.org>
Date2019-09-12 09:30 +0200
Message-ID<yFryx-2BZ-1@gated-at.bofh.it>
In reply to#11785
Hi Andrey,

On Wed, Sep 11, 2019 at 07:32:33PM +0500, Andrey Rahmatullin wrote:
> > $ cycle
> > Traceback (most recent call last):
> >   File "/usr/bin/cycle", line 12, in <module>
> >     from dialogs import *
> >   File "/usr/share/cycle/dialogs.py", line 8, in <module>
> >     from cal_year import cycle, Val
> >   File "/usr/share/cycle/cal_year.py", line 9, in <module>
> >     from dialogs import Note_Dlg
> > ImportError: cannot import name 'Note_Dlg' from 'dialogs' (/usr/share/cycle/dialogs.py)
> There are circular imports in the code so you most likely broke that by
> reordering imports in various files.

s/you most likely broke/2to3 most likely broke/

I admit I did not really checked what 2to3 created but I can assure you
I did not simply fired up an editor and had fun reverting some import
sequences.

> "from cal_year import *; from dialogs import *" works, the reverse
> doesn't, so the /usr/bin/cycle code is definitely problematic, not sure
> about other changes.

I can not confirm that

   from cal_year import *

works at all.  It works in the unpatched Python2 version.

   git clone https://salsa.debian.org/med-team/cycle
   cd cycle
   echo "from cal_year import *" | python
   quilt push -a
   echo "from cal_year import *" | python3
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/andreas/debian-maintain/salsa/med-team/cycle/cal_year.py", line 9, in <module>
    from dialogs import Note_Dlg
  File "/home/andreas/debian-maintain/salsa/med-team/cycle/dialogs.py", line 12, in <module>
    from cal_year import cycle, Val
ImportError: cannot import name 'cycle' from 'cal_year' (/home/andreas/debian-maintain/salsa/med-team/cycle/cal_year.py)


So may be I misinterpreted your hint but even reverting the reordering
of 2to3 in my latest commit does not help.

Kind regards

      Andreas.

-- 
http://fam-tille.de

[toc] | [prev] | [next] | [standalone]


#11793

FromAndrey Rahmatullin <wrar@debian.org>
Date2019-09-12 11:10 +0200
Message-ID<yFt7j-3w7-9@gated-at.bofh.it>
In reply to#11789

[Multipart message — attachments visible in raw view] — view raw

On Thu, Sep 12, 2019 at 09:17:08AM +0200, Andreas Tille wrote:
> > > $ cycle
> > > Traceback (most recent call last):
> > >   File "/usr/bin/cycle", line 12, in <module>
> > >     from dialogs import *
> > >   File "/usr/share/cycle/dialogs.py", line 8, in <module>
> > >     from cal_year import cycle, Val
> > >   File "/usr/share/cycle/cal_year.py", line 9, in <module>
> > >     from dialogs import Note_Dlg
> > > ImportError: cannot import name 'Note_Dlg' from 'dialogs' (/usr/share/cycle/dialogs.py)
> > There are circular imports in the code so you most likely broke that by
> > reordering imports in various files.
> 
> s/you most likely broke/2to3 most likely broke/
2to3 doesn't do that. You mentioned autopep8, it could do that.

> > "from cal_year import *; from dialogs import *" works, the reverse
> > doesn't, so the /usr/bin/cycle code is definitely problematic, not sure
> > about other changes.
> 
> I can not confirm that
> 
>    from cal_year import *
> 
> works at all.  It works in the unpatched Python2 version.
I was just saying that (in the unpatched Python2 version) "from cal_year
import *; from dialogs import *" works, the reverse doesn't, and the
patched version contains the reverse.

>    git clone https://salsa.debian.org/med-team/cycle
>    cd cycle
>    echo "from cal_year import *" | python
>    quilt push -a
>    echo "from cal_year import *" | python3
> Traceback (most recent call last):
>   File "<stdin>", line 1, in <module>
>   File "/home/andreas/debian-maintain/salsa/med-team/cycle/cal_year.py", line 9, in <module>
>     from dialogs import Note_Dlg
>   File "/home/andreas/debian-maintain/salsa/med-team/cycle/dialogs.py", line 12, in <module>
>     from cal_year import cycle, Val
> ImportError: cannot import name 'cycle' from 'cal_year' (/home/andreas/debian-maintain/salsa/med-team/cycle/cal_year.py)
> 
> 
> So may be I misinterpreted your hint but even reverting the reordering
> of 2to3 in my latest commit does not help.
I also said that other changes may be problematic too. I didn't check
them.

-- 
WBR, wRAR

[toc] | [prev] | [next] | [standalone]


#11795 — Re: [Help] Re: Bug#939181: cycle: Python2 removal in sid/bullseye

FromAndreas Tille <andreas@an3as.eu>
Date2019-09-12 16:10 +0200
SubjectRe: [Help] Re: Bug#939181: cycle: Python2 removal in sid/bullseye
Message-ID<yFxXj-6ZH-7@gated-at.bofh.it>
In reply to#11793
On Thu, Sep 12, 2019 at 01:57:32PM +0500, Andrey Rahmatullin wrote:
> > > There are circular imports in the code so you most likely broke that by
> > > reordering imports in various files.
> > 
> > s/you most likely broke/2to3 most likely broke/
> 2to3 doesn't do that. You mentioned autopep8, it could do that.

Ahhh, well, that might be another way to mess up the sequence.  Put a
mental note to warn me about autodep8.
 
> > So may be I misinterpreted your hint but even reverting the reordering
> > of 2to3 in my latest commit does not help.
> I also said that other changes may be problematic too. I didn't check
> them.

OK, I redid the patching in git[1] now.  Some more wxPython 4 porting
was needed as well but I somehow got the user interface working.  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.

Kind regards

      Andreas.


[1] https://salsa.debian.org/med-team/cycle

-- 
http://fam-tille.de

[toc] | [prev] | [next] | [standalone]


#11803 — Re: [Help] Re: Bug#939181: cycle: Python2 removal in sid/bullseye

FromMichael Kesper <mkesper@schokokeks.org>
Date2019-09-12 21:10 +0200
SubjectRe: [Help] Re: Bug#939181: cycle: Python2 removal in sid/bullseye
Message-ID<yFCDD-1Fz-1@gated-at.bofh.it>
In reply to#11795

[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).


[toc] | [prev] | [next] | [standalone]


#11805

FromAndreas Tille <tille@debian.org>
Date2019-09-13 12:10 +0200
Message-ID<yFQGC-2ON-1@gated-at.bofh.it>
In reply to#11803
Hi,

On Thu, Sep 12, 2019 at 09:08:04PM +0200, Michael Kesper wrote:
> > 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)))

Thanks to this hint and the other hints by Peter Green, I'm now a
bit further.
 
> As an explanation:
> 
> Python 3.7.3 (default, Apr  3 2019, 05:39:12)
> ...

Thanks as well.

> 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).

I'm aware that the code is not good - there are other issues than spaces
and tabs for instance I removed an instance of os.tempnam where upstream
simply had overridden the automatic warning.  Its unmaintained upstream
as well.

I've seen other code in Debian which is not good as well.  Its rather a
philosophical question whether it is better to drop it from Debian (and
leave its users alone may be fiddling around with the upstream code
themselves) or whether we try our best to make the code at least
acceptable.  I usually subscribe to the latter and think there is no
right or wrong here.

I'm not really sure whether we might manage in this case.  After
implementing all hints I'm now stumbling upon:


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 46, in Save_Cycle
    tmp = rt.encrypt('Cycle{}'.format(pickle.dumps(objSave)))
  File "/usr/share/cycle/p_rotor.py", line 63, in encrypt
    return self.cryptmore(buf, 0)
  File "/usr/share/cycle/p_rotor.py", line 88, in cryptmore
    c = rotors[i][c ^ pos[i]]
TypeError: unsupported operand type(s) for ^: 'str' and 'int'


I think an  "int(c) ^ pos[i]"  could do here - but I'd like
to get some confirmation first.

Kind regards

     Andreas.

-- 
http://fam-tille.de

[toc] | [prev] | [standalone]


Back to top | Article view | linux.debian.maint.python


csiph-web