Skip to content

Commit 09f8ec2

Browse files
committed
Fix breakage by Python 2.2
1 parent 156fa34 commit 09f8ec2

2 files changed

Lines changed: 23 additions & 4 deletions

File tree

Xlib/ChangeLog

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
2002-03-30 Peter Liljenberg <peter.liljenberg@esdgkonsult.com>
2+
3+
* support/unix_connect.py: Handle fcntl/FCNTL changes in Python
4+
2.2.
5+
16
2002-03-11 Peter Liljenberg <peter.liljenberg@esdgkonsult.com>
27

38
* xobject/drawable.py (Drawable.fill_arc): This should be a

Xlib/support/unix_connect.py

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
# $Id: unix_connect.py,v 1.1 2000-09-06 01:51:34 petli Exp $
1+
# $Id: unix_connect.py,v 1.2 2002-03-30 00:14:13 petli Exp $
22
#
33
# Xlib.support.unix_connect -- Unix-type display connection functions
44
#
5-
# Copyright (C) 2000 Peter Liljenberg <petli@ctrl-c.liu.se>
5+
# Copyright (C) 2000,2002 Peter Liljenberg <petli@ctrl-c.liu.se>
66
#
77
# This program is free software; you can redistribute it and/or modify
88
# it under the terms of the GNU General Public License as published by
@@ -22,8 +22,22 @@
2222
import string
2323
import os
2424
import socket
25+
26+
# FCNTL is deprecated from Python 2.2, so only import it if we doesn't
27+
# get the names we need. Furthermore, FD_CLOEXEC seems to be missing
28+
# in Python 2.2.
29+
2530
import fcntl
26-
import FCNTL
31+
32+
if hasattr(fcntl, 'F_SETFD'):
33+
F_SETFD = fcntl.F_SETFD
34+
if hasattr(fcntl, 'FD_CLOEXEC'):
35+
FD_CLOEXEC = fcntl.FD_CLOEXEC
36+
else:
37+
FD_CLOEXEC = 1
38+
else:
39+
from FCNTL import F_SETFD, FD_CLOEXEC
40+
2741

2842
from Xlib import error
2943

@@ -65,7 +79,7 @@ def get_socket(dname, host, dno):
6579
raise error.DisplayConnectionError(dname, str(val))
6680

6781
# Make sure that the connection isn't inherited in child processes
68-
fcntl.fcntl(s.fileno(), FCNTL.F_SETFD, FCNTL.FD_CLOEXEC)
82+
fcntl.fcntl(s.fileno(), F_SETFD, FD_CLOEXEC)
6983

7084
return s
7185

0 commit comments

Comments
 (0)