Issue2499

classification
Title: Modules should have implicit conversion to string when concatenated with a string
Type: Severity: normal
Components: Core Versions: Jython 2.7
Milestone:
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: jeff.allen, zyasoft
Priority: low Keywords:

Created on 2016-05-11.16:36:37 by zyasoft, last changed 2018-03-22.08:49:14 by jeff.allen.

Messages
msg10856 (view) Author: Jim Baker (zyasoft) Date: 2016-05-11.16:36:36
As seen in this hacky workaround for the lazy_reload package (https://github.com/boostpro/lazy_reload):

def is_submodule_name( name, root_name ):
    try:
        return (name + '.').startswith(root_name + '.')
    except:
        return (name + '.').startswith(root_name.__name__ + '.')
msg10857 (view) Author: Jim Baker (zyasoft) Date: 2016-05-11.16:37:42
Here's the actual diff for the hacky workaround:

diff --git a/lazy_reload.py b/lazy_reload.py
index 566521e..1694775 100644
--- a/lazy_reload.py
+++ b/lazy_reload.py
@@ -40,7 +40,10 @@ else:
     modules_to_reload = {}

 def is_submodule_name( name, root_name ):
-    return (name + '.').startswith(root_name + '.')
+    try:
+        return (name + '.').startswith(root_name + '.')
+    except:
+        return (name + '.').startswith(root_name.__name__ + '.')

 def lazy_reload(root_module):
     """
msg11737 (view) Author: Jeff Allen (jeff.allen) Date: 2018-03-03.14:34:31
I suggest only when CPython does the same thing.

>>> "hello " + pdb
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: Can't convert 'module' object to str implicitly
History
Date User Action Args
2018-03-22 08:49:14jeff.allensetpriority: low
milestone: Jython 2.7.2 ->
2018-03-03 14:34:31jeff.allensetnosy: + jeff.allen
messages: + msg11737
2016-05-11 16:37:42zyasoftsetmessages: + msg10857
2016-05-11 16:36:37zyasoftcreate