简体   繁体   English

Python 3.5:TypeError:__ init __()得到了一个意外的关键字参数'nosigint'

[英]Python 3.5 : TypeError: __init__() got an unexpected keyword argument 'nosigint'

I am using Python 3.5 to do doctest. 我使用Python 3.5来做doctest。 There is always an error: 始终存在错误:

  File "D:\Program Files\Anaconda\lib\doctest.py", line 357, in __init__
    pdb.Pdb.__init__(self, stdout=out, nosigint=True)

TypeError: __init__() got an unexpected keyword argument 'nosigint'

It seems that the error occurs in the doctest.py file, but not in my own code. 似乎错误发生在doctest.py文件中,但不在我自己的代码中。

I hope to define a class which is similar to dict. 我希望定义一个类似于dict的类。 My code is: 我的代码是:

class Dict(dict):
    '''
    Simple dict but also support access as x.y style.

    >>> d1 = Dict()
    >>> d1['x'] = 100
    >>> d1.x
    100
    >>> d1.y = 200
    >>> d1['y']
    200
    >>> d2 = Dict(a=1, b=2, c='3')
    >>> d2.c
    '3'
    >>> d2['empty']
    Traceback (most recent call last):
        ...
    KeyError: 'empty'
    >>> d2.empty
    Traceback (most recent call last):
        ...
    AttributeError: 'Dict' object has no attribute 'empty'
    '''
    def __init__(self, **kw):
        super(Dict, self).__init__(**kw)

    def __getattr__(self, key):
        try:
            return self[key]
        except KeyError:
            raise AttributeError(r"'Dict' object has no attribute '%s'" % key)

    def __setattr__(self, key, value):
        self[key] = value

if __name__=='__main__':
    import doctest
    doctest.testmod()

Can you help me with this? 你能帮帮我吗?

It looks like you are using the Anaconda Python distribution. 看起来您正在使用Anaconda Python发行版。

Are you running using the Spyder IDE? 你在使用Spyder IDE运行吗?

There is an open bug in Spyder's issue tracker. Spyder的问题跟踪器中存在一个漏洞

The suggested work-around involves modifying the source of pdb and doctest . 建议的解决方法涉及修改pdbdoctest的源代码。

For a shoddy quick fix you can remove the 对于粗制滥造的快速修复,你可以删除

nosigint=True argument from the pdb.Pdb.init in doctest.py nosigint=True pdb.Pdb.initdoctest.py nosigint=True参数

and change the default value of nosigint to True in pdb.py 并在pdb.py的默认值nosigintTrue

if you are being affected by this bug, you can encourage the folk who make Spyder to fix it by Subscribing to Notifications about this issue on GitHub 如果你受到这个bug的影响,你可以通过在GitHub上订阅有关此问题的通知来鼓励让Spyder修复它的人

There is another potential solution that I have used to work around this bug. 还有另一个我用来解决这个bug的潜在解决方案。 You can add an __init__ method to the SpyderPdb class that sets a default value for the missing nosigint argument. 您可以向SpyderPdb类添加__init__方法,该方法为缺少的nosigint参数设置默认值。

I'm using the WinPython distribution to get Spyder, but it's probably something similar for Anaconda. 我正在使用WinPython发行版来获取Spyder,但它可能类似于Anaconda。 For Python 3.5+ it's in: \\WinPython...\\python...\\Lib\\site-packages\\spyder\\utils\\site\\sitecustomize.py 对于Python 3.5+,它位于:\\ WinPython ... \\ python ... \\ Lib \\ site-packages \\ spyder \\ utils \\ site \\ sitecustomize.py

For earlier versions it might be in ...\\Lib\\site-packages\\spyderlib\\widgets\\externalshell\\sitecustomize.py 对于早期版本,它可能位于... \\ Lib \\ site-packages \\ spyderlib \\ widgets \\ externalshell \\ sitecustomize.py

class SpyderPdb(pdb.Pdb):
    def __init__(self, completekey='tab', stdin=None, stdout=None, skip=None, nosigint=False):
        super(pdb.Pdb, self).__init__()

Spyder开发人员 )这个问题将在Spyder 3.1.4中修复,将于2017年3月中旬发布。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 python请求:TypeError:__ init __()得到一个意外的关键字参数'proxies' - python requests: TypeError: __init__() got an unexpected keyword argument 'proxies' TypeError at '' __init__() 得到一个意外的关键字参数 '' - TypeError at '' __init__() got an unexpected keyword argument '' Python openpyxl TypeError:__init __()获得了意外的关键字参数'pivotButton' - Python openpyxl TypeError: __init__() got an unexpected keyword argument 'pivotButton' Telethon Python TypeError:__init__() 得到了一个意外的关键字参数“hash” - Telethon Python TypeError: __init__() got an unexpected keyword argument 'hash' Python Flask - TypeError: __init__() 得到了一个意外的关键字参数“lable” - Python Flask - TypeError: __init__() got an unexpected keyword argument 'lable' 类型错误:__init__() 得到了意外的关键字参数“名称”-CONVOKIT - TypeError: __init__() got an unexpected keyword argument 'name' - CONVOKIT TypeError:__init __()获得了意外的关键字参数'options' - TypeError: __init__() got an unexpected keyword argument 'options' 类型错误:__init__() 得到了意外的关键字参数“after” - TypeError: __init__() got an unexpected keyword argument 'after' 类型错误:__init__() 得到了意外的关键字参数“i” - TypeError: __init__() got an unexpected keyword argument 'i' Scrapy错误:TypeError:__init __()获得了意外的关键字参数“回调” - Scrapy error: TypeError: __init__() got an unexpected keyword argument 'callback'
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM