Fix exception handling, and update imports

Review Request #9648 — Created Feb. 16, 2018 and submitted

Information

RBTools
master
5629bb1...

Reviewers

Remove fix exception handling, and update imports

Ran Unit tests in Python 2.7 and all passed.

Description From Last Updated

This change breaks Python 2.7. We don't want to remove the (object).

chipx86chipx86

Import groups must be in the following order, with a blank line separating each: from __future__ Python Standard Library imports …

chipx86chipx86

This line should be removed

daviddavid

Not everything in setup() can deal with having unicode strings. I'm not sure it's actually a problem in this particular …

daviddavid

Undo this change?

daviddavid
solarmist
chipx86
  1. 
      
  2. This change breaks Python 2.7. We don't want to remove the (object).

    1. This should not break anything in Python 2.7. New style classes have been around since Python 2.2. https://docs.python.org/2.5/ref/node33.html
      And support for them is completely dropped in Python 3 https://www.python.org/doc/newstyle/.

    2. I think there's some confusion on what old-style and new-style classes are.

      Old-style classes refer to the older class model in Python 1/2 that you get if you didn't inherit from object. In Python 2, these are old-style classes:

      class A():
          pass
      
      class B:
          pass
      

      Old-style classes don't allow for things like super(). For a while, many built-in Python classes, like Exception, were old-style classes, requiring that you do things like Exception.__init__(self, ...) to call parents.

      To get a new-style class in Python 2, you had to subclass object:

      class A(object):
          pass
      

      That's now implicit in Python 3, meaning that all classes are new-style classes. There's no way to get an old-style class anymore. However, if you need to preserve compatibility with Python 2, you still need to inherit from object, or you're back to using old-style classes on Python 2.

      Removing the inheritance on object will break everything.

    3. Yeah, that was my mistake. My virtualenv was setup wrong. My nosetests-2.7 -v was using Python 3.6 to run.

  3. rbtools/api/resource.py (Diff revision 1)
     
     
     
     
     
     
     
     
     
     
     
     

    Import groups must be in the following order, with a blank line separating each:

    1. from __future__
    2. Python Standard Library imports
    3. Third-party module imports
    4. Project imports

    Within each, we want import ... statements followed by from ... statements, without a blank line in-between. All must also be in alphabetical order.

    We also don't need absolute_import. Please revert those.

  4. 
      
solarmist
david
  1. Can you rebase this on top of the latest master? There's some overlap with some of the work I did.

  2. 
      
solarmist
david
  1. 
      
  2. rbtools/utils/console.py (Diff revision 3)
     
     

    This line should be removed

  3. 
      
solarmist
david
  1. 
      
  2. setup.py (Diff revision 4)
     
     

    Not everything in setup() can deal with having unicode strings. I'm not sure it's actually a problem in this particular case, but I'd feel more comfortable just leaving this file alone.

    1. Is this what you're referring to:
      https://mail.python.org/pipermail/distutils-sig/2009-September/013275.html
      https://mail.python.org/pipermail/distutils-sig/2009-September/013277.html

      It sounds like that issue was handled in Python 2.6.

      Please let me know the specifics and I can write a unit test or at least document that in the code.

    2. What breaks is anything that deals with cmdclasses and option handling. They require native strings on both Python 2.7 and 3.x. This is a common requirement across many Python modules, and in those cases is handled by doing str('blah').

      I don't see problems with the usage in setup.py here. It just needs to be tested on Python 2.7 and supported 3.x releases for all major distribution types (sdist, bdist_egg, bdist_wheel, develop).

  3. setup.py (Diff revision 4)
     
     

    Undo this change?

    1. Okay?

    2. Two blank lines between sections at the top level is standard.

  4. 
      
solarmist
david
  1. Ship It!
  2. 
      
solarmist
Review request changed

Status: Closed (submitted)

Change Summary:

Pushed to master (a7629a1)
Loading...