Skip to content
This repository was archived by the owner on Nov 23, 2017. It is now read-only.

Commit a2427ba

Browse files
rwalkerandsgvanrossum
authored andcommitted
Fix NameError in sslproto _fatal_error() (#364)
Fixes issue #363
1 parent 27218fa commit a2427ba

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

asyncio/sslproto.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
except ImportError: # pragma: no cover
66
ssl = None
77

8+
from . import base_events
89
from . import compat
910
from . import protocols
1011
from . import transports

tests/test_sslproto.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
"""Tests for asyncio/sslproto.py."""
22

3+
import logging
34
import unittest
45
from unittest import mock
56
try:
@@ -8,6 +9,7 @@
89
ssl = None
910

1011
import asyncio
12+
from asyncio import log
1113
from asyncio import sslproto
1214
from asyncio import test_utils
1315

@@ -66,6 +68,20 @@ def test_eof_received_waiter(self):
6668
test_utils.run_briefly(self.loop)
6769
self.assertIsInstance(waiter.exception(), ConnectionResetError)
6870

71+
def test_fatal_error_no_name_error(self):
72+
# From issue #363.
73+
# _fatal_error() generates a NameError if sslproto.py
74+
# does not import base_events.
75+
waiter = asyncio.Future(loop=self.loop)
76+
ssl_proto = self.ssl_protocol(waiter)
77+
# Temporarily turn off error logging so as not to spoil test output.
78+
log_level = log.logger.getEffectiveLevel()
79+
log.logger.setLevel(logging.FATAL)
80+
try:
81+
ssl_proto._fatal_error(None)
82+
finally:
83+
# Restore error logging.
84+
log.logger.setLevel(log_level)
6985

7086
if __name__ == '__main__':
7187
unittest.main()

0 commit comments

Comments
 (0)