Opened 12 years ago

Closed 6 years ago

#1510 defect closed duplicate (duplicate)

abstract.py's writeSequence implementation accepts unicode

Reported by: Jean-Paul Calderone Owned by:
Priority: normal Milestone:
Component: core Keywords:
Cc: Jean-Paul Calderone, jknight Branch:
Author:

Description

It used to reject it, but I guess when it got changed to be more efficient that behavior got lost.

Here's a trivial patch that puts this behavior back:

Index: twisted/internet/abstract.py
===================================================================
--- twisted/internet/abstract.py        (revision 16071)
+++ twisted/internet/abstract.py        (working copy)
@@ -177,6 +177,8 @@
             self.startWriting()
 
     def writeSequence(self, iovec):
+        if unicode in map(type, iovec):
+            raise TypeError("iovec must not contain unicode data")
         if not self.connected or not iovec or self._writeDisconnected:
             return
         self._tempDataBuffer.extend(iovec)

Although there should be a unit test for this, too.

Attachments (1)

patch_1510.patch (1.8 KB) - added by moijes12 6 years ago.

Download all attachments as: .zip

Change History (6)

comment:1 Changed 12 years ago by jknight

Maybe twisted can just install a half-asscii codec that only allows conversion from ascii-str->unicode but not unicode->ascii-str as the default.

comment:2 Changed 10 years ago by therve

Owner: changed from itamarst to therve

I'll do that once #745 is in.

comment:3 Changed 7 years ago by <automation>

Owner: therve deleted

Changed 6 years ago by moijes12

Attachment: patch_1510.patch added

comment:4 Changed 6 years ago by moijes12

Keywords: review added

comment:5 Changed 6 years ago by Jean-Paul Calderone

Keywords: review removed
Resolution: duplicate
Status: newclosed

Thanks. This was already fixed in r33003, though, as part of #3896, which was sort of a duplicate of this ticket. The implementation in trunk now is fine.

Note: See TracTickets for help on using tickets.