winpdb not working with python 3.3

一个人想着一个人 提交于 2019-12-06 05:04:52

问题


I can't get rpdb2 to run with python 3.3, while that should be possible according to several sources.

$ rpdb2 -d myscript.py
A password should be set to secure debugger client-server communication.
Please type a password:x
Password has been set.
Traceback (most recent call last):
  File "/usr/local/bin/rpdb2", line 31, in <module>
    rpdb2.main()
  File "/usr/local/lib/python3.3/dist-packages/rpdb2.py", line 14470, in main
    StartServer(_rpdb2_args, fchdir, _rpdb2_pwd, fAllowUnencrypted, fAllowRemote, secret)
  File "/usr/local/lib/python3.3/dist-packages/rpdb2.py", line 14212, in StartServer
    g_module_main = -1
  File "/usr/local/lib/python3.3/dist-packages/rpdb2.py", line 14212, in StartServer
    g_module_main = -1
  File "/usr/local/lib/python3.3/dist-packages/rpdb2.py", line 7324, in trace_dispatch_init
    self.__set_signal_handler()
  File "/usr/local/lib/python3.3/dist-packages/rpdb2.py", line 7286, in __set_signal_handler
    handler = signal.getsignal(value)
  File "/usr/local/lib/python3.3/dist-packages/rpdb2.py", line 13682, in __getsignal
    handler = g_signal_handlers.get(signum, g_signal_getsignal(signum))
ValueError: signal number out of range

The version of rpdb2 is RPDB 2.4.8 - Tychod. I installed it by running pip-3.3 install winpdb.

Any clues?


回答1:


Got the same problem today here is what i've done for it to work. Still i'm not too sure if this is correct to do it this way.

From:

def __getsignal(signum):
    handler = g_signal_handlers.get(signum, g_signal_getsignal(signum))
    return handler

To:

def __getsignal(signum):
    try:
        # The problems come from the signum which was 0.
        g_signal_getsignal(signum)
    except ValueError:
        return None
    handler = g_signal_handlers.get(signum, g_signal_getsignal(signum))
    return handler

This function shall be at line 13681 or something like.




回答2:


The reason of a problem is the extended list of attributes in a signal module that was used by rpdb2 to list all signals. New python versions added attributes like SIG_BLOCK, SIG_UNBLOCK, SIG_SETMASK

So the filtering should be extended too (patch changes just one line):

--- rpdb2.py
+++ rpdb2.py
@@ -7278,11 +7278,11 @@
     def __set_signal_handler(self):
         """
         Set rpdb2 to wrap all signal handlers.
         """
         for key, value in list(vars(signal).items()):
-            if not key.startswith('SIG') or key in ['SIGRTMIN', 'SIGRTMAX'] or key.startswith('SIG_'):
+            if not key.startswith('SIG') or key in ['SIG_IGN', 'SIG_DFL', 'SIGRTMIN', 'SIGRTMAX']:
             continue

         handler = signal.getsignal(value)
         if handler in [signal.SIG_IGN, signal.SIG_DFL]:
             continue

Unfortunately there is no current official development or fork of winpdb, so by now this patch would be just stored on SO.



来源:https://stackoverflow.com/questions/20764082/winpdb-not-working-with-python-3-3

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!