On 15/06/2021 14:24, Florian Bezdeka wrote:
> On 15.06.21 12:44, Ralf Ramsauer wrote:
>>
>>
>> On 15/06/2021 11:32, Florian Bezdeka wrote:
>>> We are now calling pyhton3 via shebang, so no need to care about
>>
>> python3
>
> Thanks!
>
>>
>>> python2 anymore.
>>>
>>> Signed-off-by: Florian Bezdeka <[email protected]>
>>> ---
>>> pyjailhouse/config_parser.py | 1 -
>>> pyjailhouse/extendedenum.py | 12 ------------
>>> scripts/arm64-parsedump.py | 1 -
>>> tools/jailhouse-cell-linux | 1 -
>>> tools/jailhouse-cell-stats | 1 -
>>> tools/jailhouse-config-check | 1 -
>>> tools/jailhouse-config-create | 1 -
>>> tools/jailhouse-hardware-check | 5 -----
>>> 8 files changed, 23 deletions(-)
>>>
>>> diff --git a/pyjailhouse/config_parser.py b/pyjailhouse/config_parser.py
>>> index cad761a5..7a7f48a3 100644
>>> --- a/pyjailhouse/config_parser.py
>>> +++ b/pyjailhouse/config_parser.py
>>> @@ -14,7 +14,6 @@
>>> # information about the system. For more advanced scenarios you will have
>>> # to change the generated C-code.
>>>
>>> -from __future__ import print_function
>>> import struct
>>>
>>> from .extendedenum import ExtendedEnum
>>> diff --git a/pyjailhouse/extendedenum.py b/pyjailhouse/extendedenum.py
>>> index f3dd1bb9..9d6043a4 100644
>>> --- a/pyjailhouse/extendedenum.py
>>> +++ b/pyjailhouse/extendedenum.py
>>> @@ -9,18 +9,6 @@
>>> # This work is licensed under the terms of the GNU GPL, version 2. See
>>> # the COPYING file in the top-level directory.
>>>
>>> -# Python 2 and 3 have different ways of handling metaclasses. This
>>> decorator
>>> -# is a support layer for both and can be removed once Python 2 is no longer
>>> -# supported.
>>> -def with_metaclass(meta):
>>> - def decorator(cls):
>>> - body = vars(cls).copy()
>>> - body.pop('__dict__', None)
>>> - body.pop('__weakref__', None)
>>> - return meta(cls.__name__, cls.__bases__, body)
>>> - return decorator
>>> -
>>> -
>>
>> Did you actually test and run jailhouse-config-create? I guess this
>> should fail, because there are users of with_metaclass that need to be
>> addressed.
>
> Yes, that was tested. But as it turned out there seems to be something
> wrong with my local test env. Generation "works" but output looks quite
> funny.
>
> As I'm running out of time I will no longer take care of that strange
> Enum type. I will resend v3 without touching ExtendedEnum.
It's not that strange, it got strange, when dealing with python2
compatibility. Using Metaclasses have diffent syntax in Python[23]. The
dance was required to have one common piece of code that does the same
thing under both versions.
Could you please check the following patch:
diff --git a/pyjailhouse/extendedenum.py b/pyjailhouse/extendedenum.py
index f3dd1bb9..799f8c62 100644
--- a/pyjailhouse/extendedenum.py
+++ b/pyjailhouse/extendedenum.py
@@ -9,25 +9,13 @@
# This work is licensed under the terms of the GNU GPL, version 2. See
# the COPYING file in the top-level directory.
-# Python 2 and 3 have different ways of handling metaclasses. This
decorator
-# is a support layer for both and can be removed once Python 2 is no longer
-# supported.
-def with_metaclass(meta):
- def decorator(cls):
- body = vars(cls).copy()
- body.pop('__dict__', None)
- body.pop('__weakref__', None)
- return meta(cls.__name__, cls.__bases__, body)
- return decorator
-
class ExtendedEnumMeta(type):
def __getattr__(cls, key):
return cls(cls._ids[key])
-@with_metaclass(ExtendedEnumMeta)
-class ExtendedEnum:
+class ExtendedEnum(metaclass=ExtendedEnumMeta):
def __init__(self, value):
self.value = value
I think that should work. Feel free to add my Signed-off.
Thanks
Ralf
>
> Stared some minutes on that "Enum" but unable to figure out why it is
> implemented this way and where the difference to plain "Enum" is. I
> guess there are some python2 specifics I simply dont't know.
>
>>
>> Thanks
>> Ralf
>>
>>> class ExtendedEnumMeta(type):
>>> def __getattr__(cls, key):
>>> return cls(cls._ids[key])
>>> diff --git a/scripts/arm64-parsedump.py b/scripts/arm64-parsedump.py
>>> index c695706f..54f4fd66 100755
>>> --- a/scripts/arm64-parsedump.py
>>> +++ b/scripts/arm64-parsedump.py
>>> @@ -14,7 +14,6 @@
>>> # the COPYING file in the top-level directory.
>>>
>>>
>>> -from __future__ import print_function
>>> import subprocess
>>> import sys
>>> import fileinput
>>> diff --git a/tools/jailhouse-cell-linux b/tools/jailhouse-cell-linux
>>> index 6d1743f3..a1650912 100755
>>> --- a/tools/jailhouse-cell-linux
>>> +++ b/tools/jailhouse-cell-linux
>>> @@ -10,7 +10,6 @@
>>> # This work is licensed under the terms of the GNU GPL, version 2. See
>>> # the COPYING file in the top-level directory.
>>>
>>> -from __future__ import print_function
>>> import argparse
>>> import gzip
>>> import os
>>> diff --git a/tools/jailhouse-cell-stats b/tools/jailhouse-cell-stats
>>> index 4c5289fb..7a634212 100755
>>> --- a/tools/jailhouse-cell-stats
>>> +++ b/tools/jailhouse-cell-stats
>>> @@ -10,7 +10,6 @@
>>> # This work is licensed under the terms of the GNU GPL, version 2. See
>>> # the COPYING file in the top-level directory.
>>>
>>> -from __future__ import print_function
>>> import curses
>>> import datetime
>>> import os
>>> diff --git a/tools/jailhouse-config-check b/tools/jailhouse-config-check
>>> index 62db24c3..d6ea7079 100755
>>> --- a/tools/jailhouse-config-check
>>> +++ b/tools/jailhouse-config-check
>>> @@ -15,7 +15,6 @@
>>> # information about the system. For more advanced scenarios you will have
>>> # to change the generated C-code.
>>>
>>> -from __future__ import print_function
>>> import argparse
>>> import os
>>> import sys
>>> diff --git a/tools/jailhouse-config-create b/tools/jailhouse-config-create
>>> index 2095f4e2..c2cd5952 100755
>>> --- a/tools/jailhouse-config-create
>>> +++ b/tools/jailhouse-config-create
>>> @@ -18,7 +18,6 @@
>>> # information about the system. For more advanced scenarios you will have
>>> # to change the generated C-code.
>>>
>>> -from __future__ import print_function
>>> import sys
>>> import os
>>> import math
>>> diff --git a/tools/jailhouse-hardware-check b/tools/jailhouse-hardware-check
>>> index 7a41b48e..fc8ce4f1 100755
>>> --- a/tools/jailhouse-hardware-check
>>> +++ b/tools/jailhouse-hardware-check
>>> @@ -10,7 +10,6 @@
>>> # This work is licensed under the terms of the GNU GPL, version 2. See
>>> # the COPYING file in the top-level directory.
>>>
>>> -from __future__ import print_function
>>> import mmap
>>> import os
>>> import struct
>>> @@ -20,10 +19,6 @@ import sys
>>> sys.path[0] = os.path.dirname(os.path.abspath(__file__)) + "/.."
>>> import pyjailhouse.sysfs_parser as sysfs_parser
>>>
>>> -# just a dummy to make python2 happy
>>> -if sys.version_info[0] < 3:
>>> - class PermissionError(OSError):
>>> - pass
>>>
>>> check_passed = True
>>> ran_all = True
>>>
>
>
--
You received this message because you are subscribed to the Google Groups
"Jailhouse" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/jailhouse-dev/89c6f195-39b9-557e-761f-d12e6f3fbf60%40oth-regensburg.de.