File tree Expand file tree Collapse file tree 2 files changed +7
-1
lines changed Expand file tree Collapse file tree 2 files changed +7
-1
lines changed Original file line number Diff line number Diff line change @@ -142,6 +142,10 @@ async def client(addr):
142
142
writer .write (b'AAAA' )
143
143
self .assertEqual (await reader .readexactly (2 ), b'OK' )
144
144
145
+ re = r'(a bytes-like object is required)|(must be byte-ish)'
146
+ with self .assertRaisesRegex (TypeError , re ):
147
+ writer .write ('AAAA' )
148
+
145
149
writer .write (b'BBBB' )
146
150
self .assertEqual (await reader .readexactly (4 ), b'SPAM' )
147
151
Original file line number Diff line number Diff line change @@ -33,7 +33,6 @@ cdef class _StreamWriteContext:
33
33
ctx = _StreamWriteContext.__new__ (_StreamWriteContext)
34
34
35
35
ctx.req.data = < void * > ctx
36
- Py_INCREF(ctx)
37
36
38
37
PyObject_GetBuffer(data, & ctx.py_buf, PyBUF_SIMPLE)
39
38
ctx.uv_buf = uv.uv_buf_init(< char * > ctx.py_buf.buf, ctx.py_buf.len)
@@ -45,6 +44,9 @@ cdef class _StreamWriteContext:
45
44
stream._loop._debug_stream_write_ctx_total += 1
46
45
stream._loop._debug_stream_write_ctx_cnt += 1
47
46
47
+ # Do incref after everything else is done
48
+ # (PyObject_GetBuffer for instance may fail with exception)
49
+ Py_INCREF(ctx)
48
50
return ctx
49
51
50
52
IF DEBUG:
You can’t perform that action at this time.
0 commit comments