spyder-ide / spyder

Official repository for Spyder - The Scientific Python Development Environment
https://www.spyder-ide.org
MIT License
8.11k stars 1.57k forks source link

Instancing c# class #14242

Open freshward opened 3 years ago

freshward commented 3 years ago

Description

What steps will reproduce the problem?

import clr clr.AddReference('dll_name')

from dll_name import Class

instance = Class()

Traceback

  File "C:\ProgramData\Anaconda3\envs\ML36\lib\site-packages\spyder\plugins\ipythonconsole\widgets\control.py", line 58, in keyPressEvent
    self._key_paren_left(text)
  File "C:\ProgramData\Anaconda3\envs\ML36\lib\site-packages\spyder\plugins\ipythonconsole\widgets\control.py", line 50, in _key_paren_left
    self.show_object_info(last_obj)
  File "C:\ProgramData\Anaconda3\envs\ML36\lib\site-packages\spyder\widgets\mixins.py", line 1446, in show_object_info
    self.help.set_object_text(text, ignore_unknown=False)
  File "C:\ProgramData\Anaconda3\envs\ML36\lib\site-packages\spyder\plugins\help\plugin.py", line 521, in set_object_text
    found = self.show_help(text, ignore_unknown=ignore_unknown)
  File "C:\ProgramData\Anaconda3\envs\ML36\lib\site-packages\spyder\plugins\help\plugin.py", line 711, in show_help
    source_text = shell.get_source(obj_text)
  File "C:\ProgramData\Anaconda3\envs\ML36\lib\site-packages\spyder\plugins\ipythonconsole\widgets\help.py", line 151, in get_source
    ).get_source(objtxt)
  File "C:\ProgramData\Anaconda3\envs\ML36\lib\site-packages\spyder_kernels\comms\commbase.py", line 550, in __call__
    call_dict, call_data, self._comm_id)
  File "C:\ProgramData\Anaconda3\envs\ML36\lib\site-packages\spyder\plugins\ipythonconsole\comms\kernelcomm.py", line 152, in _get_call_return_value
    call_dict, call_data, comm_id)
  File "C:\ProgramData\Anaconda3\envs\ML36\lib\site-packages\spyder_kernels\comms\commbase.py", line 432, in _get_call_return_value
    return self._sync_error(reply['value'])
  File "C:\ProgramData\Anaconda3\envs\ML36\lib\site-packages\spyder_kernels\comms\commbase.py", line 488, in _sync_error
    error_wrapper.raise_error()
  File "C:\ProgramData\Anaconda3\envs\ML36\lib\site-packages\spyder_kernels\comms\commbase.py", line 90, in raise_error
    raise self.etype(self)
Exception in comms call get_source:

  File "C:\ProgramData\Anaconda3\envs\ML36\lib\site-packages\spyder_kernels\comms\commbase.py", line 343, in _handle_remote_call
    buffer['call_kwargs'])

  File "C:\ProgramData\Anaconda3\envs\ML36\lib\site-packages\spyder_kernels\comms\commbase.py", line 354, in _remote_callback
    *call_args, **call_kwargs)

  File "C:\ProgramData\Anaconda3\envs\ML36\lib\site-packages\spyder_kernels\console\kernel.py", line 335, in get_source
    return getsource(obj)

  File "C:\ProgramData\Anaconda3\envs\ML36\lib\site-packages\spyder_kernels\utils\dochelpers.py", line 164, in getsource
    src = to_text_string(inspect.getsource(obj))

  File "C:\ProgramData\Anaconda3\envs\ML36\lib\inspect.py", line 973, in getsource
    lines, lnum = getsourcelines(object)

  File "C:\ProgramData\Anaconda3\envs\ML36\lib\inspect.py", line 955, in getsourcelines
    lines, lnum = findsource(object)

  File "C:\ProgramData\Anaconda3\envs\ML36\lib\inspect.py", line 782, in findsource
    lines = linecache.getlines(file, module.__dict__)

  File "C:\ProgramData\Anaconda3\envs\ML36\lib\linecache.py", line 47, in getlines
    return updatecache(filename, module_globals)

  File "C:\ProgramData\Anaconda3\envs\ML36\lib\linecache.py", line 136, in updatecache
    with tokenize.open(fullname) as fp:

  File "C:\ProgramData\Anaconda3\envs\ML36\lib\tokenize.py", line 454, in open
    encoding, lines = detect_encoding(buffer.readline)

  File "C:\ProgramData\Anaconda3\envs\ML36\lib\tokenize.py", line 431, in detect_encoding
    encoding = find_cookie(first)

  File "C:\ProgramData\Anaconda3\envs\ML36\lib\tokenize.py", line 395, in find_cookie
    raise SyntaxError(msg)

  File "<string>", line None

SyntaxError: invalid or missing encoding declaration for 'Link to DLL File'

Versions

Dependencies


# Mandatory:
atomicwrites >=1.2.0           :  1.4.0 (OK)
chardet >=2.0.0                :  3.0.4 (OK)
cloudpickle >=0.5.0            :  1.6.0 (OK)
diff_match_patch >=20181111    :  20200713 (OK)
intervaltree                   :  None (OK)
IPython >=4.0                  :  7.16.1 (OK)
jedi =0.17.1                   :  0.17.1 (OK)
nbconvert >=4.0                :  6.0.7 (OK)
numpydoc >=0.6.0               :  1.1.0 (OK)
paramiko >=2.4.0               :  2.7.2 (OK)
parso =0.7.0                   :  0.7.0 (OK)
pexpect >=4.4.0                :  4.8.0 (OK)
pickleshare >=0.4              :  0.7.5 (OK)
psutil >=5.3                   :  5.7.2 (OK)
pygments >=2.0                 :  2.7.2 (OK)
pylint >=1.0                   :  2.6.0 (OK)
pyls >=0.34.0;<1.0.0           :  0.35.1 (OK)
qdarkstyle >=2.8               :  2.8.1 (OK)
qtawesome >=0.5.7              :  1.0.1 (OK)
qtconsole >=4.6.0              :  4.7.7 (OK)
qtpy >=1.5.0                   :  1.9.0 (OK)
rtree >=0.8.3                  :  0.9.4 (OK)
sphinx >=0.6.6                 :  3.2.1 (OK)
spyder_kernels >=1.9.4;<1.10.0 :  1.9.4 (OK)
watchdog                       :  None (OK)
zmq >=17                       :  19.0.2 (OK)

# Optional:
cython >=0.21                  :  None (OK)
matplotlib >=2.0.0             :  3.3.2 (OK)
numpy >=1.7                    :  1.19.2 (OK)
pandas >=0.13.1                :  1.1.3 (OK)
scipy >=0.17.0                 :  1.5.2 (OK)
sympy >=0.7.3                  :  None (OK)
ccordoba12 commented 3 years ago

Hey @freshward, thanks for reporting. We'll try to fix this in a future release

@steff456, the solution to this is very similar to issue #14100, but I'm leaving it for 4.2.2 to not increase the things you need to do for 4.2.1.