classification
Title: move getopt() to Py_GetOpt() and use it unconditionally
Type: Stage:
Components: Interpreter Core Versions:
process
Status: closed Resolution:
Dependencies: Superseder:
Assigned To: twouters Nosy List: fdrake, moshez, tim.peters, twouters
Priority: normal Keywords: patch

Created on 2000-10-30 17:43 by twouters, last changed 2000-11-08 22:53 by fdrake. This issue is now closed.

Files
File name Uploaded Description Edit
None twouters, 2000-10-30 17:43 None
Messages (6)
msg34725 - (view) Author: Thomas Wouters (twouters) * (Python committer) Date: 2000-10-30 17:43
 
msg34726 - (view) Author: Fred Drake (fdrake) (Python committer) Date: 2000-11-08 22:53
Already checked in, so I'll close this for Thomas.

Thanks, Thomas!
msg34727 - (view) Author: Moshe Zadka (moshez) (Python triager) Date: 2000-11-01 12:45
Well, as the one who almost got the assignment <wink>, I'm +1 on it. Using native getopt is more trouble then it's worth, especially considering the fact that we've had an implementation of our own for so long. So here's for reinventing the wheel! <wink>
msg34728 - (view) Author: Tim Peters (tim.peters) * (Python committer) Date: 2000-11-02 05:00
Accepted and assigned back to Thomas.

Guido approved of this "in theory" before, so go for it!  I would like to see the function renamed to _PyOS_GetOpt(), because we always stick "OS" in the name of an OS substitute function, and the leading underscore keeps it out of the public API (thus answering one of your open issues:  if people clamor for a public getopt replacement, we can add that later; but if we make it public from the start, it can never go away).

About the license, we can't change it, but it certainly allows us to modify the code and distribute your changes.  Under copyright law, I don't believe the changes are substantial enough that we could legitimately claim a new copyright for the new version.  So the whole license thing seems a non-issue to me.

Documentation?  If it's in the private API, it doesn't need any <wink>.

fprintf(stderr, ...)?  Sure.  Python barely exists by the time this code is called, and there's really nothing better to do (note that Py_Main calls fprintf(stderr, ...) itself later in a couple of other startup error cases).
msg34729 - (view) Author: Thomas Wouters (twouters) * (Python committer) Date: 2000-10-30 17:48
This patch attempts to do what Tim suggested in the python-dev thread about getopt()'s prototype and the difficulties of it. the 'getopt' implementation as provided in Python/getopt.c is renamed to Py_GetOpt(), the exported variables 'opterr', 'optind' and 'optarg' are prefixed with Py_, and all use in the Python sourcetree is adjusted.

The patch is missing the 'pygetopt.h' include file, though :P I'll resubmit a proper patch later. 

There are a couple of issues still open: the name of the getopt.c file, its use of 'fprintf(stderr, ... )', its license, documentation (which this patch lacks) and whether this Py_GetOpt should be an officially exported API at all.

msg34730 - (view) Author: Thomas Wouters (twouters) * (Python committer) Date: 2000-10-30 18:08
New patch, includes pygetopt.h by hack. (not sure if it patches cleanly, but it's not that exciting a file anyway :) Assigned to.... (spin wheel... Guido. no. spin wheel... Barry. no. spin wheel... Moshe. dang. spin wheel... *nudge*. Ah, finally,) Tim.

History
Date User Action Args
2000-10-30 17:43:03twouterscreate