IGITUGraz / spore-nest-module

Synaptic Plasticity with Online Reinforcement learning
https://igitugraz.github.io/spore-nest-module/
GNU General Public License v2.0
25 stars 11 forks source link

Building help information of external module fails "unicode expected" #24

Closed kappeld closed 6 years ago

kappeld commented 6 years ago

When building SPORE for NEST 2.14 on a Ubuntu machine (artful) with python 3.6.3, I get the following error when generating the help information of the module:

Traceback (most recent call last):
  File "generate_helpindex.py", line 39, in <module>
    write_helpindex(help_dir)
  File "/home/david/opt/share/nest/help_generator/writers.py", line 244, in write_helpindex
    f_helphlpindex.write('\u\n'.join(hlp_list))
TypeError: write() argument 1 must be unicode, not str
src/CMakeFiles/generate_help.dir/build.make:57: recipe for target 'generate_help' failed
make[2]: *** [generate_help] Error 1
CMakeFiles/Makefile2:196: recipe for target 'src/CMakeFiles/generate_help.dir/all' failed
make[1]: *** [src/CMakeFiles/generate_help.dir/all] Error 2
Makefile:162: recipe for target 'all' failed
make: *** [all] Error 2

Building the latest release of NEST worked without errors, this only occurs in our custom module.

There is a simple fix by enforcing unicode strings by adding an 'u' in line 244 of writers.py:

--- a/extras/help_generator/writers.py
+++ b/extras/help_generator/writers.py
@@ -241,7 +241,7 @@ def write_helpindex(helpdir):
     # Todo: using string template for .hlp
     f_helphlpindex = io.open(os.path.join(helpdir, 'helpindex.hlp'), mode='w',
                              encoding='utf-8')
-    f_helphlpindex.write('\n'.join(hlp_list))
+    f_helphlpindex.write(u'\n'.join(hlp_list))
     f_helphlpindex.close()

With this modification the custom module compiles and runs without problems.

So, my take on this is that the behavior of write has recently changed, making it more picky on the data encoding, which should be accounted for on the NEST side.

kappeld commented 6 years ago

Hans Ekkehard Plesser confirmed that the problem is on the NEST side and a fix is on its way:

https://github.com/nest/nest-simulator/pull/953/commits/e12737a6f2c5035b9d7dfe123c9fbb602a26b3e9

kappeld commented 6 years ago

The fix has been merged into nest/master. The newest version of NEST now works again with SPORE. I will close this issue.