Add Python 3 to CI
- Jul 22, 2019
-
-
Rosen Matev authored
-
An object used in a `raise` statement must inherit from BaseException.
-
-
-
Rosen Matev authored
Dictinary iteration order is not consistent between python versions so the only practical solution is to sort.
-
It's no longer available in Python 3 (range is now a special class that, amongst other things, implements iteration).
-
Rosen Matev authored
-
-
Consider the following class definition: >>> class Foo(object): ... def __new__(cls, name, **kwargs): ... return super(Foo, cls).__new__(cls, name, **kwargs) ... ... def __init__(self, name, **kwargs): ... print(name, kwargs) ... In Python 2, this works: >>> _ = Foo('MyFoo)' ('MyFoo', {}) It doesn't in Python 3: >>> _ = Foo('MyFoo') Traceback (most recent call last): File "tst.py", line 8, in <module> Foo('MyFoo') File "tst.py", line 3, in __new__ return super(Foo, cls).__new__(cls, name, **kwargs) TypeError: object() takes no parameters What does work is to not explicitly forward the `name, **kwargs` arguments to the `super` class's `__new__` method, as this is done implicitly. >>> class Foo(object): ... def __new__(cls, name, **kwargs): ... return super(Foo, cls).__new__(cls) ... ... def __init__(self, name, **kwargs): ... print(name, kwargs) ... In Python 2 (2.6 and 2.7, at least): >>> _ = Foo('MyFoo)' ('MyFoo', {}) In Python 3: >>> _ = Foo('MyFoo)' 'MyFoo' {}
-
Rosen Matev authored
pprint in Python 3 splits long strings. This commit undoes that See https://stackoverflow.com/questions/31485402 for a useful discussion
-
Rosen Matev authored
-
-
-
Rosen Matev authored
This fixes the warnings at the end of the test jobs: ``` WARNING: GaudiKernel.test_GAUDI-905: AttributeError: 'NoneType' object has no attribute 'find' WARNING: GaudiKernel.genconf_with_custom_factory: AttributeError: 'NoneType' object has no attribute 'find' ```
-
These lines are referenced by test references, and so must appear when the print statement is made. Adding `flush=True` ensures that this is the case.
-
Rosen Matev authored
-
This implementation detail is no longer exposed in Python 3.
-
-
In the Python 3 data model, a hashable object object must define both __eq__ and __hash__. This is in contrast to Python 2, where all user-defined classes have a default implementation of __hash__ (derived from id). See and compare: https://docs.python.org/2/reference/datamodel.html https://docs.python.org/3/reference/datamodel.html
-
There is only `int` in Python 3.
-
Plus, the dict.has_key method was removed in Python 3.
-
-
file.xreadlines with deprecated in Python 2.3.
-
-
-
-
-
In Python 3, .pyc files are created in the __pycache__ directory. The Gaudi CMake logic of creating __init__.py in any directory under python/ that doesn't already have one then creates __pycache__/__init__.py. This is copied to the install area and makes folders `import`-able that should not be.
-
Plus, using `exec` for importing is not compatible with Python 3.
-
Python 2 compatible: exec "some statement" in globals_dict, locals_dict Python 2 and 3 compatible: exec("some statement", globals_dict, locals_dict)
-
patch generated by https://gitlab.cern.ch/rmatev/Gaudi/-/jobs/3588580
-
Rosen Matev authored
-
Rosen Matev authored
-
This is optional in Python 2, but mandatory in Python 3.
-
In all interaction with C++ we assume ascii encoding. The ctypes interface uses c_char_p, and we likely don't want chars above 127, which makes this is a reasonable assumption. In addition, In Python 3, methods in the subprocess module that return command output do so with the `bytes` type (because one does not know a priori what the encoding of the output of some command might be). In Python 2, the return type is `str`. For compatibility, we've just decoded all `bytes` objects to UTF-8 strings. This is an assumption on the output of the commands that are called, and may not be valid, but it does get the tests passing.
-
patch generated by https://gitlab.cern.ch/rmatev/Gaudi/-/jobs/3577070
-
Rosen Matev authored
-
Rosen Matev authored
-
Rosen Matev authored
-
Rosen Matev authored
-
-
-
-
-
Rosen Matev authored
-