Subject: pkg/23500: lang/python23-pth configure inconsistency (and possibly other pythons)
To: None <gnats-bugs@gnats.netbsd.org>
From: Michal Pasternak <dotz@irc.pl>
List: netbsd-bugs
Date: 11/19/2003 21:51:10
>Number:         23500
>Category:       pkg
>Synopsis:       lang/python23-pth configure inconsistency (and possibly other pythons)
>Confidential:   no
>Severity:       critical
>Priority:       high
>Responsible:    pkg-manager
>State:          open
>Class:          change-request
>Submitter-Id:   net
>Arrival-Date:   Wed Nov 19 21:51:00 UTC 2003
>Closed-Date:
>Last-Modified:
>Originator:     Michal Pasternak
>Release:        NetBSD 1.6.1
>Organization:
Good People With Bad Reputation
>Environment:
System: NetBSD mainframe.w.lub.pl 1.6.1 NetBSD 1.6.1 (GENERIC) #0: Tue Apr 8 12:05:52 UTC 2003 autobuild@tgm.daemon.org:/autobuild/netbsd-1-6/i386/OBJ/autobuild/netbsd-1-6/src/sys/arch/i386/compile/GENERIC i386
Architecture: i386
Machine: i386
>Description:

	"os" module in Python is a module, which wraps many POSIX functions.

	Today, while testing some software, it appeared to me, that "os"
	module does NOT contain procedure "setgroups", which is PRESENT
	as setgroups(2) in BSD - according to manpage, since 4.2BSD.

	I started investigating.

	As it came out:

	1) on NetBSD 1.6.1, setgroups call is located in /usr/include/unistd.h and
	   it is flanked by ifdef like:

		#if !defined(_POSIX_C_SOURCE) && !defined(_XOPEN_SOURCE)

	2) configure, while creating confdefs.h, happily adds both defines to the
	   beginning of the confdefs.h file

	3) confdefs.h is, as usual, included in conftest.h while testing for 
	   presence of setgroups(2) call
	
	4) result? Python "os" module, which doesn't have setgroups call on NetBSD.

	And this is BAD. Some might say, that this is VERY, VERY BAD. Well.

	I have included a quick diff to fix it. I have tested it with python23-pth. 
	It works. It gives good results. It propably occurs in other Python versions,
	but I don't have neither resources nor need to check them. 

	The diff's a little cluttered, but you should get the idea.

	IMHO this change should be commited (even if it's pkgsrc freeze now), because:
	* it fixes a quite serious problem with NetBSD's Python os module
	* it will NOT break anything on non-NetBSD platforms
	* it affects ONLY the configure script, it doesn't mess with Python internals

	You can, of course, ignore it and wait with it until pkgsrc freeze ends, but
	don't say I haven't warned you about it :)

>How-To-Repeat:

	doc@mainframe:~> python2p3 
	Python 2p3 (#1, Sep 17 2003, 16:48:22) 
	[GCC 2.95.3 20010315 (release) (NetBSD nb3)] on netbsd1
	Type "help", "copyright", "credits" or "license" for more information.
	>>> import os
	>>> os.setgroups
	Traceback (most recent call last):
	  File "<stdin>", line 1, in ?
	AttributeError: 'module' object has no attribute 'setgroups'

	And, after patch/make replace:

	doc@mainframe:~> python2p3
	Python 2p3 (#1, Nov 19 2003, 22:40:23) 
	[GCC 2.95.3 20010315 (release) (NetBSD nb3)] on netbsd1
	Type "help", "copyright", "credits" or "license" for more information.
	>>> import os
	>>> os.setgroups
	<built-in function setgroups>
	
	Sweet!

>Fix:
Index: distinfo
===================================================================
RCS file: /cvsroot/pkgsrc/lang/python23-pth/distinfo,v
retrieving revision 1.7
diff -u -r1.7 distinfo
--- distinfo	2003/09/14 14:04:32	1.7
+++ distinfo	2003/11/19 21:48:01
@@ -13,4 +13,4 @@
 SHA1 (patch-am) = 20235b2febbc2811ca5f9b54958a4064722431ed
 SHA1 (patch-ba) = 9be4490e38c895dfc5041af1889ca7ab1c6d8bd9
 SHA1 (patch-bb) = 1390c5f0bcd75f5f3f1b9949921b555e1021954f
-SHA1 (patch-bc) = 0a83a90aea8a1414b43fa3506912ab09aafbc3c0
+SHA1 (patch-bc) = 3780f6fb316de52acba37805fd1f744b94da8ff4
Index: patches/patch-bc
===================================================================
RCS file: /cvsroot/pkgsrc/lang/python23-pth/patches/patch-bc,v
retrieving revision 1.1
diff -u -r1.1 patch-bc
--- patches/patch-bc	2003/09/10 00:11:04	1.1
+++ patches/patch-bc	2003/11/19 21:48:01
@@ -1,8 +1,8 @@
-$NetBSD: patch-bc,v 1.1 2003/09/10 00:11:04 recht Exp $
+$NetBSD$
 
---- configure.orig	Thu Jul 24 00:17:27 2003
-+++ configure
-@@ -1365,6 +1365,8 @@ case $ac_sys_system/$ac_sys_release in
+--- configure.orig	Wed Nov 19 22:25:08 2003
++++ configure	Wed Nov 19 22:27:07 2003
+@@ -1365,6 +1365,8 @@
    # Reconfirmed for OpenBSD 3.3 by Zachary Hamm.
    OpenBSD/2.* | OpenBSD/3.[0123])
      define_xopen_source=no;;
@@ -11,7 +11,7 @@
    # On Solaris 2.6, sys/wait.h is inconsistent in the usage
    # of union __?sigval. Reported by Stuart Bishop.
    SunOS/5.6)
-@@ -13079,6 +13081,7 @@ cat >conftest.$ac_ext <<_ACEOF
+@@ -13079,6 +13081,7 @@
  #include "confdefs.h"
  
  #include "confdefs.h"
@@ -19,3 +19,14 @@
  #include <sys/socket.h>
  #include <netinet/in.h>
  #include <arpa/inet.h>
+@@ -13187,6 +13190,10 @@
+ #include "confdefs.h"
+ 
+ #include "confdefs.h"
++#ifdef __NetBSD__
++#undef _POSIX_C_SOURCE
++#undef _XOPEN_SOURCE
++#endif
+ #include <unistd.h>
+ #ifdef HAVE_GRP_H
+ #include <grp.h>
>Release-Note:
>Audit-Trail:
>Unformatted: