$NetBSD: patch-Xlib_protocol_display.py,v 1.1 2011/08/22 12:18:19 wiz Exp $

Python-3.1 compatibility.

--- Xlib/protocol/display.py.orig	2007-06-10 14:11:58.000000000 +0000
+++ Xlib/protocol/display.py
@@ -504,7 +504,7 @@ class Display:
 
             # Ignore errors caused by a signal recieved while blocking.
             # All other errors are re-raised.
-            except select.error, err:
+            except select.error as err:
                 if err[0] != errno.EINTR:
                     raise err
 
@@ -519,7 +519,7 @@ class Display:
             if ws:
                 try:
                     i = self.socket.send(self.data_send)
-                except socket.error, err:
+                except socket.error as err:
                     self.close_internal('server: %s' % err[1])
                     raise self.socket_error
 
@@ -535,7 +535,7 @@ class Display:
                 if recieving:
                     try:
                         bytes_recv = self.socket.recv(2048)
-                    except socket.error, err:
+                    except socket.error as err:
                         self.close_internal('server: %s' % err[1])
                         raise self.socket_error
 
$NetBSD: patch-Xlib_protocol_rq.py,v 1.1 2011/08/22 12:18:19 wiz Exp $

Python-3.1 compatibility.

--- Xlib/protocol/rq.py.orig	2007-06-10 14:11:58.000000000 +0000
+++ Xlib/protocol/rq.py
@@ -1090,7 +1090,7 @@ class Struct:
         # memory leak isn't that serious.  Besides, Python 2.0 has
         # real garbage collect.
 
-        exec code
+        exec(code)
         self.to_binary = new.instancemethod(to_binary, self, self.__class__)
 
         # Finally call it manually
@@ -1175,7 +1175,7 @@ class Struct:
 
         # Finally, compile function as for to_binary.
 
-        exec code
+        exec(code)
         self.parse_value = new.instancemethod(parse_value, self, self.__class__)
 
         # Call it manually
@@ -1275,7 +1275,7 @@ class Struct:
 
         # Finally, compile function as for to_binary.
 
-        exec code
+        exec(code)
         self.parse_binary = new.instancemethod(parse_binary, self, self.__class__)
 
         # Call it manually
$NetBSD: patch-Xlib_rdb.py,v 1.1 2011/08/22 12:18:19 wiz Exp $

Python-3.1 compatibility.

--- Xlib/rdb.py.orig	2007-06-10 14:11:58.000000000 +0000
+++ Xlib/rdb.py
@@ -191,12 +191,13 @@ class ResourceDB:
 
         self.lock.release()
 
-    def __getitem__(self, (name, cls)):
+    def __getitem__(self, nc):
         """db[name, class]
 
         Return the value matching the resource identified by NAME and
         CLASS.  If no match is found, KeyError is raised.
         """
+        name, cls = nc
 
         # Split name and class into their parts
 
$NetBSD: patch-Xlib_support_unix__connect.py,v 1.1 2011/08/22 12:18:19 wiz Exp $

Python-3.1 compatibility.

--- Xlib/support/unix_connect.py.orig	2007-06-10 14:11:58.000000000 +0000
+++ Xlib/support/unix_connect.py
@@ -75,7 +75,7 @@ def get_socket(dname, host, dno):
         else:
             s = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
             s.connect('/tmp/.X11-unix/X%d' % dno)
-    except socket.error, val:
+    except socket.error as val:
         raise error.DisplayConnectionError(dname, str(val))
 
     # Make sure that the connection isn't inherited in child processes
$NetBSD: patch-Xlib_support_vms__connect.py,v 1.1 2011/08/22 12:18:19 wiz Exp $

Python-3.1 compatibility.

--- Xlib/support/vms_connect.py.orig	2007-06-10 14:11:58.000000000 +0000
+++ Xlib/support/vms_connect.py
@@ -62,7 +62,7 @@ def get_socket(dname, host, dno):
         s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
         s.connect((host, 6000 + dno))
 
-    except socket.error, val:
+    except socket.error as val:
         raise error.DisplayConnectionError(dname, str(val))
 
     return s
$NetBSD: patch-Xlib_xauth.py,v 1.1 2011/08/22 12:18:19 wiz Exp $

Python-3.1 compatibility.

--- Xlib/xauth.py.orig	2007-06-10 14:11:58.000000000 +0000
+++ Xlib/xauth.py
@@ -42,7 +42,7 @@ class Xauthority:
 
         try:
             raw = open(filename, 'rb').read()
-        except IOError, err:
+        except IOError as err:
             raise error.XauthError('~/.Xauthority: %s' % err)
 
         self.entries = []
@@ -84,12 +84,12 @@ class Xauthority:
                     break
 
                 self.entries.append((family, addr, num, name, data))
-        except struct.error, e:
-            print "Xlib.xauth: warning, failed to parse part of xauthority file (%s), aborting all further parsing" % filename
+        except struct.error as e:
+            print ("Xlib.xauth: warning, failed to parse part of xauthority file (%s), aborting all further parsing" % filename)
             #pass
 
         if len(self.entries) == 0:
-            print "Xlib.xauth: warning, no xauthority details available"
+            print ("Xlib.xauth: warning, no xauthority details available")
             # raise an error?  this should get partially caught by the XNoAuthError in get_best_auth..
 
     def __len__(self):
$NetBSD: patch-Xlib_xobject_cursor.py,v 1.1 2011/08/22 12:18:19 wiz Exp $

Python-3.1 compatibility.

--- Xlib/xobject/cursor.py.orig	2007-06-10 14:11:59.000000000 +0000
+++ Xlib/xobject/cursor.py
@@ -31,9 +31,9 @@ class Cursor(resource.Resource):
                            cursor = self.id)
         self.display.free_resource_id(self.id)
 
-    def recolor(self, (fore_red, fore_green, fore_blue),
-                (back_red, back_green, back_blue), onerror = None):
-
+    def recolor(self, f_rgb, b_rgb, onerror = None):
+        back_red, back_green, back_blue = b_rgb
+        fore_red, fore_green, fore_blue = f_rgb
         request.RecolorCursor(display = self.display,
                               onerror = onerror,
                               cursor = self.id,
$NetBSD: patch-Xlib_xobject_drawable.py,v 1.1 2011/08/22 12:18:19 wiz Exp $

Python-3.1 compatibility.

--- Xlib/xobject/drawable.py.orig	2007-06-10 14:11:59.000000000 +0000
+++ Xlib/xobject/drawable.py
@@ -233,7 +233,7 @@ class Drawable(resource.Resource):
             unit = self.display.info.bitmap_format_scanline_unit
             stride = roundup(width * unit, pad) >> 3
         else:
-            raise ValueError, 'Unknown data format'
+            raise ValueError('Unknown data format')
 
         maxlen = (self.display.info.max_request_length << 2) \
                  - request.PutImage._request.static_size
@@ -800,9 +800,10 @@ class Pixmap(Drawable):
         self.display.free_resource_id(self.id)
 
     def create_cursor(self, mask,
-                      (fore_red, fore_green, fore_blue),
-                      (back_red, back_green, back_blue),
+                      f_rgb, b_rgb,
                       x, y):
+        fore_red, fore_green, fore_blue = f_rgb
+        back_red, back_green, back_blue = b_rgb
         cid = self.display.allocate_resource_id()
         request.CreateCursor(display = self.display,
                              cid = cid,
$NetBSD: patch-Xlib_xobject_fontable.py,v 1.1 2011/08/22 12:18:19 wiz Exp $

Python-3.1 compatibility.

--- Xlib/xobject/fontable.py.orig	2007-06-10 14:11:59.000000000 +0000
+++ Xlib/xobject/fontable.py
@@ -87,8 +87,9 @@ class Font(Fontable):
         self.display.free_resource_id(self.id)
 
     def create_glyph_cursor(self, mask, source_char, mask_char,
-                            (fore_red, fore_green, fore_blue),
-                            (back_red, back_green, back_blue)):
+                            f_rgb, b_rgb):
+        fore_red, fore_green, fore_blue = f_rgb
+        back_red, back_green, back_blue = b_rgb
 
         cid = self.display.allocate_resource_id()
         request.CreateGlyphCursor(display = self.display,
