Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python 3 support #3773

Merged
merged 50 commits into from May 28, 2020
Merged

Python 3 support #3773

merged 50 commits into from May 28, 2020

Commits on May 27, 2020

  1. Enum bindings : Provide None_ overload for usage in Python 3

    Where `None` is now a keyword.
    johnhaddon committed May 27, 2020
  2. Call print() as a function

    It was a statement in Python 2, and is a function in Python 3.
    johnhaddon committed May 27, 2020
  3. Python : Use six.moves._thread for Python 3 compatibility

    `get_ident()` is available in the `threading` module in Python 3, but not in Python 2.
    johnhaddon committed May 27, 2020
  4. Replace file() with open() for Python 3 compatibility

    Also use the result as a context manager where it makes sense.
    johnhaddon committed May 27, 2020
  5. Widget : Support Python 3

    johnhaddon committed May 27, 2020
  6. OutputRedirection : Support Python 3

    This avoids `AttributeError: '_StdOut' object has no attribute 'flush'` errors.
    johnhaddon committed May 27, 2020
  7. Python app : Avoid execfile()

    It has been removed in Python 3.
    johnhaddon committed May 27, 2020
  8. Use universal_newlines = True when getting subprocess output

    This argument is ostensibly about Unix vs Windows line endings, but more importantly it uses the default encoding - as specified by `locale.getpreferredencoding()` - to convert from bytes to strings. In Python 3 we could use the much more appropriately named `text` argument, but we want something compatible with both 2 and 3, and this is it.
    johnhaddon committed May 27, 2020
  9. TaskNodeBinding : Define __qualname__ rather than __name__

    `__qualname__` was introduced in Python 3, but we are already using it by convention in Python 2 in `GafferBindings::Serialisation::classPath()`. Since Python 3 now defines it for all classes (but wrongly for our binding here), we must provide the correct value.
    johnhaddon committed May 27, 2020
  10. LocalDispatcher : Fix check for null plug

    In Python 2, our `GraphComponent.__nonzero__` override mitigated against this, but that wasn't supported in Python 3. We've now added `GraphComponent.__bool__` mitigation that works in Python 3, but since I'd already fixed this code to use the more robust check I thought it was worth keeping.
    johnhaddon committed May 27, 2020
  11. EventLoop : Fix call to traceback.format_exc()

    The first argument is optional, and should be a numeric limit, not the exception object. The exception object is implicitly the current exception. This has always been the case, but in Python 2 we got away with it and in Python 3 we got this exception :
    
    ```
      File "/disk1/john/dev/build/gafferPython3/lib/python3.7/traceback.py", line 337, in extract
        if limit >= 0:
    TypeError: '>=' not supported between instances of 'RuntimeError' and 'int'
    ```
    johnhaddon committed May 27, 2020
  12. DocumentationAlgo : UTF-8 encode strings passed to cmark

    And UTF-8 decode the results we get back. This is necessary in Python 3, where `ctypes.c_char_p` expects a `bytes` object rather than a string. CMark is [documented](https://github.com/commonmark/cmark/blob/master/src/cmark.h#L22-L28) as operating with UTF-8 encoded strings.
    johnhaddon committed May 27, 2020
  13. TextWidget/MultilineTextWidget : Fix getText() for Python 3

    See 62de6cc for the rationale for the existing cop-out for Python 2.
    johnhaddon committed May 27, 2020
  14. Graphics : Add nodeSetDrivertestMode icon

    This has always been needed by `GafferUITest.LayoutsTest.testSetNodeSetDriverRestore`, but only in Python 3 does its absence cause an actual test failure.
    johnhaddon committed May 27, 2020
  15. Python 3 : Replace inspect.getargspec() with getfullargspec()

    The former is deprecated in Python 3.
    johnhaddon committed May 27, 2020
  16. MultiSelectionMenu : Move __del/setslice__ logic to __del/setitem__

    In Python 2 `__delslice__` and `__setslice__` are deprecated and in Python 3 they are removed.
    johnhaddon committed May 27, 2020
  17. Widget : Remove unused private method

    The sole call to this was removed in 6f0ee6c, but we forgot to remove the method itself.
    johnhaddon committed May 27, 2020
  18. Appleseed Renderer : Scope log target on interactive render thread

    It turns out there's a wealth of output we've been missing all along.
    johnhaddon committed May 27, 2020