Issue177

Title Writing to __doc__ must not check types
Priority bug Status resolved
Superseder Nosy List kayhayen, marc.jofre
Assigned To kayhayen Keywords wrong_execution

Created on 2015-03-14.20:28:51 by marc.jofre, last changed by kayhayen.

Messages
msg1043 (view) Author: marc.jofre Date: 2015-03-20.11:43:31
Done
msg1041 (view) Author: marc.jofre Date: 2015-03-20.08:33:39
Hi Kay,

I installed release version 5.11.

The matplotlib __name__ and path issues are resolved. The matplotlib __name__ 
issue sis resolved with nuitka 5.11. The path issues is fixed using the 
parameter:

--file-reference-choice=original
msg1030 (view) Author: kayhayen Date: 2015-03-19.07:50:56
The factory MSI build is broken currently (does not get updated), however the 
correction is part of the latest stable release. Please download 0.5.11 or newer, 
and you will see it fixed. I will take care of factory MSI later.
msg1026 (view) Author: marc.jofre Date: 2015-03-18.11:35:19
Hi Kay,

I downloaded the latest nuitka factory MSI release: Nuitka64-5.0.830

I checked running the compiled files and the string issue appears:
  File "D:\WinPython-64bit-2.7.6.3\python-2.7.6.amd64\lib\functools.py", line 34
, in update_wrapper
    setattr(wrapper, attr, getattr(wrapped, attr))
TypeError: __name__ must be set to a string object

Also, --file-reference-choice=original is not recognized in the current version 
of nuitka factory.
msg1025 (view) Author: kayhayen Date: 2015-03-18.07:17:58
But it ought to be, or I have a build issue. Did the __doc__ problem go away, 
you should be able to remove your workaround with latest factory MSI. It's green 
for me, but maybe something is broken about the upload.

Annoying issue. I got to work on making these factory downloads more 
recognizable, by date and commit, and in --version output.
msg1023 (view) Author: marc.jofre Date: 2015-03-17.14:40:46
Hi Kay,

I downloaded and installed the latest nuitka factory as version of 17/03/2015. 
For the time being the string and unicode issue I have to solve it forcing to 
string.

--file-reference-choice=original is not recognized in the current version of 
nuitka factory. Do I have to install a more recent release or other package?
msg1021 (view) Author: kayhayen Date: 2015-03-17.09:11:19
I just pushed something to factory that will be in a coming release. The Windows 
build won't update though, as the last pre-release is still building on 
Debian/Ubuntu's. Your workaround is technically OK, but make sure to remove it 
later.
msg1020 (view) Author: kayhayen Date: 2015-03-17.08:31:16
Hello Marc,

__name__ Normalize <type 'str'>
> __doc__   <type 'unicode'>
>

ah, the error message contains a typo, probably the result of copy&paste
from __name__ to __doc__ attribute. And setting the __doc__ to "unicode" is
allowed, but not with Nuitka currently, making decorations of it fail.
Expect a fix and the rejection of unicode for this shortly.

As for "__file__", there have been changes to apply run time dynamic
"__file__" with accelerated mode, and module compilation too. So, if you
executable lives elsewhere, to data files from original locations won't be
found anymore. If you only care about acceleration, you can use
"--file-reference-choice=original" which is not yet documented, but ought
to be before the release. This assumes you are using factory or a
pre-release of Nuitka, are you? The other solution is to have file
structure below the binary that matches the module name space.

Yours,
Kay
msg1019 (view) Author: marc.jofre Date: 2015-03-17.08:20:27
Hi Kay,

Sure, I attach below the dump as you suggested for print attr, 
getattr(wrapped,attr), type(getattr(wrapped, attr))


    This function is deprecated, see ``relabel_sequential`` for more.
     <type 'str'>
__module__ contextlib <type 'str'>
__name__ nested <type 'str'>
__doc__ Combine multiple context managers into a single nested context manager.

   This function has been deprecated in favour of the multiple manager form
   of the with statement.

   The one advantage of this function over the multiple manager form of the
   with statement is that argument unpacking allows it to be
   used with a variable number of context managers as follows:

      with nested(*managers):
          do_something()

     <type 'str'>
__module__ matplotlib.colors <type 'str'>
__name__ Normalize <type 'str'>
__doc__
    A class which, when called, can normalize data into
    the ``[0.0, 1.0]`` interval.

     <type 'unicode'>
Traceback (most recent call last):
  File "C:/Users/mjofre/Desktop/productgeneraldistributables/backend/Backend_GUI
/mysite/mysite/RPCconnectCYT.py", line 52, in <module>
    import CYT
  File "C:\Users\mjofre\Desktop\productgeneraldistributables\backend\Backend_GUI
\mysite\mysite\CYT.py", line 42, in CYT
    from Application import Application
  File "C:\Users\mjofre\Desktop\productgeneraldistributables\backend\Backend_GUI
\mysite\mysite\Application.py", line 24, in Application
    from ImageCollection import ImageCollection
  File "C:\Users\mjofre\Desktop\productgeneraldistributables\backend\Backend_GUI
\mysite\mysite\ImageCollection.py", line 11, in ImageCollection
    import matplotlib
  File "D:\WinPython-64bit-2.7.6.3\python-2.7.6.amd64\Lib\site-packages\matplotl
ib\__init__.py", line 193, in matplotlib
    from matplotlib.rcsetup import (defaultParams,
  File "D:\WinPython-64bit-2.7.6.3\python-2.7.6.amd64\Lib\site-packages\matplotl
ib\rcsetup.py", line 24, in rcsetup
    from matplotlib.colors import is_color_like
  File "D:\WinPython-64bit-2.7.6.3\python-2.7.6.amd64\Lib\site-packages\matplotl
ib\colors.py", line 1304, in colors
    obj_type='class alias')(Normalize)
  File "D:\WinPython-64bit-2.7.6.3\python-2.7.6.amd64\Lib\site-packages\matplotl
ib\cbook.py", line 212, in deprecate
    @functools.wraps(func)
  File "D:\WinPython-64bit-2.7.6.3\python-2.7.6.amd64\lib\functools.py", line 34
, in update_wrapper
    setattr(wrapper, attr, str(getattr(wrapped, attr)))
TypeError: __name__ must be set to a string object

D:\SixSensoCytometerWebBased\bin>

Once fixed the forcing of stuff to string, the next run fail is related to 
paths:

File "D:\WinPython-64bit-2.7.6.3\python-2.7.6.amd64\Lib\site-packages\matplotl
ib\__init__.py", line 688, in _get_data_path_cached
    defaultParams['datapath'][0] = _get_data_path()
  File "D:\WinPython-64bit-2.7.6.3\python-2.7.6.amd64\Lib\site-packages\matplotl
ib\__init__.py", line 684, in _get_data_path
    raise RuntimeError('Could not find the matplotlib data files')
RuntimeError: Could not find the matplotlib data files
msg1015 (view) Author: kayhayen Date: 2015-03-17.06:35:37
Hello Marc,

I would rather like to know what type and value "__name__" there really were, so 
can you dump it for me? This seems to indicate quite serious bugs, if CPython 
worked correctly with it, and Nuitka didn't. Then we probably understand the 
issue better.
msg1013 (view) Author: marc.jofre Date: 2015-03-16.20:47:58
Hi Kay,

I corrected a few lines in matplotlib scripts to force to str __name__ and 
__doc__, as follows:

:: Matplotlib compilation issues:
:: Once compiled, when running the executable an error in functools line 33 
appears: TypeError: __name__ must be set to a string object
:: In functools.py line 33: replace by
::
::for attr in assigned:
::       #print attr, getattr(wrapped,attr), type(getattr(wrapped, attr)) # Marc 
Nuitka compilation debugging
::       setattr(wrapper, attr, str(getattr(wrapped, attr)))
::    for attr in updated:
::        getattr(wrapper, attr).update(getattr(wrapped, attr, {}))   
::    # Return the wrapper so this can be used as a decorator via partial()
::    return wrapper
::
:: In matplotlib\cbooks.py line 231: replace by
:: deprecated_func.__doc__ = str(new_doc)# MArc fix for nuitka compilation
:: In matplotlib\__init__py line 330: replace by
:: wrapper.__doc__ = str(func.__doc__) # Marc fix for nuitka compilation

Typical examples of run failings is shown in the line below:

  File "D:\WinPython-64bit-2.7.6.3\python-2.7.6.amd64\Lib\site-packages\matplotl
ib\__init__.py", line 330, in wrap
    wrapper.__doc__ = func.__doc__
TypeError: __name__ must be set to a string object


Once fixed the forcing of stuff to string, the next run fail is related to 
paths:

File "D:\WinPython-64bit-2.7.6.3\python-2.7.6.amd64\Lib\site-packages\matplotl
ib\__init__.py", line 688, in _get_data_path_cached
    defaultParams['datapath'][0] = _get_data_path()
  File "D:\WinPython-64bit-2.7.6.3\python-2.7.6.amd64\Lib\site-packages\matplotl
ib\__init__.py", line 684, in _get_data_path
    raise RuntimeError('Could not find the matplotlib data files')
RuntimeError: Could not find the matplotlib data files

The code dump:

D:\SixSensoCytometerWebBased\bin>RPCconnectCYT.exe
Traceback (most recent call last):
  File "C:/Users/mjofre/Desktop/productgeneraldistributables/backend/Backend_GUI
/mysite/mysite/RPCconnectCYT.py", line 52, in <module>
    import CYT
  File "C:\Users\mjofre\Desktop\productgeneraldistributables\backend\Backend_GUI
\mysite\mysite\CYT.py", line 42, in CYT
    from Application import Application
  File "C:\Users\mjofre\Desktop\productgeneraldistributables\backend\Backend_GUI
\mysite\mysite\Application.py", line 24, in Application
    from ImageCollection import ImageCollection
  File "C:\Users\mjofre\Desktop\productgeneraldistributables\backend\Backend_GUI
\mysite\mysite\ImageCollection.py", line 11, in ImageCollection
    import matplotlib
  File "D:\WinPython-64bit-2.7.6.3\python-2.7.6.amd64\Lib\site-packages\matplotl
ib\__init__.py", line 1048, in matplotlib
    rcParams = rc_params()
  File "D:\WinPython-64bit-2.7.6.3\python-2.7.6.amd64\Lib\site-packages\matplotl
ib\__init__.py", line 897, in rc_params
    fname = matplotlib_fname()
  File "D:\WinPython-64bit-2.7.6.3\python-2.7.6.amd64\Lib\site-packages\matplotl
ib\__init__.py", line 780, in matplotlib_fname
    path = get_data_path()  # guaranteed to exist or raise
  File "D:\WinPython-64bit-2.7.6.3\python-2.7.6.amd64\Lib\site-packages\matplotl
ib\__init__.py", line 323, in wrapper
    ret = func(*args, **kwargs)
  File "D:\WinPython-64bit-2.7.6.3\python-2.7.6.amd64\Lib\site-packages\matplotl
ib\__init__.py", line 688, in _get_data_path_cached
    defaultParams['datapath'][0] = _get_data_path()
  File "D:\WinPython-64bit-2.7.6.3\python-2.7.6.amd64\Lib\site-packages\matplotl
ib\__init__.py", line 684, in _get_data_path
    raise RuntimeError('Could not find the matplotlib data files')
RuntimeError: Could not find the matplotlib data files
msg1001 (view) Author: kayhayen Date: 2015-03-15.10:23:47
Hello Marc,

it would be interesting what "getattr(wrapped, attr)" gave down there in 
functools.py. If you don't mind, please add a "print attr, getattr(wrapped, 
attr), type(getattr(wrapped, attr))" right before that statement and we will 
know.

I think we know that attr will be "__name__", for which I tried unicode and 
None, and CPython both rejected it, with that error. Maybe something is strange 
going on. Must be a corner case anyway.

Thanks in advance,
Kay
msg1000 (view) Author: marc.jofre Date: 2015-03-14.20:28:51
Hi,

I have nuitka standalone compiled a python project which imports matplotlib. 
Nuitka compilation standalone works. When running the python exe file it fails 
with console message below:

D:\SixSensoCytometerWebBased\bin>RPCconnectCYT.exe
Traceback (most recent call last):
  File "C:/Users/mjofre/Desktop/productgeneraldistributables/backend/Backend_GUI
/mysite/mysite/RPCconnectCYT.py", line 52, in <module>
    import CYT
  File "C:\Users\mjofre\Desktop\productgeneraldistributables\backend\Backend_GUI
\mysite\mysite\CYT.py", line 42, in CYT
    from Application import Application
  File "C:\Users\mjofre\Desktop\productgeneraldistributables\backend\Backend_GUI
\mysite\mysite\Application.py", line 24, in Application
    from ImageCollection import ImageCollection
  File "C:\Users\mjofre\Desktop\productgeneraldistributables\backend\Backend_GUI
\mysite\mysite\ImageCollection.py", line 11, in ImageCollection
    import matplotlib
  File "D:\WinPython-64bit-2.7.6.3\python-2.7.6.amd64\Lib\site-packages\matplotl
ib\__init__.py", line 193, in matplotlib
    from matplotlib.rcsetup import (defaultParams,
  File "D:\WinPython-64bit-2.7.6.3\python-2.7.6.amd64\Lib\site-packages\matplotl
ib\rcsetup.py", line 24, in rcsetup
    from matplotlib.colors import is_color_like
  File "D:\WinPython-64bit-2.7.6.3\python-2.7.6.amd64\Lib\site-packages\matplotl
ib\colors.py", line 1304, in colors
    obj_type='class alias')(Normalize)
  File "D:\WinPython-64bit-2.7.6.3\python-2.7.6.amd64\Lib\site-packages\matplotl
ib\cbook.py", line 212, in deprecate
    @functools.wraps(func)
  File "D:\WinPython-64bit-2.7.6.3\python-2.7.6.amd64\lib\functools.py", line 33
, in update_wrapper
    setattr(wrapper, attr, getattr(wrapped, attr))
TypeError: __name__ must be set to a string object
History
Date User Action Args
2015-03-26 16:13:11kayhayensetstatus: done-cbb -> resolved
2015-03-20 11:43:31marc.jofresetstatus: chatting -> done-cbb
messages: + msg1043
2015-03-20 08:33:39marc.jofresetstatus: resolved -> chatting
messages: + msg1041
2015-03-19 07:50:56kayhayensetstatus: testing -> resolved
messages: + msg1030
2015-03-18 11:35:19marc.jofresetmessages: + msg1026
2015-03-18 07:17:58kayhayensetmessages: + msg1025
2015-03-17 14:40:46marc.jofresetmessages: + msg1023
2015-03-17 09:11:28kayhayensetstatus: chatting -> testing
2015-03-17 09:11:19kayhayensetmessages: + msg1021
title: Run error matplotlib -> Writing to __doc__ must not check types
2015-03-17 08:31:16kayhayensetmessages: + msg1020
2015-03-17 08:20:27marc.jofresetmessages: + msg1019
2015-03-17 06:35:37kayhayensetmessages: + msg1015
2015-03-16 20:47:58marc.jofresetmessages: + msg1013
2015-03-15 10:23:47kayhayensetstatus: unread -> chatting
assignedto: kayhayen
messages: + msg1001
keyword: + wrong_execution
nosy: + kayhayen
2015-03-14 20:28:51marc.jofrecreate