Opened 13 years ago

Closed 7 years ago

#1510 defect closed duplicate (duplicate)'s writeSequence implementation accepts unicode

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


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/
--- twisted/internet/        (revision 16071)
+++ twisted/internet/        (working copy)
@@ -177,6 +177,8 @@
     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:

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

Attachments (1)

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

Download all attachments as: .zip

Change History (6)

comment:1 Changed 13 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 11 years ago by therve

Owner: changed from itamarst to therve

I'll do that once #745 is in.

comment:3 Changed 8 years ago by <automation>

Owner: therve deleted

Changed 7 years ago by moijes12

Attachment: patch_1510.patch added

comment:4 Changed 7 years ago by moijes12

Keywords: review added

comment:5 Changed 7 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.