2016-06-07 2 views
4

doctest를 수행하기 위해 Python 3.5를 사용하고 있습니다. 오류가 항상있다 :Python 3.5 : TypeError : __init __()에서 예상치 못한 키워드 인자 'nosigint'가 발생했습니다.

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' 

내 자신의 코드에 오류가 doctest.py 파일에서 발생하는 것으로 보인다 있지만.

dict와 비슷한 클래스를 정의하고 싶습니다. 내 코드 :

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() 

도와 주시겠습니까?

답변

3

Anaconda Python 배포판을 사용하고있는 것 같습니다.

Spyder IDE를 사용하고 계십니까?

Spyder의 이슈 트래커에는 open bug이 있습니다.

제안 된 해결 방법은 소스를 pdbdoctest으로 수정하는 것입니다.

For a shoddy quick fix you can remove the

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

and change the default value of nosigint to True in pdb.py

이 버그의 영향을받는 경우, 당신은 스파이더가 Subscribing to Notifications about this issue on GitHub

+1

Spyder IDE를 사용하고 있습니다. 감사. – Dawn

2

나는이 버그를 해결하기 위해 사용한 또 다른 잠재적 인 솔루션이있다하여 문제를 해결 할 수 있도록 민속을 장려 할 수 있습니다. 누락 된 nosigint 인수의 기본값을 설정하는 SpyderPdb 클래스에 __init__ 메서드를 추가 할 수 있습니다.

나는 WinPython 배포판을 사용하여 Spyder를 사용하고 있지만, 아마 아나콘다와 비슷할 것입니다. 파이썬 3.5+의 경우 : \ WinPython ... \ python ... \ Lib \ site-packages \ spyder \ utils \ site \ sitecustomize.py

이전 버전의 경우 ... \ Lib \ 사이트 - 패키지 \ spyderlib \ 위젯 \ 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__() 
1

(여기 스파이더 개발자)이 문제는/2,017 월 중순에 출시 될, 스파이더 3.1.4에서 수정 될 것입니다 .

관련 문제