1. Alex Mayfield
  2. circuits

Commits

Alex Mayfield  committed 4bc4875

Yank encoding out of socket layer.

  • Participants
  • Parent commits 08e6bfc
  • Branches default

Comments (0)

Files changed (1)

File circuits/net/sockets.py

View file
  • Ignore whitespace
     channel = "client"
 
     def __init__(self, bind=None, bufsize=BUFSIZE,
-            encoding="utf-8", channel=channel):
+            channel=channel):
         super(Client, self).__init__(channel=channel)
 
         if isinstance(bind, int):
             self._sock = self._create_socket()
 
         self._bufsize = bufsize
-        self._encoding = encoding
 
         self._ssock = None
         self._poller = None
 
     def _write(self, data):
         try:
-            if not isinstance(data, bytes):
-                data = data.encode(self._encoding)
-
             if self.secure and self._ssock:
                 nbytes = self._ssock.write(data)
             else:
     channel = "server"
 
     def __init__(self, bind, secure=False, backlog=BACKLOG,
-            bufsize=BUFSIZE, encoding="utf-8", channel=channel,
-            **kwargs):
+            bufsize=BUFSIZE, channel=channel, **kwargs):
         super(Server, self).__init__(channel=channel)
 
         if type(bind) is int:
 
         self._backlog = backlog
         self._bufsize = bufsize
-        self._encoding = encoding
 
         if isinstance(bind, socket):
             self._sock = bind
             return
 
         try:
-            if not isinstance(data, bytes):
-                data = data.encode(self._encoding)
-
             nbytes = sock.send(data)
             if nbytes < len(data):
                 self._buffers[sock].appendleft(data[nbytes:])
 
     def _write(self, address, data):
         try:
-            if isinstance(data, str):
-                data = data.encode(self._encoding)
-
             bytes = self._sock.sendto(data, address)
             if bytes < len(data):
                 self._buffers[self._sock].appendleft(data[bytes:])