ISSUE
- ssl.SSLError.reason
ssl.SSLError.reason · Issue #4000 · RustPython/RustPython
Feature ssl.SSLError.reason Python Documentation https://docs.python.org/3/library/ssl.html#ssl.SSLError.reason
github.com
Merged PR
- Add 'library', 'reason' Attribute to ssl.SSLError
Add 'library', 'reason' Attribute to ssl.SSLError by tgsong827 · Pull Request #4058 · RustPython/RustPython
This PR associated with #4000. I added libaray and reason attribute to ssl.SSLError like CPython.
github.com
개요
CPython ssl.SSLError
클래스는 library와 reason 속성을 갖고 있다.
RustPython에는 아직 library
와 reason
속성이 없는 상태이기 때문에, 이를 추가한 내용이다.
과정
원인 분석
CPython ssl.SSLError
속성
['__cause__', '__class__', '__context__', '__delattr__', '__dict__', '__dir__', '__doc__',
'__eq__', '__format__', '__ge__', '__getattribute__', '__gt__', '__hash__', '__init__',
'__init_subclass__', '__le__', '__lt__', '__module__', '__ne__', '__new__', '__reduce__',
'__reduce_ex__', '__repr__', '__setattr__', '__setstate__', '__sizeof__', '__str__',
'__subclasshook__', '__suppress_context__', '__traceback__', 'args', 'characters_written',
'errno', 'filename', 'filename2', 'library', 'reason', 'strerror', 'with_traceback']`
RustPython ssl.SSLError
속성
['__cause__', '__class__', '__context__', '__delattr__', '__dict__', '__dir__', '__doc__',
'__eq__', '__format__', '__ge__', '__getattribute__', '__gt__', '__hash__', '__init__',
'__init_subclass__', '__le__', '__lt__', '__module__', '__ne__', '__new__', '__reduce__',
'__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__',
'__suppress_context__', '__traceback__', 'args', 'errno', 'filename', 'filename2', 'strerror',
'with_traceback']
위 차이에서 library
와 reason
속성이 빠진 것을 확인할 수 있다.
RustPython에서 SSL 관련 에러가 발생했을 때, ssl 모듈의 convert_openssl_error
함수에서 SSLError를 생성한다.
수정
원인 분석에서 언급했듯이 convert_openssl_error 함수는 SSLError를 생성한다.
이 함수에는 에러 메시지 출력을 위해 library
와 reason
값을 사용하고 있다.
아래는, 생성되는 SSLError 클래스에 library
, reason
속성을 추가하도록 변경한 내용이다.
CPython의 SSLError
RustPython과 CPython이 출력하는 ssl.SSlError
메시지가 조금 달랐는데,
이는 사용하고 있는 library
와 reason
의 문자열 값이 조금 다르기 때문이다.
CPython 출력 메시지 예시
[X509: NO_CERTIFICATE_OR_CRL_FOUND] no certificate or crl found (_ssl.c:4293)
library -> "X509"
reason -> "NO_CERTIFICATE_OR_CRL_FOUND"
RustPython 출력 메시지 예시
[x509 certificate routines] no certificate or crl found (ssl.rs:691)
library -> "x509 certificate routines"
reason -> "136"
CPython은 자체적으로 library
와 reason
의 상수를 정의한 파일을 갖고 있는데, 이는 RustPython이 값을 가져오는 방식과 조금 다르다.
CPython은 OpenSSL이 갖고 있는 err.h
, openssl.txt
등의 파일을 직접 파싱 해서 _ssl_data.h
로 만드는 모듈을 갖고 있고,
OpenSSL의 내용이 업데이트될 때 해당 모듈을 실행해 CPython의 _ssl_data.h
파일을 업데이트하는 것으로 보인다.
다음 링크는 위에서 설명한 CPython이 갖고 있는 Python 모듈이다.
GitHub - python/cpython: The Python programming language
The Python programming language. Contribute to python/cpython development by creating an account on GitHub.
github.com
CPython은 이렇게 생성된 _ssl_data.h 를 활용해 SSLError
에 필요한 library
와 reason
에 대한 문자열 값을 가져오도록 구현되어 있다.
'Dev > Contribution' 카테고리의 다른 글
[RustPython] fcntl.ioctl 수정하기 (1) | 2022.09.01 |
---|---|
[RustPython] traceback.tb_next mutable 하게 만들기 (0) | 2022.08.21 |
[RustPython] Set타입 fn update 수정하기 (0) | 2022.08.07 |
[RustPython] StopIteration 수정하기 (0) | 2022.08.07 |