Skip to contentSkip to conversation

checkpackagelib: fix Python3 execution

PATCH New Thomas De Schampheleire 2 participants 4 messages Jan 10, 2019 – Jan 11, 2019

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 checkpackagelib: fix Python3 execution

From: Thomas De Schampheleire <[email protected]>

The relative imports do not work in Python 3. Adding the leading dot works both in Python2 and Python3.

This may cause problems if ever you would try to call the helper .py files directly, but this is not currently needed/supported.

---
 utils/checkpackagelib/lib.py        |  2 +-
 utils/checkpackagelib/lib_config.py | 10 +++++-----
 utils/checkpackagelib/lib_hash.py   | 10 +++++-----
 utils/checkpackagelib/lib_mk.py     | 10 +++++-----
 utils/checkpackagelib/lib_patch.py  |  4 ++--
 5 files changed, 18 insertions(+), 18 deletions(-)
utils/checkpackagelib/lib.py +1 -1
index 91f4ad49b7..06b147a470 100644
@@ -1,6 +1,6 @@
 # See utils/checkpackagelib/readme.txt before editing this file.
 
-from base import _CheckFunction
+from .base import _CheckFunction
 
 
 class ConsecutiveEmptyLines(_CheckFunction):
utils/checkpackagelib/lib_config.py +5 -5
index 1d273f1c5f..f6dc583a08 100644
@@ -5,11 +5,11 @@
 
 import re
 
-from base import _CheckFunction
-from lib import ConsecutiveEmptyLines  # noqa: F401
-from lib import EmptyLastLine          # noqa: F401
-from lib import NewlineAtEof           # noqa: F401
-from lib import TrailingSpace          # noqa: F401
+from .base import _CheckFunction
+from .lib import ConsecutiveEmptyLines  # noqa: F401
+from .lib import EmptyLastLine          # noqa: F401
+from .lib import NewlineAtEof           # noqa: F401
+from .lib import TrailingSpace          # noqa: F401
 
 
 def _empty_or_comment(text):
utils/checkpackagelib/lib_hash.py +5 -5
index 6d4cc9fd62..3ddd88bae9 100644
@@ -5,11 +5,11 @@
 
 import re
 
-from base import _CheckFunction
-from lib import ConsecutiveEmptyLines  # noqa: F401
-from lib import EmptyLastLine          # noqa: F401
-from lib import NewlineAtEof           # noqa: F401
-from lib import TrailingSpace          # noqa: F401
+from .base import _CheckFunction
+from .lib import ConsecutiveEmptyLines  # noqa: F401
+from .lib import EmptyLastLine          # noqa: F401
+from .lib import NewlineAtEof           # noqa: F401
+from .lib import TrailingSpace          # noqa: F401
 
 
 def _empty_line_or_comment(text):
utils/checkpackagelib/lib_mk.py +5 -5
index 0e430a2f12..857d7b16ad 100644
@@ -6,11 +6,11 @@
 
 import re
 
-from base import _CheckFunction
-from lib import ConsecutiveEmptyLines  # noqa: F401
-from lib import EmptyLastLine          # noqa: F401
-from lib import NewlineAtEof           # noqa: F401
-from lib import TrailingSpace          # noqa: F401
+from .base import _CheckFunction
+from .lib import ConsecutiveEmptyLines  # noqa: F401
+from .lib import EmptyLastLine          # noqa: F401
+from .lib import NewlineAtEof           # noqa: F401
+from .lib import TrailingSpace          # noqa: F401
 
 
 class Indent(_CheckFunction):
utils/checkpackagelib/lib_patch.py +2 -2
index 555621afa1..4b1b48e6ca 100644
@@ -5,8 +5,8 @@
 
 import re
 
-from base import _CheckFunction
-from lib import NewlineAtEof           # noqa: F401
+from .base import _CheckFunction
+from .lib import NewlineAtEof           # noqa: F401
 
 
 class ApplyOrder(_CheckFunction):
Signature · 1 line
2.18.1
#1 lore raw

PATCH 1/1 checkpackagelib: fix Python3 execution

El jue., 10 ene. 2019 a las 21:52, Thomas De Schampheleire (<[email protected]>) escribi?:

Quoted 23 lines

From: Thomas De Schampheleire <[email protected]>

The relative imports do not work in Python 3. Adding the leading dot works both in Python2 and Python3.

This may cause problems if ever you would try to call the helper .py files directly, but this is not currently needed/supported.

---
 utils/checkpackagelib/lib.py        |  2 +-
 utils/checkpackagelib/lib_config.py | 10 +++++-----
 utils/checkpackagelib/lib_hash.py   | 10 +++++-----
 utils/checkpackagelib/lib_mk.py     | 10 +++++-----
 utils/checkpackagelib/lib_patch.py  |  4 ++--
 5 files changed, 18 insertions(+), 18 deletions(-)
utils/checkpackagelib/lib.py +0 -0
index 91f4ad49b7..06b147a470 100644

utils/checkpackagelib/lib.py line 3

Quoted 4 lines
utils/checkpackagelib/lib.py +1 -1
@@ -1,6 +1,6 @@
 # See utils/checkpackagelib/readme.txt before editing this file.
 
-from base import _CheckFunction
+from .base import _CheckFunction

It's also possible to replace all these imports with:

from checkpackagelib.base import ...

I.e. use an absolute import. If you like it better...

/Thomas

#2 lore raw

PATCH 1/1 checkpackagelib: fix Python3 execution

In reply to Thomas De Schampheleire

Hello,

Quoted 5 lines · Thomas De Schampheleire

The relative imports do not work in Python 3. Adding the leading dot works both in Python2 and Python3.

This may cause problems if ever you would try to call the helper .py files directly, but this is not currently needed/supported.

Could you review this one instead?
http://patchwork.ozlabs.org/patch/956517/

Regards,
Ricardo

#3 lore raw

PATCH 1/1 checkpackagelib: fix Python3 execution

El vie., 11 ene. 2019 a las 3:53, Ricardo Martincoski (<[email protected]>) escribi?:

Quoted 5 lines

Hello,

On Thu, Jan 10, 2019 at 06:55 PM, Thomas De Schampheleire wrote:

Quoted 10 lines
Quoted 5 lines

The relative imports do not work in Python 3. Adding the leading dot works both in Python2 and Python3.

This may cause problems if ever you would try to call the helper .py files directly, but this is not currently needed/supported.

Could you review this one instead?
http://patchwork.ozlabs.org/patch/956517/

Done, thanks for pointing me to it.

/Thomas