diff -r 9cd3ab7c09d1 -r 9ac347a7f375 .bzrignore --- a/.bzrignore Sat Jul 19 16:34:33 2014 -0700 +++ b/.bzrignore Sun Jul 20 10:52:46 2014 -0400 @@ -11,7 +11,6 @@ build Makefile.pre platform -pybuilddir.txt pyconfig.h libpython*.a libpython*.so* diff -r 9cd3ab7c09d1 -r 9ac347a7f375 .hgeol --- a/.hgeol Sat Jul 19 16:34:33 2014 -0700 +++ b/.hgeol Sun Jul 20 10:52:46 2014 -0400 @@ -10,8 +10,6 @@ **.vsprops = BIN **.aif = BIN -**.aifc = BIN -**.aiff = BIN **.au = BIN **.bmp = BIN **.db = BIN @@ -25,7 +23,6 @@ **.png = BIN **.psd = BIN **.tar = BIN -**.wav = BIN **.xar = BIN **.zip = BIN diff -r 9cd3ab7c09d1 -r 9ac347a7f375 .hgignore --- a/.hgignore Sat Jul 19 16:34:33 2014 -0700 +++ b/.hgignore Sun Jul 20 10:52:46 2014 -0400 @@ -1,8 +1,6 @@ .gdb_history .purify .svn/ -^.idea/ -.DS_Store Makefile$ Makefile.pre$ TAGS$ @@ -36,7 +34,6 @@ Parser/pgen.stamp$ ^core ^python-gdb.py -^pybuilddir.txt syntax: glob python.exe-gdb.py diff -r 9cd3ab7c09d1 -r 9ac347a7f375 .hgtags --- a/.hgtags Sat Jul 19 16:34:33 2014 -0700 +++ b/.hgtags Sun Jul 20 10:52:46 2014 -0400 @@ -137,9 +137,6 @@ c1dc9e7986a2a8e1070ec7bee748520febef382e v2.6.6rc1 e189dc8fd66154ef46d9cd22584d56669b544ca3 v2.6.6rc2 9f8771e0905277f8b3c2799113a062fda4164995 v2.6.6 -caab08cd2b3eb5a6f78479b2513b65d36c754f41 v2.6.8rc1 -1d1b7b9fad48bd0dc60dc8a06cca4459ef273127 v2.6.8rc2 -c9910fd022fc842e5578e1bf5a30ba55a37239fc v2.6.8 b4107eb00b4271fb73a9e1b736d4f23460950778 v2.7a1 adc85ebc7271cc22e24e816782bb2b8d7fa3a6b3 v2.7a2 4180557b7a9bb9dd5341a18af199f843f199e46e v2.7a3 @@ -153,16 +150,3 @@ 5395f96588d4f0199d329cb79eb109648dc4ef5e v2.7.1 f48756685406e8d0fa9d23d841fceb07e36a5656 v2.7.2rc1 8527427914a29d895bcb30be76a465143993a793 v2.7.2 -b2c6aff96e1251a4f03cf866e7e75fb8232869f2 v2.7.3rc1 -d46c1973d3c407ecaa6a8ee16d3fad3ef506b51f v2.7.3rc2 -70274d53c1ddc60c5f9a2b8a422a49884021447c v2.7.3 -a8d18780bc2bccf16bf580587e1e3c934a98f6a7 v2.7.4rc1 -026ee0057e2d3305f90a9da41daf7c3f9eb1e814 v2.7.4 -ab05e7dd27889b93f20d97bae86170aabfe45ace v2.7.5 -a0025037f11a73df5a7dd03e5a4027adad4cb94e v2.6.9rc1 -fcb3ec2842f99454322492dd0ec2cf01322df093 v2.6.9 -4913d0e9be30666218cc4d713937e81c0e7f346a v2.7.6rc1 -3a1db0d2747ec2d47a8693ed5650f3567161a200 v2.7.6 -e32e3a9f390212463c22509d0f9aead8051cee63 v2.7.7rc1 -f89216059edf77660ef1eb2a98e88352551da1d6 v2.7.7 -ee879c0ffa11caaa34bf01537e1c4411dd948552 v2.7.8 diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Demo/newmetaclasses/Eiffel.py --- a/Demo/newmetaclasses/Eiffel.py Sat Jul 19 16:34:33 2014 -0700 +++ b/Demo/newmetaclasses/Eiffel.py Sun Jul 20 10:52:46 2014 -0400 @@ -29,7 +29,7 @@ pre = dict.get("%s_pre" % m) post = dict.get("%s_post" % m) if pre or post: - dict[m] = cls.make_eiffel_method(dict[m], pre, post) + dict[k] = cls.make_eiffel_method(dict[m], pre, post) class EiffelMetaClass1(EiffelBaseMetaClass): # an implementation of the "eiffel" meta class that uses nested functions diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Demo/turtle/demohelp.txt --- a/Demo/turtle/demohelp.txt Sat Jul 19 16:34:33 2014 -0700 +++ b/Demo/turtle/demohelp.txt Sun Jul 20 10:52:46 2014 -0400 @@ -2,7 +2,7 @@ ---------------------------------------------- - turtleDemo - Help + xturtleDemo - Help ---------------------------------------------- @@ -52,33 +52,24 @@ (2) How to add your own demos to the demo repository - IMPORTANT! When imported, the demo should not modify the system - by calling functions in other modules, such as sys, tkinter, or - turtle. Global variables should be initialized in main(). - - The script name must begin with tdemo_ , + - scriptname: must begin with tdemo_ , so it must have the form tdemo_.py - - The code must contain a main() function which will - be executed by the viewer (see provided example scripts). - It may return a string which will be displayed in the Label below - the source code window (when execution has finished.) - - - In order to run mydemo.py by itself, such as during development, - add the following at the end of the file: + - place: same directory as xturtleDemo.py or some + subdirectory, the name of which must also begin with + tdemo_..... - if __name__ == '__main__': - main() - mainloop() # keep window + - requirements on source code: + code must contain a main() function which will + be executed by the viewer (see provided example scripts) + main() may return a string which will be displayed + in the Label below the source code window (when execution + has finished.) - python -m turtledemo.mydemo # will then run it + !! For programs, which are EVENT DRIVEN, main must return + !! the string "EVENTLOOP". This informs the viewer, that the + !! script is still running and must be stopped by the user! - - If the demo is EVENT DRIVEN, main must return the string - "EVENTLOOP". This informs the demo viewer that the script is - still running and must be stopped by the user! - - If an "EVENTLOOP" demo runs by itself, as with clock, which uses - ontimer, or minimal_hanoi, which loops by recursion, then the - code should catch the turtle.Terminator exception that will be - raised when the user presses the STOP button. (Paint is not such - a demo; it only acts in response to mouse clicks and movements.) + + diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Demo/turtle/tdemo_clock.py --- a/Demo/turtle/tdemo_clock.py Sat Jul 19 16:34:33 2014 -0700 +++ b/Demo/turtle/tdemo_clock.py Sun Jul 20 10:52:46 2014 -0400 @@ -13,6 +13,8 @@ from turtle import * from datetime import datetime +mode("logo") + def jump(distanz, winkel=0): penup() right(winkel) @@ -40,6 +42,7 @@ hand_form = get_poly() register_shape(name, hand_form) + def clockface(radius): reset() pensize(7) @@ -80,6 +83,7 @@ writer.pu() writer.bk(85) + def wochentag(t): wochentag = ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"] @@ -98,25 +102,22 @@ sekunde = t.second + t.microsecond*0.000001 minute = t.minute + sekunde/60.0 stunde = t.hour + minute/60.0 - try: - tracer(False) # Terminator can occur here - writer.clear() - writer.home() - writer.forward(65) - writer.write(wochentag(t), - align="center", font=("Courier", 14, "bold")) - writer.back(150) - writer.write(datum(t), - align="center", font=("Courier", 14, "bold")) - writer.forward(85) - tracer(True) - second_hand.setheading(6*sekunde) # or here - minute_hand.setheading(6*minute) - hour_hand.setheading(30*stunde) - tracer(True) - ontimer(tick, 100) - except Terminator: - pass # turtledemo user pressed STOP + tracer(False) + writer.clear() + writer.home() + writer.forward(65) + writer.write(wochentag(t), + align="center", font=("Courier", 14, "bold")) + writer.back(150) + writer.write(datum(t), + align="center", font=("Courier", 14, "bold")) + writer.forward(85) + tracer(True) + second_hand.setheading(6*sekunde) + minute_hand.setheading(6*minute) + hour_hand.setheading(30*stunde) + tracer(True) + ontimer(tick, 100) def main(): tracer(False) @@ -126,7 +127,6 @@ return "EVENTLOOP" if __name__ == "__main__": - mode("logo") msg = main() print msg - mainloop() # keep window open + mainloop() diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Demo/turtle/tdemo_minimal_hanoi.py --- a/Demo/turtle/tdemo_minimal_hanoi.py Sat Jul 19 16:34:33 2014 -0700 +++ b/Demo/turtle/tdemo_minimal_hanoi.py Sun Jul 20 10:52:46 2014 -0400 @@ -50,12 +50,9 @@ def play(): onkey(None,"space") clear() - try: - hanoi(6, t1, t2, t3) - write("press STOP button to exit", - align="center", font=("Courier", 16, "bold")) - except Terminator: - pass # turtledemo user pressed STOP + hanoi(6, t1, t2, t3) + write("press STOP button to exit", + align="center", font=("Courier", 16, "bold")) def main(): global t1, t2, t3 diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Demo/turtle/tdemo_nim.py --- a/Demo/turtle/tdemo_nim.py Sat Jul 19 16:34:33 2014 -0700 +++ b/Demo/turtle/tdemo_nim.py Sun Jul 20 10:52:46 2014 -0400 @@ -1,7 +1,7 @@ """ turtle-example-suite: tdemo_nim.py - + Play nim against the computer. The player who takes the last stick is the winner. @@ -41,7 +41,7 @@ return move def randommove(state): - m = max(state) + m = max(state) while True: z = random.randint(0,2) if state[z] > (m > 1): @@ -62,7 +62,7 @@ self.winner = None self.game.view.setup() self.game.state = Nim.RUNNING - + def move(self, row, col): maxspalte = self.sticks[row] self.sticks[row] = col @@ -76,7 +76,7 @@ row, col = computerzug(self.sticks) self.move(row, col) self.player = 0 - + def game_over(self): return self.sticks == [0, 0, 0] @@ -100,13 +100,13 @@ self.goto(x,y) self.color("white") self.showturtle() - + def coords(self, row, col): packet, remainder = divmod(col, 5) x = (3 + 11 * packet + 2 * remainder) * WUNIT y = (2 + 3 * row) * HUNIT return x - SCREENWIDTH // 2 + WUNIT // 2, SCREENHEIGHT // 2 - y - HUNIT // 2 - + def makemove(self, x, y): if self.game.state != Nim.RUNNING: return @@ -142,7 +142,7 @@ self.writer.pencolor("black") self.writer.write(msg1, align="center", font=("Courier",14,"bold")) self.screen.tracer(True) - + def setup(self): self.screen.tracer(False) @@ -181,7 +181,6 @@ if self.game.state == Nim.OVER: self.screen.clear() - class NimController(object): def __init__(self, game): @@ -201,26 +200,28 @@ self.BUSY = True self.game.model.notify_move(row, col) self.BUSY = False - + class Nim(object): CREATED = 0 RUNNING = 1 OVER = 2 def __init__(self, screen): - self.state = Nim.CREATED + self.state = Nim.CREATED self.screen = screen self.model = NimModel(self) self.view = NimView(self) self.controller = NimController(self) + +mainscreen = turtle.Screen() +mainscreen.mode("standard") +mainscreen.setup(SCREENWIDTH, SCREENHEIGHT) def main(): - mainscreen = turtle.Screen() - mainscreen.mode("standard") - mainscreen.setup(SCREENWIDTH, SCREENHEIGHT) nim = Nim(mainscreen) return "EVENTLOOP!" if __name__ == "__main__": main() turtle.mainloop() + diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Demo/turtle/tdemo_paint.py --- a/Demo/turtle/tdemo_paint.py Sat Jul 19 16:34:33 2014 -0700 +++ b/Demo/turtle/tdemo_paint.py Sun Jul 20 10:52:46 2014 -0400 @@ -3,15 +3,11 @@ tdemo_paint.py -A simple event-driven paint program +A simple eventdriven paint program -- left mouse button moves turtle -- middle mouse button changes color -- right mouse button toogles betweem pen up -(no line drawn when the turtle moves) and -pen down (line is drawn). If pen up follows -at least two pen-down moves, the polygon that -includes the starting point is filled. +- use left mouse button to move turtle +- middle mouse button to change color +- right mouse button do turn filling on/off ------------------------------------------- Play around by clicking into the canvas using all three mouse buttons. diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Demo/turtle/tdemo_peace.py --- a/Demo/turtle/tdemo_peace.py Sat Jul 19 16:34:33 2014 -0700 +++ b/Demo/turtle/tdemo_peace.py Sun Jul 20 10:52:46 2014 -0400 @@ -3,10 +3,14 @@ tdemo_peace.py -A simple drawing suitable as a beginner's -programming example. Aside from the -peacecolors assignment and the for loop, -it only uses turtle commands. +A very simple drawing suitable as a beginner's +programming example. + +Uses only commands, which are also available in +old turtle.py. + +Intentionally no variables are used except for the +colorloop: """ from turtle import * @@ -17,7 +21,7 @@ "royalblue1", "dodgerblue4") reset() - Screen() + s = Screen() up() goto(-320,-195) width(70) @@ -54,7 +58,7 @@ up() goto(0,300) # vanish if hideturtle() is not available ;-) - return "Done!" + return "Done!!" if __name__ == "__main__": main() diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Demo/turtle/tdemo_planet_and_moon.py --- a/Demo/turtle/tdemo_planet_and_moon.py Sat Jul 19 16:34:33 2014 -0700 +++ b/Demo/turtle/tdemo_planet_and_moon.py Sun Jul 20 10:52:46 2014 -0400 @@ -12,9 +12,9 @@ Planet has a circular orbit, moon a stable orbit around the planet. -You can hold the movement temporarily by -pressing the left mouse button with the -mouse over the scrollbar of the canvas. +You can hold the movement temporarily by pressing +the left mouse button with mouse over the +scrollbar of the canvas. """ from turtle import Shape, Turtle, mainloop, Vec2D as Vec @@ -108,5 +108,6 @@ return "Done!" if __name__ == '__main__': - main() + msg = main() + print msg mainloop() diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Demo/turtle/tdemo_tree.py --- a/Demo/turtle/tdemo_tree.py Sat Jul 19 16:34:33 2014 -0700 +++ b/Demo/turtle/tdemo_tree.py Sun Jul 20 10:52:46 2014 -0400 @@ -11,9 +11,9 @@ (1) a tree-generator, where the drawing is quasi the side-effect, whereas the generator always yields None. -(2) Turtle-cloning: At each branching point -the current pen is cloned. So in the end -there are 1024 turtles. +(2) Turtle-cloning: At each branching point the +current pen is cloned. So in the end there +are 1024 turtles. """ from turtle import Turtle, mainloop from time import clock diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Demo/turtle/tdemo_two_canvases.py --- a/Demo/turtle/tdemo_two_canvases.py Sat Jul 19 16:34:33 2014 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,54 +0,0 @@ -"""turtledemo.two_canvases - -Use TurtleScreen and RawTurtle to draw on two -distinct canvases in a separate windows. The -new window must be separately closed in -addition to pressing the STOP button. -""" - -from turtle import TurtleScreen, RawTurtle, TK - -def main(): - root = TK.Tk() - cv1 = TK.Canvas(root, width=300, height=200, bg="#ddffff") - cv2 = TK.Canvas(root, width=300, height=200, bg="#ffeeee") - cv1.pack() - cv2.pack() - - s1 = TurtleScreen(cv1) - s1.bgcolor(0.85, 0.85, 1) - s2 = TurtleScreen(cv2) - s2.bgcolor(1, 0.85, 0.85) - - p = RawTurtle(s1) - q = RawTurtle(s2) - - p.color("red", (1, 0.85, 0.85)) - p.width(3) - q.color("blue", (0.85, 0.85, 1)) - q.width(3) - - for t in p,q: - t.shape("turtle") - t.lt(36) - - q.lt(180) - - for t in p, q: - t.begin_fill() - for i in range(5): - for t in p, q: - t.fd(50) - t.lt(72) - for t in p,q: - t.end_fill() - t.lt(54) - t.pu() - t.bk(50) - - return "EVENTLOOP" - - -if __name__ == '__main__': - main() - TK.mainloop() # keep window open until user closes it diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Demo/turtle/turtleDemo.py --- a/Demo/turtle/turtleDemo.py Sat Jul 19 16:34:33 2014 -0700 +++ b/Demo/turtle/turtleDemo.py Sun Jul 20 10:52:46 2014 -0400 @@ -5,17 +5,11 @@ from Tkinter import * from idlelib.Percolator import Percolator from idlelib.ColorDelegator import ColorDelegator -from idlelib.textView import view_file +from idlelib.textView import TextViewer import turtle import time -demo_dir = os.getcwd() -if "turtleDemo.py" not in os.listdir(demo_dir): - print "Directory of turtleDemo must be current working directory!" - print "But in your case this is", demo_dir - sys.exit() - STARTUP = 1 READY = 2 RUNNING = 3 @@ -27,7 +21,12 @@ txtfont = ('Lucida Console', 8, 'normal') def getExampleEntries(): - entries1 = [entry for entry in os.listdir(demo_dir) if + cwd = os.getcwd() + if "turtleDemo.py" not in os.listdir(cwd): + print "Directory of turtleDemo must be current working directory!" + print "But in your case this is", cwd + sys.exit() + entries1 = [entry for entry in os.listdir(cwd) if entry.startswith("tdemo_") and not entry.endswith(".pyc")] entries2 = [] @@ -35,7 +34,7 @@ if entry.endswith(".py"): entries2.append(entry) else: - path = os.path.join(demo_dir, entry) + path = os.path.join(cwd,entry) sys.path.append(path) subdir = [entry] scripts = [script for script in os.listdir(path) if @@ -45,16 +44,13 @@ return entries2 def showDemoHelp(): - view_file(demo.root, "Help on turtleDemo", - os.path.join(demo_dir, "demohelp.txt")) + TextViewer(demo.root, "Help on turtleDemo", "demohelp.txt") def showAboutDemo(): - view_file(demo.root, "About turtleDemo", - os.path.join(demo_dir, "about_turtledemo.txt")) + TextViewer(demo.root, "About turtleDemo", "about_turtledemo.txt") def showAboutTurtle(): - view_file(demo.root, "About the new turtle module.", - os.path.join(demo_dir, "about_turtle.txt")) + TextViewer(demo.root, "About the new turtle module", "about_turtle.txt") class DemoWindow(object): diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Demo/turtle/turtledemo_two_canvases.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Demo/turtle/turtledemo_two_canvases.py Sun Jul 20 10:52:46 2014 -0400 @@ -0,0 +1,49 @@ +#!/usr/bin/env python +## DEMONSTRATES USE OF 2 CANVASES, SO CANNOT BE RUN IN DEMOVIEWER! +"""turtle example: Using TurtleScreen and RawTurtle +for drawing on two distinct canvases. +""" +from turtle import TurtleScreen, RawTurtle, TK + +root = TK.Tk() +cv1 = TK.Canvas(root, width=300, height=200, bg="#ddffff") +cv2 = TK.Canvas(root, width=300, height=200, bg="#ffeeee") +cv1.pack() +cv2.pack() + +s1 = TurtleScreen(cv1) +s1.bgcolor(0.85, 0.85, 1) +s2 = TurtleScreen(cv2) +s2.bgcolor(1, 0.85, 0.85) + +p = RawTurtle(s1) +q = RawTurtle(s2) + +p.color("red", "white") +p.width(3) +q.color("blue", "black") +q.width(3) + +for t in p,q: + t.shape("turtle") + t.lt(36) + +q.lt(180) + +for i in range(5): + for t in p, q: + t.fd(50) + t.lt(72) +for t in p,q: + t.lt(54) + t.pu() + t.bk(50) + +## Want to get some info? + +print s1, s2 +print p, q +print s1.turtles() +print s2.turtles() + +TK.mainloop() diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/ACKS.txt --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Doc/ACKS.txt Sun Jul 20 10:52:46 2014 -0400 @@ -0,0 +1,229 @@ +Contributors to the Python Documentation +---------------------------------------- + +This section lists people who have contributed in some way to the Python +documentation. It is probably not complete -- if you feel that you or +anyone else should be on this list, please let us know (send email to +docs@python.org), and we'll be glad to correct the problem. + +.. acks:: + + * Aahz + * Michael Abbott + * Steve Alexander + * Jim Ahlstrom + * Fred Allen + * A. Amoroso + * Pehr Anderson + * Oliver Andrich + * Heidi Annexstad + * Jesús Cea Avión + * Manuel Balsera + * Daniel Barclay + * Chris Barker + * Don Bashford + * Anthony Baxter + * Alexander Belopolsky + * Bennett Benson + * Jonathan Black + * Robin Boerdijk + * Michal Bozon + * Aaron Brancotti + * Georg Brandl + * Keith Briggs + * Ian Bruntlett + * Lee Busby + * Lorenzo M. Catucci + * Carl Cerecke + * Mauro Cicognini + * Gilles Civario + * Mike Clarkson + * Steve Clift + * Dave Cole + * Matthew Cowles + * Jeremy Craven + * Andrew Dalke + * Ben Darnell + * L. Peter Deutsch + * Robert Donohue + * Fred L. Drake, Jr. + * Josip Dzolonga + * Jeff Epler + * Michael Ernst + * Blame Andy Eskilsson + * Carey Evans + * Martijn Faassen + * Carl Feynman + * Dan Finnie + * Hernán Martínez Foffani + * Stefan Franke + * Jim Fulton + * Peter Funk + * Lele Gaifax + * Matthew Gallagher + * Gabriel Genellina + * Ben Gertzfield + * Nadim Ghaznavi + * Jonathan Giddy + * Shelley Gooch + * Nathaniel Gray + * Grant Griffin + * Thomas Guettler + * Anders Hammarquist + * Mark Hammond + * Harald Hanche-Olsen + * Manus Hand + * Gerhard Häring + * Travis B. Hartwell + * Tim Hatch + * Janko Hauser + * Ben Hayden + * Thomas Heller + * Bernhard Herzog + * Magnus L. Hetland + * Konrad Hinsen + * Stefan Hoffmeister + * Albert Hofkamp + * Gregor Hoffleit + * Steve Holden + * Thomas Holenstein + * Gerrit Holl + * Rob Hooft + * Brian Hooper + * Randall Hopper + * Michael Hudson + * Eric Huss + * Jeremy Hylton + * Roger Irwin + * Jack Jansen + * Philip H. Jensen + * Pedro Diaz Jimenez + * Kent Johnson + * Lucas de Jonge + * Andreas Jung + * Robert Kern + * Jim Kerr + * Jan Kim + * Kamil Kisiel + * Greg Kochanski + * Guido Kollerie + * Peter A. Koren + * Daniel Kozan + * Andrew M. Kuchling + * Dave Kuhlman + * Erno Kuusela + * Ross Lagerwall + * Thomas Lamb + * Detlef Lannert + * Piers Lauder + * Glyph Lefkowitz + * Robert Lehmann + * Marc-André Lemburg + * Ross Light + * Ulf A. Lindgren + * Everett Lipman + * Mirko Liss + * Martin von Löwis + * Fredrik Lundh + * Jeff MacDonald + * John Machin + * Andrew MacIntyre + * Vladimir Marangozov + * Vincent Marchetti + * Westley Martínez + * Laura Matson + * Daniel May + * Rebecca McCreary + * Doug Mennella + * Paolo Milani + * Skip Montanaro + * Paul Moore + * Ross Moore + * Sjoerd Mullender + * Dale Nagata + * Michal Nowikowski + * Steffen Daode Nurpmeso + * Ng Pheng Siong + * Koray Oner + * Tomas Oppelstrup + * Denis S. Otkidach + * Zooko O'Whielacronx + * Shriphani Palakodety + * William Park + * Joonas Paalasmaa + * Harri Pasanen + * Bo Peng + * Tim Peters + * Benjamin Peterson + * Christopher Petrilli + * Justin D. Pettit + * Chris Phoenix + * François Pinard + * Paul Prescod + * Eric S. Raymond + * Edward K. Ream + * Terry J. Reedy + * Sean Reifschneider + * Bernhard Reiter + * Armin Rigo + * Wes Rishel + * Armin Ronacher + * Jim Roskind + * Guido van Rossum + * Donald Wallace Rouse II + * Mark Russell + * Nick Russo + * Chris Ryland + * Constantina S. + * Hugh Sasse + * Bob Savage + * Scott Schram + * Neil Schemenauer + * Barry Scott + * Joakim Sernbrant + * Justin Sheehy + * Charlie Shepherd + * Yue Shuaijie + * Michael Simcich + * Ionel Simionescu + * Michael Sloan + * Gregory P. Smith + * Roy Smith + * Clay Spence + * Nicholas Spies + * Tage Stabell-Kulo + * Frank Stajano + * Anthony Starks + * Greg Stein + * Peter Stoehr + * Mark Summerfield + * Reuben Sumner + * Kalle Svensson + * Jim Tittsler + * David Turner + * Sandro Tosi + * Ville Vainio + * Martijn Vries + * Charles G. Waldman + * Greg Ward + * Barry Warsaw + * Corran Webster + * Glyn Webster + * Bob Weiner + * Eddy Welbourne + * Jeff Wheeler + * Mats Wichmann + * Gerry Wiener + * Timothy Wild + * Paul Winkler + * Collin Winter + * Blake Winton + * Dan Wolfe + * Adam Woodbeck + * Steven Work + * Thomas Wouters + * Ka-Ping Yee + * Rory Yorke + * Moshe Zadka + * Milan Zamazal + * Cheng Zhang diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/Makefile --- a/Doc/Makefile Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/Makefile Sun Jul 20 10:52:46 2014 -0400 @@ -40,7 +40,7 @@ checkout: @if [ ! -d tools/sphinx ]; then \ echo "Checking out Sphinx..."; \ - svn checkout $(SVNROOT)/external/Sphinx-1.0.7/sphinx tools/sphinx; \ + svn checkout $(SVNROOT)/external/Sphinx-0.6.7/sphinx tools/sphinx; \ fi @if [ ! -d tools/docutils ]; then \ echo "Checking out Docutils..."; \ @@ -169,19 +169,12 @@ # for development releases: always build autobuild-dev: make update - make dist SPHINXOPTS='-A daily=1 -A versionswitcher=1' - -make suspicious + make dist SPHINXOPTS='-A daily=1' -# for quick rebuilds (HTML only) -autobuild-html: - make html SPHINXOPTS='-A daily=1 -A versionswitcher=1' - -# for stable releases: only build if not in pre-release stage (alpha, beta) -# release candidate downloads are okay, since the stable tree can be in that stage +# for stable releases: only build if not in pre-release stage (alpha, beta, rc) autobuild-stable: - @case $(DISTVERSION) in *[ab]*) \ + @case $(DISTVERSION) in *[abc]*) \ echo "Not building; $(DISTVERSION) is not a release version."; \ exit 1;; \ esac @make autobuild-dev - diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/README.txt --- a/Doc/README.txt Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/README.txt Sun Jul 20 10:52:46 2014 -0400 @@ -3,17 +3,18 @@ This directory contains the reStructuredText (reST) sources to the Python documentation. You don't need to build them yourself, prebuilt versions are -available at https://docs.python.org/2/download.html +available at http://docs.python.org/download/. Documentation on the authoring Python documentation, including information about both style and markup, is available in the "Documenting Python" chapter of the -documentation. +documentation. There's also a chapter intended to point out differences to +those familiar with the previous docs written in LaTeX. Building the docs ================= -You need to have Python 2 installed; the toolset used to build the +You need to have Python 2.4 or higher installed; the toolset used to build the docs is written in Python. It is called *Sphinx*, it is not included in this tree, but maintained separately. Also needed are the docutils, supplying the base markup that Sphinx uses, Jinja, a templating engine, and optionally @@ -32,9 +33,6 @@ HTML output files. To view the generated HTML, point your favorite browser at the top-level index `build/html/index.html` after running "make". -On Windows, we try to emulate the Makefile as closely as possible with a -``make.bat`` file. - Available make targets are: * "html", which builds standalone HTML files for offline viewing. @@ -67,23 +65,43 @@ `tools/sphinxext/pyspecific.py` -- pydoc needs these to show topic and keyword help. - * "suspicious", which checks the parsed markup for text that looks like - malformed and thus unconverted reST. - A "make update" updates the Subversion checkouts in `tools/`. Without make ------------ -Install the Sphinx package and its dependencies from PyPI. +You'll need to install the Sphinx package, either by checking it out via :: -Then, from the ``Docs`` directory, run :: + svn co http://svn.python.org/projects/external/Sphinx-0.6.7/sphinx tools/sphinx - sphinx-build -b . build/ +or by installing it from PyPI. -where ```` is one of html, text, latex, or htmlhelp (for explanations -see the make targets above). +Then, you need to install Docutils, either by checking it out via :: + + svn co http://svn.python.org/projects/external/docutils-0.6/docutils tools/docutils + +or by installing it from http://docutils.sf.net/. + +You also need Jinja2, either by checking it out via :: + + svn co http://svn.python.org/projects/external/Jinja-2.3.1/jinja2 tools/jinja2 + +or by installing it from PyPI. + +You can optionally also install Pygments, either as a checkout via :: + + svn co http://svn.python.org/projects/external/Pygments-1.3.1/pygments tools/pygments + +or from PyPI at http://pypi.python.org/pypi/Pygments. + + +Then, make an output directory, e.g. under `build/`, and run :: + + python tools/sphinx-build.py -b . build/ + +where `` is one of html, text, latex, or htmlhelp (for explanations see +the make targets above). Contributing @@ -109,7 +127,7 @@ as long as you don't change or remove the copyright notice: ---------------------------------------------------------------------- -Copyright (c) 2000-2014 Python Software Foundation. +Copyright (c) 2000-2008 Python Software Foundation. All rights reserved. Copyright (c) 2000 BeOpen.com. diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/about.rst --- a/Doc/about.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/about.rst Sun Jul 20 10:52:46 2014 -0400 @@ -7,15 +7,14 @@ document processor specifically written for the Python documentation. .. _reStructuredText: http://docutils.sf.net/rst.html -.. _Sphinx: http://sphinx-doc.org/ +.. _Sphinx: http://sphinx.pocoo.org/ .. In the online version of these documents, you can submit comments and suggest changes directly on the documentation pages. -Development of the documentation and its toolchain is an entirely volunteer -effort, just like Python itself. If you want to contribute, please take a -look at the :ref:`reporting-bugs` page for information on how to do so. New -volunteers are always welcome! +Development of the documentation and its toolchain takes place on the +docs@python.org mailing list. We're always looking for volunteers wanting +to help with the docs, so feel free to send a mail there! Many thanks go to: @@ -27,13 +26,11 @@ `_ project from which Sphinx got many good ideas. +See :ref:`reporting-bugs` for information how to report bugs in this +documentation, or Python itself. -Contributors to the Python Documentation ----------------------------------------- - -Many people have contributed to the Python language, the Python standard -library, and the Python documentation. See :source:`Misc/ACKS` in the Python -source distribution for a partial list of contributors. +.. including the ACKS file here so that it can be maintained separately +.. include:: ACKS.txt It is only with the input and contributions of the Python community that Python has such wonderful documentation -- Thank You! diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/bugs.rst --- a/Doc/bugs.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/bugs.rst Sun Jul 20 10:52:46 2014 -0400 @@ -13,17 +13,15 @@ ================== If you find a bug in this documentation or would like to propose an improvement, -please submit a bug report on the :ref:`tracker `. If you -have a suggestion how to fix it, include that as well. +please send an e-mail to docs@python.org describing the bug and where you found +it. If you have a suggestion how to fix it, include that as well. -If you're short on time, you can also email your bug report to docs@python.org. -'docs@' is a mailing list run by volunteers; your request will be noticed, -though it may take a while to be processed. +docs@python.org is a mailing list run by volunteers; your request will be +noticed, even if it takes a while to be processed. -.. seealso:: - `Documentation bugs`_ on the Python issue tracker +Of course, if you want a more persistent record of your issue, you can use the +issue tracker for documentation bugs as well. -.. _using-the-tracker: Using the Python issue tracker ============================== @@ -59,7 +57,8 @@ Each bug report will be assigned to a developer who will determine what needs to be done to correct the problem. You will receive an update each time action is -taken on the bug. +taken on the bug. See http://www.python.org/dev/workflow/ for a detailed +description of the issue workflow. .. seealso:: @@ -72,16 +71,3 @@ Information about writing a good bug report. Some of this is specific to the Mozilla project, but describes general good practices. - -Getting started contributing to Python yourself -=============================================== - -Beyond just reporting bugs that you find, you are also welcome to submit -patches to fix them. You can find more information on how to get started -patching Python in the `Python Developer's Guide`_. If you have questions, -the `core-mentorship mailing list`_ is a friendly place to get answers to -any and all questions pertaining to the process of fixing issues in Python. - -.. _Documentation bugs: http://bugs.python.org/issue?@filter=status&@filter=components&components=4&status=1&@columns=id,activity,title,status&@sort=-activity -.. _Python Developer's Guide: http://docs.python.org/devguide/ -.. _core-mentorship mailing list: https://mail.python.org/mailman/listinfo/core-mentorship/ diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/c-api/abstract.rst --- a/Doc/c-api/abstract.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/c-api/abstract.rst Sun Jul 20 10:52:46 2014 -0400 @@ -13,7 +13,7 @@ will raise a Python exception. It is not possible to use these functions on objects that are not properly -initialized, such as a list object that has been created by :c:func:`PyList_New`, +initialized, such as a list object that has been created by :cfunc:`PyList_New`, but whose items have not been set to some non-\ ``NULL`` value yet. .. toctree:: diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/c-api/allocation.rst --- a/Doc/c-api/allocation.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/c-api/allocation.rst Sun Jul 20 10:52:46 2014 -0400 @@ -6,20 +6,20 @@ ============================== -.. c:function:: PyObject* _PyObject_New(PyTypeObject *type) +.. cfunction:: PyObject* _PyObject_New(PyTypeObject *type) -.. c:function:: PyVarObject* _PyObject_NewVar(PyTypeObject *type, Py_ssize_t size) +.. cfunction:: PyVarObject* _PyObject_NewVar(PyTypeObject *type, Py_ssize_t size) .. versionchanged:: 2.5 - This function used an :c:type:`int` type for *size*. This might require + This function used an :ctype:`int` type for *size*. This might require changes in your code for properly supporting 64-bit systems. -.. c:function:: void _PyObject_Del(PyObject *op) +.. cfunction:: void _PyObject_Del(PyObject *op) -.. c:function:: PyObject* PyObject_Init(PyObject *op, PyTypeObject *type) +.. cfunction:: PyObject* PyObject_Init(PyObject *op, PyTypeObject *type) Initialize a newly-allocated object *op* with its type and initial reference. Returns the initialized object. If *type* indicates that the @@ -28,51 +28,51 @@ affected. -.. c:function:: PyVarObject* PyObject_InitVar(PyVarObject *op, PyTypeObject *type, Py_ssize_t size) +.. cfunction:: PyVarObject* PyObject_InitVar(PyVarObject *op, PyTypeObject *type, Py_ssize_t size) - This does everything :c:func:`PyObject_Init` does, and also initializes the + This does everything :cfunc:`PyObject_Init` does, and also initializes the length information for a variable-size object. .. versionchanged:: 2.5 - This function used an :c:type:`int` type for *size*. This might require + This function used an :ctype:`int` type for *size*. This might require changes in your code for properly supporting 64-bit systems. -.. c:function:: TYPE* PyObject_New(TYPE, PyTypeObject *type) +.. cfunction:: TYPE* PyObject_New(TYPE, PyTypeObject *type) Allocate a new Python object using the C structure type *TYPE* and the Python type object *type*. Fields not defined by the Python object header are not initialized; the object's reference count will be one. The size of - the memory allocation is determined from the :c:member:`~PyTypeObject.tp_basicsize` field of + the memory allocation is determined from the :attr:`tp_basicsize` field of the type object. -.. c:function:: TYPE* PyObject_NewVar(TYPE, PyTypeObject *type, Py_ssize_t size) +.. cfunction:: TYPE* PyObject_NewVar(TYPE, PyTypeObject *type, Py_ssize_t size) Allocate a new Python object using the C structure type *TYPE* and the Python type object *type*. Fields not defined by the Python object header are not initialized. The allocated memory allows for the *TYPE* structure - plus *size* fields of the size given by the :c:member:`~PyTypeObject.tp_itemsize` field of + plus *size* fields of the size given by the :attr:`tp_itemsize` field of *type*. This is useful for implementing objects like tuples, which are able to determine their size at construction time. Embedding the array of fields into the same allocation decreases the number of allocations, improving the memory management efficiency. .. versionchanged:: 2.5 - This function used an :c:type:`int` type for *size*. This might require + This function used an :ctype:`int` type for *size*. This might require changes in your code for properly supporting 64-bit systems. -.. c:function:: void PyObject_Del(PyObject *op) +.. cfunction:: void PyObject_Del(PyObject *op) - Releases memory allocated to an object using :c:func:`PyObject_New` or - :c:func:`PyObject_NewVar`. This is normally called from the - :c:member:`~PyTypeObject.tp_dealloc` handler specified in the object's type. The fields of + Releases memory allocated to an object using :cfunc:`PyObject_New` or + :cfunc:`PyObject_NewVar`. This is normally called from the + :attr:`tp_dealloc` handler specified in the object's type. The fields of the object should not be accessed after this call as the memory is no longer a valid Python object. -.. c:function:: PyObject* Py_InitModule(char *name, PyMethodDef *methods) +.. cfunction:: PyObject* Py_InitModule(char *name, PyMethodDef *methods) Create a new module object based on a name and table of functions, returning the new module object. @@ -82,7 +82,7 @@ *methods* argument. -.. c:function:: PyObject* Py_InitModule3(char *name, PyMethodDef *methods, char *doc) +.. cfunction:: PyObject* Py_InitModule3(char *name, PyMethodDef *methods, char *doc) Create a new module object based on a name and table of functions, returning the new module object. If *doc* is non-*NULL*, it will be used @@ -93,7 +93,7 @@ *methods* argument. -.. c:function:: PyObject* Py_InitModule4(char *name, PyMethodDef *methods, char *doc, PyObject *self, int apiver) +.. cfunction:: PyObject* Py_InitModule4(char *name, PyMethodDef *methods, char *doc, PyObject *self, int apiver) Create a new module object based on a name and table of functions, returning the new module object. If *doc* is non-*NULL*, it will be used @@ -107,7 +107,7 @@ .. note:: Most uses of this function should probably be using the - :c:func:`Py_InitModule3` instead; only use this if you are sure you need + :cfunc:`Py_InitModule3` instead; only use this if you are sure you need it. .. versionchanged:: 2.3 @@ -115,7 +115,7 @@ *methods* argument. -.. c:var:: PyObject _Py_NoneStruct +.. cvar:: PyObject _Py_NoneStruct Object which is visible in Python as ``None``. This should only be accessed using the ``Py_None`` macro, which evaluates to a pointer to this diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/c-api/arg.rst --- a/Doc/c-api/arg.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/c-api/arg.rst Sun Jul 20 10:52:46 2014 -0400 @@ -9,8 +9,8 @@ methods. Additional information and examples are available in :ref:`extending-index`. -The first three of these functions described, :c:func:`PyArg_ParseTuple`, -:c:func:`PyArg_ParseTupleAndKeywords`, and :c:func:`PyArg_Parse`, all use +The first three of these functions described, :cfunc:`PyArg_ParseTuple`, +:cfunc:`PyArg_ParseTupleAndKeywords`, and :cfunc:`PyArg_Parse`, all use *format strings* which are used to tell the function about the expected arguments. The format strings use the same syntax for each of these functions. @@ -24,11 +24,6 @@ that matches the format unit; and the entry in [square] brackets is the type of the C variable(s) whose address should be passed. -These formats allow to access an object as a contiguous chunk of memory. -You don't have to provide raw storage for the returned unicode or bytes -area. Also, you won't have to release any memory yourself, except with the -``es``, ``es#``, ``et`` and ``et#`` formats. - ``s`` (string or Unicode) [const char \*] Convert a Python string or Unicode object to a C pointer to a character string. You must not provide storage for the string itself; a pointer to @@ -38,7 +33,7 @@ raised. Unicode objects are converted to C strings using the default encoding. If this conversion fails, a :exc:`UnicodeError` is raised. -``s#`` (string, Unicode or any read buffer compatible object) [const char \*, int (or :c:type:`Py_ssize_t`, see below)] +``s#`` (string, Unicode or any read buffer compatible object) [const char \*, int (or :ctype:`Py_ssize_t`, see below)] This variant on ``s`` stores into two C variables, the first one a pointer to a character string, the second one its length. In this case the Python string may contain embedded null bytes. Unicode objects pass back a @@ -47,8 +42,8 @@ a reference to the raw internal data representation. Starting with Python 2.5 the type of the length argument can be controlled - by defining the macro :c:macro:`PY_SSIZE_T_CLEAN` before including - :file:`Python.h`. If the macro is defined, length is a :c:type:`Py_ssize_t` + by defining the macro :cmacro:`PY_SSIZE_T_CLEAN` before including + :file:`Python.h`. If the macro is defined, length is a :ctype:`Py_ssize_t` rather than an int. ``s*`` (string, Unicode, or any buffer compatible object) [Py_buffer] @@ -76,14 +71,14 @@ Convert a Python Unicode object to a C pointer to a NUL-terminated buffer of 16-bit Unicode (UTF-16) data. As with ``s``, there is no need to provide storage for the Unicode data buffer; a pointer to the existing - Unicode data is stored into the :c:type:`Py_UNICODE` pointer variable whose + Unicode data is stored into the :ctype:`Py_UNICODE` pointer variable whose address you pass. ``u#`` (Unicode) [Py_UNICODE \*, int] This variant on ``u`` stores into two C variables, the first one a pointer to a Unicode data buffer, the second one its length. Non-Unicode objects are handled by interpreting their read-buffer pointer as pointer to a - :c:type:`Py_UNICODE` array. + :ctype:`Py_UNICODE` array. ``es`` (string, Unicode or character buffer compatible object) [const char \*encoding, char \*\*buffer] This variant on ``s`` is used for encoding Unicode and objects convertible @@ -91,18 +86,18 @@ embedded NUL bytes. This format requires two arguments. The first is only used as input, and - must be a :c:type:`const char\*` which points to the name of an encoding as + must be a :ctype:`const char\*` which points to the name of an encoding as a NUL-terminated string, or *NULL*, in which case the default encoding is used. An exception is raised if the named encoding is not known to Python. - The second argument must be a :c:type:`char\*\*`; the value of the pointer + The second argument must be a :ctype:`char\*\*`; the value of the pointer it references will be set to a buffer with the contents of the argument text. The text will be encoded in the encoding specified by the first argument. - :c:func:`PyArg_ParseTuple` will allocate a buffer of the needed size, copy + :cfunc:`PyArg_ParseTuple` will allocate a buffer of the needed size, copy the encoded data into this buffer and adjust *\*buffer* to reference the newly allocated storage. The caller is responsible for calling - :c:func:`PyMem_Free` to free the allocated buffer after use. + :cfunc:`PyMem_Free` to free the allocated buffer after use. ``et`` (string, Unicode or character buffer compatible object) [const char \*encoding, char \*\*buffer] Same as ``es`` except that 8-bit string objects are passed through without @@ -115,10 +110,10 @@ allows input data which contains NUL characters. It requires three arguments. The first is only used as input, and must be - a :c:type:`const char\*` which points to the name of an encoding as a + a :ctype:`const char\*` which points to the name of an encoding as a NUL-terminated string, or *NULL*, in which case the default encoding is used. An exception is raised if the named encoding is not known to Python. - The second argument must be a :c:type:`char\*\*`; the value of the pointer + The second argument must be a :ctype:`char\*\*`; the value of the pointer it references will be set to a buffer with the contents of the argument text. The text will be encoded in the encoding specified by the first argument. The third argument must be a pointer to an integer; the @@ -129,11 +124,11 @@ If *\*buffer* points a *NULL* pointer, the function will allocate a buffer of the needed size, copy the encoded data into this buffer and set *\*buffer* to reference the newly allocated storage. The caller is - responsible for calling :c:func:`PyMem_Free` to free the allocated buffer + responsible for calling :cfunc:`PyMem_Free` to free the allocated buffer after usage. If *\*buffer* points to a non-*NULL* pointer (an already allocated buffer), - :c:func:`PyArg_ParseTuple` will use this location as the buffer and + :cfunc:`PyArg_ParseTuple` will use this location as the buffer and interpret the initial value of *\*buffer_length* as the buffer size. It will then copy the encoded data into the buffer and NUL-terminate it. If the buffer is not large enough, a :exc:`ValueError` will be set. @@ -148,71 +143,71 @@ ``b`` (integer) [unsigned char] Convert a nonnegative Python integer to an unsigned tiny int, stored in a C - :c:type:`unsigned char`. + :ctype:`unsigned char`. ``B`` (integer) [unsigned char] Convert a Python integer to a tiny int without overflow checking, stored in - a C :c:type:`unsigned char`. + a C :ctype:`unsigned char`. .. versionadded:: 2.3 ``h`` (integer) [short int] - Convert a Python integer to a C :c:type:`short int`. + Convert a Python integer to a C :ctype:`short int`. ``H`` (integer) [unsigned short int] - Convert a Python integer to a C :c:type:`unsigned short int`, without + Convert a Python integer to a C :ctype:`unsigned short int`, without overflow checking. .. versionadded:: 2.3 ``i`` (integer) [int] - Convert a Python integer to a plain C :c:type:`int`. + Convert a Python integer to a plain C :ctype:`int`. ``I`` (integer) [unsigned int] - Convert a Python integer to a C :c:type:`unsigned int`, without overflow + Convert a Python integer to a C :ctype:`unsigned int`, without overflow checking. .. versionadded:: 2.3 ``l`` (integer) [long int] - Convert a Python integer to a C :c:type:`long int`. + Convert a Python integer to a C :ctype:`long int`. ``k`` (integer) [unsigned long] - Convert a Python integer or long integer to a C :c:type:`unsigned long` + Convert a Python integer or long integer to a C :ctype:`unsigned long` without overflow checking. .. versionadded:: 2.3 ``L`` (integer) [PY_LONG_LONG] - Convert a Python integer to a C :c:type:`long long`. This format is only - available on platforms that support :c:type:`long long` (or :c:type:`_int64` + Convert a Python integer to a C :ctype:`long long`. This format is only + available on platforms that support :ctype:`long long` (or :ctype:`_int64` on Windows). ``K`` (integer) [unsigned PY_LONG_LONG] - Convert a Python integer or long integer to a C :c:type:`unsigned long long` + Convert a Python integer or long integer to a C :ctype:`unsigned long long` without overflow checking. This format is only available on platforms that - support :c:type:`unsigned long long` (or :c:type:`unsigned _int64` on + support :ctype:`unsigned long long` (or :ctype:`unsigned _int64` on Windows). .. versionadded:: 2.3 ``n`` (integer) [Py_ssize_t] - Convert a Python integer or long integer to a C :c:type:`Py_ssize_t`. + Convert a Python integer or long integer to a C :ctype:`Py_ssize_t`. .. versionadded:: 2.5 ``c`` (string of length 1) [char] Convert a Python character, represented as a string of length 1, to a C - :c:type:`char`. + :ctype:`char`. ``f`` (float) [float] - Convert a Python floating point number to a C :c:type:`float`. + Convert a Python floating point number to a C :ctype:`float`. ``d`` (float) [double] - Convert a Python floating point number to a C :c:type:`double`. + Convert a Python floating point number to a C :ctype:`double`. ``D`` (complex) [Py_complex] - Convert a Python complex number to a C :c:type:`Py_complex` structure. + Convert a Python complex number to a C :ctype:`Py_complex` structure. ``O`` (object) [PyObject \*] Store a Python object (without any conversion) in a C object pointer. The @@ -222,20 +217,20 @@ ``O!`` (object) [*typeobject*, PyObject \*] Store a Python object in a C object pointer. This is similar to ``O``, but takes two C arguments: the first is the address of a Python type object, - the second is the address of the C variable (of type :c:type:`PyObject\*`) + the second is the address of the C variable (of type :ctype:`PyObject\*`) into which the object pointer is stored. If the Python object does not have the required type, :exc:`TypeError` is raised. ``O&`` (object) [*converter*, *anything*] Convert a Python object to a C variable through a *converter* function. This takes two arguments: the first is a function, the second is the - address of a C variable (of arbitrary type), converted to :c:type:`void \*`. + address of a C variable (of arbitrary type), converted to :ctype:`void \*`. The *converter* function in turn is called as follows:: status = converter(object, address); where *object* is the Python object to be converted and *address* is the - :c:type:`void\*` argument that was passed to the :c:func:`PyArg_Parse\*` + :ctype:`void\*` argument that was passed to the :cfunc:`PyArg_Parse\*` function. The returned *status* should be ``1`` for a successful conversion and ``0`` if the conversion has failed. When the conversion fails, the *converter* function should raise an exception and leave the @@ -244,17 +239,17 @@ ``S`` (string) [PyStringObject \*] Like ``O`` but requires that the Python object is a string object. Raises :exc:`TypeError` if the object is not a string object. The C variable may - also be declared as :c:type:`PyObject\*`. + also be declared as :ctype:`PyObject\*`. ``U`` (Unicode string) [PyUnicodeObject \*] Like ``O`` but requires that the Python object is a Unicode object. Raises :exc:`TypeError` if the object is not a Unicode object. The C variable may - also be declared as :c:type:`PyObject\*`. + also be declared as :ctype:`PyObject\*`. ``t#`` (read-only character buffer) [char \*, int] Like ``s#``, but accepts any object which implements the read-only buffer - interface. The :c:type:`char\*` variable is set to point to the first byte - of the buffer, and the :c:type:`int` is set to the length of the buffer. + interface. The :ctype:`char\*` variable is set to point to the first byte + of the buffer, and the :ctype:`int` is set to the length of the buffer. Only single-segment buffer objects are accepted; :exc:`TypeError` is raised for all others. @@ -266,8 +261,8 @@ ``w#`` (read-write character buffer) [char \*, Py_ssize_t] Like ``s#``, but accepts any object which implements the read-write buffer - interface. The :c:type:`char \*` variable is set to point to the first byte - of the buffer, and the :c:type:`Py_ssize_t` is set to the length of the + interface. The :ctype:`char \*` variable is set to point to the first byte + of the buffer, and the :ctype:`Py_ssize_t` is set to the length of the buffer. Only single-segment buffer objects are accepted; :exc:`TypeError` is raised for all others. @@ -302,13 +297,13 @@ Indicates that the remaining arguments in the Python argument list are optional. The C variables corresponding to optional arguments should be initialized to their default value --- when an optional argument is not - specified, :c:func:`PyArg_ParseTuple` does not touch the contents of the + specified, :cfunc:`PyArg_ParseTuple` does not touch the contents of the corresponding C variable(s). ``:`` The list of format units ends here; the string after the colon is used as the function name in error messages (the "associated value" of the - exception that :c:func:`PyArg_ParseTuple` raises). + exception that :cfunc:`PyArg_ParseTuple` raises). ``;`` The list of format units ends here; the string after the semicolon is used @@ -325,40 +320,40 @@ should match what is specified for the corresponding format unit in that case. For the conversion to succeed, the *arg* object must match the format and the -format must be exhausted. On success, the :c:func:`PyArg_Parse\*` functions +format must be exhausted. On success, the :cfunc:`PyArg_Parse\*` functions return true, otherwise they return false and raise an appropriate exception. -When the :c:func:`PyArg_Parse\*` functions fail due to conversion failure in +When the :cfunc:`PyArg_Parse\*` functions fail due to conversion failure in one of the format units, the variables at the addresses corresponding to that and the following format units are left untouched. -.. c:function:: int PyArg_ParseTuple(PyObject *args, const char *format, ...) +.. cfunction:: int PyArg_ParseTuple(PyObject *args, const char *format, ...) Parse the parameters of a function that takes only positional parameters into local variables. Returns true on success; on failure, it returns false and raises the appropriate exception. -.. c:function:: int PyArg_VaParse(PyObject *args, const char *format, va_list vargs) +.. cfunction:: int PyArg_VaParse(PyObject *args, const char *format, va_list vargs) - Identical to :c:func:`PyArg_ParseTuple`, except that it accepts a va_list + Identical to :cfunc:`PyArg_ParseTuple`, except that it accepts a va_list rather than a variable number of arguments. -.. c:function:: int PyArg_ParseTupleAndKeywords(PyObject *args, PyObject *kw, const char *format, char *keywords[], ...) +.. cfunction:: int PyArg_ParseTupleAndKeywords(PyObject *args, PyObject *kw, const char *format, char *keywords[], ...) Parse the parameters of a function that takes both positional and keyword parameters into local variables. Returns true on success; on failure, it returns false and raises the appropriate exception. -.. c:function:: int PyArg_VaParseTupleAndKeywords(PyObject *args, PyObject *kw, const char *format, char *keywords[], va_list vargs) +.. cfunction:: int PyArg_VaParseTupleAndKeywords(PyObject *args, PyObject *kw, const char *format, char *keywords[], va_list vargs) - Identical to :c:func:`PyArg_ParseTupleAndKeywords`, except that it accepts a + Identical to :cfunc:`PyArg_ParseTupleAndKeywords`, except that it accepts a va_list rather than a variable number of arguments. -.. c:function:: int PyArg_Parse(PyObject *args, const char *format, ...) +.. cfunction:: int PyArg_Parse(PyObject *args, const char *format, ...) Function used to deconstruct the argument lists of "old-style" functions --- these are functions which use the :const:`METH_OLDARGS` parameter @@ -369,7 +364,7 @@ purpose. -.. c:function:: int PyArg_UnpackTuple(PyObject *args, const char *name, Py_ssize_t min, Py_ssize_t max, ...) +.. cfunction:: int PyArg_UnpackTuple(PyObject *args, const char *name, Py_ssize_t min, Py_ssize_t max, ...) A simpler form of parameter retrieval which does not use a format string to specify the types of the arguments. Functions which use this method to @@ -378,7 +373,7 @@ should be passed as *args*; it must actually be a tuple. The length of the tuple must be at least *min* and no more than *max*; *min* and *max* may be equal. Additional arguments must be passed to the function, each of which - should be a pointer to a :c:type:`PyObject\*` variable; these will be filled + should be a pointer to a :ctype:`PyObject\*` variable; these will be filled in with the values from *args*; they will contain borrowed references. The variables which correspond to optional parameters not given by *args* will not be filled in; these should be initialized by the caller. This function @@ -401,26 +396,26 @@ return result; } - The call to :c:func:`PyArg_UnpackTuple` in this example is entirely - equivalent to this call to :c:func:`PyArg_ParseTuple`:: + The call to :cfunc:`PyArg_UnpackTuple` in this example is entirely + equivalent to this call to :cfunc:`PyArg_ParseTuple`:: PyArg_ParseTuple(args, "O|O:ref", &object, &callback) .. versionadded:: 2.2 .. versionchanged:: 2.5 - This function used an :c:type:`int` type for *min* and *max*. This might + This function used an :ctype:`int` type for *min* and *max*. This might require changes in your code for properly supporting 64-bit systems. -.. c:function:: PyObject* Py_BuildValue(const char *format, ...) +.. cfunction:: PyObject* Py_BuildValue(const char *format, ...) Create a new value based on a format string similar to those accepted by - the :c:func:`PyArg_Parse\*` family of functions and a sequence of values. + the :cfunc:`PyArg_Parse\*` family of functions and a sequence of values. Returns the value or *NULL* in the case of an error; an exception will be raised if *NULL* is returned. - :c:func:`Py_BuildValue` does not always build a tuple. It builds a tuple + :cfunc:`Py_BuildValue` does not always build a tuple. It builds a tuple only if its format string contains two or more format units. If the format string is empty, it returns ``None``; if it contains exactly one format unit, it returns whatever object is described by that format unit. To @@ -430,10 +425,10 @@ When memory buffers are passed as parameters to supply data to build objects, as for the ``s`` and ``s#`` formats, the required data is copied. Buffers provided by the caller are never referenced by the objects created - by :c:func:`Py_BuildValue`. In other words, if your code invokes - :c:func:`malloc` and passes the allocated memory to :c:func:`Py_BuildValue`, - your code is responsible for calling :c:func:`free` for that memory once - :c:func:`Py_BuildValue` returns. + by :cfunc:`Py_BuildValue`. In other words, if your code invokes + :cfunc:`malloc` and passes the allocated memory to :cfunc:`Py_BuildValue`, + your code is responsible for calling :cfunc:`free` for that memory once + :cfunc:`Py_BuildValue` returns. In the following description, the quoted form is the format unit; the entry in (round) parentheses is the Python object type that the format unit will @@ -469,62 +464,62 @@ length is ignored and ``None`` is returned. ``i`` (integer) [int] - Convert a plain C :c:type:`int` to a Python integer object. + Convert a plain C :ctype:`int` to a Python integer object. ``b`` (integer) [char] - Convert a plain C :c:type:`char` to a Python integer object. + Convert a plain C :ctype:`char` to a Python integer object. ``h`` (integer) [short int] - Convert a plain C :c:type:`short int` to a Python integer object. + Convert a plain C :ctype:`short int` to a Python integer object. ``l`` (integer) [long int] - Convert a C :c:type:`long int` to a Python integer object. + Convert a C :ctype:`long int` to a Python integer object. ``B`` (integer) [unsigned char] - Convert a C :c:type:`unsigned char` to a Python integer object. + Convert a C :ctype:`unsigned char` to a Python integer object. ``H`` (integer) [unsigned short int] - Convert a C :c:type:`unsigned short int` to a Python integer object. + Convert a C :ctype:`unsigned short int` to a Python integer object. ``I`` (integer/long) [unsigned int] - Convert a C :c:type:`unsigned int` to a Python integer object or a Python + Convert a C :ctype:`unsigned int` to a Python integer object or a Python long integer object, if it is larger than ``sys.maxint``. ``k`` (integer/long) [unsigned long] - Convert a C :c:type:`unsigned long` to a Python integer object or a + Convert a C :ctype:`unsigned long` to a Python integer object or a Python long integer object, if it is larger than ``sys.maxint``. ``L`` (long) [PY_LONG_LONG] - Convert a C :c:type:`long long` to a Python long integer object. Only - available on platforms that support :c:type:`long long`. + Convert a C :ctype:`long long` to a Python long integer object. Only + available on platforms that support :ctype:`long long`. ``K`` (long) [unsigned PY_LONG_LONG] - Convert a C :c:type:`unsigned long long` to a Python long integer object. - Only available on platforms that support :c:type:`unsigned long long`. + Convert a C :ctype:`unsigned long long` to a Python long integer object. + Only available on platforms that support :ctype:`unsigned long long`. ``n`` (int) [Py_ssize_t] - Convert a C :c:type:`Py_ssize_t` to a Python integer or long integer. + Convert a C :ctype:`Py_ssize_t` to a Python integer or long integer. .. versionadded:: 2.5 ``c`` (string of length 1) [char] - Convert a C :c:type:`int` representing a character to a Python string of + Convert a C :ctype:`int` representing a character to a Python string of length 1. ``d`` (float) [double] - Convert a C :c:type:`double` to a Python floating point number. + Convert a C :ctype:`double` to a Python floating point number. ``f`` (float) [float] Same as ``d``. ``D`` (complex) [Py_complex \*] - Convert a C :c:type:`Py_complex` structure to a Python complex number. + Convert a C :ctype:`Py_complex` structure to a Python complex number. ``O`` (object) [PyObject \*] Pass a Python object untouched (except for its reference count, which is incremented by one). If the object passed in is a *NULL* pointer, it is assumed that this was caused because the call producing the argument - found an error and set an exception. Therefore, :c:func:`Py_BuildValue` + found an error and set an exception. Therefore, :cfunc:`Py_BuildValue` will return *NULL* but won't raise an exception. If no exception has been raised yet, :exc:`SystemError` is set. @@ -539,7 +534,7 @@ ``O&`` (object) [*converter*, *anything*] Convert *anything* to a Python object through a *converter* function. The function is called with *anything* (which should be compatible with - :c:type:`void \*`) as its argument and should return a "new" Python + :ctype:`void \*`) as its argument and should return a "new" Python object, or *NULL* if an error occurred. ``(items)`` (tuple) [*matching-items*] @@ -558,7 +553,7 @@ If there is an error in the format string, the :exc:`SystemError` exception is set and *NULL* returned. -.. c:function:: PyObject* Py_VaBuildValue(const char *format, va_list vargs) +.. cfunction:: PyObject* Py_VaBuildValue(const char *format, va_list vargs) - Identical to :c:func:`Py_BuildValue`, except that it accepts a va_list + Identical to :cfunc:`Py_BuildValue`, except that it accepts a va_list rather than a variable number of arguments. diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/c-api/bool.rst --- a/Doc/c-api/bool.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/c-api/bool.rst Sun Jul 20 10:52:46 2014 -0400 @@ -11,26 +11,26 @@ are available, however. -.. c:function:: int PyBool_Check(PyObject *o) +.. cfunction:: int PyBool_Check(PyObject *o) - Return true if *o* is of type :c:data:`PyBool_Type`. + Return true if *o* is of type :cdata:`PyBool_Type`. .. versionadded:: 2.3 -.. c:var:: PyObject* Py_False +.. cvar:: PyObject* Py_False The Python ``False`` object. This object has no methods. It needs to be treated just like any other object with respect to reference counts. -.. c:var:: PyObject* Py_True +.. cvar:: PyObject* Py_True The Python ``True`` object. This object has no methods. It needs to be treated just like any other object with respect to reference counts. -.. c:macro:: Py_RETURN_FALSE +.. cmacro:: Py_RETURN_FALSE Return :const:`Py_False` from a function, properly incrementing its reference count. @@ -38,7 +38,7 @@ .. versionadded:: 2.4 -.. c:macro:: Py_RETURN_TRUE +.. cmacro:: Py_RETURN_TRUE Return :const:`Py_True` from a function, properly incrementing its reference count. @@ -46,7 +46,7 @@ .. versionadded:: 2.4 -.. c:function:: PyObject* PyBool_FromLong(long v) +.. cfunction:: PyObject* PyBool_FromLong(long v) Return a new reference to :const:`Py_True` or :const:`Py_False` depending on the truth value of *v*. diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/c-api/buffer.rst --- a/Doc/c-api/buffer.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/c-api/buffer.rst Sun Jul 20 10:52:46 2014 -0400 @@ -21,21 +21,19 @@ Two examples of objects that support the buffer interface are strings and arrays. The string object exposes the character contents in the buffer -interface's byte-oriented form. An array can only expose its contents via the -old-style buffer interface. This limitation does not apply to Python 3, -where :class:`memoryview` objects can be constructed from arrays, too. -Array elements may be multi-byte values. +interface's byte-oriented form. An array can also expose its contents, but it +should be noted that array elements may be multi-byte values. An example user of the buffer interface is the file object's :meth:`write` method. Any object that can export a series of bytes through the buffer interface can be written to a file. There are a number of format codes to -:c:func:`PyArg_ParseTuple` that operate against an object's buffer interface, +:cfunc:`PyArg_ParseTuple` that operate against an object's buffer interface, returning data from the target object. Starting from version 1.6, Python has been providing Python-level buffer objects and a C-level buffer API so that any built-in or used-defined type can expose its characteristics. Both, however, have been deprecated because of -various shortcomings, and have been officially removed in Python 3 in favour +various shortcomings, and have been officially removed in Python 3.0 in favour of a new C-level buffer API and a new Python-level object named :class:`memoryview`. @@ -49,49 +47,49 @@ ============================== -.. c:type:: Py_buffer +.. ctype:: Py_buffer - .. c:member:: void *buf + .. cmember:: void *buf A pointer to the start of the memory for the object. - .. c:member:: Py_ssize_t len + .. cmember:: Py_ssize_t len :noindex: The total length of the memory in bytes. - .. c:member:: int readonly + .. cmember:: int readonly An indicator of whether the buffer is read only. - .. c:member:: const char *format + .. cmember:: const char *format :noindex: A *NULL* terminated string in :mod:`struct` module style syntax giving the contents of the elements available through the buffer. If this is *NULL*, ``"B"`` (unsigned bytes) is assumed. - .. c:member:: int ndim + .. cmember:: int ndim The number of dimensions the memory represents as a multi-dimensional - array. If it is 0, :c:data:`strides` and :c:data:`suboffsets` must be + array. If it is 0, :cdata:`strides` and :cdata:`suboffsets` must be *NULL*. - .. c:member:: Py_ssize_t *shape + .. cmember:: Py_ssize_t *shape - An array of :c:type:`Py_ssize_t`\s the length of :c:data:`ndim` giving the + An array of :ctype:`Py_ssize_t`\s the length of :cdata:`ndim` giving the shape of the memory as a multi-dimensional array. Note that ``((*shape)[0] * ... * (*shape)[ndims-1])*itemsize`` should be equal to - :c:data:`len`. + :cdata:`len`. - .. c:member:: Py_ssize_t *strides + .. cmember:: Py_ssize_t *strides - An array of :c:type:`Py_ssize_t`\s the length of :c:data:`ndim` giving the + An array of :ctype:`Py_ssize_t`\s the length of :cdata:`ndim` giving the number of bytes to skip to get to a new element in each dimension. - .. c:member:: Py_ssize_t *suboffsets + .. cmember:: Py_ssize_t *suboffsets - An array of :c:type:`Py_ssize_t`\s the length of :c:data:`ndim`. If these + An array of :ctype:`Py_ssize_t`\s the length of :cdata:`ndim`. If these suboffset numbers are greater than or equal to 0, then the value stored along the indicated dimension is a pointer and the suboffset value dictates how many bytes to add to the pointer after de-referencing. A @@ -116,16 +114,16 @@ } - .. c:member:: Py_ssize_t itemsize + .. cmember:: Py_ssize_t itemsize This is a storage for the itemsize (in bytes) of each element of the shared memory. It is technically un-necessary as it can be obtained - using :c:func:`PyBuffer_SizeFromFormat`, however an exporter may know + using :cfunc:`PyBuffer_SizeFromFormat`, however an exporter may know this information without parsing the format string and it is necessary to know the itemsize for proper interpretation of striding. Therefore, storing it is more convenient and faster. - .. c:member:: void *internal + .. cmember:: void *internal This is for use internally by the exporting object. For example, this might be re-cast as an integer by the exporter and used to store flags @@ -138,14 +136,14 @@ ======================== -.. c:function:: int PyObject_CheckBuffer(PyObject *obj) +.. cfunction:: int PyObject_CheckBuffer(PyObject *obj) Return 1 if *obj* supports the buffer interface otherwise 0. -.. c:function:: int PyObject_GetBuffer(PyObject *obj, Py_buffer *view, int flags) +.. cfunction:: int PyObject_GetBuffer(PyObject *obj, Py_buffer *view, int flags) - Export *obj* into a :c:type:`Py_buffer`, *view*. These arguments must + Export *obj* into a :ctype:`Py_buffer`, *view*. These arguments must never be *NULL*. The *flags* argument is a bit field indicating what kind of buffer the caller is prepared to deal with and therefore what kind of buffer the exporter is allowed to return. The buffer interface @@ -158,131 +156,131 @@ just not possible. These errors should be a :exc:`BufferError` unless there is another error that is actually causing the problem. The exporter can use flags information to simplify how much of the - :c:data:`Py_buffer` structure is filled in with non-default values and/or + :cdata:`Py_buffer` structure is filled in with non-default values and/or raise an error if the object can't support a simpler view of its memory. 0 is returned on success and -1 on error. The following table gives possible values to the *flags* arguments. - +-------------------------------+---------------------------------------------------+ - | Flag | Description | - +===============================+===================================================+ - | :c:macro:`PyBUF_SIMPLE` | This is the default flag state. The returned | - | | buffer may or may not have writable memory. The | - | | format of the data will be assumed to be unsigned | - | | bytes. This is a "stand-alone" flag constant. It | - | | never needs to be '|'d to the others. The exporter| - | | will raise an error if it cannot provide such a | - | | contiguous buffer of bytes. | - | | | - +-------------------------------+---------------------------------------------------+ - | :c:macro:`PyBUF_WRITABLE` | The returned buffer must be writable. If it is | - | | not writable, then raise an error. | - +-------------------------------+---------------------------------------------------+ - | :c:macro:`PyBUF_STRIDES` | This implies :c:macro:`PyBUF_ND`. The returned | - | | buffer must provide strides information (i.e. the | - | | strides cannot be NULL). This would be used when | - | | the consumer can handle strided, discontiguous | - | | arrays. Handling strides automatically assumes | - | | you can handle shape. The exporter can raise an | - | | error if a strided representation of the data is | - | | not possible (i.e. without the suboffsets). | - | | | - +-------------------------------+---------------------------------------------------+ - | :c:macro:`PyBUF_ND` | The returned buffer must provide shape | - | | information. The memory will be assumed C-style | - | | contiguous (last dimension varies the | - | | fastest). The exporter may raise an error if it | - | | cannot provide this kind of contiguous buffer. If | - | | this is not given then shape will be *NULL*. | - | | | - | | | - | | | - +-------------------------------+---------------------------------------------------+ - |:c:macro:`PyBUF_C_CONTIGUOUS` | These flags indicate that the contiguity returned | - |:c:macro:`PyBUF_F_CONTIGUOUS` | buffer must be respectively, C-contiguous (last | - |:c:macro:`PyBUF_ANY_CONTIGUOUS`| dimension varies the fastest), Fortran contiguous | - | | (first dimension varies the fastest) or either | - | | one. All of these flags imply | - | | :c:macro:`PyBUF_STRIDES` and guarantee that the | - | | strides buffer info structure will be filled in | - | | correctly. | - | | | - +-------------------------------+---------------------------------------------------+ - | :c:macro:`PyBUF_INDIRECT` | This flag indicates the returned buffer must have | - | | suboffsets information (which can be NULL if no | - | | suboffsets are needed). This can be used when | - | | the consumer can handle indirect array | - | | referencing implied by these suboffsets. This | - | | implies :c:macro:`PyBUF_STRIDES`. | - | | | - | | | - | | | - +-------------------------------+---------------------------------------------------+ - | :c:macro:`PyBUF_FORMAT` | The returned buffer must have true format | - | | information if this flag is provided. This would | - | | be used when the consumer is going to be checking | - | | for what 'kind' of data is actually stored. An | - | | exporter should always be able to provide this | - | | information if requested. If format is not | - | | explicitly requested then the format must be | - | | returned as *NULL* (which means ``'B'``, or | - | | unsigned bytes) | - +-------------------------------+---------------------------------------------------+ - | :c:macro:`PyBUF_STRIDED` | This is equivalent to ``(PyBUF_STRIDES | | - | | PyBUF_WRITABLE)``. | - +-------------------------------+---------------------------------------------------+ - | :c:macro:`PyBUF_STRIDED_RO` | This is equivalent to ``(PyBUF_STRIDES)``. | - | | | - +-------------------------------+---------------------------------------------------+ - | :c:macro:`PyBUF_RECORDS` | This is equivalent to ``(PyBUF_STRIDES | | - | | PyBUF_FORMAT | PyBUF_WRITABLE)``. | - +-------------------------------+---------------------------------------------------+ - | :c:macro:`PyBUF_RECORDS_RO` | This is equivalent to ``(PyBUF_STRIDES | | - | | PyBUF_FORMAT)``. | - +-------------------------------+---------------------------------------------------+ - | :c:macro:`PyBUF_FULL` | This is equivalent to ``(PyBUF_INDIRECT | | - | | PyBUF_FORMAT | PyBUF_WRITABLE)``. | - +-------------------------------+---------------------------------------------------+ - | :c:macro:`PyBUF_FULL_RO` | This is equivalent to ``(PyBUF_INDIRECT | | - | | PyBUF_FORMAT)``. | - +-------------------------------+---------------------------------------------------+ - | :c:macro:`PyBUF_CONTIG` | This is equivalent to ``(PyBUF_ND | | - | | PyBUF_WRITABLE)``. | - +-------------------------------+---------------------------------------------------+ - | :c:macro:`PyBUF_CONTIG_RO` | This is equivalent to ``(PyBUF_ND)``. | - | | | - +-------------------------------+---------------------------------------------------+ + +------------------------------+---------------------------------------------------+ + | Flag | Description | + +==============================+===================================================+ + | :cmacro:`PyBUF_SIMPLE` | This is the default flag state. The returned | + | | buffer may or may not have writable memory. The | + | | format of the data will be assumed to be unsigned | + | | bytes. This is a "stand-alone" flag constant. It | + | | never needs to be '|'d to the others. The exporter| + | | will raise an error if it cannot provide such a | + | | contiguous buffer of bytes. | + | | | + +------------------------------+---------------------------------------------------+ + | :cmacro:`PyBUF_WRITABLE` | The returned buffer must be writable. If it is | + | | not writable, then raise an error. | + +------------------------------+---------------------------------------------------+ + | :cmacro:`PyBUF_STRIDES` | This implies :cmacro:`PyBUF_ND`. The returned | + | | buffer must provide strides information (i.e. the | + | | strides cannot be NULL). This would be used when | + | | the consumer can handle strided, discontiguous | + | | arrays. Handling strides automatically assumes | + | | you can handle shape. The exporter can raise an | + | | error if a strided representation of the data is | + | | not possible (i.e. without the suboffsets). | + | | | + +------------------------------+---------------------------------------------------+ + | :cmacro:`PyBUF_ND` | The returned buffer must provide shape | + | | information. The memory will be assumed C-style | + | | contiguous (last dimension varies the | + | | fastest). The exporter may raise an error if it | + | | cannot provide this kind of contiguous buffer. If | + | | this is not given then shape will be *NULL*. | + | | | + | | | + | | | + +------------------------------+---------------------------------------------------+ + |:cmacro:`PyBUF_C_CONTIGUOUS` | These flags indicate that the contiguity returned | + |:cmacro:`PyBUF_F_CONTIGUOUS` | buffer must be respectively, C-contiguous (last | + |:cmacro:`PyBUF_ANY_CONTIGUOUS`| dimension varies the fastest), Fortran contiguous | + | | (first dimension varies the fastest) or either | + | | one. All of these flags imply | + | | :cmacro:`PyBUF_STRIDES` and guarantee that the | + | | strides buffer info structure will be filled in | + | | correctly. | + | | | + +------------------------------+---------------------------------------------------+ + | :cmacro:`PyBUF_INDIRECT` | This flag indicates the returned buffer must have | + | | suboffsets information (which can be NULL if no | + | | suboffsets are needed). This can be used when | + | | the consumer can handle indirect array | + | | referencing implied by these suboffsets. This | + | | implies :cmacro:`PyBUF_STRIDES`. | + | | | + | | | + | | | + +------------------------------+---------------------------------------------------+ + | :cmacro:`PyBUF_FORMAT` | The returned buffer must have true format | + | | information if this flag is provided. This would | + | | be used when the consumer is going to be checking | + | | for what 'kind' of data is actually stored. An | + | | exporter should always be able to provide this | + | | information if requested. If format is not | + | | explicitly requested then the format must be | + | | returned as *NULL* (which means ``'B'``, or | + | | unsigned bytes) | + +------------------------------+---------------------------------------------------+ + | :cmacro:`PyBUF_STRIDED` | This is equivalent to ``(PyBUF_STRIDES | | + | | PyBUF_WRITABLE)``. | + +------------------------------+---------------------------------------------------+ + | :cmacro:`PyBUF_STRIDED_RO` | This is equivalent to ``(PyBUF_STRIDES)``. | + | | | + +------------------------------+---------------------------------------------------+ + | :cmacro:`PyBUF_RECORDS` | This is equivalent to ``(PyBUF_STRIDES | | + | | PyBUF_FORMAT | PyBUF_WRITABLE)``. | + +------------------------------+---------------------------------------------------+ + | :cmacro:`PyBUF_RECORDS_RO` | This is equivalent to ``(PyBUF_STRIDES | | + | | PyBUF_FORMAT)``. | + +------------------------------+---------------------------------------------------+ + | :cmacro:`PyBUF_FULL` | This is equivalent to ``(PyBUF_INDIRECT | | + | | PyBUF_FORMAT | PyBUF_WRITABLE)``. | + +------------------------------+---------------------------------------------------+ + | :cmacro:`PyBUF_FULL_RO` | This is equivalent to ``(PyBUF_INDIRECT | | + | | PyBUF_FORMAT)``. | + +------------------------------+---------------------------------------------------+ + | :cmacro:`PyBUF_CONTIG` | This is equivalent to ``(PyBUF_ND | | + | | PyBUF_WRITABLE)``. | + +------------------------------+---------------------------------------------------+ + | :cmacro:`PyBUF_CONTIG_RO` | This is equivalent to ``(PyBUF_ND)``. | + | | | + +------------------------------+---------------------------------------------------+ -.. c:function:: void PyBuffer_Release(Py_buffer *view) +.. cfunction:: void PyBuffer_Release(Py_buffer *view) Release the buffer *view*. This should be called when the buffer is no longer being used as it may free memory from it. -.. c:function:: Py_ssize_t PyBuffer_SizeFromFormat(const char *) +.. cfunction:: Py_ssize_t PyBuffer_SizeFromFormat(const char *) - Return the implied :c:data:`~Py_buffer.itemsize` from the struct-stype - :c:data:`~Py_buffer.format`. + Return the implied :cdata:`~Py_buffer.itemsize` from the struct-stype + :cdata:`~Py_buffer.format`. -.. c:function:: int PyBuffer_IsContiguous(Py_buffer *view, char fortran) +.. cfunction:: int PyBuffer_IsContiguous(Py_buffer *view, char fortran) Return 1 if the memory defined by the *view* is C-style (*fortran* is ``'C'``) or Fortran-style (*fortran* is ``'F'``) contiguous or either one (*fortran* is ``'A'``). Return 0 otherwise. -.. c:function:: void PyBuffer_FillContiguousStrides(int ndim, Py_ssize_t *shape, Py_ssize_t *strides, Py_ssize_t itemsize, char fortran) +.. cfunction:: void PyBuffer_FillContiguousStrides(int ndim, Py_ssize_t *shape, Py_ssize_t *strides, Py_ssize_t itemsize, char fortran) Fill the *strides* array with byte-strides of a contiguous (C-style if *fortran* is ``'C'`` or Fortran-style if *fortran* is ``'F'``) array of the given shape with the given number of bytes per element. -.. c:function:: int PyBuffer_FillInfo(Py_buffer *view, PyObject *obj, void *buf, Py_ssize_t len, int readonly, int infoflags) +.. cfunction:: int PyBuffer_FillInfo(Py_buffer *view, PyObject *obj, void *buf, Py_ssize_t len, int readonly, int infoflags) Fill in a buffer-info structure, *view*, correctly for an exporter that can only share a contiguous chunk of memory of "unsigned bytes" of the given @@ -297,13 +295,13 @@ A :class:`memoryview` object exposes the new C level buffer interface as a Python object which can then be passed around like any other object. -.. c:function:: PyObject *PyMemoryView_FromObject(PyObject *obj) +.. cfunction:: PyObject *PyMemoryView_FromObject(PyObject *obj) Create a memoryview object from an object that defines the new buffer interface. -.. c:function:: PyObject *PyMemoryView_FromBuffer(Py_buffer *view) +.. cfunction:: PyObject *PyMemoryView_FromBuffer(Py_buffer *view) Create a memoryview object wrapping the given buffer-info structure *view*. The memoryview object then owns the buffer, which means you shouldn't @@ -311,7 +309,7 @@ memoryview object. -.. c:function:: PyObject *PyMemoryView_GetContiguous(PyObject *obj, int buffertype, char order) +.. cfunction:: PyObject *PyMemoryView_GetContiguous(PyObject *obj, int buffertype, char order) Create a memoryview object to a contiguous chunk of memory (in either 'C' or 'F'ortran *order*) from an object that defines the buffer @@ -320,13 +318,13 @@ new bytes object. -.. c:function:: int PyMemoryView_Check(PyObject *obj) +.. cfunction:: int PyMemoryView_Check(PyObject *obj) Return true if the object *obj* is a memoryview object. It is not currently allowed to create subclasses of :class:`memoryview`. -.. c:function:: Py_buffer *PyMemoryView_GET_BUFFER(PyObject *obj) +.. cfunction:: Py_buffer *PyMemoryView_GET_BUFFER(PyObject *obj) Return a pointer to the buffer-info structure wrapped by the given object. The object **must** be a memoryview instance; this macro doesn't @@ -339,7 +337,7 @@ .. index:: single: PyBufferProcs More information on the old buffer interface is provided in the section -:ref:`buffer-structs`, under the description for :c:type:`PyBufferProcs`. +:ref:`buffer-structs`, under the description for :ctype:`PyBufferProcs`. A "buffer object" is defined in the :file:`bufferobject.h` header (included by :file:`Python.h`). These objects look very similar to string objects at the @@ -358,36 +356,36 @@ native, in-memory format. -.. c:type:: PyBufferObject +.. ctype:: PyBufferObject - This subtype of :c:type:`PyObject` represents a buffer object. + This subtype of :ctype:`PyObject` represents a buffer object. -.. c:var:: PyTypeObject PyBuffer_Type +.. cvar:: PyTypeObject PyBuffer_Type .. index:: single: BufferType (in module types) - The instance of :c:type:`PyTypeObject` which represents the Python buffer type; + The instance of :ctype:`PyTypeObject` which represents the Python buffer type; it is the same object as ``buffer`` and ``types.BufferType`` in the Python layer. . -.. c:var:: int Py_END_OF_BUFFER +.. cvar:: int Py_END_OF_BUFFER This constant may be passed as the *size* parameter to - :c:func:`PyBuffer_FromObject` or :c:func:`PyBuffer_FromReadWriteObject`. It - indicates that the new :c:type:`PyBufferObject` should refer to *base* + :cfunc:`PyBuffer_FromObject` or :cfunc:`PyBuffer_FromReadWriteObject`. It + indicates that the new :ctype:`PyBufferObject` should refer to *base* object from the specified *offset* to the end of its exported buffer. Using this enables the caller to avoid querying the *base* object for its length. -.. c:function:: int PyBuffer_Check(PyObject *p) +.. cfunction:: int PyBuffer_Check(PyObject *p) - Return true if the argument has type :c:data:`PyBuffer_Type`. + Return true if the argument has type :cdata:`PyBuffer_Type`. -.. c:function:: PyObject* PyBuffer_FromObject(PyObject *base, Py_ssize_t offset, Py_ssize_t size) +.. cfunction:: PyObject* PyBuffer_FromObject(PyObject *base, Py_ssize_t offset, Py_ssize_t size) Return a new read-only buffer object. This raises :exc:`TypeError` if *base* doesn't support the read-only buffer protocol or doesn't provide @@ -399,24 +397,24 @@ length of the *base* object's exported buffer data. .. versionchanged:: 2.5 - This function used an :c:type:`int` type for *offset* and *size*. This + This function used an :ctype:`int` type for *offset* and *size*. This might require changes in your code for properly supporting 64-bit systems. -.. c:function:: PyObject* PyBuffer_FromReadWriteObject(PyObject *base, Py_ssize_t offset, Py_ssize_t size) +.. cfunction:: PyObject* PyBuffer_FromReadWriteObject(PyObject *base, Py_ssize_t offset, Py_ssize_t size) Return a new writable buffer object. Parameters and exceptions are similar - to those for :c:func:`PyBuffer_FromObject`. If the *base* object does not + to those for :cfunc:`PyBuffer_FromObject`. If the *base* object does not export the writeable buffer protocol, then :exc:`TypeError` is raised. .. versionchanged:: 2.5 - This function used an :c:type:`int` type for *offset* and *size*. This + This function used an :ctype:`int` type for *offset* and *size*. This might require changes in your code for properly supporting 64-bit systems. -.. c:function:: PyObject* PyBuffer_FromMemory(void *ptr, Py_ssize_t size) +.. cfunction:: PyObject* PyBuffer_FromMemory(void *ptr, Py_ssize_t size) Return a new read-only buffer object that reads from a specified location in memory, with a specified size. The caller is responsible for ensuring @@ -426,27 +424,27 @@ *size* parameter; :exc:`ValueError` will be raised in that case. .. versionchanged:: 2.5 - This function used an :c:type:`int` type for *size*. This might require + This function used an :ctype:`int` type for *size*. This might require changes in your code for properly supporting 64-bit systems. -.. c:function:: PyObject* PyBuffer_FromReadWriteMemory(void *ptr, Py_ssize_t size) +.. cfunction:: PyObject* PyBuffer_FromReadWriteMemory(void *ptr, Py_ssize_t size) - Similar to :c:func:`PyBuffer_FromMemory`, but the returned buffer is + Similar to :cfunc:`PyBuffer_FromMemory`, but the returned buffer is writable. .. versionchanged:: 2.5 - This function used an :c:type:`int` type for *size*. This might require + This function used an :ctype:`int` type for *size*. This might require changes in your code for properly supporting 64-bit systems. -.. c:function:: PyObject* PyBuffer_New(Py_ssize_t size) +.. cfunction:: PyObject* PyBuffer_New(Py_ssize_t size) Return a new writable buffer object that maintains its own memory buffer of *size* bytes. :exc:`ValueError` is returned if *size* is not zero or positive. Note that the memory buffer (as returned by - :c:func:`PyObject_AsWriteBuffer`) is not specifically aligned. + :cfunc:`PyObject_AsWriteBuffer`) is not specifically aligned. .. versionchanged:: 2.5 - This function used an :c:type:`int` type for *size*. This might require + This function used an :ctype:`int` type for *size*. This might require changes in your code for properly supporting 64-bit systems. diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/c-api/bytearray.rst --- a/Doc/c-api/bytearray.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/c-api/bytearray.rst Sun Jul 20 10:52:46 2014 -0400 @@ -10,26 +10,26 @@ .. versionadded:: 2.6 -.. c:type:: PyByteArrayObject +.. ctype:: PyByteArrayObject - This subtype of :c:type:`PyObject` represents a Python bytearray object. + This subtype of :ctype:`PyObject` represents a Python bytearray object. -.. c:var:: PyTypeObject PyByteArray_Type +.. cvar:: PyTypeObject PyByteArray_Type - This instance of :c:type:`PyTypeObject` represents the Python bytearray type; + This instance of :ctype:`PyTypeObject` represents the Python bytearray type; it is the same object as ``bytearray`` in the Python layer. Type check macros ^^^^^^^^^^^^^^^^^ -.. c:function:: int PyByteArray_Check(PyObject *o) +.. cfunction:: int PyByteArray_Check(PyObject *o) Return true if the object *o* is a bytearray object or an instance of a subtype of the bytearray type. -.. c:function:: int PyByteArray_CheckExact(PyObject *o) +.. cfunction:: int PyByteArray_CheckExact(PyObject *o) Return true if the object *o* is a bytearray object, but not an instance of a subtype of the bytearray type. @@ -38,7 +38,7 @@ Direct API functions ^^^^^^^^^^^^^^^^^^^^ -.. c:function:: PyObject* PyByteArray_FromObject(PyObject *o) +.. cfunction:: PyObject* PyByteArray_FromObject(PyObject *o) Return a new bytearray object from any object, *o*, that implements the buffer protocol. @@ -46,29 +46,29 @@ .. XXX expand about the buffer protocol, at least somewhere -.. c:function:: PyObject* PyByteArray_FromStringAndSize(const char *string, Py_ssize_t len) +.. cfunction:: PyObject* PyByteArray_FromStringAndSize(const char *string, Py_ssize_t len) Create a new bytearray object from *string* and its length, *len*. On failure, *NULL* is returned. -.. c:function:: PyObject* PyByteArray_Concat(PyObject *a, PyObject *b) +.. cfunction:: PyObject* PyByteArray_Concat(PyObject *a, PyObject *b) Concat bytearrays *a* and *b* and return a new bytearray with the result. -.. c:function:: Py_ssize_t PyByteArray_Size(PyObject *bytearray) +.. cfunction:: Py_ssize_t PyByteArray_Size(PyObject *bytearray) Return the size of *bytearray* after checking for a *NULL* pointer. -.. c:function:: char* PyByteArray_AsString(PyObject *bytearray) +.. cfunction:: char* PyByteArray_AsString(PyObject *bytearray) Return the contents of *bytearray* as a char array after checking for a *NULL* pointer. -.. c:function:: int PyByteArray_Resize(PyObject *bytearray, Py_ssize_t len) +.. cfunction:: int PyByteArray_Resize(PyObject *bytearray, Py_ssize_t len) Resize the internal buffer of *bytearray* to *len*. @@ -77,11 +77,11 @@ These macros trade safety for speed and they don't check pointers. -.. c:function:: char* PyByteArray_AS_STRING(PyObject *bytearray) +.. cfunction:: char* PyByteArray_AS_STRING(PyObject *bytearray) - Macro version of :c:func:`PyByteArray_AsString`. + Macro version of :cfunc:`PyByteArray_AsString`. -.. c:function:: Py_ssize_t PyByteArray_GET_SIZE(PyObject *bytearray) +.. cfunction:: Py_ssize_t PyByteArray_GET_SIZE(PyObject *bytearray) - Macro version of :c:func:`PyByteArray_Size`. + Macro version of :cfunc:`PyByteArray_Size`. diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/c-api/capsule.rst --- a/Doc/c-api/capsule.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/c-api/capsule.rst Sun Jul 20 10:52:46 2014 -0400 @@ -10,33 +10,33 @@ Refer to :ref:`using-capsules` for more information on using these objects. -.. c:type:: PyCapsule +.. ctype:: PyCapsule - This subtype of :c:type:`PyObject` represents an opaque value, useful for C - extension modules who need to pass an opaque value (as a :c:type:`void\*` + This subtype of :ctype:`PyObject` represents an opaque value, useful for C + extension modules who need to pass an opaque value (as a :ctype:`void\*` pointer) through Python code to other C code. It is often used to make a C function pointer defined in one module available to other modules, so the regular import mechanism can be used to access C APIs defined in dynamically loaded modules. -.. c:type:: PyCapsule_Destructor +.. ctype:: PyCapsule_Destructor The type of a destructor callback for a capsule. Defined as:: typedef void (*PyCapsule_Destructor)(PyObject *); - See :c:func:`PyCapsule_New` for the semantics of PyCapsule_Destructor + See :cfunc:`PyCapsule_New` for the semantics of PyCapsule_Destructor callbacks. -.. c:function:: int PyCapsule_CheckExact(PyObject *p) +.. cfunction:: int PyCapsule_CheckExact(PyObject *p) - Return true if its argument is a :c:type:`PyCapsule`. + Return true if its argument is a :ctype:`PyCapsule`. -.. c:function:: PyObject* PyCapsule_New(void *pointer, const char *name, PyCapsule_Destructor destructor) +.. cfunction:: PyObject* PyCapsule_New(void *pointer, const char *name, PyCapsule_Destructor destructor) - Create a :c:type:`PyCapsule` encapsulating the *pointer*. The *pointer* + Create a :ctype:`PyCapsule` encapsulating the *pointer*. The *pointer* argument may not be *NULL*. On failure, set an exception and return *NULL*. @@ -50,91 +50,91 @@ If this capsule will be stored as an attribute of a module, the *name* should be specified as ``modulename.attributename``. This will enable other modules - to import the capsule using :c:func:`PyCapsule_Import`. + to import the capsule using :cfunc:`PyCapsule_Import`. -.. c:function:: void* PyCapsule_GetPointer(PyObject *capsule, const char *name) +.. cfunction:: void* PyCapsule_GetPointer(PyObject *capsule, const char *name) Retrieve the *pointer* stored in the capsule. On failure, set an exception and return *NULL*. The *name* parameter must compare exactly to the name stored in the capsule. If the name stored in the capsule is *NULL*, the *name* passed in must also - be *NULL*. Python uses the C function :c:func:`strcmp` to compare capsule + be *NULL*. Python uses the C function :cfunc:`strcmp` to compare capsule names. -.. c:function:: PyCapsule_Destructor PyCapsule_GetDestructor(PyObject *capsule) +.. cfunction:: PyCapsule_Destructor PyCapsule_GetDestructor(PyObject *capsule) Return the current destructor stored in the capsule. On failure, set an exception and return *NULL*. It is legal for a capsule to have a *NULL* destructor. This makes a *NULL* - return code somewhat ambiguous; use :c:func:`PyCapsule_IsValid` or - :c:func:`PyErr_Occurred` to disambiguate. + return code somewhat ambiguous; use :cfunc:`PyCapsule_IsValid` or + :cfunc:`PyErr_Occurred` to disambiguate. -.. c:function:: void* PyCapsule_GetContext(PyObject *capsule) +.. cfunction:: void* PyCapsule_GetContext(PyObject *capsule) Return the current context stored in the capsule. On failure, set an exception and return *NULL*. It is legal for a capsule to have a *NULL* context. This makes a *NULL* - return code somewhat ambiguous; use :c:func:`PyCapsule_IsValid` or - :c:func:`PyErr_Occurred` to disambiguate. + return code somewhat ambiguous; use :cfunc:`PyCapsule_IsValid` or + :cfunc:`PyErr_Occurred` to disambiguate. -.. c:function:: const char* PyCapsule_GetName(PyObject *capsule) +.. cfunction:: const char* PyCapsule_GetName(PyObject *capsule) Return the current name stored in the capsule. On failure, set an exception and return *NULL*. It is legal for a capsule to have a *NULL* name. This makes a *NULL* return - code somewhat ambiguous; use :c:func:`PyCapsule_IsValid` or - :c:func:`PyErr_Occurred` to disambiguate. + code somewhat ambiguous; use :cfunc:`PyCapsule_IsValid` or + :cfunc:`PyErr_Occurred` to disambiguate. -.. c:function:: void* PyCapsule_Import(const char *name, int no_block) +.. cfunction:: void* PyCapsule_Import(const char *name, int no_block) Import a pointer to a C object from a capsule attribute in a module. The *name* parameter should specify the full name to the attribute, as in ``module.attribute``. The *name* stored in the capsule must match this string exactly. If *no_block* is true, import the module without blocking - (using :c:func:`PyImport_ImportModuleNoBlock`). If *no_block* is false, - import the module conventionally (using :c:func:`PyImport_ImportModule`). + (using :cfunc:`PyImport_ImportModuleNoBlock`). If *no_block* is false, + import the module conventionally (using :cfunc:`PyImport_ImportModule`). Return the capsule's internal *pointer* on success. On failure, set an - exception and return *NULL*. However, if :c:func:`PyCapsule_Import` failed to + exception and return *NULL*. However, if :cfunc:`PyCapsule_Import` failed to import the module, and *no_block* was true, no exception is set. -.. c:function:: int PyCapsule_IsValid(PyObject *capsule, const char *name) +.. cfunction:: int PyCapsule_IsValid(PyObject *capsule, const char *name) Determines whether or not *capsule* is a valid capsule. A valid capsule is - non-*NULL*, passes :c:func:`PyCapsule_CheckExact`, has a non-*NULL* pointer + non-*NULL*, passes :cfunc:`PyCapsule_CheckExact`, has a non-*NULL* pointer stored in it, and its internal name matches the *name* parameter. (See - :c:func:`PyCapsule_GetPointer` for information on how capsule names are + :cfunc:`PyCapsule_GetPointer` for information on how capsule names are compared.) - In other words, if :c:func:`PyCapsule_IsValid` returns a true value, calls to - any of the accessors (any function starting with :c:func:`PyCapsule_Get`) are + In other words, if :cfunc:`PyCapsule_IsValid` returns a true value, calls to + any of the accessors (any function starting with :cfunc:`PyCapsule_Get`) are guaranteed to succeed. Return a nonzero value if the object is valid and matches the name passed in. Return 0 otherwise. This function will not fail. -.. c:function:: int PyCapsule_SetContext(PyObject *capsule, void *context) +.. cfunction:: int PyCapsule_SetContext(PyObject *capsule, void *context) Set the context pointer inside *capsule* to *context*. Return 0 on success. Return nonzero and set an exception on failure. -.. c:function:: int PyCapsule_SetDestructor(PyObject *capsule, PyCapsule_Destructor destructor) +.. cfunction:: int PyCapsule_SetDestructor(PyObject *capsule, PyCapsule_Destructor destructor) Set the destructor inside *capsule* to *destructor*. Return 0 on success. Return nonzero and set an exception on failure. -.. c:function:: int PyCapsule_SetName(PyObject *capsule, const char *name) +.. cfunction:: int PyCapsule_SetName(PyObject *capsule, const char *name) Set the name inside *capsule* to *name*. If non-*NULL*, the name must outlive the capsule. If the previous *name* stored in the capsule was not @@ -142,7 +142,7 @@ Return 0 on success. Return nonzero and set an exception on failure. -.. c:function:: int PyCapsule_SetPointer(PyObject *capsule, void *pointer) +.. cfunction:: int PyCapsule_SetPointer(PyObject *capsule, void *pointer) Set the void pointer inside *capsule* to *pointer*. The pointer may not be *NULL*. diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/c-api/cell.rst --- a/Doc/c-api/cell.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/c-api/cell.rst Sun Jul 20 10:52:46 2014 -0400 @@ -15,39 +15,39 @@ Cell objects are not likely to be useful elsewhere. -.. c:type:: PyCellObject +.. ctype:: PyCellObject The C structure used for cell objects. -.. c:var:: PyTypeObject PyCell_Type +.. cvar:: PyTypeObject PyCell_Type The type object corresponding to cell objects. -.. c:function:: int PyCell_Check(ob) +.. cfunction:: int PyCell_Check(ob) Return true if *ob* is a cell object; *ob* must not be *NULL*. -.. c:function:: PyObject* PyCell_New(PyObject *ob) +.. cfunction:: PyObject* PyCell_New(PyObject *ob) Create and return a new cell object containing the value *ob*. The parameter may be *NULL*. -.. c:function:: PyObject* PyCell_Get(PyObject *cell) +.. cfunction:: PyObject* PyCell_Get(PyObject *cell) Return the contents of the cell *cell*. -.. c:function:: PyObject* PyCell_GET(PyObject *cell) +.. cfunction:: PyObject* PyCell_GET(PyObject *cell) Return the contents of the cell *cell*, but without checking that *cell* is non-*NULL* and a cell object. -.. c:function:: int PyCell_Set(PyObject *cell, PyObject *value) +.. cfunction:: int PyCell_Set(PyObject *cell, PyObject *value) Set the contents of the cell object *cell* to *value*. This releases the reference to any current content of the cell. *value* may be *NULL*. *cell* @@ -55,7 +55,7 @@ success, ``0`` will be returned. -.. c:function:: void PyCell_SET(PyObject *cell, PyObject *value) +.. cfunction:: void PyCell_SET(PyObject *cell, PyObject *value) Sets the value of the cell object *cell* to *value*. No reference counts are adjusted, and no checks are made for safety; *cell* must be non-*NULL* and must diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/c-api/class.rst --- a/Doc/c-api/class.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/c-api/class.rst Sun Jul 20 10:52:46 2014 -0400 @@ -12,12 +12,12 @@ will want to work with type objects (section :ref:`typeobjects`). -.. c:type:: PyClassObject +.. ctype:: PyClassObject The C structure of the objects used to describe built-in classes. -.. c:var:: PyObject* PyClass_Type +.. cvar:: PyObject* PyClass_Type .. index:: single: ClassType (in module types) @@ -25,13 +25,13 @@ ``types.ClassType`` in the Python layer. -.. c:function:: int PyClass_Check(PyObject *o) +.. cfunction:: int PyClass_Check(PyObject *o) Return true if the object *o* is a class object, including instances of types derived from the standard class object. Return false in all other cases. -.. c:function:: int PyClass_IsSubclass(PyObject *klass, PyObject *base) +.. cfunction:: int PyClass_IsSubclass(PyObject *klass, PyObject *base) Return true if *klass* is a subclass of *base*. Return false in all other cases. @@ -41,23 +41,23 @@ There are very few functions specific to instance objects. -.. c:var:: PyTypeObject PyInstance_Type +.. cvar:: PyTypeObject PyInstance_Type Type object for class instances. -.. c:function:: int PyInstance_Check(PyObject *obj) +.. cfunction:: int PyInstance_Check(PyObject *obj) Return true if *obj* is an instance. -.. c:function:: PyObject* PyInstance_New(PyObject *class, PyObject *arg, PyObject *kw) +.. cfunction:: PyObject* PyInstance_New(PyObject *class, PyObject *arg, PyObject *kw) Create a new instance of a specific class. The parameters *arg* and *kw* are used as the positional and keyword parameters to the object's constructor. -.. c:function:: PyObject* PyInstance_NewRaw(PyObject *class, PyObject *dict) +.. cfunction:: PyObject* PyInstance_NewRaw(PyObject *class, PyObject *dict) Create a new instance of a specific class without calling its constructor. *class* is the class of new object. The *dict* parameter will be used as the diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/c-api/cobject.rst --- a/Doc/c-api/cobject.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/c-api/cobject.rst Sun Jul 20 10:52:46 2014 -0400 @@ -13,47 +13,47 @@ The CObject API is deprecated as of Python 2.7. Please switch to the new :ref:`capsules` API. -.. c:type:: PyCObject +.. ctype:: PyCObject - This subtype of :c:type:`PyObject` represents an opaque value, useful for C - extension modules who need to pass an opaque value (as a :c:type:`void\*` + This subtype of :ctype:`PyObject` represents an opaque value, useful for C + extension modules who need to pass an opaque value (as a :ctype:`void\*` pointer) through Python code to other C code. It is often used to make a C function pointer defined in one module available to other modules, so the regular import mechanism can be used to access C APIs defined in dynamically loaded modules. -.. c:function:: int PyCObject_Check(PyObject *p) +.. cfunction:: int PyCObject_Check(PyObject *p) - Return true if its argument is a :c:type:`PyCObject`. + Return true if its argument is a :ctype:`PyCObject`. -.. c:function:: PyObject* PyCObject_FromVoidPtr(void* cobj, void (*destr)(void *)) +.. cfunction:: PyObject* PyCObject_FromVoidPtr(void* cobj, void (*destr)(void *)) - Create a :c:type:`PyCObject` from the ``void *`` *cobj*. The *destr* function + Create a :ctype:`PyCObject` from the ``void *`` *cobj*. The *destr* function will be called when the object is reclaimed, unless it is *NULL*. -.. c:function:: PyObject* PyCObject_FromVoidPtrAndDesc(void* cobj, void* desc, void (*destr)(void *, void *)) +.. cfunction:: PyObject* PyCObject_FromVoidPtrAndDesc(void* cobj, void* desc, void (*destr)(void *, void *)) - Create a :c:type:`PyCObject` from the :c:type:`void \*` *cobj*. The *destr* + Create a :ctype:`PyCObject` from the :ctype:`void \*` *cobj*. The *destr* function will be called when the object is reclaimed. The *desc* argument can be used to pass extra callback data for the destructor function. -.. c:function:: void* PyCObject_AsVoidPtr(PyObject* self) +.. cfunction:: void* PyCObject_AsVoidPtr(PyObject* self) - Return the object :c:type:`void \*` that the :c:type:`PyCObject` *self* was + Return the object :ctype:`void \*` that the :ctype:`PyCObject` *self* was created with. -.. c:function:: void* PyCObject_GetDesc(PyObject* self) +.. cfunction:: void* PyCObject_GetDesc(PyObject* self) - Return the description :c:type:`void \*` that the :c:type:`PyCObject` *self* was + Return the description :ctype:`void \*` that the :ctype:`PyCObject` *self* was created with. -.. c:function:: int PyCObject_SetVoidPtr(PyObject* self, void* cobj) +.. cfunction:: int PyCObject_SetVoidPtr(PyObject* self, void* cobj) - Set the void pointer inside *self* to *cobj*. The :c:type:`PyCObject` must not + Set the void pointer inside *self* to *cobj*. The :ctype:`PyCObject` must not have an associated destructor. Return true on success, false on failure. diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/c-api/code.rst --- a/Doc/c-api/code.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/c-api/code.rst Sun Jul 20 10:52:46 2014 -0400 @@ -15,35 +15,35 @@ Each one represents a chunk of executable code that hasn't yet been bound into a function. -.. c:type:: PyCodeObject +.. ctype:: PyCodeObject The C structure of the objects used to describe code objects. The fields of this type are subject to change at any time. -.. c:var:: PyTypeObject PyCode_Type +.. cvar:: PyTypeObject PyCode_Type - This is an instance of :c:type:`PyTypeObject` representing the Python + This is an instance of :ctype:`PyTypeObject` representing the Python :class:`code` type. -.. c:function:: int PyCode_Check(PyObject *co) +.. cfunction:: int PyCode_Check(PyObject *co) Return true if *co* is a :class:`code` object -.. c:function:: int PyCode_GetNumFree(PyObject *co) +.. cfunction:: int PyCode_GetNumFree(PyObject *co) Return the number of free variables in *co*. -.. c:function:: PyCodeObject *PyCode_New(int argcount, int nlocals, int stacksize, int flags, PyObject *code, PyObject *consts, PyObject *names, PyObject *varnames, PyObject *freevars, PyObject *cellvars, PyObject *filename, PyObject *name, int firstlineno, PyObject *lnotab) +.. cfunction:: PyCodeObject *PyCode_New(int argcount, int nlocals, int stacksize, int flags, PyObject *code, PyObject *consts, PyObject *names, PyObject *varnames, PyObject *freevars, PyObject *cellvars, PyObject *filename, PyObject *name, int firstlineno, PyObject *lnotab) Return a new code object. If you need a dummy code object to - create a frame, use :c:func:`PyCode_NewEmpty` instead. Calling - :c:func:`PyCode_New` directly can bind you to a precise Python + create a frame, use :cfunc:`PyCode_NewEmpty` instead. Calling + :cfunc:`PyCode_New` directly can bind you to a precise Python version since the definition of the bytecode changes often. -.. c:function:: int PyCode_NewEmpty(const char *filename, const char *funcname, int firstlineno) +.. cfunction:: int PyCode_NewEmpty(const char *filename, const char *funcname, int firstlineno) Return a new empty code object with the specified filename, function name, and first line number. It is illegal to diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/c-api/codec.rst --- a/Doc/c-api/codec.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/c-api/codec.rst Sun Jul 20 10:52:46 2014 -0400 @@ -3,19 +3,19 @@ Codec registry and support functions ==================================== -.. c:function:: int PyCodec_Register(PyObject *search_function) +.. cfunction:: int PyCodec_Register(PyObject *search_function) Register a new codec search function. As side effect, this tries to load the :mod:`encodings` package, if not yet done, to make sure that it is always first in the list of search functions. -.. c:function:: int PyCodec_KnownEncoding(const char *encoding) +.. cfunction:: int PyCodec_KnownEncoding(const char *encoding) Return ``1`` or ``0`` depending on whether there is a registered codec for the given *encoding*. -.. c:function:: PyObject* PyCodec_Encode(PyObject *object, const char *encoding, const char *errors) +.. cfunction:: PyObject* PyCodec_Encode(PyObject *object, const char *encoding, const char *errors) Generic codec based encoding API. @@ -24,7 +24,7 @@ be *NULL* to use the default method defined for the codec. Raises a :exc:`LookupError` if no encoder can be found. -.. c:function:: PyObject* PyCodec_Decode(PyObject *object, const char *encoding, const char *errors) +.. cfunction:: PyObject* PyCodec_Decode(PyObject *object, const char *encoding, const char *errors) Generic codec based decoding API. @@ -42,35 +42,35 @@ effectively case-insensitive. If no codec is found, a :exc:`KeyError` is set and *NULL* returned. -.. c:function:: PyObject* PyCodec_Encoder(const char *encoding) +.. cfunction:: PyObject* PyCodec_Encoder(const char *encoding) Get an encoder function for the given *encoding*. -.. c:function:: PyObject* PyCodec_Decoder(const char *encoding) +.. cfunction:: PyObject* PyCodec_Decoder(const char *encoding) Get a decoder function for the given *encoding*. -.. c:function:: PyObject* PyCodec_IncrementalEncoder(const char *encoding, const char *errors) +.. cfunction:: PyObject* PyCodec_IncrementalEncoder(const char *encoding, const char *errors) - Get an :class:`~codecs.IncrementalEncoder` object for the given *encoding*. + Get an :class:`IncrementalEncoder` object for the given *encoding*. -.. c:function:: PyObject* PyCodec_IncrementalDecoder(const char *encoding, const char *errors) +.. cfunction:: PyObject* PyCodec_IncrementalDecoder(const char *encoding, const char *errors) - Get an :class:`~codecs.IncrementalDecoder` object for the given *encoding*. + Get an :class:`IncrementalDecoder` object for the given *encoding*. -.. c:function:: PyObject* PyCodec_StreamReader(const char *encoding, PyObject *stream, const char *errors) +.. cfunction:: PyObject* PyCodec_StreamReader(const char *encoding, PyObject *stream, const char *errors) - Get a :class:`~codecs.StreamReader` factory function for the given *encoding*. + Get a :class:`StreamReader` factory function for the given *encoding*. -.. c:function:: PyObject* PyCodec_StreamWriter(const char *encoding, PyObject *stream, const char *errors) +.. cfunction:: PyObject* PyCodec_StreamWriter(const char *encoding, PyObject *stream, const char *errors) - Get a :class:`~codecs.StreamWriter` factory function for the given *encoding*. + Get a :class:`StreamWriter` factory function for the given *encoding*. Registry API for Unicode encoding error handlers ------------------------------------------------ -.. c:function:: int PyCodec_RegisterError(const char *name, PyObject *error) +.. cfunction:: int PyCodec_RegisterError(const char *name, PyObject *error) Register the error handling callback function *error* under the given *name*. This callback function will be called by a codec when it encounters @@ -89,29 +89,29 @@ Return ``0`` on success, ``-1`` on error. -.. c:function:: PyObject* PyCodec_LookupError(const char *name) +.. cfunction:: PyObject* PyCodec_LookupError(const char *name) Lookup the error handling callback function registered under *name*. As a special case *NULL* can be passed, in which case the error handling callback for "strict" will be returned. -.. c:function:: PyObject* PyCodec_StrictErrors(PyObject *exc) +.. cfunction:: PyObject* PyCodec_StrictErrors(PyObject *exc) Raise *exc* as an exception. -.. c:function:: PyObject* PyCodec_IgnoreErrors(PyObject *exc) +.. cfunction:: PyObject* PyCodec_IgnoreErrors(PyObject *exc) Ignore the unicode error, skipping the faulty input. -.. c:function:: PyObject* PyCodec_ReplaceErrors(PyObject *exc) +.. cfunction:: PyObject* PyCodec_ReplaceErrors(PyObject *exc) Replace the unicode encode error with ``?`` or ``U+FFFD``. -.. c:function:: PyObject* PyCodec_XMLCharRefReplaceErrors(PyObject *exc) +.. cfunction:: PyObject* PyCodec_XMLCharRefReplaceErrors(PyObject *exc) Replace the unicode encode error with XML character references. -.. c:function:: PyObject* PyCodec_BackslashReplaceErrors(PyObject *exc) +.. cfunction:: PyObject* PyCodec_BackslashReplaceErrors(PyObject *exc) Replace the unicode encode error with backslash escapes (``\x``, ``\u`` and ``\U``). diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/c-api/complex.rst --- a/Doc/c-api/complex.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/c-api/complex.rst Sun Jul 20 10:52:46 2014 -0400 @@ -21,7 +21,7 @@ pointers. This is consistent throughout the API. -.. c:type:: Py_complex +.. ctype:: Py_complex The C structure which corresponds to the value portion of a Python complex number object. Most of the functions for dealing with complex number objects @@ -34,104 +34,97 @@ } Py_complex; -.. c:function:: Py_complex _Py_c_sum(Py_complex left, Py_complex right) +.. cfunction:: Py_complex _Py_c_sum(Py_complex left, Py_complex right) - Return the sum of two complex numbers, using the C :c:type:`Py_complex` + Return the sum of two complex numbers, using the C :ctype:`Py_complex` representation. -.. c:function:: Py_complex _Py_c_diff(Py_complex left, Py_complex right) +.. cfunction:: Py_complex _Py_c_diff(Py_complex left, Py_complex right) Return the difference between two complex numbers, using the C - :c:type:`Py_complex` representation. + :ctype:`Py_complex` representation. -.. c:function:: Py_complex _Py_c_neg(Py_complex complex) +.. cfunction:: Py_complex _Py_c_neg(Py_complex complex) Return the negation of the complex number *complex*, using the C - :c:type:`Py_complex` representation. + :ctype:`Py_complex` representation. -.. c:function:: Py_complex _Py_c_prod(Py_complex left, Py_complex right) +.. cfunction:: Py_complex _Py_c_prod(Py_complex left, Py_complex right) - Return the product of two complex numbers, using the C :c:type:`Py_complex` + Return the product of two complex numbers, using the C :ctype:`Py_complex` representation. -.. c:function:: Py_complex _Py_c_quot(Py_complex dividend, Py_complex divisor) +.. cfunction:: Py_complex _Py_c_quot(Py_complex dividend, Py_complex divisor) - Return the quotient of two complex numbers, using the C :c:type:`Py_complex` + Return the quotient of two complex numbers, using the C :ctype:`Py_complex` representation. - If *divisor* is null, this method returns zero and sets - :c:data:`errno` to :c:data:`EDOM`. +.. cfunction:: Py_complex _Py_c_pow(Py_complex num, Py_complex exp) -.. c:function:: Py_complex _Py_c_pow(Py_complex num, Py_complex exp) - - Return the exponentiation of *num* by *exp*, using the C :c:type:`Py_complex` + Return the exponentiation of *num* by *exp*, using the C :ctype:`Py_complex` representation. - If *num* is null and *exp* is not a positive real number, - this method returns zero and sets :c:data:`errno` to :c:data:`EDOM`. - Complex Numbers as Python Objects ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -.. c:type:: PyComplexObject +.. ctype:: PyComplexObject - This subtype of :c:type:`PyObject` represents a Python complex number object. + This subtype of :ctype:`PyObject` represents a Python complex number object. -.. c:var:: PyTypeObject PyComplex_Type +.. cvar:: PyTypeObject PyComplex_Type - This instance of :c:type:`PyTypeObject` represents the Python complex number + This instance of :ctype:`PyTypeObject` represents the Python complex number type. It is the same object as ``complex`` and ``types.ComplexType``. -.. c:function:: int PyComplex_Check(PyObject *p) +.. cfunction:: int PyComplex_Check(PyObject *p) - Return true if its argument is a :c:type:`PyComplexObject` or a subtype of - :c:type:`PyComplexObject`. + Return true if its argument is a :ctype:`PyComplexObject` or a subtype of + :ctype:`PyComplexObject`. .. versionchanged:: 2.2 Allowed subtypes to be accepted. -.. c:function:: int PyComplex_CheckExact(PyObject *p) +.. cfunction:: int PyComplex_CheckExact(PyObject *p) - Return true if its argument is a :c:type:`PyComplexObject`, but not a subtype of - :c:type:`PyComplexObject`. + Return true if its argument is a :ctype:`PyComplexObject`, but not a subtype of + :ctype:`PyComplexObject`. .. versionadded:: 2.2 -.. c:function:: PyObject* PyComplex_FromCComplex(Py_complex v) +.. cfunction:: PyObject* PyComplex_FromCComplex(Py_complex v) - Create a new Python complex number object from a C :c:type:`Py_complex` value. + Create a new Python complex number object from a C :ctype:`Py_complex` value. -.. c:function:: PyObject* PyComplex_FromDoubles(double real, double imag) +.. cfunction:: PyObject* PyComplex_FromDoubles(double real, double imag) - Return a new :c:type:`PyComplexObject` object from *real* and *imag*. + Return a new :ctype:`PyComplexObject` object from *real* and *imag*. -.. c:function:: double PyComplex_RealAsDouble(PyObject *op) +.. cfunction:: double PyComplex_RealAsDouble(PyObject *op) - Return the real part of *op* as a C :c:type:`double`. + Return the real part of *op* as a C :ctype:`double`. -.. c:function:: double PyComplex_ImagAsDouble(PyObject *op) +.. cfunction:: double PyComplex_ImagAsDouble(PyObject *op) - Return the imaginary part of *op* as a C :c:type:`double`. + Return the imaginary part of *op* as a C :ctype:`double`. -.. c:function:: Py_complex PyComplex_AsCComplex(PyObject *op) +.. cfunction:: Py_complex PyComplex_AsCComplex(PyObject *op) - Return the :c:type:`Py_complex` value of the complex number *op*. - Upon failure, this method returns ``-1.0`` as a real value. + Return the :ctype:`Py_complex` value of the complex number *op*. .. versionchanged:: 2.6 If *op* is not a Python complex number object but has a :meth:`__complex__` diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/c-api/concrete.rst --- a/Doc/c-api/concrete.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/c-api/concrete.rst Sun Jul 20 10:52:46 2014 -0400 @@ -11,7 +11,7 @@ Passing them an object of the wrong type is not a good idea; if you receive an object from a Python program and you are not sure that it has the right type, you must perform a type check first; for example, to check that an object is a -dictionary, use :c:func:`PyDict_Check`. The chapter is structured like the +dictionary, use :cfunc:`PyDict_Check`. The chapter is structured like the "family tree" of Python object types. .. warning:: diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/c-api/conversion.rst --- a/Doc/c-api/conversion.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/c-api/conversion.rst Sun Jul 20 10:52:46 2014 -0400 @@ -8,20 +8,20 @@ Functions for number conversion and formatted string output. -.. c:function:: int PyOS_snprintf(char *str, size_t size, const char *format, ...) +.. cfunction:: int PyOS_snprintf(char *str, size_t size, const char *format, ...) Output not more than *size* bytes to *str* according to the format string *format* and the extra arguments. See the Unix man page :manpage:`snprintf(2)`. -.. c:function:: int PyOS_vsnprintf(char *str, size_t size, const char *format, va_list va) +.. cfunction:: int PyOS_vsnprintf(char *str, size_t size, const char *format, va_list va) Output not more than *size* bytes to *str* according to the format string *format* and the variable argument list *va*. Unix man page :manpage:`vsnprintf(2)`. -:c:func:`PyOS_snprintf` and :c:func:`PyOS_vsnprintf` wrap the Standard C library -functions :c:func:`snprintf` and :c:func:`vsnprintf`. Their purpose is to +:cfunc:`PyOS_snprintf` and :cfunc:`PyOS_vsnprintf` wrap the Standard C library +functions :cfunc:`snprintf` and :cfunc:`vsnprintf`. Their purpose is to guarantee consistent behavior in corner cases, which the Standard C functions do not. @@ -30,7 +30,7 @@ Both functions require that ``str != NULL``, ``size > 0`` and ``format != NULL``. -If the platform doesn't have :c:func:`vsnprintf` and the buffer size needed to +If the platform doesn't have :cfunc:`vsnprintf` and the buffer size needed to avoid truncation exceeds *size* by more than 512 bytes, Python aborts with a *Py_FatalError*. @@ -51,9 +51,9 @@ The following functions provide locale-independent string to number conversions. -.. c:function:: double PyOS_string_to_double(const char *s, char **endptr, PyObject *overflow_exception) +.. cfunction:: double PyOS_string_to_double(const char *s, char **endptr, PyObject *overflow_exception) - Convert a string ``s`` to a :c:type:`double`, raising a Python + Convert a string ``s`` to a :ctype:`double`, raising a Python exception on failure. The set of accepted strings corresponds to the set of strings accepted by Python's :func:`float` constructor, except that ``s`` must not have leading or trailing whitespace. @@ -85,13 +85,13 @@ .. versionadded:: 2.7 -.. c:function:: double PyOS_ascii_strtod(const char *nptr, char **endptr) +.. cfunction:: double PyOS_ascii_strtod(const char *nptr, char **endptr) - Convert a string to a :c:type:`double`. This function behaves like the Standard C - function :c:func:`strtod` does in the C locale. It does this without changing the + Convert a string to a :ctype:`double`. This function behaves like the Standard C + function :cfunc:`strtod` does in the C locale. It does this without changing the current locale, since that would not be thread-safe. - :c:func:`PyOS_ascii_strtod` should typically be used for reading configuration + :cfunc:`PyOS_ascii_strtod` should typically be used for reading configuration files or other non-user input that should be locale independent. See the Unix man page :manpage:`strtod(2)` for details. @@ -99,14 +99,14 @@ .. versionadded:: 2.4 .. deprecated:: 2.7 - Use :c:func:`PyOS_string_to_double` instead. + Use :cfunc:`PyOS_string_to_double` instead. -.. c:function:: char* PyOS_ascii_formatd(char *buffer, size_t buf_len, const char *format, double d) +.. cfunction:: char* PyOS_ascii_formatd(char *buffer, size_t buf_len, const char *format, double d) - Convert a :c:type:`double` to a string using the ``'.'`` as the decimal - separator. *format* is a :c:func:`printf`\ -style format string specifying the + Convert a :ctype:`double` to a string using the ``'.'`` as the decimal + separator. *format* is a :cfunc:`printf`\ -style format string specifying the number format. Allowed conversion characters are ``'e'``, ``'E'``, ``'f'``, ``'F'``, ``'g'`` and ``'G'``. @@ -119,9 +119,9 @@ instead. -.. c:function:: char* PyOS_double_to_string(double val, char format_code, int precision, int flags, int *ptype) +.. cfunction:: char* PyOS_double_to_string(double val, char format_code, int precision, int flags, int *ptype) - Convert a :c:type:`double` *val* to a string using supplied + Convert a :ctype:`double` *val* to a string using supplied *format_code*, *precision*, and *flags*. *format_code* must be one of ``'e'``, ``'E'``, ``'f'``, ``'F'``, @@ -139,7 +139,7 @@ like an integer. * *Py_DTSF_ALT* means to apply "alternate" formatting rules. See the - documentation for the :c:func:`PyOS_snprintf` ``'#'`` specifier for + documentation for the :cfunc:`PyOS_snprintf` ``'#'`` specifier for details. If *ptype* is non-NULL, then the value it points to will be set to one of @@ -148,34 +148,34 @@ The return value is a pointer to *buffer* with the converted string or *NULL* if the conversion failed. The caller is responsible for freeing the - returned string by calling :c:func:`PyMem_Free`. + returned string by calling :cfunc:`PyMem_Free`. .. versionadded:: 2.7 -.. c:function:: double PyOS_ascii_atof(const char *nptr) +.. cfunction:: double PyOS_ascii_atof(const char *nptr) - Convert a string to a :c:type:`double` in a locale-independent way. + Convert a string to a :ctype:`double` in a locale-independent way. See the Unix man page :manpage:`atof(2)` for details. .. versionadded:: 2.4 .. deprecated:: 3.1 - Use :c:func:`PyOS_string_to_double` instead. + Use :cfunc:`PyOS_string_to_double` instead. -.. c:function:: char* PyOS_stricmp(char *s1, char *s2) +.. cfunction:: char* PyOS_stricmp(char *s1, char *s2) Case insensitive comparison of strings. The function works almost - identically to :c:func:`strcmp` except that it ignores the case. + identically to :cfunc:`strcmp` except that it ignores the case. .. versionadded:: 2.6 -.. c:function:: char* PyOS_strnicmp(char *s1, char *s2, Py_ssize_t size) +.. cfunction:: char* PyOS_strnicmp(char *s1, char *s2, Py_ssize_t size) Case insensitive comparison of strings. The function works almost - identically to :c:func:`strncmp` except that it ignores the case. + identically to :cfunc:`strncmp` except that it ignores the case. .. versionadded:: 2.6 diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/c-api/datetime.rst --- a/Doc/c-api/datetime.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/c-api/datetime.rst Sun Jul 20 10:52:46 2014 -0400 @@ -8,89 +8,89 @@ Various date and time objects are supplied by the :mod:`datetime` module. Before using any of these functions, the header file :file:`datetime.h` must be included in your source (note that this is not included by :file:`Python.h`), -and the macro :c:macro:`PyDateTime_IMPORT` must be invoked, usually as part of +and the macro :cmacro:`PyDateTime_IMPORT` must be invoked, usually as part of the module initialisation function. The macro puts a pointer to a C structure -into a static variable, :c:data:`PyDateTimeAPI`, that is used by the following +into a static variable, :cdata:`PyDateTimeAPI`, that is used by the following macros. Type-check macros: -.. c:function:: int PyDate_Check(PyObject *ob) +.. cfunction:: int PyDate_Check(PyObject *ob) - Return true if *ob* is of type :c:data:`PyDateTime_DateType` or a subtype of - :c:data:`PyDateTime_DateType`. *ob* must not be *NULL*. + Return true if *ob* is of type :cdata:`PyDateTime_DateType` or a subtype of + :cdata:`PyDateTime_DateType`. *ob* must not be *NULL*. .. versionadded:: 2.4 -.. c:function:: int PyDate_CheckExact(PyObject *ob) +.. cfunction:: int PyDate_CheckExact(PyObject *ob) - Return true if *ob* is of type :c:data:`PyDateTime_DateType`. *ob* must not be + Return true if *ob* is of type :cdata:`PyDateTime_DateType`. *ob* must not be *NULL*. .. versionadded:: 2.4 -.. c:function:: int PyDateTime_Check(PyObject *ob) +.. cfunction:: int PyDateTime_Check(PyObject *ob) - Return true if *ob* is of type :c:data:`PyDateTime_DateTimeType` or a subtype of - :c:data:`PyDateTime_DateTimeType`. *ob* must not be *NULL*. + Return true if *ob* is of type :cdata:`PyDateTime_DateTimeType` or a subtype of + :cdata:`PyDateTime_DateTimeType`. *ob* must not be *NULL*. .. versionadded:: 2.4 -.. c:function:: int PyDateTime_CheckExact(PyObject *ob) +.. cfunction:: int PyDateTime_CheckExact(PyObject *ob) - Return true if *ob* is of type :c:data:`PyDateTime_DateTimeType`. *ob* must not + Return true if *ob* is of type :cdata:`PyDateTime_DateTimeType`. *ob* must not be *NULL*. .. versionadded:: 2.4 -.. c:function:: int PyTime_Check(PyObject *ob) +.. cfunction:: int PyTime_Check(PyObject *ob) - Return true if *ob* is of type :c:data:`PyDateTime_TimeType` or a subtype of - :c:data:`PyDateTime_TimeType`. *ob* must not be *NULL*. + Return true if *ob* is of type :cdata:`PyDateTime_TimeType` or a subtype of + :cdata:`PyDateTime_TimeType`. *ob* must not be *NULL*. .. versionadded:: 2.4 -.. c:function:: int PyTime_CheckExact(PyObject *ob) +.. cfunction:: int PyTime_CheckExact(PyObject *ob) - Return true if *ob* is of type :c:data:`PyDateTime_TimeType`. *ob* must not be + Return true if *ob* is of type :cdata:`PyDateTime_TimeType`. *ob* must not be *NULL*. .. versionadded:: 2.4 -.. c:function:: int PyDelta_Check(PyObject *ob) +.. cfunction:: int PyDelta_Check(PyObject *ob) - Return true if *ob* is of type :c:data:`PyDateTime_DeltaType` or a subtype of - :c:data:`PyDateTime_DeltaType`. *ob* must not be *NULL*. + Return true if *ob* is of type :cdata:`PyDateTime_DeltaType` or a subtype of + :cdata:`PyDateTime_DeltaType`. *ob* must not be *NULL*. .. versionadded:: 2.4 -.. c:function:: int PyDelta_CheckExact(PyObject *ob) +.. cfunction:: int PyDelta_CheckExact(PyObject *ob) - Return true if *ob* is of type :c:data:`PyDateTime_DeltaType`. *ob* must not be + Return true if *ob* is of type :cdata:`PyDateTime_DeltaType`. *ob* must not be *NULL*. .. versionadded:: 2.4 -.. c:function:: int PyTZInfo_Check(PyObject *ob) +.. cfunction:: int PyTZInfo_Check(PyObject *ob) - Return true if *ob* is of type :c:data:`PyDateTime_TZInfoType` or a subtype of - :c:data:`PyDateTime_TZInfoType`. *ob* must not be *NULL*. + Return true if *ob* is of type :cdata:`PyDateTime_TZInfoType` or a subtype of + :cdata:`PyDateTime_TZInfoType`. *ob* must not be *NULL*. .. versionadded:: 2.4 -.. c:function:: int PyTZInfo_CheckExact(PyObject *ob) +.. cfunction:: int PyTZInfo_CheckExact(PyObject *ob) - Return true if *ob* is of type :c:data:`PyDateTime_TZInfoType`. *ob* must not be + Return true if *ob* is of type :cdata:`PyDateTime_TZInfoType`. *ob* must not be *NULL*. .. versionadded:: 2.4 @@ -98,14 +98,14 @@ Macros to create objects: -.. c:function:: PyObject* PyDate_FromDate(int year, int month, int day) +.. cfunction:: PyObject* PyDate_FromDate(int year, int month, int day) Return a ``datetime.date`` object with the specified year, month and day. .. versionadded:: 2.4 -.. c:function:: PyObject* PyDateTime_FromDateAndTime(int year, int month, int day, int hour, int minute, int second, int usecond) +.. cfunction:: PyObject* PyDateTime_FromDateAndTime(int year, int month, int day, int hour, int minute, int second, int usecond) Return a ``datetime.datetime`` object with the specified year, month, day, hour, minute, second and microsecond. @@ -113,7 +113,7 @@ .. versionadded:: 2.4 -.. c:function:: PyObject* PyTime_FromTime(int hour, int minute, int second, int usecond) +.. cfunction:: PyObject* PyTime_FromTime(int hour, int minute, int second, int usecond) Return a ``datetime.time`` object with the specified hour, minute, second and microsecond. @@ -121,7 +121,7 @@ .. versionadded:: 2.4 -.. c:function:: PyObject* PyDelta_FromDSU(int days, int seconds, int useconds) +.. cfunction:: PyObject* PyDelta_FromDSU(int days, int seconds, int useconds) Return a ``datetime.timedelta`` object representing the given number of days, seconds and microseconds. Normalization is performed so that the resulting @@ -131,90 +131,90 @@ .. versionadded:: 2.4 Macros to extract fields from date objects. The argument must be an instance of -:c:data:`PyDateTime_Date`, including subclasses (such as -:c:data:`PyDateTime_DateTime`). The argument must not be *NULL*, and the type is +:cdata:`PyDateTime_Date`, including subclasses (such as +:cdata:`PyDateTime_DateTime`). The argument must not be *NULL*, and the type is not checked: -.. c:function:: int PyDateTime_GET_YEAR(PyDateTime_Date *o) +.. cfunction:: int PyDateTime_GET_YEAR(PyDateTime_Date *o) Return the year, as a positive int. .. versionadded:: 2.4 -.. c:function:: int PyDateTime_GET_MONTH(PyDateTime_Date *o) +.. cfunction:: int PyDateTime_GET_MONTH(PyDateTime_Date *o) Return the month, as an int from 1 through 12. .. versionadded:: 2.4 -.. c:function:: int PyDateTime_GET_DAY(PyDateTime_Date *o) +.. cfunction:: int PyDateTime_GET_DAY(PyDateTime_Date *o) Return the day, as an int from 1 through 31. .. versionadded:: 2.4 Macros to extract fields from datetime objects. The argument must be an -instance of :c:data:`PyDateTime_DateTime`, including subclasses. The argument +instance of :cdata:`PyDateTime_DateTime`, including subclasses. The argument must not be *NULL*, and the type is not checked: -.. c:function:: int PyDateTime_DATE_GET_HOUR(PyDateTime_DateTime *o) +.. cfunction:: int PyDateTime_DATE_GET_HOUR(PyDateTime_DateTime *o) Return the hour, as an int from 0 through 23. .. versionadded:: 2.4 -.. c:function:: int PyDateTime_DATE_GET_MINUTE(PyDateTime_DateTime *o) +.. cfunction:: int PyDateTime_DATE_GET_MINUTE(PyDateTime_DateTime *o) Return the minute, as an int from 0 through 59. .. versionadded:: 2.4 -.. c:function:: int PyDateTime_DATE_GET_SECOND(PyDateTime_DateTime *o) +.. cfunction:: int PyDateTime_DATE_GET_SECOND(PyDateTime_DateTime *o) Return the second, as an int from 0 through 59. .. versionadded:: 2.4 -.. c:function:: int PyDateTime_DATE_GET_MICROSECOND(PyDateTime_DateTime *o) +.. cfunction:: int PyDateTime_DATE_GET_MICROSECOND(PyDateTime_DateTime *o) Return the microsecond, as an int from 0 through 999999. .. versionadded:: 2.4 Macros to extract fields from time objects. The argument must be an instance of -:c:data:`PyDateTime_Time`, including subclasses. The argument must not be *NULL*, +:cdata:`PyDateTime_Time`, including subclasses. The argument must not be *NULL*, and the type is not checked: -.. c:function:: int PyDateTime_TIME_GET_HOUR(PyDateTime_Time *o) +.. cfunction:: int PyDateTime_TIME_GET_HOUR(PyDateTime_Time *o) Return the hour, as an int from 0 through 23. .. versionadded:: 2.4 -.. c:function:: int PyDateTime_TIME_GET_MINUTE(PyDateTime_Time *o) +.. cfunction:: int PyDateTime_TIME_GET_MINUTE(PyDateTime_Time *o) Return the minute, as an int from 0 through 59. .. versionadded:: 2.4 -.. c:function:: int PyDateTime_TIME_GET_SECOND(PyDateTime_Time *o) +.. cfunction:: int PyDateTime_TIME_GET_SECOND(PyDateTime_Time *o) Return the second, as an int from 0 through 59. .. versionadded:: 2.4 -.. c:function:: int PyDateTime_TIME_GET_MICROSECOND(PyDateTime_Time *o) +.. cfunction:: int PyDateTime_TIME_GET_MICROSECOND(PyDateTime_Time *o) Return the microsecond, as an int from 0 through 999999. @@ -223,7 +223,7 @@ Macros for the convenience of modules implementing the DB API: -.. c:function:: PyObject* PyDateTime_FromTimestamp(PyObject *args) +.. cfunction:: PyObject* PyDateTime_FromTimestamp(PyObject *args) Create and return a new ``datetime.datetime`` object given an argument tuple suitable for passing to ``datetime.datetime.fromtimestamp()``. @@ -231,7 +231,7 @@ .. versionadded:: 2.4 -.. c:function:: PyObject* PyDate_FromTimestamp(PyObject *args) +.. cfunction:: PyObject* PyDate_FromTimestamp(PyObject *args) Create and return a new ``datetime.date`` object given an argument tuple suitable for passing to ``datetime.date.fromtimestamp()``. diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/c-api/descriptor.rst --- a/Doc/c-api/descriptor.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/c-api/descriptor.rst Sun Jul 20 10:52:46 2014 -0400 @@ -9,39 +9,39 @@ found in the dictionary of type objects. -.. c:var:: PyTypeObject PyProperty_Type +.. cvar:: PyTypeObject PyProperty_Type The type object for the built-in descriptor types. .. versionadded:: 2.2 -.. c:function:: PyObject* PyDescr_NewGetSet(PyTypeObject *type, struct PyGetSetDef *getset) +.. cfunction:: PyObject* PyDescr_NewGetSet(PyTypeObject *type, struct PyGetSetDef *getset) .. versionadded:: 2.2 -.. c:function:: PyObject* PyDescr_NewMember(PyTypeObject *type, struct PyMemberDef *meth) +.. cfunction:: PyObject* PyDescr_NewMember(PyTypeObject *type, struct PyMemberDef *meth) .. versionadded:: 2.2 -.. c:function:: PyObject* PyDescr_NewMethod(PyTypeObject *type, struct PyMethodDef *meth) +.. cfunction:: PyObject* PyDescr_NewMethod(PyTypeObject *type, struct PyMethodDef *meth) .. versionadded:: 2.2 -.. c:function:: PyObject* PyDescr_NewWrapper(PyTypeObject *type, struct wrapperbase *wrapper, void *wrapped) +.. cfunction:: PyObject* PyDescr_NewWrapper(PyTypeObject *type, struct wrapperbase *wrapper, void *wrapped) .. versionadded:: 2.2 -.. c:function:: PyObject* PyDescr_NewClassMethod(PyTypeObject *type, PyMethodDef *method) +.. cfunction:: PyObject* PyDescr_NewClassMethod(PyTypeObject *type, PyMethodDef *method) .. versionadded:: 2.3 -.. c:function:: int PyDescr_IsData(PyObject *descr) +.. cfunction:: int PyDescr_IsData(PyObject *descr) Return true if the descriptor objects *descr* describes a data attribute, or false if it describes a method. *descr* must be a descriptor object; there is @@ -50,6 +50,6 @@ .. versionadded:: 2.2 -.. c:function:: PyObject* PyWrapper_New(PyObject *, PyObject *) +.. cfunction:: PyObject* PyWrapper_New(PyObject *, PyObject *) .. versionadded:: 2.2 diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/c-api/dict.rst --- a/Doc/c-api/dict.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/c-api/dict.rst Sun Jul 20 10:52:46 2014 -0400 @@ -8,23 +8,23 @@ .. index:: object: dictionary -.. c:type:: PyDictObject +.. ctype:: PyDictObject - This subtype of :c:type:`PyObject` represents a Python dictionary object. + This subtype of :ctype:`PyObject` represents a Python dictionary object. -.. c:var:: PyTypeObject PyDict_Type +.. cvar:: PyTypeObject PyDict_Type .. index:: single: DictType (in module types) single: DictionaryType (in module types) - This instance of :c:type:`PyTypeObject` represents the Python dictionary + This instance of :ctype:`PyTypeObject` represents the Python dictionary type. This is exposed to Python programs as ``dict`` and ``types.DictType``. -.. c:function:: int PyDict_Check(PyObject *p) +.. cfunction:: int PyDict_Check(PyObject *p) Return true if *p* is a dict object or an instance of a subtype of the dict type. @@ -33,7 +33,7 @@ Allowed subtypes to be accepted. -.. c:function:: int PyDict_CheckExact(PyObject *p) +.. cfunction:: int PyDict_CheckExact(PyObject *p) Return true if *p* is a dict object, but not an instance of a subtype of the dict type. @@ -41,12 +41,12 @@ .. versionadded:: 2.4 -.. c:function:: PyObject* PyDict_New() +.. cfunction:: PyObject* PyDict_New() Return a new empty dictionary, or *NULL* on failure. -.. c:function:: PyObject* PyDictProxy_New(PyObject *dict) +.. cfunction:: PyObject* PyDictProxy_New(PyObject *dict) Return a proxy object for a mapping which enforces read-only behavior. This is normally used to create a proxy to prevent modification of the @@ -55,12 +55,12 @@ .. versionadded:: 2.2 -.. c:function:: void PyDict_Clear(PyObject *p) +.. cfunction:: void PyDict_Clear(PyObject *p) Empty an existing dictionary of all key-value pairs. -.. c:function:: int PyDict_Contains(PyObject *p, PyObject *key) +.. cfunction:: int PyDict_Contains(PyObject *p, PyObject *key) Determine if dictionary *p* contains *key*. If an item in *p* is matches *key*, return ``1``, otherwise return ``0``. On error, return ``-1``. @@ -69,74 +69,74 @@ .. versionadded:: 2.4 -.. c:function:: PyObject* PyDict_Copy(PyObject *p) +.. cfunction:: PyObject* PyDict_Copy(PyObject *p) Return a new dictionary that contains the same key-value pairs as *p*. .. versionadded:: 1.6 -.. c:function:: int PyDict_SetItem(PyObject *p, PyObject *key, PyObject *val) +.. cfunction:: int PyDict_SetItem(PyObject *p, PyObject *key, PyObject *val) Insert *value* into the dictionary *p* with a key of *key*. *key* must be :term:`hashable`; if it isn't, :exc:`TypeError` will be raised. Return ``0`` on success or ``-1`` on failure. -.. c:function:: int PyDict_SetItemString(PyObject *p, const char *key, PyObject *val) +.. cfunction:: int PyDict_SetItemString(PyObject *p, const char *key, PyObject *val) .. index:: single: PyString_FromString() Insert *value* into the dictionary *p* using *key* as a key. *key* should - be a :c:type:`char\*`. The key object is created using + be a :ctype:`char\*`. The key object is created using ``PyString_FromString(key)``. Return ``0`` on success or ``-1`` on failure. -.. c:function:: int PyDict_DelItem(PyObject *p, PyObject *key) +.. cfunction:: int PyDict_DelItem(PyObject *p, PyObject *key) Remove the entry in dictionary *p* with key *key*. *key* must be hashable; if it isn't, :exc:`TypeError` is raised. Return ``0`` on success or ``-1`` on failure. -.. c:function:: int PyDict_DelItemString(PyObject *p, char *key) +.. cfunction:: int PyDict_DelItemString(PyObject *p, char *key) Remove the entry in dictionary *p* which has a key specified by the string *key*. Return ``0`` on success or ``-1`` on failure. -.. c:function:: PyObject* PyDict_GetItem(PyObject *p, PyObject *key) +.. cfunction:: PyObject* PyDict_GetItem(PyObject *p, PyObject *key) Return the object from dictionary *p* which has a key *key*. Return *NULL* if the key *key* is not present, but *without* setting an exception. -.. c:function:: PyObject* PyDict_GetItemString(PyObject *p, const char *key) +.. cfunction:: PyObject* PyDict_GetItemString(PyObject *p, const char *key) - This is the same as :c:func:`PyDict_GetItem`, but *key* is specified as a - :c:type:`char\*`, rather than a :c:type:`PyObject\*`. + This is the same as :cfunc:`PyDict_GetItem`, but *key* is specified as a + :ctype:`char\*`, rather than a :ctype:`PyObject\*`. -.. c:function:: PyObject* PyDict_Items(PyObject *p) +.. cfunction:: PyObject* PyDict_Items(PyObject *p) - Return a :c:type:`PyListObject` containing all the items from the + Return a :ctype:`PyListObject` containing all the items from the dictionary, as in the dictionary method :meth:`dict.items`. -.. c:function:: PyObject* PyDict_Keys(PyObject *p) +.. cfunction:: PyObject* PyDict_Keys(PyObject *p) - Return a :c:type:`PyListObject` containing all the keys from the dictionary, + Return a :ctype:`PyListObject` containing all the keys from the dictionary, as in the dictionary method :meth:`dict.keys`. -.. c:function:: PyObject* PyDict_Values(PyObject *p) +.. cfunction:: PyObject* PyDict_Values(PyObject *p) - Return a :c:type:`PyListObject` containing all the values from the + Return a :ctype:`PyListObject` containing all the values from the dictionary *p*, as in the dictionary method :meth:`dict.values`. -.. c:function:: Py_ssize_t PyDict_Size(PyObject *p) +.. cfunction:: Py_ssize_t PyDict_Size(PyObject *p) .. index:: builtin: len @@ -144,18 +144,18 @@ ``len(p)`` on a dictionary. .. versionchanged:: 2.5 - This function returned an :c:type:`int` type. This might require changes + This function returned an :ctype:`int` type. This might require changes in your code for properly supporting 64-bit systems. -.. c:function:: int PyDict_Next(PyObject *p, Py_ssize_t *ppos, PyObject **pkey, PyObject **pvalue) +.. cfunction:: int PyDict_Next(PyObject *p, Py_ssize_t *ppos, PyObject **pkey, PyObject **pvalue) Iterate over all key-value pairs in the dictionary *p*. The - :c:type:`Py_ssize_t` referred to by *ppos* must be initialized to ``0`` + :ctype:`Py_ssize_t` referred to by *ppos* must be initialized to ``0`` prior to the first call to this function to start the iteration; the function returns true for each pair in the dictionary, and false once all pairs have been reported. The parameters *pkey* and *pvalue* should either - point to :c:type:`PyObject\*` variables that will be filled in with each key + point to :ctype:`PyObject\*` variables that will be filled in with each key and value, respectively, or may be *NULL*. Any references returned through them are borrowed. *ppos* should not be altered during iteration. Its value represents offsets within the internal dictionary structure, and @@ -192,15 +192,15 @@ } .. versionchanged:: 2.5 - This function used an :c:type:`int *` type for *ppos*. This might require + This function used an :ctype:`int *` type for *ppos*. This might require changes in your code for properly supporting 64-bit systems. -.. c:function:: int PyDict_Merge(PyObject *a, PyObject *b, int override) +.. cfunction:: int PyDict_Merge(PyObject *a, PyObject *b, int override) Iterate over mapping object *b* adding key-value pairs to dictionary *a*. - *b* may be a dictionary, or any object supporting :c:func:`PyMapping_Keys` - and :c:func:`PyObject_GetItem`. If *override* is true, existing pairs in *a* + *b* may be a dictionary, or any object supporting :cfunc:`PyMapping_Keys` + and :cfunc:`PyObject_GetItem`. If *override* is true, existing pairs in *a* will be replaced if a matching key is found in *b*, otherwise pairs will only be added if there is not a matching key in *a*. Return ``0`` on success or ``-1`` if an exception was raised. @@ -208,18 +208,15 @@ .. versionadded:: 2.2 -.. c:function:: int PyDict_Update(PyObject *a, PyObject *b) +.. cfunction:: int PyDict_Update(PyObject *a, PyObject *b) - This is the same as ``PyDict_Merge(a, b, 1)`` in C, and is similar to - ``a.update(b)`` in Python except that :c:func:`PyDict_Update` doesn't fall - back to the iterating over a sequence of key value pairs if the second - argument has no "keys" attribute. Return ``0`` on success or ``-1`` if an - exception was raised. + This is the same as ``PyDict_Merge(a, b, 1)`` in C, or ``a.update(b)`` in + Python. Return ``0`` on success or ``-1`` if an exception was raised. .. versionadded:: 2.2 -.. c:function:: int PyDict_MergeFromSeq2(PyObject *a, PyObject *seq2, int override) +.. cfunction:: int PyDict_MergeFromSeq2(PyObject *a, PyObject *seq2, int override) Update or merge into dictionary *a*, from the key-value pairs in *seq2*. *seq2* must be an iterable object producing iterable objects of length 2, diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/c-api/exceptions.rst --- a/Doc/c-api/exceptions.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/c-api/exceptions.rst Sun Jul 20 10:52:46 2014 -0400 @@ -9,12 +9,12 @@ The functions described in this chapter will let you handle and raise Python exceptions. It is important to understand some of the basics of Python -exception handling. It works somewhat like the Unix :c:data:`errno` variable: +exception handling. It works somewhat like the Unix :cdata:`errno` variable: there is a global indicator (per thread) of the last error that occurred. Most functions don't clear this on success, but will set it to indicate the cause of the error on failure. Most functions also return an error indicator, usually *NULL* if they are supposed to return a pointer, or ``-1`` if they return an -integer (exception: the :c:func:`PyArg_\*` functions return ``1`` for success and +integer (exception: the :cfunc:`PyArg_\*` functions return ``1`` for success and ``0`` for failure). When a function must fail because some function it called failed, it generally @@ -41,7 +41,7 @@ Either alphabetical or some kind of structure. -.. c:function:: void PyErr_PrintEx(int set_sys_last_vars) +.. cfunction:: void PyErr_PrintEx(int set_sys_last_vars) Print a standard traceback to ``sys.stderr`` and clear the error indicator. Call this function only when the error indicator is set. (Otherwise it will @@ -52,35 +52,35 @@ type, value and traceback of the printed exception, respectively. -.. c:function:: void PyErr_Print() +.. cfunction:: void PyErr_Print() Alias for ``PyErr_PrintEx(1)``. -.. c:function:: PyObject* PyErr_Occurred() +.. cfunction:: PyObject* PyErr_Occurred() Test whether the error indicator is set. If set, return the exception *type* - (the first argument to the last call to one of the :c:func:`PyErr_Set\*` - functions or to :c:func:`PyErr_Restore`). If not set, return *NULL*. You do not - own a reference to the return value, so you do not need to :c:func:`Py_DECREF` + (the first argument to the last call to one of the :cfunc:`PyErr_Set\*` + functions or to :cfunc:`PyErr_Restore`). If not set, return *NULL*. You do not + own a reference to the return value, so you do not need to :cfunc:`Py_DECREF` it. .. note:: Do not compare the return value to a specific exception; use - :c:func:`PyErr_ExceptionMatches` instead, shown below. (The comparison could + :cfunc:`PyErr_ExceptionMatches` instead, shown below. (The comparison could easily fail since the exception may be an instance instead of a class, in the case of a class exception, or it may the a subclass of the expected exception.) -.. c:function:: int PyErr_ExceptionMatches(PyObject *exc) +.. cfunction:: int PyErr_ExceptionMatches(PyObject *exc) Equivalent to ``PyErr_GivenExceptionMatches(PyErr_Occurred(), exc)``. This should only be called when an exception is actually set; a memory access violation will occur if no exception has been raised. -.. c:function:: int PyErr_GivenExceptionMatches(PyObject *given, PyObject *exc) +.. cfunction:: int PyErr_GivenExceptionMatches(PyObject *given, PyObject *exc) Return true if the *given* exception matches the exception in *exc*. If *exc* is a class object, this also returns true when *given* is an instance @@ -88,22 +88,22 @@ recursively in subtuples) are searched for a match. -.. c:function:: void PyErr_NormalizeException(PyObject**exc, PyObject**val, PyObject**tb) +.. cfunction:: void PyErr_NormalizeException(PyObject**exc, PyObject**val, PyObject**tb) - Under certain circumstances, the values returned by :c:func:`PyErr_Fetch` below + Under certain circumstances, the values returned by :cfunc:`PyErr_Fetch` below can be "unnormalized", meaning that ``*exc`` is a class object but ``*val`` is not an instance of the same class. This function can be used to instantiate the class in that case. If the values are already normalized, nothing happens. The delayed normalization is implemented to improve performance. -.. c:function:: void PyErr_Clear() +.. cfunction:: void PyErr_Clear() Clear the error indicator. If the error indicator is not set, there is no effect. -.. c:function:: void PyErr_Fetch(PyObject **ptype, PyObject **pvalue, PyObject **ptraceback) +.. cfunction:: void PyErr_Fetch(PyObject **ptype, PyObject **pvalue, PyObject **ptraceback) Retrieve the error indicator into three variables whose addresses are passed. If the error indicator is not set, set all three variables to *NULL*. If it is @@ -116,7 +116,7 @@ by code that needs to save and restore the error indicator temporarily. -.. c:function:: void PyErr_Restore(PyObject *type, PyObject *value, PyObject *traceback) +.. cfunction:: void PyErr_Restore(PyObject *type, PyObject *value, PyObject *traceback) Set the error indicator from the three objects. If the error indicator is already set, it is cleared first. If the objects are *NULL*, the error @@ -131,133 +131,111 @@ .. note:: This function is normally only used by code that needs to save and restore the - error indicator temporarily; use :c:func:`PyErr_Fetch` to save the current + error indicator temporarily; use :cfunc:`PyErr_Fetch` to save the current exception state. -.. c:function:: void PyErr_SetString(PyObject *type, const char *message) +.. cfunction:: void PyErr_SetString(PyObject *type, const char *message) This is the most common way to set the error indicator. The first argument specifies the exception type; it is normally one of the standard exceptions, - e.g. :c:data:`PyExc_RuntimeError`. You need not increment its reference count. + e.g. :cdata:`PyExc_RuntimeError`. You need not increment its reference count. The second argument is an error message; it is converted to a string object. -.. c:function:: void PyErr_SetObject(PyObject *type, PyObject *value) +.. cfunction:: void PyErr_SetObject(PyObject *type, PyObject *value) - This function is similar to :c:func:`PyErr_SetString` but lets you specify an + This function is similar to :cfunc:`PyErr_SetString` but lets you specify an arbitrary Python object for the "value" of the exception. -.. c:function:: PyObject* PyErr_Format(PyObject *exception, const char *format, ...) +.. cfunction:: PyObject* PyErr_Format(PyObject *exception, const char *format, ...) This function sets the error indicator and returns *NULL*. *exception* should be a Python exception class. The *format* and subsequent parameters help format the error message; they have the same meaning and - values as in :c:func:`PyString_FromFormat`. + values as in :cfunc:`PyString_FromFormat`. -.. c:function:: void PyErr_SetNone(PyObject *type) +.. cfunction:: void PyErr_SetNone(PyObject *type) This is a shorthand for ``PyErr_SetObject(type, Py_None)``. -.. c:function:: int PyErr_BadArgument() +.. cfunction:: int PyErr_BadArgument() This is a shorthand for ``PyErr_SetString(PyExc_TypeError, message)``, where *message* indicates that a built-in operation was invoked with an illegal argument. It is mostly for internal use. -.. c:function:: PyObject* PyErr_NoMemory() +.. cfunction:: PyObject* PyErr_NoMemory() This is a shorthand for ``PyErr_SetNone(PyExc_MemoryError)``; it returns *NULL* so an object allocation function can write ``return PyErr_NoMemory();`` when it runs out of memory. -.. c:function:: PyObject* PyErr_SetFromErrno(PyObject *type) +.. cfunction:: PyObject* PyErr_SetFromErrno(PyObject *type) .. index:: single: strerror() This is a convenience function to raise an exception when a C library function - has returned an error and set the C variable :c:data:`errno`. It constructs a - tuple object whose first item is the integer :c:data:`errno` value and whose - second item is the corresponding error message (gotten from :c:func:`strerror`), + has returned an error and set the C variable :cdata:`errno`. It constructs a + tuple object whose first item is the integer :cdata:`errno` value and whose + second item is the corresponding error message (gotten from :cfunc:`strerror`), and then calls ``PyErr_SetObject(type, object)``. On Unix, when the - :c:data:`errno` value is :const:`EINTR`, indicating an interrupted system call, - this calls :c:func:`PyErr_CheckSignals`, and if that set the error indicator, + :cdata:`errno` value is :const:`EINTR`, indicating an interrupted system call, + this calls :cfunc:`PyErr_CheckSignals`, and if that set the error indicator, leaves it set to that. The function always returns *NULL*, so a wrapper function around a system call can write ``return PyErr_SetFromErrno(type);`` when the system call returns an error. -.. c:function:: PyObject* PyErr_SetFromErrnoWithFilenameObject(PyObject *type, PyObject *filenameObject) +.. cfunction:: PyObject* PyErr_SetFromErrnoWithFilename(PyObject *type, const char *filename) - Similar to :c:func:`PyErr_SetFromErrno`, with the additional behavior that if - *filenameObject* is not *NULL*, it is passed to the constructor of *type* as - a third parameter. In the case of exceptions such as :exc:`IOError` and - :exc:`OSError`, this is used to define the :attr:`filename` attribute of the - exception instance. + Similar to :cfunc:`PyErr_SetFromErrno`, with the additional behavior that if + *filename* is not *NULL*, it is passed to the constructor of *type* as a third + parameter. In the case of exceptions such as :exc:`IOError` and :exc:`OSError`, + this is used to define the :attr:`filename` attribute of the exception instance. -.. c:function:: PyObject* PyErr_SetFromErrnoWithFilename(PyObject *type, const char *filename) - - Similar to :c:func:`PyErr_SetFromErrnoWithFilenameObject`, but the filename - is given as a C string. - - -.. c:function:: PyObject* PyErr_SetFromWindowsErr(int ierr) +.. cfunction:: PyObject* PyErr_SetFromWindowsErr(int ierr) This is a convenience function to raise :exc:`WindowsError`. If called with - *ierr* of :c:data:`0`, the error code returned by a call to :c:func:`GetLastError` - is used instead. It calls the Win32 function :c:func:`FormatMessage` to retrieve - the Windows description of error code given by *ierr* or :c:func:`GetLastError`, + *ierr* of :cdata:`0`, the error code returned by a call to :cfunc:`GetLastError` + is used instead. It calls the Win32 function :cfunc:`FormatMessage` to retrieve + the Windows description of error code given by *ierr* or :cfunc:`GetLastError`, then it constructs a tuple object whose first item is the *ierr* value and whose second item is the corresponding error message (gotten from - :c:func:`FormatMessage`), and then calls ``PyErr_SetObject(PyExc_WindowsError, + :cfunc:`FormatMessage`), and then calls ``PyErr_SetObject(PyExc_WindowsError, object)``. This function always returns *NULL*. Availability: Windows. -.. c:function:: PyObject* PyErr_SetExcFromWindowsErr(PyObject *type, int ierr) +.. cfunction:: PyObject* PyErr_SetExcFromWindowsErr(PyObject *type, int ierr) - Similar to :c:func:`PyErr_SetFromWindowsErr`, with an additional parameter + Similar to :cfunc:`PyErr_SetFromWindowsErr`, with an additional parameter specifying the exception type to be raised. Availability: Windows. .. versionadded:: 2.3 -.. c:function:: PyObject* PyErr_SetFromWindowsErrWithFilenameObject(int ierr, PyObject *filenameObject) +.. cfunction:: PyObject* PyErr_SetFromWindowsErrWithFilename(int ierr, const char *filename) - Similar to :c:func:`PyErr_SetFromWindowsErr`, with the additional behavior that - if *filenameObject* is not *NULL*, it is passed to the constructor of + Similar to :cfunc:`PyErr_SetFromWindowsErr`, with the additional behavior that + if *filename* is not *NULL*, it is passed to the constructor of :exc:`WindowsError` as a third parameter. Availability: Windows. -.. c:function:: PyObject* PyErr_SetFromWindowsErrWithFilename(int ierr, const char *filename) +.. cfunction:: PyObject* PyErr_SetExcFromWindowsErrWithFilename(PyObject *type, int ierr, char *filename) - Similar to :c:func:`PyErr_SetFromWindowsErrWithFilenameObject`, but the - filename is given as a C string. Availability: Windows. - - -.. c:function:: PyObject* PyErr_SetExcFromWindowsErrWithFilenameObject(PyObject *type, int ierr, PyObject *filename) - - Similar to :c:func:`PyErr_SetFromWindowsErrWithFilenameObject`, with an - additional parameter specifying the exception type to be raised. - Availability: Windows. - - .. versionadded:: 2.3 - - -.. c:function:: PyObject* PyErr_SetExcFromWindowsErrWithFilename(PyObject *type, int ierr, const char *filename) - - Similar to :c:func:`PyErr_SetFromWindowsErrWithFilename`, with an additional + Similar to :cfunc:`PyErr_SetFromWindowsErrWithFilename`, with an additional parameter specifying the exception type to be raised. Availability: Windows. .. versionadded:: 2.3 -.. c:function:: void PyErr_BadInternalCall() +.. cfunction:: void PyErr_BadInternalCall() This is a shorthand for ``PyErr_SetString(PyExc_SystemError, message)``, where *message* indicates that an internal operation (e.g. a Python/C API @@ -265,13 +243,13 @@ use. -.. c:function:: int PyErr_WarnEx(PyObject *category, char *message, int stacklevel) +.. cfunction:: int PyErr_WarnEx(PyObject *category, char *message, int stacklevel) Issue a warning message. The *category* argument is a warning category (see below) or *NULL*; the *message* argument is a message string. *stacklevel* is a positive number giving a number of stack frames; the warning will be issued from the currently executing line of code in that stack frame. A *stacklevel* of 1 - is the function calling :c:func:`PyErr_WarnEx`, 2 is the function above that, + is the function calling :cfunc:`PyErr_WarnEx`, 2 is the function above that, and so forth. This function normally prints a warning message to *sys.stderr*; however, it is @@ -283,36 +261,36 @@ is raised. (It is not possible to determine whether a warning message is actually printed, nor what the reason is for the exception; this is intentional.) If an exception is raised, the caller should do its normal - exception handling (for example, :c:func:`Py_DECREF` owned references and return + exception handling (for example, :cfunc:`Py_DECREF` owned references and return an error value). - Warning categories must be subclasses of :c:data:`Warning`; the default warning - category is :c:data:`RuntimeWarning`. The standard Python warning categories are + Warning categories must be subclasses of :cdata:`Warning`; the default warning + category is :cdata:`RuntimeWarning`. The standard Python warning categories are available as global variables whose names are ``PyExc_`` followed by the Python - exception name. These have the type :c:type:`PyObject\*`; they are all class - objects. Their names are :c:data:`PyExc_Warning`, :c:data:`PyExc_UserWarning`, - :c:data:`PyExc_UnicodeWarning`, :c:data:`PyExc_DeprecationWarning`, - :c:data:`PyExc_SyntaxWarning`, :c:data:`PyExc_RuntimeWarning`, and - :c:data:`PyExc_FutureWarning`. :c:data:`PyExc_Warning` is a subclass of - :c:data:`PyExc_Exception`; the other warning categories are subclasses of - :c:data:`PyExc_Warning`. + exception name. These have the type :ctype:`PyObject\*`; they are all class + objects. Their names are :cdata:`PyExc_Warning`, :cdata:`PyExc_UserWarning`, + :cdata:`PyExc_UnicodeWarning`, :cdata:`PyExc_DeprecationWarning`, + :cdata:`PyExc_SyntaxWarning`, :cdata:`PyExc_RuntimeWarning`, and + :cdata:`PyExc_FutureWarning`. :cdata:`PyExc_Warning` is a subclass of + :cdata:`PyExc_Exception`; the other warning categories are subclasses of + :cdata:`PyExc_Warning`. For information about warning control, see the documentation for the :mod:`warnings` module and the :option:`-W` option in the command line documentation. There is no C API for warning control. -.. c:function:: int PyErr_Warn(PyObject *category, char *message) +.. cfunction:: int PyErr_Warn(PyObject *category, char *message) Issue a warning message. The *category* argument is a warning category (see below) or *NULL*; the *message* argument is a message string. The warning will - appear to be issued from the function calling :c:func:`PyErr_Warn`, equivalent to - calling :c:func:`PyErr_WarnEx` with a *stacklevel* of 1. + appear to be issued from the function calling :cfunc:`PyErr_Warn`, equivalent to + calling :cfunc:`PyErr_WarnEx` with a *stacklevel* of 1. - Deprecated; use :c:func:`PyErr_WarnEx` instead. + Deprecated; use :cfunc:`PyErr_WarnEx` instead. -.. c:function:: int PyErr_WarnExplicit(PyObject *category, const char *message, const char *filename, int lineno, const char *module, PyObject *registry) +.. cfunction:: int PyErr_WarnExplicit(PyObject *category, const char *message, const char *filename, int lineno, const char *module, PyObject *registry) Issue a warning message with explicit control over all warning attributes. This is a straightforward wrapper around the Python function @@ -321,15 +299,15 @@ described there. -.. c:function:: int PyErr_WarnPy3k(char *message, int stacklevel) +.. cfunction:: int PyErr_WarnPy3k(char *message, int stacklevel) Issue a :exc:`DeprecationWarning` with the given *message* and *stacklevel* - if the :c:data:`Py_Py3kWarningFlag` flag is enabled. + if the :cdata:`Py_Py3kWarningFlag` flag is enabled. .. versionadded:: 2.6 -.. c:function:: int PyErr_CheckSignals() +.. cfunction:: int PyErr_CheckSignals() .. index:: module: signal @@ -346,21 +324,21 @@ cleared if it was previously set. -.. c:function:: void PyErr_SetInterrupt() +.. cfunction:: void PyErr_SetInterrupt() .. index:: single: SIGINT single: KeyboardInterrupt (built-in exception) This function simulates the effect of a :const:`SIGINT` signal arriving --- the - next time :c:func:`PyErr_CheckSignals` is called, :exc:`KeyboardInterrupt` will + next time :cfunc:`PyErr_CheckSignals` is called, :exc:`KeyboardInterrupt` will be raised. It may be called without holding the interpreter lock. .. % XXX This was described as obsolete, but is used in .. % thread.interrupt_main() (used from IDLE), so it's still needed. -.. c:function:: int PySignal_SetWakeupFd(int fd) +.. cfunction:: int PySignal_SetWakeupFd(int fd) This utility function specifies a file descriptor to which a ``'\0'`` byte will be written whenever a signal is received. It returns the previous such file @@ -372,13 +350,13 @@ .. versionadded:: 2.6 -.. c:function:: PyObject* PyErr_NewException(char *name, PyObject *base, PyObject *dict) +.. cfunction:: PyObject* PyErr_NewException(char *name, PyObject *base, PyObject *dict) This utility function creates and returns a new exception class. The *name* argument must be the name of the new exception, a C string of the form ``module.classname``. The *base* and *dict* arguments are normally *NULL*. This creates a class object derived from :exc:`Exception` (accessible in C as - :c:data:`PyExc_Exception`). + :cdata:`PyExc_Exception`). The :attr:`__module__` attribute of the new class is set to the first part (up to the last dot) of the *name* argument, and the class name is set to the last @@ -387,16 +365,16 @@ argument can be used to specify a dictionary of class variables and methods. -.. c:function:: PyObject* PyErr_NewExceptionWithDoc(char *name, char *doc, PyObject *base, PyObject *dict) +.. cfunction:: PyObject* PyErr_NewExceptionWithDoc(char *name, char *doc, PyObject *base, PyObject *dict) - Same as :c:func:`PyErr_NewException`, except that the new exception class can + Same as :cfunc:`PyErr_NewException`, except that the new exception class can easily be given a docstring: If *doc* is non-*NULL*, it will be used as the docstring for the exception class. .. versionadded:: 2.7 -.. c:function:: void PyErr_WriteUnraisable(PyObject *obj) +.. cfunction:: void PyErr_WriteUnraisable(PyObject *obj) This utility function prints a warning message to ``sys.stderr`` when an exception has been set but it is impossible for the interpreter to actually @@ -415,33 +393,33 @@ The following functions are used to create and modify Unicode exceptions from C. -.. c:function:: PyObject* PyUnicodeDecodeError_Create(const char *encoding, const char *object, Py_ssize_t length, Py_ssize_t start, Py_ssize_t end, const char *reason) +.. cfunction:: PyObject* PyUnicodeDecodeError_Create(const char *encoding, const char *object, Py_ssize_t length, Py_ssize_t start, Py_ssize_t end, const char *reason) Create a :class:`UnicodeDecodeError` object with the attributes *encoding*, *object*, *length*, *start*, *end* and *reason*. -.. c:function:: PyObject* PyUnicodeEncodeError_Create(const char *encoding, const Py_UNICODE *object, Py_ssize_t length, Py_ssize_t start, Py_ssize_t end, const char *reason) +.. cfunction:: PyObject* PyUnicodeEncodeError_Create(const char *encoding, const Py_UNICODE *object, Py_ssize_t length, Py_ssize_t start, Py_ssize_t end, const char *reason) Create a :class:`UnicodeEncodeError` object with the attributes *encoding*, *object*, *length*, *start*, *end* and *reason*. -.. c:function:: PyObject* PyUnicodeTranslateError_Create(const Py_UNICODE *object, Py_ssize_t length, Py_ssize_t start, Py_ssize_t end, const char *reason) +.. cfunction:: PyObject* PyUnicodeTranslateError_Create(const Py_UNICODE *object, Py_ssize_t length, Py_ssize_t start, Py_ssize_t end, const char *reason) Create a :class:`UnicodeTranslateError` object with the attributes *object*, *length*, *start*, *end* and *reason*. -.. c:function:: PyObject* PyUnicodeDecodeError_GetEncoding(PyObject *exc) +.. cfunction:: PyObject* PyUnicodeDecodeError_GetEncoding(PyObject *exc) PyObject* PyUnicodeEncodeError_GetEncoding(PyObject *exc) Return the *encoding* attribute of the given exception object. -.. c:function:: PyObject* PyUnicodeDecodeError_GetObject(PyObject *exc) +.. cfunction:: PyObject* PyUnicodeDecodeError_GetObject(PyObject *exc) PyObject* PyUnicodeEncodeError_GetObject(PyObject *exc) PyObject* PyUnicodeTranslateError_GetObject(PyObject *exc) Return the *object* attribute of the given exception object. -.. c:function:: int PyUnicodeDecodeError_GetStart(PyObject *exc, Py_ssize_t *start) +.. cfunction:: int PyUnicodeDecodeError_GetStart(PyObject *exc, Py_ssize_t *start) int PyUnicodeEncodeError_GetStart(PyObject *exc, Py_ssize_t *start) int PyUnicodeTranslateError_GetStart(PyObject *exc, Py_ssize_t *start) @@ -449,14 +427,14 @@ *\*start*. *start* must not be *NULL*. Return ``0`` on success, ``-1`` on failure. -.. c:function:: int PyUnicodeDecodeError_SetStart(PyObject *exc, Py_ssize_t start) +.. cfunction:: int PyUnicodeDecodeError_SetStart(PyObject *exc, Py_ssize_t start) int PyUnicodeEncodeError_SetStart(PyObject *exc, Py_ssize_t start) int PyUnicodeTranslateError_SetStart(PyObject *exc, Py_ssize_t start) Set the *start* attribute of the given exception object to *start*. Return ``0`` on success, ``-1`` on failure. -.. c:function:: int PyUnicodeDecodeError_GetEnd(PyObject *exc, Py_ssize_t *end) +.. cfunction:: int PyUnicodeDecodeError_GetEnd(PyObject *exc, Py_ssize_t *end) int PyUnicodeEncodeError_GetEnd(PyObject *exc, Py_ssize_t *end) int PyUnicodeTranslateError_GetEnd(PyObject *exc, Py_ssize_t *end) @@ -464,20 +442,20 @@ *\*end*. *end* must not be *NULL*. Return ``0`` on success, ``-1`` on failure. -.. c:function:: int PyUnicodeDecodeError_SetEnd(PyObject *exc, Py_ssize_t end) +.. cfunction:: int PyUnicodeDecodeError_SetEnd(PyObject *exc, Py_ssize_t end) int PyUnicodeEncodeError_SetEnd(PyObject *exc, Py_ssize_t end) int PyUnicodeTranslateError_SetEnd(PyObject *exc, Py_ssize_t end) Set the *end* attribute of the given exception object to *end*. Return ``0`` on success, ``-1`` on failure. -.. c:function:: PyObject* PyUnicodeDecodeError_GetReason(PyObject *exc) +.. cfunction:: PyObject* PyUnicodeDecodeError_GetReason(PyObject *exc) PyObject* PyUnicodeEncodeError_GetReason(PyObject *exc) PyObject* PyUnicodeTranslateError_GetReason(PyObject *exc) Return the *reason* attribute of the given exception object. -.. c:function:: int PyUnicodeDecodeError_SetReason(PyObject *exc, const char *reason) +.. cfunction:: int PyUnicodeDecodeError_SetReason(PyObject *exc, const char *reason) int PyUnicodeEncodeError_SetReason(PyObject *exc, const char *reason) int PyUnicodeTranslateError_SetReason(PyObject *exc, const char *reason) @@ -493,12 +471,12 @@ recursive code does not necessarily invoke Python code (which tracks its recursion depth automatically). -.. c:function:: int Py_EnterRecursiveCall(char *where) +.. cfunction:: int Py_EnterRecursiveCall(char *where) Marks a point where a recursive C-level call is about to be performed. If :const:`USE_STACKCHECK` is defined, this function checks if the OS - stack overflowed using :c:func:`PyOS_CheckStack`. In this is the case, it + stack overflowed using :cfunc:`PyOS_CheckStack`. In this is the case, it sets a :exc:`MemoryError` and returns a nonzero value. The function then checks if the recursion limit is reached. If this is the @@ -509,10 +487,10 @@ concatenated to the :exc:`RuntimeError` message caused by the recursion depth limit. -.. c:function:: void Py_LeaveRecursiveCall() +.. cfunction:: void Py_LeaveRecursiveCall() - Ends a :c:func:`Py_EnterRecursiveCall`. Must be called once for each - *successful* invocation of :c:func:`Py_EnterRecursiveCall`. + Ends a :cfunc:`Py_EnterRecursiveCall`. Must be called once for each + *successful* invocation of :cfunc:`Py_EnterRecursiveCall`. .. _standardexceptions: @@ -522,70 +500,70 @@ All standard Python exceptions are available as global variables whose names are ``PyExc_`` followed by the Python exception name. These have the type -:c:type:`PyObject\*`; they are all class objects. For completeness, here are all +:ctype:`PyObject\*`; they are all class objects. For completeness, here are all the variables: -+-------------------------------------+----------------------------+----------+ -| C Name | Python Name | Notes | -+=====================================+============================+==========+ -| :c:data:`PyExc_BaseException` | :exc:`BaseException` | (1), (4) | -+-------------------------------------+----------------------------+----------+ -| :c:data:`PyExc_Exception` | :exc:`Exception` | \(1) | -+-------------------------------------+----------------------------+----------+ -| :c:data:`PyExc_StandardError` | :exc:`StandardError` | \(1) | -+-------------------------------------+----------------------------+----------+ -| :c:data:`PyExc_ArithmeticError` | :exc:`ArithmeticError` | \(1) | -+-------------------------------------+----------------------------+----------+ -| :c:data:`PyExc_LookupError` | :exc:`LookupError` | \(1) | -+-------------------------------------+----------------------------+----------+ -| :c:data:`PyExc_AssertionError` | :exc:`AssertionError` | | -+-------------------------------------+----------------------------+----------+ -| :c:data:`PyExc_AttributeError` | :exc:`AttributeError` | | -+-------------------------------------+----------------------------+----------+ -| :c:data:`PyExc_EOFError` | :exc:`EOFError` | | -+-------------------------------------+----------------------------+----------+ -| :c:data:`PyExc_EnvironmentError` | :exc:`EnvironmentError` | \(1) | -+-------------------------------------+----------------------------+----------+ -| :c:data:`PyExc_FloatingPointError` | :exc:`FloatingPointError` | | -+-------------------------------------+----------------------------+----------+ -| :c:data:`PyExc_IOError` | :exc:`IOError` | | -+-------------------------------------+----------------------------+----------+ -| :c:data:`PyExc_ImportError` | :exc:`ImportError` | | -+-------------------------------------+----------------------------+----------+ -| :c:data:`PyExc_IndexError` | :exc:`IndexError` | | -+-------------------------------------+----------------------------+----------+ -| :c:data:`PyExc_KeyError` | :exc:`KeyError` | | -+-------------------------------------+----------------------------+----------+ -| :c:data:`PyExc_KeyboardInterrupt` | :exc:`KeyboardInterrupt` | | -+-------------------------------------+----------------------------+----------+ -| :c:data:`PyExc_MemoryError` | :exc:`MemoryError` | | -+-------------------------------------+----------------------------+----------+ -| :c:data:`PyExc_NameError` | :exc:`NameError` | | -+-------------------------------------+----------------------------+----------+ -| :c:data:`PyExc_NotImplementedError` | :exc:`NotImplementedError` | | -+-------------------------------------+----------------------------+----------+ -| :c:data:`PyExc_OSError` | :exc:`OSError` | | -+-------------------------------------+----------------------------+----------+ -| :c:data:`PyExc_OverflowError` | :exc:`OverflowError` | | -+-------------------------------------+----------------------------+----------+ -| :c:data:`PyExc_ReferenceError` | :exc:`ReferenceError` | \(2) | -+-------------------------------------+----------------------------+----------+ -| :c:data:`PyExc_RuntimeError` | :exc:`RuntimeError` | | -+-------------------------------------+----------------------------+----------+ -| :c:data:`PyExc_SyntaxError` | :exc:`SyntaxError` | | -+-------------------------------------+----------------------------+----------+ -| :c:data:`PyExc_SystemError` | :exc:`SystemError` | | -+-------------------------------------+----------------------------+----------+ -| :c:data:`PyExc_SystemExit` | :exc:`SystemExit` | | -+-------------------------------------+----------------------------+----------+ -| :c:data:`PyExc_TypeError` | :exc:`TypeError` | | -+-------------------------------------+----------------------------+----------+ -| :c:data:`PyExc_ValueError` | :exc:`ValueError` | | -+-------------------------------------+----------------------------+----------+ -| :c:data:`PyExc_WindowsError` | :exc:`WindowsError` | \(3) | -+-------------------------------------+----------------------------+----------+ -| :c:data:`PyExc_ZeroDivisionError` | :exc:`ZeroDivisionError` | | -+-------------------------------------+----------------------------+----------+ ++------------------------------------+----------------------------+----------+ +| C Name | Python Name | Notes | ++====================================+============================+==========+ +| :cdata:`PyExc_BaseException` | :exc:`BaseException` | (1), (4) | ++------------------------------------+----------------------------+----------+ +| :cdata:`PyExc_Exception` | :exc:`Exception` | \(1) | ++------------------------------------+----------------------------+----------+ +| :cdata:`PyExc_StandardError` | :exc:`StandardError` | \(1) | ++------------------------------------+----------------------------+----------+ +| :cdata:`PyExc_ArithmeticError` | :exc:`ArithmeticError` | \(1) | ++------------------------------------+----------------------------+----------+ +| :cdata:`PyExc_LookupError` | :exc:`LookupError` | \(1) | ++------------------------------------+----------------------------+----------+ +| :cdata:`PyExc_AssertionError` | :exc:`AssertionError` | | ++------------------------------------+----------------------------+----------+ +| :cdata:`PyExc_AttributeError` | :exc:`AttributeError` | | ++------------------------------------+----------------------------+----------+ +| :cdata:`PyExc_EOFError` | :exc:`EOFError` | | ++------------------------------------+----------------------------+----------+ +| :cdata:`PyExc_EnvironmentError` | :exc:`EnvironmentError` | \(1) | ++------------------------------------+----------------------------+----------+ +| :cdata:`PyExc_FloatingPointError` | :exc:`FloatingPointError` | | ++------------------------------------+----------------------------+----------+ +| :cdata:`PyExc_IOError` | :exc:`IOError` | | ++------------------------------------+----------------------------+----------+ +| :cdata:`PyExc_ImportError` | :exc:`ImportError` | | ++------------------------------------+----------------------------+----------+ +| :cdata:`PyExc_IndexError` | :exc:`IndexError` | | ++------------------------------------+----------------------------+----------+ +| :cdata:`PyExc_KeyError` | :exc:`KeyError` | | ++------------------------------------+----------------------------+----------+ +| :cdata:`PyExc_KeyboardInterrupt` | :exc:`KeyboardInterrupt` | | ++------------------------------------+----------------------------+----------+ +| :cdata:`PyExc_MemoryError` | :exc:`MemoryError` | | ++------------------------------------+----------------------------+----------+ +| :cdata:`PyExc_NameError` | :exc:`NameError` | | ++------------------------------------+----------------------------+----------+ +| :cdata:`PyExc_NotImplementedError` | :exc:`NotImplementedError` | | ++------------------------------------+----------------------------+----------+ +| :cdata:`PyExc_OSError` | :exc:`OSError` | | ++------------------------------------+----------------------------+----------+ +| :cdata:`PyExc_OverflowError` | :exc:`OverflowError` | | ++------------------------------------+----------------------------+----------+ +| :cdata:`PyExc_ReferenceError` | :exc:`ReferenceError` | \(2) | ++------------------------------------+----------------------------+----------+ +| :cdata:`PyExc_RuntimeError` | :exc:`RuntimeError` | | ++------------------------------------+----------------------------+----------+ +| :cdata:`PyExc_SyntaxError` | :exc:`SyntaxError` | | ++------------------------------------+----------------------------+----------+ +| :cdata:`PyExc_SystemError` | :exc:`SystemError` | | ++------------------------------------+----------------------------+----------+ +| :cdata:`PyExc_SystemExit` | :exc:`SystemExit` | | ++------------------------------------+----------------------------+----------+ +| :cdata:`PyExc_TypeError` | :exc:`TypeError` | | ++------------------------------------+----------------------------+----------+ +| :cdata:`PyExc_ValueError` | :exc:`ValueError` | | ++------------------------------------+----------------------------+----------+ +| :cdata:`PyExc_WindowsError` | :exc:`WindowsError` | \(3) | ++------------------------------------+----------------------------+----------+ +| :cdata:`PyExc_ZeroDivisionError` | :exc:`ZeroDivisionError` | | ++------------------------------------+----------------------------+----------+ .. index:: single: PyExc_BaseException diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/c-api/file.rst --- a/Doc/c-api/file.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/c-api/file.rst Sun Jul 20 10:52:46 2014 -0400 @@ -7,79 +7,79 @@ .. index:: object: file -Python's built-in file objects are implemented entirely on the :c:type:`FILE\*` +Python's built-in file objects are implemented entirely on the :ctype:`FILE\*` support from the C standard library. This is an implementation detail and may change in future releases of Python. -.. c:type:: PyFileObject +.. ctype:: PyFileObject - This subtype of :c:type:`PyObject` represents a Python file object. + This subtype of :ctype:`PyObject` represents a Python file object. -.. c:var:: PyTypeObject PyFile_Type +.. cvar:: PyTypeObject PyFile_Type .. index:: single: FileType (in module types) - This instance of :c:type:`PyTypeObject` represents the Python file type. This is + This instance of :ctype:`PyTypeObject` represents the Python file type. This is exposed to Python programs as ``file`` and ``types.FileType``. -.. c:function:: int PyFile_Check(PyObject *p) +.. cfunction:: int PyFile_Check(PyObject *p) - Return true if its argument is a :c:type:`PyFileObject` or a subtype of - :c:type:`PyFileObject`. + Return true if its argument is a :ctype:`PyFileObject` or a subtype of + :ctype:`PyFileObject`. .. versionchanged:: 2.2 Allowed subtypes to be accepted. -.. c:function:: int PyFile_CheckExact(PyObject *p) +.. cfunction:: int PyFile_CheckExact(PyObject *p) - Return true if its argument is a :c:type:`PyFileObject`, but not a subtype of - :c:type:`PyFileObject`. + Return true if its argument is a :ctype:`PyFileObject`, but not a subtype of + :ctype:`PyFileObject`. .. versionadded:: 2.2 -.. c:function:: PyObject* PyFile_FromString(char *filename, char *mode) +.. cfunction:: PyObject* PyFile_FromString(char *filename, char *mode) .. index:: single: fopen() On success, return a new file object that is opened on the file given by *filename*, with a file mode given by *mode*, where *mode* has the same - semantics as the standard C routine :c:func:`fopen`. On failure, return *NULL*. + semantics as the standard C routine :cfunc:`fopen`. On failure, return *NULL*. -.. c:function:: PyObject* PyFile_FromFile(FILE *fp, char *name, char *mode, int (*close)(FILE*)) +.. cfunction:: PyObject* PyFile_FromFile(FILE *fp, char *name, char *mode, int (*close)(FILE*)) - Create a new :c:type:`PyFileObject` from the already-open standard C file + Create a new :ctype:`PyFileObject` from the already-open standard C file pointer, *fp*. The function *close* will be called when the file should be closed. Return *NULL* and close the file using *close* on failure. *close* is optional and can be set to *NULL*. -.. c:function:: FILE* PyFile_AsFile(PyObject \*p) +.. cfunction:: FILE* PyFile_AsFile(PyObject \*p) - Return the file object associated with *p* as a :c:type:`FILE\*`. + Return the file object associated with *p* as a :ctype:`FILE\*`. - If the caller will ever use the returned :c:type:`FILE\*` object while - the :term:`GIL` is released it must also call the :c:func:`PyFile_IncUseCount` and - :c:func:`PyFile_DecUseCount` functions described below as appropriate. + If the caller will ever use the returned :ctype:`FILE\*` object while + the :term:`GIL` is released it must also call the :cfunc:`PyFile_IncUseCount` and + :cfunc:`PyFile_DecUseCount` functions described below as appropriate. -.. c:function:: void PyFile_IncUseCount(PyFileObject \*p) +.. cfunction:: void PyFile_IncUseCount(PyFileObject \*p) Increments the PyFileObject's internal use count to indicate - that the underlying :c:type:`FILE\*` is being used. + that the underlying :ctype:`FILE\*` is being used. This prevents Python from calling f_close() on it from another thread. - Callers of this must call :c:func:`PyFile_DecUseCount` when they are - finished with the :c:type:`FILE\*`. Otherwise the file object will + Callers of this must call :cfunc:`PyFile_DecUseCount` when they are + finished with the :ctype:`FILE\*`. Otherwise the file object will never be closed by Python. The :term:`GIL` must be held while calling this function. - The suggested use is to call this after :c:func:`PyFile_AsFile` and before + The suggested use is to call this after :cfunc:`PyFile_AsFile` and before you release the GIL:: FILE *fp = PyFile_AsFile(p); @@ -94,11 +94,11 @@ .. versionadded:: 2.6 -.. c:function:: void PyFile_DecUseCount(PyFileObject \*p) +.. cfunction:: void PyFile_DecUseCount(PyFileObject \*p) Decrements the PyFileObject's internal unlocked_count member to - indicate that the caller is done with its own use of the :c:type:`FILE\*`. - This may only be called to undo a prior call to :c:func:`PyFile_IncUseCount`. + indicate that the caller is done with its own use of the :ctype:`FILE\*`. + This may only be called to undo a prior call to :cfunc:`PyFile_IncUseCount`. The :term:`GIL` must be held while calling this function (see the example above). @@ -106,13 +106,12 @@ .. versionadded:: 2.6 -.. c:function:: PyObject* PyFile_GetLine(PyObject *p, int n) +.. cfunction:: PyObject* PyFile_GetLine(PyObject *p, int n) .. index:: single: EOFError (built-in exception) Equivalent to ``p.readline([n])``, this function reads one line from the - object *p*. *p* may be a file object or any object with a - :meth:`~io.IOBase.readline` + object *p*. *p* may be a file object or any object with a :meth:`readline` method. If *n* is ``0``, exactly one line is read, regardless of the length of the line. If *n* is greater than ``0``, no more than *n* bytes will be read from the file; a partial line can be returned. In both cases, an empty string @@ -121,20 +120,20 @@ raised if the end of the file is reached immediately. -.. c:function:: PyObject* PyFile_Name(PyObject *p) +.. cfunction:: PyObject* PyFile_Name(PyObject *p) Return the name of the file specified by *p* as a string object. -.. c:function:: void PyFile_SetBufSize(PyFileObject *p, int n) +.. cfunction:: void PyFile_SetBufSize(PyFileObject *p, int n) .. index:: single: setvbuf() - Available on systems with :c:func:`setvbuf` only. This should only be called + Available on systems with :cfunc:`setvbuf` only. This should only be called immediately after file object creation. -.. c:function:: int PyFile_SetEncoding(PyFileObject *p, const char *enc) +.. cfunction:: int PyFile_SetEncoding(PyFileObject *p, const char *enc) Set the file's encoding for Unicode output to *enc*. Return 1 on success and 0 on failure. @@ -142,7 +141,7 @@ .. versionadded:: 2.3 -.. c:function:: int PyFile_SetEncodingAndErrors(PyFileObject *p, const char *enc, *errors) +.. cfunction:: int PyFile_SetEncodingAndErrors(PyFileObject *p, const char *enc, *errors) Set the file's encoding for Unicode output to *enc*, and its error mode to *err*. Return 1 on success and 0 on failure. @@ -150,7 +149,7 @@ .. versionadded:: 2.6 -.. c:function:: int PyFile_SoftSpace(PyObject *p, int newflag) +.. cfunction:: int PyFile_SoftSpace(PyObject *p, int newflag) .. index:: single: softspace (file attribute) @@ -164,7 +163,7 @@ but doing so should not be needed. -.. c:function:: int PyFile_WriteObject(PyObject *obj, PyObject *p, int flags) +.. cfunction:: int PyFile_WriteObject(PyObject *obj, PyObject *p, int flags) .. index:: single: Py_PRINT_RAW @@ -174,7 +173,7 @@ appropriate exception will be set. -.. c:function:: int PyFile_WriteString(const char *s, PyObject *p) +.. cfunction:: int PyFile_WriteString(const char *s, PyObject *p) Write string *s* to file object *p*. Return ``0`` on success or ``-1`` on failure; the appropriate exception will be set. diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/c-api/float.rst --- a/Doc/c-api/float.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/c-api/float.rst Sun Jul 20 10:52:46 2014 -0400 @@ -8,64 +8,62 @@ .. index:: object: floating point -.. c:type:: PyFloatObject +.. ctype:: PyFloatObject - This subtype of :c:type:`PyObject` represents a Python floating point object. + This subtype of :ctype:`PyObject` represents a Python floating point object. -.. c:var:: PyTypeObject PyFloat_Type +.. cvar:: PyTypeObject PyFloat_Type .. index:: single: FloatType (in modules types) - This instance of :c:type:`PyTypeObject` represents the Python floating point + This instance of :ctype:`PyTypeObject` represents the Python floating point type. This is the same object as ``float`` and ``types.FloatType``. -.. c:function:: int PyFloat_Check(PyObject *p) +.. cfunction:: int PyFloat_Check(PyObject *p) - Return true if its argument is a :c:type:`PyFloatObject` or a subtype of - :c:type:`PyFloatObject`. + Return true if its argument is a :ctype:`PyFloatObject` or a subtype of + :ctype:`PyFloatObject`. .. versionchanged:: 2.2 Allowed subtypes to be accepted. -.. c:function:: int PyFloat_CheckExact(PyObject *p) +.. cfunction:: int PyFloat_CheckExact(PyObject *p) - Return true if its argument is a :c:type:`PyFloatObject`, but not a subtype of - :c:type:`PyFloatObject`. + Return true if its argument is a :ctype:`PyFloatObject`, but not a subtype of + :ctype:`PyFloatObject`. .. versionadded:: 2.2 -.. c:function:: PyObject* PyFloat_FromString(PyObject *str, char **pend) +.. cfunction:: PyObject* PyFloat_FromString(PyObject *str, char **pend) - Create a :c:type:`PyFloatObject` object based on the string value in *str*, or + Create a :ctype:`PyFloatObject` object based on the string value in *str*, or *NULL* on failure. The *pend* argument is ignored. It remains only for backward compatibility. -.. c:function:: PyObject* PyFloat_FromDouble(double v) +.. cfunction:: PyObject* PyFloat_FromDouble(double v) - Create a :c:type:`PyFloatObject` object from *v*, or *NULL* on failure. + Create a :ctype:`PyFloatObject` object from *v*, or *NULL* on failure. -.. c:function:: double PyFloat_AsDouble(PyObject *pyfloat) +.. cfunction:: double PyFloat_AsDouble(PyObject *pyfloat) - Return a C :c:type:`double` representation of the contents of *pyfloat*. If + Return a C :ctype:`double` representation of the contents of *pyfloat*. If *pyfloat* is not a Python floating point object but has a :meth:`__float__` method, this method will first be called to convert *pyfloat* into a float. - This method returns ``-1.0`` upon failure, so one should call - :c:func:`PyErr_Occurred` to check for errors. -.. c:function:: double PyFloat_AS_DOUBLE(PyObject *pyfloat) +.. cfunction:: double PyFloat_AS_DOUBLE(PyObject *pyfloat) - Return a C :c:type:`double` representation of the contents of *pyfloat*, but + Return a C :ctype:`double` representation of the contents of *pyfloat*, but without error checking. -.. c:function:: PyObject* PyFloat_GetInfo(void) +.. cfunction:: PyObject* PyFloat_GetInfo(void) Return a structseq instance which contains information about the precision, minimum and maximum values of a float. It's a thin wrapper @@ -74,21 +72,21 @@ .. versionadded:: 2.6 -.. c:function:: double PyFloat_GetMax() +.. cfunction:: double PyFloat_GetMax() - Return the maximum representable finite float *DBL_MAX* as C :c:type:`double`. + Return the maximum representable finite float *DBL_MAX* as C :ctype:`double`. .. versionadded:: 2.6 -.. c:function:: double PyFloat_GetMin() +.. cfunction:: double PyFloat_GetMin() - Return the minimum normalized positive float *DBL_MIN* as C :c:type:`double`. + Return the minimum normalized positive float *DBL_MIN* as C :ctype:`double`. .. versionadded:: 2.6 -.. c:function:: int PyFloat_ClearFreeList() +.. cfunction:: int PyFloat_ClearFreeList() Clear the float free list. Return the number of items that could not be freed. @@ -96,7 +94,7 @@ .. versionadded:: 2.6 -.. c:function:: void PyFloat_AsString(char *buf, PyFloatObject *v) +.. cfunction:: void PyFloat_AsString(char *buf, PyFloatObject *v) Convert the argument *v* to a string, using the same rules as :func:`str`. The length of *buf* should be at least 100. @@ -108,7 +106,7 @@ Use :func:`PyObject_Str` or :func:`PyOS_double_to_string` instead. -.. c:function:: void PyFloat_AsReprString(char *buf, PyFloatObject *v) +.. cfunction:: void PyFloat_AsReprString(char *buf, PyFloatObject *v) Same as PyFloat_AsString, except uses the same rules as :func:`repr`. The length of *buf* should be at least 100. diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/c-api/function.rst --- a/Doc/c-api/function.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/c-api/function.rst Sun Jul 20 10:52:46 2014 -0400 @@ -10,26 +10,26 @@ There are a few functions specific to Python functions. -.. c:type:: PyFunctionObject +.. ctype:: PyFunctionObject The C structure used for functions. -.. c:var:: PyTypeObject PyFunction_Type +.. cvar:: PyTypeObject PyFunction_Type .. index:: single: MethodType (in module types) - This is an instance of :c:type:`PyTypeObject` and represents the Python function + This is an instance of :ctype:`PyTypeObject` and represents the Python function type. It is exposed to Python programmers as ``types.FunctionType``. -.. c:function:: int PyFunction_Check(PyObject *o) +.. cfunction:: int PyFunction_Check(PyObject *o) - Return true if *o* is a function object (has type :c:data:`PyFunction_Type`). + Return true if *o* is a function object (has type :cdata:`PyFunction_Type`). The parameter must not be *NULL*. -.. c:function:: PyObject* PyFunction_New(PyObject *code, PyObject *globals) +.. cfunction:: PyObject* PyFunction_New(PyObject *code, PyObject *globals) Return a new function object associated with the code object *code*. *globals* must be a dictionary with the global variables accessible to the function. @@ -38,30 +38,30 @@ object, the argument defaults and closure are set to *NULL*. -.. c:function:: PyObject* PyFunction_GetCode(PyObject *op) +.. cfunction:: PyObject* PyFunction_GetCode(PyObject *op) Return the code object associated with the function object *op*. -.. c:function:: PyObject* PyFunction_GetGlobals(PyObject *op) +.. cfunction:: PyObject* PyFunction_GetGlobals(PyObject *op) Return the globals dictionary associated with the function object *op*. -.. c:function:: PyObject* PyFunction_GetModule(PyObject *op) +.. cfunction:: PyObject* PyFunction_GetModule(PyObject *op) Return the *__module__* attribute of the function object *op*. This is normally a string containing the module name, but can be set to any other object by Python code. -.. c:function:: PyObject* PyFunction_GetDefaults(PyObject *op) +.. cfunction:: PyObject* PyFunction_GetDefaults(PyObject *op) Return the argument default values of the function object *op*. This can be a tuple of arguments or *NULL*. -.. c:function:: int PyFunction_SetDefaults(PyObject *op, PyObject *defaults) +.. cfunction:: int PyFunction_SetDefaults(PyObject *op, PyObject *defaults) Set the argument default values for the function object *op*. *defaults* must be *Py_None* or a tuple. @@ -69,13 +69,13 @@ Raises :exc:`SystemError` and returns ``-1`` on failure. -.. c:function:: PyObject* PyFunction_GetClosure(PyObject *op) +.. cfunction:: PyObject* PyFunction_GetClosure(PyObject *op) Return the closure associated with the function object *op*. This can be *NULL* or a tuple of cell objects. -.. c:function:: int PyFunction_SetClosure(PyObject *op, PyObject *closure) +.. cfunction:: int PyFunction_SetClosure(PyObject *op, PyObject *closure) Set the closure associated with the function object *op*. *closure* must be *Py_None* or a tuple of cell objects. diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/c-api/gcsupport.rst --- a/Doc/c-api/gcsupport.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/c-api/gcsupport.rst Sun Jul 20 10:52:46 2014 -0400 @@ -15,10 +15,10 @@ .. An example showing the use of these interfaces can be found in "Supporting the .. Cycle Collector (XXX not found: ../ext/example-cycle-support.html)". -To create a container type, the :c:member:`~PyTypeObject.tp_flags` field of the type object must +To create a container type, the :attr:`tp_flags` field of the type object must include the :const:`Py_TPFLAGS_HAVE_GC` and provide an implementation of the -:c:member:`~PyTypeObject.tp_traverse` handler. If instances of the type are mutable, a -:c:member:`~PyTypeObject.tp_clear` implementation must also be provided. +:attr:`tp_traverse` handler. If instances of the type are mutable, a +:attr:`tp_clear` implementation must also be provided. .. data:: Py_TPFLAGS_HAVE_GC @@ -30,98 +30,98 @@ Constructors for container types must conform to two rules: -#. The memory for the object must be allocated using :c:func:`PyObject_GC_New` - or :c:func:`PyObject_GC_NewVar`. +#. The memory for the object must be allocated using :cfunc:`PyObject_GC_New` + or :cfunc:`PyObject_GC_NewVar`. #. Once all the fields which may contain references to other containers are - initialized, it must call :c:func:`PyObject_GC_Track`. + initialized, it must call :cfunc:`PyObject_GC_Track`. -.. c:function:: TYPE* PyObject_GC_New(TYPE, PyTypeObject *type) +.. cfunction:: TYPE* PyObject_GC_New(TYPE, PyTypeObject *type) - Analogous to :c:func:`PyObject_New` but for container objects with the + Analogous to :cfunc:`PyObject_New` but for container objects with the :const:`Py_TPFLAGS_HAVE_GC` flag set. -.. c:function:: TYPE* PyObject_GC_NewVar(TYPE, PyTypeObject *type, Py_ssize_t size) +.. cfunction:: TYPE* PyObject_GC_NewVar(TYPE, PyTypeObject *type, Py_ssize_t size) - Analogous to :c:func:`PyObject_NewVar` but for container objects with the + Analogous to :cfunc:`PyObject_NewVar` but for container objects with the :const:`Py_TPFLAGS_HAVE_GC` flag set. .. versionchanged:: 2.5 - This function used an :c:type:`int` type for *size*. This might require + This function used an :ctype:`int` type for *size*. This might require changes in your code for properly supporting 64-bit systems. -.. c:function:: TYPE* PyObject_GC_Resize(TYPE, PyVarObject *op, Py_ssize_t newsize) +.. cfunction:: TYPE* PyObject_GC_Resize(TYPE, PyVarObject *op, Py_ssize_t newsize) - Resize an object allocated by :c:func:`PyObject_NewVar`. Returns the + Resize an object allocated by :cfunc:`PyObject_NewVar`. Returns the resized object or *NULL* on failure. .. versionchanged:: 2.5 - This function used an :c:type:`int` type for *newsize*. This might + This function used an :ctype:`int` type for *newsize*. This might require changes in your code for properly supporting 64-bit systems. -.. c:function:: void PyObject_GC_Track(PyObject *op) +.. cfunction:: void PyObject_GC_Track(PyObject *op) Adds the object *op* to the set of container objects tracked by the collector. The collector can run at unexpected times so objects must be valid while being tracked. This should be called once all the fields - followed by the :c:member:`~PyTypeObject.tp_traverse` handler become valid, usually near the + followed by the :attr:`tp_traverse` handler become valid, usually near the end of the constructor. -.. c:function:: void _PyObject_GC_TRACK(PyObject *op) +.. cfunction:: void _PyObject_GC_TRACK(PyObject *op) - A macro version of :c:func:`PyObject_GC_Track`. It should not be used for + A macro version of :cfunc:`PyObject_GC_Track`. It should not be used for extension modules. Similarly, the deallocator for the object must conform to a similar pair of rules: #. Before fields which refer to other containers are invalidated, - :c:func:`PyObject_GC_UnTrack` must be called. + :cfunc:`PyObject_GC_UnTrack` must be called. -#. The object's memory must be deallocated using :c:func:`PyObject_GC_Del`. +#. The object's memory must be deallocated using :cfunc:`PyObject_GC_Del`. -.. c:function:: void PyObject_GC_Del(void *op) +.. cfunction:: void PyObject_GC_Del(void *op) - Releases memory allocated to an object using :c:func:`PyObject_GC_New` or - :c:func:`PyObject_GC_NewVar`. + Releases memory allocated to an object using :cfunc:`PyObject_GC_New` or + :cfunc:`PyObject_GC_NewVar`. -.. c:function:: void PyObject_GC_UnTrack(void *op) +.. cfunction:: void PyObject_GC_UnTrack(void *op) Remove the object *op* from the set of container objects tracked by the - collector. Note that :c:func:`PyObject_GC_Track` can be called again on + collector. Note that :cfunc:`PyObject_GC_Track` can be called again on this object to add it back to the set of tracked objects. The deallocator - (:c:member:`~PyTypeObject.tp_dealloc` handler) should call this for the object before any of - the fields used by the :c:member:`~PyTypeObject.tp_traverse` handler become invalid. + (:attr:`tp_dealloc` handler) should call this for the object before any of + the fields used by the :attr:`tp_traverse` handler become invalid. -.. c:function:: void _PyObject_GC_UNTRACK(PyObject *op) +.. cfunction:: void _PyObject_GC_UNTRACK(PyObject *op) - A macro version of :c:func:`PyObject_GC_UnTrack`. It should not be used for + A macro version of :cfunc:`PyObject_GC_UnTrack`. It should not be used for extension modules. -The :c:member:`~PyTypeObject.tp_traverse` handler accepts a function parameter of this type: +The :attr:`tp_traverse` handler accepts a function parameter of this type: -.. c:type:: int (*visitproc)(PyObject *object, void *arg) +.. ctype:: int (*visitproc)(PyObject *object, void *arg) - Type of the visitor function passed to the :c:member:`~PyTypeObject.tp_traverse` handler. + Type of the visitor function passed to the :attr:`tp_traverse` handler. The function should be called with an object to traverse as *object* and - the third parameter to the :c:member:`~PyTypeObject.tp_traverse` handler as *arg*. The + the third parameter to the :attr:`tp_traverse` handler as *arg*. The Python core uses several visitor functions to implement cyclic garbage detection; it's not expected that users will need to write their own visitor functions. -The :c:member:`~PyTypeObject.tp_traverse` handler must have the following type: +The :attr:`tp_traverse` handler must have the following type: -.. c:type:: int (*traverseproc)(PyObject *self, visitproc visit, void *arg) +.. ctype:: int (*traverseproc)(PyObject *self, visitproc visit, void *arg) Traversal function for a container object. Implementations must call the *visit* function for each object directly contained by *self*, with the @@ -130,15 +130,15 @@ object argument. If *visit* returns a non-zero value that value should be returned immediately. -To simplify writing :c:member:`~PyTypeObject.tp_traverse` handlers, a :c:func:`Py_VISIT` macro is -provided. In order to use this macro, the :c:member:`~PyTypeObject.tp_traverse` implementation +To simplify writing :attr:`tp_traverse` handlers, a :cfunc:`Py_VISIT` macro is +provided. In order to use this macro, the :attr:`tp_traverse` implementation must name its arguments exactly *visit* and *arg*: -.. c:function:: void Py_VISIT(PyObject *o) +.. cfunction:: void Py_VISIT(PyObject *o) Call the *visit* callback, with arguments *o* and *arg*. If *visit* returns - a non-zero value, then return it. Using this macro, :c:member:`~PyTypeObject.tp_traverse` + a non-zero value, then return it. Using this macro, :attr:`tp_traverse` handlers look like:: static int @@ -151,15 +151,15 @@ .. versionadded:: 2.4 -The :c:member:`~PyTypeObject.tp_clear` handler must be of the :c:type:`inquiry` type, or *NULL* +The :attr:`tp_clear` handler must be of the :ctype:`inquiry` type, or *NULL* if the object is immutable. -.. c:type:: int (*inquiry)(PyObject *self) +.. ctype:: int (*inquiry)(PyObject *self) Drop references that may have created reference cycles. Immutable objects do not have to define this method since they can never directly create reference cycles. Note that the object must still be valid after calling - this method (don't just call :c:func:`Py_DECREF` on a reference). The + this method (don't just call :cfunc:`Py_DECREF` on a reference). The collector will call this method if it detects that this object is involved in a reference cycle. diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/c-api/gen.rst --- a/Doc/c-api/gen.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/c-api/gen.rst Sun Jul 20 10:52:46 2014 -0400 @@ -7,31 +7,31 @@ Generator objects are what Python uses to implement generator iterators. They are normally created by iterating over a function that yields values, rather -than explicitly calling :c:func:`PyGen_New`. +than explicitly calling :cfunc:`PyGen_New`. -.. c:type:: PyGenObject +.. ctype:: PyGenObject The C structure used for generator objects. -.. c:var:: PyTypeObject PyGen_Type +.. cvar:: PyTypeObject PyGen_Type The type object corresponding to generator objects -.. c:function:: int PyGen_Check(ob) +.. cfunction:: int PyGen_Check(ob) Return true if *ob* is a generator object; *ob* must not be *NULL*. -.. c:function:: int PyGen_CheckExact(ob) +.. cfunction:: int PyGen_CheckExact(ob) Return true if *ob*'s type is *PyGen_Type* is a generator object; *ob* must not be *NULL*. -.. c:function:: PyObject* PyGen_New(PyFrameObject *frame) +.. cfunction:: PyObject* PyGen_New(PyFrameObject *frame) Create and return a new generator object based on the *frame* object. A reference to *frame* is stolen by this function. The parameter must not be diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/c-api/import.rst --- a/Doc/c-api/import.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/c-api/import.rst Sun Jul 20 10:52:46 2014 -0400 @@ -6,14 +6,14 @@ ================= -.. c:function:: PyObject* PyImport_ImportModule(const char *name) +.. cfunction:: PyObject* PyImport_ImportModule(const char *name) .. index:: single: package variable; __all__ single: __all__ (package variable) single: modules (in module sys) - This is a simplified interface to :c:func:`PyImport_ImportModuleEx` below, + This is a simplified interface to :cfunc:`PyImport_ImportModuleEx` below, leaving the *globals* and *locals* arguments set to *NULL* and *level* set to 0. When the *name* argument contains a dot (when it specifies a submodule of a package), the @@ -34,20 +34,20 @@ Always uses absolute imports. -.. c:function:: PyObject* PyImport_ImportModuleNoBlock(const char *name) +.. cfunction:: PyObject* PyImport_ImportModuleNoBlock(const char *name) - This version of :c:func:`PyImport_ImportModule` does not block. It's intended + This version of :cfunc:`PyImport_ImportModule` does not block. It's intended to be used in C functions that import other modules to execute a function. The import may block if another thread holds the import lock. The function - :c:func:`PyImport_ImportModuleNoBlock` never blocks. It first tries to fetch - the module from sys.modules and falls back to :c:func:`PyImport_ImportModule` + :cfunc:`PyImport_ImportModuleNoBlock` never blocks. It first tries to fetch + the module from sys.modules and falls back to :cfunc:`PyImport_ImportModule` unless the lock is held, in which case the function will raise an :exc:`ImportError`. .. versionadded:: 2.6 -.. c:function:: PyObject* PyImport_ImportModuleEx(char *name, PyObject *globals, PyObject *locals, PyObject *fromlist) +.. cfunction:: PyObject* PyImport_ImportModuleEx(char *name, PyObject *globals, PyObject *locals, PyObject *fromlist) .. index:: builtin: __import__ @@ -65,11 +65,11 @@ Failing imports remove incomplete module objects. .. versionchanged:: 2.6 - The function is an alias for :c:func:`PyImport_ImportModuleLevel` with + The function is an alias for :cfunc:`PyImport_ImportModuleLevel` with -1 as level, meaning relative import. -.. c:function:: PyObject* PyImport_ImportModuleLevel(char *name, PyObject *globals, PyObject *locals, PyObject *fromlist, int level) +.. cfunction:: PyObject* PyImport_ImportModuleLevel(char *name, PyObject *globals, PyObject *locals, PyObject *fromlist, int level) Import a module. This is best described by referring to the built-in Python function :func:`__import__`, as the standard :func:`__import__` function calls @@ -83,7 +83,7 @@ .. versionadded:: 2.5 -.. c:function:: PyObject* PyImport_Import(PyObject *name) +.. cfunction:: PyObject* PyImport_Import(PyObject *name) .. index:: module: rexec @@ -98,7 +98,7 @@ Always uses absolute imports. -.. c:function:: PyObject* PyImport_ReloadModule(PyObject *m) +.. cfunction:: PyObject* PyImport_ReloadModule(PyObject *m) .. index:: builtin: reload @@ -108,7 +108,7 @@ with an exception set on failure (the module still exists in this case). -.. c:function:: PyObject* PyImport_AddModule(const char *name) +.. cfunction:: PyObject* PyImport_AddModule(const char *name) Return the module object corresponding to a module name. The *name* argument may be of the form ``package.module``. First check the modules dictionary if @@ -118,12 +118,12 @@ .. note:: This function does not load or import the module; if the module wasn't already - loaded, you will get an empty module object. Use :c:func:`PyImport_ImportModule` + loaded, you will get an empty module object. Use :cfunc:`PyImport_ImportModule` or one of its variants to import a module. Package structures implied by a dotted name for *name* are not created if not already present. -.. c:function:: PyObject* PyImport_ExecCodeModule(char *name, PyObject *co) +.. cfunction:: PyObject* PyImport_ExecCodeModule(char *name, PyObject *co) .. index:: builtin: compile @@ -133,16 +133,16 @@ or *NULL* with an exception set if an error occurred. Before Python 2.4, the module could still be created in error cases. Starting with Python 2.4, *name* is removed from :attr:`sys.modules` in error cases, and even if *name* was already - in :attr:`sys.modules` on entry to :c:func:`PyImport_ExecCodeModule`. Leaving + in :attr:`sys.modules` on entry to :cfunc:`PyImport_ExecCodeModule`. Leaving incompletely initialized modules in :attr:`sys.modules` is dangerous, as imports of such modules have no way to know that the module object is an unknown (and probably damaged with respect to the module author's intents) state. The module's :attr:`__file__` attribute will be set to the code object's - :c:member:`co_filename`. + :cmember:`co_filename`. This function will reload the module if it was already imported. See - :c:func:`PyImport_ReloadModule` for the intended way to reload a module. + :cfunc:`PyImport_ReloadModule` for the intended way to reload a module. If *name* points to a dotted name of the form ``package.module``, any package structures not already created will still not be created. @@ -151,26 +151,26 @@ *name* is removed from :attr:`sys.modules` in error cases. -.. c:function:: PyObject* PyImport_ExecCodeModuleEx(char *name, PyObject *co, char *pathname) +.. cfunction:: PyObject* PyImport_ExecCodeModuleEx(char *name, PyObject *co, char *pathname) - Like :c:func:`PyImport_ExecCodeModule`, but the :attr:`__file__` attribute of + Like :cfunc:`PyImport_ExecCodeModule`, but the :attr:`__file__` attribute of the module object is set to *pathname* if it is non-``NULL``. -.. c:function:: long PyImport_GetMagicNumber() +.. cfunction:: long PyImport_GetMagicNumber() Return the magic number for Python bytecode files (a.k.a. :file:`.pyc` and :file:`.pyo` files). The magic number should be present in the first four bytes of the bytecode file, in little-endian byte order. -.. c:function:: PyObject* PyImport_GetModuleDict() +.. cfunction:: PyObject* PyImport_GetModuleDict() Return the dictionary used for the module administration (a.k.a. ``sys.modules``). Note that this is a per-interpreter variable. -.. c:function:: PyObject* PyImport_GetImporter(PyObject *path) +.. cfunction:: PyObject* PyImport_GetImporter(PyObject *path) Return an importer object for a :data:`sys.path`/:attr:`pkg.__path__` item *path*, possibly by fetching it from the :data:`sys.path_importer_cache` @@ -183,41 +183,41 @@ .. versionadded:: 2.6 -.. c:function:: void _PyImport_Init() +.. cfunction:: void _PyImport_Init() Initialize the import mechanism. For internal use only. -.. c:function:: void PyImport_Cleanup() +.. cfunction:: void PyImport_Cleanup() Empty the module table. For internal use only. -.. c:function:: void _PyImport_Fini() +.. cfunction:: void _PyImport_Fini() Finalize the import mechanism. For internal use only. -.. c:function:: PyObject* _PyImport_FindExtension(char *, char *) +.. cfunction:: PyObject* _PyImport_FindExtension(char *, char *) For internal use only. -.. c:function:: PyObject* _PyImport_FixupExtension(char *, char *) +.. cfunction:: PyObject* _PyImport_FixupExtension(char *, char *) For internal use only. -.. c:function:: int PyImport_ImportFrozenModule(char *name) +.. cfunction:: int PyImport_ImportFrozenModule(char *name) Load a frozen module named *name*. Return ``1`` for success, ``0`` if the module is not found, and ``-1`` with an exception set if the initialization failed. To access the imported module on a successful load, use - :c:func:`PyImport_ImportModule`. (Note the misnomer --- this function would + :cfunc:`PyImport_ImportModule`. (Note the misnomer --- this function would reload the module if it was already imported.) -.. c:type:: struct _frozen +.. ctype:: struct _frozen .. index:: single: freeze utility @@ -233,30 +233,30 @@ }; -.. c:var:: struct _frozen* PyImport_FrozenModules +.. cvar:: struct _frozen* PyImport_FrozenModules - This pointer is initialized to point to an array of :c:type:`struct _frozen` + This pointer is initialized to point to an array of :ctype:`struct _frozen` records, terminated by one whose members are all *NULL* or zero. When a frozen module is imported, it is searched in this table. Third-party code could play tricks with this to provide a dynamically created collection of frozen modules. -.. c:function:: int PyImport_AppendInittab(const char *name, void (*initfunc)(void)) +.. cfunction:: int PyImport_AppendInittab(const char *name, void (*initfunc)(void)) Add a single module to the existing table of built-in modules. This is a - convenience wrapper around :c:func:`PyImport_ExtendInittab`, returning ``-1`` if + convenience wrapper around :cfunc:`PyImport_ExtendInittab`, returning ``-1`` if the table could not be extended. The new module can be imported by the name *name*, and uses the function *initfunc* as the initialization function called on the first attempted import. This should be called before - :c:func:`Py_Initialize`. + :cfunc:`Py_Initialize`. -.. c:type:: struct _inittab +.. ctype:: struct _inittab Structure describing a single entry in the list of built-in modules. Each of these structures gives the name and initialization function for a module built into the interpreter. Programs which embed Python may use an array of these - structures in conjunction with :c:func:`PyImport_ExtendInittab` to provide + structures in conjunction with :cfunc:`PyImport_ExtendInittab` to provide additional built-in modules. The structure is defined in :file:`Include/import.h` as:: @@ -266,11 +266,11 @@ }; -.. c:function:: int PyImport_ExtendInittab(struct _inittab *newtab) +.. cfunction:: int PyImport_ExtendInittab(struct _inittab *newtab) Add a collection of modules to the table of built-in modules. The *newtab* array must end with a sentinel entry which contains *NULL* for the :attr:`name` field; failure to provide the sentinel value can result in a memory fault. Returns ``0`` on success or ``-1`` if insufficient memory could be allocated to extend the internal table. In the event of failure, no modules are added to the - internal table. This should be called before :c:func:`Py_Initialize`. + internal table. This should be called before :cfunc:`Py_Initialize`. diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/c-api/index.rst --- a/Doc/c-api/index.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/c-api/index.rst Sun Jul 20 10:52:46 2014 -0400 @@ -4,6 +4,9 @@ Python/C API Reference Manual ################################## +:Release: |version| +:Date: |today| + This manual documents the API used by C and C++ programmers who want to write extension modules or embed Python. It is a companion to :ref:`extending-index`, which describes the general principles of extension writing but does not diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/c-api/init.rst --- a/Doc/c-api/init.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/c-api/init.rst Sun Jul 20 10:52:46 2014 -0400 @@ -12,7 +12,7 @@ =========================================== -.. c:function:: void Py_Initialize() +.. cfunction:: void Py_Initialize() .. index:: single: Py_SetProgramName() @@ -31,40 +31,40 @@ Initialize the Python interpreter. In an application embedding Python, this should be called before using any other Python/C API functions; with the - exception of :c:func:`Py_SetProgramName`, :c:func:`Py_SetPythonHome`, :c:func:`PyEval_InitThreads`, - :c:func:`PyEval_ReleaseLock`, and :c:func:`PyEval_AcquireLock`. This initializes + exception of :cfunc:`Py_SetProgramName`, :cfunc:`PyEval_InitThreads`, + :cfunc:`PyEval_ReleaseLock`, and :cfunc:`PyEval_AcquireLock`. This initializes the table of loaded modules (``sys.modules``), and creates the fundamental modules :mod:`__builtin__`, :mod:`__main__` and :mod:`sys`. It also initializes the module search path (``sys.path``). It does not set ``sys.argv``; use - :c:func:`PySys_SetArgvEx` for that. This is a no-op when called for a second time - (without calling :c:func:`Py_Finalize` first). There is no return value; it is a + :cfunc:`PySys_SetArgvEx` for that. This is a no-op when called for a second time + (without calling :cfunc:`Py_Finalize` first). There is no return value; it is a fatal error if the initialization fails. -.. c:function:: void Py_InitializeEx(int initsigs) +.. cfunction:: void Py_InitializeEx(int initsigs) - This function works like :c:func:`Py_Initialize` if *initsigs* is 1. If + This function works like :cfunc:`Py_Initialize` if *initsigs* is 1. If *initsigs* is 0, it skips initialization registration of signal handlers, which might be useful when Python is embedded. .. versionadded:: 2.4 -.. c:function:: int Py_IsInitialized() +.. cfunction:: int Py_IsInitialized() Return true (nonzero) when the Python interpreter has been initialized, false - (zero) if not. After :c:func:`Py_Finalize` is called, this returns false until - :c:func:`Py_Initialize` is called again. + (zero) if not. After :cfunc:`Py_Finalize` is called, this returns false until + :cfunc:`Py_Initialize` is called again. -.. c:function:: void Py_Finalize() +.. cfunction:: void Py_Finalize() - Undo all initializations made by :c:func:`Py_Initialize` and subsequent use of + Undo all initializations made by :cfunc:`Py_Initialize` and subsequent use of Python/C API functions, and destroy all sub-interpreters (see - :c:func:`Py_NewInterpreter` below) that were created and not yet destroyed since - the last call to :c:func:`Py_Initialize`. Ideally, this frees all memory + :cfunc:`Py_NewInterpreter` below) that were created and not yet destroyed since + the last call to :cfunc:`Py_Initialize`. Ideally, this frees all memory allocated by the Python interpreter. This is a no-op when called for a second - time (without calling :c:func:`Py_Initialize` again first). There is no return + time (without calling :cfunc:`Py_Initialize` again first). There is no return value; errors during finalization are ignored. This function is provided for a number of reasons. An embedding application @@ -83,25 +83,25 @@ please report it). Memory tied up in circular references between objects is not freed. Some memory allocated by extension modules may not be freed. Some extensions may not work properly if their initialization routine is called more - than once; this can happen if an application calls :c:func:`Py_Initialize` and - :c:func:`Py_Finalize` more than once. + than once; this can happen if an application calls :cfunc:`Py_Initialize` and + :cfunc:`Py_Finalize` more than once. Process-wide parameters ======================= -.. c:function:: void Py_SetProgramName(char *name) +.. cfunction:: void Py_SetProgramName(char *name) .. index:: single: Py_Initialize() single: main() single: Py_GetPath() - This function should be called before :c:func:`Py_Initialize` is called for + This function should be called before :cfunc:`Py_Initialize` is called for the first time, if it is called at all. It tells the interpreter the value - of the ``argv[0]`` argument to the :c:func:`main` function of the program. - This is used by :c:func:`Py_GetPath` and some other functions below to find + of the ``argv[0]`` argument to the :cfunc:`main` function of the program. + This is used by :cfunc:`Py_GetPath` and some other functions below to find the Python run-time libraries relative to the interpreter executable. The default value is ``'python'``. The argument should point to a zero-terminated character string in static storage whose contents will not @@ -109,20 +109,20 @@ interpreter will change the contents of this storage. -.. c:function:: char* Py_GetProgramName() +.. cfunction:: char* Py_GetProgramName() .. index:: single: Py_SetProgramName() - Return the program name set with :c:func:`Py_SetProgramName`, or the default. + Return the program name set with :cfunc:`Py_SetProgramName`, or the default. The returned string points into static storage; the caller should not modify its value. -.. c:function:: char* Py_GetPrefix() +.. cfunction:: char* Py_GetPrefix() Return the *prefix* for installed platform-independent files. This is derived through a number of complicated rules from the program name set with - :c:func:`Py_SetProgramName` and some environment variables; for example, if the + :cfunc:`Py_SetProgramName` and some environment variables; for example, if the program name is ``'/usr/local/bin/python'``, the prefix is ``'/usr/local'``. The returned string points into static storage; the caller should not modify its value. This corresponds to the :makevar:`prefix` variable in the top-level @@ -131,11 +131,11 @@ It is only useful on Unix. See also the next function. -.. c:function:: char* Py_GetExecPrefix() +.. cfunction:: char* Py_GetExecPrefix() Return the *exec-prefix* for installed platform-*dependent* files. This is derived through a number of complicated rules from the program name set with - :c:func:`Py_SetProgramName` and some environment variables; for example, if the + :cfunc:`Py_SetProgramName` and some environment variables; for example, if the program name is ``'/usr/local/bin/python'``, the exec-prefix is ``'/usr/local'``. The returned string points into static storage; the caller should not modify its value. This corresponds to the :makevar:`exec_prefix` @@ -166,7 +166,7 @@ platform. -.. c:function:: char* Py_GetProgramFullPath() +.. cfunction:: char* Py_GetProgramFullPath() .. index:: single: Py_SetProgramName() @@ -174,19 +174,19 @@ Return the full program name of the Python executable; this is computed as a side-effect of deriving the default module search path from the program name - (set by :c:func:`Py_SetProgramName` above). The returned string points into + (set by :cfunc:`Py_SetProgramName` above). The returned string points into static storage; the caller should not modify its value. The value is available to Python code as ``sys.executable``. -.. c:function:: char* Py_GetPath() +.. cfunction:: char* Py_GetPath() .. index:: triple: module; search; path single: path (in module sys) Return the default module search path; this is computed from the program name - (set by :c:func:`Py_SetProgramName` above) and some environment variables. + (set by :cfunc:`Py_SetProgramName` above) and some environment variables. The returned string consists of a series of directory names separated by a platform dependent delimiter character. The delimiter character is ``':'`` on Unix and Mac OS X, ``';'`` on Windows. The returned string points into @@ -198,7 +198,7 @@ .. XXX should give the exact rules -.. c:function:: const char* Py_GetVersion() +.. cfunction:: const char* Py_GetVersion() Return the version of this Python interpreter. This is a string that looks something like :: @@ -213,7 +213,7 @@ modify its value. The value is available to Python code as ``sys.version``. -.. c:function:: const char* Py_GetPlatform() +.. cfunction:: const char* Py_GetPlatform() .. index:: single: platform (in module sys) @@ -226,7 +226,7 @@ to Python code as ``sys.platform``. -.. c:function:: const char* Py_GetCopyright() +.. cfunction:: const char* Py_GetCopyright() Return the official copyright string for the current Python version, for example @@ -238,7 +238,7 @@ value. The value is available to Python code as ``sys.copyright``. -.. c:function:: const char* Py_GetCompiler() +.. cfunction:: const char* Py_GetCompiler() Return an indication of the compiler used to build the current Python version, in square brackets, for example:: @@ -252,7 +252,7 @@ ``sys.version``. -.. c:function:: const char* Py_GetBuildInfo() +.. cfunction:: const char* Py_GetBuildInfo() Return information about the sequence number and build date and time of the current Python interpreter instance, for example :: @@ -266,7 +266,7 @@ ``sys.version``. -.. c:function:: void PySys_SetArgvEx(int argc, char **argv, int updatepath) +.. cfunction:: void PySys_SetArgvEx(int argc, char **argv, int updatepath) .. index:: single: main() @@ -274,12 +274,12 @@ single: argv (in module sys) Set :data:`sys.argv` based on *argc* and *argv*. These parameters are - similar to those passed to the program's :c:func:`main` function with the + similar to those passed to the program's :cfunc:`main` function with the difference that the first entry should refer to the script file to be executed rather than the executable hosting the Python interpreter. If there isn't a script that will be run, the first entry in *argv* can be an empty string. If this function fails to initialize :data:`sys.argv`, a fatal - condition is signalled using :c:func:`Py_FatalError`. + condition is signalled using :cfunc:`Py_FatalError`. If *updatepath* is zero, this is all the function does. If *updatepath* is non-zero, the function also modifies :data:`sys.path` according to the @@ -301,7 +301,7 @@ On versions before 2.6.6, you can achieve the same effect by manually popping the first :data:`sys.path` element after having called - :c:func:`PySys_SetArgv`, for example using:: + :cfunc:`PySys_SetArgv`, for example using:: PyRun_SimpleString("import sys; sys.path.pop(0)\n"); @@ -311,12 +311,12 @@ check w/ Guido. -.. c:function:: void PySys_SetArgv(int argc, char **argv) +.. cfunction:: void PySys_SetArgv(int argc, char **argv) - This function works like :c:func:`PySys_SetArgvEx` with *updatepath* set to 1. + This function works like :cfunc:`PySys_SetArgvEx` with *updatepath* set to 1. -.. c:function:: void Py_SetPythonHome(char *home) +.. cfunction:: void Py_SetPythonHome(char *home) Set the default "home" directory, that is, the location of the standard Python libraries. See :envvar:`PYTHONHOME` for the meaning of the @@ -328,10 +328,10 @@ this storage. -.. c:function:: char* Py_GetPythonHome() +.. cfunction:: char* Py_GetPythonHome() Return the default "home", that is, the value set by a previous call to - :c:func:`Py_SetPythonHome`, or the value of the :envvar:`PYTHONHOME` + :cfunc:`Py_SetPythonHome`, or the value of the :envvar:`PYTHONHOME` environment variable if it is set. @@ -368,9 +368,9 @@ single: PyThreadState The Python interpreter keeps some thread-specific bookkeeping information -inside a data structure called :c:type:`PyThreadState`. There's also one -global variable pointing to the current :c:type:`PyThreadState`: it can -be retrieved using :c:func:`PyThreadState_Get`. +inside a data structure called :ctype:`PyThreadState`. There's also one +global variable pointing to the current :ctype:`PyThreadState`: it can +be retrieved using :cfunc:`PyThreadState_Get`. Releasing the GIL from extension code ------------------------------------- @@ -394,8 +394,8 @@ single: Py_BEGIN_ALLOW_THREADS single: Py_END_ALLOW_THREADS -The :c:macro:`Py_BEGIN_ALLOW_THREADS` macro opens a new block and declares a -hidden local variable; the :c:macro:`Py_END_ALLOW_THREADS` macro closes the +The :cmacro:`Py_BEGIN_ALLOW_THREADS` macro opens a new block and declares a +hidden local variable; the :cmacro:`Py_END_ALLOW_THREADS` macro closes the block. These two macros are still available when Python is compiled without thread support (they simply have an empty expansion). @@ -427,9 +427,6 @@ standard :mod:`zlib` and :mod:`hashlib` modules release the GIL when compressing or hashing data. - -.. _gilstate: - Non-Python created threads -------------------------- @@ -448,7 +445,7 @@ API. When you are done, you should reset the thread state pointer, release the GIL, and finally free the thread state data structure. -The :c:func:`PyGILState_Ensure` and :c:func:`PyGILState_Release` functions do +The :cfunc:`PyGILState_Ensure` and :cfunc:`PyGILState_Release` functions do all of the above automatically. The typical idiom for calling into Python from a C thread is:: @@ -462,14 +459,14 @@ /* Release the thread. No Python API allowed beyond this point. */ PyGILState_Release(gstate); -Note that the :c:func:`PyGILState_\*` functions assume there is only one global -interpreter (created automatically by :c:func:`Py_Initialize`). Python +Note that the :cfunc:`PyGILState_\*` functions assume there is only one global +interpreter (created automatically by :cfunc:`Py_Initialize`). Python supports the creation of additional interpreters (using -:c:func:`Py_NewInterpreter`), but mixing multiple interpreters and the -:c:func:`PyGILState_\*` API is unsupported. +:cfunc:`Py_NewInterpreter`), but mixing multiple interpreters and the +:cfunc:`PyGILState_\*` API is unsupported. Another important thing to note about threads is their behaviour in the face -of the C :c:func:`fork` call. On most systems with :c:func:`fork`, after a +of the C :cfunc:`fork` call. On most systems with :cfunc:`fork`, after a process forks only the thread that issued the fork will exist. That also means any locks held by other threads will never be released. Python solves this for :func:`os.fork` by acquiring the locks it uses internally before @@ -477,12 +474,12 @@ :ref:`lock-objects` in the child. When extending or embedding Python, there is no way to inform Python of additional (non-Python) locks that need to be acquired before or reset after a fork. OS facilities such as -:c:func:`pthread_atfork` would need to be used to accomplish the same thing. -Additionally, when extending or embedding Python, calling :c:func:`fork` +:cfunc:`pthread_atfork` would need to be used to accomplish the same thing. +Additionally, when extending or embedding Python, calling :cfunc:`fork` directly rather than through :func:`os.fork` (and returning to or calling into Python) may result in a deadlock by one of Python's internal locks being held by a thread that is defunct after the fork. -:c:func:`PyOS_AfterFork` tries to reset the necessary locks, but is not +:cfunc:`PyOS_AfterFork` tries to reset the necessary locks, but is not always able to. @@ -492,7 +489,7 @@ These are the most commonly used types and functions when writing C extension code, or when embedding the Python interpreter: -.. c:type:: PyInterpreterState +.. ctype:: PyInterpreterState This data structure represents the state shared by a number of cooperating threads. Threads belonging to the same interpreter share their module @@ -505,14 +502,14 @@ interpreter they belong. -.. c:type:: PyThreadState +.. ctype:: PyThreadState This data structure represents the state of a single thread. The only public - data member is :c:type:`PyInterpreterState \*`:attr:`interp`, which points to + data member is :ctype:`PyInterpreterState \*`:attr:`interp`, which points to this thread's interpreter state. -.. c:function:: void PyEval_InitThreads() +.. cfunction:: void PyEval_InitThreads() .. index:: single: PyEval_ReleaseLock() @@ -522,19 +519,18 @@ Initialize and acquire the global interpreter lock. It should be called in the main thread before creating a second thread or engaging in any other thread - operations such as :c:func:`PyEval_ReleaseLock` or + operations such as :cfunc:`PyEval_ReleaseLock` or ``PyEval_ReleaseThread(tstate)``. It is not needed before calling - :c:func:`PyEval_SaveThread` or :c:func:`PyEval_RestoreThread`. + :cfunc:`PyEval_SaveThread` or :cfunc:`PyEval_RestoreThread`. .. index:: single: Py_Initialize() This is a no-op when called for a second time. It is safe to call this function - before calling :c:func:`Py_Initialize`. + before calling :cfunc:`Py_Initialize`. .. index:: module: thread .. note:: - When only the main thread exists, no GIL operations are needed. This is a common situation (most Python programs do not use threads), and the lock operations slow the interpreter down a bit. Therefore, the lock is not @@ -543,7 +539,7 @@ when this function initializes the global interpreter lock, it also acquires it. Before the Python :mod:`_thread` module creates a new thread, knowing that either it has the lock or the lock hasn't been created yet, it calls - :c:func:`PyEval_InitThreads`. When this call returns, it is guaranteed that + :cfunc:`PyEval_InitThreads`. When this call returns, it is guaranteed that the lock has been created and that the calling thread has acquired it. It is **not** safe to call this function when it is unknown which thread (if @@ -552,9 +548,9 @@ This function is not available when thread support is disabled at compile time. -.. c:function:: int PyEval_ThreadsInitialized() +.. cfunction:: int PyEval_ThreadsInitialized() - Returns a non-zero value if :c:func:`PyEval_InitThreads` has been called. This + Returns a non-zero value if :cfunc:`PyEval_InitThreads` has been called. This function can be called without holding the GIL, and therefore can be used to avoid calls to the locking API when running single-threaded. This function is not available when thread support is disabled at compile time. @@ -562,7 +558,7 @@ .. versionadded:: 2.4 -.. c:function:: PyThreadState* PyEval_SaveThread() +.. cfunction:: PyThreadState* PyEval_SaveThread() Release the global interpreter lock (if it has been created and thread support is enabled) and reset the thread state to *NULL*, returning the @@ -571,7 +567,7 @@ when thread support is disabled at compile time.) -.. c:function:: void PyEval_RestoreThread(PyThreadState *tstate) +.. cfunction:: void PyEval_RestoreThread(PyThreadState *tstate) Acquire the global interpreter lock (if it has been created and thread support is enabled) and set the thread state to *tstate*, which must not be @@ -580,23 +576,23 @@ when thread support is disabled at compile time.) -.. c:function:: PyThreadState* PyThreadState_Get() +.. cfunction:: PyThreadState* PyThreadState_Get() Return the current thread state. The global interpreter lock must be held. When the current thread state is *NULL*, this issues a fatal error (so that the caller needn't check for *NULL*). -.. c:function:: PyThreadState* PyThreadState_Swap(PyThreadState *tstate) +.. cfunction:: PyThreadState* PyThreadState_Swap(PyThreadState *tstate) Swap the current thread state with the thread state given by the argument *tstate*, which may be *NULL*. The global interpreter lock must be held and is not released. -.. c:function:: void PyEval_ReInitThreads() +.. cfunction:: void PyEval_ReInitThreads() - This function is called from :c:func:`PyOS_AfterFork` to ensure that newly + This function is called from :cfunc:`PyOS_AfterFork` to ensure that newly created child processes don't hold locks referring to threads which are not running in the child process. @@ -604,24 +600,24 @@ The following functions use thread-local storage, and are not compatible with sub-interpreters: -.. c:function:: PyGILState_STATE PyGILState_Ensure() +.. cfunction:: PyGILState_STATE PyGILState_Ensure() Ensure that the current thread is ready to call the Python C API regardless of the current state of Python, or of the global interpreter lock. This may be called as many times as desired by a thread as long as each call is - matched with a call to :c:func:`PyGILState_Release`. In general, other - thread-related APIs may be used between :c:func:`PyGILState_Ensure` and - :c:func:`PyGILState_Release` calls as long as the thread state is restored to + matched with a call to :cfunc:`PyGILState_Release`. In general, other + thread-related APIs may be used between :cfunc:`PyGILState_Ensure` and + :cfunc:`PyGILState_Release` calls as long as the thread state is restored to its previous state before the Release(). For example, normal usage of the - :c:macro:`Py_BEGIN_ALLOW_THREADS` and :c:macro:`Py_END_ALLOW_THREADS` macros is + :cmacro:`Py_BEGIN_ALLOW_THREADS` and :cmacro:`Py_END_ALLOW_THREADS` macros is acceptable. The return value is an opaque "handle" to the thread state when - :c:func:`PyGILState_Ensure` was called, and must be passed to - :c:func:`PyGILState_Release` to ensure Python is left in the same state. Even + :cfunc:`PyGILState_Ensure` was called, and must be passed to + :cfunc:`PyGILState_Release` to ensure Python is left in the same state. Even though recursive calls are allowed, these handles *cannot* be shared - each - unique call to :c:func:`PyGILState_Ensure` must save the handle for its call - to :c:func:`PyGILState_Release`. + unique call to :cfunc:`PyGILState_Ensure` must save the handle for its call + to :cfunc:`PyGILState_Release`. When the function returns, the current thread will hold the GIL and be able to call arbitrary Python code. Failure is a fatal error. @@ -629,20 +625,20 @@ .. versionadded:: 2.3 -.. c:function:: void PyGILState_Release(PyGILState_STATE) +.. cfunction:: void PyGILState_Release(PyGILState_STATE) Release any resources previously acquired. After this call, Python's state will - be the same as it was prior to the corresponding :c:func:`PyGILState_Ensure` call + be the same as it was prior to the corresponding :cfunc:`PyGILState_Ensure` call (but generally this state will be unknown to the caller, hence the use of the GILState API). - Every call to :c:func:`PyGILState_Ensure` must be matched by a call to - :c:func:`PyGILState_Release` on the same thread. + Every call to :cfunc:`PyGILState_Ensure` must be matched by a call to + :cfunc:`PyGILState_Release` on the same thread. .. versionadded:: 2.3 -.. c:function:: PyThreadState PyGILState_GetThisThreadState() +.. cfunction:: PyThreadState PyGILState_GetThisThreadState() Get the current thread state for this thread. May return ``NULL`` if no GILState API has been used on the current thread. Note that the main thread @@ -656,33 +652,33 @@ example usage in the Python source distribution. -.. c:macro:: Py_BEGIN_ALLOW_THREADS +.. cmacro:: Py_BEGIN_ALLOW_THREADS This macro expands to ``{ PyThreadState *_save; _save = PyEval_SaveThread();``. Note that it contains an opening brace; it must be matched with a following - :c:macro:`Py_END_ALLOW_THREADS` macro. See above for further discussion of this + :cmacro:`Py_END_ALLOW_THREADS` macro. See above for further discussion of this macro. It is a no-op when thread support is disabled at compile time. -.. c:macro:: Py_END_ALLOW_THREADS +.. cmacro:: Py_END_ALLOW_THREADS This macro expands to ``PyEval_RestoreThread(_save); }``. Note that it contains a closing brace; it must be matched with an earlier - :c:macro:`Py_BEGIN_ALLOW_THREADS` macro. See above for further discussion of + :cmacro:`Py_BEGIN_ALLOW_THREADS` macro. See above for further discussion of this macro. It is a no-op when thread support is disabled at compile time. -.. c:macro:: Py_BLOCK_THREADS +.. cmacro:: Py_BLOCK_THREADS This macro expands to ``PyEval_RestoreThread(_save);``: it is equivalent to - :c:macro:`Py_END_ALLOW_THREADS` without the closing brace. It is a no-op when + :cmacro:`Py_END_ALLOW_THREADS` without the closing brace. It is a no-op when thread support is disabled at compile time. -.. c:macro:: Py_UNBLOCK_THREADS +.. cmacro:: Py_UNBLOCK_THREADS This macro expands to ``_save = PyEval_SaveThread();``: it is equivalent to - :c:macro:`Py_BEGIN_ALLOW_THREADS` without the opening brace and variable + :cmacro:`Py_BEGIN_ALLOW_THREADS` without the opening brace and variable declaration. It is a no-op when thread support is disabled at compile time. @@ -694,47 +690,47 @@ been created. -.. c:function:: PyInterpreterState* PyInterpreterState_New() +.. cfunction:: PyInterpreterState* PyInterpreterState_New() Create a new interpreter state object. The global interpreter lock need not be held, but may be held if it is necessary to serialize calls to this function. -.. c:function:: void PyInterpreterState_Clear(PyInterpreterState *interp) +.. cfunction:: void PyInterpreterState_Clear(PyInterpreterState *interp) Reset all information in an interpreter state object. The global interpreter lock must be held. -.. c:function:: void PyInterpreterState_Delete(PyInterpreterState *interp) +.. cfunction:: void PyInterpreterState_Delete(PyInterpreterState *interp) Destroy an interpreter state object. The global interpreter lock need not be held. The interpreter state must have been reset with a previous call to - :c:func:`PyInterpreterState_Clear`. + :cfunc:`PyInterpreterState_Clear`. -.. c:function:: PyThreadState* PyThreadState_New(PyInterpreterState *interp) +.. cfunction:: PyThreadState* PyThreadState_New(PyInterpreterState *interp) Create a new thread state object belonging to the given interpreter object. The global interpreter lock need not be held, but may be held if it is necessary to serialize calls to this function. -.. c:function:: void PyThreadState_Clear(PyThreadState *tstate) +.. cfunction:: void PyThreadState_Clear(PyThreadState *tstate) Reset all information in a thread state object. The global interpreter lock must be held. -.. c:function:: void PyThreadState_Delete(PyThreadState *tstate) +.. cfunction:: void PyThreadState_Delete(PyThreadState *tstate) Destroy a thread state object. The global interpreter lock need not be held. The thread state must have been reset with a previous call to - :c:func:`PyThreadState_Clear`. + :cfunc:`PyThreadState_Clear`. -.. c:function:: PyObject* PyThreadState_GetDict() +.. cfunction:: PyObject* PyThreadState_GetDict() Return a dictionary in which extensions can store thread-specific state information. Each extension should use a unique key to use to store state in @@ -747,7 +743,7 @@ meant that an exception was raised. -.. c:function:: int PyThreadState_SetAsyncExc(long id, PyObject *exc) +.. cfunction:: int PyThreadState_SetAsyncExc(long id, PyObject *exc) Asynchronously raise an exception in a thread. The *id* argument is the thread id of the target thread; *exc* is the exception object to be raised. This @@ -760,18 +756,18 @@ .. versionadded:: 2.3 -.. c:function:: void PyEval_AcquireThread(PyThreadState *tstate) +.. cfunction:: void PyEval_AcquireThread(PyThreadState *tstate) Acquire the global interpreter lock and set the current thread state to *tstate*, which should not be *NULL*. The lock must have been created earlier. If this thread already has the lock, deadlock ensues. - :c:func:`PyEval_RestoreThread` is a higher-level function which is always + :cfunc:`PyEval_RestoreThread` is a higher-level function which is always available (even when thread support isn't enabled or when threads have not been initialized). -.. c:function:: void PyEval_ReleaseThread(PyThreadState *tstate) +.. cfunction:: void PyEval_ReleaseThread(PyThreadState *tstate) Reset the current thread state to *NULL* and release the global interpreter lock. The lock must have been created earlier and must be held by the current @@ -779,29 +775,29 @@ that it represents the current thread state --- if it isn't, a fatal error is reported. - :c:func:`PyEval_SaveThread` is a higher-level function which is always + :cfunc:`PyEval_SaveThread` is a higher-level function which is always available (even when thread support isn't enabled or when threads have not been initialized). -.. c:function:: void PyEval_AcquireLock() +.. cfunction:: void PyEval_AcquireLock() Acquire the global interpreter lock. The lock must have been created earlier. If this thread already has the lock, a deadlock ensues. .. warning:: This function does not change the current thread state. Please use - :c:func:`PyEval_RestoreThread` or :c:func:`PyEval_AcquireThread` + :cfunc:`PyEval_RestoreThread` or :cfunc:`PyEval_AcquireThread` instead. -.. c:function:: void PyEval_ReleaseLock() +.. cfunction:: void PyEval_ReleaseLock() Release the global interpreter lock. The lock must have been created earlier. .. warning:: This function does not change the current thread state. Please use - :c:func:`PyEval_SaveThread` or :c:func:`PyEval_ReleaseThread` + :cfunc:`PyEval_SaveThread` or :cfunc:`PyEval_ReleaseThread` instead. @@ -812,11 +808,11 @@ are cases where you need to create several independent interpreters in the same process and perhaps even in the same thread. Sub-interpreters allow you to do that. You can switch between sub-interpreters using the -:c:func:`PyThreadState_Swap` function. You can create and destroy them +:cfunc:`PyThreadState_Swap` function. You can create and destroy them using the following functions: -.. c:function:: PyThreadState* Py_NewInterpreter() +.. cfunction:: PyThreadState* Py_NewInterpreter() .. index:: module: builtins @@ -858,13 +854,13 @@ and filled with the contents of this copy; the extension's ``init`` function is not called. Note that this is different from what happens when an extension is imported after the interpreter has been completely re-initialized by calling - :c:func:`Py_Finalize` and :c:func:`Py_Initialize`; in that case, the extension's + :cfunc:`Py_Finalize` and :cfunc:`Py_Initialize`; in that case, the extension's ``initmodule`` function *is* called again. .. index:: single: close() (in module os) -.. c:function:: void Py_EndInterpreter(PyThreadState *tstate) +.. cfunction:: void Py_EndInterpreter(PyThreadState *tstate) .. index:: single: Py_Finalize() @@ -873,7 +869,7 @@ states below. When the call returns, the current thread state is *NULL*. All thread states associated with this interpreter are destroyed. (The global interpreter lock must be held before calling this function and is still held - when it returns.) :c:func:`Py_Finalize` will destroy all sub-interpreters that + when it returns.) :cfunc:`Py_Finalize` will destroy all sub-interpreters that haven't been explicitly destroyed at that point. @@ -894,11 +890,11 @@ by such objects may affect the wrong (sub-)interpreter's dictionary of loaded modules. -Also note that combining this functionality with :c:func:`PyGILState_\*` APIs +Also note that combining this functionality with :cfunc:`PyGILState_\*` APIs is delicate, because these APIs assume a bijection between Python thread states and OS-level threads, an assumption broken by the presence of sub-interpreters. It is highly recommended that you don't switch sub-interpreters between a pair -of matching :c:func:`PyGILState_Ensure` and :c:func:`PyGILState_Release` calls. +of matching :cfunc:`PyGILState_Ensure` and :cfunc:`PyGILState_Release` calls. Furthermore, extensions (such as :mod:`ctypes`) using these APIs to allow calling of Python code from non-Python created threads will probably be broken when using sub-interpreters. @@ -909,45 +905,43 @@ A mechanism is provided to make asynchronous notifications to the main interpreter thread. These notifications take the form of a function -pointer and a void pointer argument. +pointer and a void argument. +.. index:: single: setcheckinterval() (in module sys) -.. c:function:: int Py_AddPendingCall(int (*func)(void *), void *arg) +Every check interval, when the global interpreter lock is released and +reacquired, Python will also call any such provided functions. This can be used +for example by asynchronous IO handlers. The notification can be scheduled from +a worker thread and the actual call than made at the earliest convenience by the +main thread where it has possession of the global interpreter lock and can +perform any Python API calls. + +.. cfunction:: int Py_AddPendingCall(int (*func)(void *), void *arg) .. index:: single: Py_AddPendingCall() - Schedule a function to be called from the main interpreter thread. On - success, 0 is returned and *func* is queued for being called in the - main thread. On failure, -1 is returned without setting any exception. + Post a notification to the Python main thread. If successful, *func* will be + called with the argument *arg* at the earliest convenience. *func* will be + called having the global interpreter lock held and can thus use the full + Python API and can take any action such as setting object attributes to + signal IO completion. It must return 0 on success, or -1 signalling an + exception. The notification function won't be interrupted to perform another + asynchronous notification recursively, but it can still be interrupted to + switch threads if the global interpreter lock is released, for example, if it + calls back into Python code. - When successfully queued, *func* will be *eventually* called from the - main interpreter thread with the argument *arg*. It will be called - asynchronously with respect to normally running Python code, but with - both these conditions met: + This function returns 0 on success in which case the notification has been + scheduled. Otherwise, for example if the notification buffer is full, it + returns -1 without setting any exception. - * on a :term:`bytecode` boundary; - * with the main thread holding the :term:`global interpreter lock` - (*func* can therefore use the full C API). - - *func* must return 0 on success, or -1 on failure with an exception - set. *func* won't be interrupted to perform another asynchronous - notification recursively, but it can still be interrupted to switch - threads if the global interpreter lock is released. - - This function doesn't need a current thread state to run, and it doesn't - need the global interpreter lock. - - .. warning:: - This is a low-level function, only useful for very special cases. - There is no guarantee that *func* will be called as quick as - possible. If the main thread is busy executing a system call, - *func* won't be called before the system call returns. This - function is generally **not** suitable for calling Python code from - arbitrary C threads. Instead, use the :ref:`PyGILState API`. + This function can be called on any thread, be it a Python thread or some + other system thread. If it is a Python thread, it doesn't matter if it holds + the global interpreter lock or not. .. versionadded:: 2.7 + .. _profiling: Profiling and Tracing @@ -970,10 +964,10 @@ in previous versions. -.. c:type:: int (*Py_tracefunc)(PyObject *obj, PyFrameObject *frame, int what, PyObject *arg) +.. ctype:: int (*Py_tracefunc)(PyObject *obj, PyFrameObject *frame, int what, PyObject *arg) - The type of the trace function registered using :c:func:`PyEval_SetProfile` and - :c:func:`PyEval_SetTrace`. The first parameter is the object passed to the + The type of the trace function registered using :cfunc:`PyEval_SetProfile` and + :cfunc:`PyEval_SetTrace`. The first parameter is the object passed to the registration function as *obj*, *frame* is the frame object to which the event pertains, *what* is one of the constants :const:`PyTrace_CALL`, :const:`PyTrace_EXCEPTION`, :const:`PyTrace_LINE`, :const:`PyTrace_RETURN`, @@ -1001,18 +995,18 @@ +------------------------------+--------------------------------------+ -.. c:var:: int PyTrace_CALL +.. cvar:: int PyTrace_CALL - The value of the *what* parameter to a :c:type:`Py_tracefunc` function when a new + The value of the *what* parameter to a :ctype:`Py_tracefunc` function when a new call to a function or method is being reported, or a new entry into a generator. Note that the creation of the iterator for a generator function is not reported as there is no control transfer to the Python bytecode in the corresponding frame. -.. c:var:: int PyTrace_EXCEPTION +.. cvar:: int PyTrace_EXCEPTION - The value of the *what* parameter to a :c:type:`Py_tracefunc` function when an + The value of the *what* parameter to a :ctype:`Py_tracefunc` function when an exception has been raised. The callback function is called with this value for *what* when after any bytecode is processed after which the exception becomes set within the frame being executed. The effect of this is that as exception @@ -1021,37 +1015,37 @@ these events; they are not needed by the profiler. -.. c:var:: int PyTrace_LINE +.. cvar:: int PyTrace_LINE The value passed as the *what* parameter to a trace function (but not a profiling function) when a line-number event is being reported. -.. c:var:: int PyTrace_RETURN +.. cvar:: int PyTrace_RETURN - The value for the *what* parameter to :c:type:`Py_tracefunc` functions when a + The value for the *what* parameter to :ctype:`Py_tracefunc` functions when a call is returning without propagating an exception. -.. c:var:: int PyTrace_C_CALL +.. cvar:: int PyTrace_C_CALL - The value for the *what* parameter to :c:type:`Py_tracefunc` functions when a C + The value for the *what* parameter to :ctype:`Py_tracefunc` functions when a C function is about to be called. -.. c:var:: int PyTrace_C_EXCEPTION +.. cvar:: int PyTrace_C_EXCEPTION - The value for the *what* parameter to :c:type:`Py_tracefunc` functions when a C + The value for the *what* parameter to :ctype:`Py_tracefunc` functions when a C function has raised an exception. -.. c:var:: int PyTrace_C_RETURN +.. cvar:: int PyTrace_C_RETURN - The value for the *what* parameter to :c:type:`Py_tracefunc` functions when a C + The value for the *what* parameter to :ctype:`Py_tracefunc` functions when a C function has returned. -.. c:function:: void PyEval_SetProfile(Py_tracefunc func, PyObject *obj) +.. cfunction:: void PyEval_SetProfile(Py_tracefunc func, PyObject *obj) Set the profiler function to *func*. The *obj* parameter is passed to the function as its first parameter, and may be any Python object, or *NULL*. If @@ -1061,13 +1055,13 @@ events. -.. c:function:: void PyEval_SetTrace(Py_tracefunc func, PyObject *obj) +.. cfunction:: void PyEval_SetTrace(Py_tracefunc func, PyObject *obj) Set the tracing function to *func*. This is similar to - :c:func:`PyEval_SetProfile`, except the tracing function does receive line-number + :cfunc:`PyEval_SetProfile`, except the tracing function does receive line-number events. -.. c:function:: PyObject* PyEval_GetCallStats(PyObject *self) +.. cfunction:: PyObject* PyEval_GetCallStats(PyObject *self) Return a tuple of function call counts. There are constants defined for the positions within the tuple: @@ -1119,14 +1113,14 @@ These functions are only intended to be used by advanced debugging tools. -.. c:function:: PyInterpreterState* PyInterpreterState_Head() +.. cfunction:: PyInterpreterState* PyInterpreterState_Head() Return the interpreter state object at the head of the list of all such objects. .. versionadded:: 2.2 -.. c:function:: PyInterpreterState* PyInterpreterState_Next(PyInterpreterState *interp) +.. cfunction:: PyInterpreterState* PyInterpreterState_Next(PyInterpreterState *interp) Return the next interpreter state object after *interp* from the list of all such objects. @@ -1134,18 +1128,18 @@ .. versionadded:: 2.2 -.. c:function:: PyThreadState * PyInterpreterState_ThreadHead(PyInterpreterState *interp) +.. cfunction:: PyThreadState * PyInterpreterState_ThreadHead(PyInterpreterState *interp) - Return the a pointer to the first :c:type:`PyThreadState` object in the list of + Return the a pointer to the first :ctype:`PyThreadState` object in the list of threads associated with the interpreter *interp*. .. versionadded:: 2.2 -.. c:function:: PyThreadState* PyThreadState_Next(PyThreadState *tstate) +.. cfunction:: PyThreadState* PyThreadState_Next(PyThreadState *tstate) Return the next thread state object after *tstate* from the list of all such - objects belonging to the same :c:type:`PyInterpreterState` object. + objects belonging to the same :ctype:`PyInterpreterState` object. .. versionadded:: 2.2 diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/c-api/int.rst --- a/Doc/c-api/int.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/c-api/int.rst Sun Jul 20 10:52:46 2014 -0400 @@ -8,39 +8,39 @@ .. index:: object: integer -.. c:type:: PyIntObject +.. ctype:: PyIntObject - This subtype of :c:type:`PyObject` represents a Python integer object. + This subtype of :ctype:`PyObject` represents a Python integer object. -.. c:var:: PyTypeObject PyInt_Type +.. cvar:: PyTypeObject PyInt_Type .. index:: single: IntType (in modules types) - This instance of :c:type:`PyTypeObject` represents the Python plain integer type. + This instance of :ctype:`PyTypeObject` represents the Python plain integer type. This is the same object as ``int`` and ``types.IntType``. -.. c:function:: int PyInt_Check(PyObject *o) +.. cfunction:: int PyInt_Check(PyObject *o) - Return true if *o* is of type :c:data:`PyInt_Type` or a subtype of - :c:data:`PyInt_Type`. + Return true if *o* is of type :cdata:`PyInt_Type` or a subtype of + :cdata:`PyInt_Type`. .. versionchanged:: 2.2 Allowed subtypes to be accepted. -.. c:function:: int PyInt_CheckExact(PyObject *o) +.. cfunction:: int PyInt_CheckExact(PyObject *o) - Return true if *o* is of type :c:data:`PyInt_Type`, but not a subtype of - :c:data:`PyInt_Type`. + Return true if *o* is of type :cdata:`PyInt_Type`, but not a subtype of + :cdata:`PyInt_Type`. .. versionadded:: 2.2 -.. c:function:: PyObject* PyInt_FromString(char *str, char **pend, int base) +.. cfunction:: PyObject* PyInt_FromString(char *str, char **pend, int base) - Return a new :c:type:`PyIntObject` or :c:type:`PyLongObject` based on the string + Return a new :ctype:`PyIntObject` or :ctype:`PyLongObject` based on the string value in *str*, which is interpreted according to the radix in *base*. If *pend* is non-*NULL*, ``*pend`` will point to the first character in *str* which follows the representation of the number. If *base* is ``0``, the radix will be @@ -49,13 +49,13 @@ 8 will be used; otherwise radix 10 will be used. If *base* is not ``0``, it must be between ``2`` and ``36``, inclusive. Leading spaces are ignored. If there are no digits, :exc:`ValueError` will be raised. If the string represents - a number too large to be contained within the machine's :c:type:`long int` type - and overflow warnings are being suppressed, a :c:type:`PyLongObject` will be + a number too large to be contained within the machine's :ctype:`long int` type + and overflow warnings are being suppressed, a :ctype:`PyLongObject` will be returned. If overflow warnings are not being suppressed, *NULL* will be returned in this case. -.. c:function:: PyObject* PyInt_FromLong(long ival) +.. cfunction:: PyObject* PyInt_FromLong(long ival) Create a new integer object with a value of *ival*. @@ -66,7 +66,7 @@ undefined. :-) -.. c:function:: PyObject* PyInt_FromSsize_t(Py_ssize_t ival) +.. cfunction:: PyObject* PyInt_FromSsize_t(Py_ssize_t ival) Create a new integer object with a value of *ival*. If the value is larger than ``LONG_MAX`` or smaller than ``LONG_MIN``, a long integer object is @@ -75,7 +75,7 @@ .. versionadded:: 2.5 -.. c:function:: PyObject* PyInt_FromSize_t(size_t ival) +.. cfunction:: PyObject* PyInt_FromSize_t(size_t ival) Create a new integer object with a value of *ival*. If the value exceeds ``LONG_MAX``, a long integer object is returned. @@ -83,47 +83,47 @@ .. versionadded:: 2.5 -.. c:function:: long PyInt_AsLong(PyObject *io) +.. cfunction:: long PyInt_AsLong(PyObject *io) - Will first attempt to cast the object to a :c:type:`PyIntObject`, if it is not + Will first attempt to cast the object to a :ctype:`PyIntObject`, if it is not already one, and then return its value. If there is an error, ``-1`` is returned, and the caller should check ``PyErr_Occurred()`` to find out whether there was an error, or whether the value just happened to be -1. -.. c:function:: long PyInt_AS_LONG(PyObject *io) +.. cfunction:: long PyInt_AS_LONG(PyObject *io) Return the value of the object *io*. No error checking is performed. -.. c:function:: unsigned long PyInt_AsUnsignedLongMask(PyObject *io) +.. cfunction:: unsigned long PyInt_AsUnsignedLongMask(PyObject *io) - Will first attempt to cast the object to a :c:type:`PyIntObject` or - :c:type:`PyLongObject`, if it is not already one, and then return its value as + Will first attempt to cast the object to a :ctype:`PyIntObject` or + :ctype:`PyLongObject`, if it is not already one, and then return its value as unsigned long. This function does not check for overflow. .. versionadded:: 2.3 -.. c:function:: unsigned PY_LONG_LONG PyInt_AsUnsignedLongLongMask(PyObject *io) +.. cfunction:: unsigned PY_LONG_LONG PyInt_AsUnsignedLongLongMask(PyObject *io) - Will first attempt to cast the object to a :c:type:`PyIntObject` or - :c:type:`PyLongObject`, if it is not already one, and then return its value as + Will first attempt to cast the object to a :ctype:`PyIntObject` or + :ctype:`PyLongObject`, if it is not already one, and then return its value as unsigned long long, without checking for overflow. .. versionadded:: 2.3 -.. c:function:: Py_ssize_t PyInt_AsSsize_t(PyObject *io) +.. cfunction:: Py_ssize_t PyInt_AsSsize_t(PyObject *io) - Will first attempt to cast the object to a :c:type:`PyIntObject` or - :c:type:`PyLongObject`, if it is not already one, and then return its value as - :c:type:`Py_ssize_t`. + Will first attempt to cast the object to a :ctype:`PyIntObject` or + :ctype:`PyLongObject`, if it is not already one, and then return its value as + :ctype:`Py_ssize_t`. .. versionadded:: 2.5 -.. c:function:: long PyInt_GetMax() +.. cfunction:: long PyInt_GetMax() .. index:: single: LONG_MAX @@ -131,7 +131,7 @@ (:const:`LONG_MAX`, as defined in the system header files). -.. c:function:: int PyInt_ClearFreeList() +.. cfunction:: int PyInt_ClearFreeList() Clear the integer free list. Return the number of items that could not be freed. diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/c-api/intro.rst --- a/Doc/c-api/intro.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/c-api/intro.rst Sun Jul 20 10:52:46 2014 -0400 @@ -88,15 +88,15 @@ .. index:: object: type Most Python/C API functions have one or more arguments as well as a return value -of type :c:type:`PyObject\*`. This type is a pointer to an opaque data type +of type :ctype:`PyObject\*`. This type is a pointer to an opaque data type representing an arbitrary Python object. Since all Python object types are treated the same way by the Python language in most situations (e.g., assignments, scope rules, and argument passing), it is only fitting that they should be represented by a single C type. Almost all Python objects live on the heap: you never declare an automatic or static variable of type -:c:type:`PyObject`, only pointer variables of type :c:type:`PyObject\*` can be +:ctype:`PyObject`, only pointer variables of type :ctype:`PyObject\*` can be declared. The sole exception are the type objects; since these must never be -deallocated, they are typically static :c:type:`PyTypeObject` objects. +deallocated, they are typically static :ctype:`PyTypeObject` objects. All Python objects (even Python integers) have a :dfn:`type` and a :dfn:`reference count`. An object's type determines what kind of object it is @@ -127,8 +127,8 @@ single: Py_DECREF() Reference counts are always manipulated explicitly. The normal way is to use -the macro :c:func:`Py_INCREF` to increment an object's reference count by one, -and :c:func:`Py_DECREF` to decrement it by one. The :c:func:`Py_DECREF` macro +the macro :cfunc:`Py_INCREF` to increment an object's reference count by one, +and :cfunc:`Py_DECREF` to decrement it by one. The :cfunc:`Py_DECREF` macro is considerably more complex than the incref one, since it must check whether the reference count becomes zero and then cause the object's deallocator to be called. The deallocator is a function pointer contained in the object's type @@ -159,13 +159,13 @@ conceivably remove the object from the list, decrementing its reference count and possible deallocating it. The real danger is that innocent-looking operations may invoke arbitrary Python code which could do this; there is a code -path which allows control to flow back to the user from a :c:func:`Py_DECREF`, so +path which allows control to flow back to the user from a :cfunc:`Py_DECREF`, so almost any operation is potentially dangerous. A safe approach is to always use the generic operations (functions whose name begins with ``PyObject_``, ``PyNumber_``, ``PySequence_`` or ``PyMapping_``). These operations always increment the reference count of the object they return. -This leaves the caller with the responsibility to call :c:func:`Py_DECREF` when +This leaves the caller with the responsibility to call :cfunc:`Py_DECREF` when they are done with the result; this soon becomes second nature. @@ -180,7 +180,7 @@ reference" means being responsible for calling Py_DECREF on it when the reference is no longer needed. Ownership can also be transferred, meaning that the code that receives ownership of the reference then becomes responsible for -eventually decref'ing it by calling :c:func:`Py_DECREF` or :c:func:`Py_XDECREF` +eventually decref'ing it by calling :cfunc:`Py_DECREF` or :cfunc:`Py_XDECREF` when it's no longer needed---or passing on this responsibility (usually to its caller). When a function passes ownership of a reference on to its caller, the caller is said to receive a *new* reference. When no ownership is transferred, @@ -198,7 +198,7 @@ single: PyTuple_SetItem() Few functions steal references; the two notable exceptions are -:c:func:`PyList_SetItem` and :c:func:`PyTuple_SetItem`, which steal a reference +:cfunc:`PyList_SetItem` and :cfunc:`PyTuple_SetItem`, which steal a reference to the item (but not to the tuple or list into which the item is put!). These functions were designed to steal a reference because of a common idiom for populating a tuple or list with newly created objects; for example, the code to @@ -212,21 +212,21 @@ PyTuple_SetItem(t, 1, PyInt_FromLong(2L)); PyTuple_SetItem(t, 2, PyString_FromString("three")); -Here, :c:func:`PyInt_FromLong` returns a new reference which is immediately -stolen by :c:func:`PyTuple_SetItem`. When you want to keep using an object -although the reference to it will be stolen, use :c:func:`Py_INCREF` to grab +Here, :cfunc:`PyInt_FromLong` returns a new reference which is immediately +stolen by :cfunc:`PyTuple_SetItem`. When you want to keep using an object +although the reference to it will be stolen, use :cfunc:`Py_INCREF` to grab another reference before calling the reference-stealing function. -Incidentally, :c:func:`PyTuple_SetItem` is the *only* way to set tuple items; -:c:func:`PySequence_SetItem` and :c:func:`PyObject_SetItem` refuse to do this +Incidentally, :cfunc:`PyTuple_SetItem` is the *only* way to set tuple items; +:cfunc:`PySequence_SetItem` and :cfunc:`PyObject_SetItem` refuse to do this since tuples are an immutable data type. You should only use -:c:func:`PyTuple_SetItem` for tuples that you are creating yourself. +:cfunc:`PyTuple_SetItem` for tuples that you are creating yourself. -Equivalent code for populating a list can be written using :c:func:`PyList_New` -and :c:func:`PyList_SetItem`. +Equivalent code for populating a list can be written using :cfunc:`PyList_New` +and :cfunc:`PyList_SetItem`. However, in practice, you will rarely use these ways of creating and populating -a tuple or list. There's a generic function, :c:func:`Py_BuildValue`, that can +a tuple or list. There's a generic function, :cfunc:`Py_BuildValue`, that can create most common objects from C values, directed by a :dfn:`format string`. For example, the above two blocks of code could be replaced by the following (which also takes care of the error checking):: @@ -236,7 +236,7 @@ tuple = Py_BuildValue("(iis)", 1, 2, "three"); list = Py_BuildValue("[iis]", 1, 2, "three"); -It is much more common to use :c:func:`PyObject_SetItem` and friends with items +It is much more common to use :cfunc:`PyObject_SetItem` and friends with items whose references you are only borrowing, like arguments that were passed in to the function you are writing. In that case, their behaviour regarding reference counts is much saner, since you don't have to increment a reference count so you @@ -255,10 +255,8 @@ PyObject *index = PyInt_FromLong(i); if (!index) return -1; - if (PyObject_SetItem(target, index, item) < 0) { - Py_DECREF(index); + if (PyObject_SetItem(target, index, item) < 0) return -1; - } Py_DECREF(index); } return 0; @@ -272,15 +270,15 @@ you ownership of the reference. The reason is simple: in many cases, the returned object is created on the fly, and the reference you get is the only reference to the object. Therefore, the generic functions that return object -references, like :c:func:`PyObject_GetItem` and :c:func:`PySequence_GetItem`, +references, like :cfunc:`PyObject_GetItem` and :cfunc:`PySequence_GetItem`, always return a new reference (the caller becomes the owner of the reference). It is important to realize that whether you own a reference returned by a function depends on which function you call only --- *the plumage* (the type of the object passed as an argument to the function) *doesn't enter into it!* -Thus, if you extract an item from a list using :c:func:`PyList_GetItem`, you +Thus, if you extract an item from a list using :cfunc:`PyList_GetItem`, you don't own the reference --- but if you obtain the same item from the same list -using :c:func:`PySequence_GetItem` (which happens to take exactly the same +using :cfunc:`PySequence_GetItem` (which happens to take exactly the same arguments), you do own a reference to the returned object. .. index:: @@ -288,8 +286,8 @@ single: PySequence_GetItem() Here is an example of how you could write a function that computes the sum of -the items in a list of integers; once using :c:func:`PyList_GetItem`, and once -using :c:func:`PySequence_GetItem`. :: +the items in a list of integers; once using :cfunc:`PyList_GetItem`, and once +using :cfunc:`PySequence_GetItem`. :: long sum_list(PyObject *list) @@ -342,8 +340,8 @@ ----- There are few other data types that play a significant role in the Python/C -API; most are simple C types such as :c:type:`int`, :c:type:`long`, -:c:type:`double` and :c:type:`char\*`. A few structure types are used to +API; most are simple C types such as :ctype:`int`, :ctype:`long`, +:ctype:`double` and :ctype:`char\*`. A few structure types are used to describe static tables used to list the functions exported by a module or the data attributes of a new object type, and another is used to describe the value of a complex number. These will be discussed together with the functions that @@ -372,7 +370,7 @@ A few functions return a Boolean true/false result, with false indicating an error. Very few functions return no explicit error indicator or have an ambiguous return value, and require explicit testing for errors with -:c:func:`PyErr_Occurred`. These exceptions are always explicitly documented. +:cfunc:`PyErr_Occurred`. These exceptions are always explicitly documented. .. index:: single: PyErr_SetString() @@ -381,11 +379,11 @@ Exception state is maintained in per-thread storage (this is equivalent to using global storage in an unthreaded application). A thread can be in one of two states: an exception has occurred, or not. The function -:c:func:`PyErr_Occurred` can be used to check for this: it returns a borrowed +:cfunc:`PyErr_Occurred` can be used to check for this: it returns a borrowed reference to the exception type object when an exception has occurred, and *NULL* otherwise. There are a number of functions to set the exception state: -:c:func:`PyErr_SetString` is the most common (though not the most general) -function to set the exception state, and :c:func:`PyErr_Clear` clears the +:cfunc:`PyErr_SetString` is the most common (though not the most general) +function to set the exception state, and :cfunc:`PyErr_Clear` clears the exception state. .. index:: @@ -426,7 +424,7 @@ .. index:: single: sum_sequence() A simple example of detecting exceptions and passing them on is shown in the -:c:func:`sum_sequence` example above. It so happens that this example doesn't +:cfunc:`sum_sequence` example above. It so happens that that example doesn't need to clean up any owned references when it detects an error. The following example function shows some error cleanup. First, to remind you why you like Python, we show the equivalent Python code:: @@ -493,10 +491,10 @@ single: Py_XDECREF() This example represents an endorsed use of the ``goto`` statement in C! -It illustrates the use of :c:func:`PyErr_ExceptionMatches` and -:c:func:`PyErr_Clear` to handle specific exceptions, and the use of -:c:func:`Py_XDECREF` to dispose of owned references that may be *NULL* (note the -``'X'`` in the name; :c:func:`Py_DECREF` would crash when confronted with a +It illustrates the use of :cfunc:`PyErr_ExceptionMatches` and +:cfunc:`PyErr_Clear` to handle specific exceptions, and the use of +:cfunc:`Py_XDECREF` to dispose of owned references that may be *NULL* (note the +``'X'`` in the name; :cfunc:`Py_DECREF` would crash when confronted with a *NULL* reference). It is important that the variables used to hold owned references are initialized to *NULL* for this to work; likewise, the proposed return value is initialized to ``-1`` (failure) and only set to success after @@ -522,20 +520,20 @@ triple: module; search; path single: path (in module sys) -The basic initialization function is :c:func:`Py_Initialize`. This initializes +The basic initialization function is :cfunc:`Py_Initialize`. This initializes the table of loaded modules, and creates the fundamental modules :mod:`__builtin__`, :mod:`__main__`, :mod:`sys`, and :mod:`exceptions`. It also initializes the module search path (``sys.path``). .. index:: single: PySys_SetArgvEx() -:c:func:`Py_Initialize` does not set the "script argument list" (``sys.argv``). +:cfunc:`Py_Initialize` does not set the "script argument list" (``sys.argv``). If this variable is needed by Python code that will be executed later, it must be set explicitly with a call to ``PySys_SetArgvEx(argc, argv, updatepath)`` -after the call to :c:func:`Py_Initialize`. +after the call to :cfunc:`Py_Initialize`. On most systems (in particular, on Unix and Windows, although the details are -slightly different), :c:func:`Py_Initialize` calculates the module search path +slightly different), :cfunc:`Py_Initialize` calculates the module search path based upon its best guess for the location of the standard Python interpreter executable, assuming that the Python library is found in a fixed location relative to the Python interpreter executable. In particular, it looks for a @@ -559,22 +557,22 @@ single: Py_GetProgramFullPath() The embedding application can steer the search by calling -``Py_SetProgramName(file)`` *before* calling :c:func:`Py_Initialize`. Note that +``Py_SetProgramName(file)`` *before* calling :cfunc:`Py_Initialize`. Note that :envvar:`PYTHONHOME` still overrides this and :envvar:`PYTHONPATH` is still inserted in front of the standard path. An application that requires total -control has to provide its own implementation of :c:func:`Py_GetPath`, -:c:func:`Py_GetPrefix`, :c:func:`Py_GetExecPrefix`, and -:c:func:`Py_GetProgramFullPath` (all defined in :file:`Modules/getpath.c`). +control has to provide its own implementation of :cfunc:`Py_GetPath`, +:cfunc:`Py_GetPrefix`, :cfunc:`Py_GetExecPrefix`, and +:cfunc:`Py_GetProgramFullPath` (all defined in :file:`Modules/getpath.c`). .. index:: single: Py_IsInitialized() Sometimes, it is desirable to "uninitialize" Python. For instance, the application may want to start over (make another call to -:c:func:`Py_Initialize`) or the application is simply done with its use of +:cfunc:`Py_Initialize`) or the application is simply done with its use of Python and wants to free memory allocated by Python. This can be accomplished -by calling :c:func:`Py_Finalize`. The function :c:func:`Py_IsInitialized` returns +by calling :cfunc:`Py_Finalize`. The function :cfunc:`Py_IsInitialized` returns true if Python is currently in the initialized state. More information about -these functions is given in a later chapter. Notice that :c:func:`Py_Finalize` +these functions is given in a later chapter. Notice that :cfunc:`Py_Finalize` does *not* free all memory allocated by the Python interpreter, e.g. memory allocated by extension modules currently cannot be released. @@ -594,11 +592,11 @@ allocator, or low-level profiling of the main interpreter loop. Only the most frequently-used builds will be described in the remainder of this section. -Compiling the interpreter with the :c:macro:`Py_DEBUG` macro defined produces -what is generally meant by "a debug build" of Python. :c:macro:`Py_DEBUG` is +Compiling the interpreter with the :cmacro:`Py_DEBUG` macro defined produces +what is generally meant by "a debug build" of Python. :cmacro:`Py_DEBUG` is enabled in the Unix build by adding ``--with-pydebug`` to the :file:`./configure` command. It is also implied by the presence of the -not-Python-specific :c:macro:`_DEBUG` macro. When :c:macro:`Py_DEBUG` is enabled +not-Python-specific :cmacro:`_DEBUG` macro. When :cmacro:`Py_DEBUG` is enabled in the Unix build, compiler optimization is disabled. In addition to the reference count debugging described below, the following @@ -627,11 +625,11 @@ There may be additional checks not mentioned here. -Defining :c:macro:`Py_TRACE_REFS` enables reference tracing. When defined, a +Defining :cmacro:`Py_TRACE_REFS` enables reference tracing. When defined, a circular doubly linked list of active objects is maintained by adding two extra -fields to every :c:type:`PyObject`. Total allocations are tracked as well. Upon +fields to every :ctype:`PyObject`. Total allocations are tracked as well. Upon exit, all existing references are printed. (In interactive mode this happens -after every statement run by the interpreter.) Implied by :c:macro:`Py_DEBUG`. +after every statement run by the interpreter.) Implied by :cmacro:`Py_DEBUG`. Please refer to :file:`Misc/SpecialBuilds.txt` in the Python source distribution for more detailed information. diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/c-api/iter.rst --- a/Doc/c-api/iter.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/c-api/iter.rst Sun Jul 20 10:52:46 2014 -0400 @@ -7,20 +7,21 @@ .. versionadded:: 2.2 -There are two functions specifically for working with iterators. +There are only a couple of functions specifically for working with iterators. -.. c:function:: int PyIter_Check(PyObject *o) +.. cfunction:: int PyIter_Check(PyObject *o) Return true if the object *o* supports the iterator protocol. -.. c:function:: PyObject* PyIter_Next(PyObject *o) +.. cfunction:: PyObject* PyIter_Next(PyObject *o) - Return the next value from the iteration *o*. The object must be an iterator - (it is up to the caller to check this). If there are no remaining values, - returns *NULL* with no exception set. If an error occurs while retrieving - the item, returns *NULL* and passes along the exception. + Return the next value from the iteration *o*. If the object is an iterator, + this retrieves the next value from the iteration, and returns *NULL* with no + exception set if there are no remaining items. If the object is not an + iterator, :exc:`TypeError` is raised, or if there is an error in retrieving the + item, returns *NULL* and passes along the exception. To write a loop which iterates over an iterator, the C code should look something like this:: diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/c-api/iterator.rst --- a/Doc/c-api/iterator.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/c-api/iterator.rst Sun Jul 20 10:52:46 2014 -0400 @@ -12,23 +12,23 @@ sentinel value is returned. -.. c:var:: PyTypeObject PySeqIter_Type +.. cvar:: PyTypeObject PySeqIter_Type - Type object for iterator objects returned by :c:func:`PySeqIter_New` and the + Type object for iterator objects returned by :cfunc:`PySeqIter_New` and the one-argument form of the :func:`iter` built-in function for built-in sequence types. .. versionadded:: 2.2 -.. c:function:: int PySeqIter_Check(op) +.. cfunction:: int PySeqIter_Check(op) - Return true if the type of *op* is :c:data:`PySeqIter_Type`. + Return true if the type of *op* is :cdata:`PySeqIter_Type`. .. versionadded:: 2.2 -.. c:function:: PyObject* PySeqIter_New(PyObject *seq) +.. cfunction:: PyObject* PySeqIter_New(PyObject *seq) Return an iterator that works with a general sequence object, *seq*. The iteration ends when the sequence raises :exc:`IndexError` for the subscripting @@ -37,22 +37,22 @@ .. versionadded:: 2.2 -.. c:var:: PyTypeObject PyCallIter_Type +.. cvar:: PyTypeObject PyCallIter_Type - Type object for iterator objects returned by :c:func:`PyCallIter_New` and the + Type object for iterator objects returned by :cfunc:`PyCallIter_New` and the two-argument form of the :func:`iter` built-in function. .. versionadded:: 2.2 -.. c:function:: int PyCallIter_Check(op) +.. cfunction:: int PyCallIter_Check(op) - Return true if the type of *op* is :c:data:`PyCallIter_Type`. + Return true if the type of *op* is :cdata:`PyCallIter_Type`. .. versionadded:: 2.2 -.. c:function:: PyObject* PyCallIter_New(PyObject *callable, PyObject *sentinel) +.. cfunction:: PyObject* PyCallIter_New(PyObject *callable, PyObject *sentinel) Return a new iterator. The first parameter, *callable*, can be any Python callable object that can be called with no parameters; each call to it should diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/c-api/list.rst --- a/Doc/c-api/list.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/c-api/list.rst Sun Jul 20 10:52:46 2014 -0400 @@ -8,18 +8,18 @@ .. index:: object: list -.. c:type:: PyListObject +.. ctype:: PyListObject - This subtype of :c:type:`PyObject` represents a Python list object. + This subtype of :ctype:`PyObject` represents a Python list object. -.. c:var:: PyTypeObject PyList_Type +.. cvar:: PyTypeObject PyList_Type - This instance of :c:type:`PyTypeObject` represents the Python list type. This + This instance of :ctype:`PyTypeObject` represents the Python list type. This is the same object as ``list`` in the Python layer. -.. c:function:: int PyList_Check(PyObject *p) +.. cfunction:: int PyList_Check(PyObject *p) Return true if *p* is a list object or an instance of a subtype of the list type. @@ -28,7 +28,7 @@ Allowed subtypes to be accepted. -.. c:function:: int PyList_CheckExact(PyObject *p) +.. cfunction:: int PyList_CheckExact(PyObject *p) Return true if *p* is a list object, but not an instance of a subtype of the list type. @@ -36,7 +36,7 @@ .. versionadded:: 2.2 -.. c:function:: PyObject* PyList_New(Py_ssize_t len) +.. cfunction:: PyObject* PyList_New(Py_ssize_t len) Return a new list of length *len* on success, or *NULL* on failure. @@ -44,15 +44,15 @@ If *len* is greater than zero, the returned list object's items are set to ``NULL``. Thus you cannot use abstract API functions such as - :c:func:`PySequence_SetItem` or expose the object to Python code before - setting all items to a real object with :c:func:`PyList_SetItem`. + :cfunc:`PySequence_SetItem` or expose the object to Python code before + setting all items to a real object with :cfunc:`PyList_SetItem`. .. versionchanged:: 2.5 - This function used an :c:type:`int` for *size*. This might require + This function used an :ctype:`int` for *size*. This might require changes in your code for properly supporting 64-bit systems. -.. c:function:: Py_ssize_t PyList_Size(PyObject *list) +.. cfunction:: Py_ssize_t PyList_Size(PyObject *list) .. index:: builtin: len @@ -60,20 +60,20 @@ ``len(list)`` on a list object. .. versionchanged:: 2.5 - This function returned an :c:type:`int`. This might require changes in + This function returned an :ctype:`int`. This might require changes in your code for properly supporting 64-bit systems. -.. c:function:: Py_ssize_t PyList_GET_SIZE(PyObject *list) +.. cfunction:: Py_ssize_t PyList_GET_SIZE(PyObject *list) - Macro form of :c:func:`PyList_Size` without error checking. + Macro form of :cfunc:`PyList_Size` without error checking. .. versionchanged:: 2.5 - This macro returned an :c:type:`int`. This might require changes in your + This macro returned an :ctype:`int`. This might require changes in your code for properly supporting 64-bit systems. -.. c:function:: PyObject* PyList_GetItem(PyObject *list, Py_ssize_t index) +.. cfunction:: PyObject* PyList_GetItem(PyObject *list, Py_ssize_t index) Return the object at position *index* in the list pointed to by *list*. The position must be positive, indexing from the end of the list is not @@ -81,20 +81,20 @@ :exc:`IndexError` exception. .. versionchanged:: 2.5 - This function used an :c:type:`int` for *index*. This might require + This function used an :ctype:`int` for *index*. This might require changes in your code for properly supporting 64-bit systems. -.. c:function:: PyObject* PyList_GET_ITEM(PyObject *list, Py_ssize_t i) +.. cfunction:: PyObject* PyList_GET_ITEM(PyObject *list, Py_ssize_t i) - Macro form of :c:func:`PyList_GetItem` without error checking. + Macro form of :cfunc:`PyList_GetItem` without error checking. .. versionchanged:: 2.5 - This macro used an :c:type:`int` for *i*. This might require changes in + This macro used an :ctype:`int` for *i*. This might require changes in your code for properly supporting 64-bit systems. -.. c:function:: int PyList_SetItem(PyObject *list, Py_ssize_t index, PyObject *item) +.. cfunction:: int PyList_SetItem(PyObject *list, Py_ssize_t index, PyObject *item) Set the item at index *index* in list to *item*. Return ``0`` on success or ``-1`` on failure. @@ -105,46 +105,46 @@ an item already in the list at the affected position. .. versionchanged:: 2.5 - This function used an :c:type:`int` for *index*. This might require + This function used an :ctype:`int` for *index*. This might require changes in your code for properly supporting 64-bit systems. -.. c:function:: void PyList_SET_ITEM(PyObject *list, Py_ssize_t i, PyObject *o) +.. cfunction:: void PyList_SET_ITEM(PyObject *list, Py_ssize_t i, PyObject *o) - Macro form of :c:func:`PyList_SetItem` without error checking. This is + Macro form of :cfunc:`PyList_SetItem` without error checking. This is normally only used to fill in new lists where there is no previous content. .. note:: This macro "steals" a reference to *item*, and, unlike - :c:func:`PyList_SetItem`, does *not* discard a reference to any item that + :cfunc:`PyList_SetItem`, does *not* discard a reference to any item that it being replaced; any reference in *list* at position *i* will be leaked. .. versionchanged:: 2.5 - This macro used an :c:type:`int` for *i*. This might require + This macro used an :ctype:`int` for *i*. This might require changes in your code for properly supporting 64-bit systems. -.. c:function:: int PyList_Insert(PyObject *list, Py_ssize_t index, PyObject *item) +.. cfunction:: int PyList_Insert(PyObject *list, Py_ssize_t index, PyObject *item) Insert the item *item* into list *list* in front of index *index*. Return ``0`` if successful; return ``-1`` and set an exception if unsuccessful. Analogous to ``list.insert(index, item)``. .. versionchanged:: 2.5 - This function used an :c:type:`int` for *index*. This might require + This function used an :ctype:`int` for *index*. This might require changes in your code for properly supporting 64-bit systems. -.. c:function:: int PyList_Append(PyObject *list, PyObject *item) +.. cfunction:: int PyList_Append(PyObject *list, PyObject *item) Append the object *item* at the end of list *list*. Return ``0`` if successful; return ``-1`` and set an exception if unsuccessful. Analogous to ``list.append(item)``. -.. c:function:: PyObject* PyList_GetSlice(PyObject *list, Py_ssize_t low, Py_ssize_t high) +.. cfunction:: PyObject* PyList_GetSlice(PyObject *list, Py_ssize_t low, Py_ssize_t high) Return a list of the objects in *list* containing the objects *between* *low* and *high*. Return *NULL* and set an exception if unsuccessful. Analogous @@ -152,11 +152,11 @@ supported. .. versionchanged:: 2.5 - This function used an :c:type:`int` for *low* and *high*. This might + This function used an :ctype:`int` for *low* and *high*. This might require changes in your code for properly supporting 64-bit systems. -.. c:function:: int PyList_SetSlice(PyObject *list, Py_ssize_t low, Py_ssize_t high, PyObject *itemlist) +.. cfunction:: int PyList_SetSlice(PyObject *list, Py_ssize_t low, Py_ssize_t high, PyObject *itemlist) Set the slice of *list* between *low* and *high* to the contents of *itemlist*. Analogous to ``list[low:high] = itemlist``. The *itemlist* may @@ -165,23 +165,23 @@ slicing from Python, are not supported. .. versionchanged:: 2.5 - This function used an :c:type:`int` for *low* and *high*. This might + This function used an :ctype:`int` for *low* and *high*. This might require changes in your code for properly supporting 64-bit systems. -.. c:function:: int PyList_Sort(PyObject *list) +.. cfunction:: int PyList_Sort(PyObject *list) Sort the items of *list* in place. Return ``0`` on success, ``-1`` on failure. This is equivalent to ``list.sort()``. -.. c:function:: int PyList_Reverse(PyObject *list) +.. cfunction:: int PyList_Reverse(PyObject *list) Reverse the items of *list* in place. Return ``0`` on success, ``-1`` on failure. This is the equivalent of ``list.reverse()``. -.. c:function:: PyObject* PyList_AsTuple(PyObject *list) +.. cfunction:: PyObject* PyList_AsTuple(PyObject *list) .. index:: builtin: tuple diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/c-api/long.rst --- a/Doc/c-api/long.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/c-api/long.rst Sun Jul 20 10:52:46 2014 -0400 @@ -8,100 +8,100 @@ .. index:: object: long integer -.. c:type:: PyLongObject +.. ctype:: PyLongObject - This subtype of :c:type:`PyObject` represents a Python long integer object. + This subtype of :ctype:`PyObject` represents a Python long integer object. -.. c:var:: PyTypeObject PyLong_Type +.. cvar:: PyTypeObject PyLong_Type .. index:: single: LongType (in modules types) - This instance of :c:type:`PyTypeObject` represents the Python long integer type. + This instance of :ctype:`PyTypeObject` represents the Python long integer type. This is the same object as ``long`` and ``types.LongType``. -.. c:function:: int PyLong_Check(PyObject *p) +.. cfunction:: int PyLong_Check(PyObject *p) - Return true if its argument is a :c:type:`PyLongObject` or a subtype of - :c:type:`PyLongObject`. + Return true if its argument is a :ctype:`PyLongObject` or a subtype of + :ctype:`PyLongObject`. .. versionchanged:: 2.2 Allowed subtypes to be accepted. -.. c:function:: int PyLong_CheckExact(PyObject *p) +.. cfunction:: int PyLong_CheckExact(PyObject *p) - Return true if its argument is a :c:type:`PyLongObject`, but not a subtype of - :c:type:`PyLongObject`. + Return true if its argument is a :ctype:`PyLongObject`, but not a subtype of + :ctype:`PyLongObject`. .. versionadded:: 2.2 -.. c:function:: PyObject* PyLong_FromLong(long v) +.. cfunction:: PyObject* PyLong_FromLong(long v) - Return a new :c:type:`PyLongObject` object from *v*, or *NULL* on failure. + Return a new :ctype:`PyLongObject` object from *v*, or *NULL* on failure. -.. c:function:: PyObject* PyLong_FromUnsignedLong(unsigned long v) +.. cfunction:: PyObject* PyLong_FromUnsignedLong(unsigned long v) - Return a new :c:type:`PyLongObject` object from a C :c:type:`unsigned long`, or + Return a new :ctype:`PyLongObject` object from a C :ctype:`unsigned long`, or *NULL* on failure. -.. c:function:: PyObject* PyLong_FromSsize_t(Py_ssize_t v) +.. cfunction:: PyObject* PyLong_FromSsize_t(Py_ssize_t v) - Return a new :c:type:`PyLongObject` object from a C :c:type:`Py_ssize_t`, or + Return a new :ctype:`PyLongObject` object from a C :ctype:`Py_ssize_t`, or *NULL* on failure. .. versionadded:: 2.6 -.. c:function:: PyObject* PyLong_FromSize_t(size_t v) +.. cfunction:: PyObject* PyLong_FromSize_t(size_t v) - Return a new :c:type:`PyLongObject` object from a C :c:type:`size_t`, or + Return a new :ctype:`PyLongObject` object from a C :ctype:`size_t`, or *NULL* on failure. .. versionadded:: 2.6 -.. c:function:: PyObject* PyLong_FromSsize_t(Py_ssize_t v) +.. cfunction:: PyObject* PyLong_FromSsize_t(Py_ssize_t v) - Return a new :c:type:`PyLongObject` object with a value of *v*, or *NULL* + Return a new :ctype:`PyLongObject` object with a value of *v*, or *NULL* on failure. .. versionadded:: 2.6 -.. c:function:: PyObject* PyLong_FromSize_t(size_t v) +.. cfunction:: PyObject* PyLong_FromSize_t(size_t v) - Return a new :c:type:`PyLongObject` object with a value of *v*, or *NULL* + Return a new :ctype:`PyLongObject` object with a value of *v*, or *NULL* on failure. .. versionadded:: 2.6 -.. c:function:: PyObject* PyLong_FromLongLong(PY_LONG_LONG v) +.. cfunction:: PyObject* PyLong_FromLongLong(PY_LONG_LONG v) - Return a new :c:type:`PyLongObject` object from a C :c:type:`long long`, or *NULL* + Return a new :ctype:`PyLongObject` object from a C :ctype:`long long`, or *NULL* on failure. -.. c:function:: PyObject* PyLong_FromUnsignedLongLong(unsigned PY_LONG_LONG v) +.. cfunction:: PyObject* PyLong_FromUnsignedLongLong(unsigned PY_LONG_LONG v) - Return a new :c:type:`PyLongObject` object from a C :c:type:`unsigned long long`, + Return a new :ctype:`PyLongObject` object from a C :ctype:`unsigned long long`, or *NULL* on failure. -.. c:function:: PyObject* PyLong_FromDouble(double v) +.. cfunction:: PyObject* PyLong_FromDouble(double v) - Return a new :c:type:`PyLongObject` object from the integer part of *v*, or + Return a new :ctype:`PyLongObject` object from the integer part of *v*, or *NULL* on failure. -.. c:function:: PyObject* PyLong_FromString(char *str, char **pend, int base) +.. cfunction:: PyObject* PyLong_FromString(char *str, char **pend, int base) - Return a new :c:type:`PyLongObject` based on the string value in *str*, which is + Return a new :ctype:`PyLongObject` based on the string value in *str*, which is interpreted according to the radix in *base*. If *pend* is non-*NULL*, *\*pend* will point to the first character in *str* which follows the representation of the number. If *base* is ``0``, the radix will be determined @@ -112,7 +112,7 @@ no digits, :exc:`ValueError` will be raised. -.. c:function:: PyObject* PyLong_FromUnicode(Py_UNICODE *u, Py_ssize_t length, int base) +.. cfunction:: PyObject* PyLong_FromUnicode(Py_UNICODE *u, Py_ssize_t length, int base) Convert a sequence of Unicode digits to a Python long integer value. The first parameter, *u*, points to the first character of the Unicode string, *length* @@ -123,14 +123,14 @@ .. versionadded:: 1.6 .. versionchanged:: 2.5 - This function used an :c:type:`int` for *length*. This might require + This function used an :ctype:`int` for *length*. This might require changes in your code for properly supporting 64-bit systems. -.. c:function:: PyObject* PyLong_FromVoidPtr(void *p) +.. cfunction:: PyObject* PyLong_FromVoidPtr(void *p) Create a Python integer or long integer from the pointer *p*. The pointer value - can be retrieved from the resulting value using :c:func:`PyLong_AsVoidPtr`. + can be retrieved from the resulting value using :cfunc:`PyLong_AsVoidPtr`. .. versionadded:: 1.5.2 @@ -138,20 +138,20 @@ If the integer is larger than LONG_MAX, a positive long integer is returned. -.. c:function:: long PyLong_AsLong(PyObject *pylong) +.. cfunction:: long PyLong_AsLong(PyObject *pylong) .. index:: single: LONG_MAX single: OverflowError (built-in exception) - Return a C :c:type:`long` representation of the contents of *pylong*. If + Return a C :ctype:`long` representation of the contents of *pylong*. If *pylong* is greater than :const:`LONG_MAX`, an :exc:`OverflowError` is raised and ``-1`` will be returned. -.. c:function:: long PyLong_AsLongAndOverflow(PyObject *pylong, int *overflow) +.. cfunction:: long PyLong_AsLongAndOverflow(PyObject *pylong, int *overflow) - Return a C :c:type:`long` representation of the contents of + Return a C :ctype:`long` representation of the contents of *pylong*. If *pylong* is greater than :const:`LONG_MAX` or less than :const:`LONG_MIN`, set *\*overflow* to ``1`` or ``-1``, respectively, and return ``-1``; otherwise, set *\*overflow* to @@ -162,9 +162,9 @@ .. versionadded:: 2.7 -.. c:function:: PY_LONG_LONG PyLong_AsLongLongAndOverflow(PyObject *pylong, int *overflow) +.. cfunction:: PY_LONG_LONG PyLong_AsLongLongAndOverflow(PyObject *pylong, int *overflow) - Return a C :c:type:`long long` representation of the contents of + Return a C :ctype:`long long` representation of the contents of *pylong*. If *pylong* is greater than :const:`PY_LLONG_MAX` or less than :const:`PY_LLONG_MIN`, set *\*overflow* to ``1`` or ``-1``, respectively, and return ``-1``; otherwise, set *\*overflow* to @@ -175,61 +175,61 @@ .. versionadded:: 2.7 -.. c:function:: Py_ssize_t PyLong_AsSsize_t(PyObject *pylong) +.. cfunction:: Py_ssize_t PyLong_AsSsize_t(PyObject *pylong) .. index:: single: PY_SSIZE_T_MAX single: OverflowError (built-in exception) - Return a C :c:type:`Py_ssize_t` representation of the contents of *pylong*. If + Return a C :ctype:`Py_ssize_t` representation of the contents of *pylong*. If *pylong* is greater than :const:`PY_SSIZE_T_MAX`, an :exc:`OverflowError` is raised and ``-1`` will be returned. .. versionadded:: 2.6 -.. c:function:: unsigned long PyLong_AsUnsignedLong(PyObject *pylong) +.. cfunction:: unsigned long PyLong_AsUnsignedLong(PyObject *pylong) .. index:: single: ULONG_MAX single: OverflowError (built-in exception) - Return a C :c:type:`unsigned long` representation of the contents of *pylong*. + Return a C :ctype:`unsigned long` representation of the contents of *pylong*. If *pylong* is greater than :const:`ULONG_MAX`, an :exc:`OverflowError` is raised. -.. c:function:: Py_ssize_t PyLong_AsSsize_t(PyObject *pylong) +.. cfunction:: Py_ssize_t PyLong_AsSsize_t(PyObject *pylong) .. index:: single: PY_SSIZE_T_MAX - Return a :c:type:`Py_ssize_t` representation of the contents of *pylong*. If + Return a :ctype:`Py_ssize_t` representation of the contents of *pylong*. If *pylong* is greater than :const:`PY_SSIZE_T_MAX`, an :exc:`OverflowError` is raised. .. versionadded:: 2.6 -.. c:function:: PY_LONG_LONG PyLong_AsLongLong(PyObject *pylong) +.. cfunction:: PY_LONG_LONG PyLong_AsLongLong(PyObject *pylong) .. index:: single: OverflowError (built-in exception) - Return a C :c:type:`long long` from a Python long integer. If - *pylong* cannot be represented as a :c:type:`long long`, an + Return a C :ctype:`long long` from a Python long integer. If + *pylong* cannot be represented as a :ctype:`long long`, an :exc:`OverflowError` is raised and ``-1`` is returned. .. versionadded:: 2.2 -.. c:function:: unsigned PY_LONG_LONG PyLong_AsUnsignedLongLong(PyObject *pylong) +.. cfunction:: unsigned PY_LONG_LONG PyLong_AsUnsignedLongLong(PyObject *pylong) .. index:: single: OverflowError (built-in exception) - Return a C :c:type:`unsigned long long` from a Python long integer. If - *pylong* cannot be represented as an :c:type:`unsigned long long`, an + Return a C :ctype:`unsigned long long` from a Python long integer. If + *pylong* cannot be represented as an :ctype:`unsigned long long`, an :exc:`OverflowError` is raised and ``(unsigned long long)-1`` is returned. @@ -240,35 +240,35 @@ :exc:`TypeError`. -.. c:function:: unsigned long PyLong_AsUnsignedLongMask(PyObject *io) +.. cfunction:: unsigned long PyLong_AsUnsignedLongMask(PyObject *io) - Return a C :c:type:`unsigned long` from a Python long integer, without checking + Return a C :ctype:`unsigned long` from a Python long integer, without checking for overflow. .. versionadded:: 2.3 -.. c:function:: unsigned PY_LONG_LONG PyLong_AsUnsignedLongLongMask(PyObject *io) +.. cfunction:: unsigned PY_LONG_LONG PyLong_AsUnsignedLongLongMask(PyObject *io) - Return a C :c:type:`unsigned long long` from a Python long integer, without + Return a C :ctype:`unsigned long long` from a Python long integer, without checking for overflow. .. versionadded:: 2.3 -.. c:function:: double PyLong_AsDouble(PyObject *pylong) +.. cfunction:: double PyLong_AsDouble(PyObject *pylong) - Return a C :c:type:`double` representation of the contents of *pylong*. If - *pylong* cannot be approximately represented as a :c:type:`double`, an + Return a C :ctype:`double` representation of the contents of *pylong*. If + *pylong* cannot be approximately represented as a :ctype:`double`, an :exc:`OverflowError` exception is raised and ``-1.0`` will be returned. -.. c:function:: void* PyLong_AsVoidPtr(PyObject *pylong) +.. cfunction:: void* PyLong_AsVoidPtr(PyObject *pylong) - Convert a Python integer or long integer *pylong* to a C :c:type:`void` pointer. + Convert a Python integer or long integer *pylong* to a C :ctype:`void` pointer. If *pylong* cannot be converted, an :exc:`OverflowError` will be raised. This - is only assured to produce a usable :c:type:`void` pointer for values created - with :c:func:`PyLong_FromVoidPtr`. + is only assured to produce a usable :ctype:`void` pointer for values created + with :cfunc:`PyLong_FromVoidPtr`. .. versionadded:: 1.5.2 diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/c-api/mapping.rst --- a/Doc/c-api/mapping.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/c-api/mapping.rst Sun Jul 20 10:52:46 2014 -0400 @@ -6,13 +6,13 @@ ================ -.. c:function:: int PyMapping_Check(PyObject *o) +.. cfunction:: int PyMapping_Check(PyObject *o) Return ``1`` if the object provides mapping protocol, and ``0`` otherwise. This function always succeeds. -.. c:function:: Py_ssize_t PyMapping_Size(PyObject *o) +.. cfunction:: Py_ssize_t PyMapping_Size(PyObject *o) Py_ssize_t PyMapping_Length(PyObject *o) .. index:: builtin: len @@ -22,62 +22,62 @@ expression ``len(o)``. .. versionchanged:: 2.5 - These functions returned an :c:type:`int` type. This might require + These functions returned an :ctype:`int` type. This might require changes in your code for properly supporting 64-bit systems. -.. c:function:: int PyMapping_DelItemString(PyObject *o, char *key) +.. cfunction:: int PyMapping_DelItemString(PyObject *o, char *key) Remove the mapping for object *key* from the object *o*. Return ``-1`` on failure. This is equivalent to the Python statement ``del o[key]``. -.. c:function:: int PyMapping_DelItem(PyObject *o, PyObject *key) +.. cfunction:: int PyMapping_DelItem(PyObject *o, PyObject *key) Remove the mapping for object *key* from the object *o*. Return ``-1`` on failure. This is equivalent to the Python statement ``del o[key]``. -.. c:function:: int PyMapping_HasKeyString(PyObject *o, char *key) +.. cfunction:: int PyMapping_HasKeyString(PyObject *o, char *key) On success, return ``1`` if the mapping object has the key *key* and ``0`` otherwise. This is equivalent to ``o[key]``, returning ``True`` on success and ``False`` on an exception. This function always succeeds. -.. c:function:: int PyMapping_HasKey(PyObject *o, PyObject *key) +.. cfunction:: int PyMapping_HasKey(PyObject *o, PyObject *key) Return ``1`` if the mapping object has the key *key* and ``0`` otherwise. This is equivalent to ``o[key]``, returning ``True`` on success and ``False`` on an exception. This function always succeeds. -.. c:function:: PyObject* PyMapping_Keys(PyObject *o) +.. cfunction:: PyObject* PyMapping_Keys(PyObject *o) On success, return a list of the keys in object *o*. On failure, return *NULL*. This is equivalent to the Python expression ``o.keys()``. -.. c:function:: PyObject* PyMapping_Values(PyObject *o) +.. cfunction:: PyObject* PyMapping_Values(PyObject *o) On success, return a list of the values in object *o*. On failure, return *NULL*. This is equivalent to the Python expression ``o.values()``. -.. c:function:: PyObject* PyMapping_Items(PyObject *o) +.. cfunction:: PyObject* PyMapping_Items(PyObject *o) On success, return a list of the items in object *o*, where each item is a tuple containing a key-value pair. On failure, return *NULL*. This is equivalent to the Python expression ``o.items()``. -.. c:function:: PyObject* PyMapping_GetItemString(PyObject *o, char *key) +.. cfunction:: PyObject* PyMapping_GetItemString(PyObject *o, char *key) Return element of *o* corresponding to the object *key* or *NULL* on failure. This is the equivalent of the Python expression ``o[key]``. -.. c:function:: int PyMapping_SetItemString(PyObject *o, char *key, PyObject *v) +.. cfunction:: int PyMapping_SetItemString(PyObject *o, char *key, PyObject *v) Map the object *key* to the value *v* in object *o*. Returns ``-1`` on failure. This is the equivalent of the Python statement ``o[key] = v``. diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/c-api/marshal.rst --- a/Doc/c-api/marshal.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/c-api/marshal.rst Sun Jul 20 10:52:46 2014 -0400 @@ -20,17 +20,17 @@ file format (currently 2). -.. c:function:: void PyMarshal_WriteLongToFile(long value, FILE *file, int version) +.. cfunction:: void PyMarshal_WriteLongToFile(long value, FILE *file, int version) - Marshal a :c:type:`long` integer, *value*, to *file*. This will only write + Marshal a :ctype:`long` integer, *value*, to *file*. This will only write the least-significant 32 bits of *value*; regardless of the size of the - native :c:type:`long` type. + native :ctype:`long` type. .. versionchanged:: 2.4 *version* indicates the file format. -.. c:function:: void PyMarshal_WriteObjectToFile(PyObject *value, FILE *file, int version) +.. cfunction:: void PyMarshal_WriteObjectToFile(PyObject *value, FILE *file, int version) Marshal a Python object, *value*, to *file*. @@ -38,7 +38,7 @@ *version* indicates the file format. -.. c:function:: PyObject* PyMarshal_WriteObjectToString(PyObject *value, int version) +.. cfunction:: PyObject* PyMarshal_WriteObjectToString(PyObject *value, int version) Return a string object containing the marshalled representation of *value*. @@ -55,31 +55,31 @@ written using these routines? -.. c:function:: long PyMarshal_ReadLongFromFile(FILE *file) +.. cfunction:: long PyMarshal_ReadLongFromFile(FILE *file) - Return a C :c:type:`long` from the data stream in a :c:type:`FILE\*` opened + Return a C :ctype:`long` from the data stream in a :ctype:`FILE\*` opened for reading. Only a 32-bit value can be read in using this function, - regardless of the native size of :c:type:`long`. + regardless of the native size of :ctype:`long`. -.. c:function:: int PyMarshal_ReadShortFromFile(FILE *file) +.. cfunction:: int PyMarshal_ReadShortFromFile(FILE *file) - Return a C :c:type:`short` from the data stream in a :c:type:`FILE\*` opened + Return a C :ctype:`short` from the data stream in a :ctype:`FILE\*` opened for reading. Only a 16-bit value can be read in using this function, - regardless of the native size of :c:type:`short`. + regardless of the native size of :ctype:`short`. -.. c:function:: PyObject* PyMarshal_ReadObjectFromFile(FILE *file) +.. cfunction:: PyObject* PyMarshal_ReadObjectFromFile(FILE *file) - Return a Python object from the data stream in a :c:type:`FILE\*` opened for + Return a Python object from the data stream in a :ctype:`FILE\*` opened for reading. On error, sets the appropriate exception (:exc:`EOFError` or :exc:`TypeError`) and returns *NULL*. -.. c:function:: PyObject* PyMarshal_ReadLastObjectFromFile(FILE *file) +.. cfunction:: PyObject* PyMarshal_ReadLastObjectFromFile(FILE *file) - Return a Python object from the data stream in a :c:type:`FILE\*` opened for - reading. Unlike :c:func:`PyMarshal_ReadObjectFromFile`, this function + Return a Python object from the data stream in a :ctype:`FILE\*` opened for + reading. Unlike :cfunc:`PyMarshal_ReadObjectFromFile`, this function assumes that no further objects will be read from the file, allowing it to aggressively load file data into memory so that the de-serialization can operate from data in memory rather than reading a byte at a time from the @@ -88,7 +88,7 @@ (:exc:`EOFError` or :exc:`TypeError`) and returns *NULL*. -.. c:function:: PyObject* PyMarshal_ReadObjectFromString(char *string, Py_ssize_t len) +.. cfunction:: PyObject* PyMarshal_ReadObjectFromString(char *string, Py_ssize_t len) Return a Python object from the data stream in a character buffer containing *len* bytes pointed to by *string*. On error, sets the @@ -96,5 +96,5 @@ *NULL*. .. versionchanged:: 2.5 - This function used an :c:type:`int` type for *len*. This might require + This function used an :ctype:`int` type for *len*. This might require changes in your code for properly supporting 64-bit systems. diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/c-api/memory.rst --- a/Doc/c-api/memory.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/c-api/memory.rst Sun Jul 20 10:52:46 2014 -0400 @@ -47,8 +47,8 @@ single: free() To avoid memory corruption, extension writers should never try to operate on -Python objects with the functions exported by the C library: :c:func:`malloc`, -:c:func:`calloc`, :c:func:`realloc` and :c:func:`free`. This will result in mixed +Python objects with the functions exported by the C library: :cfunc:`malloc`, +:cfunc:`calloc`, :cfunc:`realloc` and :cfunc:`free`. This will result in mixed calls between the C allocator and the Python memory manager with fatal consequences, because they implement different algorithms and operate on different heaps. However, one may safely allocate and release memory blocks @@ -94,65 +94,65 @@ memory from the Python heap: -.. c:function:: void* PyMem_Malloc(size_t n) +.. cfunction:: void* PyMem_Malloc(size_t n) - Allocates *n* bytes and returns a pointer of type :c:type:`void\*` to the + Allocates *n* bytes and returns a pointer of type :ctype:`void\*` to the allocated memory, or *NULL* if the request fails. Requesting zero bytes returns - a distinct non-*NULL* pointer if possible, as if ``PyMem_Malloc(1)`` had + a distinct non-*NULL* pointer if possible, as if :cfunc:`PyMem_Malloc(1)` had been called instead. The memory will not have been initialized in any way. -.. c:function:: void* PyMem_Realloc(void *p, size_t n) +.. cfunction:: void* PyMem_Realloc(void *p, size_t n) Resizes the memory block pointed to by *p* to *n* bytes. The contents will be unchanged to the minimum of the old and the new sizes. If *p* is *NULL*, the - call is equivalent to ``PyMem_Malloc(n)``; else if *n* is equal to zero, + call is equivalent to :cfunc:`PyMem_Malloc(n)`; else if *n* is equal to zero, the memory block is resized but is not freed, and the returned pointer is non-*NULL*. Unless *p* is *NULL*, it must have been returned by a previous call - to :c:func:`PyMem_Malloc` or :c:func:`PyMem_Realloc`. If the request fails, - :c:func:`PyMem_Realloc` returns *NULL* and *p* remains a valid pointer to the + to :cfunc:`PyMem_Malloc` or :cfunc:`PyMem_Realloc`. If the request fails, + :cfunc:`PyMem_Realloc` returns *NULL* and *p* remains a valid pointer to the previous memory area. -.. c:function:: void PyMem_Free(void *p) +.. cfunction:: void PyMem_Free(void *p) Frees the memory block pointed to by *p*, which must have been returned by a - previous call to :c:func:`PyMem_Malloc` or :c:func:`PyMem_Realloc`. Otherwise, or - if ``PyMem_Free(p)`` has been called before, undefined behavior occurs. If + previous call to :cfunc:`PyMem_Malloc` or :cfunc:`PyMem_Realloc`. Otherwise, or + if :cfunc:`PyMem_Free(p)` has been called before, undefined behavior occurs. If *p* is *NULL*, no operation is performed. The following type-oriented macros are provided for convenience. Note that *TYPE* refers to any C type. -.. c:function:: TYPE* PyMem_New(TYPE, size_t n) +.. cfunction:: TYPE* PyMem_New(TYPE, size_t n) - Same as :c:func:`PyMem_Malloc`, but allocates ``(n * sizeof(TYPE))`` bytes of - memory. Returns a pointer cast to :c:type:`TYPE\*`. The memory will not have + Same as :cfunc:`PyMem_Malloc`, but allocates ``(n * sizeof(TYPE))`` bytes of + memory. Returns a pointer cast to :ctype:`TYPE\*`. The memory will not have been initialized in any way. -.. c:function:: TYPE* PyMem_Resize(void *p, TYPE, size_t n) +.. cfunction:: TYPE* PyMem_Resize(void *p, TYPE, size_t n) - Same as :c:func:`PyMem_Realloc`, but the memory block is resized to ``(n * - sizeof(TYPE))`` bytes. Returns a pointer cast to :c:type:`TYPE\*`. On return, + Same as :cfunc:`PyMem_Realloc`, but the memory block is resized to ``(n * + sizeof(TYPE))`` bytes. Returns a pointer cast to :ctype:`TYPE\*`. On return, *p* will be a pointer to the new memory area, or *NULL* in the event of failure. This is a C preprocessor macro; p is always reassigned. Save the original value of p to avoid losing memory when handling errors. -.. c:function:: void PyMem_Del(void *p) +.. cfunction:: void PyMem_Del(void *p) - Same as :c:func:`PyMem_Free`. + Same as :cfunc:`PyMem_Free`. In addition, the following macro sets are provided for calling the Python memory allocator directly, without involving the C API functions listed above. However, note that their use does not preserve binary compatibility across Python versions and is therefore deprecated in extension modules. -:c:func:`PyMem_MALLOC`, :c:func:`PyMem_REALLOC`, :c:func:`PyMem_FREE`. +:cfunc:`PyMem_MALLOC`, :cfunc:`PyMem_REALLOC`, :cfunc:`PyMem_FREE`. -:c:func:`PyMem_NEW`, :c:func:`PyMem_RESIZE`, :c:func:`PyMem_DEL`. +:cfunc:`PyMem_NEW`, :cfunc:`PyMem_RESIZE`, :cfunc:`PyMem_DEL`. .. _memoryexamples: @@ -201,8 +201,8 @@ free(buf1); /* Fatal -- should be PyMem_Del() */ In addition to the functions aimed at handling raw memory blocks from the Python -heap, objects in Python are allocated and released with :c:func:`PyObject_New`, -:c:func:`PyObject_NewVar` and :c:func:`PyObject_Del`. +heap, objects in Python are allocated and released with :cfunc:`PyObject_New`, +:cfunc:`PyObject_NewVar` and :cfunc:`PyObject_Del`. These will be explained in the next chapter on defining and implementing new object types in C. diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/c-api/method.rst --- a/Doc/c-api/method.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/c-api/method.rst Sun Jul 20 10:52:46 2014 -0400 @@ -10,21 +10,21 @@ There are some useful functions that are useful for working with method objects. -.. c:var:: PyTypeObject PyMethod_Type +.. cvar:: PyTypeObject PyMethod_Type .. index:: single: MethodType (in module types) - This instance of :c:type:`PyTypeObject` represents the Python method type. This + This instance of :ctype:`PyTypeObject` represents the Python method type. This is exposed to Python programs as ``types.MethodType``. -.. c:function:: int PyMethod_Check(PyObject *o) +.. cfunction:: int PyMethod_Check(PyObject *o) - Return true if *o* is a method object (has type :c:data:`PyMethod_Type`). The + Return true if *o* is a method object (has type :cdata:`PyMethod_Type`). The parameter must not be *NULL*. -.. c:function:: PyObject* PyMethod_New(PyObject *func, PyObject *self, PyObject *class) +.. cfunction:: PyObject* PyMethod_New(PyObject *func, PyObject *self, PyObject *class) Return a new method object, with *func* being any callable object; this is the function that will be called when the method is called. If this method should @@ -33,39 +33,39 @@ class which provides the unbound method.. -.. c:function:: PyObject* PyMethod_Class(PyObject *meth) +.. cfunction:: PyObject* PyMethod_Class(PyObject *meth) Return the class object from which the method *meth* was created; if this was created from an instance, it will be the class of the instance. -.. c:function:: PyObject* PyMethod_GET_CLASS(PyObject *meth) +.. cfunction:: PyObject* PyMethod_GET_CLASS(PyObject *meth) - Macro version of :c:func:`PyMethod_Class` which avoids error checking. + Macro version of :cfunc:`PyMethod_Class` which avoids error checking. -.. c:function:: PyObject* PyMethod_Function(PyObject *meth) +.. cfunction:: PyObject* PyMethod_Function(PyObject *meth) Return the function object associated with the method *meth*. -.. c:function:: PyObject* PyMethod_GET_FUNCTION(PyObject *meth) +.. cfunction:: PyObject* PyMethod_GET_FUNCTION(PyObject *meth) - Macro version of :c:func:`PyMethod_Function` which avoids error checking. + Macro version of :cfunc:`PyMethod_Function` which avoids error checking. -.. c:function:: PyObject* PyMethod_Self(PyObject *meth) +.. cfunction:: PyObject* PyMethod_Self(PyObject *meth) Return the instance associated with the method *meth* if it is bound, otherwise return *NULL*. -.. c:function:: PyObject* PyMethod_GET_SELF(PyObject *meth) +.. cfunction:: PyObject* PyMethod_GET_SELF(PyObject *meth) - Macro version of :c:func:`PyMethod_Self` which avoids error checking. + Macro version of :cfunc:`PyMethod_Self` which avoids error checking. -.. c:function:: int PyMethod_ClearFreeList() +.. cfunction:: int PyMethod_ClearFreeList() Clear the free list. Return the total number of freed items. diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/c-api/module.rst --- a/Doc/c-api/module.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/c-api/module.rst Sun Jul 20 10:52:46 2014 -0400 @@ -10,15 +10,15 @@ There are only a few functions special to module objects. -.. c:var:: PyTypeObject PyModule_Type +.. cvar:: PyTypeObject PyModule_Type .. index:: single: ModuleType (in module types) - This instance of :c:type:`PyTypeObject` represents the Python module type. This + This instance of :ctype:`PyTypeObject` represents the Python module type. This is exposed to Python programs as ``types.ModuleType``. -.. c:function:: int PyModule_Check(PyObject *p) +.. cfunction:: int PyModule_Check(PyObject *p) Return true if *p* is a module object, or a subtype of a module object. @@ -26,15 +26,15 @@ Allowed subtypes to be accepted. -.. c:function:: int PyModule_CheckExact(PyObject *p) +.. cfunction:: int PyModule_CheckExact(PyObject *p) Return true if *p* is a module object, but not a subtype of - :c:data:`PyModule_Type`. + :cdata:`PyModule_Type`. .. versionadded:: 2.2 -.. c:function:: PyObject* PyModule_New(const char *name) +.. cfunction:: PyObject* PyModule_New(const char *name) .. index:: single: __name__ (module attribute) @@ -46,18 +46,18 @@ the caller is responsible for providing a :attr:`__file__` attribute. -.. c:function:: PyObject* PyModule_GetDict(PyObject *module) +.. cfunction:: PyObject* PyModule_GetDict(PyObject *module) .. index:: single: __dict__ (module attribute) Return the dictionary object that implements *module*'s namespace; this object is the same as the :attr:`__dict__` attribute of the module object. This function never fails. It is recommended extensions use other - :c:func:`PyModule_\*` and :c:func:`PyObject_\*` functions rather than directly + :cfunc:`PyModule_\*` and :cfunc:`PyObject_\*` functions rather than directly manipulate a module's :attr:`__dict__`. -.. c:function:: char* PyModule_GetName(PyObject *module) +.. cfunction:: char* PyModule_GetName(PyObject *module) .. index:: single: __name__ (module attribute) @@ -67,7 +67,7 @@ or if it is not a string, :exc:`SystemError` is raised and *NULL* is returned. -.. c:function:: char* PyModule_GetFilename(PyObject *module) +.. cfunction:: char* PyModule_GetFilename(PyObject *module) .. index:: single: __file__ (module attribute) @@ -78,7 +78,7 @@ raise :exc:`SystemError` and return *NULL*. -.. c:function:: int PyModule_AddObject(PyObject *module, const char *name, PyObject *value) +.. cfunction:: int PyModule_AddObject(PyObject *module, const char *name, PyObject *value) Add an object to *module* as *name*. This is a convenience function which can be used from the module's initialization function. This steals a reference to @@ -87,7 +87,7 @@ .. versionadded:: 2.0 -.. c:function:: int PyModule_AddIntConstant(PyObject *module, const char *name, long value) +.. cfunction:: int PyModule_AddIntConstant(PyObject *module, const char *name, long value) Add an integer constant to *module* as *name*. This convenience function can be used from the module's initialization function. Return ``-1`` on error, ``0`` on @@ -96,7 +96,7 @@ .. versionadded:: 2.0 -.. c:function:: int PyModule_AddStringConstant(PyObject *module, const char *name, const char *value) +.. cfunction:: int PyModule_AddStringConstant(PyObject *module, const char *name, const char *value) Add a string constant to *module* as *name*. This convenience function can be used from the module's initialization function. The string *value* must be @@ -104,7 +104,7 @@ .. versionadded:: 2.0 -.. c:function:: int PyModule_AddIntMacro(PyObject *module, macro) +.. cfunction:: int PyModule_AddIntMacro(PyObject *module, macro) Add an int constant to *module*. The name and the value are taken from *macro*. For example ``PyModule_AddIntMacro(module, AF_INET)`` adds the int @@ -113,7 +113,7 @@ .. versionadded:: 2.6 -.. c:function:: int PyModule_AddStringMacro(PyObject *module, macro) +.. cfunction:: int PyModule_AddStringMacro(PyObject *module, macro) Add a string constant to *module*. diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/c-api/none.rst --- a/Doc/c-api/none.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/c-api/none.rst Sun Jul 20 10:52:46 2014 -0400 @@ -7,22 +7,22 @@ .. index:: object: None -Note that the :c:type:`PyTypeObject` for ``None`` is not directly exposed in the +Note that the :ctype:`PyTypeObject` for ``None`` is not directly exposed in the Python/C API. Since ``None`` is a singleton, testing for object identity (using -``==`` in C) is sufficient. There is no :c:func:`PyNone_Check` function for the +``==`` in C) is sufficient. There is no :cfunc:`PyNone_Check` function for the same reason. -.. c:var:: PyObject* Py_None +.. cvar:: PyObject* Py_None The Python ``None`` object, denoting lack of value. This object has no methods. It needs to be treated just like any other object with respect to reference counts. -.. c:macro:: Py_RETURN_NONE +.. cmacro:: Py_RETURN_NONE - Properly handle returning :c:data:`Py_None` from within a C function. + Properly handle returning :cdata:`Py_None` from within a C function. .. versionadded:: 2.4 diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/c-api/number.rst --- a/Doc/c-api/number.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/c-api/number.rst Sun Jul 20 10:52:46 2014 -0400 @@ -6,37 +6,37 @@ =============== -.. c:function:: int PyNumber_Check(PyObject *o) +.. cfunction:: int PyNumber_Check(PyObject *o) Returns ``1`` if the object *o* provides numeric protocols, and false otherwise. This function always succeeds. -.. c:function:: PyObject* PyNumber_Add(PyObject *o1, PyObject *o2) +.. cfunction:: PyObject* PyNumber_Add(PyObject *o1, PyObject *o2) Returns the result of adding *o1* and *o2*, or *NULL* on failure. This is the equivalent of the Python expression ``o1 + o2``. -.. c:function:: PyObject* PyNumber_Subtract(PyObject *o1, PyObject *o2) +.. cfunction:: PyObject* PyNumber_Subtract(PyObject *o1, PyObject *o2) Returns the result of subtracting *o2* from *o1*, or *NULL* on failure. This is the equivalent of the Python expression ``o1 - o2``. -.. c:function:: PyObject* PyNumber_Multiply(PyObject *o1, PyObject *o2) +.. cfunction:: PyObject* PyNumber_Multiply(PyObject *o1, PyObject *o2) Returns the result of multiplying *o1* and *o2*, or *NULL* on failure. This is the equivalent of the Python expression ``o1 * o2``. -.. c:function:: PyObject* PyNumber_Divide(PyObject *o1, PyObject *o2) +.. cfunction:: PyObject* PyNumber_Divide(PyObject *o1, PyObject *o2) Returns the result of dividing *o1* by *o2*, or *NULL* on failure. This is the equivalent of the Python expression ``o1 / o2``. -.. c:function:: PyObject* PyNumber_FloorDivide(PyObject *o1, PyObject *o2) +.. cfunction:: PyObject* PyNumber_FloorDivide(PyObject *o1, PyObject *o2) Return the floor of *o1* divided by *o2*, or *NULL* on failure. This is equivalent to the "classic" division of integers. @@ -44,7 +44,7 @@ .. versionadded:: 2.2 -.. c:function:: PyObject* PyNumber_TrueDivide(PyObject *o1, PyObject *o2) +.. cfunction:: PyObject* PyNumber_TrueDivide(PyObject *o1, PyObject *o2) Return a reasonable approximation for the mathematical value of *o1* divided by *o2*, or *NULL* on failure. The return value is "approximate" because binary @@ -55,13 +55,13 @@ .. versionadded:: 2.2 -.. c:function:: PyObject* PyNumber_Remainder(PyObject *o1, PyObject *o2) +.. cfunction:: PyObject* PyNumber_Remainder(PyObject *o1, PyObject *o2) Returns the remainder of dividing *o1* by *o2*, or *NULL* on failure. This is the equivalent of the Python expression ``o1 % o2``. -.. c:function:: PyObject* PyNumber_Divmod(PyObject *o1, PyObject *o2) +.. cfunction:: PyObject* PyNumber_Divmod(PyObject *o1, PyObject *o2) .. index:: builtin: divmod @@ -69,29 +69,29 @@ the equivalent of the Python expression ``divmod(o1, o2)``. -.. c:function:: PyObject* PyNumber_Power(PyObject *o1, PyObject *o2, PyObject *o3) +.. cfunction:: PyObject* PyNumber_Power(PyObject *o1, PyObject *o2, PyObject *o3) .. index:: builtin: pow See the built-in function :func:`pow`. Returns *NULL* on failure. This is the equivalent of the Python expression ``pow(o1, o2, o3)``, where *o3* is optional. - If *o3* is to be ignored, pass :c:data:`Py_None` in its place (passing *NULL* for + If *o3* is to be ignored, pass :cdata:`Py_None` in its place (passing *NULL* for *o3* would cause an illegal memory access). -.. c:function:: PyObject* PyNumber_Negative(PyObject *o) +.. cfunction:: PyObject* PyNumber_Negative(PyObject *o) Returns the negation of *o* on success, or *NULL* on failure. This is the equivalent of the Python expression ``-o``. -.. c:function:: PyObject* PyNumber_Positive(PyObject *o) +.. cfunction:: PyObject* PyNumber_Positive(PyObject *o) Returns *o* on success, or *NULL* on failure. This is the equivalent of the Python expression ``+o``. -.. c:function:: PyObject* PyNumber_Absolute(PyObject *o) +.. cfunction:: PyObject* PyNumber_Absolute(PyObject *o) .. index:: builtin: abs @@ -99,71 +99,71 @@ of the Python expression ``abs(o)``. -.. c:function:: PyObject* PyNumber_Invert(PyObject *o) +.. cfunction:: PyObject* PyNumber_Invert(PyObject *o) Returns the bitwise negation of *o* on success, or *NULL* on failure. This is the equivalent of the Python expression ``~o``. -.. c:function:: PyObject* PyNumber_Lshift(PyObject *o1, PyObject *o2) +.. cfunction:: PyObject* PyNumber_Lshift(PyObject *o1, PyObject *o2) Returns the result of left shifting *o1* by *o2* on success, or *NULL* on failure. This is the equivalent of the Python expression ``o1 << o2``. -.. c:function:: PyObject* PyNumber_Rshift(PyObject *o1, PyObject *o2) +.. cfunction:: PyObject* PyNumber_Rshift(PyObject *o1, PyObject *o2) Returns the result of right shifting *o1* by *o2* on success, or *NULL* on failure. This is the equivalent of the Python expression ``o1 >> o2``. -.. c:function:: PyObject* PyNumber_And(PyObject *o1, PyObject *o2) +.. cfunction:: PyObject* PyNumber_And(PyObject *o1, PyObject *o2) Returns the "bitwise and" of *o1* and *o2* on success and *NULL* on failure. This is the equivalent of the Python expression ``o1 & o2``. -.. c:function:: PyObject* PyNumber_Xor(PyObject *o1, PyObject *o2) +.. cfunction:: PyObject* PyNumber_Xor(PyObject *o1, PyObject *o2) Returns the "bitwise exclusive or" of *o1* by *o2* on success, or *NULL* on failure. This is the equivalent of the Python expression ``o1 ^ o2``. -.. c:function:: PyObject* PyNumber_Or(PyObject *o1, PyObject *o2) +.. cfunction:: PyObject* PyNumber_Or(PyObject *o1, PyObject *o2) Returns the "bitwise or" of *o1* and *o2* on success, or *NULL* on failure. This is the equivalent of the Python expression ``o1 | o2``. -.. c:function:: PyObject* PyNumber_InPlaceAdd(PyObject *o1, PyObject *o2) +.. cfunction:: PyObject* PyNumber_InPlaceAdd(PyObject *o1, PyObject *o2) Returns the result of adding *o1* and *o2*, or *NULL* on failure. The operation is done *in-place* when *o1* supports it. This is the equivalent of the Python statement ``o1 += o2``. -.. c:function:: PyObject* PyNumber_InPlaceSubtract(PyObject *o1, PyObject *o2) +.. cfunction:: PyObject* PyNumber_InPlaceSubtract(PyObject *o1, PyObject *o2) Returns the result of subtracting *o2* from *o1*, or *NULL* on failure. The operation is done *in-place* when *o1* supports it. This is the equivalent of the Python statement ``o1 -= o2``. -.. c:function:: PyObject* PyNumber_InPlaceMultiply(PyObject *o1, PyObject *o2) +.. cfunction:: PyObject* PyNumber_InPlaceMultiply(PyObject *o1, PyObject *o2) Returns the result of multiplying *o1* and *o2*, or *NULL* on failure. The operation is done *in-place* when *o1* supports it. This is the equivalent of the Python statement ``o1 *= o2``. -.. c:function:: PyObject* PyNumber_InPlaceDivide(PyObject *o1, PyObject *o2) +.. cfunction:: PyObject* PyNumber_InPlaceDivide(PyObject *o1, PyObject *o2) Returns the result of dividing *o1* by *o2*, or *NULL* on failure. The operation is done *in-place* when *o1* supports it. This is the equivalent of the Python statement ``o1 /= o2``. -.. c:function:: PyObject* PyNumber_InPlaceFloorDivide(PyObject *o1, PyObject *o2) +.. cfunction:: PyObject* PyNumber_InPlaceFloorDivide(PyObject *o1, PyObject *o2) Returns the mathematical floor of dividing *o1* by *o2*, or *NULL* on failure. The operation is done *in-place* when *o1* supports it. This is the equivalent @@ -172,7 +172,7 @@ .. versionadded:: 2.2 -.. c:function:: PyObject* PyNumber_InPlaceTrueDivide(PyObject *o1, PyObject *o2) +.. cfunction:: PyObject* PyNumber_InPlaceTrueDivide(PyObject *o1, PyObject *o2) Return a reasonable approximation for the mathematical value of *o1* divided by *o2*, or *NULL* on failure. The return value is "approximate" because binary @@ -183,64 +183,64 @@ .. versionadded:: 2.2 -.. c:function:: PyObject* PyNumber_InPlaceRemainder(PyObject *o1, PyObject *o2) +.. cfunction:: PyObject* PyNumber_InPlaceRemainder(PyObject *o1, PyObject *o2) Returns the remainder of dividing *o1* by *o2*, or *NULL* on failure. The operation is done *in-place* when *o1* supports it. This is the equivalent of the Python statement ``o1 %= o2``. -.. c:function:: PyObject* PyNumber_InPlacePower(PyObject *o1, PyObject *o2, PyObject *o3) +.. cfunction:: PyObject* PyNumber_InPlacePower(PyObject *o1, PyObject *o2, PyObject *o3) .. index:: builtin: pow See the built-in function :func:`pow`. Returns *NULL* on failure. The operation is done *in-place* when *o1* supports it. This is the equivalent of the Python - statement ``o1 **= o2`` when o3 is :c:data:`Py_None`, or an in-place variant of - ``pow(o1, o2, o3)`` otherwise. If *o3* is to be ignored, pass :c:data:`Py_None` + statement ``o1 **= o2`` when o3 is :cdata:`Py_None`, or an in-place variant of + ``pow(o1, o2, o3)`` otherwise. If *o3* is to be ignored, pass :cdata:`Py_None` in its place (passing *NULL* for *o3* would cause an illegal memory access). -.. c:function:: PyObject* PyNumber_InPlaceLshift(PyObject *o1, PyObject *o2) +.. cfunction:: PyObject* PyNumber_InPlaceLshift(PyObject *o1, PyObject *o2) Returns the result of left shifting *o1* by *o2* on success, or *NULL* on failure. The operation is done *in-place* when *o1* supports it. This is the equivalent of the Python statement ``o1 <<= o2``. -.. c:function:: PyObject* PyNumber_InPlaceRshift(PyObject *o1, PyObject *o2) +.. cfunction:: PyObject* PyNumber_InPlaceRshift(PyObject *o1, PyObject *o2) Returns the result of right shifting *o1* by *o2* on success, or *NULL* on failure. The operation is done *in-place* when *o1* supports it. This is the equivalent of the Python statement ``o1 >>= o2``. -.. c:function:: PyObject* PyNumber_InPlaceAnd(PyObject *o1, PyObject *o2) +.. cfunction:: PyObject* PyNumber_InPlaceAnd(PyObject *o1, PyObject *o2) Returns the "bitwise and" of *o1* and *o2* on success and *NULL* on failure. The operation is done *in-place* when *o1* supports it. This is the equivalent of the Python statement ``o1 &= o2``. -.. c:function:: PyObject* PyNumber_InPlaceXor(PyObject *o1, PyObject *o2) +.. cfunction:: PyObject* PyNumber_InPlaceXor(PyObject *o1, PyObject *o2) Returns the "bitwise exclusive or" of *o1* by *o2* on success, or *NULL* on failure. The operation is done *in-place* when *o1* supports it. This is the equivalent of the Python statement ``o1 ^= o2``. -.. c:function:: PyObject* PyNumber_InPlaceOr(PyObject *o1, PyObject *o2) +.. cfunction:: PyObject* PyNumber_InPlaceOr(PyObject *o1, PyObject *o2) Returns the "bitwise or" of *o1* and *o2* on success, or *NULL* on failure. The operation is done *in-place* when *o1* supports it. This is the equivalent of the Python statement ``o1 |= o2``. -.. c:function:: int PyNumber_Coerce(PyObject **p1, PyObject **p2) +.. cfunction:: int PyNumber_Coerce(PyObject **p1, PyObject **p2) .. index:: builtin: coerce - This function takes the addresses of two variables of type :c:type:`PyObject\*`. + This function takes the addresses of two variables of type :ctype:`PyObject\*`. If the objects pointed to by ``*p1`` and ``*p2`` have the same type, increment their reference count and return ``0`` (success). If the objects can be converted to a common numeric type, replace ``*p1`` and ``*p2`` by their @@ -250,14 +250,14 @@ &o2)`` is equivalent to the Python statement ``o1, o2 = coerce(o1, o2)``. -.. c:function:: int PyNumber_CoerceEx(PyObject **p1, PyObject **p2) +.. cfunction:: int PyNumber_CoerceEx(PyObject **p1, PyObject **p2) - This function is similar to :c:func:`PyNumber_Coerce`, except that it returns + This function is similar to :cfunc:`PyNumber_Coerce`, except that it returns ``1`` when the conversion is not possible and when no error is raised. Reference counts are still not increased in this case. -.. c:function:: PyObject* PyNumber_Int(PyObject *o) +.. cfunction:: PyObject* PyNumber_Int(PyObject *o) .. index:: builtin: int @@ -266,7 +266,7 @@ instead. This is the equivalent of the Python expression ``int(o)``. -.. c:function:: PyObject* PyNumber_Long(PyObject *o) +.. cfunction:: PyObject* PyNumber_Long(PyObject *o) .. index:: builtin: long @@ -274,7 +274,7 @@ failure. This is the equivalent of the Python expression ``long(o)``. -.. c:function:: PyObject* PyNumber_Float(PyObject *o) +.. cfunction:: PyObject* PyNumber_Float(PyObject *o) .. index:: builtin: float @@ -282,7 +282,7 @@ This is the equivalent of the Python expression ``float(o)``. -.. c:function:: PyObject* PyNumber_Index(PyObject *o) +.. cfunction:: PyObject* PyNumber_Index(PyObject *o) Returns the *o* converted to a Python int or long on success or *NULL* with a :exc:`TypeError` exception raised on failure. @@ -290,18 +290,18 @@ .. versionadded:: 2.5 -.. c:function:: PyObject* PyNumber_ToBase(PyObject *n, int base) +.. cfunction:: PyObject* PyNumber_ToBase(PyObject *n, int base) Returns the integer *n* converted to *base* as a string with a base marker of ``'0b'``, ``'0o'``, or ``'0x'`` if applicable. When *base* is not 2, 8, 10, or 16, the format is ``'x#num'`` where x is the base. If *n* is not an int object, it is converted with - :c:func:`PyNumber_Index` first. + :cfunc:`PyNumber_Index` first. .. versionadded:: 2.6 -.. c:function:: Py_ssize_t PyNumber_AsSsize_t(PyObject *o, PyObject *exc) +.. cfunction:: Py_ssize_t PyNumber_AsSsize_t(PyObject *o, PyObject *exc) Returns *o* converted to a Py_ssize_t value if *o* can be interpreted as an integer. If *o* can be converted to a Python int or long but the attempt to @@ -314,7 +314,7 @@ .. versionadded:: 2.5 -.. c:function:: int PyIndex_Check(PyObject *o) +.. cfunction:: int PyIndex_Check(PyObject *o) Returns True if *o* is an index integer (has the nb_index slot of the tp_as_number structure filled in). diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/c-api/objbuffer.rst --- a/Doc/c-api/objbuffer.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/c-api/objbuffer.rst Sun Jul 20 10:52:46 2014 -0400 @@ -8,12 +8,12 @@ This section describes the legacy buffer protocol, which has been introduced in Python 1.6. It is still supported but deprecated in the Python 2.x series. -Python 3 introduces a new buffer protocol which fixes weaknesses and +Python 3.0 introduces a new buffer protocol which fixes weaknesses and shortcomings of the protocol, and has been backported to Python 2.6. See :ref:`bufferobjects` for more information. -.. c:function:: int PyObject_AsCharBuffer(PyObject *obj, const char **buffer, Py_ssize_t *buffer_len) +.. cfunction:: int PyObject_AsCharBuffer(PyObject *obj, const char **buffer, Py_ssize_t *buffer_len) Returns a pointer to a read-only memory location usable as character-based input. The *obj* argument must support the single-segment character buffer @@ -24,11 +24,11 @@ .. versionadded:: 1.6 .. versionchanged:: 2.5 - This function used an :c:type:`int *` type for *buffer_len*. This might + This function used an :ctype:`int *` type for *buffer_len*. This might require changes in your code for properly supporting 64-bit systems. -.. c:function:: int PyObject_AsReadBuffer(PyObject *obj, const void **buffer, Py_ssize_t *buffer_len) +.. cfunction:: int PyObject_AsReadBuffer(PyObject *obj, const void **buffer, Py_ssize_t *buffer_len) Returns a pointer to a read-only memory location containing arbitrary data. The *obj* argument must support the single-segment readable buffer @@ -39,11 +39,11 @@ .. versionadded:: 1.6 .. versionchanged:: 2.5 - This function used an :c:type:`int *` type for *buffer_len*. This might + This function used an :ctype:`int *` type for *buffer_len*. This might require changes in your code for properly supporting 64-bit systems. -.. c:function:: int PyObject_CheckReadBuffer(PyObject *o) +.. cfunction:: int PyObject_CheckReadBuffer(PyObject *o) Returns ``1`` if *o* supports the single-segment readable buffer interface. Otherwise returns ``0``. @@ -51,7 +51,7 @@ .. versionadded:: 2.2 -.. c:function:: int PyObject_AsWriteBuffer(PyObject *obj, void **buffer, Py_ssize_t *buffer_len) +.. cfunction:: int PyObject_AsWriteBuffer(PyObject *obj, void **buffer, Py_ssize_t *buffer_len) Returns a pointer to a writeable memory location. The *obj* argument must support the single-segment, character buffer interface. On success, @@ -61,6 +61,6 @@ .. versionadded:: 1.6 .. versionchanged:: 2.5 - This function used an :c:type:`int *` type for *buffer_len*. This might + This function used an :ctype:`int *` type for *buffer_len*. This might require changes in your code for properly supporting 64-bit systems. diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/c-api/object.rst --- a/Doc/c-api/object.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/c-api/object.rst Sun Jul 20 10:52:46 2014 -0400 @@ -6,7 +6,7 @@ =============== -.. c:function:: int PyObject_Print(PyObject *o, FILE *fp, int flags) +.. cfunction:: int PyObject_Print(PyObject *o, FILE *fp, int flags) Print an object *o*, on file *fp*. Returns ``-1`` on error. The flags argument is used to enable certain printing options. The only option currently supported @@ -14,81 +14,81 @@ instead of the :func:`repr`. -.. c:function:: int PyObject_HasAttr(PyObject *o, PyObject *attr_name) +.. cfunction:: int PyObject_HasAttr(PyObject *o, PyObject *attr_name) Returns ``1`` if *o* has the attribute *attr_name*, and ``0`` otherwise. This is equivalent to the Python expression ``hasattr(o, attr_name)``. This function always succeeds. -.. c:function:: int PyObject_HasAttrString(PyObject *o, const char *attr_name) +.. cfunction:: int PyObject_HasAttrString(PyObject *o, const char *attr_name) Returns ``1`` if *o* has the attribute *attr_name*, and ``0`` otherwise. This is equivalent to the Python expression ``hasattr(o, attr_name)``. This function always succeeds. -.. c:function:: PyObject* PyObject_GetAttr(PyObject *o, PyObject *attr_name) +.. cfunction:: PyObject* PyObject_GetAttr(PyObject *o, PyObject *attr_name) Retrieve an attribute named *attr_name* from object *o*. Returns the attribute value on success, or *NULL* on failure. This is the equivalent of the Python expression ``o.attr_name``. -.. c:function:: PyObject* PyObject_GetAttrString(PyObject *o, const char *attr_name) +.. cfunction:: PyObject* PyObject_GetAttrString(PyObject *o, const char *attr_name) Retrieve an attribute named *attr_name* from object *o*. Returns the attribute value on success, or *NULL* on failure. This is the equivalent of the Python expression ``o.attr_name``. -.. c:function:: PyObject* PyObject_GenericGetAttr(PyObject *o, PyObject *name) +.. cfunction:: PyObject* PyObject_GenericGetAttr(PyObject *o, PyObject *name) Generic attribute getter function that is meant to be put into a type object's ``tp_getattro`` slot. It looks for a descriptor in the dictionary of classes in the object's MRO as well as an attribute in the object's - :attr:`~object.__dict__` (if present). As outlined in :ref:`descriptors`, - data descriptors take preference over instance attributes, while non-data + :attr:`__dict__` (if present). As outlined in :ref:`descriptors`, data + descriptors take preference over instance attributes, while non-data descriptors don't. Otherwise, an :exc:`AttributeError` is raised. -.. c:function:: int PyObject_SetAttr(PyObject *o, PyObject *attr_name, PyObject *v) +.. cfunction:: int PyObject_SetAttr(PyObject *o, PyObject *attr_name, PyObject *v) Set the value of the attribute named *attr_name*, for object *o*, to the value *v*. Returns ``-1`` on failure. This is the equivalent of the Python statement ``o.attr_name = v``. -.. c:function:: int PyObject_SetAttrString(PyObject *o, const char *attr_name, PyObject *v) +.. cfunction:: int PyObject_SetAttrString(PyObject *o, const char *attr_name, PyObject *v) Set the value of the attribute named *attr_name*, for object *o*, to the value *v*. Returns ``-1`` on failure. This is the equivalent of the Python statement ``o.attr_name = v``. -.. c:function:: int PyObject_GenericSetAttr(PyObject *o, PyObject *name, PyObject *value) +.. cfunction:: int PyObject_GenericSetAttr(PyObject *o, PyObject *name, PyObject *value) Generic attribute setter function that is meant to be put into a type object's ``tp_setattro`` slot. It looks for a data descriptor in the dictionary of classes in the object's MRO, and if found it takes preference over setting the attribute in the instance dictionary. Otherwise, the - attribute is set in the object's :attr:`~object.__dict__` (if present). - Otherwise, an :exc:`AttributeError` is raised and ``-1`` is returned. + attribute is set in the object's :attr:`__dict__` (if present). Otherwise, + an :exc:`AttributeError` is raised and ``-1`` is returned. -.. c:function:: int PyObject_DelAttr(PyObject *o, PyObject *attr_name) +.. cfunction:: int PyObject_DelAttr(PyObject *o, PyObject *attr_name) Delete attribute named *attr_name*, for object *o*. Returns ``-1`` on failure. This is the equivalent of the Python statement ``del o.attr_name``. -.. c:function:: int PyObject_DelAttrString(PyObject *o, const char *attr_name) +.. cfunction:: int PyObject_DelAttrString(PyObject *o, const char *attr_name) Delete attribute named *attr_name*, for object *o*. Returns ``-1`` on failure. This is the equivalent of the Python statement ``del o.attr_name``. -.. c:function:: PyObject* PyObject_RichCompare(PyObject *o1, PyObject *o2, int opid) +.. cfunction:: PyObject* PyObject_RichCompare(PyObject *o1, PyObject *o2, int opid) Compare the values of *o1* and *o2* using the operation specified by *opid*, which must be one of :const:`Py_LT`, :const:`Py_LE`, :const:`Py_EQ`, @@ -98,7 +98,7 @@ to *opid*. Returns the value of the comparison on success, or *NULL* on failure. -.. c:function:: int PyObject_RichCompareBool(PyObject *o1, PyObject *o2, int opid) +.. cfunction:: int PyObject_RichCompareBool(PyObject *o1, PyObject *o2, int opid) Compare the values of *o1* and *o2* using the operation specified by *opid*, which must be one of :const:`Py_LT`, :const:`Py_LE`, :const:`Py_EQ`, @@ -109,10 +109,10 @@ *opid*. .. note:: - If *o1* and *o2* are the same object, :c:func:`PyObject_RichCompareBool` + If *o1* and *o2* are the same object, :cfunc:`PyObject_RichCompareBool` will always return ``1`` for :const:`Py_EQ` and ``0`` for :const:`Py_NE`. -.. c:function:: int PyObject_Cmp(PyObject *o1, PyObject *o2, int *result) +.. cfunction:: int PyObject_Cmp(PyObject *o1, PyObject *o2, int *result) .. index:: builtin: cmp @@ -122,18 +122,18 @@ the Python statement ``result = cmp(o1, o2)``. -.. c:function:: int PyObject_Compare(PyObject *o1, PyObject *o2) +.. cfunction:: int PyObject_Compare(PyObject *o1, PyObject *o2) .. index:: builtin: cmp Compare the values of *o1* and *o2* using a routine provided by *o1*, if one exists, otherwise with a routine provided by *o2*. Returns the result of the comparison on success. On error, the value returned is undefined; use - :c:func:`PyErr_Occurred` to detect an error. This is equivalent to the Python + :cfunc:`PyErr_Occurred` to detect an error. This is equivalent to the Python expression ``cmp(o1, o2)``. -.. c:function:: PyObject* PyObject_Repr(PyObject *o) +.. cfunction:: PyObject* PyObject_Repr(PyObject *o) .. index:: builtin: repr @@ -143,7 +143,7 @@ by reverse quotes. -.. c:function:: PyObject* PyObject_Str(PyObject *o) +.. cfunction:: PyObject* PyObject_Str(PyObject *o) .. index:: builtin: str @@ -153,15 +153,15 @@ by the :keyword:`print` statement. -.. c:function:: PyObject* PyObject_Bytes(PyObject *o) +.. cfunction:: PyObject* PyObject_Bytes(PyObject *o) .. index:: builtin: bytes Compute a bytes representation of object *o*. In 2.x, this is just a alias - for :c:func:`PyObject_Str`. + for :cfunc:`PyObject_Str`. -.. c:function:: PyObject* PyObject_Unicode(PyObject *o) +.. cfunction:: PyObject* PyObject_Unicode(PyObject *o) .. index:: builtin: unicode @@ -171,18 +171,18 @@ function. -.. c:function:: int PyObject_IsInstance(PyObject *inst, PyObject *cls) +.. cfunction:: int PyObject_IsInstance(PyObject *inst, PyObject *cls) Returns ``1`` if *inst* is an instance of the class *cls* or a subclass of *cls*, or ``0`` if not. On error, returns ``-1`` and sets an exception. If - *cls* is a type object rather than a class object, :c:func:`PyObject_IsInstance` + *cls* is a type object rather than a class object, :cfunc:`PyObject_IsInstance` returns ``1`` if *inst* is of type *cls*. If *cls* is a tuple, the check will be done against every entry in *cls*. The result will be ``1`` when at least one of the checks returns ``1``, otherwise it will be ``0``. If *inst* is not a class instance and *cls* is neither a type object, nor a class object, nor a - tuple, *inst* must have a :attr:`~instance.__class__` attribute --- the - class relationship of the value of that attribute with *cls* will be used - to determine the result of this function. + tuple, *inst* must have a :attr:`__class__` attribute --- the class relationship + of the value of that attribute with *cls* will be used to determine the result + of this function. .. versionadded:: 2.1 @@ -195,13 +195,13 @@ :class:`A` if it inherits from :class:`A` either directly or indirectly. If either is not a class object, a more general mechanism is used to determine the class relationship of the two objects. When testing if *B* is a subclass of -*A*, if *A* is *B*, :c:func:`PyObject_IsSubclass` returns true. If *A* and *B* -are different objects, *B*'s :attr:`~class.__bases__` attribute is searched in -a depth-first fashion for *A* --- the presence of the :attr:`~class.__bases__` -attribute is considered sufficient for this determination. +*A*, if *A* is *B*, :cfunc:`PyObject_IsSubclass` returns true. If *A* and *B* +are different objects, *B*'s :attr:`__bases__` attribute is searched in a +depth-first fashion for *A* --- the presence of the :attr:`__bases__` attribute +is considered sufficient for this determination. -.. c:function:: int PyObject_IsSubclass(PyObject *derived, PyObject *cls) +.. cfunction:: int PyObject_IsSubclass(PyObject *derived, PyObject *cls) Returns ``1`` if the class *derived* is identical to or derived from the class *cls*, otherwise returns ``0``. In case of an error, returns ``-1``. If *cls* @@ -216,13 +216,13 @@ Older versions of Python did not support a tuple as the second argument. -.. c:function:: int PyCallable_Check(PyObject *o) +.. cfunction:: int PyCallable_Check(PyObject *o) Determine if the object *o* is callable. Return ``1`` if the object is callable and ``0`` otherwise. This function always succeeds. -.. c:function:: PyObject* PyObject_Call(PyObject *callable_object, PyObject *args, PyObject *kw) +.. cfunction:: PyObject* PyObject_Call(PyObject *callable_object, PyObject *args, PyObject *kw) .. index:: builtin: apply @@ -236,7 +236,7 @@ .. versionadded:: 2.2 -.. c:function:: PyObject* PyObject_CallObject(PyObject *callable_object, PyObject *args) +.. cfunction:: PyObject* PyObject_CallObject(PyObject *callable_object, PyObject *args) .. index:: builtin: apply @@ -247,52 +247,52 @@ ``callable_object(*args)``. -.. c:function:: PyObject* PyObject_CallFunction(PyObject *callable, char *format, ...) +.. cfunction:: PyObject* PyObject_CallFunction(PyObject *callable, char *format, ...) .. index:: builtin: apply Call a callable Python object *callable*, with a variable number of C arguments. - The C arguments are described using a :c:func:`Py_BuildValue` style format + The C arguments are described using a :cfunc:`Py_BuildValue` style format string. The format may be *NULL*, indicating that no arguments are provided. Returns the result of the call on success, or *NULL* on failure. This is the equivalent of the Python expression ``apply(callable, args)`` or - ``callable(*args)``. Note that if you only pass :c:type:`PyObject \*` args, - :c:func:`PyObject_CallFunctionObjArgs` is a faster alternative. + ``callable(*args)``. Note that if you only pass :ctype:`PyObject \*` args, + :cfunc:`PyObject_CallFunctionObjArgs` is a faster alternative. -.. c:function:: PyObject* PyObject_CallMethod(PyObject *o, char *method, char *format, ...) +.. cfunction:: PyObject* PyObject_CallMethod(PyObject *o, char *method, char *format, ...) Call the method named *method* of object *o* with a variable number of C - arguments. The C arguments are described by a :c:func:`Py_BuildValue` format + arguments. The C arguments are described by a :cfunc:`Py_BuildValue` format string that should produce a tuple. The format may be *NULL*, indicating that no arguments are provided. Returns the result of the call on success, or *NULL* on failure. This is the equivalent of the Python expression ``o.method(args)``. - Note that if you only pass :c:type:`PyObject \*` args, - :c:func:`PyObject_CallMethodObjArgs` is a faster alternative. + Note that if you only pass :ctype:`PyObject \*` args, + :cfunc:`PyObject_CallMethodObjArgs` is a faster alternative. -.. c:function:: PyObject* PyObject_CallFunctionObjArgs(PyObject *callable, ..., NULL) +.. cfunction:: PyObject* PyObject_CallFunctionObjArgs(PyObject *callable, ..., NULL) Call a callable Python object *callable*, with a variable number of - :c:type:`PyObject\*` arguments. The arguments are provided as a variable number + :ctype:`PyObject\*` arguments. The arguments are provided as a variable number of parameters followed by *NULL*. Returns the result of the call on success, or *NULL* on failure. .. versionadded:: 2.2 -.. c:function:: PyObject* PyObject_CallMethodObjArgs(PyObject *o, PyObject *name, ..., NULL) +.. cfunction:: PyObject* PyObject_CallMethodObjArgs(PyObject *o, PyObject *name, ..., NULL) Calls a method of the object *o*, where the name of the method is given as a Python string object in *name*. It is called with a variable number of - :c:type:`PyObject\*` arguments. The arguments are provided as a variable number + :ctype:`PyObject\*` arguments. The arguments are provided as a variable number of parameters followed by *NULL*. Returns the result of the call on success, or *NULL* on failure. .. versionadded:: 2.2 -.. c:function:: long PyObject_Hash(PyObject *o) +.. cfunction:: long PyObject_Hash(PyObject *o) .. index:: builtin: hash @@ -300,7 +300,7 @@ This is the equivalent of the Python expression ``hash(o)``. -.. c:function:: long PyObject_HashNotImplemented(PyObject *o) +.. cfunction:: long PyObject_HashNotImplemented(PyObject *o) Set a :exc:`TypeError` indicating that ``type(o)`` is not hashable and return ``-1``. This function receives special treatment when stored in a ``tp_hash`` slot, @@ -310,21 +310,21 @@ .. versionadded:: 2.6 -.. c:function:: int PyObject_IsTrue(PyObject *o) +.. cfunction:: int PyObject_IsTrue(PyObject *o) Returns ``1`` if the object *o* is considered to be true, and ``0`` otherwise. This is equivalent to the Python expression ``not not o``. On failure, return ``-1``. -.. c:function:: int PyObject_Not(PyObject *o) +.. cfunction:: int PyObject_Not(PyObject *o) Returns ``0`` if the object *o* is considered to be true, and ``1`` otherwise. This is equivalent to the Python expression ``not o``. On failure, return ``-1``. -.. c:function:: PyObject* PyObject_Type(PyObject *o) +.. cfunction:: PyObject* PyObject_Type(PyObject *o) .. index:: builtin: type @@ -333,11 +333,11 @@ is equivalent to the Python expression ``type(o)``. This function increments the reference count of the return value. There's really no reason to use this function instead of the common expression ``o->ob_type``, which returns a - pointer of type :c:type:`PyTypeObject\*`, except when the incremented reference + pointer of type :ctype:`PyTypeObject\*`, except when the incremented reference count is needed. -.. c:function:: int PyObject_TypeCheck(PyObject *o, PyTypeObject *type) +.. cfunction:: int PyObject_TypeCheck(PyObject *o, PyTypeObject *type) Return true if the object *o* is of type *type* or a subtype of *type*. Both parameters must be non-*NULL*. @@ -345,7 +345,7 @@ .. versionadded:: 2.2 -.. c:function:: Py_ssize_t PyObject_Length(PyObject *o) +.. cfunction:: Py_ssize_t PyObject_Length(PyObject *o) Py_ssize_t PyObject_Size(PyObject *o) .. index:: builtin: len @@ -355,29 +355,29 @@ returned. This is the equivalent to the Python expression ``len(o)``. .. versionchanged:: 2.5 - These functions returned an :c:type:`int` type. This might require + These functions returned an :ctype:`int` type. This might require changes in your code for properly supporting 64-bit systems. -.. c:function:: PyObject* PyObject_GetItem(PyObject *o, PyObject *key) +.. cfunction:: PyObject* PyObject_GetItem(PyObject *o, PyObject *key) Return element of *o* corresponding to the object *key* or *NULL* on failure. This is the equivalent of the Python expression ``o[key]``. -.. c:function:: int PyObject_SetItem(PyObject *o, PyObject *key, PyObject *v) +.. cfunction:: int PyObject_SetItem(PyObject *o, PyObject *key, PyObject *v) Map the object *key* to the value *v*. Returns ``-1`` on failure. This is the equivalent of the Python statement ``o[key] = v``. -.. c:function:: int PyObject_DelItem(PyObject *o, PyObject *key) +.. cfunction:: int PyObject_DelItem(PyObject *o, PyObject *key) Delete the mapping for *key* from *o*. Returns ``-1`` on failure. This is the equivalent of the Python statement ``del o[key]``. -.. c:function:: int PyObject_AsFileDescriptor(PyObject *o) +.. cfunction:: int PyObject_AsFileDescriptor(PyObject *o) Derives a file descriptor from a Python object. If the object is an integer or long integer, its value is returned. If not, the object's :meth:`fileno` method @@ -385,16 +385,16 @@ is returned as the file descriptor value. Returns ``-1`` on failure. -.. c:function:: PyObject* PyObject_Dir(PyObject *o) +.. cfunction:: PyObject* PyObject_Dir(PyObject *o) This is equivalent to the Python expression ``dir(o)``, returning a (possibly empty) list of strings appropriate for the object argument, or *NULL* if there was an error. If the argument is *NULL*, this is like the Python ``dir()``, returning the names of the current locals; in this case, if no execution frame - is active then *NULL* is returned but :c:func:`PyErr_Occurred` will return false. + is active then *NULL* is returned but :cfunc:`PyErr_Occurred` will return false. -.. c:function:: PyObject* PyObject_GetIter(PyObject *o) +.. cfunction:: PyObject* PyObject_GetIter(PyObject *o) This is equivalent to the Python expression ``iter(o)``. It returns a new iterator for the object argument, or the object itself if the object is already diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/c-api/refcounting.rst --- a/Doc/c-api/refcounting.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/c-api/refcounting.rst Sun Jul 20 10:52:46 2014 -0400 @@ -11,22 +11,22 @@ objects. -.. c:function:: void Py_INCREF(PyObject *o) +.. cfunction:: void Py_INCREF(PyObject *o) Increment the reference count for object *o*. The object must not be *NULL*; if - you aren't sure that it isn't *NULL*, use :c:func:`Py_XINCREF`. + you aren't sure that it isn't *NULL*, use :cfunc:`Py_XINCREF`. -.. c:function:: void Py_XINCREF(PyObject *o) +.. cfunction:: void Py_XINCREF(PyObject *o) Increment the reference count for object *o*. The object may be *NULL*, in which case the macro has no effect. -.. c:function:: void Py_DECREF(PyObject *o) +.. cfunction:: void Py_DECREF(PyObject *o) Decrement the reference count for object *o*. The object must not be *NULL*; if - you aren't sure that it isn't *NULL*, use :c:func:`Py_XDECREF`. If the reference + you aren't sure that it isn't *NULL*, use :cfunc:`Py_XDECREF`. If the reference count reaches zero, the object's type's deallocation function (which must not be *NULL*) is invoked. @@ -36,25 +36,25 @@ when a class instance with a :meth:`__del__` method is deallocated). While exceptions in such code are not propagated, the executed code has free access to all Python global variables. This means that any object that is reachable from - a global variable should be in a consistent state before :c:func:`Py_DECREF` is + a global variable should be in a consistent state before :cfunc:`Py_DECREF` is invoked. For example, code to delete an object from a list should copy a reference to the deleted object in a temporary variable, update the list data - structure, and then call :c:func:`Py_DECREF` for the temporary variable. + structure, and then call :cfunc:`Py_DECREF` for the temporary variable. -.. c:function:: void Py_XDECREF(PyObject *o) +.. cfunction:: void Py_XDECREF(PyObject *o) Decrement the reference count for object *o*. The object may be *NULL*, in which case the macro has no effect; otherwise the effect is the same as for - :c:func:`Py_DECREF`, and the same warning applies. + :cfunc:`Py_DECREF`, and the same warning applies. -.. c:function:: void Py_CLEAR(PyObject *o) +.. cfunction:: void Py_CLEAR(PyObject *o) Decrement the reference count for object *o*. The object may be *NULL*, in which case the macro has no effect; otherwise the effect is the same as for - :c:func:`Py_DECREF`, except that the argument is also set to *NULL*. The warning - for :c:func:`Py_DECREF` does not apply with respect to the object passed because + :cfunc:`Py_DECREF`, except that the argument is also set to *NULL*. The warning + for :cfunc:`Py_DECREF` does not apply with respect to the object passed because the macro carefully uses a temporary variable and sets the argument to *NULL* before decrementing its reference count. @@ -65,10 +65,10 @@ The following functions are for runtime dynamic embedding of Python: ``Py_IncRef(PyObject *o)``, ``Py_DecRef(PyObject *o)``. They are -simply exported function versions of :c:func:`Py_XINCREF` and -:c:func:`Py_XDECREF`, respectively. +simply exported function versions of :cfunc:`Py_XINCREF` and +:cfunc:`Py_XDECREF`, respectively. The following functions or macros are only for use within the interpreter core: -:c:func:`_Py_Dealloc`, :c:func:`_Py_ForgetReference`, :c:func:`_Py_NewReference`, -as well as the global variable :c:data:`_Py_RefTotal`. +:cfunc:`_Py_Dealloc`, :cfunc:`_Py_ForgetReference`, :cfunc:`_Py_NewReference`, +as well as the global variable :cdata:`_Py_RefTotal`. diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/c-api/reflection.rst --- a/Doc/c-api/reflection.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/c-api/reflection.rst Sun Jul 20 10:52:46 2014 -0400 @@ -5,51 +5,51 @@ Reflection ========== -.. c:function:: PyObject* PyEval_GetBuiltins() +.. cfunction:: PyObject* PyEval_GetBuiltins() Return a dictionary of the builtins in the current execution frame, or the interpreter of the thread state if no frame is currently executing. -.. c:function:: PyObject* PyEval_GetLocals() +.. cfunction:: PyObject* PyEval_GetLocals() Return a dictionary of the local variables in the current execution frame, or *NULL* if no frame is currently executing. -.. c:function:: PyObject* PyEval_GetGlobals() +.. cfunction:: PyObject* PyEval_GetGlobals() Return a dictionary of the global variables in the current execution frame, or *NULL* if no frame is currently executing. -.. c:function:: PyFrameObject* PyEval_GetFrame() +.. cfunction:: PyFrameObject* PyEval_GetFrame() Return the current thread state's frame, which is *NULL* if no frame is currently executing. -.. c:function:: int PyFrame_GetLineNumber(PyFrameObject *frame) +.. cfunction:: int PyFrame_GetLineNumber(PyFrameObject *frame) Return the line number that *frame* is currently executing. -.. c:function:: int PyEval_GetRestricted() +.. cfunction:: int PyEval_GetRestricted() If there is a current frame and it is executing in restricted mode, return true, otherwise false. -.. c:function:: const char* PyEval_GetFuncName(PyObject *func) +.. cfunction:: const char* PyEval_GetFuncName(PyObject *func) Return the name of *func* if it is a function, class or instance object, else the name of *func*\s type. -.. c:function:: const char* PyEval_GetFuncDesc(PyObject *func) +.. cfunction:: const char* PyEval_GetFuncDesc(PyObject *func) Return a description string, depending on the type of *func*. Return values include "()" for functions and methods, " constructor", " instance", and " object". Concatenated with the result of - :c:func:`PyEval_GetFuncName`, the result will be a description of + :cfunc:`PyEval_GetFuncName`, the result will be a description of *func*. diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/c-api/sequence.rst --- a/Doc/c-api/sequence.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/c-api/sequence.rst Sun Jul 20 10:52:46 2014 -0400 @@ -6,13 +6,13 @@ ================= -.. c:function:: int PySequence_Check(PyObject *o) +.. cfunction:: int PySequence_Check(PyObject *o) Return ``1`` if the object provides sequence protocol, and ``0`` otherwise. This function always succeeds. -.. c:function:: Py_ssize_t PySequence_Size(PyObject *o) +.. cfunction:: Py_ssize_t PySequence_Size(PyObject *o) Py_ssize_t PySequence_Length(PyObject *o) .. index:: builtin: len @@ -22,140 +22,140 @@ Python expression ``len(o)``. .. versionchanged:: 2.5 - These functions returned an :c:type:`int` type. This might require + These functions returned an :ctype:`int` type. This might require changes in your code for properly supporting 64-bit systems. -.. c:function:: PyObject* PySequence_Concat(PyObject *o1, PyObject *o2) +.. cfunction:: PyObject* PySequence_Concat(PyObject *o1, PyObject *o2) Return the concatenation of *o1* and *o2* on success, and *NULL* on failure. This is the equivalent of the Python expression ``o1 + o2``. -.. c:function:: PyObject* PySequence_Repeat(PyObject *o, Py_ssize_t count) +.. cfunction:: PyObject* PySequence_Repeat(PyObject *o, Py_ssize_t count) Return the result of repeating sequence object *o* *count* times, or *NULL* on failure. This is the equivalent of the Python expression ``o * count``. .. versionchanged:: 2.5 - This function used an :c:type:`int` type for *count*. This might require + This function used an :ctype:`int` type for *count*. This might require changes in your code for properly supporting 64-bit systems. -.. c:function:: PyObject* PySequence_InPlaceConcat(PyObject *o1, PyObject *o2) +.. cfunction:: PyObject* PySequence_InPlaceConcat(PyObject *o1, PyObject *o2) Return the concatenation of *o1* and *o2* on success, and *NULL* on failure. The operation is done *in-place* when *o1* supports it. This is the equivalent of the Python expression ``o1 += o2``. -.. c:function:: PyObject* PySequence_InPlaceRepeat(PyObject *o, Py_ssize_t count) +.. cfunction:: PyObject* PySequence_InPlaceRepeat(PyObject *o, Py_ssize_t count) Return the result of repeating sequence object *o* *count* times, or *NULL* on failure. The operation is done *in-place* when *o* supports it. This is the equivalent of the Python expression ``o *= count``. .. versionchanged:: 2.5 - This function used an :c:type:`int` type for *count*. This might require + This function used an :ctype:`int` type for *count*. This might require changes in your code for properly supporting 64-bit systems. -.. c:function:: PyObject* PySequence_GetItem(PyObject *o, Py_ssize_t i) +.. cfunction:: PyObject* PySequence_GetItem(PyObject *o, Py_ssize_t i) Return the *i*\ th element of *o*, or *NULL* on failure. This is the equivalent of the Python expression ``o[i]``. .. versionchanged:: 2.5 - This function used an :c:type:`int` type for *i*. This might require + This function used an :ctype:`int` type for *i*. This might require changes in your code for properly supporting 64-bit systems. -.. c:function:: PyObject* PySequence_GetSlice(PyObject *o, Py_ssize_t i1, Py_ssize_t i2) +.. cfunction:: PyObject* PySequence_GetSlice(PyObject *o, Py_ssize_t i1, Py_ssize_t i2) Return the slice of sequence object *o* between *i1* and *i2*, or *NULL* on failure. This is the equivalent of the Python expression ``o[i1:i2]``. .. versionchanged:: 2.5 - This function used an :c:type:`int` type for *i1* and *i2*. This might + This function used an :ctype:`int` type for *i1* and *i2*. This might require changes in your code for properly supporting 64-bit systems. -.. c:function:: int PySequence_SetItem(PyObject *o, Py_ssize_t i, PyObject *v) +.. cfunction:: int PySequence_SetItem(PyObject *o, Py_ssize_t i, PyObject *v) Assign object *v* to the *i*\ th element of *o*. Returns ``-1`` on failure. This is the equivalent of the Python statement ``o[i] = v``. This function *does not* steal a reference to *v*. .. versionchanged:: 2.5 - This function used an :c:type:`int` type for *i*. This might require + This function used an :ctype:`int` type for *i*. This might require changes in your code for properly supporting 64-bit systems. -.. c:function:: int PySequence_DelItem(PyObject *o, Py_ssize_t i) +.. cfunction:: int PySequence_DelItem(PyObject *o, Py_ssize_t i) Delete the *i*\ th element of object *o*. Returns ``-1`` on failure. This is the equivalent of the Python statement ``del o[i]``. .. versionchanged:: 2.5 - This function used an :c:type:`int` type for *i*. This might require + This function used an :ctype:`int` type for *i*. This might require changes in your code for properly supporting 64-bit systems. -.. c:function:: int PySequence_SetSlice(PyObject *o, Py_ssize_t i1, Py_ssize_t i2, PyObject *v) +.. cfunction:: int PySequence_SetSlice(PyObject *o, Py_ssize_t i1, Py_ssize_t i2, PyObject *v) Assign the sequence object *v* to the slice in sequence object *o* from *i1* to *i2*. This is the equivalent of the Python statement ``o[i1:i2] = v``. .. versionchanged:: 2.5 - This function used an :c:type:`int` type for *i1* and *i2*. This might + This function used an :ctype:`int` type for *i1* and *i2*. This might require changes in your code for properly supporting 64-bit systems. -.. c:function:: int PySequence_DelSlice(PyObject *o, Py_ssize_t i1, Py_ssize_t i2) +.. cfunction:: int PySequence_DelSlice(PyObject *o, Py_ssize_t i1, Py_ssize_t i2) Delete the slice in sequence object *o* from *i1* to *i2*. Returns ``-1`` on failure. This is the equivalent of the Python statement ``del o[i1:i2]``. .. versionchanged:: 2.5 - This function used an :c:type:`int` type for *i1* and *i2*. This might + This function used an :ctype:`int` type for *i1* and *i2*. This might require changes in your code for properly supporting 64-bit systems. -.. c:function:: Py_ssize_t PySequence_Count(PyObject *o, PyObject *value) +.. cfunction:: Py_ssize_t PySequence_Count(PyObject *o, PyObject *value) Return the number of occurrences of *value* in *o*, that is, return the number of keys for which ``o[key] == value``. On failure, return ``-1``. This is equivalent to the Python expression ``o.count(value)``. .. versionchanged:: 2.5 - This function returned an :c:type:`int` type. This might require changes + This function returned an :ctype:`int` type. This might require changes in your code for properly supporting 64-bit systems. -.. c:function:: int PySequence_Contains(PyObject *o, PyObject *value) +.. cfunction:: int PySequence_Contains(PyObject *o, PyObject *value) Determine if *o* contains *value*. If an item in *o* is equal to *value*, return ``1``, otherwise return ``0``. On error, return ``-1``. This is equivalent to the Python expression ``value in o``. -.. c:function:: Py_ssize_t PySequence_Index(PyObject *o, PyObject *value) +.. cfunction:: Py_ssize_t PySequence_Index(PyObject *o, PyObject *value) Return the first index *i* for which ``o[i] == value``. On error, return ``-1``. This is equivalent to the Python expression ``o.index(value)``. .. versionchanged:: 2.5 - This function returned an :c:type:`int` type. This might require changes + This function returned an :ctype:`int` type. This might require changes in your code for properly supporting 64-bit systems. -.. c:function:: PyObject* PySequence_List(PyObject *o) +.. cfunction:: PyObject* PySequence_List(PyObject *o) Return a list object with the same contents as the arbitrary sequence *o*. The returned list is guaranteed to be new. -.. c:function:: PyObject* PySequence_Tuple(PyObject *o) +.. cfunction:: PyObject* PySequence_Tuple(PyObject *o) .. index:: builtin: tuple @@ -165,28 +165,28 @@ equivalent to the Python expression ``tuple(o)``. -.. c:function:: PyObject* PySequence_Fast(PyObject *o, const char *m) +.. cfunction:: PyObject* PySequence_Fast(PyObject *o, const char *m) - Return the sequence *o* as a list, unless it is already a tuple or list, in - which case *o* is returned. Use :c:func:`PySequence_Fast_GET_ITEM` to access - the members of the result. Returns *NULL* on failure. If the object is not - a sequence, raises :exc:`TypeError` with *m* as the message text. + Returns the sequence *o* as a tuple, unless it is already a tuple or list, in + which case *o* is returned. Use :cfunc:`PySequence_Fast_GET_ITEM` to access the + members of the result. Returns *NULL* on failure. If the object is not a + sequence, raises :exc:`TypeError` with *m* as the message text. -.. c:function:: PyObject* PySequence_Fast_GET_ITEM(PyObject *o, Py_ssize_t i) +.. cfunction:: PyObject* PySequence_Fast_GET_ITEM(PyObject *o, Py_ssize_t i) Return the *i*\ th element of *o*, assuming that *o* was returned by - :c:func:`PySequence_Fast`, *o* is not *NULL*, and that *i* is within bounds. + :cfunc:`PySequence_Fast`, *o* is not *NULL*, and that *i* is within bounds. .. versionchanged:: 2.5 - This function used an :c:type:`int` type for *i*. This might require + This function used an :ctype:`int` type for *i*. This might require changes in your code for properly supporting 64-bit systems. -.. c:function:: PyObject** PySequence_Fast_ITEMS(PyObject *o) +.. cfunction:: PyObject** PySequence_Fast_ITEMS(PyObject *o) Return the underlying array of PyObject pointers. Assumes that *o* was returned - by :c:func:`PySequence_Fast` and *o* is not *NULL*. + by :cfunc:`PySequence_Fast` and *o* is not *NULL*. Note, if a list gets resized, the reallocation may relocate the items array. So, only use the underlying array pointer in contexts where the sequence @@ -195,24 +195,24 @@ .. versionadded:: 2.4 -.. c:function:: PyObject* PySequence_ITEM(PyObject *o, Py_ssize_t i) +.. cfunction:: PyObject* PySequence_ITEM(PyObject *o, Py_ssize_t i) Return the *i*\ th element of *o* or *NULL* on failure. Macro form of - :c:func:`PySequence_GetItem` but without checking that - :c:func:`PySequence_Check` on *o* is true and without adjustment for negative + :cfunc:`PySequence_GetItem` but without checking that + :cfunc:`PySequence_Check` on *o* is true and without adjustment for negative indices. .. versionadded:: 2.3 .. versionchanged:: 2.5 - This function used an :c:type:`int` type for *i*. This might require + This function used an :ctype:`int` type for *i*. This might require changes in your code for properly supporting 64-bit systems. -.. c:function:: Py_ssize_t PySequence_Fast_GET_SIZE(PyObject *o) +.. cfunction:: Py_ssize_t PySequence_Fast_GET_SIZE(PyObject *o) Returns the length of *o*, assuming that *o* was returned by - :c:func:`PySequence_Fast` and that *o* is not *NULL*. The size can also be - gotten by calling :c:func:`PySequence_Size` on *o*, but - :c:func:`PySequence_Fast_GET_SIZE` is faster because it can assume *o* is a list + :cfunc:`PySequence_Fast` and that *o* is not *NULL*. The size can also be + gotten by calling :cfunc:`PySequence_Size` on *o*, but + :cfunc:`PySequence_Fast_GET_SIZE` is faster because it can assume *o* is a list or tuple. diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/c-api/set.rst --- a/Doc/c-api/set.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/c-api/set.rst Sun Jul 20 10:52:46 2014 -0400 @@ -16,20 +16,20 @@ This section details the public API for :class:`set` and :class:`frozenset` objects. Any functionality not listed below is best accessed using the either -the abstract object protocol (including :c:func:`PyObject_CallMethod`, -:c:func:`PyObject_RichCompareBool`, :c:func:`PyObject_Hash`, -:c:func:`PyObject_Repr`, :c:func:`PyObject_IsTrue`, :c:func:`PyObject_Print`, and -:c:func:`PyObject_GetIter`) or the abstract number protocol (including -:c:func:`PyNumber_And`, :c:func:`PyNumber_Subtract`, :c:func:`PyNumber_Or`, -:c:func:`PyNumber_Xor`, :c:func:`PyNumber_InPlaceAnd`, -:c:func:`PyNumber_InPlaceSubtract`, :c:func:`PyNumber_InPlaceOr`, and -:c:func:`PyNumber_InPlaceXor`). +the abstract object protocol (including :cfunc:`PyObject_CallMethod`, +:cfunc:`PyObject_RichCompareBool`, :cfunc:`PyObject_Hash`, +:cfunc:`PyObject_Repr`, :cfunc:`PyObject_IsTrue`, :cfunc:`PyObject_Print`, and +:cfunc:`PyObject_GetIter`) or the abstract number protocol (including +:cfunc:`PyNumber_And`, :cfunc:`PyNumber_Subtract`, :cfunc:`PyNumber_Or`, +:cfunc:`PyNumber_Xor`, :cfunc:`PyNumber_InPlaceAnd`, +:cfunc:`PyNumber_InPlaceSubtract`, :cfunc:`PyNumber_InPlaceOr`, and +:cfunc:`PyNumber_InPlaceXor`). -.. c:type:: PySetObject +.. ctype:: PySetObject - This subtype of :c:type:`PyObject` is used to hold the internal data for both - :class:`set` and :class:`frozenset` objects. It is like a :c:type:`PyDictObject` + This subtype of :ctype:`PyObject` is used to hold the internal data for both + :class:`set` and :class:`frozenset` objects. It is like a :ctype:`PyDictObject` in that it is a fixed size for small sets (much like tuple storage) and will point to a separate, variable sized block of memory for medium and large sized sets (much like list storage). None of the fields of this structure should be @@ -37,53 +37,53 @@ the documented API rather than by manipulating the values in the structure. -.. c:var:: PyTypeObject PySet_Type +.. cvar:: PyTypeObject PySet_Type - This is an instance of :c:type:`PyTypeObject` representing the Python + This is an instance of :ctype:`PyTypeObject` representing the Python :class:`set` type. -.. c:var:: PyTypeObject PyFrozenSet_Type +.. cvar:: PyTypeObject PyFrozenSet_Type - This is an instance of :c:type:`PyTypeObject` representing the Python + This is an instance of :ctype:`PyTypeObject` representing the Python :class:`frozenset` type. The following type check macros work on pointers to any Python object. Likewise, the constructor functions work with any iterable Python object. -.. c:function:: int PySet_Check(PyObject *p) +.. cfunction:: int PySet_Check(PyObject *p) Return true if *p* is a :class:`set` object or an instance of a subtype. .. versionadded:: 2.6 -.. c:function:: int PyFrozenSet_Check(PyObject *p) +.. cfunction:: int PyFrozenSet_Check(PyObject *p) Return true if *p* is a :class:`frozenset` object or an instance of a subtype. .. versionadded:: 2.6 -.. c:function:: int PyAnySet_Check(PyObject *p) +.. cfunction:: int PyAnySet_Check(PyObject *p) Return true if *p* is a :class:`set` object, a :class:`frozenset` object, or an instance of a subtype. -.. c:function:: int PyAnySet_CheckExact(PyObject *p) +.. cfunction:: int PyAnySet_CheckExact(PyObject *p) Return true if *p* is a :class:`set` object or a :class:`frozenset` object but not an instance of a subtype. -.. c:function:: int PyFrozenSet_CheckExact(PyObject *p) +.. cfunction:: int PyFrozenSet_CheckExact(PyObject *p) Return true if *p* is a :class:`frozenset` object but not an instance of a subtype. -.. c:function:: PyObject* PySet_New(PyObject *iterable) +.. cfunction:: PyObject* PySet_New(PyObject *iterable) Return a new :class:`set` containing objects returned by the *iterable*. The *iterable* may be *NULL* to create a new empty set. Return the new set on @@ -92,7 +92,7 @@ (``c=set(s)``). -.. c:function:: PyObject* PyFrozenSet_New(PyObject *iterable) +.. cfunction:: PyObject* PyFrozenSet_New(PyObject *iterable) Return a new :class:`frozenset` containing objects returned by the *iterable*. The *iterable* may be *NULL* to create a new empty frozenset. Return the new @@ -108,7 +108,7 @@ or :class:`frozenset` or instances of their subtypes. -.. c:function:: Py_ssize_t PySet_Size(PyObject *anyset) +.. cfunction:: Py_ssize_t PySet_Size(PyObject *anyset) .. index:: builtin: len @@ -117,16 +117,16 @@ :class:`set`, :class:`frozenset`, or an instance of a subtype. .. versionchanged:: 2.5 - This function returned an :c:type:`int`. This might require changes in + This function returned an :ctype:`int`. This might require changes in your code for properly supporting 64-bit systems. -.. c:function:: Py_ssize_t PySet_GET_SIZE(PyObject *anyset) +.. cfunction:: Py_ssize_t PySet_GET_SIZE(PyObject *anyset) - Macro form of :c:func:`PySet_Size` without error checking. + Macro form of :cfunc:`PySet_Size` without error checking. -.. c:function:: int PySet_Contains(PyObject *anyset, PyObject *key) +.. cfunction:: int PySet_Contains(PyObject *anyset, PyObject *key) Return 1 if found, 0 if not found, and -1 if an error is encountered. Unlike the Python :meth:`__contains__` method, this function does not automatically @@ -135,7 +135,7 @@ :class:`set`, :class:`frozenset`, or an instance of a subtype. -.. c:function:: int PySet_Add(PyObject *set, PyObject *key) +.. cfunction:: int PySet_Add(PyObject *set, PyObject *key) Add *key* to a :class:`set` instance. Does not apply to :class:`frozenset` instances. Return 0 on success or -1 on failure. Raise a :exc:`TypeError` if @@ -145,24 +145,24 @@ .. versionchanged:: 2.6 Now works with instances of :class:`frozenset` or its subtypes. - Like :c:func:`PyTuple_SetItem` in that it can be used to fill-in the + Like :cfunc:`PyTuple_SetItem` in that it can be used to fill-in the values of brand new frozensets before they are exposed to other code. The following functions are available for instances of :class:`set` or its subtypes but not for instances of :class:`frozenset` or its subtypes. -.. c:function:: int PySet_Discard(PyObject *set, PyObject *key) +.. cfunction:: int PySet_Discard(PyObject *set, PyObject *key) Return 1 if found and removed, 0 if not found (no action taken), and -1 if an error is encountered. Does not raise :exc:`KeyError` for missing keys. Raise a - :exc:`TypeError` if the *key* is unhashable. Unlike the Python :meth:`~set.discard` + :exc:`TypeError` if the *key* is unhashable. Unlike the Python :meth:`discard` method, this function does not automatically convert unhashable sets into temporary frozensets. Raise :exc:`PyExc_SystemError` if *set* is an not an instance of :class:`set` or its subtype. -.. c:function:: PyObject* PySet_Pop(PyObject *set) +.. cfunction:: PyObject* PySet_Pop(PyObject *set) Return a new reference to an arbitrary object in the *set*, and removes the object from the *set*. Return *NULL* on failure. Raise :exc:`KeyError` if the @@ -170,6 +170,6 @@ :class:`set` or its subtype. -.. c:function:: int PySet_Clear(PyObject *set) +.. cfunction:: int PySet_Clear(PyObject *set) Empty an existing set of all elements. diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/c-api/slice.rst --- a/Doc/c-api/slice.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/c-api/slice.rst Sun Jul 20 10:52:46 2014 -0400 @@ -6,7 +6,7 @@ ------------- -.. c:var:: PyTypeObject PySlice_Type +.. cvar:: PyTypeObject PySlice_Type .. index:: single: SliceType (in module types) @@ -14,12 +14,12 @@ ``types.SliceType``. -.. c:function:: int PySlice_Check(PyObject *ob) +.. cfunction:: int PySlice_Check(PyObject *ob) Return true if *ob* is a slice object; *ob* must not be *NULL*. -.. c:function:: PyObject* PySlice_New(PyObject *start, PyObject *stop, PyObject *step) +.. cfunction:: PyObject* PySlice_New(PyObject *start, PyObject *stop, PyObject *step) Return a new slice object with the given values. The *start*, *stop*, and *step* parameters are used as the values of the slice object attributes of @@ -28,7 +28,7 @@ the new object could not be allocated. -.. c:function:: int PySlice_GetIndices(PySliceObject *slice, Py_ssize_t length, Py_ssize_t *start, Py_ssize_t *stop, Py_ssize_t *step) +.. cfunction:: int PySlice_GetIndices(PySliceObject *slice, Py_ssize_t length, Py_ssize_t *start, Py_ssize_t *stop, Py_ssize_t *step) Retrieve the start, stop and step indices from the slice object *slice*, assuming a sequence of length *length*. Treats indices greater than @@ -40,18 +40,18 @@ You probably do not want to use this function. If you want to use slice objects in versions of Python prior to 2.3, you would probably do well to - incorporate the source of :c:func:`PySlice_GetIndicesEx`, suitably renamed, + incorporate the source of :cfunc:`PySlice_GetIndicesEx`, suitably renamed, in the source of your extension. .. versionchanged:: 2.5 - This function used an :c:type:`int` type for *length* and an - :c:type:`int *` type for *start*, *stop*, and *step*. This might require + This function used an :ctype:`int` type for *length* and an + :ctype:`int *` type for *start*, *stop*, and *step*. This might require changes in your code for properly supporting 64-bit systems. -.. c:function:: int PySlice_GetIndicesEx(PySliceObject *slice, Py_ssize_t length, Py_ssize_t *start, Py_ssize_t *stop, Py_ssize_t *step, Py_ssize_t *slicelength) +.. cfunction:: int PySlice_GetIndicesEx(PySliceObject *slice, Py_ssize_t length, Py_ssize_t *start, Py_ssize_t *stop, Py_ssize_t *step, Py_ssize_t *slicelength) - Usable replacement for :c:func:`PySlice_GetIndices`. Retrieve the start, + Usable replacement for :cfunc:`PySlice_GetIndices`. Retrieve the start, stop, and step indices from the slice object *slice* assuming a sequence of length *length*, and store the length of the slice in *slicelength*. Out of bounds indices are clipped in a manner consistent with the handling of @@ -62,7 +62,7 @@ .. versionadded:: 2.3 .. versionchanged:: 2.5 - This function used an :c:type:`int` type for *length* and an - :c:type:`int *` type for *start*, *stop*, *step*, and *slicelength*. This + This function used an :ctype:`int` type for *length* and an + :ctype:`int *` type for *start*, *stop*, *step*, and *slicelength*. This might require changes in your code for properly supporting 64-bit systems. diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/c-api/string.rst --- a/Doc/c-api/string.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/c-api/string.rst Sun Jul 20 10:52:46 2014 -0400 @@ -17,20 +17,20 @@ .. index:: object: string -.. c:type:: PyStringObject +.. ctype:: PyStringObject - This subtype of :c:type:`PyObject` represents a Python string object. + This subtype of :ctype:`PyObject` represents a Python string object. -.. c:var:: PyTypeObject PyString_Type +.. cvar:: PyTypeObject PyString_Type .. index:: single: StringType (in module types) - This instance of :c:type:`PyTypeObject` represents the Python string type; it is + This instance of :ctype:`PyTypeObject` represents the Python string type; it is the same object as ``str`` and ``types.StringType`` in the Python layer. . -.. c:function:: int PyString_Check(PyObject *o) +.. cfunction:: int PyString_Check(PyObject *o) Return true if the object *o* is a string object or an instance of a subtype of the string type. @@ -39,7 +39,7 @@ Allowed subtypes to be accepted. -.. c:function:: int PyString_CheckExact(PyObject *o) +.. cfunction:: int PyString_CheckExact(PyObject *o) Return true if the object *o* is a string object, but not an instance of a subtype of the string type. @@ -47,27 +47,27 @@ .. versionadded:: 2.2 -.. c:function:: PyObject* PyString_FromString(const char *v) +.. cfunction:: PyObject* PyString_FromString(const char *v) Return a new string object with a copy of the string *v* as value on success, and *NULL* on failure. The parameter *v* must not be *NULL*; it will not be checked. -.. c:function:: PyObject* PyString_FromStringAndSize(const char *v, Py_ssize_t len) +.. cfunction:: PyObject* PyString_FromStringAndSize(const char *v, Py_ssize_t len) Return a new string object with a copy of the string *v* as value and length *len* on success, and *NULL* on failure. If *v* is *NULL*, the contents of the string are uninitialized. .. versionchanged:: 2.5 - This function used an :c:type:`int` type for *len*. This might require + This function used an :ctype:`int` type for *len*. This might require changes in your code for properly supporting 64-bit systems. -.. c:function:: PyObject* PyString_FromFormat(const char *format, ...) +.. cfunction:: PyObject* PyString_FromFormat(const char *format, ...) - Take a C :c:func:`printf`\ -style *format* string and a variable number of + Take a C :cfunc:`printf`\ -style *format* string and a variable number of arguments, calculate the size of the resulting Python string and return a string with the values formatted into it. The variable arguments must be C types and must correspond exactly to the format characters in the *format* string. The @@ -144,31 +144,31 @@ Support for `"%lld"` and `"%llu"` added. -.. c:function:: PyObject* PyString_FromFormatV(const char *format, va_list vargs) +.. cfunction:: PyObject* PyString_FromFormatV(const char *format, va_list vargs) - Identical to :c:func:`PyString_FromFormat` except that it takes exactly two + Identical to :cfunc:`PyString_FromFormat` except that it takes exactly two arguments. -.. c:function:: Py_ssize_t PyString_Size(PyObject *string) +.. cfunction:: Py_ssize_t PyString_Size(PyObject *string) Return the length of the string in string object *string*. .. versionchanged:: 2.5 - This function returned an :c:type:`int` type. This might require changes + This function returned an :ctype:`int` type. This might require changes in your code for properly supporting 64-bit systems. -.. c:function:: Py_ssize_t PyString_GET_SIZE(PyObject *string) +.. cfunction:: Py_ssize_t PyString_GET_SIZE(PyObject *string) - Macro form of :c:func:`PyString_Size` but without error checking. + Macro form of :cfunc:`PyString_Size` but without error checking. .. versionchanged:: 2.5 - This macro returned an :c:type:`int` type. This might require changes in + This macro returned an :ctype:`int` type. This might require changes in your code for properly supporting 64-bit systems. -.. c:function:: char* PyString_AsString(PyObject *string) +.. cfunction:: char* PyString_AsString(PyObject *string) Return a NUL-terminated representation of the contents of *string*. The pointer refers to the internal buffer of *string*, not a copy. The data must not be @@ -176,16 +176,16 @@ ``PyString_FromStringAndSize(NULL, size)``. It must not be deallocated. If *string* is a Unicode object, this function computes the default encoding of *string* and operates on that. If *string* is not a string object at all, - :c:func:`PyString_AsString` returns *NULL* and raises :exc:`TypeError`. + :cfunc:`PyString_AsString` returns *NULL* and raises :exc:`TypeError`. -.. c:function:: char* PyString_AS_STRING(PyObject *string) +.. cfunction:: char* PyString_AS_STRING(PyObject *string) - Macro form of :c:func:`PyString_AsString` but without error checking. Only + Macro form of :cfunc:`PyString_AsString` but without error checking. Only string objects are supported; no Unicode objects should be passed. -.. c:function:: int PyString_AsStringAndSize(PyObject *obj, char **buffer, Py_ssize_t *length) +.. cfunction:: int PyString_AsStringAndSize(PyObject *obj, char **buffer, Py_ssize_t *length) Return a NUL-terminated representation of the contents of the object *obj* through the output variables *buffer* and *length*. @@ -200,14 +200,14 @@ ``PyString_FromStringAndSize(NULL, size)``. It must not be deallocated. If *string* is a Unicode object, this function computes the default encoding of *string* and operates on that. If *string* is not a string object at all, - :c:func:`PyString_AsStringAndSize` returns ``-1`` and raises :exc:`TypeError`. + :cfunc:`PyString_AsStringAndSize` returns ``-1`` and raises :exc:`TypeError`. .. versionchanged:: 2.5 - This function used an :c:type:`int *` type for *length*. This might + This function used an :ctype:`int *` type for *length*. This might require changes in your code for properly supporting 64-bit systems. -.. c:function:: void PyString_Concat(PyObject **string, PyObject *newpart) +.. cfunction:: void PyString_Concat(PyObject **string, PyObject *newpart) Create a new string object in *\*string* containing the contents of *newpart* appended to *string*; the caller will own the new reference. The reference to @@ -216,13 +216,13 @@ *\*string* will be set to *NULL*; the appropriate exception will be set. -.. c:function:: void PyString_ConcatAndDel(PyObject **string, PyObject *newpart) +.. cfunction:: void PyString_ConcatAndDel(PyObject **string, PyObject *newpart) Create a new string object in *\*string* containing the contents of *newpart* appended to *string*. This version decrements the reference count of *newpart*. -.. c:function:: int _PyString_Resize(PyObject **string, Py_ssize_t newsize) +.. cfunction:: int _PyString_Resize(PyObject **string, Py_ssize_t newsize) A way to resize a string object even though it is "immutable". Only use this to build up a brand new string object; don't use this if the string may already be @@ -235,16 +235,16 @@ set to *NULL*, a memory exception is set, and ``-1`` is returned. .. versionchanged:: 2.5 - This function used an :c:type:`int` type for *newsize*. This might + This function used an :ctype:`int` type for *newsize*. This might require changes in your code for properly supporting 64-bit systems. -.. c:function:: PyObject* PyString_Format(PyObject *format, PyObject *args) +.. cfunction:: PyObject* PyString_Format(PyObject *format, PyObject *args) Return a new string object from *format* and *args*. Analogous to ``format % - args``. The *args* argument must be a tuple or dict. + args``. The *args* argument must be a tuple. -.. c:function:: void PyString_InternInPlace(PyObject **string) +.. cfunction:: void PyString_InternInPlace(PyObject **string) Intern the argument *\*string* in place. The argument must be the address of a pointer variable pointing to a Python string object. If there is an existing @@ -261,10 +261,10 @@ This function is not available in 3.x and does not have a PyBytes alias. -.. c:function:: PyObject* PyString_InternFromString(const char *v) +.. cfunction:: PyObject* PyString_InternFromString(const char *v) - A combination of :c:func:`PyString_FromString` and - :c:func:`PyString_InternInPlace`, returning either a new string object that has + A combination of :cfunc:`PyString_FromString` and + :cfunc:`PyString_InternInPlace`, returning either a new string object that has been interned, or a new ("owned") reference to an earlier interned string object with the same value. @@ -273,7 +273,7 @@ This function is not available in 3.x and does not have a PyBytes alias. -.. c:function:: PyObject* PyString_Decode(const char *s, Py_ssize_t size, const char *encoding, const char *errors) +.. cfunction:: PyObject* PyString_Decode(const char *s, Py_ssize_t size, const char *encoding, const char *errors) Create an object by decoding *size* bytes of the encoded buffer *s* using the codec registered for *encoding*. *encoding* and *errors* have the same meaning @@ -286,11 +286,11 @@ This function is not available in 3.x and does not have a PyBytes alias. .. versionchanged:: 2.5 - This function used an :c:type:`int` type for *size*. This might require + This function used an :ctype:`int` type for *size*. This might require changes in your code for properly supporting 64-bit systems. -.. c:function:: PyObject* PyString_AsDecodedObject(PyObject *str, const char *encoding, const char *errors) +.. cfunction:: PyObject* PyString_AsDecodedObject(PyObject *str, const char *encoding, const char *errors) Decode a string object by passing it to the codec registered for *encoding* and return the result as Python object. *encoding* and *errors* have the same @@ -303,9 +303,9 @@ This function is not available in 3.x and does not have a PyBytes alias. -.. c:function:: PyObject* PyString_Encode(const char *s, Py_ssize_t size, const char *encoding, const char *errors) +.. cfunction:: PyObject* PyString_Encode(const char *s, Py_ssize_t size, const char *encoding, const char *errors) - Encode the :c:type:`char` buffer of the given size by passing it to the codec + Encode the :ctype:`char` buffer of the given size by passing it to the codec registered for *encoding* and return a Python object. *encoding* and *errors* have the same meaning as the parameters of the same name in the string :meth:`encode` method. The codec to be used is looked up using the Python codec @@ -316,11 +316,11 @@ This function is not available in 3.x and does not have a PyBytes alias. .. versionchanged:: 2.5 - This function used an :c:type:`int` type for *size*. This might require + This function used an :ctype:`int` type for *size*. This might require changes in your code for properly supporting 64-bit systems. -.. c:function:: PyObject* PyString_AsEncodedObject(PyObject *str, const char *encoding, const char *errors) +.. cfunction:: PyObject* PyString_AsEncodedObject(PyObject *str, const char *encoding, const char *errors) Encode a string object using the codec registered for *encoding* and return the result as Python object. *encoding* and *errors* have the same meaning as the diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/c-api/structures.rst --- a/Doc/c-api/structures.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/c-api/structures.rst Sun Jul 20 10:52:46 2014 -0400 @@ -11,12 +11,12 @@ All Python objects ultimately share a small number of fields at the beginning of the object's representation in memory. These are represented by the -:c:type:`PyObject` and :c:type:`PyVarObject` types, which are defined, in turn, +:ctype:`PyObject` and :ctype:`PyVarObject` types, which are defined, in turn, by the expansions of some macros also used, whether directly or indirectly, in the definition of all other Python objects. -.. c:type:: PyObject +.. ctype:: PyObject All object types are extensions of this type. This is a type which contains the information Python needs to treat a pointer to an object as an @@ -26,79 +26,79 @@ macro. -.. c:type:: PyVarObject +.. ctype:: PyVarObject - This is an extension of :c:type:`PyObject` that adds the :attr:`ob_size` + This is an extension of :ctype:`PyObject` that adds the :attr:`ob_size` field. This is only used for objects that have some notion of *length*. This type does not often appear in the Python/C API. It corresponds to the fields defined by the expansion of the ``PyObject_VAR_HEAD`` macro. -These macros are used in the definition of :c:type:`PyObject` and -:c:type:`PyVarObject`: +These macros are used in the definition of :ctype:`PyObject` and +:ctype:`PyVarObject`: -.. c:macro:: PyObject_HEAD +.. cmacro:: PyObject_HEAD This is a macro which expands to the declarations of the fields of the - :c:type:`PyObject` type; it is used when declaring new types which represent + :ctype:`PyObject` type; it is used when declaring new types which represent objects without a varying length. The specific fields it expands to depend - on the definition of :c:macro:`Py_TRACE_REFS`. By default, that macro is - not defined, and :c:macro:`PyObject_HEAD` expands to:: + on the definition of :cmacro:`Py_TRACE_REFS`. By default, that macro is + not defined, and :cmacro:`PyObject_HEAD` expands to:: Py_ssize_t ob_refcnt; PyTypeObject *ob_type; - When :c:macro:`Py_TRACE_REFS` is defined, it expands to:: + When :cmacro:`Py_TRACE_REFS` is defined, it expands to:: PyObject *_ob_next, *_ob_prev; Py_ssize_t ob_refcnt; PyTypeObject *ob_type; -.. c:macro:: PyObject_VAR_HEAD +.. cmacro:: PyObject_VAR_HEAD This is a macro which expands to the declarations of the fields of the - :c:type:`PyVarObject` type; it is used when declaring new types which + :ctype:`PyVarObject` type; it is used when declaring new types which represent objects with a length that varies from instance to instance. This macro always expands to:: PyObject_HEAD Py_ssize_t ob_size; - Note that :c:macro:`PyObject_HEAD` is part of the expansion, and that its own - expansion varies depending on the definition of :c:macro:`Py_TRACE_REFS`. + Note that :cmacro:`PyObject_HEAD` is part of the expansion, and that its own + expansion varies depending on the definition of :cmacro:`Py_TRACE_REFS`. -.. c:macro:: PyObject_HEAD_INIT(type) +.. cmacro:: PyObject_HEAD_INIT(type) This is a macro which expands to initialization values for a new - :c:type:`PyObject` type. This macro expands to:: + :ctype:`PyObject` type. This macro expands to:: _PyObject_EXTRA_INIT 1, type, -.. c:macro:: PyVarObject_HEAD_INIT(type, size) +.. cmacro:: PyVarObject_HEAD_INIT(type, size) This is a macro which expands to initialization values for a new - :c:type:`PyVarObject` type, including the :attr:`ob_size` field. + :ctype:`PyVarObject` type, including the :attr:`ob_size` field. This macro expands to:: _PyObject_EXTRA_INIT 1, type, size, -.. c:type:: PyCFunction +.. ctype:: PyCFunction Type of the functions used to implement most Python callables in C. - Functions of this type take two :c:type:`PyObject\*` parameters and return + Functions of this type take two :ctype:`PyObject\*` parameters and return one such value. If the return value is *NULL*, an exception shall have been set. If not *NULL*, the return value is interpreted as the return value of the function as exposed in Python. The function must return a new reference. -.. c:type:: PyMethodDef +.. ctype:: PyMethodDef Structure used to describe a method of an extension type. This structure has four fields: @@ -119,10 +119,10 @@ +------------------+-------------+-------------------------------+ The :attr:`ml_meth` is a C function pointer. The functions may be of different -types, but they always return :c:type:`PyObject\*`. If the function is not of -the :c:type:`PyCFunction`, the compiler will require a cast in the method table. -Even though :c:type:`PyCFunction` defines the first parameter as -:c:type:`PyObject\*`, it is common that the method implementation uses a the +types, but they always return :ctype:`PyObject\*`. If the function is not of +the :ctype:`PyCFunction`, the compiler will require a cast in the method table. +Even though :ctype:`PyCFunction` defines the first parameter as +:ctype:`PyObject\*`, it is common that the method implementation uses a the specific C type of the *self* object. The :attr:`ml_flags` field is a bitfield which can include the following flags. @@ -136,27 +136,27 @@ .. data:: METH_VARARGS This is the typical calling convention, where the methods have the type - :c:type:`PyCFunction`. The function expects two :c:type:`PyObject\*` values. + :ctype:`PyCFunction`. The function expects two :ctype:`PyObject\*` values. The first one is the *self* object for methods; for module functions, it is the module object. The second parameter (often called *args*) is a tuple object representing all arguments. This parameter is typically processed - using :c:func:`PyArg_ParseTuple` or :c:func:`PyArg_UnpackTuple`. + using :cfunc:`PyArg_ParseTuple` or :cfunc:`PyArg_UnpackTuple`. .. data:: METH_KEYWORDS - Methods with these flags must be of type :c:type:`PyCFunctionWithKeywords`. + Methods with these flags must be of type :ctype:`PyCFunctionWithKeywords`. The function expects three parameters: *self*, *args*, and a dictionary of all the keyword arguments. The flag is typically combined with :const:`METH_VARARGS`, and the parameters are typically processed using - :c:func:`PyArg_ParseTupleAndKeywords`. + :cfunc:`PyArg_ParseTupleAndKeywords`. .. data:: METH_NOARGS Methods without parameters don't need to check whether arguments are given if they are listed with the :const:`METH_NOARGS` flag. They need to be of type - :c:type:`PyCFunction`. The first parameter is typically named ``self`` and + :ctype:`PyCFunction`. The first parameter is typically named ``self`` and will hold a reference to the module or object instance. In all cases the second parameter will be *NULL*. @@ -164,15 +164,15 @@ .. data:: METH_O Methods with a single object argument can be listed with the :const:`METH_O` - flag, instead of invoking :c:func:`PyArg_ParseTuple` with a ``"O"`` argument. - They have the type :c:type:`PyCFunction`, with the *self* parameter, and a - :c:type:`PyObject\*` parameter representing the single argument. + flag, instead of invoking :cfunc:`PyArg_ParseTuple` with a ``"O"`` argument. + They have the type :ctype:`PyCFunction`, with the *self* parameter, and a + :ctype:`PyObject\*` parameter representing the single argument. .. data:: METH_OLDARGS This calling convention is deprecated. The method must be of type - :c:type:`PyCFunction`. The second argument is *NULL* if no arguments are + :ctype:`PyCFunction`. The second argument is *NULL* if no arguments are given, a single object if exactly one argument is given, and a tuple of objects if more than one argument is given. There is no way for a function using this convention to distinguish between a call with multiple arguments @@ -225,7 +225,7 @@ .. versionadded:: 2.4 -.. c:type:: PyMemberDef +.. ctype:: PyMemberDef Structure which describes an attribute of a type which corresponds to a C struct member. Its fields are: @@ -277,22 +277,22 @@ T_PYSSIZET Py_ssize_t =============== ================== - :c:macro:`T_OBJECT` and :c:macro:`T_OBJECT_EX` differ in that - :c:macro:`T_OBJECT` returns ``None`` if the member is *NULL* and - :c:macro:`T_OBJECT_EX` raises an :exc:`AttributeError`. Try to use - :c:macro:`T_OBJECT_EX` over :c:macro:`T_OBJECT` because :c:macro:`T_OBJECT_EX` + :cmacro:`T_OBJECT` and :cmacro:`T_OBJECT_EX` differ in that + :cmacro:`T_OBJECT` returns ``None`` if the member is *NULL* and + :cmacro:`T_OBJECT_EX` raises an :exc:`AttributeError`. Try to use + :cmacro:`T_OBJECT_EX` over :cmacro:`T_OBJECT` because :cmacro:`T_OBJECT_EX` handles use of the :keyword:`del` statement on that attribute more correctly - than :c:macro:`T_OBJECT`. + than :cmacro:`T_OBJECT`. - :attr:`flags` can be 0 for write and read access or :c:macro:`READONLY` for - read-only access. Using :c:macro:`T_STRING` for :attr:`type` implies - :c:macro:`READONLY`. Only :c:macro:`T_OBJECT` and :c:macro:`T_OBJECT_EX` + :attr:`flags` can be 0 for write and read access or :cmacro:`READONLY` for + read-only access. Using :cmacro:`T_STRING` for :attr:`type` implies + :cmacro:`READONLY`. Only :cmacro:`T_OBJECT` and :cmacro:`T_OBJECT_EX` members can be deleted. (They are set to *NULL*). -.. c:function:: PyObject* Py_FindMethod(PyMethodDef table[], PyObject *ob, char *name) +.. cfunction:: PyObject* Py_FindMethod(PyMethodDef table[], PyObject *ob, char *name) Return a bound method object for an extension type implemented in C. This - can be useful in the implementation of a :c:member:`~PyTypeObject.tp_getattro` or - :c:member:`~PyTypeObject.tp_getattr` handler that does not use the - :c:func:`PyObject_GenericGetAttr` function. + can be useful in the implementation of a :attr:`tp_getattro` or + :attr:`tp_getattr` handler that does not use the + :cfunc:`PyObject_GenericGetAttr` function. diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/c-api/sys.rst --- a/Doc/c-api/sys.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/c-api/sys.rst Sun Jul 20 10:52:46 2014 -0400 @@ -6,16 +6,16 @@ ========================== -.. c:function:: int Py_FdIsInteractive(FILE *fp, const char *filename) +.. cfunction:: int Py_FdIsInteractive(FILE *fp, const char *filename) Return true (nonzero) if the standard I/O file *fp* with name *filename* is deemed interactive. This is the case for files for which ``isatty(fileno(fp))`` - is true. If the global flag :c:data:`Py_InteractiveFlag` is true, this function + is true. If the global flag :cdata:`Py_InteractiveFlag` is true, this function also returns true if the *filename* pointer is *NULL* or if the name is equal to one of the strings ``''`` or ``'???'``. -.. c:function:: void PyOS_AfterFork() +.. cfunction:: void PyOS_AfterFork() Function to update some internal state after a process fork; this should be called in the new process if the Python interpreter will continue to be used. @@ -23,7 +23,7 @@ to be called. -.. c:function:: int PyOS_CheckStack() +.. cfunction:: int PyOS_CheckStack() Return true when the interpreter runs out of stack space. This is a reliable check, but is only available when :const:`USE_STACKCHECK` is defined (currently @@ -32,20 +32,20 @@ own code. -.. c:function:: PyOS_sighandler_t PyOS_getsig(int i) +.. cfunction:: PyOS_sighandler_t PyOS_getsig(int i) Return the current signal handler for signal *i*. This is a thin wrapper around - either :c:func:`sigaction` or :c:func:`signal`. Do not call those functions - directly! :c:type:`PyOS_sighandler_t` is a typedef alias for :c:type:`void + either :cfunc:`sigaction` or :cfunc:`signal`. Do not call those functions + directly! :ctype:`PyOS_sighandler_t` is a typedef alias for :ctype:`void (\*)(int)`. -.. c:function:: PyOS_sighandler_t PyOS_setsig(int i, PyOS_sighandler_t h) +.. cfunction:: PyOS_sighandler_t PyOS_setsig(int i, PyOS_sighandler_t h) Set the signal handler for signal *i* to be *h*; return the old signal handler. - This is a thin wrapper around either :c:func:`sigaction` or :c:func:`signal`. Do - not call those functions directly! :c:type:`PyOS_sighandler_t` is a typedef - alias for :c:type:`void (\*)(int)`. + This is a thin wrapper around either :cfunc:`sigaction` or :cfunc:`signal`. Do + not call those functions directly! :ctype:`PyOS_sighandler_t` is a typedef + alias for :ctype:`void (\*)(int)`. .. _systemfunctions: @@ -56,38 +56,38 @@ accessible to C code. They all work with the current interpreter thread's :mod:`sys` module's dict, which is contained in the internal thread state structure. -.. c:function:: PyObject *PySys_GetObject(char *name) +.. cfunction:: PyObject *PySys_GetObject(char *name) Return the object *name* from the :mod:`sys` module or *NULL* if it does not exist, without setting an exception. -.. c:function:: FILE *PySys_GetFile(char *name, FILE *def) +.. cfunction:: FILE *PySys_GetFile(char *name, FILE *def) - Return the :c:type:`FILE*` associated with the object *name* in the + Return the :ctype:`FILE*` associated with the object *name* in the :mod:`sys` module, or *def* if *name* is not in the module or is not associated - with a :c:type:`FILE*`. + with a :ctype:`FILE*`. -.. c:function:: int PySys_SetObject(char *name, PyObject *v) +.. cfunction:: int PySys_SetObject(char *name, PyObject *v) Set *name* in the :mod:`sys` module to *v* unless *v* is *NULL*, in which case *name* is deleted from the sys module. Returns ``0`` on success, ``-1`` on error. -.. c:function:: void PySys_ResetWarnOptions() +.. cfunction:: void PySys_ResetWarnOptions() Reset :data:`sys.warnoptions` to an empty list. -.. c:function:: void PySys_AddWarnOption(char *s) +.. cfunction:: void PySys_AddWarnOption(char *s) Append *s* to :data:`sys.warnoptions`. -.. c:function:: void PySys_SetPath(char *path) +.. cfunction:: void PySys_SetPath(char *path) Set :data:`sys.path` to a list object of paths found in *path* which should be a list of paths separated with the platform's search path delimiter (``:`` on Unix, ``;`` on Windows). -.. c:function:: void PySys_WriteStdout(const char *format, ...) +.. cfunction:: void PySys_WriteStdout(const char *format, ...) Write the output string described by *format* to :data:`sys.stdout`. No exceptions are raised, even if truncation occurs (see below). @@ -103,7 +103,7 @@ If a problem occurs, or :data:`sys.stdout` is unset, the formatted message is written to the real (C level) *stdout*. -.. c:function:: void PySys_WriteStderr(const char *format, ...) +.. cfunction:: void PySys_WriteStderr(const char *format, ...) As above, but write to :data:`sys.stderr` or *stderr* instead. @@ -114,7 +114,7 @@ =============== -.. c:function:: void Py_FatalError(const char *message) +.. cfunction:: void Py_FatalError(const char *message) .. index:: single: abort() @@ -122,30 +122,30 @@ This function should only be invoked when a condition is detected that would make it dangerous to continue using the Python interpreter; e.g., when the object administration appears to be corrupted. On Unix, the standard C library - function :c:func:`abort` is called which will attempt to produce a :file:`core` + function :cfunc:`abort` is called which will attempt to produce a :file:`core` file. -.. c:function:: void Py_Exit(int status) +.. cfunction:: void Py_Exit(int status) .. index:: single: Py_Finalize() single: exit() - Exit the current process. This calls :c:func:`Py_Finalize` and then calls the + Exit the current process. This calls :cfunc:`Py_Finalize` and then calls the standard C library function ``exit(status)``. -.. c:function:: int Py_AtExit(void (*func) ()) +.. cfunction:: int Py_AtExit(void (*func) ()) .. index:: single: Py_Finalize() single: cleanup functions - Register a cleanup function to be called by :c:func:`Py_Finalize`. The cleanup + Register a cleanup function to be called by :cfunc:`Py_Finalize`. The cleanup function will be called with no arguments and should return no value. At most 32 cleanup functions can be registered. When the registration is successful, - :c:func:`Py_AtExit` returns ``0``; on failure, it returns ``-1``. The cleanup + :cfunc:`Py_AtExit` returns ``0``; on failure, it returns ``-1``. The cleanup function registered last is called first. Each cleanup function will be called at most once. Since Python's internal finalization will have completed before the cleanup function, no Python APIs should be called by *func*. diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/c-api/tuple.rst --- a/Doc/c-api/tuple.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/c-api/tuple.rst Sun Jul 20 10:52:46 2014 -0400 @@ -8,20 +8,20 @@ .. index:: object: tuple -.. c:type:: PyTupleObject +.. ctype:: PyTupleObject - This subtype of :c:type:`PyObject` represents a Python tuple object. + This subtype of :ctype:`PyObject` represents a Python tuple object. -.. c:var:: PyTypeObject PyTuple_Type +.. cvar:: PyTypeObject PyTuple_Type .. index:: single: TupleType (in module types) - This instance of :c:type:`PyTypeObject` represents the Python tuple type; it is + This instance of :ctype:`PyTypeObject` represents the Python tuple type; it is the same object as ``tuple`` and ``types.TupleType`` in the Python layer.. -.. c:function:: int PyTuple_Check(PyObject *p) +.. cfunction:: int PyTuple_Check(PyObject *p) Return true if *p* is a tuple object or an instance of a subtype of the tuple type. @@ -30,7 +30,7 @@ Allowed subtypes to be accepted. -.. c:function:: int PyTuple_CheckExact(PyObject *p) +.. cfunction:: int PyTuple_CheckExact(PyObject *p) Return true if *p* is a tuple object, but not an instance of a subtype of the tuple type. @@ -38,16 +38,16 @@ .. versionadded:: 2.2 -.. c:function:: PyObject* PyTuple_New(Py_ssize_t len) +.. cfunction:: PyObject* PyTuple_New(Py_ssize_t len) Return a new tuple object of size *len*, or *NULL* on failure. .. versionchanged:: 2.5 - This function used an :c:type:`int` type for *len*. This might require + This function used an :ctype:`int` type for *len*. This might require changes in your code for properly supporting 64-bit systems. -.. c:function:: PyObject* PyTuple_Pack(Py_ssize_t n, ...) +.. cfunction:: PyObject* PyTuple_Pack(Py_ssize_t n, ...) Return a new tuple object of size *n*, or *NULL* on failure. The tuple values are initialized to the subsequent *n* C arguments pointing to Python objects. @@ -56,59 +56,59 @@ .. versionadded:: 2.4 .. versionchanged:: 2.5 - This function used an :c:type:`int` type for *n*. This might require + This function used an :ctype:`int` type for *n*. This might require changes in your code for properly supporting 64-bit systems. -.. c:function:: Py_ssize_t PyTuple_Size(PyObject *p) +.. cfunction:: Py_ssize_t PyTuple_Size(PyObject *p) Take a pointer to a tuple object, and return the size of that tuple. .. versionchanged:: 2.5 - This function returned an :c:type:`int` type. This might require changes + This function returned an :ctype:`int` type. This might require changes in your code for properly supporting 64-bit systems. -.. c:function:: Py_ssize_t PyTuple_GET_SIZE(PyObject *p) +.. cfunction:: Py_ssize_t PyTuple_GET_SIZE(PyObject *p) Return the size of the tuple *p*, which must be non-*NULL* and point to a tuple; no error checking is performed. .. versionchanged:: 2.5 - This function returned an :c:type:`int` type. This might require changes + This function returned an :ctype:`int` type. This might require changes in your code for properly supporting 64-bit systems. -.. c:function:: PyObject* PyTuple_GetItem(PyObject *p, Py_ssize_t pos) +.. cfunction:: PyObject* PyTuple_GetItem(PyObject *p, Py_ssize_t pos) Return the object at position *pos* in the tuple pointed to by *p*. If *pos* is out of bounds, return *NULL* and sets an :exc:`IndexError` exception. .. versionchanged:: 2.5 - This function used an :c:type:`int` type for *pos*. This might require + This function used an :ctype:`int` type for *pos*. This might require changes in your code for properly supporting 64-bit systems. -.. c:function:: PyObject* PyTuple_GET_ITEM(PyObject *p, Py_ssize_t pos) +.. cfunction:: PyObject* PyTuple_GET_ITEM(PyObject *p, Py_ssize_t pos) - Like :c:func:`PyTuple_GetItem`, but does no checking of its arguments. + Like :cfunc:`PyTuple_GetItem`, but does no checking of its arguments. .. versionchanged:: 2.5 - This function used an :c:type:`int` type for *pos*. This might require + This function used an :ctype:`int` type for *pos*. This might require changes in your code for properly supporting 64-bit systems. -.. c:function:: PyObject* PyTuple_GetSlice(PyObject *p, Py_ssize_t low, Py_ssize_t high) +.. cfunction:: PyObject* PyTuple_GetSlice(PyObject *p, Py_ssize_t low, Py_ssize_t high) Take a slice of the tuple pointed to by *p* from *low* to *high* and return it as a new tuple. .. versionchanged:: 2.5 - This function used an :c:type:`int` type for *low* and *high*. This might + This function used an :ctype:`int` type for *low* and *high*. This might require changes in your code for properly supporting 64-bit systems. -.. c:function:: int PyTuple_SetItem(PyObject *p, Py_ssize_t pos, PyObject *o) +.. cfunction:: int PyTuple_SetItem(PyObject *p, Py_ssize_t pos, PyObject *o) Insert a reference to object *o* at position *pos* of the tuple pointed to by *p*. Return ``0`` on success. @@ -118,13 +118,13 @@ This function "steals" a reference to *o*. .. versionchanged:: 2.5 - This function used an :c:type:`int` type for *pos*. This might require + This function used an :ctype:`int` type for *pos*. This might require changes in your code for properly supporting 64-bit systems. -.. c:function:: void PyTuple_SET_ITEM(PyObject *p, Py_ssize_t pos, PyObject *o) +.. cfunction:: void PyTuple_SET_ITEM(PyObject *p, Py_ssize_t pos, PyObject *o) - Like :c:func:`PyTuple_SetItem`, but does no error checking, and should *only* be + Like :cfunc:`PyTuple_SetItem`, but does no error checking, and should *only* be used to fill in brand new tuples. .. note:: @@ -132,11 +132,11 @@ This function "steals" a reference to *o*. .. versionchanged:: 2.5 - This function used an :c:type:`int` type for *pos*. This might require + This function used an :ctype:`int` type for *pos*. This might require changes in your code for properly supporting 64-bit systems. -.. c:function:: int _PyTuple_Resize(PyObject **p, Py_ssize_t newsize) +.. cfunction:: int _PyTuple_Resize(PyObject **p, Py_ssize_t newsize) Can be used to resize a tuple. *newsize* will be the new length of the tuple. Because tuples are *supposed* to be immutable, this should only be used if there @@ -153,11 +153,11 @@ Removed unused third parameter, *last_is_sticky*. .. versionchanged:: 2.5 - This function used an :c:type:`int` type for *newsize*. This might + This function used an :ctype:`int` type for *newsize*. This might require changes in your code for properly supporting 64-bit systems. -.. c:function:: int PyTuple_ClearFreeList() +.. cfunction:: int PyTuple_ClearFreeList() Clear the free list. Return the total number of freed items. diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/c-api/type.rst --- a/Doc/c-api/type.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/c-api/type.rst Sun Jul 20 10:52:46 2014 -0400 @@ -8,12 +8,12 @@ .. index:: object: type -.. c:type:: PyTypeObject +.. ctype:: PyTypeObject The C structure of the objects used to describe built-in types. -.. c:var:: PyObject* PyType_Type +.. cvar:: PyObject* PyType_Type .. index:: single: TypeType (in module types) @@ -21,13 +21,13 @@ ``types.TypeType`` in the Python layer. -.. c:function:: int PyType_Check(PyObject *o) +.. cfunction:: int PyType_Check(PyObject *o) Return true if the object *o* is a type object, including instances of types derived from the standard type object. Return false in all other cases. -.. c:function:: int PyType_CheckExact(PyObject *o) +.. cfunction:: int PyType_CheckExact(PyObject *o) Return true if the object *o* is a type object, but not a subtype of the standard type object. Return false in all other cases. @@ -35,14 +35,14 @@ .. versionadded:: 2.2 -.. c:function:: unsigned int PyType_ClearCache() +.. cfunction:: unsigned int PyType_ClearCache() Clear the internal lookup cache. Return the current version tag. .. versionadded:: 2.6 -.. c:function:: void PyType_Modified(PyTypeObject *type) +.. cfunction:: void PyType_Modified(PyTypeObject *type) Invalidate the internal lookup cache for the type and all of its subtypes. This function must be called after any manual @@ -51,13 +51,13 @@ .. versionadded:: 2.6 -.. c:function:: int PyType_HasFeature(PyObject *o, int feature) +.. cfunction:: int PyType_HasFeature(PyObject *o, int feature) Return true if the type object *o* sets the feature *feature*. Type features are denoted by single bit flags. -.. c:function:: int PyType_IS_GC(PyObject *o) +.. cfunction:: int PyType_IS_GC(PyObject *o) Return true if the type object includes support for the cycle detector; this tests the type flag :const:`Py_TPFLAGS_HAVE_GC`. @@ -65,28 +65,28 @@ .. versionadded:: 2.0 -.. c:function:: int PyType_IsSubtype(PyTypeObject *a, PyTypeObject *b) +.. cfunction:: int PyType_IsSubtype(PyTypeObject *a, PyTypeObject *b) Return true if *a* is a subtype of *b*. .. versionadded:: 2.2 -.. c:function:: PyObject* PyType_GenericAlloc(PyTypeObject *type, Py_ssize_t nitems) +.. cfunction:: PyObject* PyType_GenericAlloc(PyTypeObject *type, Py_ssize_t nitems) .. versionadded:: 2.2 .. versionchanged:: 2.5 - This function used an :c:type:`int` type for *nitems*. This might require + This function used an :ctype:`int` type for *nitems*. This might require changes in your code for properly supporting 64-bit systems. -.. c:function:: PyObject* PyType_GenericNew(PyTypeObject *type, PyObject *args, PyObject *kwds) +.. cfunction:: PyObject* PyType_GenericNew(PyTypeObject *type, PyObject *args, PyObject *kwds) .. versionadded:: 2.2 -.. c:function:: int PyType_Ready(PyTypeObject *type) +.. cfunction:: int PyType_Ready(PyTypeObject *type) Finalize a type object. This should be called on all type objects to finish their initialization. This function is responsible for adding inherited slots diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/c-api/typeobj.rst --- a/Doc/c-api/typeobj.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/c-api/typeobj.rst Sun Jul 20 10:52:46 2014 -0400 @@ -6,9 +6,9 @@ ============ Perhaps one of the most important structures of the Python object system is the -structure that defines a new type: the :c:type:`PyTypeObject` structure. Type -objects can be handled using any of the :c:func:`PyObject_\*` or -:c:func:`PyType_\*` functions, but do not offer much that's interesting to most +structure that defines a new type: the :ctype:`PyTypeObject` structure. Type +objects can be handled using any of the :cfunc:`PyObject_\*` or +:cfunc:`PyType_\*` functions, but do not offer much that's interesting to most Python applications. These objects are fundamental to how objects behave, so they are very important to the interpreter itself and to any extension module that implements new types. @@ -25,21 +25,21 @@ freefunc, printfunc, getattrfunc, getattrofunc, setattrfunc, setattrofunc, cmpfunc, reprfunc, hashfunc -The structure definition for :c:type:`PyTypeObject` can be found in +The structure definition for :ctype:`PyTypeObject` can be found in :file:`Include/object.h`. For convenience of reference, this repeats the definition found there: .. literalinclude:: ../includes/typestruct.h -The type object structure extends the :c:type:`PyVarObject` structure. The +The type object structure extends the :ctype:`PyVarObject` structure. The :attr:`ob_size` field is used for dynamic types (created by :func:`type_new`, -usually called from a class statement). Note that :c:data:`PyType_Type` (the -metatype) initializes :c:member:`~PyTypeObject.tp_itemsize`, which means that its instances (i.e. +usually called from a class statement). Note that :cdata:`PyType_Type` (the +metatype) initializes :attr:`tp_itemsize`, which means that its instances (i.e. type objects) *must* have the :attr:`ob_size` field. -.. c:member:: PyObject* PyObject._ob_next +.. cmember:: PyObject* PyObject._ob_next PyObject* PyObject._ob_prev These fields are only present when the macro ``Py_TRACE_REFS`` is defined. @@ -54,7 +54,7 @@ These fields are not inherited by subtypes. -.. c:member:: Py_ssize_t PyObject.ob_refcnt +.. cmember:: Py_ssize_t PyObject.ob_refcnt This is the type object's reference count, initialized to ``1`` by the ``PyObject_HEAD_INIT`` macro. Note that for statically allocated type objects, @@ -65,11 +65,11 @@ This field is not inherited by subtypes. .. versionchanged:: 2.5 - This field used to be an :c:type:`int` type. This might require changes + This field used to be an :ctype:`int` type. This might require changes in your code for properly supporting 64-bit systems. -.. c:member:: PyTypeObject* PyObject.ob_type +.. cmember:: PyTypeObject* PyObject.ob_type This is the type's type, in other words its metatype. It is initialized by the argument to the ``PyObject_HEAD_INIT`` macro, and its value should normally be @@ -83,16 +83,16 @@ Foo_Type.ob_type = &PyType_Type; This should be done before any instances of the type are created. - :c:func:`PyType_Ready` checks if :attr:`ob_type` is *NULL*, and if so, + :cfunc:`PyType_Ready` checks if :attr:`ob_type` is *NULL*, and if so, initializes it: in Python 2.2, it is set to ``&PyType_Type``; in Python 2.2.1 and later it is initialized to the :attr:`ob_type` field of the base class. - :c:func:`PyType_Ready` will not change this field if it is non-zero. + :cfunc:`PyType_Ready` will not change this field if it is non-zero. In Python 2.2, this field is not inherited by subtypes. In 2.2.1, and in 2.3 and beyond, it is inherited by subtypes. -.. c:member:: Py_ssize_t PyVarObject.ob_size +.. cmember:: Py_ssize_t PyVarObject.ob_size For statically allocated type objects, this should be initialized to zero. For dynamically allocated type objects, this field has a special internal meaning. @@ -100,7 +100,7 @@ This field is not inherited by subtypes. -.. c:member:: char* PyTypeObject.tp_name +.. cmember:: char* PyTypeObject.tp_name Pointer to a NUL-terminated string containing the name of the type. For types that are accessible as module globals, the string should be the full module @@ -108,7 +108,7 @@ should be just the type name. If the module is a submodule of a package, the full package name is part of the full module name. For example, a type named :class:`T` defined in module :mod:`M` in subpackage :mod:`Q` in package :mod:`P` - should have the :c:member:`~PyTypeObject.tp_name` initializer ``"P.Q.M.T"``. + should have the :attr:`tp_name` initializer ``"P.Q.M.T"``. For dynamically allocated type objects, this should just be the type name, and the module name explicitly stored in the type dict as the value for key @@ -119,7 +119,7 @@ attribute, and everything after the last dot is made accessible as the :attr:`__name__` attribute. - If no dot is present, the entire :c:member:`~PyTypeObject.tp_name` field is made accessible as the + If no dot is present, the entire :attr:`tp_name` field is made accessible as the :attr:`__name__` attribute, and the :attr:`__module__` attribute is undefined (unless explicitly set in the dictionary, as explained above). This means your type will be impossible to pickle. @@ -127,19 +127,19 @@ This field is not inherited by subtypes. -.. c:member:: Py_ssize_t PyTypeObject.tp_basicsize +.. cmember:: Py_ssize_t PyTypeObject.tp_basicsize Py_ssize_t PyTypeObject.tp_itemsize These fields allow calculating the size in bytes of instances of the type. There are two kinds of types: types with fixed-length instances have a zero - :c:member:`~PyTypeObject.tp_itemsize` field, types with variable-length instances have a non-zero - :c:member:`~PyTypeObject.tp_itemsize` field. For a type with fixed-length instances, all - instances have the same size, given in :c:member:`~PyTypeObject.tp_basicsize`. + :attr:`tp_itemsize` field, types with variable-length instances have a non-zero + :attr:`tp_itemsize` field. For a type with fixed-length instances, all + instances have the same size, given in :attr:`tp_basicsize`. For a type with variable-length instances, the instances must have an - :attr:`ob_size` field, and the instance size is :c:member:`~PyTypeObject.tp_basicsize` plus N - times :c:member:`~PyTypeObject.tp_itemsize`, where N is the "length" of the object. The value of + :attr:`ob_size` field, and the instance size is :attr:`tp_basicsize` plus N + times :attr:`tp_itemsize`, where N is the "length" of the object. The value of N is typically stored in the instance's :attr:`ob_size` field. There are exceptions: for example, long ints use a negative :attr:`ob_size` to indicate a negative number, and N is ``abs(ob_size)`` there. Also, the presence of an @@ -149,131 +149,131 @@ field). The basic size includes the fields in the instance declared by the macro - :c:macro:`PyObject_HEAD` or :c:macro:`PyObject_VAR_HEAD` (whichever is used to + :cmacro:`PyObject_HEAD` or :cmacro:`PyObject_VAR_HEAD` (whichever is used to declare the instance struct) and this in turn includes the :attr:`_ob_prev` and :attr:`_ob_next` fields if they are present. This means that the only correct - way to get an initializer for the :c:member:`~PyTypeObject.tp_basicsize` is to use the + way to get an initializer for the :attr:`tp_basicsize` is to use the ``sizeof`` operator on the struct used to declare the instance layout. The basic size does not include the GC header size (this is new in Python 2.2; - in 2.1 and 2.0, the GC header size was included in :c:member:`~PyTypeObject.tp_basicsize`). + in 2.1 and 2.0, the GC header size was included in :attr:`tp_basicsize`). These fields are inherited separately by subtypes. If the base type has a - non-zero :c:member:`~PyTypeObject.tp_itemsize`, it is generally not safe to set - :c:member:`~PyTypeObject.tp_itemsize` to a different non-zero value in a subtype (though this + non-zero :attr:`tp_itemsize`, it is generally not safe to set + :attr:`tp_itemsize` to a different non-zero value in a subtype (though this depends on the implementation of the base type). A note about alignment: if the variable items require a particular alignment, - this should be taken care of by the value of :c:member:`~PyTypeObject.tp_basicsize`. Example: - suppose a type implements an array of ``double``. :c:member:`~PyTypeObject.tp_itemsize` is + this should be taken care of by the value of :attr:`tp_basicsize`. Example: + suppose a type implements an array of ``double``. :attr:`tp_itemsize` is ``sizeof(double)``. It is the programmer's responsibility that - :c:member:`~PyTypeObject.tp_basicsize` is a multiple of ``sizeof(double)`` (assuming this is the + :attr:`tp_basicsize` is a multiple of ``sizeof(double)`` (assuming this is the alignment requirement for ``double``). -.. c:member:: destructor PyTypeObject.tp_dealloc +.. cmember:: destructor PyTypeObject.tp_dealloc A pointer to the instance destructor function. This function must be defined unless the type guarantees that its instances will never be deallocated (as is the case for the singletons ``None`` and ``Ellipsis``). - The destructor function is called by the :c:func:`Py_DECREF` and - :c:func:`Py_XDECREF` macros when the new reference count is zero. At this point, + The destructor function is called by the :cfunc:`Py_DECREF` and + :cfunc:`Py_XDECREF` macros when the new reference count is zero. At this point, the instance is still in existence, but there are no references to it. The destructor function should free all references which the instance owns, free all memory buffers owned by the instance (using the freeing function corresponding to the allocation function used to allocate the buffer), and finally (as its - last action) call the type's :c:member:`~PyTypeObject.tp_free` function. If the type is not + last action) call the type's :attr:`tp_free` function. If the type is not subtypable (doesn't have the :const:`Py_TPFLAGS_BASETYPE` flag bit set), it is permissible to call the object deallocator directly instead of via - :c:member:`~PyTypeObject.tp_free`. The object deallocator should be the one used to allocate the - instance; this is normally :c:func:`PyObject_Del` if the instance was allocated - using :c:func:`PyObject_New` or :c:func:`PyObject_VarNew`, or - :c:func:`PyObject_GC_Del` if the instance was allocated using - :c:func:`PyObject_GC_New` or :c:func:`PyObject_GC_NewVar`. + :attr:`tp_free`. The object deallocator should be the one used to allocate the + instance; this is normally :cfunc:`PyObject_Del` if the instance was allocated + using :cfunc:`PyObject_New` or :cfunc:`PyObject_VarNew`, or + :cfunc:`PyObject_GC_Del` if the instance was allocated using + :cfunc:`PyObject_GC_New` or :cfunc:`PyObject_GC_NewVar`. This field is inherited by subtypes. -.. c:member:: printfunc PyTypeObject.tp_print +.. cmember:: printfunc PyTypeObject.tp_print An optional pointer to the instance print function. The print function is only called when the instance is printed to a *real* file; - when it is printed to a pseudo-file (like a :class:`~StringIO.StringIO` instance), the - instance's :c:member:`~PyTypeObject.tp_repr` or :c:member:`~PyTypeObject.tp_str` function is called to convert it to - a string. These are also called when the type's :c:member:`~PyTypeObject.tp_print` field is - *NULL*. A type should never implement :c:member:`~PyTypeObject.tp_print` in a way that produces - different output than :c:member:`~PyTypeObject.tp_repr` or :c:member:`~PyTypeObject.tp_str` would. + when it is printed to a pseudo-file (like a :class:`StringIO` instance), the + instance's :attr:`tp_repr` or :attr:`tp_str` function is called to convert it to + a string. These are also called when the type's :attr:`tp_print` field is + *NULL*. A type should never implement :attr:`tp_print` in a way that produces + different output than :attr:`tp_repr` or :attr:`tp_str` would. - The print function is called with the same signature as :c:func:`PyObject_Print`: + The print function is called with the same signature as :cfunc:`PyObject_Print`: ``int tp_print(PyObject *self, FILE *file, int flags)``. The *self* argument is the instance to be printed. The *file* argument is the stdio file to which it is to be printed. The *flags* argument is composed of flag bits. The only flag bit currently defined is :const:`Py_PRINT_RAW`. When the :const:`Py_PRINT_RAW` - flag bit is set, the instance should be printed the same way as :c:member:`~PyTypeObject.tp_str` + flag bit is set, the instance should be printed the same way as :attr:`tp_str` would format it; when the :const:`Py_PRINT_RAW` flag bit is clear, the instance - should be printed the same was as :c:member:`~PyTypeObject.tp_repr` would format it. It should + should be printed the same was as :attr:`tp_repr` would format it. It should return ``-1`` and set an exception condition when an error occurred during the comparison. - It is possible that the :c:member:`~PyTypeObject.tp_print` field will be deprecated. In any case, - it is recommended not to define :c:member:`~PyTypeObject.tp_print`, but instead to rely on - :c:member:`~PyTypeObject.tp_repr` and :c:member:`~PyTypeObject.tp_str` for printing. + It is possible that the :attr:`tp_print` field will be deprecated. In any case, + it is recommended not to define :attr:`tp_print`, but instead to rely on + :attr:`tp_repr` and :attr:`tp_str` for printing. This field is inherited by subtypes. -.. c:member:: getattrfunc PyTypeObject.tp_getattr +.. cmember:: getattrfunc PyTypeObject.tp_getattr An optional pointer to the get-attribute-string function. This field is deprecated. When it is defined, it should point to a function - that acts the same as the :c:member:`~PyTypeObject.tp_getattro` function, but taking a C string + that acts the same as the :attr:`tp_getattro` function, but taking a C string instead of a Python string object to give the attribute name. The signature is - the same as for :c:func:`PyObject_GetAttrString`. + the same as for :cfunc:`PyObject_GetAttrString`. - This field is inherited by subtypes together with :c:member:`~PyTypeObject.tp_getattro`: a subtype - inherits both :c:member:`~PyTypeObject.tp_getattr` and :c:member:`~PyTypeObject.tp_getattro` from its base type when - the subtype's :c:member:`~PyTypeObject.tp_getattr` and :c:member:`~PyTypeObject.tp_getattro` are both *NULL*. + This field is inherited by subtypes together with :attr:`tp_getattro`: a subtype + inherits both :attr:`tp_getattr` and :attr:`tp_getattro` from its base type when + the subtype's :attr:`tp_getattr` and :attr:`tp_getattro` are both *NULL*. -.. c:member:: setattrfunc PyTypeObject.tp_setattr +.. cmember:: setattrfunc PyTypeObject.tp_setattr An optional pointer to the set-attribute-string function. This field is deprecated. When it is defined, it should point to a function - that acts the same as the :c:member:`~PyTypeObject.tp_setattro` function, but taking a C string + that acts the same as the :attr:`tp_setattro` function, but taking a C string instead of a Python string object to give the attribute name. The signature is - the same as for :c:func:`PyObject_SetAttrString`. + the same as for :cfunc:`PyObject_SetAttrString`. - This field is inherited by subtypes together with :c:member:`~PyTypeObject.tp_setattro`: a subtype - inherits both :c:member:`~PyTypeObject.tp_setattr` and :c:member:`~PyTypeObject.tp_setattro` from its base type when - the subtype's :c:member:`~PyTypeObject.tp_setattr` and :c:member:`~PyTypeObject.tp_setattro` are both *NULL*. + This field is inherited by subtypes together with :attr:`tp_setattro`: a subtype + inherits both :attr:`tp_setattr` and :attr:`tp_setattro` from its base type when + the subtype's :attr:`tp_setattr` and :attr:`tp_setattro` are both *NULL*. -.. c:member:: cmpfunc PyTypeObject.tp_compare +.. cmember:: cmpfunc PyTypeObject.tp_compare An optional pointer to the three-way comparison function. - The signature is the same as for :c:func:`PyObject_Compare`. The function should + The signature is the same as for :cfunc:`PyObject_Compare`. The function should return ``1`` if *self* greater than *other*, ``0`` if *self* is equal to *other*, and ``-1`` if *self* less than *other*. It should return ``-1`` and set an exception condition when an error occurred during the comparison. - This field is inherited by subtypes together with :c:member:`~PyTypeObject.tp_richcompare` and - :c:member:`~PyTypeObject.tp_hash`: a subtypes inherits all three of :c:member:`~PyTypeObject.tp_compare`, - :c:member:`~PyTypeObject.tp_richcompare`, and :c:member:`~PyTypeObject.tp_hash` when the subtype's - :c:member:`~PyTypeObject.tp_compare`, :c:member:`~PyTypeObject.tp_richcompare`, and :c:member:`~PyTypeObject.tp_hash` are all *NULL*. + This field is inherited by subtypes together with :attr:`tp_richcompare` and + :attr:`tp_hash`: a subtypes inherits all three of :attr:`tp_compare`, + :attr:`tp_richcompare`, and :attr:`tp_hash` when the subtype's + :attr:`tp_compare`, :attr:`tp_richcompare`, and :attr:`tp_hash` are all *NULL*. -.. c:member:: reprfunc PyTypeObject.tp_repr +.. cmember:: reprfunc PyTypeObject.tp_repr .. index:: builtin: repr An optional pointer to a function that implements the built-in function :func:`repr`. - The signature is the same as for :c:func:`PyObject_Repr`; it must return a string + The signature is the same as for :cfunc:`PyObject_Repr`; it must return a string or a Unicode object. Ideally, this function should return a string that, when passed to :func:`eval`, given a suitable environment, returns an object with the same value. If this is not feasible, it should return a string starting with @@ -286,136 +286,136 @@ This field is inherited by subtypes. -.. c:member:: PyNumberMethods* tp_as_number +.. cmember:: PyNumberMethods* tp_as_number Pointer to an additional structure that contains fields relevant only to objects which implement the number protocol. These fields are documented in :ref:`number-structs`. - The :c:member:`~PyTypeObject.tp_as_number` field is not inherited, but the contained fields are + The :attr:`tp_as_number` field is not inherited, but the contained fields are inherited individually. -.. c:member:: PySequenceMethods* tp_as_sequence +.. cmember:: PySequenceMethods* tp_as_sequence Pointer to an additional structure that contains fields relevant only to objects which implement the sequence protocol. These fields are documented in :ref:`sequence-structs`. - The :c:member:`~PyTypeObject.tp_as_sequence` field is not inherited, but the contained fields + The :attr:`tp_as_sequence` field is not inherited, but the contained fields are inherited individually. -.. c:member:: PyMappingMethods* tp_as_mapping +.. cmember:: PyMappingMethods* tp_as_mapping Pointer to an additional structure that contains fields relevant only to objects which implement the mapping protocol. These fields are documented in :ref:`mapping-structs`. - The :c:member:`~PyTypeObject.tp_as_mapping` field is not inherited, but the contained fields + The :attr:`tp_as_mapping` field is not inherited, but the contained fields are inherited individually. -.. c:member:: hashfunc PyTypeObject.tp_hash +.. cmember:: hashfunc PyTypeObject.tp_hash .. index:: builtin: hash An optional pointer to a function that implements the built-in function :func:`hash`. - The signature is the same as for :c:func:`PyObject_Hash`; it must return a C + The signature is the same as for :cfunc:`PyObject_Hash`; it must return a C long. The value ``-1`` should not be returned as a normal return value; when an error occurs during the computation of the hash value, the function should set an exception and return ``-1``. - This field can be set explicitly to :c:func:`PyObject_HashNotImplemented` to + This field can be set explicitly to :cfunc:`PyObject_HashNotImplemented` to block inheritance of the hash method from a parent type. This is interpreted as the equivalent of ``__hash__ = None`` at the Python level, causing ``isinstance(o, collections.Hashable)`` to correctly return ``False``. Note that the converse is also true - setting ``__hash__ = None`` on a class at the Python level will result in the ``tp_hash`` slot being set to - :c:func:`PyObject_HashNotImplemented`. + :cfunc:`PyObject_HashNotImplemented`. - When this field is not set, two possibilities exist: if the :c:member:`~PyTypeObject.tp_compare` - and :c:member:`~PyTypeObject.tp_richcompare` fields are both *NULL*, a default hash value based on + When this field is not set, two possibilities exist: if the :attr:`tp_compare` + and :attr:`tp_richcompare` fields are both *NULL*, a default hash value based on the object's address is returned; otherwise, a :exc:`TypeError` is raised. - This field is inherited by subtypes together with :c:member:`~PyTypeObject.tp_richcompare` and - :c:member:`~PyTypeObject.tp_compare`: a subtypes inherits all three of :c:member:`~PyTypeObject.tp_compare`, - :c:member:`~PyTypeObject.tp_richcompare`, and :c:member:`~PyTypeObject.tp_hash`, when the subtype's - :c:member:`~PyTypeObject.tp_compare`, :c:member:`~PyTypeObject.tp_richcompare` and :c:member:`~PyTypeObject.tp_hash` are all *NULL*. + This field is inherited by subtypes together with :attr:`tp_richcompare` and + :attr:`tp_compare`: a subtypes inherits all three of :attr:`tp_compare`, + :attr:`tp_richcompare`, and :attr:`tp_hash`, when the subtype's + :attr:`tp_compare`, :attr:`tp_richcompare` and :attr:`tp_hash` are all *NULL*. -.. c:member:: ternaryfunc PyTypeObject.tp_call +.. cmember:: ternaryfunc PyTypeObject.tp_call An optional pointer to a function that implements calling the object. This should be *NULL* if the object is not callable. The signature is the same as - for :c:func:`PyObject_Call`. + for :cfunc:`PyObject_Call`. This field is inherited by subtypes. -.. c:member:: reprfunc PyTypeObject.tp_str +.. cmember:: reprfunc PyTypeObject.tp_str An optional pointer to a function that implements the built-in operation :func:`str`. (Note that :class:`str` is a type now, and :func:`str` calls the - constructor for that type. This constructor calls :c:func:`PyObject_Str` to do - the actual work, and :c:func:`PyObject_Str` will call this handler.) + constructor for that type. This constructor calls :cfunc:`PyObject_Str` to do + the actual work, and :cfunc:`PyObject_Str` will call this handler.) - The signature is the same as for :c:func:`PyObject_Str`; it must return a string + The signature is the same as for :cfunc:`PyObject_Str`; it must return a string or a Unicode object. This function should return a "friendly" string representation of the object, as this is the representation that will be used by the print statement. - When this field is not set, :c:func:`PyObject_Repr` is called to return a string + When this field is not set, :cfunc:`PyObject_Repr` is called to return a string representation. This field is inherited by subtypes. -.. c:member:: getattrofunc PyTypeObject.tp_getattro +.. cmember:: getattrofunc PyTypeObject.tp_getattro An optional pointer to the get-attribute function. - The signature is the same as for :c:func:`PyObject_GetAttr`. It is usually - convenient to set this field to :c:func:`PyObject_GenericGetAttr`, which + The signature is the same as for :cfunc:`PyObject_GetAttr`. It is usually + convenient to set this field to :cfunc:`PyObject_GenericGetAttr`, which implements the normal way of looking for object attributes. - This field is inherited by subtypes together with :c:member:`~PyTypeObject.tp_getattr`: a subtype - inherits both :c:member:`~PyTypeObject.tp_getattr` and :c:member:`~PyTypeObject.tp_getattro` from its base type when - the subtype's :c:member:`~PyTypeObject.tp_getattr` and :c:member:`~PyTypeObject.tp_getattro` are both *NULL*. + This field is inherited by subtypes together with :attr:`tp_getattr`: a subtype + inherits both :attr:`tp_getattr` and :attr:`tp_getattro` from its base type when + the subtype's :attr:`tp_getattr` and :attr:`tp_getattro` are both *NULL*. -.. c:member:: setattrofunc PyTypeObject.tp_setattro +.. cmember:: setattrofunc PyTypeObject.tp_setattro An optional pointer to the set-attribute function. - The signature is the same as for :c:func:`PyObject_SetAttr`. It is usually - convenient to set this field to :c:func:`PyObject_GenericSetAttr`, which + The signature is the same as for :cfunc:`PyObject_SetAttr`. It is usually + convenient to set this field to :cfunc:`PyObject_GenericSetAttr`, which implements the normal way of setting object attributes. - This field is inherited by subtypes together with :c:member:`~PyTypeObject.tp_setattr`: a subtype - inherits both :c:member:`~PyTypeObject.tp_setattr` and :c:member:`~PyTypeObject.tp_setattro` from its base type when - the subtype's :c:member:`~PyTypeObject.tp_setattr` and :c:member:`~PyTypeObject.tp_setattro` are both *NULL*. + This field is inherited by subtypes together with :attr:`tp_setattr`: a subtype + inherits both :attr:`tp_setattr` and :attr:`tp_setattro` from its base type when + the subtype's :attr:`tp_setattr` and :attr:`tp_setattro` are both *NULL*. -.. c:member:: PyBufferProcs* PyTypeObject.tp_as_buffer +.. cmember:: PyBufferProcs* PyTypeObject.tp_as_buffer Pointer to an additional structure that contains fields relevant only to objects which implement the buffer interface. These fields are documented in :ref:`buffer-structs`. - The :c:member:`~PyTypeObject.tp_as_buffer` field is not inherited, but the contained fields are + The :attr:`tp_as_buffer` field is not inherited, but the contained fields are inherited individually. -.. c:member:: long PyTypeObject.tp_flags +.. cmember:: long PyTypeObject.tp_flags This field is a bit mask of various flags. Some flags indicate variant semantics for certain situations; others are used to indicate that certain fields in the type object (or in the extension structures referenced via - :c:member:`~PyTypeObject.tp_as_number`, :c:member:`~PyTypeObject.tp_as_sequence`, :c:member:`~PyTypeObject.tp_as_mapping`, and - :c:member:`~PyTypeObject.tp_as_buffer`) that were historically not always present are valid; if + :attr:`tp_as_number`, :attr:`tp_as_sequence`, :attr:`tp_as_mapping`, and + :attr:`tp_as_buffer`) that were historically not always present are valid; if such a flag bit is clear, the type fields it guards must not be accessed and must be considered to have a zero or *NULL* value instead. @@ -425,28 +425,28 @@ inherited if the extension structure is inherited, i.e. the base type's value of the flag bit is copied into the subtype together with a pointer to the extension structure. The :const:`Py_TPFLAGS_HAVE_GC` flag bit is inherited together with - the :c:member:`~PyTypeObject.tp_traverse` and :c:member:`~PyTypeObject.tp_clear` fields, i.e. if the + the :attr:`tp_traverse` and :attr:`tp_clear` fields, i.e. if the :const:`Py_TPFLAGS_HAVE_GC` flag bit is clear in the subtype and the - :c:member:`~PyTypeObject.tp_traverse` and :c:member:`~PyTypeObject.tp_clear` fields in the subtype exist (as + :attr:`tp_traverse` and :attr:`tp_clear` fields in the subtype exist (as indicated by the :const:`Py_TPFLAGS_HAVE_RICHCOMPARE` flag bit) and have *NULL* values. The following bit masks are currently defined; these can be ORed together using - the ``|`` operator to form the value of the :c:member:`~PyTypeObject.tp_flags` field. The macro - :c:func:`PyType_HasFeature` takes a type and a flags value, *tp* and *f*, and + the ``|`` operator to form the value of the :attr:`tp_flags` field. The macro + :cfunc:`PyType_HasFeature` takes a type and a flags value, *tp* and *f*, and checks whether ``tp->tp_flags & f`` is non-zero. .. data:: Py_TPFLAGS_HAVE_GETCHARBUFFER - If this bit is set, the :c:type:`PyBufferProcs` struct referenced by - :c:member:`~PyTypeObject.tp_as_buffer` has the :attr:`bf_getcharbuffer` field. + If this bit is set, the :ctype:`PyBufferProcs` struct referenced by + :attr:`tp_as_buffer` has the :attr:`bf_getcharbuffer` field. .. data:: Py_TPFLAGS_HAVE_SEQUENCE_IN - If this bit is set, the :c:type:`PySequenceMethods` struct referenced by - :c:member:`~PyTypeObject.tp_as_sequence` has the :attr:`sq_contains` field. + If this bit is set, the :ctype:`PySequenceMethods` struct referenced by + :attr:`tp_as_sequence` has the :attr:`sq_contains` field. .. data:: Py_TPFLAGS_GC @@ -457,23 +457,23 @@ .. data:: Py_TPFLAGS_HAVE_INPLACEOPS - If this bit is set, the :c:type:`PySequenceMethods` struct referenced by - :c:member:`~PyTypeObject.tp_as_sequence` and the :c:type:`PyNumberMethods` structure referenced by - :c:member:`~PyTypeObject.tp_as_number` contain the fields for in-place operators. In particular, - this means that the :c:type:`PyNumberMethods` structure has the fields + If this bit is set, the :ctype:`PySequenceMethods` struct referenced by + :attr:`tp_as_sequence` and the :ctype:`PyNumberMethods` structure referenced by + :attr:`tp_as_number` contain the fields for in-place operators. In particular, + this means that the :ctype:`PyNumberMethods` structure has the fields :attr:`nb_inplace_add`, :attr:`nb_inplace_subtract`, :attr:`nb_inplace_multiply`, :attr:`nb_inplace_divide`, :attr:`nb_inplace_remainder`, :attr:`nb_inplace_power`, :attr:`nb_inplace_lshift`, :attr:`nb_inplace_rshift`, :attr:`nb_inplace_and`, :attr:`nb_inplace_xor`, and :attr:`nb_inplace_or`; and the - :c:type:`PySequenceMethods` struct has the fields :attr:`sq_inplace_concat` and + :ctype:`PySequenceMethods` struct has the fields :attr:`sq_inplace_concat` and :attr:`sq_inplace_repeat`. .. data:: Py_TPFLAGS_CHECKTYPES If this bit is set, the binary and ternary operations in the - :c:type:`PyNumberMethods` structure referenced by :c:member:`~PyTypeObject.tp_as_number` accept + :ctype:`PyNumberMethods` structure referenced by :attr:`tp_as_number` accept arguments of arbitrary object types, and do their own type conversions if needed. If this bit is clear, those operations require that all arguments have the current type as their type, and the caller is supposed to perform a coercion @@ -485,31 +485,31 @@ .. data:: Py_TPFLAGS_HAVE_RICHCOMPARE - If this bit is set, the type object has the :c:member:`~PyTypeObject.tp_richcompare` field, as - well as the :c:member:`~PyTypeObject.tp_traverse` and the :c:member:`~PyTypeObject.tp_clear` fields. + If this bit is set, the type object has the :attr:`tp_richcompare` field, as + well as the :attr:`tp_traverse` and the :attr:`tp_clear` fields. .. data:: Py_TPFLAGS_HAVE_WEAKREFS - If this bit is set, the :c:member:`~PyTypeObject.tp_weaklistoffset` field is defined. Instances - of a type are weakly referenceable if the type's :c:member:`~PyTypeObject.tp_weaklistoffset` field + If this bit is set, the :attr:`tp_weaklistoffset` field is defined. Instances + of a type are weakly referenceable if the type's :attr:`tp_weaklistoffset` field has a value greater than zero. .. data:: Py_TPFLAGS_HAVE_ITER - If this bit is set, the type object has the :c:member:`~PyTypeObject.tp_iter` and - :c:member:`~PyTypeObject.tp_iternext` fields. + If this bit is set, the type object has the :attr:`tp_iter` and + :attr:`tp_iternext` fields. .. data:: Py_TPFLAGS_HAVE_CLASS If this bit is set, the type object has several new fields defined starting in - Python 2.2: :c:member:`~PyTypeObject.tp_methods`, :c:member:`~PyTypeObject.tp_members`, :c:member:`~PyTypeObject.tp_getset`, - :c:member:`~PyTypeObject.tp_base`, :c:member:`~PyTypeObject.tp_dict`, :c:member:`~PyTypeObject.tp_descr_get`, :c:member:`~PyTypeObject.tp_descr_set`, - :c:member:`~PyTypeObject.tp_dictoffset`, :c:member:`~PyTypeObject.tp_init`, :c:member:`~PyTypeObject.tp_alloc`, :c:member:`~PyTypeObject.tp_new`, - :c:member:`~PyTypeObject.tp_free`, :c:member:`~PyTypeObject.tp_is_gc`, :c:member:`~PyTypeObject.tp_bases`, :c:member:`~PyTypeObject.tp_mro`, - :c:member:`~PyTypeObject.tp_cache`, :c:member:`~PyTypeObject.tp_subclasses`, and :c:member:`~PyTypeObject.tp_weaklist`. + Python 2.2: :attr:`tp_methods`, :attr:`tp_members`, :attr:`tp_getset`, + :attr:`tp_base`, :attr:`tp_dict`, :attr:`tp_descr_get`, :attr:`tp_descr_set`, + :attr:`tp_dictoffset`, :attr:`tp_init`, :attr:`tp_alloc`, :attr:`tp_new`, + :attr:`tp_free`, :attr:`tp_is_gc`, :attr:`tp_bases`, :attr:`tp_mro`, + :attr:`tp_cache`, :attr:`tp_subclasses`, and :attr:`tp_weaklist`. .. data:: Py_TPFLAGS_HEAPTYPE @@ -532,22 +532,22 @@ .. data:: Py_TPFLAGS_READY This bit is set when the type object has been fully initialized by - :c:func:`PyType_Ready`. + :cfunc:`PyType_Ready`. .. data:: Py_TPFLAGS_READYING - This bit is set while :c:func:`PyType_Ready` is in the process of initializing + This bit is set while :cfunc:`PyType_Ready` is in the process of initializing the type object. .. data:: Py_TPFLAGS_HAVE_GC This bit is set when the object supports garbage collection. If this bit - is set, instances must be created using :c:func:`PyObject_GC_New` and - destroyed using :c:func:`PyObject_GC_Del`. More information in section + is set, instances must be created using :cfunc:`PyObject_GC_New` and + destroyed using :cfunc:`PyObject_GC_Del`. More information in section :ref:`supporting-cycle-detection`. This bit also implies that the - GC-related fields :c:member:`~PyTypeObject.tp_traverse` and :c:member:`~PyTypeObject.tp_clear` are present in + GC-related fields :attr:`tp_traverse` and :attr:`tp_clear` are present in the type object; but those fields also exist when :const:`Py_TPFLAGS_HAVE_GC` is clear but :const:`Py_TPFLAGS_HAVE_RICHCOMPARE` is set. @@ -563,7 +563,7 @@ :const:`Py_TPFLAGS_HAVE_ITER`, and :const:`Py_TPFLAGS_HAVE_CLASS`. -.. c:member:: char* PyTypeObject.tp_doc +.. cmember:: char* PyTypeObject.tp_doc An optional pointer to a NUL-terminated C string giving the docstring for this type object. This is exposed as the :attr:`__doc__` attribute on the type and @@ -575,17 +575,17 @@ :const:`Py_TPFLAGS_HAVE_RICHCOMPARE` flag bit is set. -.. c:member:: traverseproc PyTypeObject.tp_traverse +.. cmember:: traverseproc PyTypeObject.tp_traverse An optional pointer to a traversal function for the garbage collector. This is only used if the :const:`Py_TPFLAGS_HAVE_GC` flag bit is set. More information about Python's garbage collection scheme can be found in section :ref:`supporting-cycle-detection`. - The :c:member:`~PyTypeObject.tp_traverse` pointer is used by the garbage collector to detect - reference cycles. A typical implementation of a :c:member:`~PyTypeObject.tp_traverse` function - simply calls :c:func:`Py_VISIT` on each of the instance's members that are Python - objects. For example, this is function :c:func:`local_traverse` from the + The :attr:`tp_traverse` pointer is used by the garbage collector to detect + reference cycles. A typical implementation of a :attr:`tp_traverse` function + simply calls :cfunc:`Py_VISIT` on each of the instance's members that are Python + objects. For example, this is function :cfunc:`local_traverse` from the :mod:`thread` extension module:: static int @@ -597,41 +597,41 @@ return 0; } - Note that :c:func:`Py_VISIT` is called only on those members that can participate + Note that :cfunc:`Py_VISIT` is called only on those members that can participate in reference cycles. Although there is also a ``self->key`` member, it can only be *NULL* or a Python string and therefore cannot be part of a reference cycle. On the other hand, even if you know a member can never be part of a cycle, as a debugging aid you may want to visit it anyway just so the :mod:`gc` module's - :func:`~gc.get_referents` function will include it. + :func:`get_referents` function will include it. - Note that :c:func:`Py_VISIT` requires the *visit* and *arg* parameters to - :c:func:`local_traverse` to have these specific names; don't name them just + Note that :cfunc:`Py_VISIT` requires the *visit* and *arg* parameters to + :cfunc:`local_traverse` to have these specific names; don't name them just anything. - This field is inherited by subtypes together with :c:member:`~PyTypeObject.tp_clear` and the - :const:`Py_TPFLAGS_HAVE_GC` flag bit: the flag bit, :c:member:`~PyTypeObject.tp_traverse`, and - :c:member:`~PyTypeObject.tp_clear` are all inherited from the base type if they are all zero in + This field is inherited by subtypes together with :attr:`tp_clear` and the + :const:`Py_TPFLAGS_HAVE_GC` flag bit: the flag bit, :attr:`tp_traverse`, and + :attr:`tp_clear` are all inherited from the base type if they are all zero in the subtype *and* the subtype has the :const:`Py_TPFLAGS_HAVE_RICHCOMPARE` flag bit set. -.. c:member:: inquiry PyTypeObject.tp_clear +.. cmember:: inquiry PyTypeObject.tp_clear An optional pointer to a clear function for the garbage collector. This is only used if the :const:`Py_TPFLAGS_HAVE_GC` flag bit is set. - The :c:member:`~PyTypeObject.tp_clear` member function is used to break reference cycles in cyclic - garbage detected by the garbage collector. Taken together, all :c:member:`~PyTypeObject.tp_clear` + The :attr:`tp_clear` member function is used to break reference cycles in cyclic + garbage detected by the garbage collector. Taken together, all :attr:`tp_clear` functions in the system must combine to break all reference cycles. This is - subtle, and if in any doubt supply a :c:member:`~PyTypeObject.tp_clear` function. For example, - the tuple type does not implement a :c:member:`~PyTypeObject.tp_clear` function, because it's + subtle, and if in any doubt supply a :attr:`tp_clear` function. For example, + the tuple type does not implement a :attr:`tp_clear` function, because it's possible to prove that no reference cycle can be composed entirely of tuples. - Therefore the :c:member:`~PyTypeObject.tp_clear` functions of other types must be sufficient to + Therefore the :attr:`tp_clear` functions of other types must be sufficient to break any cycle containing a tuple. This isn't immediately obvious, and there's - rarely a good reason to avoid implementing :c:member:`~PyTypeObject.tp_clear`. + rarely a good reason to avoid implementing :attr:`tp_clear`. - Implementations of :c:member:`~PyTypeObject.tp_clear` should drop the instance's references to + Implementations of :attr:`tp_clear` should drop the instance's references to those of its members that may be Python objects, and set its pointers to those members to *NULL*, as in the following example:: @@ -645,7 +645,7 @@ return 0; } - The :c:func:`Py_CLEAR` macro should be used, because clearing references is + The :cfunc:`Py_CLEAR` macro should be used, because clearing references is delicate: the reference to the contained object must not be decremented until after the pointer to the contained object is set to *NULL*. This is because decrementing the reference count may cause the contained object to become trash, @@ -654,25 +654,25 @@ contained object). If it's possible for such code to reference *self* again, it's important that the pointer to the contained object be *NULL* at that time, so that *self* knows the contained object can no longer be used. The - :c:func:`Py_CLEAR` macro performs the operations in a safe order. + :cfunc:`Py_CLEAR` macro performs the operations in a safe order. - Because the goal of :c:member:`~PyTypeObject.tp_clear` functions is to break reference cycles, + Because the goal of :attr:`tp_clear` functions is to break reference cycles, it's not necessary to clear contained objects like Python strings or Python integers, which can't participate in reference cycles. On the other hand, it may be convenient to clear all contained Python objects, and write the type's - :c:member:`~PyTypeObject.tp_dealloc` function to invoke :c:member:`~PyTypeObject.tp_clear`. + :attr:`tp_dealloc` function to invoke :attr:`tp_clear`. More information about Python's garbage collection scheme can be found in section :ref:`supporting-cycle-detection`. - This field is inherited by subtypes together with :c:member:`~PyTypeObject.tp_traverse` and the - :const:`Py_TPFLAGS_HAVE_GC` flag bit: the flag bit, :c:member:`~PyTypeObject.tp_traverse`, and - :c:member:`~PyTypeObject.tp_clear` are all inherited from the base type if they are all zero in + This field is inherited by subtypes together with :attr:`tp_traverse` and the + :const:`Py_TPFLAGS_HAVE_GC` flag bit: the flag bit, :attr:`tp_traverse`, and + :attr:`tp_clear` are all inherited from the base type if they are all zero in the subtype *and* the subtype has the :const:`Py_TPFLAGS_HAVE_RICHCOMPARE` flag bit set. -.. c:member:: richcmpfunc PyTypeObject.tp_richcompare +.. cmember:: richcmpfunc PyTypeObject.tp_richcompare An optional pointer to the rich comparison function, whose signature is ``PyObject *tp_richcompare(PyObject *a, PyObject *b, int op)``. @@ -688,13 +688,13 @@ comparisons makes sense (e.g. ``==`` and ``!=``, but not ``<`` and friends), directly raise :exc:`TypeError` in the rich comparison function. - This field is inherited by subtypes together with :c:member:`~PyTypeObject.tp_compare` and - :c:member:`~PyTypeObject.tp_hash`: a subtype inherits all three of :c:member:`~PyTypeObject.tp_compare`, - :c:member:`~PyTypeObject.tp_richcompare`, and :c:member:`~PyTypeObject.tp_hash`, when the subtype's - :c:member:`~PyTypeObject.tp_compare`, :c:member:`~PyTypeObject.tp_richcompare`, and :c:member:`~PyTypeObject.tp_hash` are all *NULL*. + This field is inherited by subtypes together with :attr:`tp_compare` and + :attr:`tp_hash`: a subtype inherits all three of :attr:`tp_compare`, + :attr:`tp_richcompare`, and :attr:`tp_hash`, when the subtype's + :attr:`tp_compare`, :attr:`tp_richcompare`, and :attr:`tp_hash` are all *NULL*. The following constants are defined to be used as the third argument for - :c:member:`~PyTypeObject.tp_richcompare` and for :c:func:`PyObject_RichCompare`: + :attr:`tp_richcompare` and for :cfunc:`PyObject_RichCompare`: +----------------+------------+ | Constant | Comparison | @@ -716,54 +716,54 @@ The next field only exists if the :const:`Py_TPFLAGS_HAVE_WEAKREFS` flag bit is set. -.. c:member:: long PyTypeObject.tp_weaklistoffset +.. cmember:: long PyTypeObject.tp_weaklistoffset If the instances of this type are weakly referenceable, this field is greater than zero and contains the offset in the instance structure of the weak reference list head (ignoring the GC header, if present); this offset is used by - :c:func:`PyObject_ClearWeakRefs` and the :c:func:`PyWeakref_\*` functions. The - instance structure needs to include a field of type :c:type:`PyObject\*` which is + :cfunc:`PyObject_ClearWeakRefs` and the :cfunc:`PyWeakref_\*` functions. The + instance structure needs to include a field of type :ctype:`PyObject\*` which is initialized to *NULL*. - Do not confuse this field with :c:member:`~PyTypeObject.tp_weaklist`; that is the list head for + Do not confuse this field with :attr:`tp_weaklist`; that is the list head for weak references to the type object itself. This field is inherited by subtypes, but see the rules listed below. A subtype may override this offset; this means that the subtype uses a different weak reference list head than the base type. Since the list head is always found via - :c:member:`~PyTypeObject.tp_weaklistoffset`, this should not be a problem. + :attr:`tp_weaklistoffset`, this should not be a problem. - When a type defined by a class statement has no :attr:`~object.__slots__` declaration, + When a type defined by a class statement has no :attr:`__slots__` declaration, and none of its base types are weakly referenceable, the type is made weakly referenceable by adding a weak reference list head slot to the instance layout - and setting the :c:member:`~PyTypeObject.tp_weaklistoffset` of that slot's offset. + and setting the :attr:`tp_weaklistoffset` of that slot's offset. When a type's :attr:`__slots__` declaration contains a slot named :attr:`__weakref__`, that slot becomes the weak reference list head for instances of the type, and the slot's offset is stored in the type's - :c:member:`~PyTypeObject.tp_weaklistoffset`. + :attr:`tp_weaklistoffset`. When a type's :attr:`__slots__` declaration does not contain a slot named - :attr:`__weakref__`, the type inherits its :c:member:`~PyTypeObject.tp_weaklistoffset` from its + :attr:`__weakref__`, the type inherits its :attr:`tp_weaklistoffset` from its base type. The next two fields only exist if the :const:`Py_TPFLAGS_HAVE_ITER` flag bit is set. -.. c:member:: getiterfunc PyTypeObject.tp_iter +.. cmember:: getiterfunc PyTypeObject.tp_iter An optional pointer to a function that returns an iterator for the object. Its presence normally signals that the instances of this type are iterable (although sequences may be iterable without this function, and classic instances always have this function, even if they don't define an :meth:`__iter__` method). - This function has the same signature as :c:func:`PyObject_GetIter`. + This function has the same signature as :cfunc:`PyObject_GetIter`. This field is inherited by subtypes. -.. c:member:: iternextfunc PyTypeObject.tp_iternext +.. cmember:: iternextfunc PyTypeObject.tp_iternext An optional pointer to a function that returns the next item in an iterator. When the iterator is exhausted, it must return *NULL*; a :exc:`StopIteration` @@ -772,50 +772,50 @@ are iterators (although classic instances always have this function, even if they don't define a :meth:`next` method). - Iterator types should also define the :c:member:`~PyTypeObject.tp_iter` function, and that + Iterator types should also define the :attr:`tp_iter` function, and that function should return the iterator instance itself (not a new iterator instance). - This function has the same signature as :c:func:`PyIter_Next`. + This function has the same signature as :cfunc:`PyIter_Next`. This field is inherited by subtypes. -The next fields, up to and including :c:member:`~PyTypeObject.tp_weaklist`, only exist if the +The next fields, up to and including :attr:`tp_weaklist`, only exist if the :const:`Py_TPFLAGS_HAVE_CLASS` flag bit is set. -.. c:member:: struct PyMethodDef* PyTypeObject.tp_methods +.. cmember:: struct PyMethodDef* PyTypeObject.tp_methods - An optional pointer to a static *NULL*-terminated array of :c:type:`PyMethodDef` + An optional pointer to a static *NULL*-terminated array of :ctype:`PyMethodDef` structures, declaring regular methods of this type. For each entry in the array, an entry is added to the type's dictionary (see - :c:member:`~PyTypeObject.tp_dict` below) containing a method descriptor. + :attr:`tp_dict` below) containing a method descriptor. This field is not inherited by subtypes (methods are inherited through a different mechanism). -.. c:member:: struct PyMemberDef* PyTypeObject.tp_members +.. cmember:: struct PyMemberDef* PyTypeObject.tp_members - An optional pointer to a static *NULL*-terminated array of :c:type:`PyMemberDef` + An optional pointer to a static *NULL*-terminated array of :ctype:`PyMemberDef` structures, declaring regular data members (fields or slots) of instances of this type. For each entry in the array, an entry is added to the type's dictionary (see - :c:member:`~PyTypeObject.tp_dict` below) containing a member descriptor. + :attr:`tp_dict` below) containing a member descriptor. This field is not inherited by subtypes (members are inherited through a different mechanism). -.. c:member:: struct PyGetSetDef* PyTypeObject.tp_getset +.. cmember:: struct PyGetSetDef* PyTypeObject.tp_getset - An optional pointer to a static *NULL*-terminated array of :c:type:`PyGetSetDef` + An optional pointer to a static *NULL*-terminated array of :ctype:`PyGetSetDef` structures, declaring computed attributes of instances of this type. For each entry in the array, an entry is added to the type's dictionary (see - :c:member:`~PyTypeObject.tp_dict` below) containing a getset descriptor. + :attr:`tp_dict` below) containing a getset descriptor. This field is not inherited by subtypes (computed attributes are inherited through a different mechanism). @@ -836,7 +836,7 @@ } PyGetSetDef; -.. c:member:: PyTypeObject* PyTypeObject.tp_base +.. cmember:: PyTypeObject* PyTypeObject.tp_base An optional pointer to a base type from which type properties are inherited. At this level, only single inheritance is supported; multiple inheritance require @@ -847,13 +847,13 @@ :class:`object`). -.. c:member:: PyObject* PyTypeObject.tp_dict +.. cmember:: PyObject* PyTypeObject.tp_dict - The type's dictionary is stored here by :c:func:`PyType_Ready`. + The type's dictionary is stored here by :cfunc:`PyType_Ready`. This field should normally be initialized to *NULL* before PyType_Ready is called; it may also be initialized to a dictionary containing initial attributes - for the type. Once :c:func:`PyType_Ready` has initialized the type, extra + for the type. Once :cfunc:`PyType_Ready` has initialized the type, extra attributes for the type may be added to this dictionary only if they don't correspond to overloaded operations (like :meth:`__add__`). @@ -861,7 +861,7 @@ are inherited through a different mechanism). -.. c:member:: descrgetfunc PyTypeObject.tp_descr_get +.. cmember:: descrgetfunc PyTypeObject.tp_descr_get An optional pointer to a "descriptor get" function. @@ -874,7 +874,7 @@ This field is inherited by subtypes. -.. c:member:: descrsetfunc PyTypeObject.tp_descr_set +.. cmember:: descrsetfunc PyTypeObject.tp_descr_set An optional pointer to a "descriptor set" function. @@ -887,14 +887,14 @@ .. XXX explain. -.. c:member:: long PyTypeObject.tp_dictoffset +.. cmember:: long PyTypeObject.tp_dictoffset If the instances of this type have a dictionary containing instance variables, this field is non-zero and contains the offset in the instances of the type of the instance variable dictionary; this offset is used by - :c:func:`PyObject_GenericGetAttr`. + :cfunc:`PyObject_GenericGetAttr`. - Do not confuse this field with :c:member:`~PyTypeObject.tp_dict`; that is the dictionary for + Do not confuse this field with :attr:`tp_dict`; that is the dictionary for attributes of the type object itself. If the value of this field is greater than zero, it specifies the offset from @@ -903,44 +903,44 @@ offset is more expensive to use, and should only be used when the instance structure contains a variable-length part. This is used for example to add an instance variable dictionary to subtypes of :class:`str` or :class:`tuple`. Note - that the :c:member:`~PyTypeObject.tp_basicsize` field should account for the dictionary added to + that the :attr:`tp_basicsize` field should account for the dictionary added to the end in that case, even though the dictionary is not included in the basic object layout. On a system with a pointer size of 4 bytes, - :c:member:`~PyTypeObject.tp_dictoffset` should be set to ``-4`` to indicate that the dictionary is + :attr:`tp_dictoffset` should be set to ``-4`` to indicate that the dictionary is at the very end of the structure. The real dictionary offset in an instance can be computed from a negative - :c:member:`~PyTypeObject.tp_dictoffset` as follows:: + :attr:`tp_dictoffset` as follows:: dictoffset = tp_basicsize + abs(ob_size)*tp_itemsize + tp_dictoffset if dictoffset is not aligned on sizeof(void*): round up to sizeof(void*) - where :c:member:`~PyTypeObject.tp_basicsize`, :c:member:`~PyTypeObject.tp_itemsize` and :c:member:`~PyTypeObject.tp_dictoffset` are + where :attr:`tp_basicsize`, :attr:`tp_itemsize` and :attr:`tp_dictoffset` are taken from the type object, and :attr:`ob_size` is taken from the instance. The absolute value is taken because long ints use the sign of :attr:`ob_size` to store the sign of the number. (There's never a need to do this calculation - yourself; it is done for you by :c:func:`_PyObject_GetDictPtr`.) + yourself; it is done for you by :cfunc:`_PyObject_GetDictPtr`.) This field is inherited by subtypes, but see the rules listed below. A subtype may override this offset; this means that the subtype instances store the dictionary at a difference offset than the base type. Since the dictionary is - always found via :c:member:`~PyTypeObject.tp_dictoffset`, this should not be a problem. + always found via :attr:`tp_dictoffset`, this should not be a problem. - When a type defined by a class statement has no :attr:`~object.__slots__` declaration, + When a type defined by a class statement has no :attr:`__slots__` declaration, and none of its base types has an instance variable dictionary, a dictionary - slot is added to the instance layout and the :c:member:`~PyTypeObject.tp_dictoffset` is set to + slot is added to the instance layout and the :attr:`tp_dictoffset` is set to that slot's offset. When a type defined by a class statement has a :attr:`__slots__` declaration, - the type inherits its :c:member:`~PyTypeObject.tp_dictoffset` from its base type. + the type inherits its :attr:`tp_dictoffset` from its base type. - (Adding a slot named :attr:`~object.__dict__` to the :attr:`__slots__` declaration does + (Adding a slot named :attr:`__dict__` to the :attr:`__slots__` declaration does not have the expected effect, it just causes confusion. Maybe this should be added as a feature just like :attr:`__weakref__` though.) -.. c:member:: initproc PyTypeObject.tp_init +.. cmember:: initproc PyTypeObject.tp_init An optional pointer to an instance initialization function. @@ -957,20 +957,20 @@ arguments represent positional and keyword arguments of the call to :meth:`__init__`. - The :c:member:`~PyTypeObject.tp_init` function, if not *NULL*, is called when an instance is - created normally by calling its type, after the type's :c:member:`~PyTypeObject.tp_new` function - has returned an instance of the type. If the :c:member:`~PyTypeObject.tp_new` function returns an + The :attr:`tp_init` function, if not *NULL*, is called when an instance is + created normally by calling its type, after the type's :attr:`tp_new` function + has returned an instance of the type. If the :attr:`tp_new` function returns an instance of some other type that is not a subtype of the original type, no - :c:member:`~PyTypeObject.tp_init` function is called; if :c:member:`~PyTypeObject.tp_new` returns an instance of a - subtype of the original type, the subtype's :c:member:`~PyTypeObject.tp_init` is called. (VERSION + :attr:`tp_init` function is called; if :attr:`tp_new` returns an instance of a + subtype of the original type, the subtype's :attr:`tp_init` is called. (VERSION NOTE: described here is what is implemented in Python 2.2.1 and later. In - Python 2.2, the :c:member:`~PyTypeObject.tp_init` of the type of the object returned by - :c:member:`~PyTypeObject.tp_new` was always called, if not *NULL*.) + Python 2.2, the :attr:`tp_init` of the type of the object returned by + :attr:`tp_new` was always called, if not *NULL*.) This field is inherited by subtypes. -.. c:member:: allocfunc PyTypeObject.tp_alloc +.. cmember:: allocfunc PyTypeObject.tp_alloc An optional pointer to an instance allocation function. @@ -982,22 +982,22 @@ initialization. It should return a pointer to a block of memory of adequate length for the instance, suitably aligned, and initialized to zeros, but with :attr:`ob_refcnt` set to ``1`` and :attr:`ob_type` set to the type argument. If - the type's :c:member:`~PyTypeObject.tp_itemsize` is non-zero, the object's :attr:`ob_size` field + the type's :attr:`tp_itemsize` is non-zero, the object's :attr:`ob_size` field should be initialized to *nitems* and the length of the allocated memory block should be ``tp_basicsize + nitems*tp_itemsize``, rounded up to a multiple of ``sizeof(void*)``; otherwise, *nitems* is not used and the length of the block - should be :c:member:`~PyTypeObject.tp_basicsize`. + should be :attr:`tp_basicsize`. Do not use this function to do any other instance initialization, not even to - allocate additional memory; that should be done by :c:member:`~PyTypeObject.tp_new`. + allocate additional memory; that should be done by :attr:`tp_new`. This field is inherited by static subtypes, but not by dynamic subtypes (subtypes created by a class statement); in the latter, this field is always set - to :c:func:`PyType_GenericAlloc`, to force a standard heap allocation strategy. + to :cfunc:`PyType_GenericAlloc`, to force a standard heap allocation strategy. That is also the recommended value for statically defined types. -.. c:member:: newfunc PyTypeObject.tp_new +.. cmember:: newfunc PyTypeObject.tp_new An optional pointer to an instance creation function. @@ -1011,34 +1011,34 @@ The subtype argument is the type of the object being created; the *args* and *kwds* arguments represent positional and keyword arguments of the call to the - type. Note that subtype doesn't have to equal the type whose :c:member:`~PyTypeObject.tp_new` + type. Note that subtype doesn't have to equal the type whose :attr:`tp_new` function is called; it may be a subtype of that type (but not an unrelated type). - The :c:member:`~PyTypeObject.tp_new` function should call ``subtype->tp_alloc(subtype, nitems)`` + The :attr:`tp_new` function should call ``subtype->tp_alloc(subtype, nitems)`` to allocate space for the object, and then do only as much further initialization as is absolutely necessary. Initialization that can safely be - ignored or repeated should be placed in the :c:member:`~PyTypeObject.tp_init` handler. A good + ignored or repeated should be placed in the :attr:`tp_init` handler. A good rule of thumb is that for immutable types, all initialization should take place - in :c:member:`~PyTypeObject.tp_new`, while for mutable types, most initialization should be - deferred to :c:member:`~PyTypeObject.tp_init`. + in :attr:`tp_new`, while for mutable types, most initialization should be + deferred to :attr:`tp_init`. This field is inherited by subtypes, except it is not inherited by static types - whose :c:member:`~PyTypeObject.tp_base` is *NULL* or ``&PyBaseObject_Type``. The latter exception + whose :attr:`tp_base` is *NULL* or ``&PyBaseObject_Type``. The latter exception is a precaution so that old extension types don't become callable simply by being linked with Python 2.2. -.. c:member:: destructor PyTypeObject.tp_free +.. cmember:: destructor PyTypeObject.tp_free An optional pointer to an instance deallocation function. The signature of this function has changed slightly: in Python 2.2 and 2.2.1, - its signature is :c:type:`destructor`:: + its signature is :ctype:`destructor`:: void tp_free(PyObject *) - In Python 2.3 and beyond, its signature is :c:type:`freefunc`:: + In Python 2.3 and beyond, its signature is :ctype:`freefunc`:: void tp_free(void *) @@ -1047,17 +1047,17 @@ This field is inherited by static subtypes, but not by dynamic subtypes (subtypes created by a class statement); in the latter, this field is set to a - deallocator suitable to match :c:func:`PyType_GenericAlloc` and the value of the + deallocator suitable to match :cfunc:`PyType_GenericAlloc` and the value of the :const:`Py_TPFLAGS_HAVE_GC` flag bit. -.. c:member:: inquiry PyTypeObject.tp_is_gc +.. cmember:: inquiry PyTypeObject.tp_is_gc An optional pointer to a function called by the garbage collector. The garbage collector needs to know whether a particular object is collectible or not. Normally, it is sufficient to look at the object's type's - :c:member:`~PyTypeObject.tp_flags` field, and check the :const:`Py_TPFLAGS_HAVE_GC` flag bit. But + :attr:`tp_flags` field, and check the :const:`Py_TPFLAGS_HAVE_GC` flag bit. But some types have a mixture of statically and dynamically allocated instances, and the statically allocated instances are not collectible. Such types should define this function; it should return ``1`` for a collectible instance, and @@ -1066,14 +1066,14 @@ int tp_is_gc(PyObject *self) (The only example of this are types themselves. The metatype, - :c:data:`PyType_Type`, defines this function to distinguish between statically + :cdata:`PyType_Type`, defines this function to distinguish between statically and dynamically allocated types.) This field is inherited by subtypes. (VERSION NOTE: in Python 2.2, it was not inherited. It is inherited in 2.2.1 and later versions.) -.. c:member:: PyObject* PyTypeObject.tp_bases +.. cmember:: PyObject* PyTypeObject.tp_bases Tuple of base types. @@ -1083,25 +1083,25 @@ This field is not inherited. -.. c:member:: PyObject* PyTypeObject.tp_mro +.. cmember:: PyObject* PyTypeObject.tp_mro Tuple containing the expanded set of base types, starting with the type itself and ending with :class:`object`, in Method Resolution Order. - This field is not inherited; it is calculated fresh by :c:func:`PyType_Ready`. + This field is not inherited; it is calculated fresh by :cfunc:`PyType_Ready`. -.. c:member:: PyObject* PyTypeObject.tp_cache +.. cmember:: PyObject* PyTypeObject.tp_cache Unused. Not inherited. Internal use only. -.. c:member:: PyObject* PyTypeObject.tp_subclasses +.. cmember:: PyObject* PyTypeObject.tp_subclasses List of weak references to subclasses. Not inherited. Internal use only. -.. c:member:: PyObject* PyTypeObject.tp_weaklist +.. cmember:: PyObject* PyTypeObject.tp_weaklist Weak reference list head, for weak references to this type object. Not inherited. Internal use only. @@ -1112,24 +1112,24 @@ subtypes. -.. c:member:: Py_ssize_t PyTypeObject.tp_allocs +.. cmember:: Py_ssize_t PyTypeObject.tp_allocs Number of allocations. -.. c:member:: Py_ssize_t PyTypeObject.tp_frees +.. cmember:: Py_ssize_t PyTypeObject.tp_frees Number of frees. -.. c:member:: Py_ssize_t PyTypeObject.tp_maxalloc +.. cmember:: Py_ssize_t PyTypeObject.tp_maxalloc Maximum simultaneously allocated objects. -.. c:member:: PyTypeObject* PyTypeObject.tp_next +.. cmember:: PyTypeObject* PyTypeObject.tp_next - Pointer to the next type object with a non-zero :c:member:`~PyTypeObject.tp_allocs` field. + Pointer to the next type object with a non-zero :attr:`tp_allocs` field. Also, note that, in a garbage collected Python, tp_dealloc may be called from any Python thread, not just the thread which created the object (if the object @@ -1150,7 +1150,7 @@ .. sectionauthor:: Amaury Forgeot d'Arc -.. c:type:: PyNumberMethods +.. ctype:: PyNumberMethods This structure holds pointers to the functions which an object uses to implement the number protocol. Almost every function below is used by the @@ -1215,9 +1215,9 @@ the coercion method specified by the :attr:`nb_coerce` member to convert the arguments: - .. c:member:: coercion PyNumberMethods.nb_coerce + .. cmember:: coercion PyNumberMethods.nb_coerce - This function is used by :c:func:`PyNumber_CoerceEx` and has the same + This function is used by :cfunc:`PyNumber_CoerceEx` and has the same signature. The first argument is always a pointer to an object of the defined type. If the conversion to a common "larger" type is possible, the function replaces the pointers with new references to the converted objects @@ -1227,7 +1227,7 @@ - If the :const:`Py_TPFLAGS_CHECKTYPES` flag is set, binary and ternary functions must check the type of all their operands, and implement the necessary conversions (at least one of the operands is an instance of the - defined type). This is the recommended way; with Python 3 coercion will + defined type). This is the recommended way; with Python 3.0 coercion will disappear completely. If the operation is not defined for the given operands, binary and ternary @@ -1243,26 +1243,26 @@ .. sectionauthor:: Amaury Forgeot d'Arc -.. c:type:: PyMappingMethods +.. ctype:: PyMappingMethods This structure holds pointers to the functions which an object uses to implement the mapping protocol. It has three members: -.. c:member:: lenfunc PyMappingMethods.mp_length +.. cmember:: lenfunc PyMappingMethods.mp_length - This function is used by :c:func:`PyMapping_Length` and - :c:func:`PyObject_Size`, and has the same signature. This slot may be set to + This function is used by :cfunc:`PyMapping_Length` and + :cfunc:`PyObject_Size`, and has the same signature. This slot may be set to *NULL* if the object has no defined length. -.. c:member:: binaryfunc PyMappingMethods.mp_subscript +.. cmember:: binaryfunc PyMappingMethods.mp_subscript - This function is used by :c:func:`PyObject_GetItem` and has the same - signature. This slot must be filled for the :c:func:`PyMapping_Check` + This function is used by :cfunc:`PyObject_GetItem` and has the same + signature. This slot must be filled for the :cfunc:`PyMapping_Check` function to return ``1``, it can be *NULL* otherwise. -.. c:member:: objobjargproc PyMappingMethods.mp_ass_subscript +.. cmember:: objobjargproc PyMappingMethods.mp_ass_subscript - This function is used by :c:func:`PyObject_SetItem` and has the same + This function is used by :cfunc:`PyObject_SetItem` and has the same signature. If this slot is *NULL*, the object does not support item assignment. @@ -1275,33 +1275,32 @@ .. sectionauthor:: Amaury Forgeot d'Arc -.. c:type:: PySequenceMethods +.. ctype:: PySequenceMethods This structure holds pointers to the functions which an object uses to implement the sequence protocol. -.. c:member:: lenfunc PySequenceMethods.sq_length +.. cmember:: lenfunc PySequenceMethods.sq_length - This function is used by :c:func:`PySequence_Size` and :c:func:`PyObject_Size`, + This function is used by :cfunc:`PySequence_Size` and :cfunc:`PyObject_Size`, and has the same signature. -.. c:member:: binaryfunc PySequenceMethods.sq_concat +.. cmember:: binaryfunc PySequenceMethods.sq_concat - This function is used by :c:func:`PySequence_Concat` and has the same + This function is used by :cfunc:`PySequence_Concat` and has the same signature. It is also used by the ``+`` operator, after trying the numeric - addition via the :c:member:`~PyTypeObject.tp_as_number.nb_add` slot. + addition via the :attr:`tp_as_number.nb_add` slot. -.. c:member:: ssizeargfunc PySequenceMethods.sq_repeat +.. cmember:: ssizeargfunc PySequenceMethods.sq_repeat - This function is used by :c:func:`PySequence_Repeat` and has the same + This function is used by :cfunc:`PySequence_Repeat` and has the same signature. It is also used by the ``*`` operator, after trying numeric - multiplication via the :c:member:`~PyTypeObject.tp_as_number.nb_multiply` - slot. + multiplication via the :attr:`tp_as_number.nb_mul` slot. -.. c:member:: ssizeargfunc PySequenceMethods.sq_item +.. cmember:: ssizeargfunc PySequenceMethods.sq_item - This function is used by :c:func:`PySequence_GetItem` and has the same - signature. This slot must be filled for the :c:func:`PySequence_Check` + This function is used by :cfunc:`PySequence_GetItem` and has the same + signature. This slot must be filled for the :cfunc:`PySequence_Check` function to return ``1``, it can be *NULL* otherwise. Negative indexes are handled as follows: if the :attr:`sq_length` slot is @@ -1309,27 +1308,27 @@ index which is passed to :attr:`sq_item`. If :attr:`sq_length` is *NULL*, the index is passed as is to the function. -.. c:member:: ssizeobjargproc PySequenceMethods.sq_ass_item +.. cmember:: ssizeobjargproc PySequenceMethods.sq_ass_item - This function is used by :c:func:`PySequence_SetItem` and has the same + This function is used by :cfunc:`PySequence_SetItem` and has the same signature. This slot may be left to *NULL* if the object does not support item assignment. -.. c:member:: objobjproc PySequenceMethods.sq_contains +.. cmember:: objobjproc PySequenceMethods.sq_contains - This function may be used by :c:func:`PySequence_Contains` and has the same + This function may be used by :cfunc:`PySequence_Contains` and has the same signature. This slot may be left to *NULL*, in this case - :c:func:`PySequence_Contains` simply traverses the sequence until it finds a + :cfunc:`PySequence_Contains` simply traverses the sequence until it finds a match. -.. c:member:: binaryfunc PySequenceMethods.sq_inplace_concat +.. cmember:: binaryfunc PySequenceMethods.sq_inplace_concat - This function is used by :c:func:`PySequence_InPlaceConcat` and has the same + This function is used by :cfunc:`PySequence_InPlaceConcat` and has the same signature. It should modify its first operand, and return it. -.. c:member:: ssizeargfunc PySequenceMethods.sq_inplace_repeat +.. cmember:: ssizeargfunc PySequenceMethods.sq_inplace_repeat - This function is used by :c:func:`PySequence_InPlaceRepeat` and has the same + This function is used by :cfunc:`PySequence_InPlaceRepeat` and has the same signature. It should modify its first operand, and return it. .. XXX need to explain precedence between mapping and sequence @@ -1349,46 +1348,46 @@ pointer/length pair. These chunks are called :dfn:`segments` and are presumed to be non-contiguous in memory. -If an object does not export the buffer interface, then its :c:member:`~PyTypeObject.tp_as_buffer` -member in the :c:type:`PyTypeObject` structure should be *NULL*. Otherwise, the -:c:member:`~PyTypeObject.tp_as_buffer` will point to a :c:type:`PyBufferProcs` structure. +If an object does not export the buffer interface, then its :attr:`tp_as_buffer` +member in the :ctype:`PyTypeObject` structure should be *NULL*. Otherwise, the +:attr:`tp_as_buffer` will point to a :ctype:`PyBufferProcs` structure. .. note:: - It is very important that your :c:type:`PyTypeObject` structure uses - :const:`Py_TPFLAGS_DEFAULT` for the value of the :c:member:`~PyTypeObject.tp_flags` member rather - than ``0``. This tells the Python runtime that your :c:type:`PyBufferProcs` + It is very important that your :ctype:`PyTypeObject` structure uses + :const:`Py_TPFLAGS_DEFAULT` for the value of the :attr:`tp_flags` member rather + than ``0``. This tells the Python runtime that your :ctype:`PyBufferProcs` structure contains the :attr:`bf_getcharbuffer` slot. Older versions of Python did not have this member, so a new Python interpreter using an old extension needs to be able to test for its presence before using it. -.. c:type:: PyBufferProcs +.. ctype:: PyBufferProcs Structure used to hold the function pointers which define an implementation of the buffer protocol. - The first slot is :attr:`bf_getreadbuffer`, of type :c:type:`getreadbufferproc`. + The first slot is :attr:`bf_getreadbuffer`, of type :ctype:`getreadbufferproc`. If this slot is *NULL*, then the object does not support reading from the internal data. This is non-sensical, so implementors should fill this in, but callers should test that the slot contains a non-*NULL* value. The next slot is :attr:`bf_getwritebuffer` having type - :c:type:`getwritebufferproc`. This slot may be *NULL* if the object does not + :ctype:`getwritebufferproc`. This slot may be *NULL* if the object does not allow writing into its returned buffers. - The third slot is :attr:`bf_getsegcount`, with type :c:type:`getsegcountproc`. + The third slot is :attr:`bf_getsegcount`, with type :ctype:`getsegcountproc`. This slot must not be *NULL* and is used to inform the caller how many segments - the object contains. Simple objects such as :c:type:`PyString_Type` and - :c:type:`PyBuffer_Type` objects contain a single segment. + the object contains. Simple objects such as :ctype:`PyString_Type` and + :ctype:`PyBuffer_Type` objects contain a single segment. .. index:: single: PyType_HasFeature() - The last slot is :attr:`bf_getcharbuffer`, of type :c:type:`getcharbufferproc`. + The last slot is :attr:`bf_getcharbuffer`, of type :ctype:`getcharbufferproc`. This slot will only be present if the :const:`Py_TPFLAGS_HAVE_GETCHARBUFFER` - flag is present in the :c:member:`~PyTypeObject.tp_flags` field of the object's - :c:type:`PyTypeObject`. Before using this slot, the caller should test whether it - is present by using the :c:func:`PyType_HasFeature` function. If the flag is + flag is present in the :attr:`tp_flags` field of the object's + :ctype:`PyTypeObject`. Before using this slot, the caller should test whether it + is present by using the :cfunc:`PyType_HasFeature` function. If the flag is present, :attr:`bf_getcharbuffer` may be *NULL*, indicating that the object's contents cannot be used as *8-bit characters*. The slot function may also raise an error if the object's contents cannot be interpreted as 8-bit characters. @@ -1412,7 +1411,7 @@ buffer interface or that the :attr:`bf_getcharbuffer` slot is non-*NULL*. -.. c:type:: Py_ssize_t (*readbufferproc) (PyObject *self, Py_ssize_t segment, void **ptrptr) +.. ctype:: Py_ssize_t (*readbufferproc) (PyObject *self, Py_ssize_t segment, void **ptrptr) Return a pointer to a readable segment of the buffer in ``*ptrptr``. This function is allowed to raise an exception, in which case it must return ``-1``. @@ -1422,7 +1421,7 @@ ``*ptrptr`` to a pointer to that memory. -.. c:type:: Py_ssize_t (*writebufferproc) (PyObject *self, Py_ssize_t segment, void **ptrptr) +.. ctype:: Py_ssize_t (*writebufferproc) (PyObject *self, Py_ssize_t segment, void **ptrptr) Return a pointer to a writable memory buffer in ``*ptrptr``, and the length of that segment as the function return value. The memory buffer must correspond to @@ -1436,14 +1435,14 @@ segment. That indicates a blatant programming error in the C code. -.. c:type:: Py_ssize_t (*segcountproc) (PyObject *self, Py_ssize_t *lenp) +.. ctype:: Py_ssize_t (*segcountproc) (PyObject *self, Py_ssize_t *lenp) Return the number of memory segments which comprise the buffer. If *lenp* is not *NULL*, the implementation must report the sum of the sizes (in bytes) of all segments in ``*lenp``. The function cannot fail. -.. c:type:: Py_ssize_t (*charbufferproc) (PyObject *self, Py_ssize_t segment, const char **ptrptr) +.. ctype:: Py_ssize_t (*charbufferproc) (PyObject *self, Py_ssize_t segment, const char **ptrptr) Return the size of the segment *segment* that *ptrptr* is set to. ``*ptrptr`` is set to the memory buffer. Returns ``-1`` on error. diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/c-api/unicode.rst --- a/Doc/c-api/unicode.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/c-api/unicode.rst Sun Jul 20 10:52:46 2014 -0400 @@ -18,39 +18,39 @@ Python: -.. c:type:: Py_UNICODE +.. ctype:: Py_UNICODE This type represents the storage type which is used by Python internally as basis for holding Unicode ordinals. Python's default builds use a 16-bit type - for :c:type:`Py_UNICODE` and store Unicode values internally as UCS2. It is also + for :ctype:`Py_UNICODE` and store Unicode values internally as UCS2. It is also possible to build a UCS4 version of Python (most recent Linux distributions come with UCS4 builds of Python). These builds then use a 32-bit type for - :c:type:`Py_UNICODE` and store Unicode data internally as UCS4. On platforms - where :c:type:`wchar_t` is available and compatible with the chosen Python - Unicode build variant, :c:type:`Py_UNICODE` is a typedef alias for - :c:type:`wchar_t` to enhance native platform compatibility. On all other - platforms, :c:type:`Py_UNICODE` is a typedef alias for either :c:type:`unsigned - short` (UCS2) or :c:type:`unsigned long` (UCS4). + :ctype:`Py_UNICODE` and store Unicode data internally as UCS4. On platforms + where :ctype:`wchar_t` is available and compatible with the chosen Python + Unicode build variant, :ctype:`Py_UNICODE` is a typedef alias for + :ctype:`wchar_t` to enhance native platform compatibility. On all other + platforms, :ctype:`Py_UNICODE` is a typedef alias for either :ctype:`unsigned + short` (UCS2) or :ctype:`unsigned long` (UCS4). Note that UCS2 and UCS4 Python builds are not binary compatible. Please keep this in mind when writing extensions or interfaces. -.. c:type:: PyUnicodeObject +.. ctype:: PyUnicodeObject - This subtype of :c:type:`PyObject` represents a Python Unicode object. + This subtype of :ctype:`PyObject` represents a Python Unicode object. -.. c:var:: PyTypeObject PyUnicode_Type +.. cvar:: PyTypeObject PyUnicode_Type - This instance of :c:type:`PyTypeObject` represents the Python Unicode type. It + This instance of :ctype:`PyTypeObject` represents the Python Unicode type. It is exposed to Python code as ``unicode`` and ``types.UnicodeType``. The following APIs are really C macros and can be used to do fast checks and to access internal read-only data of Unicode objects: -.. c:function:: int PyUnicode_Check(PyObject *o) +.. cfunction:: int PyUnicode_Check(PyObject *o) Return true if the object *o* is a Unicode object or an instance of a Unicode subtype. @@ -59,7 +59,7 @@ Allowed subtypes to be accepted. -.. c:function:: int PyUnicode_CheckExact(PyObject *o) +.. cfunction:: int PyUnicode_CheckExact(PyObject *o) Return true if the object *o* is a Unicode object, but not an instance of a subtype. @@ -67,39 +67,39 @@ .. versionadded:: 2.2 -.. c:function:: Py_ssize_t PyUnicode_GET_SIZE(PyObject *o) +.. cfunction:: Py_ssize_t PyUnicode_GET_SIZE(PyObject *o) - Return the size of the object. *o* has to be a :c:type:`PyUnicodeObject` (not + Return the size of the object. *o* has to be a :ctype:`PyUnicodeObject` (not checked). .. versionchanged:: 2.5 - This function returned an :c:type:`int` type. This might require changes + This function returned an :ctype:`int` type. This might require changes in your code for properly supporting 64-bit systems. -.. c:function:: Py_ssize_t PyUnicode_GET_DATA_SIZE(PyObject *o) +.. cfunction:: Py_ssize_t PyUnicode_GET_DATA_SIZE(PyObject *o) Return the size of the object's internal buffer in bytes. *o* has to be a - :c:type:`PyUnicodeObject` (not checked). + :ctype:`PyUnicodeObject` (not checked). .. versionchanged:: 2.5 - This function returned an :c:type:`int` type. This might require changes + This function returned an :ctype:`int` type. This might require changes in your code for properly supporting 64-bit systems. -.. c:function:: Py_UNICODE* PyUnicode_AS_UNICODE(PyObject *o) +.. cfunction:: Py_UNICODE* PyUnicode_AS_UNICODE(PyObject *o) - Return a pointer to the internal :c:type:`Py_UNICODE` buffer of the object. *o* - has to be a :c:type:`PyUnicodeObject` (not checked). + Return a pointer to the internal :ctype:`Py_UNICODE` buffer of the object. *o* + has to be a :ctype:`PyUnicodeObject` (not checked). -.. c:function:: const char* PyUnicode_AS_DATA(PyObject *o) +.. cfunction:: const char* PyUnicode_AS_DATA(PyObject *o) Return a pointer to the internal buffer of the object. *o* has to be a - :c:type:`PyUnicodeObject` (not checked). + :ctype:`PyUnicodeObject` (not checked). -.. c:function:: int PyUnicode_ClearFreeList() +.. cfunction:: int PyUnicode_ClearFreeList() Clear the free list. Return the total number of freed items. @@ -114,86 +114,86 @@ the Python configuration. -.. c:function:: int Py_UNICODE_ISSPACE(Py_UNICODE ch) +.. cfunction:: int Py_UNICODE_ISSPACE(Py_UNICODE ch) Return 1 or 0 depending on whether *ch* is a whitespace character. -.. c:function:: int Py_UNICODE_ISLOWER(Py_UNICODE ch) +.. cfunction:: int Py_UNICODE_ISLOWER(Py_UNICODE ch) Return 1 or 0 depending on whether *ch* is a lowercase character. -.. c:function:: int Py_UNICODE_ISUPPER(Py_UNICODE ch) +.. cfunction:: int Py_UNICODE_ISUPPER(Py_UNICODE ch) Return 1 or 0 depending on whether *ch* is an uppercase character. -.. c:function:: int Py_UNICODE_ISTITLE(Py_UNICODE ch) +.. cfunction:: int Py_UNICODE_ISTITLE(Py_UNICODE ch) Return 1 or 0 depending on whether *ch* is a titlecase character. -.. c:function:: int Py_UNICODE_ISLINEBREAK(Py_UNICODE ch) +.. cfunction:: int Py_UNICODE_ISLINEBREAK(Py_UNICODE ch) Return 1 or 0 depending on whether *ch* is a linebreak character. -.. c:function:: int Py_UNICODE_ISDECIMAL(Py_UNICODE ch) +.. cfunction:: int Py_UNICODE_ISDECIMAL(Py_UNICODE ch) Return 1 or 0 depending on whether *ch* is a decimal character. -.. c:function:: int Py_UNICODE_ISDIGIT(Py_UNICODE ch) +.. cfunction:: int Py_UNICODE_ISDIGIT(Py_UNICODE ch) Return 1 or 0 depending on whether *ch* is a digit character. -.. c:function:: int Py_UNICODE_ISNUMERIC(Py_UNICODE ch) +.. cfunction:: int Py_UNICODE_ISNUMERIC(Py_UNICODE ch) Return 1 or 0 depending on whether *ch* is a numeric character. -.. c:function:: int Py_UNICODE_ISALPHA(Py_UNICODE ch) +.. cfunction:: int Py_UNICODE_ISALPHA(Py_UNICODE ch) Return 1 or 0 depending on whether *ch* is an alphabetic character. -.. c:function:: int Py_UNICODE_ISALNUM(Py_UNICODE ch) +.. cfunction:: int Py_UNICODE_ISALNUM(Py_UNICODE ch) Return 1 or 0 depending on whether *ch* is an alphanumeric character. These APIs can be used for fast direct character conversions: -.. c:function:: Py_UNICODE Py_UNICODE_TOLOWER(Py_UNICODE ch) +.. cfunction:: Py_UNICODE Py_UNICODE_TOLOWER(Py_UNICODE ch) Return the character *ch* converted to lower case. -.. c:function:: Py_UNICODE Py_UNICODE_TOUPPER(Py_UNICODE ch) +.. cfunction:: Py_UNICODE Py_UNICODE_TOUPPER(Py_UNICODE ch) Return the character *ch* converted to upper case. -.. c:function:: Py_UNICODE Py_UNICODE_TOTITLE(Py_UNICODE ch) +.. cfunction:: Py_UNICODE Py_UNICODE_TOTITLE(Py_UNICODE ch) Return the character *ch* converted to title case. -.. c:function:: int Py_UNICODE_TODECIMAL(Py_UNICODE ch) +.. cfunction:: int Py_UNICODE_TODECIMAL(Py_UNICODE ch) Return the character *ch* converted to a decimal positive integer. Return ``-1`` if this is not possible. This macro does not raise exceptions. -.. c:function:: int Py_UNICODE_TODIGIT(Py_UNICODE ch) +.. cfunction:: int Py_UNICODE_TODIGIT(Py_UNICODE ch) Return the character *ch* converted to a single digit integer. Return ``-1`` if this is not possible. This macro does not raise exceptions. -.. c:function:: double Py_UNICODE_TONUMERIC(Py_UNICODE ch) +.. cfunction:: double Py_UNICODE_TONUMERIC(Py_UNICODE ch) Return the character *ch* converted to a double. Return ``-1.0`` if this is not possible. This macro does not raise exceptions. @@ -206,7 +206,7 @@ APIs: -.. c:function:: PyObject* PyUnicode_FromUnicode(const Py_UNICODE *u, Py_ssize_t size) +.. cfunction:: PyObject* PyUnicode_FromUnicode(const Py_UNICODE *u, Py_ssize_t size) Create a Unicode object from the Py_UNICODE buffer *u* of the given size. *u* may be *NULL* which causes the contents to be undefined. It is the user's @@ -216,11 +216,11 @@ is *NULL*. .. versionchanged:: 2.5 - This function used an :c:type:`int` type for *size*. This might require + This function used an :ctype:`int` type for *size*. This might require changes in your code for properly supporting 64-bit systems. -.. c:function:: PyObject* PyUnicode_FromStringAndSize(const char *u, Py_ssize_t size) +.. cfunction:: PyObject* PyUnicode_FromStringAndSize(const char *u, Py_ssize_t size) Create a Unicode object from the char buffer *u*. The bytes will be interpreted as being UTF-8 encoded. *u* may also be *NULL* which @@ -232,7 +232,7 @@ .. versionadded:: 2.6 -.. c:function:: PyObject *PyUnicode_FromString(const char *u) +.. cfunction:: PyObject *PyUnicode_FromString(const char *u) Create a Unicode object from an UTF-8 encoded null-terminated char buffer *u*. @@ -240,9 +240,9 @@ .. versionadded:: 2.6 -.. c:function:: PyObject* PyUnicode_FromFormat(const char *format, ...) +.. cfunction:: PyObject* PyUnicode_FromFormat(const char *format, ...) - Take a C :c:func:`printf`\ -style *format* string and a variable number of + Take a C :cfunc:`printf`\ -style *format* string and a variable number of arguments, calculate the size of the resulting Python unicode string and return a string with the values formatted into it. The variable arguments must be C types and must correspond exactly to the format characters in the *format* @@ -252,8 +252,6 @@ .. % because not all compilers support the %z width modifier -- we fake it .. % when necessary via interpolating PY_FORMAT_SIZE_T. - .. tabularcolumns:: |l|l|L| - +-------------------+---------------------+--------------------------------+ | Format Characters | Type | Comment | +===================+=====================+================================+ @@ -319,7 +317,7 @@ .. versionadded:: 2.6 -.. c:function:: PyObject* PyUnicode_FromFormatV(const char *format, va_list vargs) +.. cfunction:: PyObject* PyUnicode_FromFormatV(const char *format, va_list vargs) Identical to :func:`PyUnicode_FromFormat` except that it takes exactly two arguments. @@ -327,25 +325,22 @@ .. versionadded:: 2.6 -.. c:function:: Py_UNICODE* PyUnicode_AsUnicode(PyObject *unicode) +.. cfunction:: Py_UNICODE* PyUnicode_AsUnicode(PyObject *unicode) - Return a read-only pointer to the Unicode object's internal - :c:type:`Py_UNICODE` buffer, *NULL* if *unicode* is not a Unicode object. - Note that the resulting :c:type:`Py_UNICODE*` string may contain embedded - null characters, which would cause the string to be truncated when used in - most C functions. + Return a read-only pointer to the Unicode object's internal :ctype:`Py_UNICODE` + buffer, *NULL* if *unicode* is not a Unicode object. -.. c:function:: Py_ssize_t PyUnicode_GetSize(PyObject *unicode) +.. cfunction:: Py_ssize_t PyUnicode_GetSize(PyObject *unicode) Return the length of the Unicode object. .. versionchanged:: 2.5 - This function returned an :c:type:`int` type. This might require changes + This function returned an :ctype:`int` type. This might require changes in your code for properly supporting 64-bit systems. -.. c:function:: PyObject* PyUnicode_FromEncodedObject(PyObject *obj, const char *encoding, const char *errors) +.. cfunction:: PyObject* PyUnicode_FromEncodedObject(PyObject *obj, const char *encoding, const char *errors) Coerce an encoded object *obj* to an Unicode object and return a reference with incremented refcount. @@ -362,46 +357,44 @@ decref'ing the returned objects. -.. c:function:: PyObject* PyUnicode_FromObject(PyObject *obj) +.. cfunction:: PyObject* PyUnicode_FromObject(PyObject *obj) Shortcut for ``PyUnicode_FromEncodedObject(obj, NULL, "strict")`` which is used throughout the interpreter whenever coercion to Unicode is needed. -If the platform supports :c:type:`wchar_t` and provides a header file wchar.h, +If the platform supports :ctype:`wchar_t` and provides a header file wchar.h, Python can interface directly to this type using the following functions. -Support is optimized if Python's own :c:type:`Py_UNICODE` type is identical to -the system's :c:type:`wchar_t`. +Support is optimized if Python's own :ctype:`Py_UNICODE` type is identical to +the system's :ctype:`wchar_t`. wchar_t Support """"""""""""""" -:c:type:`wchar_t` support for platforms which support it: +:ctype:`wchar_t` support for platforms which support it: -.. c:function:: PyObject* PyUnicode_FromWideChar(const wchar_t *w, Py_ssize_t size) +.. cfunction:: PyObject* PyUnicode_FromWideChar(const wchar_t *w, Py_ssize_t size) - Create a Unicode object from the :c:type:`wchar_t` buffer *w* of the given *size*. + Create a Unicode object from the :ctype:`wchar_t` buffer *w* of the given *size*. Return *NULL* on failure. .. versionchanged:: 2.5 - This function used an :c:type:`int` type for *size*. This might require + This function used an :ctype:`int` type for *size*. This might require changes in your code for properly supporting 64-bit systems. -.. c:function:: Py_ssize_t PyUnicode_AsWideChar(PyUnicodeObject *unicode, wchar_t *w, Py_ssize_t size) +.. cfunction:: Py_ssize_t PyUnicode_AsWideChar(PyUnicodeObject *unicode, wchar_t *w, Py_ssize_t size) - Copy the Unicode object contents into the :c:type:`wchar_t` buffer *w*. At most - *size* :c:type:`wchar_t` characters are copied (excluding a possibly trailing - 0-termination character). Return the number of :c:type:`wchar_t` characters - copied or -1 in case of an error. Note that the resulting :c:type:`wchar_t` + Copy the Unicode object contents into the :ctype:`wchar_t` buffer *w*. At most + *size* :ctype:`wchar_t` characters are copied (excluding a possibly trailing + 0-termination character). Return the number of :ctype:`wchar_t` characters + copied or -1 in case of an error. Note that the resulting :ctype:`wchar_t` string may or may not be 0-terminated. It is the responsibility of the caller - to make sure that the :c:type:`wchar_t` string is 0-terminated in case this is - required by the application. Also, note that the :c:type:`wchar_t*` string - might contain null characters, which would cause the string to be truncated - when used with most C functions. + to make sure that the :ctype:`wchar_t` string is 0-terminated in case this is + required by the application. .. versionchanged:: 2.5 - This function returned an :c:type:`int` type and used an :c:type:`int` + This function returned an :ctype:`int` type and used an :ctype:`int` type for *size*. This might require changes in your code for properly supporting 64-bit systems. @@ -419,7 +412,7 @@ object constructor. Setting encoding to *NULL* causes the default encoding to be used which is -ASCII. The file system calls should use :c:data:`Py_FileSystemDefaultEncoding` +ASCII. The file system calls should use :cdata:`Py_FileSystemDefaultEncoding` as the encoding for file names. This variable should be treated as read-only: on some systems, it will be a pointer to a static string, on others, it will change at run-time (such as when the application invokes setlocale). @@ -438,7 +431,7 @@ These are the generic codec APIs: -.. c:function:: PyObject* PyUnicode_Decode(const char *s, Py_ssize_t size, const char *encoding, const char *errors) +.. cfunction:: PyObject* PyUnicode_Decode(const char *s, Py_ssize_t size, const char *encoding, const char *errors) Create a Unicode object by decoding *size* bytes of the encoded string *s*. *encoding* and *errors* have the same meaning as the parameters of the same name @@ -447,24 +440,24 @@ the codec. .. versionchanged:: 2.5 - This function used an :c:type:`int` type for *size*. This might require + This function used an :ctype:`int` type for *size*. This might require changes in your code for properly supporting 64-bit systems. -.. c:function:: PyObject* PyUnicode_Encode(const Py_UNICODE *s, Py_ssize_t size, const char *encoding, const char *errors) +.. cfunction:: PyObject* PyUnicode_Encode(const Py_UNICODE *s, Py_ssize_t size, const char *encoding, const char *errors) - Encode the :c:type:`Py_UNICODE` buffer *s* of the given *size* and return a Python + Encode the :ctype:`Py_UNICODE` buffer *s* of the given *size* and return a Python string object. *encoding* and *errors* have the same meaning as the parameters - of the same name in the Unicode :meth:`~unicode.encode` method. The codec - to be used is looked up using the Python codec registry. Return *NULL* if - an exception was raised by the codec. + of the same name in the Unicode :meth:`encode` method. The codec to be used is + looked up using the Python codec registry. Return *NULL* if an exception was + raised by the codec. .. versionchanged:: 2.5 - This function used an :c:type:`int` type for *size*. This might require + This function used an :ctype:`int` type for *size*. This might require changes in your code for properly supporting 64-bit systems. -.. c:function:: PyObject* PyUnicode_AsEncodedString(PyObject *unicode, const char *encoding, const char *errors) +.. cfunction:: PyObject* PyUnicode_AsEncodedString(PyObject *unicode, const char *encoding, const char *errors) Encode a Unicode object and return the result as Python string object. *encoding* and *errors* have the same meaning as the parameters of the same name @@ -479,19 +472,19 @@ These are the UTF-8 codec APIs: -.. c:function:: PyObject* PyUnicode_DecodeUTF8(const char *s, Py_ssize_t size, const char *errors) +.. cfunction:: PyObject* PyUnicode_DecodeUTF8(const char *s, Py_ssize_t size, const char *errors) Create a Unicode object by decoding *size* bytes of the UTF-8 encoded string *s*. Return *NULL* if an exception was raised by the codec. .. versionchanged:: 2.5 - This function used an :c:type:`int` type for *size*. This might require + This function used an :ctype:`int` type for *size*. This might require changes in your code for properly supporting 64-bit systems. -.. c:function:: PyObject* PyUnicode_DecodeUTF8Stateful(const char *s, Py_ssize_t size, const char *errors, Py_ssize_t *consumed) +.. cfunction:: PyObject* PyUnicode_DecodeUTF8Stateful(const char *s, Py_ssize_t size, const char *errors, Py_ssize_t *consumed) - If *consumed* is *NULL*, behave like :c:func:`PyUnicode_DecodeUTF8`. If + If *consumed* is *NULL*, behave like :cfunc:`PyUnicode_DecodeUTF8`. If *consumed* is not *NULL*, trailing incomplete UTF-8 byte sequences will not be treated as an error. Those bytes will not be decoded and the number of bytes that have been decoded will be stored in *consumed*. @@ -499,21 +492,21 @@ .. versionadded:: 2.4 .. versionchanged:: 2.5 - This function used an :c:type:`int` type for *size*. This might require + This function used an :ctype:`int` type for *size*. This might require changes in your code for properly supporting 64-bit systems. -.. c:function:: PyObject* PyUnicode_EncodeUTF8(const Py_UNICODE *s, Py_ssize_t size, const char *errors) +.. cfunction:: PyObject* PyUnicode_EncodeUTF8(const Py_UNICODE *s, Py_ssize_t size, const char *errors) - Encode the :c:type:`Py_UNICODE` buffer *s* of the given *size* using UTF-8 and return a + Encode the :ctype:`Py_UNICODE` buffer *s* of the given *size* using UTF-8 and return a Python string object. Return *NULL* if an exception was raised by the codec. .. versionchanged:: 2.5 - This function used an :c:type:`int` type for *size*. This might require + This function used an :ctype:`int` type for *size*. This might require changes in your code for properly supporting 64-bit systems. -.. c:function:: PyObject* PyUnicode_AsUTF8String(PyObject *unicode) +.. cfunction:: PyObject* PyUnicode_AsUTF8String(PyObject *unicode) Encode a Unicode object using UTF-8 and return the result as Python string object. Error handling is "strict". Return *NULL* if an exception was raised @@ -526,7 +519,7 @@ These are the UTF-32 codec APIs: -.. c:function:: PyObject* PyUnicode_DecodeUTF32(const char *s, Py_ssize_t size, const char *errors, int *byteorder) +.. cfunction:: PyObject* PyUnicode_DecodeUTF32(const char *s, Py_ssize_t size, const char *errors, int *byteorder) Decode *size* bytes from a UTF-32 encoded buffer string and return the corresponding Unicode object. *errors* (if non-*NULL*) defines the error @@ -556,10 +549,10 @@ .. versionadded:: 2.6 -.. c:function:: PyObject* PyUnicode_DecodeUTF32Stateful(const char *s, Py_ssize_t size, const char *errors, int *byteorder, Py_ssize_t *consumed) +.. cfunction:: PyObject* PyUnicode_DecodeUTF32Stateful(const char *s, Py_ssize_t size, const char *errors, int *byteorder, Py_ssize_t *consumed) - If *consumed* is *NULL*, behave like :c:func:`PyUnicode_DecodeUTF32`. If - *consumed* is not *NULL*, :c:func:`PyUnicode_DecodeUTF32Stateful` will not treat + If *consumed* is *NULL*, behave like :cfunc:`PyUnicode_DecodeUTF32`. If + *consumed* is not *NULL*, :cfunc:`PyUnicode_DecodeUTF32Stateful` will not treat trailing incomplete UTF-32 byte sequences (such as a number of bytes not divisible by four) as an error. Those bytes will not be decoded and the number of bytes that have been decoded will be stored in *consumed*. @@ -567,7 +560,7 @@ .. versionadded:: 2.6 -.. c:function:: PyObject* PyUnicode_EncodeUTF32(const Py_UNICODE *s, Py_ssize_t size, const char *errors, int byteorder) +.. cfunction:: PyObject* PyUnicode_EncodeUTF32(const Py_UNICODE *s, Py_ssize_t size, const char *errors, int byteorder) Return a Python bytes object holding the UTF-32 encoded value of the Unicode data in *s*. Output is written according to the following byte order:: @@ -587,7 +580,7 @@ .. versionadded:: 2.6 -.. c:function:: PyObject* PyUnicode_AsUTF32String(PyObject *unicode) +.. cfunction:: PyObject* PyUnicode_AsUTF32String(PyObject *unicode) Return a Python string using the UTF-32 encoding in native byte order. The string always starts with a BOM mark. Error handling is "strict". Return @@ -602,7 +595,7 @@ These are the UTF-16 codec APIs: -.. c:function:: PyObject* PyUnicode_DecodeUTF16(const char *s, Py_ssize_t size, const char *errors, int *byteorder) +.. cfunction:: PyObject* PyUnicode_DecodeUTF16(const char *s, Py_ssize_t size, const char *errors, int *byteorder) Decode *size* bytes from a UTF-16 encoded buffer string and return the corresponding Unicode object. *errors* (if non-*NULL*) defines the error @@ -629,14 +622,14 @@ Return *NULL* if an exception was raised by the codec. .. versionchanged:: 2.5 - This function used an :c:type:`int` type for *size*. This might require + This function used an :ctype:`int` type for *size*. This might require changes in your code for properly supporting 64-bit systems. -.. c:function:: PyObject* PyUnicode_DecodeUTF16Stateful(const char *s, Py_ssize_t size, const char *errors, int *byteorder, Py_ssize_t *consumed) +.. cfunction:: PyObject* PyUnicode_DecodeUTF16Stateful(const char *s, Py_ssize_t size, const char *errors, int *byteorder, Py_ssize_t *consumed) - If *consumed* is *NULL*, behave like :c:func:`PyUnicode_DecodeUTF16`. If - *consumed* is not *NULL*, :c:func:`PyUnicode_DecodeUTF16Stateful` will not treat + If *consumed* is *NULL*, behave like :cfunc:`PyUnicode_DecodeUTF16`. If + *consumed* is not *NULL*, :cfunc:`PyUnicode_DecodeUTF16Stateful` will not treat trailing incomplete UTF-16 byte sequences (such as an odd number of bytes or a split surrogate pair) as an error. Those bytes will not be decoded and the number of bytes that have been decoded will be stored in *consumed*. @@ -644,12 +637,12 @@ .. versionadded:: 2.4 .. versionchanged:: 2.5 - This function used an :c:type:`int` type for *size* and an :c:type:`int *` + This function used an :ctype:`int` type for *size* and an :ctype:`int *` type for *consumed*. This might require changes in your code for properly supporting 64-bit systems. -.. c:function:: PyObject* PyUnicode_EncodeUTF16(const Py_UNICODE *s, Py_ssize_t size, const char *errors, int byteorder) +.. cfunction:: PyObject* PyUnicode_EncodeUTF16(const Py_UNICODE *s, Py_ssize_t size, const char *errors, int byteorder) Return a Python string object holding the UTF-16 encoded value of the Unicode data in *s*. Output is written according to the following byte order:: @@ -661,18 +654,18 @@ If byteorder is ``0``, the output string will always start with the Unicode BOM mark (U+FEFF). In the other two modes, no BOM mark is prepended. - If *Py_UNICODE_WIDE* is defined, a single :c:type:`Py_UNICODE` value may get - represented as a surrogate pair. If it is not defined, each :c:type:`Py_UNICODE` + If *Py_UNICODE_WIDE* is defined, a single :ctype:`Py_UNICODE` value may get + represented as a surrogate pair. If it is not defined, each :ctype:`Py_UNICODE` values is interpreted as an UCS-2 character. Return *NULL* if an exception was raised by the codec. .. versionchanged:: 2.5 - This function used an :c:type:`int` type for *size*. This might require + This function used an :ctype:`int` type for *size*. This might require changes in your code for properly supporting 64-bit systems. -.. c:function:: PyObject* PyUnicode_AsUTF16String(PyObject *unicode) +.. cfunction:: PyObject* PyUnicode_AsUTF16String(PyObject *unicode) Return a Python string using the UTF-16 encoding in native byte order. The string always starts with a BOM mark. Error handling is "strict". Return @@ -685,23 +678,23 @@ These are the UTF-7 codec APIs: -.. c:function:: PyObject* PyUnicode_DecodeUTF7(const char *s, Py_ssize_t size, const char *errors) +.. cfunction:: PyObject* PyUnicode_DecodeUTF7(const char *s, Py_ssize_t size, const char *errors) Create a Unicode object by decoding *size* bytes of the UTF-7 encoded string *s*. Return *NULL* if an exception was raised by the codec. -.. c:function:: PyObject* PyUnicode_DecodeUTF7Stateful(const char *s, Py_ssize_t size, const char *errors, Py_ssize_t *consumed) +.. cfunction:: PyObject* PyUnicode_DecodeUTF7Stateful(const char *s, Py_ssize_t size, const char *errors, Py_ssize_t *consumed) - If *consumed* is *NULL*, behave like :c:func:`PyUnicode_DecodeUTF7`. If + If *consumed* is *NULL*, behave like :cfunc:`PyUnicode_DecodeUTF7`. If *consumed* is not *NULL*, trailing incomplete UTF-7 base-64 sections will not be treated as an error. Those bytes will not be decoded and the number of bytes that have been decoded will be stored in *consumed*. -.. c:function:: PyObject* PyUnicode_EncodeUTF7(const Py_UNICODE *s, Py_ssize_t size, int base64SetO, int base64WhiteSpace, const char *errors) +.. cfunction:: PyObject* PyUnicode_EncodeUTF7(const Py_UNICODE *s, Py_ssize_t size, int base64SetO, int base64WhiteSpace, const char *errors) - Encode the :c:type:`Py_UNICODE` buffer of the given size using UTF-7 and + Encode the :ctype:`Py_UNICODE` buffer of the given size using UTF-7 and return a Python bytes object. Return *NULL* if an exception was raised by the codec. @@ -717,28 +710,28 @@ These are the "Unicode Escape" codec APIs: -.. c:function:: PyObject* PyUnicode_DecodeUnicodeEscape(const char *s, Py_ssize_t size, const char *errors) +.. cfunction:: PyObject* PyUnicode_DecodeUnicodeEscape(const char *s, Py_ssize_t size, const char *errors) Create a Unicode object by decoding *size* bytes of the Unicode-Escape encoded string *s*. Return *NULL* if an exception was raised by the codec. .. versionchanged:: 2.5 - This function used an :c:type:`int` type for *size*. This might require + This function used an :ctype:`int` type for *size*. This might require changes in your code for properly supporting 64-bit systems. -.. c:function:: PyObject* PyUnicode_EncodeUnicodeEscape(const Py_UNICODE *s, Py_ssize_t size) +.. cfunction:: PyObject* PyUnicode_EncodeUnicodeEscape(const Py_UNICODE *s, Py_ssize_t size) - Encode the :c:type:`Py_UNICODE` buffer of the given *size* using Unicode-Escape and + Encode the :ctype:`Py_UNICODE` buffer of the given *size* using Unicode-Escape and return a Python string object. Return *NULL* if an exception was raised by the codec. .. versionchanged:: 2.5 - This function used an :c:type:`int` type for *size*. This might require + This function used an :ctype:`int` type for *size*. This might require changes in your code for properly supporting 64-bit systems. -.. c:function:: PyObject* PyUnicode_AsUnicodeEscapeString(PyObject *unicode) +.. cfunction:: PyObject* PyUnicode_AsUnicodeEscapeString(PyObject *unicode) Encode a Unicode object using Unicode-Escape and return the result as Python string object. Error handling is "strict". Return *NULL* if an exception was @@ -751,28 +744,28 @@ These are the "Raw Unicode Escape" codec APIs: -.. c:function:: PyObject* PyUnicode_DecodeRawUnicodeEscape(const char *s, Py_ssize_t size, const char *errors) +.. cfunction:: PyObject* PyUnicode_DecodeRawUnicodeEscape(const char *s, Py_ssize_t size, const char *errors) Create a Unicode object by decoding *size* bytes of the Raw-Unicode-Escape encoded string *s*. Return *NULL* if an exception was raised by the codec. .. versionchanged:: 2.5 - This function used an :c:type:`int` type for *size*. This might require + This function used an :ctype:`int` type for *size*. This might require changes in your code for properly supporting 64-bit systems. -.. c:function:: PyObject* PyUnicode_EncodeRawUnicodeEscape(const Py_UNICODE *s, Py_ssize_t size, const char *errors) +.. cfunction:: PyObject* PyUnicode_EncodeRawUnicodeEscape(const Py_UNICODE *s, Py_ssize_t size, const char *errors) - Encode the :c:type:`Py_UNICODE` buffer of the given *size* using Raw-Unicode-Escape + Encode the :ctype:`Py_UNICODE` buffer of the given *size* using Raw-Unicode-Escape and return a Python string object. Return *NULL* if an exception was raised by the codec. .. versionchanged:: 2.5 - This function used an :c:type:`int` type for *size*. This might require + This function used an :ctype:`int` type for *size*. This might require changes in your code for properly supporting 64-bit systems. -.. c:function:: PyObject* PyUnicode_AsRawUnicodeEscapeString(PyObject *unicode) +.. cfunction:: PyObject* PyUnicode_AsRawUnicodeEscapeString(PyObject *unicode) Encode a Unicode object using Raw-Unicode-Escape and return the result as Python string object. Error handling is "strict". Return *NULL* if an exception @@ -786,27 +779,27 @@ ordinals and only these are accepted by the codecs during encoding. -.. c:function:: PyObject* PyUnicode_DecodeLatin1(const char *s, Py_ssize_t size, const char *errors) +.. cfunction:: PyObject* PyUnicode_DecodeLatin1(const char *s, Py_ssize_t size, const char *errors) Create a Unicode object by decoding *size* bytes of the Latin-1 encoded string *s*. Return *NULL* if an exception was raised by the codec. .. versionchanged:: 2.5 - This function used an :c:type:`int` type for *size*. This might require + This function used an :ctype:`int` type for *size*. This might require changes in your code for properly supporting 64-bit systems. -.. c:function:: PyObject* PyUnicode_EncodeLatin1(const Py_UNICODE *s, Py_ssize_t size, const char *errors) +.. cfunction:: PyObject* PyUnicode_EncodeLatin1(const Py_UNICODE *s, Py_ssize_t size, const char *errors) - Encode the :c:type:`Py_UNICODE` buffer of the given *size* using Latin-1 and return + Encode the :ctype:`Py_UNICODE` buffer of the given *size* using Latin-1 and return a Python string object. Return *NULL* if an exception was raised by the codec. .. versionchanged:: 2.5 - This function used an :c:type:`int` type for *size*. This might require + This function used an :ctype:`int` type for *size*. This might require changes in your code for properly supporting 64-bit systems. -.. c:function:: PyObject* PyUnicode_AsLatin1String(PyObject *unicode) +.. cfunction:: PyObject* PyUnicode_AsLatin1String(PyObject *unicode) Encode a Unicode object using Latin-1 and return the result as Python string object. Error handling is "strict". Return *NULL* if an exception was raised @@ -820,27 +813,27 @@ codes generate errors. -.. c:function:: PyObject* PyUnicode_DecodeASCII(const char *s, Py_ssize_t size, const char *errors) +.. cfunction:: PyObject* PyUnicode_DecodeASCII(const char *s, Py_ssize_t size, const char *errors) Create a Unicode object by decoding *size* bytes of the ASCII encoded string *s*. Return *NULL* if an exception was raised by the codec. .. versionchanged:: 2.5 - This function used an :c:type:`int` type for *size*. This might require + This function used an :ctype:`int` type for *size*. This might require changes in your code for properly supporting 64-bit systems. -.. c:function:: PyObject* PyUnicode_EncodeASCII(const Py_UNICODE *s, Py_ssize_t size, const char *errors) +.. cfunction:: PyObject* PyUnicode_EncodeASCII(const Py_UNICODE *s, Py_ssize_t size, const char *errors) - Encode the :c:type:`Py_UNICODE` buffer of the given *size* using ASCII and return a + Encode the :ctype:`Py_UNICODE` buffer of the given *size* using ASCII and return a Python string object. Return *NULL* if an exception was raised by the codec. .. versionchanged:: 2.5 - This function used an :c:type:`int` type for *size*. This might require + This function used an :ctype:`int` type for *size*. This might require changes in your code for properly supporting 64-bit systems. -.. c:function:: PyObject* PyUnicode_AsASCIIString(PyObject *unicode) +.. cfunction:: PyObject* PyUnicode_AsASCIIString(PyObject *unicode) Encode a Unicode object using ASCII and return the result as Python string object. Error handling is "strict". Return *NULL* if an exception was raised @@ -873,7 +866,7 @@ These are the mapping codec APIs: -.. c:function:: PyObject* PyUnicode_DecodeCharmap(const char *s, Py_ssize_t size, PyObject *mapping, const char *errors) +.. cfunction:: PyObject* PyUnicode_DecodeCharmap(const char *s, Py_ssize_t size, PyObject *mapping, const char *errors) Create a Unicode object by decoding *size* bytes of the encoded string *s* using the given *mapping* object. Return *NULL* if an exception was raised by the @@ -886,22 +879,22 @@ Allowed unicode string as mapping argument. .. versionchanged:: 2.5 - This function used an :c:type:`int` type for *size*. This might require + This function used an :ctype:`int` type for *size*. This might require changes in your code for properly supporting 64-bit systems. -.. c:function:: PyObject* PyUnicode_EncodeCharmap(const Py_UNICODE *s, Py_ssize_t size, PyObject *mapping, const char *errors) +.. cfunction:: PyObject* PyUnicode_EncodeCharmap(const Py_UNICODE *s, Py_ssize_t size, PyObject *mapping, const char *errors) - Encode the :c:type:`Py_UNICODE` buffer of the given *size* using the given + Encode the :ctype:`Py_UNICODE` buffer of the given *size* using the given *mapping* object and return a Python string object. Return *NULL* if an exception was raised by the codec. .. versionchanged:: 2.5 - This function used an :c:type:`int` type for *size*. This might require + This function used an :ctype:`int` type for *size*. This might require changes in your code for properly supporting 64-bit systems. -.. c:function:: PyObject* PyUnicode_AsCharmapString(PyObject *unicode, PyObject *mapping) +.. cfunction:: PyObject* PyUnicode_AsCharmapString(PyObject *unicode, PyObject *mapping) Encode a Unicode object using the given *mapping* object and return the result as Python string object. Error handling is "strict". Return *NULL* if an @@ -910,9 +903,9 @@ The following codec API is special in that maps Unicode to Unicode. -.. c:function:: PyObject* PyUnicode_TranslateCharmap(const Py_UNICODE *s, Py_ssize_t size, PyObject *table, const char *errors) +.. cfunction:: PyObject* PyUnicode_TranslateCharmap(const Py_UNICODE *s, Py_ssize_t size, PyObject *table, const char *errors) - Translate a :c:type:`Py_UNICODE` buffer of the given *size* by applying a + Translate a :ctype:`Py_UNICODE` buffer of the given *size* by applying a character mapping *table* to it and return the resulting Unicode object. Return *NULL* when an exception was raised by the codec. @@ -924,7 +917,7 @@ :exc:`LookupError`) are left untouched and are copied as-is. .. versionchanged:: 2.5 - This function used an :c:type:`int` type for *size*. This might require + This function used an :ctype:`int` type for *size*. This might require changes in your code for properly supporting 64-bit systems. @@ -937,37 +930,37 @@ the user settings on the machine running the codec. -.. c:function:: PyObject* PyUnicode_DecodeMBCS(const char *s, Py_ssize_t size, const char *errors) +.. cfunction:: PyObject* PyUnicode_DecodeMBCS(const char *s, Py_ssize_t size, const char *errors) Create a Unicode object by decoding *size* bytes of the MBCS encoded string *s*. Return *NULL* if an exception was raised by the codec. .. versionchanged:: 2.5 - This function used an :c:type:`int` type for *size*. This might require + This function used an :ctype:`int` type for *size*. This might require changes in your code for properly supporting 64-bit systems. -.. c:function:: PyObject* PyUnicode_DecodeMBCSStateful(const char *s, int size, const char *errors, int *consumed) +.. cfunction:: PyObject* PyUnicode_DecodeMBCSStateful(const char *s, int size, const char *errors, int *consumed) - If *consumed* is *NULL*, behave like :c:func:`PyUnicode_DecodeMBCS`. If - *consumed* is not *NULL*, :c:func:`PyUnicode_DecodeMBCSStateful` will not decode + If *consumed* is *NULL*, behave like :cfunc:`PyUnicode_DecodeMBCS`. If + *consumed* is not *NULL*, :cfunc:`PyUnicode_DecodeMBCSStateful` will not decode trailing lead byte and the number of bytes that have been decoded will be stored in *consumed*. .. versionadded:: 2.5 -.. c:function:: PyObject* PyUnicode_EncodeMBCS(const Py_UNICODE *s, Py_ssize_t size, const char *errors) +.. cfunction:: PyObject* PyUnicode_EncodeMBCS(const Py_UNICODE *s, Py_ssize_t size, const char *errors) - Encode the :c:type:`Py_UNICODE` buffer of the given *size* using MBCS and return a + Encode the :ctype:`Py_UNICODE` buffer of the given *size* using MBCS and return a Python string object. Return *NULL* if an exception was raised by the codec. .. versionchanged:: 2.5 - This function used an :c:type:`int` type for *size*. This might require + This function used an :ctype:`int` type for *size*. This might require changes in your code for properly supporting 64-bit systems. -.. c:function:: PyObject* PyUnicode_AsMBCSString(PyObject *unicode) +.. cfunction:: PyObject* PyUnicode_AsMBCSString(PyObject *unicode) Encode a Unicode object using MBCS and return the result as Python string object. Error handling is "strict". Return *NULL* if an exception was raised @@ -989,12 +982,12 @@ They all return *NULL* or ``-1`` if an exception occurs. -.. c:function:: PyObject* PyUnicode_Concat(PyObject *left, PyObject *right) +.. cfunction:: PyObject* PyUnicode_Concat(PyObject *left, PyObject *right) Concat two strings giving a new Unicode string. -.. c:function:: PyObject* PyUnicode_Split(PyObject *s, PyObject *sep, Py_ssize_t maxsplit) +.. cfunction:: PyObject* PyUnicode_Split(PyObject *s, PyObject *sep, Py_ssize_t maxsplit) Split a string giving a list of Unicode strings. If *sep* is *NULL*, splitting will be done at all whitespace substrings. Otherwise, splits occur at the given @@ -1002,18 +995,18 @@ set. Separators are not included in the resulting list. .. versionchanged:: 2.5 - This function used an :c:type:`int` type for *maxsplit*. This might require + This function used an :ctype:`int` type for *maxsplit*. This might require changes in your code for properly supporting 64-bit systems. -.. c:function:: PyObject* PyUnicode_Splitlines(PyObject *s, int keepend) +.. cfunction:: PyObject* PyUnicode_Splitlines(PyObject *s, int keepend) Split a Unicode string at line breaks, returning a list of Unicode strings. CRLF is considered to be one line break. If *keepend* is 0, the Line break characters are not included in the resulting strings. -.. c:function:: PyObject* PyUnicode_Translate(PyObject *str, PyObject *table, const char *errors) +.. cfunction:: PyObject* PyUnicode_Translate(PyObject *str, PyObject *table, const char *errors) Translate a string by applying a character mapping table to it and return the resulting Unicode object. @@ -1029,25 +1022,25 @@ use the default error handling. -.. c:function:: PyObject* PyUnicode_Join(PyObject *separator, PyObject *seq) +.. cfunction:: PyObject* PyUnicode_Join(PyObject *separator, PyObject *seq) Join a sequence of strings using the given *separator* and return the resulting Unicode string. -.. c:function:: int PyUnicode_Tailmatch(PyObject *str, PyObject *substr, Py_ssize_t start, Py_ssize_t end, int direction) +.. cfunction:: int PyUnicode_Tailmatch(PyObject *str, PyObject *substr, Py_ssize_t start, Py_ssize_t end, int direction) Return 1 if *substr* matches ``str[start:end]`` at the given tail end (*direction* == -1 means to do a prefix match, *direction* == 1 a suffix match), 0 otherwise. Return ``-1`` if an error occurred. .. versionchanged:: 2.5 - This function used an :c:type:`int` type for *start* and *end*. This + This function used an :ctype:`int` type for *start* and *end*. This might require changes in your code for properly supporting 64-bit systems. -.. c:function:: Py_ssize_t PyUnicode_Find(PyObject *str, PyObject *substr, Py_ssize_t start, Py_ssize_t end, int direction) +.. cfunction:: Py_ssize_t PyUnicode_Find(PyObject *str, PyObject *substr, Py_ssize_t start, Py_ssize_t end, int direction) Return the first position of *substr* in ``str[start:end]`` using the given *direction* (*direction* == 1 means to do a forward search, *direction* == -1 a @@ -1056,40 +1049,40 @@ occurred and an exception has been set. .. versionchanged:: 2.5 - This function used an :c:type:`int` type for *start* and *end*. This + This function used an :ctype:`int` type for *start* and *end*. This might require changes in your code for properly supporting 64-bit systems. -.. c:function:: Py_ssize_t PyUnicode_Count(PyObject *str, PyObject *substr, Py_ssize_t start, Py_ssize_t end) +.. cfunction:: Py_ssize_t PyUnicode_Count(PyObject *str, PyObject *substr, Py_ssize_t start, Py_ssize_t end) Return the number of non-overlapping occurrences of *substr* in ``str[start:end]``. Return ``-1`` if an error occurred. .. versionchanged:: 2.5 - This function returned an :c:type:`int` type and used an :c:type:`int` + This function returned an :ctype:`int` type and used an :ctype:`int` type for *start* and *end*. This might require changes in your code for properly supporting 64-bit systems. -.. c:function:: PyObject* PyUnicode_Replace(PyObject *str, PyObject *substr, PyObject *replstr, Py_ssize_t maxcount) +.. cfunction:: PyObject* PyUnicode_Replace(PyObject *str, PyObject *substr, PyObject *replstr, Py_ssize_t maxcount) Replace at most *maxcount* occurrences of *substr* in *str* with *replstr* and return the resulting Unicode object. *maxcount* == -1 means replace all occurrences. .. versionchanged:: 2.5 - This function used an :c:type:`int` type for *maxcount*. This might + This function used an :ctype:`int` type for *maxcount*. This might require changes in your code for properly supporting 64-bit systems. -.. c:function:: int PyUnicode_Compare(PyObject *left, PyObject *right) +.. cfunction:: int PyUnicode_Compare(PyObject *left, PyObject *right) Compare two strings and return -1, 0, 1 for less than, equal, and greater than, respectively. -.. c:function:: int PyUnicode_RichCompare(PyObject *left, PyObject *right, int op) +.. cfunction:: int PyUnicode_RichCompare(PyObject *left, PyObject *right, int op) Rich compare two unicode strings and return one of the following: @@ -1105,13 +1098,13 @@ :const:`Py_NE`, :const:`Py_LT`, and :const:`Py_LE`. -.. c:function:: PyObject* PyUnicode_Format(PyObject *format, PyObject *args) +.. cfunction:: PyObject* PyUnicode_Format(PyObject *format, PyObject *args) Return a new string object from *format* and *args*; this is analogous to - ``format % args``. + ``format % args``. The *args* argument must be a tuple. -.. c:function:: int PyUnicode_Contains(PyObject *container, PyObject *element) +.. cfunction:: int PyUnicode_Contains(PyObject *container, PyObject *element) Check whether *element* is contained in *container* and return true or false accordingly. diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/c-api/veryhigh.rst --- a/Doc/c-api/veryhigh.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/c-api/veryhigh.rst Sun Jul 20 10:52:46 2014 -0400 @@ -16,20 +16,20 @@ :const:`Py_file_input`, and :const:`Py_single_input`. These are described following the functions which accept them as parameters. -Note also that several of these functions take :c:type:`FILE\*` parameters. One -particular issue which needs to be handled carefully is that the :c:type:`FILE` +Note also that several of these functions take :ctype:`FILE\*` parameters. One +particular issue which needs to be handled carefully is that the :ctype:`FILE` structure for different C libraries can be different and incompatible. Under Windows (at least), it is possible for dynamically linked extensions to actually -use different libraries, so care should be taken that :c:type:`FILE\*` parameters +use different libraries, so care should be taken that :ctype:`FILE\*` parameters are only passed to these functions if it is certain that they were created by the same library that the Python runtime is using. -.. c:function:: int Py_Main(int argc, char **argv) +.. cfunction:: int Py_Main(int argc, char **argv) The main program for the standard interpreter. This is made available for programs which embed Python. The *argc* and *argv* parameters should be - prepared exactly as those which are passed to a C program's :c:func:`main` + prepared exactly as those which are passed to a C program's :cfunc:`main` function. It is important to note that the argument list may be modified (but the contents of the strings pointed to by the argument list are not). The return value will be ``0`` if the interpreter exits normally (ie, without an @@ -41,40 +41,40 @@ ``Py_InspectFlag`` is not set. -.. c:function:: int PyRun_AnyFile(FILE *fp, const char *filename) +.. cfunction:: int PyRun_AnyFile(FILE *fp, const char *filename) - This is a simplified interface to :c:func:`PyRun_AnyFileExFlags` below, leaving + This is a simplified interface to :cfunc:`PyRun_AnyFileExFlags` below, leaving *closeit* set to ``0`` and *flags* set to *NULL*. -.. c:function:: int PyRun_AnyFileFlags(FILE *fp, const char *filename, PyCompilerFlags *flags) +.. cfunction:: int PyRun_AnyFileFlags(FILE *fp, const char *filename, PyCompilerFlags *flags) - This is a simplified interface to :c:func:`PyRun_AnyFileExFlags` below, leaving + This is a simplified interface to :cfunc:`PyRun_AnyFileExFlags` below, leaving the *closeit* argument set to ``0``. -.. c:function:: int PyRun_AnyFileEx(FILE *fp, const char *filename, int closeit) +.. cfunction:: int PyRun_AnyFileEx(FILE *fp, const char *filename, int closeit) - This is a simplified interface to :c:func:`PyRun_AnyFileExFlags` below, leaving + This is a simplified interface to :cfunc:`PyRun_AnyFileExFlags` below, leaving the *flags* argument set to *NULL*. -.. c:function:: int PyRun_AnyFileExFlags(FILE *fp, const char *filename, int closeit, PyCompilerFlags *flags) +.. cfunction:: int PyRun_AnyFileExFlags(FILE *fp, const char *filename, int closeit, PyCompilerFlags *flags) If *fp* refers to a file associated with an interactive device (console or terminal input or Unix pseudo-terminal), return the value of - :c:func:`PyRun_InteractiveLoop`, otherwise return the result of - :c:func:`PyRun_SimpleFile`. If *filename* is *NULL*, this function uses + :cfunc:`PyRun_InteractiveLoop`, otherwise return the result of + :cfunc:`PyRun_SimpleFile`. If *filename* is *NULL*, this function uses ``"???"`` as the filename. -.. c:function:: int PyRun_SimpleString(const char *command) +.. cfunction:: int PyRun_SimpleString(const char *command) - This is a simplified interface to :c:func:`PyRun_SimpleStringFlags` below, + This is a simplified interface to :cfunc:`PyRun_SimpleStringFlags` below, leaving the *PyCompilerFlags\** argument set to NULL. -.. c:function:: int PyRun_SimpleStringFlags(const char *command, PyCompilerFlags *flags) +.. cfunction:: int PyRun_SimpleStringFlags(const char *command, PyCompilerFlags *flags) Executes the Python source code from *command* in the :mod:`__main__` module according to the *flags* argument. If :mod:`__main__` does not already exist, it @@ -87,39 +87,39 @@ ``Py_InspectFlag`` is not set. -.. c:function:: int PyRun_SimpleFile(FILE *fp, const char *filename) +.. cfunction:: int PyRun_SimpleFile(FILE *fp, const char *filename) - This is a simplified interface to :c:func:`PyRun_SimpleFileExFlags` below, + This is a simplified interface to :cfunc:`PyRun_SimpleFileExFlags` below, leaving *closeit* set to ``0`` and *flags* set to *NULL*. -.. c:function:: int PyRun_SimpleFileFlags(FILE *fp, const char *filename, PyCompilerFlags *flags) +.. cfunction:: int PyRun_SimpleFileFlags(FILE *fp, const char *filename, PyCompilerFlags *flags) - This is a simplified interface to :c:func:`PyRun_SimpleFileExFlags` below, + This is a simplified interface to :cfunc:`PyRun_SimpleFileExFlags` below, leaving *closeit* set to ``0``. -.. c:function:: int PyRun_SimpleFileEx(FILE *fp, const char *filename, int closeit) +.. cfunction:: int PyRun_SimpleFileEx(FILE *fp, const char *filename, int closeit) - This is a simplified interface to :c:func:`PyRun_SimpleFileExFlags` below, + This is a simplified interface to :cfunc:`PyRun_SimpleFileExFlags` below, leaving *flags* set to *NULL*. -.. c:function:: int PyRun_SimpleFileExFlags(FILE *fp, const char *filename, int closeit, PyCompilerFlags *flags) +.. cfunction:: int PyRun_SimpleFileExFlags(FILE *fp, const char *filename, int closeit, PyCompilerFlags *flags) - Similar to :c:func:`PyRun_SimpleStringFlags`, but the Python source code is read + Similar to :cfunc:`PyRun_SimpleStringFlags`, but the Python source code is read from *fp* instead of an in-memory string. *filename* should be the name of the file. If *closeit* is true, the file is closed before PyRun_SimpleFileExFlags returns. -.. c:function:: int PyRun_InteractiveOne(FILE *fp, const char *filename) +.. cfunction:: int PyRun_InteractiveOne(FILE *fp, const char *filename) - This is a simplified interface to :c:func:`PyRun_InteractiveOneFlags` below, + This is a simplified interface to :cfunc:`PyRun_InteractiveOneFlags` below, leaving *flags* set to *NULL*. -.. c:function:: int PyRun_InteractiveOneFlags(FILE *fp, const char *filename, PyCompilerFlags *flags) +.. cfunction:: int PyRun_InteractiveOneFlags(FILE *fp, const char *filename, PyCompilerFlags *flags) Read and execute a single statement from a file associated with an interactive device according to the *flags* argument. The user will be @@ -130,34 +130,34 @@ :file:`Python.h`, so must be included specifically if needed.) -.. c:function:: int PyRun_InteractiveLoop(FILE *fp, const char *filename) +.. cfunction:: int PyRun_InteractiveLoop(FILE *fp, const char *filename) - This is a simplified interface to :c:func:`PyRun_InteractiveLoopFlags` below, + This is a simplified interface to :cfunc:`PyRun_InteractiveLoopFlags` below, leaving *flags* set to *NULL*. -.. c:function:: int PyRun_InteractiveLoopFlags(FILE *fp, const char *filename, PyCompilerFlags *flags) +.. cfunction:: int PyRun_InteractiveLoopFlags(FILE *fp, const char *filename, PyCompilerFlags *flags) Read and execute statements from a file associated with an interactive device until EOF is reached. The user will be prompted using ``sys.ps1`` and ``sys.ps2``. Returns ``0`` at EOF. -.. c:function:: struct _node* PyParser_SimpleParseString(const char *str, int start) +.. cfunction:: struct _node* PyParser_SimpleParseString(const char *str, int start) This is a simplified interface to - :c:func:`PyParser_SimpleParseStringFlagsFilename` below, leaving *filename* set + :cfunc:`PyParser_SimpleParseStringFlagsFilename` below, leaving *filename* set to *NULL* and *flags* set to ``0``. -.. c:function:: struct _node* PyParser_SimpleParseStringFlags( const char *str, int start, int flags) +.. cfunction:: struct _node* PyParser_SimpleParseStringFlags( const char *str, int start, int flags) This is a simplified interface to - :c:func:`PyParser_SimpleParseStringFlagsFilename` below, leaving *filename* set + :cfunc:`PyParser_SimpleParseStringFlagsFilename` below, leaving *filename* set to *NULL*. -.. c:function:: struct _node* PyParser_SimpleParseStringFlagsFilename( const char *str, const char *filename, int start, int flags) +.. cfunction:: struct _node* PyParser_SimpleParseStringFlagsFilename( const char *str, const char *filename, int start, int flags) Parse Python source code from *str* using the start token *start* according to the *flags* argument. The result can be used to create a code object which can @@ -165,25 +165,25 @@ many times. -.. c:function:: struct _node* PyParser_SimpleParseFile(FILE *fp, const char *filename, int start) +.. cfunction:: struct _node* PyParser_SimpleParseFile(FILE *fp, const char *filename, int start) - This is a simplified interface to :c:func:`PyParser_SimpleParseFileFlags` below, + This is a simplified interface to :cfunc:`PyParser_SimpleParseFileFlags` below, leaving *flags* set to ``0`` -.. c:function:: struct _node* PyParser_SimpleParseFileFlags(FILE *fp, const char *filename, int start, int flags) +.. cfunction:: struct _node* PyParser_SimpleParseFileFlags(FILE *fp, const char *filename, int start, int flags) - Similar to :c:func:`PyParser_SimpleParseStringFlagsFilename`, but the Python + Similar to :cfunc:`PyParser_SimpleParseStringFlagsFilename`, but the Python source code is read from *fp* instead of an in-memory string. -.. c:function:: PyObject* PyRun_String(const char *str, int start, PyObject *globals, PyObject *locals) +.. cfunction:: PyObject* PyRun_String(const char *str, int start, PyObject *globals, PyObject *locals) - This is a simplified interface to :c:func:`PyRun_StringFlags` below, leaving + This is a simplified interface to :cfunc:`PyRun_StringFlags` below, leaving *flags* set to *NULL*. -.. c:function:: PyObject* PyRun_StringFlags(const char *str, int start, PyObject *globals, PyObject *locals, PyCompilerFlags *flags) +.. cfunction:: PyObject* PyRun_StringFlags(const char *str, int start, PyObject *globals, PyObject *locals, PyCompilerFlags *flags) Execute Python source code from *str* in the context specified by the dictionaries *globals* and *locals* with the compiler flags specified by @@ -194,39 +194,39 @@ exception was raised. -.. c:function:: PyObject* PyRun_File(FILE *fp, const char *filename, int start, PyObject *globals, PyObject *locals) +.. cfunction:: PyObject* PyRun_File(FILE *fp, const char *filename, int start, PyObject *globals, PyObject *locals) - This is a simplified interface to :c:func:`PyRun_FileExFlags` below, leaving + This is a simplified interface to :cfunc:`PyRun_FileExFlags` below, leaving *closeit* set to ``0`` and *flags* set to *NULL*. -.. c:function:: PyObject* PyRun_FileEx(FILE *fp, const char *filename, int start, PyObject *globals, PyObject *locals, int closeit) +.. cfunction:: PyObject* PyRun_FileEx(FILE *fp, const char *filename, int start, PyObject *globals, PyObject *locals, int closeit) - This is a simplified interface to :c:func:`PyRun_FileExFlags` below, leaving + This is a simplified interface to :cfunc:`PyRun_FileExFlags` below, leaving *flags* set to *NULL*. -.. c:function:: PyObject* PyRun_FileFlags(FILE *fp, const char *filename, int start, PyObject *globals, PyObject *locals, PyCompilerFlags *flags) +.. cfunction:: PyObject* PyRun_FileFlags(FILE *fp, const char *filename, int start, PyObject *globals, PyObject *locals, PyCompilerFlags *flags) - This is a simplified interface to :c:func:`PyRun_FileExFlags` below, leaving + This is a simplified interface to :cfunc:`PyRun_FileExFlags` below, leaving *closeit* set to ``0``. -.. c:function:: PyObject* PyRun_FileExFlags(FILE *fp, const char *filename, int start, PyObject *globals, PyObject *locals, int closeit, PyCompilerFlags *flags) +.. cfunction:: PyObject* PyRun_FileExFlags(FILE *fp, const char *filename, int start, PyObject *globals, PyObject *locals, int closeit, PyCompilerFlags *flags) - Similar to :c:func:`PyRun_StringFlags`, but the Python source code is read from + Similar to :cfunc:`PyRun_StringFlags`, but the Python source code is read from *fp* instead of an in-memory string. *filename* should be the name of the file. - If *closeit* is true, the file is closed before :c:func:`PyRun_FileExFlags` + If *closeit* is true, the file is closed before :cfunc:`PyRun_FileExFlags` returns. -.. c:function:: PyObject* Py_CompileString(const char *str, const char *filename, int start) +.. cfunction:: PyObject* Py_CompileString(const char *str, const char *filename, int start) - This is a simplified interface to :c:func:`Py_CompileStringFlags` below, leaving + This is a simplified interface to :cfunc:`Py_CompileStringFlags` below, leaving *flags* set to *NULL*. -.. c:function:: PyObject* Py_CompileStringFlags(const char *str, const char *filename, int start, PyCompilerFlags *flags) +.. cfunction:: PyObject* Py_CompileStringFlags(const char *str, const char *filename, int start, PyCompilerFlags *flags) Parse and compile the Python source code in *str*, returning the resulting code object. The start token is given by *start*; this can be used to constrain the @@ -237,14 +237,14 @@ be parsed or compiled. -.. c:function:: PyObject* PyEval_EvalCode(PyCodeObject *co, PyObject *globals, PyObject *locals) +.. cfunction:: PyObject* PyEval_EvalCode(PyCodeObject *co, PyObject *globals, PyObject *locals) - This is a simplified interface to :c:func:`PyEval_EvalCodeEx`, with just + This is a simplified interface to :cfunc:`PyEval_EvalCodeEx`, with just the code object, and the dictionaries of global and local variables. The other arguments are set to *NULL*. -.. c:function:: PyObject* PyEval_EvalCodeEx(PyCodeObject *co, PyObject *globals, PyObject *locals, PyObject **args, int argcount, PyObject **kws, int kwcount, PyObject **defs, int defcount, PyObject *closure) +.. cfunction:: PyObject* PyEval_EvalCodeEx(PyCodeObject *co, PyObject *globals, PyObject *locals, PyObject **args, int argcount, PyObject **kws, int kwcount, PyObject **defs, int defcount, PyObject *closure) Evaluate a precompiled code object, given a particular environment for its evaluation. This environment consists of dictionaries of global and local @@ -252,55 +252,55 @@ cells. -.. c:function:: PyObject* PyEval_EvalFrame(PyFrameObject *f) +.. cfunction:: PyObject* PyEval_EvalFrame(PyFrameObject *f) Evaluate an execution frame. This is a simplified interface to PyEval_EvalFrameEx, for backward compatibility. -.. c:function:: PyObject* PyEval_EvalFrameEx(PyFrameObject *f, int throwflag) +.. cfunction:: PyObject* PyEval_EvalFrameEx(PyFrameObject *f, int throwflag) This is the main, unvarnished function of Python interpretation. It is literally 2000 lines long. The code object associated with the execution frame *f* is executed, interpreting bytecode and executing calls as needed. The additional *throwflag* parameter can mostly be ignored - if true, then it causes an exception to immediately be thrown; this is used for the - :meth:`~generator.throw` methods of generator objects. + :meth:`throw` methods of generator objects. -.. c:function:: int PyEval_MergeCompilerFlags(PyCompilerFlags *cf) +.. cfunction:: int PyEval_MergeCompilerFlags(PyCompilerFlags *cf) This function changes the flags of the current evaluation frame, and returns true on success, false on failure. -.. c:var:: int Py_eval_input +.. cvar:: int Py_eval_input .. index:: single: Py_CompileString() The start symbol from the Python grammar for isolated expressions; for use with - :c:func:`Py_CompileString`. + :cfunc:`Py_CompileString`. -.. c:var:: int Py_file_input +.. cvar:: int Py_file_input .. index:: single: Py_CompileString() The start symbol from the Python grammar for sequences of statements as read - from a file or other source; for use with :c:func:`Py_CompileString`. This is + from a file or other source; for use with :cfunc:`Py_CompileString`. This is the symbol to use when compiling arbitrarily long Python source code. -.. c:var:: int Py_single_input +.. cvar:: int Py_single_input .. index:: single: Py_CompileString() The start symbol from the Python grammar for a single statement; for use with - :c:func:`Py_CompileString`. This is the symbol used for the interactive + :cfunc:`Py_CompileString`. This is the symbol used for the interactive interpreter loop. -.. c:type:: struct PyCompilerFlags +.. ctype:: struct PyCompilerFlags This is the structure used to hold compiler flags. In cases where code is only being compiled, it is passed as ``int flags``, and in cases where code is being @@ -316,7 +316,7 @@ } -.. c:var:: int CO_FUTURE_DIVISION +.. cvar:: int CO_FUTURE_DIVISION This bit can be set in *flags* to cause division operator ``/`` to be interpreted as "true division" according to :pep:`238`. diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/c-api/weakref.rst --- a/Doc/c-api/weakref.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/c-api/weakref.rst Sun Jul 20 10:52:46 2014 -0400 @@ -11,28 +11,28 @@ as much as it can. -.. c:function:: int PyWeakref_Check(ob) +.. cfunction:: int PyWeakref_Check(ob) Return true if *ob* is either a reference or proxy object. .. versionadded:: 2.2 -.. c:function:: int PyWeakref_CheckRef(ob) +.. cfunction:: int PyWeakref_CheckRef(ob) Return true if *ob* is a reference object. .. versionadded:: 2.2 -.. c:function:: int PyWeakref_CheckProxy(ob) +.. cfunction:: int PyWeakref_CheckProxy(ob) Return true if *ob* is a proxy object. .. versionadded:: 2.2 -.. c:function:: PyObject* PyWeakref_NewRef(PyObject *ob, PyObject *callback) +.. cfunction:: PyObject* PyWeakref_NewRef(PyObject *ob, PyObject *callback) Return a weak reference object for the object *ob*. This will always return a new reference, but is not guaranteed to create a new object; an existing @@ -46,7 +46,7 @@ .. versionadded:: 2.2 -.. c:function:: PyObject* PyWeakref_NewProxy(PyObject *ob, PyObject *callback) +.. cfunction:: PyObject* PyWeakref_NewProxy(PyObject *ob, PyObject *callback) Return a weak reference proxy object for the object *ob*. This will always return a new reference, but is not guaranteed to create a new object; an @@ -60,7 +60,7 @@ .. versionadded:: 2.2 -.. c:function:: PyObject* PyWeakref_GetObject(PyObject *ref) +.. cfunction:: PyObject* PyWeakref_GetObject(PyObject *ref) Return the referenced object from a weak reference, *ref*. If the referent is no longer live, returns :const:`Py_None`. @@ -70,14 +70,14 @@ .. warning:: This function returns a **borrowed reference** to the referenced object. - This means that you should always call :c:func:`Py_INCREF` on the object + This means that you should always call :cfunc:`Py_INCREF` on the object except if you know that it cannot be destroyed while you are still using it. -.. c:function:: PyObject* PyWeakref_GET_OBJECT(PyObject *ref) +.. cfunction:: PyObject* PyWeakref_GET_OBJECT(PyObject *ref) - Similar to :c:func:`PyWeakref_GetObject`, but implemented as a macro that does no + Similar to :cfunc:`PyWeakref_GetObject`, but implemented as a macro that does no error checking. .. versionadded:: 2.2 diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/conf.py --- a/Doc/conf.py Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/conf.py Sun Jul 20 10:52:46 2014 -0400 @@ -63,9 +63,6 @@ # Options for HTML output # ----------------------- -html_theme = 'default' -html_theme_options = {'collapsiblesidebar': True} - # If not '', a 'Last updated on:' timestamp is inserted at every page bottom, # using the given strftime format. html_last_updated_fmt = '%b %d, %Y' @@ -86,7 +83,7 @@ } # Output an OpenSearch description file. -html_use_opensearch = 'http://docs.python.org/' +html_use_opensearch = 'http://docs.python.org/dev' # Additional static files. html_static_path = ['tools/sphinxext/static'] @@ -115,6 +112,8 @@ 'The Python/C API', _stdauthor, 'manual'), ('distutils/index', 'distutils.tex', 'Distributing Python Modules', _stdauthor, 'manual'), + ('documenting/index', 'documenting.tex', + 'Documenting Python', 'Georg Brandl', 'manual'), ('extending/index', 'extending.tex', 'Extending and Embedding Python', _stdauthor, 'manual'), ('install/index', 'install.tex', @@ -152,7 +151,7 @@ latex_appendices = ['glossary', 'about', 'license', 'copyright'] # Get LaTeX to handle Unicode correctly -latex_elements = {'inputenc': r'\usepackage[utf8x]{inputenc}', 'utf8extra': ''} +latex_elements = {'inputenc': r'\usepackage[utf8x]{inputenc}'} # Options for the coverage checker # -------------------------------- diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/contents.rst --- a/Doc/contents.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/contents.rst Sun Jul 20 10:52:46 2014 -0400 @@ -13,6 +13,7 @@ c-api/index.rst distutils/index.rst install/index.rst + documenting/index.rst howto/index.rst faq/index.rst glossary.rst diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/copyright.rst --- a/Doc/copyright.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/copyright.rst Sun Jul 20 10:52:46 2014 -0400 @@ -4,7 +4,7 @@ Python and this documentation is: -Copyright © 2001-2014 Python Software Foundation. All rights reserved. +Copyright © 2001-2010 Python Software Foundation. All rights reserved. Copyright © 2000 BeOpen.com. All rights reserved. diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/data/refcounts.dat --- a/Doc/data/refcounts.dat Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/data/refcounts.dat Sun Jul 20 10:52:46 2014 -0400 @@ -932,7 +932,7 @@ PyObject_CallMethodObjArgs:PyObject*::+1: PyObject_CallMethodObjArgs:PyObject*:o:0: -PyObject_CallMethodObjArgs:PyObject*:name:0: +PyObject_CallMethodObjArgs:char*:name:: PyObject_CallMethodObjArgs::...:: PyObject_CallObject:PyObject*::+1: diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/distutils/apiref.rst --- a/Doc/distutils/apiref.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/distutils/apiref.rst Sun Jul 20 10:52:46 2014 -0400 @@ -26,8 +26,6 @@ The setup function takes a large number of arguments. These are laid out in the following table. - .. tabularcolumns:: |l|L|L| - +--------------------+--------------------------------+-------------------------------------------------------------+ | argument name | value | type | +====================+================================+=============================================================+ @@ -50,10 +48,7 @@ +--------------------+--------------------------------+-------------------------------------------------------------+ | *maintainer* | The name of the current | a string | | | maintainer, if different from | | - | | the author. Note that if | | - | | the maintainer is provided, | | - | | distutils will use it as the | | - | | author in :file:`PKG-INFO` | | + | | the author | | +--------------------+--------------------------------+-------------------------------------------------------------+ | *maintainer_email* | The email address of the | a string | | | current maintainer, if | | @@ -127,8 +122,6 @@ *stop_after* tells :func:`setup` when to stop processing; possible values: - .. tabularcolumns:: |l|L| - +---------------+---------------------------------------------+ | value | description | +===============+=============================================+ @@ -169,8 +162,6 @@ The Extension class describes a single C or C++extension module in a setup script. It accepts the following keyword arguments in its constructor - .. tabularcolumns:: |l|L|l| - +------------------------+--------------------------------+---------------------------+ | argument name | value | type | +========================+================================+===========================+ @@ -270,6 +261,11 @@ | | from the source extensions if | | | | not provided. | | +------------------------+--------------------------------+---------------------------+ + | *optional* | specifies that a build failure | a boolean | + | | in the extension should not | | + | | abort the build process, but | | + | | simply skip the extension. | | + +------------------------+--------------------------------+---------------------------+ .. class:: Distribution @@ -453,9 +449,7 @@ Define a preprocessor macro for all compilations driven by this compiler object. The optional parameter *value* should be a string; if it is not supplied, then the macro will be defined without an explicit value and the exact outcome - depends on the compiler used. - - .. XXX true? does ANSI say anything about this? + depends on the compiler used (XXX true? does ANSI say anything about this?) .. method:: CCompiler.undefine_macro(name) @@ -609,9 +603,7 @@ *output_libname* should be a library name, not a filename; the filename will be inferred from the library name. *output_dir* is the directory where the library - file will be put. - - .. XXX defaults to what? + file will be put. XXX defaults to what? *debug* is a boolean; if true, debugging information will be included in the library (note that on most platforms, it is the compile step where this matters: @@ -729,31 +721,32 @@ .. method:: CCompiler.execute(func, args[, msg=None, level=1]) - Invokes :func:`distutils.util.execute`. This method invokes a Python function + Invokes :func:`distutils.util.execute` This method invokes a Python function *func* with the given arguments *args*, after logging and taking into account - the *dry_run* flag. + the *dry_run* flag. XXX see also. .. method:: CCompiler.spawn(cmd) Invokes :func:`distutils.util.spawn`. This invokes an external process to run - the given command. + the given command. XXX see also. .. method:: CCompiler.mkpath(name[, mode=511]) Invokes :func:`distutils.dir_util.mkpath`. This creates a directory and any - missing ancestor directories. + missing ancestor directories. XXX see also. .. method:: CCompiler.move_file(src, dst) - Invokes :meth:`distutils.file_util.move_file`. Renames *src* to *dst*. + Invokes :meth:`distutils.file_util.move_file`. Renames *src* to *dst*. XXX see + also. .. method:: CCompiler.announce(msg[, level=1]) - Write a message using :func:`distutils.log.debug`. + Write a message using :func:`distutils.log.debug`. XXX see also. .. method:: CCompiler.warn(msg) @@ -881,6 +874,8 @@ prefix of all files and directories in the archive. *root_dir* and *base_dir* both default to the current directory. Returns the name of the archive file. + .. XXX This should be changed to support bz2 files. + .. function:: make_tarball(base_name, base_dir[, compress='gzip', verbose=0, dry_run=0]) @@ -892,6 +887,8 @@ possibly plus the appropriate compression extension (:file:`.gz`, :file:`.bz2` or :file:`.Z`). Return the output filename. + .. XXX This should be replaced with calls to the :mod:`tarfile` module. + .. function:: make_zipfile(base_name, base_dir[, verbose=0, dry_run=0]) @@ -982,28 +979,20 @@ Copy an entire directory tree *src* to a new location *dst*. Both *src* and *dst* must be directory names. If *src* is not a directory, raise :exc:`DistutilsFileError`. If *dst* does not exist, it is created with - :func:`mkpath`. The end result of the copy is that every file in *src* is - copied to *dst*, and directories under *src* are recursively copied to *dst*. + :func:`mkpath`. The end result of the copy is that every file in *src* is + copied to *dst*, and directories under *src* are recursively copied to *dst*. Return the list of files that were copied or might have been copied, using their output name. The return value is unaffected by *update* or *dry_run*: it is simply the list of all files under *src*, with the names changed to be under *dst*. - *preserve_mode* and *preserve_times* are the same as for - :func:`distutils.file_util.copy_file`; note that they only apply to - regular files, not to + *preserve_mode* and *preserve_times* are the same as for :func:`copy_file` in + :mod:`distutils.file_util`; note that they only apply to regular files, not to directories. If *preserve_symlinks* is true, symlinks will be copied as symlinks (on platforms that support them!); otherwise (the default), the destination of the symlink will be copied. *update* and *verbose* are the same as for :func:`copy_file`. - Files in *src* that begin with :file:`.nfs` are skipped (more information on - these files is available in answer D2 of the `NFS FAQ page - `_. - - .. versionchanged:: 2.7.4 - NFS files are ignored. - .. function:: remove_tree(directory[, verbose=0, dry_run=0]) @@ -1011,6 +1000,8 @@ errors are ignored (apart from being reported to ``sys.stdout`` if *verbose* is true). +.. XXX Some of this could be replaced with the shutil module? + :mod:`distutils.file_util` --- Single file operations ===================================================== @@ -1124,6 +1115,8 @@ * ``macosx-10.6-intel`` + .. % XXX isn't this also provided by some other non-distutils module? + .. function:: convert_path(pathname) @@ -1167,6 +1160,15 @@ underscore. No { } or ( ) style quoting is available. +.. function:: grok_environment_error(exc[, prefix='error: ']) + + Generate a useful error message from an :exc:`EnvironmentError` (:exc:`IOError` + or :exc:`OSError`) exception object. Handles Python 1.5.1 and later styles, + and does what it can to deal with exception objects that don't have a filename + (which happens when the error is due to a two-file operation, such as + :func:`rename` or :func:`link`). Returns the error message as a string + prefixed with *prefix*. + .. function:: split_quoted(s) @@ -1249,8 +1251,8 @@ built/installed/distributed -This module provides the :class:`~distutils.core.Distribution` class, which -represents the module distribution being built/installed/distributed. +This module provides the :class:`Distribution` class, which represents the +module distribution being built/installed/distributed. :mod:`distutils.extension` --- The Extension class @@ -1314,6 +1316,8 @@ the "negative alias" of :option:`--verbose`, then :option:`--quiet` on the command line sets *verbose* to false. +.. XXX Should be replaced with :mod:`optparse`. + .. function:: fancy_getopt(options, negative_opt, object, args) @@ -1330,6 +1334,8 @@ Wraps *text* to less than *width* wide. + .. XXX Should be replaced with :mod:`textwrap` (which is available in Python + 2.3 and later). .. class:: FancyGetopt([option_table=None]) @@ -1393,6 +1399,10 @@ :synopsis: A simple logging mechanism, 282-style +.. XXX Should be replaced with standard :mod:`logging` module. + + + :mod:`distutils.spawn` --- Spawn a sub-process ============================================== @@ -1554,8 +1564,6 @@ The options are all boolean, and affect the values returned by :meth:`readline` - .. tabularcolumns:: |l|L|l| - +------------------+--------------------------------+---------+ | option name | description | default | +==================+================================+=========+ @@ -1698,8 +1706,8 @@ options, is the :meth:`run` method, which must also be implemented by every command class. - The class constructor takes a single argument *dist*, a - :class:`~distutils.core.Distribution` instance. + The class constructor takes a single argument *dist*, a :class:`Distribution` + instance. Creating a new Distutils command @@ -1891,6 +1899,9 @@ :synopsis: Build the .py/.pyc files of a package +.. % todo + + :mod:`distutils.command.build_scripts` --- Build the scripts of a package ========================================================================= @@ -1907,12 +1918,8 @@ .. module:: distutils.command.clean :synopsis: Clean a package build area -This command removes the temporary files created by :command:`build` -and its subcommands, like intermediary compiled object files. With -the ``--all`` option, the complete build directory will be removed. - -Extension modules built :ref:`in place ` -will not be cleaned, as they are not in the build directory. + +.. % todo :mod:`distutils.command.config` --- Perform package configuration diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/distutils/builtdist.rst --- a/Doc/distutils/builtdist.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/distutils/builtdist.rst Sun Jul 20 10:52:46 2014 -0400 @@ -426,7 +426,7 @@ Which folders are available depends on the exact Windows version, and probably also the configuration. For details refer to Microsoft's documentation of the - :c:func:`SHGetSpecialFolderPath` function. + :cfunc:`SHGetSpecialFolderPath` function. .. function:: create_shortcut(target, description, filename[, arguments[, workdir[, iconpath[, iconindex]]]]) diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/distutils/configfile.rst --- a/Doc/distutils/configfile.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/distutils/configfile.rst Sun Jul 20 10:52:46 2014 -0400 @@ -69,8 +69,6 @@ Note that an option spelled :option:`--foo-bar` on the command-line is spelled :option:`foo_bar` in configuration files. -.. _distutils-build-ext-inplace: - For example, say you want your extensions to be built "in-place"---that is, you have an extension :mod:`pkg.ext`, and you want the compiled extension file (:file:`ext.so` on Unix, say) to be put in the same source directory as your diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/distutils/examples.rst --- a/Doc/distutils/examples.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/distutils/examples.rst Sun Jul 20 10:52:46 2014 -0400 @@ -193,6 +193,9 @@ packages=['foobar', 'foobar.subfoo'], ) +(Again, the empty string in :option:`package_dir` stands for the current +directory.) + .. _single-ext: diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/distutils/index.rst --- a/Doc/distutils/index.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/distutils/index.rst Sun Jul 20 10:52:46 2014 -0400 @@ -6,22 +6,14 @@ :Authors: Greg Ward, Anthony Baxter :Email: distutils-sig@python.org +:Release: |version| +:Date: |today| This document describes the Python Distribution Utilities ("Distutils") from the module developer's point of view, describing how to use the Distutils to make Python modules and extensions easily available to a wider audience with very little overhead for build/release/install mechanics. -.. note:: - - This guide only covers the basic tools for building and distributing - extensions that are provided as part of this version of Python. Third - party tools offer easier to use and more secure alternatives. Refer to the - `quick recommendations section - `__ - in the Python Packaging User Guide for more information. - - .. toctree:: :maxdepth: 2 :numbered: @@ -32,6 +24,7 @@ sourcedist.rst builtdist.rst packageindex.rst + uploading.rst examples.rst extending.rst commandref.rst diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/distutils/packageindex.rst --- a/Doc/distutils/packageindex.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/distutils/packageindex.rst Sun Jul 20 10:52:46 2014 -0400 @@ -1,33 +1,12 @@ -.. index:: - single: Python Package Index (PyPI) - single: PyPI; (see Python Package Index (PyPI)) - .. _package-index: -******************************* -The Python Package Index (PyPI) -******************************* +********************************** +Registering with the Package Index +********************************** -The `Python Package Index (PyPI)`_ holds :ref:`meta-data ` -describing distributions packaged with distutils, as well as package data like -distribution files if the package author wishes. - -Distutils exposes two commands for submitting package data to PyPI: the -:ref:`register ` command for submitting meta-data to PyPI -and the :ref:`upload ` command for submitting distribution -files. Both commands read configuration data from a special file called the -:ref:`.pypirc file `. PyPI :ref:`displays a home page -` for each package created from the ``long_description`` -submitted by the :command:`register` command. - - -.. _package-register: - -Registering Packages -==================== - -The distutils command :command:`register` is used to submit your distribution's -meta-data to the index. It is invoked as follows:: +The Python Package Index (PyPI) holds meta-data describing distributions +packaged with distutils. The distutils command :command:`register` is used to +submit your distribution's meta-data to the index. It is invoked as follows:: python setup.py register @@ -64,59 +43,11 @@ Maintainers may edit the package information, but not designate other Owners or Maintainers. -By default PyPI displays only the newest version of a given package. The web -interface lets one change this default behavior and manually select which -versions to display and hide. +By default PyPI will list all versions of a given package. To hide certain +versions, the Hidden property should be set to yes. This must be edited through +the web interface. -.. _package-upload: - -Uploading Packages -================== - -.. versionadded:: 2.5 - -The distutils command :command:`upload` pushes the distribution files to PyPI. - -The command is invoked immediately after building one or more distribution -files. For example, the command :: - - python setup.py sdist bdist_wininst upload - -will cause the source distribution and the Windows installer to be uploaded to -PyPI. Note that these will be uploaded even if they are built using an earlier -invocation of :file:`setup.py`, but that only distributions named on the command -line for the invocation including the :command:`upload` command are uploaded. - -The :command:`upload` command uses the username, password, and repository URL -from the :file:`$HOME/.pypirc` file (see section :ref:`pypirc` for more on this -file). If a :command:`register` command was previously called in the same command, -and if the password was entered in the prompt, :command:`upload` will reuse the -entered password. This is useful if you do not want to store a clear text -password in the :file:`$HOME/.pypirc` file. - -You can specify another PyPI server with the ``--repository=url`` option:: - - python setup.py sdist bdist_wininst upload -r http://example.com/pypi - -See section :ref:`pypirc` for more on defining several servers. - -You can use the ``--sign`` option to tell :command:`upload` to sign each -uploaded file using GPG (GNU Privacy Guard). The :program:`gpg` program must -be available for execution on the system :envvar:`PATH`. You can also specify -which key to use for signing using the ``--identity=name`` option. - -Other :command:`upload` options include ``--repository=url`` or -``--repository=section`` where *url* is the url of the server and -*section* the name of the section in :file:`$HOME/.pypirc`, and -``--show-response`` (which displays the full response text from the PyPI -server for help in debugging upload problems). - - -.. index:: - single: .pypirc file - single: Python Package Index (PyPI); .pypirc file - .. _pypirc: The .pypirc file @@ -171,45 +102,3 @@ may also be used:: python setup.py register -r other - - -.. _package-display: - -PyPI package display -==================== - -The ``long_description`` field plays a special role at PyPI. It is used by -the server to display a home page for the registered package. - -If you use the `reStructuredText `_ -syntax for this field, PyPI will parse it and display an HTML output for -the package home page. - -The ``long_description`` field can be attached to a text file located -in the package:: - - from distutils.core import setup - - with open('README.txt') as file: - long_description = file.read() - - setup(name='Distutils', - long_description=long_description) - -In that case, :file:`README.txt` is a regular reStructuredText text file located -in the root of the package besides :file:`setup.py`. - -To prevent registering broken reStructuredText content, you can use the -:program:`rst2html` program that is provided by the :mod:`docutils` package and -check the ``long_description`` from the command line:: - - $ python setup.py --long-description | rst2html.py > output.html - -:mod:`docutils` will display a warning if there's something wrong with your -syntax. Because PyPI applies additional checks (e.g. by passing ``--no-raw`` -to ``rst2html.py`` in the command above), being able to run the command above -without warnings does not guarantee that PyPI will convert the content -successfully. - - -.. _Python Package Index (PyPI): http://pypi.python.org/ diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/distutils/setupscript.rst --- a/Doc/distutils/setupscript.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/distutils/setupscript.rst Sun Jul 20 10:52:46 2014 -0400 @@ -139,8 +139,7 @@ All of this is done through another keyword argument to :func:`setup`, the :option:`ext_modules` option. :option:`ext_modules` is just a list of -:class:`~distutils.core.Extension` instances, each of which describes a -single extension module. +:class:`Extension` instances, each of which describes a single extension module. Suppose your distribution includes a single extension, called :mod:`foo` and implemented by :file:`foo.c`. If no additional instructions to the compiler/linker are needed, describing this extension is quite simple:: @@ -166,8 +165,8 @@ Extension names and packages ---------------------------- -The first argument to the :class:`~distutils.core.Extension` constructor is -always the name of the extension, including any package names. For example, :: +The first argument to the :class:`Extension` constructor is always the name of +the extension, including any package names. For example, :: Extension('foo', ['src/foo1.c', 'src/foo2.c']) @@ -197,8 +196,7 @@ Extension source files ---------------------- -The second argument to the :class:`~distutils.core.Extension` constructor is -a list of source +The second argument to the :class:`Extension` constructor is a list of source files. Since the Distutils currently only support C, C++, and Objective-C extensions, these are normally C/C++/Objective-C source files. (Be sure to use appropriate extensions to distinguish C++\ source files: :file:`.cc` and @@ -234,9 +232,9 @@ Preprocessor options -------------------- -Three optional arguments to :class:`~distutils.core.Extension` will help if -you need to specify include directories to search or preprocessor macros to -define/undefine: ``include_dirs``, ``define_macros``, and ``undef_macros``. +Three optional arguments to :class:`Extension` will help if you need to specify +include directories to search or preprocessor macros to define/undefine: +``include_dirs``, ``define_macros``, and ``undef_macros``. For example, if your extension requires header files in the :file:`include` directory under your distribution root, use the ``include_dirs`` option:: @@ -336,6 +334,10 @@ There are still some other options which can be used to handle special cases. +The :option:`optional` option is a boolean; if it is true, +a build failure in the extension will not abort the build process, but +instead simply not install the failing extension. + The :option:`extra_objects` option is a list of object files to be passed to the linker. These files must not have extensions, as the default extension for the compiler is used. @@ -600,8 +602,7 @@ It is recommended that versions take the form *major.minor[.patch[.sub]]*. (3) - Either the author or the maintainer must be identified. If maintainer is - provided, distutils lists it as the author in :file:`PKG-INFO`. + Either the author or the maintainer must be identified. (4) These fields should not be used if your package is to be compatible with Python @@ -609,9 +610,8 @@ `_. (5) - The ``long_description`` field is used by PyPI when you are - :ref:`registering ` a package, to - :ref:`build its home page `. + The ``long_description`` field is used by PyPI when you are registering a + package, to build its home page. (6) The ``license`` field is a text indicating the license covering the @@ -684,8 +684,6 @@ DistributionMetadata.download_url = None -.. _debug-setup-script: - Debugging the setup script ========================== @@ -701,8 +699,7 @@ and see that it's a permission problem. On the other hand, this doesn't help the developer to find the cause of the -failure. For this purpose, the :envvar:`DISTUTILS_DEBUG` environment variable can be set +failure. For this purpose, the DISTUTILS_DEBUG environment variable can be set to anything except an empty string, and distutils will now print detailed -information about what it is doing, dump the full traceback when an exception -occurs, and print the whole command line when an external program (like a C -compiler) fails. +information what it is doing, and prints the full traceback in case an exception +occurs. diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/distutils/sourcedist.rst --- a/Doc/distutils/sourcedist.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/distutils/sourcedist.rst Sun Jul 20 10:52:46 2014 -0400 @@ -51,7 +51,8 @@ of the standard Python library since Python 1.6) (4) - requires the :program:`compress` program. + requires the :program:`compress` program. Notice that this format is now + pending for deprecation and will be removed in the future versions of Python. When using any ``tar`` format (``gztar``, ``bztar``, ``ztar`` or ``tar``) under Unix, you can specify the ``owner`` and ``group`` names diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/distutils/uploading.rst --- a/Doc/distutils/uploading.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/distutils/uploading.rst Sun Jul 20 10:52:46 2014 -0400 @@ -1,7 +1,77 @@ -:orphan: +.. _package-upload: *************************************** Uploading Packages to the Package Index *************************************** -The contents of this page have moved to the section :ref:`package-index`. +.. versionadded:: 2.5 + +The Python Package Index (PyPI) not only stores the package info, but also the +package data if the author of the package wishes to. The distutils command +:command:`upload` pushes the distribution files to PyPI. + +The command is invoked immediately after building one or more distribution +files. For example, the command :: + + python setup.py sdist bdist_wininst upload + +will cause the source distribution and the Windows installer to be uploaded to +PyPI. Note that these will be uploaded even if they are built using an earlier +invocation of :file:`setup.py`, but that only distributions named on the command +line for the invocation including the :command:`upload` command are uploaded. + +The :command:`upload` command uses the username, password, and repository URL +from the :file:`$HOME/.pypirc` file (see section :ref:`pypirc` for more on this +file). If a :command:`register` command was previously called in the same command, +and if the password was entered in the prompt, :command:`upload` will reuse the +entered password. This is useful if you do not want to store a clear text +password in the :file:`$HOME/.pypirc` file. + +You can specify another PyPI server with the :option:`--repository=*url*` option:: + + python setup.py sdist bdist_wininst upload -r http://example.com/pypi + +See section :ref:`pypirc` for more on defining several servers. + +You can use the :option:`--sign` option to tell :command:`upload` to sign each +uploaded file using GPG (GNU Privacy Guard). The :program:`gpg` program must +be available for execution on the system :envvar:`PATH`. You can also specify +which key to use for signing using the :option:`--identity=*name*` option. + +Other :command:`upload` options include :option:`--repository=` or +:option:`--repository=
` where *url* is the url of the server and +*section* the name of the section in :file:`$HOME/.pypirc`, and +:option:`--show-response` (which displays the full response text from the PyPI +server for help in debugging upload problems). + +PyPI package display +==================== + +The ``long_description`` field plays a special role at PyPI. It is used by +the server to display a home page for the registered package. + +If you use the `reStructuredText `_ +syntax for this field, PyPI will parse it and display an HTML output for +the package home page. + +The ``long_description`` field can be attached to a text file located +in the package:: + + from distutils.core import setup + + with open('README.txt') as file: + long_description = file.read() + + setup(name='Distutils', + long_description=long_description) + +In that case, :file:`README.txt` is a regular reStructuredText text file located +in the root of the package besides :file:`setup.py`. + +To prevent registering broken reStructuredText content, you can use the +:program:`rst2html` program that is provided by the :mod:`docutils` package +and check the ``long_description`` from the command line:: + + $ python setup.py --long-description | rst2html.py > output.html + +:mod:`docutils` will display a warning if there's something wrong with your syntax. diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/documenting/building.rst --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Doc/documenting/building.rst Sun Jul 20 10:52:46 2014 -0400 @@ -0,0 +1,92 @@ +Building the documentation +========================== + +You need to have Python 2.4 or higher installed; the toolset used to build the +docs is written in Python. It is called *Sphinx*, it is not included in this +tree, but maintained separately. Also needed are the docutils, supplying the +base markup that Sphinx uses, Jinja, a templating engine, and optionally +Pygments, a code highlighter. + + +Using make +---------- + +Luckily, a Makefile has been prepared so that on Unix, provided you have +installed Python and Subversion, you can just run :: + + cd Doc + make html + +to check out the necessary toolset in the :file:`tools/` subdirectory and build +the HTML output files. To view the generated HTML, point your favorite browser +at the top-level index :file:`build/html/index.html` after running "make". + +Available make targets are: + + * "html", which builds standalone HTML files for offline viewing. + + * "htmlhelp", which builds HTML files and a HTML Help project file usable to + convert them into a single Compiled HTML (.chm) file -- these are popular + under Microsoft Windows, but very handy on every platform. + + To create the CHM file, you need to run the Microsoft HTML Help Workshop + over the generated project (.hhp) file. + + * "latex", which builds LaTeX source files as input to "pdflatex" to produce + PDF documents. + + * "text", which builds a plain text file for each source file. + + * "linkcheck", which checks all external references to see whether they are + broken, redirected or malformed, and outputs this information to stdout + as well as a plain-text (.txt) file. + + * "changes", which builds an overview over all versionadded/versionchanged/ + deprecated items in the current version. This is meant as a help for the + writer of the "What's New" document. + + * "coverage", which builds a coverage overview for standard library modules + and C API. + + * "pydoc-topics", which builds a Python module containing a dictionary with + plain text documentation for the labels defined in + :file:`tools/sphinxext/pyspecific.py` -- pydoc needs these to show topic and + keyword help. + +A "make update" updates the Subversion checkouts in :file:`tools/`. + + +Without make +------------ + +You'll need to install the Sphinx package, either by checking it out via :: + + svn co http://svn.python.org/projects/external/Sphinx-0.6.5/sphinx tools/sphinx + +or by installing it from PyPI. + +Then, you need to install Docutils, either by checking it out via :: + + svn co http://svn.python.org/projects/external/docutils-0.6/docutils tools/docutils + +or by installing it from http://docutils.sf.net/. + +You also need Jinja2, either by checking it out via :: + + svn co http://svn.python.org/projects/external/Jinja-2.3.1/jinja2 tools/jinja2 + +or by installing it from PyPI. + +You can optionally also install Pygments, either as a checkout via :: + + svn co http://svn.python.org/projects/external/Pygments-1.3.1/pygments tools/pygments + +or from PyPI at http://pypi.python.org/pypi/Pygments. + + +Then, make an output directory, e.g. under `build/`, and run :: + + python tools/sphinx-build.py -b . build/ + +where `` is one of html, text, latex, or htmlhelp (for explanations see +the make targets above). diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/documenting/fromlatex.rst --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Doc/documenting/fromlatex.rst Sun Jul 20 10:52:46 2014 -0400 @@ -0,0 +1,202 @@ +.. highlightlang:: rest + +Differences to the LaTeX markup +=============================== + +Though the markup language is different, most of the concepts and markup types +of the old LaTeX docs have been kept -- environments as reST directives, inline +commands as reST roles and so forth. + +However, there are some differences in the way these work, partly due to the +differences in the markup languages, partly due to improvements in Sphinx. This +section lists these differences, in order to give those familiar with the old +format a quick overview of what they might run into. + +Inline markup +------------- + +These changes have been made to inline markup: + +* **Cross-reference roles** + + Most of the following semantic roles existed previously as inline commands, + but didn't do anything except formatting the content as code. Now, they + cross-reference to known targets (some names have also been shortened): + + | *mod* (previously *refmodule* or *module*) + | *func* (previously *function*) + | *data* (new) + | *const* + | *class* + | *meth* (previously *method*) + | *attr* (previously *member*) + | *exc* (previously *exception*) + | *cdata* + | *cfunc* (previously *cfunction*) + | *cmacro* (previously *csimplemacro*) + | *ctype* + + Also different is the handling of *func* and *meth*: while previously + parentheses were added to the callable name (like ``\func{str()}``), they are + now appended by the build system -- appending them in the source will result + in double parentheses. This also means that ``:func:`str(object)``` will not + work as expected -- use ````str(object)```` instead! + +* **Inline commands implemented as directives** + + These were inline commands in LaTeX, but are now directives in reST: + + | *deprecated* + | *versionadded* + | *versionchanged* + + These are used like so:: + + .. deprecated:: 2.5 + Reason of deprecation. + + Also, no period is appended to the text for *versionadded* and + *versionchanged*. + + | *note* + | *warning* + + These are used like so:: + + .. note:: + + Content of note. + +* **Otherwise changed commands** + + The *samp* command previously formatted code and added quotation marks around + it. The *samp* role, however, features a new highlighting system just like + *file* does: + + ``:samp:`open({filename}, {mode})``` results in :samp:`open({filename}, {mode})` + +* **Dropped commands** + + These were commands in LaTeX, but are not available as roles: + + | *bfcode* + | *character* (use :samp:`\`\`'c'\`\``) + | *citetitle* (use ```Title `_``) + | *code* (use ````code````) + | *email* (just write the address in body text) + | *filenq* + | *filevar* (use the ``{...}`` highlighting feature of *file*) + | *programopt*, *longprogramopt* (use *option*) + | *ulink* (use ```Title `_``) + | *url* (just write the URL in body text) + | *var* (use ``*var*``) + | *infinity*, *plusminus* (use the Unicode character) + | *shortversion*, *version* (use the ``|version|`` and ``|release|`` substitutions) + | *emph*, *strong* (use the reST markup) + +* **Backslash escaping** + + In reST, a backslash must be escaped in normal text, and in the content of + roles. However, in code literals and literal blocks, it must not be escaped. + Example: ``:file:`C:\\Temp\\my.tmp``` vs. ````open("C:\Temp\my.tmp")````. + + +Information units +----------------- + +Information units (*...desc* environments) have been made reST directives. +These changes to information units should be noted: + +* **New names** + + "desc" has been removed from every name. Additionally, these directives have + new names: + + | *cfunction* (previously *cfuncdesc*) + | *cmacro* (previously *csimplemacrodesc*) + | *exception* (previously *excdesc*) + | *function* (previously *funcdesc*) + | *attribute* (previously *memberdesc*) + + The *classdesc\** and *excclassdesc* environments have been dropped, the + *class* and *exception* directives support classes documented with and without + constructor arguments. + +* **Multiple objects** + + The equivalent of the *...line* commands is:: + + .. function:: do_foo(bar) + do_bar(baz) + + Description of the functions. + + IOW, just give one signatures per line, at the same indentation level. + +* **Arguments** + + There is no *optional* command. Just give function signatures like they + should appear in the output:: + + .. function:: open(filename[, mode[, buffering]]) + + Description. + + Note: markup in the signature is not supported. + +* **Indexing** + + The *...descni* environments have been dropped. To mark an information unit + as unsuitable for index entry generation, use the *noindex* option like so:: + + .. function:: foo_* + :noindex: + + Description. + +* **New information units** + + There are new generic information units: One is called "describe" and can be + used to document things that are not covered by the other units:: + + .. describe:: a == b + + The equals operator. + + The others are:: + + .. cmdoption:: -O + + Describes a command-line option. + + .. envvar:: PYTHONINSPECT + + Describes an environment variable. + + +Structure +--------- + +The LaTeX docs were split in several toplevel manuals. Now, all files are part +of the same documentation tree, as indicated by the *toctree* directives in the +sources (though individual output formats may choose to split them up into parts +again). Every *toctree* directive embeds other files as subdocuments of the +current file (this structure is not necessarily mirrored in the filesystem +layout). The toplevel file is :file:`contents.rst`. + +However, most of the old directory structure has been kept, with the +directories renamed as follows: + +* :file:`api` -> :file:`c-api` +* :file:`dist` -> :file:`distutils`, with the single TeX file split up +* :file:`doc` -> :file:`documenting` +* :file:`ext` -> :file:`extending` +* :file:`inst` -> :file:`installing` +* :file:`lib` -> :file:`library` +* :file:`mac` -> merged into :file:`library`, with :file:`mac/using.tex` + moved to :file:`using/mac.rst` +* :file:`ref` -> :file:`reference` +* :file:`tut` -> :file:`tutorial`, with the single TeX file split up + + +.. XXX more (index-generating, production lists, ...) diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/documenting/index.rst --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Doc/documenting/index.rst Sun Jul 20 10:52:46 2014 -0400 @@ -0,0 +1,38 @@ +.. _documenting-index: + +###################### + Documenting Python +###################### + + +The Python language has a substantial body of documentation, much of it +contributed by various authors. The markup used for the Python documentation is +`reStructuredText`_, developed by the `docutils`_ project, amended by custom +directives and using a toolset named `Sphinx`_ to postprocess the HTML output. + +This document describes the style guide for our documentation as well as the +custom reStructuredText markup introduced by Sphinx to support Python +documentation and how it should be used. + +.. _reStructuredText: http://docutils.sf.net/rst.html +.. _docutils: http://docutils.sf.net/ +.. _Sphinx: http://sphinx.pocoo.org/ + +.. note:: + + If you're interested in contributing to Python's documentation, there's no + need to write reStructuredText if you're not so inclined; plain text + contributions are more than welcome as well. Send an e-mail to + docs@python.org or open an issue on the :ref:`tracker `. + + +.. toctree:: + :numbered: + :maxdepth: 1 + + intro.rst + style.rst + rest.rst + markup.rst + fromlatex.rst + building.rst diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/documenting/intro.rst --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Doc/documenting/intro.rst Sun Jul 20 10:52:46 2014 -0400 @@ -0,0 +1,29 @@ +Introduction +============ + +Python's documentation has long been considered to be good for a free +programming language. There are a number of reasons for this, the most +important being the early commitment of Python's creator, Guido van Rossum, to +providing documentation on the language and its libraries, and the continuing +involvement of the user community in providing assistance for creating and +maintaining documentation. + +The involvement of the community takes many forms, from authoring to bug reports +to just plain complaining when the documentation could be more complete or +easier to use. + +This document is aimed at authors and potential authors of documentation for +Python. More specifically, it is for people contributing to the standard +documentation and developing additional documents using the same tools as the +standard documents. This guide will be less useful for authors using the Python +documentation tools for topics other than Python, and less useful still for +authors not using the tools at all. + +If your interest is in contributing to the Python documentation, but you don't +have the time or inclination to learn reStructuredText and the markup structures +documented here, there's a welcoming place for you among the Python contributors +as well. Any time you feel that you can clarify existing documentation or +provide documentation that's missing, the existing documentation team will +gladly work with you to integrate your text, dealing with the markup for you. +Please don't let the material in this document stand between the documentation +and your desire to help out! \ No newline at end of file diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/documenting/markup.rst --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Doc/documenting/markup.rst Sun Jul 20 10:52:46 2014 -0400 @@ -0,0 +1,861 @@ +.. highlightlang:: rest + +Additional Markup Constructs +============================ + +Sphinx adds a lot of new directives and interpreted text roles to standard reST +markup. This section contains the reference material for these facilities. +Documentation for "standard" reST constructs is not included here, though +they are used in the Python documentation. + +.. note:: + + This is just an overview of Sphinx' extended markup capabilities; full + coverage can be found in `its own documentation + `_. + + +Meta-information markup +----------------------- + +.. describe:: sectionauthor + + Identifies the author of the current section. The argument should include + the author's name such that it can be used for presentation (though it isn't) + and email address. The domain name portion of the address should be lower + case. Example:: + + .. sectionauthor:: Guido van Rossum + + Currently, this markup isn't reflected in the output in any way, but it helps + keep track of contributions. + + +Module-specific markup +---------------------- + +The markup described in this section is used to provide information about a +module being documented. Each module should be documented in its own file. +Normally this markup appears after the title heading of that file; a typical +file might start like this:: + + :mod:`parrot` -- Dead parrot access + =================================== + + .. module:: parrot + :platform: Unix, Windows + :synopsis: Analyze and reanimate dead parrots. + .. moduleauthor:: Eric Cleese + .. moduleauthor:: John Idle + +As you can see, the module-specific markup consists of two directives, the +``module`` directive and the ``moduleauthor`` directive. + +.. describe:: module + + This directive marks the beginning of the description of a module (or package + submodule, in which case the name should be fully qualified, including the + package name). + + The ``platform`` option, if present, is a comma-separated list of the + platforms on which the module is available (if it is available on all + platforms, the option should be omitted). The keys are short identifiers; + examples that are in use include "IRIX", "Mac", "Windows", and "Unix". It is + important to use a key which has already been used when applicable. + + The ``synopsis`` option should consist of one sentence describing the + module's purpose -- it is currently only used in the Global Module Index. + + The ``deprecated`` option can be given (with no value) to mark a module as + deprecated; it will be designated as such in various locations then. + +.. describe:: moduleauthor + + The ``moduleauthor`` directive, which can appear multiple times, names the + authors of the module code, just like ``sectionauthor`` names the author(s) + of a piece of documentation. It too does not result in any output currently. + +.. note:: + + It is important to make the section title of a module-describing file + meaningful since that value will be inserted in the table-of-contents trees + in overview files. + + +Information units +----------------- + +There are a number of directives used to describe specific features provided by +modules. Each directive requires one or more signatures to provide basic +information about what is being described, and the content should be the +description. The basic version makes entries in the general index; if no index +entry is desired, you can give the directive option flag ``:noindex:``. The +following example shows all of the features of this directive type:: + + .. function:: spam(eggs) + ham(eggs) + :noindex: + + Spam or ham the foo. + +The signatures of object methods or data attributes should not include the +class name, but be nested in a class directive. The generated files will +reflect this nesting, and the target identifiers (for HTML output) will use +both the class and method name, to enable consistent cross-references. If you +describe methods belonging to an abstract protocol such as context managers, +use a class directive with a (pseudo-)type name too to make the +index entries more informative. + +The directives are: + +.. describe:: cfunction + + Describes a C function. The signature should be given as in C, e.g.:: + + .. cfunction:: PyObject* PyType_GenericAlloc(PyTypeObject *type, Py_ssize_t nitems) + + This is also used to describe function-like preprocessor macros. The names + of the arguments should be given so they may be used in the description. + + Note that you don't have to backslash-escape asterisks in the signature, + as it is not parsed by the reST inliner. + +.. describe:: cmember + + Describes a C struct member. Example signature:: + + .. cmember:: PyObject* PyTypeObject.tp_bases + + The text of the description should include the range of values allowed, how + the value should be interpreted, and whether the value can be changed. + References to structure members in text should use the ``member`` role. + +.. describe:: cmacro + + Describes a "simple" C macro. Simple macros are macros which are used + for code expansion, but which do not take arguments so cannot be described as + functions. This is not to be used for simple constant definitions. Examples + of its use in the Python documentation include :cmacro:`PyObject_HEAD` and + :cmacro:`Py_BEGIN_ALLOW_THREADS`. + +.. describe:: ctype + + Describes a C type. The signature should just be the type name. + +.. describe:: cvar + + Describes a global C variable. The signature should include the type, such + as:: + + .. cvar:: PyObject* PyClass_Type + +.. describe:: data + + Describes global data in a module, including both variables and values used + as "defined constants." Class and object attributes are not documented + using this directive. + +.. describe:: exception + + Describes an exception class. The signature can, but need not include + parentheses with constructor arguments. + +.. describe:: function + + Describes a module-level function. The signature should include the + parameters, enclosing optional parameters in brackets. Default values can be + given if it enhances clarity. For example:: + + .. function:: repeat([repeat=3[, number=1000000]]) + + Object methods are not documented using this directive. Bound object methods + placed in the module namespace as part of the public interface of the module + are documented using this, as they are equivalent to normal functions for + most purposes. + + The description should include information about the parameters required and + how they are used (especially whether mutable objects passed as parameters + are modified), side effects, and possible exceptions. A small example may be + provided. + +.. describe:: class + + Describes a class. The signature can include parentheses with parameters + which will be shown as the constructor arguments. + +.. describe:: attribute + + Describes an object data attribute. The description should include + information about the type of the data to be expected and whether it may be + changed directly. This directive should be nested in a class directive, + like in this example:: + + .. class:: Spam + + Description of the class. + + .. data:: ham + + Description of the attribute. + + If is also possible to document an attribute outside of a class directive, + for example if the documentation for different attributes and methods is + split in multiple sections. The class name should then be included + explicitly:: + + .. data:: Spam.eggs + +.. describe:: method + + Describes an object method. The parameters should not include the ``self`` + parameter. The description should include similar information to that + described for ``function``. This directive should be nested in a class + directive, like in the example above. + +.. describe:: opcode + + Describes a Python :term:`bytecode` instruction. + +.. describe:: cmdoption + + Describes a Python command line option or switch. Option argument names + should be enclosed in angle brackets. Example:: + + .. cmdoption:: -m + + Run a module as a script. + +.. describe:: envvar + + Describes an environment variable that Python uses or defines. + + +There is also a generic version of these directives: + +.. describe:: describe + + This directive produces the same formatting as the specific ones explained + above but does not create index entries or cross-referencing targets. It is + used, for example, to describe the directives in this document. Example:: + + .. describe:: opcode + + Describes a Python bytecode instruction. + + +Showing code examples +--------------------- + +Examples of Python source code or interactive sessions are represented using +standard reST literal blocks. They are started by a ``::`` at the end of the +preceding paragraph and delimited by indentation. + +Representing an interactive session requires including the prompts and output +along with the Python code. No special markup is required for interactive +sessions. After the last line of input or output presented, there should not be +an "unused" primary prompt; this is an example of what *not* to do:: + + >>> 1 + 1 + 2 + >>> + +Syntax highlighting is handled in a smart way: + +* There is a "highlighting language" for each source file. Per default, + this is ``'python'`` as the majority of files will have to highlight Python + snippets. + +* Within Python highlighting mode, interactive sessions are recognized + automatically and highlighted appropriately. + +* The highlighting language can be changed using the ``highlightlang`` + directive, used as follows:: + + .. highlightlang:: c + + This language is used until the next ``highlightlang`` directive is + encountered. + +* The values normally used for the highlighting language are: + + * ``python`` (the default) + * ``c`` + * ``rest`` + * ``none`` (no highlighting) + +* If highlighting with the current language fails, the block is not highlighted + in any way. + +Longer displays of verbatim text may be included by storing the example text in +an external file containing only plain text. The file may be included using the +``literalinclude`` directive. [1]_ For example, to include the Python source file +:file:`example.py`, use:: + + .. literalinclude:: example.py + +The file name is relative to the current file's path. Documentation-specific +include files should be placed in the ``Doc/includes`` subdirectory. + + +Inline markup +------------- + +As said before, Sphinx uses interpreted text roles to insert semantic markup in +documents. + +Names of local variables, such as function/method arguments, are an exception, +they should be marked simply with ``*var*``. + +For all other roles, you have to write ``:rolename:`content```. + +There are some additional facilities that make cross-referencing roles more +versatile: + +* You may supply an explicit title and reference target, like in reST direct + hyperlinks: ``:role:`title ``` will refer to *target*, but the link + text will be *title*. + +* If you prefix the content with ``!``, no reference/hyperlink will be created. + +* For the Python object roles, if you prefix the content with ``~``, the link + text will only be the last component of the target. For example, + ``:meth:`~Queue.Queue.get``` will refer to ``Queue.Queue.get`` but only + display ``get`` as the link text. + + In HTML output, the link's ``title`` attribute (that is e.g. shown as a + tool-tip on mouse-hover) will always be the full target name. + +The following roles refer to objects in modules and are possibly hyperlinked if +a matching identifier is found: + +.. describe:: mod + + The name of a module; a dotted name may be used. This should also be used for + package names. + +.. describe:: func + + The name of a Python function; dotted names may be used. The role text + should not include trailing parentheses to enhance readability. The + parentheses are stripped when searching for identifiers. + +.. describe:: data + + The name of a module-level variable or constant. + +.. describe:: const + + The name of a "defined" constant. This may be a C-language ``#define`` + or a Python variable that is not intended to be changed. + +.. describe:: class + + A class name; a dotted name may be used. + +.. describe:: meth + + The name of a method of an object. The role text should include the type + name and the method name. A dotted name may be used. + +.. describe:: attr + + The name of a data attribute of an object. + +.. describe:: exc + + The name of an exception. A dotted name may be used. + +The name enclosed in this markup can include a module name and/or a class name. +For example, ``:func:`filter``` could refer to a function named ``filter`` in +the current module, or the built-in function of that name. In contrast, +``:func:`foo.filter``` clearly refers to the ``filter`` function in the ``foo`` +module. + +Normally, names in these roles are searched first without any further +qualification, then with the current module name prepended, then with the +current module and class name (if any) prepended. If you prefix the name with a +dot, this order is reversed. For example, in the documentation of the +:mod:`codecs` module, ``:func:`open``` always refers to the built-in function, +while ``:func:`.open``` refers to :func:`codecs.open`. + +A similar heuristic is used to determine whether the name is an attribute of +the currently documented class. + +The following roles create cross-references to C-language constructs if they +are defined in the API documentation: + +.. describe:: cdata + + The name of a C-language variable. + +.. describe:: cfunc + + The name of a C-language function. Should include trailing parentheses. + +.. describe:: cmacro + + The name of a "simple" C macro, as defined above. + +.. describe:: ctype + + The name of a C-language type. + + +The following role does possibly create a cross-reference, but does not refer +to objects: + +.. describe:: token + + The name of a grammar token (used in the reference manual to create links + between production displays). + + +The following role creates a cross-reference to the term in the glossary: + +.. describe:: term + + Reference to a term in the glossary. The glossary is created using the + ``glossary`` directive containing a definition list with terms and + definitions. It does not have to be in the same file as the ``term`` + markup, in fact, by default the Python docs have one global glossary + in the ``glossary.rst`` file. + + If you use a term that's not explained in a glossary, you'll get a warning + during build. + +--------- + +The following roles don't do anything special except formatting the text +in a different style: + +.. describe:: command + + The name of an OS-level command, such as ``rm``. + +.. describe:: dfn + + Mark the defining instance of a term in the text. (No index entries are + generated.) + +.. describe:: envvar + + An environment variable. Index entries are generated. + +.. describe:: file + + The name of a file or directory. Within the contents, you can use curly + braces to indicate a "variable" part, for example:: + + ... is installed in :file:`/usr/lib/python2.{x}/site-packages` ... + + In the built documentation, the ``x`` will be displayed differently to + indicate that it is to be replaced by the Python minor version. + +.. describe:: guilabel + + Labels presented as part of an interactive user interface should be marked + using ``guilabel``. This includes labels from text-based interfaces such as + those created using :mod:`curses` or other text-based libraries. Any label + used in the interface should be marked with this role, including button + labels, window titles, field names, menu and menu selection names, and even + values in selection lists. + +.. describe:: kbd + + Mark a sequence of keystrokes. What form the key sequence takes may depend + on platform- or application-specific conventions. When there are no relevant + conventions, the names of modifier keys should be spelled out, to improve + accessibility for new users and non-native speakers. For example, an + *xemacs* key sequence may be marked like ``:kbd:`C-x C-f```, but without + reference to a specific application or platform, the same sequence should be + marked as ``:kbd:`Control-x Control-f```. + +.. describe:: keyword + + The name of a Python keyword. Using this role will generate a link to the + documentation of the keyword. ``True``, ``False`` and ``None`` do not use + this role, but simple code markup (````True````), given that they're + fundamental to the language and should be known to any programmer. + +.. describe:: mailheader + + The name of an RFC 822-style mail header. This markup does not imply that + the header is being used in an email message, but can be used to refer to any + header of the same "style." This is also used for headers defined by the + various MIME specifications. The header name should be entered in the same + way it would normally be found in practice, with the camel-casing conventions + being preferred where there is more than one common usage. For example: + ``:mailheader:`Content-Type```. + +.. describe:: makevar + + The name of a :command:`make` variable. + +.. describe:: manpage + + A reference to a Unix manual page including the section, + e.g. ``:manpage:`ls(1)```. + +.. describe:: menuselection + + Menu selections should be marked using the ``menuselection`` role. This is + used to mark a complete sequence of menu selections, including selecting + submenus and choosing a specific operation, or any subsequence of such a + sequence. The names of individual selections should be separated by + ``-->``. + + For example, to mark the selection "Start > Programs", use this markup:: + + :menuselection:`Start --> Programs` + + When including a selection that includes some trailing indicator, such as the + ellipsis some operating systems use to indicate that the command opens a + dialog, the indicator should be omitted from the selection name. + +.. describe:: mimetype + + The name of a MIME type, or a component of a MIME type (the major or minor + portion, taken alone). + +.. describe:: newsgroup + + The name of a Usenet newsgroup. + +.. describe:: option + + A command-line option of Python. The leading hyphen(s) must be included. + If a matching ``cmdoption`` directive exists, it is linked to. For options + of other programs or scripts, use simple ````code```` markup. + +.. describe:: program + + The name of an executable program. This may differ from the file name for + the executable for some platforms. In particular, the ``.exe`` (or other) + extension should be omitted for Windows programs. + +.. describe:: regexp + + A regular expression. Quotes should not be included. + +.. describe:: samp + + A piece of literal text, such as code. Within the contents, you can use + curly braces to indicate a "variable" part, as in ``:file:``. + + If you don't need the "variable part" indication, use the standard + ````code```` instead. + + +The following roles generate external links: + +.. describe:: pep + + A reference to a Python Enhancement Proposal. This generates appropriate + index entries. The text "PEP *number*\ " is generated; in the HTML output, + this text is a hyperlink to an online copy of the specified PEP. + +.. describe:: rfc + + A reference to an Internet Request for Comments. This generates appropriate + index entries. The text "RFC *number*\ " is generated; in the HTML output, + this text is a hyperlink to an online copy of the specified RFC. + + +Note that there are no special roles for including hyperlinks as you can use +the standard reST markup for that purpose. + + +.. _doc-ref-role: + +Cross-linking markup +-------------------- + +To support cross-referencing to arbitrary sections in the documentation, the +standard reST labels are "abused" a bit: Every label must precede a section +title; and every label name must be unique throughout the entire documentation +source. + +You can then reference to these sections using the ``:ref:`label-name``` role. + +Example:: + + .. _my-reference-label: + + Section to cross-reference + -------------------------- + + This is the text of the section. + + It refers to the section itself, see :ref:`my-reference-label`. + +The ``:ref:`` invocation is replaced with the section title. + + +Paragraph-level markup +---------------------- + +These directives create short paragraphs and can be used inside information +units as well as normal text: + +.. describe:: note + + An especially important bit of information about an API that a user should be + aware of when using whatever bit of API the note pertains to. The content of + the directive should be written in complete sentences and include all + appropriate punctuation. + + Example:: + + .. note:: + + This function is not suitable for sending spam e-mails. + +.. describe:: warning + + An important bit of information about an API that a user should be aware of + when using whatever bit of API the warning pertains to. The content of the + directive should be written in complete sentences and include all appropriate + punctuation. In the interest of not scaring users away from pages filled + with warnings, this directive should only be chosen over ``note`` for + information regarding the possibility of crashes, data loss, or security + implications. + +.. describe:: versionadded + + This directive documents the version of Python which added the described + feature to the library or C API. When this applies to an entire module, it + should be placed at the top of the module section before any prose. + + The first argument must be given and is the version in question; you can add + a second argument consisting of a *brief* explanation of the change. + + Example:: + + .. versionadded:: 2.5 + The *spam* parameter. + + Note that there must be no blank line between the directive head and the + explanation; this is to make these blocks visually continuous in the markup. + +.. describe:: versionchanged + + Similar to ``versionadded``, but describes when and what changed in the named + feature in some way (new parameters, changed side effects, etc.). + +-------------- + +.. describe:: impl-detail + + This directive is used to mark CPython-specific information. Use either with + a block content or a single sentence as an argument, i.e. either :: + + .. impl-detail:: + + This describes some implementation detail. + + More explanation. + + or :: + + .. impl-detail:: This shortly mentions an implementation detail. + + "\ **CPython implementation detail:**\ " is automatically prepended to the + content. + +.. describe:: seealso + + Many sections include a list of references to module documentation or + external documents. These lists are created using the ``seealso`` directive. + + The ``seealso`` directive is typically placed in a section just before any + sub-sections. For the HTML output, it is shown boxed off from the main flow + of the text. + + The content of the ``seealso`` directive should be a reST definition list. + Example:: + + .. seealso:: + + Module :mod:`zipfile` + Documentation of the :mod:`zipfile` standard module. + + `GNU tar manual, Basic Tar Format `_ + Documentation for tar archive files, including GNU tar extensions. + +.. describe:: rubric + + This directive creates a paragraph heading that is not used to create a + table of contents node. It is currently used for the "Footnotes" caption. + +.. describe:: centered + + This directive creates a centered boldfaced paragraph. Use it as follows:: + + .. centered:: + + Paragraph contents. + + +Table-of-contents markup +------------------------ + +Since reST does not have facilities to interconnect several documents, or split +documents into multiple output files, Sphinx uses a custom directive to add +relations between the single files the documentation is made of, as well as +tables of contents. The ``toctree`` directive is the central element. + +.. describe:: toctree + + This directive inserts a "TOC tree" at the current location, using the + individual TOCs (including "sub-TOC trees") of the files given in the + directive body. A numeric ``maxdepth`` option may be given to indicate the + depth of the tree; by default, all levels are included. + + Consider this example (taken from the library reference index):: + + .. toctree:: + :maxdepth: 2 + + intro + strings + datatypes + numeric + (many more files listed here) + + This accomplishes two things: + + * Tables of contents from all those files are inserted, with a maximum depth + of two, that means one nested heading. ``toctree`` directives in those + files are also taken into account. + * Sphinx knows that the relative order of the files ``intro``, + ``strings`` and so forth, and it knows that they are children of the + shown file, the library index. From this information it generates "next + chapter", "previous chapter" and "parent chapter" links. + + In the end, all files included in the build process must occur in one + ``toctree`` directive; Sphinx will emit a warning if it finds a file that is + not included, because that means that this file will not be reachable through + standard navigation. + + The special file ``contents.rst`` at the root of the source directory is the + "root" of the TOC tree hierarchy; from it the "Contents" page is generated. + + +Index-generating markup +----------------------- + +Sphinx automatically creates index entries from all information units (like +functions, classes or attributes) like discussed before. + +However, there is also an explicit directive available, to make the index more +comprehensive and enable index entries in documents where information is not +mainly contained in information units, such as the language reference. + +The directive is ``index`` and contains one or more index entries. Each entry +consists of a type and a value, separated by a colon. + +For example:: + + .. index:: + single: execution; context + module: __main__ + module: sys + triple: module; search; path + +This directive contains five entries, which will be converted to entries in the +generated index which link to the exact location of the index statement (or, in +case of offline media, the corresponding page number). + +The possible entry types are: + +single + Creates a single index entry. Can be made a subentry by separating the + subentry text with a semicolon (this notation is also used below to describe + what entries are created). +pair + ``pair: loop; statement`` is a shortcut that creates two index entries, + namely ``loop; statement`` and ``statement; loop``. +triple + Likewise, ``triple: module; search; path`` is a shortcut that creates three + index entries, which are ``module; search path``, ``search; path, module`` and + ``path; module search``. +module, keyword, operator, object, exception, statement, builtin + These all create two index entries. For example, ``module: hashlib`` creates + the entries ``module; hashlib`` and ``hashlib; module``. + +For index directives containing only "single" entries, there is a shorthand +notation:: + + .. index:: BNF, grammar, syntax, notation + +This creates four index entries. + + +Grammar production displays +--------------------------- + +Special markup is available for displaying the productions of a formal grammar. +The markup is simple and does not attempt to model all aspects of BNF (or any +derived forms), but provides enough to allow context-free grammars to be +displayed in a way that causes uses of a symbol to be rendered as hyperlinks to +the definition of the symbol. There is this directive: + +.. describe:: productionlist + + This directive is used to enclose a group of productions. Each production is + given on a single line and consists of a name, separated by a colon from the + following definition. If the definition spans multiple lines, each + continuation line must begin with a colon placed at the same column as in the + first line. + + Blank lines are not allowed within ``productionlist`` directive arguments. + + The definition can contain token names which are marked as interpreted text + (e.g. ``unaryneg ::= "-" `integer```) -- this generates cross-references + to the productions of these tokens. + + Note that no further reST parsing is done in the production, so that you + don't have to escape ``*`` or ``|`` characters. + + +.. XXX describe optional first parameter + +The following is an example taken from the Python Reference Manual:: + + .. productionlist:: + try_stmt: try1_stmt | try2_stmt + try1_stmt: "try" ":" `suite` + : ("except" [`expression` ["," `target`]] ":" `suite`)+ + : ["else" ":" `suite`] + : ["finally" ":" `suite`] + try2_stmt: "try" ":" `suite` + : "finally" ":" `suite` + + +Substitutions +------------- + +The documentation system provides three substitutions that are defined by default. +They are set in the build configuration file :file:`conf.py`. + +.. describe:: |release| + + Replaced by the Python release the documentation refers to. This is the full + version string including alpha/beta/release candidate tags, e.g. ``2.5.2b3``. + +.. describe:: |version| + + Replaced by the Python version the documentation refers to. This consists + only of the major and minor version parts, e.g. ``2.5``, even for version + 2.5.1. + +.. describe:: |today| + + Replaced by either today's date, or the date set in the build configuration + file. Normally has the format ``April 14, 2007``. + + +.. rubric:: Footnotes + +.. [1] There is a standard ``.. include`` directive, but it raises errors if the + file is not found. This one only emits a warning. diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/documenting/rest.rst --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Doc/documenting/rest.rst Sun Jul 20 10:52:46 2014 -0400 @@ -0,0 +1,243 @@ +.. highlightlang:: rest + +reStructuredText Primer +======================= + +This section is a brief introduction to reStructuredText (reST) concepts and +syntax, intended to provide authors with enough information to author documents +productively. Since reST was designed to be a simple, unobtrusive markup +language, this will not take too long. + +.. seealso:: + + The authoritative `reStructuredText User + Documentation `_. + + +Paragraphs +---------- + +The paragraph is the most basic block in a reST document. Paragraphs are simply +chunks of text separated by one or more blank lines. As in Python, indentation +is significant in reST, so all lines of the same paragraph must be left-aligned +to the same level of indentation. + + +Inline markup +------------- + +The standard reST inline markup is quite simple: use + +* one asterisk: ``*text*`` for emphasis (italics), +* two asterisks: ``**text**`` for strong emphasis (boldface), and +* backquotes: ````text```` for code samples. + +If asterisks or backquotes appear in running text and could be confused with +inline markup delimiters, they have to be escaped with a backslash. + +Be aware of some restrictions of this markup: + +* it may not be nested, +* content may not start or end with whitespace: ``* text*`` is wrong, +* it must be separated from surrounding text by non-word characters. Use a + backslash escaped space to work around that: ``thisis\ *one*\ word``. + +These restrictions may be lifted in future versions of the docutils. + +reST also allows for custom "interpreted text roles"', which signify that the +enclosed text should be interpreted in a specific way. Sphinx uses this to +provide semantic markup and cross-referencing of identifiers, as described in +the appropriate section. The general syntax is ``:rolename:`content```. + + +Lists and Quotes +---------------- + +List markup is natural: just place an asterisk at the start of a paragraph and +indent properly. The same goes for numbered lists; they can also be +autonumbered using a ``#`` sign:: + + * This is a bulleted list. + * It has two items, the second + item uses two lines. + + 1. This is a numbered list. + 2. It has two items too. + + #. This is a numbered list. + #. It has two items too. + + +Nested lists are possible, but be aware that they must be separated from the +parent list items by blank lines:: + + * this is + * a list + + * with a nested list + * and some subitems + + * and here the parent list continues + +Definition lists are created as follows:: + + term (up to a line of text) + Definition of the term, which must be indented + + and can even consist of multiple paragraphs + + next term + Description. + + +Paragraphs are quoted by just indenting them more than the surrounding +paragraphs. + + +Source Code +----------- + +Literal code blocks are introduced by ending a paragraph with the special marker +``::``. The literal block must be indented:: + + This is a normal text paragraph. The next paragraph is a code sample:: + + It is not processed in any way, except + that the indentation is removed. + + It can span multiple lines. + + This is a normal text paragraph again. + +The handling of the ``::`` marker is smart: + +* If it occurs as a paragraph of its own, that paragraph is completely left + out of the document. +* If it is preceded by whitespace, the marker is removed. +* If it is preceded by non-whitespace, the marker is replaced by a single + colon. + +That way, the second sentence in the above example's first paragraph would be +rendered as "The next paragraph is a code sample:". + + +Hyperlinks +---------- + +External links +^^^^^^^^^^^^^^ + +Use ```Link text `_`` for inline web links. If the link text +should be the web address, you don't need special markup at all, the parser +finds links and mail addresses in ordinary text. + +Internal links +^^^^^^^^^^^^^^ + +Internal linking is done via a special reST role, see the section on specific +markup, :ref:`doc-ref-role`. + + +Sections +-------- + +Section headers are created by underlining (and optionally overlining) the +section title with a punctuation character, at least as long as the text:: + + ================= + This is a heading + ================= + +Normally, there are no heading levels assigned to certain characters as the +structure is determined from the succession of headings. However, for the +Python documentation, we use this convention: + +* ``#`` with overline, for parts +* ``*`` with overline, for chapters +* ``=``, for sections +* ``-``, for subsections +* ``^``, for subsubsections +* ``"``, for paragraphs + + +Explicit Markup +--------------- + +"Explicit markup" is used in reST for most constructs that need special +handling, such as footnotes, specially-highlighted paragraphs, comments, and +generic directives. + +An explicit markup block begins with a line starting with ``..`` followed by +whitespace and is terminated by the next paragraph at the same level of +indentation. (There needs to be a blank line between explicit markup and normal +paragraphs. This may all sound a bit complicated, but it is intuitive enough +when you write it.) + + +Directives +---------- + +A directive is a generic block of explicit markup. Besides roles, it is one of +the extension mechanisms of reST, and Sphinx makes heavy use of it. + +Basically, a directive consists of a name, arguments, options and content. (Keep +this terminology in mind, it is used in the next chapter describing custom +directives.) Looking at this example, :: + + .. function:: foo(x) + foo(y, z) + :bar: no + + Return a line of text input from the user. + +``function`` is the directive name. It is given two arguments here, the +remainder of the first line and the second line, as well as one option ``bar`` +(as you can see, options are given in the lines immediately following the +arguments and indicated by the colons). + +The directive content follows after a blank line and is indented relative to the +directive start. + + +Footnotes +--------- + +For footnotes, use ``[#]_`` to mark the footnote location, and add the footnote +body at the bottom of the document after a "Footnotes" rubric heading, like so:: + + Lorem ipsum [#]_ dolor sit amet ... [#]_ + + .. rubric:: Footnotes + + .. [#] Text of the first footnote. + .. [#] Text of the second footnote. + +You can also explicitly number the footnotes for better context. + + +Comments +-------- + +Every explicit markup block which isn't a valid markup construct (like the +footnotes above) is regarded as a comment. + + +Source encoding +--------------- + +Since the easiest way to include special characters like em dashes or copyright +signs in reST is to directly write them as Unicode characters, one has to +specify an encoding: + +All Python documentation source files must be in UTF-8 encoding, and the HTML +documents written from them will be in that encoding as well. + + +Gotchas +------- + +There are some problems one commonly runs into while authoring reST documents: + +* **Separation of inline markup:** As said above, inline markup spans must be + separated from the surrounding text by non-word characters, you have to use + an escaped space to get around that. diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/documenting/style.rst --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Doc/documenting/style.rst Sun Jul 20 10:52:46 2014 -0400 @@ -0,0 +1,174 @@ +.. highlightlang:: rest + +Style Guide +=========== + +The Python documentation should follow the `Apple Publications Style Guide`_ +wherever possible. This particular style guide was selected mostly because it +seems reasonable and is easy to get online. + +Topics which are not covered in Apple's style guide will be discussed in +this document. + +All reST files use an indentation of 3 spaces. The maximum line length is 80 +characters for normal text, but tables, deeply indented code samples and long +links may extend beyond that. + +Make generous use of blank lines where applicable; they help grouping things +together. + +A sentence-ending period may be followed by one or two spaces; while reST +ignores the second space, it is customarily put in by some users, for example +to aid Emacs' auto-fill mode. + +Footnotes are generally discouraged, though they may be used when they are the +best way to present specific information. When a footnote reference is added at +the end of the sentence, it should follow the sentence-ending punctuation. The +reST markup should appear something like this:: + + This sentence has a footnote reference. [#]_ This is the next sentence. + +Footnotes should be gathered at the end of a file, or if the file is very long, +at the end of a section. The docutils will automatically create backlinks to +the footnote reference. + +Footnotes may appear in the middle of sentences where appropriate. + +Many special names are used in the Python documentation, including the names of +operating systems, programming languages, standards bodies, and the like. Most +of these entities are not assigned any special markup, but the preferred +spellings are given here to aid authors in maintaining the consistency of +presentation in the Python documentation. + +Other terms and words deserve special mention as well; these conventions should +be used to ensure consistency throughout the documentation: + +CPU + For "central processing unit." Many style guides say this should be spelled + out on the first use (and if you must use it, do so!). For the Python + documentation, this abbreviation should be avoided since there's no + reasonable way to predict which occurrence will be the first seen by the + reader. It is better to use the word "processor" instead. + +POSIX + The name assigned to a particular group of standards. This is always + uppercase. + +Python + The name of our favorite programming language is always capitalized. + +Unicode + The name of a character set and matching encoding. This is always written + capitalized. + +Unix + The name of the operating system developed at AT&T Bell Labs in the early + 1970s. + +Affirmative Tone +---------------- + +The documentation focuses on affirmatively stating what the language does and +how to use it effectively. + +Except for certain security risks or segfault risks, the docs should avoid +wording along the lines of "feature x is dangerous" or "experts only". These +kinds of value judgments belong in external blogs and wikis, not in the core +documentation. + +Bad example (creating worry in the mind of a reader): + + Warning: failing to explicitly close a file could result in lost data or + excessive resource consumption. Never rely on reference counting to + automatically close a file. + +Good example (establishing confident knowledge in the effective use of the language): + + A best practice for using files is use a try/finally pair to explicitly + close a file after it is used. Alternatively, using a with-statement can + achieve the same effect. This assures that files are flushed and file + descriptor resources are released in a timely manner. + +Economy of Expression +--------------------- + +More documentation is not necessarily better documentation. Err on the side +of being succinct. + +It is an unfortunate fact that making documentation longer can be an impediment +to understanding and can result in even more ways to misread or misinterpret the +text. Long descriptions full of corner cases and caveats can create the +impression that a function is more complex or harder to use than it actually is. + +The documentation for :func:`super` is an example of where a good deal of +information was condensed into a few short paragraphs. Discussion of +:func:`super` could have filled a chapter in a book, but it is often easier to +grasp a terse description than a lengthy narrative. + + +Code Examples +------------- + +Short code examples can be a useful adjunct to understanding. Readers can often +grasp a simple example more quickly than they can digest a formal description in +prose. + +People learn faster with concrete, motivating examples that match the context of +a typical use case. For instance, the :func:`str.rpartition` method is better +demonstrated with an example splitting the domain from a URL than it would be +with an example of removing the last word from a line of Monty Python dialog. + +The ellipsis for the :attr:`sys.ps2` secondary interpreter prompt should only be +used sparingly, where it is necessary to clearly differentiate between input +lines and output lines. Besides contributing visual clutter, it makes it +difficult for readers to cut-and-paste examples so they can experiment with +variations. + +Code Equivalents +---------------- + +Giving pure Python code equivalents (or approximate equivalents) can be a useful +adjunct to a prose description. A documenter should carefully weigh whether the +code equivalent adds value. + +A good example is the code equivalent for :func:`all`. The short 4-line code +equivalent is easily digested; it re-emphasizes the early-out behavior; and it +clarifies the handling of the corner-case where the iterable is empty. In +addition, it serves as a model for people wanting to implement a commonly +requested alternative where :func:`all` would return the specific object +evaluating to False whenever the function terminates early. + +A more questionable example is the code for :func:`itertools.groupby`. Its code +equivalent borders on being too complex to be a quick aid to understanding. +Despite its complexity, the code equivalent was kept because it serves as a +model to alternative implementations and because the operation of the "grouper" +is more easily shown in code than in English prose. + +An example of when not to use a code equivalent is for the :func:`oct` function. +The exact steps in converting a number to octal doesn't add value for a user +trying to learn what the function does. + +Audience +-------- + +The tone of the tutorial (and all the docs) needs to be respectful of the +reader's intelligence. Don't presume that the readers are stupid. Lay out the +relevant information, show motivating use cases, provide glossary links, and do +your best to connect the dots, but don't talk down to them or waste their time. + +The tutorial is meant for newcomers, many of whom will be using the tutorial to +evaluate the language as a whole. The experience needs to be positive and not +leave the reader with worries that something bad will happen if they make a +misstep. The tutorial serves as guide for intelligent and curious readers, +saving details for the how-to guides and other sources. + +Be careful accepting requests for documentation changes from the rare but vocal +category of reader who is looking for vindication for one of their programming +errors ("I made a mistake, therefore the docs must be wrong ..."). Typically, +the documentation wasn't consulted until after the error was made. It is +unfortunate, but typically no documentation edit would have saved the user from +making false assumptions about the language ("I was surprised by ..."). + + +.. _Apple Publications Style Guide: http://developer.apple.com/mac/library/documentation/UserExperience/Conceptual/APStyleGuide/APSG_2009.pdf + diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/extending/building.rst --- a/Doc/extending/building.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/extending/building.rst Sun Jul 20 10:52:46 2014 -0400 @@ -58,9 +58,8 @@ It is common to pre-compute arguments to :func:`setup`, to better structure the driver script. In the example above, the\ ``ext_modules`` argument to :func:`setup` is a list of extension modules, each of which is an instance of -the :class:`~distutils.extension.Extension`. In the example, the instance -defines an extension named ``demo`` which is build by compiling a single source -file, :file:`demo.c`. +the :class:`Extension`. In the example, the instance defines an extension named +``demo`` which is build by compiling a single source file, :file:`demo.c`. In many cases, building an extension is more complex, since additional preprocessor defines and libraries may be needed. This is demonstrated in the diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/extending/embedding.rst --- a/Doc/extending/embedding.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/extending/embedding.rst Sun Jul 20 10:52:46 2014 -0400 @@ -25,14 +25,14 @@ So if you are embedding Python, you are providing your own main program. One of the things this main program has to do is initialize the Python interpreter. At -the very least, you have to call the function :c:func:`Py_Initialize`. There are +the very least, you have to call the function :cfunc:`Py_Initialize`. There are optional calls to pass command line arguments to Python. Then later you can call the interpreter from any part of the application. There are several different ways to call the interpreter: you can pass a string -containing Python statements to :c:func:`PyRun_SimpleString`, or you can pass a +containing Python statements to :cfunc:`PyRun_SimpleString`, or you can pass a stdio file pointer and a file name (for identification in error messages only) -to :c:func:`PyRun_SimpleFile`. You can also call the lower-level operations +to :cfunc:`PyRun_SimpleFile`. You can also call the lower-level operations described in the previous chapters to construct and use Python objects. A simple demo of embedding Python can be found in the directory @@ -61,7 +61,6 @@ int main(int argc, char *argv[]) { - Py_SetProgramName(argv[0]); /* optional but recommended */ Py_Initialize(); PyRun_SimpleString("from time import time,ctime\n" "print 'Today is',ctime(time())\n"); @@ -69,15 +68,13 @@ return 0; } -The :c:func:`Py_SetProgramName` function should be called before -:c:func:`Py_Initialize` to inform the interpreter about paths to Python run-time -libraries. Next, the Python interpreter is initialized with -:c:func:`Py_Initialize`, followed by the execution of a hard-coded Python script -that prints the date and time. Afterwards, the :c:func:`Py_Finalize` call shuts +The above code first initializes the Python interpreter with +:cfunc:`Py_Initialize`, followed by the execution of a hard-coded Python script +that print the date and time. Afterwards, the :cfunc:`Py_Finalize` call shuts the interpreter down, followed by the end of the program. In a real program, you may want to get the Python script from another source, perhaps a text-editor routine, a file, or a database. Getting the Python code from a file can better -be done by using the :c:func:`PyRun_SimpleFile` function, which saves you the +be done by using the :cfunc:`PyRun_SimpleFile` function, which saves you the trouble of allocating memory space and loading the file contents. @@ -140,9 +137,7 @@ This code loads a Python script using ``argv[1]``, and calls the function named in ``argv[2]``. Its integer arguments are the other values of the ``argv`` array. If you compile and link this program (let's call the finished executable -:program:`call`), and use it to execute a Python script, such as: - -.. code-block:: python +:program:`call`), and use it to execute a Python script, such as:: def multiply(a,b): print "Will compute", a, "times", b @@ -167,8 +162,8 @@ pModule = PyImport_Import(pName); After initializing the interpreter, the script is loaded using -:c:func:`PyImport_Import`. This routine needs a Python string as its argument, -which is constructed using the :c:func:`PyString_FromString` data conversion +:cfunc:`PyImport_Import`. This routine needs a Python string as its argument, +which is constructed using the :cfunc:`PyString_FromString` data conversion routine. :: pFunc = PyObject_GetAttrString(pModule, argv[2]); @@ -180,7 +175,7 @@ Py_XDECREF(pFunc); Once the script is loaded, the name we're looking for is retrieved using -:c:func:`PyObject_GetAttrString`. If the name exists, and the object returned is +:cfunc:`PyObject_GetAttrString`. If the name exists, and the object returned is callable, you can safely assume that it is a function. The program then proceeds by constructing a tuple of arguments as normal. The call to the Python function is then made with:: @@ -223,17 +218,15 @@ {NULL, NULL, 0, NULL} }; -Insert the above code just above the :c:func:`main` function. Also, insert the -following two statements directly after :c:func:`Py_Initialize`:: +Insert the above code just above the :cfunc:`main` function. Also, insert the +following two statements directly after :cfunc:`Py_Initialize`:: numargs = argc; Py_InitModule("emb", EmbMethods); These two lines initialize the ``numargs`` variable, and make the :func:`emb.numargs` function accessible to the embedded Python interpreter. -With these extensions, the Python script can do things like - -.. code-block:: python +With these extensions, the Python script can do things like :: import emb print "Number of arguments", emb.numargs() @@ -258,55 +251,35 @@ .. _link-reqs: -Compiling and Linking under Unix-like systems -============================================= +Linking Requirements +==================== -It is not necessarily trivial to find the right flags to pass to your -compiler (and linker) in order to embed the Python interpreter into your -application, particularly because Python needs to load library modules -implemented as C dynamic extensions (:file:`.so` files) linked against -it. +While the :program:`configure` script shipped with the Python sources will +correctly build Python to export the symbols needed by dynamically linked +extensions, this is not automatically inherited by applications which embed the +Python library statically, at least on Unix. This is an issue when the +application is linked to the static runtime library (:file:`libpython.a`) and +needs to load dynamic extensions (implemented as :file:`.so` files). -To find out the required compiler and linker flags, you can execute the -:file:`python{X.Y}-config` script which is generated as part of the -installation process (a :file:`python-config` script may also be -available). This script has several options, of which the following will -be directly useful to you: +The problem is that some entry points are defined by the Python runtime solely +for extension modules to use. If the embedding application does not use any of +these entry points, some linkers will not include those entries in the symbol +table of the finished executable. Some additional options are needed to inform +the linker not to remove these symbols. -* ``pythonX.Y-config --cflags`` will give you the recommended flags when - compiling:: +Determining the right options to use for any given platform can be quite +difficult, but fortunately the Python configuration already has those values. +To retrieve them from an installed Python interpreter, start an interactive +interpreter and have a short session like this:: - $ /opt/bin/python2.7-config --cflags - -I/opt/include/python2.7 -fno-strict-aliasing -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes - -* ``pythonX.Y-config --ldflags`` will give you the recommended flags when - linking:: - - $ /opt/bin/python2.7-config --ldflags - -L/opt/lib/python2.7/config -lpthread -ldl -lutil -lm -lpython2.7 -Xlinker -export-dynamic - -.. note:: - To avoid confusion between several Python installations (and especially - between the system Python and your own compiled Python), it is recommended - that you use the absolute path to :file:`python{X.Y}-config`, as in the above - example. - -If this procedure doesn't work for you (it is not guaranteed to work for -all Unix-like platforms; however, we welcome :ref:`bug reports `) -you will have to read your system's documentation about dynamic linking and/or -examine Python's :file:`Makefile` (use :func:`sysconfig.get_makefile_filename` -to find its location) and compilation -options. In this case, the :mod:`sysconfig` module is a useful tool to -programmatically extract the configuration values that you will want to -combine together. For example: - -.. code-block:: python - - >>> import sysconfig - >>> sysconfig.get_config_var('LIBS') - '-lpthread -ldl -lutil' - >>> sysconfig.get_config_var('LINKFORSHARED') + >>> import distutils.sysconfig + >>> distutils.sysconfig.get_config_var('LINKFORSHARED') '-Xlinker -export-dynamic' +.. index:: module: distutils.sysconfig -.. XXX similar documentation for Windows missing +The contents of the string presented will be the options that should be used. +If the string is empty, there's no need to add any additional options. The +:const:`LINKFORSHARED` definition corresponds to the variable of the same name +in Python's top-level :file:`Makefile`. + diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/extending/extending.rst --- a/Doc/extending/extending.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/extending/extending.rst Sun Jul 20 10:52:46 2014 -0400 @@ -35,7 +35,7 @@ Let's create an extension module called ``spam`` (the favorite food of Monty Python fans...) and let's say we want to create a Python interface to the C -library function :c:func:`system`. [#]_ This function takes a null-terminated +library function :cfunc:`system`. [#]_ This function takes a null-terminated character string as argument and returns an integer. We want this function to be callable from Python as follows:: @@ -65,8 +65,8 @@ since they are used extensively by the Python interpreter, ``"Python.h"`` includes a few standard header files: ````, ````, ````, and ````. If the latter header file does not exist on -your system, it declares the functions :c:func:`malloc`, :c:func:`free` and -:c:func:`realloc` directly. +your system, it declares the functions :cfunc:`malloc`, :cfunc:`free` and +:cfunc:`realloc` directly. The next thing we add to our module file is the C function that will be called when the Python expression ``spam.system(string)`` is evaluated (we'll see @@ -96,12 +96,12 @@ arguments. Each item of the tuple corresponds to an argument in the call's argument list. The arguments are Python objects --- in order to do anything with them in our C function we have to convert them to C values. The function -:c:func:`PyArg_ParseTuple` in the Python API checks the argument types and +:cfunc:`PyArg_ParseTuple` in the Python API checks the argument types and converts them to C values. It uses a template string to determine the required types of the arguments as well as the types of the C variables into which to store the converted values. More about this later. -:c:func:`PyArg_ParseTuple` returns true (nonzero) if all arguments have the right +:cfunc:`PyArg_ParseTuple` returns true (nonzero) if all arguments have the right type and its components have been stored in the variables whose addresses are passed. It returns false (zero) if an invalid argument list was passed. In the latter case it also raises an appropriate exception so the calling function can @@ -127,77 +127,77 @@ The Python API defines a number of functions to set various types of exceptions. -The most common one is :c:func:`PyErr_SetString`. Its arguments are an exception +The most common one is :cfunc:`PyErr_SetString`. Its arguments are an exception object and a C string. The exception object is usually a predefined object like -:c:data:`PyExc_ZeroDivisionError`. The C string indicates the cause of the error +:cdata:`PyExc_ZeroDivisionError`. The C string indicates the cause of the error and is converted to a Python string object and stored as the "associated value" of the exception. -Another useful function is :c:func:`PyErr_SetFromErrno`, which only takes an +Another useful function is :cfunc:`PyErr_SetFromErrno`, which only takes an exception argument and constructs the associated value by inspection of the -global variable :c:data:`errno`. The most general function is -:c:func:`PyErr_SetObject`, which takes two object arguments, the exception and -its associated value. You don't need to :c:func:`Py_INCREF` the objects passed +global variable :cdata:`errno`. The most general function is +:cfunc:`PyErr_SetObject`, which takes two object arguments, the exception and +its associated value. You don't need to :cfunc:`Py_INCREF` the objects passed to any of these functions. You can test non-destructively whether an exception has been set with -:c:func:`PyErr_Occurred`. This returns the current exception object, or *NULL* +:cfunc:`PyErr_Occurred`. This returns the current exception object, or *NULL* if no exception has occurred. You normally don't need to call -:c:func:`PyErr_Occurred` to see whether an error occurred in a function call, +:cfunc:`PyErr_Occurred` to see whether an error occurred in a function call, since you should be able to tell from the return value. When a function *f* that calls another function *g* detects that the latter fails, *f* should itself return an error value (usually *NULL* or ``-1``). It -should *not* call one of the :c:func:`PyErr_\*` functions --- one has already +should *not* call one of the :cfunc:`PyErr_\*` functions --- one has already been called by *g*. *f*'s caller is then supposed to also return an error -indication to *its* caller, again *without* calling :c:func:`PyErr_\*`, and so on +indication to *its* caller, again *without* calling :cfunc:`PyErr_\*`, and so on --- the most detailed cause of the error was already reported by the function that first detected it. Once the error reaches the Python interpreter's main loop, this aborts the currently executing Python code and tries to find an exception handler specified by the Python programmer. (There are situations where a module can actually give a more detailed error -message by calling another :c:func:`PyErr_\*` function, and in such cases it is +message by calling another :cfunc:`PyErr_\*` function, and in such cases it is fine to do so. As a general rule, however, this is not necessary, and can cause information about the cause of the error to be lost: most operations can fail for a variety of reasons.) To ignore an exception set by a function call that failed, the exception -condition must be cleared explicitly by calling :c:func:`PyErr_Clear`. The only -time C code should call :c:func:`PyErr_Clear` is if it doesn't want to pass the +condition must be cleared explicitly by calling :cfunc:`PyErr_Clear`. The only +time C code should call :cfunc:`PyErr_Clear` is if it doesn't want to pass the error on to the interpreter but wants to handle it completely by itself (possibly by trying something else, or pretending nothing went wrong). -Every failing :c:func:`malloc` call must be turned into an exception --- the -direct caller of :c:func:`malloc` (or :c:func:`realloc`) must call -:c:func:`PyErr_NoMemory` and return a failure indicator itself. All the -object-creating functions (for example, :c:func:`PyInt_FromLong`) already do -this, so this note is only relevant to those who call :c:func:`malloc` directly. +Every failing :cfunc:`malloc` call must be turned into an exception --- the +direct caller of :cfunc:`malloc` (or :cfunc:`realloc`) must call +:cfunc:`PyErr_NoMemory` and return a failure indicator itself. All the +object-creating functions (for example, :cfunc:`PyInt_FromLong`) already do +this, so this note is only relevant to those who call :cfunc:`malloc` directly. -Also note that, with the important exception of :c:func:`PyArg_ParseTuple` and +Also note that, with the important exception of :cfunc:`PyArg_ParseTuple` and friends, functions that return an integer status usually return a positive value or zero for success and ``-1`` for failure, like Unix system calls. -Finally, be careful to clean up garbage (by making :c:func:`Py_XDECREF` or -:c:func:`Py_DECREF` calls for objects you have already created) when you return +Finally, be careful to clean up garbage (by making :cfunc:`Py_XDECREF` or +:cfunc:`Py_DECREF` calls for objects you have already created) when you return an error indicator! The choice of which exception to raise is entirely yours. There are predeclared C objects corresponding to all built-in Python exceptions, such as -:c:data:`PyExc_ZeroDivisionError`, which you can use directly. Of course, you -should choose exceptions wisely --- don't use :c:data:`PyExc_TypeError` to mean -that a file couldn't be opened (that should probably be :c:data:`PyExc_IOError`). -If something's wrong with the argument list, the :c:func:`PyArg_ParseTuple` -function usually raises :c:data:`PyExc_TypeError`. If you have an argument whose +:cdata:`PyExc_ZeroDivisionError`, which you can use directly. Of course, you +should choose exceptions wisely --- don't use :cdata:`PyExc_TypeError` to mean +that a file couldn't be opened (that should probably be :cdata:`PyExc_IOError`). +If something's wrong with the argument list, the :cfunc:`PyArg_ParseTuple` +function usually raises :cdata:`PyExc_TypeError`. If you have an argument whose value must be in a particular range or must satisfy other conditions, -:c:data:`PyExc_ValueError` is appropriate. +:cdata:`PyExc_ValueError` is appropriate. You can also define a new exception that is unique to your module. For this, you usually declare a static object variable at the beginning of your file:: static PyObject *SpamError; -and initialize it in your module's initialization function (:c:func:`initspam`) +and initialize it in your module's initialization function (:cfunc:`initspam`) with an exception object (leaving out the error checking for now):: PyMODINIT_FUNC @@ -215,14 +215,14 @@ } Note that the Python name for the exception object is :exc:`spam.error`. The -:c:func:`PyErr_NewException` function may create a class with the base class +:cfunc:`PyErr_NewException` function may create a class with the base class being :exc:`Exception` (unless another class is passed in instead of *NULL*), described in :ref:`bltin-exceptions`. -Note also that the :c:data:`SpamError` variable retains a reference to the newly +Note also that the :cdata:`SpamError` variable retains a reference to the newly created exception class; this is intentional! Since the exception could be removed from the module by external code, an owned reference to the class is -needed to ensure that it will not be discarded, causing :c:data:`SpamError` to +needed to ensure that it will not be discarded, causing :cdata:`SpamError` to become a dangling pointer. Should it become a dangling pointer, C code which raises the exception could cause a core dump or other unintended side effects. @@ -230,7 +230,7 @@ sample. The :exc:`spam.error` exception can be raised in your extension module using a -call to :c:func:`PyErr_SetString` as shown below:: +call to :cfunc:`PyErr_SetString` as shown below:: static PyObject * spam_system(PyObject *self, PyObject *args) @@ -262,22 +262,22 @@ It returns *NULL* (the error indicator for functions returning object pointers) if an error is detected in the argument list, relying on the exception set by -:c:func:`PyArg_ParseTuple`. Otherwise the string value of the argument has been -copied to the local variable :c:data:`command`. This is a pointer assignment and +:cfunc:`PyArg_ParseTuple`. Otherwise the string value of the argument has been +copied to the local variable :cdata:`command`. This is a pointer assignment and you are not supposed to modify the string to which it points (so in Standard C, -the variable :c:data:`command` should properly be declared as ``const char +the variable :cdata:`command` should properly be declared as ``const char *command``). -The next statement is a call to the Unix function :c:func:`system`, passing it -the string we just got from :c:func:`PyArg_ParseTuple`:: +The next statement is a call to the Unix function :cfunc:`system`, passing it +the string we just got from :cfunc:`PyArg_ParseTuple`:: sts = system(command); -Our :func:`spam.system` function must return the value of :c:data:`sts` as a -Python object. This is done using the function :c:func:`Py_BuildValue`, which is -something like the inverse of :c:func:`PyArg_ParseTuple`: it takes a format +Our :func:`spam.system` function must return the value of :cdata:`sts` as a +Python object. This is done using the function :cfunc:`Py_BuildValue`, which is +something like the inverse of :cfunc:`PyArg_ParseTuple`: it takes a format string and an arbitrary number of C values, and returns a new Python object. -More info on :c:func:`Py_BuildValue` is given later. :: +More info on :cfunc:`Py_BuildValue` is given later. :: return Py_BuildValue("i", sts); @@ -285,14 +285,14 @@ on the heap in Python!) If you have a C function that returns no useful argument (a function returning -:c:type:`void`), the corresponding Python function must return ``None``. You -need this idiom to do so (which is implemented by the :c:macro:`Py_RETURN_NONE` +:ctype:`void`), the corresponding Python function must return ``None``. You +need this idiom to do so (which is implemented by the :cmacro:`Py_RETURN_NONE` macro):: Py_INCREF(Py_None); return Py_None; -:c:data:`Py_None` is the C name for the special Python object ``None``. It is a +:cdata:`Py_None` is the C name for the special Python object ``None``. It is a genuine Python object rather than a *NULL* pointer, which means "error" in most contexts, as we have seen. @@ -302,7 +302,7 @@ The Module's Method Table and Initialization Function ===================================================== -I promised to show how :c:func:`spam_system` is called from Python programs. +I promised to show how :cfunc:`spam_system` is called from Python programs. First, we need to list its name and address in a "method table":: static PyMethodDef SpamMethods[] = { @@ -316,21 +316,21 @@ Note the third entry (``METH_VARARGS``). This is a flag telling the interpreter the calling convention to be used for the C function. It should normally always be ``METH_VARARGS`` or ``METH_VARARGS | METH_KEYWORDS``; a value of ``0`` means -that an obsolete variant of :c:func:`PyArg_ParseTuple` is used. +that an obsolete variant of :cfunc:`PyArg_ParseTuple` is used. When using only ``METH_VARARGS``, the function should expect the Python-level parameters to be passed in as a tuple acceptable for parsing via -:c:func:`PyArg_ParseTuple`; more information on this function is provided below. +:cfunc:`PyArg_ParseTuple`; more information on this function is provided below. The :const:`METH_KEYWORDS` bit may be set in the third field if keyword arguments should be passed to the function. In this case, the C function should accept a third ``PyObject *`` parameter which will be a dictionary of keywords. -Use :c:func:`PyArg_ParseTupleAndKeywords` to parse the arguments to such a +Use :cfunc:`PyArg_ParseTupleAndKeywords` to parse the arguments to such a function. The method table must be passed to the interpreter in the module's initialization function. The initialization function must be named -:c:func:`initname`, where *name* is the name of the module, and should be the +:cfunc:`initname`, where *name* is the name of the module, and should be the only non-\ ``static`` item defined in the module file:: PyMODINIT_FUNC @@ -344,21 +344,21 @@ declares the function as ``extern "C"``. When the Python program imports module :mod:`spam` for the first time, -:c:func:`initspam` is called. (See below for comments about embedding Python.) -It calls :c:func:`Py_InitModule`, which creates a "module object" (which is +:cfunc:`initspam` is called. (See below for comments about embedding Python.) +It calls :cfunc:`Py_InitModule`, which creates a "module object" (which is inserted in the dictionary ``sys.modules`` under the key ``"spam"``), and inserts built-in function objects into the newly created module based upon the -table (an array of :c:type:`PyMethodDef` structures) that was passed as its -second argument. :c:func:`Py_InitModule` returns a pointer to the module object +table (an array of :ctype:`PyMethodDef` structures) that was passed as its +second argument. :cfunc:`Py_InitModule` returns a pointer to the module object that it creates (which is unused here). It may abort with a fatal error for certain errors, or return *NULL* if the module could not be initialized satisfactorily. -When embedding Python, the :c:func:`initspam` function is not called -automatically unless there's an entry in the :c:data:`_PyImport_Inittab` table. +When embedding Python, the :cfunc:`initspam` function is not called +automatically unless there's an entry in the :cdata:`_PyImport_Inittab` table. The easiest way to handle this is to statically initialize your -statically-linked modules by directly calling :c:func:`initspam` after the call -to :c:func:`Py_Initialize`:: +statically-linked modules by directly calling :cfunc:`initspam` after the call +to :cfunc:`Py_Initialize`:: int main(int argc, char *argv[]) @@ -372,20 +372,18 @@ /* Add a static module */ initspam(); - ... - An example may be found in the file :file:`Demo/embed/demo.c` in the Python source distribution. .. note:: Removing entries from ``sys.modules`` or importing compiled modules into - multiple interpreters within a process (or following a :c:func:`fork` without an - intervening :c:func:`exec`) can create problems for some extension modules. + multiple interpreters within a process (or following a :cfunc:`fork` without an + intervening :cfunc:`exec`) can create problems for some extension modules. Extension module authors should exercise caution when initializing internal data structures. Note also that the :func:`reload` function can be used with extension modules, and will call the module initialization function - (:c:func:`initspam` in the example), but will not load the module again if it was + (:cfunc:`initspam` in the example), but will not load the module again if it was loaded from a dynamically loadable object file (:file:`.so` on Unix, :file:`.dll` on Windows). @@ -449,7 +447,7 @@ Calling a Python function is easy. First, the Python program must somehow pass you the Python function object. You should provide a function (or some other interface) to do this. When this function is called, save a pointer to the -Python function object (be careful to :c:func:`Py_INCREF` it!) in a global +Python function object (be careful to :cfunc:`Py_INCREF` it!) in a global variable --- or wherever you see fit. For example, the following function might be part of a module definition:: @@ -478,10 +476,10 @@ This function must be registered with the interpreter using the :const:`METH_VARARGS` flag; this is described in section :ref:`methodtable`. The -:c:func:`PyArg_ParseTuple` function and its arguments are documented in section +:cfunc:`PyArg_ParseTuple` function and its arguments are documented in section :ref:`parsetuple`. -The macros :c:func:`Py_XINCREF` and :c:func:`Py_XDECREF` increment/decrement the +The macros :cfunc:`Py_XINCREF` and :cfunc:`Py_XDECREF` increment/decrement the reference count of an object and are safe in the presence of *NULL* pointers (but note that *temp* will not be *NULL* in this context). More info on them in section :ref:`refcounts`. @@ -489,12 +487,12 @@ .. index:: single: PyObject_CallObject() Later, when it is time to call the function, you call the C function -:c:func:`PyObject_CallObject`. This function has two arguments, both pointers to +:cfunc:`PyObject_CallObject`. This function has two arguments, both pointers to arbitrary Python objects: the Python function, and the argument list. The argument list must always be a tuple object, whose length is the number of arguments. To call the Python function with no arguments, pass in NULL, or an empty tuple; to call it with one argument, pass a singleton tuple. -:c:func:`Py_BuildValue` returns a tuple when its format string consists of zero +:cfunc:`Py_BuildValue` returns a tuple when its format string consists of zero or more format codes between parentheses. For example:: int arg; @@ -508,25 +506,25 @@ result = PyObject_CallObject(my_callback, arglist); Py_DECREF(arglist); -:c:func:`PyObject_CallObject` returns a Python object pointer: this is the return -value of the Python function. :c:func:`PyObject_CallObject` is +:cfunc:`PyObject_CallObject` returns a Python object pointer: this is the return +value of the Python function. :cfunc:`PyObject_CallObject` is "reference-count-neutral" with respect to its arguments. In the example a new -tuple was created to serve as the argument list, which is :c:func:`Py_DECREF`\ --ed immediately after the :c:func:`PyObject_CallObject` call. +tuple was created to serve as the argument list, which is :cfunc:`Py_DECREF`\ +-ed immediately after the call. -The return value of :c:func:`PyObject_CallObject` is "new": either it is a brand +The return value of :cfunc:`PyObject_CallObject` is "new": either it is a brand new object, or it is an existing object whose reference count has been incremented. So, unless you want to save it in a global variable, you should -somehow :c:func:`Py_DECREF` the result, even (especially!) if you are not +somehow :cfunc:`Py_DECREF` the result, even (especially!) if you are not interested in its value. Before you do this, however, it is important to check that the return value isn't *NULL*. If it is, the Python function terminated by raising an exception. -If the C code that called :c:func:`PyObject_CallObject` is called from Python, it +If the C code that called :cfunc:`PyObject_CallObject` is called from Python, it should now return an error indication to its Python caller, so the interpreter can print a stack trace, or the calling Python code can handle the exception. If this is not possible or desirable, the exception should be cleared by calling -:c:func:`PyErr_Clear`. For example:: +:cfunc:`PyErr_Clear`. For example:: if (result == NULL) return NULL; /* Pass error back */ @@ -534,12 +532,12 @@ Py_DECREF(result); Depending on the desired interface to the Python callback function, you may also -have to provide an argument list to :c:func:`PyObject_CallObject`. In some cases +have to provide an argument list to :cfunc:`PyObject_CallObject`. In some cases the argument list is also provided by the Python program, through the same interface that specified the callback function. It can then be saved and used in the same manner as the function object. In other cases, you may have to construct a new tuple to pass as the argument list. The simplest way to do this -is to call :c:func:`Py_BuildValue`. For example, if you want to pass an integral +is to call :cfunc:`Py_BuildValue`. For example, if you want to pass an integral event code, you might use the following code:: PyObject *arglist; @@ -554,11 +552,11 @@ Note the placement of ``Py_DECREF(arglist)`` immediately after the call, before the error check! Also note that strictly speaking this code is not complete: -:c:func:`Py_BuildValue` may run out of memory, and this should be checked. +:cfunc:`Py_BuildValue` may run out of memory, and this should be checked. You may also call a function with keyword arguments by using -:c:func:`PyObject_Call`, which supports arguments and keyword arguments. As in -the above example, we use :c:func:`Py_BuildValue` to construct the dictionary. :: +:cfunc:`PyObject_Call`, which supports arguments and keyword arguments. As in +the above example, we use :cfunc:`Py_BuildValue` to construct the dictionary. :: PyObject *dict; ... @@ -578,7 +576,7 @@ .. index:: single: PyArg_ParseTuple() -The :c:func:`PyArg_ParseTuple` function is declared as follows:: +The :cfunc:`PyArg_ParseTuple` function is declared as follows:: int PyArg_ParseTuple(PyObject *arg, char *format, ...); @@ -588,7 +586,7 @@ Manual. The remaining arguments must be addresses of variables whose type is determined by the format string. -Note that while :c:func:`PyArg_ParseTuple` checks that the Python arguments have +Note that while :cfunc:`PyArg_ParseTuple` checks that the Python arguments have the required types, it cannot check the validity of the addresses of C variables passed to the call: if you make mistakes there, your code will probably crash or at least overwrite random bits in memory. So be careful! @@ -665,17 +663,17 @@ .. index:: single: PyArg_ParseTupleAndKeywords() -The :c:func:`PyArg_ParseTupleAndKeywords` function is declared as follows:: +The :cfunc:`PyArg_ParseTupleAndKeywords` function is declared as follows:: int PyArg_ParseTupleAndKeywords(PyObject *arg, PyObject *kwdict, char *format, char *kwlist[], ...); The *arg* and *format* parameters are identical to those of the -:c:func:`PyArg_ParseTuple` function. The *kwdict* parameter is the dictionary of +:cfunc:`PyArg_ParseTuple` function. The *kwdict* parameter is the dictionary of keywords received as the third parameter from the Python runtime. The *kwlist* parameter is a *NULL*-terminated list of strings which identify the parameters; the names are matched with the type information from *format* from left to -right. On success, :c:func:`PyArg_ParseTupleAndKeywords` returns true, otherwise +right. On success, :cfunc:`PyArg_ParseTupleAndKeywords` returns true, otherwise it returns false and raises an appropriate exception. .. note:: @@ -739,19 +737,19 @@ Building Arbitrary Values ========================= -This function is the counterpart to :c:func:`PyArg_ParseTuple`. It is declared +This function is the counterpart to :cfunc:`PyArg_ParseTuple`. It is declared as follows:: PyObject *Py_BuildValue(char *format, ...); It recognizes a set of format units similar to the ones recognized by -:c:func:`PyArg_ParseTuple`, but the arguments (which are input to the function, +:cfunc:`PyArg_ParseTuple`, but the arguments (which are input to the function, not output) must not be pointers, just values. It returns a new Python object, suitable for returning from a C function called from Python. -One difference with :c:func:`PyArg_ParseTuple`: while the latter requires its +One difference with :cfunc:`PyArg_ParseTuple`: while the latter requires its first argument to be a tuple (since Python argument lists are always represented -as tuples internally), :c:func:`Py_BuildValue` does not always build a tuple. It +as tuples internally), :cfunc:`Py_BuildValue` does not always build a tuple. It builds a tuple only if its format string contains two or more format units. If the format string is empty, it returns ``None``; if it contains exactly one format unit, it returns whatever object is described by that format unit. To @@ -783,18 +781,18 @@ In languages like C or C++, the programmer is responsible for dynamic allocation and deallocation of memory on the heap. In C, this is done using the functions -:c:func:`malloc` and :c:func:`free`. In C++, the operators ``new`` and +:cfunc:`malloc` and :cfunc:`free`. In C++, the operators ``new`` and ``delete`` are used with essentially the same meaning and we'll restrict the following discussion to the C case. -Every block of memory allocated with :c:func:`malloc` should eventually be -returned to the pool of available memory by exactly one call to :c:func:`free`. -It is important to call :c:func:`free` at the right time. If a block's address -is forgotten but :c:func:`free` is not called for it, the memory it occupies +Every block of memory allocated with :cfunc:`malloc` should eventually be +returned to the pool of available memory by exactly one call to :cfunc:`free`. +It is important to call :cfunc:`free` at the right time. If a block's address +is forgotten but :cfunc:`free` is not called for it, the memory it occupies cannot be reused until the program terminates. This is called a :dfn:`memory -leak`. On the other hand, if a program calls :c:func:`free` for a block and then +leak`. On the other hand, if a program calls :cfunc:`free` for a block and then continues to use the block, it creates a conflict with re-use of the block -through another :c:func:`malloc` call. This is called :dfn:`using freed memory`. +through another :cfunc:`malloc` call. This is called :dfn:`using freed memory`. It has the same bad consequences as referencing uninitialized data --- core dumps, wrong results, mysterious crashes. @@ -811,7 +809,7 @@ important to prevent leaks from happening by having a coding convention or strategy that minimizes this kind of errors. -Since Python makes heavy use of :c:func:`malloc` and :c:func:`free`, it needs a +Since Python makes heavy use of :cfunc:`malloc` and :cfunc:`free`, it needs a strategy to avoid memory leaks as well as the use of freed memory. The chosen method is called :dfn:`reference counting`. The principle is simple: every object contains a counter, which is incremented when a reference to the object @@ -823,11 +821,11 @@ (Sometimes, reference counting is also referred to as a garbage collection strategy, hence my use of "automatic" to distinguish the two.) The big advantage of automatic garbage collection is that the user doesn't need to call -:c:func:`free` explicitly. (Another claimed advantage is an improvement in speed +:cfunc:`free` explicitly. (Another claimed advantage is an improvement in speed or memory usage --- this is no hard fact however.) The disadvantage is that for C, there is no truly portable automatic garbage collector, while reference -counting can be implemented portably (as long as the functions :c:func:`malloc` -and :c:func:`free` are available --- which the C Standard guarantees). Maybe some +counting can be implemented portably (as long as the functions :cfunc:`malloc` +and :cfunc:`free` are available --- which the C Standard guarantees). Maybe some day a sufficiently portable automatic garbage collector will be available for C. Until then, we'll have to live with reference counts. @@ -845,9 +843,9 @@ The cycle detector is able to detect garbage cycles and can reclaim them so long as there are no finalizers implemented in Python (:meth:`__del__` methods). When there are such finalizers, the detector exposes the cycles through the -:mod:`gc` module (specifically, the :attr:`~gc.garbage` variable in that module). -The :mod:`gc` module also exposes a way to run the detector (the -:func:`~gc.collect` function), as well as configuration +:mod:`gc` module (specifically, the +``garbage`` variable in that module). The :mod:`gc` module also exposes a way +to run the detector (the :func:`collect` function), as well as configuration interfaces and the ability to disable the detector at runtime. The cycle detector is considered an optional component; though it is included by default, it can be disabled at build time using the :option:`--without-cycle-gc` option @@ -863,9 +861,9 @@ ---------------------------- There are two macros, ``Py_INCREF(x)`` and ``Py_DECREF(x)``, which handle the -incrementing and decrementing of the reference count. :c:func:`Py_DECREF` also +incrementing and decrementing of the reference count. :cfunc:`Py_DECREF` also frees the object when the count reaches zero. For flexibility, it doesn't call -:c:func:`free` directly --- rather, it makes a call through a function pointer in +:cfunc:`free` directly --- rather, it makes a call through a function pointer in the object's :dfn:`type object`. For this purpose (and others), every object also contains a pointer to its type object. @@ -873,13 +871,13 @@ Let's first introduce some terms. Nobody "owns" an object; however, you can :dfn:`own a reference` to an object. An object's reference count is now defined as the number of owned references to it. The owner of a reference is -responsible for calling :c:func:`Py_DECREF` when the reference is no longer +responsible for calling :cfunc:`Py_DECREF` when the reference is no longer needed. Ownership of a reference can be transferred. There are three ways to -dispose of an owned reference: pass it on, store it, or call :c:func:`Py_DECREF`. +dispose of an owned reference: pass it on, store it, or call :cfunc:`Py_DECREF`. Forgetting to dispose of an owned reference creates a memory leak. It is also possible to :dfn:`borrow` [#]_ a reference to an object. The -borrower of a reference should not call :c:func:`Py_DECREF`. The borrower must +borrower of a reference should not call :cfunc:`Py_DECREF`. The borrower must not hold on to the object longer than the owner from which it was borrowed. Using a borrowed reference after the owner has disposed of it risks using freed memory and should be avoided completely. [#]_ @@ -893,7 +891,7 @@ disposed of it. A borrowed reference can be changed into an owned reference by calling -:c:func:`Py_INCREF`. This does not affect the status of the owner from which the +:cfunc:`Py_INCREF`. This does not affect the status of the owner from which the reference was borrowed --- it creates a new owned reference, and gives full owner responsibilities (the new owner must dispose of the reference properly, as well as the previous owner). @@ -910,36 +908,36 @@ Most functions that return a reference to an object pass on ownership with the reference. In particular, all functions whose function it is to create a new -object, such as :c:func:`PyInt_FromLong` and :c:func:`Py_BuildValue`, pass +object, such as :cfunc:`PyInt_FromLong` and :cfunc:`Py_BuildValue`, pass ownership to the receiver. Even if the object is not actually new, you still receive ownership of a new reference to that object. For instance, -:c:func:`PyInt_FromLong` maintains a cache of popular values and can return a +:cfunc:`PyInt_FromLong` maintains a cache of popular values and can return a reference to a cached item. Many functions that extract objects from other objects also transfer ownership -with the reference, for instance :c:func:`PyObject_GetAttrString`. The picture +with the reference, for instance :cfunc:`PyObject_GetAttrString`. The picture is less clear, here, however, since a few common routines are exceptions: -:c:func:`PyTuple_GetItem`, :c:func:`PyList_GetItem`, :c:func:`PyDict_GetItem`, and -:c:func:`PyDict_GetItemString` all return references that you borrow from the +:cfunc:`PyTuple_GetItem`, :cfunc:`PyList_GetItem`, :cfunc:`PyDict_GetItem`, and +:cfunc:`PyDict_GetItemString` all return references that you borrow from the tuple, list or dictionary. -The function :c:func:`PyImport_AddModule` also returns a borrowed reference, even +The function :cfunc:`PyImport_AddModule` also returns a borrowed reference, even though it may actually create the object it returns: this is possible because an owned reference to the object is stored in ``sys.modules``. When you pass an object reference into another function, in general, the function borrows the reference from you --- if it needs to store it, it will use -:c:func:`Py_INCREF` to become an independent owner. There are exactly two -important exceptions to this rule: :c:func:`PyTuple_SetItem` and -:c:func:`PyList_SetItem`. These functions take over ownership of the item passed -to them --- even if they fail! (Note that :c:func:`PyDict_SetItem` and friends +:cfunc:`Py_INCREF` to become an independent owner. There are exactly two +important exceptions to this rule: :cfunc:`PyTuple_SetItem` and +:cfunc:`PyList_SetItem`. These functions take over ownership of the item passed +to them --- even if they fail! (Note that :cfunc:`PyDict_SetItem` and friends don't take over ownership --- they are "normal.") When a C function is called from Python, it borrows references to its arguments from the caller. The caller owns a reference to the object, so the borrowed reference's lifetime is guaranteed until the function returns. Only when such a borrowed reference must be stored or passed on, it must be turned into an owned -reference by calling :c:func:`Py_INCREF`. +reference by calling :cfunc:`Py_INCREF`. The object reference returned from a C function that is called from Python must be an owned reference --- ownership is transferred from the function to its @@ -955,7 +953,7 @@ can lead to problems. These all have to do with implicit invocations of the interpreter, which can cause the owner of a reference to dispose of it. -The first and most important case to know about is using :c:func:`Py_DECREF` on +The first and most important case to know about is using :cfunc:`Py_DECREF` on an unrelated object while borrowing a reference to a list item. For instance:: void @@ -971,7 +969,7 @@ ``list[1]`` with the value ``0``, and finally prints the borrowed reference. Looks harmless, right? But it's not! -Let's follow the control flow into :c:func:`PyList_SetItem`. The list owns +Let's follow the control flow into :cfunc:`PyList_SetItem`. The list owns references to all its items, so when item 1 is replaced, it has to dispose of the original item 1. Now let's suppose the original item 1 was an instance of a user-defined class, and let's further suppose that the class defined a @@ -980,8 +978,8 @@ Since it is written in Python, the :meth:`__del__` method can execute arbitrary Python code. Could it perhaps do something to invalidate the reference to -``item`` in :c:func:`bug`? You bet! Assuming that the list passed into -:c:func:`bug` is accessible to the :meth:`__del__` method, it could execute a +``item`` in :cfunc:`bug`? You bet! Assuming that the list passed into +:cfunc:`bug` is accessible to the :meth:`__del__` method, it could execute a statement to the effect of ``del list[0]``, and assuming this was the last reference to that object, it would free the memory associated with it, thereby invalidating ``item``. @@ -1008,8 +1006,8 @@ threads. Normally, multiple threads in the Python interpreter can't get in each other's way, because there is a global lock protecting Python's entire object space. However, it is possible to temporarily release this lock using the macro -:c:macro:`Py_BEGIN_ALLOW_THREADS`, and to re-acquire it using -:c:macro:`Py_END_ALLOW_THREADS`. This is common around blocking I/O calls, to +:cmacro:`Py_BEGIN_ALLOW_THREADS`, and to re-acquire it using +:cmacro:`Py_END_ALLOW_THREADS`. This is common around blocking I/O calls, to let other threads use the processor while waiting for the I/O to complete. Obviously, the following function has the same problem as the previous one:: @@ -1038,11 +1036,11 @@ redundant tests and the code would run more slowly. It is better to test for *NULL* only at the "source:" when a pointer that may be -*NULL* is received, for example, from :c:func:`malloc` or from a function that +*NULL* is received, for example, from :cfunc:`malloc` or from a function that may raise an exception. -The macros :c:func:`Py_INCREF` and :c:func:`Py_DECREF` do not check for *NULL* -pointers --- however, their variants :c:func:`Py_XINCREF` and :c:func:`Py_XDECREF` +The macros :cfunc:`Py_INCREF` and :cfunc:`Py_DECREF` do not check for *NULL* +pointers --- however, their variants :cfunc:`Py_XINCREF` and :cfunc:`Py_XDECREF` do. The macros for checking for a particular object type (``Pytype_Check()``) don't @@ -1116,7 +1114,7 @@ Python provides a special mechanism to pass C-level information (pointers) from one extension module to another one: Capsules. A Capsule is a Python data type -which stores a pointer (:c:type:`void \*`). Capsules can only be created and +which stores a pointer (:ctype:`void \*`). Capsules can only be created and accessed via their C API, but they can be passed around like any other Python object. In particular, they can be assigned to a name in an extension module's namespace. Other extension modules can then import this module, retrieve the @@ -1129,8 +1127,8 @@ different ways between the module providing the code and the client modules. Whichever method you choose, it's important to name your Capsules properly. -The function :c:func:`PyCapsule_New` takes a name parameter -(:c:type:`const char \*`); you're permitted to pass in a *NULL* name, but +The function :cfunc:`PyCapsule_New` takes a name parameter +(:ctype:`const char \*`); you're permitted to pass in a *NULL* name, but we strongly encourage you to specify a name. Properly named Capsules provide a degree of runtime type-safety; there is no feasible way to tell one unnamed Capsule from another. @@ -1140,7 +1138,7 @@ modulename.attributename -The convenience function :c:func:`PyCapsule_Import` makes it easy to +The convenience function :cfunc:`PyCapsule_Import` makes it easy to load a C API provided via a Capsule, but only if the Capsule's name matches this convention. This behavior gives C API users a high degree of certainty that the Capsule they load contains the correct C API. @@ -1148,19 +1146,19 @@ The following example demonstrates an approach that puts most of the burden on the writer of the exporting module, which is appropriate for commonly used library modules. It stores all C API pointers (just one in the example!) in an -array of :c:type:`void` pointers which becomes the value of a Capsule. The header +array of :ctype:`void` pointers which becomes the value of a Capsule. The header file corresponding to the module provides a macro that takes care of importing the module and retrieving its C API pointers; client modules only have to call this macro before accessing the C API. The exporting module is a modification of the :mod:`spam` module from section :ref:`extending-simpleexample`. The function :func:`spam.system` does not call -the C library function :c:func:`system` directly, but a function -:c:func:`PySpam_System`, which would of course do something more complicated in +the C library function :cfunc:`system` directly, but a function +:cfunc:`PySpam_System`, which would of course do something more complicated in reality (such as adding "spam" to every command). This function -:c:func:`PySpam_System` is also exported to other extension modules. +:cfunc:`PySpam_System` is also exported to other extension modules. -The function :c:func:`PySpam_System` is a plain C function, declared +The function :cfunc:`PySpam_System` is a plain C function, declared ``static`` like everything else:: static int @@ -1169,7 +1167,7 @@ return system(command); } -The function :c:func:`spam_system` is modified in a trivial way:: +The function :cfunc:`spam_system` is modified in a trivial way:: static PyObject * spam_system(PyObject *self, PyObject *args) @@ -1272,8 +1270,8 @@ #endif /* !defined(Py_SPAMMODULE_H) */ All that a client module must do in order to have access to the function -:c:func:`PySpam_System` is to call the function (or rather macro) -:c:func:`import_spam` in its initialization function:: +:cfunc:`PySpam_System` is to call the function (or rather macro) +:cfunc:`import_spam` in its initialization function:: PyMODINIT_FUNC initclient(void) diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/extending/index.rst --- a/Doc/extending/index.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/extending/index.rst Sun Jul 20 10:52:46 2014 -0400 @@ -4,13 +4,16 @@ Extending and Embedding the Python Interpreter ################################################## +:Release: |version| +:Date: |today| + This document describes how to write modules in C or C++ to extend the Python -interpreter with new modules. Those modules can not only define new functions -but also new object types and their methods. The document also describes how -to embed the Python interpreter in another application, for use as an extension -language. Finally, it shows how to compile and link extension modules so that -they can be loaded dynamically (at run time) into the interpreter, if the -underlying operating system supports this feature. +interpreter with new modules. Those modules can define new functions but also +new object types and their methods. The document also describes how to embed +the Python interpreter in another application, for use as an extension language. +Finally, it shows how to compile and link extension modules so that they can be +loaded dynamically (at run time) into the interpreter, if the underlying +operating system supports this feature. This document assumes basic knowledge about Python. For an informal introduction to the language, see :ref:`tutorial-index`. :ref:`reference-index` @@ -21,15 +24,6 @@ For a detailed description of the whole Python/C API, see the separate :ref:`c-api-index`. -.. note:: - - This guide only covers the basic tools for creating extensions provided - as part of this version of CPython. Third party tools may offer simpler - alternatives. Refer to the `binary extensions section - `__ - in the Python Packaging User Guide for more information. - - .. toctree:: :maxdepth: 2 :numbered: diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/extending/newtypes.rst --- a/Doc/extending/newtypes.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/extending/newtypes.rst Sun Jul 20 10:52:46 2014 -0400 @@ -34,7 +34,7 @@ ========== The Python runtime sees all Python objects as variables of type -:c:type:`PyObject\*`. A :c:type:`PyObject` is not a very magnificent object - it +:ctype:`PyObject\*`. A :ctype:`PyObject` is not a very magnificent object - it just contains the refcount and a pointer to the object's "type object". This is where the action is; the type object determines which (C) functions get called when, for instance, an attribute gets looked up on an object or it is multiplied @@ -103,7 +103,7 @@ "Noddy objects", /* tp_doc */ }; -Now if you go and look up the definition of :c:type:`PyTypeObject` in +Now if you go and look up the definition of :ctype:`PyTypeObject` in :file:`object.h` you'll see that it has many more fields that the definition above. The remaining fields will be filled with zeros by the C compiler, and it's common practice to not specify them explicitly unless you need them. @@ -119,7 +119,7 @@ as the type of a type object is "type", but this isn't strictly conforming C and some compilers complain. Fortunately, this member will be filled in for us by -:c:func:`PyType_Ready`. :: +:cfunc:`PyType_Ready`. :: 0, /* ob_size */ @@ -145,16 +145,16 @@ sizeof(noddy_NoddyObject), /* tp_basicsize */ This is so that Python knows how much memory to allocate when you call -:c:func:`PyObject_New`. +:cfunc:`PyObject_New`. .. note:: If you want your type to be subclassable from Python, and your type has the same - :c:member:`~PyTypeObject.tp_basicsize` as its base type, you may have problems with multiple + :attr:`tp_basicsize` as its base type, you may have problems with multiple inheritance. A Python subclass of your type will have to list your type first - in its :attr:`~class.__bases__`, or else it will not be able to call your type's + in its :attr:`__bases__`, or else it will not be able to call your type's :meth:`__new__` method without getting an error. You can avoid this problem by - ensuring that your type has a larger value for :c:member:`~PyTypeObject.tp_basicsize` than its + ensuring that your type has a larger value for :attr:`tp_basicsize` than its base type does. Most of the time, this will be true anyway, because either your base type will be :class:`object`, or else you will be adding data members to your base type, and therefore increasing its size. @@ -174,7 +174,7 @@ All types should include this constant in their flags. It enables all of the members defined by the current version of Python. -We provide a doc string for the type in :c:member:`~PyTypeObject.tp_doc`. :: +We provide a doc string for the type in :attr:`tp_doc`. :: "Noddy objects", /* tp_doc */ @@ -183,14 +183,14 @@ the module. We'll expand this example later to have more interesting behavior. For now, all we want to be able to do is to create new :class:`Noddy` objects. -To enable object creation, we have to provide a :c:member:`~PyTypeObject.tp_new` implementation. +To enable object creation, we have to provide a :attr:`tp_new` implementation. In this case, we can just use the default implementation provided by the API -function :c:func:`PyType_GenericNew`. We'd like to just assign this to the -:c:member:`~PyTypeObject.tp_new` slot, but we can't, for portability sake, On some platforms or +function :cfunc:`PyType_GenericNew`. We'd like to just assign this to the +:attr:`tp_new` slot, but we can't, for portability sake, On some platforms or compilers, we can't statically initialize a structure member with a function -defined in another C module, so, instead, we'll assign the :c:member:`~PyTypeObject.tp_new` slot +defined in another C module, so, instead, we'll assign the :attr:`tp_new` slot in the module initialization function just before calling -:c:func:`PyType_Ready`:: +:cfunc:`PyType_Ready`:: noddy_NoddyType.tp_new = PyType_GenericNew; if (PyType_Ready(&noddy_NoddyType) < 0) @@ -200,7 +200,7 @@ for a later section! Everything else in the file should be familiar, except for some code in -:c:func:`initnoddy`:: +:cfunc:`initnoddy`:: if (PyType_Ready(&noddy_NoddyType) < 0) return; @@ -283,13 +283,13 @@ self->ob_type->tp_free((PyObject*)self); } -which is assigned to the :c:member:`~PyTypeObject.tp_dealloc` member:: +which is assigned to the :attr:`tp_dealloc` member:: (destructor)Noddy_dealloc, /*tp_dealloc*/ This method decrements the reference counts of the two Python attributes. We use -:c:func:`Py_XDECREF` here because the :attr:`first` and :attr:`last` members -could be *NULL*. It then calls the :c:member:`~PyTypeObject.tp_free` member of the object's type +:cfunc:`Py_XDECREF` here because the :attr:`first` and :attr:`last` members +could be *NULL*. It then calls the :attr:`tp_free` member of the object's type to free the object's memory. Note that the object's type might not be :class:`NoddyType`, because the object may be an instance of a subclass. @@ -323,7 +323,7 @@ return (PyObject *)self; } -and install it in the :c:member:`~PyTypeObject.tp_new` member:: +and install it in the :attr:`tp_new` member:: Noddy_new, /* tp_new */ @@ -334,8 +334,8 @@ the initial values of instance variables. In this case, we use the new method to make sure that the initial values of the members :attr:`first` and :attr:`last` are not *NULL*. If we didn't care whether the initial values were -*NULL*, we could have used :c:func:`PyType_GenericNew` as our new method, as we -did before. :c:func:`PyType_GenericNew` initializes all of the instance variable +*NULL*, we could have used :cfunc:`PyType_GenericNew` as our new method, as we +did before. :cfunc:`PyType_GenericNew` initializes all of the instance variable members to *NULL*. The new method is a static method that is passed the type being instantiated and @@ -344,16 +344,16 @@ often ignore the arguments, leaving the argument handling to initializer methods. Note that if the type supports subclassing, the type passed may not be the type being defined. The new method calls the tp_alloc slot to allocate -memory. We don't fill the :c:member:`~PyTypeObject.tp_alloc` slot ourselves. Rather -:c:func:`PyType_Ready` fills it for us by inheriting it from our base class, +memory. We don't fill the :attr:`tp_alloc` slot ourselves. Rather +:cfunc:`PyType_Ready` fills it for us by inheriting it from our base class, which is :class:`object` by default. Most types use the default allocation. .. note:: - If you are creating a co-operative :c:member:`~PyTypeObject.tp_new` (one that calls a base type's - :c:member:`~PyTypeObject.tp_new` or :meth:`__new__`), you must *not* try to determine what method + If you are creating a co-operative :attr:`tp_new` (one that calls a base type's + :attr:`tp_new` or :meth:`__new__`), you must *not* try to determine what method to call using method resolution order at runtime. Always statically determine - what type you are going to call, and call its :c:member:`~PyTypeObject.tp_new` directly, or via + what type you are going to call, and call its :attr:`tp_new` directly, or via ``type->tp_base->tp_new``. If you do not do this, Python subclasses of your type that also inherit from other Python-defined classes may not work correctly. (Specifically, you may not be able to create instances of such subclasses @@ -390,11 +390,11 @@ return 0; } -by filling the :c:member:`~PyTypeObject.tp_init` slot. :: +by filling the :attr:`tp_init` slot. :: (initproc)Noddy_init, /* tp_init */ -The :c:member:`~PyTypeObject.tp_init` slot is exposed in Python as the :meth:`__init__` method. It +The :attr:`tp_init` slot is exposed in Python as the :meth:`__init__` method. It is used to initialize an object after it's created. Unlike the new method, we can't guarantee that the initializer is called. The initializer isn't called when unpickling objects and it can be overridden. Our initializer accepts @@ -424,7 +424,7 @@ * when we know that deallocation of the object [#]_ will not cause any calls back into our type's code -* when decrementing a reference count in a :c:member:`~PyTypeObject.tp_dealloc` handler when +* when decrementing a reference count in a :attr:`tp_dealloc` handler when garbage-collections is not supported [#]_ We want to expose our instance variables as attributes. There are a @@ -440,7 +440,7 @@ {NULL} /* Sentinel */ }; -and put the definitions in the :c:member:`~PyTypeObject.tp_members` slot:: +and put the definitions in the :attr:`tp_members` slot:: Noddy_members, /* tp_members */ @@ -516,7 +516,7 @@ {NULL} /* Sentinel */ }; -and assign them to the :c:member:`~PyTypeObject.tp_methods` slot:: +and assign them to the :attr:`tp_methods` slot:: Noddy_methods, /* tp_methods */ @@ -530,8 +530,8 @@ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/ -We rename :c:func:`initnoddy` to :c:func:`initnoddy2` and update the module name -passed to :c:func:`Py_InitModule3`. +We rename :cfunc:`initnoddy` to :cfunc:`initnoddy2` and update the module name +passed to :cfunc:`Py_InitModule3`. Finally, we update our :file:`setup.py` file to build the new module:: @@ -597,7 +597,7 @@ deleted. In our setter, we raise an error if the attribute is deleted or if the attribute value is not a string. -We create an array of :c:type:`PyGetSetDef` structures:: +We create an array of :ctype:`PyGetSetDef` structures:: static PyGetSetDef Noddy_getseters[] = { {"first", @@ -611,13 +611,13 @@ {NULL} /* Sentinel */ }; -and register it in the :c:member:`~PyTypeObject.tp_getset` slot:: +and register it in the :attr:`tp_getset` slot:: Noddy_getseters, /* tp_getset */ to register our attribute getters and setters. -The last item in a :c:type:`PyGetSetDef` structure is the closure mentioned +The last item in a :ctype:`PyGetSetDef` structure is the closure mentioned above. In this case, we aren't using the closure, so we just pass *NULL*. We also remove the member definitions for these attributes:: @@ -628,7 +628,7 @@ {NULL} /* Sentinel */ }; -We also need to update the :c:member:`~PyTypeObject.tp_init` handler to only allow strings [#]_ to +We also need to update the :attr:`tp_init` handler to only allow strings [#]_ to be passed:: static int @@ -662,8 +662,8 @@ With these changes, we can assure that the :attr:`first` and :attr:`last` members are never *NULL* so we can remove checks for *NULL* values in almost all -cases. This means that most of the :c:func:`Py_XDECREF` calls can be converted to -:c:func:`Py_DECREF` calls. The only place we can't change these calls is in the +cases. This means that most of the :cfunc:`Py_XDECREF` calls can be converted to +:cfunc:`Py_DECREF` calls. The only place we can't change these calls is in the deallocator, where there is the possibility that the initialization of these members failed in the constructor. @@ -728,13 +728,13 @@ } For each subobject that can participate in cycles, we need to call the -:c:func:`visit` function, which is passed to the traversal method. The -:c:func:`visit` function takes as arguments the subobject and the extra argument +:cfunc:`visit` function, which is passed to the traversal method. The +:cfunc:`visit` function takes as arguments the subobject and the extra argument *arg* passed to the traversal method. It returns an integer value that must be returned if it is non-zero. -Python 2.4 and higher provide a :c:func:`Py_VISIT` macro that automates calling -visit functions. With :c:func:`Py_VISIT`, :c:func:`Noddy_traverse` can be +Python 2.4 and higher provide a :cfunc:`Py_VISIT` macro that automates calling +visit functions. With :cfunc:`Py_VISIT`, :cfunc:`Noddy_traverse` can be simplified:: static int @@ -747,8 +747,8 @@ .. note:: - Note that the :c:member:`~PyTypeObject.tp_traverse` implementation must name its arguments exactly - *visit* and *arg* in order to use :c:func:`Py_VISIT`. This is to encourage + Note that the :attr:`tp_traverse` implementation must name its arguments exactly + *visit* and *arg* in order to use :cfunc:`Py_VISIT`. This is to encourage uniformity across these boring implementations. We also need to provide a method for clearing any subobjects that can @@ -778,19 +778,19 @@ self->ob_type->tp_free((PyObject*)self); } -Notice the use of a temporary variable in :c:func:`Noddy_clear`. We use the +Notice the use of a temporary variable in :cfunc:`Noddy_clear`. We use the temporary variable so that we can set each member to *NULL* before decrementing its reference count. We do this because, as was discussed earlier, if the reference count drops to zero, we might cause code to run that calls back into the object. In addition, because we now support garbage collection, we also have to worry about code being run that triggers garbage collection. If garbage -collection is run, our :c:member:`~PyTypeObject.tp_traverse` handler could get called. We can't -take a chance of having :c:func:`Noddy_traverse` called when a member's reference +collection is run, our :attr:`tp_traverse` handler could get called. We can't +take a chance of having :cfunc:`Noddy_traverse` called when a member's reference count has dropped to zero and its value hasn't been set to *NULL*. -Python 2.4 and higher provide a :c:func:`Py_CLEAR` that automates the careful -decrementing of reference counts. With :c:func:`Py_CLEAR`, the -:c:func:`Noddy_clear` function can be simplified:: +Python 2.4 and higher provide a :cfunc:`Py_CLEAR` that automates the careful +decrementing of reference counts. With :cfunc:`Py_CLEAR`, the +:cfunc:`Noddy_clear` function can be simplified:: static int Noddy_clear(Noddy *self) @@ -804,8 +804,8 @@ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC, /*tp_flags*/ -That's pretty much it. If we had written custom :c:member:`~PyTypeObject.tp_alloc` or -:c:member:`~PyTypeObject.tp_free` slots, we'd need to modify them for cyclic-garbage collection. +That's pretty much it. If we had written custom :attr:`tp_alloc` or +:attr:`tp_free` slots, we'd need to modify them for cyclic-garbage collection. Most extensions will use the versions automatically provided. @@ -845,7 +845,7 @@ The primary difference for derived type objects is that the base type's object structure must be the first value. The base type will already include the -:c:func:`PyObject_HEAD` at the beginning of its structure. +:cfunc:`PyObject_HEAD` at the beginning of its structure. When a Python object is a :class:`Shoddy` instance, its *PyObject\** pointer can be safely cast to both *PyListObject\** and *Shoddy\**. :: @@ -864,13 +864,13 @@ This pattern is important when writing a type with custom :attr:`new` and :attr:`dealloc` methods. The :attr:`new` method should not actually create the -memory for the object with :c:member:`~PyTypeObject.tp_alloc`, that will be handled by the base -class when calling its :c:member:`~PyTypeObject.tp_new`. +memory for the object with :attr:`tp_alloc`, that will be handled by the base +class when calling its :attr:`tp_new`. -When filling out the :c:func:`PyTypeObject` for the :class:`Shoddy` type, you see -a slot for :c:func:`tp_base`. Due to cross platform compiler issues, you can't -fill that field directly with the :c:func:`PyList_Type`; it can be done later in -the module's :c:func:`init` function. :: +When filling out the :cfunc:`PyTypeObject` for the :class:`Shoddy` type, you see +a slot for :cfunc:`tp_base`. Due to cross platform compiler issues, you can't +fill that field directly with the :cfunc:`PyList_Type`; it can be done later in +the module's :cfunc:`init` function. :: PyMODINIT_FUNC initshoddy(void) @@ -889,12 +889,12 @@ PyModule_AddObject(m, "Shoddy", (PyObject *) &ShoddyType); } -Before calling :c:func:`PyType_Ready`, the type structure must have the -:c:member:`~PyTypeObject.tp_base` slot filled in. When we are deriving a new type, it is not -necessary to fill out the :c:member:`~PyTypeObject.tp_alloc` slot with :c:func:`PyType_GenericNew` +Before calling :cfunc:`PyType_Ready`, the type structure must have the +:attr:`tp_base` slot filled in. When we are deriving a new type, it is not +necessary to fill out the :attr:`tp_alloc` slot with :cfunc:`PyType_GenericNew` -- the allocate function from the base type will be inherited. -After that, calling :c:func:`PyType_Ready` and adding the type object to the +After that, calling :cfunc:`PyType_Ready` and adding the type object to the module is the same as with the basic :class:`Noddy` examples. @@ -906,7 +906,7 @@ This section aims to give a quick fly-by on the various type methods you can implement and what they do. -Here is the definition of :c:type:`PyTypeObject`, with some fields only used in +Here is the definition of :ctype:`PyTypeObject`, with some fields only used in debug builds omitted: .. literalinclude:: ../includes/typestruct.h @@ -934,7 +934,7 @@ These fields tell the runtime how much memory to allocate when new objects of this type are created. Python has some built-in support for variable length -structures (think: strings, lists) which is where the :c:member:`~PyTypeObject.tp_itemsize` field +structures (think: strings, lists) which is where the :attr:`tp_itemsize` field comes in. This will be dealt with later. :: char *tp_doc; @@ -984,8 +984,8 @@ executed may detect that an exception has been set. This can lead to misleading errors from the interpreter. The proper way to protect against this is to save a pending exception before performing the unsafe action, and restoring it when -done. This can be done using the :c:func:`PyErr_Fetch` and -:c:func:`PyErr_Restore` functions:: +done. This can be done using the :cfunc:`PyErr_Fetch` and +:cfunc:`PyErr_Restore` functions:: static void my_dealloc(PyObject *obj) @@ -1026,19 +1026,19 @@ object: the :func:`repr` function (or equivalent back-tick syntax), the :func:`str` function, and the :keyword:`print` statement. For most objects, the :keyword:`print` statement is equivalent to the :func:`str` function, but it is -possible to special-case printing to a :c:type:`FILE\*` if necessary; this should +possible to special-case printing to a :ctype:`FILE\*` if necessary; this should only be done if efficiency is identified as a problem and profiling suggests that creating a temporary string object to be written to a file is too expensive. These handlers are all optional, and most types at most need to implement the -:c:member:`~PyTypeObject.tp_str` and :c:member:`~PyTypeObject.tp_repr` handlers. :: +:attr:`tp_str` and :attr:`tp_repr` handlers. :: reprfunc tp_repr; reprfunc tp_str; printfunc tp_print; -The :c:member:`~PyTypeObject.tp_repr` handler should return a string object containing a +The :attr:`tp_repr` handler should return a string object containing a representation of the instance for which it is called. Here is a simple example:: @@ -1049,15 +1049,15 @@ obj->obj_UnderlyingDatatypePtr->size); } -If no :c:member:`~PyTypeObject.tp_repr` handler is specified, the interpreter will supply a -representation that uses the type's :c:member:`~PyTypeObject.tp_name` and a uniquely-identifying +If no :attr:`tp_repr` handler is specified, the interpreter will supply a +representation that uses the type's :attr:`tp_name` and a uniquely-identifying value for the object. -The :c:member:`~PyTypeObject.tp_str` handler is to :func:`str` what the :c:member:`~PyTypeObject.tp_repr` handler +The :attr:`tp_str` handler is to :func:`str` what the :attr:`tp_repr` handler described above is to :func:`repr`; that is, it is called when Python code calls :func:`str` on an instance of your object. Its implementation is very similar -to the :c:member:`~PyTypeObject.tp_repr` function, but the resulting string is intended for human -consumption. If :c:member:`~PyTypeObject.tp_str` is not specified, the :c:member:`~PyTypeObject.tp_repr` handler is +to the :attr:`tp_repr` function, but the resulting string is intended for human +consumption. If :attr:`tp_str` is not specified, the :attr:`tp_repr` handler is used instead. Here is a simple example:: @@ -1110,8 +1110,8 @@ Python supports two pairs of attribute handlers; a type that supports attributes only needs to implement the functions for one pair. The difference is that one -pair takes the name of the attribute as a :c:type:`char\*`, while the other -accepts a :c:type:`PyObject\*`. Each type can use whichever pair makes more +pair takes the name of the attribute as a :ctype:`char\*`, while the other +accepts a :ctype:`PyObject\*`. Each type can use whichever pair makes more sense for the implementation's convenience. :: getattrfunc tp_getattr; /* char * version */ @@ -1122,7 +1122,7 @@ If accessing attributes of an object is always a simple operation (this will be explained shortly), there are generic implementations which can be used to -provide the :c:type:`PyObject\*` version of the attribute management functions. +provide the :ctype:`PyObject\*` version of the attribute management functions. The actual need for type-specific attribute handlers almost completely disappeared starting with Python 2.2, though there are many examples which have not been updated to use some of the new generic mechanism that is available. @@ -1138,7 +1138,7 @@ Most extension types only use *simple* attributes. So, what makes the attributes simple? There are only a couple of conditions that must be met: -#. The name of the attributes must be known when :c:func:`PyType_Ready` is +#. The name of the attributes must be known when :cfunc:`PyType_Ready` is called. #. No special processing is needed to record that an attribute was looked up or @@ -1147,12 +1147,12 @@ Note that this list does not place any restrictions on the values of the attributes, when the values are computed, or how relevant data is stored. -When :c:func:`PyType_Ready` is called, it uses three tables referenced by the +When :cfunc:`PyType_Ready` is called, it uses three tables referenced by the type object to create :term:`descriptor`\s which are placed in the dictionary of the type object. Each descriptor controls access to one attribute of the instance object. Each of the tables is optional; if all three are *NULL*, instances of the type will only have attributes that are inherited from their base type, and -should leave the :c:member:`~PyTypeObject.tp_getattro` and :c:member:`~PyTypeObject.tp_setattro` fields *NULL* as +should leave the :attr:`tp_getattro` and :attr:`tp_setattro` fields *NULL* as well, allowing the base type to handle attributes. The tables are declared as three fields of the type object:: @@ -1161,8 +1161,8 @@ struct PyMemberDef *tp_members; struct PyGetSetDef *tp_getset; -If :c:member:`~PyTypeObject.tp_methods` is not *NULL*, it must refer to an array of -:c:type:`PyMethodDef` structures. Each entry in the table is an instance of this +If :attr:`tp_methods` is not *NULL*, it must refer to an array of +:ctype:`PyMethodDef` structures. Each entry in the table is an instance of this structure:: typedef struct PyMethodDef { @@ -1225,13 +1225,13 @@ single: WRITE_RESTRICTED single: RESTRICTED -An interesting advantage of using the :c:member:`~PyTypeObject.tp_members` table to build +An interesting advantage of using the :attr:`tp_members` table to build descriptors that are used at runtime is that any attribute defined this way can have an associated doc string simply by providing the text in the table. An application can use the introspection API to retrieve the descriptor from the class object, and get the doc string using its :attr:`__doc__` attribute. -As with the :c:member:`~PyTypeObject.tp_methods` table, a sentinel entry with a :attr:`name` value +As with the :attr:`tp_methods` table, a sentinel entry with a :attr:`name` value of *NULL* is required. .. XXX Descriptors need to be explained in more detail somewhere, but not here. @@ -1247,9 +1247,9 @@ Type-specific Attribute Management ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -For simplicity, only the :c:type:`char\*` version will be demonstrated here; the -type of the name parameter is the only difference between the :c:type:`char\*` -and :c:type:`PyObject\*` flavors of the interface. This example effectively does +For simplicity, only the :ctype:`char\*` version will be demonstrated here; the +type of the name parameter is the only difference between the :ctype:`char\*` +and :ctype:`PyObject\*` flavors of the interface. This example effectively does the same thing as the generic example above, but does not use the generic support added in Python 2.2. The value in showing this is two-fold: it demonstrates how basic attribute management can be done in a way that is @@ -1257,15 +1257,15 @@ called, so that if you do need to extend their functionality, you'll understand what needs to be done. -The :c:member:`~PyTypeObject.tp_getattr` handler is called when the object requires an attribute +The :attr:`tp_getattr` handler is called when the object requires an attribute look-up. It is called in the same situations where the :meth:`__getattr__` method of a class would be called. A likely way to handle this is (1) to implement a set of functions (such as -:c:func:`newdatatype_getSize` and :c:func:`newdatatype_setSize` in the example +:cfunc:`newdatatype_getSize` and :cfunc:`newdatatype_setSize` in the example below), (2) provide a method table listing these functions, and (3) provide a getattr function that returns the result of a lookup in that table. The method -table uses the same structure as the :c:member:`~PyTypeObject.tp_methods` field of the type +table uses the same structure as the :attr:`tp_methods` field of the type object. Here is an example:: @@ -1284,11 +1284,11 @@ return Py_FindMethod(newdatatype_methods, (PyObject *)obj, name); } -The :c:member:`~PyTypeObject.tp_setattr` handler is called when the :meth:`__setattr__` or +The :attr:`tp_setattr` handler is called when the :meth:`__setattr__` or :meth:`__delattr__` method of a class instance would be called. When an attribute should be deleted, the third parameter will be *NULL*. Here is an example that simply raises an exception; if this were really all you wanted, the -:c:member:`~PyTypeObject.tp_setattr` handler should be set to *NULL*. :: +:attr:`tp_setattr` handler should be set to *NULL*. :: static int newdatatype_setattr(newdatatypeobject *obj, char *name, PyObject *v) @@ -1305,10 +1305,10 @@ cmpfunc tp_compare; -The :c:member:`~PyTypeObject.tp_compare` handler is called when comparisons are needed and the +The :attr:`tp_compare` handler is called when comparisons are needed and the object does not implement the specific rich comparison method which matches the requested comparison. (It is always used if defined and the -:c:func:`PyObject_Compare` or :c:func:`PyObject_Cmp` functions are used, or if +:cfunc:`PyObject_Compare` or :cfunc:`PyObject_Cmp` functions are used, or if :func:`cmp` is used from Python.) It is analogous to the :meth:`__cmp__` method. This function should return ``-1`` if *obj1* is less than *obj2*, ``0`` if they are equal, and ``1`` if *obj1* is greater than *obj2*. (It was previously @@ -1316,9 +1316,9 @@ greater than, respectively; as of Python 2.2, this is no longer allowed. In the future, other return values may be assigned a different meaning.) -A :c:member:`~PyTypeObject.tp_compare` handler may raise an exception. In this case it should +A :attr:`tp_compare` handler may raise an exception. In this case it should return a negative value. The caller has to test for the exception using -:c:func:`PyErr_Occurred`. +:cfunc:`PyErr_Occurred`. Here is a sample implementation:: @@ -1360,14 +1360,14 @@ bit does not indicate that the slot values are non-*NULL*. The flag may be set to indicate the presence of a slot, but a slot may still be unfilled.) :: - PyNumberMethods *tp_as_number; - PySequenceMethods *tp_as_sequence; - PyMappingMethods *tp_as_mapping; + PyNumberMethods tp_as_number; + PySequenceMethods tp_as_sequence; + PyMappingMethods tp_as_mapping; If you wish your object to be able to act like a number, a sequence, or a mapping object, then you place the address of a structure that implements the C -type :c:type:`PyNumberMethods`, :c:type:`PySequenceMethods`, or -:c:type:`PyMappingMethods`, respectively. It is up to you to fill in this +type :ctype:`PyNumberMethods`, :ctype:`PySequenceMethods`, or +:ctype:`PyMappingMethods`, respectively. It is up to you to fill in this structure with appropriate values. You can find examples of the use of each of these in the :file:`Objects` directory of the Python source distribution. :: @@ -1391,7 +1391,7 @@ This function is called when an instance of your data type is "called", for example, if ``obj1`` is an instance of your data type and the Python script -contains ``obj1('hello')``, the :c:member:`~PyTypeObject.tp_call` handler is invoked. +contains ``obj1('hello')``, the :attr:`tp_call` handler is invoked. This function takes three arguments: @@ -1399,11 +1399,11 @@ the call is ``obj1('hello')``, then *arg1* is ``obj1``. #. *arg2* is a tuple containing the arguments to the call. You can use - :c:func:`PyArg_ParseTuple` to extract the arguments. + :cfunc:`PyArg_ParseTuple` to extract the arguments. #. *arg3* is a dictionary of keyword arguments that were passed. If this is non-*NULL* and you support keyword arguments, use - :c:func:`PyArg_ParseTupleAndKeywords` to extract the arguments. If you do not + :cfunc:`PyArg_ParseTupleAndKeywords` to extract the arguments. If you do not want to support keyword arguments and this is non-*NULL*, raise a :exc:`TypeError` with a message saying that keyword arguments are not supported. @@ -1478,9 +1478,9 @@ those objects which do not benefit by weak referencing (such as numbers). For an object to be weakly referencable, the extension must include a -:c:type:`PyObject\*` field in the instance structure for the use of the weak +:ctype:`PyObject\*` field in the instance structure for the use of the weak reference mechanism; it must be initialized to *NULL* by the object's -constructor. It must also set the :c:member:`~PyTypeObject.tp_weaklistoffset` field of the +constructor. It must also set the :attr:`tp_weaklistoffset` field of the corresponding type object to the offset of the field. For example, the instance type is defined with the following structure:: @@ -1521,8 +1521,9 @@ } The only further addition is that the destructor needs to call the weak -reference manager to clear any weak references. This is only required if the -weak reference list is non-*NULL*:: +reference manager to clear any weak references. This should be done before any +other parts of the destruction have occurred, but is only required if the weak +reference list is non-*NULL*:: static void instance_dealloc(PyInstanceObject *inst) @@ -1553,7 +1554,7 @@ examples of the function you want to implement. When you need to verify that an object is an instance of the type you are -implementing, use the :c:func:`PyObject_TypeCheck` function. A sample of its use +implementing, use the :cfunc:`PyObject_TypeCheck` function. A sample of its use might be something like the following:: if (! PyObject_TypeCheck(some_object, &MyType)) { @@ -1566,7 +1567,7 @@ .. [#] This is true when we know that the object is a basic type, like a string or a float. -.. [#] We relied on this in the :c:member:`~PyTypeObject.tp_dealloc` handler in this example, because our +.. [#] We relied on this in the :attr:`tp_dealloc` handler in this example, because our type doesn't support garbage collection. Even if a type supports garbage collection, there are calls that can be made to "untrack" the object from garbage collection, however, these calls are advanced and not covered here. diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/extending/windows.rst --- a/Doc/extending/windows.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/extending/windows.rst Sun Jul 20 10:52:46 2014 -0400 @@ -98,8 +98,8 @@ it. Copy your C sources into it. Note that the module source file name does not necessarily have to match the module name, but the name of the initialization function should match the module name --- you can only import a - module :mod:`spam` if its initialization function is called :c:func:`initspam`, - and it should call :c:func:`Py_InitModule` with the string ``"spam"`` as its + module :mod:`spam` if its initialization function is called :cfunc:`initspam`, + and it should call :cfunc:`Py_InitModule` with the string ``"spam"`` as its first argument (use the minimal :file:`example.c` in this directory as a guide). By convention, it lives in a file called :file:`spam.c` or :file:`spammodule.c`. The output file should be called :file:`spam.pyd` (in Release mode) or @@ -263,7 +263,7 @@ The first command created three files: :file:`spam.obj`, :file:`spam.dll` and :file:`spam.lib`. :file:`Spam.dll` does not contain any Python functions (such -as :c:func:`PyArg_ParseTuple`), but it does know how to find the Python code +as :cfunc:`PyArg_ParseTuple`), but it does know how to find the Python code thanks to :file:`pythonXY.lib`. The second command created :file:`ni.dll` (and :file:`.obj` and :file:`.lib`), diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/faq/design.rst --- a/Doc/faq/design.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/faq/design.rst Sun Jul 20 10:52:46 2014 -0400 @@ -225,7 +225,7 @@ generic for a group of types and which were intended to work even for objects that didn't have methods at all (e.g. tuples). It is also convenient to have a function that can readily be applied to an amorphous collection of objects when -you use the functional features of Python (``map()``, ``zip()`` et al). +you use the functional features of Python (``map()``, ``apply()`` et al). In fact, implementing ``len()``, ``max()``, ``min()`` as a built-in function is actually less code than implementing them as methods for each type. One can @@ -297,9 +297,8 @@ How fast are exceptions? ------------------------ -A try/except block is extremely efficient if no exceptions are raised. Actually -catching an exception is expensive. In versions of Python prior to 2.0 it was -common to use this idiom:: +A try/except block is extremely efficient. Actually catching an exception is +expensive. In versions of Python prior to 2.0 it was common to use this idiom:: try: value = mydict[key] @@ -310,10 +309,11 @@ This only made sense when you expected the dict to have the key almost all the time. If that wasn't the case, you coded it like this:: - if key in mydict: + if mydict.has_key(key): value = mydict[key] else: - value = mydict[key] = getvalue(key) + mydict[key] = getvalue(key) + value = mydict[key] .. note:: @@ -370,22 +370,25 @@ Answer 2: Fortunately, there is `Stackless Python `_, which has a completely redesigned interpreter loop that avoids the C stack. +It's still experimental but looks very promising. Although it is binary +compatible with standard Python, it's still unclear whether Stackless will make +it into the core -- maybe it's just too revolutionary. -Why can't lambda expressions contain statements? ------------------------------------------------- +Why can't lambda forms contain statements? +------------------------------------------ -Python lambda expressions cannot contain statements because Python's syntactic +Python lambda forms cannot contain statements because Python's syntactic framework can't handle statements nested inside expressions. However, in Python, this is not a serious problem. Unlike lambda forms in other languages, where they add functionality, Python lambdas are only a shorthand notation if you're too lazy to define a function. Functions are already first class objects in Python, and can be declared in a -local scope. Therefore the only advantage of using a lambda instead of a +local scope. Therefore the only advantage of using a lambda form instead of a locally-defined function is that you don't need to invent a name for the function -- but that's just a local variable to which the function object (which -is exactly the same type of object that a lambda expression yields) is assigned! +is exactly the same type of object that a lambda form yields) is assigned! Can Python be compiled to machine code, C or some other language? @@ -682,8 +685,7 @@ (ABCs). You can then use :func:`isinstance` and :func:`issubclass` to check whether an instance or a class implements a particular ABC. The :mod:`collections` module defines a set of useful ABCs such as -:class:`~collections.Iterable`, :class:`~collections.Container`, and -:class:`~collections.MutableMapping`. +:class:`Iterable`, :class:`Container`, and :class:`MutableMapping`. For Python, many of the advantages of interface specifications can be obtained by an appropriate test discipline for components. There is also a tool, @@ -712,6 +714,62 @@ sloppy and not write test cases at all. +Why are default values shared between objects? +---------------------------------------------- + +This type of bug commonly bites neophyte programmers. Consider this function:: + + def foo(mydict={}): # Danger: shared reference to one dict for all calls + ... compute something ... + mydict[key] = value + return mydict + +The first time you call this function, ``mydict`` contains a single item. The +second time, ``mydict`` contains two items because when ``foo()`` begins +executing, ``mydict`` starts out with an item already in it. + +It is often expected that a function call creates new objects for default +values. This is not what happens. Default values are created exactly once, when +the function is defined. If that object is changed, like the dictionary in this +example, subsequent calls to the function will refer to this changed object. + +By definition, immutable objects such as numbers, strings, tuples, and ``None``, +are safe from change. Changes to mutable objects such as dictionaries, lists, +and class instances can lead to confusion. + +Because of this feature, it is good programming practice to not use mutable +objects as default values. Instead, use ``None`` as the default value and +inside the function, check if the parameter is ``None`` and create a new +list/dictionary/whatever if it is. For example, don't write:: + + def foo(mydict={}): + ... + +but:: + + def foo(mydict=None): + if mydict is None: + mydict = {} # create a new dict for local namespace + +This feature can be useful. When you have a function that's time-consuming to +compute, a common technique is to cache the parameters and the resulting value +of each call to the function, and return the cached value if the same value is +requested again. This is called "memoizing", and can be implemented like this:: + + # Callers will never provide a third parameter for this function. + def expensive (arg1, arg2, _cache={}): + if (arg1, arg2) in _cache: + return _cache[(arg1, arg2)] + + # Calculate the value + result = ... expensive computation ... + _cache[(arg1, arg2)] = result # Store result in the cache + return result + +You could use a global variable containing a dictionary instead of the default +value; it's a matter of taste. + + Why is there no goto? --------------------- @@ -724,7 +782,7 @@ try: ... - if condition: raise label() # goto label + if (condition): raise label() # goto label ... except label: # where to goto pass @@ -855,8 +913,8 @@ When you have a literal value for a list, tuple, or dictionary spread across multiple lines, it's easier to add more elements because you don't have to -remember to add a comma to the previous line. The lines can also be reordered -without creating a syntax error. +remember to add a comma to the previous line. The lines can also be sorted in +your editor without creating a syntax error. Accidentally omitting the comma can lead to errors that are hard to diagnose. For example:: diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/faq/extending.rst --- a/Doc/faq/extending.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/faq/extending.rst Sun Jul 20 10:52:46 2014 -0400 @@ -2,9 +2,7 @@ Extending/Embedding FAQ ======================= -.. only:: html - - .. contents:: +.. contents:: .. highlight:: c @@ -62,41 +60,41 @@ How can I execute arbitrary Python statements from C? ----------------------------------------------------- -The highest-level function to do this is :c:func:`PyRun_SimpleString` which takes +The highest-level function to do this is :cfunc:`PyRun_SimpleString` which takes a single string argument to be executed in the context of the module ``__main__`` and returns 0 for success and -1 when an exception occurred (including ``SyntaxError``). If you want more control, use -:c:func:`PyRun_String`; see the source for :c:func:`PyRun_SimpleString` in +:cfunc:`PyRun_String`; see the source for :cfunc:`PyRun_SimpleString` in ``Python/pythonrun.c``. How can I evaluate an arbitrary Python expression from C? --------------------------------------------------------- -Call the function :c:func:`PyRun_String` from the previous question with the -start symbol :c:data:`Py_eval_input`; it parses an expression, evaluates it and +Call the function :cfunc:`PyRun_String` from the previous question with the +start symbol :cdata:`Py_eval_input`; it parses an expression, evaluates it and returns its value. How do I extract C values from a Python object? ----------------------------------------------- -That depends on the object's type. If it's a tuple, :c:func:`PyTuple_Size` -returns its length and :c:func:`PyTuple_GetItem` returns the item at a specified -index. Lists have similar functions, :c:func:`PyListSize` and -:c:func:`PyList_GetItem`. +That depends on the object's type. If it's a tuple, :cfunc:`PyTuple_Size` +returns its length and :cfunc:`PyTuple_GetItem` returns the item at a specified +index. Lists have similar functions, :cfunc:`PyListSize` and +:cfunc:`PyList_GetItem`. -For strings, :c:func:`PyString_Size` returns its length and -:c:func:`PyString_AsString` a pointer to its value. Note that Python strings may -contain null bytes so C's :c:func:`strlen` should not be used. +For strings, :cfunc:`PyString_Size` returns its length and +:cfunc:`PyString_AsString` a pointer to its value. Note that Python strings may +contain null bytes so C's :cfunc:`strlen` should not be used. To test the type of an object, first make sure it isn't *NULL*, and then use -:c:func:`PyString_Check`, :c:func:`PyTuple_Check`, :c:func:`PyList_Check`, etc. +:cfunc:`PyString_Check`, :cfunc:`PyTuple_Check`, :cfunc:`PyList_Check`, etc. There is also a high-level API to Python objects which is provided by the so-called 'abstract' interface -- read ``Include/abstract.h`` for further details. It allows interfacing with any kind of Python sequence using calls -like :c:func:`PySequence_Length`, :c:func:`PySequence_GetItem`, etc.) as well as +like :cfunc:`PySequence_Length`, :cfunc:`PySequence_GetItem`, etc.) as well as many other useful protocols. @@ -105,7 +103,7 @@ You can't. Use ``t = PyTuple_New(n)`` instead, and fill it with objects using ``PyTuple_SetItem(t, i, o)`` -- note that this "eats" a reference count of -``o``, so you have to :c:func:`Py_INCREF` it. Lists have similar functions +``o``, so you have to :cfunc:`Py_INCREF` it. Lists have similar functions ``PyList_New(n)`` and ``PyList_SetItem(l, i, o)``. Note that you *must* set all the tuple items to some value before you pass the tuple to Python code -- ``PyTuple_New(n)`` initializes them to NULL, which isn't a valid Python value. @@ -114,9 +112,9 @@ How do I call an object's method from C? ---------------------------------------- -The :c:func:`PyObject_CallMethod` function can be used to call an arbitrary +The :cfunc:`PyObject_CallMethod` function can be used to call an arbitrary method of an object. The parameters are the object, the name of the method to -call, a format string like that used with :c:func:`Py_BuildValue`, and the +call, a format string like that used with :cfunc:`Py_BuildValue`, and the argument values:: PyObject * @@ -124,7 +122,7 @@ char *arg_format, ...); This works for any object that has methods -- whether built-in or user-defined. -You are responsible for eventually :c:func:`Py_DECREF`\ 'ing the return value. +You are responsible for eventually :cfunc:`Py_DECREF`\ 'ing the return value. To call, e.g., a file object's "seek" method with arguments 10, 0 (assuming the file object pointer is "f"):: @@ -137,7 +135,7 @@ Py_DECREF(res); } -Note that since :c:func:`PyObject_CallObject` *always* wants a tuple for the +Note that since :cfunc:`PyObject_CallObject` *always* wants a tuple for the argument list, to call a function without arguments, pass "()" for the format, and to call a function with one argument, surround the argument in parentheses, e.g. "(i)". @@ -188,7 +186,7 @@ attr = PyObject_GetAttrString(module, ""); -Calling :c:func:`PyObject_SetAttrString` to assign to variables in the module +Calling :cfunc:`PyObject_SetAttrString` to assign to variables in the module also works. @@ -269,16 +267,16 @@ In Python you can use the :mod:`codeop` module, which approximates the parser's behavior sufficiently. IDLE uses this, for example. -The easiest way to do it in C is to call :c:func:`PyRun_InteractiveLoop` (perhaps +The easiest way to do it in C is to call :cfunc:`PyRun_InteractiveLoop` (perhaps in a separate thread) and let the Python interpreter handle the input for -you. You can also set the :c:func:`PyOS_ReadlineFunctionPointer` to point at your +you. You can also set the :cfunc:`PyOS_ReadlineFunctionPointer` to point at your custom input function. See ``Modules/readline.c`` and ``Parser/myreadline.c`` for more hints. However sometimes you have to run the embedded Python interpreter in the same thread as your rest application and you can't allow the -:c:func:`PyRun_InteractiveLoop` to stop while waiting for user input. The one -solution then is to call :c:func:`PyParser_ParseString` and test for ``e.error`` +:cfunc:`PyRun_InteractiveLoop` to stop while waiting for user input. The one +solution then is to call :cfunc:`PyParser_ParseString` and test for ``e.error`` equal to ``E_EOF``, which means the input is incomplete). Here's a sample code fragment, untested, inspired by code from Alex Farber:: @@ -309,8 +307,8 @@ } Another solution is trying to compile the received string with -:c:func:`Py_CompileString`. If it compiles without errors, try to execute the -returned code object by calling :c:func:`PyEval_EvalCode`. Otherwise save the +:cfunc:`Py_CompileString`. If it compiles without errors, try to execute the +returned code object by calling :cfunc:`PyEval_EvalCode`. Otherwise save the input for later. If the compilation fails, find out if it's an error or just more input is required - by extracting the message string from the exception tuple and comparing it to the string "unexpected EOF while parsing". Here is a @@ -462,8 +460,8 @@ 7.x, in particular, provided a "python2" binary that is compiled with 4-byte Unicode. This only causes the link failure if the extension uses any of the ``PyUnicode_*()`` functions. It is also a problem if an extension uses any of -the Unicode-related format specifiers for :c:func:`Py_BuildValue` (or similar) or -parameter specifications for :c:func:`PyArg_ParseTuple`. +the Unicode-related format specifiers for :cfunc:`Py_BuildValue` (or similar) or +parameter specifications for :cfunc:`PyArg_ParseTuple`. You can check the size of the Unicode character a Python interpreter is using by checking the value of sys.maxunicode: diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/faq/general.rst --- a/Doc/faq/general.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/faq/general.rst Sun Jul 20 10:52:46 2014 -0400 @@ -4,10 +4,7 @@ General Python FAQ ================== -.. only:: html - - .. contents:: - +.. contents:: General Information =================== @@ -160,7 +157,7 @@ The latest Python source distribution is always available from python.org, at http://www.python.org/download/. The latest development sources can be obtained -via anonymous Mercurial access at http://hg.python.org/cpython. +via anonymous Subversion at http://svn.python.org/projects/python/trunk. The source distribution is a gzipped tar file containing the complete C source, Sphinx-formatted documentation, Python library modules, example programs, and @@ -181,8 +178,8 @@ also available at http://docs.python.org/download.html. The documentation is written in reStructuredText and processed by `the Sphinx -documentation tool `__. The reStructuredText source for -the documentation is part of the Python source distribution. +documentation tool `__. The reStructuredText source +for the documentation is part of the Python source distribution. I've never programmed before. Is there a Python tutorial? @@ -268,13 +265,9 @@ Where in the world is www.python.org located? --------------------------------------------- -The Python project's infrastructure is located all over the world. -`www.python.org `_ is currently in Amsterdam, graciously -hosted by `XS4ALL `_. `Upfront Systems -`_ hosts `bugs.python.org -`_. Most other Python services like `PyPI -`_ and hg.python.org are hosted by `Oregon State -University Open Source Lab `_. +It's currently in Amsterdam, graciously hosted by `XS4ALL +`_. Thanks to Thomas Wouters for his work in arranging +python.org's hosting. Why is it called Python? @@ -471,8 +464,7 @@ Emacs users will be happy to know that there is a very good Python mode for Emacs. All of these programming environments provide syntax highlighting, auto-indenting, and access to the interactive interpreter while coding. Consult -`the Python wiki `_ for a full list -of Python editing environments. +http://www.python.org/editors/ for a full list of Python editing environments. If you want to discuss Python's use in education, you may be interested in joining `the edu-sig mailing list diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/faq/gui.rst --- a/Doc/faq/gui.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/faq/gui.rst Sun Jul 20 10:52:46 2014 -0400 @@ -4,9 +4,7 @@ Graphic User Interface FAQ ========================== -.. only:: html - - .. contents:: +.. contents:: What platform-independent GUI toolkits exist for Python? ======================================================== @@ -21,15 +19,15 @@ Standard builds of Python include an object-oriented interface to the Tcl/Tk widget set, called Tkinter. This is probably the easiest to install and use. For more info about Tk, including pointers to the source, see the Tcl/Tk home -page at http://www.tcl.tk. Tcl/Tk is fully portable to the Mac OS X, Windows, -and Unix platforms. +page at http://www.tcl.tk. Tcl/Tk is fully portable to the MacOS, Windows, and +Unix platforms. wxWidgets --------- wxWidgets (http://www.wxwidgets.org) is a free, portable GUI class library written in C++ that provides a native look and feel on a -number of platforms, with Windows, Mac OS X, GTK, X11, all listed as +number of platforms, with Windows, MacOS X, GTK, X11, all listed as current stable targets. Language bindings are available for a number of languages including Python, Perl, Ruby, etc. @@ -47,15 +45,13 @@ Qt --- -There are bindings available for the Qt toolkit (using either `PyQt -`_ or `PySide -`_) and for KDE (`PyKDE `_). -PyQt is currently more mature than PySide, but you must buy a PyQt license from -`Riverbank Computing `_ -if you want to write proprietary applications. PySide is free for all applications. - -Qt 4.5 upwards is licensed under the LGPL license; also, commercial licenses -are available from `Nokia `_. +There are bindings available for the Qt toolkit (`PyQt +`_) and for KDE (`PyKDE `__). If +you're writing open source software, you don't need to pay for PyQt, but if you +want to write proprietary applications, you must buy a PyQt license from +`Riverbank Computing `_ and (up to Qt 4.4; +Qt 4.5 upwards is licensed under the LGPL license) a Qt license from `Trolltech +`_. Gtk+ ---- @@ -88,9 +84,13 @@ What platform-specific GUI toolkits exist for Python? ======================================================== +`The Mac port `_ by Jack Jansen has a rich and +ever-growing set of modules that support the native Mac toolbox calls. The port +supports MacOS X's Carbon libraries. + By installing the `PyObjc Objective-C bridge -`_, Python programs can use Mac OS X's -Cocoa libraries. +`_, Python programs can use MacOS X's +Cocoa libraries. See the documentation that comes with the Mac port. :ref:`Pythonwin ` by Mark Hammond includes an interface to the Microsoft Foundation Classes and a Python programming environment @@ -117,7 +117,7 @@ (http://tix.sourceforge.net/). Build Tix with SAM enabled, perform the appropriate call to -:c:func:`Tclsam_init`, etc. inside Python's +:cfunc:`Tclsam_init`, etc. inside Python's :file:`Modules/tkappinit.c`, and link with libtclsam and libtksam (you might include the Tix libraries as well). @@ -126,7 +126,7 @@ --------------------------------------------------- Yes, and you don't even need threads! But you'll have to restructure your I/O -code a bit. Tk has the equivalent of Xt's :c:func:`XtAddInput()` call, which allows you +code a bit. Tk has the equivalent of Xt's :cfunc:`XtAddInput()` call, which allows you to register a callback function which will be called from the Tk mainloop when I/O is possible on a file descriptor. Here's what you need:: diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/faq/index.rst --- a/Doc/faq/index.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/faq/index.rst Sun Jul 20 10:52:46 2014 -0400 @@ -1,9 +1,10 @@ -.. _faq-index: - ################################### Python Frequently Asked Questions ################################### +:Release: |version| +:Date: |today| + .. toctree:: :maxdepth: 1 diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/faq/library.rst --- a/Doc/faq/library.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/faq/library.rst Sun Jul 20 10:52:46 2014 -0400 @@ -4,9 +4,7 @@ Library and Extension FAQ ========================= -.. only:: html - - .. contents:: +.. contents:: General Library Questions ========================= @@ -16,7 +14,7 @@ Check :ref:`the Library Reference ` to see if there's a relevant standard library module. (Eventually you'll learn what's in the standard -library and will be able to skip this step.) +library and will able to skip this step.) For third-party packages, search the `Python Package Index `_ or try `Google `_ or @@ -30,7 +28,7 @@ If you can't find a source file for a module it may be a built-in or dynamically loaded module implemented in C, C++ or other compiled language. In this case you may not have the source file or it may be something like -:file:`mathmodule.c`, somewhere in a C source directory (not on the Python Path). +mathmodule.c, somewhere in a C source directory (not on the Python Path). There are (at least) three kinds of modules in Python: @@ -62,18 +60,18 @@ interpreter is installed on your platform. If you would like the script to be independent of where the Python interpreter -lives, you can use the :program:`env` program. Almost all Unix variants support -the following, assuming the Python interpreter is in a directory on the user's -:envvar:`PATH`:: +lives, you can use the "env" program. Almost all Unix variants support the +following, assuming the Python interpreter is in a directory on the user's +$PATH:: #!/usr/bin/env python -*Don't* do this for CGI scripts. The :envvar:`PATH` variable for CGI scripts is -often very minimal, so you need to use the actual absolute pathname of the +*Don't* do this for CGI scripts. The $PATH variable for CGI scripts is often +very minimal, so you need to use the actual absolute pathname of the interpreter. -Occasionally, a user's environment is so full that the :program:`/usr/bin/env` -program fails; or there's no env program at all. In that case, you can try the +Occasionally, a user's environment is so full that the /usr/bin/env program +fails; or there's no env program at all. In that case, you can try the following hack (due to Alex Rezinsky):: #! /bin/sh @@ -93,12 +91,12 @@ .. XXX curses *is* built by default, isn't it? -For Unix variants the standard Python source distribution comes with a curses -module in the :source:`Modules` subdirectory, though it's not compiled by default. -(Note that this is not available in the Windows distribution -- there is no -curses module for Windows.) +For Unix variants: The standard Python source distribution comes with a curses +module in the ``Modules/`` subdirectory, though it's not compiled by default +(note that this is not available in the Windows distribution -- there is no +curses module for Windows). -The :mod:`curses` module supports basic curses features as well as many additional +The curses module supports basic curses features as well as many additional functions from ncurses and SYSV curses such as colour, alternative character set support, pads, and mouse support. This means the module isn't compatible with operating systems that only have BSD curses, but there don't seem to be any @@ -112,7 +110,7 @@ ------------------------------------------------- The :mod:`atexit` module provides a register function that is similar to C's -:c:func:`onexit`. +onexit. Why don't my signal handlers work? @@ -142,8 +140,8 @@ The :mod:`unittest` module is a fancier testing framework modelled on Java and Smalltalk testing frameworks. -To make testing easier, you should use good modular design in your program. -Your program should have almost all functionality +For testing, it helps to write the program so that it may be easily tested by +using good modular design. Your program should have almost all functionality encapsulated in either functions or class methods -- and this sometimes has the surprising and delightful effect of making the program run faster (because local variable accesses are faster than global accesses). Furthermore the program @@ -159,7 +157,7 @@ Once your program is organized as a tractable collection of functions and class behaviours you should write test functions that exercise the behaviours. A test -suite that automates a sequence of tests can be associated with each module. +suite can be associated with each module which automates a sequence of tests. This sounds like a lot of work, but since Python is so terse and flexible it's surprisingly easy. You can make coding much more pleasant and fun by writing your test functions in parallel with the "production code", since this makes it @@ -188,7 +186,7 @@ How do I get a single keypress at a time? ----------------------------------------- -For Unix variants there are several solutions. It's straightforward to do this +For Unix variants: There are several solutions. It's straightforward to do this using curses, but curses is a fairly large module to learn. Here's a solution without curses:: @@ -275,7 +273,7 @@ time.sleep(10) -Instead of trying to guess a good delay value for :func:`time.sleep`, +Instead of trying to guess how long a :func:`time.sleep` delay will be enough, it's better to use some kind of semaphore mechanism. One idea is to use the :mod:`Queue` module to create a queue object, let each thread append a token to the queue when it finishes, and let the main thread read as many tokens from the @@ -286,10 +284,10 @@ --------------------------------------------------------- Use the :mod:`Queue` module to create a queue containing a list of jobs. The -:class:`~Queue.Queue` class maintains a list of objects and has a ``.put(obj)`` -method that adds items to the queue and a ``.get()`` method to return them. -The class will take care of the locking necessary to ensure that each job is -handed out exactly once. +:class:`~Queue.Queue` class maintains a list of objects with ``.put(obj)`` to +add an item to the queue and ``.get()`` to return an item. The class will take +care of the locking necessary to ensure that each job is handed out exactly +once. Here's a trivial example:: @@ -298,7 +296,7 @@ # The worker thread gets jobs off the queue. When the queue is empty, it # assumes there will be no more work and exits. # (Realistically workers will run until terminated.) - def worker(): + def worker (): print 'Running worker' time.sleep(0.1) while True: @@ -331,8 +329,6 @@ When run, this will produce the following output: -.. code-block:: none - Running worker Running worker Running worker @@ -347,15 +343,15 @@ Worker running with argument 5 ... -Consult the module's documentation for more details; the :class:`~Queue.Queue` -class provides a featureful interface. +Consult the module's documentation for more details; the ``Queue`` class +provides a featureful interface. What kinds of global value mutation are thread-safe? ---------------------------------------------------- -A :term:`global interpreter lock` (GIL) is used internally to ensure that only -one thread runs in the Python VM at a time. In general, Python offers to switch +A global interpreter lock (GIL) is used internally to ensure that only one +thread runs in the Python VM at a time. In general, Python offers to switch among threads only between bytecode instructions; how frequently it switches can be set via :func:`sys.setcheckinterval`. Each bytecode instruction and therefore all the C implementation code reached from each instruction is @@ -400,7 +396,7 @@ .. XXX mention multiprocessing .. XXX link to dbeazley's talk about GIL? -The :term:`global interpreter lock` (GIL) is often seen as a hindrance to Python's +The Global Interpreter Lock (GIL) is often seen as a hindrance to Python's deployment on high-end multiprocessor server machines, because a multi-threaded Python program effectively only uses one CPU, due to the insistence that (almost) all Python code can only run while the GIL is held. @@ -414,7 +410,7 @@ Since then, the idea of getting rid of the GIL has occasionally come up but nobody has found a way to deal with the expected slowdown, and users who don't -use threads would not be happy if their code ran at half the speed. Greg's +use threads would not be happy if their code ran at half at the speed. Greg's free threading patch set has not been kept up-to-date for later Python versions. This doesn't mean that you can't make good use of Python on multi-CPU machines! @@ -463,7 +459,7 @@ To truncate a file, open it using ``f = open(filename, "r+")``, and use ``f.truncate(offset)``; offset defaults to the current seek position. There's also ``os.ftruncate(fd, offset)`` for files opened with :func:`os.open`, where -*fd* is the file descriptor (a small integer). +``fd`` is the file descriptor (a small integer). The :mod:`shutil` module also contains a number of functions to work on files including :func:`~shutil.copyfile`, :func:`~shutil.copytree`, and @@ -497,7 +493,7 @@ "short integer" (2 bytes), and 'l' reads one "long integer" (4 bytes) from the string. -For data that is more regular (e.g. a homogeneous list of ints or floats), +For data that is more regular (e.g. a homogeneous list of ints or thefloats), you can also use the :mod:`array` module. @@ -507,7 +503,7 @@ :func:`os.read` is a low-level function which takes a file descriptor, a small integer representing the opened file. :func:`os.popen` creates a high-level file object, the same type returned by the built-in :func:`open` function. -Thus, to read *n* bytes from a pipe *p* created with :func:`os.popen`, you need to +Thus, to read n bytes from a pipe p created with :func:`os.popen`, you need to use ``p.read(n)``. @@ -526,9 +522,9 @@ Warning: in general it is unwise to do this because you can easily cause a deadlock where your process is blocked waiting for output from the child while -the child is blocked waiting for input from you. This can be caused by the -parent expecting the child to output more text than it does or by data being -stuck in stdio buffers due to lack of flushing. The Python parent +the child is blocked waiting for input from you. This can be caused because the +parent expects the child to output more text than it does, or it can be caused +by data being stuck in stdio buffers due to lack of flushing. The Python parent can of course explicitly flush the data it sends to the child before it reads any output, but if the child is a naive C program it may have been written to never explicitly flush its output, even if it is interactive, since flushing is @@ -548,8 +544,8 @@ In many cases, all you really need is to run some data through a command and get the result back. Unless the amount of data is very large, the easiest way to do this is to write it to a temporary file and run the command with that temporary -file as input. The standard module :mod:`tempfile` exports a -:func:`~tempfile.mktemp` function to generate unique temporary file names. :: +file as input. The standard module :mod:`tempfile` exports a ``mktemp()`` +function to generate unique temporary file names. :: import tempfile import os @@ -640,7 +636,7 @@ .. XXX check if wiki page is still up to date A summary of available frameworks is maintained by Paul Boddie at -http://wiki.python.org/moin/WebProgramming\ . +http://wiki.python.org/moin/WebProgramming . Cameron Laird maintains a useful set of pages about Python web technologies at http://phaseit.net/claird/comp.lang.python/web_python. @@ -677,12 +673,15 @@ sys.stdout.write(httpobj.getfile().read()) Note that in general for percent-encoded POST operations, query strings must be -quoted using :func:`urllib.urlencode`. For example, to send -``name=Guy Steele, Jr.``:: +quoted using :func:`urllib.quote`. For example to send name="Guy Steele, Jr.":: - >>> import urllib - >>> urllib.urlencode({'name': 'Guy Steele, Jr.'}) - 'name=Guy+Steele%2C+Jr.' + >>> from urllib import quote + >>> x = quote("Guy Steele, Jr.") + >>> x + 'Guy%20Steele,%20Jr.' + >>> query_string = "name="+x + >>> query_string + 'name=Guy%20Steele,%20Jr.' What module should I use to help with generating HTML? @@ -690,8 +689,19 @@ .. XXX add modern template languages -You can find a collection of useful links on the `Web Programming wiki page -`_. +There are many different modules available: + +* HTMLgen is a class library of objects corresponding to all the HTML 3.2 markup + tags. It's used when you are writing in Python and wish to synthesize HTML + pages for generating a web or for CGI forms, etc. + +* DocumentTemplate and Zope Page Templates are two different systems that are + part of Zope. + +* Quixote's PTL uses Python syntax to assemble strings of text. + +Consult the `Web Programming wiki pages +`_ for more links. How do I send mail from a Python script? @@ -720,7 +730,7 @@ server.quit() A Unix-only alternative uses sendmail. The location of the sendmail program -varies between systems; sometimes it is ``/usr/lib/sendmail``, sometimes +varies between systems; sometimes it is ``/usr/lib/sendmail``, sometime ``/usr/sbin/sendmail``. The sendmail manual page will help you out. Here's some sample code:: @@ -787,7 +797,7 @@ The :mod:`marshal` module provides very fast ways to store noncircular basic Python types to files and strings, and back again. Although marshal does not do fancy things like store instances or handle shared references properly, it does -run extremely fast. For example, loading a half megabyte of data may take less +run extremely fast. For example loading a half megabyte of data may take less than a third of a second. This often beats doing something more complex and general such as using gdbm with pickle/shelve. @@ -797,9 +807,9 @@ .. XXX update this, default protocol is 2/3 -By default :mod:`pickle` uses a relatively old and slow format for backward -compatibility. You can however specify other protocol versions that are -faster:: +The default format used by the pickle module is a slow one that results in +readable pickles. Making it the default, but it would break backward +compatibility:: largeString = 'z' * (100 * 1024) myPickle = cPickle.dumps(largeString, protocol=1) diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/faq/programming.rst --- a/Doc/faq/programming.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/faq/programming.rst Sun Jul 20 10:52:46 2014 -0400 @@ -4,9 +4,7 @@ Programming FAQ =============== -.. only:: html - - .. contents:: +.. contents:: General Questions ================= @@ -149,7 +147,7 @@ `_. Guido van Rossum has written up an anecdote related to optimization at -http://www.python.org/doc/essays/list2str. +http://www.python.org/doc/essays/list2str.html. One thing to notice is that function and (especially) method calls are rather expensive; if you have designed a purely OO interface with lots of tiny @@ -354,58 +352,6 @@ declaration for identifying side-effects. -Why do lambdas defined in a loop with different values all return the same result? ----------------------------------------------------------------------------------- - -Assume you use a for loop to define a few different lambdas (or even plain -functions), e.g.:: - - >>> squares = [] - >>> for x in range(5): - ... squares.append(lambda: x**2) - -This gives you a list that contains 5 lambdas that calculate ``x**2``. You -might expect that, when called, they would return, respectively, ``0``, ``1``, -``4``, ``9``, and ``16``. However, when you actually try you will see that -they all return ``16``:: - - >>> squares[2]() - 16 - >>> squares[4]() - 16 - -This happens because ``x`` is not local to the lambdas, but is defined in -the outer scope, and it is accessed when the lambda is called --- not when it -is defined. At the end of the loop, the value of ``x`` is ``4``, so all the -functions now return ``4**2``, i.e. ``16``. You can also verify this by -changing the value of ``x`` and see how the results of the lambdas change:: - - >>> x = 8 - >>> squares[2]() - 64 - -In order to avoid this, you need to save the values in variables local to the -lambdas, so that they don't rely on the value of the global ``x``:: - - >>> squares = [] - >>> for x in range(5): - ... squares.append(lambda n=x: n**2) - -Here, ``n=x`` creates a new variable ``n`` local to the lambda and computed -when the lambda is defined so that it has the same value that ``x`` had at -that point in the loop. This means that the value of ``n`` will be ``0`` -in the first lambda, ``1`` in the second, ``2`` in the third, and so on. -Therefore each lambda will now return the correct result:: - - >>> squares[2]() - 4 - >>> squares[4]() - 16 - -Note that this behaviour is not peculiar to lambdas, but applies to regular -functions too. - - How do I share global variables across modules? ------------------------------------------------ @@ -499,62 +445,6 @@ occur when the module is initialized. -Why are default values shared between objects? ----------------------------------------------- - -This type of bug commonly bites neophyte programmers. Consider this function:: - - def foo(mydict={}): # Danger: shared reference to one dict for all calls - ... compute something ... - mydict[key] = value - return mydict - -The first time you call this function, ``mydict`` contains a single item. The -second time, ``mydict`` contains two items because when ``foo()`` begins -executing, ``mydict`` starts out with an item already in it. - -It is often expected that a function call creates new objects for default -values. This is not what happens. Default values are created exactly once, when -the function is defined. If that object is changed, like the dictionary in this -example, subsequent calls to the function will refer to this changed object. - -By definition, immutable objects such as numbers, strings, tuples, and ``None``, -are safe from change. Changes to mutable objects such as dictionaries, lists, -and class instances can lead to confusion. - -Because of this feature, it is good programming practice to not use mutable -objects as default values. Instead, use ``None`` as the default value and -inside the function, check if the parameter is ``None`` and create a new -list/dictionary/whatever if it is. For example, don't write:: - - def foo(mydict={}): - ... - -but:: - - def foo(mydict=None): - if mydict is None: - mydict = {} # create a new dict for local namespace - -This feature can be useful. When you have a function that's time-consuming to -compute, a common technique is to cache the parameters and the resulting value -of each call to the function, and return the cached value if the same value is -requested again. This is called "memoizing", and can be implemented like this:: - - # Callers will never provide a third parameter for this function. - def expensive(arg1, arg2, _cache={}): - if (arg1, arg2) in _cache: - return _cache[(arg1, arg2)] - - # Calculate the value - result = ... expensive computation ... - _cache[(arg1, arg2)] = result # Store result in the cache - return result - -You could use a global variable containing a dictionary instead of the default -value; it's a matter of taste. - - How can I pass optional or keyword parameters from one function to another? --------------------------------------------------------------------------- @@ -579,31 +469,6 @@ apply(g, (x,)+args, kwargs) -.. index:: - single: argument; difference from parameter - single: parameter; difference from argument - -.. _faq-argument-vs-parameter: - -What is the difference between arguments and parameters? --------------------------------------------------------- - -:term:`Parameters ` are defined by the names that appear in a -function definition, whereas :term:`arguments ` are the values -actually passed to a function when calling it. Parameters define what types of -arguments a function can accept. For example, given the function definition:: - - def func(foo, bar=None, **kwargs): - pass - -*foo*, *bar* and *kwargs* are parameters of ``func``. However, when calling -``func``, for example:: - - func(42, bar=314, extra=somevar) - -the values ``42``, ``314``, and ``somevar`` are arguments. - - How do I write a function with output parameters (call by reference)? --------------------------------------------------------------------- @@ -804,11 +669,11 @@ Since the comma is not an operator, but a separator between expressions the above is evaluated as if you had entered:: - ("a" in "b"), "a" + >>> ("a" in "b"), "a" not:: - "a" in ("b", "a") + >>> "a" in ("b", "a") The same is true of the various assignment operators (``=``, ``+=`` etc). They are not truly operators but syntactic delimiters in assignment statements. @@ -827,6 +692,52 @@ For versions previous to 2.5 the answer would be 'No'. +.. XXX remove rest? + +In many cases you can mimic ``a ? b : c`` with ``a and b or c``, but there's a +flaw: if *b* is zero (or empty, or ``None`` -- anything that tests false) then +*c* will be selected instead. In many cases you can prove by looking at the +code that this can't happen (e.g. because *b* is a constant or has a type that +can never be false), but in general this can be a problem. + +Tim Peters (who wishes it was Steve Majewski) suggested the following solution: +``(a and [b] or [c])[0]``. Because ``[b]`` is a singleton list it is never +false, so the wrong path is never taken; then applying ``[0]`` to the whole +thing gets the *b* or *c* that you really wanted. Ugly, but it gets you there +in the rare cases where it is really inconvenient to rewrite your code using +'if'. + +The best course is usually to write a simple ``if...else`` statement. Another +solution is to implement the ``?:`` operator as a function:: + + def q(cond, on_true, on_false): + if cond: + if not isfunction(on_true): + return on_true + else: + return on_true() + else: + if not isfunction(on_false): + return on_false + else: + return on_false() + +In most cases you'll pass b and c directly: ``q(a, b, c)``. To avoid evaluating +b or c when they shouldn't be, encapsulate them within a lambda function, e.g.: +``q(a, lambda: b, lambda: c)``. + +It has been asked *why* Python has no if-then-else expression. There are +several answers: many languages do just fine without one; it can easily lead to +less readable code; no sufficiently "Pythonic" syntax has been discovered; a +search of the standard library found remarkably few places where using an +if-then-else expression would make the code more understandable. + +In 2002, :pep:`308` was written proposing several possible syntaxes and the +community was asked to vote on the issue. The vote was inconclusive. Most +people liked one of the syntaxes, but also hated other syntaxes; many votes +implied that people preferred no ternary operator rather than having a syntax +they hated. + Is it possible to write obfuscated one-liners in Python? -------------------------------------------------------- @@ -953,7 +864,6 @@ You can't, because strings are immutable. If you need an object with this ability, try converting the string to a list or use the array module:: - >>> import io >>> s = "Hello, world" >>> a = list(s) >>> print a @@ -966,8 +876,8 @@ >>> a = array.array('c', s) >>> print a array('c', 'Hello, world') - >>> a[0] = 'y'; print a - array('c', 'yello, world') + >>> a[0] = 'y' ; print a + array('c', 'yello world') >>> a.tostring() 'yello, world' @@ -1070,7 +980,7 @@ if the line uses something other than whitespace as a separator. For more complicated input parsing, regular expressions are more powerful -than C's :c:func:`sscanf` and better suited for the task. +than C's :cfunc:`sscanf` and better suited for the task. What does 'UnicodeError: ASCII [decoding,encoding] error: ordinal not in range(128)' mean? @@ -1229,7 +1139,7 @@ You probably tried to make a multidimensional array like this:: - >>> A = [[None] * 2] * 3 + A = [[None] * 2] * 3 This looks correct if you print it:: @@ -1261,7 +1171,7 @@ A = [[None] * w for i in range(h)] Or, you can use an extension that provides a matrix datatype; `Numeric Python -`_ is the best known. +`_ is the best known. How do I apply a method to a sequence of objects? @@ -1280,92 +1190,6 @@ return map(apply, methods, [arguments]*nobjects) -Why does a_tuple[i] += ['item'] raise an exception when the addition works? ---------------------------------------------------------------------------- - -This is because of a combination of the fact that augmented assignment -operators are *assignment* operators, and the difference between mutable and -immutable objects in Python. - -This discussion applies in general when augmented assignment operators are -applied to elements of a tuple that point to mutable objects, but we'll use -a ``list`` and ``+=`` as our exemplar. - -If you wrote:: - - >>> a_tuple = (1, 2) - >>> a_tuple[0] += 1 - Traceback (most recent call last): - ... - TypeError: 'tuple' object does not support item assignment - -The reason for the exception should be immediately clear: ``1`` is added to the -object ``a_tuple[0]`` points to (``1``), producing the result object, ``2``, -but when we attempt to assign the result of the computation, ``2``, to element -``0`` of the tuple, we get an error because we can't change what an element of -a tuple points to. - -Under the covers, what this augmented assignment statement is doing is -approximately this:: - - >>> result = a_tuple[0] + 1 - >>> a_tuple[0] = result - Traceback (most recent call last): - ... - TypeError: 'tuple' object does not support item assignment - -It is the assignment part of the operation that produces the error, since a -tuple is immutable. - -When you write something like:: - - >>> a_tuple = (['foo'], 'bar') - >>> a_tuple[0] += ['item'] - Traceback (most recent call last): - ... - TypeError: 'tuple' object does not support item assignment - -The exception is a bit more surprising, and even more surprising is the fact -that even though there was an error, the append worked:: - - >>> a_tuple[0] - ['foo', 'item'] - -To see why this happens, you need to know that (a) if an object implements an -``__iadd__`` magic method, it gets called when the ``+=`` augmented assignment -is executed, and its return value is what gets used in the assignment statement; -and (b) for lists, ``__iadd__`` is equivalent to calling ``extend`` on the list -and returning the list. That's why we say that for lists, ``+=`` is a -"shorthand" for ``list.extend``:: - - >>> a_list = [] - >>> a_list += [1] - >>> a_list - [1] - -This is equivalent to:: - - >>> result = a_list.__iadd__([1]) - >>> a_list = result - -The object pointed to by a_list has been mutated, and the pointer to the -mutated object is assigned back to ``a_list``. The end result of the -assignment is a no-op, since it is a pointer to the same object that ``a_list`` -was previously pointing to, but the assignment still happens. - -Thus, in our tuple example what is happening is equivalent to:: - - >>> result = a_tuple[0].__iadd__(['item']) - >>> a_tuple[0] = result - Traceback (most recent call last): - ... - TypeError: 'tuple' object does not support item assignment - -The ``__iadd__`` succeeds, and thus the list is extended, but even though -``result`` points to the same object that ``a_tuple[0]`` already points to, -that final assignment still results in an error, because tuples are immutable. - - Dictionaries ============ @@ -1780,32 +1604,6 @@ keeping a list of weak references to each instance. -Why does the result of ``id()`` appear to be not unique? --------------------------------------------------------- - -The :func:`id` builtin returns an integer that is guaranteed to be unique during -the lifetime of the object. Since in CPython, this is the object's memory -address, it happens frequently that after an object is deleted from memory, the -next freshly created object is allocated at the same position in memory. This -is illustrated by this example: - ->>> id(1000) -13901272 ->>> id(2000) -13901272 - -The two ids belong to different integer objects that are created before, and -deleted immediately after execution of the ``id()`` call. To be sure that -objects whose id you want to examine are still alive, create another reference -to the object: - ->>> a = 1000; b = 2000 ->>> id(a) -13901272 ->>> id(b) -13891296 - - Modules ======= @@ -1823,13 +1621,13 @@ (permissions, free space, etc...) to write the compiled module back to the directory. -Running Python on a top level script is not considered an import and no -``.pyc`` will be created. For example, if you have a top-level module -``foo.py`` that imports another module ``xyz.py``, when you run ``foo``, -``xyz.pyc`` will be created since ``xyz`` is imported, but no ``foo.pyc`` file -will be created since ``foo.py`` isn't being imported. +Running Python on a top level script is not considered an import and no ``.pyc`` +will be created. For example, if you have a top-level module ``abc.py`` that +imports another module ``xyz.py``, when you run abc, ``xyz.pyc`` will be created +since xyz is imported, but no ``abc.pyc`` file will be created since ``abc.py`` +isn't being imported. -If you need to create ``foo.pyc`` -- that is, to create a ``.pyc`` file for a module +If you need to create abc.pyc -- that is, to create a .pyc file for a module that is not imported -- you can, using the :mod:`py_compile` and :mod:`compileall` modules. @@ -1837,9 +1635,9 @@ the ``compile()`` function in that module interactively:: >>> import py_compile - >>> py_compile.compile('foo.py') # doctest: +SKIP + >>> py_compile.compile('abc.py') -This will write the ``.pyc`` to the same location as ``foo.py`` (or you can +This will write the ``.pyc`` to the same location as ``abc.py`` (or you can override that with the optional parameter ``cfile``). You can also automatically compile all files in a directory or directories using diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/faq/windows.rst --- a/Doc/faq/windows.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/faq/windows.rst Sun Jul 20 10:52:46 2014 -0400 @@ -6,16 +6,16 @@ Python on Windows FAQ ===================== -.. only:: html - - .. contents:: +.. contents:: How do I run a Python program under Windows? -------------------------------------------- This is not necessarily a straightforward question. If you are already familiar with running programs from the Windows command line then everything will seem -obvious; otherwise, you might need a little more guidance. +obvious; otherwise, you might need a little more guidance. There are also +differences between Windows 95, 98, NT, ME, 2000 and XP which can add to the +confusion. .. sidebar:: |Python Development on XP|_ :subtitle: `Python Development on XP`_ @@ -32,7 +32,7 @@ Unless you use some sort of integrated development environment, you will end up *typing* Windows commands into what is variously referred to as a "DOS window" or "Command prompt window". Usually you can create such a window from your -Start menu; under Windows 7 the menu selection is :menuselection:`Start --> +Start menu; under Windows 2000 the menu selection is :menuselection:`Start --> Programs --> Accessories --> Command Prompt`. You should be able to recognize when you have started such a window because you will see a Windows "command prompt", which usually looks like this:: @@ -42,27 +42,23 @@ The letter may be different, and there might be other things after it, so you might just as easily see something like:: - D:\YourName\Projects\Python> + D:\Steve\Projects\Python> depending on how your computer has been set up and what else you have recently done with it. Once you have started such a window, you are well on the way to running Python programs. You need to realize that your Python scripts have to be processed by another -program called the Python *interpreter*. The interpreter reads your script, +program called the Python interpreter. The interpreter reads your script, compiles it into bytecodes, and then executes the bytecodes to run your program. So, how do you arrange for the interpreter to handle your Python? First, you need to make sure that your command window recognises the word "python" as an instruction to start the interpreter. If you have opened a command window, you should try entering the command ``python`` and hitting -return.:: +return. You should then see something like:: - C:\Users\YourName> python - -You should then see something like:: - - Python 2.7.3 (default, Apr 10 2012, 22.71:26) [MSC v.1500 32 bit (Intel)] on win32 + Python 2.2 (#28, Dec 21 2001, 12:21:22) [MSC 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> @@ -82,7 +78,7 @@ Windows command prompt. You may also find that you have a Start-menu entry such as :menuselection:`Start ---> Programs --> Python 2.7 --> Python (command line)` that results in you +--> Programs --> Python 2.2 --> Python (command line)` that results in you seeing the ``>>>`` prompt in a new window. If so, the window will disappear after you enter the Ctrl-Z character; Windows is running a single "python" command in the window, and closes it when you terminate the interpreter. @@ -90,7 +86,8 @@ If the ``python`` command, instead of displaying the interpreter prompt ``>>>``, gives you a message like:: - 'python' is not recognized as an internal or external command, operable program or batch file. + 'python' is not recognized as an internal or external command, + operable program or batch file. .. sidebar:: |Adding Python to DOS Path|_ :subtitle: `Adding Python to DOS Path`_ @@ -119,33 +116,115 @@ dir C:\py* will probably tell you where it is installed; the usual location is something -like ``C:\Python27``. Otherwise you will be reduced to a search of your whole +like ``C:\Python23``. Otherwise you will be reduced to a search of your whole disk ... use :menuselection:`Tools --> Find` or hit the :guilabel:`Search` button and look for "python.exe". Supposing you discover that Python is -installed in the ``C:\Python27`` directory (the default at the time of writing), +installed in the ``C:\Python23`` directory (the default at the time of writing), you should make sure that entering the command :: - c:\Python27\python + c:\Python23\python starts up the interpreter as above (and don't forget you'll need a "CTRL-Z" and -an "Enter" to get out of it). Once you have verified the directory, you can -add it to the system path to make it easier to start Python by just running -the ``python`` command. This is currently an option in the installer as of -CPython 2.7. +an "Enter" to get out of it). Once you have verified the directory, you need to +add it to the start-up routines your computer goes through. For older versions +of Windows the easiest way to do this is to edit the ``C:\AUTOEXEC.BAT`` +file. You would want to add a line like the following to ``AUTOEXEC.BAT``:: -More information about environment variables can be found on the -:ref:`Using Python on Windows ` page. + PATH C:\Python23;%PATH% + +For Windows NT, 2000 and (I assume) XP, you will need to add a string such as :: + + ;C:\Python23 + +to the current setting for the PATH environment variable, which you will find in +the properties window of "My Computer" under the "Advanced" tab. Note that if +you have sufficient privilege you might get a choice of installing the settings +either for the Current User or for System. The latter is preferred if you want +everybody to be able to run Python on the machine. + +If you aren't confident doing any of these manipulations yourself, ask for help! +At this stage you may want to reboot your system to make absolutely sure the new +setting has taken effect. You probably won't need to reboot for Windows NT, XP +or 2000. You can also avoid it in earlier versions by editing the file +``C:\WINDOWS\COMMAND\CMDINIT.BAT`` instead of ``AUTOEXEC.BAT``. + +You should now be able to start a new command window, enter ``python`` at the +``C:\>`` (or whatever) prompt, and see the ``>>>`` prompt that indicates the +Python interpreter is reading interactive commands. + +Let's suppose you have a program called ``pytest.py`` in directory +``C:\Steve\Projects\Python``. A session to run that program might look like +this:: + + C:\> cd \Steve\Projects\Python + C:\Steve\Projects\Python> python pytest.py + +Because you added a file name to the command to start the interpreter, when it +starts up it reads the Python script in the named file, compiles it, executes +it, and terminates, so you see another ``C:\>`` prompt. You might also have +entered :: + + C:\> python \Steve\Projects\Python\pytest.py + +if you hadn't wanted to change your current directory. + +Under NT, 2000 and XP you may well find that the installation process has also +arranged that the command ``pytest.py`` (or, if the file isn't in the current +directory, ``C:\Steve\Projects\Python\pytest.py``) will automatically recognize +the ".py" extension and run the Python interpreter on the named file. Using this +feature is fine, but *some* versions of Windows have bugs which mean that this +form isn't exactly equivalent to using the interpreter explicitly, so be +careful. + +The important things to remember are: + +1. Start Python from the Start Menu, or make sure the PATH is set correctly so + Windows can find the Python interpreter. :: + + python + + should give you a '>>>' prompt from the Python interpreter. Don't forget the + CTRL-Z and ENTER to terminate the interpreter (and, if you started the window + from the Start Menu, make the window disappear). + +2. Once this works, you run programs with commands:: + + python {program-file} + +3. When you know the commands to use you can build Windows shortcuts to run the + Python interpreter on any of your scripts, naming particular working + directories, and adding them to your menus. Take a look at :: + + python --help + + if your needs are complex. + +4. Interactive mode (where you see the ``>>>`` prompt) is best used for checking + that individual statements and expressions do what you think they will, and + for developing code by experiment. + How do I make Python scripts executable? ---------------------------------------- -On Windows, the standard Python installer already associates the .py +On Windows 2000, the standard Python installer already associates the .py extension with a file type (Python.File) and gives that file type an open command that runs the interpreter (``D:\Program Files\Python\python.exe "%1" %*``). This is enough to make scripts executable from the command prompt as 'foo.py'. If you'd rather be able to execute the script by simple typing 'foo' with no extension you need to add .py to the PATHEXT environment variable. +On Windows NT, the steps taken by the installer as described above allow you to +run a script with 'foo.py', but a longtime bug in the NT command processor +prevents you from redirecting the input or output of any script executed in this +way. This is often important. + +The incantation for making a Python script executable under WinNT is to give the +file an extension of .cmd and add the following as the first line:: + + @setlocal enableextensions & python -x %~f0 %* & goto :EOF + + Why does Python sometimes take so long to start? ------------------------------------------------ @@ -163,11 +242,22 @@ offender. -How do I make an executable from a Python script? -------------------------------------------------- +Where is Freeze for Windows? +---------------------------- -See http://www.py2exe.org/ for a distutils extension that allows you -to create console and GUI executables from Python code. +"Freeze" is a program that allows you to ship a Python program as a single +stand-alone executable file. It is *not* a compiler; your programs don't run +any faster, but they are more easily distributable, at least to platforms with +the same OS and CPU. Read the README file of the freeze program for more +disclaimers. + +You can use freeze on Windows, but you must download the source tree (see +http://www.python.org/download/source). The freeze program is in the +``Tools\freeze`` subdirectory of the source tree. + +You need the Microsoft VC++ compiler, and you probably need to build Python. +The required project files are in the PCbuild directory. + Is a ``*.pyd`` file the same as a DLL? -------------------------------------- @@ -198,7 +288,7 @@ be a DLL to handle importing modules that are themselves DLL's. (This is the first key undocumented fact.) Instead, link to :file:`python{NN}.dll`; it is typically installed in ``C:\Windows\System``. *NN* is the Python version, a - number such as "27" for Python 2.7. + number such as "23" for Python 2.3. You can link to Python in two different ways. Load-time linking means linking against :file:`python{NN}.lib`, while run-time linking means linking @@ -243,7 +333,7 @@ ... Py_Initialize(); // Initialize Python. initmyAppc(); // Initialize (import) the helper class. - PyRun_SimpleString("import myApp"); // Import the shadow class. + PyRun_SimpleString("import myApp") ; // Import the shadow class. 5. There are two problems with Python's C API which will become apparent if you use a compiler other than MSVC, the compiler used to build pythonNN.dll. @@ -282,6 +372,47 @@ object that supports read and write, so all you need is a Python object (defined in your extension module) that contains read() and write() methods. + +How do I use Python for CGI? +---------------------------- + +On the Microsoft IIS server or on the Win95 MS Personal Web Server you set up +Python in the same way that you would set up any other scripting engine. + +Run regedt32 and go to:: + + HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\W3SVC\Parameters\ScriptMap + +and enter the following line (making any specific changes that your system may +need):: + + .py :REG_SZ: c:\\python.exe -u %s %s + +This line will allow you to call your script with a simple reference like: +``http://yourserver/scripts/yourscript.py`` provided "scripts" is an +"executable" directory for your server (which it usually is by default). The +:option:`-u` flag specifies unbuffered and binary mode for stdin - needed when +working with binary data. + +In addition, it is recommended that using ".py" may not be a good idea for the +file extensions when used in this context (you might want to reserve ``*.py`` +for support modules and use ``*.cgi`` or ``*.cgp`` for "main program" scripts). + +In order to set up Internet Information Services 5 to use Python for CGI +processing, please see the following links: + + http://www.e-coli.net/pyiis_server.html (for Win2k Server) + http://www.e-coli.net/pyiis.html (for Win2k pro) + +Configuring Apache is much simpler. In the Apache configuration file +``httpd.conf``, add the following line at the end of the file:: + + ScriptInterpreterSource Registry + +Then, give your Python CGI-scripts the extension .py and put them in the cgi-bin +directory. + + How do I keep editors from inserting tabs into my Python source? ---------------------------------------------------------------- @@ -325,6 +456,116 @@ to console subprocesses which are designed to handle those signals. See :func:`os.kill` for further details. + +Why does os.path.isdir() fail on NT shared directories? +------------------------------------------------------- + +The solution appears to be always append the "\\" on the end of shared +drives. + + >>> import os + >>> os.path.isdir( '\\\\rorschach\\public') + 0 + >>> os.path.isdir( '\\\\rorschach\\public\\') + 1 + +It helps to think of share points as being like drive letters. Example:: + + k: is not a directory + k:\ is a directory + k:\media is a directory + k:\media\ is not a directory + +The same rules apply if you substitute "k:" with "\\conky\foo":: + + \\conky\foo is not a directory + \\conky\foo\ is a directory + \\conky\foo\media is a directory + \\conky\foo\media\ is not a directory + + +cgi.py (or other CGI programming) doesn't work sometimes on NT or win95! +------------------------------------------------------------------------ + +Be sure you have the latest python.exe, that you are using python.exe rather +than a GUI version of Python and that you have configured the server to execute +:: + + "...\python.exe -u ..." + +for the CGI execution. The :option:`-u` (unbuffered) option on NT and Win95 +prevents the interpreter from altering newlines in the standard input and +output. Without it post/multipart requests will seem to have the wrong length +and binary (e.g. GIF) responses may get garbled (resulting in broken images, PDF +files, and other binary downloads failing). + + +Why doesn't os.popen() work in PythonWin on NT? +----------------------------------------------- + +The reason that os.popen() doesn't work from within PythonWin is due to a bug in +Microsoft's C Runtime Library (CRT). The CRT assumes you have a Win32 console +attached to the process. + +You should use the win32pipe module's popen() instead which doesn't depend on +having an attached Win32 console. + +Example:: + + import win32pipe + f = win32pipe.popen('dir /c c:\\') + print f.readlines() + f.close() + + +Why doesn't os.popen()/win32pipe.popen() work on Win9x? +------------------------------------------------------- + +There is a bug in Win9x that prevents os.popen/win32pipe.popen* from +working. The good news is there is a way to work around this problem. The +Microsoft Knowledge Base article that you need to lookup is: Q150956. You will +find links to the knowledge base at: http://support.microsoft.com/. + + +PyRun_SimpleFile() crashes on Windows but not on Unix; why? +----------------------------------------------------------- + +This is very sensitive to the compiler vendor, version and (perhaps) even +options. If the FILE* structure in your embedding program isn't the same as is +assumed by the Python interpreter it won't work. + +The Python 1.5.* DLLs (``python15.dll``) are all compiled with MS VC++ 5.0 and +with multithreading-DLL options (``/MD``). + +If you can't change compilers or flags, try using :cfunc:`Py_RunSimpleString`. +A trick to get it to run an arbitrary file is to construct a call to +:func:`execfile` with the name of your file as argument. + +Also note that you can not mix-and-match Debug and Release versions. If you +wish to use the Debug Multithreaded DLL, then your module *must* have ``_d`` +appended to the base name. + + +Importing _tkinter fails on Windows 95/98: why? +------------------------------------------------ + +Sometimes, the import of _tkinter fails on Windows 95 or 98, complaining with a +message like the following:: + + ImportError: DLL load failed: One of the library files needed + to run this application cannot be found. + +It could be that you haven't installed Tcl/Tk, but if you did install Tcl/Tk, +and the Wish application works correctly, the problem may be that its installer +didn't manage to edit the autoexec.bat file correctly. It tries to add a +statement that changes the PATH environment variable to include the Tcl/Tk 'bin' +subdirectory, but sometimes this edit doesn't quite work. Opening it with +notepad usually reveals what the problem is. + +(One additional hint, noted by David Szafranski: you can't use long filenames +here; e.g. use ``C:\PROGRA~1\Tcl\bin`` instead of ``C:\Program Files\Tcl\bin``.) + + How do I extract the downloaded documentation on Windows? --------------------------------------------------------- @@ -336,3 +577,38 @@ able to handle it. (If your copy of WinZip doesn't, get a newer one from http://www.winzip.com.) + +Missing cw3215mt.dll (or missing cw3215.dll) +-------------------------------------------- + +Sometimes, when using Tkinter on Windows, you get an error that cw3215mt.dll or +cw3215.dll is missing. + +Cause: you have an old Tcl/Tk DLL built with cygwin in your path (probably +``C:\Windows``). You must use the Tcl/Tk DLLs from the standard Tcl/Tk +installation (Python 1.5.2 comes with one). + + +Warning about CTL3D32 version from installer +-------------------------------------------- + +The Python installer issues a warning like this:: + + This version uses CTL3D32.DLL which is not the correct version. + This version is used for windows NT applications only. + +Tim Peters: + + This is a Microsoft DLL, and a notorious source of problems. The message + means what it says: you have the wrong version of this DLL for your operating + system. The Python installation did not cause this -- something else you + installed previous to this overwrote the DLL that came with your OS (probably + older shareware of some sort, but there's no way to tell now). If you search + for "CTL3D32" using any search engine (AltaVista, for example), you'll find + hundreds and hundreds of web pages complaining about the same problem with + all sorts of installation programs. They'll point you to ways to get the + correct version reinstalled on your system (since Python doesn't cause this, + we can't fix it). + +David A Burton has written a little program to fix this. Go to +http://www.burtonsys.com/downloads.html and click on "ctl3dfix.zip". diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/glossary.rst --- a/Doc/glossary.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/glossary.rst Sun Jul 20 10:52:46 2014 -0400 @@ -39,34 +39,16 @@ create your own ABCs with the :mod:`abc` module. argument - A value passed to a :term:`function` (or :term:`method`) when calling the - function. There are two types of arguments: + A value passed to a function or method, assigned to a named local + variable in the function body. A function or method may have both + positional arguments and keyword arguments in its definition. + Positional and keyword arguments may be variable-length: ``*`` accepts + or passes (if in the function definition or call) several positional + arguments in a list, while ``**`` does the same for keyword arguments + in a dictionary. - * :dfn:`keyword argument`: an argument preceded by an identifier (e.g. - ``name=``) in a function call or passed as a value in a dictionary - preceded by ``**``. For example, ``3`` and ``5`` are both keyword - arguments in the following calls to :func:`complex`:: - - complex(real=3, imag=5) - complex(**{'real': 3, 'imag': 5}) - - * :dfn:`positional argument`: an argument that is not a keyword argument. - Positional arguments can appear at the beginning of an argument list - and/or be passed as elements of an :term:`iterable` preceded by ``*``. - For example, ``3`` and ``5`` are both positional arguments in the - following calls:: - - complex(3, 5) - complex(*(3, 5)) - - Arguments are assigned to the named local variables in a function body. - See the :ref:`calls` section for the rules governing this assignment. - Syntactically, any expression can be used to represent an argument; the - evaluated value is assigned to the local variable. - - See also the :term:`parameter` glossary entry and the FAQ question on - :ref:`the difference between arguments and parameters - `. + Any expression may be used within the argument list, and the evaluated + value is passed to the local variable. attribute A value associated with an object which is referenced by name using @@ -77,14 +59,6 @@ Benevolent Dictator For Life, a.k.a. `Guido van Rossum `_, Python's creator. - bytes-like object - An object that supports the :ref:`buffer protocol `, - like :class:`str`, :class:`bytearray` or :class:`memoryview`. - Bytes-like objects can be used for various operations that expect - binary data, such as compression, saving to a binary file or sending - over a socket. Some operations need the binary data to be mutable, - in which case not all bytes-like objects can apply. - bytecode Python source code is compiled into bytecode, the internal representation of a Python program in the CPython interpreter. The bytecode is also @@ -106,7 +80,7 @@ classic class Any class which does not inherit from :class:`object`. See - :term:`new-style class`. Classic classes have been removed in Python 3. + :term:`new-style class`. Classic classes will be removed in Python 3.0. coercion The implicit conversion of an instance of one type to another during an @@ -178,9 +152,9 @@ For more information about descriptors' methods, see :ref:`descriptors`. dictionary - An associative array, where arbitrary keys are mapped to values. The - keys can be any object with :meth:`__hash__` and :meth:`__eq__` methods. - Called a hash in Perl. + An associative array, where arbitrary keys are mapped to values. The keys + can be any object with :meth:`__hash__` function and :meth:`__eq__` + methods. Called a hash in Perl. docstring A string literal which appears as the first expression in a class, @@ -226,7 +200,7 @@ An object exposing a file-oriented API (with methods such as :meth:`read()` or :meth:`write()`) to an underlying resource. Depending on the way it was created, a file object can mediate access to a real - on-disk file or to another type of storage or communication device + on-disk file or to another other type of storage or communication device (for example standard input/output, in-memory buffers, sockets, pipes, etc.). File objects are also called :dfn:`file-like objects` or :dfn:`streams`. @@ -253,9 +227,8 @@ function A series of statements which returns some value to a caller. It can also - be passed zero or more :term:`arguments ` which may be used in - the execution of the body. See also :term:`parameter`, :term:`method`, - and the :ref:`function` section. + be passed zero or more arguments which may be used in the execution of + the body. See also :term:`argument` and :term:`method`. __future__ A pseudo-module which programmers can use to enable new language features @@ -338,8 +311,7 @@ All of Python's immutable built-in objects are hashable, while no mutable containers (such as lists or dictionaries) are. Objects which are instances of user-defined classes are hashable by default; they all - compare unequal (except with themselves), and their hash value is their - :func:`id`. + compare unequal, and their hash value is their :func:`id`. IDLE An Integrated Development Environment for Python. IDLE is a basic editor @@ -365,10 +337,6 @@ fraction. Integer division can be forced by using the ``//`` operator instead of the ``/`` operator. See also :term:`__future__`. - importing - The process by which Python code in one module is made available to - Python code in another module. - importer An object that both finds and loads a module; both a :term:`finder` and :term:`loader` object. @@ -391,17 +359,17 @@ slowly. See also :term:`interactive`. iterable - An object capable of returning its members one at a time. Examples of - iterables include all sequence types (such as :class:`list`, :class:`str`, - and :class:`tuple`) and some non-sequence types like :class:`dict` - and :class:`file` and objects of any classes you define - with an :meth:`__iter__` or :meth:`__getitem__` method. Iterables can be - used in a :keyword:`for` loop and in many other places where a sequence is - needed (:func:`zip`, :func:`map`, ...). When an iterable object is passed - as an argument to the built-in function :func:`iter`, it returns an - iterator for the object. This iterator is good for one pass over the set - of values. When using iterables, it is usually not necessary to call - :func:`iter` or deal with iterator objects yourself. The ``for`` + An object capable of returning its members one at a + time. Examples of iterables include all sequence types (such as + :class:`list`, :class:`str`, and :class:`tuple`) and some non-sequence + types like :class:`dict` and :class:`file` and objects of any classes you + define with an :meth:`__iter__` or :meth:`__getitem__` method. Iterables + can be used in a :keyword:`for` loop and in many other places where a + sequence is needed (:func:`zip`, :func:`map`, ...). When an iterable + object is passed as an argument to the built-in function :func:`iter`, it + returns an iterator for the object. This iterator is good for one pass + over the set of values. When using iterables, it is usually not necessary + to call :func:`iter` or deal with iterator objects yourself. The ``for`` statement does that automatically for you, creating a temporary unnamed variable to hold the iterator for the duration of the loop. See also :term:`iterator`, :term:`sequence`, and :term:`generator`. @@ -438,13 +406,16 @@ :meth:`str.lower` method can serve as a key function for case insensitive sorts. Alternatively, an ad-hoc key function can be built from a :keyword:`lambda` expression such as ``lambda r: (r[0], r[2])``. Also, - the :mod:`operator` module provides three key function constructors: + the :mod:`operator` module provides three key function constuctors: :func:`~operator.attrgetter`, :func:`~operator.itemgetter`, and :func:`~operator.methodcaller`. See the :ref:`Sorting HOW TO ` for examples of how to create and use key functions. keyword argument - See :term:`argument`. + Arguments which are preceded with a ``variable_name=`` in the call. + The variable name designates the local name in the function to which the + value is assigned. ``**`` is used to accept or pass a dictionary of + keyword arguments. See :term:`argument`. lambda An anonymous inline function consisting of a single :term:`expression` @@ -513,13 +484,6 @@ for a member during lookup. See `The Python 2.3 Method Resolution Order `_. - module - An object that serves as an organizational unit of Python code. Modules - have a namespace containing arbitrary Python objects. Modules are loaded - into Python by the process of :term:`importing`. - - See also :term:`package`. - MRO See :term:`method resolution order`. @@ -555,15 +519,16 @@ nested scope The ability to refer to a variable in an enclosing definition. For instance, a function defined inside another function can refer to - variables in the outer function. Note that nested scopes work only for - reference and not for assignment which will always write to the innermost - scope. In contrast, local variables both read and write in the innermost - scope. Likewise, global variables read and write to the global namespace. + variables in the outer function. Note that nested scopes by default work + only for reference and not for assignment. Local variables both read and + write in the innermost scope. Likewise, global variables read and write + to the global namespace. The :keyword:`nonlocal` allows writing to outer + scopes. new-style class Any class which inherits from :class:`object`. This includes all built-in types like :class:`list` and :class:`dict`. Only new-style classes can - use Python's newer, versatile features like :attr:`~object.__slots__`, + use Python's newer, versatile features like :attr:`__slots__`, descriptors, properties, and :meth:`__getattribute__`. More information can be found in :ref:`newstyle`. @@ -573,51 +538,12 @@ (methods). Also the ultimate base class of any :term:`new-style class`. - package - A Python :term:`module` which can contain submodules or recursively, - subpackages. Technically, a package is a Python module with an - ``__path__`` attribute. - - parameter - A named entity in a :term:`function` (or method) definition that - specifies an :term:`argument` (or in some cases, arguments) that the - function can accept. There are four types of parameters: - - * :dfn:`positional-or-keyword`: specifies an argument that can be passed - either :term:`positionally ` or as a :term:`keyword argument - `. This is the default kind of parameter, for example *foo* - and *bar* in the following:: - - def func(foo, bar=None): ... - - * :dfn:`positional-only`: specifies an argument that can be supplied only - by position. Python has no syntax for defining positional-only - parameters. However, some built-in functions have positional-only - parameters (e.g. :func:`abs`). - - * :dfn:`var-positional`: specifies that an arbitrary sequence of - positional arguments can be provided (in addition to any positional - arguments already accepted by other parameters). Such a parameter can - be defined by prepending the parameter name with ``*``, for example - *args* in the following:: - - def func(*args, **kwargs): ... - - * :dfn:`var-keyword`: specifies that arbitrarily many keyword arguments - can be provided (in addition to any keyword arguments already accepted - by other parameters). Such a parameter can be defined by prepending - the parameter name with ``**``, for example *kwargs* in the example - above. - - Parameters can specify both optional and required arguments, as well as - default values for some optional arguments. - - See also the :term:`argument` glossary entry, the FAQ question on - :ref:`the difference between arguments and parameters - `, and the :ref:`function` section. - positional argument - See :term:`argument`. + The arguments assigned to local names inside a function or method, + determined by the order in which they were given in the call. ``*`` is + used to either accept multiple positional arguments (when in the + definition), or pass several arguments as a list to a function. See + :term:`argument`. Python 3000 Nickname for the Python 3.x release line (coined long ago when the release @@ -680,7 +606,7 @@ statement A statement is part of a suite (a "block" of code). A statement is either - an :term:`expression` or one of several constructs with a keyword, such + an :term:`expression` or a one of several constructs with a keyword, such as :keyword:`if`, :keyword:`while` or :keyword:`for`. struct sequence @@ -703,15 +629,7 @@ type The type of a Python object determines what kind of object it is; every object has a type. An object's type is accessible as its - :attr:`~instance.__class__` attribute or can be retrieved with - ``type(obj)``. - - universal newlines - A manner of interpreting text streams in which all of the following are - recognized as ending a line: the Unix end-of-line convention ``'\n'``, - the Windows convention ``'\r\n'``, and the old Macintosh convention - ``'\r'``. See :pep:`278` and :pep:`3116`, as well as - :func:`str.splitlines` for an additional use. + :attr:`__class__` attribute or can be retrieved with ``type(obj)``. view The objects returned from :meth:`dict.viewkeys`, :meth:`dict.viewvalues`, diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/howto/advocacy.rst --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Doc/howto/advocacy.rst Sun Jul 20 10:52:46 2014 -0400 @@ -0,0 +1,356 @@ +************************* + Python Advocacy HOWTO +************************* + +:Author: A.M. Kuchling +:Release: 0.03 + + +.. topic:: Abstract + + It's usually difficult to get your management to accept open source software, + and Python is no exception to this rule. This document discusses reasons to use + Python, strategies for winning acceptance, facts and arguments you can use, and + cases where you *shouldn't* try to use Python. + + +Reasons to Use Python +===================== + +There are several reasons to incorporate a scripting language into your +development process, and this section will discuss them, and why Python has some +properties that make it a particularly good choice. + + +Programmability +--------------- + +Programs are often organized in a modular fashion. Lower-level operations are +grouped together, and called by higher-level functions, which may in turn be +used as basic operations by still further upper levels. + +For example, the lowest level might define a very low-level set of functions for +accessing a hash table. The next level might use hash tables to store the +headers of a mail message, mapping a header name like ``Date`` to a value such +as ``Tue, 13 May 1997 20:00:54 -0400``. A yet higher level may operate on +message objects, without knowing or caring that message headers are stored in a +hash table, and so forth. + +Often, the lowest levels do very simple things; they implement a data structure +such as a binary tree or hash table, or they perform some simple computation, +such as converting a date string to a number. The higher levels then contain +logic connecting these primitive operations. Using the approach, the primitives +can be seen as basic building blocks which are then glued together to produce +the complete product. + +Why is this design approach relevant to Python? Because Python is well suited +to functioning as such a glue language. A common approach is to write a Python +module that implements the lower level operations; for the sake of speed, the +implementation might be in C, Java, or even Fortran. Once the primitives are +available to Python programs, the logic underlying higher level operations is +written in the form of Python code. The high-level logic is then more +understandable, and easier to modify. + +John Ousterhout wrote a paper that explains this idea at greater length, +entitled "Scripting: Higher Level Programming for the 21st Century". I +recommend that you read this paper; see the references for the URL. Ousterhout +is the inventor of the Tcl language, and therefore argues that Tcl should be +used for this purpose; he only briefly refers to other languages such as Python, +Perl, and Lisp/Scheme, but in reality, Ousterhout's argument applies to +scripting languages in general, since you could equally write extensions for any +of the languages mentioned above. + + +Prototyping +----------- + +In *The Mythical Man-Month*, Fredrick Brooks suggests the following rule when +planning software projects: "Plan to throw one away; you will anyway." Brooks +is saying that the first attempt at a software design often turns out to be +wrong; unless the problem is very simple or you're an extremely good designer, +you'll find that new requirements and features become apparent once development +has actually started. If these new requirements can't be cleanly incorporated +into the program's structure, you're presented with two unpleasant choices: +hammer the new features into the program somehow, or scrap everything and write +a new version of the program, taking the new features into account from the +beginning. + +Python provides you with a good environment for quickly developing an initial +prototype. That lets you get the overall program structure and logic right, and +you can fine-tune small details in the fast development cycle that Python +provides. Once you're satisfied with the GUI interface or program output, you +can translate the Python code into C++, Fortran, Java, or some other compiled +language. + +Prototyping means you have to be careful not to use too many Python features +that are hard to implement in your other language. Using ``eval()``, or regular +expressions, or the :mod:`pickle` module, means that you're going to need C or +Java libraries for formula evaluation, regular expressions, and serialization, +for example. But it's not hard to avoid such tricky code, and in the end the +translation usually isn't very difficult. The resulting code can be rapidly +debugged, because any serious logical errors will have been removed from the +prototype, leaving only more minor slip-ups in the translation to track down. + +This strategy builds on the earlier discussion of programmability. Using Python +as glue to connect lower-level components has obvious relevance for constructing +prototype systems. In this way Python can help you with development, even if +end users never come in contact with Python code at all. If the performance of +the Python version is adequate and corporate politics allow it, you may not need +to do a translation into C or Java, but it can still be faster to develop a +prototype and then translate it, instead of attempting to produce the final +version immediately. + +One example of this development strategy is Microsoft Merchant Server. Version +1.0 was written in pure Python, by a company that subsequently was purchased by +Microsoft. Version 2.0 began to translate the code into C++, shipping with some +C++code and some Python code. Version 3.0 didn't contain any Python at all; all +the code had been translated into C++. Even though the product doesn't contain +a Python interpreter, the Python language has still served a useful purpose by +speeding up development. + +This is a very common use for Python. Past conference papers have also +described this approach for developing high-level numerical algorithms; see +David M. Beazley and Peter S. Lomdahl's paper "Feeding a Large-scale Physics +Application to Python" in the references for a good example. If an algorithm's +basic operations are things like "Take the inverse of this 4000x4000 matrix", +and are implemented in some lower-level language, then Python has almost no +additional performance cost; the extra time required for Python to evaluate an +expression like ``m.invert()`` is dwarfed by the cost of the actual computation. +It's particularly good for applications where seemingly endless tweaking is +required to get things right. GUI interfaces and Web sites are prime examples. + +The Python code is also shorter and faster to write (once you're familiar with +Python), so it's easier to throw it away if you decide your approach was wrong; +if you'd spent two weeks working on it instead of just two hours, you might +waste time trying to patch up what you've got out of a natural reluctance to +admit that those two weeks were wasted. Truthfully, those two weeks haven't +been wasted, since you've learnt something about the problem and the technology +you're using to solve it, but it's human nature to view this as a failure of +some sort. + + +Simplicity and Ease of Understanding +------------------------------------ + +Python is definitely *not* a toy language that's only usable for small tasks. +The language features are general and powerful enough to enable it to be used +for many different purposes. It's useful at the small end, for 10- or 20-line +scripts, but it also scales up to larger systems that contain thousands of lines +of code. + +However, this expressiveness doesn't come at the cost of an obscure or tricky +syntax. While Python has some dark corners that can lead to obscure code, there +are relatively few such corners, and proper design can isolate their use to only +a few classes or modules. It's certainly possible to write confusing code by +using too many features with too little concern for clarity, but most Python +code can look a lot like a slightly-formalized version of human-understandable +pseudocode. + +In *The New Hacker's Dictionary*, Eric S. Raymond gives the following definition +for "compact": + +.. epigraph:: + + Compact *adj.* Of a design, describes the valuable property that it can all be + apprehended at once in one's head. This generally means the thing created from + the design can be used with greater facility and fewer errors than an equivalent + tool that is not compact. Compactness does not imply triviality or lack of + power; for example, C is compact and FORTRAN is not, but C is more powerful than + FORTRAN. Designs become non-compact through accreting features and cruft that + don't merge cleanly into the overall design scheme (thus, some fans of Classic C + maintain that ANSI C is no longer compact). + + (From http://www.catb.org/~esr/jargon/html/C/compact.html) + +In this sense of the word, Python is quite compact, because the language has +just a few ideas, which are used in lots of places. Take namespaces, for +example. Import a module with ``import math``, and you create a new namespace +called ``math``. Classes are also namespaces that share many of the properties +of modules, and have a few of their own; for example, you can create instances +of a class. Instances? They're yet another namespace. Namespaces are currently +implemented as Python dictionaries, so they have the same methods as the +standard dictionary data type: .keys() returns all the keys, and so forth. + +This simplicity arises from Python's development history. The language syntax +derives from different sources; ABC, a relatively obscure teaching language, is +one primary influence, and Modula-3 is another. (For more information about ABC +and Modula-3, consult their respective Web sites at http://www.cwi.nl/~steven/abc/ +and http://www.m3.org.) Other features have come from C, Icon, +Algol-68, and even Perl. Python hasn't really innovated very much, but instead +has tried to keep the language small and easy to learn, building on ideas that +have been tried in other languages and found useful. + +Simplicity is a virtue that should not be underestimated. It lets you learn the +language more quickly, and then rapidly write code -- code that often works the +first time you run it. + + +Java Integration +---------------- + +If you're working with Java, Jython (http://www.jython.org/) is definitely worth +your attention. Jython is a re-implementation of Python in Java that compiles +Python code into Java bytecodes. The resulting environment has very tight, +almost seamless, integration with Java. It's trivial to access Java classes +from Python, and you can write Python classes that subclass Java classes. +Jython can be used for prototyping Java applications in much the same way +CPython is used, and it can also be used for test suites for Java code, or +embedded in a Java application to add scripting capabilities. + + +Arguments and Rebuttals +======================= + +Let's say that you've decided upon Python as the best choice for your +application. How can you convince your management, or your fellow developers, +to use Python? This section lists some common arguments against using Python, +and provides some possible rebuttals. + +**Python is freely available software that doesn't cost anything. How good can +it be?** + +Very good, indeed. These days Linux and Apache, two other pieces of open source +software, are becoming more respected as alternatives to commercial software, +but Python hasn't had all the publicity. + +Python has been around for several years, with many users and developers. +Accordingly, the interpreter has been used by many people, and has gotten most +of the bugs shaken out of it. While bugs are still discovered at intervals, +they're usually either quite obscure (they'd have to be, for no one to have run +into them before) or they involve interfaces to external libraries. The +internals of the language itself are quite stable. + +Having the source code should be viewed as making the software available for +peer review; people can examine the code, suggest (and implement) improvements, +and track down bugs. To find out more about the idea of open source code, along +with arguments and case studies supporting it, go to http://www.opensource.org. + +**Who's going to support it?** + +Python has a sizable community of developers, and the number is still growing. +The Internet community surrounding the language is an active one, and is worth +being considered another one of Python's advantages. Most questions posted to +the comp.lang.python newsgroup are quickly answered by someone. + +Should you need to dig into the source code, you'll find it's clear and +well-organized, so it's not very difficult to write extensions and track down +bugs yourself. If you'd prefer to pay for support, there are companies and +individuals who offer commercial support for Python. + +**Who uses Python for serious work?** + +Lots of people; one interesting thing about Python is the surprising diversity +of applications that it's been used for. People are using Python to: + +* Run Web sites + +* Write GUI interfaces + +* Control number-crunching code on supercomputers + +* Make a commercial application scriptable by embedding the Python interpreter + inside it + +* Process large XML data sets + +* Build test suites for C or Java code + +Whatever your application domain is, there's probably someone who's used Python +for something similar. Yet, despite being useable for such high-end +applications, Python's still simple enough to use for little jobs. + +See http://wiki.python.org/moin/OrganizationsUsingPython for a list of some of +the organizations that use Python. + +**What are the restrictions on Python's use?** + +They're practically nonexistent. Consult the :file:`Misc/COPYRIGHT` file in the +source distribution, or the section :ref:`history-and-license` for the full +language, but it boils down to three conditions: + +* You have to leave the copyright notice on the software; if you don't include + the source code in a product, you have to put the copyright notice in the + supporting documentation. + +* Don't claim that the institutions that have developed Python endorse your + product in any way. + +* If something goes wrong, you can't sue for damages. Practically all software + licenses contain this condition. + +Notice that you don't have to provide source code for anything that contains +Python or is built with it. Also, the Python interpreter and accompanying +documentation can be modified and redistributed in any way you like, and you +don't have to pay anyone any licensing fees at all. + +**Why should we use an obscure language like Python instead of well-known +language X?** + +I hope this HOWTO, and the documents listed in the final section, will help +convince you that Python isn't obscure, and has a healthily growing user base. +One word of advice: always present Python's positive advantages, instead of +concentrating on language X's failings. People want to know why a solution is +good, rather than why all the other solutions are bad. So instead of attacking +a competing solution on various grounds, simply show how Python's virtues can +help. + + +Useful Resources +================ + +http://www.pythonology.com/success + The Python Success Stories are a collection of stories from successful users of + Python, with the emphasis on business and corporate users. + +.. http://www.fsbassociates.com/books/pythonchpt1.htm + The first chapter of \emph{Internet Programming with Python} also + examines some of the reasons for using Python. The book is well worth + buying, but the publishers have made the first chapter available on + the Web. + +http://www.tcl.tk/doc/scripting.html + John Ousterhout's white paper on scripting is a good argument for the utility of + scripting languages, though naturally enough, he emphasizes Tcl, the language he + developed. Most of the arguments would apply to any scripting language. + +http://www.python.org/workshops/1997-10/proceedings/beazley.html + The authors, David M. Beazley and Peter S. Lomdahl, describe their use of + Python at Los Alamos National Laboratory. It's another good example of how + Python can help get real work done. This quotation from the paper has been + echoed by many people: + + .. epigraph:: + + Originally developed as a large monolithic application for massively parallel + processing systems, we have used Python to transform our application into a + flexible, highly modular, and extremely powerful system for performing + simulation, data analysis, and visualization. In addition, we describe how + Python has solved a number of important problems related to the development, + debugging, deployment, and maintenance of scientific software. + +http://pythonjournal.cognizor.com/pyj1/Everitt-Feit_interview98-V1.html + This interview with Andy Feit, discussing Infoseek's use of Python, can be used + to show that choosing Python didn't introduce any difficulties into a company's + development process, and provided some substantial benefits. + +.. http://www.python.org/psa/Commercial.html + Robin Friedrich wrote this document on how to support Python's use in + commercial projects. + +http://www.python.org/workshops/1997-10/proceedings/stein.ps + For the 6th Python conference, Greg Stein presented a paper that traced Python's + adoption and usage at a startup called eShop, and later at Microsoft. + +http://www.opensource.org + Management may be doubtful of the reliability and usefulness of software that + wasn't written commercially. This site presents arguments that show how open + source software can have considerable advantages over closed-source software. + +http://www.faqs.org/docs/Linux-mini/Advocacy.html + The Linux Advocacy mini-HOWTO was the inspiration for this document, and is also + well worth reading for general suggestions on winning acceptance for a new + technology, such as Linux or Python. In general, you won't make much progress + by simply attacking existing systems and complaining about their inadequacies; + this often ends up looking like unfocused whining. It's much better to point + out some of the many areas where Python is an improvement over other systems. + diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/howto/argparse.rst --- a/Doc/howto/argparse.rst Sat Jul 19 16:34:33 2014 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,764 +0,0 @@ -***************** -Argparse Tutorial -***************** - -:author: Tshepang Lekhonkhobe - -.. _argparse-tutorial: - -This tutorial is intended to be a gentle introduction to :mod:`argparse`, the -recommended command-line parsing module in the Python standard library. - -.. note:: - - There are two other modules that fulfill the same task, namely - :mod:`getopt` (an equivalent for :c:func:`getopt` from the C - language) and the deprecated :mod:`optparse`. - Note also that :mod:`argparse` is based on :mod:`optparse`, - and therefore very similar in terms of usage. - - -Concepts -======== - -Let's show the sort of functionality that we are going to explore in this -introductory tutorial by making use of the :command:`ls` command: - -.. code-block:: sh - - $ ls - cpython devguide prog.py pypy rm-unused-function.patch - $ ls pypy - ctypes_configure demo dotviewer include lib_pypy lib-python ... - $ ls -l - total 20 - drwxr-xr-x 19 wena wena 4096 Feb 18 18:51 cpython - drwxr-xr-x 4 wena wena 4096 Feb 8 12:04 devguide - -rwxr-xr-x 1 wena wena 535 Feb 19 00:05 prog.py - drwxr-xr-x 14 wena wena 4096 Feb 7 00:59 pypy - -rw-r--r-- 1 wena wena 741 Feb 18 01:01 rm-unused-function.patch - $ ls --help - Usage: ls [OPTION]... [FILE]... - List information about the FILEs (the current directory by default). - Sort entries alphabetically if none of -cftuvSUX nor --sort is specified. - ... - -A few concepts we can learn from the four commands: - -* The :command:`ls` command is useful when run without any options at all. It defaults - to displaying the contents of the current directory. - -* If we want beyond what it provides by default, we tell it a bit more. In - this case, we want it to display a different directory, ``pypy``. - What we did is specify what is known as a positional argument. It's named so - because the program should know what to do with the value, solely based on - where it appears on the command line. This concept is more relevant - to a command like :command:`cp`, whose most basic usage is ``cp SRC DEST``. - The first position is *what you want copied,* and the second - position is *where you want it copied to*. - -* Now, say we want to change behaviour of the program. In our example, - we display more info for each file instead of just showing the file names. - The ``-l`` in that case is known as an optional argument. - -* That's a snippet of the help text. It's very useful in that you can - come across a program you have never used before, and can figure out - how it works simply by reading its help text. - - -The basics -========== - -Let us start with a very simple example which does (almost) nothing:: - - import argparse - parser = argparse.ArgumentParser() - parser.parse_args() - -Following is a result of running the code: - -.. code-block:: sh - - $ python prog.py - $ python prog.py --help - usage: prog.py [-h] - - optional arguments: - -h, --help show this help message and exit - $ python prog.py --verbose - usage: prog.py [-h] - prog.py: error: unrecognized arguments: --verbose - $ python prog.py foo - usage: prog.py [-h] - prog.py: error: unrecognized arguments: foo - -Here is what is happening: - -* Running the script without any options results in nothing displayed to - stdout. Not so useful. - -* The second one starts to display the usefulness of the :mod:`argparse` - module. We have done almost nothing, but already we get a nice help message. - -* The ``--help`` option, which can also be shortened to ``-h``, is the only - option we get for free (i.e. no need to specify it). Specifying anything - else results in an error. But even then, we do get a useful usage message, - also for free. - - -Introducing Positional arguments -================================ - -An example:: - - import argparse - parser = argparse.ArgumentParser() - parser.add_argument("echo") - args = parser.parse_args() - print args.echo - -And running the code: - -.. code-block:: sh - - $ python prog.py - usage: prog.py [-h] echo - prog.py: error: the following arguments are required: echo - $ python prog.py --help - usage: prog.py [-h] echo - - positional arguments: - echo - - optional arguments: - -h, --help show this help message and exit - $ python prog.py foo - foo - -Here is what's happening: - -* We've added the :meth:`add_argument` method, which is what we use to specify - which command-line options the program is willing to accept. In this case, - I've named it ``echo`` so that it's in line with its function. - -* Calling our program now requires us to specify an option. - -* The :meth:`parse_args` method actually returns some data from the - options specified, in this case, ``echo``. - -* The variable is some form of 'magic' that :mod:`argparse` performs for free - (i.e. no need to specify which variable that value is stored in). - You will also notice that its name matches the string argument given - to the method, ``echo``. - -Note however that, although the help display looks nice and all, it currently -is not as helpful as it can be. For example we see that we got ``echo`` as a -positional argument, but we don't know what it does, other than by guessing or -by reading the source code. So, let's make it a bit more useful:: - - import argparse - parser = argparse.ArgumentParser() - parser.add_argument("echo", help="echo the string you use here") - args = parser.parse_args() - print args.echo - -And we get: - -.. code-block:: sh - - $ python prog.py -h - usage: prog.py [-h] echo - - positional arguments: - echo echo the string you use here - - optional arguments: - -h, --help show this help message and exit - -Now, how about doing something even more useful:: - - import argparse - parser = argparse.ArgumentParser() - parser.add_argument("square", help="display a square of a given number") - args = parser.parse_args() - print args.square**2 - -Following is a result of running the code: - -.. code-block:: sh - - $ python prog.py 4 - Traceback (most recent call last): - File "prog.py", line 5, in - print args.square**2 - TypeError: unsupported operand type(s) for ** or pow(): 'str' and 'int' - -That didn't go so well. That's because :mod:`argparse` treats the options we -give it as strings, unless we tell it otherwise. So, let's tell -:mod:`argparse` to treat that input as an integer:: - - import argparse - parser = argparse.ArgumentParser() - parser.add_argument("square", help="display a square of a given number", - type=int) - args = parser.parse_args() - print args.square**2 - -Following is a result of running the code: - -.. code-block:: sh - - $ python prog.py 4 - 16 - $ python prog.py four - usage: prog.py [-h] square - prog.py: error: argument square: invalid int value: 'four' - -That went well. The program now even helpfully quits on bad illegal input -before proceeding. - - -Introducing Optional arguments -============================== - -So far we, have been playing with positional arguments. Let us -have a look on how to add optional ones:: - - import argparse - parser = argparse.ArgumentParser() - parser.add_argument("--verbosity", help="increase output verbosity") - args = parser.parse_args() - if args.verbosity: - print "verbosity turned on" - -And the output: - -.. code-block:: sh - - $ python prog.py --verbosity 1 - verbosity turned on - $ python prog.py - $ python prog.py --help - usage: prog.py [-h] [--verbosity VERBOSITY] - - optional arguments: - -h, --help show this help message and exit - --verbosity VERBOSITY - increase output verbosity - $ python prog.py --verbosity - usage: prog.py [-h] [--verbosity VERBOSITY] - prog.py: error: argument --verbosity: expected one argument - -Here is what is happening: - -* The program is written so as to display something when ``--verbosity`` is - specified and display nothing when not. - -* To show that the option is actually optional, there is no error when running - the program without it. Note that by default, if an optional argument isn't - used, the relevant variable, in this case :attr:`args.verbosity`, is - given ``None`` as a value, which is the reason it fails the truth - test of the :keyword:`if` statement. - -* The help message is a bit different. - -* When using the ``--verbosity`` option, one must also specify some value, - any value. - -The above example accepts arbitrary integer values for ``--verbosity``, but for -our simple program, only two values are actually useful, ``True`` or ``False``. -Let's modify the code accordingly:: - - import argparse - parser = argparse.ArgumentParser() - parser.add_argument("--verbose", help="increase output verbosity", - action="store_true") - args = parser.parse_args() - if args.verbose: - print "verbosity turned on" - -And the output: - -.. code-block:: sh - - $ python prog.py --verbose - verbosity turned on - $ python prog.py --verbose 1 - usage: prog.py [-h] [--verbose] - prog.py: error: unrecognized arguments: 1 - $ python prog.py --help - usage: prog.py [-h] [--verbose] - - optional arguments: - -h, --help show this help message and exit - --verbose increase output verbosity - -Here is what is happening: - -* The option is now more of a flag than something that requires a value. - We even changed the name of the option to match that idea. - Note that we now specify a new keyword, ``action``, and give it the value - ``"store_true"``. This means that, if the option is specified, - assign the value ``True`` to :data:`args.verbose`. - Not specifying it implies ``False``. - -* It complains when you specify a value, in true spirit of what flags - actually are. - -* Notice the different help text. - - -Short options -------------- - -If you are familiar with command line usage, -you will notice that I haven't yet touched on the topic of short -versions of the options. It's quite simple:: - - import argparse - parser = argparse.ArgumentParser() - parser.add_argument("-v", "--verbose", help="increase output verbosity", - action="store_true") - args = parser.parse_args() - if args.verbose: - print "verbosity turned on" - -And here goes: - -.. code-block:: sh - - $ python prog.py -v - verbosity turned on - $ python prog.py --help - usage: prog.py [-h] [-v] - - optional arguments: - -h, --help show this help message and exit - -v, --verbose increase output verbosity - -Note that the new ability is also reflected in the help text. - - -Combining Positional and Optional arguments -=========================================== - -Our program keeps growing in complexity:: - - import argparse - parser = argparse.ArgumentParser() - parser.add_argument("square", type=int, - help="display a square of a given number") - parser.add_argument("-v", "--verbose", action="store_true", - help="increase output verbosity") - args = parser.parse_args() - answer = args.square**2 - if args.verbose: - print "the square of {} equals {}".format(args.square, answer) - else: - print answer - -And now the output: - -.. code-block:: sh - - $ python prog.py - usage: prog.py [-h] [-v] square - prog.py: error: the following arguments are required: square - $ python prog.py 4 - 16 - $ python prog.py 4 --verbose - the square of 4 equals 16 - $ python prog.py --verbose 4 - the square of 4 equals 16 - -* We've brought back a positional argument, hence the complaint. - -* Note that the order does not matter. - -How about we give this program of ours back the ability to have -multiple verbosity values, and actually get to use them:: - - import argparse - parser = argparse.ArgumentParser() - parser.add_argument("square", type=int, - help="display a square of a given number") - parser.add_argument("-v", "--verbosity", type=int, - help="increase output verbosity") - args = parser.parse_args() - answer = args.square**2 - if args.verbosity == 2: - print "the square of {} equals {}".format(args.square, answer) - elif args.verbosity == 1: - print "{}^2 == {}".format(args.square, answer) - else: - print answer - -And the output: - -.. code-block:: sh - - $ python prog.py 4 - 16 - $ python prog.py 4 -v - usage: prog.py [-h] [-v VERBOSITY] square - prog.py: error: argument -v/--verbosity: expected one argument - $ python prog.py 4 -v 1 - 4^2 == 16 - $ python prog.py 4 -v 2 - the square of 4 equals 16 - $ python prog.py 4 -v 3 - 16 - -These all look good except the last one, which exposes a bug in our program. -Let's fix it by restricting the values the ``--verbosity`` option can accept:: - - import argparse - parser = argparse.ArgumentParser() - parser.add_argument("square", type=int, - help="display a square of a given number") - parser.add_argument("-v", "--verbosity", type=int, choices=[0, 1, 2], - help="increase output verbosity") - args = parser.parse_args() - answer = args.square**2 - if args.verbosity == 2: - print "the square of {} equals {}".format(args.square, answer) - elif args.verbosity == 1: - print "{}^2 == {}".format(args.square, answer) - else: - print answer - -And the output: - -.. code-block:: sh - - $ python prog.py 4 -v 3 - usage: prog.py [-h] [-v {0,1,2}] square - prog.py: error: argument -v/--verbosity: invalid choice: 3 (choose from 0, 1, 2) - $ python prog.py 4 -h - usage: prog.py [-h] [-v {0,1,2}] square - - positional arguments: - square display a square of a given number - - optional arguments: - -h, --help show this help message and exit - -v {0,1,2}, --verbosity {0,1,2} - increase output verbosity - -Note that the change also reflects both in the error message as well as the -help string. - -Now, let's use a different approach of playing with verbosity, which is pretty -common. It also matches the way the CPython executable handles its own -verbosity argument (check the output of ``python --help``):: - - import argparse - parser = argparse.ArgumentParser() - parser.add_argument("square", type=int, - help="display the square of a given number") - parser.add_argument("-v", "--verbosity", action="count", - help="increase output verbosity") - args = parser.parse_args() - answer = args.square**2 - if args.verbosity == 2: - print "the square of {} equals {}".format(args.square, answer) - elif args.verbosity == 1: - print "{}^2 == {}".format(args.square, answer) - else: - print answer - -We have introduced another action, "count", -to count the number of occurrences of a specific optional arguments: - -.. code-block:: sh - - $ python prog.py 4 - 16 - $ python prog.py 4 -v - 4^2 == 16 - $ python prog.py 4 -vv - the square of 4 equals 16 - $ python prog.py 4 --verbosity --verbosity - the square of 4 equals 16 - $ python prog.py 4 -v 1 - usage: prog.py [-h] [-v] square - prog.py: error: unrecognized arguments: 1 - $ python prog.py 4 -h - usage: prog.py [-h] [-v] square - - positional arguments: - square display a square of a given number - - optional arguments: - -h, --help show this help message and exit - -v, --verbosity increase output verbosity - $ python prog.py 4 -vvv - 16 - -* Yes, it's now more of a flag (similar to ``action="store_true"``) in the - previous version of our script. That should explain the complaint. - -* It also behaves similar to "store_true" action. - -* Now here's a demonstration of what the "count" action gives. You've probably - seen this sort of usage before. - -* And, just like the "store_true" action, if you don't specify the ``-v`` flag, - that flag is considered to have ``None`` value. - -* As should be expected, specifying the long form of the flag, we should get - the same output. - -* Sadly, our help output isn't very informative on the new ability our script - has acquired, but that can always be fixed by improving the documentation for - out script (e.g. via the ``help`` keyword argument). - -* That last output exposes a bug in our program. - - -Let's fix:: - - import argparse - parser = argparse.ArgumentParser() - parser.add_argument("square", type=int, - help="display a square of a given number") - parser.add_argument("-v", "--verbosity", action="count", - help="increase output verbosity") - args = parser.parse_args() - answer = args.square**2 - - # bugfix: replace == with >= - if args.verbosity >= 2: - print "the square of {} equals {}".format(args.square, answer) - elif args.verbosity >= 1: - print "{}^2 == {}".format(args.square, answer) - else: - print answer - -And this is what it gives: - -.. code-block:: sh - - $ python prog.py 4 -vvv - the square of 4 equals 16 - $ python prog.py 4 -vvvv - the square of 4 equals 16 - $ python prog.py 4 - Traceback (most recent call last): - File "prog.py", line 11, in - if args.verbosity >= 2: - TypeError: unorderable types: NoneType() >= int() - -* First output went well, and fixes the bug we had before. - That is, we want any value >= 2 to be as verbose as possible. - -* Third output not so good. - -Let's fix that bug:: - - import argparse - parser = argparse.ArgumentParser() - parser.add_argument("square", type=int, - help="display a square of a given number") - parser.add_argument("-v", "--verbosity", action="count", default=0, - help="increase output verbosity") - args = parser.parse_args() - answer = args.square**2 - if args.verbosity >= 2: - print "the square of {} equals {}".format(args.square, answer) - elif args.verbosity >= 1: - print "{}^2 == {}".format(args.square, answer) - else: - print answer - -We've just introduced yet another keyword, ``default``. -We've set it to ``0`` in order to make it comparable to the other int values. -Remember that by default, -if an optional argument isn't specified, -it gets the ``None`` value, and that cannot be compared to an int value -(hence the :exc:`TypeError` exception). - -And: - -.. code-block:: sh - - $ python prog.py 4 - 16 - -You can go quite far just with what we've learned so far, -and we have only scratched the surface. -The :mod:`argparse` module is very powerful, -and we'll explore a bit more of it before we end this tutorial. - - -Getting a little more advanced -============================== - -What if we wanted to expand our tiny program to perform other powers, -not just squares:: - - import argparse - parser = argparse.ArgumentParser() - parser.add_argument("x", type=int, help="the base") - parser.add_argument("y", type=int, help="the exponent") - parser.add_argument("-v", "--verbosity", action="count", default=0) - args = parser.parse_args() - answer = args.x**args.y - if args.verbosity >= 2: - print "{} to the power {} equals {}".format(args.x, args.y, answer) - elif args.verbosity >= 1: - print "{}^{} == {}".format(args.x, args.y, answer) - else: - print answer - -Output: - -.. code-block:: sh - - $ python prog.py - usage: prog.py [-h] [-v] x y - prog.py: error: the following arguments are required: x, y - $ python prog.py -h - usage: prog.py [-h] [-v] x y - - positional arguments: - x the base - y the exponent - - optional arguments: - -h, --help show this help message and exit - -v, --verbosity - $ python prog.py 4 2 -v - 4^2 == 16 - - -Notice that so far we've been using verbosity level to *change* the text -that gets displayed. The following example instead uses verbosity level -to display *more* text instead:: - - import argparse - parser = argparse.ArgumentParser() - parser.add_argument("x", type=int, help="the base") - parser.add_argument("y", type=int, help="the exponent") - parser.add_argument("-v", "--verbosity", action="count", default=0) - args = parser.parse_args() - answer = args.x**args.y - if args.verbosity >= 2: - print "Running '{}'".format(__file__) - if args.verbosity >= 1: - print "{}^{} ==".format(args.x, args.y), - print answer - -Output: - -.. code-block:: sh - - $ python prog.py 4 2 - 16 - $ python prog.py 4 2 -v - 4^2 == 16 - $ python prog.py 4 2 -vv - Running 'prog.py' - 4^2 == 16 - - -Conflicting options -------------------- - -So far, we have been working with two methods of an -:class:`argparse.ArgumentParser` instance. Let's introduce a third one, -:meth:`add_mutually_exclusive_group`. It allows for us to specify options that -conflict with each other. Let's also change the rest of the program so that -the new functionality makes more sense: -we'll introduce the ``--quiet`` option, -which will be the opposite of the ``--verbose`` one:: - - import argparse - - parser = argparse.ArgumentParser() - group = parser.add_mutually_exclusive_group() - group.add_argument("-v", "--verbose", action="store_true") - group.add_argument("-q", "--quiet", action="store_true") - parser.add_argument("x", type=int, help="the base") - parser.add_argument("y", type=int, help="the exponent") - args = parser.parse_args() - answer = args.x**args.y - - if args.quiet: - print answer - elif args.verbose: - print "{} to the power {} equals {}".format(args.x, args.y, answer) - else: - print "{}^{} == {}".format(args.x, args.y, answer) - -Our program is now simpler, and we've lost some functionality for the sake of -demonstration. Anyways, here's the output: - -.. code-block:: sh - - $ python prog.py 4 2 - 4^2 == 16 - $ python prog.py 4 2 -q - 16 - $ python prog.py 4 2 -v - 4 to the power 2 equals 16 - $ python prog.py 4 2 -vq - usage: prog.py [-h] [-v | -q] x y - prog.py: error: argument -q/--quiet: not allowed with argument -v/--verbose - $ python prog.py 4 2 -v --quiet - usage: prog.py [-h] [-v | -q] x y - prog.py: error: argument -q/--quiet: not allowed with argument -v/--verbose - -That should be easy to follow. I've added that last output so you can see the -sort of flexibility you get, i.e. mixing long form options with short form -ones. - -Before we conclude, you probably want to tell your users the main purpose of -your program, just in case they don't know:: - - import argparse - - parser = argparse.ArgumentParser(description="calculate X to the power of Y") - group = parser.add_mutually_exclusive_group() - group.add_argument("-v", "--verbose", action="store_true") - group.add_argument("-q", "--quiet", action="store_true") - parser.add_argument("x", type=int, help="the base") - parser.add_argument("y", type=int, help="the exponent") - args = parser.parse_args() - answer = args.x**args.y - - if args.quiet: - print answer - elif args.verbose: - print "{} to the power {} equals {}".format(args.x, args.y, answer) - else: - print "{}^{} == {}".format(args.x, args.y, answer) - -Note that slight difference in the usage text. Note the ``[-v | -q]``, -which tells us that we can either use ``-v`` or ``-q``, -but not both at the same time: - -.. code-block:: sh - - $ python prog.py --help - usage: prog.py [-h] [-v | -q] x y - - calculate X to the power of Y - - positional arguments: - x the base - y the exponent - - optional arguments: - -h, --help show this help message and exit - -v, --verbose - -q, --quiet - - -Conclusion -========== - -The :mod:`argparse` module offers a lot more than shown here. -Its docs are quite detailed and thorough, and full of examples. -Having gone through this tutorial, you should easily digest them -without feeling overwhelmed. diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/howto/cporting.rst --- a/Doc/howto/cporting.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/howto/cporting.rst Sun Jul 20 10:52:46 2014 -0400 @@ -2,28 +2,27 @@ .. _cporting-howto: -************************************* -Porting Extension Modules to Python 3 -************************************* +******************************** +Porting Extension Modules to 3.0 +******************************** :author: Benjamin Peterson .. topic:: Abstract - Although changing the C-API was not one of Python 3's objectives, - the many Python-level changes made leaving Python 2's API intact - impossible. In fact, some changes such as :func:`int` and - :func:`long` unification are more obvious on the C level. This - document endeavors to document incompatibilities and how they can - be worked around. + Although changing the C-API was not one of Python 3.0's objectives, the many + Python level changes made leaving 2.x's API intact impossible. In fact, some + changes such as :func:`int` and :func:`long` unification are more obvious on + the C level. This document endeavors to document incompatibilities and how + they can be worked around. Conditional compilation ======================= -The easiest way to compile only some code for Python 3 is to check -if :c:macro:`PY_MAJOR_VERSION` is greater than or equal to 3. :: +The easiest way to compile only some code for 3.0 is to check if +:cmacro:`PY_MAJOR_VERSION` is greater than or equal to 3. :: #if PY_MAJOR_VERSION >= 3 #define IS_PY3K @@ -36,7 +35,7 @@ Changes to Object APIs ====================== -Python 3 merged together some types with similar functions while cleanly +Python 3.0 merged together some types with similar functions while cleanly separating others. @@ -44,16 +43,16 @@ ----------------------- -Python 3's :func:`str` (``PyString_*`` functions in C) type is equivalent to -Python 2's :func:`unicode` (``PyUnicode_*``). The old 8-bit string type has -become :func:`bytes`. Python 2.6 and later provide a compatibility header, +Python 3.0's :func:`str` (``PyString_*`` functions in C) type is equivalent to +2.x's :func:`unicode` (``PyUnicode_*``). The old 8-bit string type has become +:func:`bytes`. Python 2.6 and later provide a compatibility header, :file:`bytesobject.h`, mapping ``PyBytes`` names to ``PyString`` ones. For best -compatibility with Python 3, :c:type:`PyUnicode` should be used for textual data and -:c:type:`PyBytes` for binary data. It's also important to remember that -:c:type:`PyBytes` and :c:type:`PyUnicode` in Python 3 are not interchangeable like -:c:type:`PyString` and :c:type:`PyUnicode` are in Python 2. The following example -shows best practices with regards to :c:type:`PyUnicode`, :c:type:`PyString`, -and :c:type:`PyBytes`. :: +compatibility with 3.0, :ctype:`PyUnicode` should be used for textual data and +:ctype:`PyBytes` for binary data. It's also important to remember that +:ctype:`PyBytes` and :ctype:`PyUnicode` in 3.0 are not interchangeable like +:ctype:`PyString` and :ctype:`PyUnicode` are in 2.x. The following example +shows best practices with regards to :ctype:`PyUnicode`, :ctype:`PyString`, +and :ctype:`PyBytes`. :: #include "stdlib.h" #include "Python.h" @@ -95,20 +94,36 @@ long/int Unification -------------------- -Python 3 has only one integer type, :func:`int`. But it actually -corresponds to Python 2's :func:`long` type--the :func:`int` type -used in Python 2 was removed. In the C-API, ``PyInt_*`` functions -are replaced by their ``PyLong_*`` equivalents. +In Python 3.0, there is only one integer type. It is called :func:`int` on the +Python level, but actually corresponds to 2.x's :func:`long` type. In the +C-API, ``PyInt_*`` functions are replaced by their ``PyLong_*`` neighbors. The +best course of action here is using the ``PyInt_*`` functions aliased to +``PyLong_*`` found in :file:`intobject.h`. The abstract ``PyNumber_*`` APIs +can also be used in some cases. :: + + #include "Python.h" + #include "intobject.h" + + static PyObject * + add_ints(PyObject *self, PyObject *args) { + int one, two; + PyObject *result; + + if (!PyArg_ParseTuple(args, "ii:add_ints", &one, &two)) + return NULL; + + return PyInt_FromLong(one + two); + } + Module initialization and state =============================== -Python 3 has a revamped extension module initialization system. (See -:pep:`3121`.) Instead of storing module state in globals, they should -be stored in an interpreter specific structure. Creating modules that -act correctly in both Python 2 and Python 3 is tricky. The following -simple example demonstrates how. :: +Python 3.0 has a revamped extension module initialization system. (See +:pep:`3121`.) Instead of storing module state in globals, they should be stored +in an interpreter specific structure. Creating modules that act correctly in +both 2.x and 3.0 is tricky. The following simple example demonstrates how. :: #include "Python.h" @@ -197,53 +212,50 @@ CObject replaced with Capsule ============================= -The :c:type:`Capsule` object was introduced in Python 3.1 and 2.7 to replace -:c:type:`CObject`. CObjects were useful, -but the :c:type:`CObject` API was problematic: it didn't permit distinguishing +The :ctype:`Capsule` object was introduced in Python 3.1 and 2.7 to replace +:ctype:`CObject`. CObjects were useful, +but the :ctype:`CObject` API was problematic: it didn't permit distinguishing between valid CObjects, which allowed mismatched CObjects to crash the interpreter, and some of its APIs relied on undefined behavior in C. (For further reading on the rationale behind Capsules, please see :issue:`5630`.) If you're currently using CObjects, and you want to migrate to 3.1 or newer, you'll need to switch to Capsules. -:c:type:`CObject` was deprecated in 3.1 and 2.7 and completely removed in +:ctype:`CObject` was deprecated in 3.1 and 2.7 and completely removed in Python 3.2. If you only support 2.7, or 3.1 and above, you -can simply switch to :c:type:`Capsule`. If you need to support Python 3.0, -or versions of Python earlier than 2.7, -you'll have to support both CObjects and Capsules. -(Note that Python 3.0 is no longer supported, and it is not recommended -for production use.) +can simply switch to :ctype:`Capsule`. If you need to support 3.0 or +versions of Python earlier than 2.7 you'll have to support both CObjects +and Capsules. The following example header file :file:`capsulethunk.h` may -solve the problem for you. Simply write your code against the -:c:type:`Capsule` API and include this header file after -:file:`Python.h`. Your code will automatically use Capsules -in versions of Python with Capsules, and switch to CObjects -when Capsules are unavailable. +solve the problem for you; +simply write your code against the :ctype:`Capsule` API, include +this header file after ``"Python.h"``, and you'll automatically use CObjects +in Python 3.0 or versions earlier than 2.7. :file:`capsulethunk.h` simulates Capsules using CObjects. However, -:c:type:`CObject` provides no place to store the capsule's "name". As a -result the simulated :c:type:`Capsule` objects created by :file:`capsulethunk.h` +:ctype:`CObject` provides no place to store the capsule's "name". As a +result the simulated :ctype:`Capsule` objects created by :file:`capsulethunk.h` behave slightly differently from real Capsules. Specifically: - * The name parameter passed in to :c:func:`PyCapsule_New` is ignored. + * The name parameter passed in to :cfunc:`PyCapsule_New` is ignored. - * The name parameter passed in to :c:func:`PyCapsule_IsValid` and - :c:func:`PyCapsule_GetPointer` is ignored, and no error checking + * The name parameter passed in to :cfunc:`PyCapsule_IsValid` and + :cfunc:`PyCapsule_GetPointer` is ignored, and no error checking of the name is performed. - * :c:func:`PyCapsule_GetName` always returns NULL. + * :cfunc:`PyCapsule_GetName` always returns NULL. - * :c:func:`PyCapsule_SetName` always raises an exception and + * :cfunc:`PyCapsule_SetName` always throws an exception and returns failure. (Since there's no way to store a name - in a CObject, noisy failure of :c:func:`PyCapsule_SetName` + in a CObject, noisy failure of :cfunc:`PyCapsule_SetName` was deemed preferable to silent failure here. If this is - inconvenient, feel free to modify your local + inconveient, feel free to modify your local copy as you see fit.) You can find :file:`capsulethunk.h` in the Python source distribution -as :source:`Doc/includes/capsulethunk.h`. We also include it here for -your convenience: +in the :file:`Doc/includes` directory. We also include it here for +your reference; here is :file:`capsulethunk.h`: .. literalinclude:: ../includes/capsulethunk.h @@ -254,5 +266,5 @@ If you are writing a new extension module, you might consider `Cython `_. It translates a Python-like language to C. The -extension modules it creates are compatible with Python 3 and Python 2. +extension modules it creates are compatible with Python 3.x and 2.x. diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/howto/curses.rst --- a/Doc/howto/curses.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/howto/curses.rst Sun Jul 20 10:52:46 2014 -0400 @@ -118,7 +118,7 @@ A common problem when debugging a curses application is to get your terminal messed up when the application dies without restoring the terminal to its previous state. In Python this commonly happens when your code is buggy and -raises an uncaught exception. Keys are no longer echoed to the screen when +raises an uncaught exception. Keys are no longer be echoed to the screen when you type them, for example, which makes using the shell difficult. In Python you can avoid these complications and make debugging much easier by @@ -144,8 +144,8 @@ to redraw or clear them separately. The :func:`newwin` function creates a new window of a given size, returning the new window object. :: - begin_x = 20; begin_y = 7 - height = 5; width = 40 + begin_x = 20 ; begin_y = 7 + height = 5 ; width = 40 win = curses.newwin(height, width, begin_y, begin_x) A word about the coordinate system used in curses: coordinates are always passed @@ -184,13 +184,11 @@ # explained in the next section for y in range(0, 100): for x in range(0, 100): - try: - pad.addch(y,x, ord('a') + (x*x+y*y) % 26) - except curses.error: - pass + try: pad.addch(y,x, ord('a') + (x*x+y*y) % 26 ) + except curses.error: pass # Displays a section of the pad in the middle of the screen - pad.refresh(0,0, 5,5, 20,75) + pad.refresh( 0,0, 5,5, 20,75) The :func:`refresh` call displays a section of the pad in the rectangle extending from coordinate (5,5) to coordinate (20,75) on the screen; the upper @@ -273,7 +271,7 @@ highlight certain words. curses supports this by allowing you to specify an attribute for each cell on the screen. -An attribute is an integer, each bit representing a different attribute. You can +An attribute is a integer, each bit representing a different attribute. You can try to display text with multiple attribute bits set, but curses doesn't guarantee that all the possible combinations are available, or that they're all visually distinct. That depends on the ability of the terminal being used, so @@ -302,7 +300,7 @@ curses.A_REVERSE) stdscr.refresh() -The curses library also supports color on those terminals that provide it. The +The curses library also supports color on those terminals that provide it, The most common such terminal is probably the Linux console, followed by color xterms. @@ -323,7 +321,7 @@ An example, which displays a line of text using color pair 1:: - stdscr.addstr("Pretty text", curses.color_pair(1)) + stdscr.addstr( "Pretty text", curses.color_pair(1) ) stdscr.refresh() As I said before, a color pair consists of a foreground and background color. @@ -345,7 +343,7 @@ will change to the new colors. You can also display new text in this color with:: - stdscr.addstr(0,0, "RED ALERT!", curses.color_pair(1)) + stdscr.addstr(0,0, "RED ALERT!", curses.color_pair(1) ) Very fancy terminals can change the definitions of the actual colors to a given RGB value. This lets you change color 1, which is usually red, to purple or @@ -383,12 +381,9 @@ while 1: c = stdscr.getch() - if c == ord('p'): - PrintDocument() - elif c == ord('q'): - break # Exit the while() - elif c == curses.KEY_HOME: - x = y = 0 + if c == ord('p'): PrintDocument() + elif c == ord('q'): break # Exit the while() + elif c == curses.KEY_HOME: x = y = 0 The :mod:`curses.ascii` module supplies ASCII class membership functions that take either integer or 1-character-string arguments; these may be useful in @@ -438,3 +433,4 @@ another demo. We can always use more of them! The ncurses FAQ: http://invisible-island.net/ncurses/ncurses.faq.html + diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/howto/descriptor.rst --- a/Doc/howto/descriptor.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/howto/descriptor.rst Sun Jul 20 10:52:46 2014 -0400 @@ -97,7 +97,7 @@ implementation works through a precedence chain that gives data descriptors priority over instance variables, instance variables priority over non-data descriptors, and assigns lowest priority to :meth:`__getattr__` if provided. The -full C implementation can be found in :c:func:`PyObject_GenericGetAttr()` in +full C implementation can be found in :cfunc:`PyObject_GenericGetAttr()` in `Objects/object.c `_\. For classes, the machinery is in :meth:`type.__getattribute__` which transforms @@ -124,14 +124,14 @@ The object returned by ``super()`` also has a custom :meth:`__getattribute__` method for invoking descriptors. The call ``super(B, obj).m()`` searches ``obj.__class__.__mro__`` for the base class ``A`` immediately following ``B`` -and then returns ``A.__dict__['m'].__get__(obj, B)``. If not a descriptor, +and then returns ``A.__dict__['m'].__get__(obj, A)``. If not a descriptor, ``m`` is returned unchanged. If not in the dictionary, ``m`` reverts to a search using :meth:`object.__getattribute__`. Note, in Python 2.2, ``super(B, obj).m()`` would only invoke :meth:`__get__` if ``m`` was a data descriptor. In Python 2.3, non-data descriptors also get invoked unless an old-style class is involved. The implementation details are -in :c:func:`super_getattro()` in +in :cfunc:`super_getattro()` in `Objects/typeobject.c `_ and a pure Python equivalent can be found in `Guido's Tutorial`_. @@ -167,7 +167,7 @@ return self.val def __set__(self, obj, val): - print 'Updating', self.name + print 'Updating' , self.name self.val = val >>> class MyClass(object): @@ -218,36 +218,25 @@ self.fget = fget self.fset = fset self.fdel = fdel - if doc is None and fget is not None: - doc = fget.__doc__ self.__doc__ = doc def __get__(self, obj, objtype=None): if obj is None: return self if self.fget is None: - raise AttributeError("unreadable attribute") + raise AttributeError, "unreadable attribute" return self.fget(obj) def __set__(self, obj, value): if self.fset is None: - raise AttributeError("can't set attribute") + raise AttributeError, "can't set attribute" self.fset(obj, value) def __delete__(self, obj): if self.fdel is None: - raise AttributeError("can't delete attribute") + raise AttributeError, "can't delete attribute" self.fdel(obj) - def getter(self, fget): - return type(self)(fget, self.fset, self.fdel, self.__doc__) - - def setter(self, fset): - return type(self)(self.fget, fset, self.fdel, self.__doc__) - - def deleter(self, fdel): - return type(self)(self.fget, self.fset, fdel, self.__doc__) - The :func:`property` builtin helps whenever a user interface has granted attribute access and then subsequent changes require the intervention of a method. @@ -308,7 +297,7 @@ The output suggests that bound and unbound methods are two different types. While they could have been implemented that way, the actual C implementation of -:c:type:`PyMethod_Type` in +:ctype:`PyMethod_Type` in `Objects/classobject.c `_ is a single object with two different representations depending on whether the :attr:`im_self` field is set or is *NULL* (the C equivalent of *None*). @@ -409,7 +398,7 @@ :func:`dict.fromkeys` creates a new dictionary from a list of keys. The pure Python equivalent is:: - class Dict(object): + class Dict: . . . def fromkeys(klass, iterable, value=None): "Emulate dict_fromkeys() in Objects/dictobject.c" diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/howto/functional.rst --- a/Doc/howto/functional.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/howto/functional.rst Sun Jul 20 10:52:46 2014 -0400 @@ -44,14 +44,15 @@ functional languages include the ML family (Standard ML, OCaml, and other variants) and Haskell. -The designers of some computer languages choose to emphasize one particular -approach to programming. This often makes it difficult to write programs that -use a different approach. Other languages are multi-paradigm languages that -support several different approaches. Lisp, C++, and Python are -multi-paradigm; you can write programs or libraries that are largely -procedural, object-oriented, or functional in all of these languages. In a -large program, different sections might be written using different approaches; -the GUI might be object-oriented while the processing logic is procedural or +The designers of some computer languages choose to emphasize one +particular approach to programming. This often makes it difficult to +write programs that use a different approach. Other languages are +multi-paradigm languages that support several different approaches. +Lisp, C++, and Python are multi-paradigm; you can write programs or +libraries that are largely procedural, object-oriented, or functional +in all of these languages. In a large program, different sections +might be written using different approaches; the GUI might be +object-oriented while the processing logic is procedural or functional, for example. In a functional program, input flows through a set of functions. Each function @@ -244,9 +245,9 @@ iterator argument and will return the largest or smallest element. The ``"in"`` and ``"not in"`` operators also support iterators: ``X in iterator`` is true if X is found in the stream returned by the iterator. You'll run into obvious -problems if the iterator is infinite; ``max()``, ``min()`` +problems if the iterator is infinite; ``max()``, ``min()``, and ``"not in"`` will never return, and if the element X never appears in the stream, the -``"in"`` and ``"not in"`` operators won't return either. +``"in"`` operator won't return either. Note that you can only go forward in an iterator; there's no way to get the previous element, reset the iterator, or make a copy of it. Iterator objects @@ -587,8 +588,7 @@ Because ``yield`` will often be returning ``None``, you should always check for this case. Don't just use its value in expressions unless you're sure that the -``send()`` method will be the only method used to resume your generator -function. +``send()`` method will be the only method used resume your generator function. In addition to ``send()``, there are two other new methods on generators: @@ -744,8 +744,8 @@ Python wiki at http://wiki.python.org/moin/HowTo/Sorting.) The ``any(iter)`` and ``all(iter)`` built-ins look at the truth values of an -iterable's contents. :func:`any` returns ``True`` if any element in the iterable is -a true value, and :func:`all` returns ``True`` if all of the elements are true +iterable's contents. :func:`any` returns True if any element in the iterable is +a true value, and :func:`all` returns True if all of the elements are true values: >>> any([0,1,0]) @@ -1115,6 +1115,132 @@ Consult the operator module's documentation for a complete list. + +The functional module +--------------------- + +Collin Winter's `functional module `__ +provides a number of more advanced tools for functional programming. It also +reimplements several Python built-ins, trying to make them more intuitive to +those used to functional programming in other languages. + +This section contains an introduction to some of the most important functions in +``functional``; full documentation can be found at `the project's website +`__. + +``compose(outer, inner, unpack=False)`` + +The ``compose()`` function implements function composition. In other words, it +returns a wrapper around the ``outer`` and ``inner`` callables, such that the +return value from ``inner`` is fed directly to ``outer``. That is, :: + + >>> def add(a, b): + ... return a + b + ... + >>> def double(a): + ... return 2 * a + ... + >>> compose(double, add)(5, 6) + 22 + +is equivalent to :: + + >>> double(add(5, 6)) + 22 + +The ``unpack`` keyword is provided to work around the fact that Python functions +are not always `fully curried `__. By +default, it is expected that the ``inner`` function will return a single object +and that the ``outer`` function will take a single argument. Setting the +``unpack`` argument causes ``compose`` to expect a tuple from ``inner`` which +will be expanded before being passed to ``outer``. Put simply, :: + + compose(f, g)(5, 6) + +is equivalent to:: + + f(g(5, 6)) + +while :: + + compose(f, g, unpack=True)(5, 6) + +is equivalent to:: + + f(*g(5, 6)) + +Even though ``compose()`` only accepts two functions, it's trivial to build up a +version that will compose any number of functions. We'll use ``reduce()``, +``compose()`` and ``partial()`` (the last of which is provided by both +``functional`` and ``functools``). :: + + from functional import compose, partial + + multi_compose = partial(reduce, compose) + + +We can also use ``map()``, ``compose()`` and ``partial()`` to craft a version of +``"".join(...)`` that converts its arguments to string:: + + from functional import compose, partial + + join = compose("".join, partial(map, str)) + + +``flip(func)`` + +``flip()`` wraps the callable in ``func`` and causes it to receive its +non-keyword arguments in reverse order. :: + + >>> def triple(a, b, c): + ... return (a, b, c) + ... + >>> triple(5, 6, 7) + (5, 6, 7) + >>> + >>> flipped_triple = flip(triple) + >>> flipped_triple(5, 6, 7) + (7, 6, 5) + +``foldl(func, start, iterable)`` + +``foldl()`` takes a binary function, a starting value (usually some kind of +'zero'), and an iterable. The function is applied to the starting value and the +first element of the list, then the result of that and the second element of the +list, then the result of that and the third element of the list, and so on. + +This means that a call such as:: + + foldl(f, 0, [1, 2, 3]) + +is equivalent to:: + + f(f(f(0, 1), 2), 3) + + +``foldl()`` is roughly equivalent to the following recursive function:: + + def foldl(func, start, seq): + if len(seq) == 0: + return start + + return foldl(func, func(start, seq[0]), seq[1:]) + +Speaking of equivalence, the above ``foldl`` call can be expressed in terms of +the built-in ``reduce`` like so:: + + reduce(f, [1, 2, 3], 0) + + +We can use ``foldl()``, ``operator.concat()`` and ``partial()`` to write a +cleaner, more aesthetically-pleasing version of Python's ``"".join(...)`` +idiom:: + + from functional import foldl, partial from operator import concat + + join = partial(foldl, concat, "") + + Revision History and Acknowledgements ===================================== @@ -1170,10 +1296,9 @@ Mertz also wrote a 3-part series of articles on functional programming for IBM's DeveloperWorks site; see - -`part 1 `__, -`part 2 `__, and -`part 3 `__, +`part 1 `__, +`part 2 `__, and +`part 3 `__, Python documentation diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/howto/index.rst --- a/Doc/howto/index.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/howto/index.rst Sun Jul 20 10:52:46 2014 -0400 @@ -13,6 +13,7 @@ .. toctree:: :maxdepth: 1 + advocacy.rst pyporting.rst cporting.rst curses.rst @@ -27,5 +28,4 @@ unicode.rst urllib2.rst webservers.rst - argparse.rst diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/howto/logging-cookbook.rst --- a/Doc/howto/logging-cookbook.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/howto/logging-cookbook.rst Sun Jul 20 10:52:46 2014 -0400 @@ -97,11 +97,11 @@ Multiple handlers and formatters -------------------------------- -Loggers are plain Python objects. The :meth:`~Logger.addHandler` method has no -minimum or maximum quota for the number of handlers you may add. Sometimes it -will be beneficial for an application to log all messages of all severities to a -text file while simultaneously logging errors or above to the console. To set -this up, simply configure the appropriate handlers. The logging calls in the +Loggers are plain Python objects. The :func:`addHandler` method has no minimum +or maximum quota for the number of handlers you may add. Sometimes it will be +beneficial for an application to log all messages of all severities to a text +file while simultaneously logging errors or above to the console. To set this +up, simply configure the appropriate handlers. The logging calls in the application code will remain unchanged. Here is a slight modification to the previous simple module-based configuration example:: @@ -295,17 +295,17 @@ logger2.warning('Jail zesty vixen who grabbed pay from quack.') logger2.error('The five boxing wizards jump quickly.') -At the receiving end, you can set up a receiver using the :mod:`SocketServer` +At the receiving end, you can set up a receiver using the :mod:`socketserver` module. Here is a basic working example:: import pickle import logging import logging.handlers - import SocketServer + import socketserver import struct - class LogRecordStreamHandler(SocketServer.StreamRequestHandler): + class LogRecordStreamHandler(socketserver.StreamRequestHandler): """Handler for a streaming logging request. This basically logs the record using whatever logging policy is @@ -347,7 +347,7 @@ # cycles and network bandwidth! logger.handle(record) - class LogRecordSocketReceiver(SocketServer.ThreadingTCPServer): + class LogRecordSocketReceiver(socketserver.ThreadingTCPServer): """ Simple TCP socket-based logging receiver suitable for testing. """ @@ -357,7 +357,7 @@ def __init__(self, host='localhost', port=logging.handlers.DEFAULT_TCP_LOGGING_PORT, handler=LogRecordStreamHandler): - SocketServer.ThreadingTCPServer.__init__(self, (host, port), handler) + socketserver.ThreadingTCPServer.__init__(self, (host, port), handler) self.abort = 0 self.timeout = 1 self.logname = None @@ -395,9 +395,8 @@ Note that there are some security issues with pickle in some scenarios. If these affect you, you can use an alternative serialization scheme by overriding -the :meth:`~handlers.SocketHandler.makePickle` method and implementing your -alternative there, as well as adapting the above script to use your alternative -serialization. +the :meth:`makePickle` method and implementing your alternative there, as +well as adapting the above script to use your alternative serialization. .. _context-info: @@ -405,8 +404,6 @@ Adding contextual information to your logging output ---------------------------------------------------- -.. currentmodule:: logging - Sometimes you want logging output to contain contextual information in addition to the parameters passed to the logging call. For example, in a networked application, it may be desirable to log client-specific information @@ -448,9 +445,9 @@ msg, kwargs = self.process(msg, kwargs) self.logger.debug(msg, *args, **kwargs) -The :meth:`~LoggerAdapter.process` method of :class:`LoggerAdapter` is where the -contextual information is added to the logging output. It's passed the message -and keyword arguments of the logging call, and it passes back (potentially) +The :meth:`process` method of :class:`LoggerAdapter` is where the contextual +information is added to the logging output. It's passed the message and +keyword arguments of the logging call, and it passes back (potentially) modified versions of these to use in the call to the underlying logger. The default implementation of this method leaves the message alone, but inserts an 'extra' key in the keyword argument whose value is the dict-like object @@ -462,32 +459,70 @@ customized strings with your :class:`Formatter` instances which know about the keys of the dict-like object. If you need a different method, e.g. if you want to prepend or append the contextual information to the message string, -you just need to subclass :class:`LoggerAdapter` and override -:meth:`~LoggerAdapter.process` to do what you need. Here is a simple example:: +you just need to subclass :class:`LoggerAdapter` and override :meth:`process` +to do what you need. Here's an example script which uses this class, which +also illustrates what dict-like behaviour is needed from an arbitrary +'dict-like' object for use in the constructor:: - class CustomAdapter(logging.LoggerAdapter): - """ - This example adapter expects the passed in dict-like object to have a - 'connid' key, whose value in brackets is prepended to the log message. - """ - def process(self, msg, kwargs): - return '[%s] %s' % (self.extra['connid'], msg), kwargs + import logging -which you can use like this:: + class ConnInfo: + """ + An example class which shows how an arbitrary class can be used as + the 'extra' context information repository passed to a LoggerAdapter. + """ - logger = logging.getLogger(__name__) - adapter = CustomAdapter(logger, {'connid': some_conn_id}) + def __getitem__(self, name): + """ + To allow this instance to look like a dict. + """ + from random import choice + if name == 'ip': + result = choice(['127.0.0.1', '192.168.0.1']) + elif name == 'user': + result = choice(['jim', 'fred', 'sheila']) + else: + result = self.__dict__.get(name, '?') + return result -Then any events that you log to the adapter will have the value of -``some_conn_id`` prepended to the log messages. + def __iter__(self): + """ + To allow iteration over keys, which will be merged into + the LogRecord dict before formatting and output. + """ + keys = ['ip', 'user'] + keys.extend(self.__dict__.keys()) + return keys.__iter__() -Using objects other than dicts to pass contextual information -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + if __name__ == '__main__': + from random import choice + levels = (logging.DEBUG, logging.INFO, logging.WARNING, logging.ERROR, logging.CRITICAL) + a1 = logging.LoggerAdapter(logging.getLogger('a.b.c'), + { 'ip' : '123.231.231.123', 'user' : 'sheila' }) + logging.basicConfig(level=logging.DEBUG, + format='%(asctime)-15s %(name)-5s %(levelname)-8s IP: %(ip)-15s User: %(user)-8s %(message)s') + a1.debug('A debug message') + a1.info('An info message with %s', 'some parameters') + a2 = logging.LoggerAdapter(logging.getLogger('d.e.f'), ConnInfo()) + for x in range(10): + lvl = choice(levels) + lvlname = logging.getLevelName(lvl) + a2.log(lvl, 'A message at %s level with %d %s', lvlname, 2, 'parameters') -You don't need to pass an actual dict to a :class:`LoggerAdapter` - you could -pass an instance of a class which implements ``__getitem__`` and ``__iter__`` so -that it looks like a dict to logging. This would be useful if you want to -generate values dynamically (whereas the values in a dict would be constant). +When this script is run, the output should look something like this:: + + 2008-01-18 14:49:54,023 a.b.c DEBUG IP: 123.231.231.123 User: sheila A debug message + 2008-01-18 14:49:54,023 a.b.c INFO IP: 123.231.231.123 User: sheila An info message with some parameters + 2008-01-18 14:49:54,023 d.e.f CRITICAL IP: 192.168.0.1 User: jim A message at CRITICAL level with 2 parameters + 2008-01-18 14:49:54,033 d.e.f INFO IP: 192.168.0.1 User: jim A message at INFO level with 2 parameters + 2008-01-18 14:49:54,033 d.e.f WARNING IP: 192.168.0.1 User: sheila A message at WARNING level with 2 parameters + 2008-01-18 14:49:54,033 d.e.f ERROR IP: 127.0.0.1 User: fred A message at ERROR level with 2 parameters + 2008-01-18 14:49:54,033 d.e.f ERROR IP: 127.0.0.1 User: sheila A message at ERROR level with 2 parameters + 2008-01-18 14:49:54,033 d.e.f WARNING IP: 192.168.0.1 User: sheila A message at WARNING level with 2 parameters + 2008-01-18 14:49:54,033 d.e.f WARNING IP: 192.168.0.1 User: jim A message at WARNING level with 2 parameters + 2008-01-18 14:49:54,033 d.e.f INFO IP: 192.168.0.1 User: fred A message at INFO level with 2 parameters + 2008-01-18 14:49:54,033 d.e.f WARNING IP: 192.168.0.1 User: sheila A message at WARNING level with 2 parameters + 2008-01-18 14:49:54,033 d.e.f WARNING IP: 127.0.0.1 User: jim A message at WARNING level with 2 parameters .. _filters-contextual: @@ -572,23 +607,25 @@ *multiple processes* is *not* supported, because there is no standard way to serialize access to a single file across multiple processes in Python. If you need to log to a single file from multiple processes, one way of doing this is -to have all the processes log to a :class:`~handlers.SocketHandler`, and have a -separate process which implements a socket server which reads from the socket -and logs to file. (If you prefer, you can dedicate one thread in one of the -existing processes to perform this function.) -:ref:`This section ` documents this approach in more detail and -includes a working socket receiver which can be used as a starting point for you -to adapt in your own applications. +to have all the processes log to a :class:`SocketHandler`, and have a separate +process which implements a socket server which reads from the socket and logs +to file. (If you prefer, you can dedicate one thread in one of the existing +processes to perform this function.) :ref:`This section ` +documents this approach in more detail and includes a working socket receiver +which can be used as a starting point for you to adapt in your own +applications. If you are using a recent version of Python which includes the :mod:`multiprocessing` module, you could write your own handler which uses the -:class:`~multiprocessing.Lock` class from this module to serialize access to the -file from your processes. The existing :class:`FileHandler` and subclasses do -not make use of :mod:`multiprocessing` at present, though they may do so in the -future. Note that at present, the :mod:`multiprocessing` module does not provide +:class:`Lock` class from this module to serialize access to the file from +your processes. The existing :class:`FileHandler` and subclasses do not make +use of :mod:`multiprocessing` at present, though they may do so in the future. +Note that at present, the :mod:`multiprocessing` module does not provide working lock functionality on all platforms (see http://bugs.python.org/issue3770). +.. currentmodule:: logging.handlers + Using file rotation ------------------- @@ -600,7 +637,7 @@ file and log to that. You may want to keep a certain number of these files, and when that many files have been created, rotate the files so that the number of files and the size of the files both remain bounded. For this usage pattern, the -logging package provides a :class:`~handlers.RotatingFileHandler`:: +logging package provides a :class:`RotatingFileHandler`:: import glob import logging @@ -651,7 +688,7 @@ Below is an example of a logging configuration dictionary - it's taken from the `documentation on the Django project `_. -This dictionary is passed to :func:`~config.dictConfig` to put the configuration into effect:: +This dictionary is passed to :func:`~logging.config.dictConfig` to put the configuration into effect:: LOGGING = { 'version': 1, @@ -706,351 +743,5 @@ } For more information about this configuration, you can see the `relevant -section `_ +section `_ of the Django documentation. - -Inserting a BOM into messages sent to a SysLogHandler ------------------------------------------------------ - -`RFC 5424 `_ requires that a -Unicode message be sent to a syslog daemon as a set of bytes which have the -following structure: an optional pure-ASCII component, followed by a UTF-8 Byte -Order Mark (BOM), followed by Unicode encoded using UTF-8. (See the `relevant -section of the specification `_.) - -In Python 2.6 and 2.7, code was added to -:class:`~logging.handlers.SysLogHandler` to insert a BOM into the message, but -unfortunately, it was implemented incorrectly, with the BOM appearing at the -beginning of the message and hence not allowing any pure-ASCII component to -appear before it. - -As this behaviour is broken, the incorrect BOM insertion code is being removed -from Python 2.7.4 and later. However, it is not being replaced, and if you -want to produce RFC 5424-compliant messages which include a BOM, an optional -pure-ASCII sequence before it and arbitrary Unicode after it, encoded using -UTF-8, then you need to do the following: - -#. Attach a :class:`~logging.Formatter` instance to your - :class:`~logging.handlers.SysLogHandler` instance, with a format string - such as:: - - u'ASCII section\ufeffUnicode section' - - The Unicode code point ``u'\ufeff'``, when encoded using UTF-8, will be - encoded as a UTF-8 BOM -- the byte-string ``'\xef\xbb\xbf'``. - -#. Replace the ASCII section with whatever placeholders you like, but make sure - that the data that appears in there after substitution is always ASCII (that - way, it will remain unchanged after UTF-8 encoding). - -#. Replace the Unicode section with whatever placeholders you like; if the data - which appears there after substitution contains characters outside the ASCII - range, that's fine -- it will be encoded using UTF-8. - -If the formatted message is Unicode, it *will* be encoded using UTF-8 encoding -by ``SysLogHandler``. If you follow the above rules, you should be able to -produce RFC 5424-compliant messages. If you don't, logging may not complain, -but your messages will not be RFC 5424-compliant, and your syslog daemon may -complain. - - -Implementing structured logging -------------------------------- - -Although most logging messages are intended for reading by humans, and thus not -readily machine-parseable, there might be cirumstances where you want to output -messages in a structured format which *is* capable of being parsed by a program -(without needing complex regular expressions to parse the log message). This is -straightforward to achieve using the logging package. There are a number of -ways in which this could be achieved, but the following is a simple approach -which uses JSON to serialise the event in a machine-parseable manner:: - - import json - import logging - - class StructuredMessage(object): - def __init__(self, message, **kwargs): - self.message = message - self.kwargs = kwargs - - def __str__(self): - return '%s >>> %s' % (self.message, json.dumps(self.kwargs)) - - _ = StructuredMessage # optional, to improve readability - - logging.basicConfig(level=logging.INFO, format='%(message)s') - logging.info(_('message 1', foo='bar', bar='baz', num=123, fnum=123.456)) - -If the above script is run, it prints:: - - message 1 >>> {"fnum": 123.456, "num": 123, "bar": "baz", "foo": "bar"} - -Note that the order of items might be different according to the version of -Python used. - -If you need more specialised processing, you can use a custom JSON encoder, -as in the following complete example:: - - from __future__ import unicode_literals - - import json - import logging - - # This next bit is to ensure the script runs unchanged on 2.x and 3.x - try: - unicode - except NameError: - unicode = str - - class Encoder(json.JSONEncoder): - def default(self, o): - if isinstance(o, set): - return tuple(o) - elif isinstance(o, unicode): - return o.encode('unicode_escape').decode('ascii') - return super(Encoder, self).default(o) - - class StructuredMessage(object): - def __init__(self, message, **kwargs): - self.message = message - self.kwargs = kwargs - - def __str__(self): - s = Encoder().encode(self.kwargs) - return '%s >>> %s' % (self.message, s) - - _ = StructuredMessage # optional, to improve readability - - def main(): - logging.basicConfig(level=logging.INFO, format='%(message)s') - logging.info(_('message 1', set_value=set([1, 2, 3]), snowman='\u2603')) - - if __name__ == '__main__': - main() - -When the above script is run, it prints:: - - message 1 >>> {"snowman": "\u2603", "set_value": [1, 2, 3]} - -Note that the order of items might be different according to the version of -Python used. - - -.. _custom-handlers: - -.. currentmodule:: logging.config - -Customizing handlers with :func:`dictConfig` --------------------------------------------- - -There are times when you want to customize logging handlers in particular ways, -and if you use :func:`dictConfig` you may be able to do this without -subclassing. As an example, consider that you may want to set the ownership of a -log file. On POSIX, this is easily done using :func:`shutil.chown`, but the file -handlers in the stdlib don't offer built-in support. You can customize handler -creation using a plain function such as:: - - def owned_file_handler(filename, mode='a', encoding=None, owner=None): - if owner: - if not os.path.exists(filename): - open(filename, 'a').close() - shutil.chown(filename, *owner) - return logging.FileHandler(filename, mode, encoding) - -You can then specify, in a logging configuration passed to :func:`dictConfig`, -that a logging handler be created by calling this function:: - - LOGGING = { - 'version': 1, - 'disable_existing_loggers': False, - 'formatters': { - 'default': { - 'format': '%(asctime)s %(levelname)s %(name)s %(message)s' - }, - }, - 'handlers': { - 'file':{ - # The values below are popped from this dictionary and - # used to create the handler, set the handler's level and - # its formatter. - '()': owned_file_handler, - 'level':'DEBUG', - 'formatter': 'default', - # The values below are passed to the handler creator callable - # as keyword arguments. - 'owner': ['pulse', 'pulse'], - 'filename': 'chowntest.log', - 'mode': 'w', - 'encoding': 'utf-8', - }, - }, - 'root': { - 'handlers': ['file'], - 'level': 'DEBUG', - }, - } - -In this example I am setting the ownership using the ``pulse`` user and group, -just for the purposes of illustration. Putting it together into a working -script, ``chowntest.py``:: - - import logging, logging.config, os, shutil - - def owned_file_handler(filename, mode='a', encoding=None, owner=None): - if owner: - if not os.path.exists(filename): - open(filename, 'a').close() - shutil.chown(filename, *owner) - return logging.FileHandler(filename, mode, encoding) - - LOGGING = { - 'version': 1, - 'disable_existing_loggers': False, - 'formatters': { - 'default': { - 'format': '%(asctime)s %(levelname)s %(name)s %(message)s' - }, - }, - 'handlers': { - 'file':{ - # The values below are popped from this dictionary and - # used to create the handler, set the handler's level and - # its formatter. - '()': owned_file_handler, - 'level':'DEBUG', - 'formatter': 'default', - # The values below are passed to the handler creator callable - # as keyword arguments. - 'owner': ['pulse', 'pulse'], - 'filename': 'chowntest.log', - 'mode': 'w', - 'encoding': 'utf-8', - }, - }, - 'root': { - 'handlers': ['file'], - 'level': 'DEBUG', - }, - } - - logging.config.dictConfig(LOGGING) - logger = logging.getLogger('mylogger') - logger.debug('A debug message') - -To run this, you will probably need to run as ``root``:: - - $ sudo python3.3 chowntest.py - $ cat chowntest.log - 2013-11-05 09:34:51,128 DEBUG mylogger A debug message - $ ls -l chowntest.log - -rw-r--r-- 1 pulse pulse 55 2013-11-05 09:34 chowntest.log - -Note that this example uses Python 3.3 because that's where :func:`shutil.chown` -makes an appearance. This approach should work with any Python version that -supports :func:`dictConfig` - namely, Python 2.7, 3.2 or later. With pre-3.3 -versions, you would need to implement the actual ownership change using e.g. -:func:`os.chown`. - -In practice, the handler-creating function may be in a utility module somewhere -in your project. Instead of the line in the configuration:: - - '()': owned_file_handler, - -you could use e.g.:: - - '()': 'ext://project.util.owned_file_handler', - -where ``project.util`` can be replaced with the actual name of the package -where the function resides. In the above working script, using -``'ext://__main__.owned_file_handler'`` should work. Here, the actual callable -is resolved by :func:`dictConfig` from the ``ext://`` specification. - -This example hopefully also points the way to how you could implement other -types of file change - e.g. setting specific POSIX permission bits - in the -same way, using :func:`os.chmod`. - -Of course, the approach could also be extended to types of handler other than a -:class:`~logging.FileHandler` - for example, one of the rotating file handlers, -or a different type of handler altogether. - - -.. _filters-dictconfig: - -Configuring filters with :func:`dictConfig` -------------------------------------------- - -You *can* configure filters using :func:`~logging.config.dictConfig`, though it -might not be obvious at first glance how to do it (hence this recipe). Since -:class:`~logging.Filter` is the only filter class included in the standard -library, and it is unlikely to cater to many requirements (it's only there as a -base class), you will typically need to define your own :class:`~logging.Filter` -subclass with an overridden :meth:`~logging.Filter.filter` method. To do this, -specify the ``()`` key in the configuration dictionary for the filter, -specifying a callable which will be used to create the filter (a class is the -most obvious, but you can provide any callable which returns a -:class:`~logging.Filter` instance). Here is a complete example:: - - import logging - import logging.config - import sys - - class MyFilter(logging.Filter): - def __init__(self, param=None): - self.param = param - - def filter(self, record): - if self.param is None: - allow = True - else: - allow = self.param not in record.msg - if allow: - record.msg = 'changed: ' + record.msg - return allow - - LOGGING = { - 'version': 1, - 'filters': { - 'myfilter': { - '()': MyFilter, - 'param': 'noshow', - } - }, - 'handlers': { - 'console': { - 'class': 'logging.StreamHandler', - 'filters': ['myfilter'] - } - }, - 'root': { - 'level': 'DEBUG', - 'handlers': ['console'] - }, - } - - if __name__ == '__main__': - logging.config.dictConfig(LOGGING) - logging.debug('hello') - logging.debug('hello - noshow') - -This example shows how you can pass configuration data to the callable which -constructs the instance, in the form of keyword parameters. When run, the above -script will print:: - - changed: hello - -which shows that the filter is working as configured. - -A couple of extra points to note: - -* If you can't refer to the callable directly in the configuration (e.g. if it - lives in a different module, and you can't import it directly where the - configuration dictionary is), you can use the form ``ext://...`` as described - in :ref:`logging-config-dict-externalobj`. For example, you could have used - the text ``'ext://__main__.MyFilter'`` instead of ``MyFilter`` in the above - example. - -* As well as for filters, this technique can also be used to configure custom - handlers and formatters. See :ref:`logging-config-dict-userdef` for more - information on how logging supports using user-defined objects in its - configuration, and see the other cookbook recipe :ref:`custom-handlers` above. - diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/howto/logging.rst --- a/Doc/howto/logging.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/howto/logging.rst Sun Jul 20 10:52:46 2014 -0400 @@ -63,8 +63,6 @@ they are used to track. The standard levels and their applicability are described below (in increasing order of severity): -.. tabularcolumns:: |l|L| - +--------------+---------------------------------------------+ | Level | When it's used | +==============+=============================================+ @@ -122,8 +120,7 @@ ^^^^^^^^^^^^^^^^^ A very common situation is that of recording logging events in a file, so let's -look at that next. Be sure to try the following in a newly-started Python -interpreter, and don't just continue from the session described above:: +look at that next:: import logging logging.basicConfig(filename='example.log',level=logging.DEBUG) @@ -333,9 +330,6 @@ to output. * Formatters specify the layout of log records in the final output. -Log event information is passed between loggers, handlers, filters and -formatters in a :class:`LogRecord` instance. - Logging is performed by calling methods on instances of the :class:`Logger` class (hereafter called :dfn:`loggers`). Each instance has a name, and they are conceptually arranged in a namespace hierarchy using dots (periods) as @@ -380,13 +374,6 @@ *format* keyword argument. For all options regarding how a format string is constructed, see :ref:`formatter-objects`. -Logging Flow -^^^^^^^^^^^^ - -The flow of log event information in loggers and handlers is illustrated in the -following diagram. - -.. image:: logging_flow.png Loggers ^^^^^^^ @@ -470,13 +457,12 @@ :class:`~logging.Handler` objects are responsible for dispatching the appropriate log messages (based on the log messages' severity) to the handler's -specified destination. :class:`Logger` objects can add zero or more handler -objects to themselves with an :meth:`~Logger.addHandler` method. As an example -scenario, an application may want to send all log messages to a log file, all -log messages of error or higher to stdout, and all messages of critical to an -email address. This scenario requires three individual handlers where each -handler is responsible for sending messages of a specific severity to a specific -location. +specified destination. Logger objects can add zero or more handler objects to +themselves with an :func:`addHandler` method. As an example scenario, an +application may want to send all log messages to a log file, all log messages +of error or higher to stdout, and all messages of critical to an email address. +This scenario requires three individual handlers where each handler is +responsible for sending messages of a specific severity to a specific location. The standard library includes quite a few handler types (see :ref:`useful-handlers`); the tutorials use mainly :class:`StreamHandler` and @@ -487,17 +473,16 @@ developers who are using the built-in handler objects (that is, not creating custom handlers) are the following configuration methods: -* The :meth:`~Handler.setLevel` method, just as in logger objects, specifies the +* The :meth:`Handler.setLevel` method, just as in logger objects, specifies the lowest severity that will be dispatched to the appropriate destination. Why are there two :func:`setLevel` methods? The level set in the logger determines which severity of messages it will pass to its handlers. The level set in each handler determines which messages that handler will send on. -* :meth:`~Handler.setFormatter` selects a Formatter object for this handler to - use. +* :func:`setFormatter` selects a Formatter object for this handler to use. -* :meth:`~Handler.addFilter` and :meth:`~Handler.removeFilter` respectively - configure and deconfigure filter objects on handlers. +* :func:`addFilter` and :func:`removeFilter` respectively configure and + deconfigure filter objects on handlers. Application code should not directly instantiate and use instances of :class:`Handler`. Instead, the :class:`Handler` class is a base class that @@ -657,21 +642,6 @@ code approach, mainly separation of configuration and code and the ability of noncoders to easily modify the logging properties. -.. warning:: The :func:`fileConfig` function takes a default parameter, - ``disable_existing_loggers``, which defaults to ``True`` for reasons of - backward compatibility. This may or may not be what you want, since it - will cause any loggers existing before the :func:`fileConfig` call to - be disabled unless they (or an ancestor) are explicitly named in the - configuration. Please refer to the reference documentation for more - information, and specify ``False`` for this parameter if you wish. - - The dictionary passed to :func:`dictConfig` can also specify a Boolean - value with key ``disable_existing_loggers``, which if not specified - explicitly in the dictionary also defaults to being interpreted as - ``True``. This leads to the logger-disabling behaviour described above, - which may not be what you want - in which case, provide the key - explicitly with a value of ``False``. - .. currentmodule:: logging Note that the class names referenced in config files need to be either relative @@ -743,11 +713,12 @@ When developing a library which uses logging, you should take care to document how the library uses logging - for example, the names of loggers used. Some consideration also needs to be given to its logging configuration. -If the using application does not configure logging, and library code makes -logging calls, then (as described in the previous section) an error message -will be printed to ``sys.stderr``. +If the using application does not use logging, and library code makes logging +calls, then (as described in the previous section) events of severity +``WARNING`` and greater will be printed to ``sys.stderr``. This is regarded as +the best default behaviour. -If for some reason you *don't* want this message printed in the absence of +If for some reason you *don't* want these messages printed in the absence of any logging configuration, you can attach a do-nothing handler to the top-level logger for your library. This avoids the message being printed, since a handler will be always be found for the library's events: it just doesn't produce any @@ -759,7 +730,7 @@ A do-nothing handler is included in the logging package: :class:`~logging.NullHandler` (since Python 2.7). An instance of this handler could be added to the top-level logger of the logging namespace used by the -library (*if* you want to prevent an error message being output to +library (*if* you want to prevent your library's logged events being output to ``sys.stderr`` in the absence of logging configuration). If all logging by a library *foo* is done using loggers with names matching 'foo.x', 'foo.x.y', etc. then the code:: @@ -771,14 +742,13 @@ libraries, then the logger name specified can be 'orgname.foo' rather than just 'foo'. -.. note:: It is strongly advised that you *do not add any handlers other - than* :class:`~logging.NullHandler` *to your library's loggers*. This is - because the configuration of handlers is the prerogative of the application - developer who uses your library. The application developer knows their - target audience and what handlers are most appropriate for their - application: if you add handlers 'under the hood', you might well interfere - with their ability to carry out unit tests and deliver logs which suit their - requirements. +**PLEASE NOTE:** It is strongly advised that you *do not add any handlers other +than* :class:`~logging.NullHandler` *to your library's loggers*. This is +because the configuration of handlers is the prerogative of the application +developer who uses your library. The application developer knows their target +audience and what handlers are most appropriate for their application: if you +add handlers 'under the hood', you might well interfere with their ability to +carry out unit tests and deliver logs which suit their requirements. Logging Levels @@ -921,16 +891,16 @@ use with the % operator and a dictionary. For formatting multiple messages in a batch, instances of -:class:`~handlers.BufferingFormatter` can be used. In addition to the format -string (which is applied to each message in the batch), there is provision for -header and trailer format strings. +:class:`BufferingFormatter` can be used. In addition to the format string (which +is applied to each message in the batch), there is provision for header and +trailer format strings. When filtering based on logger level and/or handler level is not enough, instances of :class:`Filter` can be added to both :class:`Logger` and -:class:`Handler` instances (through their :meth:`~Handler.addFilter` method). -Before deciding to process a message further, both loggers and handlers consult -all their filters for permission. If any filter returns a false value, the -message is not processed further. +:class:`Handler` instances (through their :meth:`addFilter` method). Before +deciding to process a message further, both loggers and handlers consult all +their filters for permission. If any filter returns a false value, the message +is not processed further. The basic :class:`Filter` functionality allows filtering by specific logger name. If this feature is used, messages sent to the named logger and its @@ -948,20 +918,19 @@ cause the application using logging to terminate prematurely. :class:`SystemExit` and :class:`KeyboardInterrupt` exceptions are never -swallowed. Other exceptions which occur during the :meth:`~Handler.emit` method -of a :class:`Handler` subclass are passed to its :meth:`~Handler.handleError` -method. +swallowed. Other exceptions which occur during the :meth:`emit` method of a +:class:`Handler` subclass are passed to its :meth:`handleError` method. -The default implementation of :meth:`~Handler.handleError` in :class:`Handler` -checks to see if a module-level variable, :data:`raiseExceptions`, is set. If -set, a traceback is printed to :data:`sys.stderr`. If not set, the exception is -swallowed. +The default implementation of :meth:`handleError` in :class:`Handler` checks +to see if a module-level variable, :data:`raiseExceptions`, is set. If set, a +traceback is printed to :data:`sys.stderr`. If not set, the exception is swallowed. -.. note:: The default value of :data:`raiseExceptions` is ``True``. This is - because during development, you typically want to be notified of any - exceptions that occur. It's advised that you set :data:`raiseExceptions` to - ``False`` for production usage. +**Note:** The default value of :data:`raiseExceptions` is ``True``. This is because +during development, you typically want to be notified of any exceptions that +occur. It's advised that you set :data:`raiseExceptions` to ``False`` for production +usage. +.. currentmodule:: logging .. _arbitrary-object-messages: @@ -971,11 +940,11 @@ In the preceding sections and examples, it has been assumed that the message passed when logging the event is a string. However, this is not the only possibility. You can pass an arbitrary object as a message, and its -:meth:`~object.__str__` method will be called when the logging system needs to -convert it to a string representation. In fact, if you want to, you can avoid +:meth:`__str__` method will be called when the logging system needs to convert +it to a string representation. In fact, if you want to, you can avoid computing a string representation altogether - for example, the -:class:`~handlers.SocketHandler` emits an event by pickling it and sending it -over the wire. +:class:`SocketHandler` emits an event by pickling it and sending it over the +wire. Optimization @@ -984,10 +953,9 @@ Formatting of message arguments is deferred until it cannot be avoided. However, computing the arguments passed to the logging method can also be expensive, and you may want to avoid doing it if the logger will just throw -away your event. To decide what to do, you can call the -:meth:`~Logger.isEnabledFor` method which takes a level argument and returns -true if the event would be created by the Logger for that level of call. -You can write code like this:: +away your event. To decide what to do, you can call the :meth:`isEnabledFor` +method which takes a level argument and returns true if the event would be +created by the Logger for that level of call. You can write code like this:: if logger.isEnabledFor(logging.DEBUG): logger.debug('Message with %s, %s', expensive_func1(), @@ -996,15 +964,6 @@ so that if the logger's threshold is set above ``DEBUG``, the calls to :func:`expensive_func1` and :func:`expensive_func2` are never made. -.. note:: In some cases, :meth:`~Logger.isEnabledFor` can itself be more - expensive than you'd like (e.g. for deeply nested loggers where an explicit - level is only set high up in the logger hierarchy). In such cases (or if you - want to avoid calling a method in tight loops), you can cache the result of a - call to :meth:`~Logger.isEnabledFor` in a local or instance variable, and use - that instead of calling the method each time. Such a cached value would only - need to be recomputed when the logging configuration changes dynamically - while the application is running (which is not all that common). - There are other optimizations which can be made for specific applications which need more precise control over what logging information is collected. Here's a list of things you can do to avoid processing during logging which you don't @@ -1014,11 +973,6 @@ | What you don't want to collect | How to avoid collecting it | +===============================================+========================================+ | Information about where calls were made from. | Set ``logging._srcfile`` to ``None``. | -| | This avoids calling | -| | :func:`sys._getframe`, which may help | -| | to speed up your code in environments | -| | like PyPy (which can't speed up code | -| | that uses :func:`sys._getframe`). | +-----------------------------------------------+----------------------------------------+ | Threading information. | Set ``logging.logThreads`` to ``0``. | +-----------------------------------------------+----------------------------------------+ diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/howto/logging_flow.png Binary file Doc/howto/logging_flow.png has changed diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/howto/pyporting.rst --- a/Doc/howto/pyporting.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/howto/pyporting.rst Sun Jul 20 10:52:46 2014 -0400 @@ -10,211 +10,238 @@ With Python 3 being the future of Python while Python 2 is still in active use, it is good to have your project available for both major releases of - Python. This guide is meant to help you figure out how best to support both - Python 2 & 3 simultaneously. + Python. This guide is meant to help you choose which strategy works best + for your project to support both Python 2 & 3 along with how to execute + that strategy. If you are looking to port an extension module instead of pure Python code, please see :ref:`cporting-howto`. - If you would like to read one core Python developer's take on why Python 3 - came into existence, you can read Nick Coghlan's `Python 3 Q & A`_. - If you prefer to read a (free) book on porting a project to Python 3, - consider reading `Porting to Python 3`_ by Lennart Regebro which should cover - much of what is discussed in this HOWTO. +Choosing a Strategy +=================== - For help with porting, you can email the python-porting_ mailing list with - questions. +When a project makes the decision that it's time to support both Python 2 & 3, +a decision needs to be made as to how to go about accomplishing that goal. +The chosen strategy will depend on how large the project's existing +codebase is and how much divergence you want from your Python 2 codebase from +your Python 3 one (e.g., starting a new version with Python 3). -The Short Version -================= +If your project is brand-new or does not have a large codebase, then you may +want to consider writing/porting :ref:`all of your code for Python 3 +and use 3to2 ` to port your code for Python 2. -* Decide what's the oldest version of Python 2 you want to support (if at all) -* Make sure you have a thorough test suite and use continuous integration - testing to make sure you stay compatible with the versions of Python you care - about -* If you have dependencies, check their Python 3 status using caniusepython3 - (`command-line tool `__, - `web app `__) +If you would prefer to maintain a codebase which is semantically **and** +syntactically compatible with Python 2 & 3 simultaneously, you can write +:ref:`use_same_source`. While this tends to lead to somewhat non-idiomatic +code, it does mean you keep a rapid development process for you, the developer. -With that done, your options are: +Finally, you do have the option of :ref:`using 2to3 ` to translate +Python 2 code into Python 3 code (with some manual help). This can take the +form of branching your code and using 2to3 to start a Python 3 branch. You can +also have users perform the translation as installation time automatically so +that you only have to maintain a Python 2 codebase. -* If you are dropping Python 2 support, use 2to3_ to port to Python 3 -* If you are keeping Python 2 support, then start writing Python 2/3-compatible - code starting **TODAY** +Regardless of which approach you choose, porting is not as hard or +time-consuming as you might initially think. You can also tackle the problem +piece-meal as a good portion of porting is simply updating your code to follow +current best practices in a Python 2/3 compatible way. - + If you have dependencies that have not been ported, reach out to them to port - their project while working to make your code compatible with Python 3 so - you're ready when your dependencies are all ported - + If all your dependencies have been ported (or you have none), go ahead and - port to Python 3 -* If you are creating a new project that wants to have 2/3 compatibility, - code in Python 3 and then backport to Python 2 +Universal Bits of Advice +------------------------ +Regardless of what strategy you pick, there are a few things you should +consider. -Before You Begin -================ +One is make sure you have a robust test suite. You need to make sure everything +continues to work, just like when you support a new minor version of Python. +This means making sure your test suite is thorough and is ported properly +between Python 2 & 3. You will also most likely want to use something like tox_ +to automate testing between both a Python 2 and Python 3 VM. -If your project is on the Cheeseshop_/PyPI_, make sure it has the proper -`trove classifiers`_ to signify what versions of Python it **currently** -supports. At minimum you should specify the major version(s), e.g. -``Programming Language :: Python :: 2`` if your project currently only supports -Python 2. It is preferrable that you be as specific as possible by listing every -major/minor version of Python that you support, e.g. if your project supports -Python 2.6 and 2.7, then you want the classifiers of:: +Two, once your project has Python 3 support, make sure to add the proper +classifier on the Cheeseshop_ (PyPI_). To have your project listed as Python 3 +compatible it must have the +`Python 3 classifier `_ +(from +http://techspot.zzzeek.org/2011/01/24/zzzeek-s-guide-to-python-3-porting/):: - Programming Language :: Python :: 2 - Programming Language :: Python :: 2.6 - Programming Language :: Python :: 2.7 + setup( + name='Your Library', + version='1.0', + classifiers=[ + # make sure to use :: Python *and* :: Python :: 3 so + # that pypi can list the package on the python 3 page + 'Programming Language :: Python', + 'Programming Language :: Python :: 3' + ], + packages=['yourlibrary'], + # make sure to add custom_fixers to the MANIFEST.in + include_package_data=True, + # ... + ) -Once your project supports Python 3 you will want to go back and add the -appropriate classifiers for Python 3 as well. This is important as setting the -``Programming Language :: Python :: 3`` classifier will lead to your project -being listed under the `Python 3 Packages`_ section of PyPI. -Make sure you have a robust test suite. You need to -make sure everything continues to work, just like when you support a new -minor/feature release of Python. This means making sure your test suite is -thorough and is ported properly between Python 2 & 3 (consider using coverage_ -to measure that you have effective test coverage). You will also most likely -want to use something like tox_ to automate testing between all of your -supported versions of Python. You will also want to **port your tests first** so -that you can make sure that you detect breakage during the transition. Tests also -tend to be simpler than the code they are testing so it gives you an idea of how -easy it can be to port code. +Doing so will cause your project to show up in the +`Python 3 packages list +`_. You will know +you set the classifier properly as visiting your project page on the Cheeseshop +will show a Python 3 logo in the upper-left corner of the page. -Drop support for older Python versions if possible. `Python 2.5`_ +Three, the six_ project provides a library which helps iron out differences +between Python 2 & 3. If you find there is a sticky point that is a continual +point of contention in your translation or maintenance of code, consider using +a source-compatible solution relying on six. If you have to create your own +Python 2/3 compatible solution, you can use ``sys.version_info[0] >= 3`` as a +guard. + +Four, read all the approaches. Just because some bit of advice applies to one +approach more than another doesn't mean that some advice doesn't apply to other +strategies. + +Five, drop support for older Python versions if possible. `Python 2.5`_ introduced a lot of useful syntax and libraries which have become idiomatic in Python 3. `Python 2.6`_ introduced future statements which makes compatibility much easier if you are going from Python 2 to 3. -`Python 2.7`_ continues the trend in the stdlib. Choose the newest version +`Python 2.7`_ continues the trend in the stdlib. So choose the newest version of Python which you believe can be your minimum support version and work from there. -Target the newest version of Python 3 that you can. Beyond just the usual -bugfixes, compatibility has continued to improve between Python 2 and 3 as time -has passed. E.g. Python 3.3 added back the ``u`` prefix for -strings, making source-compatible Python code easier to write. +.. _tox: http://codespeak.net/tox/ +.. _Cheeseshop: +.. _PyPI: http://pypi.python.org/ +.. _six: http://packages.python.org/six +.. _Python 2.7: http://www.python.org/2.7.x +.. _Python 2.6: http://www.python.org/2.6.x +.. _Python 2.5: http://www.python.org/2.5.x +.. _Python 2.4: http://www.python.org/2.4.x +.. _Python 2.3: http://www.python.org/2.3.x +.. _Python 2.2: http://www.python.org/2.2.x -Writing Source-Compatible Python 2/3 Code -========================================= -Over the years the Python community has discovered that the easiest way to -support both Python 2 and 3 in parallel is to write Python code that works in -either version. While this might sound counter-intuitive at first, it actually -is not difficult and typically only requires following some select -(non-idiomatic) practices and using some key projects to help make bridging -between Python 2 and 3 easier. +.. _use_3to2: -Projects to Consider --------------------- +Python 3 and 3to2 +================= -The lowest level library for supporting Python 2 & 3 simultaneously is six_. -Reading through its documentation will give you an idea of where exactly the -Python language changed between versions 2 & 3 and thus what you will want the -library to help you continue to support. +If you are starting a new project or your codebase is small enough, you may +want to consider writing your code for Python 3 and backporting to Python 2 +using 3to2_. Thanks to Python 3 being more strict about things than Python 2 +(e.g., bytes vs. strings), the source translation can be easier and more +straightforward than from Python 2 to 3. Plus it gives you more direct +experience developing in Python 3 which, since it is the future of Python, is a +good thing long-term. -To help automate porting your code over to using six, you can use -modernize_. This project will attempt to rewrite your code to be as modern as -possible while using six to smooth out any differences between Python 2 & 3. +A drawback of this approach is that 3to2 is a third-party project. This means +that the Python core developers (and thus this guide) can make no promises +about how well 3to2 works at any time. There is nothing to suggest, though, +that 3to2 is not a high-quality project. -If you want to write your compatible code to feel more like Python 3 there is -the future_ project. It tries to provide backports of objects from Python 3 so -that you can use them from Python 2-compatible code, e.g. replacing the -``bytes`` type from Python 2 with the one from Python 3. -It also provides a translation script like modernize (its translation code is -actually partially based on it) to help start working with a pre-existing code -base. It is also unique in that its translation script will also port Python 3 -code backwards as well as Python 2 code forwards. +.. _3to2: https://bitbucket.org/amentajo/lib3to2/overview -Tips & Tricks -------------- -To help with writing source-compatible code using one of the projects mentioned -in `Projects to Consider`_, consider following the below suggestions. Some of -them are handled by the suggested projects, so if you do use one of them then -read their documentation first to see which suggestions below will taken care of -for you. +.. _use_2to3: + +Python 2 and 2to3 +================= + +Included with Python since 2.6, the 2to3_ tool (and :mod:`lib2to3` module) +helps with porting Python 2 to Python 3 by performing various source +translations. This is a perfect solution for projects which wish to branch +their Python 3 code from their Python 2 codebase and maintain them as +independent codebases. You can even begin preparing to use this approach +today by writing future-compatible Python code which works cleanly in +Python 2 in conjunction with 2to3; all steps outlined below will work +with Python 2 code up to the point when the actual use of 2to3 occurs. + +Use of 2to3 as an on-demand translation step at install time is also possible, +preventing the need to maintain a separate Python 3 codebase, but this approach +does come with some drawbacks. While users will only have to pay the +translation cost once at installation, you as a developer will need to pay the +cost regularly during development. If your codebase is sufficiently large +enough then the translation step ends up acting like a compilation step, +robbing you of the rapid development process you are used to with Python. +Obviously the time required to translate a project will vary, so do an +experimental translation just to see how long it takes to evaluate whether you +prefer this approach compared to using :ref:`use_same_source` or simply keeping +a separate Python 3 codebase. + +Below are the typical steps taken by a project which uses a 2to3-based approach +to supporting Python 2 & 3. + Support Python 2.7 -////////////////// +------------------ As a first step, make sure that your project is compatible with `Python 2.7`_. This is just good to do as Python 2.7 is the last release of Python 2 and thus will be used for a rather long time. It also allows for use of the ``-3`` flag -to Python to help discover places in your code where compatibility might be an -issue (the ``-3`` flag is in Python 2.6 but Python 2.7 adds more warnings). +to Python to help discover places in your code which 2to3 cannot handle but are +known to cause issues. Try to Support `Python 2.6`_ and Newer Only -/////////////////////////////////////////// +------------------------------------------- While not possible for all projects, if you can support `Python 2.6`_ and newer **only**, your life will be much easier. Various future statements, stdlib additions, etc. exist only in Python 2.6 and later which greatly assist in -supporting Python 3. But if you project must keep support for `Python 2.5`_ then -it is still possible to simultaneously support Python 3. +porting to Python 3. But if you project must keep support for `Python 2.5`_ (or +even `Python 2.4`_) then it is still possible to port to Python 3. Below are the benefits you gain if you only have to support Python 2.6 and newer. Some of these options are personal choice while others are **strongly** recommended (the ones that are more for personal choice are labeled as such). If you continue to support older versions of Python then you -at least need to watch out for situations that these solutions fix and handle -them appropriately (which is where library help from e.g. six_ comes in handy). +at least need to watch out for situations that these solutions fix. ``from __future__ import print_function`` ''''''''''''''''''''''''''''''''''''''''' -It will not only get you used to typing ``print()`` as a function instead of a -statement, but it will also give you the various benefits the function has over -the Python 2 statement (six_ provides a function if you support Python 2.5 or -older). +This is a personal choice. 2to3 handles the translation from the print +statement to the print function rather well so this is an optional step. This +future statement does help, though, with getting used to typing +``print('Hello, World')`` instead of ``print 'Hello, World'``. ``from __future__ import unicode_literals`` ''''''''''''''''''''''''''''''''''''''''''' -If you choose to use this future statement then all string literals in -Python 2 will be assumed to be Unicode (as is already the case in Python 3). -If you choose not to use this future statement then you should mark all of your -text strings with a ``u`` prefix and only support Python 3.3 or newer. But you -are **strongly** advised to do one or the other (six_ provides a function in -case you don't want to use the future statement **and** you want to support -Python 3.2 or older). +Another personal choice. You can always mark what you want to be a (unicode) +string with a ``u`` prefix to get the same effect. But regardless of whether +you use this future statement or not, you **must** make sure you know exactly +which Python 2 strings you want to be bytes, and which are to be strings. This +means you should, **at minimum** mark all strings that are meant to be text +strings with a ``u`` prefix if you do not use this future statement. -Bytes/string literals -''''''''''''''''''''' +Bytes literals +'''''''''''''' -This is a **very** important one. Prefix Python 2 strings that -are meant to contain bytes with a ``b`` prefix to very clearly delineate -what is and is not a Python 3 text string (six_ provides a function to use for -Python 2.5 compatibility). - -This point cannot be stressed enough: make sure you know what all of your string -literals in Python 2 are meant to be in Python 3. Any string literal that -should be treated as bytes should have the ``b`` prefix. Any string literal -that should be Unicode/text in Python 2 should either have the ``u`` literal -(supported, but ignored, in Python 3.3 and later) or you should have -``from __future__ import unicode_literals`` at the top of the file. But the key -point is you should know how Python 3 will treat every one one of your string -literals and you should mark them as appropriate. +This is a **very** important one. The ability to prefix Python 2 strings that +are meant to contain bytes with a ``b`` prefix help to very clearly delineate +what is and is not a Python 3 string. When you run 2to3 on code, all Python 2 +strings become Python 3 strings **unless** they are prefixed with ``b``. There are some differences between byte literals in Python 2 and those in Python 3 thanks to the bytes type just being an alias to ``str`` in Python 2. -See the `Handle Common "Gotchas"`_ section for what to watch out for. +Probably the biggest "gotcha" is that indexing results in different values. In +Python 2, the value of ``b'py'[1]`` is ``'y'``, while in Python 3 it's ``121``. +You can avoid this disparity by always slicing at the size of a single element: +``b'py'[1:2]`` is ``'y'`` in Python 2 and ``b'y'`` in Python 3 (i.e., close +enough). -``from __future__ import absolute_import`` -'''''''''''''''''''''''''''''''''''''''''' -Discussed in more detail below, but you should use this future statement to -prevent yourself from accidentally using implicit relative imports. +You cannot concatenate bytes and strings in Python 3. But since in Python +2 has bytes aliased to ``str``, it will succeed: ``b'a' + u'b'`` works in +Python 2, but ``b'a' + 'b'`` in Python 3 is a :exc:`TypeError`. A similar issue +also comes about when doing comparisons between bytes and strings. Supporting `Python 2.5`_ and Newer Only -/////////////////////////////////////// +--------------------------------------- If you are supporting `Python 2.5`_ and newer there are still some features of Python that you can utilize. @@ -224,7 +251,7 @@ '''''''''''''''''''''''''''''''''''''''''' Implicit relative imports (e.g., importing ``spam.bacon`` from within -``spam.eggs`` with the statement ``import bacon``) do not work in Python 3. +``spam.eggs`` with the statement ``import bacon``) does not work in Python 3. This future statement moves away from that and allows the use of explicit relative imports (e.g., ``from . import bacon``). @@ -234,74 +261,16 @@ the statement, but you still want the __future__ statement to prevent implicit relative imports. In `Python 2.7`_ the __future__ statement is not needed. In other words, unless you are only supporting Python 2.7 or a version earlier -than Python 2.5, use this __future__ statement. +than Python 2.5, use the __future__ statement. -Mark all Unicode strings with a ``u`` prefix -''''''''''''''''''''''''''''''''''''''''''''' - -While Python 2.6 has a ``__future__`` statement to automatically cause Python 2 -to treat all string literals as Unicode, Python 2.5 does not have that shortcut. -This means you should go through and mark all string literals with a ``u`` -prefix to turn them explicitly into text strings where appropriate and only -support Python 3.3 or newer. Otherwise use a project like six_ which provides a -function to pass all text string literals through. - - -Capturing the Currently Raised Exception -'''''''''''''''''''''''''''''''''''''''' - -In Python 2.5 and earlier the syntax to access the current exception is:: - - try: - raise Exception() - except Exception, exc: - # Current exception is 'exc'. - pass - -This syntax changed in Python 3 (and backported to `Python 2.6`_ and later) -to:: - - try: - raise Exception() - except Exception as exc: - # Current exception is 'exc'. - # In Python 3, 'exc' is restricted to the block; in Python 2.6/2.7 it will "leak". - pass - -Because of this syntax change you must change how you capture the current -exception in Python 2.5 and earlier to:: - - try: - raise Exception() - except Exception: - import sys - exc = sys.exc_info()[1] - # Current exception is 'exc'. - pass - -You can get more information about the raised exception from -:func:`sys.exc_info` than simply the current exception instance, but you most -likely don't need it. - -.. note:: - In Python 3, the traceback is attached to the exception instance - through the ``__traceback__`` attribute. If the instance is saved in - a local variable that persists outside of the ``except`` block, the - traceback will create a reference cycle with the current frame and its - dictionary of local variables. This will delay reclaiming dead - resources until the next cyclic :term:`garbage collection` pass. - - In Python 2, this problem only occurs if you save the traceback itself - (e.g. the third element of the tuple returned by :func:`sys.exc_info`) - in a variable. - Handle Common "Gotchas" -/////////////////////// +----------------------- -These are things to watch out for no matter what version of Python 2 you are -supporting which are not syntactic considerations. +There are a few things that just consistently come up as sticking points for +people which 2to3 cannot handle automatically or can easily be done in Python 2 +to help modernize your code. ``from __future__ import division`` @@ -358,9 +327,9 @@ the bytes/string dichotomy. Because Python 2 allowed the ``str`` type to hold textual data, people have over the years been rather loose in their delineation of what ``str`` instances held text compared to bytes. In Python 3 you cannot -be so care-free anymore and need to properly handle the difference. The key to -handling this issue is to make sure that **every** string literal in your -Python 2 code is either syntactically or functionally marked as either bytes or +be so care-free anymore and need to properly handle the difference. The key +handling this issue to make sure that **every** string literal in your +Python 2 code is either syntactically of functionally marked as either bytes or text data. After this is done you then need to make sure your APIs are designed to either handle a specific type or made to be properly polymorphic. @@ -374,7 +343,7 @@ and then designating textual data with a ``u`` prefix or using the ``unicode_literals`` future statement. -If your project supports versions of Python predating 2.6, then you should use +If your project supports versions of Python pre-dating 2.6, then you should use the six_ project and its ``b()`` function to denote bytes literals. For text literals you can either use six's ``u()`` function or use a ``u`` prefix. @@ -467,7 +436,14 @@ happen to use the ``unicode(self).encode('utf8')`` idiom as the body of your ``__str__()`` method). -You can use a mixin class to work around this. This allows you to only define a +There are two ways to solve this issue. One is to use a custom 2to3 fixer. The +blog post at http://lucumr.pocoo.org/2011/1/22/forwards-compatible-python/ +specifies how to do this. That will allow 2to3 to change all instances of ``def +__unicode(self): ...`` to ``def __str__(self): ...``. This does require you +define your ``__str__()`` method in Python 2 before your ``__unicode__()`` +method. + +The other option is to use a mixin class. This allows you to only define a ``__unicode__()`` method for your class and let the mixin derive ``__str__()`` for you (code from http://lucumr.pocoo.org/2011/1/22/forwards-compatible-python/):: @@ -510,7 +486,6 @@ Even better is to use the documented attributes the exception provides. - Don't use ``__getslice__`` & Friends '''''''''''''''''''''''''''''''''''' @@ -522,62 +497,189 @@ Updating doctests ''''''''''''''''' -Don't forget to make them Python 2/3 compatible as well. If you wrote a -monolithic set of doctests (e.g., a single docstring containing all of your -doctests), you should at least consider breaking the doctests up into smaller -pieces to make it more manageable to fix. Otherwise it might very well be worth -your time and effort to port your tests to :mod:`unittest`. +2to3_ will attempt to generate fixes for doctests that it comes across. It's +not perfect, though. If you wrote a monolithic set of doctests (e.g., a single +docstring containing all of your doctests), you should at least consider +breaking the doctests up into smaller pieces to make it more manageable to fix. +Otherwise it might very well be worth your time and effort to port your tests +to :mod:`unittest`. -Update ``map`` for imbalanced input sequences -''''''''''''''''''''''''''''''''''''''''''''' - -With Python 2, when ``map`` was given more than one input sequence it would pad -the shorter sequences with `None` values, returning a sequence as long as the -longest input sequence. - -With Python 3, if the input sequences to ``map`` are of unequal length, ``map`` -will stop at the termination of the shortest of the sequences. For full -compatibility with ``map`` from Python 2.x, wrap the sequence arguments in -:func:`itertools.zip_longest`, e.g. ``map(func, *sequences)`` becomes -``list(map(func, itertools.zip_longest(*sequences)))``. - Eliminate ``-3`` Warnings ------------------------- When you run your application's test suite, run it using the ``-3`` flag passed to Python. This will cause various warnings to be raised during execution about -things that are semantic changes between Python 2 and 3. Try to eliminate those -warnings to make your code even more portable to Python 3. +things that 2to3 cannot handle automatically (e.g., modules that have been +removed). Try to eliminate those warnings to make your code even more portable +to Python 3. -Alternative Approaches -====================== +Run 2to3 +-------- -While supporting Python 2 & 3 simultaneously is typically the preferred choice -by people so that they can continue to improve code and have it work for the -most number of users, your life may be easier if you only have to support one -major version of Python going forward. +Once you have made your Python 2 code future-compatible with Python 3, it's +time to use 2to3_ to actually port your code. -Supporting Only Python 3 Going Forward From Python 2 Code ---------------------------------------------------------- -If you have Python 2 code but going forward only want to improve it as Python 3 -code, then you can use 2to3_ to translate your Python 2 code to Python 3 code. -This is only recommended, though, if your current version of your project is -going into maintenance mode and you want all new features to be exclusive to -Python 3. +Manually +'''''''' +To manually convert source code using 2to3_, you use the ``2to3`` script that +is installed with Python 2.6 and later.:: -Backporting Python 3 code to Python 2 -------------------------------------- + 2to3 -If you have Python 3 code and have little interest in supporting Python 2 you -can use 3to2_ to translate from Python 3 code to Python 2 code. This is only -recommended if you don't plan to heavily support Python 2 users. Otherwise -write your code for Python 3 and then backport as far back as you want. This -is typically easier than going from Python 2 to 3 as you will have worked out -any difficulties with e.g. bytes/strings, etc. +This will cause 2to3 to write out a diff with all of the fixers applied for the +converted source code. If you would like 2to3 to go ahead and apply the changes +you can pass it the ``-w`` flag:: + + 2to3 -w + +There are other flags available to control exactly which fixers are applied, +etc. + + +During Installation +''''''''''''''''''' + +When a user installs your project for Python 3, you can have either +:mod:`distutils` or Distribute_ run 2to3_ on your behalf. +For distutils, use the following idiom:: + + try: # Python 3 + from distutils.command.build_py import build_py_2to3 as build_py + except ImportError: # Python 2 + from distutils.command.build_py import build_py + + setup(cmdclass = {'build_py': build_py}, + # ... + ) + +For Distribute:: + + setup(use_2to3=True, + # ... + ) + +This will allow you to not have to distribute a separate Python 3 version of +your project. It does require, though, that when you perform development that +you at least build your project and use the built Python 3 source for testing. + + +Verify & Test +------------- + +At this point you should (hopefully) have your project converted in such a way +that it works in Python 3. Verify it by running your unit tests and making sure +nothing has gone awry. If you miss something then figure out how to fix it in +Python 3, backport to your Python 2 code, and run your code through 2to3 again +to verify the fix transforms properly. + + +.. _2to3: http://docs.python.org/py3k/library/2to3.html +.. _Distribute: http://packages.python.org/distribute/ + + +.. _use_same_source: + +Python 2/3 Compatible Source +============================ + +While it may seem counter-intuitive, you can write Python code which is +source-compatible between Python 2 & 3. It does lead to code that is not +entirely idiomatic Python (e.g., having to extract the currently raised +exception from ``sys.exc_info()[1]``), but it can be run under Python 2 +**and** Python 3 without using 2to3_ as a translation step (although the tool +should be used to help find potential portability problems). This allows you to +continue to have a rapid development process regardless of whether you are +developing under Python 2 or Python 3. Whether this approach or using +:ref:`use_2to3` works best for you will be a per-project decision. + +To get a complete idea of what issues you will need to deal with, see the +`What's New in Python 3.0`_. Others have reorganized the data in other formats +such as http://docs.pythonsprints.com/python3_porting/py-porting.html . + +The following are some steps to take to try to support both Python 2 & 3 from +the same source code. + + +.. _What's New in Python 3.0: http://docs.python.org/release/3.0/whatsnew/3.0.html + + +Follow The Steps for Using 2to3_ +-------------------------------- + +All of the steps outlined in how to +:ref:`port Python 2 code with 2to3 ` apply +to creating a Python 2/3 codebase. This includes trying only support Python 2.6 +or newer (the :mod:`__future__` statements work in Python 3 without issue), +eliminating warnings that are triggered by ``-3``, etc. + +You should even consider running 2to3_ over your code (without committing the +changes). This will let you know where potential pain points are within your +code so that you can fix them properly before they become an issue. + + +Use six_ +-------- + +The six_ project contains many things to help you write portable Python code. +You should make sure to read its documentation from beginning to end and use +any and all features it provides. That way you will minimize any mistakes you +might make in writing cross-version code. + + +Capturing the Currently Raised Exception +---------------------------------------- + +One change between Python 2 and 3 that will require changing how you code (if +you support `Python 2.5`_ and earlier) is +accessing the currently raised exception. In Python 2.5 and earlier the syntax +to access the current exception is:: + + try: + raise Exception() + except Exception, exc: + # Current exception is 'exc' + pass + +This syntax changed in Python 3 (and backported to `Python 2.6`_ and later) +to:: + + try: + raise Exception() + except Exception as exc: + # Current exception is 'exc' + # In Python 3, 'exc' is restricted to the block; Python 2.6 will "leak" + pass + +Because of this syntax change you must change to capturing the current +exception to:: + + try: + raise Exception() + except Exception: + import sys + exc = sys.exc_info()[1] + # Current exception is 'exc' + pass + +You can get more information about the raised exception from +:func:`sys.exc_info` than simply the current exception instance, but you most +likely don't need it. + +.. note:: + In Python 3, the traceback is attached to the exception instance + through the ``__traceback__`` attribute. If the instance is saved in + a local variable that persists outside of the ``except`` block, the + traceback will create a reference cycle with the current frame and its + dictionary of local variables. This will delay reclaiming dead + resources until the next cyclic :term:`garbage collection` pass. + + In Python 2, this problem only occurs if you save the traceback itself + (e.g. the third element of the tuple returned by :func:`sys.exc_info`) + in a variable. Other Resources @@ -585,41 +687,17 @@ The authors of the following blog posts, wiki pages, and books deserve special thanks for making public their tips for porting Python 2 code to Python 3 (and -thus helping provide information for this document and its various revisions -over the years): +thus helping provide information for this document): -* http://wiki.python.org/moin/PortingPythonToPy3k * http://python3porting.com/ * http://docs.pythonsprints.com/python3_porting/py-porting.html * http://techspot.zzzeek.org/2011/01/24/zzzeek-s-guide-to-python-3-porting/ * http://dabeaz.blogspot.com/2011/01/porting-py65-and-my-superboard-to.html * http://lucumr.pocoo.org/2011/1/22/forwards-compatible-python/ * http://lucumr.pocoo.org/2010/2/11/porting-to-python-3-a-guide/ -* https://wiki.ubuntu.com/Python/3 +* http://wiki.python.org/moin/PortingPythonToPy3k If you feel there is something missing from this document that should be added, please email the python-porting_ mailing list. - - -.. _2to3: http://docs.python.org/2/library/2to3.html -.. _3to2: https://pypi.python.org/pypi/3to2 -.. _Cheeseshop: PyPI_ -.. _coverage: https://pypi.python.org/pypi/coverage -.. _future: http://python-future.org/ -.. _modernize: https://github.com/mitsuhiko/python-modernize -.. _Porting to Python 3: http://python3porting.com/ -.. _PyPI: http://pypi.python.org/ -.. _Python 2.2: http://www.python.org/2.2.x -.. _Python 2.5: http://www.python.org/2.5.x -.. _Python 2.6: http://www.python.org/2.6.x -.. _Python 2.7: http://www.python.org/2.7.x -.. _Python 2.5: http://www.python.org/2.5.x -.. _Python 3.3: http://www.python.org/3.3.x -.. _Python 3 Packages: https://pypi.python.org/pypi?:action=browse&c=533&show=all -.. _Python 3 Q & A: http://ncoghlan-devs-python-notes.readthedocs.org/en/latest/python3/questions_and_answers.html .. _python-porting: http://mail.python.org/mailman/listinfo/python-porting -.. _six: https://pypi.python.org/pypi/six -.. _tox: https://pypi.python.org/pypi/tox -.. _trove classifiers: https://pypi.python.org/pypi?%3Aaction=list_classifiers - diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/howto/regex.rst --- a/Doc/howto/regex.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/howto/regex.rst Sun Jul 20 10:52:46 2014 -0400 @@ -265,7 +265,7 @@ >>> import re >>> p = re.compile('ab*') - >>> p #doctest: +ELLIPSIS + >>> print p <_sre.SRE_Pattern object at 0x...> :func:`re.compile` also accepts an optional *flags* argument, used to enable @@ -359,13 +359,13 @@ +------------------+-----------------------------------------------+ :meth:`match` and :meth:`search` return ``None`` if no match can be found. If -they're successful, a :ref:`match object ` instance is returned, -containing information about the match: where it starts and ends, the substring -it matched, and more. +they're successful, a ``MatchObject`` instance is returned, containing +information about the match: where it starts and ends, the substring it matched, +and more. You can learn about this by interactively experimenting with the :mod:`re` module. If you have Tkinter available, you may also want to look at -:source:`Tools/scripts/redemo.py`, a demonstration program included with the +:file:`Tools/scripts/redemo.py`, a demonstration program included with the Python distribution. It allows you to enter REs and strings, and displays whether the RE matches or fails. :file:`redemo.py` can be quite useful when trying to debug a complicated RE. Phil Schwartz's `Kodos @@ -378,7 +378,7 @@ Python 2.2.2 (#1, Feb 10 2003, 12:57:01) >>> import re >>> p = re.compile('[a-z]+') - >>> p #doctest: +ELLIPSIS + >>> p <_sre.SRE_Pattern object at 0x...> Now, you can try matching various strings against the RE ``[a-z]+``. An empty @@ -392,16 +392,16 @@ None Now, let's try it on a string that it should match, such as ``tempo``. In this -case, :meth:`match` will return a :ref:`match object `, so you -should store the result in a variable for later use. :: +case, :meth:`match` will return a :class:`MatchObject`, so you should store the +result in a variable for later use. :: >>> m = p.match('tempo') - >>> m #doctest: +ELLIPSIS + >>> print m <_sre.SRE_Match object at 0x...> -Now you can query the :ref:`match object ` for information -about the matching string. :ref:`match object ` instances -also have several methods and attributes; the most important ones are: +Now you can query the :class:`MatchObject` for information about the matching +string. :class:`MatchObject` instances also have several methods and +attributes; the most important ones are: +------------------+--------------------------------------------+ | Method/Attribute | Purpose | @@ -435,16 +435,15 @@ >>> print p.match('::: message') None - >>> m = p.search('::: message'); print m #doctest: +ELLIPSIS + >>> m = p.search('::: message') ; print m <_sre.SRE_Match object at 0x...> >>> m.group() 'message' >>> m.span() (4, 11) -In actual programs, the most common style is to store the -:ref:`match object ` in a variable, and then check if it was -``None``. This usually looks like:: +In actual programs, the most common style is to store the :class:`MatchObject` +in a variable, and then check if it was ``None``. This usually looks like:: p = re.compile( ... ) m = p.match( 'string goes here' ) @@ -461,12 +460,12 @@ ['12', '11', '10'] :meth:`findall` has to create the entire list before it can be returned as the -result. The :meth:`finditer` method returns a sequence of -:ref:`match object ` instances as an :term:`iterator`. [#]_ :: +result. The :meth:`finditer` method returns a sequence of :class:`MatchObject` +instances as an :term:`iterator`. [#]_ :: >>> iterator = p.finditer('12 drummers drumming, 11 ... 10 ...') - >>> iterator #doctest: +ELLIPSIS - + >>> iterator + >>> for match in iterator: ... print match.span() ... @@ -483,11 +482,11 @@ :func:`search`, :func:`findall`, :func:`sub`, and so forth. These functions take the same arguments as the corresponding pattern method, with the RE string added as the first argument, and still return either ``None`` or a -:ref:`match object ` instance. :: +:class:`MatchObject` instance. :: >>> print re.match(r'From\s+', 'Fromage amk') None - >>> re.match(r'From\s+', 'From amk Thu May 14 19:12:10 1998') #doctest: +ELLIPSIS + >>> re.match(r'From\s+', 'From amk Thu May 14 19:12:10 1998') <_sre.SRE_Match object at 0x...> Under the hood, these functions simply create a pattern object for you @@ -502,7 +501,7 @@ the same ones in several locations, then it might be worthwhile to collect all the definitions in one place, in a section of code that compiles all the REs ahead of time. To take an example from the standard library, here's an extract -from the deprecated :mod:`xmllib` module:: +from :file:`xmllib.py`:: ref = re.compile( ... ) entityref = re.compile( ... ) @@ -688,7 +687,7 @@ For example, if you wish to match the word ``From`` only at the beginning of a line, the RE to use is ``^From``. :: - >>> print re.search('^From', 'From Here to Eternity') #doctest: +ELLIPSIS + >>> print re.search('^From', 'From Here to Eternity') <_sre.SRE_Match object at 0x...> >>> print re.search('^From', 'Reciting From Memory') None @@ -700,11 +699,11 @@ Matches at the end of a line, which is defined as either the end of the string, or any location followed by a newline character. :: - >>> print re.search('}$', '{block}') #doctest: +ELLIPSIS + >>> print re.search('}$', '{block}') <_sre.SRE_Match object at 0x...> >>> print re.search('}$', '{block} ') None - >>> print re.search('}$', '{block}\n') #doctest: +ELLIPSIS + >>> print re.search('}$', '{block}\n') <_sre.SRE_Match object at 0x...> To match a literal ``'$'``, use ``\$`` or enclose it inside a character class, @@ -729,7 +728,7 @@ match when it's contained inside another word. :: >>> p = re.compile(r'\bclass\b') - >>> print p.search('no class at all') #doctest: +ELLIPSIS + >>> print p.search('no class at all') <_sre.SRE_Match object at 0x...> >>> print p.search('the declassified algorithm') None @@ -747,7 +746,7 @@ >>> p = re.compile('\bclass\b') >>> print p.search('no class at all') None - >>> print p.search('\b' + 'class' + '\b') #doctest: +ELLIPSIS + >>> print p.search('\b' + 'class' + '\b') <_sre.SRE_Match object at 0x...> Second, inside a character class, where there's no use for this assertion, @@ -792,9 +791,9 @@ index of the text that they match; this can be retrieved by passing an argument to :meth:`group`, :meth:`start`, :meth:`end`, and :meth:`span`. Groups are numbered starting with 0. Group 0 is always present; it's the whole RE, so -:ref:`match object ` methods all have group 0 as their default -argument. Later we'll see how to express groups that don't capture the span -of text that they match. :: +:class:`MatchObject` methods all have group 0 as their default argument. Later +we'll see how to express groups that don't capture the span of text that they +match. :: >>> p = re.compile('(a)b') >>> m = p.match('ab') @@ -914,10 +913,10 @@ The syntax for a named group is one of the Python-specific extensions: ``(?P...)``. *name* is, obviously, the name of the group. Named groups also behave exactly like capturing groups, and additionally associate a name -with a group. The :ref:`match object ` methods that deal with -capturing groups all accept either integers that refer to the group by number -or strings that contain the desired group's name. Named groups are still -given numbers, so you can retrieve information about a group in two ways:: +with a group. The :class:`MatchObject` methods that deal with capturing groups +all accept either integers that refer to the group by number or strings that +contain the desired group's name. Named groups are still given numbers, so you +can retrieve information about a group in two ways:: >>> p = re.compile(r'(?P\b\w+\b)') >>> m = p.search( '(((( Lots of punctuation )))' ) @@ -1181,16 +1180,16 @@ *replacement* can also be a function, which gives you even more control. If *replacement* is a function, the function is called for every non-overlapping -occurrence of *pattern*. On each call, the function is passed a -:ref:`match object ` argument for the match and can use this -information to compute the desired replacement string and return it. +occurrence of *pattern*. On each call, the function is passed a +:class:`MatchObject` argument for the match and can use this information to +compute the desired replacement string and return it. -In the following example, the replacement function translates decimals into +In the following example, the replacement function translates decimals into hexadecimal:: - >>> def hexrepl(match): + >>> def hexrepl( match ): ... "Return the hex string for a decimal number" - ... value = int(match.group()) + ... value = int( match.group() ) ... return hex(value) ... >>> p = re.compile(r'\d+') diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/howto/sockets.rst --- a/Doc/howto/sockets.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/howto/sockets.rst Sun Jul 20 10:52:46 2014 -0400 @@ -1,5 +1,3 @@ -.. _socket-howto: - **************************** Socket Programming HOWTO **************************** @@ -19,6 +17,12 @@ Sockets ======= +Sockets are used nearly everywhere, but are one of the most severely +misunderstood technologies around. This is a 10,000 foot overview of sockets. +It's not really a tutorial - you'll still have work to do in getting things +working. It doesn't cover the fine points (and there are a lot of them), but I +hope it will give you enough background to begin using them decently. + I'm only going to talk about INET sockets, but they account for at least 99% of the sockets in use. And I'll only talk about STREAM sockets - unless you really know what you're doing (in which case this HOWTO isn't for you!), you'll get @@ -82,11 +86,9 @@ serversocket.listen(5) A couple things to notice: we used ``socket.gethostname()`` so that the socket -would be visible to the outside world. If we had used ``s.bind(('localhost', -80))`` or ``s.bind(('127.0.0.1', 80))`` we would still have a "server" socket, -but one that was only visible within the same machine. ``s.bind(('', 80))`` -specifies that the socket is reachable by any address the machine happens to -have. +would be visible to the outside world. If we had used ``s.bind(('', 80))`` or +``s.bind(('localhost', 80))`` or ``s.bind(('127.0.0.1', 80))`` we would still +have a "server" socket, but one that was only visible within the same machine. A second thing to note: low number ports are usually reserved for "well known" services (HTTP, SNMP etc). If you're playing around, use a nice high number (4 @@ -152,7 +154,7 @@ there, you may wait forever for the reply, because the request may still be in your output buffer. -Now we come to the major stumbling block of sockets - ``send`` and ``recv`` operate +Now we come the major stumbling block of sockets - ``send`` and ``recv`` operate on the network buffers. They do not necessarily handle all the bytes you hand them (or expect from them), because their major focus is handling the network buffers. In general, they return when the associated network buffers have been @@ -163,7 +165,7 @@ When a ``recv`` returns 0 bytes, it means the other side has closed (or is in the process of closing) the connection. You will not receive any more data on this connection. Ever. You may be able to send data successfully; I'll talk -more about this later. +about that some on the next page. A protocol like HTTP uses a socket for only one transfer. The client sends a request, then reads a reply. That's it. The socket is discarded. This means that @@ -207,15 +209,13 @@ totalsent = totalsent + sent def myreceive(self): - chunks = [] - bytes_recd = 0 - while bytes_recd < MSGLEN: - chunk = self.sock.recv(min(MSGLEN - bytes_recd, 2048)) + msg = '' + while len(msg) < MSGLEN: + chunk = self.sock.recv(MSGLEN-len(msg)) if chunk == '': raise RuntimeError("socket connection broken") - chunks.append(chunk) - bytes_recd = bytes_recd + len(chunk) - return ''.join(chunks) + msg = msg + chunk + return msg The sending code here is usable for almost any messaging scheme - in Python you send strings, and you can use ``len()`` to determine its length (even if it has diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/howto/sorting.rst --- a/Doc/howto/sorting.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/howto/sorting.rst Sun Jul 20 10:52:46 2014 -0400 @@ -124,7 +124,7 @@ ======================== Both :meth:`list.sort` and :func:`sorted` accept a *reverse* parameter with a -boolean value. This is used to flag descending sorts. For example, to get the +boolean value. This is using to flag descending sorts. For example, to get the student data in reverse *age* order: >>> sorted(student_tuples, key=itemgetter(2), reverse=True) @@ -210,11 +210,11 @@ arguments. Instead, all of the Py2.x versions supported a *cmp* parameter to handle user specified comparison functions. -In Python 3, the *cmp* parameter was removed entirely (as part of a larger effort to +In Py3.0, the *cmp* parameter was removed entirely (as part of a larger effort to simplify and unify the language, eliminating the conflict between rich comparisons and the :meth:`__cmp__` magic method). -In Python 2, :meth:`~list.sort` allowed an optional function which can be called for doing the +In Py2.x, sort allowed an optional function which can be called for doing the comparisons. That function should take two arguments to be compared and then return a negative value for less-than, return zero if they are equal, or return a positive value for greater-than. For example, we can do: @@ -276,15 +276,11 @@ >>> data = [('red', 1), ('blue', 1), ('red', 2), ('blue', 2)] >>> assert sorted(data, reverse=True) == list(reversed(sorted(reversed(data)))) -* To create a standard sort order for a class, just add the appropriate rich - comparison methods: +* The sort routines are guaranteed to use :meth:`__lt__` when making comparisons + between two objects. So, it is easy to add a standard sort order to a class by + defining an :meth:`__lt__` method:: - >>> Student.__eq__ = lambda self, other: self.age == other.age - >>> Student.__ne__ = lambda self, other: self.age != other.age >>> Student.__lt__ = lambda self, other: self.age < other.age - >>> Student.__le__ = lambda self, other: self.age <= other.age - >>> Student.__gt__ = lambda self, other: self.age > other.age - >>> Student.__ge__ = lambda self, other: self.age >= other.age >>> sorted(student_objects) [('dave', 'B', 10), ('jane', 'B', 12), ('john', 'A', 15)] diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/howto/unicode.rst --- a/Doc/howto/unicode.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/howto/unicode.rst Sun Jul 20 10:52:46 2014 -0400 @@ -6,8 +6,8 @@ This HOWTO discusses Python 2.x's support for Unicode, and explains various problems that people commonly encounter when trying to work -with Unicode. For the Python 3 version, see -. +with Unicode. (This HOWTO has not yet been updated to cover the 3.x +versions of Python.) Introduction to Unicode ======================= @@ -49,7 +49,7 @@ 255 characters aren't very many. For example, you can't fit both the accented characters used in Western Europe and the Cyrillic alphabet used for Russian -into the 128-255 range because there are more than 128 such characters. +into the 128-255 range because there are more than 127 such characters. You could write files using different codes (all your Russian files in a coding system called KOI8, all your French files in a different coding system called @@ -253,11 +253,11 @@ >>> s = unicode('abcdef') >>> type(s) - >>> unicode('abcdef' + chr(255)) #doctest: +NORMALIZE_WHITESPACE + >>> unicode('abcdef' + chr(255)) Traceback (most recent call last): - ... + File "", line 1, in ? UnicodeDecodeError: 'ascii' codec can't decode byte 0xff in position 6: - ordinal not in range(128) + ordinal not in range(128) The ``errors`` argument specifies the response when the input string can't be converted according to the encoding's rules. Legal values for this argument are @@ -265,11 +265,11 @@ 'REPLACEMENT CHARACTER'), or 'ignore' (just leave the character out of the Unicode result). The following examples show the differences:: - >>> unicode('\x80abc', errors='strict') #doctest: +NORMALIZE_WHITESPACE + >>> unicode('\x80abc', errors='strict') Traceback (most recent call last): - ... + File "", line 1, in ? UnicodeDecodeError: 'ascii' codec can't decode byte 0x80 in position 0: - ordinal not in range(128) + ordinal not in range(128) >>> unicode('\x80abc', errors='replace') u'\ufffdabc' >>> unicode('\x80abc', errors='ignore') @@ -312,11 +312,10 @@ operation; Python's default ASCII encoding will be used, so characters greater than 127 will cause an exception:: - >>> s.find('Was\x9f') #doctest: +NORMALIZE_WHITESPACE + >>> s.find('Was\x9f') Traceback (most recent call last): - ... - UnicodeDecodeError: 'ascii' codec can't decode byte 0x9f in position 3: - ordinal not in range(128) + File "", line 1, in ? + UnicodeDecodeError: 'ascii' codec can't decode byte 0x9f in position 3: ordinal not in range(128) >>> s.find(u'Was\x9f') -1 @@ -334,11 +333,10 @@ >>> u = unichr(40960) + u'abcd' + unichr(1972) >>> u.encode('utf-8') '\xea\x80\x80abcd\xde\xb4' - >>> u.encode('ascii') #doctest: +NORMALIZE_WHITESPACE + >>> u.encode('ascii') Traceback (most recent call last): - ... - UnicodeEncodeError: 'ascii' codec can't encode character u'\ua000' in - position 0: ordinal not in range(128) + File "", line 1, in ? + UnicodeEncodeError: 'ascii' codec can't encode character '\ua000' in position 0: ordinal not in range(128) >>> u.encode('ascii', 'ignore') 'abcd' >>> u.encode('ascii', 'replace') @@ -386,9 +384,9 @@ :: >>> s = u"a\xac\u1234\u20ac\U00008000" - ... # ^^^^ two-digit hex escape - ... # ^^^^^^ four-digit Unicode escape - ... # ^^^^^^^^^^ eight-digit Unicode escape + ^^^^ two-digit hex escape + ^^^^^^ four-digit Unicode escape + ^^^^^^^^^^ eight-digit Unicode escape >>> for c in s: print ord(c), ... 97 172 4660 8364 32768 diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/howto/urllib2.rst --- a/Doc/howto/urllib2.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/howto/urllib2.rst Sun Jul 20 10:52:46 2014 -0400 @@ -18,7 +18,7 @@ .. sidebar:: Related Articles You may also find useful the following article on fetching web resources - with Python: + with Python : * `Basic Authentication `_ @@ -134,7 +134,7 @@ >>> data['location'] = 'Northampton' >>> data['language'] = 'Python' >>> url_values = urllib.urlencode(data) - >>> print url_values # The order may differ. #doctest: +SKIP + >>> print url_values name=Somebody+Here&language=Python&location=Northampton >>> url = 'http://www.example.com/example.cgi' >>> full_url = url + '?' + url_values @@ -150,7 +150,7 @@ to your HTTP request. Some websites [#]_ dislike being browsed by programs, or send different versions -to different browsers [#]_. By default urllib2 identifies itself as +to different browsers [#]_ . By default urllib2 identifies itself as ``Python-urllib/x.y`` (where ``x`` and ``y`` are the major and minor version numbers of the Python release, e.g. ``Python-urllib/2.5``), which may confuse the site, or just plain @@ -201,9 +201,9 @@ >>> req = urllib2.Request('http://www.pretend_server.org') >>> try: urllib2.urlopen(req) - ... except URLError as e: - ... print e.reason #doctest: +SKIP - ... + >>> except URLError, e: + >>> print e.reason + >>> (4, 'getaddrinfo failed') @@ -309,18 +309,18 @@ >>> req = urllib2.Request('http://www.python.org/fish.html') >>> try: - ... urllib2.urlopen(req) - ... except urllib2.HTTPError as e: - ... print e.code - ... print e.read() #doctest: +ELLIPSIS, +NORMALIZE_WHITESPACE - ... + >>> urllib2.urlopen(req) + >>> except HTTPError, e: + >>> print e.code + >>> print e.read() + >>> 404 - - ... - Page Not Found - ... - + + + Error 404: File Not Found + ...... etc... Wrapping it Up -------------- @@ -338,10 +338,10 @@ req = Request(someurl) try: response = urlopen(req) - except HTTPError as e: + except HTTPError, e: print 'The server couldn\'t fulfill the request.' print 'Error code: ', e.code - except URLError as e: + except URLError, e: print 'We failed to reach a server.' print 'Reason: ', e.reason else: @@ -362,7 +362,7 @@ req = Request(someurl) try: response = urlopen(req) - except URLError as e: + except URLError, e: if hasattr(e, 'reason'): print 'We failed to reach a server.' print 'Reason: ', e.reason @@ -439,12 +439,12 @@ When authentication is required, the server sends a header (as well as the 401 error code) requesting authentication. This specifies the authentication scheme -and a 'realm'. The header looks like: ``WWW-Authenticate: SCHEME +and a 'realm'. The header looks like : ``Www-authenticate: SCHEME realm="REALM"``. e.g. :: - WWW-Authenticate: Basic realm="cPanel Users" + Www-authenticate: Basic realm="cPanel Users" The client should then retry the request with the appropriate name and password @@ -489,8 +489,7 @@ In the above example we only supplied our ``HTTPBasicAuthHandler`` to ``build_opener``. By default openers have the handlers for normal situations - -- ``ProxyHandler`` (if a proxy setting such as an :envvar:`http_proxy` - environment variable is set), ``UnknownHandler``, ``HTTPHandler``, + -- ``ProxyHandler``, ``UnknownHandler``, ``HTTPHandler``, ``HTTPDefaultErrorHandler``, ``HTTPRedirectHandler``, ``FTPHandler``, ``FileHandler``, ``HTTPErrorProcessor``. @@ -507,11 +506,10 @@ ======= **urllib2** will auto-detect your proxy settings and use those. This is through -the ``ProxyHandler``, which is part of the normal handler chain when a proxy -setting is detected. Normally that's a good thing, but there are occasions -when it may not be helpful [#]_. One way to do this is to setup our own -``ProxyHandler``, with no proxies defined. This is done using similar steps to -setting up a `Basic Authentication`_ handler: :: +the ``ProxyHandler`` which is part of the normal handler chain. Normally that's +a good thing, but there are occasions when it may not be helpful [#]_. One way +to do this is to setup our own ``ProxyHandler``, with no proxies defined. This +is done using similar steps to setting up a `Basic Authentication`_ handler : :: >>> proxy_support = urllib2.ProxyHandler({}) >>> opener = urllib2.build_opener(proxy_support) diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/howto/webservers.rst --- a/Doc/howto/webservers.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/howto/webservers.rst Sun Jul 20 10:52:46 2014 -0400 @@ -274,7 +274,7 @@ Each web server requires a specific module. * Apache has both `mod_fastcgi `_ and `mod_fcgid - `_. ``mod_fastcgi`` is the original one, but it + `_. ``mod_fastcgi`` is the original one, but it has some licensing issues, which is why it is sometimes considered non-free. ``mod_fcgid`` is a smaller, compatible alternative. One of these modules needs to be loaded by Apache. @@ -364,7 +364,7 @@ A really great WSGI feature is middleware. Middleware is a layer around your program which can add various functionality to it. There is quite a bit of -`middleware `_ already +`middleware `_ already available. For example, instead of writing your own session management (HTTP is a stateless protocol, so to associate multiple HTTP requests with a single user your application must create and manage such state via a session), you can @@ -395,9 +395,9 @@ .. seealso:: - A good overview of WSGI-related code can be found in the `WSGI homepage - `_, which contains an extensive list of `WSGI servers - `_ which can be used by *any* application + A good overview of WSGI-related code can be found in the `WSGI wiki + `_, which contains an extensive list of `WSGI servers + `_ which can be used by *any* application supporting WSGI. You might be interested in some WSGI-supporting modules already contained in @@ -691,7 +691,7 @@ The newest version of TurboGears, version 2.0, moves even further in direction of WSGI support and a component-based architecture. TurboGears 2 is based on the WSGI stack of another popular component-based web framework, `Pylons -`_. +`_. Zope diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/includes/email-unpack.py --- a/Doc/includes/email-unpack.py Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/includes/email-unpack.py Sun Jul 20 10:52:46 2014 -0400 @@ -35,7 +35,7 @@ try: os.mkdir(opts.directory) - except OSError as e: + except OSError, e: # Ignore directory exists error if e.errno != errno.EEXIST: raise diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/includes/sqlite3/complete_statement.py --- a/Doc/includes/sqlite3/complete_statement.py Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/includes/sqlite3/complete_statement.py Sun Jul 20 10:52:46 2014 -0400 @@ -23,7 +23,7 @@ if buffer.lstrip().upper().startswith("SELECT"): print cur.fetchall() - except sqlite3.Error as e: + except sqlite3.Error, e: print "An error occurred:", e.args[0] buffer = "" diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/includes/sqlite3/execute_1.py --- a/Doc/includes/sqlite3/execute_1.py Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/includes/sqlite3/execute_1.py Sun Jul 20 10:52:46 2014 -0400 @@ -1,16 +1,11 @@ import sqlite3 -con = sqlite3.connect(":memory:") +con = sqlite3.connect("mydb") + cur = con.cursor() -cur.execute("create table people (name_last, age)") who = "Yeltsin" age = 72 -# This is the qmark style: -cur.execute("insert into people values (?, ?)", (who, age)) - -# And this is the named style: -cur.execute("select * from people where name_last=:who and age=:age", {"who": who, "age": age}) - +cur.execute("select name_last, age from people where name_last=? and age=?", (who, age)) print cur.fetchone() diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/includes/sqlite3/execute_2.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Doc/includes/sqlite3/execute_2.py Sun Jul 20 10:52:46 2014 -0400 @@ -0,0 +1,12 @@ +import sqlite3 + +con = sqlite3.connect("mydb") + +cur = con.cursor() + +who = "Yeltsin" +age = 72 + +cur.execute("select name_last, age from people where name_last=:who and age=:age", + {"who": who, "age": age}) +print cur.fetchone() diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/includes/sqlite3/executemany_2.py --- a/Doc/includes/sqlite3/executemany_2.py Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/includes/sqlite3/executemany_2.py Sun Jul 20 10:52:46 2014 -0400 @@ -1,8 +1,8 @@ import sqlite3 -import string def char_generator(): - for c in string.lowercase: + import string + for c in string.letters[:26]: yield (c,) con = sqlite3.connect(":memory:") diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/includes/sqlite3/rowclass.py --- a/Doc/includes/sqlite3/rowclass.py Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/includes/sqlite3/rowclass.py Sun Jul 20 10:52:46 2014 -0400 @@ -1,12 +1,12 @@ import sqlite3 -con = sqlite3.connect(":memory:") +con = sqlite3.connect("mydb") con.row_factory = sqlite3.Row cur = con.cursor() -cur.execute("select 'John' as name, 42 as age") +cur.execute("select name_last, age from people") for row in cur: - assert row[0] == row["name"] - assert row["name"] == row["nAmE"] + assert row[0] == row["name_last"] + assert row["name_last"] == row["nAmE_lAsT"] assert row[1] == row["age"] assert row[1] == row["AgE"] diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/includes/sqlite3/shortcut_methods.py --- a/Doc/includes/sqlite3/shortcut_methods.py Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/includes/sqlite3/shortcut_methods.py Sun Jul 20 10:52:46 2014 -0400 @@ -17,4 +17,5 @@ for row in con.execute("select firstname, lastname from person"): print row -print "I just deleted", con.execute("delete from person").rowcount, "rows" +# Using a dummy WHERE clause to not let SQLite take the shortcut table deletes. +print "I just deleted", con.execute("delete from person where 1=1").rowcount, "rows" diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/includes/sqlite3/text_factory.py --- a/Doc/includes/sqlite3/text_factory.py Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/includes/sqlite3/text_factory.py Sun Jul 20 10:52:46 2014 -0400 @@ -3,6 +3,9 @@ con = sqlite3.connect(":memory:") cur = con.cursor() +# Create the table +con.execute("create table person(lastname, firstname)") + AUSTRIA = u"\xd6sterreich" # by default, rows are returned as Unicode @@ -14,7 +17,7 @@ con.text_factory = str cur.execute("select ?", (AUSTRIA,)) row = cur.fetchone() -assert type(row[0]) is str +assert type(row[0]) == str # the bytestrings will be encoded in UTF-8, unless you stored garbage in the # database ... assert row[0] == AUSTRIA.encode("utf-8") @@ -26,15 +29,15 @@ cur.execute("select ?", ("this is latin1 and would normally create errors" + u"\xe4\xf6\xfc".encode("latin1"),)) row = cur.fetchone() -assert type(row[0]) is unicode +assert type(row[0]) == unicode # sqlite3 offers a built-in optimized text_factory that will return bytestring # objects, if the data is in ASCII only, and otherwise return unicode objects con.text_factory = sqlite3.OptimizedUnicode cur.execute("select ?", (AUSTRIA,)) row = cur.fetchone() -assert type(row[0]) is unicode +assert type(row[0]) == unicode cur.execute("select ?", ("Germany",)) row = cur.fetchone() -assert type(row[0]) is str +assert type(row[0]) == str diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/install/index.rst --- a/Doc/install/index.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/install/index.rst Sun Jul 20 10:52:46 2014 -0400 @@ -7,6 +7,8 @@ ***************************** :Author: Greg Ward +:Release: |version| +:Date: |today| .. TODO: Fill in XXX comments @@ -20,20 +22,12 @@ Finally, it might be useful to include all the material from my "Care and Feeding of a Python Installation" talk in here somewhere. Yow! -This document describes the Python Distribution Utilities ("Distutils") from the -end-user's point-of-view, describing how to extend the capabilities of a -standard Python installation by building and installing third-party Python -modules and extensions. +.. topic:: Abstract - -.. note:: - - This guide only covers the basic tools for installing extensions that are - provided as part of this version of Python. Third party tools offer easier - to use and more secure alternatives. Refer to the - `quick recommendations section - `__ - in the Python Packaging User Guide for more information. + This document describes the Python Distribution Utilities ("Distutils") from the + end-user's point-of-view, describing how to extend the capabilities of a + standard Python installation by building and installing third-party Python + modules and extensions. .. _inst-intro: @@ -58,9 +52,7 @@ document; there will be some brief forays into using Python's interactive mode to explore your installation, but that's it. If you're looking for information on how to distribute your own Python modules so that others may use them, see -the :ref:`distutils-index` manual. :ref:`debug-setup-script` may also be of -interest. - +the :ref:`distutils-index` manual. .. _inst-trivial-install: @@ -199,7 +191,7 @@ to keep the source tree pristine, you can change the build directory with the :option:`--build-base` option. For example:: - python setup.py build --build-base=/path/to/pybuild/foo-1.0 + python setup.py build --build-base=/tmp/pybuild/foo-1.0 (Or you could do this permanently with a directive in your system or personal Distutils configuration file; see section :ref:`inst-config-files`.) Normally, this @@ -245,8 +237,6 @@ Unix-based), it also depends on whether the module distribution being installed is pure Python or contains extensions ("non-pure"): -.. tabularcolumns:: |l|l|l|l| - +-----------------+-----------------------------------------------------+--------------------------------------------------+-------+ | Platform | Standard installation location | Default value | Notes | +=================+=====================================================+==================================================+=======+ @@ -1052,7 +1042,7 @@ for Borland's C++, because there is no program to convert the library. First you have to create a list of symbols which the Python DLL exports. (You can find a good program for this task at -http://sourceforge.net/projects/mingw/files/MinGW/Extension/pexports/). +http://www.emmestech.com/software/pexports-0.43/download_pexports.html). .. I don't understand what the next line means. --amk .. (inclusive the references on data structures.) diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/library/2to3.rst --- a/Doc/library/2to3.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/library/2to3.rst Sun Jul 20 10:52:46 2014 -0400 @@ -23,7 +23,7 @@ also located in the :file:`Tools/scripts` directory of the Python root. 2to3's basic arguments are a list of files or directories to transform. The -directories are recursively traversed for Python sources. +directories are to recursively traversed for Python sources. Here is a sample Python 2.x source file, :file:`example.py`:: @@ -94,38 +94,6 @@ :option:`-p` to run fixers on code that already has had its print statements converted. -The :option:`-o` or :option:`--output-dir` option allows specification of an -alternate directory for processed output files to be written to. The -:option:`-n` flag is required when using this as backup files do not make sense -when not overwriting the input files. - -.. versionadded:: 2.7.3 - The :option:`-o` option was added. - -The :option:`-W` or :option:`--write-unchanged-files` flag tells 2to3 to always -write output files even if no changes were required to the file. This is most -useful with :option:`-o` so that an entire Python source tree is copied with -translation from one directory to another. -This option implies the :option:`-w` flag as it would not make sense otherwise. - -.. versionadded:: 2.7.3 - The :option:`-W` flag was added. - -The :option:`--add-suffix` option specifies a string to append to all output -filenames. The :option:`-n` flag is required when specifying this as backups -are not necessary when writing to different filenames. Example:: - - $ 2to3 -n -W --add-suffix=3 example.py - -Will cause a converted file named ``example.py3`` to be written. - -.. versionadded:: 2.7.3 - The :option:`--add-suffix` option was added. - -To translate an entire project from one directory tree to another use:: - - $ 2to3 --output-dir=python3-version/mycode -W -n python2-version/mycode - .. _2to3-fixers: @@ -264,7 +232,8 @@ .. 2to3fixer:: long - Renames :class:`long` to :class:`int`. + Strips the ``L`` suffix on long literals and renames :class:`long` to + :class:`int`. .. 2to3fixer:: map @@ -290,11 +259,11 @@ Converts the use of iterator's :meth:`~iterator.next` methods to the :func:`next` function. It also renames :meth:`next` methods to - :meth:`~iterator.__next__`. + :meth:`~object.__next__`. .. 2to3fixer:: nonzero - Renames :meth:`__nonzero__` to :meth:`~object.__bool__`. + Renames :meth:`~object.__nonzero__` to :meth:`~object.__bool__`. .. 2to3fixer:: numliterals @@ -313,7 +282,7 @@ Converts ``raise E, V`` to ``raise E(V)``, and ``raise E, V, T`` to ``raise E(V).with_traceback(T)``. If ``E`` is a tuple, the translation will be - incorrect because substituting tuples for exceptions has been removed in Python 3. + incorrect because substituting tuples for exceptions has been removed in 3.0. .. 2to3fixer:: raw_input @@ -336,7 +305,7 @@ Replaces use of the :class:`set` constructor with set literals. This fixer is optional. -.. 2to3fixer:: standarderror +.. 2to3fixer:: standard_error Renames :exc:`StandardError` to :exc:`Exception`. diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/library/__future__.rst --- a/Doc/library/__future__.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/library/__future__.rst Sun Jul 20 10:52:46 2014 -0400 @@ -75,7 +75,7 @@ | division | 2.2.0a2 | 3.0 | :pep:`238`: | | | | | *Changing the Division Operator* | +------------------+-------------+--------------+---------------------------------------------+ -| absolute_import | 2.5.0a1 | 3.0 | :pep:`328`: | +| absolute_import | 2.5.0a1 | 2.7 | :pep:`328`: | | | | | *Imports: Multi-Line and Absolute/Relative* | +------------------+-------------+--------------+---------------------------------------------+ | with_statement | 2.5.0a1 | 2.6 | :pep:`343`: | diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/library/_winreg.rst --- a/Doc/library/_winreg.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/library/_winreg.rst Sun Jul 20 10:52:46 2014 -0400 @@ -7,9 +7,9 @@ .. sectionauthor:: Mark Hammond .. note:: - The :mod:`_winreg` module has been renamed to :mod:`winreg` in Python 3. + The :mod:`_winreg` module has been renamed to :mod:`winreg` in Python 3.0. The :term:`2to3` tool will automatically adapt imports when converting your - sources to Python 3. + sources to 3.0. .. versionadded:: 2.0 diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/library/abc.rst --- a/Doc/library/abc.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/library/abc.rst Sun Jul 20 10:52:46 2014 -0400 @@ -110,19 +110,19 @@ MyIterable.register(Foo) The ABC ``MyIterable`` defines the standard iterable method, - :meth:`~iterator.__iter__`, as an abstract method. The implementation given - here can still be called from subclasses. The :meth:`get_iterator` method - is also part of the ``MyIterable`` abstract base class, but it does not have - to be overridden in non-abstract derived classes. + :meth:`__iter__`, as an abstract method. The implementation given here can + still be called from subclasses. The :meth:`get_iterator` method is also + part of the ``MyIterable`` abstract base class, but it does not have to be + overridden in non-abstract derived classes. The :meth:`__subclasshook__` class method defined here says that any class - that has an :meth:`~iterator.__iter__` method in its - :attr:`~object.__dict__` (or in that of one of its base classes, accessed - via the :attr:`~class.__mro__` list) is considered a ``MyIterable`` too. + that has an :meth:`__iter__` method in its :attr:`__dict__` (or in that of + one of its base classes, accessed via the :attr:`__mro__` list) is + considered a ``MyIterable`` too. Finally, the last line makes ``Foo`` a virtual subclass of ``MyIterable``, - even though it does not define an :meth:`~iterator.__iter__` method (it uses - the old-style iterable protocol, defined in terms of :meth:`__len__` and + even though it does not define an :meth:`__iter__` method (it uses the + old-style iterable protocol, defined in terms of :meth:`__len__` and :meth:`__getitem__`). Note that this will not make ``get_iterator`` available as a method of ``Foo``, so it is provided separately. diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/library/aifc.rst --- a/Doc/library/aifc.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/library/aifc.rst Sun Jul 20 10:52:46 2014 -0400 @@ -30,8 +30,8 @@ sampled. The number of channels indicate if the audio is mono, stereo, or quadro. Each frame consists of one sample per channel. The sample size is the size in bytes of each sample. Thus a frame consists of -*nchannels*\*\ *samplesize* bytes, and a second's worth of audio consists of -*nchannels*\*\ *samplesize*\*\ *framerate* bytes. +*nchannels*\**samplesize* bytes, and a second's worth of audio consists of +*nchannels*\**samplesize*\**framerate* bytes. For example, CD quality audio has a sample size of two bytes (16 bits), uses two channels (stereo) and has a frame rate of 44,100 frames/second. This gives a diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/library/al.rst --- a/Doc/library/al.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/library/al.rst Sun Jul 20 10:52:46 2014 -0400 @@ -8,7 +8,7 @@ :deprecated: .. deprecated:: 2.6 - The :mod:`al` module has been removed in Python 3. + The :mod:`al` module has been deprecated for removal in Python 3.0. This module provides access to the audio facilities of the SGI Indy and Indigo @@ -53,7 +53,7 @@ .. function:: queryparams(device) The device argument is an integer. The return value is a list of integers - containing the data returned by :c:func:`ALqueryparams`. + containing the data returned by :cfunc:`ALqueryparams`. .. function:: getparams(device, list) @@ -201,7 +201,7 @@ :deprecated: .. deprecated:: 2.6 - The :mod:`AL` module has been removed in Python 3. + The :mod:`AL` module has been deprecated for removal in Python 3.0. This module defines symbolic constants needed to use the built-in module diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/library/anydbm.rst --- a/Doc/library/anydbm.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/library/anydbm.rst Sun Jul 20 10:52:46 2014 -0400 @@ -6,9 +6,9 @@ .. note:: - The :mod:`anydbm` module has been renamed to :mod:`dbm` in Python 3. The + The :mod:`anydbm` module has been renamed to :mod:`dbm` in Python 3.0. The :term:`2to3` tool will automatically adapt imports when converting your - sources to Python 3. + sources to 3.0. .. index:: module: dbhash @@ -92,14 +92,6 @@ db.close() -In addition to the dictionary-like methods, ``anydbm`` objects -provide the following method: - -.. function:: close() - - Close the ``anydbm`` database. - - .. seealso:: Module :mod:`dbhash` diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/library/archiving.rst --- a/Doc/library/archiving.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/library/archiving.rst Sun Jul 20 10:52:46 2014 -0400 @@ -7,7 +7,6 @@ The modules described in this chapter support data compression with the zlib, gzip, and bzip2 algorithms, and the creation of ZIP- and tar-format archives. -See also :ref:`archiving-operations` provided by the :mod:`shutil` module. .. toctree:: diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/library/argparse.rst --- a/Doc/library/argparse.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/library/argparse.rst Sun Jul 20 10:52:46 2014 -0400 @@ -12,12 +12,6 @@ -------------- -.. sidebar:: Tutorial - - This page contains the API reference information. For a more gentle - introduction to Python command-line parsing, have a look at the - :ref:`argparse tutorial `. - The :mod:`argparse` module makes it easy to write user-friendly command-line interfaces. The program defines what arguments it requires, and :mod:`argparse` will figure out how to parse those out of :data:`sys.argv`. The :mod:`argparse` @@ -46,7 +40,7 @@ Assuming the Python code above is saved into a file called ``prog.py``, it can be run at the command line and provides useful help messages:: - $ python prog.py -h + $ prog.py -h usage: prog.py [-h] [--sum] N [N ...] Process some integers. @@ -61,15 +55,15 @@ When run with the appropriate arguments, it prints either the sum or the max of the command-line integers:: - $ python prog.py 1 2 3 4 + $ prog.py 1 2 3 4 4 - $ python prog.py 1 2 3 4 --sum + $ prog.py 1 2 3 4 --sum 10 If invalid arguments are passed in, it will issue an error:: - $ python prog.py a b c + $ prog.py a b c usage: prog.py [-h] [--sum] N [N ...] prog.py: error: argument N: invalid int value: 'a' @@ -130,143 +124,42 @@ ArgumentParser objects ---------------------- -.. class:: ArgumentParser(prog=None, usage=None, description=None, \ - epilog=None, parents=[], \ - formatter_class=argparse.HelpFormatter, \ - prefix_chars='-', fromfile_prefix_chars=None, \ - argument_default=None, conflict_handler='error', \ - add_help=True) +.. class:: ArgumentParser([description], [epilog], [prog], [usage], [add_help], [argument_default], [parents], [prefix_chars], [conflict_handler], [formatter_class]) - Create a new :class:`ArgumentParser` object. All parameters should be passed - as keyword arguments. Each parameter has its own more detailed description - below, but in short they are: + Create a new :class:`ArgumentParser` object. Each parameter has its own more + detailed description below, but in short they are: - * prog_ - The name of the program (default: ``sys.argv[0]``) + * description_ - Text to display before the argument help. - * usage_ - The string describing the program usage (default: generated from - arguments added to parser) + * epilog_ - Text to display after the argument help. - * description_ - Text to display before the argument help (default: none) + * add_help_ - Add a -h/--help option to the parser. (default: ``True``) - * epilog_ - Text to display after the argument help (default: none) + * argument_default_ - Set the global default value for arguments. + (default: ``None``) * parents_ - A list of :class:`ArgumentParser` objects whose arguments should - also be included + also be included. - * formatter_class_ - A class for customizing the help output - - * prefix_chars_ - The set of characters that prefix optional arguments + * prefix_chars_ - The set of characters that prefix optional arguments. (default: '-') * fromfile_prefix_chars_ - The set of characters that prefix files from - which additional arguments should be read (default: ``None``) + which additional arguments should be read. (default: ``None``) - * argument_default_ - The global default value for arguments - (default: ``None``) + * formatter_class_ - A class for customizing the help output. - * conflict_handler_ - The strategy for resolving conflicting optionals - (usually unnecessary) + * conflict_handler_ - Usually unnecessary, defines strategy for resolving + conflicting optionals. - * add_help_ - Add a -h/--help option to the parser (default: ``True``) + * prog_ - The name of the program (default: + ``sys.argv[0]``) + + * usage_ - The string describing the program usage (default: generated) The following sections describe how each of these are used. -prog -^^^^ - -By default, :class:`ArgumentParser` objects uses ``sys.argv[0]`` to determine -how to display the name of the program in help messages. This default is almost -always desirable because it will make the help messages match how the program was -invoked on the command line. For example, consider a file named -``myprogram.py`` with the following code:: - - import argparse - parser = argparse.ArgumentParser() - parser.add_argument('--foo', help='foo help') - args = parser.parse_args() - -The help for this program will display ``myprogram.py`` as the program name -(regardless of where the program was invoked from):: - - $ python myprogram.py --help - usage: myprogram.py [-h] [--foo FOO] - - optional arguments: - -h, --help show this help message and exit - --foo FOO foo help - $ cd .. - $ python subdir\myprogram.py --help - usage: myprogram.py [-h] [--foo FOO] - - optional arguments: - -h, --help show this help message and exit - --foo FOO foo help - -To change this default behavior, another value can be supplied using the -``prog=`` argument to :class:`ArgumentParser`:: - - >>> parser = argparse.ArgumentParser(prog='myprogram') - >>> parser.print_help() - usage: myprogram [-h] - - optional arguments: - -h, --help show this help message and exit - -Note that the program name, whether determined from ``sys.argv[0]`` or from the -``prog=`` argument, is available to help messages using the ``%(prog)s`` format -specifier. - -:: - - >>> parser = argparse.ArgumentParser(prog='myprogram') - >>> parser.add_argument('--foo', help='foo of the %(prog)s program') - >>> parser.print_help() - usage: myprogram [-h] [--foo FOO] - - optional arguments: - -h, --help show this help message and exit - --foo FOO foo of the myprogram program - - -usage -^^^^^ - -By default, :class:`ArgumentParser` calculates the usage message from the -arguments it contains:: - - >>> parser = argparse.ArgumentParser(prog='PROG') - >>> parser.add_argument('--foo', nargs='?', help='foo help') - >>> parser.add_argument('bar', nargs='+', help='bar help') - >>> parser.print_help() - usage: PROG [-h] [--foo [FOO]] bar [bar ...] - - positional arguments: - bar bar help - - optional arguments: - -h, --help show this help message and exit - --foo [FOO] foo help - -The default message can be overridden with the ``usage=`` keyword argument:: - - >>> parser = argparse.ArgumentParser(prog='PROG', usage='%(prog)s [options]') - >>> parser.add_argument('--foo', nargs='?', help='foo help') - >>> parser.add_argument('bar', nargs='+', help='bar help') - >>> parser.print_help() - usage: PROG [options] - - positional arguments: - bar bar help - - optional arguments: - -h, --help show this help message and exit - --foo [FOO] foo help - -The ``%(prog)s`` format specifier is available to fill in the program name in -your usage messages. - - description ^^^^^^^^^^^ @@ -314,6 +207,122 @@ argument to :class:`ArgumentParser`. +add_help +^^^^^^^^ + +By default, ArgumentParser objects add an option which simply displays +the parser's help message. For example, consider a file named +``myprogram.py`` containing the following code:: + + import argparse + parser = argparse.ArgumentParser() + parser.add_argument('--foo', help='foo help') + args = parser.parse_args() + +If ``-h`` or ``--help`` is supplied at the command line, the ArgumentParser +help will be printed:: + + $ python myprogram.py --help + usage: myprogram.py [-h] [--foo FOO] + + optional arguments: + -h, --help show this help message and exit + --foo FOO foo help + +Occasionally, it may be useful to disable the addition of this help option. +This can be achieved by passing ``False`` as the ``add_help=`` argument to +:class:`ArgumentParser`:: + + >>> parser = argparse.ArgumentParser(prog='PROG', add_help=False) + >>> parser.add_argument('--foo', help='foo help') + >>> parser.print_help() + usage: PROG [--foo FOO] + + optional arguments: + --foo FOO foo help + +The help option is typically ``-h/--help``. The exception to this is +if the ``prefix_chars=`` is specified and does not include ``-``, in +which case ``-h`` and ``--help`` are not valid options. In +this case, the first character in ``prefix_chars`` is used to prefix +the help options:: + + >>> parser = argparse.ArgumentParser(prog='PROG', prefix_chars='+/') + >>> parser.print_help() + usage: PROG [+h] + + optional arguments: + +h, ++help show this help message and exit + + +prefix_chars +^^^^^^^^^^^^ + +Most command-line options will use ``-`` as the prefix, e.g. ``-f/--foo``. +Parsers that need to support different or additional prefix +characters, e.g. for options +like ``+f`` or ``/foo``, may specify them using the ``prefix_chars=`` argument +to the ArgumentParser constructor:: + + >>> parser = argparse.ArgumentParser(prog='PROG', prefix_chars='-+') + >>> parser.add_argument('+f') + >>> parser.add_argument('++bar') + >>> parser.parse_args('+f X ++bar Y'.split()) + Namespace(bar='Y', f='X') + +The ``prefix_chars=`` argument defaults to ``'-'``. Supplying a set of +characters that does not include ``-`` will cause ``-f/--foo`` options to be +disallowed. + + +fromfile_prefix_chars +^^^^^^^^^^^^^^^^^^^^^ + +Sometimes, for example when dealing with a particularly long argument lists, it +may make sense to keep the list of arguments in a file rather than typing it out +at the command line. If the ``fromfile_prefix_chars=`` argument is given to the +:class:`ArgumentParser` constructor, then arguments that start with any of the +specified characters will be treated as files, and will be replaced by the +arguments they contain. For example:: + + >>> with open('args.txt', 'w') as fp: + ... fp.write('-f\nbar') + >>> parser = argparse.ArgumentParser(fromfile_prefix_chars='@') + >>> parser.add_argument('-f') + >>> parser.parse_args(['-f', 'foo', '@args.txt']) + Namespace(f='bar') + +Arguments read from a file must by default be one per line (but see also +:meth:`~ArgumentParser.convert_arg_line_to_args`) and are treated as if they +were in the same place as the original file referencing argument on the command +line. So in the example above, the expression ``['-f', 'foo', '@args.txt']`` +is considered equivalent to the expression ``['-f', 'foo', '-f', 'bar']``. + +The ``fromfile_prefix_chars=`` argument defaults to ``None``, meaning that +arguments will never be treated as file references. + + +argument_default +^^^^^^^^^^^^^^^^ + +Generally, argument defaults are specified either by passing a default to +:meth:`~ArgumentParser.add_argument` or by calling the +:meth:`~ArgumentParser.set_defaults` methods with a specific set of name-value +pairs. Sometimes however, it may be useful to specify a single parser-wide +default for arguments. This can be accomplished by passing the +``argument_default=`` keyword argument to :class:`ArgumentParser`. For example, +to globally suppress attribute creation on :meth:`~ArgumentParser.parse_args` +calls, we supply ``argument_default=SUPPRESS``:: + + >>> parser = argparse.ArgumentParser(argument_default=argparse.SUPPRESS) + >>> parser.add_argument('--foo') + >>> parser.add_argument('bar', nargs='?') + >>> parser.parse_args(['--foo', '1', 'BAR']) + Namespace(bar='BAR', foo='1') + >>> parser.parse_args([]) + Namespace() + + parents ^^^^^^^ @@ -432,74 +441,6 @@ --foo FOO FOO! (default: 42) -prefix_chars -^^^^^^^^^^^^ - -Most command-line options will use ``-`` as the prefix, e.g. ``-f/--foo``. -Parsers that need to support different or additional prefix -characters, e.g. for options -like ``+f`` or ``/foo``, may specify them using the ``prefix_chars=`` argument -to the ArgumentParser constructor:: - - >>> parser = argparse.ArgumentParser(prog='PROG', prefix_chars='-+') - >>> parser.add_argument('+f') - >>> parser.add_argument('++bar') - >>> parser.parse_args('+f X ++bar Y'.split()) - Namespace(bar='Y', f='X') - -The ``prefix_chars=`` argument defaults to ``'-'``. Supplying a set of -characters that does not include ``-`` will cause ``-f/--foo`` options to be -disallowed. - - -fromfile_prefix_chars -^^^^^^^^^^^^^^^^^^^^^ - -Sometimes, for example when dealing with a particularly long argument lists, it -may make sense to keep the list of arguments in a file rather than typing it out -at the command line. If the ``fromfile_prefix_chars=`` argument is given to the -:class:`ArgumentParser` constructor, then arguments that start with any of the -specified characters will be treated as files, and will be replaced by the -arguments they contain. For example:: - - >>> with open('args.txt', 'w') as fp: - ... fp.write('-f\nbar') - >>> parser = argparse.ArgumentParser(fromfile_prefix_chars='@') - >>> parser.add_argument('-f') - >>> parser.parse_args(['-f', 'foo', '@args.txt']) - Namespace(f='bar') - -Arguments read from a file must by default be one per line (but see also -:meth:`~ArgumentParser.convert_arg_line_to_args`) and are treated as if they -were in the same place as the original file referencing argument on the command -line. So in the example above, the expression ``['-f', 'foo', '@args.txt']`` -is considered equivalent to the expression ``['-f', 'foo', '-f', 'bar']``. - -The ``fromfile_prefix_chars=`` argument defaults to ``None``, meaning that -arguments will never be treated as file references. - - -argument_default -^^^^^^^^^^^^^^^^ - -Generally, argument defaults are specified either by passing a default to -:meth:`~ArgumentParser.add_argument` or by calling the -:meth:`~ArgumentParser.set_defaults` methods with a specific set of name-value -pairs. Sometimes however, it may be useful to specify a single parser-wide -default for arguments. This can be accomplished by passing the -``argument_default=`` keyword argument to :class:`ArgumentParser`. For example, -to globally suppress attribute creation on :meth:`~ArgumentParser.parse_args` -calls, we supply ``argument_default=SUPPRESS``:: - - >>> parser = argparse.ArgumentParser(argument_default=argparse.SUPPRESS) - >>> parser.add_argument('--foo') - >>> parser.add_argument('bar', nargs='?') - >>> parser.parse_args(['--foo', '1', 'BAR']) - Namespace(bar='BAR', foo='1') - >>> parser.parse_args([]) - Namespace() - - conflict_handler ^^^^^^^^^^^^^^^^ @@ -537,20 +478,22 @@ string was overridden. -add_help -^^^^^^^^ +prog +^^^^ -By default, ArgumentParser objects add an option which simply displays -the parser's help message. For example, consider a file named -``myprogram.py`` containing the following code:: +By default, :class:`ArgumentParser` objects uses ``sys.argv[0]`` to determine +how to display the name of the program in help messages. This default is almost +always desirable because it will make the help messages match how the program was +invoked on the command line. For example, consider a file named +``myprogram.py`` with the following code:: import argparse parser = argparse.ArgumentParser() parser.add_argument('--foo', help='foo help') args = parser.parse_args() -If ``-h`` or ``--help`` is supplied at the command line, the ArgumentParser -help will be printed:: +The help for this program will display ``myprogram.py`` as the program name +(regardless of where the program was invoked from):: $ python myprogram.py --help usage: myprogram.py [-h] [--foo FOO] @@ -558,39 +501,82 @@ optional arguments: -h, --help show this help message and exit --foo FOO foo help - -Occasionally, it may be useful to disable the addition of this help option. -This can be achieved by passing ``False`` as the ``add_help=`` argument to -:class:`ArgumentParser`:: - - >>> parser = argparse.ArgumentParser(prog='PROG', add_help=False) - >>> parser.add_argument('--foo', help='foo help') - >>> parser.print_help() - usage: PROG [--foo FOO] + $ cd .. + $ python subdir\myprogram.py --help + usage: myprogram.py [-h] [--foo FOO] optional arguments: - --foo FOO foo help + -h, --help show this help message and exit + --foo FOO foo help -The help option is typically ``-h/--help``. The exception to this is -if the ``prefix_chars=`` is specified and does not include ``-``, in -which case ``-h`` and ``--help`` are not valid options. In -this case, the first character in ``prefix_chars`` is used to prefix -the help options:: +To change this default behavior, another value can be supplied using the +``prog=`` argument to :class:`ArgumentParser`:: - >>> parser = argparse.ArgumentParser(prog='PROG', prefix_chars='+/') + >>> parser = argparse.ArgumentParser(prog='myprogram') >>> parser.print_help() - usage: PROG [+h] + usage: myprogram [-h] optional arguments: - +h, ++help show this help message and exit + -h, --help show this help message and exit + +Note that the program name, whether determined from ``sys.argv[0]`` or from the +``prog=`` argument, is available to help messages using the ``%(prog)s`` format +specifier. + +:: + + >>> parser = argparse.ArgumentParser(prog='myprogram') + >>> parser.add_argument('--foo', help='foo of the %(prog)s program') + >>> parser.print_help() + usage: myprogram [-h] [--foo FOO] + + optional arguments: + -h, --help show this help message and exit + --foo FOO foo of the myprogram program + + +usage +^^^^^ + +By default, :class:`ArgumentParser` calculates the usage message from the +arguments it contains:: + + >>> parser = argparse.ArgumentParser(prog='PROG') + >>> parser.add_argument('--foo', nargs='?', help='foo help') + >>> parser.add_argument('bar', nargs='+', help='bar help') + >>> parser.print_help() + usage: PROG [-h] [--foo [FOO]] bar [bar ...] + + positional arguments: + bar bar help + + optional arguments: + -h, --help show this help message and exit + --foo [FOO] foo help + +The default message can be overridden with the ``usage=`` keyword argument:: + + >>> parser = argparse.ArgumentParser(prog='PROG', usage='%(prog)s [options]') + >>> parser.add_argument('--foo', nargs='?', help='foo help') + >>> parser.add_argument('bar', nargs='+', help='bar help') + >>> parser.print_help() + usage: PROG [options] + + positional arguments: + bar bar help + + optional arguments: + -h, --help show this help message and exit + --foo [FOO] foo help + +The ``%(prog)s`` format specifier is available to fill in the program name in +your usage messages. The add_argument() method ------------------------- -.. method:: ArgumentParser.add_argument(name or flags..., [action], [nargs], \ - [const], [default], [type], [choices], [required], \ - [help], [metavar], [dest]) +.. method:: ArgumentParser.add_argument(name or flags..., [action], [nargs], [const], [default], [type], [choices], [required], [help], [metavar], [dest]) Define how a single command-line argument should be parsed. Each parameter has its own more detailed description below, but in short they are: @@ -664,7 +650,7 @@ actions can do just about anything with the command-line arguments associated with them, though most actions simply add an attribute to the object returned by :meth:`~ArgumentParser.parse_args`. The ``action`` keyword argument specifies -how the command-line arguments should be handled. The supported actions are: +how the command-line arguments should be handled. The supplied actions are: * ``'store'`` - This just stores the argument's value. This is the default action. For example:: @@ -717,22 +703,9 @@ >>> parser.parse_args('--str --int'.split()) Namespace(types=[, ]) -* ``'count'`` - This counts the number of times a keyword argument occurs. For - example, this is useful for increasing verbosity levels:: - - >>> parser = argparse.ArgumentParser() - >>> parser.add_argument('--verbose', '-v', action='count') - >>> parser.parse_args('-vvv'.split()) - Namespace(verbose=3) - -* ``'help'`` - This prints a complete help message for all the options in the - current parser and then exits. By default a help action is automatically - added to the parser. See :class:`ArgumentParser` for details of how the - output is created. - * ``'version'`` - This expects a ``version=`` keyword argument in the :meth:`~ArgumentParser.add_argument` call, and prints version information - and exits when invoked:: + and exits when invoked. >>> import argparse >>> parser = argparse.ArgumentParser(prog='PROG') @@ -740,28 +713,18 @@ >>> parser.parse_args(['--version']) PROG 2.0 -You can also specify an arbitrary action by passing an object that implements -the Action API. The easiest way to do this is to extend -:class:`argparse.Action`, supplying an appropriate ``__call__`` method. The -``__call__`` method should accept four parameters: - -* ``parser`` - The ArgumentParser object which contains this action. - -* ``namespace`` - The :class:`Namespace` object that will be returned by - :meth:`~ArgumentParser.parse_args`. Most actions add an attribute to this - object. - -* ``values`` - The associated command-line arguments, with any type conversions - applied. (Type conversions are specified with the type_ keyword argument to - :meth:`~ArgumentParser.add_argument`.) - -* ``option_string`` - The option string that was used to invoke this action. - The ``option_string`` argument is optional, and will be absent if the action - is associated with a positional argument. +You may also specify an arbitrary action by passing an Action subclass or +other object that implements the same interface. The recommended way to do +this is to extend :class:`argparse.Action`, overriding the ``__call__`` method +and optionally the ``__init__`` method. An example of a custom action:: >>> class FooAction(argparse.Action): + ... def __init__(self, option_strings, dest, nargs=None, **kwargs): + ... if nargs is not None: + ... raise ValueError("nargs not allowed") + ... super(FooAction, self).__init__(option_strings, dest, **kwargs) ... def __call__(self, parser, namespace, values, option_string=None): ... print '%r %r %r' % (namespace, values, option_string) ... setattr(namespace, self.dest, values) @@ -775,6 +738,7 @@ >>> args Namespace(bar='1', foo='2') +For more details, see :class:`argparse.Action`. nargs ^^^^^ @@ -784,8 +748,8 @@ different number of command-line arguments with a single action. The supported values are: -* ``N`` (an integer). ``N`` arguments from the command line will be gathered - together into a list. For example:: +* ``N`` (an integer). ``N`` arguments from the command line will be gathered together into a + list. For example:: >>> parser = argparse.ArgumentParser() >>> parser.add_argument('--foo', nargs=2) @@ -852,17 +816,6 @@ usage: PROG [-h] foo [foo ...] PROG: error: too few arguments -* ``argparse.REMAINDER``. All the remaining command-line arguments are gathered - into a list. This is commonly useful for command line utilities that dispatch - to other command line utilities:: - - >>> parser = argparse.ArgumentParser(prog='PROG') - >>> parser.add_argument('--foo') - >>> parser.add_argument('command') - >>> parser.add_argument('args', nargs=argparse.REMAINDER) - >>> print parser.parse_args('--foo B cmd --arg1 XX ZZ'.split()) - Namespace(args=['--arg1', 'XX', 'ZZ'], command='cmd', foo='B') - If the ``nargs`` keyword argument is not provided, the number of arguments consumed is determined by the action_. Generally this means a single command-line argument will be consumed and a single item (not a list) will be produced. @@ -877,8 +830,7 @@ * When :meth:`~ArgumentParser.add_argument` is called with ``action='store_const'`` or ``action='append_const'``. These actions add the - ``const`` value to one of the attributes of the object returned by - :meth:`~ArgumentParser.parse_args`. See the action_ description for examples. + ``const`` value to one of the attributes of the object returned by :meth:`~ArgumentParser.parse_args`. See the action_ description for examples. * When :meth:`~ArgumentParser.add_argument` is called with option strings (like ``-f`` or ``--foo``) and ``nargs='?'``. This creates an optional @@ -907,17 +859,6 @@ >>> parser.parse_args(''.split()) Namespace(foo=42) -If the ``default`` value is a string, the parser parses the value as if it -were a command-line argument. In particular, the parser applies any type_ -conversion argument, if provided, before setting the attribute on the -:class:`Namespace` return value. Otherwise, the parser uses the value as is:: - - >>> parser = argparse.ArgumentParser() - >>> parser.add_argument('--length', default='10', type=int) - >>> parser.add_argument('--width', default=10.5, type=int) - >>> parser.parse_args() - Namespace(length=10, width=10.5) - For positional arguments with nargs_ equal to ``?`` or ``*``, the ``default`` value is used when no command-line argument was present:: @@ -956,9 +897,6 @@ >>> parser.parse_args('2 temp.txt'.split()) Namespace(bar=, foo=2) -See the section on the default_ keyword argument for information on when the -``type`` argument is applied to default arguments. - To ease the use of various types of files, the argparse module provides the factory FileType which takes the ``mode=`` and ``bufsize=`` arguments of the ``file`` object. For example, ``FileType('w')`` can be used to create a @@ -1006,33 +944,32 @@ ^^^^^^^ Some command-line arguments should be selected from a restricted set of values. -These can be handled by passing a container object as the *choices* keyword +These can be handled by passing a container object as the ``choices`` keyword argument to :meth:`~ArgumentParser.add_argument`. When the command line is -parsed, argument values will be checked, and an error message will be displayed -if the argument was not one of the acceptable values:: +parsed, argument values will be checked, and an error message will be displayed if +the argument was not one of the acceptable values:: - >>> parser = argparse.ArgumentParser(prog='game.py') - >>> parser.add_argument('move', choices=['rock', 'paper', 'scissors']) - >>> parser.parse_args(['rock']) - Namespace(move='rock') - >>> parser.parse_args(['fire']) - usage: game.py [-h] {rock,paper,scissors} - game.py: error: argument move: invalid choice: 'fire' (choose from 'rock', - 'paper', 'scissors') + >>> parser = argparse.ArgumentParser(prog='PROG') + >>> parser.add_argument('foo', choices='abc') + >>> parser.parse_args('c'.split()) + Namespace(foo='c') + >>> parser.parse_args('X'.split()) + usage: PROG [-h] {a,b,c} + PROG: error: argument foo: invalid choice: 'X' (choose from 'a', 'b', 'c') -Note that inclusion in the *choices* container is checked after any type_ -conversions have been performed, so the type of the objects in the *choices* +Note that inclusion in the ``choices`` container is checked after any type_ +conversions have been performed, so the type of the objects in the ``choices`` container should match the type_ specified:: - >>> parser = argparse.ArgumentParser(prog='doors.py') - >>> parser.add_argument('door', type=int, choices=range(1, 4)) - >>> print(parser.parse_args(['3'])) - Namespace(door=3) - >>> parser.parse_args(['4']) - usage: doors.py [-h] {1,2,3} - doors.py: error: argument door: invalid choice: 4 (choose from 1, 2, 3) + >>> parser = argparse.ArgumentParser(prog='PROG') + >>> parser.add_argument('foo', type=complex, choices=[1, 1j]) + >>> parser.parse_args('1j'.split()) + Namespace(foo=1j) + >>> parser.parse_args('-- -4'.split()) + usage: PROG [-h] {1,1j} + PROG: error: argument foo: invalid choice: (-4+0j) (choose from 1, 1j) -Any object that supports the ``in`` operator can be passed as the *choices* +Any object that supports the ``in`` operator can be passed as the ``choices`` value, so :class:`dict` objects, :class:`set` objects, custom containers, etc. are all supported. @@ -1103,22 +1040,11 @@ optional arguments: -h, --help show this help message and exit -:mod:`argparse` supports silencing the help entry for certain options, by -setting the ``help`` value to ``argparse.SUPPRESS``:: - - >>> parser = argparse.ArgumentParser(prog='frobble') - >>> parser.add_argument('--foo', help=argparse.SUPPRESS) - >>> parser.print_help() - usage: frobble [-h] - - optional arguments: - -h, --help show this help message and exit - metavar ^^^^^^^ -When :class:`ArgumentParser` generates help messages, it needs some way to refer +When :class:`ArgumentParser` generates help messages, it need some way to refer to each expected argument. By default, ArgumentParser objects use the dest_ value as the "name" of each object. By default, for positional argument actions, the dest_ value is used directly, and for optional argument actions, @@ -1218,6 +1144,49 @@ >>> parser.parse_args('--foo XXX'.split()) Namespace(bar='XXX') +Action classes +^^^^^^^^^^^^^^ + +Action classes implement the Action API, a callable which returns a callable +which processes arguments from the command-line. Any object which follows +this API may be passed as the ``action`` parameter to +:method:`add_argument`. + +.. class:: Action(option_strings, dest, nargs=None, const=None, default=None, + type=None, choices=None, required=False, help=None, + metavar=None) + +Action objects are used by an ArgumentParser to represent the information +needed to parse a single argument from one or more strings from the +command line. The Action class must accept the two positional arguments +plus any keyword arguments passed to :method:`ArgumentParser.add_argument` +except for the ``action`` itself. + +Instances of Action (or return value of any callable to the ``action`` +parameter) should have attributes "dest", "option_strings", "default", "type", +"required", "help", etc. defined. The easiest way to ensure these attributes +are defined is to call ``Action.__init__``. + +Action instances should be callable, so subclasses must override the +``__call__`` method, which should accept four parameters: + +* ``parser`` - The ArgumentParser object which contains this action. + +* ``namespace`` - The :class:`Namespace` object that will be returned by + :meth:`~ArgumentParser.parse_args`. Most actions add an attribute to this + object using :func:`setattr`. + +* ``values`` - The associated command-line arguments, with any type conversions + applied. Type conversions are specified with the type_ keyword argument to + :meth:`~ArgumentParser.add_argument`. + +* ``option_string`` - The option string that was used to invoke this action. + The ``option_string`` argument is optional, and will be absent if the action + is associated with a positional argument. + +The ``__call__`` method may perform arbitrary actions, but will typically set +attributes on the ``namespace`` based on ``dest`` and ``values``. + The parse_args() method ----------------------- @@ -1351,14 +1320,12 @@ >>> parser.parse_args(['--', '-f']) Namespace(foo='-f', one=None) -.. _prefix-matching: -Argument abbreviations (prefix matching) -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +Argument abbreviations +^^^^^^^^^^^^^^^^^^^^^^ The :meth:`~ArgumentParser.parse_args` method allows long options to be -abbreviated to a prefix, if the abbreviation is unambiguous (the prefix matches -a unique option):: +abbreviated if the abbreviation is unambiguous:: >>> parser = argparse.ArgumentParser(prog='PROG') >>> parser.add_argument('-bacon') @@ -1434,10 +1401,7 @@ Sub-commands ^^^^^^^^^^^^ -.. method:: ArgumentParser.add_subparsers([title], [description], [prog], \ - [parser_class], [action], \ - [option_string], [dest], [help], \ - [metavar]) +.. method:: ArgumentParser.add_subparsers() Many programs split up their functionality into a number of sub-commands, for example, the ``svn`` program can invoke sub-commands like ``svn @@ -1446,35 +1410,11 @@ different functions which require different kinds of command-line arguments. :class:`ArgumentParser` supports the creation of such sub-commands with the :meth:`add_subparsers` method. The :meth:`add_subparsers` method is normally - called with no arguments and returns a special action object. This object + called with no arguments and returns an special action object. This object has a single method, :meth:`~ArgumentParser.add_parser`, which takes a command name and any :class:`ArgumentParser` constructor arguments, and returns an :class:`ArgumentParser` object that can be modified as usual. - Description of parameters: - - * title - title for the sub-parser group in help output; by default - "subcommands" if description is provided, otherwise uses title for - positional arguments - - * description - description for the sub-parser group in help output, by - default None - - * prog - usage information that will be displayed with sub-command help, - by default the name of the program and any positional arguments before the - subparser argument - - * parser_class - class which will be used to create sub-parser instances, by - default the class of the current parser (e.g. ArgumentParser) - - * dest - name of the attribute under which sub-command name will be - stored; by default None and no value is stored - - * help - help for sub-parser group in help output, by default None - - * metavar - string presenting available sub-commands in help; by default it - is None and presents sub-commands in form {cmd1, cmd2, ..} - Some example usage:: >>> # create the top-level parser @@ -1516,8 +1456,8 @@ positional arguments: {a,b} sub-command help - a a help - b b help + a a help + b b help optional arguments: -h, --help show this help message and exit @@ -1598,7 +1538,7 @@ >>> args.func(args) ((XYZYX)) - This way, you can let :meth:`parse_args` do the job of calling the + This way, you can let :meth:`parse_args` does the job of calling the appropriate function after argument parsing is complete. Associating functions with actions like this is typically the easiest way to handle the different actions for each of your subparsers. However, if it is necessary @@ -1623,21 +1563,21 @@ The :class:`FileType` factory creates objects that can be passed to the type argument of :meth:`ArgumentParser.add_argument`. Arguments that have :class:`FileType` objects as their type will open command-line arguments as files - with the requested modes and buffer sizes:: + with the requested modes and buffer sizes: - >>> parser = argparse.ArgumentParser() - >>> parser.add_argument('--output', type=argparse.FileType('wb', 0)) - >>> parser.parse_args(['--output', 'out']) - Namespace(output=) + >>> parser = argparse.ArgumentParser() + >>> parser.add_argument('--output', type=argparse.FileType('wb', 0)) + >>> parser.parse_args(['--output', 'out']) + Namespace(output=) FileType objects understand the pseudo-argument ``'-'`` and automatically convert this into ``sys.stdin`` for readable :class:`FileType` objects and - ``sys.stdout`` for writable :class:`FileType` objects:: + ``sys.stdout`` for writable :class:`FileType` objects: - >>> parser = argparse.ArgumentParser() - >>> parser.add_argument('infile', type=argparse.FileType('r')) - >>> parser.parse_args(['-']) - Namespace(infile=', mode 'r' at 0x...>) + >>> parser = argparse.ArgumentParser() + >>> parser.add_argument('infile', type=argparse.FileType('r')) + >>> parser.parse_args(['-']) + Namespace(infile=', mode 'r' at 0x...>) Argument groups @@ -1688,14 +1628,14 @@ --bar BAR bar help - Note that any arguments not in your user-defined groups will end up back - in the usual "positional arguments" and "optional arguments" sections. + Note that any arguments not your user defined groups will end up back in the + usual "positional arguments" and "optional arguments" sections. Mutual exclusion ^^^^^^^^^^^^^^^^ -.. method:: ArgumentParser.add_mutually_exclusive_group(required=False) +.. method:: add_mutually_exclusive_group(required=False) Create a mutually exclusive group. :mod:`argparse` will make sure that only one of the arguments in the mutually exclusive group was present on the @@ -1824,12 +1764,6 @@ >>> parser.parse_known_args(['--foo', '--badger', 'BAR', 'spam']) (Namespace(bar='BAR', foo=True), ['--badger', 'spam']) -.. warning:: - :ref:`Prefix matching ` rules apply to - :meth:`parse_known_args`. The parser may consume an option even if it's just - a prefix of one of its known options, instead of leaving it in the remaining - arguments list. - Customizing file parsing ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -1886,10 +1820,9 @@ * Replace all :meth:`optparse.OptionParser.add_option` calls with :meth:`ArgumentParser.add_argument` calls. -* Replace ``(options, args) = parser.parse_args()`` with ``args = +* Replace ``options, args = parser.parse_args()`` with ``args = parser.parse_args()`` and add additional :meth:`ArgumentParser.add_argument` - calls for the positional arguments. Keep in mind that what was previously - called ``options``, now in :mod:`argparse` context is called ``args``. + calls for the positional arguments. * Replace callback actions and the ``callback_*`` keyword arguments with ``type`` or ``action`` arguments. diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/library/array.rst --- a/Doc/library/array.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/library/array.rst Sun Jul 20 10:52:46 2014 -0400 @@ -107,7 +107,7 @@ memory buffer in bytes can be computed as ``array.buffer_info()[1] * array.itemsize``. This is occasionally useful when working with low-level (and inherently unsafe) I/O interfaces that require memory addresses, such as certain - :c:func:`ioctl` operations. The returned numbers are valid as long as the array + :cfunc:`ioctl` operations. The returned numbers are valid as long as the array exists and no length-changing operations are applied to it. .. note:: @@ -268,7 +268,9 @@ Packing and unpacking of External Data Representation (XDR) data as used in some remote procedure call systems. - `The Numerical Python Documentation `_ + `The Numerical Python Manual `_ The Numeric Python extension (NumPy) defines another array type; see - http://www.numpy.org/ for further information about Numerical Python. + http://numpy.sourceforge.net/ for further information about Numerical Python. + (A PDF version of the NumPy manual is available at + http://numpy.sourceforge.net/numdoc/numdoc.pdf). diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/library/ast.rst --- a/Doc/library/ast.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/library/ast.rst Sun Jul 20 10:52:46 2014 -0400 @@ -131,10 +131,10 @@ .. function:: literal_eval(node_or_string) - Safely evaluate an expression node or a Unicode or *Latin-1* encoded string - containing a Python expression. The string or node provided may only consist - of the following Python literal structures: strings, numbers, tuples, lists, - dicts, booleans, and ``None``. + Safely evaluate an expression node or a string containing a Python + expression. The string or node provided may only consist of the following + Python literal structures: strings, numbers, tuples, lists, dicts, booleans, + and ``None``. This can be used for safely evaluating strings containing Python expressions from untrusted sources without the need to parse the values oneself. @@ -257,6 +257,6 @@ Return a formatted dump of the tree in *node*. This is mainly useful for debugging purposes. The returned string will show the names and the values for fields. This makes the code impossible to evaluate, so if evaluation is - wanted *annotate_fields* must be set to ``False``. Attributes such as line + wanted *annotate_fields* must be set to False. Attributes such as line numbers and column offsets are not dumped by default. If this is wanted, *include_attributes* can be set to ``True``. diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/library/asynchat.rst --- a/Doc/library/asynchat.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/library/asynchat.rst Sun Jul 20 10:52:46 2014 -0400 @@ -34,7 +34,7 @@ Like :class:`asyncore.dispatcher`, :class:`async_chat` defines a set of events that are generated by an analysis of socket conditions after a - :c:func:`select` call. Once the polling loop has been started the + :cfunc:`select` call. Once the polling loop has been started the :class:`async_chat` object's methods are called by the event-processing framework with no action on the part of the programmer. diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/library/asyncore.rst --- a/Doc/library/asyncore.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/library/asyncore.rst Sun Jul 20 10:52:46 2014 -0400 @@ -25,7 +25,7 @@ are probably what you really need. Network servers are rarely processor bound, however. -If your operating system supports the :c:func:`select` system call in its I/O +If your operating system supports the :cfunc:`select` system call in its I/O library (and nearly all do), then you can use it to juggle multiple communication channels at once; doing other work while your I/O is taking place in the "background." Although this strategy can seem strange and @@ -53,10 +53,10 @@ channels have been closed. All arguments are optional. The *count* parameter defaults to None, resulting in the loop terminating only when all channels have been closed. The *timeout* argument sets the timeout - parameter for the appropriate :func:`~select.select` or :func:`~select.poll` - call, measured in seconds; the default is 30 seconds. The *use_poll* - parameter, if true, indicates that :func:`~select.poll` should be used in - preference to :func:`~select.select` (the default is ``False``). + parameter for the appropriate :func:`select` or :func:`poll` call, measured + in seconds; the default is 30 seconds. The *use_poll* parameter, if true, + indicates that :func:`poll` should be used in preference to :func:`select` + (the default is ``False``). The *map* parameter is a dictionary whose items are the channels to watch. As channels are closed they are deleted from their map. If *map* is @@ -95,8 +95,8 @@ During asynchronous processing, each mapped channel's :meth:`readable` and :meth:`writable` methods are used to determine whether the channel's socket - should be added to the list of channels :c:func:`select`\ ed or - :c:func:`poll`\ ed for read and write events. + should be added to the list of channels :cfunc:`select`\ ed or + :cfunc:`poll`\ ed for read and write events. Thus, the set of channel events is larger than the basic socket events. The full set of methods that can be overridden in your subclass follows: @@ -238,9 +238,9 @@ .. class:: file_dispatcher() A file_dispatcher takes a file descriptor or file object along with an - optional map argument and wraps it for use with the :c:func:`poll` or - :c:func:`loop` functions. If provided a file object or anything with a - :c:func:`fileno` method, that method will be called and passed to the + optional map argument and wraps it for use with the :cfunc:`poll` or + :cfunc:`loop` functions. If provided a file object or anything with a + :cfunc:`fileno` method, that method will be called and passed to the :class:`file_wrapper` constructor. Availability: UNIX. .. class:: file_wrapper() @@ -318,10 +318,13 @@ def handle_accept(self): pair = self.accept() - if pair is not None: + if pair is None: + pass + else: sock, addr = pair print 'Incoming connection from %s' % repr(addr) handler = EchoHandler(sock) server = EchoServer('localhost', 8080) asyncore.loop() + diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/library/atexit.rst --- a/Doc/library/atexit.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/library/atexit.rst Sun Jul 20 10:52:46 2014 -0400 @@ -15,19 +15,18 @@ The :mod:`atexit` module defines a single function to register cleanup functions. Functions thus registered are automatically executed upon normal -interpreter termination. :mod:`atexit` runs these functions in the *reverse* -order in which they were registered; if you register ``A``, ``B``, and ``C``, -at interpreter termination time they will be run in the order ``C``, ``B``, -``A``. +interpreter termination. The order in which the functions are called is not +defined; if you have cleanup operations that depend on each other, you should +wrap them in a function and register that one. This keeps :mod:`atexit` simple. -**Note:** The functions registered via this module are not called when the -program is killed by a signal not handled by Python, when a Python fatal -internal error is detected, or when :func:`os._exit` is called. +Note: the functions registered via this module are not called when the program +is killed by a signal not handled by Python, when a Python fatal internal error +is detected, or when :func:`os._exit` is called. .. index:: single: exitfunc (in sys) This is an alternate interface to the functionality provided by the -:func:`sys.exitfunc` variable. +``sys.exitfunc`` variable. Note: This module is unlikely to work correctly when used with other code that sets ``sys.exitfunc``. In particular, other core Python modules are free to use @@ -41,8 +40,7 @@ Register *func* as a function to be executed at termination. Any optional arguments that are to be passed to *func* must be passed as arguments to - :func:`register`. It is possible to register the same function and arguments - more than once. + :func:`register`. At normal program termination (for instance, if :func:`sys.exit` is called or the main module's execution completes), all functions registered are called in @@ -56,8 +54,8 @@ be raised is re-raised. .. versionchanged:: 2.6 - This function now returns *func*, which makes it possible to use it as a - decorator. + This function now returns *func* which makes it possible to use it as a + decorator without binding the original name to ``None``. .. seealso:: @@ -77,7 +75,7 @@ making an explicit call into this module at termination. :: try: - _count = int(open("counter").read()) + _count = int(open("/tmp/counter").read()) except IOError: _count = 0 @@ -86,7 +84,7 @@ _count = _count + n def savecounter(): - open("counter", "w").write("%d" % _count) + open("/tmp/counter", "w").write("%d" % _count) import atexit atexit.register(savecounter) @@ -111,4 +109,5 @@ def goodbye(): print "You are now leaving the Python sector." -This only works with functions that can be called without arguments. +This obviously only works with functions that don't take arguments. + diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/library/audioop.rst --- a/Doc/library/audioop.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/library/audioop.rst Sun Jul 20 10:52:46 2014 -0400 @@ -38,7 +38,7 @@ Return a fragment which is the addition of the two samples passed as parameters. *width* is the sample width in bytes, either ``1``, ``2`` or ``4``. Both - fragments should have the same length. Samples are truncated in case of overflow. + fragments should have the same length. .. function:: adpcm2lin(adpcmfragment, width, state) @@ -71,7 +71,7 @@ .. function:: bias(fragment, width, bias) Return a fragment that is the original fragment with a bias added to each - sample. Samples wrap around in case of overflow. + sample. .. function:: cross(fragment, width) @@ -162,6 +162,12 @@ hardware, among others. +.. function:: minmax(fragment, width) + + Return a tuple consisting of the minimum and maximum values of all samples in + the sound fragment. + + .. function:: max(fragment, width) Return the maximum of the *absolute value* of all samples in a fragment. @@ -172,16 +178,10 @@ Return the maximum peak-peak value in the sound fragment. -.. function:: minmax(fragment, width) - - Return a tuple consisting of the minimum and maximum values of all samples in - the sound fragment. - - .. function:: mul(fragment, width, factor) Return a fragment that has all samples in the original fragment multiplied by - the floating-point value *factor*. Samples are truncated in case of overflow. + the floating-point value *factor*. Overflow is silently ignored. .. function:: ratecv(fragment, width, nchannels, inrate, outrate, state[, weightA[, weightB]]) @@ -247,7 +247,7 @@ transmit the data but also the state. Note that you should send the *initial* state (the one you passed to :func:`lin2adpcm`) along to the decoder, not the final state (as returned by the coder). If you want to use -:class:`struct.Struct` to store the state in binary you can code the first +:func:`struct.struct` to store the state in binary you can code the first element (the predicted value) in 16 bits and the second (the delta index) in 8. The ADPCM coders have never been tried against other ADPCM coders, only against diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/library/base64.rst --- a/Doc/library/base64.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/library/base64.rst Sun Jul 20 10:52:46 2014 -0400 @@ -93,7 +93,7 @@ digit 0 is always mapped to the letter O). For security purposes the default is ``None``, so that 0 and 1 are not allowed in the input. - The decoded string is returned. A :exc:`TypeError` is raised if *s* is + The decoded string is returned. A :exc:`TypeError` is raised if *s* were incorrectly padded or if there are non-alphabet characters present in the string. diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/library/basehttpserver.rst --- a/Doc/library/basehttpserver.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/library/basehttpserver.rst Sun Jul 20 10:52:46 2014 -0400 @@ -6,8 +6,8 @@ .. note:: The :mod:`BaseHTTPServer` module has been merged into :mod:`http.server` in - Python 3. The :term:`2to3` tool will automatically adapt imports when - converting your sources to Python 3. + Python 3.0. The :term:`2to3` tool will automatically adapt imports when + converting your sources to 3.0. .. index:: @@ -240,7 +240,7 @@ to create custom error logging mechanisms. The *format* argument is a standard printf-style format string, where the additional arguments to :meth:`log_message` are applied as inputs to the formatting. The client - ip address and current date and time are prefixed to every message logged. + address and current date and time are prefixed to every message logged. .. method:: version_string() diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/library/bastion.rst --- a/Doc/library/bastion.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/library/bastion.rst Sun Jul 20 10:52:46 2014 -0400 @@ -7,7 +7,7 @@ :deprecated: .. deprecated:: 2.6 - The :mod:`Bastion` module has been removed in Python 3. + The :mod:`Bastion` module has been removed in Python 3.0. .. moduleauthor:: Barry Warsaw diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/library/bdb.rst --- a/Doc/library/bdb.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/library/bdb.rst Sun Jul 20 10:52:46 2014 -0400 @@ -20,7 +20,7 @@ The :mod:`bdb` module also defines two classes: -.. class:: Breakpoint(self, file, line, temporary=0, cond=None, funcname=None) +.. class:: Breakpoint(self, file, line[, temporary=0[, cond=None [, funcname=None]]]) This class implements temporary breakpoints, ignore counts, disabling and (re-)enabling, and conditionals. @@ -186,17 +186,17 @@ .. method:: user_line(frame) This method is called from :meth:`dispatch_line` when either - :meth:`stop_here` or :meth:`break_here` yields ``True``. + :meth:`stop_here` or :meth:`break_here` yields True. .. method:: user_return(frame, return_value) This method is called from :meth:`dispatch_return` when :meth:`stop_here` - yields ``True``. + yields True. .. method:: user_exception(frame, exc_info) This method is called from :meth:`dispatch_exception` when - :meth:`stop_here` yields ``True``. + :meth:`stop_here` yields True. .. method:: do_clear(arg) @@ -237,7 +237,7 @@ .. method:: set_quit() - Set the :attr:`quitting` attribute to ``True``. This raises :exc:`BdbQuit` in + Set the :attr:`quitting` attribute to True. This raises :exc:`BdbQuit` in the next call to one of the :meth:`dispatch_\*` methods. @@ -245,7 +245,7 @@ breakpoints. These methods return a string containing an error message if something went wrong, or ``None`` if all is well. - .. method:: set_break(filename, lineno, temporary=0, cond=None, funcname=None) + .. method:: set_break(filename, lineno[, temporary=0[, cond[, funcname]]]) Set a new breakpoint. If the *lineno* line doesn't exist for the *filename* passed as argument, return an error message. The *filename* diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/library/binascii.rst --- a/Doc/library/binascii.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/library/binascii.rst Sun Jul 20 10:52:46 2014 -0400 @@ -127,7 +127,7 @@ The return value is in the range [-2**31, 2**31-1] regardless of platform. In the past the value would be signed on some platforms and unsigned on others. Use & 0xffffffff on the - value if you want it to match Python 3 behavior. + value if you want it to match 3.0 behavior. .. versionchanged:: 3.0 The return value is unsigned and in the range [0, 2**32-1] diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/library/bisect.rst --- a/Doc/library/bisect.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/library/bisect.rst Sun Jul 20 10:52:46 2014 -0400 @@ -123,9 +123,9 @@ a 'B', and so on:: >>> def grade(score, breakpoints=[60, 70, 80, 90], grades='FDCBA'): - i = bisect(breakpoints, score) - return grades[i] - + ... i = bisect(breakpoints, score) + ... return grades[i] + ... >>> [grade(score) for score in [33, 99, 77, 70, 89, 90, 100]] ['F', 'A', 'C', 'C', 'B', 'A', 'A'] diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/library/bsddb.rst --- a/Doc/library/bsddb.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/library/bsddb.rst Sun Jul 20 10:52:46 2014 -0400 @@ -7,7 +7,7 @@ .. sectionauthor:: Skip Montanaro .. deprecated:: 2.6 - The :mod:`bsddb` module has been removed in Python 3. + The :mod:`bsddb` module has been deprecated for removal in Python 3.0. The :mod:`bsddb` module provides an interface to the Berkeley DB library. Users @@ -52,9 +52,9 @@ Open the hash format file named *filename*. Files never intended to be preserved on disk may be created by passing ``None`` as the *filename*. The optional *flag* identifies the mode used to open the file. It may be ``'r'`` - (read only), ``'w'`` (read-write), ``'c'`` (read-write - create if necessary; + (read only), ``'w'`` (read-write) , ``'c'`` (read-write - create if necessary; the default) or ``'n'`` (read-write - truncate to zero length). The other - arguments are rarely used and are just passed to the low-level :c:func:`dbopen` + arguments are rarely used and are just passed to the low-level :cfunc:`dbopen` function. Consult the Berkeley DB documentation for their use and interpretation. @@ -86,7 +86,7 @@ This is present *only* to allow backwards compatibility with systems which ship with the old Berkeley DB 1.85 database library. The :mod:`bsddb185` module should never be used directly in new code. The module has been removed in - Python 3. If you find you still need it look in PyPI. + Python 3.0. If you find you still need it look in PyPI. .. seealso:: @@ -170,7 +170,7 @@ Example:: >>> import bsddb - >>> db = bsddb.btopen('spam.db', 'c') + >>> db = bsddb.btopen('/tmp/spam.db', 'c') >>> for i in range(10): db['%d'%i] = '%d'% (i*i) ... >>> db['3'] diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/library/bz2.rst --- a/Doc/library/bz2.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/library/bz2.rst Sun Jul 20 10:52:46 2014 -0400 @@ -14,6 +14,9 @@ It implements a complete file interface, one-shot (de)compression functions, and types for sequential (de)compression. +For other archive formats, see the :mod:`gzip`, :mod:`zipfile`, and +:mod:`tarfile` modules. + Here is a summary of the features offered by the bz2 module: * :class:`BZ2File` class implements a complete file interface, including @@ -42,9 +45,6 @@ Handling of compressed files is offered by the :class:`BZ2File` class. -.. index:: - single: universal newlines; bz2.BZ2File class - .. class:: BZ2File(filename[, mode[, buffering[, compresslevel]]]) Open a bz2 file. Mode can be either ``'r'`` or ``'w'``, for reading (default) @@ -53,7 +53,7 @@ unbuffered, and larger numbers specify the buffer size; the default is ``0``. If *compresslevel* is given, it must be a number between ``1`` and ``9``; the default is ``9``. Add a ``'U'`` to mode to open the file for input - in :term:`universal newlines` mode. Any line ending in the input file will be + with universal newline support. Any line ending in the input file will be seen as a ``'\n'`` in Python. Also, a file so opened gains the attribute :attr:`newlines`; the value for this attribute is one of ``None`` (no newline read yet), ``'\r'``, ``'\n'``, ``'\r\n'`` or a tuple containing all the @@ -67,18 +67,6 @@ Support for the :keyword:`with` statement was added. - .. note:: - - This class does not support input files containing multiple streams (such - as those produced by the :program:`pbzip2` tool). When reading such an - input file, only the first stream will be accessible. If you require - support for multi-stream files, consider using the third-party - :mod:`bz2file` module (available from - `PyPI `_). This module provides a - backport of Python 3.3's :class:`BZ2File` class, which does support - multi-stream files. - - .. method:: close() Close the file. Sets data attribute :attr:`closed` to true. A closed file diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/library/calendar.rst --- a/Doc/library/calendar.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/library/calendar.rst Sun Jul 20 10:52:46 2014 -0400 @@ -294,11 +294,10 @@ .. function:: timegm(tuple) - An unrelated but handy function that takes a time tuple such as returned by - the :func:`~time.gmtime` function in the :mod:`time` module, and returns the - corresponding Unix timestamp value, assuming an epoch of 1970, and the POSIX - encoding. In fact, :func:`time.gmtime` and :func:`timegm` are each others' - inverse. + An unrelated but handy function that takes a time tuple such as returned by the + :func:`gmtime` function in the :mod:`time` module, and returns the corresponding + Unix timestamp value, assuming an epoch of 1970, and the POSIX encoding. In + fact, :func:`time.gmtime` and :func:`timegm` are each others' inverse. .. versionadded:: 2.0 diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/library/carbon.rst --- a/Doc/library/carbon.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/library/carbon.rst Sun Jul 20 10:52:46 2014 -0400 @@ -5,7 +5,7 @@ Mac OS Toolbox Modules ********************** -These are a set of modules that provide interfaces to various legacy Mac OS toolboxes. +There are a set of modules that provide interfaces to various Mac OS toolboxes. If applicable the module will define a number of Python objects for the various structures declared by the toolbox, and operations will be implemented as methods of the object. Other operations will be implemented as functions in the @@ -14,7 +14,7 @@ in Python (input and output buffers, especially). All methods and functions have a :attr:`__doc__` string describing their arguments and return values, and for additional description you are referred to `Inside Macintosh -`_ or similar works. +`_ or similar works. These modules all live in a package called :mod:`Carbon`. Despite that name they are not all part of the Carbon framework: CF is really in the CoreFoundation @@ -24,10 +24,7 @@ .. note:: - Most of the OS X APIs that these modules use are deprecated or removed - in recent versions of OS X. Many are not available when Python is - executing in 64-bit mode. The Carbon modules have been removed in - Python 3. You should avoid using them in Python 2. + The Carbon modules have been removed in Python 3.0. :mod:`Carbon.AE` --- Apple Events @@ -518,7 +515,7 @@ .. seealso:: - `Scrap Manager `_ + `Scrap Manager `_ Apple's documentation for the Scrap Manager gives a lot of useful information about using the Scrap Manager in applications. diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/library/cd.rst --- a/Doc/library/cd.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/library/cd.rst Sun Jul 20 10:52:46 2014 -0400 @@ -9,7 +9,7 @@ .. deprecated:: 2.6 - The :mod:`cd` module has been removed in Python 3. + The :mod:`cd` module has been deprecated for removal in Python 3.0. This module provides an interface to the Silicon Graphics CD library. It is diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/library/cgi.rst --- a/Doc/library/cgi.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/library/cgi.rst Sun Jul 20 10:52:46 2014 -0400 @@ -81,7 +81,7 @@ instead, with code like this:: import cgitb - cgitb.enable(display=0, logdir="/path/to/logdir") + cgitb.enable(display=0, logdir="/tmp") It's very helpful to use this feature during script development. The reports produced by :mod:`cgitb` provide information that can save you a lot of time in @@ -97,7 +97,7 @@ The :class:`FieldStorage` instance can be indexed like a Python dictionary. It allows membership testing with the :keyword:`in` operator, and also supports -the standard dictionary method :meth:`~dict.keys` and the built-in function +the standard dictionary method :meth:`keys` and the built-in function :func:`len`. Form fields containing empty strings are ignored and do not appear in the dictionary; to keep such values, provide a true value for the optional *keep_blank_values* keyword parameter when creating the :class:`FieldStorage` @@ -119,29 +119,28 @@ Here the fields, accessed through ``form[key]``, are themselves instances of :class:`FieldStorage` (or :class:`MiniFieldStorage`, depending on the form -encoding). The :attr:`~FieldStorage.value` attribute of the instance yields -the string value of the field. The :meth:`~FieldStorage.getvalue` method -returns this string value directly; it also accepts an optional second argument -as a default to return if the requested key is not present. +encoding). The :attr:`value` attribute of the instance yields the string value +of the field. The :meth:`getvalue` method returns this string value directly; +it also accepts an optional second argument as a default to return if the +requested key is not present. If the submitted form data contains more than one field with the same name, the object retrieved by ``form[key]`` is not a :class:`FieldStorage` or :class:`MiniFieldStorage` instance but a list of such instances. Similarly, in this situation, ``form.getvalue(key)`` would return a list of strings. If you expect this possibility (when your HTML form contains multiple fields with the -same name), use the :meth:`~FieldStorage.getlist` method, which always returns -a list of values (so that you do not need to special-case the single item -case). For example, this code concatenates any number of username fields, -separated by commas:: +same name), use the :func:`getlist` function, which always returns a list of +values (so that you do not need to special-case the single item case). For +example, this code concatenates any number of username fields, separated by +commas:: value = form.getlist("username") usernames = ",".join(value) If a field represents an uploaded file, accessing the value via the -:attr:`~FieldStorage.value` attribute or the :func:`~FieldStorage.getvalue` -method reads the entire file in memory as a string. This may not be what you -want. You can test for an uploaded file by testing either the -:attr:`~FieldStorage.filename` attribute or the :attr:`~FieldStorage.file` +:attr:`value` attribute or the :func:`getvalue` method reads the entire file in +memory as a string. This may not be what you want. You can test for an uploaded +file by testing either the :attr:`filename` attribute or the :attr:`!file` attribute. You can then read the data at leisure from the :attr:`!file` attribute:: @@ -156,8 +155,8 @@ If an error is encountered when obtaining the contents of an uploaded file (for example, when the user interrupts the form submission by clicking on -a Back or Cancel button) the :attr:`~FieldStorage.done` attribute of the -object for the field will be set to the value -1. +a Back or Cancel button) the :attr:`done` attribute of the object for the +field will be set to the value -1. The file upload draft standard entertains the possibility of uploading multiple files from one field (using a recursive :mimetype:`multipart/\*` encoding). @@ -226,8 +225,8 @@ code which checks whether the obtained value is a single value or a list of values. That's annoying and leads to less readable scripts. -A more convenient approach is to use the methods :meth:`~FieldStorage.getfirst` -and :meth:`~FieldStorage.getlist` provided by this higher level interface. +A more convenient approach is to use the methods :meth:`getfirst` and +:meth:`getlist` provided by this higher level interface. .. method:: FieldStorage.getfirst(name[, default]) @@ -285,10 +284,10 @@ algorithms implemented in this module in other circumstances. -.. function:: parse(fp[, environ[, keep_blank_values[, strict_parsing]]]) +.. function:: parse(fp[, keep_blank_values[, strict_parsing]]) Parse a query in the environment or from a file (the file defaults to - ``sys.stdin`` and environment defaults to ``os.environ``). The *keep_blank_values* and *strict_parsing* parameters are + ``sys.stdin``). The *keep_blank_values* and *strict_parsing* parameters are passed to :func:`urlparse.parse_qs` unchanged. diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/library/cgihttpserver.rst --- a/Doc/library/cgihttpserver.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/library/cgihttpserver.rst Sun Jul 20 10:52:46 2014 -0400 @@ -8,8 +8,8 @@ .. note:: The :mod:`CGIHTTPServer` module has been merged into :mod:`http.server` in - Python 3. The :term:`2to3` tool will automatically adapt imports when - converting your sources to Python 3. + Python 3.0. The :term:`2to3` tool will automatically adapt imports when + converting your sources to 3.0. The :mod:`CGIHTTPServer` module defines a request-handler class, interface diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/library/chunk.rst --- a/Doc/library/chunk.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/library/chunk.rst Sun Jul 20 10:52:46 2014 -0400 @@ -55,9 +55,8 @@ Class which represents a chunk. The *file* argument is expected to be a file-like object. An instance of this class is specifically allowed. The - only method that is needed is :meth:`~file.read`. If the methods - :meth:`~file.seek` and :meth:`~file.tell` are present and don't - raise an exception, they are also used. + only method that is needed is :meth:`read`. If the methods :meth:`seek` and + :meth:`tell` are present and don't raise an exception, they are also used. If these methods are present and raise an exception, they are expected to not have altered the object. If the optional argument *align* is true, chunks are assumed to be aligned on 2-byte boundaries. If *align* is false, no diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/library/code.rst --- a/Doc/library/code.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/library/code.rst Sun Jul 20 10:52:46 2014 -0400 @@ -33,11 +33,11 @@ Convenience function to run a read-eval-print loop. This creates a new instance of :class:`InteractiveConsole` and sets *readfunc* to be used as the - :meth:`InteractiveConsole.raw_input` method, if provided. If *local* is - provided, it is passed to the :class:`InteractiveConsole` constructor for - use as the default namespace for the interpreter loop. The :meth:`interact` - method of the instance is then run with *banner* passed as the banner to - use, if provided. The console object is discarded after use. + :meth:`raw_input` method, if provided. If *local* is provided, it is passed to + the :class:`InteractiveConsole` constructor for use as the default namespace for + the interpreter loop. The :meth:`interact` method of the instance is then run + with *banner* passed as the banner to use, if provided. The console object is + discarded after use. .. function:: compile_command(source[, filename[, symbol]]) diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/library/codecs.rst --- a/Doc/library/codecs.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/library/codecs.rst Sun Jul 20 10:52:46 2014 -0400 @@ -23,31 +23,6 @@ It defines the following functions: -.. function:: encode(obj, [encoding[, errors]]) - - Encodes *obj* using the codec registered for *encoding*. The default - encoding is ``'ascii'``. - - *Errors* may be given to set the desired error handling scheme. The - default error handler is ``'strict'`` meaning that encoding errors raise - :exc:`ValueError` (or a more codec specific subclass, such as - :exc:`UnicodeEncodeError`). Refer to :ref:`codec-base-classes` for more - information on codec error handling. - - .. versionadded:: 2.4 - -.. function:: decode(obj, [encoding[, errors]]) - - Decodes *obj* using the codec registered for *encoding*. The default - encoding is ``'ascii'``. - - *Errors* may be given to set the desired error handling scheme. The - default error handler is ``'strict'`` meaning that decoding errors raise - :exc:`ValueError` (or a more codec specific subclass, such as - :exc:`UnicodeDecodeError`). Refer to :ref:`codec-base-classes` for more - information on codec error handling. - - .. versionadded:: 2.4 .. function:: register(search_function) @@ -72,9 +47,9 @@ The various functions or classes take the following arguments: *encode* and *decode*: These must be functions or methods which have the same - interface as the :meth:`~Codec.encode`/:meth:`~Codec.decode` methods of Codec - instances (see :ref:`Codec Interface `). The functions/methods - are expected to work in a stateless mode. + interface as the :meth:`encode`/:meth:`decode` methods of Codec instances (see + Codec Interface). The functions/methods are expected to work in a stateless + mode. *incrementalencoder* and *incrementaldecoder*: These have to be factory functions providing the following interface: @@ -91,7 +66,7 @@ ``factory(stream, errors='strict')`` The factory functions must return objects providing the interfaces defined by - the base classes :class:`StreamReader` and :class:`StreamWriter`, respectively. + the base classes :class:`StreamWriter` and :class:`StreamReader`, respectively. Stream codecs can maintain state. Possible values for errors are @@ -340,13 +315,11 @@ The :class:`Codec` class defines the interface for stateless encoders/decoders. -To simplify and standardize error handling, the :meth:`~Codec.encode` and -:meth:`~Codec.decode` methods may implement different error handling schemes by +To simplify and standardize error handling, the :meth:`encode` and +:meth:`decode` methods may implement different error handling schemes by providing the *errors* string argument. The following string values are defined and implemented by all standard Python codecs: -.. tabularcolumns:: |l|L| - +-------------------------+-----------------------------------------------+ | Value | Meaning | +=========================+===============================================+ @@ -422,14 +395,12 @@ The :class:`IncrementalEncoder` and :class:`IncrementalDecoder` classes provide the basic interface for incremental encoding and decoding. Encoding/decoding the input isn't done with one call to the stateless encoder/decoder function, but -with multiple calls to the -:meth:`~IncrementalEncoder.encode`/:meth:`~IncrementalDecoder.decode` method of -the incremental encoder/decoder. The incremental encoder/decoder keeps track of -the encoding/decoding process during method calls. +with multiple calls to the :meth:`encode`/:meth:`decode` method of the +incremental encoder/decoder. The incremental encoder/decoder keeps track of the +encoding/decoding process during method calls. -The joined output of calls to the -:meth:`~IncrementalEncoder.encode`/:meth:`~IncrementalDecoder.decode` method is -the same as if all the single inputs were joined into one, and this input was +The joined output of calls to the :meth:`encode`/:meth:`decode` method is the +same as if all the single inputs were joined into one, and this input was encoded/decoded with the stateless encoder/decoder. @@ -680,7 +651,7 @@ Read one line from the input stream and return the decoded data. *size*, if given, is passed as size argument to the stream's - :meth:`read` method. + :meth:`readline` method. If *keepends* is false line-endings will be stripped from the lines returned. @@ -788,9 +759,9 @@ --------------------- Unicode strings are stored internally as sequences of codepoints (to be precise -as :c:type:`Py_UNICODE` arrays). Depending on the way Python is compiled (either +as :ctype:`Py_UNICODE` arrays). Depending on the way Python is compiled (either via ``--enable-unicode=ucs2`` or ``--enable-unicode=ucs4``, with the -former being the default) :c:type:`Py_UNICODE` is either a 16-bit or 32-bit data +former being the default) :ctype:`Py_UNICODE` is either a 16-bit or 32-bit data type. Once a Unicode object is used outside of CPU and memory, CPU endianness and how these arrays are stored as bytes become an issue. Transforming a unicode object into a sequence of bytes is called encoding and recreating the @@ -916,8 +887,6 @@ * an IBM PC code page, which is ASCII compatible -.. tabularcolumns:: |l|p{0.3\linewidth}|p{0.3\linewidth}| - +-----------------+--------------------------------+--------------------------------+ | Codec | Aliases | Languages | +=================+================================+================================+ @@ -1125,112 +1094,84 @@ | utf_8_sig | | all languages | +-----------------+--------------------------------+--------------------------------+ -Python Specific Encodings -------------------------- +A number of codecs are specific to Python, so their codec names have no meaning +outside Python. Some of them don't convert from Unicode strings to byte strings, +but instead use the property of the Python codecs machinery that any bijective +function with one argument can be considered as an encoding. -A number of predefined codecs are specific to Python, so their codec names have -no meaning outside Python. These are listed in the tables below based on the -expected input and output types (note that while text encodings are the most -common use case for codecs, the underlying codec infrastructure supports -arbitrary data transforms rather than just text encodings). For asymmetric -codecs, the stated purpose describes the encoding direction. +For the codecs listed below, the result in the "encoding" direction is always a +byte string. The result of the "decoding" direction is listed as operand type in +the table. -The following codecs provide unicode-to-str encoding [#encoding-note]_ and -str-to-unicode decoding [#decoding-note]_, similar to the Unicode text -encodings. - -.. tabularcolumns:: |l|L|L| - -+--------------------+---------------------------+---------------------------+ -| Codec | Aliases | Purpose | -+====================+===========================+===========================+ -| idna | | Implements :rfc:`3490`, | -| | | see also | -| | | :mod:`encodings.idna` | -+--------------------+---------------------------+---------------------------+ -| mbcs | dbcs | Windows only: Encode | -| | | operand according to the | -| | | ANSI codepage (CP_ACP) | -+--------------------+---------------------------+---------------------------+ -| palmos | | Encoding of PalmOS 3.5 | -+--------------------+---------------------------+---------------------------+ -| punycode | | Implements :rfc:`3492` | -+--------------------+---------------------------+---------------------------+ -| raw_unicode_escape | | Produce a string that is | -| | | suitable as raw Unicode | -| | | literal in Python source | -| | | code | -+--------------------+---------------------------+---------------------------+ -| rot_13 | rot13 | Returns the Caesar-cypher | -| | | encryption of the operand | -+--------------------+---------------------------+---------------------------+ -| undefined | | Raise an exception for | -| | | all conversions. Can be | -| | | used as the system | -| | | encoding if no automatic | -| | | :term:`coercion` between | -| | | byte and Unicode strings | -| | | is desired. | -+--------------------+---------------------------+---------------------------+ -| unicode_escape | | Produce a string that is | -| | | suitable as Unicode | -| | | literal in Python source | -| | | code | -+--------------------+---------------------------+---------------------------+ -| unicode_internal | | Return the internal | -| | | representation of the | -| | | operand | -+--------------------+---------------------------+---------------------------+ ++--------------------+---------------------------+----------------+---------------------------+ +| Codec | Aliases | Operand type | Purpose | ++====================+===========================+================+===========================+ +| base64_codec | base64, base-64 | byte string | Convert operand to MIME | +| | | | base64 | ++--------------------+---------------------------+----------------+---------------------------+ +| bz2_codec | bz2 | byte string | Compress the operand | +| | | | using bz2 | ++--------------------+---------------------------+----------------+---------------------------+ +| hex_codec | hex | byte string | Convert operand to | +| | | | hexadecimal | +| | | | representation, with two | +| | | | digits per byte | ++--------------------+---------------------------+----------------+---------------------------+ +| idna | | Unicode string | Implements :rfc:`3490`, | +| | | | see also | +| | | | :mod:`encodings.idna` | ++--------------------+---------------------------+----------------+---------------------------+ +| mbcs | dbcs | Unicode string | Windows only: Encode | +| | | | operand according to the | +| | | | ANSI codepage (CP_ACP) | ++--------------------+---------------------------+----------------+---------------------------+ +| palmos | | Unicode string | Encoding of PalmOS 3.5 | ++--------------------+---------------------------+----------------+---------------------------+ +| punycode | | Unicode string | Implements :rfc:`3492` | ++--------------------+---------------------------+----------------+---------------------------+ +| quopri_codec | quopri, quoted-printable, | byte string | Convert operand to MIME | +| | quotedprintable | | quoted printable | ++--------------------+---------------------------+----------------+---------------------------+ +| raw_unicode_escape | | Unicode string | Produce a string that is | +| | | | suitable as raw Unicode | +| | | | literal in Python source | +| | | | code | ++--------------------+---------------------------+----------------+---------------------------+ +| rot_13 | rot13 | Unicode string | Returns the Caesar-cypher | +| | | | encryption of the operand | ++--------------------+---------------------------+----------------+---------------------------+ +| string_escape | | byte string | Produce a string that is | +| | | | suitable as string | +| | | | literal in Python source | +| | | | code | ++--------------------+---------------------------+----------------+---------------------------+ +| undefined | | any | Raise an exception for | +| | | | all conversions. Can be | +| | | | used as the system | +| | | | encoding if no automatic | +| | | | :term:`coercion` between | +| | | | byte and Unicode strings | +| | | | is desired. | ++--------------------+---------------------------+----------------+---------------------------+ +| unicode_escape | | Unicode string | Produce a string that is | +| | | | suitable as Unicode | +| | | | literal in Python source | +| | | | code | ++--------------------+---------------------------+----------------+---------------------------+ +| unicode_internal | | Unicode string | Return the internal | +| | | | representation of the | +| | | | operand | ++--------------------+---------------------------+----------------+---------------------------+ +| uu_codec | uu | byte string | Convert the operand using | +| | | | uuencode | ++--------------------+---------------------------+----------------+---------------------------+ +| zlib_codec | zip, zlib | byte string | Compress the operand | +| | | | using gzip | ++--------------------+---------------------------+----------------+---------------------------+ .. versionadded:: 2.3 The ``idna`` and ``punycode`` encodings. -The following codecs provide str-to-str encoding and decoding -[#decoding-note]_. - -.. tabularcolumns:: |l|L|L|L| - -+--------------------+---------------------------+---------------------------+------------------------------+ -| Codec | Aliases | Purpose | Encoder/decoder | -+====================+===========================+===========================+==============================+ -| base64_codec | base64, base-64 | Convert operand to MIME | :meth:`base64.b64encode`, | -| | | base64 (the result always | :meth:`base64.b64decode` | -| | | includes a trailing | | -| | | ``'\n'``) | | -+--------------------+---------------------------+---------------------------+------------------------------+ -| bz2_codec | bz2 | Compress the operand | :meth:`bz2.compress`, | -| | | using bz2 | :meth:`bz2.decompress` | -+--------------------+---------------------------+---------------------------+------------------------------+ -| hex_codec | hex | Convert operand to | :meth:`base64.b16encode`, | -| | | hexadecimal | :meth:`base64.b16decode` | -| | | representation, with two | | -| | | digits per byte | | -+--------------------+---------------------------+---------------------------+------------------------------+ -| quopri_codec | quopri, quoted-printable, | Convert operand to MIME | :meth:`quopri.encodestring`, | -| | quotedprintable | quoted printable | :meth:`quopri.decodestring` | -+--------------------+---------------------------+---------------------------+------------------------------+ -| string_escape | | Produce a string that is | | -| | | suitable as string | | -| | | literal in Python source | | -| | | code | | -+--------------------+---------------------------+---------------------------+------------------------------+ -| uu_codec | uu | Convert the operand using | :meth:`uu.encode`, | -| | | uuencode | :meth:`uu.decode` | -+--------------------+---------------------------+---------------------------+------------------------------+ -| zlib_codec | zip, zlib | Compress the operand | :meth:`zlib.compress`, | -| | | using gzip | :meth:`zlib.decompress` | -+--------------------+---------------------------+---------------------------+------------------------------+ - -.. [#encoding-note] str objects are also accepted as input in place of unicode - objects. They are implicitly converted to unicode by decoding them using - the default encoding. If this conversion fails, it may lead to encoding - operations raising :exc:`UnicodeDecodeError`. - -.. [#decoding-note] unicode objects are also accepted as input in place of str - objects. They are implicitly converted to str by encoding them using the - default encoding. If this conversion fails, it may lead to decoding - operations raising :exc:`UnicodeEncodeError`. - :mod:`encodings.idna` --- Internationalized Domain Names in Applications ------------------------------------------------------------------------ diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/library/collections.rst --- a/Doc/library/collections.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/library/collections.rst Sun Jul 20 10:52:46 2014 -0400 @@ -51,7 +51,7 @@ >>> # Find the ten most common words in Hamlet >>> import re - >>> words = re.findall(r'\w+', open('hamlet.txt').read().lower()) + >>> words = re.findall('\w+', open('hamlet.txt').read().lower()) >>> Counter(words).most_common(10) [('the', 1143), ('and', 966), ('to', 762), ('of', 669), ('i', 631), ('you', 554), ('a', 546), ('my', 514), ('hamlet', 471), ('in', 451)] @@ -120,7 +120,6 @@ >>> c = Counter(a=4, b=2, c=0, d=-2) >>> d = Counter(a=1, b=2, c=3, d=4) >>> c.subtract(d) - >>> c Counter({'a': 3, 'b': 0, 'c': -3, 'd': -6}) The usual dictionary methods are available for :class:`Counter` objects @@ -146,7 +145,7 @@ dict(c) # convert to a regular dictionary c.items() # convert to a list of (elem, cnt) pairs Counter(dict(list_of_pairs)) # convert from a list of (elem, cnt) pairs - c.most_common()[:-n-1:-1] # n least common elements + c.most_common()[:-n:-1] # n least common elements c += Counter() # remove zero and negative counts Several mathematical operations are provided for combining :class:`Counter` @@ -470,11 +469,6 @@ :class:`dict` class when the requested key is not found; whatever it returns or raises is then returned or raised by :meth:`__getitem__`. - Note that :meth:`__missing__` is *not* called for any operations besides - :meth:`__getitem__`. This means that :meth:`get` will, like normal - dictionaries, return ``None`` as a default rather than using - :attr:`default_factory`. - :class:`defaultdict` objects support the following instance variable: @@ -602,53 +596,47 @@ >>> Point = namedtuple('Point', ['x', 'y'], verbose=True) class Point(tuple): - 'Point(x, y)' + 'Point(x, y)' - __slots__ = () + __slots__ = () - _fields = ('x', 'y') + _fields = ('x', 'y') - def __new__(_cls, x, y): - 'Create a new instance of Point(x, y)' - return _tuple.__new__(_cls, (x, y)) + def __new__(_cls, x, y): + 'Create a new instance of Point(x, y)' + return _tuple.__new__(_cls, (x, y)) - @classmethod - def _make(cls, iterable, new=tuple.__new__, len=len): - 'Make a new Point object from a sequence or iterable' - result = new(cls, iterable) - if len(result) != 2: - raise TypeError('Expected 2 arguments, got %d' % len(result)) - return result + @classmethod + def _make(cls, iterable, new=tuple.__new__, len=len): + 'Make a new Point object from a sequence or iterable' + result = new(cls, iterable) + if len(result) != 2: + raise TypeError('Expected 2 arguments, got %d' % len(result)) + return result - def __repr__(self): - 'Return a nicely formatted representation string' - return 'Point(x=%r, y=%r)' % self + def __repr__(self): + 'Return a nicely formatted representation string' + return 'Point(x=%r, y=%r)' % self - def _asdict(self): - 'Return a new OrderedDict which maps field names to their values' - return OrderedDict(zip(self._fields, self)) + def _asdict(self): + 'Return a new OrderedDict which maps field names to their values' + return OrderedDict(zip(self._fields, self)) - def _replace(_self, **kwds): - 'Return a new Point object replacing specified fields with new values' - result = _self._make(map(kwds.pop, ('x', 'y'), _self)) - if kwds: - raise ValueError('Got unexpected field names: %r' % kwds.keys()) - return result + __dict__ = property(_asdict) - def __getnewargs__(self): - 'Return self as a plain tuple. Used by copy and pickle.' - return tuple(self) + def _replace(_self, **kwds): + 'Return a new Point object replacing specified fields with new values' + result = _self._make(map(kwds.pop, ('x', 'y'), _self)) + if kwds: + raise ValueError('Got unexpected field names: %r' % kwds.keys()) + return result - __dict__ = _property(_asdict) + def __getnewargs__(self): + 'Return self as a plain tuple. Used by copy and pickle.' + return tuple(self) - def __getstate__(self): - 'Exclude the OrderedDict from pickling' - pass - - x = _property(_itemgetter(0), doc='Alias for field number 0') - - y = _property(_itemgetter(1), doc='Alias for field number 1') - + x = _property(_itemgetter(0), doc='Alias for field number 0') + y = _property(_itemgetter(1), doc='Alias for field number 1') >>> p = Point(11, y=22) # instantiate with positional or keyword arguments >>> p[0] + p[1] # indexable like the plain tuple (11, 22) @@ -818,9 +806,9 @@ Equality tests between :class:`OrderedDict` objects are order-sensitive and are implemented as ``list(od1.items())==list(od2.items())``. Equality tests between :class:`OrderedDict` objects and other -:class:`Mapping` objects are order-insensitive like regular -dictionaries. This allows :class:`OrderedDict` objects to be substituted -anywhere a regular dictionary is used. +:class:`Mapping` objects are order-insensitive like regular dictionaries. +This allows :class:`OrderedDict` objects to be substituted anywhere a +regular dictionary is used. The :class:`OrderedDict` constructor and :meth:`update` method both accept keyword arguments, but their order is lost because Python's function call @@ -857,7 +845,7 @@ to the end and the sort is not maintained. It is also straight-forward to create an ordered dictionary variant -that remembers the order the keys were *last* inserted. +that the remembers the order the keys were *last* inserted. If a new entry overwrites an existing entry, the original insertion position is changed and moved to the end:: @@ -899,35 +887,29 @@ :class:`Sized` ``__len__`` :class:`Callable` ``__call__`` -:class:`Sequence` :class:`Sized`, ``__getitem__``, ``__contains__``, ``__iter__``, ``__reversed__``, - :class:`Iterable`, ``__len__`` ``index``, and ``count`` +:class:`Sequence` :class:`Sized`, ``__getitem__`` ``__contains__``, ``__iter__``, ``__reversed__``, + :class:`Iterable`, ``index``, and ``count`` :class:`Container` -:class:`MutableSequence` :class:`Sequence` ``__getitem__``, Inherited :class:`Sequence` methods and - ``__setitem__``, ``append``, ``reverse``, ``extend``, ``pop``, - ``__delitem__``, ``remove``, and ``__iadd__`` - ``__len__``, - ``insert`` +:class:`MutableSequence` :class:`Sequence` ``__setitem__``, Inherited :class:`Sequence` methods and + ``__delitem__``, ``append``, ``reverse``, ``extend``, ``pop``, + ``insert`` ``remove``, and ``__iadd__`` -:class:`Set` :class:`Sized`, ``__contains__``, ``__le__``, ``__lt__``, ``__eq__``, ``__ne__``, - :class:`Iterable`, ``__iter__``, ``__gt__``, ``__ge__``, ``__and__``, ``__or__``, - :class:`Container` ``__len__`` ``__sub__``, ``__xor__``, and ``isdisjoint`` +:class:`Set` :class:`Sized`, ``__le__``, ``__lt__``, ``__eq__``, ``__ne__``, + :class:`Iterable`, ``__gt__``, ``__ge__``, ``__and__``, ``__or__``, + :class:`Container` ``__sub__``, ``__xor__``, and ``isdisjoint`` -:class:`MutableSet` :class:`Set` ``__contains__``, Inherited :class:`Set` methods and - ``__iter__``, ``clear``, ``pop``, ``remove``, ``__ior__``, - ``__len__``, ``__iand__``, ``__ixor__``, and ``__isub__`` - ``add``, - ``discard`` +:class:`MutableSet` :class:`Set` ``add``, Inherited :class:`Set` methods and + ``discard`` ``clear``, ``pop``, ``remove``, ``__ior__``, + ``__iand__``, ``__ixor__``, and ``__isub__`` -:class:`Mapping` :class:`Sized`, ``__getitem__``, ``__contains__``, ``keys``, ``items``, ``values``, - :class:`Iterable`, ``__iter__``, ``get``, ``__eq__``, and ``__ne__`` - :class:`Container` ``__len__`` +:class:`Mapping` :class:`Sized`, ``__getitem__`` ``__contains__``, ``keys``, ``items``, ``values``, + :class:`Iterable`, ``get``, ``__eq__``, and ``__ne__`` + :class:`Container` -:class:`MutableMapping` :class:`Mapping` ``__getitem__``, Inherited :class:`Mapping` methods and - ``__setitem__``, ``pop``, ``popitem``, ``clear``, ``update``, - ``__delitem__``, and ``setdefault`` - ``__iter__``, - ``__len__`` +:class:`MutableMapping` :class:`Mapping` ``__setitem__``, Inherited :class:`Mapping` methods and + ``__delitem__`` ``pop``, ``popitem``, ``clear``, ``update``, + and ``setdefault`` :class:`MappingView` :class:`Sized` ``__len__`` @@ -1028,7 +1010,7 @@ (2) To override the comparisons (presumably for speed, as the - semantics are fixed), redefine :meth:`__le__` and :meth:`__ge__`, + semantics are fixed), redefine :meth:`__le__` and then the other operations will automatically follow suit. (3) diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/library/colorsys.rst --- a/Doc/library/colorsys.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/library/colorsys.rst Sun Jul 20 10:52:46 2014 -0400 @@ -58,7 +58,7 @@ Example:: >>> import colorsys - >>> colorsys.rgb_to_hsv(0.2, 0.4, 0.4) - (0.5, 0.5, 0.4) - >>> colorsys.hsv_to_rgb(0.5, 0.5, 0.4) - (0.2, 0.4, 0.4) + >>> colorsys.rgb_to_hsv(.3, .4, .2) + (0.25, 0.5, 0.4) + >>> colorsys.hsv_to_rgb(0.25, 0.5, 0.4) + (0.3, 0.4, 0.2) diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/library/commands.rst --- a/Doc/library/commands.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/library/commands.rst Sun Jul 20 10:52:46 2014 -0400 @@ -8,7 +8,7 @@ :deprecated: .. deprecated:: 2.6 - The :mod:`commands` module has been removed in Python 3. Use the + The :mod:`commands` module has been removed in Python 3.0. Use the :mod:`subprocess` module instead. .. sectionauthor:: Sue Williams @@ -38,7 +38,7 @@ ``(status, output)``. *cmd* is actually run as ``{ cmd ; } 2>&1``, so that the returned output will contain output or error messages. A trailing newline is stripped from the output. The exit status for the command can be interpreted - according to the rules for the C function :c:func:`wait`. + according to the rules for the C function :cfunc:`wait`. .. function:: getoutput(cmd) diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/library/compileall.rst --- a/Doc/library/compileall.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/library/compileall.rst Sun Jul 20 10:52:46 2014 -0400 @@ -127,7 +127,7 @@ # Perform same compilation, excluding files in .svn directories. import re - compileall.compile_dir('Lib/', rx=re.compile(r'[/\\][.]svn'), force=True) + compileall.compile_dir('Lib/', rx=re.compile('/[.]svn'), force=True) .. seealso:: diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/library/compiler.rst --- a/Doc/library/compiler.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/library/compiler.rst Sun Jul 20 10:52:46 2014 -0400 @@ -6,7 +6,7 @@ *********************** .. deprecated:: 2.6 - The :mod:`compiler` package has been removed in Python 3. + The :mod:`compiler` package has been removed in Python 3.0. .. sectionauthor:: Jeremy Hylton @@ -540,7 +540,7 @@ AST looks like, and how to access attributes of an AST node. The first module defines a single function. Assume it is stored in -:file:`doublelib.py`. :: +:file:`/tmp/doublelib.py`. :: """This is an example module. @@ -557,7 +557,7 @@ :mod:`compiler.ast` module. :: >>> import compiler - >>> mod = compiler.parseFile("doublelib.py") + >>> mod = compiler.parseFile("/tmp/doublelib.py") >>> mod Module('This is an example module.\n\nThis is the docstring.\n', Stmt([Function(None, 'double', ['x'], [], 0, diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/library/configparser.rst --- a/Doc/library/configparser.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/library/configparser.rst Sun Jul 20 10:52:46 2014 -0400 @@ -12,8 +12,8 @@ .. note:: The :mod:`ConfigParser` module has been renamed to :mod:`configparser` in - Python 3. The :term:`2to3` tool will automatically adapt imports when - converting your sources to Python 3. + Python 3.0. The :term:`2to3` tool will automatically adapt imports when + converting your sources to 3.0. .. index:: pair: .ini; file @@ -451,9 +451,9 @@ # when attempting to write to a file or when you get it in non-raw # mode. SafeConfigParser does not allow such assignments to take place. config.add_section('Section1') - config.set('Section1', 'an_int', '15') - config.set('Section1', 'a_bool', 'true') - config.set('Section1', 'a_float', '3.1415') + config.set('Section1', 'int', '15') + config.set('Section1', 'bool', 'true') + config.set('Section1', 'float', '3.1415') config.set('Section1', 'baz', 'fun') config.set('Section1', 'bar', 'Python') config.set('Section1', 'foo', '%(bar)s is %(baz)s!') @@ -471,13 +471,13 @@ # getfloat() raises an exception if the value is not a float # getint() and getboolean() also do this for their respective types - a_float = config.getfloat('Section1', 'a_float') - an_int = config.getint('Section1', 'an_int') - print a_float + an_int + float = config.getfloat('Section1', 'float') + int = config.getint('Section1', 'int') + print float + int # Notice that the next output does not interpolate '%(bar)s' or '%(baz)s'. # This is because we are using a RawConfigParser(). - if config.getboolean('Section1', 'a_bool'): + if config.getboolean('Section1', 'bool'): print config.get('Section1', 'foo') To get interpolation, you will need to use a :class:`ConfigParser` or diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/library/cookie.rst --- a/Doc/library/cookie.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/library/cookie.rst Sun Jul 20 10:52:46 2014 -0400 @@ -8,8 +8,8 @@ .. note:: The :mod:`Cookie` module has been renamed to :mod:`http.cookies` in Python - 3. The :term:`2to3` tool will automatically adapt imports when converting - your sources to Python 3. + 3.0. The :term:`2to3` tool will automatically adapt imports when converting + your sources to 3.0. **Source code:** :source:`Lib/Cookie.py` @@ -22,14 +22,8 @@ The module formerly strictly applied the parsing rules described in the :rfc:`2109` and :rfc:`2068` specifications. It has since been discovered that -MSIE 3.0x doesn't follow the character rules outlined in those specs and also -many current day browsers and servers have relaxed parsing rules when comes to -Cookie handling. As a result, the parsing rules used are a bit less strict. - -The character set, :data:`string.ascii_letters`, :data:`string.digits` and -``!#$%&'*+-.^_`|~`` denote the set of valid characters allowed by this module -in Cookie name (as :attr:`~Morsel.key`). - +MSIE 3.0x doesn't follow the character rules outlined in those specs. As a +result, the parsing rules used are a bit less strict. .. note:: diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/library/cookielib.rst --- a/Doc/library/cookielib.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/library/cookielib.rst Sun Jul 20 10:52:46 2014 -0400 @@ -8,8 +8,8 @@ .. note:: The :mod:`cookielib` module has been renamed to :mod:`http.cookiejar` in - Python 3. The :term:`2to3` tool will automatically adapt imports when - converting your sources to Python 3. + Python 3.0. The :term:`2to3` tool will automatically adapt imports when + converting your sources to 3.0. .. versionadded:: 2.4 @@ -98,7 +98,7 @@ Netscape and RFC 2965 cookies. By default, RFC 2109 cookies (ie. cookies received in a :mailheader:`Set-Cookie` header with a version cookie-attribute of 1) are treated according to the RFC 2965 rules. However, if RFC 2965 handling - is turned off or :attr:`rfc2109_as_netscape` is ``True``, RFC 2109 cookies are + is turned off or :attr:`rfc2109_as_netscape` is True, RFC 2109 cookies are 'downgraded' by the :class:`CookieJar` instance to Netscape cookies, by setting the :attr:`version` attribute of the :class:`Cookie` instance to 0. :class:`DefaultCookiePolicy` also provides some parameters to allow some @@ -308,7 +308,7 @@ ----------------------------------------------------------- The following :class:`CookieJar` subclasses are provided for reading and -writing. +writing . .. class:: MozillaCookieJar(filename, delayload=None, policy=None) @@ -652,7 +652,7 @@ .. attribute:: Cookie.secure - ``True`` if cookie should only be returned over a secure connection. + True if cookie should only be returned over a secure connection. .. attribute:: Cookie.expires @@ -663,7 +663,7 @@ .. attribute:: Cookie.discard - ``True`` if this is a session cookie. + True if this is a session cookie. .. attribute:: Cookie.comment @@ -680,7 +680,7 @@ .. attribute:: Cookie.rfc2109 - ``True`` if this cookie was received as an RFC 2109 cookie (ie. the cookie + True if this cookie was received as an RFC 2109 cookie (ie. the cookie arrived in a :mailheader:`Set-Cookie` header, and the value of the Version cookie-attribute in that header was 1). This attribute is provided because :mod:`cookielib` may 'downgrade' RFC 2109 cookies to Netscape cookies, in @@ -691,18 +691,18 @@ .. attribute:: Cookie.port_specified - ``True`` if a port or set of ports was explicitly specified by the server (in the + True if a port or set of ports was explicitly specified by the server (in the :mailheader:`Set-Cookie` / :mailheader:`Set-Cookie2` header). .. attribute:: Cookie.domain_specified - ``True`` if a domain was explicitly specified by the server. + True if a domain was explicitly specified by the server. .. attribute:: Cookie.domain_initial_dot - ``True`` if the domain explicitly specified by the server began with a dot + True if the domain explicitly specified by the server began with a dot (``'.'``). Cookies may have additional non-standard cookie-attributes. These may be @@ -729,7 +729,7 @@ .. method:: Cookie.is_expired([now=None]) - ``True`` if cookie has passed the time at which the server requested it should + True if cookie has passed the time at which the server requested it should expire. If *now* is given (in seconds since the epoch), return whether the cookie has expired at the specified time. diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/library/copy.rst --- a/Doc/library/copy.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/library/copy.rst Sun Jul 20 10:52:46 2014 -0400 @@ -4,11 +4,7 @@ .. module:: copy :synopsis: Shallow and deep copy operations. -Assignment statements in Python do not copy objects, they create bindings -between a target and an object. For collections that are mutable or contain -mutable items, a copy is sometimes needed so one can change one copy without -changing the other. This module provides generic shallow and deep copy -operations (explained below). +This module provides generic (shallow and deep) copying operations. Interface summary: diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/library/copy_reg.rst --- a/Doc/library/copy_reg.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/library/copy_reg.rst Sun Jul 20 10:52:46 2014 -0400 @@ -5,20 +5,20 @@ :synopsis: Register pickle support functions. .. note:: - The :mod:`copy_reg` module has been renamed to :mod:`copyreg` in Python 3. + The :mod:`copy_reg` module has been renamed to :mod:`copyreg` in Python 3.0. The :term:`2to3` tool will automatically adapt imports when converting your - sources to Python 3. + sources to 3.0. .. index:: module: pickle module: cPickle module: copy -The :mod:`copy_reg` module offers a way to define fuctions used while pickling -specific objects. The :mod:`pickle`, :mod:`cPickle`, and :mod:`copy` modules -use those functions when pickling/copying those objects. The module provides -configuration information about object constructors which are not classes. -Such constructors may be factory functions or class instances. +The :mod:`copy_reg` module provides support for the :mod:`pickle` and +:mod:`cPickle` modules. The :mod:`copy` module is likely to use this in the +future as well. It provides configuration information about object constructors +which are not classes. Such constructors may be factory functions or class +instances. .. function:: constructor(object) @@ -43,24 +43,3 @@ See the :mod:`pickle` module for more details on the interface expected of *function* and *constructor*. -Example -------- - -The example below would like to show how to register a pickle function and how -it will be used: - - >>> import copy_reg, copy, pickle - >>> class C(object): - ... def __init__(self, a): - ... self.a = a - ... - >>> def pickle_c(c): - ... print("pickling a C instance...") - ... return C, (c.a,) - ... - >>> copy_reg.pickle(C, pickle_c) - >>> c = C(1) - >>> d = copy.copy(c) - pickling a C instance... - >>> p = pickle.dumps(c) - pickling a C instance... diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/library/csv.rst --- a/Doc/library/csv.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/library/csv.rst Sun Jul 20 10:52:46 2014 -0400 @@ -40,7 +40,7 @@ This version of the :mod:`csv` module doesn't support Unicode input. Also, there are currently some issues regarding ASCII NUL characters. Accordingly, all input should be UTF-8 or printable ASCII to be safe; see the examples in - section :ref:`csv-examples`. + section :ref:`csv-examples`. These restrictions will be removed in the future. .. seealso:: @@ -57,7 +57,7 @@ The :mod:`csv` module defines the following functions: -.. function:: reader(csvfile, dialect='excel', **fmtparams) +.. function:: reader(csvfile[, dialect='excel'][, fmtparam]) Return a reader object which will iterate over lines in the given *csvfile*. *csvfile* can be any object which supports the :term:`iterator` protocol and returns a @@ -67,7 +67,7 @@ *dialect* parameter can be given which is used to define a set of parameters specific to a particular CSV dialect. It may be an instance of a subclass of the :class:`Dialect` class or one of the strings returned by the - :func:`list_dialects` function. The other optional *fmtparams* keyword arguments + :func:`list_dialects` function. The other optional *fmtparam* keyword arguments can be given to override individual formatting parameters in the current dialect. For full details about the dialect and formatting parameters, see section :ref:`csv-fmt-params`. @@ -78,10 +78,9 @@ A short usage example:: >>> import csv - >>> with open('eggs.csv', 'rb') as csvfile: - ... spamreader = csv.reader(csvfile, delimiter=' ', quotechar='|') - ... for row in spamreader: - ... print ', '.join(row) + >>> spamReader = csv.reader(open('eggs.csv', 'rb'), delimiter=' ', quotechar='|') + >>> for row in spamReader: + ... print ', '.join(row) Spam, Spam, Spam, Spam, Spam, Baked Beans Spam, Lovely Spam, Wonderful Spam @@ -95,7 +94,7 @@ be split into lines in a manner which preserves the newline characters. -.. function:: writer(csvfile, dialect='excel', **fmtparams) +.. function:: writer(csvfile[, dialect='excel'][, fmtparam]) Return a writer object responsible for converting the user's data into delimited strings on the given file-like object. *csvfile* can be any object with a @@ -104,7 +103,7 @@ parameter can be given which is used to define a set of parameters specific to a particular CSV dialect. It may be an instance of a subclass of the :class:`Dialect` class or one of the strings returned by the - :func:`list_dialects` function. The other optional *fmtparams* keyword arguments + :func:`list_dialects` function. The other optional *fmtparam* keyword arguments can be given to override individual formatting parameters in the current dialect. For full details about the dialect and formatting parameters, see section :ref:`csv-fmt-params`. To make it @@ -116,19 +115,18 @@ A short usage example:: - import csv - with open('eggs.csv', 'wb') as csvfile: - spamwriter = csv.writer(csvfile, delimiter=' ', - quotechar='|', quoting=csv.QUOTE_MINIMAL) - spamwriter.writerow(['Spam'] * 5 + ['Baked Beans']) - spamwriter.writerow(['Spam', 'Lovely Spam', 'Wonderful Spam']) + >>> import csv + >>> spamWriter = csv.writer(open('eggs.csv', 'wb'), delimiter=' ', + ... quotechar='|', quoting=csv.QUOTE_MINIMAL) + >>> spamWriter.writerow(['Spam'] * 5 + ['Baked Beans']) + >>> spamWriter.writerow(['Spam', 'Lovely Spam', 'Wonderful Spam']) -.. function:: register_dialect(name[, dialect], **fmtparams) +.. function:: register_dialect(name[, dialect][, fmtparam]) Associate *dialect* with *name*. *name* must be a string or Unicode object. The dialect can be specified either by passing a sub-class of :class:`Dialect`, or - by *fmtparams* keyword arguments, or both, with keyword arguments overriding + by *fmtparam* keyword arguments, or both, with keyword arguments overriding parameters of the dialect. For full details about the dialect and formatting parameters, see section :ref:`csv-fmt-params`. @@ -164,43 +162,36 @@ The :mod:`csv` module defines the following classes: -.. class:: DictReader(csvfile, fieldnames=None, restkey=None, restval=None, \ - dialect='excel', *args, **kwds) +.. class:: DictReader(csvfile[, fieldnames=None[, restkey=None[, restval=None[, dialect='excel'[, *args, **kwds]]]]]) - Create an object which operates like a regular reader but maps the - information read into a dict whose keys are given by the optional - *fieldnames* parameter. The *fieldnames* parameter is a :ref:`sequence - ` whose elements are associated with the - fields of the input data in order. These elements become the keys of the - resulting dictionary. If the *fieldnames* parameter is omitted, the values - in the first row of the *csvfile* will be used as the fieldnames. If the - row read has more fields than the fieldnames sequence, the remaining data is - added as a sequence keyed by the value of *restkey*. If the row read has - fewer fields than the fieldnames sequence, the remaining keys take the value - of the optional *restval* parameter. Any other optional or keyword - arguments are passed to the underlying :class:`reader` instance. + Create an object which operates like a regular reader but maps the information + read into a dict whose keys are given by the optional *fieldnames* parameter. + If the *fieldnames* parameter is omitted, the values in the first row of the + *csvfile* will be used as the fieldnames. If the row read has more fields + than the fieldnames sequence, the remaining data is added as a sequence + keyed by the value of *restkey*. If the row read has fewer fields than the + fieldnames sequence, the remaining keys take the value of the optional + *restval* parameter. Any other optional or keyword arguments are passed to + the underlying :class:`reader` instance. -.. class:: DictWriter(csvfile, fieldnames, restval='', extrasaction='raise', \ - dialect='excel', *args, **kwds) +.. class:: DictWriter(csvfile, fieldnames[, restval=''[, extrasaction='raise'[, dialect='excel'[, *args, **kwds]]]]) - Create an object which operates like a regular writer but maps dictionaries - onto output rows. The *fieldnames* parameter is a :ref:`sequence - ` of keys that identify the order in - which values in the dictionary passed to the :meth:`writerow` method are - written to the *csvfile*. The optional *restval* parameter specifies the - value to be written if the dictionary is missing a key in *fieldnames*. If - the dictionary passed to the :meth:`writerow` method contains a key not - found in *fieldnames*, the optional *extrasaction* parameter indicates what - action to take. If it is set to ``'raise'`` a :exc:`ValueError` is raised. - If it is set to ``'ignore'``, extra values in the dictionary are ignored. - Any other optional or keyword arguments are passed to the underlying - :class:`writer` instance. + Create an object which operates like a regular writer but maps dictionaries onto + output rows. The *fieldnames* parameter identifies the order in which values in + the dictionary passed to the :meth:`writerow` method are written to the + *csvfile*. The optional *restval* parameter specifies the value to be written + if the dictionary is missing a key in *fieldnames*. If the dictionary passed to + the :meth:`writerow` method contains a key not found in *fieldnames*, the + optional *extrasaction* parameter indicates what action to take. If it is set + to ``'raise'`` a :exc:`ValueError` is raised. If it is set to ``'ignore'``, + extra values in the dictionary are ignored. Any other optional or keyword + arguments are passed to the underlying :class:`writer` instance. - Note that unlike the :class:`DictReader` class, the *fieldnames* parameter - of the :class:`DictWriter` is not optional. Since Python's :class:`dict` - objects are not ordered, there is not enough information available to deduce - the order in which the row should be written to the *csvfile*. + Note that unlike the :class:`DictReader` class, the *fieldnames* parameter of + the :class:`DictWriter` is not optional. Since Python's :class:`dict` objects + are not ordered, there is not enough information available to deduce the order + in which the row should be written to the *csvfile*. .. class:: Dialect @@ -228,7 +219,7 @@ The :class:`Sniffer` class provides two methods: - .. method:: sniff(sample, delimiters=None) + .. method:: sniff(sample[, delimiters=None]) Analyze the given *sample* and return a :class:`Dialect` subclass reflecting the parameters found. If the optional *delimiters* parameter @@ -243,11 +234,11 @@ An example for :class:`Sniffer` use:: - with open('example.csv', 'rb') as csvfile: - dialect = csv.Sniffer().sniff(csvfile.read(1024)) - csvfile.seek(0) - reader = csv.reader(csvfile, dialect) - # ... process CSV file contents here ... + csvfile = open("example.csv", "rb") + dialect = csv.Sniffer().sniff(csvfile.read(1024)) + csvfile.seek(0) + reader = csv.reader(csvfile, dialect) + # ... process CSV file contents here ... The :mod:`csv` module defines the following constants: @@ -362,11 +353,6 @@ The default is :const:`False`. -.. attribute:: Dialect.strict - - When ``True``, raise exception :exc:`Error` on bad CSV input. - The default is ``False``. - Reader Objects -------------- @@ -492,7 +478,7 @@ try: for row in reader: print row - except csv.Error as e: + except csv.Error, e: sys.exit('file %s, line %d: %s' % (filename, reader.line_num, e)) And while the module doesn't directly support parsing strings, it can easily be diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/library/ctypes.rst --- a/Doc/library/ctypes.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/library/ctypes.rst Sun Jul 20 10:52:46 2014 -0400 @@ -40,7 +40,7 @@ loads libraries which export functions using the standard ``cdecl`` calling convention, while *windll* libraries call functions using the ``stdcall`` calling convention. *oledll* also uses the ``stdcall`` calling convention, and -assumes the functions return a Windows :c:type:`HRESULT` error code. The error +assumes the functions return a Windows :ctype:`HRESULT` error code. The error code is used to automatically raise a :class:`WindowsError` exception when the function call fails. @@ -201,9 +201,9 @@ ``None``, integers, longs, byte strings and unicode strings are the only native Python objects that can directly be used as parameters in these function calls. ``None`` is passed as a C ``NULL`` pointer, byte strings and unicode strings are -passed as pointer to the memory block that contains their data (:c:type:`char *` -or :c:type:`wchar_t *`). Python integers and Python longs are passed as the -platforms default C :c:type:`int` type, their value is masked to fit into the C +passed as pointer to the memory block that contains their data (:ctype:`char *` +or :ctype:`wchar_t *`). Python integers and Python longs are passed as the +platforms default C :ctype:`int` type, their value is masked to fit into the C type. Before we move on calling functions with other parameter types, we have to learn @@ -215,50 +215,50 @@ Fundamental data types ^^^^^^^^^^^^^^^^^^^^^^ -:mod:`ctypes` defines a number of primitive C compatible data types: - -+----------------------+------------------------------------------+----------------------------+ -| ctypes type | C type | Python type | -+======================+==========================================+============================+ -| :class:`c_bool` | :c:type:`_Bool` | bool (1) | -+----------------------+------------------------------------------+----------------------------+ -| :class:`c_char` | :c:type:`char` | 1-character string | -+----------------------+------------------------------------------+----------------------------+ -| :class:`c_wchar` | :c:type:`wchar_t` | 1-character unicode string | -+----------------------+------------------------------------------+----------------------------+ -| :class:`c_byte` | :c:type:`char` | int/long | -+----------------------+------------------------------------------+----------------------------+ -| :class:`c_ubyte` | :c:type:`unsigned char` | int/long | -+----------------------+------------------------------------------+----------------------------+ -| :class:`c_short` | :c:type:`short` | int/long | -+----------------------+------------------------------------------+----------------------------+ -| :class:`c_ushort` | :c:type:`unsigned short` | int/long | -+----------------------+------------------------------------------+----------------------------+ -| :class:`c_int` | :c:type:`int` | int/long | -+----------------------+------------------------------------------+----------------------------+ -| :class:`c_uint` | :c:type:`unsigned int` | int/long | -+----------------------+------------------------------------------+----------------------------+ -| :class:`c_long` | :c:type:`long` | int/long | -+----------------------+------------------------------------------+----------------------------+ -| :class:`c_ulong` | :c:type:`unsigned long` | int/long | -+----------------------+------------------------------------------+----------------------------+ -| :class:`c_longlong` | :c:type:`__int64` or :c:type:`long long` | int/long | -+----------------------+------------------------------------------+----------------------------+ -| :class:`c_ulonglong` | :c:type:`unsigned __int64` or | int/long | -| | :c:type:`unsigned long long` | | -+----------------------+------------------------------------------+----------------------------+ -| :class:`c_float` | :c:type:`float` | float | -+----------------------+------------------------------------------+----------------------------+ -| :class:`c_double` | :c:type:`double` | float | -+----------------------+------------------------------------------+----------------------------+ -| :class:`c_longdouble`| :c:type:`long double` | float | -+----------------------+------------------------------------------+----------------------------+ -| :class:`c_char_p` | :c:type:`char *` (NUL terminated) | string or ``None`` | -+----------------------+------------------------------------------+----------------------------+ -| :class:`c_wchar_p` | :c:type:`wchar_t *` (NUL terminated) | unicode or ``None`` | -+----------------------+------------------------------------------+----------------------------+ -| :class:`c_void_p` | :c:type:`void *` | int/long or ``None`` | -+----------------------+------------------------------------------+----------------------------+ +:mod:`ctypes` defines a number of primitive C compatible data types : + ++----------------------+----------------------------------------+----------------------------+ +| ctypes type | C type | Python type | ++======================+========================================+============================+ +| :class:`c_bool` | :ctype:`_Bool` | bool (1) | ++----------------------+----------------------------------------+----------------------------+ +| :class:`c_char` | :ctype:`char` | 1-character string | ++----------------------+----------------------------------------+----------------------------+ +| :class:`c_wchar` | :ctype:`wchar_t` | 1-character unicode string | ++----------------------+----------------------------------------+----------------------------+ +| :class:`c_byte` | :ctype:`char` | int/long | ++----------------------+----------------------------------------+----------------------------+ +| :class:`c_ubyte` | :ctype:`unsigned char` | int/long | ++----------------------+----------------------------------------+----------------------------+ +| :class:`c_short` | :ctype:`short` | int/long | ++----------------------+----------------------------------------+----------------------------+ +| :class:`c_ushort` | :ctype:`unsigned short` | int/long | ++----------------------+----------------------------------------+----------------------------+ +| :class:`c_int` | :ctype:`int` | int/long | ++----------------------+----------------------------------------+----------------------------+ +| :class:`c_uint` | :ctype:`unsigned int` | int/long | ++----------------------+----------------------------------------+----------------------------+ +| :class:`c_long` | :ctype:`long` | int/long | ++----------------------+----------------------------------------+----------------------------+ +| :class:`c_ulong` | :ctype:`unsigned long` | int/long | ++----------------------+----------------------------------------+----------------------------+ +| :class:`c_longlong` | :ctype:`__int64` or :ctype:`long long` | int/long | ++----------------------+----------------------------------------+----------------------------+ +| :class:`c_ulonglong` | :ctype:`unsigned __int64` or | int/long | +| | :ctype:`unsigned long long` | | ++----------------------+----------------------------------------+----------------------------+ +| :class:`c_float` | :ctype:`float` | float | ++----------------------+----------------------------------------+----------------------------+ +| :class:`c_double` | :ctype:`double` | float | ++----------------------+----------------------------------------+----------------------------+ +| :class:`c_longdouble`| :ctype:`long double` | float | ++----------------------+----------------------------------------+----------------------------+ +| :class:`c_char_p` | :ctype:`char *` (NUL terminated) | string or ``None`` | ++----------------------+----------------------------------------+----------------------------+ +| :class:`c_wchar_p` | :ctype:`wchar_t *` (NUL terminated) | unicode or ``None`` | ++----------------------+----------------------------------------+----------------------------+ +| :class:`c_void_p` | :ctype:`void *` | int/long or ``None`` | ++----------------------+----------------------------------------+----------------------------+ (1) The constructor accepts any object with a truth value. @@ -329,7 +329,7 @@ The :func:`create_string_buffer` function replaces the :func:`c_buffer` function (which is still available as an alias), as well as the :func:`c_string` function from earlier ctypes releases. To create a mutable memory block containing -unicode characters of the C type :c:type:`wchar_t` use the +unicode characters of the C type :ctype:`wchar_t` use the :func:`create_unicode_buffer` function. @@ -440,7 +440,7 @@ Return types ^^^^^^^^^^^^ -By default functions are assumed to return the C :c:type:`int` type. Other +By default functions are assumed to return the C :ctype:`int` type. Other return types can be specified by setting the :attr:`restype` attribute of the function object. @@ -568,8 +568,8 @@ ValueError: too many initializers >>> -You can, however, build much more complicated structures. A structure can -itself contain other structures by using a structure as a field type. +You can, however, build much more complicated structures. Structures can itself +contain other structures by using a structure as a field type. Here is a RECT structure which contains two POINTs named *upperleft* and *lowerright*:: @@ -602,13 +602,6 @@ .. _ctypes-structureunion-alignment-byte-order: -.. warning:: - - :mod:`ctypes` does not support passing unions or structures with bit-fields - to functions by value. While this may work on 32-bit x86, it's not - guaranteed by the library to work in the general case. Unions and - structures with bit-fields should always be passed to functions by pointer. - Structure/union alignment and byte order ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -823,11 +816,6 @@ 3 >>> -In addition, if a function argument is explicitly declared to be a pointer type -(such as ``POINTER(c_int)``) in :attr:`argtypes`, an object of the pointed -type (``c_int`` in this case) can be passed to the function. ctypes will apply -the required :func:`byref` conversion in this case automatically. - To set a POINTER type field to ``NULL``, you can assign ``None``:: >>> bar.values = None @@ -1080,18 +1068,12 @@ 1 5 7 33 99 >>> -.. note:: - - Make sure you keep references to :func:`CFUNCTYPE` objects as long as they - are used from C code. :mod:`ctypes` doesn't, and if you don't, they may be - garbage collected, crashing your program when a callback is made. - - Also, note that if the callback function is called in a thread created - outside of Python's control (e.g. by the foreign code that calls the - callback), ctypes creates a new dummy Python thread on every invocation. This - behavior is correct for most purposes, but it means that values stored with - `threading.local` will *not* survive across different callbacks, even when - those calls are made from the same C thread. +**Important note for callback functions:** + +Make sure you keep references to CFUNCTYPE objects as long as they are used from +C code. :mod:`ctypes` doesn't, and if you don't, they may be garbage collected, +crashing your program when a callback is made. + .. _ctypes-accessing-values-exported-from-dlls: @@ -1171,8 +1153,8 @@ Surprises ^^^^^^^^^ -There are some edge cases in :mod:`ctypes` where you might expect something -other than what actually happens. +There are some edges in :mod:`ctypes` where you may be expect something else than +what actually happens. Consider the following example:: @@ -1339,7 +1321,7 @@ like ``find_library("c")`` will fail and return ``None``. If wrapping a shared library with :mod:`ctypes`, it *may* be better to determine -the shared library name at development time, and hardcode that into the wrapper +the shared library name at development type, and hardcode that into the wrapper module instead of using :func:`find_library` to locate the library at runtime. @@ -1356,7 +1338,7 @@ Instances of this class represent loaded shared libraries. Functions in these libraries use the standard C calling convention, and are assumed to return - :c:type:`int`. + :ctype:`int`. .. class:: OleDLL(name, mode=DEFAULT_MODE, handle=None, use_errno=False, use_last_error=False) @@ -1373,7 +1355,7 @@ Windows only: Instances of this class represent loaded shared libraries, functions in these libraries use the ``stdcall`` calling convention, and are - assumed to return :c:type:`int` by default. + assumed to return :ctype:`int` by default. On Windows CE only the standard calling convention is used, for convenience the :class:`WinDLL` and :class:`OleDLL` use the standard calling convention on this @@ -1518,7 +1500,7 @@ An instance of :class:`PyDLL` that exposes Python C API functions as attributes. Note that all these functions are assumed to return C - :c:type:`int`, which is of course not always the truth, so you have to assign + :ctype:`int`, which is of course not always the truth, so you have to assign the correct :attr:`restype` attribute to use these functions. @@ -1548,10 +1530,10 @@ .. attribute:: restype Assign a ctypes type to specify the result type of the foreign function. - Use ``None`` for :c:type:`void`, a function not returning anything. + Use ``None`` for :ctype:`void`, a function not returning anything. It is possible to assign a callable Python object that is not a ctypes - type, in this case the function is assumed to return a C :c:type:`int`, and + type, in this case the function is assumed to return a C :ctype:`int`, and the callable will be called with this integer, allowing to do further processing or error checking. Using this is deprecated, for more flexible post processing or error checking use a ctypes data type as @@ -1720,7 +1702,7 @@ WINUSERAPI int WINAPI MessageBoxA( - HWND hWnd, + HWND hWnd , LPCSTR lpText, LPCSTR lpCaption, UINT uType); @@ -2012,8 +1994,8 @@ .. function:: sizeof(obj_or_type) - Returns the size in bytes of a ctypes type or instance memory buffer. - Does the same as the C ``sizeof`` operator. + Returns the size in bytes of a ctypes type or instance memory buffer. Does the + same as the C ``sizeof()`` function. .. function:: string_at(address[, size]) @@ -2177,21 +2159,21 @@ .. class:: c_byte - Represents the C :c:type:`signed char` datatype, and interprets the value as + Represents the C :ctype:`signed char` datatype, and interprets the value as small integer. The constructor accepts an optional integer initializer; no overflow checking is done. .. class:: c_char - Represents the C :c:type:`char` datatype, and interprets the value as a single + Represents the C :ctype:`char` datatype, and interprets the value as a single character. The constructor accepts an optional string initializer, the length of the string must be exactly one character. .. class:: c_char_p - Represents the C :c:type:`char *` datatype when it points to a zero-terminated + Represents the C :ctype:`char *` datatype when it points to a zero-terminated string. For a general character pointer that may also point to binary data, ``POINTER(c_char)`` must be used. The constructor accepts an integer address, or a string. @@ -2199,13 +2181,13 @@ .. class:: c_double - Represents the C :c:type:`double` datatype. The constructor accepts an + Represents the C :ctype:`double` datatype. The constructor accepts an optional float initializer. .. class:: c_longdouble - Represents the C :c:type:`long double` datatype. The constructor accepts an + Represents the C :ctype:`long double` datatype. The constructor accepts an optional float initializer. On platforms where ``sizeof(long double) == sizeof(double)`` it is an alias to :class:`c_double`. @@ -2213,151 +2195,151 @@ .. class:: c_float - Represents the C :c:type:`float` datatype. The constructor accepts an + Represents the C :ctype:`float` datatype. The constructor accepts an optional float initializer. .. class:: c_int - Represents the C :c:type:`signed int` datatype. The constructor accepts an + Represents the C :ctype:`signed int` datatype. The constructor accepts an optional integer initializer; no overflow checking is done. On platforms where ``sizeof(int) == sizeof(long)`` it is an alias to :class:`c_long`. .. class:: c_int8 - Represents the C 8-bit :c:type:`signed int` datatype. Usually an alias for + Represents the C 8-bit :ctype:`signed int` datatype. Usually an alias for :class:`c_byte`. .. class:: c_int16 - Represents the C 16-bit :c:type:`signed int` datatype. Usually an alias for + Represents the C 16-bit :ctype:`signed int` datatype. Usually an alias for :class:`c_short`. .. class:: c_int32 - Represents the C 32-bit :c:type:`signed int` datatype. Usually an alias for + Represents the C 32-bit :ctype:`signed int` datatype. Usually an alias for :class:`c_int`. .. class:: c_int64 - Represents the C 64-bit :c:type:`signed int` datatype. Usually an alias for + Represents the C 64-bit :ctype:`signed int` datatype. Usually an alias for :class:`c_longlong`. .. class:: c_long - Represents the C :c:type:`signed long` datatype. The constructor accepts an + Represents the C :ctype:`signed long` datatype. The constructor accepts an optional integer initializer; no overflow checking is done. .. class:: c_longlong - Represents the C :c:type:`signed long long` datatype. The constructor accepts + Represents the C :ctype:`signed long long` datatype. The constructor accepts an optional integer initializer; no overflow checking is done. .. class:: c_short - Represents the C :c:type:`signed short` datatype. The constructor accepts an + Represents the C :ctype:`signed short` datatype. The constructor accepts an optional integer initializer; no overflow checking is done. .. class:: c_size_t - Represents the C :c:type:`size_t` datatype. + Represents the C :ctype:`size_t` datatype. .. class:: c_ssize_t - Represents the C :c:type:`ssize_t` datatype. + Represents the C :ctype:`ssize_t` datatype. .. versionadded:: 2.7 .. class:: c_ubyte - Represents the C :c:type:`unsigned char` datatype, it interprets the value as + Represents the C :ctype:`unsigned char` datatype, it interprets the value as small integer. The constructor accepts an optional integer initializer; no overflow checking is done. .. class:: c_uint - Represents the C :c:type:`unsigned int` datatype. The constructor accepts an + Represents the C :ctype:`unsigned int` datatype. The constructor accepts an optional integer initializer; no overflow checking is done. On platforms where ``sizeof(int) == sizeof(long)`` it is an alias for :class:`c_ulong`. .. class:: c_uint8 - Represents the C 8-bit :c:type:`unsigned int` datatype. Usually an alias for + Represents the C 8-bit :ctype:`unsigned int` datatype. Usually an alias for :class:`c_ubyte`. .. class:: c_uint16 - Represents the C 16-bit :c:type:`unsigned int` datatype. Usually an alias for + Represents the C 16-bit :ctype:`unsigned int` datatype. Usually an alias for :class:`c_ushort`. .. class:: c_uint32 - Represents the C 32-bit :c:type:`unsigned int` datatype. Usually an alias for + Represents the C 32-bit :ctype:`unsigned int` datatype. Usually an alias for :class:`c_uint`. .. class:: c_uint64 - Represents the C 64-bit :c:type:`unsigned int` datatype. Usually an alias for + Represents the C 64-bit :ctype:`unsigned int` datatype. Usually an alias for :class:`c_ulonglong`. .. class:: c_ulong - Represents the C :c:type:`unsigned long` datatype. The constructor accepts an + Represents the C :ctype:`unsigned long` datatype. The constructor accepts an optional integer initializer; no overflow checking is done. .. class:: c_ulonglong - Represents the C :c:type:`unsigned long long` datatype. The constructor + Represents the C :ctype:`unsigned long long` datatype. The constructor accepts an optional integer initializer; no overflow checking is done. .. class:: c_ushort - Represents the C :c:type:`unsigned short` datatype. The constructor accepts + Represents the C :ctype:`unsigned short` datatype. The constructor accepts an optional integer initializer; no overflow checking is done. .. class:: c_void_p - Represents the C :c:type:`void *` type. The value is represented as integer. + Represents the C :ctype:`void *` type. The value is represented as integer. The constructor accepts an optional integer initializer. .. class:: c_wchar - Represents the C :c:type:`wchar_t` datatype, and interprets the value as a + Represents the C :ctype:`wchar_t` datatype, and interprets the value as a single character unicode string. The constructor accepts an optional string initializer, the length of the string must be exactly one character. .. class:: c_wchar_p - Represents the C :c:type:`wchar_t *` datatype, which must be a pointer to a + Represents the C :ctype:`wchar_t *` datatype, which must be a pointer to a zero-terminated wide character string. The constructor accepts an integer address, or a string. .. class:: c_bool - Represent the C :c:type:`bool` datatype (more accurately, :c:type:`_Bool` from - C99). Its value can be ``True`` or ``False``, and the constructor accepts any object + Represent the C :ctype:`bool` datatype (more accurately, :ctype:`_Bool` from + C99). Its value can be True or False, and the constructor accepts any object that has a truth value. .. versionadded:: 2.6 @@ -2365,18 +2347,18 @@ .. class:: HRESULT - Windows only: Represents a :c:type:`HRESULT` value, which contains success or + Windows only: Represents a :ctype:`HRESULT` value, which contains success or error information for a function or method call. .. class:: py_object - Represents the C :c:type:`PyObject *` datatype. Calling this without an - argument creates a ``NULL`` :c:type:`PyObject *` pointer. + Represents the C :ctype:`PyObject *` datatype. Calling this without an + argument creates a ``NULL`` :ctype:`PyObject *` pointer. The :mod:`ctypes.wintypes` module provides quite some other Windows specific -data types, for example :c:type:`HWND`, :c:type:`WPARAM`, or :c:type:`DWORD`. Some -useful structures like :c:type:`MSG` or :c:type:`RECT` are also defined. +data types, for example :ctype:`HWND`, :ctype:`WPARAM`, or :ctype:`DWORD`. Some +useful structures like :ctype:`MSG` or :ctype:`RECT` are also defined. .. _ctypes-structured-data-types: diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/library/curses.rst --- a/Doc/library/curses.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/library/curses.rst Sun Jul 20 10:52:46 2014 -0400 @@ -48,7 +48,7 @@ Tutorial material on using curses with Python, by Andrew Kuchling and Eric Raymond. - The :source:`Demo/curses/` directory in the Python source distribution contains + The :file:`Demo/curses/` directory in the Python source distribution contains some example programs using the curses bindings provided by this module. @@ -380,8 +380,7 @@ is to be displayed. -.. function:: newwin(nlines, ncols) - newwin(nlines, ncols, begin_y, begin_x) +.. function:: newwin([nlines, ncols,] begin_y, begin_x) Return a new window, whose left-upper corner is at ``(begin_y, begin_x)``, and whose height/width is *nlines*/*ncols*. @@ -649,8 +648,7 @@ the following methods: -.. method:: window.addch(ch[, attr]) - window.addch(y, x, ch[, attr]) +.. method:: window.addch([y, x,] ch[, attr]) .. note:: @@ -664,15 +662,13 @@ position and attributes are the current settings for the window object. -.. method:: window.addnstr(str, n[, attr]) - window.addnstr(y, x, str, n[, attr]) +.. method:: window.addnstr([y, x,] str, n[, attr]) Paint at most *n* characters of the string *str* at ``(y, x)`` with attributes *attr*, overwriting anything previously on the display. -.. method:: window.addstr(str[, attr]) - window.addstr(y, x, str[, attr]) +.. method:: window.addstr([y, x,] str[, attr]) Paint the string *str* at ``(y, x)`` with attributes *attr*, overwriting anything previously on the display. @@ -759,10 +755,7 @@ *bs* are *horch*. The default corner characters are always used by this function. -.. method:: window.chgat(attr) - window.chgat(num, attr) - window.chgat(y, x, attr) - window.chgat(y, x, num, attr) +.. method:: window.chgat([y, x, ] [num,] attr) Set the attributes of *num* characters at the current cursor position, or at position ``(y, x)`` if supplied. If no value of *num* is given or *num* = -1, @@ -811,8 +804,7 @@ Delete the line under the cursor. All following lines are moved up by one line. -.. method:: window.derwin(begin_y, begin_x) - window.derwin(nlines, ncols, begin_y, begin_x) +.. method:: window.derwin([nlines, ncols,] begin_y, begin_x) An abbreviation for "derive window", :meth:`derwin` is the same as calling :meth:`subwin`, except that *begin_y* and *begin_x* are relative to the origin @@ -887,8 +879,7 @@ upper-left corner. -.. method:: window.hline(ch, n) - window.hline(y, x, ch, n) +.. method:: window.hline([y, x,] ch, n) Display a horizontal line starting at ``(y, x)`` with length *n* consisting of the character *ch*. @@ -922,8 +913,7 @@ the character proper, and upper bits are the attributes. -.. method:: window.insch(ch[, attr]) - window.insch(y, x, ch[, attr]) +.. method:: window.insch([y, x,] ch[, attr]) Paint character *ch* at ``(y, x)`` with attributes *attr*, moving the line from position *x* right by one character. @@ -944,8 +934,7 @@ line. -.. method:: window.insnstr(str, n[, attr]) - window.insnstr(y, x, str, n[, attr]) +.. method:: window.insnstr([y, x,] str, n [, attr]) Insert a character string (as many characters as will fit on the line) before the character under the cursor, up to *n* characters. If *n* is zero or @@ -954,8 +943,7 @@ The cursor position does not change (after moving to *y*, *x*, if specified). -.. method:: window.insstr(str[, attr]) - window.insstr(y, x, str[, attr]) +.. method:: window.insstr([y, x, ] str [, attr]) Insert a character string (as many characters as will fit on the line) before the character under the cursor. All characters to the right of the cursor are @@ -963,8 +951,7 @@ position does not change (after moving to *y*, *x*, if specified). -.. method:: window.instr([n]) - window.instr(y, x[, n]) +.. method:: window.instr([y, x] [, n]) Return a string of characters, extracted from the window starting at the current cursor position, or at *y*, *x* if specified. Attributes are stripped @@ -1139,15 +1126,13 @@ Turn on attribute *A_STANDOUT*. -.. method:: window.subpad(begin_y, begin_x) - window.subpad(nlines, ncols, begin_y, begin_x) +.. method:: window.subpad([nlines, ncols,] begin_y, begin_x) Return a sub-window, whose upper-left corner is at ``(begin_y, begin_x)``, and whose width/height is *ncols*/*nlines*. -.. method:: window.subwin(begin_y, begin_x) - window.subwin(nlines, ncols, begin_y, begin_x) +.. method:: window.subwin([nlines, ncols,] begin_y, begin_x) Return a sub-window, whose upper-left corner is at ``(begin_y, begin_x)``, and whose width/height is *ncols*/*nlines*. @@ -1204,8 +1189,7 @@ :meth:`refresh`. -.. method:: window.vline(ch, n) - window.vline(y, x, ch, n) +.. method:: window.vline([y, x,] ch, n) Display a vertical line starting at ``(y, x)`` with length *n* consisting of the character *ch*. diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/library/datetime.rst --- a/Doc/library/datetime.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/library/datetime.rst Sun Jul 20 10:52:46 2014 -0400 @@ -14,46 +14,39 @@ The :mod:`datetime` module supplies classes for manipulating dates and times in both simple and complex ways. While date and time arithmetic is supported, the focus of the implementation is on efficient attribute extraction for output -formatting and manipulation. For related functionality, see also the -:mod:`time` and :mod:`calendar` modules. +formatting and manipulation. For related +functionality, see also the :mod:`time` and :mod:`calendar` modules. -There are two kinds of date and time objects: "naive" and "aware". +There are two kinds of date and time objects: "naive" and "aware". This +distinction refers to whether the object has any notion of time zone, daylight +saving time, or other kind of algorithmic or political time adjustment. Whether +a naive :class:`datetime` object represents Coordinated Universal Time (UTC), +local time, or time in some other timezone is purely up to the program, just +like it's up to the program whether a particular number represents metres, +miles, or mass. Naive :class:`datetime` objects are easy to understand and to +work with, at the cost of ignoring some aspects of reality. -An aware object has sufficient knowledge of applicable algorithmic and -political time adjustments, such as time zone and daylight saving time -information, to locate itself relative to other aware objects. An aware object -is used to represent a specific moment in time that is not open to -interpretation [#]_. - -A naive object does not contain enough information to unambiguously locate -itself relative to other date/time objects. Whether a naive object represents -Coordinated Universal Time (UTC), local time, or time in some other timezone is -purely up to the program, just like it's up to the program whether a particular -number represents metres, miles, or mass. Naive objects are easy to understand -and to work with, at the cost of ignoring some aspects of reality. - -For applications requiring aware objects, :class:`.datetime` and :class:`.time` -objects have an optional time zone information attribute, :attr:`tzinfo`, that -can be set to an instance of a subclass of the abstract :class:`tzinfo` class. -These :class:`tzinfo` objects capture information about the offset from UTC -time, the time zone name, and whether Daylight Saving Time is in effect. Note -that no concrete :class:`tzinfo` classes are supplied by the :mod:`datetime` -module. Supporting timezones at whatever level of detail is required is up to -the application. The rules for time adjustment across the world are more -political than rational, and there is no standard suitable for every -application. +For applications requiring more, :class:`datetime` and :class:`time` objects +have an optional time zone information attribute, :attr:`tzinfo`, that can be +set to an instance of a subclass of the abstract :class:`tzinfo` class. These +:class:`tzinfo` objects capture information about the offset from UTC time, the +time zone name, and whether Daylight Saving Time is in effect. Note that no +concrete :class:`tzinfo` classes are supplied by the :mod:`datetime` module. +Supporting timezones at whatever level of detail is required is up to the +application. The rules for time adjustment across the world are more political +than rational, and there is no standard suitable for every application. The :mod:`datetime` module exports the following constants: .. data:: MINYEAR - The smallest year number allowed in a :class:`date` or :class:`.datetime` object. + The smallest year number allowed in a :class:`date` or :class:`datetime` object. :const:`MINYEAR` is ``1``. .. data:: MAXYEAR - The largest year number allowed in a :class:`date` or :class:`.datetime` object. + The largest year number allowed in a :class:`date` or :class:`datetime` object. :const:`MAXYEAR` is ``9999``. @@ -97,14 +90,14 @@ .. class:: timedelta :noindex: - A duration expressing the difference between two :class:`date`, :class:`.time`, - or :class:`.datetime` instances to microsecond resolution. + A duration expressing the difference between two :class:`date`, :class:`time`, + or :class:`datetime` instances to microsecond resolution. .. class:: tzinfo An abstract base class for time zone information objects. These are used by the - :class:`.datetime` and :class:`.time` classes to provide a customizable notion of + :class:`datetime` and :class:`time` classes to provide a customizable notion of time adjustment (for example, to account for time zone and/or daylight saving time). @@ -112,13 +105,10 @@ Objects of the :class:`date` type are always naive. -An object of type :class:`.time` or :class:`.datetime` may be naive or aware. -A :class:`.datetime` object *d* is aware if ``d.tzinfo`` is not ``None`` and -``d.tzinfo.utcoffset(d)`` does not return ``None``. If ``d.tzinfo`` is -``None``, or if ``d.tzinfo`` is not ``None`` but ``d.tzinfo.utcoffset(d)`` -returns ``None``, *d* is naive. A :class:`.time` object *t* is aware -if ``t.tzinfo`` is not ``None`` and ``t.tzinfo.utcoffset(None)`` does not return -``None``. Otherwise, *t* is naive. +An object *d* of type :class:`time` or :class:`datetime` may be naive or aware. +*d* is aware if ``d.tzinfo`` is not ``None`` and ``d.tzinfo.utcoffset(d)`` does +not return ``None``. If ``d.tzinfo`` is ``None``, or if ``d.tzinfo`` is not +``None`` but ``d.tzinfo.utcoffset(d)`` returns ``None``, *d* is naive. The distinction between naive and aware doesn't apply to :class:`timedelta` objects. @@ -279,7 +269,7 @@ -1 day, 19:00:00 In addition to the operations listed above :class:`timedelta` objects support -certain additions and subtractions with :class:`date` and :class:`.datetime` +certain additions and subtractions with :class:`date` and :class:`datetime` objects (see below). Comparisons of :class:`timedelta` objects are supported with the @@ -370,7 +360,7 @@ Return the local date corresponding to the POSIX timestamp, such as is returned by :func:`time.time`. This may raise :exc:`ValueError`, if the timestamp is out - of the range of values supported by the platform C :c:func:`localtime` function. + of the range of values supported by the platform C :cfunc:`localtime` function. It's common for this to be restricted to years from 1970 through 2038. Note that on non-POSIX systems that include leap seconds in their notion of a timestamp, leap seconds are ignored by :meth:`fromtimestamp`. @@ -544,23 +534,15 @@ Return a string representing the date, for example ``date(2002, 12, 4).ctime() == 'Wed Dec 4 00:00:00 2002'``. ``d.ctime()`` is equivalent to ``time.ctime(time.mktime(d.timetuple()))`` on platforms where the native C - :c:func:`ctime` function (which :func:`time.ctime` invokes, but which + :cfunc:`ctime` function (which :func:`time.ctime` invokes, but which :meth:`date.ctime` does not invoke) conforms to the C standard. .. method:: date.strftime(format) Return a string representing the date, controlled by an explicit format string. - Format codes referring to hours, minutes or seconds will see 0 values. For a - complete list of formatting directives, see section - :ref:`strftime-strptime-behavior`. - - -.. method:: date.__format__(format) - - Same as :meth:`.date.strftime`. This makes it possible to specify format - string for a :class:`.date` object when using :meth:`str.format`. - See section :ref:`strftime-strptime-behavior`. + Format codes referring to hours, minutes or seconds will see 0 values. See + section :ref:`strftime-strptime-behavior`. Example of counting days to an event:: @@ -613,8 +595,6 @@ '11/03/02' >>> d.strftime("%A %d. %B %Y") 'Monday 11. March 2002' - >>> 'The {1} is {0:%d}, the {2} is {0:%B}.'.format(d, "day", "month") - 'The day is 11, the month is March.' .. _datetime-datetime: @@ -622,10 +602,10 @@ :class:`datetime` Objects ------------------------- -A :class:`.datetime` object is a single object containing all the information -from a :class:`date` object and a :class:`.time` object. Like a :class:`date` -object, :class:`.datetime` assumes the current Gregorian calendar extended in -both directions; like a time object, :class:`.datetime` assumes there are exactly +A :class:`datetime` object is a single object containing all the information +from a :class:`date` object and a :class:`time` object. Like a :class:`date` +object, :class:`datetime` assumes the current Gregorian calendar extended in +both directions; like a time object, :class:`datetime` assumes there are exactly 3600\*24 seconds in every day. Constructor: @@ -661,7 +641,7 @@ or not specified, this is like :meth:`today`, but, if possible, supplies more precision than can be gotten from going through a :func:`time.time` timestamp (for example, this may be possible on platforms supplying the C - :c:func:`gettimeofday` function). + :cfunc:`gettimeofday` function). Else *tz* must be an instance of a class :class:`tzinfo` subclass, and the current date and time are converted to *tz*'s time zone. In this case the @@ -673,7 +653,7 @@ Return the current UTC date and time, with :attr:`tzinfo` ``None``. This is like :meth:`now`, but returns the current UTC date and time, as a naive - :class:`.datetime` object. See also :meth:`now`. + :class:`datetime` object. See also :meth:`now`. .. classmethod:: datetime.fromtimestamp(timestamp[, tz]) @@ -681,7 +661,7 @@ Return the local date and time corresponding to the POSIX timestamp, such as is returned by :func:`time.time`. If optional argument *tz* is ``None`` or not specified, the timestamp is converted to the platform's local date and time, and - the returned :class:`.datetime` object is naive. + the returned :class:`datetime` object is naive. Else *tz* must be an instance of a class :class:`tzinfo` subclass, and the timestamp is converted to *tz*'s time zone. In this case the result is @@ -689,26 +669,26 @@ ``tz.fromutc(datetime.utcfromtimestamp(timestamp).replace(tzinfo=tz))``. :meth:`fromtimestamp` may raise :exc:`ValueError`, if the timestamp is out of - the range of values supported by the platform C :c:func:`localtime` or - :c:func:`gmtime` functions. It's common for this to be restricted to years in + the range of values supported by the platform C :cfunc:`localtime` or + :cfunc:`gmtime` functions. It's common for this to be restricted to years in 1970 through 2038. Note that on non-POSIX systems that include leap seconds in their notion of a timestamp, leap seconds are ignored by :meth:`fromtimestamp`, and then it's possible to have two timestamps differing by a second that yield - identical :class:`.datetime` objects. See also :meth:`utcfromtimestamp`. + identical :class:`datetime` objects. See also :meth:`utcfromtimestamp`. .. classmethod:: datetime.utcfromtimestamp(timestamp) - Return the UTC :class:`.datetime` corresponding to the POSIX timestamp, with + Return the UTC :class:`datetime` corresponding to the POSIX timestamp, with :attr:`tzinfo` ``None``. This may raise :exc:`ValueError`, if the timestamp is - out of the range of values supported by the platform C :c:func:`gmtime` function. + out of the range of values supported by the platform C :cfunc:`gmtime` function. It's common for this to be restricted to years in 1970 through 2038. See also :meth:`fromtimestamp`. .. classmethod:: datetime.fromordinal(ordinal) - Return the :class:`.datetime` corresponding to the proleptic Gregorian ordinal, + Return the :class:`datetime` corresponding to the proleptic Gregorian ordinal, where January 1 of year 1 has ordinal 1. :exc:`ValueError` is raised unless ``1 <= ordinal <= datetime.max.toordinal()``. The hour, minute, second and microsecond of the result are all 0, and :attr:`tzinfo` is ``None``. @@ -716,23 +696,22 @@ .. classmethod:: datetime.combine(date, time) - Return a new :class:`.datetime` object whose date components are equal to the + Return a new :class:`datetime` object whose date components are equal to the given :class:`date` object's, and whose time components and :attr:`tzinfo` - attributes are equal to the given :class:`.time` object's. For any - :class:`.datetime` object *d*, + attributes are equal to the given :class:`time` object's. For any + :class:`datetime` object *d*, ``d == datetime.combine(d.date(), d.timetz())``. If date is a - :class:`.datetime` object, its time components and :attr:`tzinfo` attributes + :class:`datetime` object, its time components and :attr:`tzinfo` attributes are ignored. .. classmethod:: datetime.strptime(date_string, format) - Return a :class:`.datetime` corresponding to *date_string*, parsed according to + Return a :class:`datetime` corresponding to *date_string*, parsed according to *format*. This is equivalent to ``datetime(*(time.strptime(date_string, format)[0:6]))``. :exc:`ValueError` is raised if the date_string and format can't be parsed by :func:`time.strptime` or if it returns a value which isn't a - time tuple. For a complete list of formatting directives, see section - :ref:`strftime-strptime-behavior`. + time tuple. See section :ref:`strftime-strptime-behavior`. .. versionadded:: 2.5 @@ -741,19 +720,19 @@ .. attribute:: datetime.min - The earliest representable :class:`.datetime`, ``datetime(MINYEAR, 1, 1, + The earliest representable :class:`datetime`, ``datetime(MINYEAR, 1, 1, tzinfo=None)``. .. attribute:: datetime.max - The latest representable :class:`.datetime`, ``datetime(MAXYEAR, 12, 31, 23, 59, + The latest representable :class:`datetime`, ``datetime(MAXYEAR, 12, 31, 23, 59, 59, 999999, tzinfo=None)``. .. attribute:: datetime.resolution - The smallest possible difference between non-equal :class:`.datetime` objects, + The smallest possible difference between non-equal :class:`datetime` objects, ``timedelta(microseconds=1)``. @@ -796,24 +775,24 @@ .. attribute:: datetime.tzinfo - The object passed as the *tzinfo* argument to the :class:`.datetime` constructor, + The object passed as the *tzinfo* argument to the :class:`datetime` constructor, or ``None`` if none was passed. Supported operations: -+---------------------------------------+--------------------------------+ -| Operation | Result | -+=======================================+================================+ -| ``datetime2 = datetime1 + timedelta`` | \(1) | -+---------------------------------------+--------------------------------+ -| ``datetime2 = datetime1 - timedelta`` | \(2) | -+---------------------------------------+--------------------------------+ -| ``timedelta = datetime1 - datetime2`` | \(3) | -+---------------------------------------+--------------------------------+ -| ``datetime1 < datetime2`` | Compares :class:`.datetime` to | -| | :class:`.datetime`. (4) | -+---------------------------------------+--------------------------------+ ++---------------------------------------+-------------------------------+ +| Operation | Result | ++=======================================+===============================+ +| ``datetime2 = datetime1 + timedelta`` | \(1) | ++---------------------------------------+-------------------------------+ +| ``datetime2 = datetime1 - timedelta`` | \(2) | ++---------------------------------------+-------------------------------+ +| ``timedelta = datetime1 - datetime2`` | \(3) | ++---------------------------------------+-------------------------------+ +| ``datetime1 < datetime2`` | Compares :class:`datetime` to | +| | :class:`datetime`. (4) | ++---------------------------------------+-------------------------------+ (1) datetime2 is a duration of timedelta removed from datetime1, moving forward in @@ -832,7 +811,7 @@ in isolation can overflow in cases where datetime1 - timedelta does not. (3) - Subtraction of a :class:`.datetime` from a :class:`.datetime` is defined only if + Subtraction of a :class:`datetime` from a :class:`datetime` is defined only if both operands are naive, or if both are aware. If one is aware and the other is naive, :exc:`TypeError` is raised. @@ -861,16 +840,16 @@ In order to stop comparison from falling back to the default scheme of comparing object addresses, datetime comparison normally raises :exc:`TypeError` if the - other comparand isn't also a :class:`.datetime` object. However, + other comparand isn't also a :class:`datetime` object. However, ``NotImplemented`` is returned instead if the other comparand has a :meth:`timetuple` attribute. This hook gives other kinds of date objects a - chance at implementing mixed-type comparison. If not, when a :class:`.datetime` + chance at implementing mixed-type comparison. If not, when a :class:`datetime` object is compared to an object of a different type, :exc:`TypeError` is raised unless the comparison is ``==`` or ``!=``. The latter cases return :const:`False` or :const:`True`, respectively. -:class:`.datetime` objects can be used as dictionary keys. In Boolean contexts, -all :class:`.datetime` objects are considered to be true. +:class:`datetime` objects can be used as dictionary keys. In Boolean contexts, +all :class:`datetime` objects are considered to be true. Instance methods: @@ -881,13 +860,13 @@ .. method:: datetime.time() - Return :class:`.time` object with same hour, minute, second and microsecond. + Return :class:`time` object with same hour, minute, second and microsecond. :attr:`tzinfo` is ``None``. See also method :meth:`timetz`. .. method:: datetime.timetz() - Return :class:`.time` object with same hour, minute, second, microsecond, and + Return :class:`time` object with same hour, minute, second, microsecond, and tzinfo attributes. See also method :meth:`time`. @@ -901,7 +880,7 @@ .. method:: datetime.astimezone(tz) - Return a :class:`.datetime` object with new :attr:`tzinfo` attribute *tz*, + Return a :class:`datetime` object with new :attr:`tzinfo` attribute *tz*, adjusting the date and time data so the result is the same UTC time as *self*, but in *tz*'s local time. @@ -975,7 +954,7 @@ .. method:: datetime.utctimetuple() - If :class:`.datetime` instance *d* is naive, this is the same as + If :class:`datetime` instance *d* is naive, this is the same as ``d.timetuple()`` except that :attr:`tm_isdst` is forced to 0 regardless of what ``d.dst()`` returns. DST is never in effect for a UTC time. @@ -1036,7 +1015,7 @@ .. method:: datetime.__str__() - For a :class:`.datetime` instance *d*, ``str(d)`` is equivalent to + For a :class:`datetime` instance *d*, ``str(d)`` is equivalent to ``d.isoformat(' ')``. @@ -1045,22 +1024,14 @@ Return a string representing the date and time, for example ``datetime(2002, 12, 4, 20, 30, 40).ctime() == 'Wed Dec 4 20:30:40 2002'``. ``d.ctime()`` is equivalent to ``time.ctime(time.mktime(d.timetuple()))`` on platforms where the - native C :c:func:`ctime` function (which :func:`time.ctime` invokes, but which + native C :cfunc:`ctime` function (which :func:`time.ctime` invokes, but which :meth:`datetime.ctime` does not invoke) conforms to the C standard. .. method:: datetime.strftime(format) Return a string representing the date and time, controlled by an explicit format - string. For a complete list of formatting directives, see section - :ref:`strftime-strptime-behavior`. - - -.. method:: datetime.__format__(format) - - Same as :meth:`.datetime.strftime`. This makes it possible to specify format - string for a :class:`.datetime` object when using :meth:`str.format`. - See section :ref:`strftime-strptime-behavior`. + string. See section :ref:`strftime-strptime-behavior`. Examples of working with datetime objects: @@ -1107,21 +1078,19 @@ >>> # Formatting datetime >>> dt.strftime("%A, %d. %B %Y %I:%M%p") 'Tuesday, 21. November 2006 04:30PM' - >>> 'The {1} is {0:%d}, the {2} is {0:%B}, the {3} is {0:%I:%M%p}.'.format(dt, "day", "month", "time") - 'The day is 21, the month is November, the time is 04:30PM.' Using datetime with tzinfo: >>> from datetime import timedelta, datetime, tzinfo >>> class GMT1(tzinfo): - ... def utcoffset(self, dt): - ... return timedelta(hours=1) + self.dst(dt) - ... def dst(self, dt): - ... # DST starts last Sunday in March + ... def __init__(self): # DST starts last Sunday in March ... d = datetime(dt.year, 4, 1) # ends last Sunday in October ... self.dston = d - timedelta(days=d.weekday() + 1) ... d = datetime(dt.year, 11, 1) ... self.dstoff = d - timedelta(days=d.weekday() + 1) + ... def utcoffset(self, dt): + ... return timedelta(hours=1) + self.dst(dt) + ... def dst(self, dt): ... if self.dston <= dt.replace(tzinfo=None) < self.dstoff: ... return timedelta(hours=1) ... else: @@ -1130,15 +1099,16 @@ ... return "GMT +1" ... >>> class GMT2(tzinfo): - ... def utcoffset(self, dt): - ... return timedelta(hours=2) + self.dst(dt) - ... def dst(self, dt): + ... def __init__(self): ... d = datetime(dt.year, 4, 1) ... self.dston = d - timedelta(days=d.weekday() + 1) ... d = datetime(dt.year, 11, 1) ... self.dstoff = d - timedelta(days=d.weekday() + 1) + ... def utcoffset(self, dt): + ... return timedelta(hours=1) + self.dst(dt) + ... def dst(self, dt): ... if self.dston <= dt.replace(tzinfo=None) < self.dstoff: - ... return timedelta(hours=1) + ... return timedelta(hours=2) ... else: ... return timedelta(0) ... def tzname(self,dt): @@ -1175,7 +1145,7 @@ A time object represents a (local) time of day, independent of any particular day, and subject to adjustment via a :class:`tzinfo` object. -.. class:: time([hour[, minute[, second[, microsecond[, tzinfo]]]]]) +.. class:: time(hour[, minute[, second[, microsecond[, tzinfo]]]]) All arguments are optional. *tzinfo* may be ``None``, or an instance of a :class:`tzinfo` subclass. The remaining arguments may be ints or longs, in the @@ -1239,7 +1209,7 @@ Supported operations: -* comparison of :class:`.time` to :class:`.time`, where *a* is considered less +* comparison of :class:`time` to :class:`time`, where *a* is considered less than *b* when *a* precedes *b* in time. If one comparand is naive and the other is aware, :exc:`TypeError` is raised. If both comparands are aware, and have the same :attr:`tzinfo` attribute, the common :attr:`tzinfo` attribute is @@ -1247,7 +1217,7 @@ have different :attr:`tzinfo` attributes, the comparands are first adjusted by subtracting their UTC offsets (obtained from ``self.utcoffset()``). In order to stop mixed-type comparisons from falling back to the default comparison by - object address, when a :class:`.time` object is compared to an object of a + object address, when a :class:`time` object is compared to an object of a different type, :exc:`TypeError` is raised unless the comparison is ``==`` or ``!=``. The latter cases return :const:`False` or :const:`True`, respectively. @@ -1255,7 +1225,7 @@ * efficient pickling -* in Boolean contexts, a :class:`.time` object is considered to be true if and +* in Boolean contexts, a :class:`time` object is considered to be true if and only if, after converting it to minutes and subtracting :meth:`utcoffset` (or ``0`` if that's ``None``), the result is non-zero. @@ -1286,14 +1256,6 @@ .. method:: time.strftime(format) Return a string representing the time, controlled by an explicit format string. - For a complete list of formatting directives, see section - :ref:`strftime-strptime-behavior`. - - -.. method:: time.__format__(format) - - Same as :meth:`.time.strftime`. This makes it possible to specify format string - for a :class:`.time` object when using :meth:`str.format`. See section :ref:`strftime-strptime-behavior`. @@ -1343,8 +1305,6 @@ 'Europe/Prague' >>> t.strftime("%H:%M:%S %Z") '12:10:30 Europe/Prague' - >>> 'The {} is {:%H:%M}.'.format("time", t) - 'The time is 12:10.' .. _datetime-tzinfo: @@ -1355,11 +1315,11 @@ :class:`tzinfo` is an abstract base class, meaning that this class should not be instantiated directly. You need to derive a concrete subclass, and (at least) supply implementations of the standard :class:`tzinfo` methods needed by the -:class:`.datetime` methods you use. The :mod:`datetime` module does not supply +:class:`datetime` methods you use. The :mod:`datetime` module does not supply any concrete subclasses of :class:`tzinfo`. An instance of (a concrete subclass of) :class:`tzinfo` can be passed to the -constructors for :class:`.datetime` and :class:`.time` objects. The latter objects +constructors for :class:`datetime` and :class:`time` objects. The latter objects view their attributes as being in local time, and the :class:`tzinfo` object supports methods revealing offset of local time from UTC, the name of the time zone, and DST offset, all relative to a date or time object passed to them. @@ -1414,7 +1374,7 @@ ``tz.utcoffset(dt) - tz.dst(dt)`` - must return the same result for every :class:`.datetime` *dt* with ``dt.tzinfo == + must return the same result for every :class:`datetime` *dt* with ``dt.tzinfo == tz`` For sane :class:`tzinfo` subclasses, this expression yields the time zone's "standard offset", which should not depend on the date or the time, but only on geographic location. The implementation of :meth:`datetime.astimezone` @@ -1446,7 +1406,7 @@ .. method:: tzinfo.tzname(self, dt) - Return the time zone name corresponding to the :class:`.datetime` object *dt*, as + Return the time zone name corresponding to the :class:`datetime` object *dt*, as a string. Nothing about string names is defined by the :mod:`datetime` module, and there's no requirement that it mean anything in particular. For example, "GMT", "UTC", "-500", "-5:00", "EDT", "US/Eastern", "America/New York" are all @@ -1459,11 +1419,11 @@ The default implementation of :meth:`tzname` raises :exc:`NotImplementedError`. -These methods are called by a :class:`.datetime` or :class:`.time` object, in -response to their methods of the same names. A :class:`.datetime` object passes -itself as the argument, and a :class:`.time` object passes ``None`` as the +These methods are called by a :class:`datetime` or :class:`time` object, in +response to their methods of the same names. A :class:`datetime` object passes +itself as the argument, and a :class:`time` object passes ``None`` as the argument. A :class:`tzinfo` subclass's methods should therefore be prepared to -accept a *dt* argument of ``None``, or of class :class:`.datetime`. +accept a *dt* argument of ``None``, or of class :class:`datetime`. When ``None`` is passed, it's up to the class designer to decide the best response. For example, returning ``None`` is appropriate if the class wishes to @@ -1471,7 +1431,7 @@ may be more useful for ``utcoffset(None)`` to return the standard UTC offset, as there is no other convention for discovering the standard offset. -When a :class:`.datetime` object is passed in response to a :class:`.datetime` +When a :class:`datetime` object is passed in response to a :class:`datetime` method, ``dt.tzinfo`` is the same object as *self*. :class:`tzinfo` methods can rely on this, unless user code calls :class:`tzinfo` methods directly. The intent is that the :class:`tzinfo` methods interpret *dt* as being in local @@ -1561,39 +1521,24 @@ other fixed-offset :class:`tzinfo` subclass (such as a class representing only EST (fixed offset -5 hours), or only EDT (fixed offset -4 hours)). -.. seealso:: - - `pytz `_ - The standard library has no :class:`tzinfo` instances, but - there exists a third-party library which brings the *IANA timezone - database* (also known as the Olson database) to Python: *pytz*. - - *pytz* contains up-to-date information and its usage is recommended. - - `IANA timezone database `_ - The Time Zone Database (often called tz or zoneinfo) contains code and - data that represent the history of local time for many representative - locations around the globe. It is updated periodically to reflect changes - made by political bodies to time zone boundaries, UTC offsets, and - daylight-saving rules. .. _strftime-strptime-behavior: :meth:`strftime` and :meth:`strptime` Behavior ---------------------------------------------- -:class:`date`, :class:`.datetime`, and :class:`.time` objects all support a +:class:`date`, :class:`datetime`, and :class:`time` objects all support a ``strftime(format)`` method, to create a string representing the time under the control of an explicit format string. Broadly speaking, ``d.strftime(fmt)`` acts like the :mod:`time` module's ``time.strftime(fmt, d.timetuple())`` although not all objects support a :meth:`timetuple` method. Conversely, the :meth:`datetime.strptime` class method creates a -:class:`.datetime` object from a string representing a date and time and a +:class:`datetime` object from a string representing a date and time and a corresponding format string. ``datetime.strptime(date_string, format)`` is equivalent to ``datetime(*(time.strptime(date_string, format)[0:6]))``. -For :class:`.time` objects, the format codes for year, month, and day should not +For :class:`time` objects, the format codes for year, month, and day should not be used, as time objects have no such values. If they're used anyway, ``1900`` is substituted for the year, and ``1`` for the month and day. @@ -1601,10 +1546,30 @@ microseconds should not be used, as :class:`date` objects have no such values. If they're used anyway, ``0`` is substituted for them. +.. versionadded:: 2.6 + :class:`time` and :class:`datetime` objects support a ``%f`` format code + which expands to the number of microseconds in the object, zero-padded on + the left to six places. + +For a naive object, the ``%z`` and ``%Z`` format codes are replaced by empty +strings. + +For an aware object: + +``%z`` + :meth:`utcoffset` is transformed into a 5-character string of the form +HHMM or + -HHMM, where HH is a 2-digit string giving the number of UTC offset hours, and + MM is a 2-digit string giving the number of UTC offset minutes. For example, if + :meth:`utcoffset` returns ``timedelta(hours=-3, minutes=-30)``, ``%z`` is + replaced with the string ``'-0330'``. + +``%Z`` + If :meth:`tzname` returns ``None``, ``%Z`` is replaced by an empty string. + Otherwise ``%Z`` is replaced by the returned value, which must be a string. + The full set of format codes supported varies across platforms, because Python calls the platform C library's :func:`strftime` function, and platform -variations are common. To see the full set of format codes supported on your -platform, consult the :manpage:`strftime(3)` documentation. +variations are common. The following is a list of all the format codes that the C standard (1989 version) requires, and these work on all platforms with a standard C @@ -1614,156 +1579,116 @@ The exact range of years for which :meth:`strftime` works also varies across platforms. Regardless of platform, years before 1900 cannot be used. -+-----------+--------------------------------+------------------------+-------+ -| Directive | Meaning | Example | Notes | -+===========+================================+========================+=======+ -| ``%a`` | Weekday as locale's || Sun, Mon, ..., Sat | \(1) | -| | abbreviated name. | (en_US); | | -| | || So, Mo, ..., Sa | | -| | | (de_DE) | | -+-----------+--------------------------------+------------------------+-------+ -| ``%A`` | Weekday as locale's full name. || Sunday, Monday, ..., | \(1) | -| | | Saturday (en_US); | | -| | || Sonntag, Montag, ..., | | -| | | Samstag (de_DE) | | -+-----------+--------------------------------+------------------------+-------+ -| ``%w`` | Weekday as a decimal number, | 0, 1, ..., 6 | | -| | where 0 is Sunday and 6 is | | | -| | Saturday. | | | -+-----------+--------------------------------+------------------------+-------+ -| ``%d`` | Day of the month as a | 01, 02, ..., 31 | | -| | zero-padded decimal number. | | | -+-----------+--------------------------------+------------------------+-------+ -| ``%b`` | Month as locale's abbreviated || Jan, Feb, ..., Dec | \(1) | -| | name. | (en_US); | | -| | || Jan, Feb, ..., Dez | | -| | | (de_DE) | | -+-----------+--------------------------------+------------------------+-------+ -| ``%B`` | Month as locale's full name. || January, February, | \(1) | -| | | ..., December (en_US);| | -| | || Januar, Februar, ..., | | -| | | Dezember (de_DE) | | -+-----------+--------------------------------+------------------------+-------+ -| ``%m`` | Month as a zero-padded | 01, 02, ..., 12 | | -| | decimal number. | | | -+-----------+--------------------------------+------------------------+-------+ -| ``%y`` | Year without century as a | 00, 01, ..., 99 | | -| | zero-padded decimal number. | | | -+-----------+--------------------------------+------------------------+-------+ -| ``%Y`` | Year with century as a decimal | 1970, 1988, 2001, 2013 | | -| | number. | | | -+-----------+--------------------------------+------------------------+-------+ -| ``%H`` | Hour (24-hour clock) as a | 00, 01, ..., 23 | | -| | zero-padded decimal number. | | | -+-----------+--------------------------------+------------------------+-------+ -| ``%I`` | Hour (12-hour clock) as a | 01, 02, ..., 12 | | -| | zero-padded decimal number. | | | -+-----------+--------------------------------+------------------------+-------+ -| ``%p`` | Locale's equivalent of either || AM, PM (en_US); | \(1), | -| | AM or PM. || am, pm (de_DE) | \(2) | -+-----------+--------------------------------+------------------------+-------+ -| ``%M`` | Minute as a zero-padded | 00, 01, ..., 59 | | -| | decimal number. | | | -+-----------+--------------------------------+------------------------+-------+ -| ``%S`` | Second as a zero-padded | 00, 01, ..., 59 | \(3) | -| | decimal number. | | | -+-----------+--------------------------------+------------------------+-------+ -| ``%f`` | Microsecond as a decimal | 000000, 000001, ..., | \(4) | -| | number, zero-padded on the | 999999 | | -| | left. | | | -+-----------+--------------------------------+------------------------+-------+ -| ``%z`` | UTC offset in the form +HHMM | (empty), +0000, -0400, | \(5) | -| | or -HHMM (empty string if the | +1030 | | -| | the object is naive). | | | -+-----------+--------------------------------+------------------------+-------+ -| ``%Z`` | Time zone name (empty string | (empty), UTC, EST, CST | | -| | if the object is naive). | | | -+-----------+--------------------------------+------------------------+-------+ -| ``%j`` | Day of the year as a | 001, 002, ..., 366 | | -| | zero-padded decimal number. | | | -+-----------+--------------------------------+------------------------+-------+ -| ``%U`` | Week number of the year | 00, 01, ..., 53 | \(6) | -| | (Sunday as the first day of | | | -| | the week) as a zero padded | | | -| | decimal number. All days in a | | | -| | new year preceding the first | | | -| | Sunday are considered to be in | | | -| | week 0. | | | -+-----------+--------------------------------+------------------------+-------+ -| ``%W`` | Week number of the year | 00, 01, ..., 53 | \(6) | -| | (Monday as the first day of | | | -| | the week) as a decimal number. | | | -| | All days in a new year | | | -| | preceding the first Monday | | | -| | are considered to be in | | | -| | week 0. | | | -+-----------+--------------------------------+------------------------+-------+ -| ``%c`` | Locale's appropriate date and || Tue Aug 16 21:30:00 | \(1) | -| | time representation. | 1988 (en_US); | | -| | || Di 16 Aug 21:30:00 | | -| | | 1988 (de_DE) | | -+-----------+--------------------------------+------------------------+-------+ -| ``%x`` | Locale's appropriate date || 08/16/88 (None); | \(1) | -| | representation. || 08/16/1988 (en_US); | | -| | || 16.08.1988 (de_DE) | | -+-----------+--------------------------------+------------------------+-------+ -| ``%X`` | Locale's appropriate time || 21:30:00 (en_US); | \(1) | -| | representation. || 21:30:00 (de_DE) | | -+-----------+--------------------------------+------------------------+-------+ -| ``%%`` | A literal ``'%'`` character. | % | | -+-----------+--------------------------------+------------------------+-------+ ++-----------+--------------------------------+-------+ +| Directive | Meaning | Notes | ++===========+================================+=======+ +| ``%a`` | Locale's abbreviated weekday | | +| | name. | | ++-----------+--------------------------------+-------+ +| ``%A`` | Locale's full weekday name. | | ++-----------+--------------------------------+-------+ +| ``%b`` | Locale's abbreviated month | | +| | name. | | ++-----------+--------------------------------+-------+ +| ``%B`` | Locale's full month name. | | ++-----------+--------------------------------+-------+ +| ``%c`` | Locale's appropriate date and | | +| | time representation. | | ++-----------+--------------------------------+-------+ +| ``%d`` | Day of the month as a decimal | | +| | number [01,31]. | | ++-----------+--------------------------------+-------+ +| ``%f`` | Microsecond as a decimal | \(1) | +| | number [0,999999], zero-padded | | +| | on the left | | ++-----------+--------------------------------+-------+ +| ``%H`` | Hour (24-hour clock) as a | | +| | decimal number [00,23]. | | ++-----------+--------------------------------+-------+ +| ``%I`` | Hour (12-hour clock) as a | | +| | decimal number [01,12]. | | ++-----------+--------------------------------+-------+ +| ``%j`` | Day of the year as a decimal | | +| | number [001,366]. | | ++-----------+--------------------------------+-------+ +| ``%m`` | Month as a decimal number | | +| | [01,12]. | | ++-----------+--------------------------------+-------+ +| ``%M`` | Minute as a decimal number | | +| | [00,59]. | | ++-----------+--------------------------------+-------+ +| ``%p`` | Locale's equivalent of either | \(2) | +| | AM or PM. | | ++-----------+--------------------------------+-------+ +| ``%S`` | Second as a decimal number | \(3) | +| | [00,61]. | | ++-----------+--------------------------------+-------+ +| ``%U`` | Week number of the year | \(4) | +| | (Sunday as the first day of | | +| | the week) as a decimal number | | +| | [00,53]. All days in a new | | +| | year preceding the first | | +| | Sunday are considered to be in | | +| | week 0. | | ++-----------+--------------------------------+-------+ +| ``%w`` | Weekday as a decimal number | | +| | [0(Sunday),6]. | | ++-----------+--------------------------------+-------+ +| ``%W`` | Week number of the year | \(4) | +| | (Monday as the first day of | | +| | the week) as a decimal number | | +| | [00,53]. All days in a new | | +| | year preceding the first | | +| | Monday are considered to be in | | +| | week 0. | | ++-----------+--------------------------------+-------+ +| ``%x`` | Locale's appropriate date | | +| | representation. | | ++-----------+--------------------------------+-------+ +| ``%X`` | Locale's appropriate time | | +| | representation. | | ++-----------+--------------------------------+-------+ +| ``%y`` | Year without century as a | | +| | decimal number [00,99]. | | ++-----------+--------------------------------+-------+ +| ``%Y`` | Year with century as a decimal | | +| | number. | | ++-----------+--------------------------------+-------+ +| ``%z`` | UTC offset in the form +HHMM | \(5) | +| | or -HHMM (empty string if the | | +| | the object is naive). | | ++-----------+--------------------------------+-------+ +| ``%Z`` | Time zone name (empty string | | +| | if the object is naive). | | ++-----------+--------------------------------+-------+ +| ``%%`` | A literal ``'%'`` character. | | ++-----------+--------------------------------+-------+ Notes: (1) - Because the format depends on the current locale, care should be taken when - making assumptions about the output value. Field orderings will vary (for - example, "month/day/year" versus "day/month/year"), and the output may - contain Unicode characters encoded using the locale's default encoding (for - example, if the current locale is ``ja_JP``, the default encoding could be - any one of ``eucJP``, ``SJIS``, or ``utf-8``; use :meth:`locale.getlocale` - to determine the current locale's encoding). + When used with the :meth:`strptime` method, the ``%f`` directive + accepts from one to six digits and zero pads on the right. ``%f`` is + an extension to the set of format characters in the C standard (but + implemented separately in datetime objects, and therefore always + available). (2) When used with the :meth:`strptime` method, the ``%p`` directive only affects the output hour field if the ``%I`` directive is used to parse the hour. (3) - Unlike the :mod:`time` module, the :mod:`datetime` module does not support - leap seconds. + The range really is ``0`` to ``61``; according to the Posix standard this + accounts for leap seconds and the (very rare) double leap seconds. + The :mod:`time` module may produce and does accept leap seconds since + it is based on the Posix standard, but the :mod:`datetime` module + does not accept leap seconds in :meth:`strptime` input nor will it + produce them in :func:`strftime` output. (4) - ``%f`` is an extension to the set of format characters in the C standard - (but implemented separately in datetime objects, and therefore always - available). When used with the :meth:`strptime` method, the ``%f`` - directive accepts from one to six digits and zero pads on the right. - - .. versionadded:: 2.6 + When used with the :meth:`strptime` method, ``%U`` and ``%W`` are only used in + calculations when the day of the week and the year are specified. (5) - For a naive object, the ``%z`` and ``%Z`` format codes are replaced by empty - strings. - - For an aware object: - - ``%z`` - :meth:`utcoffset` is transformed into a 5-character string of the form - +HHMM or -HHMM, where HH is a 2-digit string giving the number of UTC - offset hours, and MM is a 2-digit string giving the number of UTC offset - minutes. For example, if :meth:`utcoffset` returns - ``timedelta(hours=-3, minutes=-30)``, ``%z`` is replaced with the string - ``'-0330'``. - - ``%Z`` - If :meth:`tzname` returns ``None``, ``%Z`` is replaced by an empty - string. Otherwise ``%Z`` is replaced by the returned value, which must - be a string. - -(6) - When used with the :meth:`strptime` method, ``%U`` and ``%W`` are only used - in calculations when the day of the week and the year are specified. - - -.. rubric:: Footnotes - -.. [#] If, that is, we ignore the effects of Relativity + For example, if :meth:`utcoffset` returns ``timedelta(hours=-3, minutes=-30)``, + ``%z`` is replaced with the string ``'-0330'``. diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/library/dbhash.rst --- a/Doc/library/dbhash.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/library/dbhash.rst Sun Jul 20 10:52:46 2014 -0400 @@ -6,7 +6,7 @@ .. sectionauthor:: Fred L. Drake, Jr. .. deprecated:: 2.6 - The :mod:`dbhash` module has been removed in Python 3. + The :mod:`dbhash` module has been deprecated for removal in Python 3.0. .. index:: module: bsddb diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/library/dbm.rst --- a/Doc/library/dbm.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/library/dbm.rst Sun Jul 20 10:52:46 2014 -0400 @@ -6,9 +6,9 @@ :synopsis: The standard "database" interface, based on ndbm. .. note:: - The :mod:`dbm` module has been renamed to :mod:`dbm.ndbm` in Python 3. The + The :mod:`dbm` module has been renamed to :mod:`dbm.ndbm` in Python 3.0. The :term:`2to3` tool will automatically adapt imports when converting your - sources to Python 3. + sources to 3.0. The :mod:`dbm` module provides an interface to the Unix "(n)dbm" library. Dbm @@ -64,14 +64,6 @@ database has to be created. It defaults to octal ``0666`` (and will be modified by the prevailing umask). - In addition to the dictionary-like methods, ``dbm`` objects - provide the following method: - - - .. function:: close() - - Close the ``dbm`` database. - .. seealso:: diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/library/decimal.rst --- a/Doc/library/decimal.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/library/decimal.rst Sun Jul 20 10:52:46 2014 -0400 @@ -35,7 +35,7 @@ people learn at school." -- excerpt from the decimal arithmetic specification. * Decimal numbers can be represented exactly. In contrast, numbers like - :const:`1.1` and :const:`2.2` do not have exact representations in binary + :const:`1.1` and :const:`2.2` do not have an exact representations in binary floating point. End users typically would not expect ``1.1 + 2.2`` to display as :const:`3.3000000000000003` as it does with binary floating point. @@ -375,29 +375,6 @@ compared, sorted, and coerced to another type (such as :class:`float` or :class:`long`). - There are some small differences between arithmetic on Decimal objects and - arithmetic on integers and floats. When the remainder operator ``%`` is - applied to Decimal objects, the sign of the result is the sign of the - *dividend* rather than the sign of the divisor:: - - >>> (-7) % 4 - 1 - >>> Decimal(-7) % Decimal(4) - Decimal('-3') - - The integer division operator ``//`` behaves analogously, returning the - integer part of the true quotient (truncating towards zero) rather than its - floor, so as to preserve the usual identity ``x == (x // y) * y + x % y``:: - - >>> -7 // 4 - -2 - >>> Decimal(-7) // Decimal(4) - Decimal('-1') - - The ``%`` and ``//`` operators implement the ``remainder`` and - ``divide-integer`` operations (respectively) as described in the - specification. - Decimal objects cannot generally be combined with floats in arithmetic operations: an attempt to add a :class:`Decimal` to a :class:`float`, for example, will raise a :exc:`TypeError`. @@ -825,21 +802,12 @@ .. method:: remainder_near(other[, context]) - Return the remainder from dividing *self* by *other*. This differs from - ``self % other`` in that the sign of the remainder is chosen so as to - minimize its absolute value. More precisely, the return value is - ``self - n * other`` where ``n`` is the integer nearest to the exact - value of ``self / other``, and if two integers are equally near then the - even one is chosen. - - If the result is zero then its sign will be the sign of *self*. - - >>> Decimal(18).remainder_near(Decimal(10)) - Decimal('-2') - >>> Decimal(25).remainder_near(Decimal(10)) - Decimal('5') - >>> Decimal(35).remainder_near(Decimal(10)) - Decimal('-5') + Compute the modulo as either a positive or negative value depending on + which is closest to zero. For instance, ``Decimal(10).remainder_near(6)`` + returns ``Decimal('-2')`` which is closer to zero than ``Decimal('4')``. + + If both are equally close, the one chosen will have the same sign as + *self*. .. method:: rotate(other[, context]) @@ -976,10 +944,6 @@ s = calculate_something() s = +s # Round the final result back to the default precision - with localcontext(BasicContext): # temporarily use the BasicContext - print Decimal(1) / Decimal(7) - print Decimal(355) / Decimal(113) - New contexts can also be created using the :class:`Context` constructor described below. In addition, the module provides three pre-made contexts: @@ -1226,52 +1190,52 @@ .. method:: is_canonical(x) - Returns ``True`` if *x* is canonical; otherwise returns ``False``. + Returns True if *x* is canonical; otherwise returns False. .. method:: is_finite(x) - Returns ``True`` if *x* is finite; otherwise returns ``False``. + Returns True if *x* is finite; otherwise returns False. .. method:: is_infinite(x) - Returns ``True`` if *x* is infinite; otherwise returns ``False``. + Returns True if *x* is infinite; otherwise returns False. .. method:: is_nan(x) - Returns ``True`` if *x* is a qNaN or sNaN; otherwise returns ``False``. + Returns True if *x* is a qNaN or sNaN; otherwise returns False. .. method:: is_normal(x) - Returns ``True`` if *x* is a normal number; otherwise returns ``False``. + Returns True if *x* is a normal number; otherwise returns False. .. method:: is_qnan(x) - Returns ``True`` if *x* is a quiet NaN; otherwise returns ``False``. + Returns True if *x* is a quiet NaN; otherwise returns False. .. method:: is_signed(x) - Returns ``True`` if *x* is negative; otherwise returns ``False``. + Returns True if *x* is negative; otherwise returns False. .. method:: is_snan(x) - Returns ``True`` if *x* is a signaling NaN; otherwise returns ``False``. + Returns True if *x* is a signaling NaN; otherwise returns False. .. method:: is_subnormal(x) - Returns ``True`` if *x* is subnormal; otherwise returns ``False``. + Returns True if *x* is subnormal; otherwise returns False. .. method:: is_zero(x) - Returns ``True`` if *x* is a zero; otherwise returns ``False``. + Returns True if *x* is a zero; otherwise returns False. .. method:: ln(x) @@ -1431,7 +1395,7 @@ .. method:: same_quantum(x, y) - Returns ``True`` if the two operands have the same exponent. + Returns True if the two operands have the same exponent. .. method:: scaleb (x, y) diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/library/difflib.rst --- a/Doc/library/difflib.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/library/difflib.rst Sun Jul 20 10:52:46 2014 -0400 @@ -84,7 +84,7 @@ The constructor for this class is: - .. function:: __init__(tabsize=8, wrapcolumn=None, linejunk=None, charjunk=IS_CHARACTER_JUNK) + .. function:: __init__([tabsize][, wrapcolumn][, linejunk][, charjunk]) Initializes instance of :class:`HtmlDiff`. @@ -344,7 +344,7 @@ The :class:`SequenceMatcher` class has this constructor: -.. class:: SequenceMatcher(isjunk=None, a='', b='', autojunk=True) +.. class:: SequenceMatcher([isjunk[, a[, b[, autojunk=True]]]]) Optional argument *isjunk* must be ``None`` (the default) or a one-argument function that takes a sequence element and returns true if and only if the @@ -632,12 +632,10 @@ Compare two sequences of lines, and generate the delta (a sequence of lines). - Each sequence must contain individual single-line strings ending with - newlines. Such sequences can be obtained from the - :meth:`~file.readlines` method of file-like objects. The delta - generated also consists of newline-terminated strings, ready to be - printed as-is via the :meth:`~file.writelines` method of a - file-like object. + Each sequence must contain individual single-line strings ending with newlines. + Such sequences can be obtained from the :meth:`readlines` method of file-like + objects. The delta generated also consists of newline-terminated strings, ready + to be printed as-is via the :meth:`writelines` method of a file-like object. .. _differ-examples: @@ -647,7 +645,7 @@ This example compares two texts. First we set up the texts, sequences of individual single-line strings ending with newlines (such sequences can also be -obtained from the :meth:`~file.readlines` method of file-like objects): +obtained from the :meth:`readlines` method of file-like objects): >>> text1 = ''' 1. Beautiful is better than ugly. ... 2. Explicit is better than implicit. diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/library/dircache.rst --- a/Doc/library/dircache.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/library/dircache.rst Sun Jul 20 10:52:46 2014 -0400 @@ -7,7 +7,7 @@ :deprecated: .. deprecated:: 2.6 - The :mod:`dircache` module has been removed in Python 3. + The :mod:`dircache` module has been removed in Python 3.0. .. sectionauthor:: Moshe Zadka diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/library/dl.rst --- a/Doc/library/dl.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/library/dl.rst Sun Jul 20 10:52:46 2014 -0400 @@ -8,12 +8,12 @@ :deprecated: .. deprecated:: 2.6 - The :mod:`dl` module has been removed in Python 3. Use the :mod:`ctypes` + The :mod:`dl` module has been removed in Python 3.0. Use the :mod:`ctypes` module instead. .. sectionauthor:: Moshe Zadka -The :mod:`dl` module defines an interface to the :c:func:`dlopen` function, which +The :mod:`dl` module defines an interface to the :cfunc:`dlopen` function, which is the most common interface on Unix platforms for handling dynamically linked libraries. It allows the program to call arbitrary functions in such a library. @@ -105,10 +105,10 @@ Call the function named *name* in the referenced shared object. The arguments must be either Python integers, which will be passed as is, Python strings, to which a pointer will be passed, or ``None``, which will be passed as *NULL*. - Note that strings should only be passed to functions as :c:type:`const char\*`, + Note that strings should only be passed to functions as :ctype:`const char\*`, as Python will not like its string mutated. There must be at most 10 arguments, and arguments not given will be treated as - ``None``. The function's return value must be a C :c:type:`long`, which is a + ``None``. The function's return value must be a C :ctype:`long`, which is a Python integer. diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/library/doctest.rst --- a/Doc/library/doctest.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/library/doctest.rst Sun Jul 20 10:52:46 2014 -0400 @@ -1,5 +1,3 @@ -:keepdoctest: - :mod:`doctest` --- Test interactive Python examples =================================================== @@ -341,8 +339,7 @@ Tabs in output generated by the tested code are not modified. Because any hard tabs in the sample output *are* expanded, this means that if the code output includes hard tabs, the only way the doctest can pass is if the - :const:`NORMALIZE_WHITESPACE` option or :ref:`directive ` - is in effect. + :const:`NORMALIZE_WHITESPACE` option or directive is in effect. Alternatively, the test can be rewritten to capture the output and compare it to an expected value as part of the test. This handling of tabs in the source was arrived at through trial and error, and has proven to be the least @@ -366,7 +363,7 @@ Backslashes in a raw docstring: m\n Otherwise, the backslash will be interpreted as part of the string. For example, - the ``\n`` above would be interpreted as a newline character. Alternatively, you + the "\\" above would be interpreted as a newline character. Alternatively, you can double each backslash in the doctest version (and not use a raw string):: >>> def f(x): @@ -514,16 +511,15 @@ SyntaxError: invalid syntax -.. _option-flags-and-directives: .. _doctest-options: -Option Flags -^^^^^^^^^^^^ +Option Flags and Directives +^^^^^^^^^^^^^^^^^^^^^^^^^^^ A number of option flags control various aspects of doctest's behavior. Symbolic names for the flags are supplied as module constants, which can be or'ed together and passed to various functions. The names can also be used in -:ref:`doctest directives `. +doctest directives (see below). The first group of options define test semantics, controlling aspects of how doctest decides whether actual output matches an example's expected output: @@ -577,14 +573,14 @@ :exc:`TypeError` is raised. It will also ignore the module name used in Python 3 doctest reports. Hence - both of these variations will work with the flag specified, regardless of - whether the test is run under Python 2.7 or Python 3.2 (or later versions):: - - >>> raise CustomError('message') + both these variations will work regardless of whether the test is run under + Python 2.7 or Python 3.2 (or later versions): + + >>> raise CustomError('message') #doctest: +IGNORE_EXCEPTION_DETAIL Traceback (most recent call last): CustomError: message - >>> raise CustomError('message') + >>> raise CustomError('message') #doctest: +IGNORE_EXCEPTION_DETAIL Traceback (most recent call last): my_module.CustomError: message @@ -594,16 +590,15 @@ exception name. Using :const:`IGNORE_EXCEPTION_DETAIL` and the details from Python 2.3 is also the only clear way to write a doctest that doesn't care about the exception detail yet continues to pass under Python 2.3 or - earlier (those releases do not support :ref:`doctest directives - ` and ignore them as irrelevant comments). For example:: - - >>> (1, 2)[3] = 'moo' + earlier (those releases do not support doctest directives and ignore them + as irrelevant comments). For example, :: + + >>> (1, 2)[3] = 'moo' #doctest: +IGNORE_EXCEPTION_DETAIL Traceback (most recent call last): File "", line 1, in ? TypeError: object doesn't support item assignment - passes under Python 2.3 and later Python versions with the flag specified, - even though the detail + passes under Python 2.3 and later Python versions, even though the detail changed in Python 2.4 to say "does not" instead of "doesn't". .. versionchanged:: 2.7 @@ -667,40 +662,9 @@ A bitmask or'ing together all the reporting flags above. - -.. versionadded:: 2.4 - The constants - :const:`DONT_ACCEPT_BLANKLINE`, :const:`NORMALIZE_WHITESPACE`, - :const:`ELLIPSIS`, :const:`IGNORE_EXCEPTION_DETAIL`, :const:`REPORT_UDIFF`, - :const:`REPORT_CDIFF`, :const:`REPORT_NDIFF`, - :const:`REPORT_ONLY_FIRST_FAILURE`, :const:`COMPARISON_FLAGS` and - :const:`REPORTING_FLAGS` were added. - -There's also a way to register new option flag names, although this isn't useful -unless you intend to extend :mod:`doctest` internals via subclassing: - - -.. function:: register_optionflag(name) - - Create a new option flag with a given name, and return the new flag's integer - value. :func:`register_optionflag` can be used when subclassing - :class:`OutputChecker` or :class:`DocTestRunner` to create new options that are - supported by your subclasses. :func:`register_optionflag` should always be - called using the following idiom:: - - MY_FLAG = register_optionflag('MY_FLAG') - - .. versionadded:: 2.4 - - -.. _doctest-directives: - -Directives -^^^^^^^^^^ - -Doctest directives may be used to modify the :ref:`option flags -` for an individual example. Doctest directives are -special Python comments following an example's source code: +"Doctest directives" may be used to modify the option flags for individual +examples. Doctest directives are expressed as a special Python comment +following an example's source code: .. productionlist:: doctest directive: "#" "doctest:" `directive_options` @@ -718,7 +682,7 @@ For example, this test passes:: - >>> print range(20) # doctest: +NORMALIZE_WHITESPACE + >>> print range(20) #doctest: +NORMALIZE_WHITESPACE [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19] @@ -727,11 +691,10 @@ is on a single line. This test also passes, and also requires a directive to do so:: - >>> print range(20) # doctest: +ELLIPSIS + >>> print range(20) # doctest:+ELLIPSIS [0, 1, ..., 18, 19] -Multiple directives can be used on a single physical line, separated by -commas:: +Multiple directives can be used on a single physical line, separated by commas:: >>> print range(20) # doctest: +ELLIPSIS, +NORMALIZE_WHITESPACE [0, 1, ..., 18, 19] @@ -758,7 +721,28 @@ disabling an option via ``-`` in a directive can be useful. .. versionadded:: 2.4 - Support for doctest directives was added. + Doctest directives and the associated constants + :const:`DONT_ACCEPT_BLANKLINE`, :const:`NORMALIZE_WHITESPACE`, + :const:`ELLIPSIS`, :const:`IGNORE_EXCEPTION_DETAIL`, :const:`REPORT_UDIFF`, + :const:`REPORT_CDIFF`, :const:`REPORT_NDIFF`, + :const:`REPORT_ONLY_FIRST_FAILURE`, :const:`COMPARISON_FLAGS` and + :const:`REPORTING_FLAGS` were added. + +There's also a way to register new option flag names, although this isn't useful +unless you intend to extend :mod:`doctest` internals via subclassing: + + +.. function:: register_optionflag(name) + + Create a new option flag with a given name, and return the new flag's integer + value. :func:`register_optionflag` can be used when subclassing + :class:`OutputChecker` or :class:`DocTestRunner` to create new options that are + supported by your subclasses. :func:`register_optionflag` should always be + called using the following idiom:: + + MY_FLAG = register_optionflag('MY_FLAG') + + .. versionadded:: 2.4 .. _doctest-warnings: @@ -1076,16 +1060,6 @@ .. versionchanged:: 2.5 The parameter *encoding* was added. - .. note:: - Unlike :func:`testmod` and :class:`DocTestFinder`, this function raises - a :exc:`ValueError` if *module* contains no docstrings. You can prevent - this error by passing a :class:`DocTestFinder` instance as the - *test_finder* argument with its *exclude_empty* keyword argument set - to ``False``:: - - >>> finder = doctest.DocTestFinder(exclude_empty=False) - >>> suite = doctest.DocTestSuite(test_finder=finder) - .. function:: DocTestSuite([module][, globs][, extraglobs][, test_finder][, setUp][, tearDown][, checker]) diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/library/docxmlrpcserver.rst --- a/Doc/library/docxmlrpcserver.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/library/docxmlrpcserver.rst Sun Jul 20 10:52:46 2014 -0400 @@ -8,8 +8,8 @@ .. note:: The :mod:`DocXMLRPCServer` module has been merged into :mod:`xmlrpc.server` - in Python 3. The :term:`2to3` tool will automatically adapt imports when - converting your sources to Python 3. + in Python 3.0. The :term:`2to3` tool will automatically adapt imports when + converting your sources to 3.0. .. versionadded:: 2.3 diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/library/dumbdbm.rst --- a/Doc/library/dumbdbm.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/library/dumbdbm.rst Sun Jul 20 10:52:46 2014 -0400 @@ -5,9 +5,9 @@ :synopsis: Portable implementation of the simple DBM interface. .. note:: - The :mod:`dumbdbm` module has been renamed to :mod:`dbm.dumb` in Python 3. + The :mod:`dumbdbm` module has been renamed to :mod:`dbm.dumb` in Python 3.0. The :term:`2to3` tool will automatically adapt imports when converting your - sources to Python 3. + sources to 3.0. .. index:: single: databases @@ -49,14 +49,6 @@ .. versionchanged:: 2.2 The *mode* argument was ignored in earlier versions. -In addition to the dictionary-like methods, ``dumbdm`` objects -provide the following method: - - -.. function:: close() - - Close the ``dumbdm`` database. - .. seealso:: diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/library/dummy_thread.rst --- a/Doc/library/dummy_thread.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/library/dummy_thread.rst Sun Jul 20 10:52:46 2014 -0400 @@ -6,8 +6,8 @@ .. note:: The :mod:`dummy_thread` module has been renamed to :mod:`_dummy_thread` in - Python 3. The :term:`2to3` tool will automatically adapt imports when - converting your sources to Python 3; however, you should consider using the + Python 3.0. The :term:`2to3` tool will automatically adapt imports when + converting your sources to 3.0; however, you should consider using the high-lever :mod:`dummy_threading` module instead. **Source code:** :source:`Lib/dummy_thread.py` diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/library/easydialogs.rst --- a/Doc/library/easydialogs.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/library/easydialogs.rst Sun Jul 20 10:52:46 2014 -0400 @@ -143,7 +143,7 @@ .. seealso:: - `Navigation Services Reference `_ + `Navigation Services Reference `_ Programmer's reference documentation for the Navigation Services, a part of the Carbon framework. diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/library/email.charset.rst --- a/Doc/library/email.charset.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/library/email.charset.rst Sun Jul 20 10:52:46 2014 -0400 @@ -1,5 +1,5 @@ -:mod:`email.charset`: Representing character sets -------------------------------------------------- +:mod:`email`: Representing character sets +----------------------------------------- .. module:: email.charset :synopsis: Character Sets @@ -249,5 +249,5 @@ *charset* is the canonical name of a character set. *codecname* is the name of a Python codec, as appropriate for the second argument to the :func:`unicode` - built-in, or to the :meth:`~unicode.encode` method of a Unicode string. + built-in, or to the :meth:`encode` method of a Unicode string. diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/library/email.encoders.rst --- a/Doc/library/email.encoders.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/library/email.encoders.rst Sun Jul 20 10:52:46 2014 -0400 @@ -1,5 +1,5 @@ -:mod:`email.encoders`: Encoders -------------------------------- +:mod:`email`: Encoders +---------------------- .. module:: email.encoders :synopsis: Encoders for email message payloads. @@ -18,10 +18,6 @@ payload, encode it, and reset the payload to this newly encoded value. They should also set the :mailheader:`Content-Transfer-Encoding` header as appropriate. -Note that these functions are not meaningful for a multipart message. They -must be applied to individual subparts instead, and will raise a -:exc:`TypeError` if passed a message whose type is multipart. - Here are the encoding functions provided: diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/library/email.errors.rst --- a/Doc/library/email.errors.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/library/email.errors.rst Sun Jul 20 10:52:46 2014 -0400 @@ -1,5 +1,5 @@ -:mod:`email.errors`: Exception and Defect classes -------------------------------------------------- +:mod:`email`: Exception and Defect classes +------------------------------------------ .. module:: email.errors :synopsis: The exception classes used by the email package. @@ -25,8 +25,7 @@ Raised under some error conditions when parsing the :rfc:`2822` headers of a message, this class is derived from :exc:`MessageParseError`. It can be raised - from the :meth:`Parser.parse ` or - :meth:`Parser.parsestr ` methods. + from the :meth:`Parser.parse` or :meth:`Parser.parsestr` methods. Situations where it can be raised include finding an envelope header after the first :rfc:`2822` header of the message, finding a continuation line before the @@ -38,8 +37,7 @@ Raised under some error conditions when parsing the :rfc:`2822` headers of a message, this class is derived from :exc:`MessageParseError`. It can be raised - from the :meth:`Parser.parse ` or - :meth:`Parser.parsestr ` methods. + from the :meth:`Parser.parse` or :meth:`Parser.parsestr` methods. Situations where it can be raised include not being able to find the starting or terminating boundary in a :mimetype:`multipart/\*` message when strict parsing @@ -48,20 +46,19 @@ .. exception:: MultipartConversionError() - Raised when a payload is added to a :class:`~email.message.Message` object - using :meth:`add_payload`, but the payload is already a scalar and the - message's :mailheader:`Content-Type` main type is not either - :mimetype:`multipart` or missing. :exc:`MultipartConversionError` multiply - inherits from :exc:`MessageError` and the built-in :exc:`TypeError`. + Raised when a payload is added to a :class:`Message` object using + :meth:`add_payload`, but the payload is already a scalar and the message's + :mailheader:`Content-Type` main type is not either :mimetype:`multipart` or + missing. :exc:`MultipartConversionError` multiply inherits from + :exc:`MessageError` and the built-in :exc:`TypeError`. - Since :meth:`Message.add_payload` is deprecated, this exception is rarely - raised in practice. However the exception may also be raised if the - :meth:`~email.message.Message.attach` + Since :meth:`Message.add_payload` is deprecated, this exception is rarely raised + in practice. However the exception may also be raised if the :meth:`attach` method is called on an instance of a class derived from :class:`~email.mime.nonmultipart.MIMENonMultipart` (e.g. :class:`~email.mime.image.MIMEImage`). -Here's the list of the defects that the :class:`~email.parser.FeedParser` +Here's the list of the defects that the :class:`~email.mime.parser.FeedParser` can find while parsing messages. Note that the defects are added to the message where the problem was found, so for example, if a message nested inside a :mimetype:`multipart/alternative` had a malformed header, that nested message @@ -89,7 +86,7 @@ or was otherwise malformed. * :class:`MultipartInvariantViolationDefect` -- A message claimed to be a - :mimetype:`multipart`, but no subparts were found. Note that when a message - has this defect, its :meth:`~email.message.Message.is_multipart` method may - return false even though its content type claims to be :mimetype:`multipart`. + :mimetype:`multipart`, but no subparts were found. Note that when a message has + this defect, its :meth:`is_multipart` method may return false even though its + content type claims to be :mimetype:`multipart`. diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/library/email.generator.rst --- a/Doc/library/email.generator.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/library/email.generator.rst Sun Jul 20 10:52:46 2014 -0400 @@ -1,5 +1,5 @@ -:mod:`email.generator`: Generating MIME documents -------------------------------------------------- +:mod:`email`: Generating MIME documents +--------------------------------------- .. module:: email.generator :synopsis: Generate flat text email messages from a message structure. @@ -17,10 +17,10 @@ standards-compliant way, should handle MIME and non-MIME email messages just fine, and is designed so that the transformation from flat text, to a message structure via the :class:`~email.parser.Parser` class, and back to flat text, -is idempotent (the input is identical to the output) [#]_. On the other hand, -using the Generator on a :class:`~email.message.Message` constructed by program -may result in changes to the :class:`~email.message.Message` object as defaults -are filled in. +is idempotent (the input is identical to the output). On the other hand, using +the Generator on a :class:`~email.message.Message` constructed by program may +result in changes to the :class:`~email.message.Message` object as defaults are +filled in. Here are the public methods of the :class:`Generator` class, imported from the :mod:`email.generator` module: @@ -125,11 +125,3 @@ .. versionchanged:: 2.5 The previously deprecated method :meth:`__call__` was removed. - -.. rubric:: Footnotes - -.. [#] This statement assumes that you use the appropriate setting for the - ``unixfrom`` argument, and that you set maxheaderlen=0 (which will - preserve whatever the input line lengths were). It is also not strictly - true, since in many cases runs of whitespace in headers are collapsed - into single blanks. The latter is a bug that will eventually be fixed. diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/library/email.header.rst --- a/Doc/library/email.header.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/library/email.header.rst Sun Jul 20 10:52:46 2014 -0400 @@ -1,5 +1,5 @@ -:mod:`email.header`: Internationalized headers ----------------------------------------------- +:mod:`email`: Internationalized headers +--------------------------------------- .. module:: email.header :synopsis: Representing non-ASCII headers @@ -103,7 +103,7 @@ not provoke a :exc:`UnicodeError` is used. Optional *errors* is passed through to any :func:`unicode` or - :meth:`unicode.encode` call, and defaults to "strict". + :func:`ustr.encode` call, and defaults to "strict". .. method:: encode([splitchars]) diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/library/email.iterators.rst --- a/Doc/library/email.iterators.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/library/email.iterators.rst Sun Jul 20 10:52:46 2014 -0400 @@ -1,14 +1,13 @@ -:mod:`email.iterators`: Iterators ---------------------------------- +:mod:`email`: Iterators +----------------------- .. module:: email.iterators :synopsis: Iterate over a message object tree. Iterating over a message object tree is fairly easy with the -:meth:`Message.walk ` method. The -:mod:`email.iterators` module provides some useful higher level iterations over -message object trees. +:meth:`Message.walk` method. The :mod:`email.iterators` module provides some +useful higher level iterations over message object trees. .. function:: body_line_iterator(msg[, decode]) @@ -17,11 +16,9 @@ string payloads line-by-line. It skips over all the subpart headers, and it skips over any subpart with a payload that isn't a Python string. This is somewhat equivalent to reading the flat text representation of the message from - a file using :meth:`~io.TextIOBase.readline`, skipping over all the - intervening headers. + a file using :meth:`readline`, skipping over all the intervening headers. - Optional *decode* is passed through to :meth:`Message.get_payload - `. + Optional *decode* is passed through to :meth:`Message.get_payload`. .. function:: typed_subpart_iterator(msg[, maintype[, subtype]]) diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/library/email.message.rst --- a/Doc/library/email.message.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/library/email.message.rst Sun Jul 20 10:52:46 2014 -0400 @@ -1,5 +1,5 @@ -:mod:`email.message`: Representing an email message ---------------------------------------------------- +:mod:`email`: Representing an email message +------------------------------------------- .. module:: email.message :synopsis: The base class representing email messages. @@ -48,8 +48,8 @@ Note that this method is provided as a convenience and may not always format the message the way you want. For example, by default it mangles lines that begin with ``From``. For more flexibility, instantiate a - :class:`~email.generator.Generator` instance and use its - :meth:`~email.generator.Generator.flatten` method directly. For example:: + :class:`~email.generator.Generator` instance and use its :meth:`flatten` + method directly. For example:: from cStringIO import StringIO from email.generator import Generator @@ -68,7 +68,7 @@ Return ``True`` if the message's payload is a list of sub-\ :class:`Message` objects, otherwise return ``False``. When - :meth:`is_multipart` returns ``False``, the payload should be a string object. + :meth:`is_multipart` returns False, the payload should be a string object. .. method:: set_unixfrom(unixfrom) @@ -494,8 +494,8 @@ Set the ``boundary`` parameter of the :mailheader:`Content-Type` header to *boundary*. :meth:`set_boundary` will always quote *boundary* if - necessary. A :exc:`~email.errors.HeaderParseError` is raised if the - message object has no :mailheader:`Content-Type` header. + necessary. A :exc:`HeaderParseError` is raised if the message object has + no :mailheader:`Content-Type` header. Note that using this method is subtly different than deleting the old :mailheader:`Content-Type` header and adding a new one with the new @@ -589,8 +589,7 @@ .. versionchanged:: 2.5 You do not need to set the epilogue to the empty string in order for the - :class:`~email.generator.Generator` to print a newline at the end of the - file. + :class:`Generator` to print a newline at the end of the file. .. attribute:: defects diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/library/email.mime.rst --- a/Doc/library/email.mime.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/library/email.mime.rst Sun Jul 20 10:52:46 2014 -0400 @@ -1,5 +1,5 @@ -:mod:`email.mime`: Creating email and MIME objects from scratch ---------------------------------------------------------------- +:mod:`email`: Creating email and MIME objects from scratch +---------------------------------------------------------- .. module:: email.mime :synopsis: Build MIME messages. @@ -35,8 +35,7 @@ *_maintype* is the :mailheader:`Content-Type` major type (e.g. :mimetype:`text` or :mimetype:`image`), and *_subtype* is the :mailheader:`Content-Type` minor type (e.g. :mimetype:`plain` or :mimetype:`gif`). *_params* is a parameter - key/value dictionary and is passed directly to :meth:`Message.add_header - `. + key/value dictionary and is passed directly to :meth:`Message.add_header`. The :class:`MIMEBase` class always adds a :mailheader:`Content-Type` header (based on *_maintype*, *_subtype*, and *_params*), and a @@ -51,9 +50,8 @@ A subclass of :class:`~email.mime.base.MIMEBase`, this is an intermediate base class for MIME messages that are not :mimetype:`multipart`. The primary - purpose of this class is to prevent the use of the - :meth:`~email.message.Message.attach` method, which only makes sense for - :mimetype:`multipart` messages. If :meth:`~email.message.Message.attach` + purpose of this class is to prevent the use of the :meth:`attach` method, + which only makes sense for :mimetype:`multipart` messages. If :meth:`attach` is called, a :exc:`~email.errors.MultipartConversionError` exception is raised. .. versionadded:: 2.2.2 @@ -78,8 +76,7 @@ *_subparts* is a sequence of initial subparts for the payload. It must be possible to convert this sequence to a list. You can always attach new subparts - to the message by using the :meth:`Message.attach - ` method. + to the message by using the :meth:`Message.attach` method. Additional parameters for the :mailheader:`Content-Type` header are taken from the keyword arguments, or passed into the *_params* argument, which is a keyword @@ -102,10 +99,8 @@ Optional *_encoder* is a callable (i.e. function) which will perform the actual encoding of the data for transport. This callable takes one argument, which is - the :class:`MIMEApplication` instance. It should use - :meth:`~email.message.Message.get_payload` and - :meth:`~email.message.Message.set_payload` to change the payload to encoded - form. It should also add + the :class:`MIMEApplication` instance. It should use :meth:`get_payload` and + :meth:`set_payload` to change the payload to encoded form. It should also add any :mailheader:`Content-Transfer-Encoding` or other headers to the message object as necessary. The default encoding is base64. See the :mod:`email.encoders` module for a list of the built-in encoders. @@ -132,10 +127,8 @@ Optional *_encoder* is a callable (i.e. function) which will perform the actual encoding of the audio data for transport. This callable takes one argument, - which is the :class:`MIMEAudio` instance. It should use - :meth:`~email.message.Message.get_payload` and - :meth:`~email.message.Message.set_payload` to change the payload to encoded - form. It should also add + which is the :class:`MIMEAudio` instance. It should use :meth:`get_payload` and + :meth:`set_payload` to change the payload to encoded form. It should also add any :mailheader:`Content-Transfer-Encoding` or other headers to the message object as necessary. The default encoding is base64. See the :mod:`email.encoders` module for a list of the built-in encoders. @@ -160,10 +153,8 @@ Optional *_encoder* is a callable (i.e. function) which will perform the actual encoding of the image data for transport. This callable takes one argument, - which is the :class:`MIMEImage` instance. It should use - :meth:`~email.message.Message.get_payload` and - :meth:`~email.message.Message.set_payload` to change the payload to encoded - form. It should also add + which is the :class:`MIMEImage` instance. It should use :meth:`get_payload` and + :meth:`set_payload` to change the payload to encoded form. It should also add any :mailheader:`Content-Transfer-Encoding` or other headers to the message object as necessary. The default encoding is base64. See the :mod:`email.encoders` module for a list of the built-in encoders. @@ -208,12 +199,3 @@ Transfer Encoding now happens implicitly based on the *_charset* argument. - Unless the ``_charset`` parameter is explicitly set to ``None``, the - MIMEText object created will have both a :mailheader:`Content-Type` header - with a ``charset`` parameter, and a :mailheader:`Content-Transfer-Endcoding` - header. This means that a subsequent ``set_payload`` call will not result - in an encoded payload, even if a charset is passed in the ``set_payload`` - command. You can "reset" this behavior by deleting the - ``Content-Transfer-Encoding`` header, after which a ``set_payload`` call - will automatically encode the new payload (and add a new - :mailheader:`Content-Transfer-Encoding` header). diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/library/email.parser.rst --- a/Doc/library/email.parser.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/library/email.parser.rst Sun Jul 20 10:52:46 2014 -0400 @@ -1,5 +1,5 @@ -:mod:`email.parser`: Parsing email messages -------------------------------------------- +:mod:`email`: Parsing email messages +------------------------------------ .. module:: email.parser :synopsis: Parse flat text email messages to produce a message object structure. @@ -7,8 +7,7 @@ Message object structures can be created in one of two ways: they can be created from whole cloth by instantiating :class:`~email.message.Message` objects and -stringing them together via :meth:`~email.message.Message.attach` and -:meth:`~email.message.Message.set_payload` calls, or they +stringing them together via :meth:`attach` and :meth:`set_payload` calls, or they can be created by parsing a flat text representation of the email message. The :mod:`email` package provides a standard parser that understands most email @@ -17,9 +16,8 @@ :class:`~email.message.Message` instance of the object structure. For simple, non-MIME messages the payload of this root object will likely be a string containing the text of the message. For MIME messages, the root object will -return ``True`` from its :meth:`~email.message.Message.is_multipart` method, and -the subparts can be accessed via the :meth:`~email.message.Message.get_payload` -and :meth:`~email.message.Message.walk` methods. +return ``True`` from its :meth:`is_multipart` method, and the subparts can be +accessed via the :meth:`get_payload` and :meth:`walk` methods. There are actually two parser interfaces available for use, the classic :class:`Parser` API and the incremental :class:`FeedParser` API. The classic @@ -129,8 +127,7 @@ Read all the data from the file-like object *fp*, parse the resulting text, and return the root message object. *fp* must support both the - :meth:`~io.TextIOBase.readline` and the :meth:`~io.TextIOBase.read` - methods on file-like objects. + :meth:`readline` and the :meth:`read` methods on file-like objects. The text contained in *fp* must be formatted as a block of :rfc:`2822` style headers and header continuation lines, optionally preceded by a @@ -138,9 +135,7 @@ data or by a blank line. Following the header block is the body of the message (which may contain MIME-encoded subparts). - Optional *headersonly* is a flag specifying whether to stop parsing after - reading the headers or not. The default is ``False``, meaning it parses - the entire contents of the file. + Optional *headersonly* is as with the :meth:`parse` method. .. versionchanged:: 2.2.2 The *headersonly* flag was added. @@ -150,10 +145,12 @@ Similar to the :meth:`parse` method, except it takes a string object instead of a file-like object. Calling this method on a string is exactly - equivalent to wrapping *text* in a :class:`~StringIO.StringIO` instance first and + equivalent to wrapping *text* in a :class:`StringIO` instance first and calling :meth:`parse`. - Optional *headersonly* is as with the :meth:`parse` method. + Optional *headersonly* is a flag specifying whether to stop parsing after + reading the headers or not. The default is ``False``, meaning it parses + the entire contents of the file. .. versionchanged:: 2.2.2 The *headersonly* flag was added. @@ -168,7 +165,7 @@ Return a message object structure from a string. This is exactly equivalent to ``Parser().parsestr(s)``. Optional *_class* and *strict* are interpreted as - with the :class:`~email.parser.Parser` class constructor. + with the :class:`Parser` class constructor. .. versionchanged:: 2.2.2 The *strict* flag was added. @@ -178,7 +175,7 @@ Return a message object structure tree from an open file object. This is exactly equivalent to ``Parser().parse(fp)``. Optional *_class* and *strict* - are interpreted as with the :class:`~email.parser.Parser` class constructor. + are interpreted as with the :class:`Parser` class constructor. .. versionchanged:: 2.2.2 The *strict* flag was added. @@ -196,35 +193,32 @@ * Most non-\ :mimetype:`multipart` type messages are parsed as a single message object with a string payload. These objects will return ``False`` for - :meth:`~email.message.Message.is_multipart`. Their - :meth:`~email.message.Message.get_payload` method will return a string object. + :meth:`is_multipart`. Their :meth:`get_payload` method will return a string + object. * All :mimetype:`multipart` type messages will be parsed as a container message object with a list of sub-message objects for their payload. The outer - container message will return ``True`` for - :meth:`~email.message.Message.is_multipart` and their - :meth:`~email.message.Message.get_payload` method will return the list of - :class:`~email.message.Message` subparts. + container message will return ``True`` for :meth:`is_multipart` and their + :meth:`get_payload` method will return the list of :class:`~email.message.Message` + subparts. * Most messages with a content type of :mimetype:`message/\*` (e.g. :mimetype:`message/delivery-status` and :mimetype:`message/rfc822`) will also be parsed as container object containing a list payload of length 1. Their - :meth:`~email.message.Message.is_multipart` method will return ``True``. - The single element in the list payload will be a sub-message object. + :meth:`is_multipart` method will return ``True``. The single element in the + list payload will be a sub-message object. * Some non-standards compliant messages may not be internally consistent about their :mimetype:`multipart`\ -edness. Such messages may have a :mailheader:`Content-Type` header of type :mimetype:`multipart`, but their - :meth:`~email.message.Message.is_multipart` method may return ``False``. - If such messages were parsed with the :class:`~email.parser.FeedParser`, - they will have an instance of the - :class:`~email.errors.MultipartInvariantViolationDefect` class in their - *defects* attribute list. See :mod:`email.errors` for details. + :meth:`is_multipart` method may return ``False``. If such messages were parsed + with the :class:`FeedParser`, they will have an instance of the + :class:`MultipartInvariantViolationDefect` class in their *defects* attribute + list. See :mod:`email.errors` for details. .. rubric:: Footnotes .. [#] As of email package version 3.0, introduced in Python 2.4, the classic - :class:`~email.parser.Parser` was re-implemented in terms of the - :class:`~email.parser.FeedParser`, so the semantics and results are - identical between the two parsers. + :class:`Parser` was re-implemented in terms of the :class:`FeedParser`, so the + semantics and results are identical between the two parsers. diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/library/email.rst --- a/Doc/library/email.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/library/email.rst Sun Jul 20 10:52:46 2014 -0400 @@ -112,15 +112,14 @@ *Note that the version 3 names will continue to work until Python 2.6*. * The :mod:`email.mime.application` module was added, which contains the - :class:`~email.mime.application.MIMEApplication` class. + :class:`MIMEApplication` class. * Methods that were deprecated in version 3 have been removed. These include :meth:`Generator.__call__`, :meth:`Message.get_type`, :meth:`Message.get_main_type`, :meth:`Message.get_subtype`. * Fixes have been added for :rfc:`2231` support which can change some of the - return types for :func:`Message.get_param ` - and friends. Under some + return types for :func:`Message.get_param` and friends. Under some circumstances, values which used to return a 3-tuple now return simple strings (specifically, if all extended parameter segments were unencoded, there is no language and charset designation expected, so the return type is now a simple @@ -129,24 +128,23 @@ Here are the major differences between :mod:`email` version 3 and version 2: -* The :class:`~email.parser.FeedParser` class was introduced, and the - :class:`~email.parser.Parser` class was implemented in terms of the - :class:`~email.parser.FeedParser`. All parsing therefore is +* The :class:`FeedParser` class was introduced, and the :class:`Parser` class + was implemented in terms of the :class:`FeedParser`. All parsing therefore is non-strict, and parsing will make a best effort never to raise an exception. Problems found while parsing messages are stored in the message's *defect* attribute. * All aspects of the API which raised :exc:`DeprecationWarning`\ s in version 2 have been removed. These include the *_encoder* argument to the - :class:`~email.mime.text.MIMEText` constructor, the - :meth:`Message.add_payload` method, the :func:`Utils.dump_address_pair` - function, and the functions :func:`Utils.decode` and :func:`Utils.encode`. + :class:`MIMEText` constructor, the :meth:`Message.add_payload` method, the + :func:`Utils.dump_address_pair` function, and the functions :func:`Utils.decode` + and :func:`Utils.encode`. * New :exc:`DeprecationWarning`\ s have been added to: :meth:`Generator.__call__`, :meth:`Message.get_type`, :meth:`Message.get_main_type`, :meth:`Message.get_subtype`, and the *strict* - argument to the :class:`~email.parser.Parser` class. These are expected to - be removed in future versions. + argument to the :class:`Parser` class. These are expected to be removed in + future versions. * Support for Pythons earlier than 2.3 has been removed. @@ -154,61 +152,53 @@ * The :mod:`email.Header` and :mod:`email.Charset` modules have been added. -* The pickle format for :class:`~email.message.Message` instances has changed. - Since this was never (and still isn't) formally defined, this isn't - considered a backward incompatibility. However if your application pickles - and unpickles :class:`~email.message.Message` instances, be aware that in - :mod:`email` version 2, :class:`~email.message.Message` instances now have - private variables *_charset* and *_default_type*. +* The pickle format for :class:`Message` instances has changed. Since this was + never (and still isn't) formally defined, this isn't considered a backward + incompatibility. However if your application pickles and unpickles + :class:`Message` instances, be aware that in :mod:`email` version 2, + :class:`Message` instances now have private variables *_charset* and + *_default_type*. -* Several methods in the :class:`~email.message.Message` class have been - deprecated, or their signatures changed. Also, many new methods have been - added. See the documentation for the :class:`~email.message.Message` class - for details. The changes should be completely backward compatible. +* Several methods in the :class:`Message` class have been deprecated, or their + signatures changed. Also, many new methods have been added. See the + documentation for the :class:`Message` class for details. The changes should be + completely backward compatible. * The object structure has changed in the face of :mimetype:`message/rfc822` - content types. In :mod:`email` version 1, such a type would be represented - by a scalar payload, i.e. the container message's - :meth:`~email.message.Message.is_multipart` returned false, - :meth:`~email.message.Message.get_payload` was not a list object, but a - single :class:`~email.message.Message` instance. + content types. In :mod:`email` version 1, such a type would be represented by a + scalar payload, i.e. the container message's :meth:`is_multipart` returned + false, :meth:`get_payload` was not a list object, but a single :class:`Message` + instance. This structure was inconsistent with the rest of the package, so the object representation for :mimetype:`message/rfc822` content types was changed. In :mod:`email` version 2, the container *does* return ``True`` from - :meth:`~email.message.Message.is_multipart`, and - :meth:`~email.message.Message.get_payload` returns a list containing a single - :class:`~email.message.Message` item. + :meth:`is_multipart`, and :meth:`get_payload` returns a list containing a single + :class:`Message` item. - Note that this is one place that backward compatibility could not be - completely maintained. However, if you're already testing the return type of - :meth:`~email.message.Message.get_payload`, you should be fine. You just need - to make sure your code doesn't do a :meth:`~email.message.Message.set_payload` - with a :class:`~email.message.Message` instance on a container with a content - type of :mimetype:`message/rfc822`. + Note that this is one place that backward compatibility could not be completely + maintained. However, if you're already testing the return type of + :meth:`get_payload`, you should be fine. You just need to make sure your code + doesn't do a :meth:`set_payload` with a :class:`Message` instance on a container + with a content type of :mimetype:`message/rfc822`. -* The :class:`~email.parser.Parser` constructor's *strict* argument was added, - and its :meth:`~email.parser.Parser.parse` and - :meth:`~email.parser.Parser.parsestr` methods grew a *headersonly* argument. - The *strict* flag was also added to functions :func:`email.message_from_file` - and :func:`email.message_from_string`. +* The :class:`Parser` constructor's *strict* argument was added, and its + :meth:`parse` and :meth:`parsestr` methods grew a *headersonly* argument. The + *strict* flag was also added to functions :func:`email.message_from_file` and + :func:`email.message_from_string`. -* :meth:`Generator.__call__` is deprecated; use :meth:`Generator.flatten - ` instead. The - :class:`~email.generator.Generator` class has also grown the - :meth:`~email.generator.Generator.clone` method. +* :meth:`Generator.__call__` is deprecated; use :meth:`Generator.flatten` + instead. The :class:`Generator` class has also grown the :meth:`clone` method. -* The :class:`~email.generator.DecodedGenerator` class in the - :mod:`email.generator` module was added. +* The :class:`DecodedGenerator` class in the :mod:`email.Generator` module was + added. -* The intermediate base classes - :class:`~email.mime.nonmultipart.MIMENonMultipart` and - :class:`~email.mime.multipart.MIMEMultipart` have been added, and interposed - in the class hierarchy for most of the other MIME-related derived classes. +* The intermediate base classes :class:`MIMENonMultipart` and + :class:`MIMEMultipart` have been added, and interposed in the class hierarchy + for most of the other MIME-related derived classes. -* The *_encoder* argument to the :class:`~email.mime.text.MIMEText` constructor - has been deprecated. Encoding now happens implicitly based on the - *_charset* argument. +* The *_encoder* argument to the :class:`MIMEText` constructor has been + deprecated. Encoding now happens implicitly based on the *_charset* argument. * The following functions in the :mod:`email.Utils` module have been deprecated: :func:`dump_address_pairs`, :func:`decode`, and :func:`encode`. The following @@ -241,22 +231,17 @@ * :func:`messageFromFile` has been renamed to :func:`message_from_file`. -The :class:`~email.message.Message` class has the following differences: +The :class:`Message` class has the following differences: -* The method :meth:`asString` was renamed to - :meth:`~email.message.Message.as_string`. +* The method :meth:`asString` was renamed to :meth:`as_string`. -* The method :meth:`ismultipart` was renamed to - :meth:`~email.message.Message.is_multipart`. +* The method :meth:`ismultipart` was renamed to :meth:`is_multipart`. -* The :meth:`~email.message.Message.get_payload` method has grown a *decode* - optional argument. +* The :meth:`get_payload` method has grown a *decode* optional argument. -* The method :meth:`getall` was renamed to - :meth:`~email.message.Message.get_all`. +* The method :meth:`getall` was renamed to :meth:`get_all`. -* The method :meth:`addheader` was renamed to - :meth:`~email.message.Message.add_header`. +* The method :meth:`addheader` was renamed to :meth:`add_header`. * The method :meth:`gettype` was renamed to :meth:`get_type`. @@ -264,57 +249,48 @@ * The method :meth:`getsubtype` was renamed to :meth:`get_subtype`. -* The method :meth:`getparams` was renamed to - :meth:`~email.message.Message.get_params`. Also, whereas :meth:`getparams` - returned a list of strings, :meth:`~email.message.Message.get_params` returns - a list of 2-tuples, effectively the key/value pairs of the parameters, split - on the ``'='`` sign. +* The method :meth:`getparams` was renamed to :meth:`get_params`. Also, whereas + :meth:`getparams` returned a list of strings, :meth:`get_params` returns a list + of 2-tuples, effectively the key/value pairs of the parameters, split on the + ``'='`` sign. -* The method :meth:`getparam` was renamed to - :meth:`~email.message.Message.get_param`. +* The method :meth:`getparam` was renamed to :meth:`get_param`. -* The method :meth:`getcharsets` was renamed to - :meth:`~email.message.Message.get_charsets`. +* The method :meth:`getcharsets` was renamed to :meth:`get_charsets`. -* The method :meth:`getfilename` was renamed to - :meth:`~email.message.Message.get_filename`. +* The method :meth:`getfilename` was renamed to :meth:`get_filename`. -* The method :meth:`getboundary` was renamed to - :meth:`~email.message.Message.get_boundary`. +* The method :meth:`getboundary` was renamed to :meth:`get_boundary`. -* The method :meth:`setboundary` was renamed to - :meth:`~email.message.Message.set_boundary`. +* The method :meth:`setboundary` was renamed to :meth:`set_boundary`. * The method :meth:`getdecodedpayload` was removed. To get similar - functionality, pass the value 1 to the *decode* flag of the - :meth:`~email.message.Message.get_payload` method. + functionality, pass the value 1 to the *decode* flag of the get_payload() + method. * The method :meth:`getpayloadastext` was removed. Similar functionality is - supported by the :class:`~email.generator.DecodedGenerator` class in the - :mod:`email.generator` module. + supported by the :class:`DecodedGenerator` class in the :mod:`email.generator` + module. * The method :meth:`getbodyastext` was removed. You can get similar - functionality by creating an iterator with - :func:`~email.iterators.typed_subpart_iterator` in the :mod:`email.iterators` - module. + functionality by creating an iterator with :func:`typed_subpart_iterator` in the + :mod:`email.iterators` module. -The :class:`~email.parser.Parser` class has no differences in its public -interface. It does have some additional smarts to recognize -:mimetype:`message/delivery-status` type messages, which it represents as a -:class:`~email.message.Message` instance containing separate -:class:`~email.message.Message` subparts for each header block in the delivery -status notification [#]_. +The :class:`Parser` class has no differences in its public interface. It does +have some additional smarts to recognize :mimetype:`message/delivery-status` +type messages, which it represents as a :class:`Message` instance containing +separate :class:`Message` subparts for each header block in the delivery status +notification [#]_. -The :class:`~email.generator.Generator` class has no differences in its public -interface. There is a new class in the :mod:`email.generator` module though, -called :class:`~email.generator.DecodedGenerator` which provides most of the -functionality previously available in the :meth:`Message.getpayloadastext` -method. +The :class:`Generator` class has no differences in its public interface. There +is a new class in the :mod:`email.generator` module though, called +:class:`DecodedGenerator` which provides most of the functionality previously +available in the :meth:`Message.getpayloadastext` method. The following modules and classes have been changed: -* The :class:`~email.mime.base.MIMEBase` class constructor arguments *_major* - and *_minor* have changed to *_maintype* and *_subtype* respectively. +* The :class:`MIMEBase` class constructor arguments *_major* and *_minor* have + changed to *_maintype* and *_subtype* respectively. * The ``Image`` class/module has been renamed to ``MIMEImage``. The *_minor* argument has been renamed to *_subtype*. @@ -327,8 +303,7 @@ but that clashed with the Python standard library module :mod:`rfc822` on some case-insensitive file systems. - Also, the :class:`~email.mime.message.MIMEMessage` class now represents any - kind of MIME message + Also, the :class:`MIMEMessage` class now represents any kind of MIME message with main type :mimetype:`message`. It takes an optional argument *_subtype* which is used to set the MIME subtype. *_subtype* defaults to :mimetype:`rfc822`. @@ -338,8 +313,8 @@ :mod:`email.utils` module. The ``MsgReader`` class/module has been removed. Its functionality is most -closely supported in the :func:`~email.iterators.body_line_iterator` function -in the :mod:`email.iterators` module. +closely supported in the :func:`body_line_iterator` function in the +:mod:`email.iterators` module. .. rubric:: Footnotes diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/library/email.util.rst --- a/Doc/library/email.util.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/library/email.util.rst Sun Jul 20 10:52:46 2014 -0400 @@ -1,5 +1,5 @@ -:mod:`email.utils`: Miscellaneous utilities -------------------------------------------- +:mod:`email`: Miscellaneous utilities +------------------------------------- .. module:: email.utils :synopsis: Miscellaneous email package utilities. @@ -41,8 +41,8 @@ This method returns a list of 2-tuples of the form returned by ``parseaddr()``. *fieldvalues* is a sequence of header field values as might be returned by - :meth:`Message.get_all `. Here's a simple - example that gets all the recipients of a message:: + :meth:`Message.get_all`. Here's a simple example that gets all the recipients + of a message:: from email.utils import getaddresses @@ -76,9 +76,12 @@ .. function:: mktime_tz(tuple) - Turn a 10-tuple as returned by :func:`parsedate_tz` into a UTC - timestamp (seconds since the Epoch). If the timezone item in the - tuple is ``None``, assume local time. + Turn a 10-tuple as returned by :func:`parsedate_tz` into a UTC timestamp. It + the timezone item in the tuple is ``None``, assume local time. Minor + deficiency: :func:`mktime_tz` interprets the first 8 elements of *tuple* as a + local time and then compensates for the timezone difference. This may yield a + slight error around changes in daylight savings time, though not worth worrying + about for common use. .. function:: formatdate([timeval[, localtime][, usegmt]]) @@ -127,8 +130,7 @@ .. function:: collapse_rfc2231_value(value[, errors[, fallback_charset]]) When a header parameter is encoded in :rfc:`2231` format, - :meth:`Message.get_param ` may return a - 3-tuple containing the character set, + :meth:`Message.get_param` may return a 3-tuple containing the character set, language, and value. :func:`collapse_rfc2231_value` turns this into a unicode string. Optional *errors* is passed to the *errors* argument of the built-in :func:`unicode` function; it defaults to ``replace``. Optional @@ -150,15 +152,15 @@ .. versionchanged:: 2.4 The :func:`decode` function has been removed; use the - :meth:`Header.decode_header ` method - instead. + :meth:`Header.decode_header` method instead. .. versionchanged:: 2.4 - The :func:`encode` function has been removed; use the :meth:`Header.encode - ` method instead. + The :func:`encode` function has been removed; use the :meth:`Header.encode` + method instead. .. rubric:: Footnotes .. [#] Note that the sign of the timezone offset is the opposite of the sign of the ``time.timezone`` variable for the same timezone; the latter variable follows the POSIX standard while this module follows :rfc:`2822`. + diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/library/exceptions.rst --- a/Doc/library/exceptions.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/library/exceptions.rst Sun Jul 20 10:52:46 2014 -0400 @@ -38,10 +38,10 @@ interpreter raises the same exception; but beware that there is nothing to prevent user code from raising an inappropriate error. -The built-in exception classes can be subclassed to define new exceptions; -programmers are encouraged to derive new exceptions from the :exc:`Exception` -class or one of its subclasses, and not from :exc:`BaseException`. More -information on defining exceptions is available in the Python Tutorial under +The built-in exception classes can be sub-classed to define new exceptions; +programmers are encouraged to at least derive new exceptions from the +:exc:`Exception` class and not :exc:`BaseException`. More information on +defining exceptions is available in the Python Tutorial under :ref:`tut-userexceptions`. The following exceptions are only used as base classes for other exceptions. @@ -158,9 +158,9 @@ .. exception:: GeneratorExit - Raised when a :term:`generator`\'s :meth:`close` method is called. It - directly inherits from :exc:`BaseException` instead of :exc:`StandardError` - since it is technically not an error. + Raise when a :term:`generator`\'s :meth:`close` method is called. It + directly inherits from :exc:`BaseException` instead of :exc:`StandardError` since + it is technically not an error. .. versionadded:: 2.5 @@ -220,7 +220,7 @@ Raised when an operation runs out of memory but the situation may still be rescued (by deleting some objects). The associated value is a string indicating what kind of (internal) operation ran out of memory. Note that because of the - underlying memory management architecture (C's :c:func:`malloc` function), the + underlying memory management architecture (C's :cfunc:`malloc` function), the interpreter may not always be able to completely recover from this situation; it nevertheless raises an exception so that a stack traceback can be printed, in case a run-away program was the cause. @@ -249,8 +249,8 @@ This exception is derived from :exc:`EnvironmentError`. It is raised when a function returns a system-related error (not for illegal argument types or other incidental errors). The :attr:`errno` attribute is a numeric error - code from :c:data:`errno`, and the :attr:`strerror` attribute is the - corresponding string, as would be printed by the C function :c:func:`perror`. + code from :cdata:`errno`, and the :attr:`strerror` attribute is the + corresponding string, as would be printed by the C function :cfunc:`perror`. See the module :mod:`errno`, which contains names for the error codes defined by the underlying operating system. @@ -286,7 +286,8 @@ Raised when an error is detected that doesn't fall in any of the other categories. The associated value is a string indicating what precisely went - wrong. + wrong. (This exception is mostly a relic from a previous version of the + interpreter; it is not used very much any more.) .. exception:: StopIteration @@ -341,11 +342,11 @@ This exception is raised by the :func:`sys.exit` function. When it is not handled, the Python interpreter exits; no stack traceback is printed. If the associated value is a plain integer, it specifies the system exit status (passed - to C's :c:func:`exit` function); if it is ``None``, the exit status is zero; if + to C's :cfunc:`exit` function); if it is ``None``, the exit status is zero; if it has another type (such as a string), the object's value is printed and the exit status is one. - Instances have an attribute :attr:`!code` which is set to the proposed exit + Instances have an attribute :attr:`code` which is set to the proposed exit status or error message (defaulting to ``None``). Also, this exception derives directly from :exc:`BaseException` and not :exc:`StandardError`, since it is not technically an error. @@ -355,7 +356,7 @@ executed, and so that a debugger can execute a script without running the risk of losing control. The :func:`os._exit` function can be used if it is absolutely positively necessary to exit immediately (for example, in the child - process after a call to :func:`os.fork`). + process after a call to :func:`fork`). The exception inherits from :exc:`BaseException` instead of :exc:`StandardError` or :exc:`Exception` so that it is not accidentally caught by code that catches @@ -386,30 +387,6 @@ Raised when a Unicode-related encoding or decoding error occurs. It is a subclass of :exc:`ValueError`. - :exc:`UnicodeError` has attributes that describe the encoding or decoding - error. For example, ``err.object[err.start:err.end]`` gives the particular - invalid input that the codec failed on. - - .. attribute:: encoding - - The name of the encoding that raised the error. - - .. attribute:: reason - - A string describing the specific codec error. - - .. attribute:: object - - The object the codec was attempting to encode or decode. - - .. attribute:: start - - The first index of invalid data in :attr:`object`. - - .. attribute:: end - - The index after the last invalid data in :attr:`object`. - .. versionadded:: 2.0 @@ -452,16 +429,16 @@ .. exception:: WindowsError Raised when a Windows-specific error occurs or when the error number does not - correspond to an :c:data:`errno` value. The :attr:`winerror` and + correspond to an :cdata:`errno` value. The :attr:`winerror` and :attr:`strerror` values are created from the return values of the - :c:func:`GetLastError` and :c:func:`FormatMessage` functions from the Windows + :cfunc:`GetLastError` and :cfunc:`FormatMessage` functions from the Windows Platform API. The :attr:`errno` value maps the :attr:`winerror` value to corresponding ``errno.h`` values. This is a subclass of :exc:`OSError`. .. versionadded:: 2.0 .. versionchanged:: 2.5 - Previous versions put the :c:func:`GetLastError` codes into :attr:`errno`. + Previous versions put the :cfunc:`GetLastError` codes into :attr:`errno`. .. exception:: ZeroDivisionError diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/library/fcntl.rst --- a/Doc/library/fcntl.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/library/fcntl.rst Sun Jul 20 10:52:46 2014 -0400 @@ -1,5 +1,6 @@ -:mod:`fcntl` --- The ``fcntl`` and ``ioctl`` system calls -========================================================= + +:mod:`fcntl` --- The :func:`fcntl` and :func:`ioctl` system calls +================================================================= .. module:: fcntl :platform: Unix @@ -12,55 +13,50 @@ pair: UNIX; I/O control This module performs file control and I/O control on file descriptors. It is an -interface to the :c:func:`fcntl` and :c:func:`ioctl` Unix routines. +interface to the :cfunc:`fcntl` and :cfunc:`ioctl` Unix routines. All functions in this module take a file descriptor *fd* as their first argument. This can be an integer file descriptor, such as returned by ``sys.stdin.fileno()``, or a file object, such as ``sys.stdin`` itself, which -provides a :meth:`~io.IOBase.fileno` which returns a genuine file descriptor. +provides a :meth:`fileno` which returns a genuine file descriptor. The module defines the following functions: .. function:: fcntl(fd, op[, arg]) - Perform the operation *op* on file descriptor *fd* (file objects providing - a :meth:`~io.IOBase.fileno` method are accepted as well). The values used - for for *op* are operating system dependent, and are available as constants - in the :mod:`fcntl` module, using the same names as used in the relevant C - header files. The argument *arg* is optional, and defaults to the integer + Perform the requested operation on file descriptor *fd* (file objects providing + a :meth:`fileno` method are accepted as well). The operation is defined by *op* + and is operating system dependent. These codes are also found in the + :mod:`fcntl` module. The argument *arg* is optional, and defaults to the integer value ``0``. When present, it can either be an integer value, or a string. With the argument missing or an integer value, the return value of this function - is the integer return value of the C :c:func:`fcntl` call. When the argument is + is the integer return value of the C :cfunc:`fcntl` call. When the argument is a string it represents a binary structure, e.g. created by :func:`struct.pack`. The binary data is copied to a buffer whose address is passed to the C - :c:func:`fcntl` call. The return value after a successful call is the contents + :cfunc:`fcntl` call. The return value after a successful call is the contents of the buffer, converted to a string object. The length of the returned string will be the same as the length of the *arg* argument. This is limited to 1024 bytes. If the information returned in the buffer by the operating system is larger than 1024 bytes, this is most likely to result in a segmentation violation or a more subtle data corruption. - If the :c:func:`fcntl` fails, an :exc:`IOError` is raised. + If the :cfunc:`fcntl` fails, an :exc:`IOError` is raised. .. function:: ioctl(fd, op[, arg[, mutate_flag]]) - This function is identical to the :func:`~fcntl.fcntl` function, except that the + This function is identical to the :func:`fcntl` function, except that the operations are typically defined in the library module :mod:`termios` and the argument handling is even more complicated. The op parameter is limited to values that can fit in 32-bits. - Additional constants of interest for use as the *op* argument can be - found in the :mod:`termios` module, under the same names as used in - the relevant C header files. The parameter *arg* can be one of an integer, absent (treated identically to the integer ``0``), an object supporting the read-only buffer interface (most likely a plain Python string) or an object supporting the read-write buffer interface. - In all but the last case, behaviour is as for the :func:`~fcntl.fcntl` - function. + In all but the last case, behaviour is as for the :func:`fcntl` function. If a mutable buffer is passed, then the behaviour is determined by the value of the *mutate_flag* parameter. @@ -99,16 +95,16 @@ .. function:: flock(fd, op) Perform the lock operation *op* on file descriptor *fd* (file objects providing - a :meth:`~io.IOBase.fileno` method are accepted as well). See the Unix manual + a :meth:`fileno` method are accepted as well). See the Unix manual :manpage:`flock(2)` for details. (On some systems, this function is emulated - using :c:func:`fcntl`.) + using :cfunc:`fcntl`.) .. function:: lockf(fd, operation, [length, [start, [whence]]]) - This is essentially a wrapper around the :func:`~fcntl.fcntl` locking calls. - *fd* is the file descriptor of the file to lock or unlock, and *operation* - is one of the following values: + This is essentially a wrapper around the :func:`fcntl` locking calls. *fd* is + the file descriptor of the file to lock or unlock, and *operation* is one of the + following values: * :const:`LOCK_UN` -- unlock * :const:`LOCK_SH` -- acquire a shared lock @@ -123,13 +119,13 @@ systems, :const:`LOCK_EX` can only be used if the file descriptor refers to a file opened for writing. - *length* is the number of bytes to lock, *start* is the byte offset at - which the lock starts, relative to *whence*, and *whence* is as with - :func:`io.IOBase.seek`, specifically: + *length* is the number of bytes to lock, *start* is the byte offset at which the + lock starts, relative to *whence*, and *whence* is as with :func:`fileobj.seek`, + specifically: - * :const:`0` -- relative to the start of the file (:data:`os.SEEK_SET`) - * :const:`1` -- relative to the current buffer position (:data:`os.SEEK_CUR`) - * :const:`2` -- relative to the end of the file (:data:`os.SEEK_END`) + * :const:`0` -- relative to the start of the file (:const:`SEEK_SET`) + * :const:`1` -- relative to the current buffer position (:const:`SEEK_CUR`) + * :const:`2` -- relative to the end of the file (:const:`SEEK_END`) The default for *start* is 0, which means to start at the beginning of the file. The default for *length* is 0 which means to lock to the end of the file. The @@ -154,8 +150,7 @@ .. seealso:: Module :mod:`os` - If the locking flags :data:`~os.O_SHLOCK` and :data:`~os.O_EXLOCK` are - present in the :mod:`os` module (on BSD only), the :func:`os.open` - function provides an alternative to the :func:`lockf` and :func:`flock` - functions. + If the locking flags :const:`O_SHLOCK` and :const:`O_EXLOCK` are present + in the :mod:`os` module (on BSD only), the :func:`os.open` function + provides an alternative to the :func:`lockf` and :func:`flock` functions. diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/library/filecmp.rst --- a/Doc/library/filecmp.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/library/filecmp.rst Sun Jul 20 10:52:46 2014 -0400 @@ -54,9 +54,9 @@ Example:: >>> import filecmp - >>> filecmp.cmp('undoc.rst', 'undoc.rst') # doctest: +SKIP + >>> filecmp.cmp('undoc.rst', 'undoc.rst') True - >>> filecmp.cmp('undoc.rst', 'index.rst') # doctest: +SKIP + >>> filecmp.cmp('undoc.rst', 'index.rst') False @@ -75,9 +75,6 @@ 'tags']``. *hide* is a list of names to hide, and defaults to ``[os.curdir, os.pardir]``. - The :class:`dircmp` class compares files by doing *shallow* comparisons - as described for :func:`filecmp.cmp`. - The :class:`dircmp` class provides the following methods: @@ -97,7 +94,7 @@ Print a comparison between *a* and *b* and common subdirectories (recursively). - The :class:`dircmp` class offers a number of interesting attributes that may be + The :class:`dircmp` offers a number of interesting attributes that may be used to get various bits of information about the directory trees being compared. @@ -106,16 +103,6 @@ to compute are used. - .. attribute:: left - - The directory *a*. - - - .. attribute:: right - - The directory *b*. - - .. attribute:: left_list Files and subdirectories in *a*, filtered by *hide* and *ignore*. @@ -159,14 +146,12 @@ .. attribute:: same_files - Files which are identical in both *a* and *b*, using the class's - file comparison operator. + Files which are identical in both *a* and *b*. .. attribute:: diff_files - Files which are in both *a* and *b*, whose contents differ according - to the class's file comparison operator. + Files which are in both *a* and *b*, whose contents differ. .. attribute:: funny_files @@ -178,18 +163,3 @@ A dictionary mapping names in :attr:`common_dirs` to :class:`dircmp` objects. - -Here is a simplified example of using the ``subdirs`` attribute to search -recursively through two directories to show common different files:: - - >>> from filecmp import dircmp - >>> def print_diff_files(dcmp): - ... for name in dcmp.diff_files: - ... print "diff_file %s found in %s and %s" % (name, dcmp.left, - ... dcmp.right) - ... for sub_dcmp in dcmp.subdirs.values(): - ... print_diff_files(sub_dcmp) - ... - >>> dcmp = dircmp('dir1', 'dir2') # doctest: +SKIP - >>> print_diff_files(dcmp) # doctest: +SKIP - diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/library/fileinput.rst --- a/Doc/library/fileinput.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/library/fileinput.rst Sun Jul 20 10:52:46 2014 -0400 @@ -50,7 +50,7 @@ The following function is the primary interface of this module: -.. function:: input([files[, inplace[, backup[, bufsize[, mode[, openhook]]]]]]) +.. function:: input([files[, inplace[, backup[, mode[, openhook]]]]]) Create an instance of the :class:`FileInput` class. The instance will be used as global state for the functions of this module, and is also returned to use @@ -122,16 +122,15 @@ available for subclassing as well: -.. class:: FileInput([files[, inplace[, backup[,bufsize[, mode[, openhook]]]]]]) +.. class:: FileInput([files[, inplace[, backup[, mode[, openhook]]]]]) Class :class:`FileInput` is the implementation; its methods :meth:`filename`, :meth:`fileno`, :meth:`lineno`, :meth:`filelineno`, :meth:`isfirstline`, - :meth:`isstdin`, :meth:`nextfile` and :meth:`close` correspond to the - functions of the same name in the module. In addition it has a - :meth:`~file.readline` method which returns the next input line, - and a :meth:`__getitem__` method which implements the sequence behavior. - The sequence must be accessed in strictly sequential order; random access - and :meth:`~file.readline` cannot be mixed. + :meth:`isstdin`, :meth:`nextfile` and :meth:`close` correspond to the functions + of the same name in the module. In addition it has a :meth:`readline` method + which returns the next input line, and a :meth:`__getitem__` method which + implements the sequence behavior. The sequence must be accessed in strictly + sequential order; random access and :meth:`readline` cannot be mixed. With *mode* you can specify which file mode will be passed to :func:`open`. It must be one of ``'r'``, ``'rU'``, ``'U'`` and ``'rb'``. diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/library/fl.rst --- a/Doc/library/fl.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/library/fl.rst Sun Jul 20 10:52:46 2014 -0400 @@ -9,7 +9,7 @@ .. deprecated:: 2.6 - The :mod:`fl` module has been removed in Python 3. + The :mod:`fl` module has been deprecated for removal in Python 3.0. .. index:: @@ -29,8 +29,8 @@ the 'current form' maintained by the library to which new FORMS objects are added, all functions that add a FORMS object to a form are methods of the Python object representing the form. Consequently, there are no Python equivalents for -the C functions :c:func:`fl_addto_form` and :c:func:`fl_end_form`, and the -equivalent of :c:func:`fl_bgn_form` is called :func:`fl.make_form`. +the C functions :cfunc:`fl_addto_form` and :cfunc:`fl_end_form`, and the +equivalent of :cfunc:`fl_bgn_form` is called :func:`fl.make_form`. Watch out for the somewhat confusing terminology: FORMS uses the word :dfn:`object` for the buttons, sliders etc. that you can place in a form. In @@ -44,7 +44,7 @@ event handling is available, though, so you can mix FORMS with pure GL windows. **Please note:** importing :mod:`fl` implies a call to the GL function -:c:func:`foreground` and to the FORMS routine :c:func:`fl_init`. +:cfunc:`foreground` and to the FORMS routine :cfunc:`fl_init`. .. _fl-functions: @@ -88,7 +88,7 @@ .. function:: get_rgbmode() Return the current rgb mode. This is the value of the C global variable - :c:data:`fl_rgbmode`. + :cdata:`fl_rgbmode`. .. function:: show_message(str1, str2, str3) @@ -153,8 +153,8 @@ mapcolor() getmcolor() - See the description in the FORMS documentation of :c:func:`fl_color`, - :c:func:`fl_mapcolor` and :c:func:`fl_getmcolor`. + See the description in the FORMS documentation of :cfunc:`fl_color`, + :cfunc:`fl_mapcolor` and :cfunc:`fl_getmcolor`. .. _form-objects: @@ -487,7 +487,7 @@ .. deprecated:: 2.6 - The :mod:`FL` module has been removed in Python 3. + The :mod:`FL` module has been deprecated for removal in Python 3.0. This module defines symbolic constants needed to use the built-in module @@ -509,7 +509,7 @@ .. deprecated:: 2.6 - The :mod:`flp` module has been removed in Python 3. + The :mod:`flp` module has been deprecated for removal in Python 3.0. This module defines functions that can read form definitions created by the diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/library/fm.rst --- a/Doc/library/fm.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/library/fm.rst Sun Jul 20 10:52:46 2014 -0400 @@ -8,7 +8,7 @@ :deprecated: .. deprecated:: 2.6 - The :mod:`fm` module has been removed in Python 3. + The :mod:`fm` module has been deprecated for removal in Python 3.0. @@ -30,7 +30,7 @@ .. function:: init() - Initialization function. Calls :c:func:`fminit`. It is normally not necessary to + Initialization function. Calls :cfunc:`fminit`. It is normally not necessary to call this function, since it is called automatically the first time the :mod:`fm` module is imported. @@ -43,7 +43,7 @@ .. function:: enumerate() Returns a list of available font names. This is an interface to - :c:func:`fmenumerate`. + :cfunc:`fmenumerate`. .. function:: prstr(string) diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/library/fnmatch.rst --- a/Doc/library/fnmatch.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/library/fnmatch.rst Sun Jul 20 10:52:46 2014 -0400 @@ -29,9 +29,6 @@ | ``[!seq]`` | matches any character not in *seq* | +------------+------------------------------------+ -For a literal match, wrap the meta-characters in brackets. -For example, ``'[?]'`` matches the character ``'?'``. - .. index:: module: glob Note that the filename separator (``'/'`` on Unix) is *not* special to this @@ -79,6 +76,8 @@ Return the shell-style *pattern* converted to a regular expression. + Be aware there is no way to quote meta-characters. + Example: >>> import fnmatch, re diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/library/formatter.rst --- a/Doc/library/formatter.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/library/formatter.rst Sun Jul 20 10:52:46 2014 -0400 @@ -341,10 +341,10 @@ output. -.. class:: DumbWriter(file=None, maxcol=72) +.. class:: DumbWriter([file[, maxcol=72]]) Simple writer class which writes output on the file object passed in as *file* - or, if *file* is None, on standard output. The output is simply word-wrapped + or, if *file* is omitted, on standard output. The output is simply word-wrapped to the number of columns specified by *maxcol*. This class is suitable for reflowing a sequence of paragraphs. diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/library/fpectl.rst --- a/Doc/library/fpectl.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/library/fpectl.rst Sun Jul 20 10:52:46 2014 -0400 @@ -113,8 +113,8 @@ .. seealso:: Some files in the source distribution may be interesting in learning more about - how this module operates. The include file :source:`Include/pyfpe.h` discusses the - implementation of this module at some length. :source:`Modules/fpetestmodule.c` + how this module operates. The include file :file:`Include/pyfpe.h` discusses the + implementation of this module at some length. :file:`Modules/fpetestmodule.c` gives several examples of use. Many additional examples can be found in - :source:`Objects/floatobject.c`. + :file:`Objects/floatobject.c`. diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/library/fpformat.rst --- a/Doc/library/fpformat.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/library/fpformat.rst Sun Jul 20 10:52:46 2014 -0400 @@ -7,7 +7,7 @@ :deprecated: .. deprecated:: 2.6 - The :mod:`fpformat` module has been removed in Python 3. + The :mod:`fpformat` module has been removed in Python 3.0. .. sectionauthor:: Moshe Zadka diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/library/fractions.rst --- a/Doc/library/fractions.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/library/fractions.rst Sun Jul 20 10:52:46 2014 -0400 @@ -57,6 +57,7 @@ Fraction(0, 1) >>> Fraction('3/7') Fraction(3, 7) + [40794 refs] >>> Fraction(' -3/7 ') Fraction(-3, 7) >>> Fraction('1.414213 \t\n') diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/library/ftplib.rst --- a/Doc/library/ftplib.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/library/ftplib.rst Sun Jul 20 10:52:46 2014 -0400 @@ -23,17 +23,16 @@ Here's a sample session using the :mod:`ftplib` module:: >>> from ftplib import FTP - >>> ftp = FTP('ftp.debian.org') # connect to host, default port - >>> ftp.login() # user anonymous, passwd anonymous@ - '230 Login successful.' - >>> ftp.cwd('debian') # change into "debian" directory - >>> ftp.retrlines('LIST') # list directory contents - -rw-rw-r-- 1 1176 1176 1063 Jun 15 10:18 README - ... - drwxr-sr-x 5 1176 1176 4096 Dec 19 2000 pool - drwxr-sr-x 4 1176 1176 4096 Nov 17 2008 project - drwxr-xr-x 3 1176 1176 4096 Oct 10 2012 tools - '226 Directory send OK.' + >>> ftp = FTP('ftp.cwi.nl') # connect to host, default port + >>> ftp.login() # user anonymous, passwd anonymous@ + >>> ftp.retrlines('LIST') # list directory contents + total 24418 + drwxrwsr-x 5 ftp-usr pdmaint 1536 Mar 20 09:48 . + dr-xr-srwt 105 ftp-usr pdmaint 1536 Mar 21 14:32 .. + -rw-r--r-- 1 ftp-usr pdmaint 5305 Mar 20 09:48 INDEX + . + . + . >>> ftp.retrbinary('RETR README', open('README', 'wb').write) '226 Transfer complete.' >>> ftp.quit() @@ -265,8 +264,8 @@ Store a file in ASCII transfer mode. *command* should be an appropriate ``STOR`` command (see :meth:`storbinary`). Lines are read until EOF from the - open file object *file* using its :meth:`~file.readline` method to provide - the data to be stored. *callback* is an optional single parameter callable + open file object *file* using its :meth:`readline` method to provide the data to + be stored. *callback* is an optional single parameter callable that is called on each line after it is sent. .. versionchanged:: 2.6 @@ -371,10 +370,10 @@ .. method:: FTP.close() Close the connection unilaterally. This should not be applied to an already - closed connection such as after a successful call to :meth:`~FTP.quit`. - After this call the :class:`FTP` instance should not be used any more (after - a call to :meth:`close` or :meth:`~FTP.quit` you cannot reopen the - connection by issuing another :meth:`login` method). + closed connection such as after a successful call to :meth:`quit`. After this + call the :class:`FTP` instance should not be used any more (after a call to + :meth:`close` or :meth:`quit` you cannot reopen the connection by issuing + another :meth:`login` method). FTP_TLS Objects @@ -388,8 +387,7 @@ .. method:: FTP_TLS.auth() - Set up secure control connection by using TLS or SSL, depending on what - specified in :meth:`ssl_version` attribute. + Set up secure control connection by using TLS or SSL, depending on what specified in :meth:`ssl_version` attribute. .. method:: FTP_TLS.prot_p() @@ -398,3 +396,5 @@ .. method:: FTP_TLS.prot_c() Set up clear text data connection. + + diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/library/functions.rst --- a/Doc/library/functions.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/library/functions.rst Sun Jul 20 10:52:46 2014 -0400 @@ -18,26 +18,16 @@ :func:`bool` :func:`filter` :func:`len` :func:`range` :func:`type` :func:`bytearray` :func:`float` :func:`list` :func:`raw_input` :func:`unichr` :func:`callable` :func:`format` :func:`locals` :func:`reduce` :func:`unicode` -:func:`chr` |func-frozenset|_ :func:`long` :func:`reload` :func:`vars` -:func:`classmethod` :func:`getattr` :func:`map` |func-repr|_ :func:`xrange` +:func:`chr` :func:`frozenset` :func:`long` :func:`reload` :func:`vars` +:func:`classmethod` :func:`getattr` :func:`map` :func:`repr` :func:`xrange` :func:`cmp` :func:`globals` :func:`max` :func:`reversed` :func:`zip` -:func:`compile` :func:`hasattr` |func-memoryview|_ :func:`round` :func:`__import__` -:func:`complex` :func:`hash` :func:`min` |func-set|_ :func:`apply` +:func:`compile` :func:`hasattr` :func:`memoryview` :func:`round` :func:`__import__` +:func:`complex` :func:`hash` :func:`min` :func:`set` :func:`apply` :func:`delattr` :func:`help` :func:`next` :func:`setattr` :func:`buffer` -|func-dict|_ :func:`hex` :func:`object` :func:`slice` :func:`coerce` +:func:`dict` :func:`hex` :func:`object` :func:`slice` :func:`coerce` :func:`dir` :func:`id` :func:`oct` :func:`sorted` :func:`intern` =================== ================= ================== ================= ==================== -.. using :func:`dict` would create a link to another page, so local targets are - used, with replacement texts to make the output in the table consistent - -.. |func-dict| replace:: ``dict()`` -.. |func-frozenset| replace:: ``frozenset()`` -.. |func-memoryview| replace:: ``memoryview()`` -.. |func-repr| replace:: ``repr()`` -.. |func-set| replace:: ``set()`` - - .. function:: abs(x) Return the absolute value of a number. The argument may be a plain or long @@ -47,7 +37,7 @@ .. function:: all(iterable) - Return ``True`` if all elements of the *iterable* are true (or if the iterable + Return True if all elements of the *iterable* are true (or if the iterable is empty). Equivalent to:: def all(iterable): @@ -61,8 +51,8 @@ .. function:: any(iterable) - Return ``True`` if any element of the *iterable* is true. If the iterable - is empty, return ``False``. Equivalent to:: + Return True if any element of the *iterable* is true. If the iterable + is empty, return False. Equivalent to:: def any(iterable): for element in iterable: @@ -163,10 +153,9 @@ instance method receives the instance. To declare a class method, use this idiom:: - class C(object): + class C: @classmethod - def f(cls, arg1, arg2, ...): - ... + def f(cls, arg1, arg2, ...): ... The ``@classmethod`` form is a function :term:`decorator` -- see the description of function definitions in :ref:`function` for details. @@ -199,10 +188,8 @@ Compile the *source* into a code or AST object. Code objects can be executed by an :keyword:`exec` statement or evaluated by a call to :func:`eval`. - *source* can either be a Unicode string, a *Latin-1* encoded string or an - AST object. - Refer to the :mod:`ast` module documentation for information on how to work - with AST objects. + *source* can either be a string or an AST object. Refer to the :mod:`ast` + module documentation for information on how to work with AST objects. The *filename* argument should give the file from which the code was read; pass some recognizable value if it wasn't read from a file (``''`` is @@ -226,8 +213,8 @@ Future statements are specified by bits which can be bitwise ORed together to specify multiple statements. The bitfield required to specify a given feature - can be found as the :attr:`~__future__._Feature.compiler_flag` attribute on - the :class:`~__future__._Feature` instance in the :mod:`__future__` module. + can be found as the :attr:`compiler_flag` attribute on the :class:`_Feature` + instance in the :mod:`__future__` module. This function raises :exc:`SyntaxError` if the compiled source is invalid, and :exc:`TypeError` if the source contains null bytes. @@ -260,13 +247,6 @@ the function serves as a numeric conversion function like :func:`int`, :func:`long` and :func:`float`. If both arguments are omitted, returns ``0j``. - .. note:: - - When converting from a string, the string must not contain whitespace - around the central ``+`` or ``-`` operator. For example, - ``complex('1+2j')`` is fine, but ``complex('1 + 2j')`` raises - :exc:`ValueError`. - The complex type is described in :ref:`typesnumeric`. @@ -278,18 +258,14 @@ example, ``delattr(x, 'foobar')`` is equivalent to ``del x.foobar``. -.. _func-dict: -.. function:: dict(**kwarg) - dict(mapping, **kwarg) - dict(iterable, **kwarg) +.. function:: dict([arg]) :noindex: - Create a new dictionary. The :class:`dict` object is the dictionary class. - See :class:`dict` and :ref:`typesmapping` for documentation about this - class. + Create a new data dictionary, optionally with items taken from *arg*. + The dictionary type is described in :ref:`typesmapping`. - For other containers see the built-in :class:`list`, :class:`set`, and - :class:`tuple` classes, as well as the :mod:`collections` module. + For other containers see the built in :class:`list`, :class:`set`, and + :class:`tuple` classes, and the :mod:`collections` module. .. function:: dir([object]) @@ -361,7 +337,7 @@ Using :func:`divmod` with complex numbers is deprecated. -.. function:: enumerate(sequence, start=0) +.. function:: enumerate(sequence[, start=0]) Return an enumerate object. *sequence* must be a sequence, an :term:`iterator`, or some other object which supports iteration. The @@ -390,9 +366,9 @@ .. function:: eval(expression[, globals[, locals]]) - The arguments are a Unicode or *Latin-1* encoded string and optional - globals and locals. If provided, *globals* must be a dictionary. - If provided, *locals* can be any mapping object. + The arguments are a string and optional globals and locals. If provided, + *globals* must be a dictionary. If provided, *locals* can be any mapping + object. .. versionchanged:: 2.4 formerly *locals* was required to be a dictionary. @@ -437,10 +413,7 @@ The arguments are a file name and two optional dictionaries. The file is parsed and evaluated as a sequence of Python statements (similarly to a module) using the *globals* and *locals* dictionaries as global and local namespace. If - provided, *locals* can be any mapping object. Remember that at module level, - globals and locals are the same dictionary. If two separate objects are - passed as *globals* and *locals*, the code will be executed as if it were - embedded in a class definition. + provided, *locals* can be any mapping object. .. versionchanged:: 2.4 formerly *locals* was required to be a dictionary. @@ -458,7 +431,7 @@ used reliably to modify a function's locals. -.. function:: file(name[, mode[, buffering]]) +.. function:: file(filename[, mode[, bufsize]]) Constructor function for the :class:`file` type, described further in section :ref:`bltin-file-objects`. The constructor's arguments are the same as those @@ -533,17 +506,14 @@ .. versionadded:: 2.6 -.. _func-frozenset: .. function:: frozenset([iterable]) :noindex: - Return a new :class:`frozenset` object, optionally with elements taken from - *iterable*. ``frozenset`` is a built-in class. See :class:`frozenset` and - :ref:`types-set` for documentation about this class. + Return a frozenset object, optionally with elements taken from *iterable*. + The frozenset type is described in :ref:`types-set`. - For other containers see the built-in :class:`set`, :class:`list`, - :class:`tuple`, and :class:`dict` classes, as well as the :mod:`collections` - module. + For other containers see the built in :class:`dict`, :class:`list`, and + :class:`tuple` classes, and the :mod:`collections` module. .. versionadded:: 2.4 @@ -596,21 +566,8 @@ .. function:: hex(x) - Convert an integer number (of any size) to a lowercase hexadecimal string - prefixed with "0x", for example: - - >>> hex(255) - '0xff' - >>> hex(-42) - '-0x2a' - >>> hex(1L) - '0x1L' - - If x is not a Python :class:`int` or :class:`long` object, it has to - define an __index__() method that returns an integer. - - See also :func:`int` for converting a hexadecimal string to an - integer using a base of 16. + Convert an integer number (of any size) to a hexadecimal string. The result is a + valid Python expression. .. note:: @@ -635,9 +592,12 @@ Equivalent to ``eval(raw_input(prompt))``. - This function does not catch user errors. If the input is not syntactically - valid, a :exc:`SyntaxError` will be raised. Other exceptions may be raised if - there is an error during evaluation. + .. note:: + + This function does not catch user errors. It expects a valid Python + expression as input. If the input is not syntactically valid, a + :exc:`SyntaxError` will be raised. Other exceptions may be raised if there + is an error during evaluation. If the :mod:`readline` module was loaded, then :func:`input` will use it to provide elaborate line editing and history features. @@ -645,26 +605,20 @@ Consider using the :func:`raw_input` function for general input from users. -.. function:: int(x=0) - int(x, base=10) +.. function:: int([x[, base]]) - Convert a number or string *x* to an integer, or return ``0`` if no - arguments are given. If *x* is a number, it can be a plain integer, a long - integer, or a floating point number. If *x* is floating point, the conversion - truncates towards zero. If the argument is outside the integer range, the - function returns a long object instead. - - If *x* is not a number or if *base* is given, then *x* must be a string or - Unicode object representing an :ref:`integer literal ` in radix - *base*. Optionally, the literal can be - preceded by ``+`` or ``-`` (with no space in between) and surrounded by - whitespace. A base-n literal consists of the digits 0 to n-1, with ``a`` - to ``z`` (or ``A`` to ``Z``) having - values 10 to 35. The default *base* is 10. The allowed values are 0 and 2-36. - Base-2, -8, and -16 literals can be optionally prefixed with ``0b``/``0B``, - ``0o``/``0O``/``0``, or ``0x``/``0X``, as with integer literals in code. - Base 0 means to interpret the string exactly as an integer literal, so that - the actual base is 2, 8, 10, or 16. + Convert a string or number to a plain integer. If the argument is a string, + it must contain a possibly signed decimal number representable as a Python + integer, possibly embedded in whitespace. The *base* parameter gives the + base for the conversion (which is 10 by default) and may be any integer in + the range [2, 36], or zero. If *base* is zero, the proper radix is + determined based on the contents of string; the interpretation is the same as + for integer literals. (See :ref:`numbers`.) If *base* is specified and *x* + is not a string, :exc:`TypeError` is raised. Otherwise, the argument may be a + plain or long integer or a floating point number. Conversion of floating + point numbers to integers truncates (towards zero). If the argument is + outside the integer range a long object will be returned instead. If no + arguments are given, returns ``0``. The integer type is described in :ref:`typesnumeric`. @@ -714,7 +668,7 @@ One useful application of the second form of :func:`iter` is to read lines of a file until a certain line is reached. The following example reads a file - until the :meth:`~io.TextIOBase.readline` method returns an empty string:: + until the :meth:`readline` method returns an empty string:: with open('mydata.txt') as fp: for line in iter(fp.readline, ''): @@ -726,8 +680,7 @@ .. function:: len(s) Return the length (the number of items) of an object. The argument may be a - sequence (such as a string, bytes, tuple, list, or range) or a collection - (such as a dictionary, set, or frozen set). + sequence (string, tuple or list) or a mapping (dictionary). .. function:: list([iterable]) @@ -756,8 +709,7 @@ affect the values of local and free variables used by the interpreter. -.. function:: long(x=0) - long(x, base=10) +.. function:: long([x[, base]]) Convert a string or number to a long integer. If the argument is a string, it must contain a possibly signed number of arbitrary size, possibly embedded in @@ -783,16 +735,11 @@ the result is always a list. -.. function:: max(iterable[, key]) - max(arg1, arg2, *args[, key]) +.. function:: max(iterable[, args...][key]) - Return the largest item in an iterable or the largest of two or more - arguments. - - If one positional argument is provided, *iterable* must be a non-empty - iterable (such as a non-empty string, tuple or list). The largest item - in the iterable is returned. If two or more positional arguments are - provided, the largest of the positional arguments is returned. + With a single argument *iterable*, return the largest item of a non-empty + iterable (such as a string, tuple or list). With more than one argument, return + the largest of the arguments. The optional *key* argument specifies a one-argument ordering function like that used for :meth:`list.sort`. The *key* argument, if supplied, must be in keyword @@ -801,7 +748,7 @@ .. versionchanged:: 2.5 Added support for the optional *key* argument. -.. _func-memoryview: + .. function:: memoryview(obj) :noindex: @@ -809,16 +756,11 @@ :ref:`typememoryview` for more information. -.. function:: min(iterable[, key]) - min(arg1, arg2, *args[, key]) +.. function:: min(iterable[, args...][key]) - Return the smallest item in an iterable or the smallest of two or more - arguments. - - If one positional argument is provided, *iterable* must be a non-empty - iterable (such as a non-empty string, tuple or list). The smallest item - in the iterable is returned. If two or more positional arguments are - provided, the smallest of the positional arguments is returned. + With a single argument *iterable*, return the smallest item of a non-empty + iterable (such as a string, tuple or list). With more than one argument, return + the smallest of the arguments. The optional *key* argument specifies a one-argument ordering function like that used for :meth:`list.sort`. The *key* argument, if supplied, must be in keyword @@ -866,7 +808,7 @@ :exc:`IOError` is raised. When opening a file, it's preferable to use :func:`open` instead of invoking the :class:`file` constructor directly. - The first two arguments are the same as for ``stdio``'s :c:func:`fopen`: + The first two arguments are the same as for ``stdio``'s :cfunc:`fopen`: *name* is the file name to be opened, and *mode* is a string indicating how the file is to be opened. @@ -890,29 +832,26 @@ The optional *buffering* argument specifies the file's desired buffer size: 0 means unbuffered, 1 means line buffered, any other positive value means use a - buffer of (approximately) that size (in bytes). A negative *buffering* means - to use the system default, which is usually line buffered for tty devices and - fully buffered for other files. If omitted, the system default is used. [#]_ + buffer of (approximately) that size. A negative *buffering* means to use the + system default, which is usually line buffered for tty devices and fully + buffered for other files. If omitted, the system default is used. [#]_ - Modes ``'r+'``, ``'w+'`` and ``'a+'`` open the file for updating (reading and writing); - note that ``'w+'`` truncates the file. Append ``'b'`` to the mode to open the file in + Modes ``'r+'``, ``'w+'`` and ``'a+'`` open the file for updating (note that + ``'w+'`` truncates the file). Append ``'b'`` to the mode to open the file in binary mode, on systems that differentiate between binary and text files; on systems that don't have this distinction, adding the ``'b'`` has no effect. - .. index:: - single: universal newlines; open() built-in function - - In addition to the standard :c:func:`fopen` values *mode* may be ``'U'`` or - ``'rU'``. Python is usually built with :term:`universal newlines` support; - supplying ``'U'`` opens the file as a text file, but lines may be terminated - by any of the following: the Unix end-of-line convention ``'\n'``, the - Macintosh convention ``'\r'``, or the Windows convention ``'\r\n'``. All of - these external representations are seen as ``'\n'`` by the Python program. - If Python is built without universal newlines support a *mode* with ``'U'`` - is the same as normal text mode. Note that file objects so opened also have - an attribute called :attr:`newlines` which has a value of ``None`` (if no - newlines have yet been seen), ``'\n'``, ``'\r'``, ``'\r\n'``, or a tuple - containing all the newline types seen. + In addition to the standard :cfunc:`fopen` values *mode* may be ``'U'`` or + ``'rU'``. Python is usually built with universal newline support; supplying + ``'U'`` opens the file as a text file, but lines may be terminated by any of the + following: the Unix end-of-line convention ``'\n'``, the Macintosh convention + ``'\r'``, or the Windows convention ``'\r\n'``. All of these external + representations are seen as ``'\n'`` by the Python program. If Python is built + without universal newline support a *mode* with ``'U'`` is the same as normal + text mode. Note that file objects so opened also have an attribute called + :attr:`newlines` which has a value of ``None`` (if no newlines have yet been + seen), ``'\n'``, ``'\r'``, ``'\r\n'``, or a tuple containing all the newline + types seen. Python enforces that the mode, after stripping ``'U'``, begins with ``'r'``, ``'w'`` or ``'a'``. @@ -958,22 +897,20 @@ accidents.) -.. function:: print(*objects, sep=' ', end='\\n', file=sys.stdout) +.. function:: print([object, ...][, sep=' '][, end='\\n'][, file=sys.stdout]) - Print *objects* to the stream *file*, separated by *sep* and followed by + Print *object*\(s) to the stream *file*, separated by *sep* and followed by *end*. *sep*, *end* and *file*, if present, must be given as keyword arguments. All non-keyword arguments are converted to strings like :func:`str` does and written to the stream, separated by *sep* and followed by *end*. Both *sep* and *end* must be strings; they can also be ``None``, which means to use the - default values. If no *objects* are given, :func:`print` will just write + default values. If no *object* is given, :func:`print` will just write *end*. The *file* argument must be an object with a ``write(string)`` method; if it - is not present or ``None``, :data:`sys.stdout` will be used. Output buffering - is determined by *file*. Use ``file.flush()`` to ensure, for instance, - immediate appearance on a screen. + is not present or ``None``, :data:`sys.stdout` will be used. .. note:: @@ -1027,10 +964,10 @@ turns the :meth:`voltage` method into a "getter" for a read-only attribute with the same name. - A property object has :attr:`~property.getter`, :attr:`~property.setter`, - and :attr:`~property.deleter` methods usable as decorators that create a - copy of the property with the corresponding accessor function set to the - decorated function. This is best explained with an example:: + A property object has :attr:`getter`, :attr:`setter`, and :attr:`deleter` + methods usable as decorators that create a copy of the property with the + corresponding accessor function set to the decorated function. This is + best explained with an example:: class C(object): def __init__(self): @@ -1065,8 +1002,7 @@ The ``getter``, ``setter``, and ``deleter`` attributes were added. -.. function:: range(stop) - range(start, stop[, step]) +.. function:: range([start,] stop[, step]) This is a versatile function to create lists containing arithmetic progressions. It is most often used in :keyword:`for` loops. The arguments must be plain @@ -1120,19 +1056,7 @@ it is placed before the items of the iterable in the calculation, and serves as a default when the iterable is empty. If *initializer* is not given and *iterable* contains only one item, the first item is returned. - Roughly equivalent to:: - def reduce(function, iterable, initializer=None): - it = iter(iterable) - if initializer is None: - try: - initializer = next(it) - except StopIteration: - raise TypeError('reduce() of empty sequence with no initial value') - accum_value = initializer - for x in it: - accum_value = function(accum_value, x) - return accum_value .. function:: reload(module) @@ -1196,7 +1120,6 @@ continue to use the old class definition. The same is true for derived classes. -.. _func-repr: .. function:: repr(object) Return a string containing a printable representation of an object. This is @@ -1223,14 +1146,13 @@ Added the possibility to write a custom :meth:`__reversed__` method. -.. function:: round(number[, ndigits]) +.. function:: round(x[, n]) - Return the floating point value *number* rounded to *ndigits* digits after - the decimal point. If *ndigits* is omitted, it defaults to zero. The result - is a floating point number. Values are rounded to the closest multiple of - 10 to the power minus *ndigits*; if two multiples are equally close, - rounding is done away from 0 (so. for example, ``round(0.5)`` is ``1.0`` and - ``round(-0.5)`` is ``-1.0``). + Return the floating point value *x* rounded to *n* digits after the decimal + point. If *n* is omitted, it defaults to zero. The result is a floating point + number. Values are rounded to the closest multiple of 10 to the power minus + *n*; if two multiples are equally close, rounding is done away from 0 (so. for + example, ``round(0.5)`` is ``1.0`` and ``round(-0.5)`` is ``-1.0``). .. note:: @@ -1241,18 +1163,14 @@ can't be represented exactly as a float. See :ref:`tut-fp-issues` for more information. - -.. _func-set: .. function:: set([iterable]) :noindex: - Return a new :class:`set` object, optionally with elements taken from - *iterable*. ``set`` is a built-in class. See :class:`set` and - :ref:`types-set` for documentation about this class. + Return a new set, optionally with elements taken from *iterable*. + The set type is described in :ref:`types-set`. - For other containers see the built-in :class:`frozenset`, :class:`list`, - :class:`tuple`, and :class:`dict` classes, as well as the :mod:`collections` - module. + For other containers see the built in :class:`dict`, :class:`list`, and + :class:`tuple` classes, and the :mod:`collections` module. .. versionadded:: 2.4 @@ -1266,20 +1184,19 @@ ``x.foobar = 123``. -.. function:: slice(stop) - slice(start, stop[, step]) +.. function:: slice([start,] stop[, step]) .. index:: single: Numerical Python Return a :term:`slice` object representing the set of indices specified by ``range(start, stop, step)``. The *start* and *step* arguments default to - ``None``. Slice objects have read-only data attributes :attr:`~slice.start`, - :attr:`~slice.stop` and :attr:`~slice.step` which merely return the argument - values (or their default). They have no other explicit functionality; - however they are used by Numerical Python and other third party extensions. - Slice objects are also generated when extended indexing syntax is used. For - example: ``a[start:stop:step]`` or ``a[start:stop, i]``. See - :func:`itertools.islice` for an alternate version that returns an iterator. + ``None``. Slice objects have read-only data attributes :attr:`start`, + :attr:`stop` and :attr:`step` which merely return the argument values (or their + default). They have no other explicit functionality; however they are used by + Numerical Python and other third party extensions. Slice objects are also + generated when extended indexing syntax is used. For example: + ``a[start:stop:step]`` or ``a[start:stop, i]``. See :func:`itertools.islice` + for an alternate version that returns an iterator. .. function:: sorted(iterable[, cmp[, key[, reverse]]]) @@ -1322,10 +1239,9 @@ A static method does not receive an implicit first argument. To declare a static method, use this idiom:: - class C(object): + class C: @staticmethod - def f(arg1, arg2, ...): - ... + def f(arg1, arg2, ...): ... The ``@staticmethod`` form is a function :term:`decorator` -- see the description of function definitions in :ref:`function` for details. @@ -1346,7 +1262,7 @@ Function decorator syntax added. -.. function:: str(object='') +.. function:: str([object]) Return a string containing a nicely printable representation of an object. For strings, this returns the string itself. The difference with ``repr(object)`` @@ -1384,10 +1300,9 @@ been overridden in a class. The search order is same as that used by :func:`getattr` except that the *type* itself is skipped. - The :attr:`~class.__mro__` attribute of the *type* lists the method - resolution search order used by both :func:`getattr` and :func:`super`. The - attribute is dynamic and can change whenever the inheritance hierarchy is - updated. + The :attr:`__mro__` attribute of the *type* lists the method resolution + search order used by both :func:`getattr` and :func:`super`. The attribute + is dynamic and can change whenever the inheritance hierarchy is updated. If the second argument is omitted, the super object returned is unbound. If the second argument is an object, ``isinstance(obj, type)`` must be true. If @@ -1451,21 +1366,26 @@ .. function:: type(object) - type(name, bases, dict) .. index:: object: type - With one argument, return the type of an *object*. The return value is a - type object. The :func:`isinstance` built-in function is recommended for - testing the type of an object. + Return the type of an *object*. The return value is a type object. The + :func:`isinstance` built-in function is recommended for testing the type of an + object. - With three arguments, return a new type object. This is essentially a - dynamic form of the :keyword:`class` statement. The *name* string is the - class name and becomes the :attr:`~class.__name__` attribute; the *bases* tuple - itemizes the base classes and becomes the :attr:`~class.__bases__` attribute; - and the *dict* dictionary is the namespace containing definitions for class - body and becomes the :attr:`~object.__dict__` attribute. For example, the - following two statements create identical :class:`type` objects: + With three arguments, :func:`type` functions as a constructor as detailed below. + + +.. function:: type(name, bases, dict) + :noindex: + + Return a new type object. This is essentially a dynamic form of the + :keyword:`class` statement. The *name* string is the class name and becomes the + :attr:`__name__` attribute; the *bases* tuple itemizes the base classes and + becomes the :attr:`__bases__` attribute; and the *dict* dictionary is the + namespace containing definitions for class body and becomes the :attr:`__dict__` + attribute. For example, the following two statements create identical + :class:`type` objects: >>> class X(object): ... a = 1 @@ -1487,8 +1407,7 @@ .. versionadded:: 2.0 -.. function:: unicode(object='') - unicode(object[, encoding [, errors]]) +.. function:: unicode([object[, encoding [, errors]]]) Return the Unicode string version of *object* using one of the following modes: @@ -1528,32 +1447,27 @@ .. function:: vars([object]) - Return the :attr:`~object.__dict__` attribute for a module, class, instance, - or any other object with a :attr:`__dict__` attribute. + Without an argument, act like :func:`locals`. - Objects such as modules and instances have an updateable :attr:`__dict__` - attribute; however, other objects may have write restrictions on their - :attr:`__dict__` attributes (for example, new-style classes use a - dictproxy to prevent direct dictionary updates). + With a module, class or class instance object as argument (or anything else that + has a :attr:`__dict__` attribute), return that attribute. - Without an argument, :func:`vars` acts like :func:`locals`. Note, the - locals dictionary is only useful for reads since updates to the locals - dictionary are ignored. + .. note:: + The returned dictionary should not be modified: + the effects on the corresponding symbol table are undefined. [#]_ -.. function:: xrange(stop) - xrange(start, stop[, step]) - This function is very similar to :func:`range`, but returns an :ref:`xrange - object ` +.. function:: xrange([start,] stop[, step]) + + This function is very similar to :func:`range`, but returns an "xrange object" instead of a list. This is an opaque sequence type which yields the same values as the corresponding list, without actually storing them all simultaneously. The advantage of :func:`xrange` over :func:`range` is minimal (since :func:`xrange` still has to create the values when asked for them) except when a very large range is used on a memory-starved machine or when all of the range's elements are never used (such as when the loop is usually terminated with - :keyword:`break`). For more information on xrange objects, see - :ref:`typesseq-xrange` and :ref:`typesseq`. + :keyword:`break`). .. impl-detail:: @@ -1608,7 +1522,7 @@ .. note:: This is an advanced function that is not needed in everyday Python - programming, unlike :func:`importlib.import_module`. + programming. This function is invoked by the :keyword:`import` statement. It can be replaced (by importing the :mod:`__builtin__` module and assigning to @@ -1659,8 +1573,15 @@ names. If you simply want to import a module (potentially within a package) by name, - use :func:`importlib.import_module`. + you can call :func:`__import__` and then look it up in :data:`sys.modules`:: + >>> import sys + >>> name = 'foo.bar.baz' + >>> __import__(name) + + >>> baz = sys.modules[name] + >>> baz + .. versionchanged:: 2.5 The level parameter was added. @@ -1697,8 +1618,7 @@ ``function(*args, **keywords)``. .. deprecated:: 2.3 - Use ``function(*args, **keywords)`` instead of - ``apply(function, args, keywords)`` (see :ref:`tut-unpacking-arguments`). + Use the extended call syntax with ``*args`` and ``**keywords`` instead. .. function:: buffer(object[, offset[, size]]) @@ -1738,8 +1658,8 @@ .. [#] It is used relatively rarely so does not warrant being made into a statement. .. [#] Specifying a buffer size currently has no effect on systems that don't have - :c:func:`setvbuf`. The interface to specify the buffer size is not done using a - method that calls :c:func:`setvbuf`, because that may dump core when called after + :cfunc:`setvbuf`. The interface to specify the buffer size is not done using a + method that calls :cfunc:`setvbuf`, because that may dump core when called after any I/O has been performed, and there's no reliable way to determine whether this is the case. diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/library/functools.rst --- a/Doc/library/functools.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/library/functools.rst Sun Jul 20 10:52:46 2014 -0400 @@ -1,8 +1,8 @@ -:mod:`functools` --- Higher-order functions and operations on callable objects +:mod:`functools` --- Higher order functions and operations on callable objects ============================================================================== .. module:: functools - :synopsis: Higher-order functions and operations on callable objects. + :synopsis: Higher order functions and operations on callable objects. .. moduleauthor:: Peter Harris .. moduleauthor:: Raymond Hettinger .. moduleauthor:: Nick Coghlan @@ -22,14 +22,14 @@ .. function:: cmp_to_key(func) - Transform an old-style comparison function to a key function. Used with + Transform an old-style comparison function to a key-function. Used with tools that accept key functions (such as :func:`sorted`, :func:`min`, :func:`max`, :func:`heapq.nlargest`, :func:`heapq.nsmallest`, :func:`itertools.groupby`). This function is primarily used as a transition - tool for programs being converted to Python 3 where comparison functions are - no longer supported. + tool for programs being converted to Py3.x where comparison functions are no + longer supported. - A comparison function is any callable that accept two arguments, compares them, + A compare function is any callable that accept two arguments, compares them, and returns a negative number for less-than, zero for equality, or a positive number for greater-than. A key function is a callable that accepts one argument and returns another value that indicates the position in the desired diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/library/future_builtins.rst --- a/Doc/library/future_builtins.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/library/future_builtins.rst Sun Jul 20 10:52:46 2014 -0400 @@ -50,11 +50,6 @@ Works like :func:`itertools.imap`. - .. note:: - - In Python 3, :func:`map` does not accept ``None`` for the - function argument. - .. function:: oct(object) Works like the built-in :func:`oct`, but instead of :meth:`__oct__` it will diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/library/gc.rst --- a/Doc/library/gc.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/library/gc.rst Sun Jul 20 10:52:46 2014 -0400 @@ -132,8 +132,8 @@ Return a list of objects directly referred to by any of the arguments. The referents returned are those objects visited by the arguments' C-level - :c:member:`~PyTypeObject.tp_traverse` methods (if any), and may not be all objects actually - directly reachable. :c:member:`~PyTypeObject.tp_traverse` methods are supported only by objects + :attr:`tp_traverse` methods (if any), and may not be all objects actually + directly reachable. :attr:`tp_traverse` methods are supported only by objects that support garbage collection, and are only required to visit objects that may be involved in a cycle. So, for example, if an integer is directly reachable from an argument, that integer object may or may not appear in the result list. @@ -142,8 +142,8 @@ .. function:: is_tracked(obj) - Returns ``True`` if the object is currently tracked by the garbage collector, - ``False`` otherwise. As a general rule, instances of atomic types aren't + Returns True if the object is currently tracked by the garbage collector, + False otherwise. As a general rule, instances of atomic types aren't tracked and instances of non-atomic types (containers, user-defined objects...) are. However, some type-specific optimizations can be present in order to suppress the garbage collector footprint of simple instances diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/library/gdbm.rst --- a/Doc/library/gdbm.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/library/gdbm.rst Sun Jul 20 10:52:46 2014 -0400 @@ -6,9 +6,9 @@ :synopsis: GNU's reinterpretation of dbm. .. note:: - The :mod:`gdbm` module has been renamed to :mod:`dbm.gnu` in Python 3. The + The :mod:`gdbm` module has been renamed to :mod:`dbm.gnu` in Python 3.0. The :term:`2to3` tool will automatically adapt imports when converting your - sources to Python 3. + sources to 3.0. .. index:: module: dbm @@ -116,11 +116,6 @@ unwritten data to be written to the disk. -.. function:: close() - - Close the ``gdbm`` database. - - .. seealso:: Module :mod:`anydbm` diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/library/getopt.rst --- a/Doc/library/getopt.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/library/getopt.rst Sun Jul 20 10:52:46 2014 -0400 @@ -10,15 +10,14 @@ -------------- .. note:: - The :mod:`getopt` module is a parser for command line options whose API is - designed to be familiar to users of the C :c:func:`getopt` function. Users who - are unfamiliar with the C :c:func:`getopt` function or who would like to write + designed to be familiar to users of the C :cfunc:`getopt` function. Users who + are unfamiliar with the C :cfunc:`getopt` function or who would like to write less code and get better help and error messages should consider using the :mod:`argparse` module instead. This module helps scripts to parse the command line arguments in ``sys.argv``. -It supports the same conventions as the Unix :c:func:`getopt` function (including +It supports the same conventions as the Unix :cfunc:`getopt` function (including the special meanings of arguments of the form '``-``' and '``--``'). Long options similar to those supported by GNU software may be used as well via an optional third argument. @@ -33,11 +32,11 @@ be parsed, without the leading reference to the running program. Typically, this means ``sys.argv[1:]``. *options* is the string of option letters that the script wants to recognize, with options that require an argument followed by a - colon (``':'``; i.e., the same format that Unix :c:func:`getopt` uses). + colon (``':'``; i.e., the same format that Unix :cfunc:`getopt` uses). .. note:: - Unlike GNU :c:func:`getopt`, after a non-option argument, all further + Unlike GNU :cfunc:`getopt`, after a non-option argument, all further arguments are considered also non-options. This is similar to the way non-GNU Unix systems work. @@ -127,7 +126,7 @@ def main(): try: opts, args = getopt.getopt(sys.argv[1:], "ho:v", ["help", "output="]) - except getopt.GetoptError as err: + except getopt.GetoptError, err: # print help information and exit: print str(err) # will print something like "option -a not recognized" usage() diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/library/gl.rst --- a/Doc/library/gl.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/library/gl.rst Sun Jul 20 10:52:46 2014 -0400 @@ -8,7 +8,7 @@ .. deprecated:: 2.6 - The :mod:`gl` module has been removed in Python 3. + The :mod:`gl` module has been deprecated for removal in Python 3.0. This module provides access to the Silicon Graphics *Graphics Library*. It is @@ -168,7 +168,7 @@ .. deprecated:: 2.6 - The :mod:`DEVICE` module has been removed in Python 3. + The :mod:`DEVICE` module has been deprecated for removal in Python 3.0. This modules defines the constants used by the Silicon Graphics *Graphics @@ -186,7 +186,7 @@ .. deprecated:: 2.6 - The :mod:`GL` module has been removed in Python 3. + The :mod:`GL` module has been deprecated for removal in Python 3.0. This module contains constants used by the Silicon Graphics *Graphics Library* from the C header file ````. Read the module source file for details. diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/library/glob.rst --- a/Doc/library/glob.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/library/glob.rst Sun Jul 20 10:52:46 2014 -0400 @@ -16,13 +16,8 @@ ``*``, ``?``, and character ranges expressed with ``[]`` will be correctly matched. This is done by using the :func:`os.listdir` and :func:`fnmatch.fnmatch` functions in concert, and not by actually invoking a -subshell. Note that unlike :func:`fnmatch.fnmatch`, :mod:`glob` treats -filenames beginning with a dot (``.``) as special cases. (For tilde and shell -variable expansion, use :func:`os.path.expanduser` and -:func:`os.path.expandvars`.) - -For a literal match, wrap the meta-characters in brackets. -For example, ``'[?]'`` matches the character ``'?'``. +subshell. (For tilde and shell variable expansion, use +:func:`os.path.expanduser` and :func:`os.path.expandvars`.) .. function:: glob(pathname) @@ -54,15 +49,6 @@ >>> glob.glob('?.gif') ['1.gif'] -If the directory contains files starting with ``.`` they won't be matched by -default. For example, consider a directory containing :file:`card.gif` and -:file:`.card.gif`:: - - >>> import glob - >>> glob.glob('*.gif') - ['card.gif'] - >>> glob.glob('.c*') - ['.card.gif'] .. seealso:: diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/library/gzip.rst --- a/Doc/library/gzip.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/library/gzip.rst Sun Jul 20 10:52:46 2014 -0400 @@ -22,6 +22,9 @@ :program:`gzip` and :program:`gunzip` programs, such as those produced by :program:`compress` and :program:`pack`, are not supported by this module. +For other archive formats, see the :mod:`bz2`, :mod:`zipfile`, and +:mod:`tarfile` modules. + The module defines the following items: @@ -33,12 +36,12 @@ given a non-trivial value. The new class instance is based on *fileobj*, which can be a regular file, a - :class:`~StringIO.StringIO` object, or any other object which simulates a file. It + :class:`StringIO` object, or any other object which simulates a file. It defaults to ``None``, in which case *filename* is opened to provide a file object. When *fileobj* is not ``None``, the *filename* argument is only used to be - included in the :program:`gzip` file header, which may include the original + included in the :program:`gzip` file header, which may includes the original filename of the uncompressed file. It defaults to the filename of *fileobj*, if discernible; otherwise, it defaults to the empty string, and in this case the original filename is not included in the header. @@ -49,10 +52,9 @@ not given, the 'b' flag will be added to the mode to ensure the file is opened in binary mode for cross-platform portability. - The *compresslevel* argument is an integer from ``0`` to ``9`` controlling - the level of compression; ``1`` is fastest and produces the least - compression, and ``9`` is slowest and produces the most compression. ``0`` - is no compression. The default is ``9``. + The *compresslevel* argument is an integer from ``1`` to ``9`` controlling the + level of compression; ``1`` is fastest and produces the least compression, and + ``9`` is slowest and produces the most compression. The default is ``9``. The *mtime* argument is an optional numeric timestamp to be written to the stream when compressing. All :program:`gzip` compressed streams are @@ -65,9 +67,9 @@ Calling a :class:`GzipFile` object's :meth:`close` method does not close *fileobj*, since you might wish to append more material after the compressed - data. This also allows you to pass a :class:`~StringIO.StringIO` object opened for + data. This also allows you to pass a :class:`StringIO` object opened for writing as *fileobj*, and retrieve the resulting memory buffer using the - :class:`StringIO` object's :meth:`~StringIO.StringIO.getvalue` method. + :class:`StringIO` object's :meth:`getvalue` method. :class:`GzipFile` supports iteration and the :keyword:`with` statement. @@ -77,9 +79,6 @@ .. versionchanged:: 2.7 Support for zero-padded files was added. - .. versionadded:: 2.7 - The *mtime* argument. - .. function:: open(filename[, mode[, compresslevel]]) @@ -96,7 +95,7 @@ Example of how to read a compressed file:: import gzip - f = gzip.open('file.txt.gz', 'rb') + f = gzip.open('/home/joe/file.txt.gz', 'rb') file_content = f.read() f.close() @@ -104,15 +103,15 @@ import gzip content = "Lots of content here" - f = gzip.open('file.txt.gz', 'wb') + f = gzip.open('/home/joe/file.txt.gz', 'wb') f.write(content) f.close() Example of how to GZIP compress an existing file:: import gzip - f_in = open('file.txt', 'rb') - f_out = gzip.open('file.txt.gz', 'wb') + f_in = open('/home/joe/file.txt', 'rb') + f_out = gzip.open('/home/joe/file.txt.gz', 'wb') f_out.writelines(f_in) f_out.close() f_in.close() diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/library/hashlib.rst --- a/Doc/library/hashlib.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/library/hashlib.rst Sun Jul 20 10:52:46 2014 -0400 @@ -25,14 +25,12 @@ modern term is secure hash. .. note:: - - If you want the adler32 or crc32 hash functions, they are available in + If you want the adler32 or crc32 hash functions they are available in the :mod:`zlib` module. .. warning:: - Some algorithms have known hash collision weaknesses, refer to the "See - also" section at the end. + Some algorithms have known hash collision weaknesses, see the FAQ at the end. There is one constructor method named for each type of :dfn:`hash`. All return a hash object with the same simple interface. For example: use :func:`sha1` to @@ -110,6 +108,7 @@ m.update(b)`` is equivalent to ``m.update(a+b)``. .. versionchanged:: 2.7 + The Python GIL is released to allow other threads to run while hash updates on data larger than 2048 bytes is taking place when using hash algorithms supplied by OpenSSL. @@ -135,46 +134,6 @@ compute the digests of strings that share a common initial substring. -Key Derivation Function ------------------------ - -Key derivation and key stretching algorithms are designed for secure password -hashing. Naive algorithms such as ``sha1(password)`` are not resistant against -brute-force attacks. A good password hashing function must be tunable, slow, and -include a `salt `_. - - -.. function:: pbkdf2_hmac(name, password, salt, rounds, dklen=None) - - The function provides PKCS#5 password-based key derivation function 2. It - uses HMAC as pseudorandom function. - - The string *name* is the desired name of the hash digest algorithm for - HMAC, e.g. 'sha1' or 'sha256'. *password* and *salt* are interpreted as - buffers of bytes. Applications and libraries should limit *password* to - a sensible value (e.g. 1024). *salt* should be about 16 or more bytes from - a proper source, e.g. :func:`os.urandom`. - - The number of *rounds* should be chosen based on the hash algorithm and - computing power. As of 2013, at least 100,000 rounds of SHA-256 is suggested. - - *dklen* is the length of the derived key. If *dklen* is ``None`` then the - digest size of the hash algorithm *name* is used, e.g. 64 for SHA-512. - - >>> import hashlib, binascii - >>> dk = hashlib.pbkdf2_hmac('sha256', b'password', b'salt', 100000) - >>> binascii.hexlify(dk) - b'0394a2ede332c9a13eb82e9b24631604c31df978b4e2f0fbd2c549944f9d79a5' - - .. versionadded:: 2.7.8 - - .. note:: - - A fast implementation of *pbkdf2_hmac* is available with OpenSSL. The - Python implementation uses an inline version of :mod:`hmac`. It is about - three times slower and doesn't release the GIL. - - .. seealso:: Module :mod:`hmac` diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/library/heapq.rst --- a/Doc/library/heapq.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/library/heapq.rst Sun Jul 20 10:52:46 2014 -0400 @@ -260,7 +260,7 @@ the sort is going on, provided that the inserted items are not "better" than the last 0'th element you extracted. This is especially useful in simulation contexts, where the tree holds all incoming events, and the "win" condition -means the smallest scheduled time. When an event schedules other events for +means the smallest scheduled time. When an event schedule other events for execution, they are scheduled into the future, so they can easily go into the heap. So, a heap is a good structure for implementing schedulers (this is what I used for my MIDI sequencer :-). diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/library/hmac.rst --- a/Doc/library/hmac.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/library/hmac.rst Sun Jul 20 10:52:46 2014 -0400 @@ -20,71 +20,39 @@ Return a new hmac object. If *msg* is present, the method call ``update(msg)`` is made. *digestmod* is the digest constructor or module for the HMAC object to - use. It defaults to the :data:`hashlib.md5` constructor. + use. It defaults to the :func:`hashlib.md5` constructor. An HMAC object has the following methods: -.. method:: HMAC.update(msg) + +.. method:: hmac.update(msg) Update the hmac object with the string *msg*. Repeated calls are equivalent to a single call with the concatenation of all the arguments: ``m.update(a); m.update(b)`` is equivalent to ``m.update(a + b)``. -.. method:: HMAC.digest() +.. method:: hmac.digest() Return the digest of the strings passed to the :meth:`update` method so far. This string will be the same length as the *digest_size* of the digest given to the constructor. It may contain non-ASCII characters, including NUL bytes. - .. warning:: - When comparing the output of :meth:`digest` to an externally-supplied - digest during a verification routine, it is recommended to use the - :func:`compare_digest` function instead of the ``==`` operator - to reduce the vulnerability to timing attacks. - - -.. method:: HMAC.hexdigest() +.. method:: hmac.hexdigest() Like :meth:`digest` except the digest is returned as a string twice the length containing only hexadecimal digits. This may be used to exchange the value safely in email or other non-binary environments. - .. warning:: - When comparing the output of :meth:`hexdigest` to an externally-supplied - digest during a verification routine, it is recommended to use the - :func:`compare_digest` function instead of the ``==`` operator - to reduce the vulnerability to timing attacks. - - -.. method:: HMAC.copy() +.. method:: hmac.copy() Return a copy ("clone") of the hmac object. This can be used to efficiently compute the digests of strings that share a common initial substring. -This module also provides the following helper function: - -.. function:: compare_digest(a, b) - - Return ``a == b``. This function uses an approach designed to prevent - timing analysis by avoiding content-based short circuiting behaviour, - making it appropriate for cryptography. *a* and *b* must both be of the - same type: either :class:`unicode` or a :term:`bytes-like object`. - - .. note:: - - If *a* and *b* are of different lengths, or if an error occurs, - a timing attack could theoretically reveal information about the - types and lengths of *a* and *b*--but not their values. - - - .. versionadded:: 2.7.7 - - .. seealso:: Module :mod:`hashlib` diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/library/htmllib.rst --- a/Doc/library/htmllib.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/library/htmllib.rst Sun Jul 20 10:52:46 2014 -0400 @@ -6,7 +6,7 @@ :deprecated: .. deprecated:: 2.6 - The :mod:`htmllib` module has been removed in Python 3. + The :mod:`htmllib` module has been removed in Python 3.0. .. index:: @@ -162,8 +162,8 @@ .. note:: The :mod:`htmlentitydefs` module has been renamed to :mod:`html.entities` in - Python 3. The :term:`2to3` tool will automatically adapt imports when - converting your sources to Python 3. + Python 3.0. The :term:`2to3` tool will automatically adapt imports when + converting your sources to 3.0. **Source code:** :source:`Lib/htmlentitydefs.py` diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/library/htmlparser.rst --- a/Doc/library/htmlparser.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/library/htmlparser.rst Sun Jul 20 10:52:46 2014 -0400 @@ -22,7 +22,7 @@ -------------- -This module defines a class :class:`.HTMLParser` which serves as the basis for +This module defines a class :class:`HTMLParser` which serves as the basis for parsing text files formatted in HTML (HyperText Mark-up Language) and XHTML. Unlike the parser in :mod:`htmllib`, this parser is not based on the SGML parser in :mod:`sgmllib`. @@ -30,12 +30,11 @@ .. class:: HTMLParser() - An :class:`.HTMLParser` instance is fed HTML data and calls handler methods - when start tags, end tags, text, comments, and other markup elements are - encountered. The user should subclass :class:`.HTMLParser` and override its - methods to implement the desired behavior. + The :class:`HTMLParser` class is instantiated without arguments. - The :class:`.HTMLParser` class is instantiated without arguments. + An :class:`HTMLParser` instance is fed HTML data and calls handler functions when tags + begin and end. The :class:`HTMLParser` class is meant to be overridden by the + user to provide a desired behavior. Unlike the parser in :mod:`htmllib`, this parser does not check that end tags match start tags or call the end-tag handler for elements which are closed @@ -43,67 +42,29 @@ An exception is defined as well: + .. exception:: HTMLParseError - :class:`.HTMLParser` is able to handle broken markup, but in some cases it - might raise this exception when it encounters an error while parsing. - This exception provides three attributes: :attr:`msg` is a brief - message explaining the error, :attr:`lineno` is the number of the line on - which the broken construct was detected, and :attr:`offset` is the number of + Exception raised by the :class:`HTMLParser` class when it encounters an error + while parsing. This exception provides three attributes: :attr:`msg` is a brief + message explaining the error, :attr:`lineno` is the number of the line on which + the broken construct was detected, and :attr:`offset` is the number of characters into the line at which the construct starts. +:class:`HTMLParser` instances have the following methods: -Example HTML Parser Application -------------------------------- -As a basic example, below is a simple HTML parser that uses the -:class:`.HTMLParser` class to print out start tags, end tags and data -as they are encountered:: +.. method:: HTMLParser.reset() - from HTMLParser import HTMLParser - - # create a subclass and override the handler methods - class MyHTMLParser(HTMLParser): - def handle_starttag(self, tag, attrs): - print "Encountered a start tag:", tag - def handle_endtag(self, tag): - print "Encountered an end tag :", tag - def handle_data(self, data): - print "Encountered some data :", data - - # instantiate the parser and fed it some HTML - parser = MyHTMLParser() - parser.feed('Test' - '

Parse me!

') - -The output will then be:: - - Encountered a start tag: html - Encountered a start tag: head - Encountered a start tag: title - Encountered some data : Test - Encountered an end tag : title - Encountered an end tag : head - Encountered a start tag: body - Encountered a start tag: h1 - Encountered some data : Parse me! - Encountered an end tag : h1 - Encountered an end tag : body - Encountered an end tag : html - - -:class:`.HTMLParser` Methods ----------------------------- - -:class:`.HTMLParser` instances have the following methods: + Reset the instance. Loses all unprocessed data. This is called implicitly at + instantiation time. .. method:: HTMLParser.feed(data) Feed some text to the parser. It is processed insofar as it consists of complete elements; incomplete data is buffered until more data is fed or - :meth:`close` is called. *data* can be either :class:`unicode` or - :class:`str`, but passing :class:`unicode` is advised. + :meth:`close` is called. .. method:: HTMLParser.close() @@ -111,13 +72,7 @@ Force processing of all buffered data as if it were followed by an end-of-file mark. This method may be redefined by a derived class to define additional processing at the end of the input, but the redefined version should always call - the :class:`.HTMLParser` base class method :meth:`close`. - - -.. method:: HTMLParser.reset() - - Reset the instance. Loses all unprocessed data. This is called implicitly at - instantiation time. + the :class:`HTMLParser` base class method :meth:`close`. .. method:: HTMLParser.getpos() @@ -133,34 +88,22 @@ attributes can be preserved, etc.). -The following methods are called when data or markup elements are encountered -and they are meant to be overridden in a subclass. The base class -implementations do nothing (except for :meth:`~HTMLParser.handle_startendtag`): - - .. method:: HTMLParser.handle_starttag(tag, attrs) - This method is called to handle the start of a tag (e.g. ``
``). + This method is called to handle the start of a tag. It is intended to be + overridden by a derived class; the base class implementation does nothing. The *tag* argument is the name of the tag converted to lower case. The *attrs* argument is a list of ``(name, value)`` pairs containing the attributes found inside the tag's ``<>`` brackets. The *name* will be translated to lower case, and quotes in the *value* have been removed, and character and entity references - have been replaced. - - For instance, for the tag ````, this method - would be called as ``handle_starttag('a', [('href', 'http://www.cwi.nl/')])``. + have been replaced. For instance, for the tag ````, this method would be called as + ``handle_starttag('a', [('href', 'http://www.cwi.nl/')])``. .. versionchanged:: 2.6 - All entity references from :mod:`htmlentitydefs` are now replaced in the - attribute values. - - -.. method:: HTMLParser.handle_endtag(tag) - - This method is called to handle the end tag of an element (e.g. ``
``). - - The *tag* argument is the name of the tag converted to lower case. + All entity references from :mod:`htmlentitydefs` are now replaced in the attribute + values. .. method:: HTMLParser.handle_startendtag(tag, attrs) @@ -171,175 +114,94 @@ implementation simply calls :meth:`handle_starttag` and :meth:`handle_endtag`. +.. method:: HTMLParser.handle_endtag(tag) + + This method is called to handle the end tag of an element. It is intended to be + overridden by a derived class; the base class implementation does nothing. The + *tag* argument is the name of the tag converted to lower case. + + .. method:: HTMLParser.handle_data(data) - This method is called to process arbitrary data (e.g. text nodes and the - content of ```` and ````). + This method is called to process arbitrary data (e.g. the content of + ```` and ````). It is intended to be + overridden by a derived class; the base class implementation does nothing. + + +.. method:: HTMLParser.handle_charref(name) + + This method is called to process a character reference of the form ``&#ref;``. + It is intended to be overridden by a derived class; the base class + implementation does nothing. .. method:: HTMLParser.handle_entityref(name) - This method is called to process a named character reference of the form - ``&name;`` (e.g. ``>``), where *name* is a general entity reference - (e.g. ``'gt'``). - - -.. method:: HTMLParser.handle_charref(name) - - This method is called to process decimal and hexadecimal numeric character - references of the form ``&#NNN;`` and ``&#xNNN;``. For example, the decimal - equivalent for ``>`` is ``>``, whereas the hexadecimal is ``>``; - in this case the method will receive ``'62'`` or ``'x3E'``. + This method is called to process a general entity reference of the form + ``&name;`` where *name* is an general entity reference. It is intended to be + overridden by a derived class; the base class implementation does nothing. .. method:: HTMLParser.handle_comment(data) - This method is called when a comment is encountered (e.g. ````). - - For example, the comment ```` will cause this method to be - called with the argument ``' comment '``. - - The content of Internet Explorer conditional comments (condcoms) will also be - sent to this method, so, for ````, - this method will receive ``'[if IE 9]>IE-specific content`` will cause + this method to be called with the argument ``'text'``. It is intended to be + overridden by a derived class; the base class implementation does nothing. .. method:: HTMLParser.handle_decl(decl) - This method is called to handle an HTML doctype declaration (e.g. - ````). + Method called when an SGML ``doctype`` declaration is read by the parser. + The *decl* parameter will be the entire contents of the declaration inside + the ```` markup. It is intended to be overridden by a derived class; + the base class implementation does nothing. - The *decl* parameter will be the entire contents of the declaration inside - the ```` markup (e.g. ``'DOCTYPE html'``). + +.. method:: HTMLParser.unknown_decl(data) + + Method called when an unrecognized SGML declaration is read by the parser. + The *data* parameter will be the entire contents of the declaration inside + the ```` markup. It is sometimes useful to be overridden by a + derived class; the base class implementation throws an :exc:`HTMLParseError`. .. method:: HTMLParser.handle_pi(data) - This method is called when a processing instruction is encountered. The *data* - parameter will contain the entire processing instruction. For example, for the + Method called when a processing instruction is encountered. The *data* + parameter will contain the entire processing instruction. For example, for the processing instruction ````, this method would be called as - ``handle_pi("proc color='red'")``. + ``handle_pi("proc color='red'")``. It is intended to be overridden by a derived + class; the base class implementation does nothing. .. note:: - The :class:`.HTMLParser` class uses the SGML syntactic rules for processing + The :class:`HTMLParser` class uses the SGML syntactic rules for processing instructions. An XHTML processing instruction using the trailing ``'?'`` will cause the ``'?'`` to be included in *data*. -.. method:: HTMLParser.unknown_decl(data) +.. _htmlparser-example: - This method is called when an unrecognized declaration is read by the parser. +Example HTML Parser Application +------------------------------- - The *data* parameter will be the entire contents of the declaration inside - the ```` markup. It is sometimes useful to be overridden by a - derived class. - - -.. _htmlparser-examples: - -Examples --------- - -The following class implements a parser that will be used to illustrate more -examples:: +As a basic example, below is a simple HTML parser that uses the +:class:`HTMLParser` class to print out start tags, end tags and data +as they are encountered:: from HTMLParser import HTMLParser - from htmlentitydefs import name2codepoint class MyHTMLParser(HTMLParser): def handle_starttag(self, tag, attrs): - print "Start tag:", tag - for attr in attrs: - print " attr:", attr + print "Encountered a start tag:", tag def handle_endtag(self, tag): - print "End tag :", tag + print "Encountered an end tag:", tag def handle_data(self, data): - print "Data :", data - def handle_comment(self, data): - print "Comment :", data - def handle_entityref(self, name): - c = unichr(name2codepoint[name]) - print "Named ent:", c - def handle_charref(self, name): - if name.startswith('x'): - c = unichr(int(name[1:], 16)) - else: - c = unichr(int(name)) - print "Num ent :", c - def handle_decl(self, data): - print "Decl :", data + print "Encountered some data:", data + parser = MyHTMLParser() - -Parsing a doctype:: - - >>> parser.feed('') - Decl : DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd" - -Parsing an element with a few attributes and a title:: - - >>> parser.feed('The Python logo') - Start tag: img - attr: ('src', 'python-logo.png') - attr: ('alt', 'The Python logo') - >>> - >>> parser.feed('

Python

') - Start tag: h1 - Data : Python - End tag : h1 - -The content of ``script`` and ``style`` elements is returned as is, without -further parsing:: - - >>> parser.feed('') - Start tag: style - attr: ('type', 'text/css') - Data : #python { color: green } - End tag : style - >>> - >>> parser.feed('') - Start tag: script - attr: ('type', 'text/javascript') - Data : alert("hello!"); - End tag : script - -Parsing comments:: - - >>> parser.feed('' - ... '') - Comment : a comment - Comment : [if IE 9]>IE-specific content'``):: - - >>> parser.feed('>>>') - Named ent: > - Num ent : > - Num ent : > - -Feeding incomplete chunks to :meth:`~HTMLParser.feed` works, but -:meth:`~HTMLParser.handle_data` might be called more than once:: - - >>> for chunk in ['buff', 'ered ', 'text']: - ... parser.feed(chunk) - ... - Start tag: span - Data : buff - Data : ered - Data : text - End tag : span - -Parsing invalid HTML (e.g. unquoted attributes) also works:: - - >>> parser.feed('

tag soup

') - Start tag: p - Start tag: a - attr: ('class', 'link') - attr: ('href', '#main') - Data : tag soup - End tag : p - End tag : a + parser.feed('Test' + '

Parse me!

') diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/library/httplib.rst --- a/Doc/library/httplib.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/library/httplib.rst Sun Jul 20 10:52:46 2014 -0400 @@ -6,8 +6,8 @@ .. note:: The :mod:`httplib` module has been renamed to :mod:`http.client` in Python - 3. The :term:`2to3` tool will automatically adapt imports when converting - your sources to Python 3. + 3.0. The :term:`2to3` tool will automatically adapt imports when converting + your sources to 3.0. .. index:: @@ -89,7 +89,7 @@ *source_address* was added. -.. class:: HTTPResponse(sock, debuglevel=0, strict=0) +.. class:: HTTPResponse(sock[, debuglevel=0][, strict=0]) Class whose instances are returned upon successful connection. Not instantiated directly by user. @@ -452,7 +452,7 @@ Set the host and the port for HTTP Connect Tunnelling. Normally used when it is required to do HTTPS Conection through a proxy server. - The headers argument should be a mapping of extra HTTP headers to send + The headers argument should be a mapping of extra HTTP headers to sent with the CONNECT request. .. versionadded:: 2.7 @@ -612,20 +612,3 @@ 'Redirecting to http://bugs.python.org/issue12524' >>> conn.close() -Client side ``HTTP PUT`` requests are very similar to ``POST`` requests. The -difference lies only the server side where HTTP server will allow resources to -be created via ``PUT`` request. Here is an example session that shows how to do -``PUT`` request using httplib:: - - >>> # This creates an HTTP message - >>> # with the content of BODY as the enclosed representation - >>> # for the resource http://localhost:8080/foobar - ... - >>> import httplib - >>> BODY = "***filecontents***" - >>> conn = httplib.HTTPConnection("localhost", 8080) - >>> conn.request("PUT", "/file", BODY) - >>> response = conn.getresponse() - >>> print response.status, response.reason - 200, OK - diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/library/idle.rst --- a/Doc/library/idle.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/library/idle.rst Sun Jul 20 10:52:46 2014 -0400 @@ -33,8 +33,8 @@ File menu ^^^^^^^^^ -New file - create a new file editing window +New window + create a new editing window Open... open an existing file @@ -154,77 +154,27 @@ it to the foreground (deiconifying it if necessary). -Debug menu -^^^^^^^^^^ - -* in the Python Shell window only +Debug menu (in the Python Shell window only) +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Go to file/line - Look around the insert point for a filename and line number, open the file, - and show the line. Useful to view the source lines referenced in an - exception traceback. + look around the insert point for a filename and linenumber, open the file, and + show the line. -Debugger - Run commands in the shell under the debugger. +Open stack viewer + show the stack traceback of the last exception -Stack viewer - Show the stack traceback of the last exception. +Debugger toggle + Run commands in the shell under the debugger -Auto-open Stack Viewer - Open stack viewer on traceback. +JIT Stack viewer toggle + Open stack viewer on traceback .. index:: single: stack viewer single: debugger -Edit context menu -^^^^^^^^^^^^^^^^^ - -* Right-click in Edit window (Control-click on OS X) - -Cut - Copy selection into system-wide clipboard; then delete selection - -Copy - Copy selection into system-wide clipboard - -Paste - Insert system-wide clipboard into window - -Set Breakpoint - Sets a breakpoint. Breakpoints are only enabled when the debugger is open. - -Clear Breakpoint - Clears the breakpoint on that line. - -.. index:: - single: Cut - single: Copy - single: Paste - single: Set Breakpoint - single: Clear Breakpoint - single: breakpoints - - -Shell context menu -^^^^^^^^^^^^^^^^^^ - -* Right-click in Python Shell window (Control-click on OS X) - -Cut - Copy selection into system-wide clipboard; then delete selection - -Copy - Copy selection into system-wide clipboard - -Paste - Insert system-wide clipboard into window - -Go to file/line - Same as in Debug menu. - - Basic editing and navigation ---------------------------- diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/library/imageop.rst --- a/Doc/library/imageop.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/library/imageop.rst Sun Jul 20 10:52:46 2014 -0400 @@ -7,7 +7,7 @@ :deprecated: .. deprecated:: 2.6 - The :mod:`imageop` module has been removed in Python 3. + The :mod:`imageop` module has been removed in Python 3.0. The :mod:`imageop` module contains some useful operations on images. It operates on images consisting of 8 or 32 bit pixels stored in Python strings. This is diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/library/imaplib.rst --- a/Doc/library/imaplib.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/library/imaplib.rst Sun Jul 20 10:52:46 2014 -0400 @@ -313,9 +313,8 @@ Opens socket to *port* at *host*. This method is implicitly called by the :class:`IMAP4` constructor. The connection objects established by this - method will be used in the :meth:`IMAP4.read`, :meth:`IMAP4.readline`, - :meth:`IMAP4.send`, and :meth:`IMAP4.shutdown` methods. You may override - this method. + method will be used in the ``read``, ``readline``, ``send``, and ``shutdown`` + methods. You may override this method. .. method:: IMAP4.partial(message_num, message_part, start, length) diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/library/imgfile.rst --- a/Doc/library/imgfile.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/library/imgfile.rst Sun Jul 20 10:52:46 2014 -0400 @@ -8,7 +8,7 @@ :deprecated: .. deprecated:: 2.6 - The :mod:`imgfile` module has been removed in Python 3. + The :mod:`imgfile` module has been deprecated for removal in Python 3.0. diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/library/imghdr.rst --- a/Doc/library/imghdr.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/library/imghdr.rst Sun Jul 20 10:52:46 2014 -0400 @@ -68,6 +68,6 @@ Example:: >>> import imghdr - >>> imghdr.what('bass.gif') + >>> imghdr.what('/tmp/bass.gif') 'gif' diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/library/imp.rst --- a/Doc/library/imp.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/library/imp.rst Sun Jul 20 10:52:46 2014 -0400 @@ -65,7 +65,7 @@ path and the last item in the *description* tuple is :const:`PKG_DIRECTORY`. This function does not handle hierarchical module names (names containing - dots). In order to find *P.M*, that is, submodule *M* of package *P*, use + dots). In order to find *P*.*M*, that is, submodule *M* of package *P*, use :func:`find_module` and :func:`load_module` to find and load package *P*, and then use :func:`find_module` with the *path* argument set to ``P.__path__``. When *P* itself has a dotted name, apply this recipe recursively. @@ -237,17 +237,6 @@ using shared libraries is highly system dependent, and not all systems support it.) - .. impl-detail:: - - The import internals identify extension modules by filename, so doing - ``foo = load_dynamic("foo", "mod.so")`` and - ``bar = load_dynamic("bar", "mod.so")`` will result in both foo and bar - referring to the same module, regardless of whether or not - ``mod.so`` exports an ``initbar`` function. On systems which - support them, symlinks can be used to import multiple modules from - the same shared library, as each reference to the module will use - a different file name. - .. function:: load_source(name, pathname[, file]) diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/library/imputil.rst --- a/Doc/library/imputil.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/library/imputil.rst Sun Jul 20 10:52:46 2014 -0400 @@ -7,7 +7,7 @@ :deprecated: .. deprecated:: 2.6 - The :mod:`imputil` module has been removed in Python 3. + The :mod:`imputil` module has been removed in Python 3.0. .. index:: statement: import diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/library/index.rst --- a/Doc/library/index.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/library/index.rst Sun Jul 20 10:52:46 2014 -0400 @@ -4,6 +4,9 @@ The Python Standard Library ############################### +:Release: |version| +:Date: |today| + While :ref:`reference-index` describes the exact syntax and semantics of the Python language, this library reference manual describes the standard library that is distributed with Python. It also diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/library/inspect.rst --- a/Doc/library/inspect.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/library/inspect.rst Sun Jul 20 10:52:46 2014 -0400 @@ -366,7 +366,7 @@ .. impl-detail:: getsets are attributes defined in extension modules via - :c:type:`PyGetSetDef` structures. For Python implementations without such + :ctype:`PyGetSetDef` structures. For Python implementations without such types, this method will always return ``False``. .. versionadded:: 2.5 @@ -379,7 +379,7 @@ .. impl-detail:: Member descriptors are attributes defined in extension modules via - :c:type:`PyMemberDef` structures. For Python implementations without such + :ctype:`PyMemberDef` structures. For Python implementations without such types, this method will always return ``False``. .. versionadded:: 2.5 diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/library/io.rst --- a/Doc/library/io.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/library/io.rst Sun Jul 20 10:52:46 2014 -0400 @@ -92,7 +92,7 @@ ``'b'`` binary mode ``'t'`` text mode (default) ``'+'`` open a disk file for updating (reading and writing) - ``'U'`` universal newlines mode (for backwards compatibility; should + ``'U'`` universal newline mode (for backwards compatibility; should not be used in new code) ========= =============================================================== @@ -141,17 +141,14 @@ used. Any other error handling name that has been registered with :func:`codecs.register_error` is also valid. - .. index:: - single: universal newlines; open() (in module io) - - *newline* controls how :term:`universal newlines` works (it only applies to - text mode). It can be ``None``, ``''``, ``'\n'``, ``'\r'``, and ``'\r\n'``. - It works as follows: + *newline* controls how universal newlines works (it only applies to text + mode). It can be ``None``, ``''``, ``'\n'``, ``'\r'``, and ``'\r\n'``. It + works as follows: * On input, if *newline* is ``None``, universal newlines mode is enabled. Lines in the input can end in ``'\n'``, ``'\r'``, or ``'\r\n'``, and these are translated into ``'\n'`` before being returned to the caller. If it is - ``''``, universal newlines mode is enabled, but line endings are returned to + ``''``, universal newline mode is enabled, but line endings are returned to the caller untranslated. If it has any of the other legal values, input lines are only terminated by the given string, and the line ending is returned to the caller untranslated. @@ -278,7 +275,7 @@ .. method:: readable() - Return ``True`` if the stream can be read from. If ``False``, :meth:`read` + Return ``True`` if the stream can be read from. If False, :meth:`read` will raise :exc:`IOError`. .. method:: readline(limit=-1) @@ -287,7 +284,7 @@ most *limit* bytes will be read. The line terminator is always ``b'\n'`` for binary files; for text files, - the *newline* argument to :func:`.open` can be used to select the line + the *newlines* argument to :func:`.open` can be used to select the line terminator(s) recognized. .. method:: readlines(hint=-1) @@ -296,9 +293,6 @@ to control the number of lines read: no more lines will be read if the total size (in bytes/characters) of all lines so far exceeds *hint*. - Note that it's already possible to iterate on file objects using ``for - line in file: ...`` without calling ``file.readlines()``. - .. method:: seek(offset, whence=SEEK_SET) Change the stream position to the given byte *offset*. *offset* is @@ -346,12 +340,6 @@ is usual for each of the lines provided to have a line separator at the end. - .. method:: __del__() - - Prepare for object destruction. :class:`IOBase` provides a default - implementation of this method that calls the instance's - :meth:`~IOBase.close` method. - .. class:: RawIOBase @@ -650,7 +638,6 @@ :exc:`UnsupportedOperation`. .. warning:: - :class:`BufferedRWPair` does not attempt to synchronize accesses to its underlying raw streams. You should not pass it the same object as reader and writer; use :class:`BufferedRandom` instead. @@ -709,39 +696,11 @@ Read and return at most *n* characters from the stream as a single :class:`unicode`. If *n* is negative or ``None``, reads until EOF. - .. method:: readline(limit=-1) + .. method:: readline() Read until newline or EOF and return a single ``unicode``. If the stream is already at EOF, an empty string is returned. - If *limit* is specified, at most *limit* characters will be read. - - .. method:: seek(offset, whence=SEEK_SET) - - Change the stream position to the given *offset*. Behaviour depends - on the *whence* parameter: - - * :data:`SEEK_SET` or ``0``: seek from the start of the stream - (the default); *offset* must either be a number returned by - :meth:`TextIOBase.tell`, or zero. Any other *offset* value - produces undefined behaviour. - * :data:`SEEK_CUR` or ``1``: "seek" to the current position; - *offset* must be zero, which is a no-operation (all other values - are unsupported). - * :data:`SEEK_END` or ``2``: seek to the end of the stream; - *offset* must be zero (all other values are unsupported). - - Return the new absolute position as an opaque number. - - .. versionadded:: 2.7 - The ``SEEK_*`` constants. - - .. method:: tell() - - Return the current stream position as an opaque number. The number - does not usually represent a number of bytes in the underlying - binary storage. - .. method:: write(s) Write the :class:`unicode` string *s* to the stream and return the @@ -767,25 +726,14 @@ sequences) can be used. Any other error handling name that has been registered with :func:`codecs.register_error` is also valid. - .. index:: - single: universal newlines; io.TextIOWrapper class - - *newline* controls how line endings are handled. It can be ``None``, - ``''``, ``'\n'``, ``'\r'``, and ``'\r\n'``. It works as follows: - - * On input, if *newline* is ``None``, :term:`universal newlines` mode is - enabled. Lines in the input can end in ``'\n'``, ``'\r'``, or ``'\r\n'``, - and these are translated into ``'\n'`` before being returned to the - caller. If it is ``''``, universal newlines mode is enabled, but line - endings are returned to the caller untranslated. If it has any of the - other legal values, input lines are only terminated by the given string, - and the line ending is returned to the caller untranslated. - - * On output, if *newline* is ``None``, any ``'\n'`` characters written are - translated to the system default line separator, :data:`os.linesep`. If - *newline* is ``''``, no translation takes place. If *newline* is any of - the other legal values, any ``'\n'`` characters written are translated to - the given string. + *newline* can be ``None``, ``''``, ``'\n'``, ``'\r'``, or ``'\r\n'``. It + controls the handling of line endings. If it is ``None``, universal newlines + is enabled. With this enabled, on input, the lines endings ``'\n'``, + ``'\r'``, or ``'\r\n'`` are translated to ``'\n'`` before being returned to + the caller. Conversely, on output, ``'\n'`` is translated to the system + default line separator, :data:`os.linesep`. If *newline* is any other of its + legal values, that newline becomes the newline when the file is read and it + is returned untranslated. On output, ``'\n'`` is converted to the *newline*. If *line_buffering* is ``True``, :meth:`flush` is implied when a call to write contains a newline character. @@ -798,14 +746,14 @@ Whether line buffering is enabled. -.. class:: StringIO(initial_value=u'', newline=u'\\n') +.. class:: StringIO(initial_value=u'', newline=None) An in-memory stream for unicode text. It inherits :class:`TextIOWrapper`. The initial value of the buffer (an empty unicode string by default) can be set by providing *initial_value*. The *newline* argument works like - that of :class:`TextIOWrapper`. The default is to consider only ``\n`` - characters as end of lines and to do no newline translation. + that of :class:`TextIOWrapper`. The default is to do no newline + translation. :class:`StringIO` provides this method in addition to those from :class:`TextIOWrapper` and its parents: @@ -833,13 +781,10 @@ output.close() -.. index:: - single: universal newlines; io.IncrementalNewlineDecoder class - .. class:: IncrementalNewlineDecoder - A helper codec that decodes newlines for :term:`universal newlines` mode. - It inherits :class:`codecs.IncrementalDecoder`. + A helper codec that decodes newlines for universal newlines mode. It + inherits :class:`codecs.IncrementalDecoder`. Advanced topics diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/library/itertools.rst --- a/Doc/library/itertools.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/library/itertools.rst Sun Jul 20 10:52:46 2014 -0400 @@ -52,12 +52,12 @@ :func:`compress` data, selectors (d[0] if s[0]), (d[1] if s[1]), ... ``compress('ABCDEF', [1,0,1,0,1,1]) --> A C E F`` :func:`dropwhile` pred, seq seq[n], seq[n+1], starting when pred fails ``dropwhile(lambda x: x<5, [1,4,6,4,1]) --> 6 4 1`` :func:`groupby` iterable[, keyfunc] sub-iterators grouped by value of keyfunc(v) -:func:`ifilter` pred, seq elements of seq where pred(elem) is true ``ifilter(lambda x: x%2, range(10)) --> 1 3 5 7 9`` -:func:`ifilterfalse` pred, seq elements of seq where pred(elem) is false ``ifilterfalse(lambda x: x%2, range(10)) --> 0 2 4 6 8`` +:func:`ifilter` pred, seq elements of seq where pred(elem) is True ``ifilter(lambda x: x%2, range(10)) --> 1 3 5 7 9`` +:func:`ifilterfalse` pred, seq elements of seq where pred(elem) is False ``ifilterfalse(lambda x: x%2, range(10)) --> 0 2 4 6 8`` :func:`islice` seq, [start,] stop [, step] elements from seq[start:stop:step] ``islice('ABCDEFG', 2, None) --> C D E F G`` :func:`imap` func, p, q, ... func(p0, q0), func(p1, q1), ... ``imap(pow, (2,3,10), (5,2,3)) --> 32 9 1000`` :func:`starmap` func, seq func(\*seq[0]), func(\*seq[1]), ... ``starmap(pow, [(2,5), (3,2), (10,3)]) --> 32 9 1000`` -:func:`tee` it, n it1, it2, ... itn splits one iterator into n +:func:`tee` it, n it1, it2 , ... itn splits one iterator into n :func:`takewhile` pred, seq seq[0], seq[1], until pred fails ``takewhile(lambda x: x<5, [1,4,6,4,1]) --> 1 4`` :func:`izip` p, q, ... (p[0], q[0]), (p[1], q[1]), ... ``izip('ABCD', 'xy') --> Ax By`` :func:`izip_longest` p, q, ... (p[0], q[0]), (p[1], q[1]), ... ``izip_longest('ABCD', 'xy', fillvalue='-') --> Ax By C- D-`` @@ -106,8 +106,9 @@ .. classmethod:: chain.from_iterable(iterable) Alternate constructor for :func:`chain`. Gets chained inputs from a - single iterable argument that is evaluated lazily. Roughly equivalent to:: + single iterable argument that is evaluated lazily. Equivalent to:: + @classmethod def from_iterable(iterables): # chain.from_iterable(['ABC', 'DEF']) --> A B C D E F for it in iterables: @@ -392,8 +393,7 @@ yield function(*args) -.. function:: islice(iterable, stop) - islice(iterable, start, stop[, step]) +.. function:: islice(iterable, [start,] stop [, step]) Make an iterator that returns selected elements from the iterable. If *start* is non-zero, then elements from the iterable are skipped until start is reached. @@ -590,11 +590,6 @@ for i in xrange(times): yield object - A common use for *repeat* is to supply a stream of constant values to *imap* - or *zip*:: - - >>> list(imap(pow, xrange(10), repeat(2))) - [0, 1, 4, 9, 16, 25, 36, 49, 64, 81] .. function:: starmap(function, iterable) @@ -732,9 +727,8 @@ next(b, None) return izip(a, b) - def grouper(iterable, n, fillvalue=None): - "Collect data into fixed-length chunks or blocks" - # grouper('ABCDEFG', 3, 'x') --> ABC DEF Gxx + def grouper(n, iterable, fillvalue=None): + "grouper(3, 'ABCDEFG', 'x') --> ABC DEF Gxx" args = [iter(iterable)] * n return izip_longest(fillvalue=fillvalue, *args) @@ -828,18 +822,6 @@ indices = sorted(random.randrange(n) for i in xrange(r)) return tuple(pool[i] for i in indices) - def tee_lookahead(t, i): - """Inspect the i-th upcomping value from a tee object - while leaving the tee object at its current position. - - Raise an IndexError if the underlying iterator doesn't - have enough values. - - """ - for value in islice(t.__copy__(), i, None): - return value - raise IndexError(i) - Note, many of the above recipes can be optimized by replacing global lookups with local variables defined as default values. For example, the *dotproduct* recipe can be written as:: diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/library/jpeg.rst --- a/Doc/library/jpeg.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/library/jpeg.rst Sun Jul 20 10:52:46 2014 -0400 @@ -8,7 +8,7 @@ :deprecated: .. deprecated:: 2.6 - The :mod:`jpeg` module has been removed in Python 3. + The :mod:`jpeg` module has been deprecated for removal in Python 3.0. diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/library/json.rst --- a/Doc/library/json.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/library/json.rst Sun Jul 20 10:52:46 2014 -0400 @@ -7,10 +7,8 @@ .. sectionauthor:: Bob Ippolito .. versionadded:: 2.6 -`JSON (JavaScript Object Notation) `_, specified by -:rfc:`4627`, is a lightweight data interchange format based on a subset of -`JavaScript `_ syntax (`ECMA-262 3rd -edition `_). +`JSON (JavaScript Object Notation) `_ is a subset of JavaScript +syntax (ECMA-262 3rd edition) used as a lightweight data interchange format. :mod:`json` exposes an API familiar to users of the standard library :mod:`marshal` and :mod:`pickle` modules. @@ -43,8 +41,7 @@ Pretty printing:: >>> import json - >>> print json.dumps({'4': 5, '6': 7}, sort_keys=True, - ... indent=4, separators=(',', ': ')) + >>> print json.dumps({'4': 5, '6': 7}, sort_keys=True, indent=4) { "4": 5, "6": 7 @@ -84,7 +81,6 @@ ... def default(self, obj): ... if isinstance(obj, complex): ... return [obj.real, obj.imag] - ... # Let the base class default method raise the TypeError ... return json.JSONEncoder.default(self, obj) ... >>> dumps(2 + 1j, cls=ComplexEncoder) @@ -103,44 +99,35 @@ { "json": "obj" } - $ echo '{1.2:3.4}' | python -mjson.tool - Expecting property name enclosed in double quotes: line 1 column 2 (char 1) + $ echo '{ 1.2:3.4}' | python -mjson.tool + Expecting property name: line 1 column 2 (char 2) .. highlight:: python .. note:: - JSON is a subset of `YAML `_ 1.2. The JSON produced by - this module's default settings (in particular, the default *separators* - value) is also a subset of YAML 1.0 and 1.1. This module can thus also be - used as a YAML serializer. + The JSON produced by this module's default settings is a subset of + YAML, so it may be used as a serializer for that as well. Basic Usage ----------- -.. function:: dump(obj, fp, skipkeys=False, ensure_ascii=True, \ - check_circular=True, allow_nan=True, cls=None, \ - indent=None, separators=None, encoding="utf-8", \ - default=None, sort_keys=False, **kw) +.. function:: dump(obj, fp[, skipkeys[, ensure_ascii[, check_circular[, allow_nan[, cls[, indent[, separators[, encoding[, default[, **kw]]]]]]]]]]) Serialize *obj* as a JSON formatted stream to *fp* (a ``.write()``-supporting - :term:`file-like object`) using this :ref:`conversion table - `. + file-like object). If *skipkeys* is ``True`` (default: ``False``), then dict keys that are not of a basic type (:class:`str`, :class:`unicode`, :class:`int`, :class:`long`, :class:`float`, :class:`bool`, ``None``) will be skipped instead of raising a :exc:`TypeError`. - If *ensure_ascii* is ``True`` (the default), all non-ASCII characters in the - output are escaped with ``\uXXXX`` sequences, and the result is a - :class:`str` instance consisting of ASCII characters only. If - *ensure_ascii* is ``False``, some chunks written to *fp* may be - :class:`unicode` instances. This usually happens because the input contains - unicode strings or the *encoding* parameter is used. Unless ``fp.write()`` - explicitly understands :class:`unicode` (as in :func:`codecs.getwriter`) - this is likely to cause an error. + If *ensure_ascii* is ``False`` (default: ``True``), then some chunks written + to *fp* may be :class:`unicode` instances, subject to normal Python + :class:`str` to :class:`unicode` coercion rules. Unless ``fp.write()`` + explicitly understands :class:`unicode` (as in :func:`codecs.getwriter`) this + is likely to cause an error. If *check_circular* is ``False`` (default: ``True``), then the circular reference check for container types will be skipped and a circular reference @@ -156,12 +143,6 @@ or negative, will only insert newlines. ``None`` (the default) selects the most compact representation. - .. note:: - - Since the default item separator is ``', '``, the output might include - trailing whitespace when *indent* is specified. You can use - ``separators=(',', ': ')`` to avoid this. - If *separators* is an ``(item_separator, dict_separator)`` tuple, then it will be used instead of the default ``(', ', ': ')`` separators. ``(',', ':')`` is the most compact JSON representation. @@ -171,9 +152,6 @@ *default(obj)* is a function that should return a serializable version of *obj* or raise :exc:`TypeError`. The default simply raises :exc:`TypeError`. - If *sort_keys* is ``True`` (default: ``False``), then the output of - dictionaries will be sorted by key. - To use a custom :class:`JSONEncoder` subclass (e.g. one that overrides the :meth:`default` method to serialize additional types), specify it with the *cls* kwarg; otherwise :class:`JSONEncoder` is used. @@ -184,32 +162,19 @@ trying to serialize more objects with repeated calls to :func:`dump` and the same *fp* will result in an invalid JSON file. -.. function:: dumps(obj, skipkeys=False, ensure_ascii=True, \ - check_circular=True, allow_nan=True, cls=None, \ - indent=None, separators=None, encoding="utf-8", \ - default=None, sort_keys=False, **kw) +.. function:: dumps(obj[, skipkeys[, ensure_ascii[, check_circular[, allow_nan[, cls[, indent[, separators[, encoding[, default[, **kw]]]]]]]]]]) - Serialize *obj* to a JSON formatted :class:`str` using this :ref:`conversion - table `. If *ensure_ascii* is ``False``, the result may - contain non-ASCII characters and the return value may be a :class:`unicode` - instance. + Serialize *obj* to a JSON formatted :class:`str`. - The arguments have the same meaning as in :func:`dump`. + If *ensure_ascii* is ``False``, then the return value will be a + :class:`unicode` instance. The other arguments have the same meaning as in + :func:`dump`. - .. note:: - - Keys in key/value pairs of JSON are always of the type :class:`str`. When - a dictionary is converted into JSON, all the keys of the dictionary are - coerced to strings. As a result of this, if a dictionary is converted - into JSON and then back into a dictionary, the dictionary may not equal - the original one. That is, ``loads(dumps(x)) != x`` if x has non-string - keys. .. function:: load(fp[, encoding[, cls[, object_hook[, parse_float[, parse_int[, parse_constant[, object_pairs_hook[, **kw]]]]]]]]) - Deserialize *fp* (a ``.read()``-supporting :term:`file-like object` - containing a JSON document) to a Python object using this :ref:`conversion - table `. + Deserialize *fp* (a ``.read()``-supporting file-like object containing a JSON + document) to a Python object. If the contents of *fp* are encoded with an ASCII based encoding other than UTF-8 (e.g. latin-1), then an appropriate *encoding* name must be specified. @@ -220,8 +185,7 @@ *object_hook* is an optional function that will be called with the result of any object literal decoded (a :class:`dict`). The return value of *object_hook* will be used instead of the :class:`dict`. This feature can be used - to implement custom decoders (e.g. `JSON-RPC `_ - class hinting). + to implement custom decoders (e.g. JSON-RPC class hinting). *object_pairs_hook* is an optional function that will be called with the result of any object literal decoded with an ordered list of pairs. The @@ -245,13 +209,10 @@ (e.g. :class:`float`). *parse_constant*, if specified, will be called with one of the following - strings: ``'-Infinity'``, ``'Infinity'``, ``'NaN'``. - This can be used to raise an exception if invalid JSON numbers + strings: ``'-Infinity'``, ``'Infinity'``, ``'NaN'``, ``'null'``, ``'true'``, + ``'false'``. This can be used to raise an exception if invalid JSON numbers are encountered. - .. versionchanged:: 2.7 - *parse_constant* doesn't get called on 'null', 'true', 'false' anymore. - To use a custom :class:`JSONDecoder` subclass, specify it with the ``cls`` kwarg; otherwise :class:`JSONDecoder` is used. Additional keyword arguments will be passed to the constructor of the class. @@ -260,8 +221,7 @@ .. function:: loads(s[, encoding[, cls[, object_hook[, parse_float[, parse_int[, parse_constant[, object_pairs_hook[, **kw]]]]]]]]) Deserialize *s* (a :class:`str` or :class:`unicode` instance containing a JSON - document) to a Python object using this :ref:`conversion table - `. + document) to a Python object. If *s* is a :class:`str` instance and is encoded with an ASCII based encoding other than UTF-8 (e.g. latin-1), then an appropriate *encoding* name must be @@ -271,7 +231,7 @@ The other arguments have the same meaning as in :func:`load`. -Encoders and Decoders +Encoders and decoders --------------------- .. class:: JSONDecoder([encoding[, object_hook[, parse_float[, parse_int[, parse_constant[, strict[, object_pairs_hook]]]]]]]) @@ -280,8 +240,6 @@ Performs the following translations in decoding by default: - .. _json-to-py-table: - +---------------+-------------------+ | JSON | Python | +===============+===================+ @@ -348,8 +306,6 @@ those with character codes in the 0-31 range, including ``'\t'`` (tab), ``'\n'``, ``'\r'`` and ``'\0'``. - If the data being deserialized is not a valid JSON document, a - :exc:`ValueError` will be raised. .. method:: decode(s) @@ -372,8 +328,6 @@ Supports the following objects and types by default: - .. _py-to-json-table: - +-------------------+---------------+ | Python | JSON | +===================+===============+ @@ -401,12 +355,9 @@ attempt encoding of keys that are not str, int, long, float or None. If *skipkeys* is ``True``, such items are simply skipped. - If *ensure_ascii* is ``True`` (the default), all non-ASCII characters in the - output are escaped with ``\uXXXX`` sequences, and the results are - :class:`str` instances consisting of ASCII characters only. If - *ensure_ascii* is ``False``, a result may be a :class:`unicode` - instance. This usually happens if the input contains unicode strings or the - *encoding* parameter is used. + If *ensure_ascii* is ``True`` (the default), the output is guaranteed to be + :class:`str` objects with all incoming unicode characters escaped. If + *ensure_ascii* is ``False``, the output will be a unicode object. If *check_circular* is ``True`` (the default), then lists, dicts, and custom encoded objects will be checked for circular references during encoding to @@ -428,12 +379,6 @@ level. An indent level of 0 will only insert newlines. ``None`` is the most compact representation. - .. note:: - - Since the default item separator is ``', '``, the output might include - trailing whitespace when *indent* is specified. You can use - ``separators=(',', ': ')`` to avoid this. - If specified, *separators* should be an ``(item_separator, key_separator)`` tuple. The default is ``(', ', ': ')``. To get the most compact JSON representation, you should specify ``(',', ':')`` to eliminate whitespace. @@ -463,7 +408,6 @@ pass else: return list(iterable) - # Let the base class default method raise the TypeError return JSONEncoder.default(self, o) @@ -483,108 +427,3 @@ for chunk in JSONEncoder().iterencode(bigobject): mysocket.write(chunk) - - -Standard Compliance -------------------- - -The JSON format is specified by :rfc:`4627`. This section details this -module's level of compliance with the RFC. For simplicity, -:class:`JSONEncoder` and :class:`JSONDecoder` subclasses, and parameters other -than those explicitly mentioned, are not considered. - -This module does not comply with the RFC in a strict fashion, implementing some -extensions that are valid JavaScript but not valid JSON. In particular: - -- Top-level non-object, non-array values are accepted and output; -- Infinite and NaN number values are accepted and output; -- Repeated names within an object are accepted, and only the value of the last - name-value pair is used. - -Since the RFC permits RFC-compliant parsers to accept input texts that are not -RFC-compliant, this module's deserializer is technically RFC-compliant under -default settings. - -Character Encodings -^^^^^^^^^^^^^^^^^^^ - -The RFC recommends that JSON be represented using either UTF-8, UTF-16, or -UTF-32, with UTF-8 being the default. Accordingly, this module uses UTF-8 as -the default for its *encoding* parameter. - -This module's deserializer only directly works with ASCII-compatible encodings; -UTF-16, UTF-32, and other ASCII-incompatible encodings require the use of -workarounds described in the documentation for the deserializer's *encoding* -parameter. - -The RFC also non-normatively describes a limited encoding detection technique -for JSON texts; this module's deserializer does not implement this or any other -kind of encoding detection. - -As permitted, though not required, by the RFC, this module's serializer sets -*ensure_ascii=True* by default, thus escaping the output so that the resulting -strings only contain ASCII characters. - - -Top-level Non-Object, Non-Array Values -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -The RFC specifies that the top-level value of a JSON text must be either a -JSON object or array (Python :class:`dict` or :class:`list`). This module's -deserializer also accepts input texts consisting solely of a -JSON null, boolean, number, or string value:: - - >>> just_a_json_string = '"spam and eggs"' # Not by itself a valid JSON text - >>> json.loads(just_a_json_string) - u'spam and eggs' - -This module itself does not include a way to request that such input texts be -regarded as illegal. Likewise, this module's serializer also accepts single -Python :data:`None`, :class:`bool`, numeric, and :class:`str` -values as input and will generate output texts consisting solely of a top-level -JSON null, boolean, number, or string value without raising an exception:: - - >>> neither_a_list_nor_a_dict = u"spam and eggs" - >>> json.dumps(neither_a_list_nor_a_dict) # The result is not a valid JSON text - '"spam and eggs"' - -This module's serializer does not itself include a way to enforce the -aforementioned constraint. - - -Infinite and NaN Number Values -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -The RFC does not permit the representation of infinite or NaN number values. -Despite that, by default, this module accepts and outputs ``Infinity``, -``-Infinity``, and ``NaN`` as if they were valid JSON number literal values:: - - >>> # Neither of these calls raises an exception, but the results are not valid JSON - >>> json.dumps(float('-inf')) - '-Infinity' - >>> json.dumps(float('nan')) - 'NaN' - >>> # Same when deserializing - >>> json.loads('-Infinity') - -inf - >>> json.loads('NaN') - nan - -In the serializer, the *allow_nan* parameter can be used to alter this -behavior. In the deserializer, the *parse_constant* parameter can be used to -alter this behavior. - - -Repeated Names Within an Object -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -The RFC specifies that the names within a JSON object should be unique, but -does not specify how repeated names in JSON objects should be handled. By -default, this module does not raise an exception; instead, it ignores all but -the last name-value pair for a given name:: - - >>> weird_json = '{"x": 1, "x": 2, "x": 3}' - >>> json.loads(weird_json) - {u'x': 3} - -The *object_pairs_hook* parameter can be used to alter this behavior. diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/library/locale.rst --- a/Doc/library/locale.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/library/locale.rst Sun Jul 20 10:52:46 2014 -0400 @@ -59,8 +59,6 @@ Returns the database of the local conventions as a dictionary. This dictionary has the following strings as keys: - .. tabularcolumns:: |l|l|L| - +----------------------+-------------------------------------+--------------------------------+ | Category | Key | Meaning | +======================+=====================================+================================+ @@ -166,22 +164,22 @@ .. data:: D_T_FMT - Get a string that can be used as a format string for :func:`time.strftime` to + Get a string that can be used as a format string for :func:`strftime` to represent date and time in a locale-specific way. .. data:: D_FMT - Get a string that can be used as a format string for :func:`time.strftime` to + Get a string that can be used as a format string for :func:`strftime` to represent a date in a locale-specific way. .. data:: T_FMT - Get a string that can be used as a format string for :func:`time.strftime` to + Get a string that can be used as a format string for :func:`strftime` to represent a time in a locale-specific way. .. data:: T_FMT_AMPM - Get a format string for :func:`time.strftime` to represent time in the am/pm + Get a format string for :func:`strftime` to represent time in the am/pm format. .. data:: DAY_1 ... DAY_7 @@ -221,7 +219,7 @@ .. note:: - The expression is in the syntax suitable for the :c:func:`regex` function + The expression is in the syntax suitable for the :cfunc:`regex` function from the C library, which might differ from the syntax used in :mod:`re`. .. data:: NOEXPR @@ -245,24 +243,24 @@ then-emperor's reign. Normally it should not be necessary to use this value directly. Specifying - the ``E`` modifier in their format strings causes the :func:`time.strftime` + the ``E`` modifier in their format strings causes the :func:`strftime` function to use this information. The format of the returned string is not specified, and therefore you should not assume knowledge of it on different systems. .. data:: ERA_D_T_FMT - Get a format string for :func:`time.strftime` to represent date and time in a + Get a format string for :func:`strftime` to represent date and time in a locale-specific era-based way. .. data:: ERA_D_FMT - Get a format string for :func:`time.strftime` to represent a date in a + Get a format string for :func:`strftime` to represent a date in a locale-specific era-based way. .. data:: ERA_T_FMT - Get a format string for :func:`time.strftime` to represent a time in a + Get a format string for :func:`strftime` to represent a time in a locale-specific era-based way. .. data:: ALT_DIGITS @@ -562,7 +560,7 @@ Python applications should normally find no need to invoke these functions, and should use :mod:`gettext` instead. A known exception to this rule are applications that link with additional C libraries which internally invoke -:c:func:`gettext` or :func:`dcgettext`. For these applications, it may be +:cfunc:`gettext` or :func:`dcgettext`. For these applications, it may be necessary to bind the text domain, so that the libraries can properly locate their message catalogs. diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/library/logging.config.rst --- a/Doc/library/logging.config.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/library/logging.config.rst Sun Jul 20 10:52:46 2014 -0400 @@ -17,10 +17,6 @@ * :ref:`Advanced Tutorial ` * :ref:`Logging Cookbook ` -**Source code:** :source:`Lib/logging/config.py` - --------------- - This section describes the API for configuring the logging module. .. _logging-config-api: @@ -81,9 +77,8 @@ .. function:: fileConfig(fname, defaults=None, disable_existing_loggers=True) Reads the logging configuration from a :mod:`configparser`\-format file - named *fname*. The format of the file should be as described in - :ref:`logging-config-fileformat`. This function can be called several times - from an application, allowing an end user to select from various pre-canned + named *fname*. This function can be called several times from an + application, allowing an end user to select from various pre-canned configurations (if the developer provides a mechanism to present the choices and load the chosen configuration). @@ -109,30 +104,14 @@ configurations. If no port is specified, the module's default :const:`DEFAULT_LOGGING_CONFIG_PORT` is used. Logging configurations will be sent as a file suitable for processing by :func:`fileConfig`. Returns a - :class:`~threading.Thread` instance on which you can call - :meth:`~threading.Thread.start` to start the server, and which you can - :meth:`~threading.Thread.join` when appropriate. To stop the server, + :class:`Thread` instance on which you can call :meth:`start` to start the + server, and which you can :meth:`join` when appropriate. To stop the server, call :func:`stopListening`. To send a configuration to the socket, read in the configuration file and send it to the socket as a string of bytes preceded by a four-byte length string packed in binary using ``struct.pack('>L', n)``. - .. note:: - - Because portions of the configuration are passed through - :func:`eval`, use of this function may open its users to a security risk. - While the function only binds to a socket on ``localhost``, and so does - not accept connections from remote machines, there are scenarios where - untrusted code could be run under the account of the process which calls - :func:`listen`. Specifically, if the process calling :func:`listen` runs - on a multi-user machine where users cannot trust each other, then a - malicious user could arrange to run essentially arbitrary code in a - victim user's process, simply by connecting to the victim's - :func:`listen` socket and sending a configuration which runs whatever - code the attacker wants to have executed in the victim's process. This is - especially easy to do if the default port is used, but not hard even if a - different port is used). .. function:: stopListening() @@ -177,11 +156,11 @@ * *formatters* - the corresponding value will be a dict in which each key is a formatter id and each value is a dict describing how to - configure the corresponding :class:`~logging.Formatter` instance. + configure the corresponding Formatter instance. The configuring dict is searched for keys ``format`` and ``datefmt`` (with defaults of ``None``) and these are used to construct a - :class:`~logging.Formatter` instance. + :class:`logging.Formatter` instance. * *filters* - the corresponding value will be a dict in which each key is a filter id and each value is a dict describing how to configure @@ -719,17 +698,8 @@ The ``class`` entry is optional. It indicates the name of the formatter's class (as a dotted module and class name.) This option is useful for instantiating a -:class:`~logging.Formatter` subclass. Subclasses of -:class:`~logging.Formatter` can present exception tracebacks in an expanded or -condensed format. - -.. note:: - - Due to the use of :func:`eval` as described above, there are - potential security risks which result from using the :func:`listen` to send - and receive configurations via sockets. The risks are limited to where - multiple users with no mutual trust run code on the same machine; see the - :func:`listen` documentation for more information. +:class:`Formatter` subclass. Subclasses of :class:`Formatter` can present +exception tracebacks in an expanded or condensed format. .. seealso:: diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/library/logging.handlers.rst --- a/Doc/library/logging.handlers.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/library/logging.handlers.rst Sun Jul 20 10:52:46 2014 -0400 @@ -17,10 +17,6 @@ * :ref:`Advanced Tutorial ` * :ref:`Logging Cookbook ` -**Source code:** :source:`Lib/logging/handlers.py` - --------------- - .. currentmodule:: logging The following useful handlers are provided in the package. Note that three of @@ -57,8 +53,8 @@ .. method:: flush() Flushes the stream by calling its :meth:`flush` method. Note that the - :meth:`close` method is inherited from :class:`~logging.Handler` and so - does no output, so an explicit :meth:`flush` call may be needed at times. + :meth:`close` method is inherited from :class:`Handler` and so does + no output, so an explicit :meth:`flush` call may be needed at times. .. _file-handler: @@ -146,8 +142,8 @@ This handler is not appropriate for use under Windows, because under Windows open log files cannot be moved or renamed - logging opens the files with exclusive locks - and so there is no need for such a handler. Furthermore, -*ST_INO* is not supported under Windows; :func:`~os.stat` always returns zero -for this value. +*ST_INO* is not supported under Windows; :func:`stat` always returns zero for +this value. .. class:: WatchedFileHandler(filename[,mode[, encoding[, delay]]]) @@ -240,15 +236,11 @@ +----------------+-----------------------+ | ``'D'`` | Days | +----------------+-----------------------+ - | ``'W0'-'W6'`` | Weekday (0=Monday) | + | ``'W'`` | Week day (0=Monday) | +----------------+-----------------------+ | ``'midnight'`` | Roll over at midnight | +----------------+-----------------------+ - When using weekday-based rotation, specify 'W0' for Monday, 'W1' for - Tuesday, and so on up to 'W6' for Sunday. In this case, the value passed for - *interval* isn't used. - The system will save old log files by appending extensions to the filename. The extensions are date-and-time based, using the strftime format ``%Y-%m-%d_%H-%M-%S`` or a leading portion thereof, depending on the @@ -309,8 +301,7 @@ binary format. If there is an error with the socket, silently drops the packet. If the connection was previously lost, re-establishes the connection. To unpickle the record at the receiving end into a - :class:`~logging.LogRecord`, use the :func:`~logging.makeLogRecord` - function. + :class:`LogRecord`, use the :func:`makeLogRecord` function. .. method:: handleError() @@ -388,8 +379,7 @@ Pickles the record's attribute dictionary and writes it to the socket in binary format. If there is an error with the socket, silently drops the packet. To unpickle the record at the receiving end into a - :class:`~logging.LogRecord`, use the :func:`~logging.makeLogRecord` - function. + :class:`LogRecord`, use the :func:`makeLogRecord` function. .. method:: makeSocket() @@ -660,7 +650,7 @@ :class:`BufferingHandler`, which is an abstract class. This buffers logging records in memory. Whenever each record is added to the buffer, a check is made by calling :meth:`shouldFlush` to see if the buffer should be flushed. If it -should, then :meth:`flush` is expected to do the flushing. +should, then :meth:`flush` is expected to do the needful. .. class:: BufferingHandler(capacity) @@ -708,6 +698,9 @@ .. method:: setTarget(target) + .. versionchanged:: 2.6 + *credentials* was added. + Sets the target handler for this handler. @@ -729,29 +722,15 @@ .. class:: HTTPHandler(host, url, method='GET') - Returns a new instance of the :class:`HTTPHandler` class. The ``host`` can be + Returns a new instance of the :class:`HTTPHandler` class. The *host* can be of the form ``host:port``, should you need to use a specific port number. + If no *method* is specified, ``GET`` is used. - .. method:: mapLogRecord(record) - - Provides a dictionary, based on ``record``, which is to be URL-encoded - and sent to the web server. The default implementation just returns - ``record.__dict__``. This method can be overridden if e.g. only a - subset of :class:`~logging.LogRecord` is to be sent to the web server, or - if more specific customization of what's sent to the server is required. .. method:: emit(record) - Sends the record to the Web server as an URL-encoded dictionary. The - :meth:`mapLogRecord` method is used to convert the record to the - dictionary to be sent. + Sends the record to the Web server as a percent-encoded dictionary. - .. note:: Since preparing a record for sending it to a Web server is not - the same as a generic formatting operation, using :meth:`setFormatter` - to specify a :class:`Formatter` for a :class:`HTTPHandler` has no effect. - Instead of calling :meth:`format`, this handler calls :meth:`mapLogRecord` - and then :func:`urllib.urlencode` to encode the dictionary in a form - suitable for sending to a Web server. .. seealso:: diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/library/logging.rst --- a/Doc/library/logging.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/library/logging.rst Sun Jul 20 10:52:46 2014 -0400 @@ -20,9 +20,6 @@ * :ref:`Advanced Tutorial ` * :ref:`Logging Cookbook ` -**Source code:** :source:`Lib/logging/__init__.py` - --------------- .. versionadded:: 2.3 @@ -54,46 +51,24 @@ Logger Objects -------------- -Loggers have the following attributes and methods. Note that Loggers are never +Loggers have the following attributes and methods. Note that Loggers are never instantiated directly, but always through the module-level function -``logging.getLogger(name)``. Multiple calls to :func:`getLogger` with the same -name will always return a reference to the same Logger object. - -The ``name`` is potentially a period-separated hierarchical value, like -``foo.bar.baz`` (though it could also be just plain ``foo``, for example). -Loggers that are further down in the hierarchical list are children of loggers -higher up in the list. For example, given a logger with a name of ``foo``, -loggers with names of ``foo.bar``, ``foo.bar.baz``, and ``foo.bam`` are all -descendants of ``foo``. The logger name hierarchy is analogous to the Python -package hierarchy, and identical to it if you organise your loggers on a -per-module basis using the recommended construction -``logging.getLogger(__name__)``. That's because in a module, ``__name__`` -is the module's name in the Python package namespace. - +``logging.getLogger(name)``. .. class:: Logger .. attribute:: Logger.propagate - If this evaluates to true, events logged to this logger will be passed to the - handlers of higher level (ancestor) loggers, in addition to any handlers - attached to this logger. Messages are passed directly to the ancestor - loggers' handlers - neither the level nor filters of the ancestor loggers in - question are considered. + If this evaluates to true, logging messages are passed by this logger and by + its child loggers to the handlers of higher level (ancestor) loggers. + Messages are passed directly to the ancestor loggers' handlers - neither the + level nor filters of the ancestor loggers in question are considered. If this evaluates to false, logging messages are not passed to the handlers of ancestor loggers. - The constructor sets this attribute to ``True``. + The constructor sets this attribute to 1. - .. note:: If you attach a handler to a logger *and* one or more of its - ancestors, it may emit the same record multiple times. In general, you - should not need to attach a handler to more than one logger - if you just - attach it to the appropriate logger which is highest in the logger - hierarchy, then it will see all events logged by all descendant loggers, - provided that their propagate setting is left set to ``True``. A common - scenario is to attach handlers only to the root logger, and to let - propagation take care of the rest. .. method:: Logger.setLevel(lvl) @@ -114,8 +89,6 @@ If the root is reached, and it has a level of NOTSET, then all messages will be processed. Otherwise, the root's level will be used as the effective level. - See :ref:`levels` for a list of levels. - .. method:: Logger.isEnabledFor(lvl) @@ -165,7 +138,7 @@ FORMAT = '%(asctime)-15s %(clientip)s %(user)-8s %(message)s' logging.basicConfig(format=FORMAT) - d = {'clientip': '192.168.0.1', 'user': 'fbloggs'} + d = { 'clientip' : '192.168.0.1', 'user' : 'fbloggs' } logger = logging.getLogger('tcpserver') logger.warning('Protocol problem: %s', 'connection reset', extra=d) @@ -222,7 +195,7 @@ interpreted as for :meth:`debug`. -.. method:: Logger.exception(msg, *args, **kwargs) +.. method:: Logger.exception(msg, *args) Logs a message with level :const:`ERROR` on this logger. The arguments are interpreted as for :meth:`debug`. Exception info is added to the logging @@ -242,10 +215,7 @@ .. method:: Logger.filter(record) Applies this logger's filters to the record and returns a true value if the - record is to be processed. The filters are consulted in turn, until one of - them returns a false value. If none of them return a false value, the record - will be processed (passed to handlers). If one returns a false value, no - further processing of the record occurs. + record is to be processed. .. method:: Logger.addHandler(hdlr) @@ -283,35 +253,6 @@ .. versionchanged:: 2.5 *func* and *extra* were added. - -.. _levels: - -Logging Levels --------------- - -The numeric values of logging levels are given in the following table. These are -primarily of interest if you want to define your own levels, and need them to -have specific values relative to the predefined levels. If you define a level -with the same numeric value, it overwrites the predefined value; the predefined -name is lost. - -+--------------+---------------+ -| Level | Numeric value | -+==============+===============+ -| ``CRITICAL`` | 50 | -+--------------+---------------+ -| ``ERROR`` | 40 | -+--------------+---------------+ -| ``WARNING`` | 30 | -+--------------+---------------+ -| ``INFO`` | 20 | -+--------------+---------------+ -| ``DEBUG`` | 10 | -+--------------+---------------+ -| ``NOTSET`` | 0 | -+--------------+---------------+ - - .. _handler: Handler Objects @@ -352,7 +293,6 @@ severe than *lvl* will be ignored. When a handler is created, the level is set to :const:`NOTSET` (which causes all messages to be processed). - See :ref:`levels` for a list of levels. .. method:: Handler.setFormatter(form) @@ -372,10 +312,7 @@ .. method:: Handler.filter(record) Applies this handler's filters to the record and returns a true value if the - record is to be processed. The filters are consulted in turn, until one of - them returns a false value. If none of them return a false value, the record - will be emitted. If one returns a false value, the handler will not emit the - record. + record is to be processed. .. method:: Handler.flush() @@ -402,14 +339,12 @@ .. method:: Handler.handleError(record) This method should be called from handlers when an exception is encountered - during an :meth:`emit` call. If the module-level attribute - ``raiseExceptions`` is ``False``, exceptions get silently ignored. This is - what is mostly wanted for a logging system - most users will not care about - errors in the logging system, they are more interested in application - errors. You could, however, replace this with a custom handler if you wish. - The specified record is the one which was being processed when the exception - occurred. (The default value of ``raiseExceptions`` is ``True``, as that is - more useful during development). + during an :meth:`emit` call. By default it does nothing, which means that + exceptions get silently ignored. This is what is mostly wanted for a logging + system - most users will not care about errors in the logging system, they are + more interested in application errors. You could, however, replace this with a + custom handler if you wish. The specified record is the one which was being + processed when the exception occurred. .. method:: Handler.format(record) @@ -528,12 +463,12 @@ yes. If deemed appropriate, the record may be modified in-place by this method. -Note that filters attached to handlers are consulted before an event is +Note that filters attached to handlers are consulted whenever an event is emitted by the handler, whereas filters attached to loggers are consulted -whenever an event is logged (using :meth:`debug`, :meth:`info`, -etc.), before sending an event to handlers. This means that events which have -been generated by descendant loggers will not be filtered by a logger's filter -setting, unless the filter has also been applied to those descendant loggers. +whenever an event is logged to the handler (using :meth:`debug`, :meth:`info`, +etc.) This means that events which have been generated by descendant loggers +will not be filtered by a logger's filter setting, unless the filter has also +been applied to those descendant loggers. You don't actually need to subclass ``Filter``: you can pass any instance which has a ``filter`` method with the same semantics. @@ -567,9 +502,7 @@ record. :param name: The name of the logger used to log the event represented by - this LogRecord. Note that this name will always have this - value, even though it may be emitted by a handler attached to - a different (ancestor) logger. + this LogRecord. :param level: The numeric level of the logging event (one of DEBUG, INFO etc.) Note that this is converted to *two* attributes of the LogRecord: ``levelno`` for the numeric value and ``levelname`` for the @@ -682,16 +615,13 @@ .. versionchanged:: 2.5 *funcName* was added. -.. versionchanged:: 2.6 - *processName* was added. - .. _logger-adapter: LoggerAdapter Objects --------------------- :class:`LoggerAdapter` instances are used to conveniently pass contextual -information into logging calls. For a usage example, see the section on +information into logging calls. For a usage example , see the section on :ref:`adding contextual information to your logging output `. .. versionadded:: 2.6 @@ -711,15 +641,16 @@ (possibly modified) versions of the arguments passed in. In addition to the above, :class:`LoggerAdapter` supports the following -methods of :class:`Logger`: :meth:`~Logger.debug`, :meth:`~Logger.info`, -:meth:`~Logger.warning`, :meth:`~Logger.error`, :meth:`~Logger.exception`, -:meth:`~Logger.critical`, :meth:`~Logger.log` and :meth:`~Logger.isEnabledFor`. -These methods have the same signatures as their counterparts in :class:`Logger`, -so you can use the two types of instances interchangeably for these calls. +methods of :class:`Logger`, i.e. :meth:`debug`, :meth:`info`, :meth:`warning`, +:meth:`error`, :meth:`exception`, :meth:`critical`, :meth:`log`, +:meth:`isEnabledFor`, :meth:`getEffectiveLevel`, :meth:`setLevel`, +:meth:`hasHandlers`. These methods have the same signatures as their +counterparts in :class:`Logger`, so you can use the two types of instances +interchangeably. .. versionchanged:: 2.7 - The :meth:`~Logger.isEnabledFor` method was added to :class:`LoggerAdapter`. - This method delegates to the underlying logger. + The :meth:`isEnabledFor` method was added to :class:`LoggerAdapter`. This + method delegates to the underlying logger. Thread Safety @@ -759,8 +690,8 @@ Return either the standard :class:`Logger` class, or the last class passed to :func:`setLoggerClass`. This function may be called from within a new class - definition, to ensure that installing a customized :class:`Logger` class will - not undo customizations already applied by other code. For example:: + definition, to ensure that installing a customised :class:`Logger` class will + not undo customisations already applied by other code. For example:: class MyLogger(logging.getLoggerClass()): # ... override behaviour here @@ -840,7 +771,7 @@ are interpreted as for :func:`debug`. -.. function:: exception(msg[, *args[, **kwargs]]) +.. function:: exception(msg[, *args]) Logs a message with level :const:`ERROR` on the root logger. The arguments are interpreted as for :func:`debug`. Exception info is added to the logging @@ -852,15 +783,14 @@ Logs a message with level *level* on the root logger. The other arguments are interpreted as for :func:`debug`. - .. note:: The above module-level convenience functions, which delegate to the - root logger, call :func:`basicConfig` to ensure that at least one handler - is available. Because of this, they should *not* be used in threads, - in versions of Python earlier than 2.7.1 and 3.2, unless at least one - handler has been added to the root logger *before* the threads are - started. In earlier versions of Python, due to a thread safety shortcoming - in :func:`basicConfig`, this can (under rare circumstances) lead to - handlers being added multiple times to the root logger, which can in turn - lead to multiple messages for the same event. + PLEASE NOTE: The above module-level functions which delegate to the root + logger should *not* be used in threads, in versions of Python earlier than + 2.7.1 and 3.2, unless at least one handler has been added to the root + logger *before* the threads are started. These convenience functions call + :func:`basicConfig` to ensure that at least one handler is available; in + earlier versions of Python, this can (under rare circumstances) lead to + handlers being added multiple times to the root logger, which can in turn + lead to multiple messages for the same event. .. function:: disable(lvl) @@ -870,10 +800,7 @@ effect is to disable all logging calls of severity *lvl* and below, so that if you call it with a value of INFO, then all INFO and DEBUG events would be discarded, whereas those of severity WARNING and above would be processed - according to the logger's effective level. If - ``logging.disable(logging.NOTSET)`` is called, it effectively removes this - overriding level, so that logging output again depends on the effective - levels of individual loggers. + according to the logger's effective level. .. function:: addLevelName(lvl, levelName) @@ -885,8 +812,8 @@ registered using this function, levels should be positive integers and they should increase in increasing order of severity. - .. note:: If you are thinking of defining your own levels, please see the - section on :ref:`custom-levels`. + NOTE: If you are thinking of defining your own levels, please see the section + on :ref:`custom-levels`. .. function:: getLevelName(lvl) @@ -921,17 +848,15 @@ .. versionchanged:: 2.4 Formerly, :func:`basicConfig` did not take any keyword arguments. - .. note:: This function should be called from the main thread before other - threads are started. In versions of Python prior to 2.7.1 and 3.2, if - this function is called from multiple threads, it is possible (in rare - circumstances) that a handler will be added to the root logger more than - once, leading to unexpected results such as messages being duplicated in - the log. + PLEASE NOTE: This function should be called from the main thread + before other threads are started. In versions of Python prior to + 2.7.1 and 3.2, if this function is called from multiple threads, + it is possible (in rare circumstances) that a handler will be added + to the root logger more than once, leading to unexpected results + such as messages being duplicated in the log. The following keyword arguments are supported. - .. tabularcolumns:: |l|L| - +--------------+---------------------------------------------+ | Format | Description | +==============+=============================================+ @@ -988,11 +913,12 @@ If *capture* is ``True``, warnings issued by the :mod:`warnings` module will be redirected to the logging system. Specifically, a warning will be formatted using :func:`warnings.formatwarning` and the resulting string - logged to a logger named ``'py.warnings'`` with a severity of :const:`WARNING`. + logged to a logger named 'py.warnings' with a severity of `WARNING`. If *capture* is ``False``, the redirection of warnings to the logging system will stop, and warnings will be redirected to their original destinations - (i.e. those in effect before ``captureWarnings(True)`` was called). + (i.e. those in effect before `captureWarnings(True)` was called). + .. seealso:: diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/library/mac.rst --- a/Doc/library/mac.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/library/mac.rst Sun Jul 20 10:52:46 2014 -0400 @@ -12,10 +12,7 @@ .. note:: - Most of the OS X APIs that these modules use are deprecated or removed - in recent versions of OS X. Many are not available when Python is - executing in 64-bit mode. These modules have been removed in - Python 3. You should avoid using them in Python 2. + These modules are deprecated and have been removed in Python 3.x. .. toctree:: diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/library/macos.rst --- a/Doc/library/macos.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/library/macos.rst Sun Jul 20 10:52:46 2014 -0400 @@ -41,7 +41,7 @@ This exception is raised on MacOS generated errors, either from functions in this module or from other mac-specific modules like the toolbox interfaces. The - arguments are the integer error code (the :c:data:`OSErr` value) and a textual + arguments are the integer error code (the :cdata:`OSErr` value) and a textual description of the error code. Symbolic names for all known error codes are defined in the standard module :mod:`macerrors`. diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/library/macosa.rst --- a/Doc/library/macosa.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/library/macosa.rst Sun Jul 20 10:52:46 2014 -0400 @@ -9,7 +9,8 @@ Architecture (OSA, also commonly referred to as AppleScript) for Python, allowing you to control scriptable applications from your Python program, and with a fairly pythonic interface. Development on this set of modules has -stopped. +stopped. For more up-to-date implementation of AppleScript support for Python, +see the third-party py-appscript project: . For a description of the various components of AppleScript and OSA, and to get an understanding of the architecture and terminology, you should read Apple's diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/library/macostools.rst --- a/Doc/library/macostools.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/library/macostools.rst Sun Jul 20 10:52:46 2014 -0400 @@ -15,7 +15,7 @@ .. note:: - This module has been removed in Python 3. + This module has been removed in Python 3.0. diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/library/mailbox.rst --- a/Doc/library/mailbox.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/library/mailbox.rst Sun Jul 20 10:52:46 2014 -0400 @@ -11,9 +11,8 @@ This module defines two classes, :class:`Mailbox` and :class:`Message`, for accessing and manipulating on-disk mailboxes and the messages they contain. :class:`Mailbox` offers a dictionary-like mapping from keys to messages. -:class:`Message` extends the :mod:`email.message` module's -:class:`~email.message.Message` class with format-specific state and behavior. -Supported mailbox formats are +:class:`Message` extends the :mod:`email.Message` module's :class:`Message` +class with format-specific state and behavior. Supported mailbox formats are Maildir, mbox, MH, Babyl, and MMDF. @@ -84,7 +83,7 @@ it. Parameter *message* may be a :class:`Message` instance, an - :class:`email.message.Message` instance, a string, or a file-like object + :class:`email.Message.Message` instance, a string, or a file-like object (which should be open in text mode). If *message* is an instance of the appropriate format-specific :class:`Message` subclass (e.g., if it's an :class:`mboxMessage` instance and this is an :class:`mbox` instance), its @@ -111,7 +110,7 @@ :exc:`KeyError` exception if no message already corresponds to *key*. As with :meth:`add`, parameter *message* may be a :class:`Message` - instance, an :class:`email.message.Message` instance, a string, or a + instance, an :class:`email.Message.Message` instance, a string, or a file-like object (which should be open in text mode). If *message* is an instance of the appropriate format-specific :class:`Message` subclass (e.g., if it's an :class:`mboxMessage` instance and this is an @@ -155,7 +154,7 @@ when the :class:`Mailbox` instance was initialized. - .. method:: get(key, default=None) + .. method:: get(key[, default=None]) __getitem__(key) Return a representation of the message corresponding to *key*. If no such @@ -279,7 +278,7 @@ ^^^^^^^^^^^^^^^^ -.. class:: Maildir(dirname, factory=rfc822.Message, create=True) +.. class:: Maildir(dirname[, factory=rfc822.Message[, create=True]]) A subclass of :class:`Mailbox` for mailboxes in Maildir format. Parameter *factory* is a callable object that accepts a file-like message representation @@ -424,7 +423,7 @@ ^^^^^^^^^^^^^ -.. class:: mbox(path, factory=None, create=True) +.. class:: mbox(path[, factory=None[, create=True]]) A subclass of :class:`Mailbox` for mailboxes in mbox format. Parameter *factory* is a callable object that accepts a file-like message representation (which @@ -460,7 +459,7 @@ unlock() Three locking mechanisms are used---dot locking and, if available, the - :c:func:`flock` and :c:func:`lockf` system calls. + :cfunc:`flock` and :cfunc:`lockf` system calls. .. seealso:: @@ -484,7 +483,7 @@ ^^^^^^^^^^^ -.. class:: MH(path, factory=None, create=True) +.. class:: MH(path[, factory=None[, create=True]]) A subclass of :class:`Mailbox` for mailboxes in MH format. Parameter *factory* is a callable object that accepts a file-like message representation (which @@ -574,7 +573,7 @@ unlock() Three locking mechanisms are used---dot locking and, if available, the - :c:func:`flock` and :c:func:`lockf` system calls. For MH mailboxes, locking + :cfunc:`flock` and :cfunc:`lockf` system calls. For MH mailboxes, locking the mailbox means locking the :file:`.mh_sequences` file and, only for the duration of any operations that affect them, locking individual message files. @@ -614,7 +613,7 @@ ^^^^^^^^^^^^^^ -.. class:: Babyl(path, factory=None, create=True) +.. class:: Babyl(path[, factory=None[, create=True]]) A subclass of :class:`Mailbox` for mailboxes in Babyl format. Parameter *factory* is a callable object that accepts a file-like message representation @@ -661,7 +660,7 @@ In Babyl mailboxes, the headers of a message are not stored contiguously with the body of the message. To generate a file-like representation, the - headers and body are copied together into a :class:`~StringIO.StringIO` instance + headers and body are copied together into a :class:`StringIO` instance (from the :mod:`StringIO` module), which has an API identical to that of a file. As a result, the file-like object is truly independent of the underlying mailbox but does not save memory compared to a string @@ -672,7 +671,7 @@ unlock() Three locking mechanisms are used---dot locking and, if available, the - :c:func:`flock` and :c:func:`lockf` system calls. + :cfunc:`flock` and :cfunc:`lockf` system calls. .. seealso:: @@ -690,7 +689,7 @@ ^^^^^^^^^^^^^ -.. class:: MMDF(path, factory=None, create=True) +.. class:: MMDF(path[, factory=None[, create=True]]) A subclass of :class:`Mailbox` for mailboxes in MMDF format. Parameter *factory* is a callable object that accepts a file-like message representation (which @@ -723,7 +722,7 @@ unlock() Three locking mechanisms are used---dot locking and, if available, the - :c:func:`flock` and :c:func:`lockf` system calls. + :cfunc:`flock` and :cfunc:`lockf` system calls. .. seealso:: @@ -744,12 +743,11 @@ .. class:: Message([message]) - A subclass of the :mod:`email.message` module's - :class:`~email.message.Message`. Subclasses of :class:`mailbox.Message` add - mailbox-format-specific state and behavior. + A subclass of the :mod:`email.Message` module's :class:`Message`. Subclasses of + :class:`mailbox.Message` add mailbox-format-specific state and behavior. If *message* is omitted, the new instance is created in a default, empty state. - If *message* is an :class:`email.message.Message` instance, its contents are + If *message* is an :class:`email.Message.Message` instance, its contents are copied; furthermore, any format-specific information is converted insofar as possible if *message* is a :class:`Message` instance. If *message* is a string or a file, it should contain an :rfc:`2822`\ -compliant message, which is read @@ -989,12 +987,12 @@ are excluded. - .. method:: set_from(from_, time_=None) + .. method:: set_from(from_[, time_=None]) Set the "From " line to *from_*, which should be specified without a leading "From " or trailing newline. For convenience, *time_* may be specified and will be formatted appropriately and appended to *from_*. If - *time_* is specified, it should be a :class:`time.struct_time` instance, a + *time_* is specified, it should be a :class:`struct_time` instance, a tuple suitable for passing to :meth:`time.strftime`, or ``True`` (to use :meth:`time.gmtime`). @@ -1253,7 +1251,7 @@ Set the message's visible headers to be the same as the headers in *message*. Parameter *visible* should be a :class:`Message` instance, an - :class:`email.message.Message` instance, a string, or a file-like object + :class:`email.Message.Message` instance, a string, or a file-like object (which should be open in text mode). @@ -1360,12 +1358,12 @@ are excluded. - .. method:: set_from(from_, time_=None) + .. method:: set_from(from_[, time_=None]) Set the "From " line to *from_*, which should be specified without a leading "From " or trailing newline. For convenience, *time_* may be specified and will be formatted appropriately and appended to *from_*. If - *time_* is specified, it should be a :class:`time.struct_time` instance, a + *time_* is specified, it should be a :class:`struct_time` instance, a tuple suitable for passing to :meth:`time.strftime`, or ``True`` (to use :meth:`time.gmtime`). @@ -1515,7 +1513,7 @@ mailboxes, such as adding or removing message, and do not provide classes to represent format-specific message properties. For backward compatibility, the older mailbox classes are still available, but the newer classes should be used -in preference to them. The old classes have been removed in Python 3. +in preference to them. The old classes will be removed in Python 3.0. Older mailbox objects support only iteration and provide a single public method: @@ -1664,7 +1662,7 @@ due to malformed messages in the mailbox:: import mailbox - import email.errors + import email.Errors list_names = ('python-list', 'python-dev', 'python-bugs') @@ -1674,7 +1672,7 @@ for key in inbox.iterkeys(): try: message = inbox[key] - except email.errors.MessageParseError: + except email.Errors.MessageParseError: continue # The message is malformed. Just leave it. for name in list_names: diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/library/mailcap.rst --- a/Doc/library/mailcap.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/library/mailcap.rst Sun Jul 20 10:52:46 2014 -0400 @@ -71,6 +71,6 @@ >>> import mailcap >>> d=mailcap.getcaps() - >>> mailcap.findmatch(d, 'video/mpeg', filename='tmp1223') - ('xmpeg tmp1223', {'view': 'xmpeg %s'}) + >>> mailcap.findmatch(d, 'video/mpeg', filename='/tmp/tmp1223') + ('xmpeg /tmp/tmp1223', {'view': 'xmpeg %s'}) diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/library/markup.rst --- a/Doc/library/markup.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/library/markup.rst Sun Jul 20 10:52:46 2014 -0400 @@ -1,3 +1,4 @@ + .. _markup: ********************************** @@ -25,8 +26,7 @@ htmlparser.rst sgmllib.rst htmllib.rst - xml.rst - xml.etree.elementtree.rst + pyexpat.rst xml.dom.rst xml.dom.minidom.rst xml.dom.pulldom.rst @@ -34,4 +34,4 @@ xml.sax.handler.rst xml.sax.utils.rst xml.sax.reader.rst - pyexpat.rst + xml.etree.elementtree.rst diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/library/marshal.rst --- a/Doc/library/marshal.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/library/marshal.rst Sun Jul 20 10:52:46 2014 -0400 @@ -66,9 +66,8 @@ .. function:: dump(value, file[, version]) Write the value on the open file. The value must be a supported type. The - file must be a open file object such as ``sys.stdout`` or returned by - :func:`open` or :func:`os.popen`. It may not be a wrapper such as - TemporaryFile on Windows. It must be opened in binary mode (``'wb'`` + file must be an open file object such as ``sys.stdout`` or returned by + :func:`open` or :func:`os.popen`. It must be opened in binary mode (``'wb'`` or ``'w+b'``). If the value has (or contains an object that has) an unsupported type, a diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/library/math.rst --- a/Doc/library/math.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/library/math.rst Sun Jul 20 10:52:46 2014 -0400 @@ -5,9 +5,6 @@ .. module:: math :synopsis: Mathematical functions (sin() etc.). -.. testsetup:: - - from math import fsum This module is always available. It provides access to the mathematical functions defined by the C standard. @@ -136,9 +133,8 @@ .. function:: trunc(x) - Return the :class:`~numbers.Real` value *x* truncated to an - :class:`~numbers.Integral` (usually a long integer). Uses the - ``__trunc__`` method. + Return the :class:`Real` value *x* truncated to an :class:`Integral` (usually + a long integer). Uses the ``__trunc__`` method. .. versionadded:: 2.6 @@ -213,10 +209,6 @@ ``x`` is negative, and ``y`` is not an integer then ``pow(x, y)`` is undefined, and raises :exc:`ValueError`. - Unlike the built-in ``**`` operator, :func:`math.pow` converts both - its arguments to type :class:`float`. Use ``**`` or the built-in - :func:`pow` function for computing exact integer powers. - .. versionchanged:: 2.6 The outcome of ``1**nan`` and ``nan**0`` was undefined. diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/library/mhlib.rst --- a/Doc/library/mhlib.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/library/mhlib.rst Sun Jul 20 10:52:46 2014 -0400 @@ -6,7 +6,7 @@ :deprecated: .. deprecated:: 2.6 - The :mod:`mhlib` module has been removed in Python 3. Use the + The :mod:`mhlib` module has been removed in Python 3.0. Use the :mod:`mailbox` instead. .. sectionauthor:: Skip Montanaro diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/library/mimetypes.rst --- a/Doc/library/mimetypes.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/library/mimetypes.rst Sun Jul 20 10:52:46 2014 -0400 @@ -1,3 +1,4 @@ + :mod:`mimetypes` --- Map filenames to MIME types ================================================ @@ -26,31 +27,31 @@ the information :func:`init` sets up. -.. function:: guess_type(url, strict=True) +.. function:: guess_type(filename[, strict]) .. index:: pair: MIME; headers - Guess the type of a file based on its filename or URL, given by *url*. The + Guess the type of a file based on its filename or URL, given by *filename*. The return value is a tuple ``(type, encoding)`` where *type* is ``None`` if the type can't be guessed (missing or unknown suffix) or a string of the form ``'type/subtype'``, usable for a MIME :mailheader:`content-type` header. *encoding* is ``None`` for no encoding or the name of the program used to encode (e.g. :program:`compress` or :program:`gzip`). The encoding is suitable for use - as a :mailheader:`Content-Encoding` header, **not** as a + as a :mailheader:`Content-Encoding` header, *not* as a :mailheader:`Content-Transfer-Encoding` header. The mappings are table driven. Encoding suffixes are case sensitive; type suffixes are first tried case sensitively, then case insensitively. - The optional *strict* argument is a flag specifying whether the list of known MIME types + Optional *strict* is a flag specifying whether the list of known MIME types is limited to only the official types `registered with IANA - `_. - When *strict* is ``True`` (the default), only the IANA types are supported; when - *strict* is ``False``, some additional non-standard but commonly used MIME types + `_ are recognized. + When *strict* is true (the default), only the IANA types are supported; when + *strict* is false, some additional non-standard but commonly used MIME types are also recognized. -.. function:: guess_all_extensions(type, strict=True) +.. function:: guess_all_extensions(type[, strict]) Guess the extensions for a file based on its MIME type, given by *type*. The return value is a list of strings giving all possible filename extensions, @@ -58,25 +59,25 @@ been associated with any particular data stream, but would be mapped to the MIME type *type* by :func:`guess_type`. - The optional *strict* argument has the same meaning as with the :func:`guess_type` function. + Optional *strict* has the same meaning as with the :func:`guess_type` function. -.. function:: guess_extension(type, strict=True) +.. function:: guess_extension(type[, strict]) Guess the extension for a file based on its MIME type, given by *type*. The return value is a string giving a filename extension, including the leading dot (``'.'``). The extension is not guaranteed to have been associated with any - particular data stream, but would be mapped to the MIME type *type* by + particular data stream, but would be mapped to the MIME type *type* by :func:`guess_type`. If no extension can be guessed for *type*, ``None`` is returned. - The optional *strict* argument has the same meaning as with the :func:`guess_type` function. + Optional *strict* has the same meaning as with the :func:`guess_type` function. Some additional functions and data items are available for controlling the behavior of the module. -.. function:: init(files=None) +.. function:: init([files]) Initialize the internal data structures. If given, *files* must be a sequence of file names which should be used to augment the default type map. If omitted, @@ -85,35 +86,32 @@ :const:`knownfiles` takes precedence over those named before it. Calling :func:`init` repeatedly is allowed. - Specifying an empty list for *files* will prevent the system defaults from - being applied: only the well-known values will be present from a built-in list. - .. versionchanged:: 2.7 Previously, Windows registry settings were ignored. .. function:: read_mime_types(filename) - Load the type map given in the file *filename*, if it exists. The type map is + Load the type map given in the file *filename*, if it exists. The type map is returned as a dictionary mapping filename extensions, including the leading dot (``'.'``), to strings of the form ``'type/subtype'``. If the file *filename* does not exist or cannot be read, ``None`` is returned. -.. function:: add_type(type, ext, strict=True) +.. function:: add_type(type, ext[, strict]) - Add a mapping from the MIME type *type* to the extension *ext*. When the + Add a mapping from the mimetype *type* to the extension *ext*. When the extension is already known, the new type will replace the old one. When the type is already known the extension will be added to the list of known extensions. - When *strict* is ``True`` (the default), the mapping will added to the official MIME + When *strict* is True (the default), the mapping will added to the official MIME types, otherwise to the non-standard ones. .. data:: inited Flag indicating whether or not the global data structures have been initialized. - This is set to ``True`` by :func:`init`. + This is set to true by :func:`init`. .. data:: knownfiles @@ -148,6 +146,23 @@ Dictionary mapping filename extensions to non-standard, but commonly found MIME types. +The :class:`MimeTypes` class may be useful for applications which may want more +than one MIME-type database: + + +.. class:: MimeTypes([filenames]) + + This class represents a MIME-types database. By default, it provides access to + the same database as the rest of this module. The initial database is a copy of + that provided by the module, and may be extended by loading additional + :file:`mime.types`\ -style files into the database using the :meth:`read` or + :meth:`readfp` methods. The mapping dictionaries may also be cleared before + loading additional data if the default data is not desired. + + The optional *filenames* parameter can be used to cause additional files to be + loaded "on top" of the default database. + + .. versionadded:: 2.2 An example usage of the module:: @@ -168,96 +183,70 @@ MimeTypes Objects ----------------- -The :class:`MimeTypes` class may be useful for applications which may want more -than one MIME-type database; it provides an interface similar to the one of the +:class:`MimeTypes` instances provide an interface which is very like that of the :mod:`mimetypes` module. -.. class:: MimeTypes(filenames=(), strict=True) - - This class represents a MIME-types database. By default, it provides access to - the same database as the rest of this module. The initial database is a copy of - that provided by the module, and may be extended by loading additional - :file:`mime.types`\ -style files into the database using the :meth:`read` or - :meth:`readfp` methods. The mapping dictionaries may also be cleared before - loading additional data if the default data is not desired. - - The optional *filenames* parameter can be used to cause additional files to be - loaded "on top" of the default database. - - .. attribute:: MimeTypes.suffix_map Dictionary mapping suffixes to suffixes. This is used to allow recognition of encoded files for which the encoding and the type are indicated by the same extension. For example, the :file:`.tgz` extension is mapped to :file:`.tar.gz` to allow the encoding and type to be recognized separately. This is initially a - copy of the global :data:`suffix_map` defined in the module. + copy of the global ``suffix_map`` defined in the module. .. attribute:: MimeTypes.encodings_map Dictionary mapping filename extensions to encoding types. This is initially a - copy of the global :data:`encodings_map` defined in the module. + copy of the global ``encodings_map`` defined in the module. .. attribute:: MimeTypes.types_map - Tuple containing two dictionaries, mapping filename extensions to MIME types: - the first dictionary is for the non-standards types and the second one is for - the standard types. They are initialized by :data:`common_types` and - :data:`types_map`. + Dictionary mapping filename extensions to MIME types. This is initially a copy + of the global ``types_map`` defined in the module. -.. attribute:: MimeTypes.types_map_inv +.. attribute:: MimeTypes.common_types - Tuple containing two dictionaries, mapping MIME types to a list of filename - extensions: the first dictionary is for the non-standards types and the - second one is for the standard types. They are initialized by - :data:`common_types` and :data:`types_map`. + Dictionary mapping filename extensions to non-standard, but commonly found MIME + types. This is initially a copy of the global ``common_types`` defined in the + module. -.. method:: MimeTypes.guess_extension(type, strict=True) +.. method:: MimeTypes.guess_extension(type[, strict]) Similar to the :func:`guess_extension` function, using the tables stored as part of the object. -.. method:: MimeTypes.guess_type(url, strict=True) +.. method:: MimeTypes.guess_all_extensions(type[, strict]) + + Similar to the :func:`guess_all_extensions` function, using the tables stored as part + of the object. + + +.. method:: MimeTypes.guess_type(url[, strict]) Similar to the :func:`guess_type` function, using the tables stored as part of the object. -.. method:: MimeTypes.guess_all_extensions(type, strict=True) +.. method:: MimeTypes.read(path) - Similar to the :func:`guess_all_extensions` function, using the tables stored - as part of the object. - - -.. method:: MimeTypes.read(filename, strict=True) - - Load MIME information from a file named *filename*. This uses :meth:`readfp` to + Load MIME information from a file named *path*. This uses :meth:`readfp` to parse the file. - If *strict* is ``True``, information will be added to list of standard types, - else to the list of non-standard types. +.. method:: MimeTypes.readfp(file) -.. method:: MimeTypes.readfp(fp, strict=True) - - Load MIME type information from an open file *fp*. The file must have the format of + Load MIME type information from an open file. The file must have the format of the standard :file:`mime.types` files. - If *strict* is ``True``, information will be added to the list of standard - types, else to the list of non-standard types. - -.. method:: MimeTypes.read_windows_registry(strict=True) +.. method:: MimeTypes.read_windows_registry() Load MIME type information from the Windows registry. Availability: Windows. - If *strict* is ``True``, information will be added to the list of standard - types, else to the list of non-standard types. - .. versionadded:: 2.7 diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/library/mimewriter.rst --- a/Doc/library/mimewriter.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/library/mimewriter.rst Sun Jul 20 10:52:46 2014 -0400 @@ -24,7 +24,7 @@ Return a new instance of the :class:`MimeWriter` class. The only argument passed, *fp*, is a file object to be used for writing. Note that a - :class:`~StringIO.StringIO` object could also be used. + :class:`StringIO` object could also be used. .. _mimewriter-objects: diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/library/mmap.rst --- a/Doc/library/mmap.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/library/mmap.rst Sun Jul 20 10:52:46 2014 -0400 @@ -114,19 +114,19 @@ with open("hello.txt", "r+b") as f: # memory-map the file, size 0 means whole file - mm = mmap.mmap(f.fileno(), 0) + map = mmap.mmap(f.fileno(), 0) # read content via standard file methods - print mm.readline() # prints "Hello Python!" + print map.readline() # prints "Hello Python!" # read content via slice notation - print mm[:5] # prints "Hello" + print map[:5] # prints "Hello" # update content using slice notation; # note that new content must have same size - mm[6:] = " world!\n" + map[6:] = " world!\n" # ... and read again using standard file methods - mm.seek(0) - print mm.readline() # prints "Hello world!" + map.seek(0) + print map.readline() # prints "Hello world!" # close the map - mm.close() + map.close() The next example demonstrates how to create an anonymous map and exchange @@ -135,16 +135,16 @@ import mmap import os - mm = mmap.mmap(-1, 13) - mm.write("Hello world!") + map = mmap.mmap(-1, 13) + map.write("Hello world!") pid = os.fork() if pid == 0: # In a child process - mm.seek(0) - print mm.readline() + map.seek(0) + print map.readline() - mm.close() + map.close() Memory-mapped file objects support the following methods: @@ -152,9 +152,8 @@ .. method:: close() - Closes the mmap. Subsequent calls to other methods of the object will - result in a ValueError exception being raised. This will not close - the open file. + Close the file. Subsequent calls to other methods of the object will + result in an exception being raised. .. method:: find(string[, start[, end]]) diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/library/msilib.rst --- a/Doc/library/msilib.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/library/msilib.rst Sun Jul 20 10:52:46 2014 -0400 @@ -44,7 +44,7 @@ .. function:: UuidCreate() Return the string representation of a new unique identifier. This wraps the - Windows API functions :c:func:`UuidCreate` and :c:func:`UuidToString`. + Windows API functions :cfunc:`UuidCreate` and :cfunc:`UuidToString`. .. function:: OpenDatabase(path, persist) @@ -60,7 +60,7 @@ .. function:: CreateRecord(count) - Return a new record object by calling :c:func:`MSICreateRecord`. *count* is the + Return a new record object by calling :cfunc:`MSICreateRecord`. *count* is the number of fields of the record. @@ -135,20 +135,20 @@ .. method:: Database.OpenView(sql) - Return a view object, by calling :c:func:`MSIDatabaseOpenView`. *sql* is the SQL + Return a view object, by calling :cfunc:`MSIDatabaseOpenView`. *sql* is the SQL statement to execute. .. method:: Database.Commit() Commit the changes pending in the current transaction, by calling - :c:func:`MSIDatabaseCommit`. + :cfunc:`MSIDatabaseCommit`. .. method:: Database.GetSummaryInformation(count) Return a new summary information object, by calling - :c:func:`MsiGetSummaryInformation`. *count* is the maximum number of updated + :cfunc:`MsiGetSummaryInformation`. *count* is the maximum number of updated values. @@ -166,7 +166,7 @@ .. method:: View.Execute(params) - Execute the SQL query of the view, through :c:func:`MSIViewExecute`. If + Execute the SQL query of the view, through :cfunc:`MSIViewExecute`. If *params* is not ``None``, it is a record describing actual values of the parameter tokens in the query. @@ -174,18 +174,18 @@ .. method:: View.GetColumnInfo(kind) Return a record describing the columns of the view, through calling - :c:func:`MsiViewGetColumnInfo`. *kind* can be either ``MSICOLINFO_NAMES`` or + :cfunc:`MsiViewGetColumnInfo`. *kind* can be either ``MSICOLINFO_NAMES`` or ``MSICOLINFO_TYPES``. .. method:: View.Fetch() - Return a result record of the query, through calling :c:func:`MsiViewFetch`. + Return a result record of the query, through calling :cfunc:`MsiViewFetch`. .. method:: View.Modify(kind, data) - Modify the view, by calling :c:func:`MsiViewModify`. *kind* can be one of + Modify the view, by calling :cfunc:`MsiViewModify`. *kind* can be one of ``MSIMODIFY_SEEK``, ``MSIMODIFY_REFRESH``, ``MSIMODIFY_INSERT``, ``MSIMODIFY_UPDATE``, ``MSIMODIFY_ASSIGN``, ``MSIMODIFY_REPLACE``, ``MSIMODIFY_MERGE``, ``MSIMODIFY_DELETE``, ``MSIMODIFY_INSERT_TEMPORARY``, @@ -197,7 +197,7 @@ .. method:: View.Close() - Close the view, through :c:func:`MsiViewClose`. + Close the view, through :cfunc:`MsiViewClose`. .. seealso:: @@ -216,7 +216,7 @@ .. method:: SummaryInformation.GetProperty(field) - Return a property of the summary, through :c:func:`MsiSummaryInfoGetProperty`. + Return a property of the summary, through :cfunc:`MsiSummaryInfoGetProperty`. *field* is the name of the property, and can be one of the constants ``PID_CODEPAGE``, ``PID_TITLE``, ``PID_SUBJECT``, ``PID_AUTHOR``, ``PID_KEYWORDS``, ``PID_COMMENTS``, ``PID_TEMPLATE``, ``PID_LASTAUTHOR``, @@ -228,12 +228,12 @@ .. method:: SummaryInformation.GetPropertyCount() Return the number of summary properties, through - :c:func:`MsiSummaryInfoGetPropertyCount`. + :cfunc:`MsiSummaryInfoGetPropertyCount`. .. method:: SummaryInformation.SetProperty(field, value) - Set a property through :c:func:`MsiSummaryInfoSetProperty`. *field* can have the + Set a property through :cfunc:`MsiSummaryInfoSetProperty`. *field* can have the same values as in :meth:`GetProperty`, *value* is the new value of the property. Possible value types are integer and string. @@ -241,7 +241,7 @@ .. method:: SummaryInformation.Persist() Write the modified properties to the summary information stream, using - :c:func:`MsiSummaryInfoPersist`. + :cfunc:`MsiSummaryInfoPersist`. .. seealso:: @@ -260,7 +260,7 @@ .. method:: Record.GetFieldCount() Return the number of fields of the record, through - :c:func:`MsiRecordGetFieldCount`. + :cfunc:`MsiRecordGetFieldCount`. .. method:: Record.GetInteger(field) @@ -277,25 +277,25 @@ .. method:: Record.SetString(field, value) - Set *field* to *value* through :c:func:`MsiRecordSetString`. *field* must be an + Set *field* to *value* through :cfunc:`MsiRecordSetString`. *field* must be an integer; *value* a string. .. method:: Record.SetStream(field, value) Set *field* to the contents of the file named *value*, through - :c:func:`MsiRecordSetStream`. *field* must be an integer; *value* a string. + :cfunc:`MsiRecordSetStream`. *field* must be an integer; *value* a string. .. method:: Record.SetInteger(field, value) - Set *field* to *value* through :c:func:`MsiRecordSetInteger`. Both *field* and + Set *field* to *value* through :cfunc:`MsiRecordSetInteger`. Both *field* and *value* must be an integer. .. method:: Record.ClearData() - Set all fields of the record to 0, through :c:func:`MsiRecordClearData`. + Set all fields of the record to 0, through :cfunc:`MsiRecordClearData`. .. seealso:: @@ -432,9 +432,8 @@ ----------- :mod:`msilib` provides several classes that wrap the GUI tables in an MSI -database. However, no standard user interface is provided; use -:mod:`~distutils.command.bdist_msi` to create MSI files with a user-interface -for installing Python packages. +database. However, no standard user interface is provided; use :mod:`bdist_msi` +to create MSI files with a user-interface for installing Python packages. .. class:: Control(dlg, name) diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/library/msvcrt.rst --- a/Doc/library/msvcrt.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/library/msvcrt.rst Sun Jul 20 10:52:46 2014 -0400 @@ -152,5 +152,5 @@ .. function:: heapmin() - Force the :c:func:`malloc` heap to clean itself up and return unused blocks to + Force the :cfunc:`malloc` heap to clean itself up and return unused blocks to the operating system. On failure, this raises :exc:`IOError`. diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/library/multiprocessing.rst --- a/Doc/library/multiprocessing.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/library/multiprocessing.rst Sun Jul 20 10:52:46 2014 -0400 @@ -81,8 +81,7 @@ def info(title): print title print 'module name:', __name__ - if hasattr(os, 'getppid'): # only available on Unix - print 'parent process:', os.getppid() + print 'parent process:', os.getppid() print 'process id:', os.getpid() def f(name): @@ -108,7 +107,7 @@ **Queues** - The :class:`~multiprocessing.Queue` class is a near clone of :class:`Queue.Queue`. For + The :class:`Queue` class is a near clone of :class:`Queue.Queue`. For example:: from multiprocessing import Process, Queue @@ -232,7 +231,7 @@ A manager returned by :func:`Manager` will support types :class:`list`, :class:`dict`, :class:`Namespace`, :class:`Lock`, :class:`RLock`, :class:`Semaphore`, :class:`BoundedSemaphore`, :class:`Condition`, - :class:`Event`, :class:`~multiprocessing.Queue`, :class:`Value` and :class:`Array`. For + :class:`Event`, :class:`Queue`, :class:`Value` and :class:`Array`. For example, :: from multiprocessing import Process, Manager @@ -283,13 +282,10 @@ if __name__ == '__main__': pool = Pool(processes=4) # start 4 worker processes - result = pool.apply_async(f, [10]) # evaluate "f(10)" asynchronously + result = pool.apply_async(f, [10]) # evaluate "f(10)" asynchronously print result.get(timeout=1) # prints "100" unless your computer is *very* slow print pool.map(f, range(10)) # prints "[0, 1, 4,..., 81]" -Note that the methods of a pool should only ever be used by the -process which created it. - Reference --------- @@ -301,7 +297,7 @@ :class:`Process` and exceptions ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -.. class:: Process(group=None, target=None, name=None, args=(), kwargs={}) +.. class:: Process([group[, target[, name[, args[, kwargs]]]]]) Process objects represent activity that is run in a separate process. The :class:`Process` class has equivalents of all the methods of @@ -382,7 +378,7 @@ Unix daemons or services, they are normal processes that will be terminated (and not joined) if non-daemonic processes have exited. - In addition to the :class:`threading.Thread` API, :class:`Process` objects + In addition to the :class:`Threading.Thread` API, :class:`Process` objects also support the following attributes and methods: .. attribute:: pid @@ -401,7 +397,7 @@ The process's authentication key (a byte string). When :mod:`multiprocessing` is initialized the main process is assigned a - random string using :func:`os.urandom`. + random string using :func:`os.random`. When a :class:`Process` object is created, it will inherit the authentication key of its parent process, although this may be changed by @@ -412,7 +408,7 @@ .. method:: terminate() Terminate the process. On Unix this is done using the ``SIGTERM`` signal; - on Windows :c:func:`TerminateProcess` is used. Note that exit handlers and + on Windows :cfunc:`TerminateProcess` is used. Note that exit handlers and finally clauses, etc., will not be executed. Note that descendant processes of the process will *not* be terminated -- @@ -426,9 +422,9 @@ acquired a lock or semaphore etc. then terminating it is liable to cause other processes to deadlock. - Note that the :meth:`start`, :meth:`join`, :meth:`is_alive`, - :meth:`terminate` and :attr:`exitcode` methods should only be called by - the process that created the process object. + Note that the :meth:`start`, :meth:`join`, :meth:`is_alive` and + :attr:`exit_code` methods should only be called by the process that created + the process object. Example usage of some of the methods of :class:`Process`: @@ -468,15 +464,15 @@ For passing messages one can use :func:`Pipe` (for a connection between two processes) or a queue (which allows multiple producers and consumers). -The :class:`~multiprocessing.Queue`, :class:`multiprocessing.queues.SimpleQueue` and :class:`JoinableQueue` types are multi-producer, +The :class:`Queue` and :class:`JoinableQueue` types are multi-producer, multi-consumer FIFO queues modelled on the :class:`Queue.Queue` class in the -standard library. They differ in that :class:`~multiprocessing.Queue` lacks the +standard library. They differ in that :class:`Queue` lacks the :meth:`~Queue.Queue.task_done` and :meth:`~Queue.Queue.join` methods introduced into Python 2.5's :class:`Queue.Queue` class. If you use :class:`JoinableQueue` then you **must** call :meth:`JoinableQueue.task_done` for each task removed from the queue or else the -semaphore used to count the number of unfinished tasks may eventually overflow, +semaphore used to count the number of unfinished tasks may eventually overflow raising an exception. Note that one can also create a shared queue by using a manager object -- see @@ -489,37 +485,18 @@ the :mod:`multiprocessing` namespace so you need to import them from :mod:`Queue`. -.. note:: - - When an object is put on a queue, the object is pickled and a - background thread later flushes the pickled data to an underlying - pipe. This has some consequences which are a little surprising, - but should not cause any practical difficulties -- if they really - bother you then you can instead use a queue created with a - :ref:`manager `. - - (1) After putting an object on an empty queue there may be an - infinitesimal delay before the queue's :meth:`~Queue.empty` - method returns :const:`False` and :meth:`~Queue.get_nowait` can - return without raising :exc:`Queue.Empty`. - - (2) If multiple processes are enqueuing objects, it is possible for - the objects to be received at the other end out-of-order. - However, objects enqueued by the same process will always be in - the expected order with respect to each other. .. warning:: If a process is killed using :meth:`Process.terminate` or :func:`os.kill` - while it is trying to use a :class:`~multiprocessing.Queue`, then the data in the queue is - likely to become corrupted. This may cause any other process to get an + while it is trying to use a :class:`Queue`, then the data in the queue is + likely to become corrupted. This may cause any other processes to get an exception when it tries to use the queue later on. .. warning:: As mentioned above, if a child process has put items on a queue (and it has - not used :meth:`JoinableQueue.cancel_join_thread - `), then that process will + not used :meth:`JoinableQueue.cancel_join_thread`), then that process will not terminate until all buffered items have been flushed to the pipe. This means that if you try joining that process you may get a deadlock unless @@ -554,7 +531,7 @@ The usual :exc:`Queue.Empty` and :exc:`Queue.Full` exceptions from the standard library's :mod:`Queue` module are raised to signal timeouts. - :class:`~multiprocessing.Queue` implements all the methods of :class:`Queue.Queue` except for + :class:`Queue` implements all the methods of :class:`Queue.Queue` except for :meth:`~Queue.Queue.task_done` and :meth:`~Queue.Queue.join`. .. method:: qsize() @@ -601,10 +578,11 @@ :exc:`Queue.Empty` exception (*timeout* is ignored in that case). .. method:: get_nowait() + get_no_wait() Equivalent to ``get(False)``. - :class:`~multiprocessing.Queue` has a few additional methods not found in + :class:`multiprocessing.Queue` has a few additional methods not found in :class:`Queue.Queue`. These methods are usually unnecessary for most code: @@ -631,34 +609,10 @@ the background thread from being joined automatically when the process exits -- see :meth:`join_thread`. - A better name for this method might be - ``allow_exit_without_flush()``. It is likely to cause enqueued - data to lost, and you almost certainly will not need to use it. - It is really only there if you need the current process to exit - immediately without waiting to flush enqueued data to the - underlying pipe, and you don't care about lost data. - - -.. class:: multiprocessing.queues.SimpleQueue() - - It is a simplified :class:`~multiprocessing.Queue` type, very close to a locked :class:`Pipe`. - - .. method:: empty() - - Return ``True`` if the queue is empty, ``False`` otherwise. - - .. method:: get() - - Remove and return an item from the queue. - - .. method:: put(item) - - Put *item* into the queue. - .. class:: JoinableQueue([maxsize]) - :class:`JoinableQueue`, a :class:`~multiprocessing.Queue` subclass, is a queue which + :class:`JoinableQueue`, a :class:`Queue` subclass, is a queue which additionally has :meth:`task_done` and :meth:`join` methods. .. method:: task_done() @@ -668,7 +622,7 @@ call to :meth:`task_done` tells the queue that the processing on the task is complete. - If a :meth:`~Queue.Queue.join` is currently blocking, it will resume when all + If a :meth:`~Queue.join` is currently blocking, it will resume when all items have been processed (meaning that a :meth:`task_done` call was received for every item that had been :meth:`~Queue.put` into the queue). @@ -684,7 +638,7 @@ queue. The count goes down whenever a consumer thread calls :meth:`task_done` to indicate that the item was retrieved and all work on it is complete. When the count of unfinished tasks drops to zero, - :meth:`~Queue.Queue.join` unblocks. + :meth:`~Queue.join` unblocks. Miscellaneous @@ -738,7 +692,7 @@ (By default :data:`sys.executable` is used). Embedders will probably need to do some thing like :: - set_executable(os.path.join(sys.exec_prefix, 'pythonw.exe')) + setExecutable(os.path.join(sys.exec_prefix, 'pythonw.exe')) before they can create child processes. (Windows only) @@ -757,7 +711,7 @@ Connection objects allow the sending and receiving of picklable objects or strings. They can be thought of as message oriented connected sockets. -Connection objects are usually created using :func:`Pipe` -- see also +Connection objects usually created using :func:`Pipe` -- see also :ref:`multiprocessing-listeners-clients`. .. class:: Connection @@ -768,18 +722,17 @@ using :meth:`recv`. The object must be picklable. Very large pickles (approximately 32 MB+, - though it depends on the OS) may raise a :exc:`ValueError` exception. + though it depends on the OS) may raise a ValueError exception. .. method:: recv() Return an object sent from the other end of the connection using - :meth:`send`. Blocks until there its something to receive. Raises - :exc:`EOFError` if there is nothing left to receive + :meth:`send`. Raises :exc:`EOFError` if there is nothing left to receive and the other end was closed. .. method:: fileno() - Return the file descriptor or handle used by the connection. + Returns the file descriptor or handle used by the connection. .. method:: close() @@ -803,13 +756,12 @@ If *offset* is given then data is read from that position in *buffer*. If *size* is given then that many bytes will be read from buffer. Very large buffers (approximately 32 MB+, though it depends on the OS) may raise a - :exc:`ValueError` exception + ValueError exception .. method:: recv_bytes([maxlength]) Return a complete message of byte data sent from the other end of the - connection as a string. Blocks until there is something to receive. - Raises :exc:`EOFError` if there is nothing left + connection as a string. Raises :exc:`EOFError` if there is nothing left to receive and the other end has closed. If *maxlength* is specified and the message is longer than *maxlength* @@ -819,8 +771,7 @@ .. method:: recv_bytes_into(buffer[, offset]) Read into *buffer* a complete message of byte data sent from the other end - of the connection and return the number of bytes in the message. Blocks - until there is something to receive. Raises + of the connection and return the number of bytes in the message. Raises :exc:`EOFError` if there is nothing left to receive and the other end was closed. @@ -960,24 +911,12 @@ ctypes type or a one character typecode of the kind used by the :mod:`array` module. *\*args* is passed on to the constructor for the type. - If *lock* is ``True`` (the default) then a new recursive lock - object is created to synchronize access to the value. If *lock* is - a :class:`Lock` or :class:`RLock` object then that will be used to - synchronize access to the value. If *lock* is ``False`` then - access to the returned object will not be automatically protected - by a lock, so it will not necessarily be "process-safe". - - Operations like ``+=`` which involve a read and write are not - atomic. So if, for instance, you want to atomically increment a - shared value it is insufficient to just do :: - - counter.value += 1 - - Assuming the associated lock is recursive (which it is by default) - you can instead do :: - - with counter.get_lock(): - counter.value += 1 + If *lock* is ``True`` (the default) then a new lock object is created to + synchronize access to the value. If *lock* is a :class:`Lock` or + :class:`RLock` object then that will be used to synchronize access to the + value. If *lock* is ``False`` then access to the returned object will not be + automatically protected by a lock, so it will not necessarily be + "process-safe". Note that *lock* is a keyword-only argument. @@ -1062,9 +1001,8 @@ array. If *lock* is ``True`` (the default) then a new lock object is created to - synchronize access to the value. If *lock* is a - :class:`~multiprocessing.Lock` or :class:`~multiprocessing.RLock` object - then that will be used to synchronize access to the + synchronize access to the value. If *lock* is a :class:`Lock` or + :class:`RLock` object then that will be used to synchronize access to the value. If *lock* is ``False`` then access to the returned object will not be automatically protected by a lock, so it will not necessarily be "process-safe". @@ -1078,8 +1016,8 @@ object. If *lock* is ``True`` (the default) then a new lock object is created to - synchronize access to the value. If *lock* is a :class:`~multiprocessing.Lock` or - :class:`~multiprocessing.RLock` object then that will be used to synchronize access to the + synchronize access to the value. If *lock* is a :class:`Lock` or + :class:`RLock` object then that will be used to synchronize access to the value. If *lock* is ``False`` then access to the returned object will not be automatically protected by a lock, so it will not necessarily be "process-safe". @@ -1257,12 +1195,12 @@ *exposed* is used to specify a sequence of method names which proxies for this typeid should be allowed to access using - :meth:`BaseProxy._callmethod`. (If *exposed* is ``None`` then + :meth:`BaseProxy._callMethod`. (If *exposed* is ``None`` then :attr:`proxytype._exposed_` is used instead if it exists.) In the case where no exposed list is specified, all "public methods" of the shared object will be accessible. (Here a "public method" means any attribute - which has a :meth:`~object.__call__` method and whose name does not begin - with ``'_'``.) + which has a :meth:`__call__` method and whose name does not begin with + ``'_'``.) *method_to_typeid* is a mapping used to specify the return type of those exposed methods which should return a proxy. It maps method names to @@ -1391,7 +1329,7 @@ >>>>>>>>>>>>>>>>>>> To create one's own manager, one creates a subclass of :class:`BaseManager` and -uses the :meth:`~BaseManager.register` classmethod to register new types or +use the :meth:`~BaseManager.register` classmethod to register new types or callables with the manager class. For example:: from multiprocessing.managers import BaseManager @@ -1623,9 +1561,6 @@ *initializer* is not ``None`` then each worker process will call ``initializer(*initargs)`` when it starts. - Note that the methods of the pool object should only be called by - the process which created the pool. - .. versionadded:: 2.7 *maxtasksperchild* is the number of tasks a worker process can complete before it will exit and be replaced with a fresh worker process, to enable @@ -1644,10 +1579,10 @@ .. method:: apply(func[, args[, kwds]]) - Equivalent of the :func:`apply` built-in function. It blocks until the - result is ready, so :meth:`apply_async` is better suited for performing - work in parallel. Additionally, *func* is only executed in one of the - workers of the pool. + Equivalent of the :func:`apply` built-in function. It blocks till the + result is ready. Given this blocks, :meth:`apply_async` is better suited + for performing work in parallel. Additionally, the passed + in function is only executed in one of the workers of the pool. .. method:: apply_async(func[, args[, kwds[, callback]]]) @@ -1661,7 +1596,7 @@ .. method:: map(func, iterable[, chunksize]) A parallel equivalent of the :func:`map` built-in function (it supports only - one *iterable* argument though). It blocks until the result is ready. + one *iterable* argument though). It blocks till the result is ready. This method chops the iterable into a number of chunks which it submits to the process pool as separate tasks. The (approximate) size of these @@ -1772,8 +1707,7 @@ :synopsis: API for dealing with sockets. Usually message passing between processes is done using queues or by using -:class:`~multiprocessing.Connection` objects returned by -:func:`~multiprocessing.Pipe`. +:class:`Connection` objects returned by :func:`Pipe`. However, the :mod:`multiprocessing.connection` module allows some extra flexibility. It basically gives a high level message oriented API for dealing @@ -1790,7 +1724,7 @@ then a welcome message is sent to the other end of the connection. Otherwise :exc:`AuthenticationError` is raised. -.. function:: answer_challenge(connection, authkey) +.. function:: answerChallenge(connection, authkey) Receive a message, calculate the digest of the message using *authkey* as the key, and then send the digest back. @@ -1839,8 +1773,7 @@ private temporary directory created using :func:`tempfile.mkstemp`. If the listener object uses a socket then *backlog* (1 by default) is passed - to the :meth:`~socket.socket.listen` method of the socket once it has been - bound. + to the :meth:`listen` method of the socket once it has been bound. If *authenticate* is ``True`` (``False`` by default) or *authkey* is not ``None`` then digest authentication is used. @@ -1857,9 +1790,8 @@ .. method:: accept() Accept a connection on the bound socket or named pipe of the listener - object and return a :class:`~multiprocessing.Connection` object. If - authentication is attempted and fails, then - :exc:`~multiprocessing.AuthenticationError` is raised. + object and return a :class:`Connection` object. If authentication is + attempted and fails, then :exc:`AuthenticationError` is raised. .. method:: close() @@ -1955,8 +1887,7 @@ Authentication keys ~~~~~~~~~~~~~~~~~~~ -When one uses :meth:`Connection.recv `, the -data received is automatically +When one uses :meth:`Connection.recv`, the data received is automatically unpickled. Unfortunately unpickling data from an untrusted source is a security risk. Therefore :class:`Listener` and :func:`Client` use the :mod:`hmac` module to provide digest authentication. @@ -2105,10 +2036,9 @@ On Unix when a process finishes but has not been joined it becomes a zombie. There should never be very many because each time a new process starts (or - :func:`~multiprocessing.active_children` is called) all completed processes - which have not yet been joined will be joined. Also calling a finished - process's :meth:`Process.is_alive ` will - join the process. Even so it is probably good + :func:`active_children` is called) all completed processes which have not + yet been joined will be joined. Also calling a finished process's + :meth:`Process.is_alive` will join the process. Even so it is probably good practice to explicitly join all the processes that you start. Better to inherit than pickle/unpickle @@ -2116,27 +2046,25 @@ On Windows many types from :mod:`multiprocessing` need to be picklable so that child processes can use them. However, one should generally avoid sending shared objects to other processes using pipes or queues. Instead - you should arrange the program so that a process which needs access to a + you should arrange the program so that a process which need access to a shared resource created elsewhere can inherit it from an ancestor process. Avoid terminating processes - Using the :meth:`Process.terminate ` - method to stop a process is liable to + Using the :meth:`Process.terminate` method to stop a process is liable to cause any shared resources (such as locks, semaphores, pipes and queues) currently being used by the process to become broken or unavailable to other processes. Therefore it is probably best to only consider using - :meth:`Process.terminate ` on processes - which never use any shared resources. + :meth:`Process.terminate` on processes which never use any shared resources. Joining processes that use queues Bear in mind that a process that has put items in a queue will wait before terminating until all the buffered items are fed by the "feeder" thread to the underlying pipe. (The child process can call the - :meth:`~multiprocessing.Queue.cancel_join_thread` method of the queue to avoid this behaviour.) + :meth:`Queue.cancel_join_thread` method of the queue to avoid this behaviour.) This means that whenever you use a queue you need to make sure that all items which have been put on the queue will eventually be removed before the @@ -2197,7 +2125,7 @@ for i in range(10): Process(target=f, args=(lock,)).start() -Beware of replacing :data:`sys.stdin` with a "file like object" +Beware replacing sys.stdin with a "file like object" :mod:`multiprocessing` originally unconditionally called:: @@ -2213,7 +2141,7 @@ resulting in a bad file descriptor error, but introduces a potential danger to applications which replace :func:`sys.stdin` with a "file-like object" with output buffering. This danger is that if multiple processes call - :meth:`~io.IOBase.close()` on this file-like object, it could result in the same + :func:`close()` on this file-like object, it could result in the same data being flushed to the object multiple times, resulting in corruption. If you write a file-like object and implement your own caching, you can @@ -2242,16 +2170,14 @@ as the ``target`` argument on Windows --- just define a function and use that instead. - Also, if you subclass :class:`~multiprocessing.Process` then make sure that - instances will be picklable when the :meth:`Process.start - ` method is called. + Also, if you subclass :class:`Process` then make sure that instances will be + picklable when the :meth:`Process.start` method is called. Global variables Bear in mind that if code run in a child process tries to access a global variable, then the value it sees (if any) may not be the same as the value - in the parent process at the time that :meth:`Process.start - ` was called. + in the parent process at the time that :meth:`Process.start` was called. However, global variables which are just module level constants cause no problems. @@ -2306,7 +2232,7 @@ .. literalinclude:: ../includes/mp_newtype.py -Using :class:`~multiprocessing.pool.Pool`: +Using :class:`Pool`: .. literalinclude:: ../includes/mp_pool.py @@ -2317,7 +2243,7 @@ An example showing how to use queues to feed tasks to a collection of worker -processes and collect the results: +process and collect the results: .. literalinclude:: ../includes/mp_workers.py diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/library/mutex.rst --- a/Doc/library/mutex.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/library/mutex.rst Sun Jul 20 10:52:46 2014 -0400 @@ -7,7 +7,7 @@ :deprecated: .. deprecated:: 2.6 - The :mod:`mutex` module has been removed in Python 3. + The :mod:`mutex` module has been removed in Python 3.0. .. sectionauthor:: Moshe Zadka diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/library/netrc.rst --- a/Doc/library/netrc.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/library/netrc.rst Sun Jul 20 10:52:46 2014 -0400 @@ -25,14 +25,6 @@ no argument is given, the file :file:`.netrc` in the user's home directory will be read. Parse errors will raise :exc:`NetrcParseError` with diagnostic information including the file name, line number, and terminating token. - If no argument is specified on a POSIX system, the presence of passwords in - the :file:`.netrc` file will raise a :exc:`NetrcParseError` if the file - ownership or permissions are insecure (owned by a user other than the user - running the process, or accessible for read or write by any other user). - This implements security behavior equivalent to that of ftp and other - programs that use :file:`.netrc`. - - .. versionchanged:: 2.7.6 Added the POSIX permissions check. .. exception:: NetrcParseError diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/library/new.rst --- a/Doc/library/new.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/library/new.rst Sun Jul 20 10:52:46 2014 -0400 @@ -6,7 +6,7 @@ :deprecated: .. deprecated:: 2.6 - The :mod:`new` module has been removed in Python 3. Use the :mod:`types` + The :mod:`new` module has been removed in Python 3.0. Use the :mod:`types` module's classes instead. .. sectionauthor:: Moshe Zadka @@ -48,7 +48,7 @@ .. function:: code(argcount, nlocals, stacksize, flags, codestring, constants, names, varnames, filename, name, firstlineno, lnotab) - This function is an interface to the :c:func:`PyCode_New` C function. + This function is an interface to the :cfunc:`PyCode_New` C function. .. XXX This is still undocumented! diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/library/nntplib.rst --- a/Doc/library/nntplib.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/library/nntplib.rst Sun Jul 20 10:52:46 2014 -0400 @@ -46,7 +46,7 @@ headers, and that you have right to post on the particular newsgroup):: >>> s = NNTP('news.gmane.org') - >>> f = open('articlefile') + >>> f = open('/tmp/article') >>> s.post(f) '240 Article posted successfully.' >>> s.quit() @@ -234,25 +234,25 @@ .. method:: NNTP.next() - Send a ``NEXT`` command. Return as for :meth:`.stat`. + Send a ``NEXT`` command. Return as for :meth:`stat`. .. method:: NNTP.last() - Send a ``LAST`` command. Return as for :meth:`.stat`. + Send a ``LAST`` command. Return as for :meth:`stat`. .. method:: NNTP.head(id) - Send a ``HEAD`` command, where *id* has the same meaning as for :meth:`.stat`. + Send a ``HEAD`` command, where *id* has the same meaning as for :meth:`stat`. Return a tuple ``(response, number, id, list)`` where the first three are the - same as for :meth:`.stat`, and *list* is a list of the article's headers (an + same as for :meth:`stat`, and *list* is a list of the article's headers (an uninterpreted list of lines, without trailing newlines). .. method:: NNTP.body(id,[file]) - Send a ``BODY`` command, where *id* has the same meaning as for :meth:`.stat`. + Send a ``BODY`` command, where *id* has the same meaning as for :meth:`stat`. If the *file* parameter is supplied, then the body is stored in a file. If *file* is a string, then the method will open a file object with that name, write to it then close it. If *file* is a file object, then it will start @@ -263,7 +263,7 @@ .. method:: NNTP.article(id) Send an ``ARTICLE`` command, where *id* has the same meaning as for - :meth:`.stat`. Return as for :meth:`head`. + :meth:`stat`. Return as for :meth:`head`. .. method:: NNTP.slave() @@ -290,7 +290,7 @@ .. method:: NNTP.post(file) Post an article using the ``POST`` command. The *file* argument is an open file - object which is read until EOF using its :meth:`~file.readline` method. It should be + object which is read until EOF using its :meth:`readline` method. It should be a well-formed news article, including the required headers. The :meth:`post` method automatically escapes lines beginning with ``.``. diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/library/numbers.rst --- a/Doc/library/numbers.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/library/numbers.rst Sun Jul 20 10:52:46 2014 -0400 @@ -73,10 +73,10 @@ .. class:: Integral - Subtypes :class:`Rational` and adds a conversion to :class:`int`. Provides - defaults for :func:`float`, :attr:`~Rational.numerator`, and - :attr:`~Rational.denominator`. Adds abstract methods for ``**`` and - bit-string operations: ``<<``, ``>>``, ``&``, ``^``, ``|``, ``~``. + Subtypes :class:`Rational` and adds a conversion to :class:`int`. + Provides defaults for :func:`float`, :attr:`~Rational.numerator`, and + :attr:`~Rational.denominator`, and bit-string operations: ``<<``, + ``>>``, ``&``, ``^``, ``|``, ``~``. Notes for type implementors diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/library/operator.rst --- a/Doc/library/operator.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/library/operator.rst Sun Jul 20 10:52:46 2014 -0400 @@ -12,11 +12,11 @@ from operator import itemgetter -The :mod:`operator` module exports a set of efficient functions corresponding to -the intrinsic operators of Python. For example, ``operator.add(x, y)`` is -equivalent to the expression ``x+y``. The function names are those used for -special class methods; variants without leading and trailing ``__`` are also -provided for convenience. +The :mod:`operator` module exports a set of functions implemented in C +corresponding to the intrinsic operators of Python. For example, +``operator.add(x, y)`` is equivalent to the expression ``x+y``. The function +names are those used for special class methods; variants without leading and +trailing ``__`` are also provided for convenience. The functions fall into categories that perform object comparisons, logical operations, mathematical operations, sequence operations, and abstract type @@ -490,22 +490,13 @@ expect a function argument. -.. function:: attrgetter(attr) - attrgetter(*attrs) +.. function:: attrgetter(attr[, args...]) - Return a callable object that fetches *attr* from its operand. - If more than one attribute is requested, returns a tuple of attributes. - The attribute names can also contain dots. For example: - - * After ``f = attrgetter('name')``, the call ``f(b)`` returns ``b.name``. - - * After ``f = attrgetter('name', 'date')``, the call ``f(b)`` returns - ``(b.name, b.date)``. - - * After ``f = attrgetter('name.first', 'name.last')``, the call ``f(b)`` - returns ``(b.name.first, b.name.last)``. - - Equivalent to:: + Return a callable object that fetches *attr* from its operand. If more than one + attribute is requested, returns a tuple of attributes. After, + ``f = attrgetter('name')``, the call ``f(b)`` returns ``b.name``. After, + ``f = attrgetter('name', 'date')``, the call ``f(b)`` returns ``(b.name, + b.date)``. Equivalent to:: def attrgetter(*items): if len(items) == 1: @@ -514,7 +505,7 @@ return resolve_attr(obj, attr) else: def g(obj): - return tuple(resolve_attr(obj, attr) for attr in items) + return tuple(resolve_att(obj, attr) for attr in items) return g def resolve_attr(obj, attr): @@ -523,6 +514,9 @@ return obj + The attribute names can also contain dots; after ``f = attrgetter('date.month')``, + the call ``f(b)`` returns ``b.date.month``. + .. versionadded:: 2.4 .. versionchanged:: 2.5 @@ -532,19 +526,11 @@ Added support for dotted attributes. -.. function:: itemgetter(item) - itemgetter(*items) +.. function:: itemgetter(item[, args...]) Return a callable object that fetches *item* from its operand using the operand's :meth:`__getitem__` method. If multiple items are specified, - returns a tuple of lookup values. For example: - - * After ``f = itemgetter(2)``, the call ``f(r)`` returns ``r[2]``. - - * After ``g = itemgetter(2, 5, 3)``, the call ``g(r)`` returns - ``(r[2], r[5], r[3])``. - - Equivalent to:: + returns a tuple of lookup values. Equivalent to:: def itemgetter(*items): if len(items) == 1: @@ -587,14 +573,9 @@ Return a callable object that calls the method *name* on its operand. If additional arguments and/or keyword arguments are given, they will be given - to the method as well. For example: - - * After ``f = methodcaller('name')``, the call ``f(b)`` returns ``b.name()``. - - * After ``f = methodcaller('name', 'foo', bar=1)``, the call ``f(b)`` - returns ``b.name('foo', bar=1)``. - - Equivalent to:: + to the method as well. After ``f = methodcaller('name')``, the call ``f(b)`` + returns ``b.name()``. After ``f = methodcaller('name', 'foo', bar=1)``, the + call ``f(b)`` returns ``b.name('foo', bar=1)``. Equivalent to:: def methodcaller(name, *args, **kwargs): def caller(obj): diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/library/optparse.rst --- a/Doc/library/optparse.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/library/optparse.rst Sun Jul 20 10:52:46 2014 -0400 @@ -173,10 +173,10 @@ For example, consider this hypothetical command-line:: - prog -v --report report.txt foo bar + prog -v --report /tmp/report.txt foo bar ``-v`` and ``--report`` are both options. Assuming that ``--report`` -takes one argument, ``report.txt`` is an option argument. ``foo`` and +takes one argument, ``/tmp/report.txt`` is an option argument. ``foo`` and ``bar`` are positional arguments. @@ -275,8 +275,7 @@ strings as you like (including zero), as long as there is at least one option string overall. -The option strings passed to :meth:`OptionParser.add_option` are effectively -labels for the +The option strings passed to :meth:`add_option` are effectively labels for the option defined by that call. For brevity, we will frequently refer to *encountering an option* on the command line; in reality, :mod:`optparse` encounters *option strings* and looks up options from them. @@ -896,8 +895,7 @@ The canonical way to create an :class:`Option` instance is with the :meth:`add_option` method of :class:`OptionParser`. -.. method:: OptionParser.add_option(option) - OptionParser.add_option(*opt_str, attr=value, ...) +.. method:: OptionParser.add_option(opt_str[, ...], attr=value, ...) To define an option with only a short option string:: @@ -1170,17 +1168,6 @@ options.tracks.append(int("4")) - The ``append`` action calls the ``append`` method on the current value of the - option. This means that any default value specified must have an ``append`` - method. It also means that if the default value is non-empty, the default - elements will be present in the parsed value for the option, with any values - from the command line appended after those default values:: - - >>> parser.add_option("--files", action="append", default=['~/.mypkg/defaults']) - >>> opts, args = parser.parse_args(['--files', 'overrides.mypkg']) - >>> opts.files - ['~/.mypkg/defaults', 'overrides.mypkg'] - * ``"append_const"`` [required: :attr:`~Option.const`; relevant: :attr:`~Option.dest`] diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/library/os.path.rst --- a/Doc/library/os.path.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/library/os.path.rst Sun Jul 20 10:52:46 2014 -0400 @@ -16,11 +16,6 @@ :func:`splitunc` and :func:`ismount` do handle them correctly. -Unlike a unix shell, Python does not do any *automatic* path expansions. -Functions such as :func:`expanduser` and :func:`expandvars` can be invoked -explicitly when an application desires shell-like path expansion. (See also -the :mod:`glob` module.) - .. note:: Since different operating systems have different path name conventions, there @@ -40,17 +35,15 @@ .. function:: abspath(path) Return a normalized absolutized version of the pathname *path*. On most - platforms, this is equivalent to calling the function :func:`normpath` as - follows: ``normpath(join(os.getcwd(), path))``. + platforms, this is equivalent to ``normpath(join(os.getcwd(), path))``. .. versionadded:: 1.5.2 .. function:: basename(path) - Return the base name of pathname *path*. This is the second element of the - pair returned by passing *path* to the function :func:`split`. Note that - the result of this function is different + Return the base name of pathname *path*. This is the second half of the pair + returned by ``split(path)``. Note that the result of this function is different from the Unix :program:`basename` program; where :program:`basename` for ``'/foo/bar/'`` returns ``'bar'``, the :func:`basename` function returns an empty string (``''``). @@ -65,8 +58,8 @@ .. function:: dirname(path) - Return the directory name of pathname *path*. This is the first element of - the pair returned by passing *path* to the function :func:`split`. + Return the directory name of pathname *path*. This is the first half of the + pair returned by ``split(path)``. .. function:: exists(path) @@ -127,7 +120,7 @@ .. versionadded:: 1.5.2 .. versionchanged:: 2.3 - If :func:`os.stat_float_times` returns ``True``, the result is a floating point + If :func:`os.stat_float_times` returns True, the result is a floating point number. @@ -140,14 +133,14 @@ .. versionadded:: 1.5.2 .. versionchanged:: 2.3 - If :func:`os.stat_float_times` returns ``True``, the result is a floating point + If :func:`os.stat_float_times` returns True, the result is a floating point number. .. function:: getctime(path) Return the system's ctime which, on some systems (like Unix) is the time of the - last metadata change, and, on others (like Windows), is the creation time for *path*. + last change, and, on others (like Windows), is the creation time for *path*. The return value is a number giving the number of seconds since the epoch (see the :mod:`time` module). Raise :exc:`os.error` if the file does not exist or is inaccessible. @@ -185,7 +178,7 @@ .. function:: islink(path) Return ``True`` if *path* refers to a directory entry that is a symbolic link. - Always ``False`` if symbolic links are not supported by the python runtime. + Always ``False`` if symbolic links are not supported. .. function:: ismount(path) @@ -219,11 +212,13 @@ .. function:: normpath(path) - Normalize a pathname by collapsing redundant separators and up-level - references so that ``A//B``, ``A/B/``, ``A/./B`` and ``A/foo/../B`` all - become ``A/B``. This string manipulation may change the meaning of a path - that contains symbolic links. On Windows, it converts forward slashes to - backward slashes. To normalize case, use :func:`normcase`. + Normalize a pathname. This collapses redundant separators and up-level + references so that ``A//B``, ``A/B/``, ``A/./B`` and ``A/foo/../B`` all become + ``A/B``. + + It does not normalize the case (use :func:`normcase` for that). On Windows, it + converts forward slashes to backward slashes. It should be understood that this + may change the meaning of the path if it contains symbolic links! .. function:: realpath(path) @@ -236,10 +231,8 @@ .. function:: relpath(path[, start]) - Return a relative filepath to *path* either from the current directory or - from an optional *start* directory. This is a path computation: the - filesystem is not accessed to confirm the existence or nature of *path* or - *start*. + Return a relative filepath to *path* either from the current directory or from + an optional *start* point. *start* defaults to :attr:`os.curdir`. @@ -267,9 +260,9 @@ .. function:: samestat(stat1, stat2) Return ``True`` if the stat tuples *stat1* and *stat2* refer to the same file. - These structures may have been returned by :func:`os.fstat`, - :func:`os.lstat`, or :func:`os.stat`. This function implements the - underlying comparison used by :func:`samefile` and :func:`sameopenfile`. + These structures may have been returned by :func:`fstat`, :func:`lstat`, or + :func:`stat`. This function implements the underlying comparison used by + :func:`samefile` and :func:`sameopenfile`. Availability: Unix. @@ -283,8 +276,7 @@ *path* is empty, both *head* and *tail* are empty. Trailing slashes are stripped from *head* unless it is the root (one or more slashes only). In all cases, ``join(head, tail)`` returns a path to the same location as *path* - (but the strings may differ). Also see the functions :func:`dirname` and - :func:`basename`. + (but the strings may differ). .. function:: splitdrive(path) @@ -339,13 +331,13 @@ .. note:: - This function is deprecated and has been removed in Python 3 in favor of + This function is deprecated and has been removed in 3.0 in favor of :func:`os.walk`. .. data:: supports_unicode_filenames - ``True`` if arbitrary Unicode strings can be used as file names (within limitations + True if arbitrary Unicode strings can be used as file names (within limitations imposed by the file system). .. versionadded:: 2.3 diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/library/os.rst --- a/Doc/library/os.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/library/os.rst Sun Jul 20 10:52:46 2014 -0400 @@ -72,7 +72,7 @@ .. data:: environ - A :term:`mapping` object representing the string environment. For example, + A mapping object representing the string environment. For example, ``environ['HOME']`` is the pathname of your home directory (on some platforms), and is equivalent to ``getenv("HOME")`` in C. @@ -94,7 +94,7 @@ On some platforms, including FreeBSD and Mac OS X, setting ``environ`` may cause memory leaks. Refer to the system documentation for - :c:func:`putenv`. + :cfunc:`putenv`. If :func:`putenv` is not provided, a modified copy of this mapping may be passed to the appropriate process-creation functions to cause child processes @@ -157,22 +157,6 @@ Availability: Unix. - .. note:: - - On Mac OS X, :func:`getgroups` behavior differs somewhat from - other Unix platforms. If the Python interpreter was built with a - deployment target of :const:`10.5` or earlier, :func:`getgroups` returns - the list of effective group ids associated with the current user process; - this list is limited to a system-defined number of entries, typically 16, - and may be modified by calls to :func:`setgroups` if suitably privileged. - If built with a deployment target greater than :const:`10.5`, - :func:`getgroups` returns the current group access list for the user - associated with the effective user id of the process; the group access - list may change over the lifetime of the process, it is not affected by - calls to :func:`setgroups`, and its length is not limited to 16. The - deployment target value, :const:`MACOSX_DEPLOYMENT_TARGET`, can be - obtained with :func:`sysconfig.get_config_var`. - .. function:: initgroups(username, gid) @@ -257,7 +241,7 @@ .. index:: single: user; id - Return the current process's real user id. + Return the current process's user id. Availability: Unix. @@ -322,14 +306,10 @@ .. versionadded:: 2.2 - .. note:: On Mac OS X, the length of *groups* may not exceed the - system-defined maximum number of effective group ids, typically 16. - See the documentation for :func:`getgroups` for cases where it may not - return the same group list set by calling setgroups(). .. function:: setpgrp() - Call the system call :c:func:`setpgrp` or :c:func:`setpgrp(0, 0)` depending on + Call the system call :cfunc:`setpgrp` or :cfunc:`setpgrp(0, 0)` depending on which version is implemented (if any). See the Unix manual for the semantics. Availability: Unix. @@ -337,7 +317,7 @@ .. function:: setpgid(pid, pgrp) - Call the system call :c:func:`setpgid` to set the process group id of the + Call the system call :cfunc:`setpgid` to set the process group id of the process with id *pid* to the process group with id *pgrp*. See the Unix manual for the semantics. @@ -378,7 +358,7 @@ .. function:: getsid(pid) - Call the system call :c:func:`getsid`. See the Unix manual for the semantics. + Call the system call :cfunc:`getsid`. See the Unix manual for the semantics. Availability: Unix. @@ -387,7 +367,7 @@ .. function:: setsid() - Call the system call :c:func:`setsid`. See the Unix manual for the semantics. + Call the system call :cfunc:`setsid`. See the Unix manual for the semantics. Availability: Unix. @@ -405,7 +385,7 @@ .. function:: strerror(code) Return the error message corresponding to the error code in *code*. - On platforms where :c:func:`strerror` returns ``NULL`` when given an unknown + On platforms where :cfunc:`strerror` returns ``NULL`` when given an unknown error number, :exc:`ValueError` is raised. Availability: Unix, Windows. @@ -463,9 +443,8 @@ .. index:: single: I/O control; buffering Return an open file object connected to the file descriptor *fd*. The *mode* - and *bufsize* arguments have the same meaning as the corresponding arguments - to the built-in :func:`open` function. If :func:`fdopen` raises an - exception, it leaves *fd* untouched (unclosed). + and *bufsize* arguments have the same meaning as the corresponding arguments to + the built-in :func:`open` function. Availability: Unix, Windows. @@ -475,7 +454,7 @@ .. versionchanged:: 2.5 On Unix, when the *mode* argument starts with ``'a'``, the *O_APPEND* flag is - set on the file descriptor (which the :c:func:`fdopen` implementation already + set on the file descriptor (which the :cfunc:`fdopen` implementation already does on most platforms). @@ -498,7 +477,7 @@ .. versionchanged:: 2.0 This function worked unreliably under Windows in earlier versions of Python. - This was due to the use of the :c:func:`_popen` function from the libraries + This was due to the use of the :cfunc:`_popen` function from the libraries provided with Windows. Newer versions of Python do not use the broken implementation from the Windows libraries. @@ -618,7 +597,7 @@ This function is intended for low-level I/O and must be applied to a file descriptor as returned by :func:`os.open` or :func:`pipe`. To close a "file object" returned by the built-in function :func:`open` or by :func:`popen` or - :func:`fdopen`, use its :meth:`~io.IOBase.close` method. + :func:`fdopen`, use its :meth:`~file.close` method. .. function:: closerange(fd_low, fd_high) @@ -718,7 +697,7 @@ .. function:: fsync(fd) Force write of file with filedescriptor *fd* to disk. On Unix, this calls the - native :c:func:`fsync` function; on Windows, the MS :c:func:`_commit` function. + native :cfunc:`fsync` function; on Windows, the MS :cfunc:`_commit` function. If you're starting with a Python file object *f*, first do ``f.flush()``, and then do ``os.fsync(f.fileno())``, to ensure that all internal buffers associated @@ -740,14 +719,16 @@ Return ``True`` if the file descriptor *fd* is open and connected to a tty(-like) device, else ``False``. + Availability: Unix. + .. function:: lseek(fd, pos, how) Set the current position of file descriptor *fd* to position *pos*, modified by *how*: :const:`SEEK_SET` or ``0`` to set the position relative to the beginning of the file; :const:`SEEK_CUR` or ``1`` to set it relative to the - current position; :const:`SEEK_END` or ``2`` to set it relative to the end of - the file. Return the new cursor position in bytes, starting from the beginning. + current position; :const:`os.SEEK_END` or ``2`` to set it relative to the end of + the file. Availability: Unix, Windows. @@ -1161,7 +1142,7 @@ .. function:: lstat(path) - Perform the equivalent of an :c:func:`lstat` system call on the given path. + Perform the equivalent of an :cfunc:`lstat` system call on the given path. Similar to :func:`~os.stat`, but does not follow symbolic links. On platforms that do not support symbolic links, this is an alias for :func:`~os.stat`. @@ -1182,7 +1163,7 @@ doesn't open the FIFO --- it just creates the rendezvous point. -.. function:: mknod(filename[, mode=0600[, device=0]]) +.. function:: mknod(filename[, mode=0600, device]) Create a filesystem node (file, device special file or named pipe) named *filename*. *mode* specifies both the permissions to use and the type of node to @@ -1199,7 +1180,7 @@ .. function:: major(device) Extract the device major number from a raw device number (usually the - :attr:`st_dev` or :attr:`st_rdev` field from :c:type:`stat`). + :attr:`st_dev` or :attr:`st_rdev` field from :ctype:`stat`). .. versionadded:: 2.3 @@ -1207,7 +1188,7 @@ .. function:: minor(device) Extract the device minor number from a raw device number (usually the - :attr:`st_dev` or :attr:`st_rdev` field from :c:type:`stat`). + :attr:`st_dev` or :attr:`st_rdev` field from :ctype:`stat`). .. versionadded:: 2.3 @@ -1362,11 +1343,11 @@ .. function:: stat(path) - Perform the equivalent of a :c:func:`stat` system call on the given path. + Perform the equivalent of a :cfunc:`stat` system call on the given path. (This function follows symlinks; to stat a symlink use :func:`lstat`.) The return value is an object whose attributes correspond to the members - of the :c:type:`stat` structure, namely: + of the :ctype:`stat` structure, namely: * :attr:`st_mode` - protection bits, * :attr:`st_ino` - inode number, @@ -1382,14 +1363,15 @@ .. versionchanged:: 2.3 If :func:`stat_float_times` returns ``True``, the time values are floats, measuring - seconds. Fractions of a second may be reported if the system supports that. - See :func:`stat_float_times` for further discussion. + seconds. Fractions of a second may be reported if the system supports that. On + Mac OS, the times are always floats. See :func:`stat_float_times` for further + discussion. On some Unix systems (such as Linux), the following attributes may also be available: - * :attr:`st_blocks` - number of 512-byte blocks allocated for file - * :attr:`st_blksize` - filesystem blocksize for efficient file system I/O + * :attr:`st_blocks` - number of blocks allocated for file + * :attr:`st_blksize` - filesystem blocksize * :attr:`st_rdev` - type of device if an inode device * :attr:`st_flags` - user defined flags for file @@ -1399,6 +1381,12 @@ * :attr:`st_gen` - file generation number * :attr:`st_birthtime` - time of file creation + On Mac OS systems, the following attributes may also be available: + + * :attr:`st_rsize` + * :attr:`st_creator` + * :attr:`st_type` + On RISCOS systems, the following attributes are also available: * :attr:`st_ftype` (file type) @@ -1416,7 +1404,7 @@ For backward compatibility, the return value of :func:`~os.stat` is also accessible as a tuple of at least 10 integers giving the most important (and portable) - members of the :c:type:`stat` structure, in the order :attr:`st_mode`, + members of the :ctype:`stat` structure, in the order :attr:`st_mode`, :attr:`st_ino`, :attr:`st_dev`, :attr:`st_nlink`, :attr:`st_uid`, :attr:`st_gid`, :attr:`st_size`, :attr:`st_atime`, :attr:`st_mtime`, :attr:`st_ctime`. More items may be added at the end by some implementations. @@ -1424,7 +1412,7 @@ .. index:: module: stat The standard module :mod:`stat` defines functions and constants that are useful - for extracting information from a :c:type:`stat` structure. (On Windows, some + for extracting information from a :ctype:`stat` structure. (On Windows, some items are filled with dummy values.) Example:: @@ -1473,9 +1461,9 @@ .. function:: statvfs(path) - Perform a :c:func:`statvfs` system call on the given path. The return value is + Perform a :cfunc:`statvfs` system call on the given path. The return value is an object whose attributes describe the filesystem on the given path, and - correspond to the members of the :c:type:`statvfs` structure, namely: + correspond to the members of the :ctype:`statvfs` structure, namely: :attr:`f_bsize`, :attr:`f_frsize`, :attr:`f_blocks`, :attr:`f_bfree`, :attr:`f_bavail`, :attr:`f_files`, :attr:`f_ffree`, :attr:`f_favail`, :attr:`f_flag`, :attr:`f_namemax`. @@ -1485,7 +1473,7 @@ For backward compatibility, the return value is also accessible as a tuple whose values correspond to the attributes, in the order given above. The standard module :mod:`statvfs` defines constants that are useful for extracting - information from a :c:type:`statvfs` structure when accessing it as a sequence; + information from a :ctype:`statvfs` structure when accessing it as a sequence; this remains useful when writing code that needs to work with versions of Python that don't support accessing the fields as attributes. @@ -1577,7 +1565,7 @@ Availability: Unix, Windows. -.. function:: walk(top, topdown=True, onerror=None, followlinks=False) +.. function:: walk(top[, topdown=True [, onerror=None[, followlinks=False]]]) .. index:: single: directory; walking @@ -1597,11 +1585,9 @@ If optional argument *topdown* is ``True`` or not specified, the triple for a directory is generated before the triples for any of its subdirectories - (directories are generated top-down). If *topdown* is ``False``, the triple - for a directory is generated after the triples for all of its subdirectories - (directories are generated bottom-up). No matter the value of *topdown*, the - list of subdirectories is retrieved before the tuples for the directory and - its subdirectories are generated. + (directories are generated top-down). If *topdown* is ``False``, the triple for a + directory is generated after the triples for all of its subdirectories + (directories are generated bottom-up). When *topdown* is ``True``, the caller can modify the *dirnames* list in-place (perhaps using :keyword:`del` or slice assignment), and :func:`walk` will only @@ -1674,11 +1660,11 @@ These functions may be used to create and manage processes. -The various :func:`exec\* ` functions take a list of arguments for the new +The various :func:`exec\*` functions take a list of arguments for the new program loaded into the process. In each case, the first of these arguments is passed to the new program as its own name rather than as an argument a user may have typed on a command line. For the C programmer, this is the ``argv[0]`` -passed to a program's :c:func:`main`. For example, ``os.execv('/bin/echo', +passed to a program's :cfunc:`main`. For example, ``os.execv('/bin/echo', ['foo', 'bar'])`` will only print ``bar`` on standard output; ``foo`` will seem to be ignored. @@ -1712,9 +1698,9 @@ descriptors are not flushed, so if there may be data buffered on these open files, you should flush them using :func:`sys.stdout.flush` or :func:`os.fsync` before calling an - :func:`exec\* ` function. - - The "l" and "v" variants of the :func:`exec\* ` functions differ in how + :func:`exec\*` function. + + The "l" and "v" variants of the :func:`exec\*` functions differ in how command-line arguments are passed. The "l" variants are perhaps the easiest to work with if the number of parameters is fixed when the code is written; the individual parameters simply become additional parameters to the :func:`execl\*` @@ -1726,7 +1712,7 @@ The variants which include a "p" near the end (:func:`execlp`, :func:`execlpe`, :func:`execvp`, and :func:`execvpe`) will use the :envvar:`PATH` environment variable to locate the program *file*. When the - environment is being replaced (using one of the :func:`exec\*e ` variants, + environment is being replaced (using one of the :func:`exec\*e` variants, discussed in the next paragraph), the new environment is used as the source of the :envvar:`PATH` variable. The other variants, :func:`execl`, :func:`execle`, :func:`execv`, and :func:`execve`, will not use the :envvar:`PATH` variable to @@ -1934,10 +1920,6 @@ Note that some platforms including FreeBSD <= 6.3, Cygwin and OS/2 EMX have known issues when using fork() from a thread. - .. warning:: - - See :mod:`ssl` for applications that use the SSL module with fork(). - Availability: Unix. @@ -2032,7 +2014,7 @@ process. On Windows, the process id will actually be the process handle, so can be used with the :func:`waitpid` function. - The "l" and "v" variants of the :func:`spawn\* ` functions differ in how + The "l" and "v" variants of the :func:`spawn\*` functions differ in how command-line arguments are passed. The "l" variants are perhaps the easiest to work with if the number of parameters is fixed when the code is written; the individual parameters simply become additional parameters to the @@ -2044,7 +2026,7 @@ The variants which include a second "p" near the end (:func:`spawnlp`, :func:`spawnlpe`, :func:`spawnvp`, and :func:`spawnvpe`) will use the :envvar:`PATH` environment variable to locate the program *file*. When the - environment is being replaced (using one of the :func:`spawn\*e ` variants, + environment is being replaced (using one of the :func:`spawn\*e` variants, discussed in the next paragraph), the new environment is used as the source of the :envvar:`PATH` variable. The other variants, :func:`spawnl`, :func:`spawnle`, :func:`spawnv`, and :func:`spawnve`, will not use the @@ -2080,7 +2062,7 @@ .. data:: P_NOWAIT P_NOWAITO - Possible values for the *mode* parameter to the :func:`spawn\* ` family of + Possible values for the *mode* parameter to the :func:`spawn\*` family of functions. If either of these values is given, the :func:`spawn\*` functions will return as soon as the new process has been created, with the process id as the return value. @@ -2092,7 +2074,7 @@ .. data:: P_WAIT - Possible value for the *mode* parameter to the :func:`spawn\* ` family of + Possible value for the *mode* parameter to the :func:`spawn\*` family of functions. If this is given as *mode*, the :func:`spawn\*` functions will not return until the new process has run to completion and will return the exit code of the process the run is successful, or ``-signal`` if a signal kills the @@ -2106,7 +2088,7 @@ .. data:: P_DETACH P_OVERLAY - Possible values for the *mode* parameter to the :func:`spawn\* ` family of + Possible values for the *mode* parameter to the :func:`spawn\*` family of functions. These are less portable than those listed above. :const:`P_DETACH` is similar to :const:`P_NOWAIT`, but the new process is detached from the console of the calling process. If :const:`P_OVERLAY` is used, the current @@ -2135,7 +2117,7 @@ There is no option to wait for the application to close, and no way to retrieve the application's exit status. The *path* parameter is relative to the current directory. If you want to use an absolute path, make sure the first character - is not a slash (``'/'``); the underlying Win32 :c:func:`ShellExecute` function + is not a slash (``'/'``); the underlying Win32 :cfunc:`ShellExecute` function doesn't work if it is. Use the :func:`os.path.normpath` function to ensure that the path is properly encoded for Win32. @@ -2150,13 +2132,13 @@ .. function:: system(command) Execute the command (a string) in a subshell. This is implemented by calling - the Standard C function :c:func:`system`, and has the same limitations. + the Standard C function :cfunc:`system`, and has the same limitations. Changes to :data:`sys.stdin`, etc. are not reflected in the environment of the executed command. On Unix, the return value is the exit status of the process encoded in the format specified for :func:`wait`. Note that POSIX does not specify the meaning - of the return value of the C :c:func:`system` function, so the return value of + of the return value of the C :cfunc:`system` function, so the return value of the Python function is system-dependent. On Windows, the return value is that returned by the system shell after running @@ -2222,18 +2204,17 @@ (shifting makes cross-platform use of the function easier). A *pid* less than or equal to ``0`` has no special meaning on Windows, and raises an exception. The value of integer *options* has no effect. *pid* can refer to any process whose - id is known, not necessarily a child process. The :func:`spawn\* ` - functions called with :const:`P_NOWAIT` return suitable process handles. - - -.. function:: wait3(options) + id is known, not necessarily a child process. The :func:`spawn` functions called + with :const:`P_NOWAIT` return suitable process handles. + + +.. function:: wait3([options]) Similar to :func:`waitpid`, except no process id argument is given and a 3-element tuple containing the child's process id, exit status indication, and resource usage information is returned. Refer to :mod:`resource`.\ - :func:`~resource.getrusage` for details on resource usage information. The - option argument is the same as that provided to :func:`waitpid` and - :func:`wait4`. + :func:`getrusage` for details on resource usage information. The option + argument is the same as that provided to :func:`waitpid` and :func:`wait4`. Availability: Unix. @@ -2244,9 +2225,9 @@ Similar to :func:`waitpid`, except a 3-element tuple, containing the child's process id, exit status indication, and resource usage information is returned. - Refer to :mod:`resource`.\ :func:`~resource.getrusage` for details on - resource usage information. The arguments to :func:`wait4` are the same as - those provided to :func:`waitpid`. + Refer to :mod:`resource`.\ :func:`getrusage` for details on resource usage + information. The arguments to :func:`wait4` are the same as those provided to + :func:`waitpid`. Availability: Unix. @@ -2470,9 +2451,8 @@ .. data:: defpath - The default search path used by :func:`exec\*p\* ` and - :func:`spawn\*p\* ` if the environment doesn't have a ``'PATH'`` - key. Also available via :mod:`os.path`. + The default search path used by :func:`exec\*p\*` and :func:`spawn\*p\*` if the + environment doesn't have a ``'PATH'`` key. Also available via :mod:`os.path`. .. data:: linesep @@ -2505,11 +2485,8 @@ This function returns random bytes from an OS-specific randomness source. The returned data should be unpredictable enough for cryptographic applications, though its exact quality depends on the OS implementation. On a UNIX-like - system this will query ``/dev/urandom``, and on Windows it will use - ``CryptGenRandom()``. If a randomness source is not found, - :exc:`NotImplementedError` will be raised. - - For an easy-to-use interface to the random number generator - provided by your platform, please see :class:`random.SystemRandom`. + system this will query /dev/urandom, and on Windows it will use CryptGenRandom. + If a randomness source is not found, :exc:`NotImplementedError` will be raised. .. versionadded:: 2.4 + diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/library/ossaudiodev.rst --- a/Doc/library/ossaudiodev.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/library/ossaudiodev.rst Sun Jul 20 10:52:46 2014 -0400 @@ -48,7 +48,7 @@ the official documentation for the OSS C API The module defines a large number of constants supplied by the OSS device - driver; see ```` on either Linux or FreeBSD for a listing. + driver; see ```` on either Linux or FreeBSD for a listing . :mod:`ossaudiodev` defines the following variables and functions: @@ -59,15 +59,14 @@ what went wrong. (If :mod:`ossaudiodev` receives an error from a system call such as - :c:func:`open`, :c:func:`write`, or :c:func:`ioctl`, it raises :exc:`IOError`. + :cfunc:`open`, :cfunc:`write`, or :cfunc:`ioctl`, it raises :exc:`IOError`. Errors detected directly by :mod:`ossaudiodev` result in :exc:`OSSAudioError`.) (For backwards compatibility, the exception class is also available as ``ossaudiodev.error``.) -.. function:: open(mode) - open(device, mode) +.. function:: open([device, ]mode) Open an audio device and return an OSS audio device object. This object supports many file-like methods, such as :meth:`read`, :meth:`write`, and @@ -163,11 +162,11 @@ is only useful in non-blocking mode. Has no return value, since the amount of data written is always equal to the amount of data supplied. -The following methods each map to exactly one :c:func:`ioctl` system call. The +The following methods each map to exactly one :func:`ioctl` system call. The correspondence is obvious: for example, :meth:`setfmt` corresponds to the ``SNDCTL_DSP_SETFMT`` ioctl, and :meth:`sync` to ``SNDCTL_DSP_SYNC`` (this can be useful when consulting the OSS documentation). If the underlying -:c:func:`ioctl` fails, they all raise :exc:`IOError`. +:func:`ioctl` fails, they all raise :exc:`IOError`. .. method:: oss_audio_device.nonblock() @@ -276,7 +275,7 @@ simple calculations. -.. method:: oss_audio_device.setparameters(format, nchannels, samplerate[, strict=False]) +.. method:: oss_audio_device.setparameters(format, nchannels, samplerate [, strict=False]) Set the key audio sampling parameters---sample format, number of channels, and sampling rate---in one method call. *format*, *nchannels*, and *samplerate* @@ -296,7 +295,7 @@ fmt = dsp.setfmt(fmt) channels = dsp.channels(channels) - rate = dsp.rate(rate) + rate = dsp.rate(channels) .. method:: oss_audio_device.bufsize() diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/library/othergui.rst --- a/Doc/library/othergui.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/library/othergui.rst Sun Jul 20 10:52:46 2014 -0400 @@ -13,7 +13,8 @@ provides an object oriented interface that is slightly higher level than the C one. It comes with many more widgets than Tkinter provides, and has good Python-specific reference documentation. There are also bindings to - `GNOME `_. An online `tutorial + `GNOME `_. One well known PyGTK application is + `PythonCAD `_. An online `tutorial `_ is available. `PyQt `_ diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/library/parser.rst --- a/Doc/library/parser.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/library/parser.rst Sun Jul 20 10:52:46 2014 -0400 @@ -34,7 +34,7 @@ replaced by "ast"; this is a legacy from the time when there was no other AST and has nothing to do with the AST found in Python 2.5. This is also the reason for the functions' keyword arguments being called *ast*, not *st*. - The "ast" functions have been removed in Python 3. + The "ast" functions will be removed in Python 3.0. There are a few things to note about this module which are important to making use of the data structures created. This is not a tutorial on editing the parse @@ -200,7 +200,7 @@ information is omitted if the flag is false or omitted. -.. function:: compilest(ast, filename='') +.. function:: compilest(ast[, filename='']) .. index:: builtin: eval diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/library/pickle.rst --- a/Doc/library/pickle.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/library/pickle.rst Sun Jul 20 10:52:46 2014 -0400 @@ -352,9 +352,8 @@ * classes that are defined at the top level of a module -* instances of such classes whose :attr:`~object.__dict__` or the result of - calling :meth:`__getstate__` is picklable (see section :ref:`pickle-protocol` - for details). +* instances of such classes whose :attr:`__dict__` or :meth:`__setstate__` is + picklable (see section :ref:`pickle-protocol` for details) Attempts to pickle unpicklable objects will raise the :exc:`PicklingError` exception; when this happens, an unspecified number of bytes may have already @@ -365,8 +364,8 @@ Note that functions (built-in and user-defined) are pickled by "fully qualified" name reference, not by value. This means that only the function name is -pickled, along with the name of the module the function is defined in. Neither -the function's code, nor any of its function attributes are pickled. Thus the +pickled, along with the name of the module the function is defined in. Neither the +function's code, nor any of its function attributes are pickled. Thus the defining module must be importable in the unpickling environment, and the module must contain the named object, otherwise an exception will be raised. [#]_ @@ -443,7 +442,7 @@ defines the method :meth:`__getstate__`, it is called and the return state is pickled as the contents for the instance, instead of the contents of the instance's dictionary. If there is no :meth:`__getstate__` method, the - instance's :attr:`~object.__dict__` is pickled. + instance's :attr:`__dict__` is pickled. .. method:: object.__setstate__(state) @@ -511,8 +510,7 @@ * Optionally, the object's state, which will be passed to the object's :meth:`__setstate__` method as described in section :ref:`pickle-inst`. If the object has no :meth:`__setstate__` method, then, as above, the value - must be a dictionary and it will be added to the object's - :attr:`~object.__dict__`. + must be a dictionary and it will be added to the object's :attr:`__dict__`. * Optionally, an iterator (and not a sequence) yielding successive list items. These list items will be pickled, and appended to the object using @@ -570,20 +568,19 @@ functions on the pickler and unpickler. [#]_ To define external persistent id resolution, you need to set the -:attr:`~Pickler.persistent_id` attribute of the pickler object and the -:attr:`~Unpickler.persistent_load` attribute of the unpickler object. +:attr:`persistent_id` attribute of the pickler object and the +:attr:`persistent_load` attribute of the unpickler object. To pickle objects that have an external persistent id, the pickler must have a -custom :func:`~Pickler.persistent_id` method that takes an object as an -argument and returns either ``None`` or the persistent id for that object. -When ``None`` is returned, the pickler simply pickles the object as normal. -When a persistent id string is returned, the pickler will pickle that string, -along with a marker so that the unpickler will recognize the string as a -persistent id. +custom :func:`persistent_id` method that takes an object as an argument and +returns either ``None`` or the persistent id for that object. When ``None`` is +returned, the pickler simply pickles the object as normal. When a persistent id +string is returned, the pickler will pickle that string, along with a marker so +that the unpickler will recognize the string as a persistent id. To unpickle external objects, the unpickler must have a custom -:func:`~Unpickler.persistent_load` function that takes a persistent id string -and returns the referenced object. +:func:`persistent_load` function that takes a persistent id string and returns +the referenced object. Here's a silly example that *might* shed more light:: @@ -633,14 +630,13 @@ j = up.load() print j -In the :mod:`cPickle` module, the unpickler's :attr:`~Unpickler.persistent_load` -attribute can also be set to a Python list, in which case, when the unpickler -reaches a persistent id, the persistent id string will simply be appended to -this list. This functionality exists so that a pickle data stream can be -"sniffed" for object references without actually instantiating all the objects -in a pickle. -[#]_ Setting :attr:`~Unpickler.persistent_load` to a list is usually used in -conjunction with the :meth:`~Unpickler.noload` method on the Unpickler. +In the :mod:`cPickle` module, the unpickler's :attr:`persistent_load` attribute +can also be set to a Python list, in which case, when the unpickler reaches a +persistent id, the persistent id string will simply be appended to this list. +This functionality exists so that a pickle data stream can be "sniffed" for +object references without actually instantiating all the objects in a pickle. +[#]_ Setting :attr:`persistent_load` to a list is usually used in conjunction +with the :meth:`noload` method on the Unpickler. .. BAW: Both pickle and cPickle support something called inst_persistent_id() which appears to give unknown types a second shot at producing a persistent @@ -678,13 +674,13 @@ you're right. Refer to the source code to make this work. Things are a little cleaner with :mod:`cPickle`, but not by much. To control -what gets unpickled, you can set the unpickler's :attr:`~Unpickler.find_global` -attribute to a function or ``None``. If it is ``None`` then any attempts to -unpickle instances will raise an :exc:`UnpicklingError`. If it is a function, -then it should accept a module name and a class name, and return the -corresponding class object. It is responsible for looking up the class and -performing any necessary imports, and it may raise an error to prevent -instances of the class from being unpickled. +what gets unpickled, you can set the unpickler's :attr:`find_global` attribute +to a function or ``None``. If it is ``None`` then any attempts to unpickle +instances will raise an :exc:`UnpicklingError`. If it is a function, then it +should accept a module name and a class name, and return the corresponding class +object. It is responsible for looking up the class and performing any necessary +imports, and it may raise an error to prevent instances of the class from being +unpickled. The moral of the story is that you should be really careful about the source of the strings your application unpickles. @@ -735,7 +731,7 @@ Here's a larger example that shows how to modify pickling behavior for a class. The :class:`TextReader` class opens a text file, and returns the line number and -line contents each time its :meth:`!readline` method is called. If a +line contents each time its :meth:`readline` method is called. If a :class:`TextReader` instance is pickled, all attributes *except* the file object member are saved. When the instance is unpickled, the file is reopened, and reading resumes from the last location. The :meth:`__setstate__` and diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/library/pickletools.rst --- a/Doc/library/pickletools.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/library/pickletools.rst Sun Jul 20 10:52:46 2014 -0400 @@ -20,7 +20,7 @@ probably won't find the :mod:`pickletools` module relevant. -.. function:: dis(pickle, out=None, memo=None, indentlevel=4) +.. function:: dis(pickle[, out=None, memo=None, indentlevel=4]) Outputs a symbolic disassembly of the pickle to the file-like object *out*, defaulting to ``sys.stdout``. *pickle* can be a string or a file-like object. diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/library/pipes.rst --- a/Doc/library/pipes.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/library/pipes.rst Sun Jul 20 10:52:46 2014 -0400 @@ -16,6 +16,8 @@ Because the module uses :program:`/bin/sh` command lines, a POSIX or compatible shell for :func:`os.system` and :func:`os.popen` is required. +The :mod:`pipes` module defines the following class: + .. class:: Template() @@ -24,52 +26,15 @@ Example:: >>> import pipes - >>> t = pipes.Template() + >>> t=pipes.Template() >>> t.append('tr a-z A-Z', '--') - >>> f = t.open('pipefile', 'w') + >>> f=t.open('/tmp/1', 'w') >>> f.write('hello world') >>> f.close() - >>> open('pipefile').read() + >>> open('/tmp/1').read() 'HELLO WORLD' -.. function:: quote(s) - - .. deprecated:: 2.7 - Prior to Python 2.7, this function was not publicly documented. It is - finally exposed publicly in Python 3.3 as the - :func:`quote ` function in the :mod:`shlex` module. - - Return a shell-escaped version of the string *s*. The returned value is a - string that can safely be used as one token in a shell command line, for - cases where you cannot use a list. - - This idiom would be unsafe:: - - >>> filename = 'somefile; rm -rf ~' - >>> command = 'ls -l {}'.format(filename) - >>> print command # executed by a shell: boom! - ls -l somefile; rm -rf ~ - - :func:`quote` lets you plug the security hole:: - - >>> command = 'ls -l {}'.format(quote(filename)) - >>> print command - ls -l 'somefile; rm -rf ~' - >>> remote_command = 'ssh home {}'.format(quote(command)) - >>> print remote_command - ssh home 'ls -l '"'"'somefile; rm -rf ~'"'"'' - - The quoting is compatible with UNIX shells and with :func:`shlex.split`: - - >>> remote_command = shlex.split(remote_command) - >>> remote_command - ['ssh', 'home', "ls -l 'somefile; rm -rf ~'"] - >>> command = shlex.split(remote_command[-1]) - >>> command - ['ls', '-l', 'somefile; rm -rf ~'] - - .. _template-objects: Template Objects diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/library/platform.rst --- a/Doc/library/platform.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/library/platform.rst Sun Jul 20 10:52:46 2014 -0400 @@ -33,8 +33,8 @@ returned as strings. Values that cannot be determined are returned as given by the parameter presets. - If bits is given as ``''``, the :c:func:`sizeof(pointer)` (or - :c:func:`sizeof(long)` on Python version < 1.5.2) is used as indicator for the + If bits is given as ``''``, the :cfunc:`sizeof(pointer)` (or + :cfunc:`sizeof(long)` on Python version < 1.5.2) is used as indicator for the supported pointer size. The function relies on the system's :file:`file` command to do the actual work. @@ -197,8 +197,8 @@ .. function:: win32_ver(release='', version='', csd='', ptype='') Get additional version information from the Windows Registry and return a tuple - ``(release, version, csd, ptype)`` referring to OS release, version number, - CSD level (service pack) and OS type (multi/single processor). + ``(version, csd, ptype)`` referring to version number, CSD level and OS type + (multi/single processor). As a hint: *ptype* is ``'Uniprocessor Free'`` on single processor NT machines and ``'Multiprocessor Free'`` on multi processor machines. The *'Free'* refers diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/library/plistlib.rst --- a/Doc/library/plistlib.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/library/plistlib.rst Sun Jul 20 10:52:46 2014 -0400 @@ -74,7 +74,7 @@ -.. function:: readPlistFromResource(path, restype='plst', resid=0) +.. function:: readPlistFromResource(path[, restype='plst'[, resid=0]]) Read a plist from the resource with type *restype* from the resource fork of *path*. Availability: Mac OS X. @@ -84,7 +84,7 @@ In Python 3.x, this function has been removed. -.. function:: writePlistToResource(rootObject, path, restype='plst', resid=0) +.. function:: writePlistToResource(rootObject, path[, restype='plst'[, resid=0]]) Write *rootObject* as a resource with type *restype* to the resource fork of *path*. Availability: Mac OS X. diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/library/popen2.rst --- a/Doc/library/popen2.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/library/popen2.rst Sun Jul 20 10:52:46 2014 -0400 @@ -104,7 +104,7 @@ Waits for and returns the status code of the child process. The status code encodes both the return code of the process and information about whether it - exited using the :c:func:`exit` system call or died due to a signal. Functions + exited using the :cfunc:`exit` system call or died due to a signal. Functions to help interpret the status code are defined in the :mod:`os` module; see section :ref:`os-process` for the :func:`W\*` family of functions. diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/library/poplib.rst --- a/Doc/library/poplib.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/library/poplib.rst Sun Jul 20 10:52:46 2014 -0400 @@ -24,7 +24,7 @@ mailserver supports IMAP, you would be better off using the :class:`imaplib.IMAP4` class, as IMAP servers tend to be better implemented. -The :mod:`poplib` module provides two classes: +A single class is provided by the :mod:`poplib` module: .. class:: POP3(host[, port[, timeout]]) @@ -102,7 +102,7 @@ .. method:: POP3.pass_(password) Send password, response includes message count and mailbox size. Note: the - mailbox on the server is locked until :meth:`~poplib.quit` is called. + mailbox on the server is locked until :meth:`quit` is called. .. method:: POP3.apop(user, secret) diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/library/posix.rst --- a/Doc/library/posix.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/library/posix.rst Sun Jul 20 10:52:46 2014 -0400 @@ -19,7 +19,7 @@ available through the :mod:`os` interface. Once :mod:`os` is imported, there is *no* performance penalty in using it instead of :mod:`posix`. In addition, :mod:`os` provides some additional functionality, such as automatically calling -:func:`~os.putenv` when an entry in ``os.environ`` is changed. +:func:`putenv` when an entry in ``os.environ`` is changed. Errors are reported as exceptions; the usual exceptions are given for type errors, while errors reported by the system calls raise :exc:`OSError`. @@ -38,13 +38,13 @@ Several operating systems (including AIX, HP-UX, Irix and Solaris) provide support for files that are larger than 2 GB from a C programming model where -:c:type:`int` and :c:type:`long` are 32-bit values. This is typically accomplished +:ctype:`int` and :ctype:`long` are 32-bit values. This is typically accomplished by defining the relevant size and offset types as 64-bit values. Such files are sometimes referred to as :dfn:`large files`. -Large file support is enabled in Python when the size of an :c:type:`off_t` is -larger than a :c:type:`long` and the :c:type:`long long` type is available and is -at least as large as an :c:type:`off_t`. Python longs are then used to represent +Large file support is enabled in Python when the size of an :ctype:`off_t` is +larger than a :ctype:`long` and the :ctype:`long long` type is available and is +at least as large as an :ctype:`off_t`. Python longs are then used to represent file sizes, offsets and other values that can exceed the range of a Python int. It may be necessary to configure and compile Python with certain compiler flags to enable this mode. For example, it is enabled by default with recent versions @@ -74,10 +74,9 @@ directory, equivalent to ``getenv("HOME")`` in C. Modifying this dictionary does not affect the string environment passed on by - :func:`~os.execv`, :func:`~os.popen` or :func:`~os.system`; if you need to - change the environment, pass ``environ`` to :func:`~os.execve` or add - variable assignments and export statements to the command string for - :func:`~os.system` or :func:`~os.popen`. + :func:`execv`, :func:`popen` or :func:`system`; if you need to change the + environment, pass ``environ`` to :func:`execve` or add variable assignments and + export statements to the command string for :func:`system` or :func:`popen`. .. note:: diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/library/posixfile.rst --- a/Doc/library/posixfile.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/library/posixfile.rst Sun Jul 20 10:52:46 2014 -0400 @@ -181,7 +181,7 @@ import posixfile - file = posixfile.open('testfile', 'w') + file = posixfile.open('/tmp/test', 'w') file.lock('w|') ... file.lock('u') diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/library/pprint.rst --- a/Doc/library/pprint.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/library/pprint.rst Sun Jul 20 10:52:46 2014 -0400 @@ -36,7 +36,7 @@ .. First the implementation class: -.. class:: PrettyPrinter(indent=1, width=80, depth=None, stream=None) +.. class:: PrettyPrinter(...) Construct a :class:`PrettyPrinter` instance. This constructor understands several keyword parameters. An output stream may be set using the *stream* @@ -73,7 +73,9 @@ The :class:`PrettyPrinter` class supports several derivative functions: -.. function:: pformat(object, indent=1, width=80, depth=None) +.. Now the derivative functions: + +.. function:: pformat(object[, indent[, width[, depth]]]) Return the formatted representation of *object* as a string. *indent*, *width* and *depth* will be passed to the :class:`PrettyPrinter` constructor as @@ -83,10 +85,10 @@ The parameters *indent*, *width* and *depth* were added. -.. function:: pprint(object, stream=None, indent=1, width=80, depth=None) +.. function:: pprint(object[, stream[, indent[, width[, depth]]]]) Prints the formatted representation of *object* on *stream*, followed by a - newline. If *stream* is ``None``, ``sys.stdout`` is used. This may be used in + newline. If *stream* is omitted, ``sys.stdout`` is used. This may be used in the interactive interpreter instead of a :keyword:`print` statement for inspecting values. *indent*, *width* and *depth* will be passed to the :class:`PrettyPrinter` constructor as formatting parameters. @@ -204,8 +206,7 @@ pprint Example -------------- -This example demonstrates several uses of the :func:`pprint` function and its -parameters. +This example demonstrates several uses of the :func:`pprint` function and its parameters. >>> import pprint >>> tup = ('spam', ('eggs', ('lumberjack', ('knights', ('ni', ('dead', diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/library/profile.rst --- a/Doc/library/profile.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/library/profile.rst Sun Jul 20 10:52:46 2014 -0400 @@ -4,6 +4,11 @@ The Python Profilers ******************** +.. sectionauthor:: James Roskind + +.. module:: profile + :synopsis: Python source profiler. + **Source code:** :source:`Lib/profile.py` and :source:`Lib/pstats.py` -------------- @@ -17,31 +22,33 @@ single: deterministic profiling single: profiling, deterministic -:mod:`cProfile` and :mod:`profile` provide :dfn:`deterministic profiling` of -Python programs. A :dfn:`profile` is a set of statistics that describes how -often and for how long various parts of the program executed. These statistics -can be formatted into reports via the :mod:`pstats` module. +A :dfn:`profiler` is a program that describes the run time performance +of a program, providing a variety of statistics. This documentation +describes the profiler functionality provided in the modules +:mod:`cProfile`, :mod:`profile` and :mod:`pstats`. This profiler +provides :dfn:`deterministic profiling` of Python programs. It also +provides a series of report generation tools to allow users to rapidly +examine the results of a profile operation. -The Python standard library provides three different implementations of the same -profiling interface: +The Python standard library provides three different profilers: -1. :mod:`cProfile` is recommended for most users; it's a C extension with - reasonable overhead that makes it suitable for profiling long-running - programs. Based on :mod:`lsprof`, contributed by Brett Rosen and Ted - Czotter. +#. :mod:`cProfile` is recommended for most users; it's a C extension + with reasonable overhead + that makes it suitable for profiling long-running programs. + Based on :mod:`lsprof`, + contributed by Brett Rosen and Ted Czotter. .. versionadded:: 2.5 -2. :mod:`profile`, a pure Python module whose interface is imitated by - :mod:`cProfile`, but which adds significant overhead to profiled programs. - If you're trying to extend the profiler in some way, the task might be easier - with this module. +#. :mod:`profile`, a pure Python module whose interface is imitated by + :mod:`cProfile`. Adds significant overhead to profiled programs. + If you're trying to extend + the profiler in some way, the task might be easier with this module. .. versionchanged:: 2.4 - Now also reports the time spent in calls to built-in functions - and methods. + Now also reports the time spent in calls to built-in functions and methods. -3. :mod:`hotshot` was an experimental C module that focused on minimizing +#. :mod:`hotshot` was an experimental C module that focused on minimizing the overhead of profiling, at the expense of longer data post-processing times. It is no longer maintained and may be dropped in a future version of Python. @@ -58,15 +65,6 @@ :mod:`_lsprof` module. The :mod:`hotshot` module is reserved for specialized usage. -.. note:: - - The profiler modules are designed to provide an execution profile for a given - program, not for benchmarking purposes (for that, there is :mod:`timeit` for - reasonably accurate results). This particularly applies to benchmarking - Python code against C code: the profilers introduce overhead for Python code, - but not for C-level functions, and so the C code would seem faster than any - Python one. - .. _profile-instant: @@ -77,94 +75,57 @@ provides a very brief overview, and allows a user to rapidly perform profiling on an existing application. -To profile a function that takes a single argument, you can do:: +To profile an application with a main entry point of :func:`foo`, you would add +the following to your module:: import cProfile - import re - cProfile.run('re.compile("foo|bar")') + cProfile.run('foo()') (Use :mod:`profile` instead of :mod:`cProfile` if the latter is not available on your system.) -The above action would run :func:`re.compile` and print profile results like -the following:: - - 197 function calls (192 primitive calls) in 0.002 seconds - - Ordered by: standard name - - ncalls tottime percall cumtime percall filename:lineno(function) - 1 0.000 0.000 0.001 0.001 :1() - 1 0.000 0.000 0.001 0.001 re.py:212(compile) - 1 0.000 0.000 0.001 0.001 re.py:268(_compile) - 1 0.000 0.000 0.000 0.000 sre_compile.py:172(_compile_charset) - 1 0.000 0.000 0.000 0.000 sre_compile.py:201(_optimize_charset) - 4 0.000 0.000 0.000 0.000 sre_compile.py:25(_identityfunction) - 3/1 0.000 0.000 0.000 0.000 sre_compile.py:33(_compile) - -The first line indicates that 197 calls were monitored. Of those calls, 192 -were :dfn:`primitive`, meaning that the call was not induced via recursion. The -next line: ``Ordered by: standard name``, indicates that the text string in the -far right column was used to sort the output. The column headings include: - -ncalls - for the number of calls, - -tottime - for the total time spent in the given function (and excluding time made in - calls to sub-functions) - -percall - is the quotient of ``tottime`` divided by ``ncalls`` - -cumtime - is the cumulative time spent in this and all subfunctions (from invocation - till exit). This figure is accurate *even* for recursive functions. - -percall - is the quotient of ``cumtime`` divided by primitive calls - -filename:lineno(function) - provides the respective data of each function - -When there are two numbers in the first column (for example ``3/1``), it means -that the function recursed. The second value is the number of primitive calls -and the former is the total number of calls. Note that when the function does -not recurse, these two values are the same, and only the single figure is -printed. - -Instead of printing the output at the end of the profile run, you can save the -results to a file by specifying a filename to the :func:`run` function:: +The above action would cause :func:`foo` to be run, and a series of informative +lines (the profile) to be printed. The above approach is most useful when +working with the interpreter. If you would like to save the results of a +profile into a file for later examination, you can supply a file name as the +second argument to the :func:`run` function:: import cProfile - import re - cProfile.run('re.compile("foo|bar")', 'restats') + cProfile.run('foo()', 'fooprof') -The :class:`pstats.Stats` class reads profile results from a file and formats -them in various ways. - -The file :mod:`cProfile` can also be invoked as a script to profile another +The file :file:`cProfile.py` can also be invoked as a script to profile another script. For example:: - python -m cProfile [-o output_file] [-s sort_order] myscript.py + python -m cProfile myscript.py -``-o`` writes the profile results to a file instead of to stdout +:file:`cProfile.py` accepts two optional arguments on the command line:: -``-s`` specifies one of the :func:`~pstats.Stats.sort_stats` sort values to sort -the output by. This only applies when ``-o`` is not supplied. + cProfile.py [-o output_file] [-s sort_order] -The :mod:`pstats` module's :class:`~pstats.Stats` class has a variety of methods -for manipulating and printing the data saved into a profile results file:: +``-s`` only applies to standard output (``-o`` is not supplied). +Look in the :class:`Stats` documentation for valid sort values. + +When you wish to review the profile, you should use the methods in the +:mod:`pstats` module. Typically you would load the statistics data as follows:: import pstats - p = pstats.Stats('restats') + p = pstats.Stats('fooprof') + +The class :class:`Stats` (the above code just created an instance of this class) +has a variety of methods for manipulating and printing the data that was just +read into ``p``. When you ran :func:`cProfile.run` above, what was printed was +the result of three method calls:: + p.strip_dirs().sort_stats(-1).print_stats() -The :meth:`~pstats.Stats.strip_dirs` method removed the extraneous path from all -the module names. The :meth:`~pstats.Stats.sort_stats` method sorted all the -entries according to the standard module/line/name string that is printed. The -:meth:`~pstats.Stats.print_stats` method printed out all the statistics. You -might try the following sort calls:: +The first method removed the extraneous path from all the module names. The +second method sorted all the entries according to the standard module/line/name +string that is printed. The third method printed out all the statistics. You +might try the following sort calls: + +.. (this is to comply with the semantics of the old profiler). + +:: p.sort_stats('name') p.print_stats() @@ -213,305 +174,12 @@ guess what the following functions do:: p.print_callees() - p.add('restats') + p.add('fooprof') Invoked as a script, the :mod:`pstats` module is a statistics browser for reading and examining profile dumps. It has a simple line-oriented interface (implemented using :mod:`cmd`) and interactive help. -:mod:`profile` and :mod:`cProfile` Module Reference -======================================================= - -.. module:: cProfile -.. module:: profile - :synopsis: Python source profiler. - -Both the :mod:`profile` and :mod:`cProfile` modules provide the following -functions: - -.. function:: run(command, filename=None, sort=-1) - - This function takes a single argument that can be passed to the :func:`exec` - function, and an optional file name. In all cases this routine executes:: - - exec(command, __main__.__dict__, __main__.__dict__) - - and gathers profiling statistics from the execution. If no file name is - present, then this function automatically creates a :class:`~pstats.Stats` - instance and prints a simple profiling report. If the sort value is specified - it is passed to this :class:`~pstats.Stats` instance to control how the - results are sorted. - -.. function:: runctx(command, globals, locals, filename=None) - - This function is similar to :func:`run`, with added arguments to supply the - globals and locals dictionaries for the *command* string. This routine - executes:: - - exec(command, globals, locals) - - and gathers profiling statistics as in the :func:`run` function above. - -.. class:: Profile(timer=None, timeunit=0.0, subcalls=True, builtins=True) - - This class is normally only used if more precise control over profiling is - needed than what the :func:`cProfile.run` function provides. - - A custom timer can be supplied for measuring how long code takes to run via - the *timer* argument. This must be a function that returns a single number - representing the current time. If the number is an integer, the *timeunit* - specifies a multiplier that specifies the duration of each unit of time. For - example, if the timer returns times measured in thousands of seconds, the - time unit would be ``.001``. - - Directly using the :class:`Profile` class allows formatting profile results - without writing the profile data to a file:: - - import cProfile, pstats, StringIO - pr = cProfile.Profile() - pr.enable() - # ... do something ... - pr.disable() - s = StringIO.StringIO() - sortby = 'cumulative' - ps = pstats.Stats(pr, stream=s).sort_stats(sortby) - ps.print_stats() - print s.getvalue() - - .. method:: enable() - - Start collecting profiling data. - - .. method:: disable() - - Stop collecting profiling data. - - .. method:: create_stats() - - Stop collecting profiling data and record the results internally - as the current profile. - - .. method:: print_stats(sort=-1) - - Create a :class:`~pstats.Stats` object based on the current - profile and print the results to stdout. - - .. method:: dump_stats(filename) - - Write the results of the current profile to *filename*. - - .. method:: run(cmd) - - Profile the cmd via :func:`exec`. - - .. method:: runctx(cmd, globals, locals) - - Profile the cmd via :func:`exec` with the specified global and - local environment. - - .. method:: runcall(func, *args, **kwargs) - - Profile ``func(*args, **kwargs)`` - -.. _profile-stats: - -The :class:`Stats` Class -======================== - -Analysis of the profiler data is done using the :class:`~pstats.Stats` class. - -.. module:: pstats - :synopsis: Statistics object for use with the profiler. - -.. class:: Stats(*filenames or profile, stream=sys.stdout) - - This class constructor creates an instance of a "statistics object" from a - *filename* (or list of filenames) or from a :class:`Profile` instance. Output - will be printed to the stream specified by *stream*. - - The file selected by the above constructor must have been created by the - corresponding version of :mod:`profile` or :mod:`cProfile`. To be specific, - there is *no* file compatibility guaranteed with future versions of this - profiler, and there is no compatibility with files produced by other - profilers. If several files are provided, all the statistics for identical - functions will be coalesced, so that an overall view of several processes can - be considered in a single report. If additional files need to be combined - with data in an existing :class:`~pstats.Stats` object, the - :meth:`~pstats.Stats.add` method can be used. - - Instead of reading the profile data from a file, a :class:`cProfile.Profile` - or :class:`profile.Profile` object can be used as the profile data source. - - :class:`Stats` objects have the following methods: - - .. method:: strip_dirs() - - This method for the :class:`Stats` class removes all leading path - information from file names. It is very useful in reducing the size of - the printout to fit within (close to) 80 columns. This method modifies - the object, and the stripped information is lost. After performing a - strip operation, the object is considered to have its entries in a - "random" order, as it was just after object initialization and loading. - If :meth:`~pstats.Stats.strip_dirs` causes two function names to be - indistinguishable (they are on the same line of the same filename, and - have the same function name), then the statistics for these two entries - are accumulated into a single entry. - - - .. method:: add(*filenames) - - This method of the :class:`Stats` class accumulates additional profiling - information into the current profiling object. Its arguments should refer - to filenames created by the corresponding version of :func:`profile.run` - or :func:`cProfile.run`. Statistics for identically named (re: file, line, - name) functions are automatically accumulated into single function - statistics. - - - .. method:: dump_stats(filename) - - Save the data loaded into the :class:`Stats` object to a file named - *filename*. The file is created if it does not exist, and is overwritten - if it already exists. This is equivalent to the method of the same name - on the :class:`profile.Profile` and :class:`cProfile.Profile` classes. - - .. versionadded:: 2.3 - - - .. method:: sort_stats(*keys) - - This method modifies the :class:`Stats` object by sorting it according to - the supplied criteria. The argument is typically a string identifying the - basis of a sort (example: ``'time'`` or ``'name'``). - - When more than one key is provided, then additional keys are used as - secondary criteria when there is equality in all keys selected before - them. For example, ``sort_stats('name', 'file')`` will sort all the - entries according to their function name, and resolve all ties (identical - function names) by sorting by file name. - - Abbreviations can be used for any key names, as long as the abbreviation - is unambiguous. The following are the keys currently defined: - - +------------------+----------------------+ - | Valid Arg | Meaning | - +==================+======================+ - | ``'calls'`` | call count | - +------------------+----------------------+ - | ``'cumulative'`` | cumulative time | - +------------------+----------------------+ - | ``'cumtime'`` | cumulative time | - +------------------+----------------------+ - | ``'file'`` | file name | - +------------------+----------------------+ - | ``'filename'`` | file name | - +------------------+----------------------+ - | ``'module'`` | file name | - +------------------+----------------------+ - | ``'ncalls'`` | call count | - +------------------+----------------------+ - | ``'pcalls'`` | primitive call count | - +------------------+----------------------+ - | ``'line'`` | line number | - +------------------+----------------------+ - | ``'name'`` | function name | - +------------------+----------------------+ - | ``'nfl'`` | name/file/line | - +------------------+----------------------+ - | ``'stdname'`` | standard name | - +------------------+----------------------+ - | ``'time'`` | internal time | - +------------------+----------------------+ - | ``'tottime'`` | internal time | - +------------------+----------------------+ - - Note that all sorts on statistics are in descending order (placing most - time consuming items first), where as name, file, and line number searches - are in ascending order (alphabetical). The subtle distinction between - ``'nfl'`` and ``'stdname'`` is that the standard name is a sort of the - name as printed, which means that the embedded line numbers get compared - in an odd way. For example, lines 3, 20, and 40 would (if the file names - were the same) appear in the string order 20, 3 and 40. In contrast, - ``'nfl'`` does a numeric compare of the line numbers. In fact, - ``sort_stats('nfl')`` is the same as ``sort_stats('name', 'file', - 'line')``. - - For backward-compatibility reasons, the numeric arguments ``-1``, ``0``, - ``1``, and ``2`` are permitted. They are interpreted as ``'stdname'``, - ``'calls'``, ``'time'``, and ``'cumulative'`` respectively. If this old - style format (numeric) is used, only one sort key (the numeric key) will - be used, and additional arguments will be silently ignored. - - .. For compatibility with the old profiler. - - - .. method:: reverse_order() - - This method for the :class:`Stats` class reverses the ordering of the - basic list within the object. Note that by default ascending vs - descending order is properly selected based on the sort key of choice. - - .. This method is provided primarily for compatibility with the old - profiler. - - - .. method:: print_stats(*restrictions) - - This method for the :class:`Stats` class prints out a report as described - in the :func:`profile.run` definition. - - The order of the printing is based on the last - :meth:`~pstats.Stats.sort_stats` operation done on the object (subject to - caveats in :meth:`~pstats.Stats.add` and - :meth:`~pstats.Stats.strip_dirs`). - - The arguments provided (if any) can be used to limit the list down to the - significant entries. Initially, the list is taken to be the complete set - of profiled functions. Each restriction is either an integer (to select a - count of lines), or a decimal fraction between 0.0 and 1.0 inclusive (to - select a percentage of lines), or a regular expression (to pattern match - the standard name that is printed. If several restrictions are provided, - then they are applied sequentially. For example:: - - print_stats(.1, 'foo:') - - would first limit the printing to first 10% of list, and then only print - functions that were part of filename :file:`.\*foo:`. In contrast, the - command:: - - print_stats('foo:', .1) - - would limit the list to all functions having file names :file:`.\*foo:`, - and then proceed to only print the first 10% of them. - - - .. method:: print_callers(*restrictions) - - This method for the :class:`Stats` class prints a list of all functions - that called each function in the profiled database. The ordering is - identical to that provided by :meth:`~pstats.Stats.print_stats`, and the - definition of the restricting argument is also identical. Each caller is - reported on its own line. The format differs slightly depending on the - profiler that produced the stats: - - * With :mod:`profile`, a number is shown in parentheses after each caller - to show how many times this specific call was made. For convenience, a - second non-parenthesized number repeats the cumulative time spent in the - function at the right. - - * With :mod:`cProfile`, each caller is preceded by three numbers: the - number of times this specific call was made, and the total and - cumulative times spent in the current function while it was invoked by - this specific caller. - - - .. method:: print_callees(*restrictions) - - This method for the :class:`Stats` class prints a list of all function - that were called by the indicated function. Aside from this reversal of - direction of calls (re: called vs was called by), the arguments and - ordering are identical to the :meth:`~pstats.Stats.print_callers` method. - .. _deterministic-profiling: @@ -546,7 +214,275 @@ implementations. -.. _profile-limitations: +Reference Manual -- :mod:`profile` and :mod:`cProfile` +====================================================== + +.. module:: cProfile + :synopsis: Python profiler + + +The primary entry point for the profiler is the global function +:func:`profile.run` (resp. :func:`cProfile.run`). It is typically used to create +any profile information. The reports are formatted and printed using methods of +the class :class:`pstats.Stats`. The following is a description of all of these +standard entry points and functions. For a more in-depth view of some of the +code, consider reading the later section on Profiler Extensions, which includes +discussion of how to derive "better" profilers from the classes presented, or +reading the source code for these modules. + + +.. function:: run(command[, filename]) + + This function takes a single argument that can be passed to the + :keyword:`exec` statement, and an optional file name. In all cases this + routine attempts to :keyword:`exec` its first argument, and gather profiling + statistics from the execution. If no file name is present, then this function + automatically prints a simple profiling report, sorted by the standard name + string (file/line/function-name) that is presented in each line. The + following is a typical output from such a call:: + + 2706 function calls (2004 primitive calls) in 4.504 CPU seconds + + Ordered by: standard name + + ncalls tottime percall cumtime percall filename:lineno(function) + 2 0.006 0.003 0.953 0.477 pobject.py:75(save_objects) + 43/3 0.533 0.012 0.749 0.250 pobject.py:99(evaluate) + ... + + The first line indicates that 2706 calls were monitored. Of those calls, 2004 + were :dfn:`primitive`. We define :dfn:`primitive` to mean that the call was not + induced via recursion. The next line: ``Ordered by: standard name``, indicates + that the text string in the far right column was used to sort the output. The + column headings include: + + ncalls + for the number of calls, + + tottime + for the total time spent in the given function (and excluding time made in calls + to sub-functions), + + percall + is the quotient of ``tottime`` divided by ``ncalls`` + + cumtime + is the total time spent in this and all subfunctions (from invocation till + exit). This figure is accurate *even* for recursive functions. + + percall + is the quotient of ``cumtime`` divided by primitive calls + + filename:lineno(function) + provides the respective data of each function + + When there are two numbers in the first column (for example, ``43/3``), then the + latter is the number of primitive calls, and the former is the actual number of + calls. Note that when the function does not recurse, these two values are the + same, and only the single figure is printed. + + +.. function:: runctx(command, globals, locals[, filename]) + + This function is similar to :func:`run`, with added arguments to supply the + globals and locals dictionaries for the *command* string. + +Analysis of the profiler data is done using the :class:`Stats` class. + +.. note:: + + The :class:`Stats` class is defined in the :mod:`pstats` module. + + +.. module:: pstats + :synopsis: Statistics object for use with the profiler. + + +.. class:: Stats(filename[, stream=sys.stdout[, ...]]) + + This class constructor creates an instance of a "statistics object" from a + *filename* (or set of filenames). :class:`Stats` objects are manipulated by + methods, in order to print useful reports. You may specify an alternate output + stream by giving the keyword argument, ``stream``. + + The file selected by the above constructor must have been created by the + corresponding version of :mod:`profile` or :mod:`cProfile`. To be specific, + there is *no* file compatibility guaranteed with future versions of this + profiler, and there is no compatibility with files produced by other profilers. + If several files are provided, all the statistics for identical functions will + be coalesced, so that an overall view of several processes can be considered in + a single report. If additional files need to be combined with data in an + existing :class:`Stats` object, the :meth:`add` method can be used. + + .. (such as the old system profiler). + + .. versionchanged:: 2.5 + The *stream* parameter was added. + + +.. _profile-stats: + +The :class:`Stats` Class +------------------------ + +:class:`Stats` objects have the following methods: + + +.. method:: Stats.strip_dirs() + + This method for the :class:`Stats` class removes all leading path information + from file names. It is very useful in reducing the size of the printout to fit + within (close to) 80 columns. This method modifies the object, and the stripped + information is lost. After performing a strip operation, the object is + considered to have its entries in a "random" order, as it was just after object + initialization and loading. If :meth:`strip_dirs` causes two function names to + be indistinguishable (they are on the same line of the same filename, and have + the same function name), then the statistics for these two entries are + accumulated into a single entry. + + +.. method:: Stats.add(filename[, ...]) + + This method of the :class:`Stats` class accumulates additional profiling + information into the current profiling object. Its arguments should refer to + filenames created by the corresponding version of :func:`profile.run` or + :func:`cProfile.run`. Statistics for identically named (re: file, line, name) + functions are automatically accumulated into single function statistics. + + +.. method:: Stats.dump_stats(filename) + + Save the data loaded into the :class:`Stats` object to a file named *filename*. + The file is created if it does not exist, and is overwritten if it already + exists. This is equivalent to the method of the same name on the + :class:`profile.Profile` and :class:`cProfile.Profile` classes. + + .. versionadded:: 2.3 + + +.. method:: Stats.sort_stats(key[, ...]) + + This method modifies the :class:`Stats` object by sorting it according to the + supplied criteria. The argument is typically a string identifying the basis of + a sort (example: ``'time'`` or ``'name'``). + + When more than one key is provided, then additional keys are used as secondary + criteria when there is equality in all keys selected before them. For example, + ``sort_stats('name', 'file')`` will sort all the entries according to their + function name, and resolve all ties (identical function names) by sorting by + file name. + + Abbreviations can be used for any key names, as long as the abbreviation is + unambiguous. The following are the keys currently defined: + + +------------------+----------------------+ + | Valid Arg | Meaning | + +==================+======================+ + | ``'calls'`` | call count | + +------------------+----------------------+ + | ``'cumulative'`` | cumulative time | + +------------------+----------------------+ + | ``'file'`` | file name | + +------------------+----------------------+ + | ``'module'`` | file name | + +------------------+----------------------+ + | ``'pcalls'`` | primitive call count | + +------------------+----------------------+ + | ``'line'`` | line number | + +------------------+----------------------+ + | ``'name'`` | function name | + +------------------+----------------------+ + | ``'nfl'`` | name/file/line | + +------------------+----------------------+ + | ``'stdname'`` | standard name | + +------------------+----------------------+ + | ``'time'`` | internal time | + +------------------+----------------------+ + + Note that all sorts on statistics are in descending order (placing most time + consuming items first), where as name, file, and line number searches are in + ascending order (alphabetical). The subtle distinction between ``'nfl'`` and + ``'stdname'`` is that the standard name is a sort of the name as printed, which + means that the embedded line numbers get compared in an odd way. For example, + lines 3, 20, and 40 would (if the file names were the same) appear in the string + order 20, 3 and 40. In contrast, ``'nfl'`` does a numeric compare of the line + numbers. In fact, ``sort_stats('nfl')`` is the same as ``sort_stats('name', + 'file', 'line')``. + + For backward-compatibility reasons, the numeric arguments ``-1``, ``0``, ``1``, + and ``2`` are permitted. They are interpreted as ``'stdname'``, ``'calls'``, + ``'time'``, and ``'cumulative'`` respectively. If this old style format + (numeric) is used, only one sort key (the numeric key) will be used, and + additional arguments will be silently ignored. + + .. For compatibility with the old profiler, + + +.. method:: Stats.reverse_order() + + This method for the :class:`Stats` class reverses the ordering of the basic list + within the object. Note that by default ascending vs descending order is + properly selected based on the sort key of choice. + + .. This method is provided primarily for compatibility with the old profiler. + + +.. method:: Stats.print_stats([restriction, ...]) + + This method for the :class:`Stats` class prints out a report as described in the + :func:`profile.run` definition. + + The order of the printing is based on the last :meth:`sort_stats` operation done + on the object (subject to caveats in :meth:`add` and :meth:`strip_dirs`). + + The arguments provided (if any) can be used to limit the list down to the + significant entries. Initially, the list is taken to be the complete set of + profiled functions. Each restriction is either an integer (to select a count of + lines), or a decimal fraction between 0.0 and 1.0 inclusive (to select a + percentage of lines), or a regular expression (to pattern match the standard + name that is printed; as of Python 1.5b1, this uses the Perl-style regular + expression syntax defined by the :mod:`re` module). If several restrictions are + provided, then they are applied sequentially. For example:: + + print_stats(.1, 'foo:') + + would first limit the printing to first 10% of list, and then only print + functions that were part of filename :file:`.\*foo:`. In contrast, the + command:: + + print_stats('foo:', .1) + + would limit the list to all functions having file names :file:`.\*foo:`, and + then proceed to only print the first 10% of them. + + +.. method:: Stats.print_callers([restriction, ...]) + + This method for the :class:`Stats` class prints a list of all functions that + called each function in the profiled database. The ordering is identical to + that provided by :meth:`print_stats`, and the definition of the restricting + argument is also identical. Each caller is reported on its own line. The + format differs slightly depending on the profiler that produced the stats: + + * With :mod:`profile`, a number is shown in parentheses after each caller to + show how many times this specific call was made. For convenience, a second + non-parenthesized number repeats the cumulative time spent in the function + at the right. + + * With :mod:`cProfile`, each caller is preceded by three numbers: the number of + times this specific call was made, and the total and cumulative times spent in + the current function while it was invoked by this specific caller. + + +.. method:: Stats.print_callees([restriction, ...]) + + This method for the :class:`Stats` class prints a list of all function that were + called by the indicated function. Aside from this reversal of direction of + calls (re: called vs was called by), the arguments and ordering are identical to + the :meth:`print_callers` method. + + +.. _profile-limits: Limitations =========== @@ -589,7 +525,7 @@ handling time to compensate for the overhead of calling the time function, and socking away the results. By default, the constant is 0. The following procedure can be used to obtain a better constant for a given platform (see -:ref:`profile-limitations`). :: +discussion in section Limitations above). :: import profile pr = profile.Profile() @@ -599,8 +535,8 @@ The method executes the number of Python calls given by the argument, directly and again under the profiler, measuring the time for both. It then computes the hidden overhead per profiler event, and returns that as a float. For example, -on a 1.8Ghz Intel Core i5 running Mac OS X, and using Python's time.clock() as -the timer, the magical number is about 4.04e-6. +on an 800 MHz Pentium running Windows 2000, and using Python's time.clock() as +the timer, the magical number is about 12.5e-6. The object of this exercise is to get a fairly consistent result. If your computer is *very* fast, or your timer function has poor resolution, you might @@ -623,54 +559,61 @@ If you have a choice, you are better off choosing a smaller constant, and then your results will "less often" show up as negative in profile statistics. -.. _profile-timers: -Using a custom timer -==================== +.. _profiler-extensions: -If you want to change how current time is determined (for example, to force use -of wall-clock time or elapsed process time), pass the timing function you want -to the :class:`Profile` class constructor:: +Extensions --- Deriving Better Profilers +======================================== - pr = profile.Profile(your_time_func) +The :class:`Profile` class of both modules, :mod:`profile` and :mod:`cProfile`, +were written so that derived classes could be developed to extend the profiler. +The details are not described here, as doing this successfully requires an +expert understanding of how the :class:`Profile` class works internally. Study +the source code of the module carefully if you want to pursue this. -The resulting profiler will then call ``your_time_func``. Depending on whether -you are using :class:`profile.Profile` or :class:`cProfile.Profile`, -``your_time_func``'s return value will be interpreted differently: +If all you want to do is change how current time is determined (for example, to +force use of wall-clock time or elapsed process time), pass the timing function +you want to the :class:`Profile` class constructor:: + + pr = profile.Profile(your_time_func) + +The resulting profiler will then call :func:`your_time_func`. :class:`profile.Profile` - ``your_time_func`` should return a single number, or a list of numbers whose - sum is the current time (like what :func:`os.times` returns). If the - function returns a single time number, or the list of returned numbers has - length 2, then you will get an especially fast version of the dispatch - routine. + :func:`your_time_func` should return a single number, or a list of numbers whose + sum is the current time (like what :func:`os.times` returns). If the function + returns a single time number, or the list of returned numbers has length 2, then + you will get an especially fast version of the dispatch routine. Be warned that you should calibrate the profiler class for the timer function - that you choose (see :ref:`profile-calibration`). For most machines, a timer - that returns a lone integer value will provide the best results in terms of - low overhead during profiling. (:func:`os.times` is *pretty* bad, as it - returns a tuple of floating point values). If you want to substitute a - better timer in the cleanest fashion, derive a class and hardwire a - replacement dispatch method that best handles your timer call, along with the - appropriate calibration constant. + that you choose. For most machines, a timer that returns a lone integer value + will provide the best results in terms of low overhead during profiling. + (:func:`os.times` is *pretty* bad, as it returns a tuple of floating point + values). If you want to substitute a better timer in the cleanest fashion, + derive a class and hardwire a replacement dispatch method that best handles your + timer call, along with the appropriate calibration constant. :class:`cProfile.Profile` - ``your_time_func`` should return a single number. If it returns integers, - you can also invoke the class constructor with a second argument specifying - the real duration of one unit of time. For example, if - ``your_integer_time_func`` returns times measured in thousands of seconds, + :func:`your_time_func` should return a single number. If it returns plain + integers, you can also invoke the class constructor with a second argument + specifying the real duration of one unit of time. For example, if + :func:`your_integer_time_func` returns times measured in thousands of seconds, you would construct the :class:`Profile` instance as follows:: - pr = cProfile.Profile(your_integer_time_func, 0.001) + pr = profile.Profile(your_integer_time_func, 0.001) As the :mod:`cProfile.Profile` class cannot be calibrated, custom timer - functions should be used with care and should be as fast as possible. For - the best results with a custom timer, it might be necessary to hard-code it - in the C source of the internal :mod:`_lsprof` module. - + functions should be used with care and should be as fast as possible. For the + best results with a custom timer, it might be necessary to hard-code it in the C + source of the internal :mod:`_lsprof` module. .. rubric:: Footnotes -.. [#] Prior to Python 2.2, it was necessary to edit the profiler source code to - embed the bias as a literal number. You still can, but that method is no longer +.. [#] Updated and converted to LaTeX by Guido van Rossum. Further updated by Armin + Rigo to integrate the documentation for the new :mod:`cProfile` module of Python + 2.5. + +.. [#] Prior to Python 2.2, it was necessary to edit the profiler source code to embed + the bias as a literal number. You still can, but that method is no longer described, because no longer needed. + diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/library/pyclbr.rst --- a/Doc/library/pyclbr.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/library/pyclbr.rst Sun Jul 20 10:52:46 2014 -0400 @@ -19,7 +19,7 @@ modules. -.. function:: readmodule(module, path=None) +.. function:: readmodule(module[, path=None]) Read a module and return a dictionary mapping class names to class descriptor objects. The parameter *module* should be the name of a @@ -28,7 +28,7 @@ of ``sys.path``, which is used to locate module source code. -.. function:: readmodule_ex(module, path=None) +.. function:: readmodule_ex(module[, path=None]) Like :func:`readmodule`, but the returned dictionary, in addition to mapping class names to class descriptor objects, also maps top-level diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/library/pyexpat.rst --- a/Doc/library/pyexpat.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/library/pyexpat.rst Sun Jul 20 10:52:46 2014 -0400 @@ -14,14 +14,6 @@ directive. Since they are attributes which are set by client code, in-text references to these attributes should be marked using the :member: role. - -.. warning:: - - The :mod:`pyexpat` module is not secure against maliciously - constructed data. If you need to parse untrusted or unauthenticated data see - :ref:`xml-vulnerabilities`. - - .. versionadded:: 2.0 .. index:: single: Expat @@ -103,10 +95,6 @@ http://www.python.org/ns/ elem1 elem2 - Due to limitations in the ``Expat`` library used by :mod:`pyexpat`, - the :class:`xmlparser` instance returned can only be used to parse a single - XML document. Call ``ParserCreate`` for each document to provide unique - parser instances. .. seealso:: @@ -126,9 +114,7 @@ Parses the contents of the string *data*, calling the appropriate handler functions to process the parsed data. *isfinal* must be true on the final call - to this method; it allows the parsing of a single file in fragments, - not the submission of multiple files. - *data* can be the empty string at any time. + to this method. *data* can be the empty string at any time. .. method:: xmlparser.ParseFile(file) @@ -451,7 +437,7 @@ .. method:: xmlparser.CommentHandler(data) Called for comments. *data* is the text of the comment, excluding the leading - ``''``. + '````'. .. method:: xmlparser.StartCdataSectionHandler() @@ -912,5 +898,5 @@ .. [#] The encoding string included in XML output should conform to the appropriate standards. For example, "UTF-8" is valid, but "UTF8" is not. See http://www.w3.org/TR/2006/REC-xml11-20060816/#NT-EncodingDecl - and http://www.iana.org/assignments/character-sets\ . + and http://www.iana.org/assignments/character-sets . diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/library/queue.rst --- a/Doc/library/queue.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/library/queue.rst Sun Jul 20 10:52:46 2014 -0400 @@ -5,9 +5,9 @@ :synopsis: A synchronized queue class. .. note:: - The :mod:`Queue` module has been renamed to :mod:`queue` in Python 3. The + The :mod:`Queue` module has been renamed to :mod:`queue` in Python 3.0. The :term:`2to3` tool will automatically adapt imports when converting your - sources to Python 3. + sources to 3.0. **Source code:** :source:`Lib/Queue.py` @@ -20,8 +20,8 @@ availability of thread support in Python; see the :mod:`threading` module. -The module implements three types of queue, which differ only in the order in -which the entries are retrieved. In a FIFO queue, the first tasks added are +Implements three types of queue whose only difference is the order that +the entries are retrieved. In a FIFO queue, the first tasks added are the first retrieved. In a LIFO queue, the most recently added entry is the first retrieved (operating like a stack). With a priority queue, the entries are kept sorted (using the :mod:`heapq` module) and the @@ -60,15 +60,13 @@ .. exception:: Empty - Exception raised when non-blocking :meth:`~Queue.get` (or - :meth:`~Queue.get_nowait`) is called + Exception raised when non-blocking :meth:`get` (or :meth:`get_nowait`) is called on a :class:`Queue` object which is empty. .. exception:: Full - Exception raised when non-blocking :meth:`~Queue.put` (or - :meth:`~Queue.put_nowait`) is called + Exception raised when non-blocking :meth:`put` (or :meth:`put_nowait`) is called on a :class:`Queue` object which is full. .. seealso:: diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/library/random.rst --- a/Doc/library/random.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/library/random.rst Sun Jul 20 10:52:46 2014 -0400 @@ -60,13 +60,6 @@ uses the system function :func:`os.urandom` to generate random numbers from sources provided by the operating system. -.. warning:: - - The pseudo-random generators of this module should not be used for - security purposes. Use :func:`os.urandom` or :class:`SystemRandom` if - you require a cryptographically secure pseudo-random number generator. - - Bookkeeping functions: @@ -97,7 +90,7 @@ *state* should have been obtained from a previous call to :func:`getstate`, and :func:`setstate` restores the internal state of the generator to what it was at - the time :func:`getstate` was called. + the time :func:`setstate` was called. .. versionadded:: 2.1 @@ -131,8 +124,7 @@ Functions for integers: -.. function:: randrange(stop) - randrange(start, stop[, step]) +.. function:: randrange([start,] stop[, step]) Return a randomly selected element from ``range(start, stop, step)``. This is equivalent to ``choice(range(start, stop, step))``, but doesn't actually build a diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/library/re.rst --- a/Doc/library/re.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/library/re.rst Sun Jul 20 10:52:46 2014 -0400 @@ -237,32 +237,21 @@ ``(?P...)`` Similar to regular parentheses, but the substring matched by the group is - accessible via the symbolic group name *name*. Group names must be valid - Python identifiers, and each group name must be defined only once within a - regular expression. A symbolic group is also a numbered group, just as if - the group were not named. + accessible within the rest of the regular expression via the symbolic group + name *name*. Group names must be valid Python identifiers, and each group + name must be defined only once within a regular expression. A symbolic group + is also a numbered group, just as if the group were not named. So the group + named ``id`` in the example below can also be referenced as the numbered group + ``1``. - Named groups can be referenced in three contexts. If the pattern is - ``(?P['"]).*?(?P=quote)`` (i.e. matching a string quoted with either - single or double quotes): - - +---------------------------------------+----------------------------------+ - | Context of reference to group "quote" | Ways to reference it | - +=======================================+==================================+ - | in the same pattern itself | * ``(?P=quote)`` (as shown) | - | | * ``\1`` | - +---------------------------------------+----------------------------------+ - | when processing match object ``m`` | * ``m.group('quote')`` | - | | * ``m.end('quote')`` (etc.) | - +---------------------------------------+----------------------------------+ - | in a string passed to the ``repl`` | * ``\g`` | - | argument of ``re.sub()`` | * ``\g<1>`` | - | | * ``\1`` | - +---------------------------------------+----------------------------------+ + For example, if the pattern is ``(?P[a-zA-Z_]\w*)``, the group can be + referenced by its name in arguments to methods of match objects, such as + ``m.group('id')`` or ``m.end('id')``, and also by name in the regular + expression itself (using ``(?P=id)``) and replacement text given to + ``.sub()`` (using ``\g``). ``(?P=name)`` - A backreference to a named group; it matches whatever text was matched by the - earlier group named *name*. + Matches whatever text was matched by the earlier group named *name*. ``(?#...)`` A comment; the contents of the parentheses are simply ignored. @@ -284,7 +273,7 @@ lookbehind will back up 3 characters and check if the contained pattern matches. The contained pattern must only match strings of some fixed length, meaning that ``abc`` or ``a|b`` are allowed, but ``a*`` and ``a{3,4}`` are not. Note that - patterns which start with positive lookbehind assertions will not match at the + patterns which start with positive lookbehind assertions will never match at the beginning of the string being searched; you will most likely want to use the :func:`search` function rather than the :func:`match` function: @@ -322,7 +311,7 @@ ``\number`` Matches the contents of the group of the same number. Groups are numbered starting from 1. For example, ``(.+) \1`` matches ``'the the'`` or ``'55 55'``, - but not ``'thethe'`` (note the space after the group). This special sequence + but not ``'the end'`` (note the space after the group). This special sequence can only be used to match one of the first 99 groups. If the first digit of *number* is 0, or *number* is 3 octal digits long, it will not be interpreted as a group match, but as the character with octal value *number*. Inside the @@ -336,20 +325,14 @@ Matches the empty string, but only at the beginning or end of a word. A word is defined as a sequence of alphanumeric or underscore characters, so the end of a word is indicated by whitespace or a non-alphanumeric, non-underscore character. - Note that formally, ``\b`` is defined as the boundary between a ``\w`` and - a ``\W`` character (or vice versa), or between ``\w`` and the beginning/end - of the string, so the precise set of characters deemed to be alphanumeric - depends on the values of the ``UNICODE`` and ``LOCALE`` flags. - For example, ``r'\bfoo\b'`` matches ``'foo'``, ``'foo.'``, ``'(foo)'``, - ``'bar foo baz'`` but not ``'foobar'`` or ``'foo3'``. - Inside a character range, ``\b`` represents the backspace character, for - compatibility with Python's string literals. + Note that ``\b`` is defined as the boundary between ``\w`` and ``\W``, so the + precise set of characters deemed to be alphanumeric depends on the values of the + ``UNICODE`` and ``LOCALE`` flags. Inside a character range, ``\b`` represents + the backspace character, for compatibility with Python's string literals. ``\B`` Matches the empty string, but only when it is *not* at the beginning or end of a - word. This means that ``r'py\B'`` matches ``'python'``, ``'py3'``, ``'py2'``, - but not ``'py'``, ``'py.'``, or ``'py!'``. - ``\B`` is just the opposite of ``\b``, so is also subject to the settings + word. This is just the opposite of ``\b``, so is also subject to the settings of ``LOCALE`` and ``UNICODE``. ``\d`` @@ -365,20 +348,20 @@ character properties database. ``\s`` - When the :const:`UNICODE` flag is not specified, it matches any whitespace - character, this is equivalent to the set ``[ \t\n\r\f\v]``. The - :const:`LOCALE` flag has no extra effect on matching of the space. - If :const:`UNICODE` is set, this will match the characters ``[ \t\n\r\f\v]`` - plus whatever is classified as space in the Unicode character properties - database. + When the :const:`LOCALE` and :const:`UNICODE` flags are not specified, matches + any whitespace character; this is equivalent to the set ``[ \t\n\r\f\v]``. With + :const:`LOCALE`, it will match this set plus whatever characters are defined as + space for the current locale. If :const:`UNICODE` is set, this will match the + characters ``[ \t\n\r\f\v]`` plus whatever is classified as space in the Unicode + character properties database. ``\S`` - When the :const:`UNICODE` flags is not specified, matches any non-whitespace - character; this is equivalent to the set ``[^ \t\n\r\f\v]`` The - :const:`LOCALE` flag has no extra effect on non-whitespace match. If - :const:`UNICODE` is set, then any character not marked as space in the - Unicode character properties database is matched. - + When the :const:`LOCALE` and :const:`UNICODE` flags are not specified, matches + any non-whitespace character; this is equivalent to the set ``[^ \t\n\r\f\v]`` + With :const:`LOCALE`, it will match any character not in this set, and not + defined as space in the current locale. If :const:`UNICODE` is set, this will + match anything other than ``[ \t\n\r\f\v]`` and characters marked as space in + the Unicode character properties database. ``\w`` When the :const:`LOCALE` and :const:`UNICODE` flags are not specified, matches @@ -393,16 +376,12 @@ any non-alphanumeric character; this is equivalent to the set ``[^a-zA-Z0-9_]``. With :const:`LOCALE`, it will match any character not in the set ``[0-9_]``, and not defined as alphanumeric for the current locale. If :const:`UNICODE` is set, - this will match anything other than ``[0-9_]`` plus characters classied as - not alphanumeric in the Unicode character properties database. + this will match anything other than ``[0-9_]`` and characters marked as + alphanumeric in the Unicode character properties database. ``\Z`` Matches only at the end of the string. -If both :const:`LOCALE` and :const:`UNICODE` flags are included for a -particular sequence, then :const:`LOCALE` flag takes effect first followed by -the :const:`UNICODE`. - Most of the standard escapes supported by Python string literals are also accepted by the regular expression parser:: @@ -410,15 +389,37 @@ \r \t \v \x \\ -(Note that ``\b`` is used to represent word boundaries, and means "backspace" -only inside character classes.) - Octal escapes are included in a limited form: If the first digit is a 0, or if there are three octal digits, it is considered an octal escape. Otherwise, it is a group reference. As for string literals, octal escapes are always at most three digits in length. +.. _matching-searching: + +Matching vs Searching +--------------------- + +.. sectionauthor:: Fred L. Drake, Jr. + + +Python offers two different primitive operations based on regular expressions: +**match** checks for a match only at the beginning of the string, while +**search** checks for a match anywhere in the string (this is what Perl does +by default). + +Note that match may differ from search even when using a regular expression +beginning with ``'^'``: ``'^'`` matches only at the start of the string, or in +:const:`MULTILINE` mode also immediately following a newline. The "match" +operation succeeds only if the pattern matches at the start of the string +regardless of mode, or at the starting position given by the optional *pos* +argument regardless of whether a newline precedes it. + + >>> re.match("c", "abcdef") # No match + >>> re.search("c", "abcdef") # Match + <_sre.SRE_Match object at ...> + + .. _contents-of-module-re: Module Contents @@ -433,8 +434,8 @@ .. function:: compile(pattern, flags=0) Compile a regular expression pattern into a regular expression object, which - can be used for matching using its :func:`~RegexObject.match` and - :func:`~RegexObject.search` methods, described below. + can be used for matching using its :func:`match` and :func:`search` methods, + described below. The expression's behaviour can be modified by specifying a *flags* value. Values can be any of the following variables, combined using bitwise OR (the @@ -461,11 +462,6 @@ about compiling regular expressions. -.. data:: DEBUG - - Display debug information about compiled expression. - - .. data:: I IGNORECASE @@ -527,7 +523,7 @@ .. function:: search(pattern, string, flags=0) - Scan through *string* looking for the first location where the regular expression + Scan through *string* looking for a location where the regular expression *pattern* produces a match, and return a corresponding :class:`MatchObject` instance. Return ``None`` if no position in the string matches the pattern; note that this is different from finding a zero-length match at some point in the @@ -541,11 +537,10 @@ Return ``None`` if the string does not match the pattern; note that this is different from a zero-length match. - Note that even in :const:`MULTILINE` mode, :func:`re.match` will only match - at the beginning of the string and not at the beginning of each line. + .. note:: - If you want to locate a match anywhere in *string*, use :func:`search` - instead (see also :ref:`search-vs-match`). + If you want to locate a match anywhere in *string*, use :func:`search` + instead. .. function:: split(pattern, string, maxsplit=0, flags=0) @@ -654,8 +649,7 @@ when not adjacent to a previous match, so ``sub('x*', '-', 'abc')`` returns ``'-a-b-c-'``. - In string-type *repl* arguments, in addition to the character escapes and - backreferences described above, + In addition to character escapes and backreferences as described above, ``\g`` will use the substring matched by the group named ``name``, as defined by the ``(?P...)`` syntax. ``\g`` uses the corresponding group number; ``\g<2>`` is therefore equivalent to ``\2``, but isn't ambiguous @@ -742,14 +736,16 @@ The optional *pos* and *endpos* parameters have the same meaning as for the :meth:`~RegexObject.search` method. + .. note:: + + If you want to locate a match anywhere in *string*, use + :meth:`~RegexObject.search` instead. + >>> pattern = re.compile("o") >>> pattern.match("dog") # No match as "o" is not at the start of "dog". >>> pattern.match("dog", 1) # Match as "o" is the 2nd character of "dog". <_sre.SRE_Match object at ...> - If you want to locate a match anywhere in *string*, use - :meth:`~RegexObject.search` instead (see also :ref:`search-vs-match`). - .. method:: RegexObject.split(string, maxsplit=0) @@ -782,8 +778,8 @@ .. attribute:: RegexObject.flags - The regex matching flags. This is a combination of the flags given to - :func:`.compile` and any ``(?...)`` inline flags in the pattern. + The flags argument used when the RE object was compiled, or ``0`` if no flags + were provided. .. attribute:: RegexObject.groups @@ -810,16 +806,9 @@ .. class:: MatchObject - Match objects always have a boolean value of ``True``. - Since :meth:`~regex.match` and :meth:`~regex.search` return ``None`` - when there is no match, you can test whether there was a match with a simple - ``if`` statement:: - - match = re.search(pattern, string) - if match: - process(match) - - Match objects support the following methods and attributes: + Match Objects always have a boolean value of :const:`True`, so that you can test + whether e.g. :func:`match` resulted in a match with a simple if statement. They + support the following methods and attributes: .. method:: MatchObject.expand(template) @@ -1011,16 +1000,16 @@ Suppose you are writing a poker program where a player's hand is represented as a 5-character string with each character representing a card, "a" for ace, "k" -for king, "q" for queen, "j" for jack, "t" for 10, and "2" through "9" +for king, "q" for queen, j for jack, "0" for 10, and "1" through "9" representing the card with that value. To see if a given string is a valid hand, one could do the following: - >>> valid = re.compile(r"^[a2-9tjqk]{5}$") - >>> displaymatch(valid.match("akt5q")) # Valid. - "" - >>> displaymatch(valid.match("akt5e")) # Invalid. - >>> displaymatch(valid.match("akt")) # Invalid. + >>> valid = re.compile(r"[0-9akqj]{5}$") + >>> displaymatch(valid.match("ak05q")) # Valid. + "" + >>> displaymatch(valid.match("ak05e")) # Invalid. + >>> displaymatch(valid.match("ak0")) # Invalid. >>> displaymatch(valid.match("727ak")) # Valid. "" @@ -1059,14 +1048,14 @@ .. index:: single: scanf() -Python does not currently have an equivalent to :c:func:`scanf`. Regular +Python does not currently have an equivalent to :cfunc:`scanf`. Regular expressions are generally more powerful, though also more verbose, than -:c:func:`scanf` format strings. The table below offers some more-or-less -equivalent mappings between :c:func:`scanf` format tokens and regular +:cfunc:`scanf` format strings. The table below offers some more-or-less +equivalent mappings between :cfunc:`scanf` format tokens and regular expressions. +--------------------------------+---------------------------------------------+ -| :c:func:`scanf` Token | Regular Expression | +| :cfunc:`scanf` Token | Regular Expression | +================================+=============================================+ | ``%c`` | ``.`` | +--------------------------------+---------------------------------------------+ @@ -1078,20 +1067,20 @@ +--------------------------------+---------------------------------------------+ | ``%i`` | ``[-+]?(0[xX][\dA-Fa-f]+|0[0-7]*|\d+)`` | +--------------------------------+---------------------------------------------+ -| ``%o`` | ``[-+]?[0-7]+`` | +| ``%o`` | ``0[0-7]*`` | +--------------------------------+---------------------------------------------+ | ``%s`` | ``\S+`` | +--------------------------------+---------------------------------------------+ | ``%u`` | ``\d+`` | +--------------------------------+---------------------------------------------+ -| ``%x``, ``%X`` | ``[-+]?(0[xX])?[\dA-Fa-f]+`` | +| ``%x``, ``%X`` | ``0[xX][\dA-Fa-f]+`` | +--------------------------------+---------------------------------------------+ To extract the filename and numbers from a string like :: /usr/sbin/sendmail - 0 errors, 4 warnings -you would use a :c:func:`scanf` format like :: +you would use a :cfunc:`scanf` format like :: %s - %d errors, %d warnings @@ -1100,39 +1089,59 @@ (\S+) - (\d+) errors, (\d+) warnings -.. _search-vs-match: +Avoiding recursion +^^^^^^^^^^^^^^^^^^ + +If you create regular expressions that require the engine to perform a lot of +recursion, you may encounter a :exc:`RuntimeError` exception with the message +``maximum recursion limit`` exceeded. For example, :: + + >>> s = 'Begin ' + 1000*'a very long string ' + 'end' + >>> re.match('Begin (\w| )*? end', s).end() + Traceback (most recent call last): + File "", line 1, in ? + File "/usr/local/lib/python2.5/re.py", line 132, in match + return _compile(pattern, flags).match(string) + RuntimeError: maximum recursion limit exceeded + +You can often restructure your regular expression to avoid recursion. + +Starting with Python 2.3, simple uses of the ``*?`` pattern are special-cased to +avoid recursion. Thus, the above regular expression can avoid recursion by +being recast as ``Begin [a-zA-Z0-9_ ]*?end``. As a further benefit, such +regular expressions will run faster than their recursive equivalents. + search() vs. match() ^^^^^^^^^^^^^^^^^^^^ -.. sectionauthor:: Fred L. Drake, Jr. +In a nutshell, :func:`match` only attempts to match a pattern at the beginning +of a string where :func:`search` will match a pattern anywhere in a string. +For example: -Python offers two different primitive operations based on regular expressions: -:func:`re.match` checks for a match only at the beginning of the string, while -:func:`re.search` checks for a match anywhere in the string (this is what Perl -does by default). - -For example:: - - >>> re.match("c", "abcdef") # No match - >>> re.search("c", "abcdef") # Match + >>> re.match("o", "dog") # No match as "o" is not the first letter of "dog". + >>> re.search("o", "dog") # Match as search() looks everywhere in the string. <_sre.SRE_Match object at ...> -Regular expressions beginning with ``'^'`` can be used with :func:`search` to -restrict the match at the beginning of the string:: +.. note:: - >>> re.match("c", "abcdef") # No match - >>> re.search("^c", "abcdef") # No match - >>> re.search("^a", "abcdef") # Match + The following applies only to regular expression objects like those created + with ``re.compile("pattern")``, not the primitives ``re.match(pattern, + string)`` or ``re.search(pattern, string)``. + +:func:`match` has an optional second parameter that gives an index in the string +where the search is to start:: + + >>> pattern = re.compile("o") + >>> pattern.match("dog") # No match as "o" is not at the start of "dog." + + # Equivalent to the above expression as 0 is the default starting index: + >>> pattern.match("dog", 0) + + # Match as "o" is the 2nd character of "dog" (index 0 is the first): + >>> pattern.match("dog", 1) <_sre.SRE_Match object at ...> - -Note however that in :const:`MULTILINE` mode :func:`match` only matches at the -beginning of the string, whereas using :func:`search` with a regular expression -beginning with ``'^'`` will match at the beginning of each line. - - >>> re.match('X', 'A\nB\nX', re.MULTILINE) # No match - >>> re.search('^X', 'A\nB\nX', re.MULTILINE) # Match - <_sre.SRE_Match object at ...> + >>> pattern.match("dog", 2) # No match as "o" is not the 3rd character of "dog." Making a Phonebook @@ -1146,7 +1155,7 @@ First, here is the input. Normally it may come from a file, here we are using triple-quoted string syntax: - >>> text = """Ross McFluff: 834.345.1254 155 Elm Street + >>> input = """Ross McFluff: 834.345.1254 155 Elm Street ... ... Ronald Heathmore: 892.345.3428 436 Finley Avenue ... Frank Burger: 925.541.7625 662 South Dogwood Way @@ -1160,7 +1169,7 @@ .. doctest:: :options: +NORMALIZE_WHITESPACE - >>> entries = re.split("\n+", text) + >>> entries = re.split("\n+", input) >>> entries ['Ross McFluff: 834.345.1254 155 Elm Street', 'Ronald Heathmore: 892.345.3428 436 Finley Avenue', diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/library/repr.rst --- a/Doc/library/repr.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/library/repr.rst Sun Jul 20 10:52:46 2014 -0400 @@ -6,9 +6,9 @@ .. sectionauthor:: Fred L. Drake, Jr. .. note:: - The :mod:`repr` module has been renamed to :mod:`reprlib` in Python 3. The + The :mod:`repr` module has been renamed to :mod:`reprlib` in Python 3.0. The :term:`2to3` tool will automatically adapt imports when converting your - sources to Python 3. + sources to 3.0. **Source code:** :source:`Lib/repr.py` @@ -24,9 +24,8 @@ .. class:: Repr() Class which provides formatting services useful in implementing functions - similar to the built-in :ref:`repr() `; size limits for different - object types are added to avoid the generation of representations which are - excessively long. + similar to the built-in :func:`repr`; size limits for different object types + are added to avoid the generation of representations which are excessively long. .. data:: aRepr @@ -97,8 +96,8 @@ .. method:: Repr.repr(obj) - The equivalent to the built-in :ref:`repr() ` that uses the - formatting imposed by the instance. + The equivalent to the built-in :func:`repr` that uses the formatting imposed by + the instance. .. method:: Repr.repr1(obj, level) diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/library/resource.rst --- a/Doc/library/resource.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/library/resource.rst Sun Jul 20 10:52:46 2014 -0400 @@ -42,11 +42,6 @@ this module for those platforms. -.. data:: RLIM_INFINITY - - Constant used to represent the the limit for an unlimited resource. - - .. function:: getrlimit(resource) Returns a tuple ``(soft, hard)`` with the current soft and hard limits of @@ -58,20 +53,12 @@ Sets new limits of consumption of *resource*. The *limits* argument must be a tuple ``(soft, hard)`` of two integers describing the new limits. A value of - :data:`~resource.RLIM_INFINITY` can be used to request a limit that is - unlimited. + ``-1`` can be used to specify the maximum possible upper limit. Raises :exc:`ValueError` if an invalid resource is specified, if the new soft - limit exceeds the hard limit, or if a process tries to raise its hard limit. - Specifying a limit of :data:`~resource.RLIM_INFINITY` when the hard or - system limit for that resource is not unlimited will result in a - :exc:`ValueError`. A process with the effective UID of super-user can - request any valid limit value, including unlimited, but :exc:`ValueError` - will still be raised if the requested limit exceeds the system imposed - limit. - - ``setrlimit`` may also raise :exc:`error` if the underlying system call - fails. + limit exceeds the hard limit, or if a process tries to raise its hard limit + (unless the process has an effective UID of super-user). Can also raise + :exc:`error` if the underlying system call fails. These symbols define resources whose consumption can be controlled using the :func:`setrlimit` and :func:`getrlimit` functions described below. The values of diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/library/restricted.rst --- a/Doc/library/restricted.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/library/restricted.rst Sun Jul 20 10:52:46 2014 -0400 @@ -31,7 +31,7 @@ might be deemed "safe" for untrusted code to read any file within a specified directory, but never to write a file. In this case, the supervisor may redefine the built-in :func:`open` function so that it raises an exception whenever the -*mode* parameter is ``'w'``. It might also perform a :c:func:`chroot`\ -like +*mode* parameter is ``'w'``. It might also perform a :cfunc:`chroot`\ -like operation on the *filename* parameter, such that root is always relative to some safe "sandbox" area of the filesystem. In this case, the untrusted code would still see an built-in :func:`open` function in its environment, with the same diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/library/rexec.rst --- a/Doc/library/rexec.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/library/rexec.rst Sun Jul 20 10:52:46 2014 -0400 @@ -6,7 +6,7 @@ :deprecated: .. deprecated:: 2.6 - The :mod:`rexec` module has been removed in Python 3. + The :mod:`rexec` module has been removed in Python 3.0. .. versionchanged:: 2.3 Disabled module. @@ -270,7 +270,7 @@ if mode in ('r', 'rb'): pass elif mode in ('w', 'wb', 'a', 'ab'): - # check filename: must begin with /tmp/ + # check filename : must begin with /tmp/ if file[:5]!='/tmp/': raise IOError("can't write outside /tmp") elif (string.find(file, '/../') >= 0 or diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/library/rfc822.rst --- a/Doc/library/rfc822.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/library/rfc822.rst Sun Jul 20 10:52:46 2014 -0400 @@ -10,7 +10,7 @@ .. deprecated:: 2.3 The :mod:`email` package should be used in preference to the :mod:`rfc822` module. This module is present only to maintain backward compatibility, and - has been removed in Python 3. + has been removed in 3.0. This module defines a class, :class:`Message`, which represents an "email message" as defined by the Internet standard :rfc:`2822`. [#]_ Such messages @@ -42,8 +42,8 @@ from a buffered stream. The optional *seekable* argument is provided as a workaround for certain stdio - libraries in which :c:func:`tell` discards buffered data before discovering that - the :c:func:`lseek` system call doesn't work. For maximum portability, you + libraries in which :cfunc:`tell` discards buffered data before discovering that + the :cfunc:`lseek` system call doesn't work. For maximum portability, you should set the seekable argument to zero to prevent that initial :meth:`tell` when passing in an unseekable object such as a file object created from a socket object. diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/library/robotparser.rst --- a/Doc/library/robotparser.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/library/robotparser.rst Sun Jul 20 10:52:46 2014 -0400 @@ -16,9 +16,9 @@ .. note:: The :mod:`robotparser` module has been renamed :mod:`urllib.robotparser` in - Python 3. + Python 3.0. The :term:`2to3` tool will automatically adapt imports when converting - your sources to Python 3. + your sources to 3.0. This module provides a single class, :class:`RobotFileParser`, which answers questions about whether or not a particular user agent can fetch a URL on the @@ -26,10 +26,10 @@ structure of :file:`robots.txt` files, see http://www.robotstxt.org/orig.html. -.. class:: RobotFileParser(url='') +.. class:: RobotFileParser() - This class provides methods to read, parse and answer questions about the - :file:`robots.txt` file at *url*. + This class provides a set of methods to read, parse and answer questions + about a single :file:`robots.txt` file. .. method:: set_url(url) diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/library/runpy.rst --- a/Doc/library/runpy.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/library/runpy.rst Sun Jul 20 10:52:46 2014 -0400 @@ -22,9 +22,6 @@ .. function:: run_module(mod_name, init_globals=None, run_name=None, alter_sys=False) - .. index:: - module: __main__ - Execute the code of the specified module and return the resulting module globals dictionary. The module's code is first located using the standard import mechanism (refer to :pep:`302` for details) and then executed in a @@ -80,9 +77,6 @@ .. function:: run_path(file_path, init_globals=None, run_name=None) - .. index:: - module: __main__ - Execute the code at the named filesystem location and return the resulting module globals dictionary. As with a script name supplied to the CPython command line, the supplied path may refer to a Python source file, a diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/library/scrolledtext.rst --- a/Doc/library/scrolledtext.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/library/scrolledtext.rst Sun Jul 20 10:52:46 2014 -0400 @@ -16,8 +16,8 @@ .. note:: :mod:`ScrolledText` has been renamed to :mod:`tkinter.scrolledtext` in Python - 3. The :term:`2to3` tool will automatically adapt imports when converting - your sources to Python 3. + 3.0. The :term:`2to3` tool will automatically adapt imports when converting + your sources to 3.0. The text widget and scrollbar are packed together in a :class:`Frame`, and the methods of the :class:`Grid` and :class:`Pack` geometry managers are acquired diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/library/select.rst --- a/Doc/library/select.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/library/select.rst Sun Jul 20 10:52:46 2014 -0400 @@ -6,9 +6,9 @@ :synopsis: Wait for I/O completion on multiple streams. -This module provides access to the :c:func:`select` and :c:func:`poll` functions -available in most operating systems, :c:func:`epoll` available on Linux 2.5+ and -:c:func:`kqueue` available on most BSD. +This module provides access to the :cfunc:`select` and :cfunc:`poll` functions +available in most operating systems, :cfunc:`epoll` available on Linux 2.5+ and +:cfunc:`kqueue` available on most BSD. Note that on Windows, it only works for sockets; on other operating systems, it also works for other file types (in particular, on Unix, it works on pipes). It cannot be used on regular files to determine whether a file has grown since @@ -20,8 +20,8 @@ .. exception:: error The exception raised when an error occurs. The accompanying value is a pair - containing the numeric error code from :c:data:`errno` and the corresponding - string, as would be printed by the C function :c:func:`perror`. + containing the numeric error code from :cdata:`errno` and the corresponding + string, as would be printed by the C function :cfunc:`perror`. .. function:: epoll([sizehint=-1]) @@ -60,10 +60,10 @@ .. function:: select(rlist, wlist, xlist[, timeout]) - This is a straightforward interface to the Unix :c:func:`select` system call. + This is a straightforward interface to the Unix :cfunc:`select` system call. The first three arguments are sequences of 'waitable objects': either integers representing file descriptors or objects with a parameterless method - named :meth:`~io.IOBase.fileno` returning such an integer: + named :meth:`fileno` returning such an integer: * *rlist*: wait until ready for reading * *wlist*: wait until ready for writing @@ -88,15 +88,15 @@ Among the acceptable object types in the sequences are Python file objects (e.g. ``sys.stdin``, or objects returned by :func:`open` or :func:`os.popen`), socket objects returned by :func:`socket.socket`. You may also define a :dfn:`wrapper` - class yourself, as long as it has an appropriate :meth:`~io.IOBase.fileno` - method (that really returns a file descriptor, not just a random integer). + class yourself, as long as it has an appropriate :meth:`fileno` method (that + really returns a file descriptor, not just a random integer). .. note:: .. index:: single: WinSock File objects on Windows are not acceptable, but sockets are. On Windows, - the underlying :c:func:`select` function is provided by the WinSock + the underlying :cfunc:`select` function is provided by the WinSock library, and does not handle file descriptors that don't originate from WinSock. @@ -195,22 +195,22 @@ Polling Objects --------------- -The :c:func:`poll` system call, supported on most Unix systems, provides better +The :cfunc:`poll` system call, supported on most Unix systems, provides better scalability for network servers that service many, many clients at the same -time. :c:func:`poll` scales better because the system call only requires listing -the file descriptors of interest, while :c:func:`select` builds a bitmap, turns +time. :cfunc:`poll` scales better because the system call only requires listing +the file descriptors of interest, while :cfunc:`select` builds a bitmap, turns on bits for the fds of interest, and then afterward the whole bitmap has to be -linearly scanned again. :c:func:`select` is O(highest file descriptor), while -:c:func:`poll` is O(number of file descriptors). +linearly scanned again. :cfunc:`select` is O(highest file descriptor), while +:cfunc:`poll` is O(number of file descriptors). .. method:: poll.register(fd[, eventmask]) Register a file descriptor with the polling object. Future calls to the - :meth:`poll` method will then check whether the file descriptor has any - pending I/O events. *fd* can be either an integer, or an object with a - :meth:`~io.IOBase.fileno` method that returns an integer. File objects - implement :meth:`!fileno`, so they can also be used as the argument. + :meth:`poll` method will then check whether the file descriptor has any pending + I/O events. *fd* can be either an integer, or an object with a :meth:`fileno` + method that returns an integer. File objects implement :meth:`fileno`, so they + can also be used as the argument. *eventmask* is an optional bitmask describing the type of events you want to check for, and can be a combination of the constants :const:`POLLIN`, @@ -251,7 +251,7 @@ Remove a file descriptor being tracked by a polling object. Just like the :meth:`register` method, *fd* can be an integer or an object with a - :meth:`~io.IOBase.fileno` method that returns an integer. + :meth:`fileno` method that returns an integer. Attempting to remove a file descriptor that was never registered causes a :exc:`KeyError` exception to be raised. diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/library/sgmllib.rst --- a/Doc/library/sgmllib.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/library/sgmllib.rst Sun Jul 20 10:52:46 2014 -0400 @@ -6,7 +6,7 @@ :deprecated: .. deprecated:: 2.6 - The :mod:`sgmllib` module has been removed in Python 3. + The :mod:`sgmllib` module has been removed in Python 3.0. .. index:: single: SGML diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/library/shelve.rst --- a/Doc/library/shelve.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/library/shelve.rst Sun Jul 20 10:52:46 2014 -0400 @@ -18,7 +18,7 @@ lots of shared sub-objects. The keys are ordinary strings. -.. function:: open(filename, flag='c', protocol=None, writeback=False) +.. function:: open(filename[, flag='c'[, protocol=None[, writeback=False]]]) Open a persistent dictionary. The filename specified is the base filename for the underlying database. As a side-effect, an extension may be added to the @@ -47,11 +47,9 @@ Like file objects, shelve objects should be closed explicitly to ensure that the persistent data is flushed to disk. -.. warning:: - - Because the :mod:`shelve` module is backed by :mod:`pickle`, it is insecure - to load a shelf from an untrusted source. Like with pickle, loading a shelf - can execute arbitrary code. + Since the :mod:`shelve` module stores objects using :mod:`pickle`, the same + security precautions apply. Accordingly, you should avoid loading a shelf + from an untrusted source. Shelf objects support all methods supported by dictionaries. This eases the transition from dictionary based scripts to those requiring persistent storage. @@ -102,7 +100,7 @@ implementation used. -.. class:: Shelf(dict, protocol=None, writeback=False) +.. class:: Shelf(dict[, protocol=None[, writeback=False]]) A subclass of :class:`UserDict.DictMixin` which stores pickled values in the *dict* object. @@ -120,7 +118,7 @@ memory and make sync and close take a long time. -.. class:: BsdDbShelf(dict, protocol=None, writeback=False) +.. class:: BsdDbShelf(dict[, protocol=None[, writeback=False]]) A subclass of :class:`Shelf` which exposes :meth:`first`, :meth:`!next`, :meth:`previous`, :meth:`last` and :meth:`set_location` which are available in @@ -131,7 +129,7 @@ the same interpretation as for the :class:`Shelf` class. -.. class:: DbfilenameShelf(filename, flag='c', protocol=None, writeback=False) +.. class:: DbfilenameShelf(filename[, flag='c'[, protocol=None[, writeback=False]]]) A subclass of :class:`Shelf` which accepts a *filename* instead of a dict-like object. The underlying file will be opened using :func:`anydbm.open`. By diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/library/shlex.rst --- a/Doc/library/shlex.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/library/shlex.rst Sun Jul 20 10:52:46 2014 -0400 @@ -16,9 +16,9 @@ -------------- -The :class:`~shlex.shlex` class makes it easy to write lexical analyzers for -simple syntaxes resembling that of the Unix shell. This will often be useful -for writing minilanguages, (for example, in run control files for Python +The :class:`shlex` class makes it easy to write lexical analyzers for simple +syntaxes resembling that of the Unix shell. This will often be useful for +writing minilanguages, (for example, in run control files for Python applications) or for parsing quoted strings. Prior to Python 2.7.3, this module did not support Unicode input. @@ -30,10 +30,9 @@ Split the string *s* using shell-like syntax. If *comments* is :const:`False` (the default), the parsing of comments in the given string will be disabled - (setting the :attr:`~shlex.commenters` attribute of the - :class:`~shlex.shlex` instance to the empty string). This function operates - in POSIX mode by default, but uses non-POSIX mode if the *posix* argument is - false. + (setting the :attr:`commenters` attribute of the :class:`shlex` instance to + the empty string). This function operates in POSIX mode by default, but uses + non-POSIX mode if the *posix* argument is false. .. versionadded:: 2.3 @@ -42,28 +41,26 @@ .. note:: - Since the :func:`split` function instantiates a :class:`~shlex.shlex` - instance, passing ``None`` for *s* will read the string to split from - standard input. + Since the :func:`split` function instantiates a :class:`shlex` instance, passing + ``None`` for *s* will read the string to split from standard input. The :mod:`shlex` module defines the following class: .. class:: shlex([instream[, infile[, posix]]]) - A :class:`~shlex.shlex` instance or subclass instance is a lexical analyzer - object. The initialization argument, if present, specifies where to read - characters from. It must be a file-/stream-like object with - :meth:`~io.TextIOBase.read` and :meth:`~io.TextIOBase.readline` methods, or - a string (strings are accepted since Python 2.3). If no argument is given, - input will be taken from ``sys.stdin``. The second optional argument is a - filename string, which sets the initial value of the :attr:`~shlex.infile` - attribute. If the *instream* argument is omitted or equal to ``sys.stdin``, - this second argument defaults to "stdin". The *posix* argument was - introduced in Python 2.3, and defines the operational mode. When *posix* is - not true (default), the :class:`~shlex.shlex` instance will operate in - compatibility mode. When operating in POSIX mode, :class:`~shlex.shlex` - will try to be as close as possible to the POSIX shell parsing rules. + A :class:`shlex` instance or subclass instance is a lexical analyzer object. + The initialization argument, if present, specifies where to read characters + from. It must be a file-/stream-like object with :meth:`read` and + :meth:`readline` methods, or a string (strings are accepted since Python 2.3). + If no argument is given, input will be taken from ``sys.stdin``. The second + optional argument is a filename string, which sets the initial value of the + :attr:`infile` attribute. If the *instream* argument is omitted or equal to + ``sys.stdin``, this second argument defaults to "stdin". The *posix* argument + was introduced in Python 2.3, and defines the operational mode. When *posix* is + not true (default), the :class:`shlex` instance will operate in compatibility + mode. When operating in POSIX mode, :class:`shlex` will try to be as close as + possible to the POSIX shell parsing rules. .. seealso:: @@ -77,14 +74,14 @@ shlex Objects ------------- -A :class:`~shlex.shlex` instance has the following methods: +A :class:`shlex` instance has the following methods: .. method:: shlex.get_token() Return a token. If tokens have been stacked using :meth:`push_token`, pop a token off the stack. Otherwise, read one from the input stream. If reading - encounters an immediate end-of-file, :attr:`eof` is returned (the empty + encounters an immediate end-of-file, :attr:`self.eof` is returned (the empty string (``''``) in non-POSIX mode, and ``None`` in POSIX mode). @@ -102,9 +99,9 @@ .. method:: shlex.sourcehook(filename) - When :class:`~shlex.shlex` detects a source request (see :attr:`source` - below) this method is given the following token as argument, and expected - to return a tuple consisting of a filename and an open file-like object. + When :class:`shlex` detects a source request (see :attr:`source` below) this + method is given the following token as argument, and expected to return a tuple + consisting of a filename and an open file-like object. Normally, this method first strips any quotes off the argument. If the result is an absolute pathname, or there was no previous source request in effect, or @@ -121,9 +118,8 @@ This hook is exposed so that you can use it to implement directory search paths, addition of file extensions, and other namespace hacks. There is no - corresponding 'close' hook, but a shlex instance will call the - :meth:`~io.IOBase.close` method of the sourced input stream when it returns - EOF. + corresponding 'close' hook, but a shlex instance will call the :meth:`close` + method of the sourced input stream when it returns EOF. For more explicit control of source stacking, use the :meth:`push_source` and :meth:`pop_source` methods. @@ -157,8 +153,8 @@ messages in the standard, parseable format understood by Emacs and other Unix tools. -Instances of :class:`~shlex.shlex` subclasses have some public instance -variables which either control lexical analysis or can be used for debugging: +Instances of :class:`shlex` subclasses have some public instance variables which +either control lexical analysis or can be used for debugging: .. attribute:: shlex.commenters @@ -207,8 +203,8 @@ .. attribute:: shlex.whitespace_split If ``True``, tokens will only be split in whitespaces. This is useful, for - example, for parsing command lines with :class:`~shlex.shlex`, getting - tokens in a similar way to shell arguments. + example, for parsing command lines with :class:`shlex`, getting tokens in a + similar way to shell arguments. .. versionadded:: 2.3 @@ -222,8 +218,7 @@ .. attribute:: shlex.instream - The input stream from which this :class:`~shlex.shlex` instance is reading - characters. + The input stream from which this :class:`shlex` instance is reading characters. .. attribute:: shlex.source @@ -232,16 +227,16 @@ string will be recognized as a lexical-level inclusion request similar to the ``source`` keyword in various shells. That is, the immediately following token will opened as a filename and input taken from that stream until EOF, at which - point the :meth:`~io.IOBase.close` method of that stream will be called and - the input source will again become the original input stream. Source - requests may be stacked any number of levels deep. + point the :meth:`close` method of that stream will be called and the input + source will again become the original input stream. Source requests may be + stacked any number of levels deep. .. attribute:: shlex.debug - If this attribute is numeric and ``1`` or more, a :class:`~shlex.shlex` - instance will print verbose progress output on its behavior. If you need - to use this, you can read the module source code to learn the details. + If this attribute is numeric and ``1`` or more, a :class:`shlex` instance will + print verbose progress output on its behavior. If you need to use this, you can + read the module source code to learn the details. .. attribute:: shlex.lineno @@ -267,7 +262,7 @@ Parsing Rules ------------- -When operating in non-POSIX mode, :class:`~shlex.shlex` will try to obey to the +When operating in non-POSIX mode, :class:`shlex` will try to obey to the following rules. * Quote characters are not recognized within words (``Do"Not"Separate`` is @@ -281,17 +276,16 @@ * Closing quotes separate words (``"Do"Separate`` is parsed as ``"Do"`` and ``Separate``); -* If :attr:`~shlex.whitespace_split` is ``False``, any character not - declared to be a word character, whitespace, or a quote will be returned as - a single-character token. If it is ``True``, :class:`~shlex.shlex` will only - split words in whitespaces; +* If :attr:`whitespace_split` is ``False``, any character not declared to be a + word character, whitespace, or a quote will be returned as a single-character + token. If it is ``True``, :class:`shlex` will only split words in whitespaces; * EOF is signaled with an empty string (``''``); * It's not possible to parse empty strings, even if quoted. -When operating in POSIX mode, :class:`~shlex.shlex` will try to obey to the -following parsing rules. +When operating in POSIX mode, :class:`shlex` will try to obey to the following +parsing rules. * Quotes are stripped out, and do not separate words (``"Do"Not"Separate"`` is parsed as the single word ``DoNotSeparate``); @@ -299,16 +293,14 @@ * Non-quoted escape characters (e.g. ``'\'``) preserve the literal value of the next character that follows; -* Enclosing characters in quotes which are not part of - :attr:`~shlex.escapedquotes` (e.g. ``"'"``) preserve the literal value - of all characters within the quotes; +* Enclosing characters in quotes which are not part of :attr:`escapedquotes` + (e.g. ``"'"``) preserve the literal value of all characters within the quotes; -* Enclosing characters in quotes which are part of - :attr:`~shlex.escapedquotes` (e.g. ``'"'``) preserves the literal value - of all characters within the quotes, with the exception of the characters - mentioned in :attr:`~shlex.escape`. The escape characters retain its - special meaning only when followed by the quote in use, or the escape - character itself. Otherwise the escape character will be considered a +* Enclosing characters in quotes which are part of :attr:`escapedquotes` (e.g. + ``'"'``) preserves the literal value of all characters within the quotes, with + the exception of the characters mentioned in :attr:`escape`. The escape + characters retain its special meaning only when followed by the quote in use, or + the escape character itself. Otherwise the escape character will be considered a normal character. * EOF is signaled with a :const:`None` value; diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/library/shutil.rst --- a/Doc/library/shutil.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/library/shutil.rst Sun Jul 20 10:52:46 2014 -0400 @@ -21,8 +21,8 @@ .. warning:: - Even the higher-level file copying functions (:func:`shutil.copy`, - :func:`shutil.copy2`) can't copy all file metadata. + Even the higher-level file copying functions (:func:`copy`, :func:`copy2`) + can't copy all file metadata. On POSIX platforms, this means that file owner and group are lost as well as ACLs. On Mac OS, the resource fork and other metadata are not used. @@ -31,8 +31,6 @@ are not copied. -.. _file-operations: - Directory and files operations ------------------------------ @@ -49,10 +47,10 @@ .. function:: copyfile(src, dst) - Copy the contents (no metadata) of the file named *src* to a file named - *dst*. *dst* must be the complete target file name; look at - :func:`shutil.copy` for a copy that accepts a target directory path. If - *src* and *dst* are the same files, :exc:`Error` is raised. + Copy the contents (no metadata) of the file named *src* to a file named *dst*. + *dst* must be the complete target file name; look at :func:`copy` for a copy that + accepts a target directory path. If *src* and *dst* are the same files, + :exc:`Error` is raised. The destination location must be writable; otherwise, an :exc:`IOError` exception will be raised. If *dst* already exists, it will be replaced. Special files such as character or block devices and pipes cannot be copied with this @@ -82,9 +80,9 @@ .. function:: copy2(src, dst) - Similar to :func:`shutil.copy`, but metadata is copied as well -- in fact, - this is just :func:`shutil.copy` followed by :func:`copystat`. This is - similar to the Unix command :program:`cp -p`. + Similar to :func:`copy`, but metadata is copied as well -- in fact, this is just + :func:`copy` followed by :func:`copystat`. This is similar to the + Unix command :program:`cp -p`. .. function:: ignore_patterns(\*patterns) @@ -96,13 +94,13 @@ .. versionadded:: 2.6 -.. function:: copytree(src, dst, symlinks=False, ignore=None) +.. function:: copytree(src, dst[, symlinks=False[, ignore=None]]) Recursively copy an entire directory tree rooted at *src*. The destination - directory, named by *dst*, must not already exist; it will be created as - well as missing parent directories. Permissions and times of directories - are copied with :func:`copystat`, individual files are copied using - :func:`shutil.copy2`. + directory, named by *dst*, must not already exist; it will be created as well + as missing parent directories. Permissions and times of directories are + copied with :func:`copystat`, individual files are copied using + :func:`copy2`. If *symlinks* is true, symbolic links in the source tree are represented as symbolic links in the new tree, but the metadata of the original links is NOT @@ -172,8 +170,8 @@ :func:`os.rename` semantics. If the destination is on the current filesystem, then :func:`os.rename` is - used. Otherwise, *src* is copied (using :func:`shutil.copy2`) to *dst* and - then removed. + used. Otherwise, *src* is copied (using :func:`copy2`) to *dst* and then + removed. .. versionadded:: 2.3 @@ -187,7 +185,7 @@ .. versionadded:: 2.3 -.. _copytree-example: +.. _shutil-example: copytree example :::::::::::::::: @@ -219,18 +217,18 @@ else: copy2(srcname, dstname) # XXX What about devices, sockets etc.? - except (IOError, os.error) as why: + except (IOError, os.error), why: errors.append((srcname, dstname, str(why))) # catch the Error from the recursive copytree so that we can # continue with other files - except Error as err: + except Error, err: errors.extend(err.args[0]) try: copystat(src, dst) except WindowsError: # can't copy file access times on Windows pass - except OSError as why: + except OSError, why: errors.extend((src, dst, str(why))) if errors: raise Error(errors) @@ -256,13 +254,8 @@ copytree(source, destination, ignore=_logpath) -.. _archiving-operations: - -Archiving operations --------------------- - -High-level utilities to create and read compressed and archived files are also -provided. They rely on the :mod:`zipfile` and :mod:`tarfile` modules. +Archives operations +------------------- .. function:: make_archive(base_name, format, [root_dir, [base_dir, [verbose, [dry_run, [owner, [group, [logger]]]]]]]) @@ -285,8 +278,7 @@ *owner* and *group* are used when creating a tar archive. By default, uses the current owner and group. - *logger* must be an object compatible with :pep:`282`, usually an instance of - :class:`logging.Logger`. + *logger* is an instance of :class:`logging.Logger`. .. versionadded:: 2.7 @@ -330,8 +322,6 @@ .. versionadded:: 2.7 -.. _archiving-example: - Archiving example ::::::::::::::::: @@ -356,3 +346,5 @@ -rw------- tarek/staff 1675 2008-06-09 13:26:54 ./id_rsa -rw-r--r-- tarek/staff 397 2008-06-09 13:26:54 ./id_rsa.pub -rw-r--r-- tarek/staff 37192 2010-02-06 18:23:10 ./known_hosts + + diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/library/signal.rst --- a/Doc/library/signal.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/library/signal.rst Sun Jul 20 10:52:46 2014 -0400 @@ -69,7 +69,7 @@ All the signal numbers are defined symbolically. For example, the hangup signal is defined as :const:`signal.SIGHUP`; the variable names are identical to the names used in C programs, as found in ````. The Unix man page for - ':c:func:`signal`' lists the existing signals (on some systems this is + ':cfunc:`signal`' lists the existing signals (on some systems this is :manpage:`signal(2)`, on others the list is in :manpage:`signal(7)`). Note that not all systems define the same set of signal names; only those names defined by the system are defined by this module. @@ -216,7 +216,7 @@ Note that installing a signal handler with :func:`signal` will reset the restart behaviour to interruptible by implicitly calling - :c:func:`siginterrupt` with a true *flag* value for the given signal. + :cfunc:`siginterrupt` with a true *flag* value for the given signal. .. versionadded:: 2.6 diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/library/simplehttpserver.rst --- a/Doc/library/simplehttpserver.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/library/simplehttpserver.rst Sun Jul 20 10:52:46 2014 -0400 @@ -8,8 +8,8 @@ .. note:: The :mod:`SimpleHTTPServer` module has been merged into :mod:`http.server` in - Python 3. The :term:`2to3` tool will automatically adapt imports when - converting your sources to Python 3. + Python 3.0. The :term:`2to3` tool will automatically adapt imports when + converting your sources to 3.0. The :mod:`SimpleHTTPServer` module defines a single class, diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/library/simplexmlrpcserver.rst --- a/Doc/library/simplexmlrpcserver.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/library/simplexmlrpcserver.rst Sun Jul 20 10:52:46 2014 -0400 @@ -8,8 +8,8 @@ .. note:: The :mod:`SimpleXMLRPCServer` module has been merged into - :mod:`xmlrpc.server` in Python 3. The :term:`2to3` tool will automatically - adapt imports when converting your sources to Python 3. + :mod:`xmlrpc.server` in Python 3.0. The :term:`2to3` tool will automatically + adapt imports when converting your sources to 3.0. .. versionadded:: 2.2 @@ -197,38 +197,6 @@ # Print list of available methods print s.system.listMethods() -The following :class:`SimpleXMLRPCServer` example is included in the module -`Lib/SimpleXMLRPCServer.py`:: - - server = SimpleXMLRPCServer(("localhost", 8000)) - server.register_function(pow) - server.register_function(lambda x,y: x+y, 'add') - server.register_multicall_functions() - server.serve_forever() - -This demo server can be run from the command line as:: - - python -m SimpleXMLRPCServer - -Example client code which talks to the above server is included with -`Lib/xmlrpclib.py`:: - - server = ServerProxy("http://localhost:8000") - print server - multi = MultiCall(server) - multi.pow(2, 9) - multi.add(5, 1) - multi.add(24, 11) - try: - for response in multi(): - print response - except Error, v: - print "ERROR", v - -And the client can be invoked directly using the following command:: - - python -m xmlrpclib - CGIXMLRPCRequestHandler ----------------------- @@ -279,7 +247,7 @@ Example:: class MyFuncs: - def div(self, x, y): return x // y + def div(self, x, y) : return x // y handler = CGIXMLRPCRequestHandler() diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/library/site.rst --- a/Doc/library/site.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/library/site.rst Sun Jul 20 10:52:46 2014 -0400 @@ -26,7 +26,7 @@ For the head part, it uses ``sys.prefix`` and ``sys.exec_prefix``; empty heads are skipped. For the tail part, it uses the empty string and then :file:`lib/site-packages` (on Windows) or -:file:`lib/python{X.Y}/site-packages` and then :file:`lib/site-python` (on +:file:`lib/python|version|/site-packages` and then :file:`lib/site-python` (on Unix and Macintosh). For each of the distinct head-tail combinations, it sees if it refers to an existing directory, and if so, adds it to ``sys.path`` and also inspects the newly added path for configuration files. @@ -83,11 +83,7 @@ :mod:`sitecustomize`, which can perform arbitrary site-specific customizations. It is typically created by a system administrator in the site-packages directory. If this import fails with an :exc:`ImportError` exception, it is -silently ignored. If Python is started without output streams available, as -with :file:`pythonw.exe` on Windows (which is used by default to start IDLE), -attempted output from :mod:`sitecustomize` is ignored. Any exception other -than :exc:`ImportError` causes a silent and perhaps mysterious failure of the -process. +silently ignored. .. index:: module: usercustomize @@ -185,8 +181,8 @@ .. code-block:: sh - $ python -m site --user-site - /home/user/.local/lib/python2.7/site-packages + $ python3 -m site --user-site + /home/user/.local/lib/python3.3/site-packages .. program:: site diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/library/smtplib.rst --- a/Doc/library/smtplib.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/library/smtplib.rst Sun Jul 20 10:52:46 2014 -0400 @@ -24,20 +24,15 @@ A :class:`SMTP` instance encapsulates an SMTP connection. It has methods that support a full repertoire of SMTP and ESMTP operations. If the optional - host and port parameters are given, the SMTP :meth:`connect` method is - called with those parameters during initialization. If specified, - *local_hostname* is used as the FQDN of the local host in the HELO/EHLO - command. Otherwise, the local hostname is found using - :func:`socket.getfqdn`. If the :meth:`connect` call returns anything other - than a success code, an :exc:`SMTPConnectError` is raised. The optional + host and port parameters are given, the SMTP :meth:`connect` method is called + with those parameters during initialization. An :exc:`SMTPConnectError` is + raised if the specified host doesn't respond correctly. The optional *timeout* parameter specifies a timeout in seconds for blocking operations like the connection attempt (if not specified, the global default timeout - setting will be used). If the timeout expires, :exc:`socket.timeout` - is raised. + setting will be used). For normal use, you should only require the initialization/connect, - :meth:`sendmail`, and :meth:`~smtplib.quit` methods. - An example is included below. + :meth:`sendmail`, and :meth:`quit` methods. An example is included below. .. versionchanged:: 2.6 *timeout* was added. @@ -49,14 +44,12 @@ :class:`SMTP`. :class:`SMTP_SSL` should be used for situations where SSL is required from the beginning of the connection and using :meth:`starttls` is not appropriate. If *host* is not specified, the local host is used. If - *port* is omitted, the standard SMTP-over-SSL port (465) is used. - *local_hostname* has the same meaning as it does for the :class:`SMTP` - class. *keyfile* and *certfile* are also optional, and can contain a PEM - formatted private key and certificate chain file for the SSL connection. The - optional *timeout* parameter specifies a timeout in seconds for blocking - operations like the connection attempt (if not specified, the global default - timeout setting will be used). If the timeout expires, :exc:`socket.timeout` - is raised. + *port* is omitted, the standard SMTP-over-SSL port (465) is used. *keyfile* + and *certfile* are also optional, and can contain a PEM formatted private key + and certificate chain file for the SSL connection. The optional *timeout* + parameter specifies a timeout in seconds for blocking operations like the + connection attempt (if not specified, the global default timeout setting + will be used). .. versionadded:: 2.6 @@ -64,15 +57,13 @@ .. class:: LMTP([host[, port[, local_hostname]]]) The LMTP protocol, which is very similar to ESMTP, is heavily based on the - standard SMTP client. It's common to use Unix sockets for LMTP, so our - :meth:`connect` method must support that as well as a regular host:port - server. *local_hostname* has the same meaning as it does for the - :class:`SMTP` class. To specify a Unix socket, you must use an absolute - path for *host*, starting with a '/'. + standard SMTP client. It's common to use Unix sockets for LMTP, so our :meth:`connect` + method must support that as well as a regular host:port server. To specify a + Unix socket, you must use an absolute path for *host*, starting with a '/'. - Authentication is supported, using the regular SMTP mechanism. When using a - Unix socket, LMTP generally don't support or require any authentication, but - your mileage might vary. + Authentication is supported, using the regular SMTP mechanism. When using a Unix + socket, LMTP generally don't support or require any authentication, but your + mileage might vary. .. versionadded:: 2.6 @@ -81,8 +72,7 @@ .. exception:: SMTPException - The base exception class for all the other exceptions provided by this - module. + Base exception class for all exceptions raised by this module. .. exception:: SMTPServerDisconnected @@ -161,6 +151,15 @@ for connection and for all messages sent to and received from the server. +.. method:: SMTP.connect([host[, port]]) + + Connect to a host on a given port. The defaults are to connect to the local + host at the standard SMTP port (25). If the hostname ends with a colon (``':'``) + followed by a number, that suffix will be stripped off and the number + interpreted as the port number to use. This method is automatically invoked by + the constructor if a host is specified during instantiation. + + .. method:: SMTP.docmd(cmd, [, argstring]) Send a command *cmd* to the server. The optional argument *argstring* is simply @@ -177,17 +176,6 @@ :exc:`SMTPServerDisconnected` will be raised. -.. method:: SMTP.connect([host[, port]]) - - Connect to a host on a given port. The defaults are to connect to the local - host at the standard SMTP port (25). If the hostname ends with a colon (``':'``) - followed by a number, that suffix will be stripped off and the number - interpreted as the port number to use. This method is automatically invoked by - the constructor if a host is specified during instantiation. Returns a - 2-tuple of the response code and message sent by the server in its - connection response. - - .. method:: SMTP.helo([hostname]) Identify yourself to the SMTP server using ``HELO``. The hostname argument diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/library/socket.rst --- a/Doc/library/socket.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/library/socket.rst Sun Jul 20 10:52:46 2014 -0400 @@ -28,7 +28,7 @@ The Python interface is a straightforward transliteration of the Unix system call and library interface for sockets to Python's object-oriented style: the -:func:`.socket` function returns a :dfn:`socket object` whose methods implement +:func:`socket` function returns a :dfn:`socket object` whose methods implement the various socket system calls. Parameter types are somewhat higher-level than in the C interface: as with :meth:`read` and :meth:`write` operations on Python files, buffer allocation on receive operations is automatic, and buffer length @@ -38,7 +38,7 @@ :const:`AF_UNIX` address family. A pair ``(host, port)`` is used for the :const:`AF_INET` address family, where *host* is a string representing either a hostname in Internet domain notation like ``'daring.cwi.nl'`` or an IPv4 address -like ``'100.50.200.5'``, and *port* is an integer. For +like ``'100.50.200.5'``, and *port* is an integral port number. For :const:`AF_INET6` address family, a four-tuple ``(host, port, flowinfo, scopeid)`` is used, where *flowinfo* and *scopeid* represents ``sin6_flowinfo`` and ``sin6_scope_id`` member in :const:`struct sockaddr_in6` in C. For @@ -72,17 +72,17 @@ tuple, and the fields depend on the address type. The general tuple form is ``(addr_type, v1, v2, v3 [, scope])``, where: - - *addr_type* is one of :const:`TIPC_ADDR_NAMESEQ`, :const:`TIPC_ADDR_NAME`, - or :const:`TIPC_ADDR_ID`. - - *scope* is one of :const:`TIPC_ZONE_SCOPE`, :const:`TIPC_CLUSTER_SCOPE`, - and :const:`TIPC_NODE_SCOPE`. - - If *addr_type* is :const:`TIPC_ADDR_NAME`, then *v1* is the server type, *v2* is + - *addr_type* is one of TIPC_ADDR_NAMESEQ, TIPC_ADDR_NAME, or + TIPC_ADDR_ID. + - *scope* is one of TIPC_ZONE_SCOPE, TIPC_CLUSTER_SCOPE, and + TIPC_NODE_SCOPE. + - If *addr_type* is TIPC_ADDR_NAME, then *v1* is the server type, *v2* is the port identifier, and *v3* should be 0. - If *addr_type* is :const:`TIPC_ADDR_NAMESEQ`, then *v1* is the server type, *v2* + If *addr_type* is TIPC_ADDR_NAMESEQ, then *v1* is the server type, *v2* is the lower port number, and *v3* is the upper port number. - If *addr_type* is :const:`TIPC_ADDR_ID`, then *v1* is the node, *v2* is the + If *addr_type* is TIPC_ADDR_ID, then *v1* is the node, *v2* is the reference, and *v3* should be set to 0. @@ -119,7 +119,7 @@ The accompanying value is a pair ``(h_errno, string)`` representing an error returned by a library call. *string* represents the description of *h_errno*, as - returned by the :c:func:`hstrerror` C function. + returned by the :cfunc:`hstrerror` C function. .. exception:: gaierror @@ -127,7 +127,7 @@ This exception is raised for address-related errors, for :func:`getaddrinfo` and :func:`getnameinfo`. The accompanying value is a pair ``(error, string)`` representing an error returned by a library call. *string* represents the - description of *error*, as returned by the :c:func:`gai_strerror` C function. The + description of *error*, as returned by the :cfunc:`gai_strerror` C function. The *error* value will match one of the :const:`EAI_\*` constants defined in this module. @@ -146,7 +146,7 @@ AF_INET6 These constants represent the address (and protocol) families, used for the - first argument to :func:`.socket`. If the :const:`AF_UNIX` constant is not + first argument to :func:`socket`. If the :const:`AF_UNIX` constant is not defined then this protocol is unsupported. @@ -186,7 +186,7 @@ RCVALL_* Constants for Windows' WSAIoctl(). The constants are used as arguments to the - :meth:`~socket.socket.ioctl` method of socket objects. + :meth:`ioctl` method of socket objects. .. versionadded:: 2.6 @@ -207,17 +207,10 @@ .. function:: create_connection(address[, timeout[, source_address]]) - Connect to a TCP service listening on the Internet *address* (a 2-tuple - ``(host, port)``), and return the socket object. This is a higher-level - function than :meth:`socket.connect`: if *host* is a non-numeric hostname, - it will try to resolve it for both :data:`AF_INET` and :data:`AF_INET6`, - and then try to connect to all possible addresses in turn until a - connection succeeds. This makes it easy to write clients that are - compatible to both IPv4 and IPv6. - - Passing the optional *timeout* parameter will set the timeout on the - socket instance before attempting to connect. If no *timeout* is - supplied, the global default timeout setting returned by + Convenience function. Connect to *address* (a 2-tuple ``(host, port)``), + and return the socket object. Passing the optional *timeout* parameter will + set the timeout on the socket instance before attempting to connect. If no + *timeout* is supplied, the global default timeout setting returned by :func:`getdefaulttimeout` is used. If supplied, *source_address* must be a 2-tuple ``(host, port)`` for the @@ -230,7 +223,7 @@ *source_address* was added. -.. function:: getaddrinfo(host, port[, family[, socktype[, proto[, flags]]]]) +.. function:: getaddrinfo(host, port, family=0, socktype=0, proto=0, flags=0) Translate the *host*/*port* argument into a sequence of 5-tuples that contain all the necessary arguments for creating a socket connected to that service. @@ -240,19 +233,19 @@ and *port*, you can pass ``NULL`` to the underlying C API. The *family*, *socktype* and *proto* arguments can be optionally specified - in order to narrow the list of addresses returned. By default, their value - is ``0``, meaning that the full range of results is selected. + in order to narrow the list of addresses returned. Passing zero as a + value for each of these arguments selects the full range of results. The *flags* argument can be one or several of the ``AI_*`` constants, - and will influence how results are computed and returned. Its default value - is ``0``. For example, :const:`AI_NUMERICHOST` will disable domain name - resolution and will raise an error if *host* is a domain name. + and will influence how results are computed and returned. + For example, :const:`AI_NUMERICHOST` will disable domain name resolution + and will raise an error if *host* is a domain name. The function returns a list of 5-tuples with the following structure: ``(family, socktype, proto, canonname, sockaddr)`` In these tuples, *family*, *socktype*, *proto* are all integers and are - meant to be passed to the :func:`.socket` function. *canonname* will be + meant to be passed to the :func:`socket` function. *canonname* will be a string representing the canonical name of the *host* if :const:`AI_CANONNAME` is part of the *flags* argument; else *canonname* will be empty. *sockaddr* is a tuple describing a socket address, whose @@ -343,7 +336,7 @@ .. function:: getprotobyname(protocolname) Translate an Internet protocol name (for example, ``'icmp'``) to a constant - suitable for passing as the (optional) third argument to the :func:`.socket` + suitable for passing as the (optional) third argument to the :func:`socket` function. This is usually only needed for sockets opened in "raw" mode (:const:`SOCK_RAW`); for the normal socket modes, the correct protocol is chosen automatically if the protocol is omitted or zero. @@ -377,7 +370,7 @@ Build a pair of connected socket objects using the given address family, socket type, and protocol number. Address family, socket type, and protocol number are - as for the :func:`.socket` function above. The default family is :const:`AF_UNIX` + as for the :func:`socket` function above. The default family is :const:`AF_UNIX` if defined on the platform; otherwise, the default is :const:`AF_INET`. Availability: Unix. @@ -388,7 +381,7 @@ Duplicate the file descriptor *fd* (an integer as returned by a file object's :meth:`fileno` method) and build a socket object from the result. Address - family, socket type and protocol number are as for the :func:`.socket` function + family, socket type and protocol number are as for the :func:`socket` function above. The file descriptor should refer to a socket, but this is not checked --- subsequent operations on the object may fail if the file descriptor is invalid. This function is rarely needed, but can be used to get or set socket options on @@ -430,7 +423,7 @@ Convert an IPv4 address from dotted-quad string format (for example, '123.45.67.89') to 32-bit packed binary format, as a string four characters in length. This is useful when conversing with a program that uses the standard C - library and needs objects of type :c:type:`struct in_addr`, which is the C type + library and needs objects of type :ctype:`struct in_addr`, which is the C type for the 32-bit packed binary this function returns. :func:`inet_aton` also accepts strings with less than three dots; see the @@ -438,7 +431,7 @@ If the IPv4 address string passed to this function is invalid, :exc:`socket.error` will be raised. Note that exactly what is valid depends on - the underlying C implementation of :c:func:`inet_aton`. + the underlying C implementation of :cfunc:`inet_aton`. :func:`inet_aton` does not support IPv6, and :func:`inet_pton` should be used instead for IPv4/v6 dual stack support. @@ -449,7 +442,7 @@ Convert a 32-bit packed IPv4 address (a string four characters in length) to its standard dotted-quad string representation (for example, '123.45.67.89'). This is useful when conversing with a program that uses the standard C library and - needs objects of type :c:type:`struct in_addr`, which is the C type for the + needs objects of type :ctype:`struct in_addr`, which is the C type for the 32-bit packed binary data this function takes as an argument. If the string passed to this function is not exactly 4 bytes in length, @@ -461,14 +454,14 @@ Convert an IP address from its family-specific string format to a packed, binary format. :func:`inet_pton` is useful when a library or network protocol calls for - an object of type :c:type:`struct in_addr` (similar to :func:`inet_aton`) or - :c:type:`struct in6_addr`. + an object of type :ctype:`struct in_addr` (similar to :func:`inet_aton`) or + :ctype:`struct in6_addr`. Supported values for *address_family* are currently :const:`AF_INET` and :const:`AF_INET6`. If the IP address string *ip_string* is invalid, :exc:`socket.error` will be raised. Note that exactly what is valid depends on both the value of *address_family* and the underlying implementation of - :c:func:`inet_pton`. + :cfunc:`inet_pton`. Availability: Unix (maybe not all platforms). @@ -480,8 +473,8 @@ Convert a packed IP address (a string of some number of characters) to its standard, family-specific string representation (for example, ``'7.10.0.5'`` or ``'5aef:2b::8'``) :func:`inet_ntop` is useful when a library or network protocol - returns an object of type :c:type:`struct in_addr` (similar to :func:`inet_ntoa`) - or :c:type:`struct in6_addr`. + returns an object of type :ctype:`struct in_addr` (similar to :func:`inet_ntoa`) + or :ctype:`struct in6_addr`. Supported values for *address_family* are currently :const:`AF_INET` and :const:`AF_INET6`. If the string *packed_ip* is not the correct length for the @@ -562,7 +555,6 @@ automatically closed when they are garbage-collected. .. note:: - :meth:`close()` releases the resource associated with a connection but does not necessarily close the connection immediately. If you want to close the connection in a timely fashion, call :meth:`shutdown()` @@ -584,10 +576,10 @@ .. method:: socket.connect_ex(address) Like ``connect(address)``, but return an error indicator instead of raising an - exception for errors returned by the C-level :c:func:`connect` call (other + exception for errors returned by the C-level :cfunc:`connect` call (other problems, such as "host not found," can still raise exceptions). The error indicator is ``0`` if the operation succeeded, otherwise the value of the - :c:data:`errno` variable. This is useful to support, for example, asynchronous + :cdata:`errno` variable. This is useful to support, for example, asynchronous connects. .. note:: @@ -662,7 +654,7 @@ Return a :dfn:`file object` associated with the socket. (File objects are described in :ref:`bltin-file-objects`.) The file object - references a :c:func:`dup`\ ped version of the socket file descriptor, so the + references a :cfunc:`dup`\ ped version of the socket file descriptor, so the file object and socket object may be closed or garbage-collected independently. The socket must be in blocking mode (it can not have a timeout). The optional *mode* and *bufsize* arguments are interpreted the same way as by the built-in @@ -726,8 +718,7 @@ optional *flags* argument has the same meaning as for :meth:`recv` above. Returns the number of bytes sent. Applications are responsible for checking that all data has been sent; if only some of the data was transmitted, the - application needs to attempt delivery of the remaining data. For further - information on this concept, consult the :ref:`socket-howto`. + application needs to attempt delivery of the remaining data. .. method:: socket.sendall(string[, flags]) @@ -740,8 +731,7 @@ much data, if any, was successfully sent. -.. method:: socket.sendto(string, address) - socket.sendto(string, flags, address) +.. method:: socket.sendto(string[, flags], address) Send data to the socket. The socket should not be connected to a remote socket, since the destination socket is specified by *address*. The optional *flags* @@ -862,12 +852,12 @@ Here are four minimal example programs using the TCP/IP protocol: a server that echoes all data that it receives back (servicing only one client), and a client -using it. Note that a server must perform the sequence :func:`.socket`, +using it. Note that a server must perform the sequence :func:`socket`, :meth:`~socket.bind`, :meth:`~socket.listen`, :meth:`~socket.accept` (possibly repeating the :meth:`~socket.accept` to service more than one client), while a -client only needs the sequence :func:`.socket`, :meth:`~socket.connect`. Also -note that the server does not :meth:`~socket.sendall`/:meth:`~socket.recv` on -the socket it is listening on but on the new socket returned by +client only needs the sequence :func:`socket`, :meth:`~socket.connect`. Also +note that the server does not :meth:`~socket.send`/:meth:`~socket.recv` on the +socket it is listening on but on the new socket returned by :meth:`~socket.accept`. The first two examples support IPv4 only. :: @@ -885,7 +875,7 @@ while 1: data = conn.recv(1024) if not data: break - conn.sendall(data) + conn.send(data) conn.close() :: @@ -897,7 +887,7 @@ PORT = 50007 # The same port as used by the server s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.connect((HOST, PORT)) - s.sendall('Hello, world') + s.send('Hello, world') data = s.recv(1024) s.close() print 'Received', repr(data) @@ -921,13 +911,13 @@ af, socktype, proto, canonname, sa = res try: s = socket.socket(af, socktype, proto) - except socket.error as msg: + except socket.error, msg: s = None continue try: s.bind(sa) s.listen(1) - except socket.error as msg: + except socket.error, msg: s.close() s = None continue @@ -956,12 +946,12 @@ af, socktype, proto, canonname, sa = res try: s = socket.socket(af, socktype, proto) - except socket.error as msg: + except socket.error, msg: s = None continue try: s.connect(sa) - except socket.error as msg: + except socket.error, msg: s.close() s = None continue @@ -969,7 +959,7 @@ if s is None: print 'could not open socket' sys.exit(1) - s.sendall('Hello, world') + s.send('Hello, world') data = s.recv(1024) s.close() print 'Received', repr(data) diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/library/socketserver.rst --- a/Doc/library/socketserver.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/library/socketserver.rst Sun Jul 20 10:52:46 2014 -0400 @@ -7,8 +7,8 @@ .. note:: The :mod:`SocketServer` module has been renamed to :mod:`socketserver` in - Python 3. The :term:`2to3` tool will automatically adapt imports when - converting your sources to Python 3. + Python 3.0. The :term:`2to3` tool will automatically adapt imports when + converting your sources to 3.0. **Source code:** :source:`Lib/SocketServer.py` @@ -116,13 +116,13 @@ the request handler class :meth:`handle` method. Another approach to handling multiple simultaneous requests in an environment -that supports neither threads nor :func:`~os.fork` (or where these are too -expensive or inappropriate for the service) is to maintain an explicit table of -partially finished requests and to use :func:`~select.select` to decide which -request to work on next (or whether to handle a new incoming request). This is -particularly important for stream services where each client can potentially be -connected for a long time (if threads or subprocesses cannot be used). See -:mod:`asyncore` for another way to manage this. +that supports neither threads nor :func:`fork` (or where these are too expensive +or inappropriate for the service) is to maintain an explicit table of partially +finished requests and to use :func:`select` to decide which request to work on +next (or whether to handle a new incoming request). This is particularly +important for stream services where each client can potentially be connected for +a long time (if threads or subprocesses cannot be used). See :mod:`asyncore` for +another way to manage this. .. XXX should data and methods be intermingled, or separate? how should the distinction between class and instance variables be drawn? @@ -158,14 +158,13 @@ .. method:: BaseServer.serve_forever(poll_interval=0.5) - Handle requests until an explicit :meth:`shutdown` request. - Poll for shutdown every *poll_interval* seconds. Ignores :attr:`self.timeout`. - If you need to do periodic tasks, do them in another thread. + Handle requests until an explicit :meth:`shutdown` request. Polls for + shutdown every *poll_interval* seconds. .. method:: BaseServer.shutdown() - Tell the :meth:`serve_forever` loop to stop and wait until it does. + Tells the :meth:`serve_forever` loop to stop and waits until it does. .. versionadded:: 2.6 @@ -306,8 +305,8 @@ .. method:: RequestHandler.finish() Called after the :meth:`handle` method to perform any clean-up actions - required. The default implementation does nothing. If :meth:`setup` - raises an exception, this function will not be called. + required. The default implementation does nothing. If :meth:`setup` or + :meth:`handle` raise an exception, this function will not be called. .. method:: RequestHandler.handle() @@ -360,7 +359,7 @@ print "{} wrote:".format(self.client_address[0]) print self.data # just send back the same data, but upper-cased - self.request.sendall(self.data.upper()) + self.request.send(self.data.upper()) if __name__ == "__main__": HOST, PORT = "localhost", 9999 @@ -390,7 +389,7 @@ The difference is that the ``readline()`` call in the second handler will call ``recv()`` multiple times until it encounters a newline character, while the single ``recv()`` call in the first handler will just return what has been sent -from the client in one ``sendall()`` call. +from the client in one ``send()`` call. This is the client side:: @@ -407,7 +406,7 @@ try: # Connect to server and send data sock.connect((HOST, PORT)) - sock.sendall(data + "\n") + sock.send(data + "\n") # Receive data from the server and shut down received = sock.recv(1024) @@ -505,7 +504,7 @@ data = self.request.recv(1024) cur_thread = threading.current_thread() response = "{}: {}".format(cur_thread.name, data) - self.request.sendall(response) + self.request.send(response) class ThreadedTCPServer(SocketServer.ThreadingMixIn, SocketServer.TCPServer): pass @@ -514,7 +513,7 @@ sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) sock.connect((ip, port)) try: - sock.sendall(message) + sock.send(message) response = sock.recv(1024) print "Received: {}".format(response) finally: diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/library/sqlite3.rst --- a/Doc/library/sqlite3.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/library/sqlite3.rst Sun Jul 20 10:52:46 2014 -0400 @@ -3,7 +3,7 @@ .. module:: sqlite3 :synopsis: A DB-API 2.0 implementation using SQLite 3.x. -.. sectionauthor:: Gerhard Häring +.. sectionauthor:: Gerhard Häring .. versionadded:: 2.5 @@ -15,15 +15,14 @@ application using SQLite and then port the code to a larger database such as PostgreSQL or Oracle. -The sqlite3 module was written by Gerhard Häring. It provides a SQL interface -compliant with the DB-API 2.0 specification described by :pep:`249`. +sqlite3 was written by Gerhard Häring and provides a SQL interface compliant +with the DB-API 2.0 specification described by :pep:`249`. To use the module, you must first create a :class:`Connection` object that represents the database. Here the data will be stored in the -:file:`example.db` file:: +:file:`/tmp/example` file:: - import sqlite3 - conn = sqlite3.connect('example.db') + conn = sqlite3.connect('/tmp/example') You can also supply the special name ``:memory:`` to create a database in RAM. @@ -33,29 +32,23 @@ c = conn.cursor() # Create table - c.execute('''CREATE TABLE stocks - (date text, trans text, symbol text, qty real, price real)''') + c.execute('''create table stocks + (date text, trans text, symbol text, + qty real, price real)''') # Insert a row of data - c.execute("INSERT INTO stocks VALUES ('2006-01-05','BUY','RHAT',100,35.14)") + c.execute("""insert into stocks + values ('2006-01-05','BUY','RHAT',100,35.14)""") # Save (commit) the changes conn.commit() - # We can also close the connection if we are done with it. - # Just be sure any changes have been committed or they will be lost. - conn.close() - -The data you've saved is persistent and is available in subsequent sessions:: - - import sqlite3 - conn = sqlite3.connect('example.db') - c = conn.cursor() + # We can also close the cursor if we are done with it + c.close() Usually your SQL operations will need to use values from Python variables. You shouldn't assemble your query using Python's string operations because doing so -is insecure; it makes your program vulnerable to an SQL injection attack -(see http://xkcd.com/327/ for humorous example of what can go wrong). +is insecure; it makes your program vulnerable to an SQL injection attack. Instead, use the DB-API's parameter substitution. Put ``?`` as a placeholder wherever you want to use a value, and then provide a tuple of values as the @@ -64,20 +57,19 @@ example:: # Never do this -- insecure! - symbol = 'RHAT' - c.execute("SELECT * FROM stocks WHERE symbol = '%s'" % symbol) + symbol = 'IBM' + c.execute("... where symbol = '%s'" % symbol) # Do this instead - t = ('RHAT',) - c.execute('SELECT * FROM stocks WHERE symbol=?', t) - print c.fetchone() + t = (symbol,) + c.execute('select * from stocks where symbol=?', t) - # Larger example that inserts many records at a time - purchases = [('2006-03-28', 'BUY', 'IBM', 1000, 45.00), - ('2006-04-05', 'BUY', 'MSFT', 1000, 72.00), - ('2006-04-06', 'SELL', 'IBM', 500, 53.00), - ] - c.executemany('INSERT INTO stocks VALUES (?,?,?,?,?)', purchases) + # Larger example + for t in [('2006-03-28', 'BUY', 'IBM', 1000, 45.00), + ('2006-04-05', 'BUY', 'MSOFT', 1000, 72.00), + ('2006-04-06', 'SELL', 'IBM', 500, 53.00), + ]: + c.execute('insert into stocks values (?,?,?,?,?)', t) To retrieve data after executing a SELECT statement, you can either treat the cursor as an :term:`iterator`, call the cursor's :meth:`~Cursor.fetchone` method to @@ -86,18 +78,21 @@ This example uses the iterator form:: - >>> for row in c.execute('SELECT * FROM stocks ORDER BY price'): - print row - + >>> c = conn.cursor() + >>> c.execute('select * from stocks order by price') + >>> for row in c: + ... print row + ... (u'2006-01-05', u'BUY', u'RHAT', 100, 35.14) (u'2006-03-28', u'BUY', u'IBM', 1000, 45.0) (u'2006-04-06', u'SELL', u'IBM', 500, 53.0) - (u'2006-04-05', u'BUY', u'MSFT', 1000, 72.0) + (u'2006-04-05', u'BUY', u'MSOFT', 1000, 72.0) + >>> .. seealso:: - https://github.com/ghaering/pysqlite + http://code.google.com/p/pysqlite/ The pysqlite web page -- sqlite3 is developed externally under the name "pysqlite". @@ -105,9 +100,6 @@ The SQLite web page; the documentation describes the syntax and the available data types for the supported SQL dialect. - http://www.w3schools.com/sql/ - Tutorial, reference and examples for learning SQL syntax. - :pep:`249` - Database API Specification 2.0 PEP written by Marc-André Lemburg. @@ -118,24 +110,6 @@ ------------------------------ -.. data:: version - - The version number of this module, as a string. This is not the version of - the SQLite library. - -.. data:: version_info - - The version number of this module, as a tuple of integers. This is not the - version of the SQLite library. - -.. data:: sqlite_version - - The version number of the run-time SQLite library, as a string. - -.. data:: sqlite_version_info - - The version number of the run-time SQLite library, as a tuple of integers. - .. data:: PARSE_DECLTYPES This constant is meant to be used with the *detect_types* parameter of the @@ -179,7 +153,7 @@ For the *isolation_level* parameter, please see the :attr:`Connection.isolation_level` property of :class:`Connection` objects. - SQLite natively supports only the types TEXT, INTEGER, REAL, BLOB and NULL. If + SQLite natively supports only the types TEXT, INTEGER, FLOAT, BLOB and NULL. If you want to use other types you must add support for them yourself. The *detect_types* parameter and the using custom **converters** registered with the module-level :func:`register_converter` function allow you to easily do that. @@ -234,10 +208,10 @@ .. function:: enable_callback_tracebacks(flag) By default you will not get any tracebacks in user-defined functions, - aggregates, converters, authorizer callbacks etc. If you want to debug them, - you can call this function with *flag* set to ``True``. Afterwards, you will - get tracebacks from callbacks on ``sys.stderr``. Use :const:`False` to - disable the feature again. + aggregates, converters, authorizer callbacks etc. If you want to debug them, you + can call this function with *flag* as True. Afterwards, you will get tracebacks + from callbacks on ``sys.stderr``. Use :const:`False` to disable the feature + again. .. _sqlite3-connection-objects: @@ -249,236 +223,237 @@ A SQLite database connection has the following attributes and methods: - .. attribute:: isolation_level +.. attribute:: Connection.isolation_level - Get or set the current isolation level. :const:`None` for autocommit mode or - one of "DEFERRED", "IMMEDIATE" or "EXCLUSIVE". See section - :ref:`sqlite3-controlling-transactions` for a more detailed explanation. + Get or set the current isolation level. :const:`None` for autocommit mode or + one of "DEFERRED", "IMMEDIATE" or "EXCLUSIVE". See section + :ref:`sqlite3-controlling-transactions` for a more detailed explanation. - .. method:: cursor([cursorClass]) +.. method:: Connection.cursor([cursorClass]) - The cursor method accepts a single optional parameter *cursorClass*. If - supplied, this must be a custom cursor class that extends - :class:`sqlite3.Cursor`. + The cursor method accepts a single optional parameter *cursorClass*. If + supplied, this must be a custom cursor class that extends + :class:`sqlite3.Cursor`. - .. method:: commit() - This method commits the current transaction. If you don't call this method, - anything you did since the last call to ``commit()`` is not visible from - other database connections. If you wonder why you don't see the data you've - written to the database, please check you didn't forget to call this method. +.. method:: Connection.commit() - .. method:: rollback() + This method commits the current transaction. If you don't call this method, + anything you did since the last call to ``commit()`` is not visible from + other database connections. If you wonder why you don't see the data you've + written to the database, please check you didn't forget to call this method. - This method rolls back any changes to the database since the last call to - :meth:`commit`. +.. method:: Connection.rollback() - .. method:: close() + This method rolls back any changes to the database since the last call to + :meth:`commit`. - This closes the database connection. Note that this does not automatically - call :meth:`commit`. If you just close your database connection without - calling :meth:`commit` first, your changes will be lost! +.. method:: Connection.close() - .. method:: execute(sql, [parameters]) + This closes the database connection. Note that this does not automatically + call :meth:`commit`. If you just close your database connection without + calling :meth:`commit` first, your changes will be lost! - This is a nonstandard shortcut that creates an intermediate cursor object by - calling the cursor method, then calls the cursor's :meth:`execute - ` method with the parameters given. +.. method:: Connection.execute(sql, [parameters]) + This is a nonstandard shortcut that creates an intermediate cursor object by + calling the cursor method, then calls the cursor's :meth:`execute + ` method with the parameters given. - .. method:: executemany(sql, [parameters]) - This is a nonstandard shortcut that creates an intermediate cursor object by - calling the cursor method, then calls the cursor's :meth:`executemany - ` method with the parameters given. +.. method:: Connection.executemany(sql, [parameters]) - .. method:: executescript(sql_script) + This is a nonstandard shortcut that creates an intermediate cursor object by + calling the cursor method, then calls the cursor's :meth:`executemany + ` method with the parameters given. - This is a nonstandard shortcut that creates an intermediate cursor object by - calling the cursor method, then calls the cursor's :meth:`executescript - ` method with the parameters given. +.. method:: Connection.executescript(sql_script) + This is a nonstandard shortcut that creates an intermediate cursor object by + calling the cursor method, then calls the cursor's :meth:`executescript + ` method with the parameters given. - .. method:: create_function(name, num_params, func) - Creates a user-defined function that you can later use from within SQL - statements under the function name *name*. *num_params* is the number of - parameters the function accepts, and *func* is a Python callable that is called - as the SQL function. +.. method:: Connection.create_function(name, num_params, func) - The function can return any of the types supported by SQLite: unicode, str, int, - long, float, buffer and None. + Creates a user-defined function that you can later use from within SQL + statements under the function name *name*. *num_params* is the number of + parameters the function accepts, and *func* is a Python callable that is called + as the SQL function. - Example: + The function can return any of the types supported by SQLite: unicode, str, int, + long, float, buffer and None. - .. literalinclude:: ../includes/sqlite3/md5func.py + Example: + .. literalinclude:: ../includes/sqlite3/md5func.py - .. method:: create_aggregate(name, num_params, aggregate_class) - Creates a user-defined aggregate function. +.. method:: Connection.create_aggregate(name, num_params, aggregate_class) - The aggregate class must implement a ``step`` method, which accepts the number - of parameters *num_params*, and a ``finalize`` method which will return the - final result of the aggregate. + Creates a user-defined aggregate function. - The ``finalize`` method can return any of the types supported by SQLite: - unicode, str, int, long, float, buffer and None. + The aggregate class must implement a ``step`` method, which accepts the number + of parameters *num_params*, and a ``finalize`` method which will return the + final result of the aggregate. - Example: + The ``finalize`` method can return any of the types supported by SQLite: + unicode, str, int, long, float, buffer and None. - .. literalinclude:: ../includes/sqlite3/mysumaggr.py + Example: + .. literalinclude:: ../includes/sqlite3/mysumaggr.py - .. method:: create_collation(name, callable) - Creates a collation with the specified *name* and *callable*. The callable will - be passed two string arguments. It should return -1 if the first is ordered - lower than the second, 0 if they are ordered equal and 1 if the first is ordered - higher than the second. Note that this controls sorting (ORDER BY in SQL) so - your comparisons don't affect other SQL operations. +.. method:: Connection.create_collation(name, callable) - Note that the callable will get its parameters as Python bytestrings, which will - normally be encoded in UTF-8. + Creates a collation with the specified *name* and *callable*. The callable will + be passed two string arguments. It should return -1 if the first is ordered + lower than the second, 0 if they are ordered equal and 1 if the first is ordered + higher than the second. Note that this controls sorting (ORDER BY in SQL) so + your comparisons don't affect other SQL operations. - The following example shows a custom collation that sorts "the wrong way": + Note that the callable will get its parameters as Python bytestrings, which will + normally be encoded in UTF-8. - .. literalinclude:: ../includes/sqlite3/collation_reverse.py + The following example shows a custom collation that sorts "the wrong way": - To remove a collation, call ``create_collation`` with None as callable:: + .. literalinclude:: ../includes/sqlite3/collation_reverse.py - con.create_collation("reverse", None) + To remove a collation, call ``create_collation`` with None as callable:: + con.create_collation("reverse", None) - .. method:: interrupt() - You can call this method from a different thread to abort any queries that might - be executing on the connection. The query will then abort and the caller will - get an exception. +.. method:: Connection.interrupt() + You can call this method from a different thread to abort any queries that might + be executing on the connection. The query will then abort and the caller will + get an exception. - .. method:: set_authorizer(authorizer_callback) - This routine registers a callback. The callback is invoked for each attempt to - access a column of a table in the database. The callback should return - :const:`SQLITE_OK` if access is allowed, :const:`SQLITE_DENY` if the entire SQL - statement should be aborted with an error and :const:`SQLITE_IGNORE` if the - column should be treated as a NULL value. These constants are available in the - :mod:`sqlite3` module. +.. method:: Connection.set_authorizer(authorizer_callback) - The first argument to the callback signifies what kind of operation is to be - authorized. The second and third argument will be arguments or :const:`None` - depending on the first argument. The 4th argument is the name of the database - ("main", "temp", etc.) if applicable. The 5th argument is the name of the - inner-most trigger or view that is responsible for the access attempt or - :const:`None` if this access attempt is directly from input SQL code. + This routine registers a callback. The callback is invoked for each attempt to + access a column of a table in the database. The callback should return + :const:`SQLITE_OK` if access is allowed, :const:`SQLITE_DENY` if the entire SQL + statement should be aborted with an error and :const:`SQLITE_IGNORE` if the + column should be treated as a NULL value. These constants are available in the + :mod:`sqlite3` module. - Please consult the SQLite documentation about the possible values for the first - argument and the meaning of the second and third argument depending on the first - one. All necessary constants are available in the :mod:`sqlite3` module. + The first argument to the callback signifies what kind of operation is to be + authorized. The second and third argument will be arguments or :const:`None` + depending on the first argument. The 4th argument is the name of the database + ("main", "temp", etc.) if applicable. The 5th argument is the name of the + inner-most trigger or view that is responsible for the access attempt or + :const:`None` if this access attempt is directly from input SQL code. + Please consult the SQLite documentation about the possible values for the first + argument and the meaning of the second and third argument depending on the first + one. All necessary constants are available in the :mod:`sqlite3` module. - .. method:: set_progress_handler(handler, n) - This routine registers a callback. The callback is invoked for every *n* - instructions of the SQLite virtual machine. This is useful if you want to - get called from SQLite during long-running operations, for example to update - a GUI. +.. method:: Connection.set_progress_handler(handler, n) - If you want to clear any previously installed progress handler, call the - method with :const:`None` for *handler*. + .. versionadded:: 2.6 - .. versionadded:: 2.6 + This routine registers a callback. The callback is invoked for every *n* + instructions of the SQLite virtual machine. This is useful if you want to + get called from SQLite during long-running operations, for example to update + a GUI. + If you want to clear any previously installed progress handler, call the + method with :const:`None` for *handler*. - .. method:: enable_load_extension(enabled) - This routine allows/disallows the SQLite engine to load SQLite extensions - from shared libraries. SQLite extensions can define new functions, - aggregates or whole new virtual table implementations. One well-known - extension is the fulltext-search extension distributed with SQLite. +.. method:: Connection.enable_load_extension(enabled) - Loadable extensions are disabled by default. See [#f1]_. + .. versionadded:: 2.7 - .. versionadded:: 2.7 + This routine allows/disallows the SQLite engine to load SQLite extensions + from shared libraries. SQLite extensions can define new functions, + aggregates or whole new virtual table implementations. One well-known + extension is the fulltext-search extension distributed with SQLite. - .. literalinclude:: ../includes/sqlite3/load_extension.py + .. literalinclude:: ../includes/sqlite3/load_extension.py - .. method:: load_extension(path) + Loadable extensions are disabled by default. See [#f1]_ - This routine loads a SQLite extension from a shared library. You have to - enable extension loading with :meth:`enable_load_extension` before you can - use this routine. +.. method:: Connection.load_extension(path) - Loadable extensions are disabled by default. See [#f1]_. + .. versionadded:: 2.7 - .. versionadded:: 2.7 + This routine loads a SQLite extension from a shared library. You have to + enable extension loading with :meth:`enable_load_extension` before you can + use this routine. - .. attribute:: row_factory + Loadable extensions are disabled by default. See [#f1]_ - You can change this attribute to a callable that accepts the cursor and the - original row as a tuple and will return the real result row. This way, you can - implement more advanced ways of returning results, such as returning an object - that can also access columns by name. +.. attribute:: Connection.row_factory - Example: + You can change this attribute to a callable that accepts the cursor and the + original row as a tuple and will return the real result row. This way, you can + implement more advanced ways of returning results, such as returning an object + that can also access columns by name. - .. literalinclude:: ../includes/sqlite3/row_factory.py + Example: - If returning a tuple doesn't suffice and you want name-based access to - columns, you should consider setting :attr:`row_factory` to the - highly-optimized :class:`sqlite3.Row` type. :class:`Row` provides both - index-based and case-insensitive name-based access to columns with almost no - memory overhead. It will probably be better than your own custom - dictionary-based approach or even a db_row based solution. + .. literalinclude:: ../includes/sqlite3/row_factory.py - .. XXX what's a db_row-based solution? + If returning a tuple doesn't suffice and you want name-based access to + columns, you should consider setting :attr:`row_factory` to the + highly-optimized :class:`sqlite3.Row` type. :class:`Row` provides both + index-based and case-insensitive name-based access to columns with almost no + memory overhead. It will probably be better than your own custom + dictionary-based approach or even a db_row based solution. + .. XXX what's a db_row-based solution? - .. attribute:: text_factory - Using this attribute you can control what objects are returned for the ``TEXT`` - data type. By default, this attribute is set to :class:`unicode` and the - :mod:`sqlite3` module will return Unicode objects for ``TEXT``. If you want to - return bytestrings instead, you can set it to :class:`str`. +.. attribute:: Connection.text_factory - For efficiency reasons, there's also a way to return Unicode objects only for - non-ASCII data, and bytestrings otherwise. To activate it, set this attribute to - :const:`sqlite3.OptimizedUnicode`. + Using this attribute you can control what objects are returned for the ``TEXT`` + data type. By default, this attribute is set to :class:`unicode` and the + :mod:`sqlite3` module will return Unicode objects for ``TEXT``. If you want to + return bytestrings instead, you can set it to :class:`str`. - You can also set it to any other callable that accepts a single bytestring - parameter and returns the resulting object. + For efficiency reasons, there's also a way to return Unicode objects only for + non-ASCII data, and bytestrings otherwise. To activate it, set this attribute to + :const:`sqlite3.OptimizedUnicode`. - See the following example code for illustration: + You can also set it to any other callable that accepts a single bytestring + parameter and returns the resulting object. - .. literalinclude:: ../includes/sqlite3/text_factory.py + See the following example code for illustration: + .. literalinclude:: ../includes/sqlite3/text_factory.py - .. attribute:: total_changes - Returns the total number of database rows that have been modified, inserted, or - deleted since the database connection was opened. +.. attribute:: Connection.total_changes + Returns the total number of database rows that have been modified, inserted, or + deleted since the database connection was opened. - .. attribute:: iterdump - Returns an iterator to dump the database in an SQL text format. Useful when - saving an in-memory database for later restoration. This function provides - the same capabilities as the :kbd:`.dump` command in the :program:`sqlite3` - shell. +.. attribute:: Connection.iterdump - .. versionadded:: 2.6 + Returns an iterator to dump the database in an SQL text format. Useful when + saving an in-memory database for later restoration. This function provides + the same capabilities as the :kbd:`.dump` command in the :program:`sqlite3` + shell. - Example:: + .. versionadded:: 2.6 - # Convert file existing_db.db to SQL dump file dump.sql - import sqlite3, os + Example:: - con = sqlite3.connect('existing_db.db') - with open('dump.sql', 'w') as f: - for line in con.iterdump(): - f.write('%s\n' % line) + # Convert file existing_db.db to SQL dump file dump.sql + import sqlite3, os + + con = sqlite3.connect('existing_db.db') + with open('dump.sql', 'w') as f: + for line in con.iterdump(): + f.write('%s\n' % line) .. _sqlite3-cursor-objects: @@ -490,110 +465,115 @@ A :class:`Cursor` instance has the following attributes and methods. - .. method:: execute(sql, [parameters]) +.. method:: Cursor.execute(sql, [parameters]) - Executes an SQL statement. The SQL statement may be parameterized (i. e. - placeholders instead of SQL literals). The :mod:`sqlite3` module supports two - kinds of placeholders: question marks (qmark style) and named placeholders - (named style). + Executes an SQL statement. The SQL statement may be parametrized (i. e. + placeholders instead of SQL literals). The :mod:`sqlite3` module supports two + kinds of placeholders: question marks (qmark style) and named placeholders + (named style). - Here's an example of both styles: + This example shows how to use parameters with qmark style: - .. literalinclude:: ../includes/sqlite3/execute_1.py + .. literalinclude:: ../includes/sqlite3/execute_1.py - :meth:`execute` will only execute a single SQL statement. If you try to execute - more than one statement with it, it will raise a Warning. Use - :meth:`executescript` if you want to execute multiple SQL statements with one - call. + This example shows how to use the named style: + .. literalinclude:: ../includes/sqlite3/execute_2.py - .. method:: executemany(sql, seq_of_parameters) + :meth:`execute` will only execute a single SQL statement. If you try to execute + more than one statement with it, it will raise a Warning. Use + :meth:`executescript` if you want to execute multiple SQL statements with one + call. - Executes an SQL command against all parameter sequences or mappings found in - the sequence *sql*. The :mod:`sqlite3` module also allows using an - :term:`iterator` yielding parameters instead of a sequence. - .. literalinclude:: ../includes/sqlite3/executemany_1.py +.. method:: Cursor.executemany(sql, seq_of_parameters) - Here's a shorter example using a :term:`generator`: + Executes an SQL command against all parameter sequences or mappings found in + the sequence *sql*. The :mod:`sqlite3` module also allows using an + :term:`iterator` yielding parameters instead of a sequence. - .. literalinclude:: ../includes/sqlite3/executemany_2.py + .. literalinclude:: ../includes/sqlite3/executemany_1.py + Here's a shorter example using a :term:`generator`: - .. method:: executescript(sql_script) + .. literalinclude:: ../includes/sqlite3/executemany_2.py - This is a nonstandard convenience method for executing multiple SQL statements - at once. It issues a ``COMMIT`` statement first, then executes the SQL script it - gets as a parameter. - *sql_script* can be a bytestring or a Unicode string. +.. method:: Cursor.executescript(sql_script) - Example: + This is a nonstandard convenience method for executing multiple SQL statements + at once. It issues a ``COMMIT`` statement first, then executes the SQL script it + gets as a parameter. - .. literalinclude:: ../includes/sqlite3/executescript.py + *sql_script* can be a bytestring or a Unicode string. + Example: - .. method:: fetchone() + .. literalinclude:: ../includes/sqlite3/executescript.py - Fetches the next row of a query result set, returning a single sequence, - or :const:`None` when no more data is available. +.. method:: Cursor.fetchone() - .. method:: fetchmany([size=cursor.arraysize]) + Fetches the next row of a query result set, returning a single sequence, + or :const:`None` when no more data is available. - Fetches the next set of rows of a query result, returning a list. An empty - list is returned when no more rows are available. - The number of rows to fetch per call is specified by the *size* parameter. - If it is not given, the cursor's arraysize determines the number of rows - to be fetched. The method should try to fetch as many rows as indicated by - the size parameter. If this is not possible due to the specified number of - rows not being available, fewer rows may be returned. +.. method:: Cursor.fetchmany([size=cursor.arraysize]) - Note there are performance considerations involved with the *size* parameter. - For optimal performance, it is usually best to use the arraysize attribute. - If the *size* parameter is used, then it is best for it to retain the same - value from one :meth:`fetchmany` call to the next. + Fetches the next set of rows of a query result, returning a list. An empty + list is returned when no more rows are available. - .. method:: fetchall() + The number of rows to fetch per call is specified by the *size* parameter. + If it is not given, the cursor's arraysize determines the number of rows + to be fetched. The method should try to fetch as many rows as indicated by + the size parameter. If this is not possible due to the specified number of + rows not being available, fewer rows may be returned. - Fetches all (remaining) rows of a query result, returning a list. Note that - the cursor's arraysize attribute can affect the performance of this operation. - An empty list is returned when no rows are available. + Note there are performance considerations involved with the *size* parameter. + For optimal performance, it is usually best to use the arraysize attribute. + If the *size* parameter is used, then it is best for it to retain the same + value from one :meth:`fetchmany` call to the next. +.. method:: Cursor.fetchall() - .. attribute:: rowcount + Fetches all (remaining) rows of a query result, returning a list. Note that + the cursor's arraysize attribute can affect the performance of this operation. + An empty list is returned when no rows are available. - Although the :class:`Cursor` class of the :mod:`sqlite3` module implements this - attribute, the database engine's own support for the determination of "rows - affected"/"rows selected" is quirky. - For :meth:`executemany` statements, the number of modifications are summed up - into :attr:`rowcount`. +.. attribute:: Cursor.rowcount - As required by the Python DB API Spec, the :attr:`rowcount` attribute "is -1 in - case no ``executeXX()`` has been performed on the cursor or the rowcount of the - last operation is not determinable by the interface". This includes ``SELECT`` - statements because we cannot determine the number of rows a query produced - until all rows were fetched. + Although the :class:`Cursor` class of the :mod:`sqlite3` module implements this + attribute, the database engine's own support for the determination of "rows + affected"/"rows selected" is quirky. - With SQLite versions before 3.6.5, :attr:`rowcount` is set to 0 if - you make a ``DELETE FROM table`` without any condition. + For ``DELETE`` statements, SQLite reports :attr:`rowcount` as 0 if you make a + ``DELETE FROM table`` without any condition. - .. attribute:: lastrowid + For :meth:`executemany` statements, the number of modifications are summed up + into :attr:`rowcount`. - This read-only attribute provides the rowid of the last modified row. It is - only set if you issued a ``INSERT`` statement using the :meth:`execute` - method. For operations other than ``INSERT`` or when :meth:`executemany` is - called, :attr:`lastrowid` is set to :const:`None`. + As required by the Python DB API Spec, the :attr:`rowcount` attribute "is -1 in + case no ``executeXX()`` has been performed on the cursor or the rowcount of the + last operation is not determinable by the interface". - .. attribute:: description + This includes ``SELECT`` statements because we cannot determine the number of + rows a query produced until all rows were fetched. - This read-only attribute provides the column names of the last query. To - remain compatible with the Python DB API, it returns a 7-tuple for each - column where the last six items of each tuple are :const:`None`. +.. attribute:: Cursor.lastrowid - It is set for ``SELECT`` statements without any matching rows as well. + This read-only attribute provides the rowid of the last modified row. It is + only set if you issued a ``INSERT`` statement using the :meth:`execute` + method. For operations other than ``INSERT`` or when :meth:`executemany` is + called, :attr:`lastrowid` is set to :const:`None`. + +.. attribute:: Cursor.description + + This read-only attribute provides the column names of the last query. To + remain compatible with the Python DB API, it returns a 7-tuple for each + column where the last six items of each tuple are :const:`None`. + + It is set for ``SELECT`` statements without any matching rows as well. .. _sqlite3-row-objects: @@ -617,7 +597,7 @@ .. method:: keys - This method returns a list of column names. Immediately after a query, + This method returns a tuple of column names. Immediately after a query, it is the first member of each tuple in :attr:`Cursor.description`. .. versionadded:: 2.6 @@ -653,8 +633,7 @@ ['date', 'trans', 'symbol', 'qty', 'price'] >>> r['qty'] 100.0 - >>> for member in r: - ... print member + >>> for member in r: print member ... 2006-01-05 BUY @@ -727,6 +706,9 @@ sqlite3 module's supported types for SQLite: one of NoneType, int, long, float, str, unicode, buffer. +The :mod:`sqlite3` module uses Python object adaptation, as described in +:pep:`246` for this. The protocol to use is :class:`PrepareProtocol`. + There are two ways to enable the :mod:`sqlite3` module to adapt a custom Python type to one of the supported ones. @@ -829,10 +811,6 @@ .. literalinclude:: ../includes/sqlite3/pysqlite_datetime.py -If a timestamp stored in SQLite has a fractional part longer than 6 -numbers, its value will be truncated to microsecond precision by the -timestamp converter. - .. _sqlite3-controlling-transactions: diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/library/ssl.rst --- a/Doc/library/ssl.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/library/ssl.rst Sun Jul 20 10:52:46 2014 -0400 @@ -30,18 +30,6 @@ operating system socket APIs. The installed version of OpenSSL may also cause variations in behavior. -.. warning:: - The ssl module won't validate certificates by default. When used in - client mode, this means you are vulnerable to man-in-the-middle attacks. - -.. warning:: - - OpenSSL's internal random number generator does not properly handle fork. - Applications must change the PRNG state of the parent process if they use - any SSL feature with :func:`os.fork`. Any successful call of - :func:`~ssl.RAND_add`, :func:`~ssl.RAND_bytes` or - :func:`~ssl.RAND_pseudo_bytes` is sufficient. - This section documents the objects and functions in the ``ssl`` module; for more general information about TLS, SSL, and certificates, the reader is referred to the documents in the "See Also" section at the bottom. @@ -69,16 +57,13 @@ Takes an instance ``sock`` of :class:`socket.socket`, and returns an instance of :class:`ssl.SSLSocket`, a subtype of :class:`socket.socket`, which wraps - the underlying socket in an SSL context. ``sock`` must be a - :data:`~socket.SOCK_STREAM` socket; other socket types are unsupported. - - For client-side sockets, the context construction is lazy; if the - underlying socket isn't connected yet, the context construction will be - performed after :meth:`connect` is called on the socket. For - server-side sockets, if the socket has no remote peer, it is assumed - to be a listening socket, and the server-side SSL wrapping is - automatically performed on client connections accepted via the - :meth:`accept` method. :func:`wrap_socket` may raise :exc:`SSLError`. + the underlying socket in an SSL context. For client-side sockets, the + context construction is lazy; if the underlying socket isn't connected yet, + the context construction will be performed after :meth:`connect` is called on + the socket. For server-side sockets, if the socket has no remote peer, it is + assumed to be a listening socket, and the server-side SSL wrapping is + automatically performed on client connections accepted via the :meth:`accept` + method. :func:`wrap_socket` may raise :exc:`SSLError`. The ``keyfile`` and ``certfile`` parameters specify optional files which contain a certificate to be used to identify the local side of the @@ -118,8 +103,9 @@ The parameter ``ssl_version`` specifies which version of the SSL protocol to use. Typically, the server chooses a particular protocol version, and the client must adapt to the server's choice. Most of the versions are not - interoperable with the other versions. If not specified, the default is - :data:`PROTOCOL_SSLv23`; it provides the most compatibility with other + interoperable with the other versions. If not specified, for client-side + operation, the default SSL version is SSLv3; for server-side operation, + SSLv23. These version selections provide the most compatibility with other versions. Here's a table showing which versions in a client (down the side) can connect @@ -131,7 +117,7 @@ *client* / **server** **SSLv2** **SSLv3** **SSLv23** **TLSv1** ------------------------ --------- --------- ---------- --------- *SSLv2* yes no yes no - *SSLv3* no yes yes no + *SSLv3* yes yes yes no *SSLv23* yes no yes no *TLSv1* no no yes yes ======================== ========= ========= ========== ========= @@ -169,7 +155,7 @@ .. function:: RAND_status() - Returns ``True`` if the SSL pseudo-random number generator has been seeded with + Returns True if the SSL pseudo-random number generator has been seeded with 'enough' randomness, and False otherwise. You can use :func:`ssl.RAND_egd` and :func:`ssl.RAND_add` to increase the randomness of the pseudo-random number generator. @@ -313,37 +299,21 @@ SSLSocket Objects ----------------- -SSL sockets provide the following methods of :ref:`socket-objects`: +.. method:: SSLSocket.read([nbytes=1024]) -- :meth:`~socket.socket.accept()` -- :meth:`~socket.socket.bind()` -- :meth:`~socket.socket.close()` -- :meth:`~socket.socket.connect()` -- :meth:`~socket.socket.fileno()` -- :meth:`~socket.socket.getpeername()`, :meth:`~socket.socket.getsockname()` -- :meth:`~socket.socket.getsockopt()`, :meth:`~socket.socket.setsockopt()` -- :meth:`~socket.socket.gettimeout()`, :meth:`~socket.socket.settimeout()`, - :meth:`~socket.socket.setblocking()` -- :meth:`~socket.socket.listen()` -- :meth:`~socket.socket.makefile()` -- :meth:`~socket.socket.recv()`, :meth:`~socket.socket.recv_into()` - (but passing a non-zero ``flags`` argument is not allowed) -- :meth:`~socket.socket.send()`, :meth:`~socket.socket.sendall()` (with - the same limitation) -- :meth:`~socket.socket.shutdown()` + Reads up to ``nbytes`` bytes from the SSL-encrypted channel and returns them. -However, since the SSL (and TLS) protocol has its own framing atop -of TCP, the SSL sockets abstraction can, in certain respects, diverge from -the specification of normal, OS-level sockets. +.. method:: SSLSocket.write(data) -SSL sockets also have the following additional methods and attributes: + Writes the ``data`` to the other side of the connection, using the SSL + channel to encrypt. Returns the number of bytes written. .. method:: SSLSocket.getpeercert(binary_form=False) If there is no certificate for the peer on the other end of the connection, returns ``None``. - If the ``binary_form`` parameter is :const:`False`, and a certificate was + If the parameter ``binary_form`` is :const:`False`, and a certificate was received from the peer, this method returns a :class:`dict` instance. If the certificate was not validated, the dict is empty. If the certificate was validated, it returns a dict with the keys ``subject`` (the principal for @@ -369,16 +339,10 @@ If the ``binary_form`` parameter is :const:`True`, and a certificate was provided, this method returns the DER-encoded form of the entire certificate as a sequence of bytes, or :const:`None` if the peer did not provide a - certificate. Whether the peer provides a certificate depends on the SSL - socket's role: - - * for a client SSL socket, the server will always provide a certificate, - regardless of whether validation was required; - - * for a server SSL socket, the client will only provide a certificate - when requested by the server; therefore :meth:`getpeercert` will return - :const:`None` if you used :const:`CERT_NONE` (rather than - :const:`CERT_OPTIONAL` or :const:`CERT_REQUIRED`). + certificate. This return value is independent of validation; if validation + was required (:const:`CERT_OPTIONAL` or :const:`CERT_REQUIRED`), it will have + been validated, but if :const:`CERT_NONE` was used to establish the + connection, the certificate, if present, will not have been validated. .. method:: SSLSocket.cipher() @@ -398,7 +362,7 @@ try: s.do_handshake() break - except ssl.SSLError as err: + except ssl.SSLError, err: if err.args[0] == ssl.SSL_ERROR_WANT_READ: select.select([s], [], []) elif err.args[0] == ssl.SSL_ERROR_WANT_WRITE: @@ -490,7 +454,8 @@ chain it finds in the file which matches. Some "standard" root certificates are available from various certification -authorities: `Thawte `_, `Verisign +authorities: `CACert.org `_, `Thawte +`_, `Verisign `_, `Positive SSL `_ (used by python.org), `Equifax and GeoTrust @@ -655,10 +620,10 @@ .. seealso:: Class :class:`socket.socket` - Documentation of underlying :mod:`socket` class + Documentation of underlying :mod:`socket` class - `SSL/TLS Strong Encryption: An Introduction `_ - Intro from the Apache webserver documentation + `TLS (Transport Layer Security) and SSL (Secure Socket Layer) `_ + Debby Koren `RFC 1422: Privacy Enhancement for Internet Electronic Mail: Part II: Certificate-Based Key Management `_ Steve Kent diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/library/stat.rst --- a/Doc/library/stat.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/library/stat.rst Sun Jul 20 10:52:46 2014 -0400 @@ -1,5 +1,5 @@ -:mod:`stat` --- Interpreting :func:`~os.stat` results -===================================================== +:mod:`stat` --- Interpreting :func:`stat` results +================================================= .. module:: stat :synopsis: Utilities for interpreting the results of os.stat(), os.lstat() and os.fstat(). @@ -11,8 +11,8 @@ The :mod:`stat` module defines constants and functions for interpreting the results of :func:`os.stat`, :func:`os.fstat` and :func:`os.lstat` (if they -exist). For complete details about the :c:func:`stat`, :c:func:`fstat` and -:c:func:`lstat` calls, consult the documentation for your system. +exist). For complete details about the :cfunc:`stat`, :cfunc:`fstat` and +:cfunc:`lstat` calls, consult the documentation for your system. The :mod:`stat` module defines the following functions to test for specific file types: @@ -70,7 +70,7 @@ Normally, you would use the :func:`os.path.is\*` functions for testing the type of a file; the functions here are useful when you are doing multiple tests of -the same file and wish to avoid the overhead of the :c:func:`stat` system call +the same file and wish to avoid the overhead of the :cfunc:`stat` system call for each test. These are also useful when checking for information about a file that isn't handled by :mod:`os.path`, like the tests for block and character devices. @@ -171,6 +171,10 @@ Use of the functions above is more portable than use of the first set of flags: +.. data:: S_IFMT + + Bit mask for the file type bit fields. + .. data:: S_IFSOCK Socket. diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/library/statvfs.rst --- a/Doc/library/statvfs.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/library/statvfs.rst Sun Jul 20 10:52:46 2014 -0400 @@ -6,7 +6,7 @@ :deprecated: .. deprecated:: 2.6 - The :mod:`statvfs` module has been removed in Python 3. + The :mod:`statvfs` module has been deprecated for removal in Python 3.0. .. sectionauthor:: Moshe Zadka @@ -61,7 +61,7 @@ .. data:: F_FLAG - Flags. System dependent: see :c:func:`statvfs` man page. + Flags. System dependent: see :cfunc:`statvfs` man page. .. data:: F_NAMEMAX diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/library/stdtypes.rst --- a/Doc/library/stdtypes.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/library/stdtypes.rst Sun Jul 20 10:52:46 2014 -0400 @@ -26,7 +26,7 @@ Some operations are supported by several object types; in particular, practically all objects can be compared, tested for truth value, and converted -to a string (with the :ref:`repr() ` function or the slightly different +to a string (with the :func:`repr` function or the slightly different :func:`str` function). The latter function is implicitly used when an object is written by the :func:`print` function. @@ -189,22 +189,11 @@ and ``>=`` operators will raise a :exc:`TypeError` exception when any operand is a complex number. -.. index:: - single: __cmp__() (instance method) - single: __eq__() (instance method) - single: __ne__() (instance method) - single: __lt__() (instance method) - single: __le__() (instance method) - single: __gt__() (instance method) - single: __ge__() (instance method) - -Non-identical instances of a class normally compare as non-equal unless the -class defines the :meth:`__eq__` method or the :meth:`__cmp__` method. - -Instances of a class cannot be ordered with respect to other instances of the -same class, or other types of object, unless the class defines either enough of -the rich comparison methods (:meth:`__lt__`, :meth:`__le__`, :meth:`__gt__`, and -:meth:`__ge__`) or the :meth:`__cmp__` method. +.. index:: single: __cmp__() (instance method) + +Instances of a class normally compare as non-equal unless the class defines the +:meth:`__cmp__` method. Refer to :ref:`customization`) for information on the +use of this method to effect object comparisons. .. impl-detail:: @@ -237,11 +226,11 @@ There are four distinct numeric types: :dfn:`plain integers`, :dfn:`long integers`, :dfn:`floating point numbers`, and :dfn:`complex numbers`. In addition, Booleans are a subtype of plain integers. Plain integers (also just -called :dfn:`integers`) are implemented using :c:type:`long` in C, which gives +called :dfn:`integers`) are implemented using :ctype:`long` in C, which gives them at least 32 bits of precision (``sys.maxint`` is always set to the maximum plain integer value for the current platform, the minimum value is ``-sys.maxint - 1``). Long integers have unlimited precision. Floating point -numbers are usually implemented using :c:type:`double` in C; information about +numbers are usually implemented using :ctype:`double` in C; information about the precision and internal representation of floating point numbers for the machine on which your program is running is available in :data:`sys.float_info`. Complex numbers have a real and imaginary part, which @@ -399,8 +388,8 @@ | ``math.trunc(x)`` | *x* truncated to Integral | | +--------------------+------------------------------------+--------+ | ``round(x[, n])`` | *x* rounded to n digits, | | -| | rounding ties away from zero. If n | | -| | is omitted, it defaults to 0. | | +| | rounding half to even. If n is | | +| | omitted, it defaults to 0. | | +--------------------+------------------------------------+--------+ | ``math.floor(x)`` | the greatest integral float <= *x* | | +--------------------+------------------------------------+--------+ @@ -412,12 +401,12 @@ .. _bitstring-ops: -Bitwise Operations on Integer Types +Bit-string Operations on Integer Types -------------------------------------- .. index:: triple: operations on; integer; types - pair: bitwise; operations + pair: bit-string; operations pair: shifting; operations pair: masking; operations operator: ^ @@ -425,16 +414,16 @@ operator: << operator: >> -Bitwise operations only make sense for integers. Negative numbers are treated -as their 2's complement value (this assumes a sufficiently large number of bits -that no overflow occurs during the operation). +Plain and long integer types support additional operations that make sense only +for bit-strings. Negative numbers are treated as their 2's complement value +(for long integers, this assumes a sufficiently large number of bits that no +overflow occurs during the operation). The priorities of the binary bitwise operations are all lower than the numeric operations and higher than the comparisons; the unary operation ``~`` has the same priority as the other unary numeric operations (``+`` and ``-``). -This table lists the bitwise operations sorted in ascending priority -(operations in the same box have the same priority): +This table lists the bit-string operations sorted in ascending priority: +------------+--------------------------------+----------+ | Operation | Result | Notes | @@ -625,7 +614,7 @@ iterators for those iteration types. (An example of an object supporting multiple forms of iteration would be a tree structure which supports both breadth-first and depth-first traversal.) This method corresponds to the - :c:member:`~PyTypeObject.tp_iter` slot of the type structure for Python objects in the Python/C + :attr:`tp_iter` slot of the type structure for Python objects in the Python/C API. The iterator objects themselves are required to support the following two @@ -636,7 +625,7 @@ Return the iterator object itself. This is required to allow both containers and iterators to be used with the :keyword:`for` and :keyword:`in` statements. - This method corresponds to the :c:member:`~PyTypeObject.tp_iter` slot of the type structure for + This method corresponds to the :attr:`tp_iter` slot of the type structure for Python objects in the Python/C API. @@ -644,7 +633,7 @@ Return the next item from the container. If there are no further items, raise the :exc:`StopIteration` exception. This method corresponds to the - :c:member:`~PyTypeObject.tp_iternext` slot of the type structure for Python objects in the + :attr:`tp_iternext` slot of the type structure for Python objects in the Python/C API. Python defines several iterator objects to support iteration over general and @@ -741,7 +730,7 @@ | ``s * n, n * s`` | *n* shallow copies of *s* | \(2) | | | concatenated | | +------------------+--------------------------------+----------+ -| ``s[i]`` | *i*\ th item of *s*, origin 0 | \(3) | +| ``s[i]`` | *i*'th item of *s*, origin 0 | \(3) | +------------------+--------------------------------+----------+ | ``s[i:j]`` | slice of *s* from *i* to *j* | (3)(4) | +------------------+--------------------------------+----------+ @@ -754,11 +743,11 @@ +------------------+--------------------------------+----------+ | ``max(s)`` | largest item of *s* | | +------------------+--------------------------------+----------+ -| ``s.index(x)`` | index of the first occurrence | | -| | of *x* in *s* | | +| ``s.index(i)`` | index of the first occurence | | +| | of *i* in *s* | | +------------------+--------------------------------+----------+ -| ``s.count(x)`` | total number of occurrences of | | -| | *x* in *s* | | +| ``s.count(i)`` | total number of occurences of | | +| | *i* in *s* | | +------------------+--------------------------------+----------+ Sequence types also support comparisons. In particular, tuples and lists @@ -942,22 +931,10 @@ .. method:: str.expandtabs([tabsize]) Return a copy of the string where all tab characters are replaced by one or - more spaces, depending on the current column and the given tab size. Tab - positions occur every *tabsize* characters (default is 8, giving tab - positions at columns 0, 8, 16 and so on). To expand the string, the current - column is set to zero and the string is examined character by character. If - the character is a tab (``\t``), one or more space characters are inserted - in the result until the current column is equal to the next tab position. - (The tab character itself is not copied.) If the character is a newline - (``\n``) or return (``\r``), it is copied and the current column is reset to - zero. Any other character is copied unchanged and the current column is - incremented by one regardless of how the character is represented when - printed. - - >>> '01\t012\t0123\t01234'.expandtabs() - '01 012 0123 01234' - >>> '01\t012\t0123\t01234'.expandtabs(4) - '01 012 0123 01234' + more spaces, depending on the current column and the given tab size. The + column number is reset to zero after each newline occurring in the string. + If *tabsize* is not given, a tab size of ``8`` characters is assumed. This + doesn't understand other non-printing characters or escape sequences. .. method:: str.find(sub[, start[, end]]) @@ -992,7 +969,7 @@ See :ref:`formatstrings` for a description of the various formatting options that can be specified in format strings. - This method of string formatting is the new standard in Python 3, and + This method of string formatting is the new standard in Python 3.0, and should be preferred to the ``%`` formatting described in :ref:`string-formatting` in new code. @@ -1072,7 +1049,7 @@ Return the string left justified in a string of length *width*. Padding is done using the specified *fillchar* (default is a space). The original string is - returned if *width* is less than or equal to ``len(s)``. + returned if *width* is less than ``len(s)``. .. versionchanged:: 2.4 Support for the *fillchar* argument. @@ -1136,7 +1113,7 @@ Return the string right justified in a string of length *width*. Padding is done using the specified *fillchar* (default is a space). The original string is - returned if *width* is less than or equal to ``len(s)``. + returned if *width* is less than ``len(s)``. .. versionchanged:: 2.4 Support for the *fillchar* argument. @@ -1184,8 +1161,8 @@ Return a list of the words in the string, using *sep* as the delimiter string. If *maxsplit* is given, at most *maxsplit* splits are done (thus, the list will have at most ``maxsplit+1`` elements). If *maxsplit* is not - specified or ``-1``, then there is no limit on the number of splits - (all possible splits are made). + specified, then there is no limit on the number of splits (all possible + splits are made). If *sep* is given, consecutive delimiters are not grouped together and are deemed to delimit empty strings (for example, ``'1,,2'.split(',')`` returns @@ -1204,23 +1181,11 @@ ``' 1 2 3 '.split(None, 1)`` returns ``['1', '2 3 ']``. -.. index:: - single: universal newlines; str.splitlines method - .. method:: str.splitlines([keepends]) - Return a list of the lines in the string, breaking at line boundaries. - This method uses the :term:`universal newlines` approach to splitting lines. - Line breaks are not included in the resulting list unless *keepends* is - given and true. - - For example, ``'ab c\n\nde fg\rkl\r\n'.splitlines()`` returns - ``['ab c', '', 'de fg', 'kl']``, while the same call with ``splitlines(True)`` - returns ``['ab c\n', '\n', 'de fg\r', 'kl\r\n']``. - - Unlike :meth:`~str.split` when a delimiter string *sep* is given, this - method returns an empty list for the empty string, and a terminal line - break does not result in an extra line. + Return a list of the lines in the string, breaking at line boundaries. Line + breaks are not included in the resulting list unless *keepends* is given and + true. .. method:: str.startswith(prefix[, start[, end]]) @@ -1276,11 +1241,11 @@ >>> import re >>> def titlecase(s): - ... return re.sub(r"[A-Za-z]+('[A-Za-z]+)?", - ... lambda mo: mo.group(0)[0].upper() + - ... mo.group(0)[1:].lower(), - ... s) - ... + return re.sub(r"[A-Za-z]+('[A-Za-z]+)?", + lambda mo: mo.group(0)[0].upper() + + mo.group(0)[1:].lower(), + s) + >>> titlecase("they're bill's friends.") "They're Bill's Friends." @@ -1328,7 +1293,7 @@ Return the numeric string left filled with zeros in a string of length *width*. A sign prefix is handled correctly. The original string is - returned if *width* is less than or equal to ``len(s)``. + returned if *width* is less than ``len(s)``. .. versionadded:: 2.2.2 @@ -1370,7 +1335,7 @@ *interpolation* operator. Given ``format % values`` (where *format* is a string or Unicode object), ``%`` conversion specifications in *format* are replaced with zero or more elements of *values*. The effect is similar to the using -:c:func:`sprintf` in the C language. If *format* is a Unicode object, or if any +:cfunc:`sprintf` in the C language. If *format* is a Unicode object, or if any of the objects being converted using the ``%s`` conversion are Unicode objects, the result will also be a Unicode object. @@ -1475,7 +1440,7 @@ | | character string). | | +------------+-----------------------------------------------------+-------+ | ``'r'`` | String (converts any Python object using | \(5) | -| | :ref:`repr() `). | | +| | :func:`repr`). | | +------------+-----------------------------------------------------+-------+ | ``'s'`` | String (converts any Python object using | \(6) | | | :func:`str`). | | @@ -1668,8 +1633,9 @@ Previously, all negative indices were truncated to zero. (6) - The :meth:`pop` method's optional argument *i* defaults to ``-1``, so that - by default the last item is removed and returned. + The :meth:`pop` method is only supported by the list and array types. The + optional argument *i* defaults to ``-1``, so that by default the last item is + removed and returned. (7) The :meth:`sort` and :meth:`reverse` methods modify the list in place for @@ -1744,11 +1710,11 @@ There are currently two built-in set types, :class:`set` and :class:`frozenset`. The :class:`set` type is mutable --- the contents can be changed using methods -like :meth:`~set.add` and :meth:`~set.remove`. Since it is mutable, it has no -hash value and cannot be used as either a dictionary key or as an element of -another set. The :class:`frozenset` type is immutable and :term:`hashable` --- -its contents cannot be altered after it is created; it can therefore be used as -a dictionary key or as an element of another set. +like :meth:`add` and :meth:`remove`. Since it is mutable, it has no hash value +and cannot be used as either a dictionary key or as an element of another set. +The :class:`frozenset` type is immutable and :term:`hashable` --- its contents +cannot be altered after it is created; it can therefore be used as a dictionary +key or as an element of another set. As of Python 2.7, non-empty sets (not frozensets) can be created by placing a comma-separated list of elements within braces, for example: ``{'jack', @@ -1760,10 +1726,9 @@ frozenset([iterable]) Return a new set or frozenset object whose elements are taken from - *iterable*. The elements of a set must be :term:`hashable`. To - represent sets of sets, the inner sets must be :class:`frozenset` - objects. If *iterable* is not specified, a new empty set is - returned. + *iterable*. The elements of a set must be hashable. To represent sets of + sets, the inner sets must be :class:`frozenset` objects. If *iterable* is + not specified, a new empty set is returned. Instances of :class:`set` and :class:`frozenset` provide the following operations: @@ -1782,7 +1747,7 @@ .. method:: isdisjoint(other) - Return ``True`` if the set has no elements in common with *other*. Sets are + Return True if the set has no elements in common with *other*. Sets are disjoint if and only if their intersection is the empty set. .. versionadded:: 2.6 @@ -1794,7 +1759,7 @@ .. method:: set < other - Test whether the set is a proper subset of *other*, that is, + Test whether the set is a true subset of *other*, that is, ``set <= other and set != other``. .. method:: issuperset(other) @@ -1804,7 +1769,7 @@ .. method:: set > other - Test whether the set is a proper superset of *other*, that is, ``set >= + Test whether the set is a true superset of *other*, that is, ``set >= other and set != other``. .. method:: union(other, ...) @@ -1859,8 +1824,8 @@ based on their members. For example, ``set('abc') == frozenset('abc')`` returns ``True`` and so does ``set('abc') in set([frozenset('abc')])``. - The subset and equality comparisons do not generalize to a total ordering - function. For example, any two non-empty disjoint sets are not equal and are not + The subset and equality comparisons do not generalize to a complete ordering + function. For example, any two disjoint sets are not equal and are not subsets of each other, so *all* of the following return ``False``: ``ab``. Accordingly, sets do not implement the :meth:`__cmp__` method. @@ -1960,7 +1925,7 @@ statement: del builtin: len -A :term:`mapping` object maps :term:`hashable` values to arbitrary objects. +A :dfn:`mapping` object maps :term:`hashable` values to arbitrary objects. Mappings are mutable objects. There is currently only one standard mapping type, the :dfn:`dictionary`. (For other containers see the built in :class:`list`, :class:`set`, and :class:`tuple` classes, and the @@ -1979,41 +1944,32 @@ pairs within braces, for example: ``{'jack': 4098, 'sjoerd': 4127}`` or ``{4098: 'jack', 4127: 'sjoerd'}``, or by the :class:`dict` constructor. -.. class:: dict(**kwarg) - dict(mapping, **kwarg) - dict(iterable, **kwarg) - - Return a new dictionary initialized from an optional positional argument - and a possibly empty set of keyword arguments. - - If no positional argument is given, an empty dictionary is created. - If a positional argument is given and it is a mapping object, a dictionary - is created with the same key-value pairs as the mapping object. Otherwise, - the positional argument must be an :term:`iterable` object. Each item in - the iterable must itself be an iterable with exactly two objects. The - first object of each item becomes a key in the new dictionary, and the - second object the corresponding value. If a key occurs more than once, the - last value for that key becomes the corresponding value in the new - dictionary. - - If keyword arguments are given, the keyword arguments and their values are - added to the dictionary created from the positional argument. If a key - being added is already present, the value from the keyword argument - replaces the value from the positional argument. - - To illustrate, the following examples all return a dictionary equal to - ``{"one": 1, "two": 2, "three": 3}``:: - - >>> a = dict(one=1, two=2, three=3) - >>> b = {'one': 1, 'two': 2, 'three': 3} - >>> c = dict(zip(['one', 'two', 'three'], [1, 2, 3])) - >>> d = dict([('two', 2), ('one', 1), ('three', 3)]) - >>> e = dict({'three': 3, 'one': 1, 'two': 2}) - >>> a == b == c == d == e - True - - Providing keyword arguments as in the first example only works for keys that - are valid Python identifiers. Otherwise, any valid keys can be used. +.. class:: dict([arg]) + + Return a new dictionary initialized from an optional positional argument or from + a set of keyword arguments. If no arguments are given, return a new empty + dictionary. If the positional argument *arg* is a mapping object, return a + dictionary mapping the same keys to the same values as does the mapping object. + Otherwise the positional argument must be a sequence, a container that supports + iteration, or an iterator object. The elements of the argument must each also + be of one of those kinds, and each must in turn contain exactly two objects. + The first is used as a key in the new dictionary, and the second as the key's + value. If a given key is seen more than once, the last value associated with it + is retained in the new dictionary. + + If keyword arguments are given, the keywords themselves with their associated + values are added as items to the dictionary. If a key is specified both in the + positional argument and as a keyword argument, the value associated with the + keyword is retained in the dictionary. For example, these all return a + dictionary equal to ``{"one": 1, "two": 2}``: + + * ``dict(one=1, two=2)`` + * ``dict({'one': 1, 'two': 2})`` + * ``dict(zip(('one', 'two'), (1, 2)))`` + * ``dict([['two', 2], ['one', 1]])`` + + The first example only works for keys that are valid Python + identifiers; the others work with any valid keys. .. versionadded:: 2.2 @@ -2353,7 +2309,7 @@ with open("hello.txt") as f: for line in f: - print line, + print line In older versions of Python, you would have needed to do this to get the same effect:: @@ -2361,7 +2317,7 @@ f = open("hello.txt") try: for line in f: - print line, + print line finally: f.close() @@ -2375,7 +2331,7 @@ .. method:: file.flush() - Flush the internal buffer, like ``stdio``'s :c:func:`fflush`. This may be a + Flush the internal buffer, like ``stdio``'s :cfunc:`fflush`. This may be a no-op on some file-like objects. .. note:: @@ -2415,14 +2371,14 @@ A file object is its own iterator, for example ``iter(f)`` returns *f* (unless *f* is closed). When a file is used as an iterator, typically in a - :keyword:`for` loop (for example, ``for line in f: print line.strip()``), the - :meth:`~file.next` method is called repeatedly. This method returns the next input + :keyword:`for` loop (for example, ``for line in f: print line``), the + :meth:`.next` method is called repeatedly. This method returns the next input line, or raises :exc:`StopIteration` when EOF is hit when the file is open for reading (behavior is undefined when the file is open for writing). In order to make a :keyword:`for` loop the most efficient way of looping over the lines of a - file (a very common operation), the :meth:`~file.next` method uses a hidden read-ahead - buffer. As a consequence of using a read-ahead buffer, combining :meth:`~file.next` - with other file methods (like :meth:`~file.readline`) does not work right. However, + file (a very common operation), the :meth:`next` method uses a hidden read-ahead + buffer. As a consequence of using a read-ahead buffer, combining :meth:`.next` + with other file methods (like :meth:`readline`) does not work right. However, using :meth:`seek` to reposition the file to an absolute position will flush the read-ahead buffer. @@ -2436,14 +2392,14 @@ all data until EOF is reached. The bytes are returned as a string object. An empty string is returned when EOF is encountered immediately. (For certain files, like ttys, it makes sense to continue reading after an EOF is hit.) Note - that this method may call the underlying C function :c:func:`fread` more than + that this method may call the underlying C function :cfunc:`fread` more than once in an effort to acquire as close to *size* bytes as possible. Also note that when in non-blocking mode, less data than was requested may be returned, even if no *size* parameter was given. .. note:: This function is simply a wrapper for the underlying - :c:func:`fread` C function, and will behave the same in corner cases, + :cfunc:`fread` C function, and will behave the same in corner cases, such as whether the EOF value is cached. @@ -2458,13 +2414,13 @@ .. note:: - Unlike ``stdio``'s :c:func:`fgets`, the returned string contains null characters + Unlike ``stdio``'s :cfunc:`fgets`, the returned string contains null characters (``'\0'``) if they occurred in the input. .. method:: file.readlines([sizehint]) - Read until EOF using :meth:`~file.readline` and return a list containing the lines + Read until EOF using :meth:`readline` and return a list containing the lines thus read. If the optional *sizehint* argument is present, instead of reading up to EOF, whole lines totalling approximately *sizehint* bytes (possibly after rounding up to an internal buffer size) are read. Objects @@ -2484,7 +2440,7 @@ .. method:: file.seek(offset[, whence]) - Set the file's current position, like ``stdio``'s :c:func:`fseek`. The *whence* + Set the file's current position, like ``stdio``'s :cfunc:`fseek`. The *whence* argument is optional and defaults to ``os.SEEK_SET`` or ``0`` (absolute file positioning); other values are ``os.SEEK_CUR`` or ``1`` (seek relative to the current position) and ``os.SEEK_END`` or ``2`` (seek relative to the file's @@ -2509,11 +2465,11 @@ .. method:: file.tell() - Return the file's current position, like ``stdio``'s :c:func:`ftell`. + Return the file's current position, like ``stdio``'s :cfunc:`ftell`. .. note:: - On Windows, :meth:`tell` can return illegal values (after an :c:func:`fgets`) + On Windows, :meth:`tell` can return illegal values (after an :cfunc:`fgets`) when reading files with Unix-style line-endings. Use binary mode (``'rb'``) to circumvent this problem. @@ -2544,7 +2500,7 @@ add line separators.) Files support the iterator protocol. Each iteration returns the same result as -:meth:`~file.readline`, and iteration ends when the :meth:`~file.readline` method returns +``file.readline()``, and iteration ends when the :meth:`readline` method returns an empty string. File objects also offer a number of other interesting attributes. These are not @@ -2593,19 +2549,16 @@ form ``<...>``. This is a read-only attribute and may not be present on all file-like objects. - .. index:: - single: universal newlines; file.newlines attribute - .. attribute:: file.newlines - If Python was built with :term:`universal newlines` enabled (the default) this + If Python was built with universal newlines enabled (the default) this read-only attribute exists, and for files opened in universal newline read mode it keeps track of the types of newlines encountered while reading the file. The values it can take are ``'\r'``, ``'\n'``, ``'\r\n'``, ``None`` (unknown, no newlines read yet) or a tuple containing all the newline types seen, to indicate that multiple newline conventions were encountered. For - files not opened in universal newlines read mode the value of this attribute + files not opened in universal newline read mode the value of this attribute will be ``None``. @@ -2838,12 +2791,12 @@ foo`` does not require a module object named *foo* to exist, rather it requires an (external) *definition* for a module named *foo* somewhere.) -A special attribute of every module is :attr:`~object.__dict__`. This is the -dictionary containing the module's symbol table. Modifying this dictionary will -actually change the module's symbol table, but direct assignment to the -:attr:`__dict__` attribute is not possible (you can write -``m.__dict__['a'] = 1``, which defines ``m.a`` to be ``1``, but you can't write -``m.__dict__ = {}``). Modifying :attr:`__dict__` directly is not recommended. +A special attribute of every module is :attr:`__dict__`. This is the dictionary +containing the module's symbol table. Modifying this dictionary will actually +change the module's symbol table, but direct assignment to the :attr:`__dict__` +attribute is not possible (you can write ``m.__dict__['a'] = 1``, which defines +``m.a`` to be ``1``, but you can't write ``m.__dict__ = {}``). Modifying +:attr:`__dict__` directly is not recommended. Modules built into the interpreter are written like this: ````. If loaded from a file, they are written as ``>> class C: - ... def method(self): - ... pass - ... - >>> c = C() - >>> c.method.whoami = 'my name is method' # can't set on the method - Traceback (most recent call last): - File "", line 1, in - AttributeError: 'instancemethod' object has no attribute 'whoami' - >>> c.method.im_func.whoami = 'my name is method' - >>> c.method.whoami - 'my name is method' - +methods is disallowed. Attempting to set a method attribute results in a +:exc:`TypeError` being raised. In order to set a method attribute, you need to +explicitly set it on the underlying function object:: + + class C: + def method(self): + pass + + c = C() + c.method.im_func.whoami = 'my name is c' See :ref:`types` for more information. @@ -3087,7 +3033,7 @@ This method can be overridden by a metaclass to customize the method resolution order for its instances. It is called at class instantiation, and - its result is stored in :attr:`~class.__mro__`. + its result is stored in :attr:`__mro__`. .. method:: class.__subclasses__ diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/library/string.rst --- a/Doc/library/string.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/library/string.rst Sun Jul 20 10:52:46 2014 -0400 @@ -123,8 +123,8 @@ .. method:: format(format_string, *args, **kwargs) - :meth:`format` is the primary API method. It takes a format string and - an arbitrary set of positional and keyword arguments. + :meth:`format` is the primary API method. It takes a format template + string, and an arbitrary set of positional and keyword argument. :meth:`format` is just a wrapper that calls :meth:`vformat`. .. method:: vformat(format_string, args, kwargs) @@ -132,9 +132,9 @@ This function does the actual work of formatting. It is exposed as a separate function for cases where you want to pass in a predefined dictionary of arguments, rather than unpacking and repacking the - dictionary as individual arguments using the ``*args`` and ``**kwargs`` - syntax. :meth:`vformat` does the work of breaking up the format string - into character data and replacement fields. It calls the various + dictionary as individual arguments using the ``*args`` and ``**kwds`` + syntax. :meth:`vformat` does the work of breaking up the format template + string into character data and replacement fields. It calls the various methods described below. In addition, the :class:`Formatter` defines a number of methods that are @@ -205,8 +205,7 @@ Converts the value (returned by :meth:`get_field`) given a conversion type (as in the tuple returned by the :meth:`parse` method). The default - version understands 's' (str), 'r' (repr) and 'a' (ascii) conversion - types. + version understands 'r' (repr) and 's' (str) conversion types. .. _formatstrings: @@ -323,18 +322,18 @@ .. productionlist:: sf format_spec: [[`fill`]`align`][`sign`][#][0][`width`][,][.`precision`][`type`] - fill: + fill: align: "<" | ">" | "=" | "^" sign: "+" | "-" | " " width: `integer` precision: `integer` type: "b" | "c" | "d" | "e" | "E" | "f" | "F" | "g" | "G" | "n" | "o" | "s" | "x" | "X" | "%" -If a valid *align* value is specified, it can be preceded by a *fill* -character that can be any character and defaults to a space if omitted. -Note that it is not possible to use ``{`` and ``}`` as *fill* char while -using the :meth:`str.format` method; this limitation however doesn't -affect the :func:`format` function. +The *fill* character can be any character other than '{' or '}'. The presence +of a fill character is signaled by the character following it, which must be +one of the alignment options. If the second character of *format_spec* is not +a valid alignment option, then it is assumed that both the fill character and +the alignment option are absent. The meaning of the various alignment options is as follows: @@ -390,9 +389,9 @@ *width* is a decimal integer defining the minimum field width. If not specified, then the field width will be determined by the content. -Preceding the *width* field by a zero (``'0'``) character enables -sign-aware zero-padding for numeric types. This is equivalent to a *fill* -character of ``'0'`` with an *alignment* type of ``'='``. +If the *width* field is preceded by a zero (``'0'``) character, this enables +zero-padding. This is equivalent to an *alignment* type of ``'='`` and a *fill* +character of ``'0'``. The *precision* is a decimal number indicating how many digits should be displayed after the decimal point for a floating point value formatted with @@ -453,13 +452,12 @@ +=========+==========================================================+ | ``'e'`` | Exponent notation. Prints the number in scientific | | | notation using the letter 'e' to indicate the exponent. | - | | The default precision is ``6``. | +---------+----------------------------------------------------------+ | ``'E'`` | Exponent notation. Same as ``'e'`` except it uses an | | | upper case 'E' as the separator character. | +---------+----------------------------------------------------------+ | ``'f'`` | Fixed point. Displays the number as a fixed-point | - | | number. The default precision is ``6``. | + | | number. | +---------+----------------------------------------------------------+ | ``'F'`` | Fixed point. Same as ``'f'``. | +---------+----------------------------------------------------------+ @@ -485,7 +483,7 @@ | | the precision. | | | | | | A precision of ``0`` is treated as equivalent to a | - | | precision of ``1``. The default precision is ``6``. | + | | precision of ``1``. | +---------+----------------------------------------------------------+ | ``'G'`` | General format. Same as ``'g'`` except switches to | | | ``'E'`` if the number gets too large. The | @@ -604,7 +602,7 @@ >>> points = 19.5 >>> total = 22 - >>> 'Correct answers: {:.2%}'.format(points/total) + >>> 'Correct answers: {:.2%}.'.format(points/total) 'Correct answers: 88.64%' Using type-specific formatting:: @@ -708,7 +706,7 @@ This is the object passed to the constructor's *template* argument. In general, you shouldn't change it, but read-only access is not enforced. -Here is an example of how to use a Template:: +Here is an example of how to use a Template: >>> from string import Template >>> s = Template('$who likes $what') @@ -717,11 +715,11 @@ >>> d = dict(who='tim') >>> Template('Give $who $100').substitute(d) Traceback (most recent call last): - ... - ValueError: Invalid placeholder in string: line 1, col 11 + [...] + ValueError: Invalid placeholder in string: line 1, col 10 >>> Template('$who likes $what').substitute(d) Traceback (most recent call last): - ... + [...] KeyError: 'what' >>> Template('$who likes $what').safe_substitute(d) 'tim likes $what' @@ -795,7 +793,7 @@ The following list of functions are also defined as methods of string and Unicode objects; see section :ref:`string-methods` for more information on those. You should consider these functions as deprecated, although they will -not be removed until Python 3. The functions defined in this module are: +not be removed until Python 3.0. The functions defined in this module are: .. function:: atof(s) @@ -907,15 +905,14 @@ Return a list of the words of the string *s*. If the optional second argument *sep* is absent or ``None``, the words are separated by arbitrary strings of - whitespace characters (space, tab, newline, return, formfeed). If the second + whitespace characters (space, tab, newline, return, formfeed). If the second argument *sep* is present and not ``None``, it specifies a string to be used as the word separator. The returned list will then have one more item than the - number of non-overlapping occurrences of the separator in the string. - If *maxsplit* is given, at most *maxsplit* number of splits occur, and the - remainder of the string is returned as the final element of the list (thus, - the list will have at most ``maxsplit+1`` elements). If *maxsplit* is not - specified or ``-1``, then there is no limit on the number of splits (all - possible splits are made). + number of non-overlapping occurrences of the separator in the string. The + optional third argument *maxsplit* defaults to 0. If it is nonzero, at most + *maxsplit* number of splits occur, and the remainder of the string is returned + as the final element of the list (thus, the list will have at most + ``maxsplit+1`` elements). The behavior of split on an empty string depends on the value of *sep*. If *sep* is not specified, or specified as ``None``, the result will be an empty list. @@ -928,7 +925,7 @@ Return a list of the words of the string *s*, scanning *s* from the end. To all intents and purposes, the resulting list of words is the same as returned by :func:`split`, except when the optional third argument *maxsplit* is explicitly - specified and nonzero. If *maxsplit* is given, at most *maxsplit* number of + specified and nonzero. When *maxsplit* is nonzero, at most *maxsplit* number of splits -- the *rightmost* ones -- occur, and the remainder of the string is returned as the first element of the list (thus, the list will have at most ``maxsplit+1`` elements). @@ -1026,14 +1023,13 @@ .. function:: zfill(s, width) - Pad a numeric string *s* on the left with zero digits until the - given *width* is reached. Strings starting with a sign are handled - correctly. + Pad a numeric string on the left with zero digits until the given width is + reached. Strings starting with a sign are handled correctly. -.. function:: replace(s, old, new[, maxreplace]) +.. function:: replace(str, old, new[, maxreplace]) - Return a copy of string *s* with all occurrences of substring *old* replaced + Return a copy of string *str* with all occurrences of substring *old* replaced by *new*. If the optional argument *maxreplace* is given, the first *maxreplace* occurrences are replaced. diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/library/stringprep.rst --- a/Doc/library/stringprep.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/library/stringprep.rst Sun Jul 20 10:52:46 2014 -0400 @@ -4,6 +4,7 @@ .. module:: stringprep :synopsis: String preparation, as per RFC 3453 + :deprecated: .. moduleauthor:: Martin v. Löwis .. sectionauthor:: Martin v. Löwis diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/library/struct.rst --- a/Doc/library/struct.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/library/struct.rst Sun Jul 20 10:52:46 2014 -0400 @@ -162,60 +162,60 @@ ``'='``. When using native size, the size of the packed value is platform-dependent. -+--------+--------------------------+--------------------+----------------+------------+ -| Format | C Type | Python type | Standard size | Notes | -+========+==========================+====================+================+============+ -| ``x`` | pad byte | no value | | | -+--------+--------------------------+--------------------+----------------+------------+ -| ``c`` | :c:type:`char` | string of length 1 | 1 | | -+--------+--------------------------+--------------------+----------------+------------+ -| ``b`` | :c:type:`signed char` | integer | 1 | \(3) | -+--------+--------------------------+--------------------+----------------+------------+ -| ``B`` | :c:type:`unsigned char` | integer | 1 | \(3) | -+--------+--------------------------+--------------------+----------------+------------+ -| ``?`` | :c:type:`_Bool` | bool | 1 | \(1) | -+--------+--------------------------+--------------------+----------------+------------+ -| ``h`` | :c:type:`short` | integer | 2 | \(3) | -+--------+--------------------------+--------------------+----------------+------------+ -| ``H`` | :c:type:`unsigned short` | integer | 2 | \(3) | -+--------+--------------------------+--------------------+----------------+------------+ -| ``i`` | :c:type:`int` | integer | 4 | \(3) | -+--------+--------------------------+--------------------+----------------+------------+ -| ``I`` | :c:type:`unsigned int` | integer | 4 | \(3) | -+--------+--------------------------+--------------------+----------------+------------+ -| ``l`` | :c:type:`long` | integer | 4 | \(3) | -+--------+--------------------------+--------------------+----------------+------------+ -| ``L`` | :c:type:`unsigned long` | integer | 4 | \(3) | -+--------+--------------------------+--------------------+----------------+------------+ -| ``q`` | :c:type:`long long` | integer | 8 | \(2), \(3) | -+--------+--------------------------+--------------------+----------------+------------+ -| ``Q`` | :c:type:`unsigned long | integer | 8 | \(2), \(3) | -| | long` | | | | -+--------+--------------------------+--------------------+----------------+------------+ -| ``f`` | :c:type:`float` | float | 4 | \(4) | -+--------+--------------------------+--------------------+----------------+------------+ -| ``d`` | :c:type:`double` | float | 8 | \(4) | -+--------+--------------------------+--------------------+----------------+------------+ -| ``s`` | :c:type:`char[]` | string | | | -+--------+--------------------------+--------------------+----------------+------------+ -| ``p`` | :c:type:`char[]` | string | | | -+--------+--------------------------+--------------------+----------------+------------+ -| ``P`` | :c:type:`void \*` | integer | | \(5), \(3) | -+--------+--------------------------+--------------------+----------------+------------+ ++--------+-------------------------+--------------------+----------------+------------+ +| Format | C Type | Python type | Standard size | Notes | ++========+=========================+====================+================+============+ +| ``x`` | pad byte | no value | | | ++--------+-------------------------+--------------------+----------------+------------+ +| ``c`` | :ctype:`char` | string of length 1 | 1 | | ++--------+-------------------------+--------------------+----------------+------------+ +| ``b`` | :ctype:`signed char` | integer | 1 | \(3) | ++--------+-------------------------+--------------------+----------------+------------+ +| ``B`` | :ctype:`unsigned char` | integer | 1 | \(3) | ++--------+-------------------------+--------------------+----------------+------------+ +| ``?`` | :ctype:`_Bool` | bool | 1 | \(1) | ++--------+-------------------------+--------------------+----------------+------------+ +| ``h`` | :ctype:`short` | integer | 2 | \(3) | ++--------+-------------------------+--------------------+----------------+------------+ +| ``H`` | :ctype:`unsigned short` | integer | 2 | \(3) | ++--------+-------------------------+--------------------+----------------+------------+ +| ``i`` | :ctype:`int` | integer | 4 | \(3) | ++--------+-------------------------+--------------------+----------------+------------+ +| ``I`` | :ctype:`unsigned int` | integer | 4 | \(3) | ++--------+-------------------------+--------------------+----------------+------------+ +| ``l`` | :ctype:`long` | integer | 4 | \(3) | ++--------+-------------------------+--------------------+----------------+------------+ +| ``L`` | :ctype:`unsigned long` | integer | 4 | \(3) | ++--------+-------------------------+--------------------+----------------+------------+ +| ``q`` | :ctype:`long long` | integer | 8 | \(2), \(3) | ++--------+-------------------------+--------------------+----------------+------------+ +| ``Q`` | :ctype:`unsigned long | integer | 8 | \(2), \(3) | +| | long` | | | | ++--------+-------------------------+--------------------+----------------+------------+ +| ``f`` | :ctype:`float` | float | 4 | \(4) | ++--------+-------------------------+--------------------+----------------+------------+ +| ``d`` | :ctype:`double` | float | 8 | \(4) | ++--------+-------------------------+--------------------+----------------+------------+ +| ``s`` | :ctype:`char[]` | string | | | ++--------+-------------------------+--------------------+----------------+------------+ +| ``p`` | :ctype:`char[]` | string | | | ++--------+-------------------------+--------------------+----------------+------------+ +| ``P`` | :ctype:`void \*` | integer | | \(5), \(3) | ++--------+-------------------------+--------------------+----------------+------------+ Notes: (1) - The ``'?'`` conversion code corresponds to the :c:type:`_Bool` type defined by - C99. If this type is not available, it is simulated using a :c:type:`char`. In + The ``'?'`` conversion code corresponds to the :ctype:`_Bool` type defined by + C99. If this type is not available, it is simulated using a :ctype:`char`. In standard mode, it is always represented by one byte. .. versionadded:: 2.6 (2) The ``'q'`` and ``'Q'`` conversion codes are available in native mode only if - the platform C compiler supports C :c:type:`long long`, or, on Windows, - :c:type:`__int64`. They are always available in standard modes. + the platform C compiler supports C :ctype:`long long`, or, on Windows, + :ctype:`__int64`. They are always available in standard modes. .. versionadded:: 2.2 @@ -284,7 +284,7 @@ For the ``'?'`` format character, the return value is either :const:`True` or :const:`False`. When packing, the truth value of the argument object is used. Either 0 or 1 in the native or standard bool representation will be packed, and -any non-zero value will be ``True`` when unpacking. +any non-zero value will be True when unpacking. @@ -386,7 +386,7 @@ (``len(string)`` must equal :attr:`self.size`). - .. method:: unpack_from(buffer, offset=0) + .. method:: unpack_from(buffer[, offset=0]) Identical to the :func:`unpack_from` function, using the compiled format. (``len(buffer[offset:])`` must be at least :attr:`self.size`). diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/library/subprocess.rst --- a/Doc/library/subprocess.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/library/subprocess.rst Sun Jul 20 10:52:46 2014 -0400 @@ -12,7 +12,7 @@ The :mod:`subprocess` module allows you to spawn new processes, connect to their input/output/error pipes, and obtain their return codes. This module intends to -replace several older modules and functions:: +replace several other, older modules and functions, such as:: os.system os.spawn* @@ -20,26 +20,20 @@ popen2.* commands.* -Information about how this module can be used to replace the older -functions can be found in the subprocess-replacements_ section. +Information about how the :mod:`subprocess` module can be used to replace these +modules and functions can be found in the following sections. .. seealso:: - POSIX users (Linux, BSD, etc.) are strongly encouraged to install - and use the much more recent subprocess32_ module instead of the - version included with python 2.7. It is a drop in replacement with - better behavior in many situations. - :pep:`324` -- PEP proposing the subprocess module -.. _subprocess32: https://pypi.python.org/pypi/subprocess32/ -Using the :mod:`subprocess` Module ----------------------------------- +Using the subprocess Module +--------------------------- -The recommended way to launch subprocesses is to use the following -convenience functions. For more advanced use cases when these do not -meet your needs, use the underlying :class:`Popen` interface. +The recommended approach to invoking subprocesses is to use the following +convenience functions for all use cases they can handle. For more advanced +use cases, the underlying :class:`Popen` interface can be used directly. .. function:: call(args, *, stdin=None, stdout=None, stderr=None, shell=False) @@ -63,15 +57,16 @@ .. warning:: - Using ``shell=True`` can be a security hazard. See the warning - under :ref:`frequently-used-arguments` for details. + Invoking the system shell with ``shell=True`` can be a security hazard + if combined with untrusted input. See the warning under + :ref:`frequently-used-arguments` for details. .. note:: - Do not use ``stdout=PIPE`` or ``stderr=PIPE`` with this function - as that can deadlock based on the child process output volume. - Use :class:`Popen` with the :meth:`communicate` method when you - need pipes. + Do not use ``stdout=PIPE`` or ``stderr=PIPE`` with this function. As + the pipes are not being read in the current process, the child + process may block if it generates enough output to a pipe to fill up + the OS pipe buffer. .. function:: check_call(args, *, stdin=None, stdout=None, stderr=None, shell=False) @@ -79,7 +74,7 @@ Run command with arguments. Wait for command to complete. If the return code was zero then return, otherwise raise :exc:`CalledProcessError`. The :exc:`CalledProcessError` object will have the return code in the - :attr:`~CalledProcessError.returncode` attribute. + :attr:`returncode` attribute. The arguments shown above are merely the most common ones, described below in :ref:`frequently-used-arguments` (hence the slightly odd notation in @@ -101,15 +96,16 @@ .. warning:: - Using ``shell=True`` can be a security hazard. See the warning - under :ref:`frequently-used-arguments` for details. + Invoking the system shell with ``shell=True`` can be a security hazard + if combined with untrusted input. See the warning under + :ref:`frequently-used-arguments` for details. .. note:: - Do not use ``stdout=PIPE`` or ``stderr=PIPE`` with this function - as that can deadlock based on the child process output volume. - Use :class:`Popen` with the :meth:`communicate` method when you - need pipes. + Do not use ``stdout=PIPE`` or ``stderr=PIPE`` with this function. As + the pipes are not being read in the current process, the child + process may block if it generates enough output to a pipe to fill up + the OS pipe buffer. .. function:: check_output(args, *, stdin=None, stderr=None, shell=False, universal_newlines=False) @@ -118,8 +114,8 @@ If the return code was non-zero it raises a :exc:`CalledProcessError`. The :exc:`CalledProcessError` object will have the return code in the - :attr:`~CalledProcessError.returncode` attribute and any output in the - :attr:`~CalledProcessError.output` attribute. + :attr:`returncode` attribute and any output in the :attr:`output` + attribute. The arguments shown above are merely the most common ones, described below in :ref:`frequently-used-arguments` (hence the slightly odd notation in @@ -151,14 +147,15 @@ .. warning:: - Using ``shell=True`` can be a security hazard. See the warning - under :ref:`frequently-used-arguments` for details. + Invoking the system shell with ``shell=True`` can be a security hazard + if combined with untrusted input. See the warning under + :ref:`frequently-used-arguments` for details. .. note:: - Do not use ``stderr=PIPE`` with this function as that can deadlock - based on the child process error volume. Use :class:`Popen` with - the :meth:`communicate` method when you need a stderr pipe. + Do not use ``stderr=PIPE`` with this function. As the pipe is not being + read in the current process, the child process may block if it + generates enough output to the pipe to fill up the OS pipe buffer. .. data:: PIPE @@ -175,26 +172,6 @@ output. -.. exception:: CalledProcessError - - Exception raised when a process run by :func:`check_call` or - :func:`check_output` returns a non-zero exit status. - - .. attribute:: returncode - - Exit status of the child process. - - .. attribute:: cmd - - Command that was used to spawn the child process. - - .. attribute:: output - - Output of the child process if this exception is raised by - :func:`check_output`. Otherwise, ``None``. - - - .. _frequently-used-arguments: Frequently Used Arguments @@ -223,22 +200,15 @@ the stderr data from the child process should be captured into the same file handle as for stdout. - .. index:: - single: universal newlines; subprocess module + When *stdout* or *stderr* are pipes and *universal_newlines* is + :const:`True` then all line endings will be converted to ``'\n'`` as + described for the universal newlines `'U'`` mode argument to :func:`open`. - When *stdout* or *stderr* are pipes and *universal_newlines* is - ``True`` then all line endings will be converted to ``'\n'`` as described - for the :term:`universal newlines` ``'U'`` mode argument to :func:`open`. - - If *shell* is ``True``, the specified command will be executed through - the shell. This can be useful if you are using Python primarily for the + If *shell* is :const:`True`, the specified command will be executed through + the shell. This can be useful if you are using Python primarily for the enhanced control flow it offers over most system shells and still want - convenient access to other shell features such as shell pipes, filename - wildcards, environment variable expansion, and expansion of ``~`` to a - user's home directory. However, note that Python itself offers - implementations of many shell-like features (in particular, :mod:`glob`, - :mod:`fnmatch`, :func:`os.walk`, :func:`os.path.expandvars`, - :func:`os.path.expanduser`, and :mod:`shutil`). + access to other shell features such as filename wildcards, shell pipes and + environment variable expansion. .. warning:: @@ -246,8 +216,8 @@ untrusted source makes a program vulnerable to `shell injection `_, a serious security flaw which can result in arbitrary command execution. - For this reason, the use of ``shell=True`` is **strongly discouraged** - in cases where the command string is constructed from external input:: + For this reason, the use of *shell=True* is **strongly discouraged** in cases + where the command string is constructed from external input:: >>> from subprocess import call >>> filename = input("What file would you like to display?\n") @@ -259,16 +229,12 @@ from this vulnerability; see the Note in the :class:`Popen` constructor documentation for helpful hints in getting ``shell=False`` to work. - When using ``shell=True``, :func:`pipes.quote` can be used to properly - escape whitespace and shell metacharacters in strings that are going to - be used to construct shell commands. - These options, along with all of the other options, are described in more detail in the :class:`Popen` constructor documentation. -Popen Constructor -^^^^^^^^^^^^^^^^^ +Popen Constuctor +^^^^^^^^^^^^^^^^ The underlying process creation and management in this module is handled by the :class:`Popen` class. It offers a lot of flexibility so that developers @@ -276,26 +242,23 @@ functions. -.. class:: Popen(args, bufsize=0, executable=None, stdin=None, stdout=None, \ - stderr=None, preexec_fn=None, close_fds=False, shell=False, \ - cwd=None, env=None, universal_newlines=False, \ - startupinfo=None, creationflags=0) +.. class:: Popen(args, bufsize=0, executable=None, stdin=None, stdout=None, stderr=None, preexec_fn=None, close_fds=False, shell=False, cwd=None, env=None, universal_newlines=False, startupinfo=None, creationflags=0) - Execute a child program in a new process. On Unix, the class uses - :meth:`os.execvp`-like behavior to execute the child program. On Windows, - the class uses the Windows ``CreateProcess()`` function. The arguments to - :class:`Popen` are as follows. + Arguments are: - *args* should be a sequence of program arguments or else a single string. - By default, the program to execute is the first item in *args* if *args* is - a sequence. If *args* is a string, the interpretation is - platform-dependent and described below. See the *shell* and *executable* - arguments for additional differences from the default behavior. Unless - otherwise stated, it is recommended to pass *args* as a sequence. + *args* should be a string, or a sequence of program arguments. The program + to execute is normally the first item in the args sequence or the string if + a string is given, but can be explicitly set by using the *executable* + argument. When *executable* is given, the first item in the args sequence + is still treated by most programs as the command name, which can then be + different from the actual executable name. On Unix, it becomes the display + name for the executing program in utilities such as :program:`ps`. - On Unix, if *args* is a string, the string is interpreted as the name or - path of the program to execute. However, this can only be done if not - passing arguments to the program. + On Unix, with *shell=False* (default): In this case, the Popen class uses + :meth:`os.execvp` to execute the child program. *args* should normally be a + sequence. If a string is specified for *args*, it will be used as the name + or path of the program to execute; this will only work if the program is + being given no arguments. .. note:: @@ -316,36 +279,20 @@ used in the shell (such as filenames containing spaces or the *echo* command shown above) are single list elements. - On Windows, if *args* is a sequence, it will be converted to a string in a - manner described in :ref:`converting-argument-sequence`. This is because - the underlying ``CreateProcess()`` operates on strings. - - The *shell* argument (which defaults to *False*) specifies whether to use - the shell as the program to execute. If *shell* is *True*, it is - recommended to pass *args* as a string rather than as a sequence. - - On Unix with ``shell=True``, the shell defaults to :file:`/bin/sh`. If - *args* is a string, the string specifies the command - to execute through the shell. This means that the string must be + On Unix, with *shell=True*: If args is a string, it specifies the command + string to execute through the shell. This means that the string must be formatted exactly as it would be when typed at the shell prompt. This includes, for example, quoting or backslash escaping filenames with spaces in them. If *args* is a sequence, the first item specifies the command string, and any additional items will be treated as additional arguments to the shell - itself. That is to say, :class:`Popen` does the equivalent of:: + itself. That is to say, *Popen* does the equivalent of:: Popen(['/bin/sh', '-c', args[0], args[1], ...]) - On Windows with ``shell=True``, the :envvar:`COMSPEC` environment variable - specifies the default shell. The only time you need to specify - ``shell=True`` on Windows is when the command you wish to execute is built - into the shell (e.g. :command:`dir` or :command:`copy`). You do not need - ``shell=True`` to run a batch file or console-based executable. - - .. warning:: - - Passing ``shell=True`` can be a security hazard if combined with - untrusted input. See the warning under :ref:`frequently-used-arguments` - for details. + On Windows: the :class:`Popen` class uses CreateProcess() to execute the child + child program, which operates on strings. If *args* is a sequence, it will + be converted to a string in a manner described in + :ref:`converting-argument-sequence`. *bufsize*, if given, has the same meaning as the corresponding argument to the built-in open() function: :const:`0` means unbuffered, :const:`1` means line @@ -359,15 +306,15 @@ enable buffering by setting *bufsize* to either -1 or a large enough positive value (such as 4096). - The *executable* argument specifies a replacement program to execute. It - is very seldom needed. When ``shell=False``, *executable* replaces the - program to execute specified by *args*. However, the original *args* is - still passed to the program. Most programs treat the program specified - by *args* as the command name, which can then be different from the program - actually executed. On Unix, the *args* name - becomes the display name for the executable in utilities such as - :program:`ps`. If ``shell=True``, on Unix the *executable* argument - specifies a replacement shell for the default :file:`/bin/sh`. + The *executable* argument specifies the program to execute. It is very seldom + needed: Usually, the program to execute is defined by the *args* argument. If + ``shell=True``, the *executable* argument specifies which shell to use. On Unix, + the default shell is :file:`/bin/sh`. On Windows, the default shell is + specified by the :envvar:`COMSPEC` environment variable. The only reason you + would need to specify ``shell=True`` on Windows is where the command you + wish to execute is actually built in to the shell, eg ``dir``, ``copy``. + You don't need ``shell=True`` to run a batch file, nor to run a console-based + executable. *stdin*, *stdout* and *stderr* specify the executed program's standard input, standard output and standard error file handles, respectively. Valid values @@ -388,6 +335,15 @@ child process. Note that on Windows, you cannot set *close_fds* to true and also redirect the standard handles by setting *stdin*, *stdout* or *stderr*. + If *shell* is :const:`True`, the specified command will be executed through the + shell. + + .. warning:: + + Enabling this option can be a security hazard if combined with untrusted + input. See the warning under :ref:`frequently-used-arguments` + for details. + If *cwd* is not ``None``, the child's current directory will be changed to *cwd* before it is executed. Note that this directory is not considered when searching the executable, so you can't specify the program's path relative to @@ -406,11 +362,11 @@ .. _side-by-side assembly: http://en.wikipedia.org/wiki/Side-by-Side_Assembly - If *universal_newlines* is ``True``, the file objects *stdout* and *stderr* - are opened as text files in :term:`universal newlines` mode. Lines may be - terminated by any of ``'\n'``, the Unix end-of-line convention, ``'\r'``, - the old Macintosh convention or ``'\r\n'``, the Windows convention. All of - these external representations are seen as ``'\n'`` by the Python program. + If *universal_newlines* is :const:`True`, the file objects stdout and stderr are + opened as text files, but lines may be terminated by any of ``'\n'``, the Unix + end-of-line convention, ``'\r'``, the old Macintosh convention or ``'\r\n'``, the + Windows convention. All of these external representations are seen as ``'\n'`` + by the Python program. .. note:: @@ -463,14 +419,14 @@ .. method:: Popen.poll() - Check if child process has terminated. Set and return - :attr:`~Popen.returncode` attribute. + Check if child process has terminated. Set and return :attr:`returncode` + attribute. .. method:: Popen.wait() - Wait for child process to terminate. Set and return - :attr:`~Popen.returncode` attribute. + Wait for child process to terminate. Set and return :attr:`returncode` + attribute. .. warning:: @@ -516,7 +472,7 @@ .. method:: Popen.terminate() Stop the child. On Posix OSs the method sends SIGTERM to the - child. On Windows the Win32 API function :c:func:`TerminateProcess` is called + child. On Windows the Win32 API function :cfunc:`TerminateProcess` is called to stop the child. .. versionadded:: 2.6 @@ -534,8 +490,8 @@ .. warning:: - Use :meth:`~Popen.communicate` rather than :attr:`.stdin.write `, - :attr:`.stdout.read ` or :attr:`.stderr.read ` to avoid + Use :meth:`communicate` rather than :attr:`.stdin.write `, + :attr:`.stdout.read ` or :attr:`.stderr.read ` to avoid deadlocks due to any of the other OS pipe buffers filling up and blocking the child process. @@ -683,8 +639,8 @@ .. _subprocess-replacements: -Replacing Older Functions with the :mod:`subprocess` Module ------------------------------------------------------------ +Replacing Older Functions with the subprocess Module +---------------------------------------------------- In this section, "a becomes b" means that b can be used as a replacement for a. @@ -696,11 +652,11 @@ In addition, the replacements using :func:`check_output` will fail with a :exc:`CalledProcessError` if the requested operation produces a non-zero - return code. The output is still available as the - :attr:`~CalledProcessError.output` attribute of the raised exception. + return code. The output is still available as the ``output`` attribute of + the raised exception. In the following examples, we assume that the relevant functions have already -been imported from the :mod:`subprocess` module. +been imported from the subprocess module. Replacing /bin/sh shell backquote @@ -729,7 +685,7 @@ to receive a SIGPIPE if p2 exits before p1. Alternatively, for trusted input, the shell's own pipeline support may still -be used directly:: +be used directly: output=`dmesg | grep hda` # becomes @@ -741,9 +697,9 @@ :: - status = os.system("mycmd" + " myarg") + sts = os.system("mycmd" + " myarg") # becomes - status = subprocess.call("mycmd" + " myarg", shell=True) + sts = call("mycmd" + " myarg", shell=True) Notes: @@ -757,7 +713,7 @@ print >>sys.stderr, "Child was terminated by signal", -retcode else: print >>sys.stderr, "Child returned", retcode - except OSError as e: + except OSError, e: print >>sys.stderr, "Execution failed:", e @@ -866,7 +822,7 @@ (child_stdout, child_stdin) = popen2.popen2("somestring", bufsize, mode) ==> - p = Popen("somestring", shell=True, bufsize=bufsize, + p = Popen(["somestring"], shell=True, bufsize=bufsize, stdin=PIPE, stdout=PIPE, close_fds=True) (child_stdout, child_stdin) = (p.stdout, p.stdin) diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/library/sunaudio.rst --- a/Doc/library/sunaudio.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/library/sunaudio.rst Sun Jul 20 10:52:46 2014 -0400 @@ -8,7 +8,7 @@ :deprecated: .. deprecated:: 2.6 - The :mod:`sunaudiodev` module has been removed in Python 3. + The :mod:`sunaudiodev` module has been deprecated for removal in Python 3.0. @@ -93,10 +93,10 @@ names and meanings of the attributes are described in ```` and in the :manpage:`audio(7I)` manual page. Member names are slightly different from their C counterparts: a status object is only a single structure. Members of the - :c:data:`play` substructure have ``o_`` prepended to their name and members of - the :c:data:`record` structure have ``i_``. So, the C member - :c:data:`play.sample_rate` is accessed as :attr:`o_sample_rate`, - :c:data:`record.gain` as :attr:`i_gain` and :c:data:`monitor_gain` plainly as + :cdata:`play` substructure have ``o_`` prepended to their name and members of + the :cdata:`record` structure have ``i_``. So, the C member + :cdata:`play.sample_rate` is accessed as :attr:`o_sample_rate`, + :cdata:`record.gain` as :attr:`i_gain` and :cdata:`monitor_gain` plainly as :attr:`monitor_gain`. @@ -153,7 +153,7 @@ :deprecated: .. deprecated:: 2.6 - The :mod:`SUNAUDIODEV` module has been removed in Python 3. + The :mod:`SUNAUDIODEV` module has been deprecated for removal in Python 3.0. diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/library/symbol.rst --- a/Doc/library/symbol.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/library/symbol.rst Sun Jul 20 10:52:46 2014 -0400 @@ -25,3 +25,10 @@ back to name strings, allowing more human-readable representation of parse trees to be generated. + +.. seealso:: + + Module :mod:`parser` + The second example for the :mod:`parser` module shows how to use the + :mod:`symbol` module. + diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/library/sys.rst --- a/Doc/library/sys.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/library/sys.rst Sun Jul 20 10:52:46 2014 -0400 @@ -1,3 +1,4 @@ + :mod:`sys` --- System-specific parameters and functions ======================================================= @@ -207,17 +208,15 @@ be set at build time with the ``--exec-prefix`` argument to the :program:`configure` script. Specifically, all configuration files (e.g. the :file:`pyconfig.h` header file) are installed in the directory - :file:`{exec_prefix}/lib/python{X.Y}/config`, and shared library modules are + :file:`{exec_prefix}/lib/python{X.Y}/config', and shared library modules are installed in :file:`{exec_prefix}/lib/python{X.Y}/lib-dynload`, where *X.Y* is the version number of Python, for example ``2.7``. .. data:: executable - A string giving the absolute path of the executable binary for the Python - interpreter, on systems where this makes sense. If Python is unable to retrieve - the real path to its executable, :data:`sys.executable` will be an empty string - or ``None``. + A string giving the name of the executable binary for the Python interpreter, on + systems where this makes sense. .. function:: exit([arg]) @@ -285,13 +284,10 @@ :const:`verbose` :option:`-v` :const:`unicode` :option:`-U` :const:`bytes_warning` :option:`-b` - :const:`hash_randomization` :option:`-R` ============================= =================================== .. versionadded:: 2.6 - .. versionadded:: 2.7.3 - The ``hash_randomization`` attribute. .. data:: float_info @@ -302,8 +298,6 @@ 5.2.4.2.2 of the 1999 ISO/IEC C standard [C99]_, 'Characteristics of floating types', for details. - .. tabularcolumns:: |l|l|L| - +---------------------+----------------+--------------------------------------------------+ | attribute | float.h macro | explanation | +=====================+================+==================================================+ @@ -394,7 +388,7 @@ .. function:: getdlopenflags() - Return the current value of the flags that are used for :c:func:`dlopen` calls. + Return the current value of the flags that are used for :cfunc:`dlopen` calls. The flag constants are defined in the :mod:`dl` and :mod:`DLFCN` modules. Availability: Unix. @@ -539,8 +533,8 @@ +---------------------------------------+---------------------------------+ - This function wraps the Win32 :c:func:`GetVersionEx` function; see the - Microsoft documentation on :c:func:`OSVERSIONINFOEX` for more information + This function wraps the Win32 :cfunc:`GetVersionEx` function; see the + Microsoft documentation on :cfunc:`OSVERSIONINFOEX` for more information about these fields. Availability: Windows. @@ -601,8 +595,6 @@ A struct sequence that holds information about Python's internal representation of integers. The attributes are read only. - .. tabularcolumns:: |l|L| - +-------------------------+----------------------------------------------+ | Attribute | Explanation | +=========================+==============================================+ @@ -661,7 +653,7 @@ imported. The :meth:`find_module` method is called at least with the absolute name of the module being imported. If the module to be imported is contained in package then the parent package's :attr:`__path__` attribute - is passed in as a second argument. The method returns ``None`` if + is passed in as a second argument. The method returns :keyword:`None` if the module cannot be found, else returns a :term:`loader`. :data:`sys.meta_path` is searched before any implicit default finders or @@ -720,7 +712,7 @@ A dictionary acting as a cache for :term:`finder` objects. The keys are paths that have been passed to :data:`sys.path_hooks` and the values are the finders that are found. If a path is a valid file system path but no - explicit finder is found on :data:`sys.path_hooks` then ``None`` is + explicit finder is found on :data:`sys.path_hooks` then :keyword:`None` is stored to represent the implicit default finder should be used. If the path is not an existing path then :class:`imp.NullImporter` is set. @@ -778,9 +770,9 @@ independent Python files are installed; by default, this is the string ``'/usr/local'``. This can be set at build time with the ``--prefix`` argument to the :program:`configure` script. The main collection of Python - library modules is installed in the directory :file:`{prefix}/lib/python{X.Y}` + library modules is installed in the directory :file:`{prefix}/lib/python{X.Y}`` while the platform independent header files (all except :file:`pyconfig.h`) are - stored in :file:`{prefix}/include/python{X.Y}`, where *X.Y* is the version + stored in :file:`{prefix}/include/python{X.Y}``, where *X.Y* is the version number of Python, for example ``2.7``. @@ -801,10 +793,10 @@ .. data:: py3kwarning - Bool containing the status of the Python 3 warning flag. It's ``True`` + Bool containing the status of the Python 3.0 warning flag. It's ``True`` when Python is started with the -3 option. (This should be considered read-only; setting it to a different value doesn't have an effect on - Python 3 warnings.) + Python 3.0 warnings.) .. versionadded:: 2.6 @@ -835,7 +827,7 @@ .. function:: setdlopenflags(n) - Set the flags used by the interpreter for :c:func:`dlopen` calls, such as when + Set the flags used by the interpreter for :cfunc:`dlopen` calls, such as when the interpreter loads extension modules. Among other things, this will enable a lazy resolving of symbols when importing a module, if called as ``sys.setdlopenflags(0)``. To share symbols across extension modules, call as @@ -1077,5 +1069,5 @@ .. rubric:: Citations -.. [C99] ISO/IEC 9899:1999. "Programming languages -- C." A public draft of this standard is available at http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1256.pdf\ . +.. [C99] ISO/IEC 9899:1999. "Programming languages -- C." A public draft of this standard is available at http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1256.pdf . diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/library/sysconfig.rst --- a/Doc/library/sysconfig.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/library/sysconfig.rst Sun Jul 20 10:52:46 2014 -0400 @@ -129,7 +129,7 @@ one may call this function and get the default value. If *scheme* is provided, it must be a value from the list returned by - :func:`get_scheme_names`. Otherwise, the default scheme for the current + :func:`get_path_names`. Otherwise, the default scheme for the current platform is used. If *vars* is provided, it must be a dictionary of variables that will update diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/library/syslog.rst --- a/Doc/library/syslog.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/library/syslog.rst Sun Jul 20 10:52:46 2014 -0400 @@ -17,8 +17,7 @@ The module defines the following functions: -.. function:: syslog(message) - syslog(priority, message) +.. function:: syslog([priority,] message) Send the string *message* to the system logger. A trailing newline is added if necessary. Each message is tagged with a priority composed of a @@ -31,7 +30,7 @@ ``openlog()`` will be called with no arguments. -.. function:: openlog([ident[, logoption[, facility]]]) +.. function:: openlog([ident[, logopt[, facility]]]) Logging options of subsequent :func:`syslog` calls can be set by calling :func:`openlog`. :func:`syslog` will call :func:`openlog` with no arguments @@ -39,7 +38,7 @@ The optional *ident* keyword argument is a string which is prepended to every message, and defaults to ``sys.argv[0]`` with leading path components - stripped. The optional *logoption* keyword argument (default is 0) is a bit + stripped. The optional *logopt* keyword argument (default is 0) is a bit field -- see below for possible values to combine. The optional *facility* keyword argument (default is :const:`LOG_USER`) sets the default facility for messages which do not have a facility explicitly encoded. @@ -74,8 +73,7 @@ Facilities: :const:`LOG_KERN`, :const:`LOG_USER`, :const:`LOG_MAIL`, :const:`LOG_DAEMON`, :const:`LOG_AUTH`, :const:`LOG_LPR`, :const:`LOG_NEWS`, :const:`LOG_UUCP`, - :const:`LOG_CRON`, :const:`LOG_SYSLOG` and :const:`LOG_LOCAL0` to - :const:`LOG_LOCAL7`. + :const:`LOG_CRON` and :const:`LOG_LOCAL0` to :const:`LOG_LOCAL7`. Log options: :const:`LOG_PID`, :const:`LOG_CONS`, :const:`LOG_NDELAY`, :const:`LOG_NOWAIT` @@ -100,5 +98,5 @@ logged messages, and write the messages to the destination facility used for mail logging:: - syslog.openlog(logoption=syslog.LOG_PID, facility=syslog.LOG_MAIL) + syslog.openlog(logopt=syslog.LOG_PID, facility=syslog.LOG_MAIL) syslog.syslog('E-mail processing initiated...') diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/library/tarfile.rst --- a/Doc/library/tarfile.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/library/tarfile.rst Sun Jul 20 10:52:46 2014 -0400 @@ -16,8 +16,7 @@ The :mod:`tarfile` module makes it possible to read and write tar archives, including those using gzip or bz2 compression. -Use the :mod:`zipfile` module to read or write :file:`.zip` files, or the -higher-level functions in :ref:`shutil `. +(:file:`.zip` files can be read and written using the :mod:`zipfile` module.) Some facts and figures: @@ -77,10 +76,6 @@ If *fileobj* is specified, it is used as an alternative to a file object opened for *name*. It is supposed to be at position 0. - For modes ``'w:gz'``, ``'r:gz'``, ``'w:bz2'``, ``'r:bz2'``, :func:`tarfile.open` - accepts the keyword argument *compresslevel* to specify the compression level of - the file. - For special purposes, there is a second format for *mode*: ``'filemode|[compression]'``. :func:`tarfile.open` will return a :class:`TarFile` object that processes its data as a stream of blocks. No random seeking will @@ -147,7 +142,7 @@ .. deprecated:: 2.6 - The :class:`TarFileCompat` class has been removed in Python 3. + The :class:`TarFileCompat` class has been deprecated for removal in Python 3.0. .. exception:: TarError @@ -309,7 +304,7 @@ .. versionadded:: 2.6 -.. classmethod:: TarFile.open(...) +.. method:: TarFile.open(...) Alternative constructor. The :func:`tarfile.open` function is actually a shortcut to this classmethod. @@ -548,7 +543,7 @@ :const:`AREGTYPE`, :const:`LNKTYPE`, :const:`SYMTYPE`, :const:`DIRTYPE`, :const:`FIFOTYPE`, :const:`CONTTYPE`, :const:`CHRTYPE`, :const:`BLKTYPE`, :const:`GNUTYPE_SPARSE`. To determine the type of a :class:`TarInfo` object - more conveniently, use the ``is*()`` methods below. + more conveniently, use the ``is_*()`` methods below. .. attribute:: TarInfo.linkname diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/library/telnetlib.rst --- a/Doc/library/telnetlib.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/library/telnetlib.rst Sun Jul 20 10:52:46 2014 -0400 @@ -189,7 +189,7 @@ Read until one from a list of a regular expressions matches. The first argument is a list of regular expressions, either compiled - (:class:`regex objects `) or uncompiled (strings). The optional second + (:class:`re.RegexObject` instances) or uncompiled (strings). The optional second argument is a timeout, in seconds; the default is to block indefinitely. Return a tuple of three items: the index in the list of the first regular @@ -208,7 +208,7 @@ .. method:: Telnet.set_option_negotiation_callback(callback) Each time a telnet option is read on the input flow, this *callback* (if set) is - called with the following parameters: callback(telnet socket, command + called with the following parameters : callback(telnet socket, command (DO/DONT/WILL/WONT), option). No other action is done afterwards by telnetlib. diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/library/tempfile.rst --- a/Doc/library/tempfile.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/library/tempfile.rst Sun Jul 20 10:52:46 2014 -0400 @@ -86,14 +86,13 @@ data is spooled in memory until the file size exceeds *max_size*, or until the file's :func:`fileno` method is called, at which point the contents are written to disk and operation proceeds as with - :func:`TemporaryFile`. Also, it's ``truncate`` method does not - accept a ``size`` argument. + :func:`TemporaryFile`. The resulting file has one additional method, :func:`rollover`, which causes the file to roll over to an on-disk file regardless of its size. The returned object is a file-like object whose :attr:`_file` attribute - is either a :class:`~StringIO.StringIO` object or a true file object, depending on + is either a :class:`StringIO` object or a true file object, depending on whether :func:`rollover` has been called. This file-like object can be used in a :keyword:`with` statement, just like a normal file. diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/library/test.rst --- a/Doc/library/test.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/library/test.rst Sun Jul 20 10:52:46 2014 -0400 @@ -169,10 +169,10 @@ the test passed or failed and thus minimize output. Running :mod:`test.regrtest` directly allows what resources are available for -tests to use to be set. You do this by using the ``-u`` command-line -option. Specifying ``all`` as the value for the ``-u`` option enables all -possible resources: :program:`python -m test -uall`. -If all but one resource is desired (a more common case), a +tests to use to be set. You do this by using the :option:`-u` command-line +option. Run :program:`python -m test.regrtest -uall` to turn on all +resources; specifying ``all`` as an option for ``-u`` enables all +possible resources. If all but one resource is desired (a more common case), a comma-separated list of resources that are not desired may be listed after ``all``. The command :program:`python -m test.regrtest -uall,-audio,-largefile` will run :mod:`test.regrtest` with all resources except the ``audio`` and @@ -380,7 +380,7 @@ with captured_stdout() as s: print "hello" - assert s.getvalue() == "hello\n" + assert s.getvalue() == "hello" .. versionadded:: 2.6 diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/library/textwrap.rst --- a/Doc/library/textwrap.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/library/textwrap.rst Sun Jul 20 10:52:46 2014 -0400 @@ -26,9 +26,6 @@ Optional keyword arguments correspond to the instance attributes of :class:`TextWrapper`, documented below. *width* defaults to ``70``. - See the :meth:`TextWrapper.wrap` method for additional details on how - :func:`wrap` behaves. - .. function:: fill(text[, width[, ...]]) @@ -115,11 +112,9 @@ .. attribute:: replace_whitespace - (default: ``True``) If true, after tab expansion but before wrapping, - the :meth:`wrap` method will replace each whitespace character - with a single space. The whitespace characters replaced are - as follows: tab, newline, vertical tab, formfeed, and carriage - return (``'\t\n\v\f\r'``). + (default: ``True``) If true, each whitespace character (as defined by + ``string.whitespace``) remaining after tab expansion will be replaced by a + single space. .. note:: @@ -137,11 +132,9 @@ .. attribute:: drop_whitespace - (default: ``True``) If true, whitespace at the beginning and ending of - every line (after wrapping but before indenting) is dropped. - Whitespace at the beginning of the paragraph, however, is not dropped - if non-whitespace follows it. If whitespace being dropped takes up an - entire line, the whole line is dropped. + (default: ``True``) If true, whitespace that, after wrapping, happens to + end up at the beginning or end of a line is dropped (leading whitespace in + the first line is always preserved, though). .. versionadded:: 2.6 Whitespace was always dropped in earlier versions. @@ -150,8 +143,7 @@ .. attribute:: initial_indent (default: ``''``) String that will be prepended to the first line of - wrapped output. Counts towards the length of the first line. The empty - string is not indented. + wrapped output. Counts towards the length of the first line. .. attribute:: subsequent_indent @@ -214,9 +206,8 @@ Wraps the single paragraph in *text* (a string) so every line is at most :attr:`width` characters long. All wrapping options are taken from - instance attributes of the :class:`TextWrapper` instance. Returns a list - of output lines, without final newlines. If the wrapped output has no - content, the returned list is empty. + instance attributes of the :class:`TextWrapper` instance. Returns a list + of output lines, without final newlines. .. method:: fill(text) diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/library/thread.rst --- a/Doc/library/thread.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/library/thread.rst Sun Jul 20 10:52:46 2014 -0400 @@ -5,9 +5,9 @@ :synopsis: Create multiple threads of control within one interpreter. .. note:: - The :mod:`thread` module has been renamed to :mod:`_thread` in Python 3. + The :mod:`thread` module has been renamed to :mod:`_thread` in Python 3.0. The :term:`2to3` tool will automatically adapt imports when converting your - sources to Python 3; however, you should consider using the high-level + sources to 3.0; however, you should consider using the high-level :mod:`threading` module instead. @@ -159,6 +159,10 @@ * Calling :func:`sys.exit` or raising the :exc:`SystemExit` exception is equivalent to calling :func:`thread.exit`. +* Not all built-in functions that may block waiting for I/O allow other threads + to run. (The most popular ones (:func:`time.sleep`, :meth:`file.read`, + :func:`select.select`) work as expected.) + * It is not possible to interrupt the :meth:`acquire` method on a lock --- the :exc:`KeyboardInterrupt` exception will happen after the lock has been acquired. diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/library/threading.rst --- a/Doc/library/threading.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/library/threading.rst Sun Jul 20 10:52:46 2014 -0400 @@ -31,10 +31,10 @@ .. impl-detail:: - In CPython, due to the :term:`Global Interpreter Lock`, only one thread + Due to the :term:`Global Interpreter Lock`, in CPython only one thread can execute Python code at once (even though certain performance-oriented libraries might overcome this limitation). - If you want your application to make better use of the computational + If you want your application to make better of use of the computational resources of multi-core machines, you are advised to use :mod:`multiprocessing`. However, threading is still an appropriate model if you want to run multiple I/O-bound tasks simultaneously. @@ -48,9 +48,6 @@ Return the number of :class:`Thread` objects currently alive. The returned count is equal to the length of the list returned by :func:`.enumerate`. - .. versionchanged:: 2.6 - Added ``active_count()`` spelling. - .. function:: Condition() :noindex: @@ -70,9 +67,6 @@ :mod:`threading` module, a dummy thread object with limited functionality is returned. - .. versionchanged:: 2.6 - Added ``current_thread()`` spelling. - .. function:: enumerate() @@ -173,7 +167,7 @@ Set a trace function for all threads started from the :mod:`threading` module. The *func* will be passed to :func:`sys.settrace` for each thread, before its - :meth:`~Thread.run` method is called. + :meth:`run` method is called. .. versionadded:: 2.3 @@ -184,7 +178,7 @@ Set a profile function for all threads started from the :mod:`threading` module. The *func* will be passed to :func:`sys.setprofile` for each thread, before its - :meth:`~Thread.run` method is called. + :meth:`run` method is called. .. versionadded:: 2.3 @@ -208,13 +202,6 @@ .. versionadded:: 2.5 - -.. exception:: ThreadError - - Raised for various threading-related errors as described below. Note that - many interfaces use :exc:`RuntimeError` instead of :exc:`ThreadError`. - - Detailed interfaces for the objects are documented below. The design of this module is loosely based on Java's threading model. However, @@ -260,12 +247,6 @@ initial value is inherited from the creating thread. The flag can be set through the :attr:`daemon` property. -.. note:: - Daemon threads are abruptly stopped at shutdown. Their resources (such - as open files, database transactions, etc.) may not be released properly. - If you want your threads to stop gracefully, make them non-daemonic and - use a suitable signalling mechanism such as an :class:`Event`. - There is a "main thread" object; this corresponds to the initial thread of control in the Python program. It is not a daemon thread. @@ -341,19 +322,17 @@ :meth:`join` a thread before it has been started and attempts to do so raises the same exception. + .. method:: getName() + setName() + + Old API for :attr:`~Thread.name`. + .. attribute:: name A string used for identification purposes only. It has no semantics. Multiple threads may be given the same name. The initial name is set by the constructor. - .. versionadded:: 2.6 - - .. method:: getName() - setName() - - Pre-2.6 API for :attr:`~Thread.name`. - .. attribute:: ident The 'thread identifier' of this thread or ``None`` if the thread has not @@ -373,8 +352,10 @@ until just after the :meth:`run` method terminates. The module function :func:`.enumerate` returns a list of all alive threads. - .. versionchanged:: 2.6 - Added ``is_alive()`` spelling. + .. method:: isDaemon() + setDaemon() + + Old API for :attr:`~Thread.daemon`. .. attribute:: daemon @@ -387,13 +368,6 @@ The entire Python program exits when no alive non-daemon threads are left. - .. versionadded:: 2.6 - - .. method:: isDaemon() - setDaemon() - - Pre-2.6 API for :attr:`~Thread.daemon`. - .. _lock-objects: @@ -413,7 +387,7 @@ then the :meth:`acquire` call resets it to locked and returns. The :meth:`release` method should only be called in the locked state; it changes the state to unlocked and returns immediately. If an attempt is made to release an -unlocked lock, a :exc:`ThreadError` will be raised. +unlocked lock, a :exc:`RuntimeError` will be raised. When more than one thread is blocked in :meth:`acquire` waiting for the state to turn to unlocked, only one thread proceeds when a :meth:`release` call resets @@ -427,12 +401,15 @@ Acquire a lock, blocking or non-blocking. - When invoked with the *blocking* argument set to ``True`` (the default), - block until the lock is unlocked, then set it to locked and return ``True``. + When invoked without arguments, block until the lock is unlocked, then set it to + locked, and return true. - When invoked with the *blocking* argument set to ``False``, do not block. - If a call with *blocking* set to ``True`` would block, return ``False`` - immediately; otherwise, set the lock to locked and return ``True``. + When invoked with the *blocking* argument set to true, do the same thing as when + called without arguments, and return true. + + When invoked with the *blocking* argument set to false, do not block. If a call + without an argument would block, return false immediately; otherwise, do the + same thing as when called without arguments, and return true. .. method:: Lock.release() @@ -443,7 +420,7 @@ are blocked waiting for the lock to become unlocked, allow exactly one of them to proceed. - When invoked on an unlocked lock, a :exc:`ThreadError` is raised. + Do not call this method when the lock is unlocked. There is no return value. @@ -622,9 +599,6 @@ calling thread has not acquired the lock when this method is called, a :exc:`RuntimeError` is raised. - .. versionchanged:: 2.6 - Added ``notify_all()`` spelling. - .. _semaphore-objects: @@ -724,7 +698,7 @@ Return true if and only if the internal flag is true. .. versionchanged:: 2.6 - Added ``is_set()`` spelling. + The ``is_set()`` syntax is new. .. method:: set() @@ -765,11 +739,10 @@ of time has passed --- a timer. :class:`Timer` is a subclass of :class:`Thread` and as such also functions as an example of creating custom threads. -Timers are started, as with threads, by calling their :meth:`~Timer.start` -method. The timer can be stopped (before its action has begun) by calling the -:meth:`~Timer.cancel` method. The interval the timer will wait before -executing its action may not be exactly the same as the interval specified by -the user. +Timers are started, as with threads, by calling their :meth:`start` method. The +timer can be stopped (before its action has begun) by calling the :meth:`cancel` +method. The interval the timer will wait before executing its action may not be +exactly the same as the interval specified by the user. For example:: diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/library/time.rst --- a/Doc/library/time.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/library/time.rst Sun Jul 20 10:52:46 2014 -0400 @@ -71,11 +71,11 @@ the units in which their value or argument is expressed. E.g. on most Unix systems, the clock "ticks" only 50 or 100 times a second. -* On the other hand, the precision of :func:`.time` and :func:`sleep` is better +* On the other hand, the precision of :func:`time` and :func:`sleep` is better than their Unix equivalents: times are expressed as floating point numbers, - :func:`.time` returns the most accurate time available (using Unix - :c:func:`gettimeofday` where available), and :func:`sleep` will accept a time - with a nonzero fraction (Unix :c:func:`select` is used to implement this, where + :func:`time` returns the most accurate time available (using Unix + :cfunc:`gettimeofday` where available), and :func:`sleep` will accept a time + with a nonzero fraction (Unix :cfunc:`select` is used to implement this, where available). * The time value as returned by :func:`gmtime`, :func:`localtime`, and @@ -156,7 +156,7 @@ On Windows, this function returns wall-clock seconds elapsed since the first call to this function, as a floating point number, based on the Win32 function - :c:func:`QueryPerformanceCounter`. The resolution is typically better than one + :cfunc:`QueryPerformanceCounter`. The resolution is typically better than one microsecond. @@ -164,7 +164,7 @@ Convert a time expressed in seconds since the epoch to a string representing local time. If *secs* is not provided or :const:`None`, the current time as - returned by :func:`.time` is used. ``ctime(secs)`` is equivalent to + returned by :func:`time` is used. ``ctime(secs)`` is equivalent to ``asctime(localtime(secs))``. Locale information is not used by :func:`ctime`. .. versionchanged:: 2.1 @@ -183,7 +183,7 @@ Convert a time expressed in seconds since the epoch to a :class:`struct_time` in UTC in which the dst flag is always zero. If *secs* is not provided or - :const:`None`, the current time as returned by :func:`.time` is used. Fractions + :const:`None`, the current time as returned by :func:`time` is used. Fractions of a second are ignored. See above for a description of the :class:`struct_time` object. See :func:`calendar.timegm` for the inverse of this function. @@ -198,7 +198,7 @@ .. function:: localtime([secs]) Like :func:`gmtime` but converts to local time. If *secs* is not provided or - :const:`None`, the current time as returned by :func:`.time` is used. The dst + :const:`None`, the current time as returned by :func:`time` is used. The dst flag is set to ``1`` when DST applies to the given time. .. versionchanged:: 2.1 @@ -213,7 +213,7 @@ This is the inverse function of :func:`localtime`. Its argument is the :class:`struct_time` or full 9-tuple (since the dst flag is needed; use ``-1`` as the dst flag if it is unknown) which expresses the time in *local* time, not - UTC. It returns a floating point number, for compatibility with :func:`.time`. + UTC. It returns a floating point number, for compatibility with :func:`time`. If the input value cannot be represented as a valid time, either :exc:`OverflowError` or :exc:`ValueError` will be raised (which depends on whether the invalid value is caught by Python or the underlying C libraries). @@ -236,9 +236,7 @@ :func:`gmtime` or :func:`localtime` to a string as specified by the *format* argument. If *t* is not provided, the current time as returned by :func:`localtime` is used. *format* must be a string. :exc:`ValueError` is - raised if any field in *t* is outside of the allowed range. :func:`strftime` - returns a locale depedent byte string; the result may be converted to unicode - by doing ``strftime().decode(locale.getlocale()[1])``. + raised if any field in *t* is outside of the allowed range. .. versionchanged:: 2.1 Allowed *t* to be omitted. @@ -248,7 +246,7 @@ .. versionchanged:: 2.5 0 is now a legal argument for any position in the time tuple; if it is normally - illegal the value is forced to a correct one. + illegal the value is forced to a correct one.. The following directives can be embedded in the *format* string. They are shown without the optional field width and precision specification, and are replaced @@ -352,10 +350,8 @@ >>> strftime("%a, %d %b %Y %H:%M:%S +0000", gmtime()) 'Thu, 28 Jun 2001 14:17:15 +0000' - Additional directives may be supported on certain platforms, but only the - ones listed here have a meaning standardized by ANSI C. To see the full set - of format codes supported on your platform, consult the :manpage:`strftime(3)` - documentation. + Additional directives may be supported on certain platforms, but only the ones + listed here have a meaning standardized by ANSI C. On some platforms, an optional field width and precision specification can immediately follow the initial ``'%'`` of a directive in the following order; @@ -414,7 +410,7 @@ +-------+-------------------+---------------------------------+ | 4 | :attr:`tm_min` | range [0, 59] | +-------+-------------------+---------------------------------+ - | 5 | :attr:`tm_sec` | range [0, 61]; see **(2)** in | + | 5 | :attr:`tm_sec` | range [0, 61]; see **(1)** in | | | | :func:`strftime` description | +-------+-------------------+---------------------------------+ | 6 | :attr:`tm_wday` | range [0, 6], Monday is 0 | @@ -439,8 +435,8 @@ .. function:: time() - Return the time in seconds since the epoch as a floating point number. - Note that even though the time is always returned as a floating point + Return the time as a floating point number expressed in seconds since the epoch, + in UTC. Note that even though the time is always returned as a floating point number, not all systems provide time with a better precision than 1 second. While this function normally returns non-decreasing values, it can return a lower value than a previous call if the system clock has been set back between @@ -551,12 +547,12 @@ More object-oriented interface to dates and times. Module :mod:`locale` - Internationalization services. The locale setting affects the interpretation - of many format specifiers in :func:`strftime` and :func:`strptime`. + Internationalization services. The locale settings can affect the return values + for some of the functions in the :mod:`time` module. Module :mod:`calendar` - General calendar-related functions. :func:`~calendar.timegm` is the - inverse of :func:`gmtime` from this module. + General calendar-related functions. :func:`timegm` is the inverse of + :func:`gmtime` from this module. .. rubric:: Footnotes diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/library/timeit.rst --- a/Doc/library/timeit.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/library/timeit.rst Sun Jul 20 10:52:46 2014 -0400 @@ -16,163 +16,112 @@ -------------- This module provides a simple way to time small bits of Python code. It has both -a :ref:`command-line-interface` as well as a :ref:`callable ` -one. It avoids a number of common traps for measuring execution times. -See also Tim Peters' introduction to the "Algorithms" chapter in the *Python -Cookbook*, published by O'Reilly. +command line as well as callable interfaces. It avoids a number of common traps +for measuring execution times. See also Tim Peters' introduction to the +"Algorithms" chapter in the Python Cookbook, published by O'Reilly. +The module defines the following public class: -Basic Examples --------------- -The following example shows how the :ref:`command-line-interface` -can be used to compare three different expressions: +.. class:: Timer([stmt='pass' [, setup='pass' [, timer=]]]) -.. code-block:: sh + Class for timing execution speed of small code snippets. - $ python -m timeit '"-".join(str(n) for n in range(100))' - 10000 loops, best of 3: 40.3 usec per loop - $ python -m timeit '"-".join([str(n) for n in range(100)])' - 10000 loops, best of 3: 33.4 usec per loop - $ python -m timeit '"-".join(map(str, range(100)))' - 10000 loops, best of 3: 25.2 usec per loop + The constructor takes a statement to be timed, an additional statement used for + setup, and a timer function. Both statements default to ``'pass'``; the timer + function is platform-dependent (see the module doc string). *stmt* and *setup* + may also contain multiple statements separated by ``;`` or newlines, as long as + they don't contain multi-line string literals. -This can be achieved from the :ref:`python-interface` with:: + To measure the execution time of the first statement, use the :meth:`timeit` + method. The :meth:`repeat` method is a convenience to call :meth:`timeit` + multiple times and return a list of results. - >>> import timeit - >>> timeit.timeit('"-".join(str(n) for n in range(100))', number=10000) - 0.8187260627746582 - >>> timeit.timeit('"-".join([str(n) for n in range(100)])', number=10000) - 0.7288308143615723 - >>> timeit.timeit('"-".join(map(str, range(100)))', number=10000) - 0.5858950614929199 + .. versionchanged:: 2.6 + The *stmt* and *setup* parameters can now also take objects that are callable + without arguments. This will embed calls to them in a timer function that will + then be executed by :meth:`timeit`. Note that the timing overhead is a little + larger in this case because of the extra function calls. -Note however that :mod:`timeit` will automatically determine the number of -repetitions only when the command-line interface is used. In the -:ref:`timeit-examples` section you can find more advanced examples. +.. method:: Timer.print_exc([file=None]) -.. _python-interface: + Helper to print a traceback from the timed code. -Python Interface ----------------- + Typical use:: -The module defines three convenience functions and a public class: + t = Timer(...) # outside the try/except + try: + t.timeit(...) # or t.repeat(...) + except: + t.print_exc() + The advantage over the standard traceback is that source lines in the compiled + template will be displayed. The optional *file* argument directs where the + traceback is sent; it defaults to ``sys.stderr``. -.. function:: timeit(stmt='pass', setup='pass', timer=, number=1000000) - Create a :class:`Timer` instance with the given statement, *setup* code and - *timer* function and run its :meth:`.timeit` method with *number* executions. +.. method:: Timer.repeat([repeat=3 [, number=1000000]]) + + Call :meth:`timeit` a few times. + + This is a convenience function that calls the :meth:`timeit` repeatedly, + returning a list of results. The first argument specifies how many times to + call :meth:`timeit`. The second argument specifies the *number* argument for + :func:`timeit`. + + .. note:: + + It's tempting to calculate mean and standard deviation from the result vector + and report these. However, this is not very useful. In a typical case, the + lowest value gives a lower bound for how fast your machine can run the given + code snippet; higher values in the result vector are typically not caused by + variability in Python's speed, but by other processes interfering with your + timing accuracy. So the :func:`min` of the result is probably the only number + you should be interested in. After that, you should look at the entire vector + and apply common sense rather than statistics. + + +.. method:: Timer.timeit([number=1000000]) + + Time *number* executions of the main statement. This executes the setup + statement once, and then returns the time it takes to execute the main statement + a number of times, measured in seconds as a float. The argument is the number + of times through the loop, defaulting to one million. The main statement, the + setup statement and the timer function to be used are passed to the constructor. + + .. note:: + + By default, :meth:`timeit` temporarily turns off :term:`garbage collection` + during the timing. The advantage of this approach is that it makes + independent timings more comparable. This disadvantage is that GC may be + an important component of the performance of the function being measured. + If so, GC can be re-enabled as the first statement in the *setup* string. + For example:: + + timeit.Timer('for i in xrange(10): oct(i)', 'gc.enable()').timeit() + +Starting with version 2.6, the module also defines two convenience functions: + + +.. function:: repeat(stmt[, setup[, timer[, repeat=3 [, number=1000000]]]]) + + Create a :class:`Timer` instance with the given statement, setup code and timer + function and run its :meth:`repeat` method with the given repeat count and + *number* executions. .. versionadded:: 2.6 -.. function:: repeat(stmt='pass', setup='pass', timer=, repeat=3, number=1000000) +.. function:: timeit(stmt[, setup[, timer[, number=1000000]]]) - Create a :class:`Timer` instance with the given statement, *setup* code and - *timer* function and run its :meth:`.repeat` method with the given *repeat* - count and *number* executions. + Create a :class:`Timer` instance with the given statement, setup code and timer + function and run its :meth:`timeit` method with *number* executions. .. versionadded:: 2.6 -.. function:: default_timer() - - Define a default timer, in a platform-specific manner. On Windows, - :func:`time.clock` has microsecond granularity, but :func:`time.time`'s - granularity is 1/60th of a second. On Unix, :func:`time.clock` has 1/100th of - a second granularity, and :func:`time.time` is much more precise. On either - platform, :func:`default_timer` measures wall clock time, not the CPU - time. This means that other processes running on the same computer may - interfere with the timing. - - -.. class:: Timer(stmt='pass', setup='pass', timer=) - - Class for timing execution speed of small code snippets. - - The constructor takes a statement to be timed, an additional statement used - for setup, and a timer function. Both statements default to ``'pass'``; - the timer function is platform-dependent (see the module doc string). - *stmt* and *setup* may also contain multiple statements separated by ``;`` - or newlines, as long as they don't contain multi-line string literals. - - To measure the execution time of the first statement, use the :meth:`.timeit` - method. The :meth:`.repeat` method is a convenience to call :meth:`.timeit` - multiple times and return a list of results. - - .. versionchanged:: 2.6 - The *stmt* and *setup* parameters can now also take objects that are - callable without arguments. This will embed calls to them in a timer - function that will then be executed by :meth:`.timeit`. Note that the - timing overhead is a little larger in this case because of the extra - function calls. - - - .. method:: Timer.timeit(number=1000000) - - Time *number* executions of the main statement. This executes the setup - statement once, and then returns the time it takes to execute the main - statement a number of times, measured in seconds as a float. - The argument is the number of times through the loop, defaulting to one - million. The main statement, the setup statement and the timer function - to be used are passed to the constructor. - - .. note:: - - By default, :meth:`.timeit` temporarily turns off :term:`garbage - collection` during the timing. The advantage of this approach is that - it makes independent timings more comparable. This disadvantage is - that GC may be an important component of the performance of the - function being measured. If so, GC can be re-enabled as the first - statement in the *setup* string. For example:: - - timeit.Timer('for i in xrange(10): oct(i)', 'gc.enable()').timeit() - - - .. method:: Timer.repeat(repeat=3, number=1000000) - - Call :meth:`.timeit` a few times. - - This is a convenience function that calls the :meth:`.timeit` repeatedly, - returning a list of results. The first argument specifies how many times - to call :meth:`.timeit`. The second argument specifies the *number* - argument for :meth:`.timeit`. - - .. note:: - - It's tempting to calculate mean and standard deviation from the result - vector and report these. However, this is not very useful. - In a typical case, the lowest value gives a lower bound for how fast - your machine can run the given code snippet; higher values in the - result vector are typically not caused by variability in Python's - speed, but by other processes interfering with your timing accuracy. - So the :func:`min` of the result is probably the only number you - should be interested in. After that, you should look at the entire - vector and apply common sense rather than statistics. - - - .. method:: Timer.print_exc(file=None) - - Helper to print a traceback from the timed code. - - Typical use:: - - t = Timer(...) # outside the try/except - try: - t.timeit(...) # or t.repeat(...) - except: - t.print_exc() - - The advantage over the standard traceback is that source lines in the - compiled template will be displayed. The optional *file* argument directs - where the traceback is sent; it defaults to :data:`sys.stderr`. - - -.. _command-line-interface: - -Command-Line Interface +Command Line Interface ---------------------- When called as a program from the command line, the following form is used:: @@ -219,9 +168,13 @@ If :option:`-n` is not given, a suitable number of loops is calculated by trying successive powers of 10 until the total time is at least 0.2 seconds. -:func:`default_timer` measurations can be affected by other programs running on -the same machine, so -the best thing to do when accurate timing is necessary is to repeat +The default timer function is platform dependent. On Windows, +:func:`time.clock` has microsecond granularity but :func:`time.time`'s +granularity is 1/60th of a second; on Unix, :func:`time.clock` has 1/100th of a +second granularity and :func:`time.time` is much more precise. On either +platform, the default timer functions measure wall clock time, not the CPU time. +This means that other processes running on the same computer may interfere with +the timing. The best thing to do when accurate timing is necessary is to repeat the timing a few times and use the best time. The :option:`-r` option is good for this; the default of 3 repetitions is probably enough in most cases. On Unix, you can use :func:`time.clock` to measure CPU time. @@ -230,55 +183,25 @@ There is a certain baseline overhead associated with executing a pass statement. The code here doesn't try to hide it, but you should be aware of it. The - baseline overhead can be measured by invoking the program without arguments, and - it might differ between Python versions. Also, to fairly compare older Python - versions to Python 2.3, you may want to use Python's :option:`-O` option for - the older versions to avoid timing ``SET_LINENO`` instructions. + baseline overhead can be measured by invoking the program without arguments. +The baseline overhead differs between Python versions! Also, to fairly compare +older Python versions to Python 2.3, you may want to use Python's :option:`-O` +option for the older versions to avoid timing ``SET_LINENO`` instructions. -.. _timeit-examples: Examples -------- -It is possible to provide a setup statement that is executed only once at the beginning: - -.. code-block:: sh - - $ python -m timeit -s 'text = "sample string"; char = "g"' 'char in text' - 10000000 loops, best of 3: 0.0877 usec per loop - $ python -m timeit -s 'text = "sample string"; char = "g"' 'text.find(char)' - 1000000 loops, best of 3: 0.342 usec per loop - -:: - - >>> import timeit - >>> timeit.timeit('char in text', setup='text = "sample string"; char = "g"') - 0.41440500499993504 - >>> timeit.timeit('text.find(char)', setup='text = "sample string"; char = "g"') - 1.7246671520006203 - -The same can be done using the :class:`Timer` class and its methods:: - - >>> import timeit - >>> t = timeit.Timer('char in text', setup='text = "sample string"; char = "g"') - >>> t.timeit() - 0.3955516149999312 - >>> t.repeat() - [0.40193588800002544, 0.3960157959998014, 0.39594301399984033] - - -The following examples show how to time expressions that contain multiple lines. -Here we compare the cost of using :func:`hasattr` vs. :keyword:`try`/:keyword:`except` -to test for missing and present object attributes: - -.. code-block:: sh +Here are two example sessions (one using the command line, one using the module +interface) that compare the cost of using :func:`hasattr` vs. +:keyword:`try`/:keyword:`except` to test for missing and present object +attributes. :: $ python -m timeit 'try:' ' str.__nonzero__' 'except AttributeError:' ' pass' 100000 loops, best of 3: 15.7 usec per loop $ python -m timeit 'if hasattr(str, "__nonzero__"): pass' 100000 loops, best of 3: 4.26 usec per loop - $ python -m timeit 'try:' ' int.__nonzero__' 'except AttributeError:' ' pass' 1000000 loops, best of 3: 1.43 usec per loop $ python -m timeit 'if hasattr(int, "__nonzero__"): pass' @@ -287,34 +210,39 @@ :: >>> import timeit - >>> # attribute is missing >>> s = """\ ... try: ... str.__nonzero__ ... except AttributeError: ... pass ... """ - >>> timeit.timeit(stmt=s, number=100000) - 0.9138244460009446 - >>> s = "if hasattr(str, '__bool__'): pass" - >>> timeit.timeit(stmt=s, number=100000) - 0.5829014980008651 - >>> - >>> # attribute is present + >>> t = timeit.Timer(stmt=s) + >>> print "%.2f usec/pass" % (1000000 * t.timeit(number=100000)/100000) + 17.09 usec/pass + >>> s = """\ + ... if hasattr(str, '__nonzero__'): pass + ... """ + >>> t = timeit.Timer(stmt=s) + >>> print "%.2f usec/pass" % (1000000 * t.timeit(number=100000)/100000) + 4.85 usec/pass >>> s = """\ ... try: ... int.__nonzero__ ... except AttributeError: ... pass ... """ - >>> timeit.timeit(stmt=s, number=100000) - 0.04215312199994514 - >>> s = "if hasattr(int, '__bool__'): pass" - >>> timeit.timeit(stmt=s, number=100000) - 0.08588060699912603 + >>> t = timeit.Timer(stmt=s) + >>> print "%.2f usec/pass" % (1000000 * t.timeit(number=100000)/100000) + 1.97 usec/pass + >>> s = """\ + ... if hasattr(int, '__nonzero__'): pass + ... """ + >>> t = timeit.Timer(stmt=s) + >>> print "%.2f usec/pass" % (1000000 * t.timeit(number=100000)/100000) + 3.15 usec/pass To give the :mod:`timeit` module access to functions you define, you can pass a -*setup* parameter which contains an import statement:: +``setup`` parameter which contains an import statement:: def test(): """Stupid test function""" @@ -323,5 +251,7 @@ L.append(i) if __name__ == '__main__': - import timeit - print(timeit.timeit("test()", setup="from __main__ import test")) + from timeit import Timer + t = Timer("test()", "from __main__ import test") + print t.timeit() + diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/library/tix.rst --- a/Doc/library/tix.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/library/tix.rst Sun Jul 20 10:52:46 2014 -0400 @@ -24,9 +24,9 @@ .. note:: - :mod:`Tix` has been renamed to :mod:`tkinter.tix` in Python 3. The + :mod:`Tix` has been renamed to :mod:`tkinter.tix` in Python 3.0. The :term:`2to3` tool will automatically adapt imports when converting your - sources to Python 3. + sources to 3.0. .. seealso:: @@ -514,7 +514,7 @@ print root.tix_configure() -.. method:: tixCommand.tix_configure(cnf=None **kw) +.. method:: tixCommand.tix_configure([cnf,] **kw) Query or modify the configuration options of the Tix application context. If no option is specified, returns a dictionary all of the available options. If diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/library/tkinter.rst --- a/Doc/library/tkinter.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/library/tkinter.rst Sun Jul 20 10:52:46 2014 -0400 @@ -13,34 +13,22 @@ .. note:: - :mod:`Tkinter` has been renamed to :mod:`tkinter` in Python 3. The + :mod:`Tkinter` has been renamed to :mod:`tkinter` in Python 3.0. The :term:`2to3` tool will automatically adapt imports when converting your - sources to Python 3. + sources to 3.0. .. seealso:: - `Python Tkinter Resources `_ + `Python Tkinter Resources `_ The Python Tkinter Topic Guide provides a great deal of information on using Tk from Python and links to other sources of information on Tk. - `TKDocs `_ - Extensive tutorial plus friendlier widget pages for some of the widgets. + `An Introduction to Tkinter `_ + Fredrik Lundh's on-line reference material. - `Tkinter reference: a GUI for Python `_ + `Tkinter reference: a GUI for Python `_ On-line reference material. - `Tkinter docs from effbot `_ - Online reference for tkinter supported by effbot.org. - - `Tcl/Tk manual `_ - Official manual for the latest tcl/tk version. - - `Programming Python `_ - Book by Mark Lutz, has excellent coverage of Tkinter. - - `Modern Tkinter for Busy Python Developers `_ - Book by Mark Rozerman about building attractive and modern graphical user interfaces with Python and Tkinter. - `Python and Tkinter Programming `_ The book by John Grayson (ISBN 1-884777-81-3). @@ -121,7 +109,7 @@ :mod:`turtle` Turtle graphics in a Tk window. -These have been renamed as well in Python 3; they were all made submodules of +These have been renamed as well in Python 3.0; they were all made submodules of the new ``tkinter`` package. @@ -188,7 +176,7 @@ The Tk/Tcl development is largely taking place at ActiveState. `Tcl and the Tk Toolkit `_ - The book by John Ousterhout, the inventor of Tcl. + The book by John Ousterhout, the inventor of Tcl . `Practical Programming in Tcl and Tk `_ Brent Welch's encyclopedic book. @@ -452,7 +440,7 @@ Example:: >>> print fred.config() - {'relief': ('relief', 'relief', 'Relief', 'raised', 'groove')} + {'relief' : ('relief', 'relief', 'Relief', 'raised', 'groove')} Of course, the dictionary printed will include all the options available and their values. This is meant only as an example. @@ -625,7 +613,7 @@ preceded with an ``@``, as in ``"@/usr/contrib/bitmap/gumby.bit"``. boolean - You can pass integers 0 or 1 or the strings ``"yes"`` or ``"no"``. + You can pass integers 0 or 1 or the strings ``"yes"`` or ``"no"`` . callback This is any Python function that takes no arguments. For example:: diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/library/tokenize.rst --- a/Doc/library/tokenize.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/library/tokenize.rst Sun Jul 20 10:52:46 2014 -0400 @@ -15,13 +15,6 @@ well, making it useful for implementing "pretty-printers," including colorizers for on-screen displays. -To simplify token stream handling, all :ref:`operators` and :ref:`delimiters` -tokens are returned using the generic :data:`token.OP` token type. The exact -type can be determined by checking the second field (containing the actual -token string matched) of the tuple returned from -:func:`tokenize.generate_tokens` for the character sequence that identifies a -specific operator token. - The primary entry point is a :term:`generator`: .. function:: generate_tokens(readline) @@ -30,8 +23,7 @@ which must be a callable object which provides the same interface as the :meth:`readline` method of built-in file objects (see section :ref:`bltin-file-objects`). Each call to the function should return one line - of input as a string. Alternately, *readline* may be a callable object that - signals completion by raising :exc:`StopIteration`. + of input as a string. The generator produces 5-tuples with these members: the token type; the token string; a 2-tuple ``(srow, scol)`` of ints specifying the row and column @@ -98,24 +90,6 @@ .. versionadded:: 2.5 -.. exception:: TokenError - - Raised when either a docstring or expression that may be split over several - lines is not completed anywhere in the file, for example:: - - """Beginning of - docstring - - or:: - - [1, - 2, - 3 - -Note that unclosed single-quoted strings do not cause an error to be -raised. They are tokenized as ``ERRORTOKEN``, followed by the tokenization of -their contents. - Example of a script re-writer that transforms float literals into Decimal objects:: diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/library/trace.rst --- a/Doc/library/trace.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/library/trace.rst Sun Jul 20 10:52:46 2014 -0400 @@ -41,8 +41,8 @@ At least one of the following options must be specified when invoking :mod:`trace`. The :option:`--listfuncs <-l>` option is mutually exclusive with -the :option:`--trace <-t>` and :option:`--count <-c>` options. When -:option:`--listfuncs <-l>` is provided, neither :option:`--count <-c>` nor +the :option:`--trace <-t>` and :option:`--counts <-c>` options . When +:option:`--listfuncs <-l>` is provided, neither :option:`--counts <-c>` nor :option:`--trace <-t>` are accepted, and vice versa. .. program:: trace @@ -149,7 +149,7 @@ the current tracing parameters. *cmd* must be a string or code object, suitable for passing into :func:`exec`. - .. method:: runctx(cmd, globals=None, locals=None) + .. method:: runctx(cmd[, globals=None[, locals=None]]) Execute the command and gather statistics from the execution with the current tracing parameters, in the defined global and local @@ -200,7 +200,7 @@ # run the new command using the given tracer tracer.run('main()') - # make a report, placing output in the current directory + # make a report, placing output in /tmp r = tracer.results() - r.write_results(show_missing=True, coverdir=".") + r.write_results(show_missing=True, coverdir="/tmp") diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/library/traceback.rst --- a/Doc/library/traceback.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/library/traceback.rst Sun Jul 20 10:52:46 2014 -0400 @@ -75,7 +75,7 @@ Return a list of up to *limit* "pre-processed" stack trace entries extracted from the traceback object *traceback*. It is useful for alternate formatting of stack traces. If *limit* is omitted or ``None``, all entries are extracted. A - "pre-processed" stack trace entry is a 4-tuple (*filename*, *line number*, + "pre-processed" stack trace entry is a quadruple (*filename*, *line number*, *function name*, *text*) representing the information that is usually printed for a stack trace. The *text* is a string with leading and trailing whitespace stripped; if the source is not available it is ``None``. diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/library/ttk.rst --- a/Doc/library/ttk.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/library/ttk.rst Sun Jul 20 10:52:46 2014 -0400 @@ -265,10 +265,10 @@ *x* and *y* are pixel coordinates relative to the widget. - .. method:: instate(statespec, callback=None, *args, **kw) + .. method:: instate(statespec[, callback=None[, *args[, **kw]]]) - Test the widget's state. If a callback is not specified, returns ``True`` - if the widget state matches *statespec* and ``False`` otherwise. If callback + Test the widget's state. If a callback is not specified, returns True + if the widget state matches *statespec* and False otherwise. If callback is specified then it is called with *args* if widget state matches *statespec*. @@ -523,7 +523,7 @@ omitted, returns the widget name of the currently selected pane. - .. method:: tab(tab_id, option=None, **kw) + .. method:: tab(tab_id[, option=None[, **kw]]) Query or modify the options of the specific *tab_id*. @@ -846,7 +846,7 @@ .. class:: Treeview - .. method:: bbox(item, column=None) + .. method:: bbox(item[, column=None]) Returns the bounding box (relative to the treeview widget's window) of the specified *item* in the form (x, y, width, height). @@ -873,7 +873,7 @@ *item*'s children. - .. method:: column(column, option=None, **kw) + .. method:: column(column[, option=None[, **kw]]) Query or modify the options for the specified *column*. @@ -919,7 +919,7 @@ .. method:: exists(item) - Returns ``True`` if the specified *item* is present in the tree. + Returns True if the specified *item* is present in the tree. .. method:: focus([item=None]) @@ -928,7 +928,7 @@ the current focus item, or '' if there is none. - .. method:: heading(column, option=None, **kw) + .. method:: heading(column[, option=None[, **kw]]) Query or modify the heading options for the specified *column*. @@ -1001,7 +1001,7 @@ Returns the integer index of *item* within its parent's list of children. - .. method:: insert(parent, index, iid=None, **kw) + .. method:: insert(parent, index[, iid=None[, **kw]]) Creates a new item and returns the item identifier of the newly created item. @@ -1065,7 +1065,7 @@ Ensure that *item* is visible. - Sets all of *item*'s ancestors open option to ``True``, and scrolls the + Sets all of *item*'s ancestors open option to True, and scrolls the widget if necessary so that *item* is within the visible portion of the tree. @@ -1096,7 +1096,7 @@ Toggle the selection state of each item in *items*. - .. method:: set(item, column=None, value=None) + .. method:: set(item[, column=None[, value=None]]) With one argument, returns a dictionary of column/value pairs for the specified *item*. With two arguments, returns the current value of the @@ -1104,14 +1104,14 @@ *column* in given *item* to the specified *value*. - .. method:: tag_bind(tagname, sequence=None, callback=None) + .. method:: tag_bind(tagname[, sequence=None[, callback=None]]) Bind a callback for the given event *sequence* to the tag *tagname*. When an event is delivered to an item, the callbacks for each of the item's tags option are called. - .. method:: tag_configure(tagname, option=None, **kw) + .. method:: tag_configure(tagname[, option=None[, **kw]]) Query or modify the options for the specified *tagname*. @@ -1220,7 +1220,7 @@ foreground option, for example, you would get a blue foreground when the widget is in the active or pressed states. - .. method:: lookup(style, option, state=None, default=None) + .. method:: lookup(style, option[, state=None[, default=None]]) Returns the value specified for *option* in *style*. @@ -1235,7 +1235,7 @@ print ttk.Style().lookup("TButton", "font") - .. method:: layout(style, layoutspec=None) + .. method:: layout(style[, layoutspec=None]) Define the widget layout for given *style*. If *layoutspec* is omitted, return the layout specification for given style. @@ -1294,7 +1294,7 @@ * sticky=spec Specifies how the image is placed within the final parcel. spec - contains zero or more characters "n", "s", "w", or "e". + contains zero or more characters “n”, “s”, “w”, or “e”. * width=width Specifies a minimum width for the element. If less than zero, the @@ -1318,7 +1318,7 @@ Returns the list of *elementname*'s options. - .. method:: theme_create(themename, parent=None, settings=None) + .. method:: theme_create(themename[, parent=None[, settings=None]]) Create a new theme. diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/library/turtle.rst --- a/Doc/library/turtle.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/library/turtle.rst Sun Jul 20 10:52:46 2014 -0400 @@ -1049,8 +1049,8 @@ Write text - the string representation of *arg* - at the current turtle position according to *align* ("left", "center" or right") and with the given - font. If *move* is true, the pen is moved to the bottom-right corner of the - text. By default, *move* is ``False``. + font. If *move* is True, the pen is moved to the bottom-right corner of the + text. By default, *move* is False. >>> turtle.write("Home = ", True, align="center") >>> turtle.write((0,0), True) @@ -1086,7 +1086,7 @@ .. function:: isvisible() - Return ``True`` if the Turtle is shown, ``False`` if it's hidden. + Return True if the Turtle is shown, False if it's hidden. >>> turtle.hideturtle() >>> turtle.isvisible() @@ -1859,7 +1859,7 @@ :param startx: if positive, starting position in pixels from the left edge of the screen, if negative from the right edge, if None, center window horizontally - :param starty: if positive, starting position in pixels from the top + :param startx: if positive, starting position in pixels from the top edge of the screen, if negative from the bottom edge, if None, center window vertically @@ -2173,11 +2173,9 @@ The demoscripts are: -.. tabularcolumns:: |l|L|L| - +----------------+------------------------------+-----------------------+ | Name | Description | Features | -+================+==============================+=======================+ ++----------------+------------------------------+-----------------------+ | bytedesign | complex classical | :func:`tracer`, delay,| | | turtlegraphics pattern | :func:`update` | +----------------+------------------------------+-----------------------+ diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/library/unicodedata.rst --- a/Doc/library/unicodedata.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/library/unicodedata.rst Sun Jul 20 10:52:46 2014 -0400 @@ -66,7 +66,7 @@ .. function:: bidirectional(unichr) - Returns the bidirectional class assigned to the Unicode character *unichr* as + Returns the bidirectional category assigned to the Unicode character *unichr* as string. If no such value is defined, an empty string is returned. @@ -107,7 +107,7 @@ based on the definition of canonical equivalence and compatibility equivalence. In Unicode, several characters can be expressed in various way. For example, the character U+00C7 (LATIN CAPITAL LETTER C WITH CEDILLA) can also be expressed as - the sequence U+0043 (LATIN CAPITAL LETTER C) U+0327 (COMBINING CEDILLA). + the sequence U+0327 (COMBINING CEDILLA) U+0043 (LATIN CAPITAL LETTER C). For each character, there are two normal forms: normal form C and normal form D. Normal form D (NFD) is also known as canonical decomposition, and translates diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/library/unittest.rst --- a/Doc/library/unittest.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/library/unittest.rst Sun Jul 20 10:52:46 2014 -0400 @@ -91,7 +91,7 @@ Third-party unittest frameworks with a lighter-weight syntax for writing tests. For example, ``assert func(10) == 42``. - `The Python Testing Tools Taxonomy `_ + `The Python Testing Tools Taxonomy `_ An extensive list of Python testing tools including functional testing frameworks and mock object libraries. @@ -279,15 +279,15 @@ Verbose output -.. cmdoption:: -s, --start-directory directory - - Directory to start discovery (``.`` default) - -.. cmdoption:: -p, --pattern pattern - - Pattern to match test files (``test*.py`` default) - -.. cmdoption:: -t, --top-level-directory directory +.. cmdoption:: -s directory + + Directory to start discovery ('.' default) + +.. cmdoption:: -p pattern + + Pattern to match test files ('test*.py' default) + +.. cmdoption:: -t directory Top level directory of project (defaults to start directory) @@ -352,7 +352,7 @@ widget = Widget('The widget') self.assertEqual(widget.size(), (50, 50), 'incorrect default size') -Note that in order to test something, we use one of the :meth:`assert\*` +Note that in order to test something, we use the one of the :meth:`assert\*` methods provided by the :class:`TestCase` base class. If the test fails, an exception will be raised, and :mod:`unittest` will identify the test case as a :dfn:`failure`. Any other exceptions will be treated as :dfn:`errors`. This @@ -584,7 +584,7 @@ Skipping a test is simply a matter of using the :func:`skip` :term:`decorator` or one of its conditional variants. -Basic skipping looks like this:: +Basic skipping looks like this: :: class MyTestCase(unittest.TestCase): @@ -603,7 +603,7 @@ # windows specific testing code pass -This is the output of running the example above in verbose mode:: +This is the output of running the example above in verbose mode: :: test_format (__main__.MyTestCase) ... skipped 'not supported in this library version' test_nothing (__main__.MyTestCase) ... skipped 'demonstrating skipping' @@ -614,9 +614,9 @@ OK (skipped=3) -Classes can be skipped just like methods:: - - @unittest.skip("showing class skipping") +Classes can be skipped just like methods: :: + + @skip("showing class skipping") class MySkippedTestCase(unittest.TestCase): def test_not_run(self): pass @@ -633,12 +633,12 @@ It's easy to roll your own skipping decorators by making a decorator that calls :func:`skip` on the test when it wants it to be skipped. This decorator skips -the test unless the passed object has a certain attribute:: +the test unless the passed object has a certain attribute: :: def skipUnlessHasattr(obj, attr): if hasattr(obj, attr): return lambda func: func - return unittest.skip("{!r} doesn't have {!r}".format(obj, attr)) + return unittest.skip("{0!r} doesn't have {1!r}".format(obj, attr)) The following decorators implement test skipping and expected failures: @@ -660,13 +660,6 @@ Mark the test as an expected failure. If the test fails when run, the test is not counted as a failure. -.. exception:: SkipTest(reason) - - This exception is raised to skip a test. - - Usually you can use :meth:`TestCase.skipTest` or one of the skipping - decorators instead of raising this directly. - Skipped tests will not have :meth:`setUp` or :meth:`tearDown` run around them. Skipped classes will not have :meth:`setUpClass` or :meth:`tearDownClass` run. @@ -719,9 +712,9 @@ .. method:: setUp() Method called to prepare the test fixture. This is called immediately - before calling the test method; other than :exc:`AssertionError` or :exc:`SkipTest`, - any exception raised by this method will be considered an error rather than - a test failure. The default implementation does nothing. + before calling the test method; any exception raised by this method will + be considered an error rather than a test failure. The default + implementation does nothing. .. method:: tearDown() @@ -729,10 +722,10 @@ Method called immediately after the test method has been called and the result recorded. This is called even if the test method raised an exception, so the implementation in subclasses may need to be particularly - careful about checking internal state. Any exception, other than :exc:`AssertionError` - or :exc:`SkipTest`, raised by this method will be considered an error rather than a - test failure. This method will only be called if the :meth:`setUp` succeeds, - regardless of the outcome of the test method. The default implementation does nothing. + careful about checking internal state. Any exception raised by this + method will be considered an error rather than a test failure. This + method will only be called if the :meth:`setUp` succeeds, regardless of + the outcome of the test method. The default implementation does nothing. .. method:: setUpClass() @@ -847,13 +840,13 @@ In addition, if *first* and *second* are the exact same type and one of list, tuple, dict, set, frozenset or unicode or any type that a subclass - registers with :meth:`addTypeEqualityFunc` the type-specific equality + registers with :meth:`addTypeEqualityFunc` the type specific equality function will be called in order to generate a more useful default error message (see also the :ref:`list of type-specific methods `). .. versionchanged:: 2.7 - Added the automatic calling of type-specific equality function. + Added the automatic calling of type specific equality function. .. method:: assertNotEqual(first, second, msg=None) @@ -902,7 +895,8 @@ Test that *obj* is (or is not) an instance of *cls* (which can be a class or a tuple of classes, as supported by :func:`isinstance`). - To check for the exact type, use :func:`assertIs(type(obj), cls) `. + To check for a specific type (without including superclasses) use + :func:`assertIs(type(obj), cls) `. .. versionadded:: 2.7 @@ -916,8 +910,8 @@ | :meth:`assertRaises(exc, fun, *args, **kwds) | ``fun(*args, **kwds)`` raises *exc* | | | ` | | | +---------------------------------------------------------+--------------------------------------+------------+ - | :meth:`assertRaisesRegexp(exc, r, fun, *args, **kwds) | ``fun(*args, **kwds)`` raises *exc* | 2.7 | - | ` | and the message matches regex *r* | | + | :meth:`assertRaisesRegexp(exc, re, fun, *args, **kwds) | ``fun(*args, **kwds)`` raises *exc* | 2.7 | + | ` | and the message matches *re* | | +---------------------------------------------------------+--------------------------------------+------------+ .. method:: assertRaises(exception, callable, *args, **kwds) @@ -958,7 +952,7 @@ a regular expression object or a string containing a regular expression suitable for use by :func:`re.search`. Examples:: - self.assertRaisesRegexp(ValueError, "invalid literal for.*XYZ'$", + self.assertRaisesRegexp(ValueError, 'invalid literal for.*XYZ$', int, 'XYZ') or:: @@ -993,10 +987,10 @@ | :meth:`assertLessEqual(a, b) | ``a <= b`` | 2.7 | | ` | | | +---------------------------------------+--------------------------------+--------------+ - | :meth:`assertRegexpMatches(s, r) | ``r.search(s)`` | 2.7 | + | :meth:`assertRegexpMatches(s, re) | ``regex.search(s)`` | 2.7 | | ` | | | +---------------------------------------+--------------------------------+--------------+ - | :meth:`assertNotRegexpMatches(s, r) | ``not r.search(s)`` | 2.7 | + | :meth:`assertNotRegexpMatches(s, re) | ``not regex.search(s)`` | 2.7 | | ` | | | +---------------------------------------+--------------------------------+--------------+ | :meth:`assertItemsEqual(a, b) | sorted(a) == sorted(b) and | 2.7 | @@ -1017,7 +1011,7 @@ like the :func:`round` function) and not *significant digits*. If *delta* is supplied instead of *places* then the difference - between *first* and *second* must be less or equal to (or greater than) *delta*. + between *first* and *second* must be less (or more) than *delta*. Supplying both *delta* and *places* raises a ``TypeError``. @@ -1075,8 +1069,6 @@ sorted(actual))`` but it works with sequences of unhashable objects as well. - In Python 3, this method is named ``assertCountEqual``. - .. versionadded:: 2.7 @@ -1166,7 +1158,7 @@ .. method:: assertListEqual(list1, list2, msg=None) assertTupleEqual(tuple1, tuple2, msg=None) - Tests that two lists or tuples are equal. If not, an error message is + Tests that two lists or tuples are equal. If not an error message is constructed that shows only the differences between the two. An error is also raised if either of the parameters are of the wrong type. These methods are used by default when comparing lists or tuples with @@ -1435,8 +1427,8 @@ The :class:`TestLoader` class is used to create test suites from classes and modules. Normally, there is no need to create an instance of this class; the :mod:`unittest` module provides an instance that can be shared as - :data:`unittest.defaultTestLoader`. Using a subclass or instance, however, - allows customization of some configurable properties. + ``unittest.defaultTestLoader``. Using a subclass or instance, however, allows + customization of some configurable properties. :class:`TestLoader` objects have the following methods: @@ -1510,11 +1502,11 @@ .. method:: discover(start_dir, pattern='test*.py', top_level_dir=None) - Find all the test modules by recursing into subdirectories from the - specified start directory, and return a TestSuite object containing them. - Only test files that match *pattern* will be loaded. (Using shell style - pattern matching.) Only module names that are importable (i.e. are valid - Python identifiers) will be loaded. + Find and return all test modules from the specified start directory, + recursing into subdirectories to find them. Only test files that match + *pattern* will be loaded. (Using shell style pattern matching.) Only + module names that are importable (i.e. are valid Python identifiers) will + be loaded. All test modules must be importable from the top level of the project. If the start directory is not the top level directory then the top level @@ -1603,7 +1595,8 @@ A list containing 2-tuples of :class:`TestCase` instances and strings holding formatted tracebacks. Each tuple represents a test where a failure - was explicitly signalled using the :meth:`TestCase.assert\*` methods. + was explicitly signalled using the :meth:`TestCase.fail\*` or + :meth:`TestCase.assert\*` methods. .. versionchanged:: 2.2 Contains formatted tracebacks instead of :func:`sys.exc_info` results. @@ -1687,14 +1680,14 @@ Called after the test case *test* has been executed, regardless of the outcome. - .. method:: startTestRun() + .. method:: startTestRun(test) Called once before any tests are executed. .. versionadded:: 2.7 - .. method:: stopTestRun() + .. method:: stopTestRun(test) Called once after all tests are executed. @@ -1703,7 +1696,7 @@ .. method:: addError(test, err) - Called when the test case *test* raises an unexpected exception. *err* is a + Called when the test case *test* raises an unexpected exception *err* is a tuple of the form returned by :func:`sys.exc_info`: ``(type, value, traceback)``. @@ -1792,12 +1785,11 @@ stream, descriptions, verbosity -.. function:: main([module[, defaultTest[, argv[, testRunner[, testLoader[, exit[, verbosity[, failfast[, catchbreak[, buffer]]]]]]]]]]) - - A command-line program that loads a set of tests from *module* and runs them; - this is primarily for making test modules conveniently executable. - The simplest use for this function is to include the following line at the - end of a test script:: +.. function:: main([module[, defaultTest[, argv[, testRunner[, testLoader[, exit[, verbosity[, failfast[, catchbreak[,buffer]]]]]]]]]]) + + A command-line program that runs a set of tests; this is primarily for making + test modules conveniently executable. The simplest use for this function is to + include the following line at the end of a test script:: if __name__ == '__main__': unittest.main() @@ -1808,21 +1800,10 @@ if __name__ == '__main__': unittest.main(verbosity=2) - The *defaultTest* argument is the name of the test to run if no test names - are specified via *argv*. If not specified or ``None`` and no test names are - provided via *argv*, all tests found in *module* are run. - - The *argv* argument can be a list of options passed to the program, with the - first element being the program name. If not specified or ``None``, - the values of :data:`sys.argv` are used. - The *testRunner* argument can either be a test runner class or an already created instance of it. By default ``main`` calls :func:`sys.exit` with an exit code indicating success or failure of the tests run. - The *testLoader* argument has to be a :class:`TestLoader` instance, - and defaults to :data:`defaultTestLoader`. - ``main`` supports being used from the interactive interpreter by passing in the argument ``exit=False``. This displays the result on standard output without calling :func:`sys.exit`:: @@ -1830,14 +1811,14 @@ >>> from unittest import main >>> main(module='test_module', exit=False) - The *failfast*, *catchbreak* and *buffer* parameters have the same + The ``failfast``, ``catchbreak`` and ``buffer`` parameters have the same effect as the same-name `command-line options`_. Calling ``main`` actually returns an instance of the ``TestProgram`` class. This stores the result of the tests run as the ``result`` attribute. .. versionchanged:: 2.7 - The *exit*, *verbosity*, *failfast*, *catchbreak* and *buffer* + The ``exit``, ``verbosity``, ``failfast``, ``catchbreak`` and ``buffer`` parameters were added. @@ -1880,10 +1861,10 @@ .. note:: - The default pattern is ``'test*.py'``. This matches all Python files - that start with ``'test'`` but *won't* match any test directories. - - A pattern like ``'test*'`` will match test packages as well as + The default pattern is 'test*.py'. This matches all Python files + that start with 'test' but *won't* match any test directories. + + A pattern like 'test*' will match test packages as well as modules. If the package :file:`__init__.py` defines ``load_tests`` then it will be @@ -1968,7 +1949,7 @@ If an exception is raised during a ``setUpClass`` then the tests in the class are not run and the ``tearDownClass`` is not run. Skipped classes will not have ``setUpClass`` or ``tearDownClass`` run. If the exception is a -:exc:`SkipTest` exception then the class will be reported as having been skipped +``SkipTest`` exception then the class will be reported as having been skipped instead of as an error. @@ -1985,7 +1966,7 @@ If an exception is raised in a ``setUpModule`` then none of the tests in the module will be run and the ``tearDownModule`` will not be run. If the exception is a -:exc:`SkipTest` exception then the module will be reported as having been skipped +``SkipTest`` exception then the module will be reported as having been skipped instead of as an error. diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/library/urllib.rst --- a/Doc/library/urllib.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/library/urllib.rst Sun Jul 20 10:52:46 2014 -0400 @@ -6,12 +6,11 @@ .. note:: The :mod:`urllib` module has been split into parts and renamed in - Python 3 to :mod:`urllib.request`, :mod:`urllib.parse`, + Python 3.0 to :mod:`urllib.request`, :mod:`urllib.parse`, and :mod:`urllib.error`. The :term:`2to3` tool will automatically adapt - imports when converting your sources to Python 3. - Also note that the :func:`urllib.request.urlopen` function in Python 3 is - equivalent to :func:`urllib2.urlopen` and that :func:`urllib.urlopen` has - been removed. + imports when converting your sources to 3.0. + Also note that the :func:`urllib.urlopen` function has been removed in + Python 3.0 in favor of :func:`urllib2.urlopen`. .. index:: single: WWW @@ -33,17 +32,16 @@ .. function:: urlopen(url[, data[, proxies]]) - Open a network object denoted by a URL for reading. If the URL does not - have a scheme identifier, or if it has :file:`file:` as its scheme - identifier, this opens a local file (without :term:`universal newlines`); - otherwise it opens a socket to a server somewhere on the network. If the - connection cannot be made the :exc:`IOError` exception is raised. If all - went well, a file-like object is returned. This supports the following - methods: :meth:`read`, :meth:`readline`, :meth:`readlines`, :meth:`fileno`, - :meth:`close`, :meth:`info`, :meth:`getcode` and :meth:`geturl`. It also - has proper support for the :term:`iterator` protocol. One caveat: the - :meth:`read` method, if the size argument is omitted or negative, may not - read until the end of the data stream; there is no good way to determine + Open a network object denoted by a URL for reading. If the URL does not have a + scheme identifier, or if it has :file:`file:` as its scheme identifier, this + opens a local file (without universal newlines); otherwise it opens a socket to + a server somewhere on the network. If the connection cannot be made the + :exc:`IOError` exception is raised. If all went well, a file-like object is + returned. This supports the following methods: :meth:`read`, :meth:`readline`, + :meth:`readlines`, :meth:`fileno`, :meth:`close`, :meth:`info`, :meth:`getcode` and + :meth:`geturl`. It also has proper support for the :term:`iterator` protocol. One + caveat: the :meth:`read` method, if the size argument is omitted or negative, + may not read until the end of the data stream; there is no good way to determine that the entire stream from a socket has been read in the general case. Except for the :meth:`info`, :meth:`getcode` and :meth:`geturl` methods, @@ -133,7 +131,7 @@ :envvar:`no_proxy` environment variable. .. deprecated:: 2.6 - The :func:`urlopen` function has been removed in Python 3 in favor + The :func:`urlopen` function has been removed in Python 3.0 in favor of :func:`urllib2.urlopen`. @@ -276,17 +274,10 @@ .. function:: getproxies() This helper function returns a dictionary of scheme to proxy server URL - mappings. It scans the environment for variables named ``_proxy``, - in case insensitive way, for all operating systems first, and when it cannot - find it, looks for proxy information from Mac OSX System Configuration for - Mac OS X and Windows Systems Registry for Windows. - -.. note:: - urllib also exposes certain utility functions like splittype, splithost and - others parsing url into various components. But it is recommended to use - :mod:`urlparse` for parsing urls than using these functions directly. - Python 3 does not expose these helper functions from :mod:`urllib.parse` - module. + mappings. It scans the environment for variables named ``_proxy`` + for all operating systems first, and when it cannot find it, looks for proxy + information from Mac OSX System Configuration for Mac OS X and Windows + Systems Registry for Windows. URL Opener objects diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/library/urllib2.rst --- a/Doc/library/urllib2.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/library/urllib2.rst Sun Jul 20 10:52:46 2014 -0400 @@ -9,9 +9,9 @@ .. note:: The :mod:`urllib2` module has been split across several modules in - Python 3 named :mod:`urllib.request` and :mod:`urllib.error`. + Python 3.0 named :mod:`urllib.request` and :mod:`urllib.error`. The :term:`2to3` tool will automatically adapt imports when converting - your sources to Python 3. + your sources to 3.0. The :mod:`urllib2` module defines functions and classes which help in opening @@ -43,7 +43,7 @@ timeout setting will be used). This actually only works for HTTP, HTTPS and FTP connections. - This function returns a file-like object with three additional methods: + This function returns a file-like object with two additional methods: * :meth:`geturl` --- return the URL of the resource retrieved, commonly used to determine if a redirect was followed @@ -52,18 +52,14 @@ in the form of an :class:`mimetools.Message` instance (see `Quick Reference to HTTP Headers `_) - * :meth:`getcode` --- return the HTTP status code of the response. - Raises :exc:`URLError` on errors. Note that ``None`` may be returned if no handler handles the request (though the default installed global :class:`OpenerDirector` uses :class:`UnknownHandler` to ensure this never happens). - In addition, if proxy settings are detected (for example, when a ``*_proxy`` - environment variable like :envvar:`http_proxy` is set), - :class:`ProxyHandler` is default installed and makes sure the requests are - handled through the proxy. + In addition, default installed :class:`ProxyHandler` makes sure the requests + are handled through the proxy when they are set. .. versionchanged:: 2.6 *timeout* was added. @@ -85,8 +81,7 @@ subclasses of :class:`BaseHandler` (in which case it must be possible to call the constructor without any parameters). Instances of the following classes will be in front of the *handler*\s, unless the *handler*\s contain them, - instances of them or subclasses of them: :class:`ProxyHandler` (if proxy - settings are detected), + instances of them or subclasses of them: :class:`ProxyHandler`, :class:`UnknownHandler`, :class:`HTTPHandler`, :class:`HTTPDefaultErrorHandler`, :class:`HTTPRedirectHandler`, :class:`FTPHandler`, :class:`FileHandler`, :class:`HTTPErrorProcessor`. @@ -126,10 +121,7 @@ This numeric value corresponds to a value found in the dictionary of codes as found in :attr:`BaseHTTPServer.BaseHTTPRequestHandler.responses`. - .. attribute:: reason - The reason for this error. It can be a message string or another exception - instance. The following classes are provided: @@ -166,7 +158,7 @@ should be the request-host of the request for the page containing the image. *unverifiable* should indicate whether the request is unverifiable, as defined - by RFC 2965. It defaults to ``False``. An unverifiable request is one whose URL + by RFC 2965. It defaults to False. An unverifiable request is one whose URL the user did not have the option to approve. For example, if the request is for an image in an HTML document, and the user had no option to approve the automatic fetching of the image, this should be true. @@ -205,9 +197,9 @@ Cause requests to go through a proxy. If *proxies* is given, it must be a dictionary mapping protocol names to URLs of proxies. The default is to read the list of proxies from the environment variables - :envvar:`_proxy`. If no proxy environment variables are set, then - in a Windows environment proxy settings are obtained from the registry's - Internet Settings section, and in a Mac OS X environment proxy information + :envvar:`_proxy`. If no proxy environment variables are set, in a + Windows environment, proxy settings are obtained from the registry's + Internet Settings section and in a Mac OS X environment, proxy information is retrieved from the OS X System Configuration Framework. To disable autodetected proxy pass an empty dictionary. @@ -388,17 +380,6 @@ Return the selector --- the part of the URL that is sent to the server. -.. method:: Request.get_header(header_name, default=None) - - Return the value of the given header. If the header is not present, return - the default value. - - -.. method:: Request.header_items() - - Return a list of tuples (header_name, header_value) of the Request headers. - - .. method:: Request.set_proxy(host, type) Prepare the request by connecting to a proxy server. The *host* and *type* will diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/library/urlparse.rst --- a/Doc/library/urlparse.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/library/urlparse.rst Sun Jul 20 10:52:46 2014 -0400 @@ -13,9 +13,9 @@ pair: relative; URL .. note:: - The :mod:`urlparse` module is renamed to :mod:`urllib.parse` in Python 3. + The :mod:`urlparse` module is renamed to :mod:`urllib.parse` in Python 3.0. The :term:`2to3` tool will automatically adapt imports when converting - your sources to Python 3. + your sources to 3.0. **Source code:** :source:`Lib/urlparse.py` @@ -27,11 +27,11 @@ to an absolute URL given a "base URL." The module has been designed to match the Internet RFC on Relative Uniform -Resource Locators. It supports the following URL schemes: ``file``, ``ftp``, -``gopher``, ``hdl``, ``http``, ``https``, ``imap``, ``mailto``, ``mms``, -``news``, ``nntp``, ``prospero``, ``rsync``, ``rtsp``, ``rtspu``, ``sftp``, -``shttp``, ``sip``, ``sips``, ``snews``, ``svn``, ``svn+ssh``, ``telnet``, -``wais``. +Resource Locators (and discovered a bug in an earlier draft!). It supports the +following URL schemes: ``file``, ``ftp``, ``gopher``, ``hdl``, ``http``, +``https``, ``imap``, ``mailto``, ``mms``, ``news``, ``nntp``, ``prospero``, +``rsync``, ``rtsp``, ``rtspu``, ``sftp``, ``shttp``, ``sip``, ``sips``, +``snews``, ``svn``, ``svn+ssh``, ``telnet``, ``wais``. .. versionadded:: 2.5 Support for the ``sftp`` and ``sips`` schemes. @@ -71,8 +71,8 @@ >>> urlparse('//www.cwi.nl:80/%7Eguido/Python.html') ParseResult(scheme='', netloc='www.cwi.nl:80', path='/%7Eguido/Python.html', params='', query='', fragment='') - >>> urlparse('www.cwi.nl/%7Eguido/Python.html') - ParseResult(scheme='', netloc='', path='www.cwi.nl/%7Eguido/Python.html', + >>> urlparse('www.cwi.nl:80/%7Eguido/Python.html') + ParseResult(scheme='', netloc='', path='www.cwi.nl:80/%7Eguido/Python.html', params='', query='', fragment='') >>> urlparse('help/Python.html') ParseResult(scheme='', netloc='', path='help/Python.html', params='', diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/library/user.rst --- a/Doc/library/user.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/library/user.rst Sun Jul 20 10:52:46 2014 -0400 @@ -7,7 +7,7 @@ :deprecated: .. deprecated:: 2.6 - The :mod:`user` module has been removed in Python 3. + The :mod:`user` module has been removed in Python 3.0. .. index:: pair: .pythonrc.py; file diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/library/userdict.rst --- a/Doc/library/userdict.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/library/userdict.rst Sun Jul 20 10:52:46 2014 -0400 @@ -83,18 +83,9 @@ .. note:: - When Python 2.2 was released, many of the use cases for this class were - subsumed by the ability to subclass :class:`list` directly. However, a - handful of use cases remain. - - This module provides a list-interface around an underlying data store. By - default, that data store is a :class:`list`; however, it can be used to wrap - a list-like interface around other objects (such as persistent storage). - - In addition, this class can be mixed-in with built-in classes using multiple - inheritance. This can sometimes be useful. For example, you can inherit - from :class:`UserList` and :class:`str` at the same time. That would not be - possible with both a real :class:`list` and a real :class:`str`. + This module is available for backward compatibility only. If you are writing + code that does not need to work with versions of Python earlier than Python 2.2, + please consider subclassing directly from the built-in :class:`list` type. This module defines a class that acts as a wrapper around list objects. It is a useful base class for your own list-like classes, which can inherit from them @@ -114,8 +105,8 @@ .. note:: The :class:`UserList` class has been moved to the :mod:`collections` - module in Python 3. The :term:`2to3` tool will automatically adapt - imports when converting your sources to Python 3. + module in Python 3.0. The :term:`2to3` tool will automatically adapt + imports when converting your sources to 3.0. In addition to supporting the methods and operations of mutable sequences (see @@ -128,7 +119,7 @@ A real Python list object used to store the contents of the :class:`UserList` class. -**Subclassing requirements:** Subclasses of :class:`UserList` are expected to +**Subclassing requirements:** Subclasses of :class:`UserList` are expect to offer a constructor which can be called with either no arguments or one argument. List operations which return a new sequence attempt to create an instance of the actual implementation class. To do so, it assumes that the @@ -187,8 +178,8 @@ .. note:: The :class:`UserString` class has been moved to the :mod:`collections` - module in Python 3. The :term:`2to3` tool will automatically adapt - imports when converting your sources to Python 3. + module in Python 3.0. The :term:`2to3` tool will automatically adapt + imports when converting your sources to 3.0. @@ -203,7 +194,7 @@ hard to track down. .. deprecated:: 2.6 - The :class:`MutableString` class has been removed in Python 3. + The :class:`MutableString` class has been removed in Python 3.0. In addition to supporting the methods and operations of string and Unicode objects (see section :ref:`string-methods`), :class:`UserString` instances diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/library/warnings.rst --- a/Doc/library/warnings.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/library/warnings.rst Sun Jul 20 10:52:46 2014 -0400 @@ -19,7 +19,7 @@ might want to issue a warning when a program uses an obsolete module. Python programmers issue warnings by calling the :func:`warn` function defined -in this module. (C programmers use :c:func:`PyErr_WarnEx`; see +in this module. (C programmers use :cfunc:`PyErr_WarnEx`; see :ref:`exceptionhandling` for details). Warning messages are normally written to ``sys.stderr``, but their disposition @@ -57,8 +57,6 @@ This categorization is useful to be able to filter out groups of warnings. The following warnings category classes are currently defined: -.. tabularcolumns:: |l|p{0.6\linewidth}| - +----------------------------------+-----------------------------------------------+ | Class | Description | +==================================+===============================================+ @@ -169,8 +167,7 @@ the command-line options passed to :option:`-W` and calls to :func:`filterwarnings`. -* :exc:`DeprecationWarning` and :exc:`PendingDeprecationWarning`, and - :exc:`ImportWarning` are ignored. +* :exc:`PendingDeprecationWarning`, and :exc:`ImportWarning` are ignored. * :exc:`BytesWarning` is ignored unless the :option:`-b` option is given once or twice; in this case this warning is either printed (``-b``) or turned into an @@ -421,7 +418,7 @@ .. note:: - In Python 3, the arguments to the constructor for + In Python 3.0, the arguments to the constructor for :class:`catch_warnings` are keyword-only arguments. .. versionadded:: 2.6 diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/library/weakref.rst --- a/Doc/library/weakref.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/library/weakref.rst Sun Jul 20 10:52:46 2014 -0400 @@ -53,6 +53,12 @@ dictionary implementations is exposed by the :mod:`weakref` module for the benefit of advanced uses. +.. note:: + + Weak references to an object are cleared before the object's :meth:`__del__` + is called, to ensure that the weak reference callback (if any) finds the + object still alive. + Not all objects can be weakly referenced; those objects which can include class instances, functions written in Python (but not in C), methods (both bound and unbound), sets, frozensets, file objects, :term:`generator`\s, type objects, @@ -163,7 +169,7 @@ .. method:: WeakKeyDictionary.iterkeyrefs() - Return an iterable of the weak references to the keys. + Return an :term:`iterator` that yields the weak references to the keys. .. versionadded:: 2.5 @@ -195,7 +201,7 @@ .. method:: WeakValueDictionary.itervaluerefs() - Return an iterable of the weak references to the values. + Return an :term:`iterator` that yields the weak references to the values. .. versionadded:: 2.5 diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/library/webbrowser.rst --- a/Doc/library/webbrowser.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/library/webbrowser.rst Sun Jul 20 10:52:46 2014 -0400 @@ -36,9 +36,7 @@ module. It accepts an URL as the argument. It accepts the following optional parameters: ``-n`` opens the URL in a new browser window, if possible; ``-t`` opens the URL in a new browser page ("tab"). The options are, -naturally, mutually exclusive. Usage example:: - - python -m webbrowser -t "http://www.python.org" +naturally, mutually exclusive. The following exception is defined: @@ -50,7 +48,7 @@ The following functions are defined: -.. function:: open(url, new=0, autoraise=True) +.. function:: open(url[, new=0[, autoraise=True]]) Display *url* using the default browser. If *new* is 0, the *url* is opened in the same browser window if possible. If *new* is 1, a new browser window @@ -140,9 +138,9 @@ +-----------------------+-----------------------------------------+-------+ | ``'windows-default'`` | :class:`WindowsDefault` | \(2) | +-----------------------+-----------------------------------------+-------+ -| ``'macosx'`` | :class:`MacOSX('default')` | \(3) | +| ``'internet-config'`` | :class:`InternetConfig` | \(3) | +-----------------------+-----------------------------------------+-------+ -| ``'safari'`` | :class:`MacOSX('safari')` | \(3) | +| ``'macosx'`` | :class:`MacOSX('default')` | \(4) | +-----------------------+-----------------------------------------+-------+ Notes: @@ -158,6 +156,9 @@ Only on Windows platforms. (3) + Only on Mac OS platforms; requires the standard MacPython :mod:`ic` module. + +(4) Only on Mac OS X platform. Here are some simple examples:: @@ -180,7 +181,7 @@ module-level convenience functions: -.. method:: controller.open(url, new=0, autoraise=True) +.. method:: controller.open(url[, new=0[, autoraise=True]]) Display *url* using the browser handled by this controller. If *new* is 1, a new browser window is opened if possible. If *new* is 2, a new browser page ("tab") diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/library/whichdb.rst --- a/Doc/library/whichdb.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/library/whichdb.rst Sun Jul 20 10:52:46 2014 -0400 @@ -6,8 +6,8 @@ .. note:: The :mod:`whichdb` module's only function has been put into the :mod:`dbm` - module in Python 3. The :term:`2to3` tool will automatically adapt imports - when converting your sources to Python 3. + module in Python 3.0. The :term:`2to3` tool will automatically adapt imports + when converting your sources to 3.0. The single function in this module attempts to guess which of the several simple diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/library/winsound.rst --- a/Doc/library/winsound.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/library/winsound.rst Sun Jul 20 10:52:46 2014 -0400 @@ -27,7 +27,7 @@ .. function:: PlaySound(sound, flags) - Call the underlying :c:func:`PlaySound` function from the Platform API. The + Call the underlying :cfunc:`PlaySound` function from the Platform API. The *sound* parameter may be a filename, audio data as a string, or ``None``. Its interpretation depends on the value of *flags*, which can be a bitwise ORed combination of the constants described below. If the *sound* parameter is @@ -37,7 +37,7 @@ .. function:: MessageBeep([type=MB_OK]) - Call the underlying :c:func:`MessageBeep` function from the Platform API. This + Call the underlying :cfunc:`MessageBeep` function from the Platform API. This plays a sound as specified in the registry. The *type* argument specifies which sound to play; possible values are ``-1``, ``MB_ICONASTERISK``, ``MB_ICONEXCLAMATION``, ``MB_ICONHAND``, ``MB_ICONQUESTION``, and ``MB_OK``, all @@ -133,10 +133,6 @@ Return immediately if the sound driver is busy. - .. note:: - - This flag is not supported on modern Windows platforms. - .. data:: MB_ICONASTERISK diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/library/wsgiref.rst --- a/Doc/library/wsgiref.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/library/wsgiref.rst Sun Jul 20 10:52:46 2014 -0400 @@ -59,7 +59,7 @@ found, and "http" otherwise. -.. function:: request_uri(environ, include_query=1) +.. function:: request_uri(environ [, include_query=1]) Return the full request URI, optionally including the query string, using the algorithm found in the "URL Reconstruction" section of :pep:`333`. If @@ -148,7 +148,7 @@ :rfc:`2616`. -.. class:: FileWrapper(filelike, blksize=8192) +.. class:: FileWrapper(filelike [, blksize=8192]) A wrapper to convert a file-like object to an :term:`iterator`. The resulting objects support both :meth:`__getitem__` and :meth:`__iter__` iteration styles, for @@ -271,7 +271,7 @@ :mod:`wsgiref.util`.) -.. function:: make_server(host, port, app, server_class=WSGIServer, handler_class=WSGIRequestHandler) +.. function:: make_server(host, port, app [, server_class=WSGIServer [, handler_class=WSGIRequestHandler]]) Create a new WSGI server listening on *host* and *port*, accepting connections for *app*. The return value is an instance of the supplied *server_class*, and @@ -460,7 +460,7 @@ environment. -.. class:: BaseCGIHandler(stdin, stdout, stderr, environ, multithread=True, multiprocess=False) +.. class:: BaseCGIHandler(stdin, stdout, stderr, environ [, multithread=True [, multiprocess=False]]) Similar to :class:`CGIHandler`, but instead of using the :mod:`sys` and :mod:`os` modules, the CGI environment and I/O streams are specified explicitly. @@ -475,7 +475,7 @@ instead of :class:`SimpleHandler`. -.. class:: SimpleHandler(stdin, stdout, stderr, environ, multithread=True, multiprocess=False) +.. class:: SimpleHandler(stdin, stdout, stderr, environ [,multithread=True [, multiprocess=False]]) Similar to :class:`BaseCGIHandler`, but designed for use with HTTP origin servers. If you are writing an HTTP server implementation, you will probably diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/library/xdrlib.rst --- a/Doc/library/xdrlib.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/library/xdrlib.rst Sun Jul 20 10:52:46 2014 -0400 @@ -274,5 +274,6 @@ p = xdrlib.Packer() try: p.pack_double(8.01) - except xdrlib.ConversionError as instance: + except xdrlib.ConversionError, instance: print 'packing the double failed:', instance.msg + diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/library/xml.dom.minidom.rst --- a/Doc/library/xml.dom.minidom.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/library/xml.dom.minidom.rst Sun Jul 20 10:52:46 2014 -0400 @@ -1,8 +1,8 @@ -:mod:`xml.dom.minidom` --- Minimal DOM implementation -===================================================== +:mod:`xml.dom.minidom` --- Lightweight DOM implementation +========================================================= .. module:: xml.dom.minidom - :synopsis: Minimal Document Object Model (DOM) implementation. + :synopsis: Lightweight Document Object Model (DOM) implementation. .. moduleauthor:: Paul Prescod .. sectionauthor:: Paul Prescod .. sectionauthor:: Martin v. Löwis @@ -14,19 +14,9 @@ -------------- -:mod:`xml.dom.minidom` is a minimal implementation of the Document Object -Model interface, with an API similar to that in other languages. It is intended -to be simpler than the full DOM and also significantly smaller. Users who are -not already proficient with the DOM should consider using the -:mod:`xml.etree.ElementTree` module for their XML processing instead - - -.. warning:: - - The :mod:`xml.dom.minidom` module is not secure against - maliciously constructed data. If you need to parse untrusted or - unauthenticated data see :ref:`xml-vulnerabilities`. - +:mod:`xml.dom.minidom` is a light-weight implementation of the Document Object +Model interface. It is intended to be simpler than the full DOM and also +significantly smaller. DOM applications typically start by parsing some XML into a DOM. With :mod:`xml.dom.minidom`, this is done through the parse functions:: @@ -58,7 +48,7 @@ .. function:: parseString(string[, parser]) Return a :class:`Document` that represents the *string*. This method creates a - :class:`~StringIO.StringIO` object for the string and passes that on to :func:`parse`. + :class:`StringIO` object for the string and passes that on to :func:`parse`. Both functions return a :class:`Document` object representing the content of the document. @@ -131,7 +121,7 @@ to discard children of that node. -.. method:: Node.writexml(writer, indent="", addindent="", newl="") +.. method:: Node.writexml(writer[, indent=""[, addindent=""[, newl=""]]]) Write XML to the writer object. The writer should have a :meth:`write` method which matches that of the file object interface. The *indent* parameter is the @@ -276,4 +266,4 @@ .. [#] The encoding string included in XML output should conform to the appropriate standards. For example, "UTF-8" is valid, but "UTF8" is not. See http://www.w3.org/TR/2006/REC-xml11-20060816/#NT-EncodingDecl - and http://www.iana.org/assignments/character-sets\ . + and http://www.iana.org/assignments/character-sets . diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/library/xml.dom.pulldom.rst --- a/Doc/library/xml.dom.pulldom.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/library/xml.dom.pulldom.rst Sun Jul 20 10:52:46 2014 -0400 @@ -16,13 +16,6 @@ Object Model representation of a document from SAX events. -.. warning:: - - The :mod:`xml.dom.pulldom` module is not secure against - maliciously constructed data. If you need to parse untrusted or - unauthenticated data see :ref:`xml-vulnerabilities`. - - .. class:: PullDOM([documentFactory]) :class:`xml.sax.handler.ContentHandler` implementation that ... diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/library/xml.dom.rst --- a/Doc/library/xml.dom.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/library/xml.dom.rst Sun Jul 20 10:52:46 2014 -0400 @@ -374,7 +374,7 @@ Add a new child node to this node at the end of the list of children, returning *newChild*. If the node was already in - the tree, it is removed first. + in the tree, it is removed first. .. method:: Node.insertBefore(newChild, refChild) @@ -441,15 +441,14 @@ In addition, the Python DOM interface requires that some additional support is provided to allow :class:`NodeList` objects to be used as Python sequences. All -:class:`NodeList` implementations must include support for -:meth:`~object.__len__` and -:meth:`~object.__getitem__`; this allows iteration over the :class:`NodeList` in +:class:`NodeList` implementations must include support for :meth:`__len__` and +:meth:`__getitem__`; this allows iteration over the :class:`NodeList` in :keyword:`for` statements and proper support for the :func:`len` built-in function. If a DOM implementation supports modification of the document, the -:class:`NodeList` implementation must also support the -:meth:`~object.__setitem__` and :meth:`~object.__delitem__` methods. +:class:`NodeList` implementation must also support the :meth:`__setitem__` and +:meth:`__delitem__` methods. .. _dom-documenttype-objects: diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/library/xml.etree.elementtree.rst --- a/Doc/library/xml.etree.elementtree.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/library/xml.etree.elementtree.rst Sun Jul 20 10:52:46 2014 -0400 @@ -16,14 +16,6 @@ hierarchical data structures in memory. The type can be described as a cross between a list and a dictionary. - -.. warning:: - - The :mod:`xml.etree.ElementTree` module is not secure against - maliciously constructed data. If you need to parse untrusted or - unauthenticated data see :ref:`xml-vulnerabilities`. - - Each element has a number of properties associated with it: * a tag which is a string identifying what kind of data this element represents @@ -54,315 +46,11 @@ `Introducing ElementTree 1.3 `_. -Tutorial --------- - -This is a short tutorial for using :mod:`xml.etree.ElementTree` (``ET`` in -short). The goal is to demonstrate some of the building blocks and basic -concepts of the module. - -XML tree and elements -^^^^^^^^^^^^^^^^^^^^^ - -XML is an inherently hierarchical data format, and the most natural way to -represent it is with a tree. ``ET`` has two classes for this purpose - -:class:`ElementTree` represents the whole XML document as a tree, and -:class:`Element` represents a single node in this tree. Interactions with -the whole document (reading and writing to/from files) are usually done -on the :class:`ElementTree` level. Interactions with a single XML element -and its sub-elements are done on the :class:`Element` level. - -.. _elementtree-parsing-xml: - -Parsing XML -^^^^^^^^^^^ - -We'll be using the following XML document as the sample data for this section: - -.. code-block:: xml - - - - - 1 - 2008 - 141100 - - - - - 4 - 2011 - 59900 - - - - 68 - 2011 - 13600 - - - - - -We have a number of ways to import the data. Reading the file from disk:: - - import xml.etree.ElementTree as ET - tree = ET.parse('country_data.xml') - root = tree.getroot() - -Reading the data from a string:: - - root = ET.fromstring(country_data_as_string) - -:func:`fromstring` parses XML from a string directly into an :class:`Element`, -which is the root element of the parsed tree. Other parsing functions may -create an :class:`ElementTree`. Check the documentation to be sure. - -As an :class:`Element`, ``root`` has a tag and a dictionary of attributes:: - - >>> root.tag - 'data' - >>> root.attrib - {} - -It also has children nodes over which we can iterate:: - - >>> for child in root: - ... print child.tag, child.attrib - ... - country {'name': 'Liechtenstein'} - country {'name': 'Singapore'} - country {'name': 'Panama'} - -Children are nested, and we can access specific child nodes by index:: - - >>> root[0][1].text - '2008' - -Finding interesting elements -^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -:class:`Element` has some useful methods that help iterate recursively over all -the sub-tree below it (its children, their children, and so on). For example, -:meth:`Element.iter`:: - - >>> for neighbor in root.iter('neighbor'): - ... print neighbor.attrib - ... - {'name': 'Austria', 'direction': 'E'} - {'name': 'Switzerland', 'direction': 'W'} - {'name': 'Malaysia', 'direction': 'N'} - {'name': 'Costa Rica', 'direction': 'W'} - {'name': 'Colombia', 'direction': 'E'} - -:meth:`Element.findall` finds only elements with a tag which are direct -children of the current element. :meth:`Element.find` finds the *first* child -with a particular tag, and :attr:`Element.text` accesses the element's text -content. :meth:`Element.get` accesses the element's attributes:: - - >>> for country in root.findall('country'): - ... rank = country.find('rank').text - ... name = country.get('name') - ... print name, rank - ... - Liechtenstein 1 - Singapore 4 - Panama 68 - -More sophisticated specification of which elements to look for is possible by -using :ref:`XPath `. - -Modifying an XML File -^^^^^^^^^^^^^^^^^^^^^ - -:class:`ElementTree` provides a simple way to build XML documents and write them to files. -The :meth:`ElementTree.write` method serves this purpose. - -Once created, an :class:`Element` object may be manipulated by directly changing -its fields (such as :attr:`Element.text`), adding and modifying attributes -(:meth:`Element.set` method), as well as adding new children (for example -with :meth:`Element.append`). - -Let's say we want to add one to each country's rank, and add an ``updated`` -attribute to the rank element:: - - >>> for rank in root.iter('rank'): - ... new_rank = int(rank.text) + 1 - ... rank.text = str(new_rank) - ... rank.set('updated', 'yes') - ... - >>> tree.write('output.xml') - -Our XML now looks like this: - -.. code-block:: xml - - - - - 2 - 2008 - 141100 - - - - - 5 - 2011 - 59900 - - - - 69 - 2011 - 13600 - - - - - -We can remove elements using :meth:`Element.remove`. Let's say we want to -remove all countries with a rank higher than 50:: - - >>> for country in root.findall('country'): - ... rank = int(country.find('rank').text) - ... if rank > 50: - ... root.remove(country) - ... - >>> tree.write('output.xml') - -Our XML now looks like this: - -.. code-block:: xml - - - - - 2 - 2008 - 141100 - - - - - 5 - 2011 - 59900 - - - - -Building XML documents -^^^^^^^^^^^^^^^^^^^^^^ - -The :func:`SubElement` function also provides a convenient way to create new -sub-elements for a given element:: - - >>> a = ET.Element('a') - >>> b = ET.SubElement(a, 'b') - >>> c = ET.SubElement(a, 'c') - >>> d = ET.SubElement(c, 'd') - >>> ET.dump(a) - - -Additional resources -^^^^^^^^^^^^^^^^^^^^ - -See http://effbot.org/zone/element-index.htm for tutorials and links to other -docs. - -.. _elementtree-xpath: - -XPath support -------------- - -This module provides limited support for -`XPath expressions `_ for locating elements in a -tree. The goal is to support a small subset of the abbreviated syntax; a full -XPath engine is outside the scope of the module. - -Example -^^^^^^^ - -Here's an example that demonstrates some of the XPath capabilities of the -module. We'll be using the ``countrydata`` XML document from the -:ref:`Parsing XML ` section:: - - import xml.etree.ElementTree as ET - - root = ET.fromstring(countrydata) - - # Top-level elements - root.findall(".") - - # All 'neighbor' grand-children of 'country' children of the top-level - # elements - root.findall("./country/neighbor") - - # Nodes with name='Singapore' that have a 'year' child - root.findall(".//year/..[@name='Singapore']") - - # 'year' nodes that are children of nodes with name='Singapore' - root.findall(".//*[@name='Singapore']/year") - - # All 'neighbor' nodes that are the second child of their parent - root.findall(".//neighbor[2]") - -Supported XPath syntax -^^^^^^^^^^^^^^^^^^^^^^ - -.. tabularcolumns:: |l|L| - -+-----------------------+------------------------------------------------------+ -| Syntax | Meaning | -+=======================+======================================================+ -| ``tag`` | Selects all child elements with the given tag. | -| | For example, ``spam`` selects all child elements | -| | named ``spam``, and ``spam/egg`` selects all | -| | grandchildren named ``egg`` in all children named | -| | ``spam``. | -+-----------------------+------------------------------------------------------+ -| ``*`` | Selects all child elements. For example, ``*/egg`` | -| | selects all grandchildren named ``egg``. | -+-----------------------+------------------------------------------------------+ -| ``.`` | Selects the current node. This is mostly useful | -| | at the beginning of the path, to indicate that it's | -| | a relative path. | -+-----------------------+------------------------------------------------------+ -| ``//`` | Selects all subelements, on all levels beneath the | -| | current element. For example, ``.//egg`` selects | -| | all ``egg`` elements in the entire tree. | -+-----------------------+------------------------------------------------------+ -| ``..`` | Selects the parent element. | -+-----------------------+------------------------------------------------------+ -| ``[@attrib]`` | Selects all elements that have the given attribute. | -+-----------------------+------------------------------------------------------+ -| ``[@attrib='value']`` | Selects all elements for which the given attribute | -| | has the given value. The value cannot contain | -| | quotes. | -+-----------------------+------------------------------------------------------+ -| ``[tag]`` | Selects all elements that have a child named | -| | ``tag``. Only immediate children are supported. | -+-----------------------+------------------------------------------------------+ -| ``[position]`` | Selects all elements that are located at the given | -| | position. The position can be either an integer | -| | (1 is the first position), the expression ``last()`` | -| | (for the last position), or a position relative to | -| | the last position (e.g. ``last()-1``). | -+-----------------------+------------------------------------------------------+ - -Predicates (expressions within square brackets) must be preceded by a tag -name, an asterisk, or another predicate. ``position`` predicates must be -preceded by a tag name. - -Reference ---------- .. _elementtree-functions: Functions -^^^^^^^^^ +--------- .. function:: Comment(text=None) @@ -413,9 +101,8 @@ going on to the user. *source* is a filename or file object containing XML data. *events* is a list of events to report back. If omitted, only "end" events are reported. *parser* is an optional parser instance. If not - given, the standard :class:`XMLParser` parser is used. *parser* is not - supported by ``cElementTree``. Returns an :term:`iterator` providing - ``(event, elem)`` pairs. + given, the standard :class:`XMLParser` parser is used. Returns an + :term:`iterator` providing ``(event, elem)`` pairs. .. note:: @@ -509,7 +196,8 @@ .. _elementtree-element-objects: Element Objects -^^^^^^^^^^^^^^^ +--------------- + .. class:: Element(tag, attrib={}, **extra) @@ -680,9 +368,8 @@ or contents. :class:`Element` objects also support the following sequence type methods - for working with subelements: :meth:`~object.__delitem__`, - :meth:`~object.__getitem__`, :meth:`~object.__setitem__`, - :meth:`~object.__len__`. + for working with subelements: :meth:`__delitem__`, :meth:`__getitem__`, + :meth:`__setitem__`, :meth:`__len__`. Caution: Elements with no subelements will test as ``False``. This behavior will change in future versions. Use specific ``len(elem)`` or ``elem is @@ -700,7 +387,7 @@ .. _elementtree-elementtree-objects: ElementTree Objects -^^^^^^^^^^^^^^^^^^^ +------------------- .. class:: ElementTree(element=None, file=None) @@ -722,17 +409,26 @@ .. method:: find(match) - Same as :meth:`Element.find`, starting at the root of the tree. + Finds the first toplevel element matching *match*. *match* may be a tag + name or path. Same as getroot().find(match). Returns the first matching + element, or ``None`` if no element was found. .. method:: findall(match) - Same as :meth:`Element.findall`, starting at the root of the tree. + Finds all matching subelements, by tag name or path. Same as + getroot().findall(match). *match* may be a tag name or path. Returns a + list containing all matching elements, in document order. .. method:: findtext(match, default=None) - Same as :meth:`Element.findtext`, starting at the root of the tree. + Finds the element text for the first toplevel element with given tag. + Same as getroot().findtext(match). *match* may be a tag name or path. + *default* is the value to return if the element was not found. Returns + the text content of the first matching element, or the default value no + element was found. Note that if the element is found, but has no text + content, this method returns an empty string. .. method:: getiterator(tag=None) @@ -770,15 +466,13 @@ root element. - .. method:: write(file, encoding="us-ascii", xml_declaration=None, \ - default_namespace=None, method="xml") + .. method:: write(file, encoding="us-ascii", xml_declaration=None, method="xml") Writes the element tree to a file, as XML. *file* is a file name, or a file object opened for writing. *encoding* [1]_ is the output encoding (default is US-ASCII). *xml_declaration* controls if an XML declaration should be added to the file. Use False for never, True for always, None - for only if not US-ASCII or UTF-8 (default is None). *default_namespace* - sets the default XML namespace (for "xmlns"). *method* is either + for only if not US-ASCII or UTF-8 (default is None). *method* is either ``"xml"``, ``"html"`` or ``"text"`` (default is ``"xml"``). Returns an encoded string. @@ -813,7 +507,7 @@ .. _elementtree-qname-objects: QName Objects -^^^^^^^^^^^^^ +------------- .. class:: QName(text_or_uri, tag=None) @@ -829,7 +523,7 @@ .. _elementtree-treebuilder-objects: TreeBuilder Objects -^^^^^^^^^^^^^^^^^^^ +------------------- .. class:: TreeBuilder(element_factory=None) @@ -880,7 +574,7 @@ .. _elementtree-xmlparser-objects: XMLParser Objects -^^^^^^^^^^^^^^^^^ +----------------- .. class:: XMLParser(html=0, target=None, encoding=None) diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/library/xml.rst --- a/Doc/library/xml.rst Sat Jul 19 16:34:33 2014 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,136 +0,0 @@ -.. _xml: - -XML Processing Modules -====================== - -.. module:: xml - :synopsis: Package containing XML processing modules -.. sectionauthor:: Christian Heimes -.. sectionauthor:: Georg Brandl - - -Python's interfaces for processing XML are grouped in the ``xml`` package. - -.. warning:: - - The XML modules are not secure against erroneous or maliciously - constructed data. If you need to parse untrusted or unauthenticated data see - :ref:`xml-vulnerabilities`. - -It is important to note that modules in the :mod:`xml` package require that -there be at least one SAX-compliant XML parser available. The Expat parser is -included with Python, so the :mod:`xml.parsers.expat` module will always be -available. - -The documentation for the :mod:`xml.dom` and :mod:`xml.sax` packages are the -definition of the Python bindings for the DOM and SAX interfaces. - -The XML handling submodules are: - -* :mod:`xml.etree.ElementTree`: the ElementTree API, a simple and lightweight - XML processor - -.. - -* :mod:`xml.dom`: the DOM API definition -* :mod:`xml.dom.minidom`: a minimal DOM implementation -* :mod:`xml.dom.pulldom`: support for building partial DOM trees - -.. - -* :mod:`xml.sax`: SAX2 base classes and convenience functions -* :mod:`xml.parsers.expat`: the Expat parser binding - - -.. _xml-vulnerabilities: - -XML vulnerabilities -=================== - -The XML processing modules are not secure against maliciously constructed data. -An attacker can abuse vulnerabilities for e.g. denial of service attacks, to -access local files, to generate network connections to other machines, or -to or circumvent firewalls. The attacks on XML abuse unfamiliar features -like inline `DTD`_ (document type definition) with entities. - -The following table gives an overview of the known attacks and if the various -modules are vulnerable to them. - -========================= ======== ========= ========= ======== ========= -kind sax etree minidom pulldom xmlrpc -========================= ======== ========= ========= ======== ========= -billion laughs **Yes** **Yes** **Yes** **Yes** **Yes** -quadratic blowup **Yes** **Yes** **Yes** **Yes** **Yes** -external entity expansion **Yes** No (1) No (2) **Yes** No (3) -DTD retrieval **Yes** No No **Yes** No -decompression bomb No No No No **Yes** -========================= ======== ========= ========= ======== ========= - -1. :mod:`xml.etree.ElementTree` doesn't expand external entities and raises a - ParserError when an entity occurs. -2. :mod:`xml.dom.minidom` doesn't expand external entities and simply returns - the unexpanded entity verbatim. -3. :mod:`xmlrpclib` doesn't expand external entities and omits them. - - -billion laughs / exponential entity expansion - The `Billion Laughs`_ attack -- also known as exponential entity expansion -- - uses multiple levels of nested entities. Each entity refers to another entity - several times, the final entity definition contains a small string. Eventually - the small string is expanded to several gigabytes. The exponential expansion - consumes lots of CPU time, too. - -quadratic blowup entity expansion - A quadratic blowup attack is similar to a `Billion Laughs`_ attack; it abuses - entity expansion, too. Instead of nested entities it repeats one large entity - with a couple of thousand chars over and over again. The attack isn't as - efficient as the exponential case but it avoids triggering countermeasures of - parsers against heavily nested entities. - -external entity expansion - Entity declarations can contain more than just text for replacement. They can - also point to external resources by public identifiers or system identifiers. - System identifiers are standard URIs or can refer to local files. The XML - parser retrieves the resource with e.g. HTTP or FTP requests and embeds the - content into the XML document. - -DTD retrieval - Some XML libraries like Python's :mod:`xml.dom.pulldom` retrieve document type - definitions from remote or local locations. The feature has similar - implications as the external entity expansion issue. - -decompression bomb - The issue of decompression bombs (aka `ZIP bomb`_) apply to all XML libraries - that can parse compressed XML stream like gzipped HTTP streams or LZMA-ed - files. For an attacker it can reduce the amount of transmitted data by three - magnitudes or more. - -The documentation of `defusedxml`_ on PyPI has further information about -all known attack vectors with examples and references. - -defused packages ----------------- - -These external packages are recommended for any code that parses -untrusted XML data. - -`defusedxml`_ is a pure Python package with modified subclasses of all stdlib -XML parsers that prevent any potentially malicious operation. The -package also ships with example exploits and extended documentation on more -XML exploits like xpath injection. - -`defusedexpat`_ provides a modified libexpat and patched replacement -:mod:`pyexpat` extension module with countermeasures against entity expansion -DoS attacks. Defusedexpat still allows a sane and configurable amount of entity -expansions. The modifications will be merged into future releases of Python. - -The workarounds and modifications are not included in patch releases as they -break backward compatibility. After all inline DTD and entity expansion are -well-defined XML features. - - -.. _defusedxml: https://pypi.python.org/pypi/defusedxml/ -.. _defusedexpat: https://pypi.python.org/pypi/defusedexpat/ -.. _Billion Laughs: http://en.wikipedia.org/wiki/Billion_laughs -.. _ZIP bomb: http://en.wikipedia.org/wiki/Zip_bomb -.. _DTD: http://en.wikipedia.org/wiki/Document_Type_Definition diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/library/xml.sax.handler.rst --- a/Doc/library/xml.sax.handler.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/library/xml.sax.handler.rst Sun Jul 20 10:52:46 2014 -0400 @@ -240,8 +240,7 @@ Signals the start of an element in non-namespace mode. The *name* parameter contains the raw XML 1.0 name of the element type as a - string and the *attrs* parameter holds an object of the - :class:`~xml.sax.xmlreader.Attributes` + string and the *attrs* parameter holds an object of the :class:`Attributes` interface (see :ref:`attributes-objects`) containing the attributes of the element. The object passed as *attrs* may be re-used by the parser; holding on to a reference to it is not a reliable way to keep a copy of the attributes. @@ -264,8 +263,7 @@ The *name* parameter contains the name of the element type as a ``(uri, localname)`` tuple, the *qname* parameter contains the raw XML 1.0 name used in the source document, and the *attrs* parameter holds an instance of the - :class:`~xml.sax.xmlreader.AttributesNS` interface (see - :ref:`attributes-ns-objects`) + :class:`AttributesNS` interface (see :ref:`attributes-ns-objects`) containing the attributes of the element. If no namespace is associated with the element, the *uri* component of *name* will be ``None``. The object passed as *attrs* may be re-used by the parser; holding on to a reference to it is not @@ -381,9 +379,8 @@ -------------------- Objects with this interface are used to receive error and warning information -from the :class:`~xml.sax.xmlreader.XMLReader`. If you create an object that -implements this interface, then register the object with your -:class:`~xml.sax.xmlreader.XMLReader`, the parser +from the :class:`XMLReader`. If you create an object that implements this +interface, then register the object with your :class:`XMLReader`, the parser will call the methods in your object to report all warnings and errors. There are three levels of errors available: warnings, (possibly) recoverable errors, and unrecoverable errors. All methods take a :exc:`SAXParseException` as the diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/library/xml.sax.reader.rst --- a/Doc/library/xml.sax.reader.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/library/xml.sax.reader.rst Sun Jul 20 10:52:46 2014 -0400 @@ -109,50 +109,47 @@ .. method:: XMLReader.getContentHandler() - Return the current :class:`~xml.sax.handler.ContentHandler`. + Return the current :class:`ContentHandler`. .. method:: XMLReader.setContentHandler(handler) - Set the current :class:`~xml.sax.handler.ContentHandler`. If no - :class:`~xml.sax.handler.ContentHandler` is set, content events will be - discarded. + Set the current :class:`ContentHandler`. If no :class:`ContentHandler` is set, + content events will be discarded. .. method:: XMLReader.getDTDHandler() - Return the current :class:`~xml.sax.handler.DTDHandler`. + Return the current :class:`DTDHandler`. .. method:: XMLReader.setDTDHandler(handler) - Set the current :class:`~xml.sax.handler.DTDHandler`. If no - :class:`~xml.sax.handler.DTDHandler` is set, DTD + Set the current :class:`DTDHandler`. If no :class:`DTDHandler` is set, DTD events will be discarded. .. method:: XMLReader.getEntityResolver() - Return the current :class:`~xml.sax.handler.EntityResolver`. + Return the current :class:`EntityResolver`. .. method:: XMLReader.setEntityResolver(handler) - Set the current :class:`~xml.sax.handler.EntityResolver`. If no - :class:`~xml.sax.handler.EntityResolver` is set, + Set the current :class:`EntityResolver`. If no :class:`EntityResolver` is set, attempts to resolve an external entity will result in opening the system identifier for the entity, and fail if it is not available. .. method:: XMLReader.getErrorHandler() - Return the current :class:`~xml.sax.handler.ErrorHandler`. + Return the current :class:`ErrorHandler`. .. method:: XMLReader.setErrorHandler(handler) - Set the current error handler. If no :class:`~xml.sax.handler.ErrorHandler` - is set, errors will be raised as exceptions, and warnings will be printed. + Set the current error handler. If no :class:`ErrorHandler` is set, errors will + be raised as exceptions, and warnings will be printed. .. method:: XMLReader.setLocale(locale) @@ -329,13 +326,8 @@ --------------------------------- :class:`Attributes` objects implement a portion of the mapping protocol, -including the methods :meth:`~collections.Mapping.copy`, -:meth:`~collections.Mapping.get`, -:meth:`~collections.Mapping.has_key`, -:meth:`~collections.Mapping.items`, -:meth:`~collections.Mapping.keys`, -and :meth:`~collections.Mapping.values`. The following methods -are also provided: +including the methods :meth:`copy`, :meth:`get`, :meth:`has_key`, :meth:`items`, +:meth:`keys`, and :meth:`values`. The following methods are also provided: .. method:: Attributes.getLength() diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/library/xml.sax.rst --- a/Doc/library/xml.sax.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/library/xml.sax.rst Sun Jul 20 10:52:46 2014 -0400 @@ -16,21 +16,12 @@ SAX exceptions and the convenience functions which will be most used by users of the SAX API. - -.. warning:: - - The :mod:`xml.sax` module is not secure against maliciously - constructed data. If you need to parse untrusted or unauthenticated data see - :ref:`xml-vulnerabilities`. - - The convenience functions are: .. function:: make_parser([parser_list]) - Create and return a SAX :class:`~xml.sax.xmlreader.XMLReader` object. The - first parser found will + Create and return a SAX :class:`XMLReader` object. The first parser found will be used. If *parser_list* is provided, it must be a sequence of strings which name modules that have a function named :func:`create_parser`. Modules listed in *parser_list* will be used before modules in the default list of parsers. @@ -40,9 +31,8 @@ Create a SAX parser and use it to parse a document. The document, passed in as *filename_or_stream*, can be a filename or a file object. The *handler* - parameter needs to be a SAX :class:`~handler.ContentHandler` instance. If - *error_handler* is given, it must be a SAX :class:`~handler.ErrorHandler` - instance; if + parameter needs to be a SAX :class:`ContentHandler` instance. If + *error_handler* is given, it must be a SAX :class:`ErrorHandler` instance; if omitted, :exc:`SAXParseException` will be raised on all errors. There is no return value; all work must be done by the *handler* passed in. @@ -67,12 +57,10 @@ instantiated by the application itself. Since Python does not have an explicit notion of interface, they are formally introduced as classes, but applications may use implementations which do not inherit from the provided classes. The -:class:`~xml.sax.xmlreader.InputSource`, :class:`~xml.sax.xmlreader.Locator`, -:class:`~xml.sax.xmlreader.Attributes`, :class:`~xml.sax.xmlreader.AttributesNS`, -and :class:`~xml.sax.xmlreader.XMLReader` interfaces are defined in the +:class:`InputSource`, :class:`Locator`, :class:`Attributes`, +:class:`AttributesNS`, and :class:`XMLReader` interfaces are defined in the module :mod:`xml.sax.xmlreader`. The handler interfaces are defined in -:mod:`xml.sax.handler`. For convenience, -:class:`~xml.sax.xmlreader.InputSource` (which is often +:mod:`xml.sax.handler`. For convenience, :class:`InputSource` (which is often instantiated directly) and the handler classes are also available from :mod:`xml.sax`. These interfaces are described below. @@ -85,8 +73,7 @@ Encapsulate an XML error or warning. This class can contain basic error or warning information from either the XML parser or the application: it can be subclassed to provide additional functionality or to add localization. Note - that although the handlers defined in the - :class:`~xml.sax.handler.ErrorHandler` interface + that although the handlers defined in the :class:`ErrorHandler` interface receive instances of this exception, it is not required to actually raise the exception --- it is also useful as a container for information. @@ -99,26 +86,22 @@ .. exception:: SAXParseException(msg, exception, locator) - Subclass of :exc:`SAXException` raised on parse errors. Instances of this - class are passed to the methods of the SAX - :class:`~xml.sax.handler.ErrorHandler` interface to provide information - about the parse error. This class supports the SAX - :class:`~xml.sax.xmlreader.Locator` interface as well as the - :class:`SAXException` interface. + Subclass of :exc:`SAXException` raised on parse errors. Instances of this class + are passed to the methods of the SAX :class:`ErrorHandler` interface to provide + information about the parse error. This class supports the SAX :class:`Locator` + interface as well as the :class:`SAXException` interface. .. exception:: SAXNotRecognizedException(msg[, exception]) - Subclass of :exc:`SAXException` raised when a SAX - :class:`~xml.sax.xmlreader.XMLReader` is + Subclass of :exc:`SAXException` raised when a SAX :class:`XMLReader` is confronted with an unrecognized feature or property. SAX applications and extensions may use this class for similar purposes. .. exception:: SAXNotSupportedException(msg[, exception]) - Subclass of :exc:`SAXException` raised when a SAX - :class:`~xml.sax.xmlreader.XMLReader` is asked to + Subclass of :exc:`SAXException` raised when a SAX :class:`XMLReader` is asked to enable a feature that is not supported, or to set a property to a value that the implementation does not support. SAX applications and extensions may use this class for similar purposes. diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/library/xml.sax.utils.rst --- a/Doc/library/xml.sax.utils.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/library/xml.sax.utils.rst Sun Jul 20 10:52:46 2014 -0400 @@ -59,8 +59,7 @@ .. class:: XMLGenerator([out[, encoding]]) - This class implements the :class:`~xml.sax.handler.ContentHandler` interface - by writing SAX + This class implements the :class:`ContentHandler` interface by writing SAX events back into an XML document. In other words, using an :class:`XMLGenerator` as the content handler will reproduce the original document being parsed. *out* should be a file-like object which will default to *sys.stdout*. *encoding* is @@ -69,8 +68,7 @@ .. class:: XMLFilterBase(base) - This class is designed to sit between an - :class:`~xml.sax.xmlreader.XMLReader` and the client + This class is designed to sit between an :class:`XMLReader` and the client application's event handlers. By default, it does nothing but pass requests up to the reader and events on to the handlers unmodified, but subclasses can override specific methods to modify the event stream or the configuration @@ -79,10 +77,9 @@ .. function:: prepare_input_source(source[, base]) - This function takes an input source and an optional base URL and returns a - fully resolved :class:`~xml.sax.xmlreader.InputSource` object ready for - reading. The input source can be given as a string, a file-like object, or - an :class:`~xml.sax.xmlreader.InputSource` object; parsers will use this - function to implement the polymorphic *source* argument to their - :meth:`parse` method. + This function takes an input source and an optional base URL and returns a fully + resolved :class:`InputSource` object ready for reading. The input source can be + given as a string, a file-like object, or an :class:`InputSource` object; + parsers will use this function to implement the polymorphic *source* argument to + their :meth:`parse` method. diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/library/xmlrpclib.rst --- a/Doc/library/xmlrpclib.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/library/xmlrpclib.rst Sun Jul 20 10:52:46 2014 -0400 @@ -8,8 +8,8 @@ .. note:: The :mod:`xmlrpclib` module has been renamed to :mod:`xmlrpc.client` in - Python 3. The :term:`2to3` tool will automatically adapt imports when - converting your sources to Python 3. + Python 3.0. The :term:`2to3` tool will automatically adapt imports when + converting your sources to 3.0. .. XXX Not everything is documented yet. It might be good to describe @@ -28,13 +28,6 @@ between conformable Python objects and XML on the wire. -.. warning:: - - The :mod:`xmlrpclib` module is not secure against maliciously - constructed data. If you need to parse untrusted or unauthenticated data see - :ref:`xml-vulnerabilities`. - - .. class:: ServerProxy(uri[, transport[, encoding[, verbose[, allow_none[, use_datetime]]]]]) A :class:`ServerProxy` instance is an object that manages communication with a @@ -387,7 +380,7 @@ proxy = xmlrpclib.ServerProxy("http://localhost:8000/") try: proxy.add(2, 5) - except xmlrpclib.Fault as err: + except xmlrpclib.Fault, err: print "A fault occurred" print "Fault code: %d" % err.faultCode print "Fault string: %s" % err.faultString @@ -434,7 +427,7 @@ try: proxy.some_method() - except xmlrpclib.ProtocolError as err: + except xmlrpclib.ProtocolError, err: print "A protocol error occurred" print "URL: %s" % err.url print "HTTP/HTTPS headers: %s" % err.headers @@ -552,7 +545,7 @@ try: print server.examples.getStateName(41) - except Error as v: + except Error, v: print "ERROR", v To access an XML-RPC server through a proxy, you need to define a custom diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/library/zipfile.rst --- a/Doc/library/zipfile.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/library/zipfile.rst Sun Jul 20 10:52:46 2014 -0400 @@ -25,6 +25,9 @@ create an encrypted file. Decryption is extremely slow as it is implemented in native Python rather than C. +For other archive formats, see the :mod:`bz2`, :mod:`gzip`, and +:mod:`tarfile` modules. + The module defines the following items: .. exception:: BadZipfile @@ -53,7 +56,7 @@ .. class:: ZipInfo([filename[, date_time]]) Class used to represent information about a member of an archive. Instances - of this class are returned by the :meth:`.getinfo` and :meth:`.infolist` + of this class are returned by the :meth:`getinfo` and :meth:`infolist` methods of :class:`ZipFile` objects. Most users of the :mod:`zipfile` module will not need to create these, but only use those created by this module. *filename* should be the full name of the archive member, and @@ -78,7 +81,7 @@ .. data:: ZIP_DEFLATED The numeric constant for the usual ZIP compression method. This requires the - :mod:`zlib` module. No other compression methods are currently supported. + zlib module. No other compression methods are currently supported. .. seealso:: @@ -125,7 +128,7 @@ .. versionchanged:: 2.7.1 If the file is created with mode ``'a'`` or ``'w'`` and then - :meth:`closed ` without adding any files to the archive, the appropriate + :meth:`close`\ d without adding any files to the archive, the appropriate ZIP structures for an empty archive will be written to the file. ZipFile is also a context manager and therefore supports the @@ -163,26 +166,21 @@ Return a list of archive members by name. - .. index:: - single: universal newlines; zipfile.ZipFile.open method - .. method:: ZipFile.open(name[, mode[, pwd]]) Extract a member from the archive as a file-like object (ZipExtFile). *name* is the name of the file in the archive, or a :class:`ZipInfo` object. The *mode* - parameter, if included, must be one of the following: ``'r'`` (the default), - ``'U'``, or ``'rU'``. Choosing ``'U'`` or ``'rU'`` will enable - :term:`universal newline ` + parameter, if included, must be one of the following: ``'r'`` (the default), + ``'U'``, or ``'rU'``. Choosing ``'U'`` or ``'rU'`` will enable universal newline support in the read-only object. *pwd* is the password used for encrypted files. - Calling :meth:`.open` on a closed ZipFile will raise a :exc:`RuntimeError`. + Calling :meth:`open` on a closed ZipFile will raise a :exc:`RuntimeError`. .. note:: The file-like object is read-only and provides the following methods: - :meth:`~file.read`, :meth:`~file.readline`, - :meth:`~file.readlines`, :meth:`__iter__`, - :meth:`~object.next`. + :meth:`!read`, :meth:`!readline`, :meth:`!readlines`, :meth:`!__iter__`, + :meth:`!next`. .. note:: @@ -197,7 +195,7 @@ .. note:: - The :meth:`.open`, :meth:`read` and :meth:`extract` methods can take a filename + The :meth:`open`, :meth:`read` and :meth:`extract` methods can take a filename or a :class:`ZipInfo` object. You will appreciate this when trying to read a ZIP file that contains members with duplicate names. @@ -214,16 +212,6 @@ .. versionadded:: 2.6 - .. note:: - - If a member filename is an absolute path, a drive/UNC sharepoint and - leading (back)slashes will be stripped, e.g.: ``///foo/bar`` becomes - ``foo/bar`` on Unix, and ``C:\foo\bar`` becomes ``foo\bar`` on Windows. - And all ``".."`` components in a member filename will be removed, e.g.: - ``../../foo../../ba..r`` becomes ``foo../ba..r``. On Windows illegal - characters (``:``, ``<``, ``>``, ``|``, ``"``, ``?``, and ``*``) - replaced by underscore (``_``). - .. method:: ZipFile.extractall([path[, members[, pwd]]]) @@ -239,9 +227,6 @@ that have absolute filenames starting with ``"/"`` or filenames with two dots ``".."``. - .. versionchanged:: 2.7.4 - The zipfile module attempts to prevent that. See :meth:`extract` note. - .. versionadded:: 2.6 @@ -327,7 +312,7 @@ :class:`ZipInfo` constructor sets this member to :const:`ZIP_STORED`. .. versionchanged:: 2.7 - The *compress_type* argument. + The *compression_type* argument. The following data attributes are also available: @@ -343,7 +328,7 @@ The comment text associated with the ZIP file. If assigning a comment to a :class:`ZipFile` instance created with mode 'a' or 'w', this should be a string no longer than 65535 bytes. Comments longer than this will be - truncated in the written archive when :meth:`.close` is called. + truncated in the written archive when :meth:`ZipFile.close` is called. .. _pyzipfile-objects: @@ -383,8 +368,8 @@ ZipInfo Objects --------------- -Instances of the :class:`ZipInfo` class are returned by the :meth:`.getinfo` and -:meth:`.infolist` methods of :class:`ZipFile` objects. Each object stores +Instances of the :class:`ZipInfo` class are returned by the :meth:`getinfo` and +:meth:`infolist` methods of :class:`ZipFile` objects. Each object stores information about a single member of the ZIP archive. Instances have the following attributes: diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/library/zipimport.rst --- a/Doc/library/zipimport.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/library/zipimport.rst Sun Jul 20 10:52:46 2014 -0400 @@ -19,7 +19,7 @@ also allows an item of :data:`sys.path` to be a string naming a ZIP file archive. The ZIP archive can contain a subdirectory structure to support package imports, and a path within the archive can be specified to only import from a -subdirectory. For example, the path :file:`example.zip/lib/` would only +subdirectory. For example, the path :file:`/tmp/example.zip/lib/` would only import from the :file:`lib/` subdirectory within the archive. Any files may be present in the ZIP archive, but only files :file:`.py` and @@ -115,7 +115,7 @@ .. method:: is_package(fullname) - Return ``True`` if the module specified by *fullname* is a package. Raise + Return True if the module specified by *fullname* is a package. Raise :exc:`ZipImportError` if the module couldn't be found. @@ -151,8 +151,8 @@ Here is an example that imports a module from a ZIP archive - note that the :mod:`zipimport` module is not explicitly used. :: - $ unzip -l example.zip - Archive: example.zip + $ unzip -l /tmp/example.zip + Archive: /tmp/example.zip Length Date Time Name -------- ---- ---- ---- 8467 11-26-02 22:30 jwzthreading.py @@ -161,8 +161,8 @@ $ ./python Python 2.3 (#1, Aug 1 2003, 19:54:32) >>> import sys - >>> sys.path.insert(0, 'example.zip') # Add .zip file to front of path + >>> sys.path.insert(0, '/tmp/example.zip') # Add .zip file to front of path >>> import jwzthreading >>> jwzthreading.__file__ - 'example.zip/jwzthreading.py' + '/tmp/example.zip/jwzthreading.py' diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/library/zlib.rst --- a/Doc/library/zlib.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/library/zlib.rst Sun Jul 20 10:52:46 2014 -0400 @@ -19,7 +19,9 @@ consult the zlib manual at http://www.zlib.net/manual.html for authoritative information. -For reading and writing ``.gz`` files see the :mod:`gzip` module. +For reading and writing ``.gz`` files see the :mod:`gzip` module. For +other archive formats, see the :mod:`bz2`, :mod:`zipfile`, and +:mod:`tarfile` modules. The available exception and functions in this module are: @@ -62,34 +64,18 @@ .. function:: compress(string[, level]) Compresses the data in *string*, returning a string contained compressed data. - *level* is an integer from ``0`` to ``9`` controlling the level of compression; + *level* is an integer from ``1`` to ``9`` controlling the level of compression; ``1`` is fastest and produces the least compression, ``9`` is slowest and - produces the most. ``0`` is no compression. The default value is ``6``. - Raises the :exc:`error` exception if any error occurs. + produces the most. The default value is ``6``. Raises the :exc:`error` + exception if any error occurs. -.. function:: compressobj([level[, method[, wbits[, memlevel[, strategy]]]]]) +.. function:: compressobj([level]) Returns a compression object, to be used for compressing data streams that won't - fit into memory at once. *level* is an integer from ``0`` to ``9`` controlling + fit into memory at once. *level* is an integer from ``1`` to ``9`` controlling the level of compression; ``1`` is fastest and produces the least compression, - ``9`` is slowest and produces the most. ``0`` is no compression. The default - value is ``6``. - - *method* is the compression algorithm. Currently, the only supported value is - ``DEFLATED``. - - *wbits* is the base two logarithm of the size of the window buffer. This - should be an integer from ``8`` to ``15``. Higher values give better - compression, but use more memory. The default is 15. - - *memlevel* controls the amount of memory used for internal compression state. - Valid values range from ``1`` to ``9``. Higher values using more memory, - but are faster and produce smaller output. The default is 8. - - *strategy* is used to tune the compression algorithm. Possible values are - ``Z_DEFAULT_STRATEGY``, ``Z_FILTERED``, and ``Z_HUFFMAN_ONLY``. The default - is ``Z_DEFAULT_STRATEGY``. + ``9`` is slowest and produces the most. The default value is ``6``. .. function:: crc32(data[, value]) @@ -146,7 +132,7 @@ *bufsize* is the initial size of the buffer used to hold decompressed data. If more space is required, the buffer size will be increased as needed, so you don't have to get this value exactly right; tuning it will only save a few calls - to :c:func:`malloc`. The default size is 16384. + to :cfunc:`malloc`. The default size is 16384. .. function:: decompressobj([wbits]) diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/license.rst --- a/Doc/license.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/license.rst Sun Jul 20 10:52:46 2014 -0400 @@ -50,11 +50,59 @@ +----------------+--------------+-----------+------------+-----------------+ | 2.1.1 | 2.1+2.0.1 | 2001 | PSF | yes | +----------------+--------------+-----------+------------+-----------------+ +| 2.2 | 2.1.1 | 2001 | PSF | yes | ++----------------+--------------+-----------+------------+-----------------+ | 2.1.2 | 2.1.1 | 2002 | PSF | yes | +----------------+--------------+-----------+------------+-----------------+ | 2.1.3 | 2.1.2 | 2002 | PSF | yes | +----------------+--------------+-----------+------------+-----------------+ -| 2.2 and above | 2.1.1 | 2001-now | PSF | yes | +| 2.2.1 | 2.2 | 2002 | PSF | yes | ++----------------+--------------+-----------+------------+-----------------+ +| 2.2.2 | 2.2.1 | 2002 | PSF | yes | ++----------------+--------------+-----------+------------+-----------------+ +| 2.2.3 | 2.2.2 | 2002-2003 | PSF | yes | ++----------------+--------------+-----------+------------+-----------------+ +| 2.3 | 2.2.2 | 2002-2003 | PSF | yes | ++----------------+--------------+-----------+------------+-----------------+ +| 2.3.1 | 2.3 | 2002-2003 | PSF | yes | ++----------------+--------------+-----------+------------+-----------------+ +| 2.3.2 | 2.3.1 | 2003 | PSF | yes | ++----------------+--------------+-----------+------------+-----------------+ +| 2.3.3 | 2.3.2 | 2003 | PSF | yes | ++----------------+--------------+-----------+------------+-----------------+ +| 2.3.4 | 2.3.3 | 2004 | PSF | yes | ++----------------+--------------+-----------+------------+-----------------+ +| 2.3.5 | 2.3.4 | 2005 | PSF | yes | ++----------------+--------------+-----------+------------+-----------------+ +| 2.4 | 2.3 | 2004 | PSF | yes | ++----------------+--------------+-----------+------------+-----------------+ +| 2.4.1 | 2.4 | 2005 | PSF | yes | ++----------------+--------------+-----------+------------+-----------------+ +| 2.4.2 | 2.4.1 | 2005 | PSF | yes | ++----------------+--------------+-----------+------------+-----------------+ +| 2.4.3 | 2.4.2 | 2006 | PSF | yes | ++----------------+--------------+-----------+------------+-----------------+ +| 2.4.4 | 2.4.3 | 2006 | PSF | yes | ++----------------+--------------+-----------+------------+-----------------+ +| 2.5 | 2.4 | 2006 | PSF | yes | ++----------------+--------------+-----------+------------+-----------------+ +| 2.5.1 | 2.5 | 2007 | PSF | yes | ++----------------+--------------+-----------+------------+-----------------+ +| 2.5.2 | 2.5.1 | 2008 | PSF | yes | ++----------------+--------------+-----------+------------+-----------------+ +| 2.5.3 | 2.5.2 | 2008 | PSF | yes | ++----------------+--------------+-----------+------------+-----------------+ +| 2.6 | 2.5 | 2008 | PSF | yes | ++----------------+--------------+-----------+------------+-----------------+ +| 2.6.1 | 2.6 | 2008 | PSF | yes | ++----------------+--------------+-----------+------------+-----------------+ +| 2.6.2 | 2.6.1 | 2009 | PSF | yes | ++----------------+--------------+-----------+------------+-----------------+ +| 2.6.3 | 2.6.2 | 2009 | PSF | yes | ++----------------+--------------+-----------+------------+-----------------+ +| 2.6.4 | 2.6.3 | 2010 | PSF | yes | ++----------------+--------------+-----------+------------+-----------------+ +| 2.7 | 2.6 | 2010 | PSF | yes | +----------------+--------------+-----------+------------+-----------------+ .. note:: @@ -84,7 +132,7 @@ analyze, test, perform and/or display publicly, prepare derivative works, distribute, and otherwise use Python |release| alone or in any derivative version, provided, however, that PSF's License Agreement and PSF's notice of - copyright, i.e., "Copyright © 2001-2014 Python Software Foundation; All Rights + copyright, i.e., "Copyright © 2001-2010 Python Software Foundation; All Rights Reserved" are retained in Python |release| alone or in any derivative version prepared by Licensee. @@ -261,7 +309,7 @@ ---------------- The :mod:`_random` module includes code based on a download from -http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/MT2002/emt19937ar.html. The following are +http://www.math.keio.ac.jp/ matumoto/MT2002/emt19937ar.html. The following are the verbatim comments from the original code:: A C-program for MT19937, with initialization improved 2002/1/26. @@ -302,8 +350,8 @@ Any feedback is very welcome. - http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/emt.html - email: m-mat @ math.sci.hiroshima-u.ac.jp (remove space) + http://www.math.keio.ac.jp/matumoto/emt.html + email: matumoto@math.keio.ac.jp Sockets @@ -746,8 +794,8 @@ * */ - Original SSLeay License - ----------------------- + Original SSLeay License + ----------------------- /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/make.bat --- a/Doc/make.bat Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/make.bat Sun Jul 20 10:52:46 2014 -0400 @@ -34,7 +34,7 @@ goto end :checkout -svn co %SVNROOT%/external/Sphinx-1.0.7/sphinx tools/sphinx +svn co %SVNROOT%/external/Sphinx-0.6.7/sphinx tools/sphinx svn co %SVNROOT%/external/docutils-0.6/docutils tools/docutils svn co %SVNROOT%/external/Jinja-2.3.1/jinja2 tools/jinja2 svn co %SVNROOT%/external/Pygments-1.3.1/pygments tools/pygments diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/reference/compound_stmts.rst --- a/Doc/reference/compound_stmts.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/reference/compound_stmts.rst Sun Jul 20 10:52:46 2014 -0400 @@ -238,7 +238,10 @@ expression, that expression is evaluated, and the clause matches the exception if the resulting object is "compatible" with the exception. An object is compatible with an exception if it is the class or a base class of the exception -object, or a tuple containing an item compatible with the exception. +object, a tuple containing an item compatible with the exception, or, in the +(deprecated) case of string exceptions, is the raised string itself (note that +the object identities must match, i.e. it must be the same string object, not +just a string with the same value). If no except clause matches the exception, the search for an exception handler continues in the surrounding code and on the invocation stack. [#]_ @@ -294,19 +297,8 @@ is executed. If there is a saved exception, it is re-raised at the end of the :keyword:`finally` clause. If the :keyword:`finally` clause raises another exception or executes a :keyword:`return` or :keyword:`break` statement, the -saved exception is discarded:: - - >>> def f(): - ... try: - ... 1/0 - ... finally: - ... return 42 - ... - >>> f() - 42 - -The exception information is not available to the program during execution of -the :keyword:`finally` clause. +saved exception is lost. The exception information is not available to the +program during execution of the :keyword:`finally` clause. .. index:: statement: return @@ -320,20 +312,6 @@ reason is a problem with the current implementation --- this restriction may be lifted in the future). -The return value of a function is determined by the last :keyword:`return` -statement executed. Since the :keyword:`finally` clause always executes, a -:keyword:`return` statement executed in the :keyword:`finally` clause will -always be the last one executed:: - - >>> def foo(): - ... try: - ... return 'try' - ... finally: - ... return 'finally' - ... - >>> foo() - 'finally' - Additional information on exceptions can be found in section :ref:`exceptions`, and information on using the :keyword:`raise` statement to generate exceptions may be found in section :ref:`raise`. @@ -345,9 +323,7 @@ The :keyword:`with` statement ============================= -.. index:: - statement: with - single: as; with statement +.. index:: statement: with .. versionadded:: 2.5 @@ -423,9 +399,6 @@ statement. -.. index:: - single: parameter; function definition - .. _function: .. _def: @@ -450,7 +423,7 @@ funcdef: "def" `funcname` "(" [`parameter_list`] ")" ":" `suite` dotted_name: `identifier` ("." `identifier`)* parameter_list: (`defparameter` ",")* - : ( "*" `identifier` ["," "**" `identifier`] + : ( "*" `identifier` [, "**" `identifier`] : | "**" `identifier` : | `defparameter` [","] ) defparameter: `parameter` ["=" `expression`] @@ -486,15 +459,12 @@ def func(): pass func = f1(arg)(f2(func)) -.. index:: - triple: default; parameter; value - single: argument; function definition +.. index:: triple: default; parameter; value -When one or more top-level :term:`parameters ` have the form -*parameter* ``=`` *expression*, the function is said to have "default parameter -values." For a parameter with a default value, the corresponding -:term:`argument` may be omitted from a call, in which -case the parameter's default value is substituted. If a +When one or more top-level parameters have the form *parameter* ``=`` +*expression*, the function is said to have "default parameter values." For a +parameter with a default value, the corresponding argument may be omitted from a +call, in which case the parameter's default value is substituted. If a parameter has a default value, all following parameters must also have a default value --- this is a syntactic restriction that is not expressed by the grammar. @@ -525,14 +495,14 @@ the form "``**identifier``" is present, it is initialized to a new dictionary receiving any excess keyword arguments, defaulting to a new empty dictionary. -.. index:: pair: lambda; expression +.. index:: pair: lambda; form It is also possible to create anonymous functions (functions not bound to a -name), for immediate use in expressions. This uses lambda expressions, described in -section :ref:`lambda`. Note that the lambda expression is merely a shorthand for a +name), for immediate use in expressions. This uses lambda forms, described in +section :ref:`lambda`. Note that the lambda form is merely a shorthand for a simplified function definition; a function defined in a ":keyword:`def`" statement can be passed around or assigned to another name just like a function -defined by a lambda expression. The ":keyword:`def`" form is actually more powerful +defined by a lambda form. The ":keyword:`def`" form is actually more powerful since it allows the execution of multiple statements. **Programmer's note:** Functions are first-class objects. A "``def``" form diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/reference/datamodel.rst --- a/Doc/reference/datamodel.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/reference/datamodel.rst Sun Jul 20 10:52:46 2014 -0400 @@ -207,7 +207,7 @@ single: True These represent the truth values False and True. The two objects - representing the values ``False`` and ``True`` are the only Boolean objects. + representing the values False and True are the only Boolean objects. The Boolean type is a subtype of plain integers, and Boolean values behave like the values 0 and 1, respectively, in almost all contexts, the exception being that when converted to a string, the strings @@ -356,6 +356,8 @@ object: mutable sequence object: mutable pair: assignment; statement + single: delete + statement: del single: subscription single: slicing @@ -409,7 +411,7 @@ These represent a mutable set. They are created by the built-in :func:`set` constructor and can be modified afterwards by several methods, such as - :meth:`~set.add`. + :meth:`add`. Frozen sets .. index:: object: frozenset @@ -479,44 +481,47 @@ Special attributes: - .. tabularcolumns:: |l|L|l| - +-----------------------+-------------------------------+-----------+ | Attribute | Meaning | | +=======================+===============================+===========+ - | :attr:`__doc__` | The function's documentation | Writable | - | :attr:`func_doc` | string, or ``None`` if | | - | | unavailable. | | + | :attr:`func_doc` | The function's documentation | Writable | + | | string, or ``None`` if | | + | | unavailable | | +-----------------------+-------------------------------+-----------+ - | :attr:`__name__` | The function's name. | Writable | - | :attr:`func_name` | | | + | :attr:`__doc__` | Another way of spelling | Writable | + | | :attr:`func_doc` | | + +-----------------------+-------------------------------+-----------+ + | :attr:`func_name` | The function's name | Writable | + +-----------------------+-------------------------------+-----------+ + | :attr:`__name__` | Another way of spelling | Writable | + | | :attr:`func_name` | | +-----------------------+-------------------------------+-----------+ | :attr:`__module__` | The name of the module the | Writable | | | function was defined in, or | | | | ``None`` if unavailable. | | +-----------------------+-------------------------------+-----------+ - | :attr:`__defaults__` | A tuple containing default | Writable | - | :attr:`func_defaults` | argument values for those | | + | :attr:`func_defaults` | A tuple containing default | Writable | + | | argument values for those | | | | arguments that have defaults, | | | | or ``None`` if no arguments | | - | | have a default value. | | + | | have a default value | | +-----------------------+-------------------------------+-----------+ - | :attr:`__code__` | The code object representing | Writable | - | :attr:`func_code` | the compiled function body. | | + | :attr:`func_code` | The code object representing | Writable | + | | the compiled function body. | | +-----------------------+-------------------------------+-----------+ - | :attr:`__globals__` | A reference to the dictionary | Read-only | - | :attr:`func_globals` | that holds the function's | | + | :attr:`func_globals` | A reference to the dictionary | Read-only | + | | that holds the function's | | | | global variables --- the | | | | global namespace of the | | | | module in which the function | | | | was defined. | | +-----------------------+-------------------------------+-----------+ - | :attr:`__dict__` | The namespace supporting | Writable | - | :attr:`func_dict` | arbitrary function | | + | :attr:`func_dict` | The namespace supporting | Writable | + | | arbitrary function | | | | attributes. | | +-----------------------+-------------------------------+-----------+ - | :attr:`__closure__` | ``None`` or a tuple of cells | Read-only | - | :attr:`func_closure` | that contain bindings for the | | + | :attr:`func_closure` | ``None`` or a tuple of cells | Read-only | + | | that contain bindings for the | | | | function's free variables. | | +-----------------------+-------------------------------+-----------+ @@ -525,12 +530,6 @@ .. versionchanged:: 2.4 ``func_name`` is now writable. - .. versionchanged:: 2.6 - The double-underscore attributes ``__closure__``, ``__code__``, - ``__defaults__``, and ``__globals__`` were introduced as aliases for - the corresponding ``func_*`` attributes for forwards compatibility - with Python 3. - Function objects also support getting and setting arbitrary attributes, which can be used, for example, to attach metadata to functions. Regular attribute dot-notation is used to get and set such attributes. *Note that the current @@ -541,21 +540,16 @@ code object; see the description of internal types below. .. index:: + single: func_doc (function attribute) single: __doc__ (function attribute) single: __name__ (function attribute) single: __module__ (function attribute) single: __dict__ (function attribute) - single: __defaults__ (function attribute) - single: __code__ (function attribute) - single: __globals__ (function attribute) - single: __closure__ (function attribute) - single: func_doc (function attribute) - single: func_name (function attribute) - single: func_dict (function attribute) single: func_defaults (function attribute) + single: func_closure (function attribute) single: func_code (function attribute) single: func_globals (function attribute) - single: func_closure (function attribute) + single: func_dict (function attribute) pair: global; namespace User-defined methods @@ -579,7 +573,7 @@ :attr:`im_self` used to refer to the class that defined the method. .. versionchanged:: 2.6 - For Python 3 forward-compatibility, :attr:`im_func` is also available as + For 3.0 forward-compatibility, :attr:`im_func` is also available as :attr:`__func__`, and :attr:`im_self` as :attr:`__self__`. .. index:: @@ -627,8 +621,9 @@ single: im_self (method attribute) When a user-defined method object is created by retrieving a class method object - from a class or instance, its :attr:`im_self` attribute is the class itself, and - its :attr:`im_func` attribute is the function object underlying the class method. + from a class or instance, its :attr:`im_self` attribute is the class itself (the + same as the :attr:`im_class` attribute), and its :attr:`im_func` attribute is + the function object underlying the class method. When an unbound user-defined method object is called, the underlying function (:attr:`im_func`) is called, with the restriction that the first argument must @@ -665,8 +660,7 @@ :ref:`yield`) is called a :dfn:`generator function`. Such a function, when called, always returns an iterator object which can be used to execute the body of the function: calling the iterator's - :meth:`~iterator.next` method will cause the function to execute until - it provides a value + :meth:`next` method will cause the function to execute until it provides a value using the :keyword:`yield` statement. When the function executes a :keyword:`return` statement or falls off the end, a :exc:`StopIteration` exception is raised and the iterator will have reached the end of the set of @@ -801,8 +795,8 @@ associated class is either :class:`C` or one of its base classes, it is transformed into an unbound user-defined method object whose :attr:`im_class` attribute is :class:`C`. When it would yield a class method object, it is - transformed into a bound user-defined method object whose - :attr:`im_self` attribute is :class:`C`. When it would yield a + transformed into a bound user-defined method object whose :attr:`im_class` + and :attr:`im_self` attributes are both :class:`C`. When it would yield a static method object, it is transformed into the object wrapped by the static method object. See section :ref:`descriptors` for another way in which attributes retrieved from a class may differ from those actually contained in @@ -826,10 +820,10 @@ Special attributes: :attr:`__name__` is the class name; :attr:`__module__` is the module name in which the class was defined; :attr:`__dict__` is the - dictionary containing the class's namespace; :attr:`~class.__bases__` is a - tuple (possibly empty or a singleton) containing the base classes, in the - order of their occurrence in the base class list; :attr:`__doc__` is the - class's documentation string, or None if undefined. + dictionary containing the class's namespace; :attr:`__bases__` is a tuple + (possibly empty or a singleton) containing the base classes, in the order of + their occurrence in the base class list; :attr:`__doc__` is the class's + documentation string, or None if undefined. Class instances .. index:: @@ -874,8 +868,8 @@ single: __dict__ (instance attribute) single: __class__ (instance attribute) - Special attributes: :attr:`~object.__dict__` is the attribute dictionary; - :attr:`~instance.__class__` is the instance's class. + Special attributes: :attr:`__dict__` is the attribute dictionary; + :attr:`__class__` is the instance's class. Files .. index:: @@ -1074,9 +1068,9 @@ single: stop (slice object attribute) single: step (slice object attribute) - Special read-only attributes: :attr:`~slice.start` is the lower bound; - :attr:`~slice.stop` is the upper bound; :attr:`~slice.step` is the step - value; each is ``None`` if omitted. These attributes can have any type. + Special read-only attributes: :attr:`start` is the lower bound; :attr:`stop` is + the upper bound; :attr:`step` is the step value; each is ``None`` if omitted. + These attributes can have any type. Slice objects support one method: @@ -1155,7 +1149,7 @@ single: class; classic single: class; old-style -Old-style classes are removed in Python 3, leaving only the semantics of +Old-style classes are removed in Python 3.0, leaving only the semantics of new-style classes. @@ -1183,8 +1177,7 @@ the emulation only be implemented to the degree that it makes sense for the object being modelled. For example, some sequences may work well with retrieval of individual elements, but extracting a slice may not make sense. (One example -of this is the :class:`~xml.dom.NodeList` interface in the W3C's Document -Object Model.) +of this is the :class:`NodeList` interface in the W3C's Document Object Model.) .. _customization: @@ -1289,8 +1282,6 @@ modules are still available at the time when the :meth:`__del__` method is called. - See also the :option:`-R` command-line option. - .. method:: object.__repr__(self) @@ -1420,7 +1411,7 @@ User-defined classes have :meth:`__cmp__` and :meth:`__hash__` methods by default; with them, all objects compare unequal (except with themselves) - and ``x.__hash__()`` returns a result derived from ``id(x)``. + and ``x.__hash__()`` returns ``id(x)``. Classes which inherit a :meth:`__hash__` method from a parent class but change the meaning of :meth:`__cmp__` or :meth:`__eq__` such that the hash @@ -1816,10 +1807,10 @@ :pep:`3119` - Introducing Abstract Base Classes Includes the specification for customizing :func:`isinstance` and - :func:`issubclass` behavior through :meth:`~class.__instancecheck__` and - :meth:`~class.__subclasscheck__`, with motivation for this functionality - in the context of adding Abstract Base Classes (see the :mod:`abc` - module) to the language. + :func:`issubclass` behavior through :meth:`__instancecheck__` and + :meth:`__subclasscheck__`, with motivation for this functionality in the + context of adding Abstract Base Classes (see the :mod:`abc` module) to the + language. .. _callable-types: @@ -1852,7 +1843,7 @@ is also recommended that mappings provide the methods :meth:`keys`, :meth:`values`, :meth:`items`, :meth:`has_key`, :meth:`get`, :meth:`clear`, :meth:`setdefault`, :meth:`iterkeys`, :meth:`itervalues`, :meth:`iteritems`, -:meth:`pop`, :meth:`popitem`, :meth:`!copy`, and :meth:`update` behaving similar +:meth:`pop`, :meth:`popitem`, :meth:`copy`, and :meth:`update` behaving similar to those for Python's standard dictionary objects. The :mod:`UserDict` module provides a :class:`DictMixin` class to help create those methods from a base set of :meth:`__getitem__`, :meth:`__setitem__`, :meth:`__delitem__`, and @@ -2242,7 +2233,7 @@ This section used to document the rules for coercion. As the language has evolved, the coercion rules have become hard to document precisely; documenting what one version of one particular implementation does is undesirable. Instead, -here are some informal guidelines regarding coercion. In Python 3, coercion +here are some informal guidelines regarding coercion. In Python 3.0, coercion will not be supported. * diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/reference/expressions.rst --- a/Doc/reference/expressions.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/reference/expressions.rst Sun Jul 20 10:52:46 2014 -0400 @@ -96,13 +96,14 @@ definition begins with two or more underscore characters and does not end in two or more underscores, it is considered a :dfn:`private name` of that class. Private names are transformed to a longer form before code is generated for -them. The transformation inserts the class name, with leading underscores -removed and a single underscore inserted, in front of the name. For example, -the identifier ``__spam`` occurring in a class named ``Ham`` will be transformed -to ``_Ham__spam``. This transformation is independent of the syntactical -context in which the identifier is used. If the transformed name is extremely -long (longer than 255 characters), implementation defined truncation may happen. -If the class name consists only of underscores, no transformation is done. +them. The transformation inserts the class name in front of the name, with +leading underscores removed, and a single underscore inserted in front of the +class name. For example, the identifier ``__spam`` occurring in a class named +``Ham`` will be transformed to ``_Ham__spam``. This transformation is +independent of the syntactical context in which the identifier is used. If the +transformed name is extremely long (longer than 255 characters), implementation +defined truncation may happen. If the class name consists only of underscores, +no transformation is done. @@ -184,7 +185,7 @@ list_comprehension: `expression` `list_for` list_for: "for" `target_list` "in" `old_expression_list` [`list_iter`] old_expression_list: `old_expression` [("," `old_expression`)+ [","]] - old_expression: `or_test` | `old_lambda_expr` + old_expression: `or_test` | `old_lambda_form` list_iter: `list_for` | `list_if` list_if: "if" `old_expression` [`list_iter`] @@ -420,18 +421,10 @@ .. index:: object: generator - -Generator-iterator methods -^^^^^^^^^^^^^^^^^^^^^^^^^^ - -This subsection describes the methods of a generator iterator. They can -be used to control the execution of a generator function. - -Note that calling any of the generator methods below when the generator -is already executing raises a :exc:`ValueError` exception. +The following generator's methods can be used to control the execution of a +generator function: .. index:: exception: StopIteration -.. class:: generator .. method:: generator.next() @@ -445,7 +438,6 @@ exits without yielding another value, a :exc:`StopIteration` exception is raised. -.. class:: . .. method:: generator.send(value) @@ -662,24 +654,23 @@ conversion of the lone slice item is the key. The conversion of a slice item that is an expression is that expression. The conversion of an ellipsis slice item is the built-in ``Ellipsis`` object. The conversion of a proper slice is a -slice object (see section :ref:`types`) whose :attr:`~slice.start`, -:attr:`~slice.stop` and :attr:`~slice.step` attributes are the values of the -expressions given as lower bound, upper bound and stride, respectively, -substituting ``None`` for missing expressions. +slice object (see section :ref:`types`) whose :attr:`start`, :attr:`stop` and +:attr:`step` attributes are the values of the expressions given as lower bound, +upper bound and stride, respectively, substituting ``None`` for missing +expressions. -.. index:: - object: callable - single: call - single: argument; call semantics - .. _calls: Calls ----- -A call calls a callable object (e.g., a :term:`function`) with a possibly empty -series of :term:`arguments `: +.. index:: single: call + +.. index:: object: callable + +A call calls a callable object (e.g., a function) with a possibly empty series +of arguments: .. productionlist:: call: `primary` "(" [`argument_list` [","] @@ -698,15 +689,12 @@ A trailing comma may be present after the positional and keyword arguments but does not affect the semantics. -.. index:: - single: parameter; call semantics - The primary must evaluate to a callable object (user-defined functions, built-in functions, methods of built-in objects, class objects, methods of class instances, and certain class instances themselves are callable; extensions may define additional callable object types). All argument expressions are evaluated before the call is attempted. Please refer to section :ref:`function` -for the syntax of formal :term:`parameter` lists. +for the syntax of formal parameter lists. If keyword arguments are present, they are first converted to positional arguments, as follows. First, a list of unfilled slots is created for the @@ -731,7 +719,7 @@ An implementation may provide built-in functions whose positional parameters do not have names, even if they are 'named' for the purpose of documentation, and which therefore cannot be supplied by keyword. In CPython, this is the - case for functions implemented in C that use :c:func:`PyArg_ParseTuple` to + case for functions implemented in C that use :cfunc:`PyArg_ParseTuple` to parse their arguments. If there are more positional arguments than there are formal parameter slots, a @@ -1060,9 +1048,9 @@ .. _comparisons: .. _is: -.. _is not: +.. _isnot: .. _in: -.. _not in: +.. _notin: Comparisons =========== @@ -1257,7 +1245,7 @@ .. productionlist:: conditional_expression: `or_test` ["if" `or_test` "else" `expression`] - expression: `conditional_expression` | `lambda_expr` + expression: `conditional_expression` | `lambda_form` Conditional expressions (sometimes called a "ternary operator") have the lowest priority of all Python operations. @@ -1277,13 +1265,14 @@ .. index:: pair: lambda; expression + pair: lambda; form pair: anonymous; function .. productionlist:: - lambda_expr: "lambda" [`parameter_list`]: `expression` - old_lambda_expr: "lambda" [`parameter_list`]: `old_expression` + lambda_form: "lambda" [`parameter_list`]: `expression` + old_lambda_form: "lambda" [`parameter_list`]: `old_expression` -Lambda expressions (sometimes called lambda forms) have the same syntactic position as +Lambda forms (lambda expressions) have the same syntactic position as expressions. They are a shorthand to create anonymous functions; the expression ``lambda arguments: expression`` yields a function object. The unnamed object behaves like a function object defined with :: @@ -1292,7 +1281,7 @@ return expression See section :ref:`function` for the syntax of parameter lists. Note that -functions created with lambda expressions cannot contain statements. +functions created with lambda forms cannot contain statements. .. _exprlists: @@ -1343,8 +1332,8 @@ .. _operator-summary: -Operator precedence -=================== +Summary +======= .. index:: pair: operator; precedence @@ -1367,10 +1356,10 @@ +-----------------------------------------------+-------------------------------------+ | :keyword:`and` | Boolean AND | +-----------------------------------------------+-------------------------------------+ -| :keyword:`not` ``x`` | Boolean NOT | +| :keyword:`not` *x* | Boolean NOT | +-----------------------------------------------+-------------------------------------+ -| :keyword:`in`, :keyword:`not in`, | Comparisons, including membership | -| :keyword:`is`, :keyword:`is not`, ``<``, | tests and identity tests | +| :keyword:`in`, :keyword:`not` :keyword:`in`, | Comparisons, including membership | +| :keyword:`is`, :keyword:`is not`, ``<``, | tests and identity tests, | | ``<=``, ``>``, ``>=``, ``<>``, ``!=``, ``==`` | | +-----------------------------------------------+-------------------------------------+ | ``|`` | Bitwise OR | @@ -1395,7 +1384,7 @@ +-----------------------------------------------+-------------------------------------+ | ``(expressions...)``, | Binding or tuple display, | | ``[expressions...]``, | list display, | -| ``{key: value...}``, | dictionary display, | +| ``{key:datum...}``, | dictionary display, | | ```expressions...``` | string conversion | +-----------------------------------------------+-------------------------------------+ @@ -1403,7 +1392,7 @@ .. [#] In Python 2.3 and later releases, a list comprehension "leaks" the control variables of each ``for`` it contains into the containing scope. However, this - behavior is deprecated, and relying on it will not work in Python 3. + behavior is deprecated, and relying on it will not work in Python 3.0 .. [#] While ``abs(x%y) < abs(y)`` is true mathematically, for floats it may not be true numerically due to roundoff. For example, and assuming a platform on which diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/reference/index.rst --- a/Doc/reference/index.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/reference/index.rst Sun Jul 20 10:52:46 2014 -0400 @@ -4,6 +4,9 @@ The Python Language Reference ################################# +:Release: |version| +:Date: |today| + This reference manual describes the syntax and "core semantics" of the language. It is terse, but attempts to be exact and complete. The semantics of non-essential built-in object types and of the built-in functions and modules diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/reference/introduction.rst --- a/Doc/reference/introduction.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/reference/introduction.rst Sun Jul 20 10:52:46 2014 -0400 @@ -65,7 +65,7 @@ An alternate Python for .NET. Unlike Python.NET, this is a complete Python implementation that generates IL, and compiles Python code directly to .NET assemblies. It was created by Jim Hugunin, the original creator of Jython. For - more information, see `the IronPython website `_. + more information, see `the IronPython website `_. PyPy An implementation of Python written completely in Python. It supports several diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/reference/lexical_analysis.rst --- a/Doc/reference/lexical_analysis.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/reference/lexical_analysis.rst Sun Jul 20 10:52:46 2014 -0400 @@ -104,7 +104,9 @@ Encoding declarations --------------------- -.. index:: source character set, encoding declarations (source file) +.. index:: + single: source character set + single: encodings If a comment in the first or second line of the Python script matches the regular expression ``coding[=:]\s*([-\w.]+)``, this comment is processed as an @@ -355,11 +357,11 @@ assign a different object to it. .. versionchanged:: 2.5 - Using :keyword:`as` and :keyword:`with` as identifiers triggers a warning. To - use them as keywords, enable the ``with_statement`` future feature . - -.. versionchanged:: 2.6 - :keyword:`as` and :keyword:`with` are full keywords. + Both :keyword:`as` and :keyword:`with` are only recognized when the + ``with_statement`` future feature has been enabled. It will always be enabled in + Python 2.6. See section :ref:`with` for details. Note that using :keyword:`as` + and :keyword:`with` as identifiers will always issue a warning, even when the + ``with_statement`` future directive is not in effect. .. _id-classes: @@ -527,7 +529,8 @@ (2) Any Unicode character can be encoded this way, but characters outside the Basic Multilingual Plane (BMP) will be encoded using a surrogate pair if Python is - compiled to use 16-bit code units (the default). + compiled to use 16-bit code units (the default). Individual code units which + form parts of a surrogate pair can be encoded using this escape sequence. (3) As in Standard C, up to three octal digits are accepted. diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/reference/simple_stmts.rst --- a/Doc/reference/simple_stmts.rst Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/reference/simple_stmts.rst Sun Jul 20 10:52:46 2014 -0400 @@ -72,7 +72,6 @@ ===================== .. index:: - single: =; assignment statement pair: assignment; statement pair: binding; name pair: rebinding; name @@ -242,18 +241,6 @@ .. index:: pair: augmented; assignment single: statement; assignment, augmented - single: +=; augmented assignment - single: -=; augmented assignment - single: *=; augmented assignment - single: /=; augmented assignment - single: %=; augmented assignment - single: &=; augmented assignment - single: ^=; augmented assignment - single: |=; augmented assignment - single: **=; augmented assignment - single: //=; augmented assignment - single: >>=; augmented assignment - single: <<=; augmented assignment Augmented assignment is the combination, in a single statement, of a binary operation and an assignment statement: @@ -365,7 +352,7 @@ del_stmt: "del" `target_list` Deletion is recursively defined very similar to the way assignment is defined. -Rather than spelling it out in full details, here are some hints. +Rather that spelling it out in full details, here are some hints. Deletion of a target list recursively deletes each target, from left to right. @@ -524,9 +511,6 @@ :meth:`close` method will be called, allowing any pending :keyword:`finally` clauses to execute. -For full details of :keyword:`yield` semantics, refer to the :ref:`yieldexpr` -section. - .. note:: In Python 2.2, the :keyword:`yield` statement was only allowed when the @@ -666,7 +650,6 @@ single: module; importing pair: name; binding keyword: from - single: as; import statement .. productionlist:: import_stmt: "import" `module` ["as" `name`] ( "," `module` ["as" `name`] )* @@ -723,7 +706,7 @@ second argument to :meth:`find_module` is given as the value of the :attr:`__path__` attribute from the parent package (everything up to the last dot in the name of the module being imported). If a finder can find the module -it returns a :term:`loader` (discussed later) or returns ``None``. +it returns a :term:`loader` (discussed later) or returns :keyword:`None`. .. index:: single: sys.path_hooks @@ -750,11 +733,11 @@ the list with a single argument of the path, returning a finder or raises :exc:`ImportError`. If a finder is returned then it is cached in :data:`sys.path_importer_cache` and then used for that path entry. If no finder -can be found but the path exists then a value of ``None`` is +can be found but the path exists then a value of :keyword:`None` is stored in :data:`sys.path_importer_cache` to signify that an implicit, file-based finder that handles modules stored as individual files should be used for that path. If the path does not exist then a finder which always -returns ``None`` is placed in the cache for the path. +returns :keyword:`None` is placed in the cache for the path. .. index:: single: loader @@ -995,32 +978,21 @@ exec_stmt: "exec" `or_expr` ["in" `expression` ["," `expression`]] This statement supports dynamic execution of Python code. The first expression -should evaluate to either a Unicode string, a *Latin-1* encoded string, an open -file object, a code object, or a tuple. If it is a string, the string is parsed -as a suite of Python statements which is then executed (unless a syntax error -occurs). [#]_ If it is an open file, the file is parsed until EOF and executed. -If it is a code object, it is simply executed. For the interpretation of a -tuple, see below. In all cases, the code that's executed is expected to be -valid as file input (see section :ref:`file-input`). Be aware that the +should evaluate to either a string, an open file object, or a code object. If +it is a string, the string is parsed as a suite of Python statements which is +then executed (unless a syntax error occurs). [#]_ If it is an open file, the file +is parsed until EOF and executed. If it is a code object, it is simply +executed. In all cases, the code that's executed is expected to be valid as +file input (see section :ref:`file-input`). Be aware that the :keyword:`return` and :keyword:`yield` statements may not be used outside of function definitions even within the context of code passed to the :keyword:`exec` statement. In all cases, if the optional parts are omitted, the code is executed in the -current scope. If only the first expression after ``in`` is specified, +current scope. If only the first expression after :keyword:`in` is specified, it should be a dictionary, which will be used for both the global and the local variables. If two expressions are given, they are used for the global and local variables, respectively. If provided, *locals* can be any mapping object. -Remember that at module level, globals and locals are the same dictionary. If -two separate objects are given as *globals* and *locals*, the code will be -executed as if it were embedded in a class definition. - -The first expression may also be a tuple of length 2 or 3. In this case, the -optional parts must be omitted. The form ``exec(expr, globals)`` is equivalent -to ``exec expr in globals``, while the form ``exec(expr, globals, locals)`` is -equivalent to ``exec expr in globals, locals``. The tuple form of ``exec`` -provides compatibility with Python 3, where ``exec`` is a function rather than -a statement. .. versionchanged:: 2.4 Formerly, *locals* was required to be a dictionary. @@ -1049,5 +1021,5 @@ .. rubric:: Footnotes .. [#] Note that the parser only accepts the Unix-style end of line convention. - If you are reading the code from a file, make sure to use - :term:`universal newlines` mode to convert Windows or Mac-style newlines. + If you are reading the code from a file, make sure to use universal + newline mode to convert Windows or Mac-style newlines. diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/tools/dailybuild.py --- a/Doc/tools/dailybuild.py Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/tools/dailybuild.py Sun Jul 20 10:52:46 2014 -0400 @@ -5,12 +5,12 @@ # # Usages: # -# dailybuild.py [-q] +# dailybuild.py # # without any arguments builds docs for all branches configured in the global -# BRANCHES value. -q selects "quick build", which means to build only HTML. +# BRANCHES value. # -# dailybuild.py [-q] [-d] +# dailybuild.py [-d] # # builds one version, where is an SVN checkout directory of the # Python branch to build docs for, and is the directory where the @@ -29,79 +29,31 @@ BUILDROOT = '/home/gbrandl/docbuild' -SPHINXBUILD = os.path.join(BUILDROOT, 'sphinx-env/bin/sphinx-build') WWWROOT = '/data/ftp.python.org/pub/docs.python.org' BRANCHES = [ # checkout, target, isdev - (BUILDROOT + '/python34', WWWROOT + '/3.4', False), - (BUILDROOT + '/python35', WWWROOT + '/3.5', True), - (BUILDROOT + '/python27', WWWROOT + '/2.7', False), + (BUILDROOT + '/python33', WWWROOT + '/dev', True), + (BUILDROOT + '/python27', WWWROOT, False), + (BUILDROOT + '/python32', WWWROOT + '/py3k', False), ] -def _files_changed(old, new): - with open(old, 'rb') as fp1, open(new, 'rb') as fp2: - st1 = os.fstat(fp1.fileno()) - st2 = os.fstat(fp2.fileno()) - if st1.st_size != st2.st_size: - return False - if st1.st_mtime >= st2.st_mtime: - return True - while True: - one = fp1.read(4096) - two = fp2.read(4096) - if one != two: - return False - if one == '': - break - return True - -def build_one(checkout, target, isdev, quick): +def build_one(checkout, target, isdev): print 'Doc autobuild started in %s' % checkout os.chdir(checkout) - print 'Running hg pull --update' - os.system('hg pull --update') + print 'Running svn update' + os.system('svn update') print 'Running make autobuild' - maketarget = 'autobuild-' + ('html' if quick else - ('dev' if isdev else 'stable')) - if os.WEXITSTATUS(os.system('cd Doc; make SPHINXBUILD=%s %s' % (SPHINXBUILD, maketarget))) == 2: + if os.WEXITSTATUS(os.system( + 'cd Doc; make autobuild-%s' % (isdev and 'dev' or 'stable'))) == 2: print '*' * 80 return - print('Computing changed files') - changed = [] - for dirpath, dirnames, filenames in os.walk('Doc/build/html/'): - dir_rel = dirpath[len('Doc/build/html/'):] - for fn in filenames: - local_path = os.path.join(dirpath, fn) - rel_path = os.path.join(dir_rel, fn) - target_path = os.path.join(target, rel_path) - if (os.path.exists(target_path) and - not _files_changed(target_path, local_path)): - changed.append(rel_path) - print 'Copying HTML files to %s' % target + print 'Copying HTML files' os.system('cp -a Doc/build/html/* %s' % target) - if not quick: - print 'Copying dist files' - os.system('mkdir -p %s/archives' % target) - os.system('cp -a Doc/dist/* %s/archives' % target) - changed.append('archives/') - for fn in os.listdir(os.path.join(target, 'archives')): - changed.append('archives/' + fn) - print '%s files changed' % len(changed) - if changed: - target_ino = os.stat(target).st_ino - targets_dir = os.path.dirname(target) - prefixes = [] - for fn in os.listdir(targets_dir): - if os.stat(os.path.join(targets_dir, fn)).st_ino == target_ino: - prefixes.append(fn) - to_purge = [] - for prefix in prefixes: - to_purge.extend(prefix + "/" + p for p in changed) - purge_cmd = 'curl -X PURGE "https://docs.python.org/{%s}"' % ','.join(to_purge) - print("Running CDN purge") - os.system(purge_cmd) + print 'Copying dist files' + os.system('mkdir -p %s/archives' % target) + os.system('cp -a Doc/dist/* %s/archives' % target) print 'Finished' print '=' * 80 @@ -115,21 +67,15 @@ if __name__ == '__main__': try: - opts, args = getopt.getopt(sys.argv[1:], 'dq') + opts, args = getopt.getopt(sys.argv[1:], 'd') except getopt.error: usage() - quick = devel = False - for opt, _ in opts: - if opt == '-q': - quick = True - if opt == '-d': - devel = True - if devel and not args: + if opts and not args: usage() if args: if len(args) != 2: usage() - build_one(os.path.abspath(args[0]), os.path.abspath(args[1]), devel, quick) + build_one(args[0], args[1], bool(opts)) else: - for checkout, dest, devel in BRANCHES: - build_one(checkout, dest, devel, quick) + for branch in BRANCHES: + build_one(*branch) diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/tools/sphinx-build.py --- a/Doc/tools/sphinx-build.py Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/tools/sphinx-build.py Sun Jul 20 10:52:46 2014 -0400 @@ -15,13 +15,13 @@ if __name__ == '__main__': - if sys.version_info[:3] < (2, 4, 0) or sys.version_info[:3] > (3, 0, 0): - sys.stderr.write("""\ -Error: Sphinx needs to be executed with Python 2.4 or newer (not 3.x though). + if sys.version_info[:3] < (2, 4, 0): + print >>sys.stderr, """\ +Error: Sphinx needs to be executed with Python 2.4 or newer (If you run this from the Makefile, you can set the PYTHON variable to the path of an alternative interpreter executable, e.g., ``make html PYTHON=python2.5``). -""") +""" sys.exit(1) from sphinx import main diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/tools/sphinxext/download.html --- a/Doc/tools/sphinxext/download.html Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/tools/sphinxext/download.html Sun Jul 20 10:52:46 2014 -0400 @@ -35,13 +35,9 @@ +

These archives contain all the content in the documentation.

-

HTML Help (.chm) files are made available in the "Windows" section -on the Python -download page.

- -

Unpacking

Unix users should download the .tar.bz2 archives; these are bzipped tar diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/tools/sphinxext/indexcontent.html --- a/Doc/tools/sphinxext/indexcontent.html Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/tools/sphinxext/indexcontent.html Sun Jul 20 10:52:46 2014 -0400 @@ -24,6 +24,8 @@ information for installers & sys-admins

+ @@ -32,7 +34,7 @@

Indices and tables:

- diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/tools/sphinxext/indexsidebar.html --- a/Doc/tools/sphinxext/indexsidebar.html Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/tools/sphinxext/indexsidebar.html Sun Jul 20 10:52:46 2014 -0400 @@ -1,17 +1,23 @@ -

Download

-

Download these documents

-

Docs for other versions

- +

Download

+

Download these documents

+

Docs for other versions

+ -

Other resources

- +

Other resources

+ diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Doc/tools/sphinxext/layout.html --- a/Doc/tools/sphinxext/layout.html Sat Jul 19 16:34:33 2014 -0700 +++ b/Doc/tools/sphinxext/layout.html Sun Jul 20 10:52:46 2014 -0400 @@ -2,35 +2,18 @@ {% block rootrellink %}
  • -
  • Python{{ reldelim1 }}
  • -
  • - {%- if versionswitcher is defined %} - {{ release }} - Documentation{{ reldelim1 }} - {%- else %} - {{ shorttitle }}{{ reldelim1 }} - {%- endif %} -
  • +
  • {{ shorttitle }}{{ reldelim1 }}
  • {% endblock %} -{% block relbar1 %} {% if builder != 'qthelp' %} {{ relbar() }} {% endif %} {% endblock %} -{% block relbar2 %} {% if builder != 'qthelp' %} {{ relbar() }} {% endif %} {% endblock %} {% block extrahead %} - {% if not embedded %}{% endif %} - {% if versionswitcher is defined and not embedded %}{% endif %} + {{ super() }} - {% if builder == 'qthelp' %} - - {% endif %} {% endblock %} {% block footer %}

    ' - '


    ') - expected = [('starttag', 'br', []), - # < is part of the name, / is discarded, p is an attribute - ('endtag', 'label<'), - ('starttag', 'br', []), - # text and attributes are discarded - ('endtag', 'div'), - ('starttag', 'br', []), - # comment because the first char after is ignored - ('starttag', 'br', [])] - self._run_check(html, expected) - - def test_broken_invalid_end_tag(self): - # This is technically wrong (the "> shouldn't be included in the 'data') - # but is probably not worth fixing it (in addition to all the cases of - # the previous test, it would require a full attribute parsing). - # see #13993 - html = 'This confuses the parser' - expected = [('starttag', 'b', []), - ('data', 'This'), - ('endtag', 'b'), - ('data', '"> confuses the parser')] - self._run_check(html, expected) - def test_get_starttag_text(self): s = """""" self._run_check_extra(s, [ @@ -394,12 +313,6 @@ ("data", "&#bad;"), ("endtag", "p"), ]) - # add the [] as a workaround to avoid buffering (see #20288) - self._run_check(["
    &#bad;
    "], [ - ("starttag", "div", []), - ("data", "&#bad;"), - ("endtag", "div"), - ]) def test_unescape_function(self): parser = HTMLParser.HTMLParser() @@ -536,81 +449,6 @@ [("href", "http://www.example.org/\">;")]), ("data", "spam"), ("endtag", "a")]) - def test_comments(self): - html = ("" - '' - '' - '' - '' - '' - '') - expected = [('comment', " I'm a valid comment "), - ('comment', 'me too!'), - ('comment', '--'), - ('comment', ''), - ('comment', '--I have many hyphens--'), - ('comment', ' I have a > in the middle '), - ('comment', ' and I have -- in the middle! ')] - self._run_check(html, expected) - - def test_broken_comments(self): - html = ('' - '' - '' - '' - '') - expected = [ - ('comment', ' not really a comment '), - ('comment', ' not a comment either --'), - ('comment', ' -- close enough --'), - ('comment', ''), - ('comment', '<-- this was an empty comment'), - ('comment', '!! another bogus comment !!!'), - ] - self._run_check(html, expected) - - def test_condcoms(self): - html = ('' - '' - '') - expected = [('comment', "[if IE & !(lte IE 8)]>aren'tcondcomspretty?' - html = ('broken condcom' - '' - '' - 'foo' - '') - # According to the HTML5 specs sections "8.2.4.44 Bogus comment state" - # and "8.2.4.45 Markup declaration open state", comment tokens should - # be emitted instead of 'unknown decl', but calling unknown_decl - # provides more flexibility. - # See also Lib/_markupbase.py:parse_declaration - expected = [ - ('unknown decl', 'if !(IE)'), - ('data', 'broken condcom'), - ('unknown decl', 'endif'), - ('unknown decl', 'if ! IE'), - ('startendtag', 'link', [('href', 'favicon.tiff')]), - ('unknown decl', 'endif'), - ('unknown decl', 'if !IE 6'), - ('startendtag', 'img', [('src', 'firefox.png')]), - ('unknown decl', 'endif'), - ('unknown decl', 'if !ie 6'), - ('starttag', 'b', []), - ('data', 'foo'), - ('endtag', 'b'), - ('unknown decl', 'endif'), - ('unknown decl', 'if (!IE)|(lt IE 9)'), - ('startendtag', 'img', [('src', 'mammoth.bmp')]), - ('unknown decl', 'endif') - ] - self._run_check(html, expected) - def test_main(): test_support.run_unittest(HTMLParserTestCase, AttributesTestCase) diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Lib/test/test_httplib.py --- a/Lib/test/test_httplib.py Sat Jul 19 16:34:33 2014 -0700 +++ b/Lib/test/test_httplib.py Sun Jul 20 10:52:46 2014 -0400 @@ -13,12 +13,10 @@ HOST = test_support.HOST class FakeSocket: - def __init__(self, text, fileclass=StringIO.StringIO, host=None, port=None): + def __init__(self, text, fileclass=StringIO.StringIO): self.text = text self.fileclass = fileclass self.data = '' - self.host = host - self.port = port def sendall(self, data): self.data += ''.join(data) @@ -28,9 +26,6 @@ raise httplib.UnimplementedFileMode() return self.fileclass(self.text) - def close(self): - pass - class EPipeSocket(FakeSocket): def __init__(self, text, pipe_trigger): @@ -95,40 +90,12 @@ conn.request('POST', '/', body, headers) self.assertEqual(conn._buffer.count[header.lower()], 1) - def test_content_length_0(self): - - class ContentLengthChecker(list): - def __init__(self): - list.__init__(self) - self.content_length = None - def append(self, item): - kv = item.split(':', 1) - if len(kv) > 1 and kv[0].lower() == 'content-length': - self.content_length = kv[1].strip() - list.append(self, item) - - # POST with empty body - conn = httplib.HTTPConnection('example.com') - conn.sock = FakeSocket(None) - conn._buffer = ContentLengthChecker() - conn.request('POST', '/', '') - self.assertEqual(conn._buffer.content_length, '0', - 'Header Content-Length not set') - - # PUT request with empty body - conn = httplib.HTTPConnection('example.com') - conn.sock = FakeSocket(None) - conn._buffer = ContentLengthChecker() - conn.request('PUT', '/', '') - self.assertEqual(conn._buffer.content_length, '0', - 'Header Content-Length not set') - def test_putheader(self): conn = httplib.HTTPConnection('example.com') conn.sock = FakeSocket(None) conn.putrequest('GET','/') conn.putheader('Content-length',42) - self.assertIn('Content-length: 42', conn._buffer) + self.assertTrue('Content-length: 42' in conn._buffer) def test_ipv6host_header(self): # Default host header on IPv6 transaction should wrapped by [] if @@ -158,8 +125,6 @@ sock = FakeSocket(body) resp = httplib.HTTPResponse(sock) resp.begin() - self.assertEqual(resp.read(0), '') # Issue #20007 - self.assertFalse(resp.isclosed()) self.assertEqual(resp.read(), 'Text') self.assertTrue(resp.isclosed()) @@ -173,7 +138,7 @@ self.assertEqual(repr(exc), '''BadStatusLine("\'\'",)''') def test_partial_reads(self): - # if we have a length, the system knows when to close itself + # if we have a lenght, the system knows when to close itself # same behaviour than when we read the whole thing with read() body = "HTTP/1.1 200 Ok\r\nContent-Length: 4\r\n\r\nText" sock = FakeSocket(body) @@ -184,32 +149,6 @@ self.assertEqual(resp.read(2), 'xt') self.assertTrue(resp.isclosed()) - def test_partial_reads_no_content_length(self): - # when no length is present, the socket should be gracefully closed when - # all data was read - body = "HTTP/1.1 200 Ok\r\n\r\nText" - sock = FakeSocket(body) - resp = httplib.HTTPResponse(sock) - resp.begin() - self.assertEqual(resp.read(2), 'Te') - self.assertFalse(resp.isclosed()) - self.assertEqual(resp.read(2), 'xt') - self.assertEqual(resp.read(1), '') - self.assertTrue(resp.isclosed()) - - def test_partial_reads_incomplete_body(self): - # if the server shuts down the connection before the whole - # content-length is delivered, the socket is gracefully closed - body = "HTTP/1.1 200 Ok\r\nContent-Length: 10\r\n\r\nText" - sock = FakeSocket(body) - resp = httplib.HTTPResponse(sock) - resp.begin() - self.assertEqual(resp.read(2), 'Te') - self.assertFalse(resp.isclosed()) - self.assertEqual(resp.read(2), 'xt') - self.assertEqual(resp.read(1), '') - self.assertTrue(resp.isclosed()) - def test_host_port(self): # Check invalid host_port @@ -340,7 +279,7 @@ resp = httplib.HTTPResponse(sock, method="GET") resp.begin() self.assertEqual(resp.read(), 'Hello\r\n') - self.assertTrue(resp.isclosed()) + resp.close() def test_incomplete_read(self): sock = FakeSocket('HTTP/1.1 200 OK\r\nContent-Length: 10\r\n\r\nHello\r\n') @@ -354,9 +293,10 @@ "IncompleteRead(7 bytes read, 3 more expected)") self.assertEqual(str(i), "IncompleteRead(7 bytes read, 3 more expected)") - self.assertTrue(resp.isclosed()) else: self.fail('IncompleteRead expected') + finally: + resp.close() def test_epipe(self): sock = EPipeSocket( @@ -409,14 +349,6 @@ resp.begin() self.assertRaises(httplib.LineTooLong, resp.read) - def test_early_eof(self): - # Test httpresponse with no \r\n termination, - body = "HTTP/1.1 200 Ok" - sock = FakeSocket(body) - resp = httplib.HTTPResponse(sock) - resp.begin() - self.assertEqual(resp.read(), '') - self.assertTrue(resp.isclosed()) class OfflineTest(TestCase): def test_responses(self): @@ -471,7 +403,7 @@ HTTPConnection and into the socket. ''' # default -- use global socket timeout - self.assertIsNone(socket.getdefaulttimeout()) + self.assertTrue(socket.getdefaulttimeout() is None) socket.setdefaulttimeout(30) try: httpConn = httplib.HTTPConnection(HOST, TimeoutTest.PORT) @@ -482,7 +414,7 @@ httpConn.close() # no timeout -- do not use global socket default - self.assertIsNone(socket.getdefaulttimeout()) + self.assertTrue(socket.getdefaulttimeout() is None) socket.setdefaulttimeout(30) try: httpConn = httplib.HTTPConnection(HOST, TimeoutTest.PORT, @@ -531,48 +463,9 @@ self.fail("Port incorrectly parsed: %s != %s" % (p, c.host)) -class TunnelTests(TestCase): - def test_connect(self): - response_text = ( - 'HTTP/1.0 200 OK\r\n\r\n' # Reply to CONNECT - 'HTTP/1.1 200 OK\r\n' # Reply to HEAD - 'Content-Length: 42\r\n\r\n' - ) - - def create_connection(address, timeout=None, source_address=None): - return FakeSocket(response_text, host=address[0], port=address[1]) - - conn = httplib.HTTPConnection('proxy.com') - conn._create_connection = create_connection - - # Once connected, we should not be able to tunnel anymore - conn.connect() - self.assertRaises(RuntimeError, conn.set_tunnel, 'destination.com') - - # But if close the connection, we are good. - conn.close() - conn.set_tunnel('destination.com') - conn.request('HEAD', '/', '') - - self.assertEqual(conn.sock.host, 'proxy.com') - self.assertEqual(conn.sock.port, 80) - self.assertTrue('CONNECT destination.com' in conn.sock.data) - self.assertTrue('Host: destination.com' in conn.sock.data) - - self.assertTrue('Host: proxy.com' not in conn.sock.data) - - conn.close() - - conn.request('PUT', '/', '') - self.assertEqual(conn.sock.host, 'proxy.com') - self.assertEqual(conn.sock.port, 80) - self.assertTrue('CONNECT destination.com' in conn.sock.data) - self.assertTrue('Host: destination.com' in conn.sock.data) - - def test_main(verbose=None): test_support.run_unittest(HeaderTests, OfflineTest, BasicTest, TimeoutTest, - HTTPSTimeoutTest, SourceAddressTest, TunnelTests) + HTTPSTimeoutTest, SourceAddressTest) if __name__ == '__main__': test_main() diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Lib/test/test_httpservers.py --- a/Lib/test/test_httpservers.py Sat Jul 19 16:34:33 2014 -0700 +++ b/Lib/test/test_httpservers.py Sun Jul 20 10:52:46 2014 -0400 @@ -4,6 +4,11 @@ Josip Dzolonga, and Michael Otteneder for the 2007/08 GHOP contest. """ +from BaseHTTPServer import BaseHTTPRequestHandler, HTTPServer +from SimpleHTTPServer import SimpleHTTPRequestHandler +from CGIHTTPServer import CGIHTTPRequestHandler +import CGIHTTPServer + import os import sys import re @@ -12,17 +17,12 @@ import urllib import httplib import tempfile + import unittest -import CGIHTTPServer +from StringIO import StringIO -from BaseHTTPServer import BaseHTTPRequestHandler, HTTPServer -from SimpleHTTPServer import SimpleHTTPRequestHandler -from CGIHTTPServer import CGIHTTPRequestHandler -from StringIO import StringIO from test import test_support - - threading = test_support.import_module('threading') @@ -43,7 +43,7 @@ self.end_headers() self.wfile.write(b'Data\r\n') - def log_message(self, fmt, *args): + def log_message(self, format, *args): pass @@ -97,9 +97,9 @@ self.handler = SocketlessRequestHandler() def send_typical_request(self, message): - input_msg = StringIO(message) + input = StringIO(message) output = StringIO() - self.handler.rfile = input_msg + self.handler.rfile = input self.handler.wfile = output self.handler.handle_one_request() output.seek(0) @@ -114,7 +114,7 @@ def verify_http_server_response(self, response): match = self.HTTPResponseMatch.search(response) - self.assertIsNotNone(match) + self.assertTrue(match is not None) def test_http_1_1(self): result = self.send_typical_request('GET / HTTP/1.1\r\n\r\n') @@ -189,7 +189,7 @@ def test_request_line_trimming(self): self.con._http_vsn_str = 'HTTP/1.1\n' - self.con.putrequest('XYZBOGUS', '/') + self.con.putrequest('GET', '/') self.con.endheaders() res = self.con.getresponse() self.assertEqual(res.status, 501) @@ -216,9 +216,8 @@ self.assertEqual(res.status, 501) def test_version_none(self): - # Test that a valid method is rejected when not HTTP/1.x self.con._http_vsn_str = '' - self.con.putrequest('CUSTOM', '/') + self.con.putrequest('PUT', '/') self.con.endheaders() res = self.con.getresponse() self.assertEqual(res.status, 400) @@ -297,7 +296,7 @@ os.chdir(self.cwd) try: shutil.rmtree(self.tempdir) - except OSError: + except: pass finally: BaseTestCase.tearDown(self) @@ -314,9 +313,6 @@ #constructs the path relative to the root directory of the HTTPServer response = self.request(self.tempdir_name + '/test') self.check_status_and_reason(response, 200, data=self.data) - # check for trailing "/" which should return 404. See Issue17324 - response = self.request(self.tempdir_name + '/test/') - self.check_status_and_reason(response, 404) response = self.request(self.tempdir_name + '/') self.check_status_and_reason(response, 200) response = self.request(self.tempdir_name) @@ -325,16 +321,17 @@ self.check_status_and_reason(response, 404) response = self.request('/' + 'ThisDoesNotExist' + '/') self.check_status_and_reason(response, 404) - with open(os.path.join(self.tempdir_name, 'index.html'), 'w') as fp: - response = self.request('/' + self.tempdir_name + '/') - self.check_status_and_reason(response, 200) - # chmod() doesn't work as expected on Windows, and filesystem - # permissions are ignored by root on Unix. - if os.name == 'posix' and os.geteuid() != 0: - os.chmod(self.tempdir, 0) - response = self.request(self.tempdir_name + '/') - self.check_status_and_reason(response, 404) - os.chmod(self.tempdir, 0755) + f = open(os.path.join(self.tempdir_name, 'index.html'), 'w') + response = self.request('/' + self.tempdir_name + '/') + self.check_status_and_reason(response, 200) + + # chmod() doesn't work as expected on Windows, and filesystem + # permissions are ignored by root on Unix. + if os.name == 'posix' and os.geteuid() != 0: + os.chmod(self.tempdir, 0) + response = self.request(self.tempdir_name + '/') + self.check_status_and_reason(response, 404) + os.chmod(self.tempdir, 0755) def test_head(self): response = self.request( @@ -386,9 +383,7 @@ BaseTestCase.setUp(self) self.parent_dir = tempfile.mkdtemp() self.cgi_dir = os.path.join(self.parent_dir, 'cgi-bin') - self.cgi_child_dir = os.path.join(self.cgi_dir, 'child-dir') os.mkdir(self.cgi_dir) - os.mkdir(self.cgi_child_dir) # The shebang line should be pure ASCII: use symlink if possible. # See issue #7668. @@ -398,11 +393,6 @@ else: self.pythonexe = sys.executable - self.nocgi_path = os.path.join(self.parent_dir, 'nocgi.py') - with open(self.nocgi_path, 'w') as fp: - fp.write(cgi_file1 % self.pythonexe) - os.chmod(self.nocgi_path, 0777) - self.file1_path = os.path.join(self.cgi_dir, 'file1.py') with open(self.file1_path, 'w') as file1: file1.write(cgi_file1 % self.pythonexe) @@ -413,11 +403,6 @@ file2.write(cgi_file2 % self.pythonexe) os.chmod(self.file2_path, 0777) - self.file3_path = os.path.join(self.cgi_child_dir, 'file3.py') - with open(self.file3_path, 'w') as file3: - file3.write(cgi_file1 % self.pythonexe) - os.chmod(self.file3_path, 0777) - self.cwd = os.getcwd() os.chdir(self.parent_dir) @@ -426,54 +411,48 @@ os.chdir(self.cwd) if self.pythonexe != sys.executable: os.remove(self.pythonexe) - os.remove(self.nocgi_path) os.remove(self.file1_path) os.remove(self.file2_path) - os.remove(self.file3_path) - os.rmdir(self.cgi_child_dir) os.rmdir(self.cgi_dir) os.rmdir(self.parent_dir) finally: BaseTestCase.tearDown(self) - def test_url_collapse_path(self): - # verify tail is the last portion and head is the rest on proper urls + def test_url_collapse_path_split(self): test_vectors = { - '': '//', + '': ('/', ''), '..': IndexError, '/.//..': IndexError, - '/': '//', - '//': '//', - '/\\': '//\\', - '/.//': '//', - 'cgi-bin/file1.py': '/cgi-bin/file1.py', - '/cgi-bin/file1.py': '/cgi-bin/file1.py', - 'a': '//a', - '/a': '//a', - '//a': '//a', - './a': '//a', - './C:/': '/C:/', - '/a/b': '/a/b', - '/a/b/': '/a/b/', - '/a/b/.': '/a/b/', - '/a/b/c/..': '/a/b/', - '/a/b/c/../d': '/a/b/d', - '/a/b/c/../d/e/../f': '/a/b/d/f', - '/a/b/c/../d/e/../../f': '/a/b/f', - '/a/b/c/../d/e/.././././..//f': '/a/b/f', + '/': ('/', ''), + '//': ('/', ''), + '/\\': ('/', '\\'), + '/.//': ('/', ''), + 'cgi-bin/file1.py': ('/cgi-bin', 'file1.py'), + '/cgi-bin/file1.py': ('/cgi-bin', 'file1.py'), + 'a': ('/', 'a'), + '/a': ('/', 'a'), + '//a': ('/', 'a'), + './a': ('/', 'a'), + './C:/': ('/C:', ''), + '/a/b': ('/a', 'b'), + '/a/b/': ('/a/b', ''), + '/a/b/c/..': ('/a/b', ''), + '/a/b/c/../d': ('/a/b', 'd'), + '/a/b/c/../d/e/../f': ('/a/b/d', 'f'), + '/a/b/c/../d/e/../../f': ('/a/b', 'f'), + '/a/b/c/../d/e/.././././..//f': ('/a/b', 'f'), '../a/b/c/../d/e/.././././..//f': IndexError, - '/a/b/c/../d/e/../../../f': '/a/f', - '/a/b/c/../d/e/../../../../f': '//f', + '/a/b/c/../d/e/../../../f': ('/a', 'f'), + '/a/b/c/../d/e/../../../../f': ('/', 'f'), '/a/b/c/../d/e/../../../../../f': IndexError, - '/a/b/c/../d/e/../../../../f/..': '//', - '/a/b/c/../d/e/../../../../f/../.': '//', + '/a/b/c/../d/e/../../../../f/..': ('/', ''), } for path, expected in test_vectors.iteritems(): if isinstance(expected, type) and issubclass(expected, Exception): self.assertRaises(expected, - CGIHTTPServer._url_collapse_path, path) + CGIHTTPServer._url_collapse_path_split, path) else: - actual = CGIHTTPServer._url_collapse_path(path) + actual = CGIHTTPServer._url_collapse_path_split(path) self.assertEqual(expected, actual, msg='path = %r\nGot: %r\nWanted: %r' % (path, actual, expected)) @@ -483,10 +462,6 @@ self.assertEqual(('Hello World\n', 'text/html', 200), (res.read(), res.getheader('Content-type'), res.status)) - def test_issue19435(self): - res = self.request('///////////nocgi.py/../cgi-bin/nothere.sh') - self.assertEqual(res.status, 404) - def test_post(self): params = urllib.urlencode({'spam' : 1, 'eggs' : 'python', 'bacon' : 123456}) headers = {'Content-type' : 'application/x-www-form-urlencoded'} @@ -520,16 +495,6 @@ (res.read(), res.getheader('Content-type'), res.status)) self.assertEqual(os.environ['SERVER_SOFTWARE'], signature) - def test_urlquote_decoding_in_cgi_check(self): - res = self.request('/cgi-bin%2ffile1.py') - self.assertEqual((b'Hello World\n', 'text/html', 200), - (res.read(), res.getheader('Content-type'), res.status)) - - def test_nested_cgi_path_issue21323(self): - res = self.request('/cgi-bin/child-dir/file3.py') - self.assertEqual((b'Hello World\n', 'text/html', 200), - (res.read(), res.getheader('Content-type'), res.status)) - class SimpleHTTPRequestHandlerTestCase(unittest.TestCase): """ Test url parsing """ diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Lib/test/test_idle.py --- a/Lib/test/test_idle.py Sat Jul 19 16:34:33 2014 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,20 +0,0 @@ -import unittest -from test import test_support as support -from test.test_support import import_module - -# Skip test if _thread or _tkinter wasn't built or idlelib was deleted. -import_module('threading') # imported by idlelib.PyShell, imports _thread -tk = import_module('Tkinter') # imports _tkinter -idletest = import_module('idlelib.idle_test') - -# Without test_main present, regrtest.runtest_inner (line1219) calls -# unittest.TestLoader().loadTestsFromModule(this_module) which calls -# load_tests() if it finds it. (Unittest.main does the same.) -load_tests = idletest.load_tests - -# pre-3.3 regrtest does not support the load_tests protocol. use test_main -def test_main(): - support.run_unittest(unittest.TestLoader().loadTestsFromModule(idletest)) - -if __name__ == '__main__': - unittest.main(verbosity=2, exit=False) diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Lib/test/test_imageop.py --- a/Lib/test/test_imageop.py Sat Jul 19 16:34:33 2014 -0700 +++ b/Lib/test/test_imageop.py Sun Jul 20 10:52:46 2014 -0400 @@ -1,3 +1,5 @@ +#! /usr/bin/env python + """Test script for the imageop module. This has the side effect of partially testing the imgfile module as well. Roger E. Masse diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Lib/test/test_imaplib.py --- a/Lib/test/test_imaplib.py Sat Jul 19 16:34:33 2014 -0700 +++ b/Lib/test/test_imaplib.py Sun Jul 20 10:52:46 2014 -0400 @@ -79,7 +79,7 @@ return line += part except IOError: - # ..but SSLSockets raise exceptions. + # ..but SSLSockets throw exceptions. return if line.endswith('\r\n'): break @@ -165,16 +165,6 @@ self.imap_class, *server.server_address) - def test_linetoolong(self): - class TooLongHandler(SimpleIMAPHandler): - def handle(self): - # Send a very long response line - self.wfile.write('* OK ' + imaplib._MAXLINE*'x' + '\r\n') - - with self.reaped_server(TooLongHandler) as server: - self.assertRaises(imaplib.IMAP4.error, - self.imap_class, *server.server_address) - class ThreadedNetworkedTests(BaseThreadedNetworkedTests): server_class = SocketServer.TCPServer @@ -187,9 +177,6 @@ server_class = SecureTCPServer imap_class = IMAP4_SSL - def test_linetoolong(self): - raise unittest.SkipTest("test is not reliable on 2.7; see issue 20118") - class RemoteIMAPTest(unittest.TestCase): host = 'cyrus.andrew.cmu.edu' @@ -249,4 +236,5 @@ if __name__ == "__main__": + support.use_resources = ['network'] test_main() diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Lib/test/test_imgfile.py --- a/Lib/test/test_imgfile.py Sat Jul 19 16:34:33 2014 -0700 +++ b/Lib/test/test_imgfile.py Sun Jul 20 10:52:46 2014 -0400 @@ -1,3 +1,5 @@ +#! /usr/bin/env python + """Simple test script for imgfile.c Roger E. Masse """ diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Lib/test/test_imghdr.py --- a/Lib/test/test_imghdr.py Sat Jul 19 16:34:33 2014 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,120 +0,0 @@ -import imghdr -import io -import sys -import unittest -from test.test_support import findfile, TESTFN, unlink, run_unittest - -TEST_FILES = ( - ('python.png', 'png'), - ('python.gif', 'gif'), - ('python.bmp', 'bmp'), - ('python.ppm', 'ppm'), - ('python.pgm', 'pgm'), - ('python.pbm', 'pbm'), - ('python.jpg', 'jpeg'), - ('python.ras', 'rast'), - ('python.sgi', 'rgb'), - ('python.tiff', 'tiff'), - ('python.xbm', 'xbm') -) - -class UnseekableIO(io.FileIO): - def tell(self): - raise io.UnsupportedOperation - - def seek(self, *args, **kwargs): - raise io.UnsupportedOperation - -class TestImghdr(unittest.TestCase): - @classmethod - def setUpClass(cls): - cls.testfile = findfile('python.png', subdir='imghdrdata') - with open(cls.testfile, 'rb') as stream: - cls.testdata = stream.read() - - def tearDown(self): - unlink(TESTFN) - - def test_data(self): - for filename, expected in TEST_FILES: - filename = findfile(filename, subdir='imghdrdata') - self.assertEqual(imghdr.what(filename), expected) - ufilename = filename.decode(sys.getfilesystemencoding()) - self.assertEqual(imghdr.what(ufilename), expected) - with open(filename, 'rb') as stream: - self.assertEqual(imghdr.what(stream), expected) - with open(filename, 'rb') as stream: - data = stream.read() - self.assertEqual(imghdr.what(None, data), expected) - - def test_register_test(self): - def test_jumbo(h, file): - if h.startswith(b'eggs'): - return 'ham' - imghdr.tests.append(test_jumbo) - self.addCleanup(imghdr.tests.pop) - self.assertEqual(imghdr.what(None, b'eggs'), 'ham') - - def test_file_pos(self): - with open(TESTFN, 'wb') as stream: - stream.write(b'ababagalamaga') - pos = stream.tell() - stream.write(self.testdata) - with open(TESTFN, 'rb') as stream: - stream.seek(pos) - self.assertEqual(imghdr.what(stream), 'png') - self.assertEqual(stream.tell(), pos) - - def test_bad_args(self): - with self.assertRaises(TypeError): - imghdr.what() - with self.assertRaises(AttributeError): - imghdr.what(None) - with self.assertRaises(TypeError): - imghdr.what(self.testfile, 1) - with open(self.testfile, 'rb') as f: - with self.assertRaises(AttributeError): - imghdr.what(f.fileno()) - - def test_invalid_headers(self): - for header in (b'\211PN\r\n', - b'\001\331', - b'\x59\xA6', - b'cutecat', - b'000000JFI', - b'GIF80'): - self.assertIsNone(imghdr.what(None, header)) - - def test_missing_file(self): - with self.assertRaises(IOError): - imghdr.what('missing') - - def test_closed_file(self): - stream = open(self.testfile, 'rb') - stream.close() - with self.assertRaises(ValueError) as cm: - imghdr.what(stream) - stream = io.BytesIO(self.testdata) - stream.close() - with self.assertRaises(ValueError) as cm: - imghdr.what(stream) - - def test_unseekable(self): - with open(TESTFN, 'wb') as stream: - stream.write(self.testdata) - with UnseekableIO(TESTFN, 'rb') as stream: - with self.assertRaises(io.UnsupportedOperation): - imghdr.what(stream) - - def test_output_stream(self): - with open(TESTFN, 'wb') as stream: - stream.write(self.testdata) - stream.seek(0) - with self.assertRaises(IOError) as cm: - imghdr.what(stream) - -def test_main(): - run_unittest(TestImghdr) - -if __name__ == '__main__': - test_main() diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Lib/test/test_imp.py --- a/Lib/test/test_imp.py Sat Jul 19 16:34:33 2014 -0700 +++ b/Lib/test/test_imp.py Sun Jul 20 10:52:46 2014 -0400 @@ -2,12 +2,7 @@ import unittest from test import test_support -try: - import thread -except ImportError: - thread = None -@unittest.skipUnless(thread, 'threading not available') class LockTests(unittest.TestCase): """Very basic test of import lock functions.""" @@ -73,8 +68,13 @@ def test_main(): tests = [ ReloadTests, - LockTests, ] + try: + import thread + except ImportError: + pass + else: + tests.append(LockTests) test_support.run_unittest(*tests) if __name__ == "__main__": diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Lib/test/test_import.py --- a/Lib/test/test_import.py Sat Jul 19 16:34:33 2014 -0700 +++ b/Lib/test/test_import.py Sun Jul 20 10:52:46 2014 -0400 @@ -1,38 +1,22 @@ -import errno import imp import marshal import os import py_compile import random import stat -import struct import sys import unittest -import textwrap -import shutil - from test.test_support import (unlink, TESTFN, unload, run_unittest, rmtree, is_jython, check_warnings, EnvironmentVarGuard) -from test import symlink_support +import textwrap from test import script_helper -def _files(name): - return (name + os.extsep + "py", - name + os.extsep + "pyc", - name + os.extsep + "pyo", - name + os.extsep + "pyw", - name + "$py.class") - -def chmod_files(name): - for f in _files(name): - try: - os.chmod(f, 0600) - except OSError as exc: - if exc.errno != errno.ENOENT: - raise - def remove_files(name): - for f in _files(name): + for f in (name + os.extsep + "py", + name + os.extsep + "pyc", + name + os.extsep + "pyo", + name + os.extsep + "pyw", + name + "$py.class"): unlink(f) @@ -88,8 +72,7 @@ unlink(source) try: - if not sys.dont_write_bytecode: - imp.reload(mod) + imp.reload(mod) except ImportError, err: self.fail("import from .pyc/.pyo failed: %s" % err) finally: @@ -106,10 +89,7 @@ finally: del sys.path[0] - @unittest.skipUnless(os.name == 'posix', - "test meaningful only on posix systems") - @unittest.skipIf(sys.dont_write_bytecode, - "test meaningful only when writing bytecode") + @unittest.skipUnless(os.name == 'posix', "test meaningful only on posix systems") def test_execute_bit_not_copied(self): # Issue 6070: under posix .pyc files got their execute bit set if # the .py file had the execute bit set, but they aren't executable. @@ -136,42 +116,6 @@ unload(TESTFN) del sys.path[0] - @unittest.skipIf(sys.dont_write_bytecode, - "test meaningful only when writing bytecode") - def test_rewrite_pyc_with_read_only_source(self): - # Issue 6074: a long time ago on posix, and more recently on Windows, - # a read only source file resulted in a read only pyc file, which - # led to problems with updating it later - sys.path.insert(0, os.curdir) - fname = TESTFN + os.extsep + "py" - try: - # Write a Python file, make it read-only and import it - with open(fname, 'w') as f: - f.write("x = 'original'\n") - # Tweak the mtime of the source to ensure pyc gets updated later - s = os.stat(fname) - os.utime(fname, (s.st_atime, s.st_mtime-100000000)) - os.chmod(fname, 0400) - m1 = __import__(TESTFN) - self.assertEqual(m1.x, 'original') - # Change the file and then reimport it - os.chmod(fname, 0600) - with open(fname, 'w') as f: - f.write("x = 'rewritten'\n") - unload(TESTFN) - m2 = __import__(TESTFN) - self.assertEqual(m2.x, 'rewritten') - # Now delete the source file and check the pyc was rewritten - unlink(fname) - unload(TESTFN) - m3 = __import__(TESTFN) - self.assertEqual(m3.x, 'rewritten') - finally: - chmod_files(TESTFN) - remove_files(TESTFN) - unload(TESTFN) - del sys.path[0] - def test_imp_module(self): # Verify that the imp module can correctly load and find .py files @@ -319,10 +263,7 @@ import imp sys.argv.insert(0, C()) """)) - try: - script_helper.assert_python_ok(testfn) - finally: - unlink(testfn) + script_helper.assert_python_ok(testfn) def test_bug7732(self): source = TESTFN + '.py' @@ -333,70 +274,6 @@ finally: os.rmdir(source) - def test_timestamp_overflow(self): - # A modification timestamp larger than 2**32 should not be a problem - # when importing a module (issue #11235). - sys.path.insert(0, os.curdir) - try: - source = TESTFN + ".py" - compiled = source + ('c' if __debug__ else 'o') - with open(source, 'w') as f: - pass - try: - os.utime(source, (2 ** 33 - 5, 2 ** 33 - 5)) - except OverflowError: - self.skipTest("cannot set modification time to large integer") - except OSError as e: - if e.errno != getattr(errno, 'EOVERFLOW', None): - raise - self.skipTest("cannot set modification time to large integer ({})".format(e)) - __import__(TESTFN) - # The pyc file was created. - os.stat(compiled) - finally: - del sys.path[0] - remove_files(TESTFN) - - def test_pyc_mtime(self): - # Test for issue #13863: .pyc timestamp sometimes incorrect on Windows. - sys.path.insert(0, os.curdir) - try: - # Jan 1, 2012; Jul 1, 2012. - mtimes = 1325376000, 1341100800 - - # Different names to avoid running into import caching. - tails = "spam", "eggs" - for mtime, tail in zip(mtimes, tails): - module = TESTFN + tail - source = module + ".py" - compiled = source + ('c' if __debug__ else 'o') - - # Create a new Python file with the given mtime. - with open(source, 'w') as f: - f.write("# Just testing\nx=1, 2, 3\n") - os.utime(source, (mtime, mtime)) - - # Generate the .pyc/o file; if it couldn't be created - # for some reason, skip the test. - m = __import__(module) - if not os.path.exists(compiled): - unlink(source) - self.skipTest("Couldn't create .pyc/.pyo file.") - - # Actual modification time of .py file. - mtime1 = int(os.stat(source).st_mtime) & 0xffffffff - - # mtime that was encoded in the .pyc file. - with open(compiled, 'rb') as f: - mtime2 = struct.unpack(' sample-tagged - symlink_support.symlink(self.tagged, self.package_name) - - assert os.path.isdir(self.package_name) - assert os.path.isfile(os.path.join(self.package_name, '__init__.py')) - - @property - def tagged(self): - return self.package_name + '-tagged' - - # regression test for issue6727 - @unittest.skipUnless( - not hasattr(sys, 'getwindowsversion') - or sys.getwindowsversion() >= (6, 0), - "Windows Vista or later required") - @symlink_support.skip_unless_symlink - def test_symlinked_dir_importable(self): - # make sure sample can only be imported from the current directory. - sys.path[:] = ['.'] - - # and try to import the package - __import__(self.package_name) - - def tearDown(self): - # now cleanup - if os.path.exists(self.package_name): - symlink_support.remove_symlink(self.package_name) - if os.path.exists(self.tagged): - shutil.rmtree(self.tagged) - sys.path[:] = self.orig_sys_path - def test_main(verbose=None): - run_unittest(ImportTests, PycRewritingTests, PathsTests, - RelativeImportTests, TestSymbolicallyLinkedPackage) + run_unittest(ImportTests, PycRewritingTests, PathsTests, RelativeImportTests) if __name__ == '__main__': # Test needs to be a package, so we can do relative imports. diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Lib/test/test_index.py --- a/Lib/test/test_index.py Sat Jul 19 16:34:33 2014 -0700 +++ b/Lib/test/test_index.py Sun Jul 20 10:52:46 2014 -0400 @@ -91,7 +91,7 @@ self.assertEqual(self.seq[self.o:self.o2], self.seq[1:3]) self.assertEqual(self.seq[self.n:self.n2], self.seq[2:4]) - def test_slice_bug7532a(self): + def test_slice_bug7532(self): seqlen = len(self.seq) self.o.ind = int(seqlen * 1.5) self.n.ind = seqlen + 2 @@ -99,12 +99,9 @@ self.assertEqual(self.seq[:self.o], self.seq) self.assertEqual(self.seq[self.n:], self.seq[0:0]) self.assertEqual(self.seq[:self.n], self.seq) - - def test_slice_bug7532b(self): if isinstance(self.seq, ClassicSeq): - self.skipTest('test fails for ClassicSeq') + return # These tests fail for ClassicSeq (see bug #7532) - seqlen = len(self.seq) self.o2.ind = -seqlen - 2 self.n2.ind = -int(seqlen * 1.5) self.assertEqual(self.seq[self.o2:], self.seq) diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Lib/test/test_inspect.py --- a/Lib/test/test_inspect.py Sat Jul 19 16:34:33 2014 -0700 +++ b/Lib/test/test_inspect.py Sun Jul 20 10:52:46 2014 -0400 @@ -220,23 +220,8 @@ [('FesteringGob', mod.FesteringGob), ('MalodorousPervert', mod.MalodorousPervert), ('ParrotDroppings', mod.ParrotDroppings), - ('StupidGit', mod.StupidGit), - ('Tit', mod.MalodorousPervert), - ]) - tree = inspect.getclasstree([cls[1] for cls in classes]) - self.assertEqual(tree, - [(mod.ParrotDroppings, ()), - [(mod.FesteringGob, (mod.MalodorousPervert, - mod.ParrotDroppings)) - ], - (mod.StupidGit, ()), - [(mod.MalodorousPervert, (mod.StupidGit,)), - [(mod.FesteringGob, (mod.MalodorousPervert, - mod.ParrotDroppings)) - ] - ] - ]) - tree = inspect.getclasstree([cls[1] for cls in classes], True) + ('StupidGit', mod.StupidGit)]) + tree = inspect.getclasstree([cls[1] for cls in classes], 1) self.assertEqual(tree, [(mod.ParrotDroppings, ()), (mod.StupidGit, ()), @@ -419,43 +404,10 @@ self.assertEqual(inspect.findsource(co), (lines,0)) self.assertEqual(inspect.getsource(co), lines[0]) - def test_findsource_without_filename(self): - for fname in ['', '']: - co = compile('x=1', fname, "exec") - self.assertRaises(IOError, inspect.findsource, co) - self.assertRaises(IOError, inspect.getsource, co) - - -class _BrokenDataDescriptor(object): - """ - A broken data descriptor. See bug #1785. - """ - def __get__(*args): - raise AssertionError("should not __get__ data descriptors") - - def __set__(*args): - raise RuntimeError - - def __getattr__(*args): - raise AssertionError("should not __getattr__ data descriptors") - - -class _BrokenMethodDescriptor(object): - """ - A broken method descriptor. See bug #1785. - """ - def __get__(*args): - raise AssertionError("should not __get__ method descriptors") - - def __getattr__(*args): - raise AssertionError("should not __getattr__ method descriptors") - - # Helper for testing classify_class_attrs. def attrs_wo_objs(cls): return [t[:3] for t in inspect.classify_class_attrs(cls)] - class TestClassesAndFunctions(unittest.TestCase): def test_classic_mro(self): # Test classic-class method resolution order. @@ -542,9 +494,6 @@ datablob = '1' - dd = _BrokenDataDescriptor() - md = _BrokenMethodDescriptor() - attrs = attrs_wo_objs(A) self.assertIn(('s', 'static method', A), attrs, 'missing static method') self.assertIn(('c', 'class method', A), attrs, 'missing class method') @@ -552,8 +501,6 @@ self.assertIn(('m', 'method', A), attrs, 'missing plain method') self.assertIn(('m1', 'method', A), attrs, 'missing plain method') self.assertIn(('datablob', 'data', A), attrs, 'missing data') - self.assertIn(('md', 'method', A), attrs, 'missing method descriptor') - self.assertIn(('dd', 'data', A), attrs, 'missing data descriptor') class B(A): def m(self): pass @@ -565,8 +512,6 @@ self.assertIn(('m', 'method', B), attrs, 'missing plain method') self.assertIn(('m1', 'method', A), attrs, 'missing plain method') self.assertIn(('datablob', 'data', A), attrs, 'missing data') - self.assertIn(('md', 'method', A), attrs, 'missing method descriptor') - self.assertIn(('dd', 'data', A), attrs, 'missing data descriptor') class C(A): @@ -580,8 +525,6 @@ self.assertIn(('m', 'method', C), attrs, 'missing plain method') self.assertIn(('m1', 'method', A), attrs, 'missing plain method') self.assertIn(('datablob', 'data', A), attrs, 'missing data') - self.assertIn(('md', 'method', A), attrs, 'missing method descriptor') - self.assertIn(('dd', 'data', A), attrs, 'missing data descriptor') class D(B, C): def m1(self): pass @@ -596,8 +539,6 @@ self.assertIn(('m', 'method', B), attrs, 'missing plain method') self.assertIn(('m1', 'method', D), attrs, 'missing plain method') self.assertIn(('datablob', 'data', A), attrs, 'missing data') - self.assertIn(('md', 'method', A), attrs, 'missing method descriptor') - self.assertIn(('dd', 'data', A), attrs, 'missing data descriptor') def test_classify_oldstyle(self): @@ -613,38 +554,6 @@ """ self._classify_test(True) - def test_classify_builtin_types(self): - # Simple sanity check that all built-in types can have their - # attributes classified. - for name in dir(__builtin__): - builtin = getattr(__builtin__, name) - if isinstance(builtin, type): - inspect.classify_class_attrs(builtin) - - def test_getmembers_method(self): - # Old-style classes - class B: - def f(self): - pass - - self.assertIn(('f', B.f), inspect.getmembers(B)) - # contrary to spec, ismethod() is also True for unbound methods - # (see #1785) - self.assertIn(('f', B.f), inspect.getmembers(B, inspect.ismethod)) - b = B() - self.assertIn(('f', b.f), inspect.getmembers(b)) - self.assertIn(('f', b.f), inspect.getmembers(b, inspect.ismethod)) - - # New-style classes - class B(object): - def f(self): - pass - - self.assertIn(('f', B.f), inspect.getmembers(B)) - self.assertIn(('f', B.f), inspect.getmembers(B, inspect.ismethod)) - b = B() - self.assertIn(('f', b.f), inspect.getmembers(b)) - self.assertIn(('f', b.f), inspect.getmembers(b, inspect.ismethod)) class TestGetcallargsFunctions(unittest.TestCase): diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Lib/test/test_int.py --- a/Lib/test/test_int.py Sat Jul 19 16:34:33 2014 -0700 +++ b/Lib/test/test_int.py Sun Jul 20 10:52:46 2014 -0400 @@ -1,7 +1,6 @@ import sys import unittest -from test import test_support from test.test_support import run_unittest, have_unicode import math @@ -45,27 +44,7 @@ (unichr(0x200), ValueError), ] -class IntLongCommonTests(object): - - """Mixin of test cases to share between both test_int and test_long.""" - - # Change to int or long in the TestCase subclass. - ntype = None - - def test_no_args(self): - self.assertEqual(self.ntype(), 0) - - def test_keyword_args(self): - # Test invoking constructor using keyword arguments. - self.assertEqual(self.ntype(x=1.2), 1) - self.assertEqual(self.ntype('100', base=2), 4) - self.assertEqual(self.ntype(x='100', base=2), 4) - self.assertRaises(TypeError, self.ntype, base=10) - self.assertRaises(TypeError, self.ntype, base=0) - -class IntTestCases(IntLongCommonTests, unittest.TestCase): - - ntype = int +class IntTestCases(unittest.TestCase): def test_basic(self): self.assertEqual(int(314), 314) @@ -336,46 +315,6 @@ self.assertEqual(int(float(2**54+10)), 2**54+8) self.assertEqual(int(float(2**54+11)), 2**54+12) - def test_valid_non_numeric_input_types_for_x(self): - # Test possible valid non-numeric types for x, including subclasses - # of the allowed built-in types. - class CustomStr(str): pass - values = ['100', CustomStr('100')] - - if have_unicode: - class CustomUnicode(unicode): pass - values += [unicode('100'), CustomUnicode(unicode('100'))] - - for x in values: - msg = 'x has value %s and type %s' % (x, type(x).__name__) - try: - self.assertEqual(int(x), 100, msg=msg) - self.assertEqual(int(x, 2), 4, msg=msg) - except TypeError, err: - raise AssertionError('For %s got TypeError: %s' % - (type(x).__name__, err)) - - def test_error_on_string_float_for_x(self): - self.assertRaises(ValueError, int, '1.2') - - def test_error_on_bytearray_for_x(self): - self.assertRaises(TypeError, int, bytearray('100'), 2) - - def test_error_on_invalid_int_bases(self): - for base in [-1, 1, 1000]: - self.assertRaises(ValueError, int, '100', base) - - def test_error_on_string_base(self): - self.assertRaises(TypeError, int, 100, base='foo') - - @test_support.cpython_only - def test_small_ints(self): - self.assertIs(int('10'), 10) - self.assertIs(int('-1'), -1) - if have_unicode: - self.assertIs(int(u'10'), 10) - self.assertIs(int(u'-1'), -1) - def test_intconversion(self): # Test __int__() class ClassicMissingMethods: diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Lib/test/test_io.py --- a/Lib/test/test_io.py Sat Jul 19 16:34:33 2014 -0700 +++ b/Lib/test/test_io.py Sun Jul 20 10:52:46 2014 -0400 @@ -29,15 +29,12 @@ import random import unittest import weakref -import warnings import abc import signal import errno from itertools import cycle, count from collections import deque -from UserList import UserList from test import test_support as support -import contextlib import codecs import io # C implementation of io @@ -394,9 +391,14 @@ # a long time to build the >2GB file and takes >2GB of disk space # therefore the resource must be enabled to run this test. if sys.platform[:3] == 'win' or sys.platform == 'darwin': - support.requires( - 'largefile', - 'test requires %s bytes and a long time to run' % self.LARGE) + if not support.is_resource_enabled("largefile"): + print("\nTesting large file ops skipped on %s." % sys.platform, + file=sys.stderr) + print("It requires %d bytes and a long time." % self.LARGE, + file=sys.stderr) + print("Use 'regrtest.py -u largefile test_io' to run it.", + file=sys.stderr) + return with self.open(support.TESTFN, "w+b", 0) as f: self.large_file_ops(f) with self.open(support.TESTFN, "w+b") as f: @@ -570,7 +572,6 @@ raise IOError() f.flush = bad_flush self.assertRaises(IOError, f.close) # exception not swallowed - self.assertTrue(f.closed) def test_multi_close(self): f = self.open(support.TESTFN, "wb", buffering=0) @@ -592,33 +593,6 @@ self.assertEqual(rawio.read(2), None) self.assertEqual(rawio.read(2), b"") - def test_fileio_closefd(self): - # Issue #4841 - with self.open(__file__, 'rb') as f1, \ - self.open(__file__, 'rb') as f2: - fileio = self.FileIO(f1.fileno(), closefd=False) - # .__init__() must not close f1 - fileio.__init__(f2.fileno(), closefd=False) - f1.readline() - # .close() must not close f2 - fileio.close() - f2.readline() - - def test_nonbuffered_textio(self): - with warnings.catch_warnings(record=True) as recorded: - with self.assertRaises(ValueError): - self.open(support.TESTFN, 'w', buffering=0) - support.gc_collect() - self.assertEqual(recorded, []) - - def test_invalid_newline(self): - with warnings.catch_warnings(record=True) as recorded: - with self.assertRaises(ValueError): - self.open(support.TESTFN, 'w', newline='invalid') - support.gc_collect() - self.assertEqual(recorded, []) - - class CIOTest(IOTest): def test_IOBase_finalize(self): @@ -660,7 +634,6 @@ self.assertEqual(42, bufio.fileno()) - @unittest.skip('test having existential crisis') def test_no_fileno(self): # XXX will we always have fileno() function? If so, kill # this test. Else, write it. @@ -745,21 +718,6 @@ raw.flush = bad_flush b = self.tp(raw) self.assertRaises(IOError, b.close) # exception not swallowed - self.assertTrue(b.closed) - - def test_close_error_on_close(self): - raw = self.MockRawIO() - def bad_flush(): - raise IOError('flush') - def bad_close(): - raise IOError('close') - raw.close = bad_close - b = self.tp(raw) - b.flush = bad_flush - with self.assertRaises(IOError) as err: # exception not swallowed - b.close() - self.assertEqual(err.exception.args, ('close',)) - self.assertFalse(b.closed) def test_multi_close(self): raw = self.MockRawIO() @@ -777,20 +735,6 @@ buf.raw = x -class SizeofTest: - - @support.cpython_only - def test_sizeof(self): - bufsize1 = 4096 - bufsize2 = 8192 - rawio = self.MockRawIO() - bufio = self.tp(rawio, buffer_size=bufsize1) - size = sys.getsizeof(bufio) - bufsize1 - rawio = self.MockRawIO() - bufio = self.tp(rawio, buffer_size=bufsize2) - self.assertEqual(sys.getsizeof(bufio), size + bufsize2) - - class BufferedReaderTest(unittest.TestCase, CommonBufferedTests): read_mode = "rb" @@ -808,16 +752,6 @@ bufio.__init__(rawio) self.assertEqual(b"abc", bufio.read()) - def test_uninitialized(self): - bufio = self.tp.__new__(self.tp) - del bufio - bufio = self.tp.__new__(self.tp) - self.assertRaisesRegexp((ValueError, AttributeError), - 'uninitialized|has no attribute', - bufio.read, 0) - bufio.__init__(self.MockRawIO()) - self.assertEqual(bufio.read(0), b'') - def test_read(self): for arg in (None, 7): rawio = self.MockRawIO((b"abc", b"d", b"efg")) @@ -984,7 +918,7 @@ "failed for {}: {} != 0".format(n, rawio._extraneous_reads)) -class CBufferedReaderTest(BufferedReaderTest, SizeofTest): +class CBufferedReaderTest(BufferedReaderTest): tp = io.BufferedReader def test_constructor(self): @@ -1025,12 +959,6 @@ support.gc_collect() self.assertTrue(wr() is None, wr) - def test_args_error(self): - # Issue #17275 - with self.assertRaisesRegexp(TypeError, "BufferedReader"): - self.tp(io.BytesIO(), 1024, 1024, 1024) - - class PyBufferedReaderTest(BufferedReaderTest): tp = pyio.BufferedReader @@ -1054,16 +982,6 @@ bufio.flush() self.assertEqual(b"".join(rawio._write_stack), b"abcghi") - def test_uninitialized(self): - bufio = self.tp.__new__(self.tp) - del bufio - bufio = self.tp.__new__(self.tp) - self.assertRaisesRegexp((ValueError, AttributeError), - 'uninitialized|has no attribute', - bufio.write, b'') - bufio.__init__(self.MockRawIO()) - self.assertEqual(bufio.write(b''), 0) - def test_detach_flush(self): raw = self.MockRawIO() buf = self.tp(raw) @@ -1181,28 +1099,6 @@ bufio.flush() self.assertEqual(b"abc", writer._write_stack[0]) - def test_writelines(self): - l = [b'ab', b'cd', b'ef'] - writer = self.MockRawIO() - bufio = self.tp(writer, 8) - bufio.writelines(l) - bufio.flush() - self.assertEqual(b''.join(writer._write_stack), b'abcdef') - - def test_writelines_userlist(self): - l = UserList([b'ab', b'cd', b'ef']) - writer = self.MockRawIO() - bufio = self.tp(writer, 8) - bufio.writelines(l) - bufio.flush() - self.assertEqual(b''.join(writer._write_stack), b'abcdef') - - def test_writelines_error(self): - writer = self.MockRawIO() - bufio = self.tp(writer, 8) - self.assertRaises(TypeError, bufio.writelines, [1, 2, 3]) - self.assertRaises(TypeError, bufio.writelines, None) - def test_destructor(self): writer = self.MockRawIO() bufio = self.tp(writer, 8) @@ -1284,18 +1180,8 @@ DeprecationWarning)): self.tp(self.MockRawIO(), 8, 12) - def test_write_error_on_close(self): - raw = self.MockRawIO() - def bad_write(b): - raise IOError() - raw.write = bad_write - b = self.tp(raw) - b.write(b'spam') - self.assertRaises(IOError, b.close) # exception not swallowed - self.assertTrue(b.closed) - - -class CBufferedWriterTest(BufferedWriterTest, SizeofTest): + +class CBufferedWriterTest(BufferedWriterTest): tp = io.BufferedWriter def test_constructor(self): @@ -1333,11 +1219,6 @@ with self.open(support.TESTFN, "rb") as f: self.assertEqual(f.read(), b"123xxx") - def test_args_error(self): - # Issue #17275 - with self.assertRaisesRegexp(TypeError, "BufferedWriter"): - self.tp(io.BytesIO(), 1024, 1024, 1024) - class PyBufferedWriterTest(BufferedWriterTest): tp = pyio.BufferedWriter @@ -1348,20 +1229,6 @@ pair = self.tp(self.MockRawIO(), self.MockRawIO()) self.assertFalse(pair.closed) - def test_uninitialized(self): - pair = self.tp.__new__(self.tp) - del pair - pair = self.tp.__new__(self.tp) - self.assertRaisesRegexp((ValueError, AttributeError), - 'uninitialized|has no attribute', - pair.read, 0) - self.assertRaisesRegexp((ValueError, AttributeError), - 'uninitialized|has no attribute', - pair.write, b'') - pair.__init__(self.MockRawIO(), self.MockRawIO()) - self.assertEqual(pair.read(0), b'') - self.assertEqual(pair.write(b''), 0) - def test_detach(self): pair = self.tp(self.MockRawIO(), self.MockRawIO()) self.assertRaises(self.UnsupportedOperation, pair.detach) @@ -1489,10 +1356,6 @@ BufferedReaderTest.test_constructor(self) BufferedWriterTest.test_constructor(self) - def test_uninitialized(self): - BufferedReaderTest.test_uninitialized(self) - BufferedWriterTest.test_uninitialized(self) - def test_read_and_write(self): raw = self.MockRawIO((b"asdf", b"ghjk")) rw = self.tp(raw, 8) @@ -1707,8 +1570,7 @@ self.assertEqual(raw.getvalue(), b'1b\n2def\n3\n') -class CBufferedRandomTest(CBufferedReaderTest, CBufferedWriterTest, - BufferedRandomTest, SizeofTest): +class CBufferedRandomTest(CBufferedReaderTest, CBufferedWriterTest, BufferedRandomTest): tp = io.BufferedRandom def test_constructor(self): @@ -1725,12 +1587,6 @@ CBufferedReaderTest.test_garbage_collection(self) CBufferedWriterTest.test_garbage_collection(self) - def test_args_error(self): - # Issue #17275 - with self.assertRaisesRegexp(TypeError, "BufferedRandom"): - self.tp(io.BytesIO(), 1024, 1024, 1024) - - class PyBufferedRandomTest(BufferedRandomTest): tp = pyio.BufferedRandom @@ -2327,28 +2183,6 @@ reads += c self.assertEqual(reads, "A"*127+"\nB") - def test_writelines(self): - l = ['ab', 'cd', 'ef'] - buf = self.BytesIO() - txt = self.TextIOWrapper(buf) - txt.writelines(l) - txt.flush() - self.assertEqual(buf.getvalue(), b'abcdef') - - def test_writelines_userlist(self): - l = UserList(['ab', 'cd', 'ef']) - buf = self.BytesIO() - txt = self.TextIOWrapper(buf) - txt.writelines(l) - txt.flush() - self.assertEqual(buf.getvalue(), b'abcdef') - - def test_writelines_error(self): - txt = self.TextIOWrapper(self.BytesIO()) - self.assertRaises(TypeError, txt.writelines, [1, 2, 3]) - self.assertRaises(TypeError, txt.writelines, None) - self.assertRaises(TypeError, txt.writelines, b'abc') - def test_issue1395_1(self): txt = self.TextIOWrapper(self.BytesIO(self.testdata), encoding="ascii") @@ -2472,7 +2306,6 @@ raise IOError() txt.flush = bad_flush self.assertRaises(IOError, txt.close) # exception not swallowed - self.assertTrue(txt.closed) def test_multi_close(self): txt = self.TextIOWrapper(self.BytesIO(self.testdata), encoding="ascii") @@ -2487,39 +2320,6 @@ with self.assertRaises((AttributeError, TypeError)): txt.buffer = buf - def test_read_nonbytes(self): - # Issue #17106 - # Crash when underlying read() returns non-bytes - class NonbytesStream(self.StringIO): - read1 = self.StringIO.read - class NonbytesStream(self.StringIO): - read1 = self.StringIO.read - t = self.TextIOWrapper(NonbytesStream('a')) - with self.maybeRaises(TypeError): - t.read(1) - t = self.TextIOWrapper(NonbytesStream('a')) - with self.maybeRaises(TypeError): - t.readline() - t = self.TextIOWrapper(NonbytesStream('a')) - self.assertEqual(t.read(), u'a') - - def test_illegal_decoder(self): - # Issue #17106 - # Crash when decoder returns non-string - t = self.TextIOWrapper(self.BytesIO(b'aaaaaa'), newline='\n', - encoding='quopri_codec') - with self.maybeRaises(TypeError): - t.read(1) - t = self.TextIOWrapper(self.BytesIO(b'aaaaaa'), newline='\n', - encoding='quopri_codec') - with self.maybeRaises(TypeError): - t.readline() - t = self.TextIOWrapper(self.BytesIO(b'aaaaaa'), newline='\n', - encoding='quopri_codec') - with self.maybeRaises(TypeError): - t.read() - - class CTextIOWrapperTest(TextIOWrapperTest): def test_initialization(self): @@ -2561,13 +2361,9 @@ t2.buddy = t1 support.gc_collect() - maybeRaises = unittest.TestCase.assertRaises - class PyTextIOWrapperTest(TextIOWrapperTest): - @contextlib.contextmanager - def maybeRaises(self, *args, **kwds): - yield + pass class IncrementalNewlineDecoderTest(unittest.TestCase): @@ -2929,7 +2725,7 @@ # The buffered IO layer must check for pending signal # handlers, which in this case will invoke alarm_interrupt(). self.assertRaises(ZeroDivisionError, - wio.write, item * (support.PIPE_MAX_SIZE // len(item) + 1)) + wio.write, item * (1024 * 1024)) t.join() # We got one byte, get another one and check that it isn't a # repeat of the first one. @@ -3027,7 +2823,7 @@ select = support.import_module("select") # A quantity that exceeds the buffer size of an anonymous pipe's # write end. - N = support.PIPE_MAX_SIZE + N = 1024 * 1024 r, w = os.pipe() fdopen_kwargs["closefd"] = False # We need a separate thread to read from the pipe and allow the diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Lib/test/test_iter.py --- a/Lib/test/test_iter.py Sat Jul 19 16:34:33 2014 -0700 +++ b/Lib/test/test_iter.py Sun Jul 20 10:52:46 2014 -0400 @@ -526,7 +526,7 @@ d = {"one": 1, "two": 2, "three": 3} self.assertEqual(reduce(add, d), "".join(d.keys())) - @unittest.skipUnless(have_unicode, 'needs unicode support') + # This test case will be removed if we don't have Unicode def test_unicode_join_endcase(self): # This class inserts a Unicode object into its argument's natural @@ -567,6 +567,8 @@ unlink(TESTFN) except OSError: pass + if not have_unicode: + def test_unicode_join_endcase(self): pass # Test iterators with 'x in y' and 'x not in y'. def test_in_and_not_in(self): @@ -906,21 +908,6 @@ except TypeError: pass - def test_extending_list_with_iterator_does_not_segfault(self): - # The code to extend a list with an iterator has a fair - # amount of nontrivial logic in terms of guessing how - # much memory to allocate in advance, "stealing" refs, - # and then shrinking at the end. This is a basic smoke - # test for that scenario. - def gen(): - for i in range(500): - yield i - lst = [0] * 500 - for i in range(240): - lst.pop(0) - lst.extend(gen()) - self.assertEqual(len(lst), 760) - def test_main(): run_unittest(TestCase) diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Lib/test/test_itertools.py --- a/Lib/test/test_itertools.py Sat Jul 19 16:34:33 2014 -0700 +++ b/Lib/test/test_itertools.py Sun Jul 20 10:52:46 2014 -0400 @@ -1,7 +1,7 @@ import unittest from test import test_support from itertools import * -import weakref +from weakref import proxy from decimal import Decimal from fractions import Fraction import sys @@ -274,7 +274,7 @@ self.assertEqual(result, list(permutations(values, None))) # test r as None self.assertEqual(result, list(permutations(values))) # test default r - @test_support.impl_detail("tuple reuse is specific to CPython") + @test_support.impl_detail("tuple resuse is CPython specific") def test_permutations_tuple_reuse(self): self.assertEqual(len(set(map(id, permutations('abcde', 3)))), 1) self.assertNotEqual(len(set(map(id, list(permutations('abcde', 3))))), 1) @@ -536,7 +536,7 @@ zip('abc', 'def')) @test_support.impl_detail("tuple reuse is specific to CPython") - def test_izip_tuple_reuse(self): + def test_izip_tuple_resuse(self): ids = map(id, izip('abc', 'def')) self.assertEqual(min(ids), max(ids)) ids = map(id, list(izip('abc', 'def'))) @@ -698,9 +698,6 @@ def test_repeat(self): self.assertEqual(list(repeat(object='a', times=3)), ['a', 'a', 'a']) - self.assertEqual(list(repeat(object='a', times=0)), []) - self.assertEqual(list(repeat(object='a', times=-1)), []) - self.assertEqual(list(repeat(object='a', times=-2)), []) self.assertEqual(zip(xrange(3),repeat('a')), [(0, 'a'), (1, 'a'), (2, 'a')]) self.assertEqual(list(repeat('a', 3)), ['a', 'a', 'a']) @@ -717,12 +714,6 @@ list(r) self.assertEqual(repr(r), 'repeat((1+0j), 0)') - def test_repeat_with_negative_times(self): - self.assertEqual(repr(repeat('a', -1)), "repeat('a', 0)") - self.assertEqual(repr(repeat('a', -2)), "repeat('a', 0)") - self.assertEqual(repr(repeat('a', times=-1)), "repeat('a', 0)") - self.assertEqual(repr(repeat('a', times=-2)), "repeat('a', 0)") - def test_imap(self): self.assertEqual(list(imap(operator.pow, range(3), range(1,7))), [0**1, 1**2, 2**3]) @@ -801,15 +792,6 @@ self.assertEqual(list(islice(c, 1, 3, 50)), [1]) self.assertEqual(next(c), 3) - # Issue #21321: check source iterator is not referenced - # from islice() after the latter has been exhausted - it = (x for x in (1, 2)) - wr = weakref.ref(it) - it = islice(it, 1) - self.assertIsNotNone(wr()) - list(it) # exhaust the iterator - self.assertIsNone(wr()) - def test_takewhile(self): data = [1, 3, 5, 20, 2, 4, 6, 8] underten = lambda x: x<10 @@ -919,17 +901,11 @@ # test that tee objects are weak referencable a, b = tee(xrange(10)) - p = weakref.proxy(a) + p = proxy(a) self.assertEqual(getattr(p, '__class__'), type(b)) del a self.assertRaises(ReferenceError, getattr, p, '__class__') - # Issue 13454: Crash when deleting backward iterator from tee() - def test_tee_del_backward(self): - forward, backward = tee(repeat(None, 20000000)) - any(forward) # exhaust the iterator - del backward - def test_StopIteration(self): self.assertRaises(StopIteration, izip().next) diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Lib/test/test_kqueue.py --- a/Lib/test/test_kqueue.py Sat Jul 19 16:34:33 2014 -0700 +++ b/Lib/test/test_kqueue.py Sun Jul 20 10:52:46 2014 -0400 @@ -70,13 +70,13 @@ self.assertEqual(ev, ev) self.assertNotEqual(ev, other) - bignum = 0x7fff - ev = select.kevent(bignum, 1, 2, 3, bignum - 1, bignum) + bignum = sys.maxsize * 2 + 1 + ev = select.kevent(bignum, 1, 2, 3, sys.maxsize, bignum) self.assertEqual(ev.ident, bignum) self.assertEqual(ev.filter, 1) self.assertEqual(ev.flags, 2) self.assertEqual(ev.fflags, 3) - self.assertEqual(ev.data, bignum - 1) + self.assertEqual(ev.data, sys.maxsize) self.assertEqual(ev.udata, bignum) self.assertEqual(ev, ev) self.assertNotEqual(ev, other) @@ -96,6 +96,11 @@ pass # FreeBSD doesn't raise an exception here server, addr = serverSocket.accept() + if sys.platform.startswith("darwin"): + flags = select.KQ_EV_ADD | select.KQ_EV_ENABLE + else: + flags = 0 + kq = select.kqueue() kq2 = select.kqueue.fromfd(kq.fileno()) @@ -117,10 +122,11 @@ kq2.control([ev], 0) events = kq.control(None, 4, 1) - events = set((e.ident, e.filter) for e in events) - self.assertEqual(events, set([ - (client.fileno(), select.KQ_FILTER_WRITE), - (server.fileno(), select.KQ_FILTER_WRITE)])) + events = [(e.ident, e.filter, e.flags) for e in events] + events.sort() + self.assertEqual(events, [ + (client.fileno(), select.KQ_FILTER_WRITE, flags), + (server.fileno(), select.KQ_FILTER_WRITE, flags)]) client.send("Hello!") server.send("world!!!") @@ -134,12 +140,14 @@ else: self.fail('timeout waiting for event notifications') - events = set((e.ident, e.filter) for e in events) - self.assertEqual(events, set([ - (client.fileno(), select.KQ_FILTER_WRITE), - (client.fileno(), select.KQ_FILTER_READ), - (server.fileno(), select.KQ_FILTER_WRITE), - (server.fileno(), select.KQ_FILTER_READ)])) + events = [(e.ident, e.filter, e.flags) for e in events] + events.sort() + + self.assertEqual(events, [ + (client.fileno(), select.KQ_FILTER_WRITE, flags), + (client.fileno(), select.KQ_FILTER_READ, flags), + (server.fileno(), select.KQ_FILTER_WRITE, flags), + (server.fileno(), select.KQ_FILTER_READ, flags)]) # Remove completely client, and server read part ev = select.kevent(client.fileno(), @@ -156,9 +164,10 @@ kq.control([ev], 0, 0) events = kq.control([], 4, 0.99) - events = set((e.ident, e.filter) for e in events) - self.assertEqual(events, set([ - (server.fileno(), select.KQ_FILTER_WRITE)])) + events = [(e.ident, e.filter, e.flags) for e in events] + events.sort() + self.assertEqual(events, [ + (server.fileno(), select.KQ_FILTER_WRITE, flags)]) client.close() server.close() diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Lib/test/test_locale.py --- a/Lib/test/test_locale.py Sat Jul 19 16:34:33 2014 -0700 +++ b/Lib/test/test_locale.py Sun Jul 20 10:52:46 2014 -0400 @@ -1,4 +1,5 @@ from test.test_support import run_unittest, verbose +from platform import linux_distribution import unittest import locale import sys @@ -372,77 +373,6 @@ self.assertEqual('\xec\xa0\xbc'.split(), ['\xec\xa0\xbc']) -class NormalizeTest(unittest.TestCase): - def check(self, localename, expected): - self.assertEqual(locale.normalize(localename), expected, msg=localename) - - def test_locale_alias(self): - for localename, alias in locale.locale_alias.items(): - self.check(localename, alias) - - def test_empty(self): - self.check('', '') - - def test_c(self): - self.check('c', 'C') - self.check('posix', 'C') - - def test_english(self): - self.check('en', 'en_US.ISO8859-1') - self.check('EN', 'en_US.ISO8859-1') - self.check('en_US', 'en_US.ISO8859-1') - self.check('en_us', 'en_US.ISO8859-1') - self.check('en_GB', 'en_GB.ISO8859-1') - self.check('en_US.UTF-8', 'en_US.UTF-8') - self.check('en_US.utf8', 'en_US.UTF-8') - self.check('en_US:UTF-8', 'en_US.UTF-8') - self.check('en_US.ISO8859-1', 'en_US.ISO8859-1') - self.check('en_US.US-ASCII', 'en_US.ISO8859-1') - self.check('english', 'en_EN.ISO8859-1') - - def test_hyphenated_encoding(self): - self.check('az_AZ.iso88599e', 'az_AZ.ISO8859-9E') - self.check('az_AZ.ISO8859-9E', 'az_AZ.ISO8859-9E') - self.check('tt_RU.koi8c', 'tt_RU.KOI8-C') - self.check('tt_RU.KOI8-C', 'tt_RU.KOI8-C') - self.check('lo_LA.cp1133', 'lo_LA.IBM-CP1133') - self.check('lo_LA.ibmcp1133', 'lo_LA.IBM-CP1133') - self.check('lo_LA.IBM-CP1133', 'lo_LA.IBM-CP1133') - self.check('uk_ua.microsoftcp1251', 'uk_UA.CP1251') - self.check('uk_ua.microsoft-cp1251', 'uk_UA.CP1251') - self.check('ka_ge.georgianacademy', 'ka_GE.GEORGIAN-ACADEMY') - self.check('ka_GE.GEORGIAN-ACADEMY', 'ka_GE.GEORGIAN-ACADEMY') - self.check('cs_CZ.iso88592', 'cs_CZ.ISO8859-2') - self.check('cs_CZ.ISO8859-2', 'cs_CZ.ISO8859-2') - - def test_euro_modifier(self): - self.check('de_DE@euro', 'de_DE.ISO8859-15') - self.check('en_US.ISO8859-15@euro', 'en_US.ISO8859-15') - - def test_latin_modifier(self): - self.check('be_BY.UTF-8@latin', 'be_BY.UTF-8@latin') - self.check('sr_RS.UTF-8@latin', 'sr_RS.UTF-8@latin') - - def test_valencia_modifier(self): - self.check('ca_ES.UTF-8@valencia', 'ca_ES.UTF-8@valencia') - self.check('ca_ES@valencia', 'ca_ES.ISO8859-1@valencia') - self.check('ca@valencia', 'ca_ES.ISO8859-1@valencia') - - def test_devanagari_modifier(self): - self.check('ks_IN.UTF-8@devanagari', 'ks_IN.UTF-8@devanagari') - self.check('ks_IN@devanagari', 'ks_IN.UTF-8@devanagari') - self.check('ks@devanagari', 'ks_IN.UTF-8@devanagari') - self.check('ks_IN.UTF-8', 'ks_IN.UTF-8') - self.check('ks_IN', 'ks_IN.UTF-8') - self.check('ks', 'ks_IN.UTF-8') - self.check('sd_IN.UTF-8@devanagari', 'sd_IN.UTF-8@devanagari') - self.check('sd_IN@devanagari', 'sd_IN.UTF-8@devanagari') - self.check('sd@devanagari', 'sd_IN.UTF-8@devanagari') - self.check('sd_IN.UTF-8', 'sd_IN.UTF-8') - self.check('sd_IN', 'sd_IN.UTF-8') - self.check('sd', 'sd_IN.UTF-8') - - class TestMiscellaneous(unittest.TestCase): def test_getpreferredencoding(self): # Invoke getpreferredencoding to make sure it does not cause exceptions. @@ -467,25 +397,19 @@ # crasher from bug #7419 self.assertRaises(locale.Error, locale.setlocale, 12345) + @unittest.skipIf(linux_distribution()[0] == 'Fedora', "Fedora setlocale() " + "bug: https://bugzilla.redhat.com/show_bug.cgi?id=726536") def test_getsetlocale_issue1813(self): # Issue #1813: setting and getting the locale under a Turkish locale oldlocale = locale.getlocale() self.addCleanup(locale.setlocale, locale.LC_CTYPE, oldlocale) - for loc in ('tr_TR', 'tr_TR.UTF-8', 'tr_TR.ISO8859-9'): - try: - locale.setlocale(locale.LC_CTYPE, loc) - break - except locale.Error: - continue - else: + try: + locale.setlocale(locale.LC_CTYPE, 'tr_TR') + except locale.Error: # Unsupported locale on this system self.skipTest('test needs Turkish locale') loc = locale.getlocale() - try: - locale.setlocale(locale.LC_CTYPE, loc) - except Exception as e: - self.fail("Failed to set locale %r (default locale is %r): %r" % - (loc, oldlocale, e)) + locale.setlocale(locale.LC_CTYPE, loc) self.assertEqual(loc, locale.getlocale()) def test_normalize_issue12752(self): diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Lib/test/test_logging.py --- a/Lib/test/test_logging.py Sat Jul 19 16:34:33 2014 -0700 +++ b/Lib/test/test_logging.py Sun Jul 20 10:52:46 2014 -0400 @@ -1,4 +1,6 @@ -# Copyright 2001-2013 by Vinay Sajip. All Rights Reserved. +#!/usr/bin/env python +# +# Copyright 2001-2010 by Vinay Sajip. All Rights Reserved. # # Permission to use, copy, modify, and distribute this software and its # documentation for any purpose and without fee is hereby granted, @@ -16,7 +18,7 @@ """Test harness for the logging module. Run all tests. -Copyright (C) 2001-2013 Vinay Sajip. All Rights Reserved. +Copyright (C) 2001-2010 Vinay Sajip. All Rights Reserved. """ import logging @@ -29,7 +31,6 @@ import gc import json import os -import random import re import select import socket @@ -39,7 +40,6 @@ import tempfile from test.test_support import captured_stdout, run_with_locale, run_unittest import textwrap -import time import unittest import warnings import weakref @@ -712,30 +712,9 @@ datefmt= """ - disable_test = """ - [loggers] - keys=root - - [handlers] - keys=screen - - [formatters] - keys= - - [logger_root] - level=DEBUG - handlers=screen - - [handler_screen] - level=DEBUG - class=StreamHandler - args=(sys.stdout,) - formatter= - """ - - def apply_config(self, conf, **kwargs): + def apply_config(self, conf): file = cStringIO.StringIO(textwrap.dedent(conf)) - logging.config.fileConfig(file, **kwargs) + logging.config.fileConfig(file) def test_config0_ok(self): # A simple config file which overrides the default settings. @@ -839,15 +818,6 @@ # Original logger output is empty. self.assert_log_lines([]) - def test_logger_disabling(self): - self.apply_config(self.disable_test) - logger = logging.getLogger('foo') - self.assertFalse(logger.disabled) - self.apply_config(self.disable_test) - self.assertTrue(logger.disabled) - self.apply_config(self.disable_test, disable_existing_loggers=False) - self.assertFalse(logger.disabled) - class LogRecordStreamHandler(StreamRequestHandler): """Handler for a streaming logging request. It saves the log message in the @@ -1058,24 +1028,6 @@ #Compare against what the data should be when encoded in CP-1251 self.assertEqual(s, '\xe4\xee \xf1\xe2\xe8\xe4\xe0\xed\xe8\xff\n') - def test_encoding_utf16_unicode(self): - # Issue #19267 - log = logging.getLogger("test") - message = u'b\u0142\u0105d' - writer_class = codecs.getwriter('utf-16-le') - writer_class.encoding = 'utf-16-le' - stream = cStringIO.StringIO() - writer = writer_class(stream, 'strict') - handler = logging.StreamHandler(writer) - log.addHandler(handler) - try: - log.warning(message) - finally: - log.removeHandler(handler) - handler.close() - s = stream.getvalue() - self.assertEqual(s, 'b\x00B\x01\x05\x01d\x00\n\x00') - class WarningsTest(BaseTest): @@ -1631,36 +1583,6 @@ }, } - out_of_order = { - "version": 1, - "formatters": { - "mySimpleFormatter": { - "format": "%(asctime)s (%(name)s) %(levelname)s: %(message)s" - } - }, - "handlers": { - "fileGlobal": { - "class": "logging.StreamHandler", - "level": "DEBUG", - "formatter": "mySimpleFormatter" - }, - "bufferGlobal": { - "class": "logging.handlers.MemoryHandler", - "capacity": 5, - "formatter": "mySimpleFormatter", - "target": "fileGlobal", - "level": "DEBUG" - } - }, - "loggers": { - "mymodule": { - "level": "DEBUG", - "handlers": ["bufferGlobal"], - "propagate": "true" - } - } - } - def apply_config(self, conf): logging.config.dictConfig(conf) @@ -1915,10 +1837,6 @@ # Original logger output is empty. self.assert_log_lines([]) - def test_out_of_order(self): - self.apply_config(self.out_of_order) - handler = logging.getLogger('mymodule').handlers[0] - self.assertIsInstance(handler.target, logging.Handler) class ManagerTest(BaseTest): def test_manager_loggerclass(self): @@ -1955,47 +1873,6 @@ self.assertTrue(c2 is c3) -class HandlerTest(BaseTest): - - @unittest.skipIf(os.name == 'nt', 'WatchedFileHandler not appropriate for Windows.') - @unittest.skipUnless(threading, 'Threading required for this test.') - def test_race(self): - # Issue #14632 refers. - def remove_loop(fname, tries): - for _ in range(tries): - try: - os.unlink(fname) - except OSError: - pass - time.sleep(0.004 * random.randint(0, 4)) - - del_count = 500 - log_count = 500 - - for delay in (False, True): - fd, fn = tempfile.mkstemp('.log', 'test_logging-3-') - os.close(fd) - remover = threading.Thread(target=remove_loop, args=(fn, del_count)) - remover.daemon = True - remover.start() - h = logging.handlers.WatchedFileHandler(fn, delay=delay) - f = logging.Formatter('%(asctime)s: %(levelname)s: %(message)s') - h.setFormatter(f) - try: - for _ in range(log_count): - time.sleep(0.005) - r = logging.makeLogRecord({'msg': 'testing' }) - h.handle(r) - finally: - remover.join() - try: - h.close() - except ValueError: - pass - if os.path.exists(fn): - os.unlink(fn) - - # Set the locale to the platform-dependent default. I have no idea # why the test does this, but in any case we save the current locale # first and restore it at the end. @@ -2005,7 +1882,7 @@ CustomLevelsAndFiltersTest, MemoryHandlerTest, ConfigFileTest, SocketHandlerTest, MemoryTest, EncodingTest, WarningsTest, ConfigDictTest, ManagerTest, - ChildLoggerTest, HandlerTest) + ChildLoggerTest) if __name__ == "__main__": test_main() diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Lib/test/test_long.py --- a/Lib/test/test_long.py Sat Jul 19 16:34:33 2014 -0700 +++ b/Lib/test/test_long.py Sun Jul 20 10:52:46 2014 -0400 @@ -1,11 +1,10 @@ import unittest +from test import test_support import sys import random import math -from test import test_int, test_support - # Used for lazy formatting of failure messages class Frm(object): def __init__(self, format, *args): @@ -79,9 +78,8 @@ (unichr(0x200), ValueError), ] -class LongTest(test_int.IntLongCommonTests, unittest.TestCase): - ntype = long +class LongTest(unittest.TestCase): # Get quasi-random long consisting of ndigits digits (in base BASE). # quasi == the most-significant digit will not be 0, and the number @@ -90,7 +88,7 @@ # The sign of the number is also random. def getran(self, ndigits): - self.assertGreater(ndigits, 0) + self.assertTrue(ndigits > 0) nbits_hi = ndigits * SHIFT nbits_lo = nbits_hi - SHIFT + 1 answer = 0L @@ -588,7 +586,7 @@ pass x = long2(1L<<100) y = int(x) - self.assertIs(type(y), long, + self.assertTrue(type(y) is long, "overflowing int conversion must return long not long subtype") # long -> Py_ssize_t conversion diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Lib/test/test_macos.py --- a/Lib/test/test_macos.py Sat Jul 19 16:34:33 2014 -0700 +++ b/Lib/test/test_macos.py Sun Jul 20 10:52:46 2014 -0400 @@ -8,9 +8,11 @@ TESTFN2 = test_support.TESTFN + '2' class TestMacOS(unittest.TestCase): - @unittest.skipUnless(os.path.exists('/Developer/Tools/SetFile'), - '/Developer/Tools/SetFile does not exist') + def testGetCreatorAndType(self): + if not os.path.exists('/Developer/Tools/SetFile'): + return + try: fp = open(test_support.TESTFN, 'w') fp.write('\n') @@ -27,9 +29,10 @@ finally: os.unlink(test_support.TESTFN) - @unittest.skipUnless(os.path.exists('/Developer/Tools/GetFileInfo'), - '/Developer/Tools/GetFileInfo does not exist') def testSetCreatorAndType(self): + if not os.path.exists('/Developer/Tools/GetFileInfo'): + return + try: fp = open(test_support.TESTFN, 'w') fp.write('\n') diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Lib/test/test_macostools.py --- a/Lib/test/test_macostools.py Sat Jul 19 16:34:33 2014 -0700 +++ b/Lib/test/test_macostools.py Sun Jul 20 10:52:46 2014 -0400 @@ -12,8 +12,6 @@ TESTFN2 = test_support.TESTFN + '2' -requires_32bit = unittest.skipUnless(sys.maxint < 2**32, '32-bit only test') - class TestMacostools(unittest.TestCase): def setUp(self): @@ -53,32 +51,30 @@ DeprecationWarning), quiet=True): macostools.touched(test_support.TESTFN) - @requires_32bit - def test_copy(self): - test_support.unlink(TESTFN2) - macostools.copy(test_support.TESTFN, TESTFN2) - self.assertEqual(self.compareData(), '') + if sys.maxint < 2**32: + def test_copy(self): + test_support.unlink(TESTFN2) + macostools.copy(test_support.TESTFN, TESTFN2) + self.assertEqual(self.compareData(), '') - @requires_32bit - def test_mkalias(self): - test_support.unlink(TESTFN2) - macostools.mkalias(test_support.TESTFN, TESTFN2) - fss, _, _ = Carbon.File.ResolveAliasFile(TESTFN2, 0) - self.assertEqual(fss.as_pathname(), os.path.realpath(test_support.TESTFN)) + if sys.maxint < 2**32: + def test_mkalias(self): + test_support.unlink(TESTFN2) + macostools.mkalias(test_support.TESTFN, TESTFN2) + fss, _, _ = Carbon.File.ResolveAliasFile(TESTFN2, 0) + self.assertEqual(fss.as_pathname(), os.path.realpath(test_support.TESTFN)) - @requires_32bit - # If the directory doesn't exist, then chances are this is a new - # install of Python so don't create it since the user might end up - # running ``sudo make install`` and creating the directory here won't - # leave it with the proper permissions. - @unittest.skipUnless(os.path.exists(sys.prefix), - "%r doesn't exist" % sys.prefix) - def test_mkalias_relative(self): - test_support.unlink(TESTFN2) - - macostools.mkalias(test_support.TESTFN, TESTFN2, sys.prefix) - fss, _, _ = Carbon.File.ResolveAliasFile(TESTFN2, 0) - self.assertEqual(fss.as_pathname(), os.path.realpath(test_support.TESTFN)) + def test_mkalias_relative(self): + test_support.unlink(TESTFN2) + # If the directory doesn't exist, then chances are this is a new + # install of Python so don't create it since the user might end up + # running ``sudo make install`` and creating the directory here won't + # leave it with the proper permissions. + if not os.path.exists(sys.prefix): + return + macostools.mkalias(test_support.TESTFN, TESTFN2, sys.prefix) + fss, _, _ = Carbon.File.ResolveAliasFile(TESTFN2, 0) + self.assertEqual(fss.as_pathname(), os.path.realpath(test_support.TESTFN)) def test_main(): diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Lib/test/test_macurl2path.py --- a/Lib/test/test_macurl2path.py Sat Jul 19 16:34:33 2014 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,31 +0,0 @@ -import macurl2path -import unittest - -class MacUrl2PathTestCase(unittest.TestCase): - def test_url2pathname(self): - self.assertEqual(":index.html", macurl2path.url2pathname("index.html")) - self.assertEqual(":bar:index.html", macurl2path.url2pathname("bar/index.html")) - self.assertEqual("foo:bar:index.html", macurl2path.url2pathname("/foo/bar/index.html")) - self.assertEqual("foo:bar", macurl2path.url2pathname("/foo/bar/")) - self.assertEqual("", macurl2path.url2pathname("/")) - self.assertRaises(RuntimeError, macurl2path.url2pathname, "http://foo.com") - self.assertEqual("index.html", macurl2path.url2pathname("///index.html")) - self.assertRaises(RuntimeError, macurl2path.url2pathname, "//index.html") - self.assertEqual(":index.html", macurl2path.url2pathname("./index.html")) - self.assertEqual(":index.html", macurl2path.url2pathname("foo/../index.html")) - self.assertEqual("::index.html", macurl2path.url2pathname("../index.html")) - - def test_pathname2url(self): - self.assertEqual("drive", macurl2path.pathname2url("drive:")) - self.assertEqual("drive/dir", macurl2path.pathname2url("drive:dir:")) - self.assertEqual("drive/dir/file", macurl2path.pathname2url("drive:dir:file")) - self.assertEqual("drive/file", macurl2path.pathname2url("drive:file")) - self.assertEqual("file", macurl2path.pathname2url("file")) - self.assertEqual("file", macurl2path.pathname2url(":file")) - self.assertEqual("dir", macurl2path.pathname2url(":dir:")) - self.assertEqual("dir/file", macurl2path.pathname2url(":dir:file")) - self.assertRaises(RuntimeError, macurl2path.pathname2url, "/") - self.assertEqual("dir/../file", macurl2path.pathname2url("dir::file")) - -if __name__ == "__main__": - unittest.main() diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Lib/test/test_mailbox.py --- a/Lib/test/test_mailbox.py Sat Jul 19 16:34:33 2014 -0700 +++ b/Lib/test/test_mailbox.py Sun Jul 20 10:52:46 2014 -0400 @@ -6,9 +6,7 @@ import email import email.message import re -import shutil import StringIO -import tempfile from test import test_support import unittest import mailbox @@ -21,7 +19,7 @@ # Silence Py3k warning rfc822 = test_support.import_module('rfc822', deprecated=True) -class TestBase: +class TestBase(unittest.TestCase): def _check_sample(self, msg): # Inspect a mailbox.Message representation of the sample message @@ -40,15 +38,20 @@ def _delete_recursively(self, target): # Delete a file or delete a directory recursively if os.path.isdir(target): - test_support.rmtree(target) + for path, dirs, files in os.walk(target, topdown=False): + for name in files: + os.remove(os.path.join(path, name)) + for name in dirs: + os.rmdir(os.path.join(path, name)) + os.rmdir(target) elif os.path.exists(target): - test_support.unlink(target) + os.remove(target) class TestMailbox(TestBase): _factory = None # Overridden by subclasses to reuse tests - _template = 'From: foo\n\n%s\n' + _template = 'From: foo\n\n%s' def setUp(self): self._path = test_support.TESTFN @@ -76,18 +79,6 @@ for i in (1, 2, 3, 4): self._check_sample(self._box[keys[i]]) - def test_add_file(self): - with tempfile.TemporaryFile('w+') as f: - f.write(_sample_message) - f.seek(0) - key = self._box.add(f) - self.assertEqual(self._box.get_string(key).split('\n'), - _sample_message.split('\n')) - - def test_add_StringIO(self): - key = self._box.add(StringIO.StringIO(self._template % "0")) - self.assertEqual(self._box.get_string(key), self._template % "0") - def test_remove(self): # Remove messages using remove() self._test_remove_or_delitem(self._box.remove) @@ -137,23 +128,22 @@ key0 = self._box.add(self._template % 0) msg = self._box.get(key0) self.assertEqual(msg['from'], 'foo') - self.assertEqual(msg.get_payload(), '0\n') - self.assertIsNone(self._box.get('foo')) + self.assertEqual(msg.get_payload(), '0') + self.assertIs(self._box.get('foo'), None) self.assertFalse(self._box.get('foo', False)) self._box.close() self._box = self._factory(self._path, factory=rfc822.Message) key1 = self._box.add(self._template % 1) msg = self._box.get(key1) self.assertEqual(msg['from'], 'foo') - self.assertEqual(msg.fp.read(), '1' + os.linesep) - msg.fp.close() + self.assertEqual(msg.fp.read(), '1') def test_getitem(self): # Retrieve message using __getitem__() key0 = self._box.add(self._template % 0) msg = self._box[key0] self.assertEqual(msg['from'], 'foo') - self.assertEqual(msg.get_payload(), '0\n') + self.assertEqual(msg.get_payload(), '0') self.assertRaises(KeyError, lambda: self._box['foo']) self._box.discard(key0) self.assertRaises(KeyError, lambda: self._box[key0]) @@ -165,7 +155,7 @@ msg0 = self._box.get_message(key0) self.assertIsInstance(msg0, mailbox.Message) self.assertEqual(msg0['from'], 'foo') - self.assertEqual(msg0.get_payload(), '0\n') + self.assertEqual(msg0.get_payload(), '0') self._check_sample(self._box.get_message(key1)) def test_get_string(self): @@ -179,14 +169,10 @@ # Get file representations of messages key0 = self._box.add(self._template % 0) key1 = self._box.add(_sample_message) - msg0 = self._box.get_file(key0) - self.assertEqual(msg0.read().replace(os.linesep, '\n'), + self.assertEqual(self._box.get_file(key0).read().replace(os.linesep, '\n'), self._template % 0) - msg1 = self._box.get_file(key1) - self.assertEqual(msg1.read().replace(os.linesep, '\n'), + self.assertEqual(self._box.get_file(key1).read().replace(os.linesep, '\n'), _sample_message) - msg0.close() - msg1.close() def test_get_file_can_be_closed_twice(self): # Issue 11700 @@ -249,7 +235,8 @@ count = 0 for value in returned_values: self.assertEqual(value['from'], 'foo') - self.assertLess(int(value.get_payload()), repetitions) + self.assertTrue(int(value.get_payload()) < repetitions, + (value.get_payload(), repetitions)) count += 1 self.assertEqual(len(values), count) @@ -337,15 +324,15 @@ self.assertIn(key0, self._box) key1 = self._box.add(self._template % 1) self.assertIn(key1, self._box) - self.assertEqual(self._box.pop(key0).get_payload(), '0\n') + self.assertEqual(self._box.pop(key0).get_payload(), '0') self.assertNotIn(key0, self._box) self.assertIn(key1, self._box) key2 = self._box.add(self._template % 2) self.assertIn(key2, self._box) - self.assertEqual(self._box.pop(key2).get_payload(), '2\n') + self.assertEqual(self._box.pop(key2).get_payload(), '2') self.assertNotIn(key2, self._box) self.assertIn(key1, self._box) - self.assertEqual(self._box.pop(key1).get_payload(), '1\n') + self.assertEqual(self._box.pop(key1).get_payload(), '1') self.assertNotIn(key1, self._box) self.assertEqual(len(self._box), 0) @@ -403,17 +390,6 @@ # Write changes to disk self._test_flush_or_close(self._box.flush, True) - def test_popitem_and_flush_twice(self): - # See #15036. - self._box.add(self._template % 0) - self._box.add(self._template % 1) - self._box.flush() - - self._box.popitem() - self._box.flush() - self._box.popitem() - self._box.flush() - def test_lock_unlock(self): # Lock and unlock the mailbox self.assertFalse(os.path.exists(self._get_lock_path())) @@ -431,7 +407,6 @@ self._box.add(contents[0]) self._box.add(contents[1]) self._box.add(contents[2]) - oldbox = self._box method() if should_call_close: self._box.close() @@ -440,7 +415,6 @@ self.assertEqual(len(keys), 3) for key in keys: self.assertIn(self._box.get_string(key), contents) - oldbox.close() def test_dump_message(self): # Write message representations to disk @@ -459,7 +433,7 @@ return self._path + '.lock' -class TestMailboxSuperclass(TestBase, unittest.TestCase): +class TestMailboxSuperclass(TestBase): def test_notimplemented(self): # Test that all Mailbox methods raise NotImplementedException. @@ -494,7 +468,7 @@ self.assertRaises(NotImplementedError, lambda: box.close()) -class TestMaildir(TestMailbox, unittest.TestCase): +class TestMaildir(TestMailbox): _factory = lambda self, path, factory=None: mailbox.Maildir(path, factory) @@ -536,7 +510,7 @@ msg_returned = self._box.get_message(key) self.assertEqual(msg_returned.get_subdir(), 'new') self.assertEqual(msg_returned.get_flags(), '') - self.assertEqual(msg_returned.get_payload(), '1\n') + self.assertEqual(msg_returned.get_payload(), '1') msg2 = mailbox.MaildirMessage(self._template % 2) msg2.set_info('2,S') self._box[key] = msg2 @@ -544,7 +518,7 @@ msg_returned = self._box.get_message(key) self.assertEqual(msg_returned.get_subdir(), 'new') self.assertEqual(msg_returned.get_flags(), 'S') - self.assertEqual(msg_returned.get_payload(), '3\n') + self.assertEqual(msg_returned.get_payload(), '3') def test_consistent_factory(self): # Add a message. @@ -663,32 +637,32 @@ "tmp")), "File in wrong location: '%s'" % head) match = pattern.match(tail) - self.assertIsNotNone(match, "Invalid file name: '%s'" % tail) + self.assertTrue(match is not None, "Invalid file name: '%s'" % tail) groups = match.groups() if previous_groups is not None: - self.assertGreaterEqual(int(groups[0]), int(previous_groups[0]), + self.assertTrue(int(groups[0] >= previous_groups[0]), "Non-monotonic seconds: '%s' before '%s'" % (previous_groups[0], groups[0])) - if int(groups[0]) == int(previous_groups[0]): - self.assertGreaterEqual(int(groups[1]), int(previous_groups[1]), - "Non-monotonic milliseconds: '%s' before '%s'" % - (previous_groups[1], groups[1])) - self.assertEqual(int(groups[2]), pid, + self.assertTrue(int(groups[1] >= previous_groups[1]) or + groups[0] != groups[1], + "Non-monotonic milliseconds: '%s' before '%s'" % + (previous_groups[1], groups[1])) + self.assertTrue(int(groups[2]) == pid, "Process ID mismatch: '%s' should be '%s'" % (groups[2], pid)) - self.assertEqual(int(groups[3]), int(previous_groups[3]) + 1, + self.assertTrue(int(groups[3]) == int(previous_groups[3]) + 1, "Non-sequential counter: '%s' before '%s'" % (previous_groups[3], groups[3])) - self.assertEqual(groups[4], hostname, + self.assertTrue(groups[4] == hostname, "Host name mismatch: '%s' should be '%s'" % (groups[4], hostname)) previous_groups = groups tmp_file.write(_sample_message) tmp_file.seek(0) - self.assertEqual(tmp_file.read(), _sample_message) + self.assertTrue(tmp_file.read() == _sample_message) tmp_file.close() file_count = len(os.listdir(os.path.join(self._path, "tmp"))) - self.assertEqual(file_count, repetitions, + self.assertTrue(file_count == repetitions, "Wrong file count: '%s' should be '%s'" % (file_count, repetitions)) @@ -771,10 +745,10 @@ for msg in self._box: pass - @unittest.skipUnless(hasattr(os, 'umask'), 'test needs os.umask()') - @unittest.skipUnless(hasattr(os, 'stat'), 'test needs os.stat()') def test_file_permissions(self): # Verify that message files are created without execute permissions + if not hasattr(os, "stat") or not hasattr(os, "umask"): + return msg = mailbox.MaildirMessage(self._template % 0) orig_umask = os.umask(0) try: @@ -785,11 +759,12 @@ mode = os.stat(path).st_mode self.assertEqual(mode & 0111, 0) - @unittest.skipUnless(hasattr(os, 'umask'), 'test needs os.umask()') - @unittest.skipUnless(hasattr(os, 'stat'), 'test needs os.stat()') def test_folder_file_perms(self): # From bug #3228, we want to verify that the file created inside a Maildir # subfolder isn't marked as executable. + if not hasattr(os, "stat") or not hasattr(os, "umask"): + return + orig_umask = os.umask(0) try: subfolder = self._box.add_folder('subfolder') @@ -842,49 +817,7 @@ self._box._refresh() self.assertTrue(refreshed()) - -class _TestSingleFile(TestMailbox): - '''Common tests for single-file mailboxes''' - - def test_add_doesnt_rewrite(self): - # When only adding messages, flush() should not rewrite the - # mailbox file. See issue #9559. - - # Inode number changes if the contents are written to another - # file which is then renamed over the original file. So we - # must check that the inode number doesn't change. - inode_before = os.stat(self._path).st_ino - - self._box.add(self._template % 0) - self._box.flush() - - inode_after = os.stat(self._path).st_ino - self.assertEqual(inode_before, inode_after) - - # Make sure the message was really added - self._box.close() - self._box = self._factory(self._path) - self.assertEqual(len(self._box), 1) - - def test_permissions_after_flush(self): - # See issue #5346 - - # Make the mailbox world writable. It's unlikely that the new - # mailbox file would have these permissions after flush(), - # because umask usually prevents it. - mode = os.stat(self._path).st_mode | 0o666 - os.chmod(self._path, mode) - - self._box.add(self._template % 0) - i = self._box.add(self._template % 1) - # Need to remove one message to make flush() create a new file - self._box.remove(i) - self._box.flush() - - self.assertEqual(os.stat(self._path).st_mode, mode) - - -class _TestMboxMMDF(_TestSingleFile): +class _TestMboxMMDF(TestMailbox): def tearDown(self): self._box.close() @@ -894,14 +827,14 @@ def test_add_from_string(self): # Add a string starting with 'From ' to the mailbox - key = self._box.add('From foo@bar blah\nFrom: foo\n\n0\n') + key = self._box.add('From foo@bar blah\nFrom: foo\n\n0') self.assertEqual(self._box[key].get_from(), 'foo@bar blah') - self.assertEqual(self._box[key].get_payload(), '0\n') + self.assertEqual(self._box[key].get_payload(), '0') def test_add_mbox_or_mmdf_message(self): # Add an mboxMessage or MMDFMessage for class_ in (mailbox.mboxMessage, mailbox.MMDFMessage): - msg = class_('From foo@bar blah\nFrom: foo\n\n0\n') + msg = class_('From foo@bar blah\nFrom: foo\n\n0') key = self._box.add(msg) def test_open_close_open(self): @@ -932,37 +865,26 @@ self.assertEqual(contents, f.read()) self._box = self._factory(self._path) - @unittest.skipUnless(hasattr(os, 'fork'), "Test needs fork().") - @unittest.skipUnless(hasattr(socket, 'socketpair'), "Test needs socketpair().") def test_lock_conflict(self): - # Fork off a child process that will lock the mailbox temporarily, - # unlock it and exit. - c, p = socket.socketpair() - self.addCleanup(c.close) - self.addCleanup(p.close) - + # Fork off a subprocess that will lock the file for 2 seconds, + # unlock it, and then exit. + if not hasattr(os, 'fork'): + return pid = os.fork() if pid == 0: - # child - try: - # lock the mailbox, and signal the parent it can proceed - self._box.lock() - c.send(b'c') + # In the child, lock the mailbox. + self._box.lock() + time.sleep(2) + self._box.unlock() + os._exit(0) - # wait until the parent is done, and unlock the mailbox - c.recv(1) - self._box.unlock() - finally: - os._exit(0) - - # In the parent, wait until the child signals it locked the mailbox. - p.recv(1) + # In the parent, sleep a bit to give the child time to acquire + # the lock. + time.sleep(0.5) try: self.assertRaises(mailbox.ExternalClashError, self._box.lock) finally: - # Signal the child it can now release the lock and exit. - p.send(b'p') # Wait for child to exit. Locking should now succeed. exited_pid, status = os.waitpid(pid, 0) @@ -985,59 +907,35 @@ self._box.close() -class TestMbox(_TestMboxMMDF, unittest.TestCase): +class TestMbox(_TestMboxMMDF): _factory = lambda self, path, factory=None: mailbox.mbox(path, factory) - @unittest.skipUnless(hasattr(os, 'umask'), 'test needs os.umask()') - @unittest.skipUnless(hasattr(os, 'stat'), 'test needs os.stat()') def test_file_perms(self): # From bug #3228, we want to verify that the mailbox file isn't executable, # even if the umask is set to something that would leave executable bits set. # We only run this test on platforms that support umask. - try: - old_umask = os.umask(0077) - self._box.close() - os.unlink(self._path) - self._box = mailbox.mbox(self._path, create=True) - self._box.add('') - self._box.close() - finally: - os.umask(old_umask) + if hasattr(os, 'umask') and hasattr(os, 'stat'): + try: + old_umask = os.umask(0077) + self._box.close() + os.unlink(self._path) + self._box = mailbox.mbox(self._path, create=True) + self._box.add('') + self._box.close() + finally: + os.umask(old_umask) - st = os.stat(self._path) - perms = st.st_mode - self.assertFalse((perms & 0111)) # Execute bits should all be off. + st = os.stat(self._path) + perms = st.st_mode + self.assertFalse((perms & 0111)) # Execute bits should all be off. - def test_terminating_newline(self): - message = email.message.Message() - message['From'] = 'john@example.com' - message.set_payload('No newline at the end') - i = self._box.add(message) - - # A newline should have been appended to the payload - message = self._box.get(i) - self.assertEqual(message.get_payload(), 'No newline at the end\n') - - def test_message_separator(self): - # Check there's always a single blank line after each message - self._box.add('From: foo\n\n0') # No newline at the end - with open(self._path) as f: - data = f.read() - self.assertEqual(data[-3:], '0\n\n') - - self._box.add('From: foo\n\n0\n') # Newline at the end - with open(self._path) as f: - data = f.read() - self.assertEqual(data[-3:], '0\n\n') - - -class TestMMDF(_TestMboxMMDF, unittest.TestCase): +class TestMMDF(_TestMboxMMDF): _factory = lambda self, path, factory=None: mailbox.MMDF(path, factory) -class TestMH(TestMailbox, unittest.TestCase): +class TestMH(TestMailbox): _factory = lambda self, path, factory=None: mailbox.MH(path, factory) @@ -1169,7 +1067,7 @@ return os.path.join(self._path, '.mh_sequences.lock') -class TestBabyl(_TestSingleFile, unittest.TestCase): +class TestBabyl(TestMailbox): _factory = lambda self, path, factory=None: mailbox.Babyl(path, factory) @@ -1198,7 +1096,7 @@ self.assertEqual(set(self._box.get_labels()), set(['blah'])) -class TestMessage(TestBase, unittest.TestCase): +class TestMessage(TestBase): _factory = mailbox.Message # Overridden by subclasses to reuse tests @@ -1239,7 +1137,7 @@ self.assertIsInstance(msg, self._factory) self.assertEqual(msg.keys(), []) self.assertFalse(msg.is_multipart()) - self.assertIsNone(msg.get_payload()) + self.assertEqual(msg.get_payload(), None) def test_initialize_incorrectly(self): # Initialize with invalid argument @@ -1269,7 +1167,7 @@ pass -class TestMaildirMessage(TestMessage, unittest.TestCase): +class TestMaildirMessage(TestMessage): _factory = mailbox.MaildirMessage @@ -1312,7 +1210,7 @@ # Use get_date() and set_date() msg = mailbox.MaildirMessage(_sample_message) diff = msg.get_date() - time.time() - self.assertLess(abs(diff), 60, diff) + self.assertTrue(abs(diff) < 60, diff) msg.set_date(0.0) self.assertEqual(msg.get_date(), 0.0) @@ -1344,7 +1242,7 @@ self._check_sample(msg) -class _TestMboxMMDFMessage: +class _TestMboxMMDFMessage(TestMessage): _factory = mailbox._mboxMMDFMessage @@ -1387,17 +1285,16 @@ # Check contents of "From " line if sender is None: sender = "MAILER-DAEMON" - self.assertIsNotNone(re.match( - sender + r" \w{3} \w{3} [\d ]\d [\d ]\d:\d{2}:\d{2} \d{4}", - msg.get_from())) + self.assertTrue(re.match(sender + r" \w{3} \w{3} [\d ]\d [\d ]\d:\d{2}:" + r"\d{2} \d{4}", msg.get_from())) -class TestMboxMessage(_TestMboxMMDFMessage, TestMessage): +class TestMboxMessage(_TestMboxMMDFMessage): _factory = mailbox.mboxMessage -class TestMHMessage(TestMessage, unittest.TestCase): +class TestMHMessage(TestMessage): _factory = mailbox.MHMessage @@ -1428,7 +1325,7 @@ self.assertEqual(msg.get_sequences(), ['foobar', 'replied']) -class TestBabylMessage(TestMessage, unittest.TestCase): +class TestBabylMessage(TestMessage): _factory = mailbox.BabylMessage @@ -1463,7 +1360,7 @@ msg = mailbox.BabylMessage(_sample_message) visible = msg.get_visible() self.assertEqual(visible.keys(), []) - self.assertIsNone(visible.get_payload()) + self.assertIs(visible.get_payload(), None) visible['User-Agent'] = 'FooBar 1.0' visible['X-Whatever'] = 'Blah' self.assertEqual(msg.get_visible().keys(), []) @@ -1472,10 +1369,10 @@ self.assertEqual(visible.keys(), ['User-Agent', 'X-Whatever']) self.assertEqual(visible['User-Agent'], 'FooBar 1.0') self.assertEqual(visible['X-Whatever'], 'Blah') - self.assertIsNone(visible.get_payload()) + self.assertIs(visible.get_payload(), None) msg.update_visible() self.assertEqual(visible.keys(), ['User-Agent', 'X-Whatever']) - self.assertIsNone(visible.get_payload()) + self.assertIs(visible.get_payload(), None) visible = msg.get_visible() self.assertEqual(visible.keys(), ['User-Agent', 'Date', 'From', 'To', 'Subject']) @@ -1483,12 +1380,12 @@ self.assertEqual(visible[header], msg[header]) -class TestMMDFMessage(_TestMboxMMDFMessage, TestMessage): +class TestMMDFMessage(_TestMboxMMDFMessage): _factory = mailbox.MMDFMessage -class TestMessageConversion(TestBase, unittest.TestCase): +class TestMessageConversion(TestBase): def test_plain_to_x(self): # Convert Message to all formats @@ -1811,7 +1708,7 @@ proxy.close() -class TestProxyFile(TestProxyFileBase, unittest.TestCase): +class TestProxyFile(TestProxyFileBase): def setUp(self): self._path = test_support.TESTFN @@ -1860,7 +1757,7 @@ self._test_close(mailbox._ProxyFile(self._file)) -class TestPartialFile(TestProxyFileBase, unittest.TestCase): +class TestPartialFile(TestProxyFileBase): def setUp(self): self._path = test_support.TESTFN @@ -1927,10 +1824,6 @@ def setUp(self): # create a new maildir mailbox to work with: self._dir = test_support.TESTFN - if os.path.isdir(self._dir): - test_support.rmtree(self._dir) - if os.path.isfile(self._dir): - test_support.unlink(self._dir) os.mkdir(self._dir) os.mkdir(os.path.join(self._dir, "cur")) os.mkdir(os.path.join(self._dir, "tmp")) @@ -1940,10 +1833,10 @@ def tearDown(self): map(os.unlink, self._msgfiles) - test_support.rmdir(os.path.join(self._dir, "cur")) - test_support.rmdir(os.path.join(self._dir, "tmp")) - test_support.rmdir(os.path.join(self._dir, "new")) - test_support.rmdir(self._dir) + os.rmdir(os.path.join(self._dir, "cur")) + os.rmdir(os.path.join(self._dir, "tmp")) + os.rmdir(os.path.join(self._dir, "new")) + os.rmdir(self._dir) def createMessage(self, dir, mbox=False): t = int(time.time() % 1000000) @@ -1971,56 +1864,46 @@ # Make sure the boxes attribute actually gets set. self.mbox = mailbox.Maildir(test_support.TESTFN) #self.assertTrue(hasattr(self.mbox, "boxes")) - #self.assertEqual(len(self.mbox.boxes), 0) - self.assertIsNone(self.mbox.next()) - self.assertIsNone(self.mbox.next()) + #self.assertTrue(len(self.mbox.boxes) == 0) + self.assertIs(self.mbox.next(), None) + self.assertIs(self.mbox.next(), None) def test_nonempty_maildir_cur(self): self.createMessage("cur") self.mbox = mailbox.Maildir(test_support.TESTFN) - #self.assertEqual(len(self.mbox.boxes), 1) - msg = self.mbox.next() - self.assertIsNotNone(msg) - msg.fp.close() - self.assertIsNone(self.mbox.next()) - self.assertIsNone(self.mbox.next()) + #self.assertTrue(len(self.mbox.boxes) == 1) + self.assertIsNot(self.mbox.next(), None) + self.assertIs(self.mbox.next(), None) + self.assertIs(self.mbox.next(), None) def test_nonempty_maildir_new(self): self.createMessage("new") self.mbox = mailbox.Maildir(test_support.TESTFN) - #self.assertEqual(len(self.mbox.boxes), 1) - msg = self.mbox.next() - self.assertIsNotNone(msg) - msg.fp.close() - self.assertIsNone(self.mbox.next()) - self.assertIsNone(self.mbox.next()) + #self.assertTrue(len(self.mbox.boxes) == 1) + self.assertIsNot(self.mbox.next(), None) + self.assertIs(self.mbox.next(), None) + self.assertIs(self.mbox.next(), None) def test_nonempty_maildir_both(self): self.createMessage("cur") self.createMessage("new") self.mbox = mailbox.Maildir(test_support.TESTFN) - #self.assertEqual(len(self.mbox.boxes), 2) - msg = self.mbox.next() - self.assertIsNotNone(msg) - msg.fp.close() - msg = self.mbox.next() - self.assertIsNotNone(msg) - msg.fp.close() - self.assertIsNone(self.mbox.next()) - self.assertIsNone(self.mbox.next()) + #self.assertTrue(len(self.mbox.boxes) == 2) + self.assertIsNot(self.mbox.next(), None) + self.assertIsNot(self.mbox.next(), None) + self.assertIs(self.mbox.next(), None) + self.assertIs(self.mbox.next(), None) def test_unix_mbox(self): ### should be better! import email.parser fname = self.createMessage("cur", True) n = 0 - fid = open(fname) - for msg in mailbox.PortableUnixMailbox(fid, + for msg in mailbox.PortableUnixMailbox(open(fname), email.parser.Parser().parse): n += 1 self.assertEqual(msg["subject"], "Simple Test") self.assertEqual(len(str(msg)), len(FROM_)+len(DUMMY_MESSAGE)) - fid.close() self.assertEqual(n, 1) ## End: classes from the original module (for backward compatibility). diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Lib/test/test_marshal.py --- a/Lib/test/test_marshal.py Sat Jul 19 16:34:33 2014 -0700 +++ b/Lib/test/test_marshal.py Sun Jul 20 10:52:46 2014 -0400 @@ -1,3 +1,4 @@ +#!/usr/bin/env python # -*- coding: iso-8859-1 -*- from test import test_support @@ -268,53 +269,6 @@ invalid_string = 'l\x02\x00\x00\x00\x00\x00\x00\x00' self.assertRaises(ValueError, marshal.loads, invalid_string) -LARGE_SIZE = 2**31 -character_size = 4 if sys.maxunicode > 0xFFFF else 2 -pointer_size = 8 if sys.maxsize > 0xFFFFFFFF else 4 - -@unittest.skipIf(LARGE_SIZE > sys.maxsize, "test cannot run on 32-bit systems") -class LargeValuesTestCase(unittest.TestCase): - def check_unmarshallable(self, data): - f = open(test_support.TESTFN, 'wb') - self.addCleanup(test_support.unlink, test_support.TESTFN) - with f: - self.assertRaises(ValueError, marshal.dump, data, f) - - @test_support.precisionbigmemtest(size=LARGE_SIZE, memuse=1, dry_run=False) - def test_string(self, size): - self.check_unmarshallable('x' * size) - - @test_support.precisionbigmemtest(size=LARGE_SIZE, - memuse=character_size + 2, dry_run=False) - def test_unicode(self, size): - self.check_unmarshallable(u'x' * size) - - @test_support.precisionbigmemtest(size=LARGE_SIZE, - memuse=pointer_size, dry_run=False) - def test_tuple(self, size): - self.check_unmarshallable((None,) * size) - - @test_support.precisionbigmemtest(size=LARGE_SIZE, - memuse=pointer_size, dry_run=False) - def test_list(self, size): - self.check_unmarshallable([None] * size) - - @test_support.precisionbigmemtest(size=LARGE_SIZE, - memuse=pointer_size*12 + sys.getsizeof(LARGE_SIZE-1), - dry_run=False) - def test_set(self, size): - self.check_unmarshallable(set(range(size))) - - @test_support.precisionbigmemtest(size=LARGE_SIZE, - memuse=pointer_size*12 + sys.getsizeof(LARGE_SIZE-1), - dry_run=False) - def test_frozenset(self, size): - self.check_unmarshallable(frozenset(range(size))) - - @test_support.precisionbigmemtest(size=LARGE_SIZE, memuse=1, dry_run=False) - def test_bytearray(self, size): - self.check_unmarshallable(bytearray(size)) - def test_main(): test_support.run_unittest(IntTestCase, @@ -323,9 +277,7 @@ CodeTestCase, ContainerTestCase, ExceptionTestCase, - BugsTestCase, - LargeValuesTestCase, - ) + BugsTestCase) if __name__ == "__main__": test_main() diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Lib/test/test_math.py --- a/Lib/test/test_math.py Sat Jul 19 16:34:33 2014 -0700 +++ b/Lib/test/test_math.py Sun Jul 20 10:52:46 2014 -0400 @@ -599,9 +599,6 @@ self.assertEqual(math.log(INF), INF) self.assertRaises(ValueError, math.log, NINF) self.assertTrue(math.isnan(math.log(NAN))) - # Log values should match for int and long (issue #18739). - for n in range(1, 1000): - self.assertEqual(math.log(n), math.log(long(n))) def testLog1p(self): self.assertRaises(TypeError, math.log1p) @@ -624,9 +621,6 @@ self.assertEqual(math.log(INF), INF) self.assertRaises(ValueError, math.log10, NINF) self.assertTrue(math.isnan(math.log10(NAN))) - # Log values should match for int and long (issue #18739). - for n in range(1, 1000): - self.assertEqual(math.log10(n), math.log10(long(n))) def testModf(self): self.assertRaises(TypeError, math.modf) @@ -906,37 +900,38 @@ # still fails this part of the test on some platforms. For now, we only # *run* test_exceptions() in verbose mode, so that this isn't normally # tested. - @unittest.skipUnless(verbose, 'requires verbose mode') - def test_exceptions(self): - try: - x = math.exp(-1000000000) - except: - # mathmodule.c is failing to weed out underflows from libm, or - # we've got an fp format with huge dynamic range - self.fail("underflowing exp() should not have raised " - "an exception") - if x != 0: - self.fail("underflowing exp() should have returned 0") - # If this fails, probably using a strict IEEE-754 conforming libm, and x - # is +Inf afterwards. But Python wants overflows detected by default. - try: - x = math.exp(1000000000) - except OverflowError: - pass - else: - self.fail("overflowing exp() didn't trigger OverflowError") + if verbose: + def test_exceptions(self): + try: + x = math.exp(-1000000000) + except: + # mathmodule.c is failing to weed out underflows from libm, or + # we've got an fp format with huge dynamic range + self.fail("underflowing exp() should not have raised " + "an exception") + if x != 0: + self.fail("underflowing exp() should have returned 0") - # If this fails, it could be a puzzle. One odd possibility is that - # mathmodule.c's macros are getting confused while comparing - # Inf (HUGE_VAL) to a NaN, and artificially setting errno to ERANGE - # as a result (and so raising OverflowError instead). - try: - x = math.sqrt(-1.0) - except ValueError: - pass - else: - self.fail("sqrt(-1) didn't raise ValueError") + # If this fails, probably using a strict IEEE-754 conforming libm, and x + # is +Inf afterwards. But Python wants overflows detected by default. + try: + x = math.exp(1000000000) + except OverflowError: + pass + else: + self.fail("overflowing exp() didn't trigger OverflowError") + + # If this fails, it could be a puzzle. One odd possibility is that + # mathmodule.c's macros are getting confused while comparing + # Inf (HUGE_VAL) to a NaN, and artificially setting errno to ERANGE + # as a result (and so raising OverflowError instead). + try: + x = math.sqrt(-1.0) + except ValueError: + pass + else: + self.fail("sqrt(-1) didn't raise ValueError") @requires_IEEE_754 def test_testfile(self): diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Lib/test/test_memoryio.py --- a/Lib/test/test_memoryio.py Sat Jul 19 16:34:33 2014 -0700 +++ b/Lib/test/test_memoryio.py Sun Jul 20 10:52:46 2014 -0400 @@ -328,9 +328,9 @@ self.assertEqual(memio.isatty(), False) self.assertEqual(memio.closed, False) memio.close() - self.assertRaises(ValueError, memio.writable) - self.assertRaises(ValueError, memio.readable) - self.assertRaises(ValueError, memio.seekable) + self.assertEqual(memio.writable(), True) + self.assertEqual(memio.readable(), True) + self.assertEqual(memio.seekable(), True) self.assertRaises(ValueError, memio.isatty) self.assertEqual(memio.closed, True) @@ -522,17 +522,6 @@ self.assertIsNone(memio.errors) self.assertFalse(memio.line_buffering) - def test_newline_default(self): - memio = self.ioclass("a\nb\r\nc\rd") - self.assertEqual(list(memio), ["a\n", "b\r\n", "c\rd"]) - self.assertEqual(memio.getvalue(), "a\nb\r\nc\rd") - - memio = self.ioclass() - self.assertEqual(memio.write("a\nb\r\nc\rd"), 8) - memio.seek(0) - self.assertEqual(list(memio), ["a\n", "b\r\n", "c\rd"]) - self.assertEqual(memio.getvalue(), "a\nb\r\nc\rd") - def test_newline_none(self): # newline=None memio = self.ioclass("a\nb\r\nc\rd", newline=None) @@ -542,16 +531,12 @@ self.assertEqual(memio.read(2), "\nb") self.assertEqual(memio.read(2), "\nc") self.assertEqual(memio.read(1), "\n") - self.assertEqual(memio.getvalue(), "a\nb\nc\nd") - memio = self.ioclass(newline=None) self.assertEqual(2, memio.write("a\n")) self.assertEqual(3, memio.write("b\r\n")) self.assertEqual(3, memio.write("c\rd")) memio.seek(0) self.assertEqual(memio.read(), "a\nb\nc\nd") - self.assertEqual(memio.getvalue(), "a\nb\nc\nd") - memio = self.ioclass("a\r\nb", newline=None) self.assertEqual(memio.read(3), "a\nb") @@ -563,8 +548,6 @@ self.assertEqual(memio.read(4), "a\nb\r") self.assertEqual(memio.read(2), "\nc") self.assertEqual(memio.read(1), "\r") - self.assertEqual(memio.getvalue(), "a\nb\r\nc\rd") - memio = self.ioclass(newline="") self.assertEqual(2, memio.write("a\n")) self.assertEqual(2, memio.write("b\r")) @@ -572,19 +555,11 @@ self.assertEqual(2, memio.write("\rd")) memio.seek(0) self.assertEqual(list(memio), ["a\n", "b\r\n", "c\r", "d"]) - self.assertEqual(memio.getvalue(), "a\nb\r\nc\rd") def test_newline_lf(self): # newline="\n" - memio = self.ioclass("a\nb\r\nc\rd", newline="\n") + memio = self.ioclass("a\nb\r\nc\rd") self.assertEqual(list(memio), ["a\n", "b\r\n", "c\rd"]) - self.assertEqual(memio.getvalue(), "a\nb\r\nc\rd") - - memio = self.ioclass(newline="\n") - self.assertEqual(memio.write("a\nb\r\nc\rd"), 8) - memio.seek(0) - self.assertEqual(list(memio), ["a\n", "b\r\n", "c\rd"]) - self.assertEqual(memio.getvalue(), "a\nb\r\nc\rd") def test_newline_cr(self): # newline="\r" @@ -592,15 +567,6 @@ self.assertEqual(memio.read(), "a\rb\r\rc\rd") memio.seek(0) self.assertEqual(list(memio), ["a\r", "b\r", "\r", "c\r", "d"]) - self.assertEqual(memio.getvalue(), "a\rb\r\rc\rd") - - memio = self.ioclass(newline="\r") - self.assertEqual(memio.write("a\nb\r\nc\rd"), 8) - memio.seek(0) - self.assertEqual(list(memio), ["a\r", "b\r", "\r", "c\r", "d"]) - memio.seek(0) - self.assertEqual(memio.readlines(), ["a\r", "b\r", "\r", "c\r", "d"]) - self.assertEqual(memio.getvalue(), "a\rb\r\rc\rd") def test_newline_crlf(self): # newline="\r\n" @@ -608,21 +574,11 @@ self.assertEqual(memio.read(), "a\r\nb\r\r\nc\rd") memio.seek(0) self.assertEqual(list(memio), ["a\r\n", "b\r\r\n", "c\rd"]) - memio.seek(0) - self.assertEqual(memio.readlines(), ["a\r\n", "b\r\r\n", "c\rd"]) - self.assertEqual(memio.getvalue(), "a\r\nb\r\r\nc\rd") - - memio = self.ioclass(newline="\r\n") - self.assertEqual(memio.write("a\nb\r\nc\rd"), 8) - memio.seek(0) - self.assertEqual(list(memio), ["a\r\n", "b\r\r\n", "c\rd"]) - self.assertEqual(memio.getvalue(), "a\r\nb\r\r\nc\rd") def test_issue5265(self): # StringIO can duplicate newlines in universal newlines mode memio = self.ioclass("a\r\nb\r\n", newline=None) self.assertEqual(memio.read(5), "a\nb\n") - self.assertEqual(memio.getvalue(), "a\nb\n") class PyStringIOTest(MemoryTestMixin, MemorySeekTestMixin, @@ -632,16 +588,6 @@ UnsupportedOperation = pyio.UnsupportedOperation EOF = "" - def test_lone_surrogates(self): - # Issue #20424 - surrogate = unichr(0xd800) - memio = self.ioclass(surrogate) - self.assertEqual(memio.read(), surrogate) - - memio = self.ioclass() - memio.write(surrogate) - self.assertEqual(memio.getvalue(), surrogate) - class PyStringIOPickleTest(TextIOTestMixin, unittest.TestCase): """Test if pickle restores properly the internal state of StringIO. @@ -692,16 +638,6 @@ memio.close() self.assertRaises(ValueError, memio.__setstate__, (b"closed", 0, None)) - check_sizeof = support.check_sizeof - - @support.cpython_only - def test_sizeof(self): - basesize = support.calcobjsize(b'P2PP2P') - check = self.check_sizeof - self.assertEqual(object.__sizeof__(io.BytesIO()), basesize) - check(io.BytesIO(), basesize ) - check(io.BytesIO(b'a'), basesize + 1 + 1 ) - check(io.BytesIO(b'a' * 1000), basesize + 1000 + 1 ) class CStringIOTest(PyStringIOTest): ioclass = io.StringIO diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Lib/test/test_memoryview.py --- a/Lib/test/test_memoryview.py Sat Jul 19 16:34:33 2014 -0700 +++ b/Lib/test/test_memoryview.py Sun Jul 20 10:52:46 2014 -0400 @@ -63,7 +63,7 @@ def test_setitem_readonly(self): if not self.ro_type: - self.skipTest("no read-only type to test") + return b = self.ro_type(self._source) oldrefcount = sys.getrefcount(b) m = self._view(b) @@ -77,7 +77,7 @@ def test_setitem_writable(self): if not self.rw_type: - self.skipTest("no writable type to test") + return tp = self.rw_type b = self.rw_type(self._source) oldrefcount = sys.getrefcount(b) @@ -183,13 +183,13 @@ def test_attributes_readonly(self): if not self.ro_type: - self.skipTest("no read-only type to test") + return m = self.check_attributes_with_type(self.ro_type) self.assertEqual(m.readonly, True) def test_attributes_writable(self): if not self.rw_type: - self.skipTest("no writable type to test") + return m = self.check_attributes_with_type(self.rw_type) self.assertEqual(m.readonly, False) @@ -236,7 +236,7 @@ # buffer as writable causing a segfault if using mmap tp = self.ro_type if tp is None: - self.skipTest("no read-only type to test") + return b = tp(self._source) m = self._view(b) i = io.BytesIO(b'ZZZZ') diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Lib/test/test_mimetypes.py --- a/Lib/test/test_mimetypes.py Sat Jul 19 16:34:33 2014 -0700 +++ b/Lib/test/test_mimetypes.py Sun Jul 20 10:52:46 2014 -0400 @@ -1,5 +1,3 @@ -# -*- coding: utf-8 -*- - import mimetypes import StringIO import unittest @@ -23,8 +21,6 @@ eq(self.db.guess_type("foo.tgz"), ("application/x-tar", "gzip")) eq(self.db.guess_type("foo.tar.gz"), ("application/x-tar", "gzip")) eq(self.db.guess_type("foo.tar.Z"), ("application/x-tar", "compress")) - eq(self.db.guess_type("foo.tar.bz2"), ("application/x-tar", "bzip2")) - eq(self.db.guess_type("foo.tar.xz"), ("application/x-tar", "xz")) def test_data_urls(self): eq = self.assertEqual @@ -73,6 +69,8 @@ # ensure all entries actually come from the Windows registry self.original_types_map = mimetypes.types_map.copy() mimetypes.types_map.clear() + mimetypes.init() + self.db = mimetypes.MimeTypes() def tearDown(self): # restore default settings @@ -84,87 +82,12 @@ # Windows registry is undocumented AFAIK. # Use file types that should *always* exist: eq = self.assertEqual - mimetypes.init() - db = mimetypes.MimeTypes() - eq(db.guess_type("foo.txt"), ("text/plain", None)) - eq(db.guess_type("image.jpg"), ("image/jpeg", None)) - eq(db.guess_type("image.png"), ("image/png", None)) - - def test_non_latin_extension(self): - import _winreg - - class MockWinreg(object): - def __getattr__(self, name): - if name == 'EnumKey': - return lambda key, i: _winreg.EnumKey(key, i) + "\xa3" - elif name == 'OpenKey': - return lambda key, name: _winreg.OpenKey(key, name.rstrip("\xa3")) - elif name == 'QueryValueEx': - return lambda subkey, label: (u'текст/простой' , _winreg.REG_SZ) - return getattr(_winreg, name) - - mimetypes._winreg = MockWinreg() - try: - # this used to throw an exception if registry contained non-Latin - # characters in extensions (issue #9291) - mimetypes.init() - finally: - mimetypes._winreg = _winreg - - def test_non_latin_type(self): - import _winreg - - class MockWinreg(object): - def __getattr__(self, name): - if name == 'QueryValueEx': - return lambda subkey, label: (u'текст/простой', _winreg.REG_SZ) - return getattr(_winreg, name) - - mimetypes._winreg = MockWinreg() - try: - # this used to throw an exception if registry contained non-Latin - # characters in content types (issue #9291) - mimetypes.init() - finally: - mimetypes._winreg = _winreg - - def test_type_map_values(self): - import _winreg - - class MockWinreg(object): - def __getattr__(self, name): - if name == 'QueryValueEx': - return lambda subkey, label: (u'text/plain', _winreg.REG_SZ) - return getattr(_winreg, name) - - mimetypes._winreg = MockWinreg() - try: - mimetypes.init() - self.assertTrue(isinstance(mimetypes.types_map.values()[0], str)) - finally: - mimetypes._winreg = _winreg - - def test_registry_read_error(self): - import _winreg - - class MockWinreg(object): - def OpenKey(self, key, name): - if key != _winreg.HKEY_CLASSES_ROOT: - raise WindowsError(5, "Access is denied") - return _winreg.OpenKey(key, name) - def __getattr__(self, name): - return getattr(_winreg, name) - - mimetypes._winreg = MockWinreg() - try: - mimetypes.init() - finally: - mimetypes._winreg = _winreg + eq(self.db.guess_type("foo.txt"), ("text/plain", None)) def test_main(): test_support.run_unittest(MimeTypesTestCase, Win32MimeTypesTestCase - ) + ) if __name__ == "__main__": diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Lib/test/test_minidom.py --- a/Lib/test/test_minidom.py Sat Jul 19 16:34:33 2014 -0700 +++ b/Lib/test/test_minidom.py Sun Jul 20 10:52:46 2014 -0400 @@ -340,6 +340,19 @@ and el.getAttribute("spam2") == "bam2") dom.unlink() + def testGetAttrList(self): + pass + + def testGetAttrValues(self): pass + + def testGetAttrLength(self): pass + + def testGetAttribute(self): pass + + def testGetAttributeNS(self): pass + + def testGetAttributeNode(self): pass + def testGetElementsByTagNameNS(self): d=""" @@ -410,6 +423,8 @@ self.confirm(str(node) == repr(node)) dom.unlink() + def testTextNodeRepr(self): pass + def testWriteXML(self): str = '
    ' dom = parseString(str) @@ -473,6 +488,14 @@ and pi.localName is None and pi.namespaceURI == xml.dom.EMPTY_NAMESPACE) + def testProcessingInstructionRepr(self): pass + + def testTextRepr(self): pass + + def testWriteText(self): pass + + def testDocumentElement(self): pass + def testTooManyDocumentElements(self): doc = parseString("") elem = doc.createElement("extra") @@ -481,6 +504,26 @@ elem.unlink() doc.unlink() + def testCreateElementNS(self): pass + + def testCreateAttributeNS(self): pass + + def testParse(self): pass + + def testParseString(self): pass + + def testComment(self): pass + + def testAttrListItem(self): pass + + def testAttrListItems(self): pass + + def testAttrListItemNS(self): pass + + def testAttrListKeys(self): pass + + def testAttrListKeysNS(self): pass + def testRemoveNamedItem(self): doc = parseString("") e = doc.documentElement @@ -500,6 +543,32 @@ self.assertRaises(xml.dom.NotFoundErr, attrs.removeNamedItemNS, "http://xml.python.org/", "b") + def testAttrListValues(self): pass + + def testAttrListLength(self): pass + + def testAttrList__getitem__(self): pass + + def testAttrList__setitem__(self): pass + + def testSetAttrValueandNodeValue(self): pass + + def testParseElement(self): pass + + def testParseAttributes(self): pass + + def testParseElementNamespaces(self): pass + + def testParseAttributeNamespaces(self): pass + + def testParseProcessingInstructions(self): pass + + def testChildNodes(self): pass + + def testFirstChild(self): pass + + def testHasChildNodes(self): pass + def _testCloneElementCopiesAttributes(self, e1, e2, test): attrs1 = e1.attributes attrs2 = e2.attributes @@ -991,7 +1060,7 @@ '\xa4', "testEncodings - encoding EURO SIGN") - # Verify that character decoding errors raise exceptions instead + # Verify that character decoding errors throw exceptions instead # of crashing self.assertRaises(UnicodeDecodeError, parseString, 'Comment \xe7a va ? Tr\xe8s bien ?') diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Lib/test/test_mmap.py --- a/Lib/test/test_mmap.py Sat Jul 19 16:34:33 2014 -0700 +++ b/Lib/test/test_mmap.py Sun Jul 20 10:52:46 2014 -0400 @@ -320,25 +320,26 @@ mf.close() f.close() - @unittest.skipUnless(hasattr(os, "stat"), "needs os.stat()") def test_entire_file(self): # test mapping of entire file by passing 0 for map length - f = open(TESTFN, "w+") + if hasattr(os, "stat"): + f = open(TESTFN, "w+") - f.write(2**16 * 'm') # Arbitrary character - f.close() + f.write(2**16 * 'm') # Arbitrary character + f.close() - f = open(TESTFN, "rb+") - mf = mmap.mmap(f.fileno(), 0) - self.assertEqual(len(mf), 2**16, "Map size should equal file size.") - self.assertEqual(mf.read(2**16), 2**16 * "m") - mf.close() - f.close() + f = open(TESTFN, "rb+") + mf = mmap.mmap(f.fileno(), 0) + self.assertEqual(len(mf), 2**16, "Map size should equal file size.") + self.assertEqual(mf.read(2**16), 2**16 * "m") + mf.close() + f.close() - @unittest.skipUnless(hasattr(os, "stat"), "needs os.stat()") def test_length_0_offset(self): # Issue #10916: test mapping of remainder of file by passing 0 for # map length with an offset doesn't cause a segfault. + if not hasattr(os, "stat"): + self.skipTest("needs os.stat") # NOTE: allocation granularity is currently 65536 under Win64, # and therefore the minimum offset alignment. with open(TESTFN, "wb") as f: @@ -351,10 +352,12 @@ finally: mf.close() - @unittest.skipUnless(hasattr(os, "stat"), "needs os.stat()") def test_length_0_large_offset(self): # Issue #10959: test mapping of a file by passing 0 for # map length with a large offset doesn't cause a segfault. + if not hasattr(os, "stat"): + self.skipTest("needs os.stat") + with open(TESTFN, "wb") as f: f.write(115699 * b'm') # Arbitrary character @@ -463,15 +466,6 @@ f.flush () return mmap.mmap (f.fileno(), 0) - def test_empty_file (self): - f = open (TESTFN, 'w+b') - f.close() - with open(TESTFN, "rb") as f : - self.assertRaisesRegexp(ValueError, - "cannot mmap an empty file", - mmap.mmap, f.fileno(), 0, - access=mmap.ACCESS_READ) - def test_offset (self): f = open (TESTFN, 'w+b') @@ -535,8 +529,9 @@ return mmap.mmap.__new__(klass, -1, *args, **kwargs) anon_mmap(PAGESIZE) - @unittest.skipUnless(hasattr(mmap, 'PROT_READ'), "needs mmap.PROT_READ") def test_prot_readonly(self): + if not hasattr(mmap, 'PROT_READ'): + return mapsize = 10 open(TESTFN, "wb").write("a"*mapsize) f = open(TESTFN, "rb") @@ -580,68 +575,66 @@ m.seek(8) self.assertRaises(ValueError, m.write, "bar") - @unittest.skipUnless(os.name == 'nt', 'requires Windows') - def test_tagname(self): - data1 = "0123456789" - data2 = "abcdefghij" - assert len(data1) == len(data2) + if os.name == 'nt': + def test_tagname(self): + data1 = "0123456789" + data2 = "abcdefghij" + assert len(data1) == len(data2) - # Test same tag - m1 = mmap.mmap(-1, len(data1), tagname="foo") - m1[:] = data1 - m2 = mmap.mmap(-1, len(data2), tagname="foo") - m2[:] = data2 - self.assertEqual(m1[:], data2) - self.assertEqual(m2[:], data2) - m2.close() - m1.close() + # Test same tag + m1 = mmap.mmap(-1, len(data1), tagname="foo") + m1[:] = data1 + m2 = mmap.mmap(-1, len(data2), tagname="foo") + m2[:] = data2 + self.assertEqual(m1[:], data2) + self.assertEqual(m2[:], data2) + m2.close() + m1.close() - # Test different tag - m1 = mmap.mmap(-1, len(data1), tagname="foo") - m1[:] = data1 - m2 = mmap.mmap(-1, len(data2), tagname="boo") - m2[:] = data2 - self.assertEqual(m1[:], data1) - self.assertEqual(m2[:], data2) - m2.close() - m1.close() + # Test different tag + m1 = mmap.mmap(-1, len(data1), tagname="foo") + m1[:] = data1 + m2 = mmap.mmap(-1, len(data2), tagname="boo") + m2[:] = data2 + self.assertEqual(m1[:], data1) + self.assertEqual(m2[:], data2) + m2.close() + m1.close() - @unittest.skipUnless(os.name == 'nt', 'requires Windows') - def test_crasher_on_windows(self): - # Should not crash (Issue 1733986) - m = mmap.mmap(-1, 1000, tagname="foo") - try: - mmap.mmap(-1, 5000, tagname="foo")[:] # same tagname, but larger size - except: - pass - m.close() + def test_crasher_on_windows(self): + # Should not crash (Issue 1733986) + m = mmap.mmap(-1, 1000, tagname="foo") + try: + mmap.mmap(-1, 5000, tagname="foo")[:] # same tagname, but larger size + except: + pass + m.close() - # Should not crash (Issue 5385) - open(TESTFN, "wb").write("x"*10) - f = open(TESTFN, "r+b") - m = mmap.mmap(f.fileno(), 0) - f.close() - try: - m.resize(0) # will raise WindowsError - except: - pass - try: - m[:] - except: - pass - m.close() + # Should not crash (Issue 5385) + open(TESTFN, "wb").write("x"*10) + f = open(TESTFN, "r+b") + m = mmap.mmap(f.fileno(), 0) + f.close() + try: + m.resize(0) # will raise WindowsError + except: + pass + try: + m[:] + except: + pass + m.close() - @unittest.skipUnless(os.name == 'nt', 'requires Windows') - def test_invalid_descriptor(self): - # socket file descriptors are valid, but out of range - # for _get_osfhandle, causing a crash when validating the - # parameters to _get_osfhandle. - s = socket.socket() - try: - with self.assertRaises(mmap.error): - m = mmap.mmap(s.fileno(), 10) - finally: - s.close() + def test_invalid_descriptor(self): + # socket file descriptors are valid, but out of range + # for _get_osfhandle, causing a crash when validating the + # parameters to _get_osfhandle. + s = socket.socket() + try: + with self.assertRaises(mmap.error): + m = mmap.mmap(s.fileno(), 10) + finally: + s.close() class LargeMmapTests(unittest.TestCase): @@ -676,13 +669,6 @@ def test_large_filesize(self): with self._make_test_file(0x17FFFFFFF, b" ") as f: - if sys.maxsize < 0x180000000: - # On 32 bit platforms the file is larger than sys.maxsize so - # mapping the whole file should fail -- Issue #16743 - with self.assertRaises(OverflowError): - mmap.mmap(f.fileno(), 0x180000000, access=mmap.ACCESS_READ) - with self.assertRaises(ValueError): - mmap.mmap(f.fileno(), 0, access=mmap.ACCESS_READ) m = mmap.mmap(f.fileno(), 0x10000, access=mmap.ACCESS_READ) try: self.assertEqual(m.size(), 0x180000000) diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Lib/test/test_module.py --- a/Lib/test/test_module.py Sat Jul 19 16:34:33 2014 -0700 +++ b/Lib/test/test_module.py Sun Jul 20 10:52:46 2014 -0400 @@ -70,7 +70,7 @@ m = ModuleType("foo") m.destroyed = destroyed s = """class A: - def __del__(self, destroyed=destroyed): + def __del__(self): destroyed.append(1) a = A()""" exec(s, m.__dict__) diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Lib/test/test_multibytecodec.py --- a/Lib/test/test_multibytecodec.py Sat Jul 19 16:34:33 2014 -0700 +++ b/Lib/test/test_multibytecodec.py Sun Jul 20 10:52:46 2014 -0400 @@ -1,3 +1,5 @@ +#!/usr/bin/env python +# # test_multibytecodec.py # Unit test for multibytecodec itself # @@ -155,55 +157,57 @@ os.unlink(TESTFN) class Test_StreamWriter(unittest.TestCase): - @unittest.skipUnless(len(u'\U00012345') == 2, 'need a narrow build') - def test_gb18030(self): - s = StringIO.StringIO() - c = codecs.getwriter('gb18030')(s) - c.write(u'123') - self.assertEqual(s.getvalue(), '123') - c.write(u'\U00012345') - self.assertEqual(s.getvalue(), '123\x907\x959') - c.write(u'\U00012345'[0]) - self.assertEqual(s.getvalue(), '123\x907\x959') - c.write(u'\U00012345'[1] + u'\U00012345' + u'\uac00\u00ac') - self.assertEqual(s.getvalue(), - '123\x907\x959\x907\x959\x907\x959\x827\xcf5\x810\x851') - c.write(u'\U00012345'[0]) - self.assertEqual(s.getvalue(), - '123\x907\x959\x907\x959\x907\x959\x827\xcf5\x810\x851') - self.assertRaises(UnicodeError, c.reset) - self.assertEqual(s.getvalue(), - '123\x907\x959\x907\x959\x907\x959\x827\xcf5\x810\x851') - - @unittest.skipUnless(len(u'\U00012345') == 2, 'need a narrow build') - def test_utf_8(self): - s= StringIO.StringIO() - c = codecs.getwriter('utf-8')(s) - c.write(u'123') - self.assertEqual(s.getvalue(), '123') - c.write(u'\U00012345') - self.assertEqual(s.getvalue(), '123\xf0\x92\x8d\x85') - - # Python utf-8 codec can't buffer surrogate pairs yet. - if 0: + if len(u'\U00012345') == 2: # UCS2 + def test_gb18030(self): + s = StringIO.StringIO() + c = codecs.getwriter('gb18030')(s) + c.write(u'123') + self.assertEqual(s.getvalue(), '123') + c.write(u'\U00012345') + self.assertEqual(s.getvalue(), '123\x907\x959') c.write(u'\U00012345'[0]) - self.assertEqual(s.getvalue(), '123\xf0\x92\x8d\x85') + self.assertEqual(s.getvalue(), '123\x907\x959') c.write(u'\U00012345'[1] + u'\U00012345' + u'\uac00\u00ac') self.assertEqual(s.getvalue(), - '123\xf0\x92\x8d\x85\xf0\x92\x8d\x85\xf0\x92\x8d\x85' - '\xea\xb0\x80\xc2\xac') + '123\x907\x959\x907\x959\x907\x959\x827\xcf5\x810\x851') c.write(u'\U00012345'[0]) self.assertEqual(s.getvalue(), - '123\xf0\x92\x8d\x85\xf0\x92\x8d\x85\xf0\x92\x8d\x85' - '\xea\xb0\x80\xc2\xac') - c.reset() + '123\x907\x959\x907\x959\x907\x959\x827\xcf5\x810\x851') + self.assertRaises(UnicodeError, c.reset) self.assertEqual(s.getvalue(), - '123\xf0\x92\x8d\x85\xf0\x92\x8d\x85\xf0\x92\x8d\x85' - '\xea\xb0\x80\xc2\xac\xed\xa0\x88') - c.write(u'\U00012345'[1]) - self.assertEqual(s.getvalue(), - '123\xf0\x92\x8d\x85\xf0\x92\x8d\x85\xf0\x92\x8d\x85' - '\xea\xb0\x80\xc2\xac\xed\xa0\x88\xed\xbd\x85') + '123\x907\x959\x907\x959\x907\x959\x827\xcf5\x810\x851') + + def test_utf_8(self): + s= StringIO.StringIO() + c = codecs.getwriter('utf-8')(s) + c.write(u'123') + self.assertEqual(s.getvalue(), '123') + c.write(u'\U00012345') + self.assertEqual(s.getvalue(), '123\xf0\x92\x8d\x85') + + # Python utf-8 codec can't buffer surrogate pairs yet. + if 0: + c.write(u'\U00012345'[0]) + self.assertEqual(s.getvalue(), '123\xf0\x92\x8d\x85') + c.write(u'\U00012345'[1] + u'\U00012345' + u'\uac00\u00ac') + self.assertEqual(s.getvalue(), + '123\xf0\x92\x8d\x85\xf0\x92\x8d\x85\xf0\x92\x8d\x85' + '\xea\xb0\x80\xc2\xac') + c.write(u'\U00012345'[0]) + self.assertEqual(s.getvalue(), + '123\xf0\x92\x8d\x85\xf0\x92\x8d\x85\xf0\x92\x8d\x85' + '\xea\xb0\x80\xc2\xac') + c.reset() + self.assertEqual(s.getvalue(), + '123\xf0\x92\x8d\x85\xf0\x92\x8d\x85\xf0\x92\x8d\x85' + '\xea\xb0\x80\xc2\xac\xed\xa0\x88') + c.write(u'\U00012345'[1]) + self.assertEqual(s.getvalue(), + '123\xf0\x92\x8d\x85\xf0\x92\x8d\x85\xf0\x92\x8d\x85' + '\xea\xb0\x80\xc2\xac\xed\xa0\x88\xed\xbd\x85') + + else: # UCS4 + pass def test_streamwriter_strwrite(self): s = StringIO.StringIO() diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Lib/test/test_multibytecodec_support.py --- a/Lib/test/test_multibytecodec_support.py Sat Jul 19 16:34:33 2014 -0700 +++ b/Lib/test/test_multibytecodec_support.py Sun Jul 20 10:52:46 2014 -0400 @@ -1,3 +1,5 @@ +#!/usr/bin/env python +# # test_multibytecodec_support.py # Common Unittest Routines for CJK codecs # @@ -65,7 +67,7 @@ def test_xmlcharrefreplace(self): if self.has_iso10646: - self.skipTest('encoding contains full ISO 10646 map') + return s = u"\u0b13\u0b23\u0b60 nd eggs" self.assertEqual( @@ -75,7 +77,7 @@ def test_customreplace_encode(self): if self.has_iso10646: - self.skipTest('encoding contains full ISO 10646 map') + return from htmlentitydefs import codepoint2name diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Lib/test/test_multiprocessing.py --- a/Lib/test/test_multiprocessing.py Sat Jul 19 16:34:33 2014 -0700 +++ b/Lib/test/test_multiprocessing.py Sun Jul 20 10:52:46 2014 -0400 @@ -1,3 +1,5 @@ +#!/usr/bin/env python + # # Unit tests for the multiprocessing package # @@ -14,7 +16,6 @@ import random import logging import errno -import test.script_helper from test import test_support from StringIO import StringIO _multiprocessing = test_support.import_module('_multiprocessing') @@ -180,7 +181,7 @@ def test_current(self): if self.TYPE == 'threads': - self.skipTest('test not appropriate for {}'.format(self.TYPE)) + return current = self.current_process() authkey = current.authkey @@ -247,7 +248,7 @@ def test_terminate(self): if self.TYPE == 'threads': - self.skipTest('test not appropriate for {}'.format(self.TYPE)) + return p = self.Process(target=self._test_terminate) p.daemon = True @@ -324,36 +325,6 @@ ] self.assertEqual(result, expected) - @classmethod - def _test_sys_exit(cls, reason, testfn): - sys.stderr = open(testfn, 'w') - sys.exit(reason) - - def test_sys_exit(self): - # See Issue 13854 - if self.TYPE == 'threads': - self.skipTest('test not appropriate for {}'.format(self.TYPE)) - - testfn = test_support.TESTFN - self.addCleanup(test_support.unlink, testfn) - - for reason, code in (([1, 2, 3], 1), ('ignore this', 1)): - p = self.Process(target=self._test_sys_exit, args=(reason, testfn)) - p.daemon = True - p.start() - p.join(5) - self.assertEqual(p.exitcode, code) - - with open(testfn, 'r') as f: - self.assertEqual(f.read().rstrip(), str(reason)) - - for reason in (True, False, 8): - p = self.Process(target=sys.exit, args=(reason,)) - p.daemon = True - p.start() - p.join(5) - self.assertEqual(p.exitcode, reason) - # # # @@ -580,7 +551,7 @@ try: self.assertEqual(q.qsize(), 0) except NotImplementedError: - self.skipTest('qsize method not implemented') + return q.put(1) self.assertEqual(q.qsize(), 1) q.put(5) @@ -681,7 +652,7 @@ def test_timeout(self): if self.TYPE != 'processes': - self.skipTest('test not appropriate for {}'.format(self.TYPE)) + return sem = self.Semaphore(0) acquire = TimingWrapper(sem.acquire) @@ -1115,16 +1086,6 @@ self.assertEqual(pmap(sqr, range(100), chunksize=20), map(sqr, range(100))) - def test_map_unplicklable(self): - # Issue #19425 -- failure to pickle should not cause a hang - if self.TYPE == 'threads': - self.skipTest('test not appropriate for {}'.format(self.TYPE)) - class A(object): - def __reduce__(self): - raise RuntimeError('cannot pickle') - with self.assertRaises(RuntimeError): - self.pool.map(sqr, [A()]*10) - def test_map_chunksize(self): try: self.pool.map_async(sqr, [], chunksize=1).get(timeout=TIMEOUT1) @@ -1138,7 +1099,7 @@ self.assertTimingAlmostEqual(get.elapsed, TIMEOUT1) def test_async_timeout(self): - res = self.pool.apply_async(sqr, (6, TIMEOUT2 + 1.0)) + res = self.pool.apply_async(sqr, (6, TIMEOUT2 + 0.2)) get = TimingWrapper(res.get) self.assertRaises(multiprocessing.TimeoutError, get, timeout=TIMEOUT2) self.assertTimingAlmostEqual(get.elapsed, TIMEOUT2) @@ -1174,45 +1135,23 @@ p.join() def test_terminate(self): - p = self.Pool(4) - result = p.map_async( + if self.TYPE == 'manager': + # On Unix a forked process increfs each shared object to + # which its parent process held a reference. If the + # forked process gets terminated then there is likely to + # be a reference leak. So to prevent + # _TestZZZNumberOfObjects from failing we skip this test + # when using a manager. + return + + result = self.pool.map_async( time.sleep, [0.1 for i in range(10000)], chunksize=1 ) - p.terminate() - join = TimingWrapper(p.join) + self.pool.terminate() + join = TimingWrapper(self.pool.join) join() self.assertTrue(join.elapsed < 0.2) - def test_empty_iterable(self): - # See Issue 12157 - p = self.Pool(1) - - self.assertEqual(p.map(sqr, []), []) - self.assertEqual(list(p.imap(sqr, [])), []) - self.assertEqual(list(p.imap_unordered(sqr, [])), []) - self.assertEqual(p.map_async(sqr, []).get(), []) - - p.close() - p.join() - -def unpickleable_result(): - return lambda: 42 - -class _TestPoolWorkerErrors(BaseTestCase): - ALLOWED_TYPES = ('processes', ) - - def test_unpickleable_result(self): - from multiprocessing.pool import MaybeEncodingError - p = multiprocessing.Pool(2) - - # Make sure we don't lose pool processes because of encoding errors. - for iteration in range(20): - res = p.apply_async(unpickleable_result) - self.assertRaises(MaybeEncodingError, res.get) - - p.close() - p.join() - class _TestPoolWorkerLifetime(BaseTestCase): ALLOWED_TYPES = ('processes', ) @@ -1385,7 +1324,7 @@ authkey = os.urandom(32) manager = QueueManager( - address=(test.test_support.HOST, 0), authkey=authkey, serializer=SERIALIZER + address=('localhost', 0), authkey=authkey, serializer=SERIALIZER ) manager.start() @@ -1423,7 +1362,7 @@ def test_rapid_restart(self): authkey = os.urandom(32) manager = QueueManager( - address=(test.test_support.HOST, 0), authkey=authkey, serializer=SERIALIZER) + address=('localhost', 0), authkey=authkey, serializer=SERIALIZER) srvr = manager.get_server() addr = srvr.address # Close the connection.Listener socket which gets opened as a part @@ -1513,7 +1452,6 @@ self.assertTimingAlmostEqual(poll.elapsed, TIMEOUT1) conn.send(None) - time.sleep(.1) self.assertEqual(poll(TIMEOUT1), True) self.assertTimingAlmostEqual(poll.elapsed, 0) @@ -1571,7 +1509,7 @@ def test_sendbytes(self): if self.TYPE != 'processes': - self.skipTest('test not appropriate for {}'.format(self.TYPE)) + return msg = latin('abcdefghijklmnopqrstuvwxyz') a, b = self.Pipe() @@ -1713,23 +1651,6 @@ self.assertEqual(conn.recv(), 'hello') p.join() l.close() - - def test_issue14725(self): - l = self.connection.Listener() - p = self.Process(target=self._test, args=(l.address,)) - p.daemon = True - p.start() - time.sleep(1) - # On Windows the client process should by now have connected, - # written data and closed the pipe handle by now. This causes - # ConnectNamdedPipe() to fail with ERROR_NO_DATA. See Issue - # 14725. - conn = l.accept() - self.assertEqual(conn.recv(), 'hello') - conn.close() - p.join() - l.close() - # # Test of sending connection and socket objects between processes # @@ -2105,38 +2026,6 @@ # assert self.__handled # -# Check that Process.join() retries if os.waitpid() fails with EINTR -# - -class _TestPollEintr(BaseTestCase): - - ALLOWED_TYPES = ('processes',) - - @classmethod - def _killer(cls, pid): - time.sleep(0.5) - os.kill(pid, signal.SIGUSR1) - - @unittest.skipUnless(hasattr(signal, 'SIGUSR1'), 'requires SIGUSR1') - def test_poll_eintr(self): - got_signal = [False] - def record(*args): - got_signal[0] = True - pid = os.getpid() - oldhandler = signal.signal(signal.SIGUSR1, record) - try: - killer = self.Process(target=self._killer, args=(pid,)) - killer.start() - p = self.Process(target=time.sleep, args=(1,)) - p.start() - p.join() - self.assertTrue(got_signal[0]) - self.assertEqual(p.exitcode, 0) - killer.join() - finally: - signal.signal(signal.SIGUSR1, oldhandler) - -# # Test to verify handle verification, see issue 3321 # @@ -2189,7 +2078,7 @@ 'Queue', 'Lock', 'RLock', 'Semaphore', 'BoundedSemaphore', 'Condition', 'Event', 'Value', 'Array', 'RawValue', 'RawArray', 'current_process', 'active_children', 'Pipe', - 'connection', 'JoinableQueue', 'Pool' + 'connection', 'JoinableQueue' ))) testcases_processes = create_test_cases(ProcessesMixin, type='processes') @@ -2203,7 +2092,7 @@ locals().update(get_attributes(manager, ( 'Queue', 'Lock', 'RLock', 'Semaphore', 'BoundedSemaphore', 'Condition', 'Event', 'Value', 'Array', 'list', 'dict', - 'Namespace', 'JoinableQueue', 'Pool' + 'Namespace', 'JoinableQueue' ))) testcases_manager = create_test_cases(ManagerMixin, type='manager') @@ -2217,7 +2106,7 @@ 'Queue', 'Lock', 'RLock', 'Semaphore', 'BoundedSemaphore', 'Condition', 'Event', 'Value', 'Array', 'current_process', 'active_children', 'Pipe', 'connection', 'dict', 'list', - 'Namespace', 'JoinableQueue', 'Pool' + 'Namespace', 'JoinableQueue' ))) testcases_threads = create_test_cases(ThreadsMixin, type='threads') @@ -2287,15 +2176,15 @@ # Verifies os.close(sys.stdin.fileno) vs. sys.stdin.close() behavior # -def _this_sub_process(q): +def _ThisSubProcess(q): try: item = q.get(block=False) except Queue.Empty: pass -def _test_process(q): +def _TestProcess(q): queue = multiprocessing.Queue() - subProc = multiprocessing.Process(target=_this_sub_process, args=(queue,)) + subProc = multiprocessing.Process(target=_ThisSubProcess, args=(queue,)) subProc.daemon = True subProc.start() subProc.join() @@ -2332,7 +2221,7 @@ def test_queue_in_process(self): queue = multiprocessing.Queue() - proc = multiprocessing.Process(target=_test_process, args=(queue,)) + proc = multiprocessing.Process(target=_TestProcess, args=(queue,)) proc.start() proc.join() @@ -2349,192 +2238,8 @@ flike.flush() assert sio.getvalue() == 'foo' -# -# Test interaction with socket timeouts - see Issue #6056 -# - -class TestTimeouts(unittest.TestCase): - @classmethod - def _test_timeout(cls, child, address): - time.sleep(1) - child.send(123) - child.close() - conn = multiprocessing.connection.Client(address) - conn.send(456) - conn.close() - - def test_timeout(self): - old_timeout = socket.getdefaulttimeout() - try: - socket.setdefaulttimeout(0.1) - parent, child = multiprocessing.Pipe(duplex=True) - l = multiprocessing.connection.Listener(family='AF_INET') - p = multiprocessing.Process(target=self._test_timeout, - args=(child, l.address)) - p.start() - child.close() - self.assertEqual(parent.recv(), 123) - parent.close() - conn = l.accept() - self.assertEqual(conn.recv(), 456) - conn.close() - l.close() - p.join(10) - finally: - socket.setdefaulttimeout(old_timeout) - -# -# Test what happens with no "if __name__ == '__main__'" -# - -class TestNoForkBomb(unittest.TestCase): - def test_noforkbomb(self): - name = os.path.join(os.path.dirname(__file__), 'mp_fork_bomb.py') - if WIN32: - rc, out, err = test.script_helper.assert_python_failure(name) - self.assertEqual('', out.decode('ascii')) - self.assertIn('RuntimeError', err.decode('ascii')) - else: - rc, out, err = test.script_helper.assert_python_ok(name) - self.assertEqual('123', out.decode('ascii').rstrip()) - self.assertEqual('', err.decode('ascii')) - -# -# Issue 12098: check sys.flags of child matches that for parent -# - -class TestFlags(unittest.TestCase): - @classmethod - def run_in_grandchild(cls, conn): - conn.send(tuple(sys.flags)) - - @classmethod - def run_in_child(cls): - import json - r, w = multiprocessing.Pipe(duplex=False) - p = multiprocessing.Process(target=cls.run_in_grandchild, args=(w,)) - p.start() - grandchild_flags = r.recv() - p.join() - r.close() - w.close() - flags = (tuple(sys.flags), grandchild_flags) - print(json.dumps(flags)) - - def test_flags(self): - import json, subprocess - # start child process using unusual flags - prog = ('from test.test_multiprocessing import TestFlags; ' + - 'TestFlags.run_in_child()') - data = subprocess.check_output( - [sys.executable, '-E', '-B', '-O', '-c', prog]) - child_flags, grandchild_flags = json.loads(data.decode('ascii')) - self.assertEqual(child_flags, grandchild_flags) - -# -# Issue #17555: ForkAwareThreadLock -# - -class TestForkAwareThreadLock(unittest.TestCase): - # We recurisvely start processes. Issue #17555 meant that the - # after fork registry would get duplicate entries for the same - # lock. The size of the registry at generation n was ~2**n. - - @classmethod - def child(cls, n, conn): - if n > 1: - p = multiprocessing.Process(target=cls.child, args=(n-1, conn)) - p.start() - p.join() - else: - conn.send(len(util._afterfork_registry)) - conn.close() - - def test_lock(self): - r, w = multiprocessing.Pipe(False) - l = util.ForkAwareThreadLock() - old_size = len(util._afterfork_registry) - p = multiprocessing.Process(target=self.child, args=(5, w)) - p.start() - new_size = r.recv() - p.join() - self.assertLessEqual(new_size, old_size) - -# -# Issue #17097: EINTR should be ignored by recv(), send(), accept() etc -# - -class TestIgnoreEINTR(unittest.TestCase): - - @classmethod - def _test_ignore(cls, conn): - def handler(signum, frame): - pass - signal.signal(signal.SIGUSR1, handler) - conn.send('ready') - x = conn.recv() - conn.send(x) - conn.send_bytes(b'x'*(1024*1024)) # sending 1 MB should block - - @unittest.skipUnless(hasattr(signal, 'SIGUSR1'), 'requires SIGUSR1') - def test_ignore(self): - conn, child_conn = multiprocessing.Pipe() - try: - p = multiprocessing.Process(target=self._test_ignore, - args=(child_conn,)) - p.daemon = True - p.start() - child_conn.close() - self.assertEqual(conn.recv(), 'ready') - time.sleep(0.1) - os.kill(p.pid, signal.SIGUSR1) - time.sleep(0.1) - conn.send(1234) - self.assertEqual(conn.recv(), 1234) - time.sleep(0.1) - os.kill(p.pid, signal.SIGUSR1) - self.assertEqual(conn.recv_bytes(), b'x'*(1024*1024)) - time.sleep(0.1) - p.join() - finally: - conn.close() - - @classmethod - def _test_ignore_listener(cls, conn): - def handler(signum, frame): - pass - signal.signal(signal.SIGUSR1, handler) - l = multiprocessing.connection.Listener() - conn.send(l.address) - a = l.accept() - a.send('welcome') - - @unittest.skipUnless(hasattr(signal, 'SIGUSR1'), 'requires SIGUSR1') - def test_ignore_listener(self): - conn, child_conn = multiprocessing.Pipe() - try: - p = multiprocessing.Process(target=self._test_ignore_listener, - args=(child_conn,)) - p.daemon = True - p.start() - child_conn.close() - address = conn.recv() - time.sleep(0.1) - os.kill(p.pid, signal.SIGUSR1) - time.sleep(0.1) - client = multiprocessing.connection.Client(address) - self.assertEqual(client.recv(), 'welcome') - p.join() - finally: - conn.close() - -# -# -# - testcases_other = [OtherTest, TestInvalidHandle, TestInitializers, - TestStdinBadfiledescriptor, TestTimeouts, TestNoForkBomb, - TestFlags, TestForkAwareThreadLock, TestIgnoreEINTR] + TestStdinBadfiledescriptor] # # diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Lib/test/test_mutex.py --- a/Lib/test/test_mutex.py Sat Jul 19 16:34:33 2014 -0700 +++ b/Lib/test/test_mutex.py Sun Jul 20 10:52:46 2014 -0400 @@ -14,7 +14,7 @@ m.lock(called_by_mutex2, "eggs") def called_by_mutex2(some_data): - self.assertEqual(some_data, "eggs") + self.assertEquals(some_data, "eggs") self.assertTrue(m.test(), "mutex not held") self.assertTrue(ready_for_2, "called_by_mutex2 called too soon") diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Lib/test/test_netrc.py --- a/Lib/test/test_netrc.py Sat Jul 19 16:34:33 2014 -0700 +++ b/Lib/test/test_netrc.py Sun Jul 20 10:52:46 2014 -0400 @@ -5,6 +5,9 @@ class NetrcTestCase(unittest.TestCase): + def tearDown(self): + os.unlink(temp_filename) + def make_nrc(self, test_data): test_data = textwrap.dedent(test_data) mode = 'w' @@ -12,7 +15,6 @@ mode += 't' with open(temp_filename, mode) as fp: fp.write(test_data) - self.addCleanup(os.unlink, temp_filename) return netrc.netrc(temp_filename) def test_default(self): @@ -101,28 +103,6 @@ """, '#pass') - @unittest.skipUnless(os.name == 'posix', 'POSIX only test') - def test_security(self): - # This test is incomplete since we are normally not run as root and - # therefore can't test the file ownership being wrong. - d = test_support.TESTFN - os.mkdir(d) - self.addCleanup(test_support.rmtree, d) - fn = os.path.join(d, '.netrc') - with open(fn, 'wt') as f: - f.write("""\ - machine foo.domain.com login bar password pass - default login foo password pass - """) - with test_support.EnvironmentVarGuard() as environ: - environ.set('HOME', d) - os.chmod(fn, 0600) - nrc = netrc.netrc() - self.assertEqual(nrc.hosts['foo.domain.com'], - ('bar', None, 'pass')) - os.chmod(fn, 0o622) - self.assertRaises(netrc.NetrcParseError, netrc.netrc) - def test_main(): test_support.run_unittest(NetrcTestCase) diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Lib/test/test_nis.py --- a/Lib/test/test_nis.py Sat Jul 19 16:34:33 2014 -0700 +++ b/Lib/test/test_nis.py Sun Jul 20 10:52:46 2014 -0400 @@ -9,7 +9,11 @@ maps = nis.maps() except nis.error, msg: # NIS is probably not active, so this test isn't useful - self.skipTest(str(msg)) + if test_support.verbose: + print "Test Skipped:", msg + # Can't raise SkipTest as regrtest only recognizes the exception + # import time. + return try: # On some systems, this map is only accessible to the # super user diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Lib/test/test_nntplib.py --- a/Lib/test/test_nntplib.py Sat Jul 19 16:34:33 2014 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,73 +0,0 @@ -import socket -import nntplib -import time -import unittest - -try: - import threading -except ImportError: - threading = None - - -from unittest import TestCase -from test import test_support - -HOST = test_support.HOST - - -def server(evt, serv, evil=False): - serv.listen(5) - try: - conn, addr = serv.accept() - except socket.timeout: - pass - else: - if evil: - conn.send("1 I'm too long response" * 3000 + "\n") - else: - conn.send("1 I'm OK response\n") - conn.close() - finally: - serv.close() - evt.set() - - -class BaseServerTest(TestCase): - def setUp(self): - self.evt = threading.Event() - self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) - self.sock.settimeout(3) - self.port = test_support.bind_port(self.sock) - threading.Thread( - target=server, - args=(self.evt, self.sock, self.evil)).start() - time.sleep(.1) - - def tearDown(self): - self.evt.wait() - - -@unittest.skipUnless(threading, 'threading required') -class ServerTests(BaseServerTest): - evil = False - - def test_basic_connect(self): - nntp = nntplib.NNTP('localhost', self.port) - nntp.sock.close() - - -@unittest.skipUnless(threading, 'threading required') -class EvilServerTests(BaseServerTest): - evil = True - - def test_too_long_line(self): - self.assertRaises(nntplib.NNTPDataError, - nntplib.NNTP, 'localhost', self.port) - - -def test_main(verbose=None): - test_support.run_unittest(EvilServerTests) - test_support.run_unittest(ServerTests) - -if __name__ == '__main__': - test_main() diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Lib/test/test_normalization.py --- a/Lib/test/test_normalization.py Sat Jul 19 16:34:33 2014 -0700 +++ b/Lib/test/test_normalization.py Sun Jul 20 10:52:46 2014 -0400 @@ -57,7 +57,7 @@ c1,c2,c3,c4,c5 = [unistr(x) for x in line.split(';')[:-1]] except RangeError: # Skip unsupported characters; - # try at least adding c1 if we are in part1 + # try atleast adding c1 if we are in part1 if part == "@Part1": try: c1 = unistr(line.split(';')[0]) diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Lib/test/test_ntpath.py --- a/Lib/test/test_ntpath.py Sat Jul 19 16:34:33 2014 -0700 +++ b/Lib/test/test_ntpath.py Sun Jul 20 10:52:46 2014 -0400 @@ -1,20 +1,16 @@ -# coding: utf-8 import ntpath import os -import sys from test.test_support import TestFailed from test import test_support, test_genericpath import unittest -def tester0(fn, wantResult): - gotResult = eval(fn) - if wantResult != gotResult: - raise TestFailed, "%s should return: %r but returned: %r" \ - %(fn, wantResult, gotResult) def tester(fn, wantResult): fn = fn.replace("\\", "\\\\") - tester0(fn, wantResult) + gotResult = eval(fn) + if wantResult != gotResult: + raise TestFailed, "%s should return: %s but returned: %s" \ + %(str(fn), str(wantResult), str(gotResult)) class TestNtpath(unittest.TestCase): @@ -35,41 +31,12 @@ ('c:', '\\foo\\bar')) tester('ntpath.splitdrive("c:/foo/bar")', ('c:', '/foo/bar')) - tester('ntpath.splitdrive("\\\\conky\\mountpoint\\foo\\bar")', - ('\\\\conky\\mountpoint', '\\foo\\bar')) - tester('ntpath.splitdrive("//conky/mountpoint/foo/bar")', - ('//conky/mountpoint', '/foo/bar')) - tester('ntpath.splitdrive("\\\\\\conky\\mountpoint\\foo\\bar")', - ('', '\\\\\\conky\\mountpoint\\foo\\bar')) - tester('ntpath.splitdrive("///conky/mountpoint/foo/bar")', - ('', '///conky/mountpoint/foo/bar')) - tester('ntpath.splitdrive("\\\\conky\\\\mountpoint\\foo\\bar")', - ('', '\\\\conky\\\\mountpoint\\foo\\bar')) - tester('ntpath.splitdrive("//conky//mountpoint/foo/bar")', - ('', '//conky//mountpoint/foo/bar')) - # Issue #19911: UNC part containing U+0130 - self.assertEqual(ntpath.splitdrive(u'//conky/MOUNTPOİNT/foo/bar'), - (u'//conky/MOUNTPOİNT', '/foo/bar')) def test_splitunc(self): - tester('ntpath.splitunc("c:\\foo\\bar")', - ('', 'c:\\foo\\bar')) - tester('ntpath.splitunc("c:/foo/bar")', - ('', 'c:/foo/bar')) tester('ntpath.splitunc("\\\\conky\\mountpoint\\foo\\bar")', ('\\\\conky\\mountpoint', '\\foo\\bar')) tester('ntpath.splitunc("//conky/mountpoint/foo/bar")', ('//conky/mountpoint', '/foo/bar')) - tester('ntpath.splitunc("\\\\\\conky\\mountpoint\\foo\\bar")', - ('', '\\\\\\conky\\mountpoint\\foo\\bar')) - tester('ntpath.splitunc("///conky/mountpoint/foo/bar")', - ('', '///conky/mountpoint/foo/bar')) - tester('ntpath.splitunc("\\\\conky\\\\mountpoint\\foo\\bar")', - ('', '\\\\conky\\\\mountpoint\\foo\\bar')) - tester('ntpath.splitunc("//conky//mountpoint/foo/bar")', - ('', '//conky//mountpoint/foo/bar')) - self.assertEqual(ntpath.splitunc(u'//conky/MOUNTPO\u0130NT/foo/bar'), - (u'//conky/MOUNTPO\u0130NT', u'/foo/bar')) def test_split(self): tester('ntpath.split("c:\\foo\\bar")', ('c:\\foo', 'bar')) @@ -78,10 +45,10 @@ tester('ntpath.split("c:\\")', ('c:\\', '')) tester('ntpath.split("\\\\conky\\mountpoint\\")', - ('\\\\conky\\mountpoint\\', '')) + ('\\\\conky\\mountpoint', '')) tester('ntpath.split("c:/")', ('c:/', '')) - tester('ntpath.split("//conky/mountpoint/")', ('//conky/mountpoint/', '')) + tester('ntpath.split("//conky/mountpoint/")', ('//conky/mountpoint', '')) def test_isabs(self): tester('ntpath.isabs("c:\\")', 1) @@ -104,7 +71,10 @@ tester('ntpath.join("/a")', '/a') tester('ntpath.join("\\a")', '\\a') tester('ntpath.join("a:")', 'a:') + tester('ntpath.join("a:", "b")', 'a:b') + tester('ntpath.join("a:", "/b")', 'a:/b') tester('ntpath.join("a:", "\\b")', 'a:\\b') + tester('ntpath.join("a", "/b")', '/b') tester('ntpath.join("a", "\\b")', '\\b') tester('ntpath.join("a", "b", "c")', 'a\\b\\c') tester('ntpath.join("a\\", "b", "c")', 'a\\b\\c') @@ -112,46 +82,22 @@ tester('ntpath.join("a", "b", "\\c")', '\\c') tester('ntpath.join("d:\\", "\\pleep")', 'd:\\pleep') tester('ntpath.join("d:\\", "a", "b")', 'd:\\a\\b') + tester("ntpath.join('c:', '/a')", 'c:/a') + tester("ntpath.join('c:/', '/a')", 'c:/a') + tester("ntpath.join('c:/a', '/b')", '/b') + tester("ntpath.join('c:', 'd:/')", 'd:/') + tester("ntpath.join('c:/', 'd:/')", 'd:/') + tester("ntpath.join('c:/', 'd:/a/b')", 'd:/a/b') + tester("ntpath.join('')", '') + tester("ntpath.join('', '', '', '', '')", '') + tester("ntpath.join('a')", 'a') tester("ntpath.join('', 'a')", 'a') tester("ntpath.join('', '', '', '', 'a')", 'a') tester("ntpath.join('a', '')", 'a\\') tester("ntpath.join('a', '', '', '', '')", 'a\\') tester("ntpath.join('a\\', '')", 'a\\') tester("ntpath.join('a\\', '', '', '', '')", 'a\\') - tester("ntpath.join('a/', '')", 'a/') - - tester("ntpath.join('a/b', 'x/y')", 'a/b\\x/y') - tester("ntpath.join('/a/b', 'x/y')", '/a/b\\x/y') - tester("ntpath.join('/a/b/', 'x/y')", '/a/b/x/y') - tester("ntpath.join('c:', 'x/y')", 'c:x/y') - tester("ntpath.join('c:a/b', 'x/y')", 'c:a/b\\x/y') - tester("ntpath.join('c:a/b/', 'x/y')", 'c:a/b/x/y') - tester("ntpath.join('c:/', 'x/y')", 'c:/x/y') - tester("ntpath.join('c:/a/b', 'x/y')", 'c:/a/b\\x/y') - tester("ntpath.join('c:/a/b/', 'x/y')", 'c:/a/b/x/y') - tester("ntpath.join('//computer/share', 'x/y')", '//computer/share\\x/y') - tester("ntpath.join('//computer/share/', 'x/y')", '//computer/share/x/y') - tester("ntpath.join('//computer/share/a/b', 'x/y')", '//computer/share/a/b\\x/y') - - tester("ntpath.join('a/b', '/x/y')", '/x/y') - tester("ntpath.join('/a/b', '/x/y')", '/x/y') - tester("ntpath.join('c:', '/x/y')", 'c:/x/y') - tester("ntpath.join('c:a/b', '/x/y')", 'c:/x/y') - tester("ntpath.join('c:/', '/x/y')", 'c:/x/y') - tester("ntpath.join('c:/a/b', '/x/y')", 'c:/x/y') - tester("ntpath.join('//computer/share', '/x/y')", '//computer/share/x/y') - tester("ntpath.join('//computer/share/', '/x/y')", '//computer/share/x/y') - tester("ntpath.join('//computer/share/a', '/x/y')", '//computer/share/x/y') - - tester("ntpath.join('c:', 'C:x/y')", 'C:x/y') - tester("ntpath.join('c:a/b', 'C:x/y')", 'C:a/b\\x/y') - tester("ntpath.join('c:/', 'C:x/y')", 'C:/x/y') - tester("ntpath.join('c:/a/b', 'C:x/y')", 'C:/a/b\\x/y') - - for x in ('', 'a/b', '/a/b', 'c:', 'c:a/b', 'c:/', 'c:/a/b'): - for y in ('d:', 'd:x/y', 'd:/', 'd:/x/y'): - tester("ntpath.join(%r, %r)" % (x, y), y) def test_normpath(self): tester("ntpath.normpath('A//////././//.//B')", r'A\B') @@ -192,6 +138,7 @@ tester('ntpath.expandvars("$[foo]bar")', "$[foo]bar") tester('ntpath.expandvars("$bar bar")', "$bar bar") tester('ntpath.expandvars("$?bar")', "$?bar") + tester('ntpath.expandvars("${foo}bar")', "barbar") tester('ntpath.expandvars("$foo}bar")', "bar}bar") tester('ntpath.expandvars("${foo")', "${foo") tester('ntpath.expandvars("${{foo}}")', "baz1}") @@ -205,65 +152,6 @@ tester('ntpath.expandvars("%foo%%bar")', "bar%bar") tester('ntpath.expandvars("\'%foo%\'%bar")', "\'%foo%\'%bar") - @unittest.skipUnless(test_support.FS_NONASCII, 'need test_support.FS_NONASCII') - def test_expandvars_nonascii(self): - encoding = sys.getfilesystemencoding() - def check(value, expected): - tester0("ntpath.expandvars(%r)" % value, expected) - tester0("ntpath.expandvars(%r)" % value.decode(encoding), - expected.decode(encoding)) - with test_support.EnvironmentVarGuard() as env: - env.clear() - unonascii = test_support.FS_NONASCII - snonascii = unonascii.encode(encoding) - env['spam'] = snonascii - env[snonascii] = 'ham' + snonascii - check('$spam bar', '%s bar' % snonascii) - check('$%s bar' % snonascii, '$%s bar' % snonascii) - check('${spam}bar', '%sbar' % snonascii) - check('${%s}bar' % snonascii, 'ham%sbar' % snonascii) - check('$spam}bar', '%s}bar' % snonascii) - check('$%s}bar' % snonascii, '$%s}bar' % snonascii) - check('%spam% bar', '%s bar' % snonascii) - check('%{}% bar'.format(snonascii), 'ham%s bar' % snonascii) - check('%spam%bar', '%sbar' % snonascii) - check('%{}%bar'.format(snonascii), 'ham%sbar' % snonascii) - - def test_expanduser(self): - tester('ntpath.expanduser("test")', 'test') - - with test_support.EnvironmentVarGuard() as env: - env.clear() - tester('ntpath.expanduser("~test")', '~test') - - env['HOMEPATH'] = 'eric\\idle' - env['HOMEDRIVE'] = 'C:\\' - tester('ntpath.expanduser("~test")', 'C:\\eric\\test') - tester('ntpath.expanduser("~")', 'C:\\eric\\idle') - - del env['HOMEDRIVE'] - tester('ntpath.expanduser("~test")', 'eric\\test') - tester('ntpath.expanduser("~")', 'eric\\idle') - - env.clear() - env['USERPROFILE'] = 'C:\\eric\\idle' - tester('ntpath.expanduser("~test")', 'C:\\eric\\test') - tester('ntpath.expanduser("~")', 'C:\\eric\\idle') - - env.clear() - env['HOME'] = 'C:\\idle\\eric' - tester('ntpath.expanduser("~test")', 'C:\\idle\\test') - tester('ntpath.expanduser("~")', 'C:\\idle\\eric') - - tester('ntpath.expanduser("~test\\foo\\bar")', - 'C:\\idle\\test\\foo\\bar') - tester('ntpath.expanduser("~test/foo/bar")', - 'C:\\idle\\test/foo/bar') - tester('ntpath.expanduser("~\\foo\\bar")', - 'C:\\idle\\eric\\foo\\bar') - tester('ntpath.expanduser("~/foo/bar")', - 'C:\\idle\\eric/foo/bar') - def test_abspath(self): # ntpath.abspath() can only be used on a system with the "nt" module # (reasonably), so we protect this test with "import nt". This allows diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Lib/test/test_old_mailbox.py --- a/Lib/test/test_old_mailbox.py Sat Jul 19 16:34:33 2014 -0700 +++ b/Lib/test/test_old_mailbox.py Sun Jul 20 10:52:46 2014 -0400 @@ -73,9 +73,7 @@ self.createMessage("cur") self.mbox = mailbox.Maildir(test_support.TESTFN) self.assertTrue(len(self.mbox) == 1) - msg = self.mbox.next() - self.assertTrue(msg is not None) - msg.fp.close() + self.assertTrue(self.mbox.next() is not None) self.assertTrue(self.mbox.next() is None) self.assertTrue(self.mbox.next() is None) @@ -83,9 +81,7 @@ self.createMessage("new") self.mbox = mailbox.Maildir(test_support.TESTFN) self.assertTrue(len(self.mbox) == 1) - msg = self.mbox.next() - self.assertTrue(msg is not None) - msg.fp.close() + self.assertTrue(self.mbox.next() is not None) self.assertTrue(self.mbox.next() is None) self.assertTrue(self.mbox.next() is None) @@ -94,12 +90,8 @@ self.createMessage("new") self.mbox = mailbox.Maildir(test_support.TESTFN) self.assertTrue(len(self.mbox) == 2) - msg = self.mbox.next() - self.assertTrue(msg is not None) - msg.fp.close() - msg = self.mbox.next() - self.assertTrue(msg is not None) - msg.fp.close() + self.assertTrue(self.mbox.next() is not None) + self.assertTrue(self.mbox.next() is not None) self.assertTrue(self.mbox.next() is None) self.assertTrue(self.mbox.next() is None) diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Lib/test/test_openpty.py --- a/Lib/test/test_openpty.py Sat Jul 19 16:34:33 2014 -0700 +++ b/Lib/test/test_openpty.py Sun Jul 20 10:52:46 2014 -0400 @@ -10,8 +10,6 @@ class OpenptyTest(unittest.TestCase): def test(self): master, slave = os.openpty() - self.addCleanup(os.close, master) - self.addCleanup(os.close, slave) if not os.isatty(slave): self.fail("Slave-end of pty is not a terminal.") diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Lib/test/test_optparse.py --- a/Lib/test/test_optparse.py Sat Jul 19 16:34:33 2014 -0700 +++ b/Lib/test/test_optparse.py Sun Jul 20 10:52:46 2014 -0400 @@ -383,7 +383,6 @@ self.assertRaises(self.parser.remove_option, ('foo',), None, ValueError, "no such option 'foo'") - @test_support.impl_detail('Relies on sys.getrefcount', cpython=True) def test_refleak(self): # If an OptionParser is carrying around a reference to a large # object, various cycles can prevent it from being GC'd in @@ -770,13 +769,6 @@ self.assertParseFail(["-test"], "no such option: -e") - def test_add_option_accepts_unicode(self): - self.parser.add_option(u"-u", u"--unicode", action="store_true") - self.assertParseOK(["-u"], - {'a': None, 'boo': None, 'foo': None, 'unicode': True}, - []) - - class TestBool(BaseTest): def setUp(self): options = [make_option("-v", @@ -1445,39 +1437,6 @@ -h, --help show this help message and exit """ -_expected_very_help_short_lines = """\ -Usage: bar.py [options] - -Options: - -a APPLE - throw - APPLEs at - basket - -b NUM, --boo=NUM - shout - "boo!" NUM - times (in - order to - frighten - away all - the evil - spirits - that cause - trouble and - mayhem) - --foo=FOO - store FOO - in the foo - list for - later - fooing - -h, --help - show this - help - message and - exit -""" - class TestHelp(BaseTest): def setUp(self): self.parser = self.make_parser(80) @@ -1539,8 +1498,6 @@ # we look at $COLUMNS. self.parser = self.make_parser(60) self.assertHelpEquals(_expected_help_short_lines) - self.parser = self.make_parser(0) - self.assertHelpEquals(_expected_very_help_short_lines) def test_help_unicode(self): self.parser = InterceptingOptionParser(usage=SUPPRESS_USAGE) diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Lib/test/test_os.py --- a/Lib/test/test_os.py Sat Jul 19 16:34:33 2014 -0700 +++ b/Lib/test/test_os.py Sun Jul 20 10:52:46 2014 -0400 @@ -10,13 +10,7 @@ import signal import subprocess import time -try: - import resource -except ImportError: - resource = None - from test import test_support -from test.script_helper import assert_python_ok import mmap import uuid @@ -83,8 +77,9 @@ open(name, "w") self.files.append(name) - @unittest.skipUnless(hasattr(os, 'tempnam'), 'test needs os.tempnam()') def test_tempnam(self): + if not hasattr(os, "tempnam"): + return with warnings.catch_warnings(): warnings.filterwarnings("ignore", "tempnam", RuntimeWarning, r"test_os$") @@ -98,8 +93,9 @@ self.assertTrue(os.path.basename(name)[:3] == "pfx") self.check_tempfile(name) - @unittest.skipUnless(hasattr(os, 'tmpfile'), 'test needs os.tmpfile()') def test_tmpfile(self): + if not hasattr(os, "tmpfile"): + return # As with test_tmpnam() below, the Windows implementation of tmpfile() # attempts to create a file in the root directory of the current drive. # On Vista and Server 2008, this test will always fail for normal users @@ -148,8 +144,9 @@ fp.close() self.assertTrue(s == "foobar") - @unittest.skipUnless(hasattr(os, 'tmpnam'), 'test needs os.tmpnam()') def test_tmpnam(self): + if not hasattr(os, "tmpnam"): + return with warnings.catch_warnings(): warnings.filterwarnings("ignore", "tmpnam", RuntimeWarning, r"test_os$") @@ -190,8 +187,10 @@ os.unlink(self.fname) os.rmdir(test_support.TESTFN) - @unittest.skipUnless(hasattr(os, 'stat'), 'test needs os.stat()') def test_stat_attributes(self): + if not hasattr(os, "stat"): + return + import stat result = os.stat(self.fname) @@ -214,33 +213,33 @@ try: result[200] - self.fail("No exception raised") + self.fail("No exception thrown") except IndexError: pass # Make sure that assignment fails try: result.st_mode = 1 - self.fail("No exception raised") + self.fail("No exception thrown") except (AttributeError, TypeError): pass try: result.st_rdev = 1 - self.fail("No exception raised") + self.fail("No exception thrown") except (AttributeError, TypeError): pass try: result.parrot = 1 - self.fail("No exception raised") + self.fail("No exception thrown") except AttributeError: pass # Use the stat_result constructor with a too-short tuple. try: result2 = os.stat_result((10,)) - self.fail("No exception raised") + self.fail("No exception thrown") except TypeError: pass @@ -251,14 +250,16 @@ pass - @unittest.skipUnless(hasattr(os, 'statvfs'), 'test needs os.statvfs()') def test_statvfs_attributes(self): + if not hasattr(os, "statvfs"): + return + try: result = os.statvfs(self.fname) except OSError, e: # On AtheOS, glibc always returns ENOSYS if e.errno == errno.ENOSYS: - self.skipTest('glibc always returns ENOSYS on AtheOS') + return # Make sure direct access works self.assertEqual(result.f_bfree, result[3]) @@ -272,20 +273,20 @@ # Make sure that assignment really fails try: result.f_bfree = 1 - self.fail("No exception raised") + self.fail("No exception thrown") except TypeError: pass try: result.parrot = 1 - self.fail("No exception raised") + self.fail("No exception thrown") except AttributeError: pass # Use the constructor with a too-short tuple. try: result2 = os.statvfs_result((10,)) - self.fail("No exception raised") + self.fail("No exception thrown") except TypeError: pass @@ -304,10 +305,10 @@ st2 = os.stat(test_support.TESTFN) self.assertEqual(st2.st_mtime, int(st.st_mtime-delta)) - # Restrict tests to Win32, since there is no guarantee other + # Restrict test to Win32, since there is no guarantee other # systems support centiseconds - def get_file_system(path): - if sys.platform == 'win32': + if sys.platform == 'win32': + def get_file_system(path): root = os.path.splitdrive(os.path.abspath(path))[0] + '\\' import ctypes kernel32 = ctypes.windll.kernel32 @@ -315,31 +316,25 @@ if kernel32.GetVolumeInformationA(root, None, 0, None, None, None, buf, len(buf)): return buf.value - @unittest.skipUnless(sys.platform == "win32", "Win32 specific tests") - @unittest.skipUnless(get_file_system(test_support.TESTFN) == "NTFS", - "requires NTFS") - def test_1565150(self): - t1 = 1159195039.25 - os.utime(self.fname, (t1, t1)) - self.assertEqual(os.stat(self.fname).st_mtime, t1) + if get_file_system(test_support.TESTFN) == "NTFS": + def test_1565150(self): + t1 = 1159195039.25 + os.utime(self.fname, (t1, t1)) + self.assertEqual(os.stat(self.fname).st_mtime, t1) - @unittest.skipUnless(sys.platform == "win32", "Win32 specific tests") - @unittest.skipUnless(get_file_system(test_support.TESTFN) == "NTFS", - "requires NTFS") - def test_large_time(self): - t1 = 5000000000 # some day in 2128 - os.utime(self.fname, (t1, t1)) - self.assertEqual(os.stat(self.fname).st_mtime, t1) + def test_large_time(self): + t1 = 5000000000 # some day in 2128 + os.utime(self.fname, (t1, t1)) + self.assertEqual(os.stat(self.fname).st_mtime, t1) - @unittest.skipUnless(sys.platform == "win32", "Win32 specific tests") - def test_1686475(self): - # Verify that an open file can be stat'ed - try: - os.stat(r"c:\pagefile.sys") - except WindowsError, e: - if e.errno == 2: # file does not exist; cannot run test - self.skipTest(r'c:\pagefile.sys does not exist') - self.fail("Could not stat pagefile.sys") + def test_1686475(self): + # Verify that an open file can be stat'ed + try: + os.stat(r"c:\pagefile.sys") + except WindowsError, e: + if e.errno == 2: # file does not exist; cannot run test + return + self.fail("Could not stat pagefile.sys") from test import mapping_tests @@ -531,73 +526,22 @@ f.close() class URandomTests (unittest.TestCase): - - def test_urandom_length(self): - self.assertEqual(len(os.urandom(0)), 0) - self.assertEqual(len(os.urandom(1)), 1) - self.assertEqual(len(os.urandom(10)), 10) - self.assertEqual(len(os.urandom(100)), 100) - self.assertEqual(len(os.urandom(1000)), 1000) - - def test_urandom_value(self): - data1 = os.urandom(16) - data2 = os.urandom(16) - self.assertNotEqual(data1, data2) - - def get_urandom_subprocess(self, count): - # We need to use repr() and eval() to avoid line ending conversions - # under Windows. - code = '\n'.join(( - 'import os, sys', - 'data = os.urandom(%s)' % count, - 'sys.stdout.write(repr(data))', - 'sys.stdout.flush()', - 'print >> sys.stderr, (len(data), data)')) - cmd_line = [sys.executable, '-c', code] - p = subprocess.Popen(cmd_line, stdin=subprocess.PIPE, - stdout=subprocess.PIPE, stderr=subprocess.PIPE) - out, err = p.communicate() - self.assertEqual(p.wait(), 0, (p.wait(), err)) - out = eval(out) - self.assertEqual(len(out), count, err) - return out - - def test_urandom_subprocess(self): - data1 = self.get_urandom_subprocess(16) - data2 = self.get_urandom_subprocess(16) - self.assertNotEqual(data1, data2) - - @unittest.skipUnless(resource, "test requires the resource module") - def test_urandom_failure(self): - # Check urandom() failing when it is not able to open /dev/random. - # We spawn a new process to make the test more robust (if getrlimit() - # failed to restore the file descriptor limit after this, the whole - # test suite would crash; this actually happened on the OS X Tiger - # buildbot). - code = """if 1: - import errno - import os - import resource - - soft_limit, hard_limit = resource.getrlimit(resource.RLIMIT_NOFILE) - resource.setrlimit(resource.RLIMIT_NOFILE, (1, hard_limit)) - try: - os.urandom(16) - except OSError as e: - assert e.errno == errno.EMFILE, e.errno - else: - raise AssertionError("OSError not raised") - """ - assert_python_ok('-c', code) - - -class ExecvpeTests(unittest.TestCase): + def test_urandom(self): + try: + self.assertEqual(len(os.urandom(1)), 1) + self.assertEqual(len(os.urandom(10)), 10) + self.assertEqual(len(os.urandom(100)), 100) + self.assertEqual(len(os.urandom(1000)), 1000) + # see http://bugs.python.org/issue3708 + self.assertRaises(TypeError, os.urandom, 0.9) + self.assertRaises(TypeError, os.urandom, 1.1) + self.assertRaises(TypeError, os.urandom, 2.0) + except NotImplementedError: + pass def test_execvpe_with_bad_arglist(self): self.assertRaises(ValueError, os.execvpe, 'notepad', [], None) - -@unittest.skipUnless(sys.platform == "win32", "Win32 specific tests") class Win32ErrorTests(unittest.TestCase): def test_rename(self): self.assertRaises(WindowsError, os.rename, test_support.TESTFN, test_support.TESTFN+".bak") @@ -644,118 +588,121 @@ self.fail("%r didn't raise a OSError with a bad file descriptor" % f) - @unittest.skipUnless(hasattr(os, 'isatty'), 'test needs os.isatty()') def test_isatty(self): - self.assertEqual(os.isatty(test_support.make_bad_fd()), False) + if hasattr(os, "isatty"): + self.assertEqual(os.isatty(test_support.make_bad_fd()), False) - @unittest.skipUnless(hasattr(os, 'closerange'), 'test needs os.closerange()') def test_closerange(self): - fd = test_support.make_bad_fd() - # Make sure none of the descriptors we are about to close are - # currently valid (issue 6542). - for i in range(10): - try: os.fstat(fd+i) - except OSError: - pass - else: - break - if i < 2: - raise unittest.SkipTest( - "Unable to acquire a range of invalid file descriptors") - self.assertEqual(os.closerange(fd, fd + i-1), None) + if hasattr(os, "closerange"): + fd = test_support.make_bad_fd() + # Make sure none of the descriptors we are about to close are + # currently valid (issue 6542). + for i in range(10): + try: os.fstat(fd+i) + except OSError: + pass + else: + break + if i < 2: + raise unittest.SkipTest( + "Unable to acquire a range of invalid file descriptors") + self.assertEqual(os.closerange(fd, fd + i-1), None) - @unittest.skipUnless(hasattr(os, 'dup2'), 'test needs os.dup2()') def test_dup2(self): - self.check(os.dup2, 20) + if hasattr(os, "dup2"): + self.check(os.dup2, 20) - @unittest.skipUnless(hasattr(os, 'fchmod'), 'test needs os.fchmod()') def test_fchmod(self): - self.check(os.fchmod, 0) + if hasattr(os, "fchmod"): + self.check(os.fchmod, 0) - @unittest.skipUnless(hasattr(os, 'fchown'), 'test needs os.fchown()') def test_fchown(self): - self.check(os.fchown, -1, -1) + if hasattr(os, "fchown"): + self.check(os.fchown, -1, -1) - @unittest.skipUnless(hasattr(os, 'fpathconf'), 'test needs os.fpathconf()') def test_fpathconf(self): - self.check(os.fpathconf, "PC_NAME_MAX") + if hasattr(os, "fpathconf"): + self.check(os.fpathconf, "PC_NAME_MAX") - @unittest.skipUnless(hasattr(os, 'ftruncate'), 'test needs os.ftruncate()') def test_ftruncate(self): - self.check(os.ftruncate, 0) + if hasattr(os, "ftruncate"): + self.check(os.ftruncate, 0) - @unittest.skipUnless(hasattr(os, 'lseek'), 'test needs os.lseek()') def test_lseek(self): - self.check(os.lseek, 0, 0) + if hasattr(os, "lseek"): + self.check(os.lseek, 0, 0) - @unittest.skipUnless(hasattr(os, 'read'), 'test needs os.read()') def test_read(self): - self.check(os.read, 1) + if hasattr(os, "read"): + self.check(os.read, 1) - @unittest.skipUnless(hasattr(os, 'tcsetpgrp'), 'test needs os.tcsetpgrp()') def test_tcsetpgrpt(self): - self.check(os.tcsetpgrp, 0) + if hasattr(os, "tcsetpgrp"): + self.check(os.tcsetpgrp, 0) - @unittest.skipUnless(hasattr(os, 'write'), 'test needs os.write()') def test_write(self): - self.check(os.write, " ") + if hasattr(os, "write"): + self.check(os.write, " ") -@unittest.skipIf(sys.platform == "win32", "Posix specific tests") -class PosixUidGidTests(unittest.TestCase): - @unittest.skipUnless(hasattr(os, 'setuid'), 'test needs os.setuid()') - def test_setuid(self): - if os.getuid() != 0: - self.assertRaises(os.error, os.setuid, 0) - self.assertRaises(OverflowError, os.setuid, 1<<32) +if sys.platform != 'win32': + class Win32ErrorTests(unittest.TestCase): + pass - @unittest.skipUnless(hasattr(os, 'setgid'), 'test needs os.setgid()') - def test_setgid(self): - if os.getuid() != 0: - self.assertRaises(os.error, os.setgid, 0) - self.assertRaises(OverflowError, os.setgid, 1<<32) + class PosixUidGidTests(unittest.TestCase): + if hasattr(os, 'setuid'): + def test_setuid(self): + if os.getuid() != 0: + self.assertRaises(os.error, os.setuid, 0) + self.assertRaises(OverflowError, os.setuid, 1<<32) - @unittest.skipUnless(hasattr(os, 'seteuid'), 'test needs os.seteuid()') - def test_seteuid(self): - if os.getuid() != 0: - self.assertRaises(os.error, os.seteuid, 0) - self.assertRaises(OverflowError, os.seteuid, 1<<32) + if hasattr(os, 'setgid'): + def test_setgid(self): + if os.getuid() != 0: + self.assertRaises(os.error, os.setgid, 0) + self.assertRaises(OverflowError, os.setgid, 1<<32) - @unittest.skipUnless(hasattr(os, 'setegid'), 'test needs os.setegid()') - def test_setegid(self): - if os.getuid() != 0: - self.assertRaises(os.error, os.setegid, 0) - self.assertRaises(OverflowError, os.setegid, 1<<32) + if hasattr(os, 'seteuid'): + def test_seteuid(self): + if os.getuid() != 0: + self.assertRaises(os.error, os.seteuid, 0) + self.assertRaises(OverflowError, os.seteuid, 1<<32) - @unittest.skipUnless(hasattr(os, 'setreuid'), 'test needs os.setreuid()') - def test_setreuid(self): - if os.getuid() != 0: - self.assertRaises(os.error, os.setreuid, 0, 0) - self.assertRaises(OverflowError, os.setreuid, 1<<32, 0) - self.assertRaises(OverflowError, os.setreuid, 0, 1<<32) + if hasattr(os, 'setegid'): + def test_setegid(self): + if os.getuid() != 0: + self.assertRaises(os.error, os.setegid, 0) + self.assertRaises(OverflowError, os.setegid, 1<<32) - @unittest.skipUnless(hasattr(os, 'setreuid'), 'test needs os.setreuid()') - def test_setreuid_neg1(self): - # Needs to accept -1. We run this in a subprocess to avoid - # altering the test runner's process state (issue8045). - subprocess.check_call([ - sys.executable, '-c', - 'import os,sys;os.setreuid(-1,-1);sys.exit(0)']) + if hasattr(os, 'setreuid'): + def test_setreuid(self): + if os.getuid() != 0: + self.assertRaises(os.error, os.setreuid, 0, 0) + self.assertRaises(OverflowError, os.setreuid, 1<<32, 0) + self.assertRaises(OverflowError, os.setreuid, 0, 1<<32) - @unittest.skipUnless(hasattr(os, 'setregid'), 'test needs os.setregid()') - def test_setregid(self): - if os.getuid() != 0: - self.assertRaises(os.error, os.setregid, 0, 0) - self.assertRaises(OverflowError, os.setregid, 1<<32, 0) - self.assertRaises(OverflowError, os.setregid, 0, 1<<32) + def test_setreuid_neg1(self): + # Needs to accept -1. We run this in a subprocess to avoid + # altering the test runner's process state (issue8045). + subprocess.check_call([ + sys.executable, '-c', + 'import os,sys;os.setreuid(-1,-1);sys.exit(0)']) - @unittest.skipUnless(hasattr(os, 'setregid'), 'test needs os.setregid()') - def test_setregid_neg1(self): - # Needs to accept -1. We run this in a subprocess to avoid - # altering the test runner's process state (issue8045). - subprocess.check_call([ - sys.executable, '-c', - 'import os,sys;os.setregid(-1,-1);sys.exit(0)']) + if hasattr(os, 'setregid'): + def test_setregid(self): + if os.getuid() != 0: + self.assertRaises(os.error, os.setregid, 0, 0) + self.assertRaises(OverflowError, os.setregid, 1<<32, 0) + self.assertRaises(OverflowError, os.setregid, 0, 1<<32) + def test_setregid_neg1(self): + # Needs to accept -1. We run this in a subprocess to avoid + # altering the test runner's process state (issue8045). + subprocess.check_call([ + sys.executable, '-c', + 'import os,sys;os.setregid(-1,-1);sys.exit(0)']) +else: + class PosixUidGidTests(unittest.TestCase): + pass @unittest.skipUnless(sys.platform == "win32", "Win32 specific tests") class Win32KillTests(unittest.TestCase): @@ -881,7 +828,6 @@ MakedirTests, DevNullTests, URandomTests, - ExecvpeTests, Win32ErrorTests, TestInvalidFD, PosixUidGidTests, diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Lib/test/test_parser.py --- a/Lib/test/test_parser.py Sat Jul 19 16:34:33 2014 -0700 +++ b/Lib/test/test_parser.py Sun Jul 20 10:52:46 2014 -0400 @@ -1,9 +1,7 @@ import parser import unittest import sys -import struct -from test import test_support as support -from test.script_helper import assert_python_failure +from test import test_support # # First, we test that we can generate trees from valid source fragments, @@ -568,19 +566,8 @@ st = parser.suite('a = u"\u1"') self.assertRaises(SyntaxError, parser.compilest, st) - def test_issue_9011(self): - # Issue 9011: compilation of an unary minus expression changed - # the meaning of the ST, so that a second compilation produced - # incorrect results. - st = parser.expr('-3') - code1 = parser.compilest(st) - self.assertEqual(eval(code1), -3) - code2 = parser.compilest(st) - self.assertEqual(eval(code2), -3) - - class ParserStackLimitTestCase(unittest.TestCase): - """try to push the parser to/over its limits. + """try to push the parser to/over it's limits. see http://bugs.python.org/issue1881 for a discussion """ def _nested_expression(self, level): @@ -593,63 +580,15 @@ def test_trigger_memory_error(self): e = self._nested_expression(100) - rc, out, err = assert_python_failure('-c', e) - # parsing the expression will result in an error message - # followed by a MemoryError (see #11963) - self.assertIn(b's_push: parser stack overflow', err) - self.assertIn(b'MemoryError', err) - -class STObjectTestCase(unittest.TestCase): - """Test operations on ST objects themselves""" - - check_sizeof = support.check_sizeof - - @support.cpython_only - def test_sizeof(self): - def XXXROUNDUP(n): - if n <= 1: - return n - if n <= 128: - return (n + 3) & ~3 - return 1 << (n - 1).bit_length() - - basesize = support.calcobjsize('Pii') - nodesize = struct.calcsize('hP3iP0h') - def sizeofchildren(node): - if node is None: - return 0 - res = 0 - hasstr = len(node) > 1 and isinstance(node[-1], str) - if hasstr: - res += len(node[-1]) + 1 - children = node[1:-1] if hasstr else node[1:] - if children: - res += XXXROUNDUP(len(children)) * nodesize - for child in children: - res += sizeofchildren(child) - return res - - def check_st_sizeof(st): - self.check_sizeof(st, basesize + nodesize + - sizeofchildren(st.totuple())) - - check_st_sizeof(parser.expr('2 + 3')) - check_st_sizeof(parser.expr('2 + 3 + 4')) - check_st_sizeof(parser.suite('x = 2 + 3')) - check_st_sizeof(parser.suite('')) - check_st_sizeof(parser.suite('# -*- coding: utf-8 -*-')) - check_st_sizeof(parser.expr('[' + '2,' * 1000 + ']')) - - - # XXX tests for pickling and unpickling of ST objects should go here + print >>sys.stderr, "Expecting 's_push: parser stack overflow' in next line" + self.assertRaises(MemoryError, parser.expr, e) def test_main(): - support.run_unittest( + test_support.run_unittest( RoundtripLegalSyntaxTestCase, IllegalSyntaxTestCase, CompileTestCase, ParserStackLimitTestCase, - STObjectTestCase, ) diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Lib/test/test_pdb.py --- a/Lib/test/test_pdb.py Sat Jul 19 16:34:33 2014 -0700 +++ b/Lib/test/test_pdb.py Sun Jul 20 10:52:46 2014 -0400 @@ -6,69 +6,12 @@ import os import unittest import subprocess -import textwrap from test import test_support # This little helper class is essential for testing pdb under doctest. from test_doctest import _FakeInput -class PdbTestCase(unittest.TestCase): - - def run_pdb(self, script, commands): - """Run 'script' lines with pdb and the pdb 'commands'.""" - filename = 'main.py' - with open(filename, 'w') as f: - f.write(textwrap.dedent(script)) - self.addCleanup(test_support.unlink, filename) - cmd = [sys.executable, '-m', 'pdb', filename] - stdout = stderr = None - proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, - stdin=subprocess.PIPE, - stderr=subprocess.STDOUT, - ) - stdout, stderr = proc.communicate(commands) - proc.stdout.close() - proc.stdin.close() - return stdout, stderr - - def test_issue13183(self): - script = """ - from bar import bar - - def foo(): - bar() - - def nope(): - pass - - def foobar(): - foo() - nope() - - foobar() - """ - commands = """ - from bar import bar - break bar - continue - step - step - quit - """ - bar = """ - def bar(): - pass - """ - with open('bar.py', 'w') as f: - f.write(textwrap.dedent(bar)) - self.addCleanup(test_support.unlink, 'bar.py') - stdout, stderr = self.run_pdb(script, commands) - self.assertTrue( - any('main.py(5)foo()->None' in l for l in stdout.splitlines()), - 'Fail to step into the caller after a return') - - class PdbTestInput(object): """Context manager that makes testing Pdb in doctests easier.""" @@ -366,9 +309,7 @@ def test_main(): from test import test_pdb test_support.run_doctest(test_pdb, verbosity=True) - test_support.run_unittest( - PdbTestCase, - ModuleInitTester) + test_support.run_unittest(ModuleInitTester) if __name__ == '__main__': test_main() diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Lib/test/test_peepholer.py --- a/Lib/test/test_peepholer.py Sat Jul 19 16:34:33 2014 -0700 +++ b/Lib/test/test_peepholer.py Sun Jul 20 10:52:46 2014 -0400 @@ -138,22 +138,21 @@ self.assertIn('(1000)', asm) def test_binary_subscr_on_unicode(self): - # unicode strings don't get optimized + # valid code get optimized asm = dis_single('u"foo"[0]') - self.assertNotIn("(u'f')", asm) - self.assertIn('BINARY_SUBSCR', asm) + self.assertIn("(u'f')", asm) + self.assertNotIn('BINARY_SUBSCR', asm) asm = dis_single('u"\u0061\uffff"[1]') - self.assertNotIn("(u'\\uffff')", asm) - self.assertIn('BINARY_SUBSCR', asm) + self.assertIn("(u'\\uffff')", asm) + self.assertNotIn('BINARY_SUBSCR', asm) + # invalid code doesn't get optimized # out of range asm = dis_single('u"fuu"[10]') self.assertIn('BINARY_SUBSCR', asm) # non-BMP char (see #5057) asm = dis_single('u"\U00012345"[0]') self.assertIn('BINARY_SUBSCR', asm) - asm = dis_single('u"\U00012345abcdef"[3]') - self.assertIn('BINARY_SUBSCR', asm) def test_folding_of_unaryops_on_constants(self): diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Lib/test/test_pep263.py --- a/Lib/test/test_pep263.py Sat Jul 19 16:34:33 2014 -0700 +++ b/Lib/test/test_pep263.py Sun Jul 20 10:52:46 2014 -0400 @@ -41,29 +41,6 @@ # two bytes in common with the UTF-8 BOM self.assertRaises(SyntaxError, eval, '\xef\xbb\x20') - def test_error_message(self): - compile('# -*- coding: iso-8859-15 -*-\n', 'dummy', 'exec') - compile('\xef\xbb\xbf\n', 'dummy', 'exec') - compile('\xef\xbb\xbf# -*- coding: utf-8 -*-\n', 'dummy', 'exec') - with self.assertRaisesRegexp(SyntaxError, 'fake'): - compile('# -*- coding: fake -*-\n', 'dummy', 'exec') - with self.assertRaisesRegexp(SyntaxError, 'iso-8859-15'): - compile('\xef\xbb\xbf# -*- coding: iso-8859-15 -*-\n', - 'dummy', 'exec') - with self.assertRaisesRegexp(SyntaxError, 'BOM'): - compile('\xef\xbb\xbf# -*- coding: iso-8859-15 -*-\n', - 'dummy', 'exec') - with self.assertRaisesRegexp(SyntaxError, 'fake'): - compile('\xef\xbb\xbf# -*- coding: fake -*-\n', 'dummy', 'exec') - with self.assertRaisesRegexp(SyntaxError, 'BOM'): - compile('\xef\xbb\xbf# -*- coding: fake -*-\n', 'dummy', 'exec') - - def test_non_unicode_codec(self): - with self.assertRaisesRegexp(SyntaxError, - 'codec did not return a unicode'): - from test import bad_coding3 - - def test_main(): test_support.run_unittest(PEP263Test) diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Lib/test/test_pickle.py --- a/Lib/test/test_pickle.py Sat Jul 19 16:34:33 2014 -0700 +++ b/Lib/test/test_pickle.py Sun Jul 20 10:52:46 2014 -0400 @@ -3,11 +3,10 @@ from test import test_support -from test.pickletester import (AbstractPickleTests, - AbstractPickleModuleTests, - AbstractPersistentPicklerTests, - AbstractPicklerUnpicklerObjectTests, - BigmemPickleTests) +from test.pickletester import AbstractPickleTests +from test.pickletester import AbstractPickleModuleTests +from test.pickletester import AbstractPersistentPicklerTests +from test.pickletester import AbstractPicklerUnpicklerObjectTests class PickleTests(AbstractPickleTests, AbstractPickleModuleTests): @@ -67,16 +66,6 @@ pickler_class = pickle.Pickler unpickler_class = pickle.Unpickler -class PickleBigmemPickleTests(BigmemPickleTests): - - def dumps(self, arg, proto=0, fast=0): - # Ignore fast - return pickle.dumps(arg, proto) - - def loads(self, buf): - # Ignore fast - return pickle.loads(buf) - def test_main(): test_support.run_unittest( @@ -84,7 +73,6 @@ PicklerTests, PersPicklerTests, PicklerUnpicklerObjectTests, - PickleBigmemPickleTests, ) test_support.run_doctest(pickle) diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Lib/test/test_platform.py --- a/Lib/test/test_platform.py Sat Jul 19 16:34:33 2014 -0700 +++ b/Lib/test/test_platform.py Sun Jul 20 10:52:46 2014 -0400 @@ -84,28 +84,15 @@ ("CPython", "2.6.1", "tags/r261", "67515", ('r261:67515', 'Dec 6 2008 15:26:00'), 'GCC 4.0.1 (Apple Computer, Inc. build 5370)'), - ("IronPython 2.0 (2.0.0.0) on .NET 2.0.50727.3053", None, "cli") : ("IronPython", "2.0.0", "", "", ("", ""), ".NET 2.0.50727.3053"), - - ("2.6.1 (IronPython 2.6.1 (2.6.10920.0) on .NET 2.0.50727.1433)", None, "cli") - : - ("IronPython", "2.6.1", "", "", ("", ""), - ".NET 2.0.50727.1433"), - - ("2.7.4 (IronPython 2.7.4 (2.7.0.40) on Mono 4.0.30319.1 (32-bit))", None, "cli") - : - ("IronPython", "2.7.4", "", "", ("", ""), - "Mono 4.0.30319.1 (32-bit)"), - ("2.5 (trunk:6107, Mar 26 2009, 13:02:18) \n[Java HotSpot(TM) Client VM (\"Apple Computer, Inc.\")]", ('Jython', 'trunk', '6107'), "java1.5.0_16") : ("Jython", "2.5.0", "trunk", "6107", ('trunk:6107', 'Mar 26 2009'), "java1.5.0_16"), - ("2.5.2 (63378, Mar 26 2009, 18:03:29)\n[PyPy 1.0.0]", ('PyPy', 'trunk', '63378'), self.save_platform) : diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Lib/test/test_plistlib.py --- a/Lib/test/test_plistlib.py Sat Jul 19 16:34:33 2014 -0700 +++ b/Lib/test/test_plistlib.py Sun Jul 20 10:52:46 2014 -0400 @@ -135,18 +135,6 @@ data2 = plistlib.writePlistToString(pl2) self.assertEqual(data, data2) - def test_indentation_array(self): - data = [[[[[[[[{'test': plistlib.Data(b'aaaaaa')}]]]]]]]] - self.assertEqual(plistlib.readPlistFromString(plistlib.writePlistToString(data)), data) - - def test_indentation_dict(self): - data = {'1': {'2': {'3': {'4': {'5': {'6': {'7': {'8': {'9': plistlib.Data(b'aaaaaa')}}}}}}}}} - self.assertEqual(plistlib.readPlistFromString(plistlib.writePlistToString(data)), data) - - def test_indentation_dict_mix(self): - data = {'1': {'2': [{'3': [[[[[{'test': plistlib.Data(b'aaaaaa')}]]]]]}]}} - self.assertEqual(plistlib.readPlistFromString(plistlib.writePlistToString(data)), data) - def test_appleformatting(self): pl = plistlib.readPlistFromString(TESTDATA) data = plistlib.writePlistToString(pl) diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Lib/test/test_poll.py --- a/Lib/test/test_poll.py Sat Jul 19 16:34:33 2014 -0700 +++ b/Lib/test/test_poll.py Sun Jul 20 10:52:46 2014 -0400 @@ -1,15 +1,7 @@ # Test case for the os.poll() function -import os -import random -import select -try: - import threading -except ImportError: - threading = None -import time -import unittest -from test.test_support import TESTFN, run_unittest, reap_threads, cpython_only +import os, select, random, unittest +from test.test_support import TESTFN, run_unittest try: select.poll @@ -158,54 +150,6 @@ if x != 5: self.fail('Overflow must have occurred') - # Issues #15989, #17919 - self.assertRaises(OverflowError, pollster.register, 0, -1) - self.assertRaises(OverflowError, pollster.register, 0, 1 << 64) - self.assertRaises(OverflowError, pollster.modify, 1, -1) - self.assertRaises(OverflowError, pollster.modify, 1, 1 << 64) - - @cpython_only - def test_poll_c_limits(self): - from _testcapi import USHRT_MAX, INT_MAX, UINT_MAX - pollster = select.poll() - pollster.register(1) - - # Issues #15989, #17919 - self.assertRaises(OverflowError, pollster.register, 0, USHRT_MAX + 1) - self.assertRaises(OverflowError, pollster.modify, 1, USHRT_MAX + 1) - self.assertRaises(OverflowError, pollster.poll, INT_MAX + 1) - self.assertRaises(OverflowError, pollster.poll, UINT_MAX + 1) - - @unittest.skipUnless(threading, 'Threading required for this test.') - @reap_threads - def test_threaded_poll(self): - r, w = os.pipe() - self.addCleanup(os.close, r) - self.addCleanup(os.close, w) - rfds = [] - for i in range(10): - fd = os.dup(r) - self.addCleanup(os.close, fd) - rfds.append(fd) - pollster = select.poll() - for fd in rfds: - pollster.register(fd, select.POLLIN) - - t = threading.Thread(target=pollster.poll) - t.start() - try: - time.sleep(0.5) - # trigger ufds array reallocation - for fd in rfds: - pollster.unregister(fd) - pollster.register(w, select.POLLOUT) - self.assertRaises(RuntimeError, pollster.poll) - finally: - # and make the call to poll() from the thread return - os.write(w, b'spam') - t.join() - - def test_main(): run_unittest(PollTests) diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Lib/test/test_popen.py --- a/Lib/test/test_popen.py Sat Jul 19 16:34:33 2014 -0700 +++ b/Lib/test/test_popen.py Sun Jul 20 10:52:46 2014 -0400 @@ -1,3 +1,4 @@ +#! /usr/bin/env python """Basic tests for os.popen() Particularly useful for platforms that fake popen. diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Lib/test/test_popen2.py --- a/Lib/test/test_popen2.py Sat Jul 19 16:34:33 2014 -0700 +++ b/Lib/test/test_popen2.py Sun Jul 20 10:52:46 2014 -0400 @@ -1,3 +1,4 @@ +#! /usr/bin/env python """Test script for popen2.py""" import warnings diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Lib/test/test_poplib.py --- a/Lib/test/test_poplib.py Sat Jul 19 16:34:33 2014 -0700 +++ b/Lib/test/test_poplib.py Sun Jul 20 10:52:46 2014 -0400 @@ -11,7 +11,7 @@ import time import errno -from unittest import TestCase, skipUnless +from unittest import TestCase from test import test_support from test.test_support import HOST threading = test_support.import_module('threading') @@ -263,20 +263,17 @@ else: DummyPOP3Handler.handle_read(self) -requires_ssl = skipUnless(SUPPORTS_SSL, 'SSL not supported') + class TestPOP3_SSLClass(TestPOP3Class): + # repeat previous tests by using poplib.POP3_SSL -@requires_ssl -class TestPOP3_SSLClass(TestPOP3Class): - # repeat previous tests by using poplib.POP3_SSL + def setUp(self): + self.server = DummyPOP3Server((HOST, 0)) + self.server.handler = DummyPOP3_SSLHandler + self.server.start() + self.client = poplib.POP3_SSL(self.server.host, self.server.port) - def setUp(self): - self.server = DummyPOP3Server((HOST, 0)) - self.server.handler = DummyPOP3_SSLHandler - self.server.start() - self.client = poplib.POP3_SSL(self.server.host, self.server.port) - - def test__all__(self): - self.assertIn('POP3_SSL', poplib.__all__) + def test__all__(self): + self.assertIn('POP3_SSL', poplib.__all__) class TestTimeouts(TestCase): @@ -284,58 +281,57 @@ def setUp(self): self.evt = threading.Event() self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) - self.sock.settimeout(60) # Safety net. Look issue 11812 + self.sock.settimeout(3) self.port = test_support.bind_port(self.sock) - self.thread = threading.Thread(target=self.server, args=(self.evt,self.sock)) - self.thread.setDaemon(True) - self.thread.start() - self.evt.wait() + threading.Thread(target=self.server, args=(self.evt,self.sock)).start() + time.sleep(.1) def tearDown(self): - self.thread.join() - del self.thread # Clear out any dangling Thread objects. + self.evt.wait() def server(self, evt, serv): serv.listen(5) - evt.set() try: conn, addr = serv.accept() + except socket.timeout: + pass + else: conn.send("+ Hola mundo\n") conn.close() - except socket.timeout: - pass finally: serv.close() + evt.set() def testTimeoutDefault(self): - self.assertIsNone(socket.getdefaulttimeout()) + self.assertTrue(socket.getdefaulttimeout() is None) socket.setdefaulttimeout(30) try: - pop = poplib.POP3(HOST, self.port) + pop = poplib.POP3("localhost", self.port) finally: socket.setdefaulttimeout(None) self.assertEqual(pop.sock.gettimeout(), 30) pop.sock.close() def testTimeoutNone(self): - self.assertIsNone(socket.getdefaulttimeout()) + self.assertTrue(socket.getdefaulttimeout() is None) socket.setdefaulttimeout(30) try: pop = poplib.POP3(HOST, self.port, timeout=None) finally: socket.setdefaulttimeout(None) - self.assertIsNone(pop.sock.gettimeout()) + self.assertTrue(pop.sock.gettimeout() is None) pop.sock.close() def testTimeoutValue(self): - pop = poplib.POP3(HOST, self.port, timeout=30) + pop = poplib.POP3("localhost", self.port, timeout=30) self.assertEqual(pop.sock.gettimeout(), 30) pop.sock.close() def test_main(): - tests = [TestPOP3Class, TestTimeouts, - TestPOP3_SSLClass] + tests = [TestPOP3Class, TestTimeouts] + if SUPPORTS_SSL: + tests.append(TestPOP3_SSLClass) thread_info = test_support.threading_setup() try: test_support.run_unittest(*tests) diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Lib/test/test_posix.py --- a/Lib/test/test_posix.py Sat Jul 19 16:34:33 2014 -0700 +++ b/Lib/test/test_posix.py Sun Jul 20 10:52:46 2014 -0400 @@ -9,7 +9,6 @@ import sys import time import os -import platform import pwd import shutil import stat @@ -53,55 +52,47 @@ posix_func() self.assertRaises(TypeError, posix_func, 1) - @unittest.skipUnless(hasattr(posix, 'getresuid'), - 'test needs posix.getresuid()') - def test_getresuid(self): - user_ids = posix.getresuid() - self.assertEqual(len(user_ids), 3) - for val in user_ids: - self.assertGreaterEqual(val, 0) + if hasattr(posix, 'getresuid'): + def test_getresuid(self): + user_ids = posix.getresuid() + self.assertEqual(len(user_ids), 3) + for val in user_ids: + self.assertGreaterEqual(val, 0) - @unittest.skipUnless(hasattr(posix, 'getresgid'), - 'test needs posix.getresgid()') - def test_getresgid(self): - group_ids = posix.getresgid() - self.assertEqual(len(group_ids), 3) - for val in group_ids: - self.assertGreaterEqual(val, 0) + if hasattr(posix, 'getresgid'): + def test_getresgid(self): + group_ids = posix.getresgid() + self.assertEqual(len(group_ids), 3) + for val in group_ids: + self.assertGreaterEqual(val, 0) - @unittest.skipUnless(hasattr(posix, 'setresuid'), - 'test needs posix.setresuid()') - def test_setresuid(self): - current_user_ids = posix.getresuid() - self.assertIsNone(posix.setresuid(*current_user_ids)) - # -1 means don't change that value. - self.assertIsNone(posix.setresuid(-1, -1, -1)) + if hasattr(posix, 'setresuid'): + def test_setresuid(self): + current_user_ids = posix.getresuid() + self.assertIsNone(posix.setresuid(*current_user_ids)) + # -1 means don't change that value. + self.assertIsNone(posix.setresuid(-1, -1, -1)) - @unittest.skipUnless(hasattr(posix, 'setresuid'), - 'test needs posix.setresuid()') - def test_setresuid_exception(self): - # Don't do this test if someone is silly enough to run us as root. - current_user_ids = posix.getresuid() - if 0 not in current_user_ids: - new_user_ids = (current_user_ids[0]+1, -1, -1) - self.assertRaises(OSError, posix.setresuid, *new_user_ids) + def test_setresuid_exception(self): + # Don't do this test if someone is silly enough to run us as root. + current_user_ids = posix.getresuid() + if 0 not in current_user_ids: + new_user_ids = (current_user_ids[0]+1, -1, -1) + self.assertRaises(OSError, posix.setresuid, *new_user_ids) - @unittest.skipUnless(hasattr(posix, 'setresgid'), - 'test needs posix.setresgid()') - def test_setresgid(self): - current_group_ids = posix.getresgid() - self.assertIsNone(posix.setresgid(*current_group_ids)) - # -1 means don't change that value. - self.assertIsNone(posix.setresgid(-1, -1, -1)) + if hasattr(posix, 'setresgid'): + def test_setresgid(self): + current_group_ids = posix.getresgid() + self.assertIsNone(posix.setresgid(*current_group_ids)) + # -1 means don't change that value. + self.assertIsNone(posix.setresgid(-1, -1, -1)) - @unittest.skipUnless(hasattr(posix, 'setresgid'), - 'test needs posix.setresgid()') - def test_setresgid_exception(self): - # Don't do this test if someone is silly enough to run us as root. - current_group_ids = posix.getresgid() - if 0 not in current_group_ids: - new_group_ids = (current_group_ids[0]+1, -1, -1) - self.assertRaises(OSError, posix.setresgid, *new_group_ids) + def test_setresgid_exception(self): + # Don't do this test if someone is silly enough to run us as root. + current_group_ids = posix.getresgid() + if 0 not in current_group_ids: + new_group_ids = (current_group_ids[0]+1, -1, -1) + self.assertRaises(OSError, posix.setresgid, *new_group_ids) @unittest.skipUnless(hasattr(posix, 'initgroups'), "test needs os.initgroups()") @@ -116,11 +107,7 @@ # If a non-privileged user invokes it, it should fail with OSError # EPERM. if os.getuid() != 0: - try: - name = pwd.getpwuid(posix.getuid()).pw_name - except KeyError: - # the current UID may not have a pwd entry - raise unittest.SkipTest("need a pwd entry") + name = pwd.getpwuid(posix.getuid()).pw_name try: posix.initgroups(name, 13) except OSError as e: @@ -128,185 +115,128 @@ else: self.fail("Expected OSError to be raised by initgroups") - @unittest.skipUnless(hasattr(posix, 'statvfs'), - 'test needs posix.statvfs()') def test_statvfs(self): - self.assertTrue(posix.statvfs(os.curdir)) + if hasattr(posix, 'statvfs'): + self.assertTrue(posix.statvfs(os.curdir)) - @unittest.skipUnless(hasattr(posix, 'fstatvfs'), - 'test needs posix.fstatvfs()') def test_fstatvfs(self): - fp = open(test_support.TESTFN) - try: - self.assertTrue(posix.fstatvfs(fp.fileno())) - finally: - fp.close() + if hasattr(posix, 'fstatvfs'): + fp = open(test_support.TESTFN) + try: + self.assertTrue(posix.fstatvfs(fp.fileno())) + finally: + fp.close() - @unittest.skipUnless(hasattr(posix, 'ftruncate'), - 'test needs posix.ftruncate()') def test_ftruncate(self): - fp = open(test_support.TESTFN, 'w+') - try: - # we need to have some data to truncate - fp.write('test') - fp.flush() - posix.ftruncate(fp.fileno(), 0) - finally: - fp.close() + if hasattr(posix, 'ftruncate'): + fp = open(test_support.TESTFN, 'w+') + try: + # we need to have some data to truncate + fp.write('test') + fp.flush() + posix.ftruncate(fp.fileno(), 0) + finally: + fp.close() - @unittest.skipUnless(hasattr(posix, 'dup'), - 'test needs posix.dup()') def test_dup(self): - fp = open(test_support.TESTFN) - try: - fd = posix.dup(fp.fileno()) - self.assertIsInstance(fd, int) - os.close(fd) - finally: - fp.close() + if hasattr(posix, 'dup'): + fp = open(test_support.TESTFN) + try: + fd = posix.dup(fp.fileno()) + self.assertIsInstance(fd, int) + os.close(fd) + finally: + fp.close() - @unittest.skipUnless(hasattr(posix, 'confstr'), - 'test needs posix.confstr()') def test_confstr(self): - self.assertRaises(ValueError, posix.confstr, "CS_garbage") - self.assertEqual(len(posix.confstr("CS_PATH")) > 0, True) + if hasattr(posix, 'confstr'): + self.assertRaises(ValueError, posix.confstr, "CS_garbage") + self.assertEqual(len(posix.confstr("CS_PATH")) > 0, True) - @unittest.skipUnless(hasattr(posix, 'dup2'), - 'test needs posix.dup2()') def test_dup2(self): - fp1 = open(test_support.TESTFN) - fp2 = open(test_support.TESTFN) - try: - posix.dup2(fp1.fileno(), fp2.fileno()) - finally: - fp1.close() - fp2.close() + if hasattr(posix, 'dup2'): + fp1 = open(test_support.TESTFN) + fp2 = open(test_support.TESTFN) + try: + posix.dup2(fp1.fileno(), fp2.fileno()) + finally: + fp1.close() + fp2.close() def fdopen_helper(self, *args): fd = os.open(test_support.TESTFN, os.O_RDONLY) fp2 = posix.fdopen(fd, *args) fp2.close() - @unittest.skipUnless(hasattr(posix, 'fdopen'), - 'test needs posix.fdopen()') def test_fdopen(self): - self.fdopen_helper() - self.fdopen_helper('r') - self.fdopen_helper('r', 100) + if hasattr(posix, 'fdopen'): + self.fdopen_helper() + self.fdopen_helper('r') + self.fdopen_helper('r', 100) - @unittest.skipUnless(hasattr(posix, 'fdopen') and - not sys.platform.startswith("sunos"), - 'test needs posix.fdopen()') - def test_fdopen_keeps_fd_open_on_errors(self): - fd = os.open(test_support.TESTFN, os.O_RDONLY) - self.assertRaises(OSError, posix.fdopen, fd, 'w') - os.close(fd) # fd should not be closed. - - @unittest.skipUnless(hasattr(posix, 'O_EXLOCK'), - 'test needs posix.O_EXLOCK') def test_osexlock(self): - fd = os.open(test_support.TESTFN, - os.O_WRONLY|os.O_EXLOCK|os.O_CREAT) - self.assertRaises(OSError, os.open, test_support.TESTFN, - os.O_WRONLY|os.O_EXLOCK|os.O_NONBLOCK) - os.close(fd) - - if hasattr(posix, "O_SHLOCK"): + if hasattr(posix, "O_EXLOCK"): fd = os.open(test_support.TESTFN, - os.O_WRONLY|os.O_SHLOCK|os.O_CREAT) + os.O_WRONLY|os.O_EXLOCK|os.O_CREAT) self.assertRaises(OSError, os.open, test_support.TESTFN, os.O_WRONLY|os.O_EXLOCK|os.O_NONBLOCK) os.close(fd) - @unittest.skipUnless(hasattr(posix, 'O_SHLOCK'), - 'test needs posix.O_SHLOCK') + if hasattr(posix, "O_SHLOCK"): + fd = os.open(test_support.TESTFN, + os.O_WRONLY|os.O_SHLOCK|os.O_CREAT) + self.assertRaises(OSError, os.open, test_support.TESTFN, + os.O_WRONLY|os.O_EXLOCK|os.O_NONBLOCK) + os.close(fd) + def test_osshlock(self): - fd1 = os.open(test_support.TESTFN, - os.O_WRONLY|os.O_SHLOCK|os.O_CREAT) - fd2 = os.open(test_support.TESTFN, - os.O_WRONLY|os.O_SHLOCK|os.O_CREAT) - os.close(fd2) - os.close(fd1) + if hasattr(posix, "O_SHLOCK"): + fd1 = os.open(test_support.TESTFN, + os.O_WRONLY|os.O_SHLOCK|os.O_CREAT) + fd2 = os.open(test_support.TESTFN, + os.O_WRONLY|os.O_SHLOCK|os.O_CREAT) + os.close(fd2) + os.close(fd1) - if hasattr(posix, "O_EXLOCK"): - fd = os.open(test_support.TESTFN, - os.O_WRONLY|os.O_SHLOCK|os.O_CREAT) - self.assertRaises(OSError, os.open, test_support.TESTFN, - os.O_RDONLY|os.O_EXLOCK|os.O_NONBLOCK) - os.close(fd) + if hasattr(posix, "O_EXLOCK"): + fd = os.open(test_support.TESTFN, + os.O_WRONLY|os.O_SHLOCK|os.O_CREAT) + self.assertRaises(OSError, os.open, test_support.TESTFN, + os.O_RDONLY|os.O_EXLOCK|os.O_NONBLOCK) + os.close(fd) - @unittest.skipUnless(hasattr(posix, 'fstat'), - 'test needs posix.fstat()') def test_fstat(self): - fp = open(test_support.TESTFN) - try: - self.assertTrue(posix.fstat(fp.fileno())) - finally: - fp.close() + if hasattr(posix, 'fstat'): + fp = open(test_support.TESTFN) + try: + self.assertTrue(posix.fstat(fp.fileno())) + finally: + fp.close() - @unittest.skipUnless(hasattr(posix, 'stat'), - 'test needs posix.stat()') def test_stat(self): - self.assertTrue(posix.stat(test_support.TESTFN)) + if hasattr(posix, 'stat'): + self.assertTrue(posix.stat(test_support.TESTFN)) - def _test_all_chown_common(self, chown_func, first_param, stat_func): + def _test_all_chown_common(self, chown_func, first_param): """Common code for chown, fchown and lchown tests.""" - def check_stat(uid, gid): - if stat_func is not None: - stat = stat_func(first_param) - self.assertEqual(stat.st_uid, uid) - self.assertEqual(stat.st_gid, gid) - uid = os.getuid() - gid = os.getgid() - # test a successful chown call - chown_func(first_param, uid, gid) - check_stat(uid, gid) - chown_func(first_param, -1, gid) - check_stat(uid, gid) - chown_func(first_param, uid, -1) - check_stat(uid, gid) - - if uid == 0: - # Try an amusingly large uid/gid to make sure we handle - # large unsigned values. (chown lets you use any - # uid/gid you like, even if they aren't defined.) - # - # This problem keeps coming up: - # http://bugs.python.org/issue1747858 - # http://bugs.python.org/issue4591 - # http://bugs.python.org/issue15301 - # Hopefully the fix in 4591 fixes it for good! - # - # This part of the test only runs when run as root. - # Only scary people run their tests as root. - - big_value = 2**31 - chown_func(first_param, big_value, big_value) - check_stat(big_value, big_value) - chown_func(first_param, -1, -1) - check_stat(big_value, big_value) - chown_func(first_param, uid, gid) - check_stat(uid, gid) - elif platform.system() in ('HP-UX', 'SunOS'): - # HP-UX and Solaris can allow a non-root user to chown() to root - # (issue #5113) - raise unittest.SkipTest("Skipping because of non-standard chown() " - "behavior") + if os.getuid() == 0: + try: + # Many linux distros have a nfsnobody user as MAX_UID-2 + # that makes a good test case for signedness issues. + # http://bugs.python.org/issue1747858 + # This part of the test only runs when run as root. + # Only scary people run their tests as root. + ent = pwd.getpwnam('nfsnobody') + chown_func(first_param, ent.pw_uid, ent.pw_gid) + except KeyError: + pass else: # non-root cannot chown to root, raises OSError - self.assertRaises(OSError, chown_func, first_param, 0, 0) - check_stat(uid, gid) - self.assertRaises(OSError, chown_func, first_param, 0, -1) - check_stat(uid, gid) - if 0 not in os.getgroups(): - self.assertRaises(OSError, chown_func, first_param, -1, 0) - check_stat(uid, gid) - # test illegal types - for t in str, float: - self.assertRaises(TypeError, chown_func, first_param, t(uid), gid) - check_stat(uid, gid) - self.assertRaises(TypeError, chown_func, first_param, uid, t(gid)) - check_stat(uid, gid) + self.assertRaises(OSError, chown_func, + first_param, 0, 0) + + # test a successful chown call + chown_func(first_param, os.getuid(), os.getgid()) @unittest.skipUnless(hasattr(posix, 'chown'), "test needs os.chown()") def test_chown(self): @@ -316,8 +246,7 @@ # re-create the file open(test_support.TESTFN, 'w').close() - self._test_all_chown_common(posix.chown, test_support.TESTFN, - getattr(posix, 'stat', None)) + self._test_all_chown_common(posix.chown, test_support.TESTFN) @unittest.skipUnless(hasattr(posix, 'fchown'), "test needs os.fchown()") def test_fchown(self): @@ -327,8 +256,7 @@ test_file = open(test_support.TESTFN, 'w') try: fd = test_file.fileno() - self._test_all_chown_common(posix.fchown, fd, - getattr(posix, 'fstat', None)) + self._test_all_chown_common(posix.fchown, fd) finally: test_file.close() @@ -337,79 +265,66 @@ os.unlink(test_support.TESTFN) # create a symlink os.symlink(_DUMMY_SYMLINK, test_support.TESTFN) - self._test_all_chown_common(posix.lchown, test_support.TESTFN, - getattr(posix, 'lstat', None)) + self._test_all_chown_common(posix.lchown, test_support.TESTFN) - @unittest.skipUnless(hasattr(posix, 'chdir'), 'test needs posix.chdir()') def test_chdir(self): - posix.chdir(os.curdir) - self.assertRaises(OSError, posix.chdir, test_support.TESTFN) + if hasattr(posix, 'chdir'): + posix.chdir(os.curdir) + self.assertRaises(OSError, posix.chdir, test_support.TESTFN) - @unittest.skipUnless(hasattr(posix, 'lsdir'), 'test needs posix.lsdir()') def test_lsdir(self): - self.assertIn(test_support.TESTFN, posix.lsdir(os.curdir)) + if hasattr(posix, 'lsdir'): + self.assertIn(test_support.TESTFN, posix.lsdir(os.curdir)) - @unittest.skipUnless(hasattr(posix, 'access'), 'test needs posix.access()') def test_access(self): - self.assertTrue(posix.access(test_support.TESTFN, os.R_OK)) + if hasattr(posix, 'access'): + self.assertTrue(posix.access(test_support.TESTFN, os.R_OK)) - @unittest.skipUnless(hasattr(posix, 'umask'), 'test needs posix.umask()') def test_umask(self): - old_mask = posix.umask(0) - self.assertIsInstance(old_mask, int) - posix.umask(old_mask) + if hasattr(posix, 'umask'): + old_mask = posix.umask(0) + self.assertIsInstance(old_mask, int) + posix.umask(old_mask) - @unittest.skipUnless(hasattr(posix, 'strerror'), - 'test needs posix.strerror()') def test_strerror(self): - self.assertTrue(posix.strerror(0)) + if hasattr(posix, 'strerror'): + self.assertTrue(posix.strerror(0)) - @unittest.skipUnless(hasattr(posix, 'pipe'), 'test needs posix.pipe()') def test_pipe(self): - reader, writer = posix.pipe() - os.close(reader) - os.close(writer) + if hasattr(posix, 'pipe'): + reader, writer = posix.pipe() + os.close(reader) + os.close(writer) - @unittest.skipUnless(hasattr(posix, 'tempnam'), - 'test needs posix.tempnam()') def test_tempnam(self): - with warnings.catch_warnings(): - warnings.filterwarnings("ignore", "tempnam", DeprecationWarning) - self.assertTrue(posix.tempnam()) - self.assertTrue(posix.tempnam(os.curdir)) - self.assertTrue(posix.tempnam(os.curdir, 'blah')) + if hasattr(posix, 'tempnam'): + with warnings.catch_warnings(): + warnings.filterwarnings("ignore", "tempnam", DeprecationWarning) + self.assertTrue(posix.tempnam()) + self.assertTrue(posix.tempnam(os.curdir)) + self.assertTrue(posix.tempnam(os.curdir, 'blah')) - @unittest.skipUnless(hasattr(posix, 'tmpfile'), - 'test needs posix.tmpfile()') def test_tmpfile(self): - with warnings.catch_warnings(): - warnings.filterwarnings("ignore", "tmpfile", DeprecationWarning) - fp = posix.tmpfile() - fp.close() + if hasattr(posix, 'tmpfile'): + with warnings.catch_warnings(): + warnings.filterwarnings("ignore", "tmpfile", DeprecationWarning) + fp = posix.tmpfile() + fp.close() - @unittest.skipUnless(hasattr(posix, 'utime'), 'test needs posix.utime()') def test_utime(self): - now = time.time() - posix.utime(test_support.TESTFN, None) - self.assertRaises(TypeError, posix.utime, test_support.TESTFN, (None, None)) - self.assertRaises(TypeError, posix.utime, test_support.TESTFN, (now, None)) - self.assertRaises(TypeError, posix.utime, test_support.TESTFN, (None, now)) - posix.utime(test_support.TESTFN, (int(now), int(now))) - posix.utime(test_support.TESTFN, (now, now)) + if hasattr(posix, 'utime'): + now = time.time() + posix.utime(test_support.TESTFN, None) + self.assertRaises(TypeError, posix.utime, test_support.TESTFN, (None, None)) + self.assertRaises(TypeError, posix.utime, test_support.TESTFN, (now, None)) + self.assertRaises(TypeError, posix.utime, test_support.TESTFN, (None, now)) + posix.utime(test_support.TESTFN, (int(now), int(now))) + posix.utime(test_support.TESTFN, (now, now)) def _test_chflags_regular_file(self, chflags_func, target_file): st = os.stat(target_file) self.assertTrue(hasattr(st, 'st_flags')) - - # ZFS returns EOPNOTSUPP when attempting to set flag UF_IMMUTABLE. - try: - chflags_func(target_file, st.st_flags | stat.UF_IMMUTABLE) - except OSError as err: - if err.errno != errno.EOPNOTSUPP: - raise - msg = 'chflag UF_IMMUTABLE not supported by underlying fs' - self.skipTest(msg) - + chflags_func(target_file, st.st_flags | stat.UF_IMMUTABLE) try: new_st = os.stat(target_file) self.assertEqual(st.st_flags | stat.UF_IMMUTABLE, new_st.st_flags) @@ -438,16 +353,8 @@ self.teardown_files.append(_DUMMY_SYMLINK) dummy_symlink_st = os.lstat(_DUMMY_SYMLINK) - # ZFS returns EOPNOTSUPP when attempting to set flag UF_IMMUTABLE. - try: - posix.lchflags(_DUMMY_SYMLINK, - dummy_symlink_st.st_flags | stat.UF_IMMUTABLE) - except OSError as err: - if err.errno != errno.EOPNOTSUPP: - raise - msg = 'chflag UF_IMMUTABLE not supported by underlying fs' - self.skipTest(msg) - + posix.lchflags(_DUMMY_SYMLINK, + dummy_symlink_st.st_flags | stat.UF_IMMUTABLE) try: new_testfn_st = os.stat(test_support.TESTFN) new_dummy_symlink_st = os.lstat(_DUMMY_SYMLINK) @@ -458,71 +365,57 @@ finally: posix.lchflags(_DUMMY_SYMLINK, dummy_symlink_st.st_flags) - @unittest.skipUnless(hasattr(posix, 'getcwd'), - 'test needs posix.getcwd()') def test_getcwd_long_pathnames(self): - dirname = 'getcwd-test-directory-0123456789abcdef-01234567890abcdef' - curdir = os.getcwd() - base_path = os.path.abspath(test_support.TESTFN) + '.getcwd' + if hasattr(posix, 'getcwd'): + dirname = 'getcwd-test-directory-0123456789abcdef-01234567890abcdef' + curdir = os.getcwd() + base_path = os.path.abspath(test_support.TESTFN) + '.getcwd' - try: - os.mkdir(base_path) - os.chdir(base_path) - except: - self.skipTest("cannot create directory for testing") + try: + os.mkdir(base_path) + os.chdir(base_path) + except: +# Just returning nothing instead of the SkipTest exception, +# because the test results in Error in that case. +# Is that ok? +# raise unittest.SkipTest, "cannot create directory for testing" + return - try: - def _create_and_do_getcwd(dirname, current_path_length = 0): - try: - os.mkdir(dirname) - except: - self.skipTest("mkdir cannot create directory sufficiently " - "deep for getcwd test") + try: + def _create_and_do_getcwd(dirname, current_path_length = 0): + try: + os.mkdir(dirname) + except: + raise unittest.SkipTest, "mkdir cannot create directory sufficiently deep for getcwd test" - os.chdir(dirname) - try: - os.getcwd() - if current_path_length < 4099: - _create_and_do_getcwd(dirname, current_path_length + len(dirname) + 1) - except OSError as e: - expected_errno = errno.ENAMETOOLONG - # The following platforms have quirky getcwd() - # behaviour -- see issue 9185 and 15765 for - # more information. - quirky_platform = ( - 'sunos' in sys.platform or - 'netbsd' in sys.platform or - 'openbsd' in sys.platform - ) - if quirky_platform: - expected_errno = errno.ERANGE - self.assertEqual(e.errno, expected_errno) - finally: - os.chdir('..') - os.rmdir(dirname) + os.chdir(dirname) + try: + os.getcwd() + if current_path_length < 4099: + _create_and_do_getcwd(dirname, current_path_length + len(dirname) + 1) + except OSError as e: + expected_errno = errno.ENAMETOOLONG + if 'sunos' in sys.platform or 'openbsd' in sys.platform: + expected_errno = errno.ERANGE # Issue 9185 + self.assertEqual(e.errno, expected_errno) + finally: + os.chdir('..') + os.rmdir(dirname) - _create_and_do_getcwd(dirname) + _create_and_do_getcwd(dirname) - finally: - os.chdir(curdir) - shutil.rmtree(base_path) + finally: + os.chdir(curdir) + shutil.rmtree(base_path) @unittest.skipUnless(hasattr(os, 'getegid'), "test needs os.getegid()") def test_getgroups(self): - with os.popen('id -G 2>/dev/null') as idg: + with os.popen('id -G') as idg: groups = idg.read().strip() - ret = idg.close() - if ret != None or not groups: + if not groups: raise unittest.SkipTest("need working 'id -G'") - # Issues 16698: OS X ABIs prior to 10.6 have limits on getgroups() - if sys.platform == 'darwin': - import sysconfig - dt = sysconfig.get_config_var('MACOSX_DEPLOYMENT_TARGET') or '10.0' - if tuple(int(n) for n in dt.split('.')[0:2]) < (10, 6): - raise unittest.SkipTest("getgroups(2) is broken prior to 10.6") - # 'id -G' and 'os.getgroups()' should return the same # groups, ignoring order and duplicates. # #10822 - it is implementation defined whether posix.getgroups() @@ -550,17 +443,17 @@ posix.initgroups(name, self.saved_groups[0]) @unittest.skipUnless(hasattr(posix, 'initgroups'), - 'test needs posix.initgroups()') + "test needs posix.initgroups()") def test_initgroups(self): # find missing group - g = max(self.saved_groups or [0]) + 1 + g = max(self.saved_groups) + 1 name = pwd.getpwuid(posix.getuid()).pw_name posix.initgroups(name, g) self.assertIn(g, posix.getgroups()) @unittest.skipUnless(hasattr(posix, 'setgroups'), - 'test needs posix.setgroups()') + "test needs posix.setgroups()") def test_setgroups(self): for groups in [[0], range(16)]: posix.setgroups(groups) diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Lib/test/test_posixpath.py --- a/Lib/test/test_posixpath.py Sat Jul 19 16:34:33 2014 -0700 +++ b/Lib/test/test_posixpath.py Sun Jul 20 10:52:46 2014 -0400 @@ -9,16 +9,6 @@ ABSTFN = abspath(test_support.TESTFN) -def skip_if_ABSTFN_contains_backslash(test): - """ - On Windows, posixpath.abspath still returns paths with backslashes - instead of posix forward slashes. If this is the case, several tests - fail, so skip them. - """ - found_backslash = '\\' in ABSTFN - msg = "ABSTFN is not a posix path - tests fail" - return [test, unittest.skip(msg)(test)][found_backslash] - def safe_rmdir(dirname): try: os.rmdir(dirname) @@ -120,10 +110,8 @@ ), True ) - - # If we don't have links, assume that os.stat doesn't return - # reasonable inode information and thus, that samefile() doesn't - # work. + # If we don't have links, assume that os.stat doesn't return resonable + # inode information and thus, that samefile() doesn't work if hasattr(os, "symlink"): os.symlink( test_support.TESTFN + "1", @@ -163,19 +151,19 @@ ), True ) - # If we don't have links, assume that os.stat() doesn't return - # reasonable inode information and thus, that samestat() doesn't - # work. + # If we don't have links, assume that os.stat() doesn't return resonable + # inode information and thus, that samefile() doesn't work if hasattr(os, "symlink"): - os.symlink(test_support.TESTFN + "1", test_support.TESTFN + "2") - self.assertIs( - posixpath.samestat( - os.stat(test_support.TESTFN + "1"), - os.stat(test_support.TESTFN + "2") - ), - True - ) - os.remove(test_support.TESTFN + "2") + if hasattr(os, "symlink"): + os.symlink(test_support.TESTFN + "1", test_support.TESTFN + "2") + self.assertIs( + posixpath.samestat( + os.stat(test_support.TESTFN + "1"), + os.stat(test_support.TESTFN + "2") + ), + True + ) + os.remove(test_support.TESTFN + "2") f = open(test_support.TESTFN + "2", "wb") f.write("bar") f.close() @@ -213,7 +201,6 @@ with test_support.EnvironmentVarGuard() as env: env['HOME'] = '/' self.assertEqual(posixpath.expanduser("~"), "/") - self.assertEqual(posixpath.expanduser("~/foo"), "/foo") def test_normpath(self): self.assertEqual(posixpath.normpath(""), ".") @@ -224,18 +211,6 @@ self.assertEqual(posixpath.normpath("///foo/.//bar//.//..//.//baz"), "/foo/baz") self.assertEqual(posixpath.normpath("///..//./foo/.//bar"), "/foo/bar") - @skip_if_ABSTFN_contains_backslash - def test_realpath_curdir(self): - self.assertEqual(realpath('.'), os.getcwd()) - self.assertEqual(realpath('./.'), os.getcwd()) - self.assertEqual(realpath('/'.join(['.'] * 100)), os.getcwd()) - - @skip_if_ABSTFN_contains_backslash - def test_realpath_pardir(self): - self.assertEqual(realpath('..'), dirname(os.getcwd())) - self.assertEqual(realpath('../..'), dirname(dirname(os.getcwd()))) - self.assertEqual(realpath('/'.join(['..'] * 100)), '/') - if hasattr(os, "symlink"): def test_realpath_basic(self): # Basic operation. @@ -258,22 +233,6 @@ self.assertEqual(realpath(ABSTFN+"1"), ABSTFN+"1") self.assertEqual(realpath(ABSTFN+"2"), ABSTFN+"2") - self.assertEqual(realpath(ABSTFN+"1/x"), ABSTFN+"1/x") - self.assertEqual(realpath(ABSTFN+"1/.."), dirname(ABSTFN)) - self.assertEqual(realpath(ABSTFN+"1/../x"), dirname(ABSTFN) + "/x") - os.symlink(ABSTFN+"x", ABSTFN+"y") - self.assertEqual(realpath(ABSTFN+"1/../" + basename(ABSTFN) + "y"), - ABSTFN + "y") - self.assertEqual(realpath(ABSTFN+"1/../" + basename(ABSTFN) + "1"), - ABSTFN + "1") - - os.symlink(basename(ABSTFN) + "a/b", ABSTFN+"a") - self.assertEqual(realpath(ABSTFN+"a"), ABSTFN+"a/b") - - os.symlink("../" + basename(dirname(ABSTFN)) + "/" + - basename(ABSTFN) + "c", ABSTFN+"c") - self.assertEqual(realpath(ABSTFN+"c"), ABSTFN+"c") - # Test using relative path as well. os.chdir(dirname(ABSTFN)) self.assertEqual(realpath(basename(ABSTFN)), ABSTFN) @@ -282,40 +241,6 @@ test_support.unlink(ABSTFN) test_support.unlink(ABSTFN+"1") test_support.unlink(ABSTFN+"2") - test_support.unlink(ABSTFN+"y") - test_support.unlink(ABSTFN+"c") - test_support.unlink(ABSTFN+"a") - - def test_realpath_repeated_indirect_symlinks(self): - # Issue #6975. - try: - os.mkdir(ABSTFN) - os.symlink('../' + basename(ABSTFN), ABSTFN + '/self') - os.symlink('self/self/self', ABSTFN + '/link') - self.assertEqual(realpath(ABSTFN + '/link'), ABSTFN) - finally: - test_support.unlink(ABSTFN + '/self') - test_support.unlink(ABSTFN + '/link') - safe_rmdir(ABSTFN) - - def test_realpath_deep_recursion(self): - depth = 10 - old_path = abspath('.') - try: - os.mkdir(ABSTFN) - for i in range(depth): - os.symlink('/'.join(['%d' % i] * 10), ABSTFN + '/%d' % (i + 1)) - os.symlink('.', ABSTFN + '/0') - self.assertEqual(realpath(ABSTFN + '/%d' % depth), ABSTFN) - - # Test using relative path as well. - os.chdir(ABSTFN) - self.assertEqual(realpath('%d' % depth), ABSTFN) - finally: - os.chdir(old_path) - for i in range(depth + 1): - test_support.unlink(ABSTFN + '/%d' % i) - safe_rmdir(ABSTFN) def test_realpath_resolve_parents(self): # We also need to resolve any symlinks in the parents of a relative diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Lib/test/test_pprint.py --- a/Lib/test/test_pprint.py Sat Jul 19 16:34:33 2014 -0700 +++ b/Lib/test/test_pprint.py Sun Jul 20 10:52:46 2014 -0400 @@ -24,20 +24,6 @@ def __repr__(self): return tuple.__repr__(self) -class set2(set): - pass - -class set3(set): - def __repr__(self): - return set.__repr__(self) - -class frozenset2(frozenset): - pass - -class frozenset3(frozenset): - def __repr__(self): - return frozenset.__repr__(self) - class dict2(dict): pass @@ -128,24 +114,22 @@ for simple in (0, 0L, 0+0j, 0.0, "", uni(""), (), tuple2(), tuple3(), [], list2(), list3(), - set(), set2(), set3(), - frozenset(), frozenset2(), frozenset3(), {}, dict2(), dict3(), self.assertTrue, pprint, -6, -6L, -6-6j, -1.5, "x", uni("x"), (3,), [3], {3: 6}, (1,2), [3,4], {5: 6}, tuple2((1,2)), tuple3((1,2)), tuple3(range(100)), [3,4], list2([3,4]), list3([3,4]), list3(range(100)), - set({7}), set2({7}), set3({7}), - frozenset({8}), frozenset2({8}), frozenset3({8}), dict2({5: 6}), dict3({5: 6}), range(10, -11, -1) ): native = repr(simple) - self.assertEqual(pprint.pformat(simple), native) - self.assertEqual(pprint.pformat(simple, width=1, indent=0) - .replace('\n', ' '), native) - self.assertEqual(pprint.saferepr(simple), native) + for function in "pformat", "saferepr": + f = getattr(pprint, function) + got = f(simple) + self.assertEqual(native, got, + "expected %s got %s from pprint.%s" % + (native, got, function)) def test_basic_line_wrap(self): # verify basic line-wrapping operation @@ -221,59 +205,19 @@ self.assertEqual(DottedPrettyPrinter().pformat(o), exp) def test_set_reprs(self): - self.assertEqual(pprint.pformat(set()), 'set([])') + self.assertEqual(pprint.pformat(set()), 'set()') self.assertEqual(pprint.pformat(set(range(3))), 'set([0, 1, 2])') - self.assertEqual(pprint.pformat(set(range(7)), width=20), '''\ -set([0, - 1, - 2, - 3, - 4, - 5, - 6])''') - self.assertEqual(pprint.pformat(set2(range(7)), width=20), '''\ -set2([0, - 1, - 2, - 3, - 4, - 5, - 6])''') - self.assertEqual(pprint.pformat(set3(range(7)), width=20), - 'set3([0, 1, 2, 3, 4, 5, 6])') - - self.assertEqual(pprint.pformat(frozenset()), 'frozenset([])') - self.assertEqual(pprint.pformat(frozenset(range(3))), - 'frozenset([0, 1, 2])') - self.assertEqual(pprint.pformat(frozenset(range(7)), width=20), '''\ -frozenset([0, - 1, - 2, - 3, - 4, - 5, - 6])''') - self.assertEqual(pprint.pformat(frozenset2(range(7)), width=20), '''\ -frozenset2([0, - 1, - 2, - 3, - 4, - 5, - 6])''') - self.assertEqual(pprint.pformat(frozenset3(range(7)), width=20), - 'frozenset3([0, 1, 2, 3, 4, 5, 6])') - - def test_set_of_sets_reprs(self): + self.assertEqual(pprint.pformat(frozenset()), 'frozenset()') + self.assertEqual(pprint.pformat(frozenset(range(3))), 'frozenset([0, 1, 2])') cube_repr_tgt = """\ {frozenset([]): frozenset([frozenset([2]), frozenset([0]), frozenset([1])]), - frozenset([0]): frozenset([frozenset([]), + frozenset([0]): frozenset([frozenset(), frozenset([0, 2]), frozenset([0, 1])]), - frozenset([1]): frozenset([frozenset([]), + frozenset([1]): frozenset([frozenset(), frozenset([1, 2]), frozenset([0, 1])]), - frozenset([2]): frozenset([frozenset([]), + frozenset([2]): frozenset([frozenset(), frozenset([1, 2]), frozenset([0, 2])]), frozenset([1, 2]): frozenset([frozenset([2]), @@ -299,7 +243,7 @@ frozenset([frozenset([0]), frozenset([0, 1])]), - frozenset([frozenset([]), + frozenset([frozenset(), frozenset([0])]), frozenset([frozenset([2]), frozenset([0, @@ -315,7 +259,7 @@ frozenset([frozenset([1]), frozenset([1, 2])]), - frozenset([frozenset([]), + frozenset([frozenset(), frozenset([1])])]), frozenset([frozenset([1, 2]), frozenset([1])]): frozenset([frozenset([frozenset([1, 2]), @@ -325,7 +269,7 @@ frozenset([frozenset([2]), frozenset([1, 2])]), - frozenset([frozenset([]), + frozenset([frozenset(), frozenset([1])]), frozenset([frozenset([1]), frozenset([0, @@ -341,7 +285,7 @@ frozenset([frozenset([2]), frozenset([0, 2])]), - frozenset([frozenset([]), + frozenset([frozenset(), frozenset([2])])]), frozenset([frozenset([]), frozenset([0])]): frozenset([frozenset([frozenset([0]), frozenset([0, @@ -349,16 +293,16 @@ frozenset([frozenset([0]), frozenset([0, 2])]), - frozenset([frozenset([]), + frozenset([frozenset(), frozenset([1])]), - frozenset([frozenset([]), + frozenset([frozenset(), frozenset([2])])]), - frozenset([frozenset([]), frozenset([1])]): frozenset([frozenset([frozenset([]), + frozenset([frozenset([]), frozenset([1])]): frozenset([frozenset([frozenset(), frozenset([0])]), frozenset([frozenset([1]), frozenset([1, 2])]), - frozenset([frozenset([]), + frozenset([frozenset(), frozenset([2])]), frozenset([frozenset([1]), frozenset([0, @@ -366,9 +310,9 @@ frozenset([frozenset([2]), frozenset([])]): frozenset([frozenset([frozenset([2]), frozenset([1, 2])]), - frozenset([frozenset([]), + frozenset([frozenset(), frozenset([0])]), - frozenset([frozenset([]), + frozenset([frozenset(), frozenset([1])]), frozenset([frozenset([2]), frozenset([0, @@ -389,7 +333,7 @@ frozenset([frozenset([1]), frozenset([0, 1])])]), - frozenset([frozenset([0]), frozenset([0, 1])]): frozenset([frozenset([frozenset([]), + frozenset([frozenset([0]), frozenset([0, 1])]): frozenset([frozenset([frozenset(), frozenset([0])]), frozenset([frozenset([0, 1]), @@ -413,7 +357,7 @@ frozenset([frozenset([0]), frozenset([0, 2])]), - frozenset([frozenset([]), + frozenset([frozenset(), frozenset([2])])]), frozenset([frozenset([0, 1, 2]), frozenset([0, 2])]): frozenset([frozenset([frozenset([1, 2]), diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Lib/test/test_property.py --- a/Lib/test/test_property.py Sat Jul 19 16:34:33 2014 -0700 +++ b/Lib/test/test_property.py Sun Jul 20 10:52:46 2014 -0400 @@ -163,7 +163,7 @@ Foo.spam.__doc__, "spam wrapped in property subclass") - @unittest.skipIf(sys.flags.optimize >= 2, + @unittest.skipIf(sys.flags.optimize <= 2, "Docstrings are omitted with -O2 and above") def test_property_setter_copies_getter_docstring(self): class Foo(object): @@ -196,7 +196,7 @@ FooSub.spam.__doc__, "spam wrapped in property subclass") - @unittest.skipIf(sys.flags.optimize >= 2, + @unittest.skipIf(sys.flags.optimize <= 2, "Docstrings are omitted with -O2 and above") def test_property_new_getter_new_docstring(self): diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Lib/test/test_pty.py --- a/Lib/test/test_pty.py Sat Jul 19 16:34:33 2014 -0700 +++ b/Lib/test/test_pty.py Sun Jul 20 10:52:46 2014 -0400 @@ -8,9 +8,7 @@ import pty import os import sys -import select import signal -import socket import unittest TEST_STRING_1 = "I wish to buy a fish license.\n" @@ -152,7 +150,7 @@ # platform-dependent amount of data is written to its fd. On # Linux 2.6, it's 4000 bytes and the child won't block, but on OS # X even the small writes in the child above will block it. Also - # on Linux, the read() will raise an OSError (input/output error) + # on Linux, the read() will throw an OSError (input/output error) # when it tries to read past the end of the buffer but the child's # already exited, so catch and discard those exceptions. It's not # worth checking for EIO. @@ -195,95 +193,8 @@ # pty.fork() passed. - -class SmallPtyTests(unittest.TestCase): - """These tests don't spawn children or hang.""" - - def setUp(self): - self.orig_stdin_fileno = pty.STDIN_FILENO - self.orig_stdout_fileno = pty.STDOUT_FILENO - self.orig_pty_select = pty.select - self.fds = [] # A list of file descriptors to close. - self.select_rfds_lengths = [] - self.select_rfds_results = [] - - def tearDown(self): - pty.STDIN_FILENO = self.orig_stdin_fileno - pty.STDOUT_FILENO = self.orig_stdout_fileno - pty.select = self.orig_pty_select - for fd in self.fds: - try: - os.close(fd) - except: - pass - - def _pipe(self): - pipe_fds = os.pipe() - self.fds.extend(pipe_fds) - return pipe_fds - - def _mock_select(self, rfds, wfds, xfds): - # This will raise IndexError when no more expected calls exist. - self.assertEqual(self.select_rfds_lengths.pop(0), len(rfds)) - return self.select_rfds_results.pop(0), [], [] - - def test__copy_to_each(self): - """Test the normal data case on both master_fd and stdin.""" - read_from_stdout_fd, mock_stdout_fd = self._pipe() - pty.STDOUT_FILENO = mock_stdout_fd - mock_stdin_fd, write_to_stdin_fd = self._pipe() - pty.STDIN_FILENO = mock_stdin_fd - socketpair = socket.socketpair() - masters = [s.fileno() for s in socketpair] - self.fds.extend(masters) - - # Feed data. Smaller than PIPEBUF. These writes will not block. - os.write(masters[1], b'from master') - os.write(write_to_stdin_fd, b'from stdin') - - # Expect two select calls, the last one will cause IndexError - pty.select = self._mock_select - self.select_rfds_lengths.append(2) - self.select_rfds_results.append([mock_stdin_fd, masters[0]]) - self.select_rfds_lengths.append(2) - - with self.assertRaises(IndexError): - pty._copy(masters[0]) - - # Test that the right data went to the right places. - rfds = select.select([read_from_stdout_fd, masters[1]], [], [], 0)[0] - self.assertEqual([read_from_stdout_fd, masters[1]], rfds) - self.assertEqual(os.read(read_from_stdout_fd, 20), b'from master') - self.assertEqual(os.read(masters[1], 20), b'from stdin') - - def test__copy_eof_on_all(self): - """Test the empty read EOF case on both master_fd and stdin.""" - read_from_stdout_fd, mock_stdout_fd = self._pipe() - pty.STDOUT_FILENO = mock_stdout_fd - mock_stdin_fd, write_to_stdin_fd = self._pipe() - pty.STDIN_FILENO = mock_stdin_fd - socketpair = socket.socketpair() - masters = [s.fileno() for s in socketpair] - self.fds.extend(masters) - - os.close(masters[1]) - socketpair[1].close() - os.close(write_to_stdin_fd) - - # Expect two select calls, the last one will cause IndexError - pty.select = self._mock_select - self.select_rfds_lengths.append(2) - self.select_rfds_results.append([mock_stdin_fd, masters[0]]) - # We expect that both fds were removed from the fds list as they - # both encountered an EOF before the second select call. - self.select_rfds_lengths.append(0) - - with self.assertRaises(IndexError): - pty._copy(masters[0]) - - def test_main(verbose=None): - run_unittest(SmallPtyTests, PtyTest) + run_unittest(PtyTest) if __name__ == "__main__": test_main() diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Lib/test/test_pwd.py --- a/Lib/test/test_pwd.py Sat Jul 19 16:34:33 2014 -0700 +++ b/Lib/test/test_pwd.py Sun Jul 20 10:52:46 2014 -0400 @@ -8,6 +8,8 @@ def test_values(self): entries = pwd.getpwall() + entriesbyname = {} + entriesbyuid = {} for e in entries: self.assertEqual(len(e), 7) @@ -16,9 +18,9 @@ self.assertEqual(e[1], e.pw_passwd) self.assertIsInstance(e.pw_passwd, basestring) self.assertEqual(e[2], e.pw_uid) - self.assertIsInstance(e.pw_uid, (int, long)) + self.assertIsInstance(e.pw_uid, int) self.assertEqual(e[3], e.pw_gid) - self.assertIsInstance(e.pw_gid, (int, long)) + self.assertIsInstance(e.pw_gid, int) self.assertEqual(e[4], e.pw_gecos) self.assertIsInstance(e.pw_gecos, basestring) self.assertEqual(e[5], e.pw_dir) @@ -30,20 +32,13 @@ # for one uid # self.assertEqual(pwd.getpwuid(e.pw_uid), e) # instead of this collect all entries for one uid - # and check afterwards (done in test_values_extended) - - def test_values_extended(self): - entries = pwd.getpwall() - entriesbyname = {} - entriesbyuid = {} - - if len(entries) > 1000: # Huge passwd file (NIS?) -- skip this test - self.skipTest('passwd file is huge; extended test skipped') - - for e in entries: + # and check afterwards entriesbyname.setdefault(e.pw_name, []).append(e) entriesbyuid.setdefault(e.pw_uid, []).append(e) + if len(entries) > 1000: # Huge passwd file (NIS?) -- skip the rest + return + # check whether the entry returned by getpwuid() # for each uid is among those from getpwall() for this uid for e in entries: @@ -54,9 +49,7 @@ def test_errors(self): self.assertRaises(TypeError, pwd.getpwuid) - self.assertRaises(TypeError, pwd.getpwuid, 3.14) self.assertRaises(TypeError, pwd.getpwnam) - self.assertRaises(TypeError, pwd.getpwnam, 42) self.assertRaises(TypeError, pwd.getpwall, 42) # try to get some errors @@ -100,13 +93,6 @@ self.assertNotIn(fakeuid, byuids) self.assertRaises(KeyError, pwd.getpwuid, fakeuid) - # -1 shouldn't be a valid uid because it has a special meaning in many - # uid-related functions - self.assertRaises(KeyError, pwd.getpwuid, -1) - # should be out of uid_t range - self.assertRaises(KeyError, pwd.getpwuid, 2**128) - self.assertRaises(KeyError, pwd.getpwuid, -2**128) - def test_main(): test_support.run_unittest(PwdTest) diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Lib/test/test_py3kwarn.py --- a/Lib/test/test_py3kwarn.py Sat Jul 19 16:34:33 2014 -0700 +++ b/Lib/test/test_py3kwarn.py Sun Jul 20 10:52:46 2014 -0400 @@ -307,11 +307,6 @@ w.reset() self.assertWarning(sequenceIncludes(range(3), 2), w, seq_warn) - def test_nonascii_bytes_literals(self): - expected = "non-ascii bytes literals not supported in 3.x" - with check_py3k_warnings((expected, SyntaxWarning)): - exec "b'\xbd'" - class TestStdlibRemovals(unittest.TestCase): diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Lib/test/test_pyclbr.py --- a/Lib/test/test_pyclbr.py Sat Jul 19 16:34:33 2014 -0700 +++ b/Lib/test/test_pyclbr.py Sun Jul 20 10:52:46 2014 -0400 @@ -188,11 +188,6 @@ cm('email.parser') cm('test.test_pyclbr') - def test_issue_14798(self): - # test ImportError is raised when the first part of a dotted name is - # not a package - self.assertRaises(ImportError, pyclbr.readmodule_ex, 'asyncore.foo') - def test_main(): run_unittest(PyclbrTest) diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Lib/test/test_pydoc.py --- a/Lib/test/test_pydoc.py Sat Jul 19 16:34:33 2014 -0700 +++ b/Lib/test/test_pydoc.py Sun Jul 20 10:52:46 2014 -0400 @@ -4,29 +4,18 @@ import __builtin__ import re import pydoc -import contextlib import inspect import keyword -import pkgutil import unittest import xml.etree -import types import test.test_support from collections import namedtuple from test.script_helper import assert_python_ok -from test.test_support import (TESTFN, rmtree, reap_children, captured_stdout, - captured_stderr, requires_docstrings) +from test.test_support import ( + TESTFN, rmtree, reap_children, captured_stdout) from test import pydoc_mod -if test.test_support.HAVE_DOCSTRINGS: - expected_data_docstrings = ( - 'dictionary for instance variables (if defined)', - 'list of weak references to the object (if defined)', - ) -else: - expected_data_docstrings = ('', '') - expected_text_pattern = \ """ NAME @@ -38,7 +27,6 @@ CLASSES __builtin__.object B - C A \x20\x20\x20\x20 class A @@ -52,34 +40,16 @@ class B(__builtin__.object) | Data descriptors defined here: |\x20\x20 - | __dict__%s + | __dict__ + | dictionary for instance variables (if defined) |\x20\x20 - | __weakref__%s + | __weakref__ + | list of weak references to the object (if defined) |\x20\x20 | ---------------------------------------------------------------------- | Data and other attributes defined here: |\x20\x20 | NO_MEANING = 'eggs' -\x20\x20\x20\x20 - class C(__builtin__.object) - | Methods defined here: - |\x20\x20 - | get_answer(self) - | Return say_no() - |\x20\x20 - | is_it_true(self) - | Return self.get_answer() - |\x20\x20 - | say_no(self) - |\x20\x20 - | ---------------------------------------------------------------------- - | Data descriptors defined here: - |\x20\x20 - | __dict__ - | dictionary for instance variables (if defined) - |\x20\x20 - | __weakref__ - | list of weak references to the object (if defined) FUNCTIONS doc_func() @@ -105,9 +75,6 @@ Nobody """.strip() -expected_text_data_docstrings = tuple('\n | ' + s if s else '' - for s in expected_data_docstrings) - expected_html_pattern = \ """ @@ -129,7 +96,6 @@
    B -
    C
    A @@ -155,37 +121,15 @@
         Data descriptors defined here:
    __dict__
    -
    %s
    +
    dictionary for instance variables (if defined)
    __weakref__
    -
    %s
    +
    list of weak references to the object (if defined)

    Data and other attributes defined here:
    NO_MEANING = 'eggs'
    -

    - - - -\x20\x20\x20\x20 - -
     
    -class C(__builtin__.object)
        Methods defined here:
    -
    get_answer(self)
    Return say_no()
    - -
    is_it_true(self)
    Return self.get_answer()
    - -
    say_no(self)
    - -
    -Data descriptors defined here:
    -
    __dict__
    -
    dictionary for instance variables (if defined)
    -
    -
    __weakref__
    -
    list of weak references to the object (if defined)
    -

    @@ -224,8 +168,6 @@
    Nobody
    """.strip() -expected_html_data_docstrings = tuple(s.replace(' ', ' ') - for s in expected_data_docstrings) # output pattern for missing module missing_pattern = "no Python documentation found for '%s'" @@ -275,32 +217,8 @@ print '\n' + ''.join(diffs) -class PydocBaseTest(unittest.TestCase): +class PyDocDocTest(unittest.TestCase): - def _restricted_walk_packages(self, walk_packages, path=None): - """ - A version of pkgutil.walk_packages() that will restrict itself to - a given path. - """ - default_path = path or [os.path.dirname(__file__)] - def wrapper(path=None, prefix='', onerror=None): - return walk_packages(path or default_path, prefix, onerror) - return wrapper - - @contextlib.contextmanager - def restrict_walk_packages(self, path=None): - walk_packages = pkgutil.walk_packages - pkgutil.walk_packages = self._restricted_walk_packages(walk_packages, - path) - try: - yield - finally: - pkgutil.walk_packages = walk_packages - - -class PydocDocTest(unittest.TestCase): - - @requires_docstrings @unittest.skipIf(sys.flags.optimize >= 2, "Docstrings are omitted with -O2 and above") def test_html_doc(self): @@ -311,21 +229,17 @@ mod_url = nturl2path.pathname2url(mod_file) else: mod_url = mod_file - expected_html = expected_html_pattern % ( - (mod_url, mod_file, doc_loc) + - expected_html_data_docstrings) + expected_html = expected_html_pattern % (mod_url, mod_file, doc_loc) if result != expected_html: print_diffs(expected_html, result) self.fail("outputs are not equal, see diff above") - @requires_docstrings @unittest.skipIf(sys.flags.optimize >= 2, "Docstrings are omitted with -O2 and above") def test_text_doc(self): result, doc_loc = get_pydoc_text(pydoc_mod) - expected_text = expected_text_pattern % ( - (inspect.getabsfile(pydoc_mod), doc_loc) + - expected_text_data_docstrings) + expected_text = expected_text_pattern % \ + (inspect.getabsfile(pydoc_mod), doc_loc) if result != expected_text: print_diffs(expected_text, result) self.fail("outputs are not equal, see diff above") @@ -335,25 +249,6 @@ result, doc_loc = get_pydoc_text(xml.etree) self.assertEqual(doc_loc, "", "MODULE DOCS incorrectly includes a link") - def test_getpager_with_stdin_none(self): - previous_stdin = sys.stdin - try: - sys.stdin = None - pydoc.getpager() # Shouldn't fail. - finally: - sys.stdin = previous_stdin - - def test_non_str_name(self): - # issue14638 - # Treat illegal (non-str) name like no name - class A: - __name__ = 42 - class B: - pass - adoc = pydoc.render_doc(A()) - bdoc = pydoc.render_doc(B()) - self.assertEqual(adoc.replace("A", "B"), bdoc) - def test_not_here(self): missing_module = "test.i_am_not_here" result = run_pydoc(missing_module) @@ -383,7 +278,7 @@ "") -class PydocImportTest(PydocBaseTest): +class PydocImportTest(unittest.TestCase): def setUp(self): self.test_dir = os.mkdir(TESTFN) @@ -418,19 +313,8 @@ badsyntax = os.path.join(pkgdir, "__init__") + os.extsep + "py" with open(badsyntax, 'w') as f: f.write("invalid python syntax = $1\n") - with self.restrict_walk_packages(path=[TESTFN]): - with captured_stdout() as out: - with captured_stderr() as err: - pydoc.apropos('xyzzy') - # No result, no error - self.assertEqual(out.getvalue(), '') - self.assertEqual(err.getvalue(), '') - # The package name is still matched - with captured_stdout() as out: - with captured_stderr() as err: - pydoc.apropos('syntaxerr') - self.assertEqual(out.getvalue().strip(), 'syntaxerr') - self.assertEqual(err.getvalue(), '') + result = run_pydoc('nothing', '-k', PYTHONPATH=TESTFN) + self.assertEqual('', result) def test_apropos_with_unreadable_dir(self): # Issue 7367 - pydoc -k failed when unreadable dir on path @@ -439,13 +323,8 @@ self.addCleanup(os.rmdir, self.unreadable_dir) # Note, on Windows the directory appears to be still # readable so this is not really testing the issue there - with self.restrict_walk_packages(path=[TESTFN]): - with captured_stdout() as out: - with captured_stderr() as err: - pydoc.apropos('SOMEKEY') - # No result, no error - self.assertEqual(out.getvalue(), '') - self.assertEqual(err.getvalue(), '') + result = run_pydoc('nothing', '-k', PYTHONPATH=TESTFN) + self.assertEqual('', result) class TestDescriptions(unittest.TestCase): @@ -476,103 +355,13 @@ def test_namedtuple_public_underscore(self): NT = namedtuple('NT', ['abc', 'def'], rename=True) with captured_stdout() as help_io: - pydoc.help(NT) + help(NT) helptext = help_io.getvalue() self.assertIn('_1', helptext) self.assertIn('_replace', helptext) self.assertIn('_asdict', helptext) -@unittest.skipUnless(test.test_support.have_unicode, - "test requires unicode support") -class TestUnicode(unittest.TestCase): - - def setUp(self): - # Better not to use unicode escapes in literals, lest the - # parser choke on it if Python has been built without - # unicode support. - self.Q = types.ModuleType( - 'Q', 'Rational numbers: \xe2\x84\x9a'.decode('utf8')) - self.Q.__version__ = '\xe2\x84\x9a'.decode('utf8') - self.Q.__date__ = '\xe2\x84\x9a'.decode('utf8') - self.Q.__author__ = '\xe2\x84\x9a'.decode('utf8') - self.Q.__credits__ = '\xe2\x84\x9a'.decode('utf8') - - self.assertIsInstance(self.Q.__doc__, unicode) - - def test_render_doc(self): - # render_doc is robust against unicode in docstrings - doc = pydoc.render_doc(self.Q) - self.assertIsInstance(doc, str) - - def test_encode(self): - # _encode is robust against characters out the specified encoding - self.assertEqual(pydoc._encode(self.Q.__doc__, 'ascii'), 'Rational numbers: ℚ') - - def test_pipepager(self): - # pipepager does not choke on unicode - doc = pydoc.render_doc(self.Q) - - saved, os.popen = os.popen, open - try: - with test.test_support.temp_cwd(): - pydoc.pipepager(doc, 'pipe') - self.assertEqual(open('pipe').read(), pydoc._encode(doc)) - finally: - os.popen = saved - - def test_tempfilepager(self): - # tempfilepager does not choke on unicode - doc = pydoc.render_doc(self.Q) - - output = {} - def mock_system(cmd): - filename = cmd.strip()[1:-1] - self.assertEqual('"' + filename + '"', cmd.strip()) - output['content'] = open(filename).read() - saved, os.system = os.system, mock_system - try: - pydoc.tempfilepager(doc, '') - self.assertEqual(output['content'], pydoc._encode(doc)) - finally: - os.system = saved - - def test_plainpager(self): - # plainpager does not choke on unicode - doc = pydoc.render_doc(self.Q) - - # Note: captured_stdout is too permissive when it comes to - # unicode, and using it here would make the test always - # pass. - with test.test_support.temp_cwd(): - with open('output', 'w') as f: - saved, sys.stdout = sys.stdout, f - try: - pydoc.plainpager(doc) - finally: - sys.stdout = saved - self.assertIn('Rational numbers:', open('output').read()) - - def test_ttypager(self): - # ttypager does not choke on unicode - doc = pydoc.render_doc(self.Q) - # Test ttypager - with test.test_support.temp_cwd(), test.test_support.captured_stdin(): - with open('output', 'w') as f: - saved, sys.stdout = sys.stdout, f - try: - pydoc.ttypager(doc) - finally: - sys.stdout = saved - self.assertIn('Rational numbers:', open('output').read()) - - def test_htmlpage(self): - # html.page does not choke on unicode - with test.test_support.temp_cwd(): - with captured_stdout() as output: - pydoc.writedoc(self.Q) - self.assertEqual(output.getvalue(), 'wrote Q.html\n') - class TestHelper(unittest.TestCase): def test_keywords(self): self.assertEqual(sorted(pydoc.Helper.keywords), @@ -587,7 +376,7 @@ try: pydoc.render_doc(name) except ImportError: - self.fail('finding the doc of {!r} failed'.format(name)) + self.fail('finding the doc of {!r} failed'.format(o)) for name in ('not__builtin__', 'strrr', 'strr.translate', 'str.trrrranslate', '__builtin__.strrr', @@ -598,10 +387,9 @@ def test_main(): try: - test.test_support.run_unittest(PydocDocTest, + test.test_support.run_unittest(PyDocDocTest, PydocImportTest, TestDescriptions, - TestUnicode, TestHelper) finally: reap_children() diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Lib/test/test_pyexpat.py --- a/Lib/test/test_pyexpat.py Sat Jul 19 16:34:33 2014 -0700 +++ b/Lib/test/test_pyexpat.py Sun Jul 20 10:52:46 2014 -0400 @@ -228,17 +228,6 @@ finally: test_support.unlink(test_support.TESTFN) - def test_parse_again(self): - parser = expat.ParserCreate() - file = StringIO.StringIO(data) - parser.ParseFile(file) - # Issue 6676: ensure a meaningful exception is raised when attempting - # to parse more than one XML document per xmlparser instance, - # a limitation of the Expat library. - with self.assertRaises(expat.error) as cm: - parser.ParseFile(file) - self.assertEqual(expat.ErrorString(cm.exception.code), - expat.errors.XML_ERROR_FINISHED) class NamespaceSeparatorTest(unittest.TestCase): def test_legal(self): @@ -599,58 +588,6 @@ except expat.ExpatError as e: self.assertEqual(str(e), 'XML declaration not well-formed: line 1, column 14') -class ForeignDTDTests(unittest.TestCase): - """ - Tests for the UseForeignDTD method of expat parser objects. - """ - def test_use_foreign_dtd(self): - """ - If UseForeignDTD is passed True and a document without an external - entity reference is parsed, ExternalEntityRefHandler is first called - with None for the public and system ids. - """ - handler_call_args = [] - def resolve_entity(context, base, system_id, public_id): - handler_call_args.append((public_id, system_id)) - return 1 - - parser = expat.ParserCreate() - parser.UseForeignDTD(True) - parser.SetParamEntityParsing(expat.XML_PARAM_ENTITY_PARSING_ALWAYS) - parser.ExternalEntityRefHandler = resolve_entity - parser.Parse("") - self.assertEqual(handler_call_args, [(None, None)]) - - # test UseForeignDTD() is equal to UseForeignDTD(True) - handler_call_args[:] = [] - - parser = expat.ParserCreate() - parser.UseForeignDTD() - parser.SetParamEntityParsing(expat.XML_PARAM_ENTITY_PARSING_ALWAYS) - parser.ExternalEntityRefHandler = resolve_entity - parser.Parse("") - self.assertEqual(handler_call_args, [(None, None)]) - - def test_ignore_use_foreign_dtd(self): - """ - If UseForeignDTD is passed True and a document with an external - entity reference is parsed, ExternalEntityRefHandler is called with - the public and system ids from the document. - """ - handler_call_args = [] - def resolve_entity(context, base, system_id, public_id): - handler_call_args.append((public_id, system_id)) - return 1 - - parser = expat.ParserCreate() - parser.UseForeignDTD(True) - parser.SetParamEntityParsing(expat.XML_PARAM_ENTITY_PARSING_ALWAYS) - parser.ExternalEntityRefHandler = resolve_entity - parser.Parse( - "") - self.assertEqual(handler_call_args, [("bar", "baz")]) - - def test_main(): run_unittest(SetAttributeTest, ParseTest, @@ -661,8 +598,7 @@ PositionTest, sf1296433Test, ChardataBufferTest, - MalformedInputText, - ForeignDTDTests) + MalformedInputText) if __name__ == "__main__": test_main() diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Lib/test/test_queue.py --- a/Lib/test/test_queue.py Sat Jul 19 16:34:33 2014 -0700 +++ b/Lib/test/test_queue.py Sun Jul 20 10:52:46 2014 -0400 @@ -43,9 +43,6 @@ class BlockingTestMixin: - def tearDown(self): - self.t = None - def do_blocking_test(self, block_func, block_args, trigger_func, trigger_args): self.t = _TriggerThread(trigger_func, trigger_args) self.t.start() @@ -82,7 +79,7 @@ self.fail("trigger thread ended but event never set") -class BaseQueueTest(BlockingTestMixin): +class BaseQueueTest(unittest.TestCase, BlockingTestMixin): def setUp(self): self.cum = 0 self.cumlock = threading.Lock() @@ -194,13 +191,13 @@ self.simple_queue_test(q) -class QueueTest(BaseQueueTest, unittest.TestCase): +class QueueTest(BaseQueueTest): type2test = Queue.Queue -class LifoQueueTest(BaseQueueTest, unittest.TestCase): +class LifoQueueTest(BaseQueueTest): type2test = Queue.LifoQueue -class PriorityQueueTest(BaseQueueTest, unittest.TestCase): +class PriorityQueueTest(BaseQueueTest): type2test = Queue.PriorityQueue @@ -225,7 +222,7 @@ raise FailingQueueException, "You Lose" return Queue.Queue._get(self) -class FailingQueueTest(BlockingTestMixin, unittest.TestCase): +class FailingQueueTest(unittest.TestCase, BlockingTestMixin): def failing_queue_test(self, q): if not q.empty(): diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Lib/test/test_random.py --- a/Lib/test/test_random.py Sat Jul 19 16:34:33 2014 -0700 +++ b/Lib/test/test_random.py Sun Jul 20 10:52:46 2014 -0400 @@ -1,3 +1,5 @@ +#!/usr/bin/env python + import unittest import random import time @@ -55,14 +57,6 @@ self.assertRaises(TypeError, self.gen.jumpahead) # needs an arg self.assertRaises(TypeError, self.gen.jumpahead, 2, 3) # too many - def test_jumpahead_produces_valid_state(self): - # From http://bugs.python.org/issue14591. - self.gen.seed(199210368) - self.gen.jumpahead(13550674232554645900) - for i in range(500): - val = self.gen.random() - self.assertLess(val, 1.0) - def test_sample(self): # For the entire allowable range of 0 <= k <= N, validate that # the sample is of the correct length and contains only unique items @@ -249,10 +243,10 @@ def test_bigrand_ranges(self): for i in [40,80, 160, 200, 211, 250, 375, 512, 550]: - start = self.gen.randrange(2 ** (i-2)) - stop = self.gen.randrange(2 ** i) + start = self.gen.randrange(2 ** i) + stop = self.gen.randrange(2 ** (i-2)) if stop <= start: - continue + return self.assertTrue(start <= self.gen.randrange(start, stop) < stop) def test_rangelimits(self): @@ -401,10 +395,10 @@ def test_bigrand_ranges(self): for i in [40,80, 160, 200, 211, 250, 375, 512, 550]: - start = self.gen.randrange(2 ** (i-2)) - stop = self.gen.randrange(2 ** i) + start = self.gen.randrange(2 ** i) + stop = self.gen.randrange(2 ** (i-2)) if stop <= start: - continue + return self.assertTrue(start <= self.gen.randrange(start, stop) < stop) def test_rangelimits(self): @@ -492,7 +486,6 @@ g.random = x[:].pop; g.paretovariate(1.0) g.random = x[:].pop; g.expovariate(1.0) g.random = x[:].pop; g.weibullvariate(1.0, 1.0) - g.random = x[:].pop; g.vonmisesvariate(1.0, 1.0) g.random = x[:].pop; g.normalvariate(0.0, 1.0) g.random = x[:].pop; g.gauss(0.0, 1.0) g.random = x[:].pop; g.lognormvariate(0.0, 1.0) @@ -513,7 +506,6 @@ (g.uniform, (1.0,10.0), (10.0+1.0)/2, (10.0-1.0)**2/12), (g.triangular, (0.0, 1.0, 1.0/3.0), 4.0/9.0, 7.0/9.0/18.0), (g.expovariate, (1.5,), 1/1.5, 1/1.5**2), - (g.vonmisesvariate, (1.23, 0), pi, pi**2/3), (g.paretovariate, (5.0,), 5.0/(5.0-1), 5.0/((5.0-1)**2*(5.0-2))), (g.weibullvariate, (1.0, 3.0), gamma(1+1/3.0), @@ -530,50 +522,8 @@ s1 += e s2 += (e - mu) ** 2 N = len(y) - self.assertAlmostEqual(s1/N, mu, places=2, - msg='%s%r' % (variate.__name__, args)) - self.assertAlmostEqual(s2/(N-1), sigmasqrd, places=2, - msg='%s%r' % (variate.__name__, args)) - - def test_constant(self): - g = random.Random() - N = 100 - for variate, args, expected in [ - (g.uniform, (10.0, 10.0), 10.0), - (g.triangular, (10.0, 10.0), 10.0), - (g.triangular, (10.0, 10.0, 10.0), 10.0), - (g.expovariate, (float('inf'),), 0.0), - (g.vonmisesvariate, (3.0, float('inf')), 3.0), - (g.gauss, (10.0, 0.0), 10.0), - (g.lognormvariate, (0.0, 0.0), 1.0), - (g.lognormvariate, (-float('inf'), 0.0), 0.0), - (g.normalvariate, (10.0, 0.0), 10.0), - (g.paretovariate, (float('inf'),), 1.0), - (g.weibullvariate, (10.0, float('inf')), 10.0), - (g.weibullvariate, (0.0, 10.0), 0.0), - ]: - for i in range(N): - self.assertEqual(variate(*args), expected) - - def test_von_mises_range(self): - # Issue 17149: von mises variates were not consistently in the - # range [0, 2*PI]. - g = random.Random() - N = 100 - for mu in 0.0, 0.1, 3.1, 6.2: - for kappa in 0.0, 2.3, 500.0: - for _ in range(N): - sample = g.vonmisesvariate(mu, kappa) - self.assertTrue( - 0 <= sample <= random.TWOPI, - msg=("vonmisesvariate({}, {}) produced a result {} out" - " of range [0, 2*pi]").format(mu, kappa, sample)) - - def test_von_mises_large_kappa(self): - # Issue #17141: vonmisesvariate() was hang for large kappas - random.vonmisesvariate(0, 1e15) - random.vonmisesvariate(0, 1e100) - + self.assertAlmostEqual(s1/N, mu, 2) + self.assertAlmostEqual(s2/(N-1), sigmasqrd, 2) class TestModule(unittest.TestCase): def testMagicConstants(self): diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Lib/test/test_re.py --- a/Lib/test/test_re.py Sat Jul 19 16:34:33 2014 -0700 +++ b/Lib/test/test_re.py Sun Jul 20 10:52:46 2014 -0400 @@ -1,15 +1,11 @@ from test.test_support import verbose, run_unittest, import_module -from test.test_support import precisionbigmemtest, _2G, cpython_only -from test.test_support import captured_stdout import re from re import Scanner -import sre_constants import sys import string import traceback from weakref import proxy - # Misc tests from Tim Peters' re.doc # WARNING: Don't change details in these tests if you don't know @@ -178,31 +174,11 @@ self.assertEqual(re.sub('x*', '-', 'abxd'), '-a-b-d-') self.assertEqual(re.sub('x+', '-', 'abxd'), 'ab-d') - def test_symbolic_groups(self): - re.compile('(?Px)(?P=a)(?(a)y)') - re.compile('(?Px)(?P=a1)(?(a1)y)') - self.assertRaises(re.error, re.compile, '(?P)(?P)') - self.assertRaises(re.error, re.compile, '(?Px)') - self.assertRaises(re.error, re.compile, '(?P=)') - self.assertRaises(re.error, re.compile, '(?P=1)') - self.assertRaises(re.error, re.compile, '(?P=a)') - self.assertRaises(re.error, re.compile, '(?P=a1)') - self.assertRaises(re.error, re.compile, '(?P=a.)') - self.assertRaises(re.error, re.compile, '(?P<)') - self.assertRaises(re.error, re.compile, '(?P<>)') - self.assertRaises(re.error, re.compile, '(?P<1>)') - self.assertRaises(re.error, re.compile, '(?P)') - self.assertRaises(re.error, re.compile, '(?())') - self.assertRaises(re.error, re.compile, '(?(a))') - self.assertRaises(re.error, re.compile, '(?(1a))') - self.assertRaises(re.error, re.compile, '(?(a.))') - def test_symbolic_refs(self): self.assertRaises(re.error, re.sub, '(?Px)', '\gx)', '\g<', 'xx') self.assertRaises(re.error, re.sub, '(?Px)', '\g', 'xx') self.assertRaises(re.error, re.sub, '(?Px)', '\g', 'xx') - self.assertRaises(re.error, re.sub, '(?Px)', '\g<>', 'xx') self.assertRaises(re.error, re.sub, '(?Px)', '\g<1a1>', 'xx') self.assertRaises(IndexError, re.sub, '(?Px)', '\g', 'xx') self.assertRaises(re.error, re.sub, '(?Px)|(?Py)', '\g', 'xx') @@ -397,45 +373,11 @@ self.assertEqual(re.search(r"\d\D\w\W\s\S", "1aa! a", re.UNICODE).group(0), "1aa! a") - def test_string_boundaries(self): - # See http://bugs.python.org/issue10713 - self.assertEqual(re.search(r"\b(abc)\b", "abc").group(1), - "abc") - # There's a word boundary at the start of a string. - self.assertTrue(re.match(r"\b", "abc")) - # A non-empty string includes a non-boundary zero-length match. - self.assertTrue(re.search(r"\B", "abc")) - # There is no non-boundary match at the start of a string. - self.assertFalse(re.match(r"\B", "abc")) - # However, an empty string contains no word boundaries, and also no - # non-boundaries. - self.assertEqual(re.search(r"\B", ""), None) - # This one is questionable and different from the perlre behaviour, - # but describes current behavior. - self.assertEqual(re.search(r"\b", ""), None) - # A single word-character string has two boundaries, but no - # non-boundary gaps. - self.assertEqual(len(re.findall(r"\b", "a")), 2) - self.assertEqual(len(re.findall(r"\B", "a")), 0) - # If there are no words, there are no boundaries - self.assertEqual(len(re.findall(r"\b", " ")), 0) - self.assertEqual(len(re.findall(r"\b", " ")), 0) - # Can match around the whitespace. - self.assertEqual(len(re.findall(r"\B", " ")), 2) - def test_bigcharset(self): self.assertEqual(re.match(u"([\u2222\u2223])", u"\u2222").group(1), u"\u2222") self.assertEqual(re.match(u"([\u2222\u2223])", u"\u2222", re.UNICODE).group(1), u"\u2222") - r = u'[%s]' % u''.join(map(unichr, range(256, 2**16, 255))) - self.assertEqual(re.match(r, u"\uff01", re.UNICODE).group(), u"\uff01") - - def test_big_codesize(self): - # Issue #1160 - r = re.compile('|'.join(('%d'%x for x in range(10000)))) - self.assertIsNotNone(r.match('1000')) - self.assertIsNotNone(r.match('9999')) def test_anyall(self): self.assertEqual(re.match("a.b", "a\nb", re.DOTALL).group(0), @@ -632,15 +574,6 @@ self.assertEqual(re.match('(x)*y', 50000*'x'+'y').group(1), 'x') self.assertEqual(re.match('(x)*?y', 50000*'x'+'y').group(1), 'x') - def test_unlimited_zero_width_repeat(self): - # Issue #9669 - self.assertIsNone(re.match(r'(?:a?)*y', 'z')) - self.assertIsNone(re.match(r'(?:a?)+y', 'z')) - self.assertIsNone(re.match(r'(?:a?){2,}y', 'z')) - self.assertIsNone(re.match(r'(?:a?)*?y', 'z')) - self.assertIsNone(re.match(r'(?:a?)+?y', 'z')) - self.assertIsNone(re.match(r'(?:a?){2,}?y', 'z')) - def test_scanner(self): def s_ident(scanner, token): return token def s_operator(scanner, token): return "op%s" % token @@ -701,7 +634,7 @@ try: unicode except NameError: - self.skipTest('no problem if we have no unicode') + return # no problem if we have no unicode class my_unicode(unicode): pass pat = re.compile(my_unicode("abc")) self.assertEqual(pat.match("xyz"), None) @@ -715,7 +648,7 @@ try: unicode except NameError: - self.skipTest('no problem if we have no unicode') + return # no problem if we have no unicode self.assertTrue(re.compile('bug_926075') is not re.compile(eval("u'bug_926075'"))) @@ -723,7 +656,7 @@ try: unicode except NameError: - self.skipTest('no problem if we have no unicode') + pass pattern = eval('u"[\u002E\u3002\uFF0E\uFF61]"') self.assertEqual(re.compile(pattern).split("a.b.c"), ['a','b','c']) @@ -824,129 +757,6 @@ self.assertRaises(TypeError, re.finditer, "a", {}) self.assertRaises(OverflowError, _sre.compile, "abc", 0, [long_overflow]) - def test_compile(self): - # Test return value when given string and pattern as parameter - pattern = re.compile('random pattern') - self.assertIsInstance(pattern, re._pattern_type) - same_pattern = re.compile(pattern) - self.assertIsInstance(same_pattern, re._pattern_type) - self.assertIs(same_pattern, pattern) - # Test behaviour when not given a string or pattern as parameter - self.assertRaises(TypeError, re.compile, 0) - - def test_bug_13899(self): - # Issue #13899: re pattern r"[\A]" should work like "A" but matches - # nothing. Ditto B and Z. - self.assertEqual(re.findall(r'[\A\B\b\C\Z]', 'AB\bCZ'), - ['A', 'B', '\b', 'C', 'Z']) - - @precisionbigmemtest(size=_2G, memuse=1) - def test_large_search(self, size): - # Issue #10182: indices were 32-bit-truncated. - s = 'a' * size - m = re.search('$', s) - self.assertIsNotNone(m) - self.assertEqual(m.start(), size) - self.assertEqual(m.end(), size) - - # The huge memuse is because of re.sub() using a list and a join() - # to create the replacement result. - @precisionbigmemtest(size=_2G, memuse=16 + 2) - def test_large_subn(self, size): - # Issue #10182: indices were 32-bit-truncated. - s = 'a' * size - r, n = re.subn('', '', s) - self.assertEqual(r, s) - self.assertEqual(n, size + 1) - - - def test_repeat_minmax_overflow(self): - # Issue #13169 - string = "x" * 100000 - self.assertEqual(re.match(r".{65535}", string).span(), (0, 65535)) - self.assertEqual(re.match(r".{,65535}", string).span(), (0, 65535)) - self.assertEqual(re.match(r".{65535,}?", string).span(), (0, 65535)) - self.assertEqual(re.match(r".{65536}", string).span(), (0, 65536)) - self.assertEqual(re.match(r".{,65536}", string).span(), (0, 65536)) - self.assertEqual(re.match(r".{65536,}?", string).span(), (0, 65536)) - # 2**128 should be big enough to overflow both SRE_CODE and Py_ssize_t. - self.assertRaises(OverflowError, re.compile, r".{%d}" % 2**128) - self.assertRaises(OverflowError, re.compile, r".{,%d}" % 2**128) - self.assertRaises(OverflowError, re.compile, r".{%d,}?" % 2**128) - self.assertRaises(OverflowError, re.compile, r".{%d,%d}" % (2**129, 2**128)) - - @cpython_only - def test_repeat_minmax_overflow_maxrepeat(self): - try: - from _sre import MAXREPEAT - except ImportError: - self.skipTest('requires _sre.MAXREPEAT constant') - string = "x" * 100000 - self.assertIsNone(re.match(r".{%d}" % (MAXREPEAT - 1), string)) - self.assertEqual(re.match(r".{,%d}" % (MAXREPEAT - 1), string).span(), - (0, 100000)) - self.assertIsNone(re.match(r".{%d,}?" % (MAXREPEAT - 1), string)) - self.assertRaises(OverflowError, re.compile, r".{%d}" % MAXREPEAT) - self.assertRaises(OverflowError, re.compile, r".{,%d}" % MAXREPEAT) - self.assertRaises(OverflowError, re.compile, r".{%d,}?" % MAXREPEAT) - - def test_backref_group_name_in_exception(self): - # Issue 17341: Poor error message when compiling invalid regex - with self.assertRaisesRegexp(sre_constants.error, ''): - re.compile('(?P=)') - - def test_group_name_in_exception(self): - # Issue 17341: Poor error message when compiling invalid regex - with self.assertRaisesRegexp(sre_constants.error, '\?foo'): - re.compile('(?P)') - - def test_issue17998(self): - for reps in '*', '+', '?', '{1}': - for mod in '', '?': - pattern = '.' + reps + mod + 'yz' - self.assertEqual(re.compile(pattern, re.S).findall('xyz'), - ['xyz'], msg=pattern) - pattern = pattern.encode() - self.assertEqual(re.compile(pattern, re.S).findall(b'xyz'), - [b'xyz'], msg=pattern) - - - def test_bug_2537(self): - # issue 2537: empty submatches - for outer_op in ('{0,}', '*', '+', '{1,187}'): - for inner_op in ('{0,}', '*', '?'): - r = re.compile("^((x|y)%s)%s" % (inner_op, outer_op)) - m = r.match("xyyzy") - self.assertEqual(m.group(0), "xyy") - self.assertEqual(m.group(1), "") - self.assertEqual(m.group(2), "y") - - def test_debug_flag(self): - with captured_stdout() as out: - re.compile('foo', re.DEBUG) - self.assertEqual(out.getvalue().splitlines(), - ['literal 102', 'literal 111', 'literal 111']) - # Debug output is output again even a second time (bypassing - # the cache -- issue #20426). - with captured_stdout() as out: - re.compile('foo', re.DEBUG) - self.assertEqual(out.getvalue().splitlines(), - ['literal 102', 'literal 111', 'literal 111']) - - def test_keyword_parameters(self): - # Issue #20283: Accepting the string keyword parameter. - pat = re.compile(r'(ab)') - self.assertEqual( - pat.match(string='abracadabra', pos=7, endpos=10).span(), (7, 9)) - self.assertEqual( - pat.search(string='abracadabra', pos=3, endpos=10).span(), (7, 9)) - self.assertEqual( - pat.findall(string='abracadabra', pos=3, endpos=10), ['ab']) - self.assertEqual( - pat.split(string='abracadabra', maxsplit=1), - ['', 'ab', 'racadabra']) - - def run_re_tests(): from test.re_tests import tests, SUCCEED, FAIL, SYNTAX_ERROR if verbose: diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Lib/test/test_readline.py --- a/Lib/test/test_readline.py Sat Jul 19 16:34:33 2014 -0700 +++ b/Lib/test/test_readline.py Sun Jul 20 10:52:46 2014 -0400 @@ -12,10 +12,6 @@ readline = import_module('readline') class TestHistoryManipulation (unittest.TestCase): - - @unittest.skipIf(not hasattr(readline, 'clear_history'), - "The history update test cannot be run because the " - "clear_history method is not available.") def testHistoryUpdates(self): readline.clear_history() diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Lib/test/test_repr.py --- a/Lib/test/test_repr.py Sat Jul 19 16:34:33 2014 -0700 +++ b/Lib/test/test_repr.py Sun Jul 20 10:52:46 2014 -0400 @@ -130,10 +130,10 @@ def test_file(self): fp = open(unittest.__file__) self.assertTrue(repr(fp).startswith( - "') - self.assertRegexpMatches(r(x), r'') + # XXX Hmm? How to get at a cell object? + pass def test_descriptors(self): eq = self.assertEqual @@ -268,7 +261,6 @@ eq(repr(foo.foo), "" % foo.__name__) - @unittest.skip('need a suitable object') def test_object(self): # XXX Test the repr of a type with a really long tp_name but with no # tp_repr. WIBNI we had ::Inline? :) @@ -310,7 +302,6 @@ '") def test_xmlgen_content(self): - result = self.ioclass() + result = StringIO() gen = XMLGenerator(result) gen.startDocument() @@ -195,7 +179,7 @@ self.assertEqual(result.getvalue(), start + "huhei") def test_xmlgen_pi(self): - result = self.ioclass() + result = StringIO() gen = XMLGenerator(result) gen.startDocument() @@ -207,7 +191,7 @@ self.assertEqual(result.getvalue(), start + "") def test_xmlgen_content_escape(self): - result = self.ioclass() + result = StringIO() gen = XMLGenerator(result) gen.startDocument() @@ -220,7 +204,7 @@ start + "<huhei&") def test_xmlgen_attr_escape(self): - result = self.ioclass() + result = StringIO() gen = XMLGenerator(result) gen.startDocument() @@ -239,41 +223,8 @@ "" "")) - def test_xmlgen_encoding(self): - encodings = ('iso-8859-15', 'utf-8', - 'utf-16be', 'utf-16le', - 'utf-32be', 'utf-32le') - for encoding in encodings: - result = self.ioclass() - gen = XMLGenerator(result, encoding=encoding) - - gen.startDocument() - gen.startElement("doc", {"a": u'\u20ac'}) - gen.characters(u"\u20ac") - gen.endElement("doc") - gen.endDocument() - - self.assertEqual(result.getvalue(), ( - u'\n' - u'\u20ac' % encoding - ).encode(encoding, 'xmlcharrefreplace')) - - def test_xmlgen_unencodable(self): - result = self.ioclass() - gen = XMLGenerator(result, encoding='ascii') - - gen.startDocument() - gen.startElement("doc", {"a": u'\u20ac'}) - gen.characters(u"\u20ac") - gen.endElement("doc") - gen.endDocument() - - self.assertEqual(result.getvalue(), - '\n' - '') - def test_xmlgen_ignorable(self): - result = self.ioclass() + result = StringIO() gen = XMLGenerator(result) gen.startDocument() @@ -284,28 +235,8 @@ self.assertEqual(result.getvalue(), start + " ") - def test_xmlgen_encoding_bytes(self): - encodings = ('iso-8859-15', 'utf-8', - 'utf-16be', 'utf-16le', - 'utf-32be', 'utf-32le') - for encoding in encodings: - result = self.ioclass() - gen = XMLGenerator(result, encoding=encoding) - - gen.startDocument() - gen.startElement("doc", {"a": u'\u20ac'}) - gen.characters(u"\u20ac".encode(encoding)) - gen.ignorableWhitespace(" ".encode(encoding)) - gen.endElement("doc") - gen.endDocument() - - self.assertEqual(result.getvalue(), ( - u'\n' - u'\u20ac ' % encoding - ).encode(encoding, 'xmlcharrefreplace')) - def test_xmlgen_ns(self): - result = self.ioclass() + result = StringIO() gen = XMLGenerator(result) gen.startDocument() @@ -323,7 +254,7 @@ ns_uri)) def test_1463026_1(self): - result = self.ioclass() + result = StringIO() gen = XMLGenerator(result) gen.startDocument() @@ -334,7 +265,7 @@ self.assertEqual(result.getvalue(), start+'') def test_1463026_2(self): - result = self.ioclass() + result = StringIO() gen = XMLGenerator(result) gen.startDocument() @@ -347,7 +278,7 @@ self.assertEqual(result.getvalue(), start+'') def test_1463026_3(self): - result = self.ioclass() + result = StringIO() gen = XMLGenerator(result) gen.startDocument() @@ -363,7 +294,7 @@ def test_5027_1(self): # The xml prefix (as in xml:lang below) is reserved and bound by # definition to http://www.w3.org/XML/1998/namespace. XMLGenerator had - # a bug whereby a KeyError is raised because this namespace is missing + # a bug whereby a KeyError is thrown because this namespace is missing # from a dictionary. # # This test demonstrates the bug by parsing a document. @@ -375,7 +306,7 @@ parser = make_parser() parser.setFeature(feature_namespaces, True) - result = self.ioclass() + result = StringIO() gen = XMLGenerator(result) parser.setContentHandler(gen) parser.parse(test_xml) @@ -389,12 +320,12 @@ def test_5027_2(self): # The xml prefix (as in xml:lang below) is reserved and bound by # definition to http://www.w3.org/XML/1998/namespace. XMLGenerator had - # a bug whereby a KeyError is raised because this namespace is missing + # a bug whereby a KeyError is thrown because this namespace is missing # from a dictionary. # # This test demonstrates the bug by direct manipulation of the # XMLGenerator. - result = self.ioclass() + result = StringIO() gen = XMLGenerator(result) gen.startDocument() @@ -414,44 +345,6 @@ 'Hello' '')) - def test_no_close_file(self): - result = self.ioclass() - def func(out): - gen = XMLGenerator(out) - gen.startDocument() - gen.startElement("doc", {}) - func(result) - self.assertFalse(result.closed) - - def test_xmlgen_fragment(self): - result = self.ioclass() - gen = XMLGenerator(result) - - # Don't call gen.startDocument() - gen.startElement("foo", {"a": "1.0"}) - gen.characters("Hello") - gen.endElement("foo") - gen.startElement("bar", {"b": "2.0"}) - gen.endElement("bar") - # Don't call gen.endDocument() - - self.assertEqual(result.getvalue(), - 'Hello') - -class StringXmlgenTest(XmlgenTest, unittest.TestCase): - ioclass = StringIO - -class BytesIOXmlgenTest(XmlgenTest, unittest.TestCase): - ioclass = io.BytesIO - -class WriterXmlgenTest(XmlgenTest, unittest.TestCase): - class ioclass(list): - write = list.append - closed = False - - def getvalue(self): - return b''.join(self) - class XMLFilterBaseTest(unittest.TestCase): def test_filter_basic(self): @@ -491,21 +384,6 @@ self.assertEqual(result.getvalue(), xml_test_out) - @requires_unicode_filenames - def test_expat_file_unicode(self): - fname = support.TESTFN_UNICODE - shutil.copyfile(TEST_XMLFILE, fname) - self.addCleanup(support.unlink, fname) - - parser = create_parser() - result = StringIO() - xmlgen = XMLGenerator(result) - - parser.setContentHandler(xmlgen) - parser.parse(open(fname)) - - self.assertEqual(result.getvalue(), xml_test_out) - # ===== DTDHandler support class TestDTDHandler: @@ -645,21 +523,6 @@ self.assertEqual(result.getvalue(), xml_test_out) - @requires_unicode_filenames - def test_expat_inpsource_sysid_unicode(self): - fname = support.TESTFN_UNICODE - shutil.copyfile(TEST_XMLFILE, fname) - self.addCleanup(support.unlink, fname) - - parser = create_parser() - result = StringIO() - xmlgen = XMLGenerator(result) - - parser.setContentHandler(xmlgen) - parser.parse(InputSource(fname)) - - self.assertEqual(result.getvalue(), xml_test_out) - def test_expat_inpsource_stream(self): parser = create_parser() result = StringIO() @@ -733,21 +596,6 @@ self.assertEqual(parser.getSystemId(), TEST_XMLFILE) self.assertEqual(parser.getPublicId(), None) - @requires_unicode_filenames - def test_expat_locator_withinfo_unicode(self): - fname = support.TESTFN_UNICODE - shutil.copyfile(TEST_XMLFILE, fname) - self.addCleanup(support.unlink, fname) - - result = StringIO() - xmlgen = XMLGenerator(result) - parser = create_parser() - parser.setContentHandler(xmlgen) - parser.parse(fname) - - self.assertEqual(parser.getSystemId(), fname) - self.assertEqual(parser.getPublicId(), None) - # =========================================================================== # @@ -896,9 +744,7 @@ def test_main(): run_unittest(MakeParserTest, SaxutilsTest, - StringXmlgenTest, - BytesIOXmlgenTest, - WriterXmlgenTest, + XmlgenTest, ExpatReaderTest, ErrorReportingTest, XmlReaderTest) diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Lib/test/test_select.py --- a/Lib/test/test_select.py Sat Jul 19 16:34:33 2014 -0700 +++ b/Lib/test/test_select.py Sun Jul 20 10:52:46 2014 -0400 @@ -49,15 +49,6 @@ self.fail('Unexpected return values from select():', rfd, wfd, xfd) p.close() - # Issue 16230: Crash on select resized list - def test_select_mutated(self): - a = [] - class F: - def fileno(self): - del a[-1] - return sys.__stdout__.fileno() - a[:] = [F()] * 10 - self.assertEqual(select.select([], a, []), ([], a[:5], [])) def test_main(): test_support.run_unittest(SelectTestCase) diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Lib/test/test_set.py --- a/Lib/test/test_set.py Sat Jul 19 16:34:33 2014 -0700 +++ b/Lib/test/test_set.py Sun Jul 20 10:52:46 2014 -0400 @@ -561,10 +561,10 @@ s = None self.assertRaises(ReferenceError, str, p) - @unittest.skipUnless(hasattr(set, "test_c_api"), - 'C API test only available in a debug build') - def test_c_api(self): - self.assertEqual(set().test_c_api(), True) + # C API test only available in a debug build + if hasattr(set, "test_c_api"): + def test_c_api(self): + self.assertEqual(set().test_c_api(), True) class SetSubclass(set): pass @@ -687,17 +687,6 @@ if self.repr is not None: self.assertEqual(repr(self.set), self.repr) - def check_repr_against_values(self): - text = repr(self.set) - self.assertTrue(text.startswith('{')) - self.assertTrue(text.endswith('}')) - - result = text[1:-1].split(', ') - result.sort() - sorted_repr_values = [repr(value) for value in self.values] - sorted_repr_values.sort() - self.assertEqual(result, sorted_repr_values) - def test_print(self): fo = open(test_support.TESTFN, "wb") try: @@ -847,46 +836,6 @@ self.length = 3 self.repr = None -#------------------------------------------------------------------------------ - -class TestBasicOpsString(TestBasicOps): - def setUp(self): - self.case = "string set" - self.values = ["a", "b", "c"] - self.set = set(self.values) - self.dup = set(self.values) - self.length = 3 - - def test_repr(self): - self.check_repr_against_values() - -#------------------------------------------------------------------------------ - -class TestBasicOpsUnicode(TestBasicOps): - def setUp(self): - self.case = "unicode set" - self.values = [u"a", u"b", u"c"] - self.set = set(self.values) - self.dup = set(self.values) - self.length = 3 - - def test_repr(self): - self.check_repr_against_values() - -#------------------------------------------------------------------------------ - -class TestBasicOpsMixedStringUnicode(TestBasicOps): - def setUp(self): - self.case = "string and bytes set" - self.values = ["a", "b", u"a", u"b"] - self.set = set(self.values) - self.dup = set(self.values) - self.length = 4 - - def test_repr(self): - with test_support.check_warnings(): - self.check_repr_against_values() - #============================================================================== def baditer(): @@ -1017,6 +966,8 @@ # without calling __cmp__. self.assertEqual(cmp(a, a), 0) + self.assertRaises(TypeError, cmp, a, 12) + self.assertRaises(TypeError, cmp, "abc", a) #============================================================================== @@ -1267,6 +1218,17 @@ self.assertEqual(self.other != self.set, True) self.assertEqual(self.set != self.other, True) + def test_ge_gt_le_lt(self): + self.assertRaises(TypeError, lambda: self.set < self.other) + self.assertRaises(TypeError, lambda: self.set <= self.other) + self.assertRaises(TypeError, lambda: self.set > self.other) + self.assertRaises(TypeError, lambda: self.set >= self.other) + + self.assertRaises(TypeError, lambda: self.other < self.set) + self.assertRaises(TypeError, lambda: self.other <= self.set) + self.assertRaises(TypeError, lambda: self.other > self.set) + self.assertRaises(TypeError, lambda: self.other >= self.set) + def test_update_operator(self): try: self.set |= self.other @@ -1379,6 +1341,18 @@ #------------------------------------------------------------------------------ +class TestOnlySetsOperator(TestOnlySetsInBinaryOps): + def setUp(self): + self.set = set((1, 2, 3)) + self.other = operator.add + self.otherIsIterable = False + + def test_ge_gt_le_lt(self): + with test_support.check_py3k_warnings(): + super(TestOnlySetsOperator, self).test_ge_gt_le_lt() + +#------------------------------------------------------------------------------ + class TestOnlySetsTuple(TestOnlySetsInBinaryOps): def setUp(self): self.set = set((1, 2, 3)) @@ -1590,7 +1564,7 @@ for meth in (s.union, s.intersection, s.difference, s.symmetric_difference, s.isdisjoint): for g in (G, I, Ig, L, R): expected = meth(data) - actual = meth(g(data)) + actual = meth(G(data)) if isinstance(expected, bool): self.assertEqual(actual, expected) else: @@ -1776,6 +1750,7 @@ TestSubsetNonOverlap, TestOnlySetsNumeric, TestOnlySetsDict, + TestOnlySetsOperator, TestOnlySetsTuple, TestOnlySetsString, TestOnlySetsGenerator, diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Lib/test/test_sets.py --- a/Lib/test/test_sets.py Sat Jul 19 16:34:33 2014 -0700 +++ b/Lib/test/test_sets.py Sun Jul 20 10:52:46 2014 -0400 @@ -1,3 +1,5 @@ +#!/usr/bin/env python + import unittest, operator, copy, pickle, random from test import test_support diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Lib/test/test_shutil.py --- a/Lib/test/test_shutil.py Sat Jul 19 16:34:33 2014 -0700 +++ b/Lib/test/test_shutil.py Sun Jul 20 10:52:46 2014 -0400 @@ -7,7 +7,6 @@ import stat import os import os.path -import errno from os.path import splitdrive from distutils.spawn import find_executable, spawn from shutil import (_make_tarball, _make_zipfile, make_archive, @@ -78,34 +77,33 @@ filename = tempfile.mktemp() self.assertRaises(OSError, shutil.rmtree, filename) - @unittest.skipUnless(hasattr(os, 'chmod'), 'requires os.chmod()') - @unittest.skipIf(sys.platform[:6] == 'cygwin', - "This test can't be run on Cygwin (issue #1071513).") - @unittest.skipIf(hasattr(os, 'geteuid') and os.geteuid() == 0, - "This test can't be run reliably as root (issue #1076467).") - def test_on_error(self): - self.errorState = 0 - os.mkdir(TESTFN) - self.childpath = os.path.join(TESTFN, 'a') - f = open(self.childpath, 'w') - f.close() - old_dir_mode = os.stat(TESTFN).st_mode - old_child_mode = os.stat(self.childpath).st_mode - # Make unwritable. - os.chmod(self.childpath, stat.S_IREAD) - os.chmod(TESTFN, stat.S_IREAD) + # See bug #1071513 for why we don't run this on cygwin + # and bug #1076467 for why we don't run this as root. + if (hasattr(os, 'chmod') and sys.platform[:6] != 'cygwin' + and not (hasattr(os, 'geteuid') and os.geteuid() == 0)): + def test_on_error(self): + self.errorState = 0 + os.mkdir(TESTFN) + self.childpath = os.path.join(TESTFN, 'a') + f = open(self.childpath, 'w') + f.close() + old_dir_mode = os.stat(TESTFN).st_mode + old_child_mode = os.stat(self.childpath).st_mode + # Make unwritable. + os.chmod(self.childpath, stat.S_IREAD) + os.chmod(TESTFN, stat.S_IREAD) - shutil.rmtree(TESTFN, onerror=self.check_args_to_onerror) - # Test whether onerror has actually been called. - self.assertEqual(self.errorState, 2, - "Expected call to onerror function did not happen.") + shutil.rmtree(TESTFN, onerror=self.check_args_to_onerror) + # Test whether onerror has actually been called. + self.assertEqual(self.errorState, 2, + "Expected call to onerror function did not happen.") - # Make writable again. - os.chmod(TESTFN, old_dir_mode) - os.chmod(self.childpath, old_child_mode) + # Make writable again. + os.chmod(TESTFN, old_dir_mode) + os.chmod(self.childpath, old_child_mode) - # Clean up. - shutil.rmtree(TESTFN) + # Clean up. + shutil.rmtree(TESTFN) def check_args_to_onerror(self, func, arg, exc): # test_rmtree_errors deliberately runs rmtree @@ -309,67 +307,37 @@ finally: shutil.rmtree(TESTFN, ignore_errors=True) - # Issue #3002: copyfile and copytree block indefinitely on named pipes - @unittest.skipUnless(hasattr(os, "mkfifo"), 'requires os.mkfifo()') - def test_copyfile_named_pipe(self): - os.mkfifo(TESTFN) - try: - self.assertRaises(shutil.SpecialFileError, - shutil.copyfile, TESTFN, TESTFN2) - self.assertRaises(shutil.SpecialFileError, - shutil.copyfile, __file__, TESTFN) - finally: - os.remove(TESTFN) + if hasattr(os, "mkfifo"): + # Issue #3002: copyfile and copytree block indefinitely on named pipes + def test_copyfile_named_pipe(self): + os.mkfifo(TESTFN) + try: + self.assertRaises(shutil.SpecialFileError, + shutil.copyfile, TESTFN, TESTFN2) + self.assertRaises(shutil.SpecialFileError, + shutil.copyfile, __file__, TESTFN) + finally: + os.remove(TESTFN) - @unittest.skipUnless(hasattr(os, "mkfifo"), 'requires os.mkfifo()') - def test_copytree_named_pipe(self): - os.mkdir(TESTFN) - try: - subdir = os.path.join(TESTFN, "subdir") - os.mkdir(subdir) - pipe = os.path.join(subdir, "mypipe") - os.mkfifo(pipe) + def test_copytree_named_pipe(self): + os.mkdir(TESTFN) try: - shutil.copytree(TESTFN, TESTFN2) - except shutil.Error as e: - errors = e.args[0] - self.assertEqual(len(errors), 1) - src, dst, error_msg = errors[0] - self.assertEqual("`%s` is a named pipe" % pipe, error_msg) - else: - self.fail("shutil.Error should have been raised") - finally: - shutil.rmtree(TESTFN, ignore_errors=True) - shutil.rmtree(TESTFN2, ignore_errors=True) - - @unittest.skipUnless(hasattr(os, 'chflags') and - hasattr(errno, 'EOPNOTSUPP') and - hasattr(errno, 'ENOTSUP'), - "requires os.chflags, EOPNOTSUPP & ENOTSUP") - def test_copystat_handles_harmless_chflags_errors(self): - tmpdir = self.mkdtemp() - file1 = os.path.join(tmpdir, 'file1') - file2 = os.path.join(tmpdir, 'file2') - self.write_file(file1, 'xxx') - self.write_file(file2, 'xxx') - - def make_chflags_raiser(err): - ex = OSError() - - def _chflags_raiser(path, flags): - ex.errno = err - raise ex - return _chflags_raiser - old_chflags = os.chflags - try: - for err in errno.EOPNOTSUPP, errno.ENOTSUP: - os.chflags = make_chflags_raiser(err) - shutil.copystat(file1, file2) - # assert others errors break it - os.chflags = make_chflags_raiser(errno.EOPNOTSUPP + errno.ENOTSUP) - self.assertRaises(OSError, shutil.copystat, file1, file2) - finally: - os.chflags = old_chflags + subdir = os.path.join(TESTFN, "subdir") + os.mkdir(subdir) + pipe = os.path.join(subdir, "mypipe") + os.mkfifo(pipe) + try: + shutil.copytree(TESTFN, TESTFN2) + except shutil.Error as e: + errors = e.args[0] + self.assertEqual(len(errors), 1) + src, dst, error_msg = errors[0] + self.assertEqual("`%s` is a named pipe" % pipe, error_msg) + else: + self.fail("shutil.Error should have been raised") + finally: + shutil.rmtree(TESTFN, ignore_errors=True) + shutil.rmtree(TESTFN2, ignore_errors=True) @unittest.skipUnless(zlib, "requires zlib") def test_make_tarball(self): @@ -651,14 +619,16 @@ def test_move_file_other_fs(self): # Move a file to an existing dir on another filesystem. if not self.dir_other_fs: - self.skipTest('dir on other filesystem not available') + # skip + return self._check_move_file(self.src_file, self.file_other_fs, self.file_other_fs) def test_move_file_to_dir_other_fs(self): # Move a file to another location on another filesystem. if not self.dir_other_fs: - self.skipTest('dir on other filesystem not available') + # skip + return self._check_move_file(self.src_file, self.dir_other_fs, self.file_other_fs) @@ -676,7 +646,8 @@ def test_move_dir_other_fs(self): # Move a dir to another location on another filesystem. if not self.dir_other_fs: - self.skipTest('dir on other filesystem not available') + # skip + return dst_dir = tempfile.mktemp(dir=self.dir_other_fs) try: self._check_move_dir(self.src_dir, dst_dir, dst_dir) @@ -694,19 +665,11 @@ def test_move_dir_to_dir_other_fs(self): # Move a dir inside an existing dir on another filesystem. if not self.dir_other_fs: - self.skipTest('dir on other filesystem not available') + # skip + return self._check_move_dir(self.src_dir, self.dir_other_fs, os.path.join(self.dir_other_fs, os.path.basename(self.src_dir))) - def test_move_dir_sep_to_dir(self): - self._check_move_dir(self.src_dir + os.path.sep, self.dst_dir, - os.path.join(self.dst_dir, os.path.basename(self.src_dir))) - - @unittest.skipUnless(os.path.altsep, 'requires os.path.altsep') - def test_move_dir_altsep_to_dir(self): - self._check_move_dir(self.src_dir + os.path.altsep, self.dst_dir, - os.path.join(self.dst_dir, os.path.basename(self.src_dir))) - def test_existing_file_inside_dest_dir(self): # A file with the same name inside the destination dir already exists. with open(self.dst_file, "wb"): diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Lib/test/test_signal.py --- a/Lib/test/test_signal.py Sat Jul 19 16:34:33 2014 -0700 +++ b/Lib/test/test_signal.py Sun Jul 20 10:52:46 2014 -0400 @@ -109,7 +109,7 @@ # This wait should be interrupted by the signal's exception. self.wait(child) time.sleep(1) # Give the signal time to be delivered. - self.fail('HandlerBCalled exception not raised') + self.fail('HandlerBCalled exception not thrown') except HandlerBCalled: self.assertTrue(self.b_called) self.assertFalse(self.a_called) @@ -148,7 +148,7 @@ # test-running process from all the signals. It then # communicates with that child process over a pipe and # re-raises information about any exceptions the child - # raises. The real work happens in self.run_test(). + # throws. The real work happens in self.run_test(). os_done_r, os_done_w = os.pipe() with closing(os.fdopen(os_done_r)) as done_r, \ closing(os.fdopen(os_done_w, 'w')) as done_w: @@ -227,13 +227,6 @@ signal.signal(7, handler) -class WakeupFDTests(unittest.TestCase): - - def test_invalid_fd(self): - fd = test_support.make_bad_fd() - self.assertRaises(ValueError, signal.set_wakeup_fd, fd) - - @unittest.skipIf(sys.platform == "win32", "Not valid on Windows") class WakeupSignalTests(unittest.TestCase): TIMEOUT_FULL = 10 @@ -492,9 +485,8 @@ def test_main(): test_support.run_unittest(BasicSignalTests, InterProcessSignalTests, - WakeupFDTests, WakeupSignalTests, - SiginterruptTest, ItimerTest, - WindowsSignalTests) + WakeupSignalTests, SiginterruptTest, + ItimerTest, WindowsSignalTests) if __name__ == "__main__": diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Lib/test/test_site.py --- a/Lib/test/test_site.py Sat Jul 19 16:34:33 2014 -0700 +++ b/Lib/test/test_site.py Sun Jul 20 10:52:46 2014 -0400 @@ -228,19 +228,7 @@ self.assertEqual(len(dirs), 1) wanted = os.path.join('xoxo', 'Lib', 'site-packages') self.assertEqual(dirs[0], wanted) - elif (sys.platform == "darwin" and - sysconfig.get_config_var("PYTHONFRAMEWORK")): - # OS X framework builds - site.PREFIXES = ['Python.framework'] - dirs = site.getsitepackages() - self.assertEqual(len(dirs), 3) - wanted = os.path.join('/Library', - sysconfig.get_config_var("PYTHONFRAMEWORK"), - sys.version[:3], - 'site-packages') - self.assertEqual(dirs[2], wanted) elif os.sep == '/': - # OS X non-framwework builds, Linux, FreeBSD, etc self.assertEqual(len(dirs), 2) wanted = os.path.join('xoxo', 'lib', 'python' + sys.version[:3], 'site-packages') @@ -248,12 +236,24 @@ wanted = os.path.join('xoxo', 'lib', 'site-python') self.assertEqual(dirs[1], wanted) else: - # other platforms self.assertEqual(len(dirs), 2) self.assertEqual(dirs[0], 'xoxo') wanted = os.path.join('xoxo', 'lib', 'site-packages') self.assertEqual(dirs[1], wanted) + # let's try the specific Apple location + if (sys.platform == "darwin" and + sysconfig.get_config_var("PYTHONFRAMEWORK")): + site.PREFIXES = ['Python.framework'] + dirs = site.getsitepackages() + self.assertEqual(len(dirs), 4) + wanted = os.path.join('~', 'Library', 'Python', + sys.version[:3], 'site-packages') + self.assertEqual(dirs[2], os.path.expanduser(wanted)) + wanted = os.path.join('/Library', 'Python', sys.version[:3], + 'site-packages') + self.assertEqual(dirs[3], wanted) + class PthFile(object): """Helper class for handling testing of .pth files""" @@ -343,7 +343,6 @@ self.assertNotIn(path, seen_paths) seen_paths.add(path) - @unittest.skip('test not implemented') def test_add_build_dir(self): # Test that the build directory's Modules directory is used when it # should be. diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Lib/test/test_smtplib.py --- a/Lib/test/test_smtplib.py Sat Jul 19 16:34:33 2014 -0700 +++ b/Lib/test/test_smtplib.py Sun Jul 20 10:52:46 2014 -0400 @@ -77,7 +77,7 @@ smtp.close() def testTimeoutDefault(self): - self.assertIsNone(socket.getdefaulttimeout()) + self.assertTrue(socket.getdefaulttimeout() is None) socket.setdefaulttimeout(30) try: smtp = smtplib.SMTP(HOST, self.port) @@ -87,13 +87,13 @@ smtp.close() def testTimeoutNone(self): - self.assertIsNone(socket.getdefaulttimeout()) + self.assertTrue(socket.getdefaulttimeout() is None) socket.setdefaulttimeout(30) try: smtp = smtplib.SMTP(HOST, self.port, timeout=None) finally: socket.setdefaulttimeout(None) - self.assertIsNone(smtp.sock.gettimeout()) + self.assertTrue(smtp.sock.gettimeout() is None) smtp.close() def testTimeoutValue(self): diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Lib/test/test_smtpnet.py --- a/Lib/test/test_smtpnet.py Sat Jul 19 16:34:33 2014 -0700 +++ b/Lib/test/test_smtpnet.py Sun Jul 20 10:52:46 2014 -0400 @@ -1,3 +1,5 @@ +#!/usr/bin/env python + import unittest from test import test_support import smtplib diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Lib/test/test_socket.py --- a/Lib/test/test_socket.py Sat Jul 19 16:34:33 2014 -0700 +++ b/Lib/test/test_socket.py Sun Jul 20 10:52:46 2014 -0400 @@ -1,3 +1,5 @@ +#!/usr/bin/env python + import unittest from test import test_support @@ -328,29 +330,28 @@ ip = socket.gethostbyname(hostname) except socket.error: # Probably name lookup wasn't set up right; skip this test - self.skipTest('name lookup failure') + return self.assertTrue(ip.find('.') >= 0, "Error resolving host to ip.") try: hname, aliases, ipaddrs = socket.gethostbyaddr(ip) except socket.error: # Probably a similar problem as above; skip this test - self.skipTest('address lookup failure') + return all_host_names = [hostname, hname] + aliases fqhn = socket.getfqdn(ip) if not fqhn in all_host_names: self.fail("Error testing host resolution mechanisms. (fqdn: %s, all: %s)" % (fqhn, repr(all_host_names))) - @unittest.skipUnless(hasattr(sys, 'getrefcount'), - 'test needs sys.getrefcount()') def testRefCountGetNameInfo(self): # Testing reference count for getnameinfo - try: - # On some versions, this loses a reference - orig = sys.getrefcount(__name__) - socket.getnameinfo(__name__,0) - except TypeError: - self.assertEqual(sys.getrefcount(__name__), orig, - "socket.getnameinfo loses a reference") + if hasattr(sys, "getrefcount"): + try: + # On some versions, this loses a reference + orig = sys.getrefcount(__name__) + socket.getnameinfo(__name__,0) + except TypeError: + self.assertEqual(sys.getrefcount(__name__), orig, + "socket.getnameinfo loses a reference") def testInterpreterCrash(self): # Making sure getnameinfo doesn't crash the interpreter @@ -413,7 +414,7 @@ # Try same call with optional protocol omitted port2 = socket.getservbyname(service) eq(port, port2) - # Try udp, but don't barf if it doesn't exist + # Try udp, but don't barf it it doesn't exist try: udpport = socket.getservbyname(service, 'udp') except socket.error: @@ -457,17 +458,17 @@ # Check that setting it to an invalid type raises TypeError self.assertRaises(TypeError, socket.setdefaulttimeout, "spam") - @unittest.skipUnless(hasattr(socket, 'inet_aton'), - 'test needs socket.inet_aton()') def testIPv4_inet_aton_fourbytes(self): + if not hasattr(socket, 'inet_aton'): + return # No inet_aton, nothing to check # Test that issue1008086 and issue767150 are fixed. # It must return 4 bytes. self.assertEqual('\x00'*4, socket.inet_aton('0.0.0.0')) self.assertEqual('\xff'*4, socket.inet_aton('255.255.255.255')) - @unittest.skipUnless(hasattr(socket, 'inet_pton'), - 'test needs socket.inet_pton()') def testIPv4toString(self): + if not hasattr(socket, 'inet_pton'): + return # No inet_pton() on this platform from socket import inet_aton as f, inet_pton, AF_INET g = lambda a: inet_pton(AF_INET, a) @@ -482,15 +483,15 @@ self.assertEqual('\xaa\xaa\xaa\xaa', g('170.170.170.170')) self.assertEqual('\xff\xff\xff\xff', g('255.255.255.255')) - @unittest.skipUnless(hasattr(socket, 'inet_pton'), - 'test needs socket.inet_pton()') def testIPv6toString(self): + if not hasattr(socket, 'inet_pton'): + return # No inet_pton() on this platform try: from socket import inet_pton, AF_INET6, has_ipv6 if not has_ipv6: - self.skipTest('IPv6 not available') + return except ImportError: - self.skipTest('could not import needed symbols from socket') + return f = lambda a: inet_pton(AF_INET6, a) self.assertEqual('\x00' * 16, f('::')) @@ -501,9 +502,9 @@ f('45ef:76cb:1a:56ef:afeb:bac:1924:aeae') ) - @unittest.skipUnless(hasattr(socket, 'inet_ntop'), - 'test needs socket.inet_ntop()') def testStringToIPv4(self): + if not hasattr(socket, 'inet_ntop'): + return # No inet_ntop() on this platform from socket import inet_ntoa as f, inet_ntop, AF_INET g = lambda a: inet_ntop(AF_INET, a) @@ -516,15 +517,15 @@ self.assertEqual('170.85.170.85', g('\xaa\x55\xaa\x55')) self.assertEqual('255.255.255.255', g('\xff\xff\xff\xff')) - @unittest.skipUnless(hasattr(socket, 'inet_ntop'), - 'test needs socket.inet_ntop()') def testStringToIPv6(self): + if not hasattr(socket, 'inet_ntop'): + return # No inet_ntop() on this platform try: from socket import inet_ntop, AF_INET6, has_ipv6 if not has_ipv6: - self.skipTest('IPv6 not available') + return except ImportError: - self.skipTest('could not import needed symbols from socket') + return f = lambda a: inet_ntop(AF_INET6, a) self.assertEqual('::', f('\x00' * 16)) @@ -564,7 +565,7 @@ my_ip_addr = socket.gethostbyname(socket.gethostname()) except socket.error: # Probably name lookup wasn't set up right; skip this test - self.skipTest('name lookup failure') + return self.assertIn(name[0], ("0.0.0.0", my_ip_addr), '%s invalid' % name[0]) self.assertEqual(name[1], port) @@ -643,10 +644,9 @@ if SUPPORTS_IPV6: socket.getaddrinfo('::1', 80) # port can be a string service name such as "http", a numeric - # port number (int or long), or None + # port number or None socket.getaddrinfo(HOST, "http") socket.getaddrinfo(HOST, 80) - socket.getaddrinfo(HOST, 80L) socket.getaddrinfo(HOST, None) # test family and socktype filters infos = socket.getaddrinfo(HOST, None, socket.AF_INET) @@ -663,15 +663,6 @@ socket.getaddrinfo(None, 0, socket.AF_UNSPEC, socket.SOCK_STREAM, 0, socket.AI_PASSIVE) - # Issue 17269: test workaround for OS X platform bug segfault - if hasattr(socket, 'AI_NUMERICSERV'): - try: - # The arguments here are undefined and the call may succeed - # or fail. All we care here is that it doesn't segfault. - socket.getaddrinfo("localhost", None, 0, 0, 0, - socket.AI_NUMERICSERV) - except socket.gaierror: - pass def check_sendall_interrupted(self, with_timeout): # socketpair() is not stricly required, but it makes things easier. @@ -692,12 +683,11 @@ c.settimeout(1.5) with self.assertRaises(ZeroDivisionError): signal.alarm(1) - c.sendall(b"x" * test_support.SOCK_MAX_SIZE) + c.sendall(b"x" * (1024**2)) if with_timeout: signal.signal(signal.SIGALRM, ok_handler) signal.alarm(1) - self.assertRaises(socket.timeout, c.sendall, - b"x" * test_support.SOCK_MAX_SIZE) + self.assertRaises(socket.timeout, c.sendall, b"x" * (1024**2)) finally: signal.signal(signal.SIGALRM, old_alarm) c.close() @@ -709,32 +699,13 @@ def test_sendall_interrupted_with_timeout(self): self.check_sendall_interrupted(True) - def test_listen_backlog(self): - for backlog in 0, -1: - srv = socket.socket(socket.AF_INET, socket.SOCK_STREAM) - srv.bind((HOST, 0)) - srv.listen(backlog) - srv.close() - - @test_support.cpython_only - def test_listen_backlog_overflow(self): - # Issue 15989 - import _testcapi + def testListenBacklog0(self): srv = socket.socket(socket.AF_INET, socket.SOCK_STREAM) srv.bind((HOST, 0)) - self.assertRaises(OverflowError, srv.listen, _testcapi.INT_MAX + 1) + # backlog = 0 + srv.listen(0) srv.close() - @unittest.skipUnless(SUPPORTS_IPV6, 'IPv6 required for this test.') - def test_flowinfo(self): - self.assertRaises(OverflowError, socket.getnameinfo, - ('::1',0, 0xffffffff), 0) - s = socket.socket(socket.AF_INET6, socket.SOCK_STREAM) - try: - self.assertRaises(OverflowError, s.bind, ('::1', 0, -10)) - finally: - s.close() - @unittest.skipUnless(thread, 'Threading required for this test.') class BasicTCPTest(SocketConnectedTest): @@ -792,10 +763,10 @@ big_chunk = 'f' * 2048 self.serv_conn.sendall(big_chunk) - @unittest.skipUnless(hasattr(socket, 'fromfd'), - 'socket.fromfd not availble') def testFromFd(self): # Testing fromfd() + if not hasattr(socket, "fromfd"): + return # On Windows, this doesn't exist fd = self.cli_conn.fileno() sock = socket.fromfd(fd, socket.AF_INET, socket.SOCK_STREAM) self.addCleanup(sock.close) @@ -828,19 +799,6 @@ self.serv_conn.send(MSG) self.serv_conn.shutdown(2) - testShutdown_overflow = test_support.cpython_only(testShutdown) - - @test_support.cpython_only - def _testShutdown_overflow(self): - import _testcapi - self.serv_conn.send(MSG) - # Issue 15989 - self.assertRaises(OverflowError, self.serv_conn.shutdown, - _testcapi.INT_MAX + 1) - self.assertRaises(OverflowError, self.serv_conn.shutdown, - 2 + (_testcapi.UINT_MAX + 1)) - self.serv_conn.shutdown(2) - @unittest.skipUnless(thread, 'Threading required for this test.') class BasicUDPTest(ThreadedUDPSocketTest): @@ -886,8 +844,6 @@ self.cli.connect((HOST, self.port)) time.sleep(1.0) -@unittest.skipUnless(hasattr(socket, 'socketpair'), - 'test needs socket.socketpair()') @unittest.skipUnless(thread, 'Threading required for this test.') class BasicSocketPairTest(SocketPairTest): @@ -916,10 +872,7 @@ def testSetBlocking(self): # Testing whether set blocking works - self.serv.setblocking(True) - self.assertIsNone(self.serv.gettimeout()) - self.serv.setblocking(False) - self.assertEqual(self.serv.gettimeout(), 0.0) + self.serv.setblocking(0) start = time.time() try: self.serv.accept() @@ -931,19 +884,6 @@ def _testSetBlocking(self): pass - @test_support.cpython_only - def testSetBlocking_overflow(self): - # Issue 15989 - import _testcapi - if _testcapi.UINT_MAX >= _testcapi.ULONG_MAX: - self.skipTest('needs UINT_MAX < ULONG_MAX') - self.serv.setblocking(False) - self.assertEqual(self.serv.gettimeout(), 0.0) - self.serv.setblocking(_testcapi.UINT_MAX + 1) - self.assertIsNone(self.serv.gettimeout()) - - _testSetBlocking_overflow = test_support.cpython_only(_testSetBlocking) - def testAccept(self): # Testing non-blocking accept self.serv.setblocking(0) @@ -1011,8 +951,8 @@ def tearDown(self): self.serv_file.close() self.assertTrue(self.serv_file.closed) + self.serv_file = None SocketConnectedTest.tearDown(self) - self.serv_file = None def clientSetUp(self): SocketConnectedTest.clientSetUp(self) @@ -1200,64 +1140,6 @@ bufsize = 1 # Default-buffered for reading; line-buffered for writing - class SocketMemo(object): - """A wrapper to keep track of sent data, needed to examine write behaviour""" - def __init__(self, sock): - self._sock = sock - self.sent = [] - - def send(self, data, flags=0): - n = self._sock.send(data, flags) - self.sent.append(data[:n]) - return n - - def sendall(self, data, flags=0): - self._sock.sendall(data, flags) - self.sent.append(data) - - def __getattr__(self, attr): - return getattr(self._sock, attr) - - def getsent(self): - return [e.tobytes() if isinstance(e, memoryview) else e for e in self.sent] - - def setUp(self): - FileObjectClassTestCase.setUp(self) - self.serv_file._sock = self.SocketMemo(self.serv_file._sock) - - def testLinebufferedWrite(self): - # Write two lines, in small chunks - msg = MSG.strip() - print >> self.serv_file, msg, - print >> self.serv_file, msg - - # second line: - print >> self.serv_file, msg, - print >> self.serv_file, msg, - print >> self.serv_file, msg - - # third line - print >> self.serv_file, '' - - self.serv_file.flush() - - msg1 = "%s %s\n"%(msg, msg) - msg2 = "%s %s %s\n"%(msg, msg, msg) - msg3 = "\n" - self.assertEqual(self.serv_file._sock.getsent(), [msg1, msg2, msg3]) - - def _testLinebufferedWrite(self): - msg = MSG.strip() - msg1 = "%s %s\n"%(msg, msg) - msg2 = "%s %s %s\n"%(msg, msg, msg) - msg3 = "\n" - l1 = self.cli_file.readline() - self.assertEqual(l1, msg1) - l2 = self.cli_file.readline() - self.assertEqual(l2, msg2) - l3 = self.cli_file.readline() - self.assertEqual(l3, msg3) - class SmallBufferedFileObjectClassTestCase(FileObjectClassTestCase): @@ -1305,26 +1187,7 @@ port = test_support.find_unused_port() with self.assertRaises(socket.error) as cm: socket.create_connection((HOST, port)) - - # Issue #16257: create_connection() calls getaddrinfo() against - # 'localhost'. This may result in an IPV6 addr being returned - # as well as an IPV4 one: - # >>> socket.getaddrinfo('localhost', port, 0, SOCK_STREAM) - # >>> [(2, 2, 0, '', ('127.0.0.1', 41230)), - # (26, 2, 0, '', ('::1', 41230, 0, 0))] - # - # create_connection() enumerates through all the addresses returned - # and if it doesn't successfully bind to any of them, it propagates - # the last exception it encountered. - # - # On Solaris, ENETUNREACH is returned in this circumstance instead - # of ECONNREFUSED. So, if that errno exists, add it to our list of - # expected errnos. - expected_errnos = [ errno.ECONNREFUSED, ] - if hasattr(errno, 'ENETUNREACH'): - expected_errnos.append(errno.ENETUNREACH) - - self.assertIn(cm.exception.errno, expected_errnos) + self.assertEqual(cm.exception.errno, errno.ECONNREFUSED) def test_create_connection_timeout(self): # Issue #9792: create_connection() should not recast timeout errors @@ -1482,12 +1345,12 @@ if not ok: self.fail("accept() returned success when we did not expect it") - @unittest.skipUnless(hasattr(signal, 'alarm'), - 'test needs signal.alarm()') def testInterruptedTimeout(self): # XXX I don't know how to do this test on MSWindows or any other # plaform that doesn't support signal.alarm() or os.kill(), though # the bug should have existed on all platforms. + if not hasattr(signal, "alarm"): + return # can only test on *nix self.serv.settimeout(5.0) # must be longer than alarm class Alarm(Exception): pass @@ -1547,7 +1410,6 @@ self.assertTrue(issubclass(socket.gaierror, socket.error)) self.assertTrue(issubclass(socket.timeout, socket.error)) -@unittest.skipUnless(sys.platform == 'linux', 'Linux specific test') class TestLinuxAbstractNamespace(unittest.TestCase): UNIX_PATH_MAX = 108 @@ -1643,23 +1505,6 @@ _testRecvFromIntoMemoryview = _testRecvFromIntoArray - def testRecvFromIntoSmallBuffer(self): - # See issue #20246. - buf = bytearray(8) - self.assertRaises(ValueError, self.cli_conn.recvfrom_into, buf, 1024) - - def _testRecvFromIntoSmallBuffer(self): - with test_support.check_py3k_warnings(): - buf = buffer(MSG) - self.serv_conn.send(buf) - - def testRecvFromIntoEmptyBuffer(self): - buf = bytearray() - self.cli_conn.recvfrom_into(buf) - self.cli_conn.recvfrom_into(buf, 0) - - _testRecvFromIntoEmptyBuffer = _testRecvFromIntoArray - TIPC_STYPE = 2000 TIPC_LOWER = 200 @@ -1679,11 +1524,11 @@ for line in f: if line.startswith("tipc "): return True + if test_support.verbose: + print "TIPC module is not loaded, please 'sudo modprobe tipc'" return False -@unittest.skipUnless(isTipcAvailable(), - "TIPC module is not loaded, please 'sudo modprobe tipc'") -class TIPCTest(unittest.TestCase): +class TIPCTest (unittest.TestCase): def testRDM(self): srv = socket.socket(socket.AF_TIPC, socket.SOCK_RDM) cli = socket.socket(socket.AF_TIPC, socket.SOCK_RDM) @@ -1703,9 +1548,7 @@ self.assertEqual(msg, MSG) -@unittest.skipUnless(isTipcAvailable(), - "TIPC module is not loaded, please 'sudo modprobe tipc'") -class TIPCThreadableTest(unittest.TestCase, ThreadableTest): +class TIPCThreadableTest (unittest.TestCase, ThreadableTest): def __init__(self, methodName = 'runTest'): unittest.TestCase.__init__(self, methodName = methodName) ThreadableTest.__init__(self) @@ -1758,9 +1601,13 @@ NetworkConnectionAttributesTest, NetworkConnectionBehaviourTest, ]) - tests.append(BasicSocketPairTest) - tests.append(TestLinuxAbstractNamespace) - tests.extend([TIPCTest, TIPCThreadableTest]) + if hasattr(socket, "socketpair"): + tests.append(BasicSocketPairTest) + if sys.platform == 'linux2': + tests.append(TestLinuxAbstractNamespace) + if isTipcAvailable(): + tests.append(TIPCTest) + tests.append(TIPCThreadableTest) thread_info = test_support.threading_setup() test_support.run_unittest(*tests) diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Lib/test/test_socketserver.py --- a/Lib/test/test_socketserver.py Sat Jul 19 16:34:33 2014 -0700 +++ b/Lib/test/test_socketserver.py Sun Jul 20 10:52:46 2014 -0400 @@ -8,8 +8,6 @@ import select import signal import socket -import select -import errno import tempfile import unittest import SocketServer @@ -27,21 +25,15 @@ HOST = test.test_support.HOST HAVE_UNIX_SOCKETS = hasattr(socket, "AF_UNIX") -requires_unix_sockets = unittest.skipUnless(HAVE_UNIX_SOCKETS, - 'requires Unix sockets') HAVE_FORKING = hasattr(os, "fork") and os.name != "os2" -requires_forking = unittest.skipUnless(HAVE_FORKING, 'requires forking') def signal_alarm(n): """Call signal.alarm when it exists (i.e. not on Windows).""" if hasattr(signal, 'alarm'): signal.alarm(n) -# Remember real select() to avoid interferences with mocking -_real_select = select.select - def receive(sock, n, timeout=20): - r, w, x = _real_select([sock], [], [], timeout) + r, w, x = select.select([sock], [], [], timeout) if sock in r: return sock.recv(n) else: @@ -61,7 +53,7 @@ def simple_subprocess(testcase): pid = os.fork() if pid == 0: - # Don't raise an exception; it would be caught by the test harness. + # Don't throw an exception; it would be caught by the test harness. os._exit(72) yield None pid2, status = os.waitpid(pid, 0) @@ -191,33 +183,31 @@ SocketServer.StreamRequestHandler, self.stream_examine) - @requires_forking - def test_ForkingTCPServer(self): - with simple_subprocess(self): - self.run_server(SocketServer.ForkingTCPServer, + if HAVE_FORKING: + def test_ForkingTCPServer(self): + with simple_subprocess(self): + self.run_server(SocketServer.ForkingTCPServer, + SocketServer.StreamRequestHandler, + self.stream_examine) + + if HAVE_UNIX_SOCKETS: + def test_UnixStreamServer(self): + self.run_server(SocketServer.UnixStreamServer, SocketServer.StreamRequestHandler, self.stream_examine) - @requires_unix_sockets - def test_UnixStreamServer(self): - self.run_server(SocketServer.UnixStreamServer, - SocketServer.StreamRequestHandler, - self.stream_examine) - - @requires_unix_sockets - def test_ThreadingUnixStreamServer(self): - self.run_server(SocketServer.ThreadingUnixStreamServer, - SocketServer.StreamRequestHandler, - self.stream_examine) - - @requires_unix_sockets - @requires_forking - def test_ForkingUnixStreamServer(self): - with simple_subprocess(self): - self.run_server(ForkingUnixStreamServer, + def test_ThreadingUnixStreamServer(self): + self.run_server(SocketServer.ThreadingUnixStreamServer, SocketServer.StreamRequestHandler, self.stream_examine) + if HAVE_FORKING: + def test_ForkingUnixStreamServer(self): + with simple_subprocess(self): + self.run_server(ForkingUnixStreamServer, + SocketServer.StreamRequestHandler, + self.stream_examine) + def test_UDPServer(self): self.run_server(SocketServer.UDPServer, SocketServer.DatagramRequestHandler, @@ -228,66 +218,32 @@ SocketServer.DatagramRequestHandler, self.dgram_examine) - @requires_forking - def test_ForkingUDPServer(self): - with simple_subprocess(self): - self.run_server(SocketServer.ForkingUDPServer, - SocketServer.DatagramRequestHandler, - self.dgram_examine) - - @contextlib.contextmanager - def mocked_select_module(self): - """Mocks the select.select() call to raise EINTR for first call""" - old_select = select.select - - class MockSelect: - def __init__(self): - self.called = 0 - - def __call__(self, *args): - self.called += 1 - if self.called == 1: - # raise the exception on first call - raise select.error(errno.EINTR, os.strerror(errno.EINTR)) - else: - # Return real select value for consecutive calls - return old_select(*args) - - select.select = MockSelect() - try: - yield select.select - finally: - select.select = old_select - - def test_InterruptServerSelectCall(self): - with self.mocked_select_module() as mock_select: - pid = self.run_server(SocketServer.TCPServer, - SocketServer.StreamRequestHandler, - self.stream_examine) - # Make sure select was called again: - self.assertGreater(mock_select.called, 1) + if HAVE_FORKING: + def test_ForkingUDPServer(self): + with simple_subprocess(self): + self.run_server(SocketServer.ForkingUDPServer, + SocketServer.DatagramRequestHandler, + self.dgram_examine) # Alas, on Linux (at least) recvfrom() doesn't return a meaningful # client address so this cannot work: - # @requires_unix_sockets - # def test_UnixDatagramServer(self): - # self.run_server(SocketServer.UnixDatagramServer, - # SocketServer.DatagramRequestHandler, - # self.dgram_examine) + # if HAVE_UNIX_SOCKETS: + # def test_UnixDatagramServer(self): + # self.run_server(SocketServer.UnixDatagramServer, + # SocketServer.DatagramRequestHandler, + # self.dgram_examine) # - # @requires_unix_sockets - # def test_ThreadingUnixDatagramServer(self): - # self.run_server(SocketServer.ThreadingUnixDatagramServer, - # SocketServer.DatagramRequestHandler, - # self.dgram_examine) + # def test_ThreadingUnixDatagramServer(self): + # self.run_server(SocketServer.ThreadingUnixDatagramServer, + # SocketServer.DatagramRequestHandler, + # self.dgram_examine) # - # @requires_unix_sockets - # @requires_forking - # def test_ForkingUnixDatagramServer(self): - # self.run_server(SocketServer.ForkingUnixDatagramServer, - # SocketServer.DatagramRequestHandler, - # self.dgram_examine) + # if HAVE_FORKING: + # def test_ForkingUnixDatagramServer(self): + # self.run_server(SocketServer.ForkingUnixDatagramServer, + # SocketServer.DatagramRequestHandler, + # self.dgram_examine) @reap_threads def test_shutdown(self): diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Lib/test/test_spwd.py --- a/Lib/test/test_spwd.py Sat Jul 19 16:34:33 2014 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,62 +0,0 @@ -import os -import unittest -from test import test_support - -spwd = test_support.import_module('spwd') - - -@unittest.skipUnless(hasattr(os, 'geteuid') and os.geteuid() == 0, - 'root privileges required') -class TestSpwdRoot(unittest.TestCase): - - def test_getspall(self): - entries = spwd.getspall() - self.assertIsInstance(entries, list) - for entry in entries: - self.assertIsInstance(entry, spwd.struct_spwd) - - def test_getspnam(self): - entries = spwd.getspall() - if not entries: - self.skipTest('empty shadow password database') - random_name = entries[0].sp_nam - entry = spwd.getspnam(random_name) - self.assertIsInstance(entry, spwd.struct_spwd) - self.assertEqual(entry.sp_nam, random_name) - self.assertEqual(entry.sp_nam, entry[0]) - self.assertIsInstance(entry.sp_pwd, str) - self.assertEqual(entry.sp_pwd, entry[1]) - self.assertIsInstance(entry.sp_lstchg, int) - self.assertEqual(entry.sp_lstchg, entry[2]) - self.assertIsInstance(entry.sp_min, int) - self.assertEqual(entry.sp_min, entry[3]) - self.assertIsInstance(entry.sp_max, int) - self.assertEqual(entry.sp_max, entry[4]) - self.assertIsInstance(entry.sp_warn, int) - self.assertEqual(entry.sp_warn, entry[5]) - self.assertIsInstance(entry.sp_inact, int) - self.assertEqual(entry.sp_inact, entry[6]) - self.assertIsInstance(entry.sp_expire, int) - self.assertEqual(entry.sp_expire, entry[7]) - self.assertIsInstance(entry.sp_flag, int) - self.assertEqual(entry.sp_flag, entry[8]) - with self.assertRaises(KeyError) as cx: - spwd.getspnam('invalid user name') - self.assertEqual(str(cx.exception), "'getspnam(): name not found'") - self.assertRaises(TypeError, spwd.getspnam) - self.assertRaises(TypeError, spwd.getspnam, 0) - self.assertRaises(TypeError, spwd.getspnam, random_name, 0) - if test_support.have_unicode: - try: - unicode_name = unicode(random_name) - except UnicodeDecodeError: - pass - else: - self.assertEqual(spwd.getspnam(unicode_name), entry) - - -def test_main(): - test_support.run_unittest(TestSpwdRoot) - -if __name__ == "__main__": - test_main() diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Lib/test/test_ssl.py --- a/Lib/test/test_ssl.py Sat Jul 19 16:34:33 2014 -0700 +++ b/Lib/test/test_ssl.py Sun Jul 20 10:52:46 2014 -0400 @@ -25,7 +25,6 @@ HOST = test_support.HOST CERTFILE = None SVN_PYTHON_ORG_ROOT_CERT = None -NULLBYTECERT = None def handle_error(prefix): exc_format = ' '.join(traceback.format_exception(*sys.exc_info())) @@ -96,8 +95,12 @@ sys.stdout.write("\n RAND_status is %d (%s)\n" % (v, (v and "sufficient randomness") or "insufficient randomness")) - self.assertRaises(TypeError, ssl.RAND_egd, 1) - self.assertRaises(TypeError, ssl.RAND_egd, 'foo', 1) + try: + ssl.RAND_egd(1) + except TypeError: + pass + else: + print "didn't raise TypeError" ssl.RAND_add("this is a random string", 75.0) def test_parse_cert(self): @@ -108,12 +111,13 @@ if test_support.verbose: sys.stdout.write("\n" + pprint.pformat(p) + "\n") self.assertEqual(p['subject'], - ((('countryName', 'XY'),), - (('localityName', 'Castle Anthrax'),), - (('organizationName', 'Python Software Foundation'),), - (('commonName', 'localhost'),)) + ((('countryName', u'US'),), + (('stateOrProvinceName', u'Delaware'),), + (('localityName', u'Wilmington'),), + (('organizationName', u'Python Software Foundation'),), + (('organizationalUnitName', u'SSL'),), + (('commonName', u'somemachine.python.org'),)), ) - self.assertEqual(p['subjectAltName'], (('DNS', 'localhost'),)) # Issue #13034: the subjectAltName in some certificates # (notably projects.developer.nokia.com:443) wasn't parsed p = ssl._ssl._test_decode_cert(NOKIACERT) @@ -124,35 +128,6 @@ ('DNS', 'projects.forum.nokia.com')) ) - def test_parse_cert_CVE_2013_4238(self): - p = ssl._ssl._test_decode_cert(NULLBYTECERT) - if test_support.verbose: - sys.stdout.write("\n" + pprint.pformat(p) + "\n") - subject = ((('countryName', 'US'),), - (('stateOrProvinceName', 'Oregon'),), - (('localityName', 'Beaverton'),), - (('organizationName', 'Python Software Foundation'),), - (('organizationalUnitName', 'Python Core Development'),), - (('commonName', 'null.python.org\x00example.org'),), - (('emailAddress', 'python-dev@python.org'),)) - self.assertEqual(p['subject'], subject) - self.assertEqual(p['issuer'], subject) - if ssl.OPENSSL_VERSION_INFO >= (0, 9, 8): - san = (('DNS', 'altnull.python.org\x00example.com'), - ('email', 'null@python.org\x00user@example.org'), - ('URI', 'http://null.python.org\x00http://example.org'), - ('IP Address', '192.0.2.1'), - ('IP Address', '2001:DB8:0:0:0:0:0:1\n')) - else: - # OpenSSL 0.9.7 doesn't support IPv6 addresses in subjectAltName - san = (('DNS', 'altnull.python.org\x00example.com'), - ('email', 'null@python.org\x00user@example.org'), - ('URI', 'http://null.python.org\x00http://example.org'), - ('IP Address', '192.0.2.1'), - ('IP Address', '')) - - self.assertEqual(p['subjectAltName'], san) - def test_DER_to_PEM(self): with open(SVN_PYTHON_ORG_ROOT_CERT, 'r') as f: pem = f.read() @@ -192,8 +167,9 @@ self.assertTrue(s.startswith("OpenSSL {:d}.{:d}.{:d}".format(major, minor, fix)), (s, t)) - @test_support.requires_resource('network') def test_ciphers(self): + if not test_support.is_resource_enabled('network'): + return remote = ("svn.python.org", 443) with test_support.transient_internet(remote[0]): s = ssl.wrap_socket(socket.socket(socket.AF_INET), @@ -232,13 +208,6 @@ self.assertRaises(socket.error, ss.send, b'x') self.assertRaises(socket.error, ss.sendto, b'x', ('0.0.0.0', 0)) - def test_unsupported_dtls(self): - s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) - self.addCleanup(s.close) - with self.assertRaises(NotImplementedError) as cx: - ssl.wrap_socket(s, cert_reqs=ssl.CERT_NONE) - self.assertEqual(str(cx.exception), "only stream sockets are supported") - class NetworkedTests(unittest.TestCase): @@ -315,34 +284,6 @@ finally: s.close() - def test_timeout_connect_ex(self): - # Issue #12065: on a timeout, connect_ex() should return the original - # errno (mimicking the behaviour of non-SSL sockets). - with test_support.transient_internet("svn.python.org"): - s = ssl.wrap_socket(socket.socket(socket.AF_INET), - cert_reqs=ssl.CERT_REQUIRED, - ca_certs=SVN_PYTHON_ORG_ROOT_CERT, - do_handshake_on_connect=False) - try: - s.settimeout(0.0000001) - rc = s.connect_ex(('svn.python.org', 443)) - if rc == 0: - self.skipTest("svn.python.org responded too quickly") - self.assertIn(rc, (errno.EAGAIN, errno.EWOULDBLOCK)) - finally: - s.close() - - def test_connect_ex_error(self): - with test_support.transient_internet("svn.python.org"): - s = ssl.wrap_socket(socket.socket(socket.AF_INET), - cert_reqs=ssl.CERT_REQUIRED, - ca_certs=SVN_PYTHON_ORG_ROOT_CERT) - try: - self.assertEqual(errno.ECONNREFUSED, - s.connect_ex(("svn.python.org", 444))) - finally: - s.close() - @unittest.skipIf(os.name == "nt", "Can't use a socket as a file under Windows") def test_makefile_close(self): # Issue #5238: creating a file-like object with makefile() shouldn't @@ -390,24 +331,19 @@ def test_get_server_certificate(self): with test_support.transient_internet("svn.python.org"): - pem = ssl.get_server_certificate(("svn.python.org", 443), - ssl.PROTOCOL_SSLv23) + pem = ssl.get_server_certificate(("svn.python.org", 443)) if not pem: self.fail("No server certificate on svn.python.org:443!") try: - pem = ssl.get_server_certificate(("svn.python.org", 443), - ssl.PROTOCOL_SSLv23, - ca_certs=CERTFILE) + pem = ssl.get_server_certificate(("svn.python.org", 443), ca_certs=CERTFILE) except ssl.SSLError: #should fail pass else: self.fail("Got server certificate %s for svn.python.org!" % pem) - pem = ssl.get_server_certificate(("svn.python.org", 443), - ssl.PROTOCOL_SSLv23, - ca_certs=SVN_PYTHON_ORG_ROOT_CERT) + pem = ssl.get_server_certificate(("svn.python.org", 443), ca_certs=SVN_PYTHON_ORG_ROOT_CERT) if not pem: self.fail("No server certificate on svn.python.org:443!") if test_support.verbose: @@ -419,8 +355,7 @@ # SHA256 was added in OpenSSL 0.9.8 if ssl.OPENSSL_VERSION_INFO < (0, 9, 8, 0, 15): self.skipTest("SHA256 not available on %r" % ssl.OPENSSL_VERSION) - self.skipTest("remote host needs SNI, only available on Python 3.2+") - # NOTE: https://sha2.hboeck.de is another possible test host + # NOTE: https://sha256.tbs-internet.com is another possible test host remote = ("sha256.tbs-internet.com", 443) sha256_cert = os.path.join(os.path.dirname(__file__), "sha256.pem") with test_support.transient_internet("sha256.tbs-internet.com"): @@ -482,11 +417,10 @@ ca_certs=self.server.cacerts, cert_reqs=self.server.certreqs, ciphers=self.server.ciphers) - except ssl.SSLError as e: + except ssl.SSLError: # XXX Various errors can have happened here, for example # a mismatching protocol version, an invalid certificate, # or a low-level bug. This should be made more discriminating. - self.server.conn_errors.append(e) if self.server.chatty: handle_error("\n server: bad connection attempt from " + str(self.sock.getpeername()) + ":\n") @@ -595,19 +529,9 @@ sys.stdout.write(' server: wrapped server socket as %s\n' % str(self.sock)) self.port = test_support.bind_port(self.sock) self.active = False - self.conn_errors = [] threading.Thread.__init__(self) self.daemon = True - def __enter__(self): - self.start(threading.Event()) - self.flag.wait() - return self - - def __exit__(self, *args): - self.stop() - self.join() - def start(self, flag=None): self.flag = flag threading.Thread.start(self) @@ -627,7 +551,6 @@ + str(connaddr) + '\n') handler = self.ConnectionHandler(self, newconn) handler.start() - handler.join() except socket.timeout: pass except KeyboardInterrupt: @@ -715,21 +638,6 @@ def __str__(self): return "<%s %s>" % (self.__class__.__name__, self.server) - def __enter__(self): - self.start(threading.Event()) - self.flag.wait() - return self - - def __exit__(self, *args): - if test_support.verbose: - sys.stdout.write(" cleanup: stopping server.\n") - self.stop() - if test_support.verbose: - sys.stdout.write(" cleanup: joining server thread.\n") - self.join() - if test_support.verbose: - sys.stdout.write(" cleanup: successfully joined.\n") - def start(self, flag=None): self.flag = flag threading.Thread.start(self) @@ -844,7 +752,12 @@ server = ThreadedEchoServer(CERTFILE, certreqs=ssl.CERT_REQUIRED, cacerts=CERTFILE, chatty=False) - with server: + flag = threading.Event() + server.start(flag) + # wait for it to start + flag.wait() + # try to connect + try: try: s = ssl.wrap_socket(socket.socket(), certfile=certfile, @@ -858,6 +771,9 @@ sys.stdout.write("\nsocket.error is %s\n" % x[1]) else: raise AssertionError("Use of invalid cert should have failed!") + finally: + server.stop() + server.join() def server_params_test(certfile, protocol, certreqs, cacertsfile, client_certfile, client_protocol=None, indata="FOO\n", @@ -875,10 +791,14 @@ chatty=chatty, connectionchatty=connectionchatty, wrap_accepting_socket=wrap_accepting_socket) - with server: - # try to connect - if client_protocol is None: - client_protocol = protocol + flag = threading.Event() + server.start(flag) + # wait for it to start + flag.wait() + # try to connect + if client_protocol is None: + client_protocol = protocol + try: s = ssl.wrap_socket(socket.socket(), certfile=client_certfile, ca_certs=cacertsfile, @@ -906,6 +826,9 @@ if test_support.verbose: sys.stdout.write(" client: closing connection.\n") s.close() + finally: + server.stop() + server.join() def try_protocol_combo(server_protocol, client_protocol, @@ -1007,7 +930,12 @@ ssl_version=ssl.PROTOCOL_SSLv23, cacerts=CERTFILE, chatty=False) - with server: + flag = threading.Event() + server.start(flag) + # wait for it to start + flag.wait() + # try to connect + try: s = ssl.wrap_socket(socket.socket(), certfile=CERTFILE, ca_certs=CERTFILE, @@ -1029,6 +957,9 @@ "Missing or invalid 'organizationName' field in certificate subject; " "should be 'Python Software Foundation'.") s.close() + finally: + server.stop() + server.join() def test_empty_cert(self): """Connecting with an empty cert file""" @@ -1057,7 +988,7 @@ try_protocol_combo(ssl.PROTOCOL_SSLv2, ssl.PROTOCOL_SSLv2, True) try_protocol_combo(ssl.PROTOCOL_SSLv2, ssl.PROTOCOL_SSLv2, True, ssl.CERT_OPTIONAL) try_protocol_combo(ssl.PROTOCOL_SSLv2, ssl.PROTOCOL_SSLv2, True, ssl.CERT_REQUIRED) - try_protocol_combo(ssl.PROTOCOL_SSLv2, ssl.PROTOCOL_SSLv23, False) + try_protocol_combo(ssl.PROTOCOL_SSLv2, ssl.PROTOCOL_SSLv23, True) try_protocol_combo(ssl.PROTOCOL_SSLv2, ssl.PROTOCOL_SSLv3, False) try_protocol_combo(ssl.PROTOCOL_SSLv2, ssl.PROTOCOL_TLSv1, False) @@ -1111,8 +1042,13 @@ starttls_server=True, chatty=True, connectionchatty=True) + flag = threading.Event() + server.start(flag) + # wait for it to start + flag.wait() + # try to connect wrapped = False - with server: + try: s = socket.socket() s.setblocking(1) s.connect((HOST, server.port)) @@ -1157,6 +1093,9 @@ else: s.send("over\n") s.close() + finally: + server.stop() + server.join() def test_socketserver(self): """Using a SocketServer to create and manage SSL connections.""" @@ -1206,7 +1145,12 @@ if test_support.verbose: sys.stdout.write("\n") server = AsyncoreEchoServer(CERTFILE) - with server: + flag = threading.Event() + server.start(flag) + # wait for it to start + flag.wait() + # try to connect + try: s = ssl.wrap_socket(socket.socket()) s.connect(('127.0.0.1', server.port)) if test_support.verbose: @@ -1225,6 +1169,10 @@ if test_support.verbose: sys.stdout.write(" client: closing connection.\n") s.close() + finally: + server.stop() + # wait for server thread to end + server.join() def test_recv_send(self): """Test recv(), send() and friends.""" @@ -1237,14 +1185,19 @@ cacerts=CERTFILE, chatty=True, connectionchatty=False) - with server: - s = ssl.wrap_socket(socket.socket(), - server_side=False, - certfile=CERTFILE, - ca_certs=CERTFILE, - cert_reqs=ssl.CERT_NONE, - ssl_version=ssl.PROTOCOL_TLSv1) - s.connect((HOST, server.port)) + flag = threading.Event() + server.start(flag) + # wait for it to start + flag.wait() + # try to connect + s = ssl.wrap_socket(socket.socket(), + server_side=False, + certfile=CERTFILE, + ca_certs=CERTFILE, + cert_reqs=ssl.CERT_NONE, + ssl_version=ssl.PROTOCOL_TLSv1) + s.connect((HOST, server.port)) + try: # helper methods for standardising recv* method signatures def _recv_into(): b = bytearray("\0"*100) @@ -1332,6 +1285,9 @@ s.write("over\n".encode("ASCII", "strict")) s.close() + finally: + server.stop() + server.join() def test_handshake_timeout(self): # Issue #5103: SSL handshake must respect the socket timeout @@ -1380,28 +1336,9 @@ t.join() server.close() - def test_default_ciphers(self): - with ThreadedEchoServer(CERTFILE, - ssl_version=ssl.PROTOCOL_SSLv23, - chatty=False) as server: - sock = socket.socket() - try: - # Force a set of weak ciphers on our client socket - try: - s = ssl.wrap_socket(sock, - ssl_version=ssl.PROTOCOL_SSLv23, - ciphers="DES") - except ssl.SSLError: - self.skipTest("no DES cipher available") - with self.assertRaises((OSError, ssl.SSLError)): - s.connect((HOST, server.port)) - finally: - sock.close() - self.assertIn("no shared cipher", str(server.conn_errors[0])) - def test_main(verbose=False): - global CERTFILE, SVN_PYTHON_ORG_ROOT_CERT, NOKIACERT, NULLBYTECERT + global CERTFILE, SVN_PYTHON_ORG_ROOT_CERT, NOKIACERT CERTFILE = os.path.join(os.path.dirname(__file__) or os.curdir, "keycert.pem") SVN_PYTHON_ORG_ROOT_CERT = os.path.join( @@ -1409,13 +1346,10 @@ "https_svn_python_org_root.pem") NOKIACERT = os.path.join(os.path.dirname(__file__) or os.curdir, "nokia.pem") - NULLBYTECERT = os.path.join(os.path.dirname(__file__) or os.curdir, - "nullbytecert.pem") if (not os.path.exists(CERTFILE) or not os.path.exists(SVN_PYTHON_ORG_ROOT_CERT) or - not os.path.exists(NOKIACERT) or - not os.path.exists(NULLBYTECERT)): + not os.path.exists(NOKIACERT)): raise test_support.TestFailed("Can't read certificate files!") tests = [BasicTests, BasicSocketTests] diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Lib/test/test_stat.py --- a/Lib/test/test_stat.py Sat Jul 19 16:34:33 2014 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,175 +0,0 @@ -import unittest -import os -from test.test_support import TESTFN, run_unittest -import stat - -class TestFilemode(unittest.TestCase): - file_flags = {'SF_APPEND', 'SF_ARCHIVED', 'SF_IMMUTABLE', 'SF_NOUNLINK', - 'SF_SNAPSHOT', 'UF_APPEND', 'UF_COMPRESSED', 'UF_HIDDEN', - 'UF_IMMUTABLE', 'UF_NODUMP', 'UF_NOUNLINK', 'UF_OPAQUE'} - - formats = {'S_IFBLK', 'S_IFCHR', 'S_IFDIR', 'S_IFIFO', 'S_IFLNK', - 'S_IFREG', 'S_IFSOCK'} - - format_funcs = {'S_ISBLK', 'S_ISCHR', 'S_ISDIR', 'S_ISFIFO', 'S_ISLNK', - 'S_ISREG', 'S_ISSOCK'} - - stat_struct = { - 'ST_MODE': 0, - 'ST_INO': 1, - 'ST_DEV': 2, - 'ST_NLINK': 3, - 'ST_UID': 4, - 'ST_GID': 5, - 'ST_SIZE': 6, - 'ST_ATIME': 7, - 'ST_MTIME': 8, - 'ST_CTIME': 9} - - # permission bit value are defined by POSIX - permission_bits = { - 'S_ISUID': 0o4000, - 'S_ISGID': 0o2000, - 'S_ENFMT': 0o2000, - 'S_ISVTX': 0o1000, - 'S_IRWXU': 0o700, - 'S_IRUSR': 0o400, - 'S_IREAD': 0o400, - 'S_IWUSR': 0o200, - 'S_IWRITE': 0o200, - 'S_IXUSR': 0o100, - 'S_IEXEC': 0o100, - 'S_IRWXG': 0o070, - 'S_IRGRP': 0o040, - 'S_IWGRP': 0o020, - 'S_IXGRP': 0o010, - 'S_IRWXO': 0o007, - 'S_IROTH': 0o004, - 'S_IWOTH': 0o002, - 'S_IXOTH': 0o001} - - def setUp(self): - try: - os.remove(TESTFN) - except OSError: - try: - os.rmdir(TESTFN) - except OSError: - pass - tearDown = setUp - - def get_mode(self, fname=TESTFN, lstat=True): - if lstat: - st_mode = os.lstat(fname).st_mode - else: - st_mode = os.stat(fname).st_mode - return st_mode - - def assertS_IS(self, name, mode): - # test format, lstrip is for S_IFIFO - fmt = getattr(stat, "S_IF" + name.lstrip("F")) - self.assertEqual(stat.S_IFMT(mode), fmt) - # test that just one function returns true - testname = "S_IS" + name - for funcname in self.format_funcs: - func = getattr(stat, funcname, None) - if func is None: - if funcname == testname: - raise ValueError(funcname) - continue - if funcname == testname: - self.assertTrue(func(mode)) - else: - self.assertFalse(func(mode)) - - def test_mode(self): - with open(TESTFN, 'w'): - pass - if os.name == 'posix': - os.chmod(TESTFN, 0o700) - st_mode = self.get_mode() - self.assertS_IS("REG", st_mode) - self.assertEqual(stat.S_IMODE(st_mode), - stat.S_IRWXU) - - os.chmod(TESTFN, 0o070) - st_mode = self.get_mode() - self.assertS_IS("REG", st_mode) - self.assertEqual(stat.S_IMODE(st_mode), - stat.S_IRWXG) - - os.chmod(TESTFN, 0o007) - st_mode = self.get_mode() - self.assertS_IS("REG", st_mode) - self.assertEqual(stat.S_IMODE(st_mode), - stat.S_IRWXO) - - os.chmod(TESTFN, 0o444) - st_mode = self.get_mode() - self.assertS_IS("REG", st_mode) - self.assertEqual(stat.S_IMODE(st_mode), 0o444) - else: - os.chmod(TESTFN, 0o700) - st_mode = self.get_mode() - self.assertS_IS("REG", st_mode) - self.assertEqual(stat.S_IFMT(st_mode), - stat.S_IFREG) - - def test_directory(self): - os.mkdir(TESTFN) - os.chmod(TESTFN, 0o700) - st_mode = self.get_mode() - self.assertS_IS("DIR", st_mode) - - @unittest.skipUnless(hasattr(os, 'symlink'), 'os.symlink not available') - def test_link(self): - try: - os.symlink(os.getcwd(), TESTFN) - except (OSError, NotImplementedError) as err: - raise unittest.SkipTest(str(err)) - else: - st_mode = self.get_mode() - self.assertS_IS("LNK", st_mode) - - @unittest.skipUnless(hasattr(os, 'mkfifo'), 'os.mkfifo not available') - def test_fifo(self): - os.mkfifo(TESTFN, 0o700) - st_mode = self.get_mode() - self.assertS_IS("FIFO", st_mode) - - @unittest.skipUnless(os.name == 'posix', 'requires Posix') - def test_devices(self): - if os.path.exists(os.devnull): - st_mode = self.get_mode(os.devnull, lstat=False) - self.assertS_IS("CHR", st_mode) - # Linux block devices, BSD has no block devices anymore - for blockdev in ("/dev/sda", "/dev/hda"): - if os.path.exists(blockdev): - st_mode = self.get_mode(blockdev, lstat=False) - self.assertS_IS("BLK", st_mode) - break - - def test_module_attributes(self): - for key, value in self.stat_struct.items(): - modvalue = getattr(stat, key) - self.assertEqual(value, modvalue, key) - for key, value in self.permission_bits.items(): - modvalue = getattr(stat, key) - self.assertEqual(value, modvalue, key) - for key in self.file_flags: - modvalue = getattr(stat, key) - self.assertIsInstance(modvalue, int) - for key in self.formats: - modvalue = getattr(stat, key) - self.assertIsInstance(modvalue, int) - for key in self.format_funcs: - func = getattr(stat, key) - self.assertTrue(callable(func)) - self.assertEqual(func(0), 0) - - -def test_main(): - run_unittest(TestFilemode) - -if __name__ == '__main__': - test_main() diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Lib/test/test_str.py --- a/Lib/test/test_str.py Sat Jul 19 16:34:33 2014 -0700 +++ b/Lib/test/test_str.py Sun Jul 20 10:52:46 2014 -0400 @@ -1,4 +1,4 @@ -import unittest + import struct import sys from test import test_support, string_tests @@ -35,18 +35,6 @@ string_tests.MixinStrUnicodeUserStringTest.test_formatting(self) self.assertRaises(OverflowError, '%c'.__mod__, 0x1234) - @test_support.cpython_only - def test_formatting_huge_precision(self): - from _testcapi import INT_MAX - format_string = "%.{}f".format(INT_MAX + 1) - with self.assertRaises(ValueError): - result = format_string % 2.34 - - def test_formatting_huge_width(self): - format_string = "%{}f".format(sys.maxsize + 1) - with self.assertRaises(ValueError): - result = format_string % 2.34 - def test_conversion(self): # Make sure __str__() behaves properly class Foo0: @@ -110,12 +98,12 @@ self.assertEqual(str(Foo9("foo")), "string") self.assertEqual(unicode(Foo9("foo")), u"not unicode") - # This test only affects 32-bit platforms because expandtabs can only take - # an int as the max value, not a 64-bit C long. If expandtabs is changed - # to take a 64-bit long, this test should apply to all platforms. - @unittest.skipIf(sys.maxint > (1 << 32) or struct.calcsize('P') != 4, - 'only applies to 32-bit platforms') def test_expandtabs_overflows_gracefully(self): + # This test only affects 32-bit platforms because expandtabs can only take + # an int as the max value, not a 64-bit C long. If expandtabs is changed + # to take a 64-bit long, this test should apply to all platforms. + if sys.maxint > (1 << 32) or struct.calcsize('P') != 4: + return self.assertRaises(OverflowError, 't\tt\t'.expandtabs, sys.maxint) def test__format__(self): @@ -383,21 +371,6 @@ self.assertRaises(ValueError, format, "", "-") self.assertRaises(ValueError, "{0:=s}".format, '') - def test_format_huge_precision(self): - format_string = ".{}f".format(sys.maxsize + 1) - with self.assertRaises(ValueError): - result = format(2.34, format_string) - - def test_format_huge_width(self): - format_string = "{}f".format(sys.maxsize + 1) - with self.assertRaises(ValueError): - result = format(2.34, format_string) - - def test_format_huge_item_number(self): - format_string = "{{{}:.6f}}".format(sys.maxsize + 1) - with self.assertRaises(ValueError): - result = format_string.format(2.34) - def test_format_auto_numbering(self): class C: def __init__(self, x=100): diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Lib/test/test_strop.py --- a/Lib/test/test_strop.py Sat Jul 19 16:34:33 2014 -0700 +++ b/Lib/test/test_strop.py Sun Jul 20 10:52:46 2014 -0400 @@ -4,7 +4,6 @@ r'test.test_strop|unittest') import strop import unittest -import sys from test import test_support @@ -116,11 +115,6 @@ strop.uppercase strop.whitespace - @unittest.skipUnless(sys.maxsize == 2147483647, "only for 32-bit") - def test_expandtabs_overflow(self): - s = '\t\n' * 0x10000 + 'A' * 0x1000000 - self.assertRaises(OverflowError, strop.expandtabs, s, 0x10001) - @test_support.precisionbigmemtest(size=test_support._2G - 1, memuse=5) def test_stropjoin_huge_list(self, size): a = "A" * size diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Lib/test/test_strptime.py --- a/Lib/test/test_strptime.py Sat Jul 19 16:34:33 2014 -0700 +++ b/Lib/test/test_strptime.py Sun Jul 20 10:52:46 2014 -0400 @@ -38,9 +38,9 @@ comparison = testing[self.time_tuple[tuple_position]] self.assertIn(strftime_output, testing, "%s: not found in tuple" % error_msg) - self.assertEqual(comparison, strftime_output, - "%s: position within tuple incorrect; %s != %s" % - (error_msg, comparison, strftime_output)) + self.assertTrue(comparison == strftime_output, + "%s: position within tuple incorrect; %s != %s" % + (error_msg, comparison, strftime_output)) def test_weekday(self): # Make sure that full and abbreviated weekday names are correct in @@ -65,8 +65,8 @@ "AM/PM representation not in tuple") if self.time_tuple[3] < 12: position = 0 else: position = 1 - self.assertEqual(self.LT_ins.am_pm[position], strftime_output, - "AM/PM representation in the wrong position within the tuple") + self.assertTrue(strftime_output == self.LT_ins.am_pm[position], + "AM/PM representation in the wrong position within the tuple") def test_timezone(self): # Make sure timezone is correct @@ -86,14 +86,17 @@ # output. magic_date = (1999, 3, 17, 22, 44, 55, 2, 76, 0) strftime_output = time.strftime("%c", magic_date) - self.assertEqual(time.strftime(self.LT_ins.LC_date_time, magic_date), - strftime_output, "LC_date_time incorrect") + self.assertTrue(strftime_output == time.strftime(self.LT_ins.LC_date_time, + magic_date), + "LC_date_time incorrect") strftime_output = time.strftime("%x", magic_date) - self.assertEqual(time.strftime(self.LT_ins.LC_date, magic_date), - strftime_output, "LC_date incorrect") + self.assertTrue(strftime_output == time.strftime(self.LT_ins.LC_date, + magic_date), + "LC_date incorrect") strftime_output = time.strftime("%X", magic_date) - self.assertEqual(time.strftime(self.LT_ins.LC_time, magic_date), - strftime_output, "LC_time incorrect") + self.assertTrue(strftime_output == time.strftime(self.LT_ins.LC_time, + magic_date), + "LC_time incorrect") LT = _strptime.LocaleTime() LT.am_pm = ('', '') self.assertTrue(LT.LC_time, "LocaleTime's LC directives cannot handle " @@ -165,8 +168,8 @@ # Fixes bug #661354 test_locale = _strptime.LocaleTime() test_locale.timezone = (frozenset(), frozenset()) - self.assertEqual(_strptime.TimeRE(test_locale).pattern("%Z"), '', - "with timezone == ('',''), TimeRE().pattern('%Z') != ''") + self.assertTrue(_strptime.TimeRE(test_locale).pattern("%Z") == '', + "with timezone == ('',''), TimeRE().pattern('%Z') != ''") def test_matching_with_escapes(self): # Make sure a format that requires escaping of characters works @@ -192,7 +195,7 @@ # so as to not allow to subpatterns to end up next to each other and # "steal" characters from each other. pattern = self.time_re.pattern('%j %H') - self.assertFalse(re.match(pattern, "180")) + self.assertTrue(not re.match(pattern, "180")) self.assertTrue(re.match(pattern, "18 0")) @@ -313,7 +316,7 @@ # when time.tzname[0] == time.tzname[1] and time.daylight tz_name = time.tzname[0] if tz_name.upper() in ("UTC", "GMT"): - self.skipTest('need non-UTC/GMT timezone') + return try: original_tzname = time.tzname original_daylight = time.daylight @@ -378,14 +381,6 @@ need_escaping = ".^$*+?{}\[]|)(" self.assertTrue(_strptime._strptime_time(need_escaping, need_escaping)) - def test_feb29_on_leap_year_without_year(self): - time.strptime("Feb 29", "%b %d") - - def test_mar1_comes_after_feb29_even_when_omitting_the_year(self): - self.assertLess( - time.strptime("Feb 29", "%b %d"), - time.strptime("Mar 1", "%b %d")) - class Strptime12AMPMTests(unittest.TestCase): """Test a _strptime regression in '%I %p' at 12 noon (12 PM)""" @@ -526,7 +521,7 @@ try: locale.setlocale(locale.LC_TIME, ('en_US', 'UTF8')) except locale.Error: - self.skipTest('test needs en_US.UTF8 locale') + return try: _strptime._strptime_time('10', '%d') # Get id of current cache object. @@ -543,7 +538,7 @@ # If this is the case just suppress the exception and fall-through # to the resetting to the original locale. except locale.Error: - self.skipTest('test needs de_DE.UTF8 locale') + pass # Make sure we don't trample on the locale setting once we leave the # test. finally: diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Lib/test/test_strtod.py --- a/Lib/test/test_strtod.py Sat Jul 19 16:34:33 2014 -0700 +++ b/Lib/test/test_strtod.py Sun Jul 20 10:52:46 2014 -0400 @@ -249,38 +249,6 @@ else: assert False, "expected ValueError" - @test_support.precisionbigmemtest(size=test_support._2G, memuse=3, - dry_run=False) - def test_oversized_digit_strings(self, maxsize): - # Input string whose length doesn't fit in an INT. - s = "1." + "1" * int(2.2e9) - with self.assertRaises(ValueError): - float(s) - del s - - s = "0." + "0" * int(2.2e9) + "1" - with self.assertRaises(ValueError): - float(s) - del s - - def test_large_exponents(self): - # Verify that the clipping of the exponent in strtod doesn't affect the - # output values. - def positive_exp(n): - """ Long string with value 1.0 and exponent n""" - return '0.{}1e+{}'.format('0'*(n-1), n) - - def negative_exp(n): - """ Long string with value 1.0 and exponent -n""" - return '1{}e-{}'.format('0'*n, n) - - self.assertEqual(float(positive_exp(10000)), 1.0) - self.assertEqual(float(positive_exp(20000)), 1.0) - self.assertEqual(float(positive_exp(30000)), 1.0) - self.assertEqual(float(negative_exp(10000)), 1.0) - self.assertEqual(float(negative_exp(20000)), 1.0) - self.assertEqual(float(negative_exp(30000)), 1.0) - def test_particular(self): # inputs that produced crashes or incorrectly rounded results with # previous versions of dtoa.c, for various reasons diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Lib/test/test_struct.py --- a/Lib/test/test_struct.py Sat Jul 19 16:34:33 2014 -0700 +++ b/Lib/test/test_struct.py Sun Jul 20 10:52:46 2014 -0400 @@ -3,8 +3,7 @@ import unittest import struct import inspect -from test import test_support as support -from test.test_support import (check_warnings, check_py3k_warnings) +from test.test_support import run_unittest, check_warnings, check_py3k_warnings import sys ISBIGENDIAN = sys.byteorder == "big" @@ -496,14 +495,6 @@ self.test_unpack_from(cls=buffer) - def test_unpack_with_memoryview(self): - # Bug 10212: struct.unpack doesn't support new buffer protocol objects - data1 = memoryview('\x12\x34\x56\x78') - for data in [data1,]: - value, = struct.unpack('>I', data) - self.assertEqual(value, 0x12345678) - self.test_unpack_from(cls=memoryview) - def test_bool(self): class ExplodingBool(object): def __nonzero__(self): @@ -553,41 +544,8 @@ hugecount2 = '{}b{}H'.format(sys.maxsize//2, sys.maxsize//2) self.assertRaises(struct.error, struct.calcsize, hugecount2) - def check_sizeof(self, format_str, number_of_codes): - # The size of 'PyStructObject' - totalsize = support.calcobjsize('5P') - # The size taken up by the 'formatcode' dynamic array - totalsize += struct.calcsize('3P') * (number_of_codes + 1) - support.check_sizeof(self, struct.Struct(format_str), totalsize) - - @support.cpython_only - def test__sizeof__(self): - for code in integer_codes: - self.check_sizeof(code, 1) - self.check_sizeof('BHILfdspP', 9) - self.check_sizeof('B' * 1234, 1234) - self.check_sizeof('fd', 2) - self.check_sizeof('xxxxxxxxxxxxxx', 0) - self.check_sizeof('100H', 100) - self.check_sizeof('187s', 1) - self.check_sizeof('20p', 1) - self.check_sizeof('0s', 1) - self.check_sizeof('0c', 0) - - def test_unicode_format(self): - try: - unicode - except NameError: - self.skipTest('no unicode support') - # Issue #19099 - s = struct.Struct(unichr(ord('I'))) - self.assertEqual(s.format, 'I') - self.assertIs(type(s.format), str) - self.assertRaises(ValueError, struct.Struct, unichr(0x80)) - - def test_main(): - support.run_unittest(StructTest) + run_unittest(StructTest) if __name__ == '__main__': test_main() diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Lib/test/test_structmembers.py --- a/Lib/test/test_structmembers.py Sat Jul 19 16:34:33 2014 -0700 +++ b/Lib/test/test_structmembers.py Sun Jul 20 10:52:46 2014 -0400 @@ -1,8 +1,3 @@ -import unittest -from test import test_support - -# Skip this test if the _testcapi module isn't available. -test_support.import_module('_testcapi') from _testcapi import _test_structmembersType, \ CHAR_MAX, CHAR_MIN, UCHAR_MAX, \ SHRT_MAX, SHRT_MIN, USHRT_MAX, \ @@ -10,6 +5,9 @@ LONG_MAX, LONG_MIN, ULONG_MAX, \ LLONG_MAX, LLONG_MIN, ULLONG_MAX +import unittest +from test import test_support + ts=_test_structmembersType(False, 1, 2, 3, 4, 5, 6, 7, 8, 9.99999, 10.1010101010, "hi") diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Lib/test/test_subprocess.py --- a/Lib/test/test_subprocess.py Sat Jul 19 16:34:33 2014 -0700 +++ b/Lib/test/test_subprocess.py Sun Jul 20 10:52:46 2014 -0400 @@ -14,10 +14,6 @@ import resource except ImportError: resource = None -try: - import threading -except ImportError: - threading = None mswindows = (sys.platform == "win32") @@ -62,18 +58,6 @@ self.assertEqual(actual, expected, msg) -class PopenTestException(Exception): - pass - - -class PopenExecuteChildRaises(subprocess.Popen): - """Popen subclass for testing cleanup of subprocess.PIPE filehandles when - _execute_child fails. - """ - def _execute_child(self, *args, **kwargs): - raise PopenTestException("Forced Exception for Test") - - class ProcessTestCase(BaseTestCase): def test_call_seq(self): @@ -154,27 +138,16 @@ self.assertEqual(p.stdin, None) def test_stdout_none(self): - # .stdout is None when not redirected, and the child's stdout will - # be inherited from the parent. In order to test this we run a - # subprocess in a subprocess: - # this_test - # \-- subprocess created by this test (parent) - # \-- subprocess created by the parent subprocess (child) - # The parent doesn't specify stdout, so the child will use the - # parent's stdout. This test checks that the message printed by the - # child goes to the parent stdout. The parent also checks that the - # child's stdout is None. See #11963. - code = ('import sys; from subprocess import Popen, PIPE;' - 'p = Popen([sys.executable, "-c", "print \'test_stdout_none\'"],' - ' stdin=PIPE, stderr=PIPE);' - 'p.wait(); assert p.stdout is None;') - p = subprocess.Popen([sys.executable, "-c", code], - stdout=subprocess.PIPE, stderr=subprocess.PIPE) - self.addCleanup(p.stdout.close) + # .stdout is None when not redirected + p = subprocess.Popen([sys.executable, "-c", + 'print " this bit of output is from a ' + 'test of stdout in a different ' + 'process ..."'], + stdin=subprocess.PIPE, stderr=subprocess.PIPE) + self.addCleanup(p.stdin.close) self.addCleanup(p.stderr.close) - out, err = p.communicate() - self.assertEqual(p.returncode, 0, err) - self.assertEqual(out.rstrip(), 'test_stdout_none') + p.wait() + self.assertEqual(p.stdout, None) def test_stderr_none(self): # .stderr is None when not redirected @@ -323,22 +296,9 @@ def test_stdout_filedes_of_stdout(self): # stdout is set to 1 (#1531862). - # To avoid printing the text on stdout, we do something similar to - # test_stdout_none (see above). The parent subprocess calls the child - # subprocess passing stdout=1, and this test uses stdout=PIPE in - # order to capture and check the output of the parent. See #11963. - code = ('import sys, subprocess; ' - 'rc = subprocess.call([sys.executable, "-c", ' - ' "import os, sys; sys.exit(os.write(sys.stdout.fileno(), ' - '\'test with stdout=1\'))"], stdout=1); ' - 'assert rc == 18') - p = subprocess.Popen([sys.executable, "-c", code], - stdout=subprocess.PIPE, stderr=subprocess.PIPE) - self.addCleanup(p.stdout.close) - self.addCleanup(p.stderr.close) - out, err = p.communicate() - self.assertEqual(p.returncode, 0, err) - self.assertEqual(out.rstrip(), 'test with stdout=1') + cmd = r"import sys, os; sys.exit(os.write(sys.stdout.fileno(), '.\n'))" + rc = subprocess.call([sys.executable, "-c", cmd], stdout=1) + self.assertEqual(rc, 2) def test_cwd(self): tmpdir = tempfile.gettempdir() @@ -566,7 +526,6 @@ finally: for h in handles: os.close(h) - test_support.unlink(test_support.TESTFN) def test_list2cmdline(self): self.assertEqual(subprocess.list2cmdline(['a b c', 'd', 'e']), @@ -633,36 +592,6 @@ if c.exception.errno not in (errno.ENOENT, errno.EACCES): raise c.exception - @unittest.skipIf(threading is None, "threading required") - def test_double_close_on_error(self): - # Issue #18851 - fds = [] - def open_fds(): - for i in range(20): - fds.extend(os.pipe()) - time.sleep(0.001) - t = threading.Thread(target=open_fds) - t.start() - try: - with self.assertRaises(EnvironmentError): - subprocess.Popen(['nonexisting_i_hope'], - stdin=subprocess.PIPE, - stdout=subprocess.PIPE, - stderr=subprocess.PIPE) - finally: - t.join() - exc = None - for fd in fds: - # If a double close occurred, some of those fds will - # already have been closed by mistake, and os.close() - # here will raise. - try: - os.close(fd) - except OSError as e: - exc = e - if exc is not None: - raise exc - def test_handles_closed_on_exception(self): # If CreateProcess exits with an error, ensure the # duplicate output handles are released @@ -702,27 +631,6 @@ time.sleep(2) p.communicate("x" * 2**20) - # This test is Linux-ish specific for simplicity to at least have - # some coverage. It is not a platform specific bug. - @unittest.skipUnless(os.path.isdir('/proc/%d/fd' % os.getpid()), - "Linux specific") - def test_failed_child_execute_fd_leak(self): - """Test for the fork() failure fd leak reported in issue16327.""" - fd_directory = '/proc/%d/fd' % os.getpid() - fds_before_popen = os.listdir(fd_directory) - with self.assertRaises(PopenTestException): - PopenExecuteChildRaises( - [sys.executable, '-c', 'pass'], stdin=subprocess.PIPE, - stdout=subprocess.PIPE, stderr=subprocess.PIPE) - - # NOTE: This test doesn't verify that the real _execute_child - # does not close the file descriptors itself on the way out - # during an exception. Code inspection has confirmed that. - - fds_after_exception = os.listdir(fd_directory) - self.assertEqual(fds_before_popen, fds_after_exception) - - # context manager class _SuppressCoreFiles(object): """Try to prevent core files from being created.""" @@ -809,53 +717,6 @@ self.addCleanup(p.stdout.close) self.assertEqual(p.stdout.read(), "apple") - class _TestExecuteChildPopen(subprocess.Popen): - """Used to test behavior at the end of _execute_child.""" - def __init__(self, testcase, *args, **kwargs): - self._testcase = testcase - subprocess.Popen.__init__(self, *args, **kwargs) - - def _execute_child( - self, args, executable, preexec_fn, close_fds, cwd, env, - universal_newlines, startupinfo, creationflags, shell, to_close, - p2cread, p2cwrite, - c2pread, c2pwrite, - errread, errwrite): - try: - subprocess.Popen._execute_child( - self, args, executable, preexec_fn, close_fds, - cwd, env, universal_newlines, - startupinfo, creationflags, shell, to_close, - p2cread, p2cwrite, - c2pread, c2pwrite, - errread, errwrite) - finally: - # Open a bunch of file descriptors and verify that - # none of them are the same as the ones the Popen - # instance is using for stdin/stdout/stderr. - devzero_fds = [os.open("/dev/zero", os.O_RDONLY) - for _ in range(8)] - try: - for fd in devzero_fds: - self._testcase.assertNotIn( - fd, (p2cwrite, c2pread, errread)) - finally: - for fd in devzero_fds: - os.close(fd) - - @unittest.skipIf(not os.path.exists("/dev/zero"), "/dev/zero required.") - def test_preexec_errpipe_does_not_double_close_pipes(self): - """Issue16140: Don't double close pipes on preexec error.""" - - def raise_it(): - raise RuntimeError("force the _execute_child() errpipe_data path.") - - with self.assertRaises(RuntimeError): - self._TestExecuteChildPopen( - self, [sys.executable, "-c", "pass"], - stdin=subprocess.PIPE, stdout=subprocess.PIPE, - stderr=subprocess.PIPE, preexec_fn=raise_it) - def test_args_string(self): # args is a string f, fname = mkstemp() @@ -951,29 +812,6 @@ getattr(p, method)(*args) return p - @unittest.skipIf(sys.platform.startswith(('netbsd', 'openbsd')), - "Due to known OS bug (issue #16762)") - def _kill_dead_process(self, method, *args): - # Do not inherit file handles from the parent. - # It should fix failures on some platforms. - p = subprocess.Popen([sys.executable, "-c", """if 1: - import sys, time - sys.stdout.write('x\\n') - sys.stdout.flush() - """], - close_fds=True, - stdin=subprocess.PIPE, - stdout=subprocess.PIPE, - stderr=subprocess.PIPE) - # Wait for the interpreter to be completely initialized before - # sending any signal. - p.stdout.read(1) - # The process should end after this - time.sleep(1) - # This shouldn't raise even though the child is now dead - getattr(p, method)(*args) - p.communicate() - def test_send_signal(self): p = self._kill_process('send_signal', signal.SIGINT) _, stderr = p.communicate() @@ -992,18 +830,6 @@ self.assertStderrEqual(stderr, '') self.assertEqual(p.wait(), -signal.SIGTERM) - def test_send_signal_dead(self): - # Sending a signal to a dead process - self._kill_dead_process('send_signal', signal.SIGINT) - - def test_kill_dead(self): - # Killing a dead process - self._kill_dead_process('kill') - - def test_terminate_dead(self): - # Terminating a dead process - self._kill_dead_process('terminate') - def check_close_std_fds(self, fds): # Issue #9905: test that subprocess pipes still work properly with # some standard fds closed @@ -1300,31 +1126,6 @@ returncode = p.wait() self.assertNotEqual(returncode, 0) - def _kill_dead_process(self, method, *args): - p = subprocess.Popen([sys.executable, "-c", """if 1: - import sys, time - sys.stdout.write('x\\n') - sys.stdout.flush() - sys.exit(42) - """], - stdin=subprocess.PIPE, - stdout=subprocess.PIPE, - stderr=subprocess.PIPE) - self.addCleanup(p.stdout.close) - self.addCleanup(p.stderr.close) - self.addCleanup(p.stdin.close) - # Wait for the interpreter to be completely initialized before - # sending any signal. - p.stdout.read(1) - # The process should end after this - time.sleep(1) - # This shouldn't raise even though the child is now dead - getattr(p, method)(*args) - _, stderr = p.communicate() - self.assertStderrEqual(stderr, b'') - rc = p.wait() - self.assertEqual(rc, 42) - def test_send_signal(self): self._kill_process('send_signal', signal.SIGTERM) @@ -1334,15 +1135,6 @@ def test_terminate(self): self._kill_process('terminate') - def test_send_signal_dead(self): - self._kill_dead_process('send_signal', signal.SIGTERM) - - def test_kill_dead(self): - self._kill_dead_process('kill') - - def test_terminate_dead(self): - self._kill_dead_process('terminate') - @unittest.skipUnless(getattr(subprocess, '_has_poll', False), "poll system call not supported") diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Lib/test/test_sunau.py --- a/Lib/test/test_sunau.py Sat Jul 19 16:34:33 2014 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,100 +0,0 @@ -from test.test_support import TESTFN, run_unittest -import unittest -from test import audiotests -import sys -import sunau - - -class SunauTest(audiotests.AudioWriteTests, - audiotests.AudioTestsWithSourceFile): - module = sunau - - -class SunauPCM8Test(SunauTest, unittest.TestCase): - sndfilename = 'pluck-pcm8.au' - sndfilenframes = 3307 - nchannels = 2 - sampwidth = 1 - framerate = 11025 - nframes = 48 - comptype = 'NONE' - compname = 'not compressed' - frames = audiotests.fromhex("""\ - 02FF 4B00 3104 8008 CB06 4803 BF01 03FE B8FA B4F3 29EB 1AE6 \ - EDE4 C6E2 0EE0 EFE0 57E2 FBE8 13EF D8F7 97FB F5FC 08FB DFFB \ - 11FA 3EFB BCFC 66FF CF04 4309 C10E 5112 EE17 8216 7F14 8012 \ - 490E 520D EF0F CE0F E40C 630A 080A 2B0B 510E 8B11 B60E 440A \ - """) - - -class SunauPCM16Test(SunauTest, unittest.TestCase): - sndfilename = 'pluck-pcm16.au' - sndfilenframes = 3307 - nchannels = 2 - sampwidth = 2 - framerate = 11025 - nframes = 48 - comptype = 'NONE' - compname = 'not compressed' - frames = audiotests.fromhex("""\ - 022EFFEA 4B5C00F9 311404EF 80DB0844 CBE006B0 48AB03F3 BFE601B5 0367FE80 \ - B853FA42 B4AFF351 2997EBCD 1A5AE6DC EDF9E492 C627E277 0E06E0B7 EF29E029 \ - 5759E271 FB34E83F 1377EF85 D82CF727 978EFB79 F5F7FC12 0864FB9E DF30FB40 \ - 1183FA30 3EEAFB59 BC78FCB4 66D5FF60 CF130415 431A097D C1BA0EC7 512312A0 \ - EEE11754 82071666 7FFE1448 80001298 49990EB7 52B40DC1 EFAD0F65 CE3A0FBE \ - E4B70CE6 63490A57 08CC0A1D 2BBC0B09 51480E46 8BCB113C B6F60EE9 44150A5A \ - """) - - -class SunauPCM32Test(SunauTest, unittest.TestCase): - sndfilename = 'pluck-pcm32.au' - sndfilenframes = 3307 - nchannels = 2 - sampwidth = 4 - framerate = 11025 - nframes = 48 - comptype = 'NONE' - compname = 'not compressed' - frames = audiotests.fromhex("""\ - 022D65BCFFEB9D92 4B5A0F8000FA549C 3113C34004EE2BC0 80DCD680084303E0 \ - CBDEC0C006B26140 48A9980003F2F8FC BFE8248001B07D92 036BFB60FE7B5D34 \ - B8575600FA3EC920 B4B05500F3502BC0 29983000EBCB6240 1A5CA7A0E6D99A60 \ - EDFA3E80E491BD40 C625EB80E27884A0 0E05A9A0E0B6CFE0 EF292940E0292280 \ - 5758D800E2706700 FB3557D8E83E1640 1377BF00EF840280 D82C5B80F7272A80 \ - 978F1600FB774560 F5F86510FC101364 086635A0FB9C4E20 DF30FC40FB40EE28 \ - 117FE0A0FA3438B0 3EE6B840FB5AC3F0 BC77A380FCB2F454 66D6DA80FF5F32B4 \ - CF13B980041275B0 431D6980097A8C00 C1BB60000EC74E00 5120B98012A2BAA0 \ - EEDF64C01754C060 820700001664B780 7FFFFFFF14453F40 800000001294E6E0 \ - 499C1B000EB3B270 52B73E000DBCA020 EFB2B2E00F5FD880 CE3CDB400FBE1270 \ - E4B49CC00CEA2D90 6344A8800A5A7CA0 08C8FE800A1FFEE0 2BB986C00B0A0E00 \ - 51486F800E44E190 8BCC6480113B0580 B6F4EC000EEB3630 441317800A5B48A0 \ - """) - - -class SunauULAWTest(SunauTest, unittest.TestCase): - sndfilename = 'pluck-ulaw.au' - sndfilenframes = 3307 - nchannels = 2 - sampwidth = 2 - framerate = 11025 - nframes = 48 - comptype = 'ULAW' - compname = 'CCITT G.711 u-law' - frames = audiotests.fromhex("""\ - 022CFFE8 497C00F4 307C04DC 8284083C CB84069C 497C03DC BE8401AC 036CFE74 \ - B684FA24 B684F344 2A7CEC04 19FCE704 EE04E504 C584E204 0E3CE104 EF04DF84 \ - 557CE204 FB24E804 12FCEF04 D784F744 9684FB64 F5C4FC24 083CFBA4 DF84FB24 \ - 11FCFA24 3E7CFB64 BA84FCB4 657CFF5C CF84041C 417C09BC C1840EBC 517C12FC \ - EF0416FC 828415FC 7D7C13FC 828412FC 497C0EBC 517C0DBC F0040F3C CD840FFC \ - E5040CBC 617C0A3C 08BC0A3C 2C7C0B3C 517C0E3C 8A8410FC B6840EBC 457C0A3C \ - """) - if sys.byteorder != 'big': - frames = audiotests.byteswap2(frames) - - -def test_main(): - run_unittest(SunauPCM8Test, SunauPCM16Test, SunauPCM16Test, - SunauPCM32Test, SunauULAWTest) - -if __name__ == "__main__": - test_main() diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Lib/test/test_sundry.py --- a/Lib/test/test_sundry.py Sat Jul 19 16:34:33 2014 -0700 +++ b/Lib/test/test_sundry.py Sun Jul 20 10:52:46 2014 -0400 @@ -49,9 +49,11 @@ import getpass import htmlentitydefs import ihooks + import imghdr import imputil import keyword import linecache + import macurl2path import mailcap import mimify import nntplib diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Lib/test/test_support.py --- a/Lib/test/test_support.py Sat Jul 19 16:34:33 2014 -0700 +++ b/Lib/test/test_support.py Sun Jul 20 10:52:46 2014 -0400 @@ -18,8 +18,6 @@ import UserDict import re import time -import struct -import sysconfig try: import thread except ImportError: @@ -38,8 +36,8 @@ "BasicTestRunner", "run_unittest", "run_doctest", "threading_setup", "threading_cleanup", "reap_children", "cpython_only", "check_impl_detail", "get_attribute", "py3k_bytes", - "import_fresh_module", "threading_cleanup", "reap_children", - "strip_python_stderr"] + "import_fresh_module"] + class Error(Exception): """Base class for regression test exceptions.""" @@ -181,79 +179,15 @@ except KeyError: pass -if sys.platform.startswith("win"): - def _waitfor(func, pathname, waitall=False): - # Perform the operation - func(pathname) - # Now setup the wait loop - if waitall: - dirname = pathname - else: - dirname, name = os.path.split(pathname) - dirname = dirname or '.' - # Check for `pathname` to be removed from the filesystem. - # The exponential backoff of the timeout amounts to a total - # of ~1 second after which the deletion is probably an error - # anyway. - # Testing on a i7@4.3GHz shows that usually only 1 iteration is - # required when contention occurs. - timeout = 0.001 - while timeout < 1.0: - # Note we are only testing for the existence of the file(s) in - # the contents of the directory regardless of any security or - # access rights. If we have made it this far, we have sufficient - # permissions to do that much using Python's equivalent of the - # Windows API FindFirstFile. - # Other Windows APIs can fail or give incorrect results when - # dealing with files that are pending deletion. - L = os.listdir(dirname) - if not (L if waitall else name in L): - return - # Increase the timeout and try again - time.sleep(timeout) - timeout *= 2 - warnings.warn('tests may fail, delete still pending for ' + pathname, - RuntimeWarning, stacklevel=4) - - def _unlink(filename): - _waitfor(os.unlink, filename) - - def _rmdir(dirname): - _waitfor(os.rmdir, dirname) - - def _rmtree(path): - def _rmtree_inner(path): - for name in os.listdir(path): - fullname = os.path.join(path, name) - if os.path.isdir(fullname): - _waitfor(_rmtree_inner, fullname, waitall=True) - os.rmdir(fullname) - else: - os.unlink(fullname) - _waitfor(_rmtree_inner, path, waitall=True) - _waitfor(os.rmdir, path) -else: - _unlink = os.unlink - _rmdir = os.rmdir - _rmtree = shutil.rmtree - def unlink(filename): try: - _unlink(filename) + os.unlink(filename) except OSError: pass -def rmdir(dirname): - try: - _rmdir(dirname) - except OSError as error: - # The directory need not exist. - if error.errno != errno.ENOENT: - raise - def rmtree(path): try: - _rmtree(path) + shutil.rmtree(path) except OSError, e: # Unix returns ENOENT, Windows returns ESRCH. if e.errno not in (errno.ENOENT, errno.ESRCH): @@ -270,104 +204,26 @@ # is exited) but there is a .pyo file. unlink(os.path.join(dirname, modname + os.extsep + 'pyo')) -# Check whether a gui is actually available -def _is_gui_available(): - if hasattr(_is_gui_available, 'result'): - return _is_gui_available.result - reason = None - if sys.platform.startswith('win'): - # if Python is running as a service (such as the buildbot service), - # gui interaction may be disallowed - import ctypes - import ctypes.wintypes - UOI_FLAGS = 1 - WSF_VISIBLE = 0x0001 - class USEROBJECTFLAGS(ctypes.Structure): - _fields_ = [("fInherit", ctypes.wintypes.BOOL), - ("fReserved", ctypes.wintypes.BOOL), - ("dwFlags", ctypes.wintypes.DWORD)] - dll = ctypes.windll.user32 - h = dll.GetProcessWindowStation() - if not h: - raise ctypes.WinError() - uof = USEROBJECTFLAGS() - needed = ctypes.wintypes.DWORD() - res = dll.GetUserObjectInformationW(h, - UOI_FLAGS, - ctypes.byref(uof), - ctypes.sizeof(uof), - ctypes.byref(needed)) - if not res: - raise ctypes.WinError() - if not bool(uof.dwFlags & WSF_VISIBLE): - reason = "gui not available (WSF_VISIBLE flag not set)" - elif sys.platform == 'darwin': - # The Aqua Tk implementations on OS X can abort the process if - # being called in an environment where a window server connection - # cannot be made, for instance when invoked by a buildbot or ssh - # process not running under the same user id as the current console - # user. To avoid that, raise an exception if the window manager - # connection is not available. - from ctypes import cdll, c_int, pointer, Structure - from ctypes.util import find_library - - app_services = cdll.LoadLibrary(find_library("ApplicationServices")) - - if app_services.CGMainDisplayID() == 0: - reason = "gui tests cannot run without OS X window manager" - else: - class ProcessSerialNumber(Structure): - _fields_ = [("highLongOfPSN", c_int), - ("lowLongOfPSN", c_int)] - psn = ProcessSerialNumber() - psn_p = pointer(psn) - if ( (app_services.GetCurrentProcess(psn_p) < 0) or - (app_services.SetFrontProcess(psn_p) < 0) ): - reason = "cannot run without OS X gui process" - - # check on every platform whether tkinter can actually do anything - # but skip the test on OS X because it can cause segfaults in Cocoa Tk - # when running regrtest with the -j option (multiple threads/subprocesses) - if (not reason) and (sys.platform != 'darwin'): - try: - from Tkinter import Tk - root = Tk() - root.destroy() - except Exception as e: - err_string = str(e) - if len(err_string) > 50: - err_string = err_string[:50] + ' [...]' - reason = 'Tk unavailable due to {}: {}'.format(type(e).__name__, - err_string) - - _is_gui_available.reason = reason - _is_gui_available.result = not reason - - return _is_gui_available.result - def is_resource_enabled(resource): - """Test whether a resource is enabled. - - Known resources are set by regrtest.py. If not running under regrtest.py, - all resources are assumed enabled unless use_resources has been set. - """ - return use_resources is None or resource in use_resources + """Test whether a resource is enabled. Known resources are set by + regrtest.py.""" + return use_resources is not None and resource in use_resources def requires(resource, msg=None): - """Raise ResourceDenied if the specified resource is not available.""" - if resource == 'gui' and not _is_gui_available(): - raise ResourceDenied(_is_gui_available.reason) + """Raise ResourceDenied if the specified resource is not available. + + If the caller's module is __main__ then automatically return True. The + possibility of False being returned occurs when regrtest.py is executing.""" + # see if the caller's module is __main__ - if so, treat as if + # the resource was set + if sys._getframe(1).f_globals.get("__name__") == "__main__": + return if not is_resource_enabled(resource): if msg is None: msg = "Use of the `%s' resource not enabled" % resource raise ResourceDenied(msg) - -# Don't use "localhost", since resolving it uses the DNS under recent -# Windows versions (see issue #18792). -HOST = "127.0.0.1" -HOSTv6 = "::1" - +HOST = 'localhost' def find_unused_port(family=socket.AF_INET, socktype=socket.SOCK_STREAM): """Returns an unused port that should be suitable for binding. This is @@ -449,15 +305,9 @@ raise TestFailed("tests should never set the SO_REUSEADDR " \ "socket option on TCP/IP sockets!") if hasattr(socket, 'SO_REUSEPORT'): - try: - if sock.getsockopt(socket.SOL_SOCKET, socket.SO_REUSEPORT) == 1: - raise TestFailed("tests should never set the SO_REUSEPORT " \ - "socket option on TCP/IP sockets!") - except EnvironmentError: - # Python's socket module was compiled using modern headers - # thus defining SO_REUSEPORT but this process is running - # under an older kernel that does not support SO_REUSEPORT. - pass + if sock.getsockopt(socket.SOL_SOCKET, socket.SO_REUSEPORT) == 1: + raise TestFailed("tests should never set the SO_REUSEPORT " \ + "socket option on TCP/IP sockets!") if hasattr(socket, 'SO_EXCLUSIVEADDRUSE'): sock.setsockopt(socket.SOL_SOCKET, socket.SO_EXCLUSIVEADDRUSE, 1) @@ -483,79 +333,13 @@ return (len(x) > len(y)) - (len(x) < len(y)) return (x > y) - (x < y) - -# A constant likely larger than the underlying OS pipe buffer size, to -# make writes blocking. -# Windows limit seems to be around 512 B, and many Unix kernels have a -# 64 KiB pipe buffer size or 16 * PAGE_SIZE: take a few megs to be sure. -# (see issue #17835 for a discussion of this number). -PIPE_MAX_SIZE = 4 * 1024 * 1024 + 1 - -# A constant likely larger than the underlying OS socket buffer size, to make -# writes blocking. -# The socket buffer sizes can usually be tuned system-wide (e.g. through sysctl -# on Linux), or on a per-socket basis (SO_SNDBUF/SO_RCVBUF). See issue #18643 -# for a discussion of this number). -SOCK_MAX_SIZE = 16 * 1024 * 1024 + 1 - -is_jython = sys.platform.startswith('java') - try: unicode have_unicode = True except NameError: have_unicode = False -requires_unicode = unittest.skipUnless(have_unicode, 'no unicode support') - -def u(s): - return unicode(s, 'unicode-escape') - -# FS_NONASCII: non-ASCII Unicode character encodable by -# sys.getfilesystemencoding(), or None if there is no such character. -FS_NONASCII = None -if have_unicode: - for character in ( - # First try printable and common characters to have a readable filename. - # For each character, the encoding list are just example of encodings able - # to encode the character (the list is not exhaustive). - - # U+00E6 (Latin Small Letter Ae): cp1252, iso-8859-1 - unichr(0x00E6), - # U+0130 (Latin Capital Letter I With Dot Above): cp1254, iso8859_3 - unichr(0x0130), - # U+0141 (Latin Capital Letter L With Stroke): cp1250, cp1257 - unichr(0x0141), - # U+03C6 (Greek Small Letter Phi): cp1253 - unichr(0x03C6), - # U+041A (Cyrillic Capital Letter Ka): cp1251 - unichr(0x041A), - # U+05D0 (Hebrew Letter Alef): Encodable to cp424 - unichr(0x05D0), - # U+060C (Arabic Comma): cp864, cp1006, iso8859_6, mac_arabic - unichr(0x060C), - # U+062A (Arabic Letter Teh): cp720 - unichr(0x062A), - # U+0E01 (Thai Character Ko Kai): cp874 - unichr(0x0E01), - - # Then try more "special" characters. "special" because they may be - # interpreted or displayed differently depending on the exact locale - # encoding and the font. - - # U+00A0 (No-Break Space) - unichr(0x00A0), - # U+20AC (Euro Sign) - unichr(0x20AC), - ): - try: - character.encode(sys.getfilesystemencoding())\ - .decode(sys.getfilesystemencoding()) - except UnicodeError: - pass - else: - FS_NONASCII = character - break +is_jython = sys.platform.startswith('java') # Filename used for testing if os.name == 'java': @@ -621,7 +405,7 @@ the CWD, an error is raised. If it's True, only a warning is raised and the original CWD is used. """ - if have_unicode and isinstance(name, unicode): + if isinstance(name, unicode): try: name = name.encode(sys.getfilesystemencoding() or 'ascii') except UnicodeEncodeError: @@ -983,9 +767,6 @@ ('EAI_FAIL', -4), ('EAI_NONAME', -2), ('EAI_NODATA', -5), - # Windows defines EAI_NODATA as 11001 but idiotic getaddrinfo() - # implementation actually returns WSANO_DATA i.e. 11004. - ('WSANO_DATA', 11004), ] denied = ResourceDenied("Resource '%s' is not available" % resource_name) @@ -1077,33 +858,6 @@ gc.collect() -_header = '2P' -if hasattr(sys, "gettotalrefcount"): - _header = '2P' + _header -_vheader = _header + 'P' - -def calcobjsize(fmt): - return struct.calcsize(_header + fmt + '0P') - -def calcvobjsize(fmt): - return struct.calcsize(_vheader + fmt + '0P') - - -_TPFLAGS_HAVE_GC = 1<<14 -_TPFLAGS_HEAPTYPE = 1<<9 - -def check_sizeof(test, o, size): - import _testcapi - result = sys.getsizeof(o) - # add GC header size - if ((type(o) == type) and (o.__flags__ & _TPFLAGS_HEAPTYPE) or\ - ((type(o) != type) and (type(o).__flags__ & _TPFLAGS_HAVE_GC))): - size += _testcapi.SIZEOF_PYGC_HEAD - msg = 'wrong size for %s: got %d, expected %d' \ - % (type(o), result, size) - test.assertEqual(result, size, msg) - - #======================================================================= # Decorator for running a function in a different locale, correctly resetting # it afterwards. @@ -1212,7 +966,7 @@ return wrapper return decorator -def precisionbigmemtest(size, memuse, overhead=5*_1M, dry_run=True): +def precisionbigmemtest(size, memuse, overhead=5*_1M): def decorator(f): def wrapper(self): if not real_max_memuse: @@ -1220,12 +974,11 @@ else: maxsize = size - if ((real_max_memuse or not dry_run) - and real_max_memuse < maxsize * memuse): - if verbose: - sys.stderr.write("Skipping %s because of memory " - "constraint\n" % (f.__name__,)) - return + if real_max_memuse and real_max_memuse < maxsize * memuse: + if verbose: + sys.stderr.write("Skipping %s because of memory " + "constraint\n" % (f.__name__,)) + return return f(self, maxsize) wrapper.size = size @@ -1258,8 +1011,6 @@ return obj def requires_resource(resource): - if resource == 'gui' and not _is_gui_available(): - return unittest.skip(_is_gui_available.reason) if is_resource_enabled(resource): return _id else: @@ -1342,16 +1093,6 @@ suite.addTest(unittest.makeSuite(cls)) _run_suite(suite) -#======================================================================= -# Check for the presence of docstrings. - -HAVE_DOCSTRINGS = (check_impl_detail(cpython=False) or - sys.platform == 'win32' or - sysconfig.get_config_var('WITH_DOC_STRINGS')) - -requires_docstrings = unittest.skipUnless(HAVE_DOCSTRINGS, - "test requires docstrings") - #======================================================================= # doctest driver. @@ -1451,33 +1192,6 @@ except: break -@contextlib.contextmanager -def swap_attr(obj, attr, new_val): - """Temporary swap out an attribute with a new object. - - Usage: - with swap_attr(obj, "attr", 5): - ... - - This will set obj.attr to 5 for the duration of the with: block, - restoring the old value at the end of the block. If `attr` doesn't - exist on `obj`, it will be created and then deleted at the end of the - block. - """ - if hasattr(obj, attr): - real_val = getattr(obj, attr) - setattr(obj, attr, new_val) - try: - yield - finally: - setattr(obj, attr, real_val) - else: - setattr(obj, attr, new_val) - try: - yield - finally: - delattr(obj, attr) - def py3k_bytes(b): """Emulate the py3k bytes() constructor. @@ -1496,8 +1210,22 @@ def args_from_interpreter_flags(): """Return a list of command-line arguments reproducing the current settings in sys.flags.""" - import subprocess - return subprocess._args_from_interpreter_flags() + flag_opt_map = { + 'bytes_warning': 'b', + 'dont_write_bytecode': 'B', + 'ignore_environment': 'E', + 'no_user_site': 's', + 'no_site': 'S', + 'optimize': 'O', + 'py3k_warning': '3', + 'verbose': 'v', + } + args = [] + for flag, opt in flag_opt_map.items(): + v = getattr(sys.flags, flag) + if v > 0: + args.append('-' + opt * v) + return args def strip_python_stderr(stderr): """Strip the stderr of a Python process from potential debug output diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Lib/test/test_symtable.py --- a/Lib/test/test_symtable.py Sat Jul 19 16:34:33 2014 -0700 +++ b/Lib/test/test_symtable.py Sun Jul 20 10:52:46 2014 -0400 @@ -88,10 +88,10 @@ def test_function_info(self): func = self.spam - self.assertEqual(sorted(func.get_parameters()), ["a", "b", "kw", "var"]) - expected = ["a", "b", "internal", "kw", "var", "x"] - self.assertEqual(sorted(func.get_locals()), expected) - self.assertEqual(sorted(func.get_globals()), ["bar", "glob"]) + self.assertEqual(func.get_parameters(), ("a", "b", "kw", "var")) + self.assertEqual(func.get_locals(), + ("a", "b", "internal", "kw", "var", "x")) + self.assertEqual(func.get_globals(), ("bar", "glob")) self.assertEqual(self.internal.get_frees(), ("x",)) def test_globals(self): diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Lib/test/test_sys.py --- a/Lib/test/test_sys.py Sat Jul 19 16:34:33 2014 -0700 +++ b/Lib/test/test_sys.py Sun Jul 20 10:52:46 2014 -0400 @@ -1,6 +1,5 @@ # -*- coding: iso-8859-1 -*- import unittest, test.test_support -from test.script_helper import assert_python_ok, assert_python_failure import sys, os, cStringIO import struct import operator @@ -115,69 +114,90 @@ clear_check(exc) def test_exit(self): - # call with two arguments self.assertRaises(TypeError, sys.exit, 42, 42) # call without argument - with self.assertRaises(SystemExit) as cm: - sys.exit() - self.assertIsNone(cm.exception.code) - - rc, out, err = assert_python_ok('-c', 'import sys; sys.exit()') - self.assertEqual(rc, 0) - self.assertEqual(out, b'') - self.assertEqual(err, b'') - - # call with integer argument - with self.assertRaises(SystemExit) as cm: - sys.exit(42) - self.assertEqual(cm.exception.code, 42) + try: + sys.exit(0) + except SystemExit, exc: + self.assertEqual(exc.code, 0) + except: + self.fail("wrong exception") + else: + self.fail("no exception") # call with tuple argument with one entry # entry will be unpacked - with self.assertRaises(SystemExit) as cm: + try: + sys.exit(42) + except SystemExit, exc: + self.assertEqual(exc.code, 42) + except: + self.fail("wrong exception") + else: + self.fail("no exception") + + # call with integer argument + try: sys.exit((42,)) - self.assertEqual(cm.exception.code, 42) + except SystemExit, exc: + self.assertEqual(exc.code, 42) + except: + self.fail("wrong exception") + else: + self.fail("no exception") # call with string argument - with self.assertRaises(SystemExit) as cm: + try: sys.exit("exit") - self.assertEqual(cm.exception.code, "exit") + except SystemExit, exc: + self.assertEqual(exc.code, "exit") + except: + self.fail("wrong exception") + else: + self.fail("no exception") # call with tuple argument with two entries - with self.assertRaises(SystemExit) as cm: + try: sys.exit((17, 23)) - self.assertEqual(cm.exception.code, (17, 23)) + except SystemExit, exc: + self.assertEqual(exc.code, (17, 23)) + except: + self.fail("wrong exception") + else: + self.fail("no exception") # test that the exit machinery handles SystemExits properly + import subprocess # both unnormalized... - rc, out, err = assert_python_failure('-c', 'raise SystemExit, 46') + rc = subprocess.call([sys.executable, "-c", + "raise SystemExit, 46"]) self.assertEqual(rc, 46) - self.assertEqual(out, b'') - self.assertEqual(err, b'') # ... and normalized - rc, out, err = assert_python_failure('-c', 'raise SystemExit(47)') + rc = subprocess.call([sys.executable, "-c", + "raise SystemExit(47)"]) self.assertEqual(rc, 47) - self.assertEqual(out, b'') - self.assertEqual(err, b'') - def check_exit_message(code, expected, **env_vars): - rc, out, err = assert_python_failure('-c', code, **env_vars) - self.assertEqual(rc, 1) - self.assertEqual(out, b'') - self.assertTrue(err.startswith(expected), - "%s doesn't start with %s" % (repr(err), repr(expected))) + def check_exit_message(code, expected, env=None): + process = subprocess.Popen([sys.executable, "-c", code], + stderr=subprocess.PIPE, env=env) + stdout, stderr = process.communicate() + self.assertEqual(process.returncode, 1) + self.assertTrue(stderr.startswith(expected), + "%s doesn't start with %s" % (repr(stderr), repr(expected))) - # test that stderr buffer is flushed before the exit message is written + # test that stderr buffer if flushed before the exit message is written # into stderr check_exit_message( r'import sys; sys.stderr.write("unflushed,"); sys.exit("message")', b"unflushed,message") # test that the unicode message is encoded to the stderr encoding + env = os.environ.copy() + env['PYTHONIOENCODING'] = 'latin-1' check_exit_message( r'import sys; sys.exit(u"h\xe9")', - b"h\xe9", PYTHONIOENCODING='latin-1') + b"h\xe9", env=env) def test_getdefaultencoding(self): if test.test_support.have_unicode: @@ -246,16 +266,15 @@ # still has 5 elements maj, min, buildno, plat, csd = sys.getwindowsversion() - @unittest.skipUnless(hasattr(sys, "setdlopenflags"), - 'test needs sys.setdlopenflags()') def test_dlopenflags(self): - self.assertTrue(hasattr(sys, "getdlopenflags")) - self.assertRaises(TypeError, sys.getdlopenflags, 42) - oldflags = sys.getdlopenflags() - self.assertRaises(TypeError, sys.setdlopenflags) - sys.setdlopenflags(oldflags+1) - self.assertEqual(sys.getdlopenflags(), oldflags+1) - sys.setdlopenflags(oldflags) + if hasattr(sys, "setdlopenflags"): + self.assertTrue(hasattr(sys, "getdlopenflags")) + self.assertRaises(TypeError, sys.getdlopenflags, 42) + oldflags = sys.getdlopenflags() + self.assertRaises(TypeError, sys.setdlopenflags) + sys.setdlopenflags(oldflags+1) + self.assertEqual(sys.getdlopenflags(), oldflags+1) + sys.setdlopenflags(oldflags) def test_refcount(self): # n here must be a global in order for this test to pass while @@ -419,7 +438,7 @@ attrs = ("debug", "py3k_warning", "division_warning", "division_new", "inspect", "interactive", "optimize", "dont_write_bytecode", "no_site", "ignore_environment", "tabcheck", "verbose", - "unicode", "bytes_warning", "hash_randomization") + "unicode", "bytes_warning") for attr in attrs: self.assertTrue(hasattr(sys.flags, attr), attr) self.assertEqual(type(getattr(sys.flags, attr)), int, attr) @@ -452,9 +471,6 @@ self.assertRaises(TypeError, sys.call_tracing, str, 2) def test_executable(self): - # sys.executable should be absolute - self.assertEqual(os.path.abspath(sys.executable), sys.executable) - # Issue #7774: Ensure that sys.executable is an empty string if argv[0] # has been set to an non existent program name and Python is unable to # retrieve the real program name @@ -469,11 +485,24 @@ p.wait() self.assertIn(executable, ["''", repr(sys.executable)]) -@test.test_support.cpython_only class SizeofTest(unittest.TestCase): + TPFLAGS_HAVE_GC = 1<<14 + TPFLAGS_HEAPTYPE = 1L<<9 + def setUp(self): - self.P = struct.calcsize('P') + self.c = len(struct.pack('c', ' ')) + self.H = len(struct.pack('H', 0)) + self.i = len(struct.pack('i', 0)) + self.l = len(struct.pack('l', 0)) + self.P = len(struct.pack('P', 0)) + # due to missing size_t information from struct, it is assumed that + # sizeof(Py_ssize_t) = sizeof(void*) + self.header = 'PP' + self.vheader = self.header + 'P' + if hasattr(sys, "gettotalrefcount"): + self.header += '2P' + self.vheader += '2P' self.longdigit = sys.long_info.sizeof_digit import _testcapi self.gc_headsize = _testcapi.SIZEOF_PYGC_HEAD @@ -483,109 +512,128 @@ self.file.close() test.test_support.unlink(test.test_support.TESTFN) - check_sizeof = test.test_support.check_sizeof + def check_sizeof(self, o, size): + result = sys.getsizeof(o) + if ((type(o) == type) and (o.__flags__ & self.TPFLAGS_HEAPTYPE) or\ + ((type(o) != type) and (type(o).__flags__ & self.TPFLAGS_HAVE_GC))): + size += self.gc_headsize + msg = 'wrong size for %s: got %d, expected %d' \ + % (type(o), result, size) + self.assertEqual(result, size, msg) + + def calcsize(self, fmt): + """Wrapper around struct.calcsize which enforces the alignment of the + end of a structure to the alignment requirement of pointer. + + Note: This wrapper should only be used if a pointer member is included + and no member with a size larger than a pointer exists. + """ + return struct.calcsize(fmt + '0P') def test_gc_head_size(self): # Check that the gc header size is added to objects tracked by the gc. - size = test.test_support.calcobjsize + h = self.header + size = self.calcsize gc_header_size = self.gc_headsize # bool objects are not gc tracked - self.assertEqual(sys.getsizeof(True), size('l')) + self.assertEqual(sys.getsizeof(True), size(h + 'l')) # but lists are - self.assertEqual(sys.getsizeof([]), size('P PP') + gc_header_size) + self.assertEqual(sys.getsizeof([]), size(h + 'P PP') + gc_header_size) def test_default(self): - size = test.test_support.calcobjsize - self.assertEqual(sys.getsizeof(True, -1), size('l')) + h = self.header + size = self.calcsize + self.assertEqual(sys.getsizeof(True, -1), size(h + 'l')) def test_objecttypes(self): # check all types defined in Objects/ - size = test.test_support.calcobjsize - vsize = test.test_support.calcvobjsize + h = self.header + vh = self.vheader + size = self.calcsize check = self.check_sizeof # bool - check(True, size('l')) + check(True, size(h + 'l')) # buffer with test.test_support.check_py3k_warnings(): - check(buffer(''), size('2P2Pil')) + check(buffer(''), size(h + '2P2Pil')) # builtin_function_or_method - check(len, size('3P')) + check(len, size(h + '3P')) # bytearray samples = ['', 'u'*100000] for sample in samples: x = bytearray(sample) - check(x, vsize('iPP') + x.__alloc__()) + check(x, size(vh + 'iPP') + x.__alloc__() * self.c) # bytearray_iterator - check(iter(bytearray()), size('PP')) + check(iter(bytearray()), size(h + 'PP')) # cell def get_cell(): x = 42 def inner(): return x return inner - check(get_cell().func_closure[0], size('P')) + check(get_cell().func_closure[0], size(h + 'P')) # classobj (old-style class) class class_oldstyle(): def method(): pass - check(class_oldstyle, size('7P')) + check(class_oldstyle, size(h + '7P')) # instance (old-style class) - check(class_oldstyle(), size('3P')) + check(class_oldstyle(), size(h + '3P')) # instancemethod (old-style class) - check(class_oldstyle().method, size('4P')) + check(class_oldstyle().method, size(h + '4P')) # complex - check(complex(0,1), size('2d')) + check(complex(0,1), size(h + '2d')) # code - check(get_cell().func_code, size('4i8Pi3P')) + check(get_cell().func_code, size(h + '4i8Pi3P')) # BaseException - check(BaseException(), size('3P')) + check(BaseException(), size(h + '3P')) # UnicodeEncodeError - check(UnicodeEncodeError("", u"", 0, 0, ""), size('5P2PP')) + check(UnicodeEncodeError("", u"", 0, 0, ""), size(h + '5P2PP')) # UnicodeDecodeError - check(UnicodeDecodeError("", "", 0, 0, ""), size('5P2PP')) + check(UnicodeDecodeError("", "", 0, 0, ""), size(h + '5P2PP')) # UnicodeTranslateError - check(UnicodeTranslateError(u"", 0, 1, ""), size('5P2PP')) + check(UnicodeTranslateError(u"", 0, 1, ""), size(h + '5P2PP')) # method_descriptor (descriptor object) - check(str.lower, size('2PP')) + check(str.lower, size(h + '2PP')) # classmethod_descriptor (descriptor object) # XXX # member_descriptor (descriptor object) import datetime - check(datetime.timedelta.days, size('2PP')) + check(datetime.timedelta.days, size(h + '2PP')) # getset_descriptor (descriptor object) import __builtin__ - check(__builtin__.file.closed, size('2PP')) + check(__builtin__.file.closed, size(h + '2PP')) # wrapper_descriptor (descriptor object) - check(int.__add__, size('2P2P')) + check(int.__add__, size(h + '2P2P')) # dictproxy class C(object): pass - check(C.__dict__, size('P')) + check(C.__dict__, size(h + 'P')) # method-wrapper (descriptor object) - check({}.__iter__, size('2P')) + check({}.__iter__, size(h + '2P')) # dict - check({}, size('3P2P' + 8*'P2P')) + check({}, size(h + '3P2P' + 8*'P2P')) x = {1:1, 2:2, 3:3, 4:4, 5:5, 6:6, 7:7, 8:8} - check(x, size('3P2P' + 8*'P2P') + 16*struct.calcsize('P2P')) + check(x, size(h + '3P2P' + 8*'P2P') + 16*size('P2P')) # dictionary-keyiterator - check({}.iterkeys(), size('P2PPP')) + check({}.iterkeys(), size(h + 'P2PPP')) # dictionary-valueiterator - check({}.itervalues(), size('P2PPP')) + check({}.itervalues(), size(h + 'P2PPP')) # dictionary-itemiterator - check({}.iteritems(), size('P2PPP')) + check({}.iteritems(), size(h + 'P2PPP')) # ellipses - check(Ellipsis, size('')) + check(Ellipsis, size(h + '')) # EncodingMap import codecs, encodings.iso8859_3 x = codecs.charmap_build(encodings.iso8859_3.decoding_table) - check(x, size('32B2iB')) + check(x, size(h + '32B2iB')) # enumerate - check(enumerate([]), size('l3P')) + check(enumerate([]), size(h + 'l3P')) # file - check(self.file, size('4P2i4P3i3P3i')) + check(self.file, size(h + '4P2i4P3i3P3i')) # float - check(float(0), size('d')) + check(float(0), size(h + 'd')) # sys.floatinfo - check(sys.float_info, vsize('') + self.P * len(sys.float_info)) + check(sys.float_info, size(vh) + self.P * len(sys.float_info)) # frame import inspect CO_MAXBLOCKS = 20 @@ -594,10 +642,10 @@ nfrees = len(x.f_code.co_freevars) extras = x.f_code.co_stacksize + x.f_code.co_nlocals +\ ncells + nfrees - 1 - check(x, vsize('12P3i' + CO_MAXBLOCKS*'3i' + 'P' + extras*'P')) + check(x, size(vh + '12P3i' + CO_MAXBLOCKS*'3i' + 'P' + extras*'P')) # function def func(): pass - check(func, size('9P')) + check(func, size(h + '9P')) class c(): @staticmethod def foo(): @@ -606,65 +654,65 @@ def bar(cls): pass # staticmethod - check(foo, size('P')) + check(foo, size(h + 'P')) # classmethod - check(bar, size('P')) + check(bar, size(h + 'P')) # generator def get_gen(): yield 1 - check(get_gen(), size('Pi2P')) + check(get_gen(), size(h + 'Pi2P')) # integer - check(1, size('l')) - check(100, size('l')) + check(1, size(h + 'l')) + check(100, size(h + 'l')) # iterator - check(iter('abc'), size('lP')) + check(iter('abc'), size(h + 'lP')) # callable-iterator import re - check(re.finditer('',''), size('2P')) + check(re.finditer('',''), size(h + '2P')) # list samples = [[], [1,2,3], ['1', '2', '3']] for sample in samples: - check(sample, vsize('PP') + len(sample)*self.P) + check(sample, size(vh + 'PP') + len(sample)*self.P) # sortwrapper (list) # XXX # cmpwrapper (list) # XXX # listiterator (list) - check(iter([]), size('lP')) + check(iter([]), size(h + 'lP')) # listreverseiterator (list) - check(reversed([]), size('lP')) + check(reversed([]), size(h + 'lP')) # long - check(0L, vsize('')) - check(1L, vsize('') + self.longdigit) - check(-1L, vsize('') + self.longdigit) + check(0L, size(vh)) + check(1L, size(vh) + self.longdigit) + check(-1L, size(vh) + self.longdigit) PyLong_BASE = 2**sys.long_info.bits_per_digit - check(long(PyLong_BASE), vsize('') + 2*self.longdigit) - check(long(PyLong_BASE**2-1), vsize('') + 2*self.longdigit) - check(long(PyLong_BASE**2), vsize('') + 3*self.longdigit) + check(long(PyLong_BASE), size(vh) + 2*self.longdigit) + check(long(PyLong_BASE**2-1), size(vh) + 2*self.longdigit) + check(long(PyLong_BASE**2), size(vh) + 3*self.longdigit) # module - check(unittest, size('P')) + check(unittest, size(h + 'P')) # None - check(None, size('')) + check(None, size(h + '')) # object - check(object(), size('')) + check(object(), size(h + '')) # property (descriptor object) class C(object): def getx(self): return self.__x def setx(self, value): self.__x = value def delx(self): del self.__x x = property(getx, setx, delx, "") - check(x, size('4Pi')) + check(x, size(h + '4Pi')) # PyCObject # PyCapsule # XXX # rangeiterator - check(iter(xrange(1)), size('4l')) + check(iter(xrange(1)), size(h + '4l')) # reverse - check(reversed(''), size('PP')) + check(reversed(''), size(h + 'PP')) # set # frozenset PySet_MINSIZE = 8 samples = [[], range(10), range(50)] - s = size('3P2P' + PySet_MINSIZE*'lP' + 'lP') + s = size(h + '3P2P' + PySet_MINSIZE*'lP' + 'lP') for sample in samples: minused = len(sample) if minused == 0: tmp = 1 @@ -681,24 +729,23 @@ check(set(sample), s + newsize*struct.calcsize('lP')) check(frozenset(sample), s + newsize*struct.calcsize('lP')) # setiterator - check(iter(set()), size('P3P')) + check(iter(set()), size(h + 'P3P')) # slice - check(slice(1), size('3P')) + check(slice(1), size(h + '3P')) # str - vh = test.test_support._vheader - check('', struct.calcsize(vh + 'lic')) - check('abc', struct.calcsize(vh + 'lic') + 3) + check('', struct.calcsize(vh + 'li') + 1) + check('abc', struct.calcsize(vh + 'li') + 1 + 3*self.c) # super - check(super(int), size('3P')) + check(super(int), size(h + '3P')) # tuple - check((), vsize('')) - check((1,2,3), vsize('') + 3*self.P) + check((), size(vh)) + check((1,2,3), size(vh) + 3*self.P) # tupleiterator - check(iter(()), size('lP')) + check(iter(()), size(h + 'lP')) # type # (PyTypeObject + PyNumberMethods + PyMappingMethods + # PySequenceMethods + PyBufferProcs) - s = vsize('P2P15Pl4PP9PP11PI') + struct.calcsize('41P 10P 3P 6P') + s = size(vh + 'P2P15Pl4PP9PP11PI') + size('41P 10P 3P 6P') class newstyleclass(object): pass check(newstyleclass, s) @@ -713,40 +760,41 @@ # we need to test for both sizes, because we don't know if the string # has been cached for s in samples: - check(s, size('PPlP') + usize * (len(s) + 1)) + check(s, size(h + 'PPlP') + usize * (len(s) + 1)) # weakref import weakref - check(weakref.ref(int), size('2Pl2P')) + check(weakref.ref(int), size(h + '2Pl2P')) # weakproxy # XXX # weakcallableproxy - check(weakref.proxy(int), size('2Pl2P')) + check(weakref.proxy(int), size(h + '2Pl2P')) # xrange - check(xrange(1), size('3l')) - check(xrange(66000), size('3l')) + check(xrange(1), size(h + '3l')) + check(xrange(66000), size(h + '3l')) def test_pythontypes(self): # check all types defined in Python/ - size = test.test_support.calcobjsize - vsize = test.test_support.calcvobjsize + h = self.header + vh = self.vheader + size = self.calcsize check = self.check_sizeof # _ast.AST import _ast - check(_ast.AST(), size('')) + check(_ast.AST(), size(h + '')) # imp.NullImporter import imp - check(imp.NullImporter(self.file.name), size('')) + check(imp.NullImporter(self.file.name), size(h + '')) try: raise TypeError except TypeError: tb = sys.exc_info()[2] # traceback if tb != None: - check(tb, size('2P2i')) + check(tb, size(h + '2P2i')) # symtable entry # XXX # sys.flags - check(sys.flags, vsize('') + self.P * len(sys.flags)) + check(sys.flags, size(vh) + self.P * len(sys.flags)) def test_main(): diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Lib/test/test_sys_settrace.py --- a/Lib/test/test_sys_settrace.py Sat Jul 19 16:34:33 2014 -0700 +++ b/Lib/test/test_sys_settrace.py Sun Jul 20 10:52:46 2014 -0400 @@ -417,7 +417,7 @@ except ValueError: pass else: - self.fail("exception not raised!") + self.fail("exception not thrown!") except RuntimeError: self.fail("recursion counter not reset") @@ -670,14 +670,6 @@ no_jump_to_non_integers.jump = (2, "Spam") no_jump_to_non_integers.output = [True] -def jump_across_with(output): - with open(test_support.TESTFN, "wb") as fp: - pass - with open(test_support.TESTFN, "wb") as fp: - pass -jump_across_with.jump = (1, 3) -jump_across_with.output = [] - # This verifies that you can't set f_lineno via _getframe or similar # trickery. def no_jump_without_trace_function(): @@ -747,9 +739,6 @@ self.run_test(no_jump_to_non_integers) def test_19_no_jump_without_trace_function(self): no_jump_without_trace_function() - def test_jump_across_with(self): - self.addCleanup(test_support.unlink, test_support.TESTFN) - self.run_test(jump_across_with) def test_20_large_function(self): d = {} diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Lib/test/test_sysconfig.py --- a/Lib/test/test_sysconfig.py Sat Jul 19 16:34:33 2014 -0700 +++ b/Lib/test/test_sysconfig.py Sun Jul 20 10:52:46 2014 -0400 @@ -14,7 +14,6 @@ get_path, get_path_names, _INSTALL_SCHEMES, _get_default_scheme, _expand_vars, get_scheme_names, get_config_var) -import _osx_support class TestSysConfig(unittest.TestCase): @@ -138,7 +137,6 @@ ('Darwin Kernel Version 8.11.1: ' 'Wed Oct 10 18:23:28 PDT 2007; ' 'root:xnu-792.25.20~1/RELEASE_I386'), 'PowerPC')) - _osx_support._remove_original_values(get_config_vars()) get_config_vars()['MACOSX_DEPLOYMENT_TARGET'] = '10.3' get_config_vars()['CFLAGS'] = ('-fno-strict-aliasing -DNDEBUG -g ' @@ -158,7 +156,6 @@ ('Darwin Kernel Version 8.11.1: ' 'Wed Oct 10 18:23:28 PDT 2007; ' 'root:xnu-792.25.20~1/RELEASE_I386'), 'i386')) - _osx_support._remove_original_values(get_config_vars()) get_config_vars()['MACOSX_DEPLOYMENT_TARGET'] = '10.3' get_config_vars()['CFLAGS'] = ('-fno-strict-aliasing -DNDEBUG -g ' @@ -174,7 +171,6 @@ sys.maxint = maxint # macbook with fat binaries (fat, universal or fat64) - _osx_support._remove_original_values(get_config_vars()) get_config_vars()['MACOSX_DEPLOYMENT_TARGET'] = '10.4' get_config_vars()['CFLAGS'] = ('-arch ppc -arch i386 -isysroot ' '/Developer/SDKs/MacOSX10.4u.sdk ' @@ -183,7 +179,6 @@ self.assertEqual(get_platform(), 'macosx-10.4-fat') - _osx_support._remove_original_values(get_config_vars()) get_config_vars()['CFLAGS'] = ('-arch x86_64 -arch i386 -isysroot ' '/Developer/SDKs/MacOSX10.4u.sdk ' '-fno-strict-aliasing -fno-common ' @@ -191,21 +186,18 @@ self.assertEqual(get_platform(), 'macosx-10.4-intel') - _osx_support._remove_original_values(get_config_vars()) get_config_vars()['CFLAGS'] = ('-arch x86_64 -arch ppc -arch i386 -isysroot ' '/Developer/SDKs/MacOSX10.4u.sdk ' '-fno-strict-aliasing -fno-common ' '-dynamic -DNDEBUG -g -O3') self.assertEqual(get_platform(), 'macosx-10.4-fat3') - _osx_support._remove_original_values(get_config_vars()) get_config_vars()['CFLAGS'] = ('-arch ppc64 -arch x86_64 -arch ppc -arch i386 -isysroot ' '/Developer/SDKs/MacOSX10.4u.sdk ' '-fno-strict-aliasing -fno-common ' '-dynamic -DNDEBUG -g -O3') self.assertEqual(get_platform(), 'macosx-10.4-universal') - _osx_support._remove_original_values(get_config_vars()) get_config_vars()['CFLAGS'] = ('-arch x86_64 -arch ppc64 -isysroot ' '/Developer/SDKs/MacOSX10.4u.sdk ' '-fno-strict-aliasing -fno-common ' @@ -214,7 +206,6 @@ self.assertEqual(get_platform(), 'macosx-10.4-fat64') for arch in ('ppc', 'i386', 'x86_64', 'ppc64'): - _osx_support._remove_original_values(get_config_vars()) get_config_vars()['CFLAGS'] = ('-arch %s -isysroot ' '/Developer/SDKs/MacOSX10.4u.sdk ' '-fno-strict-aliasing -fno-common ' diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Lib/test/test_tarfile.py --- a/Lib/test/test_tarfile.py Sat Jul 19 16:34:33 2014 -0700 +++ b/Lib/test/test_tarfile.py Sun Jul 20 10:52:46 2014 -0400 @@ -1,7 +1,6 @@ # -*- coding: iso-8859-15 -*- import sys -import io import os import shutil import StringIO @@ -155,83 +154,6 @@ def test_fileobj_symlink2(self): self._test_fileobj_link("./ustar/linktest2/symtype", "ustar/linktest1/regtype") - def test_issue14160(self): - self._test_fileobj_link("symtype2", "ustar/regtype") - - -class ListTest(ReadTest, unittest.TestCase): - - # Override setUp to use default encoding (UTF-8) - def setUp(self): - self.tar = tarfile.open(self.tarname, mode=self.mode) - - def test_list(self): - with test_support.captured_stdout() as t: - self.tar.list(verbose=False) - out = t.getvalue() - self.assertIn('ustar/conttype', out) - self.assertIn('ustar/regtype', out) - self.assertIn('ustar/lnktype', out) - self.assertIn('ustar' + ('/12345' * 40) + '67/longname', out) - self.assertIn('./ustar/linktest2/symtype', out) - self.assertIn('./ustar/linktest2/lnktype', out) - # Make sure it puts trailing slash for directory - self.assertIn('ustar/dirtype/', out) - self.assertIn('ustar/dirtype-with-size/', out) - # Make sure it is able to print non-ASCII characters - self.assertIn('ustar/umlauts-' - '\xc4\xd6\xdc\xe4\xf6\xfc\xdf', out) - self.assertIn('misc/regtype-hpux-signed-chksum-' - '\xc4\xd6\xdc\xe4\xf6\xfc\xdf', out) - self.assertIn('misc/regtype-old-v7-signed-chksum-' - '\xc4\xd6\xdc\xe4\xf6\xfc\xdf', out) - # Make sure it prints files separated by one newline without any - # 'ls -l'-like accessories if verbose flag is not being used - # ... - # ustar/conttype - # ustar/regtype - # ... - self.assertRegexpMatches(out, r'ustar/conttype ?\r?\n' - r'ustar/regtype ?\r?\n') - # Make sure it does not print the source of link without verbose flag - self.assertNotIn('link to', out) - self.assertNotIn('->', out) - - def test_list_verbose(self): - with test_support.captured_stdout() as t: - self.tar.list(verbose=True) - out = t.getvalue() - # Make sure it prints files separated by one newline with 'ls -l'-like - # accessories if verbose flag is being used - # ... - # ?rw-r--r-- tarfile/tarfile 7011 2003-01-06 07:19:43 ustar/conttype - # ?rw-r--r-- tarfile/tarfile 7011 2003-01-06 07:19:43 ustar/regtype - # ... - self.assertRegexpMatches(out, (r'-rw-r--r-- tarfile/tarfile\s+7011 ' - r'\d{4}-\d\d-\d\d\s+\d\d:\d\d:\d\d ' - r'ustar/\w+type ?\r?\n') * 2) - # Make sure it prints the source of link with verbose flag - self.assertIn('ustar/symtype -> regtype', out) - self.assertIn('./ustar/linktest2/symtype -> ../linktest1/regtype', out) - self.assertIn('./ustar/linktest2/lnktype link to ' - './ustar/linktest1/regtype', out) - self.assertIn('gnu' + ('/123' * 125) + '/longlink link to gnu' + - ('/123' * 125) + '/longname', out) - self.assertIn('pax' + ('/123' * 125) + '/longlink link to pax' + - ('/123' * 125) + '/longname', out) - - -class GzipListTest(ListTest): - tarname = gzipname - mode = "r:gz" - taropen = tarfile.TarFile.gzopen - - -class Bz2ListTest(ListTest): - tarname = bz2name - mode = "r:bz2" - taropen = tarfile.TarFile.bz2open - class CommonReadTest(ReadTest): @@ -256,14 +178,6 @@ self.assertRaises(tarfile.ReadError, tarfile.open, tmpname, self.mode) self.assertRaises(tarfile.ReadError, tarfile.open, tmpname) - def test_non_existent_tarfile(self): - # Test for issue11513: prevent non-existent gzipped tarfiles raising - # multiple exceptions. - exctype = OSError if '|' in self.mode else IOError - with self.assertRaisesRegexp(exctype, "xxx") as ex: - tarfile.open("xxx", self.mode) - self.assertEqual(ex.exception.errno, errno.ENOENT) - def test_ignore_zeros(self): # Test TarFile's ignore_zeros option. if self.mode.endswith(":gz"): @@ -288,62 +202,25 @@ class MiscReadTest(CommonReadTest): - taropen = tarfile.TarFile.taropen - - def requires_name_attribute(self): - pass def test_no_name_argument(self): - self.requires_name_attribute() - with open(self.tarname, "rb") as fobj: - self.assertIsInstance(fobj.name, str) - with tarfile.open(fileobj=fobj, mode=self.mode) as tar: - self.assertIsInstance(tar.name, str) - self.assertEqual(tar.name, os.path.abspath(fobj.name)) + fobj = open(self.tarname, "rb") + tar = tarfile.open(fileobj=fobj, mode=self.mode) + self.assertEqual(tar.name, os.path.abspath(fobj.name)) def test_no_name_attribute(self): data = open(self.tarname, "rb").read() fobj = StringIO.StringIO(data) self.assertRaises(AttributeError, getattr, fobj, "name") tar = tarfile.open(fileobj=fobj, mode=self.mode) - self.assertIsNone(tar.name) + self.assertEqual(tar.name, None) def test_empty_name_attribute(self): data = open(self.tarname, "rb").read() fobj = StringIO.StringIO(data) fobj.name = "" tar = tarfile.open(fileobj=fobj, mode=self.mode) - self.assertIsNone(tar.name) - - def test_int_name_attribute(self): - # Issue 21044: tarfile.open() should handle fileobj with an integer - # 'name' attribute. - fd = os.open(self.tarname, os.O_RDONLY) - with io.open(fd, 'rb') as fobj: - self.assertIsInstance(fobj.name, int) - with tarfile.open(fileobj=fobj, mode=self.mode) as tar: - self.assertIsNone(tar.name) - - @test_support.requires_unicode - def test_unicode_name_attribute(self): - self.requires_name_attribute() - tarname = unicode(self.tarname, test_support.TESTFN_ENCODING) - with io.open(tarname, 'rb') as fobj: - self.assertIsInstance(fobj.name, unicode) - with tarfile.open(fileobj=fobj, mode=self.mode) as tar: - self.assertIsInstance(tar.name, unicode) - self.assertEqual(tar.name, os.path.abspath(fobj.name)) - - def test_illegal_mode_arg(self): - with open(tmpname, 'wb'): - pass - self.addCleanup(os.unlink, tmpname) - with self.assertRaisesRegexp(ValueError, 'mode must be '): - tar = self.taropen(tmpname, 'q') - with self.assertRaisesRegexp(ValueError, 'mode must be '): - tar = self.taropen(tmpname, 'rw') - with self.assertRaisesRegexp(ValueError, 'mode must be '): - tar = self.taropen(tmpname, '') + self.assertEqual(tar.name, None) def test_fileobj_with_offset(self): # Skip the first member and store values from the second member @@ -380,7 +257,7 @@ def test_fail_comp(self): # For Gzip and Bz2 Tests: fail with a ReadError on an uncompressed file. if self.mode == "r:": - self.skipTest('needs a gz or bz2 mode') + return self.assertRaises(tarfile.ReadError, tarfile.open, tarname, self.mode) fobj = open(tarname, "rb") self.assertRaises(tarfile.ReadError, tarfile.open, fileobj=fobj, mode=self.mode) @@ -417,21 +294,26 @@ def test_extract_hardlink(self): # Test hardlink extraction (e.g. bug #857297). - with tarfile.open(tarname, errorlevel=1, encoding="iso8859-1") as tar: - tar.extract("ustar/regtype", TEMPDIR) - self.addCleanup(os.remove, os.path.join(TEMPDIR, "ustar/regtype")) + tar = tarfile.open(tarname, errorlevel=1, encoding="iso8859-1") + tar.extract("ustar/regtype", TEMPDIR) + try: tar.extract("ustar/lnktype", TEMPDIR) - self.addCleanup(os.remove, os.path.join(TEMPDIR, "ustar/lnktype")) - with open(os.path.join(TEMPDIR, "ustar/lnktype"), "rb") as f: - data = f.read() - self.assertEqual(md5sum(data), md5_regtype) + except EnvironmentError, e: + if e.errno == errno.ENOENT: + self.fail("hardlink not extracted properly") + data = open(os.path.join(TEMPDIR, "ustar/lnktype"), "rb").read() + self.assertEqual(md5sum(data), md5_regtype) + + try: tar.extract("ustar/symtype", TEMPDIR) - self.addCleanup(os.remove, os.path.join(TEMPDIR, "ustar/symtype")) - with open(os.path.join(TEMPDIR, "ustar/symtype"), "rb") as f: - data = f.read() - self.assertEqual(md5sum(data), md5_regtype) + except EnvironmentError, e: + if e.errno == errno.ENOENT: + self.fail("symlink not extracted properly") + + data = open(os.path.join(TEMPDIR, "ustar/symtype"), "rb").read() + self.assertEqual(md5sum(data), md5_regtype) def test_extractall(self): # Test if extractall() correctly restores directory permissions @@ -465,14 +347,6 @@ finally: os.remove(empty) - def test_parallel_iteration(self): - # Issue #16601: Restarting iteration over tarfile continued - # from where it left off. - with tarfile.open(self.tarname) as tar: - for m1, m2 in zip(tar, tar): - self.assertEqual(m1.offset, m2.offset) - self.assertEqual(m1.name, m2.name) - class StreamReadTest(CommonReadTest): @@ -566,12 +440,14 @@ def test_detect_fileobj(self): self._test_modes(self._testfunc_fileobj) - @unittest.skipUnless(bz2, 'requires bz2') def test_detect_stream_bz2(self): # Originally, tarfile's stream detection looked for the string # "BZh91" at the start of the file. This is incorrect because # the '9' represents the blocksize (900kB). If the file was # compressed using another blocksize autodetection fails. + if not bz2: + return + with open(tarname, "rb") as fobj: data = fobj.read() @@ -757,12 +633,6 @@ tar.addfile(tarfile.TarInfo("foo")) tar.close() self.assertTrue(fobj.closed is False, "external fileobjs must never closed") - # Issue #20238: Incomplete gzip output with mode="w:gz" - data = fobj.getvalue() - del tar - test_support.gc_collect() - self.assertFalse(fobj.closed) - self.assertEqual(data, fobj.getvalue()) class WriteTest(WriteTestBase): @@ -985,7 +855,7 @@ tar = tarfile.open(tmpname, "r") for t in tar: - self.assertTrue(t.name == "." or t.name.startswith("./")) + self.assert_(t.name == "." or t.name.startswith("./")) tar.close() finally: os.chdir(cwd) @@ -1079,22 +949,6 @@ os.unlink(temparchive) shutil.rmtree(tempdir) - def test_open_nonwritable_fileobj(self): - for exctype in IOError, EOFError, RuntimeError: - class BadFile(StringIO.StringIO): - first = True - def write(self, data): - if self.first: - self.first = False - raise exctype - - f = BadFile() - with self.assertRaises(exctype): - tar = tarfile.open(tmpname, self.mode, fileobj=f, - format=tarfile.PAX_FORMAT, - pax_headers={'non': 'empty'}) - self.assertFalse(f.closed) - class StreamWriteTest(WriteTestBase): mode = "w|" @@ -1122,11 +976,12 @@ self.assertTrue(data.count("\0") == tarfile.RECORDSIZE, "incorrect zero padding") - @unittest.skipIf(sys.platform == 'win32', 'not appropriate for Windows') - @unittest.skipUnless(hasattr(os, 'umask'), 'requires os.umask') def test_file_mode(self): # Test for issue #8464: Create files with correct # permissions. + if sys.platform == "win32" or not hasattr(os, "umask"): + return + if os.path.exists(tmpname): os.remove(tmpname) @@ -1139,13 +994,6 @@ finally: os.umask(original_umask) - def test_issue13639(self): - try: - with tarfile.open(unicode(tmpname, sys.getfilesystemencoding()), self.mode): - pass - except UnicodeDecodeError: - self.fail("_Stream failed to write unicode filename") - class GNUWriteTest(unittest.TestCase): # This testcase checks for correct creation of GNU Longname @@ -1499,13 +1347,15 @@ self._add_testfile() self._test(names=["foo", "bar"]) - @unittest.skipUnless(gzip, 'requires gzip') def test_append_gz(self): + if gzip is None: + return self._create_testtar("w:gz") self.assertRaises(tarfile.ReadError, tarfile.open, tmpname, "a") - @unittest.skipUnless(bz2, 'requires bz2') def test_append_bz2(self): + if bz2 is None: + return self._create_testtar("w:bz2") self.assertRaises(tarfile.ReadError, tarfile.open, tmpname, "a") @@ -1677,7 +1527,6 @@ class GzipMiscReadTest(MiscReadTest): tarname = gzipname mode = "r:gz" - taropen = tarfile.TarFile.gzopen class GzipUstarReadTest(UstarReadTest): tarname = gzipname mode = "r:gz" @@ -1693,9 +1542,6 @@ class Bz2MiscReadTest(MiscReadTest): tarname = bz2name mode = "r:bz2" - taropen = tarfile.TarFile.bz2open - def requires_name_attribute(self): - self.skipTest("BZ2File have no name attribute") class Bz2UstarReadTest(UstarReadTest): tarname = bz2name mode = "r:bz2" @@ -1748,7 +1594,6 @@ MemberReadTest, GNUReadTest, PaxReadTest, - ListTest, WriteTest, StreamWriteTest, GNUWriteTest, @@ -1780,7 +1625,6 @@ GzipMiscReadTest, GzipUstarReadTest, GzipStreamReadTest, - GzipListTest, GzipWriteTest, GzipStreamWriteTest, ] @@ -1795,7 +1639,6 @@ Bz2MiscReadTest, Bz2UstarReadTest, Bz2StreamReadTest, - Bz2ListTest, Bz2WriteTest, Bz2StreamWriteTest, Bz2PartialReadTest, diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Lib/test/test_tcl.py --- a/Lib/test/test_tcl.py Sat Jul 19 16:34:33 2014 -0700 +++ b/Lib/test/test_tcl.py Sun Jul 20 10:52:46 2014 -0400 @@ -1,8 +1,8 @@ +#!/usr/bin/env python + import unittest -import sys import os from test import test_support -from subprocess import Popen, PIPE # Skip this test if the _tkinter module wasn't built. _tkinter = test_support.import_module('_tkinter') @@ -10,34 +10,6 @@ from Tkinter import Tcl from _tkinter import TclError -try: - from _testcapi import INT_MAX, PY_SSIZE_T_MAX -except ImportError: - INT_MAX = PY_SSIZE_T_MAX = sys.maxsize - -tcl_version = _tkinter.TCL_VERSION.split('.') -try: - for i in range(len(tcl_version)): - tcl_version[i] = int(tcl_version[i]) -except ValueError: - pass -tcl_version = tuple(tcl_version) - -_tk_patchlevel = None -def get_tk_patchlevel(): - global _tk_patchlevel - if _tk_patchlevel is None: - tcl = Tcl() - patchlevel = [] - for x in tcl.call('info', 'patchlevel').split('.'): - try: - x = int(x, 10) - except ValueError: - x = -1 - patchlevel.append(x) - _tk_patchlevel = tuple(patchlevel) - return _tk_patchlevel - class TkinterTest(unittest.TestCase): @@ -50,7 +22,6 @@ def setUp(self): self.interp = Tcl() - self.wantobjects = self.interp.tk.wantobjects() def testEval(self): tcl = self.interp @@ -127,53 +98,6 @@ tcl = self.interp self.assertRaises(TclError,tcl.unsetvar,'a') - def test_getint(self): - tcl = self.interp.tk - self.assertEqual(tcl.getint(' 42 '), 42) - self.assertEqual(tcl.getint(42), 42) - self.assertRaises(TypeError, tcl.getint) - self.assertRaises(TypeError, tcl.getint, '42', '10') - self.assertRaises(TypeError, tcl.getint, 42.0) - self.assertRaises(TclError, tcl.getint, 'a') - self.assertRaises((TypeError, ValueError, TclError), - tcl.getint, '42\0') - if test_support.have_unicode: - self.assertEqual(tcl.getint(unicode('42')), 42) - self.assertRaises((UnicodeEncodeError, ValueError, TclError), - tcl.getint, '42' + unichr(0xd800)) - - def test_getdouble(self): - tcl = self.interp.tk - self.assertEqual(tcl.getdouble(' 42 '), 42.0) - self.assertEqual(tcl.getdouble(' 42.5 '), 42.5) - self.assertEqual(tcl.getdouble(42.5), 42.5) - self.assertRaises(TypeError, tcl.getdouble) - self.assertRaises(TypeError, tcl.getdouble, '42.5', '10') - self.assertRaises(TypeError, tcl.getdouble, 42) - self.assertRaises(TclError, tcl.getdouble, 'a') - self.assertRaises((TypeError, ValueError, TclError), - tcl.getdouble, '42.5\0') - if test_support.have_unicode: - self.assertEqual(tcl.getdouble(unicode('42.5')), 42.5) - self.assertRaises((UnicodeEncodeError, ValueError, TclError), - tcl.getdouble, '42.5' + unichr(0xd800)) - - def test_getboolean(self): - tcl = self.interp.tk - self.assertIs(tcl.getboolean('on'), True) - self.assertIs(tcl.getboolean('1'), True) - self.assertEqual(tcl.getboolean(42), 42) - self.assertRaises(TypeError, tcl.getboolean) - self.assertRaises(TypeError, tcl.getboolean, 'on', '1') - self.assertRaises(TypeError, tcl.getboolean, 1.0) - self.assertRaises(TclError, tcl.getboolean, 'a') - self.assertRaises((TypeError, ValueError, TclError), - tcl.getboolean, 'on\0') - if test_support.have_unicode: - self.assertIs(tcl.getboolean(unicode('on')), True) - self.assertRaises((UnicodeEncodeError, ValueError, TclError), - tcl.getboolean, 'on' + unichr(0xd800)) - def testEvalFile(self): tcl = self.interp filename = "testEvalFile.tcl" @@ -190,18 +114,6 @@ self.assertEqual(tcl.eval('set b'),'2') self.assertEqual(tcl.eval('set c'),'3') - def test_evalfile_null_in_result(self): - tcl = self.interp - with open(test_support.TESTFN, 'wb') as f: - self.addCleanup(test_support.unlink, test_support.TESTFN) - f.write(""" - set a "a\0b" - set b "a\\0b" - """) - tcl.evalfile(test_support.TESTFN) - self.assertEqual(tcl.eval('set a'), 'a\xc0\x80b') - self.assertEqual(tcl.eval('set b'), 'a\xc0\x80b') - def testEvalFileException(self): tcl = self.interp filename = "doesnotexists" @@ -215,428 +127,34 @@ tcl = self.interp self.assertRaises(TclError,tcl.eval,'package require DNE') - @unittest.skipUnless(sys.platform == 'win32', "only applies to Windows") def testLoadWithUNC(self): + import sys + if sys.platform != 'win32': + return + # Build a UNC path from the regular path. # Something like # \\%COMPUTERNAME%\c$\python27\python.exe fullname = os.path.abspath(sys.executable) if fullname[1] != ':': - self.skipTest('unusable path: %r' % fullname) + return unc_name = r'\\%s\%s$\%s' % (os.environ['COMPUTERNAME'], fullname[0], fullname[3:]) with test_support.EnvironmentVarGuard() as env: env.unset("TCL_LIBRARY") - cmd = '%s -c "import Tkinter; print Tkinter"' % (unc_name,) + f = os.popen('%s -c "import Tkinter; print Tkinter"' % (unc_name,)) - try: - p = Popen(cmd, stdout=PIPE, stderr=PIPE) - except WindowsError as e: - if e.winerror == 5: - self.skipTest('Not permitted to start the child process') - else: - raise + self.assertTrue('Tkinter.py' in f.read()) + # exit code must be zero + self.assertEqual(f.close(), None) - out_data, err_data = p.communicate() - - msg = '\n\n'.join(['"Tkinter.py" not in output', - 'Command:', cmd, - 'stdout:', out_data, - 'stderr:', err_data]) - - self.assertIn('Tkinter.py', out_data, msg) - - self.assertEqual(p.wait(), 0, 'Non-zero exit code') - - - def test_exprstring(self): - tcl = self.interp - tcl.call('set', 'a', 3) - tcl.call('set', 'b', 6) - def check(expr, expected): - result = tcl.exprstring(expr) - self.assertEqual(result, expected) - self.assertIsInstance(result, str) - - self.assertRaises(TypeError, tcl.exprstring) - self.assertRaises(TypeError, tcl.exprstring, '8.2', '+6') - self.assertRaises(TclError, tcl.exprstring, 'spam') - check('', '0') - check('8.2 + 6', '14.2') - check('3.1 + $a', '6.1') - check('2 + "$a.$b"', '5.6') - check('4*[llength "6 2"]', '8') - check('{word one} < "word $a"', '0') - check('4*2 < 7', '0') - check('hypot($a, 4)', '5.0') - check('5 / 4', '1') - check('5 / 4.0', '1.25') - check('5 / ( [string length "abcd"] + 0.0 )', '1.25') - check('20.0/5.0', '4.0') - check('"0x03" > "2"', '1') - check('[string length "a\xc2\xbd\xe2\x82\xac"]', '3') - check(r'[string length "a\xbd\u20ac"]', '3') - check('"abc"', 'abc') - check('"a\xc2\xbd\xe2\x82\xac"', 'a\xc2\xbd\xe2\x82\xac') - check(r'"a\xbd\u20ac"', 'a\xc2\xbd\xe2\x82\xac') - check(r'"a\0b"', 'a\xc0\x80b') - if tcl_version >= (8, 5): - check('2**64', str(2**64)) - - def test_exprdouble(self): - tcl = self.interp - tcl.call('set', 'a', 3) - tcl.call('set', 'b', 6) - def check(expr, expected): - result = tcl.exprdouble(expr) - self.assertEqual(result, expected) - self.assertIsInstance(result, float) - - self.assertRaises(TypeError, tcl.exprdouble) - self.assertRaises(TypeError, tcl.exprdouble, '8.2', '+6') - self.assertRaises(TclError, tcl.exprdouble, 'spam') - check('', 0.0) - check('8.2 + 6', 14.2) - check('3.1 + $a', 6.1) - check('2 + "$a.$b"', 5.6) - check('4*[llength "6 2"]', 8.0) - check('{word one} < "word $a"', 0.0) - check('4*2 < 7', 0.0) - check('hypot($a, 4)', 5.0) - check('5 / 4', 1.0) - check('5 / 4.0', 1.25) - check('5 / ( [string length "abcd"] + 0.0 )', 1.25) - check('20.0/5.0', 4.0) - check('"0x03" > "2"', 1.0) - check('[string length "a\xc2\xbd\xe2\x82\xac"]', 3.0) - check(r'[string length "a\xbd\u20ac"]', 3.0) - self.assertRaises(TclError, tcl.exprdouble, '"abc"') - if tcl_version >= (8, 5): - check('2**64', float(2**64)) - - def test_exprlong(self): - tcl = self.interp - tcl.call('set', 'a', 3) - tcl.call('set', 'b', 6) - def check(expr, expected): - result = tcl.exprlong(expr) - self.assertEqual(result, expected) - self.assertIsInstance(result, int) - - self.assertRaises(TypeError, tcl.exprlong) - self.assertRaises(TypeError, tcl.exprlong, '8.2', '+6') - self.assertRaises(TclError, tcl.exprlong, 'spam') - check('', 0) - check('8.2 + 6', 14) - check('3.1 + $a', 6) - check('2 + "$a.$b"', 5) - check('4*[llength "6 2"]', 8) - check('{word one} < "word $a"', 0) - check('4*2 < 7', 0) - check('hypot($a, 4)', 5) - check('5 / 4', 1) - check('5 / 4.0', 1) - check('5 / ( [string length "abcd"] + 0.0 )', 1) - check('20.0/5.0', 4) - check('"0x03" > "2"', 1) - check('[string length "a\xc2\xbd\xe2\x82\xac"]', 3) - check(r'[string length "a\xbd\u20ac"]', 3) - self.assertRaises(TclError, tcl.exprlong, '"abc"') - if tcl_version >= (8, 5): - self.assertRaises(TclError, tcl.exprlong, '2**64') - - def test_exprboolean(self): - tcl = self.interp - tcl.call('set', 'a', 3) - tcl.call('set', 'b', 6) - def check(expr, expected): - result = tcl.exprboolean(expr) - self.assertEqual(result, expected) - self.assertIsInstance(result, int) - self.assertNotIsInstance(result, bool) - - self.assertRaises(TypeError, tcl.exprboolean) - self.assertRaises(TypeError, tcl.exprboolean, '8.2', '+6') - self.assertRaises(TclError, tcl.exprboolean, 'spam') - check('', False) - for value in ('0', 'false', 'no', 'off'): - check(value, False) - check('"%s"' % value, False) - check('{%s}' % value, False) - for value in ('1', 'true', 'yes', 'on'): - check(value, True) - check('"%s"' % value, True) - check('{%s}' % value, True) - check('8.2 + 6', True) - check('3.1 + $a', True) - check('2 + "$a.$b"', True) - check('4*[llength "6 2"]', True) - check('{word one} < "word $a"', False) - check('4*2 < 7', False) - check('hypot($a, 4)', True) - check('5 / 4', True) - check('5 / 4.0', True) - check('5 / ( [string length "abcd"] + 0.0 )', True) - check('20.0/5.0', True) - check('"0x03" > "2"', True) - check('[string length "a\xc2\xbd\xe2\x82\xac"]', True) - check(r'[string length "a\xbd\u20ac"]', True) - self.assertRaises(TclError, tcl.exprboolean, '"abc"') - if tcl_version >= (8, 5): - check('2**64', True) - - def test_passing_values(self): - def passValue(value): - return self.interp.call('set', '_', value) - - self.assertEqual(passValue(True), True if self.wantobjects else '1') - self.assertEqual(passValue(False), False if self.wantobjects else '0') - self.assertEqual(passValue('string'), 'string') - self.assertEqual(passValue('string\xbd'), 'string\xbd') - self.assertEqual(passValue('string\xe2\x82\xac'), u'string\u20ac') - self.assertEqual(passValue(u'string'), u'string') - self.assertEqual(passValue(u'string\xbd'), u'string\xbd') - self.assertEqual(passValue(u'string\u20ac'), u'string\u20ac') - self.assertEqual(passValue('str\x00ing'), 'str\x00ing') - self.assertEqual(passValue('str\xc0\x80ing'), 'str\x00ing') - self.assertEqual(passValue(u'str\x00ing'), u'str\x00ing') - self.assertEqual(passValue(u'str\x00ing\xbd'), u'str\x00ing\xbd') - self.assertEqual(passValue(u'str\x00ing\u20ac'), u'str\x00ing\u20ac') - for i in (0, 1, -1, int(2**31-1), int(-2**31)): - self.assertEqual(passValue(i), i if self.wantobjects else str(i)) - for f in (0.0, 1.0, -1.0, 1//3, 1/3.0, - sys.float_info.min, sys.float_info.max, - -sys.float_info.min, -sys.float_info.max): - if self.wantobjects: - self.assertEqual(passValue(f), f) - else: - self.assertEqual(float(passValue(f)), f) - if self.wantobjects: - f = passValue(float('nan')) - self.assertNotEqual(f, f) - self.assertEqual(passValue(float('inf')), float('inf')) - self.assertEqual(passValue(-float('inf')), -float('inf')) - else: - self.assertEqual(float(passValue(float('inf'))), float('inf')) - self.assertEqual(float(passValue(-float('inf'))), -float('inf')) - # XXX NaN representation can be not parsable by float() - self.assertEqual(passValue((1, '2', (3.4,))), - (1, '2', (3.4,)) if self.wantobjects else '1 2 3.4') - - def test_user_command(self): - result = [] - def testfunc(arg): - result.append(arg) - return arg - self.interp.createcommand('testfunc', testfunc) - self.addCleanup(self.interp.tk.deletecommand, 'testfunc') - def check(value, expected, expected2=None, eq=self.assertEqual): - if expected2 is None: - expected2 = expected - del result[:] - r = self.interp.call('testfunc', value) - self.assertEqual(len(result), 1) - self.assertIsInstance(result[0], (str, unicode)) - eq(result[0], expected2) - self.assertIsInstance(r, (str, unicode)) - eq(r, expected2) - def float_eq(actual, expected): - expected = float(expected) - self.assertAlmostEqual(float(actual), expected, - delta=abs(expected) * 1e-10) - - check(True, '1') - check(False, '0') - check('string', 'string') - check('string\xbd', 'string\xbd') - check('string\xe2\x82\xac', 'string\xe2\x82\xac', u'string\u20ac') - check(u'string', u'string') - check(u'string\xbd', 'string\xc2\xbd', u'string\xbd') - check(u'string\u20ac', 'string\xe2\x82\xac', u'string\u20ac') - check('str\xc0\x80ing', 'str\xc0\x80ing', u'str\x00ing') - check('str\xc0\x80ing\xe2\x82\xac', 'str\xc0\x80ing\xe2\x82\xac', u'str\x00ing\u20ac') - check(u'str\x00ing', 'str\xc0\x80ing', u'str\x00ing') - check(u'str\x00ing\xbd', 'str\xc0\x80ing\xc2\xbd', u'str\x00ing\xbd') - check(u'str\x00ing\u20ac', 'str\xc0\x80ing\xe2\x82\xac', u'str\x00ing\u20ac') - for i in (0, 1, -1, 2**31-1, -2**31): - check(i, str(i)) - for f in (0.0, 1.0, -1.0): - check(f, repr(f)) - for f in (1/3.0, sys.float_info.min, sys.float_info.max, - -sys.float_info.min, -sys.float_info.max): - check(f, f, eq=float_eq) - check(float('inf'), 'Inf', eq=float_eq) - check(-float('inf'), '-Inf', eq=float_eq) - # XXX NaN representation can be not parsable by float() - check((), '') - check((1, (2,), (3, 4), '5 6', ()), '1 2 {3 4} {5 6} {}') - - def test_splitlist(self): - splitlist = self.interp.tk.splitlist - call = self.interp.tk.call - self.assertRaises(TypeError, splitlist) - self.assertRaises(TypeError, splitlist, 'a', 'b') - self.assertRaises(TypeError, splitlist, 2) - testcases = [ - ('2', ('2',)), - ('', ()), - ('{}', ('',)), - ('""', ('',)), - ('a\n b\t\r c\n ', ('a', 'b', 'c')), - (u'a\n b\t\r c\n ', ('a', 'b', 'c')), - ('a \xe2\x82\xac', ('a', '\xe2\x82\xac')), - (u'a \u20ac', ('a', '\xe2\x82\xac')), - ('a\xc0\x80b c\xc0\x80d', ('a\xc0\x80b', 'c\xc0\x80d')), - ('a {b c}', ('a', 'b c')), - (r'a b\ c', ('a', 'b c')), - (('a', 'b c'), ('a', 'b c')), - ('a 2', ('a', '2')), - (('a', 2), ('a', 2)), - ('a 3.4', ('a', '3.4')), - (('a', 3.4), ('a', 3.4)), - ((), ()), - (call('list', 1, '2', (3.4,)), - (1, '2', (3.4,)) if self.wantobjects else - ('1', '2', '3.4')), - ] - if tcl_version >= (8, 5): - if not self.wantobjects: - expected = ('12', '\xe2\x82\xac', '\xe2\x82\xac', '3.4') - elif get_tk_patchlevel() < (8, 5, 5): - # Before 8.5.5 dicts were converted to lists through string - expected = ('12', u'\u20ac', u'\u20ac', '3.4') - else: - expected = (12, u'\u20ac', u'\u20ac', (3.4,)) - testcases += [ - (call('dict', 'create', 12, u'\u20ac', '\xe2\x82\xac', (3.4,)), - expected), - ] - for arg, res in testcases: - self.assertEqual(splitlist(arg), res) - self.assertRaises(TclError, splitlist, '{') - - def test_split(self): - split = self.interp.tk.split - call = self.interp.tk.call - self.assertRaises(TypeError, split) - self.assertRaises(TypeError, split, 'a', 'b') - self.assertRaises(TypeError, split, 2) - testcases = [ - ('2', '2'), - ('', ''), - ('{}', ''), - ('""', ''), - ('{', '{'), - ('a\n b\t\r c\n ', ('a', 'b', 'c')), - (u'a\n b\t\r c\n ', ('a', 'b', 'c')), - ('a \xe2\x82\xac', ('a', '\xe2\x82\xac')), - (u'a \u20ac', ('a', '\xe2\x82\xac')), - ('a\xc0\x80b', 'a\xc0\x80b'), - ('a\xc0\x80b c\xc0\x80d', ('a\xc0\x80b', 'c\xc0\x80d')), - ('a {b c}', ('a', ('b', 'c'))), - (r'a b\ c', ('a', ('b', 'c'))), - (('a', 'b c'), ('a', ('b', 'c'))), - (('a', u'b c'), ('a', ('b', 'c'))), - ('a 2', ('a', '2')), - (('a', 2), ('a', 2)), - ('a 3.4', ('a', '3.4')), - (('a', 3.4), ('a', 3.4)), - (('a', (2, 3.4)), ('a', (2, 3.4))), - ((), ()), - (call('list', 1, '2', (3.4,)), - (1, '2', (3.4,)) if self.wantobjects else - ('1', '2', '3.4')), - ] - if tcl_version >= (8, 5): - if not self.wantobjects: - expected = ('12', '\xe2\x82\xac', '\xe2\x82\xac', '3.4') - elif get_tk_patchlevel() < (8, 5, 5): - # Before 8.5.5 dicts were converted to lists through string - expected = ('12', u'\u20ac', u'\u20ac', '3.4') - else: - expected = (12, u'\u20ac', u'\u20ac', (3.4,)) - testcases += [ - (call('dict', 'create', 12, u'\u20ac', '\xe2\x82\xac', (3.4,)), - expected), - ] - for arg, res in testcases: - self.assertEqual(split(arg), res) - -character_size = 4 if sys.maxunicode > 0xFFFF else 2 - -class BigmemTclTest(unittest.TestCase): - - def setUp(self): - self.interp = Tcl() - - @test_support.cpython_only - @unittest.skipUnless(INT_MAX < PY_SSIZE_T_MAX, "needs UINT_MAX < SIZE_MAX") - @test_support.precisionbigmemtest(size=INT_MAX + 1, memuse=5, dry_run=False) - def test_huge_string_call(self, size): - value = ' ' * size - self.assertRaises(OverflowError, self.interp.call, 'set', '_', value) - - @test_support.cpython_only - @unittest.skipUnless(test_support.have_unicode, 'requires unicode support') - @unittest.skipUnless(INT_MAX < PY_SSIZE_T_MAX, "needs UINT_MAX < SIZE_MAX") - @test_support.precisionbigmemtest(size=INT_MAX + 1, - memuse=2*character_size + 2, - dry_run=False) - def test_huge_unicode_call(self, size): - value = unicode(' ') * size - self.assertRaises(OverflowError, self.interp.call, 'set', '_', value) - - - @test_support.cpython_only - @unittest.skipUnless(INT_MAX < PY_SSIZE_T_MAX, "needs UINT_MAX < SIZE_MAX") - @test_support.precisionbigmemtest(size=INT_MAX + 1, memuse=9, dry_run=False) - def test_huge_string_builtins(self, size): - value = '1' + ' ' * size - self.check_huge_string_builtins(value) - - @test_support.cpython_only - @unittest.skipUnless(test_support.have_unicode, 'requires unicode support') - @unittest.skipUnless(INT_MAX < PY_SSIZE_T_MAX, "needs UINT_MAX < SIZE_MAX") - @test_support.precisionbigmemtest(size=INT_MAX + 1, - memuse=2*character_size + 7, - dry_run=False) - def test_huge_unicode_builtins(self, size): - value = unicode('1' + ' ' * size) - self.check_huge_string_builtins(value) - - def check_huge_string_builtins(self, value): - self.assertRaises(OverflowError, self.interp.tk.getint, value) - self.assertRaises(OverflowError, self.interp.tk.getdouble, value) - self.assertRaises(OverflowError, self.interp.tk.getboolean, value) - self.assertRaises(OverflowError, self.interp.eval, value) - self.assertRaises(OverflowError, self.interp.evalfile, value) - self.assertRaises(OverflowError, self.interp.record, value) - self.assertRaises(OverflowError, self.interp.adderrorinfo, value) - self.assertRaises(OverflowError, self.interp.setvar, value, 'x', 'a') - self.assertRaises(OverflowError, self.interp.setvar, 'x', value, 'a') - self.assertRaises(OverflowError, self.interp.unsetvar, value) - self.assertRaises(OverflowError, self.interp.unsetvar, 'x', value) - self.assertRaises(OverflowError, self.interp.adderrorinfo, value) - self.assertRaises(OverflowError, self.interp.exprstring, value) - self.assertRaises(OverflowError, self.interp.exprlong, value) - self.assertRaises(OverflowError, self.interp.exprboolean, value) - self.assertRaises(OverflowError, self.interp.splitlist, value) - self.assertRaises(OverflowError, self.interp.split, value) - self.assertRaises(OverflowError, self.interp.createcommand, value, max) - self.assertRaises(OverflowError, self.interp.deletecommand, value) - - -def setUpModule(): - if test_support.verbose: - tcl = Tcl() - print 'patchlevel =', tcl.call('info', 'patchlevel') def test_main(): - test_support.run_unittest(TclTest, TkinterTest, BigmemTclTest) + test_support.run_unittest(TclTest, TkinterTest) if __name__ == "__main__": test_main() diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Lib/test/test_telnetlib.py --- a/Lib/test/test_telnetlib.py Sat Jul 19 16:34:33 2014 -0700 +++ b/Lib/test/test_telnetlib.py Sun Jul 20 10:52:46 2014 -0400 @@ -3,7 +3,6 @@ import time import Queue -import unittest from unittest import TestCase from test import test_support threading = test_support.import_module('threading') @@ -92,19 +91,11 @@ self.assertEqual(telnet.sock.gettimeout(), 30) telnet.sock.close() - def testGetters(self): - # Test telnet getter methods - telnet = telnetlib.Telnet(HOST, self.port, timeout=30) - t_sock = telnet.sock - self.assertEqual(telnet.get_socket(), t_sock) - self.assertEqual(telnet.fileno(), t_sock.fileno()) - telnet.sock.close() - def _read_setUp(self): self.evt = threading.Event() self.dataq = Queue.Queue() self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) - self.sock.settimeout(10) + self.sock.settimeout(3) self.port = test_support.bind_port(self.sock) self.thread = threading.Thread(target=server, args=(self.evt,self.sock, self.dataq)) self.thread.start() @@ -144,28 +135,6 @@ self.assertEqual(data, want[0]) self.assertEqual(telnet.read_all(), 'not seen') - def test_read_until_with_poll(self): - """Use select.poll() to implement telnet.read_until().""" - want = ['x' * 10, 'match', 'y' * 10, EOF_sigil] - self.dataq.put(want) - telnet = telnetlib.Telnet(HOST, self.port) - if not telnet._has_poll: - raise unittest.SkipTest('select.poll() is required') - telnet._has_poll = True - self.dataq.join() - data = telnet.read_until('match') - self.assertEqual(data, ''.join(want[:-2])) - - def test_read_until_with_select(self): - """Use select.select() to implement telnet.read_until().""" - want = ['x' * 10, 'match', 'y' * 10, EOF_sigil] - self.dataq.put(want) - telnet = telnetlib.Telnet(HOST, self.port) - telnet._has_poll = False - self.dataq.join() - data = telnet.read_until('match') - self.assertEqual(data, ''.join(want[:-2])) - def test_read_all_A(self): """ read_all() @@ -177,6 +146,7 @@ self.dataq.join() data = telnet.read_all() self.assertEqual(data, ''.join(want[:-1])) + return def _test_blocking(self, func): self.dataq.put([self.block_long, EOF_sigil]) @@ -387,75 +357,8 @@ self.assertEqual('', telnet.read_sb_data()) nego.sb_getter = None # break the nego => telnet cycle - -class ExpectTests(TestCase): - def setUp(self): - self.evt = threading.Event() - self.dataq = Queue.Queue() - self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) - self.sock.settimeout(10) - self.port = test_support.bind_port(self.sock) - self.thread = threading.Thread(target=server, args=(self.evt,self.sock, - self.dataq)) - self.thread.start() - self.evt.wait() - - def tearDown(self): - self.thread.join() - - # use a similar approach to testing timeouts as test_timeout.py - # these will never pass 100% but make the fuzz big enough that it is rare - block_long = 0.6 - block_short = 0.3 - def test_expect_A(self): - """ - expect(expected, [timeout]) - Read until the expected string has been seen, or a timeout is - hit (default is no timeout); may block. - """ - want = ['x' * 10, 'match', 'y' * 10, EOF_sigil] - self.dataq.put(want) - telnet = telnetlib.Telnet(HOST, self.port) - self.dataq.join() - (_,_,data) = telnet.expect(['match']) - self.assertEqual(data, ''.join(want[:-2])) - - def test_expect_B(self): - # test the timeout - it does NOT raise socket.timeout - want = ['hello', self.block_long, 'not seen', EOF_sigil] - self.dataq.put(want) - telnet = telnetlib.Telnet(HOST, self.port) - self.dataq.join() - (_,_,data) = telnet.expect(['not seen'], self.block_short) - self.assertEqual(data, want[0]) - self.assertEqual(telnet.read_all(), 'not seen') - - def test_expect_with_poll(self): - """Use select.poll() to implement telnet.expect().""" - want = ['x' * 10, 'match', 'y' * 10, EOF_sigil] - self.dataq.put(want) - telnet = telnetlib.Telnet(HOST, self.port) - if not telnet._has_poll: - raise unittest.SkipTest('select.poll() is required') - telnet._has_poll = True - self.dataq.join() - (_,_,data) = telnet.expect(['match']) - self.assertEqual(data, ''.join(want[:-2])) - - def test_expect_with_select(self): - """Use select.select() to implement telnet.expect().""" - want = ['x' * 10, 'match', 'y' * 10, EOF_sigil] - self.dataq.put(want) - telnet = telnetlib.Telnet(HOST, self.port) - telnet._has_poll = False - self.dataq.join() - (_,_,data) = telnet.expect(['match']) - self.assertEqual(data, ''.join(want[:-2])) - - def test_main(verbose=None): - test_support.run_unittest(GeneralTests, ReadTests, OptionTests, - ExpectTests) + test_support.run_unittest(GeneralTests, ReadTests, OptionTests) if __name__ == '__main__': test_main() diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Lib/test/test_tempfile.py --- a/Lib/test/test_tempfile.py Sat Jul 19 16:34:33 2014 -0700 +++ b/Lib/test/test_tempfile.py Sun Jul 20 10:52:46 2014 -0400 @@ -1,17 +1,13 @@ # tempfile.py unit tests. import tempfile -import errno -import io import os import signal -import shutil import sys import re import warnings -import contextlib import unittest -from test import test_support as support +from test import test_support warnings.filterwarnings("ignore", category=RuntimeWarning, @@ -181,7 +177,7 @@ # _candidate_tempdir_list contains the expected directories # Make sure the interesting environment variables are all set. - with support.EnvironmentVarGuard() as env: + with test_support.EnvironmentVarGuard() as env: for envname in 'TMPDIR', 'TEMP', 'TMP': dirname = os.getenv(envname) if not dirname: @@ -206,51 +202,8 @@ test_classes.append(test__candidate_tempdir_list) -# We test _get_default_tempdir some more by testing gettempdir. -class TestGetDefaultTempdir(TC): - """Test _get_default_tempdir().""" - - def test_no_files_left_behind(self): - # use a private empty directory - our_temp_directory = tempfile.mkdtemp() - try: - # force _get_default_tempdir() to consider our empty directory - def our_candidate_list(): - return [our_temp_directory] - - with support.swap_attr(tempfile, "_candidate_tempdir_list", - our_candidate_list): - # verify our directory is empty after _get_default_tempdir() - tempfile._get_default_tempdir() - self.assertEqual(os.listdir(our_temp_directory), []) - - def raise_OSError(*args, **kwargs): - raise OSError(-1) - - with support.swap_attr(io, "open", raise_OSError): - # test again with failing io.open() - with self.assertRaises(IOError) as cm: - tempfile._get_default_tempdir() - self.assertEqual(cm.exception.errno, errno.ENOENT) - self.assertEqual(os.listdir(our_temp_directory), []) - - open = io.open - def bad_writer(*args, **kwargs): - fp = open(*args, **kwargs) - fp.write = raise_OSError - return fp - - with support.swap_attr(io, "open", bad_writer): - # test again with failing write() - with self.assertRaises(IOError) as cm: - tempfile._get_default_tempdir() - self.assertEqual(cm.exception.errno, errno.ENOENT) - self.assertEqual(os.listdir(our_temp_directory), []) - finally: - shutil.rmtree(our_temp_directory) - -test_classes.append(TestGetDefaultTempdir) +# We test _get_default_tempdir by testing gettempdir. class test__get_candidate_names(TC): @@ -271,22 +224,6 @@ test_classes.append(test__get_candidate_names) -@contextlib.contextmanager -def _inside_empty_temp_dir(): - dir = tempfile.mkdtemp() - try: - with support.swap_attr(tempfile, 'tempdir', dir): - yield - finally: - support.rmtree(dir) - - -def _mock_candidate_names(*names): - return support.swap_attr(tempfile, - '_get_candidate_names', - lambda: iter(names)) - - class test__mkstemp_inner(TC): """Test the internal function _mkstemp_inner.""" @@ -342,9 +279,10 @@ finally: os.rmdir(dir) - @unittest.skipUnless(has_stat, 'os.stat not available') def test_file_mode(self): # _mkstemp_inner creates files with the proper mode + if not has_stat: + return # ugh, can't use SkipTest. file = self.do_create() mode = stat.S_IMODE(os.stat(file.name).st_mode) @@ -356,11 +294,12 @@ expected = user * (1 + 8 + 64) self.assertEqual(mode, expected) - @unittest.skipUnless(has_spawnl, 'os.spawnl not available') def test_noinherit(self): # _mkstemp_inner file handles are not inherited by child processes + if not has_spawnl: + return # ugh, can't use SkipTest. - if support.verbose: + if test_support.verbose: v="v" else: v="q" @@ -393,44 +332,14 @@ "child process caught fatal signal %d" % -retval) self.assertFalse(retval > 0, "child process reports failure %d"%retval) - @unittest.skipUnless(has_textmode, "text mode not available") def test_textmode(self): # _mkstemp_inner can create files in text mode + if not has_textmode: + return # ugh, can't use SkipTest. self.do_create(bin=0).write("blat\n") # XXX should test that the file really is a text file - def default_mkstemp_inner(self): - return tempfile._mkstemp_inner(tempfile.gettempdir(), - tempfile.template, - '', - tempfile._bin_openflags) - - def test_collision_with_existing_file(self): - # _mkstemp_inner tries another name when a file with - # the chosen name already exists - with _inside_empty_temp_dir(), \ - _mock_candidate_names('aaa', 'aaa', 'bbb'): - (fd1, name1) = self.default_mkstemp_inner() - os.close(fd1) - self.assertTrue(name1.endswith('aaa')) - - (fd2, name2) = self.default_mkstemp_inner() - os.close(fd2) - self.assertTrue(name2.endswith('bbb')) - - def test_collision_with_existing_directory(self): - # _mkstemp_inner tries another name when a directory with - # the chosen name already exists - with _inside_empty_temp_dir(), \ - _mock_candidate_names('aaa', 'aaa', 'bbb'): - dir = tempfile.mkdtemp() - self.assertTrue(dir.endswith('aaa')) - - (fd, name) = self.default_mkstemp_inner() - os.close(fd) - self.assertTrue(name.endswith('bbb')) - test_classes.append(test__mkstemp_inner) @@ -587,9 +496,10 @@ finally: os.rmdir(dir) - @unittest.skipUnless(has_stat, 'os.stat not available') def test_mode(self): # mkdtemp creates directories with the proper mode + if not has_stat: + return # ugh, can't use SkipTest. dir = self.do_create() try: @@ -605,27 +515,6 @@ finally: os.rmdir(dir) - def test_collision_with_existing_file(self): - # mkdtemp tries another name when a file with - # the chosen name already exists - with _inside_empty_temp_dir(), \ - _mock_candidate_names('aaa', 'aaa', 'bbb'): - file = tempfile.NamedTemporaryFile(delete=False) - file.close() - self.assertTrue(file.name.endswith('aaa')) - dir = tempfile.mkdtemp() - self.assertTrue(dir.endswith('bbb')) - - def test_collision_with_existing_directory(self): - # mkdtemp tries another name when a directory with - # the chosen name already exists - with _inside_empty_temp_dir(), \ - _mock_candidate_names('aaa', 'aaa', 'bbb'): - dir1 = tempfile.mkdtemp() - self.assertTrue(dir1.endswith('aaa')) - dir2 = tempfile.mkdtemp() - self.assertTrue(dir2.endswith('bbb')) - test_classes.append(test_mkdtemp) @@ -771,24 +660,6 @@ pass self.assertRaises(ValueError, use_closed) - def test_no_leak_fd(self): - # Issue #21058: don't leak file descriptor when fdopen() fails - old_close = os.close - old_fdopen = os.fdopen - closed = [] - def close(fd): - closed.append(fd) - def fdopen(*args): - raise ValueError() - os.close = close - os.fdopen = fdopen - try: - self.assertRaises(ValueError, tempfile.NamedTemporaryFile) - self.assertEqual(len(closed), 1) - finally: - os.close = old_close - os.fdopen = old_fdopen - # How to test the mode and bufsize parameters? test_classes.append(test_NamedTemporaryFile) @@ -867,17 +738,6 @@ f.write(b'x') self.assertTrue(f._rolled) - def test_xreadlines(self): - f = self.do_create(max_size=20) - f.write(b'abc\n' * 5) - f.seek(0) - self.assertFalse(f._rolled) - self.assertEqual(list(f.xreadlines()), [b'abc\n'] * 5) - f.write(b'x\ny') - self.assertTrue(f._rolled) - f.seek(0) - self.assertEqual(list(f.xreadlines()), [b'abc\n'] * 5 + [b'x\n', b'y']) - def test_sparse(self): # A SpooledTemporaryFile that is written late in the file will extend # when that occurs @@ -933,26 +793,6 @@ seek(0, 0) self.assertTrue(read(70) == 'a'*35 + 'b'*35) - def test_properties(self): - f = tempfile.SpooledTemporaryFile(max_size=10) - f.write(b'x' * 10) - self.assertFalse(f._rolled) - self.assertEqual(f.mode, 'w+b') - self.assertIsNone(f.name) - with self.assertRaises(AttributeError): - f.newlines - with self.assertRaises(AttributeError): - f.encoding - - f.write(b'x') - self.assertTrue(f._rolled) - self.assertEqual(f.mode, 'w+b') - self.assertIsNotNone(f.name) - with self.assertRaises(AttributeError): - f.newlines - with self.assertRaises(AttributeError): - f.encoding - def test_context_manager_before_rollover(self): # A SpooledTemporaryFile can be used as a context manager with tempfile.SpooledTemporaryFile(max_size=1) as f: @@ -1042,7 +882,7 @@ test_classes.append(test_TemporaryFile) def test_main(): - support.run_unittest(*test_classes) + test_support.run_unittest(*test_classes) if __name__ == "__main__": test_main() diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Lib/test/test_textwrap.py --- a/Lib/test/test_textwrap.py Sat Jul 19 16:34:33 2014 -0700 +++ b/Lib/test/test_textwrap.py Sun Jul 20 10:52:46 2014 -0400 @@ -66,15 +66,6 @@ "I'm glad to hear it!"]) self.check_wrap(text, 80, [text]) - def test_empty_string(self): - # Check that wrapping the empty string returns an empty list. - self.check_wrap("", 6, []) - self.check_wrap("", 6, [], drop_whitespace=False) - - def test_empty_string_with_initial_indent(self): - # Check that the empty string is not indented. - self.check_wrap("", 6, [], initial_indent="++") - self.check_wrap("", 6, [], initial_indent="++", drop_whitespace=False) def test_whitespace(self): # Whitespace munging and end-of-sentence detection @@ -332,32 +323,7 @@ ["blah", " ", "(ding", " ", "dong),", " ", "wubba"]) - def test_drop_whitespace_false(self): - # Check that drop_whitespace=False preserves whitespace. - # SF patch #1581073 - text = " This is a sentence with much whitespace." - self.check_wrap(text, 10, - [" This is a", " ", "sentence ", - "with ", "much white", "space."], - drop_whitespace=False) - - def test_drop_whitespace_false_whitespace_only(self): - # Check that drop_whitespace=False preserves a whitespace-only string. - self.check_wrap(" ", 6, [" "], drop_whitespace=False) - - def test_drop_whitespace_false_whitespace_only_with_indent(self): - # Check that a whitespace-only string gets indented (when - # drop_whitespace is False). - self.check_wrap(" ", 6, [" "], drop_whitespace=False, - initial_indent=" ") - - def test_drop_whitespace_whitespace_only(self): - # Check drop_whitespace on a whitespace-only string. - self.check_wrap(" ", 6, []) - - def test_drop_whitespace_leading_whitespace(self): - # Check that drop_whitespace does not drop leading whitespace (if - # followed by non-whitespace). + def test_initial_whitespace(self): # SF bug #622849 reported inconsistent handling of leading # whitespace; let's test that a bit, shall we? text = " This is a sentence with leading whitespace." @@ -366,27 +332,13 @@ self.check_wrap(text, 30, [" This is a sentence with", "leading whitespace."]) - def test_drop_whitespace_whitespace_line(self): - # Check that drop_whitespace skips the whole line if a non-leading - # line consists only of whitespace. - text = "abcd efgh" - # Include the result for drop_whitespace=False for comparison. - self.check_wrap(text, 6, ["abcd", " ", "efgh"], + def test_no_drop_whitespace(self): + # SF patch #1581073 + text = " This is a sentence with much whitespace." + self.check_wrap(text, 10, + [" This is a", " ", "sentence ", + "with ", "much white", "space."], drop_whitespace=False) - self.check_wrap(text, 6, ["abcd", "efgh"]) - - def test_drop_whitespace_whitespace_only_with_indent(self): - # Check that initial_indent is not applied to a whitespace-only - # string. This checks a special case of the fact that dropping - # whitespace occurs before indenting. - self.check_wrap(" ", 6, [], initial_indent="++") - - def test_drop_whitespace_whitespace_indent(self): - # Check that drop_whitespace does not drop whitespace indents. - # This checks a special case of the fact that dropping whitespace - # occurs before indenting. - self.check_wrap("abcd efgh", 6, [" abcd", " efgh"], - initial_indent=" ", subsequent_indent=" ") if test_support.have_unicode: def test_unicode(self): diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Lib/test/test_thread.py --- a/Lib/test/test_thread.py Sat Jul 19 16:34:33 2014 -0700 +++ b/Lib/test/test_thread.py Sun Jul 20 10:52:46 2014 -0400 @@ -70,35 +70,39 @@ thread.stack_size(0) self.assertEqual(thread.stack_size(), 0, "stack_size not reset to default") - @unittest.skipIf(os.name not in ("nt", "os2", "posix"), 'test meant for nt, os2, and posix') - def test_nt_and_posix_stack_size(self): + if os.name not in ("nt", "os2", "posix"): + return + + tss_supported = True try: thread.stack_size(4096) except ValueError: verbose_print("caught expected ValueError setting " "stack_size(4096)") except thread.error: - self.skipTest("platform does not support changing thread stack " - "size") + tss_supported = False + verbose_print("platform does not support changing thread stack " + "size") - fail_msg = "stack_size(%d) failed - should succeed" - for tss in (262144, 0x100000, 0): - thread.stack_size(tss) - self.assertEqual(thread.stack_size(), tss, fail_msg % tss) - verbose_print("successfully set stack_size(%d)" % tss) + if tss_supported: + fail_msg = "stack_size(%d) failed - should succeed" + for tss in (262144, 0x100000, 0): + thread.stack_size(tss) + self.assertEqual(thread.stack_size(), tss, fail_msg % tss) + verbose_print("successfully set stack_size(%d)" % tss) - for tss in (262144, 0x100000): - verbose_print("trying stack_size = (%d)" % tss) - self.next_ident = 0 - self.created = 0 - for i in range(NUMTASKS): - self.newtask() + for tss in (262144, 0x100000): + verbose_print("trying stack_size = (%d)" % tss) + self.next_ident = 0 + self.created = 0 + for i in range(NUMTASKS): + self.newtask() - verbose_print("waiting for all tasks to complete") - self.done_mutex.acquire() - verbose_print("all tasks done") + verbose_print("waiting for all tasks to complete") + self.done_mutex.acquire() + verbose_print("all tasks done") - thread.stack_size(0) + thread.stack_size(0) def test__count(self): # Test the _count() function. @@ -126,29 +130,6 @@ time.sleep(0.01) self.assertEqual(thread._count(), orig) - def test_save_exception_state_on_error(self): - # See issue #14474 - def task(): - started.release() - raise SyntaxError - def mywrite(self, *args): - try: - raise ValueError - except ValueError: - pass - real_write(self, *args) - c = thread._count() - started = thread.allocate_lock() - with test_support.captured_output("stderr") as stderr: - real_write = stderr.write - stderr.write = mywrite - started.acquire() - thread.start_new_thread(task, ()) - started.acquire() - while thread._count() > c: - time.sleep(0.01) - self.assertIn("Traceback", stderr.getvalue()) - class Barrier: def __init__(self, num_threads): diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Lib/test/test_threading.py --- a/Lib/test/test_threading.py Sat Jul 19 16:34:33 2014 -0700 +++ b/Lib/test/test_threading.py Sun Jul 20 10:52:46 2014 -0400 @@ -1,9 +1,7 @@ # Very rudimentary test of threading module import test.test_support -from test.test_support import verbose, cpython_only -from test.script_helper import assert_python_ok - +from test.test_support import verbose import random import re import sys @@ -14,10 +12,6 @@ import weakref import os import subprocess -try: - import _testcapi -except ImportError: - _testcapi = None from test import lock_tests @@ -129,7 +123,9 @@ try: threading.stack_size(262144) except thread.error: - self.skipTest('platform does not support changing thread stack size') + if verbose: + print 'platform does not support changing thread stack size' + return self.test_various_ops() threading.stack_size(0) @@ -140,7 +136,9 @@ try: threading.stack_size(0x100000) except thread.error: - self.skipTest('platform does not support changing thread stack size') + if verbose: + print 'platform does not support changing thread stack size' + return self.test_various_ops() threading.stack_size(0) @@ -167,7 +165,9 @@ try: import ctypes except ImportError: - self.skipTest('requires ctypes') + if verbose: + print "test_PyThreadState_SetAsyncExc can't import ctypes" + return # can't do anything set_async_exc = ctypes.pythonapi.PyThreadState_SetAsyncExc @@ -273,7 +273,9 @@ try: import ctypes except ImportError: - self.skipTest('requires ctypes') + if verbose: + print("test_finalize_with_runnning_thread can't import ctypes") + return # can't do anything rc = subprocess.call([sys.executable, "-c", """if 1: import ctypes, sys, time, thread @@ -412,73 +414,6 @@ msg=('%d references still around' % sys.getrefcount(weak_raising_cyclic_object()))) - @unittest.skipUnless(hasattr(os, 'fork'), 'test needs fork()') - def test_dummy_thread_after_fork(self): - # Issue #14308: a dummy thread in the active list doesn't mess up - # the after-fork mechanism. - code = """if 1: - import thread, threading, os, time - - def background_thread(evt): - # Creates and registers the _DummyThread instance - threading.current_thread() - evt.set() - time.sleep(10) - - evt = threading.Event() - thread.start_new_thread(background_thread, (evt,)) - evt.wait() - assert threading.active_count() == 2, threading.active_count() - if os.fork() == 0: - assert threading.active_count() == 1, threading.active_count() - os._exit(0) - else: - os.wait() - """ - _, out, err = assert_python_ok("-c", code) - self.assertEqual(out, '') - self.assertEqual(err, '') - - @unittest.skipUnless(hasattr(os, 'fork'), "needs os.fork()") - def test_is_alive_after_fork(self): - # Try hard to trigger #18418: is_alive() could sometimes be True on - # threads that vanished after a fork. - old_interval = sys.getcheckinterval() - - # Make the bug more likely to manifest. - sys.setcheckinterval(10) - - try: - for i in range(20): - t = threading.Thread(target=lambda: None) - t.start() - pid = os.fork() - if pid == 0: - os._exit(1 if t.is_alive() else 0) - else: - t.join() - pid, status = os.waitpid(pid, 0) - self.assertEqual(0, status) - finally: - sys.setcheckinterval(old_interval) - - def test_BoundedSemaphore_limit(self): - # BoundedSemaphore should raise ValueError if released too often. - for limit in range(1, 10): - bs = threading.BoundedSemaphore(limit) - threads = [threading.Thread(target=bs.acquire) - for _ in range(limit)] - for t in threads: - t.start() - for t in threads: - t.join() - threads = [threading.Thread(target=bs.release) - for _ in range(limit)] - for t in threads: - t.start() - for t in threads: - t.join() - self.assertRaises(ValueError, bs.release) class ThreadJoinOnShutdown(BaseTestCase): @@ -700,113 +635,6 @@ output = "end of worker thread\nend of main thread\n" self.assertScriptHasOutput(script, output) - @unittest.skipIf(sys.platform in platforms_to_skip, "due to known OS bug") - def test_6_daemon_threads(self): - # Check that a daemon thread cannot crash the interpreter on shutdown - # by manipulating internal structures that are being disposed of in - # the main thread. - script = """if True: - import os - import random - import sys - import time - import threading - - thread_has_run = set() - - def random_io(): - '''Loop for a while sleeping random tiny amounts and doing some I/O.''' - while True: - in_f = open(os.__file__, 'rb') - stuff = in_f.read(200) - null_f = open(os.devnull, 'wb') - null_f.write(stuff) - time.sleep(random.random() / 1995) - null_f.close() - in_f.close() - thread_has_run.add(threading.current_thread()) - - def main(): - count = 0 - for _ in range(40): - new_thread = threading.Thread(target=random_io) - new_thread.daemon = True - new_thread.start() - count += 1 - while len(thread_has_run) < count: - time.sleep(0.001) - # Trigger process shutdown - sys.exit(0) - - main() - """ - rc, out, err = assert_python_ok('-c', script) - self.assertFalse(err) - - @unittest.skipUnless(hasattr(os, 'fork'), "needs os.fork()") - @unittest.skipIf(sys.platform in platforms_to_skip, "due to known OS bug") - def test_reinit_tls_after_fork(self): - # Issue #13817: fork() would deadlock in a multithreaded program with - # the ad-hoc TLS implementation. - - def do_fork_and_wait(): - # just fork a child process and wait it - pid = os.fork() - if pid > 0: - os.waitpid(pid, 0) - else: - os._exit(0) - - # start a bunch of threads that will fork() child processes - threads = [] - for i in range(16): - t = threading.Thread(target=do_fork_and_wait) - threads.append(t) - t.start() - - for t in threads: - t.join() - - @cpython_only - @unittest.skipIf(_testcapi is None, "need _testcapi module") - def test_frame_tstate_tracing(self): - # Issue #14432: Crash when a generator is created in a C thread that is - # destroyed while the generator is still used. The issue was that a - # generator contains a frame, and the frame kept a reference to the - # Python state of the destroyed C thread. The crash occurs when a trace - # function is setup. - - def noop_trace(frame, event, arg): - # no operation - return noop_trace - - def generator(): - while 1: - yield "genereator" - - def callback(): - if callback.gen is None: - callback.gen = generator() - return next(callback.gen) - callback.gen = None - - old_trace = sys.gettrace() - sys.settrace(noop_trace) - try: - # Install a trace function - threading.settrace(noop_trace) - - # Create a generator in a C thread which exits after the call - _testcapi.call_in_temporary_c_thread(callback) - - # Call the generator in a different Python thread, check that the - # generator didn't keep a reference to the destroyed thread state - for test in range(3): - # The trace function is still called here - callback() - finally: - sys.settrace(old_trace) - class ThreadingExceptionTests(BaseTestCase): # A RuntimeError should be raised if Thread.start() is called diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Lib/test/test_time.py --- a/Lib/test/test_time.py Sat Jul 19 16:34:33 2014 -0700 +++ b/Lib/test/test_time.py Sun Jul 20 10:52:46 2014 -0400 @@ -106,7 +106,7 @@ def test_strptime(self): # Should be able to go round-trip from strftime to strptime without - # raising an exception. + # throwing an exception. tt = time.gmtime(self.t) for directive in ('a', 'A', 'b', 'B', 'c', 'd', 'H', 'I', 'j', 'm', 'M', 'p', 'S', diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Lib/test/test_timeout.py --- a/Lib/test/test_timeout.py Sat Jul 19 16:34:33 2014 -0700 +++ b/Lib/test/test_timeout.py Sun Jul 20 10:52:46 2014 -0400 @@ -178,19 +178,16 @@ "timeout (%g) is %g seconds more than expected (%g)" %(_delta, self.fuzz, _timeout)) - @unittest.skip('test not implemented') def testSend(self): # Test send() timeout # couldn't figure out how to test it pass - @unittest.skip('test not implemented') def testSendto(self): # Test sendto() timeout # couldn't figure out how to test it pass - @unittest.skip('test not implemented') def testSendall(self): # Test sendall() timeout # couldn't figure out how to test it diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Lib/test/test_tk.py --- a/Lib/test/test_tk.py Sat Jul 19 16:34:33 2014 -0700 +++ b/Lib/test/test_tk.py Sun Jul 20 10:52:46 2014 -0400 @@ -1,9 +1,8 @@ import os from test import test_support -# Skip test if _tkinter wasn't built or gui resource is not available. +# Skip test if _tkinter wasn't built. test_support.import_module('_tkinter') -test_support.requires('gui') this_dir = os.path.dirname(os.path.abspath(__file__)) lib_tk_test = os.path.abspath(os.path.join(this_dir, os.path.pardir, @@ -12,10 +11,19 @@ with test_support.DirsOnSysPath(lib_tk_test): import runtktests -def test_main(): +# Skip test if tk cannot be initialized. +runtktests.check_tk_availability() + +def test_main(enable_gui=False): + if enable_gui: + if test_support.use_resources is None: + test_support.use_resources = ['gui'] + elif 'gui' not in test_support.use_resources: + test_support.use_resources.append('gui') + with test_support.DirsOnSysPath(lib_tk_test): test_support.run_unittest( *runtktests.get_tests(text=False, packages=['test_tkinter'])) if __name__ == '__main__': - test_main() + test_main(enable_gui=True) diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Lib/test/test_tokenize.py --- a/Lib/test/test_tokenize.py Sat Jul 19 16:34:33 2014 -0700 +++ b/Lib/test/test_tokenize.py Sun Jul 20 10:52:46 2014 -0400 @@ -4,7 +4,7 @@ >>> import glob, random, sys The tests can be really simple. Given a small fragment of source -code, print out a table with tokens. The ENDMARKER is omitted for +code, print out a table with tokens. The ENDMARK is omitted for brevity. >>> dump_tokens("1 + 1") @@ -278,31 +278,6 @@ OP '+' (1, 32) (1, 33) STRING 'UR"ABC"' (1, 34) (1, 41) - >>> dump_tokens("b'abc' + B'abc'") - STRING "b'abc'" (1, 0) (1, 6) - OP '+' (1, 7) (1, 8) - STRING "B'abc'" (1, 9) (1, 15) - >>> dump_tokens('b"abc" + B"abc"') - STRING 'b"abc"' (1, 0) (1, 6) - OP '+' (1, 7) (1, 8) - STRING 'B"abc"' (1, 9) (1, 15) - >>> dump_tokens("br'abc' + bR'abc' + Br'abc' + BR'abc'") - STRING "br'abc'" (1, 0) (1, 7) - OP '+' (1, 8) (1, 9) - STRING "bR'abc'" (1, 10) (1, 17) - OP '+' (1, 18) (1, 19) - STRING "Br'abc'" (1, 20) (1, 27) - OP '+' (1, 28) (1, 29) - STRING "BR'abc'" (1, 30) (1, 37) - >>> dump_tokens('br"abc" + bR"abc" + Br"abc" + BR"abc"') - STRING 'br"abc"' (1, 0) (1, 7) - OP '+' (1, 8) (1, 9) - STRING 'bR"abc"' (1, 10) (1, 17) - OP '+' (1, 18) (1, 19) - STRING 'Br"abc"' (1, 20) (1, 27) - OP '+' (1, 28) (1, 29) - STRING 'BR"abc"' (1, 30) (1, 37) - Operators >>> dump_tokens("def d22(a, b, c=2, d=2, *k): pass") @@ -550,19 +525,14 @@ NAME 'pass' (3, 9) (3, 13) DEDENT '' (4, 0) (4, 0) DEDENT '' (4, 0) (4, 0) - -Pathological whitespace (http://bugs.python.org/issue16152) - >>> dump_tokens("@ ") - OP '@' (1, 0) (1, 1) """ from test import test_support from tokenize import (untokenize, generate_tokens, NUMBER, NAME, OP, - STRING, ENDMARKER, tok_name, Untokenizer) + STRING, ENDMARKER, tok_name) from StringIO import StringIO import os -from unittest import TestCase def dump_tokens(s): """Print out the tokens in s in a table format. @@ -615,47 +585,12 @@ return untokenize(result) -class UntokenizeTest(TestCase): +__test__ = {"doctests" : doctests, 'decistmt': decistmt} - def test_bad_input_order(self): - # raise if previous row - u = Untokenizer() - u.prev_row = 2 - u.prev_col = 2 - with self.assertRaises(ValueError) as cm: - u.add_whitespace((1,3)) - self.assertEqual(cm.exception.args[0], - 'start (1,3) precedes previous end (2,2)') - # raise if previous column in row - self.assertRaises(ValueError, u.add_whitespace, (2,1)) - - def test_backslash_continuation(self): - # The problem is that \ leaves no token - u = Untokenizer() - u.prev_row = 1 - u.prev_col = 1 - u.tokens = [] - u.add_whitespace((2, 0)) - self.assertEqual(u.tokens, ['\\\n']) - u.prev_row = 2 - u.add_whitespace((4, 4)) - self.assertEqual(u.tokens, ['\\\n', '\\\n\\\n', ' ']) - - def test_iter_compat(self): - u = Untokenizer() - token = (NAME, 'Hello') - u.compat(token, iter([])) - self.assertEqual(u.tokens, ["Hello "]) - u = Untokenizer() - self.assertEqual(u.untokenize(iter([token])), 'Hello ') - - -__test__ = {"doctests" : doctests, 'decistmt': decistmt} def test_main(): from test import test_tokenize test_support.run_doctest(test_tokenize, True) - test_support.run_unittest(UntokenizeTest) if __name__ == "__main__": test_main() diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Lib/test/test_tools.py --- a/Lib/test/test_tools.py Sat Jul 19 16:34:33 2014 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,368 +0,0 @@ -"""Tests for scripts in the Tools directory. - -This file contains regression tests for some of the scripts found in the -Tools directory of a Python checkout or tarball, such as reindent.py. -""" - -import os -import sys -import unittest -import shutil -import subprocess -import sysconfig -import tempfile -import textwrap -from test import test_support -from test.script_helper import assert_python_ok, temp_dir - -if not sysconfig.is_python_build(): - # XXX some installers do contain the tools, should we detect that - # and run the tests in that case too? - raise unittest.SkipTest('test irrelevant for an installed Python') - -basepath = os.path.join(os.path.dirname(os.path.dirname(os.path.dirname(__file__))), - 'Tools') -scriptsdir = os.path.join(basepath, 'scripts') - - -class ReindentTests(unittest.TestCase): - script = os.path.join(scriptsdir, 'reindent.py') - - def test_noargs(self): - assert_python_ok(self.script) - - def test_help(self): - rc, out, err = assert_python_ok(self.script, '-h') - self.assertEqual(out, b'') - self.assertGreater(err, b'') - - -class PindentTests(unittest.TestCase): - script = os.path.join(scriptsdir, 'pindent.py') - - def assertFileEqual(self, fn1, fn2): - with open(fn1) as f1, open(fn2) as f2: - self.assertEqual(f1.readlines(), f2.readlines()) - - def pindent(self, source, *args): - proc = subprocess.Popen( - (sys.executable, self.script) + args, - stdin=subprocess.PIPE, stdout=subprocess.PIPE, - universal_newlines=True) - out, err = proc.communicate(source) - self.assertIsNone(err) - return out - - def lstriplines(self, data): - return '\n'.join(line.lstrip() for line in data.splitlines()) + '\n' - - def test_selftest(self): - self.maxDiff = None - with temp_dir() as directory: - data_path = os.path.join(directory, '_test.py') - with open(self.script) as f: - closed = f.read() - with open(data_path, 'w') as f: - f.write(closed) - - rc, out, err = assert_python_ok(self.script, '-d', data_path) - self.assertEqual(out, b'') - self.assertEqual(err, b'') - backup = data_path + '~' - self.assertTrue(os.path.exists(backup)) - with open(backup) as f: - self.assertEqual(f.read(), closed) - with open(data_path) as f: - clean = f.read() - compile(clean, '_test.py', 'exec') - self.assertEqual(self.pindent(clean, '-c'), closed) - self.assertEqual(self.pindent(closed, '-d'), clean) - - rc, out, err = assert_python_ok(self.script, '-c', data_path) - self.assertEqual(out, b'') - self.assertEqual(err, b'') - with open(backup) as f: - self.assertEqual(f.read(), clean) - with open(data_path) as f: - self.assertEqual(f.read(), closed) - - broken = self.lstriplines(closed) - with open(data_path, 'w') as f: - f.write(broken) - rc, out, err = assert_python_ok(self.script, '-r', data_path) - self.assertEqual(out, b'') - self.assertEqual(err, b'') - with open(backup) as f: - self.assertEqual(f.read(), broken) - with open(data_path) as f: - indented = f.read() - compile(indented, '_test.py', 'exec') - self.assertEqual(self.pindent(broken, '-r'), indented) - - def pindent_test(self, clean, closed): - self.assertEqual(self.pindent(clean, '-c'), closed) - self.assertEqual(self.pindent(closed, '-d'), clean) - broken = self.lstriplines(closed) - self.assertEqual(self.pindent(broken, '-r', '-e', '-s', '4'), closed) - - def test_statements(self): - clean = textwrap.dedent("""\ - if a: - pass - - if a: - pass - else: - pass - - if a: - pass - elif: - pass - else: - pass - - while a: - break - - while a: - break - else: - pass - - for i in a: - break - - for i in a: - break - else: - pass - - try: - pass - finally: - pass - - try: - pass - except TypeError: - pass - except ValueError: - pass - else: - pass - - try: - pass - except TypeError: - pass - except ValueError: - pass - finally: - pass - - with a: - pass - - class A: - pass - - def f(): - pass - """) - - closed = textwrap.dedent("""\ - if a: - pass - # end if - - if a: - pass - else: - pass - # end if - - if a: - pass - elif: - pass - else: - pass - # end if - - while a: - break - # end while - - while a: - break - else: - pass - # end while - - for i in a: - break - # end for - - for i in a: - break - else: - pass - # end for - - try: - pass - finally: - pass - # end try - - try: - pass - except TypeError: - pass - except ValueError: - pass - else: - pass - # end try - - try: - pass - except TypeError: - pass - except ValueError: - pass - finally: - pass - # end try - - with a: - pass - # end with - - class A: - pass - # end class A - - def f(): - pass - # end def f - """) - self.pindent_test(clean, closed) - - def test_multilevel(self): - clean = textwrap.dedent("""\ - def foobar(a, b): - if a == b: - a = a+1 - elif a < b: - b = b-1 - if b > a: a = a-1 - else: - print 'oops!' - """) - closed = textwrap.dedent("""\ - def foobar(a, b): - if a == b: - a = a+1 - elif a < b: - b = b-1 - if b > a: a = a-1 - # end if - else: - print 'oops!' - # end if - # end def foobar - """) - self.pindent_test(clean, closed) - - def test_preserve_indents(self): - clean = textwrap.dedent("""\ - if a: - if b: - pass - """) - closed = textwrap.dedent("""\ - if a: - if b: - pass - # end if - # end if - """) - self.assertEqual(self.pindent(clean, '-c'), closed) - self.assertEqual(self.pindent(closed, '-d'), clean) - broken = self.lstriplines(closed) - self.assertEqual(self.pindent(broken, '-r', '-e', '-s', '9'), closed) - clean = textwrap.dedent("""\ - if a: - \tif b: - \t\tpass - """) - closed = textwrap.dedent("""\ - if a: - \tif b: - \t\tpass - \t# end if - # end if - """) - self.assertEqual(self.pindent(clean, '-c'), closed) - self.assertEqual(self.pindent(closed, '-d'), clean) - broken = self.lstriplines(closed) - self.assertEqual(self.pindent(broken, '-r'), closed) - - def test_escaped_newline(self): - clean = textwrap.dedent("""\ - class\\ - \\ - A: - def\ - \\ - f: - pass - """) - closed = textwrap.dedent("""\ - class\\ - \\ - A: - def\ - \\ - f: - pass - # end def f - # end class A - """) - self.assertEqual(self.pindent(clean, '-c'), closed) - self.assertEqual(self.pindent(closed, '-d'), clean) - - def test_empty_line(self): - clean = textwrap.dedent("""\ - if a: - - pass - """) - closed = textwrap.dedent("""\ - if a: - - pass - # end if - """) - self.pindent_test(clean, closed) - - def test_oneline(self): - clean = textwrap.dedent("""\ - if a: pass - """) - closed = textwrap.dedent("""\ - if a: pass - # end if - """) - self.pindent_test(clean, closed) - - -def test_main(): - test_support.run_unittest(*[obj for obj in globals().values() - if isinstance(obj, type)]) - - -if __name__ == '__main__': - unittest.main() diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Lib/test/test_traceback.py --- a/Lib/test/test_traceback.py Sat Jul 19 16:34:33 2014 -0700 +++ b/Lib/test/test_traceback.py Sun Jul 20 10:52:46 2014 -0400 @@ -1,10 +1,11 @@ """Test cases for traceback module""" +from _testcapi import traceback_print from StringIO import StringIO import sys import unittest from imp import reload -from test.test_support import run_unittest, is_jython, Error, cpython_only +from test.test_support import run_unittest, is_jython, Error import traceback @@ -34,9 +35,6 @@ def syntax_error_bad_indentation(self): compile("def spam():\n print 1\n print 2", "?", "exec") - def syntax_error_bad_indentation2(self): - compile(" print(2)", "?", "exec") - def test_caret(self): err = self.get_exception_format(self.syntax_error_with_caret, SyntaxError) @@ -113,13 +111,6 @@ os.unlink(os.path.join(testdir, f)) os.rmdir(testdir) - err = self.get_exception_format(self.syntax_error_bad_indentation2, - IndentationError) - self.assertEqual(len(err), 4) - self.assertEqual(err[1].strip(), "print(2)") - self.assertIn("^", err[2]) - self.assertEqual(err[1].find("p"), err[2].find("^")) - def test_base_exception(self): # Test that exceptions derived from BaseException are formatted right e = KeyboardInterrupt() @@ -180,9 +171,7 @@ class TracebackFormatTests(unittest.TestCase): - @cpython_only def test_traceback_format(self): - from _testcapi import traceback_print try: raise KeyError('blah') except KeyError: diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Lib/test/test_ttk_guionly.py --- a/Lib/test/test_ttk_guionly.py Sat Jul 19 16:34:33 2014 -0700 +++ b/Lib/test/test_ttk_guionly.py Sun Jul 20 10:52:46 2014 -0400 @@ -2,9 +2,8 @@ import unittest from test import test_support -# Skip this test if _tkinter wasn't built or gui resource is not available. +# Skip this test if _tkinter wasn't built. test_support.import_module('_tkinter') -test_support.requires('gui') this_dir = os.path.dirname(os.path.abspath(__file__)) lib_tk_test = os.path.abspath(os.path.join(this_dir, os.path.pardir, @@ -13,6 +12,9 @@ with test_support.DirsOnSysPath(lib_tk_test): import runtktests +# Skip test if tk cannot be initialized. +runtktests.check_tk_availability() + import ttk from _tkinter import TclError @@ -22,7 +24,13 @@ # assuming ttk is not available raise unittest.SkipTest("ttk not available: %s" % msg) -def test_main(): +def test_main(enable_gui=False): + if enable_gui: + if test_support.use_resources is None: + test_support.use_resources = ['gui'] + elif 'gui' not in test_support.use_resources: + test_support.use_resources.append('gui') + with test_support.DirsOnSysPath(lib_tk_test): from test_ttk.support import get_tk_root try: @@ -32,4 +40,4 @@ get_tk_root().destroy() if __name__ == '__main__': - test_main() + test_main(enable_gui=True) diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Lib/test/test_ucn.py --- a/Lib/test/test_ucn.py Sat Jul 19 16:34:33 2014 -0700 +++ b/Lib/test/test_ucn.py Sun Jul 20 10:52:46 2014 -0400 @@ -8,15 +8,9 @@ """#" import unittest -import sys from test import test_support -try: - from _testcapi import INT_MAX, PY_SSIZE_T_MAX, UINT_MAX -except ImportError: - INT_MAX = PY_SSIZE_T_MAX = UINT_MAX = 2**64 - 1 - class UnicodeNamesTest(unittest.TestCase): def checkletter(self, name, code): @@ -143,25 +137,6 @@ unicode, "\\NSPACE", 'unicode-escape', 'strict' ) - @test_support.cpython_only - @unittest.skipUnless(INT_MAX < PY_SSIZE_T_MAX, "needs UINT_MAX < SIZE_MAX") - @unittest.skipUnless(UINT_MAX < sys.maxint, "needs UINT_MAX < sys.maxint") - @test_support.bigmemtest(minsize=UINT_MAX + 1, - memuse=2 + 4 // len(u'\U00010000')) - def test_issue16335(self, size): - func = self.test_issue16335 - if size < func.minsize: - raise unittest.SkipTest("not enough memory: %.1fG minimum needed" % - (func.minsize * func.memuse / float(1024**3),)) - # very very long bogus character name - x = b'\\N{SPACE' + b'x' * int(UINT_MAX + 1) + b'}' - self.assertEqual(len(x), len(b'\\N{SPACE}') + (UINT_MAX + 1)) - self.assertRaisesRegexp(UnicodeError, - 'unknown Unicode character name', - x.decode, 'unicode-escape' - ) - - def test_main(): test_support.run_unittest(UnicodeNamesTest) diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Lib/test/test_unicode.py --- a/Lib/test/test_unicode.py Sat Jul 19 16:34:33 2014 -0700 +++ b/Lib/test/test_unicode.py Sun Jul 20 10:52:46 2014 -0400 @@ -644,23 +644,6 @@ return u'\u1234' self.assertEqual('%s' % Wrapper(), u'\u1234') - def test_formatting_huge_precision(self): - format_string = u"%.{}f".format(sys.maxsize + 1) - with self.assertRaises(ValueError): - result = format_string % 2.34 - - @test_support.cpython_only - def test_formatting_huge_precision_c_limits(self): - from _testcapi import INT_MAX - format_string = u"%.{}f".format(INT_MAX + 1) - with self.assertRaises(ValueError): - result = format_string % 2.34 - - def test_formatting_huge_width(self): - format_string = u"%{}f".format(sys.maxsize + 1) - with self.assertRaises(ValueError): - result = format_string % 2.34 - def test_startswith_endswith_errors(self): for meth in (u'foo'.startswith, u'foo'.endswith): with self.assertRaises(UnicodeDecodeError): @@ -1283,12 +1266,12 @@ self.assertEqual(repr(s1()), '\\n') self.assertEqual(repr(s2()), '\\n') - # This test only affects 32-bit platforms because expandtabs can only take - # an int as the max value, not a 64-bit C long. If expandtabs is changed - # to take a 64-bit long, this test should apply to all platforms. - @unittest.skipIf(sys.maxint > (1 << 32) or struct.calcsize('P') != 4, - 'only applies to 32-bit platforms') def test_expandtabs_overflows_gracefully(self): + # This test only affects 32-bit platforms because expandtabs can only take + # an int as the max value, not a 64-bit C long. If expandtabs is changed + # to take a 64-bit long, this test should apply to all platforms. + if sys.maxint > (1 << 32) or struct.calcsize('P') != 4: + return self.assertRaises(OverflowError, u't\tt\t'.expandtabs, sys.maxint) def test__format__(self): @@ -1463,27 +1446,6 @@ self.assertEqual(u'{0:10000}'.format(u''), u' ' * 10000) self.assertEqual(u'{0:10000000}'.format(u''), u' ' * 10000000) - # issue 12546: use \x00 as a fill character - self.assertEqual('{0:\x00<6s}'.format('foo'), 'foo\x00\x00\x00') - self.assertEqual('{0:\x01<6s}'.format('foo'), 'foo\x01\x01\x01') - self.assertEqual('{0:\x00^6s}'.format('foo'), '\x00foo\x00\x00') - self.assertEqual('{0:^6s}'.format('foo'), ' foo ') - - self.assertEqual('{0:\x00<6}'.format(3), '3\x00\x00\x00\x00\x00') - self.assertEqual('{0:\x01<6}'.format(3), '3\x01\x01\x01\x01\x01') - self.assertEqual('{0:\x00^6}'.format(3), '\x00\x003\x00\x00\x00') - self.assertEqual('{0:<6}'.format(3), '3 ') - - self.assertEqual('{0:\x00<6}'.format(3.14), '3.14\x00\x00') - self.assertEqual('{0:\x01<6}'.format(3.14), '3.14\x01\x01') - self.assertEqual('{0:\x00^6}'.format(3.14), '\x003.14\x00') - self.assertEqual('{0:^6}'.format(3.14), ' 3.14 ') - - self.assertEqual('{0:\x00<12}'.format(3+2.0j), '(3+2j)\x00\x00\x00\x00\x00\x00') - self.assertEqual('{0:\x01<12}'.format(3+2.0j), '(3+2j)\x01\x01\x01\x01\x01\x01') - self.assertEqual('{0:\x00^12}'.format(3+2.0j), '\x00\x00\x00(3+2j)\x00\x00\x00') - self.assertEqual('{0:^12}'.format(3+2.0j), ' (3+2j) ') - # format specifiers for user defined type self.assertEqual(u'{0:abc}'.format(C()), u'abc') @@ -1594,21 +1556,6 @@ # will fail self.assertRaises(UnicodeEncodeError, "foo{0}".format, u'\u1000bar') - def test_format_huge_precision(self): - format_string = u".{}f".format(sys.maxsize + 1) - with self.assertRaises(ValueError): - result = format(2.34, format_string) - - def test_format_huge_width(self): - format_string = u"{}f".format(sys.maxsize + 1) - with self.assertRaises(ValueError): - result = format(2.34, format_string) - - def test_format_huge_item_number(self): - format_string = u"{{{}:.6f}}".format(sys.maxsize + 1) - with self.assertRaises(ValueError): - result = format_string.format(2.34) - def test_format_auto_numbering(self): class C: def __init__(self, x=100): @@ -1659,7 +1606,6 @@ self.assertEqual("%s" % u, u'__unicode__ overridden') self.assertEqual("{}".format(u), '__unicode__ overridden') - @test_support.cpython_only def test_encode_decimal(self): from _testcapi import unicode_encodedecimal self.assertEqual(unicode_encodedecimal(u'123'), @@ -1685,19 +1631,6 @@ self.assertEqual(unicode_encodedecimal(u"123\u20ac\u0660", "replace"), b'123?0') - @test_support.cpython_only - def test_encode_decimal_with_surrogates(self): - from _testcapi import unicode_encodedecimal - tests = [(u'\U0001f49d', '💝'), - (u'\ud83d', '�'), - (u'\udc9d', '�'), - ] - if u'\ud83d\udc9d' != u'\U0001f49d': - tests += [(u'\ud83d\udc9d', '��')] - for s, exp in tests: - self.assertEqual( - unicode_encodedecimal(u"123" + s, "xmlcharrefreplace"), - '123' + exp) def test_main(): test_support.run_unittest(__name__) diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Lib/test/test_urllib.py --- a/Lib/test/test_urllib.py Sat Jul 19 16:34:33 2014 -0700 +++ b/Lib/test/test_urllib.py Sun Jul 20 10:52:46 2014 -0400 @@ -3,16 +3,13 @@ import urllib import httplib import unittest +from test import test_support import os import sys import mimetools import tempfile import StringIO -from test import test_support -from base64 import b64encode - - def hexescape(char): """Escape char as RFC 2396 specifies""" hex_repr = hex(ord(char))[2:].upper() @@ -25,9 +22,8 @@ def fakehttp(self, fakedata): class FakeSocket(StringIO.StringIO): - def sendall(self, data): - FakeHTTPConnection.buf = data - + def sendall(self, str): + pass def makefile(self, *args, **kwds): return self @@ -42,15 +38,9 @@ return StringIO.StringIO.readline(self, length) class FakeHTTPConnection(httplib.HTTPConnection): - - # buffer to store data for verification in urlopen tests. - buf = "" - def connect(self): self.sock = FakeSocket(fakedata) - assert httplib.HTTP._connection_class == httplib.HTTPConnection - httplib.HTTP._connection_class = FakeHTTPConnection def unfakehttp(self): @@ -134,9 +124,6 @@ for line in self.returned_obj.__iter__(): self.assertEqual(line, self.text) - def test_relativelocalfile(self): - self.assertRaises(ValueError,urllib.urlopen,'./' + self.pathname) - class ProxyTests(unittest.TestCase): def setUp(self): @@ -222,62 +209,6 @@ finally: self.unfakehttp() - def test_missing_localfile(self): - self.assertRaises(IOError, urllib.urlopen, - 'file://localhost/a/missing/file.py') - fd, tmp_file = tempfile.mkstemp() - tmp_fileurl = 'file://localhost/' + tmp_file.replace(os.path.sep, '/') - self.assertTrue(os.path.exists(tmp_file)) - try: - fp = urllib.urlopen(tmp_fileurl) - fp.close() - finally: - os.close(fd) - os.unlink(tmp_file) - - self.assertFalse(os.path.exists(tmp_file)) - self.assertRaises(IOError, urllib.urlopen, tmp_fileurl) - - def test_ftp_nonexisting(self): - self.assertRaises(IOError, urllib.urlopen, - 'ftp://localhost/not/existing/file.py') - - - def test_userpass_inurl(self): - self.fakehttp('Hello!') - try: - fakehttp_wrapper = httplib.HTTP._connection_class - fp = urllib.urlopen("http://user:pass@python.org/") - authorization = ("Authorization: Basic %s\r\n" % - b64encode('user:pass')) - # The authorization header must be in place - self.assertIn(authorization, fakehttp_wrapper.buf) - self.assertEqual(fp.readline(), "Hello!") - self.assertEqual(fp.readline(), "") - self.assertEqual(fp.geturl(), 'http://user:pass@python.org/') - self.assertEqual(fp.getcode(), 200) - finally: - self.unfakehttp() - - def test_userpass_with_spaces_inurl(self): - self.fakehttp('Hello!') - try: - url = "http://a b:c d@python.org/" - fakehttp_wrapper = httplib.HTTP._connection_class - authorization = ("Authorization: Basic %s\r\n" % - b64encode('a b:c d')) - fp = urllib.urlopen(url) - # The authorization header must be in place - self.assertIn(authorization, fakehttp_wrapper.buf) - self.assertEqual(fp.readline(), "Hello!") - self.assertEqual(fp.readline(), "") - # the spaces are quoted in URL so no match - self.assertNotEqual(fp.geturl(), url) - self.assertEqual(fp.getcode(), 200) - finally: - self.unfakehttp() - - class urlretrieve_FileTests(unittest.TestCase): """Test urllib.urlretrieve() on local files""" @@ -785,29 +716,6 @@ self.assertEqual(('user', 'a\fb'),urllib.splitpasswd('user:a\fb')) self.assertEqual(('user', 'a\vb'),urllib.splitpasswd('user:a\vb')) self.assertEqual(('user', 'a:b'),urllib.splitpasswd('user:a:b')) - self.assertEqual(('user', 'a b'),urllib.splitpasswd('user:a b')) - self.assertEqual(('user 2', 'ab'),urllib.splitpasswd('user 2:ab')) - self.assertEqual(('user+1', 'a+b'),urllib.splitpasswd('user+1:a+b')) - - def test_splitport(self): - splitport = urllib.splitport - self.assertEqual(splitport('parrot:88'), ('parrot', '88')) - self.assertEqual(splitport('parrot'), ('parrot', None)) - self.assertEqual(splitport('parrot:'), ('parrot', None)) - self.assertEqual(splitport('127.0.0.1'), ('127.0.0.1', None)) - self.assertEqual(splitport('parrot:cheese'), ('parrot:cheese', None)) - - def test_splitnport(self): - splitnport = urllib.splitnport - self.assertEqual(splitnport('parrot:88'), ('parrot', 88)) - self.assertEqual(splitnport('parrot'), ('parrot', -1)) - self.assertEqual(splitnport('parrot', 55), ('parrot', 55)) - self.assertEqual(splitnport('parrot:'), ('parrot', -1)) - self.assertEqual(splitnport('parrot:', 55), ('parrot', 55)) - self.assertEqual(splitnport('127.0.0.1'), ('127.0.0.1', -1)) - self.assertEqual(splitnport('127.0.0.1', 55), ('127.0.0.1', 55)) - self.assertEqual(splitnport('parrot:cheese'), ('parrot', None)) - self.assertEqual(splitnport('parrot:cheese', 55), ('parrot', None)) class URLopener_Tests(unittest.TestCase): @@ -832,7 +740,7 @@ # Everywhere else they work ok, but on those machines, sometimes # fail in one of the tests, sometimes in other. I have a linux, and # the tests go ok. -# If anybody has one of the problematic environments, please help! +# If anybody has one of the problematic enviroments, please help! # . Facundo # # def server(evt): @@ -878,7 +786,7 @@ # def testTimeoutNone(self): # # global default timeout is ignored # import socket -# self.assertIsNone(socket.getdefaulttimeout()) +# self.assertTrue(socket.getdefaulttimeout() is None) # socket.setdefaulttimeout(30) # try: # ftp = urllib.ftpwrapper("myuser", "mypass", "localhost", 9093, []) @@ -890,7 +798,7 @@ # def testTimeoutDefault(self): # # global default timeout is used # import socket -# self.assertIsNone(socket.getdefaulttimeout()) +# self.assertTrue(socket.getdefaulttimeout() is None) # socket.setdefaulttimeout(30) # try: # ftp = urllib.ftpwrapper("myuser", "mypass", "localhost", 9093, []) diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Lib/test/test_urllib2.py --- a/Lib/test/test_urllib2.py Sat Jul 19 16:34:33 2014 -0700 +++ b/Lib/test/test_urllib2.py Sun Jul 20 10:52:46 2014 -0400 @@ -591,8 +591,8 @@ self.assertIsInstance(args[0], Request) # response from opener.open is None, because there's no # handler that defines http_open to handle it - if args[1] is not None: - self.assertIsInstance(args[1], MockResponse) + self.assertTrue(args[1] is None or + isinstance(args[1], MockResponse)) def sanepathname2url(path): @@ -924,8 +924,7 @@ MockHeaders({"location": to_url})) except urllib2.HTTPError: # 307 in response to POST requires user OK - self.assertEqual(code, 307) - self.assertIsNotNone(data) + self.assertTrue(code == 307 and data is not None) self.assertEqual(o.req.get_full_url(), to_url) try: self.assertEqual(o.req.get_method(), "GET") @@ -1107,30 +1106,12 @@ self._test_basic_auth(opener, auth_handler, "Authorization", realm, http_handler, password_manager, "http://acme.example.com/protected", - "http://acme.example.com/protected" - ) + "http://acme.example.com/protected", + ) def test_basic_auth_with_single_quoted_realm(self): self.test_basic_auth(quote_char="'") - def test_basic_auth_with_unquoted_realm(self): - opener = OpenerDirector() - password_manager = MockPasswordManager() - auth_handler = urllib2.HTTPBasicAuthHandler(password_manager) - realm = "ACME Widget Store" - http_handler = MockHTTPHandler( - 401, 'WWW-Authenticate: Basic realm=%s\r\n\r\n' % realm) - opener.add_handler(auth_handler) - opener.add_handler(http_handler) - msg = "Basic Auth Realm was unquoted" - with test_support.check_warnings((msg, UserWarning)): - self._test_basic_auth(opener, auth_handler, "Authorization", - realm, http_handler, password_manager, - "http://acme.example.com/protected", - "http://acme.example.com/protected" - ) - - def test_proxy_basic_auth(self): opener = OpenerDirector() ph = urllib2.ProxyHandler(dict(http="proxy.example.com:3128")) @@ -1149,7 +1130,7 @@ ) def test_basic_and_digest_auth_handlers(self): - # HTTPDigestAuthHandler raised an exception if it couldn't handle a 40* + # HTTPDigestAuthHandler threw an exception if it couldn't handle a 40* # response (http://python.org/sf/1479302), where it should instead # return None to allow another handler (especially # HTTPBasicAuthHandler) to handle the response. @@ -1337,32 +1318,16 @@ req = Request(url) self.assertEqual(req.get_full_url(), url) - def test_HTTPError_interface(self): - """ - Issue 13211 reveals that HTTPError didn't implement the URLError - interface even though HTTPError is a subclass of URLError. +def test_HTTPError_interface(): + """ + Issue 13211 reveals that HTTPError didn't implement the URLError + interface even though HTTPError is a subclass of URLError. - >>> err = urllib2.HTTPError(msg='something bad happened', url=None, code=None, hdrs=None, fp=None) - >>> assert hasattr(err, 'reason') - >>> err.reason - 'something bad happened' - """ - - def test_HTTPError_interface_call(self): - """ - Issue 15701= - HTTPError interface has info method available from URLError. - """ - err = urllib2.HTTPError(msg='something bad happened', url=None, - code=None, hdrs='Content-Length:42', fp=None) - self.assertTrue(hasattr(err, 'reason')) - assert hasattr(err, 'reason') - assert hasattr(err, 'info') - assert callable(err.info) - try: - err.info() - except AttributeError: - self.fail("err.info() failed") - self.assertEqual(err.info(), "Content-Length:42") + >>> err = urllib2.HTTPError(msg='something bad happened', url=None, code=None, hdrs=None, fp=None) + >>> assert hasattr(err, 'reason') + >>> err.reason + 'something bad happened' + """ def test_main(verbose=None): from test import test_urllib2 diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Lib/test/test_urllib2_localnet.py --- a/Lib/test/test_urllib2_localnet.py Sat Jul 19 16:34:33 2014 -0700 +++ b/Lib/test/test_urllib2_localnet.py Sun Jul 20 10:52:46 2014 -0400 @@ -1,11 +1,11 @@ +#!/usr/bin/env python + import urlparse import urllib2 import BaseHTTPServer import unittest import hashlib - from test import test_support - mimetools = test_support.import_module('mimetools', deprecated=True) threading = test_support.import_module('threading') @@ -346,12 +346,6 @@ for transparent redirection have been written. """ - def setUp(self): - proxy_handler = urllib2.ProxyHandler({}) - opener = urllib2.build_opener(proxy_handler) - urllib2.install_opener(opener) - super(TestUrlopen, self).setUp() - def start_server(self, responses): handler = GetRequestHandler(responses) @@ -487,11 +481,6 @@ def test_bad_address(self): # Make sure proper exception is raised when connecting to a bogus # address. - - # as indicated by the comment below, this might fail with some ISP, - # so we run the test only when -unetwork/-uall is specified to - # mitigate the problem a bit (see #17564) - test_support.requires('network') self.assertRaises(IOError, # Given that both VeriSign and various ISPs have in # the past or are presently hijacking various invalid diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Lib/test/test_urllib2net.py --- a/Lib/test/test_urllib2net.py Sat Jul 19 16:34:33 2014 -0700 +++ b/Lib/test/test_urllib2net.py Sun Jul 20 10:52:46 2014 -0400 @@ -1,3 +1,5 @@ +#!/usr/bin/env python + import unittest from test import test_support from test.test_urllib2 import sanepathname2url @@ -78,13 +80,13 @@ # underlying socket # delve deep into response to fetch socket._socketobject - response = _urlopen_with_retry("http://www.example.com/") + response = _urlopen_with_retry("http://www.python.org/") abused_fileobject = response.fp - self.assertIs(abused_fileobject.__class__, socket._fileobject) + self.assertTrue(abused_fileobject.__class__ is socket._fileobject) httpresponse = abused_fileobject._sock - self.assertIs(httpresponse.__class__, httplib.HTTPResponse) + self.assertTrue(httpresponse.__class__ is httplib.HTTPResponse) fileobject = httpresponse.fp - self.assertIs(fileobject.__class__, socket._fileobject) + self.assertTrue(fileobject.__class__ is socket._fileobject) self.assertTrue(not fileobject.closed) response.close() @@ -124,8 +126,6 @@ finally: os.remove(TESTFN) - self.assertRaises(ValueError, urllib2.urlopen,'./relative_path/to/file') - # XXX Following test depends on machine configurations that are internal # to CNRI. Need to set up a public server with the right authentication # configuration for test purposes. @@ -155,15 +155,15 @@ ## self._test_urls(urls, self._extra_handlers()+[bauth, dauth]) def test_urlwithfrag(self): - urlwith_frag = "https://docs.python.org/2/glossary.html#glossary" + urlwith_frag = "http://docs.python.org/glossary.html#glossary" with test_support.transient_internet(urlwith_frag): req = urllib2.Request(urlwith_frag) res = urllib2.urlopen(req) self.assertEqual(res.geturl(), - "https://docs.python.org/2/glossary.html#glossary") + "http://docs.python.org/glossary.html#glossary") def test_fileno(self): - req = urllib2.Request("http://www.example.com") + req = urllib2.Request("http://www.python.org") opener = urllib2.build_opener() res = opener.open(req) try: @@ -250,15 +250,15 @@ class TimeoutTest(unittest.TestCase): def test_http_basic(self): - self.assertIsNone(socket.getdefaulttimeout()) - url = "http://www.example.com" + self.assertTrue(socket.getdefaulttimeout() is None) + url = "http://www.python.org" with test_support.transient_internet(url, timeout=None): u = _urlopen_with_retry(url) - self.assertIsNone(u.fp._sock.fp._sock.gettimeout()) + self.assertTrue(u.fp._sock.fp._sock.gettimeout() is None) def test_http_default_timeout(self): - self.assertIsNone(socket.getdefaulttimeout()) - url = "http://www.example.com" + self.assertTrue(socket.getdefaulttimeout() is None) + url = "http://www.python.org" with test_support.transient_internet(url): socket.setdefaulttimeout(60) try: @@ -268,18 +268,18 @@ self.assertEqual(u.fp._sock.fp._sock.gettimeout(), 60) def test_http_no_timeout(self): - self.assertIsNone(socket.getdefaulttimeout()) - url = "http://www.example.com" + self.assertTrue(socket.getdefaulttimeout() is None) + url = "http://www.python.org" with test_support.transient_internet(url): socket.setdefaulttimeout(60) try: u = _urlopen_with_retry(url, timeout=None) finally: socket.setdefaulttimeout(None) - self.assertIsNone(u.fp._sock.fp._sock.gettimeout()) + self.assertTrue(u.fp._sock.fp._sock.gettimeout() is None) def test_http_timeout(self): - url = "http://www.example.com" + url = "http://www.python.org" with test_support.transient_internet(url): u = _urlopen_with_retry(url, timeout=120) self.assertEqual(u.fp._sock.fp._sock.gettimeout(), 120) @@ -287,13 +287,13 @@ FTP_HOST = "ftp://ftp.mirror.nl/pub/gnu/" def test_ftp_basic(self): - self.assertIsNone(socket.getdefaulttimeout()) + self.assertTrue(socket.getdefaulttimeout() is None) with test_support.transient_internet(self.FTP_HOST, timeout=None): u = _urlopen_with_retry(self.FTP_HOST) - self.assertIsNone(u.fp.fp._sock.gettimeout()) + self.assertTrue(u.fp.fp._sock.gettimeout() is None) def test_ftp_default_timeout(self): - self.assertIsNone(socket.getdefaulttimeout()) + self.assertTrue(socket.getdefaulttimeout() is None) with test_support.transient_internet(self.FTP_HOST): socket.setdefaulttimeout(60) try: @@ -303,14 +303,14 @@ self.assertEqual(u.fp.fp._sock.gettimeout(), 60) def test_ftp_no_timeout(self): - self.assertIsNone(socket.getdefaulttimeout(),) + self.assertTrue(socket.getdefaulttimeout() is None) with test_support.transient_internet(self.FTP_HOST): socket.setdefaulttimeout(60) try: u = _urlopen_with_retry(self.FTP_HOST, timeout=None) finally: socket.setdefaulttimeout(None) - self.assertIsNone(u.fp.fp._sock.gettimeout()) + self.assertTrue(u.fp.fp._sock.gettimeout() is None) def test_ftp_timeout(self): with test_support.transient_internet(self.FTP_HOST): diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Lib/test/test_urllibnet.py --- a/Lib/test/test_urllibnet.py Sat Jul 19 16:34:33 2014 -0700 +++ b/Lib/test/test_urllibnet.py Sun Jul 20 10:52:46 2014 -0400 @@ -1,3 +1,5 @@ +#!/usr/bin/env python + import unittest from test import test_support @@ -34,7 +36,7 @@ socket.setdefaulttimeout(None) def testURLread(self): - f = _open_with_retry(urllib.urlopen, "http://www.example.com/") + f = _open_with_retry(urllib.urlopen, "http://www.python.org/") x = f.read() class urlopenNetworkTests(unittest.TestCase): @@ -46,7 +48,7 @@ for transparent redirection have been written. setUp is not used for always constructing a connection to - http://www.example.com/ since there a few tests that don't use that address + http://www.python.org/ since there a few tests that don't use that address and making a connection is expensive enough to warrant minimizing unneeded connections. @@ -57,7 +59,7 @@ def test_basic(self): # Simple test expected to pass. - open_url = self.urlopen("http://www.example.com/") + open_url = self.urlopen("http://www.python.org/") for attr in ("read", "readline", "readlines", "fileno", "close", "info", "geturl"): self.assertTrue(hasattr(open_url, attr), "object returned from " @@ -69,7 +71,7 @@ def test_readlines(self): # Test both readline and readlines. - open_url = self.urlopen("http://www.example.com/") + open_url = self.urlopen("http://www.python.org/") try: self.assertIsInstance(open_url.readline(), basestring, "readline did not return a string") @@ -80,7 +82,7 @@ def test_info(self): # Test 'info'. - open_url = self.urlopen("http://www.example.com/") + open_url = self.urlopen("http://www.python.org/") try: info_obj = open_url.info() finally: @@ -92,7 +94,7 @@ def test_geturl(self): # Make sure same URL as opened is returned by geturl. - URL = "http://www.example.com/" + URL = "http://www.python.org/" open_url = self.urlopen(URL) try: gotten_url = open_url.geturl() @@ -102,7 +104,7 @@ def test_getcode(self): # test getcode() with the fancy opener to get 404 error codes - URL = "http://www.example.com/XXXinvalidXXX" + URL = "http://www.python.org/XXXinvalidXXX" open_url = urllib.FancyURLopener().open(URL) try: code = open_url.getcode() @@ -110,11 +112,14 @@ open_url.close() self.assertEqual(code, 404) - @unittest.skipIf(sys.platform in ('win32',), 'not appropriate for Windows') - @unittest.skipUnless(hasattr(os, 'fdopen'), 'os.fdopen not available') def test_fileno(self): + if (sys.platform in ('win32',) or + not hasattr(os, 'fdopen')): + # On Windows, socket handles are not file descriptors; this + # test can't pass on Windows. + return # Make sure fd returned by fileno is valid. - open_url = self.urlopen("http://www.example.com/") + open_url = self.urlopen("http://www.python.org/") fd = open_url.fileno() FILE = os.fdopen(fd) try: @@ -152,7 +157,7 @@ def test_basic(self): # Test basic functionality. - file_location,info = self.urlretrieve("http://www.example.com/") + file_location,info = self.urlretrieve("http://www.python.org/") self.assertTrue(os.path.exists(file_location), "file location returned by" " urlretrieve is not a valid path") FILE = file(file_location) @@ -165,7 +170,7 @@ def test_specified_path(self): # Make sure that specifying the location of the file to write to works. - file_location,info = self.urlretrieve("http://www.example.com/", + file_location,info = self.urlretrieve("http://www.python.org/", test_support.TESTFN) self.assertEqual(file_location, test_support.TESTFN) self.assertTrue(os.path.exists(file_location)) @@ -178,13 +183,13 @@ def test_header(self): # Make sure header returned as 2nd value from urlretrieve is good. - file_location, header = self.urlretrieve("http://www.example.com/") + file_location, header = self.urlretrieve("http://www.python.org/") os.unlink(file_location) self.assertIsInstance(header, mimetools.Message, "header is not an instance of mimetools.Message") def test_data_header(self): - logo = "http://www.example.com/" + logo = "http://www.python.org/community/logos/python-logo-master-v3-TM.png" file_location, fileheaders = self.urlretrieve(logo) os.unlink(file_location) datevalue = fileheaders.getheader('Date') diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Lib/test/test_urlparse.py --- a/Lib/test/test_urlparse.py Sat Jul 19 16:34:33 2014 -0700 +++ b/Lib/test/test_urlparse.py Sun Jul 20 10:52:46 2014 -0400 @@ -1,3 +1,5 @@ +#! /usr/bin/env python + from test import test_support import unittest import urlparse @@ -362,16 +364,6 @@ ('http://[::12.34.56.78]/foo/', '::12.34.56.78', None), ('http://[::ffff:12.34.56.78]/foo/', '::ffff:12.34.56.78', None), - ('http://Test.python.org:/foo/', 'test.python.org', None), - ('http://12.34.56.78:/foo/', '12.34.56.78', None), - ('http://[::1]:/foo/', '::1', None), - ('http://[dead:beef::1]:/foo/', 'dead:beef::1', None), - ('http://[dead:beef::]:/foo/', 'dead:beef::', None), - ('http://[dead:beef:cafe:5417:affe:8FA3:deaf:feed]:/foo/', - 'dead:beef:cafe:5417:affe:8fa3:deaf:feed', None), - ('http://[::12.34.56.78]:/foo/', '::12.34.56.78', None), - ('http://[::ffff:12.34.56.78]:/foo/', - '::ffff:12.34.56.78', None), ]: urlparsed = urlparse.urlparse(url) self.assertEqual((urlparsed.hostname, urlparsed.port) , (hostname, port)) @@ -445,51 +437,6 @@ self.assertEqual(p.port, 80) self.assertEqual(p.geturl(), url) - # Verify an illegal port of value greater than 65535 is set as None - url = "http://www.python.org:65536" - p = urlparse.urlsplit(url) - self.assertEqual(p.port, None) - - def test_issue14072(self): - p1 = urlparse.urlsplit('tel:+31-641044153') - self.assertEqual(p1.scheme, 'tel') - self.assertEqual(p1.path, '+31-641044153') - - p2 = urlparse.urlsplit('tel:+31641044153') - self.assertEqual(p2.scheme, 'tel') - self.assertEqual(p2.path, '+31641044153') - - # Assert for urlparse - p1 = urlparse.urlparse('tel:+31-641044153') - self.assertEqual(p1.scheme, 'tel') - self.assertEqual(p1.path, '+31-641044153') - - p2 = urlparse.urlparse('tel:+31641044153') - self.assertEqual(p2.scheme, 'tel') - self.assertEqual(p2.path, '+31641044153') - - - def test_telurl_params(self): - p1 = urlparse.urlparse('tel:123-4;phone-context=+1-650-516') - self.assertEqual(p1.scheme, 'tel') - self.assertEqual(p1.path, '123-4') - self.assertEqual(p1.params, 'phone-context=+1-650-516') - - p1 = urlparse.urlparse('tel:+1-201-555-0123') - self.assertEqual(p1.scheme, 'tel') - self.assertEqual(p1.path, '+1-201-555-0123') - self.assertEqual(p1.params, '') - - p1 = urlparse.urlparse('tel:7042;phone-context=example.com') - self.assertEqual(p1.scheme, 'tel') - self.assertEqual(p1.path, '7042') - self.assertEqual(p1.params, 'phone-context=example.com') - - p1 = urlparse.urlparse('tel:863-1234;phone-context=+1-914-555') - self.assertEqual(p1.scheme, 'tel') - self.assertEqual(p1.path, '863-1234') - self.assertEqual(p1.params, 'phone-context=+1-914-555') - def test_attributes_bad_port(self): """Check handling of non-integer ports.""" @@ -546,10 +493,6 @@ ('s3','foo.com','/stuff','','','')) self.assertEqual(urlparse.urlparse("x-newscheme://foo.com/stuff"), ('x-newscheme','foo.com','/stuff','','','')) - self.assertEqual(urlparse.urlparse("x-newscheme://foo.com/stuff?query#fragment"), - ('x-newscheme','foo.com','/stuff','','query','fragment')) - self.assertEqual(urlparse.urlparse("x-newscheme://foo.com/stuff?query"), - ('x-newscheme','foo.com','/stuff','','query','')) def test_withoutscheme(self): # Test urlparse without scheme diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Lib/test/test_userstring.py --- a/Lib/test/test_userstring.py Sat Jul 19 16:34:33 2014 -0700 +++ b/Lib/test/test_userstring.py Sun Jul 20 10:52:46 2014 -0400 @@ -1,3 +1,4 @@ +#!/usr/bin/env python # UserString is a wrapper around the native builtin string type. # UserString instances should behave similar to builtin string objects. diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Lib/test/test_uu.py --- a/Lib/test/test_uu.py Sat Jul 19 16:34:33 2014 -0700 +++ b/Lib/test/test_uu.py Sun Jul 20 10:52:46 2014 -0400 @@ -48,7 +48,7 @@ out = cStringIO.StringIO() try: uu.decode(inp, out) - self.fail("No exception raised") + self.fail("No exception thrown") except uu.Error, e: self.assertEqual(str(e), "Truncated input file") @@ -57,7 +57,7 @@ out = cStringIO.StringIO() try: uu.decode(inp, out) - self.fail("No exception raised") + self.fail("No exception thrown") except uu.Error, e: self.assertEqual(str(e), "No valid begin line found in input file") diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Lib/test/test_uuid.py --- a/Lib/test/test_uuid.py Sat Jul 19 16:34:33 2014 -0700 +++ b/Lib/test/test_uuid.py Sun Jul 20 10:52:46 2014 -0400 @@ -1,7 +1,5 @@ -import unittest +from unittest import TestCase from test import test_support -import io -import os import uuid def importable(name): @@ -11,7 +9,7 @@ except: return False -class TestUUID(unittest.TestCase): +class TestUUID(TestCase): last_node = None source2node = {} @@ -301,22 +299,24 @@ else: TestUUID.last_node = node - @unittest.skipUnless(os.name == 'posix', 'requires Posix') def test_ifconfig_getnode(self): - node = uuid._ifconfig_getnode() - if node is not None: - self.check_node(node, 'ifconfig') + import sys + import os + if os.name == 'posix': + node = uuid._ifconfig_getnode() + if node is not None: + self.check_node(node, 'ifconfig') - @unittest.skipUnless(os.name == 'nt', 'requires Windows') def test_ipconfig_getnode(self): - node = uuid._ipconfig_getnode() - if node is not None: - self.check_node(node, 'ipconfig') + import os + if os.name == 'nt': + node = uuid._ipconfig_getnode() + if node is not None: + self.check_node(node, 'ipconfig') - @unittest.skipUnless(importable('win32wnet'), 'requires win32wnet') - @unittest.skipUnless(importable('netbios'), 'requires netbios') def test_netbios_getnode(self): - self.check_node(uuid._netbios_getnode(), 'netbios') + if importable('win32wnet') and importable('netbios'): + self.check_node(uuid._netbios_getnode(), 'netbios') def test_random_getnode(self): node = uuid._random_getnode() @@ -324,20 +324,22 @@ self.assertTrue(node & 0x010000000000) self.assertTrue(node < (1L << 48)) - @unittest.skipUnless(os.name == 'posix', 'requires Posix') - @unittest.skipUnless(importable('ctypes'), 'requires ctypes') def test_unixdll_getnode(self): - try: # Issues 1481, 3581: _uuid_generate_time() might be None. - self.check_node(uuid._unixdll_getnode(), 'unixdll') - except TypeError: - pass + import sys + import os + if importable('ctypes') and os.name == 'posix': + try: # Issues 1481, 3581: _uuid_generate_time() might be None. + self.check_node(uuid._unixdll_getnode(), 'unixdll') + except TypeError: + pass - @unittest.skipUnless(os.name == 'nt', 'requires Windows') - @unittest.skipUnless(importable('ctypes'), 'requires ctypes') def test_windll_getnode(self): - self.check_node(uuid._windll_getnode(), 'windll') + import os + if importable('ctypes') and os.name == 'nt': + self.check_node(uuid._windll_getnode(), 'windll') def test_getnode(self): + import sys node1 = uuid.getnode() self.check_node(node1, "getnode1") @@ -347,39 +349,13 @@ self.assertEqual(node1, node2) - @unittest.skipUnless(os.name == 'posix', 'requires Posix') - def test_find_mac(self): - data = '''\ + def test_uuid1(self): + # uuid1 requires ctypes. + try: + import ctypes + except ImportError: + return -fake hwaddr -cscotun0 Link encap:UNSPEC HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00 -eth0 Link encap:Ethernet HWaddr 12:34:56:78:90:ab -''' - def mock_popen(cmd): - return io.BytesIO(data) - - path = os.environ.get("PATH", os.defpath).split(os.pathsep) - path.extend(('/sbin', '/usr/sbin')) - for dir in path: - executable = os.path.join(dir, 'ifconfig') - if (os.path.exists(executable) and - os.access(executable, os.F_OK | os.X_OK) and - not os.path.isdir(executable)): - break - else: - self.skipTest('requires ifconfig') - - with test_support.swap_attr(os, 'popen', mock_popen): - mac = uuid._find_mac( - command='ifconfig', - args='', - hw_identifiers=['hwaddr'], - get_index=lambda x: x + 1, - ) - self.assertEqual(mac, 0x1234567890ab) - - @unittest.skipUnless(importable('ctypes'), 'requires ctypes') - def test_uuid1(self): equal = self.assertEqual # Make sure uuid1() generates UUIDs that are actually version 1. @@ -432,8 +408,13 @@ equal(u, uuid.UUID(v)) equal(str(u), v) - @unittest.skipUnless(importable('ctypes'), 'requires ctypes') def test_uuid4(self): + # uuid4 requires ctypes. + try: + import ctypes + except ImportError: + return + equal = self.assertEqual # Make sure uuid4() generates UUIDs that are actually version 4. @@ -465,8 +446,12 @@ equal(u, uuid.UUID(v)) equal(str(u), v) - @unittest.skipUnless(os.name == 'posix', 'requires Posix') def testIssue8621(self): + import os + import sys + if os.name != 'posix': + return + # On at least some versions of OSX uuid.uuid4 generates # the same sequence of UUIDs in the parent and any # children started using fork. @@ -480,7 +465,6 @@ else: os.close(fds[1]) - self.addCleanup(os.close, fds[0]) parent_value = uuid.uuid4().hex os.waitpid(pid, 0) child_value = os.read(fds[0], 100) diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Lib/test/test_wait4.py --- a/Lib/test/test_wait4.py Sat Jul 19 16:34:33 2014 -0700 +++ b/Lib/test/test_wait4.py Sun Jul 20 10:52:46 2014 -0400 @@ -3,7 +3,6 @@ import os import time -import sys from test.fork_wait import ForkWait from test.test_support import run_unittest, reap_children, get_attribute @@ -14,15 +13,10 @@ class Wait4Test(ForkWait): def wait_impl(self, cpid): - option = os.WNOHANG - if sys.platform.startswith('aix'): - # Issue #11185: wait4 is broken on AIX and will always return 0 - # with WNOHANG. - option = 0 for i in range(10): # wait4() shouldn't hang, but some of the buildbots seem to hang # in the forking tests. This is an attempt to fix the problem. - spid, status, rusage = os.wait4(cpid, option) + spid, status, rusage = os.wait4(cpid, os.WNOHANG) if spid == cpid: break time.sleep(1.0) diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Lib/test/test_warnings.py --- a/Lib/test/test_warnings.py Sat Jul 19 16:34:33 2014 -0700 +++ b/Lib/test/test_warnings.py Sun Jul 20 10:52:46 2014 -0400 @@ -259,10 +259,11 @@ finally: warning_tests.__file__ = filename - @unittest.skipUnless(hasattr(sys, 'argv'), 'test needs sys.argv') def test_missing_filename_main_with_argv(self): # If __file__ is not specified and the caller is __main__ and sys.argv # exists, then use sys.argv[0] as the file. + if not hasattr(sys, 'argv'): + return filename = warning_tests.__file__ module_name = warning_tests.__name__ try: @@ -668,7 +669,7 @@ # Explicit tests for the test_support convenience wrapper wmod = self.module if wmod is not sys.modules['warnings']: - self.skipTest('module to test is not loaded warnings module') + return with test_support.check_warnings(quiet=False) as w: self.assertEqual(w.warnings, []) wmod.simplefilter("always") diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Lib/test/test_wave.py --- a/Lib/test/test_wave.py Sat Jul 19 16:34:33 2014 -0700 +++ b/Lib/test/test_wave.py Sun Jul 20 10:52:46 2014 -0400 @@ -1,123 +1,45 @@ from test.test_support import TESTFN, run_unittest +import os +import wave import unittest -from test import audiotests -import sys -import wave +nchannels = 2 +sampwidth = 2 +framerate = 8000 +nframes = 100 -class WaveTest(audiotests.AudioWriteTests, - audiotests.AudioTestsWithSourceFile): - module = wave - test_unseekable_write = None - test_unseekable_overflowed_write = None - test_unseekable_incompleted_write = None +class TestWave(unittest.TestCase): + def setUp(self): + self.f = None -class WavePCM8Test(WaveTest, unittest.TestCase): - sndfilename = 'pluck-pcm8.wav' - sndfilenframes = 3307 - nchannels = 2 - sampwidth = 1 - framerate = 11025 - nframes = 48 - comptype = 'NONE' - compname = 'not compressed' - frames = audiotests.fromhex("""\ - 827F CB80 B184 0088 4B86 C883 3F81 837E 387A 3473 A96B 9A66 \ - 6D64 4662 8E60 6F60 D762 7B68 936F 5877 177B 757C 887B 5F7B \ - 917A BE7B 3C7C E67F 4F84 C389 418E D192 6E97 0296 FF94 0092 \ - C98E D28D 6F8F 4E8F 648C E38A 888A AB8B D18E 0B91 368E C48A \ - """) + def tearDown(self): + if self.f is not None: + self.f.close() + try: + os.remove(TESTFN) + except OSError: + pass + def test_it(self): + self.f = wave.open(TESTFN, 'wb') + self.f.setnchannels(nchannels) + self.f.setsampwidth(sampwidth) + self.f.setframerate(framerate) + self.f.setnframes(nframes) + output = '\0' * nframes * nchannels * sampwidth + self.f.writeframes(output) + self.f.close() -class WavePCM16Test(WaveTest, unittest.TestCase): - sndfilename = 'pluck-pcm16.wav' - sndfilenframes = 3307 - nchannels = 2 - sampwidth = 2 - framerate = 11025 - nframes = 48 - comptype = 'NONE' - compname = 'not compressed' - frames = audiotests.fromhex("""\ - 022EFFEA 4B5C00F9 311404EF 80DC0843 CBDF06B2 48AA03F3 BFE701B2 036BFE7C \ - B857FA3E B4B2F34F 2999EBCA 1A5FE6D7 EDFCE491 C626E279 0E05E0B8 EF27E02D \ - 5754E275 FB31E843 1373EF89 D827F72C 978BFB7A F5F7FC11 0866FB9C DF30FB42 \ - 117FFA36 3EE4FB5D BC75FCB6 66D5FF5F CF16040E 43220978 C1BC0EC8 511F12A4 \ - EEDF1755 82061666 7FFF1446 80001296 499C0EB2 52BA0DB9 EFB70F5C CE400FBC \ - E4B50CEB 63440A5A 08CA0A1F 2BBA0B0B 51460E47 8BCB113C B6F50EEA 44150A59 \ - """) - if sys.byteorder != 'big': - frames = audiotests.byteswap2(frames) - - if sys.byteorder == 'big': - @unittest.expectedFailure - def test_unseekable_incompleted_write(self): - super().test_unseekable_incompleted_write() - - - -class WavePCM24Test(WaveTest, unittest.TestCase): - sndfilename = 'pluck-pcm24.wav' - sndfilenframes = 3307 - nchannels = 2 - sampwidth = 3 - framerate = 11025 - nframes = 48 - comptype = 'NONE' - compname = 'not compressed' - frames = audiotests.fromhex("""\ - 022D65FFEB9D 4B5A0F00FA54 3113C304EE2B 80DCD6084303 \ - CBDEC006B261 48A99803F2F8 BFE82401B07D 036BFBFE7B5D \ - B85756FA3EC9 B4B055F3502B 299830EBCB62 1A5CA7E6D99A \ - EDFA3EE491BD C625EBE27884 0E05A9E0B6CF EF2929E02922 \ - 5758D8E27067 FB3557E83E16 1377BFEF8402 D82C5BF7272A \ - 978F16FB7745 F5F865FC1013 086635FB9C4E DF30FCFB40EE \ - 117FE0FA3438 3EE6B8FB5AC3 BC77A3FCB2F4 66D6DAFF5F32 \ - CF13B9041275 431D69097A8C C1BB600EC74E 5120B912A2BA \ - EEDF641754C0 8207001664B7 7FFFFF14453F 8000001294E6 \ - 499C1B0EB3B2 52B73E0DBCA0 EFB2B20F5FD8 CE3CDB0FBE12 \ - E4B49C0CEA2D 6344A80A5A7C 08C8FE0A1FFE 2BB9860B0A0E \ - 51486F0E44E1 8BCC64113B05 B6F4EC0EEB36 4413170A5B48 \ - """) - if sys.byteorder != 'big': - frames = audiotests.byteswap3(frames) - - -class WavePCM32Test(WaveTest, unittest.TestCase): - sndfilename = 'pluck-pcm32.wav' - sndfilenframes = 3307 - nchannels = 2 - sampwidth = 4 - framerate = 11025 - nframes = 48 - comptype = 'NONE' - compname = 'not compressed' - frames = audiotests.fromhex("""\ - 022D65BCFFEB9D92 4B5A0F8000FA549C 3113C34004EE2BC0 80DCD680084303E0 \ - CBDEC0C006B26140 48A9980003F2F8FC BFE8248001B07D92 036BFB60FE7B5D34 \ - B8575600FA3EC920 B4B05500F3502BC0 29983000EBCB6240 1A5CA7A0E6D99A60 \ - EDFA3E80E491BD40 C625EB80E27884A0 0E05A9A0E0B6CFE0 EF292940E0292280 \ - 5758D800E2706700 FB3557D8E83E1640 1377BF00EF840280 D82C5B80F7272A80 \ - 978F1600FB774560 F5F86510FC101364 086635A0FB9C4E20 DF30FC40FB40EE28 \ - 117FE0A0FA3438B0 3EE6B840FB5AC3F0 BC77A380FCB2F454 66D6DA80FF5F32B4 \ - CF13B980041275B0 431D6980097A8C00 C1BB60000EC74E00 5120B98012A2BAA0 \ - EEDF64C01754C060 820700001664B780 7FFFFFFF14453F40 800000001294E6E0 \ - 499C1B000EB3B270 52B73E000DBCA020 EFB2B2E00F5FD880 CE3CDB400FBE1270 \ - E4B49CC00CEA2D90 6344A8800A5A7CA0 08C8FE800A1FFEE0 2BB986C00B0A0E00 \ - 51486F800E44E190 8BCC6480113B0580 B6F4EC000EEB3630 441317800A5B48A0 \ - """) - if sys.byteorder != 'big': - frames = audiotests.byteswap4(frames) - - if sys.byteorder == 'big': - @unittest.expectedFailure - def test_unseekable_incompleted_write(self): - super().test_unseekable_incompleted_write() - + self.f = wave.open(TESTFN, 'rb') + self.assertEqual(nchannels, self.f.getnchannels()) + self.assertEqual(sampwidth, self.f.getsampwidth()) + self.assertEqual(framerate, self.f.getframerate()) + self.assertEqual(nframes, self.f.getnframes()) + self.assertEqual(self.f.readframes(nframes), output) def test_main(): - run_unittest(WavePCM8Test, WavePCM16Test, WavePCM24Test, WavePCM32Test) + run_unittest(TestWave) if __name__ == '__main__': test_main() diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Lib/test/test_weakref.py --- a/Lib/test/test_weakref.py Sat Jul 19 16:34:33 2014 -0700 +++ b/Lib/test/test_weakref.py Sun Jul 20 10:52:46 2014 -0400 @@ -4,8 +4,6 @@ import UserList import weakref import operator -import contextlib -import copy from test import test_support @@ -35,27 +33,6 @@ return C.method -class Object: - def __init__(self, arg): - self.arg = arg - def __repr__(self): - return "" % self.arg - def __eq__(self, other): - if isinstance(other, Object): - return self.arg == other.arg - return NotImplemented - def __ne__(self, other): - if isinstance(other, Object): - return self.arg != other.arg - return NotImplemented - def __hash__(self): - return hash(self.arg) - -class RefCycle: - def __init__(self): - self.cycle = self - - class TestBase(unittest.TestCase): def setUp(self): @@ -93,9 +70,11 @@ ref1 = weakref.ref(o, self.callback) ref2 = weakref.ref(o, self.callback) del o - self.assertIsNone(ref1(), "expected reference to be invalidated") - self.assertIsNone(ref2(), "expected reference to be invalidated") - self.assertEqual(self.cbcalled, 2, + self.assertTrue(ref1() is None, + "expected reference to be invalidated") + self.assertTrue(ref2() is None, + "expected reference to be invalidated") + self.assertTrue(self.cbcalled == 2, "callback not called the right number of times") def test_multiple_selfref_callbacks(self): @@ -129,15 +108,15 @@ self.assertRaises(weakref.ReferenceError, check, ref1) self.assertRaises(weakref.ReferenceError, check, ref2) self.assertRaises(weakref.ReferenceError, bool, weakref.proxy(C())) - self.assertEqual(self.cbcalled, 2) + self.assertTrue(self.cbcalled == 2) def check_basic_ref(self, factory): o = factory() ref = weakref.ref(o) - self.assertIsNotNone(ref(), + self.assertTrue(ref() is not None, "weak reference to live object should be live") o2 = ref() - self.assertIs(o, o2, + self.assertTrue(o is o2, "() should return original object if live") def check_basic_callback(self, factory): @@ -145,9 +124,9 @@ o = factory() ref = weakref.ref(o, self.callback) del o - self.assertEqual(self.cbcalled, 1, + self.assertTrue(self.cbcalled == 1, "callback did not properly set 'cbcalled'") - self.assertIsNone(ref(), + self.assertTrue(ref() is None, "ref2 should be dead after deleting object reference") def test_ref_reuse(self): @@ -157,19 +136,19 @@ # between these two; it should make no difference proxy = weakref.proxy(o) ref2 = weakref.ref(o) - self.assertIs(ref1, ref2, + self.assertTrue(ref1 is ref2, "reference object w/out callback should be re-used") o = C() proxy = weakref.proxy(o) ref1 = weakref.ref(o) ref2 = weakref.ref(o) - self.assertIs(ref1, ref2, + self.assertTrue(ref1 is ref2, "reference object w/out callback should be re-used") - self.assertEqual(weakref.getweakrefcount(o), 2, + self.assertTrue(weakref.getweakrefcount(o) == 2, "wrong weak ref count for object") del proxy - self.assertEqual(weakref.getweakrefcount(o), 1, + self.assertTrue(weakref.getweakrefcount(o) == 1, "wrong weak ref count for object after deleting proxy") def test_proxy_reuse(self): @@ -177,7 +156,7 @@ proxy1 = weakref.proxy(o) ref = weakref.ref(o) proxy2 = weakref.proxy(o) - self.assertIs(proxy1, proxy2, + self.assertTrue(proxy1 is proxy2, "proxy object w/out callback should have been re-used") def test_basic_proxy(self): @@ -259,19 +238,19 @@ o = Object(1) p1 = makeref(o, None) p2 = makeref(o, None) - self.assertIs(p1, p2, "both callbacks were None in the C API") + self.assertTrue(p1 is p2, "both callbacks were None in the C API") del p1, p2 p1 = makeref(o) p2 = makeref(o, None) - self.assertIs(p1, p2, "callbacks were NULL, None in the C API") + self.assertTrue(p1 is p2, "callbacks were NULL, None in the C API") del p1, p2 p1 = makeref(o) p2 = makeref(o) - self.assertIs(p1, p2, "both callbacks were NULL in the C API") + self.assertTrue(p1 is p2, "both callbacks were NULL in the C API") del p1, p2 p1 = makeref(o, None) p2 = makeref(o) - self.assertIs(p1, p2, "callbacks were None, NULL in the C API") + self.assertTrue(p1 is p2, "callbacks were None, NULL in the C API") def test_callable_proxy(self): o = Callable() @@ -279,13 +258,13 @@ self.check_proxy(o, ref1) - self.assertIs(type(ref1), weakref.CallableProxyType, + self.assertTrue(type(ref1) is weakref.CallableProxyType, "proxy is not of callable type") ref1('twinkies!') - self.assertEqual(o.bar, 'twinkies!', + self.assertTrue(o.bar == 'twinkies!', "call through proxy not passed through to original") ref1(x='Splat.') - self.assertEqual(o.bar, 'Splat.', + self.assertTrue(o.bar == 'Splat.', "call through proxy not passed through to original") # expect due to too few args @@ -296,23 +275,24 @@ def check_proxy(self, o, proxy): o.foo = 1 - self.assertEqual(proxy.foo, 1, + self.assertTrue(proxy.foo == 1, "proxy does not reflect attribute addition") o.foo = 2 - self.assertEqual(proxy.foo, 2, + self.assertTrue(proxy.foo == 2, "proxy does not reflect attribute modification") del o.foo - self.assertFalse(hasattr(proxy, 'foo'), + self.assertTrue(not hasattr(proxy, 'foo'), "proxy does not reflect attribute removal") proxy.foo = 1 - self.assertEqual(o.foo, 1, + self.assertTrue(o.foo == 1, "object does not reflect attribute addition via proxy") proxy.foo = 2 - self.assertEqual(o.foo, 2, + self.assertTrue( + o.foo == 2, "object does not reflect attribute modification via proxy") del proxy.foo - self.assertFalse(hasattr(o, 'foo'), + self.assertTrue(not hasattr(o, 'foo'), "object does not reflect attribute removal via proxy") def test_proxy_deletion(self): @@ -336,21 +316,21 @@ o = C() ref1 = weakref.ref(o) ref2 = weakref.ref(o, self.callback) - self.assertEqual(weakref.getweakrefcount(o), 2, + self.assertTrue(weakref.getweakrefcount(o) == 2, "got wrong number of weak reference objects") proxy1 = weakref.proxy(o) proxy2 = weakref.proxy(o, self.callback) - self.assertEqual(weakref.getweakrefcount(o), 4, + self.assertTrue(weakref.getweakrefcount(o) == 4, "got wrong number of weak reference objects") del ref1, ref2, proxy1, proxy2 - self.assertEqual(weakref.getweakrefcount(o), 0, + self.assertTrue(weakref.getweakrefcount(o) == 0, "weak reference objects not unlinked from" " referent when discarded.") # assumes ints do not support weakrefs - self.assertEqual(weakref.getweakrefcount(1), 0, + self.assertTrue(weakref.getweakrefcount(1) == 0, "got wrong number of weak reference objects for int") def test_getweakrefs(self): @@ -358,22 +338,22 @@ ref1 = weakref.ref(o, self.callback) ref2 = weakref.ref(o, self.callback) del ref1 - self.assertEqual(weakref.getweakrefs(o), [ref2], + self.assertTrue(weakref.getweakrefs(o) == [ref2], "list of refs does not match") o = C() ref1 = weakref.ref(o, self.callback) ref2 = weakref.ref(o, self.callback) del ref2 - self.assertEqual(weakref.getweakrefs(o), [ref1], + self.assertTrue(weakref.getweakrefs(o) == [ref1], "list of refs does not match") del ref1 - self.assertEqual(weakref.getweakrefs(o), [], + self.assertTrue(weakref.getweakrefs(o) == [], "list of refs not cleared") # assumes ints do not support weakrefs - self.assertEqual(weakref.getweakrefs(1), [], + self.assertTrue(weakref.getweakrefs(1) == [], "list of refs does not match for int") def test_newstyle_number_ops(self): @@ -381,8 +361,8 @@ pass f = F(2.0) p = weakref.proxy(f) - self.assertEqual(p + 1.0, 3.0) - self.assertEqual(1.0 + p, 3.0) # this used to SEGV + self.assertTrue(p + 1.0 == 3.0) + self.assertTrue(1.0 + p == 3.0) # this used to SEGV def test_callbacks_protected(self): # Callbacks protected from already-set exceptions? @@ -635,7 +615,7 @@ c.wr = weakref.ref(d, callback) # this won't trigger d.wr = weakref.ref(callback, d.cb) # ditto external_wr = weakref.ref(callback, safe_callback) # but this will - self.assertIs(external_wr(), callback) + self.assertTrue(external_wr() is callback) # The weakrefs attached to c and d should get cleared, so that # C.cb is never called. But external_wr isn't part of the cyclic @@ -725,75 +705,6 @@ self.assertEqual(b(), None) self.assertEqual(l, [a, b]) - def test_equality(self): - # Alive weakrefs defer equality testing to their underlying object. - x = Object(1) - y = Object(1) - z = Object(2) - a = weakref.ref(x) - b = weakref.ref(y) - c = weakref.ref(z) - d = weakref.ref(x) - # Note how we directly test the operators here, to stress both - # __eq__ and __ne__. - self.assertTrue(a == b) - self.assertFalse(a != b) - self.assertFalse(a == c) - self.assertTrue(a != c) - self.assertTrue(a == d) - self.assertFalse(a != d) - del x, y, z - gc.collect() - for r in a, b, c: - # Sanity check - self.assertIs(r(), None) - # Dead weakrefs compare by identity: whether `a` and `d` are the - # same weakref object is an implementation detail, since they pointed - # to the same original object and didn't have a callback. - # (see issue #16453). - self.assertFalse(a == b) - self.assertTrue(a != b) - self.assertFalse(a == c) - self.assertTrue(a != c) - self.assertEqual(a == d, a is d) - self.assertEqual(a != d, a is not d) - - def test_hashing(self): - # Alive weakrefs hash the same as the underlying object - x = Object(42) - y = Object(42) - a = weakref.ref(x) - b = weakref.ref(y) - self.assertEqual(hash(a), hash(42)) - del x, y - gc.collect() - # Dead weakrefs: - # - retain their hash is they were hashed when alive; - # - otherwise, cannot be hashed. - self.assertEqual(hash(a), hash(42)) - self.assertRaises(TypeError, hash, b) - - def test_trashcan_16602(self): - # Issue #16602: when a weakref's target was part of a long - # deallocation chain, the trashcan mechanism could delay clearing - # of the weakref and make the target object visible from outside - # code even though its refcount had dropped to 0. A crash ensued. - class C(object): - def __init__(self, parent): - if not parent: - return - wself = weakref.ref(self) - def cb(wparent): - o = wself() - self.wparent = weakref.ref(parent, cb) - - d = weakref.WeakKeyDictionary() - root = c = C(None) - for n in range(100): - d[c] = c = C(c) - del root - gc.collect() - class SubclassableWeakrefTestCase(TestBase): @@ -807,11 +718,11 @@ return super(MyRef, self).__call__() o = Object("foo") mr = MyRef(o, value=24) - self.assertIs(mr(), o) + self.assertTrue(mr() is o) self.assertTrue(mr.called) self.assertEqual(mr.value, 24) del o - self.assertIsNone(mr()) + self.assertTrue(mr() is None) self.assertTrue(mr.called) def test_subclass_refs_dont_replace_standard_refs(self): @@ -820,14 +731,14 @@ o = Object(42) r1 = MyRef(o) r2 = weakref.ref(o) - self.assertIsNot(r1, r2) + self.assertTrue(r1 is not r2) self.assertEqual(weakref.getweakrefs(o), [r2, r1]) self.assertEqual(weakref.getweakrefcount(o), 2) r3 = MyRef(o) self.assertEqual(weakref.getweakrefcount(o), 3) refs = weakref.getweakrefs(o) self.assertEqual(len(refs), 3) - self.assertIs(r2, refs[0]) + self.assertTrue(r2 is refs[0]) self.assertIn(r1, refs[1:]) self.assertIn(r3, refs[1:]) @@ -837,7 +748,7 @@ o = Object(42) r1 = MyRef(o, id) r2 = MyRef(o, str) - self.assertIsNot(r1, r2) + self.assertTrue(r1 is not r2) refs = weakref.getweakrefs(o) self.assertIn(r1, refs) self.assertIn(r2, refs) @@ -898,94 +809,40 @@ self.assertEqual(self.cbcalled, 0) +class Object: + def __init__(self, arg): + self.arg = arg + def __repr__(self): + return "" % self.arg + + class MappingTestCase(TestBase): COUNT = 10 - def check_len_cycles(self, dict_type, cons): - N = 20 - items = [RefCycle() for i in range(N)] - dct = dict_type(cons(i, o) for i, o in enumerate(items)) - # Keep an iterator alive - it = dct.iteritems() - try: - next(it) - except StopIteration: - pass - del items - gc.collect() - n1 = len(dct) - list(it) - del it - gc.collect() - n2 = len(dct) - # iteration should prevent garbage collection here - # Note that this is a test on an implementation detail. The requirement - # is only to provide stable iteration, not that the size of the container - # stay fixed. - self.assertEqual(n1, 20) - #self.assertIn(n1, (0, 1)) - self.assertEqual(n2, 0) - - def test_weak_keyed_len_cycles(self): - self.check_len_cycles(weakref.WeakKeyDictionary, lambda n, k: (k, n)) - - def test_weak_valued_len_cycles(self): - self.check_len_cycles(weakref.WeakValueDictionary, lambda n, k: (n, k)) - - def check_len_race(self, dict_type, cons): - # Extended sanity checks for len() in the face of cyclic collection - self.addCleanup(gc.set_threshold, *gc.get_threshold()) - for th in range(1, 100): - N = 20 - gc.collect(0) - gc.set_threshold(th, th, th) - items = [RefCycle() for i in range(N)] - dct = dict_type(cons(o) for o in items) - del items - # All items will be collected at next garbage collection pass - it = dct.iteritems() - try: - next(it) - except StopIteration: - pass - n1 = len(dct) - del it - n2 = len(dct) - self.assertGreaterEqual(n1, 0) - self.assertLessEqual(n1, N) - self.assertGreaterEqual(n2, 0) - self.assertLessEqual(n2, n1) - - def test_weak_keyed_len_race(self): - self.check_len_race(weakref.WeakKeyDictionary, lambda k: (k, 1)) - - def test_weak_valued_len_race(self): - self.check_len_race(weakref.WeakValueDictionary, lambda k: (1, k)) - def test_weak_values(self): # # This exercises d.copy(), d.items(), d[], del d[], len(d). # dict, objects = self.make_weak_valued_dict() for o in objects: - self.assertEqual(weakref.getweakrefcount(o), 1, + self.assertTrue(weakref.getweakrefcount(o) == 1, "wrong number of weak references to %r!" % o) - self.assertIs(o, dict[o.arg], + self.assertTrue(o is dict[o.arg], "wrong object returned by weak dict!") items1 = dict.items() items2 = dict.copy().items() items1.sort() items2.sort() - self.assertEqual(items1, items2, + self.assertTrue(items1 == items2, "cloning of weak-valued dictionary did not work!") del items1, items2 - self.assertEqual(len(dict), self.COUNT) + self.assertTrue(len(dict) == self.COUNT) del objects[0] - self.assertEqual(len(dict), (self.COUNT - 1), + self.assertTrue(len(dict) == (self.COUNT - 1), "deleting object did not cause dictionary update") del objects, o - self.assertEqual(len(dict), 0, + self.assertTrue(len(dict) == 0, "deleting the values did not clear the dictionary") # regression on SF bug #447152: dict = weakref.WeakValueDictionary() @@ -1000,21 +857,21 @@ # dict, objects = self.make_weak_keyed_dict() for o in objects: - self.assertEqual(weakref.getweakrefcount(o), 1, + self.assertTrue(weakref.getweakrefcount(o) == 1, "wrong number of weak references to %r!" % o) - self.assertIs(o.arg, dict[o], + self.assertTrue(o.arg is dict[o], "wrong object returned by weak dict!") items1 = dict.items() items2 = dict.copy().items() - self.assertEqual(set(items1), set(items2), + self.assertTrue(set(items1) == set(items2), "cloning of weak-keyed dictionary did not work!") del items1, items2 - self.assertEqual(len(dict), self.COUNT) + self.assertTrue(len(dict) == self.COUNT) del objects[0] - self.assertEqual(len(dict), (self.COUNT - 1), + self.assertTrue(len(dict) == (self.COUNT - 1), "deleting object did not cause dictionary update") del objects, o - self.assertEqual(len(dict), 0, + self.assertTrue(len(dict) == 0, "deleting the keys did not clear the dictionary") o = Object(42) dict[o] = "What is the meaning of the universe?" @@ -1076,117 +933,37 @@ items = dict.items() for item in dict.iteritems(): items.remove(item) - self.assertEqual(len(items), 0, "iteritems() did not touch all items") + self.assertTrue(len(items) == 0, "iteritems() did not touch all items") # key iterator, via __iter__(): keys = dict.keys() for k in dict: keys.remove(k) - self.assertEqual(len(keys), 0, "__iter__() did not touch all keys") + self.assertTrue(len(keys) == 0, "__iter__() did not touch all keys") # key iterator, via iterkeys(): keys = dict.keys() for k in dict.iterkeys(): keys.remove(k) - self.assertEqual(len(keys), 0, "iterkeys() did not touch all keys") + self.assertTrue(len(keys) == 0, "iterkeys() did not touch all keys") # value iterator: values = dict.values() for v in dict.itervalues(): values.remove(v) - self.assertEqual(len(values), 0, + self.assertTrue(len(values) == 0, "itervalues() did not touch all values") - def check_weak_destroy_while_iterating(self, dict, objects, iter_name): - n = len(dict) - it = iter(getattr(dict, iter_name)()) - next(it) # Trigger internal iteration - # Destroy an object - del objects[-1] - gc.collect() # just in case - # We have removed either the first consumed object, or another one - self.assertIn(len(list(it)), [len(objects), len(objects) - 1]) - del it - # The removal has been committed - self.assertEqual(len(dict), n - 1) - - def check_weak_destroy_and_mutate_while_iterating(self, dict, testcontext): - # Check that we can explicitly mutate the weak dict without - # interfering with delayed removal. - # `testcontext` should create an iterator, destroy one of the - # weakref'ed objects and then return a new key/value pair corresponding - # to the destroyed object. - with testcontext() as (k, v): - self.assertFalse(k in dict) - with testcontext() as (k, v): - self.assertRaises(KeyError, dict.__delitem__, k) - self.assertFalse(k in dict) - with testcontext() as (k, v): - self.assertRaises(KeyError, dict.pop, k) - self.assertFalse(k in dict) - with testcontext() as (k, v): - dict[k] = v - self.assertEqual(dict[k], v) - ddict = copy.copy(dict) - with testcontext() as (k, v): - dict.update(ddict) - self.assertEqual(dict, ddict) - with testcontext() as (k, v): - dict.clear() - self.assertEqual(len(dict), 0) - - def test_weak_keys_destroy_while_iterating(self): - # Issue #7105: iterators shouldn't crash when a key is implicitly removed - dict, objects = self.make_weak_keyed_dict() - self.check_weak_destroy_while_iterating(dict, objects, 'iterkeys') - self.check_weak_destroy_while_iterating(dict, objects, 'iteritems') - self.check_weak_destroy_while_iterating(dict, objects, 'itervalues') - self.check_weak_destroy_while_iterating(dict, objects, 'iterkeyrefs') - dict, objects = self.make_weak_keyed_dict() - @contextlib.contextmanager - def testcontext(): - try: - it = iter(dict.iteritems()) - next(it) - # Schedule a key/value for removal and recreate it - v = objects.pop().arg - gc.collect() # just in case - yield Object(v), v - finally: - it = None # should commit all removals - self.check_weak_destroy_and_mutate_while_iterating(dict, testcontext) - - def test_weak_values_destroy_while_iterating(self): - # Issue #7105: iterators shouldn't crash when a key is implicitly removed - dict, objects = self.make_weak_valued_dict() - self.check_weak_destroy_while_iterating(dict, objects, 'iterkeys') - self.check_weak_destroy_while_iterating(dict, objects, 'iteritems') - self.check_weak_destroy_while_iterating(dict, objects, 'itervalues') - self.check_weak_destroy_while_iterating(dict, objects, 'itervaluerefs') - dict, objects = self.make_weak_valued_dict() - @contextlib.contextmanager - def testcontext(): - try: - it = iter(dict.iteritems()) - next(it) - # Schedule a key/value for removal and recreate it - k = objects.pop().arg - gc.collect() # just in case - yield k, Object(k) - finally: - it = None # should commit all removals - self.check_weak_destroy_and_mutate_while_iterating(dict, testcontext) - def test_make_weak_keyed_dict_from_dict(self): o = Object(3) dict = weakref.WeakKeyDictionary({o:364}) - self.assertEqual(dict[o], 364) + self.assertTrue(dict[o] == 364) def test_make_weak_keyed_dict_from_weak_keyed_dict(self): o = Object(3) dict = weakref.WeakKeyDictionary({o:364}) dict2 = weakref.WeakKeyDictionary(dict) - self.assertEqual(dict[o], 364) + self.assertTrue(dict[o] == 364) def make_weak_keyed_dict(self): dict = weakref.WeakKeyDictionary() @@ -1206,19 +983,19 @@ weakdict = klass() weakdict[key1] = value1 weakdict[key2] = value2 - self.assertEqual(len(weakdict), 2) + self.assertTrue(len(weakdict) == 2) k, v = weakdict.popitem() - self.assertEqual(len(weakdict), 1) + self.assertTrue(len(weakdict) == 1) if k is key1: - self.assertIs(v, value1) + self.assertTrue(v is value1) else: - self.assertIs(v, value2) + self.assertTrue(v is value2) k, v = weakdict.popitem() - self.assertEqual(len(weakdict), 0) + self.assertTrue(len(weakdict) == 0) if k is key1: - self.assertIs(v, value1) + self.assertTrue(v is value1) else: - self.assertIs(v, value2) + self.assertTrue(v is value2) def test_weak_valued_dict_popitem(self): self.check_popitem(weakref.WeakValueDictionary, @@ -1229,7 +1006,7 @@ C(), "value 1", C(), "value 2") def check_setdefault(self, klass, key, value1, value2): - self.assertIsNot(value1, value2, + self.assertTrue(value1 is not value2, "invalid test" " -- value parameters must be distinct objects") weakdict = klass() @@ -1288,10 +1065,10 @@ o2 = Object('2') d[o1] = 'something' d[o2] = 'something' - self.assertEqual(len(d), 2) + self.assertTrue(len(d) == 2) del d[o1] - self.assertEqual(len(d), 1) - self.assertEqual(d.keys(), [o2]) + self.assertTrue(len(d) == 1) + self.assertTrue(d.keys() == [o2]) def test_weak_valued_delitem(self): d = weakref.WeakValueDictionary() @@ -1299,10 +1076,10 @@ o2 = Object('2') d['something'] = o1 d['something else'] = o2 - self.assertEqual(len(d), 2) + self.assertTrue(len(d) == 2) del d['something'] - self.assertEqual(len(d), 1) - self.assertEqual(d.items(), [('something else', o2)]) + self.assertTrue(len(d) == 1) + self.assertTrue(d.items() == [('something else', o2)]) def test_weak_keyed_bad_delitem(self): d = weakref.WeakKeyDictionary() diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Lib/test/test_weakset.py --- a/Lib/test/test_weakset.py Sat Jul 19 16:34:33 2014 -0700 +++ b/Lib/test/test_weakset.py Sun Jul 20 10:52:46 2014 -0400 @@ -11,7 +11,6 @@ import collections import gc import contextlib -from UserString import UserString as ustr class Foo: @@ -31,10 +30,6 @@ def __hash__(self): return hash((SomeClass, self.value)) -class RefCycle(object): - def __init__(self): - self.cycle = self - class TestWeakSet(unittest.TestCase): def setUp(self): @@ -42,12 +37,6 @@ self.items = [SomeClass(c) for c in ('a', 'b', 'c')] self.items2 = [SomeClass(c) for c in ('x', 'y', 'z')] self.letters = [SomeClass(c) for c in string.ascii_letters] - self.ab_items = [SomeClass(c) for c in 'ab'] - self.abcde_items = [SomeClass(c) for c in 'abcde'] - self.def_items = [SomeClass(c) for c in 'def'] - self.ab_weakset = WeakSet(self.ab_items) - self.abcde_weakset = WeakSet(self.abcde_items) - self.def_weakset = WeakSet(self.def_items) self.s = WeakSet(self.items) self.d = dict.fromkeys(self.items) self.obj = SomeClass('F') @@ -90,11 +79,6 @@ x = WeakSet(self.items + self.items2) c = C(self.items2) self.assertEqual(self.s.union(c), x) - del c - self.assertEqual(len(u), len(self.items) + len(self.items2)) - self.items2.pop() - gc.collect() - self.assertEqual(len(u), len(self.items) + len(self.items2)) def test_or(self): i = self.s.union(self.items2) @@ -102,19 +86,14 @@ self.assertEqual(self.s | frozenset(self.items2), i) def test_intersection(self): - s = WeakSet(self.letters) - i = s.intersection(self.items2) + i = self.s.intersection(self.items2) for c in self.letters: - self.assertEqual(c in i, c in self.items2 and c in self.letters) - self.assertEqual(s, WeakSet(self.letters)) + self.assertEqual(c in i, c in self.d and c in self.items2) + self.assertEqual(self.s, WeakSet(self.items)) self.assertEqual(type(i), WeakSet) for C in set, frozenset, dict.fromkeys, list, tuple: x = WeakSet([]) - self.assertEqual(i.intersection(C(self.items)), x) - self.assertEqual(len(i), len(self.items2)) - self.items2.pop() - gc.collect() - self.assertEqual(len(i), len(self.items2)) + self.assertEqual(self.s.intersection(C(self.items2)), x) def test_isdisjoint(self): self.assertTrue(self.s.isdisjoint(WeakSet(self.items2))) @@ -145,10 +124,6 @@ self.assertEqual(self.s, WeakSet(self.items)) self.assertEqual(type(i), WeakSet) self.assertRaises(TypeError, self.s.symmetric_difference, [[]]) - self.assertEqual(len(i), len(self.items) + len(self.items2)) - self.items2.pop() - gc.collect() - self.assertEqual(len(i), len(self.items) + len(self.items2)) def test_xor(self): i = self.s.symmetric_difference(self.items2) @@ -156,28 +131,22 @@ self.assertEqual(self.s ^ frozenset(self.items2), i) def test_sub_and_super(self): - self.assertTrue(self.ab_weakset <= self.abcde_weakset) - self.assertTrue(self.abcde_weakset <= self.abcde_weakset) - self.assertTrue(self.abcde_weakset >= self.ab_weakset) - self.assertFalse(self.abcde_weakset <= self.def_weakset) - self.assertFalse(self.abcde_weakset >= self.def_weakset) + pl, ql, rl = map(lambda s: [SomeClass(c) for c in s], ['ab', 'abcde', 'def']) + p, q, r = map(WeakSet, (pl, ql, rl)) + self.assertTrue(p < q) + self.assertTrue(p <= q) + self.assertTrue(q <= q) + self.assertTrue(q > p) + self.assertTrue(q >= p) + self.assertFalse(q < r) + self.assertFalse(q <= r) + self.assertFalse(q > r) + self.assertFalse(q >= r) self.assertTrue(set('a').issubset('abc')) self.assertTrue(set('abc').issuperset('a')) self.assertFalse(set('a').issubset('cbs')) self.assertFalse(set('cbs').issuperset('a')) - def test_lt(self): - self.assertTrue(self.ab_weakset < self.abcde_weakset) - self.assertFalse(self.abcde_weakset < self.def_weakset) - self.assertFalse(self.ab_weakset < self.ab_weakset) - self.assertFalse(WeakSet() < WeakSet()) - - def test_gt(self): - self.assertTrue(self.abcde_weakset > self.ab_weakset) - self.assertFalse(self.abcde_weakset > self.def_weakset) - self.assertFalse(self.ab_weakset > self.ab_weakset) - self.assertFalse(WeakSet() > WeakSet()) - def test_gc(self): # Create a nest of cycles to exercise overall ref count check s = WeakSet(Foo() for i in range(1000)) @@ -352,12 +321,6 @@ self.assertFalse(self.s == tuple(self.items)) self.assertFalse(self.s == 1) - def test_ne(self): - self.assertTrue(self.s != set(self.items)) - s1 = WeakSet() - s2 = WeakSet() - self.assertFalse(s1 != s2) - def test_weak_destroy_while_iterating(self): # Issue #7105: iterators shouldn't crash when a key is implicitly removed # Create new items to be sure no-one else holds a reference @@ -406,102 +369,6 @@ s.clear() self.assertEqual(len(s), 0) - def test_len_cycles(self): - N = 20 - items = [RefCycle() for i in range(N)] - s = WeakSet(items) - del items - it = iter(s) - try: - next(it) - except StopIteration: - pass - gc.collect() - n1 = len(s) - del it - gc.collect() - n2 = len(s) - # one item may be kept alive inside the iterator - self.assertIn(n1, (0, 1)) - self.assertEqual(n2, 0) - - def test_len_race(self): - # Extended sanity checks for len() in the face of cyclic collection - self.addCleanup(gc.set_threshold, *gc.get_threshold()) - for th in range(1, 100): - N = 20 - gc.collect(0) - gc.set_threshold(th, th, th) - items = [RefCycle() for i in range(N)] - s = WeakSet(items) - del items - # All items will be collected at next garbage collection pass - it = iter(s) - try: - next(it) - except StopIteration: - pass - n1 = len(s) - del it - n2 = len(s) - self.assertGreaterEqual(n1, 0) - self.assertLessEqual(n1, N) - self.assertGreaterEqual(n2, 0) - self.assertLessEqual(n2, n1) - - def test_weak_destroy_while_iterating(self): - # Issue #7105: iterators shouldn't crash when a key is implicitly removed - # Create new items to be sure no-one else holds a reference - items = [ustr(c) for c in ('a', 'b', 'c')] - s = WeakSet(items) - it = iter(s) - next(it) # Trigger internal iteration - # Destroy an item - del items[-1] - gc.collect() # just in case - # We have removed either the first consumed items, or another one - self.assertIn(len(list(it)), [len(items), len(items) - 1]) - del it - # The removal has been committed - self.assertEqual(len(s), len(items)) - - def test_weak_destroy_and_mutate_while_iterating(self): - # Issue #7105: iterators shouldn't crash when a key is implicitly removed - items = [ustr(c) for c in string.ascii_letters] - s = WeakSet(items) - @contextlib.contextmanager - def testcontext(): - try: - it = iter(s) - # Start iterator - yielded = ustr(str(next(it))) - # Schedule an item for removal and recreate it - u = ustr(str(items.pop())) - if yielded == u: - # The iterator still has a reference to the removed item, - # advance it (issue #20006). - next(it) - gc.collect() # just in case - yield u - finally: - it = None # should commit all removals - - with testcontext() as u: - self.assertFalse(u in s) - with testcontext() as u: - self.assertRaises(KeyError, s.remove, u) - self.assertFalse(u in s) - with testcontext() as u: - s.add(u) - self.assertTrue(u in s) - t = s.copy() - with testcontext() as u: - s.update(t) - self.assertEqual(len(s), len(t)) - with testcontext() as u: - s.clear() - self.assertEqual(len(s), 0) - def test_main(verbose=None): test_support.run_unittest(TestWeakSet) diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Lib/test/test_whichdb.py --- a/Lib/test/test_whichdb.py Sat Jul 19 16:34:33 2014 -0700 +++ b/Lib/test/test_whichdb.py Sun Jul 20 10:52:46 2014 -0400 @@ -1,3 +1,4 @@ +#! /usr/bin/env python """Test script for the whichdb module based on test_anydbm.py """ diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Lib/test/test_winreg.py --- a/Lib/test/test_winreg.py Sat Jul 19 16:34:33 2014 -0700 +++ b/Lib/test/test_winreg.py Sun Jul 20 10:52:46 2014 -0400 @@ -1,7 +1,7 @@ # Test the windows specific win32reg module. # Only win32reg functions not hit here: FlushKey, LoadKey and SaveKey -import os, sys, errno +import os, sys import unittest from test import test_support threading = test_support.import_module("threading") @@ -28,12 +28,9 @@ # tests are only valid up until 6.1 HAS_REFLECTION = True if WIN_VER < (6, 1) else False -# Use a per-process key to prevent concurrent test runs (buildbot!) from -# stomping on each other. -test_key_base = "Python Test Key [%d] - Delete Me" % (os.getpid(),) -test_key_name = "SOFTWARE\\" + test_key_base +test_key_name = "SOFTWARE\\Python Registry Test Key - Delete Me" # On OS'es that support reflection we should test with a reflected key -test_reflect_key_name = "SOFTWARE\\Classes\\" + test_key_base +test_reflect_key_name = "SOFTWARE\\Classes\\Python Test Key - Delete Me" test_data = [ ("Int Value", 45, REG_DWORD), @@ -237,7 +234,7 @@ def test_changing_value(self): # Issue2810: A race condition in 2.6 and 3.1 may cause - # EnumValue or QueryValue to raise "WindowsError: More data is + # EnumValue or QueryValue to throw "WindowsError: More data is # available" done = False @@ -270,7 +267,7 @@ def test_long_key(self): # Issue2810, in 2.6 and 3.1 when the key name was exactly 256 - # characters, EnumKey raised "WindowsError: More data is + # characters, EnumKey threw "WindowsError: More data is # available" name = 'x'*256 try: @@ -285,14 +282,8 @@ def test_dynamic_key(self): # Issue2810, when the value is dynamically generated, these - # raise "WindowsError: More data is available" in 2.6 and 3.1 - try: - EnumValue(HKEY_PERFORMANCE_DATA, 0) - except OSError as e: - if e.errno in (errno.EPERM, errno.EACCES): - self.skipTest("access denied to registry key " - "(are you running in a non-interactive session?)") - raise + # throw "WindowsError: More data is available" in 2.6 and 3.1 + EnumValue(HKEY_PERFORMANCE_DATA, 0) QueryValueEx(HKEY_PERFORMANCE_DATA, None) # Reflection requires XP x64/Vista at a minimum. XP doesn't have this stuff @@ -317,57 +308,6 @@ finally: DeleteKey(HKEY_CURRENT_USER, test_key_name) - def test_setvalueex_value_range(self): - # Test for Issue #14420, accept proper ranges for SetValueEx. - # Py2Reg, which gets called by SetValueEx, was using PyLong_AsLong, - # thus raising OverflowError. The implementation now uses - # PyLong_AsUnsignedLong to match DWORD's size. - try: - with CreateKey(HKEY_CURRENT_USER, test_key_name) as ck: - self.assertNotEqual(ck.handle, 0) - SetValueEx(ck, "test_name", None, REG_DWORD, 0x80000000) - finally: - DeleteKey(HKEY_CURRENT_USER, test_key_name) - - def test_setvalueex_with_memoryview(self): - try: - with CreateKey(HKEY_CURRENT_USER, test_key_name) as ck: - self.assertNotEqual(ck.handle, 0) - with self.assertRaises(TypeError): - SetValueEx(ck, "test_name", None, REG_BINARY, memoryview('val')) - finally: - DeleteKey(HKEY_CURRENT_USER, test_key_name) - - def test_queryvalueex_return_value(self): - # Test for Issue #16759, return unsigned int from QueryValueEx. - # Reg2Py, which gets called by QueryValueEx, was returning a value - # generated by PyLong_FromLong. The implementation now uses - # PyLong_FromUnsignedLong to match DWORD's size. - try: - with CreateKey(HKEY_CURRENT_USER, test_key_name) as ck: - self.assertNotEqual(ck.handle, 0) - test_val = 0x80000000 - SetValueEx(ck, "test_name", None, REG_DWORD, test_val) - ret_val, ret_type = QueryValueEx(ck, "test_name") - self.assertEqual(ret_type, REG_DWORD) - self.assertEqual(ret_val, test_val) - finally: - DeleteKey(HKEY_CURRENT_USER, test_key_name) - - def test_setvalueex_crash_with_none_arg(self): - # Test for Issue #21151, segfault when None is passed to SetValueEx - try: - with CreateKey(HKEY_CURRENT_USER, test_key_name) as ck: - self.assertNotEqual(ck.handle, 0) - test_val = None - SetValueEx(ck, "test_name", 0, REG_BINARY, test_val) - ret_val, ret_type = QueryValueEx(ck, "test_name") - self.assertEqual(ret_type, REG_BINARY) - self.assertEqual(ret_val, test_val) - finally: - DeleteKey(HKEY_CURRENT_USER, test_key_name) - - @unittest.skipUnless(REMOTE_NAME, "Skipping remote registry tests") class RemoteWinregTests(BaseWinregTests): @@ -464,11 +404,6 @@ DeleteKeyEx(HKEY_CURRENT_USER, test_reflect_key_name, KEY_WOW64_32KEY, 0) - def test_exception_numbers(self): - with self.assertRaises(WindowsError) as ctx: - QueryValue(HKEY_CLASSES_ROOT, 'some_value_that_does_not_exist') - - self.assertEqual(ctx.exception.errno, 2) def test_main(): test_support.run_unittest(LocalWinregTests, RemoteWinregTests, diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Lib/test/test_winsound.py --- a/Lib/test/test_winsound.py Sat Jul 19 16:34:33 2014 -0700 +++ b/Lib/test/test_winsound.py Sun Jul 20 10:52:46 2014 -0400 @@ -2,7 +2,6 @@ import unittest from test import test_support -test_support.requires('audio') import time import os import subprocess @@ -159,15 +158,18 @@ ) def test_alias_fallback(self): - # In the absense of the ability to tell if a sound was actually - # played, this test has two acceptable outcomes: success (no error, - # sound was theoretically played; although as issue #19987 shows - # a box without a soundcard can "succeed") or RuntimeError. Any - # other error is a failure. - try: - winsound.PlaySound('!"$%&/(#+*', winsound.SND_ALIAS) - except RuntimeError: - pass + # This test can't be expected to work on all systems. The MS + # PlaySound() docs say: + # + # If it cannot find the specified sound, PlaySound uses the + # default system event sound entry instead. If the function + # can find neither the system default entry nor the default + # sound, it makes no sound and returns FALSE. + # + # It's known to return FALSE on some real systems. + + # winsound.PlaySound('!"$%&/(#+*', winsound.SND_ALIAS) + return def test_alias_nofallback(self): if _have_soundcard(): diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Lib/test/test_with.py --- a/Lib/test/test_with.py Sat Jul 19 16:34:33 2014 -0700 +++ b/Lib/test/test_with.py Sun Jul 20 10:52:46 2014 -0400 @@ -1,3 +1,5 @@ +#!/usr/bin/env python + """Unit tests for the with statement specified in PEP 343.""" diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Lib/test/test_wsgiref.py --- a/Lib/test/test_wsgiref.py Sat Jul 19 16:34:33 2014 -0700 +++ b/Lib/test/test_wsgiref.py Sun Jul 20 10:52:46 2014 -0400 @@ -39,6 +39,9 @@ pass + + + def hello_app(environ,start_response): start_response("200 OK", [ ('Content-Type','text/plain'), @@ -59,6 +62,27 @@ return out.getvalue(), err.getvalue() + + + + + + + + + + + + + + + + + + + + + def compare_generic_iter(make_it,match): """Utility to compare a generic 2.1/2.2+ iterator with an iterable @@ -96,6 +120,10 @@ raise AssertionError("Too many items from .next()",it) + + + + class IntegrationTests(TestCase): def check_hello(self, out, has_length=True): @@ -133,6 +161,10 @@ ) + + + + class UtilityTests(TestCase): def checkShift(self,sn_in,pi_in,part,sn_out,pi_out): @@ -155,7 +187,7 @@ # Check existing value env = {key:alt} util.setup_testing_defaults(env) - self.assertIs(env[key], alt) + self.assertTrue(env[key] is alt) def checkCrossDefault(self,key,value,**kw): util.setup_testing_defaults(kw) @@ -169,6 +201,11 @@ util.setup_testing_defaults(kw) self.assertEqual(util.request_uri(kw,query),uri) + + + + + def checkFW(self,text,size,match): def make_it(text=text,size=size): @@ -187,6 +224,7 @@ it.close() self.assertTrue(it.filelike.closed) + def testSimpleShifts(self): self.checkShift('','/', '', '/', '') self.checkShift('','/x', 'x', '/x', '') @@ -194,6 +232,7 @@ self.checkShift('/a','/x/y', 'x', '/a/x', '/y') self.checkShift('/a','/x/', 'x', '/a/x', '/') + def testNormalizedShifts(self): self.checkShift('/a/b', '/../y', '..', '/a', '/y') self.checkShift('', '/../y', '..', '', '/y') @@ -207,6 +246,7 @@ self.checkShift('/a/b', '/x//', 'x', '/a/b/x', '/') self.checkShift('/a/b', '/.', None, '/a/b', '') + def testDefaults(self): for key, value in [ ('SERVER_NAME','127.0.0.1'), @@ -226,6 +266,7 @@ ]: self.checkDefault(key,value) + def testCrossDefaults(self): self.checkCrossDefault('HTTP_HOST',"foo.bar",SERVER_NAME="foo.bar") self.checkCrossDefault('wsgi.url_scheme',"https",HTTPS="on") @@ -235,6 +276,7 @@ self.checkCrossDefault('SERVER_PORT',"80",HTTPS="foo") self.checkCrossDefault('SERVER_PORT',"443",HTTPS="on") + def testGuessScheme(self): self.assertEqual(util.guess_scheme({}), "http") self.assertEqual(util.guess_scheme({'HTTPS':"foo"}), "http") @@ -242,10 +284,13 @@ self.assertEqual(util.guess_scheme({'HTTPS':"yes"}), "https") self.assertEqual(util.guess_scheme({'HTTPS':"1"}), "https") + + + + def testAppURIs(self): self.checkAppURI("http://127.0.0.1/") self.checkAppURI("http://127.0.0.1/spam", SCRIPT_NAME="/spam") - self.checkAppURI("http://127.0.0.1/sp%E4m", SCRIPT_NAME="/sp\xe4m") self.checkAppURI("http://spam.example.com:2071/", HTTP_HOST="spam.example.com:2071", SERVER_PORT="2071") self.checkAppURI("http://spam.example.com/", @@ -259,19 +304,14 @@ def testReqURIs(self): self.checkReqURI("http://127.0.0.1/") self.checkReqURI("http://127.0.0.1/spam", SCRIPT_NAME="/spam") - self.checkReqURI("http://127.0.0.1/sp%E4m", SCRIPT_NAME="/sp\xe4m") self.checkReqURI("http://127.0.0.1/spammity/spam", SCRIPT_NAME="/spammity", PATH_INFO="/spam") - self.checkReqURI("http://127.0.0.1/spammity/sp%E4m", - SCRIPT_NAME="/spammity", PATH_INFO="/sp\xe4m") self.checkReqURI("http://127.0.0.1/spammity/spam;ham", SCRIPT_NAME="/spammity", PATH_INFO="/spam;ham") self.checkReqURI("http://127.0.0.1/spammity/spam;cookie=1234,5678", SCRIPT_NAME="/spammity", PATH_INFO="/spam;cookie=1234,5678") self.checkReqURI("http://127.0.0.1/spammity/spam?say=ni", SCRIPT_NAME="/spammity", PATH_INFO="/spam",QUERY_STRING="say=ni") - self.checkReqURI("http://127.0.0.1/spammity/spam?s%E4y=ni", - SCRIPT_NAME="/spammity", PATH_INFO="/spam",QUERY_STRING="s%E4y=ni") self.checkReqURI("http://127.0.0.1/spammity/spam", 0, SCRIPT_NAME="/spammity", PATH_INFO="/spam",QUERY_STRING="say=ni") @@ -302,7 +342,7 @@ self.assertEqual(Headers(test[:]).keys(), ['x']) self.assertEqual(Headers(test[:]).values(), ['y']) self.assertEqual(Headers(test[:]).items(), test) - self.assertIsNot(Headers(test).items(), test) # must be copy! + self.assertFalse(Headers(test).items() is test) # must be copy! h=Headers([]) del h['foo'] # should not raise an error @@ -371,6 +411,15 @@ raise # for testing, we want to see what's happening + + + + + + + + + class HandlerTests(TestCase): def checkEnvironAttrs(self, handler): @@ -411,6 +460,7 @@ h=TestHandler(); h.setup_environ() self.assertEqual(h.environ['wsgi.url_scheme'],'http') + def testAbstractMethods(self): h = BaseHandler() for name in [ @@ -419,6 +469,7 @@ self.assertRaises(NotImplementedError, getattr(h,name)) self.assertRaises(NotImplementedError, h._write, "test") + def testContentLength(self): # Demo one reason iteration is better than write()... ;) @@ -498,6 +549,7 @@ "\r\n"+MSG) self.assertNotEqual(h.stderr.getvalue().find("AssertionError"), -1) + def testHeaderFormats(self): def non_error_app(e,s): @@ -539,28 +591,40 @@ (stdpat%(version,sw), h.stdout.getvalue()) ) - def testCloseOnError(self): - side_effects = {'close_called': False} - MSG = b"Some output has been sent" - def error_app(e,s): - s("200 OK",[])(MSG) - class CrashyIterable(object): - def __iter__(self): - while True: - yield b'blah' - raise AssertionError("This should be caught by handler") - - def close(self): - side_effects['close_called'] = True - return CrashyIterable() - - h = ErrorHandler() - h.run(error_app) - self.assertEqual(side_effects['close_called'], True) - +# This epilogue is needed for compatibility with the Python 2.5 regrtest module def test_main(): test_support.run_unittest(__name__) if __name__ == "__main__": test_main() + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +# the above lines intentionally left blank diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Lib/test/test_xml_etree.py --- a/Lib/test/test_xml_etree.py Sat Jul 19 16:34:33 2014 -0700 +++ b/Lib/test/test_xml_etree.py Sun Jul 20 10:52:46 2014 -0400 @@ -713,21 +713,14 @@ end {namespace}root end-ns None - >>> import StringIO - - >>> events = ('start-ns', 'end-ns') - >>> context = ET.iterparse(StringIO.StringIO(r""), events) - >>> for action, elem in context: - ... print action, elem - start-ns ('', '') - end-ns None - >>> events = ("start", "end", "bogus") >>> with open(SIMPLE_XMLFILE, "rb") as f: ... iterparse(f, events) Traceback (most recent call last): ValueError: unknown event 'bogus' + >>> import StringIO + >>> source = StringIO.StringIO( ... "\\n" ... ">> check_encoding("iso-8859-15") >>> check_encoding("cp437") >>> check_encoding("mac-roman") - >>> check_encoding("gbk") - Traceback (most recent call last): - ValueError: multi-byte encodings are not supported - >>> check_encoding("cp037") - Traceback (most recent call last): - ParseError: unknown encoding: line 1, column 30 """ ET.XML("" % encoding) @@ -1782,16 +1769,6 @@ """ -def bug_18347(): - """ - - >>> e = ET.XML('text') - >>> serialize(e) - 'text' - >>> serialize(e, method="html") - 'text' - """ - # -------------------------------------------------------------------- # reported on bugs.python.org @@ -1845,26 +1822,6 @@ """ -def check_html_empty_elems_serialization(self): - # issue 15970 - # from http://www.w3.org/TR/html401/index/elements.html - """ - - >>> empty_elems = ['AREA', 'BASE', 'BASEFONT', 'BR', 'COL', 'FRAME', 'HR', - ... 'IMG', 'INPUT', 'ISINDEX', 'LINK', 'META', 'PARAM'] - >>> elems = ''.join('<%s />' % elem for elem in empty_elems) - >>> serialize(ET.XML('%s' % elems), method='html') - '

    ' - >>> serialize(ET.XML('%s' % elems.lower()), method='html') - '

    ' - >>> elems = ''.join('<%s>' % (elem, elem) for elem in empty_elems) - >>> serialize(ET.XML('%s' % elems), method='html') - '

    ' - >>> serialize(ET.XML('%s' % elems.lower()), method='html') - '

    ' - - """ - # -------------------------------------------------------------------- diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Lib/test/test_xmlrpc.py --- a/Lib/test/test_xmlrpc.py Sat Jul 19 16:34:33 2014 -0700 +++ b/Lib/test/test_xmlrpc.py Sun Jul 20 10:52:46 2014 -0400 @@ -19,11 +19,6 @@ threading = None try: - import gzip -except ImportError: - gzip = None - -try: unicode except NameError: have_unicode = False @@ -594,12 +589,6 @@ # This avoids waiting for the socket timeout. self.test_simple1() - def test_partial_post(self): - # Check that a partial POST doesn't make the server loop: issue #14001. - conn = httplib.HTTPConnection(ADDR, PORT) - conn.request('POST', '/RPC2 HTTP/1.0\r\nContent-Length: 100\r\n\r\nbye') - conn.close() - class MultiPathServerTestCase(BaseServerTestCase): threadFunc = staticmethod(http_multi_server) request_count = 2 @@ -686,7 +675,6 @@ #A test case that verifies that gzip encoding works in both directions #(for a request and the response) -@unittest.skipUnless(gzip, 'gzip not available') class GzipServerTestCase(BaseServerTestCase): #a request handler that supports keep-alive and logs requests into a #class variable @@ -1017,7 +1005,11 @@ xmlrpc_tests.append(SimpleServerTestCase) xmlrpc_tests.append(KeepaliveServerTestCase1) xmlrpc_tests.append(KeepaliveServerTestCase2) - xmlrpc_tests.append(GzipServerTestCase) + try: + import gzip + xmlrpc_tests.append(GzipServerTestCase) + except ImportError: + pass #gzip not supported in this build xmlrpc_tests.append(MultiPathServerTestCase) xmlrpc_tests.append(ServerProxyTestCase) xmlrpc_tests.append(FailingServerTestCase) diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Lib/test/test_xrange.py --- a/Lib/test/test_xrange.py Sat Jul 19 16:34:33 2014 -0700 +++ b/Lib/test/test_xrange.py Sun Jul 20 10:52:46 2014 -0400 @@ -46,28 +46,6 @@ self.fail('{}: wrong element at position {};' 'expected {}, got {}'.format(test_id, i, y, x)) - def assert_xranges_equivalent(self, x, y): - # Check that two xrange objects are equivalent, in the sense of the - # associated sequences being the same. We want to use this for large - # xrange objects, so instead of converting to lists and comparing - # directly we do a number of indirect checks. - if len(x) != len(y): - self.fail('{} and {} have different ' - 'lengths: {} and {} '.format(x, y, len(x), len(y))) - if len(x) >= 1: - if x[0] != y[0]: - self.fail('{} and {} have different initial ' - 'elements: {} and {} '.format(x, y, x[0], y[0])) - if x[-1] != y[-1]: - self.fail('{} and {} have different final ' - 'elements: {} and {} '.format(x, y, x[-1], y[-1])) - if len(x) >= 2: - x_step = x[1] - x[0] - y_step = y[1] - y[0] - if x_step != y_step: - self.fail('{} and {} have different step: ' - '{} and {} '.format(x, y, x_step, y_step)) - def test_xrange(self): self.assertEqual(list(xrange(3)), [0, 1, 2]) self.assertEqual(list(xrange(1, 5)), [1, 2, 3, 4]) @@ -126,59 +104,6 @@ self.assertEqual(list(pickle.loads(pickle.dumps(r, proto))), list(r)) - M = min(sys.maxint, sys.maxsize) - large_testcases = testcases + [ - (0, M, 1), - (M, 0, -1), - (0, M, M - 1), - (M // 2, M, 1), - (0, -M, -1), - (0, -M, 1 - M), - (-M, M, 2), - (-M, M, 1024), - (-M, M, 10585), - (M, -M, -2), - (M, -M, -1024), - (M, -M, -10585), - ] - for proto in range(pickle.HIGHEST_PROTOCOL + 1): - for t in large_testcases: - r = xrange(*t) - r_out = pickle.loads(pickle.dumps(r, proto)) - self.assert_xranges_equivalent(r_out, r) - - def test_repr(self): - # Check that repr of an xrange is a valid representation - # of that xrange. - - # Valid xranges have at most min(sys.maxint, sys.maxsize) elements. - M = min(sys.maxint, sys.maxsize) - - testcases = [ - (13,), - (0, 11), - (-22, 10), - (20, 3, -1), - (13, 21, 3), - (-2, 2, 2), - (0, M, 1), - (M, 0, -1), - (0, M, M - 1), - (M // 2, M, 1), - (0, -M, -1), - (0, -M, 1 - M), - (-M, M, 2), - (-M, M, 1024), - (-M, M, 10585), - (M, -M, -2), - (M, -M, -1024), - (M, -M, -10585), - ] - for t in testcases: - r = xrange(*t) - r_out = eval(repr(r)) - self.assert_xranges_equivalent(r, r_out) - def test_range_iterators(self): # see issue 7298 limits = [base + jiggle diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Lib/test/test_zipfile.py --- a/Lib/test/test_zipfile.py Sat Jul 19 16:34:33 2014 -0700 +++ b/Lib/test/test_zipfile.py Sun Jul 20 10:52:46 2014 -0400 @@ -8,6 +8,7 @@ import io import sys import time +import shutil import struct import zipfile import unittest @@ -17,14 +18,7 @@ from random import randint, random from unittest import skipUnless -from test.test_support import TESTFN, TESTFN_UNICODE, TESTFN_ENCODING, \ - run_unittest, findfile, unlink, rmtree, check_warnings -try: - TESTFN_UNICODE.encode(TESTFN_ENCODING) -except (UnicodeError, TypeError): - # Either the file system encoding is None, or the file name - # cannot be encoded in the file system encoding. - TESTFN_UNICODE = None +from test.test_support import TESTFN, run_unittest, findfile, unlink TESTFN2 = TESTFN + "2" TESTFNDIR = TESTFN + "d" @@ -32,7 +26,7 @@ SMALL_TEST_DATA = [('_ziptest1', '1q2w3e4r5t'), ('ziptest2dir/_ziptest2', 'qawsedrftg'), - ('ziptest2dir/ziptest3dir/_ziptest3', 'azsxdcfvgb'), + ('/ziptest2dir/ziptest3dir/_ziptest3', 'azsxdcfvgb'), ('ziptest2dir/ziptest3dir/ziptest4dir/_ziptest3', '6y7u8i9o0p')] @@ -147,9 +141,7 @@ # Create the ZIP archive with zipfile.ZipFile(TESTFN2, "w", zipfile.ZIP_STORED) as zipfp: zipfp.writestr("name", "foo") - with check_warnings(('', UserWarning)): - zipfp.writestr("name", "bar") - self.assertEqual(zipfp.namelist(), ["name"] * 2) + zipfp.writestr("name", "bar") with zipfile.ZipFile(TESTFN2, "r") as zipfp: infos = zipfp.infolist() @@ -366,8 +358,7 @@ produces the expected result.""" with zipfile.ZipFile(TESTFN2, "w") as zipfp: zipfp.write(TESTFN) - with open(TESTFN,'r') as fid: - self.assertEqual(zipfp.read(TESTFN), fid.read()) + self.assertEqual(zipfp.read(TESTFN), open(TESTFN).read()) @skipUnless(zlib, "requires zlib") def test_per_file_compression(self): @@ -400,18 +391,20 @@ writtenfile = zipfp.extract(fpath) # make sure it was written to the right place - correctfile = os.path.join(os.getcwd(), fpath) + if os.path.isabs(fpath): + correctfile = os.path.join(os.getcwd(), fpath[1:]) + else: + correctfile = os.path.join(os.getcwd(), fpath) correctfile = os.path.normpath(correctfile) self.assertEqual(writtenfile, correctfile) # make sure correct data is in correct file - with open(writtenfile, "rb") as fid: - self.assertEqual(fdata, fid.read()) + self.assertEqual(fdata, open(writtenfile, "rb").read()) os.remove(writtenfile) # remove the test file subdirectories - rmtree(os.path.join(os.getcwd(), 'ziptest2dir')) + shutil.rmtree(os.path.join(os.getcwd(), 'ziptest2dir')) def test_extract_all(self): with zipfile.ZipFile(TESTFN2, "w", zipfile.ZIP_STORED) as zipfp: @@ -421,120 +414,16 @@ with zipfile.ZipFile(TESTFN2, "r") as zipfp: zipfp.extractall() for fpath, fdata in SMALL_TEST_DATA: - outfile = os.path.join(os.getcwd(), fpath) + if os.path.isabs(fpath): + outfile = os.path.join(os.getcwd(), fpath[1:]) + else: + outfile = os.path.join(os.getcwd(), fpath) - with open(outfile, "rb") as fid: - self.assertEqual(fdata, fid.read()) + self.assertEqual(fdata, open(outfile, "rb").read()) os.remove(outfile) # remove the test file subdirectories - rmtree(os.path.join(os.getcwd(), 'ziptest2dir')) - - def check_file(self, filename, content): - self.assertTrue(os.path.isfile(filename)) - with open(filename, 'rb') as f: - self.assertEqual(f.read(), content) - - @skipUnless(TESTFN_UNICODE, "No Unicode filesystem semantics on this platform.") - def test_extract_unicode_filenames(self): - fnames = [u'foo.txt', os.path.basename(TESTFN_UNICODE)] - content = 'Test for unicode filename' - with zipfile.ZipFile(TESTFN2, "w", zipfile.ZIP_STORED) as zipfp: - for fname in fnames: - zipfp.writestr(fname, content) - - with zipfile.ZipFile(TESTFN2, "r") as zipfp: - for fname in fnames: - writtenfile = zipfp.extract(fname) - - # make sure it was written to the right place - correctfile = os.path.join(os.getcwd(), fname) - correctfile = os.path.normpath(correctfile) - self.assertEqual(writtenfile, correctfile) - - self.check_file(writtenfile, content) - os.remove(writtenfile) - - def test_extract_hackers_arcnames(self): - hacknames = [ - ('../foo/bar', 'foo/bar'), - ('foo/../bar', 'foo/bar'), - ('foo/../../bar', 'foo/bar'), - ('foo/bar/..', 'foo/bar'), - ('./../foo/bar', 'foo/bar'), - ('/foo/bar', 'foo/bar'), - ('/foo/../bar', 'foo/bar'), - ('/foo/../../bar', 'foo/bar'), - ] - if os.path.sep == '\\': - hacknames.extend([ - (r'..\foo\bar', 'foo/bar'), - (r'..\/foo\/bar', 'foo/bar'), - (r'foo/\..\/bar', 'foo/bar'), - (r'foo\/../\bar', 'foo/bar'), - (r'C:foo/bar', 'foo/bar'), - (r'C:/foo/bar', 'foo/bar'), - (r'C://foo/bar', 'foo/bar'), - (r'C:\foo\bar', 'foo/bar'), - (r'//conky/mountpoint/foo/bar', 'foo/bar'), - (r'\\conky\mountpoint\foo\bar', 'foo/bar'), - (r'///conky/mountpoint/foo/bar', 'conky/mountpoint/foo/bar'), - (r'\\\conky\mountpoint\foo\bar', 'conky/mountpoint/foo/bar'), - (r'//conky//mountpoint/foo/bar', 'conky/mountpoint/foo/bar'), - (r'\\conky\\mountpoint\foo\bar', 'conky/mountpoint/foo/bar'), - (r'//?/C:/foo/bar', 'foo/bar'), - (r'\\?\C:\foo\bar', 'foo/bar'), - (r'C:/../C:/foo/bar', 'C_/foo/bar'), - (r'a:b\ce|f"g?h*i', 'b/c_d_e_f_g_h_i'), - ('../../foo../../ba..r', 'foo/ba..r'), - ]) - else: # Unix - hacknames.extend([ - ('//foo/bar', 'foo/bar'), - ('../../foo../../ba..r', 'foo../ba..r'), - (r'foo/..\bar', r'foo/..\bar'), - ]) - - for arcname, fixedname in hacknames: - content = b'foobar' + arcname.encode() - with zipfile.ZipFile(TESTFN2, 'w', zipfile.ZIP_STORED) as zipfp: - zinfo = zipfile.ZipInfo() - # preserve backslashes - zinfo.filename = arcname - zinfo.external_attr = 0o600 << 16 - zipfp.writestr(zinfo, content) - - arcname = arcname.replace(os.sep, "/") - targetpath = os.path.join('target', 'subdir', 'subsub') - correctfile = os.path.join(targetpath, *fixedname.split('/')) - - with zipfile.ZipFile(TESTFN2, 'r') as zipfp: - writtenfile = zipfp.extract(arcname, targetpath) - self.assertEqual(writtenfile, correctfile, - msg="extract %r" % arcname) - self.check_file(correctfile, content) - rmtree('target') - - with zipfile.ZipFile(TESTFN2, 'r') as zipfp: - zipfp.extractall(targetpath) - self.check_file(correctfile, content) - rmtree('target') - - correctfile = os.path.join(os.getcwd(), *fixedname.split('/')) - - with zipfile.ZipFile(TESTFN2, 'r') as zipfp: - writtenfile = zipfp.extract(arcname) - self.assertEqual(writtenfile, correctfile, - msg="extract %r" % arcname) - self.check_file(correctfile, content) - rmtree(fixedname.split('/')[0]) - - with zipfile.ZipFile(TESTFN2, 'r') as zipfp: - zipfp.extractall() - self.check_file(correctfile, content) - rmtree(fixedname.split('/')[0]) - - os.remove(TESTFN2) + shutil.rmtree(os.path.join(os.getcwd(), 'ziptest2dir')) def test_writestr_compression(self): zipfp = zipfile.ZipFile(TESTFN2, "w") @@ -777,12 +666,11 @@ self.assertNotIn('mod2.txt', names) finally: - rmtree(TESTFN2) + shutil.rmtree(TESTFN2) def test_write_non_pyfile(self): with zipfile.PyZipFile(TemporaryFile(), "w") as zipfp: - with open(TESTFN, 'w') as fid: - fid.write('most definitely not a python file') + open(TESTFN, 'w').write('most definitely not a python file') self.assertRaises(RuntimeError, zipfp.writepy, TESTFN) os.remove(TESTFN) @@ -872,20 +760,6 @@ chk = zipfile.is_zipfile(fp) self.assertTrue(not chk) - def test_damaged_zipfile(self): - """Check that zipfiles with missing bytes at the end raise BadZipFile.""" - # - Create a valid zip file - fp = io.BytesIO() - with zipfile.ZipFile(fp, mode="w") as zipf: - zipf.writestr("foo.txt", b"O, for a Muse of Fire!") - zipfiledata = fp.getvalue() - - # - Now create copies of it missing the last N bytes and make sure - # a BadZipFile exception is raised when we try to open it - for N in range(len(zipfiledata)): - fp = io.BytesIO(zipfiledata[:N]) - self.assertRaises(zipfile.BadZipfile, zipfile.ZipFile, fp) - def test_is_zip_valid_file(self): """Check that is_zipfile() correctly identifies zip files.""" # - passing a filename @@ -937,7 +811,7 @@ with zipfile.ZipFile(data, mode="w") as zipf: zipf.writestr("foo.txt", "O, for a Muse of Fire!") - # This is correct; calling .read on a closed ZipFile should raise + # This is correct; calling .read on a closed ZipFile should throw # a RuntimeError, and so should calling .testzip. An earlier # version of .testzip would swallow this exception (and any other) # and report that the first file in the archive was corrupt. @@ -945,9 +819,8 @@ self.assertRaises(RuntimeError, zipf.open, "foo.txt") self.assertRaises(RuntimeError, zipf.testzip) self.assertRaises(RuntimeError, zipf.writestr, "bogus.txt", "bogus") - with open(TESTFN, 'w') as fid: - fid.write('zipfile test data') - self.assertRaises(RuntimeError, zipf.write, TESTFN) + open(TESTFN, 'w').write('zipfile test data') + self.assertRaises(RuntimeError, zipf.write, TESTFN) def test_bad_constructor_mode(self): """Check that bad modes passed to ZipFile constructor are caught.""" @@ -986,17 +859,6 @@ caught.""" self.assertRaises(RuntimeError, zipfile.ZipFile, TESTFN, "w", -1) - def test_unsupported_compression(self): - # data is declared as shrunk, but actually deflated - data = (b'PK\x03\x04.\x00\x00\x00\x01\x00\xe4C\xa1@\x00\x00\x00' - b'\x00\x02\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00x\x03\x00PK\x01' - b'\x02.\x03.\x00\x00\x00\x01\x00\xe4C\xa1@\x00\x00\x00\x00\x02\x00\x00' - b'\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' - b'\x80\x01\x00\x00\x00\x00xPK\x05\x06\x00\x00\x00\x00\x01\x00\x01\x00' - b'/\x00\x00\x00!\x00\x00\x00\x00\x00') - with zipfile.ZipFile(io.BytesIO(data), 'r') as zipf: - self.assertRaises(NotImplementedError, zipf.open, 'x') - def test_null_byte_in_filename(self): """Check that a filename containing a null byte is properly terminated.""" @@ -1041,28 +903,11 @@ # check a comment that is too long is truncated with zipfile.ZipFile(TESTFN, mode="w") as zipf: - with check_warnings(('', UserWarning)): - zipf.comment = comment2 + 'oops' + zipf.comment = comment2 + 'oops' zipf.writestr("foo.txt", "O, for a Muse of Fire!") with zipfile.ZipFile(TESTFN, mode="r") as zipf: self.assertEqual(zipf.comment, comment2) - def test_change_comment_in_empty_archive(self): - with zipfile.ZipFile(TESTFN, "a", zipfile.ZIP_STORED) as zipf: - self.assertFalse(zipf.filelist) - zipf.comment = b"this is a comment" - with zipfile.ZipFile(TESTFN, "r") as zipf: - self.assertEqual(zipf.comment, b"this is a comment") - - def test_change_comment_in_nonempty_archive(self): - with zipfile.ZipFile(TESTFN, "w", zipfile.ZIP_STORED) as zipf: - zipf.writestr("foo.txt", "O, for a Muse of Fire!") - with zipfile.ZipFile(TESTFN, "a", zipfile.ZIP_STORED) as zipf: - self.assertTrue(zipf.filelist) - zipf.comment = b"this is a comment" - with zipfile.ZipFile(TESTFN, "r") as zipf: - self.assertEqual(zipf.comment, b"this is a comment") - def check_testzip_with_bad_crc(self, compression): """Tests that files with bad CRCs return their name from testzip.""" zipdata = self.zips_with_bad_crc[compression] @@ -1133,7 +978,6 @@ pass try: zipf = zipfile.ZipFile(TESTFN, mode="r") - zipf.close() except zipfile.BadZipfile: self.fail("Unable to create empty ZIP file in 'w' mode") @@ -1141,7 +985,6 @@ pass try: zipf = zipfile.ZipFile(TESTFN, mode="r") - zipf.close() except: self.fail("Unable to create empty ZIP file in 'a' mode") @@ -1157,21 +1000,6 @@ self.assertRaises(ValueError, zipfile.ZipInfo, 'seventies', (1979, 1, 1, 0, 0, 0)) - def test_zipfile_with_short_extra_field(self): - """If an extra field in the header is less than 4 bytes, skip it.""" - zipdata = ( - b'PK\x03\x04\x14\x00\x00\x00\x00\x00\x93\x9b\xad@\x8b\x9e' - b'\xd9\xd3\x01\x00\x00\x00\x01\x00\x00\x00\x03\x00\x03\x00ab' - b'c\x00\x00\x00APK\x01\x02\x14\x03\x14\x00\x00\x00\x00' - b'\x00\x93\x9b\xad@\x8b\x9e\xd9\xd3\x01\x00\x00\x00\x01\x00\x00' - b'\x00\x03\x00\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\xa4\x81\x00' - b'\x00\x00\x00abc\x00\x00PK\x05\x06\x00\x00\x00\x00' - b'\x01\x00\x01\x003\x00\x00\x00%\x00\x00\x00\x00\x00' - ) - with zipfile.ZipFile(io.BytesIO(zipdata), 'r') as zipf: - # testzip returns the name of the first corrupt file, or None - self.assertIsNone(zipf.testzip()) - def tearDown(self): unlink(TESTFN) unlink(TESTFN2) @@ -1353,11 +1181,12 @@ # Verify that (when the ZipFile is in control of creating file objects) # multiple open() calls can be made without interfering with each other. with zipfile.ZipFile(TESTFN2, mode="r") as zipf: - with zipf.open('ones') as zopen1, zipf.open('ones') as zopen2: - data1 = zopen1.read(500) - data2 = zopen2.read(500) - data1 += zopen1.read(500) - data2 += zopen2.read(500) + zopen1 = zipf.open('ones') + zopen2 = zipf.open('ones') + data1 = zopen1.read(500) + data2 = zopen2.read(500) + data1 += zopen1.read(500) + data2 += zopen2.read(500) self.assertEqual(data1, data2) def test_different_file(self): @@ -1384,17 +1213,6 @@ self.assertEqual(data1, '1'*FIXEDTEST_SIZE) self.assertEqual(data2, '2'*FIXEDTEST_SIZE) - def test_many_opens(self): - # Verify that read() and open() promptly close the file descriptor, - # and don't rely on the garbage collector to free resources. - with zipfile.ZipFile(TESTFN2, mode="r") as zipf: - for x in range(100): - zipf.read('ones') - with zipf.open('ones') as zopen1: - pass - with open(os.devnull) as f: - self.assertLess(f.fileno(), 100) - def tearDown(self): unlink(TESTFN2) @@ -1417,12 +1235,12 @@ def test_store_dir(self): os.mkdir(os.path.join(TESTFN2, "x")) - with zipfile.ZipFile(TESTFN, "w") as zipf: - zipf.write(os.path.join(TESTFN2, "x"), "x") - self.assertTrue(zipf.filelist[0].filename.endswith("x/")) + zipf = zipfile.ZipFile(TESTFN, "w") + zipf.write(os.path.join(TESTFN2, "x"), "x") + self.assertTrue(zipf.filelist[0].filename.endswith("x/")) def tearDown(self): - rmtree(TESTFN2) + shutil.rmtree(TESTFN2) if os.path.exists(TESTFN): unlink(TESTFN) @@ -1436,8 +1254,7 @@ for n, s in enumerate(self.seps): self.arcdata[s] = s.join(self.line_gen) + s self.arcfiles[s] = '%s-%d' % (TESTFN, n) - with open(self.arcfiles[s], "wb") as fid: - fid.write(self.arcdata[s]) + open(self.arcfiles[s], "wb").write(self.arcdata[s]) def make_test_archive(self, f, compression): # Create the ZIP archive @@ -1506,9 +1323,8 @@ # Read the ZIP archive with zipfile.ZipFile(f, "r") as zipfp: for sep, fn in self.arcfiles.items(): - with zipfp.open(fn, "rU") as fid: - for line, zipline in zip(self.line_gen, fid): - self.assertEqual(zipline, line + '\n') + for line, zipline in zip(self.line_gen, zipfp.open(fn, "rU")): + self.assertEqual(zipline, line + '\n') def test_read_stored(self): for f in (TESTFN2, TemporaryFile(), StringIO()): diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Lib/test/test_zipimport_support.py --- a/Lib/test/test_zipimport_support.py Sat Jul 19 16:34:33 2014 -0700 +++ b/Lib/test/test_zipimport_support.py Sun Jul 20 10:52:46 2014 -0400 @@ -29,8 +29,7 @@ # test_cmd_line_script (covers the zipimport support in runpy) # Retrieve some helpers from other test cases -from test import (test_doctest, sample_doctest, sample_doctest_no_doctests, - sample_doctest_no_docstrings) +from test import test_doctest, sample_doctest from test.test_importhooks import ImportHooksBaseTestCase @@ -100,26 +99,16 @@ "test_zipped_doctest") test_src = test_src.replace("test.sample_doctest", "sample_zipped_doctest") - # The sample doctest files rewritten to include in the zipped version. - sample_sources = {} - for mod in [sample_doctest, sample_doctest_no_doctests, - sample_doctest_no_docstrings]: - src = inspect.getsource(mod) - src = src.replace("test.test_doctest", "test_zipped_doctest") - # Rewrite the module name so that, for example, - # "test.sample_doctest" becomes "sample_zipped_doctest". - mod_name = mod.__name__.split(".")[-1] - mod_name = mod_name.replace("sample_", "sample_zipped_") - sample_sources[mod_name] = src - + sample_src = inspect.getsource(sample_doctest) + sample_src = sample_src.replace("test.test_doctest", + "test_zipped_doctest") with temp_dir() as d: script_name = make_script(d, 'test_zipped_doctest', test_src) zip_name, run_name = make_zip_script(d, 'test_zip', script_name) z = zipfile.ZipFile(zip_name, 'a') - for mod_name, src in sample_sources.items(): - z.writestr(mod_name + ".py", src) + z.writestr("sample_zipped_doctest.py", sample_src) z.close() if verbose: zip_file = zipfile.ZipFile(zip_name, 'r') @@ -179,10 +168,9 @@ test_zipped_doctest.test_unittest_reportflags, ] # Needed for test_DocTestParser and test_debug - deprecations = [] - if __debug__: + deprecations = [ # Ignore all warnings about the use of class Tester in this module. - deprecations.append(("class Tester is deprecated", DeprecationWarning)) + ("class Tester is deprecated", DeprecationWarning)] if sys.py3kwarning: deprecations += [ ("backquote not supported", SyntaxWarning), diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Lib/test/test_zlib.py --- a/Lib/test/test_zlib.py Sat Jul 19 16:34:33 2014 -0700 +++ b/Lib/test/test_zlib.py Sun Jul 20 10:52:46 2014 -0400 @@ -12,13 +12,6 @@ zlib = import_module('zlib') -requires_Compress_copy = unittest.skipUnless( - hasattr(zlib.compressobj(), "copy"), - 'requires Compress.copy()') -requires_Decompress_copy = unittest.skipUnless( - hasattr(zlib.decompressobj(), "copy"), - 'requires Decompress.copy()') - class ChecksumTestCase(unittest.TestCase): # checksum test cases @@ -346,39 +339,39 @@ "mode=%i, level=%i") % (sync, level)) del obj - @unittest.skipUnless(hasattr(zlib, 'Z_SYNC_FLUSH'), - 'requires zlib.Z_SYNC_FLUSH') def test_odd_flush(self): # Test for odd flushing bugs noted in 2.0, and hopefully fixed in 2.1 import random - # Testing on 17K of "random" data - # Create compressor and decompressor objects - co = zlib.compressobj(zlib.Z_BEST_COMPRESSION) - dco = zlib.decompressobj() + if hasattr(zlib, 'Z_SYNC_FLUSH'): + # Testing on 17K of "random" data - # Try 17K of data - # generate random data stream - try: - # In 2.3 and later, WichmannHill is the RNG of the bug report - gen = random.WichmannHill() - except AttributeError: + # Create compressor and decompressor objects + co = zlib.compressobj(zlib.Z_BEST_COMPRESSION) + dco = zlib.decompressobj() + + # Try 17K of data + # generate random data stream try: - # 2.2 called it Random - gen = random.Random() + # In 2.3 and later, WichmannHill is the RNG of the bug report + gen = random.WichmannHill() except AttributeError: - # others might simply have a single RNG - gen = random - gen.seed(1) - data = genblock(1, 17 * 1024, generator=gen) + try: + # 2.2 called it Random + gen = random.Random() + except AttributeError: + # others might simply have a single RNG + gen = random + gen.seed(1) + data = genblock(1, 17 * 1024, generator=gen) - # compress, sync-flush, and decompress - first = co.compress(data) - second = co.flush(zlib.Z_SYNC_FLUSH) - expanded = dco.decompress(first + second) + # compress, sync-flush, and decompress + first = co.compress(data) + second = co.flush(zlib.Z_SYNC_FLUSH) + expanded = dco.decompress(first + second) - # if decompressed data is different from the input data, choke. - self.assertEqual(expanded, data, "17K random source doesn't match") + # if decompressed data is different from the input data, choke. + self.assertEqual(expanded, data, "17K random source doesn't match") def test_empty_flush(self): # Test that calling .flush() on unused objects works. @@ -403,104 +396,65 @@ y += dco.flush() self.assertEqual(y, 'foo') - def test_flush_with_freed_input(self): - # Issue #16411: decompressor accesses input to last decompress() call - # in flush(), even if this object has been freed in the meanwhile. - input1 = 'abcdefghijklmnopqrstuvwxyz' - input2 = 'QWERTYUIOPASDFGHJKLZXCVBNM' - data = zlib.compress(input1) - dco = zlib.decompressobj() - dco.decompress(data, 1) - del data - data = zlib.compress(input2) - self.assertEqual(dco.flush(), input1[1:]) + if hasattr(zlib.compressobj(), "copy"): + def test_compresscopy(self): + # Test copying a compression object + data0 = HAMLET_SCENE + data1 = HAMLET_SCENE.swapcase() + c0 = zlib.compressobj(zlib.Z_BEST_COMPRESSION) + bufs0 = [] + bufs0.append(c0.compress(data0)) - @requires_Compress_copy - def test_compresscopy(self): - # Test copying a compression object - data0 = HAMLET_SCENE - data1 = HAMLET_SCENE.swapcase() - c0 = zlib.compressobj(zlib.Z_BEST_COMPRESSION) - bufs0 = [] - bufs0.append(c0.compress(data0)) + c1 = c0.copy() + bufs1 = bufs0[:] - c1 = c0.copy() - bufs1 = bufs0[:] + bufs0.append(c0.compress(data0)) + bufs0.append(c0.flush()) + s0 = ''.join(bufs0) - bufs0.append(c0.compress(data0)) - bufs0.append(c0.flush()) - s0 = ''.join(bufs0) + bufs1.append(c1.compress(data1)) + bufs1.append(c1.flush()) + s1 = ''.join(bufs1) - bufs1.append(c1.compress(data1)) - bufs1.append(c1.flush()) - s1 = ''.join(bufs1) + self.assertEqual(zlib.decompress(s0),data0+data0) + self.assertEqual(zlib.decompress(s1),data0+data1) - self.assertEqual(zlib.decompress(s0),data0+data0) - self.assertEqual(zlib.decompress(s1),data0+data1) + def test_badcompresscopy(self): + # Test copying a compression object in an inconsistent state + c = zlib.compressobj() + c.compress(HAMLET_SCENE) + c.flush() + self.assertRaises(ValueError, c.copy) - @requires_Compress_copy - def test_badcompresscopy(self): - # Test copying a compression object in an inconsistent state - c = zlib.compressobj() - c.compress(HAMLET_SCENE) - c.flush() - self.assertRaises(ValueError, c.copy) + if hasattr(zlib.decompressobj(), "copy"): + def test_decompresscopy(self): + # Test copying a decompression object + data = HAMLET_SCENE + comp = zlib.compress(data) - def test_decompress_unused_data(self): - # Repeated calls to decompress() after EOF should accumulate data in - # dco.unused_data, instead of just storing the arg to the last call. - source = b'abcdefghijklmnopqrstuvwxyz' - remainder = b'0123456789' - y = zlib.compress(source) - x = y + remainder - for maxlen in 0, 1000: - for step in 1, 2, len(y), len(x): - dco = zlib.decompressobj() - data = b'' - for i in range(0, len(x), step): - if i < len(y): - self.assertEqual(dco.unused_data, b'') - if maxlen == 0: - data += dco.decompress(x[i : i + step]) - self.assertEqual(dco.unconsumed_tail, b'') - else: - data += dco.decompress( - dco.unconsumed_tail + x[i : i + step], maxlen) - data += dco.flush() - self.assertEqual(data, source) - self.assertEqual(dco.unconsumed_tail, b'') - self.assertEqual(dco.unused_data, remainder) + d0 = zlib.decompressobj() + bufs0 = [] + bufs0.append(d0.decompress(comp[:32])) - @requires_Decompress_copy - def test_decompresscopy(self): - # Test copying a decompression object - data = HAMLET_SCENE - comp = zlib.compress(data) + d1 = d0.copy() + bufs1 = bufs0[:] - d0 = zlib.decompressobj() - bufs0 = [] - bufs0.append(d0.decompress(comp[:32])) + bufs0.append(d0.decompress(comp[32:])) + s0 = ''.join(bufs0) - d1 = d0.copy() - bufs1 = bufs0[:] + bufs1.append(d1.decompress(comp[32:])) + s1 = ''.join(bufs1) - bufs0.append(d0.decompress(comp[32:])) - s0 = ''.join(bufs0) + self.assertEqual(s0,s1) + self.assertEqual(s0,data) - bufs1.append(d1.decompress(comp[32:])) - s1 = ''.join(bufs1) - - self.assertEqual(s0,s1) - self.assertEqual(s0,data) - - @requires_Decompress_copy - def test_baddecompresscopy(self): - # Test copying a compression object in an inconsistent state - data = zlib.compress(HAMLET_SCENE) - d = zlib.decompressobj() - d.decompress(data) - d.flush() - self.assertRaises(ValueError, d.copy) + def test_baddecompresscopy(self): + # Test copying a compression object in an inconsistent state + data = zlib.compress(HAMLET_SCENE) + d = zlib.decompressobj() + d.decompress(data) + d.flush() + self.assertRaises(ValueError, d.copy) # Memory use of the following functions takes into account overallocation diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Lib/test/testtar.tar Binary file Lib/test/testtar.tar has changed diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Lib/textwrap.py --- a/Lib/textwrap.py Sat Jul 19 16:34:33 2014 -0700 +++ b/Lib/textwrap.py Sun Jul 20 10:52:46 2014 -0400 @@ -9,14 +9,6 @@ import string, re -try: - _unicode = unicode -except NameError: - # If Python is built without Unicode support, the unicode type - # will not exist. Fake one. - class _unicode(object): - pass - # Do the right thing with boolean values for all known Python versions # (so this module can be copied to projects that don't depend on Python # 2.3, e.g. Optik and Docutils) by uncommenting the block of code below. @@ -155,7 +147,7 @@ if self.replace_whitespace: if isinstance(text, str): text = text.translate(self.whitespace_trans) - elif isinstance(text, _unicode): + elif isinstance(text, unicode): text = text.translate(self.unicode_whitespace_trans) return text @@ -175,7 +167,7 @@ 'use', ' ', 'the', ' ', '-b', ' ', option!' otherwise. """ - if isinstance(text, _unicode): + if isinstance(text, unicode): if self.break_on_hyphens: pat = self.wordsep_re_uni else: diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Lib/threading.py --- a/Lib/threading.py Sat Jul 19 16:34:33 2014 -0700 +++ b/Lib/threading.py Sun Jul 20 10:52:46 2014 -0400 @@ -10,9 +10,9 @@ import warnings -from collections import deque as _deque from time import time as _time, sleep as _sleep from traceback import format_exc as _format_exc +from collections import deque # Note regarding PEP 8 compliant aliases # This threading model was originally inspired by Java, and inherited @@ -87,22 +87,10 @@ _trace_hook = None def setprofile(func): - """Set a profile function for all threads started from the threading module. - - The func will be passed to sys.setprofile() for each thread, before its - run() method is called. - - """ global _profile_hook _profile_hook = func def settrace(func): - """Set a trace function for all threads started from the threading module. - - The func will be passed to sys.settrace() for each thread, before its run() - method is called. - - """ global _trace_hook _trace_hook = func @@ -111,22 +99,9 @@ Lock = _allocate_lock def RLock(*args, **kwargs): - """Factory function that returns a new reentrant lock. - - A reentrant lock must be released by the thread that acquired it. Once a - thread has acquired a reentrant lock, the same thread may acquire it again - without blocking; the thread must release it once for each time it has - acquired it. - - """ return _RLock(*args, **kwargs) class _RLock(_Verbose): - """A reentrant lock must be released by the thread that acquired it. Once a - thread has acquired a reentrant lock, the same thread may acquire it - again without blocking; the thread must release it once for each time it - has acquired it. - """ def __init__(self, verbose=None): _Verbose.__init__(self, verbose) @@ -144,26 +119,6 @@ self.__class__.__name__, owner, self.__count) def acquire(self, blocking=1): - """Acquire a lock, blocking or non-blocking. - - When invoked without arguments: if this thread already owns the lock, - increment the recursion level by one, and return immediately. Otherwise, - if another thread owns the lock, block until the lock is unlocked. Once - the lock is unlocked (not owned by any thread), then grab ownership, set - the recursion level to one, and return. If more than one thread is - blocked waiting until the lock is unlocked, only one at a time will be - able to grab ownership of the lock. There is no return value in this - case. - - When invoked with the blocking argument set to true, do the same thing - as when called without arguments, and return true. - - When invoked with the blocking argument set to false, do not block. If a - call without an argument would block, return false immediately; - otherwise, do the same thing as when called without arguments, and - return true. - - """ me = _get_ident() if self.__owner == me: self.__count = self.__count + 1 @@ -184,21 +139,6 @@ __enter__ = acquire def release(self): - """Release a lock, decrementing the recursion level. - - If after the decrement it is zero, reset the lock to unlocked (not owned - by any thread), and if any other threads are blocked waiting for the - lock to become unlocked, allow exactly one of them to proceed. If after - the decrement the recursion level is still nonzero, the lock remains - locked and owned by the calling thread. - - Only call this method when the calling thread owns the lock. A - RuntimeError is raised if this method is called when the lock is - unlocked. - - There is no return value. - - """ if self.__owner != _get_ident(): raise RuntimeError("cannot release un-acquired lock") self.__count = count = self.__count - 1 @@ -239,22 +179,9 @@ def Condition(*args, **kwargs): - """Factory function that returns a new condition variable object. - - A condition variable allows one or more threads to wait until they are - notified by another thread. - - If the lock argument is given and not None, it must be a Lock or RLock - object, and it is used as the underlying lock. Otherwise, a new RLock object - is created and used as the underlying lock. - - """ return _Condition(*args, **kwargs) class _Condition(_Verbose): - """Condition variables allow one or more threads to wait until they are - notified by another thread. - """ def __init__(self, lock=None, verbose=None): _Verbose.__init__(self, verbose) @@ -306,28 +233,6 @@ return True def wait(self, timeout=None): - """Wait until notified or until a timeout occurs. - - If the calling thread has not acquired the lock when this method is - called, a RuntimeError is raised. - - This method releases the underlying lock, and then blocks until it is - awakened by a notify() or notifyAll() call for the same condition - variable in another thread, or until the optional timeout occurs. Once - awakened or timed out, it re-acquires the lock and returns. - - When the timeout argument is present and not None, it should be a - floating point number specifying a timeout for the operation in seconds - (or fractions thereof). - - When the underlying lock is an RLock, it is not released using its - release() method, since this may not actually unlock the lock when it - was acquired multiple times recursively. Instead, an internal interface - of the RLock class is used, which really unlocks it even when it has - been recursively acquired several times. Another internal interface is - then used to restore the recursion level when the lock is reacquired. - - """ if not self._is_owned(): raise RuntimeError("cannot wait on un-acquired lock") waiter = _allocate_lock() @@ -370,15 +275,6 @@ self._acquire_restore(saved_state) def notify(self, n=1): - """Wake up one or more threads waiting on this condition, if any. - - If the calling thread has not acquired the lock when this method is - called, a RuntimeError is raised. - - This method wakes up at most n of the threads waiting for the condition - variable; it is a no-op if no threads are waiting. - - """ if not self._is_owned(): raise RuntimeError("cannot notify on un-acquired lock") __waiters = self.__waiters @@ -397,35 +293,15 @@ pass def notifyAll(self): - """Wake up all threads waiting on this condition. - - If the calling thread has not acquired the lock when this method - is called, a RuntimeError is raised. - - """ self.notify(len(self.__waiters)) notify_all = notifyAll def Semaphore(*args, **kwargs): - """A factory function that returns a new semaphore. - - Semaphores manage a counter representing the number of release() calls minus - the number of acquire() calls, plus an initial value. The acquire() method - blocks if necessary until it can return without making the counter - negative. If not given, value defaults to 1. - - """ return _Semaphore(*args, **kwargs) class _Semaphore(_Verbose): - """Semaphores manage a counter representing the number of release() calls - minus the number of acquire() calls, plus an initial value. The acquire() - method blocks if necessary until it can return without making the counter - negative. If not given, value defaults to 1. - - """ # After Tim Peters' semaphore class, but not quite the same (no maximum) @@ -437,123 +313,58 @@ self.__value = value def acquire(self, blocking=1): - """Acquire a semaphore, decrementing the internal counter by one. - - When invoked without arguments: if the internal counter is larger than - zero on entry, decrement it by one and return immediately. If it is zero - on entry, block, waiting until some other thread has called release() to - make it larger than zero. This is done with proper interlocking so that - if multiple acquire() calls are blocked, release() will wake exactly one - of them up. The implementation may pick one at random, so the order in - which blocked threads are awakened should not be relied on. There is no - return value in this case. - - When invoked with blocking set to true, do the same thing as when called - without arguments, and return true. - - When invoked with blocking set to false, do not block. If a call without - an argument would block, return false immediately; otherwise, do the - same thing as when called without arguments, and return true. - - """ rc = False - with self.__cond: - while self.__value == 0: - if not blocking: - break - if __debug__: - self._note("%s.acquire(%s): blocked waiting, value=%s", - self, blocking, self.__value) - self.__cond.wait() - else: - self.__value = self.__value - 1 - if __debug__: - self._note("%s.acquire: success, value=%s", - self, self.__value) - rc = True + self.__cond.acquire() + while self.__value == 0: + if not blocking: + break + if __debug__: + self._note("%s.acquire(%s): blocked waiting, value=%s", + self, blocking, self.__value) + self.__cond.wait() + else: + self.__value = self.__value - 1 + if __debug__: + self._note("%s.acquire: success, value=%s", + self, self.__value) + rc = True + self.__cond.release() return rc __enter__ = acquire def release(self): - """Release a semaphore, incrementing the internal counter by one. - - When the counter is zero on entry and another thread is waiting for it - to become larger than zero again, wake up that thread. - - """ - with self.__cond: - self.__value = self.__value + 1 - if __debug__: - self._note("%s.release: success, value=%s", - self, self.__value) - self.__cond.notify() + self.__cond.acquire() + self.__value = self.__value + 1 + if __debug__: + self._note("%s.release: success, value=%s", + self, self.__value) + self.__cond.notify() + self.__cond.release() def __exit__(self, t, v, tb): self.release() def BoundedSemaphore(*args, **kwargs): - """A factory function that returns a new bounded semaphore. - - A bounded semaphore checks to make sure its current value doesn't exceed its - initial value. If it does, ValueError is raised. In most situations - semaphores are used to guard resources with limited capacity. - - If the semaphore is released too many times it's a sign of a bug. If not - given, value defaults to 1. - - Like regular semaphores, bounded semaphores manage a counter representing - the number of release() calls minus the number of acquire() calls, plus an - initial value. The acquire() method blocks if necessary until it can return - without making the counter negative. If not given, value defaults to 1. - - """ return _BoundedSemaphore(*args, **kwargs) class _BoundedSemaphore(_Semaphore): - """A bounded semaphore checks to make sure its current value doesn't exceed - its initial value. If it does, ValueError is raised. In most situations - semaphores are used to guard resources with limited capacity. - """ - + """Semaphore that checks that # releases is <= # acquires""" def __init__(self, value=1, verbose=None): _Semaphore.__init__(self, value, verbose) self._initial_value = value def release(self): - """Release a semaphore, incrementing the internal counter by one. - - When the counter is zero on entry and another thread is waiting for it - to become larger than zero again, wake up that thread. - - If the number of releases exceeds the number of acquires, - raise a ValueError. - - """ - with self._Semaphore__cond: - if self._Semaphore__value >= self._initial_value: - raise ValueError("Semaphore released too many times") - self._Semaphore__value += 1 - self._Semaphore__cond.notify() + if self._Semaphore__value >= self._initial_value: + raise ValueError, "Semaphore released too many times" + return _Semaphore.release(self) def Event(*args, **kwargs): - """A factory function that returns a new event. - - Events manage a flag that can be set to true with the set() method and reset - to false with the clear() method. The wait() method blocks until the flag is - true. - - """ return _Event(*args, **kwargs) class _Event(_Verbose): - """A factory function that returns a new event object. An event manages a - flag that can be set to true with the set() method and reset to false - with the clear() method. The wait() method blocks until the flag is true. - - """ # After Tim Peters' event class (without is_posted()) @@ -567,18 +378,11 @@ self.__cond.__init__() def isSet(self): - 'Return true if and only if the internal flag is true.' return self.__flag is_set = isSet def set(self): - """Set the internal flag to true. - - All threads waiting for the flag to become true are awakened. Threads - that call wait() once the flag is true will not block at all. - - """ self.__cond.acquire() try: self.__flag = True @@ -587,12 +391,6 @@ self.__cond.release() def clear(self): - """Reset the internal flag to false. - - Subsequently, threads calling wait() will block until set() is called to - set the internal flag to true again. - - """ self.__cond.acquire() try: self.__flag = False @@ -600,20 +398,6 @@ self.__cond.release() def wait(self, timeout=None): - """Block until the internal flag is true. - - If the internal flag is true on entry, return immediately. Otherwise, - block until another thread calls set() to set the flag to true, or until - the optional timeout occurs. - - When the timeout argument is present and not None, it should be a - floating point number specifying a timeout for the operation in seconds - (or fractions thereof). - - This method returns the internal flag on exit, so it will always return - True except if a timeout is given and the operation times out. - - """ self.__cond.acquire() try: if not self.__flag: @@ -638,11 +422,7 @@ # Main class for threads class Thread(_Verbose): - """A class that represents a thread of control. - This class can be safely subclassed in a limited fashion. - - """ __initialized = False # Need to store a reference to sys.exc_info for printing # out exceptions when a thread tries to use a global var. during interp. @@ -655,27 +435,6 @@ def __init__(self, group=None, target=None, name=None, args=(), kwargs=None, verbose=None): - """This constructor should always be called with keyword arguments. Arguments are: - - *group* should be None; reserved for future extension when a ThreadGroup - class is implemented. - - *target* is the callable object to be invoked by the run() - method. Defaults to None, meaning nothing is called. - - *name* is the thread name. By default, a unique name is constructed of - the form "Thread-N" where N is a small decimal number. - - *args* is the argument tuple for the target invocation. Defaults to (). - - *kwargs* is a dictionary of keyword arguments for the target - invocation. Defaults to {}. - - If a subclass overrides the constructor, it must make sure to invoke - the base class constructor (Thread.__init__()) before doing anything - else to the thread. - -""" assert group is None, "group argument must be None for now" _Verbose.__init__(self, verbose) if kwargs is None: @@ -724,15 +483,6 @@ return "<%s(%s, %s)>" % (self.__class__.__name__, self.__name, status) def start(self): - """Start the thread's activity. - - It must be called at most once per thread object. It arranges for the - object's run() method to be invoked in a separate thread of control. - - This method will raise a RuntimeError if called more than once on the - same thread object. - - """ if not self.__initialized: raise RuntimeError("thread.__init__() not called") if self.__started.is_set(): @@ -750,14 +500,6 @@ self.__started.wait() def run(self): - """Method representing the thread's activity. - - You may override this method in a subclass. The standard run() method - invokes the callable object passed to the object's constructor as the - target argument, if any, with sequential and keyword arguments taken - from the args and kwargs arguments, respectively. - - """ try: if self.__target: self.__target(*self.__args, **self.__kwargs) @@ -864,10 +606,6 @@ pass def __stop(self): - # DummyThreads delete self.__block, but they have no waiters to - # notify anyway (join() is forbidden on them). - if not hasattr(self, '_Thread__block'): - return self.__block.acquire() self.__stopped = True self.__block.notify_all() @@ -909,29 +647,6 @@ raise def join(self, timeout=None): - """Wait until the thread terminates. - - This blocks the calling thread until the thread whose join() method is - called terminates -- either normally or through an unhandled exception - or until the optional timeout occurs. - - When the timeout argument is present and not None, it should be a - floating point number specifying a timeout for the operation in seconds - (or fractions thereof). As join() always returns None, you must call - isAlive() after join() to decide whether a timeout happened -- if the - thread is still alive, the join() call timed out. - - When the timeout argument is not present or None, the operation will - block until the thread terminates. - - A thread can be join()ed many times. - - join() raises a RuntimeError if an attempt is made to join the current - thread as that would cause a deadlock. It is also an error to join() a - thread before it has been started and attempts to do so raises the same - exception. - - """ if not self.__initialized: raise RuntimeError("Thread.__init__() not called") if not self.__started.is_set(): @@ -966,12 +681,6 @@ @property def name(self): - """A string used for identification purposes only. - - It has no semantics. Multiple threads may be given the same name. The - initial name is set by the constructor. - - """ assert self.__initialized, "Thread.__init__() not called" return self.__name @@ -982,24 +691,10 @@ @property def ident(self): - """Thread identifier of this thread or None if it has not been started. - - This is a nonzero integer. See the thread.get_ident() function. Thread - identifiers may be recycled when a thread exits and another thread is - created. The identifier is available even after the thread has exited. - - """ assert self.__initialized, "Thread.__init__() not called" return self.__ident def isAlive(self): - """Return whether the thread is alive. - - This method returns True just before the run() method starts until just - after the run() method terminates. The module function enumerate() - returns a list of all alive threads. - - """ assert self.__initialized, "Thread.__init__() not called" return self.__started.is_set() and not self.__stopped @@ -1007,17 +702,6 @@ @property def daemon(self): - """A boolean value indicating whether this thread is a daemon thread (True) or not (False). - - This must be set before start() is called, otherwise RuntimeError is - raised. Its initial value is inherited from the creating thread; the - main thread is not a daemon thread and therefore all threads created in - the main thread default to daemon = False. - - The entire Python program exits when no alive non-daemon threads are - left. - - """ assert self.__initialized, "Thread.__init__() not called" return self.__daemonic @@ -1044,24 +728,14 @@ # The timer class was contributed by Itamar Shtull-Trauring def Timer(*args, **kwargs): - """Factory function to create a Timer object. - - Timers call a function after a specified number of seconds: - - t = Timer(30.0, f, args=[], kwargs={}) - t.start() - t.cancel() # stop the timer's action if it's still waiting - - """ return _Timer(*args, **kwargs) class _Timer(Thread): """Call a function after a specified number of seconds: - t = Timer(30.0, f, args=[], kwargs={}) - t.start() - t.cancel() # stop the timer's action if it's still waiting - + t = Timer(30.0, f, args=[], kwargs={}) + t.start() + t.cancel() # stop the timer's action if it's still waiting """ def __init__(self, interval, function, args=[], kwargs={}): @@ -1150,12 +824,6 @@ # Global API functions def currentThread(): - """Return the current Thread object, corresponding to the caller's thread of control. - - If the caller's thread of control was not created through the threading - module, a dummy thread object with limited functionality is returned. - - """ try: return _active[_get_ident()] except KeyError: @@ -1165,12 +833,6 @@ current_thread = currentThread def activeCount(): - """Return the number of Thread objects currently alive. - - The returned count is equal to the length of the list returned by - enumerate(). - - """ with _active_limbo_lock: return len(_active) + len(_limbo) @@ -1181,13 +843,6 @@ return _active.values() + _limbo.values() def enumerate(): - """Return a list of all Thread objects currently alive. - - The list includes daemonic threads, dummy thread objects created by - current_thread(), and the main thread. It excludes terminated threads and - threads that have not yet been started. - - """ with _active_limbo_lock: return _active.values() + _limbo.values() @@ -1222,20 +877,23 @@ new_active = {} current = current_thread() with _active_limbo_lock: - for thread in _enumerate(): - # Any lock/condition variable may be currently locked or in an - # invalid state, so we reinitialize them. - if hasattr(thread, '_reset_internal_locks'): - thread._reset_internal_locks() + for thread in _active.itervalues(): if thread is current: # There is only one active thread. We reset the ident to # its new value since it can have changed. ident = _get_ident() thread._Thread__ident = ident + # Any condition variables hanging off of the active thread may + # be in an invalid state, so we reinitialize them. + if hasattr(thread, '_reset_internal_locks'): + thread._reset_internal_locks() new_active[ident] = thread else: # All the others are already stopped. - thread._Thread__stop() + # We don't call _Thread__stop() because it tries to acquire + # thread._Thread__block which could also have been held while + # we forked. + thread._Thread__stopped = True _limbo.clear() _active.clear() @@ -1255,7 +913,7 @@ self.rc = Condition(self.mon) self.wc = Condition(self.mon) self.limit = limit - self.queue = _deque() + self.queue = deque() def put(self, item): self.mon.acquire() diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Lib/token.py --- a/Lib/token.py Sat Jul 19 16:34:33 2014 -0700 +++ b/Lib/token.py Sun Jul 20 10:52:46 2014 -0400 @@ -1,3 +1,5 @@ +#! /usr/bin/env python + """Token constants (from "token.h").""" # This file is automatically generated; please don't muck it up! @@ -5,7 +7,7 @@ # To update the symbols in this file, 'cd' to the top directory of # the python source tree after building the interpreter and run: # -# ./python Lib/token.py +# python Lib/token.py #--start constants-- ENDMARKER = 0 diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Lib/tokenize.py --- a/Lib/tokenize.py Sat Jul 19 16:34:33 2014 -0700 +++ b/Lib/tokenize.py Sun Jul 20 10:52:46 2014 -0400 @@ -26,7 +26,6 @@ __credits__ = ('GvR, ESR, Tim Peters, Thomas Wouters, Fred Drake, ' 'Skip Montanaro, Raymond Hettinger') -from itertools import chain import string, re from token import * @@ -71,10 +70,10 @@ Single3 = r"[^'\\]*(?:(?:\\.|'(?!''))[^'\\]*)*'''" # Tail end of """ string. Double3 = r'[^"\\]*(?:(?:\\.|"(?!""))[^"\\]*)*"""' -Triple = group("[uUbB]?[rR]?'''", '[uUbB]?[rR]?"""') +Triple = group("[uU]?[rR]?'''", '[uU]?[rR]?"""') # Single-line ' or " string. -String = group(r"[uUbB]?[rR]?'[^\n'\\]*(?:\\.[^\n'\\]*)*'", - r'[uUbB]?[rR]?"[^\n"\\]*(?:\\.[^\n"\\]*)*"') +String = group(r"[uU]?[rR]?'[^\n'\\]*(?:\\.[^\n'\\]*)*'", + r'[uU]?[rR]?"[^\n"\\]*(?:\\.[^\n"\\]*)*"') # Because of leftmost-then-longest match semantics, be sure to put the # longest operators first (e.g., if = came before ==, == would get @@ -92,11 +91,11 @@ Token = Ignore + PlainToken # First (or only) line of ' or " string. -ContStr = group(r"[uUbB]?[rR]?'[^\n'\\]*(?:\\.[^\n'\\]*)*" + +ContStr = group(r"[uU]?[rR]?'[^\n'\\]*(?:\\.[^\n'\\]*)*" + group("'", r'\\\r?\n'), - r'[uUbB]?[rR]?"[^\n"\\]*(?:\\.[^\n"\\]*)*' + + r'[uU]?[rR]?"[^\n"\\]*(?:\\.[^\n"\\]*)*' + group('"', r'\\\r?\n')) -PseudoExtras = group(r'\\\r?\n|\Z', Comment, Triple) +PseudoExtras = group(r'\\\r?\n', Comment, Triple) PseudoToken = Whitespace + group(PseudoExtras, Number, Funny, ContStr, Name) tokenprog, pseudoprog, single3prog, double3prog = map( @@ -185,26 +184,17 @@ def add_whitespace(self, start): row, col = start - if row < self.prev_row or row == self.prev_row and col < self.prev_col: - raise ValueError("start ({},{}) precedes previous end ({},{})" - .format(row, col, self.prev_row, self.prev_col)) - row_offset = row - self.prev_row - if row_offset: - self.tokens.append("\\\n" * row_offset) - self.prev_col = 0 + assert row <= self.prev_row col_offset = col - self.prev_col if col_offset: self.tokens.append(" " * col_offset) def untokenize(self, iterable): - it = iter(iterable) - for t in it: + for t in iterable: if len(t) == 2: - self.compat(t, it) + self.compat(t, iterable) break tok_type, token, start, end, line = t - if tok_type == ENDMARKER: - break self.add_whitespace(start) self.tokens.append(token) self.prev_row, self.prev_col = end @@ -214,12 +204,16 @@ return "".join(self.tokens) def compat(self, token, iterable): + startline = False indents = [] toks_append = self.tokens.append - startline = token[0] in (NEWLINE, NL) + toknum, tokval = token + if toknum in (NAME, NUMBER): + tokval += ' ' + if toknum in (NEWLINE, NL): + startline = True prevstring = False - - for tok in chain([token], iterable): + for tok in iterable: toknum, tokval = tok[:2] if toknum in (NAME, NUMBER): @@ -269,7 +263,7 @@ def generate_tokens(readline): """ - The generate_tokens() generator requires one argument, readline, which + The generate_tokens() generator requires one argment, readline, which must be a callable object which provides the same interface as the readline() method of built-in file objects. Each call to the function should return one line of input as a string. Alternately, readline @@ -368,8 +362,6 @@ if pseudomatch: # scan for tokens start, end = pseudomatch.span(1) spos, epos, pos = (lnum, start), (lnum, end), end - if start == end: - continue token, initial = line[start:end], line[start] if initial in numchars or \ diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Lib/traceback.py --- a/Lib/traceback.py Sat Jul 19 16:34:33 2014 -0700 +++ b/Lib/traceback.py Sun Jul 20 10:52:46 2014 -0400 @@ -72,7 +72,7 @@ n = n+1 def format_tb(tb, limit = None): - """A shorthand for 'format_list(extract_tb(tb, limit))'.""" + """A shorthand for 'format_list(extract_stack(f, limit)).""" return format_list(extract_tb(tb, limit)) def extract_tb(tb, limit = None): @@ -166,7 +166,7 @@ # >>> raise string1, string2 # deprecated # # Clear these out first because issubtype(string1, SyntaxError) - # would raise another exception and mask the original problem. + # would throw another exception and mask the original problem. if (isinstance(etype, BaseException) or isinstance(etype, types.InstanceType) or etype is None or type(etype) is str): @@ -189,12 +189,11 @@ if badline is not None: lines.append(' %s\n' % badline.strip()) if offset is not None: - caretspace = badline.rstrip('\n') - offset = min(len(caretspace), offset) - 1 - caretspace = caretspace[:offset].lstrip() + caretspace = badline.rstrip('\n')[:offset].lstrip() # non-space whitespace (likes tabs) must be kept for alignment caretspace = ((c.isspace() and c or ' ') for c in caretspace) - lines.append(' %s^\n' % ''.join(caretspace)) + # only three spaces to account for offset1 == pos 0 + lines.append(' %s^\n' % ''.join(caretspace)) value = msg lines.append(_format_final_exc_line(stype, value)) diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Lib/unittest/__init__.py --- a/Lib/unittest/__init__.py Sat Jul 19 16:34:33 2014 -0700 +++ b/Lib/unittest/__init__.py Sun Jul 20 10:52:46 2014 -0400 @@ -11,7 +11,7 @@ import unittest - class IntegerArithmeticTestCase(unittest.TestCase): + class IntegerArithmenticTestCase(unittest.TestCase): def testAdd(self): ## test method names begin 'test*' self.assertEqual((1 + 2), 3) self.assertEqual(0 + 1, 1) diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Lib/unittest/case.py --- a/Lib/unittest/case.py Sat Jul 19 16:34:33 2014 -0700 +++ b/Lib/unittest/case.py Sun Jul 20 10:52:46 2014 -0400 @@ -6,7 +6,6 @@ import difflib import pprint import re -import types import warnings from . import result @@ -26,7 +25,7 @@ """ Raise this exception in a test to skip it. - Usually you can use TestCase.skipTest() or one of the skipping decorators + Usually you can use TestResult.skip() or one of the skipping decorators instead of raising this directly. """ pass @@ -56,7 +55,7 @@ Unconditionally skip a test. """ def decorator(test_item): - if not isinstance(test_item, (type, types.ClassType)): + if not (isinstance(test_item, type) and issubclass(test_item, TestCase)): @functools.wraps(test_item) def skip_wrapper(*args, **kwargs): raise SkipTest(reason) @@ -122,6 +121,8 @@ return True expected_regexp = self.expected_regexp + if isinstance(expected_regexp, basestring): + expected_regexp = re.compile(expected_regexp) if not expected_regexp.search(str(exc_value)): raise self.failureException('"%s" does not match "%s"' % (expected_regexp.pattern, str(exc_value))) @@ -148,23 +149,24 @@ should not change the signature of their __init__ method, since instances of the classes are instantiated automatically by parts of the framework in order to be run. + """ - When subclassing TestCase, you can set these attributes: - * failureException: determines which exception will be raised when - the instance's assertion methods fail; test methods raising this - exception will be deemed to have 'failed' rather than 'errored'. - * longMessage: determines whether long messages (including repr of - objects used in assert methods) will be printed on failure in *addition* - to any explicit message passed. - * maxDiff: sets the maximum length of a diff in failure messages - by assert methods using difflib. It is looked up as an instance - attribute so can be configured by individual tests if required. - """ + # This attribute determines which exception will be raised when + # the instance's assertion methods fail; test methods raising this + # exception will be deemed to have 'failed' rather than 'errored' failureException = AssertionError + # This attribute determines whether long messages (including repr of + # objects used in assert methods) will be printed on failure in *addition* + # to any explicit message passed. + longMessage = False + # This attribute sets the maximum length of a diff in failure messages + # by assert methods using difflib. It is looked up as an instance attribute + # so can be configured by individual tests if required. + maxDiff = 80*8 # If a string is longer than _diffThreshold, use normal comparison instead @@ -199,11 +201,7 @@ self.addTypeEqualityFunc(tuple, 'assertTupleEqual') self.addTypeEqualityFunc(set, 'assertSetEqual') self.addTypeEqualityFunc(frozenset, 'assertSetEqual') - try: - self.addTypeEqualityFunc(unicode, 'assertMultiLineEqual') - except NameError: - # No unicode support in this build - pass + self.addTypeEqualityFunc(unicode, 'assertMultiLineEqual') def addTypeEqualityFunc(self, typeobj, function): """Add a type specific assertEqual style function to compare a type. @@ -444,10 +442,10 @@ def assertRaises(self, excClass, callableObj=None, *args, **kwargs): - """Fail unless an exception of class excClass is raised + """Fail unless an exception of class excClass is thrown by callableObj when invoked with arguments args and keyword arguments kwargs. If a different type of exception is - raised, it will not be caught, and the test case will be + thrown, it will not be caught, and the test case will be deemed to have suffered an error, exactly as for an unexpected exception. @@ -513,7 +511,7 @@ assertion_func(first, second, msg=msg) def assertNotEqual(self, first, second, msg=None): - """Fail if the two objects are equal as determined by the '!=' + """Fail if the two objects are equal as determined by the '==' operator. """ if not first != second: @@ -873,7 +871,7 @@ - [0, 1, 1] and [1, 0, 1] compare equal. - [0, 0, 1] and [0, 1] compare unequal. """ - first_seq, second_seq = list(expected_seq), list(actual_seq) + first_seq, second_seq = list(actual_seq), list(expected_seq) with warnings.catch_warnings(): if sys.py3kwarning: # Silence Py3k warning raised during the sorting @@ -984,8 +982,6 @@ args: Extra args. kwargs: Extra kwargs. """ - if expected_regexp is not None: - expected_regexp = re.compile(expected_regexp) context = _AssertRaisesContext(expected_exception, self, expected_regexp) if callable_obj is None: return context diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Lib/unittest/loader.py --- a/Lib/unittest/loader.py Sat Jul 19 16:34:33 2014 -0700 +++ b/Lib/unittest/loader.py Sun Jul 20 10:52:46 2014 -0400 @@ -106,9 +106,7 @@ elif (isinstance(obj, types.UnboundMethodType) and isinstance(parent, type) and issubclass(parent, case.TestCase)): - name = parts[-1] - inst = parent(name) - return self.suiteClass([inst]) + return self.suiteClass([parent(obj.__name__)]) elif isinstance(obj, suite.TestSuite): return obj elif hasattr(obj, '__call__'): @@ -256,8 +254,8 @@ yield _make_failed_import_test(name, self.suiteClass) else: mod_file = os.path.abspath(getattr(module, '__file__', full_path)) - realpath = os.path.splitext(os.path.realpath(mod_file))[0] - fullpath_noext = os.path.splitext(os.path.realpath(full_path))[0] + realpath = os.path.splitext(mod_file)[0] + fullpath_noext = os.path.splitext(full_path)[0] if realpath.lower() != fullpath_noext.lower(): module_dir = os.path.dirname(realpath) mod_name = os.path.splitext(os.path.basename(full_path))[0] diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Lib/unittest/main.py --- a/Lib/unittest/main.py Sat Jul 19 16:34:33 2014 -0700 +++ b/Lib/unittest/main.py Sun Jul 20 10:52:46 2014 -0400 @@ -157,10 +157,7 @@ self.test = self.testLoader.loadTestsFromNames(self.testNames, self.module) - def _do_discovery(self, argv, Loader=None): - if Loader is None: - Loader = lambda: self.testLoader - + def _do_discovery(self, argv, Loader=loader.TestLoader): # handle command line args for test discovery self.progName = '%s discover' % self.progName import optparse diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Lib/unittest/runner.py --- a/Lib/unittest/runner.py Sat Jul 19 16:34:33 2014 -0700 +++ b/Lib/unittest/runner.py Sun Jul 20 10:52:46 2014 -0400 @@ -34,7 +34,7 @@ separator2 = '-' * 70 def __init__(self, stream, descriptions, verbosity): - super(TextTestResult, self).__init__(stream, descriptions, verbosity) + super(TextTestResult, self).__init__() self.stream = stream self.showAll = verbosity > 1 self.dots = verbosity == 1 diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Lib/unittest/signals.py --- a/Lib/unittest/signals.py Sat Jul 19 16:34:33 2014 -0700 +++ b/Lib/unittest/signals.py Sun Jul 20 10:52:46 2014 -0400 @@ -9,20 +9,6 @@ class _InterruptHandler(object): def __init__(self, default_handler): self.called = False - self.original_handler = default_handler - if isinstance(default_handler, int): - if default_handler == signal.SIG_DFL: - # Pretend it's signal.default_int_handler instead. - default_handler = signal.default_int_handler - elif default_handler == signal.SIG_IGN: - # Not quite the same thing as SIG_IGN, but the closest we - # can make it: do nothing. - def default_handler(unused_signum, unused_frame): - pass - else: - raise TypeError("expected SIGINT signal handler to be " - "signal.SIG_IGN, signal.SIG_DFL, or a " - "callable object") self.default_handler = default_handler def __call__(self, signum, frame): @@ -68,4 +54,4 @@ global _interrupt_handler if _interrupt_handler is not None: - signal.signal(signal.SIGINT, _interrupt_handler.original_handler) + signal.signal(signal.SIGINT, _interrupt_handler.default_handler) diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Lib/unittest/test/test_assertions.py --- a/Lib/unittest/test/test_assertions.py Sat Jul 19 16:34:33 2014 -0700 +++ b/Lib/unittest/test/test_assertions.py Sun Jul 20 10:52:46 2014 -0400 @@ -33,10 +33,6 @@ self.assertNotAlmostEqual(1.1, 1.0, delta=0.05) self.assertNotAlmostEqual(1.0, 1.1, delta=0.05) - self.assertAlmostEqual(1.0, 1.0, delta=0.5) - self.assertRaises(self.failureException, self.assertNotAlmostEqual, - 1.0, 1.0, delta=0.5) - self.assertRaises(self.failureException, self.assertAlmostEqual, 1.1, 1.0, delta=0.05) self.assertRaises(self.failureException, self.assertNotAlmostEqual, diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Lib/unittest/test/test_break.py --- a/Lib/unittest/test/test_break.py Sat Jul 19 16:34:33 2014 -0700 +++ b/Lib/unittest/test/test_break.py Sun Jul 20 10:52:46 2014 -0400 @@ -15,12 +15,9 @@ @unittest.skipIf(sys.platform == 'freebsd6', "Test kills regrtest on freebsd6 " "if threads have been used") class TestBreak(unittest.TestCase): - int_handler = None def setUp(self): self._default_handler = signal.getsignal(signal.SIGINT) - if self.int_handler is not None: - signal.signal(signal.SIGINT, self.int_handler) def tearDown(self): signal.signal(signal.SIGINT, self._default_handler) @@ -77,10 +74,6 @@ def testSecondInterrupt(self): - # Can't use skipIf decorator because the signal handler may have - # been changed after defining this method. - if signal.getsignal(signal.SIGINT) == signal.SIG_IGN: - self.skipTest("test requires SIGINT to not be ignored") result = unittest.TestResult() unittest.installHandler() unittest.registerResult(result) @@ -130,10 +123,6 @@ def testHandlerReplacedButCalled(self): - # Can't use skipIf decorator because the signal handler may have - # been changed after defining this method. - if signal.getsignal(signal.SIGINT) == signal.SIG_IGN: - self.skipTest("test requires SIGINT to not be ignored") # If our handler has been replaced (is no longer installed) but is # called by the *new* handler, then it isn't safe to delay the # SIGINT and we should immediately delegate to the default handler @@ -261,24 +250,3 @@ test() self.assertNotEqual(signal.getsignal(signal.SIGINT), default_handler) - -@unittest.skipUnless(hasattr(os, 'kill'), "Test requires os.kill") -@unittest.skipIf(sys.platform =="win32", "Test cannot run on Windows") -@unittest.skipIf(sys.platform == 'freebsd6', "Test kills regrtest on freebsd6 " - "if threads have been used") -class TestBreakDefaultIntHandler(TestBreak): - int_handler = signal.default_int_handler - -@unittest.skipUnless(hasattr(os, 'kill'), "Test requires os.kill") -@unittest.skipIf(sys.platform =="win32", "Test cannot run on Windows") -@unittest.skipIf(sys.platform == 'freebsd6', "Test kills regrtest on freebsd6 " - "if threads have been used") -class TestBreakSignalIgnored(TestBreak): - int_handler = signal.SIG_IGN - -@unittest.skipUnless(hasattr(os, 'kill'), "Test requires os.kill") -@unittest.skipIf(sys.platform =="win32", "Test cannot run on Windows") -@unittest.skipIf(sys.platform == 'freebsd6', "Test kills regrtest on freebsd6 " - "if threads have been used") -class TestBreakSignalDefault(TestBreak): - int_handler = signal.SIG_DFL diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Lib/unittest/test/test_case.py --- a/Lib/unittest/test/test_case.py Sat Jul 19 16:34:33 2014 -0700 +++ b/Lib/unittest/test/test_case.py Sun Jul 20 10:52:46 2014 -0400 @@ -293,7 +293,7 @@ def test(self): pass - self.assertIs(Foo('test').failureException, AssertionError) + self.assertTrue(Foo('test').failureException is AssertionError) # "This class attribute gives the exception raised by the test() method. # If a test framework needs to use a specialized exception, possibly to @@ -311,7 +311,7 @@ failureException = RuntimeError - self.assertIs(Foo('test').failureException, RuntimeError) + self.assertTrue(Foo('test').failureException is RuntimeError) Foo('test').run(result) @@ -334,7 +334,7 @@ failureException = RuntimeError - self.assertIs(Foo('test').failureException, RuntimeError) + self.assertTrue(Foo('test').failureException is RuntimeError) Foo('test').run(result) @@ -607,7 +607,7 @@ msg = e.args[0] else: self.fail('assertSequenceEqual did not fail.') - self.assertLess(len(msg), len(diff)) + self.assertTrue(len(msg) < len(diff)) self.assertIn(omitted, msg) self.maxDiff = len(diff) * 2 @@ -617,7 +617,7 @@ msg = e.args[0] else: self.fail('assertSequenceEqual did not fail.') - self.assertGreater(len(msg), len(diff)) + self.assertTrue(len(msg) > len(diff)) self.assertNotIn(omitted, msg) self.maxDiff = None @@ -627,7 +627,7 @@ msg = e.args[0] else: self.fail('assertSequenceEqual did not fail.') - self.assertGreater(len(msg), len(diff)) + self.assertTrue(len(msg) > len(diff)) self.assertNotIn(omitted, msg) def testTruncateMessage(self): @@ -979,12 +979,6 @@ self.assertRaisesRegexp, Exception, u'x', lambda: None) - def testAssertRaisesRegexpInvalidRegexp(self): - # Issue 20145. - class MyExc(Exception): - pass - self.assertRaises(TypeError, self.assertRaisesRegexp, MyExc, lambda: True) - def testAssertRaisesRegexpMismatch(self): def Stub(): raise Exception('Unexpected') diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Lib/unittest/test/test_discovery.py --- a/Lib/unittest/test/test_discovery.py Sat Jul 19 16:34:33 2014 -0700 +++ b/Lib/unittest/test/test_discovery.py Sun Jul 20 10:52:46 2014 -0400 @@ -220,26 +220,12 @@ program = object.__new__(unittest.TestProgram) program.usageExit = usageExit - program.testLoader = None with self.assertRaises(Stop): # too many args program._do_discovery(['one', 'two', 'three', 'four']) - def test_command_line_handling_do_discovery_uses_default_loader(self): - program = object.__new__(unittest.TestProgram) - - class Loader(object): - args = [] - def discover(self, start_dir, pattern, top_level_dir): - self.args.append((start_dir, pattern, top_level_dir)) - return 'tests' - - program.testLoader = Loader() - program._do_discovery(['-v']) - self.assertEqual(Loader.args, [('.', 'test*.py', None)]) - def test_command_line_handling_do_discovery_calls_loader(self): program = object.__new__(unittest.TestProgram) @@ -314,7 +300,7 @@ self.assertTrue(program.failfast) self.assertTrue(program.catchbreak) - def setup_module_clash(self): + def test_detect_module_clash(self): class Module(object): __file__ = 'bar/foo.py' sys.modules['foo'] = Module @@ -341,10 +327,7 @@ os.listdir = listdir os.path.isfile = isfile os.path.isdir = isdir - return full_path - def test_detect_module_clash(self): - full_path = self.setup_module_clash() loader = unittest.TestLoader() mod_dir = os.path.abspath('bar') @@ -357,25 +340,6 @@ ) self.assertEqual(sys.path[0], full_path) - def test_module_symlink_ok(self): - full_path = self.setup_module_clash() - - original_realpath = os.path.realpath - - mod_dir = os.path.abspath('bar') - expected_dir = os.path.abspath('foo') - - def cleanup(): - os.path.realpath = original_realpath - self.addCleanup(cleanup) - - def realpath(path): - if path == os.path.join(mod_dir, 'foo.py'): - return os.path.join(expected_dir, 'foo.py') - return path - os.path.realpath = realpath - loader = unittest.TestLoader() - loader.discover(start_dir='foo', pattern='foo.py') def test_discovery_from_dotted_path(self): loader = unittest.TestLoader() diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Lib/unittest/test/test_loader.py --- a/Lib/unittest/test/test_loader.py Sat Jul 19 16:34:33 2014 -0700 +++ b/Lib/unittest/test/test_loader.py Sun Jul 20 10:52:46 2014 -0400 @@ -324,7 +324,7 @@ # Does loadTestsFromName raise TypeError when the `module` argument # isn't a module object? # - # XXX Accepts the not-a-module object, ignoring the object's type + # XXX Accepts the not-a-module object, ignorning the object's type # This should raise an exception or the method name should be changed # # XXX Some people are relying on this, so keep it for now @@ -1279,23 +1279,8 @@ # "The default value is the TestSuite class" def test_suiteClass__default_value(self): loader = unittest.TestLoader() - self.assertIs(loader.suiteClass, unittest.TestSuite) + self.assertTrue(loader.suiteClass is unittest.TestSuite) - # Make sure the dotted name resolution works even if the actual - # function doesn't have the same name as is used to find it. - def test_loadTestsFromName__function_with_different_name_than_method(self): - # lambdas have the name ''. - m = types.ModuleType('m') - class MyTestCase(unittest.TestCase): - test = lambda: 1 - m.testcase_1 = MyTestCase - - loader = unittest.TestLoader() - suite = loader.loadTestsFromNames(['testcase_1.test'], m) - self.assertIsInstance(suite, loader.suiteClass) - - ref_suite = unittest.TestSuite([MyTestCase('test')]) - self.assertEqual(list(suite), [ref_suite]) if __name__ == '__main__': unittest.main() diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Lib/unittest/test/test_result.py --- a/Lib/unittest/test/test_result.py Sat Jul 19 16:34:33 2014 -0700 +++ b/Lib/unittest/test/test_result.py Sun Jul 20 10:52:46 2014 -0400 @@ -176,7 +176,7 @@ self.assertEqual(result.shouldStop, False) test_case, formatted_exc = result.failures[0] - self.assertIs(test_case, test) + self.assertTrue(test_case is test) self.assertIsInstance(formatted_exc, str) # "addError(test, err)" @@ -224,7 +224,7 @@ self.assertEqual(result.shouldStop, False) test_case, formatted_exc = result.errors[0] - self.assertIs(test_case, test) + self.assertTrue(test_case is test) self.assertIsInstance(formatted_exc, str) def testGetDescriptionWithoutDocstring(self): diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Lib/unittest/test/test_runner.py --- a/Lib/unittest/test/test_runner.py Sat Jul 19 16:34:33 2014 -0700 +++ b/Lib/unittest/test/test_runner.py Sun Jul 20 10:52:46 2014 -0400 @@ -149,19 +149,6 @@ self.assertEqual(runner.resultclass, unittest.TextTestResult) - def test_multiple_inheritance(self): - class AResult(unittest.TestResult): - def __init__(self, stream, descriptions, verbosity): - super(AResult, self).__init__(stream, descriptions, verbosity) - - class ATextResult(unittest.TextTestResult, AResult): - pass - - # This used to raise an exception due to TextTestResult not passing - # on arguments in its __init__ super call - ATextResult(None, None, 1) - - def testBufferAndFailfast(self): class Test(unittest.TestCase): def testFoo(self): diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Lib/unittest/test/test_skipping.py --- a/Lib/unittest/test/test_skipping.py Sat Jul 19 16:34:33 2014 -0700 +++ b/Lib/unittest/test/test_skipping.py Sun Jul 20 10:52:46 2014 -0400 @@ -66,36 +66,6 @@ self.assertEqual(result.skipped, [(test, "testing")]) self.assertEqual(record, []) - def test_skip_non_unittest_class_old_style(self): - @unittest.skip("testing") - class Mixin: - def test_1(self): - record.append(1) - class Foo(Mixin, unittest.TestCase): - pass - record = [] - result = unittest.TestResult() - test = Foo("test_1") - suite = unittest.TestSuite([test]) - suite.run(result) - self.assertEqual(result.skipped, [(test, "testing")]) - self.assertEqual(record, []) - - def test_skip_non_unittest_class_new_style(self): - @unittest.skip("testing") - class Mixin(object): - def test_1(self): - record.append(1) - class Foo(Mixin, unittest.TestCase): - pass - record = [] - result = unittest.TestResult() - test = Foo("test_1") - suite = unittest.TestSuite([test]) - suite.run(result) - self.assertEqual(result.skipped, [(test, "testing")]) - self.assertEqual(record, []) - def test_expected_failure(self): class Foo(unittest.TestCase): @unittest.expectedFailure diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Lib/urllib.py --- a/Lib/urllib.py Sat Jul 19 16:34:33 2014 -0700 +++ b/Lib/urllib.py Sun Jul 20 10:52:46 2014 -0400 @@ -27,9 +27,6 @@ import os import time import sys -import base64 -import re - from urlparse import urljoin as basejoin __all__ = ["urlopen", "URLopener", "FancyURLopener", "urlretrieve", @@ -321,13 +318,13 @@ if not host: raise IOError, ('http error', 'no host given') if proxy_passwd: - proxy_passwd = unquote(proxy_passwd) + import base64 proxy_auth = base64.b64encode(proxy_passwd).strip() else: proxy_auth = None if user_passwd: - user_passwd = unquote(user_passwd) + import base64 auth = base64.b64encode(user_passwd).strip() else: auth = None @@ -377,6 +374,7 @@ def http_error_default(self, url, fp, errcode, errmsg, headers): """Default error handler: close the connection and raise IOError.""" + void = fp.read() fp.close() raise IOError, ('http error', errcode, errmsg, headers) @@ -411,12 +409,12 @@ #print "proxy via https:", host, selector if not host: raise IOError, ('https error', 'no host given') if proxy_passwd: - proxy_passwd = unquote(proxy_passwd) + import base64 proxy_auth = base64.b64encode(proxy_passwd).strip() else: proxy_auth = None if user_passwd: - user_passwd = unquote(user_passwd) + import base64 auth = base64.b64encode(user_passwd).strip() else: auth = None @@ -485,8 +483,6 @@ urlfile = file if file[:1] == '/': urlfile = 'file://' + file - elif file[:2] == './': - raise ValueError("local file url may start with / or file:. Unknown url of type: %s" % url) return addinfourl(open(localname, 'rb'), headers, urlfile) host, port = splitport(host) @@ -594,6 +590,7 @@ time.gmtime(time.time()))) msg.append('Content-type: %s' % type) if encoding == 'base64': + import base64 data = base64.decodestring(data) else: data = unquote(data) @@ -643,6 +640,7 @@ newurl = headers['uri'] else: return + void = fp.read() fp.close() # In case the server sent a relative URL, join with original: newurl = basejoin(self.type + ":" + url, newurl) @@ -819,10 +817,7 @@ """Return the IP address of the current host.""" global _thishost if _thishost is None: - try: - _thishost = socket.gethostbyname(socket.gethostname()) - except socket.gaierror: - _thishost = socket.gethostbyname('localhost') + _thishost = socket.gethostbyname(socket.gethostname()) return _thishost _ftperrors = None @@ -873,8 +868,8 @@ self.ftp = ftplib.FTP() self.ftp.connect(self.host, self.port, self.timeout) self.ftp.login(self.user, self.passwd) - _target = '/'.join(self.dirs) - self.ftp.cwd(_target) + for dir in self.dirs: + self.ftp.cwd(dir) def retrfile(self, file, type): import ftplib @@ -984,11 +979,11 @@ self.hookargs = hookargs def close(self): + addbase.close(self) if self.closehook: self.closehook(*self.hookargs) self.closehook = None self.hookargs = None - addbase.close(self) class addinfo(addbase): """class to add an info() method to an open file.""" @@ -1125,13 +1120,10 @@ global _portprog if _portprog is None: import re - _portprog = re.compile('^(.*):([0-9]*)$') + _portprog = re.compile('^(.*):([0-9]+)$') match = _portprog.match(host) - if match: - host, port = match.groups() - if port: - return host, port + if match: return match.group(1, 2) return host, None _nportprog = None @@ -1148,12 +1140,12 @@ match = _nportprog.match(host) if match: host, port = match.group(1, 2) - if port: - try: - nport = int(port) - except ValueError: - nport = None - return host, nport + try: + if not port: raise ValueError, "no digits" + nport = int(port) + except ValueError: + nport = None + return host, nport return host, defport _queryprog = None @@ -1205,35 +1197,22 @@ _hexdig = '0123456789ABCDEFabcdef' _hextochr = dict((a + b, chr(int(a + b, 16))) for a in _hexdig for b in _hexdig) -_asciire = re.compile('([\x00-\x7f]+)') def unquote(s): """unquote('abc%20def') -> 'abc def'.""" - if _is_unicode(s): - if '%' not in s: - return s - bits = _asciire.split(s) - res = [bits[0]] - append = res.append - for i in range(1, len(bits), 2): - append(unquote(str(bits[i])).decode('latin1')) - append(bits[i + 1]) - return ''.join(res) - - bits = s.split('%') + res = s.split('%') # fastpath - if len(bits) == 1: + if len(res) == 1: return s - res = [bits[0]] - append = res.append - for item in bits[1:]: + s = res[0] + for item in res[1:]: try: - append(_hextochr[item[:2]]) - append(item[2:]) + s += _hextochr[item[:2]] + item[2:] except KeyError: - append('%') - append(item) - return ''.join(res) + s += '%' + item + except UnicodeDecodeError: + s += unichr(int(item[:2], 16)) + item[2:] + return s def unquote_plus(s): """unquote('%7e/abc+def') -> '~/abc def'""" diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Lib/urllib2.py --- a/Lib/urllib2.py Sat Jul 19 16:34:33 2014 -0700 +++ b/Lib/urllib2.py Sun Jul 20 10:52:46 2014 -0400 @@ -102,7 +102,6 @@ import time import urlparse import bisect -import warnings try: from cStringIO import StringIO @@ -110,7 +109,7 @@ from StringIO import StringIO from urllib import (unwrap, unquote, splittype, splithost, quote, - addinfourl, splitport, splittag, toBytes, + addinfourl, splitport, splittag, splitattr, ftpwrapper, splituser, splitpasswd, splitvalue) # support for FileHandler, proxies via environment variables @@ -173,9 +172,6 @@ def reason(self): return self.msg - def info(self): - return self.hdrs - # copied from cookielib.py _cut_port_re = re.compile(r":\d+$") def request_host(request): @@ -832,7 +828,7 @@ # allow for double- and single-quoted realm values # (single quotes are a violation of the RFC, but appear in the wild) rx = re.compile('(?:.*,)*[ \t]*([^ \t]+)[ \t]+' - 'realm=(["\']?)([^"\']*)\\2', re.I) + 'realm=(["\'])(.*?)\\2', re.I) # XXX could pre-emptively send auth info already accepted (RFC 2617, # end of section 2, and section 1.2 immediately after "credentials" @@ -865,9 +861,6 @@ mo = AbstractBasicAuthHandler.rx.search(authreq) if mo: scheme, quote, realm = mo.groups() - if quote not in ['"', "'"]: - warnings.warn("Basic Auth Realm was unquoted", - UserWarning, 2) if scheme.lower() == 'basic': response = self.retry_http_basic_auth(host, req, realm) if response and response.code != 401: diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Lib/urlparse.py --- a/Lib/urlparse.py Sat Jul 19 16:34:33 2014 -0700 +++ b/Lib/urlparse.py Sun Jul 20 10:52:46 2014 -0400 @@ -28,8 +28,6 @@ """ -import re - __all__ = ["urlparse", "urlunparse", "urljoin", "urldefrag", "urlsplit", "urlunsplit", "parse_qs", "parse_qsl"] @@ -42,14 +40,11 @@ 'imap', 'wais', 'file', 'mms', 'https', 'shttp', 'snews', 'prospero', 'rtsp', 'rtspu', 'rsync', '', 'svn', 'svn+ssh', 'sftp','nfs','git', 'git+ssh'] +non_hierarchical = ['gopher', 'hdl', 'mailto', 'news', + 'telnet', 'wais', 'imap', 'snews', 'sip', 'sips'] uses_params = ['ftp', 'hdl', 'prospero', 'http', 'imap', 'https', 'shttp', 'rtsp', 'rtspu', 'sip', 'sips', - 'mms', '', 'sftp', 'tel'] - -# These are not actually used anymore, but should stay for backwards -# compatibility. (They are undocumented, but have a public-looking name.) -non_hierarchical = ['gopher', 'hdl', 'mailto', 'news', - 'telnet', 'wais', 'imap', 'snews', 'sip', 'sips'] + 'mms', '', 'sftp'] uses_query = ['http', 'wais', 'imap', 'https', 'shttp', 'mms', 'gopher', 'rtsp', 'rtspu', 'sip', 'sips', ''] uses_fragment = ['ftp', 'hdl', 'http', 'gopher', 'news', @@ -109,12 +104,9 @@ netloc = self.netloc.split('@')[-1].split(']')[-1] if ':' in netloc: port = netloc.split(':')[1] - if port: - port = int(port, 10) - # verify legal port - if (0 <= port <= 65535): - return port - return None + return int(port, 10) + else: + return None from collections import namedtuple @@ -200,21 +192,21 @@ if c not in scheme_chars: break else: - # make sure "url" is not actually a port number (in which case - # "scheme" is really part of the path) - rest = url[i+1:] - if not rest or any(c not in '0123456789' for c in rest): - # not a port number - scheme, url = url[:i].lower(), rest + try: + # make sure "url" is not actually a port number (in which case + # "scheme" is really part of the path + _testportnum = int(url[i+1:]) + except ValueError: + scheme, url = url[:i].lower(), url[i+1:] if url[:2] == '//': netloc, url = _splitnetloc(url, 2) if (('[' in netloc and ']' not in netloc) or (']' in netloc and '[' not in netloc)): raise ValueError("Invalid IPv6 URL") - if allow_fragments and '#' in url: + if allow_fragments and scheme in uses_fragment and '#' in url: url, fragment = url.split('#', 1) - if '?' in url: + if scheme in uses_query and '?' in url: url, query = url.split('?', 1) v = SplitResult(scheme, netloc, url, query, fragment) _parse_cache[key] = v @@ -314,15 +306,6 @@ else: return url, '' -try: - unicode -except NameError: - def _is_unicode(x): - return 0 -else: - def _is_unicode(x): - return isinstance(x, unicode) - # unquote method for parse_qs and parse_qsl # Cannot use directly from urllib as it would create a circular reference # because urllib uses urlparse methods (urljoin). If you update this function, @@ -331,35 +314,22 @@ _hexdig = '0123456789ABCDEFabcdef' _hextochr = dict((a+b, chr(int(a+b,16))) for a in _hexdig for b in _hexdig) -_asciire = re.compile('([\x00-\x7f]+)') def unquote(s): """unquote('abc%20def') -> 'abc def'.""" - if _is_unicode(s): - if '%' not in s: - return s - bits = _asciire.split(s) - res = [bits[0]] - append = res.append - for i in range(1, len(bits), 2): - append(unquote(str(bits[i])).decode('latin1')) - append(bits[i + 1]) - return ''.join(res) - - bits = s.split('%') + res = s.split('%') # fastpath - if len(bits) == 1: + if len(res) == 1: return s - res = [bits[0]] - append = res.append - for item in bits[1:]: + s = res[0] + for item in res[1:]: try: - append(_hextochr[item[:2]]) - append(item[2:]) + s += _hextochr[item[:2]] + item[2:] except KeyError: - append('%') - append(item) - return ''.join(res) + s += '%' + item + except UnicodeDecodeError: + s += unichr(int(item[:2], 16)) + item[2:] + return s def parse_qs(qs, keep_blank_values=0, strict_parsing=0): """Parse a query given as a string argument. diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Lib/uuid.py --- a/Lib/uuid.py Sat Jul 19 16:34:33 2014 -0700 +++ b/Lib/uuid.py Sun Jul 20 10:52:46 2014 -0400 @@ -293,38 +293,25 @@ def _find_mac(command, args, hw_identifiers, get_index): import os - path = os.environ.get("PATH", os.defpath).split(os.pathsep) - path.extend(('/sbin', '/usr/sbin')) - for dir in path: + for dir in ['', '/sbin/', '/usr/sbin']: executable = os.path.join(dir, command) - if (os.path.exists(executable) and - os.access(executable, os.F_OK | os.X_OK) and - not os.path.isdir(executable)): - break - else: - return None + if not os.path.exists(executable): + continue - try: - # LC_ALL to ensure English output, 2>/dev/null to - # prevent output on stderr - cmd = 'LC_ALL=C %s %s 2>/dev/null' % (executable, args) - with os.popen(cmd) as pipe: - for line in pipe: - words = line.lower().split() - for i in range(len(words)): - if words[i] in hw_identifiers: - try: + try: + # LC_ALL to get English output, 2>/dev/null to + # prevent output on stderr + cmd = 'LC_ALL=C %s %s 2>/dev/null' % (executable, args) + with os.popen(cmd) as pipe: + for line in pipe: + words = line.lower().split() + for i in range(len(words)): + if words[i] in hw_identifiers: return int( words[get_index(i)].replace(':', ''), 16) - except (ValueError, IndexError): - # Virtual interfaces, such as those provided by - # VPNs, do not have a colon-delimited MAC address - # as expected, but a 16-byte HWAddr separated by - # dashes. These should be ignored in favor of a - # real MAC address - pass - except IOError: - pass + except IOError: + continue + return None def _ifconfig_getnode(): """Get the hardware address on Unix by running ifconfig.""" @@ -421,8 +408,6 @@ _uuid_generate_random = lib.uuid_generate_random if hasattr(lib, 'uuid_generate_time'): _uuid_generate_time = lib.uuid_generate_time - if _uuid_generate_random is not None: - break # found everything we were looking for # The uuid_generate_* functions are broken on MacOS X 10.5, as noted # in issue #8621 the function generates the same sequence of values diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Lib/wave.py --- a/Lib/wave.py Sat Jul 19 16:34:33 2014 -0700 +++ b/Lib/wave.py Sun Jul 20 10:52:46 2014 -0400 @@ -80,18 +80,17 @@ WAVE_FORMAT_PCM = 0x0001 -_array_fmts = None, 'b', 'h', None, 'i' +_array_fmts = None, 'b', 'h', None, 'l' +# Determine endian-ness import struct -import sys +if struct.pack("h", 1) == "\000\001": + big_endian = 1 +else: + big_endian = 0 + from chunk import Chunk -def _byteswap3(data): - ba = bytearray(data) - ba[::3] = data[2::3] - ba[2::3] = data[::3] - return bytes(ba) - class Wave_read: """Variables used in this class: @@ -232,14 +231,13 @@ self._data_seek_needed = 0 if nframes == 0: return '' - if self._sampwidth in (2, 4) and sys.byteorder == 'big': + if self._sampwidth > 1 and big_endian: # unfortunately the fromfile() method does not take # something that only looks like a file object, so # we have to reach into the innards of the chunk object import array chunk = self._data_chunk data = array.array(_array_fmts[self._sampwidth]) - assert data.itemsize == self._sampwidth nitems = nframes * self._nchannels if nitems * self._sampwidth > chunk.chunksize - chunk.size_read: nitems = (chunk.chunksize - chunk.size_read) / self._sampwidth @@ -253,8 +251,6 @@ data = data.tostring() else: data = self._data_chunk.read(nframes * self._framesize) - if self._sampwidth == 3 and sys.byteorder == 'big': - data = _byteswap3(data) if self._convert and data: data = self._convert(data) self._soundpos = self._soundpos + len(data) // (self._nchannels * self._sampwidth) @@ -265,9 +261,9 @@ # def _read_fmt_chunk(self, chunk): - wFormatTag, self._nchannels, self._framerate, dwAvgBytesPerSec, wBlockAlign = struct.unpack(' 1 and big_endian: import array - a = array.array(_array_fmts[self._sampwidth]) - a.fromstring(data) - data = a - assert data.itemsize == self._sampwidth + data = array.array(_array_fmts[self._sampwidth], data) data.byteswap() data.tofile(self._file) self._datawritten = self._datawritten + len(data) * self._sampwidth else: - if self._sampwidth == 3 and sys.byteorder == 'big': - data = _byteswap3(data) self._file.write(data) self._datawritten = self._datawritten + len(data) self._nframeswritten = self._nframeswritten + nframes @@ -445,13 +436,11 @@ def close(self): if self._file: - try: - self._ensure_header_written(0) - if self._datalength != self._datawritten: - self._patchheader() - self._file.flush() - finally: - self._file = None + self._ensure_header_written(0) + if self._datalength != self._datawritten: + self._patchheader() + self._file.flush() + self._file = None if self._i_opened_the_file: self._i_opened_the_file.close() self._i_opened_the_file = None @@ -477,14 +466,14 @@ self._nframes = initlength / (self._nchannels * self._sampwidth) self._datalength = self._nframes * self._nchannels * self._sampwidth self._form_length_pos = self._file.tell() - self._file.write(struct.pack('" % id(self) def __setitem__(self, key, value): - if self._pending_removals: - self._commit_removals() self.data[key] = KeyedRef(value, self._remove, key) - def clear(self): - if self._pending_removals: - self._commit_removals() - self.data.clear() - def copy(self): new = WeakValueDictionary() for key, wr in self.data.items(): @@ -146,18 +120,16 @@ return L def iteritems(self): - with _IterationGuard(self): - for wr in self.data.itervalues(): - value = wr() - if value is not None: - yield wr.key, value + for wr in self.data.itervalues(): + value = wr() + if value is not None: + yield wr.key, value def iterkeys(self): - with _IterationGuard(self): - for k in self.data.iterkeys(): - yield k + return self.data.iterkeys() - __iter__ = iterkeys + def __iter__(self): + return self.data.iterkeys() def itervaluerefs(self): """Return an iterator that yields the weak references to the values. @@ -169,20 +141,15 @@ keep the values around longer than needed. """ - with _IterationGuard(self): - for wr in self.data.itervalues(): - yield wr + return self.data.itervalues() def itervalues(self): - with _IterationGuard(self): - for wr in self.data.itervalues(): - obj = wr() - if obj is not None: - yield obj + for wr in self.data.itervalues(): + obj = wr() + if obj is not None: + yield obj def popitem(self): - if self._pending_removals: - self._commit_removals() while 1: key, wr = self.data.popitem() o = wr() @@ -190,8 +157,6 @@ return key, o def pop(self, key, *args): - if self._pending_removals: - self._commit_removals() try: o = self.data.pop(key)() except KeyError: @@ -207,16 +172,12 @@ try: wr = self.data[key] except KeyError: - if self._pending_removals: - self._commit_removals() self.data[key] = KeyedRef(default, self._remove, key) return default else: return wr() def update(self, dict=None, **kwargs): - if self._pending_removals: - self._commit_removals() d = self.data if dict is not None: if not hasattr(dict, "items"): @@ -284,29 +245,9 @@ def remove(k, selfref=ref(self)): self = selfref() if self is not None: - if self._iterating: - self._pending_removals.append(k) - else: - del self.data[k] + del self.data[k] self._remove = remove - # A list of dead weakrefs (keys to be removed) - self._pending_removals = [] - self._iterating = set() - if dict is not None: - self.update(dict) - - def _commit_removals(self): - # NOTE: We don't need to call this method before mutating the dict, - # because a dead weakref never compares equal to a live weakref, - # even if they happened to refer to equal objects. - # However, it means keys may already have been removed. - l = self._pending_removals - d = self.data - while l: - try: - del d[l.pop()] - except KeyError: - pass + if dict is not None: self.update(dict) def __delitem__(self, key): del self.data[ref(key)] @@ -365,11 +306,10 @@ return L def iteritems(self): - with _IterationGuard(self): - for wr, value in self.data.iteritems(): - key = wr() - if key is not None: - yield key, value + for wr, value in self.data.iteritems(): + key = wr() + if key is not None: + yield key, value def iterkeyrefs(self): """Return an iterator that yields the weak references to the keys. @@ -381,23 +321,19 @@ keep the keys around longer than needed. """ - with _IterationGuard(self): - for wr in self.data.iterkeys(): - yield wr + return self.data.iterkeys() def iterkeys(self): - with _IterationGuard(self): - for wr in self.data.iterkeys(): - obj = wr() - if obj is not None: - yield obj + for wr in self.data.iterkeys(): + obj = wr() + if obj is not None: + yield obj - __iter__ = iterkeys + def __iter__(self): + return self.iterkeys() def itervalues(self): - with _IterationGuard(self): - for value in self.data.itervalues(): - yield value + return self.data.itervalues() def keyrefs(self): """Return a list of weak references to the keys. diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Lib/webbrowser.py --- a/Lib/webbrowser.py Sat Jul 19 16:34:33 2014 -0700 +++ b/Lib/webbrowser.py Sun Jul 20 10:52:46 2014 -0400 @@ -304,18 +304,6 @@ background = True -class Chrome(UnixBrowser): - "Launcher class for Google Chrome browser." - - remote_args = ['%action', '%s'] - remote_action = "" - remote_action_newwin = "--new-window" - remote_action_newtab = "" - background = True - -Chromium = Chrome - - class Opera(UnixBrowser): "Launcher class for Opera browser." @@ -453,14 +441,6 @@ def register_X_browsers(): - # use xdg-open if around - if _iscommand("xdg-open"): - register("xdg-open", None, BackgroundBrowser("xdg-open")) - - # The default GNOME3 browser - if "GNOME_DESKTOP_SESSION_ID" in os.environ and _iscommand("gvfs-open"): - register("gvfs-open", None, BackgroundBrowser("gvfs-open")) - # The default GNOME browser if "GNOME_DESKTOP_SESSION_ID" in os.environ and _iscommand("gnome-open"): register("gnome-open", None, BackgroundBrowser("gnome-open")) @@ -469,13 +449,9 @@ if "KDE_FULL_SESSION" in os.environ and _iscommand("kfmclient"): register("kfmclient", Konqueror, Konqueror("kfmclient")) - if _iscommand("x-www-browser"): - register("x-www-browser", None, BackgroundBrowser("x-www-browser")) - # The Mozilla/Netscape browsers for browser in ("mozilla-firefox", "firefox", "mozilla-firebird", "firebird", - "iceweasel", "iceape", "seamonkey", "mozilla", "netscape"): if _iscommand(browser): register(browser, None, Mozilla(browser)) @@ -495,11 +471,6 @@ if _iscommand("skipstone"): register("skipstone", None, BackgroundBrowser("skipstone")) - # Google Chrome/Chromium browsers - for browser in ("google-chrome", "chrome", "chromium", "chromium-browser"): - if _iscommand(browser): - register(browser, None, Chrome(browser)) - # Opera, quite popular if _iscommand("opera"): register("opera", None, Opera("opera")) @@ -518,8 +489,6 @@ # Also try console browsers if os.environ.get("TERM"): - if _iscommand("www-browser"): - register("www-browser", None, GenericBrowser("www-browser")) # The Links/elinks browsers if _iscommand("links"): register("links", None, GenericBrowser("links")) diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Lib/wsgiref/handlers.py --- a/Lib/wsgiref/handlers.py Sat Jul 19 16:34:33 2014 -0700 +++ b/Lib/wsgiref/handlers.py Sun Jul 20 10:52:46 2014 -0400 @@ -122,13 +122,11 @@ in the event loop to iterate over the data, and to call 'self.close()' once the response is finished. """ - try: - if not self.result_is_file() or not self.sendfile(): - for data in self.result: - self.write(data) - self.finish_content() - finally: - self.close() + if not self.result_is_file() or not self.sendfile(): + for data in self.result: + self.write(data) + self.finish_content() + self.close() def get_scheme(self): diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Lib/wsgiref/simple_server.py --- a/Lib/wsgiref/simple_server.py Sat Jul 19 16:34:33 2014 -0700 +++ b/Lib/wsgiref/simple_server.py Sun Jul 20 10:52:46 2014 -0400 @@ -153,4 +153,3 @@ import webbrowser webbrowser.open('http://localhost:8000/xyz?abc') httpd.handle_request() # serve one request, then exit - httpd.server_close() diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Lib/wsgiref/validate.py --- a/Lib/wsgiref/validate.py Sat Jul 19 16:34:33 2014 -0700 +++ b/Lib/wsgiref/validate.py Sun Jul 20 10:52:46 2014 -0400 @@ -134,9 +134,9 @@ When applied between a WSGI server and a WSGI application, this middleware will check for WSGI compliancy on a number of levels. This middleware does not modify the request or response in any - way, but will raise an AssertionError if anything seems off + way, but will throw an AssertionError if anything seems off (except for a failure to close the application iterator, which - will be printed to stderr -- there's no way to raise an exception + will be printed to stderr -- there's no way to throw an exception at that point). """ diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Lib/xml/dom/minidom.py --- a/Lib/xml/dom/minidom.py Sat Jul 19 16:34:33 2014 -0700 +++ b/Lib/xml/dom/minidom.py Sun Jul 20 10:52:46 2014 -0400 @@ -1,6 +1,5 @@ -"""Simple implementation of the Level 1 DOM. - -Namespaces and other minor Level 2 features are also supported. +"""\ +minidom.py -- a lightweight DOM implementation. parse("foo.xml") @@ -358,6 +357,9 @@ def _get_localName(self): return self.nodeName.split(":", 1)[-1] + def _get_name(self): + return self.name + def _get_specified(self): return self.specified diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Lib/xml/etree/ElementInclude.py --- a/Lib/xml/etree/ElementInclude.py Sat Jul 19 16:34:33 2014 -0700 +++ b/Lib/xml/etree/ElementInclude.py Sun Jul 20 10:52:46 2014 -0400 @@ -75,13 +75,14 @@ # @throws IOError If the loader fails to load the resource. def default_loader(href, parse, encoding=None): - with open(href) as file: - if parse == "xml": - data = ElementTree.parse(file).getroot() - else: - data = file.read() - if encoding: - data = data.decode(encoding) + file = open(href) + if parse == "xml": + data = ElementTree.parse(file).getroot() + else: + data = file.read() + if encoding: + data = data.decode(encoding) + file.close() return data ## diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Lib/xml/etree/ElementTree.py --- a/Lib/xml/etree/ElementTree.py Sat Jul 19 16:34:33 2014 -0700 +++ b/Lib/xml/etree/ElementTree.py Sun Jul 20 10:52:46 2014 -0400 @@ -683,8 +683,8 @@ return list(self.iter(tag)) ## - # Same as getroot().find(path), starting at the root of the - # tree. + # Finds the first toplevel element with given tag. + # Same as getroot().find(path). # # @param path What element to look for. # @keyparam namespaces Optional namespace prefix map. @@ -704,9 +704,10 @@ return self._root.find(path, namespaces) ## - # Same as getroot().findtext(path), starting at the root of the tree. + # Finds the element text for the first toplevel element with given + # tag. Same as getroot().findtext(path). # - # @param path What element to look for. + # @param path What toplevel element to look for. # @param default What to return if the element was not found. # @keyparam namespaces Optional namespace prefix map. # @return The text content of the first matching element, or the @@ -728,7 +729,8 @@ return self._root.findtext(path, default, namespaces) ## - # Same as getroot().findall(path), starting at the root of the tree. + # Finds all toplevel elements with the given tag. + # Same as getroot().findall(path). # # @param path What element to look for. # @keyparam namespaces Optional namespace prefix map. @@ -777,12 +779,11 @@ # @param file A file name, or a file object opened for writing. # @param **options Options, given as keyword arguments. # @keyparam encoding Optional output encoding (default is US-ASCII). + # @keyparam method Optional output method ("xml", "html", "text" or + # "c14n"; default is "xml"). # @keyparam xml_declaration Controls if an XML declaration should # be added to the file. Use False for never, True for always, # None for only if not US-ASCII or UTF-8. None is default. - # @keyparam default_namespace Sets the default XML namespace (for "xmlns"). - # @keyparam method Optional output method ("xml", "html", "text" or - # "c14n"; default is "xml"). def write(self, file_or_filename, # keyword arguments @@ -944,7 +945,7 @@ write(_escape_cdata(elem.tail, encoding)) HTML_EMPTY = ("area", "base", "basefont", "br", "col", "frame", "hr", - "img", "input", "isindex", "link", "meta", "param") + "img", "input", "isindex", "link", "meta" "param") try: HTML_EMPTY = set(HTML_EMPTY) @@ -988,15 +989,15 @@ # FIXME: handle boolean attributes write(" %s=\"%s\"" % (qnames[k], v)) write(">") - ltag = tag.lower() + tag = tag.lower() if text: - if ltag == "script" or ltag == "style": + if tag == "script" or tag == "style": write(_encode(text, encoding)) else: write(_escape_cdata(text, encoding)) for e in elem: _serialize_html(write, e, encoding, qnames, None) - if ltag not in HTML_EMPTY: + if tag not in HTML_EMPTY: write("") if elem.tail: write(_escape_cdata(elem.tail, encoding)) diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Lib/xml/sax/_exceptions.py --- a/Lib/xml/sax/_exceptions.py Sat Jul 19 16:34:33 2014 -0700 +++ b/Lib/xml/sax/_exceptions.py Sun Jul 20 10:52:46 2014 -0400 @@ -12,7 +12,7 @@ the application: you can subclass it to provide additional functionality, or to add localization. Note that although you will receive a SAXException as the argument to the handlers in the - ErrorHandler interface, you are not actually required to raise + ErrorHandler interface, you are not actually required to throw the exception; instead, you can simply read the information in it.""" @@ -50,7 +50,7 @@ the original XML document. Note that although the application will receive a SAXParseException as the argument to the handlers in the ErrorHandler interface, the application is not actually required - to raise the exception; instead, it can simply read the + to throw the exception; instead, it can simply read the information in it and take a different action. Since this exception is a subclass of SAXException, it inherits @@ -62,7 +62,7 @@ self._locator = locator # We need to cache this stuff at construction time. - # If this exception is raised, the objects through which we must + # If this exception is thrown, the objects through which we must # traverse to get this information may be deleted by the time # it gets caught. self._systemId = self._locator.getSystemId() diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Lib/xml/sax/expatreader.py --- a/Lib/xml/sax/expatreader.py Sat Jul 19 16:34:33 2014 -0700 +++ b/Lib/xml/sax/expatreader.py Sun Jul 20 10:52:46 2014 -0400 @@ -108,10 +108,7 @@ def prepareParser(self, source): if source.getSystemId() is not None: - base = source.getSystemId() - if isinstance(base, unicode): - base = base.encode('utf-8') - self._parser.SetBase(base) + self._parser.SetBase(source.getSystemId()) # Redefined setContentHandler to allow changing handlers during parsing diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Lib/xml/sax/saxutils.py --- a/Lib/xml/sax/saxutils.py Sat Jul 19 16:34:33 2014 -0700 +++ b/Lib/xml/sax/saxutils.py Sun Jul 20 10:52:46 2014 -0400 @@ -4,8 +4,6 @@ """ import os, urlparse, urllib, types -import io -import sys import handler import xmlreader @@ -14,6 +12,15 @@ except AttributeError: _StringTypes = [types.StringType] +# See whether the xmlcharrefreplace error handler is +# supported +try: + from codecs import xmlcharrefreplace_errors + _error_handling = "xmlcharrefreplace" + del xmlcharrefreplace_errors +except ImportError: + _error_handling = "strict" + def __dict_replace(s, d): """Replace substrings of a string using a dictionary.""" for key, value in d.items(): @@ -74,50 +81,25 @@ return data -def _gettextwriter(out, encoding): - if out is None: - import sys - out = sys.stdout - - if isinstance(out, io.RawIOBase): - buffer = io.BufferedIOBase(out) - # Keep the original file open when the TextIOWrapper is - # destroyed - buffer.close = lambda: None - else: - # This is to handle passed objects that aren't in the - # IOBase hierarchy, but just have a write method - buffer = io.BufferedIOBase() - buffer.writable = lambda: True - buffer.write = out.write - try: - # TextIOWrapper uses this methods to determine - # if BOM (for UTF-16, etc) should be added - buffer.seekable = out.seekable - buffer.tell = out.tell - except AttributeError: - pass - # wrap a binary writer with TextIOWrapper - class UnbufferedTextIOWrapper(io.TextIOWrapper): - def write(self, s): - super(UnbufferedTextIOWrapper, self).write(s) - self.flush() - return UnbufferedTextIOWrapper(buffer, encoding=encoding, - errors='xmlcharrefreplace', - newline='\n') - class XMLGenerator(handler.ContentHandler): def __init__(self, out=None, encoding="iso-8859-1"): + if out is None: + import sys + out = sys.stdout handler.ContentHandler.__init__(self) - out = _gettextwriter(out, encoding) - self._write = out.write - self._flush = out.flush + self._out = out self._ns_contexts = [{}] # contains uri -> prefix dicts self._current_context = self._ns_contexts[-1] self._undeclared_ns_maps = [] self._encoding = encoding + def _write(self, text): + if isinstance(text, str): + self._out.write(text) + else: + self._out.write(text.encode(self._encoding, _error_handling)) + def _qname(self, name): """Builds a qualified name from a (ns_url, localname) pair""" if name[0]: @@ -138,12 +120,9 @@ # ContentHandler methods def startDocument(self): - self._write(u'\n' % + self._write('\n' % self._encoding) - def endDocument(self): - self._flush() - def startPrefixMapping(self, prefix, uri): self._ns_contexts.append(self._current_context.copy()) self._current_context[uri] = prefix @@ -154,43 +133,39 @@ del self._ns_contexts[-1] def startElement(self, name, attrs): - self._write(u'<' + name) + self._write('<' + name) for (name, value) in attrs.items(): - self._write(u' %s=%s' % (name, quoteattr(value))) - self._write(u'>') + self._write(' %s=%s' % (name, quoteattr(value))) + self._write('>') def endElement(self, name): - self._write(u'' % name) + self._write('' % name) def startElementNS(self, name, qname, attrs): - self._write(u'<' + self._qname(name)) + self._write('<' + self._qname(name)) for prefix, uri in self._undeclared_ns_maps: if prefix: - self._write(u' xmlns:%s="%s"' % (prefix, uri)) + self._out.write(' xmlns:%s="%s"' % (prefix, uri)) else: - self._write(u' xmlns="%s"' % uri) + self._out.write(' xmlns="%s"' % uri) self._undeclared_ns_maps = [] for (name, value) in attrs.items(): - self._write(u' %s=%s' % (self._qname(name), quoteattr(value))) - self._write(u'>') + self._write(' %s=%s' % (self._qname(name), quoteattr(value))) + self._write('>') def endElementNS(self, name, qname): - self._write(u'' % self._qname(name)) + self._write('' % self._qname(name)) def characters(self, content): - if not isinstance(content, unicode): - content = unicode(content, self._encoding) self._write(escape(content)) def ignorableWhitespace(self, content): - if not isinstance(content, unicode): - content = unicode(content, self._encoding) self._write(content) def processingInstruction(self, target, data): - self._write(u'' % (target, data)) + self._write('' % (target, data)) class XMLFilterBase(xmlreader.XMLReader): @@ -318,31 +293,14 @@ source.setSystemId(f.name) if source.getByteStream() is None: - try: - sysid = source.getSystemId() - basehead = os.path.dirname(os.path.normpath(base)) - encoding = sys.getfilesystemencoding() - if isinstance(sysid, unicode): - if not isinstance(basehead, unicode): - try: - basehead = basehead.decode(encoding) - except UnicodeDecodeError: - sysid = sysid.encode(encoding) - else: - if isinstance(basehead, unicode): - try: - sysid = sysid.decode(encoding) - except UnicodeDecodeError: - basehead = basehead.encode(encoding) - sysidfilename = os.path.join(basehead, sysid) - isfile = os.path.isfile(sysidfilename) - except UnicodeError: - isfile = False - if isfile: + sysid = source.getSystemId() + basehead = os.path.dirname(os.path.normpath(base)) + sysidfilename = os.path.join(basehead, sysid) + if os.path.isfile(sysidfilename): source.setSystemId(sysidfilename) f = open(sysidfilename, "rb") else: - source.setSystemId(urlparse.urljoin(base, source.getSystemId())) + source.setSystemId(urlparse.urljoin(base, sysid)) f = urllib.urlopen(source.getSystemId()) source.setByteStream(f) diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Lib/xml/sax/xmlreader.py --- a/Lib/xml/sax/xmlreader.py Sat Jul 19 16:34:33 2014 -0700 +++ b/Lib/xml/sax/xmlreader.py Sun Jul 20 10:52:46 2014 -0400 @@ -68,7 +68,7 @@ SAX parsers are not required to provide localization for errors and warnings; if they cannot support the requested locale, - however, they must raise a SAX exception. Applications may + however, they must throw a SAX exception. Applications may request a locale change in the middle of a parse.""" raise SAXNotSupportedException("Locale support not implemented") diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Lib/xmlrpclib.py --- a/Lib/xmlrpclib.py Sat Jul 19 16:34:33 2014 -0700 +++ b/Lib/xmlrpclib.py Sun Jul 20 10:52:46 2014 -0400 @@ -945,7 +945,7 @@ class MultiCallIterator: """Iterates over the results of a multicall. Exceptions are - raised in response to xmlrpc faults.""" + thrown in response to xmlrpc faults.""" def __init__(self, results): self.results = results @@ -1617,14 +1617,21 @@ if __name__ == "__main__": - server = ServerProxy("http://localhost:8000") + # simple test program (from the XML-RPC specification) + + # server = ServerProxy("http://localhost:8000") # local server + server = ServerProxy("http://time.xmlrpc.com/RPC2") print server + try: + print server.currentTime.getCurrentTime() + except Error, v: + print "ERROR", v + multi = MultiCall(server) - multi.pow(2, 9) - multi.add(5, 1) - multi.add(24, 11) + multi.currentTime.getCurrentTime() + multi.currentTime.getCurrentTime() try: for response in multi(): print response diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Lib/zipfile.py --- a/Lib/zipfile.py Sat Jul 19 16:34:33 2014 -0700 +++ b/Lib/zipfile.py Sun Jul 20 10:52:46 2014 -0400 @@ -5,7 +5,6 @@ import binascii, cStringIO, stat import io import re -import string try: import zlib # We may need its compression method @@ -167,8 +166,6 @@ return endrec data = fpin.read(sizeEndCentDir64Locator) - if len(data) != sizeEndCentDir64Locator: - return endrec sig, diskno, reloff, disks = struct.unpack(structEndArchive64Locator, data) if sig != stringEndArchive64Locator: return endrec @@ -179,8 +176,6 @@ # Assume no 'zip64 extensible data' fpin.seek(offset - sizeEndCentDir64Locator - sizeEndCentDir64, 2) data = fpin.read(sizeEndCentDir64) - if len(data) != sizeEndCentDir64: - return endrec sig, sz, create_version, read_version, disk_num, disk_dir, \ dircount, dircount2, dirsize, diroffset = \ struct.unpack(structEndArchive64, data) @@ -216,9 +211,7 @@ except IOError: return None data = fpin.read() - if (len(data) == sizeEndCentDir and - data[0:4] == stringEndArchive and - data[-2:] == b"\000\000"): + if data[0:4] == stringEndArchive and data[-2:] == "\000\000": # the signature is correct and there's no comment, unpack structure endrec = struct.unpack(structEndArchive, data) endrec=list(endrec) @@ -242,9 +235,6 @@ if start >= 0: # found the magic number; attempt to unpack and interpret recData = data[start:start+sizeEndCentDir] - if len(recData) != sizeEndCentDir: - # Zip file is corrupted. - return None endrec = list(struct.unpack(structEndArchive, recData)) commentSize = endrec[_ECD_COMMENT_SIZE] #as claimed by the zip file comment = data[start+sizeEndCentDir:start+sizeEndCentDir+commentSize] @@ -256,7 +246,7 @@ endrec) # Unable to find a valid end of central directory structure - return None + return class ZipInfo (object): @@ -326,7 +316,7 @@ # compress_size Size of the compressed file # file_size Size of the uncompressed file - def FileHeader(self, zip64=None): + def FileHeader(self): """Return the per-file header as a string.""" dt = self.date_time dosdate = (dt[0] - 1980) << 9 | dt[1] << 5 | dt[2] @@ -341,17 +331,12 @@ extra = self.extra - if zip64 is None: - zip64 = file_size > ZIP64_LIMIT or compress_size > ZIP64_LIMIT - if zip64: + if file_size > ZIP64_LIMIT or compress_size > ZIP64_LIMIT: + # File is larger than what fits into a 4 byte integer, + # fall back to the ZIP64 extension fmt = ' ZIP64_LIMIT or compress_size > ZIP64_LIMIT: - if not zip64: - raise LargeZipFile("Filesize would require ZIP64 extensions") - # File is larger than what fits into a 4 byte integer, - # fall back to the ZIP64 extension file_size = 0xffffffff compress_size = 0xffffffff self.extract_version = max(45, self.extract_version) @@ -384,7 +369,7 @@ # Try to decode the extra field. extra = self.extra unpack = struct.unpack - while len(extra) >= 4: + while extra: tp, ln = unpack('= 24: @@ -476,28 +461,6 @@ self._UpdateKeys(c) return c - -compressor_names = { - 0: 'store', - 1: 'shrink', - 2: 'reduce', - 3: 'reduce', - 4: 'reduce', - 5: 'reduce', - 6: 'implode', - 7: 'tokenize', - 8: 'deflate', - 9: 'deflate64', - 10: 'implode', - 12: 'bzip2', - 14: 'lzma', - 18: 'terse', - 19: 'lz77', - 97: 'wavpack', - 98: 'ppmd', -} - - class ZipExtFile(io.BufferedIOBase): """File-like object for reading an archive member. Is returned by ZipFile.open(). @@ -512,11 +475,9 @@ # Search for universal newlines or line chunks. PATTERN = re.compile(r'^(?P[^\r\n]+)|(?P\n|\r\n?)') - def __init__(self, fileobj, mode, zipinfo, decrypter=None, - close_fileobj=False): + def __init__(self, fileobj, mode, zipinfo, decrypter=None): self._fileobj = fileobj self._decrypter = decrypter - self._close_fileobj = close_fileobj self._compress_type = zipinfo.compress_type self._compress_size = zipinfo.compress_size @@ -524,12 +485,6 @@ if self._compress_type == ZIP_DEFLATED: self._decompressor = zlib.decompressobj(-15) - elif self._compress_type != ZIP_STORED: - descr = compressor_names.get(self._compress_type) - if descr: - raise NotImplementedError("compression type %d (%s)" % (self._compress_type, descr)) - else: - raise NotImplementedError("compression type %d" % (self._compress_type,)) self._unconsumed = '' self._readbuffer = '' @@ -606,11 +561,7 @@ """Returns buffered bytes without advancing the position.""" if n > len(self._readbuffer) - self._offset: chunk = self.read(n) - if len(chunk) > self._offset: - self._readbuffer = chunk + self._readbuffer[self._offset:] - self._offset = 0 - else: - self._offset -= len(chunk) + self._offset -= len(chunk) # Return up to 512 bytes to reduce allocation overhead for tight loops. return self._readbuffer[self._offset: self._offset + 512] @@ -698,15 +649,9 @@ self._offset += len(data) return data - def close(self): - try : - if self._close_fileobj: - self._fileobj.close() - finally: - super(ZipExtFile, self).close() -class ZipFile(object): +class ZipFile: """ Class with methods to open, read, write, close, list zip files. z = ZipFile(file, mode="r", compression=ZIP_STORED, allowZip64=False) @@ -745,7 +690,7 @@ self.compression = compression # Method of compression self.mode = key = mode.replace('b', '')[0] self.pwd = None - self._comment = '' + self.comment = '' # Check if we were passed a file-like object if isinstance(file, basestring): @@ -765,34 +710,30 @@ self.fp = file self.filename = getattr(file, 'name', None) - try: - if key == 'r': + if key == 'r': + self._GetContents() + elif key == 'w': + # set the modified flag so central directory gets written + # even if no files are added to the archive + self._didModify = True + elif key == 'a': + try: + # See if file is a zip file self._RealGetContents() - elif key == 'w': + # seek to start of directory and overwrite + self.fp.seek(self.start_dir, 0) + except BadZipfile: + # file is not a zip file, just append + self.fp.seek(0, 2) + # set the modified flag so central directory gets written # even if no files are added to the archive self._didModify = True - elif key == 'a': - try: - # See if file is a zip file - self._RealGetContents() - # seek to start of directory and overwrite - self.fp.seek(self.start_dir, 0) - except BadZipfile: - # file is not a zip file, just append - self.fp.seek(0, 2) - - # set the modified flag so central directory gets written - # even if no files are added to the archive - self._didModify = True - else: - raise RuntimeError('Mode must be "r", "w" or "a"') - except: - fp = self.fp - self.fp = None + else: if not self._filePassed: - fp.close() - raise + self.fp.close() + self.fp = None + raise RuntimeError, 'Mode must be "r", "w" or "a"' def __enter__(self): return self @@ -800,6 +741,17 @@ def __exit__(self, type, value, traceback): self.close() + def _GetContents(self): + """Read the directory, making sure we close the file if the format + is bad.""" + try: + self._RealGetContents() + except BadZipfile: + if not self._filePassed: + self.fp.close() + self.fp = None + raise + def _RealGetContents(self): """Read in the table of contents for the ZIP file.""" fp = self.fp @@ -813,7 +765,7 @@ print endrec size_cd = endrec[_ECD_SIZE] # bytes in central directory offset_cd = endrec[_ECD_OFFSET] # offset of central directory - self._comment = endrec[_ECD_COMMENT] # archive comment + self.comment = endrec[_ECD_COMMENT] # archive comment # "concat" is zero, unless zip was concatenated to another file concat = endrec[_ECD_LOCATION] - size_cd - offset_cd @@ -832,11 +784,9 @@ total = 0 while total < size_cd: centdir = fp.read(sizeCentralDir) - if len(centdir) != sizeCentralDir: - raise BadZipfile("Truncated central directory") + if centdir[0:4] != stringCentralDir: + raise BadZipfile, "Bad magic number for central directory" centdir = struct.unpack(structCentralDir, centdir) - if centdir[_CD_SIGNATURE] != stringCentralDir: - raise BadZipfile("Bad magic number for central directory") if self.debug > 2: print centdir filename = fp.read(centdir[_CD_FILENAME_LENGTH]) @@ -895,9 +845,9 @@ try: # Read by chunks, to avoid an OverflowError or a # MemoryError with very large embedded files. - with self.open(zinfo.filename, "r") as f: - while f.read(chunk_size): # Check CRC-32 - pass + f = self.open(zinfo.filename, "r") + while f.read(chunk_size): # Check CRC-32 + pass except BadZipfile: return zinfo.filename @@ -914,22 +864,6 @@ """Set default password for encrypted files.""" self.pwd = pwd - @property - def comment(self): - """The comment text associated with the ZIP file.""" - return self._comment - - @comment.setter - def comment(self, comment): - # check for valid comment length - if len(comment) > ZIP_MAX_COMMENT: - import warnings - warnings.warn('Archive comment is too long; truncating to %d bytes' - % ZIP_MAX_COMMENT, stacklevel=2) - comment = comment[:ZIP_MAX_COMMENT] - self._comment = comment - self._didModify = True - def read(self, name, pwd=None): """Return file bytes (as a string) for name.""" return self.open(name, "r", pwd).read() @@ -946,72 +880,62 @@ # given a file object in the constructor if self._filePassed: zef_file = self.fp - should_close = False else: zef_file = open(self.filename, 'rb') - should_close = True - try: - # Make sure we have an info object - if isinstance(name, ZipInfo): - # 'name' is already an info object - zinfo = name + # Make sure we have an info object + if isinstance(name, ZipInfo): + # 'name' is already an info object + zinfo = name + else: + # Get info object for name + zinfo = self.getinfo(name) + + zef_file.seek(zinfo.header_offset, 0) + + # Skip the file header: + fheader = zef_file.read(sizeFileHeader) + if fheader[0:4] != stringFileHeader: + raise BadZipfile, "Bad magic number for file header" + + fheader = struct.unpack(structFileHeader, fheader) + fname = zef_file.read(fheader[_FH_FILENAME_LENGTH]) + if fheader[_FH_EXTRA_FIELD_LENGTH]: + zef_file.read(fheader[_FH_EXTRA_FIELD_LENGTH]) + + if fname != zinfo.orig_filename: + raise BadZipfile, \ + 'File name in directory "%s" and header "%s" differ.' % ( + zinfo.orig_filename, fname) + + # check for encrypted flag & handle password + is_encrypted = zinfo.flag_bits & 0x1 + zd = None + if is_encrypted: + if not pwd: + pwd = self.pwd + if not pwd: + raise RuntimeError, "File %s is encrypted, " \ + "password required for extraction" % name + + zd = _ZipDecrypter(pwd) + # The first 12 bytes in the cypher stream is an encryption header + # used to strengthen the algorithm. The first 11 bytes are + # completely random, while the 12th contains the MSB of the CRC, + # or the MSB of the file time depending on the header type + # and is used to check the correctness of the password. + bytes = zef_file.read(12) + h = map(zd, bytes[0:12]) + if zinfo.flag_bits & 0x8: + # compare against the file type from extended local headers + check_byte = (zinfo._raw_time >> 8) & 0xff else: - # Get info object for name - zinfo = self.getinfo(name) + # compare against the CRC otherwise + check_byte = (zinfo.CRC >> 24) & 0xff + if ord(h[11]) != check_byte: + raise RuntimeError("Bad password for file", name) - zef_file.seek(zinfo.header_offset, 0) - - # Skip the file header: - fheader = zef_file.read(sizeFileHeader) - if len(fheader) != sizeFileHeader: - raise BadZipfile("Truncated file header") - fheader = struct.unpack(structFileHeader, fheader) - if fheader[_FH_SIGNATURE] != stringFileHeader: - raise BadZipfile("Bad magic number for file header") - - fname = zef_file.read(fheader[_FH_FILENAME_LENGTH]) - if fheader[_FH_EXTRA_FIELD_LENGTH]: - zef_file.read(fheader[_FH_EXTRA_FIELD_LENGTH]) - - if fname != zinfo.orig_filename: - raise BadZipfile, \ - 'File name in directory "%s" and header "%s" differ.' % ( - zinfo.orig_filename, fname) - - # check for encrypted flag & handle password - is_encrypted = zinfo.flag_bits & 0x1 - zd = None - if is_encrypted: - if not pwd: - pwd = self.pwd - if not pwd: - raise RuntimeError, "File %s is encrypted, " \ - "password required for extraction" % name - - zd = _ZipDecrypter(pwd) - # The first 12 bytes in the cypher stream is an encryption header - # used to strengthen the algorithm. The first 11 bytes are - # completely random, while the 12th contains the MSB of the CRC, - # or the MSB of the file time depending on the header type - # and is used to check the correctness of the password. - bytes = zef_file.read(12) - h = map(zd, bytes[0:12]) - if zinfo.flag_bits & 0x8: - # compare against the file type from extended local headers - check_byte = (zinfo._raw_time >> 8) & 0xff - else: - # compare against the CRC otherwise - check_byte = (zinfo.CRC >> 24) & 0xff - if ord(h[11]) != check_byte: - raise RuntimeError("Bad password for file", name) - - return ZipExtFile(zef_file, mode, zinfo, zd, - close_fileobj=should_close) - except: - if should_close: - zef_file.close() - raise + return ZipExtFile(zef_file, mode, zinfo, zd) def extract(self, member, path=None, pwd=None): """Extract a member from the archive to the current working directory, @@ -1045,28 +969,17 @@ """ # build the destination pathname, replacing # forward slashes to platform specific separators. - arcname = member.filename.replace('/', os.path.sep) + # Strip trailing path separator, unless it represents the root. + if (targetpath[-1:] in (os.path.sep, os.path.altsep) + and len(os.path.splitdrive(targetpath)[1]) > 1): + targetpath = targetpath[:-1] - if os.path.altsep: - arcname = arcname.replace(os.path.altsep, os.path.sep) - # interpret absolute pathname as relative, remove drive letter or - # UNC path, redundant separators, "." and ".." components. - arcname = os.path.splitdrive(arcname)[1] - arcname = os.path.sep.join(x for x in arcname.split(os.path.sep) - if x not in ('', os.path.curdir, os.path.pardir)) - if os.path.sep == '\\': - # filter illegal characters on Windows - illegal = ':<>|"?*' - if isinstance(arcname, unicode): - table = {ord(c): ord('_') for c in illegal} - else: - table = string.maketrans(illegal, '_' * len(illegal)) - arcname = arcname.translate(table) - # remove trailing dots - arcname = (x.rstrip('.') for x in arcname.split(os.path.sep)) - arcname = os.path.sep.join(x for x in arcname if x) + # don't include leading "/" from file name if present + if member.filename[0] == '/': + targetpath = os.path.join(targetpath, member.filename[1:]) + else: + targetpath = os.path.join(targetpath, member.filename) - targetpath = os.path.join(targetpath, arcname) targetpath = os.path.normpath(targetpath) # Create all upper directories if necessary. @@ -1079,17 +992,19 @@ os.mkdir(targetpath) return targetpath - with self.open(member, pwd=pwd) as source, \ - file(targetpath, "wb") as target: - shutil.copyfileobj(source, target) + source = self.open(member, pwd=pwd) + target = file(targetpath, "wb") + shutil.copyfileobj(source, target) + source.close() + target.close() return targetpath def _writecheck(self, zinfo): """Check for errors before writing a file to the archive.""" if zinfo.filename in self.NameToInfo: - import warnings - warnings.warn('Duplicate name: %r' % zinfo.filename, stacklevel=3) + if self.debug: # Warning for duplicate names + print "Duplicate name:", zinfo.filename if self.mode not in ("w", "a"): raise RuntimeError, 'write() requires mode "w" or "a"' if not self.fp: @@ -1147,23 +1062,20 @@ zinfo.CRC = 0 self.filelist.append(zinfo) self.NameToInfo[zinfo.filename] = zinfo - self.fp.write(zinfo.FileHeader(False)) + self.fp.write(zinfo.FileHeader()) return with open(filename, "rb") as fp: # Must overwrite CRC and sizes with correct data later zinfo.CRC = CRC = 0 zinfo.compress_size = compress_size = 0 - # Compressed size can be larger than uncompressed size - zip64 = self._allowZip64 and \ - zinfo.file_size * 1.05 > ZIP64_LIMIT - self.fp.write(zinfo.FileHeader(zip64)) + zinfo.file_size = file_size = 0 + self.fp.write(zinfo.FileHeader()) if zinfo.compress_type == ZIP_DEFLATED: cmpr = zlib.compressobj(zlib.Z_DEFAULT_COMPRESSION, zlib.DEFLATED, -15) else: cmpr = None - file_size = 0 while 1: buf = fp.read(1024 * 8) if not buf: @@ -1183,16 +1095,11 @@ zinfo.compress_size = file_size zinfo.CRC = CRC zinfo.file_size = file_size - if not zip64 and self._allowZip64: - if file_size > ZIP64_LIMIT: - raise RuntimeError('File size has increased during compressing') - if compress_size > ZIP64_LIMIT: - raise RuntimeError('Compressed size larger than uncompressed size') - # Seek backwards and write file header (which will now include - # correct CRC and file sizes) + # Seek backwards and write CRC and file sizes position = self.fp.tell() # Preserve current position in file - self.fp.seek(zinfo.header_offset, 0) - self.fp.write(zinfo.FileHeader(zip64)) + self.fp.seek(zinfo.header_offset + 14, 0) + self.fp.write(struct.pack(" ZIP64_LIMIT or \ - zinfo.compress_size > ZIP64_LIMIT - if zip64 and not self._allowZip64: - raise LargeZipFile("Filesize would require ZIP64 extensions") - self.fp.write(zinfo.FileHeader(zip64)) + zinfo.header_offset = self.fp.tell() # Start of header bytes + self.fp.write(zinfo.FileHeader()) self.fp.write(bytes) + self.fp.flush() if zinfo.flag_bits & 0x08: # Write CRC and file sizes after the file data - fmt = ' ZIP64_LIMIT \ - or zinfo.compress_size > ZIP64_LIMIT: - extra.append(zinfo.file_size) - extra.append(zinfo.compress_size) - file_size = 0xffffffff - compress_size = 0xffffffff - else: - file_size = zinfo.file_size - compress_size = zinfo.compress_size + if self.mode in ("w", "a") and self._didModify: # write ending records + count = 0 + pos1 = self.fp.tell() + for zinfo in self.filelist: # write central directory + count = count + 1 + dt = zinfo.date_time + dosdate = (dt[0] - 1980) << 9 | dt[1] << 5 | dt[2] + dostime = dt[3] << 11 | dt[4] << 5 | (dt[5] // 2) + extra = [] + if zinfo.file_size > ZIP64_LIMIT \ + or zinfo.compress_size > ZIP64_LIMIT: + extra.append(zinfo.file_size) + extra.append(zinfo.compress_size) + file_size = 0xffffffff + compress_size = 0xffffffff + else: + file_size = zinfo.file_size + compress_size = zinfo.compress_size - if zinfo.header_offset > ZIP64_LIMIT: - extra.append(zinfo.header_offset) - header_offset = 0xffffffffL - else: - header_offset = zinfo.header_offset + if zinfo.header_offset > ZIP64_LIMIT: + extra.append(zinfo.header_offset) + header_offset = 0xffffffffL + else: + header_offset = zinfo.header_offset - extra_data = zinfo.extra - if extra: - # Append a ZIP64 field to the extra's - extra_data = struct.pack( - '>sys.stderr, (structCentralDir, - stringCentralDir, create_version, - zinfo.create_system, extract_version, zinfo.reserved, - zinfo.flag_bits, zinfo.compress_type, dostime, dosdate, - zinfo.CRC, compress_size, file_size, - len(zinfo.filename), len(extra_data), len(zinfo.comment), - 0, zinfo.internal_attr, zinfo.external_attr, - header_offset) - raise - self.fp.write(centdir) - self.fp.write(filename) - self.fp.write(extra_data) - self.fp.write(zinfo.comment) + try: + filename, flag_bits = zinfo._encodeFilenameFlags() + centdir = struct.pack(structCentralDir, + stringCentralDir, create_version, + zinfo.create_system, extract_version, zinfo.reserved, + flag_bits, zinfo.compress_type, dostime, dosdate, + zinfo.CRC, compress_size, file_size, + len(filename), len(extra_data), len(zinfo.comment), + 0, zinfo.internal_attr, zinfo.external_attr, + header_offset) + except DeprecationWarning: + print >>sys.stderr, (structCentralDir, + stringCentralDir, create_version, + zinfo.create_system, extract_version, zinfo.reserved, + zinfo.flag_bits, zinfo.compress_type, dostime, dosdate, + zinfo.CRC, compress_size, file_size, + len(zinfo.filename), len(extra_data), len(zinfo.comment), + 0, zinfo.internal_attr, zinfo.external_attr, + header_offset) + raise + self.fp.write(centdir) + self.fp.write(filename) + self.fp.write(extra_data) + self.fp.write(zinfo.comment) - pos2 = self.fp.tell() - # Write end-of-zip-archive record - centDirCount = count - centDirSize = pos2 - pos1 - centDirOffset = pos1 - if (centDirCount >= ZIP_FILECOUNT_LIMIT or - centDirOffset > ZIP64_LIMIT or - centDirSize > ZIP64_LIMIT): - # Need to write the ZIP64 end-of-archive records - zip64endrec = struct.pack( - structEndArchive64, stringEndArchive64, - 44, 45, 45, 0, 0, centDirCount, centDirCount, - centDirSize, centDirOffset) - self.fp.write(zip64endrec) + pos2 = self.fp.tell() + # Write end-of-zip-archive record + centDirCount = count + centDirSize = pos2 - pos1 + centDirOffset = pos1 + if (centDirCount >= ZIP_FILECOUNT_LIMIT or + centDirOffset > ZIP64_LIMIT or + centDirSize > ZIP64_LIMIT): + # Need to write the ZIP64 end-of-archive records + zip64endrec = struct.pack( + structEndArchive64, stringEndArchive64, + 44, 45, 45, 0, 0, centDirCount, centDirCount, + centDirSize, centDirOffset) + self.fp.write(zip64endrec) - zip64locrec = struct.pack( - structEndArchive64Locator, - stringEndArchive64Locator, 0, pos2, 1) - self.fp.write(zip64locrec) - centDirCount = min(centDirCount, 0xFFFF) - centDirSize = min(centDirSize, 0xFFFFFFFF) - centDirOffset = min(centDirOffset, 0xFFFFFFFF) + zip64locrec = struct.pack( + structEndArchive64Locator, + stringEndArchive64Locator, 0, pos2, 1) + self.fp.write(zip64locrec) + centDirCount = min(centDirCount, 0xFFFF) + centDirSize = min(centDirSize, 0xFFFFFFFF) + centDirOffset = min(centDirOffset, 0xFFFFFFFF) - endrec = struct.pack(structEndArchive, stringEndArchive, - 0, 0, centDirCount, centDirCount, - centDirSize, centDirOffset, len(self._comment)) - self.fp.write(endrec) - self.fp.write(self._comment) - self.fp.flush() - finally: - fp = self.fp - self.fp = None - if not self._filePassed: - fp.close() + # check for valid comment length + if len(self.comment) >= ZIP_MAX_COMMENT: + if self.debug > 0: + msg = 'Archive comment is too long; truncating to %d bytes' \ + % ZIP_MAX_COMMENT + self.comment = self.comment[:ZIP_MAX_COMMENT] + + endrec = struct.pack(structEndArchive, stringEndArchive, + 0, 0, centDirCount, centDirCount, + centDirSize, centDirOffset, len(self.comment)) + self.fp.write(endrec) + self.fp.write(self.comment) + self.fp.flush() + + if not self._filePassed: + self.fp.close() + self.fp = None class PyZipFile(ZipFile): @@ -1473,15 +1381,16 @@ if len(args) != 2: print USAGE sys.exit(1) - with ZipFile(args[1], 'r') as zf: - zf.printdir() + zf = ZipFile(args[1], 'r') + zf.printdir() + zf.close() elif args[0] == '-t': if len(args) != 2: print USAGE sys.exit(1) - with ZipFile(args[1], 'r') as zf: - badfile = zf.testzip() + zf = ZipFile(args[1], 'r') + badfile = zf.testzip() if badfile: print("The following enclosed file is corrupted: {!r}".format(badfile)) print "Done testing" @@ -1491,19 +1400,20 @@ print USAGE sys.exit(1) - with ZipFile(args[1], 'r') as zf: - out = args[2] - for path in zf.namelist(): - if path.startswith('./'): - tgt = os.path.join(out, path[2:]) - else: - tgt = os.path.join(out, path) + zf = ZipFile(args[1], 'r') + out = args[2] + for path in zf.namelist(): + if path.startswith('./'): + tgt = os.path.join(out, path[2:]) + else: + tgt = os.path.join(out, path) - tgtdir = os.path.dirname(tgt) - if not os.path.exists(tgtdir): - os.makedirs(tgtdir) - with open(tgt, 'wb') as fp: - fp.write(zf.read(path)) + tgtdir = os.path.dirname(tgt) + if not os.path.exists(tgtdir): + os.makedirs(tgtdir) + with open(tgt, 'wb') as fp: + fp.write(zf.read(path)) + zf.close() elif args[0] == '-c': if len(args) < 3: @@ -1519,9 +1429,11 @@ os.path.join(path, nm), os.path.join(zippath, nm)) # else: ignore - with ZipFile(args[1], 'w', allowZip64=True) as zf: - for src in args[2:]: - addToZip(zf, src, os.path.basename(src)) + zf = ZipFile(args[1], 'w', allowZip64=True) + for src in args[2:]: + addToZip(zf, src, os.path.basename(src)) + + zf.close() if __name__ == "__main__": main() diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Mac/BuildScript/README.txt --- a/Mac/BuildScript/README.txt Sat Jul 19 16:34:33 2014 -0700 +++ b/Mac/BuildScript/README.txt Sun Jul 20 10:52:46 2014 -0400 @@ -8,122 +8,70 @@ an Installer package from the installation plus other files in ``resources`` and ``scripts`` and placed that on a ``.dmg`` disk image. -For Python 2.7.x and 3.x, PSF practice is to build two installer variants -for each release. +As of Python 2.7.x and 3.2, PSF practice is to build two installer variants +for each release: -Beginning with Python 2.7.8, we plan to drop binary installer support for -Mac OS X 10.3.9 and 10.4.x systems. To ease the transition, for Python 2.7.7 -only there will be three installers provided: +1. 32-bit-only, i386 and PPC universal, capable on running on all machines + supported by Mac OS X 10.3.9 through (at least) 10.6:: -1. DEPRECATED - 32-bit-only, i386 and PPC universal, capable on running on all - machines supported by Mac OS X 10.3.9 through (at least) 10.9:: - - /usr/bin/python build-installer.py \ + python build-installer.py \ --sdk-path=/Developer/SDKs/MacOSX10.4u.sdk \ --universal-archs=32-bit \ --dep-target=10.3 + # These are the current default options - builds the following third-party libraries * Bzip2 + * Zlib 1.2.3 + * GNU Readline (GPL) + * SQLite 3 * NCurses - * GNU Readline (GPL) - * SQLite 3.7.13 - * Zlib 1.2.3 * Oracle Sleepycat DB 4.8 (Python 2.x only) - requires ActiveState ``Tcl/Tk 8.4`` (currently 8.4.19) to be installed for building - - recommended build environment: + - current target build environment: * Mac OS X 10.5.8 PPC or Intel - * Xcode 3.1.4 + * Xcode 3.1.4 (or later) * ``MacOSX10.4u`` SDK (later SDKs do not support PPC G3 processors) * ``MACOSX_DEPLOYMENT_TARGET=10.3`` * Apple ``gcc-4.0`` - * system Python 2.5 for documentation build with Sphinx + * Python 2.n (n >= 4) for documentation build with Sphinx - alternate build environments: - * Mac OS X 10.6.8 with Xcode 3.2.6 + * Mac OS X 10.4.11 with Xcode 2.5 + * Mac OS X 10.6.6 with Xcode 3.2.5 - need to change ``/System/Library/Frameworks/{Tcl,Tk}.framework/Version/Current`` to ``8.4`` - * Note Xcode 4.* does not support building for PPC so cannot be used for this build -2. 32-bit-only, i386 and PPC universal, capable on running on all machines - supported by Mac OS X 10.5 through (at least) 10.9:: +2. 64-bit / 32-bit, x86_64 and i386 universal, for OS X 10.6 (and later):: - /usr/bin/python build-installer.py \ - --sdk-path=/Developer/SDKs/MacOSX10.5.sdk \ - --universal-archs=32-bit \ - --dep-target=10.5 - - - builds the following third-party libraries - - * NCurses 5.9 - * SQLite 3.7.13 - * Oracle Sleepycat DB 4.8 (Python 2.x only) - - - uses system-supplied versions of third-party libraries - - * readline module links with Apple BSD editline (libedit) - - - requires ActiveState ``Tcl/Tk 8.4`` (currently 8.4.20) to be installed for building - - - recommended build environment: - - * Mac OS X 10.5.8 Intel or PPC - * Xcode 3.1.4 - * ``MacOSX10.5`` SDK - * ``MACOSX_DEPLOYMENT_TARGET=10.5`` - * Apple ``gcc-4.2`` - * system Python 2.5+ for documentation build with Sphinx - - - alternate build environments: - - * Mac OS X 10.6.8 with Xcode 3.2.6 - - need to change ``/System/Library/Frameworks/{Tcl,Tk}.framework/Version/Current`` to ``8.4`` - * Note Xcode 4.* does not support building for PPC so cannot be used for this build - -3. 64-bit / 32-bit, x86_64 and i386 universal, for OS X 10.6 (and later):: - - /usr/bin/python build-installer.py \ + python build-installer.py \ --sdk-path=/Developer/SDKs/MacOSX10.6.sdk \ --universal-archs=intel \ --dep-target=10.6 - - builds the following third-party libraries + - uses system-supplied versions of third-party libraries + + * readline module links with Apple BSD editline (libedit) + * builds Oracle Sleepycat DB 4.8 (Python 2.x only) - * NCurses 5.9 (http://bugs.python.org/issue15037) - * SQLite 3.7.13 - * Oracle Sleepycat DB 4.8 (Python 2.x only) + - requires ActiveState Tcl/Tk 8.5.9 (or later) to be installed for building - - uses system-supplied versions of third-party libraries - - * readline module links with Apple BSD editline (libedit) - - - requires ActiveState Tcl/Tk 8.5.15 (or later) to be installed for building - - - recommended build environment: - - * Mac OS X 10.6.8 (or later) - * Xcode 3.2.6 + - current target build environment: + + * Mac OS X 10.6.6 (or later) + * Xcode 3.2.5 (or later) * ``MacOSX10.6`` SDK * ``MACOSX_DEPLOYMENT_TARGET=10.6`` * Apple ``gcc-4.2`` - * system Python 2.6 for documentation build with Sphinx + * Python 2.n (n >= 4) for documentation build with Sphinx - alternate build environments: - * none. Xcode 4.x currently supplies two C compilers. - ``llvm-gcc-4.2.1`` has been found to miscompile Python 3.3.x and - produce a non-functional Python executable. As it appears to be - considered a migration aid by Apple and is not likely to be fixed, - its use should be avoided. The other compiler, ``clang``, has been - undergoing rapid development. While it appears to have become - production-ready in the most recent Xcode 5 releases, the versions - available on the deprecated Xcode 4.x for 10.6 were early releases - and did not receive the level of exposure in production environments - that the Xcode 3 gcc-4.2 compiler has had. + * none General Prerequisites @@ -139,11 +87,6 @@ * It is safest to start each variant build with an empty source directory populated with a fresh copy of the untarred source. -* It is recommended that you remove any existing installed version of the - Python being built:: - - sudo rm -rf /Library/Frameworks/Python.framework/Versions/n.n - The Recipe ---------- @@ -164,9 +107,9 @@ ................................... It is also possible to build a 4-way universal installer that runs on -OS X 10.5 Leopard or later:: +OS X Leopard or later:: - /usr/bin/python /build-installer.py \ + python 2.6 /build-installer.py \ --dep-target=10.5 --universal-archs=all --sdk-path=/Developer/SDKs/MacOSX10.5.sdk @@ -177,8 +120,7 @@ variants can only be run on G5 machines running 10.5. Note that, while OS X 10.6 is only supported on Intel-based machines, it is possible to run ``ppc`` (32-bit) executables unmodified thanks to the Rosetta ppc -emulation in OS X 10.5 and 10.6. The 4-way installer variant must be -built with Xcode 3. It is not regularly built or tested. +emulation in OS X 10.5 and 10.6. Other ``--universal-archs`` options are ``64-bit`` (``x86_64``, ``ppc64``), and ``3-way`` (``ppc``, ``i386``, ``x86_64``). None of these options @@ -191,21 +133,15 @@ Ideally, the resulting binaries should be installed and the test suite run on all supported OS X releases and architectures. As a practical matter, that is generally not possible. At a minimum, variant 1 should be run on -a PPC G4 system with OS X 10.5 and at least one Intel system running OS X -10.8, 10.7, 10.6, or 10.5. Variant 2 should be run on 10.8, 10.7, and 10.6 -systems in both 32-bit and 64-bit modes.:: +at least one Intel, one PPC G4, and one PPC G3 system and one each of +OS X 10.6, 10.5, 10.4, and 10.3.9. Not all tests run on 10.3.9. +Variant 2 should be run on 10.6 in both 32-bit and 64-bit modes.:: - /usr/local/bin/pythonn.n -m test -w -u all,-largefile - /usr/local/bin/pythonn.n-32 -m test -w -u all + arch -i386 /usr/local/bin/pythonn.n -m test.regrtest -w -u all + arch -X86_64 /usr/local/bin/pythonn.n -m test.regrtest -w -u all Certain tests will be skipped and some cause the interpreter to fail which will likely generate ``Python quit unexpectedly`` alert messages -to be generated at several points during a test run. These are normal -during testing and can be ignored. +to be generated at several points during a test run. These can +be ignored. -It is also recommend to launch IDLE and verify that it is at least -functional. Double-click on the IDLE app icon in ``/Applications/Pythonn.n``. -It should also be tested from the command line:: - - /usr/local/bin/idlen.n - diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Mac/BuildScript/build-installer.py --- a/Mac/BuildScript/build-installer.py Sat Jul 19 16:34:33 2014 -0700 +++ b/Mac/BuildScript/build-installer.py Sun Jul 20 10:52:46 2014 -0400 @@ -1,52 +1,27 @@ -#!/usr/bin/env python +#!/usr/bin/python """ This script is used to build "official" universal installers on Mac OS X. -It requires at least Mac OS X 10.5, Xcode 3, and the 10.4u SDK for +It requires at least Mac OS X 10.4, Xcode 2.2 and the 10.4u SDK for 32-bit builds. 64-bit or four-way universal builds require at least OS X 10.5 and the 10.5 SDK. Please ensure that this script keeps working with Python 2.5, to avoid bootstrap issues (/usr/bin/python is Python 2.5 on OSX 10.5). Sphinx, which is used to build the documentation, currently requires at least -Python 2.4. However, as of Python 3.4.1, Doc builds require an external -sphinx-build and the current versions of Sphinx now require at least -Python 2.6. - -In addition to what is supplied with OS X 10.5+ and Xcode 3+, the script -requires an installed version of hg and a third-party version of -Tcl/Tk 8.4 (for OS X 10.4 and 10.5 deployment targets) or Tcl/TK 8.5 -(for 10.6 or later) installed in /Library/Frameworks. When installed, -the Python built by this script will attempt to dynamically link first to -Tcl and Tk frameworks in /Library/Frameworks if available otherwise fall -back to the ones in /System/Library/Framework. For the build, we recommend -installing the most recent ActiveTcl 8.4 or 8.5 version. - -32-bit-only installer builds are still possible on OS X 10.4 with Xcode 2.5 -and the installation of additional components, such as a newer Python -(2.5 is needed for Python parser updates), hg, and for the documentation -build either svn (pre-3.4.1) or sphinx-build (3.4.1 and later). +Python 2.4. Usage: see USAGE variable in the script. """ -import platform, os, sys, getopt, textwrap, shutil, stat, time, pwd, grp -try: - import urllib2 as urllib_request -except ImportError: - import urllib.request as urllib_request - -STAT_0o755 = ( stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR - | stat.S_IRGRP | stat.S_IXGRP - | stat.S_IROTH | stat.S_IXOTH ) - -STAT_0o775 = ( stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR - | stat.S_IRGRP | stat.S_IWGRP | stat.S_IXGRP - | stat.S_IROTH | stat.S_IXOTH ) +import platform, os, sys, getopt, textwrap, shutil, urllib2, stat, time, pwd +import grp INCLUDE_TIMESTAMP = 1 VERBOSE = 1 from plistlib import Plist +import MacOS + try: from plistlib import writePlist except ImportError: @@ -67,35 +42,20 @@ if ln.startswith(variable): value = ln[len(variable):].strip() return value[1:-1] - raise RuntimeError("Cannot find variable %s" % variable[:-1]) - -_cache_getVersion = None + raise RuntimeError, "Cannot find variable %s" % variable[:-1] def getVersion(): - global _cache_getVersion - if _cache_getVersion is None: - _cache_getVersion = grepValue( - os.path.join(SRCDIR, 'configure'), 'PACKAGE_VERSION') - return _cache_getVersion + return grepValue(os.path.join(SRCDIR, 'configure'), 'PACKAGE_VERSION') def getVersionTuple(): return tuple([int(n) for n in getVersion().split('.')]) -def getVersionMajorMinor(): - return tuple([int(n) for n in getVersion().split('.', 2)]) - -_cache_getFullVersion = None - def getFullVersion(): - global _cache_getFullVersion - if _cache_getFullVersion is not None: - return _cache_getFullVersion fn = os.path.join(SRCDIR, 'Include', 'patchlevel.h') for ln in open(fn): if 'PY_VERSION' in ln: - _cache_getFullVersion = ln.split()[-1][1:-1] - return _cache_getFullVersion - raise RuntimeError("Cannot find full version??") + return ln.split()[-1][1:-1] + raise RuntimeError, "Cannot find full version??" # The directory we'll use to create the build (will be erased and recreated) WORKDIR = "/tmp/_py" @@ -110,7 +70,7 @@ ### There are some issues with the SDK selection below here, ### The resulting binary doesn't work on all platforms that ### it should. Always default to the 10.4u SDK until that -### issue is resolved. +### isue is resolved. ### ##if int(os.uname()[2].split('.')[0]) == 8: ## # Explicitly use the 10.4u (universal) SDK when @@ -150,19 +110,14 @@ # $MACOSX_DEPLOYMENT_TARGET -> minimum OS X level DEPTARGET = '10.3' -def getDeptargetTuple(): - return tuple([int(n) for n in DEPTARGET.split('.')[0:2]]) +target_cc_map = { + '10.3': 'gcc-4.0', + '10.4': 'gcc-4.0', + '10.5': 'gcc-4.0', + '10.6': 'gcc-4.2', +} -def getTargetCompilers(): - target_cc_map = { - '10.3': ('gcc-4.0', 'g++-4.0'), - '10.4': ('gcc-4.0', 'g++-4.0'), - '10.5': ('gcc-4.2', 'g++-4.2'), - '10.6': ('gcc-4.2', 'g++-4.2'), - } - return target_cc_map.get(DEPTARGET, ('clang', 'clang++') ) - -CC, CXX = getTargetCompilers() +CC = target_cc_map[DEPTARGET] PYTHON_3 = getVersionTuple() >= (3, 0) @@ -180,13 +135,6 @@ --universal-archs=x universal architectures (options: %(UNIVERSALOPTS)r, default: %(UNIVERSALARCHS)r) """)% globals() -# Dict of object file names with shared library names to check after building. -# This is to ensure that we ended up dynamically linking with the shared -# library paths and versions we expected. For example: -# EXPECTED_SHARED_LIBS['_tkinter.so'] = [ -# '/Library/Frameworks/Tcl.framework/Versions/8.5/Tcl', -# '/Library/Frameworks/Tk.framework/Versions/8.5/Tk'] -EXPECTED_SHARED_LIBS = {} # Instructions for building libraries that are necessary for building a # batteries included python. @@ -195,126 +143,15 @@ def library_recipes(): result = [] - LT_10_5 = bool(getDeptargetTuple() < (10, 5)) - -# Disable for now - if False: # if (getDeptargetTuple() > (10, 5)) and (getVersionTuple() >= (3, 5)): - result.extend([ - dict( - name="Tcl 8.5.15", - url="ftp://ftp.tcl.tk/pub/tcl//tcl8_5/tcl8.5.15-src.tar.gz", - checksum='f3df162f92c69b254079c4d0af7a690f', - buildDir="unix", - configure_pre=[ - '--enable-shared', - '--enable-threads', - '--libdir=/Library/Frameworks/Python.framework/Versions/%s/lib'%(getVersion(),), - ], - useLDFlags=False, - install='make TCL_LIBRARY=%(TCL_LIBRARY)s && make install TCL_LIBRARY=%(TCL_LIBRARY)s DESTDIR=%(DESTDIR)s'%{ - "DESTDIR": shellQuote(os.path.join(WORKDIR, 'libraries')), - "TCL_LIBRARY": shellQuote('/Library/Frameworks/Python.framework/Versions/%s/lib/tcl8.5'%(getVersion())), - }, - ), - dict( - name="Tk 8.5.15", - url="ftp://ftp.tcl.tk/pub/tcl//tcl8_5/tk8.5.15-src.tar.gz", - checksum='55b8e33f903210a4e1c8bce0f820657f', - patches=[ - "issue19373_tk_8_5_15_source.patch", - ], - buildDir="unix", - configure_pre=[ - '--enable-aqua', - '--enable-shared', - '--enable-threads', - '--libdir=/Library/Frameworks/Python.framework/Versions/%s/lib'%(getVersion(),), - ], - useLDFlags=False, - install='make TCL_LIBRARY=%(TCL_LIBRARY)s TK_LIBRARY=%(TK_LIBRARY)s && make install TCL_LIBRARY=%(TCL_LIBRARY)s TK_LIBRARY=%(TK_LIBRARY)s DESTDIR=%(DESTDIR)s'%{ - "DESTDIR": shellQuote(os.path.join(WORKDIR, 'libraries')), - "TCL_LIBRARY": shellQuote('/Library/Frameworks/Python.framework/Versions/%s/lib/tcl8.5'%(getVersion())), - "TK_LIBRARY": shellQuote('/Library/Frameworks/Python.framework/Versions/%s/lib/tk8.5'%(getVersion())), - }, - ), - ]) - - if getVersionTuple() >= (3, 3): - result.extend([ - dict( - name="XZ 5.0.5", - url="http://tukaani.org/xz/xz-5.0.5.tar.gz", - checksum='19d924e066b6fff0bc9d1981b4e53196', - configure_pre=[ - '--disable-dependency-tracking', - ] - ), - ]) - - result.extend([ - dict( - name="NCurses 5.9", - url="http://ftp.gnu.org/pub/gnu/ncurses/ncurses-5.9.tar.gz", - checksum='8cb9c412e5f2d96bc6f459aa8c6282a1', - configure_pre=[ - "--enable-widec", - "--without-cxx", - "--without-cxx-binding", - "--without-ada", - "--without-curses-h", - "--enable-shared", - "--with-shared", - "--without-debug", - "--without-normal", - "--without-tests", - "--without-manpages", - "--datadir=/usr/share", - "--sysconfdir=/etc", - "--sharedstatedir=/usr/com", - "--with-terminfo-dirs=/usr/share/terminfo", - "--with-default-terminfo-dir=/usr/share/terminfo", - "--libdir=/Library/Frameworks/Python.framework/Versions/%s/lib"%(getVersion(),), - ], - patchscripts=[ - ("ftp://invisible-island.net/ncurses//5.9/ncurses-5.9-20120616-patch.sh.bz2", - "f54bf02a349f96a7c4f0d00922f3a0d4"), - ], - useLDFlags=False, - install='make && make install DESTDIR=%s && cd %s/usr/local/lib && ln -fs ../../../Library/Frameworks/Python.framework/Versions/%s/lib/lib* .'%( - shellQuote(os.path.join(WORKDIR, 'libraries')), - shellQuote(os.path.join(WORKDIR, 'libraries')), - getVersion(), - ), - ), - dict( - name="SQLite 3.8.3.1", - url="http://www.sqlite.org/2014/sqlite-autoconf-3080301.tar.gz", - checksum='509ff98d8dc9729b618b7e96612079c6', - extra_cflags=('-Os ' - '-DSQLITE_ENABLE_FTS4 ' - '-DSQLITE_ENABLE_FTS3_PARENTHESIS ' - '-DSQLITE_ENABLE_RTREE ' - '-DSQLITE_TCL=0 ' - '%s' % ('','-DSQLITE_WITHOUT_ZONEMALLOC ')[LT_10_5]), - configure_pre=[ - '--enable-threadsafe', - '--enable-shared=no', - '--enable-static=yes', - '--disable-readline', - '--disable-dependency-tracking', - ] - ), - ]) - - if getDeptargetTuple() < (10, 5): + if DEPTARGET < '10.5': result.extend([ dict( name="Bzip2 1.0.6", url="http://bzip.org/1.0.6/bzip2-1.0.6.tar.gz", checksum='00b516f4704d4a7cb50a1d97e6e8e15b', configure=None, - install='make install CC=%s CXX=%s, PREFIX=%s/usr/local/ CFLAGS="-arch %s -isysroot %s"'%( - CC, CXX, + install='make install CC=%s PREFIX=%s/usr/local/ CFLAGS="-arch %s -isysroot %s"'%( + CC, shellQuote(os.path.join(WORKDIR, 'libraries')), ' -arch '.join(ARCHLIST), SDKPATH, @@ -325,8 +162,8 @@ url="http://www.gzip.org/zlib/zlib-1.2.3.tar.gz", checksum='debc62758716a169df9f62e6ab2bc634', configure=None, - install='make install CC=%s CXX=%s, prefix=%s/usr/local/ CFLAGS="-arch %s -isysroot %s"'%( - CC, CXX, + install='make install CC=%s prefix=%s/usr/local/ CFLAGS="-arch %s -isysroot %s"'%( + CC, shellQuote(os.path.join(WORKDIR, 'libraries')), ' -arch '.join(ARCHLIST), SDKPATH, @@ -341,12 +178,58 @@ patches=[ # The readline maintainers don't do actual micro releases, but # just ship a set of patches. - ('http://ftp.gnu.org/pub/gnu/readline/readline-6.1-patches/readline61-001', - 'c642f2e84d820884b0bf9fd176bc6c3f'), - ('http://ftp.gnu.org/pub/gnu/readline/readline-6.1-patches/readline61-002', - '1a76781a1ea734e831588285db7ec9b1'), + 'http://ftp.gnu.org/pub/gnu/readline/readline-6.1-patches/readline61-001', + 'http://ftp.gnu.org/pub/gnu/readline/readline-6.1-patches/readline61-002', ] ), + dict( + name="SQLite 3.7.4", + url="http://www.sqlite.org/sqlite-autoconf-3070400.tar.gz", + checksum='8f0c690bfb33c3cbbc2471c3d9ba0158', + configure_env=('CFLAGS="-Os' + ' -DSQLITE_ENABLE_FTS3' + ' -DSQLITE_ENABLE_FTS3_PARENTHESIS' + ' -DSQLITE_ENABLE_RTREE' + ' -DSQLITE_TCL=0' + '"'), + configure_pre=[ + '--enable-threadsafe', + '--enable-shared=no', + '--enable-static=yes', + '--disable-readline', + '--disable-dependency-tracking', + ] + ), + dict( + name="NCurses 5.5", + url="http://ftp.gnu.org/pub/gnu/ncurses/ncurses-5.5.tar.gz", + checksum='e73c1ac10b4bfc46db43b2ddfd6244ef', + configure_pre=[ + "--enable-widec", + "--without-cxx", + "--without-ada", + "--without-progs", + "--without-curses-h", + "--enable-shared", + "--with-shared", + "--datadir=/usr/share", + "--sysconfdir=/etc", + "--sharedstatedir=/usr/com", + "--with-terminfo-dirs=/usr/share/terminfo", + "--with-default-terminfo-dir=/usr/share/terminfo", + "--libdir=/Library/Frameworks/Python.framework/Versions/%s/lib"%(getVersion(),), + "--enable-termcap", + ], + patches=[ + "ncurses-5.5.patch", + ], + useLDFlags=False, + install='make && make install DESTDIR=%s && cd %s/usr/local/lib && ln -fs ../../../Library/Frameworks/Python.framework/Versions/%s/lib/lib* .'%( + shellQuote(os.path.join(WORKDIR, 'libraries')), + shellQuote(os.path.join(WORKDIR, 'libraries')), + getVersion(), + ), + ), ]) if not PYTHON_3: @@ -369,8 +252,6 @@ # Instructions for building packages inside the .mpkg. def pkg_recipes(): unselected_for_python3 = ('selected', 'unselected')[PYTHON_3] - # unselected if 3.0 through 3.3, selected otherwise (2.x or >= 3.4) - unselected_for_lt_python34 = ('selected', 'unselected')[(3, 0) <= getVersionTuple() < (3, 4)] result = [ dict( name="PythonFramework", @@ -417,7 +298,9 @@ source="/pydocs", readme="""\ This package installs the python documentation at a location - that is useable for pydoc and IDLE. + that is useable for pydoc and IDLE. If you have installed Xcode + it will also install a link to the documentation in + /Developer/Documentation/Python """, postflight="scripts/postflight.documentation", required=False, @@ -439,28 +322,11 @@ topdir="/Library/Frameworks/Python.framework", source="/empty-dir", required=False, - selected=unselected_for_lt_python34, + selected=unselected_for_python3, ), ] - if getVersionTuple() >= (3, 4): - result.append( - dict( - name="PythonInstallPip", - long_name="Install or upgrade pip", - readme="""\ - This package installs (or upgrades from an earlier version) - pip, a tool for installing and managing Python packages. - """, - postflight="scripts/postflight.ensurepip", - topdir="/Library/Frameworks/Python.framework", - source="/empty-dir", - required=False, - selected='selected', - ) - ) - - if getDeptargetTuple() < (10, 4) and not PYTHON_3: + if DEPTARGET < '10.4': result.append( dict( name="PythonSystemFixes", @@ -477,7 +343,6 @@ selected=unselected_for_python3, ) ) - return result def fatal(msg): @@ -493,7 +358,7 @@ """ Return the contents of the named file """ - return open(fn, 'r').read() + return open(fn, 'rb').read() def runCommand(commandline): """ @@ -505,7 +370,7 @@ xit = fd.close() if xit is not None: sys.stdout.write(data) - raise RuntimeError("command failed: %s"%(commandline,)) + raise RuntimeError, "command failed: %s"%(commandline,) if VERBOSE: sys.stdout.write(data); sys.stdout.flush() @@ -516,7 +381,7 @@ xit = fd.close() if xit is not None: sys.stdout.write(data) - raise RuntimeError("command failed: %s"%(commandline,)) + raise RuntimeError, "command failed: %s"%(commandline,) return data @@ -558,72 +423,47 @@ # Because we only support dynamic load of only one major/minor version of # Tcl/Tk, ensure: # 1. there are no user-installed frameworks of Tcl/Tk with version - # higher than the Apple-supplied system version in - # SDKROOT/System/Library/Frameworks - # 2. there is a user-installed framework (usually ActiveTcl) in (or linked - # in) SDKROOT/Library/Frameworks with the same version as the system - # version. This allows users to choose to install a newer patch level. + # higher than the Apple-supplied system version + # 2. there is a user-installed framework in /Library/Frameworks with the + # same version as the system version. This allows users to choose + # to install a newer patch level. - frameworks = {} for framework in ['Tcl', 'Tk']: - fwpth = 'Library/Frameworks/%s.framework/Versions/Current' % framework + #fw = dict(lower=framework.lower(), + # upper=framework.upper(), + # cap=framework.capitalize()) + #fwpth = "Library/Frameworks/%(cap)s.framework/%(lower)sConfig.sh" % fw + fwpth = 'Library/Frameworks/Tcl.framework/Versions/Current' sysfw = os.path.join(SDKPATH, 'System', fwpth) - libfw = os.path.join(SDKPATH, fwpth) + libfw = os.path.join('/', fwpth) usrfw = os.path.join(os.getenv('HOME'), fwpth) - frameworks[framework] = os.readlink(sysfw) - if not os.path.exists(libfw): - fatal("Please install a link to a current %s %s as %s so " - "the user can override the system framework." - % (framework, frameworks[framework], libfw)) + #version = "%(upper)s_VERSION" % fw if os.readlink(libfw) != os.readlink(sysfw): fatal("Version of %s must match %s" % (libfw, sysfw) ) if os.path.exists(usrfw): fatal("Please rename %s to avoid possible dynamic load issues." % usrfw) - if frameworks['Tcl'] != frameworks['Tk']: - fatal("The Tcl and Tk frameworks are not the same version.") - - # add files to check after build - EXPECTED_SHARED_LIBS['_tkinter.so'] = [ - "/Library/Frameworks/Tcl.framework/Versions/%s/Tcl" - % frameworks['Tcl'], - "/Library/Frameworks/Tk.framework/Versions/%s/Tk" - % frameworks['Tk'], - ] - # Remove inherited environment variables which might influence build environ_var_prefixes = ['CPATH', 'C_INCLUDE_', 'DYLD_', 'LANG', 'LC_', 'LD_', 'LIBRARY_', 'PATH', 'PYTHON'] for ev in list(os.environ): for prefix in environ_var_prefixes: if ev.startswith(prefix) : - print("INFO: deleting environment variable %s=%s" % ( - ev, os.environ[ev])) + print "INFO: deleting environment variable %s=%s" % ( + ev, os.environ[ev]) del os.environ[ev] - base_path = '/bin:/sbin:/usr/bin:/usr/sbin' - if 'SDK_TOOLS_BIN' in os.environ: - base_path = os.environ['SDK_TOOLS_BIN'] + ':' + base_path - # Xcode 2.5 on OS X 10.4 does not include SetFile in its usr/bin; - # add its fixed location here if it exists - OLD_DEVELOPER_TOOLS = '/Developer/Tools' - if os.path.isdir(OLD_DEVELOPER_TOOLS): - base_path = base_path + ':' + OLD_DEVELOPER_TOOLS - os.environ['PATH'] = base_path - print("Setting default PATH: %s"%(os.environ['PATH'])) - # Ensure ws have access to hg and to sphinx-build. - # You may have to create links in /usr/bin for them. - runCommand('hg --version') - if getVersionTuple() >= (3, 4): - runCommand('sphinx-build --version') + os.environ['PATH'] = '/bin:/sbin:/usr/bin:/usr/sbin' + print "Setting default PATH: %s"%(os.environ['PATH']) + def parseOptions(args=None): """ Parse arguments and update global settings. """ global WORKDIR, DEPSRC, SDKPATH, SRCDIR, DEPTARGET - global UNIVERSALOPTS, UNIVERSALARCHS, ARCHLIST, CC, CXX + global UNIVERSALOPTS, UNIVERSALARCHS, ARCHLIST, CC if args is None: args = sys.argv[1:] @@ -632,18 +472,18 @@ options, args = getopt.getopt(args, '?hb', [ 'build-dir=', 'third-party=', 'sdk-path=' , 'src-dir=', 'dep-target=', 'universal-archs=', 'help' ]) - except getopt.GetoptError: - print(sys.exc_info()[1]) + except getopt.error, msg: + print msg sys.exit(1) if args: - print("Additional arguments") + print "Additional arguments" sys.exit(1) deptarget = None for k, v in options: if k in ('-h', '-?', '--help'): - print(USAGE) + print USAGE sys.exit(0) elif k in ('-d', '--build-dir'): @@ -671,28 +511,27 @@ # target DEPTARGET = default_target_map.get(v, '10.3') else: - raise NotImplementedError(v) + raise NotImplementedError, v else: - raise NotImplementedError(k) + raise NotImplementedError, k SRCDIR=os.path.abspath(SRCDIR) WORKDIR=os.path.abspath(WORKDIR) SDKPATH=os.path.abspath(SDKPATH) DEPSRC=os.path.abspath(DEPSRC) - CC, CXX = getTargetCompilers() + CC=target_cc_map[DEPTARGET] - print("Settings:") - print(" * Source directory:", SRCDIR) - print(" * Build directory: ", WORKDIR) - print(" * SDK location: ", SDKPATH) - print(" * Third-party source:", DEPSRC) - print(" * Deployment target:", DEPTARGET) - print(" * Universal architectures:", ARCHLIST) - print(" * C compiler:", CC) - print(" * C++ compiler:", CXX) - print("") + print "Settings:" + print " * Source directory:", SRCDIR + print " * Build directory: ", WORKDIR + print " * SDK location: ", SDKPATH + print " * Third-party source:", DEPSRC + print " * Deployment target:", DEPTARGET + print " * Universal architectures:", ARCHLIST + print " * C compiler:", CC + print "" @@ -704,19 +543,13 @@ XXX: This function assumes that archives contain a toplevel directory that is has the same name as the basename of the archive. This is - safe enough for almost anything we use. Unfortunately, it does not - work for current Tcl and Tk source releases where the basename of - the archive ends with "-src" but the uncompressed directory does not. - For now, just special case Tcl and Tk tar.gz downloads. + save enough for anything we use. """ curdir = os.getcwd() try: os.chdir(builddir) if archiveName.endswith('.tar.gz'): retval = os.path.basename(archiveName[:-7]) - if ((retval.startswith('tcl') or retval.startswith('tk')) - and retval.endswith('-src')): - retval = retval[:-4] if os.path.exists(retval): shutil.rmtree(retval) fp = os.popen("tar zxf %s 2>&1"%(shellQuote(archiveName),), 'r') @@ -743,18 +576,31 @@ xit = fp.close() if xit is not None: sys.stdout.write(data) - raise RuntimeError("Cannot extract %s"%(archiveName,)) + raise RuntimeError, "Cannot extract %s"%(archiveName,) return os.path.join(builddir, retval) finally: os.chdir(curdir) +KNOWNSIZES = { + "http://ftp.gnu.org/pub/gnu/readline/readline-5.1.tar.gz": 7952742, + "http://downloads.sleepycat.com/db-4.4.20.tar.gz": 2030276, +} + def downloadURL(url, fname): """ Download the contents of the url into the file. """ - fpIn = urllib_request.urlopen(url) + try: + size = os.path.getsize(fname) + except OSError: + pass + else: + if KNOWNSIZES.get(url) == size: + print "Using existing file for", url + return + fpIn = urllib2.urlopen(url) fpOut = open(fname, 'wb') block = fpIn.read(10240) try: @@ -769,24 +615,6 @@ except: pass -def verifyThirdPartyFile(url, checksum, fname): - """ - Download file from url to filename fname if it does not already exist. - Abort if file contents does not match supplied md5 checksum. - """ - name = os.path.basename(fname) - if os.path.exists(fname): - print("Using local copy of %s"%(name,)) - else: - print("Did not find local copy of %s"%(name,)) - print("Downloading %s"%(name,)) - downloadURL(url, fname) - print("Archive for %s stored as %s"%(name, fname)) - if os.system( - 'MD5=$(openssl md5 %s) ; test "${MD5##*= }" = "%s"' - % (shellQuote(fname), checksum) ): - fatal('MD5 checksum mismatch for file %s' % fname) - def buildRecipe(recipe, basedir, archList): """ Build software using a recipe. This function does the @@ -807,43 +635,38 @@ if not os.path.exists(DEPSRC): os.mkdir(DEPSRC) - verifyThirdPartyFile(url, recipe['checksum'], sourceArchive) - print("Extracting archive for %s"%(name,)) + + if os.path.exists(sourceArchive): + print "Using local copy of %s"%(name,) + + else: + print "Did not find local copy of %s"%(name,) + print "Downloading %s"%(name,) + downloadURL(url, sourceArchive) + print "Archive for %s stored as %s"%(name, sourceArchive) + + print "Extracting archive for %s"%(name,) buildDir=os.path.join(WORKDIR, '_bld') if not os.path.exists(buildDir): os.mkdir(buildDir) workDir = extractArchive(buildDir, sourceArchive) os.chdir(workDir) + if 'buildDir' in recipe: + os.chdir(recipe['buildDir']) - for patch in recipe.get('patches', ()): - if isinstance(patch, tuple): - url, checksum = patch - fn = os.path.join(DEPSRC, os.path.basename(url)) - verifyThirdPartyFile(url, checksum, fn) - else: - # patch is a file in the source directory - fn = os.path.join(curdir, patch) + + for fn in recipe.get('patches', ()): + if fn.startswith('http://'): + # Download the patch before applying it. + path = os.path.join(DEPSRC, os.path.basename(fn)) + downloadURL(fn, path) + fn = path + + fn = os.path.join(curdir, fn) runCommand('patch -p%s < %s'%(recipe.get('patchlevel', 1), shellQuote(fn),)) - for patchscript in recipe.get('patchscripts', ()): - if isinstance(patchscript, tuple): - url, checksum = patchscript - fn = os.path.join(DEPSRC, os.path.basename(url)) - verifyThirdPartyFile(url, checksum, fn) - else: - # patch is a file in the source directory - fn = os.path.join(curdir, patchscript) - if fn.endswith('.bz2'): - runCommand('bunzip2 -fk %s' % shellQuote(fn)) - fn = fn[:-4] - runCommand('sh %s' % shellQuote(fn)) - os.unlink(fn) - - if 'buildDir' in recipe: - os.chdir(recipe['buildDir']) - if configure is not None: configure_args = [ "--prefix=/usr/local", @@ -862,44 +685,40 @@ if recipe.get('useLDFlags', 1): configure_args.extend([ - "CFLAGS=%s-mmacosx-version-min=%s -arch %s -isysroot %s " - "-I%s/usr/local/include"%( - recipe.get('extra_cflags', ''), - DEPTARGET, + "CFLAGS=-arch %s -isysroot %s -I%s/usr/local/include"%( ' -arch '.join(archList), shellQuote(SDKPATH)[1:-1], shellQuote(basedir)[1:-1],), - "LDFLAGS=-mmacosx-version-min=%s -isysroot %s -L%s/usr/local/lib -arch %s"%( - DEPTARGET, + "LDFLAGS=-syslibroot,%s -L%s/usr/local/lib -arch %s"%( shellQuote(SDKPATH)[1:-1], shellQuote(basedir)[1:-1], ' -arch '.join(archList)), ]) else: configure_args.extend([ - "CFLAGS=%s-mmacosx-version-min=%s -arch %s -isysroot %s " - "-I%s/usr/local/include"%( - recipe.get('extra_cflags', ''), - DEPTARGET, + "CFLAGS=-arch %s -isysroot %s -I%s/usr/local/include"%( ' -arch '.join(archList), shellQuote(SDKPATH)[1:-1], shellQuote(basedir)[1:-1],), ]) if 'configure_post' in recipe: - configure_args = configure_args + list(recipe['configure_post']) + configure_args = configure_args = list(recipe['configure_post']) configure_args.insert(0, configure) configure_args = [ shellQuote(a) for a in configure_args ] - print("Running configure for %s"%(name,)) + if 'configure_env' in recipe: + configure_args.insert(0, recipe['configure_env']) + + print "Running configure for %s"%(name,) runCommand(' '.join(configure_args) + ' 2>&1') - print("Running install for %s"%(name,)) + print "Running install for %s"%(name,) runCommand('{ ' + install + ' ;} 2>&1') - print("Done %s"%(name,)) - print("") + print "Done %s"%(name,) + print "" os.chdir(curdir) @@ -907,9 +726,9 @@ """ Build our dependencies into $WORKDIR/libraries/usr/local """ - print("") - print("Building required libraries") - print("") + print "" + print "Building required libraries" + print "" universal = os.path.join(WORKDIR, 'libraries') os.mkdir(universal) os.makedirs(os.path.join(universal, 'usr', 'local', 'lib')) @@ -923,21 +742,14 @@ def buildPythonDocs(): # This stores the documentation as Resources/English.lproj/Documentation # inside the framwork. pydoc and IDLE will pick it up there. - print("Install python documentation") + print "Install python documentation" rootDir = os.path.join(WORKDIR, '_root') buildDir = os.path.join('../../Doc') docdir = os.path.join(rootDir, 'pydocs') curDir = os.getcwd() os.chdir(buildDir) - # The Doc build changed for 3.4 (technically, for 3.4.1) - if getVersionTuple() < (3, 4): - # This step does an svn checkout of sphinx and its dependencies - runCommand('make update') - runCommand("make html PYTHON='%s'" % os.path.abspath(sys.executable)) - else: - runCommand('make clean') - # Assume sphinx-build is on our PATH, checked in checkEnvironment - runCommand('make html') + runCommand('make update') + runCommand("make html PYTHON='%s'" % os.path.abspath(sys.executable)) os.chdir(curDir) if not os.path.exists(docdir): os.mkdir(docdir) @@ -945,7 +757,7 @@ def buildPython(): - print("Building a universal python for %s architectures" % UNIVERSALARCHS) + print "Building a universal python for %s architectures" % UNIVERSALARCHS buildDir = os.path.join(WORKDIR, '_bld', 'python') rootDir = os.path.join(WORKDIR, '_root') @@ -973,36 +785,31 @@ # will find them during its extension import sanity checks. os.environ['DYLD_LIBRARY_PATH'] = os.path.join(WORKDIR, 'libraries', 'usr', 'local', 'lib') - print("Running configure...") + print "Running configure..." runCommand("%s -C --enable-framework --enable-universalsdk=%s " "--with-universal-archs=%s " "%s " - "%s " "LDFLAGS='-g -L%s/libraries/usr/local/lib' " - "CFLAGS='-g -I%s/libraries/usr/local/include' 2>&1"%( + "OPT='-g -O3 -I%s/libraries/usr/local/include' 2>&1"%( shellQuote(os.path.join(SRCDIR, 'configure')), shellQuote(SDKPATH), UNIVERSALARCHS, (' ', '--with-computed-gotos ')[PYTHON_3], - (' ', '--without-ensurepip ')[getVersionTuple() >= (3, 4)], shellQuote(WORKDIR)[1:-1], shellQuote(WORKDIR)[1:-1])) - print("Running make touch") - runCommand("make touch") - - print("Running make") + print "Running make" runCommand("make") - print("Running make install") + print "Running make install" runCommand("make install DESTDIR=%s"%( shellQuote(rootDir))) - print("Running make frameworkinstallextras") + print "Running make frameworkinstallextras" runCommand("make frameworkinstallextras DESTDIR=%s"%( shellQuote(rootDir))) del os.environ['DYLD_LIBRARY_PATH'] - print("Copying required shared libraries") + print "Copying required shared libraries" if os.path.exists(os.path.join(WORKDIR, 'libraries', 'Library')): runCommand("mv %s/* %s"%( shellQuote(os.path.join( @@ -1013,20 +820,16 @@ 'Python.framework', 'Versions', getVersion(), 'lib')))) - path_to_lib = os.path.join(rootDir, 'Library', 'Frameworks', - 'Python.framework', 'Versions', - version, 'lib', 'python%s'%(version,)) - - print("Fix file modes") + print "Fix file modes" frmDir = os.path.join(rootDir, 'Library', 'Frameworks', 'Python.framework') gid = grp.getgrnam('admin').gr_gid - shared_lib_error = False for dirpath, dirnames, filenames in os.walk(frmDir): for dn in dirnames: - os.chmod(os.path.join(dirpath, dn), STAT_0o775) + os.chmod(os.path.join(dirpath, dn), 0775) os.chown(os.path.join(dirpath, dn), -1, gid) + for fn in filenames: if os.path.islink(fn): continue @@ -1037,19 +840,6 @@ os.chmod(p, stat.S_IMODE(st.st_mode) | stat.S_IWGRP) os.chown(p, -1, gid) - if fn in EXPECTED_SHARED_LIBS: - # check to see that this file was linked with the - # expected library path and version - data = captureCommand("otool -L %s" % shellQuote(p)) - for sl in EXPECTED_SHARED_LIBS[fn]: - if ("\t%s " % sl) not in data: - print("Expected shared lib %s was not linked with %s" - % (sl, p)) - shared_lib_error = True - - if shared_lib_error: - fatal("Unexpected shared library errors.") - if PYTHON_3: LDVERSION=None VERSION=None @@ -1073,63 +863,20 @@ # We added some directories to the search path during the configure # phase. Remove those because those directories won't be there on - # the end-users system. Also remove the directories from _sysconfigdata.py - # (added in 3.3) if it exists. - - include_path = '-I%s/libraries/usr/local/include' % (WORKDIR,) - lib_path = '-L%s/libraries/usr/local/lib' % (WORKDIR,) - - # fix Makefile - path = os.path.join(path_to_lib, 'config' + config_suffix, 'Makefile') + # the end-users system. + path =os.path.join(rootDir, 'Library', 'Frameworks', 'Python.framework', + 'Versions', version, 'lib', 'python%s'%(version,), + 'config' + config_suffix, 'Makefile') fp = open(path, 'r') data = fp.read() fp.close() - for p in (include_path, lib_path): - data = data.replace(" " + p, '') - data = data.replace(p + " ", '') - + data = data.replace('-L%s/libraries/usr/local/lib'%(WORKDIR,), '') + data = data.replace('-I%s/libraries/usr/local/include'%(WORKDIR,), '') fp = open(path, 'w') fp.write(data) fp.close() - # fix _sysconfigdata if it exists - # - # TODO: make this more robust! test_sysconfig_module of - # distutils.tests.test_sysconfig.SysconfigTestCase tests that - # the output from get_config_var in both sysconfig and - # distutils.sysconfig is exactly the same for both CFLAGS and - # LDFLAGS. The fixing up is now complicated by the pretty - # printing in _sysconfigdata.py. Also, we are using the - # pprint from the Python running the installer build which - # may not cosmetically format the same as the pprint in the Python - # being built (and which is used to originally generate - # _sysconfigdata.py). - - import pprint - path = os.path.join(path_to_lib, '_sysconfigdata.py') - if os.path.exists(path): - fp = open(path, 'r') - data = fp.read() - fp.close() - # create build_time_vars dict - exec(data) - vars = {} - for k, v in build_time_vars.items(): - if type(v) == type(''): - for p in (include_path, lib_path): - v = v.replace(' ' + p, '') - v = v.replace(p + ' ', '') - vars[k] = v - - fp = open(path, 'w') - # duplicated from sysconfig._generate_posix_vars() - fp.write('# system configuration generated and used by' - ' the sysconfig module\n') - fp.write('build_time_vars = ') - pprint.pprint(vars, stream=fp) - fp.close() - # Add symlinks in /usr/local/bin, using relative links usr_local_bin = os.path.join(rootDir, 'usr', 'local', 'bin') to_framework = os.path.join('..', '..', '..', 'Library', 'Frameworks', @@ -1145,7 +892,7 @@ os.chdir(curdir) if PYTHON_3: - # Remove the 'Current' link, that way we don't accidentally mess + # Remove the 'Current' link, that way we don't accidently mess # with an already installed version of python 2 os.unlink(os.path.join(rootDir, 'Library', 'Frameworks', 'Python.framework', 'Versions', 'Current')) @@ -1160,17 +907,17 @@ # This one is not handy as a template variable data = data.replace('$PYTHONFRAMEWORKINSTALLDIR', '/Library/Frameworks/Python.framework') - fp = open(outPath, 'w') + fp = open(outPath, 'wb') fp.write(data) fp.close() def patchScript(inPath, outPath): data = fileContents(inPath) data = data.replace('@PYVER@', getVersion()) - fp = open(outPath, 'w') + fp = open(outPath, 'wb') fp.write(data) fp.close() - os.chmod(outPath, STAT_0o755) + os.chmod(outPath, 0755) @@ -1187,7 +934,7 @@ readme = textwrap.dedent(recipe['readme']) isRequired = recipe.get('required', True) - print("- building package %s"%(pkgname,)) + print "- building package %s"%(pkgname,) # Substitute some variables textvars = dict( @@ -1232,7 +979,7 @@ patchScript(postflight, os.path.join(rsrcDir, 'postflight')) vers = getFullVersion() - major, minor = getVersionMajorMinor() + major, minor = map(int, getVersion().split('.', 2)) pl = Plist( CFBundleGetInfoString="Python.%s %s"%(pkgname, vers,), CFBundleIdentifier='org.python.Python.%s'%(pkgname,), @@ -1269,7 +1016,7 @@ def makeMpkgPlist(path): vers = getFullVersion() - major, minor = getVersionMajorMinor() + major, minor = map(int, getVersion().split('.', 2)) pl = Plist( CFBundleGetInfoString="Python %s"%(vers,), @@ -1380,7 +1127,7 @@ # Custom icon for the DMG, shown when the DMG is mounted. shutil.copy("../Icons/Disk Image.icns", os.path.join(WORKDIR, "mnt", volname, ".VolumeIcon.icns")) - runCommand("SetFile -a C %s/"%( + runCommand("/Developer/Tools/SetFile -a C %s/"%( shellQuote(os.path.join(WORKDIR, "mnt", volname)),)) runCommand("hdiutil detach %s"%(shellQuote(os.path.join(WORKDIR, "mnt", volname)))) @@ -1421,7 +1168,6 @@ os.environ['MACOSX_DEPLOYMENT_TARGET'] = DEPTARGET os.environ['CC'] = CC - os.environ['CXX'] = CXX if os.path.exists(WORKDIR): shutil.rmtree(WORKDIR) @@ -1452,7 +1198,7 @@ folder = os.path.join(WORKDIR, "_root", "Applications", "Python %s"%( getVersion(),)) - os.chmod(folder, STAT_0o755) + os.chmod(folder, 0755) setIcon(folder, "../Icons/Python Folder.icns") # Create the installer @@ -1465,9 +1211,9 @@ shutil.copy('../../LICENSE', os.path.join(WORKDIR, 'installer', 'License.txt')) fp = open(os.path.join(WORKDIR, 'installer', 'Build.txt'), 'w') - fp.write("# BUILD INFO\n") - fp.write("# Date: %s\n" % time.ctime()) - fp.write("# By: %s\n" % pwd.getpwuid(os.getuid()).pw_gecos) + print >> fp, "# BUILD INFO" + print >> fp, "# Date:", time.ctime() + print >> fp, "# By:", pwd.getpwuid(os.getuid()).pw_gecos fp.close() # And copy it to a DMG diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Mac/BuildScript/issue19373_tk_8_5_15_source.patch --- a/Mac/BuildScript/issue19373_tk_8_5_15_source.patch Sat Jul 19 16:34:33 2014 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,13 +0,0 @@ -Issue #19373: Patch to Tk 8.5.15 to correct refresh problem on OS x 10.9. -From upstream checkin https://core.tcl.tk/tk/info/5a5abf71f9 - ---- tk8.5.15/macosx/tkMacOSXDraw.c 2013-09-16 09:41:21.000000000 -0700 -+++ Tk_Source_Code-5a5abf71f9fdb0da/macosx/tkMacOSXDraw.c 2013-10-27 13:27:00.000000000 -0700 -@@ -1688,6 +1688,7 @@ - { - if (dcPtr->context) { - CGContextSynchronize(dcPtr->context); -+ [[dcPtr->view window] setViewsNeedDisplay:YES]; - [[dcPtr->view window] enableFlushWindow]; - if (dcPtr->focusLocked) { - [dcPtr->view unlockFocus]; diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Mac/BuildScript/ncurses-5.5.patch --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Mac/BuildScript/ncurses-5.5.patch Sun Jul 20 10:52:46 2014 -0400 @@ -0,0 +1,36 @@ +diff -r -u ncurses-5.5-orig/test/Makefile.in ncurses-5.5/test/Makefile.in +--- ncurses-5.5-orig/test/Makefile.in 2006-03-24 12:47:40.000000000 +0100 ++++ ncurses-5.5/test/Makefile.in 2006-03-24 12:47:50.000000000 +0100 +@@ -75,7 +75,7 @@ + MATH_LIB = @MATH_LIB@ + + LD = @LD@ +-LINK = @LINK_TESTS@ $(LIBTOOL_LINK) $(CC) $(CFLAGS) ++LINK = @LINK_TESTS@ $(LIBTOOL_LINK) $(CC) + + usFLAGS = @LD_MODEL@ @LOCAL_LDFLAGS@ @LDFLAGS@ + +diff -ru ncurses-5.5-orig/ncurses/tinfo/read_entry.c ncurses-5.5/ncurses/tinfo/read_entry.c +--- ncurses-5.5-orig/ncurses/tinfo/read_entry.c 2004-01-11 02:57:05.000000000 +0100 ++++ ncurses-5.5/ncurses/tinfo/read_entry.c 2006-03-25 22:49:39.000000000 +0100 +@@ -474,7 +474,7 @@ + } + + /* truncate the terminal name to prevent buffer overflow */ +- (void) sprintf(ttn, "%c/%.*s", *tn, (int) sizeof(ttn) - 3, tn); ++ (void) sprintf(ttn, "%x/%.*s", *tn, (int) sizeof(ttn) - 3, tn); + + /* This is System V behavior, in conjunction with our requirements for + * writing terminfo entries. +diff -ru ncurses-5.5-orig/configure ncurses-5.5/configure +--- ncurses-5.5-orig/configure 2005-09-24 23:50:50.000000000 +0200 ++++ ncurses-5.5/configure 2006-03-26 22:24:59.000000000 +0200 +@@ -5027,7 +5027,7 @@ + darwin*) + EXTRA_CFLAGS="-no-cpp-precomp" + CC_SHARED_OPTS="-dynamic" +- MK_SHARED_LIB='$(CC) -dynamiclib -install_name $(DESTDIR)$(libdir)/`basename $@` -compatibility_version $(ABI_VERSION) -current_version $(ABI_VERSION) -o $@' ++ MK_SHARED_LIB='$(CC) $(CFLAGS) -dynamiclib -install_name $(DESTDIR)$(libdir)/`basename $@` -compatibility_version $(ABI_VERSION) -current_version $(ABI_VERSION) -o $@' + test "$cf_cv_shlib_version" = auto && cf_cv_shlib_version=abi + cf_cv_shlib_version_infix=yes + ;; diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Mac/BuildScript/resources/ReadMe.txt --- a/Mac/BuildScript/resources/ReadMe.txt Sat Jul 19 16:34:33 2014 -0700 +++ b/Mac/BuildScript/resources/ReadMe.txt Sun Jul 20 10:52:46 2014 -0400 @@ -2,61 +2,11 @@ $MACOSX_DEPLOYMENT_TARGET for the following architecture(s): $ARCHITECTURES. - **** IMPORTANT **** +Installation requires approximately $INSTALL_SIZE MB of disk space, +ignore the message that it will take zero bytes. -Installing on OS X 10.8 (Mountain Lion) or later systems -======================================================== - -If you are attempting to install on an OS X 10.8+ system, you may -see a message that Python can't be installed because it is from an -unidentified developer. This is because this Python installer -package is not yet compatible with the Gatekeeper security feature -introduced in OS X 10.8. To allow Python to be installed, you -can override the Gatekeeper policy for this install. In the Finder, -instead of double-clicking, control-click or right click the "Python" -installer package icon. Then select "Open using ... Installer" from -the contextual menu that appears. - - **** IMPORTANT **** - -Update your version of Tcl/Tk to use IDLE or other Tk applications -================================================================== - -To use IDLE or other programs that use the Tkinter graphical user -interface toolkit, you may need to install a newer third-party version -of the Tcl/Tk frameworks. Visit http://www.python.org/download/mac/tcltk/ -for current information about supported and recommended versions of -Tcl/Tk for this version of Python and of Mac OS X. - - **** IMPORTANT **** - -Binary installer support for 10.4 and 10.3.9 to be discontinued -=============================================================== - -Python 2.7.7 is the last release for which binary installers will be -released on python.org that support OS X 10.3.9 (Panther) and 10.4.x -(Tiger) systems. These systems were last updated by Apple in 2005 -and 2007. As of 2.7.8, the 32-bit-only installer will support PPC -and Intel Macs running OS X 10.5 (Leopard) and later. 10.5 was the -last OS X release for PPC machines (G4 and G5). (The 64-/32-bit -installer configuration will remain unchanged.) This aligns Python -2.7.x installer configurations with those currently provided with -Python 3.x. Some of the reasons for making this change are: -there were significant additions and compatibility improvements to -the OS X POSIX system APIs in OS X 10.5 that Python users can now -take advantage of; it is increasingly difficult to build and test -on obsolete 10.3 and 10.4 systems and with the 10.3 ABI; and it is -assumed that most remaining legacy PPC systems have upgraded to 10.5. -To ease the transition, for Python 2.7.7 only we are providing three -binary installers: (1) the legacy deprecated 32-bit-only 10.3+ -PPC/Intel format, (2) the newer 32-bit-only 10.5+ PPC/Intel format, -and (3) the current 64-bit/32-bit 10.6+ Intel-only format. While -future releases will not provide the deprecated installer, it will -still be possible to build Python from source on 10.3.9 and 10.4 -systems if needed. - -Using this version of Python on OS X -==================================== +You must install onto your current boot disk, even though the +installer does not enforce this, otherwise things will not work. Python consists of the Python programming language interpreter, plus a set of programs to allow easy access to it for Mac users including @@ -64,8 +14,17 @@ extension modules that open up specific Macintosh technologies to Python programs. + **** IMPORTANT **** + +Before using IDLE or other programs using the tkinter graphical user +interface toolkit, visit http://www.python.org/download/mac/tcltk/ +for current information about supported and recommended versions +of Tcl/Tk for this version of Python and Mac OS X. + + ******************* + The installer puts applications, an "Update Shell Profile" command, -and a link to the optionally installed Python Documentation into the +and an Extras folder containing demo programs and tools into the "Python $VERSION" subfolder of the system Applications folder, and puts the underlying machinery into the folder $PYTHONFRAMEWORKINSTALLDIR. It can @@ -73,16 +32,5 @@ well. Double-click on the "Update Shell Profile" command to add the "bin" directory inside the framework to your shell's search path. -You must install onto your current boot disk, even though the -installer may not enforce this, otherwise things will not work. - -You can verify the integrity of the disk image file containing the -installer package and this ReadMe file by comparing its md5 checksum -and size with the values published on the release page linked at -http://www.python.org/download/ - -Installation requires approximately $INSTALL_SIZE MB of disk space, -ignore the message that it will take zero bytes. - More information on Python in general can be found at http://www.python.org. diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Mac/BuildScript/resources/Welcome.rtf --- a/Mac/BuildScript/resources/Welcome.rtf Sat Jul 19 16:34:33 2014 -0700 +++ b/Mac/BuildScript/resources/Welcome.rtf Sun Jul 20 10:52:46 2014 -0400 @@ -1,8 +1,8 @@ -{\rtf1\ansi\ansicpg1252\cocoartf1265\cocoasubrtf200 -\cocoascreenfonts1{\fonttbl\f0\fswiss\fcharset0 Helvetica;} +{\rtf1\ansi\ansicpg1252\cocoartf1038\cocoasubrtf350 +{\fonttbl\f0\fswiss\fcharset0 Helvetica;} {\colortbl;\red255\green255\blue255;} -\paperw11905\paperh16837\margl1440\margr1440\vieww9640\viewh10620\viewkind0 -\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640 +\paperw11904\paperh16836\margl1440\margr1440\vieww9640\viewh10620\viewkind0 +\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\ql\qnatural \f0\fs24 \cf0 This package will install \b Python $FULL_VERSION @@ -16,7 +16,7 @@ \b IDLE \b0 and a set of pre-built extension modules that open up specific Macintosh technologies to Python programs.\ \ -See the ReadMe file and the Python documentation for important information, including the dropping of support for OS X 10.3.9 and 10.4 in future Python 2.7.x binary installers.\ +See the ReadMe file and the Python documentation for more information.\ \ \b IMPORTANT: diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Mac/BuildScript/scripts/postflight.documentation --- a/Mac/BuildScript/scripts/postflight.documentation Sat Jul 19 16:34:33 2014 -0700 +++ b/Mac/BuildScript/scripts/postflight.documentation Sun Jul 20 10:52:46 2014 -0400 @@ -5,10 +5,19 @@ FWK_DOCDIR_SUBPATH="Resources/English.lproj/Documentation" FWK_DOCDIR="${FWK}/${FWK_DOCDIR_SUBPATH}" APPDIR="/Applications/Python ${PYVER}" +DEV_DOCDIR="/Developer/Documentation" SHARE_DIR="${FWK}/share" SHARE_DOCDIR="${SHARE_DIR}/doc/python${PYVER}" SHARE_DOCDIR_TO_FWK="../../.." +# make link in /Developer/Documentation/ for Xcode users +if [ -d "${DEV_DOCDIR}" ]; then + if [ ! -d "${DEV_DOCDIR}/Python" ]; then + mkdir -p "${DEV_DOCDIR}/Python" + fi + ln -fhs "${FWK_DOCDIR}" "${DEV_DOCDIR}/Python/Reference Documentation ${PYVER}" +fi + # make link in /Applications/Python m.n/ for Finder users if [ -d "${APPDIR}" ]; then ln -fhs "${FWK_DOCDIR}/index.html" "${APPDIR}/Python Documentation.html" @@ -16,7 +25,7 @@ # make share/doc link in framework for command line users if [ -d "${SHARE_DIR}" ]; then - mkdir -m 775 -p "${SHARE_DOCDIR}" + mkdir -p "${SHARE_DOCDIR}" # make relative link to html doc directory ln -fhs "${SHARE_DOCDIR_TO_FWK}/${FWK_DOCDIR_SUBPATH}" "${SHARE_DOCDIR}/html" fi diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Mac/BuildScript/scripts/postflight.framework --- a/Mac/BuildScript/scripts/postflight.framework Sat Jul 19 16:34:33 2014 -0700 +++ b/Mac/BuildScript/scripts/postflight.framework Sun Jul 20 10:52:46 2014 -0400 @@ -8,24 +8,14 @@ "${FWK}/bin/python@PYVER@" -Wi -tt \ "${FWK}/lib/python${PYVER}/compileall.py" \ - -f -x 'bad_coding|badsyntax|site-packages|lib2to3/tests/data' \ + -x badsyntax -x site-packages \ "${FWK}/lib/python${PYVER}" "${FWK}/bin/python@PYVER@" -Wi -tt -O \ "${FWK}/lib/python${PYVER}/compileall.py" \ - -f -x 'bad_coding|badsyntax|site-packages|lib2to3/tests/data' \ + -x badsyntax -x site-packages \ "${FWK}/lib/python${PYVER}" -"${FWK}/bin/python@PYVER@" -Wi \ - "${FWK}/lib/python${PYVER}/compileall.py" \ - -f -x badsyntax \ - "${FWK}/lib/python${PYVER}/site-packages" - -"${FWK}/bin/python@PYVER@" -Wi -O \ - "${FWK}/lib/python${PYVER}/compileall.py" \ - -f -x badsyntax \ - "${FWK}/lib/python${PYVER}/site-packages" - chgrp -R admin "${FWK}" chmod -R g+w "${FWK}" diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Mac/IDLE/Info.plist.in --- a/Mac/IDLE/Info.plist.in Sat Jul 19 16:34:33 2014 -0700 +++ b/Mac/IDLE/Info.plist.in Sun Jul 20 10:52:46 2014 -0400 @@ -36,7 +36,7 @@ CFBundleExecutable IDLE CFBundleGetInfoString - %VERSION%, © 2001-2014 Python Software Foundation + %VERSION%, © 2001-2011 Python Software Foundation CFBundleIconFile IDLE.icns CFBundleIdentifier @@ -51,8 +51,6 @@ %VERSION% CFBundleVersion %VERSION% - NSHighResolutionCapable - Python */ +#if defined(MYDB_USE_GILSTATE) #define MYDB_BEGIN_BLOCK_THREADS \ PyGILState_STATE __savestate = PyGILState_Ensure(); #define MYDB_END_BLOCK_THREADS \ PyGILState_Release(__savestate); +#else /* MYDB_USE_GILSTATE */ +/* Pre GILState API - do it the long old way */ +static PyInterpreterState* _db_interpreterState = NULL; +#define MYDB_BEGIN_BLOCK_THREADS { \ + PyThreadState* prevState; \ + PyThreadState* newState; \ + PyEval_AcquireLock(); \ + newState = PyThreadState_New(_db_interpreterState); \ + prevState = PyThreadState_Swap(newState); + +#define MYDB_END_BLOCK_THREADS \ + newState = PyThreadState_Swap(prevState); \ + PyThreadState_Clear(newState); \ + PyEval_ReleaseLock(); \ + PyThreadState_Delete(newState); \ + } +#endif /* MYDB_USE_GILSTATE */ #else /* Compiled without threads - avoid all this cruft */ @@ -165,24 +187,24 @@ static PyObject* DBRunRecoveryError; /* DB_RUNRECOVERY */ static PyObject* DBVerifyBadError; /* DB_VERIFY_BAD */ static PyObject* DBNoServerError; /* DB_NOSERVER */ -#if (DBVER < 52) static PyObject* DBNoServerHomeError; /* DB_NOSERVER_HOME */ static PyObject* DBNoServerIDError; /* DB_NOSERVER_ID */ -#endif static PyObject* DBPageNotFoundError; /* DB_PAGE_NOTFOUND */ static PyObject* DBSecondaryBadError; /* DB_SECONDARY_BAD */ static PyObject* DBInvalidArgError; /* EINVAL */ static PyObject* DBAccessError; /* EACCES */ static PyObject* DBNoSpaceError; /* ENOSPC */ -static PyObject* DBNoMemoryError; /* DB_BUFFER_SMALL */ +static PyObject* DBNoMemoryError; /* DB_BUFFER_SMALL (ENOMEM when < 4.3) */ static PyObject* DBAgainError; /* EAGAIN */ static PyObject* DBBusyError; /* EBUSY */ static PyObject* DBFileExistsError; /* EEXIST */ static PyObject* DBNoSuchFileError; /* ENOENT */ static PyObject* DBPermissionsError; /* EPERM */ +#if (DBVER >= 42) static PyObject* DBRepHandleDeadError; /* DB_REP_HANDLE_DEAD */ +#endif #if (DBVER >= 44) static PyObject* DBRepLockoutError; /* DB_REP_LOCKOUT */ #endif @@ -198,6 +220,10 @@ static PyObject* DBRepUnavailError; /* DB_REP_UNAVAIL */ +#if (DBVER < 43) +#define DB_BUFFER_SMALL ENOMEM +#endif + #if (DBVER < 48) #define DB_GID_SIZE DB_XIDDATASIZE #endif @@ -226,9 +252,8 @@ staticforward PyTypeObject DB_Type, DBCursor_Type, DBEnv_Type, DBTxn_Type, DBLock_Type, DBLogCursor_Type; +#if (DBVER >= 43) staticforward PyTypeObject DBSequence_Type; -#if (DBVER >= 52) -staticforward PyTypeObject DBSite_Type; #endif #ifndef Py_TYPE @@ -242,9 +267,8 @@ #define DBEnvObject_Check(v) (Py_TYPE(v) == &DBEnv_Type) #define DBTxnObject_Check(v) (Py_TYPE(v) == &DBTxn_Type) #define DBLockObject_Check(v) (Py_TYPE(v) == &DBLock_Type) +#if (DBVER >= 43) #define DBSequenceObject_Check(v) (Py_TYPE(v) == &DBSequence_Type) -#if (DBVER >= 52) -#define DBSiteObject_Check(v) (Py_TYPE(v) == &DBSite_Type) #endif #if (DBVER < 46) @@ -348,12 +372,9 @@ #define CHECK_LOGCURSOR_NOT_CLOSED(logcurs) \ _CHECK_OBJECT_NOT_CLOSED(logcurs->logc, DBCursorClosedError, DBLogCursor) +#if (DBVER >= 43) #define CHECK_SEQUENCE_NOT_CLOSED(curs) \ _CHECK_OBJECT_NOT_CLOSED(curs->sequence, DBError, DBSequence) - -#if (DBVER >= 52) -#define CHECK_SITE_NOT_CLOSED(db_site) \ - _CHECK_OBJECT_NOT_CLOSED(db_site->site, DBError, DBSite) #endif #define CHECK_DBFLAG(mydb, flag) (((mydb)->flags & (flag)) || \ @@ -546,8 +567,12 @@ /* Callback used to save away more information about errors from the DB * library. */ static char _db_errmsg[1024]; +#if (DBVER <= 42) +static void _db_errorCallback(const char* prefix, char* msg) +#else static void _db_errorCallback(const DB_ENV *db_env, const char* prefix, const char* msg) +#endif { our_strlcpy(_db_errmsg, msg, sizeof(_db_errmsg)); } @@ -601,7 +626,11 @@ return NULL; } +#if (PY_VERSION_HEX >= 0x02040000) r = PyTuple_Pack(2, a, b) ; +#else + r = Py_BuildValue("OO", a, b); +#endif Py_DECREF(a); Py_DECREF(b); return r; @@ -667,15 +696,16 @@ case DB_RUNRECOVERY: errObj = DBRunRecoveryError; break; case DB_VERIFY_BAD: errObj = DBVerifyBadError; break; case DB_NOSERVER: errObj = DBNoServerError; break; -#if (DBVER < 52) case DB_NOSERVER_HOME: errObj = DBNoServerHomeError; break; case DB_NOSERVER_ID: errObj = DBNoServerIDError; break; -#endif case DB_PAGE_NOTFOUND: errObj = DBPageNotFoundError; break; case DB_SECONDARY_BAD: errObj = DBSecondaryBadError; break; case DB_BUFFER_SMALL: errObj = DBNoMemoryError; break; +#if (DBVER >= 43) + /* ENOMEM and DB_BUFFER_SMALL were one and the same until 4.3 */ case ENOMEM: errObj = PyExc_MemoryError; break; +#endif case EINVAL: errObj = DBInvalidArgError; break; case EACCES: errObj = DBAccessError; break; case ENOSPC: errObj = DBNoSpaceError; break; @@ -685,7 +715,9 @@ case ENOENT: errObj = DBNoSuchFileError; break; case EPERM : errObj = DBPermissionsError; break; +#if (DBVER >= 42) case DB_REP_HANDLE_DEAD : errObj = DBRepHandleDeadError; break; +#endif #if (DBVER >= 44) case DB_REP_LOCKOUT : errObj = DBRepLockoutError; break; #endif @@ -870,6 +902,7 @@ Py_XDECREF(v); } +#if (DBVER >= 43) /* add an db_seq_t to a dictionary using the given name as a key */ static void _addDb_seq_tToDict(PyObject* dict, char *name, db_seq_t value) { @@ -879,6 +912,7 @@ Py_XDECREF(v); } +#endif static void _addDB_lsnToDict(PyObject* dict, char *name, DB_LSN value) { @@ -908,10 +942,11 @@ self->myenvobj = NULL; self->db = NULL; self->children_cursors = NULL; +#if (DBVER >=43) self->children_sequences = NULL; +#endif self->associateCallback = NULL; self->btCompareCallback = NULL; - self->dupCompareCallback = NULL; self->primaryDBType = 0; Py_INCREF(Py_None); self->private_obj = Py_None; @@ -949,7 +984,8 @@ * DBTxns and closing any open DBs first. */ if (makeDBError(err)) { if (self->myenvobj) { - Py_CLEAR(self->myenvobj); + Py_DECREF(self->myenvobj); + self->myenvobj = NULL; } Py_DECREF(self); self = NULL; @@ -981,16 +1017,16 @@ PyObject_ClearWeakRefs((PyObject *) self); } if (self->myenvobj) { - Py_CLEAR(self->myenvobj); + Py_DECREF(self->myenvobj); + self->myenvobj = NULL; } if (self->associateCallback != NULL) { - Py_CLEAR(self->associateCallback); + Py_DECREF(self->associateCallback); + self->associateCallback = NULL; } if (self->btCompareCallback != NULL) { - Py_CLEAR(self->btCompareCallback); - } - if (self->dupCompareCallback != NULL) { - Py_CLEAR(self->dupCompareCallback); + Py_DECREF(self->btCompareCallback); + self->btCompareCallback = NULL; } Py_DECREF(self->private_obj); PyObject_Del(self); @@ -1111,9 +1147,6 @@ self->children_dbs = NULL; self->children_txns = NULL; self->children_logcursors = NULL ; -#if (DBVER >= 52) - self->children_sites = NULL; -#endif Py_INCREF(Py_None); self->private_obj = Py_None; Py_INCREF(Py_None); @@ -1155,7 +1188,8 @@ PyErr_Clear(); } - Py_CLEAR(self->event_notifyCallback); + Py_XDECREF(self->event_notifyCallback); + self->event_notifyCallback = NULL; if (self->in_weakreflist != NULL) { PyObject_ClearWeakRefs((PyObject *) self); @@ -1306,6 +1340,7 @@ } +#if (DBVER >= 43) static DBSequenceObject* newDBSequenceObject(DBObject* mydb, int flags) { @@ -1361,53 +1396,6 @@ Py_DECREF(self->mydb); PyObject_Del(self); } - -#if (DBVER >= 52) -static DBSiteObject* -newDBSiteObject(DB_SITE* sitep, DBEnvObject* env) -{ - DBSiteObject* self; - - self = PyObject_New(DBSiteObject, &DBSite_Type); - - if (self == NULL) - return NULL; - - self->site = sitep; - self->env = env; - - INSERT_IN_DOUBLE_LINKED_LIST(self->env->children_sites, self); - - self->in_weakreflist = NULL; - Py_INCREF(self->env); - return self; -} - -/* Forward declaration */ -static PyObject *DBSite_close_internal(DBSiteObject* self); - -static void -DBSite_dealloc(DBSiteObject* self) -{ - PyObject *dummy; - - if (self->site != NULL) { - dummy = DBSite_close_internal(self); - /* - ** Raising exceptions while doing - ** garbage collection is a fatal error. - */ - if (dummy) - Py_DECREF(dummy); - else - PyErr_Clear(); - } - if (self->in_weakreflist != NULL) { - PyObject_ClearWeakRefs((PyObject *) self); - } - Py_DECREF(self->env); - PyObject_Del(self); -} #endif /* --------------------------------------------------------------------- */ @@ -1634,7 +1622,8 @@ MYDB_END_ALLOW_THREADS; if (err) { - Py_CLEAR(secondaryDB->associateCallback); + Py_XDECREF(secondaryDB->associateCallback); + secondaryDB->associateCallback = NULL; secondaryDB->primaryDBType = 0; } @@ -1663,10 +1652,12 @@ Py_XDECREF(dummy); } +#if (DBVER >= 43) while(self->children_sequences) { dummy=DBSequence_close_internal(self->children_sequences,0,0); Py_XDECREF(dummy); } +#endif /* ** "do_not_close" is used to dispose all related objects in the @@ -2083,12 +2074,20 @@ keyObj = NUMBER_FromLong(*(int *)key.data); else keyObj = Build_PyString(key.data, key.size); +#if (PY_VERSION_HEX >= 0x02040000) retval = PyTuple_Pack(3, keyObj, pkeyObj, dataObj); +#else + retval = Py_BuildValue("OOO", keyObj, pkeyObj, dataObj); +#endif Py_DECREF(keyObj); } else /* return just the pkey and data */ { +#if (PY_VERSION_HEX >= 0x02040000) retval = PyTuple_Pack(2, pkeyObj, dataObj); +#else + retval = Py_BuildValue("OO", pkeyObj, dataObj); +#endif } Py_DECREF(dataObj); Py_DECREF(pkeyObj); @@ -2133,7 +2132,7 @@ MYDB_BEGIN_ALLOW_THREADS; err = self->db->get(self->db, txn, &key, &data, flags); MYDB_END_ALLOW_THREADS; - if ((err == DB_BUFFER_SMALL) || (err == 0)) { + if (err == DB_BUFFER_SMALL) { retval = NUMBER_FromLong((long)data.size); err = 0; } @@ -2386,7 +2385,9 @@ return NULL; } +#if (DBVER >= 42) self->db->get_flags(self->db, &self->setflags); +#endif self->flags = flags; @@ -2538,53 +2539,23 @@ #endif static PyObject* -DB_get_dbname(DBObject* self) -{ - int err; - const char *filename, *dbname; - +DB_set_q_extentsize(DBObject* self, PyObject* args) +{ + int err; + u_int32_t extentsize; + + if (!PyArg_ParseTuple(args,"i:set_q_extentsize", &extentsize)) + return NULL; CHECK_DB_NOT_CLOSED(self); MYDB_BEGIN_ALLOW_THREADS; - err = self->db->get_dbname(self->db, &filename, &dbname); - MYDB_END_ALLOW_THREADS; - RETURN_IF_ERR(); - /* If "dbname==NULL", it is correctly converted to "None" */ - return Py_BuildValue("(ss)", filename, dbname); -} - -static PyObject* -DB_get_open_flags(DBObject* self) -{ - int err; - unsigned int flags; - - CHECK_DB_NOT_CLOSED(self); - - MYDB_BEGIN_ALLOW_THREADS; - err = self->db->get_open_flags(self->db, &flags); - MYDB_END_ALLOW_THREADS; - RETURN_IF_ERR(); - return NUMBER_FromLong(flags); -} - -static PyObject* -DB_set_q_extentsize(DBObject* self, PyObject* args) -{ - int err; - u_int32_t extentsize; - - if (!PyArg_ParseTuple(args,"i:set_q_extentsize", &extentsize)) - return NULL; - CHECK_DB_NOT_CLOSED(self); - - MYDB_BEGIN_ALLOW_THREADS; err = self->db->set_q_extentsize(self->db, extentsize); MYDB_END_ALLOW_THREADS; RETURN_IF_ERR(); RETURN_NONE(); } +#if (DBVER >= 42) static PyObject* DB_get_q_extentsize(DBObject* self) { @@ -2599,6 +2570,7 @@ RETURN_IF_ERR(); return NUMBER_FromLong(extentsize); } +#endif static PyObject* DB_set_bt_minkey(DBObject* self, PyObject* args) @@ -2616,6 +2588,7 @@ RETURN_NONE(); } +#if (DBVER >= 42) static PyObject* DB_get_bt_minkey(DBObject* self) { @@ -2630,6 +2603,7 @@ RETURN_IF_ERR(); return NUMBER_FromLong(bt_minkey); } +#endif static int _default_cmp(const DBT *leftKey, @@ -2766,120 +2740,6 @@ RETURN_NONE(); } -static int -_db_dupCompareCallback(DB* db, - const DBT *leftKey, - const DBT *rightKey) -{ - int res = 0; - PyObject *args; - PyObject *result = NULL; - DBObject *self = (DBObject *)db->app_private; - - if (self == NULL || self->dupCompareCallback == NULL) { - MYDB_BEGIN_BLOCK_THREADS; - PyErr_SetString(PyExc_TypeError, - (self == 0 - ? "DB_dup_compare db is NULL." - : "DB_dup_compare callback is NULL.")); - /* we're in a callback within the DB code, we can't raise */ - PyErr_Print(); - res = _default_cmp(leftKey, rightKey); - MYDB_END_BLOCK_THREADS; - } else { - MYDB_BEGIN_BLOCK_THREADS; - - args = BuildValue_SS(leftKey->data, leftKey->size, rightKey->data, rightKey->size); - if (args != NULL) { - result = PyEval_CallObject(self->dupCompareCallback, args); - } - if (args == NULL || result == NULL) { - /* we're in a callback within the DB code, we can't raise */ - PyErr_Print(); - res = _default_cmp(leftKey, rightKey); - } else if (NUMBER_Check(result)) { - res = NUMBER_AsLong(result); - } else { - PyErr_SetString(PyExc_TypeError, - "DB_dup_compare callback MUST return an int."); - /* we're in a callback within the DB code, we can't raise */ - PyErr_Print(); - res = _default_cmp(leftKey, rightKey); - } - - Py_XDECREF(args); - Py_XDECREF(result); - - MYDB_END_BLOCK_THREADS; - } - return res; -} - -static PyObject* -DB_set_dup_compare(DBObject* self, PyObject* comparator) -{ - int err; - PyObject *tuple, *result; - - CHECK_DB_NOT_CLOSED(self); - - if (!PyCallable_Check(comparator)) { - makeTypeError("Callable", comparator); - return NULL; - } - - /* - * Perform a test call of the comparator function with two empty - * string objects here. verify that it returns an int (0). - * err if not. - */ - tuple = Py_BuildValue("(ss)", "", ""); - result = PyEval_CallObject(comparator, tuple); - Py_DECREF(tuple); - if (result == NULL) - return NULL; - if (!NUMBER_Check(result)) { - Py_DECREF(result); - PyErr_SetString(PyExc_TypeError, - "callback MUST return an int"); - return NULL; - } else if (NUMBER_AsLong(result) != 0) { - Py_DECREF(result); - PyErr_SetString(PyExc_TypeError, - "callback failed to return 0 on two empty strings"); - return NULL; - } - Py_DECREF(result); - - /* We don't accept multiple set_dup_compare operations, in order to - * simplify the code. This would have no real use, as one cannot - * change the function once the db is opened anyway */ - if (self->dupCompareCallback != NULL) { - PyErr_SetString(PyExc_RuntimeError, "set_dup_compare() cannot be called more than once"); - return NULL; - } - - Py_INCREF(comparator); - self->dupCompareCallback = comparator; - - /* This is to workaround a problem with un-initialized threads (see - comment in DB_associate) */ -#ifdef WITH_THREAD - PyEval_InitThreads(); -#endif - - err = self->db->set_dup_compare(self->db, _db_dupCompareCallback); - - if (err) { - /* restore the old state in case of error */ - Py_DECREF(comparator); - self->dupCompareCallback = NULL; - } - - RETURN_IF_ERR(); - RETURN_NONE(); -} - static PyObject* DB_set_cachesize(DBObject* self, PyObject* args) @@ -2899,6 +2759,7 @@ RETURN_NONE(); } +#if (DBVER >= 42) static PyObject* DB_get_cachesize(DBObject* self) { @@ -2916,6 +2777,7 @@ return Py_BuildValue("(iii)", gbytes, bytes, ncache); } +#endif static PyObject* DB_set_flags(DBObject* self, PyObject* args) @@ -2935,6 +2797,7 @@ RETURN_NONE(); } +#if (DBVER >= 42) static PyObject* DB_get_flags(DBObject* self) { @@ -2949,158 +2812,139 @@ RETURN_IF_ERR(); return NUMBER_FromLong(flags); } - -static PyObject* -DB_get_transactional(DBObject* self) -{ - int err; - +#endif + +static PyObject* +DB_set_h_ffactor(DBObject* self, PyObject* args) +{ + int err, ffactor; + + if (!PyArg_ParseTuple(args,"i:set_h_ffactor", &ffactor)) + return NULL; CHECK_DB_NOT_CLOSED(self); MYDB_BEGIN_ALLOW_THREADS; - err = self->db->get_transactional(self->db); - MYDB_END_ALLOW_THREADS; - - if(err == 0) { - Py_INCREF(Py_False); - return Py_False; - } else if(err == 1) { - Py_INCREF(Py_True); - return Py_True; - } - - /* - ** If we reach there, there was an error. The - ** "return" should be unreachable. - */ - RETURN_IF_ERR(); - assert(0); /* This code SHOULD be unreachable */ - return NULL; -} - -static PyObject* -DB_set_h_ffactor(DBObject* self, PyObject* args) -{ - int err, ffactor; - - if (!PyArg_ParseTuple(args,"i:set_h_ffactor", &ffactor)) - return NULL; + err = self->db->set_h_ffactor(self->db, ffactor); + MYDB_END_ALLOW_THREADS; + RETURN_IF_ERR(); + RETURN_NONE(); +} + +#if (DBVER >= 42) +static PyObject* +DB_get_h_ffactor(DBObject* self) +{ + int err; + u_int32_t ffactor; + CHECK_DB_NOT_CLOSED(self); MYDB_BEGIN_ALLOW_THREADS; - err = self->db->set_h_ffactor(self->db, ffactor); - MYDB_END_ALLOW_THREADS; - RETURN_IF_ERR(); - RETURN_NONE(); -} - -static PyObject* -DB_get_h_ffactor(DBObject* self) -{ - int err; - u_int32_t ffactor; - + err = self->db->get_h_ffactor(self->db, &ffactor); + MYDB_END_ALLOW_THREADS; + RETURN_IF_ERR(); + return NUMBER_FromLong(ffactor); +} +#endif + +static PyObject* +DB_set_h_nelem(DBObject* self, PyObject* args) +{ + int err, nelem; + + if (!PyArg_ParseTuple(args,"i:set_h_nelem", &nelem)) + return NULL; CHECK_DB_NOT_CLOSED(self); MYDB_BEGIN_ALLOW_THREADS; - err = self->db->get_h_ffactor(self->db, &ffactor); - MYDB_END_ALLOW_THREADS; - RETURN_IF_ERR(); - return NUMBER_FromLong(ffactor); -} - -static PyObject* -DB_set_h_nelem(DBObject* self, PyObject* args) -{ - int err, nelem; - - if (!PyArg_ParseTuple(args,"i:set_h_nelem", &nelem)) - return NULL; + err = self->db->set_h_nelem(self->db, nelem); + MYDB_END_ALLOW_THREADS; + RETURN_IF_ERR(); + RETURN_NONE(); +} + +#if (DBVER >= 42) +static PyObject* +DB_get_h_nelem(DBObject* self) +{ + int err; + u_int32_t nelem; + CHECK_DB_NOT_CLOSED(self); MYDB_BEGIN_ALLOW_THREADS; - err = self->db->set_h_nelem(self->db, nelem); - MYDB_END_ALLOW_THREADS; - RETURN_IF_ERR(); - RETURN_NONE(); -} - -static PyObject* -DB_get_h_nelem(DBObject* self) -{ - int err; - u_int32_t nelem; - + err = self->db->get_h_nelem(self->db, &nelem); + MYDB_END_ALLOW_THREADS; + RETURN_IF_ERR(); + return NUMBER_FromLong(nelem); +} +#endif + +static PyObject* +DB_set_lorder(DBObject* self, PyObject* args) +{ + int err, lorder; + + if (!PyArg_ParseTuple(args,"i:set_lorder", &lorder)) + return NULL; CHECK_DB_NOT_CLOSED(self); MYDB_BEGIN_ALLOW_THREADS; - err = self->db->get_h_nelem(self->db, &nelem); - MYDB_END_ALLOW_THREADS; - RETURN_IF_ERR(); - return NUMBER_FromLong(nelem); -} - -static PyObject* -DB_set_lorder(DBObject* self, PyObject* args) -{ - int err, lorder; - - if (!PyArg_ParseTuple(args,"i:set_lorder", &lorder)) - return NULL; + err = self->db->set_lorder(self->db, lorder); + MYDB_END_ALLOW_THREADS; + RETURN_IF_ERR(); + RETURN_NONE(); +} + +#if (DBVER >= 42) +static PyObject* +DB_get_lorder(DBObject* self) +{ + int err; + int lorder; + CHECK_DB_NOT_CLOSED(self); MYDB_BEGIN_ALLOW_THREADS; - err = self->db->set_lorder(self->db, lorder); - MYDB_END_ALLOW_THREADS; - RETURN_IF_ERR(); - RETURN_NONE(); -} - -static PyObject* -DB_get_lorder(DBObject* self) -{ - int err; - int lorder; - + err = self->db->get_lorder(self->db, &lorder); + MYDB_END_ALLOW_THREADS; + RETURN_IF_ERR(); + return NUMBER_FromLong(lorder); +} +#endif + +static PyObject* +DB_set_pagesize(DBObject* self, PyObject* args) +{ + int err, pagesize; + + if (!PyArg_ParseTuple(args,"i:set_pagesize", &pagesize)) + return NULL; CHECK_DB_NOT_CLOSED(self); MYDB_BEGIN_ALLOW_THREADS; - err = self->db->get_lorder(self->db, &lorder); - MYDB_END_ALLOW_THREADS; - RETURN_IF_ERR(); - return NUMBER_FromLong(lorder); -} - -static PyObject* -DB_set_pagesize(DBObject* self, PyObject* args) -{ - int err, pagesize; - - if (!PyArg_ParseTuple(args,"i:set_pagesize", &pagesize)) - return NULL; + err = self->db->set_pagesize(self->db, pagesize); + MYDB_END_ALLOW_THREADS; + RETURN_IF_ERR(); + RETURN_NONE(); +} + +#if (DBVER >= 42) +static PyObject* +DB_get_pagesize(DBObject* self) +{ + int err; + u_int32_t pagesize; + CHECK_DB_NOT_CLOSED(self); MYDB_BEGIN_ALLOW_THREADS; - err = self->db->set_pagesize(self->db, pagesize); - MYDB_END_ALLOW_THREADS; - RETURN_IF_ERR(); - RETURN_NONE(); -} - -static PyObject* -DB_get_pagesize(DBObject* self) -{ - int err; - u_int32_t pagesize; - - CHECK_DB_NOT_CLOSED(self); - - MYDB_BEGIN_ALLOW_THREADS; err = self->db->get_pagesize(self->db, &pagesize); MYDB_END_ALLOW_THREADS; RETURN_IF_ERR(); return NUMBER_FromLong(pagesize); } +#endif static PyObject* DB_set_re_delim(DBObject* self, PyObject* args) @@ -3123,6 +2967,7 @@ RETURN_NONE(); } +#if (DBVER >= 42) static PyObject* DB_get_re_delim(DBObject* self) { @@ -3136,6 +2981,7 @@ RETURN_IF_ERR(); return NUMBER_FromLong(re_delim); } +#endif static PyObject* DB_set_re_len(DBObject* self, PyObject* args) @@ -3153,6 +2999,7 @@ RETURN_NONE(); } +#if (DBVER >= 42) static PyObject* DB_get_re_len(DBObject* self) { @@ -3167,6 +3014,7 @@ RETURN_IF_ERR(); return NUMBER_FromLong(re_len); } +#endif static PyObject* DB_set_re_pad(DBObject* self, PyObject* args) @@ -3188,6 +3036,7 @@ RETURN_NONE(); } +#if (DBVER >= 42) static PyObject* DB_get_re_pad(DBObject* self) { @@ -3201,6 +3050,7 @@ RETURN_IF_ERR(); return NUMBER_FromLong(re_pad); } +#endif static PyObject* DB_set_re_source(DBObject* self, PyObject* args) @@ -3219,6 +3069,7 @@ RETURN_NONE(); } +#if (DBVER >= 42) static PyObject* DB_get_re_source(DBObject* self) { @@ -3233,6 +3084,7 @@ RETURN_IF_ERR(); return PyBytes_FromString(source); } +#endif static PyObject* DB_stat(DBObject* self, PyObject* args, PyObject* kwargs) @@ -3240,19 +3092,32 @@ int err, flags = 0, type; void* sp; PyObject* d; +#if (DBVER >= 43) PyObject* txnobj = NULL; DB_TXN *txn = NULL; static char* kwnames[] = { "flags", "txn", NULL }; - +#else + static char* kwnames[] = { "flags", NULL }; +#endif + +#if (DBVER >= 43) if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|iO:stat", kwnames, &flags, &txnobj)) return NULL; if (!checkTxnObj(txnobj, &txn)) return NULL; +#else + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|i:stat", kwnames, &flags)) + return NULL; +#endif CHECK_DB_NOT_CLOSED(self); MYDB_BEGIN_ALLOW_THREADS; +#if (DBVER >= 43) err = self->db->stat(self->db, txn, &sp, flags); +#else + err = self->db->stat(self->db, &sp, flags); +#endif MYDB_END_ALLOW_THREADS; RETURN_IF_ERR(); @@ -3307,7 +3172,9 @@ MAKE_BT_ENTRY(leaf_pg); MAKE_BT_ENTRY(dup_pg); MAKE_BT_ENTRY(over_pg); +#if (DBVER >= 43) MAKE_BT_ENTRY(empty_pg); +#endif MAKE_BT_ENTRY(free); MAKE_BT_ENTRY(int_pgfree); MAKE_BT_ENTRY(leaf_pgfree); @@ -3347,6 +3214,7 @@ return d; } +#if (DBVER >= 43) static PyObject* DB_stat_print(DBObject* self, PyObject* args, PyObject *kwargs) { @@ -3366,6 +3234,7 @@ RETURN_IF_ERR(); RETURN_NONE(); } +#endif static PyObject* @@ -3512,6 +3381,7 @@ RETURN_NONE(); } +#if (DBVER >= 42) static PyObject* DB_get_encrypt_flags(DBObject* self) { @@ -3526,6 +3396,7 @@ return NUMBER_FromLong(flags); } +#endif @@ -3549,7 +3420,11 @@ } MYDB_BEGIN_ALLOW_THREADS; +#if (DBVER >= 43) err = self->db->stat(self->db, /*txnid*/ NULL, &sp, 0); +#else + err = self->db->stat(self->db, &sp, 0); +#endif MYDB_END_ALLOW_THREADS; /* All the stat structures have matching fields upto the ndata field, @@ -3993,136 +3868,6 @@ } -/* --------------------------------------------------------------------- */ -/* DBSite methods */ - - -#if (DBVER >= 52) -static PyObject* -DBSite_close_internal(DBSiteObject* self) -{ - int err = 0; - - if (self->site != NULL) { - EXTRACT_FROM_DOUBLE_LINKED_LIST(self); - - MYDB_BEGIN_ALLOW_THREADS; - err = self->site->close(self->site); - MYDB_END_ALLOW_THREADS; - self->site = NULL; - } - RETURN_IF_ERR(); - RETURN_NONE(); -} - -static PyObject* -DBSite_close(DBSiteObject* self) -{ - return DBSite_close_internal(self); -} - -static PyObject* -DBSite_remove(DBSiteObject* self) -{ - int err = 0; - - CHECK_SITE_NOT_CLOSED(self); - - MYDB_BEGIN_ALLOW_THREADS; - err = self->site->remove(self->site); - MYDB_END_ALLOW_THREADS; - - RETURN_IF_ERR(); - RETURN_NONE(); -} - -static PyObject* -DBSite_get_eid(DBSiteObject* self) -{ - int err = 0; - int eid; - - CHECK_SITE_NOT_CLOSED(self); - - MYDB_BEGIN_ALLOW_THREADS; - err = self->site->get_eid(self->site, &eid); - MYDB_END_ALLOW_THREADS; - - RETURN_IF_ERR(); - return NUMBER_FromLong(eid); -} - -static PyObject* -DBSite_get_address(DBSiteObject* self) -{ - int err = 0; - const char *host; - u_int port; - - CHECK_SITE_NOT_CLOSED(self); - - MYDB_BEGIN_ALLOW_THREADS; - err = self->site->get_address(self->site, &host, &port); - MYDB_END_ALLOW_THREADS; - - RETURN_IF_ERR(); - - return Py_BuildValue("(sI)", host, port); -} - -static PyObject* -DBSite_get_config(DBSiteObject* self, PyObject* args, PyObject* kwargs) -{ - int err = 0; - u_int32_t which, value; - static char* kwnames[] = { "which", NULL }; - - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "i:get_config", kwnames, - &which)) - return NULL; - - CHECK_SITE_NOT_CLOSED(self); - - MYDB_BEGIN_ALLOW_THREADS; - err = self->site->get_config(self->site, which, &value); - MYDB_END_ALLOW_THREADS; - - RETURN_IF_ERR(); - - if (value) { - Py_INCREF(Py_True); - return Py_True; - } else { - Py_INCREF(Py_False); - return Py_False; - } -} - -static PyObject* -DBSite_set_config(DBSiteObject* self, PyObject* args, PyObject* kwargs) -{ - int err = 0; - u_int32_t which, value; - PyObject *valueO; - static char* kwnames[] = { "which", "value", NULL }; - - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "iO:set_config", kwnames, - &which, &valueO)) - return NULL; - - CHECK_SITE_NOT_CLOSED(self); - - value = PyObject_IsTrue(valueO); - - MYDB_BEGIN_ALLOW_THREADS; - err = self->site->set_config(self->site, which, value); - MYDB_END_ALLOW_THREADS; - - RETURN_IF_ERR(); - RETURN_NONE(); -} -#endif - /* --------------------------------------------------------------------- */ /* DBCursor methods */ @@ -4382,13 +4127,21 @@ keyObj = NUMBER_FromLong(*(int *)key.data); else keyObj = Build_PyString(key.data, key.size); +#if (PY_VERSION_HEX >= 0x02040000) retval = PyTuple_Pack(3, keyObj, pkeyObj, dataObj); +#else + retval = Py_BuildValue("OOO", keyObj, pkeyObj, dataObj); +#endif Py_DECREF(keyObj); FREE_DBT(key); /* 'make_key_dbt' could do a 'malloc' */ } else /* return just the pkey and data */ { +#if (PY_VERSION_HEX >= 0x02040000) retval = PyTuple_Pack(2, pkeyObj, dataObj); +#else + retval = Py_BuildValue("OO", pkeyObj, dataObj); +#endif } Py_DECREF(dataObj); Py_DECREF(pkeyObj); @@ -4903,12 +4656,6 @@ dummy = DBLogCursor_close_internal(self->children_logcursors); Py_XDECREF(dummy); } -#if (DBVER >= 52) - while(self->children_sites) { - dummy = DBSite_close_internal(self->children_sites); - Py_XDECREF(dummy); - } -#endif } self->closed = 1; @@ -4988,16 +4735,17 @@ #define MAKE_ENTRY(name) _addIntToDict(d, #name, gsp->st_##name) MAKE_ENTRY(gbytes); - MAKE_ENTRY(bytes); MAKE_ENTRY(ncache); #if (DBVER >= 46) MAKE_ENTRY(max_ncache); #endif MAKE_ENTRY(regsize); +#if (DBVER >= 43) MAKE_ENTRY(mmapsize); MAKE_ENTRY(maxopenfd); MAKE_ENTRY(maxwrite); MAKE_ENTRY(maxwrite_sleep); +#endif MAKE_ENTRY(map); MAKE_ENTRY(cache_hit); MAKE_ENTRY(cache_miss); @@ -5080,12 +4828,13 @@ #undef MAKE_ENTRY free(fsp); - r = PyTuple_Pack(2, d, d2); + r = Py_BuildValue("(OO)", d, d2); Py_DECREF(d); Py_DECREF(d2); return r; } +#if (DBVER >= 43) static PyObject* DBEnv_memp_stat_print(DBEnvObject* self, PyObject* args, PyObject *kwargs) { @@ -5105,6 +4854,7 @@ RETURN_IF_ERR(); RETURN_NONE(); } +#endif static PyObject* @@ -5237,6 +4987,7 @@ RETURN_NONE(); } +#if (DBVER >= 42) static PyObject* DBEnv_get_encrypt_flags(DBEnvObject* self) { @@ -5274,6 +5025,7 @@ RETURN_IF_ERR(); return NUMBER_FromLong(timeout); } +#endif static PyObject* @@ -5312,6 +5064,7 @@ RETURN_NONE(); } +#if (DBVER >= 42) static PyObject* DBEnv_get_shm_key(DBEnvObject* self) { @@ -5328,6 +5081,7 @@ return NUMBER_FromLong(shm_key); } +#endif #if (DBVER >= 46) static PyObject* @@ -5416,6 +5170,7 @@ RETURN_NONE(); } +#if (DBVER >= 42) static PyObject* DBEnv_get_cachesize(DBEnvObject* self) { @@ -5433,6 +5188,7 @@ return Py_BuildValue("(iii)", gbytes, bytes, ncache); } +#endif static PyObject* @@ -5452,6 +5208,7 @@ RETURN_NONE(); } +#if (DBVER >= 42) static PyObject* DBEnv_get_flags(DBEnvObject* self) { @@ -5466,6 +5223,7 @@ RETURN_IF_ERR(); return NUMBER_FromLong(flags); } +#endif #if (DBVER >= 47) static PyObject* @@ -5665,6 +5423,7 @@ RETURN_NONE(); } +#if (DBVER >= 42) static PyObject* DBEnv_get_data_dirs(DBEnvObject* self) { @@ -5704,6 +5463,7 @@ } return tuple; } +#endif #if (DBVER >= 44) static PyObject* @@ -5753,6 +5513,7 @@ RETURN_NONE(); } +#if (DBVER >= 42) static PyObject* DBEnv_get_lg_bsize(DBEnvObject* self) { @@ -5767,6 +5528,7 @@ RETURN_IF_ERR(); return NUMBER_FromLong(lg_bsize); } +#endif static PyObject* DBEnv_set_lg_dir(DBEnvObject* self, PyObject* args) @@ -5785,6 +5547,7 @@ RETURN_NONE(); } +#if (DBVER >= 42) static PyObject* DBEnv_get_lg_dir(DBEnvObject* self) { @@ -5799,6 +5562,7 @@ RETURN_IF_ERR(); return PyBytes_FromString(dirp); } +#endif static PyObject* DBEnv_set_lg_max(DBEnvObject* self, PyObject* args) @@ -5816,6 +5580,7 @@ RETURN_NONE(); } +#if (DBVER >= 42) static PyObject* DBEnv_get_lg_max(DBEnvObject* self) { @@ -5830,6 +5595,8 @@ RETURN_IF_ERR(); return NUMBER_FromLong(lg_max); } +#endif + static PyObject* DBEnv_set_lg_regionmax(DBEnvObject* self, PyObject* args) @@ -5847,6 +5614,7 @@ RETURN_NONE(); } +#if (DBVER >= 42) static PyObject* DBEnv_get_lg_regionmax(DBEnvObject* self) { @@ -5861,6 +5629,7 @@ RETURN_IF_ERR(); return NUMBER_FromLong(lg_regionmax); } +#endif #if (DBVER >= 47) static PyObject* @@ -5911,6 +5680,7 @@ RETURN_NONE(); } +#if (DBVER >= 42) static PyObject* DBEnv_get_lk_detect(DBEnvObject* self) { @@ -5925,6 +5695,8 @@ RETURN_IF_ERR(); return NUMBER_FromLong(lk_detect); } +#endif + #if (DBVER < 45) static PyObject* @@ -5962,6 +5734,7 @@ RETURN_NONE(); } +#if (DBVER >= 42) static PyObject* DBEnv_get_lk_max_locks(DBEnvObject* self) { @@ -5976,6 +5749,7 @@ RETURN_IF_ERR(); return NUMBER_FromLong(lk_max); } +#endif static PyObject* DBEnv_set_lk_max_lockers(DBEnvObject* self, PyObject* args) @@ -5993,6 +5767,7 @@ RETURN_NONE(); } +#if (DBVER >= 42) static PyObject* DBEnv_get_lk_max_lockers(DBEnvObject* self) { @@ -6007,6 +5782,7 @@ RETURN_IF_ERR(); return NUMBER_FromLong(lk_max); } +#endif static PyObject* DBEnv_set_lk_max_objects(DBEnvObject* self, PyObject* args) @@ -6024,6 +5800,7 @@ RETURN_NONE(); } +#if (DBVER >= 42) static PyObject* DBEnv_get_lk_max_objects(DBEnvObject* self) { @@ -6038,7 +5815,9 @@ RETURN_IF_ERR(); return NUMBER_FromLong(lk_max); } - +#endif + +#if (DBVER >= 42) static PyObject* DBEnv_get_mp_mmapsize(DBEnvObject* self) { @@ -6053,6 +5832,8 @@ RETURN_IF_ERR(); return NUMBER_FromLong(mmapsize); } +#endif + static PyObject* DBEnv_set_mp_mmapsize(DBEnvObject* self, PyObject* args) @@ -6088,6 +5869,8 @@ RETURN_NONE(); } + +#if (DBVER >= 42) static PyObject* DBEnv_get_tmp_dir(DBEnvObject* self) { @@ -6104,6 +5887,8 @@ return PyBytes_FromString(dirpp); } +#endif + static PyObject* DBEnv_txn_recover(DBEnvObject* self) @@ -6114,7 +5899,7 @@ DBTxnObject *txn; #define PREPLIST_LEN 16 DB_PREPLIST preplist[PREPLIST_LEN]; -#if (DBVER < 48) || (DBVER >= 52) +#if (DBVER < 48) long retp; #else u_int32_t retp; @@ -6218,6 +6003,8 @@ RETURN_NONE(); } + +#if (DBVER >= 42) static PyObject* DBEnv_get_tx_max(DBEnvObject* self) { @@ -6232,6 +6019,8 @@ RETURN_IF_ERR(); return PyLong_FromUnsignedLong(max); } +#endif + static PyObject* DBEnv_set_tx_max(DBEnvObject* self, PyObject* args) @@ -6249,6 +6038,8 @@ RETURN_NONE(); } + +#if (DBVER >= 42) static PyObject* DBEnv_get_tx_timestamp(DBEnvObject* self) { @@ -6263,6 +6054,7 @@ RETURN_IF_ERR(); return NUMBER_FromLong(timestamp); } +#endif static PyObject* DBEnv_set_tx_timestamp(DBEnvObject* self, PyObject* args) @@ -6412,6 +6204,7 @@ #endif /* DBVER >= 4.4 */ +#if (DBVER >= 43) static PyObject* DBEnv_stat_print(DBEnvObject* self, PyObject* args, PyObject *kwargs) { @@ -6431,6 +6224,7 @@ RETURN_IF_ERR(); RETURN_NONE(); } +#endif static PyObject* @@ -6494,6 +6288,7 @@ } /* DBEnv_log_stat */ +#if (DBVER >= 43) static PyObject* DBEnv_log_stat_print(DBEnvObject* self, PyObject* args, PyObject *kwargs) { @@ -6513,6 +6308,7 @@ RETURN_IF_ERR(); RETURN_NONE(); } +#endif static PyObject* @@ -6594,6 +6390,7 @@ return d; } +#if (DBVER >= 43) static PyObject* DBEnv_lock_stat_print(DBEnvObject* self, PyObject* args, PyObject *kwargs) { @@ -6613,6 +6410,7 @@ RETURN_IF_ERR(); RETURN_NONE(); } +#endif static PyObject* @@ -6774,52 +6572,6 @@ } -#if (DBVER >= 52) -static PyObject* -DBEnv_repmgr_site(DBEnvObject* self, PyObject* args, PyObject *kwargs) -{ - int err; - DB_SITE* site; - char *host; - u_int port; - static char* kwnames[] = {"host", "port", NULL}; - - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "si:repmgr_site", kwnames, - &host, &port)) - return NULL; - - CHECK_ENV_NOT_CLOSED(self); - - MYDB_BEGIN_ALLOW_THREADS; - err = self->db_env->repmgr_site(self->db_env, host, port, &site, 0); - MYDB_END_ALLOW_THREADS; - RETURN_IF_ERR(); - return (PyObject*) newDBSiteObject(site, self); -} - -static PyObject* -DBEnv_repmgr_site_by_eid(DBEnvObject* self, PyObject* args, PyObject *kwargs) -{ - int err; - DB_SITE* site; - int eid; - static char* kwnames[] = {"eid", NULL}; - - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "i:repmgr_site_by_eid", - kwnames, &eid)) - return NULL; - - CHECK_ENV_NOT_CLOSED(self); - - MYDB_BEGIN_ALLOW_THREADS; - err = self->db_env->repmgr_site_by_eid(self->db_env, eid, &site); - MYDB_END_ALLOW_THREADS; - RETURN_IF_ERR(); - return (PyObject*) newDBSiteObject(site, self); -} -#endif - - #if (DBVER >= 44) static PyObject* DBEnv_mutex_stat(DBEnvObject* self, PyObject* args) @@ -6888,6 +6640,7 @@ #endif +#if (DBVER >= 43) static PyObject* DBEnv_txn_stat_print(DBEnvObject* self, PyObject* args, PyObject *kwargs) { @@ -6909,6 +6662,7 @@ RETURN_IF_ERR(); RETURN_NONE(); } +#endif static PyObject* @@ -7002,76 +6756,6 @@ RETURN_NONE(); } -#if (DBVER >= 47) -static PyObject* -DBEnv_set_intermediate_dir_mode(DBEnvObject* self, PyObject* args) -{ - int err; - const char *mode; - - if (!PyArg_ParseTuple(args,"s:set_intermediate_dir_mode", &mode)) - return NULL; - - CHECK_ENV_NOT_CLOSED(self); - - MYDB_BEGIN_ALLOW_THREADS; - err = self->db_env->set_intermediate_dir_mode(self->db_env, mode); - MYDB_END_ALLOW_THREADS; - RETURN_IF_ERR(); - RETURN_NONE(); -} - -static PyObject* -DBEnv_get_intermediate_dir_mode(DBEnvObject* self) -{ - int err; - const char *mode; - - CHECK_ENV_NOT_CLOSED(self); - - MYDB_BEGIN_ALLOW_THREADS; - err = self->db_env->get_intermediate_dir_mode(self->db_env, &mode); - MYDB_END_ALLOW_THREADS; - RETURN_IF_ERR(); - return Py_BuildValue("s", mode); -} -#endif - -#if (DBVER < 47) -static PyObject* -DBEnv_set_intermediate_dir(DBEnvObject* self, PyObject* args) -{ - int err; - int mode; - u_int32_t flags; - - if (!PyArg_ParseTuple(args, "iI:set_intermediate_dir", &mode, &flags)) - return NULL; - - CHECK_ENV_NOT_CLOSED(self); - - MYDB_BEGIN_ALLOW_THREADS; - err = self->db_env->set_intermediate_dir(self->db_env, mode, flags); - MYDB_END_ALLOW_THREADS; - RETURN_IF_ERR(); - RETURN_NONE(); -} -#endif - -static PyObject* -DBEnv_get_open_flags(DBEnvObject* self) -{ - int err; - unsigned int flags; - - CHECK_ENV_NOT_CLOSED(self); - - MYDB_BEGIN_ALLOW_THREADS; - err = self->db_env->get_open_flags(self->db_env, &flags); - MYDB_END_ALLOW_THREADS; - RETURN_IF_ERR(); - return NUMBER_FromLong(flags); -} #if (DBVER < 48) static PyObject* @@ -7097,6 +6781,7 @@ } #endif +#if (DBVER >= 43) static PyObject* DBEnv_set_mp_max_openfd(DBEnvObject* self, PyObject* args) { @@ -7170,6 +6855,7 @@ return Py_BuildValue("(ii)", maxwrite, (int)maxwrite_sleep); } +#endif static PyObject* @@ -7189,6 +6875,7 @@ RETURN_NONE(); } +#if (DBVER >= 42) static PyObject* DBEnv_get_verbose(DBEnvObject* self, PyObject* args) { @@ -7206,6 +6893,7 @@ RETURN_IF_ERR(); return PyBool_FromLong(verbose); } +#endif #if (DBVER >= 45) static void @@ -7287,7 +6975,9 @@ PyObject *control_py, *rec_py; DBT control, rec; int envid; +#if (DBVER >= 42) DB_LSN lsn; +#endif if (!PyArg_ParseTuple(args, "OOi:rep_process_message", &control_py, &rec_py, &envid)) @@ -7304,8 +6994,13 @@ err = self->db_env->rep_process_message(self->db_env, &control, &rec, envid, &lsn); #else +#if (DBVER >= 42) err = self->db_env->rep_process_message(self->db_env, &control, &rec, &envid, &lsn); +#else + err = self->db_env->rep_process_message(self->db_env, &control, &rec, + &envid); +#endif #endif MYDB_END_ALLOW_THREADS; switch (err) { @@ -7334,13 +7029,15 @@ return r; break; } +#if (DBVER >= 42) case DB_REP_NOTPERM : case DB_REP_ISPERM : return Py_BuildValue("(i(ll))", err, lsn.file, lsn.offset); break; - } - RETURN_IF_ERR(); - return PyTuple_Pack(2, Py_None, Py_None); +#endif + } + RETURN_IF_ERR(); + return Py_BuildValue("(OO)", Py_None, Py_None); } static int @@ -7365,7 +7062,11 @@ b = PyBytes_FromStringAndSize(rec->data, rec->size); args = Py_BuildValue( +#if (PY_VERSION_HEX >= 0x02040000) "(OOO(ll)iI)", +#else + "(OOO(ll)ii)", +#endif dbenv, a, b, lsn->file, lsn->offset, envid, flags); @@ -7385,6 +7086,20 @@ return ret; } +#if (DBVER <= 41) +static int +_DBEnv_rep_transportCallbackOLD(DB_ENV* db_env, const DBT* control, const DBT* rec, + int envid, u_int32_t flags) +{ + DB_LSN lsn; + + lsn.file = -1; /* Dummy values */ + lsn.offset = -1; + return _DBEnv_rep_transportCallback(db_env, control, rec, &lsn, envid, + flags); +} +#endif + static PyObject* DBEnv_rep_set_transport(DBEnvObject* self, PyObject* args) { @@ -7405,8 +7120,13 @@ err = self->db_env->rep_set_transport(self->db_env, envid, &_DBEnv_rep_transportCallback); #else +#if (DBVER >= 42) err = self->db_env->set_rep_transport(self->db_env, envid, &_DBEnv_rep_transportCallback); +#else + err = self->db_env->set_rep_transport(self->db_env, envid, + &_DBEnv_rep_transportCallbackOLD); +#endif #endif MYDB_END_ALLOW_THREADS; RETURN_IF_ERR(); @@ -7446,7 +7166,11 @@ err = self->db_env->rep_get_request(self->db_env, &minimum, &maximum); MYDB_END_ALLOW_THREADS; RETURN_IF_ERR(); +#if (PY_VERSION_HEX >= 0x02040000) return Py_BuildValue("II", minimum, maximum); +#else + return Py_BuildValue("ii", minimum, maximum); +#endif } #endif @@ -7533,7 +7257,7 @@ } CHECK_ENV_NOT_CLOSED(self); MYDB_BEGIN_ALLOW_THREADS; - err = self->db_env->rep_elect(self->db_env, nsites, nvotes, 0); + err = self->db_env->rep_elect(self->db_env, nvotes, nvotes, 0); MYDB_END_ALLOW_THREADS; RETURN_IF_ERR(); RETURN_NONE(); @@ -7698,8 +7422,13 @@ int err; unsigned int fast, slow; +#if (PY_VERSION_HEX >= 0x02040000) if (!PyArg_ParseTuple(args,"II:rep_set_clockskew", &fast, &slow)) return NULL; +#else + if (!PyArg_ParseTuple(args,"ii:rep_set_clockskew", &fast, &slow)) + return NULL; +#endif CHECK_ENV_NOT_CLOSED(self); @@ -7721,10 +7450,15 @@ err = self->db_env->rep_get_clockskew(self->db_env, &fast, &slow); MYDB_END_ALLOW_THREADS; RETURN_IF_ERR(); +#if (PY_VERSION_HEX >= 0x02040000) return Py_BuildValue("(II)", fast, slow); -} -#endif - +#else + return Py_BuildValue("(ii)", fast, slow); +#endif +} +#endif + +#if (DBVER >= 43) static PyObject* DBEnv_rep_stat_print(DBEnvObject* self, PyObject* args, PyObject *kwargs) { @@ -7744,6 +7478,7 @@ RETURN_IF_ERR(); RETURN_NONE(); } +#endif static PyObject* DBEnv_rep_stat(DBEnvObject* self, PyObject* args, PyObject *kwargs) @@ -7784,6 +7519,7 @@ MAKE_ENTRY(client_svc_req); #endif MAKE_ENTRY(dupmasters); +#if (DBVER >= 43) MAKE_ENTRY(egen); MAKE_ENTRY(election_nvotes); MAKE_ENTRY(startup_complete); @@ -7792,6 +7528,7 @@ MAKE_ENTRY(pg_requested); MAKE_ENTRY(next_pg); MAKE_ENTRY(waiting_pg); +#endif MAKE_ENTRY(election_cur_winner); MAKE_ENTRY(election_gen); MAKE_DB_LSN_ENTRY(election_lsn); @@ -7871,7 +7608,6 @@ RETURN_NONE(); } -#if (DBVER < 52) static PyObject* DBEnv_repmgr_set_local_site(DBEnvObject* self, PyObject* args, PyObject* kwargs) @@ -7918,7 +7654,6 @@ RETURN_IF_ERR(); return NUMBER_FromLong(eidp); } -#endif static PyObject* DBEnv_repmgr_set_ack_policy(DBEnvObject* self, PyObject* args) @@ -7979,8 +7714,13 @@ free(listp); return NULL; } +#if (PY_VERSION_HEX >= 0x02040000) tuple=Py_BuildValue("(sII)", listp[countp].host, listp[countp].port, listp[countp].status); +#else + tuple=Py_BuildValue("(sii)", listp[countp].host, + listp[countp].port, listp[countp].status); +#endif if(!tuple) { Py_DECREF(key); Py_DECREF(stats); @@ -8084,7 +7824,9 @@ static void _promote_transaction_dbs_and_sequences(DBTxnObject *txn) { DBObject *db; +#if (DBVER >= 43) DBSequenceObject *dbs; +#endif while (txn->children_dbs) { db=txn->children_dbs; @@ -8100,6 +7842,7 @@ } } +#if (DBVER >= 43) while (txn->children_sequences) { dbs=txn->children_sequences; EXTRACT_FROM_DOUBLE_LINKED_LIST_TXN(dbs); @@ -8113,6 +7856,7 @@ dbs->txn=NULL; } } +#endif } @@ -8209,10 +7953,12 @@ self->txn = NULL; /* this DB_TXN is no longer valid after this call */ _close_transaction_cursors(self); +#if (DBVER >= 43) while (self->children_sequences) { dummy=DBSequence_close_internal(self->children_sequences,0,0); Py_XDECREF(dummy); } +#endif while (self->children_dbs) { dummy=DB_close_internal(self->children_dbs, 0, 0); Py_XDECREF(dummy); @@ -8348,6 +8094,7 @@ #endif +#if (DBVER >= 43) /* --------------------------------------------------------------------- */ /* DBSequence methods */ @@ -8697,6 +8444,7 @@ free(sp); return dict_stat; } +#endif /* --------------------------------------------------------------------- */ @@ -8734,45 +8482,70 @@ {"remove", (PyCFunction)DB_remove, METH_VARARGS|METH_KEYWORDS}, {"rename", (PyCFunction)DB_rename, METH_VARARGS}, {"set_bt_minkey", (PyCFunction)DB_set_bt_minkey, METH_VARARGS}, +#if (DBVER >= 42) {"get_bt_minkey", (PyCFunction)DB_get_bt_minkey, METH_NOARGS}, +#endif {"set_bt_compare", (PyCFunction)DB_set_bt_compare, METH_O}, {"set_cachesize", (PyCFunction)DB_set_cachesize, METH_VARARGS}, +#if (DBVER >= 42) {"get_cachesize", (PyCFunction)DB_get_cachesize, METH_NOARGS}, - {"set_dup_compare", (PyCFunction)DB_set_dup_compare, METH_O}, +#endif {"set_encrypt", (PyCFunction)DB_set_encrypt, METH_VARARGS|METH_KEYWORDS}, +#if (DBVER >= 42) {"get_encrypt_flags", (PyCFunction)DB_get_encrypt_flags, METH_NOARGS}, +#endif + {"set_flags", (PyCFunction)DB_set_flags, METH_VARARGS}, +#if (DBVER >= 42) {"get_flags", (PyCFunction)DB_get_flags, METH_NOARGS}, - {"get_transactional", (PyCFunction)DB_get_transactional, METH_NOARGS}, +#endif {"set_h_ffactor", (PyCFunction)DB_set_h_ffactor, METH_VARARGS}, +#if (DBVER >= 42) {"get_h_ffactor", (PyCFunction)DB_get_h_ffactor, METH_NOARGS}, +#endif {"set_h_nelem", (PyCFunction)DB_set_h_nelem, METH_VARARGS}, +#if (DBVER >= 42) {"get_h_nelem", (PyCFunction)DB_get_h_nelem, METH_NOARGS}, +#endif {"set_lorder", (PyCFunction)DB_set_lorder, METH_VARARGS}, +#if (DBVER >= 42) {"get_lorder", (PyCFunction)DB_get_lorder, METH_NOARGS}, +#endif {"set_pagesize", (PyCFunction)DB_set_pagesize, METH_VARARGS}, +#if (DBVER >= 42) {"get_pagesize", (PyCFunction)DB_get_pagesize, METH_NOARGS}, +#endif {"set_re_delim", (PyCFunction)DB_set_re_delim, METH_VARARGS}, +#if (DBVER >= 42) {"get_re_delim", (PyCFunction)DB_get_re_delim, METH_NOARGS}, +#endif {"set_re_len", (PyCFunction)DB_set_re_len, METH_VARARGS}, +#if (DBVER >= 42) {"get_re_len", (PyCFunction)DB_get_re_len, METH_NOARGS}, +#endif {"set_re_pad", (PyCFunction)DB_set_re_pad, METH_VARARGS}, +#if (DBVER >= 42) {"get_re_pad", (PyCFunction)DB_get_re_pad, METH_NOARGS}, +#endif {"set_re_source", (PyCFunction)DB_set_re_source, METH_VARARGS}, +#if (DBVER >= 42) {"get_re_source", (PyCFunction)DB_get_re_source, METH_NOARGS}, +#endif {"set_q_extentsize",(PyCFunction)DB_set_q_extentsize, METH_VARARGS}, +#if (DBVER >= 42) {"get_q_extentsize",(PyCFunction)DB_get_q_extentsize, METH_NOARGS}, +#endif {"set_private", (PyCFunction)DB_set_private, METH_O}, {"get_private", (PyCFunction)DB_get_private, METH_NOARGS}, #if (DBVER >= 46) {"set_priority", (PyCFunction)DB_set_priority, METH_VARARGS}, {"get_priority", (PyCFunction)DB_get_priority, METH_NOARGS}, #endif - {"get_dbname", (PyCFunction)DB_get_dbname, METH_NOARGS}, - {"get_open_flags", (PyCFunction)DB_get_open_flags, METH_NOARGS}, {"stat", (PyCFunction)DB_stat, METH_VARARGS|METH_KEYWORDS}, +#if (DBVER >= 43) {"stat_print", (PyCFunction)DB_stat_print, METH_VARARGS|METH_KEYWORDS}, +#endif {"sync", (PyCFunction)DB_sync, METH_VARARGS}, {"truncate", (PyCFunction)DB_truncate, METH_VARARGS|METH_KEYWORDS}, {"type", (PyCFunction)DB_get_type, METH_NOARGS}, @@ -8854,19 +8627,6 @@ {NULL, NULL} /* sentinel */ }; -#if (DBVER >= 52) -static PyMethodDef DBSite_methods[] = { - {"get_config", (PyCFunction)DBSite_get_config, - METH_VARARGS | METH_KEYWORDS}, - {"set_config", (PyCFunction)DBSite_set_config, - METH_VARARGS | METH_KEYWORDS}, - {"remove", (PyCFunction)DBSite_remove, METH_NOARGS}, - {"get_eid", (PyCFunction)DBSite_get_eid, METH_NOARGS}, - {"get_address", (PyCFunction)DBSite_get_address, METH_NOARGS}, - {"close", (PyCFunction)DBSite_close, METH_NOARGS}, - {NULL, NULL} /* sentinel */ -}; -#endif static PyMethodDef DBEnv_methods[] = { {"close", (PyCFunction)DBEnv_close, METH_VARARGS}, @@ -8879,24 +8639,32 @@ {"get_thread_count", (PyCFunction)DBEnv_get_thread_count, METH_NOARGS}, #endif {"set_encrypt", (PyCFunction)DBEnv_set_encrypt, METH_VARARGS|METH_KEYWORDS}, +#if (DBVER >= 42) {"get_encrypt_flags", (PyCFunction)DBEnv_get_encrypt_flags, METH_NOARGS}, {"get_timeout", (PyCFunction)DBEnv_get_timeout, METH_VARARGS|METH_KEYWORDS}, +#endif {"set_timeout", (PyCFunction)DBEnv_set_timeout, METH_VARARGS|METH_KEYWORDS}, {"set_shm_key", (PyCFunction)DBEnv_set_shm_key, METH_VARARGS}, +#if (DBVER >= 42) {"get_shm_key", (PyCFunction)DBEnv_get_shm_key, METH_NOARGS}, +#endif #if (DBVER >= 46) {"set_cache_max", (PyCFunction)DBEnv_set_cache_max, METH_VARARGS}, {"get_cache_max", (PyCFunction)DBEnv_get_cache_max, METH_NOARGS}, #endif {"set_cachesize", (PyCFunction)DBEnv_set_cachesize, METH_VARARGS}, +#if (DBVER >= 42) {"get_cachesize", (PyCFunction)DBEnv_get_cachesize, METH_NOARGS}, +#endif {"memp_trickle", (PyCFunction)DBEnv_memp_trickle, METH_VARARGS}, {"memp_sync", (PyCFunction)DBEnv_memp_sync, METH_VARARGS}, {"memp_stat", (PyCFunction)DBEnv_memp_stat, METH_VARARGS|METH_KEYWORDS}, +#if (DBVER >= 43) {"memp_stat_print", (PyCFunction)DBEnv_memp_stat_print, METH_VARARGS|METH_KEYWORDS}, +#endif #if (DBVER >= 44) {"mutex_set_max", (PyCFunction)DBEnv_mutex_set_max, METH_VARARGS}, {"mutex_get_max", (PyCFunction)DBEnv_mutex_get_max, METH_NOARGS}, @@ -8917,21 +8685,33 @@ #endif #endif {"set_data_dir", (PyCFunction)DBEnv_set_data_dir, METH_VARARGS}, +#if (DBVER >= 42) {"get_data_dirs", (PyCFunction)DBEnv_get_data_dirs, METH_NOARGS}, +#endif +#if (DBVER >= 42) {"get_flags", (PyCFunction)DBEnv_get_flags, METH_NOARGS}, +#endif {"set_flags", (PyCFunction)DBEnv_set_flags, METH_VARARGS}, #if (DBVER >= 47) {"log_set_config", (PyCFunction)DBEnv_log_set_config, METH_VARARGS}, {"log_get_config", (PyCFunction)DBEnv_log_get_config, METH_VARARGS}, #endif {"set_lg_bsize", (PyCFunction)DBEnv_set_lg_bsize, METH_VARARGS}, +#if (DBVER >= 42) {"get_lg_bsize", (PyCFunction)DBEnv_get_lg_bsize, METH_NOARGS}, +#endif {"set_lg_dir", (PyCFunction)DBEnv_set_lg_dir, METH_VARARGS}, +#if (DBVER >= 42) {"get_lg_dir", (PyCFunction)DBEnv_get_lg_dir, METH_NOARGS}, +#endif {"set_lg_max", (PyCFunction)DBEnv_set_lg_max, METH_VARARGS}, +#if (DBVER >= 42) {"get_lg_max", (PyCFunction)DBEnv_get_lg_max, METH_NOARGS}, +#endif {"set_lg_regionmax",(PyCFunction)DBEnv_set_lg_regionmax, METH_VARARGS}, +#if (DBVER >= 42) {"get_lg_regionmax",(PyCFunction)DBEnv_get_lg_regionmax, METH_NOARGS}, +#endif #if (DBVER >= 44) {"set_lg_filemode", (PyCFunction)DBEnv_set_lg_filemode, METH_VARARGS}, {"get_lg_filemode", (PyCFunction)DBEnv_get_lg_filemode, METH_NOARGS}, @@ -8941,29 +8721,47 @@ {"get_lk_partitions", (PyCFunction)DBEnv_get_lk_partitions, METH_NOARGS}, #endif {"set_lk_detect", (PyCFunction)DBEnv_set_lk_detect, METH_VARARGS}, +#if (DBVER >= 42) {"get_lk_detect", (PyCFunction)DBEnv_get_lk_detect, METH_NOARGS}, +#endif #if (DBVER < 45) {"set_lk_max", (PyCFunction)DBEnv_set_lk_max, METH_VARARGS}, #endif {"set_lk_max_locks", (PyCFunction)DBEnv_set_lk_max_locks, METH_VARARGS}, +#if (DBVER >= 42) {"get_lk_max_locks", (PyCFunction)DBEnv_get_lk_max_locks, METH_NOARGS}, +#endif {"set_lk_max_lockers", (PyCFunction)DBEnv_set_lk_max_lockers, METH_VARARGS}, +#if (DBVER >= 42) {"get_lk_max_lockers", (PyCFunction)DBEnv_get_lk_max_lockers, METH_NOARGS}, +#endif {"set_lk_max_objects", (PyCFunction)DBEnv_set_lk_max_objects, METH_VARARGS}, +#if (DBVER >= 42) {"get_lk_max_objects", (PyCFunction)DBEnv_get_lk_max_objects, METH_NOARGS}, +#endif +#if (DBVER >= 43) {"stat_print", (PyCFunction)DBEnv_stat_print, METH_VARARGS|METH_KEYWORDS}, +#endif {"set_mp_mmapsize", (PyCFunction)DBEnv_set_mp_mmapsize, METH_VARARGS}, +#if (DBVER >= 42) {"get_mp_mmapsize", (PyCFunction)DBEnv_get_mp_mmapsize, METH_NOARGS}, +#endif {"set_tmp_dir", (PyCFunction)DBEnv_set_tmp_dir, METH_VARARGS}, +#if (DBVER >= 42) {"get_tmp_dir", (PyCFunction)DBEnv_get_tmp_dir, METH_NOARGS}, +#endif {"txn_begin", (PyCFunction)DBEnv_txn_begin, METH_VARARGS|METH_KEYWORDS}, {"txn_checkpoint", (PyCFunction)DBEnv_txn_checkpoint, METH_VARARGS}, {"txn_stat", (PyCFunction)DBEnv_txn_stat, METH_VARARGS}, +#if (DBVER >= 43) {"txn_stat_print", (PyCFunction)DBEnv_txn_stat_print, METH_VARARGS|METH_KEYWORDS}, +#endif +#if (DBVER >= 42) {"get_tx_max", (PyCFunction)DBEnv_get_tx_max, METH_NOARGS}, {"get_tx_timestamp", (PyCFunction)DBEnv_get_tx_timestamp, METH_NOARGS}, +#endif {"set_tx_max", (PyCFunction)DBEnv_set_tx_max, METH_VARARGS}, {"set_tx_timestamp", (PyCFunction)DBEnv_set_tx_timestamp, METH_VARARGS}, {"lock_detect", (PyCFunction)DBEnv_lock_detect, METH_VARARGS}, @@ -8972,8 +8770,10 @@ {"lock_id_free", (PyCFunction)DBEnv_lock_id_free, METH_VARARGS}, {"lock_put", (PyCFunction)DBEnv_lock_put, METH_VARARGS}, {"lock_stat", (PyCFunction)DBEnv_lock_stat, METH_VARARGS}, +#if (DBVER >= 43) {"lock_stat_print", (PyCFunction)DBEnv_lock_stat_print, METH_VARARGS|METH_KEYWORDS}, +#endif {"log_cursor", (PyCFunction)DBEnv_log_cursor, METH_NOARGS}, {"log_file", (PyCFunction)DBEnv_log_file, METH_VARARGS}, #if (DBVER >= 44) @@ -8983,8 +8783,10 @@ {"log_archive", (PyCFunction)DBEnv_log_archive, METH_VARARGS}, {"log_flush", (PyCFunction)DBEnv_log_flush, METH_NOARGS}, {"log_stat", (PyCFunction)DBEnv_log_stat, METH_VARARGS}, +#if (DBVER >= 43) {"log_stat_print", (PyCFunction)DBEnv_log_stat_print, METH_VARARGS|METH_KEYWORDS}, +#endif #if (DBVER >= 44) {"fileid_reset", (PyCFunction)DBEnv_fileid_reset, METH_VARARGS|METH_KEYWORDS}, {"lsn_reset", (PyCFunction)DBEnv_lsn_reset, METH_VARARGS|METH_KEYWORDS}, @@ -8995,25 +8797,18 @@ {"set_rpc_server", (PyCFunction)DBEnv_set_rpc_server, METH_VARARGS|METH_KEYWORDS}, #endif +#if (DBVER >= 43) {"set_mp_max_openfd", (PyCFunction)DBEnv_set_mp_max_openfd, METH_VARARGS}, {"get_mp_max_openfd", (PyCFunction)DBEnv_get_mp_max_openfd, METH_NOARGS}, {"set_mp_max_write", (PyCFunction)DBEnv_set_mp_max_write, METH_VARARGS}, {"get_mp_max_write", (PyCFunction)DBEnv_get_mp_max_write, METH_NOARGS}, +#endif {"set_verbose", (PyCFunction)DBEnv_set_verbose, METH_VARARGS}, - {"get_verbose", (PyCFunction)DBEnv_get_verbose, METH_VARARGS}, - {"set_private", (PyCFunction)DBEnv_set_private, METH_O}, - {"get_private", (PyCFunction)DBEnv_get_private, METH_NOARGS}, - {"get_open_flags", (PyCFunction)DBEnv_get_open_flags, METH_NOARGS}, -#if (DBVER >= 47) - {"set_intermediate_dir_mode", (PyCFunction)DBEnv_set_intermediate_dir_mode, - METH_VARARGS}, - {"get_intermediate_dir_mode", (PyCFunction)DBEnv_get_intermediate_dir_mode, - METH_NOARGS}, -#endif -#if (DBVER < 47) - {"set_intermediate_dir", (PyCFunction)DBEnv_set_intermediate_dir, - METH_VARARGS}, -#endif +#if (DBVER >= 42) + {"get_verbose", (PyCFunction)DBEnv_get_verbose, METH_VARARGS}, +#endif + {"set_private", (PyCFunction)DBEnv_set_private, METH_O}, + {"get_private", (PyCFunction)DBEnv_get_private, METH_NOARGS}, {"rep_start", (PyCFunction)DBEnv_rep_start, METH_VARARGS|METH_KEYWORDS}, {"rep_set_transport", (PyCFunction)DBEnv_rep_set_transport, METH_VARARGS}, @@ -9052,18 +8847,18 @@ #endif {"rep_stat", (PyCFunction)DBEnv_rep_stat, METH_VARARGS|METH_KEYWORDS}, +#if (DBVER >= 43) {"rep_stat_print", (PyCFunction)DBEnv_rep_stat_print, METH_VARARGS|METH_KEYWORDS}, +#endif #if (DBVER >= 45) {"repmgr_start", (PyCFunction)DBEnv_repmgr_start, METH_VARARGS|METH_KEYWORDS}, -#if (DBVER < 52) {"repmgr_set_local_site", (PyCFunction)DBEnv_repmgr_set_local_site, METH_VARARGS|METH_KEYWORDS}, {"repmgr_add_remote_site", (PyCFunction)DBEnv_repmgr_add_remote_site, METH_VARARGS|METH_KEYWORDS}, -#endif {"repmgr_set_ack_policy", (PyCFunction)DBEnv_repmgr_set_ack_policy, METH_VARARGS}, {"repmgr_get_ack_policy", (PyCFunction)DBEnv_repmgr_get_ack_policy, @@ -9077,12 +8872,6 @@ {"repmgr_stat_print", (PyCFunction)DBEnv_repmgr_stat_print, METH_VARARGS|METH_KEYWORDS}, #endif -#if (DBVER >= 52) - {"repmgr_site", (PyCFunction)DBEnv_repmgr_site, - METH_VARARGS | METH_KEYWORDS}, - {"repmgr_site_by_eid", (PyCFunction)DBEnv_repmgr_site_by_eid, - METH_VARARGS | METH_KEYWORDS}, -#endif {NULL, NULL} /* sentinel */ }; @@ -9103,6 +8892,7 @@ }; +#if (DBVER >= 43) static PyMethodDef DBSequence_methods[] = { {"close", (PyCFunction)DBSequence_close, METH_VARARGS}, {"get", (PyCFunction)DBSequence_get, METH_VARARGS|METH_KEYWORDS}, @@ -9122,6 +8912,7 @@ METH_VARARGS|METH_KEYWORDS}, {NULL, NULL} /* sentinel */ }; +#endif static PyObject* @@ -9131,9 +8922,13 @@ CHECK_ENV_NOT_CLOSED(self); +#if (DBVER >= 42) MYDB_BEGIN_ALLOW_THREADS; self->db_env->get_home(self->db_env, &home); MYDB_END_ALLOW_THREADS; +#else + home=self->db_env->db_home; +#endif if (home == NULL) { RETURN_NONE(); @@ -9275,49 +9070,6 @@ 0, /*tp_members*/ }; -#if (DBVER >= 52) -statichere PyTypeObject DBSite_Type = { -#if (PY_VERSION_HEX < 0x03000000) - PyObject_HEAD_INIT(NULL) - 0, /*ob_size*/ -#else - PyVarObject_HEAD_INIT(NULL, 0) -#endif - "DBSite", /*tp_name*/ - sizeof(DBSiteObject), /*tp_basicsize*/ - 0, /*tp_itemsize*/ - /* methods */ - (destructor)DBSite_dealloc,/*tp_dealloc*/ - 0, /*tp_print*/ - 0, /*tp_getattr*/ - 0, /*tp_setattr*/ - 0, /*tp_compare*/ - 0, /*tp_repr*/ - 0, /*tp_as_number*/ - 0, /*tp_as_sequence*/ - 0, /*tp_as_mapping*/ - 0, /*tp_hash*/ - 0, /*tp_call*/ - 0, /*tp_str*/ - 0, /*tp_getattro*/ - 0, /*tp_setattro*/ - 0, /*tp_as_buffer*/ -#if (PY_VERSION_HEX < 0x03000000) - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_WEAKREFS, /* tp_flags */ -#else - Py_TPFLAGS_DEFAULT, /* tp_flags */ -#endif - 0, /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - offsetof(DBSiteObject, in_weakreflist), /* tp_weaklistoffset */ - 0, /*tp_iter*/ - 0, /*tp_iternext*/ - DBSite_methods, /*tp_methods*/ - 0, /*tp_members*/ -}; -#endif statichere PyTypeObject DBEnv_Type = { #if (PY_VERSION_HEX < 0x03000000) @@ -9443,6 +9195,7 @@ offsetof(DBLockObject, in_weakreflist), /* tp_weaklistoffset */ }; +#if (DBVER >= 43) statichere PyTypeObject DBSequence_Type = { #if (PY_VERSION_HEX < 0x03000000) PyObject_HEAD_INIT(NULL) @@ -9484,6 +9237,7 @@ DBSequence_methods, /*tp_methods*/ 0, /*tp_members*/ }; +#endif /* --------------------------------------------------------------------- */ /* Module-level functions */ @@ -9517,6 +9271,7 @@ return (PyObject* )newDBEnvObject(flags); } +#if (DBVER >= 43) static PyObject* DBSequence_construct(PyObject* self, PyObject* args, PyObject* kwargs) { @@ -9532,6 +9287,7 @@ } return (PyObject* )newDBSequenceObject((DBObject*)dbobj, flags); } +#endif static char bsddb_version_doc[] = "Returns a tuple of major, minor, and patch release numbers of the\n\ @@ -9542,35 +9298,19 @@ { int major, minor, patch; - /* This should be instantaneous, no need to release the GIL */ db_version(&major, &minor, &patch); return Py_BuildValue("(iii)", major, minor, patch); } -#if (DBVER >= 50) -static PyObject* -bsddb_version_full(PyObject* self) -{ - char *version_string; - int family, release, major, minor, patch; - - /* This should be instantaneous, no need to release the GIL */ - version_string = db_full_version(&family, &release, &major, &minor, &patch); - return Py_BuildValue("(siiiii)", - version_string, family, release, major, minor, patch); -} -#endif - /* List of functions defined in the module */ static PyMethodDef bsddb_methods[] = { {"DB", (PyCFunction)DB_construct, METH_VARARGS | METH_KEYWORDS }, {"DBEnv", (PyCFunction)DBEnv_construct, METH_VARARGS}, +#if (DBVER >= 43) {"DBSequence", (PyCFunction)DBSequence_construct, METH_VARARGS | METH_KEYWORDS }, +#endif {"version", (PyCFunction)bsddb_version, METH_NOARGS, bsddb_version_doc}, -#if (DBVER >= 50) - {"full_version", (PyCFunction)bsddb_version_full, METH_NOARGS}, -#endif {NULL, NULL} /* sentinel */ }; @@ -9588,11 +9328,6 @@ */ #define ADD_INT(dict, NAME) _addIntToDict(dict, #NAME, NAME) -/* -** We can rename the module at import time, so the string allocated -** must be big enough, and any use of the name must use this particular -** string. -*/ #define MODULE_NAME_MAX_LEN 11 static char _bsddbModuleName[MODULE_NAME_MAX_LEN+1] = "_bsddb"; @@ -9643,9 +9378,8 @@ || (PyType_Ready(&DBEnv_Type) < 0) || (PyType_Ready(&DBTxn_Type) < 0) || (PyType_Ready(&DBLock_Type) < 0) +#if (DBVER >= 43) || (PyType_Ready(&DBSequence_Type) < 0) -#if (DBVER >= 52) - || (PyType_Ready(&DBSite_Type) < 0) #endif ) { #if (PY_VERSION_HEX < 0x03000000) @@ -9655,6 +9389,11 @@ #endif } +#if defined(WITH_THREAD) && !defined(MYDB_USE_GILSTATE) + /* Save the current interpreter, so callbacks can do the right thing. */ + _db_interpreterState = PyThreadState_GET()->interp; +#endif + /* Create the module and add the functions */ #if (PY_VERSION_HEX < 0x03000000) m = Py_InitModule(_bsddbModuleName, bsddb_methods); @@ -9689,7 +9428,13 @@ ADD_INT(d, DB_MAX_RECORDS); #if (DBVER < 48) +#if (DBVER >= 42) ADD_INT(d, DB_RPCCLIENT); +#else + ADD_INT(d, DB_CLIENT); + /* allow apps to be written using DB_RPCCLIENT on older Berkeley DB */ + _addIntToDict(d, "DB_RPCCLIENT", DB_CLIENT); +#endif #endif #if (DBVER < 48) @@ -9732,14 +9477,6 @@ ADD_INT(d, DB_TXN_SYNC); ADD_INT(d, DB_TXN_NOWAIT); -#if (DBVER >= 51) - ADD_INT(d, DB_TXN_BULK); -#endif - -#if (DBVER >= 48) - ADD_INT(d, DB_CURSOR_BULK); -#endif - #if (DBVER >= 46) ADD_INT(d, DB_TXN_WAIT); #endif @@ -9774,7 +9511,9 @@ ADD_INT(d, DB_LOCK_MINWRITE); ADD_INT(d, DB_LOCK_EXPIRE); +#if (DBVER >= 43) ADD_INT(d, DB_LOCK_MAXWRITE); +#endif _addIntToDict(d, "DB_LOCK_CONFLICT", 0); @@ -9810,6 +9549,9 @@ ADD_INT(d, DB_LOCK_UPGRADE); ADD_INT(d, DB_LSTAT_ABORTED); +#if (DBVER < 43) + ADD_INT(d, DB_LSTAT_ERR); +#endif ADD_INT(d, DB_LSTAT_FREE); ADD_INT(d, DB_LSTAT_HELD); @@ -9819,7 +9561,9 @@ ADD_INT(d, DB_ARCH_ABS); ADD_INT(d, DB_ARCH_DATA); ADD_INT(d, DB_ARCH_LOG); +#if (DBVER >= 42) ADD_INT(d, DB_ARCH_REMOVE); +#endif ADD_INT(d, DB_BTREE); ADD_INT(d, DB_HASH); @@ -9834,7 +9578,9 @@ ADD_INT(d, DB_REVSPLITOFF); ADD_INT(d, DB_SNAPSHOT); +#if (DBVER >= 43) ADD_INT(d, DB_INORDER); +#endif ADD_INT(d, DB_JOIN_NOSORT); @@ -9845,6 +9591,9 @@ ADD_INT(d, DB_CACHED_COUNTS); #endif +#if (DBVER <= 41) + ADD_INT(d, DB_COMMIT); +#endif ADD_INT(d, DB_CONSUME); ADD_INT(d, DB_CONSUME_WAIT); ADD_INT(d, DB_CURRENT); @@ -9902,10 +9651,8 @@ ADD_INT(d, DB_LOCK_DEADLOCK); ADD_INT(d, DB_LOCK_NOTGRANTED); ADD_INT(d, DB_NOSERVER); -#if (DBVER < 52) ADD_INT(d, DB_NOSERVER_HOME); ADD_INT(d, DB_NOSERVER_ID); -#endif ADD_INT(d, DB_NOTFOUND); ADD_INT(d, DB_OLD_VERSION); ADD_INT(d, DB_RUNRECOVERY); @@ -9918,14 +9665,13 @@ ADD_INT(d, DB_YIELDCPU); ADD_INT(d, DB_PANIC_ENVIRONMENT); ADD_INT(d, DB_NOPANIC); + ADD_INT(d, DB_OVERWRITE); +#if (DBVER >= 43) ADD_INT(d, DB_STAT_SUBSYSTEM); ADD_INT(d, DB_STAT_MEMP_HASH); - ADD_INT(d, DB_STAT_LOCK_CONF); - ADD_INT(d, DB_STAT_LOCK_LOCKERS); - ADD_INT(d, DB_STAT_LOCK_OBJECTS); - ADD_INT(d, DB_STAT_LOCK_PARAMS); +#endif #if (DBVER >= 48) ADD_INT(d, DB_OVERWRITE_DUP); @@ -9944,6 +9690,7 @@ ADD_INT(d, DB_EID_INVALID); ADD_INT(d, DB_EID_BROADCAST); +#if (DBVER >= 42) ADD_INT(d, DB_TIME_NOTGRANTED); ADD_INT(d, DB_TXN_NOT_DURABLE); ADD_INT(d, DB_TXN_WRITE_NOSYNC); @@ -9951,8 +9698,9 @@ ADD_INT(d, DB_INIT_REP); ADD_INT(d, DB_ENCRYPT); ADD_INT(d, DB_CHKSUM); - -#if (DBVER < 47) +#endif + +#if (DBVER >= 42) && (DBVER < 47) ADD_INT(d, DB_LOG_AUTOREMOVE); ADD_INT(d, DB_DIRECT_LOG); #endif @@ -9985,20 +9733,6 @@ ADD_INT(d, DB_VERB_REPLICATION); ADD_INT(d, DB_VERB_WAITSFOR); -#if (DBVER >= 50) - ADD_INT(d, DB_VERB_REP_SYSTEM); -#endif - -#if (DBVER >= 47) - ADD_INT(d, DB_VERB_REP_ELECT); - ADD_INT(d, DB_VERB_REP_LEASE); - ADD_INT(d, DB_VERB_REP_MISC); - ADD_INT(d, DB_VERB_REP_MSGS); - ADD_INT(d, DB_VERB_REP_SYNC); - ADD_INT(d, DB_VERB_REPMGR_CONNFAIL); - ADD_INT(d, DB_VERB_REPMGR_MISC); -#endif - #if (DBVER >= 45) ADD_INT(d, DB_EVENT_PANIC); ADD_INT(d, DB_EVENT_REP_CLIENT); @@ -10014,48 +9748,16 @@ ADD_INT(d, DB_EVENT_WRITE_FAILED); #endif -#if (DBVER >= 50) - ADD_INT(d, DB_REPMGR_CONF_ELECTIONS); - ADD_INT(d, DB_EVENT_REP_MASTER_FAILURE); - ADD_INT(d, DB_EVENT_REP_DUPMASTER); - ADD_INT(d, DB_EVENT_REP_ELECTION_FAILED); -#endif -#if (DBVER >= 48) - ADD_INT(d, DB_EVENT_REG_ALIVE); - ADD_INT(d, DB_EVENT_REG_PANIC); -#endif - -#if (DBVER >=52) - ADD_INT(d, DB_EVENT_REP_SITE_ADDED); - ADD_INT(d, DB_EVENT_REP_SITE_REMOVED); - ADD_INT(d, DB_EVENT_REP_LOCAL_SITE_REMOVED); - ADD_INT(d, DB_EVENT_REP_CONNECT_BROKEN); - ADD_INT(d, DB_EVENT_REP_CONNECT_ESTD); - ADD_INT(d, DB_EVENT_REP_CONNECT_TRY_FAILED); - ADD_INT(d, DB_EVENT_REP_INIT_DONE); - - ADD_INT(d, DB_MEM_LOCK); - ADD_INT(d, DB_MEM_LOCKOBJECT); - ADD_INT(d, DB_MEM_LOCKER); - ADD_INT(d, DB_MEM_LOGID); - ADD_INT(d, DB_MEM_TRANSACTION); - ADD_INT(d, DB_MEM_THREAD); - - ADD_INT(d, DB_BOOTSTRAP_HELPER); - ADD_INT(d, DB_GROUP_CREATOR); - ADD_INT(d, DB_LEGACY); - ADD_INT(d, DB_LOCAL_SITE); - ADD_INT(d, DB_REPMGR_PEER); -#endif - ADD_INT(d, DB_REP_DUPMASTER); ADD_INT(d, DB_REP_HOLDELECTION); #if (DBVER >= 44) ADD_INT(d, DB_REP_IGNORE); ADD_INT(d, DB_REP_JOIN_FAILURE); #endif +#if (DBVER >= 42) ADD_INT(d, DB_REP_ISPERM); ADD_INT(d, DB_REP_NOTPERM); +#endif ADD_INT(d, DB_REP_NEWSITE); ADD_INT(d, DB_REP_MASTER); @@ -10064,13 +9766,7 @@ ADD_INT(d, DB_REP_PERMANENT); #if (DBVER >= 44) -#if (DBVER >= 50) - ADD_INT(d, DB_REP_CONF_AUTOINIT); -#else ADD_INT(d, DB_REP_CONF_NOAUTOINIT); -#endif /* 5.0 */ -#endif /* 4.4 */ -#if (DBVER >= 44) ADD_INT(d, DB_REP_CONF_DELAYCLIENT); ADD_INT(d, DB_REP_CONF_BULK); ADD_INT(d, DB_REP_CONF_NOWAIT); @@ -10078,7 +9774,9 @@ ADD_INT(d, DB_REP_REREQUEST); #endif +#if (DBVER >= 42) ADD_INT(d, DB_REP_NOBUFFER); +#endif #if (DBVER >= 46) ADD_INT(d, DB_REP_LEASE_EXPIRED); @@ -10121,34 +9819,14 @@ ADD_INT(d, DB_STAT_ALL); #endif -#if (DBVER >= 51) - ADD_INT(d, DB_REPMGR_ACKS_ALL_AVAILABLE); -#endif - -#if (DBVER >= 48) - ADD_INT(d, DB_REP_CONF_INMEM); -#endif - - ADD_INT(d, DB_TIMEOUT); - -#if (DBVER >= 50) - ADD_INT(d, DB_FORCESYNC); -#endif - -#if (DBVER >= 48) - ADD_INT(d, DB_FAILCHK); -#endif - -#if (DBVER >= 51) - ADD_INT(d, DB_HOTBACKUP_IN_PROGRESS); -#endif - +#if (DBVER >= 43) ADD_INT(d, DB_BUFFER_SMALL); ADD_INT(d, DB_SEQ_DEC); ADD_INT(d, DB_SEQ_INC); ADD_INT(d, DB_SEQ_WRAP); - -#if (DBVER < 47) +#endif + +#if (DBVER >= 43) && (DBVER < 47) ADD_INT(d, DB_LOG_INMEMORY); ADD_INT(d, DB_DSYNC_LOG); #endif @@ -10178,10 +9856,6 @@ ADD_INT(d, DB_SET_LOCK_TIMEOUT); ADD_INT(d, DB_SET_TXN_TIMEOUT); -#if (DBVER >= 48) - ADD_INT(d, DB_SET_REG_TIMEOUT); -#endif - /* The exception name must be correct for pickled exception * * objects to unpickle properly. */ #ifdef PYBSDDB_STANDALONE /* different value needed for standalone pybsddb */ @@ -10238,10 +9912,8 @@ MAKE_EX(DBRunRecoveryError); MAKE_EX(DBVerifyBadError); MAKE_EX(DBNoServerError); -#if (DBVER < 52) MAKE_EX(DBNoServerHomeError); MAKE_EX(DBNoServerIDError); -#endif MAKE_EX(DBPageNotFoundError); MAKE_EX(DBSecondaryBadError); @@ -10255,7 +9927,9 @@ MAKE_EX(DBNoSuchFileError); MAKE_EX(DBPermissionsError); +#if (DBVER >= 42) MAKE_EX(DBRepHandleDeadError); +#endif #if (DBVER >= 44) MAKE_EX(DBRepLockoutError); #endif @@ -10273,30 +9947,27 @@ #undef MAKE_EX /* Initialise the C API structure and add it to the module */ - bsddb_api.api_version = PYBSDDB_API_VERSION; bsddb_api.db_type = &DB_Type; bsddb_api.dbcursor_type = &DBCursor_Type; bsddb_api.dblogcursor_type = &DBLogCursor_Type; bsddb_api.dbenv_type = &DBEnv_Type; bsddb_api.dbtxn_type = &DBTxn_Type; bsddb_api.dblock_type = &DBLock_Type; +#if (DBVER >= 43) bsddb_api.dbsequence_type = &DBSequence_Type; +#endif bsddb_api.makeDBError = makeDBError; /* - ** Capsules exist from Python 2.7 and 3.1. - ** We don't support Python 3.0 anymore, so... - ** #if (PY_VERSION_HEX < ((PY_MAJOR_VERSION < 3) ? 0x02070000 : 0x03020000)) + ** Capsules exist from Python 3.1, but I + ** don't want to break the API compatibility + ** for already published Python versions. */ -#if (PY_VERSION_HEX < 0x02070000) +#if (PY_VERSION_HEX < 0x03020000) py_api = PyCObject_FromVoidPtr((void*)&bsddb_api, NULL); #else { - /* - ** The data must outlive the call!!. So, the static definition. - ** The buffer must be big enough... - */ - static char py_api_name[MODULE_NAME_MAX_LEN+10]; + char py_api_name[250]; strcpy(py_api_name, _bsddbModuleName); strcat(py_api_name, ".api"); diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_collectionsmodule.c --- a/Modules/_collectionsmodule.c Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/_collectionsmodule.c Sun Jul 20 10:52:46 2014 -0400 @@ -8,13 +8,9 @@ */ /* The block length may be set to any number over 1. Larger numbers - * reduce the number of calls to the memory allocator, give faster - * indexing and rotation, and reduce the link::data overhead ratio. - * - * Ideally, the block length will be set to two less than some - * multiple of the cache-line length (so that the full block - * including the leftlink and rightlink will fit neatly into - * cache lines). + * reduce the number of calls to the memory allocator but take more + * memory. Ideally, BLOCKLEN should be set with an eye to the + * length of a cache line. */ #define BLOCKLEN 62 @@ -50,9 +46,9 @@ */ typedef struct BLOCK { + struct BLOCK *leftlink; + struct BLOCK *rightlink; PyObject *data[BLOCKLEN]; - struct BLOCK *rightlink; - struct BLOCK *leftlink; } block; #define MAXFREEBLOCKS 10 @@ -62,8 +58,13 @@ static block * newblock(block *leftlink, block *rightlink, Py_ssize_t len) { block *b; - /* To prevent len from overflowing PY_SSIZE_T_MAX on 32-bit machines, we - * refuse to allocate new blocks if the current len is nearing overflow. */ + /* To prevent len from overflowing PY_SSIZE_T_MAX on 64-bit machines, we + * refuse to allocate new blocks if the current len is dangerously + * close. There is some extra margin to prevent spurious arithmetic + * overflows at various places. The following check ensures that + * the blocks allocated to the deque, in the worst case, can only + * have PY_SSIZE_T_MAX-2 entries in total. + */ if (len >= PY_SSIZE_T_MAX - 2*BLOCKLEN) { PyErr_SetString(PyExc_OverflowError, "cannot add more blocks to the deque"); @@ -102,8 +103,8 @@ Py_ssize_t leftindex; /* in range(BLOCKLEN) */ Py_ssize_t rightindex; /* in range(BLOCKLEN) */ Py_ssize_t len; + Py_ssize_t maxlen; long state; /* incremented whenever the indices move */ - Py_ssize_t maxlen; PyObject *weakreflist; /* List of weak references */ } dequeobject; @@ -412,9 +413,10 @@ static int _deque_rotate(dequeobject *deque, Py_ssize_t n) { - Py_ssize_t m, len=deque->len, halflen=len>>1; + Py_ssize_t i, len=deque->len, halflen=(len+1)>>1; + PyObject *item, *rv; - if (len <= 1) + if (len == 0) return 0; if (n > halflen || n < -halflen) { n %= len; @@ -423,79 +425,24 @@ else if (n < -halflen) n += len; } - assert(len > 1); - assert(-halflen <= n && n <= halflen); - deque->state++; - while (n > 0) { - if (deque->leftindex == 0) { - block *b = newblock(NULL, deque->leftblock, len); - if (b == NULL) - return -1; - assert(deque->leftblock->leftlink == NULL); - deque->leftblock->leftlink = b; - deque->leftblock = b; - deque->leftindex = BLOCKLEN; - } - assert(deque->leftindex > 0); - - m = n; - if (m > deque->rightindex + 1) - m = deque->rightindex + 1; - if (m > deque->leftindex) - m = deque->leftindex; - assert (m > 0 && m <= len); - memcpy(&deque->leftblock->data[deque->leftindex - m], - &deque->rightblock->data[deque->rightindex + 1 - m], - m * sizeof(PyObject *)); - deque->rightindex -= m; - deque->leftindex -= m; - n -= m; - - if (deque->rightindex == -1) { - block *prevblock = deque->rightblock->leftlink; - assert(deque->rightblock != NULL); - assert(deque->leftblock != deque->rightblock); - freeblock(deque->rightblock); - prevblock->rightlink = NULL; - deque->rightblock = prevblock; - deque->rightindex = BLOCKLEN - 1; - } + for (i=0 ; irightindex == BLOCKLEN - 1) { - block *b = newblock(deque->rightblock, NULL, len); - if (b == NULL) - return -1; - assert(deque->rightblock->rightlink == NULL); - deque->rightblock->rightlink = b; - deque->rightblock = b; - deque->rightindex = -1; - } - assert (deque->rightindex < BLOCKLEN - 1); - - m = -n; - if (m > BLOCKLEN - deque->leftindex) - m = BLOCKLEN - deque->leftindex; - if (m > BLOCKLEN - 1 - deque->rightindex) - m = BLOCKLEN - 1 - deque->rightindex; - assert (m > 0 && m <= len); - memcpy(&deque->rightblock->data[deque->rightindex + 1], - &deque->leftblock->data[deque->leftindex], - m * sizeof(PyObject *)); - deque->leftindex += m; - deque->rightindex += m; - n += m; - - if (deque->leftindex == BLOCKLEN) { - block *nextblock = deque->leftblock->rightlink; - assert(deque->leftblock != deque->rightblock); - freeblock(deque->leftblock); - assert(nextblock != NULL); - nextblock->leftlink = NULL; - deque->leftblock = nextblock; - deque->leftindex = 0; - } + for (i=0 ; i>n ; i--) { + item = deque_popleft(deque, NULL); + assert (item != NULL); + rv = deque_append(deque, item); + Py_DECREF(item); + if (rv == NULL) + return -1; + Py_DECREF(rv); } return 0; } @@ -641,7 +588,7 @@ PyDoc_STRVAR(remove_doc, "D.remove(value) -- remove first occurrence of value."); -static void +static int deque_clear(dequeobject *deque) { PyObject *item; @@ -654,6 +601,7 @@ assert(deque->leftblock == deque->rightblock && deque->leftindex - 1 == deque->rightindex && deque->len == 0); + return 0; } static PyObject * @@ -756,7 +704,10 @@ static PyObject * deque_clearmethod(dequeobject *deque) { - deque_clear(deque); + int rv; + + rv = deque_clear(deque); + assert (rv != -1); Py_RETURN_NONE; } @@ -1040,23 +991,6 @@ } static PyObject * -deque_sizeof(dequeobject *deque, void *unused) -{ - Py_ssize_t res; - Py_ssize_t blocks; - - res = sizeof(dequeobject); - blocks = (deque->leftindex + deque->len + BLOCKLEN - 1) / BLOCKLEN; - assert(deque->leftindex + deque->len - 1 == - (blocks - 1) * BLOCKLEN + deque->rightindex); - res += blocks * sizeof(block); - return PyLong_FromSsize_t(res); -} - -PyDoc_STRVAR(sizeof_doc, -"D.__sizeof__() -- size of D in memory, in bytes"); - -static PyObject * deque_get_maxlen(dequeobject *deque) { if (deque->maxlen == -1) @@ -1119,14 +1053,12 @@ {"reverse", (PyCFunction)deque_reverse, METH_NOARGS, reverse_doc}, {"rotate", (PyCFunction)deque_rotate, - METH_VARARGS, rotate_doc}, - {"__sizeof__", (PyCFunction)deque_sizeof, - METH_NOARGS, sizeof_doc}, + METH_VARARGS, rotate_doc}, {NULL, NULL} /* sentinel */ }; PyDoc_STRVAR(deque_doc, -"deque([iterable[, maxlen]]) --> deque object\n\ +"deque(iterable[, maxlen]) --> deque object\n\ \n\ Build an ordered collection with optimized access from its endpoints."); @@ -1543,10 +1475,8 @@ { int status = Py_ReprEnter(dd->default_factory); if (status != 0) { - if (status < 0) { - Py_DECREF(baserepr); + if (status < 0) return NULL; - } defrepr = PyString_FromString("..."); } else @@ -1612,13 +1542,11 @@ } PyDoc_STRVAR(defdict_doc, -"defaultdict(default_factory[, ...]) --> dict with default factory\n\ +"defaultdict(default_factory) --> dict with default factory\n\ \n\ The default factory is called without arguments to produce\n\ a new value when a key is not present, in __getitem__ only.\n\ A defaultdict compares equal to a dict with the same items.\n\ -All remaining arguments are treated the same as if they were\n\ -passed to the dict constructor, including keyword arguments.\n\ "); /* See comment in xxsubtype.c */ diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_csv.c --- a/Modules/_csv.c Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/_csv.c Sun Jul 20 10:52:46 2014 -0400 @@ -208,12 +208,8 @@ { if (src == NULL) *target = dflt; - else { - int b = PyObject_IsTrue(src); - if (b < 0) - return -1; - *target = b; - } + else + *target = PyObject_IsTrue(src); return 0; } @@ -239,24 +235,19 @@ if (src == NULL) *target = dflt; else { - *target = '\0'; - if (src != Py_None) { - Py_ssize_t len; - if (!PyString_Check(src)) { - PyErr_Format(PyExc_TypeError, - "\"%s\" must be string, not %.200s", name, - src->ob_type->tp_name); + if (src == Py_None || PyString_Size(src) == 0) + *target = '\0'; + else if (!PyString_Check(src) || PyString_Size(src) != 1) { + PyErr_Format(PyExc_TypeError, + "\"%s\" must be an 1-character string", + name); + return -1; + } + else { + char *s = PyString_AsString(src); + if (s == NULL) return -1; - } - len = PyString_GET_SIZE(src); - if (len > 1) { - PyErr_Format(PyExc_TypeError, - "\"%s\" must be an 1-character string", - name); - return -1; - } - if (len > 0) - *target = *PyString_AS_STRING(src); + *target = s[0]; } } return 0; @@ -272,7 +263,7 @@ *target = NULL; else if (!IS_BASESTRING(src)) { PyErr_Format(PyExc_TypeError, - "\"%s\" must be a string", name); + "\"%s\" must be an string", name); return -1; } else { @@ -431,8 +422,7 @@ if (dialect_check_quoting(self->quoting)) goto err; if (self->delimiter == 0) { - PyErr_SetString(PyExc_TypeError, - "\"delimiter\" must be an 1-character string"); + PyErr_SetString(PyExc_TypeError, "delimiter must be set"); goto err; } if (quotechar == Py_None && quoting == NULL) @@ -794,13 +784,9 @@ lineobj = PyIter_Next(self->input_iter); if (lineobj == NULL) { /* End of input OR exception */ - if (!PyErr_Occurred() && (self->field_len != 0 || - self->state == IN_QUOTED_FIELD)) { - if (self->dialect->strict) - PyErr_SetString(error_obj, "unexpected end of data"); - else if (parse_save_field(self) >= 0 ) - break; - } + if (!PyErr_Occurred() && self->field_len != 0) + PyErr_Format(error_obj, + "newline inside string"); return NULL; } ++self->line_num; diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/_ctypes.c --- a/Modules/_ctypes/_ctypes.c Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/_ctypes/_ctypes.c Sun Jul 20 10:52:46 2014 -0400 @@ -194,8 +194,10 @@ if (-1 == PyDict_DelItem(self->dict, self->key)) /* XXX Error context */ PyErr_WriteUnraisable(Py_None); - Py_CLEAR(self->key); - Py_CLEAR(self->dict); + Py_DECREF(self->key); + self->key = NULL; + Py_DECREF(self->dict); + self->dict = NULL; } Py_INCREF(Py_None); return Py_None; @@ -322,48 +324,6 @@ } /* - Allocate a memory block for a pep3118 format string, adding - the given prefix (if non-null), an additional shape prefix, and a suffix. - Returns NULL on failure, with the error indicator set. If called with - a suffix of NULL the error indicator must already be set. - */ -char * -_ctypes_alloc_format_string_with_shape(int ndim, const Py_ssize_t *shape, - const char *prefix, const char *suffix) -{ - char *new_prefix; - char *result; - char buf[32]; - int prefix_len; - int k; - - prefix_len = 32 * ndim + 3; - if (prefix) - prefix_len += strlen(prefix); - new_prefix = PyMem_Malloc(prefix_len); - if (new_prefix == NULL) - return NULL; - new_prefix[0] = '\0'; - if (prefix) - strcpy(new_prefix, prefix); - if (ndim > 0) { - /* Add the prefix "(shape[0],shape[1],...,shape[ndim-1])" */ - strcat(new_prefix, "("); - for (k = 0; k < ndim; ++k) { - if (k < ndim-1) { - sprintf(buf, "%"PY_FORMAT_SIZE_T"d,", shape[k]); - } else { - sprintf(buf, "%"PY_FORMAT_SIZE_T"d)", shape[k]); - } - strcat(new_prefix, buf); - } - } - result = _ctypes_alloc_format_string(new_prefix, suffix); - PyMem_Free(new_prefix); - return result; -} - -/* PyCStructType_Type - a meta type/class. Creating a new class using this one as __metaclass__ will call the contructor StructUnionType_new. It replaces the tp_dict member with a new instance of StgDict, and initializes the C @@ -959,21 +919,14 @@ if (proto) { StgDictObject *itemdict = PyType_stgdict(proto); - const char *current_format; assert(itemdict); /* If itemdict->format is NULL, then this is a pointer to an incomplete type. We create a generic format string 'pointer to bytes' in this case. XXX Better would be to fix the format string later... */ - current_format = itemdict->format ? itemdict->format : "B"; - if (itemdict->shape != NULL) { - /* pointer to an array: the shape needs to be prefixed */ - stgdict->format = _ctypes_alloc_format_string_with_shape( - itemdict->ndim, itemdict->shape, "&", current_format); - } else { - stgdict->format = _ctypes_alloc_format_string("&", current_format); - } + stgdict->format = _ctypes_alloc_format_string("&", + itemdict->format ? itemdict->format : "B"); if (stgdict->format == NULL) { Py_DECREF((PyObject *)stgdict); return NULL; @@ -1375,6 +1328,7 @@ long length; Py_ssize_t itemsize, itemalign; + char buf[32]; typedict = PyTuple_GetItem(args, 2); if (!typedict) @@ -1410,7 +1364,13 @@ } assert(itemdict->format); - stgdict->format = _ctypes_alloc_format_string(NULL, itemdict->format); + if (itemdict->format[0] == '(') { + sprintf(buf, "(%ld,", length); + stgdict->format = _ctypes_alloc_format_string(buf, itemdict->format+1); + } else { + sprintf(buf, "(%ld)", length); + stgdict->format = _ctypes_alloc_format_string(buf, itemdict->format); + } if (stgdict->format == NULL) { Py_DECREF((PyObject *)stgdict); return NULL; @@ -2566,9 +2526,11 @@ static int PyCData_clear(CDataObject *self) { + StgDictObject *dict = PyObject_stgdict((PyObject *)self); + assert(dict); /* Cannot be NULL for CDataObject instances */ Py_CLEAR(self->b_objects); if ((self->b_needsfree) - && _CDataObject_HasExternalBuffer(self)) + && ((size_t)dict->size > sizeof(self->b_value))) PyMem_Free(self->b_ptr); self->b_ptr = NULL; Py_CLEAR(self->b_base); @@ -3080,8 +3042,10 @@ PyCFuncPtr_set_restype(PyCFuncPtrObject *self, PyObject *ob) { if (ob == NULL) { - Py_CLEAR(self->restype); - Py_CLEAR(self->checker); + Py_XDECREF(self->restype); + self->restype = NULL; + Py_XDECREF(self->checker); + self->checker = NULL; return 0; } if (ob != Py_None && !PyType_stgdict(ob) && !PyCallable_Check(ob)) { @@ -3124,8 +3088,10 @@ PyObject *converters; if (ob == NULL || ob == Py_None) { - Py_CLEAR(self->converters); - Py_CLEAR(self->argtypes); + Py_XDECREF(self->converters); + self->converters = NULL; + Py_XDECREF(self->argtypes); + self->argtypes = NULL; } else { converters = converters_from_argtypes(ob); if (!converters) @@ -3330,37 +3296,23 @@ { char *name; int (* address)(void); - PyObject *ftuple; PyObject *dll; PyObject *obj; PyCFuncPtrObject *self; void *handle; PyObject *paramflags = NULL; - if (!PyArg_ParseTuple(args, "O|O", &ftuple, ¶mflags)) + if (!PyArg_ParseTuple(args, "(O&O)|O", _get_name, &name, &dll, ¶mflags)) return NULL; if (paramflags == Py_None) paramflags = NULL; - ftuple = PySequence_Tuple(ftuple); - if (!ftuple) - /* Here ftuple is a borrowed reference */ + obj = PyObject_GetAttrString(dll, "_handle"); + if (!obj) return NULL; - - if (!PyArg_ParseTuple(ftuple, "O&O", _get_name, &name, &dll)) { - Py_DECREF(ftuple); - return NULL; - } - - obj = PyObject_GetAttrString(dll, "_handle"); - if (!obj) { - Py_DECREF(ftuple); - return NULL; - } if (!PyInt_Check(obj) && !PyLong_Check(obj)) { PyErr_SetString(PyExc_TypeError, "the _handle attribute of the second argument must be an integer"); - Py_DECREF(ftuple); Py_DECREF(obj); return NULL; } @@ -3369,7 +3321,6 @@ if (PyErr_Occurred()) { PyErr_SetString(PyExc_ValueError, "could not convert the _handle attribute to a pointer"); - Py_DECREF(ftuple); return NULL; } @@ -3384,7 +3335,6 @@ PyErr_Format(PyExc_AttributeError, "function ordinal %d not found", (WORD)(size_t)name); - Py_DECREF(ftuple); return NULL; } #else @@ -3398,12 +3348,9 @@ #else PyErr_SetString(PyExc_AttributeError, ctypes_dlerror()); #endif - Py_DECREF(ftuple); return NULL; } #endif - Py_INCREF(dll); /* for KeepRef */ - Py_DECREF(ftuple); if (!_validate_paramflags(type, paramflags)) return NULL; @@ -3416,6 +3363,7 @@ *(void **)self->b_ptr = address; + Py_INCREF((PyObject *)dll); /* for KeepRef */ if (-1 == KeepRef((CDataObject *)self, 0, dll)) { Py_DECREF((PyObject *)self); return NULL; diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/callproc.c --- a/Modules/_ctypes/callproc.c Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/_ctypes/callproc.c Sun Jul 20 10:52:46 2014 -0400 @@ -25,8 +25,8 @@ 2. After several checks, _build_callargs() is called which returns another tuple 'callargs'. This may be the same tuple as 'inargs', a slice of - 'inargs', or a completely fresh tuple, depending on several things (is it a - COM method?, are 'paramflags' available?). + 'inargs', or a completely fresh tuple, depending on several things (is is a + COM method, are 'paramflags' available). 3. _build_callargs also calculates bitarrays containing indexes into the callargs tuple, specifying how to build the return value(s) of @@ -75,10 +75,6 @@ #include #include "ctypes.h" -#ifdef HAVE_ALLOCA_H -/* AIX needs alloca.h for alloca() */ -#include -#endif #if defined(_DEBUG) || defined(__MINGW32__) /* Don't use structured exception handling on Windows if this is defined. @@ -405,11 +401,6 @@ { *pdw = ptrs->ExceptionRecord->ExceptionCode; *record = *ptrs->ExceptionRecord; - /* We don't want to catch breakpoint exceptions, they are used to attach - * a debugger to the process. - */ - if (*pdw == EXCEPTION_BREAKPOINT) - return EXCEPTION_CONTINUE_SEARCH; return EXCEPTION_EXECUTE_HANDLER; } #endif @@ -853,11 +844,11 @@ space[0] = errno; errno = temp; } + Py_XDECREF(error_object); #ifdef WITH_THREAD if ((flags & FUNCFLAG_PYTHONAPI) == 0) Py_BLOCK_THREADS #endif - Py_XDECREF(error_object); #ifdef MS_WIN32 #ifndef DONT_USE_SEH if (dwExceptionCode) { @@ -1749,7 +1740,7 @@ obj->b_size = size; goto done; } - if (!_CDataObject_HasExternalBuffer(obj)) { + if (obj->b_size <= sizeof(obj->b_value)) { /* We are currently using the objects default buffer, but it isn't large enough any more. */ void *ptr = PyMem_Malloc(size); diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/cfield.c --- a/Modules/_ctypes/cfield.c Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/_ctypes/cfield.c Sun Jul 20 10:52:46 2014 -0400 @@ -431,8 +431,12 @@ #define LOW_BIT(x) ((x) & 0xFFFF) #define NUM_BITS(x) ((x) >> 16) -/* Doesn't work if NUM_BITS(size) == 0, but it never happens in SET() call. */ -#define BIT_MASK(type, size) (((((type)1 << (NUM_BITS(size) - 1)) - 1) << 1) + 1) +/* This seems nore a compiler issue than a Windows/non-Windows one */ +#ifdef MS_WIN32 +# define BIT_MASK(size) ((1 << NUM_BITS(size))-1) +#else +# define BIT_MASK(size) ((1LL << NUM_BITS(size))-1) +#endif /* This macro CHANGES the first parameter IN PLACE. For proper sign handling, we must first shift left, then right. @@ -444,10 +448,10 @@ } /* This macro RETURNS the first parameter with the bit field CHANGED. */ -#define SET(type, x, v, size) \ +#define SET(x, v, size) \ (NUM_BITS(size) ? \ - ( ( (type)x & ~(BIT_MASK(type, size) << LOW_BIT(size)) ) | ( ((type)v & BIT_MASK(type, size)) << LOW_BIT(size) ) ) \ - : (type)v) + ( ( x & ~(BIT_MASK(size) << LOW_BIT(size)) ) | ( (v & BIT_MASK(size)) << LOW_BIT(size) ) ) \ + : v) /* byte swapping macros */ #define SWAP_2(v) \ @@ -519,7 +523,7 @@ long val; if (get_long(value, &val) < 0) return NULL; - *(signed char *)ptr = SET(signed char, *(signed char *)ptr, val, size); + *(signed char *)ptr = (signed char)SET(*(signed char *)ptr, (signed char)val, size); _RET(value); } @@ -538,7 +542,8 @@ unsigned long val; if (get_ulong(value, &val) < 0) return NULL; - *(unsigned char *)ptr = SET(unsigned char, *(unsigned char*)ptr, val, size); + *(unsigned char *)ptr = (unsigned char)SET(*(unsigned char*)ptr, + (unsigned short)val, size); _RET(value); } @@ -559,7 +564,7 @@ if (get_long(value, &val) < 0) return NULL; memcpy(&x, ptr, sizeof(x)); - x = SET(short, x, val, size); + x = SET(x, (short)val, size); memcpy(ptr, &x, sizeof(x)); _RET(value); } @@ -574,7 +579,7 @@ return NULL; memcpy(&field, ptr, sizeof(field)); field = SWAP_2(field); - field = SET(short, field, val, size); + field = SET(field, (short)val, size); field = SWAP_2(field); memcpy(ptr, &field, sizeof(field)); _RET(value); @@ -607,7 +612,7 @@ if (get_ulong(value, &val) < 0) return NULL; memcpy(&x, ptr, sizeof(x)); - x = SET(unsigned short, x, val, size); + x = SET(x, (unsigned short)val, size); memcpy(ptr, &x, sizeof(x)); _RET(value); } @@ -621,7 +626,7 @@ return NULL; memcpy(&field, ptr, sizeof(field)); field = SWAP_2(field); - field = SET(unsigned short, field, val, size); + field = SET(field, (unsigned short)val, size); field = SWAP_2(field); memcpy(ptr, &field, sizeof(field)); _RET(value); @@ -655,7 +660,7 @@ if (get_long(value, &val) < 0) return NULL; memcpy(&x, ptr, sizeof(x)); - x = SET(int, x, val, size); + x = SET(x, (int)val, size); memcpy(ptr, &x, sizeof(x)); _RET(value); } @@ -669,7 +674,7 @@ return NULL; memcpy(&field, ptr, sizeof(field)); field = SWAP_INT(field); - field = SET(int, field, val, size); + field = SET(field, (int)val, size); field = SWAP_INT(field); memcpy(ptr, &field, sizeof(field)); _RET(value); @@ -756,7 +761,7 @@ if (get_ulong(value, &val) < 0) return NULL; memcpy(&x, ptr, sizeof(x)); - x = SET(unsigned int, x, val, size); + x = SET(x, (unsigned int)val, size); memcpy(ptr, &x, sizeof(x)); _RET(value); } @@ -769,7 +774,7 @@ if (get_ulong(value, &val) < 0) return NULL; memcpy(&field, ptr, sizeof(field)); - field = SET(unsigned int, field, (unsigned int)val, size); + field = (unsigned int)SET(field, (unsigned int)val, size); field = SWAP_INT(field); memcpy(ptr, &field, sizeof(field)); _RET(value); @@ -803,7 +808,7 @@ if (get_long(value, &val) < 0) return NULL; memcpy(&x, ptr, sizeof(x)); - x = SET(long, x, val, size); + x = SET(x, val, size); memcpy(ptr, &x, sizeof(x)); _RET(value); } @@ -817,7 +822,7 @@ return NULL; memcpy(&field, ptr, sizeof(field)); field = SWAP_LONG(field); - field = SET(long, field, val, size); + field = (long)SET(field, val, size); field = SWAP_LONG(field); memcpy(ptr, &field, sizeof(field)); _RET(value); @@ -851,7 +856,7 @@ if (get_ulong(value, &val) < 0) return NULL; memcpy(&x, ptr, sizeof(x)); - x = SET(unsigned long, x, val, size); + x = SET(x, val, size); memcpy(ptr, &x, sizeof(x)); _RET(value); } @@ -865,7 +870,7 @@ return NULL; memcpy(&field, ptr, sizeof(field)); field = SWAP_LONG(field); - field = SET(unsigned long, field, val, size); + field = (unsigned long)SET(field, val, size); field = SWAP_LONG(field); memcpy(ptr, &field, sizeof(field)); _RET(value); @@ -900,7 +905,7 @@ if (get_longlong(value, &val) < 0) return NULL; memcpy(&x, ptr, sizeof(x)); - x = SET(PY_LONG_LONG, x, val, size); + x = SET(x, val, size); memcpy(ptr, &x, sizeof(x)); _RET(value); } @@ -914,7 +919,7 @@ return NULL; memcpy(&field, ptr, sizeof(field)); field = SWAP_8(field); - field = SET(PY_LONG_LONG, field, val, size); + field = (PY_LONG_LONG)SET(field, val, size); field = SWAP_8(field); memcpy(ptr, &field, sizeof(field)); _RET(value); @@ -947,7 +952,7 @@ if (get_ulonglong(value, &val) < 0) return NULL; memcpy(&x, ptr, sizeof(x)); - x = SET(PY_LONG_LONG, x, val, size); + x = SET(x, val, size); memcpy(ptr, &x, sizeof(x)); _RET(value); } @@ -961,7 +966,7 @@ return NULL; memcpy(&field, ptr, sizeof(field)); field = SWAP_8(field); - field = SET(unsigned PY_LONG_LONG, field, val, size); + field = (unsigned PY_LONG_LONG)SET(field, val, size); field = SWAP_8(field); memcpy(ptr, &field, sizeof(field)); _RET(value); @@ -998,8 +1003,12 @@ long double x; x = PyFloat_AsDouble(value); - if (x == -1 && PyErr_Occurred()) + if (x == -1 && PyErr_Occurred()) { + PyErr_Format(PyExc_TypeError, + " float expected instead of %s instance", + value->ob_type->tp_name); return NULL; + } memcpy(ptr, &x, sizeof(long double)); _RET(value); } @@ -1018,8 +1027,12 @@ double x; x = PyFloat_AsDouble(value); - if (x == -1 && PyErr_Occurred()) + if (x == -1 && PyErr_Occurred()) { + PyErr_Format(PyExc_TypeError, + " float expected instead of %s instance", + value->ob_type->tp_name); return NULL; + } memcpy(ptr, &x, sizeof(double)); _RET(value); } @@ -1038,8 +1051,12 @@ double x; x = PyFloat_AsDouble(value); - if (x == -1 && PyErr_Occurred()) + if (x == -1 && PyErr_Occurred()) { + PyErr_Format(PyExc_TypeError, + " float expected instead of %s instance", + value->ob_type->tp_name); return NULL; + } #ifdef WORDS_BIGENDIAN if (_PyFloat_Pack8(x, (unsigned char *)ptr, 1)) return NULL; @@ -1066,8 +1083,12 @@ float x; x = (float)PyFloat_AsDouble(value); - if (x == -1 && PyErr_Occurred()) + if (x == -1 && PyErr_Occurred()) { + PyErr_Format(PyExc_TypeError, + " float expected instead of %s instance", + value->ob_type->tp_name); return NULL; + } memcpy(ptr, &x, sizeof(x)); _RET(value); } @@ -1086,8 +1107,12 @@ float x; x = (float)PyFloat_AsDouble(value); - if (x == -1 && PyErr_Occurred()) + if (x == -1 && PyErr_Occurred()) { + PyErr_Format(PyExc_TypeError, + " float expected instead of %s instance", + value->ob_type->tp_name); return NULL; + } #ifdef WORDS_BIGENDIAN if (_PyFloat_Pack4(x, (unsigned char *)ptr, 1)) return NULL; @@ -1687,9 +1712,9 @@ /* #define CHAR_ALIGN (sizeof(s_char) - sizeof(char)) #define SHORT_ALIGN (sizeof(s_short) - sizeof(short)) +#define INT_ALIGN (sizeof(s_int) - sizeof(int)) #define LONG_ALIGN (sizeof(s_long) - sizeof(long)) */ -#define INT_ALIGN (sizeof(s_int) - sizeof(int)) #define FLOAT_ALIGN (sizeof(s_float) - sizeof(float)) #define DOUBLE_ALIGN (sizeof(s_double) - sizeof(double)) #define LONGDOUBLE_ALIGN (sizeof(s_long_double) - sizeof(long double)) @@ -1731,8 +1756,8 @@ ffi_type ffi_type_uint16 = { 2, 2, FFI_TYPE_UINT16 }; ffi_type ffi_type_sint16 = { 2, 2, FFI_TYPE_SINT16 }; -ffi_type ffi_type_uint32 = { 4, INT_ALIGN, FFI_TYPE_UINT32 }; -ffi_type ffi_type_sint32 = { 4, INT_ALIGN, FFI_TYPE_SINT32 }; +ffi_type ffi_type_uint32 = { 4, 4, FFI_TYPE_UINT32 }; +ffi_type ffi_type_sint32 = { 4, 4, FFI_TYPE_SINT32 }; ffi_type ffi_type_uint64 = { 8, LONG_LONG_ALIGN, FFI_TYPE_UINT64 }; ffi_type ffi_type_sint64 = { 8, LONG_LONG_ALIGN, FFI_TYPE_SINT64 }; diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/ctypes.h --- a/Modules/_ctypes/ctypes.h Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/_ctypes/ctypes.h Sun Jul 20 10:52:46 2014 -0400 @@ -153,7 +153,6 @@ extern PyTypeObject PyCData_Type; #define CDataObject_CheckExact(v) ((v)->ob_type == &PyCData_Type) #define CDataObject_Check(v) PyObject_TypeCheck(v, &PyCData_Type) -#define _CDataObject_HasExternalBuffer(v) ((v)->b_ptr != (char *)&(v)->b_value) extern PyTypeObject PyCSimpleType_Type; #define PyCSimpleTypeObject_CheckExact(v) ((v)->ob_type == &PyCSimpleType_Type) @@ -434,9 +433,6 @@ extern PyObject *PyCData_FromBaseObj(PyObject *type, PyObject *base, Py_ssize_t index, char *adr); extern char *_ctypes_alloc_format_string(const char *prefix, const char *suffix); -extern char *_ctypes_alloc_format_string_with_shape(int ndim, - const Py_ssize_t *shape, - const char *prefix, const char *suffix); extern int _ctypes_simple_instance(PyObject *obj); diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi.diff --- a/Modules/_ctypes/libffi.diff Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/_ctypes/libffi.diff Sun Jul 20 10:52:46 2014 -0400 @@ -1,26 +1,24 @@ -diff -r -N -u libffi.orig/autom4te.cache/output.0 libffi/autom4te.cache/output.0 -diff -r -N -u libffi.orig/configure libffi/configure ---- libffi.orig/configure 2013-03-17 15:37:50.000000000 -0700 -+++ libffi/configure 2013-03-18 15:11:39.611575163 -0700 -@@ -13368,6 +13368,10 @@ - fi +diff -urN libffi.orig/configure libffi/configure +--- libffi.orig/configure 2010-03-19 18:29:54.588499862 +0100 ++++ libffi/configure 2010-03-19 18:32:09.113499479 +0100 +@@ -11228,6 +11228,9 @@ + i?86-*-solaris2.1[0-9]*) + TARGET=X86_64; TARGETDIR=x86 ;; - + i*86-*-nto-qnx*) + TARGET=X86; TARGETDIR=x86 + ;; -+ - x86_64-*-darwin*) - TARGET=X86_DARWIN; TARGETDIR=x86 + i?86-*-*) + TARGET=X86; TARGETDIR=x86 ;; -@@ -13426,12 +13430,12 @@ +@@ -11245,12 +11248,12 @@ ;; - mips-sgi-irix5.* | mips-sgi-irix6.* | mips*-*-rtems*) + mips-sgi-irix5.* | mips-sgi-irix6.*) - TARGET=MIPS; TARGETDIR=mips + TARGET=MIPS_IRIX; TARGETDIR=mips ;; - mips*-*-linux* | mips*-*-openbsd*) + mips*-*-linux*) # Support 128-bit long double for NewABI. HAVE_LONG_DOUBLE='defined(__mips64)' - TARGET=MIPS; TARGETDIR=mips @@ -28,8 +26,8 @@ ;; powerpc*-*-linux* | powerpc-*-sysv*) -@@ -13491,7 +13495,7 @@ - as_fn_error $? "\"libffi has not been ported to $host.\"" "$LINENO" 5 +@@ -11307,7 +11310,7 @@ + as_fn_error "\"libffi has not been ported to $host.\"" "$LINENO" 5 fi - if test x$TARGET = xMIPS; then @@ -37,7 +35,7 @@ MIPS_TRUE= MIPS_FALSE='#' else -@@ -14862,6 +14866,12 @@ +@@ -12422,6 +12425,12 @@ ac_config_files="$ac_config_files include/Makefile include/ffi.h Makefile testsuite/Makefile man/Makefile libffi.pc" @@ -50,45 +48,44 @@ cat >confcache <<\_ACEOF # This file is a shell script that caches the results of configure # tests run on this system so they can be shared between configure -@@ -16047,6 +16057,8 @@ +@@ -13521,6 +13530,8 @@ "testsuite/Makefile") CONFIG_FILES="$CONFIG_FILES testsuite/Makefile" ;; "man/Makefile") CONFIG_FILES="$CONFIG_FILES man/Makefile" ;; "libffi.pc") CONFIG_FILES="$CONFIG_FILES libffi.pc" ;; + "include/ffi_common.h") CONFIG_LINKS="$CONFIG_LINKS include/ffi_common.h:include/ffi_common.h" ;; + "fficonfig.py") CONFIG_FILES="$CONFIG_FILES fficonfig.py" ;; - *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;; + *) as_fn_error "invalid argument: \`$ac_config_target'" "$LINENO" 5;; esac -diff -r -N -u libffi.orig/configure.ac libffi/configure.ac ---- libffi.orig/configure.ac 2013-03-17 15:37:50.000000000 -0700 -+++ libffi/configure.ac 2013-03-18 15:11:11.392989136 -0700 +diff -urN libffi.orig/configure.ac libffi/configure.ac +--- libffi.orig/configure.ac 2010-03-19 18:27:44.988498585 +0100 ++++ libffi/configure.ac 2010-03-19 18:31:29.252505178 +0100 @@ -1,4 +1,7 @@ dnl Process this with autoconf to create configure +# -+# file from libffi - slightly patched for Python's ctypes ++# file from libffi - slightly patched for ctypes +# - AC_PREREQ(2.68) + AC_PREREQ(2.63) -@@ -146,6 +149,10 @@ - fi +@@ -91,6 +94,9 @@ + i?86-*-solaris2.1[[0-9]]*) + TARGET=X86_64; TARGETDIR=x86 ;; - + i*86-*-nto-qnx*) + TARGET=X86; TARGETDIR=x86 + ;; -+ - x86_64-*-darwin*) - TARGET=X86_DARWIN; TARGETDIR=x86 + i?86-*-*) + TARGET=X86; TARGETDIR=x86 ;; -@@ -204,12 +211,12 @@ +@@ -108,12 +114,12 @@ ;; - mips-sgi-irix5.* | mips-sgi-irix6.* | mips*-*-rtems*) + mips-sgi-irix5.* | mips-sgi-irix6.*) - TARGET=MIPS; TARGETDIR=mips + TARGET=MIPS_IRIX; TARGETDIR=mips ;; - mips*-*-linux* | mips*-*-openbsd*) + mips*-*-linux*) # Support 128-bit long double for NewABI. HAVE_LONG_DOUBLE='defined(__mips64)' - TARGET=MIPS; TARGETDIR=mips @@ -96,16 +93,16 @@ ;; powerpc*-*-linux* | powerpc-*-sysv*) -@@ -269,7 +276,7 @@ +@@ -170,7 +176,7 @@ AC_MSG_ERROR(["libffi has not been ported to $host."]) fi -AM_CONDITIONAL(MIPS, test x$TARGET = xMIPS) +AM_CONDITIONAL(MIPS,[expr x$TARGET : 'xMIPS' > /dev/null]) - AM_CONDITIONAL(BFIN, test x$TARGET = xBFIN) AM_CONDITIONAL(SPARC, test x$TARGET = xSPARC) AM_CONDITIONAL(X86, test x$TARGET = xX86) -@@ -567,4 +574,8 @@ + AM_CONDITIONAL(X86_FREEBSD, test x$TARGET = xX86_FREEBSD) +@@ -401,4 +407,8 @@ AC_CONFIG_FILES(include/Makefile include/ffi.h Makefile testsuite/Makefile man/Makefile libffi.pc) diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi/.gitignore --- a/Modules/_ctypes/libffi/.gitignore Sat Jul 19 16:34:33 2014 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,21 +0,0 @@ -.libs -.deps -*.o -*.lo -.dirstamp -*.la -Makefile -config.log -config.status -*~ -fficonfig.h -include/ffi.h -include/ffitarget.h -libffi.pc -libtool -stamp-h1 -libffi*gz -autom4te.cache -libffi.xcodeproj/xcuserdata -libffi.xcodeproj/project.xcworkspace -ios/ diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi/.travis.yml --- a/Modules/_ctypes/libffi/.travis.yml Sat Jul 19 16:34:33 2014 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,8 +0,0 @@ -language: c -compiler: - - gcc - - clang - -before_script: sudo apt-get install dejagnu - -script: ./configure && make && make check diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi/ChangeLog --- a/Modules/_ctypes/libffi/ChangeLog Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/_ctypes/libffi/ChangeLog Sun Jul 20 10:52:46 2014 -0400 @@ -1,1360 +1,8 @@ -2013-03-17 Anthony Green - - * README: Update for 3.0.13. - * configure.ac: Ditto. - * configure: Rebuilt. - * doc/*: Update version. - -2013-03-17 Dave Korn - - * src/closures.c (is_emutramp_enabled - [!FFI_MMAP_EXEC_EMUTRAMP_PAX]): Move default definition outside - enclosing #if scope. - -2013-03-17 Anthony Green - - * configure.ac: Only modify toolexecdir in certain cases. - * configure: Rebuilt. - -2013-03-16 Gilles Talis - - * src/powerpc/ffi.c (ffi_prep_args_SYSV): Don't use - fparg_count,etc on __NO_FPRS__ targets. - -2013-03-16 Alan Hourihane - - * src/m68k/sysv.S (epilogue): Don't use extb instruction on - m680000 machines. - -2013-03-16 Alex Gaynor - - * src/x86/ffi.c (ffi_prep_cif_machdep): Always align stack. - -2013-03-13 Markos Chandras - - * configure.ac: Add support for Imagination Technologies Meta. - * Makefile.am: Likewise. - * README: Add Imagination Technologies Meta details. - * src/metag/ffi.c: New. - * src/metag/ffitarget.h: Likewise. - * src/metag/sysv.S: Likewise. - -2013-02-24 Andreas Schwab - - * doc/libffi.texi (Structures): Fix missing category argument of - @deftp. - -2013-02-11 Anthony Green - - * configure.ac: Update release number to 3.0.12. - * configure: Rebuilt. - * README: Update release info. - -2013-02-10 Anthony Green - - * README: Add Moxie. - * src/moxie/ffi.c: Created. - * src/moxie/eabi.S: Created. - * src/moxie/ffitarget.h: Created. - * Makefile.am (nodist_libffi_la_SOURCES): Add Moxie. - * Makefile.in: Rebuilt. - * configure.ac: Add Moxie. - * configure: Rebuilt. - * testsuite/libffi.call/huge_struct.c: Disable format string - warnings for moxie*-*-elf tests. - -2013-02-10 Anthony Green - - * Makefile.am (LTLDFLAGS): Fix reference. - * Makefile.in: Rebuilt. - -2013-02-10 Anthony Green - - * README: Update supported platforms. Update test results link. - -2013-02-09 Anthony Green - - * testsuite/libffi.call/negint.c: Remove forced -O2. - * testsuite/libffi.call/many2.c (foo): Remove GCCism. - * testsuite/libffi.call/ffitest.h: Add default PRIuPTR definition. - - * src/sparc/v8.S (ffi_closure_v8): Import ancient ulonglong - closure return type fix developed by Martin v. Löwis for cpython - fork. - -2013-02-08 Andreas Tobler - - * src/powerpc/ffi.c (ffi_prep_cif_machdep): Fix small struct - support. - * src/powerpc/sysv.S: Ditto. - -2013-02-08 Anthony Green - - * testsuite/libffi.call/cls_longdouble.c: Remove xfail for - arm*-*-*. - -2013-02-08 Anthony Green - - * src/sparc/ffi.c (ffi_prep_closure_loc): Fix cache flushing for GCC. - -2013-02-08 Matthias Klose - - * man/ffi_prep_cif.3: Clean up for debian linter. - -2013-02-08 Peter Bergner - - * src/powerpc/ffi.c (ffi_prep_args_SYSV): Account for FP args pushed - on the stack. - -2013-02-08 Anthony Green - - * Makefile.am (EXTRA_DIST): Add missing files. - * testsuite/Makefile.am (EXTRA_DIST): Ditto. - * Makefile.in: Rebuilt. - -2013-02-08 Anthony Green - - * configure.ac: Move sparc asm config checks to within functions - for compatibility with sun tools. - * configure: Rebuilt. - * src/sparc/ffi.c (ffi_prep_closure_loc): Flush cache on v9 - systems. - * src/sparc/v8.S (ffi_flush_icache): Implement a sparc v9 cache - flusher. - -2013-02-08 Nathan Rossi - - * src/microblaze/ffi.c (ffi_closure_call_SYSV): Fix handling of - small big-endian structures. - (ffi_prep_args): Ditto. - -2013-02-07 Anthony Green - - * src/sparc/v8.S (ffi_call_v8): Fix typo from last patch - (effectively hiding ffi_call_v8). - -2013-02-07 Anthony Green - - * configure.ac: Update bug reporting address. - * configure.in: Rebuild. - - * src/sparc/v8.S (ffi_flush_icache): Out-of-line cache flusher for - Sun compiler. - * src/sparc/ffi.c (ffi_call): Remove warning. - Call ffi_flush_icache for non-GCC builds. - (ffi_prep_closure_loc): Use ffi_flush_icache. - - * Makefile.am (EXTRA_DIST): Add libtool-ldflags. - * Makefile.in: Rebuilt. - * libtool-ldflags: New file. - -2013-02-07 Daniel Schepler - - * configure.ac: Correctly identify x32 systems as 64-bit. - * m4/libtool.m4: Remove libtool expr error. - * aclocal.m4, configure: Rebuilt. - -2013-02-07 Anthony Green - - * configure.ac: Fix GCC usage test. - * configure: Rebuilt. - * README: Mention LLVM/GCC x86_64 issue. - * testsuite/Makefile.in: Rebuilt. - -2013-02-07 Anthony Green - - * testsuite/libffi.call/cls_double_va.c (main): Replace // style - comments with /* */ for xlc compiler. - * testsuite/libffi.call/stret_large.c (main): Ditto. - * testsuite/libffi.call/stret_large2.c (main): Ditto. - * testsuite/libffi.call/nested_struct1.c (main): Ditto. - * testsuite/libffi.call/huge_struct.c (main): Ditto. - * testsuite/libffi.call/float_va.c (main): Ditto. - * testsuite/libffi.call/cls_struct_va1.c (main): Ditto. - * testsuite/libffi.call/cls_pointer_stack.c (main): Ditto. - * testsuite/libffi.call/cls_pointer.c (main): Ditto. - * testsuite/libffi.call/cls_longdouble_va.c (main): Ditto. - -2013-02-06 Anthony Green - - * man/ffi_prep_cif.3: Clean up for debian lintian checker. - -2013-02-06 Anthony Green - - * Makefile.am (pkgconfigdir): Add missing pkgconfig install bits. - * Makefile.in: Rebuild. - -2013-02-02 Mark H Weaver - - * src/x86/ffi64.c (ffi_call): Sign-extend integer arguments passed - via general purpose registers. - -2013-01-21 Nathan Rossi - - * README: Add MicroBlaze details. - * Makefile.am: Add MicroBlaze support. - * configure.ac: Likewise. - * src/microblaze/ffi.c: New. - * src/microblaze/ffitarget.h: Likewise. - * src/microblaze/sysv.S: Likewise. - -2013-01-21 Nathan Rossi - * testsuite/libffi.call/return_uc.c: Fixed issue. - -2013-01-21 Chris Zankel - - * README: Add Xtensa support. - * Makefile.am: Likewise. - * configure.ac: Likewise. - * Makefile.in Regenerate. - * configure: Likewise. - * src/prep_cif.c: Handle Xtensa. - * src/xtensa: New directory. - * src/xtensa/ffi.c: New file. - * src/xtensa/ffitarget.h: Ditto. - * src/xtensa/sysv.S: Ditto. - -2013-01-11 Anthony Green - - * src/powerpc/ffi_darwin.c (ffi_prep_args): Replace // style - comments with /* */ for xlc compiler. - * src/powerpc/aix.S (ffi_call_AIX): Ditto. - * testsuite/libffi.call/ffitest.h (allocate_mmap): Delete - deprecated inline function. - * testsuite/libffi.special/ffitestcxx.h: Ditto. - * README: Add update for AIX support. - -2013-01-11 Anthony Green - - * configure.ac: Robustify pc relative reloc check. - * m4/ax_cc_maxopt.m4: Don't -malign-double. This is an ABI - changing option for 32-bit x86. - * aclocal.m4, configure: Rebuilt. - * README: Update supported target list. - -2013-01-10 Anthony Green - - * README (tested): Add Compiler column to table. - -2013-01-10 Anthony Green - - * src/x86/ffi64.c (struct register_args): Make sse array and array - of unions for sunpro compiler compatibility. - -2013-01-10 Anthony Green - - * configure.ac: Test target platform size_t size. Handle both 32 - and 64-bit builds for x86_64-* and i?86-* targets (allowing for - CFLAG option to change default settings). - * configure, aclocal.m4: Rebuilt. - -2013-01-10 Anthony Green - - * testsuite/libffi.special/special.exp: Only run exception - handling tests when using GNU compiler. - - * m4/ax_compiler_vendor.m4: New file. - * configure.ac: Test for compiler vendor and don't use - AX_CFLAGS_WARN_ALL with the sun compiler. - * aclocal.m4, configure: Rebuilt. - -2013-01-10 Anthony Green - - * include/ffi_common.h: Don't use GCCisms to define types when - building with the SUNPRO compiler. - -2013-01-10 Anthony Green - - * configure.ac: Put local.exp in the right place. - * configure: Rebuilt. - - * src/x86/ffi.c: Update comment about regparm function attributes. - * src/x86/sysv.S (ffi_closure_SYSV): The SUNPRO compiler requires - that all function arguments be passed on the stack (no regparm - support). - -2013-01-08 Anthony Green - - * configure.ac: Generate local.exp. This sets CC_FOR_TARGET - when we are using the vendor compiler. - * testsuite/Makefile.am (EXTRA_DEJAGNU_SITE_CONFIG): Point to - ../local.exp. - * configure, testsuite/Makefile.in: Rebuilt. - - * testsuite/libffi.call/call.exp: Run tests with different - options, depending on whether or not we are using gcc or the - vendor compiler. - * testsuite/lib/libffi.exp (libffi-init): Set using_gcc based on - whether or not we are building/testing with gcc. - -2013-01-08 Anthony Green - - * configure.ac: Switch x86 solaris target to X86 by default. - * configure: Rebuilt. - -2013-01-08 Anthony Green - - * configure.ac: Fix test for read-only eh_frame. - * configure: Rebuilt. - -2013-01-08 Anthony Green - - * src/x86/sysv.S, src/x86/unix64.S: Only emit DWARF unwind info - when building with the GNU toolchain. - * testsuite/libffi.call/ffitest.h (CHECK): Fix for Solaris vendor - compiler. - -2013-01-07 Thorsten Glaser - - * testsuite/libffi.call/cls_uchar_va.c, - testsuite/libffi.call/cls_ushort_va.c, - testsuite/libffi.call/va_1.c: Testsuite fixes. - -2013-01-07 Thorsten Glaser - - * src/m68k/ffi.c (CIF_FLAGS_SINT8, CIF_FLAGS_SINT16): Define. - (ffi_prep_cif_machdep): Fix 8-bit and 16-bit signed calls. - * src/m68k/sysv.S (ffi_call_SYSV, ffi_closure_SYSV): Ditto. - -2013-01-04 Anthony Green - - * Makefile.am (AM_CFLAGS): Don't automatically add -fexceptions - and -Wall. This is set in the configure script after testing for - GCC. - * Makefile.in: Rebuilt. - -2013-01-02 rofl0r - - * src/powerpc/ffi.c (ffi_prep_cif_machdep): Fix build error on ppc - when long double == double. - -2013-01-02 Reini Urban - - * Makefile.am (libffi_la_LDFLAGS): Add -no-undefined to LDFLAGS - (required for shared libs on cygwin/mingw). - * Makefile.in: Rebuilt. - -2012-10-31 Alan Modra - - * src/powerpc/linux64_closure.S: Add new ABI support. - * src/powerpc/linux64.S: Likewise. - -2012-10-30 Magnus Granberg - Pavel Labushev - - * configure.ac: New options pax_emutramp - * configure, fficonfig.h.in: Regenerated - * src/closures.c: New function emutramp_enabled_check() and - checks. - -2012-10-30 Frederick Cheung - - * configure.ac: Enable FFI_MAP_EXEC_WRIT for Darwin 12 (mountain - lion) and future version. - * configure: Rebuild. - -2012-10-30 James Greenhalgh - Marcus Shawcroft - - * README: Add details of aarch64 port. - * src/aarch64/ffi.c: New. - * src/aarch64/ffitarget.h: Likewise. - * src/aarch64/sysv.S: Likewise. - * Makefile.am: Support aarch64. - * configure.ac: Support aarch64. - * Makefile.in, configure: Rebuilt. - -2012-10-30 James Greenhalgh - Marcus Shawcroft - - * testsuite/lib/libffi.exp: Add support for aarch64. - * testsuite/libffi.call/cls_struct_va1.c: New. - * testsuite/libffi.call/cls_uchar_va.c: Likewise. - * testsuite/libffi.call/cls_uint_va.c: Likewise. - * testsuite/libffi.call/cls_ulong_va.c: Likewise. - * testsuite/libffi.call/cls_ushort_va.c: Likewise. - * testsuite/libffi.call/nested_struct11.c: Likewise. - * testsuite/libffi.call/uninitialized.c: Likewise. - * testsuite/libffi.call/va_1.c: Likewise. - * testsuite/libffi.call/va_struct1.c: Likewise. - * testsuite/libffi.call/va_struct2.c: Likewise. - * testsuite/libffi.call/va_struct3.c: Likewise. - -2012-10-12 Walter Lee - - * Makefile.am: Add TILE-Gx/TILEPro support. - * configure.ac: Likewise. - * Makefile.in: Regenerate. - * configure: Likewise. - * src/prep_cif.c (ffi_prep_cif_core): Handle TILE-Gx/TILEPro. - * src/tile: New directory. - * src/tile/ffi.c: New file. - * src/tile/ffitarget.h: Ditto. - * src/tile/tile.S: Ditto. - -2012-10-12 Matthias Klose - - * generate-osx-source-and-headers.py: Normalize whitespace. - -2012-09-14 David Edelsohn - - * configure: Regenerated. - -2012-08-26 Andrew Pinski - - PR libffi/53014 - * src/mips/ffi.c (ffi_prep_closure_loc): Allow n32 with soft-float and n64 with - soft-float. - -2012-08-08 Uros Bizjak - - * src/s390/ffi.c (ffi_prep_closure_loc): Don't ASSERT ABI test, - just return FFI_BAD_ABI when things are wrong. - -2012-07-18 H.J. Lu - - PR libffi/53982 - PR libffi/53973 - * src/x86/ffitarget.h: Check __ILP32__ instead of __LP64__ for x32. - (FFI_SIZEOF_JAVA_RAW): Defined to 4 for x32. - -2012-05-16 H.J. Lu - - * configure: Regenerated. - -2012-05-05 Nicolas Lelong - - * libffi.xcodeproj/project.pbxproj: Fixes. - * README: Update for iOS builds. - -2012-04-23 Alexandre Keunecke I. de Mendonca - - * configure.ac: Add Blackfin/sysv support - * Makefile.am: Add Blackfin/sysv support - * src/bfin/ffi.c: Add Blackfin/sysv support - * src/bfin/ffitarget.h: Add Blackfin/sysv support - -2012-04-11 Anthony Green - - * Makefile.am (EXTRA_DIST): Add new script. - * Makefile.in: Rebuilt. - -2012-04-11 Zachary Waldowski - - * generate-ios-source-and-headers.py, - libffi.xcodeproj/project.pbxproj: Support a Mac static library via - Xcode. Set iOS compatibility to 4.0. Move iOS trampoline - generation into an Xcode "run script" phase. Include both as - Xcode build scripts. Don't always regenerate config files. - -2012-04-10 Anthony Green - - * src/powerpc/ffi_darwin.c (ffi_prep_args): Add missing semicolon. - -2012-04-06 Anthony Green - - * Makefile.am (EXTRA_DIST): Add new iOS/xcode files. - * Makefile.in: Rebuilt. - -2012-04-06 Mike Lewis - - * generate-ios-source-and-headers.py: New file. - * libffi.xcodeproj/project.pbxproj: New file. - * README: Update instructions on building iOS binary. - * build-ios.sh: Delete. - -2012-04-06 Anthony Green - - * src/x86/ffi64.c (UINT128): Define differently for Intel and GNU - compilers, then use it. - -2012-04-06 H.J. Lu - - * m4/libtool.m4 (_LT_ENABLE_LOCK): Support x32. - -2012-04-06 Anthony Green - - * testsuite/Makefile.am (EXTRA_DIST): Add missing test cases. - * testsuite/Makefile.in: Rebuilt. - -2012-04-05 Zachary Waldowski - - * include/ffi.h.in: Add missing trampoline table fields. - * src/arm/sysv.S: Fix ENTRY definition, and wrap symbol references - in CNAME. - * src/x86/ffi.c: Wrap Windows specific code in ifdefs. - -2012-04-02 Peter Bergner - - * src/powerpc/ffi.c (ffi_prep_args_SYSV): Declare double_tmp. - Silence casting pointer to integer of different size warning. - Delete goto to previously deleted label. - (ffi_call): Silence possibly undefined warning. - (ffi_closure_helper_SYSV): Declare variable type. - -2012-04-02 Peter Rosin - - * src/x86/win32.S (ffi_call_win32): Sign/zero extend the return - value in the Intel version as is already done for the AT&T version. - (ffi_closure_SYSV): Likewise. - (ffi_closure_raw_SYSV): Likewise. - (ffi_closure_STDCALL): Likewise. - -2012-03-29 Peter Rosin - - * src/x86/win32.S (ffi_closure_raw_THISCALL): Unify the frame - generation, fix the ENDP label and remove the surplus third arg - from the 'lea' insn. - -2012-03-29 Peter Rosin - - * src/x86/win32.S (ffi_closure_raw_SYSV): Make the 'stubraw' label - visible outside the PROC, so that ffi_closure_raw_THISCALL can see - it. Also instruct the assembler to add a frame to the function. - -2012-03-23 Peter Rosin - - * Makefile.am (AM_CPPFLAGS): Add -DFFI_BUILDING. - * Makefile.in: Rebuilt. - * include/ffi.h.in [MSVC]: Add __declspec(dllimport) decorations - to all data exports, when compiling libffi clients using MSVC. - -2012-03-29 Peter Rosin - - * src/x86/ffitarget.h (ffi_abi): Add new ABI FFI_MS_CDECL and - make it the default for MSVC. - (FFI_TYPE_MS_STRUCT): New structure return convention. - * src/x86/ffi.c (ffi_prep_cif_machdep): Tweak the structure - return convention for FFI_MS_CDECL to be FFI_TYPE_MS_STRUCT - instead of an ordinary FFI_TYPE_STRUCT. - (ffi_prep_args): Treat FFI_TYPE_MS_STRUCT as FFI_TYPE_STRUCT. - (ffi_call): Likewise. - (ffi_prep_incoming_args_SYSV): Likewise. - (ffi_raw_call): Likewise. - (ffi_prep_closure_loc): Treat FFI_MS_CDECL as FFI_SYSV. - * src/x86/win32.S (ffi_closure_SYSV): For FFI_TYPE_MS_STRUCT, - return a pointer to the result structure in eax and don't pop - that pointer from the stack, the caller takes care of it. - (ffi_call_win32): Treat FFI_TYPE_MS_STRUCT as FFI_TYPE_STRUCT. - (ffi_closure_raw_SYSV): Likewise. - -2012-03-22 Peter Rosin - - * testsuite/libffi.call/closure_stdcall.c [MSVC]: Add inline - assembly version with Intel syntax. - * testsuite/libffi.call/closure_thiscall.c [MSVC]: Likewise. - -2012-03-23 Peter Rosin - - * testsuite/libffi.call/ffitest.h: Provide abstration of - __attribute__((fastcall)) in the form of a __FASTCALL__ - define. Define it to __fastcall for MSVC. - * testsuite/libffi.call/fastthis1_win32.c: Use the above. - * testsuite/libffi.call/fastthis2_win32.c: Likewise. - * testsuite/libffi.call/fastthis3_win32.c: Likewise. - * testsuite/libffi.call/strlen2_win32.c: Likewise. - * testsuite/libffi.call/struct1_win32.c: Likewise. - * testsuite/libffi.call/struct2_win32.c: Likewise. - -2012-03-22 Peter Rosin - - * src/x86/win32.S [MSVC] (ffi_closure_THISCALL): Remove the manual - frame on function entry, MASM adds one automatically. - -2012-03-22 Peter Rosin - - * testsuite/libffi.call/ffitest.h [MSVC]: Add kludge for missing - bits in the MSVC headers. - -2012-03-22 Peter Rosin - - * testsuite/libffi.call/cls_12byte.c: Adjust to the C89 style - with no declarations after statements. - * testsuite/libffi.call/cls_16byte.c: Likewise. - * testsuite/libffi.call/cls_18byte.c: Likewise. - * testsuite/libffi.call/cls_19byte.c: Likewise. - * testsuite/libffi.call/cls_1_1byte.c: Likewise. - * testsuite/libffi.call/cls_20byte.c: Likewise. - * testsuite/libffi.call/cls_20byte1.c: Likewise. - * testsuite/libffi.call/cls_24byte.c: Likewise. - * testsuite/libffi.call/cls_2byte.c: Likewise. - * testsuite/libffi.call/cls_3_1byte.c: Likewise. - * testsuite/libffi.call/cls_3byte1.c: Likewise. - * testsuite/libffi.call/cls_3byte2.c: Likewise. - * testsuite/libffi.call/cls_4_1byte.c: Likewise. - * testsuite/libffi.call/cls_4byte.c: Likewise. - * testsuite/libffi.call/cls_5_1_byte.c: Likewise. - * testsuite/libffi.call/cls_5byte.c: Likewise. - * testsuite/libffi.call/cls_64byte.c: Likewise. - * testsuite/libffi.call/cls_6_1_byte.c: Likewise. - * testsuite/libffi.call/cls_6byte.c: Likewise. - * testsuite/libffi.call/cls_7_1_byte.c: Likewise. - * testsuite/libffi.call/cls_7byte.c: Likewise. - * testsuite/libffi.call/cls_8byte.c: Likewise. - * testsuite/libffi.call/cls_9byte1.c: Likewise. - * testsuite/libffi.call/cls_9byte2.c: Likewise. - * testsuite/libffi.call/cls_align_double.c: Likewise. - * testsuite/libffi.call/cls_align_float.c: Likewise. - * testsuite/libffi.call/cls_align_longdouble.c: Likewise. - * testsuite/libffi.call/cls_align_longdouble_split.c: Likewise. - * testsuite/libffi.call/cls_align_longdouble_split2.c: Likewise. - * testsuite/libffi.call/cls_align_pointer.c: Likewise. - * testsuite/libffi.call/cls_align_sint16.c: Likewise. - * testsuite/libffi.call/cls_align_sint32.c: Likewise. - * testsuite/libffi.call/cls_align_sint64.c: Likewise. - * testsuite/libffi.call/cls_align_uint16.c: Likewise. - * testsuite/libffi.call/cls_align_uint32.c: Likewise. - * testsuite/libffi.call/cls_align_uint64.c: Likewise. - * testsuite/libffi.call/cls_dbls_struct.c: Likewise. - * testsuite/libffi.call/cls_pointer_stack.c: Likewise. - * testsuite/libffi.call/err_bad_typedef.c: Likewise. - * testsuite/libffi.call/huge_struct.c: Likewise. - * testsuite/libffi.call/nested_struct.c: Likewise. - * testsuite/libffi.call/nested_struct1.c: Likewise. - * testsuite/libffi.call/nested_struct10.c: Likewise. - * testsuite/libffi.call/nested_struct2.c: Likewise. - * testsuite/libffi.call/nested_struct3.c: Likewise. - * testsuite/libffi.call/nested_struct4.c: Likewise. - * testsuite/libffi.call/nested_struct5.c: Likewise. - * testsuite/libffi.call/nested_struct6.c: Likewise. - * testsuite/libffi.call/nested_struct7.c: Likewise. - * testsuite/libffi.call/nested_struct8.c: Likewise. - * testsuite/libffi.call/nested_struct9.c: Likewise. - * testsuite/libffi.call/stret_large.c: Likewise. - * testsuite/libffi.call/stret_large2.c: Likewise. - * testsuite/libffi.call/stret_medium.c: Likewise. - * testsuite/libffi.call/stret_medium2.c: Likewise. - * testsuite/libffi.call/struct1.c: Likewise. - * testsuite/libffi.call/struct1_win32.c: Likewise. - * testsuite/libffi.call/struct2.c: Likewise. - * testsuite/libffi.call/struct2_win32.c: Likewise. - * testsuite/libffi.call/struct3.c: Likewise. - * testsuite/libffi.call/struct4.c: Likewise. - * testsuite/libffi.call/struct5.c: Likewise. - * testsuite/libffi.call/struct6.c: Likewise. - * testsuite/libffi.call/struct7.c: Likewise. - * testsuite/libffi.call/struct8.c: Likewise. - * testsuite/libffi.call/struct9.c: Likewise. - * testsuite/libffi.call/testclosure.c: Likewise. - -2012-03-21 Peter Rosin - - * testsuite/libffi.call/float_va.c (float_va_fn): Use %f when - printing doubles (%lf is for long doubles). - (main): Likewise. - -2012-03-21 Peter Rosin - - * testsuite/lib/target-libpath.exp [*-*-cygwin*, *-*-mingw*] - (set_ld_library_path_env_vars): Add the library search dir to PATH - (and save PATH for later). - (restore_ld_library_path_env_vars): Restore PATH. - -2012-03-21 Peter Rosin - - * testsuite/lib/target-libpath.exp [*-*-cygwin*, *-*-mingw*] - (set_ld_library_path_env_vars): Add the library search dir to PATH - (and save PATH for later). - (restore_ld_library_path_env_vars): Restore PATH. - -2012-03-20 Peter Rosin - - * testsuite/libffi.call/strlen2_win32.c (main): Remove bug. - * src/x86/win32.S [MSVC] (ffi_closure_SYSV): Make the 'stub' label - visible outside the PROC, so that ffi_closure_THISCALL can see it. - -2012-03-20 Peter Rosin - - * testsuite/libffi.call/strlen2_win32.c (main): Remove bug. - * src/x86/win32.S [MSVC] (ffi_closure_SYSV): Make the 'stub' label - visible outside the PROC, so that ffi_closure_THISCALL can see it. - -2012-03-19 Alan Hourihane - - * src/m68k/ffi.c: Add MINT support. - * src/m68k/sysv.S: Ditto. - -2012-03-06 Chung-Lin Tang - - * src/arm/ffi.c (ffi_call): Add __ARM_EABI__ guard around call to - ffi_call_VFP(). - (ffi_prep_closure_loc): Add __ARM_EABI__ guard around use of - ffi_closure_VFP. - * src/arm/sysv.S: Add __ARM_EABI__ guard around VFP code. - -2012-03-19 chennam - - * src/powerpc/ffi_darwin.c (ffi_prep_closure_loc): Fix AIX closure - support. - -2012-03-13 Kaz Kojima - - * src/sh/ffi.c (ffi_prep_closure_loc): Don't ASSERT ABI test, - just return FFI_BAD_ABI when things are wrong. - * src/sh64/ffi.c (ffi_prep_closure_loc): Ditto. - -2012-03-09 David Edelsohn - - * src/powerpc/aix_closure.S (ffi_closure_ASM): Adjust for Darwin64 - change to return value of ffi_closure_helper_DARWIN and load type - from return type. - -2012-03-03 H.J. Lu - - * src/x86/ffi64.c (ffi_call): Cast the return value to unsigned - long. - (ffi_prep_closure_loc): Cast to 64bit address in trampoline. - (ffi_closure_unix64_inner): Cast return pointer to unsigned long - first. - - * src/x86/ffitarget.h (FFI_SIZEOF_ARG): Defined to 8 for x32. - (ffi_arg): Set to unsigned long long for x32. - (ffi_sarg): Set to long long for x32. - -2012-03-03 H.J. Lu - - * src/prep_cif.c (ffi_prep_cif_core): Properly check bad ABI. - -2012-03-03 Andoni Morales Alastruey - - * configure.ac: Add -no-undefined for both 32- and 64-bit x86 - windows-like hosts. - * configure: Rebuilt. - -2012-02-27 Mikael Pettersson - - PR libffi/52223 - * Makefile.am (FLAGS_TO_PASS): Define. - * Makefile.in: Regenerate. - -2012-02-23 Anthony Green - - * src/*/ffitarget.h: Ensure that users never include ffitarget.h - directly. - -2012-02-23 Kai Tietz - - PR libffi/52221 - * src/x86/ffi.c (ffi_closure_raw_THISCALL): New - prototype. - (ffi_prep_raw_closure_loc): Use ffi_closure_raw_THISCALL for - thiscall-convention. - (ffi_raw_call): Use ffi_prep_args_raw. - * src/x86/win32.S (ffi_closure_raw_THISCALL): Add - implementation for stub. - -2012-02-10 Kai Tietz - - * configure.ac (AM_LTLDFLAGS): Add -no-undefine for x64 - windows target. - * configure: Regenerated. - -2012-02-08 Kai Tietz - - * src/prep_cif.c (ffi_prep_cif): Allow for X86_WIN32 - also FFI_THISCALL. - * src/x86/ffi.c (ffi_closure_THISCALL): Add prototype. - (FFI_INIT_TRAMPOLINE_THISCALL): New trampoline code. - (ffi_prep_closure_loc): Add FFI_THISCALL support. - * src/x86/ffitarget.h (FFI_TRAMPOLINE_SIZE): Adjust size. - * src/x86/win32.S (ffi_closure_THISCALL): New closure code - for thiscall-calling convention. - * testsuite/libffi.call/closure_thiscall.c: New test. - -2012-01-28 Kai Tietz - - * src/libffi/src/x86/ffi.c (ffi_call_win32): Add new - argument to prototype for specify calling-convention. - (ffi_call): Add support for stdcall/thiscall convention. - (ffi_prep_args): Likewise. - (ffi_raw_call): Likewise. - * src/x86/ffitarget.h (ffi_abi): Add FFI_THISCALL and - FFI_FASTCALL. - * src/x86/win32.S (_ffi_call_win32): Add support for - fastcall/thiscall calling-convention calls. - * testsuite/libffi.call/fastthis1_win32.c: New test. - * testsuite/libffi.call/fastthis2_win32.c: New test. - * testsuite/libffi.call/fastthis3_win32.c: New test. - * testsuite/libffi.call/strlen2_win32.c: New test. - * testsuite/libffi.call/many2_win32.c: New test. - * testsuite/libffi.call/struct1_win32.c: New test. - * testsuite/libffi.call/struct2_win32.c: New test. - -2012-01-23 Uros Bizjak - - * src/alpha/ffi.c (ffi_prep_closure_loc): Check for bad ABI. - -2012-01-23 Anthony Green - Chris Young - - * configure.ac: Add Amiga support. - * configure: Rebuilt. - -2012-01-23 Dmitry Nadezhin - - * include/ffi_common.h (LIKELY, UNLIKELY): Fix definitions. - -2012-01-23 Andreas Schwab - - * src/m68k/sysv.S (ffi_call_SYSV): Properly test for plain - mc68000. Test for __HAVE_68881__ in addition to __MC68881__. - -2012-01-19 Jakub Jelinek - - PR rtl-optimization/48496 - * src/ia64/ffi.c (ffi_call): Fix up aliasing violations. - -2012-01-09 Rainer Orth - - * configure.ac (i?86-*-*): Set TARGET to X86_64. - * configure: Regenerate. - -2011-12-07 Andrew Pinski - - PR libffi/50051 - * src/mips/n32.S: Add ".set mips4". - -2011-11-21 Andreas Tobler - - * configure: Regenerate. - -2011-11-12 David Gilbert - - * doc/libffi.texi, include/ffi.h.in, include/ffi_common.h, - man/Makefile.am, man/ffi.3, man/ffi_prep_cif.3, - man/ffi_prep_cif_var.3, src/arm/ffi.c, src/arm/ffitarget.h, - src/cris/ffi.c, src/prep_cif.c, - testsuite/libffi.call/cls_double_va.c, - testsuite/libffi.call/cls_longdouble_va.c, - testsuite/libffi.call/float_va.c: Many changes to support variadic - function calls. - -2011-11-12 Kyle Moffett - - * src/powerpc/ffi.c, src/powerpc/ffitarget.h, - src/powerpc/ppc_closure.S, src/powerpc/sysv.S: Many changes for - softfloat powerpc variants. - -2011-11-12 Petr Salinger - - * configure.ac (FFI_EXEC_TRAMPOLINE_TABLE): Fix kfreebsd support. - * configure: Rebuilt. - -2011-11-12 Timothy Wall - - * src/arm/ffi.c (ffi_prep_args, ffi_prep_incoming_args_SYSV): Max - alignment of 4 for wince on ARM. - -2011-11-12 Kyle Moffett - Anthony Green - - * src/ppc/sysv.S, src/ppc/ffi.c: Remove use of ppc string - instructions (not available on some cores, like the PPC440). - -2011-11-12 Kimura Wataru - - * m4/ax_enable_builddir: Change from string comparison to numeric - comparison for wc output. - * configure.ac: Enable FFI_MMAP_EXEC_WRIT for darwin11 aka Mac OS - X 10.7. - * configure: Rebuilt. - -2011-11-12 Anthony Green - - * Makefile.am (AM_CCASFLAGS): Add -g option to build assembly - files with debug info. - * Makefile.in: Rebuilt. - -2011-11-12 Jasper Lievisse Adriaanse - - * README: Update list of supported OpenBSD systems. - -2011-11-12 Anthony Green - - * libtool-version: Update. - * Makefile.am (nodist_libffi_la_SOURCES): Add src/debug.c if - FFI_DEBUG. - (libffi_la_SOURCES): Remove src/debug.c - (EXTRA_DIST): Add src/debug.c - * Makefile.in: Rebuilt. - * README: Update for 3.0.11. - -2011-11-10 Richard Henderson - - * configure.ac (GCC_AS_CFI_PSEUDO_OP): Use it instead of inline check. - * configure, aclocal.m4: Rebuild. - -2011-09-04 Iain Sandoe - - PR libffi/49594 - * src/powerpc/darwin_closure.S (stubs): Make the stub binding - helper reference track the architecture pointer size. - -2011-08-25 Andrew Haley - - * src/arm/ffi.c (FFI_INIT_TRAMPOLINE): Remove hard-coded assembly - instructions. - * src/arm/sysv.S (ffi_arm_trampoline): Put them here instead. - -2011-07-11 Andrew Haley - - * src/arm/ffi.c (FFI_INIT_TRAMPOLINE): Clear icache. - -2011-06-29 Rainer Orth - - * testsuite/libffi.call/cls_double_va.c: Move PR number to comment. - * testsuite/libffi.call/cls_longdouble_va.c: Likewise. - -2011-06-29 Rainer Orth - - PR libffi/46660 - * testsuite/libffi.call/cls_double_va.c: xfail dg-output on - mips-sgi-irix6*. - * testsuite/libffi.call/cls_longdouble_va.c: Likewise. - -2011-06-14 Rainer Orth - - * testsuite/libffi.call/huge_struct.c (test_large_fn): Use PRIu8, - PRId8 instead of %hhu, %hhd. - * testsuite/libffi.call/ffitest.h [__alpha__ && __osf__] (PRId8, - PRIu8): Define. - [__sgi__] (PRId8, PRIu8): Define. - -2011-04-29 Rainer Orth - - * src/alpha/osf.S (UA_SI, FDE_ENCODING, FDE_ENCODE, FDE_ARANGE): - Define. - Use them to handle ELF vs. ECOFF differences. - [__osf__] (_GLOBAL__F_ffi_call_osf): Define. - -2011-03-30 Timothy Wall - - * src/powerpc/darwin.S: Fix unknown FDE encoding. - * src/powerpc/darwin_closure.S: ditto. - -2011-02-25 Anthony Green - - * src/powerpc/ffi.c (ffi_prep_closure_loc): Allow for more - 32-bit ABIs. - -2011-02-15 Anthony Green - - * m4/ax_cc_maxopt.m4: Don't -malign-double or use -ffast-math. - * configure: Rebuilt. - -2011-02-13 Ralf Wildenhues - - * configure: Regenerate. - -2011-02-13 Anthony Green - - * include/ffi_common.h (UNLIKELY, LIKELY): Define. - * src/x86/ffi64.c (UNLIKELY, LIKELY): Remove definition. - * src/prep_cif.c (UNLIKELY, LIKELY): Remove definition. - - * src/prep_cif.c (initialize_aggregate): Convert assertion into - FFI_BAD_TYPEDEF return. Initialize arg size and alignment to 0. - - * src/pa/ffi.c (ffi_prep_closure_loc): Don't ASSERT ABI test, - just return FFI_BAD_ABI when things are wrong. - * src/arm/ffi.c (ffi_prep_closure_loc): Ditto. - * src/powerpc/ffi.c (ffi_prep_closure_loc): Ditto. - * src/mips/ffi.c (ffi_prep_closure_loc): Ditto. - * src/ia64/ffi.c (ffi_prep_closure_loc): Ditto. - * src/avr32/ffi.c (ffi_prep_closure_loc): Ditto. - -2011-02-11 Anthony Green - - * src/sparc/ffi.c (ffi_prep_closure_loc): Don't ASSERT ABI test, - just return FFI_BAD_ABI when things are wrong. - -2012-02-11 Eric Botcazou - - * src/sparc/v9.S (STACKFRAME): Bump to 176. - -2011-02-09 Stuart Shelton - - http://bugs.gentoo.org/show_bug.cgi?id=286911 - * src/mips/ffitarget.h: Clean up error messages. - * src/java_raw_api.c (ffi_java_translate_args): Cast raw arg to - ffi_raw*. - * include/ffi.h.in: Add pragma for SGI compiler. - -2011-02-09 Anthony Green - - * configure.ac: Add powerpc64-*-darwin* support. - -2011-02-09 Anthony Green - - * README: Mention Interix. - -2011-02-09 Jonathan Callen - - * configure.ac: Add Interix to win32/cygwin/mingw case. - * configure: Ditto. - * src/closures.c: Treat Interix like Cygwin, instead of as a - generic win32. - -2011-02-09 Anthony Green - - * testsuite/libffi.call/err_bad_typedef.c: Remove xfail. - * testsuite/libffi.call/err_bad_abi.c: Remove xfail. - * src/x86/ffi64.c (UNLIKELY, LIKELY): Define. - (ffi_prep_closure_loc): Check for bad ABI. - * src/prep_cif.c (UNLIKELY, LIKELY): Define. - (initialize_aggregate): Check for bad types. - -2011-02-09 Landon Fuller - - * Makefile.am (EXTRA_DIST): Add build-ios.sh, src/arm/gentramp.sh, - src/arm/trampoline.S. - (nodist_libffi_la_SOURCES): Add src/arc/trampoline.S. - * configure.ac (FFI_EXEC_TRAMPOLINE_TABLE): Define. - * src/arm/ffi.c (ffi_trampoline_table) - (ffi_closure_trampoline_table_page, ffi_trampoline_table_entry) - (FFI_TRAMPOLINE_CODELOC_CONFIG, FFI_TRAMPOLINE_CONFIG_PAGE_OFFSET) - (FFI_TRAMPOLINE_COUNT, ffi_trampoline_lock, ffi_trampoline_tables) - (ffi_trampoline_table_alloc, ffi_closure_alloc, ffi_closure_free): - Define for FFI_EXEC_TRAMPOLINE_TABLE case (iOS). - (ffi_prep_closure_loc): Handl FFI_EXEC_TRAMPOLINE_TABLE case - separately. - * src/arm/sysv.S: Handle Apple iOS host. - * src/closures.c: Handle FFI_EXEC_TRAMPOLINE_TABLE case. - * build-ios.sh: New file. - * fficonfig.h.in, configure, Makefile.in: Rebuilt. - * README: Mention ARM iOS. - -2011-02-08 Oren Held - - * src/dlmalloc.c (_STRUCT_MALLINFO): Define in order to avoid - redefinition of mallinfo on HP-UX. - -2011-02-08 Ginn Chen - - * src/sparc/ffi.c (ffi_call): Make compatible with Solaris Studio - aggregate return ABI. Flush cache. - (ffi_prep_closure_loc): Flush cache. - -2011-02-11 Anthony Green - - From Tom Honermann : - * src/powerpc/aix.S (ffi_call_AIX): Support for xlc toolchain on - AIX. Declare .ffi_prep_args. Insert nops after branch - instructions so that the AIX linker can insert TOC reload - instructions. - * src/powerpc/aix_closure.S: Declare .ffi_closure_helper_DARWIN. - -2011-02-08 Ed - - * src/powerpc/asm.h: Fix grammar nit in comment. - -2011-02-08 Uli Link - - * include/ffi.h.in (FFI_64_BIT_MAX): Define and use. - -2011-02-09 Rainer Orth - - PR libffi/46661 - * testsuite/libffi.call/cls_pointer.c (main): Cast void * to - uintptr_t first. - * testsuite/libffi.call/cls_pointer_stack.c (main): Likewise. - -2011-02-08 Rafael Avila de Espindola - - * configure.ac: Fix x86 test for pc related relocs. - * configure: Rebuilt. - -2011-02-07 Joel Sherrill - - * libffi/src/m68k/ffi.c: Add RTEMS support for cache flushing. - Handle case when CPU variant does not have long double support. - * libffi/src/m68k/sysv.S: Add support for mc68000, Coldfire, - and cores with soft floating point. - -2011-02-07 Joel Sherrill - - * configure.ac: Add mips*-*-rtems* support. - * configure: Regenerate. - * src/mips/ffitarget.h: Ensure needed constants are available - for targets which do not have sgidefs.h. - -2011-01-26 Dave Korn - - PR target/40125 - * configure.ac (AM_LTLDFLAGS): Add -bindir option for windows DLLs. - * configure: Regenerate. - -2010-12-18 Iain Sandoe - - PR libffi/29152 - PR libffi/42378 - * src/powerpc/darwin_closure.S: Provide Darwin64 implementation, - update comments. - * src/powerpc/ffitarget.h (POWERPC_DARWIN64): New, - (FFI_TRAMPOLINE_SIZE): Update for Darwin64. - * src/powerpc/darwin.S: Provide Darwin64 implementation, - update comments. - * src/powerpc/ffi_darwin.c: Likewise. - -2010-12-06 Rainer Orth - - * configure.ac (libffi_cv_as_ascii_pseudo_op): Use double - backslashes. - (libffi_cv_as_string_pseudo_op): Likewise. - * configure: Regenerate. - -2010-12-03 Chung-Lin Tang - - * src/arm/sysv.S (ffi_closure_SYSV): Add UNWIND to .pad directive. - (ffi_closure_VFP): Same. - (ffi_call_VFP): Move down to before ffi_closure_VFP. Add '.fpu vfp' - directive. - -2010-12-01 Rainer Orth - - * testsuite/libffi.call/ffitest.h [__sgi] (PRId64, PRIu64): Define. - (PRIuPTR): Define. - -2010-11-29 Richard Henderson - Rainer Orth - - * src/x86/sysv.S (FDE_ENCODING, FDE_ENCODE): Define. - (.eh_frame): Use FDE_ENCODING. - (.LASFDE1, .LASFDE2, LASFDE3): Simplify with FDE_ENCODE. - -2010-11-22 Jacek Caban - - * configure.ac: Check for symbol underscores on mingw-w64. - * configure: Rebuilt. - * src/x86/win64.S: Correctly access extern symbols in respect to - underscores. - -2010-11-15 Rainer Orth - - * testsuite/lib/libffi-dg.exp: Rename ... - * testsuite/lib/libffi.exp: ... to this. - * libffi/testsuite/libffi.call/call.exp: Don't load libffi-dg.exp. - * libffi/testsuite/libffi.special/special.exp: Likewise. - -2010-10-28 Chung-Lin Tang - - * src/arm/ffi.c (ffi_prep_args): Add VFP register argument handling - code, new parameter, and return value. Update comments. - (ffi_prep_cif_machdep): Add case for VFP struct return values. Add - call to layout_vfp_args(). - (ffi_call_SYSV): Update declaration. - (ffi_call_VFP): New declaration. - (ffi_call): Add VFP struct return conditions. Call ffi_call_VFP() - when ABI is FFI_VFP. - (ffi_closure_VFP): New declaration. - (ffi_closure_SYSV_inner): Add new vfp_args parameter, update call to - ffi_prep_incoming_args_SYSV(). - (ffi_prep_incoming_args_SYSV): Update parameters. Add VFP argument - case handling. - (ffi_prep_closure_loc): Pass ffi_closure_VFP to trampoline - construction under VFP hard-float. - (rec_vfp_type_p): New function. - (vfp_type_p): Same. - (place_vfp_arg): Same. - (layout_vfp_args): Same. - * src/arm/ffitarget.h (ffi_abi): Add FFI_VFP. Define FFI_DEFAULT_ABI - based on __ARM_PCS_VFP. - (FFI_EXTRA_CIF_FIELDS): Define for adding VFP hard-float specific - fields. - (FFI_TYPE_STRUCT_VFP_FLOAT): Define internally used type code. - (FFI_TYPE_STRUCT_VFP_DOUBLE): Same. - * src/arm/sysv.S (ffi_call_SYSV): Change call of ffi_prep_args() to - direct call. Move function pointer load upwards. - (ffi_call_VFP): New function. - (ffi_closure_VFP): Same. - - * testsuite/lib/libffi-dg.exp (check-flags): New function. - (dg-skip-if): New function. - * testsuite/libffi.call/cls_double_va.c: Skip if target is arm*-*-* - and compiler options include -mfloat-abi=hard. - * testsuite/libffi.call/cls_longdouble_va.c: Same. - -2010-10-01 Jakub Jelinek - - PR libffi/45677 - * src/x86/ffi64.c (ffi_prep_cif_machdep): Ensure cif->bytes is - a multiple of 8. - * testsuite/libffi.call/many2.c: New test. - -2010-08-20 Mark Wielaard - - * src/closures.c (open_temp_exec_file_mnt): Check if getmntent_r - returns NULL. - -2010-08-09 Andreas Tobler - - * configure.ac: Add target powerpc64-*-freebsd*. - * configure: Regenerate. - * testsuite/libffi.call/cls_align_longdouble_split.c: Pass - -mlong-double-128 only to linux targets. - * testsuite/libffi.call/cls_align_longdouble_split2.c: Likewise. - * testsuite/libffi.call/cls_longdouble.c: Likewise. - * testsuite/libffi.call/huge_struct.c: Likewise. - -2010-08-05 Dan Witte - - * Makefile.am: Pass FFI_DEBUG define to msvcc.sh for linking to the - debug CRT when --enable-debug is given. - * configure.ac: Define it. - * msvcc.sh: Translate -g and -DFFI_DEBUG appropriately. - -2010-08-04 Dan Witte - - * src/x86/ffitarget.h: Add X86_ANY define for all x86/x86_64 - platforms. - * src/x86/ffi.c: Remove redundant ifdef checks. - * src/prep_cif.c: Push stack space computation into src/x86/ffi.c - for X86_ANY so return value space doesn't get added twice. - -2010-08-03 Neil Rashbrooke - - * msvcc.sh: Don't pass -safeseh to ml64 because behavior is buggy. - -2010-07-22 Dan Witte - - * src/*/ffitarget.h: Make FFI_LAST_ABI one past the last valid ABI. - * src/prep_cif.c: Fix ABI assertion. - * src/cris/ffi.c: Ditto. - -2010-07-10 Evan Phoenix - - * src/closures.c (selinux_enabled_check): Fix strncmp usage bug. - -2010-07-07 Dan Horák - - * include/ffi.h.in: Protect #define with #ifndef. - * src/powerpc/ffitarget.h: Ditto. - * src/s390/ffitarget.h: Ditto. - * src/sparc/ffitarget.h: Ditto. - -2010-07-07 Neil Roberts - - * src/x86/sysv.S (ffi_call_SYSV): Align the stack pointer to - 16-bytes. - -2010-07-02 Jakub Jelinek - - * Makefile.am (AM_MAKEFLAGS): Pass also mandir to submakes. - * Makefile.in: Regenerated. - -2010-05-19 Rainer Orth - - * configure.ac (libffi_cv_as_x86_pcrel): Check for illegal in as - output, too. - (libffi_cv_as_ascii_pseudo_op): Check for .ascii. - (libffi_cv_as_string_pseudo_op): Check for .string. - * configure: Regenerate. - * fficonfig.h.in: Regenerate. - * src/x86/sysv.S (.eh_frame): Use .ascii, .string or error. - -2010-05-11 Dan Witte - - * doc/libffi.tex: Document previous change. - -2010-05-11 Makoto Kato - - * src/x86/ffi.c (ffi_call): Don't copy structs passed by value. - -2010-05-05 Michael Kohler - - * src/dlmalloc.c (dlfree): Fix spelling. - * src/ia64/ffi.c (ffi_prep_cif_machdep): Ditto. - * configure.ac: Ditto. - * configure: Rebuilt. - -2010-04-13 Dan Witte - - * msvcc.sh: Build with -W3 instead of -Wall. - * src/powerpc/ffi_darwin.c: Remove build warnings. - * src/x86/ffi.c: Ditto. - * src/x86/ffitarget.h: Ditto. - -2010-04-12 Dan Witte - Walter Meinl - - * configure.ac: Add OS/2 support. - * configure: Rebuilt. - * src/closures.c: Ditto. - * src/dlmalloc.c: Ditto. - * src/x86/win32.S: Ditto. - -2010-04-07 Jakub Jelinek - - * testsuite/libffi.call/err_bad_abi.c: Remove unused args variable. - -2010-04-02 Ralf Wildenhues - - * Makefile.in: Regenerate. - * aclocal.m4: Regenerate. - * include/Makefile.in: Regenerate. - * man/Makefile.in: Regenerate. - * testsuite/Makefile.in: Regenerate. - -2010-03-30 Dan Witte - - * msvcc.sh: Disable build warnings. - * README (tested): Clarify windows build procedure. - -2010-03-15 Rainer Orth - - * configure.ac (libffi_cv_as_x86_64_unwind_section_type): New test. - * configure: Regenerate. - * fficonfig.h.in: Regenerate. - * libffi/src/x86/unix64.S (.eh_frame) - [HAVE_AS_X86_64_UNWIND_SECTION_TYPE]: Use @unwind section type. - 2010-03-14 Matthias Klose * src/x86/ffi64.c: Fix typo in comment. * src/x86/ffi.c: Use /* ... */ comment style. -2010-02-24 Rainer Orth - - * doc/libffi.texi (The Closure API): Fix typo. - * doc/libffi.info: Remove. - -2010-02-15 Matthias Klose - - * src/arm/sysv.S (__ARM_ARCH__): Define for processor - __ARM_ARCH_7EM__. - -2010-01-15 Anthony Green - - * README: Add notes on building with Microsoft Visual C++. - -2010-01-15 Daniel Witte - - * msvcc.sh: New file. - - * src/x86/win32.S: Port assembly routines to MSVC and #ifdef. - * src/x86/ffi.c: Tweak function declaration and remove excess - parens. - * include/ffi.h.in: Add __declspec(align(8)) to typedef struct - ffi_closure. - - * src/x86/ffi.c: Merge ffi_call_SYSV and ffi_call_STDCALL into new - function ffi_call_win32 on X86_WIN32. - * src/x86/win32.S (ffi_call_SYSV): Rename to ffi_call_win32. - (ffi_call_STDCALL): Remove. - - * src/prep_cif.c (ffi_prep_cif): Move stack space allocation code - to ffi_prep_cif_machdep for x86. - * src/x86/ffi.c (ffi_prep_cif_machdep): To here. - -2010-01-15 Oliver Kiddle - - * src/x86/ffitarget.h (ffi_abi): Check for __i386 and __amd64 for - Sun Studio compiler compatibility. - -2010-01-12 Conrad Irwin - - * doc/libffi.texi: Add closure example. - 2010-01-07 Rainer Orth PR libffi/40701 @@ -1500,13 +148,6 @@ * src/pa/ffi.c (ffi_closure_inner_pa32): Handle FFI_TYPE_LONGDOUBLE type on HP-UX. -2012-02-13 Kai Tietz - - PR libffi/52221 - * src/x86/ffi.c (ffi_prep_raw_closure_loc): Add thiscall - support for X86_WIN32. - (FFI_INIT_TRAMPOLINE_THISCALL): Fix displacement. - 2009-12-11 Eric Botcazou * src/sparc/ffi.c (ffi_closure_sparc_inner_v9): Properly align 'long @@ -1681,11 +322,6 @@ * man/Makefile.in: Regenerate. * testsuite/Makefile.in: Regenerate. -2011-08-22 Jasper Lievisse Adriaanse - - * configure.ac: Add OpenBSD/hppa and OpenBSD/powerpc support. - * configure: Rebuilt. - 2009-07-30 Ralf Wildenhues * configure.ac (_AC_ARG_VAR_PRECIOUS): Use m4_rename_force. diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi/ChangeLog.libffi --- a/Modules/_ctypes/libffi/ChangeLog.libffi Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/_ctypes/libffi/ChangeLog.libffi Sun Jul 20 10:52:46 2014 -0400 @@ -1,6 +1,35 @@ -2011-02-08 Andreas Tobler +2010-01-15 Anthony Green - * testsuite/lib/libffi.exp: Tweak for stand-alone mode. + * README: Add notes on building with Microsoft Visual C++. + +2010-01-15 Daniel Witte + + * msvcc.sh: New file. + + * src/x86/win32.S: Port assembly routines to MSVC and #ifdef. + * src/x86/ffi.c: Tweak function declaration and remove excess + parens. + * include/ffi.h.in: Add __declspec(align(8)) to typedef struct + ffi_closure. + + * src/x86/ffi.c: Merge ffi_call_SYSV and ffi_call_STDCALL into new + function ffi_call_win32 on X86_WIN32. + * src/x86/win32.S (ffi_call_SYSV): Rename to ffi_call_win32. + (ffi_call_STDCALL): Remove. + + * src/prep_cif.c (ffi_prep_cif): Move stack space allocation code + to ffi_prep_cif_machdep for x86. + * src/x86/ffi.c (ffi_prep_cif_machdep): To here. + +2010-01-15 Oliver Kiddle + + * src/x86/ffitarget.h (ffi_abi): Check for __i386 and __amd64 for + Sun Studio compiler compatibility. + +2010-01-12 Conrad Irwin + + * doc/libffi.texi: Add closure example. + * doc/libffi.info: Rebuilt. 2009-12-25 Samuli Suominen @@ -574,8 +603,8 @@ * Makefile.am, include/Makefile.am: Move headers to libffi_la_SOURCES for new automake. * Makefile.in, include/Makefile.in: Rebuilt. - - * testsuite/lib/wrapper.exp: Copied from gcc tree to allow for + + * testsuite/lib/wrapper.exp: Copied from gcc tree to allow for execution outside of gcc tree. * testsuite/lib/target-libpath.exp: Ditto. diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi/LICENSE --- a/Modules/_ctypes/libffi/LICENSE Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/_ctypes/libffi/LICENSE Sun Jul 20 10:52:46 2014 -0400 @@ -1,4 +1,4 @@ -libffi - Copyright (c) 1996-2012 Anthony Green, Red Hat, Inc and others. +libffi - Copyright (c) 1996-2009 Anthony Green, Red Hat, Inc and others. See source files for details. Permission is hereby granted, free of charge, to any person obtaining @@ -9,8 +9,8 @@ permit persons to whom the Software is furnished to do so, subject to the following conditions: -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. +The above copyright notice and this permission notice shall be included +in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi/Makefile.am --- a/Modules/_ctypes/libffi/Makefile.am Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/_ctypes/libffi/Makefile.am Sun Jul 20 10:52:46 2014 -0400 @@ -2,50 +2,37 @@ AUTOMAKE_OPTIONS = foreign subdir-objects -ACLOCAL_AMFLAGS = -I m4 - SUBDIRS = include testsuite man -EXTRA_DIST = LICENSE ChangeLog.v1 ChangeLog.libgcj configure.host \ - src/aarch64/ffi.c src/aarch64/ffitarget.h src/aarch64/sysv.S \ - build-ios.sh src/alpha/ffi.c src/alpha/osf.S \ - src/alpha/ffitarget.h src/arm/ffi.c src/arm/sysv.S \ - src/arm/ffitarget.h src/avr32/ffi.c src/avr32/sysv.S \ - src/avr32/ffitarget.h src/cris/ffi.c src/cris/sysv.S \ - src/cris/ffitarget.h src/ia64/ffi.c src/ia64/ffitarget.h \ - src/ia64/ia64_flags.h src/ia64/unix.S src/mips/ffi.c \ - src/mips/n32.S src/mips/o32.S src/metag/ffi.c \ - src/metag/ffitarget.h src/metag/sysv.S src/moxie/ffi.c \ - src/moxie/ffitarget.h src/moxie/eabi.S src/mips/ffitarget.h \ - src/m32r/ffi.c src/m32r/sysv.S src/m32r/ffitarget.h \ - src/m68k/ffi.c src/m68k/sysv.S src/m68k/ffitarget.h \ - src/microblaze/ffi.c src/microblaze/sysv.S \ - src/microblaze/ffitarget.h src/powerpc/ffi.c \ - src/powerpc/sysv.S src/powerpc/linux64.S \ - src/powerpc/linux64_closure.S src/powerpc/ppc_closure.S \ - src/powerpc/asm.h src/powerpc/aix.S src/powerpc/darwin.S \ - src/powerpc/aix_closure.S src/powerpc/darwin_closure.S \ - src/powerpc/ffi_darwin.c src/powerpc/ffitarget.h \ - src/s390/ffi.c src/s390/sysv.S src/s390/ffitarget.h \ - src/sh/ffi.c src/sh/sysv.S src/sh/ffitarget.h src/sh64/ffi.c \ - src/sh64/sysv.S src/sh64/ffitarget.h src/sparc/v8.S \ - src/sparc/v9.S src/sparc/ffitarget.h src/sparc/ffi.c \ - src/x86/darwin64.S src/x86/ffi.c src/x86/sysv.S \ - src/x86/win32.S src/x86/darwin.S src/x86/win64.S \ - src/x86/freebsd.S src/x86/ffi64.c src/x86/unix64.S \ - src/x86/ffitarget.h src/pa/ffitarget.h src/pa/ffi.c \ - src/pa/linux.S src/pa/hpux32.S src/frv/ffi.c src/bfin/ffi.c \ - src/bfin/ffitarget.h src/bfin/sysv.S src/frv/eabi.S \ - src/frv/ffitarget.h src/dlmalloc.c src/tile/ffi.c \ - src/tile/ffitarget.h src/tile/tile.S libtool-version \ - src/xtensa/ffitarget.h src/xtensa/ffi.c src/xtensa/sysv.S \ - ChangeLog.libffi m4/libtool.m4 m4/lt~obsolete.m4 \ - m4/ltoptions.m4 m4/ltsugar.m4 m4/ltversion.m4 \ - m4/ltversion.m4 src/arm/gentramp.sh src/debug.c msvcc.sh \ - generate-ios-source-and-headers.py \ - generate-osx-source-and-headers.py \ - libffi.xcodeproj/project.pbxproj src/arm/trampoline.S \ - libtool-ldflags +EXTRA_DIST = LICENSE ChangeLog.v1 ChangeLog.libgcj configure.host \ + src/alpha/ffi.c src/alpha/osf.S src/alpha/ffitarget.h \ + src/arm/ffi.c src/arm/sysv.S src/arm/ffitarget.h \ + src/avr32/ffi.c src/avr32/sysv.S src/avr32/ffitarget.h \ + src/cris/ffi.c src/cris/sysv.S src/cris/ffitarget.h \ + src/ia64/ffi.c src/ia64/ffitarget.h src/ia64/ia64_flags.h \ + src/ia64/unix.S \ + src/mips/ffi.c src/mips/n32.S src/mips/o32.S \ + src/mips/ffitarget.h \ + src/m32r/ffi.c src/m32r/sysv.S src/m32r/ffitarget.h \ + src/m68k/ffi.c src/m68k/sysv.S src/m68k/ffitarget.h \ + src/powerpc/ffi.c src/powerpc/sysv.S \ + src/powerpc/linux64.S src/powerpc/linux64_closure.S \ + src/powerpc/ppc_closure.S src/powerpc/asm.h \ + src/powerpc/aix.S src/powerpc/darwin.S \ + src/powerpc/aix_closure.S src/powerpc/darwin_closure.S \ + src/powerpc/ffi_darwin.c src/powerpc/ffitarget.h \ + src/s390/ffi.c src/s390/sysv.S src/s390/ffitarget.h \ + src/sh/ffi.c src/sh/sysv.S src/sh/ffitarget.h \ + src/sh64/ffi.c src/sh64/sysv.S src/sh64/ffitarget.h \ + src/sparc/v8.S src/sparc/v9.S src/sparc/ffitarget.h \ + src/sparc/ffi.c src/x86/darwin64.S \ + src/x86/ffi.c src/x86/sysv.S src/x86/win32.S src/x86/win64.S \ + src/x86/darwin.S src/x86/freebsd.S \ + src/x86/ffi64.c src/x86/unix64.S src/x86/ffitarget.h \ + src/pa/ffitarget.h src/pa/ffi.c src/pa/linux.S src/pa/hpux32.S \ + src/frv/ffi.c src/frv/eabi.S src/frv/ffitarget.h src/dlmalloc.c \ + libtool-version ChangeLog.libffi m4/libtool.m4 \ + m4/lt~obsolete.m4 m4/ltoptions.m4 m4/ltsugar.m4 m4/ltversion.m4 info_TEXINFOS = doc/libffi.texi @@ -82,7 +69,6 @@ "exec_prefix=$(exec_prefix)" \ "infodir=$(infodir)" \ "libdir=$(libdir)" \ - "mandir=$(mandir)" \ "prefix=$(prefix)" \ "AR=$(AR)" \ "AS=$(AS)" \ @@ -93,15 +79,14 @@ "RANLIB=$(RANLIB)" \ "DESTDIR=$(DESTDIR)" -# Subdir rules rely on $(FLAGS_TO_PASS) -FLAGS_TO_PASS = $(AM_MAKEFLAGS) - MAKEOVERRIDES= -toolexeclib_LTLIBRARIES = libffi.la +ACLOCAL_AMFLAGS=$(ACLOCAL_AMFLAGS) -I m4 + +lib_LTLIBRARIES = libffi.la noinst_LTLIBRARIES = libffi_convenience.la -libffi_la_SOURCES = src/prep_cif.c src/types.c \ +libffi_la_SOURCES = src/debug.c src/prep_cif.c src/types.c \ src/raw_api.c src/java_raw_api.c src/closures.c pkgconfigdir = $(libdir)/pkgconfig @@ -109,16 +94,9 @@ nodist_libffi_la_SOURCES = -if FFI_DEBUG -nodist_libffi_la_SOURCES += src/debug.c -endif - if MIPS nodist_libffi_la_SOURCES += src/mips/ffi.c src/mips/o32.S src/mips/n32.S endif -if BFIN -nodist_libffi_la_SOURCES += src/bfin/ffi.c src/bfin/sysv.S -endif if X86 nodist_libffi_la_SOURCES += src/x86/ffi.c src/x86/sysv.S endif @@ -149,12 +127,6 @@ if M68K nodist_libffi_la_SOURCES += src/m68k/ffi.c src/m68k/sysv.S endif -if MOXIE -nodist_libffi_la_SOURCES += src/moxie/ffi.c src/moxie/eabi.S -endif -if MICROBLAZE -nodist_libffi_la_SOURCES += src/microblaze/ffi.c src/microblaze/sysv.S -endif if POWERPC nodist_libffi_la_SOURCES += src/powerpc/ffi.c src/powerpc/sysv.S src/powerpc/ppc_closure.S src/powerpc/linux64.S src/powerpc/linux64_closure.S endif @@ -167,14 +139,8 @@ if POWERPC_FREEBSD nodist_libffi_la_SOURCES += src/powerpc/ffi.c src/powerpc/sysv.S src/powerpc/ppc_closure.S endif -if AARCH64 -nodist_libffi_la_SOURCES += src/aarch64/sysv.S src/aarch64/ffi.c -endif if ARM nodist_libffi_la_SOURCES += src/arm/sysv.S src/arm/ffi.c -if FFI_EXEC_TRAMPOLINE_TABLE -nodist_libffi_la_SOURCES += src/arm/trampoline.S -endif endif if AVR32 nodist_libffi_la_SOURCES += src/avr32/sysv.S src/avr32/ffi.c @@ -203,23 +169,18 @@ if PA_HPUX nodist_libffi_la_SOURCES += src/pa/hpux32.S src/pa/ffi.c endif -if TILE -nodist_libffi_la_SOURCES += src/tile/tile.S src/tile/ffi.c -endif -if XTENSA -nodist_libffi_la_SOURCES += src/xtensa/sysv.S src/xtensa/ffi.c -endif -if METAG -nodist_libffi_la_SOURCES += src/metag/sysv.S src/metag/ffi.c -endif libffi_convenience_la_SOURCES = $(libffi_la_SOURCES) nodist_libffi_convenience_la_SOURCES = $(nodist_libffi_la_SOURCES) -LTLDFLAGS = $(shell $(SHELL) $(top_srcdir)/libtool-ldflags $(LDFLAGS)) +AM_CFLAGS = -Wall -g -fexceptions -libffi_la_LDFLAGS = -no-undefined -version-info `grep -v '^\#' $(srcdir)/libtool-version` $(LTLDFLAGS) $(AM_LTLDFLAGS) +libffi_la_LDFLAGS = -version-info `grep -v '^\#' $(srcdir)/libtool-version` $(LTLDFLAGS) $(AM_LTLDFLAGS) AM_CPPFLAGS = -I. -I$(top_srcdir)/include -Iinclude -I$(top_srcdir)/src AM_CCASFLAGS = $(AM_CPPFLAGS) +# No install-html or install-pdf support in automake yet +.PHONY: install-html install-pdf +install-html: +install-pdf: diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi/Makefile.in --- a/Modules/_ctypes/libffi/Makefile.in Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/_ctypes/libffi/Makefile.in Sun Jul 20 10:52:46 2014 -0400 @@ -1,8 +1,9 @@ -# Makefile.in generated by automake 1.12.2 from Makefile.am. +# Makefile.in generated by automake 1.11 from Makefile.am. # @configure_input@ -# Copyright (C) 1994-2012 Free Software Foundation, Inc. - +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, +# Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. @@ -16,23 +17,6 @@ VPATH = @srcdir@ -am__make_dryrun = \ - { \ - am__dry=no; \ - case $$MAKEFLAGS in \ - *\\[\ \ ]*) \ - echo 'am--echo: ; @echo "AM" OK' | $(MAKE) -f - 2>/dev/null \ - | grep '^AM OK$$' >/dev/null || am__dry=yes;; \ - *) \ - for am__flg in $$MAKEFLAGS; do \ - case $$am__flg in \ - *=*|--*) ;; \ - *n*) am__dry=yes; break;; \ - esac; \ - done;; \ - esac; \ - test $$am__dry = yes; \ - } pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ @@ -52,40 +36,31 @@ build_triplet = @build@ host_triplet = @host@ target_triplet = @target@ -@FFI_DEBUG_TRUE@am__append_1 = src/debug.c -@MIPS_TRUE@am__append_2 = src/mips/ffi.c src/mips/o32.S src/mips/n32.S -@BFIN_TRUE@am__append_3 = src/bfin/ffi.c src/bfin/sysv.S -@X86_TRUE@am__append_4 = src/x86/ffi.c src/x86/sysv.S -@X86_FREEBSD_TRUE@am__append_5 = src/x86/ffi.c src/x86/freebsd.S -@X86_WIN32_TRUE@am__append_6 = src/x86/ffi.c src/x86/win32.S -@X86_WIN64_TRUE@am__append_7 = src/x86/ffi.c src/x86/win64.S -@X86_DARWIN_TRUE@am__append_8 = src/x86/ffi.c src/x86/darwin.S src/x86/ffi64.c src/x86/darwin64.S -@SPARC_TRUE@am__append_9 = src/sparc/ffi.c src/sparc/v8.S src/sparc/v9.S -@ALPHA_TRUE@am__append_10 = src/alpha/ffi.c src/alpha/osf.S -@IA64_TRUE@am__append_11 = src/ia64/ffi.c src/ia64/unix.S -@M32R_TRUE@am__append_12 = src/m32r/sysv.S src/m32r/ffi.c -@M68K_TRUE@am__append_13 = src/m68k/ffi.c src/m68k/sysv.S -@MOXIE_TRUE@am__append_14 = src/moxie/ffi.c src/moxie/eabi.S -@MICROBLAZE_TRUE@am__append_15 = src/microblaze/ffi.c src/microblaze/sysv.S -@POWERPC_TRUE@am__append_16 = src/powerpc/ffi.c src/powerpc/sysv.S src/powerpc/ppc_closure.S src/powerpc/linux64.S src/powerpc/linux64_closure.S -@POWERPC_AIX_TRUE@am__append_17 = src/powerpc/ffi_darwin.c src/powerpc/aix.S src/powerpc/aix_closure.S -@POWERPC_DARWIN_TRUE@am__append_18 = src/powerpc/ffi_darwin.c src/powerpc/darwin.S src/powerpc/darwin_closure.S -@POWERPC_FREEBSD_TRUE@am__append_19 = src/powerpc/ffi.c src/powerpc/sysv.S src/powerpc/ppc_closure.S -@AARCH64_TRUE@am__append_20 = src/aarch64/sysv.S src/aarch64/ffi.c -@ARM_TRUE@am__append_21 = src/arm/sysv.S src/arm/ffi.c -@ARM_TRUE@@FFI_EXEC_TRAMPOLINE_TABLE_TRUE@am__append_22 = src/arm/trampoline.S -@AVR32_TRUE@am__append_23 = src/avr32/sysv.S src/avr32/ffi.c -@LIBFFI_CRIS_TRUE@am__append_24 = src/cris/sysv.S src/cris/ffi.c -@FRV_TRUE@am__append_25 = src/frv/eabi.S src/frv/ffi.c -@S390_TRUE@am__append_26 = src/s390/sysv.S src/s390/ffi.c -@X86_64_TRUE@am__append_27 = src/x86/ffi64.c src/x86/unix64.S src/x86/ffi.c src/x86/sysv.S -@SH_TRUE@am__append_28 = src/sh/sysv.S src/sh/ffi.c -@SH64_TRUE@am__append_29 = src/sh64/sysv.S src/sh64/ffi.c -@PA_LINUX_TRUE@am__append_30 = src/pa/linux.S src/pa/ffi.c -@PA_HPUX_TRUE@am__append_31 = src/pa/hpux32.S src/pa/ffi.c -@TILE_TRUE@am__append_32 = src/tile/tile.S src/tile/ffi.c -@XTENSA_TRUE@am__append_33 = src/xtensa/sysv.S src/xtensa/ffi.c -@METAG_TRUE@am__append_34 = src/metag/sysv.S src/metag/ffi.c +@MIPS_TRUE@am__append_1 = src/mips/ffi.c src/mips/o32.S src/mips/n32.S +@X86_TRUE@am__append_2 = src/x86/ffi.c src/x86/sysv.S +@X86_FREEBSD_TRUE@am__append_3 = src/x86/ffi.c src/x86/freebsd.S +@X86_WIN32_TRUE@am__append_4 = src/x86/ffi.c src/x86/win32.S +@X86_WIN64_TRUE@am__append_5 = src/x86/ffi.c src/x86/win64.S +@X86_DARWIN_TRUE@am__append_6 = src/x86/ffi.c src/x86/darwin.S src/x86/ffi64.c src/x86/darwin64.S +@SPARC_TRUE@am__append_7 = src/sparc/ffi.c src/sparc/v8.S src/sparc/v9.S +@ALPHA_TRUE@am__append_8 = src/alpha/ffi.c src/alpha/osf.S +@IA64_TRUE@am__append_9 = src/ia64/ffi.c src/ia64/unix.S +@M32R_TRUE@am__append_10 = src/m32r/sysv.S src/m32r/ffi.c +@M68K_TRUE@am__append_11 = src/m68k/ffi.c src/m68k/sysv.S +@POWERPC_TRUE@am__append_12 = src/powerpc/ffi.c src/powerpc/sysv.S src/powerpc/ppc_closure.S src/powerpc/linux64.S src/powerpc/linux64_closure.S +@POWERPC_AIX_TRUE@am__append_13 = src/powerpc/ffi_darwin.c src/powerpc/aix.S src/powerpc/aix_closure.S +@POWERPC_DARWIN_TRUE@am__append_14 = src/powerpc/ffi_darwin.c src/powerpc/darwin.S src/powerpc/darwin_closure.S +@POWERPC_FREEBSD_TRUE@am__append_15 = src/powerpc/ffi.c src/powerpc/sysv.S src/powerpc/ppc_closure.S +@ARM_TRUE@am__append_16 = src/arm/sysv.S src/arm/ffi.c +@AVR32_TRUE@am__append_17 = src/avr32/sysv.S src/avr32/ffi.c +@LIBFFI_CRIS_TRUE@am__append_18 = src/cris/sysv.S src/cris/ffi.c +@FRV_TRUE@am__append_19 = src/frv/eabi.S src/frv/ffi.c +@S390_TRUE@am__append_20 = src/s390/sysv.S src/s390/ffi.c +@X86_64_TRUE@am__append_21 = src/x86/ffi64.c src/x86/unix64.S src/x86/ffi.c src/x86/sysv.S +@SH_TRUE@am__append_22 = src/sh/sysv.S src/sh/ffi.c +@SH64_TRUE@am__append_23 = src/sh64/sysv.S src/sh64/ffi.c +@PA_LINUX_TRUE@am__append_24 = src/pa/linux.S src/pa/ffi.c +@PA_HPUX_TRUE@am__append_25 = src/pa/hpux32.S src/pa/ffi.c subdir = . DIST_COMMON = README $(am__configure_deps) $(srcdir)/Makefile.am \ $(srcdir)/Makefile.in $(srcdir)/doc/stamp-vti \ @@ -94,19 +69,7 @@ compile config.guess config.sub depcomp install-sh ltmain.sh \ mdate-sh missing texinfo.tex ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 -am__aclocal_m4_deps = $(top_srcdir)/m4/asmcfi.m4 \ - $(top_srcdir)/m4/ax_append_flag.m4 \ - $(top_srcdir)/m4/ax_cc_maxopt.m4 \ - $(top_srcdir)/m4/ax_cflags_warn_all.m4 \ - $(top_srcdir)/m4/ax_check_compile_flag.m4 \ - $(top_srcdir)/m4/ax_compiler_vendor.m4 \ - $(top_srcdir)/m4/ax_configure_args.m4 \ - $(top_srcdir)/m4/ax_enable_builddir.m4 \ - $(top_srcdir)/m4/ax_gcc_archflag.m4 \ - $(top_srcdir)/m4/ax_gcc_x86_cpuid.m4 \ - $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \ - $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \ - $(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/acinclude.m4 \ +am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) @@ -137,67 +100,51 @@ am__base_list = \ sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' -am__uninstall_files_from_dir = { \ - test -z "$$files" \ - || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ - || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ - $(am__cd) "$$dir" && rm -f $$files; }; \ - } -am__installdirs = "$(DESTDIR)$(toolexeclibdir)" "$(DESTDIR)$(infodir)" \ +am__installdirs = "$(DESTDIR)$(libdir)" "$(DESTDIR)$(infodir)" \ "$(DESTDIR)$(pkgconfigdir)" -LTLIBRARIES = $(noinst_LTLIBRARIES) $(toolexeclib_LTLIBRARIES) +LTLIBRARIES = $(lib_LTLIBRARIES) $(noinst_LTLIBRARIES) libffi_la_LIBADD = am__dirstamp = $(am__leading_dot)dirstamp -am_libffi_la_OBJECTS = src/prep_cif.lo src/types.lo src/raw_api.lo \ - src/java_raw_api.lo src/closures.lo -@FFI_DEBUG_TRUE@am__objects_1 = src/debug.lo -@MIPS_TRUE@am__objects_2 = src/mips/ffi.lo src/mips/o32.lo \ +am_libffi_la_OBJECTS = src/debug.lo src/prep_cif.lo src/types.lo \ + src/raw_api.lo src/java_raw_api.lo src/closures.lo +@MIPS_TRUE@am__objects_1 = src/mips/ffi.lo src/mips/o32.lo \ @MIPS_TRUE@ src/mips/n32.lo -@BFIN_TRUE@am__objects_3 = src/bfin/ffi.lo src/bfin/sysv.lo -@X86_TRUE@am__objects_4 = src/x86/ffi.lo src/x86/sysv.lo -@X86_FREEBSD_TRUE@am__objects_5 = src/x86/ffi.lo src/x86/freebsd.lo -@X86_WIN32_TRUE@am__objects_6 = src/x86/ffi.lo src/x86/win32.lo -@X86_WIN64_TRUE@am__objects_7 = src/x86/ffi.lo src/x86/win64.lo -@X86_DARWIN_TRUE@am__objects_8 = src/x86/ffi.lo src/x86/darwin.lo \ +@X86_TRUE@am__objects_2 = src/x86/ffi.lo src/x86/sysv.lo +@X86_FREEBSD_TRUE@am__objects_3 = src/x86/ffi.lo src/x86/freebsd.lo +@X86_WIN32_TRUE@am__objects_4 = src/x86/ffi.lo src/x86/win32.lo +@X86_WIN64_TRUE@am__objects_5 = src/x86/ffi.lo src/x86/win64.lo +@X86_DARWIN_TRUE@am__objects_6 = src/x86/ffi.lo src/x86/darwin.lo \ @X86_DARWIN_TRUE@ src/x86/ffi64.lo src/x86/darwin64.lo -@SPARC_TRUE@am__objects_9 = src/sparc/ffi.lo src/sparc/v8.lo \ +@SPARC_TRUE@am__objects_7 = src/sparc/ffi.lo src/sparc/v8.lo \ @SPARC_TRUE@ src/sparc/v9.lo -@ALPHA_TRUE@am__objects_10 = src/alpha/ffi.lo src/alpha/osf.lo -@IA64_TRUE@am__objects_11 = src/ia64/ffi.lo src/ia64/unix.lo -@M32R_TRUE@am__objects_12 = src/m32r/sysv.lo src/m32r/ffi.lo -@M68K_TRUE@am__objects_13 = src/m68k/ffi.lo src/m68k/sysv.lo -@MOXIE_TRUE@am__objects_14 = src/moxie/ffi.lo src/moxie/eabi.lo -@MICROBLAZE_TRUE@am__objects_15 = src/microblaze/ffi.lo \ -@MICROBLAZE_TRUE@ src/microblaze/sysv.lo -@POWERPC_TRUE@am__objects_16 = src/powerpc/ffi.lo src/powerpc/sysv.lo \ +@ALPHA_TRUE@am__objects_8 = src/alpha/ffi.lo src/alpha/osf.lo +@IA64_TRUE@am__objects_9 = src/ia64/ffi.lo src/ia64/unix.lo +@M32R_TRUE@am__objects_10 = src/m32r/sysv.lo src/m32r/ffi.lo +@M68K_TRUE@am__objects_11 = src/m68k/ffi.lo src/m68k/sysv.lo +@POWERPC_TRUE@am__objects_12 = src/powerpc/ffi.lo src/powerpc/sysv.lo \ @POWERPC_TRUE@ src/powerpc/ppc_closure.lo \ @POWERPC_TRUE@ src/powerpc/linux64.lo \ @POWERPC_TRUE@ src/powerpc/linux64_closure.lo -@POWERPC_AIX_TRUE@am__objects_17 = src/powerpc/ffi_darwin.lo \ +@POWERPC_AIX_TRUE@am__objects_13 = src/powerpc/ffi_darwin.lo \ @POWERPC_AIX_TRUE@ src/powerpc/aix.lo \ @POWERPC_AIX_TRUE@ src/powerpc/aix_closure.lo -@POWERPC_DARWIN_TRUE@am__objects_18 = src/powerpc/ffi_darwin.lo \ +@POWERPC_DARWIN_TRUE@am__objects_14 = src/powerpc/ffi_darwin.lo \ @POWERPC_DARWIN_TRUE@ src/powerpc/darwin.lo \ @POWERPC_DARWIN_TRUE@ src/powerpc/darwin_closure.lo -@POWERPC_FREEBSD_TRUE@am__objects_19 = src/powerpc/ffi.lo \ +@POWERPC_FREEBSD_TRUE@am__objects_15 = src/powerpc/ffi.lo \ @POWERPC_FREEBSD_TRUE@ src/powerpc/sysv.lo \ @POWERPC_FREEBSD_TRUE@ src/powerpc/ppc_closure.lo -@AARCH64_TRUE@am__objects_20 = src/aarch64/sysv.lo src/aarch64/ffi.lo -@ARM_TRUE@am__objects_21 = src/arm/sysv.lo src/arm/ffi.lo -@ARM_TRUE@@FFI_EXEC_TRAMPOLINE_TABLE_TRUE@am__objects_22 = src/arm/trampoline.lo -@AVR32_TRUE@am__objects_23 = src/avr32/sysv.lo src/avr32/ffi.lo -@LIBFFI_CRIS_TRUE@am__objects_24 = src/cris/sysv.lo src/cris/ffi.lo -@FRV_TRUE@am__objects_25 = src/frv/eabi.lo src/frv/ffi.lo -@S390_TRUE@am__objects_26 = src/s390/sysv.lo src/s390/ffi.lo -@X86_64_TRUE@am__objects_27 = src/x86/ffi64.lo src/x86/unix64.lo \ +@ARM_TRUE@am__objects_16 = src/arm/sysv.lo src/arm/ffi.lo +@AVR32_TRUE@am__objects_17 = src/avr32/sysv.lo src/avr32/ffi.lo +@LIBFFI_CRIS_TRUE@am__objects_18 = src/cris/sysv.lo src/cris/ffi.lo +@FRV_TRUE@am__objects_19 = src/frv/eabi.lo src/frv/ffi.lo +@S390_TRUE@am__objects_20 = src/s390/sysv.lo src/s390/ffi.lo +@X86_64_TRUE@am__objects_21 = src/x86/ffi64.lo src/x86/unix64.lo \ @X86_64_TRUE@ src/x86/ffi.lo src/x86/sysv.lo -@SH_TRUE@am__objects_28 = src/sh/sysv.lo src/sh/ffi.lo -@SH64_TRUE@am__objects_29 = src/sh64/sysv.lo src/sh64/ffi.lo -@PA_LINUX_TRUE@am__objects_30 = src/pa/linux.lo src/pa/ffi.lo -@PA_HPUX_TRUE@am__objects_31 = src/pa/hpux32.lo src/pa/ffi.lo -@TILE_TRUE@am__objects_32 = src/tile/tile.lo src/tile/ffi.lo -@XTENSA_TRUE@am__objects_33 = src/xtensa/sysv.lo src/xtensa/ffi.lo -@METAG_TRUE@am__objects_34 = src/metag/sysv.lo src/metag/ffi.lo +@SH_TRUE@am__objects_22 = src/sh/sysv.lo src/sh/ffi.lo +@SH64_TRUE@am__objects_23 = src/sh64/sysv.lo src/sh64/ffi.lo +@PA_LINUX_TRUE@am__objects_24 = src/pa/linux.lo src/pa/ffi.lo +@PA_HPUX_TRUE@am__objects_25 = src/pa/hpux32.lo src/pa/ffi.lo nodist_libffi_la_OBJECTS = $(am__objects_1) $(am__objects_2) \ $(am__objects_3) $(am__objects_4) $(am__objects_5) \ $(am__objects_6) $(am__objects_7) $(am__objects_8) \ @@ -206,20 +153,17 @@ $(am__objects_15) $(am__objects_16) $(am__objects_17) \ $(am__objects_18) $(am__objects_19) $(am__objects_20) \ $(am__objects_21) $(am__objects_22) $(am__objects_23) \ - $(am__objects_24) $(am__objects_25) $(am__objects_26) \ - $(am__objects_27) $(am__objects_28) $(am__objects_29) \ - $(am__objects_30) $(am__objects_31) $(am__objects_32) \ - $(am__objects_33) $(am__objects_34) + $(am__objects_24) $(am__objects_25) libffi_la_OBJECTS = $(am_libffi_la_OBJECTS) \ $(nodist_libffi_la_OBJECTS) libffi_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ $(libffi_la_LDFLAGS) $(LDFLAGS) -o $@ libffi_convenience_la_LIBADD = -am__objects_35 = src/prep_cif.lo src/types.lo src/raw_api.lo \ - src/java_raw_api.lo src/closures.lo -am_libffi_convenience_la_OBJECTS = $(am__objects_35) -am__objects_36 = $(am__objects_1) $(am__objects_2) $(am__objects_3) \ +am__objects_26 = src/debug.lo src/prep_cif.lo src/types.lo \ + src/raw_api.lo src/java_raw_api.lo src/closures.lo +am_libffi_convenience_la_OBJECTS = $(am__objects_26) +am__objects_27 = $(am__objects_1) $(am__objects_2) $(am__objects_3) \ $(am__objects_4) $(am__objects_5) $(am__objects_6) \ $(am__objects_7) $(am__objects_8) $(am__objects_9) \ $(am__objects_10) $(am__objects_11) $(am__objects_12) \ @@ -227,11 +171,8 @@ $(am__objects_16) $(am__objects_17) $(am__objects_18) \ $(am__objects_19) $(am__objects_20) $(am__objects_21) \ $(am__objects_22) $(am__objects_23) $(am__objects_24) \ - $(am__objects_25) $(am__objects_26) $(am__objects_27) \ - $(am__objects_28) $(am__objects_29) $(am__objects_30) \ - $(am__objects_31) $(am__objects_32) $(am__objects_33) \ - $(am__objects_34) -nodist_libffi_convenience_la_OBJECTS = $(am__objects_36) + $(am__objects_25) +nodist_libffi_convenience_la_OBJECTS = $(am__objects_27) libffi_convenience_la_OBJECTS = $(am_libffi_convenience_la_OBJECTS) \ $(nodist_libffi_convenience_la_OBJECTS) DEFAULT_INCLUDES = -I.@am__isrc@ @@ -275,31 +216,22 @@ install-pdf-recursive install-ps-recursive install-recursive \ installcheck-recursive installdirs-recursive pdf-recursive \ ps-recursive uninstall-recursive -am__can_run_installinfo = \ - case $$AM_UPDATE_INFO_DIR in \ - n|no|NO) false;; \ - *) (install-info --version) >/dev/null 2>&1;; \ - esac DATA = $(pkgconfig_DATA) RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \ distclean-recursive maintainer-clean-recursive AM_RECURSIVE_TARGETS = $(RECURSIVE_TARGETS:-recursive=) \ $(RECURSIVE_CLEAN_TARGETS:-recursive=) tags TAGS ctags CTAGS \ - cscope distdir dist dist-all distcheck + distdir dist dist-all distcheck ETAGS = etags CTAGS = ctags -CSCOPE = cscope DIST_SUBDIRS = $(SUBDIRS) DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) distdir = $(PACKAGE)-$(VERSION) top_distdir = $(distdir) am__remove_distdir = \ - if test -d "$(distdir)"; then \ - find "$(distdir)" -type d ! -perm -200 -exec chmod u+w {} ';' \ - && rm -rf "$(distdir)" \ - || { sleep 5 && rm -rf "$(distdir)"; }; \ - else :; fi -am__post_remove_distdir = $(am__remove_distdir) + { test ! -d "$(distdir)" \ + || { find "$(distdir)" -type d ! -perm -200 -exec chmod u+w {} ';' \ + && rm -fr "$(distdir)"; }; } am__relativize = \ dir0=`pwd`; \ sed_first='s,^\([^/]*\)/.*$$,\1,'; \ @@ -327,10 +259,7 @@ reldir="$$dir2" DIST_ARCHIVES = $(distdir).tar.gz GZIP_ENV = --best -DIST_TARGETS = dist-gzip distuninstallcheck_listfiles = find . -type f -print -am__distuninstallcheck_listfiles = $(distuninstallcheck_listfiles) \ - | sed 's|^\./|$(prefix)/|' | grep -v '$(infodir)/dir$$' distcleancheck_listfiles = find . -type f -print ACLOCAL = @ACLOCAL@ ALLOCA = @ALLOCA@ @@ -353,7 +282,6 @@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ -DLLTOOL = @DLLTOOL@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ @@ -361,7 +289,6 @@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ -FFI_EXEC_TRAMPOLINE_TABLE = @FFI_EXEC_TRAMPOLINE_TABLE@ FGREP = @FGREP@ GREP = @GREP@ HAVE_LONG_DOUBLE = @HAVE_LONG_DOUBLE@ @@ -380,7 +307,6 @@ LTLIBOBJS = @LTLIBOBJS@ MAINT = @MAINT@ MAKEINFO = @MAKEINFO@ -MANIFEST_TOOL = @MANIFEST_TOOL@ MKDIR_P = @MKDIR_P@ NM = @NM@ NMEDIT = @NMEDIT@ @@ -393,10 +319,8 @@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ -PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ -PRTDIAG = @PRTDIAG@ RANLIB = @RANLIB@ SED = @SED@ SET_MAKE = @SET_MAKE@ @@ -409,7 +333,6 @@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ -ac_ct_AR = @ac_ct_AR@ ac_ct_CC = @ac_ct_CC@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ am__include = @am__include@ @@ -417,7 +340,6 @@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ -ax_enable_builddir_sed = @ax_enable_builddir_sed@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ @@ -443,6 +365,7 @@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ +lt_ECHO = @lt_ECHO@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ @@ -453,7 +376,6 @@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ -sys_symbol_underscore = @sys_symbol_underscore@ sysconfdir = @sysconfdir@ target = @target@ target_alias = @target_alias@ @@ -466,48 +388,36 @@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ AUTOMAKE_OPTIONS = foreign subdir-objects -ACLOCAL_AMFLAGS = -I m4 SUBDIRS = include testsuite man -EXTRA_DIST = LICENSE ChangeLog.v1 ChangeLog.libgcj configure.host \ - src/aarch64/ffi.c src/aarch64/ffitarget.h src/aarch64/sysv.S \ - build-ios.sh src/alpha/ffi.c src/alpha/osf.S \ - src/alpha/ffitarget.h src/arm/ffi.c src/arm/sysv.S \ - src/arm/ffitarget.h src/avr32/ffi.c src/avr32/sysv.S \ - src/avr32/ffitarget.h src/cris/ffi.c src/cris/sysv.S \ - src/cris/ffitarget.h src/ia64/ffi.c src/ia64/ffitarget.h \ - src/ia64/ia64_flags.h src/ia64/unix.S src/mips/ffi.c \ - src/mips/n32.S src/mips/o32.S src/metag/ffi.c \ - src/metag/ffitarget.h src/metag/sysv.S src/moxie/ffi.c \ - src/moxie/ffitarget.h src/moxie/eabi.S src/mips/ffitarget.h \ - src/m32r/ffi.c src/m32r/sysv.S src/m32r/ffitarget.h \ - src/m68k/ffi.c src/m68k/sysv.S src/m68k/ffitarget.h \ - src/microblaze/ffi.c src/microblaze/sysv.S \ - src/microblaze/ffitarget.h src/powerpc/ffi.c \ - src/powerpc/sysv.S src/powerpc/linux64.S \ - src/powerpc/linux64_closure.S src/powerpc/ppc_closure.S \ - src/powerpc/asm.h src/powerpc/aix.S src/powerpc/darwin.S \ - src/powerpc/aix_closure.S src/powerpc/darwin_closure.S \ - src/powerpc/ffi_darwin.c src/powerpc/ffitarget.h \ - src/s390/ffi.c src/s390/sysv.S src/s390/ffitarget.h \ - src/sh/ffi.c src/sh/sysv.S src/sh/ffitarget.h src/sh64/ffi.c \ - src/sh64/sysv.S src/sh64/ffitarget.h src/sparc/v8.S \ - src/sparc/v9.S src/sparc/ffitarget.h src/sparc/ffi.c \ - src/x86/darwin64.S src/x86/ffi.c src/x86/sysv.S \ - src/x86/win32.S src/x86/darwin.S src/x86/win64.S \ - src/x86/freebsd.S src/x86/ffi64.c src/x86/unix64.S \ - src/x86/ffitarget.h src/pa/ffitarget.h src/pa/ffi.c \ - src/pa/linux.S src/pa/hpux32.S src/frv/ffi.c src/bfin/ffi.c \ - src/bfin/ffitarget.h src/bfin/sysv.S src/frv/eabi.S \ - src/frv/ffitarget.h src/dlmalloc.c src/tile/ffi.c \ - src/tile/ffitarget.h src/tile/tile.S libtool-version \ - src/xtensa/ffitarget.h src/xtensa/ffi.c src/xtensa/sysv.S \ - ChangeLog.libffi m4/libtool.m4 m4/lt~obsolete.m4 \ - m4/ltoptions.m4 m4/ltsugar.m4 m4/ltversion.m4 \ - m4/ltversion.m4 src/arm/gentramp.sh src/debug.c msvcc.sh \ - generate-ios-source-and-headers.py \ - generate-osx-source-and-headers.py \ - libffi.xcodeproj/project.pbxproj src/arm/trampoline.S \ - libtool-ldflags +EXTRA_DIST = LICENSE ChangeLog.v1 ChangeLog.libgcj configure.host \ + src/alpha/ffi.c src/alpha/osf.S src/alpha/ffitarget.h \ + src/arm/ffi.c src/arm/sysv.S src/arm/ffitarget.h \ + src/avr32/ffi.c src/avr32/sysv.S src/avr32/ffitarget.h \ + src/cris/ffi.c src/cris/sysv.S src/cris/ffitarget.h \ + src/ia64/ffi.c src/ia64/ffitarget.h src/ia64/ia64_flags.h \ + src/ia64/unix.S \ + src/mips/ffi.c src/mips/n32.S src/mips/o32.S \ + src/mips/ffitarget.h \ + src/m32r/ffi.c src/m32r/sysv.S src/m32r/ffitarget.h \ + src/m68k/ffi.c src/m68k/sysv.S src/m68k/ffitarget.h \ + src/powerpc/ffi.c src/powerpc/sysv.S \ + src/powerpc/linux64.S src/powerpc/linux64_closure.S \ + src/powerpc/ppc_closure.S src/powerpc/asm.h \ + src/powerpc/aix.S src/powerpc/darwin.S \ + src/powerpc/aix_closure.S src/powerpc/darwin_closure.S \ + src/powerpc/ffi_darwin.c src/powerpc/ffitarget.h \ + src/s390/ffi.c src/s390/sysv.S src/s390/ffitarget.h \ + src/sh/ffi.c src/sh/sysv.S src/sh/ffitarget.h \ + src/sh64/ffi.c src/sh64/sysv.S src/sh64/ffitarget.h \ + src/sparc/v8.S src/sparc/v9.S src/sparc/ffitarget.h \ + src/sparc/ffi.c src/x86/darwin64.S \ + src/x86/ffi.c src/x86/sysv.S src/x86/win32.S src/x86/win64.S \ + src/x86/darwin.S src/x86/freebsd.S \ + src/x86/ffi64.c src/x86/unix64.S src/x86/ffitarget.h \ + src/pa/ffitarget.h src/pa/ffi.c src/pa/linux.S src/pa/hpux32.S \ + src/frv/ffi.c src/frv/eabi.S src/frv/ffitarget.h src/dlmalloc.c \ + libtool-version ChangeLog.libffi m4/libtool.m4 \ + m4/lt~obsolete.m4 m4/ltoptions.m4 m4/ltsugar.m4 m4/ltversion.m4 info_TEXINFOS = doc/libffi.texi @@ -538,7 +448,6 @@ "exec_prefix=$(exec_prefix)" \ "infodir=$(infodir)" \ "libdir=$(libdir)" \ - "mandir=$(mandir)" \ "prefix=$(prefix)" \ "AR=$(AR)" \ "AS=$(AS)" \ @@ -549,13 +458,11 @@ "RANLIB=$(RANLIB)" \ "DESTDIR=$(DESTDIR)" - -# Subdir rules rely on $(FLAGS_TO_PASS) -FLAGS_TO_PASS = $(AM_MAKEFLAGS) MAKEOVERRIDES = -toolexeclib_LTLIBRARIES = libffi.la +ACLOCAL_AMFLAGS = $(ACLOCAL_AMFLAGS) -I m4 +lib_LTLIBRARIES = libffi.la noinst_LTLIBRARIES = libffi_convenience.la -libffi_la_SOURCES = src/prep_cif.c src/types.c \ +libffi_la_SOURCES = src/debug.c src/prep_cif.c src/types.c \ src/raw_api.c src/java_raw_api.c src/closures.c pkgconfigdir = $(libdir)/pkgconfig @@ -568,14 +475,11 @@ $(am__append_15) $(am__append_16) $(am__append_17) \ $(am__append_18) $(am__append_19) $(am__append_20) \ $(am__append_21) $(am__append_22) $(am__append_23) \ - $(am__append_24) $(am__append_25) $(am__append_26) \ - $(am__append_27) $(am__append_28) $(am__append_29) \ - $(am__append_30) $(am__append_31) $(am__append_32) \ - $(am__append_33) $(am__append_34) + $(am__append_24) $(am__append_25) libffi_convenience_la_SOURCES = $(libffi_la_SOURCES) nodist_libffi_convenience_la_SOURCES = $(nodist_libffi_la_SOURCES) -LTLDFLAGS = $(shell $(SHELL) $(top_srcdir)/libtool-ldflags $(LDFLAGS)) -libffi_la_LDFLAGS = -no-undefined -version-info `grep -v '^\#' $(srcdir)/libtool-version` $(LTLDFLAGS) $(AM_LTLDFLAGS) +AM_CFLAGS = -Wall -g -fexceptions +libffi_la_LDFLAGS = -version-info `grep -v '^\#' $(srcdir)/libtool-version` $(AM_LTLDFLAGS) AM_CPPFLAGS = -I. -I$(top_srcdir)/include -Iinclude -I$(top_srcdir)/src AM_CCASFLAGS = $(AM_CPPFLAGS) all: fficonfig.h @@ -583,7 +487,7 @@ .SUFFIXES: .SUFFIXES: .S .c .dvi .lo .o .obj .ps -am--refresh: Makefile +am--refresh: @: $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ @@ -619,8 +523,10 @@ $(am__aclocal_m4_deps): fficonfig.h: stamp-h1 - @if test ! -f $@; then rm -f stamp-h1; else :; fi - @if test ! -f $@; then $(MAKE) $(AM_MAKEFLAGS) stamp-h1; else :; fi + @if test ! -f $@; then \ + rm -f stamp-h1; \ + $(MAKE) $(AM_MAKEFLAGS) stamp-h1; \ + else :; fi stamp-h1: $(srcdir)/fficonfig.h.in $(top_builddir)/config.status @rm -f stamp-h1 @@ -634,63 +540,58 @@ -rm -f fficonfig.h stamp-h1 libffi.pc: $(top_builddir)/config.status $(srcdir)/libffi.pc.in cd $(top_builddir) && $(SHELL) ./config.status $@ - -clean-noinstLTLIBRARIES: - -test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES) - @list='$(noinst_LTLIBRARIES)'; \ - locs=`for p in $$list; do echo $$p; done | \ - sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \ - sort -u`; \ - test -z "$$locs" || { \ - echo rm -f $${locs}; \ - rm -f $${locs}; \ - } -install-toolexeclibLTLIBRARIES: $(toolexeclib_LTLIBRARIES) +install-libLTLIBRARIES: $(lib_LTLIBRARIES) @$(NORMAL_INSTALL) - @list='$(toolexeclib_LTLIBRARIES)'; test -n "$(toolexeclibdir)" || list=; \ + test -z "$(libdir)" || $(MKDIR_P) "$(DESTDIR)$(libdir)" + @list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \ list2=; for p in $$list; do \ if test -f $$p; then \ list2="$$list2 $$p"; \ else :; fi; \ done; \ test -z "$$list2" || { \ - echo " $(MKDIR_P) '$(DESTDIR)$(toolexeclibdir)'"; \ - $(MKDIR_P) "$(DESTDIR)$(toolexeclibdir)" || exit 1; \ - echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(toolexeclibdir)'"; \ - $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(toolexeclibdir)"; \ + echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(libdir)'"; \ + $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(libdir)"; \ } -uninstall-toolexeclibLTLIBRARIES: +uninstall-libLTLIBRARIES: @$(NORMAL_UNINSTALL) - @list='$(toolexeclib_LTLIBRARIES)'; test -n "$(toolexeclibdir)" || list=; \ + @list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \ for p in $$list; do \ $(am__strip_dir) \ - echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(toolexeclibdir)/$$f'"; \ - $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(toolexeclibdir)/$$f"; \ + echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(libdir)/$$f'"; \ + $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(libdir)/$$f"; \ done -clean-toolexeclibLTLIBRARIES: - -test -z "$(toolexeclib_LTLIBRARIES)" || rm -f $(toolexeclib_LTLIBRARIES) - @list='$(toolexeclib_LTLIBRARIES)'; \ - locs=`for p in $$list; do echo $$p; done | \ - sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \ - sort -u`; \ - test -z "$$locs" || { \ - echo rm -f $${locs}; \ - rm -f $${locs}; \ - } +clean-libLTLIBRARIES: + -test -z "$(lib_LTLIBRARIES)" || rm -f $(lib_LTLIBRARIES) + @list='$(lib_LTLIBRARIES)'; for p in $$list; do \ + dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \ + test "$$dir" != "$$p" || dir=.; \ + echo "rm -f \"$${dir}/so_locations\""; \ + rm -f "$${dir}/so_locations"; \ + done + +clean-noinstLTLIBRARIES: + -test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES) + @list='$(noinst_LTLIBRARIES)'; for p in $$list; do \ + dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \ + test "$$dir" != "$$p" || dir=.; \ + echo "rm -f \"$${dir}/so_locations\""; \ + rm -f "$${dir}/so_locations"; \ + done src/$(am__dirstamp): @$(MKDIR_P) src @: > src/$(am__dirstamp) src/$(DEPDIR)/$(am__dirstamp): @$(MKDIR_P) src/$(DEPDIR) @: > src/$(DEPDIR)/$(am__dirstamp) +src/debug.lo: src/$(am__dirstamp) src/$(DEPDIR)/$(am__dirstamp) src/prep_cif.lo: src/$(am__dirstamp) src/$(DEPDIR)/$(am__dirstamp) src/types.lo: src/$(am__dirstamp) src/$(DEPDIR)/$(am__dirstamp) src/raw_api.lo: src/$(am__dirstamp) src/$(DEPDIR)/$(am__dirstamp) src/java_raw_api.lo: src/$(am__dirstamp) src/$(DEPDIR)/$(am__dirstamp) src/closures.lo: src/$(am__dirstamp) src/$(DEPDIR)/$(am__dirstamp) -src/debug.lo: src/$(am__dirstamp) src/$(DEPDIR)/$(am__dirstamp) src/mips/$(am__dirstamp): @$(MKDIR_P) src/mips @: > src/mips/$(am__dirstamp) @@ -703,16 +604,6 @@ src/mips/$(DEPDIR)/$(am__dirstamp) src/mips/n32.lo: src/mips/$(am__dirstamp) \ src/mips/$(DEPDIR)/$(am__dirstamp) -src/bfin/$(am__dirstamp): - @$(MKDIR_P) src/bfin - @: > src/bfin/$(am__dirstamp) -src/bfin/$(DEPDIR)/$(am__dirstamp): - @$(MKDIR_P) src/bfin/$(DEPDIR) - @: > src/bfin/$(DEPDIR)/$(am__dirstamp) -src/bfin/ffi.lo: src/bfin/$(am__dirstamp) \ - src/bfin/$(DEPDIR)/$(am__dirstamp) -src/bfin/sysv.lo: src/bfin/$(am__dirstamp) \ - src/bfin/$(DEPDIR)/$(am__dirstamp) src/x86/$(am__dirstamp): @$(MKDIR_P) src/x86 @: > src/x86/$(am__dirstamp) @@ -787,26 +678,6 @@ src/m68k/$(DEPDIR)/$(am__dirstamp) src/m68k/sysv.lo: src/m68k/$(am__dirstamp) \ src/m68k/$(DEPDIR)/$(am__dirstamp) -src/moxie/$(am__dirstamp): - @$(MKDIR_P) src/moxie - @: > src/moxie/$(am__dirstamp) -src/moxie/$(DEPDIR)/$(am__dirstamp): - @$(MKDIR_P) src/moxie/$(DEPDIR) - @: > src/moxie/$(DEPDIR)/$(am__dirstamp) -src/moxie/ffi.lo: src/moxie/$(am__dirstamp) \ - src/moxie/$(DEPDIR)/$(am__dirstamp) -src/moxie/eabi.lo: src/moxie/$(am__dirstamp) \ - src/moxie/$(DEPDIR)/$(am__dirstamp) -src/microblaze/$(am__dirstamp): - @$(MKDIR_P) src/microblaze - @: > src/microblaze/$(am__dirstamp) -src/microblaze/$(DEPDIR)/$(am__dirstamp): - @$(MKDIR_P) src/microblaze/$(DEPDIR) - @: > src/microblaze/$(DEPDIR)/$(am__dirstamp) -src/microblaze/ffi.lo: src/microblaze/$(am__dirstamp) \ - src/microblaze/$(DEPDIR)/$(am__dirstamp) -src/microblaze/sysv.lo: src/microblaze/$(am__dirstamp) \ - src/microblaze/$(DEPDIR)/$(am__dirstamp) src/powerpc/$(am__dirstamp): @$(MKDIR_P) src/powerpc @: > src/powerpc/$(am__dirstamp) @@ -833,16 +704,6 @@ src/powerpc/$(DEPDIR)/$(am__dirstamp) src/powerpc/darwin_closure.lo: src/powerpc/$(am__dirstamp) \ src/powerpc/$(DEPDIR)/$(am__dirstamp) -src/aarch64/$(am__dirstamp): - @$(MKDIR_P) src/aarch64 - @: > src/aarch64/$(am__dirstamp) -src/aarch64/$(DEPDIR)/$(am__dirstamp): - @$(MKDIR_P) src/aarch64/$(DEPDIR) - @: > src/aarch64/$(DEPDIR)/$(am__dirstamp) -src/aarch64/sysv.lo: src/aarch64/$(am__dirstamp) \ - src/aarch64/$(DEPDIR)/$(am__dirstamp) -src/aarch64/ffi.lo: src/aarch64/$(am__dirstamp) \ - src/aarch64/$(DEPDIR)/$(am__dirstamp) src/arm/$(am__dirstamp): @$(MKDIR_P) src/arm @: > src/arm/$(am__dirstamp) @@ -853,8 +714,6 @@ src/arm/$(DEPDIR)/$(am__dirstamp) src/arm/ffi.lo: src/arm/$(am__dirstamp) \ src/arm/$(DEPDIR)/$(am__dirstamp) -src/arm/trampoline.lo: src/arm/$(am__dirstamp) \ - src/arm/$(DEPDIR)/$(am__dirstamp) src/avr32/$(am__dirstamp): @$(MKDIR_P) src/avr32 @: > src/avr32/$(am__dirstamp) @@ -927,91 +786,125 @@ src/pa/ffi.lo: src/pa/$(am__dirstamp) src/pa/$(DEPDIR)/$(am__dirstamp) src/pa/hpux32.lo: src/pa/$(am__dirstamp) \ src/pa/$(DEPDIR)/$(am__dirstamp) -src/tile/$(am__dirstamp): - @$(MKDIR_P) src/tile - @: > src/tile/$(am__dirstamp) -src/tile/$(DEPDIR)/$(am__dirstamp): - @$(MKDIR_P) src/tile/$(DEPDIR) - @: > src/tile/$(DEPDIR)/$(am__dirstamp) -src/tile/tile.lo: src/tile/$(am__dirstamp) \ - src/tile/$(DEPDIR)/$(am__dirstamp) -src/tile/ffi.lo: src/tile/$(am__dirstamp) \ - src/tile/$(DEPDIR)/$(am__dirstamp) -src/xtensa/$(am__dirstamp): - @$(MKDIR_P) src/xtensa - @: > src/xtensa/$(am__dirstamp) -src/xtensa/$(DEPDIR)/$(am__dirstamp): - @$(MKDIR_P) src/xtensa/$(DEPDIR) - @: > src/xtensa/$(DEPDIR)/$(am__dirstamp) -src/xtensa/sysv.lo: src/xtensa/$(am__dirstamp) \ - src/xtensa/$(DEPDIR)/$(am__dirstamp) -src/xtensa/ffi.lo: src/xtensa/$(am__dirstamp) \ - src/xtensa/$(DEPDIR)/$(am__dirstamp) -src/metag/$(am__dirstamp): - @$(MKDIR_P) src/metag - @: > src/metag/$(am__dirstamp) -src/metag/$(DEPDIR)/$(am__dirstamp): - @$(MKDIR_P) src/metag/$(DEPDIR) - @: > src/metag/$(DEPDIR)/$(am__dirstamp) -src/metag/sysv.lo: src/metag/$(am__dirstamp) \ - src/metag/$(DEPDIR)/$(am__dirstamp) -src/metag/ffi.lo: src/metag/$(am__dirstamp) \ - src/metag/$(DEPDIR)/$(am__dirstamp) -libffi.la: $(libffi_la_OBJECTS) $(libffi_la_DEPENDENCIES) $(EXTRA_libffi_la_DEPENDENCIES) - $(libffi_la_LINK) -rpath $(toolexeclibdir) $(libffi_la_OBJECTS) $(libffi_la_LIBADD) $(LIBS) -libffi_convenience.la: $(libffi_convenience_la_OBJECTS) $(libffi_convenience_la_DEPENDENCIES) $(EXTRA_libffi_convenience_la_DEPENDENCIES) +libffi.la: $(libffi_la_OBJECTS) $(libffi_la_DEPENDENCIES) + $(libffi_la_LINK) -rpath $(libdir) $(libffi_la_OBJECTS) $(libffi_la_LIBADD) $(LIBS) +libffi_convenience.la: $(libffi_convenience_la_OBJECTS) $(libffi_convenience_la_DEPENDENCIES) $(LINK) $(libffi_convenience_la_OBJECTS) $(libffi_convenience_la_LIBADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) - -rm -f src/*.$(OBJEXT) - -rm -f src/*.lo - -rm -f src/aarch64/*.$(OBJEXT) - -rm -f src/aarch64/*.lo - -rm -f src/alpha/*.$(OBJEXT) - -rm -f src/alpha/*.lo - -rm -f src/arm/*.$(OBJEXT) - -rm -f src/arm/*.lo - -rm -f src/avr32/*.$(OBJEXT) - -rm -f src/avr32/*.lo - -rm -f src/bfin/*.$(OBJEXT) - -rm -f src/bfin/*.lo - -rm -f src/cris/*.$(OBJEXT) - -rm -f src/cris/*.lo - -rm -f src/frv/*.$(OBJEXT) - -rm -f src/frv/*.lo - -rm -f src/ia64/*.$(OBJEXT) - -rm -f src/ia64/*.lo - -rm -f src/m32r/*.$(OBJEXT) - -rm -f src/m32r/*.lo - -rm -f src/m68k/*.$(OBJEXT) - -rm -f src/m68k/*.lo - -rm -f src/metag/*.$(OBJEXT) - -rm -f src/metag/*.lo - -rm -f src/microblaze/*.$(OBJEXT) - -rm -f src/microblaze/*.lo - -rm -f src/mips/*.$(OBJEXT) - -rm -f src/mips/*.lo - -rm -f src/moxie/*.$(OBJEXT) - -rm -f src/moxie/*.lo - -rm -f src/pa/*.$(OBJEXT) - -rm -f src/pa/*.lo - -rm -f src/powerpc/*.$(OBJEXT) - -rm -f src/powerpc/*.lo - -rm -f src/s390/*.$(OBJEXT) - -rm -f src/s390/*.lo - -rm -f src/sh/*.$(OBJEXT) - -rm -f src/sh/*.lo - -rm -f src/sh64/*.$(OBJEXT) - -rm -f src/sh64/*.lo - -rm -f src/sparc/*.$(OBJEXT) - -rm -f src/sparc/*.lo - -rm -f src/tile/*.$(OBJEXT) - -rm -f src/tile/*.lo - -rm -f src/x86/*.$(OBJEXT) - -rm -f src/x86/*.lo - -rm -f src/xtensa/*.$(OBJEXT) - -rm -f src/xtensa/*.lo + -rm -f src/alpha/ffi.$(OBJEXT) + -rm -f src/alpha/ffi.lo + -rm -f src/alpha/osf.$(OBJEXT) + -rm -f src/alpha/osf.lo + -rm -f src/arm/ffi.$(OBJEXT) + -rm -f src/arm/ffi.lo + -rm -f src/arm/sysv.$(OBJEXT) + -rm -f src/arm/sysv.lo + -rm -f src/avr32/ffi.$(OBJEXT) + -rm -f src/avr32/ffi.lo + -rm -f src/avr32/sysv.$(OBJEXT) + -rm -f src/avr32/sysv.lo + -rm -f src/closures.$(OBJEXT) + -rm -f src/closures.lo + -rm -f src/cris/ffi.$(OBJEXT) + -rm -f src/cris/ffi.lo + -rm -f src/cris/sysv.$(OBJEXT) + -rm -f src/cris/sysv.lo + -rm -f src/debug.$(OBJEXT) + -rm -f src/debug.lo + -rm -f src/frv/eabi.$(OBJEXT) + -rm -f src/frv/eabi.lo + -rm -f src/frv/ffi.$(OBJEXT) + -rm -f src/frv/ffi.lo + -rm -f src/ia64/ffi.$(OBJEXT) + -rm -f src/ia64/ffi.lo + -rm -f src/ia64/unix.$(OBJEXT) + -rm -f src/ia64/unix.lo + -rm -f src/java_raw_api.$(OBJEXT) + -rm -f src/java_raw_api.lo + -rm -f src/m32r/ffi.$(OBJEXT) + -rm -f src/m32r/ffi.lo + -rm -f src/m32r/sysv.$(OBJEXT) + -rm -f src/m32r/sysv.lo + -rm -f src/m68k/ffi.$(OBJEXT) + -rm -f src/m68k/ffi.lo + -rm -f src/m68k/sysv.$(OBJEXT) + -rm -f src/m68k/sysv.lo + -rm -f src/mips/ffi.$(OBJEXT) + -rm -f src/mips/ffi.lo + -rm -f src/mips/n32.$(OBJEXT) + -rm -f src/mips/n32.lo + -rm -f src/mips/o32.$(OBJEXT) + -rm -f src/mips/o32.lo + -rm -f src/pa/ffi.$(OBJEXT) + -rm -f src/pa/ffi.lo + -rm -f src/pa/hpux32.$(OBJEXT) + -rm -f src/pa/hpux32.lo + -rm -f src/pa/linux.$(OBJEXT) + -rm -f src/pa/linux.lo + -rm -f src/powerpc/aix.$(OBJEXT) + -rm -f src/powerpc/aix.lo + -rm -f src/powerpc/aix_closure.$(OBJEXT) + -rm -f src/powerpc/aix_closure.lo + -rm -f src/powerpc/darwin.$(OBJEXT) + -rm -f src/powerpc/darwin.lo + -rm -f src/powerpc/darwin_closure.$(OBJEXT) + -rm -f src/powerpc/darwin_closure.lo + -rm -f src/powerpc/ffi.$(OBJEXT) + -rm -f src/powerpc/ffi.lo + -rm -f src/powerpc/ffi_darwin.$(OBJEXT) + -rm -f src/powerpc/ffi_darwin.lo + -rm -f src/powerpc/linux64.$(OBJEXT) + -rm -f src/powerpc/linux64.lo + -rm -f src/powerpc/linux64_closure.$(OBJEXT) + -rm -f src/powerpc/linux64_closure.lo + -rm -f src/powerpc/ppc_closure.$(OBJEXT) + -rm -f src/powerpc/ppc_closure.lo + -rm -f src/powerpc/sysv.$(OBJEXT) + -rm -f src/powerpc/sysv.lo + -rm -f src/prep_cif.$(OBJEXT) + -rm -f src/prep_cif.lo + -rm -f src/raw_api.$(OBJEXT) + -rm -f src/raw_api.lo + -rm -f src/s390/ffi.$(OBJEXT) + -rm -f src/s390/ffi.lo + -rm -f src/s390/sysv.$(OBJEXT) + -rm -f src/s390/sysv.lo + -rm -f src/sh/ffi.$(OBJEXT) + -rm -f src/sh/ffi.lo + -rm -f src/sh/sysv.$(OBJEXT) + -rm -f src/sh/sysv.lo + -rm -f src/sh64/ffi.$(OBJEXT) + -rm -f src/sh64/ffi.lo + -rm -f src/sh64/sysv.$(OBJEXT) + -rm -f src/sh64/sysv.lo + -rm -f src/sparc/ffi.$(OBJEXT) + -rm -f src/sparc/ffi.lo + -rm -f src/sparc/v8.$(OBJEXT) + -rm -f src/sparc/v8.lo + -rm -f src/sparc/v9.$(OBJEXT) + -rm -f src/sparc/v9.lo + -rm -f src/types.$(OBJEXT) + -rm -f src/types.lo + -rm -f src/x86/darwin.$(OBJEXT) + -rm -f src/x86/darwin.lo + -rm -f src/x86/darwin64.$(OBJEXT) + -rm -f src/x86/darwin64.lo + -rm -f src/x86/ffi.$(OBJEXT) + -rm -f src/x86/ffi.lo + -rm -f src/x86/ffi64.$(OBJEXT) + -rm -f src/x86/ffi64.lo + -rm -f src/x86/freebsd.$(OBJEXT) + -rm -f src/x86/freebsd.lo + -rm -f src/x86/sysv.$(OBJEXT) + -rm -f src/x86/sysv.lo + -rm -f src/x86/unix64.$(OBJEXT) + -rm -f src/x86/unix64.lo + -rm -f src/x86/win32.$(OBJEXT) + -rm -f src/x86/win32.lo + -rm -f src/x86/win64.$(OBJEXT) + -rm -f src/x86/win64.lo distclean-compile: -rm -f *.tab.c @@ -1022,17 +915,12 @@ @AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/prep_cif.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/raw_api.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/types.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@src/aarch64/$(DEPDIR)/ffi.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@src/aarch64/$(DEPDIR)/sysv.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/alpha/$(DEPDIR)/ffi.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/alpha/$(DEPDIR)/osf.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/arm/$(DEPDIR)/ffi.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/arm/$(DEPDIR)/sysv.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@src/arm/$(DEPDIR)/trampoline.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/avr32/$(DEPDIR)/ffi.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/avr32/$(DEPDIR)/sysv.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@src/bfin/$(DEPDIR)/ffi.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@src/bfin/$(DEPDIR)/sysv.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/cris/$(DEPDIR)/ffi.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/cris/$(DEPDIR)/sysv.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/frv/$(DEPDIR)/eabi.Plo@am__quote@ @@ -1043,15 +931,9 @@ @AMDEP_TRUE@@am__include@ @am__quote@src/m32r/$(DEPDIR)/sysv.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/m68k/$(DEPDIR)/ffi.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/m68k/$(DEPDIR)/sysv.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@src/metag/$(DEPDIR)/ffi.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@src/metag/$(DEPDIR)/sysv.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@src/microblaze/$(DEPDIR)/ffi.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@src/microblaze/$(DEPDIR)/sysv.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/mips/$(DEPDIR)/ffi.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/mips/$(DEPDIR)/n32.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/mips/$(DEPDIR)/o32.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@src/moxie/$(DEPDIR)/eabi.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@src/moxie/$(DEPDIR)/ffi.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/pa/$(DEPDIR)/ffi.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/pa/$(DEPDIR)/hpux32.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/pa/$(DEPDIR)/linux.Plo@am__quote@ @@ -1074,8 +956,6 @@ @AMDEP_TRUE@@am__include@ @am__quote@src/sparc/$(DEPDIR)/ffi.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/sparc/$(DEPDIR)/v8.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/sparc/$(DEPDIR)/v9.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@src/tile/$(DEPDIR)/ffi.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@src/tile/$(DEPDIR)/tile.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/x86/$(DEPDIR)/darwin.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/x86/$(DEPDIR)/darwin64.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/x86/$(DEPDIR)/ffi.Plo@am__quote@ @@ -1085,8 +965,6 @@ @AMDEP_TRUE@@am__include@ @am__quote@src/x86/$(DEPDIR)/unix64.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/x86/$(DEPDIR)/win32.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/x86/$(DEPDIR)/win64.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@src/xtensa/$(DEPDIR)/ffi.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@src/xtensa/$(DEPDIR)/sysv.Plo@am__quote@ .S.o: @am__fastdepCCAS_TRUE@ depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\ @@ -1142,29 +1020,22 @@ clean-libtool: -rm -rf .libs _libs -rm -rf src/.libs src/_libs - -rm -rf src/aarch64/.libs src/aarch64/_libs -rm -rf src/alpha/.libs src/alpha/_libs -rm -rf src/arm/.libs src/arm/_libs -rm -rf src/avr32/.libs src/avr32/_libs - -rm -rf src/bfin/.libs src/bfin/_libs -rm -rf src/cris/.libs src/cris/_libs -rm -rf src/frv/.libs src/frv/_libs -rm -rf src/ia64/.libs src/ia64/_libs -rm -rf src/m32r/.libs src/m32r/_libs -rm -rf src/m68k/.libs src/m68k/_libs - -rm -rf src/metag/.libs src/metag/_libs - -rm -rf src/microblaze/.libs src/microblaze/_libs -rm -rf src/mips/.libs src/mips/_libs - -rm -rf src/moxie/.libs src/moxie/_libs -rm -rf src/pa/.libs src/pa/_libs -rm -rf src/powerpc/.libs src/powerpc/_libs -rm -rf src/s390/.libs src/s390/_libs -rm -rf src/sh/.libs src/sh/_libs -rm -rf src/sh64/.libs src/sh64/_libs -rm -rf src/sparc/.libs src/sparc/_libs - -rm -rf src/tile/.libs src/tile/_libs -rm -rf src/x86/.libs src/x86/_libs - -rm -rf src/xtensa/.libs src/xtensa/_libs distclean-libtool: -rm -f libtool config.lt @@ -1197,12 +1068,12 @@ doc/libffi.dvi: doc/libffi.texi $(srcdir)/doc/version.texi doc/$(am__dirstamp) TEXINPUTS="$(am__TEXINFO_TEX_DIR)$(PATH_SEPARATOR)$$TEXINPUTS" \ MAKEINFO='$(MAKEINFO) $(AM_MAKEINFOFLAGS) $(MAKEINFOFLAGS) -I doc -I $(srcdir)/doc' \ - $(TEXI2DVI) --clean -o $@ `test -f 'doc/libffi.texi' || echo '$(srcdir)/'`doc/libffi.texi + $(TEXI2DVI) -o $@ `test -f 'doc/libffi.texi' || echo '$(srcdir)/'`doc/libffi.texi doc/libffi.pdf: doc/libffi.texi $(srcdir)/doc/version.texi doc/$(am__dirstamp) TEXINPUTS="$(am__TEXINFO_TEX_DIR)$(PATH_SEPARATOR)$$TEXINPUTS" \ MAKEINFO='$(MAKEINFO) $(AM_MAKEINFOFLAGS) $(MAKEINFOFLAGS) -I doc -I $(srcdir)/doc' \ - $(TEXI2PDF) --clean -o $@ `test -f 'doc/libffi.texi' || echo '$(srcdir)/'`doc/libffi.texi + $(TEXI2PDF) -o $@ `test -f 'doc/libffi.texi' || echo '$(srcdir)/'`doc/libffi.texi doc/libffi.html: doc/libffi.texi $(srcdir)/doc/version.texi doc/$(am__dirstamp) rm -rf $(@:.html=.htp) @@ -1239,7 +1110,7 @@ @MAINTAINER_MODE_TRUE@ -rm -f $(srcdir)/doc/stamp-vti $(srcdir)/doc/version.texi .dvi.ps: TEXINPUTS="$(am__TEXINFO_TEX_DIR)$(PATH_SEPARATOR)$$TEXINPUTS" \ - $(DVIPS) -o $@ $< + $(DVIPS) -o $@ $< uninstall-dvi-am: @$(NORMAL_UNINSTALL) @@ -1261,7 +1132,9 @@ uninstall-info-am: @$(PRE_UNINSTALL) - @if test -d '$(DESTDIR)$(infodir)' && $(am__can_run_installinfo); then \ + @if test -d '$(DESTDIR)$(infodir)' && \ + (install-info --version && \ + install-info --version 2>&1 | sed 1q | grep -i -v debian) >/dev/null 2>&1; then \ list='$(INFO_DEPS)'; \ for file in $$list; do \ relfile=`echo "$$file" | sed 's|^.*/||'`; \ @@ -1333,11 +1206,8 @@ done install-pkgconfigDATA: $(pkgconfig_DATA) @$(NORMAL_INSTALL) + test -z "$(pkgconfigdir)" || $(MKDIR_P) "$(DESTDIR)$(pkgconfigdir)" @list='$(pkgconfig_DATA)'; test -n "$(pkgconfigdir)" || list=; \ - if test -n "$$list"; then \ - echo " $(MKDIR_P) '$(DESTDIR)$(pkgconfigdir)'"; \ - $(MKDIR_P) "$(DESTDIR)$(pkgconfigdir)" || exit 1; \ - fi; \ for p in $$list; do \ if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ echo "$$d$$p"; \ @@ -1351,16 +1221,18 @@ @$(NORMAL_UNINSTALL) @list='$(pkgconfig_DATA)'; test -n "$(pkgconfigdir)" || list=; \ files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \ - dir='$(DESTDIR)$(pkgconfigdir)'; $(am__uninstall_files_from_dir) + test -n "$$files" || exit 0; \ + echo " ( cd '$(DESTDIR)$(pkgconfigdir)' && rm -f" $$files ")"; \ + cd "$(DESTDIR)$(pkgconfigdir)" && rm -f $$files # This directory's subdirectories are mostly independent; you can cd -# into them and run 'make' without going through this Makefile. -# To change the values of 'make' variables: instead of editing Makefiles, -# (1) if the variable is set in 'config.status', edit 'config.status' -# (which will cause the Makefiles to be regenerated when you run 'make'); -# (2) otherwise, pass the desired values on the 'make' command line. -$(RECURSIVE_TARGETS) $(RECURSIVE_CLEAN_TARGETS): - @fail= failcom='exit 1'; \ +# into them and run `make' without going through this Makefile. +# To change the values of `make' variables: instead of editing Makefiles, +# (1) if the variable is set in `config.status', edit `config.status' +# (which will cause the Makefiles to be regenerated when you run `make'); +# (2) otherwise, pass the desired values on the `make' command line. +$(RECURSIVE_TARGETS): + @failcom='exit 1'; \ for f in x $$MAKEFLAGS; do \ case $$f in \ *=* | --[!k]*);; \ @@ -1369,11 +1241,7 @@ done; \ dot_seen=no; \ target=`echo $@ | sed s/-recursive//`; \ - case "$@" in \ - distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \ - *) list='$(SUBDIRS)' ;; \ - esac; \ - for subdir in $$list; do \ + list='$(SUBDIRS)'; for subdir in $$list; do \ echo "Making $$target in $$subdir"; \ if test "$$subdir" = "."; then \ dot_seen=yes; \ @@ -1387,6 +1255,37 @@ if test "$$dot_seen" = "no"; then \ $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \ fi; test -z "$$fail" + +$(RECURSIVE_CLEAN_TARGETS): + @failcom='exit 1'; \ + for f in x $$MAKEFLAGS; do \ + case $$f in \ + *=* | --[!k]*);; \ + *k*) failcom='fail=yes';; \ + esac; \ + done; \ + dot_seen=no; \ + case "$@" in \ + distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \ + *) list='$(SUBDIRS)' ;; \ + esac; \ + rev=''; for subdir in $$list; do \ + if test "$$subdir" = "."; then :; else \ + rev="$$subdir $$rev"; \ + fi; \ + done; \ + rev="$$rev ."; \ + target=`echo $@ | sed s/-recursive//`; \ + for subdir in $$rev; do \ + echo "Making $$target in $$subdir"; \ + if test "$$subdir" = "."; then \ + local_target="$$target-am"; \ + else \ + local_target="$$target"; \ + fi; \ + ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ + || eval $$failcom; \ + done && test -z "$$fail" tags-recursive: list='$(SUBDIRS)'; for subdir in $$list; do \ test "$$subdir" = . || ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \ @@ -1395,10 +1294,6 @@ list='$(SUBDIRS)'; for subdir in $$list; do \ test "$$subdir" = . || ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) ctags); \ done -cscopelist-recursive: - list='$(SUBDIRS)'; for subdir in $$list; do \ - test "$$subdir" = . || ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) cscopelist); \ - done ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ @@ -1462,32 +1357,8 @@ && $(am__cd) $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) "$$here" -cscope: cscope.files - test ! -s cscope.files \ - || $(CSCOPE) -b -q $(AM_CSCOPEFLAGS) $(CSCOPEFLAGS) -i cscope.files $(CSCOPE_ARGS) - -clean-cscope: - -rm -f cscope.files - -cscope.files: clean-cscope cscopelist-recursive cscopelist - -cscopelist: cscopelist-recursive $(HEADERS) $(SOURCES) $(LISP) - list='$(SOURCES) $(HEADERS) $(LISP)'; \ - case "$(srcdir)" in \ - [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ - *) sdir=$(subdir)/$(srcdir) ;; \ - esac; \ - for i in $$list; do \ - if test -f "$$i"; then \ - echo "$(subdir)/$$i"; \ - else \ - echo "$$sdir/$$i"; \ - fi; \ - done >> $(top_builddir)/cscope.files - distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags - -rm -f cscope.out cscope.in.out cscope.po.out cscope.files distdir: $(DISTFILES) $(am__remove_distdir) @@ -1523,10 +1394,13 @@ done @list='$(DIST_SUBDIRS)'; for subdir in $$list; do \ if test "$$subdir" = .; then :; else \ - $(am__make_dryrun) \ - || test -d "$(distdir)/$$subdir" \ - || $(MKDIR_P) "$(distdir)/$$subdir" \ - || exit 1; \ + test -d "$(distdir)/$$subdir" \ + || $(MKDIR_P) "$(distdir)/$$subdir" \ + || exit 1; \ + fi; \ + done + @list='$(DIST_SUBDIRS)'; for subdir in $$list; do \ + if test "$$subdir" = .; then :; else \ dir1=$$subdir; dir2="$(distdir)/$$subdir"; \ $(am__relativize); \ new_distdir=$$reldir; \ @@ -1550,44 +1424,43 @@ top_distdir="$(top_distdir)" distdir="$(distdir)" \ dist-info -test -n "$(am__skip_mode_fix)" \ - || find "$(distdir)" -type d ! -perm -755 \ - -exec chmod u+rwx,go+rx {} \; -o \ + || find "$(distdir)" -type d ! -perm -777 -exec chmod a+rwx {} \; -o \ ! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; -o \ ! -type d ! -perm -400 -exec chmod a+r {} \; -o \ ! -type d ! -perm -444 -exec $(install_sh) -c -m a+r {} {} \; \ || chmod -R a+r "$(distdir)" dist-gzip: distdir tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz - $(am__post_remove_distdir) + $(am__remove_distdir) dist-bzip2: distdir - tardir=$(distdir) && $(am__tar) | BZIP2=$${BZIP2--9} bzip2 -c >$(distdir).tar.bz2 - $(am__post_remove_distdir) + tardir=$(distdir) && $(am__tar) | bzip2 -9 -c >$(distdir).tar.bz2 + $(am__remove_distdir) -dist-lzip: distdir - tardir=$(distdir) && $(am__tar) | lzip -c $${LZIP_OPT--9} >$(distdir).tar.lz - $(am__post_remove_distdir) +dist-lzma: distdir + tardir=$(distdir) && $(am__tar) | lzma -9 -c >$(distdir).tar.lzma + $(am__remove_distdir) dist-xz: distdir - tardir=$(distdir) && $(am__tar) | XZ_OPT=$${XZ_OPT--e} xz -c >$(distdir).tar.xz - $(am__post_remove_distdir) + tardir=$(distdir) && $(am__tar) | xz -c >$(distdir).tar.xz + $(am__remove_distdir) dist-tarZ: distdir tardir=$(distdir) && $(am__tar) | compress -c >$(distdir).tar.Z - $(am__post_remove_distdir) + $(am__remove_distdir) dist-shar: distdir shar $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).shar.gz - $(am__post_remove_distdir) + $(am__remove_distdir) dist-zip: distdir -rm -f $(distdir).zip zip -rq $(distdir).zip $(distdir) - $(am__post_remove_distdir) + $(am__remove_distdir) -dist dist-all: - $(MAKE) $(AM_MAKEFLAGS) $(DIST_TARGETS) am__post_remove_distdir='@:' - $(am__post_remove_distdir) +dist dist-all: distdir + tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz + $(am__remove_distdir) # This target untars the dist file and tries a VPATH configuration. Then # it guarantees that the distribution is self-contained by making another @@ -1595,21 +1468,21 @@ distcheck: dist case '$(DIST_ARCHIVES)' in \ *.tar.gz*) \ - GZIP=$(GZIP_ENV) gzip -dc $(distdir).tar.gz | $(am__untar) ;;\ + GZIP=$(GZIP_ENV) gunzip -c $(distdir).tar.gz | $(am__untar) ;;\ *.tar.bz2*) \ - bzip2 -dc $(distdir).tar.bz2 | $(am__untar) ;;\ - *.tar.lz*) \ - lzip -dc $(distdir).tar.lz | $(am__untar) ;;\ + bunzip2 -c $(distdir).tar.bz2 | $(am__untar) ;;\ + *.tar.lzma*) \ + unlzma -c $(distdir).tar.lzma | $(am__untar) ;;\ *.tar.xz*) \ xz -dc $(distdir).tar.xz | $(am__untar) ;;\ *.tar.Z*) \ uncompress -c $(distdir).tar.Z | $(am__untar) ;;\ *.shar.gz*) \ - GZIP=$(GZIP_ENV) gzip -dc $(distdir).shar.gz | unshar ;;\ + GZIP=$(GZIP_ENV) gunzip -c $(distdir).shar.gz | unshar ;;\ *.zip*) \ unzip $(distdir).zip ;;\ esac - chmod -R a-w $(distdir); chmod u+w $(distdir) + chmod -R a-w $(distdir); chmod a+w $(distdir) mkdir $(distdir)/_build mkdir $(distdir)/_inst chmod a-w $(distdir) @@ -1619,7 +1492,6 @@ && am__cwd=`pwd` \ && $(am__cd) $(distdir)/_build \ && ../configure --srcdir=.. --prefix="$$dc_install_base" \ - $(AM_DISTCHECK_CONFIGURE_FLAGS) \ $(DISTCHECK_CONFIGURE_FLAGS) \ && $(MAKE) $(AM_MAKEFLAGS) \ && $(MAKE) $(AM_MAKEFLAGS) dvi \ @@ -1643,21 +1515,13 @@ && $(MAKE) $(AM_MAKEFLAGS) distcleancheck \ && cd "$$am__cwd" \ || exit 1 - $(am__post_remove_distdir) + $(am__remove_distdir) @(echo "$(distdir) archives ready for distribution: "; \ list='$(DIST_ARCHIVES)'; for i in $$list; do echo $$i; done) | \ sed -e 1h -e 1s/./=/g -e 1p -e 1x -e '$$p' -e '$$x' distuninstallcheck: - @test -n '$(distuninstallcheck_dir)' || { \ - echo 'ERROR: trying to run $@ with an empty' \ - '$$(distuninstallcheck_dir)' >&2; \ - exit 1; \ - }; \ - $(am__cd) '$(distuninstallcheck_dir)' || { \ - echo 'ERROR: cannot chdir into $(distuninstallcheck_dir)' >&2; \ - exit 1; \ - }; \ - test `$(am__distuninstallcheck_listfiles) | wc -l` -eq 0 \ + @$(am__cd) '$(distuninstallcheck_dir)' \ + && test `$(distuninstallcheck_listfiles) | wc -l` -le 1 \ || { echo "ERROR: files left after uninstall:" ; \ if test -n "$(DESTDIR)"; then \ echo " (check DESTDIR support)"; \ @@ -1678,7 +1542,7 @@ all-am: Makefile $(INFO_DEPS) $(LTLIBRARIES) $(DATA) fficonfig.h installdirs: installdirs-recursive installdirs-am: - for dir in "$(DESTDIR)$(toolexeclibdir)" "$(DESTDIR)$(infodir)" "$(DESTDIR)$(pkgconfigdir)"; do \ + for dir in "$(DESTDIR)$(libdir)" "$(DESTDIR)$(infodir)" "$(DESTDIR)$(pkgconfigdir)"; do \ test -z "$$dir" || $(MKDIR_P) "$$dir"; \ done install: install-recursive @@ -1691,15 +1555,10 @@ installcheck: installcheck-recursive install-strip: - if test -z '$(STRIP)'; then \ - $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ - install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ - install; \ - else \ - $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ - install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ - "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ - fi + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install mostlyclean-generic: clean-generic: @@ -1710,16 +1569,12 @@ -rm -f doc/$(am__dirstamp) -rm -f src/$(DEPDIR)/$(am__dirstamp) -rm -f src/$(am__dirstamp) - -rm -f src/aarch64/$(DEPDIR)/$(am__dirstamp) - -rm -f src/aarch64/$(am__dirstamp) -rm -f src/alpha/$(DEPDIR)/$(am__dirstamp) -rm -f src/alpha/$(am__dirstamp) -rm -f src/arm/$(DEPDIR)/$(am__dirstamp) -rm -f src/arm/$(am__dirstamp) -rm -f src/avr32/$(DEPDIR)/$(am__dirstamp) -rm -f src/avr32/$(am__dirstamp) - -rm -f src/bfin/$(DEPDIR)/$(am__dirstamp) - -rm -f src/bfin/$(am__dirstamp) -rm -f src/cris/$(DEPDIR)/$(am__dirstamp) -rm -f src/cris/$(am__dirstamp) -rm -f src/frv/$(DEPDIR)/$(am__dirstamp) @@ -1730,14 +1585,8 @@ -rm -f src/m32r/$(am__dirstamp) -rm -f src/m68k/$(DEPDIR)/$(am__dirstamp) -rm -f src/m68k/$(am__dirstamp) - -rm -f src/metag/$(DEPDIR)/$(am__dirstamp) - -rm -f src/metag/$(am__dirstamp) - -rm -f src/microblaze/$(DEPDIR)/$(am__dirstamp) - -rm -f src/microblaze/$(am__dirstamp) -rm -f src/mips/$(DEPDIR)/$(am__dirstamp) -rm -f src/mips/$(am__dirstamp) - -rm -f src/moxie/$(DEPDIR)/$(am__dirstamp) - -rm -f src/moxie/$(am__dirstamp) -rm -f src/pa/$(DEPDIR)/$(am__dirstamp) -rm -f src/pa/$(am__dirstamp) -rm -f src/powerpc/$(DEPDIR)/$(am__dirstamp) @@ -1750,25 +1599,20 @@ -rm -f src/sh64/$(am__dirstamp) -rm -f src/sparc/$(DEPDIR)/$(am__dirstamp) -rm -f src/sparc/$(am__dirstamp) - -rm -f src/tile/$(DEPDIR)/$(am__dirstamp) - -rm -f src/tile/$(am__dirstamp) -rm -f src/x86/$(DEPDIR)/$(am__dirstamp) -rm -f src/x86/$(am__dirstamp) - -rm -f src/xtensa/$(DEPDIR)/$(am__dirstamp) - -rm -f src/xtensa/$(am__dirstamp) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-recursive -clean-am: clean-aminfo clean-generic clean-libtool \ - clean-noinstLTLIBRARIES clean-toolexeclibLTLIBRARIES \ - mostlyclean-am +clean-am: clean-aminfo clean-generic clean-libLTLIBRARIES \ + clean-libtool clean-noinstLTLIBRARIES mostlyclean-am distclean: distclean-recursive -rm -f $(am__CONFIG_DISTCLEAN_FILES) - -rm -rf src/$(DEPDIR) src/aarch64/$(DEPDIR) src/alpha/$(DEPDIR) src/arm/$(DEPDIR) src/avr32/$(DEPDIR) src/bfin/$(DEPDIR) src/cris/$(DEPDIR) src/frv/$(DEPDIR) src/ia64/$(DEPDIR) src/m32r/$(DEPDIR) src/m68k/$(DEPDIR) src/metag/$(DEPDIR) src/microblaze/$(DEPDIR) src/mips/$(DEPDIR) src/moxie/$(DEPDIR) src/pa/$(DEPDIR) src/powerpc/$(DEPDIR) src/s390/$(DEPDIR) src/sh/$(DEPDIR) src/sh64/$(DEPDIR) src/sparc/$(DEPDIR) src/tile/$(DEPDIR) src/x86/$(DEPDIR) src/xtensa/$(DEPDIR) + -rm -rf src/$(DEPDIR) src/alpha/$(DEPDIR) src/arm/$(DEPDIR) src/avr32/$(DEPDIR) src/cris/$(DEPDIR) src/frv/$(DEPDIR) src/ia64/$(DEPDIR) src/m32r/$(DEPDIR) src/m68k/$(DEPDIR) src/mips/$(DEPDIR) src/pa/$(DEPDIR) src/powerpc/$(DEPDIR) src/s390/$(DEPDIR) src/sh/$(DEPDIR) src/sh64/$(DEPDIR) src/sparc/$(DEPDIR) src/x86/$(DEPDIR) -rm -f Makefile distclean-am: clean-am distclean-compile distclean-generic \ distclean-hdr distclean-libtool distclean-tags @@ -1791,11 +1635,8 @@ install-dvi-am: $(DVIS) @$(NORMAL_INSTALL) + test -z "$(dvidir)" || $(MKDIR_P) "$(DESTDIR)$(dvidir)" @list='$(DVIS)'; test -n "$(dvidir)" || list=; \ - if test -n "$$list"; then \ - echo " $(MKDIR_P) '$(DESTDIR)$(dvidir)'"; \ - $(MKDIR_P) "$(DESTDIR)$(dvidir)" || exit 1; \ - fi; \ for p in $$list; do \ if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ echo "$$d$$p"; \ @@ -1804,28 +1645,22 @@ echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(dvidir)'"; \ $(INSTALL_DATA) $$files "$(DESTDIR)$(dvidir)" || exit $$?; \ done -install-exec-am: install-toolexeclibLTLIBRARIES - -install-html: install-html-recursive +install-exec-am: install-libLTLIBRARIES install-html-am: $(HTMLS) @$(NORMAL_INSTALL) + test -z "$(htmldir)" || $(MKDIR_P) "$(DESTDIR)$(htmldir)" @list='$(HTMLS)'; list2=; test -n "$(htmldir)" || list=; \ - if test -n "$$list"; then \ - echo " $(MKDIR_P) '$(DESTDIR)$(htmldir)'"; \ - $(MKDIR_P) "$(DESTDIR)$(htmldir)" || exit 1; \ - fi; \ for p in $$list; do \ if test -f "$$p" || test -d "$$p"; then d=; else d="$(srcdir)/"; fi; \ $(am__strip_dir) \ - d2=$$d$$p; \ - if test -d "$$d2"; then \ + if test -d "$$d$$p"; then \ echo " $(MKDIR_P) '$(DESTDIR)$(htmldir)/$$f'"; \ $(MKDIR_P) "$(DESTDIR)$(htmldir)/$$f" || exit 1; \ - echo " $(INSTALL_DATA) '$$d2'/* '$(DESTDIR)$(htmldir)/$$f'"; \ - $(INSTALL_DATA) "$$d2"/* "$(DESTDIR)$(htmldir)/$$f" || exit $$?; \ + echo " $(INSTALL_DATA) '$$d$$p'/* '$(DESTDIR)$(htmldir)/$$f'"; \ + $(INSTALL_DATA) "$$d$$p"/* "$(DESTDIR)$(htmldir)/$$f" || exit $$?; \ else \ - list2="$$list2 $$d2"; \ + list2="$$list2 $$d$$p"; \ fi; \ done; \ test -z "$$list2" || { echo "$$list2" | $(am__base_list) | \ @@ -1837,12 +1672,9 @@ install-info-am: $(INFO_DEPS) @$(NORMAL_INSTALL) + test -z "$(infodir)" || $(MKDIR_P) "$(DESTDIR)$(infodir)" @srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \ list='$(INFO_DEPS)'; test -n "$(infodir)" || list=; \ - if test -n "$$list"; then \ - echo " $(MKDIR_P) '$(DESTDIR)$(infodir)'"; \ - $(MKDIR_P) "$(DESTDIR)$(infodir)" || exit 1; \ - fi; \ for file in $$list; do \ case $$file in \ $(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \ @@ -1860,7 +1692,8 @@ echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(infodir)'"; \ $(INSTALL_DATA) $$files "$(DESTDIR)$(infodir)" || exit $$?; done @$(POST_INSTALL) - @if $(am__can_run_installinfo); then \ + @if (install-info --version && \ + install-info --version 2>&1 | sed 1q | grep -i -v debian) >/dev/null 2>&1; then \ list='$(INFO_DEPS)'; test -n "$(infodir)" || list=; \ for file in $$list; do \ relfile=`echo "$$file" | sed 's|^.*/||'`; \ @@ -1870,15 +1703,10 @@ else : ; fi install-man: -install-pdf: install-pdf-recursive - install-pdf-am: $(PDFS) @$(NORMAL_INSTALL) + test -z "$(pdfdir)" || $(MKDIR_P) "$(DESTDIR)$(pdfdir)" @list='$(PDFS)'; test -n "$(pdfdir)" || list=; \ - if test -n "$$list"; then \ - echo " $(MKDIR_P) '$(DESTDIR)$(pdfdir)'"; \ - $(MKDIR_P) "$(DESTDIR)$(pdfdir)" || exit 1; \ - fi; \ for p in $$list; do \ if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ echo "$$d$$p"; \ @@ -1890,11 +1718,8 @@ install-ps-am: $(PSS) @$(NORMAL_INSTALL) + test -z "$(psdir)" || $(MKDIR_P) "$(DESTDIR)$(psdir)" @list='$(PSS)'; test -n "$(psdir)" || list=; \ - if test -n "$$list"; then \ - echo " $(MKDIR_P) '$(DESTDIR)$(psdir)'"; \ - $(MKDIR_P) "$(DESTDIR)$(psdir)" || exit 1; \ - fi; \ for p in $$list; do \ if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ echo "$$d$$p"; \ @@ -1907,7 +1732,7 @@ maintainer-clean: maintainer-clean-recursive -rm -f $(am__CONFIG_DISTCLEAN_FILES) -rm -rf $(top_srcdir)/autom4te.cache - -rm -rf src/$(DEPDIR) src/aarch64/$(DEPDIR) src/alpha/$(DEPDIR) src/arm/$(DEPDIR) src/avr32/$(DEPDIR) src/bfin/$(DEPDIR) src/cris/$(DEPDIR) src/frv/$(DEPDIR) src/ia64/$(DEPDIR) src/m32r/$(DEPDIR) src/m68k/$(DEPDIR) src/metag/$(DEPDIR) src/microblaze/$(DEPDIR) src/mips/$(DEPDIR) src/moxie/$(DEPDIR) src/pa/$(DEPDIR) src/powerpc/$(DEPDIR) src/s390/$(DEPDIR) src/sh/$(DEPDIR) src/sh64/$(DEPDIR) src/sparc/$(DEPDIR) src/tile/$(DEPDIR) src/x86/$(DEPDIR) src/xtensa/$(DEPDIR) + -rm -rf src/$(DEPDIR) src/alpha/$(DEPDIR) src/arm/$(DEPDIR) src/avr32/$(DEPDIR) src/cris/$(DEPDIR) src/frv/$(DEPDIR) src/ia64/$(DEPDIR) src/m32r/$(DEPDIR) src/m68k/$(DEPDIR) src/mips/$(DEPDIR) src/pa/$(DEPDIR) src/powerpc/$(DEPDIR) src/s390/$(DEPDIR) src/sh/$(DEPDIR) src/sh64/$(DEPDIR) src/sparc/$(DEPDIR) src/x86/$(DEPDIR) -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-aminfo \ maintainer-clean-generic maintainer-clean-vti @@ -1926,39 +1751,41 @@ ps-am: $(PSS) uninstall-am: uninstall-dvi-am uninstall-html-am uninstall-info-am \ - uninstall-pdf-am uninstall-pkgconfigDATA uninstall-ps-am \ - uninstall-toolexeclibLTLIBRARIES + uninstall-libLTLIBRARIES uninstall-pdf-am \ + uninstall-pkgconfigDATA uninstall-ps-am .MAKE: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) all \ - cscopelist-recursive ctags-recursive install-am install-strip \ - tags-recursive + ctags-recursive install-am install-strip tags-recursive .PHONY: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) CTAGS GTAGS \ all all-am am--refresh check check-am clean clean-aminfo \ - clean-cscope clean-generic clean-libtool \ - clean-noinstLTLIBRARIES clean-toolexeclibLTLIBRARIES cscope \ - cscopelist cscopelist-recursive ctags ctags-recursive dist \ - dist-all dist-bzip2 dist-gzip dist-info dist-lzip dist-shar \ - dist-tarZ dist-xz dist-zip distcheck distclean \ - distclean-compile distclean-generic distclean-hdr \ - distclean-libtool distclean-tags distcleancheck distdir \ - distuninstallcheck dvi dvi-am html html-am info info-am \ - install install-am install-data install-data-am install-dvi \ - install-dvi-am install-exec install-exec-am install-html \ - install-html-am install-info install-info-am install-man \ - install-pdf install-pdf-am install-pkgconfigDATA install-ps \ - install-ps-am install-strip install-toolexeclibLTLIBRARIES \ - installcheck installcheck-am installdirs installdirs-am \ - maintainer-clean maintainer-clean-aminfo \ - maintainer-clean-generic maintainer-clean-vti mostlyclean \ - mostlyclean-aminfo mostlyclean-compile mostlyclean-generic \ - mostlyclean-libtool mostlyclean-vti pdf pdf-am ps ps-am tags \ - tags-recursive uninstall uninstall-am uninstall-dvi-am \ - uninstall-html-am uninstall-info-am uninstall-pdf-am \ - uninstall-pkgconfigDATA uninstall-ps-am \ - uninstall-toolexeclibLTLIBRARIES + clean-generic clean-libLTLIBRARIES clean-libtool \ + clean-noinstLTLIBRARIES ctags ctags-recursive dist dist-all \ + dist-bzip2 dist-gzip dist-info dist-lzma dist-shar dist-tarZ \ + dist-xz dist-zip distcheck distclean distclean-compile \ + distclean-generic distclean-hdr distclean-libtool \ + distclean-tags distcleancheck distdir distuninstallcheck dvi \ + dvi-am html html-am info info-am install install-am \ + install-data install-data-am install-dvi install-dvi-am \ + install-exec install-exec-am install-html install-html-am \ + install-info install-info-am install-libLTLIBRARIES \ + install-man install-pdf install-pdf-am install-pkgconfigDATA \ + install-ps install-ps-am install-strip installcheck \ + installcheck-am installdirs installdirs-am maintainer-clean \ + maintainer-clean-aminfo maintainer-clean-generic \ + maintainer-clean-vti mostlyclean mostlyclean-aminfo \ + mostlyclean-compile mostlyclean-generic mostlyclean-libtool \ + mostlyclean-vti pdf pdf-am ps ps-am tags tags-recursive \ + uninstall uninstall-am uninstall-dvi-am uninstall-html-am \ + uninstall-info-am uninstall-libLTLIBRARIES uninstall-pdf-am \ + uninstall-pkgconfigDATA uninstall-ps-am +# No install-html or install-pdf support in automake yet +.PHONY: install-html install-pdf +install-html: +install-pdf: + # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi/README --- a/Modules/_ctypes/libffi/README Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/_ctypes/libffi/README Sun Jul 20 10:52:46 2014 -0400 @@ -1,7 +1,7 @@ Status ====== -libffi-3.0.13 was released on March 17, 2013. Check the libffi web +libffi-3.0.10 was released on XXXXXXXXXX, 2010. Check the libffi web page for updates: . @@ -43,70 +43,46 @@ For specific configuration details and testing status, please refer to the wiki page here: - http://www.moxielogic.org/wiki/index.php?title=Libffi_3.0.13 + http://www.moxielogic.org/wiki/index.php?title=Libffi_3.0.10 At the time of release, the following basic configurations have been tested: -|-----------------+------------------+-------------------------| -| Architecture | Operating System | Compiler | -|-----------------+------------------+-------------------------| -| AArch64 | Linux | GCC | -| Alpha | Linux | GCC | -| Alpha | Tru64 | GCC | -| ARM | Linux | GCC | -| ARM | iOS | GCC | -| AVR32 | Linux | GCC | -| Blackfin | uClinux | GCC | -| HPPA | HPUX | GCC | -| IA-64 | Linux | GCC | -| M68K | FreeMiNT | GCC | -| M68K | Linux | GCC | -| M68K | RTEMS | GCC | -| Meta | Linux | GCC | -| MicroBlaze | Linux | GCC | -| MIPS | IRIX | GCC | -| MIPS | Linux | GCC | -| MIPS | RTEMS | GCC | -| MIPS64 | Linux | GCC | -| Moxie | Bare metal | GCC -| PowerPC 32-bit | AIX | IBM XL C | -| PowerPC 64-bit | AIX | IBM XL C | -| PowerPC | AMIGA | GCC | -| PowerPC | Linux | GCC | -| PowerPC | Mac OSX | GCC | -| PowerPC | FreeBSD | GCC | -| PowerPC 64-bit | FreeBSD | GCC | -| PowerPC 64-bit | Linux | GCC | -| S390 | Linux | GCC | -| S390X | Linux | GCC | -| SPARC | Linux | GCC | -| SPARC | Solaris | GCC | -| SPARC | Solaris | Oracle Solaris Studio C | -| SPARC64 | Linux | GCC | -| SPARC64 | FreeBSD | GCC | -| SPARC64 | Solaris | Oracle Solaris Studio C | -| TILE-Gx/TILEPro | Linux | GCC | -| X86 | FreeBSD | GCC | -| X86 | GNU HURD | GCC | -| X86 | Interix | GCC | -| X86 | kFreeBSD | GCC | -| X86 | Linux | GCC | -| X86 | Mac OSX | GCC | -| X86 | OpenBSD | GCC | -| X86 | OS/2 | GCC | -| X86 | Solaris | GCC | -| X86 | Solaris | Oracle Solaris Studio C | -| X86 | Windows/Cygwin | GCC | -| X86 | Windows/MingW | GCC | -| X86-64 | FreeBSD | GCC | -| X86-64 | Linux | GCC | -| X86-64 | Linux/x32 | GCC | -| X86-64 | OpenBSD | GCC | -| X86-64 | Solaris | Oracle Solaris Studio C | -| X86-64 | Windows/MingW | GCC | -| Xtensa | Linux | GCC | -|-----------------+------------------+-------------------------| +|--------------+------------------| +| Architecture | Operating System | +|--------------+------------------| +| Alpha | Linux | +| Alpha | Tru64 | +| ARM | Linux | +| AVR32 | Linux | +| HPPA | HPUX | +| IA-64 | Linux | +| MIPS | IRIX | +| MIPS | Linux | +| MIPS64 | Linux | +| PowerPC | Linux | +| PowerPC | Mac OSX | +| PowerPC | FreeBSD | +| PowerPC64 | Linux | +| S390 | Linux | +| S390X | Linux | +| SPARC | Linux | +| SPARC | Solaris | +| SPARC64 | Linux | +| SPARC64 | FreeBSD | +| X86 | FreeBSD | +| X86 | kFreeBSD | +| X86 | Linux | +| X86 | Mac OSX | +| X86 | OpenBSD | +| X86 | Solaris | +| X86 | Windows/Cygwin | +| X86 | Windows/MingW | +| X86-64 | FreeBSD | +| X86-64 | Linux | +| X86-64 | OpenBSD | +| X86-64 | Windows/MingW | +|--------------+------------------| Please send additional platform test results to libffi-discuss@sourceware.org and feel free to update the wiki page @@ -137,20 +113,14 @@ Microsoft's Visual C++ compiler. In this case, use the msvcc.sh wrapper script during configuration like so: -path/to/configure CC=path/to/msvcc.sh LD=link CPP=\"cl -nologo -EP\" - -For 64-bit Windows builds, use CC="path/to/msvcc.sh -m64". -You may also need to specify --build appropriately. When building with MSVC -under a MingW environment, you may need to remove the line in configure -that sets 'fix_srcfile_path' to a 'cygpath' command. ('cygpath' is not -present in MingW, and is not required when using MingW-style paths.) - -For iOS builds, the 'libffi.xcodeproj' Xcode project is available. +path/to/configure --enable-shared --enable-static \ + CC=path/to/msvcc.sh LD=link \ + CPP=\"cl -nologo -EP\" Configure has many other options. Use "configure --help" to see them all. Once configure has finished, type "make". Note that you must be using -GNU make. You can ftp GNU make from ftp.gnu.org:/pub/gnu/make . +GNU make. You can ftp GNU make from prep.ai.mit.edu:/pub/gnu. To ensure that libffi is working as advertised, type "make check". This will require that you have DejaGNU installed. @@ -163,53 +133,11 @@ See the ChangeLog files for details. -3.0.13 Mar-17-13 - Add Meta support. - Add missing Moxie bits. - Fix stack alignment bug on 32-bit x86. - Build fix for m68000 targets. - Build fix for soft-float Power targets. - Fix the install dir location for some platforms when building - with GCC (OS X, Solaris). - Fix Cygwin regression. - -3.0.12 Feb-11-13 - Add Moxie support. - Add AArch64 support. - Add Blackfin support. - Add TILE-Gx/TILEPro support. - Add MicroBlaze support. - Add Xtensa support. - Add support for PaX enabled kernels with MPROTECT. - Add support for native vendor compilers on - Solaris and AIX. - Work around LLVM/GCC interoperability issue on x86_64. - -3.0.11 Apr-11-12 - Lots of build fixes. - Add Amiga newer MacOS support. - Add support for variadic functions (ffi_prep_cif_var). - Add Linux/x32 support. - Add thiscall, fastcall and MSVC cdecl support on Windows. - Add Amiga and newer MacOS support. - Add m68k FreeMiNT support. - Integration with iOS' xcode build tools. - Fix Octeon and MC68881 support. - Fix code pessimizations. - -3.0.10 Aug-23-11 - Add support for Apple's iOS. - Add support for ARM VFP ABI. - Add RTEMS support for MIPS and M68K. - Fix instruction cache clearing problems on - ARM and SPARC. - Fix the N64 build on mips-sgi-irix6.5. +3.0.10 ???-??-?? + Fix the N64 build on mips-sgi-irix6.5. + Testsuite fixes for Tru64 Unix. Enable builds with Microsoft's compiler. - Enable x86 builds with Oracle's Solaris compiler. - Fix support for calling code compiled with Oracle's Sparc - Solaris compiler. - Testsuite fixes for Tru64 Unix. - Additional platform support. + Enable x86 builds with Sun's compiler. 3.0.9 Dec-31-09 Add AVR32 and win64 ports. Add ARM softfp support. @@ -354,19 +282,15 @@ Major processor architecture ports were contributed by the following developers: -aarch64 Marcus Shawcroft, James Greenhalgh alpha Richard Henderson arm Raffaele Sena -blackfin Alexandre Keunecke I. de Mendonca cris Simon Posnjak, Hans-Peter Nilsson frv Anthony Green ia64 Hans Boehm m32r Kazuhiro Inaoka m68k Andreas Schwab -microblaze Nathan Rossi mips Anthony Green, Casey Marshall mips64 David Daney -moxie Anthony Green pa Randolph Chung, Dave Anglin, Andreas Tobler powerpc Geoffrey Keating, Andreas Tobler, David Edelsohn, John Hornkvist @@ -375,10 +299,8 @@ sh Kaz Kojima sh64 Kaz Kojima sparc Anthony Green, Gordon Irlam -tile-gx/tilepro Walter Lee x86 Anthony Green, Jon Beniston x86-64 Bo Thorsen -xtensa Chris Zankel Jesper Skov and Andrew Haley both did more than their fair share of stepping through the code and tracking down bugs. @@ -396,6 +318,5 @@ The list above is almost certainly incomplete and inaccurate. I'm happy to make corrections or additions upon request. -If you have a problem, or have found a bug, please send a note to the -author at green@moxielogic.com, or the project mailing list at -libffi-discuss@sourceware.org. +If you have a problem, or have found a bug, please send a note to +green@redhat.com. diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi/aclocal.m4 --- a/Modules/_ctypes/libffi/aclocal.m4 Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/_ctypes/libffi/aclocal.m4 Sun Jul 20 10:52:46 2014 -0400 @@ -1,7 +1,7 @@ -# generated automatically by aclocal 1.12.2 -*- Autoconf -*- +# generated automatically by aclocal 1.11.1 -*- Autoconf -*- -# Copyright (C) 1996-2012 Free Software Foundation, Inc. - +# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, +# 2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc. # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. @@ -13,848 +13,28 @@ m4_ifndef([AC_AUTOCONF_VERSION], [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl -m4_if(m4_defn([AC_AUTOCONF_VERSION]), [2.69],, -[m4_warning([this file was generated for autoconf 2.69. +m4_if(m4_defn([AC_AUTOCONF_VERSION]), [2.65],, +[m4_warning([this file was generated for autoconf 2.65. You have another version of autoconf. It may work, but is not guaranteed to. If you have problems, you may need to regenerate the build system entirely. -To do so, use the procedure documented by the package, typically 'autoreconf'.])]) +To do so, use the procedure documented by the package, typically `autoreconf'.])]) -# ltdl.m4 - Configure ltdl for the target system. -*-Autoconf-*- -# -# Copyright (C) 1999-2006, 2007, 2008, 2011 Free Software Foundation, Inc. -# Written by Thomas Tanner, 1999 -# -# This file is free software; the Free Software Foundation gives -# unlimited permission to copy and/or distribute it, with or without -# modifications, as long as this notice is preserved. - -# serial 18 LTDL_INIT - -# LT_CONFIG_LTDL_DIR(DIRECTORY, [LTDL-MODE]) -# ------------------------------------------ -# DIRECTORY contains the libltdl sources. It is okay to call this -# function multiple times, as long as the same DIRECTORY is always given. -AC_DEFUN([LT_CONFIG_LTDL_DIR], -[AC_BEFORE([$0], [LTDL_INIT]) -_$0($*) -])# LT_CONFIG_LTDL_DIR - -# We break this out into a separate macro, so that we can call it safely -# internally without being caught accidentally by the sed scan in libtoolize. -m4_defun([_LT_CONFIG_LTDL_DIR], -[dnl remove trailing slashes -m4_pushdef([_ARG_DIR], m4_bpatsubst([$1], [/*$])) -m4_case(_LTDL_DIR, - [], [dnl only set lt_ltdl_dir if _ARG_DIR is not simply `.' - m4_if(_ARG_DIR, [.], - [], - [m4_define([_LTDL_DIR], _ARG_DIR) - _LT_SHELL_INIT([lt_ltdl_dir=']_ARG_DIR['])])], - [m4_if(_ARG_DIR, _LTDL_DIR, - [], - [m4_fatal([multiple libltdl directories: `]_LTDL_DIR[', `]_ARG_DIR['])])]) -m4_popdef([_ARG_DIR]) -])# _LT_CONFIG_LTDL_DIR - -# Initialise: -m4_define([_LTDL_DIR], []) - - -# _LT_BUILD_PREFIX -# ---------------- -# If Autoconf is new enough, expand to `${top_build_prefix}', otherwise -# to `${top_builddir}/'. -m4_define([_LT_BUILD_PREFIX], -[m4_ifdef([AC_AUTOCONF_VERSION], - [m4_if(m4_version_compare(m4_defn([AC_AUTOCONF_VERSION]), [2.62]), - [-1], [m4_ifdef([_AC_HAVE_TOP_BUILD_PREFIX], - [${top_build_prefix}], - [${top_builddir}/])], - [${top_build_prefix}])], - [${top_builddir}/])[]dnl -]) - - -# LTDL_CONVENIENCE -# ---------------- -# sets LIBLTDL to the link flags for the libltdl convenience library and -# LTDLINCL to the include flags for the libltdl header and adds -# --enable-ltdl-convenience to the configure arguments. Note that -# AC_CONFIG_SUBDIRS is not called here. LIBLTDL will be prefixed with -# '${top_build_prefix}' if available, otherwise with '${top_builddir}/', -# and LTDLINCL will be prefixed with '${top_srcdir}/' (note the single -# quotes!). If your package is not flat and you're not using automake, -# define top_build_prefix, top_builddir, and top_srcdir appropriately -# in your Makefiles. -AC_DEFUN([LTDL_CONVENIENCE], -[AC_BEFORE([$0], [LTDL_INIT])dnl -dnl Although the argument is deprecated and no longer documented, -dnl LTDL_CONVENIENCE used to take a DIRECTORY orgument, if we have one -dnl here make sure it is the same as any other declaration of libltdl's -dnl location! This also ensures lt_ltdl_dir is set when configure.ac is -dnl not yet using an explicit LT_CONFIG_LTDL_DIR. -m4_ifval([$1], [_LT_CONFIG_LTDL_DIR([$1])])dnl -_$0() -])# LTDL_CONVENIENCE - -# AC_LIBLTDL_CONVENIENCE accepted a directory argument in older libtools, -# now we have LT_CONFIG_LTDL_DIR: -AU_DEFUN([AC_LIBLTDL_CONVENIENCE], -[_LT_CONFIG_LTDL_DIR([m4_default([$1], [libltdl])]) -_LTDL_CONVENIENCE]) - -dnl aclocal-1.4 backwards compatibility: -dnl AC_DEFUN([AC_LIBLTDL_CONVENIENCE], []) - - -# _LTDL_CONVENIENCE -# ----------------- -# Code shared by LTDL_CONVENIENCE and LTDL_INIT([convenience]). -m4_defun([_LTDL_CONVENIENCE], -[case $enable_ltdl_convenience in - no) AC_MSG_ERROR([this package needs a convenience libltdl]) ;; - "") enable_ltdl_convenience=yes - ac_configure_args="$ac_configure_args --enable-ltdl-convenience" ;; -esac -LIBLTDL='_LT_BUILD_PREFIX'"${lt_ltdl_dir+$lt_ltdl_dir/}libltdlc.la" -LTDLDEPS=$LIBLTDL -LTDLINCL='-I${top_srcdir}'"${lt_ltdl_dir+/$lt_ltdl_dir}" - -AC_SUBST([LIBLTDL]) -AC_SUBST([LTDLDEPS]) -AC_SUBST([LTDLINCL]) - -# For backwards non-gettext consistent compatibility... -INCLTDL="$LTDLINCL" -AC_SUBST([INCLTDL]) -])# _LTDL_CONVENIENCE - - -# LTDL_INSTALLABLE -# ---------------- -# sets LIBLTDL to the link flags for the libltdl installable library -# and LTDLINCL to the include flags for the libltdl header and adds -# --enable-ltdl-install to the configure arguments. Note that -# AC_CONFIG_SUBDIRS is not called from here. If an installed libltdl -# is not found, LIBLTDL will be prefixed with '${top_build_prefix}' if -# available, otherwise with '${top_builddir}/', and LTDLINCL will be -# prefixed with '${top_srcdir}/' (note the single quotes!). If your -# package is not flat and you're not using automake, define top_build_prefix, -# top_builddir, and top_srcdir appropriately in your Makefiles. -# In the future, this macro may have to be called after LT_INIT. -AC_DEFUN([LTDL_INSTALLABLE], -[AC_BEFORE([$0], [LTDL_INIT])dnl -dnl Although the argument is deprecated and no longer documented, -dnl LTDL_INSTALLABLE used to take a DIRECTORY orgument, if we have one -dnl here make sure it is the same as any other declaration of libltdl's -dnl location! This also ensures lt_ltdl_dir is set when configure.ac is -dnl not yet using an explicit LT_CONFIG_LTDL_DIR. -m4_ifval([$1], [_LT_CONFIG_LTDL_DIR([$1])])dnl -_$0() -])# LTDL_INSTALLABLE - -# AC_LIBLTDL_INSTALLABLE accepted a directory argument in older libtools, -# now we have LT_CONFIG_LTDL_DIR: -AU_DEFUN([AC_LIBLTDL_INSTALLABLE], -[_LT_CONFIG_LTDL_DIR([m4_default([$1], [libltdl])]) -_LTDL_INSTALLABLE]) - -dnl aclocal-1.4 backwards compatibility: -dnl AC_DEFUN([AC_LIBLTDL_INSTALLABLE], []) - - -# _LTDL_INSTALLABLE -# ----------------- -# Code shared by LTDL_INSTALLABLE and LTDL_INIT([installable]). -m4_defun([_LTDL_INSTALLABLE], -[if test -f $prefix/lib/libltdl.la; then - lt_save_LDFLAGS="$LDFLAGS" - LDFLAGS="-L$prefix/lib $LDFLAGS" - AC_CHECK_LIB([ltdl], [lt_dlinit], [lt_lib_ltdl=yes]) - LDFLAGS="$lt_save_LDFLAGS" - if test x"${lt_lib_ltdl-no}" = xyes; then - if test x"$enable_ltdl_install" != xyes; then - # Don't overwrite $prefix/lib/libltdl.la without --enable-ltdl-install - AC_MSG_WARN([not overwriting libltdl at $prefix, force with `--enable-ltdl-install']) - enable_ltdl_install=no - fi - elif test x"$enable_ltdl_install" = xno; then - AC_MSG_WARN([libltdl not installed, but installation disabled]) - fi -fi - -# If configure.ac declared an installable ltdl, and the user didn't override -# with --disable-ltdl-install, we will install the shipped libltdl. -case $enable_ltdl_install in - no) ac_configure_args="$ac_configure_args --enable-ltdl-install=no" - LIBLTDL="-lltdl" - LTDLDEPS= - LTDLINCL= - ;; - *) enable_ltdl_install=yes - ac_configure_args="$ac_configure_args --enable-ltdl-install" - LIBLTDL='_LT_BUILD_PREFIX'"${lt_ltdl_dir+$lt_ltdl_dir/}libltdl.la" - LTDLDEPS=$LIBLTDL - LTDLINCL='-I${top_srcdir}'"${lt_ltdl_dir+/$lt_ltdl_dir}" - ;; -esac - -AC_SUBST([LIBLTDL]) -AC_SUBST([LTDLDEPS]) -AC_SUBST([LTDLINCL]) - -# For backwards non-gettext consistent compatibility... -INCLTDL="$LTDLINCL" -AC_SUBST([INCLTDL]) -])# LTDL_INSTALLABLE - - -# _LTDL_MODE_DISPATCH -# ------------------- -m4_define([_LTDL_MODE_DISPATCH], -[dnl If _LTDL_DIR is `.', then we are configuring libltdl itself: -m4_if(_LTDL_DIR, [], - [], - dnl if _LTDL_MODE was not set already, the default value is `subproject': - [m4_case(m4_default(_LTDL_MODE, [subproject]), - [subproject], [AC_CONFIG_SUBDIRS(_LTDL_DIR) - _LT_SHELL_INIT([lt_dlopen_dir="$lt_ltdl_dir"])], - [nonrecursive], [_LT_SHELL_INIT([lt_dlopen_dir="$lt_ltdl_dir"; lt_libobj_prefix="$lt_ltdl_dir/"])], - [recursive], [], - [m4_fatal([unknown libltdl mode: ]_LTDL_MODE)])])dnl -dnl Be careful not to expand twice: -m4_define([$0], []) -])# _LTDL_MODE_DISPATCH - - -# _LT_LIBOBJ(MODULE_NAME) -# ----------------------- -# Like AC_LIBOBJ, except that MODULE_NAME goes into _LT_LIBOBJS instead -# of into LIBOBJS. -AC_DEFUN([_LT_LIBOBJ], [ - m4_pattern_allow([^_LT_LIBOBJS$]) - _LT_LIBOBJS="$_LT_LIBOBJS $1.$ac_objext" -])# _LT_LIBOBJS - - -# LTDL_INIT([OPTIONS]) -# -------------------- -# Clients of libltdl can use this macro to allow the installer to -# choose between a shipped copy of the ltdl sources or a preinstalled -# version of the library. If the shipped ltdl sources are not in a -# subdirectory named libltdl, the directory name must be given by -# LT_CONFIG_LTDL_DIR. -AC_DEFUN([LTDL_INIT], -[dnl Parse OPTIONS -_LT_SET_OPTIONS([$0], [$1]) - -dnl We need to keep our own list of libobjs separate from our parent project, -dnl and the easiest way to do that is redefine the AC_LIBOBJs macro while -dnl we look for our own LIBOBJs. -m4_pushdef([AC_LIBOBJ], m4_defn([_LT_LIBOBJ])) -m4_pushdef([AC_LIBSOURCES]) - -dnl If not otherwise defined, default to the 1.5.x compatible subproject mode: -m4_if(_LTDL_MODE, [], - [m4_define([_LTDL_MODE], m4_default([$2], [subproject])) - m4_if([-1], [m4_bregexp(_LTDL_MODE, [\(subproject\|\(non\)?recursive\)])], - [m4_fatal([unknown libltdl mode: ]_LTDL_MODE)])]) - -AC_ARG_WITH([included_ltdl], - [AS_HELP_STRING([--with-included-ltdl], - [use the GNU ltdl sources included here])]) - -if test "x$with_included_ltdl" != xyes; then - # We are not being forced to use the included libltdl sources, so - # decide whether there is a useful installed version we can use. - AC_CHECK_HEADER([ltdl.h], - [AC_CHECK_DECL([lt_dlinterface_register], - [AC_CHECK_LIB([ltdl], [lt_dladvise_preload], - [with_included_ltdl=no], - [with_included_ltdl=yes])], - [with_included_ltdl=yes], - [AC_INCLUDES_DEFAULT - #include ])], - [with_included_ltdl=yes], - [AC_INCLUDES_DEFAULT] - ) -fi - -dnl If neither LT_CONFIG_LTDL_DIR, LTDL_CONVENIENCE nor LTDL_INSTALLABLE -dnl was called yet, then for old times' sake, we assume libltdl is in an -dnl eponymous directory: -AC_PROVIDE_IFELSE([LT_CONFIG_LTDL_DIR], [], [_LT_CONFIG_LTDL_DIR([libltdl])]) - -AC_ARG_WITH([ltdl_include], - [AS_HELP_STRING([--with-ltdl-include=DIR], - [use the ltdl headers installed in DIR])]) - -if test -n "$with_ltdl_include"; then - if test -f "$with_ltdl_include/ltdl.h"; then : - else - AC_MSG_ERROR([invalid ltdl include directory: `$with_ltdl_include']) - fi -else - with_ltdl_include=no -fi - -AC_ARG_WITH([ltdl_lib], - [AS_HELP_STRING([--with-ltdl-lib=DIR], - [use the libltdl.la installed in DIR])]) - -if test -n "$with_ltdl_lib"; then - if test -f "$with_ltdl_lib/libltdl.la"; then : - else - AC_MSG_ERROR([invalid ltdl library directory: `$with_ltdl_lib']) - fi -else - with_ltdl_lib=no -fi - -case ,$with_included_ltdl,$with_ltdl_include,$with_ltdl_lib, in - ,yes,no,no,) - m4_case(m4_default(_LTDL_TYPE, [convenience]), - [convenience], [_LTDL_CONVENIENCE], - [installable], [_LTDL_INSTALLABLE], - [m4_fatal([unknown libltdl build type: ]_LTDL_TYPE)]) - ;; - ,no,no,no,) - # If the included ltdl is not to be used, then use the - # preinstalled libltdl we found. - AC_DEFINE([HAVE_LTDL], [1], - [Define this if a modern libltdl is already installed]) - LIBLTDL=-lltdl - LTDLDEPS= - LTDLINCL= - ;; - ,no*,no,*) - AC_MSG_ERROR([`--with-ltdl-include' and `--with-ltdl-lib' options must be used together]) - ;; - *) with_included_ltdl=no - LIBLTDL="-L$with_ltdl_lib -lltdl" - LTDLDEPS= - LTDLINCL="-I$with_ltdl_include" - ;; -esac -INCLTDL="$LTDLINCL" - -# Report our decision... -AC_MSG_CHECKING([where to find libltdl headers]) -AC_MSG_RESULT([$LTDLINCL]) -AC_MSG_CHECKING([where to find libltdl library]) -AC_MSG_RESULT([$LIBLTDL]) - -_LTDL_SETUP - -dnl restore autoconf definition. -m4_popdef([AC_LIBOBJ]) -m4_popdef([AC_LIBSOURCES]) - -AC_CONFIG_COMMANDS_PRE([ - _ltdl_libobjs= - _ltdl_ltlibobjs= - if test -n "$_LT_LIBOBJS"; then - # Remove the extension. - _lt_sed_drop_objext='s/\.o$//;s/\.obj$//' - for i in `for i in $_LT_LIBOBJS; do echo "$i"; done | sed "$_lt_sed_drop_objext" | sort -u`; do - _ltdl_libobjs="$_ltdl_libobjs $lt_libobj_prefix$i.$ac_objext" - _ltdl_ltlibobjs="$_ltdl_ltlibobjs $lt_libobj_prefix$i.lo" - done - fi - AC_SUBST([ltdl_LIBOBJS], [$_ltdl_libobjs]) - AC_SUBST([ltdl_LTLIBOBJS], [$_ltdl_ltlibobjs]) -]) - -# Only expand once: -m4_define([LTDL_INIT]) -])# LTDL_INIT - -# Old names: -AU_DEFUN([AC_LIB_LTDL], [LTDL_INIT($@)]) -AU_DEFUN([AC_WITH_LTDL], [LTDL_INIT($@)]) -AU_DEFUN([LT_WITH_LTDL], [LTDL_INIT($@)]) -dnl aclocal-1.4 backwards compatibility: -dnl AC_DEFUN([AC_LIB_LTDL], []) -dnl AC_DEFUN([AC_WITH_LTDL], []) -dnl AC_DEFUN([LT_WITH_LTDL], []) - - -# _LTDL_SETUP -# ----------- -# Perform all the checks necessary for compilation of the ltdl objects -# -- including compiler checks and header checks. This is a public -# interface mainly for the benefit of libltdl's own configure.ac, most -# other users should call LTDL_INIT instead. -AC_DEFUN([_LTDL_SETUP], -[AC_REQUIRE([AC_PROG_CC])dnl -AC_REQUIRE([LT_SYS_MODULE_EXT])dnl -AC_REQUIRE([LT_SYS_MODULE_PATH])dnl -AC_REQUIRE([LT_SYS_DLSEARCH_PATH])dnl -AC_REQUIRE([LT_LIB_DLLOAD])dnl -AC_REQUIRE([LT_SYS_SYMBOL_USCORE])dnl -AC_REQUIRE([LT_FUNC_DLSYM_USCORE])dnl -AC_REQUIRE([LT_SYS_DLOPEN_DEPLIBS])dnl -AC_REQUIRE([gl_FUNC_ARGZ])dnl - -m4_require([_LT_CHECK_OBJDIR])dnl -m4_require([_LT_HEADER_DLFCN])dnl -m4_require([_LT_CHECK_DLPREOPEN])dnl -m4_require([_LT_DECL_SED])dnl - -dnl Don't require this, or it will be expanded earlier than the code -dnl that sets the variables it relies on: -_LT_ENABLE_INSTALL - -dnl _LTDL_MODE specific code must be called at least once: -_LTDL_MODE_DISPATCH - -# In order that ltdl.c can compile, find out the first AC_CONFIG_HEADERS -# the user used. This is so that ltdl.h can pick up the parent projects -# config.h file, The first file in AC_CONFIG_HEADERS must contain the -# definitions required by ltdl.c. -# FIXME: Remove use of undocumented AC_LIST_HEADERS (2.59 compatibility). -AC_CONFIG_COMMANDS_PRE([dnl -m4_pattern_allow([^LT_CONFIG_H$])dnl -m4_ifset([AH_HEADER], - [LT_CONFIG_H=AH_HEADER], - [m4_ifset([AC_LIST_HEADERS], - [LT_CONFIG_H=`echo "AC_LIST_HEADERS" | $SED 's,^[[ ]]*,,;s,[[ :]].*$,,'`], - [])])]) -AC_SUBST([LT_CONFIG_H]) - -AC_CHECK_HEADERS([unistd.h dl.h sys/dl.h dld.h mach-o/dyld.h dirent.h], - [], [], [AC_INCLUDES_DEFAULT]) - -AC_CHECK_FUNCS([closedir opendir readdir], [], [AC_LIBOBJ([lt__dirent])]) -AC_CHECK_FUNCS([strlcat strlcpy], [], [AC_LIBOBJ([lt__strl])]) - -m4_pattern_allow([LT_LIBEXT])dnl -AC_DEFINE_UNQUOTED([LT_LIBEXT],["$libext"],[The archive extension]) - -name= -eval "lt_libprefix=\"$libname_spec\"" -m4_pattern_allow([LT_LIBPREFIX])dnl -AC_DEFINE_UNQUOTED([LT_LIBPREFIX],["$lt_libprefix"],[The archive prefix]) - -name=ltdl -eval "LTDLOPEN=\"$libname_spec\"" -AC_SUBST([LTDLOPEN]) -])# _LTDL_SETUP - - -# _LT_ENABLE_INSTALL -# ------------------ -m4_define([_LT_ENABLE_INSTALL], -[AC_ARG_ENABLE([ltdl-install], - [AS_HELP_STRING([--enable-ltdl-install], [install libltdl])]) - -case ,${enable_ltdl_install},${enable_ltdl_convenience} in - *yes*) ;; - *) enable_ltdl_convenience=yes ;; -esac - -m4_ifdef([AM_CONDITIONAL], -[AM_CONDITIONAL(INSTALL_LTDL, test x"${enable_ltdl_install-no}" != xno) - AM_CONDITIONAL(CONVENIENCE_LTDL, test x"${enable_ltdl_convenience-no}" != xno)]) -])# _LT_ENABLE_INSTALL - - -# LT_SYS_DLOPEN_DEPLIBS -# --------------------- -AC_DEFUN([LT_SYS_DLOPEN_DEPLIBS], -[AC_REQUIRE([AC_CANONICAL_HOST])dnl -AC_CACHE_CHECK([whether deplibs are loaded by dlopen], - [lt_cv_sys_dlopen_deplibs], - [# PORTME does your system automatically load deplibs for dlopen? - # or its logical equivalent (e.g. shl_load for HP-UX < 11) - # For now, we just catch OSes we know something about -- in the - # future, we'll try test this programmatically. - lt_cv_sys_dlopen_deplibs=unknown - case $host_os in - aix3*|aix4.1.*|aix4.2.*) - # Unknown whether this is true for these versions of AIX, but - # we want this `case' here to explicitly catch those versions. - lt_cv_sys_dlopen_deplibs=unknown - ;; - aix[[4-9]]*) - lt_cv_sys_dlopen_deplibs=yes - ;; - amigaos*) - case $host_cpu in - powerpc) - lt_cv_sys_dlopen_deplibs=no - ;; - esac - ;; - darwin*) - # Assuming the user has installed a libdl from somewhere, this is true - # If you are looking for one http://www.opendarwin.org/projects/dlcompat - lt_cv_sys_dlopen_deplibs=yes - ;; - freebsd* | dragonfly*) - lt_cv_sys_dlopen_deplibs=yes - ;; - gnu* | linux* | k*bsd*-gnu | kopensolaris*-gnu) - # GNU and its variants, using gnu ld.so (Glibc) - lt_cv_sys_dlopen_deplibs=yes - ;; - hpux10*|hpux11*) - lt_cv_sys_dlopen_deplibs=yes - ;; - interix*) - lt_cv_sys_dlopen_deplibs=yes - ;; - irix[[12345]]*|irix6.[[01]]*) - # Catch all versions of IRIX before 6.2, and indicate that we don't - # know how it worked for any of those versions. - lt_cv_sys_dlopen_deplibs=unknown - ;; - irix*) - # The case above catches anything before 6.2, and it's known that - # at 6.2 and later dlopen does load deplibs. - lt_cv_sys_dlopen_deplibs=yes - ;; - netbsd*) - lt_cv_sys_dlopen_deplibs=yes - ;; - openbsd*) - lt_cv_sys_dlopen_deplibs=yes - ;; - osf[[1234]]*) - # dlopen did load deplibs (at least at 4.x), but until the 5.x series, - # it did *not* use an RPATH in a shared library to find objects the - # library depends on, so we explicitly say `no'. - lt_cv_sys_dlopen_deplibs=no - ;; - osf5.0|osf5.0a|osf5.1) - # dlopen *does* load deplibs and with the right loader patch applied - # it even uses RPATH in a shared library to search for shared objects - # that the library depends on, but there's no easy way to know if that - # patch is installed. Since this is the case, all we can really - # say is unknown -- it depends on the patch being installed. If - # it is, this changes to `yes'. Without it, it would be `no'. - lt_cv_sys_dlopen_deplibs=unknown - ;; - osf*) - # the two cases above should catch all versions of osf <= 5.1. Read - # the comments above for what we know about them. - # At > 5.1, deplibs are loaded *and* any RPATH in a shared library - # is used to find them so we can finally say `yes'. - lt_cv_sys_dlopen_deplibs=yes - ;; - qnx*) - lt_cv_sys_dlopen_deplibs=yes - ;; - solaris*) - lt_cv_sys_dlopen_deplibs=yes - ;; - sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*) - libltdl_cv_sys_dlopen_deplibs=yes - ;; - esac - ]) -if test "$lt_cv_sys_dlopen_deplibs" != yes; then - AC_DEFINE([LTDL_DLOPEN_DEPLIBS], [1], - [Define if the OS needs help to load dependent libraries for dlopen().]) -fi -])# LT_SYS_DLOPEN_DEPLIBS - -# Old name: -AU_ALIAS([AC_LTDL_SYS_DLOPEN_DEPLIBS], [LT_SYS_DLOPEN_DEPLIBS]) -dnl aclocal-1.4 backwards compatibility: -dnl AC_DEFUN([AC_LTDL_SYS_DLOPEN_DEPLIBS], []) - - -# LT_SYS_MODULE_EXT -# ----------------- -AC_DEFUN([LT_SYS_MODULE_EXT], -[m4_require([_LT_SYS_DYNAMIC_LINKER])dnl -AC_CACHE_CHECK([which extension is used for runtime loadable modules], - [libltdl_cv_shlibext], -[ -module=yes -eval libltdl_cv_shlibext=$shrext_cmds -module=no -eval libltdl_cv_shrext=$shrext_cmds - ]) -if test -n "$libltdl_cv_shlibext"; then - m4_pattern_allow([LT_MODULE_EXT])dnl - AC_DEFINE_UNQUOTED([LT_MODULE_EXT], ["$libltdl_cv_shlibext"], - [Define to the extension used for runtime loadable modules, say, ".so".]) -fi -if test "$libltdl_cv_shrext" != "$libltdl_cv_shlibext"; then - m4_pattern_allow([LT_SHARED_EXT])dnl - AC_DEFINE_UNQUOTED([LT_SHARED_EXT], ["$libltdl_cv_shrext"], - [Define to the shared library suffix, say, ".dylib".]) -fi -])# LT_SYS_MODULE_EXT - -# Old name: -AU_ALIAS([AC_LTDL_SHLIBEXT], [LT_SYS_MODULE_EXT]) -dnl aclocal-1.4 backwards compatibility: -dnl AC_DEFUN([AC_LTDL_SHLIBEXT], []) - - -# LT_SYS_MODULE_PATH -# ------------------ -AC_DEFUN([LT_SYS_MODULE_PATH], -[m4_require([_LT_SYS_DYNAMIC_LINKER])dnl -AC_CACHE_CHECK([which variable specifies run-time module search path], - [lt_cv_module_path_var], [lt_cv_module_path_var="$shlibpath_var"]) -if test -n "$lt_cv_module_path_var"; then - m4_pattern_allow([LT_MODULE_PATH_VAR])dnl - AC_DEFINE_UNQUOTED([LT_MODULE_PATH_VAR], ["$lt_cv_module_path_var"], - [Define to the name of the environment variable that determines the run-time module search path.]) -fi -])# LT_SYS_MODULE_PATH - -# Old name: -AU_ALIAS([AC_LTDL_SHLIBPATH], [LT_SYS_MODULE_PATH]) -dnl aclocal-1.4 backwards compatibility: -dnl AC_DEFUN([AC_LTDL_SHLIBPATH], []) - - -# LT_SYS_DLSEARCH_PATH -# -------------------- -AC_DEFUN([LT_SYS_DLSEARCH_PATH], -[m4_require([_LT_SYS_DYNAMIC_LINKER])dnl -AC_CACHE_CHECK([for the default library search path], - [lt_cv_sys_dlsearch_path], - [lt_cv_sys_dlsearch_path="$sys_lib_dlsearch_path_spec"]) -if test -n "$lt_cv_sys_dlsearch_path"; then - sys_dlsearch_path= - for dir in $lt_cv_sys_dlsearch_path; do - if test -z "$sys_dlsearch_path"; then - sys_dlsearch_path="$dir" - else - sys_dlsearch_path="$sys_dlsearch_path$PATH_SEPARATOR$dir" - fi - done - m4_pattern_allow([LT_DLSEARCH_PATH])dnl - AC_DEFINE_UNQUOTED([LT_DLSEARCH_PATH], ["$sys_dlsearch_path"], - [Define to the system default library search path.]) -fi -])# LT_SYS_DLSEARCH_PATH - -# Old name: -AU_ALIAS([AC_LTDL_SYSSEARCHPATH], [LT_SYS_DLSEARCH_PATH]) -dnl aclocal-1.4 backwards compatibility: -dnl AC_DEFUN([AC_LTDL_SYSSEARCHPATH], []) - - -# _LT_CHECK_DLPREOPEN -# ------------------- -m4_defun([_LT_CHECK_DLPREOPEN], -[m4_require([_LT_CMD_GLOBAL_SYMBOLS])dnl -AC_CACHE_CHECK([whether libtool supports -dlopen/-dlpreopen], - [libltdl_cv_preloaded_symbols], - [if test -n "$lt_cv_sys_global_symbol_pipe"; then - libltdl_cv_preloaded_symbols=yes - else - libltdl_cv_preloaded_symbols=no - fi - ]) -if test x"$libltdl_cv_preloaded_symbols" = xyes; then - AC_DEFINE([HAVE_PRELOADED_SYMBOLS], [1], - [Define if libtool can extract symbol lists from object files.]) -fi -])# _LT_CHECK_DLPREOPEN - - -# LT_LIB_DLLOAD -# ------------- -AC_DEFUN([LT_LIB_DLLOAD], -[m4_pattern_allow([^LT_DLLOADERS$]) -LT_DLLOADERS= -AC_SUBST([LT_DLLOADERS]) - -AC_LANG_PUSH([C]) - -LIBADD_DLOPEN= -AC_SEARCH_LIBS([dlopen], [dl], - [AC_DEFINE([HAVE_LIBDL], [1], - [Define if you have the libdl library or equivalent.]) - if test "$ac_cv_search_dlopen" != "none required" ; then - LIBADD_DLOPEN="-ldl" - fi - libltdl_cv_lib_dl_dlopen="yes" - LT_DLLOADERS="$LT_DLLOADERS ${lt_dlopen_dir+$lt_dlopen_dir/}dlopen.la"], - [AC_LINK_IFELSE([AC_LANG_PROGRAM([[#if HAVE_DLFCN_H -# include -#endif - ]], [[dlopen(0, 0);]])], - [AC_DEFINE([HAVE_LIBDL], [1], - [Define if you have the libdl library or equivalent.]) - libltdl_cv_func_dlopen="yes" - LT_DLLOADERS="$LT_DLLOADERS ${lt_dlopen_dir+$lt_dlopen_dir/}dlopen.la"], - [AC_CHECK_LIB([svld], [dlopen], - [AC_DEFINE([HAVE_LIBDL], [1], - [Define if you have the libdl library or equivalent.]) - LIBADD_DLOPEN="-lsvld" libltdl_cv_func_dlopen="yes" - LT_DLLOADERS="$LT_DLLOADERS ${lt_dlopen_dir+$lt_dlopen_dir/}dlopen.la"])])]) -if test x"$libltdl_cv_func_dlopen" = xyes || test x"$libltdl_cv_lib_dl_dlopen" = xyes -then - lt_save_LIBS="$LIBS" - LIBS="$LIBS $LIBADD_DLOPEN" - AC_CHECK_FUNCS([dlerror]) - LIBS="$lt_save_LIBS" -fi -AC_SUBST([LIBADD_DLOPEN]) - -LIBADD_SHL_LOAD= -AC_CHECK_FUNC([shl_load], - [AC_DEFINE([HAVE_SHL_LOAD], [1], - [Define if you have the shl_load function.]) - LT_DLLOADERS="$LT_DLLOADERS ${lt_dlopen_dir+$lt_dlopen_dir/}shl_load.la"], - [AC_CHECK_LIB([dld], [shl_load], - [AC_DEFINE([HAVE_SHL_LOAD], [1], - [Define if you have the shl_load function.]) - LT_DLLOADERS="$LT_DLLOADERS ${lt_dlopen_dir+$lt_dlopen_dir/}shl_load.la" - LIBADD_SHL_LOAD="-ldld"])]) -AC_SUBST([LIBADD_SHL_LOAD]) - -case $host_os in -darwin[[1567]].*) -# We only want this for pre-Mac OS X 10.4. - AC_CHECK_FUNC([_dyld_func_lookup], - [AC_DEFINE([HAVE_DYLD], [1], - [Define if you have the _dyld_func_lookup function.]) - LT_DLLOADERS="$LT_DLLOADERS ${lt_dlopen_dir+$lt_dlopen_dir/}dyld.la"]) - ;; -beos*) - LT_DLLOADERS="$LT_DLLOADERS ${lt_dlopen_dir+$lt_dlopen_dir/}load_add_on.la" - ;; -cygwin* | mingw* | os2* | pw32*) - AC_CHECK_DECLS([cygwin_conv_path], [], [], [[#include ]]) - LT_DLLOADERS="$LT_DLLOADERS ${lt_dlopen_dir+$lt_dlopen_dir/}loadlibrary.la" - ;; -esac - -AC_CHECK_LIB([dld], [dld_link], - [AC_DEFINE([HAVE_DLD], [1], - [Define if you have the GNU dld library.]) - LT_DLLOADERS="$LT_DLLOADERS ${lt_dlopen_dir+$lt_dlopen_dir/}dld_link.la"]) -AC_SUBST([LIBADD_DLD_LINK]) - -m4_pattern_allow([^LT_DLPREOPEN$]) -LT_DLPREOPEN= -if test -n "$LT_DLLOADERS" -then - for lt_loader in $LT_DLLOADERS; do - LT_DLPREOPEN="$LT_DLPREOPEN-dlpreopen $lt_loader " - done - AC_DEFINE([HAVE_LIBDLLOADER], [1], - [Define if libdlloader will be built on this platform]) -fi -AC_SUBST([LT_DLPREOPEN]) - -dnl This isn't used anymore, but set it for backwards compatibility -LIBADD_DL="$LIBADD_DLOPEN $LIBADD_SHL_LOAD" -AC_SUBST([LIBADD_DL]) - -AC_LANG_POP -])# LT_LIB_DLLOAD - -# Old name: -AU_ALIAS([AC_LTDL_DLLIB], [LT_LIB_DLLOAD]) -dnl aclocal-1.4 backwards compatibility: -dnl AC_DEFUN([AC_LTDL_DLLIB], []) - - -# LT_SYS_SYMBOL_USCORE -# -------------------- -# does the compiler prefix global symbols with an underscore? -AC_DEFUN([LT_SYS_SYMBOL_USCORE], -[m4_require([_LT_CMD_GLOBAL_SYMBOLS])dnl -AC_CACHE_CHECK([for _ prefix in compiled symbols], - [lt_cv_sys_symbol_underscore], - [lt_cv_sys_symbol_underscore=no - cat > conftest.$ac_ext <<_LT_EOF -void nm_test_func(){} -int main(){nm_test_func;return 0;} -_LT_EOF - if AC_TRY_EVAL(ac_compile); then - # Now try to grab the symbols. - ac_nlist=conftest.nm - if AC_TRY_EVAL(NM conftest.$ac_objext \| $lt_cv_sys_global_symbol_pipe \> $ac_nlist) && test -s "$ac_nlist"; then - # See whether the symbols have a leading underscore. - if grep '^. _nm_test_func' "$ac_nlist" >/dev/null; then - lt_cv_sys_symbol_underscore=yes - else - if grep '^. nm_test_func ' "$ac_nlist" >/dev/null; then - : - else - echo "configure: cannot find nm_test_func in $ac_nlist" >&AS_MESSAGE_LOG_FD - fi - fi - else - echo "configure: cannot run $lt_cv_sys_global_symbol_pipe" >&AS_MESSAGE_LOG_FD - fi - else - echo "configure: failed program was:" >&AS_MESSAGE_LOG_FD - cat conftest.c >&AS_MESSAGE_LOG_FD - fi - rm -rf conftest* - ]) - sys_symbol_underscore=$lt_cv_sys_symbol_underscore - AC_SUBST([sys_symbol_underscore]) -])# LT_SYS_SYMBOL_USCORE - -# Old name: -AU_ALIAS([AC_LTDL_SYMBOL_USCORE], [LT_SYS_SYMBOL_USCORE]) -dnl aclocal-1.4 backwards compatibility: -dnl AC_DEFUN([AC_LTDL_SYMBOL_USCORE], []) - - -# LT_FUNC_DLSYM_USCORE -# -------------------- -AC_DEFUN([LT_FUNC_DLSYM_USCORE], -[AC_REQUIRE([LT_SYS_SYMBOL_USCORE])dnl -if test x"$lt_cv_sys_symbol_underscore" = xyes; then - if test x"$libltdl_cv_func_dlopen" = xyes || - test x"$libltdl_cv_lib_dl_dlopen" = xyes ; then - AC_CACHE_CHECK([whether we have to add an underscore for dlsym], - [libltdl_cv_need_uscore], - [libltdl_cv_need_uscore=unknown - save_LIBS="$LIBS" - LIBS="$LIBS $LIBADD_DLOPEN" - _LT_TRY_DLOPEN_SELF( - [libltdl_cv_need_uscore=no], [libltdl_cv_need_uscore=yes], - [], [libltdl_cv_need_uscore=cross]) - LIBS="$save_LIBS" - ]) - fi -fi - -if test x"$libltdl_cv_need_uscore" = xyes; then - AC_DEFINE([NEED_USCORE], [1], - [Define if dlsym() requires a leading underscore in symbol names.]) -fi -])# LT_FUNC_DLSYM_USCORE - -# Old name: -AU_ALIAS([AC_LTDL_DLSYM_USCORE], [LT_FUNC_DLSYM_USCORE]) -dnl aclocal-1.4 backwards compatibility: -dnl AC_DEFUN([AC_LTDL_DLSYM_USCORE], []) - -# Copyright (C) 2002-2012 Free Software Foundation, Inc. +# Copyright (C) 2002, 2003, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. -# serial 8 - # AM_AUTOMAKE_VERSION(VERSION) # ---------------------------- # Automake X.Y traces this macro to ensure aclocal.m4 has been # generated from the m4 files accompanying Automake X.Y. # (This private macro should not be called outside this file.) AC_DEFUN([AM_AUTOMAKE_VERSION], -[am__api_version='1.12' +[am__api_version='1.11' dnl Some users find AM_AUTOMAKE_VERSION and mistake it for a way to dnl require some minimum version. Point them to the right macro. -m4_if([$1], [1.12.2], [], +m4_if([$1], [1.11.1], [], [AC_FATAL([Do not call $0, use AM_INIT_AUTOMAKE([$1]).])])dnl ]) @@ -870,14 +50,14 @@ # Call AM_AUTOMAKE_VERSION and AM_AUTOMAKE_VERSION so they can be traced. # This function is AC_REQUIREd by AM_INIT_AUTOMAKE. AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION], -[AM_AUTOMAKE_VERSION([1.12.2])dnl +[AM_AUTOMAKE_VERSION([1.11.1])dnl m4_ifndef([AC_AUTOCONF_VERSION], [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl _AM_AUTOCONF_VERSION(m4_defn([AC_AUTOCONF_VERSION]))]) # Figure out how to run the assembler. -*- Autoconf -*- -# Copyright (C) 2001-2012 Free Software Foundation, Inc. +# Copyright (C) 2001, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -899,17 +79,15 @@ # AM_AUX_DIR_EXPAND -*- Autoconf -*- -# Copyright (C) 2001-2012 Free Software Foundation, Inc. +# Copyright (C) 2001, 2003, 2005 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. -# serial 2 - # For projects using AC_CONFIG_AUX_DIR([foo]), Autoconf sets -# $ac_aux_dir to '$srcdir/foo'. In other projects, it is set to -# '$srcdir', '$srcdir/..', or '$srcdir/../..'. +# $ac_aux_dir to `$srcdir/foo'. In other projects, it is set to +# `$srcdir', `$srcdir/..', or `$srcdir/../..'. # # Of course, Automake must honor this variable whenever it calls a # tool from the auxiliary directory. The problem is that $srcdir (and @@ -928,7 +106,7 @@ # # The reason of the latter failure is that $top_srcdir and $ac_aux_dir # are both prefixed by $srcdir. In an in-source build this is usually -# harmless because $srcdir is '.', but things will broke when you +# harmless because $srcdir is `.', but things will broke when you # start a VPATH build or use an absolute $srcdir. # # So we could use something similar to $top_srcdir/$ac_aux_dir/missing, @@ -954,21 +132,22 @@ # AM_CONDITIONAL -*- Autoconf -*- -# Copyright (C) 1997-2012 Free Software Foundation, Inc. +# Copyright (C) 1997, 2000, 2001, 2003, 2004, 2005, 2006, 2008 +# Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. -# serial 10 +# serial 9 # AM_CONDITIONAL(NAME, SHELL-CONDITION) # ------------------------------------- # Define a conditional. AC_DEFUN([AM_CONDITIONAL], -[AC_PREREQ([2.52])dnl - m4_if([$1], [TRUE], [AC_FATAL([$0: invalid condition: $1])], - [$1], [FALSE], [AC_FATAL([$0: invalid condition: $1])])dnl +[AC_PREREQ(2.52)dnl + ifelse([$1], [TRUE], [AC_FATAL([$0: invalid condition: $1])], + [$1], [FALSE], [AC_FATAL([$0: invalid condition: $1])])dnl AC_SUBST([$1_TRUE])dnl AC_SUBST([$1_FALSE])dnl _AM_SUBST_NOTMAKE([$1_TRUE])dnl @@ -987,15 +166,16 @@ Usually this means the macro was only invoked conditionally.]]) fi])]) -# Copyright (C) 1999-2012 Free Software Foundation, Inc. +# Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2009 +# Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. -# serial 17 +# serial 10 -# There are a few dirty hacks below to avoid letting 'AC_PROG_CC' be +# There are a few dirty hacks below to avoid letting `AC_PROG_CC' be # written in clear, in which case automake, when reading aclocal.m4, # will think it sees a *use*, and therefore will trigger all it's # C support machinery. Also note that it means that autoscan, seeing @@ -1005,7 +185,7 @@ # _AM_DEPENDENCIES(NAME) # ---------------------- # See how the compiler implements dependency checking. -# NAME is "CC", "CXX", "OBJC", "OBJCXX", "UPC", or "GJC". +# NAME is "CC", "CXX", "GCJ", or "OBJC". # We try a few techniques and use that to set a single cache variable. # # We don't AC_REQUIRE the corresponding AC_PROG_CC since the latter was @@ -1018,13 +198,12 @@ AC_REQUIRE([AM_MAKE_INCLUDE])dnl AC_REQUIRE([AM_DEP_TRACK])dnl -m4_if([$1], [CC], [depcc="$CC" am_compiler_list=], - [$1], [CXX], [depcc="$CXX" am_compiler_list=], - [$1], [OBJC], [depcc="$OBJC" am_compiler_list='gcc3 gcc'], - [$1], [OBJCXX], [depcc="$OBJCXX" am_compiler_list='gcc3 gcc'], - [$1], [UPC], [depcc="$UPC" am_compiler_list=], - [$1], [GCJ], [depcc="$GCJ" am_compiler_list='gcc3 gcc'], - [depcc="$$1" am_compiler_list=]) +ifelse([$1], CC, [depcc="$CC" am_compiler_list=], + [$1], CXX, [depcc="$CXX" am_compiler_list=], + [$1], OBJC, [depcc="$OBJC" am_compiler_list='gcc3 gcc'], + [$1], UPC, [depcc="$UPC" am_compiler_list=], + [$1], GCJ, [depcc="$GCJ" am_compiler_list='gcc3 gcc'], + [depcc="$$1" am_compiler_list=]) AC_CACHE_CHECK([dependency style of $depcc], [am_cv_$1_dependencies_compiler_type], @@ -1032,9 +211,8 @@ # We make a subdir and do the tests there. Otherwise we can end up # making bogus files that we don't know about and never remove. For # instance it was reported that on HP-UX the gcc test will end up - # making a dummy file named 'D' -- because '-MD' means "put the output - # in D". - rm -rf conftest.dir + # making a dummy file named `D' -- because `-MD' means `put the output + # in D'. mkdir conftest.dir # Copy depcomp to subdir because otherwise we won't find it if we're # using a relative directory. @@ -1073,16 +251,16 @@ : > sub/conftest.c for i in 1 2 3 4 5 6; do echo '#include "conftst'$i'.h"' >> sub/conftest.c - # Using ": > sub/conftst$i.h" creates only sub/conftst1.h with - # Solaris 10 /bin/sh. - echo '/* dummy */' > sub/conftst$i.h + # Using `: > sub/conftst$i.h' creates only sub/conftst1.h with + # Solaris 8's {/usr,}/bin/sh. + touch sub/conftst$i.h done echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf - # We check with '-c' and '-o' for the sake of the "dashmstdout" + # We check with `-c' and `-o' for the sake of the "dashmstdout" # mode. It turns out that the SunPro C++ compiler does not properly - # handle '-M -o', and we need to detect this. Also, some Intel - # versions had trouble with output in subdirs. + # handle `-M -o', and we need to detect this. Also, some Intel + # versions had trouble with output in subdirs am__obj=sub/conftest.${OBJEXT-o} am__minus_obj="-o $am__obj" case $depmode in @@ -1091,16 +269,16 @@ test "$am__universal" = false || continue ;; nosideeffect) - # After this tag, mechanisms are not by side-effect, so they'll - # only be used when explicitly requested. + # after this tag, mechanisms are not by side-effect, so they'll + # only be used when explicitly requested if test "x$enable_dependency_tracking" = xyes; then continue else break fi ;; - msvc7 | msvc7msys | msvisualcpp | msvcmsys) - # This compiler won't grok '-c -o', but also, the minuso test has + msvisualcpp | msvcmsys) + # This compiler won't grok `-c -o', but also, the minuso test has # not run yet. These depmodes are late enough in the game, and # so weak that their functioning should not be impacted. am__obj=conftest.${OBJEXT-o} @@ -1148,7 +326,7 @@ # AM_SET_DEPDIR # ------------- # Choose a directory name for dependency files. -# This macro is AC_REQUIREd in _AM_DEPENDENCIES. +# This macro is AC_REQUIREd in _AM_DEPENDENCIES AC_DEFUN([AM_SET_DEPDIR], [AC_REQUIRE([AM_SET_LEADING_DOT])dnl AC_SUBST([DEPDIR], ["${am__leading_dot}deps"])dnl @@ -1158,34 +336,28 @@ # AM_DEP_TRACK # ------------ AC_DEFUN([AM_DEP_TRACK], -[AC_ARG_ENABLE([dependency-tracking], [dnl -AS_HELP_STRING( - [--enable-dependency-tracking], - [do not reject slow dependency extractors]) -AS_HELP_STRING( - [--disable-dependency-tracking], - [speeds up one-time build])]) +[AC_ARG_ENABLE(dependency-tracking, +[ --disable-dependency-tracking speeds up one-time build + --enable-dependency-tracking do not reject slow dependency extractors]) if test "x$enable_dependency_tracking" != xno; then am_depcomp="$ac_aux_dir/depcomp" AMDEPBACKSLASH='\' - am__nodep='_no' fi AM_CONDITIONAL([AMDEP], [test "x$enable_dependency_tracking" != xno]) AC_SUBST([AMDEPBACKSLASH])dnl _AM_SUBST_NOTMAKE([AMDEPBACKSLASH])dnl -AC_SUBST([am__nodep])dnl -_AM_SUBST_NOTMAKE([am__nodep])dnl ]) # Generate code to set up dependency tracking. -*- Autoconf -*- -# Copyright (C) 1999-2012 Free Software Foundation, Inc. +# Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2008 +# Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. -# serial 6 +#serial 5 # _AM_OUTPUT_DEPENDENCY_COMMANDS # ------------------------------ @@ -1204,7 +376,7 @@ # Strip MF so we end up with the name of the file. mf=`echo "$mf" | sed -e 's/:.*$//'` # Check whether this is an Automake generated Makefile or not. - # We used to match only the files named 'Makefile.in', but + # We used to match only the files named `Makefile.in', but # some people rename them; so instead we look at the file content. # Grep'ing the first line is not enough: some people post-process # each Makefile.in and add a new line on top of each file to say so. @@ -1216,19 +388,21 @@ continue fi # Extract the definition of DEPDIR, am__include, and am__quote - # from the Makefile without running 'make'. + # from the Makefile without running `make'. DEPDIR=`sed -n 's/^DEPDIR = //p' < "$mf"` test -z "$DEPDIR" && continue am__include=`sed -n 's/^am__include = //p' < "$mf"` test -z "am__include" && continue am__quote=`sed -n 's/^am__quote = //p' < "$mf"` + # When using ansi2knr, U may be empty or an underscore; expand it + U=`sed -n 's/^U = //p' < "$mf"` # Find all dependency output files, they are included files with # $(DEPDIR) in their names. We invoke sed twice because it is the # simplest approach to changing $(DEPDIR) to its actual value in the # expansion. for file in `sed -n " s/^$am__include $am__quote\(.*(DEPDIR).*\)$am__quote"'$/\1/p' <"$mf" | \ - sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g'`; do + sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g' -e 's/\$U/'"$U"'/g'`; do # Make sure the directory exists. test -f "$dirpart/$file" && continue fdir=`AS_DIRNAME(["$file"])` @@ -1246,7 +420,7 @@ # This macro should only be invoked once -- use via AC_REQUIRE. # # This code is only required when automatic dependency tracking -# is enabled. FIXME. This creates each '.P' file that we will +# is enabled. FIXME. This creates each `.P' file that we will # need in order to bootstrap the dependency handling code. AC_DEFUN([AM_OUTPUT_DEPENDENCY_COMMANDS], [AC_CONFIG_COMMANDS([depfiles], @@ -1256,13 +430,14 @@ # Do all the work for Automake. -*- Autoconf -*- -# Copyright (C) 1996-2012 Free Software Foundation, Inc. +# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, +# 2005, 2006, 2008, 2009 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. -# serial 19 +# serial 16 # This macro actually does too much. Some checks are only needed if # your package does certain things. But this isn't really a big deal. @@ -1308,41 +483,31 @@ # Define the identity of the package. dnl Distinguish between old-style and new-style calls. m4_ifval([$2], -[AC_DIAGNOSE([obsolete], -[$0: two- and three-arguments forms are deprecated. For more info, see: -http://www.gnu.org/software/automake/manual/automake.html#Modernize-AM_INIT_AUTOMAKE-invocation]) -m4_ifval([$3], [_AM_SET_OPTION([no-define])])dnl +[m4_ifval([$3], [_AM_SET_OPTION([no-define])])dnl AC_SUBST([PACKAGE], [$1])dnl AC_SUBST([VERSION], [$2])], [_AM_SET_OPTIONS([$1])dnl dnl Diagnose old-style AC_INIT with new-style AM_AUTOMAKE_INIT. -m4_if( - m4_ifdef([AC_PACKAGE_NAME], [ok]):m4_ifdef([AC_PACKAGE_VERSION], [ok]), - [ok:ok],, +m4_if(m4_ifdef([AC_PACKAGE_NAME], 1)m4_ifdef([AC_PACKAGE_VERSION], 1), 11,, [m4_fatal([AC_INIT should be called with package and version arguments])])dnl AC_SUBST([PACKAGE], ['AC_PACKAGE_TARNAME'])dnl AC_SUBST([VERSION], ['AC_PACKAGE_VERSION'])])dnl _AM_IF_OPTION([no-define],, -[AC_DEFINE_UNQUOTED([PACKAGE], ["$PACKAGE"], [Name of package]) - AC_DEFINE_UNQUOTED([VERSION], ["$VERSION"], [Version number of package])])dnl +[AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Name of package]) + AC_DEFINE_UNQUOTED(VERSION, "$VERSION", [Version number of package])])dnl # Some tools Automake needs. AC_REQUIRE([AM_SANITY_CHECK])dnl AC_REQUIRE([AC_ARG_PROGRAM])dnl -AM_MISSING_PROG([ACLOCAL], [aclocal-${am__api_version}]) -AM_MISSING_PROG([AUTOCONF], [autoconf]) -AM_MISSING_PROG([AUTOMAKE], [automake-${am__api_version}]) -AM_MISSING_PROG([AUTOHEADER], [autoheader]) -AM_MISSING_PROG([MAKEINFO], [makeinfo]) +AM_MISSING_PROG(ACLOCAL, aclocal-${am__api_version}) +AM_MISSING_PROG(AUTOCONF, autoconf) +AM_MISSING_PROG(AUTOMAKE, automake-${am__api_version}) +AM_MISSING_PROG(AUTOHEADER, autoheader) +AM_MISSING_PROG(MAKEINFO, makeinfo) AC_REQUIRE([AM_PROG_INSTALL_SH])dnl AC_REQUIRE([AM_PROG_INSTALL_STRIP])dnl -AC_REQUIRE([AC_PROG_MKDIR_P])dnl -# For better backward compatibility. To be removed once Automake 1.9.x -# dies out for good. For more background, see: -# -# -AC_SUBST([mkdir_p], ['$(MKDIR_P)']) +AC_REQUIRE([AM_PROG_MKDIR_P])dnl # We need awk for the "check" target. The system "awk" is bad on # some platforms. AC_REQUIRE([AC_PROG_AWK])dnl @@ -1353,35 +518,28 @@ [_AM_PROG_TAR([v7])])]) _AM_IF_OPTION([no-dependencies],, [AC_PROVIDE_IFELSE([AC_PROG_CC], - [_AM_DEPENDENCIES([CC])], - [m4_define([AC_PROG_CC], - m4_defn([AC_PROG_CC])[_AM_DEPENDENCIES([CC])])])dnl + [_AM_DEPENDENCIES(CC)], + [define([AC_PROG_CC], + defn([AC_PROG_CC])[_AM_DEPENDENCIES(CC)])])dnl AC_PROVIDE_IFELSE([AC_PROG_CXX], - [_AM_DEPENDENCIES([CXX])], - [m4_define([AC_PROG_CXX], - m4_defn([AC_PROG_CXX])[_AM_DEPENDENCIES([CXX])])])dnl + [_AM_DEPENDENCIES(CXX)], + [define([AC_PROG_CXX], + defn([AC_PROG_CXX])[_AM_DEPENDENCIES(CXX)])])dnl AC_PROVIDE_IFELSE([AC_PROG_OBJC], - [_AM_DEPENDENCIES([OBJC])], - [m4_define([AC_PROG_OBJC], - m4_defn([AC_PROG_OBJC])[_AM_DEPENDENCIES([OBJC])])])dnl -dnl Support for Objective C++ was only introduced in Autoconf 2.65, -dnl but we still cater to Autoconf 2.62. -m4_ifdef([AC_PROG_OBJCXX], -[AC_PROVIDE_IFELSE([AC_PROG_OBJCXX], - [_AM_DEPENDENCIES([OBJCXX])], - [m4_define([AC_PROG_OBJCXX], - m4_defn([AC_PROG_OBJCXX])[_AM_DEPENDENCIES([OBJCXX])])])])dnl + [_AM_DEPENDENCIES(OBJC)], + [define([AC_PROG_OBJC], + defn([AC_PROG_OBJC])[_AM_DEPENDENCIES(OBJC)])])dnl ]) _AM_IF_OPTION([silent-rules], [AC_REQUIRE([AM_SILENT_RULES])])dnl -dnl The 'parallel-tests' driver may need to know about EXEEXT, so add the -dnl 'am__EXEEXT' conditional if _AM_COMPILER_EXEEXT was seen. This macro +dnl The `parallel-tests' driver may need to know about EXEEXT, so add the +dnl `am__EXEEXT' conditional if _AM_COMPILER_EXEEXT was seen. This macro dnl is hooked onto _AC_COMPILER_EXEEXT early, see below. AC_CONFIG_COMMANDS_PRE(dnl [m4_provide_if([_AM_COMPILER_EXEEXT], [AM_CONDITIONAL([am__EXEEXT], [test -n "$EXEEXT"])])])dnl ]) -dnl Hook into '_AC_COMPILER_EXEEXT' early to learn its expansion. Do not +dnl Hook into `_AC_COMPILER_EXEEXT' early to learn its expansion. Do not dnl add the conditional right here, as _AC_COMPILER_EXEEXT may be further dnl mangled by Autoconf and run in a shell conditional statement. m4_define([_AC_COMPILER_EXEEXT], @@ -1409,14 +567,12 @@ done echo "timestamp for $_am_arg" >`AS_DIRNAME(["$_am_arg"])`/stamp-h[]$_am_stamp_count]) -# Copyright (C) 2001-2012 Free Software Foundation, Inc. +# Copyright (C) 2001, 2003, 2005, 2008 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. -# serial 8 - # AM_PROG_INSTALL_SH # ------------------ # Define $install_sh. @@ -1430,9 +586,9 @@ install_sh="\${SHELL} $am_aux_dir/install-sh" esac fi -AC_SUBST([install_sh])]) +AC_SUBST(install_sh)]) -# Copyright (C) 2003-2012 Free Software Foundation, Inc. +# Copyright (C) 2003, 2005 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -1456,19 +612,20 @@ # Add --enable-maintainer-mode option to configure. -*- Autoconf -*- # From Jim Meyering -# Copyright (C) 1996-2012 Free Software Foundation, Inc. +# Copyright (C) 1996, 1998, 2000, 2001, 2002, 2003, 2004, 2005, 2008 +# Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. -# serial 7 +# serial 5 # AM_MAINTAINER_MODE([DEFAULT-MODE]) # ---------------------------------- # Control maintainer-specific portions of Makefiles. -# Default is to disable them, unless 'enable' is passed literally. -# For symmetry, 'disable' may be passed as well. Anyway, the user +# Default is to disable them, unless `enable' is passed literally. +# For symmetry, `disable' may be passed as well. Anyway, the user # can override the default with the --enable/--disable switch. AC_DEFUN([AM_MAINTAINER_MODE], [m4_case(m4_default([$1], [disable]), @@ -1476,14 +633,13 @@ [disable], [m4_define([am_maintainer_other], [enable])], [m4_define([am_maintainer_other], [enable]) m4_warn([syntax], [unexpected argument to AM@&t@_MAINTAINER_MODE: $1])]) -AC_MSG_CHECKING([whether to enable maintainer-specific portions of Makefiles]) +AC_MSG_CHECKING([whether to am_maintainer_other maintainer-specific portions of Makefiles]) dnl maintainer-mode's default is 'disable' unless 'enable' is passed AC_ARG_ENABLE([maintainer-mode], - [AS_HELP_STRING([--]am_maintainer_other[-maintainer-mode], - am_maintainer_other[ make rules and dependencies not useful - (and sometimes confusing) to the casual installer])], - [USE_MAINTAINER_MODE=$enableval], - [USE_MAINTAINER_MODE=]m4_if(am_maintainer_other, [enable], [no], [yes])) +[ --][am_maintainer_other][-maintainer-mode am_maintainer_other make rules and dependencies not useful + (and sometimes confusing) to the casual installer], + [USE_MAINTAINER_MODE=$enableval], + [USE_MAINTAINER_MODE=]m4_if(am_maintainer_other, [enable], [no], [yes])) AC_MSG_RESULT([$USE_MAINTAINER_MODE]) AM_CONDITIONAL([MAINTAINER_MODE], [test $USE_MAINTAINER_MODE = yes]) MAINT=$MAINTAINER_MODE_TRUE @@ -1495,13 +651,13 @@ # Check to see how 'make' treats includes. -*- Autoconf -*- -# Copyright (C) 2001-2012 Free Software Foundation, Inc. +# Copyright (C) 2001, 2002, 2003, 2005, 2009 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. -# serial 5 +# serial 4 # AM_MAKE_INCLUDE() # ----------------- @@ -1520,7 +676,7 @@ _am_result=none # First try GNU make style include. echo "include confinc" > confmf -# Ignore all kinds of additional output from 'make'. +# Ignore all kinds of additional output from `make'. case `$am_make -s -f confmf 2> /dev/null` in #( *the\ am__doit\ target*) am__include=include @@ -1545,7 +701,8 @@ rm -f confinc confmf ]) -# Copyright (C) 1999-2012 Free Software Foundation, Inc. +# Copyright (C) 1999, 2000, 2001, 2003, 2004, 2005, 2008 +# Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -1581,13 +738,14 @@ # Fake the existence of programs that GNU maintainers use. -*- Autoconf -*- -# Copyright (C) 1997-2012 Free Software Foundation, Inc. +# Copyright (C) 1997, 1999, 2000, 2001, 2003, 2004, 2005, 2008 +# Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. -# serial 7 +# serial 6 # AM_MISSING_PROG(NAME, PROGRAM) # ------------------------------ @@ -1617,19 +775,45 @@ am_missing_run="$MISSING --run " else am_missing_run= - AC_MSG_WARN(['missing' script is too old or missing]) + AC_MSG_WARN([`missing' script is too old or missing]) fi ]) -# Helper functions for option handling. -*- Autoconf -*- - -# Copyright (C) 2001-2012 Free Software Foundation, Inc. +# Copyright (C) 2003, 2004, 2005, 2006 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. -# serial 6 +# AM_PROG_MKDIR_P +# --------------- +# Check for `mkdir -p'. +AC_DEFUN([AM_PROG_MKDIR_P], +[AC_PREREQ([2.60])dnl +AC_REQUIRE([AC_PROG_MKDIR_P])dnl +dnl Automake 1.8 to 1.9.6 used to define mkdir_p. We now use MKDIR_P, +dnl while keeping a definition of mkdir_p for backward compatibility. +dnl @MKDIR_P@ is magic: AC_OUTPUT adjusts its value for each Makefile. +dnl However we cannot define mkdir_p as $(MKDIR_P) for the sake of +dnl Makefile.ins that do not define MKDIR_P, so we do our own +dnl adjustment using top_builddir (which is defined more often than +dnl MKDIR_P). +AC_SUBST([mkdir_p], ["$MKDIR_P"])dnl +case $mkdir_p in + [[\\/$]]* | ?:[[\\/]]*) ;; + */*) mkdir_p="\$(top_builddir)/$mkdir_p" ;; +esac +]) + +# Helper functions for option handling. -*- Autoconf -*- + +# Copyright (C) 2001, 2002, 2003, 2005, 2008 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# serial 4 # _AM_MANGLE_OPTION(NAME) # ----------------------- @@ -1637,13 +821,13 @@ [[_AM_OPTION_]m4_bpatsubst($1, [[^a-zA-Z0-9_]], [_])]) # _AM_SET_OPTION(NAME) -# -------------------- +# ------------------------------ # Set option NAME. Presently that only means defining a flag for this option. AC_DEFUN([_AM_SET_OPTION], -[m4_define(_AM_MANGLE_OPTION([$1]), [1])]) +[m4_define(_AM_MANGLE_OPTION([$1]), 1)]) # _AM_SET_OPTIONS(OPTIONS) -# ------------------------ +# ---------------------------------- # OPTIONS is a space-separated list of Automake options. AC_DEFUN([_AM_SET_OPTIONS], [m4_foreach_w([_AM_Option], [$1], [_AM_SET_OPTION(_AM_Option)])]) @@ -1656,18 +840,22 @@ # Check to make sure that the build environment is sane. -*- Autoconf -*- -# Copyright (C) 1996-2012 Free Software Foundation, Inc. +# Copyright (C) 1996, 1997, 2000, 2001, 2003, 2005, 2008 +# Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. -# serial 9 +# serial 5 # AM_SANITY_CHECK # --------------- AC_DEFUN([AM_SANITY_CHECK], [AC_MSG_CHECKING([whether build environment is sane]) +# Just in case +sleep 1 +echo timestamp > conftest.file # Reject unsafe characters in $srcdir or the absolute working directory # name. Accept space and tab only in the latter. am_lf=' @@ -1678,40 +866,32 @@ esac case $srcdir in *[[\\\"\#\$\&\'\`$am_lf\ \ ]]*) - AC_MSG_ERROR([unsafe srcdir value: '$srcdir']);; + AC_MSG_ERROR([unsafe srcdir value: `$srcdir']);; esac -# Do 'set' in a subshell so we don't clobber the current shell's +# Do `set' in a subshell so we don't clobber the current shell's # arguments. Must try -L first in case configure is actually a # symlink; some systems play weird games with the mod time of symlinks # (eg FreeBSD returns the mod time of the symlink's containing # directory). if ( - am_has_slept=no - for am_try in 1 2; do - echo "timestamp, slept: $am_has_slept" > conftest.file - set X `ls -Lt "$srcdir/configure" conftest.file 2> /dev/null` - if test "$[*]" = "X"; then - # -L didn't work. - set X `ls -t "$srcdir/configure" conftest.file` - fi - if test "$[*]" != "X $srcdir/configure conftest.file" \ - && test "$[*]" != "X conftest.file $srcdir/configure"; then + set X `ls -Lt "$srcdir/configure" conftest.file 2> /dev/null` + if test "$[*]" = "X"; then + # -L didn't work. + set X `ls -t "$srcdir/configure" conftest.file` + fi + rm -f conftest.file + if test "$[*]" != "X $srcdir/configure conftest.file" \ + && test "$[*]" != "X conftest.file $srcdir/configure"; then - # If neither matched, then we have a broken ls. This can happen - # if, for instance, CONFIG_SHELL is bash and it inherits a - # broken ls alias from the environment. This has actually - # happened. Such a system could not be considered "sane". - AC_MSG_ERROR([ls -t appears to fail. Make sure there is not a broken - alias in your environment]) - fi - if test "$[2]" = conftest.file || test $am_try -eq 2; then - break - fi - # Just in case. - sleep 1 - am_has_slept=yes - done + # If neither matched, then we have a broken ls. This can happen + # if, for instance, CONFIG_SHELL is bash and it inherits a + # broken ls alias from the environment. This has actually + # happened. Such a system could not be considered "sane". + AC_MSG_ERROR([ls -t appears to fail. Make sure there is not a broken +alias in your environment]) + fi + test "$[2]" = conftest.file ) then @@ -1721,25 +901,37 @@ AC_MSG_ERROR([newly created file is older than distributed files! Check your system clock]) fi -AC_MSG_RESULT([yes]) -# If we didn't sleep, we still need to ensure time stamps of config.status and -# generated files are strictly newer. -am_sleep_pid= -if grep 'slept: no' conftest.file >/dev/null 2>&1; then - ( sleep 1 ) & - am_sleep_pid=$! +AC_MSG_RESULT(yes)]) + +# Copyright (C) 2001, 2003, 2005 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# AM_PROG_INSTALL_STRIP +# --------------------- +# One issue with vendor `install' (even GNU) is that you can't +# specify the program used to strip binaries. This is especially +# annoying in cross-compiling environments, where the build's strip +# is unlikely to handle the host's binaries. +# Fortunately install-sh will honor a STRIPPROG variable, so we +# always use install-sh in `make install-strip', and initialize +# STRIPPROG with the value of the STRIP variable (set by the user). +AC_DEFUN([AM_PROG_INSTALL_STRIP], +[AC_REQUIRE([AM_PROG_INSTALL_SH])dnl +# Installed binaries are usually stripped using `strip' when the user +# run `make install-strip'. However `strip' might not be the right +# tool to use in cross-compilation environments, therefore Automake +# will honor the `STRIP' environment variable to overrule this program. +dnl Don't test for $cross_compiling = yes, because it might be `maybe'. +if test "$cross_compiling" != no; then + AC_CHECK_TOOL([STRIP], [strip], :) fi -AC_CONFIG_COMMANDS_PRE( - [AC_MSG_CHECKING([that generated files are newer than configure]) - if test -n "$am_sleep_pid"; then - # Hide warnings about reused PIDs. - wait $am_sleep_pid 2>/dev/null - fi - AC_MSG_RESULT([done])]) -rm -f conftest.file -]) +INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s" +AC_SUBST([INSTALL_STRIP_PROGRAM])]) -# Copyright (C) 2001-2012 Free Software Foundation, Inc. +# Copyright (C) 2006, 2008 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -1747,36 +939,6 @@ # serial 2 -# AM_PROG_INSTALL_STRIP -# --------------------- -# One issue with vendor 'install' (even GNU) is that you can't -# specify the program used to strip binaries. This is especially -# annoying in cross-compiling environments, where the build's strip -# is unlikely to handle the host's binaries. -# Fortunately install-sh will honor a STRIPPROG variable, so we -# always use install-sh in "make install-strip", and initialize -# STRIPPROG with the value of the STRIP variable (set by the user). -AC_DEFUN([AM_PROG_INSTALL_STRIP], -[AC_REQUIRE([AM_PROG_INSTALL_SH])dnl -# Installed binaries are usually stripped using 'strip' when the user -# run "make install-strip". However 'strip' might not be the right -# tool to use in cross-compilation environments, therefore Automake -# will honor the 'STRIP' environment variable to overrule this program. -dnl Don't test for $cross_compiling = yes, because it might be 'maybe'. -if test "$cross_compiling" != no; then - AC_CHECK_TOOL([STRIP], [strip], :) -fi -INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s" -AC_SUBST([INSTALL_STRIP_PROGRAM])]) - -# Copyright (C) 2006-2012 Free Software Foundation, Inc. -# -# This file is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# serial 3 - # _AM_SUBST_NOTMAKE(VARIABLE) # --------------------------- # Prevent Automake from outputting VARIABLE = @VARIABLE@ in Makefile.in. @@ -1784,24 +946,24 @@ AC_DEFUN([_AM_SUBST_NOTMAKE]) # AM_SUBST_NOTMAKE(VARIABLE) -# -------------------------- +# --------------------------- # Public sister of _AM_SUBST_NOTMAKE. AC_DEFUN([AM_SUBST_NOTMAKE], [_AM_SUBST_NOTMAKE($@)]) # Check how to create a tarball. -*- Autoconf -*- -# Copyright (C) 2004-2012 Free Software Foundation, Inc. +# Copyright (C) 2004, 2005 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. -# serial 3 +# serial 2 # _AM_PROG_TAR(FORMAT) # -------------------- # Check how to create a tarball in format FORMAT. -# FORMAT should be one of 'v7', 'ustar', or 'pax'. +# FORMAT should be one of `v7', `ustar', or `pax'. # # Substitute a variable $(am__tar) that is a command # writing to stdout a FORMAT-tarball containing the directory @@ -1812,11 +974,10 @@ # a tarball read from stdin. # $(am__untar) < result.tar AC_DEFUN([_AM_PROG_TAR], -[# Always define AMTAR for backward compatibility. Yes, it's still used -# in the wild :-( We should find a proper way to deprecate it ... -AC_SUBST([AMTAR], ['$${TAR-tar}']) +[# Always define AMTAR for backward compatibility. +AM_MISSING_PROG([AMTAR], [tar]) m4_if([$1], [v7], - [am__tar='$${TAR-tar} chof - "$$tardir"' am__untar='$${TAR-tar} xf -'], + [am__tar='${AMTAR} chof - "$$tardir"'; am__untar='${AMTAR} xf -'], [m4_case([$1], [ustar],, [pax],, [m4_fatal([Unknown tar format])]) AC_MSG_CHECKING([how to create a $1 tar archive]) @@ -1824,7 +985,7 @@ _am_tools='gnutar m4_if([$1], [ustar], [plaintar]) pax cpio none' _am_tools=${am_cv_prog_tar_$1-$_am_tools} # Do not fold the above two line into one, because Tru64 sh and -# Solaris sh will not grok spaces in the rhs of '-'. +# Solaris sh will not grok spaces in the rhs of `-'. for _am_tool in $_am_tools do case $_am_tool in @@ -1885,16 +1046,6 @@ AC_SUBST([am__untar]) ]) # _AM_PROG_TAR -m4_include([m4/asmcfi.m4]) -m4_include([m4/ax_append_flag.m4]) -m4_include([m4/ax_cc_maxopt.m4]) -m4_include([m4/ax_cflags_warn_all.m4]) -m4_include([m4/ax_check_compile_flag.m4]) -m4_include([m4/ax_compiler_vendor.m4]) -m4_include([m4/ax_configure_args.m4]) -m4_include([m4/ax_enable_builddir.m4]) -m4_include([m4/ax_gcc_archflag.m4]) -m4_include([m4/ax_gcc_x86_cpuid.m4]) m4_include([m4/libtool.m4]) m4_include([m4/ltoptions.m4]) m4_include([m4/ltsugar.m4]) diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi/build-ios.sh --- a/Modules/_ctypes/libffi/build-ios.sh Sat Jul 19 16:34:33 2014 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,67 +0,0 @@ -#!/bin/sh - -PLATFORM_IOS=/Developer/Platforms/iPhoneOS.platform/ -PLATFORM_IOS_SIM=/Developer/Platforms/iPhoneSimulator.platform/ -SDK_IOS_VERSION="4.2" -MIN_IOS_VERSION="3.0" -OUTPUT_DIR="universal-ios" - -build_target () { - local platform=$1 - local sdk=$2 - local arch=$3 - local triple=$4 - local builddir=$5 - - mkdir -p "${builddir}" - pushd "${builddir}" - export CC="${platform}"/Developer/usr/bin/gcc-4.2 - export CFLAGS="-arch ${arch} -isysroot ${sdk} -miphoneos-version-min=${MIN_IOS_VERSION}" - ../configure --host=${triple} && make - popd -} - -# Build all targets -build_target "${PLATFORM_IOS}" "${PLATFORM_IOS}/Developer/SDKs/iPhoneOS${SDK_IOS_VERSION}.sdk/" armv6 arm-apple-darwin10 armv6-ios -build_target "${PLATFORM_IOS}" "${PLATFORM_IOS}/Developer/SDKs/iPhoneOS${SDK_IOS_VERSION}.sdk/" armv7 arm-apple-darwin10 armv7-ios -build_target "${PLATFORM_IOS_SIM}" "${PLATFORM_IOS_SIM}/Developer/SDKs/iPhoneSimulator${SDK_IOS_VERSION}.sdk/" i386 i386-apple-darwin10 i386-ios-sim - -# Create universal output directories -mkdir -p "${OUTPUT_DIR}" -mkdir -p "${OUTPUT_DIR}/include" -mkdir -p "${OUTPUT_DIR}/include/armv6" -mkdir -p "${OUTPUT_DIR}/include/armv7" -mkdir -p "${OUTPUT_DIR}/include/i386" - -# Create the universal binary -lipo -create armv6-ios/.libs/libffi.a armv7-ios/.libs/libffi.a i386-ios-sim/.libs/libffi.a -output "${OUTPUT_DIR}/libffi.a" - -# Copy in the headers -copy_headers () { - local src=$1 - local dest=$2 - - # Fix non-relative header reference - sed 's//"ffitarget.h"/' < "${src}/include/ffi.h" > "${dest}/ffi.h" - cp "${src}/include/ffitarget.h" "${dest}" -} - -copy_headers armv6-ios "${OUTPUT_DIR}/include/armv6" -copy_headers armv7-ios "${OUTPUT_DIR}/include/armv7" -copy_headers i386-ios-sim "${OUTPUT_DIR}/include/i386" - -# Create top-level header -( -cat << EOF -#ifdef __arm__ - #include - #ifdef _ARM_ARCH_6 - #include "include/armv6/ffi.h" - #elif _ARM_ARCH_7 - #include "include/armv7/ffi.h" - #endif -#elif defined(__i386__) - #include "include/i386/ffi.h" -#endif -EOF -) > "${OUTPUT_DIR}/ffi.h" diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi/compile --- a/Modules/_ctypes/libffi/compile Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/_ctypes/libffi/compile Sun Jul 20 10:52:46 2014 -0400 @@ -1,10 +1,9 @@ #! /bin/sh # Wrapper for compilers which do not understand `-c -o'. -scriptversion=2009-10-06.20; # UTC +scriptversion=2005-05-14.22 -# Copyright (C) 1999, 2000, 2003, 2004, 2005, 2009 Free Software -# Foundation, Inc. +# Copyright (C) 1999, 2000, 2003, 2004, 2005 Free Software Foundation, Inc. # Written by Tom Tromey . # # This program is free software; you can redistribute it and/or modify @@ -18,7 +17,8 @@ # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License -# along with this program. If not, see . +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a @@ -103,13 +103,13 @@ fi # Name of file we expect compiler to create. -cofile=`echo "$cfile" | sed 's|^.*[\\/]||; s|^[a-zA-Z]:||; s/\.c$/.o/'` +cofile=`echo "$cfile" | sed -e 's|^.*/||' -e 's/\.c$/.o/'` # Create the lock directory. -# Note: use `[/\\:.-]' here to ensure that we don't use the same name +# Note: use `[/.-]' here to ensure that we don't use the same name # that we are using for the .o file. Also, base the name on the expected # object file name, since that is what matters with a parallel build. -lockdir=`echo "$cofile" | sed -e 's|[/\\:.-]|_|g'`.d +lockdir=`echo "$cofile" | sed -e 's|[/.-]|_|g'`.d while true; do if mkdir "$lockdir" >/dev/null 2>&1; then break @@ -124,9 +124,9 @@ ret=$? if test -f "$cofile"; then - test "$cofile" = "$ofile" || mv "$cofile" "$ofile" + mv "$cofile" "$ofile" elif test -f "${cofile}bj"; then - test "${cofile}bj" = "$ofile" || mv "${cofile}bj" "$ofile" + mv "${cofile}bj" "$ofile" fi rmdir "$lockdir" @@ -138,6 +138,5 @@ # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "scriptversion=" # time-stamp-format: "%:y-%02m-%02d.%02H" -# time-stamp-time-zone: "UTC" -# time-stamp-end: "; # UTC" +# time-stamp-end: "$" # End: diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi/config.guess --- a/Modules/_ctypes/libffi/config.guess Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/_ctypes/libffi/config.guess Sun Jul 20 10:52:46 2014 -0400 @@ -1,14 +1,14 @@ #! /bin/sh # Attempt to guess a canonical system name. # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, -# 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, -# 2011, 2012, 2013 Free Software Foundation, Inc. +# 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 +# Free Software Foundation, Inc. -timestamp='2012-12-29' +timestamp='2009-11-19' # This file is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3 of the License, or +# the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, but @@ -17,22 +17,26 @@ # General Public License for more details. # # You should have received a copy of the GNU General Public License -# along with this program; if not, see . +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA +# 02110-1301, USA. # # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under -# the same distribution terms that you use for the rest of that -# program. This Exception is an additional permission under section 7 -# of the GNU General Public License, version 3 ("GPLv3"). +# the same distribution terms that you use for the rest of that program. + + +# Originally written by Per Bothner. Please send patches (context +# diff format) to and include a ChangeLog +# entry. # -# Originally written by Per Bothner. +# This script attempts to guess a canonical system name similar to +# config.sub. If it succeeds, it prints the system name on stdout, and +# exits with 0. Otherwise, it exits with 1. # # You can get the latest version of this script from: # http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD -# -# Please send patches with a ChangeLog entry to config-patches@gnu.org. - me=`echo "$0" | sed -e 's,.*/,,'` @@ -52,9 +56,8 @@ GNU config.guess ($timestamp) Originally written by Per Bothner. -Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, -2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, -2012, 2013 Free Software Foundation, Inc. +Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, +2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." @@ -141,7 +144,7 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in *:NetBSD:*:*) # NetBSD (nbsd) targets should (where applicable) match one or - # more of the tuples: *-*-netbsdelf*, *-*-netbsdaout*, + # more of the tupples: *-*-netbsdelf*, *-*-netbsdaout*, # *-*-netbsdecoff* and *-*-netbsd*. For targets that recently # switched to ELF, *-*-netbsd* would select the old # object file format. This provides both forward @@ -177,7 +180,7 @@ fi ;; *) - os=netbsd + os=netbsd ;; esac # The OS release @@ -198,10 +201,6 @@ # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used. echo "${machine}-${os}${release}" exit ;; - *:Bitrig:*:*) - UNAME_MACHINE_ARCH=`arch | sed 's/Bitrig.//'` - echo ${UNAME_MACHINE_ARCH}-unknown-bitrig${UNAME_RELEASE} - exit ;; *:OpenBSD:*:*) UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'` echo ${UNAME_MACHINE_ARCH}-unknown-openbsd${UNAME_RELEASE} @@ -224,7 +223,7 @@ UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'` ;; *5.*) - UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'` + UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'` ;; esac # According to Compaq, /usr/sbin/psrinfo has been available on @@ -270,10 +269,7 @@ # A Xn.n version is an unreleased experimental baselevel. # 1.2 uses "1.2" for uname -r. echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[PVTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` - # Reset EXIT trap before exiting to avoid spurious non-zero exit code. - exitcode=$? - trap '' 0 - exit $exitcode ;; + exit ;; Alpha\ *:Windows_NT*:*) # How do we know it's Interix rather than the generic POSIX subsystem? # Should we change UNAME_MACHINE based on the output of uname instead @@ -299,12 +295,12 @@ echo s390-ibm-zvmoe exit ;; *:OS400:*:*) - echo powerpc-ibm-os400 + echo powerpc-ibm-os400 exit ;; arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*) echo arm-acorn-riscix${UNAME_RELEASE} exit ;; - arm*:riscos:*:*|arm*:RISCOS:*:*) + arm:riscos:*:*|arm:RISCOS:*:*) echo arm-unknown-riscos exit ;; SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*) @@ -337,9 +333,6 @@ sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*) echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit ;; - i86pc:AuroraUX:5.*:* | i86xen:AuroraUX:5.*:*) - echo i386-pc-auroraux${UNAME_RELEASE} - exit ;; i86pc:SunOS:5.*:* | i86xen:SunOS:5.*:*) eval $set_cc_for_build SUN_ARCH="i386" @@ -398,23 +391,23 @@ # MiNT. But MiNT is downward compatible to TOS, so this should # be no problem. atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*) - echo m68k-atari-mint${UNAME_RELEASE} + echo m68k-atari-mint${UNAME_RELEASE} exit ;; atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*) echo m68k-atari-mint${UNAME_RELEASE} - exit ;; + exit ;; *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*) - echo m68k-atari-mint${UNAME_RELEASE} + echo m68k-atari-mint${UNAME_RELEASE} exit ;; milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*) - echo m68k-milan-mint${UNAME_RELEASE} - exit ;; + echo m68k-milan-mint${UNAME_RELEASE} + exit ;; hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*) - echo m68k-hades-mint${UNAME_RELEASE} - exit ;; + echo m68k-hades-mint${UNAME_RELEASE} + exit ;; *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*) - echo m68k-unknown-mint${UNAME_RELEASE} - exit ;; + echo m68k-unknown-mint${UNAME_RELEASE} + exit ;; m68k:machten:*:*) echo m68k-apple-machten${UNAME_RELEASE} exit ;; @@ -484,8 +477,8 @@ echo m88k-motorola-sysv3 exit ;; AViiON:dgux:*:*) - # DG/UX returns AViiON for all architectures - UNAME_PROCESSOR=`/usr/bin/uname -p` + # DG/UX returns AViiON for all architectures + UNAME_PROCESSOR=`/usr/bin/uname -p` if [ $UNAME_PROCESSOR = mc88100 ] || [ $UNAME_PROCESSOR = mc88110 ] then if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx ] || \ @@ -498,7 +491,7 @@ else echo i586-dg-dgux${UNAME_RELEASE} fi - exit ;; + exit ;; M88*:DolphinOS:*:*) # DolphinOS (SVR3) echo m88k-dolphin-sysv3 exit ;; @@ -555,7 +548,7 @@ echo rs6000-ibm-aix3.2 fi exit ;; - *:AIX:*:[4567]) + *:AIX:*:[456]) IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'` if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then IBM_ARCH=rs6000 @@ -598,52 +591,52 @@ 9000/[678][0-9][0-9]) if [ -x /usr/bin/getconf ]; then sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null` - sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null` - case "${sc_cpu_version}" in - 523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0 - 528) HP_ARCH="hppa1.1" ;; # CPU_PA_RISC1_1 - 532) # CPU_PA_RISC2_0 - case "${sc_kernel_bits}" in - 32) HP_ARCH="hppa2.0n" ;; - 64) HP_ARCH="hppa2.0w" ;; + sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null` + case "${sc_cpu_version}" in + 523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0 + 528) HP_ARCH="hppa1.1" ;; # CPU_PA_RISC1_1 + 532) # CPU_PA_RISC2_0 + case "${sc_kernel_bits}" in + 32) HP_ARCH="hppa2.0n" ;; + 64) HP_ARCH="hppa2.0w" ;; '') HP_ARCH="hppa2.0" ;; # HP-UX 10.20 - esac ;; - esac + esac ;; + esac fi if [ "${HP_ARCH}" = "" ]; then eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c + sed 's/^ //' << EOF >$dummy.c - #define _HPUX_SOURCE - #include - #include + #define _HPUX_SOURCE + #include + #include - int main () - { - #if defined(_SC_KERNEL_BITS) - long bits = sysconf(_SC_KERNEL_BITS); - #endif - long cpu = sysconf (_SC_CPU_VERSION); + int main () + { + #if defined(_SC_KERNEL_BITS) + long bits = sysconf(_SC_KERNEL_BITS); + #endif + long cpu = sysconf (_SC_CPU_VERSION); - switch (cpu) - { - case CPU_PA_RISC1_0: puts ("hppa1.0"); break; - case CPU_PA_RISC1_1: puts ("hppa1.1"); break; - case CPU_PA_RISC2_0: - #if defined(_SC_KERNEL_BITS) - switch (bits) - { - case 64: puts ("hppa2.0w"); break; - case 32: puts ("hppa2.0n"); break; - default: puts ("hppa2.0"); break; - } break; - #else /* !defined(_SC_KERNEL_BITS) */ - puts ("hppa2.0"); break; - #endif - default: puts ("hppa1.0"); break; - } - exit (0); - } + switch (cpu) + { + case CPU_PA_RISC1_0: puts ("hppa1.0"); break; + case CPU_PA_RISC1_1: puts ("hppa1.1"); break; + case CPU_PA_RISC2_0: + #if defined(_SC_KERNEL_BITS) + switch (bits) + { + case 64: puts ("hppa2.0w"); break; + case 32: puts ("hppa2.0n"); break; + default: puts ("hppa2.0"); break; + } break; + #else /* !defined(_SC_KERNEL_BITS) */ + puts ("hppa2.0"); break; + #endif + default: puts ("hppa1.0"); break; + } + exit (0); + } EOF (CCOPTS= $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null) && HP_ARCH=`$dummy` test -z "$HP_ARCH" && HP_ARCH=hppa @@ -734,22 +727,22 @@ exit ;; C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*) echo c1-convex-bsd - exit ;; + exit ;; C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*) if getsysinfo -f scalar_acc then echo c32-convex-bsd else echo c2-convex-bsd fi - exit ;; + exit ;; C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*) echo c34-convex-bsd - exit ;; + exit ;; C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*) echo c38-convex-bsd - exit ;; + exit ;; C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*) echo c4-convex-bsd - exit ;; + exit ;; CRAY*Y-MP:*:*:*) echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit ;; @@ -773,14 +766,14 @@ exit ;; F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*) FUJITSU_PROC=`uname -m | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` - FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` - FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'` - echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" - exit ;; + FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` + FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'` + echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" + exit ;; 5000:UNIX_System_V:4.*:*) - FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` - FUJITSU_REL=`echo ${UNAME_RELEASE} | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/ /_/'` - echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" + FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` + FUJITSU_REL=`echo ${UNAME_RELEASE} | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/ /_/'` + echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" exit ;; i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*) echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE} @@ -792,35 +785,30 @@ echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE} exit ;; *:FreeBSD:*:*) - UNAME_PROCESSOR=`/usr/bin/uname -p` - case ${UNAME_PROCESSOR} in + case ${UNAME_MACHINE} in + pc98) + echo i386-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; amd64) echo x86_64-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; *) - echo ${UNAME_PROCESSOR}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; + echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; esac exit ;; i*:CYGWIN*:*) echo ${UNAME_MACHINE}-pc-cygwin exit ;; - *:MINGW64*:*) - echo ${UNAME_MACHINE}-pc-mingw64 - exit ;; *:MINGW*:*) echo ${UNAME_MACHINE}-pc-mingw32 exit ;; - i*:MSYS*:*) - echo ${UNAME_MACHINE}-pc-msys - exit ;; i*:windows32*:*) - # uname -m includes "-pc" on this system. - echo ${UNAME_MACHINE}-mingw32 + # uname -m includes "-pc" on this system. + echo ${UNAME_MACHINE}-mingw32 exit ;; i*:PW*:*) echo ${UNAME_MACHINE}-pc-pw32 exit ;; *:Interix*:*) - case ${UNAME_MACHINE} in + case ${UNAME_MACHINE} in x86) echo i586-pc-interix${UNAME_RELEASE} exit ;; @@ -866,13 +854,6 @@ i*86:Minix:*:*) echo ${UNAME_MACHINE}-pc-minix exit ;; - aarch64:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-gnu - exit ;; - aarch64_be:Linux:*:*) - UNAME_MACHINE=aarch64_be - echo ${UNAME_MACHINE}-unknown-linux-gnu - exit ;; alpha:Linux:*:*) case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in EV5) UNAME_MACHINE=alphaev5 ;; @@ -882,7 +863,7 @@ EV6) UNAME_MACHINE=alphaev6 ;; EV67) UNAME_MACHINE=alphaev67 ;; EV68*) UNAME_MACHINE=alphaev68 ;; - esac + esac objdump --private-headers /bin/sh | grep -q ld.so.1 if test "$?" = 0 ; then LIBC="libc1" ; else LIBC="" ; fi echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC} @@ -894,29 +875,20 @@ then echo ${UNAME_MACHINE}-unknown-linux-gnu else - if echo __ARM_PCS_VFP | $CC_FOR_BUILD -E - 2>/dev/null \ - | grep -q __ARM_PCS_VFP - then - echo ${UNAME_MACHINE}-unknown-linux-gnueabi - else - echo ${UNAME_MACHINE}-unknown-linux-gnueabihf - fi + echo ${UNAME_MACHINE}-unknown-linux-gnueabi fi exit ;; avr32*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; cris:Linux:*:*) - echo ${UNAME_MACHINE}-axis-linux-gnu + echo cris-axis-linux-gnu exit ;; crisv32:Linux:*:*) - echo ${UNAME_MACHINE}-axis-linux-gnu + echo crisv32-axis-linux-gnu exit ;; frv:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-gnu - exit ;; - hexagon:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-gnu + echo frv-unknown-linux-gnu exit ;; i*86:Linux:*:*) LIBC=gnu @@ -958,7 +930,7 @@ test x"${CPU}" != x && { echo "${CPU}-unknown-linux-gnu"; exit; } ;; or32:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-gnu + echo or32-unknown-linux-gnu exit ;; padre:Linux:*:*) echo sparc-unknown-linux-gnu @@ -984,7 +956,7 @@ echo ${UNAME_MACHINE}-ibm-linux exit ;; sh64*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-gnu + echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; sh*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu @@ -992,17 +964,14 @@ sparc:Linux:*:* | sparc64:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; - tile*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-gnu - exit ;; vax:Linux:*:*) echo ${UNAME_MACHINE}-dec-linux-gnu exit ;; x86_64:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-gnu + echo x86_64-unknown-linux-gnu exit ;; xtensa*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-gnu + echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; i*86:DYNIX/ptx:4*:*) # ptx 4.0 does uname -s correctly, with DYNIX/ptx in there. @@ -1011,11 +980,11 @@ echo i386-sequent-sysv4 exit ;; i*86:UNIX_SV:4.2MP:2.*) - # Unixware is an offshoot of SVR4, but it has its own version - # number series starting with 2... - # I am not positive that other SVR4 systems won't match this, + # Unixware is an offshoot of SVR4, but it has its own version + # number series starting with 2... + # I am not positive that other SVR4 systems won't match this, # I just have to hope. -- rms. - # Use sysv4.2uw... so that sysv4* matches it. + # Use sysv4.2uw... so that sysv4* matches it. echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION} exit ;; i*86:OS/2:*:*) @@ -1047,7 +1016,7 @@ fi exit ;; i*86:*:5:[678]*) - # UnixWare 7.x, OpenUNIX and OpenServer 6. + # UnixWare 7.x, OpenUNIX and OpenServer 6. case `/bin/uname -X | grep "^Machine"` in *486*) UNAME_MACHINE=i486 ;; *Pentium) UNAME_MACHINE=i586 ;; @@ -1075,13 +1044,13 @@ exit ;; pc:*:*:*) # Left here for compatibility: - # uname -m prints for DJGPP always 'pc', but it prints nothing about - # the processor, so we play safe by assuming i586. + # uname -m prints for DJGPP always 'pc', but it prints nothing about + # the processor, so we play safe by assuming i586. # Note: whatever this is, it MUST be the same as what config.sub # prints for the "djgpp" host, or else GDB configury will decide that # this is a cross-build. echo i586-pc-msdosdjgpp - exit ;; + exit ;; Intel:Mach:3*:*) echo i386-pc-mach3 exit ;; @@ -1116,8 +1085,8 @@ /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;; 3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*) - /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ - && { echo i486-ncr-sysv4; exit; } ;; + /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ + && { echo i486-ncr-sysv4; exit; } ;; NCR*:*:4.2:* | MPRAS*:*:4.2:*) OS_REL='.3' test -r /etc/.relid \ @@ -1160,10 +1129,10 @@ echo ns32k-sni-sysv fi exit ;; - PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort - # says - echo i586-unisys-sysv4 - exit ;; + PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort + # says + echo i586-unisys-sysv4 + exit ;; *:UNIX_System_V:4*:FTX*) # From Gerald Hewes . # How about differentiating between stratus architectures? -djm @@ -1189,11 +1158,11 @@ exit ;; R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*) if [ -d /usr/nec ]; then - echo mips-nec-sysv${UNAME_RELEASE} + echo mips-nec-sysv${UNAME_RELEASE} else - echo mips-unknown-sysv${UNAME_RELEASE} + echo mips-unknown-sysv${UNAME_RELEASE} fi - exit ;; + exit ;; BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only. echo powerpc-be-beos exit ;; @@ -1206,9 +1175,6 @@ BePC:Haiku:*:*) # Haiku running on Intel PC compatible. echo i586-pc-haiku exit ;; - x86_64:Haiku:*:*) - echo x86_64-unknown-haiku - exit ;; SX-4:SUPER-UX:*:*) echo sx4-nec-superux${UNAME_RELEASE} exit ;; @@ -1261,10 +1227,7 @@ *:QNX:*:4*) echo i386-pc-qnx exit ;; - NEO-?:NONSTOP_KERNEL:*:*) - echo neo-tandem-nsk${UNAME_RELEASE} - exit ;; - NSE-*:NONSTOP_KERNEL:*:*) + NSE-?:NONSTOP_KERNEL:*:*) echo nse-tandem-nsk${UNAME_RELEASE} exit ;; NSR-?:NONSTOP_KERNEL:*:*) @@ -1309,13 +1272,13 @@ echo pdp10-unknown-its exit ;; SEI:*:*:SEIUX) - echo mips-sei-seiux${UNAME_RELEASE} + echo mips-sei-seiux${UNAME_RELEASE} exit ;; *:DragonFly:*:*) echo ${UNAME_MACHINE}-unknown-dragonfly`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` exit ;; *:*VMS:*:*) - UNAME_MACHINE=`(uname -p) 2>/dev/null` + UNAME_MACHINE=`(uname -p) 2>/dev/null` case "${UNAME_MACHINE}" in A*) echo alpha-dec-vms ; exit ;; I*) echo ia64-dec-vms ; exit ;; @@ -1333,11 +1296,11 @@ i*86:AROS:*:*) echo ${UNAME_MACHINE}-pc-aros exit ;; - x86_64:VMkernel:*:*) - echo ${UNAME_MACHINE}-unknown-esx - exit ;; esac +#echo '(No uname command or uname output not recognized.)' 1>&2 +#echo "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" 1>&2 + eval $set_cc_for_build cat >$dummy.c < printf ("m68k-sony-newsos%s\n", #ifdef NEWSOS4 - "4" + "4" #else - "" + "" #endif - ); exit (0); + ); exit (0); #endif #endif diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi/config.sub --- a/Modules/_ctypes/libffi/config.sub Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/_ctypes/libffi/config.sub Sun Jul 20 10:52:46 2014 -0400 @@ -1,33 +1,38 @@ #! /bin/sh # Configuration validation subroutine script. # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, -# 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, -# 2011, 2012, 2013 Free Software Foundation, Inc. +# 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 +# Free Software Foundation, Inc. -timestamp='2012-12-29' +timestamp='2009-11-07' -# This file is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3 of the License, or +# This file is (in principle) common to ALL GNU software. +# The presence of a machine in this file suggests that SOME GNU software +# can handle that machine. It does not imply ALL GNU software can. +# +# This file is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. # # You should have received a copy of the GNU General Public License -# along with this program; if not, see . +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA +# 02110-1301, USA. # # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under -# the same distribution terms that you use for the rest of that -# program. This Exception is an additional permission under section 7 -# of the GNU General Public License, version 3 ("GPLv3"). +# the same distribution terms that you use for the rest of that program. -# Please send patches with a ChangeLog entry to config-patches@gnu.org. +# Please send patches to . Submit a context +# diff and a properly formatted GNU ChangeLog entry. # # Configuration subroutine to validate and canonicalize a configuration type. # Supply the specified configuration type as an argument. @@ -70,9 +75,8 @@ version="\ GNU config.sub ($timestamp) -Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, -2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, -2012, 2013 Free Software Foundation, Inc. +Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, +2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." @@ -119,18 +123,13 @@ # Here we must recognize all the valid KERNEL-OS combinations. maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'` case $maybe_os in - nto-qnx* | linux-gnu* | linux-android* | linux-dietlibc | linux-newlib* | \ - linux-musl* | linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | \ - knetbsd*-gnu* | netbsd*-gnu* | \ + nto-qnx* | linux-gnu* | linux-dietlibc | linux-newlib* | linux-uclibc* | \ + uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | knetbsd*-gnu* | netbsd*-gnu* | \ kopensolaris*-gnu* | \ storm-chaos* | os2-emx* | rtmk-nova*) os=-$maybe_os basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'` ;; - android-linux) - os=-linux-android - basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`-unknown - ;; *) basic_machine=`echo $1 | sed 's/-[^-]*$//'` if [ $basic_machine != $1 ] @@ -153,12 +152,12 @@ -convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\ -c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \ -harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \ - -apple | -axis | -knuth | -cray | -microblaze*) + -apple | -axis | -knuth | -cray | -microblaze) os= basic_machine=$1 ;; - -bluegene*) - os=-cnk + -bluegene*) + os=-cnk ;; -sim | -cisco | -oki | -wec | -winbond) os= @@ -174,10 +173,10 @@ os=-chorusos basic_machine=$1 ;; - -chorusrdb) - os=-chorusrdb + -chorusrdb) + os=-chorusrdb basic_machine=$1 - ;; + ;; -hiux*) os=-hiuxwe2 ;; @@ -222,12 +221,6 @@ -isc*) basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; - -lynx*178) - os=-lynxos178 - ;; - -lynx*5) - os=-lynxos5 - ;; -lynx*) os=-lynxos ;; @@ -252,27 +245,20 @@ # Some are omitted here because they have special meanings below. 1750a | 580 \ | a29k \ - | aarch64 | aarch64_be \ | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \ | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \ | am33_2.0 \ - | arc \ - | arm | arm[bl]e | arme[lb] | armv[2-8] | armv[3-8][lb] | armv7[arm] \ - | avr | avr32 \ - | be32 | be64 \ + | arc | arm | arm[bl]e | arme[lb] | armv[2345] | armv[345][lb] | avr | avr32 \ | bfin \ | c4x | clipper \ | d10v | d30v | dlx | dsp16xx \ - | epiphany \ | fido | fr30 | frv \ | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \ - | hexagon \ | i370 | i860 | i960 | ia64 \ | ip2k | iq2000 \ - | le32 | le64 \ | lm32 \ | m32c | m32r | m32rle | m68000 | m68k | m88k \ - | maxq | mb | microblaze | microblazeel | mcore | mep | metag \ + | maxq | mb | microblaze | mcore | mep | metag \ | mips | mipsbe | mipseb | mipsel | mipsle \ | mips16 \ | mips64 | mips64el \ @@ -295,39 +281,29 @@ | moxie \ | mt \ | msp430 \ - | nds32 | nds32le | nds32be \ | nios | nios2 \ | ns16k | ns32k \ - | open8 \ | or32 \ | pdp10 | pdp11 | pj | pjl \ - | powerpc | powerpc64 | powerpc64le | powerpcle \ + | powerpc | powerpc64 | powerpc64le | powerpcle | ppcbe \ | pyramid \ - | rl78 | rx \ + | rx \ | score \ | sh | sh[1234] | sh[24]a | sh[24]aeb | sh[23]e | sh[34]eb | sheb | shbe | shle | sh[1234]le | sh3ele \ | sh64 | sh64le \ | sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet | sparclite \ | sparcv8 | sparcv9 | sparcv9b | sparcv9v \ - | spu \ - | tahoe | tic4x | tic54x | tic55x | tic6x | tic80 | tron \ + | spu | strongarm \ + | tahoe | thumb | tic4x | tic80 | tron \ | ubicom32 \ - | v850 | v850e | v850e1 | v850e2 | v850es | v850e2v3 \ + | v850 | v850e \ | we32k \ - | x86 | xc16x | xstormy16 | xtensa \ + | x86 | xc16x | xscale | xscalee[bl] | xstormy16 | xtensa \ | z8k | z80) basic_machine=$basic_machine-unknown ;; - c54x) - basic_machine=tic54x-unknown - ;; - c55x) - basic_machine=tic55x-unknown - ;; - c6x) - basic_machine=tic6x-unknown - ;; - m6811 | m68hc11 | m6812 | m68hc12 | m68hcs12x | picochip) + m6811 | m68hc11 | m6812 | m68hc12 | picochip) + # Motorola 68HC11/12. basic_machine=$basic_machine-unknown os=-none ;; @@ -337,21 +313,6 @@ basic_machine=mt-unknown ;; - strongarm | thumb | xscale) - basic_machine=arm-unknown - ;; - xgate) - basic_machine=$basic_machine-unknown - os=-none - ;; - xscaleeb) - basic_machine=armeb-unknown - ;; - - xscaleel) - basic_machine=armel-unknown - ;; - # We use `pc' rather than `unknown' # because (1) that's what they normally are, and # (2) the word "unknown" tends to confuse beginning users. @@ -366,30 +327,25 @@ # Recognize the basic CPU types with company name. 580-* \ | a29k-* \ - | aarch64-* | aarch64_be-* \ | alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \ | alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \ | alphapca5[67]-* | alpha64pca5[67]-* | arc-* \ | arm-* | armbe-* | armle-* | armeb-* | armv*-* \ | avr-* | avr32-* \ - | be32-* | be64-* \ | bfin-* | bs2000-* \ - | c[123]* | c30-* | [cjt]90-* | c4x-* \ + | c[123]* | c30-* | [cjt]90-* | c4x-* | c54x-* | c55x-* | c6x-* \ | clipper-* | craynv-* | cydra-* \ | d10v-* | d30v-* | dlx-* \ | elxsi-* \ | f30[01]-* | f700-* | fido-* | fr30-* | frv-* | fx80-* \ | h8300-* | h8500-* \ | hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \ - | hexagon-* \ | i*86-* | i860-* | i960-* | ia64-* \ | ip2k-* | iq2000-* \ - | le32-* | le64-* \ | lm32-* \ | m32c-* | m32r-* | m32rle-* \ | m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \ - | m88110-* | m88k-* | maxq-* | mcore-* | metag-* \ - | microblaze-* | microblazeel-* \ + | m88110-* | m88k-* | maxq-* | mcore-* | metag-* | microblaze-* \ | mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \ | mips16-* \ | mips64-* | mips64el-* \ @@ -411,29 +367,25 @@ | mmix-* \ | mt-* \ | msp430-* \ - | nds32-* | nds32le-* | nds32be-* \ | nios-* | nios2-* \ | none-* | np1-* | ns16k-* | ns32k-* \ - | open8-* \ | orion-* \ | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \ - | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* \ + | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* | ppcbe-* \ | pyramid-* \ - | rl78-* | romp-* | rs6000-* | rx-* \ + | romp-* | rs6000-* | rx-* \ | sh-* | sh[1234]-* | sh[24]a-* | sh[24]aeb-* | sh[23]e-* | sh[34]eb-* | sheb-* | shbe-* \ | shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \ | sparc-* | sparc64-* | sparc64b-* | sparc64v-* | sparc86x-* | sparclet-* \ | sparclite-* \ - | sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | sv1-* | sx?-* \ - | tahoe-* \ - | tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \ - | tile*-* \ + | sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | strongarm-* | sv1-* | sx?-* \ + | tahoe-* | thumb-* \ + | tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* | tile-* \ | tron-* \ | ubicom32-* \ - | v850-* | v850e-* | v850e1-* | v850es-* | v850e2-* | v850e2v3-* \ - | vax-* \ + | v850-* | v850e-* | vax-* \ | we32k-* \ - | x86-* | x86_64-* | xc16x-* | xps100-* \ + | x86-* | x86_64-* | xc16x-* | xps100-* | xscale-* | xscalee[bl]-* \ | xstormy16-* | xtensa*-* \ | ymp-* \ | z8k-* | z80-*) @@ -458,7 +410,7 @@ basic_machine=a29k-amd os=-udi ;; - abacus) + abacus) basic_machine=abacus-unknown ;; adobe68k) @@ -528,20 +480,11 @@ basic_machine=powerpc-ibm os=-cnk ;; - c54x-*) - basic_machine=tic54x-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - c55x-*) - basic_machine=tic55x-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - c6x-*) - basic_machine=tic6x-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; c90) basic_machine=c90-cray os=-unicos ;; - cegcc) + cegcc) basic_machine=arm-unknown os=-cegcc ;; @@ -573,7 +516,7 @@ basic_machine=craynv-cray os=-unicosmp ;; - cr16 | cr16-*) + cr16) basic_machine=cr16-unknown os=-elf ;; @@ -731,6 +674,7 @@ i370-ibm* | ibm*) basic_machine=i370-ibm ;; +# I'm not sure what "Sysv32" means. Should this be sysv3.2? i*86v32) basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` os=-sysv32 @@ -788,13 +732,9 @@ basic_machine=ns32k-utek os=-sysv ;; - microblaze*) + microblaze) basic_machine=microblaze-xilinx ;; - mingw64) - basic_machine=x86_64-pc - os=-mingw64 - ;; mingw32) basic_machine=i386-pc os=-mingw32 @@ -831,18 +771,10 @@ ms1-*) basic_machine=`echo $basic_machine | sed -e 's/ms1-/mt-/'` ;; - msys) - basic_machine=i386-pc - os=-msys - ;; mvs) basic_machine=i370-ibm os=-mvs ;; - nacl) - basic_machine=le32-unknown - os=-nacl - ;; ncr3000) basic_machine=i486-ncr os=-sysv4 @@ -907,12 +839,6 @@ np1) basic_machine=np1-gould ;; - neo-tandem) - basic_machine=neo-tandem - ;; - nse-tandem) - basic_machine=nse-tandem - ;; nsr-tandem) basic_machine=nsr-tandem ;; @@ -995,10 +921,9 @@ ;; power) basic_machine=power-ibm ;; - ppc | ppcbe) basic_machine=powerpc-unknown + ppc) basic_machine=powerpc-unknown ;; - ppc-* | ppcbe-*) - basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'` + ppc-*) basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'` ;; ppcle | powerpclittle | ppc-le | powerpc-little) basic_machine=powerpcle-unknown @@ -1023,11 +948,7 @@ basic_machine=i586-unknown os=-pw32 ;; - rdos | rdos64) - basic_machine=x86_64-pc - os=-rdos - ;; - rdos32) + rdos) basic_machine=i386-pc os=-rdos ;; @@ -1096,9 +1017,6 @@ basic_machine=i860-stratus os=-sysv4 ;; - strongarm-* | thumb-*) - basic_machine=arm-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; sun2) basic_machine=m68000-sun ;; @@ -1155,8 +1073,20 @@ basic_machine=t90-cray os=-unicos ;; + tic54x | c54x*) + basic_machine=tic54x-unknown + os=-coff + ;; + tic55x | c55x*) + basic_machine=tic55x-unknown + os=-coff + ;; + tic6x | c6x*) + basic_machine=tic6x-unknown + os=-coff + ;; tile*) - basic_machine=$basic_machine-unknown + basic_machine=tile-unknown os=-linux-gnu ;; tx39) @@ -1226,9 +1156,6 @@ xps | xps100) basic_machine=xps100-honeywell ;; - xscale-* | xscalee[bl]-*) - basic_machine=`echo $basic_machine | sed 's/^xscale/arm/'` - ;; ymp) basic_machine=ymp-cray os=-unicos @@ -1326,12 +1253,9 @@ if [ x"$os" != x"" ] then case $os in - # First match some system type aliases - # that might get confused with valid system types. + # First match some system type aliases + # that might get confused with valid system types. # -solaris* is a basic system type, with this one exception. - -auroraux) - os=-auroraux - ;; -solaris1 | -solaris1.*) os=`echo $os | sed -e 's|solaris1|sunos4|'` ;; @@ -1353,22 +1277,21 @@ # -sysv* is not here because it comes later, after sysvr4. -gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \ | -*vms* | -sco* | -esix* | -isc* | -aix* | -cnk* | -sunos | -sunos[34]*\ - | -hpux* | -unos* | -osf* | -luna* | -dgux* | -auroraux* | -solaris* \ - | -sym* | -kopensolaris* \ + | -hpux* | -unos* | -osf* | -luna* | -dgux* | -solaris* | -sym* \ + | -kopensolaris* \ | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \ | -aos* | -aros* \ | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \ - | -bitrig* | -openbsd* | -solidbsd* \ + | -openbsd* | -solidbsd* \ | -ekkobsd* | -kfreebsd* | -freebsd* | -riscix* | -lynxos* \ | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \ | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \ | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \ | -chorusos* | -chorusrdb* | -cegcc* \ - | -cygwin* | -msys* | -pe* | -psos* | -moss* | -proelf* | -rtems* \ - | -mingw32* | -mingw64* | -linux-gnu* | -linux-android* \ - | -linux-newlib* | -linux-musl* | -linux-uclibc* \ + | -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \ + | -mingw32* | -linux-gnu* | -linux-newlib* | -linux-uclibc* \ | -uxpv* | -beos* | -mpeix* | -udk* \ | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \ | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \ @@ -1415,7 +1338,7 @@ -opened*) os=-openedition ;; - -os400*) + -os400*) os=-os400 ;; -wince*) @@ -1464,7 +1387,7 @@ -sinix*) os=-sysv4 ;; - -tpf*) + -tpf*) os=-tpf ;; -triton*) @@ -1509,8 +1432,6 @@ -dicos*) os=-dicos ;; - -nacl*) - ;; -none) ;; *) @@ -1533,10 +1454,10 @@ # system, and we'll never get to this point. case $basic_machine in - score-*) + score-*) os=-elf ;; - spu-*) + spu-*) os=-elf ;; *-acorn) @@ -1548,20 +1469,8 @@ arm*-semi) os=-aout ;; - c4x-* | tic4x-*) - os=-coff - ;; - hexagon-*) - os=-elf - ;; - tic54x-*) - os=-coff - ;; - tic55x-*) - os=-coff - ;; - tic6x-*) - os=-coff + c4x-* | tic4x-*) + os=-coff ;; # This must come before the *-dec entry. pdp10-*) @@ -1581,11 +1490,14 @@ ;; m68000-sun) os=-sunos3 + # This also exists in the configure program, but was not the + # default. + # os=-sunos4 ;; m68*-cisco) os=-aout ;; - mep-*) + mep-*) os=-elf ;; mips*-cisco) @@ -1612,7 +1524,7 @@ *-ibm) os=-aix ;; - *-knuth) + *-knuth) os=-mmixware ;; *-wec) diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi/configure --- a/Modules/_ctypes/libffi/configure Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/_ctypes/libffi/configure Sun Jul 20 10:52:46 2014 -0400 @@ -1,11 +1,13 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.69 for libffi 3.0.13. +# Generated by GNU Autoconf 2.65 for libffi 3.0.10rc0. # -# Report bugs to . +# Report bugs to . # # -# Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc. +# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, +# 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, +# Inc. # # # This configure script is free software; the Free Software Foundation @@ -89,7 +91,6 @@ IFS=" "" $as_nl" # Find who we are. Look in the path if we contain no directory separator. -as_myself= case $0 in #(( *[\\/]* ) as_myself=$0 ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR @@ -134,31 +135,6 @@ # CDPATH. (unset CDPATH) >/dev/null 2>&1 && unset CDPATH -# Use a proper internal environment variable to ensure we don't fall - # into an infinite loop, continuously re-executing ourselves. - if test x"${_as_can_reexec}" != xno && test "x$CONFIG_SHELL" != x; then - _as_can_reexec=no; export _as_can_reexec; - # We cannot yet assume a decent shell, so we have to provide a -# neutralization value for shells without unset; and this also -# works around shells that cannot unset nonexistent variables. -# Preserve -v and -x to the replacement shell. -BASH_ENV=/dev/null -ENV=/dev/null -(unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV -case $- in # (((( - *v*x* | *x*v* ) as_opts=-vx ;; - *v* ) as_opts=-v ;; - *x* ) as_opts=-x ;; - * ) as_opts= ;; -esac -exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"} -# Admittedly, this is quite paranoid, since all the known shells bail -# out after a failed `exec'. -$as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2 -as_fn_exit 255 - fi - # We don't want this to propagate to other subprocesses. - { _as_can_reexec=; unset _as_can_reexec;} if test "x$CONFIG_SHELL" = x; then as_bourne_compatible="if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then : emulate sh @@ -192,20 +168,11 @@ else exitcode=1; echo positional parameters were not saved. fi -test x\$exitcode = x0 || exit 1 -test -x / || exit 1" +test x\$exitcode = x0 || exit 1" as_suggested=" as_lineno_1=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_1a=\$LINENO as_lineno_2=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_2a=\$LINENO eval 'test \"x\$as_lineno_1'\$as_run'\" != \"x\$as_lineno_2'\$as_run'\" && test \"x\`expr \$as_lineno_1'\$as_run' + 1\`\" = \"x\$as_lineno_2'\$as_run'\"' || exit 1 - - test -n \"\${ZSH_VERSION+set}\${BASH_VERSION+set}\" || ( - ECHO='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' - ECHO=\$ECHO\$ECHO\$ECHO\$ECHO\$ECHO - ECHO=\$ECHO\$ECHO\$ECHO\$ECHO\$ECHO\$ECHO - PATH=/empty FPATH=/empty; export PATH FPATH - test \"X\`printf %s \$ECHO\`\" = \"X\$ECHO\" \\ - || test \"X\`print -r -- \$ECHO\`\" = \"X\$ECHO\" ) || exit 1 test \$(( 1 + 1 )) = 2 || exit 1" if (eval "$as_required") 2>/dev/null; then : as_have_required=yes @@ -246,25 +213,14 @@ if test "x$CONFIG_SHELL" != x; then : - export CONFIG_SHELL - # We cannot yet assume a decent shell, so we have to provide a -# neutralization value for shells without unset; and this also -# works around shells that cannot unset nonexistent variables. -# Preserve -v and -x to the replacement shell. -BASH_ENV=/dev/null -ENV=/dev/null -(unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV -case $- in # (((( - *v*x* | *x*v* ) as_opts=-vx ;; - *v* ) as_opts=-v ;; - *x* ) as_opts=-x ;; - * ) as_opts= ;; -esac -exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"} -# Admittedly, this is quite paranoid, since all the known shells bail -# out after a failed `exec'. -$as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2 -exit 255 + # We cannot yet assume a decent shell, so we have to provide a + # neutralization value for shells without unset; and this also + # works around shells that cannot unset nonexistent variables. + BASH_ENV=/dev/null + ENV=/dev/null + (unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV + export CONFIG_SHELL + exec "$CONFIG_SHELL" "$as_myself" ${1+"$@"} fi if test x$as_have_required = xno; then : @@ -275,8 +231,8 @@ $as_echo "$0: be upgraded to zsh 4.3.4 or later." else $as_echo "$0: Please tell bug-autoconf@gnu.org and -$0: http://github.com/atgreen/libffi/issues about your -$0: system, including any error possibly output before this +$0: http://gcc.gnu.org/bugs.html about your system, +$0: including any error possibly output before this $0: message. Then install a modern shell, or manually run $0: the script under such a shell if you do have one." fi @@ -363,18 +319,10 @@ test -d "$as_dir" && break done test -z "$as_dirs" || eval "mkdir $as_dirs" - } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir" + } || test -d "$as_dir" || as_fn_error "cannot create directory $as_dir" } # as_fn_mkdir_p - -# as_fn_executable_p FILE -# ----------------------- -# Test if FILE is an executable regular file. -as_fn_executable_p () -{ - test -f "$1" && test -x "$1" -} # as_fn_executable_p # as_fn_append VAR VALUE # ---------------------- # Append the text in VALUE to the end of the definition contained in VAR. Take @@ -411,19 +359,19 @@ fi # as_fn_arith -# as_fn_error STATUS ERROR [LINENO LOG_FD] -# ---------------------------------------- +# as_fn_error ERROR [LINENO LOG_FD] +# --------------------------------- # Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are # provided, also output the error to LOG_FD, referencing LINENO. Then exit the -# script with STATUS, using 1 if that was 0. +# script with status $?, using 1 if that was 0. as_fn_error () { - as_status=$1; test $as_status -eq 0 && as_status=1 - if test "$4"; then - as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4 - fi - $as_echo "$as_me: error: $2" >&2 + as_status=$?; test $as_status -eq 0 && as_status=1 + if test "$3"; then + as_lineno=${as_lineno-"$2"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + $as_echo "$as_me:${as_lineno-$LINENO}: error: $1" >&$3 + fi + $as_echo "$as_me: error: $1" >&2 as_fn_exit $as_status } # as_fn_error @@ -496,10 +444,6 @@ chmod +x "$as_me.lineno" || { $as_echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2; as_fn_exit 1; } - # If we had to re-execute with $CONFIG_SHELL, we're ensured to have - # already done that, so ensure we don't try to do so again and fall - # in an infinite loop. This has already happened in practice. - _as_can_reexec=no; export _as_can_reexec # Don't try to exec as it changes $[0], causing all sort of problems # (the dirname of $[0] is not the place where we might find the # original and so on. Autoconf is especially sensitive to this). @@ -534,16 +478,16 @@ # ... but there are two gotchas: # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. - # In both cases, we have to default to `cp -pR'. + # In both cases, we have to default to `cp -p'. ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || - as_ln_s='cp -pR' + as_ln_s='cp -p' elif ln conf$$.file conf$$ 2>/dev/null; then as_ln_s=ln else - as_ln_s='cp -pR' - fi -else - as_ln_s='cp -pR' + as_ln_s='cp -p' + fi +else + as_ln_s='cp -p' fi rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file rmdir conf$$.dir 2>/dev/null @@ -555,8 +499,28 @@ as_mkdir_p=false fi -as_test_x='test -x' -as_executable_p=as_fn_executable_p +if test -x / >/dev/null 2>&1; then + as_test_x='test -x' +else + if ls -dL / >/dev/null 2>&1; then + as_ls_L_option=L + else + as_ls_L_option= + fi + as_test_x=' + eval sh -c '\'' + if test -d "$1"; then + test -d "$1/."; + else + case $1 in #( + -*)set "./$1";; + esac; + case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in #(( + ???[sx]*):;;*)false;;esac;fi + '\'' sh + ' +fi +as_executable_p=$as_test_x # Sed expression to map a string onto a valid CPP name. as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" @@ -564,14 +528,161 @@ # Sed expression to map a string onto a valid variable name. as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" + + +# Check that we are running under the correct shell. SHELL=${CONFIG_SHELL-/bin/sh} +case X$lt_ECHO in +X*--fallback-echo) + # Remove one level of quotation (which was required for Make). + ECHO=`echo "$lt_ECHO" | sed 's,\\\\\$\\$0,'$0','` + ;; +esac + +ECHO=${lt_ECHO-echo} +if test "X$1" = X--no-reexec; then + # Discard the --no-reexec flag, and continue. + shift +elif test "X$1" = X--fallback-echo; then + # Avoid inline document here, it may be left over + : +elif test "X`{ $ECHO '\t'; } 2>/dev/null`" = 'X\t' ; then + # Yippee, $ECHO works! + : +else + # Restart under the correct shell. + exec $SHELL "$0" --no-reexec ${1+"$@"} +fi + +if test "X$1" = X--fallback-echo; then + # used as fallback echo + shift + cat <<_LT_EOF +$* +_LT_EOF + exit 0 +fi + +# The HP-UX ksh and POSIX shell print the target directory to stdout +# if CDPATH is set. +(unset CDPATH) >/dev/null 2>&1 && unset CDPATH + +if test -z "$lt_ECHO"; then + if test "X${echo_test_string+set}" != Xset; then + # find a string as large as possible, as long as the shell can cope with it + for cmd in 'sed 50q "$0"' 'sed 20q "$0"' 'sed 10q "$0"' 'sed 2q "$0"' 'echo test'; do + # expected sizes: less than 2Kb, 1Kb, 512 bytes, 16 bytes, ... + if { echo_test_string=`eval $cmd`; } 2>/dev/null && + { test "X$echo_test_string" = "X$echo_test_string"; } 2>/dev/null + then + break + fi + done + fi + + if test "X`{ $ECHO '\t'; } 2>/dev/null`" = 'X\t' && + echo_testing_string=`{ $ECHO "$echo_test_string"; } 2>/dev/null` && + test "X$echo_testing_string" = "X$echo_test_string"; then + : + else + # The Solaris, AIX, and Digital Unix default echo programs unquote + # backslashes. This makes it impossible to quote backslashes using + # echo "$something" | sed 's/\\/\\\\/g' + # + # So, first we look for a working echo in the user's PATH. + + lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR + for dir in $PATH /usr/ucb; do + IFS="$lt_save_ifs" + if (test -f $dir/echo || test -f $dir/echo$ac_exeext) && + test "X`($dir/echo '\t') 2>/dev/null`" = 'X\t' && + echo_testing_string=`($dir/echo "$echo_test_string") 2>/dev/null` && + test "X$echo_testing_string" = "X$echo_test_string"; then + ECHO="$dir/echo" + break + fi + done + IFS="$lt_save_ifs" + + if test "X$ECHO" = Xecho; then + # We didn't find a better echo, so look for alternatives. + if test "X`{ print -r '\t'; } 2>/dev/null`" = 'X\t' && + echo_testing_string=`{ print -r "$echo_test_string"; } 2>/dev/null` && + test "X$echo_testing_string" = "X$echo_test_string"; then + # This shell has a builtin print -r that does the trick. + ECHO='print -r' + elif { test -f /bin/ksh || test -f /bin/ksh$ac_exeext; } && + test "X$CONFIG_SHELL" != X/bin/ksh; then + # If we have ksh, try running configure again with it. + ORIGINAL_CONFIG_SHELL=${CONFIG_SHELL-/bin/sh} + export ORIGINAL_CONFIG_SHELL + CONFIG_SHELL=/bin/ksh + export CONFIG_SHELL + exec $CONFIG_SHELL "$0" --no-reexec ${1+"$@"} + else + # Try using printf. + ECHO='printf %s\n' + if test "X`{ $ECHO '\t'; } 2>/dev/null`" = 'X\t' && + echo_testing_string=`{ $ECHO "$echo_test_string"; } 2>/dev/null` && + test "X$echo_testing_string" = "X$echo_test_string"; then + # Cool, printf works + : + elif echo_testing_string=`($ORIGINAL_CONFIG_SHELL "$0" --fallback-echo '\t') 2>/dev/null` && + test "X$echo_testing_string" = 'X\t' && + echo_testing_string=`($ORIGINAL_CONFIG_SHELL "$0" --fallback-echo "$echo_test_string") 2>/dev/null` && + test "X$echo_testing_string" = "X$echo_test_string"; then + CONFIG_SHELL=$ORIGINAL_CONFIG_SHELL + export CONFIG_SHELL + SHELL="$CONFIG_SHELL" + export SHELL + ECHO="$CONFIG_SHELL $0 --fallback-echo" + elif echo_testing_string=`($CONFIG_SHELL "$0" --fallback-echo '\t') 2>/dev/null` && + test "X$echo_testing_string" = 'X\t' && + echo_testing_string=`($CONFIG_SHELL "$0" --fallback-echo "$echo_test_string") 2>/dev/null` && + test "X$echo_testing_string" = "X$echo_test_string"; then + ECHO="$CONFIG_SHELL $0 --fallback-echo" + else + # maybe with a smaller string... + prev=: + + for cmd in 'echo test' 'sed 2q "$0"' 'sed 10q "$0"' 'sed 20q "$0"' 'sed 50q "$0"'; do + if { test "X$echo_test_string" = "X`eval $cmd`"; } 2>/dev/null + then + break + fi + prev="$cmd" + done + + if test "$prev" != 'sed 50q "$0"'; then + echo_test_string=`eval $prev` + export echo_test_string + exec ${ORIGINAL_CONFIG_SHELL-${CONFIG_SHELL-/bin/sh}} "$0" ${1+"$@"} + else + # Oops. We lost completely, so just stick with echo. + ECHO=echo + fi + fi + fi + fi + fi +fi + +# Copy echo and quote the copy suitably for passing to libtool from +# the Makefile, instead of quoting the original, which is used later. +lt_ECHO=$ECHO +if test "X$lt_ECHO" = "X$CONFIG_SHELL $0 --fallback-echo"; then + lt_ECHO="$CONFIG_SHELL \\\$\$0 --fallback-echo" +fi + + + test -n "$DJDIR" || exec 7<&0 &1 # Name of the host. -# hostname on some systems (SVR3.2, old GNU/Linux) returns a bogus exit status, +# hostname on some systems (SVR3.2, Linux) returns a bogus exit status, # so uname gets run too. ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q` @@ -590,9 +701,9 @@ # Identity of this package. PACKAGE_NAME='libffi' PACKAGE_TARNAME='libffi' -PACKAGE_VERSION='3.0.13' -PACKAGE_STRING='libffi 3.0.13' -PACKAGE_BUGREPORT='http://github.com/atgreen/libffi/issues' +PACKAGE_VERSION='3.0.10rc0' +PACKAGE_STRING='libffi 3.0.10rc0' +PACKAGE_BUGREPORT='http://gcc.gnu.org/bugs.html' PACKAGE_URL='' # Factoring default headers for most tests. @@ -637,20 +748,10 @@ LIBOBJS toolexeclibdir toolexecdir -FFI_DEBUG_FALSE -FFI_DEBUG_TRUE TARGETDIR TARGET -FFI_EXEC_TRAMPOLINE_TABLE -FFI_EXEC_TRAMPOLINE_TABLE_FALSE -FFI_EXEC_TRAMPOLINE_TABLE_TRUE -sys_symbol_underscore HAVE_LONG_DOUBLE ALLOCA -XTENSA_FALSE -XTENSA_TRUE -TILE_FALSE -TILE_TRUE PA64_HPUX_FALSE PA64_HPUX_TRUE PA_HPUX_FALSE @@ -673,8 +774,6 @@ AVR32_TRUE ARM_FALSE ARM_TRUE -AARCH64_FALSE -AARCH64_TRUE POWERPC_FREEBSD_FALSE POWERPC_FREEBSD_TRUE POWERPC_DARWIN_FALSE @@ -683,12 +782,6 @@ POWERPC_AIX_TRUE POWERPC_FALSE POWERPC_TRUE -MOXIE_FALSE -MOXIE_TRUE -METAG_FALSE -METAG_TRUE -MICROBLAZE_FALSE -MICROBLAZE_TRUE M68K_FALSE M68K_TRUE M32R_FALSE @@ -709,8 +802,6 @@ X86_TRUE SPARC_FALSE SPARC_TRUE -BFIN_FALSE -BFIN_TRUE MIPS_FALSE MIPS_TRUE AM_LTLDFLAGS @@ -720,18 +811,15 @@ MAINT MAINTAINER_MODE_FALSE MAINTAINER_MODE_TRUE -PRTDIAG CPP OTOOL64 OTOOL LIPO NMEDIT DSYMUTIL -MANIFEST_TOOL +lt_ECHO RANLIB -ac_ct_AR AR -DLLTOOL OBJDUMP LN_S NM @@ -751,7 +839,6 @@ am__fastdepCC_FALSE am__fastdepCC_TRUE CCDEPMODE -am__nodep AMDEPBACKSLASH AMDEP_FALSE AMDEP_TRUE @@ -788,7 +875,6 @@ INSTALL_DATA INSTALL_SCRIPT INSTALL_PROGRAM -ax_enable_builddir_sed target_os target_vendor target_cpu @@ -842,19 +928,14 @@ ac_subst_files='' ac_user_opts=' enable_option_checking -enable_builddir enable_dependency_tracking enable_shared enable_static with_pic enable_fast_install with_gnu_ld -with_sysroot enable_libtool_lock -enable_portable_binary -with_gcc_arch enable_maintainer_mode -enable_pax_emutramp enable_debug enable_structs enable_raw_api @@ -929,9 +1010,8 @@ fi case $ac_option in - *=?*) ac_optarg=`expr "X$ac_option" : '[^=]*=\(.*\)'` ;; - *=) ac_optarg= ;; - *) ac_optarg=yes ;; + *=*) ac_optarg=`expr "X$ac_option" : '[^=]*=\(.*\)'` ;; + *) ac_optarg=yes ;; esac # Accept the important Cygnus configure options, so we can diagnose typos. @@ -976,7 +1056,7 @@ ac_useropt=`expr "x$ac_option" : 'x-*disable-\(.*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && - as_fn_error $? "invalid feature name: $ac_useropt" + as_fn_error "invalid feature name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in @@ -1002,7 +1082,7 @@ ac_useropt=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && - as_fn_error $? "invalid feature name: $ac_useropt" + as_fn_error "invalid feature name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in @@ -1206,7 +1286,7 @@ ac_useropt=`expr "x$ac_option" : 'x-*with-\([^=]*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && - as_fn_error $? "invalid package name: $ac_useropt" + as_fn_error "invalid package name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in @@ -1222,7 +1302,7 @@ ac_useropt=`expr "x$ac_option" : 'x-*without-\(.*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && - as_fn_error $? "invalid package name: $ac_useropt" + as_fn_error "invalid package name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in @@ -1252,8 +1332,8 @@ | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*) x_libraries=$ac_optarg ;; - -*) as_fn_error $? "unrecognized option: \`$ac_option' -Try \`$0 --help' for more information" + -*) as_fn_error "unrecognized option: \`$ac_option' +Try \`$0 --help' for more information." ;; *=*) @@ -1261,7 +1341,7 @@ # Reject names that are not valid shell variable names. case $ac_envvar in #( '' | [0-9]* | *[!_$as_cr_alnum]* ) - as_fn_error $? "invalid variable name: \`$ac_envvar'" ;; + as_fn_error "invalid variable name: \`$ac_envvar'" ;; esac eval $ac_envvar=\$ac_optarg export $ac_envvar ;; @@ -1271,7 +1351,7 @@ $as_echo "$as_me: WARNING: you should use --build, --host, --target" >&2 expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null && $as_echo "$as_me: WARNING: invalid host type: $ac_option" >&2 - : "${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option}" + : ${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option} ;; esac @@ -1279,13 +1359,13 @@ if test -n "$ac_prev"; then ac_option=--`echo $ac_prev | sed 's/_/-/g'` - as_fn_error $? "missing argument to $ac_option" + as_fn_error "missing argument to $ac_option" fi if test -n "$ac_unrecognized_opts"; then case $enable_option_checking in no) ;; - fatal) as_fn_error $? "unrecognized options: $ac_unrecognized_opts" ;; + fatal) as_fn_error "unrecognized options: $ac_unrecognized_opts" ;; *) $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2 ;; esac fi @@ -1308,7 +1388,7 @@ [\\/$]* | ?:[\\/]* ) continue;; NONE | '' ) case $ac_var in *prefix ) continue;; esac;; esac - as_fn_error $? "expected an absolute directory name for --$ac_var: $ac_val" + as_fn_error "expected an absolute directory name for --$ac_var: $ac_val" done # There might be people who depend on the old broken behavior: `$host' @@ -1322,6 +1402,8 @@ if test "x$host_alias" != x; then if test "x$build_alias" = x; then cross_compiling=maybe + $as_echo "$as_me: WARNING: If you wanted to set the --build type, don't use --host. + If a cross compiler is detected then cross compile mode will be used." >&2 elif test "x$build_alias" != "x$host_alias"; then cross_compiling=yes fi @@ -1336,9 +1418,9 @@ ac_pwd=`pwd` && test -n "$ac_pwd" && ac_ls_di=`ls -di .` && ac_pwd_ls_di=`cd "$ac_pwd" && ls -di .` || - as_fn_error $? "working directory cannot be determined" + as_fn_error "working directory cannot be determined" test "X$ac_ls_di" = "X$ac_pwd_ls_di" || - as_fn_error $? "pwd does not report name of working directory" + as_fn_error "pwd does not report name of working directory" # Find the source files, if location was not specified. @@ -1377,11 +1459,11 @@ fi if test ! -r "$srcdir/$ac_unique_file"; then test "$ac_srcdir_defaulted" = yes && srcdir="$ac_confdir or .." - as_fn_error $? "cannot find sources ($ac_unique_file) in $srcdir" + as_fn_error "cannot find sources ($ac_unique_file) in $srcdir" fi ac_msg="sources are in $srcdir, but \`cd $srcdir' does not work" ac_abs_confdir=`( - cd "$srcdir" && test -r "./$ac_unique_file" || as_fn_error $? "$ac_msg" + cd "$srcdir" && test -r "./$ac_unique_file" || as_fn_error "$ac_msg" pwd)` # When building in place, set srcdir=. if test "$ac_abs_confdir" = "$ac_pwd"; then @@ -1407,7 +1489,7 @@ # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures libffi 3.0.13 to adapt to many kinds of systems. +\`configure' configures libffi 3.0.10rc0 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1421,7 +1503,7 @@ --help=short display options specific to this package --help=recursive display the short help of all the included packages -V, --version display version information and exit - -q, --quiet, --silent do not print \`checking ...' messages + -q, --quiet, --silent do not print \`checking...' messages --cache-file=FILE cache test results in FILE [disabled] -C, --config-cache alias for \`--cache-file=config.cache' -n, --no-create do not create output files @@ -1478,7 +1560,7 @@ if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of libffi 3.0.13:";; + short | recursive ) echo "Configuration of libffi 3.0.10rc0:";; esac cat <<\_ACEOF @@ -1486,24 +1568,15 @@ --disable-option-checking ignore unrecognized --enable/--with options --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no) --enable-FEATURE[=ARG] include FEATURE [ARG=yes] - --disable-builddir disable automatic build in subdir of sources - - --enable-dependency-tracking - do not reject slow dependency extractors - --disable-dependency-tracking - speeds up one-time build + --disable-dependency-tracking speeds up one-time build + --enable-dependency-tracking do not reject slow dependency extractors --enable-shared[=PKGS] build shared libraries [default=yes] --enable-static[=PKGS] build static libraries [default=yes] --enable-fast-install[=PKGS] optimize for fast installation [default=yes] --disable-libtool-lock avoid locking (might break parallel builds) - --enable-portable-binary - disable compiler optimizations that would produce - unportable binaries - --enable-maintainer-mode - enable make rules and dependencies not useful (and - sometimes confusing) to the casual installer - --enable-pax_emutramp enable pax emulated trampolines, for we can't use PROT_EXEC + --enable-maintainer-mode enable make rules and dependencies not useful + (and sometimes confusing) to the casual installer --enable-debug debugging mode --disable-structs omit code for struct support --disable-raw-api make the raw api unavailable @@ -1512,13 +1585,9 @@ Optional Packages: --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no) - --with-pic[=PKGS] try to use only PIC/non-PIC objects [default=use + --with-pic try to use only PIC/non-PIC objects [default=use both] --with-gnu-ld assume the C compiler uses GNU ld [default=no] - --with-sysroot=DIR Search for dependent libraries within DIR - (or the compiler's sysroot if not specified). - --with-gcc-arch= use architecture for gcc -march/-mtune, - instead of guessing Some influential environment variables: CC C compiler command @@ -1535,7 +1604,7 @@ Use these variables to override the choices made by `configure' or to help it to find libraries and programs with nonstandard names/locations. -Report bugs to . +Report bugs to . _ACEOF ac_status=$? fi @@ -1598,10 +1667,10 @@ test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -libffi configure 3.0.13 -generated by GNU Autoconf 2.69 - -Copyright (C) 2012 Free Software Foundation, Inc. +libffi configure 3.0.10rc0 +generated by GNU Autoconf 2.65 + +Copyright (C) 2009 Free Software Foundation, Inc. This configure script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it. _ACEOF @@ -1645,7 +1714,7 @@ ac_retval=1 fi - eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} as_fn_set_status $ac_retval } # ac_fn_c_try_compile @@ -1677,7 +1746,7 @@ test ! -s conftest.err } && test -s conftest$ac_exeext && { test "$cross_compiling" = yes || - test -x conftest$ac_exeext + $as_test_x conftest$ac_exeext }; then : ac_retval=0 else @@ -1691,7 +1760,7 @@ # interfere with the next link command; also delete a directory that is # left behind by Apple's compiler. We do this before executing the actions. rm -rf conftest.dSYM conftest_ipa8_conftest.oo - eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} as_fn_set_status $ac_retval } # ac_fn_c_try_link @@ -1705,7 +1774,7 @@ as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } -if eval \${$3+:} false; then : +if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext @@ -1723,7 +1792,7 @@ eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } - eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} } # ac_fn_c_check_header_compile @@ -1748,7 +1817,7 @@ mv -f conftest.er1 conftest.err fi $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } > conftest.i && { + test $ac_status = 0; } >/dev/null && { test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || test ! -s conftest.err }; then : @@ -1759,7 +1828,7 @@ ac_retval=1 fi - eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} as_fn_set_status $ac_retval } # ac_fn_c_try_cpp @@ -1801,7 +1870,7 @@ ac_retval=$ac_status fi rm -rf conftest.dSYM conftest_ipa8_conftest.oo - eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} as_fn_set_status $ac_retval } # ac_fn_c_try_run @@ -1814,7 +1883,7 @@ as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } -if eval \${$3+:} false; then : +if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext @@ -1869,10 +1938,103 @@ eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } - eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} } # ac_fn_c_check_func +# ac_fn_c_check_header_mongrel LINENO HEADER VAR INCLUDES +# ------------------------------------------------------- +# Tests whether HEADER exists, giving a warning if it cannot be compiled using +# the include files in INCLUDES and setting the cache variable VAR +# accordingly. +ac_fn_c_check_header_mongrel () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 +$as_echo_n "checking for $2... " >&6; } +if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then : + $as_echo_n "(cached) " >&6 +fi +eval ac_res=\$$3 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } +else + # Is the header compilable? +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 usability" >&5 +$as_echo_n "checking $2 usability... " >&6; } +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$4 +#include <$2> +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_header_compiler=yes +else + ac_header_compiler=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_compiler" >&5 +$as_echo "$ac_header_compiler" >&6; } + +# Is the header present? +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 presence" >&5 +$as_echo_n "checking $2 presence... " >&6; } +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include <$2> +_ACEOF +if ac_fn_c_try_cpp "$LINENO"; then : + ac_header_preproc=yes +else + ac_header_preproc=no +fi +rm -f conftest.err conftest.$ac_ext +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_preproc" >&5 +$as_echo "$ac_header_preproc" >&6; } + +# So? What about this header? +case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in #(( + yes:no: ) + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&5 +$as_echo "$as_me: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5 +$as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;} + ;; + no:yes:* ) + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: present but cannot be compiled" >&5 +$as_echo "$as_me: WARNING: $2: present but cannot be compiled" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: check for missing prerequisite headers?" >&5 +$as_echo "$as_me: WARNING: $2: check for missing prerequisite headers?" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: see the Autoconf documentation" >&5 +$as_echo "$as_me: WARNING: $2: see the Autoconf documentation" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: section \"Present But Cannot Be Compiled\"" >&5 +$as_echo "$as_me: WARNING: $2: section \"Present But Cannot Be Compiled\"" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5 +$as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;} +( cat <<\_ASBOX +## ------------------------------------------- ## +## Report this to http://gcc.gnu.org/bugs.html ## +## ------------------------------------------- ## +_ASBOX + ) | sed "s/^/$as_me: WARNING: /" >&2 + ;; +esac + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 +$as_echo_n "checking for $2... " >&6; } +if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then : + $as_echo_n "(cached) " >&6 +else + eval "$3=\$ac_header_compiler" +fi +eval ac_res=\$$3 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } +fi + eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} + +} # ac_fn_c_check_header_mongrel + # ac_fn_c_compute_int LINENO EXPR VAR INCLUDES # -------------------------------------------- # Tries to find the compile-time value of EXPR in a program that includes @@ -1890,8 +2052,7 @@ main () { static int test_array [1 - 2 * !(($2) >= 0)]; -test_array [0] = 0; -return test_array [0]; +test_array [0] = 0 ; return 0; @@ -1907,8 +2068,7 @@ main () { static int test_array [1 - 2 * !(($2) <= $ac_mid)]; -test_array [0] = 0; -return test_array [0]; +test_array [0] = 0 ; return 0; @@ -1934,8 +2094,7 @@ main () { static int test_array [1 - 2 * !(($2) < 0)]; -test_array [0] = 0; -return test_array [0]; +test_array [0] = 0 ; return 0; @@ -1951,8 +2110,7 @@ main () { static int test_array [1 - 2 * !(($2) >= $ac_mid)]; -test_array [0] = 0; -return test_array [0]; +test_array [0] = 0 ; return 0; @@ -1986,8 +2144,7 @@ main () { static int test_array [1 - 2 * !(($2) <= $ac_mid)]; -test_array [0] = 0; -return test_array [0]; +test_array [0] = 0 ; return 0; @@ -2051,161 +2208,16 @@ rm -f conftest.val fi - eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} as_fn_set_status $ac_retval } # ac_fn_c_compute_int - -# ac_fn_c_check_header_mongrel LINENO HEADER VAR INCLUDES -# ------------------------------------------------------- -# Tests whether HEADER exists, giving a warning if it cannot be compiled using -# the include files in INCLUDES and setting the cache variable VAR -# accordingly. -ac_fn_c_check_header_mongrel () -{ - as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - if eval \${$3+:} false; then : - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 -$as_echo_n "checking for $2... " >&6; } -if eval \${$3+:} false; then : - $as_echo_n "(cached) " >&6 -fi -eval ac_res=\$$3 - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } -else - # Is the header compilable? -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 usability" >&5 -$as_echo_n "checking $2 usability... " >&6; } -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -$4 -#include <$2> -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - ac_header_compiler=yes -else - ac_header_compiler=no -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_compiler" >&5 -$as_echo "$ac_header_compiler" >&6; } - -# Is the header present? -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 presence" >&5 -$as_echo_n "checking $2 presence... " >&6; } -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include <$2> -_ACEOF -if ac_fn_c_try_cpp "$LINENO"; then : - ac_header_preproc=yes -else - ac_header_preproc=no -fi -rm -f conftest.err conftest.i conftest.$ac_ext -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_preproc" >&5 -$as_echo "$ac_header_preproc" >&6; } - -# So? What about this header? -case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in #(( - yes:no: ) - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&5 -$as_echo "$as_me: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&2;} - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5 -$as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;} - ;; - no:yes:* ) - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: present but cannot be compiled" >&5 -$as_echo "$as_me: WARNING: $2: present but cannot be compiled" >&2;} - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: check for missing prerequisite headers?" >&5 -$as_echo "$as_me: WARNING: $2: check for missing prerequisite headers?" >&2;} - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: see the Autoconf documentation" >&5 -$as_echo "$as_me: WARNING: $2: see the Autoconf documentation" >&2;} - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: section \"Present But Cannot Be Compiled\"" >&5 -$as_echo "$as_me: WARNING: $2: section \"Present But Cannot Be Compiled\"" >&2;} - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5 -$as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;} -( $as_echo "## ------------------------------------------------------ ## -## Report this to http://github.com/atgreen/libffi/issues ## -## ------------------------------------------------------ ##" - ) | sed "s/^/$as_me: WARNING: /" >&2 - ;; -esac - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 -$as_echo_n "checking for $2... " >&6; } -if eval \${$3+:} false; then : - $as_echo_n "(cached) " >&6 -else - eval "$3=\$ac_header_compiler" -fi -eval ac_res=\$$3 - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } -fi - eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno - -} # ac_fn_c_check_header_mongrel - -# ac_fn_c_check_type LINENO TYPE VAR INCLUDES -# ------------------------------------------- -# Tests whether TYPE exists after having included INCLUDES, setting cache -# variable VAR accordingly. -ac_fn_c_check_type () -{ - as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 -$as_echo_n "checking for $2... " >&6; } -if eval \${$3+:} false; then : - $as_echo_n "(cached) " >&6 -else - eval "$3=no" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -$4 -int -main () -{ -if (sizeof ($2)) - return 0; - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -$4 -int -main () -{ -if (sizeof (($2))) - return 0; - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - -else - eval "$3=yes" -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -fi -eval ac_res=\$$3 - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } - eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno - -} # ac_fn_c_check_type cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by libffi $as_me 3.0.13, which was -generated by GNU Autoconf 2.69. Invocation command line was +It was created by libffi $as_me 3.0.10rc0, which was +generated by GNU Autoconf 2.65. Invocation command line was $ $0 $@ @@ -2315,9 +2327,11 @@ { echo - $as_echo "## ---------------- ## + cat <<\_ASBOX +## ---------------- ## ## Cache variables. ## -## ---------------- ##" +## ---------------- ## +_ASBOX echo # The following way of writing the cache mishandles newlines in values, ( @@ -2351,9 +2365,11 @@ ) echo - $as_echo "## ----------------- ## + cat <<\_ASBOX +## ----------------- ## ## Output variables. ## -## ----------------- ##" +## ----------------- ## +_ASBOX echo for ac_var in $ac_subst_vars do @@ -2366,9 +2382,11 @@ echo if test -n "$ac_subst_files"; then - $as_echo "## ------------------- ## + cat <<\_ASBOX +## ------------------- ## ## File substitutions. ## -## ------------------- ##" +## ------------------- ## +_ASBOX echo for ac_var in $ac_subst_files do @@ -2382,9 +2400,11 @@ fi if test -s confdefs.h; then - $as_echo "## ----------- ## + cat <<\_ASBOX +## ----------- ## ## confdefs.h. ## -## ----------- ##" +## ----------- ## +_ASBOX echo cat confdefs.h echo @@ -2439,12 +2459,7 @@ ac_site_file1=NONE ac_site_file2=NONE if test -n "$CONFIG_SITE"; then - # We do not want a PATH search for config.site. - case $CONFIG_SITE in #(( - -*) ac_site_file1=./$CONFIG_SITE;; - */*) ac_site_file1=$CONFIG_SITE;; - *) ac_site_file1=./$CONFIG_SITE;; - esac + ac_site_file1=$CONFIG_SITE elif test "x$prefix" != xNONE; then ac_site_file1=$prefix/share/config.site ac_site_file2=$prefix/etc/config.site @@ -2459,11 +2474,7 @@ { $as_echo "$as_me:${as_lineno-$LINENO}: loading site script $ac_site_file" >&5 $as_echo "$as_me: loading site script $ac_site_file" >&6;} sed 's/^/| /' "$ac_site_file" >&5 - . "$ac_site_file" \ - || { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error $? "failed to load site script $ac_site_file -See \`config.log' for more details" "$LINENO" 5; } + . "$ac_site_file" fi done @@ -2539,7 +2550,7 @@ $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: error: changes in the environment can compromise the build" >&5 $as_echo "$as_me: error: changes in the environment can compromise the build" >&2;} - as_fn_error $? "run \`make distclean' and/or \`rm $cache_file' and start over" "$LINENO" 5 + as_fn_error "run \`make distclean' and/or \`rm $cache_file' and start over" "$LINENO" 5 fi ## -------------------- ## ## Main body of script. ## @@ -2557,22 +2568,16 @@ ac_aux_dir= for ac_dir in "$srcdir" "$srcdir/.." "$srcdir/../.."; do - if test -f "$ac_dir/install-sh"; then - ac_aux_dir=$ac_dir - ac_install_sh="$ac_aux_dir/install-sh -c" - break - elif test -f "$ac_dir/install.sh"; then - ac_aux_dir=$ac_dir - ac_install_sh="$ac_aux_dir/install.sh -c" - break - elif test -f "$ac_dir/shtool"; then - ac_aux_dir=$ac_dir - ac_install_sh="$ac_aux_dir/shtool install -c" - break - fi + for ac_t in install-sh install.sh shtool; do + if test -f "$ac_dir/$ac_t"; then + ac_aux_dir=$ac_dir + ac_install_sh="$ac_aux_dir/$ac_t -c" + break 2 + fi + done done if test -z "$ac_aux_dir"; then - as_fn_error $? "cannot find install-sh, install.sh, or shtool in \"$srcdir\" \"$srcdir/..\" \"$srcdir/../..\"" "$LINENO" 5 + as_fn_error "cannot find install-sh, install.sh, or shtool in \"$srcdir\" \"$srcdir/..\" \"$srcdir/../..\"" "$LINENO" 5 fi # These three variables are undocumented and unsupported, @@ -2586,27 +2591,27 @@ # Make sure we can run config.sub. $SHELL "$ac_aux_dir/config.sub" sun4 >/dev/null 2>&1 || - as_fn_error $? "cannot run $SHELL $ac_aux_dir/config.sub" "$LINENO" 5 + as_fn_error "cannot run $SHELL $ac_aux_dir/config.sub" "$LINENO" 5 { $as_echo "$as_me:${as_lineno-$LINENO}: checking build system type" >&5 $as_echo_n "checking build system type... " >&6; } -if ${ac_cv_build+:} false; then : +if test "${ac_cv_build+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_build_alias=$build_alias test "x$ac_build_alias" = x && ac_build_alias=`$SHELL "$ac_aux_dir/config.guess"` test "x$ac_build_alias" = x && - as_fn_error $? "cannot guess build type; you must specify one" "$LINENO" 5 + as_fn_error "cannot guess build type; you must specify one" "$LINENO" 5 ac_cv_build=`$SHELL "$ac_aux_dir/config.sub" $ac_build_alias` || - as_fn_error $? "$SHELL $ac_aux_dir/config.sub $ac_build_alias failed" "$LINENO" 5 + as_fn_error "$SHELL $ac_aux_dir/config.sub $ac_build_alias failed" "$LINENO" 5 fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_build" >&5 $as_echo "$ac_cv_build" >&6; } case $ac_cv_build in *-*-*) ;; -*) as_fn_error $? "invalid value of canonical build" "$LINENO" 5;; +*) as_fn_error "invalid value of canonical build" "$LINENO" 5;; esac build=$ac_cv_build ac_save_IFS=$IFS; IFS='-' @@ -2624,14 +2629,14 @@ { $as_echo "$as_me:${as_lineno-$LINENO}: checking host system type" >&5 $as_echo_n "checking host system type... " >&6; } -if ${ac_cv_host+:} false; then : +if test "${ac_cv_host+set}" = set; then : $as_echo_n "(cached) " >&6 else if test "x$host_alias" = x; then ac_cv_host=$ac_cv_build else ac_cv_host=`$SHELL "$ac_aux_dir/config.sub" $host_alias` || - as_fn_error $? "$SHELL $ac_aux_dir/config.sub $host_alias failed" "$LINENO" 5 + as_fn_error "$SHELL $ac_aux_dir/config.sub $host_alias failed" "$LINENO" 5 fi fi @@ -2639,7 +2644,7 @@ $as_echo "$ac_cv_host" >&6; } case $ac_cv_host in *-*-*) ;; -*) as_fn_error $? "invalid value of canonical host" "$LINENO" 5;; +*) as_fn_error "invalid value of canonical host" "$LINENO" 5;; esac host=$ac_cv_host ac_save_IFS=$IFS; IFS='-' @@ -2657,14 +2662,14 @@ { $as_echo "$as_me:${as_lineno-$LINENO}: checking target system type" >&5 $as_echo_n "checking target system type... " >&6; } -if ${ac_cv_target+:} false; then : +if test "${ac_cv_target+set}" = set; then : $as_echo_n "(cached) " >&6 else if test "x$target_alias" = x; then ac_cv_target=$ac_cv_host else ac_cv_target=`$SHELL "$ac_aux_dir/config.sub" $target_alias` || - as_fn_error $? "$SHELL $ac_aux_dir/config.sub $target_alias failed" "$LINENO" 5 + as_fn_error "$SHELL $ac_aux_dir/config.sub $target_alias failed" "$LINENO" 5 fi fi @@ -2672,7 +2677,7 @@ $as_echo "$ac_cv_target" >&6; } case $ac_cv_target in *-*-*) ;; -*) as_fn_error $? "invalid value of canonical target" "$LINENO" 5;; +*) as_fn_error "invalid value of canonical target" "$LINENO" 5;; esac target=$ac_cv_target ac_save_IFS=$IFS; IFS='-' @@ -2699,111 +2704,7 @@ . ${srcdir}/configure.host - - # [$]@ is unsable in 2.60+ but earlier autoconf had no ac_configure_args - if test "${ac_configure_args+set}" != "set" ; then - ac_configure_args= - for ac_arg in ${1+"$@"}; do - ac_configure_args="$ac_configure_args '$ac_arg'" - done - fi - -# expand $ac_aux_dir to an absolute path -am_aux_dir=`cd $ac_aux_dir && pwd` - - -ax_enable_builddir="." -# Check whether --enable-builddir was given. -if test "${enable_builddir+set}" = set; then : - enableval=$enable_builddir; ax_enable_builddir="$enableval" -else - ax_enable_builddir="auto" -fi - -if test ".$ac_srcdir_defaulted" != ".no" ; then -if test ".$srcdir" = ".." ; then - if test -f config.status ; then - { $as_echo "$as_me:${as_lineno-$LINENO}: toplevel srcdir already configured... skipping subdir build" >&5 -$as_echo "$as_me: toplevel srcdir already configured... skipping subdir build" >&6;} - else - test ".$ax_enable_builddir" = "." && ax_enable_builddir="." - test ".$ax_enable_builddir" = ".no" && ax_enable_builddir="." - test ".$TARGET" = "." && TARGET="$target" - test ".$ax_enable_builddir" = ".auto" && ax_enable_builddir="$TARGET" - if test ".$ax_enable_builddir" != ".." ; then # we know where to go and - as_dir=$ax_enable_builddir; as_fn_mkdir_p - echo __.$ax_enable_builddir.__ > $ax_enable_builddir/conftest.tmp - cd $ax_enable_builddir - if grep __.$ax_enable_builddir.__ conftest.tmp >/dev/null 2>/dev/null ; then - rm conftest.tmp - { $as_echo "$as_me:${as_lineno-$LINENO}: result: continue configure in default builddir \"./$ax_enable_builddir\"" >&5 -$as_echo "continue configure in default builddir \"./$ax_enable_builddir\"" >&6; } - else - as_fn_error $? "could not change to default builddir \"./$ax_enable_builddir\"" "$LINENO" 5 - fi - srcdir=`echo "$ax_enable_builddir" | - sed -e 's,^\./,,;s,[^/]$,&/,;s,[^/]*/,../,g;s,[/]$,,;'` - # going to restart from subdirectory location - test -f $srcdir/config.log && mv $srcdir/config.log . - test -f $srcdir/confdefs.h && mv $srcdir/confdefs.h . - test -f $srcdir/conftest.log && mv $srcdir/conftest.log . - test -f $srcdir/$cache_file && mv $srcdir/$cache_file . - { $as_echo "$as_me:${as_lineno-$LINENO}: result: ....exec $SHELL $srcdir/$0 \"--srcdir=$srcdir\" \"--enable-builddir=$ax_enable_builddir\" ${1+\"$@\"}" >&5 -$as_echo "....exec $SHELL $srcdir/$0 \"--srcdir=$srcdir\" \"--enable-builddir=$ax_enable_builddir\" ${1+\"$@\"}" >&6; } - case "$0" in # restart - /\\*) eval $SHELL "'$0'" "'--srcdir=$srcdir'" "'--enable-builddir=$ax_enable_builddir'" $ac_configure_args ;; - *) eval $SHELL "'$srcdir/$0'" "'--srcdir=$srcdir'" "'--enable-builddir=$ax_enable_builddir'" $ac_configure_args ;; - esac ; exit $? - fi - fi -fi fi -test ".$ax_enable_builddir" = ".auto" && ax_enable_builddir="." -# Extract the first word of "gsed sed", so it can be a program name with args. -set dummy gsed sed; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_ax_enable_builddir_sed+:} false; then : - $as_echo_n "(cached) " >&6 -else - case $ax_enable_builddir_sed in - [\\/]* | ?:[\\/]*) - ac_cv_path_ax_enable_builddir_sed="$ax_enable_builddir_sed" # Let the user override the test with a path. - ;; - *) - as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_path_ax_enable_builddir_sed="$as_dir/$ac_word$ac_exec_ext" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - - test -z "$ac_cv_path_ax_enable_builddir_sed" && ac_cv_path_ax_enable_builddir_sed="sed" - ;; -esac -fi -ax_enable_builddir_sed=$ac_cv_path_ax_enable_builddir_sed -if test -n "$ax_enable_builddir_sed"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_enable_builddir_sed" >&5 -$as_echo "$ax_enable_builddir_sed" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - -ax_enable_builddir_auxdir="$am_aux_dir" -ac_config_commands="$ac_config_commands buildir" - - -am__api_version='1.12' +am__api_version='1.11' # Find a good install program. We prefer a C program (faster), # so one script is as good as another. But avoid the broken or @@ -2822,7 +2723,7 @@ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for a BSD-compatible install" >&5 $as_echo_n "checking for a BSD-compatible install... " >&6; } if test -z "$INSTALL"; then -if ${ac_cv_path_install+:} false; then : +if test "${ac_cv_path_install+set}" = set; then : $as_echo_n "(cached) " >&6 else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR @@ -2842,7 +2743,7 @@ # by default. for ac_prog in ginstall scoinst install; do for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_prog$ac_exec_ext"; then + if { test -f "$as_dir/$ac_prog$ac_exec_ext" && $as_test_x "$as_dir/$ac_prog$ac_exec_ext"; }; then if test $ac_prog = install && grep dspmsg "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then # AIX install. It has an incompatible calling convention. @@ -2900,71 +2801,56 @@ { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether build environment is sane" >&5 $as_echo_n "checking whether build environment is sane... " >&6; } +# Just in case +sleep 1 +echo timestamp > conftest.file # Reject unsafe characters in $srcdir or the absolute working directory # name. Accept space and tab only in the latter. am_lf=' ' case `pwd` in *[\\\"\#\$\&\'\`$am_lf]*) - as_fn_error $? "unsafe absolute working directory name" "$LINENO" 5;; + as_fn_error "unsafe absolute working directory name" "$LINENO" 5;; esac case $srcdir in *[\\\"\#\$\&\'\`$am_lf\ \ ]*) - as_fn_error $? "unsafe srcdir value: '$srcdir'" "$LINENO" 5;; -esac - -# Do 'set' in a subshell so we don't clobber the current shell's + as_fn_error "unsafe srcdir value: \`$srcdir'" "$LINENO" 5;; +esac + +# Do `set' in a subshell so we don't clobber the current shell's # arguments. Must try -L first in case configure is actually a # symlink; some systems play weird games with the mod time of symlinks # (eg FreeBSD returns the mod time of the symlink's containing # directory). if ( - am_has_slept=no - for am_try in 1 2; do - echo "timestamp, slept: $am_has_slept" > conftest.file - set X `ls -Lt "$srcdir/configure" conftest.file 2> /dev/null` - if test "$*" = "X"; then - # -L didn't work. - set X `ls -t "$srcdir/configure" conftest.file` - fi - if test "$*" != "X $srcdir/configure conftest.file" \ - && test "$*" != "X conftest.file $srcdir/configure"; then - - # If neither matched, then we have a broken ls. This can happen - # if, for instance, CONFIG_SHELL is bash and it inherits a - # broken ls alias from the environment. This has actually - # happened. Such a system could not be considered "sane". - as_fn_error $? "ls -t appears to fail. Make sure there is not a broken - alias in your environment" "$LINENO" 5 - fi - if test "$2" = conftest.file || test $am_try -eq 2; then - break - fi - # Just in case. - sleep 1 - am_has_slept=yes - done + set X `ls -Lt "$srcdir/configure" conftest.file 2> /dev/null` + if test "$*" = "X"; then + # -L didn't work. + set X `ls -t "$srcdir/configure" conftest.file` + fi + rm -f conftest.file + if test "$*" != "X $srcdir/configure conftest.file" \ + && test "$*" != "X conftest.file $srcdir/configure"; then + + # If neither matched, then we have a broken ls. This can happen + # if, for instance, CONFIG_SHELL is bash and it inherits a + # broken ls alias from the environment. This has actually + # happened. Such a system could not be considered "sane". + as_fn_error "ls -t appears to fail. Make sure there is not a broken +alias in your environment" "$LINENO" 5 + fi + test "$2" = conftest.file ) then # Ok. : else - as_fn_error $? "newly created file is older than distributed files! + as_fn_error "newly created file is older than distributed files! Check your system clock" "$LINENO" 5 fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } -# If we didn't sleep, we still need to ensure time stamps of config.status and -# generated files are strictly newer. -am_sleep_pid= -if grep 'slept: no' conftest.file >/dev/null 2>&1; then - ( sleep 1 ) & - am_sleep_pid=$! -fi - -rm -f conftest.file - test "$program_prefix" != NONE && program_transform_name="s&^&$program_prefix&;$program_transform_name" # Use a double $ so make ignores it. @@ -2975,6 +2861,9 @@ ac_script='s/[\\$]/&&/g;s/;s,x,x,$//' program_transform_name=`$as_echo "$program_transform_name" | sed "$ac_script"` +# expand $ac_aux_dir to an absolute path +am_aux_dir=`cd $ac_aux_dir && pwd` + if test x"${MISSING+set}" != xset; then case $am_aux_dir in *\ * | *\ *) @@ -2988,8 +2877,8 @@ am_missing_run="$MISSING --run " else am_missing_run= - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: 'missing' script is too old or missing" >&5 -$as_echo "$as_me: WARNING: 'missing' script is too old or missing" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: \`missing' script is too old or missing" >&5 +$as_echo "$as_me: WARNING: \`missing' script is too old or missing" >&2;} fi if test x"${install_sh}" != xset; then @@ -3001,17 +2890,17 @@ esac fi -# Installed binaries are usually stripped using 'strip' when the user -# run "make install-strip". However 'strip' might not be the right +# Installed binaries are usually stripped using `strip' when the user +# run `make install-strip'. However `strip' might not be the right # tool to use in cross-compilation environments, therefore Automake -# will honor the 'STRIP' environment variable to overrule this program. +# will honor the `STRIP' environment variable to overrule this program. if test "$cross_compiling" != no; then if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}strip", so it can be a program name with args. set dummy ${ac_tool_prefix}strip; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_STRIP+:} false; then : +if test "${ac_cv_prog_STRIP+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$STRIP"; then @@ -3023,7 +2912,7 @@ IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_STRIP="${ac_tool_prefix}strip" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -3051,7 +2940,7 @@ set dummy strip; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_ac_ct_STRIP+:} false; then : +if test "${ac_cv_prog_ac_ct_STRIP+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_STRIP"; then @@ -3063,7 +2952,7 @@ IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_STRIP="strip" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -3104,7 +2993,7 @@ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for a thread-safe mkdir -p" >&5 $as_echo_n "checking for a thread-safe mkdir -p... " >&6; } if test -z "$MKDIR_P"; then - if ${ac_cv_path_mkdir+:} false; then : + if test "${ac_cv_path_mkdir+set}" = set; then : $as_echo_n "(cached) " >&6 else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR @@ -3114,7 +3003,7 @@ test -z "$as_dir" && as_dir=. for ac_prog in mkdir gmkdir; do for ac_exec_ext in '' $ac_executable_extensions; do - as_fn_executable_p "$as_dir/$ac_prog$ac_exec_ext" || continue + { test -f "$as_dir/$ac_prog$ac_exec_ext" && $as_test_x "$as_dir/$ac_prog$ac_exec_ext"; } || continue case `"$as_dir/$ac_prog$ac_exec_ext" --version 2>&1` in #( 'mkdir (GNU coreutils) '* | \ 'mkdir (coreutils) '* | \ @@ -3143,13 +3032,19 @@ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MKDIR_P" >&5 $as_echo "$MKDIR_P" >&6; } +mkdir_p="$MKDIR_P" +case $mkdir_p in + [\\/$]* | ?:[\\/]*) ;; + */*) mkdir_p="\$(top_builddir)/$mkdir_p" ;; +esac + for ac_prog in gawk mawk nawk awk do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_AWK+:} false; then : +if test "${ac_cv_prog_AWK+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$AWK"; then @@ -3161,7 +3056,7 @@ IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_AWK="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -3189,7 +3084,7 @@ $as_echo_n "checking whether ${MAKE-make} sets \$(MAKE)... " >&6; } set x ${MAKE-make} ac_make=`$as_echo "$2" | sed 's/+/p/g; s/[^a-zA-Z0-9_]/_/g'` -if eval \${ac_cv_prog_make_${ac_make}_set+:} false; then : +if { as_var=ac_cv_prog_make_${ac_make}_set; eval "test \"\${$as_var+set}\" = set"; }; then : $as_echo_n "(cached) " >&6 else cat >conftest.make <<\_ACEOF @@ -3197,7 +3092,7 @@ all: @echo '@@@%%%=$(MAKE)=@@@%%%' _ACEOF -# GNU make sometimes prints "make[1]: Entering ...", which would confuse us. +# GNU make sometimes prints "make[1]: Entering...", which would confuse us. case `${MAKE-make} -f conftest.make 2>/dev/null` in *@@@%%%=?*=@@@%%%*) eval ac_cv_prog_make_${ac_make}_set=yes;; @@ -3231,7 +3126,7 @@ am__isrc=' -I$(srcdir)' # test to see if srcdir already configured if test -f $srcdir/config.status; then - as_fn_error $? "source directory already configured; run \"make distclean\" there first" "$LINENO" 5 + as_fn_error "source directory already configured; run \"make distclean\" there first" "$LINENO" 5 fi fi @@ -3247,7 +3142,7 @@ # Define the identity of the package. PACKAGE='libffi' - VERSION='3.0.13' + VERSION='3.0.10rc0' cat >>confdefs.h <<_ACEOF @@ -3275,19 +3170,13 @@ MAKEINFO=${MAKEINFO-"${am_missing_run}makeinfo"} -# For better backward compatibility. To be removed once Automake 1.9.x -# dies out for good. For more background, see: -# -# -mkdir_p='$(MKDIR_P)' - # We need awk for the "check" target. The system "awk" is bad on # some platforms. -# Always define AMTAR for backward compatibility. Yes, it's still used -# in the wild :-( We should find a proper way to deprecate it ... -AMTAR='$${TAR-tar}' - -am__tar='$${TAR-tar} chof - "$$tardir"' am__untar='$${TAR-tar} xf -' +# Always define AMTAR for backward compatibility. + +AMTAR=${AMTAR-"${am_missing_run}tar"} + +am__tar='${AMTAR} chof - "$$tardir"'; am__untar='${AMTAR} xf -' @@ -3298,12 +3187,9 @@ # We must force CC to /not/ be precious variables; otherwise # the wrong, non-multilib-adjusted value will be used in multilibs. # As a side effect, we have to subst CFLAGS ourselves. -# Also save and restore CFLAGS, since AC_PROG_CC will come up with -# defaults of its own if none are provided. - - - -save_CFLAGS=$CFLAGS + + + ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' @@ -3314,7 +3200,7 @@ set dummy ${ac_tool_prefix}gcc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_CC+:} false; then : +if test "${ac_cv_prog_CC+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then @@ -3326,7 +3212,7 @@ IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_CC="${ac_tool_prefix}gcc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -3354,7 +3240,7 @@ set dummy gcc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_ac_ct_CC+:} false; then : +if test "${ac_cv_prog_ac_ct_CC+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_CC"; then @@ -3366,7 +3252,7 @@ IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_CC="gcc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -3407,7 +3293,7 @@ set dummy ${ac_tool_prefix}cc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_CC+:} false; then : +if test "${ac_cv_prog_CC+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then @@ -3419,7 +3305,7 @@ IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_CC="${ac_tool_prefix}cc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -3447,7 +3333,7 @@ set dummy cc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_CC+:} false; then : +if test "${ac_cv_prog_CC+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then @@ -3460,7 +3346,7 @@ IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then ac_prog_rejected=yes continue @@ -3506,7 +3392,7 @@ set dummy $ac_tool_prefix$ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_CC+:} false; then : +if test "${ac_cv_prog_CC+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then @@ -3518,7 +3404,7 @@ IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_CC="$ac_tool_prefix$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -3550,7 +3436,7 @@ set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_ac_ct_CC+:} false; then : +if test "${ac_cv_prog_ac_ct_CC+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_CC"; then @@ -3562,7 +3448,7 @@ IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_CC="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -3604,8 +3490,8 @@ test -z "$CC" && { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error $? "no acceptable C compiler found in \$PATH -See \`config.log' for more details" "$LINENO" 5; } +as_fn_error "no acceptable C compiler found in \$PATH +See \`config.log' for more details." "$LINENO" 5; } # Provide some information about the compiler. $as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler version" >&5 @@ -3719,8 +3605,9 @@ { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error 77 "C compiler cannot create executables -See \`config.log' for more details" "$LINENO" 5; } +{ as_fn_set_status 77 +as_fn_error "C compiler cannot create executables +See \`config.log' for more details." "$LINENO" 5; }; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } @@ -3762,8 +3649,8 @@ else { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error $? "cannot compute suffix of executables: cannot compile and link -See \`config.log' for more details" "$LINENO" 5; } +as_fn_error "cannot compute suffix of executables: cannot compile and link +See \`config.log' for more details." "$LINENO" 5; } fi rm -f conftest conftest$ac_cv_exeext { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_exeext" >&5 @@ -3820,9 +3707,9 @@ else { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error $? "cannot run C compiled programs. +as_fn_error "cannot run C compiled programs. If you meant to cross compile, use \`--host'. -See \`config.log' for more details" "$LINENO" 5; } +See \`config.log' for more details." "$LINENO" 5; } fi fi fi @@ -3833,7 +3720,7 @@ ac_clean_files=$ac_clean_files_save { $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of object files" >&5 $as_echo_n "checking for suffix of object files... " >&6; } -if ${ac_cv_objext+:} false; then : +if test "${ac_cv_objext+set}" = set; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext @@ -3873,8 +3760,8 @@ { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error $? "cannot compute suffix of object files: cannot compile -See \`config.log' for more details" "$LINENO" 5; } +as_fn_error "cannot compute suffix of object files: cannot compile +See \`config.log' for more details." "$LINENO" 5; } fi rm -f conftest.$ac_cv_objext conftest.$ac_ext fi @@ -3884,7 +3771,7 @@ ac_objext=$OBJEXT { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C compiler" >&5 $as_echo_n "checking whether we are using the GNU C compiler... " >&6; } -if ${ac_cv_c_compiler_gnu+:} false; then : +if test "${ac_cv_c_compiler_gnu+set}" = set; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext @@ -3921,7 +3808,7 @@ ac_save_CFLAGS=$CFLAGS { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC accepts -g" >&5 $as_echo_n "checking whether $CC accepts -g... " >&6; } -if ${ac_cv_prog_cc_g+:} false; then : +if test "${ac_cv_prog_cc_g+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_save_c_werror_flag=$ac_c_werror_flag @@ -3999,7 +3886,7 @@ fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CC option to accept ISO C89" >&5 $as_echo_n "checking for $CC option to accept ISO C89... " >&6; } -if ${ac_cv_prog_cc_c89+:} false; then : +if test "${ac_cv_prog_cc_c89+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_cv_prog_cc_c89=no @@ -4008,7 +3895,8 @@ /* end confdefs.h. */ #include #include -struct stat; +#include +#include /* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */ struct buf { int x; }; FILE * (*rcsopen) (struct buf *, struct stat *, int); @@ -4111,7 +3999,7 @@ _am_result=none # First try GNU make style include. echo "include confinc" > confmf -# Ignore all kinds of additional output from 'make'. +# Ignore all kinds of additional output from `make'. case `$am_make -s -f confmf 2> /dev/null` in #( *the\ am__doit\ target*) am__include=include @@ -4144,7 +4032,6 @@ if test "x$enable_dependency_tracking" != xno; then am_depcomp="$ac_aux_dir/depcomp" AMDEPBACKSLASH='\' - am__nodep='_no' fi if test "x$enable_dependency_tracking" != xno; then AMDEP_TRUE= @@ -4160,16 +4047,15 @@ { $as_echo "$as_me:${as_lineno-$LINENO}: checking dependency style of $depcc" >&5 $as_echo_n "checking dependency style of $depcc... " >&6; } -if ${am_cv_CC_dependencies_compiler_type+:} false; then : +if test "${am_cv_CC_dependencies_compiler_type+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then # We make a subdir and do the tests there. Otherwise we can end up # making bogus files that we don't know about and never remove. For # instance it was reported that on HP-UX the gcc test will end up - # making a dummy file named 'D' -- because '-MD' means "put the output - # in D". - rm -rf conftest.dir + # making a dummy file named `D' -- because `-MD' means `put the output + # in D'. mkdir conftest.dir # Copy depcomp to subdir because otherwise we won't find it if we're # using a relative directory. @@ -4203,16 +4089,16 @@ : > sub/conftest.c for i in 1 2 3 4 5 6; do echo '#include "conftst'$i'.h"' >> sub/conftest.c - # Using ": > sub/conftst$i.h" creates only sub/conftst1.h with - # Solaris 10 /bin/sh. - echo '/* dummy */' > sub/conftst$i.h + # Using `: > sub/conftst$i.h' creates only sub/conftst1.h with + # Solaris 8's {/usr,}/bin/sh. + touch sub/conftst$i.h done echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf - # We check with '-c' and '-o' for the sake of the "dashmstdout" + # We check with `-c' and `-o' for the sake of the "dashmstdout" # mode. It turns out that the SunPro C++ compiler does not properly - # handle '-M -o', and we need to detect this. Also, some Intel - # versions had trouble with output in subdirs. + # handle `-M -o', and we need to detect this. Also, some Intel + # versions had trouble with output in subdirs am__obj=sub/conftest.${OBJEXT-o} am__minus_obj="-o $am__obj" case $depmode in @@ -4221,16 +4107,16 @@ test "$am__universal" = false || continue ;; nosideeffect) - # After this tag, mechanisms are not by side-effect, so they'll - # only be used when explicitly requested. + # after this tag, mechanisms are not by side-effect, so they'll + # only be used when explicitly requested if test "x$enable_dependency_tracking" = xyes; then continue else break fi ;; - msvc7 | msvc7msys | msvisualcpp | msvcmsys) - # This compiler won't grok '-c -o', but also, the minuso test has + msvisualcpp | msvcmsys) + # This compiler won't grok `-c -o', but also, the minuso test has # not run yet. These depmodes are late enough in the game, and # so weak that their functioning should not be impacted. am__obj=conftest.${OBJEXT-o} @@ -4284,7 +4170,6 @@ fi -CFLAGS=$save_CFLAGS @@ -4301,16 +4186,15 @@ { $as_echo "$as_me:${as_lineno-$LINENO}: checking dependency style of $depcc" >&5 $as_echo_n "checking dependency style of $depcc... " >&6; } -if ${am_cv_CCAS_dependencies_compiler_type+:} false; then : +if test "${am_cv_CCAS_dependencies_compiler_type+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then # We make a subdir and do the tests there. Otherwise we can end up # making bogus files that we don't know about and never remove. For # instance it was reported that on HP-UX the gcc test will end up - # making a dummy file named 'D' -- because '-MD' means "put the output - # in D". - rm -rf conftest.dir + # making a dummy file named `D' -- because `-MD' means `put the output + # in D'. mkdir conftest.dir # Copy depcomp to subdir because otherwise we won't find it if we're # using a relative directory. @@ -4342,16 +4226,16 @@ : > sub/conftest.c for i in 1 2 3 4 5 6; do echo '#include "conftst'$i'.h"' >> sub/conftest.c - # Using ": > sub/conftst$i.h" creates only sub/conftst1.h with - # Solaris 10 /bin/sh. - echo '/* dummy */' > sub/conftst$i.h + # Using `: > sub/conftst$i.h' creates only sub/conftst1.h with + # Solaris 8's {/usr,}/bin/sh. + touch sub/conftst$i.h done echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf - # We check with '-c' and '-o' for the sake of the "dashmstdout" + # We check with `-c' and `-o' for the sake of the "dashmstdout" # mode. It turns out that the SunPro C++ compiler does not properly - # handle '-M -o', and we need to detect this. Also, some Intel - # versions had trouble with output in subdirs. + # handle `-M -o', and we need to detect this. Also, some Intel + # versions had trouble with output in subdirs am__obj=sub/conftest.${OBJEXT-o} am__minus_obj="-o $am__obj" case $depmode in @@ -4360,16 +4244,16 @@ test "$am__universal" = false || continue ;; nosideeffect) - # After this tag, mechanisms are not by side-effect, so they'll - # only be used when explicitly requested. + # after this tag, mechanisms are not by side-effect, so they'll + # only be used when explicitly requested if test "x$enable_dependency_tracking" = xyes; then continue else break fi ;; - msvc7 | msvc7msys | msvisualcpp | msvcmsys) - # This compiler won't grok '-c -o', but also, the minuso test has + msvisualcpp | msvcmsys) + # This compiler won't grok `-c -o', but also, the minuso test has # not run yet. These depmodes are late enough in the game, and # so weak that their functioning should not be impacted. am__obj=conftest.${OBJEXT-o} @@ -4432,7 +4316,7 @@ fi set dummy $CC; ac_cc=`$as_echo "$2" | sed 's/[^a-zA-Z0-9_]/_/g;s/^[0-9]/_/'` -if eval \${ac_cv_prog_cc_${ac_cc}_c_o+:} false; then : +if { as_var=ac_cv_prog_cc_${ac_cc}_c_o; eval "test \"\${$as_var+set}\" = set"; }; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext @@ -4557,8 +4441,8 @@ -macro_version='2.4.2' -macro_revision='1.3337' +macro_version='2.2.6' +macro_revision='1.3012' @@ -4574,78 +4458,9 @@ ltmain="$ac_aux_dir/ltmain.sh" -# Backslashify metacharacters that are still active within -# double-quoted strings. -sed_quote_subst='s/\(["`$\\]\)/\\\1/g' - -# Same as above, but do not quote variable references. -double_quote_subst='s/\(["`\\]\)/\\\1/g' - -# Sed substitution to delay expansion of an escaped shell variable in a -# double_quote_subst'ed string. -delay_variable_subst='s/\\\\\\\\\\\$/\\\\\\$/g' - -# Sed substitution to delay expansion of an escaped single quote. -delay_single_quote_subst='s/'\''/'\'\\\\\\\'\''/g' - -# Sed substitution to avoid accidental globbing in evaled expressions -no_glob_subst='s/\*/\\\*/g' - -ECHO='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' -ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO -ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO$ECHO - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to print strings" >&5 -$as_echo_n "checking how to print strings... " >&6; } -# Test print first, because it will be a builtin if present. -if test "X`( print -r -- -n ) 2>/dev/null`" = X-n && \ - test "X`print -r -- $ECHO 2>/dev/null`" = "X$ECHO"; then - ECHO='print -r --' -elif test "X`printf %s $ECHO 2>/dev/null`" = "X$ECHO"; then - ECHO='printf %s\n' -else - # Use this function as a fallback that always works. - func_fallback_echo () - { - eval 'cat <<_LTECHO_EOF -$1 -_LTECHO_EOF' - } - ECHO='func_fallback_echo' -fi - -# func_echo_all arg... -# Invoke $ECHO with all args, space-separated. -func_echo_all () -{ - $ECHO "" -} - -case "$ECHO" in - printf*) { $as_echo "$as_me:${as_lineno-$LINENO}: result: printf" >&5 -$as_echo "printf" >&6; } ;; - print*) { $as_echo "$as_me:${as_lineno-$LINENO}: result: print -r" >&5 -$as_echo "print -r" >&6; } ;; - *) { $as_echo "$as_me:${as_lineno-$LINENO}: result: cat" >&5 -$as_echo "cat" >&6; } ;; -esac - - - - - - - - - - - - - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for a sed that does not truncate output" >&5 $as_echo_n "checking for a sed that does not truncate output... " >&6; } -if ${ac_cv_path_SED+:} false; then : +if test "${ac_cv_path_SED+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_script=s/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb/ @@ -4665,7 +4480,7 @@ for ac_prog in sed gsed; do for ac_exec_ext in '' $ac_executable_extensions; do ac_path_SED="$as_dir/$ac_prog$ac_exec_ext" - as_fn_executable_p "$ac_path_SED" || continue + { test -f "$ac_path_SED" && $as_test_x "$ac_path_SED"; } || continue # Check for GNU ac_path_SED and select it if it is found. # Check for GNU $ac_path_SED case `"$ac_path_SED" --version 2>&1` in @@ -4700,7 +4515,7 @@ done IFS=$as_save_IFS if test -z "$ac_cv_path_SED"; then - as_fn_error $? "no acceptable sed could be found in \$PATH" "$LINENO" 5 + as_fn_error "no acceptable sed could be found in \$PATH" "$LINENO" 5 fi else ac_cv_path_SED=$SED @@ -4727,7 +4542,7 @@ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for grep that handles long lines and -e" >&5 $as_echo_n "checking for grep that handles long lines and -e... " >&6; } -if ${ac_cv_path_GREP+:} false; then : +if test "${ac_cv_path_GREP+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -z "$GREP"; then @@ -4741,7 +4556,7 @@ for ac_prog in grep ggrep; do for ac_exec_ext in '' $ac_executable_extensions; do ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext" - as_fn_executable_p "$ac_path_GREP" || continue + { test -f "$ac_path_GREP" && $as_test_x "$ac_path_GREP"; } || continue # Check for GNU ac_path_GREP and select it if it is found. # Check for GNU $ac_path_GREP case `"$ac_path_GREP" --version 2>&1` in @@ -4776,7 +4591,7 @@ done IFS=$as_save_IFS if test -z "$ac_cv_path_GREP"; then - as_fn_error $? "no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 + as_fn_error "no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 fi else ac_cv_path_GREP=$GREP @@ -4790,7 +4605,7 @@ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for egrep" >&5 $as_echo_n "checking for egrep... " >&6; } -if ${ac_cv_path_EGREP+:} false; then : +if test "${ac_cv_path_EGREP+set}" = set; then : $as_echo_n "(cached) " >&6 else if echo a | $GREP -E '(a|b)' >/dev/null 2>&1 @@ -4807,7 +4622,7 @@ for ac_prog in egrep; do for ac_exec_ext in '' $ac_executable_extensions; do ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext" - as_fn_executable_p "$ac_path_EGREP" || continue + { test -f "$ac_path_EGREP" && $as_test_x "$ac_path_EGREP"; } || continue # Check for GNU ac_path_EGREP and select it if it is found. # Check for GNU $ac_path_EGREP case `"$ac_path_EGREP" --version 2>&1` in @@ -4842,7 +4657,7 @@ done IFS=$as_save_IFS if test -z "$ac_cv_path_EGREP"; then - as_fn_error $? "no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 + as_fn_error "no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 fi else ac_cv_path_EGREP=$EGREP @@ -4857,7 +4672,7 @@ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for fgrep" >&5 $as_echo_n "checking for fgrep... " >&6; } -if ${ac_cv_path_FGREP+:} false; then : +if test "${ac_cv_path_FGREP+set}" = set; then : $as_echo_n "(cached) " >&6 else if echo 'ab*c' | $GREP -F 'ab*c' >/dev/null 2>&1 @@ -4874,7 +4689,7 @@ for ac_prog in fgrep; do for ac_exec_ext in '' $ac_executable_extensions; do ac_path_FGREP="$as_dir/$ac_prog$ac_exec_ext" - as_fn_executable_p "$ac_path_FGREP" || continue + { test -f "$ac_path_FGREP" && $as_test_x "$ac_path_FGREP"; } || continue # Check for GNU ac_path_FGREP and select it if it is found. # Check for GNU $ac_path_FGREP case `"$ac_path_FGREP" --version 2>&1` in @@ -4909,7 +4724,7 @@ done IFS=$as_save_IFS if test -z "$ac_cv_path_FGREP"; then - as_fn_error $? "no acceptable fgrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 + as_fn_error "no acceptable fgrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 fi else ac_cv_path_FGREP=$FGREP @@ -4988,7 +4803,7 @@ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for non-GNU ld" >&5 $as_echo_n "checking for non-GNU ld... " >&6; } fi -if ${lt_cv_path_LD+:} false; then : +if test "${lt_cv_path_LD+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -z "$LD"; then @@ -5025,10 +4840,10 @@ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi -test -z "$LD" && as_fn_error $? "no acceptable ld found in \$PATH" "$LINENO" 5 +test -z "$LD" && as_fn_error "no acceptable ld found in \$PATH" "$LINENO" 5 { $as_echo "$as_me:${as_lineno-$LINENO}: checking if the linker ($LD) is GNU ld" >&5 $as_echo_n "checking if the linker ($LD) is GNU ld... " >&6; } -if ${lt_cv_prog_gnu_ld+:} false; then : +if test "${lt_cv_prog_gnu_ld+set}" = set; then : $as_echo_n "(cached) " >&6 else # I'd rather use --version here, but apparently some GNU lds only accept -v. @@ -5055,7 +4870,7 @@ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for BSD- or MS-compatible name lister (nm)" >&5 $as_echo_n "checking for BSD- or MS-compatible name lister (nm)... " >&6; } -if ${lt_cv_path_NM+:} false; then : +if test "${lt_cv_path_NM+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$NM"; then @@ -5108,17 +4923,14 @@ NM="$lt_cv_path_NM" else # Didn't find any BSD compatible name lister, look for dumpbin. - if test -n "$DUMPBIN"; then : - # Let the user override the test. - else - if test -n "$ac_tool_prefix"; then - for ac_prog in dumpbin "link -dump" + if test -n "$ac_tool_prefix"; then + for ac_prog in "dumpbin -symbols" "link -dump -symbols" do # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. set dummy $ac_tool_prefix$ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_DUMPBIN+:} false; then : +if test "${ac_cv_prog_DUMPBIN+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$DUMPBIN"; then @@ -5130,7 +4942,7 @@ IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_DUMPBIN="$ac_tool_prefix$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -5156,13 +4968,13 @@ fi if test -z "$DUMPBIN"; then ac_ct_DUMPBIN=$DUMPBIN - for ac_prog in dumpbin "link -dump" + for ac_prog in "dumpbin -symbols" "link -dump -symbols" do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_ac_ct_DUMPBIN+:} false; then : +if test "${ac_cv_prog_ac_ct_DUMPBIN+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_DUMPBIN"; then @@ -5174,7 +4986,7 @@ IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_DUMPBIN="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -5211,15 +5023,6 @@ fi fi - case `$DUMPBIN -symbols /dev/null 2>&1 | sed '1q'` in - *COFF*) - DUMPBIN="$DUMPBIN -symbols" - ;; - *) - DUMPBIN=: - ;; - esac - fi if test "$DUMPBIN" != ":"; then NM="$DUMPBIN" @@ -5234,18 +5037,18 @@ { $as_echo "$as_me:${as_lineno-$LINENO}: checking the name lister ($NM) interface" >&5 $as_echo_n "checking the name lister ($NM) interface... " >&6; } -if ${lt_cv_nm_interface+:} false; then : +if test "${lt_cv_nm_interface+set}" = set; then : $as_echo_n "(cached) " >&6 else lt_cv_nm_interface="BSD nm" echo "int some_variable = 0;" > conftest.$ac_ext - (eval echo "\"\$as_me:$LINENO: $ac_compile\"" >&5) + (eval echo "\"\$as_me:5045: $ac_compile\"" >&5) (eval "$ac_compile" 2>conftest.err) cat conftest.err >&5 - (eval echo "\"\$as_me:$LINENO: $NM \\\"conftest.$ac_objext\\\"\"" >&5) + (eval echo "\"\$as_me:5048: $NM \\\"conftest.$ac_objext\\\"\"" >&5) (eval "$NM \"conftest.$ac_objext\"" 2>conftest.err > conftest.out) cat conftest.err >&5 - (eval echo "\"\$as_me:$LINENO: output\"" >&5) + (eval echo "\"\$as_me:5051: output\"" >&5) cat conftest.out >&5 if $GREP 'External.*some_variable' conftest.out > /dev/null; then lt_cv_nm_interface="MS dumpbin" @@ -5269,7 +5072,7 @@ # find the maximum length of command line arguments { $as_echo "$as_me:${as_lineno-$LINENO}: checking the maximum length of command line arguments" >&5 $as_echo_n "checking the maximum length of command line arguments... " >&6; } -if ${lt_cv_sys_max_cmd_len+:} false; then : +if test "${lt_cv_sys_max_cmd_len+set}" = set; then : $as_echo_n "(cached) " >&6 else i=0 @@ -5302,11 +5105,6 @@ lt_cv_sys_max_cmd_len=8192; ;; - mint*) - # On MiNT this can take a long time and run out of memory. - lt_cv_sys_max_cmd_len=8192; - ;; - amigaos*) # On AmigaOS with pdksh, this test takes hours, literally. # So we just punt and use a minimum line length of 8192. @@ -5332,11 +5130,6 @@ lt_cv_sys_max_cmd_len=196608 ;; - os2*) - # The test takes a long time on OS/2. - lt_cv_sys_max_cmd_len=8192 - ;; - osf*) # Dr. Hans Ekkehard Plesser reports seeing a kernel panic running configure # due to this test when exec_disable_arg_limit is 1 on Tru64. It is not @@ -5363,8 +5156,7 @@ ;; *) lt_cv_sys_max_cmd_len=`(getconf ARG_MAX) 2> /dev/null` - if test -n "$lt_cv_sys_max_cmd_len" && \ - test undefined != "$lt_cv_sys_max_cmd_len"; then + if test -n "$lt_cv_sys_max_cmd_len"; then lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4` lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3` else @@ -5377,8 +5169,8 @@ # If test is not a shell built-in, we'll probably end up computing a # maximum length that is only half of the actual maximum length, but # we can't tell. - while { test "X"`env echo "$teststring$teststring" 2>/dev/null` \ - = "X$teststring$teststring"; } >/dev/null 2>&1 && + while { test "X"`$SHELL $0 --fallback-echo "X$teststring$teststring" 2>/dev/null` \ + = "XX$teststring$teststring"; } >/dev/null 2>&1 && test $i != 17 # 1/2 MB should be enough do i=`expr $i + 1` @@ -5420,8 +5212,8 @@ # Try some XSI features xsi_shell=no ( _lt_dummy="a/b/c" - test "${_lt_dummy##*/},${_lt_dummy%/*},${_lt_dummy#??}"${_lt_dummy%"$_lt_dummy"}, \ - = c,a/b,b/c, \ + test "${_lt_dummy##*/},${_lt_dummy%/*},"${_lt_dummy%"$_lt_dummy"}, \ + = c,a/b,, \ && eval 'test $(( 1 + 1 )) -eq 2 \ && test "${#_lt_dummy}" -eq 5' ) >/dev/null 2>&1 \ && xsi_shell=yes @@ -5470,83 +5262,9 @@ -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to convert $build file names to $host format" >&5 -$as_echo_n "checking how to convert $build file names to $host format... " >&6; } -if ${lt_cv_to_host_file_cmd+:} false; then : - $as_echo_n "(cached) " >&6 -else - case $host in - *-*-mingw* ) - case $build in - *-*-mingw* ) # actually msys - lt_cv_to_host_file_cmd=func_convert_file_msys_to_w32 - ;; - *-*-cygwin* ) - lt_cv_to_host_file_cmd=func_convert_file_cygwin_to_w32 - ;; - * ) # otherwise, assume *nix - lt_cv_to_host_file_cmd=func_convert_file_nix_to_w32 - ;; - esac - ;; - *-*-cygwin* ) - case $build in - *-*-mingw* ) # actually msys - lt_cv_to_host_file_cmd=func_convert_file_msys_to_cygwin - ;; - *-*-cygwin* ) - lt_cv_to_host_file_cmd=func_convert_file_noop - ;; - * ) # otherwise, assume *nix - lt_cv_to_host_file_cmd=func_convert_file_nix_to_cygwin - ;; - esac - ;; - * ) # unhandled hosts (and "normal" native builds) - lt_cv_to_host_file_cmd=func_convert_file_noop - ;; -esac - -fi - -to_host_file_cmd=$lt_cv_to_host_file_cmd -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_to_host_file_cmd" >&5 -$as_echo "$lt_cv_to_host_file_cmd" >&6; } - - - - - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to convert $build file names to toolchain format" >&5 -$as_echo_n "checking how to convert $build file names to toolchain format... " >&6; } -if ${lt_cv_to_tool_file_cmd+:} false; then : - $as_echo_n "(cached) " >&6 -else - #assume ordinary cross tools, or native build. -lt_cv_to_tool_file_cmd=func_convert_file_noop -case $host in - *-*-mingw* ) - case $build in - *-*-mingw* ) # actually msys - lt_cv_to_tool_file_cmd=func_convert_file_msys_to_w32 - ;; - esac - ;; -esac - -fi - -to_tool_file_cmd=$lt_cv_to_tool_file_cmd -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_to_tool_file_cmd" >&5 -$as_echo "$lt_cv_to_tool_file_cmd" >&6; } - - - - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $LD option to reload object files" >&5 $as_echo_n "checking for $LD option to reload object files... " >&6; } -if ${lt_cv_ld_reload_flag+:} false; then : +if test "${lt_cv_ld_reload_flag+set}" = set; then : $as_echo_n "(cached) " >&6 else lt_cv_ld_reload_flag='-r' @@ -5560,11 +5278,6 @@ esac reload_cmds='$LD$reload_flag -o $output$reload_objs' case $host_os in - cygwin* | mingw* | pw32* | cegcc*) - if test "$GCC" != yes; then - reload_cmds=false - fi - ;; darwin*) if test "$GCC" = yes; then reload_cmds='$LTCC $LTCFLAGS -nostdlib ${wl}-r -o $output$reload_objs' @@ -5587,7 +5300,7 @@ set dummy ${ac_tool_prefix}objdump; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_OBJDUMP+:} false; then : +if test "${ac_cv_prog_OBJDUMP+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$OBJDUMP"; then @@ -5599,7 +5312,7 @@ IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_OBJDUMP="${ac_tool_prefix}objdump" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -5627,7 +5340,7 @@ set dummy objdump; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_ac_ct_OBJDUMP+:} false; then : +if test "${ac_cv_prog_ac_ct_OBJDUMP+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_OBJDUMP"; then @@ -5639,7 +5352,7 @@ IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_OBJDUMP="objdump" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -5686,7 +5399,7 @@ { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to recognize dependent libraries" >&5 $as_echo_n "checking how to recognize dependent libraries... " >&6; } -if ${lt_cv_deplibs_check_method+:} false; then : +if test "${lt_cv_deplibs_check_method+set}" = set; then : $as_echo_n "(cached) " >&6 else lt_cv_file_magic_cmd='$MAGIC_CMD' @@ -5728,18 +5441,16 @@ # Base MSYS/MinGW do not provide the 'file' command needed by # func_win32_libid shell function, so use a weaker test based on 'objdump', # unless we find 'file', for example because we are cross-compiling. - # func_win32_libid assumes BSD nm, so disallow it if using MS dumpbin. - if ( test "$lt_cv_nm_interface" = "BSD nm" && file / ) >/dev/null 2>&1; then + if ( file / ) >/dev/null 2>&1; then lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL' lt_cv_file_magic_cmd='func_win32_libid' else - # Keep this pattern in sync with the one in func_win32_libid. - lt_cv_deplibs_check_method='file_magic file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' + lt_cv_deplibs_check_method='file_magic file format pei*-i386(.*architecture: i386)?' lt_cv_file_magic_cmd='$OBJDUMP -f' fi ;; -cegcc*) +cegcc) # use the weaker test based on 'objdump'. See mingw*. lt_cv_deplibs_check_method='file_magic file format pe-arm-.*little(.*architecture: arm)?' lt_cv_file_magic_cmd='$OBJDUMP -f' @@ -5769,10 +5480,6 @@ lt_cv_deplibs_check_method=pass_all ;; -haiku*) - lt_cv_deplibs_check_method=pass_all - ;; - hpux10.20* | hpux11*) lt_cv_file_magic_cmd=/usr/bin/file case $host_cpu in @@ -5781,11 +5488,11 @@ lt_cv_file_magic_test_file=/usr/lib/hpux32/libc.so ;; hppa*64*) - lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|ELF[ -][0-9][0-9])(-bit)?( [LM]SB)? shared object( file)?[, -]* PA-RISC [0-9]\.[0-9]' + lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|ELF-[0-9][0-9]) shared object file - PA-RISC [0-9].[0-9]' lt_cv_file_magic_test_file=/usr/lib/pa20_64/libc.sl ;; *) - lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|PA-RISC[0-9]\.[0-9]) shared library' + lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|PA-RISC[0-9].[0-9]) shared library' lt_cv_file_magic_test_file=/usr/lib/libc.sl ;; esac @@ -5806,8 +5513,8 @@ lt_cv_deplibs_check_method=pass_all ;; -# This must be glibc/ELF. -linux* | k*bsd*-gnu | kopensolaris*-gnu) +# This must be Linux ELF. +linux* | k*bsd*-gnu) lt_cv_deplibs_check_method=pass_all ;; @@ -5888,21 +5595,6 @@ fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_deplibs_check_method" >&5 $as_echo "$lt_cv_deplibs_check_method" >&6; } - -file_magic_glob= -want_nocaseglob=no -if test "$build" = "$host"; then - case $host_os in - mingw* | pw32*) - if ( shopt | grep nocaseglob ) >/dev/null 2>&1; then - want_nocaseglob=yes - else - file_magic_glob=`echo aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ | $SED -e "s/\(..\)/s\/[\1]\/[\1]\/g;/g"` - fi - ;; - esac -fi - file_magic_cmd=$lt_cv_file_magic_cmd deplibs_check_method=$lt_cv_deplibs_check_method test -z "$deplibs_check_method" && deplibs_check_method=unknown @@ -5918,26 +5610,16 @@ - - - - - - - - - - if test -n "$ac_tool_prefix"; then - # Extract the first word of "${ac_tool_prefix}dlltool", so it can be a program name with args. -set dummy ${ac_tool_prefix}dlltool; ac_word=$2 + # Extract the first word of "${ac_tool_prefix}ar", so it can be a program name with args. +set dummy ${ac_tool_prefix}ar; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_DLLTOOL+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$DLLTOOL"; then - ac_cv_prog_DLLTOOL="$DLLTOOL" # Let the user override the test. +if test "${ac_cv_prog_AR+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$AR"; then + ac_cv_prog_AR="$AR" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH @@ -5945,8 +5627,8 @@ IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_DLLTOOL="${ac_tool_prefix}dlltool" + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_AR="${ac_tool_prefix}ar" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi @@ -5956,10 +5638,10 @@ fi fi -DLLTOOL=$ac_cv_prog_DLLTOOL -if test -n "$DLLTOOL"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $DLLTOOL" >&5 -$as_echo "$DLLTOOL" >&6; } +AR=$ac_cv_prog_AR +if test -n "$AR"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $AR" >&5 +$as_echo "$AR" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } @@ -5967,17 +5649,17 @@ fi -if test -z "$ac_cv_prog_DLLTOOL"; then - ac_ct_DLLTOOL=$DLLTOOL - # Extract the first word of "dlltool", so it can be a program name with args. -set dummy dlltool; ac_word=$2 +if test -z "$ac_cv_prog_AR"; then + ac_ct_AR=$AR + # Extract the first word of "ar", so it can be a program name with args. +set dummy ar; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_ac_ct_DLLTOOL+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$ac_ct_DLLTOOL"; then - ac_cv_prog_ac_ct_DLLTOOL="$ac_ct_DLLTOOL" # Let the user override the test. +if test "${ac_cv_prog_ac_ct_AR+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$ac_ct_AR"; then + ac_cv_prog_ac_ct_AR="$ac_ct_AR" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH @@ -5985,156 +5667,8 @@ IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_ac_ct_DLLTOOL="dlltool" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -ac_ct_DLLTOOL=$ac_cv_prog_ac_ct_DLLTOOL -if test -n "$ac_ct_DLLTOOL"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_DLLTOOL" >&5 -$as_echo "$ac_ct_DLLTOOL" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - if test "x$ac_ct_DLLTOOL" = x; then - DLLTOOL="false" - else - case $cross_compiling:$ac_tool_warned in -yes:) -{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 -$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} -ac_tool_warned=yes ;; -esac - DLLTOOL=$ac_ct_DLLTOOL - fi -else - DLLTOOL="$ac_cv_prog_DLLTOOL" -fi - -test -z "$DLLTOOL" && DLLTOOL=dlltool - - - - - - - - - - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to associate runtime and link libraries" >&5 -$as_echo_n "checking how to associate runtime and link libraries... " >&6; } -if ${lt_cv_sharedlib_from_linklib_cmd+:} false; then : - $as_echo_n "(cached) " >&6 -else - lt_cv_sharedlib_from_linklib_cmd='unknown' - -case $host_os in -cygwin* | mingw* | pw32* | cegcc*) - # two different shell functions defined in ltmain.sh - # decide which to use based on capabilities of $DLLTOOL - case `$DLLTOOL --help 2>&1` in - *--identify-strict*) - lt_cv_sharedlib_from_linklib_cmd=func_cygming_dll_for_implib - ;; - *) - lt_cv_sharedlib_from_linklib_cmd=func_cygming_dll_for_implib_fallback - ;; - esac - ;; -*) - # fallback: assume linklib IS sharedlib - lt_cv_sharedlib_from_linklib_cmd="$ECHO" - ;; -esac - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_sharedlib_from_linklib_cmd" >&5 -$as_echo "$lt_cv_sharedlib_from_linklib_cmd" >&6; } -sharedlib_from_linklib_cmd=$lt_cv_sharedlib_from_linklib_cmd -test -z "$sharedlib_from_linklib_cmd" && sharedlib_from_linklib_cmd=$ECHO - - - - - - - - -if test -n "$ac_tool_prefix"; then - for ac_prog in ar - do - # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. -set dummy $ac_tool_prefix$ac_prog; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_AR+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$AR"; then - ac_cv_prog_AR="$AR" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_AR="$ac_tool_prefix$ac_prog" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -AR=$ac_cv_prog_AR -if test -n "$AR"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $AR" >&5 -$as_echo "$AR" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - - test -n "$AR" && break - done -fi -if test -z "$AR"; then - ac_ct_AR=$AR - for ac_prog in ar -do - # Extract the first word of "$ac_prog", so it can be a program name with args. -set dummy $ac_prog; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_ac_ct_AR+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$ac_ct_AR"; then - ac_cv_prog_ac_ct_AR="$ac_ct_AR" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_ac_ct_AR="$ac_prog" + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_ac_ct_AR="ar" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi @@ -6153,10 +5687,6 @@ $as_echo "no" >&6; } fi - - test -n "$ac_ct_AR" && break -done - if test "x$ac_ct_AR" = x; then AR="false" else @@ -6168,72 +5698,16 @@ esac AR=$ac_ct_AR fi -fi - -: ${AR=ar} -: ${AR_FLAGS=cru} - - - - - - - - - - - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for archiver @FILE support" >&5 -$as_echo_n "checking for archiver @FILE support... " >&6; } -if ${lt_cv_ar_at_file+:} false; then : - $as_echo_n "(cached) " >&6 -else - lt_cv_ar_at_file=no - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - echo conftest.$ac_objext > conftest.lst - lt_ar_try='$AR $AR_FLAGS libconftest.a @conftest.lst >&5' - { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$lt_ar_try\""; } >&5 - (eval $lt_ar_try) 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } - if test "$ac_status" -eq 0; then - # Ensure the archiver fails upon bogus file names. - rm -f conftest.$ac_objext libconftest.a - { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$lt_ar_try\""; } >&5 - (eval $lt_ar_try) 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } - if test "$ac_status" -ne 0; then - lt_cv_ar_at_file=@ - fi - fi - rm -f conftest.* libconftest.a - -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_ar_at_file" >&5 -$as_echo "$lt_cv_ar_at_file" >&6; } - -if test "x$lt_cv_ar_at_file" = xno; then - archiver_list_spec= -else - archiver_list_spec=$lt_cv_ar_at_file -fi +else + AR="$ac_cv_prog_AR" +fi + +test -z "$AR" && AR=ar +test -z "$AR_FLAGS" && AR_FLAGS=cru + + + + @@ -6246,7 +5720,7 @@ set dummy ${ac_tool_prefix}strip; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_STRIP+:} false; then : +if test "${ac_cv_prog_STRIP+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$STRIP"; then @@ -6258,7 +5732,7 @@ IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_STRIP="${ac_tool_prefix}strip" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -6286,7 +5760,7 @@ set dummy strip; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_ac_ct_STRIP+:} false; then : +if test "${ac_cv_prog_ac_ct_STRIP+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_STRIP"; then @@ -6298,7 +5772,7 @@ IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_STRIP="strip" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -6345,7 +5819,7 @@ set dummy ${ac_tool_prefix}ranlib; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_RANLIB+:} false; then : +if test "${ac_cv_prog_RANLIB+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$RANLIB"; then @@ -6357,7 +5831,7 @@ IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_RANLIB="${ac_tool_prefix}ranlib" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -6385,7 +5859,7 @@ set dummy ranlib; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_ac_ct_RANLIB+:} false; then : +if test "${ac_cv_prog_ac_ct_RANLIB+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_RANLIB"; then @@ -6397,7 +5871,7 @@ IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_RANLIB="ranlib" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -6447,26 +5921,14 @@ if test -n "$RANLIB"; then case $host_os in openbsd*) - old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB -t \$tool_oldlib" + old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB -t \$oldlib" ;; *) - old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB \$tool_oldlib" + old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB \$oldlib" ;; esac - old_archive_cmds="$old_archive_cmds~\$RANLIB \$tool_oldlib" -fi - -case $host_os in - darwin*) - lock_old_archive_extraction=yes ;; - *) - lock_old_archive_extraction=no ;; -esac - - - - - + old_archive_cmds="$old_archive_cmds~\$RANLIB \$oldlib" +fi @@ -6514,7 +5976,7 @@ # Check for command to grab the raw symbol name followed by C symbol from nm. { $as_echo "$as_me:${as_lineno-$LINENO}: checking command to parse $NM output from $compiler object" >&5 $as_echo_n "checking command to parse $NM output from $compiler object... " >&6; } -if ${lt_cv_sys_global_symbol_pipe+:} false; then : +if test "${lt_cv_sys_global_symbol_pipe+set}" = set; then : $as_echo_n "(cached) " >&6 else @@ -6575,8 +6037,8 @@ lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^T .* \(.*\)$/extern int \1();/p' -e 's/^$symcode* .* \(.*\)$/extern char \1;/p'" # Transform an extracted symbol line into symbol name and symbol address -lt_cv_sys_global_symbol_to_c_name_address="sed -n -e 's/^: \([^ ]*\)[ ]*$/ {\\\"\1\\\", (void *) 0},/p' -e 's/^$symcode* \([^ ]*\) \([^ ]*\)$/ {\"\2\", (void *) \&\2},/p'" -lt_cv_sys_global_symbol_to_c_name_address_lib_prefix="sed -n -e 's/^: \([^ ]*\)[ ]*$/ {\\\"\1\\\", (void *) 0},/p' -e 's/^$symcode* \([^ ]*\) \(lib[^ ]*\)$/ {\"\2\", (void *) \&\2},/p' -e 's/^$symcode* \([^ ]*\) \([^ ]*\)$/ {\"lib\2\", (void *) \&\2},/p'" +lt_cv_sys_global_symbol_to_c_name_address="sed -n -e 's/^: \([^ ]*\) $/ {\\\"\1\\\", (void *) 0},/p' -e 's/^$symcode* \([^ ]*\) \([^ ]*\)$/ {\"\2\", (void *) \&\2},/p'" +lt_cv_sys_global_symbol_to_c_name_address_lib_prefix="sed -n -e 's/^: \([^ ]*\) $/ {\\\"\1\\\", (void *) 0},/p' -e 's/^$symcode* \([^ ]*\) \(lib[^ ]*\)$/ {\"\2\", (void *) \&\2},/p' -e 's/^$symcode* \([^ ]*\) \([^ ]*\)$/ {\"lib\2\", (void *) \&\2},/p'" # Handle CRLF in mingw tool chain opt_cr= @@ -6600,7 +6062,6 @@ # which start with @ or ?. lt_cv_sys_global_symbol_pipe="$AWK '"\ " {last_section=section; section=\$ 3};"\ -" /^COFF SYMBOL TABLE/{for(i in hide) delete hide[i]};"\ " /Section length .*#relocs.*(pick any)/{hide[last_section]=1};"\ " \$ 0!~/External *\|/{next};"\ " / 0+ UNDEF /{next}; / UNDEF \([^|]\)*()/{next};"\ @@ -6613,7 +6074,6 @@ else lt_cv_sys_global_symbol_pipe="sed -n -e 's/^.*[ ]\($symcode$symcode*\)[ ][ ]*$ac_symprfx$sympat$opt_cr$/$symxfrm/p'" fi - lt_cv_sys_global_symbol_pipe="$lt_cv_sys_global_symbol_pipe | sed '/ __gnu_lto/d'" # Check to see that the pipe works correctly. pipe_works=no @@ -6639,8 +6099,8 @@ test $ac_status = 0; }; then # Now try to grab the symbols. nlist=conftest.nm - if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$NM conftest.$ac_objext \| "$lt_cv_sys_global_symbol_pipe" \> $nlist\""; } >&5 - (eval $NM conftest.$ac_objext \| "$lt_cv_sys_global_symbol_pipe" \> $nlist) 2>&5 + if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$NM conftest.$ac_objext \| $lt_cv_sys_global_symbol_pipe \> $nlist\""; } >&5 + (eval $NM conftest.$ac_objext \| $lt_cv_sys_global_symbol_pipe \> $nlist) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && test -s "$nlist"; then @@ -6655,18 +6115,6 @@ if $GREP ' nm_test_var$' "$nlist" >/dev/null; then if $GREP ' nm_test_func$' "$nlist" >/dev/null; then cat <<_LT_EOF > conftest.$ac_ext -/* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests. */ -#if defined(_WIN32) || defined(__CYGWIN__) || defined(_WIN32_WCE) -/* DATA imports from DLLs on WIN32 con't be const, because runtime - relocations are performed -- see ld's documentation on pseudo-relocs. */ -# define LT_DLSYM_CONST -#elif defined(__osf__) -/* This system does not cope well with relocations in const data. */ -# define LT_DLSYM_CONST -#else -# define LT_DLSYM_CONST const -#endif - #ifdef __cplusplus extern "C" { #endif @@ -6678,7 +6126,7 @@ cat <<_LT_EOF >> conftest.$ac_ext /* The mapping between symbol names and symbols. */ -LT_DLSYM_CONST struct { +const struct { const char *name; void *address; } @@ -6704,8 +6152,8 @@ _LT_EOF # Now try linking the two files. mv conftest.$ac_objext conftstm.$ac_objext - lt_globsym_save_LIBS=$LIBS - lt_globsym_save_CFLAGS=$CFLAGS + lt_save_LIBS="$LIBS" + lt_save_CFLAGS="$CFLAGS" LIBS="conftstm.$ac_objext" CFLAGS="$CFLAGS$lt_prog_compiler_no_builtin_flag" if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_link\""; } >&5 @@ -6715,8 +6163,8 @@ test $ac_status = 0; } && test -s conftest${ac_exeext}; then pipe_works=yes fi - LIBS=$lt_globsym_save_LIBS - CFLAGS=$lt_globsym_save_CFLAGS + LIBS="$lt_save_LIBS" + CFLAGS="$lt_save_CFLAGS" else echo "cannot find nm_test_func in $nlist" >&5 fi @@ -6753,71 +6201,23 @@ $as_echo "ok" >&6; } fi -# Response file support. -if test "$lt_cv_nm_interface" = "MS dumpbin"; then - nm_file_list_spec='@' -elif $NM --help 2>/dev/null | grep '[@]FILE' >/dev/null; then - nm_file_list_spec='@' -fi - - - - - - - - - - - - - - - - - - - - - - - - - - - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for sysroot" >&5 -$as_echo_n "checking for sysroot... " >&6; } - -# Check whether --with-sysroot was given. -if test "${with_sysroot+set}" = set; then : - withval=$with_sysroot; -else - with_sysroot=no -fi - - -lt_sysroot= -case ${with_sysroot} in #( - yes) - if test "$GCC" = yes; then - lt_sysroot=`$CC --print-sysroot 2>/dev/null` - fi - ;; #( - /*) - lt_sysroot=`echo "$with_sysroot" | sed -e "$sed_quote_subst"` - ;; #( - no|'') - ;; #( - *) - { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${with_sysroot}" >&5 -$as_echo "${with_sysroot}" >&6; } - as_fn_error $? "The sysroot must be an absolute path." "$LINENO" 5 - ;; -esac - - { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${lt_sysroot:-no}" >&5 -$as_echo "${lt_sysroot:-no}" >&6; } + + + + + + + + + + + + + + + + + @@ -6854,7 +6254,7 @@ ;; *-*-irix6*) # Find out which ABI we are using. - echo '#line '$LINENO' "configure"' > conftest.$ac_ext + echo '#line 6257 "configure"' > conftest.$ac_ext if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 (eval $ac_compile) 2>&5 ac_status=$? @@ -6905,14 +6305,7 @@ LD="${LD-ld} -m elf_i386_fbsd" ;; x86_64-*linux*) - case `/usr/bin/file conftest.o` in - *x86-64*) - LD="${LD-ld} -m elf32_x86_64" - ;; - *) - LD="${LD-ld} -m elf_i386" - ;; - esac + LD="${LD-ld} -m elf_i386" ;; ppc64-*linux*|powerpc64-*linux*) LD="${LD-ld} -m elf32ppclinux" @@ -6955,7 +6348,7 @@ CFLAGS="$CFLAGS -belf" { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the C compiler needs -belf" >&5 $as_echo_n "checking whether the C compiler needs -belf... " >&6; } -if ${lt_cv_cc_needs_belf+:} false; then : +if test "${lt_cv_cc_needs_belf+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_ext=c @@ -6996,7 +6389,7 @@ CFLAGS="$SAVE_CFLAGS" fi ;; -*-*solaris*) +sparc*-*solaris*) # Find out which ABI we are using. echo 'int i;' > conftest.$ac_ext if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 @@ -7007,20 +6400,7 @@ case `/usr/bin/file conftest.o` in *64-bit*) case $lt_cv_prog_gnu_ld in - yes*) - case $host in - i?86-*-solaris*) - LD="${LD-ld} -m elf_x86_64" - ;; - sparc*-*-solaris*) - LD="${LD-ld} -m elf64_sparc" - ;; - esac - # GNU ld 2.21 introduced _sol2 emulations. Use them if available. - if ${LD-ld} -V | grep _sol2 >/dev/null 2>&1; then - LD="${LD-ld}_sol2" - fi - ;; + yes*) LD="${LD-ld} -m elf64_sparc" ;; *) if ${LD-ld} -64 -r -o conftest2.o conftest.o >/dev/null 2>&1; then LD="${LD-ld} -64" @@ -7036,123 +6416,6 @@ need_locks="$enable_libtool_lock" -if test -n "$ac_tool_prefix"; then - # Extract the first word of "${ac_tool_prefix}mt", so it can be a program name with args. -set dummy ${ac_tool_prefix}mt; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_MANIFEST_TOOL+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$MANIFEST_TOOL"; then - ac_cv_prog_MANIFEST_TOOL="$MANIFEST_TOOL" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_MANIFEST_TOOL="${ac_tool_prefix}mt" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -MANIFEST_TOOL=$ac_cv_prog_MANIFEST_TOOL -if test -n "$MANIFEST_TOOL"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MANIFEST_TOOL" >&5 -$as_echo "$MANIFEST_TOOL" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - -fi -if test -z "$ac_cv_prog_MANIFEST_TOOL"; then - ac_ct_MANIFEST_TOOL=$MANIFEST_TOOL - # Extract the first word of "mt", so it can be a program name with args. -set dummy mt; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_ac_ct_MANIFEST_TOOL+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$ac_ct_MANIFEST_TOOL"; then - ac_cv_prog_ac_ct_MANIFEST_TOOL="$ac_ct_MANIFEST_TOOL" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_ac_ct_MANIFEST_TOOL="mt" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -ac_ct_MANIFEST_TOOL=$ac_cv_prog_ac_ct_MANIFEST_TOOL -if test -n "$ac_ct_MANIFEST_TOOL"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_MANIFEST_TOOL" >&5 -$as_echo "$ac_ct_MANIFEST_TOOL" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - if test "x$ac_ct_MANIFEST_TOOL" = x; then - MANIFEST_TOOL=":" - else - case $cross_compiling:$ac_tool_warned in -yes:) -{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 -$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} -ac_tool_warned=yes ;; -esac - MANIFEST_TOOL=$ac_ct_MANIFEST_TOOL - fi -else - MANIFEST_TOOL="$ac_cv_prog_MANIFEST_TOOL" -fi - -test -z "$MANIFEST_TOOL" && MANIFEST_TOOL=mt -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if $MANIFEST_TOOL is a manifest tool" >&5 -$as_echo_n "checking if $MANIFEST_TOOL is a manifest tool... " >&6; } -if ${lt_cv_path_mainfest_tool+:} false; then : - $as_echo_n "(cached) " >&6 -else - lt_cv_path_mainfest_tool=no - echo "$as_me:$LINENO: $MANIFEST_TOOL '-?'" >&5 - $MANIFEST_TOOL '-?' 2>conftest.err > conftest.out - cat conftest.err >&5 - if $GREP 'Manifest Tool' conftest.out > /dev/null; then - lt_cv_path_mainfest_tool=yes - fi - rm -f conftest* -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_path_mainfest_tool" >&5 -$as_echo "$lt_cv_path_mainfest_tool" >&6; } -if test "x$lt_cv_path_mainfest_tool" != xyes; then - MANIFEST_TOOL=: -fi - - - - - case $host_os in rhapsody* | darwin*) @@ -7161,7 +6424,7 @@ set dummy ${ac_tool_prefix}dsymutil; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_DSYMUTIL+:} false; then : +if test "${ac_cv_prog_DSYMUTIL+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$DSYMUTIL"; then @@ -7173,7 +6436,7 @@ IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_DSYMUTIL="${ac_tool_prefix}dsymutil" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -7201,7 +6464,7 @@ set dummy dsymutil; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_ac_ct_DSYMUTIL+:} false; then : +if test "${ac_cv_prog_ac_ct_DSYMUTIL+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_DSYMUTIL"; then @@ -7213,7 +6476,7 @@ IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_DSYMUTIL="dsymutil" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -7253,7 +6516,7 @@ set dummy ${ac_tool_prefix}nmedit; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_NMEDIT+:} false; then : +if test "${ac_cv_prog_NMEDIT+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$NMEDIT"; then @@ -7265,7 +6528,7 @@ IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_NMEDIT="${ac_tool_prefix}nmedit" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -7293,7 +6556,7 @@ set dummy nmedit; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_ac_ct_NMEDIT+:} false; then : +if test "${ac_cv_prog_ac_ct_NMEDIT+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_NMEDIT"; then @@ -7305,7 +6568,7 @@ IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_NMEDIT="nmedit" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -7345,7 +6608,7 @@ set dummy ${ac_tool_prefix}lipo; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_LIPO+:} false; then : +if test "${ac_cv_prog_LIPO+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$LIPO"; then @@ -7357,7 +6620,7 @@ IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_LIPO="${ac_tool_prefix}lipo" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -7385,7 +6648,7 @@ set dummy lipo; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_ac_ct_LIPO+:} false; then : +if test "${ac_cv_prog_ac_ct_LIPO+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_LIPO"; then @@ -7397,7 +6660,7 @@ IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_LIPO="lipo" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -7437,7 +6700,7 @@ set dummy ${ac_tool_prefix}otool; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_OTOOL+:} false; then : +if test "${ac_cv_prog_OTOOL+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$OTOOL"; then @@ -7449,7 +6712,7 @@ IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_OTOOL="${ac_tool_prefix}otool" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -7477,7 +6740,7 @@ set dummy otool; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_ac_ct_OTOOL+:} false; then : +if test "${ac_cv_prog_ac_ct_OTOOL+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_OTOOL"; then @@ -7489,7 +6752,7 @@ IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_OTOOL="otool" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -7529,7 +6792,7 @@ set dummy ${ac_tool_prefix}otool64; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_OTOOL64+:} false; then : +if test "${ac_cv_prog_OTOOL64+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$OTOOL64"; then @@ -7541,7 +6804,7 @@ IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_OTOOL64="${ac_tool_prefix}otool64" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -7569,7 +6832,7 @@ set dummy otool64; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_ac_ct_OTOOL64+:} false; then : +if test "${ac_cv_prog_ac_ct_OTOOL64+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_OTOOL64"; then @@ -7581,7 +6844,7 @@ IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_OTOOL64="otool64" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -7644,7 +6907,7 @@ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for -single_module linker flag" >&5 $as_echo_n "checking for -single_module linker flag... " >&6; } -if ${lt_cv_apple_cc_single_mod+:} false; then : +if test "${lt_cv_apple_cc_single_mod+set}" = set; then : $as_echo_n "(cached) " >&6 else lt_cv_apple_cc_single_mod=no @@ -7660,13 +6923,7 @@ $LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \ -dynamiclib -Wl,-single_module conftest.c 2>conftest.err _lt_result=$? - # If there is a non-empty error log, and "single_module" - # appears in it, assume the flag caused a linker warning - if test -s conftest.err && $GREP single_module conftest.err; then - cat conftest.err >&5 - # Otherwise, if the output was created with a 0 exit code from - # the compiler, it worked. - elif test -f libconftest.dylib && test $_lt_result -eq 0; then + if test -f libconftest.dylib && test ! -s conftest.err && test $_lt_result = 0; then lt_cv_apple_cc_single_mod=yes else cat conftest.err >&5 @@ -7677,10 +6934,9 @@ fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_apple_cc_single_mod" >&5 $as_echo "$lt_cv_apple_cc_single_mod" >&6; } - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for -exported_symbols_list linker flag" >&5 $as_echo_n "checking for -exported_symbols_list linker flag... " >&6; } -if ${lt_cv_ld_exported_symbols_list+:} false; then : +if test "${lt_cv_ld_exported_symbols_list+set}" = set; then : $as_echo_n "(cached) " >&6 else lt_cv_ld_exported_symbols_list=no @@ -7710,41 +6966,6 @@ fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_ld_exported_symbols_list" >&5 $as_echo "$lt_cv_ld_exported_symbols_list" >&6; } - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for -force_load linker flag" >&5 -$as_echo_n "checking for -force_load linker flag... " >&6; } -if ${lt_cv_ld_force_load+:} false; then : - $as_echo_n "(cached) " >&6 -else - lt_cv_ld_force_load=no - cat > conftest.c << _LT_EOF -int forced_loaded() { return 2;} -_LT_EOF - echo "$LTCC $LTCFLAGS -c -o conftest.o conftest.c" >&5 - $LTCC $LTCFLAGS -c -o conftest.o conftest.c 2>&5 - echo "$AR cru libconftest.a conftest.o" >&5 - $AR cru libconftest.a conftest.o 2>&5 - echo "$RANLIB libconftest.a" >&5 - $RANLIB libconftest.a 2>&5 - cat > conftest.c << _LT_EOF -int main() { return 0;} -_LT_EOF - echo "$LTCC $LTCFLAGS $LDFLAGS -o conftest conftest.c -Wl,-force_load,./libconftest.a" >&5 - $LTCC $LTCFLAGS $LDFLAGS -o conftest conftest.c -Wl,-force_load,./libconftest.a 2>conftest.err - _lt_result=$? - if test -s conftest.err && $GREP force_load conftest.err; then - cat conftest.err >&5 - elif test -f conftest && test $_lt_result -eq 0 && $GREP forced_load conftest >/dev/null 2>&1 ; then - lt_cv_ld_force_load=yes - else - cat conftest.err >&5 - fi - rm -f conftest.err libconftest.a conftest conftest.c - rm -rf conftest.dSYM - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_ld_force_load" >&5 -$as_echo "$lt_cv_ld_force_load" >&6; } case $host_os in rhapsody* | darwin1.[012]) _lt_dar_allow_undefined='${wl}-undefined ${wl}suppress' ;; @@ -7772,7 +6993,7 @@ else _lt_dar_export_syms='~$NMEDIT -s $output_objdir/${libname}-symbols.expsym ${lib}' fi - if test "$DSYMUTIL" != ":" && test "$lt_cv_ld_force_load" = "no"; then + if test "$DSYMUTIL" != ":"; then _lt_dsymutil='~$DSYMUTIL $lib || :' else _lt_dsymutil= @@ -7792,7 +7013,7 @@ CPP= fi if test -z "$CPP"; then - if ${ac_cv_prog_CPP+:} false; then : + if test "${ac_cv_prog_CPP+set}" = set; then : $as_echo_n "(cached) " >&6 else # Double quotes because CPP needs to be expanded @@ -7822,7 +7043,7 @@ # Broken: fails on valid input. continue fi -rm -f conftest.err conftest.i conftest.$ac_ext +rm -f conftest.err conftest.$ac_ext # OK, works on sane cases. Now check whether nonexistent headers # can be detected and how. @@ -7838,11 +7059,11 @@ ac_preproc_ok=: break fi -rm -f conftest.err conftest.i conftest.$ac_ext +rm -f conftest.err conftest.$ac_ext done # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. -rm -f conftest.i conftest.err conftest.$ac_ext +rm -f conftest.err conftest.$ac_ext if $ac_preproc_ok; then : break fi @@ -7881,7 +7102,7 @@ # Broken: fails on valid input. continue fi -rm -f conftest.err conftest.i conftest.$ac_ext +rm -f conftest.err conftest.$ac_ext # OK, works on sane cases. Now check whether nonexistent headers # can be detected and how. @@ -7897,18 +7118,18 @@ ac_preproc_ok=: break fi -rm -f conftest.err conftest.i conftest.$ac_ext +rm -f conftest.err conftest.$ac_ext done # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. -rm -f conftest.i conftest.err conftest.$ac_ext +rm -f conftest.err conftest.$ac_ext if $ac_preproc_ok; then : else { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error $? "C preprocessor \"$CPP\" fails sanity check -See \`config.log' for more details" "$LINENO" 5; } +as_fn_error "C preprocessor \"$CPP\" fails sanity check +See \`config.log' for more details." "$LINENO" 5; } fi ac_ext=c @@ -7920,7 +7141,7 @@ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ANSI C header files" >&5 $as_echo_n "checking for ANSI C header files... " >&6; } -if ${ac_cv_header_stdc+:} false; then : +if test "${ac_cv_header_stdc+set}" = set; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext @@ -8037,7 +7258,8 @@ as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default " -if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : +eval as_val=\$$as_ac_Header + if test "x$as_val" = x""yes; then : cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF @@ -8051,7 +7273,7 @@ do : ac_fn_c_check_header_compile "$LINENO" "dlfcn.h" "ac_cv_header_dlfcn_h" "$ac_includes_default " -if test "x$ac_cv_header_dlfcn_h" = xyes; then : +if test "x$ac_cv_header_dlfcn_h" = x""yes; then : cat >>confdefs.h <<_ACEOF #define HAVE_DLFCN_H 1 _ACEOF @@ -8062,8 +7284,6 @@ - - # Set options @@ -8139,22 +7359,7 @@ # Check whether --with-pic was given. if test "${with_pic+set}" = set; then : - withval=$with_pic; lt_p=${PACKAGE-default} - case $withval in - yes|no) pic_mode=$withval ;; - *) - pic_mode=default - # Look at the argument we got. We use all the common list separators. - lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," - for lt_pkg in $withval; do - IFS="$lt_save_ifs" - if test "X$lt_pkg" = "X$lt_p"; then - pic_mode=yes - fi - done - IFS="$lt_save_ifs" - ;; - esac + withval=$with_pic; pic_mode="$withval" else pic_mode=default fi @@ -8231,11 +7436,6 @@ - - - - - test -z "$LN_S" && LN_S="ln -s" @@ -8257,7 +7457,7 @@ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for objdir" >&5 $as_echo_n "checking for objdir... " >&6; } -if ${lt_cv_objdir+:} false; then : +if test "${lt_cv_objdir+set}" = set; then : $as_echo_n "(cached) " >&6 else rm -f .libs 2>/dev/null @@ -8285,6 +7485,19 @@ + + + + + + + + + + + + + case $host_os in aix3*) # AIX sometimes has problems with the GCC collect2 program. For some @@ -8297,6 +7510,23 @@ ;; esac +# Sed substitution that helps us do robust quoting. It backslashifies +# metacharacters that are still active within double-quoted strings. +sed_quote_subst='s/\(["`$\\]\)/\\\1/g' + +# Same as above, but do not quote variable references. +double_quote_subst='s/\(["`\\]\)/\\\1/g' + +# Sed substitution to delay expansion of an escaped shell variable in a +# double_quote_subst'ed string. +delay_variable_subst='s/\\\\\\\\\\\$/\\\\\\$/g' + +# Sed substitution to delay expansion of an escaped single quote. +delay_single_quote_subst='s/'\''/'\'\\\\\\\'\''/g' + +# Sed substitution to avoid accidental globbing in evaled expressions +no_glob_subst='s/\*/\\\*/g' + # Global variables: ofile=libtool can_build_shared=yes @@ -8325,7 +7555,7 @@ *) break;; esac done -cc_basename=`$ECHO "$cc_temp" | $SED "s%.*/%%; s%^$host_alias-%%"` +cc_basename=`$ECHO "X$cc_temp" | $Xsed -e 's%.*/%%' -e "s%^$host_alias-%%"` # Only perform the check for file, if the check method requires it @@ -8335,7 +7565,7 @@ if test "$file_magic_cmd" = '$MAGIC_CMD'; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ${ac_tool_prefix}file" >&5 $as_echo_n "checking for ${ac_tool_prefix}file... " >&6; } -if ${lt_cv_path_MAGIC_CMD+:} false; then : +if test "${lt_cv_path_MAGIC_CMD+set}" = set; then : $as_echo_n "(cached) " >&6 else case $MAGIC_CMD in @@ -8401,7 +7631,7 @@ if test -n "$ac_tool_prefix"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for file" >&5 $as_echo_n "checking for file... " >&6; } -if ${lt_cv_path_MAGIC_CMD+:} false; then : +if test "${lt_cv_path_MAGIC_CMD+set}" = set; then : $as_echo_n "(cached) " >&6 else case $MAGIC_CMD in @@ -8534,16 +7764,11 @@ lt_prog_compiler_no_builtin_flag= if test "$GCC" = yes; then - case $cc_basename in - nvcc*) - lt_prog_compiler_no_builtin_flag=' -Xcompiler -fno-builtin' ;; - *) - lt_prog_compiler_no_builtin_flag=' -fno-builtin' ;; - esac + lt_prog_compiler_no_builtin_flag=' -fno-builtin' { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler supports -fno-rtti -fno-exceptions" >&5 $as_echo_n "checking if $compiler supports -fno-rtti -fno-exceptions... " >&6; } -if ${lt_cv_prog_compiler_rtti_exceptions+:} false; then : +if test "${lt_cv_prog_compiler_rtti_exceptions+set}" = set; then : $as_echo_n "(cached) " >&6 else lt_cv_prog_compiler_rtti_exceptions=no @@ -8559,15 +7784,15 @@ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&5) + (eval echo "\"\$as_me:7787: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 + echo "$as_me:7791: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. - $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' >conftest.exp + $ECHO "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' >conftest.exp $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then lt_cv_prog_compiler_rtti_exceptions=yes @@ -8596,6 +7821,8 @@ lt_prog_compiler_pic= lt_prog_compiler_static= +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $compiler option to produce PIC" >&5 +$as_echo_n "checking for $compiler option to produce PIC... " >&6; } if test "$GCC" = yes; then lt_prog_compiler_wl='-Wl,' @@ -8643,12 +7870,6 @@ lt_prog_compiler_pic='-fno-common' ;; - haiku*) - # PIC is the default for Haiku. - # The "-static" flag exists, but is broken. - lt_prog_compiler_static= - ;; - hpux*) # PIC is the default for 64-bit PA HP-UX, but not for 32-bit # PA HP-UX. On IA64 HP-UX, PIC is the default but the pic flag @@ -8691,15 +7912,6 @@ lt_prog_compiler_pic='-fPIC' ;; esac - - case $cc_basename in - nvcc*) # Cuda Compiler Driver 2.2 - lt_prog_compiler_wl='-Xlinker ' - if test -n "$lt_prog_compiler_pic"; then - lt_prog_compiler_pic="-Xcompiler $lt_prog_compiler_pic" - fi - ;; - esac else # PORTME Check for flag to pass linker flags through the system compiler. case $host_os in @@ -8741,7 +7953,7 @@ lt_prog_compiler_static='-non_shared' ;; - linux* | k*bsd*-gnu | kopensolaris*-gnu) + linux* | k*bsd*-gnu) case $cc_basename in # old Intel for x86_64 which still supported -KPIC. ecc*) @@ -8762,13 +7974,7 @@ lt_prog_compiler_pic='--shared' lt_prog_compiler_static='--static' ;; - nagfor*) - # NAG Fortran compiler - lt_prog_compiler_wl='-Wl,-Wl,,' - lt_prog_compiler_pic='-PIC' - lt_prog_compiler_static='-Bstatic' - ;; - pgcc* | pgf77* | pgf90* | pgf95* | pgfortran*) + pgcc* | pgf77* | pgf90* | pgf95*) # Portland Group compilers (*not* the Pentium gcc compiler, # which looks to be a dead project) lt_prog_compiler_wl='-Wl,' @@ -8780,40 +7986,25 @@ # All Alpha code is PIC. lt_prog_compiler_static='-non_shared' ;; - xl* | bgxl* | bgf* | mpixl*) - # IBM XL C 8.0/Fortran 10.1, 11.1 on PPC and BlueGene + xl*) + # IBM XL C 8.0/Fortran 10.1 on PPC lt_prog_compiler_wl='-Wl,' lt_prog_compiler_pic='-qpic' lt_prog_compiler_static='-qstaticlink' ;; *) case `$CC -V 2>&1 | sed 5q` in - *Sun\ Ceres\ Fortran* | *Sun*Fortran*\ [1-7].* | *Sun*Fortran*\ 8.[0-3]*) - # Sun Fortran 8.3 passes all unrecognized flags to the linker - lt_prog_compiler_pic='-KPIC' - lt_prog_compiler_static='-Bstatic' - lt_prog_compiler_wl='' - ;; - *Sun\ F* | *Sun*Fortran*) - lt_prog_compiler_pic='-KPIC' - lt_prog_compiler_static='-Bstatic' - lt_prog_compiler_wl='-Qoption ld ' - ;; *Sun\ C*) # Sun C 5.9 lt_prog_compiler_pic='-KPIC' lt_prog_compiler_static='-Bstatic' lt_prog_compiler_wl='-Wl,' ;; - *Intel*\ [CF]*Compiler*) - lt_prog_compiler_wl='-Wl,' - lt_prog_compiler_pic='-fPIC' - lt_prog_compiler_static='-static' - ;; - *Portland\ Group*) - lt_prog_compiler_wl='-Wl,' - lt_prog_compiler_pic='-fpic' + *Sun\ F*) + # Sun Fortran 8.3 passes all unrecognized flags to the linker + lt_prog_compiler_pic='-KPIC' lt_prog_compiler_static='-Bstatic' + lt_prog_compiler_wl='' ;; esac ;; @@ -8845,7 +8036,7 @@ lt_prog_compiler_pic='-KPIC' lt_prog_compiler_static='-Bstatic' case $cc_basename in - f77* | f90* | f95* | sunf77* | sunf90* | sunf95*) + f77* | f90* | f95*) lt_prog_compiler_wl='-Qoption ld ';; *) lt_prog_compiler_wl='-Wl,';; @@ -8902,17 +8093,13 @@ lt_prog_compiler_pic="$lt_prog_compiler_pic -DPIC" ;; esac - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $compiler option to produce PIC" >&5 -$as_echo_n "checking for $compiler option to produce PIC... " >&6; } -if ${lt_cv_prog_compiler_pic+:} false; then : - $as_echo_n "(cached) " >&6 -else - lt_cv_prog_compiler_pic=$lt_prog_compiler_pic -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_pic" >&5 -$as_echo "$lt_cv_prog_compiler_pic" >&6; } -lt_prog_compiler_pic=$lt_cv_prog_compiler_pic +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_prog_compiler_pic" >&5 +$as_echo "$lt_prog_compiler_pic" >&6; } + + + + + # # Check to make sure the PIC flag actually works. @@ -8920,7 +8107,7 @@ if test -n "$lt_prog_compiler_pic"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler PIC flag $lt_prog_compiler_pic works" >&5 $as_echo_n "checking if $compiler PIC flag $lt_prog_compiler_pic works... " >&6; } -if ${lt_cv_prog_compiler_pic_works+:} false; then : +if test "${lt_cv_prog_compiler_pic_works+set}" = set; then : $as_echo_n "(cached) " >&6 else lt_cv_prog_compiler_pic_works=no @@ -8936,15 +8123,15 @@ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&5) + (eval echo "\"\$as_me:8126: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 + echo "$as_me:8130: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. - $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' >conftest.exp + $ECHO "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' >conftest.exp $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then lt_cv_prog_compiler_pic_works=yes @@ -8973,18 +8160,13 @@ - - - - - # # Check to make sure the static flag actually works. # wl=$lt_prog_compiler_wl eval lt_tmp_static_flag=\"$lt_prog_compiler_static\" { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler static flag $lt_tmp_static_flag works" >&5 $as_echo_n "checking if $compiler static flag $lt_tmp_static_flag works... " >&6; } -if ${lt_cv_prog_compiler_static_works+:} false; then : +if test "${lt_cv_prog_compiler_static_works+set}" = set; then : $as_echo_n "(cached) " >&6 else lt_cv_prog_compiler_static_works=no @@ -8997,7 +8179,7 @@ if test -s conftest.err; then # Append any errors to the config.log. cat conftest.err 1>&5 - $ECHO "$_lt_linker_boilerplate" | $SED '/^$/d' > conftest.exp + $ECHO "X$_lt_linker_boilerplate" | $Xsed -e '/^$/d' > conftest.exp $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 if diff conftest.exp conftest.er2 >/dev/null; then lt_cv_prog_compiler_static_works=yes @@ -9027,7 +8209,7 @@ { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler supports -c -o file.$ac_objext" >&5 $as_echo_n "checking if $compiler supports -c -o file.$ac_objext... " >&6; } -if ${lt_cv_prog_compiler_c_o+:} false; then : +if test "${lt_cv_prog_compiler_c_o+set}" = set; then : $as_echo_n "(cached) " >&6 else lt_cv_prog_compiler_c_o=no @@ -9046,16 +8228,16 @@ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&5) + (eval echo "\"\$as_me:8231: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 + echo "$as_me:8235: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings - $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' > out/conftest.exp + $ECHO "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' > out/conftest.exp $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2 if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then lt_cv_prog_compiler_c_o=yes @@ -9082,7 +8264,7 @@ { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler supports -c -o file.$ac_objext" >&5 $as_echo_n "checking if $compiler supports -c -o file.$ac_objext... " >&6; } -if ${lt_cv_prog_compiler_c_o+:} false; then : +if test "${lt_cv_prog_compiler_c_o+set}" = set; then : $as_echo_n "(cached) " >&6 else lt_cv_prog_compiler_c_o=no @@ -9101,16 +8283,16 @@ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&5) + (eval echo "\"\$as_me:8286: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 + echo "$as_me:8290: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings - $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' > out/conftest.exp + $ECHO "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' > out/conftest.exp $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2 if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then lt_cv_prog_compiler_c_o=yes @@ -9176,6 +8358,7 @@ hardcode_direct=no hardcode_direct_absolute=no hardcode_libdir_flag_spec= + hardcode_libdir_flag_spec_ld= hardcode_libdir_separator= hardcode_minus_L=no hardcode_shlibpath_var=unsupported @@ -9222,33 +8405,7 @@ esac ld_shlibs=yes - - # On some targets, GNU ld is compatible enough with the native linker - # that we're better off using the native interface for both. - lt_use_gnu_ld_interface=no if test "$with_gnu_ld" = yes; then - case $host_os in - aix*) - # The AIX port of GNU ld has always aspired to compatibility - # with the native linker. However, as the warning in the GNU ld - # block says, versions before 2.19.5* couldn't really create working - # shared libraries, regardless of the interface used. - case `$LD -v 2>&1` in - *\ \(GNU\ Binutils\)\ 2.19.5*) ;; - *\ \(GNU\ Binutils\)\ 2.[2-9]*) ;; - *\ \(GNU\ Binutils\)\ [3-9]*) ;; - *) - lt_use_gnu_ld_interface=yes - ;; - esac - ;; - *) - lt_use_gnu_ld_interface=yes - ;; - esac - fi - - if test "$lt_use_gnu_ld_interface" = yes; then # If archive_cmds runs LD, not CC, wlarc should be empty wlarc='${wl}' @@ -9266,7 +8423,6 @@ fi supports_anon_versioning=no case `$LD -v 2>&1` in - *GNU\ gold*) supports_anon_versioning=yes ;; *\ [01].* | *\ 2.[0-9].* | *\ 2.10.*) ;; # catch versions < 2.11 *\ 2.11.93.0.2\ *) supports_anon_versioning=yes ;; # RH7.3 ... *\ 2.11.92.0.12\ *) supports_anon_versioning=yes ;; # Mandrake 8.2 ... @@ -9282,12 +8438,11 @@ ld_shlibs=no cat <<_LT_EOF 1>&2 -*** Warning: the GNU linker, at least up to release 2.19, is reported +*** Warning: the GNU linker, at least up to release 2.9.1, is reported *** to be unable to reliably create shared libraries on AIX. *** Therefore, libtool is disabling shared libraries support. If you -*** really care for shared libraries, you may want to install binutils -*** 2.20 or above, or modify your PATH so that a non-GNU linker is found. -*** You will then need to restart the configuration process. +*** really care for shared libraries, you may want to modify your PATH +*** so that a non-GNU linker is found, and then restart. _LT_EOF fi @@ -9323,12 +8478,10 @@ # _LT_TAGVAR(hardcode_libdir_flag_spec, ) is actually meaningless, # as there is no search path for DLLs. hardcode_libdir_flag_spec='-L$libdir' - export_dynamic_flag_spec='${wl}--export-all-symbols' allow_undefined_flag=unsupported always_export_symbols=no enable_shared_with_static_runtimes=yes - export_symbols_cmds='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[BCDGRS][ ]/s/.*[ ]\([^ ]*\)/\1 DATA/;s/^.*[ ]__nm__\([^ ]*\)[ ][^ ]*/\1 DATA/;/^I[ ]/d;/^[AITW][ ]/s/.* //'\'' | sort | uniq > $export_symbols' - exclude_expsyms='[_]+GLOBAL_OFFSET_TABLE_|[_]+GLOBAL__[FID]_.*|[_]+head_[A-Za-z0-9_]+_dll|[A-Za-z0-9_]+_dll_iname' + export_symbols_cmds='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[BCDGRS][ ]/s/.*[ ]\([^ ]*\)/\1 DATA/'\'' | $SED -e '\''/^[AITW][ ]/s/.*[ ]//'\'' | sort | uniq > $export_symbols' if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' @@ -9346,11 +8499,6 @@ fi ;; - haiku*) - archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' - link_all_deplibs=yes - ;; - interix[3-9]*) hardcode_direct=no hardcode_shlibpath_var=no @@ -9366,7 +8514,7 @@ archive_expsym_cmds='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' ;; - gnu* | linux* | tpf* | k*bsd*-gnu | kopensolaris*-gnu) + gnu* | linux* | tpf* | k*bsd*-gnu) tmp_diet=no if test "$host_os" = linux-dietlibc; then case $cc_basename in @@ -9376,16 +8524,15 @@ if $LD --help 2>&1 | $EGREP ': supported targets:.* elf' > /dev/null \ && test "$tmp_diet" = no then - tmp_addflag=' $pic_flag' + tmp_addflag= tmp_sharedflag='-shared' case $cc_basename,$host_cpu in pgcc*) # Portland Group C compiler - whole_archive_flag_spec='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive' + whole_archive_flag_spec='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $ECHO \"$new_convenience\"` ${wl}--no-whole-archive' tmp_addflag=' $pic_flag' ;; - pgf77* | pgf90* | pgf95* | pgfortran*) - # Portland Group f77 and f90 compilers - whole_archive_flag_spec='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive' + pgf77* | pgf90* | pgf95*) # Portland Group f77 and f90 compilers + whole_archive_flag_spec='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $ECHO \"$new_convenience\"` ${wl}--no-whole-archive' tmp_addflag=' $pic_flag -Mnomain' ;; ecc*,ia64* | icc*,ia64*) # Intel C compiler on ia64 tmp_addflag=' -i_dynamic' ;; @@ -9396,17 +8543,13 @@ lf95*) # Lahey Fortran 8.1 whole_archive_flag_spec= tmp_sharedflag='--shared' ;; - xl[cC]* | bgxl[cC]* | mpixl[cC]*) # IBM XL C 8.0 on PPC (deal with xlf below) + xl[cC]*) # IBM XL C 8.0 on PPC (deal with xlf below) tmp_sharedflag='-qmkshrobj' tmp_addflag= ;; - nvcc*) # Cuda Compiler Driver 2.2 - whole_archive_flag_spec='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive' - compiler_needs_object=yes - ;; esac case `$CC -V 2>&1 | sed 5q` in *Sun\ C*) # Sun C 5.9 - whole_archive_flag_spec='${wl}--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive' + whole_archive_flag_spec='${wl}--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; $ECHO \"$new_convenience\"` ${wl}--no-whole-archive' compiler_needs_object=yes tmp_sharedflag='-G' ;; *Sun\ F*) # Sun Fortran 8.3 @@ -9422,16 +8565,17 @@ fi case $cc_basename in - xlf* | bgf* | bgxlf* | mpixlf*) + xlf*) # IBM XL Fortran 10.1 on PPC cannot create shared libs itself whole_archive_flag_spec='--whole-archive$convenience --no-whole-archive' - hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' - archive_cmds='$LD -shared $libobjs $deplibs $linker_flags -soname $soname -o $lib' + hardcode_libdir_flag_spec= + hardcode_libdir_flag_spec_ld='-rpath $libdir' + archive_cmds='$LD -shared $libobjs $deplibs $compiler_flags -soname $soname -o $lib' if test "x$supports_anon_versioning" = xyes; then archive_expsym_cmds='echo "{ global:" > $output_objdir/$libname.ver~ cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ echo "local: *; };" >> $output_objdir/$libname.ver~ - $LD -shared $libobjs $deplibs $linker_flags -soname $soname -version-script $output_objdir/$libname.ver -o $lib' + $LD -shared $libobjs $deplibs $compiler_flags -soname $soname -version-script $output_objdir/$libname.ver -o $lib' fi ;; esac @@ -9445,8 +8589,8 @@ archive_cmds='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib' wlarc= else - archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' - archive_expsym_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' + archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' fi ;; @@ -9464,8 +8608,8 @@ _LT_EOF elif $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then - archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' - archive_expsym_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' + archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' else ld_shlibs=no fi @@ -9511,8 +8655,8 @@ *) if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then - archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' - archive_expsym_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' + archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' else ld_shlibs=no fi @@ -9552,10 +8696,8 @@ else # If we're using GNU nm, then we don't want the "-C" option. # -C means demangle to AIX nm, but means don't demangle with GNU nm - # Also, AIX nm treats weak defined symbols like other global - # defined symbols, whereas GNU nm marks them as "W". if $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then - export_symbols_cmds='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W")) && (substr(\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols' + export_symbols_cmds='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && (substr(\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols' else export_symbols_cmds='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && (substr(\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols' fi @@ -9642,13 +8784,7 @@ allow_undefined_flag='-berok' # Determine the default libpath from the value encoded in an # empty executable. - if test "${lt_cv_aix_libpath+set}" = set; then - aix_libpath=$lt_cv_aix_libpath -else - if ${lt_cv_aix_libpath_+:} false; then : - $as_echo_n "(cached) " >&6 -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int @@ -9661,32 +8797,25 @@ _ACEOF if ac_fn_c_try_link "$LINENO"; then : - lt_aix_libpath_sed=' - /Import File Strings/,/^$/ { - /^0/ { - s/^0 *\([^ ]*\) *$/\1/ - p - } - }' - lt_cv_aix_libpath_=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` - # Check for a 64-bit object if we didn't find anything. - if test -z "$lt_cv_aix_libpath_"; then - lt_cv_aix_libpath_=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` - fi +lt_aix_libpath_sed=' + /Import File Strings/,/^$/ { + /^0/ { + s/^0 *\(.*\)$/\1/ + p + } + }' +aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` +# Check for a 64-bit object if we didn't find anything. +if test -z "$aix_libpath"; then + aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` +fi fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext - if test -z "$lt_cv_aix_libpath_"; then - lt_cv_aix_libpath_="/usr/lib:/lib" - fi - -fi - - aix_libpath=$lt_cv_aix_libpath_ -fi +if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi hardcode_libdir_flag_spec='${wl}-blibpath:$libdir:'"$aix_libpath" - archive_expsym_cmds='$CC -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then func_echo_all "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag" + archive_expsym_cmds='$CC -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then $ECHO "X${wl}${allow_undefined_flag}" | $Xsed; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag" else if test "$host_cpu" = ia64; then hardcode_libdir_flag_spec='${wl}-R $libdir:/usr/lib:/lib' @@ -9695,13 +8824,7 @@ else # Determine the default libpath from the value encoded in an # empty executable. - if test "${lt_cv_aix_libpath+set}" = set; then - aix_libpath=$lt_cv_aix_libpath -else - if ${lt_cv_aix_libpath_+:} false; then : - $as_echo_n "(cached) " >&6 -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int @@ -9714,42 +8837,30 @@ _ACEOF if ac_fn_c_try_link "$LINENO"; then : - lt_aix_libpath_sed=' - /Import File Strings/,/^$/ { - /^0/ { - s/^0 *\([^ ]*\) *$/\1/ - p - } - }' - lt_cv_aix_libpath_=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` - # Check for a 64-bit object if we didn't find anything. - if test -z "$lt_cv_aix_libpath_"; then - lt_cv_aix_libpath_=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` - fi +lt_aix_libpath_sed=' + /Import File Strings/,/^$/ { + /^0/ { + s/^0 *\(.*\)$/\1/ + p + } + }' +aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` +# Check for a 64-bit object if we didn't find anything. +if test -z "$aix_libpath"; then + aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` +fi fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext - if test -z "$lt_cv_aix_libpath_"; then - lt_cv_aix_libpath_="/usr/lib:/lib" - fi - -fi - - aix_libpath=$lt_cv_aix_libpath_ -fi +if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi hardcode_libdir_flag_spec='${wl}-blibpath:$libdir:'"$aix_libpath" # Warning - without using the other run time loading flags, # -berok will link without error, but may produce a broken library. no_undefined_flag=' ${wl}-bernotok' allow_undefined_flag=' ${wl}-berok' - if test "$with_gnu_ld" = yes; then - # We only use this code for GNU lds that support --whole-archive. - whole_archive_flag_spec='${wl}--whole-archive$convenience ${wl}--no-whole-archive' - else - # Exported symbols can be pulled into shared objects from archives - whole_archive_flag_spec='$convenience' - fi + # Exported symbols can be pulled into shared objects from archives + whole_archive_flag_spec='$convenience' archive_cmds_need_lc=yes # This is similar to how AIX traditionally builds its shared libraries. archive_expsym_cmds="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname' @@ -9781,64 +8892,20 @@ # Microsoft Visual C++. # hardcode_libdir_flag_spec is actually meaningless, as there is # no search path for DLLs. - case $cc_basename in - cl*) - # Native MSVC - hardcode_libdir_flag_spec=' ' - allow_undefined_flag=unsupported - always_export_symbols=yes - file_list_spec='@' - # Tell ltmain to make .lib files, not .a files. - libext=lib - # Tell ltmain to make .dll files, not .so files. - shrext_cmds=".dll" - # FIXME: Setting linknames here is a bad hack. - archive_cmds='$CC -o $output_objdir/$soname $libobjs $compiler_flags $deplibs -Wl,-dll~linknames=' - archive_expsym_cmds='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then - sed -n -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' -e '1\\\!p' < $export_symbols > $output_objdir/$soname.exp; - else - sed -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' < $export_symbols > $output_objdir/$soname.exp; - fi~ - $CC -o $tool_output_objdir$soname $libobjs $compiler_flags $deplibs "@$tool_output_objdir$soname.exp" -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~ - linknames=' - # The linker will not automatically build a static lib if we build a DLL. - # _LT_TAGVAR(old_archive_from_new_cmds, )='true' - enable_shared_with_static_runtimes=yes - exclude_expsyms='_NULL_IMPORT_DESCRIPTOR|_IMPORT_DESCRIPTOR_.*' - export_symbols_cmds='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[BCDGRS][ ]/s/.*[ ]\([^ ]*\)/\1,DATA/'\'' | $SED -e '\''/^[AITW][ ]/s/.*[ ]//'\'' | sort | uniq > $export_symbols' - # Don't use ranlib - old_postinstall_cmds='chmod 644 $oldlib' - postlink_cmds='lt_outputfile="@OUTPUT@"~ - lt_tool_outputfile="@TOOL_OUTPUT@"~ - case $lt_outputfile in - *.exe|*.EXE) ;; - *) - lt_outputfile="$lt_outputfile.exe" - lt_tool_outputfile="$lt_tool_outputfile.exe" - ;; - esac~ - if test "$MANIFEST_TOOL" != ":" && test -f "$lt_outputfile.manifest"; then - $MANIFEST_TOOL -manifest "$lt_tool_outputfile.manifest" -outputresource:"$lt_tool_outputfile" || exit 1; - $RM "$lt_outputfile.manifest"; - fi' - ;; - *) - # Assume MSVC wrapper - hardcode_libdir_flag_spec=' ' - allow_undefined_flag=unsupported - # Tell ltmain to make .lib files, not .a files. - libext=lib - # Tell ltmain to make .dll files, not .so files. - shrext_cmds=".dll" - # FIXME: Setting linknames here is a bad hack. - archive_cmds='$CC -o $lib $libobjs $compiler_flags `func_echo_all "$deplibs" | $SED '\''s/ -lc$//'\''` -link -dll~linknames=' - # The linker will automatically build a .lib file if we build a DLL. - old_archive_from_new_cmds='true' - # FIXME: Should let the user specify the lib program. - old_archive_cmds='lib -OUT:$oldlib$oldobjs$old_deplibs' - enable_shared_with_static_runtimes=yes - ;; - esac + hardcode_libdir_flag_spec=' ' + allow_undefined_flag=unsupported + # Tell ltmain to make .lib files, not .a files. + libext=lib + # Tell ltmain to make .dll files, not .so files. + shrext_cmds=".dll" + # FIXME: Setting linknames here is a bad hack. + archive_cmds='$CC -o $lib $libobjs $compiler_flags `$ECHO "X$deplibs" | $Xsed -e '\''s/ -lc$//'\''` -link -dll~linknames=' + # The linker will automatically build a .lib file if we build a DLL. + old_archive_from_new_cmds='true' + # FIXME: Should let the user specify the lib program. + old_archive_cmds='lib -OUT:$oldlib$oldobjs$old_deplibs' + fix_srcfile_path='`cygpath -w "$srcfile"`' + enable_shared_with_static_runtimes=yes ;; darwin* | rhapsody*) @@ -9848,12 +8915,7 @@ hardcode_direct=no hardcode_automatic=yes hardcode_shlibpath_var=unsupported - if test "$lt_cv_ld_force_load" = "yes"; then - whole_archive_flag_spec='`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience ${wl}-force_load,$conv\"; done; func_echo_all \"$new_convenience\"`' - - else - whole_archive_flag_spec='' - fi + whole_archive_flag_spec='' link_all_deplibs=yes allow_undefined_flag="$_lt_dar_allow_undefined" case $cc_basename in @@ -9861,7 +8923,7 @@ *) _lt_dar_can_shared=$GCC ;; esac if test "$_lt_dar_can_shared" = "yes"; then - output_verbose_link_cmd=func_echo_all + output_verbose_link_cmd=echo archive_cmds="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod${_lt_dsymutil}" module_cmds="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}" archive_expsym_cmds="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}" @@ -9879,6 +8941,10 @@ hardcode_shlibpath_var=no ;; + freebsd1*) + ld_shlibs=no + ;; + # FreeBSD 2.2.[012] allows us to include c++rt0.o to get C++ constructor # support. Future versions do this automatically, but an explicit c++rt0.o # does not break anything, and helps significantly (at the cost of a little @@ -9891,7 +8957,7 @@ ;; # Unfortunately, older versions of FreeBSD 2 do not have this feature. - freebsd2.*) + freebsd2*) archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' hardcode_direct=yes hardcode_minus_L=yes @@ -9900,7 +8966,7 @@ # FreeBSD 3 and greater uses gcc -shared to do shared libraries. freebsd* | dragonfly*) - archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' + archive_cmds='$CC -shared -o $lib $libobjs $deplibs $compiler_flags' hardcode_libdir_flag_spec='-R$libdir' hardcode_direct=yes hardcode_shlibpath_var=no @@ -9908,7 +8974,7 @@ hpux9*) if test "$GCC" = yes; then - archive_cmds='$RM $output_objdir/$soname~$CC -shared $pic_flag ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $libobjs $deplibs $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' + archive_cmds='$RM $output_objdir/$soname~$CC -shared -fPIC ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $libobjs $deplibs $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' else archive_cmds='$RM $output_objdir/$soname~$LD -b +b $install_libdir -o $output_objdir/$soname $libobjs $deplibs $linker_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' fi @@ -9923,13 +8989,14 @@ ;; hpux10*) - if test "$GCC" = yes && test "$with_gnu_ld" = no; then - archive_cmds='$CC -shared $pic_flag ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' + if test "$GCC" = yes -a "$with_gnu_ld" = no; then + archive_cmds='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' else archive_cmds='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags' fi if test "$with_gnu_ld" = no; then hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir' + hardcode_libdir_flag_spec_ld='+b $libdir' hardcode_libdir_separator=: hardcode_direct=yes hardcode_direct_absolute=yes @@ -9941,16 +9008,16 @@ ;; hpux11*) - if test "$GCC" = yes && test "$with_gnu_ld" = no; then + if test "$GCC" = yes -a "$with_gnu_ld" = no; then case $host_cpu in hppa*64*) archive_cmds='$CC -shared ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' ;; ia64*) - archive_cmds='$CC -shared $pic_flag ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags' + archive_cmds='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags' ;; *) - archive_cmds='$CC -shared $pic_flag ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' + archive_cmds='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' ;; esac else @@ -9962,46 +9029,7 @@ archive_cmds='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags' ;; *) - - # Older versions of the 11.00 compiler do not understand -b yet - # (HP92453-01 A.11.01.20 doesn't, HP92453-01 B.11.X.35175-35176.GP does) - { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $CC understands -b" >&5 -$as_echo_n "checking if $CC understands -b... " >&6; } -if ${lt_cv_prog_compiler__b+:} false; then : - $as_echo_n "(cached) " >&6 -else - lt_cv_prog_compiler__b=no - save_LDFLAGS="$LDFLAGS" - LDFLAGS="$LDFLAGS -b" - echo "$lt_simple_link_test_code" > conftest.$ac_ext - if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then - # The linker can only warn and ignore the option if not recognized - # So say no if there are warnings - if test -s conftest.err; then - # Append any errors to the config.log. - cat conftest.err 1>&5 - $ECHO "$_lt_linker_boilerplate" | $SED '/^$/d' > conftest.exp - $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 - if diff conftest.exp conftest.er2 >/dev/null; then - lt_cv_prog_compiler__b=yes - fi - else - lt_cv_prog_compiler__b=yes - fi - fi - $RM -r conftest* - LDFLAGS="$save_LDFLAGS" - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler__b" >&5 -$as_echo "$lt_cv_prog_compiler__b" >&6; } - -if test x"$lt_cv_prog_compiler__b" = xyes; then - archive_cmds='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' -else - archive_cmds='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags' -fi - + archive_cmds='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' ;; esac fi @@ -10029,39 +9057,26 @@ irix5* | irix6* | nonstopux*) if test "$GCC" = yes; then - archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' + archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' # Try to use the -exported_symbol ld option, if it does not # work, assume that -exports_file does not work either and # implicitly export all symbols. - # This should be the same for all languages, so no per-tag cache variable. - { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the $host_os linker accepts -exported_symbol" >&5 -$as_echo_n "checking whether the $host_os linker accepts -exported_symbol... " >&6; } -if ${lt_cv_irix_exported_symbol+:} false; then : - $as_echo_n "(cached) " >&6 -else - save_LDFLAGS="$LDFLAGS" - LDFLAGS="$LDFLAGS -shared ${wl}-exported_symbol ${wl}foo ${wl}-update_registry ${wl}/dev/null" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext + save_LDFLAGS="$LDFLAGS" + LDFLAGS="$LDFLAGS -shared ${wl}-exported_symbol ${wl}foo ${wl}-update_registry ${wl}/dev/null" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ -int foo (void) { return 0; } +int foo(void) {} _ACEOF if ac_fn_c_try_link "$LINENO"; then : - lt_cv_irix_exported_symbol=yes -else - lt_cv_irix_exported_symbol=no + archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations ${wl}-exports_file ${wl}$export_symbols -o $lib' + fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext - LDFLAGS="$save_LDFLAGS" -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_irix_exported_symbol" >&5 -$as_echo "$lt_cv_irix_exported_symbol" >&6; } - if test "$lt_cv_irix_exported_symbol" = yes; then - archive_expsym_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations ${wl}-exports_file ${wl}$export_symbols -o $lib' - fi + LDFLAGS="$save_LDFLAGS" else - archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib' - archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -exports_file $export_symbols -o $lib' + archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib' + archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -exports_file $export_symbols -o $lib' fi archive_cmds_need_lc='no' hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' @@ -10123,17 +9138,17 @@ hardcode_libdir_flag_spec='-L$libdir' hardcode_minus_L=yes allow_undefined_flag=unsupported - archive_cmds='$ECHO "LIBRARY $libname INITINSTANCE" > $output_objdir/$libname.def~$ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~echo DATA >> $output_objdir/$libname.def~echo " SINGLE NONSHARED" >> $output_objdir/$libname.def~echo EXPORTS >> $output_objdir/$libname.def~emxexp $libobjs >> $output_objdir/$libname.def~$CC -Zdll -Zcrtdll -o $lib $libobjs $deplibs $compiler_flags $output_objdir/$libname.def' + archive_cmds='$ECHO "LIBRARY $libname INITINSTANCE" > $output_objdir/$libname.def~$ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~$ECHO DATA >> $output_objdir/$libname.def~$ECHO " SINGLE NONSHARED" >> $output_objdir/$libname.def~$ECHO EXPORTS >> $output_objdir/$libname.def~emxexp $libobjs >> $output_objdir/$libname.def~$CC -Zdll -Zcrtdll -o $lib $libobjs $deplibs $compiler_flags $output_objdir/$libname.def' old_archive_from_new_cmds='emximp -o $output_objdir/$libname.a $output_objdir/$libname.def' ;; osf3*) if test "$GCC" = yes; then allow_undefined_flag=' ${wl}-expect_unresolved ${wl}\*' - archive_cmds='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' + archive_cmds='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' else allow_undefined_flag=' -expect_unresolved \*' - archive_cmds='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib' + archive_cmds='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib' fi archive_cmds_need_lc='no' hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' @@ -10143,13 +9158,13 @@ osf4* | osf5*) # as osf3* with the addition of -msym flag if test "$GCC" = yes; then allow_undefined_flag=' ${wl}-expect_unresolved ${wl}\*' - archive_cmds='$CC -shared${allow_undefined_flag} $pic_flag $libobjs $deplibs $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' + archive_cmds='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' else allow_undefined_flag=' -expect_unresolved \*' - archive_cmds='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags -msym -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib' + archive_cmds='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags -msym -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib' archive_expsym_cmds='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done; printf "%s\\n" "-hidden">> $lib.exp~ - $CC -shared${allow_undefined_flag} ${wl}-input ${wl}$lib.exp $compiler_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && $ECHO "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib~$RM $lib.exp' + $CC -shared${allow_undefined_flag} ${wl}-input ${wl}$lib.exp $compiler_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib~$RM $lib.exp' # Both c and cxx compiler support -rpath directly hardcode_libdir_flag_spec='-rpath $libdir' @@ -10162,9 +9177,9 @@ no_undefined_flag=' -z defs' if test "$GCC" = yes; then wlarc='${wl}' - archive_cmds='$CC -shared $pic_flag ${wl}-z ${wl}text ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' + archive_cmds='$CC -shared ${wl}-z ${wl}text ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' archive_expsym_cmds='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ - $CC -shared $pic_flag ${wl}-z ${wl}text ${wl}-M ${wl}$lib.exp ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp' + $CC -shared ${wl}-z ${wl}text ${wl}-M ${wl}$lib.exp ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp' else case `$CC -V 2>&1` in *"Compilers 5.0"*) @@ -10352,50 +9367,44 @@ # to ld, don't add -lc before -lgcc. { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether -lc should be explicitly linked in" >&5 $as_echo_n "checking whether -lc should be explicitly linked in... " >&6; } -if ${lt_cv_archive_cmds_need_lc+:} false; then : - $as_echo_n "(cached) " >&6 -else - $RM conftest* - echo "$lt_simple_compile_test_code" > conftest.$ac_ext - - if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 + $RM conftest* + echo "$lt_simple_compile_test_code" > conftest.$ac_ext + + if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 (eval $ac_compile) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } 2>conftest.err; then - soname=conftest - lib=conftest - libobjs=conftest.$ac_objext - deplibs= - wl=$lt_prog_compiler_wl - pic_flag=$lt_prog_compiler_pic - compiler_flags=-v - linker_flags=-v - verstring= - output_objdir=. - libname=conftest - lt_save_allow_undefined_flag=$allow_undefined_flag - allow_undefined_flag= - if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$archive_cmds 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1\""; } >&5 + soname=conftest + lib=conftest + libobjs=conftest.$ac_objext + deplibs= + wl=$lt_prog_compiler_wl + pic_flag=$lt_prog_compiler_pic + compiler_flags=-v + linker_flags=-v + verstring= + output_objdir=. + libname=conftest + lt_save_allow_undefined_flag=$allow_undefined_flag + allow_undefined_flag= + if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$archive_cmds 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1\""; } >&5 (eval $archive_cmds 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } - then - lt_cv_archive_cmds_need_lc=no - else - lt_cv_archive_cmds_need_lc=yes - fi - allow_undefined_flag=$lt_save_allow_undefined_flag - else - cat conftest.err 1>&5 - fi - $RM conftest* - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_archive_cmds_need_lc" >&5 -$as_echo "$lt_cv_archive_cmds_need_lc" >&6; } - archive_cmds_need_lc=$lt_cv_archive_cmds_need_lc + then + archive_cmds_need_lc=no + else + archive_cmds_need_lc=yes + fi + allow_undefined_flag=$lt_save_allow_undefined_flag + else + cat conftest.err 1>&5 + fi + $RM conftest* + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $archive_cmds_need_lc" >&5 +$as_echo "$archive_cmds_need_lc" >&6; } ;; esac fi @@ -10553,6 +9562,11 @@ + + + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking dynamic linker characteristics" >&5 $as_echo_n "checking dynamic linker characteristics... " >&6; } @@ -10561,23 +9575,16 @@ darwin*) lt_awk_arg="/^libraries:/,/LR/" ;; *) lt_awk_arg="/^libraries:/" ;; esac - case $host_os in - mingw* | cegcc*) lt_sed_strip_eq="s,=\([A-Za-z]:\),\1,g" ;; - *) lt_sed_strip_eq="s,=/,/,g" ;; - esac - lt_search_path_spec=`$CC -print-search-dirs | awk $lt_awk_arg | $SED -e "s/^libraries://" -e $lt_sed_strip_eq` - case $lt_search_path_spec in - *\;*) + lt_search_path_spec=`$CC -print-search-dirs | awk $lt_awk_arg | $SED -e "s/^libraries://" -e "s,=/,/,g"` + if $ECHO "$lt_search_path_spec" | $GREP ';' >/dev/null ; then # if the path contains ";" then we assume it to be the separator # otherwise default to the standard path separator (i.e. ":") - it is # assumed that no part of a normal pathname contains ";" but that should # okay in the real world where ";" in dirpaths is itself problematic. - lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED 's/;/ /g'` - ;; - *) - lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED "s/$PATH_SEPARATOR/ /g"` - ;; - esac + lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED -e 's/;/ /g'` + else + lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` + fi # Ok, now we have the path, separated by spaces, we can step through it # and add multilib dir if necessary. lt_tmp_lt_search_path_spec= @@ -10590,7 +9597,7 @@ lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path" fi done - lt_search_path_spec=`$ECHO "$lt_tmp_lt_search_path_spec" | awk ' + lt_search_path_spec=`$ECHO $lt_tmp_lt_search_path_spec | awk ' BEGIN {RS=" "; FS="/|\n";} { lt_foo=""; lt_count=0; @@ -10610,13 +9617,7 @@ if (lt_foo != "") { lt_freq[lt_foo]++; } if (lt_freq[lt_foo] == 1) { print lt_foo; } }'` - # AWK program above erroneously prepends '/' to C:/dos/paths - # for these hosts. - case $host_os in - mingw* | cegcc*) lt_search_path_spec=`$ECHO "$lt_search_path_spec" |\ - $SED 's,/\([A-Za-z]:\),\1,g'` ;; - esac - sys_lib_search_path_spec=`$ECHO "$lt_search_path_spec" | $lt_NL2SP` + sys_lib_search_path_spec=`$ECHO $lt_search_path_spec` else sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib" fi @@ -10642,7 +9643,7 @@ case $host_os in aix3*) - version_type=linux # correct to gnu/linux during the next big refactor + version_type=linux library_names_spec='${libname}${release}${shared_ext}$versuffix $libname.a' shlibpath_var=LIBPATH @@ -10651,7 +9652,7 @@ ;; aix[4-9]*) - version_type=linux # correct to gnu/linux during the next big refactor + version_type=linux need_lib_prefix=no need_version=no hardcode_into_libs=yes @@ -10704,7 +9705,7 @@ m68k) library_names_spec='$libname.ixlibrary $libname.a' # Create ${libname}_ixlibrary.a entries in /sys/libs. - finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`func_echo_all "$lib" | $SED '\''s%^.*/\([^/]*\)\.ixlibrary$%\1%'\''`; test $RM /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done' + finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`$ECHO "X$lib" | $Xsed -e '\''s%^.*/\([^/]*\)\.ixlibrary$%\1%'\''`; test $RM /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done' ;; esac ;; @@ -10716,7 +9717,7 @@ ;; bsdi[45]*) - version_type=linux # correct to gnu/linux during the next big refactor + version_type=linux need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' @@ -10735,9 +9736,8 @@ need_version=no need_lib_prefix=no - case $GCC,$cc_basename in - yes,*) - # gcc + case $GCC,$host_os in + yes,cygwin* | yes,mingw* | yes,pw32* | yes,cegcc*) library_names_spec='$libname.dll.a' # DLL is installed to $(libdir)/../bin by postinstall_cmds postinstall_cmds='base_file=`basename \${file}`~ @@ -10758,83 +9758,36 @@ cygwin*) # Cygwin DLLs use 'cyg' prefix rather than 'lib' soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}' - - sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/lib/w32api" + sys_lib_search_path_spec="/usr/lib /lib/w32api /lib /usr/local/lib" ;; mingw* | cegcc*) # MinGW DLLs use traditional 'lib' prefix soname_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}' + sys_lib_search_path_spec=`$CC -print-search-dirs | $GREP "^libraries:" | $SED -e "s/^libraries://" -e "s,=/,/,g"` + if $ECHO "$sys_lib_search_path_spec" | $GREP ';[c-zC-Z]:/' >/dev/null; then + # It is most probably a Windows format PATH printed by + # mingw gcc, but we are running on Cygwin. Gcc prints its search + # path with ; separators, and with drive letters. We can handle the + # drive letters (cygwin fileutils understands them), so leave them, + # especially as we might pass files found there to a mingw objdump, + # which wouldn't understand a cygwinified path. Ahh. + sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'` + else + sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` + fi ;; pw32*) # pw32 DLLs use 'pw' prefix rather than 'lib' library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}' ;; esac - dynamic_linker='Win32 ld.exe' ;; - *,cl*) - # Native MSVC - libname_spec='$name' - soname_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}' - library_names_spec='${libname}.dll.lib' - - case $build_os in - mingw*) - sys_lib_search_path_spec= - lt_save_ifs=$IFS - IFS=';' - for lt_path in $LIB - do - IFS=$lt_save_ifs - # Let DOS variable expansion print the short 8.3 style file name. - lt_path=`cd "$lt_path" 2>/dev/null && cmd //C "for %i in (".") do @echo %~si"` - sys_lib_search_path_spec="$sys_lib_search_path_spec $lt_path" - done - IFS=$lt_save_ifs - # Convert to MSYS style. - sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | sed -e 's|\\\\|/|g' -e 's| \\([a-zA-Z]\\):| /\\1|g' -e 's|^ ||'` - ;; - cygwin*) - # Convert to unix form, then to dos form, then back to unix form - # but this time dos style (no spaces!) so that the unix form looks - # like /cygdrive/c/PROGRA~1:/cygdr... - sys_lib_search_path_spec=`cygpath --path --unix "$LIB"` - sys_lib_search_path_spec=`cygpath --path --dos "$sys_lib_search_path_spec" 2>/dev/null` - sys_lib_search_path_spec=`cygpath --path --unix "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` - ;; - *) - sys_lib_search_path_spec="$LIB" - if $ECHO "$sys_lib_search_path_spec" | $GREP ';[c-zC-Z]:/' >/dev/null; then - # It is most probably a Windows format PATH. - sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'` - else - sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` - fi - # FIXME: find the short name or the path components, as spaces are - # common. (e.g. "Program Files" -> "PROGRA~1") - ;; - esac - - # DLL is installed to $(libdir)/../bin by postinstall_cmds - postinstall_cmds='base_file=`basename \${file}`~ - dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~ - dldir=$destdir/`dirname \$dlpath`~ - test -d \$dldir || mkdir -p \$dldir~ - $install_prog $dir/$dlname \$dldir/$dlname' - postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~ - dlpath=$dir/\$dldll~ - $RM \$dlpath' - shlibpath_overrides_runpath=yes - dynamic_linker='Win32 link.exe' - ;; - *) - # Assume MSVC wrapper library_names_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext} $libname.lib' - dynamic_linker='Win32 ld.exe' ;; esac + dynamic_linker='Win32 ld.exe' # FIXME: first we should search . and the directory the executable is in shlibpath_var=PATH ;; @@ -10855,7 +9808,7 @@ ;; dgux*) - version_type=linux # correct to gnu/linux during the next big refactor + version_type=linux need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname$shared_ext' @@ -10863,6 +9816,10 @@ shlibpath_var=LD_LIBRARY_PATH ;; +freebsd1*) + dynamic_linker=no + ;; + freebsd* | dragonfly*) # DragonFly does not have aout. When/if they implement a new # versioning mechanism, adjust this. @@ -10870,7 +9827,7 @@ objformat=`/usr/bin/objformat` else case $host_os in - freebsd[23].*) objformat=aout ;; + freebsd[123]*) objformat=aout ;; *) objformat=elf ;; esac fi @@ -10888,7 +9845,7 @@ esac shlibpath_var=LD_LIBRARY_PATH case $host_os in - freebsd2.*) + freebsd2*) shlibpath_overrides_runpath=yes ;; freebsd3.[01]* | freebsdelf3.[01]*) @@ -10908,26 +9865,12 @@ ;; gnu*) - version_type=linux # correct to gnu/linux during the next big refactor + version_type=linux need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH - shlibpath_overrides_runpath=no - hardcode_into_libs=yes - ;; - -haiku*) - version_type=linux # correct to gnu/linux during the next big refactor - need_lib_prefix=no - need_version=no - dynamic_linker="$host_os runtime_loader" - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - shlibpath_var=LIBRARY_PATH - shlibpath_overrides_runpath=yes - sys_lib_dlsearch_path_spec='/boot/home/config/lib /boot/common/lib /boot/system/lib' hardcode_into_libs=yes ;; @@ -10973,14 +9916,12 @@ soname_spec='${libname}${release}${shared_ext}$major' ;; esac - # HP-UX runs *really* slowly unless shared libraries are mode 555, ... + # HP-UX runs *really* slowly unless shared libraries are mode 555. postinstall_cmds='chmod 555 $lib' - # or fails outright, so override atomically: - install_override_mode=555 ;; interix[3-9]*) - version_type=linux # correct to gnu/linux during the next big refactor + version_type=linux need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' @@ -10996,7 +9937,7 @@ nonstopux*) version_type=nonstopux ;; *) if test "$lt_cv_prog_gnu_ld" = yes; then - version_type=linux # correct to gnu/linux during the next big refactor + version_type=linux else version_type=irix fi ;; @@ -11033,9 +9974,9 @@ dynamic_linker=no ;; -# This must be glibc/ELF. -linux* | k*bsd*-gnu | kopensolaris*-gnu) - version_type=linux # correct to gnu/linux during the next big refactor +# This must be Linux ELF. +linux* | k*bsd*-gnu) + version_type=linux need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' @@ -11043,17 +9984,12 @@ finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no - # Some binutils ld are patched to set DT_RUNPATH - if ${lt_cv_shlibpath_overrides_runpath+:} false; then : - $as_echo_n "(cached) " >&6 -else - lt_cv_shlibpath_overrides_runpath=no - save_LDFLAGS=$LDFLAGS - save_libdir=$libdir - eval "libdir=/foo; wl=\"$lt_prog_compiler_wl\"; \ - LDFLAGS=\"\$LDFLAGS $hardcode_libdir_flag_spec\"" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext + save_LDFLAGS=$LDFLAGS + save_libdir=$libdir + eval "libdir=/foo; wl=\"$lt_prog_compiler_wl\"; \ + LDFLAGS=\"\$LDFLAGS $hardcode_libdir_flag_spec\"" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int @@ -11066,17 +10002,13 @@ _ACEOF if ac_fn_c_try_link "$LINENO"; then : if ($OBJDUMP -p conftest$ac_exeext) 2>/dev/null | grep "RUNPATH.*$libdir" >/dev/null; then : - lt_cv_shlibpath_overrides_runpath=yes + shlibpath_overrides_runpath=yes fi fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext - LDFLAGS=$save_LDFLAGS - libdir=$save_libdir - -fi - - shlibpath_overrides_runpath=$lt_cv_shlibpath_overrides_runpath + LDFLAGS=$save_LDFLAGS + libdir=$save_libdir # This implies no fast_install, which is unacceptable. # Some rework will be needed to allow for fast_install @@ -11088,9 +10020,8 @@ # Append ld.so.conf contents to the search path if test -f /etc/ld.so.conf; then - lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s 2>/dev/null", \$2)); skip = 1; } { if (!skip) print \$0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;/^[ ]*hwcap[ ]/d;s/[:, ]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;s/"//g;/^$/d' | tr '\n' ' '` + lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s 2>/dev/null", \$2)); skip = 1; } { if (!skip) print \$0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;/^[ ]*hwcap[ ]/d;s/[:, ]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;/^$/d' | tr '\n' ' '` sys_lib_dlsearch_path_spec="$sys_lib_dlsearch_path_spec $lt_ld_extra" - fi # We used to test for /lib/ld.so.1 and disable shared libraries on @@ -11121,7 +10052,7 @@ ;; newsos6) - version_type=linux # correct to gnu/linux during the next big refactor + version_type=linux library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes @@ -11190,7 +10121,7 @@ ;; solaris*) - version_type=linux # correct to gnu/linux during the next big refactor + version_type=linux need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' @@ -11215,7 +10146,7 @@ ;; sysv4 | sysv4.3*) - version_type=linux # correct to gnu/linux during the next big refactor + version_type=linux library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH @@ -11239,7 +10170,7 @@ sysv4*MP*) if test -d /usr/nec ;then - version_type=linux # correct to gnu/linux during the next big refactor + version_type=linux library_names_spec='$libname${shared_ext}.$versuffix $libname${shared_ext}.$major $libname${shared_ext}' soname_spec='$libname${shared_ext}.$major' shlibpath_var=LD_LIBRARY_PATH @@ -11270,7 +10201,7 @@ tpf*) # TPF is a cross-target only. Preferred cross-host = GNU/Linux. - version_type=linux # correct to gnu/linux during the next big refactor + version_type=linux need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' @@ -11280,7 +10211,7 @@ ;; uts4*) - version_type=linux # correct to gnu/linux during the next big refactor + version_type=linux library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH @@ -11392,11 +10323,6 @@ - - - - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to hardcode library paths into programs" >&5 $as_echo_n "checking how to hardcode library paths into programs... " >&6; } hardcode_action= @@ -11469,7 +10395,7 @@ # if libdl is installed we need to link against it { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlopen in -ldl" >&5 $as_echo_n "checking for dlopen in -ldl... " >&6; } -if ${ac_cv_lib_dl_dlopen+:} false; then : +if test "${ac_cv_lib_dl_dlopen+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS @@ -11503,7 +10429,7 @@ fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dl_dlopen" >&5 $as_echo "$ac_cv_lib_dl_dlopen" >&6; } -if test "x$ac_cv_lib_dl_dlopen" = xyes; then : +if test "x$ac_cv_lib_dl_dlopen" = x""yes; then : lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl" else @@ -11517,12 +10443,12 @@ *) ac_fn_c_check_func "$LINENO" "shl_load" "ac_cv_func_shl_load" -if test "x$ac_cv_func_shl_load" = xyes; then : +if test "x$ac_cv_func_shl_load" = x""yes; then : lt_cv_dlopen="shl_load" else { $as_echo "$as_me:${as_lineno-$LINENO}: checking for shl_load in -ldld" >&5 $as_echo_n "checking for shl_load in -ldld... " >&6; } -if ${ac_cv_lib_dld_shl_load+:} false; then : +if test "${ac_cv_lib_dld_shl_load+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS @@ -11556,16 +10482,16 @@ fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dld_shl_load" >&5 $as_echo "$ac_cv_lib_dld_shl_load" >&6; } -if test "x$ac_cv_lib_dld_shl_load" = xyes; then : +if test "x$ac_cv_lib_dld_shl_load" = x""yes; then : lt_cv_dlopen="shl_load" lt_cv_dlopen_libs="-ldld" else ac_fn_c_check_func "$LINENO" "dlopen" "ac_cv_func_dlopen" -if test "x$ac_cv_func_dlopen" = xyes; then : +if test "x$ac_cv_func_dlopen" = x""yes; then : lt_cv_dlopen="dlopen" else { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlopen in -ldl" >&5 $as_echo_n "checking for dlopen in -ldl... " >&6; } -if ${ac_cv_lib_dl_dlopen+:} false; then : +if test "${ac_cv_lib_dl_dlopen+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS @@ -11599,12 +10525,12 @@ fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dl_dlopen" >&5 $as_echo "$ac_cv_lib_dl_dlopen" >&6; } -if test "x$ac_cv_lib_dl_dlopen" = xyes; then : +if test "x$ac_cv_lib_dl_dlopen" = x""yes; then : lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl" else { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlopen in -lsvld" >&5 $as_echo_n "checking for dlopen in -lsvld... " >&6; } -if ${ac_cv_lib_svld_dlopen+:} false; then : +if test "${ac_cv_lib_svld_dlopen+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS @@ -11638,12 +10564,12 @@ fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_svld_dlopen" >&5 $as_echo "$ac_cv_lib_svld_dlopen" >&6; } -if test "x$ac_cv_lib_svld_dlopen" = xyes; then : +if test "x$ac_cv_lib_svld_dlopen" = x""yes; then : lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-lsvld" else { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dld_link in -ldld" >&5 $as_echo_n "checking for dld_link in -ldld... " >&6; } -if ${ac_cv_lib_dld_dld_link+:} false; then : +if test "${ac_cv_lib_dld_dld_link+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS @@ -11677,7 +10603,7 @@ fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dld_dld_link" >&5 $as_echo "$ac_cv_lib_dld_dld_link" >&6; } -if test "x$ac_cv_lib_dld_dld_link" = xyes; then : +if test "x$ac_cv_lib_dld_dld_link" = x""yes; then : lt_cv_dlopen="dld_link" lt_cv_dlopen_libs="-ldld" fi @@ -11718,7 +10644,7 @@ { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether a program can dlopen itself" >&5 $as_echo_n "checking whether a program can dlopen itself... " >&6; } -if ${lt_cv_dlopen_self+:} false; then : +if test "${lt_cv_dlopen_self+set}" = set; then : $as_echo_n "(cached) " >&6 else if test "$cross_compiling" = yes; then : @@ -11727,7 +10653,7 @@ lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line $LINENO "configure" +#line 10656 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -11768,13 +10694,7 @@ # endif #endif -/* When -fvisbility=hidden is used, assume the code has been annotated - correspondingly for the symbols needed. */ -#if defined(__GNUC__) && (((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3)) || (__GNUC__ > 3)) -int fnord () __attribute__((visibility("default"))); -#endif - -int fnord () { return 42; } +void fnord() { int i=42;} int main () { void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW); @@ -11783,11 +10703,7 @@ if (self) { if (dlsym (self,"fnord")) status = $lt_dlno_uscore; - else - { - if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore; - else puts (dlerror ()); - } + else if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore; /* dlclose (self); */ } else @@ -11824,7 +10740,7 @@ wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $lt_prog_compiler_static\" { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether a statically linked program can dlopen itself" >&5 $as_echo_n "checking whether a statically linked program can dlopen itself... " >&6; } -if ${lt_cv_dlopen_self_static+:} false; then : +if test "${lt_cv_dlopen_self_static+set}" = set; then : $as_echo_n "(cached) " >&6 else if test "$cross_compiling" = yes; then : @@ -11833,7 +10749,7 @@ lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line $LINENO "configure" +#line 10752 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -11874,13 +10790,7 @@ # endif #endif -/* When -fvisbility=hidden is used, assume the code has been annotated - correspondingly for the symbols needed. */ -#if defined(__GNUC__) && (((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3)) || (__GNUC__ > 3)) -int fnord () __attribute__((visibility("default"))); -#endif - -int fnord () { return 42; } +void fnord() { int i=42;} int main () { void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW); @@ -11889,11 +10799,7 @@ if (self) { if (dlsym (self,"fnord")) status = $lt_dlno_uscore; - else - { - if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore; - else puts (dlerror ()); - } + else if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore; /* dlclose (self); */ } else @@ -12062,8 +10968,6 @@ - - ac_config_commands="$ac_config_commands libtool" @@ -12074,1021 +10978,6 @@ -# Test for 64-bit build. -# The cast to long int works around a bug in the HP C Compiler -# version HP92453-01 B.11.11.23709.GP, which incorrectly rejects -# declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. -# This bug is HP SR number 8606223364. -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking size of size_t" >&5 -$as_echo_n "checking size of size_t... " >&6; } -if ${ac_cv_sizeof_size_t+:} false; then : - $as_echo_n "(cached) " >&6 -else - if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (size_t))" "ac_cv_sizeof_size_t" "$ac_includes_default"; then : - -else - if test "$ac_cv_type_size_t" = yes; then - { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error 77 "cannot compute sizeof (size_t) -See \`config.log' for more details" "$LINENO" 5; } - else - ac_cv_sizeof_size_t=0 - fi -fi - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_size_t" >&5 -$as_echo "$ac_cv_sizeof_size_t" >&6; } - - - -cat >>confdefs.h <<_ACEOF -#define SIZEOF_SIZE_T $ac_cv_sizeof_size_t -_ACEOF - - - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler vendor" >&5 -$as_echo_n "checking for C compiler vendor... " >&6; } -if ${ax_cv_c_compiler_vendor+:} false; then : - $as_echo_n "(cached) " >&6 -else - # note: don't check for gcc first since some other compilers define __GNUC__ - vendors="intel: __ICC,__ECC,__INTEL_COMPILER - ibm: __xlc__,__xlC__,__IBMC__,__IBMCPP__ - pathscale: __PATHCC__,__PATHSCALE__ - clang: __clang__ - gnu: __GNUC__ - sun: __SUNPRO_C,__SUNPRO_CC - hp: __HP_cc,__HP_aCC - dec: __DECC,__DECCXX,__DECC_VER,__DECCXX_VER - borland: __BORLANDC__,__TURBOC__ - comeau: __COMO__ - cray: _CRAYC - kai: __KCC - lcc: __LCC__ - sgi: __sgi,sgi - microsoft: _MSC_VER - metrowerks: __MWERKS__ - watcom: __WATCOMC__ - portland: __PGI - unknown: UNKNOWN" - for ventest in $vendors; do - case $ventest in - *:) vendor=$ventest; continue ;; - *) vencpp="defined("`echo $ventest | sed 's/,/) || defined(/g'`")" ;; - esac - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ - - #if !($vencpp) - thisisanerror; - #endif - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - break -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - done - ax_cv_c_compiler_vendor=`echo $vendor | cut -d: -f1` - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv_c_compiler_vendor" >&5 -$as_echo "$ax_cv_c_compiler_vendor" >&6; } - - - - - - -# Check whether --enable-portable-binary was given. -if test "${enable_portable_binary+set}" = set; then : - enableval=$enable_portable_binary; acx_maxopt_portable=$enableval -else - acx_maxopt_portable=no -fi - - -# Try to determine "good" native compiler flags if none specified via CFLAGS -if test "$ac_test_CFLAGS" != "set"; then - CFLAGS="" - case $ax_cv_c_compiler_vendor in - dec) CFLAGS="-newc -w0 -O5 -ansi_alias -ansi_args -fp_reorder -tune host" - if test "x$acx_maxopt_portable" = xno; then - CFLAGS="$CFLAGS -arch host" - fi;; - - sun) CFLAGS="-native -fast -xO5 -dalign" - if test "x$acx_maxopt_portable" = xyes; then - CFLAGS="$CFLAGS -xarch=generic" - fi;; - - hp) CFLAGS="+Oall +Optrs_ansi +DSnative" - if test "x$acx_maxopt_portable" = xyes; then - CFLAGS="$CFLAGS +DAportable" - fi;; - - ibm) if test "x$acx_maxopt_portable" = xno; then - xlc_opt="-qarch=auto -qtune=auto" - else - xlc_opt="-qtune=auto" - fi - as_CACHEVAR=`$as_echo "ax_cv_check_cflags__$xlc_opt" | $as_tr_sh` -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether C compiler accepts $xlc_opt" >&5 -$as_echo_n "checking whether C compiler accepts $xlc_opt... " >&6; } -if eval \${$as_CACHEVAR+:} false; then : - $as_echo_n "(cached) " >&6 -else - - ax_check_save_flags=$CFLAGS - CFLAGS="$CFLAGS $xlc_opt" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - eval "$as_CACHEVAR=yes" -else - eval "$as_CACHEVAR=no" -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - CFLAGS=$ax_check_save_flags -fi -eval ac_res=\$$as_CACHEVAR - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } -if test x"`eval 'as_val=${'$as_CACHEVAR'};$as_echo "$as_val"'`" = xyes; then : - CFLAGS="-O3 -qansialias -w $xlc_opt" -else - CFLAGS="-O3 -qansialias -w" - echo "******************************************************" - echo "* You seem to have the IBM C compiler. It is *" - echo "* recommended for best performance that you use: *" - echo "* *" - echo "* CFLAGS=-O3 -qarch=xxx -qtune=xxx -qansialias -w *" - echo "* ^^^ ^^^ *" - echo "* where xxx is pwr2, pwr3, 604, or whatever kind of *" - echo "* CPU you have. (Set the CFLAGS environment var. *" - echo "* and re-run configure.) For more info, man cc. *" - echo "******************************************************" -fi - - ;; - - intel) CFLAGS="-O3 -ansi_alias" - if test "x$acx_maxopt_portable" = xno; then - icc_archflag=unknown - icc_flags="" - case $host_cpu in - i686*|x86_64*) - # icc accepts gcc assembly syntax, so these should work: - -ac_ext=c -ac_cpp='$CPP $CPPFLAGS' -ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_c_compiler_gnu - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for x86 cpuid 0 output" >&5 -$as_echo_n "checking for x86 cpuid 0 output... " >&6; } -if ${ax_cv_gcc_x86_cpuid_0+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test "$cross_compiling" = yes; then : - ax_cv_gcc_x86_cpuid_0=unknown -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include -int -main () -{ - - int op = 0, eax, ebx, ecx, edx; - FILE *f; - __asm__("cpuid" - : "=a" (eax), "=b" (ebx), "=c" (ecx), "=d" (edx) - : "a" (op)); - f = fopen("conftest_cpuid", "w"); if (!f) return 1; - fprintf(f, "%x:%x:%x:%x\n", eax, ebx, ecx, edx); - fclose(f); - return 0; - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_run "$LINENO"; then : - ax_cv_gcc_x86_cpuid_0=`cat conftest_cpuid`; rm -f conftest_cpuid -else - ax_cv_gcc_x86_cpuid_0=unknown; rm -f conftest_cpuid -fi -rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ - conftest.$ac_objext conftest.beam conftest.$ac_ext -fi - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv_gcc_x86_cpuid_0" >&5 -$as_echo "$ax_cv_gcc_x86_cpuid_0" >&6; } -ac_ext=c -ac_cpp='$CPP $CPPFLAGS' -ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_c_compiler_gnu - - - -ac_ext=c -ac_cpp='$CPP $CPPFLAGS' -ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_c_compiler_gnu - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for x86 cpuid 1 output" >&5 -$as_echo_n "checking for x86 cpuid 1 output... " >&6; } -if ${ax_cv_gcc_x86_cpuid_1+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test "$cross_compiling" = yes; then : - ax_cv_gcc_x86_cpuid_1=unknown -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include -int -main () -{ - - int op = 1, eax, ebx, ecx, edx; - FILE *f; - __asm__("cpuid" - : "=a" (eax), "=b" (ebx), "=c" (ecx), "=d" (edx) - : "a" (op)); - f = fopen("conftest_cpuid", "w"); if (!f) return 1; - fprintf(f, "%x:%x:%x:%x\n", eax, ebx, ecx, edx); - fclose(f); - return 0; - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_run "$LINENO"; then : - ax_cv_gcc_x86_cpuid_1=`cat conftest_cpuid`; rm -f conftest_cpuid -else - ax_cv_gcc_x86_cpuid_1=unknown; rm -f conftest_cpuid -fi -rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ - conftest.$ac_objext conftest.beam conftest.$ac_ext -fi - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv_gcc_x86_cpuid_1" >&5 -$as_echo "$ax_cv_gcc_x86_cpuid_1" >&6; } -ac_ext=c -ac_cpp='$CPP $CPPFLAGS' -ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_c_compiler_gnu - - - case $ax_cv_gcc_x86_cpuid_0 in # see AX_GCC_ARCHFLAG - *:756e6547:*:*) # Intel - case $ax_cv_gcc_x86_cpuid_1 in - *6a?:*[234]:*:*|*6[789b]?:*:*:*) icc_flags="-xK";; - *f3[347]:*:*:*|*f41347:*:*:*) icc_flags="-xP -xN -xW -xK";; - *f??:*:*:*) icc_flags="-xN -xW -xK";; - esac ;; - esac ;; - esac - if test "x$icc_flags" != x; then - for flag in $icc_flags; do - as_CACHEVAR=`$as_echo "ax_cv_check_cflags__$flag" | $as_tr_sh` -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether C compiler accepts $flag" >&5 -$as_echo_n "checking whether C compiler accepts $flag... " >&6; } -if eval \${$as_CACHEVAR+:} false; then : - $as_echo_n "(cached) " >&6 -else - - ax_check_save_flags=$CFLAGS - CFLAGS="$CFLAGS $flag" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - eval "$as_CACHEVAR=yes" -else - eval "$as_CACHEVAR=no" -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - CFLAGS=$ax_check_save_flags -fi -eval ac_res=\$$as_CACHEVAR - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } -if test x"`eval 'as_val=${'$as_CACHEVAR'};$as_echo "$as_val"'`" = xyes; then : - icc_archflag=$flag; break -else - : -fi - - done - fi - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for icc architecture flag" >&5 -$as_echo_n "checking for icc architecture flag... " >&6; } - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $icc_archflag" >&5 -$as_echo "$icc_archflag" >&6; } - if test "x$icc_archflag" != xunknown; then - CFLAGS="$CFLAGS $icc_archflag" - fi - fi - ;; - - gnu) - # default optimization flags for gcc on all systems - CFLAGS="-O3 -fomit-frame-pointer" - - # -malign-double for x86 systems - # LIBFFI -- DON'T DO THIS - CHANGES ABI - # AX_CHECK_COMPILE_FLAG(-malign-double, CFLAGS="$CFLAGS -malign-double") - - # -fstrict-aliasing for gcc-2.95+ - { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether C compiler accepts -fstrict-aliasing" >&5 -$as_echo_n "checking whether C compiler accepts -fstrict-aliasing... " >&6; } -if ${ax_cv_check_cflags___fstrict_aliasing+:} false; then : - $as_echo_n "(cached) " >&6 -else - - ax_check_save_flags=$CFLAGS - CFLAGS="$CFLAGS -fstrict-aliasing" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - ax_cv_check_cflags___fstrict_aliasing=yes -else - ax_cv_check_cflags___fstrict_aliasing=no -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - CFLAGS=$ax_check_save_flags -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv_check_cflags___fstrict_aliasing" >&5 -$as_echo "$ax_cv_check_cflags___fstrict_aliasing" >&6; } -if test x"$ax_cv_check_cflags___fstrict_aliasing" = xyes; then : - CFLAGS="$CFLAGS -fstrict-aliasing" -else - : -fi - - - # note that we enable "unsafe" fp optimization with other compilers, too - { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether C compiler accepts -ffast-math" >&5 -$as_echo_n "checking whether C compiler accepts -ffast-math... " >&6; } -if ${ax_cv_check_cflags___ffast_math+:} false; then : - $as_echo_n "(cached) " >&6 -else - - ax_check_save_flags=$CFLAGS - CFLAGS="$CFLAGS -ffast-math" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - ax_cv_check_cflags___ffast_math=yes -else - ax_cv_check_cflags___ffast_math=no -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - CFLAGS=$ax_check_save_flags -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv_check_cflags___ffast_math" >&5 -$as_echo "$ax_cv_check_cflags___ffast_math" >&6; } -if test x"$ax_cv_check_cflags___ffast_math" = xyes; then : - CFLAGS="$CFLAGS -ffast-math" -else - : -fi - - - - - - -# Check whether --with-gcc-arch was given. -if test "${with_gcc_arch+set}" = set; then : - withval=$with_gcc_arch; ax_gcc_arch=$withval -else - ax_gcc_arch=yes -fi - - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for gcc architecture flag" >&5 -$as_echo_n "checking for gcc architecture flag... " >&6; } -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: " >&5 -$as_echo "" >&6; } -if ${ax_cv_gcc_archflag+:} false; then : - $as_echo_n "(cached) " >&6 -else - -ax_cv_gcc_archflag="unknown" - -if test "$GCC" = yes; then - -if test "x$ax_gcc_arch" = xyes; then -ax_gcc_arch="" -if test "$cross_compiling" = no; then -case $host_cpu in - i[3456]86*|x86_64*) # use cpuid codes - -ac_ext=c -ac_cpp='$CPP $CPPFLAGS' -ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_c_compiler_gnu - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for x86 cpuid 0 output" >&5 -$as_echo_n "checking for x86 cpuid 0 output... " >&6; } -if ${ax_cv_gcc_x86_cpuid_0+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test "$cross_compiling" = yes; then : - ax_cv_gcc_x86_cpuid_0=unknown -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include -int -main () -{ - - int op = 0, eax, ebx, ecx, edx; - FILE *f; - __asm__("cpuid" - : "=a" (eax), "=b" (ebx), "=c" (ecx), "=d" (edx) - : "a" (op)); - f = fopen("conftest_cpuid", "w"); if (!f) return 1; - fprintf(f, "%x:%x:%x:%x\n", eax, ebx, ecx, edx); - fclose(f); - return 0; - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_run "$LINENO"; then : - ax_cv_gcc_x86_cpuid_0=`cat conftest_cpuid`; rm -f conftest_cpuid -else - ax_cv_gcc_x86_cpuid_0=unknown; rm -f conftest_cpuid -fi -rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ - conftest.$ac_objext conftest.beam conftest.$ac_ext -fi - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv_gcc_x86_cpuid_0" >&5 -$as_echo "$ax_cv_gcc_x86_cpuid_0" >&6; } -ac_ext=c -ac_cpp='$CPP $CPPFLAGS' -ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_c_compiler_gnu - - - -ac_ext=c -ac_cpp='$CPP $CPPFLAGS' -ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_c_compiler_gnu - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for x86 cpuid 1 output" >&5 -$as_echo_n "checking for x86 cpuid 1 output... " >&6; } -if ${ax_cv_gcc_x86_cpuid_1+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test "$cross_compiling" = yes; then : - ax_cv_gcc_x86_cpuid_1=unknown -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include -int -main () -{ - - int op = 1, eax, ebx, ecx, edx; - FILE *f; - __asm__("cpuid" - : "=a" (eax), "=b" (ebx), "=c" (ecx), "=d" (edx) - : "a" (op)); - f = fopen("conftest_cpuid", "w"); if (!f) return 1; - fprintf(f, "%x:%x:%x:%x\n", eax, ebx, ecx, edx); - fclose(f); - return 0; - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_run "$LINENO"; then : - ax_cv_gcc_x86_cpuid_1=`cat conftest_cpuid`; rm -f conftest_cpuid -else - ax_cv_gcc_x86_cpuid_1=unknown; rm -f conftest_cpuid -fi -rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ - conftest.$ac_objext conftest.beam conftest.$ac_ext -fi - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv_gcc_x86_cpuid_1" >&5 -$as_echo "$ax_cv_gcc_x86_cpuid_1" >&6; } -ac_ext=c -ac_cpp='$CPP $CPPFLAGS' -ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_c_compiler_gnu - - - case $ax_cv_gcc_x86_cpuid_0 in - *:756e6547:*:*) # Intel - case $ax_cv_gcc_x86_cpuid_1 in - *5[48]?:*:*:*) ax_gcc_arch="pentium-mmx pentium" ;; - *5??:*:*:*) ax_gcc_arch=pentium ;; - *0?6[3456]?:*:*:*) ax_gcc_arch="pentium2 pentiumpro" ;; - *0?6a?:*[01]:*:*) ax_gcc_arch="pentium2 pentiumpro" ;; - *0?6a?:*[234]:*:*) ax_gcc_arch="pentium3 pentiumpro" ;; - *0?6[9de]?:*:*:*) ax_gcc_arch="pentium-m pentium3 pentiumpro" ;; - *0?6[78b]?:*:*:*) ax_gcc_arch="pentium3 pentiumpro" ;; - *0?6f?:*:*:*|*1?66?:*:*:*) ax_gcc_arch="core2 pentium-m pentium3 pentiumpro" ;; - *1?6[7d]?:*:*:*) ax_gcc_arch="penryn core2 pentium-m pentium3 pentiumpro" ;; - *1?6[aef]?:*:*:*|*2?6[5cef]?:*:*:*) ax_gcc_arch="corei7 core2 pentium-m pentium3 pentiumpro" ;; - *1?6c?:*:*:*|*[23]?66?:*:*:*) ax_gcc_arch="atom core2 pentium-m pentium3 pentiumpro" ;; - *2?6[ad]?:*:*:*) ax_gcc_arch="corei7-avx corei7 core2 pentium-m pentium3 pentiumpro" ;; - *0?6??:*:*:*) ax_gcc_arch=pentiumpro ;; - *6??:*:*:*) ax_gcc_arch="core2 pentiumpro" ;; - ?000?f3[347]:*:*:*|?000?f41347:*:*:*|?000?f6?:*:*:*) - case $host_cpu in - x86_64*) ax_gcc_arch="nocona pentium4 pentiumpro" ;; - *) ax_gcc_arch="prescott pentium4 pentiumpro" ;; - esac ;; - ?000?f??:*:*:*) ax_gcc_arch="pentium4 pentiumpro";; - esac ;; - *:68747541:*:*) # AMD - case $ax_cv_gcc_x86_cpuid_1 in - *5[67]?:*:*:*) ax_gcc_arch=k6 ;; - *5[8d]?:*:*:*) ax_gcc_arch="k6-2 k6" ;; - *5[9]?:*:*:*) ax_gcc_arch="k6-3 k6" ;; - *60?:*:*:*) ax_gcc_arch=k7 ;; - *6[12]?:*:*:*) ax_gcc_arch="athlon k7" ;; - *6[34]?:*:*:*) ax_gcc_arch="athlon-tbird k7" ;; - *67?:*:*:*) ax_gcc_arch="athlon-4 athlon k7" ;; - *6[68a]?:*:*:*) - -ac_ext=c -ac_cpp='$CPP $CPPFLAGS' -ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_c_compiler_gnu - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for x86 cpuid 0x80000006 output" >&5 -$as_echo_n "checking for x86 cpuid 0x80000006 output... " >&6; } -if ${ax_cv_gcc_x86_cpuid_0x80000006+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test "$cross_compiling" = yes; then : - ax_cv_gcc_x86_cpuid_0x80000006=unknown -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include -int -main () -{ - - int op = 0x80000006, eax, ebx, ecx, edx; - FILE *f; - __asm__("cpuid" - : "=a" (eax), "=b" (ebx), "=c" (ecx), "=d" (edx) - : "a" (op)); - f = fopen("conftest_cpuid", "w"); if (!f) return 1; - fprintf(f, "%x:%x:%x:%x\n", eax, ebx, ecx, edx); - fclose(f); - return 0; - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_run "$LINENO"; then : - ax_cv_gcc_x86_cpuid_0x80000006=`cat conftest_cpuid`; rm -f conftest_cpuid -else - ax_cv_gcc_x86_cpuid_0x80000006=unknown; rm -f conftest_cpuid -fi -rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ - conftest.$ac_objext conftest.beam conftest.$ac_ext -fi - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv_gcc_x86_cpuid_0x80000006" >&5 -$as_echo "$ax_cv_gcc_x86_cpuid_0x80000006" >&6; } -ac_ext=c -ac_cpp='$CPP $CPPFLAGS' -ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_c_compiler_gnu - - # L2 cache size - case $ax_cv_gcc_x86_cpuid_0x80000006 in - *:*:*[1-9a-f]??????:*) # (L2 = ecx >> 16) >= 256 - ax_gcc_arch="athlon-xp athlon-4 athlon k7" ;; - *) ax_gcc_arch="athlon-4 athlon k7" ;; - esac ;; - ?00??f[4cef8b]?:*:*:*) ax_gcc_arch="athlon64 k8" ;; - ?00??f5?:*:*:*) ax_gcc_arch="opteron k8" ;; - ?00??f7?:*:*:*) ax_gcc_arch="athlon-fx opteron k8" ;; - ?00??f??:*:*:*) ax_gcc_arch="k8" ;; - ?05??f??:*:*:*) ax_gcc_arch="btver1 amdfam10 k8" ;; - ?06??f??:*:*:*) ax_gcc_arch="bdver1 amdfam10 k8" ;; - *f??:*:*:*) ax_gcc_arch="amdfam10 k8" ;; - esac ;; - *:746e6543:*:*) # IDT - case $ax_cv_gcc_x86_cpuid_1 in - *54?:*:*:*) ax_gcc_arch=winchip-c6 ;; - *58?:*:*:*) ax_gcc_arch=winchip2 ;; - *6[78]?:*:*:*) ax_gcc_arch=c3 ;; - *69?:*:*:*) ax_gcc_arch="c3-2 c3" ;; - esac ;; - esac - if test x"$ax_gcc_arch" = x; then # fallback - case $host_cpu in - i586*) ax_gcc_arch=pentium ;; - i686*) ax_gcc_arch=pentiumpro ;; - esac - fi - ;; - - sparc*) - # Extract the first word of "prtdiag", so it can be a program name with args. -set dummy prtdiag; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_PRTDIAG+:} false; then : - $as_echo_n "(cached) " >&6 -else - case $PRTDIAG in - [\\/]* | ?:[\\/]*) - ac_cv_path_PRTDIAG="$PRTDIAG" # Let the user override the test with a path. - ;; - *) - as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -as_dummy="$PATH:/usr/platform/`uname -i`/sbin/:/usr/platform/`uname -m`/sbin/" -for as_dir in $as_dummy -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_path_PRTDIAG="$as_dir/$ac_word$ac_exec_ext" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - - test -z "$ac_cv_path_PRTDIAG" && ac_cv_path_PRTDIAG="prtdiag" - ;; -esac -fi -PRTDIAG=$ac_cv_path_PRTDIAG -if test -n "$PRTDIAG"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PRTDIAG" >&5 -$as_echo "$PRTDIAG" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - - cputype=`(((grep cpu /proc/cpuinfo | cut -d: -f2) ; ($PRTDIAG -v |grep -i sparc) ; grep -i cpu /var/run/dmesg.boot ) | head -n 1) 2> /dev/null` - cputype=`echo "$cputype" | tr -d ' -' |tr $as_cr_LETTERS $as_cr_letters` - case $cputype in - *ultrasparciv*) ax_gcc_arch="ultrasparc4 ultrasparc3 ultrasparc v9" ;; - *ultrasparciii*) ax_gcc_arch="ultrasparc3 ultrasparc v9" ;; - *ultrasparc*) ax_gcc_arch="ultrasparc v9" ;; - *supersparc*|*tms390z5[05]*) ax_gcc_arch="supersparc v8" ;; - *hypersparc*|*rt62[056]*) ax_gcc_arch="hypersparc v8" ;; - *cypress*) ax_gcc_arch=cypress ;; - esac ;; - - alphaev5) ax_gcc_arch=ev5 ;; - alphaev56) ax_gcc_arch=ev56 ;; - alphapca56) ax_gcc_arch="pca56 ev56" ;; - alphapca57) ax_gcc_arch="pca57 pca56 ev56" ;; - alphaev6) ax_gcc_arch=ev6 ;; - alphaev67) ax_gcc_arch=ev67 ;; - alphaev68) ax_gcc_arch="ev68 ev67" ;; - alphaev69) ax_gcc_arch="ev69 ev68 ev67" ;; - alphaev7) ax_gcc_arch="ev7 ev69 ev68 ev67" ;; - alphaev79) ax_gcc_arch="ev79 ev7 ev69 ev68 ev67" ;; - - powerpc*) - cputype=`((grep cpu /proc/cpuinfo | head -n 1 | cut -d: -f2 | cut -d, -f1 | sed 's/ //g') ; /usr/bin/machine ; /bin/machine; grep CPU /var/run/dmesg.boot | head -n 1 | cut -d" " -f2) 2> /dev/null` - cputype=`echo $cputype | sed -e 's/ppc//g;s/ *//g'` - case $cputype in - *750*) ax_gcc_arch="750 G3" ;; - *740[0-9]*) ax_gcc_arch="$cputype 7400 G4" ;; - *74[4-5][0-9]*) ax_gcc_arch="$cputype 7450 G4" ;; - *74[0-9][0-9]*) ax_gcc_arch="$cputype G4" ;; - *970*) ax_gcc_arch="970 G5 power4";; - *POWER4*|*power4*|*gq*) ax_gcc_arch="power4 970";; - *POWER5*|*power5*|*gr*|*gs*) ax_gcc_arch="power5 power4 970";; - 603ev|8240) ax_gcc_arch="$cputype 603e 603";; - *) ax_gcc_arch=$cputype ;; - esac - ax_gcc_arch="$ax_gcc_arch powerpc" - ;; -esac -fi # not cross-compiling -fi # guess arch - -if test "x$ax_gcc_arch" != x -a "x$ax_gcc_arch" != xno; then -for arch in $ax_gcc_arch; do - if test "x$acx_maxopt_portable" = xyes; then # if we require portable code - flags="-mtune=$arch" - # -mcpu=$arch and m$arch generate nonportable code on every arch except - # x86. And some other arches (e.g. Alpha) don't accept -mtune. Grrr. - case $host_cpu in i*86|x86_64*) flags="$flags -mcpu=$arch -m$arch";; esac - else - flags="-march=$arch -mcpu=$arch -m$arch" - fi - for flag in $flags; do - as_CACHEVAR=`$as_echo "ax_cv_check_cflags__$flag" | $as_tr_sh` -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether C compiler accepts $flag" >&5 -$as_echo_n "checking whether C compiler accepts $flag... " >&6; } -if eval \${$as_CACHEVAR+:} false; then : - $as_echo_n "(cached) " >&6 -else - - ax_check_save_flags=$CFLAGS - CFLAGS="$CFLAGS $flag" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - eval "$as_CACHEVAR=yes" -else - eval "$as_CACHEVAR=no" -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - CFLAGS=$ax_check_save_flags -fi -eval ac_res=\$$as_CACHEVAR - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } -if test x"`eval 'as_val=${'$as_CACHEVAR'};$as_echo "$as_val"'`" = xyes; then : - ax_cv_gcc_archflag=$flag; break -else - : -fi - - done - test "x$ax_cv_gcc_archflag" = xunknown || break -done -fi - -fi # $GCC=yes - -fi - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for gcc architecture flag" >&5 -$as_echo_n "checking for gcc architecture flag... " >&6; } -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv_gcc_archflag" >&5 -$as_echo "$ax_cv_gcc_archflag" >&6; } -if test "x$ax_cv_gcc_archflag" = xunknown; then - : -else - CFLAGS="$CFLAGS $ax_cv_gcc_archflag" -fi - - ;; - esac - - if test -z "$CFLAGS"; then - echo "" - echo "********************************************************" - echo "* WARNING: Don't know the best CFLAGS for this system *" - echo "* Use ./configure CFLAGS=... to specify your own flags *" - echo "* (otherwise, a default of CFLAGS=-O3 will be used) *" - echo "********************************************************" - echo "" - CFLAGS="-O3" - fi - - as_CACHEVAR=`$as_echo "ax_cv_check_cflags__$CFLAGS" | $as_tr_sh` -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether C compiler accepts $CFLAGS" >&5 -$as_echo_n "checking whether C compiler accepts $CFLAGS... " >&6; } -if eval \${$as_CACHEVAR+:} false; then : - $as_echo_n "(cached) " >&6 -else - - ax_check_save_flags=$CFLAGS - CFLAGS="$CFLAGS $CFLAGS" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - eval "$as_CACHEVAR=yes" -else - eval "$as_CACHEVAR=no" -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - CFLAGS=$ax_check_save_flags -fi -eval ac_res=\$$as_CACHEVAR - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } -if test x"`eval 'as_val=${'$as_CACHEVAR'};$as_echo "$as_val"'`" = xyes; then : - : -else - - echo "" - echo "********************************************************" - echo "* WARNING: The guessed CFLAGS don't seem to work with *" - echo "* your compiler. *" - echo "* Use ./configure CFLAGS=... to specify your own flags *" - echo "********************************************************" - echo "" - CFLAGS="" - -fi - - -fi - -# The AX_CFLAGS_WARN_ALL macro doesn't currently work for sunpro -# compiler. -if test "$ax_cv_c_compiler_vendor" != "sun"; then - if ${CFLAGS+:} false; then : - case " $CFLAGS " in - *" "*) - { { $as_echo "$as_me:${as_lineno-$LINENO}: : CFLAGS already contains "; } >&5 - (: CFLAGS already contains ) 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } - ;; - *) - { { $as_echo "$as_me:${as_lineno-$LINENO}: : CFLAGS=\"\$CFLAGS \""; } >&5 - (: CFLAGS="$CFLAGS ") 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } - CFLAGS="$CFLAGS " - ;; - esac -else - CFLAGS="" -fi - -ac_ext=c -ac_cpp='$CPP $CPPFLAGS' -ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_c_compiler_gnu - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking CFLAGS for maximum warnings" >&5 -$as_echo_n "checking CFLAGS for maximum warnings... " >&6; } -if ${ac_cv_cflags_warn_all+:} false; then : - $as_echo_n "(cached) " >&6 -else - ac_cv_cflags_warn_all="no, unknown" -ac_save_CFLAGS="$CFLAGS" -for ac_arg in "-warn all % -warn all" "-pedantic % -Wall" "-xstrconst % -v" "-std1 % -verbose -w0 -warnprotos" "-qlanglvl=ansi % -qsrcmsg -qinfo=all:noppt:noppc:noobs:nocnd" "-ansi -ansiE % -fullwarn" "+ESlit % +w1" "-Xc % -pvctl,fullmsg" "-h conform % -h msglevel 2" # -do CFLAGS="$ac_save_CFLAGS "`echo $ac_arg | sed -e 's,%%.*,,' -e 's,%,,'` - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - ac_cv_cflags_warn_all=`echo $ac_arg | sed -e 's,.*% *,,'` ; break -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -done -CFLAGS="$ac_save_CFLAGS" - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_cflags_warn_all" >&5 -$as_echo "$ac_cv_cflags_warn_all" >&6; } - -case ".$ac_cv_cflags_warn_all" in - .ok|.ok,*) ;; - .|.no|.no,*) ;; - *) if ${CFLAGS+:} false; then : - case " $CFLAGS " in - *" $ac_cv_cflags_warn_all "*) - { { $as_echo "$as_me:${as_lineno-$LINENO}: : CFLAGS already contains \$ac_cv_cflags_warn_all"; } >&5 - (: CFLAGS already contains $ac_cv_cflags_warn_all) 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } - ;; - *) - { { $as_echo "$as_me:${as_lineno-$LINENO}: : CFLAGS=\"\$CFLAGS \$ac_cv_cflags_warn_all\""; } >&5 - (: CFLAGS="$CFLAGS $ac_cv_cflags_warn_all") 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } - CFLAGS="$CFLAGS $ac_cv_cflags_warn_all" - ;; - esac -else - CFLAGS="$ac_cv_cflags_warn_all" -fi - ;; -esac - -ac_ext=c -ac_cpp='$CPP $CPPFLAGS' -ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_c_compiler_gnu - - -fi - -if test "x$GCC" = "xyes"; then - CFLAGS="$CFLAGS -fexceptions" - touch local.exp -else - cat > local.exp <&5 $as_echo_n "checking whether to enable maintainer-specific portions of Makefiles... " >&6; } @@ -13116,7 +11005,7 @@ for ac_header in sys/mman.h do : ac_fn_c_check_header_mongrel "$LINENO" "sys/mman.h" "ac_cv_header_sys_mman_h" "$ac_includes_default" -if test "x$ac_cv_header_sys_mman_h" = xyes; then : +if test "x$ac_cv_header_sys_mman_h" = x""yes; then : cat >>confdefs.h <<_ACEOF #define HAVE_SYS_MMAN_H 1 _ACEOF @@ -13128,7 +11017,7 @@ for ac_func in mmap do : ac_fn_c_check_func "$LINENO" "mmap" "ac_cv_func_mmap" -if test "x$ac_cv_func_mmap" = xyes; then : +if test "x$ac_cv_func_mmap" = x""yes; then : cat >>confdefs.h <<_ACEOF #define HAVE_MMAP 1 _ACEOF @@ -13138,7 +11027,7 @@ ac_fn_c_check_header_mongrel "$LINENO" "sys/mman.h" "ac_cv_header_sys_mman_h" "$ac_includes_default" -if test "x$ac_cv_header_sys_mman_h" = xyes; then : +if test "x$ac_cv_header_sys_mman_h" = x""yes; then : libffi_header_sys_mman_h=yes else libffi_header_sys_mman_h=no @@ -13146,7 +11035,7 @@ ac_fn_c_check_func "$LINENO" "mmap" "ac_cv_func_mmap" -if test "x$ac_cv_func_mmap" = xyes; then : +if test "x$ac_cv_func_mmap" = x""yes; then : libffi_func_mmap=yes else libffi_func_mmap=no @@ -13160,7 +11049,7 @@ else { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether read-only mmap of a plain file works" >&5 $as_echo_n "checking whether read-only mmap of a plain file works... " >&6; } -if ${ac_cv_func_mmap_file+:} false; then : +if test "${ac_cv_func_mmap_file+set}" = set; then : $as_echo_n "(cached) " >&6 else # Add a system to this blacklist if @@ -13179,7 +11068,7 @@ $as_echo "$ac_cv_func_mmap_file" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether mmap from /dev/zero works" >&5 $as_echo_n "checking whether mmap from /dev/zero works... " >&6; } -if ${ac_cv_func_mmap_dev_zero+:} false; then : +if test "${ac_cv_func_mmap_dev_zero+set}" = set; then : $as_echo_n "(cached) " >&6 else # Add a system to this blacklist if it has mmap() but /dev/zero @@ -13205,7 +11094,7 @@ # Unlike /dev/zero, the MAP_ANON(YMOUS) defines can be probed for. { $as_echo "$as_me:${as_lineno-$LINENO}: checking for MAP_ANON(YMOUS)" >&5 $as_echo_n "checking for MAP_ANON(YMOUS)... " >&6; } -if ${ac_cv_decl_map_anon+:} false; then : +if test "${ac_cv_decl_map_anon+set}" = set; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext @@ -13241,7 +11130,7 @@ else { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether mmap with MAP_ANON(YMOUS) works" >&5 $as_echo_n "checking whether mmap with MAP_ANON(YMOUS) works... " >&6; } -if ${ac_cv_func_mmap_anon+:} false; then : +if test "${ac_cv_func_mmap_anon+set}" = set; then : $as_echo_n "(cached) " >&6 else # Add a system to this blacklist if it has mmap() and MAP_ANON or @@ -13289,13 +11178,9 @@ TARGETDIR="unknown" case "$host" in - aarch64*-*-*) - TARGET=AARCH64; TARGETDIR=aarch64 - ;; - alpha*-*-*) TARGET=ALPHA; TARGETDIR=alpha; - # Support 128-bit long double, changeable via command-line switch. + # Support 128-bit long double, changable via command-line switch. HAVE_LONG_DOUBLE='defined(__LONG_DOUBLE_128__)' ;; @@ -13309,20 +11194,12 @@ amd64-*-freebsd*) TARGET=X86_64; TARGETDIR=x86 - ;; - - amd64-*-freebsd*) - TARGET=X86_64; TARGETDIR=x86 ;; avr32*-*-*) TARGET=AVR32; TARGETDIR=avr32 ;; - bfin*) - TARGET=BFIN; TARGETDIR=bfin - ;; - cris-*-*) TARGET=LIBFFI_CRIS; TARGETDIR=cris ;; @@ -13331,7 +11208,7 @@ TARGET=FRV; TARGETDIR=frv ;; - hppa*-*-linux* | parisc*-*-linux* | hppa*-*-openbsd*) + hppa*-*-linux* | parisc*-*-linux*) TARGET=PA_LINUX; TARGETDIR=pa ;; hppa*64-*-hpux*) @@ -13344,65 +11221,22 @@ i?86-*-freebsd* | i?86-*-openbsd*) TARGET=X86_FREEBSD; TARGETDIR=x86 ;; - i?86-win32* | i?86-*-cygwin* | i?86-*-mingw* | i?86-*-os2* | i?86-*-interix*) + i?86-win32* | i?86-*-cygwin* | i?86-*-mingw*) TARGET=X86_WIN32; TARGETDIR=x86 - # All mingw/cygwin/win32 builds require -no-undefined for sharedlib. - # We must also check with_cross_host to decide if this is a native - # or cross-build and select where to install dlls appropriately. - if test -n "$with_cross_host" && - test x"$with_cross_host" != x"no"; then - AM_LTLDFLAGS='-no-undefined -bindir "$(toolexeclibdir)"'; - else - AM_LTLDFLAGS='-no-undefined -bindir "$(bindir)"'; - fi + # All mingw/cygwin/win32 builds require this for sharedlib + AM_LTLDFLAGS="-no-undefined" ;; i?86-*-darwin*) TARGET=X86_DARWIN; TARGETDIR=x86 ;; i?86-*-solaris2.1[0-9]*) - TARGETDIR=x86 - if test $ac_cv_sizeof_size_t = 4; then - TARGET=X86; - else - TARGET=X86_64; - fi + TARGET=X86_64; TARGETDIR=x86 ;; - i*86-*-nto-qnx*) TARGET=X86; TARGETDIR=x86 ;; - - x86_64-*-darwin*) - TARGET=X86_DARWIN; TARGETDIR=x86 - ;; - - x86_64-*-cygwin* | x86_64-*-mingw*) - TARGET=X86_WIN64; TARGETDIR=x86 - # All mingw/cygwin/win32 builds require -no-undefined for sharedlib. - # We must also check with_cross_host to decide if this is a native - # or cross-build and select where to install dlls appropriately. - if test -n "$with_cross_host" && - test x"$with_cross_host" != x"no"; then - AM_LTLDFLAGS='-no-undefined -bindir "$(toolexeclibdir)"'; - else - AM_LTLDFLAGS='-no-undefined -bindir "$(bindir)"'; - fi - ;; - - i?86-*-* | x86_64-*-*) - TARGETDIR=x86 - if test $ac_cv_sizeof_size_t = 4; then - case "$host" in - *-gnux32) - TARGET=X86_64 - ;; - *) - TARGET=X86 - ;; - esac - else - TARGET=X86_64; - fi + i?86-*-*) + TARGET=X86; TARGETDIR=x86 ;; ia64*-*-*) @@ -13417,22 +11251,10 @@ TARGET=M68K; TARGETDIR=m68k ;; - microblaze*-*-*) - TARGET=MICROBLAZE; TARGETDIR=microblaze - ;; - - moxie-*-*) - TARGET=MOXIE; TARGETDIR=moxie - ;; - - metag-*-*) - TARGET=METAG; TARGETDIR=metag - ;; - - mips-sgi-irix5.* | mips-sgi-irix6.* | mips*-*-rtems*) + mips-sgi-irix5.* | mips-sgi-irix6.*) TARGET=MIPS_IRIX; TARGETDIR=mips ;; - mips*-*-linux* | mips*-*-openbsd*) + mips*-*-linux*) # Support 128-bit long double for NewABI. HAVE_LONG_DOUBLE='defined(__mips64)' TARGET=MIPS_IRIX; TARGETDIR=mips @@ -13441,24 +11263,18 @@ powerpc*-*-linux* | powerpc-*-sysv*) TARGET=POWERPC; TARGETDIR=powerpc ;; - powerpc-*-amigaos*) - TARGET=POWERPC; TARGETDIR=powerpc - ;; powerpc-*-beos*) TARGET=POWERPC; TARGETDIR=powerpc ;; - powerpc-*-darwin* | powerpc64-*-darwin*) + powerpc-*-darwin*) TARGET=POWERPC_DARWIN; TARGETDIR=powerpc ;; powerpc-*-aix* | rs6000-*-aix*) TARGET=POWERPC_AIX; TARGETDIR=powerpc ;; - powerpc-*-freebsd* | powerpc-*-openbsd*) + powerpc-*-freebsd*) TARGET=POWERPC_FREEBSD; TARGETDIR=powerpc ;; - powerpc64-*-freebsd*) - TARGET=POWERPC; TARGETDIR=powerpc - ;; powerpc*-*-rtems*) TARGET=POWERPC; TARGETDIR=powerpc ;; @@ -13478,21 +11294,24 @@ TARGET=SPARC; TARGETDIR=sparc ;; - tile*-*) - TARGET=TILE; TARGETDIR=tile - ;; - - xtensa*-*) - TARGET=XTENSA; TARGETDIR=xtensa + x86_64-*-darwin*) + TARGET=X86_DARWIN; TARGETDIR=x86 ;; + x86_64-*-cygwin* | x86_64-*-mingw*) + TARGET=X86_WIN64; TARGETDIR=x86 + ;; + + x86_64-*-*) + TARGET=X86_64; TARGETDIR=x86 + ;; esac if test $TARGETDIR = unknown; then - as_fn_error $? "\"libffi has not been ported to $host.\"" "$LINENO" 5 + as_fn_error "\"libffi has not been ported to $host.\"" "$LINENO" 5 fi if expr x$TARGET : 'xMIPS' > /dev/null; then @@ -13503,14 +11322,6 @@ MIPS_FALSE= fi - if test x$TARGET = xBFIN; then - BFIN_TRUE= - BFIN_FALSE='#' -else - BFIN_TRUE='#' - BFIN_FALSE= -fi - if test x$TARGET = xSPARC; then SPARC_TRUE= SPARC_FALSE='#' @@ -13591,30 +11402,6 @@ M68K_FALSE= fi - if test x$TARGET = xMICROBLAZE; then - MICROBLAZE_TRUE= - MICROBLAZE_FALSE='#' -else - MICROBLAZE_TRUE='#' - MICROBLAZE_FALSE= -fi - - if test x$TARGET = xMETAG; then - METAG_TRUE= - METAG_FALSE='#' -else - METAG_TRUE='#' - METAG_FALSE= -fi - - if test x$TARGET = xMOXIE; then - MOXIE_TRUE= - MOXIE_FALSE='#' -else - MOXIE_TRUE='#' - MOXIE_FALSE= -fi - if test x$TARGET = xPOWERPC; then POWERPC_TRUE= POWERPC_FALSE='#' @@ -13647,14 +11434,6 @@ POWERPC_FREEBSD_FALSE= fi - if test x$TARGET = xAARCH64; then - AARCH64_TRUE= - AARCH64_FALSE='#' -else - AARCH64_TRUE='#' - AARCH64_FALSE= -fi - if test x$TARGET = xARM; then ARM_TRUE= ARM_FALSE='#' @@ -13743,26 +11522,10 @@ PA64_HPUX_FALSE= fi - if test x$TARGET = xTILE; then - TILE_TRUE= - TILE_FALSE='#' -else - TILE_TRUE='#' - TILE_FALSE= -fi - - if test x$TARGET = xXTENSA; then - XTENSA_TRUE= - XTENSA_FALSE='#' -else - XTENSA_TRUE='#' - XTENSA_FALSE= -fi - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ANSI C header files" >&5 $as_echo_n "checking for ANSI C header files... " >&6; } -if ${ac_cv_header_stdc+:} false; then : +if test "${ac_cv_header_stdc+set}" = set; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext @@ -13875,7 +11638,7 @@ for ac_func in memcpy do : ac_fn_c_check_func "$LINENO" "memcpy" "ac_cv_func_memcpy" -if test "x$ac_cv_func_memcpy" = xyes; then : +if test "x$ac_cv_func_memcpy" = x""yes; then : cat >>confdefs.h <<_ACEOF #define HAVE_MEMCPY 1 _ACEOF @@ -13883,22 +11646,11 @@ fi done -ac_fn_c_check_type "$LINENO" "size_t" "ac_cv_type_size_t" "$ac_includes_default" -if test "x$ac_cv_type_size_t" = xyes; then : - -else - -cat >>confdefs.h <<_ACEOF -#define size_t unsigned int -_ACEOF - -fi - # The Ultrix 4.2 mips builtin alloca declared by alloca.h only works # for constant arguments. Useless! { $as_echo "$as_me:${as_lineno-$LINENO}: checking for working alloca.h" >&5 $as_echo_n "checking for working alloca.h... " >&6; } -if ${ac_cv_working_alloca_h+:} false; then : +if test "${ac_cv_working_alloca_h+set}" = set; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext @@ -13931,7 +11683,7 @@ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for alloca" >&5 $as_echo_n "checking for alloca... " >&6; } -if ${ac_cv_func_alloca_works+:} false; then : +if test "${ac_cv_func_alloca_works+set}" = set; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext @@ -13950,7 +11702,7 @@ #pragma alloca # else # ifndef alloca /* predefined by HP cc +Olibcalls */ -void *alloca (size_t); +char *alloca (); # endif # endif # endif @@ -13994,7 +11746,7 @@ { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether \`alloca.c' needs Cray hooks" >&5 $as_echo_n "checking whether \`alloca.c' needs Cray hooks... " >&6; } -if ${ac_cv_os_cray+:} false; then : +if test "${ac_cv_os_cray+set}" = set; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext @@ -14021,7 +11773,8 @@ for ac_func in _getb67 GETB67 getb67; do as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var" -if eval test \"x\$"$as_ac_var"\" = x"yes"; then : +eval as_val=\$$as_ac_var + if test "x$as_val" = x""yes; then : cat >>confdefs.h <<_ACEOF #define CRAY_STACKSEG_END $ac_func @@ -14035,7 +11788,7 @@ { $as_echo "$as_me:${as_lineno-$LINENO}: checking stack direction for C alloca" >&5 $as_echo_n "checking stack direction for C alloca... " >&6; } -if ${ac_cv_c_stack_direction+:} false; then : +if test "${ac_cv_c_stack_direction+set}" = set; then : $as_echo_n "(cached) " >&6 else if test "$cross_compiling" = yes; then : @@ -14045,20 +11798,23 @@ /* end confdefs.h. */ $ac_includes_default int -find_stack_direction (int *addr, int depth) -{ - int dir, dummy = 0; - if (! addr) - addr = &dummy; - *addr = addr < &dummy ? 1 : addr == &dummy ? 0 : -1; - dir = depth ? find_stack_direction (addr, depth - 1) : 0; - return dir + dummy; +find_stack_direction () +{ + static char *addr = 0; + auto char dummy; + if (addr == 0) + { + addr = &dummy; + return find_stack_direction (); + } + else + return (&dummy > addr) ? 1 : -1; } int -main (int argc, char **argv) -{ - return find_stack_direction (0, argc + !argv + 20) < 0; +main () +{ + return find_stack_direction () < 0; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : @@ -14087,7 +11843,7 @@ # This bug is HP SR number 8606223364. { $as_echo "$as_me:${as_lineno-$LINENO}: checking size of double" >&5 $as_echo_n "checking size of double... " >&6; } -if ${ac_cv_sizeof_double+:} false; then : +if test "${ac_cv_sizeof_double+set}" = set; then : $as_echo_n "(cached) " >&6 else if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (double))" "ac_cv_sizeof_double" "$ac_includes_default"; then : @@ -14096,8 +11852,9 @@ if test "$ac_cv_type_double" = yes; then { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error 77 "cannot compute sizeof (double) -See \`config.log' for more details" "$LINENO" 5; } +{ as_fn_set_status 77 +as_fn_error "cannot compute sizeof (double) +See \`config.log' for more details." "$LINENO" 5; }; } else ac_cv_sizeof_double=0 fi @@ -14120,7 +11877,7 @@ # This bug is HP SR number 8606223364. { $as_echo "$as_me:${as_lineno-$LINENO}: checking size of long double" >&5 $as_echo_n "checking size of long double... " >&6; } -if ${ac_cv_sizeof_long_double+:} false; then : +if test "${ac_cv_sizeof_long_double+set}" = set; then : $as_echo_n "(cached) " >&6 else if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (long double))" "ac_cv_sizeof_long_double" "$ac_includes_default"; then : @@ -14129,8 +11886,9 @@ if test "$ac_cv_type_long_double" = yes; then { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error 77 "cannot compute sizeof (long double) -See \`config.log' for more details" "$LINENO" 5; } +{ as_fn_set_status 77 +as_fn_error "cannot compute sizeof (long double) +See \`config.log' for more details." "$LINENO" 5; }; } else ac_cv_sizeof_long_double=0 fi @@ -14164,7 +11922,7 @@ { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether byte ordering is bigendian" >&5 $as_echo_n "checking whether byte ordering is bigendian... " >&6; } -if ${ac_cv_c_bigendian+:} false; then : +if test "${ac_cv_c_bigendian+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_cv_c_bigendian=unknown @@ -14382,18 +12140,18 @@ ;; #( *) - as_fn_error $? "unknown endianness + as_fn_error "unknown endianness presetting ac_cv_c_bigendian=no (or yes) will help" "$LINENO" 5 ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking assembler .cfi pseudo-op support" >&5 $as_echo_n "checking assembler .cfi pseudo-op support... " >&6; } -if ${gcc_cv_as_cfi_pseudo_op+:} false; then : - $as_echo_n "(cached) " >&6 -else - - gcc_cv_as_cfi_pseudo_op=unknown +if test "${libffi_cv_as_cfi_pseudo_op+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + + libffi_cv_as_cfi_pseudo_op=unknown cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ asm (".cfi_startproc\n\t.cfi_endproc"); @@ -14406,26 +12164,25 @@ } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : - gcc_cv_as_cfi_pseudo_op=yes -else - gcc_cv_as_cfi_pseudo_op=no + libffi_cv_as_cfi_pseudo_op=yes +else + libffi_cv_as_cfi_pseudo_op=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gcc_cv_as_cfi_pseudo_op" >&5 -$as_echo "$gcc_cv_as_cfi_pseudo_op" >&6; } - if test "x$gcc_cv_as_cfi_pseudo_op" = xyes; then +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $libffi_cv_as_cfi_pseudo_op" >&5 +$as_echo "$libffi_cv_as_cfi_pseudo_op" >&6; } +if test "x$libffi_cv_as_cfi_pseudo_op" = xyes; then $as_echo "#define HAVE_AS_CFI_PSEUDO_OP 1" >>confdefs.h - fi - +fi if test x$TARGET = xSPARC; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking assembler and linker support unaligned pc related relocs" >&5 $as_echo_n "checking assembler and linker support unaligned pc related relocs... " >&6; } -if ${libffi_cv_as_sparc_ua_pcrel+:} false; then : +if test "${libffi_cv_as_sparc_ua_pcrel+set}" = set; then : $as_echo_n "(cached) " >&6 else @@ -14464,7 +12221,7 @@ { $as_echo "$as_me:${as_lineno-$LINENO}: checking assembler .register pseudo-op support" >&5 $as_echo_n "checking assembler .register pseudo-op support... " >&6; } -if ${libffi_cv_as_register_pseudo_op+:} false; then : +if test "${libffi_cv_as_register_pseudo_op+set}" = set; then : $as_echo_n "(cached) " >&6 else @@ -14472,11 +12229,11 @@ # Check if we have .register cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ - +asm (".register %g2, #scratch"); int main () { -asm (".register %g2, #scratch"); + ; return 0; } @@ -14501,14 +12258,14 @@ if test x$TARGET = xX86 || test x$TARGET = xX86_WIN32 || test x$TARGET = xX86_64; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking assembler supports pc related relocs" >&5 $as_echo_n "checking assembler supports pc related relocs... " >&6; } -if ${libffi_cv_as_x86_pcrel+:} false; then : - $as_echo_n "(cached) " >&6 -else - - libffi_cv_as_x86_pcrel=no +if test "${libffi_cv_as_x86_pcrel+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + + libffi_cv_as_x86_pcrel=yes echo '.text; foo: nop; .data; .long foo-.; .text' > conftest.s - if $CC $CFLAGS -c conftest.s > /dev/null 2>&1; then - libffi_cv_as_x86_pcrel=yes + if $CC $CFLAGS -c conftest.s 2>&1 | grep -i warning > /dev/null; then + libffi_cv_as_x86_pcrel=no fi fi @@ -14519,255 +12276,77 @@ $as_echo "#define HAVE_AS_X86_PCREL 1" >>confdefs.h fi - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking assembler .ascii pseudo-op support" >&5 -$as_echo_n "checking assembler .ascii pseudo-op support... " >&6; } -if ${libffi_cv_as_ascii_pseudo_op+:} false; then : - $as_echo_n "(cached) " >&6 -else - - libffi_cv_as_ascii_pseudo_op=unknown - # Check if we have .ascii - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ -asm (".ascii \\"string\\""); - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - libffi_cv_as_ascii_pseudo_op=yes -else - libffi_cv_as_ascii_pseudo_op=no -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $libffi_cv_as_ascii_pseudo_op" >&5 -$as_echo "$libffi_cv_as_ascii_pseudo_op" >&6; } - if test "x$libffi_cv_as_ascii_pseudo_op" = xyes; then - -$as_echo "#define HAVE_AS_ASCII_PSEUDO_OP 1" >>confdefs.h - - fi - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking assembler .string pseudo-op support" >&5 -$as_echo_n "checking assembler .string pseudo-op support... " >&6; } -if ${libffi_cv_as_string_pseudo_op+:} false; then : - $as_echo_n "(cached) " >&6 -else - - libffi_cv_as_string_pseudo_op=unknown - # Check if we have .string - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ -asm (".string \\"string\\""); - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - libffi_cv_as_string_pseudo_op=yes -else - libffi_cv_as_string_pseudo_op=no -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $libffi_cv_as_string_pseudo_op" >&5 -$as_echo "$libffi_cv_as_string_pseudo_op" >&6; } - if test "x$libffi_cv_as_string_pseudo_op" = xyes; then - -$as_echo "#define HAVE_AS_STRING_PSEUDO_OP 1" >>confdefs.h - - fi -fi - -# On PaX enable kernels that have MPROTECT enable we can't use PROT_EXEC. -# Check whether --enable-pax_emutramp was given. -if test "${enable_pax_emutramp+set}" = set; then : - enableval=$enable_pax_emutramp; if test "$enable_pax_emutramp" = "yes"; then - -$as_echo "#define FFI_MMAP_EXEC_EMUTRAMP_PAX 1" >>confdefs.h - - fi -fi - - -if test x$TARGET = xX86_WIN64; then - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for _ prefix in compiled symbols" >&5 -$as_echo_n "checking for _ prefix in compiled symbols... " >&6; } -if ${lt_cv_sys_symbol_underscore+:} false; then : - $as_echo_n "(cached) " >&6 -else - lt_cv_sys_symbol_underscore=no - cat > conftest.$ac_ext <<_LT_EOF -void nm_test_func(){} -int main(){nm_test_func;return 0;} -_LT_EOF - if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 - (eval $ac_compile) 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; }; then - # Now try to grab the symbols. - ac_nlist=conftest.nm - if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$NM conftest.$ac_objext \| $lt_cv_sys_global_symbol_pipe \> $ac_nlist\""; } >&5 - (eval $NM conftest.$ac_objext \| $lt_cv_sys_global_symbol_pipe \> $ac_nlist) 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } && test -s "$ac_nlist"; then - # See whether the symbols have a leading underscore. - if grep '^. _nm_test_func' "$ac_nlist" >/dev/null; then - lt_cv_sys_symbol_underscore=yes - else - if grep '^. nm_test_func ' "$ac_nlist" >/dev/null; then - : - else - echo "configure: cannot find nm_test_func in $ac_nlist" >&5 - fi - fi - else - echo "configure: cannot run $lt_cv_sys_global_symbol_pipe" >&5 - fi - else - echo "configure: failed program was:" >&5 - cat conftest.c >&5 - fi - rm -rf conftest* - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_sys_symbol_underscore" >&5 -$as_echo "$lt_cv_sys_symbol_underscore" >&6; } - sys_symbol_underscore=$lt_cv_sys_symbol_underscore - - - if test "x$sys_symbol_underscore" = xyes; then - -$as_echo "#define SYMBOL_UNDERSCORE 1" >>confdefs.h - - fi -fi - -FFI_EXEC_TRAMPOLINE_TABLE=0 +fi + case "$target" in - *arm*-apple-darwin*) - FFI_EXEC_TRAMPOLINE_TABLE=1 - -$as_echo "#define FFI_EXEC_TRAMPOLINE_TABLE 1" >>confdefs.h + *-apple-darwin10* | *-*-freebsd* | *-*-openbsd* | *-pc-solaris*) + +$as_echo "#define FFI_MMAP_EXEC_WRIT 1" >>confdefs.h ;; - *-apple-darwin1* | *-*-freebsd* | *-*-kfreebsd* | *-*-openbsd* | *-pc-solaris*) - -$as_echo "#define FFI_MMAP_EXEC_WRIT 1" >>confdefs.h - - ;; -esac - if test x$FFI_EXEC_TRAMPOLINE_TABLE = x1; then - FFI_EXEC_TRAMPOLINE_TABLE_TRUE= - FFI_EXEC_TRAMPOLINE_TABLE_FALSE='#' -else - FFI_EXEC_TRAMPOLINE_TABLE_TRUE='#' - FFI_EXEC_TRAMPOLINE_TABLE_FALSE= -fi - - - -if test x$TARGET = xX86_64; then - { $as_echo "$as_me:${as_lineno-$LINENO}: checking assembler supports unwind section type" >&5 -$as_echo_n "checking assembler supports unwind section type... " >&6; } -if ${libffi_cv_as_x86_64_unwind_section_type+:} false; then : - $as_echo_n "(cached) " >&6 -else - - libffi_cv_as_x86_64_unwind_section_type=yes - echo '.section .eh_frame,"a",@unwind' > conftest.s - if $CC $CFLAGS -c conftest.s 2>&1 | grep -i warning > /dev/null; then - libffi_cv_as_x86_64_unwind_section_type=no +esac + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether .eh_frame section should be read-only" >&5 +$as_echo_n "checking whether .eh_frame section should be read-only... " >&6; } +if test "${libffi_cv_ro_eh_frame+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + + libffi_cv_ro_eh_frame=no + echo 'extern void foo (void); void bar (void) { foo (); foo (); }' > conftest.c + if $CC $CFLAGS -S -fpic -fexceptions -o conftest.s conftest.c > /dev/null 2>&1; then + if grep '.section.*eh_frame.*"a"' conftest.s > /dev/null; then + libffi_cv_ro_eh_frame=yes + elif grep '.section.*eh_frame.*#alloc' conftest.c \ + | grep -v '#write' > /dev/null; then + libffi_cv_ro_eh_frame=yes + fi fi - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $libffi_cv_as_x86_64_unwind_section_type" >&5 -$as_echo "$libffi_cv_as_x86_64_unwind_section_type" >&6; } - if test "x$libffi_cv_as_x86_64_unwind_section_type" = xyes; then - -$as_echo "#define HAVE_AS_X86_64_UNWIND_SECTION_TYPE 1" >>confdefs.h - - fi -fi - -if test "x$GCC" = "xyes"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether .eh_frame section should be read-only" >&5 -$as_echo_n "checking whether .eh_frame section should be read-only... " >&6; } -if ${libffi_cv_ro_eh_frame+:} false; then : - $as_echo_n "(cached) " >&6 -else - - libffi_cv_ro_eh_frame=no - echo 'extern void foo (void); void bar (void) { foo (); foo (); }' > conftest.c - if $CC $CFLAGS -c -fpic -fexceptions -o conftest.o conftest.c > /dev/null 2>&1; then - objdump -h conftest.o > conftest.dump 2>&1 - libffi_eh_frame_line=`grep -n eh_frame conftest.dump | cut -d: -f 1` - libffi_test_line=`expr $libffi_eh_frame_line + 1`p - sed -n $libffi_test_line conftest.dump > conftest.line - if grep READONLY conftest.line > /dev/null; then - libffi_cv_ro_eh_frame=yes - fi - fi - rm -f conftest.* + rm -f conftest.* fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $libffi_cv_ro_eh_frame" >&5 $as_echo "$libffi_cv_ro_eh_frame" >&6; } - if test "x$libffi_cv_ro_eh_frame" = xyes; then +if test "x$libffi_cv_ro_eh_frame" = xyes; then $as_echo "#define HAVE_RO_EH_FRAME 1" >>confdefs.h $as_echo "#define EH_FRAME_FLAGS \"a\"" >>confdefs.h - else +else $as_echo "#define EH_FRAME_FLAGS \"aw\"" >>confdefs.h - fi - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for __attribute__((visibility(\"hidden\")))" >&5 +fi + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for __attribute__((visibility(\"hidden\")))" >&5 $as_echo_n "checking for __attribute__((visibility(\"hidden\")))... " >&6; } -if ${libffi_cv_hidden_visibility_attribute+:} false; then : - $as_echo_n "(cached) " >&6 -else - - echo 'int __attribute__ ((visibility ("hidden"))) foo (void) { return 1 ; }' > conftest.c - libffi_cv_hidden_visibility_attribute=no - if { ac_try='${CC-cc} -Werror -S conftest.c -o conftest.s 1>&5' +if test "${libffi_cv_hidden_visibility_attribute+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + + echo 'int __attribute__ ((visibility ("hidden"))) foo (void) { return 1; }' > conftest.c + libffi_cv_hidden_visibility_attribute=no + if { ac_try='${CC-cc} -Werror -S conftest.c -o conftest.s 1>&5' { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_try\""; } >&5 (eval $ac_try) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; }; then - if grep '\.hidden.*foo' conftest.s >/dev/null; then - libffi_cv_hidden_visibility_attribute=yes - fi - fi - rm -f conftest.* + if grep '\.hidden.*foo' conftest.s >/dev/null; then + libffi_cv_hidden_visibility_attribute=yes + fi + fi + rm -f conftest.* fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $libffi_cv_hidden_visibility_attribute" >&5 $as_echo "$libffi_cv_hidden_visibility_attribute" >&6; } - if test $libffi_cv_hidden_visibility_attribute = yes; then +if test $libffi_cv_hidden_visibility_attribute = yes; then $as_echo "#define HAVE_HIDDEN_VISIBILITY_ATTRIBUTE 1" >>confdefs.h - fi fi @@ -14786,14 +12365,6 @@ fi fi - if test "$enable_debug" = "yes"; then - FFI_DEBUG_TRUE= - FFI_DEBUG_FALSE='#' -else - FFI_DEBUG_TRUE='#' - FFI_DEBUG_FALSE= -fi - # Check whether --enable-structs was given. if test "${enable_structs+set}" = set; then : @@ -14804,14 +12375,6 @@ fi fi - if test "$enable_debug" = "yes"; then - FFI_DEBUG_TRUE= - FFI_DEBUG_FALSE='#' -else - FFI_DEBUG_TRUE='#' - FFI_DEBUG_FALSE= -fi - # Check whether --enable-raw-api was given. if test "${enable_raw_api+set}" = set; then : @@ -14833,27 +12396,27 @@ fi -# These variables are only ever used when we cross-build to X86_WIN32. -# And we only support this with GCC, so... -if test "x$GCC" = "xyes"; then - if test -n "$with_cross_host" && - test x"$with_cross_host" != x"no"; then - toolexecdir='$(exec_prefix)/$(target_alias)' - toolexeclibdir='$(toolexecdir)/lib' - else - toolexecdir='$(libdir)/gcc-lib/$(target_alias)' - toolexeclibdir='$(libdir)' - fi - multi_os_directory=`$CC -print-multi-os-directory` - case $multi_os_directory in - .) ;; # Avoid trailing /. - ../*) toolexeclibdir=$toolexeclibdir/$multi_os_directory ;; - esac - -else +if test -n "$with_cross_host" && + test x"$with_cross_host" != x"no"; then + toolexecdir='$(exec_prefix)/$(target_alias)' + toolexeclibdir='$(toolexecdir)/lib' +else + toolexecdir='$(libdir)/gcc-lib/$(target_alias)' toolexeclibdir='$(libdir)' fi - +multi_os_directory=`$CC -print-multi-os-directory` +case $multi_os_directory in + .) ;; # Avoid trailing /. + *) toolexeclibdir=$toolexeclibdir/$multi_os_directory ;; +esac + + + +if test "${multilib}" = "yes"; then + multilib_arg="--enable-multilib" +else + multilib_arg= +fi ac_config_commands="$ac_config_commands include" @@ -14936,21 +12499,10 @@ :end' >>confcache if diff "$cache_file" confcache >/dev/null 2>&1; then :; else if test -w "$cache_file"; then - if test "x$cache_file" != "x/dev/null"; then + test "x$cache_file" != "x/dev/null" && { $as_echo "$as_me:${as_lineno-$LINENO}: updating cache $cache_file" >&5 $as_echo "$as_me: updating cache $cache_file" >&6;} - if test ! -f "$cache_file" || test -h "$cache_file"; then - cat confcache >"$cache_file" - else - case $cache_file in #( - */* | ?:*) - mv -f confcache "$cache_file"$$ && - mv -f "$cache_file"$$ "$cache_file" ;; #( - *) - mv -f confcache "$cache_file" ;; - esac - fi - fi + cat confcache >$cache_file else { $as_echo "$as_me:${as_lineno-$LINENO}: not updating unwritable cache $cache_file" >&5 $as_echo "$as_me: not updating unwritable cache $cache_file" >&6;} @@ -14966,7 +12518,6 @@ ac_libobjs= ac_ltlibobjs= -U= for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue # 1. Remove the extension, and $U if already installed. ac_script='s/\$U\././;s/\.o$//;s/\.obj$//' @@ -14981,14 +12532,6 @@ LTLIBOBJS=$ac_ltlibobjs -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking that generated files are newer than configure" >&5 -$as_echo_n "checking that generated files are newer than configure... " >&6; } - if test -n "$am_sleep_pid"; then - # Hide warnings about reused PIDs. - wait $am_sleep_pid 2>/dev/null - fi - { $as_echo "$as_me:${as_lineno-$LINENO}: result: done" >&5 -$as_echo "done" >&6; } if test -n "$EXEEXT"; then am__EXEEXT_TRUE= am__EXEEXT_FALSE='#' @@ -14998,172 +12541,132 @@ fi if test -z "${AMDEP_TRUE}" && test -z "${AMDEP_FALSE}"; then - as_fn_error $? "conditional \"AMDEP\" was never defined. + as_fn_error "conditional \"AMDEP\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${am__fastdepCC_TRUE}" && test -z "${am__fastdepCC_FALSE}"; then - as_fn_error $? "conditional \"am__fastdepCC\" was never defined. + as_fn_error "conditional \"am__fastdepCC\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${am__fastdepCCAS_TRUE}" && test -z "${am__fastdepCCAS_FALSE}"; then - as_fn_error $? "conditional \"am__fastdepCCAS\" was never defined. + as_fn_error "conditional \"am__fastdepCCAS\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${MAINTAINER_MODE_TRUE}" && test -z "${MAINTAINER_MODE_FALSE}"; then - as_fn_error $? "conditional \"MAINTAINER_MODE\" was never defined. + as_fn_error "conditional \"MAINTAINER_MODE\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${TESTSUBDIR_TRUE}" && test -z "${TESTSUBDIR_FALSE}"; then - as_fn_error $? "conditional \"TESTSUBDIR\" was never defined. + as_fn_error "conditional \"TESTSUBDIR\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${MIPS_TRUE}" && test -z "${MIPS_FALSE}"; then - as_fn_error $? "conditional \"MIPS\" was never defined. + as_fn_error "conditional \"MIPS\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi -if test -z "${BFIN_TRUE}" && test -z "${BFIN_FALSE}"; then - as_fn_error $? "conditional \"BFIN\" was never defined. +if test -z "${SPARC_TRUE}" && test -z "${SPARC_FALSE}"; then + as_fn_error "conditional \"SPARC\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi -if test -z "${SPARC_TRUE}" && test -z "${SPARC_FALSE}"; then - as_fn_error $? "conditional \"SPARC\" was never defined. +if test -z "${X86_TRUE}" && test -z "${X86_FALSE}"; then + as_fn_error "conditional \"X86\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi -if test -z "${X86_TRUE}" && test -z "${X86_FALSE}"; then - as_fn_error $? "conditional \"X86\" was never defined. +if test -z "${X86_FREEBSD_TRUE}" && test -z "${X86_FREEBSD_FALSE}"; then + as_fn_error "conditional \"X86_FREEBSD\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi -if test -z "${X86_FREEBSD_TRUE}" && test -z "${X86_FREEBSD_FALSE}"; then - as_fn_error $? "conditional \"X86_FREEBSD\" was never defined. +if test -z "${X86_WIN32_TRUE}" && test -z "${X86_WIN32_FALSE}"; then + as_fn_error "conditional \"X86_WIN32\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi -if test -z "${X86_WIN32_TRUE}" && test -z "${X86_WIN32_FALSE}"; then - as_fn_error $? "conditional \"X86_WIN32\" was never defined. +if test -z "${X86_WIN64_TRUE}" && test -z "${X86_WIN64_FALSE}"; then + as_fn_error "conditional \"X86_WIN64\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi -if test -z "${X86_WIN64_TRUE}" && test -z "${X86_WIN64_FALSE}"; then - as_fn_error $? "conditional \"X86_WIN64\" was never defined. +if test -z "${X86_DARWIN_TRUE}" && test -z "${X86_DARWIN_FALSE}"; then + as_fn_error "conditional \"X86_DARWIN\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi -if test -z "${X86_DARWIN_TRUE}" && test -z "${X86_DARWIN_FALSE}"; then - as_fn_error $? "conditional \"X86_DARWIN\" was never defined. +if test -z "${ALPHA_TRUE}" && test -z "${ALPHA_FALSE}"; then + as_fn_error "conditional \"ALPHA\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi -if test -z "${ALPHA_TRUE}" && test -z "${ALPHA_FALSE}"; then - as_fn_error $? "conditional \"ALPHA\" was never defined. +if test -z "${IA64_TRUE}" && test -z "${IA64_FALSE}"; then + as_fn_error "conditional \"IA64\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi -if test -z "${IA64_TRUE}" && test -z "${IA64_FALSE}"; then - as_fn_error $? "conditional \"IA64\" was never defined. +if test -z "${M32R_TRUE}" && test -z "${M32R_FALSE}"; then + as_fn_error "conditional \"M32R\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi -if test -z "${M32R_TRUE}" && test -z "${M32R_FALSE}"; then - as_fn_error $? "conditional \"M32R\" was never defined. +if test -z "${M68K_TRUE}" && test -z "${M68K_FALSE}"; then + as_fn_error "conditional \"M68K\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi -if test -z "${M68K_TRUE}" && test -z "${M68K_FALSE}"; then - as_fn_error $? "conditional \"M68K\" was never defined. +if test -z "${POWERPC_TRUE}" && test -z "${POWERPC_FALSE}"; then + as_fn_error "conditional \"POWERPC\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi -if test -z "${MICROBLAZE_TRUE}" && test -z "${MICROBLAZE_FALSE}"; then - as_fn_error $? "conditional \"MICROBLAZE\" was never defined. +if test -z "${POWERPC_AIX_TRUE}" && test -z "${POWERPC_AIX_FALSE}"; then + as_fn_error "conditional \"POWERPC_AIX\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi -if test -z "${METAG_TRUE}" && test -z "${METAG_FALSE}"; then - as_fn_error $? "conditional \"METAG\" was never defined. +if test -z "${POWERPC_DARWIN_TRUE}" && test -z "${POWERPC_DARWIN_FALSE}"; then + as_fn_error "conditional \"POWERPC_DARWIN\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi -if test -z "${MOXIE_TRUE}" && test -z "${MOXIE_FALSE}"; then - as_fn_error $? "conditional \"MOXIE\" was never defined. +if test -z "${POWERPC_FREEBSD_TRUE}" && test -z "${POWERPC_FREEBSD_FALSE}"; then + as_fn_error "conditional \"POWERPC_FREEBSD\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi -if test -z "${POWERPC_TRUE}" && test -z "${POWERPC_FALSE}"; then - as_fn_error $? "conditional \"POWERPC\" was never defined. +if test -z "${ARM_TRUE}" && test -z "${ARM_FALSE}"; then + as_fn_error "conditional \"ARM\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi -if test -z "${POWERPC_AIX_TRUE}" && test -z "${POWERPC_AIX_FALSE}"; then - as_fn_error $? "conditional \"POWERPC_AIX\" was never defined. +if test -z "${AVR32_TRUE}" && test -z "${AVR32_FALSE}"; then + as_fn_error "conditional \"AVR32\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi -if test -z "${POWERPC_DARWIN_TRUE}" && test -z "${POWERPC_DARWIN_FALSE}"; then - as_fn_error $? "conditional \"POWERPC_DARWIN\" was never defined. +if test -z "${LIBFFI_CRIS_TRUE}" && test -z "${LIBFFI_CRIS_FALSE}"; then + as_fn_error "conditional \"LIBFFI_CRIS\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi -if test -z "${POWERPC_FREEBSD_TRUE}" && test -z "${POWERPC_FREEBSD_FALSE}"; then - as_fn_error $? "conditional \"POWERPC_FREEBSD\" was never defined. +if test -z "${FRV_TRUE}" && test -z "${FRV_FALSE}"; then + as_fn_error "conditional \"FRV\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi -if test -z "${AARCH64_TRUE}" && test -z "${AARCH64_FALSE}"; then - as_fn_error $? "conditional \"AARCH64\" was never defined. +if test -z "${S390_TRUE}" && test -z "${S390_FALSE}"; then + as_fn_error "conditional \"S390\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi -if test -z "${ARM_TRUE}" && test -z "${ARM_FALSE}"; then - as_fn_error $? "conditional \"ARM\" was never defined. +if test -z "${X86_64_TRUE}" && test -z "${X86_64_FALSE}"; then + as_fn_error "conditional \"X86_64\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi -if test -z "${AVR32_TRUE}" && test -z "${AVR32_FALSE}"; then - as_fn_error $? "conditional \"AVR32\" was never defined. +if test -z "${SH_TRUE}" && test -z "${SH_FALSE}"; then + as_fn_error "conditional \"SH\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi -if test -z "${LIBFFI_CRIS_TRUE}" && test -z "${LIBFFI_CRIS_FALSE}"; then - as_fn_error $? "conditional \"LIBFFI_CRIS\" was never defined. +if test -z "${SH64_TRUE}" && test -z "${SH64_FALSE}"; then + as_fn_error "conditional \"SH64\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi -if test -z "${FRV_TRUE}" && test -z "${FRV_FALSE}"; then - as_fn_error $? "conditional \"FRV\" was never defined. +if test -z "${PA_LINUX_TRUE}" && test -z "${PA_LINUX_FALSE}"; then + as_fn_error "conditional \"PA_LINUX\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi -if test -z "${S390_TRUE}" && test -z "${S390_FALSE}"; then - as_fn_error $? "conditional \"S390\" was never defined. +if test -z "${PA_HPUX_TRUE}" && test -z "${PA_HPUX_FALSE}"; then + as_fn_error "conditional \"PA_HPUX\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi -if test -z "${X86_64_TRUE}" && test -z "${X86_64_FALSE}"; then - as_fn_error $? "conditional \"X86_64\" was never defined. +if test -z "${PA64_HPUX_TRUE}" && test -z "${PA64_HPUX_FALSE}"; then + as_fn_error "conditional \"PA64_HPUX\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi -if test -z "${SH_TRUE}" && test -z "${SH_FALSE}"; then - as_fn_error $? "conditional \"SH\" was never defined. -Usually this means the macro was only invoked conditionally." "$LINENO" 5 -fi -if test -z "${SH64_TRUE}" && test -z "${SH64_FALSE}"; then - as_fn_error $? "conditional \"SH64\" was never defined. -Usually this means the macro was only invoked conditionally." "$LINENO" 5 -fi -if test -z "${PA_LINUX_TRUE}" && test -z "${PA_LINUX_FALSE}"; then - as_fn_error $? "conditional \"PA_LINUX\" was never defined. -Usually this means the macro was only invoked conditionally." "$LINENO" 5 -fi -if test -z "${PA_HPUX_TRUE}" && test -z "${PA_HPUX_FALSE}"; then - as_fn_error $? "conditional \"PA_HPUX\" was never defined. -Usually this means the macro was only invoked conditionally." "$LINENO" 5 -fi -if test -z "${PA64_HPUX_TRUE}" && test -z "${PA64_HPUX_FALSE}"; then - as_fn_error $? "conditional \"PA64_HPUX\" was never defined. -Usually this means the macro was only invoked conditionally." "$LINENO" 5 -fi -if test -z "${TILE_TRUE}" && test -z "${TILE_FALSE}"; then - as_fn_error $? "conditional \"TILE\" was never defined. -Usually this means the macro was only invoked conditionally." "$LINENO" 5 -fi -if test -z "${XTENSA_TRUE}" && test -z "${XTENSA_FALSE}"; then - as_fn_error $? "conditional \"XTENSA\" was never defined. -Usually this means the macro was only invoked conditionally." "$LINENO" 5 -fi - -if test -z "${FFI_EXEC_TRAMPOLINE_TABLE_TRUE}" && test -z "${FFI_EXEC_TRAMPOLINE_TABLE_FALSE}"; then - as_fn_error $? "conditional \"FFI_EXEC_TRAMPOLINE_TABLE\" was never defined. -Usually this means the macro was only invoked conditionally." "$LINENO" 5 -fi -if test -z "${FFI_DEBUG_TRUE}" && test -z "${FFI_DEBUG_FALSE}"; then - as_fn_error $? "conditional \"FFI_DEBUG\" was never defined. -Usually this means the macro was only invoked conditionally." "$LINENO" 5 -fi -if test -z "${FFI_DEBUG_TRUE}" && test -z "${FFI_DEBUG_FALSE}"; then - as_fn_error $? "conditional \"FFI_DEBUG\" was never defined. -Usually this means the macro was only invoked conditionally." "$LINENO" 5 -fi - -: "${CONFIG_STATUS=./config.status}" + + +: ${CONFIG_STATUS=./config.status} ac_write_fail=0 ac_clean_files_save=$ac_clean_files ac_clean_files="$ac_clean_files $CONFIG_STATUS" @@ -15264,7 +12767,6 @@ IFS=" "" $as_nl" # Find who we are. Look in the path if we contain no directory separator. -as_myself= case $0 in #(( *[\\/]* ) as_myself=$0 ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR @@ -15310,19 +12812,19 @@ (unset CDPATH) >/dev/null 2>&1 && unset CDPATH -# as_fn_error STATUS ERROR [LINENO LOG_FD] -# ---------------------------------------- +# as_fn_error ERROR [LINENO LOG_FD] +# --------------------------------- # Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are # provided, also output the error to LOG_FD, referencing LINENO. Then exit the -# script with STATUS, using 1 if that was 0. +# script with status $?, using 1 if that was 0. as_fn_error () { - as_status=$1; test $as_status -eq 0 && as_status=1 - if test "$4"; then - as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4 - fi - $as_echo "$as_me: error: $2" >&2 + as_status=$?; test $as_status -eq 0 && as_status=1 + if test "$3"; then + as_lineno=${as_lineno-"$2"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + $as_echo "$as_me:${as_lineno-$LINENO}: error: $1" >&$3 + fi + $as_echo "$as_me: error: $1" >&2 as_fn_exit $as_status } # as_fn_error @@ -15460,16 +12962,16 @@ # ... but there are two gotchas: # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. - # In both cases, we have to default to `cp -pR'. + # In both cases, we have to default to `cp -p'. ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || - as_ln_s='cp -pR' + as_ln_s='cp -p' elif ln conf$$.file conf$$ 2>/dev/null; then as_ln_s=ln else - as_ln_s='cp -pR' - fi -else - as_ln_s='cp -pR' + as_ln_s='cp -p' + fi +else + as_ln_s='cp -p' fi rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file rmdir conf$$.dir 2>/dev/null @@ -15518,7 +13020,7 @@ test -d "$as_dir" && break done test -z "$as_dirs" || eval "mkdir $as_dirs" - } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir" + } || test -d "$as_dir" || as_fn_error "cannot create directory $as_dir" } # as_fn_mkdir_p @@ -15529,16 +13031,28 @@ as_mkdir_p=false fi - -# as_fn_executable_p FILE -# ----------------------- -# Test if FILE is an executable regular file. -as_fn_executable_p () -{ - test -f "$1" && test -x "$1" -} # as_fn_executable_p -as_test_x='test -x' -as_executable_p=as_fn_executable_p +if test -x / >/dev/null 2>&1; then + as_test_x='test -x' +else + if ls -dL / >/dev/null 2>&1; then + as_ls_L_option=L + else + as_ls_L_option= + fi + as_test_x=' + eval sh -c '\'' + if test -d "$1"; then + test -d "$1/."; + else + case $1 in #( + -*)set "./$1";; + esac; + case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in #(( + ???[sx]*):;;*)false;;esac;fi + '\'' sh + ' +fi +as_executable_p=$as_test_x # Sed expression to map a string onto a valid CPP name. as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" @@ -15559,8 +13073,8 @@ # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by libffi $as_me 3.0.13, which was -generated by GNU Autoconf 2.69. Invocation command line was +This file was extended by libffi $as_me 3.0.10rc0, which was +generated by GNU Autoconf 2.65. Invocation command line was CONFIG_FILES = $CONFIG_FILES CONFIG_HEADERS = $CONFIG_HEADERS @@ -15623,17 +13137,17 @@ Configuration commands: $config_commands -Report bugs to ." +Report bugs to ." _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ -libffi config.status 3.0.13 -configured by $0, generated by GNU Autoconf 2.69, +libffi config.status 3.0.10rc0 +configured by $0, generated by GNU Autoconf 2.65, with options \\"\$ac_cs_config\\" -Copyright (C) 2012 Free Software Foundation, Inc. +Copyright (C) 2009 Free Software Foundation, Inc. This config.status script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it." @@ -15651,16 +13165,11 @@ while test $# != 0 do case $1 in - --*=?*) + --*=*) ac_option=`expr "X$1" : 'X\([^=]*\)='` ac_optarg=`expr "X$1" : 'X[^=]*=\(.*\)'` ac_shift=: ;; - --*=) - ac_option=`expr "X$1" : 'X\([^=]*\)='` - ac_optarg= - ac_shift=: - ;; *) ac_option=$1 ac_optarg=$2 @@ -15682,7 +13191,6 @@ $ac_shift case $ac_optarg in *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; - '') as_fn_error $? "missing file argument" ;; esac as_fn_append CONFIG_FILES " '$ac_optarg'" ac_need_defaults=false;; @@ -15695,7 +13203,7 @@ ac_need_defaults=false;; --he | --h) # Conflict between --help and --header - as_fn_error $? "ambiguous option: \`$1' + as_fn_error "ambiguous option: \`$1' Try \`$0 --help' for more information.";; --help | --hel | -h ) $as_echo "$ac_cs_usage"; exit ;; @@ -15704,7 +13212,7 @@ ac_cs_silent=: ;; # This is an error. - -*) as_fn_error $? "unrecognized option: \`$1' + -*) as_fn_error "unrecognized option: \`$1' Try \`$0 --help' for more information." ;; *) as_fn_append ac_config_targets " $1" @@ -15724,7 +13232,7 @@ _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 if \$ac_cs_recheck; then - set X $SHELL '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion + set X '$SHELL' '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion shift \$as_echo "running CONFIG_SHELL=$SHELL \$*" >&6 CONFIG_SHELL='$SHELL' @@ -15748,14 +13256,6 @@ # # INIT-COMMANDS # -ax_enable_builddir_srcdir="$srcdir" # $srcdir -ax_enable_builddir_host="$HOST" # $HOST / $host -ax_enable_builddir_version="$VERSION" # $VERSION -ax_enable_builddir_package="$PACKAGE" # $PACKAGE -ax_enable_builddir_auxdir="$ax_enable_builddir_auxdir" # $AUX -ax_enable_builddir_sed="$ax_enable_builddir_sed" # $SED -ax_enable_builddir="$ax_enable_builddir" # $SUB - AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir" @@ -15766,154 +13266,131 @@ sed_quote_subst='$sed_quote_subst' double_quote_subst='$double_quote_subst' delay_variable_subst='$delay_variable_subst' -macro_version='`$ECHO "$macro_version" | $SED "$delay_single_quote_subst"`' -macro_revision='`$ECHO "$macro_revision" | $SED "$delay_single_quote_subst"`' -enable_shared='`$ECHO "$enable_shared" | $SED "$delay_single_quote_subst"`' -enable_static='`$ECHO "$enable_static" | $SED "$delay_single_quote_subst"`' -pic_mode='`$ECHO "$pic_mode" | $SED "$delay_single_quote_subst"`' -enable_fast_install='`$ECHO "$enable_fast_install" | $SED "$delay_single_quote_subst"`' -SHELL='`$ECHO "$SHELL" | $SED "$delay_single_quote_subst"`' -ECHO='`$ECHO "$ECHO" | $SED "$delay_single_quote_subst"`' -PATH_SEPARATOR='`$ECHO "$PATH_SEPARATOR" | $SED "$delay_single_quote_subst"`' -host_alias='`$ECHO "$host_alias" | $SED "$delay_single_quote_subst"`' -host='`$ECHO "$host" | $SED "$delay_single_quote_subst"`' -host_os='`$ECHO "$host_os" | $SED "$delay_single_quote_subst"`' -build_alias='`$ECHO "$build_alias" | $SED "$delay_single_quote_subst"`' -build='`$ECHO "$build" | $SED "$delay_single_quote_subst"`' -build_os='`$ECHO "$build_os" | $SED "$delay_single_quote_subst"`' -SED='`$ECHO "$SED" | $SED "$delay_single_quote_subst"`' -Xsed='`$ECHO "$Xsed" | $SED "$delay_single_quote_subst"`' -GREP='`$ECHO "$GREP" | $SED "$delay_single_quote_subst"`' -EGREP='`$ECHO "$EGREP" | $SED "$delay_single_quote_subst"`' -FGREP='`$ECHO "$FGREP" | $SED "$delay_single_quote_subst"`' -LD='`$ECHO "$LD" | $SED "$delay_single_quote_subst"`' -NM='`$ECHO "$NM" | $SED "$delay_single_quote_subst"`' -LN_S='`$ECHO "$LN_S" | $SED "$delay_single_quote_subst"`' -max_cmd_len='`$ECHO "$max_cmd_len" | $SED "$delay_single_quote_subst"`' -ac_objext='`$ECHO "$ac_objext" | $SED "$delay_single_quote_subst"`' -exeext='`$ECHO "$exeext" | $SED "$delay_single_quote_subst"`' -lt_unset='`$ECHO "$lt_unset" | $SED "$delay_single_quote_subst"`' -lt_SP2NL='`$ECHO "$lt_SP2NL" | $SED "$delay_single_quote_subst"`' -lt_NL2SP='`$ECHO "$lt_NL2SP" | $SED "$delay_single_quote_subst"`' -lt_cv_to_host_file_cmd='`$ECHO "$lt_cv_to_host_file_cmd" | $SED "$delay_single_quote_subst"`' -lt_cv_to_tool_file_cmd='`$ECHO "$lt_cv_to_tool_file_cmd" | $SED "$delay_single_quote_subst"`' -reload_flag='`$ECHO "$reload_flag" | $SED "$delay_single_quote_subst"`' -reload_cmds='`$ECHO "$reload_cmds" | $SED "$delay_single_quote_subst"`' -OBJDUMP='`$ECHO "$OBJDUMP" | $SED "$delay_single_quote_subst"`' -deplibs_check_method='`$ECHO "$deplibs_check_method" | $SED "$delay_single_quote_subst"`' -file_magic_cmd='`$ECHO "$file_magic_cmd" | $SED "$delay_single_quote_subst"`' -file_magic_glob='`$ECHO "$file_magic_glob" | $SED "$delay_single_quote_subst"`' -want_nocaseglob='`$ECHO "$want_nocaseglob" | $SED "$delay_single_quote_subst"`' -DLLTOOL='`$ECHO "$DLLTOOL" | $SED "$delay_single_quote_subst"`' -sharedlib_from_linklib_cmd='`$ECHO "$sharedlib_from_linklib_cmd" | $SED "$delay_single_quote_subst"`' -AR='`$ECHO "$AR" | $SED "$delay_single_quote_subst"`' -AR_FLAGS='`$ECHO "$AR_FLAGS" | $SED "$delay_single_quote_subst"`' -archiver_list_spec='`$ECHO "$archiver_list_spec" | $SED "$delay_single_quote_subst"`' -STRIP='`$ECHO "$STRIP" | $SED "$delay_single_quote_subst"`' -RANLIB='`$ECHO "$RANLIB" | $SED "$delay_single_quote_subst"`' -old_postinstall_cmds='`$ECHO "$old_postinstall_cmds" | $SED "$delay_single_quote_subst"`' -old_postuninstall_cmds='`$ECHO "$old_postuninstall_cmds" | $SED "$delay_single_quote_subst"`' -old_archive_cmds='`$ECHO "$old_archive_cmds" | $SED "$delay_single_quote_subst"`' -lock_old_archive_extraction='`$ECHO "$lock_old_archive_extraction" | $SED "$delay_single_quote_subst"`' -CC='`$ECHO "$CC" | $SED "$delay_single_quote_subst"`' -CFLAGS='`$ECHO "$CFLAGS" | $SED "$delay_single_quote_subst"`' -compiler='`$ECHO "$compiler" | $SED "$delay_single_quote_subst"`' -GCC='`$ECHO "$GCC" | $SED "$delay_single_quote_subst"`' -lt_cv_sys_global_symbol_pipe='`$ECHO "$lt_cv_sys_global_symbol_pipe" | $SED "$delay_single_quote_subst"`' -lt_cv_sys_global_symbol_to_cdecl='`$ECHO "$lt_cv_sys_global_symbol_to_cdecl" | $SED "$delay_single_quote_subst"`' -lt_cv_sys_global_symbol_to_c_name_address='`$ECHO "$lt_cv_sys_global_symbol_to_c_name_address" | $SED "$delay_single_quote_subst"`' -lt_cv_sys_global_symbol_to_c_name_address_lib_prefix='`$ECHO "$lt_cv_sys_global_symbol_to_c_name_address_lib_prefix" | $SED "$delay_single_quote_subst"`' -nm_file_list_spec='`$ECHO "$nm_file_list_spec" | $SED "$delay_single_quote_subst"`' -lt_sysroot='`$ECHO "$lt_sysroot" | $SED "$delay_single_quote_subst"`' -objdir='`$ECHO "$objdir" | $SED "$delay_single_quote_subst"`' -MAGIC_CMD='`$ECHO "$MAGIC_CMD" | $SED "$delay_single_quote_subst"`' -lt_prog_compiler_no_builtin_flag='`$ECHO "$lt_prog_compiler_no_builtin_flag" | $SED "$delay_single_quote_subst"`' -lt_prog_compiler_pic='`$ECHO "$lt_prog_compiler_pic" | $SED "$delay_single_quote_subst"`' -lt_prog_compiler_wl='`$ECHO "$lt_prog_compiler_wl" | $SED "$delay_single_quote_subst"`' -lt_prog_compiler_static='`$ECHO "$lt_prog_compiler_static" | $SED "$delay_single_quote_subst"`' -lt_cv_prog_compiler_c_o='`$ECHO "$lt_cv_prog_compiler_c_o" | $SED "$delay_single_quote_subst"`' -need_locks='`$ECHO "$need_locks" | $SED "$delay_single_quote_subst"`' -MANIFEST_TOOL='`$ECHO "$MANIFEST_TOOL" | $SED "$delay_single_quote_subst"`' -DSYMUTIL='`$ECHO "$DSYMUTIL" | $SED "$delay_single_quote_subst"`' -NMEDIT='`$ECHO "$NMEDIT" | $SED "$delay_single_quote_subst"`' -LIPO='`$ECHO "$LIPO" | $SED "$delay_single_quote_subst"`' -OTOOL='`$ECHO "$OTOOL" | $SED "$delay_single_quote_subst"`' -OTOOL64='`$ECHO "$OTOOL64" | $SED "$delay_single_quote_subst"`' -libext='`$ECHO "$libext" | $SED "$delay_single_quote_subst"`' -shrext_cmds='`$ECHO "$shrext_cmds" | $SED "$delay_single_quote_subst"`' -extract_expsyms_cmds='`$ECHO "$extract_expsyms_cmds" | $SED "$delay_single_quote_subst"`' -archive_cmds_need_lc='`$ECHO "$archive_cmds_need_lc" | $SED "$delay_single_quote_subst"`' -enable_shared_with_static_runtimes='`$ECHO "$enable_shared_with_static_runtimes" | $SED "$delay_single_quote_subst"`' -export_dynamic_flag_spec='`$ECHO "$export_dynamic_flag_spec" | $SED "$delay_single_quote_subst"`' -whole_archive_flag_spec='`$ECHO "$whole_archive_flag_spec" | $SED "$delay_single_quote_subst"`' -compiler_needs_object='`$ECHO "$compiler_needs_object" | $SED "$delay_single_quote_subst"`' -old_archive_from_new_cmds='`$ECHO "$old_archive_from_new_cmds" | $SED "$delay_single_quote_subst"`' -old_archive_from_expsyms_cmds='`$ECHO "$old_archive_from_expsyms_cmds" | $SED "$delay_single_quote_subst"`' -archive_cmds='`$ECHO "$archive_cmds" | $SED "$delay_single_quote_subst"`' -archive_expsym_cmds='`$ECHO "$archive_expsym_cmds" | $SED "$delay_single_quote_subst"`' -module_cmds='`$ECHO "$module_cmds" | $SED "$delay_single_quote_subst"`' -module_expsym_cmds='`$ECHO "$module_expsym_cmds" | $SED "$delay_single_quote_subst"`' -with_gnu_ld='`$ECHO "$with_gnu_ld" | $SED "$delay_single_quote_subst"`' -allow_undefined_flag='`$ECHO "$allow_undefined_flag" | $SED "$delay_single_quote_subst"`' -no_undefined_flag='`$ECHO "$no_undefined_flag" | $SED "$delay_single_quote_subst"`' -hardcode_libdir_flag_spec='`$ECHO "$hardcode_libdir_flag_spec" | $SED "$delay_single_quote_subst"`' -hardcode_libdir_separator='`$ECHO "$hardcode_libdir_separator" | $SED "$delay_single_quote_subst"`' -hardcode_direct='`$ECHO "$hardcode_direct" | $SED "$delay_single_quote_subst"`' -hardcode_direct_absolute='`$ECHO "$hardcode_direct_absolute" | $SED "$delay_single_quote_subst"`' -hardcode_minus_L='`$ECHO "$hardcode_minus_L" | $SED "$delay_single_quote_subst"`' -hardcode_shlibpath_var='`$ECHO "$hardcode_shlibpath_var" | $SED "$delay_single_quote_subst"`' -hardcode_automatic='`$ECHO "$hardcode_automatic" | $SED "$delay_single_quote_subst"`' -inherit_rpath='`$ECHO "$inherit_rpath" | $SED "$delay_single_quote_subst"`' -link_all_deplibs='`$ECHO "$link_all_deplibs" | $SED "$delay_single_quote_subst"`' -always_export_symbols='`$ECHO "$always_export_symbols" | $SED "$delay_single_quote_subst"`' -export_symbols_cmds='`$ECHO "$export_symbols_cmds" | $SED "$delay_single_quote_subst"`' -exclude_expsyms='`$ECHO "$exclude_expsyms" | $SED "$delay_single_quote_subst"`' -include_expsyms='`$ECHO "$include_expsyms" | $SED "$delay_single_quote_subst"`' -prelink_cmds='`$ECHO "$prelink_cmds" | $SED "$delay_single_quote_subst"`' -postlink_cmds='`$ECHO "$postlink_cmds" | $SED "$delay_single_quote_subst"`' -file_list_spec='`$ECHO "$file_list_spec" | $SED "$delay_single_quote_subst"`' -variables_saved_for_relink='`$ECHO "$variables_saved_for_relink" | $SED "$delay_single_quote_subst"`' -need_lib_prefix='`$ECHO "$need_lib_prefix" | $SED "$delay_single_quote_subst"`' -need_version='`$ECHO "$need_version" | $SED "$delay_single_quote_subst"`' -version_type='`$ECHO "$version_type" | $SED "$delay_single_quote_subst"`' -runpath_var='`$ECHO "$runpath_var" | $SED "$delay_single_quote_subst"`' -shlibpath_var='`$ECHO "$shlibpath_var" | $SED "$delay_single_quote_subst"`' -shlibpath_overrides_runpath='`$ECHO "$shlibpath_overrides_runpath" | $SED "$delay_single_quote_subst"`' -libname_spec='`$ECHO "$libname_spec" | $SED "$delay_single_quote_subst"`' -library_names_spec='`$ECHO "$library_names_spec" | $SED "$delay_single_quote_subst"`' -soname_spec='`$ECHO "$soname_spec" | $SED "$delay_single_quote_subst"`' -install_override_mode='`$ECHO "$install_override_mode" | $SED "$delay_single_quote_subst"`' -postinstall_cmds='`$ECHO "$postinstall_cmds" | $SED "$delay_single_quote_subst"`' -postuninstall_cmds='`$ECHO "$postuninstall_cmds" | $SED "$delay_single_quote_subst"`' -finish_cmds='`$ECHO "$finish_cmds" | $SED "$delay_single_quote_subst"`' -finish_eval='`$ECHO "$finish_eval" | $SED "$delay_single_quote_subst"`' -hardcode_into_libs='`$ECHO "$hardcode_into_libs" | $SED "$delay_single_quote_subst"`' -sys_lib_search_path_spec='`$ECHO "$sys_lib_search_path_spec" | $SED "$delay_single_quote_subst"`' -sys_lib_dlsearch_path_spec='`$ECHO "$sys_lib_dlsearch_path_spec" | $SED "$delay_single_quote_subst"`' -hardcode_action='`$ECHO "$hardcode_action" | $SED "$delay_single_quote_subst"`' -enable_dlopen='`$ECHO "$enable_dlopen" | $SED "$delay_single_quote_subst"`' -enable_dlopen_self='`$ECHO "$enable_dlopen_self" | $SED "$delay_single_quote_subst"`' -enable_dlopen_self_static='`$ECHO "$enable_dlopen_self_static" | $SED "$delay_single_quote_subst"`' -old_striplib='`$ECHO "$old_striplib" | $SED "$delay_single_quote_subst"`' -striplib='`$ECHO "$striplib" | $SED "$delay_single_quote_subst"`' +macro_version='`$ECHO "X$macro_version" | $Xsed -e "$delay_single_quote_subst"`' +macro_revision='`$ECHO "X$macro_revision" | $Xsed -e "$delay_single_quote_subst"`' +enable_shared='`$ECHO "X$enable_shared" | $Xsed -e "$delay_single_quote_subst"`' +enable_static='`$ECHO "X$enable_static" | $Xsed -e "$delay_single_quote_subst"`' +pic_mode='`$ECHO "X$pic_mode" | $Xsed -e "$delay_single_quote_subst"`' +enable_fast_install='`$ECHO "X$enable_fast_install" | $Xsed -e "$delay_single_quote_subst"`' +host_alias='`$ECHO "X$host_alias" | $Xsed -e "$delay_single_quote_subst"`' +host='`$ECHO "X$host" | $Xsed -e "$delay_single_quote_subst"`' +host_os='`$ECHO "X$host_os" | $Xsed -e "$delay_single_quote_subst"`' +build_alias='`$ECHO "X$build_alias" | $Xsed -e "$delay_single_quote_subst"`' +build='`$ECHO "X$build" | $Xsed -e "$delay_single_quote_subst"`' +build_os='`$ECHO "X$build_os" | $Xsed -e "$delay_single_quote_subst"`' +SED='`$ECHO "X$SED" | $Xsed -e "$delay_single_quote_subst"`' +Xsed='`$ECHO "X$Xsed" | $Xsed -e "$delay_single_quote_subst"`' +GREP='`$ECHO "X$GREP" | $Xsed -e "$delay_single_quote_subst"`' +EGREP='`$ECHO "X$EGREP" | $Xsed -e "$delay_single_quote_subst"`' +FGREP='`$ECHO "X$FGREP" | $Xsed -e "$delay_single_quote_subst"`' +LD='`$ECHO "X$LD" | $Xsed -e "$delay_single_quote_subst"`' +NM='`$ECHO "X$NM" | $Xsed -e "$delay_single_quote_subst"`' +LN_S='`$ECHO "X$LN_S" | $Xsed -e "$delay_single_quote_subst"`' +max_cmd_len='`$ECHO "X$max_cmd_len" | $Xsed -e "$delay_single_quote_subst"`' +ac_objext='`$ECHO "X$ac_objext" | $Xsed -e "$delay_single_quote_subst"`' +exeext='`$ECHO "X$exeext" | $Xsed -e "$delay_single_quote_subst"`' +lt_unset='`$ECHO "X$lt_unset" | $Xsed -e "$delay_single_quote_subst"`' +lt_SP2NL='`$ECHO "X$lt_SP2NL" | $Xsed -e "$delay_single_quote_subst"`' +lt_NL2SP='`$ECHO "X$lt_NL2SP" | $Xsed -e "$delay_single_quote_subst"`' +reload_flag='`$ECHO "X$reload_flag" | $Xsed -e "$delay_single_quote_subst"`' +reload_cmds='`$ECHO "X$reload_cmds" | $Xsed -e "$delay_single_quote_subst"`' +OBJDUMP='`$ECHO "X$OBJDUMP" | $Xsed -e "$delay_single_quote_subst"`' +deplibs_check_method='`$ECHO "X$deplibs_check_method" | $Xsed -e "$delay_single_quote_subst"`' +file_magic_cmd='`$ECHO "X$file_magic_cmd" | $Xsed -e "$delay_single_quote_subst"`' +AR='`$ECHO "X$AR" | $Xsed -e "$delay_single_quote_subst"`' +AR_FLAGS='`$ECHO "X$AR_FLAGS" | $Xsed -e "$delay_single_quote_subst"`' +STRIP='`$ECHO "X$STRIP" | $Xsed -e "$delay_single_quote_subst"`' +RANLIB='`$ECHO "X$RANLIB" | $Xsed -e "$delay_single_quote_subst"`' +old_postinstall_cmds='`$ECHO "X$old_postinstall_cmds" | $Xsed -e "$delay_single_quote_subst"`' +old_postuninstall_cmds='`$ECHO "X$old_postuninstall_cmds" | $Xsed -e "$delay_single_quote_subst"`' +old_archive_cmds='`$ECHO "X$old_archive_cmds" | $Xsed -e "$delay_single_quote_subst"`' +CC='`$ECHO "X$CC" | $Xsed -e "$delay_single_quote_subst"`' +CFLAGS='`$ECHO "X$CFLAGS" | $Xsed -e "$delay_single_quote_subst"`' +compiler='`$ECHO "X$compiler" | $Xsed -e "$delay_single_quote_subst"`' +GCC='`$ECHO "X$GCC" | $Xsed -e "$delay_single_quote_subst"`' +lt_cv_sys_global_symbol_pipe='`$ECHO "X$lt_cv_sys_global_symbol_pipe" | $Xsed -e "$delay_single_quote_subst"`' +lt_cv_sys_global_symbol_to_cdecl='`$ECHO "X$lt_cv_sys_global_symbol_to_cdecl" | $Xsed -e "$delay_single_quote_subst"`' +lt_cv_sys_global_symbol_to_c_name_address='`$ECHO "X$lt_cv_sys_global_symbol_to_c_name_address" | $Xsed -e "$delay_single_quote_subst"`' +lt_cv_sys_global_symbol_to_c_name_address_lib_prefix='`$ECHO "X$lt_cv_sys_global_symbol_to_c_name_address_lib_prefix" | $Xsed -e "$delay_single_quote_subst"`' +objdir='`$ECHO "X$objdir" | $Xsed -e "$delay_single_quote_subst"`' +SHELL='`$ECHO "X$SHELL" | $Xsed -e "$delay_single_quote_subst"`' +ECHO='`$ECHO "X$ECHO" | $Xsed -e "$delay_single_quote_subst"`' +MAGIC_CMD='`$ECHO "X$MAGIC_CMD" | $Xsed -e "$delay_single_quote_subst"`' +lt_prog_compiler_no_builtin_flag='`$ECHO "X$lt_prog_compiler_no_builtin_flag" | $Xsed -e "$delay_single_quote_subst"`' +lt_prog_compiler_wl='`$ECHO "X$lt_prog_compiler_wl" | $Xsed -e "$delay_single_quote_subst"`' +lt_prog_compiler_pic='`$ECHO "X$lt_prog_compiler_pic" | $Xsed -e "$delay_single_quote_subst"`' +lt_prog_compiler_static='`$ECHO "X$lt_prog_compiler_static" | $Xsed -e "$delay_single_quote_subst"`' +lt_cv_prog_compiler_c_o='`$ECHO "X$lt_cv_prog_compiler_c_o" | $Xsed -e "$delay_single_quote_subst"`' +need_locks='`$ECHO "X$need_locks" | $Xsed -e "$delay_single_quote_subst"`' +DSYMUTIL='`$ECHO "X$DSYMUTIL" | $Xsed -e "$delay_single_quote_subst"`' +NMEDIT='`$ECHO "X$NMEDIT" | $Xsed -e "$delay_single_quote_subst"`' +LIPO='`$ECHO "X$LIPO" | $Xsed -e "$delay_single_quote_subst"`' +OTOOL='`$ECHO "X$OTOOL" | $Xsed -e "$delay_single_quote_subst"`' +OTOOL64='`$ECHO "X$OTOOL64" | $Xsed -e "$delay_single_quote_subst"`' +libext='`$ECHO "X$libext" | $Xsed -e "$delay_single_quote_subst"`' +shrext_cmds='`$ECHO "X$shrext_cmds" | $Xsed -e "$delay_single_quote_subst"`' +extract_expsyms_cmds='`$ECHO "X$extract_expsyms_cmds" | $Xsed -e "$delay_single_quote_subst"`' +archive_cmds_need_lc='`$ECHO "X$archive_cmds_need_lc" | $Xsed -e "$delay_single_quote_subst"`' +enable_shared_with_static_runtimes='`$ECHO "X$enable_shared_with_static_runtimes" | $Xsed -e "$delay_single_quote_subst"`' +export_dynamic_flag_spec='`$ECHO "X$export_dynamic_flag_spec" | $Xsed -e "$delay_single_quote_subst"`' +whole_archive_flag_spec='`$ECHO "X$whole_archive_flag_spec" | $Xsed -e "$delay_single_quote_subst"`' +compiler_needs_object='`$ECHO "X$compiler_needs_object" | $Xsed -e "$delay_single_quote_subst"`' +old_archive_from_new_cmds='`$ECHO "X$old_archive_from_new_cmds" | $Xsed -e "$delay_single_quote_subst"`' +old_archive_from_expsyms_cmds='`$ECHO "X$old_archive_from_expsyms_cmds" | $Xsed -e "$delay_single_quote_subst"`' +archive_cmds='`$ECHO "X$archive_cmds" | $Xsed -e "$delay_single_quote_subst"`' +archive_expsym_cmds='`$ECHO "X$archive_expsym_cmds" | $Xsed -e "$delay_single_quote_subst"`' +module_cmds='`$ECHO "X$module_cmds" | $Xsed -e "$delay_single_quote_subst"`' +module_expsym_cmds='`$ECHO "X$module_expsym_cmds" | $Xsed -e "$delay_single_quote_subst"`' +with_gnu_ld='`$ECHO "X$with_gnu_ld" | $Xsed -e "$delay_single_quote_subst"`' +allow_undefined_flag='`$ECHO "X$allow_undefined_flag" | $Xsed -e "$delay_single_quote_subst"`' +no_undefined_flag='`$ECHO "X$no_undefined_flag" | $Xsed -e "$delay_single_quote_subst"`' +hardcode_libdir_flag_spec='`$ECHO "X$hardcode_libdir_flag_spec" | $Xsed -e "$delay_single_quote_subst"`' +hardcode_libdir_flag_spec_ld='`$ECHO "X$hardcode_libdir_flag_spec_ld" | $Xsed -e "$delay_single_quote_subst"`' +hardcode_libdir_separator='`$ECHO "X$hardcode_libdir_separator" | $Xsed -e "$delay_single_quote_subst"`' +hardcode_direct='`$ECHO "X$hardcode_direct" | $Xsed -e "$delay_single_quote_subst"`' +hardcode_direct_absolute='`$ECHO "X$hardcode_direct_absolute" | $Xsed -e "$delay_single_quote_subst"`' +hardcode_minus_L='`$ECHO "X$hardcode_minus_L" | $Xsed -e "$delay_single_quote_subst"`' +hardcode_shlibpath_var='`$ECHO "X$hardcode_shlibpath_var" | $Xsed -e "$delay_single_quote_subst"`' +hardcode_automatic='`$ECHO "X$hardcode_automatic" | $Xsed -e "$delay_single_quote_subst"`' +inherit_rpath='`$ECHO "X$inherit_rpath" | $Xsed -e "$delay_single_quote_subst"`' +link_all_deplibs='`$ECHO "X$link_all_deplibs" | $Xsed -e "$delay_single_quote_subst"`' +fix_srcfile_path='`$ECHO "X$fix_srcfile_path" | $Xsed -e "$delay_single_quote_subst"`' +always_export_symbols='`$ECHO "X$always_export_symbols" | $Xsed -e "$delay_single_quote_subst"`' +export_symbols_cmds='`$ECHO "X$export_symbols_cmds" | $Xsed -e "$delay_single_quote_subst"`' +exclude_expsyms='`$ECHO "X$exclude_expsyms" | $Xsed -e "$delay_single_quote_subst"`' +include_expsyms='`$ECHO "X$include_expsyms" | $Xsed -e "$delay_single_quote_subst"`' +prelink_cmds='`$ECHO "X$prelink_cmds" | $Xsed -e "$delay_single_quote_subst"`' +file_list_spec='`$ECHO "X$file_list_spec" | $Xsed -e "$delay_single_quote_subst"`' +variables_saved_for_relink='`$ECHO "X$variables_saved_for_relink" | $Xsed -e "$delay_single_quote_subst"`' +need_lib_prefix='`$ECHO "X$need_lib_prefix" | $Xsed -e "$delay_single_quote_subst"`' +need_version='`$ECHO "X$need_version" | $Xsed -e "$delay_single_quote_subst"`' +version_type='`$ECHO "X$version_type" | $Xsed -e "$delay_single_quote_subst"`' +runpath_var='`$ECHO "X$runpath_var" | $Xsed -e "$delay_single_quote_subst"`' +shlibpath_var='`$ECHO "X$shlibpath_var" | $Xsed -e "$delay_single_quote_subst"`' +shlibpath_overrides_runpath='`$ECHO "X$shlibpath_overrides_runpath" | $Xsed -e "$delay_single_quote_subst"`' +libname_spec='`$ECHO "X$libname_spec" | $Xsed -e "$delay_single_quote_subst"`' +library_names_spec='`$ECHO "X$library_names_spec" | $Xsed -e "$delay_single_quote_subst"`' +soname_spec='`$ECHO "X$soname_spec" | $Xsed -e "$delay_single_quote_subst"`' +postinstall_cmds='`$ECHO "X$postinstall_cmds" | $Xsed -e "$delay_single_quote_subst"`' +postuninstall_cmds='`$ECHO "X$postuninstall_cmds" | $Xsed -e "$delay_single_quote_subst"`' +finish_cmds='`$ECHO "X$finish_cmds" | $Xsed -e "$delay_single_quote_subst"`' +finish_eval='`$ECHO "X$finish_eval" | $Xsed -e "$delay_single_quote_subst"`' +hardcode_into_libs='`$ECHO "X$hardcode_into_libs" | $Xsed -e "$delay_single_quote_subst"`' +sys_lib_search_path_spec='`$ECHO "X$sys_lib_search_path_spec" | $Xsed -e "$delay_single_quote_subst"`' +sys_lib_dlsearch_path_spec='`$ECHO "X$sys_lib_dlsearch_path_spec" | $Xsed -e "$delay_single_quote_subst"`' +hardcode_action='`$ECHO "X$hardcode_action" | $Xsed -e "$delay_single_quote_subst"`' +enable_dlopen='`$ECHO "X$enable_dlopen" | $Xsed -e "$delay_single_quote_subst"`' +enable_dlopen_self='`$ECHO "X$enable_dlopen_self" | $Xsed -e "$delay_single_quote_subst"`' +enable_dlopen_self_static='`$ECHO "X$enable_dlopen_self_static" | $Xsed -e "$delay_single_quote_subst"`' +old_striplib='`$ECHO "X$old_striplib" | $Xsed -e "$delay_single_quote_subst"`' +striplib='`$ECHO "X$striplib" | $Xsed -e "$delay_single_quote_subst"`' LTCC='$LTCC' LTCFLAGS='$LTCFLAGS' compiler='$compiler_DEFAULT' -# A function that is used when there is no print builtin or printf. -func_fallback_echo () -{ - eval 'cat <<_LTECHO_EOF -\$1 -_LTECHO_EOF' -} - # Quote evaled strings. -for var in SHELL \ -ECHO \ -PATH_SEPARATOR \ -SED \ +for var in SED \ GREP \ EGREP \ FGREP \ @@ -15926,13 +13403,8 @@ OBJDUMP \ deplibs_check_method \ file_magic_cmd \ -file_magic_glob \ -want_nocaseglob \ -DLLTOOL \ -sharedlib_from_linklib_cmd \ AR \ AR_FLAGS \ -archiver_list_spec \ STRIP \ RANLIB \ CC \ @@ -15942,14 +13414,14 @@ lt_cv_sys_global_symbol_to_cdecl \ lt_cv_sys_global_symbol_to_c_name_address \ lt_cv_sys_global_symbol_to_c_name_address_lib_prefix \ -nm_file_list_spec \ +SHELL \ +ECHO \ lt_prog_compiler_no_builtin_flag \ +lt_prog_compiler_wl \ lt_prog_compiler_pic \ -lt_prog_compiler_wl \ lt_prog_compiler_static \ lt_cv_prog_compiler_c_o \ need_locks \ -MANIFEST_TOOL \ DSYMUTIL \ NMEDIT \ LIPO \ @@ -15963,7 +13435,9 @@ allow_undefined_flag \ no_undefined_flag \ hardcode_libdir_flag_spec \ +hardcode_libdir_flag_spec_ld \ hardcode_libdir_separator \ +fix_srcfile_path \ exclude_expsyms \ include_expsyms \ file_list_spec \ @@ -15971,13 +13445,12 @@ libname_spec \ library_names_spec \ soname_spec \ -install_override_mode \ finish_eval \ old_striplib \ striplib; do - case \`eval \\\\\$ECHO \\\\""\\\\\$\$var"\\\\"\` in + case \`eval \\\\\$ECHO "X\\\\\$\$var"\` in *[\\\\\\\`\\"\\\$]*) - eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"\\\$\$var\\" | \\\$SED \\"\\\$sed_quote_subst\\"\\\`\\\\\\"" + eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"X\\\$\$var\\" | \\\$Xsed -e \\"\\\$sed_quote_subst\\"\\\`\\\\\\"" ;; *) eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\"" @@ -15999,15 +13472,14 @@ module_expsym_cmds \ export_symbols_cmds \ prelink_cmds \ -postlink_cmds \ postinstall_cmds \ postuninstall_cmds \ finish_cmds \ sys_lib_search_path_spec \ sys_lib_dlsearch_path_spec; do - case \`eval \\\\\$ECHO \\\\""\\\\\$\$var"\\\\"\` in + case \`eval \\\\\$ECHO "X\\\\\$\$var"\` in *[\\\\\\\`\\"\\\$]*) - eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"\\\$\$var\\" | \\\$SED -e \\"\\\$double_quote_subst\\" -e \\"\\\$sed_quote_subst\\" -e \\"\\\$delay_variable_subst\\"\\\`\\\\\\"" + eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"X\\\$\$var\\" | \\\$Xsed -e \\"\\\$double_quote_subst\\" -e \\"\\\$sed_quote_subst\\" -e \\"\\\$delay_variable_subst\\"\\\`\\\\\\"" ;; *) eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\"" @@ -16015,6 +13487,12 @@ esac done +# Fix-up fallback echo if it was mangled by the above quoting rules. +case \$lt_ECHO in +*'\\\$0 --fallback-echo"') lt_ECHO=\`\$ECHO "X\$lt_ECHO" | \$Xsed -e 's/\\\\\\\\\\\\\\\$0 --fallback-echo"\$/\$0 --fallback-echo"/'\` + ;; +esac + ac_aux_dir='$ac_aux_dir' xsi_shell='$xsi_shell' lt_shell_append='$lt_shell_append' @@ -16045,7 +13523,6 @@ do case $ac_config_target in "fficonfig.h") CONFIG_HEADERS="$CONFIG_HEADERS fficonfig.h" ;; - "buildir") CONFIG_COMMANDS="$CONFIG_COMMANDS buildir" ;; "depfiles") CONFIG_COMMANDS="$CONFIG_COMMANDS depfiles" ;; "libtool") CONFIG_COMMANDS="$CONFIG_COMMANDS libtool" ;; "include") CONFIG_COMMANDS="$CONFIG_COMMANDS include" ;; @@ -16060,7 +13537,7 @@ "include/ffi_common.h") CONFIG_LINKS="$CONFIG_LINKS include/ffi_common.h:include/ffi_common.h" ;; "fficonfig.py") CONFIG_FILES="$CONFIG_FILES fficonfig.py" ;; - *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;; + *) as_fn_error "invalid argument: \`$ac_config_target'" "$LINENO" 5;; esac done @@ -16084,10 +13561,9 @@ # after its creation but before its name has been assigned to `$tmp'. $debug || { - tmp= ac_tmp= + tmp= trap 'exit_status=$? - : "${ac_tmp:=$tmp}" - { test ! -d "$ac_tmp" || rm -fr "$ac_tmp"; } && exit $exit_status + { test -z "$tmp" || test ! -d "$tmp" || rm -fr "$tmp"; } && exit $exit_status ' 0 trap 'as_fn_exit 1' 1 2 13 15 } @@ -16095,13 +13571,12 @@ { tmp=`(umask 077 && mktemp -d "./confXXXXXX") 2>/dev/null` && - test -d "$tmp" + test -n "$tmp" && test -d "$tmp" } || { tmp=./conf$$-$RANDOM (umask 077 && mkdir "$tmp") -} || as_fn_error $? "cannot create a temporary directory in ." "$LINENO" 5 -ac_tmp=$tmp +} || as_fn_error "cannot create a temporary directory in ." "$LINENO" 5 # Set up the scripts for CONFIG_FILES section. # No need to generate them if there are no CONFIG_FILES. @@ -16118,12 +13593,12 @@ fi ac_cs_awk_cr=`$AWK 'BEGIN { print "a\rb" }' /dev/null` if test "$ac_cs_awk_cr" = "a${ac_cr}b"; then - ac_cs_awk_cr='\\r' + ac_cs_awk_cr='\r' else ac_cs_awk_cr=$ac_cr fi -echo 'BEGIN {' >"$ac_tmp/subs1.awk" && +echo 'BEGIN {' >"$tmp/subs1.awk" && _ACEOF @@ -16132,18 +13607,18 @@ echo "$ac_subst_vars" | sed 's/.*/&!$&$ac_delim/' && echo "_ACEOF" } >conf$$subs.sh || - as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 -ac_delim_num=`echo "$ac_subst_vars" | grep -c '^'` + as_fn_error "could not make $CONFIG_STATUS" "$LINENO" 5 +ac_delim_num=`echo "$ac_subst_vars" | grep -c '$'` ac_delim='%!_!# ' for ac_last_try in false false false false false :; do . ./conf$$subs.sh || - as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 + as_fn_error "could not make $CONFIG_STATUS" "$LINENO" 5 ac_delim_n=`sed -n "s/.*$ac_delim\$/X/p" conf$$subs.awk | grep -c X` if test $ac_delim_n = $ac_delim_num; then break elif $ac_last_try; then - as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 + as_fn_error "could not make $CONFIG_STATUS" "$LINENO" 5 else ac_delim="$ac_delim!$ac_delim _$ac_delim!! " fi @@ -16151,7 +13626,7 @@ rm -f conf$$subs.sh cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 -cat >>"\$ac_tmp/subs1.awk" <<\\_ACAWK && +cat >>"\$tmp/subs1.awk" <<\\_ACAWK && _ACEOF sed -n ' h @@ -16199,7 +13674,7 @@ rm -f conf$$subs.awk cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 _ACAWK -cat >>"\$ac_tmp/subs1.awk" <<_ACAWK && +cat >>"\$tmp/subs1.awk" <<_ACAWK && for (key in S) S_is_set[key] = 1 FS = "" @@ -16231,29 +13706,21 @@ sed "s/$ac_cr\$//; s/$ac_cr/$ac_cs_awk_cr/g" else cat -fi < "$ac_tmp/subs1.awk" > "$ac_tmp/subs.awk" \ - || as_fn_error $? "could not setup config files machinery" "$LINENO" 5 -_ACEOF - -# VPATH may cause trouble with some makes, so we remove sole $(srcdir), -# ${srcdir} and @srcdir@ entries from VPATH if srcdir is ".", strip leading and +fi < "$tmp/subs1.awk" > "$tmp/subs.awk" \ + || as_fn_error "could not setup config files machinery" "$LINENO" 5 +_ACEOF + +# VPATH may cause trouble with some makes, so we remove $(srcdir), +# ${srcdir} and @srcdir@ from VPATH if srcdir is ".", strip leading and # trailing colons and then remove the whole line if VPATH becomes empty # (actually we leave an empty line to preserve line numbers). if test "x$srcdir" = x.; then - ac_vpsub='/^[ ]*VPATH[ ]*=[ ]*/{ -h -s/// -s/^/:/ -s/[ ]*$/:/ -s/:\$(srcdir):/:/g -s/:\${srcdir}:/:/g -s/:@srcdir@:/:/g -s/^:*// + ac_vpsub='/^[ ]*VPATH[ ]*=/{ +s/:*\$(srcdir):*/:/ +s/:*\${srcdir}:*/:/ +s/:*@srcdir@:*/:/ +s/^\([^=]*=[ ]*\):*/\1/ s/:*$// -x -s/\(=[ ]*\).*/\1/ -G -s/\n// s/^[^=]*=[ ]*$// }' fi @@ -16265,7 +13732,7 @@ # No need to generate them if there are no CONFIG_HEADERS. # This happens for instance with `./config.status Makefile'. if test -n "$CONFIG_HEADERS"; then -cat >"$ac_tmp/defines.awk" <<\_ACAWK || +cat >"$tmp/defines.awk" <<\_ACAWK || BEGIN { _ACEOF @@ -16277,11 +13744,11 @@ # handling of long lines. ac_delim='%!_!# ' for ac_last_try in false false :; do - ac_tt=`sed -n "/$ac_delim/p" confdefs.h` - if test -z "$ac_tt"; then + ac_t=`sed -n "/$ac_delim/p" confdefs.h` + if test -z "$ac_t"; then break elif $ac_last_try; then - as_fn_error $? "could not make $CONFIG_HEADERS" "$LINENO" 5 + as_fn_error "could not make $CONFIG_HEADERS" "$LINENO" 5 else ac_delim="$ac_delim!$ac_delim _$ac_delim!! " fi @@ -16366,7 +13833,7 @@ _ACAWK _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 - as_fn_error $? "could not setup config headers machinery" "$LINENO" 5 + as_fn_error "could not setup config headers machinery" "$LINENO" 5 fi # test -n "$CONFIG_HEADERS" @@ -16379,7 +13846,7 @@ esac case $ac_mode$ac_tag in :[FHL]*:*);; - :L* | :C*:*) as_fn_error $? "invalid tag \`$ac_tag'" "$LINENO" 5;; + :L* | :C*:*) as_fn_error "invalid tag \`$ac_tag'" "$LINENO" 5;; :[FH]-) ac_tag=-:-;; :[FH]*) ac_tag=$ac_tag:$ac_tag.in;; esac @@ -16398,7 +13865,7 @@ for ac_f do case $ac_f in - -) ac_f="$ac_tmp/stdin";; + -) ac_f="$tmp/stdin";; *) # Look for the file first in the build tree, then in the source tree # (if the path is not absolute). The absolute path cannot be DOS-style, # because $ac_f cannot contain `:'. @@ -16407,7 +13874,7 @@ [\\/$]*) false;; *) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";; esac || - as_fn_error 1 "cannot find input file: \`$ac_f'" "$LINENO" 5;; + as_fn_error "cannot find input file: \`$ac_f'" "$LINENO" 5;; esac case $ac_f in *\'*) ac_f=`$as_echo "$ac_f" | sed "s/'/'\\\\\\\\''/g"`;; esac as_fn_append ac_file_inputs " '$ac_f'" @@ -16433,8 +13900,8 @@ esac case $ac_tag in - *:-:* | *:-) cat >"$ac_tmp/stdin" \ - || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;; + *:-:* | *:-) cat >"$tmp/stdin" \ + || as_fn_error "could not create $ac_file" "$LINENO" 5 ;; esac ;; esac @@ -16570,24 +14037,23 @@ s&@MKDIR_P@&$ac_MKDIR_P&;t t $ac_datarootdir_hack " -eval sed \"\$ac_sed_extra\" "$ac_file_inputs" | $AWK -f "$ac_tmp/subs.awk" \ - >$ac_tmp/out || as_fn_error $? "could not create $ac_file" "$LINENO" 5 +eval sed \"\$ac_sed_extra\" "$ac_file_inputs" | $AWK -f "$tmp/subs.awk" >$tmp/out \ + || as_fn_error "could not create $ac_file" "$LINENO" 5 test -z "$ac_datarootdir_hack$ac_datarootdir_seen" && - { ac_out=`sed -n '/\${datarootdir}/p' "$ac_tmp/out"`; test -n "$ac_out"; } && - { ac_out=`sed -n '/^[ ]*datarootdir[ ]*:*=/p' \ - "$ac_tmp/out"`; test -z "$ac_out"; } && + { ac_out=`sed -n '/\${datarootdir}/p' "$tmp/out"`; test -n "$ac_out"; } && + { ac_out=`sed -n '/^[ ]*datarootdir[ ]*:*=/p' "$tmp/out"`; test -z "$ac_out"; } && { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file contains a reference to the variable \`datarootdir' -which seems to be undefined. Please make sure it is defined" >&5 +which seems to be undefined. Please make sure it is defined." >&5 $as_echo "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir' -which seems to be undefined. Please make sure it is defined" >&2;} - - rm -f "$ac_tmp/stdin" +which seems to be undefined. Please make sure it is defined." >&2;} + + rm -f "$tmp/stdin" case $ac_file in - -) cat "$ac_tmp/out" && rm -f "$ac_tmp/out";; - *) rm -f "$ac_file" && mv "$ac_tmp/out" "$ac_file";; + -) cat "$tmp/out" && rm -f "$tmp/out";; + *) rm -f "$ac_file" && mv "$tmp/out" "$ac_file";; esac \ - || as_fn_error $? "could not create $ac_file" "$LINENO" 5 + || as_fn_error "could not create $ac_file" "$LINENO" 5 ;; :H) # @@ -16596,21 +14062,21 @@ if test x"$ac_file" != x-; then { $as_echo "/* $configure_input */" \ - && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs" - } >"$ac_tmp/config.h" \ - || as_fn_error $? "could not create $ac_file" "$LINENO" 5 - if diff "$ac_file" "$ac_tmp/config.h" >/dev/null 2>&1; then + && eval '$AWK -f "$tmp/defines.awk"' "$ac_file_inputs" + } >"$tmp/config.h" \ + || as_fn_error "could not create $ac_file" "$LINENO" 5 + if diff "$ac_file" "$tmp/config.h" >/dev/null 2>&1; then { $as_echo "$as_me:${as_lineno-$LINENO}: $ac_file is unchanged" >&5 $as_echo "$as_me: $ac_file is unchanged" >&6;} else rm -f "$ac_file" - mv "$ac_tmp/config.h" "$ac_file" \ - || as_fn_error $? "could not create $ac_file" "$LINENO" 5 + mv "$tmp/config.h" "$ac_file" \ + || as_fn_error "could not create $ac_file" "$LINENO" 5 fi else $as_echo "/* $configure_input */" \ - && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs" \ - || as_fn_error $? "could not create -" "$LINENO" 5 + && eval '$AWK -f "$tmp/defines.awk"' "$ac_file_inputs" \ + || as_fn_error "could not create -" "$LINENO" 5 fi # Compute "$ac_file"'s index in $config_headers. _am_arg="$ac_file" @@ -16664,19 +14130,19 @@ $as_echo "$as_me: linking $ac_source to $ac_file" >&6;} if test ! -r "$ac_source"; then - as_fn_error $? "$ac_source: file not found" "$LINENO" 5 + as_fn_error "$ac_source: file not found" "$LINENO" 5 fi rm -f "$ac_file" # Try a relative symlink, then a hard link, then a copy. - case $ac_source in + case $srcdir in [\\/$]* | ?:[\\/]* ) ac_rel_source=$ac_source ;; *) ac_rel_source=$ac_top_build_prefix$ac_source ;; esac ln -s "$ac_rel_source" "$ac_file" 2>/dev/null || ln "$ac_source" "$ac_file" 2>/dev/null || cp -p "$ac_source" "$ac_file" || - as_fn_error $? "cannot link or copy $ac_source to $ac_file" "$LINENO" 5 + as_fn_error "cannot link or copy $ac_source to $ac_file" "$LINENO" 5 fi ;; :C) { $as_echo "$as_me:${as_lineno-$LINENO}: executing $ac_file commands" >&5 @@ -16686,150 +14152,6 @@ case $ac_file$ac_mode in - "buildir":C) ac_top_srcdir="$ax_enable_builddir_srcdir" - if test ".$ax_enable_builddir" = ".." ; then - if test -f "$top_srcdir/Makefile" ; then - { $as_echo "$as_me:${as_lineno-$LINENO}: skipping top_srcdir/Makefile - left untouched" >&5 -$as_echo "$as_me: skipping top_srcdir/Makefile - left untouched" >&6;} - else - { $as_echo "$as_me:${as_lineno-$LINENO}: skipping top_srcdir/Makefile - not created" >&5 -$as_echo "$as_me: skipping top_srcdir/Makefile - not created" >&6;} - fi - else - if test -f "$ac_top_srcdir/Makefile" ; then - a=`grep "^VERSION " "$ac_top_srcdir/Makefile"` ; b=`grep "^VERSION " Makefile` - test "$a" != "$b" && rm "$ac_top_srcdir/Makefile" - fi - if test -f "$ac_top_srcdir/Makefile" ; then - echo "$ac_top_srcdir/Makefile : $ac_top_srcdir/Makefile.in" > $tmp/conftemp.mk - echo " @ echo 'REMOVED,,,' >\$@" >> $tmp/conftemp.mk - eval "${MAKE-make} -f $tmp/conftemp.mk 2>/dev/null >/dev/null" - if grep '^REMOVED,,,' "$ac_top_srcdir/Makefile" >/dev/null - then rm $ac_top_srcdir/Makefile ; fi - cp $tmp/conftemp.mk $ac_top_srcdir/makefiles.mk~ ## DEBUGGING - fi - if test ! -f "$ac_top_srcdir/Makefile" ; then - { $as_echo "$as_me:${as_lineno-$LINENO}: create top_srcdir/Makefile guessed from local Makefile" >&5 -$as_echo "$as_me: create top_srcdir/Makefile guessed from local Makefile" >&6;} - x='`' ; cat >$tmp/conftemp.sed <<_EOF -/^\$/n -x -/^\$/bS -x -/\\\\\$/{H;d;} -{H;s/.*//;x;} -bM -:S -x -/\\\\\$/{h;d;} -{h;s/.*//;x;} -:M -s/\\(\\n\\) /\\1 /g -/^ /d -/^[ ]*[\\#]/d -/^VPATH *=/d -s/^srcdir *=.*/srcdir = ./ -s/^top_srcdir *=.*/top_srcdir = ./ -/[:=]/!d -/^\\./d -/ = /b -/ .= /b -/:/!b -s/:.*/:/ -s/ / /g -s/ \\([a-z][a-z-]*[a-zA-Z0-9]\\)\\([ :]\\)/ \\1 \\1-all\\2/g -s/^\\([a-z][a-z-]*[a-zA-Z0-9]\\)\\([ :]\\)/\\1 \\1-all\\2/ -s/ / /g -/^all all-all[ :]/i\\ -all-configured : all-all -s/ [a-zA-Z0-9-]*-all [a-zA-Z0-9-]*-all-all//g -/-all-all/d -a\\ - @ HOST="\$(HOST)\" \\\\\\ - ; test ".\$\$HOST" = "." && HOST=$x sh $ax_enable_builddir_auxdir/config.guess $x \\\\\\ - ; BUILD=$x grep "^#### \$\$HOST " Makefile | sed -e 's/.*|//' $x \\\\\\ - ; use=$x basename "\$\@" -all $x; n=$x echo \$\$BUILD | wc -w $x \\\\\\ - ; echo "MAKE \$\$HOST : \$\$n * \$\@"; if test "\$\$n" -eq "0" ; then : \\\\\\ - ; BUILD=$x grep "^####.*|" Makefile |tail -1| sed -e 's/.*|//' $x ; fi \\\\\\ - ; test ".\$\$BUILD" = "." && BUILD="." \\\\\\ - ; test "\$\$use" = "\$\@" && BUILD=$x echo "\$\$BUILD" | tail -1 $x \\\\\\ - ; for i in \$\$BUILD ; do test ".\$\$i" = "." && continue \\\\\\ - ; (cd "\$\$i" && test ! -f configure && \$(MAKE) \$\$use) || exit; done -/dist-all *:/a\\ - @ HOST="\$(HOST)\" \\\\\\ - ; test ".\$\$HOST" = "." && HOST=$x sh $ax_enable_builddir_auxdir/config.guess $x \\\\\\ - ; BUILD=$x grep "^#### \$\$HOST " Makefile | sed -e 's/.*|//' $x \\\\\\ - ; found=$x echo \$\$BUILD | wc -w $x \\\\\\ - ; echo "MAKE \$\$HOST : \$\$found \$(PACKAGE)-\$(VERSION).tar.*" \\\\\\ - ; if test "\$\$found" -eq "0" ; then : \\\\\\ - ; BUILD=$x grep "^#### .*|" Makefile |tail -1| sed -e 's/.*|//' $x \\\\\\ - ; fi ; for i in \$\$BUILD ; do test ".\$\$i" = "." && continue \\\\\\ - ; for f in \$\$i/\$(PACKAGE)-\$(VERSION).tar.* \\\\\\ - ; do test -f "\$\$f" && mv "\$\$f" \$(PUB). ; done ; break ; done -/dist-[a-zA-Z0-9]*-all *:/a\\ - @ HOST="\$(HOST)\" \\\\\\ - ; test ".\$\$HOST" = "." && HOST=$x sh ./config.guess $x \\\\\\ - ; BUILD=$x grep "^#### \$\$HOST " Makefile | sed -e 's/.*|//' $x \\\\\\ - ; found=$x echo \$\$BUILD | wc -w $x \\\\\\ - ; echo "MAKE \$\$HOST : \$\$found \$(PACKAGE)-\$(VERSION).*" \\\\\\ - ; if test "\$\$found" -eq "0" ; then : \\\\\\ - ; BUILD=$x grep "^#### .*|" Makefile |tail -1| sed -e 's/.*|//' $x \\\\\\ - ; fi ; for i in \$\$BUILD ; do test ".\$\$i" = "." && continue \\\\\\ - ; for f in \$\$i/\$(PACKAGE)-\$(VERSION).* \\\\\\ - ; do test -f "\$\$f" && mv "\$\$f" \$(PUB). ; done ; break ; done -/distclean-all *:/a\\ - @ HOST="\$(HOST)\" \\\\\\ - ; test ".\$\$HOST" = "." && HOST=$x sh $ax_enable_builddir_auxdir/config.guess $x \\\\\\ - ; BUILD=$x grep "^#### .*|" Makefile | sed -e 's/.*|//' $x \\\\\\ - ; use=$x basename "\$\@" -all $x; n=$x echo \$\$BUILD | wc -w $x \\\\\\ - ; echo "MAKE \$\$HOST : \$\$n * \$\@ (all local builds)" \\\\\\ - ; test ".\$\$BUILD" = "." && BUILD="." \\\\\\ - ; for i in \$\$BUILD ; do test ".\$\$i" = "." && continue \\\\\\ - ; echo "# rm -r \$\$i"; done ; echo "# (sleep 3)" ; sleep 3 \\\\\\ - ; for i in \$\$BUILD ; do test ".\$\$i" = "." && continue \\\\\\ - ; echo "\$\$i" | grep "^/" > /dev/null && continue \\\\\\ - ; echo "\$\$i" | grep "^../" > /dev/null && continue \\\\\\ - ; echo "rm -r \$\$i"; (rm -r "\$\$i") ; done ; rm Makefile -_EOF - cp "$tmp/conftemp.sed" "$ac_top_srcdir/makefile.sed~" ## DEBUGGING - $ax_enable_builddir_sed -f $tmp/conftemp.sed Makefile >$ac_top_srcdir/Makefile - if test -f "$ac_top_srcdir/Makefile.mk" ; then - { $as_echo "$as_me:${as_lineno-$LINENO}: extend top_srcdir/Makefile with top_srcdir/Makefile.mk" >&5 -$as_echo "$as_me: extend top_srcdir/Makefile with top_srcdir/Makefile.mk" >&6;} - cat $ac_top_srcdir/Makefile.mk >>$ac_top_srcdir/Makefile - fi ; xxxx="####" - echo "$xxxx CONFIGURATIONS FOR TOPLEVEL MAKEFILE: " >>$ac_top_srcdir/Makefile - # sanity check - if grep '^; echo "MAKE ' $ac_top_srcdir/Makefile >/dev/null ; then - { $as_echo "$as_me:${as_lineno-$LINENO}: buggy sed found - it deletes tab in \"a\" text parts" >&5 -$as_echo "$as_me: buggy sed found - it deletes tab in \"a\" text parts" >&6;} - $ax_enable_builddir_sed -e '/^@ HOST=/s/^/ /' -e '/^; /s/^/ /' $ac_top_srcdir/Makefile \ - >$ac_top_srcdir/Makefile~ - (test -s $ac_top_srcdir/Makefile~ && mv $ac_top_srcdir/Makefile~ $ac_top_srcdir/Makefile) 2>/dev/null - fi - else - xxxx="\\#\\#\\#\\#" - # echo "/^$xxxx *$ax_enable_builddir_host /d" >$tmp/conftemp.sed - echo "s!^$xxxx [^|]* | *$ax_enable_builddir *\$!$xxxx ...... $ax_enable_builddir!" >$tmp/conftemp.sed - $ax_enable_builddir_sed -f "$tmp/conftemp.sed" "$ac_top_srcdir/Makefile" >$tmp/mkfile.tmp - cp "$tmp/conftemp.sed" "$ac_top_srcdir/makefiles.sed~" ## DEBUGGING - cp "$tmp/mkfile.tmp" "$ac_top_srcdir/makefiles.out~" ## DEBUGGING - if cmp -s "$ac_top_srcdir/Makefile" "$tmp/mkfile.tmp" 2>/dev/null ; then - { $as_echo "$as_me:${as_lineno-$LINENO}: keeping top_srcdir/Makefile from earlier configure" >&5 -$as_echo "$as_me: keeping top_srcdir/Makefile from earlier configure" >&6;} - rm "$tmp/mkfile.tmp" - else - { $as_echo "$as_me:${as_lineno-$LINENO}: reusing top_srcdir/Makefile from earlier configure" >&5 -$as_echo "$as_me: reusing top_srcdir/Makefile from earlier configure" >&6;} - mv "$tmp/mkfile.tmp" "$ac_top_srcdir/Makefile" - fi - fi - { $as_echo "$as_me:${as_lineno-$LINENO}: build in $ax_enable_builddir (HOST=$ax_enable_builddir_host)" >&5 -$as_echo "$as_me: build in $ax_enable_builddir (HOST=$ax_enable_builddir_host)" >&6;} - xxxx="####" - echo "$xxxx" "$ax_enable_builddir_host" "|$ax_enable_builddir" >>$ac_top_srcdir/Makefile - fi - ;; "depfiles":C) test x"$AMDEP_TRUE" != x"" || { # Autoconf 2.62 quotes --file arguments for eval, but not when files # are listed without --file. Let's play safe and only enable the eval @@ -16844,7 +14166,7 @@ # Strip MF so we end up with the name of the file. mf=`echo "$mf" | sed -e 's/:.*$//'` # Check whether this is an Automake generated Makefile or not. - # We used to match only the files named 'Makefile.in', but + # We used to match only the files named `Makefile.in', but # some people rename them; so instead we look at the file content. # Grep'ing the first line is not enough: some people post-process # each Makefile.in and add a new line on top of each file to say so. @@ -16878,19 +14200,21 @@ continue fi # Extract the definition of DEPDIR, am__include, and am__quote - # from the Makefile without running 'make'. + # from the Makefile without running `make'. DEPDIR=`sed -n 's/^DEPDIR = //p' < "$mf"` test -z "$DEPDIR" && continue am__include=`sed -n 's/^am__include = //p' < "$mf"` test -z "am__include" && continue am__quote=`sed -n 's/^am__quote = //p' < "$mf"` + # When using ansi2knr, U may be empty or an underscore; expand it + U=`sed -n 's/^U = //p' < "$mf"` # Find all dependency output files, they are included files with # $(DEPDIR) in their names. We invoke sed twice because it is the # simplest approach to changing $(DEPDIR) to its actual value in the # expansion. for file in `sed -n " s/^$am__include $am__quote\(.*(DEPDIR).*\)$am__quote"'$/\1/p' <"$mf" | \ - sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g'`; do + sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g' -e 's/\$U/'"$U"'/g'`; do # Make sure the directory exists. test -f "$dirpart/$file" && continue fdir=`$as_dirname -- "$file" || @@ -16944,8 +14268,7 @@ # NOTE: Changes made to this file will be lost: look at ltmain.sh. # # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, -# 2006, 2007, 2008, 2009, 2010, 2011 Free Software -# Foundation, Inc. +# 2006, 2007, 2008 Free Software Foundation, Inc. # Written by Gordon Matzigkeit, 1996 # # This file is part of GNU Libtool. @@ -16993,15 +14316,6 @@ # Whether or not to optimize for fast installation. fast_install=$enable_fast_install -# Shell to use when invoking shell scripts. -SHELL=$lt_SHELL - -# An echo program that protects backslashes. -ECHO=$lt_ECHO - -# The PATH separator for the build system. -PATH_SEPARATOR=$lt_PATH_SEPARATOR - # The host system. host_alias=$host_alias host=$host @@ -17051,11 +14365,9 @@ # turn newlines into spaces. NL2SP=$lt_lt_NL2SP -# convert \$build file names to \$host format. -to_host_file_cmd=$lt_cv_to_host_file_cmd - -# convert \$build files to toolchain format. -to_tool_file_cmd=$lt_cv_to_tool_file_cmd +# How to create reloadable object files. +reload_flag=$lt_reload_flag +reload_cmds=$lt_reload_cmds # An object symbol dumper. OBJDUMP=$lt_OBJDUMP @@ -17063,30 +14375,13 @@ # Method to check whether dependent libraries are shared objects. deplibs_check_method=$lt_deplibs_check_method -# Command to use when deplibs_check_method = "file_magic". +# Command to use when deplibs_check_method == "file_magic". file_magic_cmd=$lt_file_magic_cmd -# How to find potential files when deplibs_check_method = "file_magic". -file_magic_glob=$lt_file_magic_glob - -# Find potential files using nocaseglob when deplibs_check_method = "file_magic". -want_nocaseglob=$lt_want_nocaseglob - -# DLL creation program. -DLLTOOL=$lt_DLLTOOL - -# Command to associate shared and link libraries. -sharedlib_from_linklib_cmd=$lt_sharedlib_from_linklib_cmd - # The archiver. AR=$lt_AR - -# Flags to create an archive. AR_FLAGS=$lt_AR_FLAGS -# How to feed a file listing to the archiver. -archiver_list_spec=$lt_archiver_list_spec - # A symbol stripping program. STRIP=$lt_STRIP @@ -17095,9 +14390,6 @@ old_postinstall_cmds=$lt_old_postinstall_cmds old_postuninstall_cmds=$lt_old_postuninstall_cmds -# Whether to use a lock for old archive extraction. -lock_old_archive_extraction=$lock_old_archive_extraction - # A C compiler. LTCC=$lt_CC @@ -17116,24 +14408,21 @@ # Transform the output of nm in a C name address pair when lib prefix is needed. global_symbol_to_c_name_address_lib_prefix=$lt_lt_cv_sys_global_symbol_to_c_name_address_lib_prefix -# Specify filename containing input files for \$NM. -nm_file_list_spec=$lt_nm_file_list_spec - -# The root where to search for dependent libraries,and in which our libraries should be installed. -lt_sysroot=$lt_sysroot - # The name of the directory that contains temporary libtool files. objdir=$objdir +# Shell to use when invoking shell scripts. +SHELL=$lt_SHELL + +# An echo program that does not interpret backslashes. +ECHO=$lt_ECHO + # Used to examine libraries when file_magic_cmd begins with "file". MAGIC_CMD=$MAGIC_CMD # Must we lock files when doing compilation? need_locks=$lt_need_locks -# Manifest tool. -MANIFEST_TOOL=$lt_MANIFEST_TOOL - # Tool to manipulate archived DWARF debug symbol files on Mac OS X. DSYMUTIL=$lt_DSYMUTIL @@ -17190,9 +14479,6 @@ # The coded name of the library, if different from the real name. soname_spec=$lt_soname_spec -# Permission mode override for installation of shared libraries. -install_override_mode=$lt_install_override_mode - # Command to use after installation of a shared archive. postinstall_cmds=$lt_postinstall_cmds @@ -17232,10 +14518,6 @@ # The linker used to build libraries. LD=$lt_LD -# How to create reloadable object files. -reload_flag=$lt_reload_flag -reload_cmds=$lt_reload_cmds - # Commands used to build an old-style archive. old_archive_cmds=$lt_old_archive_cmds @@ -17248,12 +14530,12 @@ # Compiler flag to turn off builtin functions. no_builtin_flag=$lt_lt_prog_compiler_no_builtin_flag +# How to pass a linker flag through the compiler. +wl=$lt_lt_prog_compiler_wl + # Additional compiler flags for building library objects. pic_flag=$lt_lt_prog_compiler_pic -# How to pass a linker flag through the compiler. -wl=$lt_lt_prog_compiler_wl - # Compiler flag to prevent dynamic linking. link_static_flag=$lt_lt_prog_compiler_static @@ -17303,6 +14585,10 @@ # This must work even if \$libdir does not exist hardcode_libdir_flag_spec=$lt_hardcode_libdir_flag_spec +# If ld is used when linking, flag to hardcode \$libdir into a binary +# during linking. This must work even if \$libdir does not exist. +hardcode_libdir_flag_spec_ld=$lt_hardcode_libdir_flag_spec_ld + # Whether we need a single "-rpath" flag with a separated argument. hardcode_libdir_separator=$lt_hardcode_libdir_separator @@ -17336,6 +14622,9 @@ # Whether libtool must link a program against all its dependency libraries. link_all_deplibs=$link_all_deplibs +# Fix the shell variable \$srcfile for the compiler. +fix_srcfile_path=$lt_fix_srcfile_path + # Set to "yes" if exported symbols are required. always_export_symbols=$always_export_symbols @@ -17351,9 +14640,6 @@ # Commands necessary for linking programs (against libraries) with templates. prelink_cmds=$lt_prelink_cmds -# Commands necessary for finishing linking programs. -postlink_cmds=$lt_postlink_cmds - # Specify filename containing input files. file_list_spec=$lt_file_list_spec @@ -17386,169 +14672,212 @@ # if finds mixed CR/LF and LF-only lines. Since sed operates in # text mode, it properly converts lines to CR/LF. This bash problem # is reportedly fixed, but why not run on old versions too? - sed '$q' "$ltmain" >> "$cfgfile" \ - || (rm -f "$cfgfile"; exit 1) - - if test x"$xsi_shell" = xyes; then - sed -e '/^func_dirname ()$/,/^} # func_dirname /c\ -func_dirname ()\ -{\ -\ case ${1} in\ -\ */*) func_dirname_result="${1%/*}${2}" ;;\ -\ * ) func_dirname_result="${3}" ;;\ -\ esac\ -} # Extended-shell func_dirname implementation' "$cfgfile" > $cfgfile.tmp \ - && mv -f "$cfgfile.tmp" "$cfgfile" \ - || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") -test 0 -eq $? || _lt_function_replace_fail=: - - - sed -e '/^func_basename ()$/,/^} # func_basename /c\ -func_basename ()\ -{\ -\ func_basename_result="${1##*/}"\ -} # Extended-shell func_basename implementation' "$cfgfile" > $cfgfile.tmp \ - && mv -f "$cfgfile.tmp" "$cfgfile" \ - || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") -test 0 -eq $? || _lt_function_replace_fail=: - - - sed -e '/^func_dirname_and_basename ()$/,/^} # func_dirname_and_basename /c\ -func_dirname_and_basename ()\ -{\ -\ case ${1} in\ -\ */*) func_dirname_result="${1%/*}${2}" ;;\ -\ * ) func_dirname_result="${3}" ;;\ -\ esac\ -\ func_basename_result="${1##*/}"\ -} # Extended-shell func_dirname_and_basename implementation' "$cfgfile" > $cfgfile.tmp \ - && mv -f "$cfgfile.tmp" "$cfgfile" \ - || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") -test 0 -eq $? || _lt_function_replace_fail=: - - - sed -e '/^func_stripname ()$/,/^} # func_stripname /c\ -func_stripname ()\ -{\ -\ # pdksh 5.2.14 does not do ${X%$Y} correctly if both X and Y are\ -\ # positional parameters, so assign one to ordinary parameter first.\ -\ func_stripname_result=${3}\ -\ func_stripname_result=${func_stripname_result#"${1}"}\ -\ func_stripname_result=${func_stripname_result%"${2}"}\ -} # Extended-shell func_stripname implementation' "$cfgfile" > $cfgfile.tmp \ - && mv -f "$cfgfile.tmp" "$cfgfile" \ - || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") -test 0 -eq $? || _lt_function_replace_fail=: - - - sed -e '/^func_split_long_opt ()$/,/^} # func_split_long_opt /c\ -func_split_long_opt ()\ -{\ -\ func_split_long_opt_name=${1%%=*}\ -\ func_split_long_opt_arg=${1#*=}\ -} # Extended-shell func_split_long_opt implementation' "$cfgfile" > $cfgfile.tmp \ - && mv -f "$cfgfile.tmp" "$cfgfile" \ - || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") -test 0 -eq $? || _lt_function_replace_fail=: - - - sed -e '/^func_split_short_opt ()$/,/^} # func_split_short_opt /c\ -func_split_short_opt ()\ -{\ -\ func_split_short_opt_arg=${1#??}\ -\ func_split_short_opt_name=${1%"$func_split_short_opt_arg"}\ -} # Extended-shell func_split_short_opt implementation' "$cfgfile" > $cfgfile.tmp \ - && mv -f "$cfgfile.tmp" "$cfgfile" \ - || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") -test 0 -eq $? || _lt_function_replace_fail=: - - - sed -e '/^func_lo2o ()$/,/^} # func_lo2o /c\ -func_lo2o ()\ -{\ -\ case ${1} in\ -\ *.lo) func_lo2o_result=${1%.lo}.${objext} ;;\ -\ *) func_lo2o_result=${1} ;;\ -\ esac\ -} # Extended-shell func_lo2o implementation' "$cfgfile" > $cfgfile.tmp \ - && mv -f "$cfgfile.tmp" "$cfgfile" \ - || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") -test 0 -eq $? || _lt_function_replace_fail=: - - - sed -e '/^func_xform ()$/,/^} # func_xform /c\ -func_xform ()\ -{\ - func_xform_result=${1%.*}.lo\ -} # Extended-shell func_xform implementation' "$cfgfile" > $cfgfile.tmp \ - && mv -f "$cfgfile.tmp" "$cfgfile" \ - || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") -test 0 -eq $? || _lt_function_replace_fail=: - - - sed -e '/^func_arith ()$/,/^} # func_arith /c\ -func_arith ()\ -{\ - func_arith_result=$(( $* ))\ -} # Extended-shell func_arith implementation' "$cfgfile" > $cfgfile.tmp \ - && mv -f "$cfgfile.tmp" "$cfgfile" \ - || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") -test 0 -eq $? || _lt_function_replace_fail=: - - - sed -e '/^func_len ()$/,/^} # func_len /c\ -func_len ()\ -{\ - func_len_result=${#1}\ -} # Extended-shell func_len implementation' "$cfgfile" > $cfgfile.tmp \ - && mv -f "$cfgfile.tmp" "$cfgfile" \ - || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") -test 0 -eq $? || _lt_function_replace_fail=: - -fi - -if test x"$lt_shell_append" = xyes; then - sed -e '/^func_append ()$/,/^} # func_append /c\ -func_append ()\ -{\ - eval "${1}+=\\${2}"\ -} # Extended-shell func_append implementation' "$cfgfile" > $cfgfile.tmp \ - && mv -f "$cfgfile.tmp" "$cfgfile" \ - || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") -test 0 -eq $? || _lt_function_replace_fail=: - - - sed -e '/^func_append_quoted ()$/,/^} # func_append_quoted /c\ -func_append_quoted ()\ -{\ -\ func_quote_for_eval "${2}"\ -\ eval "${1}+=\\\\ \\$func_quote_for_eval_result"\ -} # Extended-shell func_append_quoted implementation' "$cfgfile" > $cfgfile.tmp \ - && mv -f "$cfgfile.tmp" "$cfgfile" \ - || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") -test 0 -eq $? || _lt_function_replace_fail=: - - - # Save a `func_append' function call where possible by direct use of '+=' - sed -e 's%func_append \([a-zA-Z_]\{1,\}\) "%\1+="%g' $cfgfile > $cfgfile.tmp \ - && mv -f "$cfgfile.tmp" "$cfgfile" \ - || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") - test 0 -eq $? || _lt_function_replace_fail=: -else - # Save a `func_append' function call even when '+=' is not available - sed -e 's%func_append \([a-zA-Z_]\{1,\}\) "%\1="$\1%g' $cfgfile > $cfgfile.tmp \ - && mv -f "$cfgfile.tmp" "$cfgfile" \ - || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") - test 0 -eq $? || _lt_function_replace_fail=: -fi - -if test x"$_lt_function_replace_fail" = x":"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Unable to substitute extended shell functions in $ofile" >&5 -$as_echo "$as_me: WARNING: Unable to substitute extended shell functions in $ofile" >&2;} -fi - - - mv -f "$cfgfile" "$ofile" || + sed '/^# Generated shell functions inserted here/q' "$ltmain" >> "$cfgfile" \ + || (rm -f "$cfgfile"; exit 1) + + case $xsi_shell in + yes) + cat << \_LT_EOF >> "$cfgfile" + +# func_dirname file append nondir_replacement +# Compute the dirname of FILE. If nonempty, add APPEND to the result, +# otherwise set result to NONDIR_REPLACEMENT. +func_dirname () +{ + case ${1} in + */*) func_dirname_result="${1%/*}${2}" ;; + * ) func_dirname_result="${3}" ;; + esac +} + +# func_basename file +func_basename () +{ + func_basename_result="${1##*/}" +} + +# func_dirname_and_basename file append nondir_replacement +# perform func_basename and func_dirname in a single function +# call: +# dirname: Compute the dirname of FILE. If nonempty, +# add APPEND to the result, otherwise set result +# to NONDIR_REPLACEMENT. +# value returned in "$func_dirname_result" +# basename: Compute filename of FILE. +# value retuned in "$func_basename_result" +# Implementation must be kept synchronized with func_dirname +# and func_basename. For efficiency, we do not delegate to +# those functions but instead duplicate the functionality here. +func_dirname_and_basename () +{ + case ${1} in + */*) func_dirname_result="${1%/*}${2}" ;; + * ) func_dirname_result="${3}" ;; + esac + func_basename_result="${1##*/}" +} + +# func_stripname prefix suffix name +# strip PREFIX and SUFFIX off of NAME. +# PREFIX and SUFFIX must not contain globbing or regex special +# characters, hashes, percent signs, but SUFFIX may contain a leading +# dot (in which case that matches only a dot). +func_stripname () +{ + # pdksh 5.2.14 does not do ${X%$Y} correctly if both X and Y are + # positional parameters, so assign one to ordinary parameter first. + func_stripname_result=${3} + func_stripname_result=${func_stripname_result#"${1}"} + func_stripname_result=${func_stripname_result%"${2}"} +} + +# func_opt_split +func_opt_split () +{ + func_opt_split_opt=${1%%=*} + func_opt_split_arg=${1#*=} +} + +# func_lo2o object +func_lo2o () +{ + case ${1} in + *.lo) func_lo2o_result=${1%.lo}.${objext} ;; + *) func_lo2o_result=${1} ;; + esac +} + +# func_xform libobj-or-source +func_xform () +{ + func_xform_result=${1%.*}.lo +} + +# func_arith arithmetic-term... +func_arith () +{ + func_arith_result=$(( $* )) +} + +# func_len string +# STRING may not start with a hyphen. +func_len () +{ + func_len_result=${#1} +} + +_LT_EOF + ;; + *) # Bourne compatible functions. + cat << \_LT_EOF >> "$cfgfile" + +# func_dirname file append nondir_replacement +# Compute the dirname of FILE. If nonempty, add APPEND to the result, +# otherwise set result to NONDIR_REPLACEMENT. +func_dirname () +{ + # Extract subdirectory from the argument. + func_dirname_result=`$ECHO "X${1}" | $Xsed -e "$dirname"` + if test "X$func_dirname_result" = "X${1}"; then + func_dirname_result="${3}" + else + func_dirname_result="$func_dirname_result${2}" + fi +} + +# func_basename file +func_basename () +{ + func_basename_result=`$ECHO "X${1}" | $Xsed -e "$basename"` +} + + +# func_stripname prefix suffix name +# strip PREFIX and SUFFIX off of NAME. +# PREFIX and SUFFIX must not contain globbing or regex special +# characters, hashes, percent signs, but SUFFIX may contain a leading +# dot (in which case that matches only a dot). +# func_strip_suffix prefix name +func_stripname () +{ + case ${2} in + .*) func_stripname_result=`$ECHO "X${3}" \ + | $Xsed -e "s%^${1}%%" -e "s%\\\\${2}\$%%"`;; + *) func_stripname_result=`$ECHO "X${3}" \ + | $Xsed -e "s%^${1}%%" -e "s%${2}\$%%"`;; + esac +} + +# sed scripts: +my_sed_long_opt='1s/^\(-[^=]*\)=.*/\1/;q' +my_sed_long_arg='1s/^-[^=]*=//' + +# func_opt_split +func_opt_split () +{ + func_opt_split_opt=`$ECHO "X${1}" | $Xsed -e "$my_sed_long_opt"` + func_opt_split_arg=`$ECHO "X${1}" | $Xsed -e "$my_sed_long_arg"` +} + +# func_lo2o object +func_lo2o () +{ + func_lo2o_result=`$ECHO "X${1}" | $Xsed -e "$lo2o"` +} + +# func_xform libobj-or-source +func_xform () +{ + func_xform_result=`$ECHO "X${1}" | $Xsed -e 's/\.[^.]*$/.lo/'` +} + +# func_arith arithmetic-term... +func_arith () +{ + func_arith_result=`expr "$@"` +} + +# func_len string +# STRING may not start with a hyphen. +func_len () +{ + func_len_result=`expr "$1" : ".*" 2>/dev/null || echo $max_cmd_len` +} + +_LT_EOF +esac + +case $lt_shell_append in + yes) + cat << \_LT_EOF >> "$cfgfile" + +# func_append var value +# Append VALUE to the end of shell variable VAR. +func_append () +{ + eval "$1+=\$2" +} +_LT_EOF + ;; + *) + cat << \_LT_EOF >> "$cfgfile" + +# func_append var value +# Append VALUE to the end of shell variable VAR. +func_append () +{ + eval "$1=\$$1\$2" +} + +_LT_EOF + ;; + esac + + + sed -n '/^# Generated shell functions inserted here/,$p' "$ltmain" >> "$cfgfile" \ + || (rm -f "$cfgfile"; exit 1) + + mv -f "$cfgfile" "$ofile" || (rm -f "$ofile" && cp "$cfgfile" "$ofile" && rm -f "$cfgfile") chmod +x "$ofile" @@ -17568,7 +14897,7 @@ ac_clean_files=$ac_clean_files_save test $ac_write_fail = 0 || - as_fn_error $? "write failure creating $CONFIG_STATUS" "$LINENO" 5 + as_fn_error "write failure creating $CONFIG_STATUS" "$LINENO" 5 # configure is writing to config.log, and then calls config.status. @@ -17589,7 +14918,7 @@ exec 5>>config.log # Use ||, not &&, to avoid exiting from the if with $? = 1, which # would make configure fail if this is the last instruction. - $ac_cs_success || as_fn_exit 1 + $ac_cs_success || as_fn_exit $? fi if test -n "$ac_unrecognized_opts" && test "$enable_option_checking" != no; then { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: unrecognized options: $ac_unrecognized_opts" >&5 diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi/configure.ac --- a/Modules/_ctypes/libffi/configure.ac Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/_ctypes/libffi/configure.ac Sun Jul 20 10:52:46 2014 -0400 @@ -1,11 +1,11 @@ dnl Process this with autoconf to create configure # -# file from libffi - slightly patched for Python's ctypes +# file from libffi - slightly patched for ctypes # -AC_PREREQ(2.68) +AC_PREREQ(2.63) -AC_INIT([libffi], [3.0.13], [http://github.com/atgreen/libffi/issues]) +AC_INIT([libffi], [3.0.10rc0], [http://gcc.gnu.org/bugs.html]) AC_CONFIG_HEADERS([fficonfig.h]) AC_CANONICAL_SYSTEM @@ -13,24 +13,18 @@ . ${srcdir}/configure.host -AX_ENABLE_BUILDDIR - AM_INIT_AUTOMAKE # The same as in boehm-gc and libstdc++. Have to borrow it from there. # We must force CC to /not/ be precious variables; otherwise # the wrong, non-multilib-adjusted value will be used in multilibs. # As a side effect, we have to subst CFLAGS ourselves. -# Also save and restore CFLAGS, since AC_PROG_CC will come up with -# defaults of its own if none are provided. m4_rename([_AC_ARG_VAR_PRECIOUS],[real_PRECIOUS]) m4_define([_AC_ARG_VAR_PRECIOUS],[]) -save_CFLAGS=$CFLAGS AC_PROG_CC -CFLAGS=$save_CFLAGS m4_undefine([_AC_ARG_VAR_PRECIOUS]) -m4_rename_force([real_PRECIOUS],[_AC_ARG_VAR_PRECIOUS]) +m4_rename([real_PRECIOUS],[_AC_ARG_VAR_PRECIOUS]) AC_SUBST(CFLAGS) @@ -39,26 +33,6 @@ AC_PROG_LIBTOOL AC_CONFIG_MACRO_DIR([m4]) -# Test for 64-bit build. -AC_CHECK_SIZEOF([size_t]) - -AX_COMPILER_VENDOR -AX_CC_MAXOPT -# The AX_CFLAGS_WARN_ALL macro doesn't currently work for sunpro -# compiler. -if test "$ax_cv_c_compiler_vendor" != "sun"; then - AX_CFLAGS_WARN_ALL -fi - -if test "x$GCC" = "xyes"; then - CFLAGS="$CFLAGS -fexceptions" - touch local.exp -else - cat > local.exp < /dev/null]) -AM_CONDITIONAL(BFIN, test x$TARGET = xBFIN) AM_CONDITIONAL(SPARC, test x$TARGET = xSPARC) AM_CONDITIONAL(X86, test x$TARGET = xX86) AM_CONDITIONAL(X86_FREEBSD, test x$TARGET = xX86_FREEBSD) @@ -288,14 +191,10 @@ AM_CONDITIONAL(IA64, test x$TARGET = xIA64) AM_CONDITIONAL(M32R, test x$TARGET = xM32R) AM_CONDITIONAL(M68K, test x$TARGET = xM68K) -AM_CONDITIONAL(MICROBLAZE, test x$TARGET = xMICROBLAZE) -AM_CONDITIONAL(METAG, test x$TARGET = xMETAG) -AM_CONDITIONAL(MOXIE, test x$TARGET = xMOXIE) AM_CONDITIONAL(POWERPC, test x$TARGET = xPOWERPC) AM_CONDITIONAL(POWERPC_AIX, test x$TARGET = xPOWERPC_AIX) AM_CONDITIONAL(POWERPC_DARWIN, test x$TARGET = xPOWERPC_DARWIN) AM_CONDITIONAL(POWERPC_FREEBSD, test x$TARGET = xPOWERPC_FREEBSD) -AM_CONDITIONAL(AARCH64, test x$TARGET = xAARCH64) AM_CONDITIONAL(ARM, test x$TARGET = xARM) AM_CONDITIONAL(AVR32, test x$TARGET = xAVR32) AM_CONDITIONAL(LIBFFI_CRIS, test x$TARGET = xLIBFFI_CRIS) @@ -307,8 +206,6 @@ AM_CONDITIONAL(PA_LINUX, test x$TARGET = xPA_LINUX) AM_CONDITIONAL(PA_HPUX, test x$TARGET = xPA_HPUX) AM_CONDITIONAL(PA64_HPUX, test x$TARGET = xPA64_HPUX) -AM_CONDITIONAL(TILE, test x$TARGET = xTILE) -AM_CONDITIONAL(XTENSA, test x$TARGET = xXTENSA) AC_HEADER_STDC AC_CHECK_FUNCS(memcpy) @@ -331,7 +228,17 @@ AC_C_BIGENDIAN -GCC_AS_CFI_PSEUDO_OP +AC_CACHE_CHECK([assembler .cfi pseudo-op support], + libffi_cv_as_cfi_pseudo_op, [ + libffi_cv_as_cfi_pseudo_op=unknown + AC_TRY_COMPILE([asm (".cfi_startproc\n\t.cfi_endproc");],, + [libffi_cv_as_cfi_pseudo_op=yes], + [libffi_cv_as_cfi_pseudo_op=no]) +]) +if test "x$libffi_cv_as_cfi_pseudo_op" = xyes; then + AC_DEFINE(HAVE_AS_CFI_PSEUDO_OP, 1, + [Define if your assembler supports .cfi_* directives.]) +fi if test x$TARGET = xSPARC; then AC_CACHE_CHECK([assembler and linker support unaligned pc related relocs], @@ -354,7 +261,7 @@ libffi_cv_as_register_pseudo_op, [ libffi_cv_as_register_pseudo_op=unknown # Check if we have .register - AC_TRY_COMPILE(,[asm (".register %g2, #scratch");], + AC_TRY_COMPILE([asm (".register %g2, #scratch");],, [libffi_cv_as_register_pseudo_op=yes], [libffi_cv_as_register_pseudo_op=no]) ]) @@ -367,132 +274,64 @@ if test x$TARGET = xX86 || test x$TARGET = xX86_WIN32 || test x$TARGET = xX86_64; then AC_CACHE_CHECK([assembler supports pc related relocs], libffi_cv_as_x86_pcrel, [ - libffi_cv_as_x86_pcrel=no + libffi_cv_as_x86_pcrel=yes echo '.text; foo: nop; .data; .long foo-.; .text' > conftest.s - if $CC $CFLAGS -c conftest.s > /dev/null 2>&1; then - libffi_cv_as_x86_pcrel=yes + if $CC $CFLAGS -c conftest.s 2>&1 | grep -i warning > /dev/null; then + libffi_cv_as_x86_pcrel=no fi ]) if test "x$libffi_cv_as_x86_pcrel" = xyes; then AC_DEFINE(HAVE_AS_X86_PCREL, 1, [Define if your assembler supports PC relative relocs.]) fi - - AC_CACHE_CHECK([assembler .ascii pseudo-op support], - libffi_cv_as_ascii_pseudo_op, [ - libffi_cv_as_ascii_pseudo_op=unknown - # Check if we have .ascii - AC_TRY_COMPILE(,[asm (".ascii \\"string\\"");], - [libffi_cv_as_ascii_pseudo_op=yes], - [libffi_cv_as_ascii_pseudo_op=no]) - ]) - if test "x$libffi_cv_as_ascii_pseudo_op" = xyes; then - AC_DEFINE(HAVE_AS_ASCII_PSEUDO_OP, 1, - [Define if your assembler supports .ascii.]) - fi - - AC_CACHE_CHECK([assembler .string pseudo-op support], - libffi_cv_as_string_pseudo_op, [ - libffi_cv_as_string_pseudo_op=unknown - # Check if we have .string - AC_TRY_COMPILE(,[asm (".string \\"string\\"");], - [libffi_cv_as_string_pseudo_op=yes], - [libffi_cv_as_string_pseudo_op=no]) - ]) - if test "x$libffi_cv_as_string_pseudo_op" = xyes; then - AC_DEFINE(HAVE_AS_STRING_PSEUDO_OP, 1, - [Define if your assembler supports .string.]) - fi fi -# On PaX enable kernels that have MPROTECT enable we can't use PROT_EXEC. -AC_ARG_ENABLE(pax_emutramp, - [ --enable-pax_emutramp enable pax emulated trampolines, for we can't use PROT_EXEC], - if test "$enable_pax_emutramp" = "yes"; then - AC_DEFINE(FFI_MMAP_EXEC_EMUTRAMP_PAX, 1, - [Define this if you want to enable pax emulated trampolines]) - fi) - -if test x$TARGET = xX86_WIN64; then - LT_SYS_SYMBOL_USCORE - if test "x$sys_symbol_underscore" = xyes; then - AC_DEFINE(SYMBOL_UNDERSCORE, 1, [Define if symbols are underscored.]) - fi -fi - -FFI_EXEC_TRAMPOLINE_TABLE=0 case "$target" in - *arm*-apple-darwin*) - FFI_EXEC_TRAMPOLINE_TABLE=1 - AC_DEFINE(FFI_EXEC_TRAMPOLINE_TABLE, 1, - [Cannot use PROT_EXEC on this target, so, we revert to - alternative means]) - ;; - *-apple-darwin1* | *-*-freebsd* | *-*-kfreebsd* | *-*-openbsd* | *-pc-solaris*) + *-apple-darwin10* | *-*-freebsd* | *-*-openbsd* | *-pc-solaris*) AC_DEFINE(FFI_MMAP_EXEC_WRIT, 1, [Cannot use malloc on this target, so, we revert to alternative means]) ;; esac -AM_CONDITIONAL(FFI_EXEC_TRAMPOLINE_TABLE, test x$FFI_EXEC_TRAMPOLINE_TABLE = x1) -AC_SUBST(FFI_EXEC_TRAMPOLINE_TABLE) -if test x$TARGET = xX86_64; then - AC_CACHE_CHECK([assembler supports unwind section type], - libffi_cv_as_x86_64_unwind_section_type, [ - libffi_cv_as_x86_64_unwind_section_type=yes - echo '.section .eh_frame,"a",@unwind' > conftest.s - if $CC $CFLAGS -c conftest.s 2>&1 | grep -i warning > /dev/null; then - libffi_cv_as_x86_64_unwind_section_type=no +AC_CACHE_CHECK([whether .eh_frame section should be read-only], + libffi_cv_ro_eh_frame, [ + libffi_cv_ro_eh_frame=no + echo 'extern void foo (void); void bar (void) { foo (); foo (); }' > conftest.c + if $CC $CFLAGS -S -fpic -fexceptions -o conftest.s conftest.c > /dev/null 2>&1; then + if grep '.section.*eh_frame.*"a"' conftest.s > /dev/null; then + libffi_cv_ro_eh_frame=yes + elif grep '.section.*eh_frame.*#alloc' conftest.c \ + | grep -v '#write' > /dev/null; then + libffi_cv_ro_eh_frame=yes + fi fi - ]) - if test "x$libffi_cv_as_x86_64_unwind_section_type" = xyes; then - AC_DEFINE(HAVE_AS_X86_64_UNWIND_SECTION_TYPE, 1, - [Define if your assembler supports unwind section type.]) - fi + rm -f conftest.* + ]) +if test "x$libffi_cv_ro_eh_frame" = xyes; then + AC_DEFINE(HAVE_RO_EH_FRAME, 1, + [Define if .eh_frame sections should be read-only.]) + AC_DEFINE(EH_FRAME_FLAGS, "a", + [Define to the flags needed for the .section .eh_frame directive.]) +else + AC_DEFINE(EH_FRAME_FLAGS, "aw", + [Define to the flags needed for the .section .eh_frame directive.]) fi -if test "x$GCC" = "xyes"; then - AC_CACHE_CHECK([whether .eh_frame section should be read-only], - libffi_cv_ro_eh_frame, [ - libffi_cv_ro_eh_frame=no - echo 'extern void foo (void); void bar (void) { foo (); foo (); }' > conftest.c - if $CC $CFLAGS -c -fpic -fexceptions -o conftest.o conftest.c > /dev/null 2>&1; then - objdump -h conftest.o > conftest.dump 2>&1 - libffi_eh_frame_line=`grep -n eh_frame conftest.dump | cut -d: -f 1` - libffi_test_line=`expr $libffi_eh_frame_line + 1`p - sed -n $libffi_test_line conftest.dump > conftest.line - if grep READONLY conftest.line > /dev/null; then - libffi_cv_ro_eh_frame=yes - fi - fi - rm -f conftest.* - ]) - if test "x$libffi_cv_ro_eh_frame" = xyes; then - AC_DEFINE(HAVE_RO_EH_FRAME, 1, - [Define if .eh_frame sections should be read-only.]) - AC_DEFINE(EH_FRAME_FLAGS, "a", - [Define to the flags needed for the .section .eh_frame directive. ]) - else - AC_DEFINE(EH_FRAME_FLAGS, "aw", - [Define to the flags needed for the .section .eh_frame directive. ]) - fi - - AC_CACHE_CHECK([for __attribute__((visibility("hidden")))], - libffi_cv_hidden_visibility_attribute, [ - echo 'int __attribute__ ((visibility ("hidden"))) foo (void) { return 1 ; }' > conftest.c - libffi_cv_hidden_visibility_attribute=no - if AC_TRY_COMMAND(${CC-cc} -Werror -S conftest.c -o conftest.s 1>&AS_MESSAGE_LOG_FD); then - if grep '\.hidden.*foo' conftest.s >/dev/null; then - libffi_cv_hidden_visibility_attribute=yes - fi - fi - rm -f conftest.* - ]) - if test $libffi_cv_hidden_visibility_attribute = yes; then - AC_DEFINE(HAVE_HIDDEN_VISIBILITY_ATTRIBUTE, 1, - [Define if __attribute__((visibility("hidden"))) is supported.]) - fi +AC_CACHE_CHECK([for __attribute__((visibility("hidden")))], + libffi_cv_hidden_visibility_attribute, [ + echo 'int __attribute__ ((visibility ("hidden"))) foo (void) { return 1; }' > conftest.c + libffi_cv_hidden_visibility_attribute=no + if AC_TRY_COMMAND(${CC-cc} -Werror -S conftest.c -o conftest.s 1>&AS_MESSAGE_LOG_FD); then + if grep '\.hidden.*foo' conftest.s >/dev/null; then + libffi_cv_hidden_visibility_attribute=yes + fi + fi + rm -f conftest.* + ]) +if test $libffi_cv_hidden_visibility_attribute = yes; then + AC_DEFINE(HAVE_HIDDEN_VISIBILITY_ATTRIBUTE, 1, + [Define if __attribute__((visibility("hidden"))) is supported.]) fi AH_BOTTOM([ @@ -521,14 +360,12 @@ if test "$enable_debug" = "yes"; then AC_DEFINE(FFI_DEBUG, 1, [Define this if you want extra debugging.]) fi) -AM_CONDITIONAL(FFI_DEBUG, test "$enable_debug" = "yes") AC_ARG_ENABLE(structs, [ --disable-structs omit code for struct support], if test "$enable_structs" = "no"; then AC_DEFINE(FFI_NO_STRUCTS, 1, [Define this is you do not want support for aggregate types.]) fi) -AM_CONDITIONAL(FFI_DEBUG, test "$enable_debug" = "yes") AC_ARG_ENABLE(raw-api, [ --disable-raw-api make the raw api unavailable], @@ -542,28 +379,28 @@ AC_DEFINE(USING_PURIFY, 1, [Define this if you are using Purify and want to suppress spurious messages.]) fi) -# These variables are only ever used when we cross-build to X86_WIN32. -# And we only support this with GCC, so... -if test "x$GCC" = "xyes"; then - if test -n "$with_cross_host" && - test x"$with_cross_host" != x"no"; then - toolexecdir='$(exec_prefix)/$(target_alias)' - toolexeclibdir='$(toolexecdir)/lib' - else - toolexecdir='$(libdir)/gcc-lib/$(target_alias)' - toolexeclibdir='$(libdir)' - fi - multi_os_directory=`$CC -print-multi-os-directory` - case $multi_os_directory in - .) ;; # Avoid trailing /. - ../*) toolexeclibdir=$toolexeclibdir/$multi_os_directory ;; - esac - AC_SUBST(toolexecdir) +if test -n "$with_cross_host" && + test x"$with_cross_host" != x"no"; then + toolexecdir='$(exec_prefix)/$(target_alias)' + toolexeclibdir='$(toolexecdir)/lib' else + toolexecdir='$(libdir)/gcc-lib/$(target_alias)' toolexeclibdir='$(libdir)' fi +multi_os_directory=`$CC -print-multi-os-directory` +case $multi_os_directory in + .) ;; # Avoid trailing /. + *) toolexeclibdir=$toolexeclibdir/$multi_os_directory ;; +esac +AC_SUBST(toolexecdir) AC_SUBST(toolexeclibdir) +if test "${multilib}" = "yes"; then + multilib_arg="--enable-multilib" +else + multilib_arg= +fi + AC_CONFIG_COMMANDS(include, [test -d include || mkdir include]) AC_CONFIG_COMMANDS(src, [ test -d src || mkdir src diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi/depcomp --- a/Modules/_ctypes/libffi/depcomp Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/_ctypes/libffi/depcomp Sun Jul 20 10:52:46 2014 -0400 @@ -1,10 +1,10 @@ #! /bin/sh # depcomp - compile a program generating dependencies as side-effects -scriptversion=2009-04-28.21; # UTC +scriptversion=2006-10-15.18 -# Copyright (C) 1999, 2000, 2003, 2004, 2005, 2006, 2007, 2009 Free -# Software Foundation, Inc. +# Copyright (C) 1999, 2000, 2003, 2004, 2005, 2006 Free Software +# Foundation, Inc. # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -17,7 +17,9 @@ # GNU General Public License for more details. # You should have received a copy of the GNU General Public License -# along with this program. If not, see . +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +# 02110-1301, USA. # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a @@ -85,15 +87,6 @@ depmode=dashmstdout fi -cygpath_u="cygpath -u -f -" -if test "$depmode" = msvcmsys; then - # This is just like msvisualcpp but w/o cygpath translation. - # Just convert the backslash-escaped backslashes to single forward - # slashes to satisfy depend.m4 - cygpath_u="sed s,\\\\\\\\,/,g" - depmode=msvisualcpp -fi - case "$depmode" in gcc3) ## gcc 3 implements dependency tracking that does exactly what @@ -199,14 +192,14 @@ ' < "$tmpdepfile" \ | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \ tr ' -' ' ' >> "$depfile" - echo >> "$depfile" +' ' ' >> $depfile + echo >> $depfile # The second pass generates a dummy entry for each header file. tr ' ' ' ' < "$tmpdepfile" \ | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \ - >> "$depfile" + >> $depfile else # The sourcefile does not contain any dependencies, so just # store a dummy comment line, to avoid errors with the Makefile @@ -222,39 +215,34 @@ # current directory. Also, the AIX compiler puts `$object:' at the # start of each line; $object doesn't have directory information. # Version 6 uses the directory in both cases. - dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` - test "x$dir" = "x$object" && dir= - base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` + stripped=`echo "$object" | sed 's/\(.*\)\..*$/\1/'` + tmpdepfile="$stripped.u" if test "$libtool" = yes; then - tmpdepfile1=$dir$base.u - tmpdepfile2=$base.u - tmpdepfile3=$dir.libs/$base.u "$@" -Wc,-M else - tmpdepfile1=$dir$base.u - tmpdepfile2=$dir$base.u - tmpdepfile3=$dir$base.u "$@" -M fi stat=$? + if test -f "$tmpdepfile"; then : + else + stripped=`echo "$stripped" | sed 's,^.*/,,'` + tmpdepfile="$stripped.u" + fi + if test $stat -eq 0; then : else - rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" + rm -f "$tmpdepfile" exit $stat fi - for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" - do - test -f "$tmpdepfile" && break - done if test -f "$tmpdepfile"; then + outname="$stripped.o" # Each line is of the form `foo.o: dependent.h'. # Do two passes, one to just change these to # `$object: dependent.h' and one to simply `dependent.h:'. - sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile" - # That's a tab and a space in the []. - sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile" + sed -e "s,^$outname:,$object :," < "$tmpdepfile" > "$depfile" + sed -e "s,^$outname: \(.*\)$,\1:," < "$tmpdepfile" >> "$depfile" else # The sourcefile does not contain any dependencies, so just # store a dummy comment line, to avoid errors with the Makefile @@ -335,12 +323,7 @@ if test -f "$tmpdepfile"; then sed -e "s,^.*\.[a-z]*:,$object:," "$tmpdepfile" > "$depfile" # Add `dependent.h:' lines. - sed -ne '2,${ - s/^ *// - s/ \\*$// - s/$/:/ - p - }' "$tmpdepfile" >> "$depfile" + sed -ne '2,${; s/^ *//; s/ \\*$//; s/$/:/; p;}' "$tmpdepfile" >> "$depfile" else echo "#dummy" > "$depfile" fi @@ -416,7 +399,7 @@ # Remove the call to Libtool. if test "$libtool" = yes; then - while test "X$1" != 'X--mode=compile'; do + while test $1 != '--mode=compile'; do shift done shift @@ -467,39 +450,32 @@ "$@" || exit $? # Remove any Libtool call if test "$libtool" = yes; then - while test "X$1" != 'X--mode=compile'; do + while test $1 != '--mode=compile'; do shift done shift fi # X makedepend shift - cleared=no eat=no - for arg - do + cleared=no + for arg in "$@"; do case $cleared in no) set ""; shift cleared=yes ;; esac - if test $eat = yes; then - eat=no - continue - fi case "$arg" in -D*|-I*) set fnord "$@" "$arg"; shift ;; # Strip any option that makedepend may not understand. Remove # the object too, otherwise makedepend will parse it as a source file. - -arch) - eat=yes ;; -*|$object) ;; *) set fnord "$@" "$arg"; shift ;; esac done - obj_suffix=`echo "$object" | sed 's/^.*\././'` + obj_suffix="`echo $object | sed 's/^.*\././'`" touch "$tmpdepfile" ${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@" rm -f "$depfile" @@ -519,7 +495,7 @@ # Remove the call to Libtool. if test "$libtool" = yes; then - while test "X$1" != 'X--mode=compile'; do + while test $1 != '--mode=compile'; do shift done shift @@ -557,27 +533,13 @@ msvisualcpp) # Important note: in order to support this mode, a compiler *must* - # always write the preprocessed file to stdout. + # always write the preprocessed file to stdout, regardless of -o, + # because we must use -o when running libtool. "$@" || exit $? - - # Remove the call to Libtool. - if test "$libtool" = yes; then - while test "X$1" != 'X--mode=compile'; do - shift - done - shift - fi - IFS=" " for arg do case "$arg" in - -o) - shift - ;; - $object) - shift - ;; "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI") set fnord "$@" shift @@ -590,23 +552,16 @@ ;; esac done - "$@" -E 2>/dev/null | - sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::\1:p' | $cygpath_u | sort -u > "$tmpdepfile" + "$@" -E | + sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::echo "`cygpath -u \\"\1\\"`":p' | sort | uniq > "$tmpdepfile" rm -f "$depfile" echo "$object : \\" > "$depfile" - sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s:: \1 \\:p' >> "$depfile" + . "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s:: \1 \\:p' >> "$depfile" echo " " >> "$depfile" - sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::\1\::p' >> "$depfile" + . "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s::\1\::p' >> "$depfile" rm -f "$tmpdepfile" ;; -msvcmsys) - # This case exists only to let depend.m4 do its work. It works by - # looking at the text of this script. This case will never be run, - # since it is checked for above. - exit 1 - ;; - none) exec "$@" ;; @@ -625,6 +580,5 @@ # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "scriptversion=" # time-stamp-format: "%:y-%02m-%02d.%02H" -# time-stamp-time-zone: "UTC" -# time-stamp-end: "; # UTC" +# time-stamp-end: "$" # End: diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi/doc/libffi.info Binary file Modules/_ctypes/libffi/doc/libffi.info has changed diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi/doc/libffi.texi --- a/Modules/_ctypes/libffi/doc/libffi.texi Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/_ctypes/libffi/doc/libffi.texi Sun Jul 20 10:52:46 2014 -0400 @@ -19,7 +19,7 @@ This manual is for Libffi, a portable foreign-function interface library. -Copyright @copyright{} 2008, 2010, 2011 Red Hat, Inc. +Copyright @copyright{} 2008, 2010 Red Hat, Inc. @quotation Permission is granted to copy, distribute and/or modify this document @@ -133,6 +133,8 @@ you want. @ref{Multiple ABIs} for more information. @var{nargs} is the number of arguments that this function accepts. +@samp{libffi} does not yet handle varargs functions; see @ref{Missing +Features} for more information. @var{rtype} is a pointer to an @code{ffi_type} structure that describes the return type of the function. @xref{Types}. @@ -148,30 +150,6 @@ is invalid. @end defun -If the function being called is variadic (varargs) then -@code{ffi_prep_cif_var} must be used instead of @code{ffi_prep_cif}. - -@findex ffi_prep_cif_var -@defun ffi_status ffi_prep_cif_var (ffi_cif *@var{cif}, ffi_abi var{abi}, unsigned int @var{nfixedargs}, unsigned int var{ntotalargs}, ffi_type *@var{rtype}, ffi_type **@var{argtypes}) -This initializes @var{cif} according to the given parameters for -a call to a variadic function. In general it's operation is the -same as for @code{ffi_prep_cif} except that: - -@var{nfixedargs} is the number of fixed arguments, prior to any -variadic arguments. It must be greater than zero. - -@var{ntotalargs} the total number of arguments, including variadic -and fixed arguments. - -Note that, different cif's must be prepped for calls to the same -function when different numbers of arguments are passed. - -Also note that a call to @code{ffi_prep_cif_var} with -@var{nfixedargs}=@var{nototalargs} is NOT equivalent to a call to -@code{ffi_prep_cif}. - -@end defun - To call a function using an initialized @code{ffi_cif}, use the @code{ffi_call} function: @@ -193,9 +171,7 @@ @var{avalues} is a vector of @code{void *} pointers that point to the memory locations holding the argument values for a call. If @var{cif} declares that the function has no arguments (i.e., @var{nargs} was 0), -then @var{avalues} is ignored. Note that argument values may be -modified by the callee (for instance, structs passed by value); the -burden of copying pass-by-value arguments is placed on the caller. +then @var{avalues} is ignored. @end defun @@ -360,7 +336,7 @@ new @code{ffi_type} object for it. @tindex ffi_type -@deftp {Data type} ffi_type +@deftp ffi_type The @code{ffi_type} has the following members: @table @code @item size_t size @@ -462,7 +438,7 @@ heap. Memory management for closures is handled by a pair of functions: -@findex ffi_closure_alloc +@findex ffi_closure_alloca @defun void *ffi_closure_alloc (size_t @var{size}, void **@var{code}) Allocate a chunk of memory holding @var{size} bytes. This returns a pointer to the writable address, and sets *@var{code} to the @@ -594,7 +570,9 @@ @itemize @bullet @item -Variadic closures. +There is no support for calling varargs functions. This may work on +some platforms, depending on how the ABI is defined, but it is not +reliable. @item There is no support for bit fields in structures. @@ -611,8 +589,6 @@ @c anything else? @end itemize -Note that variadic support is very new and tested on a relatively -small number of platforms. @node Index @unnumbered Index diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi/doc/stamp-vti --- a/Modules/_ctypes/libffi/doc/stamp-vti Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/_ctypes/libffi/doc/stamp-vti Sun Jul 20 10:52:46 2014 -0400 @@ -1,4 +1,4 @@ -@set UPDATED 16 March 2013 -@set UPDATED-MONTH March 2013 -@set EDITION 3.0.13 -@set VERSION 3.0.13 +@set UPDATED 14 February 2008 +@set UPDATED-MONTH February 2008 +@set EDITION 3.0.8 +@set VERSION 3.0.8 diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi/doc/version.texi --- a/Modules/_ctypes/libffi/doc/version.texi Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/_ctypes/libffi/doc/version.texi Sun Jul 20 10:52:46 2014 -0400 @@ -1,4 +1,4 @@ -@set UPDATED 16 March 2013 -@set UPDATED-MONTH March 2013 -@set EDITION 3.0.13 -@set VERSION 3.0.13 +@set UPDATED 14 February 2008 +@set UPDATED-MONTH February 2008 +@set EDITION 3.0.8 +@set VERSION 3.0.8 diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi/fficonfig.h.in --- a/Modules/_ctypes/libffi/fficonfig.h.in Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/_ctypes/libffi/fficonfig.h.in Sun Jul 20 10:52:46 2014 -0400 @@ -17,12 +17,6 @@ /* Define this if you want extra debugging. */ #undef FFI_DEBUG -/* Cannot use PROT_EXEC on this target, so, we revert to alternative means */ -#undef FFI_EXEC_TRAMPOLINE_TABLE - -/* Define this if you want to enable pax emulated trampolines */ -#undef FFI_MMAP_EXEC_EMUTRAMP_PAX - /* Cannot use malloc on this target, so, we revert to alternative means */ #undef FFI_MMAP_EXEC_WRIT @@ -39,9 +33,6 @@ */ #undef HAVE_ALLOCA_H -/* Define if your assembler supports .ascii. */ -#undef HAVE_AS_ASCII_PSEUDO_OP - /* Define if your assembler supports .cfi_* directives. */ #undef HAVE_AS_CFI_PSEUDO_OP @@ -52,12 +43,6 @@ */ #undef HAVE_AS_SPARC_UA_PCREL -/* Define if your assembler supports .string. */ -#undef HAVE_AS_STRING_PSEUDO_OP - -/* Define if your assembler supports unwind section type. */ -#undef HAVE_AS_X86_64_UNWIND_SECTION_TYPE - /* Define if your assembler supports PC relative relocs. */ #undef HAVE_AS_X86_PCREL @@ -163,9 +148,6 @@ /* Define to 1 if you have the ANSI C header files. */ #undef STDC_HEADERS -/* Define if symbols are underscored. */ -#undef SYMBOL_UNDERSCORE - /* Define this if you are using Purify and want to suppress spurious messages. */ #undef USING_PURIFY @@ -185,9 +167,6 @@ # endif #endif -/* Define to `unsigned int' if does not define. */ -#undef size_t - #ifdef HAVE_HIDDEN_VISIBILITY_ATTRIBUTE #ifdef LIBFFI_ASM diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi/fficonfig.py.in --- a/Modules/_ctypes/libffi/fficonfig.py.in Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/_ctypes/libffi/fficonfig.py.in Sun Jul 20 10:52:46 2014 -0400 @@ -1,6 +1,7 @@ ffi_sources = """ src/prep_cif.c src/closures.c +src/dlmalloc.c """.split() ffi_platforms = { diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi/generate-ios-source-and-headers.py --- a/Modules/_ctypes/libffi/generate-ios-source-and-headers.py Sat Jul 19 16:34:33 2014 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,160 +0,0 @@ -#!/usr/bin/env python - -import subprocess -import re -import os -import errno -import collections -import sys - -class Platform(object): - pass - -sdk_re = re.compile(r'.*-sdk ([a-zA-Z0-9.]*)') - -def sdkinfo(sdkname): - ret = {} - for line in subprocess.Popen(['xcodebuild', '-sdk', sdkname, '-version'], stdout=subprocess.PIPE).stdout: - kv = line.strip().split(': ', 1) - if len(kv) == 2: - k,v = kv - ret[k] = v - return ret - -sim_sdk_info = sdkinfo('iphonesimulator') -device_sdk_info = sdkinfo('iphoneos') - -def latest_sdks(): - latest_sim = None - latest_device = None - for line in subprocess.Popen(['xcodebuild', '-showsdks'], stdout=subprocess.PIPE).stdout: - match = sdk_re.match(line) - if match: - if 'Simulator' in line: - latest_sim = match.group(1) - elif 'iOS' in line: - latest_device = match.group(1) - - return latest_sim, latest_device - -sim_sdk, device_sdk = latest_sdks() - -class simulator_platform(Platform): - sdk='iphonesimulator' - arch = 'i386' - name = 'simulator' - triple = 'i386-apple-darwin10' - sdkroot = sim_sdk_info['Path'] - - prefix = "#if !defined(__arm__) && defined(__i386__)\n\n" - suffix = "\n\n#endif" - -class device_platform(Platform): - sdk='iphoneos' - name = 'ios' - arch = 'armv7' - triple = 'arm-apple-darwin10' - sdkroot = device_sdk_info['Path'] - - prefix = "#ifdef __arm__\n\n" - suffix = "\n\n#endif" - - -def move_file(src_dir, dst_dir, filename, file_suffix=None, prefix='', suffix=''): - if not os.path.exists(dst_dir): - os.makedirs(dst_dir) - - out_filename = filename - - if file_suffix: - split_name = os.path.splitext(filename) - out_filename = "%s_%s%s" % (split_name[0], file_suffix, split_name[1]) - - with open(os.path.join(src_dir, filename)) as in_file: - with open(os.path.join(dst_dir, out_filename), 'w') as out_file: - if prefix: - out_file.write(prefix) - - out_file.write(in_file.read()) - - if suffix: - out_file.write(suffix) - -headers_seen = collections.defaultdict(set) - -def move_source_tree(src_dir, dest_dir, dest_include_dir, arch=None, prefix=None, suffix=None): - for root, dirs, files in os.walk(src_dir, followlinks=True): - relroot = os.path.relpath(root,src_dir) - - def move_dir(arch, prefix='', suffix='', files=[]): - for file in files: - file_suffix = None - if file.endswith('.h'): - if dest_include_dir: - file_suffix = arch - if arch: - headers_seen[file].add(arch) - move_file(root, dest_include_dir, file, arch, prefix=prefix, suffix=suffix) - - elif dest_dir: - outroot = os.path.join(dest_dir, relroot) - move_file(root, outroot, file, prefix=prefix, suffix=suffix) - - if relroot == '.': - move_dir(arch=arch, - files=files, - prefix=prefix, - suffix=suffix) - elif relroot == 'arm': - move_dir(arch='arm', - prefix="#ifdef __arm__\n\n", - suffix="\n\n#endif", - files=files) - elif relroot == 'x86': - move_dir(arch='i386', - prefix="#if !defined(__arm__) && defined(__i386__)\n\n", - suffix="\n\n#endif", - files=files) - -def build_target(platform): - def xcrun_cmd(cmd): - return subprocess.check_output(['xcrun', '-sdk', platform.sdkroot, '-find', cmd]).strip() - - build_dir = 'build_' + platform.name - if not os.path.exists(build_dir): - os.makedirs(build_dir) - env = dict(CC=xcrun_cmd('clang'), - LD=xcrun_cmd('ld'), - CFLAGS='-arch %s -isysroot %s -miphoneos-version-min=4.0' % (platform.arch, platform.sdkroot)) - working_dir=os.getcwd() - try: - os.chdir(build_dir) - subprocess.check_call(['../configure', '-host', platform.triple], env=env) - move_source_tree('.', None, '../ios/include', - arch=platform.arch, - prefix=platform.prefix, - suffix=platform.suffix) - move_source_tree('./include', None, '../ios/include', - arch=platform.arch, - prefix=platform.prefix, - suffix=platform.suffix) - finally: - os.chdir(working_dir) - - for header_name, archs in headers_seen.iteritems(): - basename, suffix = os.path.splitext(header_name) - -def main(): - move_source_tree('src', 'ios/src', 'ios/include') - move_source_tree('include', None, 'ios/include') - build_target(simulator_platform) - build_target(device_platform) - - for header_name, archs in headers_seen.iteritems(): - basename, suffix = os.path.splitext(header_name) - with open(os.path.join('ios/include', header_name), 'w') as header: - for arch in archs: - header.write('#include <%s_%s%s>\n' % (basename, arch, suffix)) - -if __name__ == '__main__': - main() diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi/generate-osx-source-and-headers.py --- a/Modules/_ctypes/libffi/generate-osx-source-and-headers.py Sat Jul 19 16:34:33 2014 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,153 +0,0 @@ -#!/usr/bin/env python -import subprocess -import re -import os -import errno -import collections -import sys - -class Platform(object): - pass - -sdk_re = re.compile(r'.*-sdk ([a-zA-Z0-9.]*)') - -def sdkinfo(sdkname): - ret = {} - for line in subprocess.Popen(['xcodebuild', '-sdk', sdkname, '-version'], stdout=subprocess.PIPE).stdout: - kv = line.strip().split(': ', 1) - if len(kv) == 2: - k,v = kv - ret[k] = v - return ret - -desktop_sdk_info = sdkinfo('macosx') - -def latest_sdks(): - latest_desktop = None - for line in subprocess.Popen(['xcodebuild', '-showsdks'], stdout=subprocess.PIPE).stdout: - match = sdk_re.match(line) - if match: - if 'OS X' in line: - latest_desktop = match.group(1) - - return latest_desktop - -desktop_sdk = latest_sdks() - -class desktop_platform_32(Platform): - sdk='macosx' - arch = 'i386' - name = 'mac32' - triple = 'i386-apple-darwin10' - sdkroot = desktop_sdk_info['Path'] - - prefix = "#if defined(__i386__) && !defined(__x86_64__)\n\n" - suffix = "\n\n#endif" - -class desktop_platform_64(Platform): - sdk='macosx' - arch = 'x86_64' - name = 'mac' - triple = 'x86_64-apple-darwin10' - sdkroot = desktop_sdk_info['Path'] - - prefix = "#if !defined(__i386__) && defined(__x86_64__)\n\n" - suffix = "\n\n#endif" - -def move_file(src_dir, dst_dir, filename, file_suffix=None, prefix='', suffix=''): - if not os.path.exists(dst_dir): - os.makedirs(dst_dir) - - out_filename = filename - - if file_suffix: - split_name = os.path.splitext(filename) - out_filename = "%s_%s%s" % (split_name[0], file_suffix, split_name[1]) - - with open(os.path.join(src_dir, filename)) as in_file: - with open(os.path.join(dst_dir, out_filename), 'w') as out_file: - if prefix: - out_file.write(prefix) - - out_file.write(in_file.read()) - - if suffix: - out_file.write(suffix) - -headers_seen = collections.defaultdict(set) - -def move_source_tree(src_dir, dest_dir, dest_include_dir, arch=None, prefix=None, suffix=None): - for root, dirs, files in os.walk(src_dir, followlinks=True): - relroot = os.path.relpath(root,src_dir) - - def move_dir(arch, prefix='', suffix='', files=[]): - for file in files: - file_suffix = None - if file.endswith('.h'): - if dest_include_dir: - file_suffix = arch - if arch: - headers_seen[file].add(arch) - move_file(root, dest_include_dir, file, arch, prefix=prefix, suffix=suffix) - - elif dest_dir: - outroot = os.path.join(dest_dir, relroot) - move_file(root, outroot, file, prefix=prefix, suffix=suffix) - - if relroot == '.': - move_dir(arch=arch, - files=files, - prefix=prefix, - suffix=suffix) - elif relroot == 'x86': - move_dir(arch='i386', - prefix="#if defined(__i386__) && !defined(__x86_64__)\n\n", - suffix="\n\n#endif", - files=files) - move_dir(arch='x86_64', - prefix="#if !defined(__i386__) && defined(__x86_64__)\n\n", - suffix="\n\n#endif", - files=files) - -def build_target(platform): - def xcrun_cmd(cmd): - return subprocess.check_output(['xcrun', '-sdk', platform.sdkroot, '-find', cmd]).strip() - - build_dir = 'build_' + platform.name - if not os.path.exists(build_dir): - os.makedirs(build_dir) - env = dict(CC=xcrun_cmd('clang'), - LD=xcrun_cmd('ld'), - CFLAGS='-arch %s -isysroot %s -mmacosx-version-min=10.6' % (platform.arch, platform.sdkroot)) - working_dir=os.getcwd() - try: - os.chdir(build_dir) - subprocess.check_call(['../configure', '-host', platform.triple], env=env) - move_source_tree('.', None, '../osx/include', - arch=platform.arch, - prefix=platform.prefix, - suffix=platform.suffix) - move_source_tree('./include', None, '../osx/include', - arch=platform.arch, - prefix=platform.prefix, - suffix=platform.suffix) - finally: - os.chdir(working_dir) - - for header_name, archs in headers_seen.iteritems(): - basename, suffix = os.path.splitext(header_name) - -def main(): - move_source_tree('src', 'osx/src', 'osx/include') - move_source_tree('include', None, 'osx/include') - build_target(desktop_platform_32) - build_target(desktop_platform_64) - - for header_name, archs in headers_seen.iteritems(): - basename, suffix = os.path.splitext(header_name) - with open(os.path.join('osx/include', header_name), 'w') as header: - for arch in archs: - header.write('#include <%s_%s%s>\n' % (basename, arch, suffix)) - -if __name__ == '__main__': - main() diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi/include/Makefile.in --- a/Modules/_ctypes/libffi/include/Makefile.in Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/_ctypes/libffi/include/Makefile.in Sun Jul 20 10:52:46 2014 -0400 @@ -1,8 +1,9 @@ -# Makefile.in generated by automake 1.12.2 from Makefile.am. +# Makefile.in generated by automake 1.11 from Makefile.am. # @configure_input@ -# Copyright (C) 1994-2012 Free Software Foundation, Inc. - +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, +# Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. @@ -15,23 +16,6 @@ @SET_MAKE@ VPATH = @srcdir@ -am__make_dryrun = \ - { \ - am__dry=no; \ - case $$MAKEFLAGS in \ - *\\[\ \ ]*) \ - echo 'am--echo: ; @echo "AM" OK' | $(MAKE) -f - 2>/dev/null \ - | grep '^AM OK$$' >/dev/null || am__dry=yes;; \ - *) \ - for am__flg in $$MAKEFLAGS; do \ - case $$am__flg in \ - *=*|--*) ;; \ - *n*) am__dry=yes; break;; \ - esac; \ - done;; \ - esac; \ - test $$am__dry = yes; \ - } pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ @@ -55,19 +39,7 @@ DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in \ $(srcdir)/ffi.h.in ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 -am__aclocal_m4_deps = $(top_srcdir)/m4/asmcfi.m4 \ - $(top_srcdir)/m4/ax_append_flag.m4 \ - $(top_srcdir)/m4/ax_cc_maxopt.m4 \ - $(top_srcdir)/m4/ax_cflags_warn_all.m4 \ - $(top_srcdir)/m4/ax_check_compile_flag.m4 \ - $(top_srcdir)/m4/ax_compiler_vendor.m4 \ - $(top_srcdir)/m4/ax_configure_args.m4 \ - $(top_srcdir)/m4/ax_enable_builddir.m4 \ - $(top_srcdir)/m4/ax_gcc_archflag.m4 \ - $(top_srcdir)/m4/ax_gcc_x86_cpuid.m4 \ - $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \ - $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \ - $(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/acinclude.m4 \ +am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) @@ -77,11 +49,6 @@ CONFIG_CLEAN_VPATH_FILES = SOURCES = DIST_SOURCES = -am__can_run_installinfo = \ - case $$AM_UPDATE_INFO_DIR in \ - n|no|NO) false;; \ - *) (install-info --version) >/dev/null 2>&1;; \ - esac am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; am__vpath_adj = case $$p in \ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ @@ -103,12 +70,6 @@ am__base_list = \ sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' -am__uninstall_files_from_dir = { \ - test -z "$$files" \ - || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ - || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ - $(am__cd) "$$dir" && rm -f $$files; }; \ - } am__installdirs = "$(DESTDIR)$(includesdir)" HEADERS = $(nodist_includes_HEADERS) ETAGS = etags @@ -117,7 +78,6 @@ ACLOCAL = @ACLOCAL@ ALLOCA = @ALLOCA@ AMTAR = @AMTAR@ -AM_LTLDFLAGS = @AM_LTLDFLAGS@ AM_RUNTESTFLAGS = @AM_RUNTESTFLAGS@ AR = @AR@ AUTOCONF = @AUTOCONF@ @@ -135,7 +95,6 @@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ -DLLTOOL = @DLLTOOL@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ @@ -143,7 +102,6 @@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ -FFI_EXEC_TRAMPOLINE_TABLE = @FFI_EXEC_TRAMPOLINE_TABLE@ FGREP = @FGREP@ GREP = @GREP@ HAVE_LONG_DOUBLE = @HAVE_LONG_DOUBLE@ @@ -162,7 +120,6 @@ LTLIBOBJS = @LTLIBOBJS@ MAINT = @MAINT@ MAKEINFO = @MAKEINFO@ -MANIFEST_TOOL = @MANIFEST_TOOL@ MKDIR_P = @MKDIR_P@ NM = @NM@ NMEDIT = @NMEDIT@ @@ -175,10 +132,8 @@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ -PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ -PRTDIAG = @PRTDIAG@ RANLIB = @RANLIB@ SED = @SED@ SET_MAKE = @SET_MAKE@ @@ -191,7 +146,6 @@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ -ac_ct_AR = @ac_ct_AR@ ac_ct_CC = @ac_ct_CC@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ am__include = @am__include@ @@ -199,7 +153,6 @@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ -ax_enable_builddir_sed = @ax_enable_builddir_sed@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ @@ -225,6 +178,7 @@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ +lt_ECHO = @lt_ECHO@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ @@ -235,7 +189,6 @@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ -sys_symbol_underscore = @sys_symbol_underscore@ sysconfdir = @sysconfdir@ target = @target@ target_alias = @target_alias@ @@ -295,11 +248,8 @@ -rm -rf .libs _libs install-nodist_includesHEADERS: $(nodist_includes_HEADERS) @$(NORMAL_INSTALL) + test -z "$(includesdir)" || $(MKDIR_P) "$(DESTDIR)$(includesdir)" @list='$(nodist_includes_HEADERS)'; test -n "$(includesdir)" || list=; \ - if test -n "$$list"; then \ - echo " $(MKDIR_P) '$(DESTDIR)$(includesdir)'"; \ - $(MKDIR_P) "$(DESTDIR)$(includesdir)" || exit 1; \ - fi; \ for p in $$list; do \ if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ echo "$$d$$p"; \ @@ -313,7 +263,9 @@ @$(NORMAL_UNINSTALL) @list='$(nodist_includes_HEADERS)'; test -n "$(includesdir)" || list=; \ files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \ - dir='$(DESTDIR)$(includesdir)'; $(am__uninstall_files_from_dir) + test -n "$$files" || exit 0; \ + echo " ( cd '$(DESTDIR)$(includesdir)' && rm -f" $$files ")"; \ + cd "$(DESTDIR)$(includesdir)" && rm -f $$files ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ @@ -364,20 +316,6 @@ && $(am__cd) $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) "$$here" -cscopelist: $(HEADERS) $(SOURCES) $(LISP) - list='$(SOURCES) $(HEADERS) $(LISP)'; \ - case "$(srcdir)" in \ - [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ - *) sdir=$(subdir)/$(srcdir) ;; \ - esac; \ - for i in $$list; do \ - if test -f "$$i"; then \ - echo "$(subdir)/$$i"; \ - else \ - echo "$$sdir/$$i"; \ - fi; \ - done >> $(top_builddir)/cscope.files - distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags @@ -428,15 +366,10 @@ installcheck: installcheck-am install-strip: - if test -z '$(STRIP)'; then \ - $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ - install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ - install; \ - else \ - $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ - install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ - "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ - fi + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install mostlyclean-generic: clean-generic: @@ -518,7 +451,7 @@ .MAKE: install-am install-strip .PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \ - clean-libtool cscopelist ctags distclean distclean-generic \ + clean-libtool ctags distclean distclean-generic \ distclean-libtool distclean-tags distdir dvi dvi-am html \ html-am info info-am install install-am install-data \ install-data-am install-dvi install-dvi-am install-exec \ diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi/include/ffi.h.in --- a/Modules/_ctypes/libffi/include/ffi.h.in Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/_ctypes/libffi/include/ffi.h.in Sun Jul 20 10:52:46 2014 -0400 @@ -1,17 +1,16 @@ /* -----------------------------------------------------------------*-C-*- - libffi @VERSION@ - Copyright (c) 2011 Anthony Green - - Copyright (c) 1996-2003, 2007, 2008 Red Hat, Inc. + libffi @VERSION@ - Copyright (c) 1996-2003, 2007, 2008 Red Hat, Inc. - Permission is hereby granted, free of charge, to any person - obtaining a copy of this software and associated documentation - files (the ``Software''), to deal in the Software without - restriction, including without limitation the rights to use, copy, - modify, merge, publish, distribute, sublicense, and/or sell copies - of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: + Permission is hereby granted, free of charge, to any person obtaining + a copy of this software and associated documentation files (the + ``Software''), to deal in the Software without restriction, including + without limitation the rights to use, copy, modify, merge, publish, + distribute, sublicense, and/or sell copies of the Software, and to + permit persons to whom the Software is furnished to do so, subject to + the following conditions: - The above copyright notice and this permission notice shall be - included in all copies or substantial portions of the Software. + The above copyright notice and this permission notice shall be included + in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF @@ -58,9 +57,7 @@ #endif /* Specify which architecture libffi is configured for. */ -#ifndef @TARGET@ #define @TARGET@ -#endif /* ---- System configuration information --------------------------------- */ @@ -78,31 +75,15 @@ /* LONG_LONG_MAX is not always defined (not if STRICT_ANSI, for example). But we can find it either under the correct ANSI name, or under GNU C's internal name. */ - -#define FFI_64_BIT_MAX 9223372036854775807 - #ifdef LONG_LONG_MAX # define FFI_LONG_LONG_MAX LONG_LONG_MAX #else # ifdef LLONG_MAX # define FFI_LONG_LONG_MAX LLONG_MAX -# ifdef _AIX52 /* or newer has C99 LLONG_MAX */ -# undef FFI_64_BIT_MAX -# define FFI_64_BIT_MAX 9223372036854775807LL -# endif /* _AIX52 or newer */ # else # ifdef __GNUC__ # define FFI_LONG_LONG_MAX __LONG_LONG_MAX__ # endif -# ifdef _AIX /* AIX 5.1 and earlier have LONGLONG_MAX */ -# ifndef __PPC64__ -# if defined (__IBMC__) || defined (__IBMCPP__) -# define FFI_LONG_LONG_MAX LONGLONG_MAX -# endif -# endif /* __PPC64__ */ -# undef FFI_64_BIT_MAX -# define FFI_64_BIT_MAX 9223372036854775807LL -# endif # endif #endif @@ -149,53 +130,39 @@ #endif #if LONG_MAX == 2147483647 -# if FFI_LONG_LONG_MAX != FFI_64_BIT_MAX +# if FFI_LONG_LONG_MAX != 9223372036854775807 #error "no 64-bit data type supported" # endif -#elif LONG_MAX != FFI_64_BIT_MAX +#elif LONG_MAX != 9223372036854775807 #error "long size not supported" #endif #if LONG_MAX == 2147483647 # define ffi_type_ulong ffi_type_uint32 # define ffi_type_slong ffi_type_sint32 -#elif LONG_MAX == FFI_64_BIT_MAX +#elif LONG_MAX == 9223372036854775807 # define ffi_type_ulong ffi_type_uint64 # define ffi_type_slong ffi_type_sint64 #else #error "long size not supported" #endif -/* Need minimal decorations for DLLs to works on Windows. */ -/* GCC has autoimport and autoexport. Rely on Libtool to */ -/* help MSVC export from a DLL, but always declare data */ -/* to be imported for MSVC clients. This costs an extra */ -/* indirection for MSVC clients using the static version */ -/* of the library, but don't worry about that. Besides, */ -/* as a workaround, they can define FFI_BUILDING if they */ -/* *know* they are going to link with the static library. */ -#if defined _MSC_VER && !defined FFI_BUILDING -#define FFI_EXTERN extern __declspec(dllimport) -#else -#define FFI_EXTERN extern -#endif - /* These are defined in types.c */ -FFI_EXTERN ffi_type ffi_type_void; -FFI_EXTERN ffi_type ffi_type_uint8; -FFI_EXTERN ffi_type ffi_type_sint8; -FFI_EXTERN ffi_type ffi_type_uint16; -FFI_EXTERN ffi_type ffi_type_sint16; -FFI_EXTERN ffi_type ffi_type_uint32; -FFI_EXTERN ffi_type ffi_type_sint32; -FFI_EXTERN ffi_type ffi_type_uint64; -FFI_EXTERN ffi_type ffi_type_sint64; -FFI_EXTERN ffi_type ffi_type_float; -FFI_EXTERN ffi_type ffi_type_double; -FFI_EXTERN ffi_type ffi_type_pointer; +extern ffi_type ffi_type_void; +extern ffi_type ffi_type_uint8; +extern ffi_type ffi_type_sint8; +extern ffi_type ffi_type_uint16; +extern ffi_type ffi_type_sint16; +extern ffi_type ffi_type_uint32; +extern ffi_type ffi_type_sint32; +extern ffi_type ffi_type_uint64; +extern ffi_type ffi_type_sint64; +extern ffi_type ffi_type_float; +extern ffi_type ffi_type_double; +extern ffi_type ffi_type_pointer; #if @HAVE_LONG_DOUBLE@ -FFI_EXTERN ffi_type ffi_type_longdouble; +extern ffi_type ffi_type_longdouble; #else #define ffi_type_longdouble ffi_type_double #endif @@ -221,21 +188,12 @@ #endif } ffi_cif; -/* Used internally, but overridden by some architectures */ -ffi_status ffi_prep_cif_core(ffi_cif *cif, - ffi_abi abi, - unsigned int isvariadic, - unsigned int nfixedargs, - unsigned int ntotalargs, - ffi_type *rtype, - ffi_type **atypes); - /* ---- Definitions for the raw API -------------------------------------- */ #ifndef FFI_SIZEOF_ARG # if LONG_MAX == 2147483647 # define FFI_SIZEOF_ARG 4 -# elif LONG_MAX == FFI_64_BIT_MAX +# elif LONG_MAX == 9223372036854775807 # define FFI_SIZEOF_ARG 8 # endif #endif @@ -297,12 +255,7 @@ __declspec(align(8)) #endif typedef struct { -#if @FFI_EXEC_TRAMPOLINE_TABLE@ - void *trampoline_table; - void *trampoline_table_entry; -#else char tramp[FFI_TRAMPOLINE_SIZE]; -#endif ffi_cif *cif; void (*fun)(ffi_cif*,void*,void**,void*); void *user_data; @@ -310,9 +263,6 @@ } ffi_closure __attribute__((aligned (8))); #else } ffi_closure; -# ifdef __sgi -# pragma pack 0 -# endif #endif void *ffi_closure_alloc (size_t size, void **code); @@ -331,16 +281,9 @@ void *user_data, void*codeloc); -#ifdef __sgi -# pragma pack 8 -#endif typedef struct { -#if @FFI_EXEC_TRAMPOLINE_TABLE@ - void *trampoline_table; - void *trampoline_table_entry; -#else char tramp[FFI_TRAMPOLINE_SIZE]; -#endif + ffi_cif *cif; #if !FFI_NATIVE_RAW_API @@ -360,12 +303,7 @@ } ffi_raw_closure; typedef struct { -#if @FFI_EXEC_TRAMPOLINE_TABLE@ - void *trampoline_table; - void *trampoline_table_entry; -#else char tramp[FFI_TRAMPOLINE_SIZE]; -#endif ffi_cif *cif; @@ -421,13 +359,6 @@ ffi_type *rtype, ffi_type **atypes); -ffi_status ffi_prep_cif_var(ffi_cif *cif, - ffi_abi abi, - unsigned int nfixedargs, - unsigned int ntotalargs, - ffi_type *rtype, - ffi_type **atypes); - void ffi_call(ffi_cif *cif, void (*fn)(void), void *rvalue, diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi/include/ffi_common.h --- a/Modules/_ctypes/libffi/include/ffi_common.h Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/_ctypes/libffi/include/ffi_common.h Sun Jul 20 10:52:46 2014 -0400 @@ -1,8 +1,7 @@ /* ----------------------------------------------------------------------- - ffi_common.h - Copyright (C) 2011, 2012 Anthony Green - Copyright (C) 2007 Free Software Foundation, Inc - Copyright (c) 1996 Red Hat, Inc. - + ffi_common.h - Copyright (c) 1996 Red Hat, Inc. + Copyright (C) 2007 Free Software Foundation, Inc + Common internal definitions and macros. Only necessary for building libffi. ----------------------------------------------------------------------- */ @@ -75,8 +74,6 @@ /* Perform machine dependent cif processing */ ffi_status ffi_prep_cif_machdep(ffi_cif *cif); -ffi_status ffi_prep_cif_machdep_var(ffi_cif *cif, - unsigned int nfixedargs, unsigned int ntotalargs); /* Extended cif, used in callback from assembly routine */ typedef struct @@ -87,7 +84,7 @@ } extended_cif; /* Terse sized type definitions. */ -#if defined(_MSC_VER) || defined(__sgi) || defined(__SUNPRO_C) +#if defined(_MSC_VER) || defined(__sgi) typedef unsigned char UINT8; typedef signed char SINT8; typedef unsigned short UINT16; @@ -115,14 +112,11 @@ typedef float FLOAT32; -#ifndef __GNUC__ -#define __builtin_expect(x, expected_value) (x) -#endif -#define LIKELY(x) __builtin_expect(!!(x),1) -#define UNLIKELY(x) __builtin_expect((x)!=0,0) #ifdef __cplusplus } #endif #endif + + diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi/install-sh --- a/Modules/_ctypes/libffi/install-sh Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/_ctypes/libffi/install-sh Sun Jul 20 10:52:46 2014 -0400 @@ -1,7 +1,7 @@ #!/bin/sh # install - install a program, script, or datafile -scriptversion=2009-04-28.21; # UTC +scriptversion=2004-12-17.09 # This originates from X11R5 (mit/util/scripts/install.sh), which was # later released in X11R6 (xc/config/util/install.sh) with the @@ -39,68 +39,38 @@ # when there is no Makefile. # # This script is compatible with the BSD install script, but was written -# from scratch. - -nl=' -' -IFS=" "" $nl" +# from scratch. It can only install one file at a time, a restriction +# shared with many OS's install programs. # set DOITPROG to echo to test this script # Don't use :- since 4.3BSD and earlier shells don't like it. -doit=${DOITPROG-} -if test -z "$doit"; then - doit_exec=exec -else - doit_exec=$doit -fi +doit="${DOITPROG-}" -# Put in absolute file names if you don't have them in your path; -# or use environment vars. +# put in absolute paths if you don't have them in your path; or use env. vars. -chgrpprog=${CHGRPPROG-chgrp} -chmodprog=${CHMODPROG-chmod} -chownprog=${CHOWNPROG-chown} -cmpprog=${CMPPROG-cmp} -cpprog=${CPPROG-cp} -mkdirprog=${MKDIRPROG-mkdir} -mvprog=${MVPROG-mv} -rmprog=${RMPROG-rm} -stripprog=${STRIPPROG-strip} +mvprog="${MVPROG-mv}" +cpprog="${CPPROG-cp}" +chmodprog="${CHMODPROG-chmod}" +chownprog="${CHOWNPROG-chown}" +chgrpprog="${CHGRPPROG-chgrp}" +stripprog="${STRIPPROG-strip}" +rmprog="${RMPROG-rm}" +mkdirprog="${MKDIRPROG-mkdir}" -posix_glob='?' -initialize_posix_glob=' - test "$posix_glob" != "?" || { - if (set -f) 2>/dev/null; then - posix_glob= - else - posix_glob=: - fi - } -' - -posix_mkdir= - -# Desired mode of installed file. -mode=0755 - +chmodcmd="$chmodprog 0755" +chowncmd= chgrpcmd= -chmodcmd=$chmodprog -chowncmd= -mvcmd=$mvprog +stripcmd= rmcmd="$rmprog -f" -stripcmd= - +mvcmd="$mvprog" src= dst= dir_arg= -dst_arg= - -copy_on_change=false +dstarg= no_target_directory= -usage="\ -Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE +usage="Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE or: $0 [OPTION]... SRCFILES... DIRECTORY or: $0 [OPTION]... -t DIRECTORY SRCFILES... or: $0 [OPTION]... -d DIRECTORIES... @@ -110,86 +80,81 @@ In the 4th, create DIRECTORIES. Options: - --help display this help and exit. - --version display version info and exit. - - -c (ignored) - -C install only if different (preserve the last data modification time) - -d create directories instead of installing files. - -g GROUP $chgrpprog installed files to GROUP. - -m MODE $chmodprog installed files to MODE. - -o USER $chownprog installed files to USER. - -s $stripprog installed files. - -t DIRECTORY install into DIRECTORY. - -T report an error if DSTFILE is a directory. +-c (ignored) +-d create directories instead of installing files. +-g GROUP $chgrpprog installed files to GROUP. +-m MODE $chmodprog installed files to MODE. +-o USER $chownprog installed files to USER. +-s $stripprog installed files. +-t DIRECTORY install into DIRECTORY. +-T report an error if DSTFILE is a directory. +--help display this help and exit. +--version display version info and exit. Environment variables override the default commands: - CHGRPPROG CHMODPROG CHOWNPROG CMPPROG CPPROG MKDIRPROG MVPROG - RMPROG STRIPPROG + CHGRPPROG CHMODPROG CHOWNPROG CPPROG MKDIRPROG MVPROG RMPROG STRIPPROG " -while test $# -ne 0; do +while test -n "$1"; do case $1 in - -c) ;; + -c) shift + continue;; - -C) copy_on_change=true;; - - -d) dir_arg=true;; + -d) dir_arg=true + shift + continue;; -g) chgrpcmd="$chgrpprog $2" - shift;; + shift + shift + continue;; - --help) echo "$usage"; exit $?;; + --help) echo "$usage"; exit 0;; - -m) mode=$2 - case $mode in - *' '* | *' '* | *' -'* | *'*'* | *'?'* | *'['*) - echo "$0: invalid mode: $mode" >&2 - exit 1;; - esac - shift;; + -m) chmodcmd="$chmodprog $2" + shift + shift + continue;; -o) chowncmd="$chownprog $2" - shift;; + shift + shift + continue;; - -s) stripcmd=$stripprog;; + -s) stripcmd=$stripprog + shift + continue;; - -t) dst_arg=$2 - shift;; + -t) dstarg=$2 + shift + shift + continue;; - -T) no_target_directory=true;; + -T) no_target_directory=true + shift + continue;; - --version) echo "$0 $scriptversion"; exit $?;; + --version) echo "$0 $scriptversion"; exit 0;; - --) shift + *) # When -d is used, all remaining arguments are directories to create. + # When -t is used, the destination is already specified. + test -n "$dir_arg$dstarg" && break + # Otherwise, the last argument is the destination. Remove it from $@. + for arg + do + if test -n "$dstarg"; then + # $@ is not empty: it contains at least $arg. + set fnord "$@" "$dstarg" + shift # fnord + fi + shift # arg + dstarg=$arg + done break;; - - -*) echo "$0: invalid option: $1" >&2 - exit 1;; - - *) break;; esac - shift done -if test $# -ne 0 && test -z "$dir_arg$dst_arg"; then - # When -d is used, all remaining arguments are directories to create. - # When -t is used, the destination is already specified. - # Otherwise, the last argument is the destination. Remove it from $@. - for arg - do - if test -n "$dst_arg"; then - # $@ is not empty: it contains at least $arg. - set fnord "$@" "$dst_arg" - shift # fnord - fi - shift # arg - dst_arg=$arg - done -fi - -if test $# -eq 0; then +if test -z "$1"; then if test -z "$dir_arg"; then echo "$0: no input file specified." >&2 exit 1 @@ -199,47 +164,24 @@ exit 0 fi -if test -z "$dir_arg"; then - trap '(exit $?); exit' 1 2 13 15 - - # Set umask so as not to create temps with too-generous modes. - # However, 'strip' requires both read and write access to temps. - case $mode in - # Optimize common cases. - *644) cp_umask=133;; - *755) cp_umask=22;; - - *[0-7]) - if test -z "$stripcmd"; then - u_plus_rw= - else - u_plus_rw='% 200' - fi - cp_umask=`expr '(' 777 - $mode % 1000 ')' $u_plus_rw`;; - *) - if test -z "$stripcmd"; then - u_plus_rw= - else - u_plus_rw=,u+rw - fi - cp_umask=$mode$u_plus_rw;; - esac -fi - for src do # Protect names starting with `-'. case $src in - -*) src=./$src;; + -*) src=./$src ;; esac if test -n "$dir_arg"; then dst=$src - dstdir=$dst - test -d "$dstdir" - dstdir_status=$? + src= + + if test -d "$dst"; then + mkdircmd=: + chmodcmd= + else + mkdircmd=$mkdirprog + fi else - # Waiting for this to be detected by the "$cpprog $src $dsttmp" command # might cause directories to be created, which would be especially bad # if $src (and thus $dsttmp) contains '*'. @@ -248,199 +190,71 @@ exit 1 fi - if test -z "$dst_arg"; then + if test -z "$dstarg"; then echo "$0: no destination specified." >&2 exit 1 fi - dst=$dst_arg + dst=$dstarg # Protect names starting with `-'. case $dst in - -*) dst=./$dst;; + -*) dst=./$dst ;; esac # If destination is a directory, append the input filename; won't work # if double slashes aren't ignored. if test -d "$dst"; then if test -n "$no_target_directory"; then - echo "$0: $dst_arg: Is a directory" >&2 + echo "$0: $dstarg: Is a directory" >&2 exit 1 fi - dstdir=$dst - dst=$dstdir/`basename "$src"` - dstdir_status=0 - else - # Prefer dirname, but fall back on a substitute if dirname fails. - dstdir=` - (dirname "$dst") 2>/dev/null || - expr X"$dst" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ - X"$dst" : 'X\(//\)[^/]' \| \ - X"$dst" : 'X\(//\)$' \| \ - X"$dst" : 'X\(/\)' \| . 2>/dev/null || - echo X"$dst" | - sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ - s//\1/ - q - } - /^X\(\/\/\)[^/].*/{ - s//\1/ - q - } - /^X\(\/\/\)$/{ - s//\1/ - q - } - /^X\(\/\).*/{ - s//\1/ - q - } - s/.*/./; q' - ` - - test -d "$dstdir" - dstdir_status=$? + dst=$dst/`basename "$src"` fi fi - obsolete_mkdir_used=false + # This sed command emulates the dirname command. + dstdir=`echo "$dst" | sed -e 's,/*$,,;s,[^/]*$,,;s,/*$,,;s,^$,.,'` - if test $dstdir_status != 0; then - case $posix_mkdir in - '') - # Create intermediate dirs using mode 755 as modified by the umask. - # This is like FreeBSD 'install' as of 1997-10-28. - umask=`umask` - case $stripcmd.$umask in - # Optimize common cases. - *[2367][2367]) mkdir_umask=$umask;; - .*0[02][02] | .[02][02] | .[02]) mkdir_umask=22;; + # Make sure that the destination directory exists. - *[0-7]) - mkdir_umask=`expr $umask + 22 \ - - $umask % 100 % 40 + $umask % 20 \ - - $umask % 10 % 4 + $umask % 2 - `;; - *) mkdir_umask=$umask,go-w;; - esac + # Skip lots of stat calls in the usual case. + if test ! -d "$dstdir"; then + defaultIFS=' + ' + IFS="${IFS-$defaultIFS}" - # With -d, create the new directory with the user-specified mode. - # Otherwise, rely on $mkdir_umask. - if test -n "$dir_arg"; then - mkdir_mode=-m$mode - else - mkdir_mode= - fi + oIFS=$IFS + # Some sh's can't handle IFS=/ for some reason. + IFS='%' + set x `echo "$dstdir" | sed -e 's@/@%@g' -e 's@^%@/@'` + shift + IFS=$oIFS - posix_mkdir=false - case $umask in - *[123567][0-7][0-7]) - # POSIX mkdir -p sets u+wx bits regardless of umask, which - # is incompatible with FreeBSD 'install' when (umask & 300) != 0. - ;; - *) - tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$ - trap 'ret=$?; rmdir "$tmpdir/d" "$tmpdir" 2>/dev/null; exit $ret' 0 + pathcomp= - if (umask $mkdir_umask && - exec $mkdirprog $mkdir_mode -p -- "$tmpdir/d") >/dev/null 2>&1 - then - if test -z "$dir_arg" || { - # Check for POSIX incompatibilities with -m. - # HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or - # other-writeable bit of parent directory when it shouldn't. - # FreeBSD 6.1 mkdir -m -p sets mode of existing directory. - ls_ld_tmpdir=`ls -ld "$tmpdir"` - case $ls_ld_tmpdir in - d????-?r-*) different_mode=700;; - d????-?--*) different_mode=755;; - *) false;; - esac && - $mkdirprog -m$different_mode -p -- "$tmpdir" && { - ls_ld_tmpdir_1=`ls -ld "$tmpdir"` - test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1" - } - } - then posix_mkdir=: - fi - rmdir "$tmpdir/d" "$tmpdir" - else - # Remove any dirs left behind by ancient mkdir implementations. - rmdir ./$mkdir_mode ./-p ./-- 2>/dev/null - fi - trap '' 0;; - esac;; - esac - - if - $posix_mkdir && ( - umask $mkdir_umask && - $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir" - ) - then : - else - - # The umask is ridiculous, or mkdir does not conform to POSIX, - # or it failed possibly due to a race condition. Create the - # directory the slow way, step by step, checking for races as we go. - - case $dstdir in - /*) prefix='/';; - -*) prefix='./';; - *) prefix='';; - esac - - eval "$initialize_posix_glob" - - oIFS=$IFS - IFS=/ - $posix_glob set -f - set fnord $dstdir + while test $# -ne 0 ; do + pathcomp=$pathcomp$1 shift - $posix_glob set +f - IFS=$oIFS - - prefixes= - - for d - do - test -z "$d" && continue - - prefix=$prefix$d - if test -d "$prefix"; then - prefixes= - else - if $posix_mkdir; then - (umask=$mkdir_umask && - $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir") && break - # Don't fail if two instances are running concurrently. - test -d "$prefix" || exit 1 - else - case $prefix in - *\'*) qprefix=`echo "$prefix" | sed "s/'/'\\\\\\\\''/g"`;; - *) qprefix=$prefix;; - esac - prefixes="$prefixes '$qprefix'" - fi - fi - prefix=$prefix/ - done - - if test -n "$prefixes"; then - # Don't fail if two instances are running concurrently. - (umask $mkdir_umask && - eval "\$doit_exec \$mkdirprog $prefixes") || - test -d "$dstdir" || exit 1 - obsolete_mkdir_used=true + if test ! -d "$pathcomp"; then + $mkdirprog "$pathcomp" + # mkdir can fail with a `File exist' error in case several + # install-sh are creating the directory concurrently. This + # is OK. + test -d "$pathcomp" || exit fi - fi + pathcomp=$pathcomp/ + done fi if test -n "$dir_arg"; then - { test -z "$chowncmd" || $doit $chowncmd "$dst"; } && - { test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } && - { test "$obsolete_mkdir_used$chowncmd$chgrpcmd" = false || - test -z "$chmodcmd" || $doit $chmodcmd $mode "$dst"; } || exit 1 + $doit $mkdircmd "$dst" \ + && { test -z "$chowncmd" || $doit $chowncmd "$dst"; } \ + && { test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } \ + && { test -z "$stripcmd" || $doit $stripcmd "$dst"; } \ + && { test -z "$chmodcmd" || $doit $chmodcmd "$dst"; } + else + dstfile=`basename "$dst"` # Make a couple of temp file names in the proper directory. dsttmp=$dstdir/_inst.$$_ @@ -448,9 +262,10 @@ # Trap to clean up those temp files at exit. trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0 + trap '(exit $?); exit' 1 2 13 15 # Copy the file name to the temp name. - (umask $cp_umask && $doit_exec $cpprog "$src" "$dsttmp") && + $doit $cpprog "$src" "$dsttmp" && # and set any options; do chmod last to preserve setuid bits. # @@ -458,63 +273,51 @@ # ignore errors from any of these, just make sure not to ignore # errors from the above "$doit $cpprog $src $dsttmp" command. # - { test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } && - { test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } && - { test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } && - { test -z "$chmodcmd" || $doit $chmodcmd $mode "$dsttmp"; } && + { test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } \ + && { test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } \ + && { test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } \ + && { test -z "$chmodcmd" || $doit $chmodcmd "$dsttmp"; } && - # If -C, don't bother to copy if it wouldn't change the file. - if $copy_on_change && - old=`LC_ALL=C ls -dlL "$dst" 2>/dev/null` && - new=`LC_ALL=C ls -dlL "$dsttmp" 2>/dev/null` && + # Now rename the file to the real destination. + { $doit $mvcmd -f "$dsttmp" "$dstdir/$dstfile" 2>/dev/null \ + || { + # The rename failed, perhaps because mv can't rename something else + # to itself, or perhaps because mv is so ancient that it does not + # support -f. - eval "$initialize_posix_glob" && - $posix_glob set -f && - set X $old && old=:$2:$4:$5:$6 && - set X $new && new=:$2:$4:$5:$6 && - $posix_glob set +f && + # Now remove or move aside any old file at destination location. + # We try this two ways since rm can't unlink itself on some + # systems and the destination file might be busy for other + # reasons. In this case, the final cleanup might fail but the new + # file should still install successfully. + { + if test -f "$dstdir/$dstfile"; then + $doit $rmcmd -f "$dstdir/$dstfile" 2>/dev/null \ + || $doit $mvcmd -f "$dstdir/$dstfile" "$rmtmp" 2>/dev/null \ + || { + echo "$0: cannot unlink or rename $dstdir/$dstfile" >&2 + (exit 1); exit 1 + } + else + : + fi + } && - test "$old" = "$new" && - $cmpprog "$dst" "$dsttmp" >/dev/null 2>&1 - then - rm -f "$dsttmp" - else - # Rename the file to the real destination. - $doit $mvcmd -f "$dsttmp" "$dst" 2>/dev/null || + # Now rename the file to the real destination. + $doit $mvcmd "$dsttmp" "$dstdir/$dstfile" + } + } + fi || { (exit 1); exit 1; } +done - # The rename failed, perhaps because mv can't rename something else - # to itself, or perhaps because mv is so ancient that it does not - # support -f. - { - # Now remove or move aside any old file at destination location. - # We try this two ways since rm can't unlink itself on some - # systems and the destination file might be busy for other - # reasons. In this case, the final cleanup might fail but the new - # file should still install successfully. - { - test ! -f "$dst" || - $doit $rmcmd -f "$dst" 2>/dev/null || - { $doit $mvcmd -f "$dst" "$rmtmp" 2>/dev/null && - { $doit $rmcmd -f "$rmtmp" 2>/dev/null; :; } - } || - { echo "$0: cannot unlink or rename $dst" >&2 - (exit 1); exit 1 - } - } && - - # Now rename the file to the real destination. - $doit $mvcmd "$dsttmp" "$dst" - } - fi || exit 1 - - trap '' 0 - fi -done +# The final little trick to "correctly" pass the exit status to the exit trap. +{ + (exit 0); exit 0 +} # Local variables: # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "scriptversion=" # time-stamp-format: "%:y-%02m-%02d.%02H" -# time-stamp-time-zone: "UTC" -# time-stamp-end: "; # UTC" +# time-stamp-end: "$" # End: diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi/libffi.xcodeproj/project.pbxproj --- a/Modules/_ctypes/libffi/libffi.xcodeproj/project.pbxproj Sat Jul 19 16:34:33 2014 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,579 +0,0 @@ -// !$*UTF8*$! -{ - archiveVersion = 1; - classes = { - }; - objectVersion = 46; - objects = { - -/* Begin PBXBuildFile section */ - 6C43CBDC1534F76F00162364 /* ffi.c in Sources */ = {isa = PBXBuildFile; fileRef = 6C43CBBD1534F76F00162364 /* ffi.c */; }; - 6C43CBDD1534F76F00162364 /* sysv.S in Sources */ = {isa = PBXBuildFile; fileRef = 6C43CBBF1534F76F00162364 /* sysv.S */; }; - 6C43CBDE1534F76F00162364 /* trampoline.S in Sources */ = {isa = PBXBuildFile; fileRef = 6C43CBC01534F76F00162364 /* trampoline.S */; }; - 6C43CBE61534F76F00162364 /* darwin.S in Sources */ = {isa = PBXBuildFile; fileRef = 6C43CBC91534F76F00162364 /* darwin.S */; }; - 6C43CBE81534F76F00162364 /* ffi.c in Sources */ = {isa = PBXBuildFile; fileRef = 6C43CBCB1534F76F00162364 /* ffi.c */; }; - 6C43CC1F1534F77800162364 /* darwin.S in Sources */ = {isa = PBXBuildFile; fileRef = 6C43CC051534F77800162364 /* darwin.S */; }; - 6C43CC201534F77800162364 /* darwin64.S in Sources */ = {isa = PBXBuildFile; fileRef = 6C43CC061534F77800162364 /* darwin64.S */; }; - 6C43CC211534F77800162364 /* ffi.c in Sources */ = {isa = PBXBuildFile; fileRef = 6C43CC071534F77800162364 /* ffi.c */; }; - 6C43CC221534F77800162364 /* ffi64.c in Sources */ = {isa = PBXBuildFile; fileRef = 6C43CC081534F77800162364 /* ffi64.c */; }; - 6C43CC2F1534F7BE00162364 /* closures.c in Sources */ = {isa = PBXBuildFile; fileRef = 6C43CC281534F7BE00162364 /* closures.c */; }; - 6C43CC301534F7BE00162364 /* closures.c in Sources */ = {isa = PBXBuildFile; fileRef = 6C43CC281534F7BE00162364 /* closures.c */; }; - 6C43CC351534F7BE00162364 /* java_raw_api.c in Sources */ = {isa = PBXBuildFile; fileRef = 6C43CC2B1534F7BE00162364 /* java_raw_api.c */; }; - 6C43CC361534F7BE00162364 /* java_raw_api.c in Sources */ = {isa = PBXBuildFile; fileRef = 6C43CC2B1534F7BE00162364 /* java_raw_api.c */; }; - 6C43CC371534F7BE00162364 /* prep_cif.c in Sources */ = {isa = PBXBuildFile; fileRef = 6C43CC2C1534F7BE00162364 /* prep_cif.c */; }; - 6C43CC381534F7BE00162364 /* prep_cif.c in Sources */ = {isa = PBXBuildFile; fileRef = 6C43CC2C1534F7BE00162364 /* prep_cif.c */; }; - 6C43CC391534F7BE00162364 /* raw_api.c in Sources */ = {isa = PBXBuildFile; fileRef = 6C43CC2D1534F7BE00162364 /* raw_api.c */; }; - 6C43CC3A1534F7BE00162364 /* raw_api.c in Sources */ = {isa = PBXBuildFile; fileRef = 6C43CC2D1534F7BE00162364 /* raw_api.c */; }; - 6C43CC3B1534F7BE00162364 /* types.c in Sources */ = {isa = PBXBuildFile; fileRef = 6C43CC2E1534F7BE00162364 /* types.c */; }; - 6C43CC3C1534F7BE00162364 /* types.c in Sources */ = {isa = PBXBuildFile; fileRef = 6C43CC2E1534F7BE00162364 /* types.c */; }; - 6C43CC971535032600162364 /* ffi.h in Headers */ = {isa = PBXBuildFile; fileRef = 6C43CC8D1535032600162364 /* ffi.h */; settings = {ATTRIBUTES = (Public, ); }; }; - 6C43CC981535032600162364 /* ffi_common.h in Headers */ = {isa = PBXBuildFile; fileRef = 6C43CC8E1535032600162364 /* ffi_common.h */; settings = {ATTRIBUTES = (Public, ); }; }; - 6C43CC991535032600162364 /* ffi_i386.h in Headers */ = {isa = PBXBuildFile; fileRef = 6C43CC8F1535032600162364 /* ffi_i386.h */; settings = {ATTRIBUTES = (Public, ); }; }; - 6C43CC9A1535032600162364 /* ffi_x86_64.h in Headers */ = {isa = PBXBuildFile; fileRef = 6C43CC901535032600162364 /* ffi_x86_64.h */; settings = {ATTRIBUTES = (Public, ); }; }; - 6C43CC9B1535032600162364 /* fficonfig.h in Headers */ = {isa = PBXBuildFile; fileRef = 6C43CC911535032600162364 /* fficonfig.h */; }; - 6C43CC9C1535032600162364 /* fficonfig_i386.h in Headers */ = {isa = PBXBuildFile; fileRef = 6C43CC921535032600162364 /* fficonfig_i386.h */; }; - 6C43CC9D1535032600162364 /* fficonfig_x86_64.h in Headers */ = {isa = PBXBuildFile; fileRef = 6C43CC931535032600162364 /* fficonfig_x86_64.h */; }; - 6C43CC9E1535032600162364 /* ffitarget.h in Headers */ = {isa = PBXBuildFile; fileRef = 6C43CC941535032600162364 /* ffitarget.h */; settings = {ATTRIBUTES = (Public, ); }; }; - 6C43CC9F1535032600162364 /* ffitarget_i386.h in Headers */ = {isa = PBXBuildFile; fileRef = 6C43CC951535032600162364 /* ffitarget_i386.h */; settings = {ATTRIBUTES = (Public, ); }; }; - 6C43CCA01535032600162364 /* ffitarget_x86_64.h in Headers */ = {isa = PBXBuildFile; fileRef = 6C43CC961535032600162364 /* ffitarget_x86_64.h */; settings = {ATTRIBUTES = (Public, ); }; }; - 6C43CCAD1535039600162364 /* ffi.h in Headers */ = {isa = PBXBuildFile; fileRef = 6C43CCA21535039600162364 /* ffi.h */; settings = {ATTRIBUTES = (Public, ); }; }; - 6C43CCAE1535039600162364 /* ffi_armv7.h in Headers */ = {isa = PBXBuildFile; fileRef = 6C43CCA31535039600162364 /* ffi_armv7.h */; settings = {ATTRIBUTES = (Public, ); }; }; - 6C43CCAF1535039600162364 /* ffi_common.h in Headers */ = {isa = PBXBuildFile; fileRef = 6C43CCA41535039600162364 /* ffi_common.h */; settings = {ATTRIBUTES = (Public, ); }; }; - 6C43CCB01535039600162364 /* ffi_i386.h in Headers */ = {isa = PBXBuildFile; fileRef = 6C43CCA51535039600162364 /* ffi_i386.h */; settings = {ATTRIBUTES = (Public, ); }; }; - 6C43CCB11535039600162364 /* fficonfig.h in Headers */ = {isa = PBXBuildFile; fileRef = 6C43CCA61535039600162364 /* fficonfig.h */; }; - 6C43CCB21535039600162364 /* fficonfig_armv7.h in Headers */ = {isa = PBXBuildFile; fileRef = 6C43CCA71535039600162364 /* fficonfig_armv7.h */; }; - 6C43CCB31535039600162364 /* fficonfig_i386.h in Headers */ = {isa = PBXBuildFile; fileRef = 6C43CCA81535039600162364 /* fficonfig_i386.h */; }; - 6C43CCB41535039600162364 /* ffitarget.h in Headers */ = {isa = PBXBuildFile; fileRef = 6C43CCA91535039600162364 /* ffitarget.h */; settings = {ATTRIBUTES = (Public, ); }; }; - 6C43CCB51535039600162364 /* ffitarget_arm.h in Headers */ = {isa = PBXBuildFile; fileRef = 6C43CCAA1535039600162364 /* ffitarget_arm.h */; settings = {ATTRIBUTES = (Public, ); }; }; - 6C43CCB61535039600162364 /* ffitarget_armv7.h in Headers */ = {isa = PBXBuildFile; fileRef = 6C43CCAB1535039600162364 /* ffitarget_armv7.h */; settings = {ATTRIBUTES = (Public, ); }; }; - 6C43CCB71535039600162364 /* ffitarget_i386.h in Headers */ = {isa = PBXBuildFile; fileRef = 6C43CCAC1535039600162364 /* ffitarget_i386.h */; settings = {ATTRIBUTES = (Public, ); }; }; -/* End PBXBuildFile section */ - -/* Begin PBXFileReference section */ - 6C43CB3D1534E9D100162364 /* libffi.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libffi.a; sourceTree = BUILT_PRODUCTS_DIR; }; - 6C43CBBD1534F76F00162364 /* ffi.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ffi.c; sourceTree = ""; }; - 6C43CBBF1534F76F00162364 /* sysv.S */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.asm; path = sysv.S; sourceTree = ""; }; - 6C43CBC01534F76F00162364 /* trampoline.S */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.asm; path = trampoline.S; sourceTree = ""; }; - 6C43CBC91534F76F00162364 /* darwin.S */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.asm; path = darwin.S; sourceTree = ""; }; - 6C43CBCB1534F76F00162364 /* ffi.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ffi.c; sourceTree = ""; }; - 6C43CC051534F77800162364 /* darwin.S */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.asm; path = darwin.S; sourceTree = ""; }; - 6C43CC061534F77800162364 /* darwin64.S */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.asm; path = darwin64.S; sourceTree = ""; }; - 6C43CC071534F77800162364 /* ffi.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ffi.c; sourceTree = ""; }; - 6C43CC081534F77800162364 /* ffi64.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ffi64.c; sourceTree = ""; }; - 6C43CC281534F7BE00162364 /* closures.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = closures.c; path = src/closures.c; sourceTree = SOURCE_ROOT; }; - 6C43CC2B1534F7BE00162364 /* java_raw_api.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = java_raw_api.c; path = src/java_raw_api.c; sourceTree = SOURCE_ROOT; }; - 6C43CC2C1534F7BE00162364 /* prep_cif.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = prep_cif.c; path = src/prep_cif.c; sourceTree = SOURCE_ROOT; }; - 6C43CC2D1534F7BE00162364 /* raw_api.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = raw_api.c; path = src/raw_api.c; sourceTree = SOURCE_ROOT; }; - 6C43CC2E1534F7BE00162364 /* types.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = types.c; path = src/types.c; sourceTree = SOURCE_ROOT; }; - 6C43CC8D1535032600162364 /* ffi.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ffi.h; sourceTree = ""; }; - 6C43CC8E1535032600162364 /* ffi_common.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ffi_common.h; sourceTree = ""; }; - 6C43CC8F1535032600162364 /* ffi_i386.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ffi_i386.h; sourceTree = ""; }; - 6C43CC901535032600162364 /* ffi_x86_64.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ffi_x86_64.h; sourceTree = ""; }; - 6C43CC911535032600162364 /* fficonfig.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = fficonfig.h; sourceTree = ""; }; - 6C43CC921535032600162364 /* fficonfig_i386.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = fficonfig_i386.h; sourceTree = ""; }; - 6C43CC931535032600162364 /* fficonfig_x86_64.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = fficonfig_x86_64.h; sourceTree = ""; }; - 6C43CC941535032600162364 /* ffitarget.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ffitarget.h; sourceTree = ""; }; - 6C43CC951535032600162364 /* ffitarget_i386.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ffitarget_i386.h; sourceTree = ""; }; - 6C43CC961535032600162364 /* ffitarget_x86_64.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ffitarget_x86_64.h; sourceTree = ""; }; - 6C43CCA21535039600162364 /* ffi.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ffi.h; sourceTree = ""; }; - 6C43CCA31535039600162364 /* ffi_armv7.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ffi_armv7.h; sourceTree = ""; }; - 6C43CCA41535039600162364 /* ffi_common.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ffi_common.h; sourceTree = ""; }; - 6C43CCA51535039600162364 /* ffi_i386.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ffi_i386.h; sourceTree = ""; }; - 6C43CCA61535039600162364 /* fficonfig.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = fficonfig.h; sourceTree = ""; }; - 6C43CCA71535039600162364 /* fficonfig_armv7.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = fficonfig_armv7.h; sourceTree = ""; }; - 6C43CCA81535039600162364 /* fficonfig_i386.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = fficonfig_i386.h; sourceTree = ""; }; - 6C43CCA91535039600162364 /* ffitarget.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ffitarget.h; sourceTree = ""; }; - 6C43CCAA1535039600162364 /* ffitarget_arm.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ffitarget_arm.h; sourceTree = ""; }; - 6C43CCAB1535039600162364 /* ffitarget_armv7.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ffitarget_armv7.h; sourceTree = ""; }; - 6C43CCAC1535039600162364 /* ffitarget_i386.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ffitarget_i386.h; sourceTree = ""; }; - F6F980BA147386130008F121 /* libffi.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libffi.a; sourceTree = BUILT_PRODUCTS_DIR; }; -/* End PBXFileReference section */ - -/* Begin PBXFrameworksBuildPhase section */ - 6C43CB3A1534E9D100162364 /* Frameworks */ = { - isa = PBXFrameworksBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - runOnlyForDeploymentPostprocessing = 0; - }; - F6F980B7147386130008F121 /* Frameworks */ = { - isa = PBXFrameworksBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXFrameworksBuildPhase section */ - -/* Begin PBXGroup section */ - 6C43CBAF1534F76F00162364 /* iOS */ = { - isa = PBXGroup; - children = ( - 6C43CCA11535039600162364 /* include */, - 6C43CBBB1534F76F00162364 /* src */, - ); - name = iOS; - path = ios; - sourceTree = ""; - }; - 6C43CBBB1534F76F00162364 /* src */ = { - isa = PBXGroup; - children = ( - 6C43CBC81534F76F00162364 /* x86 */, - 6C43CBBC1534F76F00162364 /* arm */, - ); - path = src; - sourceTree = ""; - }; - 6C43CBBC1534F76F00162364 /* arm */ = { - isa = PBXGroup; - children = ( - 6C43CBBD1534F76F00162364 /* ffi.c */, - 6C43CBBF1534F76F00162364 /* sysv.S */, - 6C43CBC01534F76F00162364 /* trampoline.S */, - ); - path = arm; - sourceTree = ""; - }; - 6C43CBC81534F76F00162364 /* x86 */ = { - isa = PBXGroup; - children = ( - 6C43CBC91534F76F00162364 /* darwin.S */, - 6C43CBCB1534F76F00162364 /* ffi.c */, - ); - path = x86; - sourceTree = ""; - }; - 6C43CBF01534F77800162364 /* OS X */ = { - isa = PBXGroup; - children = ( - 6C43CC8C1535032600162364 /* include */, - 6C43CBFC1534F77800162364 /* src */, - ); - name = "OS X"; - path = osx; - sourceTree = ""; - }; - 6C43CBFC1534F77800162364 /* src */ = { - isa = PBXGroup; - children = ( - 6C43CC041534F77800162364 /* x86 */, - ); - path = src; - sourceTree = ""; - }; - 6C43CC041534F77800162364 /* x86 */ = { - isa = PBXGroup; - children = ( - 6C43CC051534F77800162364 /* darwin.S */, - 6C43CC061534F77800162364 /* darwin64.S */, - 6C43CC071534F77800162364 /* ffi.c */, - 6C43CC081534F77800162364 /* ffi64.c */, - ); - path = x86; - sourceTree = ""; - }; - 6C43CC3D1534F7C400162364 /* src */ = { - isa = PBXGroup; - children = ( - 6C43CC281534F7BE00162364 /* closures.c */, - 6C43CC2B1534F7BE00162364 /* java_raw_api.c */, - 6C43CC2C1534F7BE00162364 /* prep_cif.c */, - 6C43CC2D1534F7BE00162364 /* raw_api.c */, - 6C43CC2E1534F7BE00162364 /* types.c */, - ); - name = src; - path = ios; - sourceTree = ""; - }; - 6C43CC8C1535032600162364 /* include */ = { - isa = PBXGroup; - children = ( - 6C43CC8D1535032600162364 /* ffi.h */, - 6C43CC8E1535032600162364 /* ffi_common.h */, - 6C43CC8F1535032600162364 /* ffi_i386.h */, - 6C43CC901535032600162364 /* ffi_x86_64.h */, - 6C43CC911535032600162364 /* fficonfig.h */, - 6C43CC921535032600162364 /* fficonfig_i386.h */, - 6C43CC931535032600162364 /* fficonfig_x86_64.h */, - 6C43CC941535032600162364 /* ffitarget.h */, - 6C43CC951535032600162364 /* ffitarget_i386.h */, - 6C43CC961535032600162364 /* ffitarget_x86_64.h */, - ); - path = include; - sourceTree = ""; - }; - 6C43CCA11535039600162364 /* include */ = { - isa = PBXGroup; - children = ( - 6C43CCA21535039600162364 /* ffi.h */, - 6C43CCA31535039600162364 /* ffi_armv7.h */, - 6C43CCA41535039600162364 /* ffi_common.h */, - 6C43CCA51535039600162364 /* ffi_i386.h */, - 6C43CCA61535039600162364 /* fficonfig.h */, - 6C43CCA71535039600162364 /* fficonfig_armv7.h */, - 6C43CCA81535039600162364 /* fficonfig_i386.h */, - 6C43CCA91535039600162364 /* ffitarget.h */, - 6C43CCAA1535039600162364 /* ffitarget_arm.h */, - 6C43CCAB1535039600162364 /* ffitarget_armv7.h */, - 6C43CCAC1535039600162364 /* ffitarget_i386.h */, - ); - path = include; - sourceTree = ""; - }; - F6B0839514721EE50031D8A1 = { - isa = PBXGroup; - children = ( - 6C43CC3D1534F7C400162364 /* src */, - 6C43CBAF1534F76F00162364 /* iOS */, - 6C43CBF01534F77800162364 /* OS X */, - F6F980C6147386260008F121 /* Products */, - ); - sourceTree = ""; - }; - F6F980C6147386260008F121 /* Products */ = { - isa = PBXGroup; - children = ( - F6F980BA147386130008F121 /* libffi.a */, - 6C43CB3D1534E9D100162364 /* libffi.a */, - ); - name = Products; - path = ../..; - sourceTree = BUILT_PRODUCTS_DIR; - }; -/* End PBXGroup section */ - -/* Begin PBXHeadersBuildPhase section */ - 6C43CB3B1534E9D100162364 /* Headers */ = { - isa = PBXHeadersBuildPhase; - buildActionMask = 2147483647; - files = ( - 6C43CC971535032600162364 /* ffi.h in Headers */, - 6C43CC981535032600162364 /* ffi_common.h in Headers */, - 6C43CC991535032600162364 /* ffi_i386.h in Headers */, - 6C43CC9A1535032600162364 /* ffi_x86_64.h in Headers */, - 6C43CC9E1535032600162364 /* ffitarget.h in Headers */, - 6C43CC9F1535032600162364 /* ffitarget_i386.h in Headers */, - 6C43CCA01535032600162364 /* ffitarget_x86_64.h in Headers */, - 6C43CC9B1535032600162364 /* fficonfig.h in Headers */, - 6C43CC9C1535032600162364 /* fficonfig_i386.h in Headers */, - 6C43CC9D1535032600162364 /* fficonfig_x86_64.h in Headers */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; - F6F980B8147386130008F121 /* Headers */ = { - isa = PBXHeadersBuildPhase; - buildActionMask = 2147483647; - files = ( - 6C43CCAD1535039600162364 /* ffi.h in Headers */, - 6C43CCAE1535039600162364 /* ffi_armv7.h in Headers */, - 6C43CCAF1535039600162364 /* ffi_common.h in Headers */, - 6C43CCB01535039600162364 /* ffi_i386.h in Headers */, - 6C43CCB41535039600162364 /* ffitarget.h in Headers */, - 6C43CCB51535039600162364 /* ffitarget_arm.h in Headers */, - 6C43CCB61535039600162364 /* ffitarget_armv7.h in Headers */, - 6C43CCB71535039600162364 /* ffitarget_i386.h in Headers */, - 6C43CCB11535039600162364 /* fficonfig.h in Headers */, - 6C43CCB21535039600162364 /* fficonfig_armv7.h in Headers */, - 6C43CCB31535039600162364 /* fficonfig_i386.h in Headers */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXHeadersBuildPhase section */ - -/* Begin PBXNativeTarget section */ - 6C43CB3C1534E9D100162364 /* libffi OS X */ = { - isa = PBXNativeTarget; - buildConfigurationList = 6C43CB4A1534E9D100162364 /* Build configuration list for PBXNativeTarget "libffi OS X" */; - buildPhases = ( - 6C43CC401534FF3B00162364 /* Generate Source and Headers */, - 6C43CB391534E9D100162364 /* Sources */, - 6C43CB3A1534E9D100162364 /* Frameworks */, - 6C43CB3B1534E9D100162364 /* Headers */, - ); - buildRules = ( - ); - dependencies = ( - ); - name = "libffi OS X"; - productName = "ffi OS X"; - productReference = 6C43CB3D1534E9D100162364 /* libffi.a */; - productType = "com.apple.product-type.library.static"; - }; - F6F980B9147386130008F121 /* libffi iOS */ = { - isa = PBXNativeTarget; - buildConfigurationList = F6F980C4147386130008F121 /* Build configuration list for PBXNativeTarget "libffi iOS" */; - buildPhases = ( - 6C43CC3E1534F8E200162364 /* Generate Trampoline */, - 6C43CC3F1534FF1B00162364 /* Generate Source and Headers */, - F6F980B6147386130008F121 /* Sources */, - F6F980B7147386130008F121 /* Frameworks */, - F6F980B8147386130008F121 /* Headers */, - ); - buildRules = ( - ); - dependencies = ( - ); - name = "libffi iOS"; - productName = ffi; - productReference = F6F980BA147386130008F121 /* libffi.a */; - productType = "com.apple.product-type.library.static"; - }; -/* End PBXNativeTarget section */ - -/* Begin PBXProject section */ - F6B0839714721EE50031D8A1 /* Project object */ = { - isa = PBXProject; - attributes = { - LastUpgradeCheck = 0430; - }; - buildConfigurationList = F6B0839A14721EE50031D8A1 /* Build configuration list for PBXProject "libffi" */; - compatibilityVersion = "Xcode 3.2"; - developmentRegion = English; - hasScannedForEncodings = 0; - knownRegions = ( - en, - ); - mainGroup = F6B0839514721EE50031D8A1; - productRefGroup = F6B0839514721EE50031D8A1; - projectDirPath = ""; - projectRoot = ""; - targets = ( - F6F980B9147386130008F121 /* libffi iOS */, - 6C43CB3C1534E9D100162364 /* libffi OS X */, - ); - }; -/* End PBXProject section */ - -/* Begin PBXShellScriptBuildPhase section */ - 6C43CC3E1534F8E200162364 /* Generate Trampoline */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputPaths = ( - ); - name = "Generate Trampoline"; - outputPaths = ( - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /usr/bin/python; - shellScript = "import subprocess\nimport re\nimport os\nimport errno\nimport sys\n\ndef main():\n with open('src/arm/trampoline.S', 'w') as tramp_out:\n p = subprocess.Popen(['bash', 'src/arm/gentramp.sh'], stdout=tramp_out)\n p.wait()\n\nif __name__ == '__main__':\n main()"; - }; - 6C43CC3F1534FF1B00162364 /* Generate Source and Headers */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputPaths = ( - ); - name = "Generate Source and Headers"; - outputPaths = ( - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "/usr/bin/python generate-ios-source-and-headers.py"; - }; - 6C43CC401534FF3B00162364 /* Generate Source and Headers */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputPaths = ( - ); - name = "Generate Source and Headers"; - outputPaths = ( - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "/usr/bin/python generate-osx-source-and-headers.py"; - }; -/* End PBXShellScriptBuildPhase section */ - -/* Begin PBXSourcesBuildPhase section */ - 6C43CB391534E9D100162364 /* Sources */ = { - isa = PBXSourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - 6C43CC1F1534F77800162364 /* darwin.S in Sources */, - 6C43CC201534F77800162364 /* darwin64.S in Sources */, - 6C43CC211534F77800162364 /* ffi.c in Sources */, - 6C43CC221534F77800162364 /* ffi64.c in Sources */, - 6C43CC301534F7BE00162364 /* closures.c in Sources */, - 6C43CC361534F7BE00162364 /* java_raw_api.c in Sources */, - 6C43CC381534F7BE00162364 /* prep_cif.c in Sources */, - 6C43CC3A1534F7BE00162364 /* raw_api.c in Sources */, - 6C43CC3C1534F7BE00162364 /* types.c in Sources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; - F6F980B6147386130008F121 /* Sources */ = { - isa = PBXSourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - 6C43CBDC1534F76F00162364 /* ffi.c in Sources */, - 6C43CBDD1534F76F00162364 /* sysv.S in Sources */, - 6C43CBDE1534F76F00162364 /* trampoline.S in Sources */, - 6C43CBE61534F76F00162364 /* darwin.S in Sources */, - 6C43CBE81534F76F00162364 /* ffi.c in Sources */, - 6C43CC2F1534F7BE00162364 /* closures.c in Sources */, - 6C43CC351534F7BE00162364 /* java_raw_api.c in Sources */, - 6C43CC371534F7BE00162364 /* prep_cif.c in Sources */, - 6C43CC391534F7BE00162364 /* raw_api.c in Sources */, - 6C43CC3B1534F7BE00162364 /* types.c in Sources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXSourcesBuildPhase section */ - -/* Begin XCBuildConfiguration section */ - 6C43CB4B1534E9D100162364 /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - ARCHS = "$(ARCHS_STANDARD_32_64_BIT)"; - DSTROOT = /tmp/ffi.dst; - FRAMEWORK_SEARCH_PATHS = ( - "$(inherited)", - "\"$(SYSTEM_APPS_DIR)/Xcode.app/Contents/Developer/Library/Frameworks\"", - ); - GCC_ENABLE_OBJC_EXCEPTIONS = YES; - GCC_VERSION = com.apple.compilers.llvm.clang.1_0; - GCC_WARN_64_TO_32_BIT_CONVERSION = YES; - GCC_WARN_UNINITIALIZED_AUTOS = YES; - MACOSX_DEPLOYMENT_TARGET = 10.6; - ONLY_ACTIVE_ARCH = YES; - PRODUCT_NAME = ffi; - SDKROOT = macosx; - }; - name = Debug; - }; - 6C43CB4C1534E9D100162364 /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - ARCHS = "$(ARCHS_STANDARD_32_64_BIT)"; - DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; - DSTROOT = /tmp/ffi.dst; - FRAMEWORK_SEARCH_PATHS = ( - "$(inherited)", - "\"$(SYSTEM_APPS_DIR)/Xcode.app/Contents/Developer/Library/Frameworks\"", - ); - GCC_ENABLE_OBJC_EXCEPTIONS = YES; - GCC_VERSION = com.apple.compilers.llvm.clang.1_0; - GCC_WARN_64_TO_32_BIT_CONVERSION = YES; - GCC_WARN_UNINITIALIZED_AUTOS = YES; - MACOSX_DEPLOYMENT_TARGET = 10.6; - PRODUCT_NAME = ffi; - SDKROOT = macosx; - }; - name = Release; - }; - F6B083AB14721EE50031D8A1 /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - ALWAYS_SEARCH_USER_PATHS = NO; - ARCHS = "$(ARCHS_STANDARD_32_BIT)"; - COPY_PHASE_STRIP = NO; - GCC_C_LANGUAGE_STANDARD = gnu99; - GCC_DYNAMIC_NO_PIC = NO; - GCC_OPTIMIZATION_LEVEL = 0; - GCC_PREPROCESSOR_DEFINITIONS = ( - "DEBUG=1", - "$(inherited)", - ); - GCC_SYMBOLS_PRIVATE_EXTERN = NO; - GCC_WARN_ABOUT_MISSING_PROTOTYPES = NO; - GCC_WARN_ABOUT_RETURN_TYPE = YES; - GCC_WARN_UNUSED_VALUE = NO; - GCC_WARN_UNUSED_VARIABLE = YES; - HEADER_SEARCH_PATHS = ios/include; - SDKROOT = iphoneos; - }; - name = Debug; - }; - F6B083AC14721EE50031D8A1 /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - ALWAYS_SEARCH_USER_PATHS = NO; - ARCHS = "$(ARCHS_STANDARD_32_BIT)"; - COPY_PHASE_STRIP = YES; - GCC_C_LANGUAGE_STANDARD = gnu99; - GCC_PREPROCESSOR_DEFINITIONS = ""; - GCC_WARN_ABOUT_MISSING_PROTOTYPES = NO; - GCC_WARN_ABOUT_RETURN_TYPE = YES; - GCC_WARN_UNUSED_VALUE = NO; - GCC_WARN_UNUSED_VARIABLE = YES; - HEADER_SEARCH_PATHS = ios/include; - SDKROOT = iphoneos; - VALIDATE_PRODUCT = YES; - }; - name = Release; - }; - F6F980C2147386130008F121 /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - ARCHS = ( - armv6, - armv7, - ); - DSTROOT = /tmp/ffi.dst; - GCC_PRECOMPILE_PREFIX_HEADER = YES; - GCC_THUMB_SUPPORT = NO; - IPHONEOS_DEPLOYMENT_TARGET = 4.0; - OTHER_LDFLAGS = "-ObjC"; - PRODUCT_NAME = ffi; - SKIP_INSTALL = YES; - }; - name = Debug; - }; - F6F980C3147386130008F121 /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - ARCHS = ( - armv6, - armv7, - ); - DSTROOT = /tmp/ffi.dst; - GCC_PRECOMPILE_PREFIX_HEADER = YES; - GCC_THUMB_SUPPORT = NO; - IPHONEOS_DEPLOYMENT_TARGET = 4.0; - OTHER_LDFLAGS = "-ObjC"; - PRODUCT_NAME = ffi; - SKIP_INSTALL = YES; - }; - name = Release; - }; -/* End XCBuildConfiguration section */ - -/* Begin XCConfigurationList section */ - 6C43CB4A1534E9D100162364 /* Build configuration list for PBXNativeTarget "libffi OS X" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 6C43CB4B1534E9D100162364 /* Debug */, - 6C43CB4C1534E9D100162364 /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; - F6B0839A14721EE50031D8A1 /* Build configuration list for PBXProject "libffi" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - F6B083AB14721EE50031D8A1 /* Debug */, - F6B083AC14721EE50031D8A1 /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; - F6F980C4147386130008F121 /* Build configuration list for PBXNativeTarget "libffi iOS" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - F6F980C2147386130008F121 /* Debug */, - F6F980C3147386130008F121 /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; -/* End XCConfigurationList section */ - }; - rootObject = F6B0839714721EE50031D8A1 /* Project object */; -} diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi/libtool-ldflags --- a/Modules/_ctypes/libffi/libtool-ldflags Sat Jul 19 16:34:33 2014 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,106 +0,0 @@ -#! /bin/sh - -# Script to translate LDFLAGS into a form suitable for use with libtool. - -# Copyright (C) 2005 Free Software Foundation, Inc. -# -# This file is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, -# MA 02110-1301, USA. - -# Contributed by CodeSourcery, LLC. - -# This script is designed to be used from a Makefile that uses libtool -# to build libraries as follows: -# -# LTLDFLAGS = $(shell libtool-ldflags $(LDFLAGS)) -# -# Then, use (LTLDFLAGS) in place of $(LDFLAGS) in your link line. - -# The output of the script. This string is built up as we process the -# arguments. -result= -prev_arg= - -for arg -do - case $arg in - -f*|--*) - # Libtool does not ascribe any special meaning options - # that begin with -f or with a double-dash. So, it will - # think these options are linker options, and prefix them - # with "-Wl,". Then, the compiler driver will ignore the - # options. So, we prefix these options with -Xcompiler to - # make clear to libtool that they are in fact compiler - # options. - case $prev_arg in - -Xpreprocessor|-Xcompiler|-Xlinker) - # This option is already prefixed; don't prefix it again. - ;; - *) - result="$result -Xcompiler" - ;; - esac - ;; - *) - # We do not want to add -Xcompiler to other options because - # that would prevent libtool itself from recognizing them. - ;; - esac - prev_arg=$arg - - # If $(LDFLAGS) is (say): - # a "b'c d" e - # then the user expects that: - # $(LD) $(LDFLAGS) - # will pass three arguments to $(LD): - # 1) a - # 2) b'c d - # 3) e - # We must ensure, therefore, that the arguments are appropriately - # quoted so that using: - # libtool --mode=link ... $(LTLDFLAGS) - # will result in the same number of arguments being passed to - # libtool. In other words, when this script was invoked, the shell - # removed one level of quoting, present in $(LDFLAGS); we have to put - # it back. - - # Quote any embedded single quotes. - case $arg in - *"'"*) - # The following command creates the script: - # 1s,^X,,;s|'|'"'"'|g - # which removes a leading X, and then quotes and embedded single - # quotes. - sed_script="1s,^X,,;s|'|'\"'\"'|g" - # Add a leading "X" so that if $arg starts with a dash, - # the echo command will not try to interpret the argument - # as a command-line option. - arg="X$arg" - # Generate the quoted string. - quoted_arg=`echo "$arg" | sed -e "$sed_script"` - ;; - *) - quoted_arg=$arg - ;; - esac - # Surround the entire argument with single quotes. - quoted_arg="'"$quoted_arg"'" - - # Add it to the string. - result="$result $quoted_arg" -done - -# Output the string we have built up. -echo "$result" diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi/libtool-version --- a/Modules/_ctypes/libffi/libtool-version Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/_ctypes/libffi/libtool-version Sun Jul 20 10:52:46 2014 -0400 @@ -26,4 +26,4 @@ # release, then set age to 0. # # CURRENT:REVISION:AGE -6:1:0 +5:10:0 diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi/ltmain.sh --- a/Modules/_ctypes/libffi/ltmain.sh Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/_ctypes/libffi/ltmain.sh Sun Jul 20 10:52:46 2014 -0400 @@ -1,9 +1,9 @@ - -# libtool (GNU libtool) 2.4.2 +# Generated from ltmain.m4sh. + +# ltmain.sh (GNU libtool) 2.2.6 # Written by Gordon Matzigkeit , 1996 -# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, 2006, -# 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc. +# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, 2006, 2007 2008 Free Software Foundation, Inc. # This is free software; see the source for copying conditions. There is NO # warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. @@ -32,57 +32,50 @@ # # Provide generalized library-building support services. # -# --config show all configuration variables -# --debug enable verbose shell tracing -# -n, --dry-run display commands without modifying any files -# --features display basic configuration information and exit -# --mode=MODE use operation mode MODE -# --preserve-dup-deps don't remove duplicate dependency libraries -# --quiet, --silent don't print informational messages -# --no-quiet, --no-silent -# print informational messages (default) -# --no-warn don't display warning messages -# --tag=TAG use configuration variables from tag TAG -# -v, --verbose print more informational messages than default -# --no-verbose don't print the extra informational messages -# --version print version information -# -h, --help, --help-all print short, long, or detailed help message +# --config show all configuration variables +# --debug enable verbose shell tracing +# -n, --dry-run display commands without modifying any files +# --features display basic configuration information and exit +# --mode=MODE use operation mode MODE +# --preserve-dup-deps don't remove duplicate dependency libraries +# --quiet, --silent don't print informational messages +# --tag=TAG use configuration variables from tag TAG +# -v, --verbose print informational messages (default) +# --version print version information +# -h, --help print short or long help message # # MODE must be one of the following: # -# clean remove files from the build directory -# compile compile a source file into a libtool object -# execute automatically set library path, then run a program -# finish complete the installation of libtool libraries -# install install libraries or executables -# link create a library or an executable -# uninstall remove libraries from an installed directory +# clean remove files from the build directory +# compile compile a source file into a libtool object +# execute automatically set library path, then run a program +# finish complete the installation of libtool libraries +# install install libraries or executables +# link create a library or an executable +# uninstall remove libraries from an installed directory # -# MODE-ARGS vary depending on the MODE. When passed as first option, -# `--mode=MODE' may be abbreviated as `MODE' or a unique abbreviation of that. +# MODE-ARGS vary depending on the MODE. # Try `$progname --help --mode=MODE' for a more detailed description of MODE. # # When reporting a bug, please describe a test case to reproduce it and # include the following information: # -# host-triplet: $host -# shell: $SHELL -# compiler: $LTCC -# compiler flags: $LTCFLAGS -# linker: $LD (gnu? $with_gnu_ld) -# $progname: (GNU libtool) 2.4.2 -# automake: $automake_version -# autoconf: $autoconf_version +# host-triplet: $host +# shell: $SHELL +# compiler: $LTCC +# compiler flags: $LTCFLAGS +# linker: $LD (gnu? $with_gnu_ld) +# $progname: (GNU libtool) 2.2.6 +# automake: $automake_version +# autoconf: $autoconf_version # # Report bugs to . -# GNU libtool home page: . -# General help using GNU software: . - -PROGRAM=libtool + +PROGRAM=ltmain.sh PACKAGE=libtool -VERSION=2.4.2 +VERSION=2.2.6 TIMESTAMP="" -package_revision=1.3337 +package_revision=1.3012 # Be Bourne compatible if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then @@ -98,15 +91,10 @@ BIN_SH=xpg4; export BIN_SH # for Tru64 DUALCASE=1; export DUALCASE # for MKS sh -# A function that is used when there is no print builtin or printf. -func_fallback_echo () -{ - eval 'cat <<_LTECHO_EOF -$1 -_LTECHO_EOF' -} - # NLS nuisances: We save the old values to restore during execute mode. +# Only set LANG and LC_ALL to C if already set. +# These must not be set unconditionally because not all systems understand +# e.g. LANG=C (notably SCO). lt_user_locale= lt_safe_locale= for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES @@ -119,28 +107,24 @@ lt_safe_locale=\"$lt_var=C; \$lt_safe_locale\" fi" done -LC_ALL=C -LANGUAGE=C -export LANGUAGE LC_ALL $lt_unset CDPATH -# Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh -# is ksh but when the shell is invoked as "sh" and the current value of -# the _XPG environment variable is not equal to 1 (one), the special -# positional parameter $0, within a function call, is the name of the -# function. -progpath="$0" : ${CP="cp -f"} -test "${ECHO+set}" = set || ECHO=${as_echo-'printf %s\n'} +: ${ECHO="echo"} +: ${EGREP="/bin/grep -E"} +: ${FGREP="/bin/grep -F"} +: ${GREP="/bin/grep"} +: ${LN_S="ln -s"} : ${MAKE="make"} : ${MKDIR="mkdir"} : ${MV="mv -f"} : ${RM="rm -f"} +: ${SED="/bin/sed"} : ${SHELL="${CONFIG_SHELL-/bin/sh}"} : ${Xsed="$SED -e 1s/^X//"} @@ -160,27 +144,6 @@ dirname="s,/[^/]*$,," basename="s,^.*/,," -# func_dirname file append nondir_replacement -# Compute the dirname of FILE. If nonempty, add APPEND to the result, -# otherwise set result to NONDIR_REPLACEMENT. -func_dirname () -{ - func_dirname_result=`$ECHO "${1}" | $SED "$dirname"` - if test "X$func_dirname_result" = "X${1}"; then - func_dirname_result="${3}" - else - func_dirname_result="$func_dirname_result${2}" - fi -} # func_dirname may be replaced by extended shell implementation - - -# func_basename file -func_basename () -{ - func_basename_result=`$ECHO "${1}" | $SED "$basename"` -} # func_basename may be replaced by extended shell implementation - - # func_dirname_and_basename file append nondir_replacement # perform func_basename and func_dirname in a single function # call: @@ -195,183 +158,33 @@ # those functions but instead duplicate the functionality here. func_dirname_and_basename () { - # Extract subdirectory from the argument. - func_dirname_result=`$ECHO "${1}" | $SED -e "$dirname"` - if test "X$func_dirname_result" = "X${1}"; then - func_dirname_result="${3}" - else - func_dirname_result="$func_dirname_result${2}" - fi - func_basename_result=`$ECHO "${1}" | $SED -e "$basename"` -} # func_dirname_and_basename may be replaced by extended shell implementation - - -# func_stripname prefix suffix name -# strip PREFIX and SUFFIX off of NAME. -# PREFIX and SUFFIX must not contain globbing or regex special -# characters, hashes, percent signs, but SUFFIX may contain a leading -# dot (in which case that matches only a dot). -# func_strip_suffix prefix name -func_stripname () -{ - case ${2} in - .*) func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%\\\\${2}\$%%"`;; - *) func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%${2}\$%%"`;; - esac -} # func_stripname may be replaced by extended shell implementation - - -# These SED scripts presuppose an absolute path with a trailing slash. -pathcar='s,^/\([^/]*\).*$,\1,' -pathcdr='s,^/[^/]*,,' -removedotparts=':dotsl - s@/\./@/@g - t dotsl - s,/\.$,/,' -collapseslashes='s@/\{1,\}@/@g' -finalslash='s,/*$,/,' - -# func_normal_abspath PATH -# Remove doubled-up and trailing slashes, "." path components, -# and cancel out any ".." path components in PATH after making -# it an absolute path. -# value returned in "$func_normal_abspath_result" -func_normal_abspath () -{ - # Start from root dir and reassemble the path. - func_normal_abspath_result= - func_normal_abspath_tpath=$1 - func_normal_abspath_altnamespace= - case $func_normal_abspath_tpath in - "") - # Empty path, that just means $cwd. - func_stripname '' '/' "`pwd`" - func_normal_abspath_result=$func_stripname_result - return - ;; - # The next three entries are used to spot a run of precisely - # two leading slashes without using negated character classes; - # we take advantage of case's first-match behaviour. - ///*) - # Unusual form of absolute path, do nothing. - ;; - //*) - # Not necessarily an ordinary path; POSIX reserves leading '//' - # and for example Cygwin uses it to access remote file shares - # over CIFS/SMB, so we conserve a leading double slash if found. - func_normal_abspath_altnamespace=/ - ;; - /*) - # Absolute path, do nothing. - ;; - *) - # Relative path, prepend $cwd. - func_normal_abspath_tpath=`pwd`/$func_normal_abspath_tpath - ;; - esac - # Cancel out all the simple stuff to save iterations. We also want - # the path to end with a slash for ease of parsing, so make sure - # there is one (and only one) here. - func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \ - -e "$removedotparts" -e "$collapseslashes" -e "$finalslash"` - while :; do - # Processed it all yet? - if test "$func_normal_abspath_tpath" = / ; then - # If we ascended to the root using ".." the result may be empty now. - if test -z "$func_normal_abspath_result" ; then - func_normal_abspath_result=/ - fi - break - fi - func_normal_abspath_tcomponent=`$ECHO "$func_normal_abspath_tpath" | $SED \ - -e "$pathcar"` - func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \ - -e "$pathcdr"` - # Figure out what to do with it - case $func_normal_abspath_tcomponent in - "") - # Trailing empty path component, ignore it. - ;; - ..) - # Parent dir; strip last assembled component from result. - func_dirname "$func_normal_abspath_result" - func_normal_abspath_result=$func_dirname_result - ;; - *) - # Actual path component, append it. - func_normal_abspath_result=$func_normal_abspath_result/$func_normal_abspath_tcomponent - ;; - esac - done - # Restore leading double-slash if one was found on entry. - func_normal_abspath_result=$func_normal_abspath_altnamespace$func_normal_abspath_result + # Extract subdirectory from the argument. + func_dirname_result=`$ECHO "X${1}" | $Xsed -e "$dirname"` + if test "X$func_dirname_result" = "X${1}"; then + func_dirname_result="${3}" + else + func_dirname_result="$func_dirname_result${2}" + fi + func_basename_result=`$ECHO "X${1}" | $Xsed -e "$basename"` } -# func_relative_path SRCDIR DSTDIR -# generates a relative path from SRCDIR to DSTDIR, with a trailing -# slash if non-empty, suitable for immediately appending a filename -# without needing to append a separator. -# value returned in "$func_relative_path_result" -func_relative_path () -{ - func_relative_path_result= - func_normal_abspath "$1" - func_relative_path_tlibdir=$func_normal_abspath_result - func_normal_abspath "$2" - func_relative_path_tbindir=$func_normal_abspath_result - - # Ascend the tree starting from libdir - while :; do - # check if we have found a prefix of bindir - case $func_relative_path_tbindir in - $func_relative_path_tlibdir) - # found an exact match - func_relative_path_tcancelled= - break - ;; - $func_relative_path_tlibdir*) - # found a matching prefix - func_stripname "$func_relative_path_tlibdir" '' "$func_relative_path_tbindir" - func_relative_path_tcancelled=$func_stripname_result - if test -z "$func_relative_path_result"; then - func_relative_path_result=. - fi - break - ;; - *) - func_dirname $func_relative_path_tlibdir - func_relative_path_tlibdir=${func_dirname_result} - if test "x$func_relative_path_tlibdir" = x ; then - # Have to descend all the way to the root! - func_relative_path_result=../$func_relative_path_result - func_relative_path_tcancelled=$func_relative_path_tbindir - break - fi - func_relative_path_result=../$func_relative_path_result - ;; - esac - done - - # Now calculate path; take care to avoid doubling-up slashes. - func_stripname '' '/' "$func_relative_path_result" - func_relative_path_result=$func_stripname_result - func_stripname '/' '/' "$func_relative_path_tcancelled" - if test "x$func_stripname_result" != x ; then - func_relative_path_result=${func_relative_path_result}/${func_stripname_result} - fi - - # Normalisation. If bindir is libdir, return empty string, - # else relative path ending with a slash; either way, target - # file name can be directly appended. - if test ! -z "$func_relative_path_result"; then - func_stripname './' '' "$func_relative_path_result/" - func_relative_path_result=$func_stripname_result - fi -} +# Generated shell functions inserted here. + +# Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh +# is ksh but when the shell is invoked as "sh" and the current value of +# the _XPG environment variable is not equal to 1 (one), the special +# positional parameter $0, within a function call, is the name of the +# function. +progpath="$0" # The name of this program: +# In the unlikely event $progname began with a '-', it would play havoc with +# func_echo (imagine progname=-n), so we prepend ./ in that case: func_dirname_and_basename "$progpath" progname=$func_basename_result +case $progname in + -*) progname=./$progname ;; +esac # Make sure we have an absolute path for reexecution: case $progpath in @@ -383,7 +196,7 @@ ;; *) save_IFS="$IFS" - IFS=${PATH_SEPARATOR-:} + IFS=: for progdir in $PATH; do IFS="$save_IFS" test -x "$progdir/$progname" && break @@ -402,15 +215,6 @@ # Same as above, but do not quote variable references. double_quote_subst='s/\(["`\\]\)/\\\1/g' -# Sed substitution that turns a string into a regex matching for the -# string literally. -sed_make_literal_regex='s,[].[^$\\*\/],\\&,g' - -# Sed substitution that converts a w32 file name or path -# which contains forward slashes, into one that contains -# (escaped) backslashes. A very naive implementation. -lt_sed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g' - # Re-`\' parameter expansions in output of double_quote_subst that were # `\'-ed in input to the same. If an odd number of `\' preceded a '$' # in input to double_quote_subst, that '$' was protected from expansion. @@ -439,7 +243,7 @@ # name if it has been set yet. func_echo () { - $ECHO "$progname: ${opt_mode+$opt_mode: }$*" + $ECHO "$progname${mode+: }$mode: $*" } # func_verbose arg... @@ -454,25 +258,18 @@ : } -# func_echo_all arg... -# Invoke $ECHO with all args, space-separated. -func_echo_all () -{ - $ECHO "$*" -} - # func_error arg... # Echo program name prefixed message to standard error. func_error () { - $ECHO "$progname: ${opt_mode+$opt_mode: }"${1+"$@"} 1>&2 + $ECHO "$progname${mode+: }$mode: "${1+"$@"} 1>&2 } # func_warning arg... # Echo program name prefixed warning message to standard error. func_warning () { - $opt_warning && $ECHO "$progname: ${opt_mode+$opt_mode: }warning: "${1+"$@"} 1>&2 + $opt_warning && $ECHO "$progname${mode+: }$mode: warning: "${1+"$@"} 1>&2 # bash bug again: : @@ -529,9 +326,9 @@ case $my_directory_path in */*) ;; *) break ;; esac # ...otherwise throw away the child directory and loop - my_directory_path=`$ECHO "$my_directory_path" | $SED -e "$dirname"` + my_directory_path=`$ECHO "X$my_directory_path" | $Xsed -e "$dirname"` done - my_dir_list=`$ECHO "$my_dir_list" | $SED 's,:*$,,'` + my_dir_list=`$ECHO "X$my_dir_list" | $Xsed -e 's,:*$,,'` save_mkdir_p_IFS="$IFS"; IFS=':' for my_dir in $my_dir_list; do @@ -581,7 +378,7 @@ func_fatal_error "cannot create temporary directory \`$my_tmpdir'" fi - $ECHO "$my_tmpdir" + $ECHO "X$my_tmpdir" | $Xsed } @@ -595,7 +392,7 @@ { case $1 in *[\\\`\"\$]*) - func_quote_for_eval_unquoted_result=`$ECHO "$1" | $SED "$sed_quote_subst"` ;; + func_quote_for_eval_unquoted_result=`$ECHO "X$1" | $Xsed -e "$sed_quote_subst"` ;; *) func_quote_for_eval_unquoted_result="$1" ;; esac @@ -622,7 +419,7 @@ { case $1 in *[\\\`\"]*) - my_arg=`$ECHO "$1" | $SED \ + my_arg=`$ECHO "X$1" | $Xsed \ -e "$double_quote_subst" -e "$sed_double_backslash"` ;; *) my_arg="$1" ;; @@ -691,39 +488,15 @@ fi } -# func_tr_sh -# Turn $1 into a string suitable for a shell variable name. -# Result is stored in $func_tr_sh_result. All characters -# not in the set a-zA-Z0-9_ are replaced with '_'. Further, -# if $1 begins with a digit, a '_' is prepended as well. -func_tr_sh () -{ - case $1 in - [0-9]* | *[!a-zA-Z0-9_]*) - func_tr_sh_result=`$ECHO "$1" | $SED 's/^\([0-9]\)/_\1/; s/[^a-zA-Z0-9_]/_/g'` - ;; - * ) - func_tr_sh_result=$1 - ;; - esac -} + + # func_version # Echo version message to standard output and exit. func_version () { - $opt_debug - - $SED -n '/(C)/!b go - :more - /\./!{ - N - s/\n# / / - b more - } - :go - /^# '$PROGRAM' (GNU /,/# warranty; / { + $SED -n '/^# '$PROGRAM' (GNU /,/# warranty; / { s/^# // s/^# *$// s/\((C)\)[ 0-9,-]*\( [1-9][0-9]*\)/\1\2/ @@ -736,28 +509,22 @@ # Echo short help message to standard output and exit. func_usage () { - $opt_debug - - $SED -n '/^# Usage:/,/^# *.*--help/ { + $SED -n '/^# Usage:/,/# -h/ { s/^# // s/^# *$// s/\$progname/'$progname'/ p }' < "$progpath" - echo + $ECHO $ECHO "run \`$progname --help | more' for full usage" exit $? } -# func_help [NOEXIT] -# Echo long help message to standard output and exit, -# unless 'noexit' is passed as argument. +# func_help +# Echo long help message to standard output and exit. func_help () { - $opt_debug - $SED -n '/^# Usage:/,/# Report bugs to/ { - :print s/^# // s/^# *$// s*\$progname*'$progname'* @@ -767,18 +534,11 @@ s*\$LTCFLAGS*'"$LTCFLAGS"'* s*\$LD*'"$LD"'* s/\$with_gnu_ld/'"$with_gnu_ld"'/ - s/\$automake_version/'"`(${AUTOMAKE-automake} --version) 2>/dev/null |$SED 1q`"'/ - s/\$autoconf_version/'"`(${AUTOCONF-autoconf} --version) 2>/dev/null |$SED 1q`"'/ + s/\$automake_version/'"`(automake --version) 2>/dev/null |$SED 1q`"'/ + s/\$autoconf_version/'"`(autoconf --version) 2>/dev/null |$SED 1q`"'/ p - d - } - /^# .* home page:/b print - /^# General help using/b print - ' < "$progpath" - ret=$? - if test -z "$1"; then - exit $ret - fi + }' < "$progpath" + exit $? } # func_missing_arg argname @@ -786,106 +546,63 @@ # exit_cmd. func_missing_arg () { - $opt_debug - - func_error "missing argument for $1." + func_error "missing argument for $1" exit_cmd=exit } - -# func_split_short_opt shortopt -# Set func_split_short_opt_name and func_split_short_opt_arg shell -# variables after splitting SHORTOPT after the 2nd character. -func_split_short_opt () -{ - my_sed_short_opt='1s/^\(..\).*$/\1/;q' - my_sed_short_rest='1s/^..\(.*\)$/\1/;q' - - func_split_short_opt_name=`$ECHO "$1" | $SED "$my_sed_short_opt"` - func_split_short_opt_arg=`$ECHO "$1" | $SED "$my_sed_short_rest"` -} # func_split_short_opt may be replaced by extended shell implementation - - -# func_split_long_opt longopt -# Set func_split_long_opt_name and func_split_long_opt_arg shell -# variables after splitting LONGOPT at the `=' sign. -func_split_long_opt () -{ - my_sed_long_opt='1s/^\(--[^=]*\)=.*/\1/;q' - my_sed_long_arg='1s/^--[^=]*=//' - - func_split_long_opt_name=`$ECHO "$1" | $SED "$my_sed_long_opt"` - func_split_long_opt_arg=`$ECHO "$1" | $SED "$my_sed_long_arg"` -} # func_split_long_opt may be replaced by extended shell implementation - exit_cmd=: +# Check that we have a working $ECHO. +if test "X$1" = X--no-reexec; then + # Discard the --no-reexec flag, and continue. + shift +elif test "X$1" = X--fallback-echo; then + # Avoid inline document here, it may be left over + : +elif test "X`{ $ECHO '\t'; } 2>/dev/null`" = 'X\t'; then + # Yippee, $ECHO works! + : +else + # Restart under the correct shell, and then maybe $ECHO will work. + exec $SHELL "$progpath" --no-reexec ${1+"$@"} +fi + +if test "X$1" = X--fallback-echo; then + # used as fallback echo + shift + cat </dev/null || echo $max_cmd_len` -} # func_len may be replaced by extended shell implementation - - -# func_lo2o object -func_lo2o () -{ - func_lo2o_result=`$ECHO "${1}" | $SED "$lo2o"` -} # func_lo2o may be replaced by extended shell implementation - - -# func_xform libobj-or-source -func_xform () -{ - func_xform_result=`$ECHO "${1}" | $SED 's/\.[^.]*$/.lo/'` -} # func_xform may be replaced by extended shell implementation - - # func_fatal_configuration arg... # Echo program name prefixed message to standard error, followed by # a configuration failure hint, and exit. @@ -919,16 +636,16 @@ # Display the features supported by this script. func_features () { - echo "host: $host" + $ECHO "host: $host" if test "$build_libtool_libs" = yes; then - echo "enable shared libraries" + $ECHO "enable shared libraries" else - echo "disable shared libraries" + $ECHO "disable shared libraries" fi if test "$build_old_libs" = yes; then - echo "enable static libraries" + $ECHO "enable static libraries" else - echo "disable static libraries" + $ECHO "disable static libraries" fi exit $? @@ -975,6 +692,133 @@ esac } +# Parse options once, thoroughly. This comes as soon as possible in +# the script to make things like `libtool --version' happen quickly. +{ + + # Shorthand for --mode=foo, only valid as the first argument + case $1 in + clean|clea|cle|cl) + shift; set dummy --mode clean ${1+"$@"}; shift + ;; + compile|compil|compi|comp|com|co|c) + shift; set dummy --mode compile ${1+"$@"}; shift + ;; + execute|execut|execu|exec|exe|ex|e) + shift; set dummy --mode execute ${1+"$@"}; shift + ;; + finish|finis|fini|fin|fi|f) + shift; set dummy --mode finish ${1+"$@"}; shift + ;; + install|instal|insta|inst|ins|in|i) + shift; set dummy --mode install ${1+"$@"}; shift + ;; + link|lin|li|l) + shift; set dummy --mode link ${1+"$@"}; shift + ;; + uninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u) + shift; set dummy --mode uninstall ${1+"$@"}; shift + ;; + esac + + # Parse non-mode specific arguments: + while test "$#" -gt 0; do + opt="$1" + shift + + case $opt in + --config) func_config ;; + + --debug) preserve_args="$preserve_args $opt" + func_echo "enabling shell trace mode" + opt_debug='set -x' + $opt_debug + ;; + + -dlopen) test "$#" -eq 0 && func_missing_arg "$opt" && break + execute_dlfiles="$execute_dlfiles $1" + shift + ;; + + --dry-run | -n) opt_dry_run=: ;; + --features) func_features ;; + --finish) mode="finish" ;; + + --mode) test "$#" -eq 0 && func_missing_arg "$opt" && break + case $1 in + # Valid mode arguments: + clean) ;; + compile) ;; + execute) ;; + finish) ;; + install) ;; + link) ;; + relink) ;; + uninstall) ;; + + # Catch anything else as an error + *) func_error "invalid argument for $opt" + exit_cmd=exit + break + ;; + esac + + mode="$1" + shift + ;; + + --preserve-dup-deps) + opt_duplicate_deps=: ;; + + --quiet|--silent) preserve_args="$preserve_args $opt" + opt_silent=: + ;; + + --verbose| -v) preserve_args="$preserve_args $opt" + opt_silent=false + ;; + + --tag) test "$#" -eq 0 && func_missing_arg "$opt" && break + preserve_args="$preserve_args $opt $1" + func_enable_tag "$1" # tagname is set here + shift + ;; + + # Separate optargs to long options: + -dlopen=*|--mode=*|--tag=*) + func_opt_split "$opt" + set dummy "$func_opt_split_opt" "$func_opt_split_arg" ${1+"$@"} + shift + ;; + + -\?|-h) func_usage ;; + --help) opt_help=: ;; + --version) func_version ;; + + -*) func_fatal_help "unrecognized option \`$opt'" ;; + + *) nonopt="$opt" + break + ;; + esac + done + + + case $host in + *cygwin* | *mingw* | *pw32* | *cegcc*) + # don't eliminate duplications in $postdeps and $predeps + opt_duplicate_compiler_generated_deps=: + ;; + *) + opt_duplicate_compiler_generated_deps=$opt_duplicate_deps + ;; + esac + + # Having warned about all mis-specified options, bail out if + # anything was wrong. + $exit_cmd $EXIT_FAILURE +} + # func_check_version_match # Ensure that we are using m4 macros, and libtool script from the same # release of libtool. @@ -1011,219 +855,38 @@ } -# Shorthand for --mode=foo, only valid as the first argument -case $1 in -clean|clea|cle|cl) - shift; set dummy --mode clean ${1+"$@"}; shift - ;; -compile|compil|compi|comp|com|co|c) - shift; set dummy --mode compile ${1+"$@"}; shift - ;; -execute|execut|execu|exec|exe|ex|e) - shift; set dummy --mode execute ${1+"$@"}; shift - ;; -finish|finis|fini|fin|fi|f) - shift; set dummy --mode finish ${1+"$@"}; shift - ;; -install|instal|insta|inst|ins|in|i) - shift; set dummy --mode install ${1+"$@"}; shift - ;; -link|lin|li|l) - shift; set dummy --mode link ${1+"$@"}; shift - ;; -uninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u) - shift; set dummy --mode uninstall ${1+"$@"}; shift - ;; -esac - - - -# Option defaults: -opt_debug=: -opt_dry_run=false -opt_config=false -opt_preserve_dup_deps=false -opt_features=false -opt_finish=false -opt_help=false -opt_help_all=false -opt_silent=: -opt_warning=: -opt_verbose=: -opt_silent=false -opt_verbose=false - - -# Parse options once, thoroughly. This comes as soon as possible in the -# script to make things like `--version' happen as quickly as we can. -{ - # this just eases exit handling - while test $# -gt 0; do - opt="$1" - shift - case $opt in - --debug|-x) opt_debug='set -x' - func_echo "enabling shell trace mode" - $opt_debug - ;; - --dry-run|--dryrun|-n) - opt_dry_run=: - ;; - --config) - opt_config=: -func_config - ;; - --dlopen|-dlopen) - optarg="$1" - opt_dlopen="${opt_dlopen+$opt_dlopen -}$optarg" - shift - ;; - --preserve-dup-deps) - opt_preserve_dup_deps=: - ;; - --features) - opt_features=: -func_features - ;; - --finish) - opt_finish=: -set dummy --mode finish ${1+"$@"}; shift - ;; - --help) - opt_help=: - ;; - --help-all) - opt_help_all=: -opt_help=': help-all' - ;; - --mode) - test $# = 0 && func_missing_arg $opt && break - optarg="$1" - opt_mode="$optarg" -case $optarg in - # Valid mode arguments: - clean|compile|execute|finish|install|link|relink|uninstall) ;; - - # Catch anything else as an error - *) func_error "invalid argument for $opt" - exit_cmd=exit - break - ;; -esac - shift - ;; - --no-silent|--no-quiet) - opt_silent=false -func_append preserve_args " $opt" - ;; - --no-warning|--no-warn) - opt_warning=false -func_append preserve_args " $opt" - ;; - --no-verbose) - opt_verbose=false -func_append preserve_args " $opt" - ;; - --silent|--quiet) - opt_silent=: -func_append preserve_args " $opt" - opt_verbose=false - ;; - --verbose|-v) - opt_verbose=: -func_append preserve_args " $opt" -opt_silent=false - ;; - --tag) - test $# = 0 && func_missing_arg $opt && break - optarg="$1" - opt_tag="$optarg" -func_append preserve_args " $opt $optarg" -func_enable_tag "$optarg" - shift - ;; - - -\?|-h) func_usage ;; - --help) func_help ;; - --version) func_version ;; - - # Separate optargs to long options: - --*=*) - func_split_long_opt "$opt" - set dummy "$func_split_long_opt_name" "$func_split_long_opt_arg" ${1+"$@"} - shift - ;; - - # Separate non-argument short options: - -\?*|-h*|-n*|-v*) - func_split_short_opt "$opt" - set dummy "$func_split_short_opt_name" "-$func_split_short_opt_arg" ${1+"$@"} - shift - ;; - - --) break ;; - -*) func_fatal_help "unrecognized option \`$opt'" ;; - *) set dummy "$opt" ${1+"$@"}; shift; break ;; - esac - done - - # Validate options: - - # save first non-option argument - if test "$#" -gt 0; then - nonopt="$opt" - shift - fi - - # preserve --debug - test "$opt_debug" = : || func_append preserve_args " --debug" - - case $host in - *cygwin* | *mingw* | *pw32* | *cegcc*) - # don't eliminate duplications in $postdeps and $predeps - opt_duplicate_compiler_generated_deps=: - ;; - *) - opt_duplicate_compiler_generated_deps=$opt_preserve_dup_deps - ;; - esac - - $opt_help || { - # Sanity checks first: - func_check_version_match - - if test "$build_libtool_libs" != yes && test "$build_old_libs" != yes; then - func_fatal_configuration "not configured to build any kind of library" - fi - - # Darwin sucks - eval std_shrext=\"$shrext_cmds\" - - # Only execute mode is allowed to have -dlopen flags. - if test -n "$opt_dlopen" && test "$opt_mode" != execute; then - func_error "unrecognized option \`-dlopen'" - $ECHO "$help" 1>&2 - exit $EXIT_FAILURE - fi - - # Change the help message to a mode-specific one. - generic_help="$help" - help="Try \`$progname --help --mode=$opt_mode' for more information." - } - - - # Bail if the options were screwed - $exit_cmd $EXIT_FAILURE -} - - - - ## ----------- ## ## Main. ## ## ----------- ## +$opt_help || { + # Sanity checks first: + func_check_version_match + + if test "$build_libtool_libs" != yes && test "$build_old_libs" != yes; then + func_fatal_configuration "not configured to build any kind of library" + fi + + test -z "$mode" && func_fatal_error "error: you must specify a MODE." + + + # Darwin sucks + eval std_shrext=\"$shrext_cmds\" + + + # Only execute mode is allowed to have -dlopen flags. + if test -n "$execute_dlfiles" && test "$mode" != execute; then + func_error "unrecognized option \`-dlopen'" + $ECHO "$help" 1>&2 + exit $EXIT_FAILURE + fi + + # Change the help message to a mode-specific one. + generic_help="$help" + help="Try \`$progname --help --mode=$mode' for more information." +} + + # func_lalib_p file # True iff FILE is a libtool `.la' library or `.lo' object file. # This function is only a basic sanity check; it will hardly flush out @@ -1287,9 +950,12 @@ # temporary ltwrapper_script. func_ltwrapper_scriptname () { - func_dirname_and_basename "$1" "" "." - func_stripname '' '.exe' "$func_basename_result" - func_ltwrapper_scriptname_result="$func_dirname_result/$objdir/${func_stripname_result}_ltshwrapper" + func_ltwrapper_scriptname_result="" + if func_ltwrapper_executable_p "$1"; then + func_dirname_and_basename "$1" "" "." + func_stripname '' '.exe' "$func_basename_result" + func_ltwrapper_scriptname_result="$func_dirname_result/$objdir/${func_stripname_result}_ltshwrapper" + fi } # func_ltwrapper_p file @@ -1335,37 +1001,6 @@ } -# func_resolve_sysroot PATH -# Replace a leading = in PATH with a sysroot. Store the result into -# func_resolve_sysroot_result -func_resolve_sysroot () -{ - func_resolve_sysroot_result=$1 - case $func_resolve_sysroot_result in - =*) - func_stripname '=' '' "$func_resolve_sysroot_result" - func_resolve_sysroot_result=$lt_sysroot$func_stripname_result - ;; - esac -} - -# func_replace_sysroot PATH -# If PATH begins with the sysroot, replace it with = and -# store the result into func_replace_sysroot_result. -func_replace_sysroot () -{ - case "$lt_sysroot:$1" in - ?*:"$lt_sysroot"*) - func_stripname "$lt_sysroot" '' "$1" - func_replace_sysroot_result="=$func_stripname_result" - ;; - *) - # Including no sysroot. - func_replace_sysroot_result=$1 - ;; - esac -} - # func_infer_tag arg # Infer tagged configuration to use if any are available and # if one wasn't chosen via the "--tag" command line option. @@ -1378,15 +1013,13 @@ if test -n "$available_tags" && test -z "$tagname"; then CC_quoted= for arg in $CC; do - func_append_quoted CC_quoted "$arg" + func_quote_for_eval "$arg" + CC_quoted="$CC_quoted $func_quote_for_eval_result" done - CC_expanded=`func_echo_all $CC` - CC_quoted_expanded=`func_echo_all $CC_quoted` case $@ in # Blanks in the command may have been stripped by the calling shell, # but not from the CC environment variable when configure was run. - " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \ - " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) ;; + " $CC "* | "$CC "* | " `$ECHO $CC` "* | "`$ECHO $CC` "* | " $CC_quoted"* | "$CC_quoted "* | " `$ECHO $CC_quoted` "* | "`$ECHO $CC_quoted` "*) ;; # Blanks at the start of $base_compile will cause this to fail # if we don't check for them as well. *) @@ -1397,13 +1030,11 @@ CC_quoted= for arg in $CC; do # Double-quote args containing other shell metacharacters. - func_append_quoted CC_quoted "$arg" + func_quote_for_eval "$arg" + CC_quoted="$CC_quoted $func_quote_for_eval_result" done - CC_expanded=`func_echo_all $CC` - CC_quoted_expanded=`func_echo_all $CC_quoted` case "$@ " in - " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \ - " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) + " $CC "* | "$CC "* | " `$ECHO $CC` "* | "`$ECHO $CC` "* | " $CC_quoted"* | "$CC_quoted "* | " `$ECHO $CC_quoted` "* | "`$ECHO $CC_quoted` "*) # The compiler in the base compile command matches # the one in the tagged configuration. # Assume this is the tagged configuration we want. @@ -1466,486 +1097,6 @@ } } - -################################################## -# FILE NAME AND PATH CONVERSION HELPER FUNCTIONS # -################################################## - -# func_convert_core_file_wine_to_w32 ARG -# Helper function used by file name conversion functions when $build is *nix, -# and $host is mingw, cygwin, or some other w32 environment. Relies on a -# correctly configured wine environment available, with the winepath program -# in $build's $PATH. -# -# ARG is the $build file name to be converted to w32 format. -# Result is available in $func_convert_core_file_wine_to_w32_result, and will -# be empty on error (or when ARG is empty) -func_convert_core_file_wine_to_w32 () -{ - $opt_debug - func_convert_core_file_wine_to_w32_result="$1" - if test -n "$1"; then - # Unfortunately, winepath does not exit with a non-zero error code, so we - # are forced to check the contents of stdout. On the other hand, if the - # command is not found, the shell will set an exit code of 127 and print - # *an error message* to stdout. So we must check for both error code of - # zero AND non-empty stdout, which explains the odd construction: - func_convert_core_file_wine_to_w32_tmp=`winepath -w "$1" 2>/dev/null` - if test "$?" -eq 0 && test -n "${func_convert_core_file_wine_to_w32_tmp}"; then - func_convert_core_file_wine_to_w32_result=`$ECHO "$func_convert_core_file_wine_to_w32_tmp" | - $SED -e "$lt_sed_naive_backslashify"` - else - func_convert_core_file_wine_to_w32_result= - fi - fi -} -# end: func_convert_core_file_wine_to_w32 - - -# func_convert_core_path_wine_to_w32 ARG -# Helper function used by path conversion functions when $build is *nix, and -# $host is mingw, cygwin, or some other w32 environment. Relies on a correctly -# configured wine environment available, with the winepath program in $build's -# $PATH. Assumes ARG has no leading or trailing path separator characters. -# -# ARG is path to be converted from $build format to win32. -# Result is available in $func_convert_core_path_wine_to_w32_result. -# Unconvertible file (directory) names in ARG are skipped; if no directory names -# are convertible, then the result may be empty. -func_convert_core_path_wine_to_w32 () -{ - $opt_debug - # unfortunately, winepath doesn't convert paths, only file names - func_convert_core_path_wine_to_w32_result="" - if test -n "$1"; then - oldIFS=$IFS - IFS=: - for func_convert_core_path_wine_to_w32_f in $1; do - IFS=$oldIFS - func_convert_core_file_wine_to_w32 "$func_convert_core_path_wine_to_w32_f" - if test -n "$func_convert_core_file_wine_to_w32_result" ; then - if test -z "$func_convert_core_path_wine_to_w32_result"; then - func_convert_core_path_wine_to_w32_result="$func_convert_core_file_wine_to_w32_result" - else - func_append func_convert_core_path_wine_to_w32_result ";$func_convert_core_file_wine_to_w32_result" - fi - fi - done - IFS=$oldIFS - fi -} -# end: func_convert_core_path_wine_to_w32 - - -# func_cygpath ARGS... -# Wrapper around calling the cygpath program via LT_CYGPATH. This is used when -# when (1) $build is *nix and Cygwin is hosted via a wine environment; or (2) -# $build is MSYS and $host is Cygwin, or (3) $build is Cygwin. In case (1) or -# (2), returns the Cygwin file name or path in func_cygpath_result (input -# file name or path is assumed to be in w32 format, as previously converted -# from $build's *nix or MSYS format). In case (3), returns the w32 file name -# or path in func_cygpath_result (input file name or path is assumed to be in -# Cygwin format). Returns an empty string on error. -# -# ARGS are passed to cygpath, with the last one being the file name or path to -# be converted. -# -# Specify the absolute *nix (or w32) name to cygpath in the LT_CYGPATH -# environment variable; do not put it in $PATH. -func_cygpath () -{ - $opt_debug - if test -n "$LT_CYGPATH" && test -f "$LT_CYGPATH"; then - func_cygpath_result=`$LT_CYGPATH "$@" 2>/dev/null` - if test "$?" -ne 0; then - # on failure, ensure result is empty - func_cygpath_result= - fi - else - func_cygpath_result= - func_error "LT_CYGPATH is empty or specifies non-existent file: \`$LT_CYGPATH'" - fi -} -#end: func_cygpath - - -# func_convert_core_msys_to_w32 ARG -# Convert file name or path ARG from MSYS format to w32 format. Return -# result in func_convert_core_msys_to_w32_result. -func_convert_core_msys_to_w32 () -{ - $opt_debug - # awkward: cmd appends spaces to result - func_convert_core_msys_to_w32_result=`( cmd //c echo "$1" ) 2>/dev/null | - $SED -e 's/[ ]*$//' -e "$lt_sed_naive_backslashify"` -} -#end: func_convert_core_msys_to_w32 - - -# func_convert_file_check ARG1 ARG2 -# Verify that ARG1 (a file name in $build format) was converted to $host -# format in ARG2. Otherwise, emit an error message, but continue (resetting -# func_to_host_file_result to ARG1). -func_convert_file_check () -{ - $opt_debug - if test -z "$2" && test -n "$1" ; then - func_error "Could not determine host file name corresponding to" - func_error " \`$1'" - func_error "Continuing, but uninstalled executables may not work." - # Fallback: - func_to_host_file_result="$1" - fi -} -# end func_convert_file_check - - -# func_convert_path_check FROM_PATHSEP TO_PATHSEP FROM_PATH TO_PATH -# Verify that FROM_PATH (a path in $build format) was converted to $host -# format in TO_PATH. Otherwise, emit an error message, but continue, resetting -# func_to_host_file_result to a simplistic fallback value (see below). -func_convert_path_check () -{ - $opt_debug - if test -z "$4" && test -n "$3"; then - func_error "Could not determine the host path corresponding to" - func_error " \`$3'" - func_error "Continuing, but uninstalled executables may not work." - # Fallback. This is a deliberately simplistic "conversion" and - # should not be "improved". See libtool.info. - if test "x$1" != "x$2"; then - lt_replace_pathsep_chars="s|$1|$2|g" - func_to_host_path_result=`echo "$3" | - $SED -e "$lt_replace_pathsep_chars"` - else - func_to_host_path_result="$3" - fi - fi -} -# end func_convert_path_check - - -# func_convert_path_front_back_pathsep FRONTPAT BACKPAT REPL ORIG -# Modifies func_to_host_path_result by prepending REPL if ORIG matches FRONTPAT -# and appending REPL if ORIG matches BACKPAT. -func_convert_path_front_back_pathsep () -{ - $opt_debug - case $4 in - $1 ) func_to_host_path_result="$3$func_to_host_path_result" - ;; - esac - case $4 in - $2 ) func_append func_to_host_path_result "$3" - ;; - esac -} -# end func_convert_path_front_back_pathsep - - -################################################## -# $build to $host FILE NAME CONVERSION FUNCTIONS # -################################################## -# invoked via `$to_host_file_cmd ARG' -# -# In each case, ARG is the path to be converted from $build to $host format. -# Result will be available in $func_to_host_file_result. - - -# func_to_host_file ARG -# Converts the file name ARG from $build format to $host format. Return result -# in func_to_host_file_result. -func_to_host_file () -{ - $opt_debug - $to_host_file_cmd "$1" -} -# end func_to_host_file - - -# func_to_tool_file ARG LAZY -# converts the file name ARG from $build format to toolchain format. Return -# result in func_to_tool_file_result. If the conversion in use is listed -# in (the comma separated) LAZY, no conversion takes place. -func_to_tool_file () -{ - $opt_debug - case ,$2, in - *,"$to_tool_file_cmd",*) - func_to_tool_file_result=$1 - ;; - *) - $to_tool_file_cmd "$1" - func_to_tool_file_result=$func_to_host_file_result - ;; - esac -} -# end func_to_tool_file - - -# func_convert_file_noop ARG -# Copy ARG to func_to_host_file_result. -func_convert_file_noop () -{ - func_to_host_file_result="$1" -} -# end func_convert_file_noop - - -# func_convert_file_msys_to_w32 ARG -# Convert file name ARG from (mingw) MSYS to (mingw) w32 format; automatic -# conversion to w32 is not available inside the cwrapper. Returns result in -# func_to_host_file_result. -func_convert_file_msys_to_w32 () -{ - $opt_debug - func_to_host_file_result="$1" - if test -n "$1"; then - func_convert_core_msys_to_w32 "$1" - func_to_host_file_result="$func_convert_core_msys_to_w32_result" - fi - func_convert_file_check "$1" "$func_to_host_file_result" -} -# end func_convert_file_msys_to_w32 - - -# func_convert_file_cygwin_to_w32 ARG -# Convert file name ARG from Cygwin to w32 format. Returns result in -# func_to_host_file_result. -func_convert_file_cygwin_to_w32 () -{ - $opt_debug - func_to_host_file_result="$1" - if test -n "$1"; then - # because $build is cygwin, we call "the" cygpath in $PATH; no need to use - # LT_CYGPATH in this case. - func_to_host_file_result=`cygpath -m "$1"` - fi - func_convert_file_check "$1" "$func_to_host_file_result" -} -# end func_convert_file_cygwin_to_w32 - - -# func_convert_file_nix_to_w32 ARG -# Convert file name ARG from *nix to w32 format. Requires a wine environment -# and a working winepath. Returns result in func_to_host_file_result. -func_convert_file_nix_to_w32 () -{ - $opt_debug - func_to_host_file_result="$1" - if test -n "$1"; then - func_convert_core_file_wine_to_w32 "$1" - func_to_host_file_result="$func_convert_core_file_wine_to_w32_result" - fi - func_convert_file_check "$1" "$func_to_host_file_result" -} -# end func_convert_file_nix_to_w32 - - -# func_convert_file_msys_to_cygwin ARG -# Convert file name ARG from MSYS to Cygwin format. Requires LT_CYGPATH set. -# Returns result in func_to_host_file_result. -func_convert_file_msys_to_cygwin () -{ - $opt_debug - func_to_host_file_result="$1" - if test -n "$1"; then - func_convert_core_msys_to_w32 "$1" - func_cygpath -u "$func_convert_core_msys_to_w32_result" - func_to_host_file_result="$func_cygpath_result" - fi - func_convert_file_check "$1" "$func_to_host_file_result" -} -# end func_convert_file_msys_to_cygwin - - -# func_convert_file_nix_to_cygwin ARG -# Convert file name ARG from *nix to Cygwin format. Requires Cygwin installed -# in a wine environment, working winepath, and LT_CYGPATH set. Returns result -# in func_to_host_file_result. -func_convert_file_nix_to_cygwin () -{ - $opt_debug - func_to_host_file_result="$1" - if test -n "$1"; then - # convert from *nix to w32, then use cygpath to convert from w32 to cygwin. - func_convert_core_file_wine_to_w32 "$1" - func_cygpath -u "$func_convert_core_file_wine_to_w32_result" - func_to_host_file_result="$func_cygpath_result" - fi - func_convert_file_check "$1" "$func_to_host_file_result" -} -# end func_convert_file_nix_to_cygwin - - -############################################# -# $build to $host PATH CONVERSION FUNCTIONS # -############################################# -# invoked via `$to_host_path_cmd ARG' -# -# In each case, ARG is the path to be converted from $build to $host format. -# The result will be available in $func_to_host_path_result. -# -# Path separators are also converted from $build format to $host format. If -# ARG begins or ends with a path separator character, it is preserved (but -# converted to $host format) on output. -# -# All path conversion functions are named using the following convention: -# file name conversion function : func_convert_file_X_to_Y () -# path conversion function : func_convert_path_X_to_Y () -# where, for any given $build/$host combination the 'X_to_Y' value is the -# same. If conversion functions are added for new $build/$host combinations, -# the two new functions must follow this pattern, or func_init_to_host_path_cmd -# will break. - - -# func_init_to_host_path_cmd -# Ensures that function "pointer" variable $to_host_path_cmd is set to the -# appropriate value, based on the value of $to_host_file_cmd. -to_host_path_cmd= -func_init_to_host_path_cmd () -{ - $opt_debug - if test -z "$to_host_path_cmd"; then - func_stripname 'func_convert_file_' '' "$to_host_file_cmd" - to_host_path_cmd="func_convert_path_${func_stripname_result}" - fi -} - - -# func_to_host_path ARG -# Converts the path ARG from $build format to $host format. Return result -# in func_to_host_path_result. -func_to_host_path () -{ - $opt_debug - func_init_to_host_path_cmd - $to_host_path_cmd "$1" -} -# end func_to_host_path - - -# func_convert_path_noop ARG -# Copy ARG to func_to_host_path_result. -func_convert_path_noop () -{ - func_to_host_path_result="$1" -} -# end func_convert_path_noop - - -# func_convert_path_msys_to_w32 ARG -# Convert path ARG from (mingw) MSYS to (mingw) w32 format; automatic -# conversion to w32 is not available inside the cwrapper. Returns result in -# func_to_host_path_result. -func_convert_path_msys_to_w32 () -{ - $opt_debug - func_to_host_path_result="$1" - if test -n "$1"; then - # Remove leading and trailing path separator characters from ARG. MSYS - # behavior is inconsistent here; cygpath turns them into '.;' and ';.'; - # and winepath ignores them completely. - func_stripname : : "$1" - func_to_host_path_tmp1=$func_stripname_result - func_convert_core_msys_to_w32 "$func_to_host_path_tmp1" - func_to_host_path_result="$func_convert_core_msys_to_w32_result" - func_convert_path_check : ";" \ - "$func_to_host_path_tmp1" "$func_to_host_path_result" - func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" - fi -} -# end func_convert_path_msys_to_w32 - - -# func_convert_path_cygwin_to_w32 ARG -# Convert path ARG from Cygwin to w32 format. Returns result in -# func_to_host_file_result. -func_convert_path_cygwin_to_w32 () -{ - $opt_debug - func_to_host_path_result="$1" - if test -n "$1"; then - # See func_convert_path_msys_to_w32: - func_stripname : : "$1" - func_to_host_path_tmp1=$func_stripname_result - func_to_host_path_result=`cygpath -m -p "$func_to_host_path_tmp1"` - func_convert_path_check : ";" \ - "$func_to_host_path_tmp1" "$func_to_host_path_result" - func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" - fi -} -# end func_convert_path_cygwin_to_w32 - - -# func_convert_path_nix_to_w32 ARG -# Convert path ARG from *nix to w32 format. Requires a wine environment and -# a working winepath. Returns result in func_to_host_file_result. -func_convert_path_nix_to_w32 () -{ - $opt_debug - func_to_host_path_result="$1" - if test -n "$1"; then - # See func_convert_path_msys_to_w32: - func_stripname : : "$1" - func_to_host_path_tmp1=$func_stripname_result - func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1" - func_to_host_path_result="$func_convert_core_path_wine_to_w32_result" - func_convert_path_check : ";" \ - "$func_to_host_path_tmp1" "$func_to_host_path_result" - func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" - fi -} -# end func_convert_path_nix_to_w32 - - -# func_convert_path_msys_to_cygwin ARG -# Convert path ARG from MSYS to Cygwin format. Requires LT_CYGPATH set. -# Returns result in func_to_host_file_result. -func_convert_path_msys_to_cygwin () -{ - $opt_debug - func_to_host_path_result="$1" - if test -n "$1"; then - # See func_convert_path_msys_to_w32: - func_stripname : : "$1" - func_to_host_path_tmp1=$func_stripname_result - func_convert_core_msys_to_w32 "$func_to_host_path_tmp1" - func_cygpath -u -p "$func_convert_core_msys_to_w32_result" - func_to_host_path_result="$func_cygpath_result" - func_convert_path_check : : \ - "$func_to_host_path_tmp1" "$func_to_host_path_result" - func_convert_path_front_back_pathsep ":*" "*:" : "$1" - fi -} -# end func_convert_path_msys_to_cygwin - - -# func_convert_path_nix_to_cygwin ARG -# Convert path ARG from *nix to Cygwin format. Requires Cygwin installed in a -# a wine environment, working winepath, and LT_CYGPATH set. Returns result in -# func_to_host_file_result. -func_convert_path_nix_to_cygwin () -{ - $opt_debug - func_to_host_path_result="$1" - if test -n "$1"; then - # Remove leading and trailing path separator characters from - # ARG. msys behavior is inconsistent here, cygpath turns them - # into '.;' and ';.', and winepath ignores them completely. - func_stripname : : "$1" - func_to_host_path_tmp1=$func_stripname_result - func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1" - func_cygpath -u -p "$func_convert_core_path_wine_to_w32_result" - func_to_host_path_result="$func_cygpath_result" - func_convert_path_check : : \ - "$func_to_host_path_tmp1" "$func_to_host_path_result" - func_convert_path_front_back_pathsep ":*" "*:" : "$1" - fi -} -# end func_convert_path_nix_to_cygwin - - # func_mode_compile arg... func_mode_compile () { @@ -1986,12 +1137,12 @@ ;; -pie | -fpie | -fPIE) - func_append pie_flag " $arg" + pie_flag="$pie_flag $arg" continue ;; -shared | -static | -prefer-pic | -prefer-non-pic) - func_append later " $arg" + later="$later $arg" continue ;; @@ -2012,14 +1163,15 @@ save_ifs="$IFS"; IFS=',' for arg in $args; do IFS="$save_ifs" - func_append_quoted lastarg "$arg" + func_quote_for_eval "$arg" + lastarg="$lastarg $func_quote_for_eval_result" done IFS="$save_ifs" func_stripname ' ' '' "$lastarg" lastarg=$func_stripname_result # Add the arguments to base_compile. - func_append base_compile " $lastarg" + base_compile="$base_compile $lastarg" continue ;; @@ -2035,7 +1187,8 @@ esac # case $arg_mode # Aesthetically quote the previous argument. - func_append_quoted base_compile "$lastarg" + func_quote_for_eval "$lastarg" + base_compile="$base_compile $func_quote_for_eval_result" done # for arg case $arg_mode in @@ -2060,7 +1213,7 @@ *.[cCFSifmso] | \ *.ada | *.adb | *.ads | *.asm | \ *.c++ | *.cc | *.ii | *.class | *.cpp | *.cxx | \ - *.[fF][09]? | *.for | *.java | *.go | *.obj | *.sx | *.cu | *.cup) + *.[fF][09]? | *.for | *.java | *.obj | *.sx) func_xform "$libobj" libobj=$func_xform_result ;; @@ -2135,7 +1288,7 @@ # Calculate the filename of the output object if compiler does # not support -o with -c if test "$compiler_c_o" = no; then - output_obj=`$ECHO "$srcfile" | $SED 's%^.*/%%; s%\.[^.]*$%%'`.${objext} + output_obj=`$ECHO "X$srcfile" | $Xsed -e 's%^.*/%%' -e 's%\.[^.]*$%%'`.${objext} lockfile="$output_obj.lock" else output_obj= @@ -2166,16 +1319,17 @@ $opt_dry_run || $RM $removelist exit $EXIT_FAILURE fi - func_append removelist " $output_obj" + removelist="$removelist $output_obj" $ECHO "$srcfile" > "$lockfile" fi $opt_dry_run || $RM $removelist - func_append removelist " $lockfile" + removelist="$removelist $lockfile" trap '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 1 2 15 - func_to_tool_file "$srcfile" func_convert_file_msys_to_w32 - srcfile=$func_to_tool_file_result + if test -n "$fix_srcfile_path"; then + eval srcfile=\"$fix_srcfile_path\" + fi func_quote_for_eval "$srcfile" qsrcfile=$func_quote_for_eval_result @@ -2195,7 +1349,7 @@ if test -z "$output_obj"; then # Place PIC objects in $objdir - func_append command " -o $lobj" + command="$command -o $lobj" fi func_show_eval_locale "$command" \ @@ -2242,11 +1396,11 @@ command="$base_compile $qsrcfile $pic_flag" fi if test "$compiler_c_o" = yes; then - func_append command " -o $obj" + command="$command -o $obj" fi # Suppress compiler output if we already did a PIC compilation. - func_append command "$suppress_output" + command="$command$suppress_output" func_show_eval_locale "$command" \ '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' @@ -2291,13 +1445,13 @@ } $opt_help || { - test "$opt_mode" = compile && func_mode_compile ${1+"$@"} +test "$mode" = compile && func_mode_compile ${1+"$@"} } func_mode_help () { # We need to display help for each of the modes. - case $opt_mode in + case $mode in "") # Generic help is extracted from the usage comments # at the start of this file. @@ -2328,11 +1482,10 @@ -o OUTPUT-FILE set the output file name to OUTPUT-FILE -no-suppress do not suppress compiler output for multiple passes - -prefer-pic try to build PIC objects only - -prefer-non-pic try to build non-PIC objects only + -prefer-pic try to building PIC objects only + -prefer-non-pic try to building non-PIC objects only -shared do not build a \`.o' file suitable for static linking -static only build a \`.o' file suitable for static linking - -Wc,FLAG pass FLAG directly to the compiler COMPILE-COMMAND is a command to be used in creating a \`standard' object file from the given SOURCEFILE. @@ -2385,7 +1538,7 @@ The following components of INSTALL-COMMAND are treated specially: - -inst-prefix-dir PREFIX-DIR Use PREFIX-DIR as a staging area for installation + -inst-prefix PREFIX-DIR Use PREFIX-DIR as a staging area for installation The rest of the components are interpreted as arguments to that command (only BSD-compatible install options are recognized)." @@ -2405,8 +1558,6 @@ -all-static do not do any dynamic linking at all -avoid-version do not add a version suffix if possible - -bindir BINDIR specify path to binaries directory (for systems where - libraries must be found in the PATH setting at runtime) -dlopen FILE \`-dlpreopen' FILE if it cannot be dlopened at runtime -dlpreopen FILE link in FILE and add its symbols to lt_preloaded_symbols -export-dynamic allow symbols from OUTPUT-FILE to be resolved with dlsym(3) @@ -2435,11 +1586,6 @@ -version-info CURRENT[:REVISION[:AGE]] specify library version info [each variable defaults to 0] -weak LIBNAME declare that the target provides the LIBNAME interface - -Wc,FLAG - -Xcompiler FLAG pass linker-specific FLAG directly to the compiler - -Wl,FLAG - -Xlinker FLAG pass linker-specific FLAG directly to the linker - -XCClinker FLAG pass link-specific FLAG to the compiler driver (CC) All other options (arguments beginning with \`-') are ignored. @@ -2473,44 +1619,18 @@ ;; *) - func_fatal_help "invalid operation mode \`$opt_mode'" + func_fatal_help "invalid operation mode \`$mode'" ;; esac - echo + $ECHO $ECHO "Try \`$progname --help' for more information about other modes." + + exit $? } -# Now that we've collected a possible --mode arg, show help if necessary -if $opt_help; then - if test "$opt_help" = :; then - func_mode_help - else - { - func_help noexit - for opt_mode in compile link execute install finish uninstall clean; do - func_mode_help - done - } | sed -n '1p; 2,$s/^Usage:/ or: /p' - { - func_help noexit - for opt_mode in compile link execute install finish uninstall clean; do - echo - func_mode_help - done - } | - sed '1d - /^When reporting/,/^Report/{ - H - d - } - $x - /information about other modes/d - /more detailed .*MODE/d - s/^Usage:.*--mode=\([^ ]*\) .*/Description of \1 mode:/' - fi - exit $? -fi + # Now that we've collected a possible --mode arg, show help if necessary + $opt_help && func_mode_help # func_mode_execute arg... @@ -2523,16 +1643,13 @@ func_fatal_help "you must specify a COMMAND" # Handle -dlopen flags immediately. - for file in $opt_dlopen; do + for file in $execute_dlfiles; do test -f "$file" \ || func_fatal_help "\`$file' is not a file" dir= case $file in *.la) - func_resolve_sysroot "$file" - file=$func_resolve_sysroot_result - # Check to see that this really is a libtool archive. func_lalib_unsafe_p "$file" \ || func_fatal_help "\`$lib' is not a valid libtool archive" @@ -2554,7 +1671,7 @@ dir="$func_dirname_result" if test -f "$dir/$objdir/$dlname"; then - func_append dir "/$objdir" + dir="$dir/$objdir" else if test ! -f "$dir/$dlname"; then func_fatal_error "cannot find \`$dlname' in \`$dir' or \`$dir/$objdir'" @@ -2595,7 +1712,7 @@ for file do case $file in - -* | *.la | *.lo ) ;; + -*) ;; *) # Do a test to see if this is really a libtool program. if func_ltwrapper_script_p "$file"; then @@ -2611,7 +1728,8 @@ ;; esac # Quote arguments (to preserve shell metacharacters). - func_append_quoted args "$file" + func_quote_for_eval "$file" + args="$args $func_quote_for_eval_result" done if test "X$opt_dry_run" = Xfalse; then @@ -2636,66 +1754,29 @@ # Display what would be done. if test -n "$shlibpath_var"; then eval "\$ECHO \"\$shlibpath_var=\$$shlibpath_var\"" - echo "export $shlibpath_var" + $ECHO "export $shlibpath_var" fi $ECHO "$cmd$args" exit $EXIT_SUCCESS fi } -test "$opt_mode" = execute && func_mode_execute ${1+"$@"} +test "$mode" = execute && func_mode_execute ${1+"$@"} # func_mode_finish arg... func_mode_finish () { $opt_debug - libs= - libdirs= + libdirs="$nonopt" admincmds= - for opt in "$nonopt" ${1+"$@"} - do - if test -d "$opt"; then - func_append libdirs " $opt" - - elif test -f "$opt"; then - if func_lalib_unsafe_p "$opt"; then - func_append libs " $opt" - else - func_warning "\`$opt' is not a valid libtool archive" - fi - - else - func_fatal_error "invalid argument \`$opt'" - fi - done - - if test -n "$libs"; then - if test -n "$lt_sysroot"; then - sysroot_regex=`$ECHO "$lt_sysroot" | $SED "$sed_make_literal_regex"` - sysroot_cmd="s/\([ ']\)$sysroot_regex/\1/g;" - else - sysroot_cmd= - fi - - # Remove sysroot references - if $opt_dry_run; then - for lib in $libs; do - echo "removing references to $lt_sysroot and \`=' prefixes from $lib" - done - else - tmpdir=`func_mktempdir` - for lib in $libs; do - sed -e "${sysroot_cmd} s/\([ ']-[LR]\)=/\1/g; s/\([ ']\)=/\1/g" $lib \ - > $tmpdir/tmp-la - mv -f $tmpdir/tmp-la $lib - done - ${RM}r "$tmpdir" - fi - fi - if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then + for dir + do + libdirs="$libdirs $dir" + done + for libdir in $libdirs; do if test -n "$finish_cmds"; then # Do each command in the finish commands. @@ -2705,7 +1786,7 @@ if test -n "$finish_eval"; then # Do the single finish_eval. eval cmds=\"$finish_eval\" - $opt_dry_run || eval "$cmds" || func_append admincmds " + $opt_dry_run || eval "$cmds" || admincmds="$admincmds $cmds" fi done @@ -2714,55 +1795,53 @@ # Exit here if they wanted silent mode. $opt_silent && exit $EXIT_SUCCESS - if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then - echo "----------------------------------------------------------------------" - echo "Libraries have been installed in:" - for libdir in $libdirs; do - $ECHO " $libdir" - done - echo - echo "If you ever happen to want to link against installed libraries" - echo "in a given directory, LIBDIR, you must either use libtool, and" - echo "specify the full pathname of the library, or use the \`-LLIBDIR'" - echo "flag during linking and do at least one of the following:" - if test -n "$shlibpath_var"; then - echo " - add LIBDIR to the \`$shlibpath_var' environment variable" - echo " during execution" - fi - if test -n "$runpath_var"; then - echo " - add LIBDIR to the \`$runpath_var' environment variable" - echo " during linking" - fi - if test -n "$hardcode_libdir_flag_spec"; then - libdir=LIBDIR - eval flag=\"$hardcode_libdir_flag_spec\" - - $ECHO " - use the \`$flag' linker flag" - fi - if test -n "$admincmds"; then - $ECHO " - have your system administrator run these commands:$admincmds" - fi - if test -f /etc/ld.so.conf; then - echo " - have your system administrator add LIBDIR to \`/etc/ld.so.conf'" - fi - echo - - echo "See any operating system documentation about shared libraries for" - case $host in - solaris2.[6789]|solaris2.1[0-9]) - echo "more information, such as the ld(1), crle(1) and ld.so(8) manual" - echo "pages." - ;; - *) - echo "more information, such as the ld(1) and ld.so(8) manual pages." - ;; - esac - echo "----------------------------------------------------------------------" + $ECHO "X----------------------------------------------------------------------" | $Xsed + $ECHO "Libraries have been installed in:" + for libdir in $libdirs; do + $ECHO " $libdir" + done + $ECHO + $ECHO "If you ever happen to want to link against installed libraries" + $ECHO "in a given directory, LIBDIR, you must either use libtool, and" + $ECHO "specify the full pathname of the library, or use the \`-LLIBDIR'" + $ECHO "flag during linking and do at least one of the following:" + if test -n "$shlibpath_var"; then + $ECHO " - add LIBDIR to the \`$shlibpath_var' environment variable" + $ECHO " during execution" fi + if test -n "$runpath_var"; then + $ECHO " - add LIBDIR to the \`$runpath_var' environment variable" + $ECHO " during linking" + fi + if test -n "$hardcode_libdir_flag_spec"; then + libdir=LIBDIR + eval flag=\"$hardcode_libdir_flag_spec\" + + $ECHO " - use the \`$flag' linker flag" + fi + if test -n "$admincmds"; then + $ECHO " - have your system administrator run these commands:$admincmds" + fi + if test -f /etc/ld.so.conf; then + $ECHO " - have your system administrator add LIBDIR to \`/etc/ld.so.conf'" + fi + $ECHO + + $ECHO "See any operating system documentation about shared libraries for" + case $host in + solaris2.[6789]|solaris2.1[0-9]) + $ECHO "more information, such as the ld(1), crle(1) and ld.so(8) manual" + $ECHO "pages." + ;; + *) + $ECHO "more information, such as the ld(1) and ld.so(8) manual pages." + ;; + esac + $ECHO "X----------------------------------------------------------------------" | $Xsed exit $EXIT_SUCCESS } -test "$opt_mode" = finish && func_mode_finish ${1+"$@"} +test "$mode" = finish && func_mode_finish ${1+"$@"} # func_mode_install arg... @@ -2773,7 +1852,7 @@ # install_prog (especially on Windows NT). if test "$nonopt" = "$SHELL" || test "$nonopt" = /bin/sh || # Allow the use of GNU shtool's install command. - case $nonopt in *shtool*) :;; *) false;; esac; then + $ECHO "X$nonopt" | $GREP shtool >/dev/null; then # Aesthetically quote it. func_quote_for_eval "$nonopt" install_prog="$func_quote_for_eval_result " @@ -2787,12 +1866,7 @@ # The real first argument should be the name of the installation program. # Aesthetically quote it. func_quote_for_eval "$arg" - func_append install_prog "$func_quote_for_eval_result" - install_shared_prog=$install_prog - case " $install_prog " in - *[\\\ /]cp\ *) install_cp=: ;; - *) install_cp=false ;; - esac + install_prog="$install_prog$func_quote_for_eval_result" # We need to accept at least all the BSD install flags. dest= @@ -2802,12 +1876,10 @@ install_type= isdir=no stripme= - no_mode=: for arg do - arg2= if test -n "$dest"; then - func_append files " $dest" + files="$files $dest" dest=$arg continue fi @@ -2815,9 +1887,10 @@ case $arg in -d) isdir=yes ;; -f) - if $install_cp; then :; else - prev=$arg - fi + case " $install_prog " in + *[\\\ /]cp\ *) ;; + *) prev=$arg ;; + esac ;; -g | -m | -o) prev=$arg @@ -2831,10 +1904,6 @@ *) # If the previous option needed an argument, then skip it. if test -n "$prev"; then - if test "x$prev" = x-m && test -n "$install_override_mode"; then - arg2=$install_override_mode - no_mode=false - fi prev= else dest=$arg @@ -2845,11 +1914,7 @@ # Aesthetically quote the argument. func_quote_for_eval "$arg" - func_append install_prog " $func_quote_for_eval_result" - if test -n "$arg2"; then - func_quote_for_eval "$arg2" - fi - func_append install_shared_prog " $func_quote_for_eval_result" + install_prog="$install_prog $func_quote_for_eval_result" done test -z "$install_prog" && \ @@ -2858,13 +1923,6 @@ test -n "$prev" && \ func_fatal_help "the \`$prev' option requires an argument" - if test -n "$install_override_mode" && $no_mode; then - if $install_cp; then :; else - func_quote_for_eval "$install_override_mode" - func_append install_shared_prog " -m $func_quote_for_eval_result" - fi - fi - if test -z "$files"; then if test -z "$dest"; then func_fatal_help "no file or destination specified" @@ -2919,13 +1977,10 @@ case $file in *.$libext) # Do the static libraries later. - func_append staticlibs " $file" + staticlibs="$staticlibs $file" ;; *.la) - func_resolve_sysroot "$file" - file=$func_resolve_sysroot_result - # Check to see that this really is a libtool archive. func_lalib_unsafe_p "$file" \ || func_fatal_help "\`$file' is not a valid libtool archive" @@ -2939,23 +1994,23 @@ if test "X$destdir" = "X$libdir"; then case "$current_libdirs " in *" $libdir "*) ;; - *) func_append current_libdirs " $libdir" ;; + *) current_libdirs="$current_libdirs $libdir" ;; esac else # Note the libdir as a future libdir. case "$future_libdirs " in *" $libdir "*) ;; - *) func_append future_libdirs " $libdir" ;; + *) future_libdirs="$future_libdirs $libdir" ;; esac fi func_dirname "$file" "/" "" dir="$func_dirname_result" - func_append dir "$objdir" + dir="$dir$objdir" if test -n "$relink_command"; then # Determine the prefix the user has applied to our future dir. - inst_prefix_dir=`$ECHO "$destdir" | $SED -e "s%$libdir\$%%"` + inst_prefix_dir=`$ECHO "X$destdir" | $Xsed -e "s%$libdir\$%%"` # Don't allow the user to place us outside of our expected # location b/c this prevents finding dependent libraries that @@ -2968,9 +2023,9 @@ if test -n "$inst_prefix_dir"; then # Stick the inst_prefix_dir data into the link command. - relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"` + relink_command=`$ECHO "X$relink_command" | $Xsed -e "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"` else - relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%%"` + relink_command=`$ECHO "X$relink_command" | $Xsed -e "s%@inst_prefix_dir@%%"` fi func_warning "relinking \`$file'" @@ -2988,7 +2043,7 @@ test -n "$relink_command" && srcname="$realname"T # Install the shared library and build the symlinks. - func_show_eval "$install_shared_prog $dir/$srcname $destdir/$realname" \ + func_show_eval "$install_prog $dir/$srcname $destdir/$realname" \ 'exit $?' tstripme="$stripme" case $host_os in @@ -3028,7 +2083,7 @@ func_show_eval "$install_prog $instname $destdir/$name" 'exit $?' # Maybe install the static library, too. - test -n "$old_library" && func_append staticlibs " $dir/$old_library" + test -n "$old_library" && staticlibs="$staticlibs $dir/$old_library" ;; *.lo) @@ -3128,7 +2183,7 @@ if test -f "$lib"; then func_source "$lib" fi - libfile="$libdir/"`$ECHO "$lib" | $SED 's%^.*/%%g'` ### testsuite: skip nested quoting test + libfile="$libdir/"`$ECHO "X$lib" | $Xsed -e 's%^.*/%%g'` ### testsuite: skip nested quoting test if test -n "$libdir" && test ! -f "$libfile"; then func_warning "\`$lib' has not been installed in \`$libdir'" finalize=no @@ -3147,7 +2202,7 @@ file="$func_basename_result" outputname="$tmpdir/$file" # Replace the output file specification. - relink_command=`$ECHO "$relink_command" | $SED 's%@OUTPUT@%'"$outputname"'%g'` + relink_command=`$ECHO "X$relink_command" | $Xsed -e 's%@OUTPUT@%'"$outputname"'%g'` $opt_silent || { func_quote_for_expand "$relink_command" @@ -3166,7 +2221,7 @@ } else # Install the binary that we compiled earlier. - file=`$ECHO "$file$stripped_ext" | $SED "s%\([^/]*\)$%$objdir/\1%"` + file=`$ECHO "X$file$stripped_ext" | $Xsed -e "s%\([^/]*\)$%$objdir/\1%"` fi fi @@ -3202,13 +2257,11 @@ # Set up the ranlib parameters. oldlib="$destdir/$name" - func_to_tool_file "$oldlib" func_convert_file_msys_to_w32 - tool_oldlib=$func_to_tool_file_result func_show_eval "$install_prog \$file \$oldlib" 'exit $?' if test -n "$stripme" && test -n "$old_striplib"; then - func_show_eval "$old_striplib $tool_oldlib" 'exit $?' + func_show_eval "$old_striplib $oldlib" 'exit $?' fi # Do each command in the postinstall commands. @@ -3227,7 +2280,7 @@ fi } -test "$opt_mode" = install && func_mode_install ${1+"$@"} +test "$mode" = install && func_mode_install ${1+"$@"} # func_generate_dlsyms outputname originator pic_p @@ -3270,22 +2323,6 @@ extern \"C\" { #endif -#if defined(__GNUC__) && (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 4)) || (__GNUC__ > 4)) -#pragma GCC diagnostic ignored \"-Wstrict-prototypes\" -#endif - -/* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests. */ -#if defined(_WIN32) || defined(__CYGWIN__) || defined(_WIN32_WCE) -/* DATA imports from DLLs on WIN32 con't be const, because runtime - relocations are performed -- see ld's documentation on pseudo-relocs. */ -# define LT_DLSYM_CONST -#elif defined(__osf__) -/* This system does not cope well with relocations in const data. */ -# define LT_DLSYM_CONST -#else -# define LT_DLSYM_CONST const -#endif - /* External symbol declarations for the compiler. */\ " @@ -3295,11 +2332,10 @@ $opt_dry_run || echo ': @PROGRAM@ ' > "$nlist" # Add our own program objects to the symbol list. - progfiles=`$ECHO "$objs$old_deplibs" | $SP2NL | $SED "$lo2o" | $NL2SP` + progfiles=`$ECHO "X$objs$old_deplibs" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP` for progfile in $progfiles; do - func_to_tool_file "$progfile" func_convert_file_msys_to_w32 - func_verbose "extracting global C symbols from \`$func_to_tool_file_result'" - $opt_dry_run || eval "$NM $func_to_tool_file_result | $global_symbol_pipe >> '$nlist'" + func_verbose "extracting global C symbols from \`$progfile'" + $opt_dry_run || eval "$NM $progfile | $global_symbol_pipe >> '$nlist'" done if test -n "$exclude_expsyms"; then @@ -3335,7 +2371,7 @@ eval '$GREP -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T' eval '$MV "$nlist"T "$nlist"' case $host in - *cygwin* | *mingw* | *cegcc* ) + *cygwin | *mingw* | *cegcc* ) eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' eval 'cat "$nlist" >> "$output_objdir/$outputname.def"' ;; @@ -3348,52 +2384,10 @@ func_verbose "extracting global C symbols from \`$dlprefile'" func_basename "$dlprefile" name="$func_basename_result" - case $host in - *cygwin* | *mingw* | *cegcc* ) - # if an import library, we need to obtain dlname - if func_win32_import_lib_p "$dlprefile"; then - func_tr_sh "$dlprefile" - eval "curr_lafile=\$libfile_$func_tr_sh_result" - dlprefile_dlbasename="" - if test -n "$curr_lafile" && func_lalib_p "$curr_lafile"; then - # Use subshell, to avoid clobbering current variable values - dlprefile_dlname=`source "$curr_lafile" && echo "$dlname"` - if test -n "$dlprefile_dlname" ; then - func_basename "$dlprefile_dlname" - dlprefile_dlbasename="$func_basename_result" - else - # no lafile. user explicitly requested -dlpreopen . - $sharedlib_from_linklib_cmd "$dlprefile" - dlprefile_dlbasename=$sharedlib_from_linklib_result - fi - fi - $opt_dry_run || { - if test -n "$dlprefile_dlbasename" ; then - eval '$ECHO ": $dlprefile_dlbasename" >> "$nlist"' - else - func_warning "Could not compute DLL name from $name" - eval '$ECHO ": $name " >> "$nlist"' - fi - func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 - eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe | - $SED -e '/I __imp/d' -e 's/I __nm_/D /;s/_nm__//' >> '$nlist'" - } - else # not an import lib - $opt_dry_run || { - eval '$ECHO ": $name " >> "$nlist"' - func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 - eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'" - } - fi - ;; - *) - $opt_dry_run || { - eval '$ECHO ": $name " >> "$nlist"' - func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 - eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'" - } - ;; - esac + $opt_dry_run || { + eval '$ECHO ": $name " >> "$nlist"' + eval "$NM $dlprefile 2>/dev/null | $global_symbol_pipe >> '$nlist'" + } done $opt_dry_run || { @@ -3421,19 +2415,36 @@ if test -f "$nlist"S; then eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$my_dlsyms"' else - echo '/* NONE */' >> "$output_objdir/$my_dlsyms" + $ECHO '/* NONE */' >> "$output_objdir/$my_dlsyms" fi - echo >> "$output_objdir/$my_dlsyms" "\ + $ECHO >> "$output_objdir/$my_dlsyms" "\ /* The mapping between symbol names and symbols. */ typedef struct { const char *name; void *address; } lt_dlsymlist; -extern LT_DLSYM_CONST lt_dlsymlist +" + case $host in + *cygwin* | *mingw* | *cegcc* ) + $ECHO >> "$output_objdir/$my_dlsyms" "\ +/* DATA imports from DLLs on WIN32 con't be const, because + runtime relocations are performed -- see ld's documentation + on pseudo-relocs. */" + lt_dlsym_const= ;; + *osf5*) + echo >> "$output_objdir/$my_dlsyms" "\ +/* This system does not cope well with relocations in const data */" + lt_dlsym_const= ;; + *) + lt_dlsym_const=const ;; + esac + + $ECHO >> "$output_objdir/$my_dlsyms" "\ +extern $lt_dlsym_const lt_dlsymlist lt_${my_prefix}_LTX_preloaded_symbols[]; -LT_DLSYM_CONST lt_dlsymlist +$lt_dlsym_const lt_dlsymlist lt_${my_prefix}_LTX_preloaded_symbols[] = {\ { \"$my_originator\", (void *) 0 }," @@ -3446,7 +2457,7 @@ eval "$global_symbol_to_c_name_address_lib_prefix" < "$nlist" >> "$output_objdir/$my_dlsyms" ;; esac - echo >> "$output_objdir/$my_dlsyms" "\ + $ECHO >> "$output_objdir/$my_dlsyms" "\ {0, (void *) 0} }; @@ -3473,7 +2484,7 @@ # linked before any other PIC object. But we must not use # pic_flag when linking with -static. The problem exists in # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1. - *-*-freebsd2.*|*-*-freebsd3.0*|*-*-freebsdelf3.0*) + *-*-freebsd2*|*-*-freebsd3.0*|*-*-freebsdelf3.0*) pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND" ;; *-*-hpux*) pic_flag_for_symtable=" $pic_flag" ;; @@ -3489,7 +2500,7 @@ for arg in $LTCFLAGS; do case $arg in -pie | -fpie | -fPIE) ;; - *) func_append symtab_cflags " $arg" ;; + *) symtab_cflags="$symtab_cflags $arg" ;; esac done @@ -3504,16 +2515,16 @@ case $host in *cygwin* | *mingw* | *cegcc* ) if test -f "$output_objdir/$my_outputname.def"; then - compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` - finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` + compile_command=`$ECHO "X$compile_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` + finalize_command=`$ECHO "X$finalize_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` else - compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"` - finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"` + compile_command=`$ECHO "X$compile_command" | $Xsed -e "s%@SYMFILE@%$symfileobj%"` + finalize_command=`$ECHO "X$finalize_command" | $Xsed -e "s%@SYMFILE@%$symfileobj%"` fi ;; *) - compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"` - finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"` + compile_command=`$ECHO "X$compile_command" | $Xsed -e "s%@SYMFILE@%$symfileobj%"` + finalize_command=`$ECHO "X$finalize_command" | $Xsed -e "s%@SYMFILE@%$symfileobj%"` ;; esac ;; @@ -3527,8 +2538,8 @@ # really was required. # Nullify the symbol file. - compile_command=`$ECHO "$compile_command" | $SED "s% @SYMFILE@%%"` - finalize_command=`$ECHO "$finalize_command" | $SED "s% @SYMFILE@%%"` + compile_command=`$ECHO "X$compile_command" | $Xsed -e "s% @SYMFILE@%%"` + finalize_command=`$ECHO "X$finalize_command" | $Xsed -e "s% @SYMFILE@%%"` fi } @@ -3538,7 +2549,6 @@ # Need a lot of goo to handle *both* DLLs and import libs # Has to be a shell function in order to 'eat' the argument # that is supplied when $file_magic_command is called. -# Despite the name, also deal with 64 bit binaries. func_win32_libid () { $opt_debug @@ -3549,11 +2559,9 @@ win32_libid_type="x86 archive import" ;; *ar\ archive*) # could be an import, or static - # Keep the egrep pattern in sync with the one in _LT_CHECK_MAGIC_METHOD. if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null | - $EGREP 'file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' >/dev/null; then - func_to_tool_file "$1" func_convert_file_msys_to_w32 - win32_nmres=`eval $NM -f posix -A \"$func_to_tool_file_result\" | + $EGREP 'file format pe-i386(.*architecture: i386)?' >/dev/null ; then + win32_nmres=`eval $NM -f posix -A $1 | $SED -n -e ' 1,100{ / I /{ @@ -3582,131 +2590,6 @@ $ECHO "$win32_libid_type" } -# func_cygming_dll_for_implib ARG -# -# Platform-specific function to extract the -# name of the DLL associated with the specified -# import library ARG. -# Invoked by eval'ing the libtool variable -# $sharedlib_from_linklib_cmd -# Result is available in the variable -# $sharedlib_from_linklib_result -func_cygming_dll_for_implib () -{ - $opt_debug - sharedlib_from_linklib_result=`$DLLTOOL --identify-strict --identify "$1"` -} - -# func_cygming_dll_for_implib_fallback_core SECTION_NAME LIBNAMEs -# -# The is the core of a fallback implementation of a -# platform-specific function to extract the name of the -# DLL associated with the specified import library LIBNAME. -# -# SECTION_NAME is either .idata$6 or .idata$7, depending -# on the platform and compiler that created the implib. -# -# Echos the name of the DLL associated with the -# specified import library. -func_cygming_dll_for_implib_fallback_core () -{ - $opt_debug - match_literal=`$ECHO "$1" | $SED "$sed_make_literal_regex"` - $OBJDUMP -s --section "$1" "$2" 2>/dev/null | - $SED '/^Contents of section '"$match_literal"':/{ - # Place marker at beginning of archive member dllname section - s/.*/====MARK====/ - p - d - } - # These lines can sometimes be longer than 43 characters, but - # are always uninteresting - /:[ ]*file format pe[i]\{,1\}-/d - /^In archive [^:]*:/d - # Ensure marker is printed - /^====MARK====/p - # Remove all lines with less than 43 characters - /^.\{43\}/!d - # From remaining lines, remove first 43 characters - s/^.\{43\}//' | - $SED -n ' - # Join marker and all lines until next marker into a single line - /^====MARK====/ b para - H - $ b para - b - :para - x - s/\n//g - # Remove the marker - s/^====MARK====// - # Remove trailing dots and whitespace - s/[\. \t]*$// - # Print - /./p' | - # we now have a list, one entry per line, of the stringified - # contents of the appropriate section of all members of the - # archive which possess that section. Heuristic: eliminate - # all those which have a first or second character that is - # a '.' (that is, objdump's representation of an unprintable - # character.) This should work for all archives with less than - # 0x302f exports -- but will fail for DLLs whose name actually - # begins with a literal '.' or a single character followed by - # a '.'. - # - # Of those that remain, print the first one. - $SED -e '/^\./d;/^.\./d;q' -} - -# func_cygming_gnu_implib_p ARG -# This predicate returns with zero status (TRUE) if -# ARG is a GNU/binutils-style import library. Returns -# with nonzero status (FALSE) otherwise. -func_cygming_gnu_implib_p () -{ - $opt_debug - func_to_tool_file "$1" func_convert_file_msys_to_w32 - func_cygming_gnu_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $EGREP ' (_head_[A-Za-z0-9_]+_[ad]l*|[A-Za-z0-9_]+_[ad]l*_iname)$'` - test -n "$func_cygming_gnu_implib_tmp" -} - -# func_cygming_ms_implib_p ARG -# This predicate returns with zero status (TRUE) if -# ARG is an MS-style import library. Returns -# with nonzero status (FALSE) otherwise. -func_cygming_ms_implib_p () -{ - $opt_debug - func_to_tool_file "$1" func_convert_file_msys_to_w32 - func_cygming_ms_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $GREP '_NULL_IMPORT_DESCRIPTOR'` - test -n "$func_cygming_ms_implib_tmp" -} - -# func_cygming_dll_for_implib_fallback ARG -# Platform-specific function to extract the -# name of the DLL associated with the specified -# import library ARG. -# -# This fallback implementation is for use when $DLLTOOL -# does not support the --identify-strict option. -# Invoked by eval'ing the libtool variable -# $sharedlib_from_linklib_cmd -# Result is available in the variable -# $sharedlib_from_linklib_result -func_cygming_dll_for_implib_fallback () -{ - $opt_debug - if func_cygming_gnu_implib_p "$1" ; then - # binutils import library - sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$7' "$1"` - elif func_cygming_ms_implib_p "$1" ; then - # ms-generated import library - sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$6' "$1"` - else - # unknown - sharedlib_from_linklib_result="" - fi -} # func_extract_an_archive dir oldlib @@ -3715,18 +2598,7 @@ $opt_debug f_ex_an_ar_dir="$1"; shift f_ex_an_ar_oldlib="$1" - if test "$lock_old_archive_extraction" = yes; then - lockfile=$f_ex_an_ar_oldlib.lock - until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do - func_echo "Waiting for $lockfile to be removed" - sleep 2 - done - fi - func_show_eval "(cd \$f_ex_an_ar_dir && $AR x \"\$f_ex_an_ar_oldlib\")" \ - 'stat=$?; rm -f "$lockfile"; exit $stat' - if test "$lock_old_archive_extraction" = yes; then - $opt_dry_run || rm -f "$lockfile" - fi + func_show_eval "(cd \$f_ex_an_ar_dir && $AR x \"\$f_ex_an_ar_oldlib\")" 'exit $?' if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then : else @@ -3797,7 +2669,7 @@ darwin_file= darwin_files= for darwin_file in $darwin_filelist; do - darwin_files=`find unfat-$$ -name $darwin_file -print | sort | $NL2SP` + darwin_files=`find unfat-$$ -name $darwin_file -print | $NL2SP` $LIPO -create -output "$darwin_file" $darwin_files done # $darwin_filelist $RM -rf unfat-$$ @@ -3812,13 +2684,248 @@ func_extract_an_archive "$my_xdir" "$my_xabs" ;; esac - my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | sort | $NL2SP` + my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | $NL2SP` done func_extract_archives_result="$my_oldobjs" } + +# func_emit_wrapper_part1 [arg=no] +# +# Emit the first part of a libtool wrapper script on stdout. +# For more information, see the description associated with +# func_emit_wrapper(), below. +func_emit_wrapper_part1 () +{ + func_emit_wrapper_part1_arg1=no + if test -n "$1" ; then + func_emit_wrapper_part1_arg1=$1 + fi + + $ECHO "\ +#! $SHELL + +# $output - temporary wrapper script for $objdir/$outputname +# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION +# +# The $output program cannot be directly executed until all the libtool +# libraries that it depends on are installed. +# +# This wrapper script should never be moved out of the build directory. +# If it is, it will not operate correctly. + +# Sed substitution that helps us do robust quoting. It backslashifies +# metacharacters that are still active within double-quoted strings. +Xsed='${SED} -e 1s/^X//' +sed_quote_subst='$sed_quote_subst' + +# Be Bourne compatible +if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then + emulate sh + NULLCMD=: + # Zsh 3.x and 4.x performs word splitting on \${1+\"\$@\"}, which + # is contrary to our usage. Disable this feature. + alias -g '\${1+\"\$@\"}'='\"\$@\"' + setopt NO_GLOB_SUBST +else + case \`(set -o) 2>/dev/null\` in *posix*) set -o posix;; esac +fi +BIN_SH=xpg4; export BIN_SH # for Tru64 +DUALCASE=1; export DUALCASE # for MKS sh + +# The HP-UX ksh and POSIX shell print the target directory to stdout +# if CDPATH is set. +(unset CDPATH) >/dev/null 2>&1 && unset CDPATH + +relink_command=\"$relink_command\" + +# This environment variable determines our operation mode. +if test \"\$libtool_install_magic\" = \"$magic\"; then + # install mode needs the following variables: + generated_by_libtool_version='$macro_version' + notinst_deplibs='$notinst_deplibs' +else + # When we are sourced in execute mode, \$file and \$ECHO are already set. + if test \"\$libtool_execute_magic\" != \"$magic\"; then + ECHO=\"$qecho\" + file=\"\$0\" + # Make sure echo works. + if test \"X\$1\" = X--no-reexec; then + # Discard the --no-reexec flag, and continue. + shift + elif test \"X\`{ \$ECHO '\t'; } 2>/dev/null\`\" = 'X\t'; then + # Yippee, \$ECHO works! + : + else + # Restart under the correct shell, and then maybe \$ECHO will work. + exec $SHELL \"\$0\" --no-reexec \${1+\"\$@\"} + fi + fi\ +" + $ECHO "\ + + # Find the directory that this script lives in. + thisdir=\`\$ECHO \"X\$file\" | \$Xsed -e 's%/[^/]*$%%'\` + test \"x\$thisdir\" = \"x\$file\" && thisdir=. + + # Follow symbolic links until we get to the real thisdir. + file=\`ls -ld \"\$file\" | ${SED} -n 's/.*-> //p'\` + while test -n \"\$file\"; do + destdir=\`\$ECHO \"X\$file\" | \$Xsed -e 's%/[^/]*\$%%'\` + + # If there was a directory component, then change thisdir. + if test \"x\$destdir\" != \"x\$file\"; then + case \"\$destdir\" in + [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;; + *) thisdir=\"\$thisdir/\$destdir\" ;; + esac + fi + + file=\`\$ECHO \"X\$file\" | \$Xsed -e 's%^.*/%%'\` + file=\`ls -ld \"\$thisdir/\$file\" | ${SED} -n 's/.*-> //p'\` + done +" +} +# end: func_emit_wrapper_part1 + +# func_emit_wrapper_part2 [arg=no] +# +# Emit the second part of a libtool wrapper script on stdout. +# For more information, see the description associated with +# func_emit_wrapper(), below. +func_emit_wrapper_part2 () +{ + func_emit_wrapper_part2_arg1=no + if test -n "$1" ; then + func_emit_wrapper_part2_arg1=$1 + fi + + $ECHO "\ + + # Usually 'no', except on cygwin/mingw when embedded into + # the cwrapper. + WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=$func_emit_wrapper_part2_arg1 + if test \"\$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR\" = \"yes\"; then + # special case for '.' + if test \"\$thisdir\" = \".\"; then + thisdir=\`pwd\` + fi + # remove .libs from thisdir + case \"\$thisdir\" in + *[\\\\/]$objdir ) thisdir=\`\$ECHO \"X\$thisdir\" | \$Xsed -e 's%[\\\\/][^\\\\/]*$%%'\` ;; + $objdir ) thisdir=. ;; + esac + fi + + # Try to get the absolute directory name. + absdir=\`cd \"\$thisdir\" && pwd\` + test -n \"\$absdir\" && thisdir=\"\$absdir\" +" + + if test "$fast_install" = yes; then + $ECHO "\ + program=lt-'$outputname'$exeext + progdir=\"\$thisdir/$objdir\" + + if test ! -f \"\$progdir/\$program\" || + { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | ${SED} 1q\`; \\ + test \"X\$file\" != \"X\$progdir/\$program\"; }; then + + file=\"\$\$-\$program\" + + if test ! -d \"\$progdir\"; then + $MKDIR \"\$progdir\" + else + $RM \"\$progdir/\$file\" + fi" + + $ECHO "\ + + # relink executable if necessary + if test -n \"\$relink_command\"; then + if relink_command_output=\`eval \$relink_command 2>&1\`; then : + else + $ECHO \"\$relink_command_output\" >&2 + $RM \"\$progdir/\$file\" + exit 1 + fi + fi + + $MV \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null || + { $RM \"\$progdir/\$program\"; + $MV \"\$progdir/\$file\" \"\$progdir/\$program\"; } + $RM \"\$progdir/\$file\" + fi" + else + $ECHO "\ + program='$outputname' + progdir=\"\$thisdir/$objdir\" +" + fi + + $ECHO "\ + + if test -f \"\$progdir/\$program\"; then" + + # Export our shlibpath_var if we have one. + if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then + $ECHO "\ + # Add our own library path to $shlibpath_var + $shlibpath_var=\"$temp_rpath\$$shlibpath_var\" + + # Some systems cannot cope with colon-terminated $shlibpath_var + # The second colon is a workaround for a bug in BeOS R4 sed + $shlibpath_var=\`\$ECHO \"X\$$shlibpath_var\" | \$Xsed -e 's/::*\$//'\` + + export $shlibpath_var +" + fi + + # fixup the dll searchpath if we need to. + if test -n "$dllsearchpath"; then + $ECHO "\ + # Add the dll search path components to the executable PATH + PATH=$dllsearchpath:\$PATH +" + fi + + $ECHO "\ + if test \"\$libtool_execute_magic\" != \"$magic\"; then + # Run the actual program with our arguments. +" + case $host in + # Backslashes separate directories on plain windows + *-*-mingw | *-*-os2* | *-cegcc*) + $ECHO "\ + exec \"\$progdir\\\\\$program\" \${1+\"\$@\"} +" + ;; + + *) + $ECHO "\ + exec \"\$progdir/\$program\" \${1+\"\$@\"} +" + ;; + esac + $ECHO "\ + \$ECHO \"\$0: cannot exec \$program \$*\" 1>&2 + exit 1 + fi + else + # The program doesn't exist. + \$ECHO \"\$0: error: \\\`\$progdir/\$program' does not exist\" 1>&2 + \$ECHO \"This script is just a wrapper for \$program.\" 1>&2 + $ECHO \"See the $PACKAGE documentation for more information.\" 1>&2 + exit 1 + fi +fi\ +" +} +# end: func_emit_wrapper_part2 + + # func_emit_wrapper [arg=no] # # Emit a libtool wrapper script on stdout. @@ -3835,301 +2942,188 @@ # behavior. func_emit_wrapper () { - func_emit_wrapper_arg1=${1-no} - - $ECHO "\ -#! $SHELL - -# $output - temporary wrapper script for $objdir/$outputname -# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION + func_emit_wrapper_arg1=no + if test -n "$1" ; then + func_emit_wrapper_arg1=$1 + fi + + # split this up so that func_emit_cwrapperexe_src + # can call each part independently. + func_emit_wrapper_part1 "${func_emit_wrapper_arg1}" + func_emit_wrapper_part2 "${func_emit_wrapper_arg1}" +} + + +# func_to_host_path arg # -# The $output program cannot be directly executed until all the libtool -# libraries that it depends on are installed. +# Convert paths to host format when used with build tools. +# Intended for use with "native" mingw (where libtool itself +# is running under the msys shell), or in the following cross- +# build environments: +# $build $host +# mingw (msys) mingw [e.g. native] +# cygwin mingw +# *nix + wine mingw +# where wine is equipped with the `winepath' executable. +# In the native mingw case, the (msys) shell automatically +# converts paths for any non-msys applications it launches, +# but that facility isn't available from inside the cwrapper. +# Similar accommodations are necessary for $host mingw and +# $build cygwin. Calling this function does no harm for other +# $host/$build combinations not listed above. # -# This wrapper script should never be moved out of the build directory. -# If it is, it will not operate correctly. - -# Sed substitution that helps us do robust quoting. It backslashifies -# metacharacters that are still active within double-quoted strings. -sed_quote_subst='$sed_quote_subst' - -# Be Bourne compatible -if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then - emulate sh - NULLCMD=: - # Zsh 3.x and 4.x performs word splitting on \${1+\"\$@\"}, which - # is contrary to our usage. Disable this feature. - alias -g '\${1+\"\$@\"}'='\"\$@\"' - setopt NO_GLOB_SUBST -else - case \`(set -o) 2>/dev/null\` in *posix*) set -o posix;; esac -fi -BIN_SH=xpg4; export BIN_SH # for Tru64 -DUALCASE=1; export DUALCASE # for MKS sh - -# The HP-UX ksh and POSIX shell print the target directory to stdout -# if CDPATH is set. -(unset CDPATH) >/dev/null 2>&1 && unset CDPATH - -relink_command=\"$relink_command\" - -# This environment variable determines our operation mode. -if test \"\$libtool_install_magic\" = \"$magic\"; then - # install mode needs the following variables: - generated_by_libtool_version='$macro_version' - notinst_deplibs='$notinst_deplibs' -else - # When we are sourced in execute mode, \$file and \$ECHO are already set. - if test \"\$libtool_execute_magic\" != \"$magic\"; then - file=\"\$0\"" - - qECHO=`$ECHO "$ECHO" | $SED "$sed_quote_subst"` - $ECHO "\ - -# A function that is used when there is no print builtin or printf. -func_fallback_echo () +# ARG is the path (on $build) that should be converted to +# the proper representation for $host. The result is stored +# in $func_to_host_path_result. +func_to_host_path () { - eval 'cat <<_LTECHO_EOF -\$1 -_LTECHO_EOF' -} - ECHO=\"$qECHO\" - fi - -# Very basic option parsing. These options are (a) specific to -# the libtool wrapper, (b) are identical between the wrapper -# /script/ and the wrapper /executable/ which is used only on -# windows platforms, and (c) all begin with the string "--lt-" -# (application programs are unlikely to have options which match -# this pattern). -# -# There are only two supported options: --lt-debug and -# --lt-dump-script. There is, deliberately, no --lt-help. -# -# The first argument to this parsing function should be the -# script's $0 value, followed by "$@". -lt_option_debug= -func_parse_lt_options () -{ - lt_script_arg0=\$0 - shift - for lt_opt - do - case \"\$lt_opt\" in - --lt-debug) lt_option_debug=1 ;; - --lt-dump-script) - lt_dump_D=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%/[^/]*$%%'\` - test \"X\$lt_dump_D\" = \"X\$lt_script_arg0\" && lt_dump_D=. - lt_dump_F=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%^.*/%%'\` - cat \"\$lt_dump_D/\$lt_dump_F\" - exit 0 - ;; - --lt-*) - \$ECHO \"Unrecognized --lt- option: '\$lt_opt'\" 1>&2 - exit 1 - ;; + func_to_host_path_result="$1" + if test -n "$1" ; then + case $host in + *mingw* ) + lt_sed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g' + case $build in + *mingw* ) # actually, msys + # awkward: cmd appends spaces to result + lt_sed_strip_trailing_spaces="s/[ ]*\$//" + func_to_host_path_tmp1=`( cmd //c echo "$1" |\ + $SED -e "$lt_sed_strip_trailing_spaces" ) 2>/dev/null || echo ""` + func_to_host_path_result=`echo "$func_to_host_path_tmp1" |\ + $SED -e "$lt_sed_naive_backslashify"` + ;; + *cygwin* ) + func_to_host_path_tmp1=`cygpath -w "$1"` + func_to_host_path_result=`echo "$func_to_host_path_tmp1" |\ + $SED -e "$lt_sed_naive_backslashify"` + ;; + * ) + # Unfortunately, winepath does not exit with a non-zero + # error code, so we are forced to check the contents of + # stdout. On the other hand, if the command is not + # found, the shell will set an exit code of 127 and print + # *an error message* to stdout. So we must check for both + # error code of zero AND non-empty stdout, which explains + # the odd construction: + func_to_host_path_tmp1=`winepath -w "$1" 2>/dev/null` + if test "$?" -eq 0 && test -n "${func_to_host_path_tmp1}"; then + func_to_host_path_result=`echo "$func_to_host_path_tmp1" |\ + $SED -e "$lt_sed_naive_backslashify"` + else + # Allow warning below. + func_to_host_path_result="" + fi + ;; + esac + if test -z "$func_to_host_path_result" ; then + func_error "Could not determine host path corresponding to" + func_error " '$1'" + func_error "Continuing, but uninstalled executables may not work." + # Fallback: + func_to_host_path_result="$1" + fi + ;; esac - done - - # Print the debug banner immediately: - if test -n \"\$lt_option_debug\"; then - echo \"${outputname}:${output}:\${LINENO}: libtool wrapper (GNU $PACKAGE$TIMESTAMP) $VERSION\" 1>&2 fi } - -# Used when --lt-debug. Prints its arguments to stdout -# (redirection is the responsibility of the caller) -func_lt_dump_args () +# end: func_to_host_path + +# func_to_host_pathlist arg +# +# Convert pathlists to host format when used with build tools. +# See func_to_host_path(), above. This function supports the +# following $build/$host combinations (but does no harm for +# combinations not listed here): +# $build $host +# mingw (msys) mingw [e.g. native] +# cygwin mingw +# *nix + wine mingw +# +# Path separators are also converted from $build format to +# $host format. If ARG begins or ends with a path separator +# character, it is preserved (but converted to $host format) +# on output. +# +# ARG is a pathlist (on $build) that should be converted to +# the proper representation on $host. The result is stored +# in $func_to_host_pathlist_result. +func_to_host_pathlist () { - lt_dump_args_N=1; - for lt_arg - do - \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[\$lt_dump_args_N]: \$lt_arg\" - lt_dump_args_N=\`expr \$lt_dump_args_N + 1\` - done -} - -# Core function for launching the target application -func_exec_program_core () -{ -" - case $host in - # Backslashes separate directories on plain windows - *-*-mingw | *-*-os2* | *-cegcc*) - $ECHO "\ - if test -n \"\$lt_option_debug\"; then - \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[0]: \$progdir\\\\\$program\" 1>&2 - func_lt_dump_args \${1+\"\$@\"} 1>&2 - fi - exec \"\$progdir\\\\\$program\" \${1+\"\$@\"} -" - ;; - - *) - $ECHO "\ - if test -n \"\$lt_option_debug\"; then - \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[0]: \$progdir/\$program\" 1>&2 - func_lt_dump_args \${1+\"\$@\"} 1>&2 - fi - exec \"\$progdir/\$program\" \${1+\"\$@\"} -" - ;; - esac - $ECHO "\ - \$ECHO \"\$0: cannot exec \$program \$*\" 1>&2 - exit 1 -} - -# A function to encapsulate launching the target application -# Strips options in the --lt-* namespace from \$@ and -# launches target application with the remaining arguments. -func_exec_program () -{ - case \" \$* \" in - *\\ --lt-*) - for lt_wr_arg - do - case \$lt_wr_arg in - --lt-*) ;; - *) set x \"\$@\" \"\$lt_wr_arg\"; shift;; - esac - shift - done ;; - esac - func_exec_program_core \${1+\"\$@\"} -} - - # Parse options - func_parse_lt_options \"\$0\" \${1+\"\$@\"} - - # Find the directory that this script lives in. - thisdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*$%%'\` - test \"x\$thisdir\" = \"x\$file\" && thisdir=. - - # Follow symbolic links until we get to the real thisdir. - file=\`ls -ld \"\$file\" | $SED -n 's/.*-> //p'\` - while test -n \"\$file\"; do - destdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*\$%%'\` - - # If there was a directory component, then change thisdir. - if test \"x\$destdir\" != \"x\$file\"; then - case \"\$destdir\" in - [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;; - *) thisdir=\"\$thisdir/\$destdir\" ;; - esac - fi - - file=\`\$ECHO \"\$file\" | $SED 's%^.*/%%'\` - file=\`ls -ld \"\$thisdir/\$file\" | $SED -n 's/.*-> //p'\` - done - - # Usually 'no', except on cygwin/mingw when embedded into - # the cwrapper. - WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=$func_emit_wrapper_arg1 - if test \"\$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR\" = \"yes\"; then - # special case for '.' - if test \"\$thisdir\" = \".\"; then - thisdir=\`pwd\` - fi - # remove .libs from thisdir - case \"\$thisdir\" in - *[\\\\/]$objdir ) thisdir=\`\$ECHO \"\$thisdir\" | $SED 's%[\\\\/][^\\\\/]*$%%'\` ;; - $objdir ) thisdir=. ;; + func_to_host_pathlist_result="$1" + if test -n "$1" ; then + case $host in + *mingw* ) + lt_sed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g' + # Remove leading and trailing path separator characters from + # ARG. msys behavior is inconsistent here, cygpath turns them + # into '.;' and ';.', and winepath ignores them completely. + func_to_host_pathlist_tmp2="$1" + # Once set for this call, this variable should not be + # reassigned. It is used in tha fallback case. + func_to_host_pathlist_tmp1=`echo "$func_to_host_pathlist_tmp2" |\ + $SED -e 's|^:*||' -e 's|:*$||'` + case $build in + *mingw* ) # Actually, msys. + # Awkward: cmd appends spaces to result. + lt_sed_strip_trailing_spaces="s/[ ]*\$//" + func_to_host_pathlist_tmp2=`( cmd //c echo "$func_to_host_pathlist_tmp1" |\ + $SED -e "$lt_sed_strip_trailing_spaces" ) 2>/dev/null || echo ""` + func_to_host_pathlist_result=`echo "$func_to_host_pathlist_tmp2" |\ + $SED -e "$lt_sed_naive_backslashify"` + ;; + *cygwin* ) + func_to_host_pathlist_tmp2=`cygpath -w -p "$func_to_host_pathlist_tmp1"` + func_to_host_pathlist_result=`echo "$func_to_host_pathlist_tmp2" |\ + $SED -e "$lt_sed_naive_backslashify"` + ;; + * ) + # unfortunately, winepath doesn't convert pathlists + func_to_host_pathlist_result="" + func_to_host_pathlist_oldIFS=$IFS + IFS=: + for func_to_host_pathlist_f in $func_to_host_pathlist_tmp1 ; do + IFS=$func_to_host_pathlist_oldIFS + if test -n "$func_to_host_pathlist_f" ; then + func_to_host_path "$func_to_host_pathlist_f" + if test -n "$func_to_host_path_result" ; then + if test -z "$func_to_host_pathlist_result" ; then + func_to_host_pathlist_result="$func_to_host_path_result" + else + func_to_host_pathlist_result="$func_to_host_pathlist_result;$func_to_host_path_result" + fi + fi + fi + IFS=: + done + IFS=$func_to_host_pathlist_oldIFS + ;; + esac + if test -z "$func_to_host_pathlist_result" ; then + func_error "Could not determine the host path(s) corresponding to" + func_error " '$1'" + func_error "Continuing, but uninstalled executables may not work." + # Fallback. This may break if $1 contains DOS-style drive + # specifications. The fix is not to complicate the expression + # below, but for the user to provide a working wine installation + # with winepath so that path translation in the cross-to-mingw + # case works properly. + lt_replace_pathsep_nix_to_dos="s|:|;|g" + func_to_host_pathlist_result=`echo "$func_to_host_pathlist_tmp1" |\ + $SED -e "$lt_replace_pathsep_nix_to_dos"` + fi + # Now, add the leading and trailing path separators back + case "$1" in + :* ) func_to_host_pathlist_result=";$func_to_host_pathlist_result" + ;; + esac + case "$1" in + *: ) func_to_host_pathlist_result="$func_to_host_pathlist_result;" + ;; + esac + ;; esac fi - - # Try to get the absolute directory name. - absdir=\`cd \"\$thisdir\" && pwd\` - test -n \"\$absdir\" && thisdir=\"\$absdir\" -" - - if test "$fast_install" = yes; then - $ECHO "\ - program=lt-'$outputname'$exeext - progdir=\"\$thisdir/$objdir\" - - if test ! -f \"\$progdir/\$program\" || - { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | ${SED} 1q\`; \\ - test \"X\$file\" != \"X\$progdir/\$program\"; }; then - - file=\"\$\$-\$program\" - - if test ! -d \"\$progdir\"; then - $MKDIR \"\$progdir\" - else - $RM \"\$progdir/\$file\" - fi" - - $ECHO "\ - - # relink executable if necessary - if test -n \"\$relink_command\"; then - if relink_command_output=\`eval \$relink_command 2>&1\`; then : - else - $ECHO \"\$relink_command_output\" >&2 - $RM \"\$progdir/\$file\" - exit 1 - fi - fi - - $MV \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null || - { $RM \"\$progdir/\$program\"; - $MV \"\$progdir/\$file\" \"\$progdir/\$program\"; } - $RM \"\$progdir/\$file\" - fi" - else - $ECHO "\ - program='$outputname' - progdir=\"\$thisdir/$objdir\" -" - fi - - $ECHO "\ - - if test -f \"\$progdir/\$program\"; then" - - # fixup the dll searchpath if we need to. - # - # Fix the DLL searchpath if we need to. Do this before prepending - # to shlibpath, because on Windows, both are PATH and uninstalled - # libraries must come first. - if test -n "$dllsearchpath"; then - $ECHO "\ - # Add the dll search path components to the executable PATH - PATH=$dllsearchpath:\$PATH -" - fi - - # Export our shlibpath_var if we have one. - if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then - $ECHO "\ - # Add our own library path to $shlibpath_var - $shlibpath_var=\"$temp_rpath\$$shlibpath_var\" - - # Some systems cannot cope with colon-terminated $shlibpath_var - # The second colon is a workaround for a bug in BeOS R4 sed - $shlibpath_var=\`\$ECHO \"\$$shlibpath_var\" | $SED 's/::*\$//'\` - - export $shlibpath_var -" - fi - - $ECHO "\ - if test \"\$libtool_execute_magic\" != \"$magic\"; then - # Run the actual program with our arguments. - func_exec_program \${1+\"\$@\"} - fi - else - # The program doesn't exist. - \$ECHO \"\$0: error: \\\`\$progdir/\$program' does not exist\" 1>&2 - \$ECHO \"This script is just a wrapper for \$program.\" 1>&2 - \$ECHO \"See the $PACKAGE documentation for more information.\" 1>&2 - exit 1 - fi -fi\ -" } - +# end: func_to_host_pathlist # func_emit_cwrapperexe_src # emit the source code for a wrapper executable on stdout @@ -4147,23 +3141,31 @@ This wrapper executable should never be moved out of the build directory. If it is, it will not operate correctly. + + Currently, it simply execs the wrapper *script* "$SHELL $output", + but could eventually absorb all of the scripts functionality and + exec $objdir/$outputname directly. */ EOF cat <<"EOF" -#ifdef _MSC_VER -# define _CRT_SECURE_NO_DEPRECATE 1 -#endif #include #include #ifdef _MSC_VER # include # include # include +# define setmode _setmode #else # include # include # ifdef __CYGWIN__ # include +# define HAVE_SETENV +# ifdef __STRICT_ANSI__ +char *realpath (const char *, char *); +int putenv (char *); +int setenv (const char *, const char *, int); +# endif # endif #endif #include @@ -4175,44 +3177,6 @@ #include #include -/* declarations of non-ANSI functions */ -#if defined(__MINGW32__) -# ifdef __STRICT_ANSI__ -int _putenv (const char *); -# endif -#elif defined(__CYGWIN__) -# ifdef __STRICT_ANSI__ -char *realpath (const char *, char *); -int putenv (char *); -int setenv (const char *, const char *, int); -# endif -/* #elif defined (other platforms) ... */ -#endif - -/* portability defines, excluding path handling macros */ -#if defined(_MSC_VER) -# define setmode _setmode -# define stat _stat -# define chmod _chmod -# define getcwd _getcwd -# define putenv _putenv -# define S_IXUSR _S_IEXEC -# ifndef _INTPTR_T_DEFINED -# define _INTPTR_T_DEFINED -# define intptr_t int -# endif -#elif defined(__MINGW32__) -# define setmode _setmode -# define stat _stat -# define chmod _chmod -# define getcwd _getcwd -# define putenv _putenv -#elif defined(__CYGWIN__) -# define HAVE_SETENV -# define FOPEN_WB "wb" -/* #elif defined (other platforms) ... */ -#endif - #if defined(PATH_MAX) # define LT_PATHMAX PATH_MAX #elif defined(MAXPATHLEN) @@ -4228,7 +3192,14 @@ # define S_IXGRP 0 #endif -/* path handling portability macros */ +#ifdef _MSC_VER +# define S_IXUSR _S_IEXEC +# define stat _stat +# ifndef _INTPTR_T_DEFINED +# define intptr_t int +# endif +#endif + #ifndef DIR_SEPARATOR # define DIR_SEPARATOR '/' # define PATH_SEPARATOR ':' @@ -4259,6 +3230,10 @@ # define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2) #endif /* PATH_SEPARATOR_2 */ +#ifdef __CYGWIN__ +# define FOPEN_WB "wb" +#endif + #ifndef FOPEN_WB # define FOPEN_WB "w" #endif @@ -4271,13 +3246,22 @@ if (stale) { free ((void *) stale); stale = 0; } \ } while (0) -#if defined(LT_DEBUGWRAPPER) -static int lt_debug = 1; +#undef LTWRAPPER_DEBUGPRINTF +#if defined DEBUGWRAPPER +# define LTWRAPPER_DEBUGPRINTF(args) ltwrapper_debugprintf args +static void +ltwrapper_debugprintf (const char *fmt, ...) +{ + va_list args; + va_start (args, fmt); + (void) vfprintf (stderr, fmt, args); + va_end (args); +} #else -static int lt_debug = 0; +# define LTWRAPPER_DEBUGPRINTF(args) #endif -const char *program_name = "libtool-wrapper"; /* in case xstrdup fails */ +const char *program_name = NULL; void *xmalloc (size_t num); char *xstrdup (const char *string); @@ -4287,27 +3271,41 @@ int make_executable (const char *path); int check_executable (const char *path); char *strendzap (char *str, const char *pat); -void lt_debugprintf (const char *file, int line, const char *fmt, ...); -void lt_fatal (const char *file, int line, const char *message, ...); -static const char *nonnull (const char *s); -static const char *nonempty (const char *s); +void lt_fatal (const char *message, ...); void lt_setenv (const char *name, const char *value); char *lt_extend_str (const char *orig_value, const char *add, int to_end); +void lt_opt_process_env_set (const char *arg); +void lt_opt_process_env_prepend (const char *arg); +void lt_opt_process_env_append (const char *arg); +int lt_split_name_value (const char *arg, char** name, char** value); void lt_update_exe_path (const char *name, const char *value); void lt_update_lib_path (const char *name, const char *value); -char **prepare_spawn (char **argv); -void lt_dump_script (FILE *f); + +static const char *script_text_part1 = EOF + func_emit_wrapper_part1 yes | + $SED -e 's/\([\\"]\)/\\\1/g' \ + -e 's/^/ "/' -e 's/$/\\n"/' + echo ";" cat <"))); for (i = 0; i < newargc; i++) { - lt_debugprintf (__FILE__, __LINE__, "(main) newargz[%d]: %s\n", - i, nonnull (newargz[i])); + LTWRAPPER_DEBUGPRINTF (("(main) newargz[%d] : %s\n", i, (newargz[i] ? newargz[i] : ""))); } EOF @@ -4523,14 +3560,11 @@ mingw*) cat <<"EOF" /* execv doesn't actually work on mingw as expected on unix */ - newargz = prepare_spawn (newargz); rval = _spawnv (_P_WAIT, lt_argv_zero, (const char * const *) newargz); if (rval == -1) { /* failed to start process */ - lt_debugprintf (__FILE__, __LINE__, - "(main) failed to launch target \"%s\": %s\n", - lt_argv_zero, nonnull (strerror (errno))); + LTWRAPPER_DEBUGPRINTF (("(main) failed to launch target \"%s\": errno = %d\n", lt_argv_zero, errno)); return 127; } return rval; @@ -4552,7 +3586,7 @@ { void *p = (void *) malloc (num); if (!p) - lt_fatal (__FILE__, __LINE__, "memory exhausted"); + lt_fatal ("Memory exhausted"); return p; } @@ -4586,8 +3620,8 @@ { struct stat st; - lt_debugprintf (__FILE__, __LINE__, "(check_executable): %s\n", - nonempty (path)); + LTWRAPPER_DEBUGPRINTF (("(check_executable) : %s\n", + path ? (*path ? path : "EMPTY!") : "NULL!")); if ((!path) || (!*path)) return 0; @@ -4604,8 +3638,8 @@ int rval = 0; struct stat st; - lt_debugprintf (__FILE__, __LINE__, "(make_executable): %s\n", - nonempty (path)); + LTWRAPPER_DEBUGPRINTF (("(make_executable) : %s\n", + path ? (*path ? path : "EMPTY!") : "NULL!")); if ((!path) || (!*path)) return 0; @@ -4631,8 +3665,8 @@ int tmp_len; char *concat_name; - lt_debugprintf (__FILE__, __LINE__, "(find_executable): %s\n", - nonempty (wrapper)); + LTWRAPPER_DEBUGPRINTF (("(find_executable) : %s\n", + wrapper ? (*wrapper ? wrapper : "EMPTY!") : "NULL!")); if ((wrapper == NULL) || (*wrapper == '\0')) return NULL; @@ -4685,8 +3719,7 @@ { /* empty path: current directory */ if (getcwd (tmp, LT_PATHMAX) == NULL) - lt_fatal (__FILE__, __LINE__, "getcwd failed: %s", - nonnull (strerror (errno))); + lt_fatal ("getcwd failed"); tmp_len = strlen (tmp); concat_name = XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1); @@ -4711,8 +3744,7 @@ } /* Relative path | not found in path: prepend cwd */ if (getcwd (tmp, LT_PATHMAX) == NULL) - lt_fatal (__FILE__, __LINE__, "getcwd failed: %s", - nonnull (strerror (errno))); + lt_fatal ("getcwd failed"); tmp_len = strlen (tmp); concat_name = XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1); memcpy (concat_name, tmp, tmp_len); @@ -4738,9 +3770,8 @@ int has_symlinks = 0; while (strlen (tmp_pathspec) && !has_symlinks) { - lt_debugprintf (__FILE__, __LINE__, - "checking path component for symlinks: %s\n", - tmp_pathspec); + LTWRAPPER_DEBUGPRINTF (("checking path component for symlinks: %s\n", + tmp_pathspec)); if (lstat (tmp_pathspec, &s) == 0) { if (S_ISLNK (s.st_mode) != 0) @@ -4762,9 +3793,8 @@ } else { - lt_fatal (__FILE__, __LINE__, - "error accessing file \"%s\": %s", - tmp_pathspec, nonnull (strerror (errno))); + char *errstr = strerror (errno); + lt_fatal ("Error accessing file %s (%s)", tmp_pathspec, errstr); } } XFREE (tmp_pathspec); @@ -4777,8 +3807,7 @@ tmp_pathspec = realpath (pathspec, buf); if (tmp_pathspec == 0) { - lt_fatal (__FILE__, __LINE__, - "could not follow symlinks for %s", pathspec); + lt_fatal ("Could not follow symlinks for %s", pathspec); } return xstrdup (tmp_pathspec); #endif @@ -4804,25 +3833,11 @@ return str; } -void -lt_debugprintf (const char *file, int line, const char *fmt, ...) -{ - va_list args; - if (lt_debug) - { - (void) fprintf (stderr, "%s:%s:%d: ", program_name, file, line); - va_start (args, fmt); - (void) vfprintf (stderr, fmt, args); - va_end (args); - } -} - static void -lt_error_core (int exit_status, const char *file, - int line, const char *mode, +lt_error_core (int exit_status, const char *mode, const char *message, va_list ap) { - fprintf (stderr, "%s:%s:%d: %s: ", program_name, file, line, mode); + fprintf (stderr, "%s: %s: ", program_name, mode); vfprintf (stderr, message, ap); fprintf (stderr, ".\n"); @@ -4831,32 +3846,20 @@ } void -lt_fatal (const char *file, int line, const char *message, ...) +lt_fatal (const char *message, ...) { va_list ap; va_start (ap, message); - lt_error_core (EXIT_FAILURE, file, line, "FATAL", message, ap); + lt_error_core (EXIT_FAILURE, "FATAL", message, ap); va_end (ap); } -static const char * -nonnull (const char *s) -{ - return s ? s : "(null)"; -} - -static const char * -nonempty (const char *s) -{ - return (s && !*s) ? "(empty)" : nonnull (s); -} - void lt_setenv (const char *name, const char *value) { - lt_debugprintf (__FILE__, __LINE__, - "(lt_setenv) setting '%s' to '%s'\n", - nonnull (name), nonnull (value)); + LTWRAPPER_DEBUGPRINTF (("(lt_setenv) setting '%s' to '%s'\n", + (name ? name : ""), + (value ? value : ""))); { #ifdef HAVE_SETENV /* always make a copy, for consistency with !HAVE_SETENV */ @@ -4901,12 +3904,95 @@ return new_value; } +int +lt_split_name_value (const char *arg, char** name, char** value) +{ + const char *p; + int len; + if (!arg || !*arg) + return 1; + + p = strchr (arg, (int)'='); + + if (!p) + return 1; + + *value = xstrdup (++p); + + len = strlen (arg) - strlen (*value); + *name = XMALLOC (char, len); + strncpy (*name, arg, len-1); + (*name)[len - 1] = '\0'; + + return 0; +} + +void +lt_opt_process_env_set (const char *arg) +{ + char *name = NULL; + char *value = NULL; + + if (lt_split_name_value (arg, &name, &value) != 0) + { + XFREE (name); + XFREE (value); + lt_fatal ("bad argument for %s: '%s'", env_set_opt, arg); + } + + lt_setenv (name, value); + XFREE (name); + XFREE (value); +} + +void +lt_opt_process_env_prepend (const char *arg) +{ + char *name = NULL; + char *value = NULL; + char *new_value = NULL; + + if (lt_split_name_value (arg, &name, &value) != 0) + { + XFREE (name); + XFREE (value); + lt_fatal ("bad argument for %s: '%s'", env_prepend_opt, arg); + } + + new_value = lt_extend_str (getenv (name), value, 0); + lt_setenv (name, new_value); + XFREE (new_value); + XFREE (name); + XFREE (value); +} + +void +lt_opt_process_env_append (const char *arg) +{ + char *name = NULL; + char *value = NULL; + char *new_value = NULL; + + if (lt_split_name_value (arg, &name, &value) != 0) + { + XFREE (name); + XFREE (value); + lt_fatal ("bad argument for %s: '%s'", env_append_opt, arg); + } + + new_value = lt_extend_str (getenv (name), value, 1); + lt_setenv (name, new_value); + XFREE (new_value); + XFREE (name); + XFREE (value); +} + void lt_update_exe_path (const char *name, const char *value) { - lt_debugprintf (__FILE__, __LINE__, - "(lt_update_exe_path) modifying '%s' by prepending '%s'\n", - nonnull (name), nonnull (value)); + LTWRAPPER_DEBUGPRINTF (("(lt_update_exe_path) modifying '%s' by prepending '%s'\n", + (name ? name : ""), + (value ? value : ""))); if (name && *name && value && *value) { @@ -4925,9 +4011,9 @@ void lt_update_lib_path (const char *name, const char *value) { - lt_debugprintf (__FILE__, __LINE__, - "(lt_update_lib_path) modifying '%s' by prepending '%s'\n", - nonnull (name), nonnull (value)); + LTWRAPPER_DEBUGPRINTF (("(lt_update_lib_path) modifying '%s' by prepending '%s'\n", + (name ? name : ""), + (value ? value : ""))); if (name && *name && value && *value) { @@ -4937,158 +4023,11 @@ } } -EOF - case $host_os in - mingw*) - cat <<"EOF" - -/* Prepares an argument vector before calling spawn(). - Note that spawn() does not by itself call the command interpreter - (getenv ("COMSPEC") != NULL ? getenv ("COMSPEC") : - ({ OSVERSIONINFO v; v.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); - GetVersionEx(&v); - v.dwPlatformId == VER_PLATFORM_WIN32_NT; - }) ? "cmd.exe" : "command.com"). - Instead it simply concatenates the arguments, separated by ' ', and calls - CreateProcess(). We must quote the arguments since Win32 CreateProcess() - interprets characters like ' ', '\t', '\\', '"' (but not '<' and '>') in a - special way: - - Space and tab are interpreted as delimiters. They are not treated as - delimiters if they are surrounded by double quotes: "...". - - Unescaped double quotes are removed from the input. Their only effect is - that within double quotes, space and tab are treated like normal - characters. - - Backslashes not followed by double quotes are not special. - - But 2*n+1 backslashes followed by a double quote become - n backslashes followed by a double quote (n >= 0): - \" -> " - \\\" -> \" - \\\\\" -> \\" - */ -#define SHELL_SPECIAL_CHARS "\"\\ \001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021\022\023\024\025\026\027\030\031\032\033\034\035\036\037" -#define SHELL_SPACE_CHARS " \001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021\022\023\024\025\026\027\030\031\032\033\034\035\036\037" -char ** -prepare_spawn (char **argv) -{ - size_t argc; - char **new_argv; - size_t i; - - /* Count number of arguments. */ - for (argc = 0; argv[argc] != NULL; argc++) - ; - - /* Allocate new argument vector. */ - new_argv = XMALLOC (char *, argc + 1); - - /* Put quoted arguments into the new argument vector. */ - for (i = 0; i < argc; i++) - { - const char *string = argv[i]; - - if (string[0] == '\0') - new_argv[i] = xstrdup ("\"\""); - else if (strpbrk (string, SHELL_SPECIAL_CHARS) != NULL) - { - int quote_around = (strpbrk (string, SHELL_SPACE_CHARS) != NULL); - size_t length; - unsigned int backslashes; - const char *s; - char *quoted_string; - char *p; - - length = 0; - backslashes = 0; - if (quote_around) - length++; - for (s = string; *s != '\0'; s++) - { - char c = *s; - if (c == '"') - length += backslashes + 1; - length++; - if (c == '\\') - backslashes++; - else - backslashes = 0; - } - if (quote_around) - length += backslashes + 1; - - quoted_string = XMALLOC (char, length + 1); - - p = quoted_string; - backslashes = 0; - if (quote_around) - *p++ = '"'; - for (s = string; *s != '\0'; s++) - { - char c = *s; - if (c == '"') - { - unsigned int j; - for (j = backslashes + 1; j > 0; j--) - *p++ = '\\'; - } - *p++ = c; - if (c == '\\') - backslashes++; - else - backslashes = 0; - } - if (quote_around) - { - unsigned int j; - for (j = backslashes; j > 0; j--) - *p++ = '\\'; - *p++ = '"'; - } - *p = '\0'; - - new_argv[i] = quoted_string; - } - else - new_argv[i] = (char *) string; - } - new_argv[argc] = NULL; - - return new_argv; -} -EOF - ;; - esac - - cat <<"EOF" -void lt_dump_script (FILE* f) -{ -EOF - func_emit_wrapper yes | - $SED -n -e ' -s/^\(.\{79\}\)\(..*\)/\1\ -\2/ -h -s/\([\\"]\)/\\\1/g -s/$/\\n/ -s/\([^\n]*\).*/ fputs ("\1", f);/p -g -D' - cat <<"EOF" -} + EOF } # end: func_emit_cwrapperexe_src -# func_win32_import_lib_p ARG -# True if ARG is an import lib, as indicated by $file_magic_cmd -func_win32_import_lib_p () -{ - $opt_debug - case `eval $file_magic_cmd \"\$1\" 2>/dev/null | $SED -e 10q` in - *import*) : ;; - *) false ;; - esac -} - # func_mode_link arg... func_mode_link () { @@ -5133,7 +4072,6 @@ new_inherited_linker_flags= avoid_version=no - bindir= dlfiles= dlprefiles= dlself=no @@ -5226,11 +4164,6 @@ esac case $prev in - bindir) - bindir="$arg" - prev= - continue - ;; dlfiles|dlprefiles) if test "$preload" = no; then # Add the symbol object into the linking commands. @@ -5262,9 +4195,9 @@ ;; *) if test "$prev" = dlfiles; then - func_append dlfiles " $arg" + dlfiles="$dlfiles $arg" else - func_append dlprefiles " $arg" + dlprefiles="$dlprefiles $arg" fi prev= continue @@ -5288,7 +4221,7 @@ *-*-darwin*) case "$deplibs " in *" $qarg.ltframework "*) ;; - *) func_append deplibs " $qarg.ltframework" # this is fixed later + *) deplibs="$deplibs $qarg.ltframework" # this is fixed later ;; esac ;; @@ -5307,7 +4240,7 @@ moreargs= for fil in `cat "$save_arg"` do -# func_append moreargs " $fil" +# moreargs="$moreargs $fil" arg=$fil # A libtool-controlled object. @@ -5336,7 +4269,7 @@ if test "$prev" = dlfiles; then if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then - func_append dlfiles " $pic_object" + dlfiles="$dlfiles $pic_object" prev= continue else @@ -5348,7 +4281,7 @@ # CHECK ME: I think I busted this. -Ossama if test "$prev" = dlprefiles; then # Preload the old-style object. - func_append dlprefiles " $pic_object" + dlprefiles="$dlprefiles $pic_object" prev= fi @@ -5418,12 +4351,12 @@ if test "$prev" = rpath; then case "$rpath " in *" $arg "*) ;; - *) func_append rpath " $arg" ;; + *) rpath="$rpath $arg" ;; esac else case "$xrpath " in *" $arg "*) ;; - *) func_append xrpath " $arg" ;; + *) xrpath="$xrpath $arg" ;; esac fi prev= @@ -5435,28 +4368,28 @@ continue ;; weak) - func_append weak_libs " $arg" + weak_libs="$weak_libs $arg" prev= continue ;; xcclinker) - func_append linker_flags " $qarg" - func_append compiler_flags " $qarg" + linker_flags="$linker_flags $qarg" + compiler_flags="$compiler_flags $qarg" prev= func_append compile_command " $qarg" func_append finalize_command " $qarg" continue ;; xcompiler) - func_append compiler_flags " $qarg" + compiler_flags="$compiler_flags $qarg" prev= func_append compile_command " $qarg" func_append finalize_command " $qarg" continue ;; xlinker) - func_append linker_flags " $qarg" - func_append compiler_flags " $wl$qarg" + linker_flags="$linker_flags $qarg" + compiler_flags="$compiler_flags $wl$qarg" prev= func_append compile_command " $wl$qarg" func_append finalize_command " $wl$qarg" @@ -5492,11 +4425,6 @@ continue ;; - -bindir) - prev=bindir - continue - ;; - -dlopen) prev=dlfiles continue @@ -5547,16 +4475,15 @@ ;; -L*) - func_stripname "-L" '' "$arg" - if test -z "$func_stripname_result"; then + func_stripname '-L' '' "$arg" + dir=$func_stripname_result + if test -z "$dir"; then if test "$#" -gt 0; then func_fatal_error "require no space between \`-L' and \`$1'" else func_fatal_error "need path for \`-L' option" fi fi - func_resolve_sysroot "$func_stripname_result" - dir=$func_resolve_sysroot_result # We need an absolute path. case $dir in [\\/]* | [A-Za-z]:[\\/]*) ;; @@ -5568,30 +4495,24 @@ ;; esac case "$deplibs " in - *" -L$dir "* | *" $arg "*) - # Will only happen for absolute or sysroot arguments - ;; + *" -L$dir "*) ;; *) - # Preserve sysroot, but never include relative directories - case $dir in - [\\/]* | [A-Za-z]:[\\/]* | =*) func_append deplibs " $arg" ;; - *) func_append deplibs " -L$dir" ;; - esac - func_append lib_search_path " $dir" + deplibs="$deplibs -L$dir" + lib_search_path="$lib_search_path $dir" ;; esac case $host in *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) - testbindir=`$ECHO "$dir" | $SED 's*/lib$*/bin*'` + testbindir=`$ECHO "X$dir" | $Xsed -e 's*/lib$*/bin*'` case :$dllsearchpath: in *":$dir:"*) ;; ::) dllsearchpath=$dir;; - *) func_append dllsearchpath ":$dir";; + *) dllsearchpath="$dllsearchpath:$dir";; esac case :$dllsearchpath: in *":$testbindir:"*) ;; ::) dllsearchpath=$testbindir;; - *) func_append dllsearchpath ":$testbindir";; + *) dllsearchpath="$dllsearchpath:$testbindir";; esac ;; esac @@ -5601,7 +4522,7 @@ -l*) if test "X$arg" = "X-lc" || test "X$arg" = "X-lm"; then case $host in - *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos* | *-cegcc* | *-*-haiku*) + *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos* | *-cegcc*) # These systems don't actually have a C or math library (as such) continue ;; @@ -5615,7 +4536,7 @@ ;; *-*-rhapsody* | *-*-darwin1.[012]) # Rhapsody C and math libraries are in the System framework - func_append deplibs " System.ltframework" + deplibs="$deplibs System.ltframework" continue ;; *-*-sco3.2v5* | *-*-sco5v6*) @@ -5635,7 +4556,7 @@ ;; esac fi - func_append deplibs " $arg" + deplibs="$deplibs $arg" continue ;; @@ -5647,22 +4568,21 @@ # Tru64 UNIX uses -model [arg] to determine the layout of C++ # classes, name mangling, and exception handling. # Darwin uses the -arch flag to determine output architecture. - -model|-arch|-isysroot|--sysroot) - func_append compiler_flags " $arg" + -model|-arch|-isysroot) + compiler_flags="$compiler_flags $arg" func_append compile_command " $arg" func_append finalize_command " $arg" prev=xcompiler continue ;; - -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \ - |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*) - func_append compiler_flags " $arg" + -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe|-threads) + compiler_flags="$compiler_flags $arg" func_append compile_command " $arg" func_append finalize_command " $arg" case "$new_inherited_linker_flags " in *" $arg "*) ;; - * ) func_append new_inherited_linker_flags " $arg" ;; + * ) new_inherited_linker_flags="$new_inherited_linker_flags $arg" ;; esac continue ;; @@ -5729,17 +4649,13 @@ # We need an absolute path. case $dir in [\\/]* | [A-Za-z]:[\\/]*) ;; - =*) - func_stripname '=' '' "$dir" - dir=$lt_sysroot$func_stripname_result - ;; *) func_fatal_error "only absolute run-paths are allowed" ;; esac case "$xrpath " in *" $dir "*) ;; - *) func_append xrpath " $dir" ;; + *) xrpath="$xrpath $dir" ;; esac continue ;; @@ -5792,8 +4708,8 @@ for flag in $args; do IFS="$save_ifs" func_quote_for_eval "$flag" - func_append arg " $func_quote_for_eval_result" - func_append compiler_flags " $func_quote_for_eval_result" + arg="$arg $wl$func_quote_for_eval_result" + compiler_flags="$compiler_flags $func_quote_for_eval_result" done IFS="$save_ifs" func_stripname ' ' '' "$arg" @@ -5808,9 +4724,9 @@ for flag in $args; do IFS="$save_ifs" func_quote_for_eval "$flag" - func_append arg " $wl$func_quote_for_eval_result" - func_append compiler_flags " $wl$func_quote_for_eval_result" - func_append linker_flags " $func_quote_for_eval_result" + arg="$arg $wl$func_quote_for_eval_result" + compiler_flags="$compiler_flags $wl$func_quote_for_eval_result" + linker_flags="$linker_flags $func_quote_for_eval_result" done IFS="$save_ifs" func_stripname ' ' '' "$arg" @@ -5838,27 +4754,23 @@ arg="$func_quote_for_eval_result" ;; - # Flags to be passed through unchanged, with rationale: - # -64, -mips[0-9] enable 64-bit mode for the SGI compiler - # -r[0-9][0-9]* specify processor for the SGI compiler - # -xarch=*, -xtarget=* enable 64-bit mode for the Sun compiler - # +DA*, +DD* enable 64-bit mode for the HP compiler - # -q* compiler args for the IBM compiler - # -m*, -t[45]*, -txscale* architecture-specific flags for GCC - # -F/path path to uninstalled frameworks, gcc on darwin - # -p, -pg, --coverage, -fprofile-* profiling flags for GCC - # @file GCC response files - # -tp=* Portland pgcc target processor selection - # --sysroot=* for sysroot support - # -O*, -flto*, -fwhopr*, -fuse-linker-plugin GCC link-time optimization + # -64, -mips[0-9] enable 64-bit mode on the SGI compiler + # -r[0-9][0-9]* specifies the processor on the SGI compiler + # -xarch=*, -xtarget=* enable 64-bit mode on the Sun compiler + # +DA*, +DD* enable 64-bit mode on the HP compiler + # -q* pass through compiler args for the IBM compiler + # -m*, -t[45]*, -txscale* pass through architecture-specific + # compiler args for GCC + # -F/path gives path to uninstalled frameworks, gcc on darwin + # -p, -pg, --coverage, -fprofile-* pass through profiling flag for GCC + # @file GCC response files -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \ - -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*|-tp=*|--sysroot=*| \ - -O*|-flto*|-fwhopr*|-fuse-linker-plugin) + -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*) func_quote_for_eval "$arg" arg="$func_quote_for_eval_result" func_append compile_command " $arg" func_append finalize_command " $arg" - func_append compiler_flags " $arg" + compiler_flags="$compiler_flags $arg" continue ;; @@ -5870,7 +4782,7 @@ *.$objext) # A standard object. - func_append objs " $arg" + objs="$objs $arg" ;; *.lo) @@ -5901,7 +4813,7 @@ if test "$prev" = dlfiles; then if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then - func_append dlfiles " $pic_object" + dlfiles="$dlfiles $pic_object" prev= continue else @@ -5913,7 +4825,7 @@ # CHECK ME: I think I busted this. -Ossama if test "$prev" = dlprefiles; then # Preload the old-style object. - func_append dlprefiles " $pic_object" + dlprefiles="$dlprefiles $pic_object" prev= fi @@ -5958,25 +4870,24 @@ *.$libext) # An archive. - func_append deplibs " $arg" - func_append old_deplibs " $arg" + deplibs="$deplibs $arg" + old_deplibs="$old_deplibs $arg" continue ;; *.la) # A libtool-controlled library. - func_resolve_sysroot "$arg" if test "$prev" = dlfiles; then # This library was specified with -dlopen. - func_append dlfiles " $func_resolve_sysroot_result" + dlfiles="$dlfiles $arg" prev= elif test "$prev" = dlprefiles; then # The library was specified with -dlpreopen. - func_append dlprefiles " $func_resolve_sysroot_result" + dlprefiles="$dlprefiles $arg" prev= else - func_append deplibs " $func_resolve_sysroot_result" + deplibs="$deplibs $arg" fi continue ;; @@ -6014,7 +4925,7 @@ if test -n "$shlibpath_var"; then # get the directories listed in $shlibpath_var - eval shlib_search_path=\`\$ECHO \"\${$shlibpath_var}\" \| \$SED \'s/:/ /g\'\` + eval shlib_search_path=\`\$ECHO \"X\${$shlibpath_var}\" \| \$Xsed -e \'s/:/ /g\'\` else shlib_search_path= fi @@ -6023,8 +4934,6 @@ func_dirname "$output" "/" "" output_objdir="$func_dirname_result$objdir" - func_to_tool_file "$output_objdir/" - tool_output_objdir=$func_to_tool_file_result # Create the object directory. func_mkdir_p "$output_objdir" @@ -6045,12 +4954,12 @@ # Find all interdependent deplibs by searching for libraries # that are linked more than once (e.g. -la -lb -la) for deplib in $deplibs; do - if $opt_preserve_dup_deps ; then + if $opt_duplicate_deps ; then case "$libs " in - *" $deplib "*) func_append specialdeplibs " $deplib" ;; + *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;; esac fi - func_append libs " $deplib" + libs="$libs $deplib" done if test "$linkmode" = lib; then @@ -6063,9 +4972,9 @@ if $opt_duplicate_compiler_generated_deps; then for pre_post_dep in $predeps $postdeps; do case "$pre_post_deps " in - *" $pre_post_dep "*) func_append specialdeplibs " $pre_post_deps" ;; + *" $pre_post_dep "*) specialdeplibs="$specialdeplibs $pre_post_deps" ;; esac - func_append pre_post_deps " $pre_post_dep" + pre_post_deps="$pre_post_deps $pre_post_dep" done fi pre_post_deps= @@ -6132,19 +5041,17 @@ for lib in $dlprefiles; do # Ignore non-libtool-libs dependency_libs= - func_resolve_sysroot "$lib" case $lib in - *.la) func_source "$func_resolve_sysroot_result" ;; + *.la) func_source "$lib" ;; esac # Collect preopened libtool deplibs, except any this library # has declared as weak libs for deplib in $dependency_libs; do - func_basename "$deplib" - deplib_base=$func_basename_result + deplib_base=`$ECHO "X$deplib" | $Xsed -e "$basename"` case " $weak_libs " in *" $deplib_base "*) ;; - *) func_append deplibs " $deplib" ;; + *) deplibs="$deplibs $deplib" ;; esac done done @@ -6160,17 +5067,16 @@ lib= found=no case $deplib in - -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \ - |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*) + -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe|-threads) if test "$linkmode,$pass" = "prog,link"; then compile_deplibs="$deplib $compile_deplibs" finalize_deplibs="$deplib $finalize_deplibs" else - func_append compiler_flags " $deplib" + compiler_flags="$compiler_flags $deplib" if test "$linkmode" = lib ; then case "$new_inherited_linker_flags " in *" $deplib "*) ;; - * ) func_append new_inherited_linker_flags " $deplib" ;; + * ) new_inherited_linker_flags="$new_inherited_linker_flags $deplib" ;; esac fi fi @@ -6255,7 +5161,7 @@ if test "$linkmode" = lib ; then case "$new_inherited_linker_flags " in *" $deplib "*) ;; - * ) func_append new_inherited_linker_flags " $deplib" ;; + * ) new_inherited_linker_flags="$new_inherited_linker_flags $deplib" ;; esac fi fi @@ -6268,8 +5174,7 @@ test "$pass" = conv && continue newdependency_libs="$deplib $newdependency_libs" func_stripname '-L' '' "$deplib" - func_resolve_sysroot "$func_stripname_result" - func_append newlib_search_path " $func_resolve_sysroot_result" + newlib_search_path="$newlib_search_path $func_stripname_result" ;; prog) if test "$pass" = conv; then @@ -6283,8 +5188,7 @@ finalize_deplibs="$deplib $finalize_deplibs" fi func_stripname '-L' '' "$deplib" - func_resolve_sysroot "$func_stripname_result" - func_append newlib_search_path " $func_resolve_sysroot_result" + newlib_search_path="$newlib_search_path $func_stripname_result" ;; *) func_warning "\`-L' is ignored for archives/objects" @@ -6295,21 +5199,17 @@ -R*) if test "$pass" = link; then func_stripname '-R' '' "$deplib" - func_resolve_sysroot "$func_stripname_result" - dir=$func_resolve_sysroot_result + dir=$func_stripname_result # Make sure the xrpath contains only unique directories. case "$xrpath " in *" $dir "*) ;; - *) func_append xrpath " $dir" ;; + *) xrpath="$xrpath $dir" ;; esac fi deplibs="$deplib $deplibs" continue ;; - *.la) - func_resolve_sysroot "$deplib" - lib=$func_resolve_sysroot_result - ;; + *.la) lib="$deplib" ;; *.$libext) if test "$pass" = conv; then deplibs="$deplib $deplibs" @@ -6327,7 +5227,7 @@ match_pattern*) set dummy $deplibs_check_method; shift match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` - if eval "\$ECHO \"$deplib\"" 2>/dev/null | $SED 10q \ + if eval "\$ECHO \"X$deplib\"" 2>/dev/null | $Xsed -e 10q \ | $EGREP "$match_pattern_regex" > /dev/null; then valid_a_lib=yes fi @@ -6337,15 +5237,15 @@ ;; esac if test "$valid_a_lib" != yes; then - echo + $ECHO $ECHO "*** Warning: Trying to link with static lib archive $deplib." - echo "*** I have the capability to make that library automatically link in when" - echo "*** you link to this library. But I can only do this if you have a" - echo "*** shared version of the library, which you do not appear to have" - echo "*** because the file extensions .$libext of this argument makes me believe" - echo "*** that it is just a static archive that I should not use here." + $ECHO "*** I have the capability to make that library automatically link in when" + $ECHO "*** you link to this library. But I can only do this if you have a" + $ECHO "*** shared version of the library, which you do not appear to have" + $ECHO "*** because the file extensions .$libext of this argument makes me believe" + $ECHO "*** that it is just a static archive that I should not use here." else - echo + $ECHO $ECHO "*** Warning: Linking the shared library $output against the" $ECHO "*** static library $deplib is not portable!" deplibs="$deplib $deplibs" @@ -6372,11 +5272,11 @@ if test "$pass" = dlpreopen || test "$dlopen_support" != yes || test "$build_libtool_libs" = no; then # If there is no dlopen support or we're linking statically, # we need to preload. - func_append newdlprefiles " $deplib" + newdlprefiles="$newdlprefiles $deplib" compile_deplibs="$deplib $compile_deplibs" finalize_deplibs="$deplib $finalize_deplibs" else - func_append newdlfiles " $deplib" + newdlfiles="$newdlfiles $deplib" fi fi continue @@ -6418,20 +5318,20 @@ # Convert "-framework foo" to "foo.ltframework" if test -n "$inherited_linker_flags"; then - tmp_inherited_linker_flags=`$ECHO "$inherited_linker_flags" | $SED 's/-framework \([^ $]*\)/\1.ltframework/g'` + tmp_inherited_linker_flags=`$ECHO "X$inherited_linker_flags" | $Xsed -e 's/-framework \([^ $]*\)/\1.ltframework/g'` for tmp_inherited_linker_flag in $tmp_inherited_linker_flags; do case " $new_inherited_linker_flags " in *" $tmp_inherited_linker_flag "*) ;; - *) func_append new_inherited_linker_flags " $tmp_inherited_linker_flag";; + *) new_inherited_linker_flags="$new_inherited_linker_flags $tmp_inherited_linker_flag";; esac done fi - dependency_libs=`$ECHO " $dependency_libs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` + dependency_libs=`$ECHO "X $dependency_libs" | $Xsed -e 's% \([^ $]*\).ltframework% -framework \1%g'` if test "$linkmode,$pass" = "lib,link" || test "$linkmode,$pass" = "prog,scan" || { test "$linkmode" != prog && test "$linkmode" != lib; }; then - test -n "$dlopen" && func_append dlfiles " $dlopen" - test -n "$dlpreopen" && func_append dlprefiles " $dlpreopen" + test -n "$dlopen" && dlfiles="$dlfiles $dlopen" + test -n "$dlpreopen" && dlprefiles="$dlprefiles $dlpreopen" fi if test "$pass" = conv; then @@ -6442,20 +5342,20 @@ func_fatal_error "cannot find name of link library for \`$lib'" fi # It is a libtool convenience library, so add in its objects. - func_append convenience " $ladir/$objdir/$old_library" - func_append old_convenience " $ladir/$objdir/$old_library" + convenience="$convenience $ladir/$objdir/$old_library" + old_convenience="$old_convenience $ladir/$objdir/$old_library" elif test "$linkmode" != prog && test "$linkmode" != lib; then func_fatal_error "\`$lib' is not a convenience library" fi tmp_libs= for deplib in $dependency_libs; do deplibs="$deplib $deplibs" - if $opt_preserve_dup_deps ; then + if $opt_duplicate_deps ; then case "$tmp_libs " in - *" $deplib "*) func_append specialdeplibs " $deplib" ;; + *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;; esac fi - func_append tmp_libs " $deplib" + tmp_libs="$tmp_libs $deplib" done continue fi # $pass = conv @@ -6463,15 +5363,9 @@ # Get the name of the library we link against. linklib= - if test -n "$old_library" && - { test "$prefer_static_libs" = yes || - test "$prefer_static_libs,$installed" = "built,no"; }; then - linklib=$old_library - else - for l in $old_library $library_names; do - linklib="$l" - done - fi + for l in $old_library $library_names; do + linklib="$l" + done if test -z "$linklib"; then func_fatal_error "cannot find name of link library for \`$lib'" fi @@ -6488,9 +5382,9 @@ # statically, we need to preload. We also need to preload any # dependent libraries so libltdl's deplib preloader doesn't # bomb out in the load deplibs phase. - func_append dlprefiles " $lib $dependency_libs" + dlprefiles="$dlprefiles $lib $dependency_libs" else - func_append newdlfiles " $lib" + newdlfiles="$newdlfiles $lib" fi continue fi # $pass = dlopen @@ -6512,14 +5406,14 @@ # Find the relevant object directory and library name. if test "X$installed" = Xyes; then - if test ! -f "$lt_sysroot$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then + if test ! -f "$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then func_warning "library \`$lib' was moved." dir="$ladir" absdir="$abs_ladir" libdir="$abs_ladir" else - dir="$lt_sysroot$libdir" - absdir="$lt_sysroot$libdir" + dir="$libdir" + absdir="$libdir" fi test "X$hardcode_automatic" = Xyes && avoidtemprpath=yes else @@ -6527,12 +5421,12 @@ dir="$ladir" absdir="$abs_ladir" # Remove this search path later - func_append notinst_path " $abs_ladir" + notinst_path="$notinst_path $abs_ladir" else dir="$ladir/$objdir" absdir="$abs_ladir/$objdir" # Remove this search path later - func_append notinst_path " $abs_ladir" + notinst_path="$notinst_path $abs_ladir" fi fi # $installed = yes func_stripname 'lib' '.la' "$laname" @@ -6543,46 +5437,20 @@ if test -z "$libdir" && test "$linkmode" = prog; then func_fatal_error "only libraries may -dlpreopen a convenience library: \`$lib'" fi - case "$host" in - # special handling for platforms with PE-DLLs. - *cygwin* | *mingw* | *cegcc* ) - # Linker will automatically link against shared library if both - # static and shared are present. Therefore, ensure we extract - # symbols from the import library if a shared library is present - # (otherwise, the dlopen module name will be incorrect). We do - # this by putting the import library name into $newdlprefiles. - # We recover the dlopen module name by 'saving' the la file - # name in a special purpose variable, and (later) extracting the - # dlname from the la file. - if test -n "$dlname"; then - func_tr_sh "$dir/$linklib" - eval "libfile_$func_tr_sh_result=\$abs_ladir/\$laname" - func_append newdlprefiles " $dir/$linklib" - else - func_append newdlprefiles " $dir/$old_library" - # Keep a list of preopened convenience libraries to check - # that they are being used correctly in the link pass. - test -z "$libdir" && \ - func_append dlpreconveniencelibs " $dir/$old_library" - fi - ;; - * ) - # Prefer using a static library (so that no silly _DYNAMIC symbols - # are required to link). - if test -n "$old_library"; then - func_append newdlprefiles " $dir/$old_library" - # Keep a list of preopened convenience libraries to check - # that they are being used correctly in the link pass. - test -z "$libdir" && \ - func_append dlpreconveniencelibs " $dir/$old_library" - # Otherwise, use the dlname, so that lt_dlopen finds it. - elif test -n "$dlname"; then - func_append newdlprefiles " $dir/$dlname" - else - func_append newdlprefiles " $dir/$linklib" - fi - ;; - esac + # Prefer using a static library (so that no silly _DYNAMIC symbols + # are required to link). + if test -n "$old_library"; then + newdlprefiles="$newdlprefiles $dir/$old_library" + # Keep a list of preopened convenience libraries to check + # that they are being used correctly in the link pass. + test -z "$libdir" && \ + dlpreconveniencelibs="$dlpreconveniencelibs $dir/$old_library" + # Otherwise, use the dlname, so that lt_dlopen finds it. + elif test -n "$dlname"; then + newdlprefiles="$newdlprefiles $dir/$dlname" + else + newdlprefiles="$newdlprefiles $dir/$linklib" + fi fi # $pass = dlpreopen if test -z "$libdir"; then @@ -6600,7 +5468,7 @@ if test "$linkmode" = prog && test "$pass" != link; then - func_append newlib_search_path " $ladir" + newlib_search_path="$newlib_search_path $ladir" deplibs="$lib $deplibs" linkalldeplibs=no @@ -6613,8 +5481,7 @@ for deplib in $dependency_libs; do case $deplib in -L*) func_stripname '-L' '' "$deplib" - func_resolve_sysroot "$func_stripname_result" - func_append newlib_search_path " $func_resolve_sysroot_result" + newlib_search_path="$newlib_search_path $func_stripname_result" ;; esac # Need to link against all dependency_libs? @@ -6625,12 +5492,12 @@ # or/and link against static libraries newdependency_libs="$deplib $newdependency_libs" fi - if $opt_preserve_dup_deps ; then + if $opt_duplicate_deps ; then case "$tmp_libs " in - *" $deplib "*) func_append specialdeplibs " $deplib" ;; + *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;; esac fi - func_append tmp_libs " $deplib" + tmp_libs="$tmp_libs $deplib" done # for deplib continue fi # $linkmode = prog... @@ -6645,7 +5512,7 @@ # Make sure the rpath contains only unique directories. case "$temp_rpath:" in *"$absdir:"*) ;; - *) func_append temp_rpath "$absdir:" ;; + *) temp_rpath="$temp_rpath$absdir:" ;; esac fi @@ -6657,7 +5524,7 @@ *) case "$compile_rpath " in *" $absdir "*) ;; - *) func_append compile_rpath " $absdir" ;; + *) compile_rpath="$compile_rpath $absdir" esac ;; esac @@ -6666,7 +5533,7 @@ *) case "$finalize_rpath " in *" $libdir "*) ;; - *) func_append finalize_rpath " $libdir" ;; + *) finalize_rpath="$finalize_rpath $libdir" esac ;; esac @@ -6691,12 +5558,12 @@ case $host in *cygwin* | *mingw* | *cegcc*) # No point in relinking DLLs because paths are not encoded - func_append notinst_deplibs " $lib" + notinst_deplibs="$notinst_deplibs $lib" need_relink=no ;; *) if test "$installed" = no; then - func_append notinst_deplibs " $lib" + notinst_deplibs="$notinst_deplibs $lib" need_relink=yes fi ;; @@ -6713,7 +5580,7 @@ fi done if test -z "$dlopenmodule" && test "$shouldnotlink" = yes && test "$pass" = link; then - echo + $ECHO if test "$linkmode" = prog; then $ECHO "*** Warning: Linking the executable $output against the loadable module" else @@ -6731,7 +5598,7 @@ *) case "$compile_rpath " in *" $absdir "*) ;; - *) func_append compile_rpath " $absdir" ;; + *) compile_rpath="$compile_rpath $absdir" esac ;; esac @@ -6740,7 +5607,7 @@ *) case "$finalize_rpath " in *" $libdir "*) ;; - *) func_append finalize_rpath " $libdir" ;; + *) finalize_rpath="$finalize_rpath $libdir" esac ;; esac @@ -6794,7 +5661,7 @@ linklib=$newlib fi # test -n "$old_archive_from_expsyms_cmds" - if test "$linkmode" = prog || test "$opt_mode" != relink; then + if test "$linkmode" = prog || test "$mode" != relink; then add_shlibpath= add_dir= add= @@ -6816,9 +5683,9 @@ if test "X$dlopenmodule" != "X$lib"; then $ECHO "*** Warning: lib $linklib is a module, not a shared library" if test -z "$old_library" ; then - echo - echo "*** And there doesn't seem to be a static archive available" - echo "*** The link will probably fail, sorry" + $ECHO + $ECHO "*** And there doesn't seem to be a static archive available" + $ECHO "*** The link will probably fail, sorry" else add="$dir/$old_library" fi @@ -6845,12 +5712,12 @@ test "$hardcode_direct_absolute" = no; then add="$dir/$linklib" elif test "$hardcode_minus_L" = yes; then - add_dir="-L$absdir" + add_dir="-L$dir" # Try looking first in the location we're being installed to. if test -n "$inst_prefix_dir"; then case $libdir in [\\/]*) - func_append add_dir " -L$inst_prefix_dir$libdir" + add_dir="$add_dir -L$inst_prefix_dir$libdir" ;; esac fi @@ -6872,7 +5739,7 @@ if test -n "$add_shlibpath"; then case :$compile_shlibpath: in *":$add_shlibpath:"*) ;; - *) func_append compile_shlibpath "$add_shlibpath:" ;; + *) compile_shlibpath="$compile_shlibpath$add_shlibpath:" ;; esac fi if test "$linkmode" = prog; then @@ -6886,13 +5753,13 @@ test "$hardcode_shlibpath_var" = yes; then case :$finalize_shlibpath: in *":$libdir:"*) ;; - *) func_append finalize_shlibpath "$libdir:" ;; + *) finalize_shlibpath="$finalize_shlibpath$libdir:" ;; esac fi fi fi - if test "$linkmode" = prog || test "$opt_mode" = relink; then + if test "$linkmode" = prog || test "$mode" = relink; then add_shlibpath= add_dir= add= @@ -6906,7 +5773,7 @@ elif test "$hardcode_shlibpath_var" = yes; then case :$finalize_shlibpath: in *":$libdir:"*) ;; - *) func_append finalize_shlibpath "$libdir:" ;; + *) finalize_shlibpath="$finalize_shlibpath$libdir:" ;; esac add="-l$name" elif test "$hardcode_automatic" = yes; then @@ -6923,7 +5790,7 @@ if test -n "$inst_prefix_dir"; then case $libdir in [\\/]*) - func_append add_dir " -L$inst_prefix_dir$libdir" + add_dir="$add_dir -L$inst_prefix_dir$libdir" ;; esac fi @@ -6958,21 +5825,21 @@ # Just print a warning and add the library to dependency_libs so # that the program can be linked against the static library. - echo + $ECHO $ECHO "*** Warning: This system can not link to static lib archive $lib." - echo "*** I have the capability to make that library automatically link in when" - echo "*** you link to this library. But I can only do this if you have a" - echo "*** shared version of the library, which you do not appear to have." + $ECHO "*** I have the capability to make that library automatically link in when" + $ECHO "*** you link to this library. But I can only do this if you have a" + $ECHO "*** shared version of the library, which you do not appear to have." if test "$module" = yes; then - echo "*** But as you try to build a module library, libtool will still create " - echo "*** a static module, that should work as long as the dlopening application" - echo "*** is linked with the -dlopen flag to resolve symbols at runtime." + $ECHO "*** But as you try to build a module library, libtool will still create " + $ECHO "*** a static module, that should work as long as the dlopening application" + $ECHO "*** is linked with the -dlopen flag to resolve symbols at runtime." if test -z "$global_symbol_pipe"; then - echo - echo "*** However, this would only work if libtool was able to extract symbol" - echo "*** lists from a program, using \`nm' or equivalent, but libtool could" - echo "*** not find such a program. So, this module is probably useless." - echo "*** \`nm' from GNU binutils and a full rebuild may help." + $ECHO + $ECHO "*** However, this would only work if libtool was able to extract symbol" + $ECHO "*** lists from a program, using \`nm' or equivalent, but libtool could" + $ECHO "*** not find such a program. So, this module is probably useless." + $ECHO "*** \`nm' from GNU binutils and a full rebuild may help." fi if test "$build_old_libs" = no; then build_libtool_libs=module @@ -7000,46 +5867,37 @@ temp_xrpath=$func_stripname_result case " $xrpath " in *" $temp_xrpath "*) ;; - *) func_append xrpath " $temp_xrpath";; + *) xrpath="$xrpath $temp_xrpath";; esac;; - *) func_append temp_deplibs " $libdir";; + *) temp_deplibs="$temp_deplibs $libdir";; esac done dependency_libs="$temp_deplibs" fi - func_append newlib_search_path " $absdir" + newlib_search_path="$newlib_search_path $absdir" # Link against this library test "$link_static" = no && newdependency_libs="$abs_ladir/$laname $newdependency_libs" # ... and its dependency_libs tmp_libs= for deplib in $dependency_libs; do newdependency_libs="$deplib $newdependency_libs" - case $deplib in - -L*) func_stripname '-L' '' "$deplib" - func_resolve_sysroot "$func_stripname_result";; - *) func_resolve_sysroot "$deplib" ;; - esac - if $opt_preserve_dup_deps ; then + if $opt_duplicate_deps ; then case "$tmp_libs " in - *" $func_resolve_sysroot_result "*) - func_append specialdeplibs " $func_resolve_sysroot_result" ;; + *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;; esac fi - func_append tmp_libs " $func_resolve_sysroot_result" + tmp_libs="$tmp_libs $deplib" done if test "$link_all_deplibs" != no; then # Add the search paths of all dependency libraries for deplib in $dependency_libs; do - path= case $deplib in -L*) path="$deplib" ;; *.la) - func_resolve_sysroot "$deplib" - deplib=$func_resolve_sysroot_result func_dirname "$deplib" "" "." - dir=$func_dirname_result + dir="$func_dirname_result" # We need an absolute path. case $dir in [\\/]* | [A-Za-z]:[\\/]*) absdir="$dir" ;; @@ -7066,8 +5924,8 @@ if test -z "$darwin_install_name"; then darwin_install_name=`${OTOOL64} -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'` fi - func_append compiler_flags " ${wl}-dylib_file ${wl}${darwin_install_name}:${depdepl}" - func_append linker_flags " -dylib_file ${darwin_install_name}:${depdepl}" + compiler_flags="$compiler_flags ${wl}-dylib_file ${wl}${darwin_install_name}:${depdepl}" + linker_flags="$linker_flags -dylib_file ${darwin_install_name}:${depdepl}" path= fi fi @@ -7100,7 +5958,7 @@ compile_deplibs="$new_inherited_linker_flags $compile_deplibs" finalize_deplibs="$new_inherited_linker_flags $finalize_deplibs" else - compiler_flags="$compiler_flags "`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` + compiler_flags="$compiler_flags "`$ECHO "X $new_inherited_linker_flags" | $Xsed -e 's% \([^ $]*\).ltframework% -framework \1%g'` fi fi dependency_libs="$newdependency_libs" @@ -7117,7 +5975,7 @@ for dir in $newlib_search_path; do case "$lib_search_path " in *" $dir "*) ;; - *) func_append lib_search_path " $dir" ;; + *) lib_search_path="$lib_search_path $dir" ;; esac done newlib_search_path= @@ -7175,10 +6033,10 @@ -L*) case " $tmp_libs " in *" $deplib "*) ;; - *) func_append tmp_libs " $deplib" ;; + *) tmp_libs="$tmp_libs $deplib" ;; esac ;; - *) func_append tmp_libs " $deplib" ;; + *) tmp_libs="$tmp_libs $deplib" ;; esac done eval $var=\"$tmp_libs\" @@ -7194,7 +6052,7 @@ ;; esac if test -n "$i" ; then - func_append tmp_libs " $i" + tmp_libs="$tmp_libs $i" fi done dependency_libs=$tmp_libs @@ -7235,7 +6093,7 @@ # Now set the variables for building old libraries. build_libtool_libs=no oldlibs="$output" - func_append objs "$old_deplibs" + objs="$objs$old_deplibs" ;; lib) @@ -7268,10 +6126,10 @@ if test "$deplibs_check_method" != pass_all; then func_fatal_error "cannot build libtool library \`$output' from non-libtool objects on this host:$objs" else - echo + $ECHO $ECHO "*** Warning: Linking the shared library $output against the non-libtool" $ECHO "*** objects $objs is not portable!" - func_append libobjs " $objs" + libobjs="$libobjs $objs" fi fi @@ -7330,14 +6188,13 @@ # which has an extra 1 added just for fun # case $version_type in - # correct linux to gnu/linux during the next big refactor darwin|linux|osf|windows|none) func_arith $number_major + $number_minor current=$func_arith_result age="$number_minor" revision="$number_revision" ;; - freebsd-aout|freebsd-elf|qnx|sunos) + freebsd-aout|freebsd-elf|sunos) current="$number_major" revision="$number_minor" age="0" @@ -7447,7 +6304,7 @@ versuffix="$major.$revision" ;; - linux) # correct to gnu/linux during the next big refactor + linux) func_arith $current - $age major=.$func_arith_result versuffix="$major.$age.$revision" @@ -7470,7 +6327,7 @@ done # Make executables depend on our current version. - func_append verstring ":${current}.0" + verstring="$verstring:${current}.0" ;; qnx) @@ -7538,10 +6395,10 @@ fi func_generate_dlsyms "$libname" "$libname" "yes" - func_append libobjs " $symfileobj" + libobjs="$libobjs $symfileobj" test "X$libobjs" = "X " && libobjs= - if test "$opt_mode" != relink; then + if test "$mode" != relink; then # Remove our outputs, but don't remove object files since they # may have been created when compiling PIC objects. removelist= @@ -7557,7 +6414,7 @@ continue fi fi - func_append removelist " $p" + removelist="$removelist $p" ;; *) ;; esac @@ -7568,28 +6425,27 @@ # Now set the variables for building old libraries. if test "$build_old_libs" = yes && test "$build_libtool_libs" != convenience ; then - func_append oldlibs " $output_objdir/$libname.$libext" + oldlibs="$oldlibs $output_objdir/$libname.$libext" # Transform .lo files to .o files. - oldobjs="$objs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.${libext}$/d; $lo2o" | $NL2SP` + oldobjs="$objs "`$ECHO "X$libobjs" | $SP2NL | $Xsed -e '/\.'${libext}'$/d' -e "$lo2o" | $NL2SP` fi # Eliminate all temporary directories. #for path in $notinst_path; do - # lib_search_path=`$ECHO "$lib_search_path " | $SED "s% $path % %g"` - # deplibs=`$ECHO "$deplibs " | $SED "s% -L$path % %g"` - # dependency_libs=`$ECHO "$dependency_libs " | $SED "s% -L$path % %g"` + # lib_search_path=`$ECHO "X$lib_search_path " | $Xsed -e "s% $path % %g"` + # deplibs=`$ECHO "X$deplibs " | $Xsed -e "s% -L$path % %g"` + # dependency_libs=`$ECHO "X$dependency_libs " | $Xsed -e "s% -L$path % %g"` #done if test -n "$xrpath"; then # If the user specified any rpath flags, then add them. temp_xrpath= for libdir in $xrpath; do - func_replace_sysroot "$libdir" - func_append temp_xrpath " -R$func_replace_sysroot_result" + temp_xrpath="$temp_xrpath -R$libdir" case "$finalize_rpath " in *" $libdir "*) ;; - *) func_append finalize_rpath " $libdir" ;; + *) finalize_rpath="$finalize_rpath $libdir" ;; esac done if test "$hardcode_into_libs" != yes || test "$build_old_libs" = yes; then @@ -7603,7 +6459,7 @@ for lib in $old_dlfiles; do case " $dlprefiles $dlfiles " in *" $lib "*) ;; - *) func_append dlfiles " $lib" ;; + *) dlfiles="$dlfiles $lib" ;; esac done @@ -7613,19 +6469,19 @@ for lib in $old_dlprefiles; do case "$dlprefiles " in *" $lib "*) ;; - *) func_append dlprefiles " $lib" ;; + *) dlprefiles="$dlprefiles $lib" ;; esac done if test "$build_libtool_libs" = yes; then if test -n "$rpath"; then case $host in - *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos* | *-cegcc* | *-*-haiku*) + *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos* | *-cegcc*) # these systems don't actually have a c library (as such)! ;; *-*-rhapsody* | *-*-darwin1.[012]) # Rhapsody C library is in the System framework - func_append deplibs " System.ltframework" + deplibs="$deplibs System.ltframework" ;; *-*-netbsd*) # Don't link with libc until the a.out ld.so is fixed. @@ -7642,7 +6498,7 @@ *) # Add libc to deplibs on all other systems if necessary. if test "$build_libtool_need_lc" = "yes"; then - func_append deplibs " -lc" + deplibs="$deplibs -lc" fi ;; esac @@ -7691,7 +6547,7 @@ if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then case " $predeps $postdeps " in *" $i "*) - func_append newdeplibs " $i" + newdeplibs="$newdeplibs $i" i="" ;; esac @@ -7702,21 +6558,21 @@ set dummy $deplib_matches; shift deplib_match=$1 if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then - func_append newdeplibs " $i" + newdeplibs="$newdeplibs $i" else droppeddeps=yes - echo + $ECHO $ECHO "*** Warning: dynamic linker does not accept needed library $i." - echo "*** I have the capability to make that library automatically link in when" - echo "*** you link to this library. But I can only do this if you have a" - echo "*** shared version of the library, which I believe you do not have" - echo "*** because a test_compile did reveal that the linker did not use it for" - echo "*** its dynamic dependency list that programs get resolved with at runtime." + $ECHO "*** I have the capability to make that library automatically link in when" + $ECHO "*** you link to this library. But I can only do this if you have a" + $ECHO "*** shared version of the library, which I believe you do not have" + $ECHO "*** because a test_compile did reveal that the linker did not use it for" + $ECHO "*** its dynamic dependency list that programs get resolved with at runtime." fi fi ;; *) - func_append newdeplibs " $i" + newdeplibs="$newdeplibs $i" ;; esac done @@ -7734,7 +6590,7 @@ if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then case " $predeps $postdeps " in *" $i "*) - func_append newdeplibs " $i" + newdeplibs="$newdeplibs $i" i="" ;; esac @@ -7745,29 +6601,29 @@ set dummy $deplib_matches; shift deplib_match=$1 if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then - func_append newdeplibs " $i" + newdeplibs="$newdeplibs $i" else droppeddeps=yes - echo + $ECHO $ECHO "*** Warning: dynamic linker does not accept needed library $i." - echo "*** I have the capability to make that library automatically link in when" - echo "*** you link to this library. But I can only do this if you have a" - echo "*** shared version of the library, which you do not appear to have" - echo "*** because a test_compile did reveal that the linker did not use this one" - echo "*** as a dynamic dependency that programs can get resolved with at runtime." + $ECHO "*** I have the capability to make that library automatically link in when" + $ECHO "*** you link to this library. But I can only do this if you have a" + $ECHO "*** shared version of the library, which you do not appear to have" + $ECHO "*** because a test_compile did reveal that the linker did not use this one" + $ECHO "*** as a dynamic dependency that programs can get resolved with at runtime." fi fi else droppeddeps=yes - echo + $ECHO $ECHO "*** Warning! Library $i is needed by this library but I was not able to" - echo "*** make it link in! You will probably need to install it or some" - echo "*** library that it depends on before this library will be fully" - echo "*** functional. Installing it before continuing would be even better." + $ECHO "*** make it link in! You will probably need to install it or some" + $ECHO "*** library that it depends on before this library will be fully" + $ECHO "*** functional. Installing it before continuing would be even better." fi ;; *) - func_append newdeplibs " $i" + newdeplibs="$newdeplibs $i" ;; esac done @@ -7784,27 +6640,15 @@ if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then case " $predeps $postdeps " in *" $a_deplib "*) - func_append newdeplibs " $a_deplib" + newdeplibs="$newdeplibs $a_deplib" a_deplib="" ;; esac fi if test -n "$a_deplib" ; then libname=`eval "\\$ECHO \"$libname_spec\""` - if test -n "$file_magic_glob"; then - libnameglob=`func_echo_all "$libname" | $SED -e $file_magic_glob` - else - libnameglob=$libname - fi - test "$want_nocaseglob" = yes && nocaseglob=`shopt -p nocaseglob` for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do - if test "$want_nocaseglob" = yes; then - shopt -s nocaseglob - potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null` - $nocaseglob - else - potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null` - fi + potential_libs=`ls $i/$libname[.-]* 2>/dev/null` for potent_lib in $potential_libs; do # Follow soft links. if ls -lLd "$potent_lib" 2>/dev/null | @@ -7821,13 +6665,13 @@ potliblink=`ls -ld $potlib | ${SED} 's/.* -> //'` case $potliblink in [\\/]* | [A-Za-z]:[\\/]*) potlib="$potliblink";; - *) potlib=`$ECHO "$potlib" | $SED 's,[^/]*$,,'`"$potliblink";; + *) potlib=`$ECHO "X$potlib" | $Xsed -e 's,[^/]*$,,'`"$potliblink";; esac done if eval $file_magic_cmd \"\$potlib\" 2>/dev/null | $SED -e 10q | $EGREP "$file_magic_regex" > /dev/null; then - func_append newdeplibs " $a_deplib" + newdeplibs="$newdeplibs $a_deplib" a_deplib="" break 2 fi @@ -7836,12 +6680,12 @@ fi if test -n "$a_deplib" ; then droppeddeps=yes - echo + $ECHO $ECHO "*** Warning: linker path does not have real file for library $a_deplib." - echo "*** I have the capability to make that library automatically link in when" - echo "*** you link to this library. But I can only do this if you have a" - echo "*** shared version of the library, which you do not appear to have" - echo "*** because I did check the linker path looking for a file starting" + $ECHO "*** I have the capability to make that library automatically link in when" + $ECHO "*** you link to this library. But I can only do this if you have a" + $ECHO "*** shared version of the library, which you do not appear to have" + $ECHO "*** because I did check the linker path looking for a file starting" if test -z "$potlib" ; then $ECHO "*** with $libname but no candidates were found. (...for file magic test)" else @@ -7852,7 +6696,7 @@ ;; *) # Add a -L argument. - func_append newdeplibs " $a_deplib" + newdeplibs="$newdeplibs $a_deplib" ;; esac done # Gone through all deplibs. @@ -7868,7 +6712,7 @@ if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then case " $predeps $postdeps " in *" $a_deplib "*) - func_append newdeplibs " $a_deplib" + newdeplibs="$newdeplibs $a_deplib" a_deplib="" ;; esac @@ -7879,9 +6723,9 @@ potential_libs=`ls $i/$libname[.-]* 2>/dev/null` for potent_lib in $potential_libs; do potlib="$potent_lib" # see symlink-check above in file_magic test - if eval "\$ECHO \"$potent_lib\"" 2>/dev/null | $SED 10q | \ + if eval "\$ECHO \"X$potent_lib\"" 2>/dev/null | $Xsed -e 10q | \ $EGREP "$match_pattern_regex" > /dev/null; then - func_append newdeplibs " $a_deplib" + newdeplibs="$newdeplibs $a_deplib" a_deplib="" break 2 fi @@ -7890,12 +6734,12 @@ fi if test -n "$a_deplib" ; then droppeddeps=yes - echo + $ECHO $ECHO "*** Warning: linker path does not have real file for library $a_deplib." - echo "*** I have the capability to make that library automatically link in when" - echo "*** you link to this library. But I can only do this if you have a" - echo "*** shared version of the library, which you do not appear to have" - echo "*** because I did check the linker path looking for a file starting" + $ECHO "*** I have the capability to make that library automatically link in when" + $ECHO "*** you link to this library. But I can only do this if you have a" + $ECHO "*** shared version of the library, which you do not appear to have" + $ECHO "*** because I did check the linker path looking for a file starting" if test -z "$potlib" ; then $ECHO "*** with $libname but no candidates were found. (...for regex pattern test)" else @@ -7906,32 +6750,32 @@ ;; *) # Add a -L argument. - func_append newdeplibs " $a_deplib" + newdeplibs="$newdeplibs $a_deplib" ;; esac done # Gone through all deplibs. ;; none | unknown | *) newdeplibs="" - tmp_deplibs=`$ECHO " $deplibs" | $SED 's/ -lc$//; s/ -[LR][^ ]*//g'` + tmp_deplibs=`$ECHO "X $deplibs" | $Xsed \ + -e 's/ -lc$//' -e 's/ -[LR][^ ]*//g'` if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then for i in $predeps $postdeps ; do # can't use Xsed below, because $i might contain '/' - tmp_deplibs=`$ECHO " $tmp_deplibs" | $SED "s,$i,,"` + tmp_deplibs=`$ECHO "X $tmp_deplibs" | $Xsed -e "s,$i,,"` done fi - case $tmp_deplibs in - *[!\ \ ]*) - echo + if $ECHO "X $tmp_deplibs" | $Xsed -e 's/[ ]//g' | + $GREP . >/dev/null; then + $ECHO if test "X$deplibs_check_method" = "Xnone"; then - echo "*** Warning: inter-library dependencies are not supported in this platform." + $ECHO "*** Warning: inter-library dependencies are not supported in this platform." else - echo "*** Warning: inter-library dependencies are not known to be supported." + $ECHO "*** Warning: inter-library dependencies are not known to be supported." fi - echo "*** All declared inter-library dependencies are being dropped." + $ECHO "*** All declared inter-library dependencies are being dropped." droppeddeps=yes - ;; - esac + fi ;; esac versuffix=$versuffix_save @@ -7943,23 +6787,23 @@ case $host in *-*-rhapsody* | *-*-darwin1.[012]) # On Rhapsody replace the C library with the System framework - newdeplibs=`$ECHO " $newdeplibs" | $SED 's/ -lc / System.ltframework /'` + newdeplibs=`$ECHO "X $newdeplibs" | $Xsed -e 's/ -lc / System.ltframework /'` ;; esac if test "$droppeddeps" = yes; then if test "$module" = yes; then - echo - echo "*** Warning: libtool could not satisfy all declared inter-library" + $ECHO + $ECHO "*** Warning: libtool could not satisfy all declared inter-library" $ECHO "*** dependencies of module $libname. Therefore, libtool will create" - echo "*** a static module, that should work as long as the dlopening" - echo "*** application is linked with the -dlopen flag." + $ECHO "*** a static module, that should work as long as the dlopening" + $ECHO "*** application is linked with the -dlopen flag." if test -z "$global_symbol_pipe"; then - echo - echo "*** However, this would only work if libtool was able to extract symbol" - echo "*** lists from a program, using \`nm' or equivalent, but libtool could" - echo "*** not find such a program. So, this module is probably useless." - echo "*** \`nm' from GNU binutils and a full rebuild may help." + $ECHO + $ECHO "*** However, this would only work if libtool was able to extract symbol" + $ECHO "*** lists from a program, using \`nm' or equivalent, but libtool could" + $ECHO "*** not find such a program. So, this module is probably useless." + $ECHO "*** \`nm' from GNU binutils and a full rebuild may help." fi if test "$build_old_libs" = no; then oldlibs="$output_objdir/$libname.$libext" @@ -7969,16 +6813,16 @@ build_libtool_libs=no fi else - echo "*** The inter-library dependencies that have been dropped here will be" - echo "*** automatically added whenever a program is linked with this library" - echo "*** or is declared to -dlopen it." + $ECHO "*** The inter-library dependencies that have been dropped here will be" + $ECHO "*** automatically added whenever a program is linked with this library" + $ECHO "*** or is declared to -dlopen it." if test "$allow_undefined" = no; then - echo - echo "*** Since this library must not contain undefined symbols," - echo "*** because either the platform does not support them or" - echo "*** it was explicitly requested with -no-undefined," - echo "*** libtool will only create a static version of it." + $ECHO + $ECHO "*** Since this library must not contain undefined symbols," + $ECHO "*** because either the platform does not support them or" + $ECHO "*** it was explicitly requested with -no-undefined," + $ECHO "*** libtool will only create a static version of it." if test "$build_old_libs" = no; then oldlibs="$output_objdir/$libname.$libext" build_libtool_libs=module @@ -7995,9 +6839,9 @@ # Time to change all our "foo.ltframework" stuff back to "-framework foo" case $host in *-*-darwin*) - newdeplibs=`$ECHO " $newdeplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` - new_inherited_linker_flags=`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` - deplibs=`$ECHO " $deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` + newdeplibs=`$ECHO "X $newdeplibs" | $Xsed -e 's% \([^ $]*\).ltframework% -framework \1%g'` + new_inherited_linker_flags=`$ECHO "X $new_inherited_linker_flags" | $Xsed -e 's% \([^ $]*\).ltframework% -framework \1%g'` + deplibs=`$ECHO "X $deplibs" | $Xsed -e 's% \([^ $]*\).ltframework% -framework \1%g'` ;; esac @@ -8010,7 +6854,7 @@ *) case " $deplibs " in *" -L$path/$objdir "*) - func_append new_libs " -L$path/$objdir" ;; + new_libs="$new_libs -L$path/$objdir" ;; esac ;; esac @@ -8020,10 +6864,10 @@ -L*) case " $new_libs " in *" $deplib "*) ;; - *) func_append new_libs " $deplib" ;; + *) new_libs="$new_libs $deplib" ;; esac ;; - *) func_append new_libs " $deplib" ;; + *) new_libs="$new_libs $deplib" ;; esac done deplibs="$new_libs" @@ -8035,22 +6879,15 @@ # Test again, we may have decided not to build it any more if test "$build_libtool_libs" = yes; then - # Remove ${wl} instances when linking with ld. - # FIXME: should test the right _cmds variable. - case $archive_cmds in - *\$LD\ *) wl= ;; - esac if test "$hardcode_into_libs" = yes; then # Hardcode the library paths hardcode_libdirs= dep_rpath= rpath="$finalize_rpath" - test "$opt_mode" != relink && rpath="$compile_rpath$rpath" + test "$mode" != relink && rpath="$compile_rpath$rpath" for libdir in $rpath; do if test -n "$hardcode_libdir_flag_spec"; then if test -n "$hardcode_libdir_separator"; then - func_replace_sysroot "$libdir" - libdir=$func_replace_sysroot_result if test -z "$hardcode_libdirs"; then hardcode_libdirs="$libdir" else @@ -8059,18 +6896,18 @@ *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) ;; *) - func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" + hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir" ;; esac fi else eval flag=\"$hardcode_libdir_flag_spec\" - func_append dep_rpath " $flag" + dep_rpath="$dep_rpath $flag" fi elif test -n "$runpath_var"; then case "$perm_rpath " in *" $libdir "*) ;; - *) func_append perm_rpath " $libdir" ;; + *) perm_rpath="$perm_rpath $libdir" ;; esac fi done @@ -8078,13 +6915,17 @@ if test -n "$hardcode_libdir_separator" && test -n "$hardcode_libdirs"; then libdir="$hardcode_libdirs" - eval "dep_rpath=\"$hardcode_libdir_flag_spec\"" + if test -n "$hardcode_libdir_flag_spec_ld"; then + eval dep_rpath=\"$hardcode_libdir_flag_spec_ld\" + else + eval dep_rpath=\"$hardcode_libdir_flag_spec\" + fi fi if test -n "$runpath_var" && test -n "$perm_rpath"; then # We should set the runpath_var. rpath= for dir in $perm_rpath; do - func_append rpath "$dir:" + rpath="$rpath$dir:" done eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var" fi @@ -8092,7 +6933,7 @@ fi shlibpath="$finalize_shlibpath" - test "$opt_mode" != relink && shlibpath="$compile_shlibpath$shlibpath" + test "$mode" != relink && shlibpath="$compile_shlibpath$shlibpath" if test -n "$shlibpath"; then eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var" fi @@ -8118,18 +6959,18 @@ linknames= for link do - func_append linknames " $link" + linknames="$linknames $link" done # Use standard objects if they are pic - test -z "$pic_flag" && libobjs=`$ECHO "$libobjs" | $SP2NL | $SED "$lo2o" | $NL2SP` + test -z "$pic_flag" && libobjs=`$ECHO "X$libobjs" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP` test "X$libobjs" = "X " && libobjs= delfiles= if test -n "$export_symbols" && test -n "$include_expsyms"; then $opt_dry_run || cp "$export_symbols" "$output_objdir/$libname.uexp" export_symbols="$output_objdir/$libname.uexp" - func_append delfiles " $export_symbols" + delfiles="$delfiles $export_symbols" fi orig_export_symbols= @@ -8160,46 +7001,14 @@ $opt_dry_run || $RM $export_symbols cmds=$export_symbols_cmds save_ifs="$IFS"; IFS='~' - for cmd1 in $cmds; do + for cmd in $cmds; do IFS="$save_ifs" - # Take the normal branch if the nm_file_list_spec branch - # doesn't work or if tool conversion is not needed. - case $nm_file_list_spec~$to_tool_file_cmd in - *~func_convert_file_noop | *~func_convert_file_msys_to_w32 | ~*) - try_normal_branch=yes - eval cmd=\"$cmd1\" - func_len " $cmd" - len=$func_len_result - ;; - *) - try_normal_branch=no - ;; - esac - if test "$try_normal_branch" = yes \ - && { test "$len" -lt "$max_cmd_len" \ - || test "$max_cmd_len" -le -1; } - then + eval cmd=\"$cmd\" + func_len " $cmd" + len=$func_len_result + if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then func_show_eval "$cmd" 'exit $?' skipped_export=false - elif test -n "$nm_file_list_spec"; then - func_basename "$output" - output_la=$func_basename_result - save_libobjs=$libobjs - save_output=$output - output=${output_objdir}/${output_la}.nm - func_to_tool_file "$output" - libobjs=$nm_file_list_spec$func_to_tool_file_result - func_append delfiles " $output" - func_verbose "creating $NM input file list: $output" - for obj in $save_libobjs; do - func_to_tool_file "$obj" - $ECHO "$func_to_tool_file_result" - done > "$output" - eval cmd=\"$cmd1\" - func_show_eval "$cmd" 'exit $?' - output=$save_output - libobjs=$save_libobjs - skipped_export=false else # The command line is too long to execute in one step. func_verbose "using reloadable object file for export list..." @@ -8220,7 +7029,7 @@ if test -n "$export_symbols" && test -n "$include_expsyms"; then tmp_export_symbols="$export_symbols" test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols" - $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"' + $opt_dry_run || eval '$ECHO "X$include_expsyms" | $Xsed | $SP2NL >> "$tmp_export_symbols"' fi if test "X$skipped_export" != "X:" && test -n "$orig_export_symbols"; then @@ -8232,7 +7041,7 @@ # global variables. join(1) would be nice here, but unfortunately # isn't a blessed tool. $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter - func_append delfiles " $export_symbols $output_objdir/$libname.filter" + delfiles="$delfiles $export_symbols $output_objdir/$libname.filter" export_symbols=$output_objdir/$libname.def $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols fi @@ -8242,7 +7051,7 @@ case " $convenience " in *" $test_deplib "*) ;; *) - func_append tmp_deplibs " $test_deplib" + tmp_deplibs="$tmp_deplibs $test_deplib" ;; esac done @@ -8262,21 +7071,21 @@ test "X$libobjs" = "X " && libobjs= else gentop="$output_objdir/${outputname}x" - func_append generated " $gentop" + generated="$generated $gentop" func_extract_archives $gentop $convenience - func_append libobjs " $func_extract_archives_result" + libobjs="$libobjs $func_extract_archives_result" test "X$libobjs" = "X " && libobjs= fi fi if test "$thread_safe" = yes && test -n "$thread_safe_flag_spec"; then eval flag=\"$thread_safe_flag_spec\" - func_append linker_flags " $flag" + linker_flags="$linker_flags $flag" fi # Make a backup of the uninstalled library when relinking - if test "$opt_mode" = relink; then + if test "$mode" = relink; then $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}U && $MV $realname ${realname}U)' || exit $? fi @@ -8321,8 +7130,7 @@ save_libobjs=$libobjs fi save_output=$output - func_basename "$output" - output_la=$func_basename_result + output_la=`$ECHO "X$output" | $Xsed -e "$basename"` # Clear the reloadable object creation command queue and # initialize k to one. @@ -8335,16 +7143,13 @@ if test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "$with_gnu_ld" = yes; then output=${output_objdir}/${output_la}.lnkscript func_verbose "creating GNU ld script: $output" - echo 'INPUT (' > $output + $ECHO 'INPUT (' > $output for obj in $save_libobjs do - func_to_tool_file "$obj" - $ECHO "$func_to_tool_file_result" >> $output + $ECHO "$obj" >> $output done - echo ')' >> $output - func_append delfiles " $output" - func_to_tool_file "$output" - output=$func_to_tool_file_result + $ECHO ')' >> $output + delfiles="$delfiles $output" elif test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "X$file_list_spec" != X; then output=${output_objdir}/${output_la}.lnk func_verbose "creating linker input file list: $output" @@ -8358,12 +7163,10 @@ fi for obj do - func_to_tool_file "$obj" - $ECHO "$func_to_tool_file_result" >> $output + $ECHO "$obj" >> $output done - func_append delfiles " $output" - func_to_tool_file "$output" - output=$firstobj\"$file_list_spec$func_to_tool_file_result\" + delfiles="$delfiles $output" + output=$firstobj\"$file_list_spec$output\" else if test -n "$save_libobjs"; then func_verbose "creating reloadable object files..." @@ -8387,19 +7190,17 @@ # command to the queue. if test "$k" -eq 1 ; then # The first file doesn't have a previous command to add. - reload_objs=$objlist - eval concat_cmds=\"$reload_cmds\" + eval concat_cmds=\"$reload_cmds $objlist $last_robj\" else # All subsequent reloadable object files will link in # the last one created. - reload_objs="$objlist $last_robj" - eval concat_cmds=\"\$concat_cmds~$reload_cmds~\$RM $last_robj\" + eval concat_cmds=\"\$concat_cmds~$reload_cmds $objlist $last_robj~\$RM $last_robj\" fi last_robj=$output_objdir/$output_la-${k}.$objext func_arith $k + 1 k=$func_arith_result output=$output_objdir/$output_la-${k}.$objext - objlist=" $obj" + objlist=$obj func_len " $last_robj" func_arith $len0 + $func_len_result len=$func_arith_result @@ -8409,12 +7210,11 @@ # reloadable object file. All subsequent reloadable object # files will link in the last one created. test -z "$concat_cmds" || concat_cmds=$concat_cmds~ - reload_objs="$objlist $last_robj" - eval concat_cmds=\"\${concat_cmds}$reload_cmds\" + eval concat_cmds=\"\${concat_cmds}$reload_cmds $objlist $last_robj\" if test -n "$last_robj"; then eval concat_cmds=\"\${concat_cmds}~\$RM $last_robj\" fi - func_append delfiles " $output" + delfiles="$delfiles $output" else output= @@ -8448,7 +7248,7 @@ lt_exit=$? # Restore the uninstalled library and exit - if test "$opt_mode" = relink; then + if test "$mode" = relink; then ( cd "$output_objdir" && \ $RM "${realname}T" && \ $MV "${realname}U" "$realname" ) @@ -8469,7 +7269,7 @@ if test -n "$export_symbols" && test -n "$include_expsyms"; then tmp_export_symbols="$export_symbols" test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols" - $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"' + $opt_dry_run || eval '$ECHO "X$include_expsyms" | $Xsed | $SP2NL >> "$tmp_export_symbols"' fi if test -n "$orig_export_symbols"; then @@ -8481,7 +7281,7 @@ # global variables. join(1) would be nice here, but unfortunately # isn't a blessed tool. $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter - func_append delfiles " $export_symbols $output_objdir/$libname.filter" + delfiles="$delfiles $export_symbols $output_objdir/$libname.filter" export_symbols=$output_objdir/$libname.def $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols fi @@ -8522,10 +7322,10 @@ # Add any objects from preloaded convenience libraries if test -n "$dlprefiles"; then gentop="$output_objdir/${outputname}x" - func_append generated " $gentop" + generated="$generated $gentop" func_extract_archives $gentop $dlprefiles - func_append libobjs " $func_extract_archives_result" + libobjs="$libobjs $func_extract_archives_result" test "X$libobjs" = "X " && libobjs= fi @@ -8541,7 +7341,7 @@ lt_exit=$? # Restore the uninstalled library and exit - if test "$opt_mode" = relink; then + if test "$mode" = relink; then ( cd "$output_objdir" && \ $RM "${realname}T" && \ $MV "${realname}U" "$realname" ) @@ -8553,7 +7353,7 @@ IFS="$save_ifs" # Restore the uninstalled library and exit - if test "$opt_mode" = relink; then + if test "$mode" = relink; then $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}T && $MV $realname ${realname}T && $MV ${realname}U $realname)' || exit $? if test -n "$convenience"; then @@ -8634,21 +7434,18 @@ if test -n "$convenience"; then if test -n "$whole_archive_flag_spec"; then eval tmp_whole_archive_flags=\"$whole_archive_flag_spec\" - reload_conv_objs=$reload_objs\ `$ECHO "$tmp_whole_archive_flags" | $SED 's|,| |g'` + reload_conv_objs=$reload_objs\ `$ECHO "X$tmp_whole_archive_flags" | $Xsed -e 's|,| |g'` else gentop="$output_objdir/${obj}x" - func_append generated " $gentop" + generated="$generated $gentop" func_extract_archives $gentop $convenience reload_conv_objs="$reload_objs $func_extract_archives_result" fi fi - # If we're not building shared, we need to use non_pic_objs - test "$build_libtool_libs" != yes && libobjs="$non_pic_objects" - # Create the old-style object. - reload_objs="$objs$old_deplibs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.${libext}$/d; /\.lib$/d; $lo2o" | $NL2SP`" $reload_conv_objs" ### testsuite: skip nested quoting test + reload_objs="$objs$old_deplibs "`$ECHO "X$libobjs" | $SP2NL | $Xsed -e '/\.'${libext}$'/d' -e '/\.lib$/d' -e "$lo2o" | $NL2SP`" $reload_conv_objs" ### testsuite: skip nested quoting test output="$obj" func_execute_cmds "$reload_cmds" 'exit $?' @@ -8708,8 +7505,8 @@ case $host in *-*-rhapsody* | *-*-darwin1.[012]) # On Rhapsody replace the C library is the System framework - compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's/ -lc / System.ltframework /'` - finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's/ -lc / System.ltframework /'` + compile_deplibs=`$ECHO "X $compile_deplibs" | $Xsed -e 's/ -lc / System.ltframework /'` + finalize_deplibs=`$ECHO "X $finalize_deplibs" | $Xsed -e 's/ -lc / System.ltframework /'` ;; esac @@ -8720,14 +7517,14 @@ if test "$tagname" = CXX ; then case ${MACOSX_DEPLOYMENT_TARGET-10.0} in 10.[0123]) - func_append compile_command " ${wl}-bind_at_load" - func_append finalize_command " ${wl}-bind_at_load" + compile_command="$compile_command ${wl}-bind_at_load" + finalize_command="$finalize_command ${wl}-bind_at_load" ;; esac fi # Time to change all our "foo.ltframework" stuff back to "-framework foo" - compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` - finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` + compile_deplibs=`$ECHO "X $compile_deplibs" | $Xsed -e 's% \([^ $]*\).ltframework% -framework \1%g'` + finalize_deplibs=`$ECHO "X $finalize_deplibs" | $Xsed -e 's% \([^ $]*\).ltframework% -framework \1%g'` ;; esac @@ -8741,7 +7538,7 @@ *) case " $compile_deplibs " in *" -L$path/$objdir "*) - func_append new_libs " -L$path/$objdir" ;; + new_libs="$new_libs -L$path/$objdir" ;; esac ;; esac @@ -8751,17 +7548,17 @@ -L*) case " $new_libs " in *" $deplib "*) ;; - *) func_append new_libs " $deplib" ;; + *) new_libs="$new_libs $deplib" ;; esac ;; - *) func_append new_libs " $deplib" ;; + *) new_libs="$new_libs $deplib" ;; esac done compile_deplibs="$new_libs" - func_append compile_command " $compile_deplibs" - func_append finalize_command " $finalize_deplibs" + compile_command="$compile_command $compile_deplibs" + finalize_command="$finalize_command $finalize_deplibs" if test -n "$rpath$xrpath"; then # If the user specified any rpath flags, then add them. @@ -8769,7 +7566,7 @@ # This is the magic to use -rpath. case "$finalize_rpath " in *" $libdir "*) ;; - *) func_append finalize_rpath " $libdir" ;; + *) finalize_rpath="$finalize_rpath $libdir" ;; esac done fi @@ -8788,18 +7585,18 @@ *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) ;; *) - func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" + hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir" ;; esac fi else eval flag=\"$hardcode_libdir_flag_spec\" - func_append rpath " $flag" + rpath="$rpath $flag" fi elif test -n "$runpath_var"; then case "$perm_rpath " in *" $libdir "*) ;; - *) func_append perm_rpath " $libdir" ;; + *) perm_rpath="$perm_rpath $libdir" ;; esac fi case $host in @@ -8808,12 +7605,12 @@ case :$dllsearchpath: in *":$libdir:"*) ;; ::) dllsearchpath=$libdir;; - *) func_append dllsearchpath ":$libdir";; + *) dllsearchpath="$dllsearchpath:$libdir";; esac case :$dllsearchpath: in *":$testbindir:"*) ;; ::) dllsearchpath=$testbindir;; - *) func_append dllsearchpath ":$testbindir";; + *) dllsearchpath="$dllsearchpath:$testbindir";; esac ;; esac @@ -8839,18 +7636,18 @@ *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) ;; *) - func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" + hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir" ;; esac fi else eval flag=\"$hardcode_libdir_flag_spec\" - func_append rpath " $flag" + rpath="$rpath $flag" fi elif test -n "$runpath_var"; then case "$finalize_perm_rpath " in *" $libdir "*) ;; - *) func_append finalize_perm_rpath " $libdir" ;; + *) finalize_perm_rpath="$finalize_perm_rpath $libdir" ;; esac fi done @@ -8864,8 +7661,8 @@ if test -n "$libobjs" && test "$build_old_libs" = yes; then # Transform all the library objects into standard objects. - compile_command=`$ECHO "$compile_command" | $SP2NL | $SED "$lo2o" | $NL2SP` - finalize_command=`$ECHO "$finalize_command" | $SP2NL | $SED "$lo2o" | $NL2SP` + compile_command=`$ECHO "X$compile_command" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP` + finalize_command=`$ECHO "X$finalize_command" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP` fi func_generate_dlsyms "$outputname" "@PROGRAM@" "no" @@ -8877,15 +7674,15 @@ wrappers_required=yes case $host in - *cegcc* | *mingw32ce*) - # Disable wrappers for cegcc and mingw32ce hosts, we are cross compiling anyway. - wrappers_required=no - ;; *cygwin* | *mingw* ) if test "$build_libtool_libs" != yes; then wrappers_required=no fi ;; + *cegcc) + # Disable wrappers for cegcc, we are cross compiling anyway. + wrappers_required=no + ;; *) if test "$need_relink" = no || test "$build_libtool_libs" != yes; then wrappers_required=no @@ -8894,19 +7691,13 @@ esac if test "$wrappers_required" = no; then # Replace the output file specification. - compile_command=`$ECHO "$compile_command" | $SED 's%@OUTPUT@%'"$output"'%g'` + compile_command=`$ECHO "X$compile_command" | $Xsed -e 's%@OUTPUT@%'"$output"'%g'` link_command="$compile_command$compile_rpath" # We have no uninstalled library dependencies, so finalize right now. exit_status=0 func_show_eval "$link_command" 'exit_status=$?' - if test -n "$postlink_cmds"; then - func_to_tool_file "$output" - postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` - func_execute_cmds "$postlink_cmds" 'exit $?' - fi - # Delete the generated files. if test -f "$output_objdir/${outputname}S.${objext}"; then func_show_eval '$RM "$output_objdir/${outputname}S.${objext}"' @@ -8929,7 +7720,7 @@ # We should set the runpath_var. rpath= for dir in $perm_rpath; do - func_append rpath "$dir:" + rpath="$rpath$dir:" done compile_var="$runpath_var=\"$rpath\$$runpath_var\" " fi @@ -8937,7 +7728,7 @@ # We should set the runpath_var. rpath= for dir in $finalize_perm_rpath; do - func_append rpath "$dir:" + rpath="$rpath$dir:" done finalize_var="$runpath_var=\"$rpath\$$runpath_var\" " fi @@ -8947,18 +7738,11 @@ # We don't need to create a wrapper script. link_command="$compile_var$compile_command$compile_rpath" # Replace the output file specification. - link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output"'%g'` + link_command=`$ECHO "X$link_command" | $Xsed -e 's%@OUTPUT@%'"$output"'%g'` # Delete the old output file. $opt_dry_run || $RM $output # Link the executable and exit func_show_eval "$link_command" 'exit $?' - - if test -n "$postlink_cmds"; then - func_to_tool_file "$output" - postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` - func_execute_cmds "$postlink_cmds" 'exit $?' - fi - exit $EXIT_SUCCESS fi @@ -8973,7 +7757,7 @@ if test "$fast_install" != no; then link_command="$finalize_var$compile_command$finalize_rpath" if test "$fast_install" = yes; then - relink_command=`$ECHO "$compile_var$compile_command$compile_rpath" | $SED 's%@OUTPUT@%\$progdir/\$file%g'` + relink_command=`$ECHO "X$compile_var$compile_command$compile_rpath" | $Xsed -e 's%@OUTPUT@%\$progdir/\$file%g'` else # fast_install is set to needless relink_command= @@ -8985,19 +7769,13 @@ fi # Replace the output file specification. - link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'` + link_command=`$ECHO "X$link_command" | $Xsed -e 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'` # Delete the old output files. $opt_dry_run || $RM $output $output_objdir/$outputname $output_objdir/lt-$outputname func_show_eval "$link_command" 'exit $?' - if test -n "$postlink_cmds"; then - func_to_tool_file "$output_objdir/$outputname" - postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output_objdir/$outputname"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` - func_execute_cmds "$postlink_cmds" 'exit $?' - fi - # Now create the wrapper script. func_verbose "creating $output" @@ -9015,7 +7793,18 @@ fi done relink_command="(cd `pwd`; $relink_command)" - relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"` + relink_command=`$ECHO "X$relink_command" | $Xsed -e "$sed_quote_subst"` + fi + + # Quote $ECHO for shipping. + if test "X$ECHO" = "X$SHELL $progpath --fallback-echo"; then + case $progpath in + [\\/]* | [A-Za-z]:[\\/]*) qecho="$SHELL $progpath --fallback-echo";; + *) qecho="$SHELL `pwd`/$progpath --fallback-echo";; + esac + qecho=`$ECHO "X$qecho" | $Xsed -e "$sed_quote_subst"` + else + qecho=`$ECHO "X$ECHO" | $Xsed -e "$sed_quote_subst"` fi # Only actually do things if not in dry run mode. @@ -9095,7 +7884,7 @@ else oldobjs="$old_deplibs $non_pic_objects" if test "$preload" = yes && test -f "$symfileobj"; then - func_append oldobjs " $symfileobj" + oldobjs="$oldobjs $symfileobj" fi fi addlibs="$old_convenience" @@ -9103,10 +7892,10 @@ if test -n "$addlibs"; then gentop="$output_objdir/${outputname}x" - func_append generated " $gentop" + generated="$generated $gentop" func_extract_archives $gentop $addlibs - func_append oldobjs " $func_extract_archives_result" + oldobjs="$oldobjs $func_extract_archives_result" fi # Do each command in the archive commands. @@ -9117,10 +7906,10 @@ # Add any objects from preloaded convenience libraries if test -n "$dlprefiles"; then gentop="$output_objdir/${outputname}x" - func_append generated " $gentop" + generated="$generated $gentop" func_extract_archives $gentop $dlprefiles - func_append oldobjs " $func_extract_archives_result" + oldobjs="$oldobjs $func_extract_archives_result" fi # POSIX demands no paths to be encoded in archives. We have @@ -9136,9 +7925,9 @@ done | sort | sort -uc >/dev/null 2>&1); then : else - echo "copying selected object files to avoid basename conflicts..." + $ECHO "copying selected object files to avoid basename conflicts..." gentop="$output_objdir/${outputname}x" - func_append generated " $gentop" + generated="$generated $gentop" func_mkdir_p "$gentop" save_oldobjs=$oldobjs oldobjs= @@ -9162,30 +7951,18 @@ esac done func_show_eval "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj" - func_append oldobjs " $gentop/$newobj" + oldobjs="$oldobjs $gentop/$newobj" ;; - *) func_append oldobjs " $obj" ;; + *) oldobjs="$oldobjs $obj" ;; esac done fi - func_to_tool_file "$oldlib" func_convert_file_msys_to_w32 - tool_oldlib=$func_to_tool_file_result eval cmds=\"$old_archive_cmds\" func_len " $cmds" len=$func_len_result if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then cmds=$old_archive_cmds - elif test -n "$archiver_list_spec"; then - func_verbose "using command file archive linking..." - for obj in $oldobjs - do - func_to_tool_file "$obj" - $ECHO "$func_to_tool_file_result" - done > $output_objdir/$libname.libcmd - func_to_tool_file "$output_objdir/$libname.libcmd" - oldobjs=" $archiver_list_spec$func_to_tool_file_result" - cmds=$old_archive_cmds else # the command line is too long to link in one step, link in parts func_verbose "using piecewise archive linking..." @@ -9259,7 +8036,7 @@ done # Quote the link command for shipping. relink_command="(cd `pwd`; $SHELL $progpath $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)" - relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"` + relink_command=`$ECHO "X$relink_command" | $Xsed -e "$sed_quote_subst"` if test "$hardcode_automatic" = yes ; then relink_command= fi @@ -9279,23 +8056,12 @@ *.la) func_basename "$deplib" name="$func_basename_result" - func_resolve_sysroot "$deplib" - eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $func_resolve_sysroot_result` + eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib` test -z "$libdir" && \ func_fatal_error "\`$deplib' is not a valid libtool archive" - func_append newdependency_libs " ${lt_sysroot:+=}$libdir/$name" + newdependency_libs="$newdependency_libs $libdir/$name" ;; - -L*) - func_stripname -L '' "$deplib" - func_replace_sysroot "$func_stripname_result" - func_append newdependency_libs " -L$func_replace_sysroot_result" - ;; - -R*) - func_stripname -R '' "$deplib" - func_replace_sysroot "$func_stripname_result" - func_append newdependency_libs " -R$func_replace_sysroot_result" - ;; - *) func_append newdependency_libs " $deplib" ;; + *) newdependency_libs="$newdependency_libs $deplib" ;; esac done dependency_libs="$newdependency_libs" @@ -9309,9 +8075,9 @@ eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib` test -z "$libdir" && \ func_fatal_error "\`$lib' is not a valid libtool archive" - func_append newdlfiles " ${lt_sysroot:+=}$libdir/$name" + newdlfiles="$newdlfiles $libdir/$name" ;; - *) func_append newdlfiles " $lib" ;; + *) newdlfiles="$newdlfiles $lib" ;; esac done dlfiles="$newdlfiles" @@ -9328,7 +8094,7 @@ eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib` test -z "$libdir" && \ func_fatal_error "\`$lib' is not a valid libtool archive" - func_append newdlprefiles " ${lt_sysroot:+=}$libdir/$name" + newdlprefiles="$newdlprefiles $libdir/$name" ;; esac done @@ -9340,7 +8106,7 @@ [\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;; *) abs=`pwd`"/$lib" ;; esac - func_append newdlfiles " $abs" + newdlfiles="$newdlfiles $abs" done dlfiles="$newdlfiles" newdlprefiles= @@ -9349,33 +8115,15 @@ [\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;; *) abs=`pwd`"/$lib" ;; esac - func_append newdlprefiles " $abs" + newdlprefiles="$newdlprefiles $abs" done dlprefiles="$newdlprefiles" fi $RM $output # place dlname in correct position for cygwin - # In fact, it would be nice if we could use this code for all target - # systems that can't hard-code library paths into their executables - # and that have no shared library path variable independent of PATH, - # but it turns out we can't easily determine that from inspecting - # libtool variables, so we have to hard-code the OSs to which it - # applies here; at the moment, that means platforms that use the PE - # object format with DLL files. See the long comment at the top of - # tests/bindir.at for full details. tdlname=$dlname case $host,$output,$installed,$module,$dlname in - *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll | *cegcc*,*lai,yes,no,*.dll) - # If a -bindir argument was supplied, place the dll there. - if test "x$bindir" != x ; - then - func_relative_path "$install_libdir" "$bindir" - tdlname=$func_relative_path_result$dlname - else - # Otherwise fall back on heuristic. - tdlname=../bin/$dlname - fi - ;; + *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll | *cegcc*,*lai,yes,no,*.dll) tdlname=../bin/$dlname ;; esac $ECHO > $output "\ # $outputname - a libtool library file @@ -9434,7 +8182,7 @@ exit $EXIT_SUCCESS } -{ test "$opt_mode" = link || test "$opt_mode" = relink; } && +{ test "$mode" = link || test "$mode" = relink; } && func_mode_link ${1+"$@"} @@ -9454,9 +8202,9 @@ for arg do case $arg in - -f) func_append RM " $arg"; rmforce=yes ;; - -*) func_append RM " $arg" ;; - *) func_append files " $arg" ;; + -f) RM="$RM $arg"; rmforce=yes ;; + -*) RM="$RM $arg" ;; + *) files="$files $arg" ;; esac done @@ -9465,23 +8213,24 @@ rmdirs= + origobjdir="$objdir" for file in $files; do func_dirname "$file" "" "." dir="$func_dirname_result" if test "X$dir" = X.; then - odir="$objdir" + objdir="$origobjdir" else - odir="$dir/$objdir" + objdir="$dir/$origobjdir" fi func_basename "$file" name="$func_basename_result" - test "$opt_mode" = uninstall && odir="$dir" - - # Remember odir for removal later, being careful to avoid duplicates - if test "$opt_mode" = clean; then + test "$mode" = uninstall && objdir="$dir" + + # Remember objdir for removal later, being careful to avoid duplicates + if test "$mode" = clean; then case " $rmdirs " in - *" $odir "*) ;; - *) func_append rmdirs " $odir" ;; + *" $objdir "*) ;; + *) rmdirs="$rmdirs $objdir" ;; esac fi @@ -9507,17 +8256,18 @@ # Delete the libtool libraries and symlinks. for n in $library_names; do - func_append rmfiles " $odir/$n" + rmfiles="$rmfiles $objdir/$n" done - test -n "$old_library" && func_append rmfiles " $odir/$old_library" - - case "$opt_mode" in + test -n "$old_library" && rmfiles="$rmfiles $objdir/$old_library" + + case "$mode" in clean) - case " $library_names " in + case " $library_names " in + # " " in the beginning catches empty $dlname *" $dlname "*) ;; - *) test -n "$dlname" && func_append rmfiles " $odir/$dlname" ;; + *) rmfiles="$rmfiles $objdir/$dlname" ;; esac - test -n "$libdir" && func_append rmfiles " $odir/$name $odir/${name}i" + test -n "$libdir" && rmfiles="$rmfiles $objdir/$name $objdir/${name}i" ;; uninstall) if test -n "$library_names"; then @@ -9545,19 +8295,19 @@ # Add PIC object to the list of files to remove. if test -n "$pic_object" && test "$pic_object" != none; then - func_append rmfiles " $dir/$pic_object" + rmfiles="$rmfiles $dir/$pic_object" fi # Add non-PIC object to the list of files to remove. if test -n "$non_pic_object" && test "$non_pic_object" != none; then - func_append rmfiles " $dir/$non_pic_object" + rmfiles="$rmfiles $dir/$non_pic_object" fi fi ;; *) - if test "$opt_mode" = clean ; then + if test "$mode" = clean ; then noexename=$name case $file in *.exe) @@ -9567,7 +8317,7 @@ noexename=$func_stripname_result # $file with .exe has already been added to rmfiles, # add $file without .exe - func_append rmfiles " $file" + rmfiles="$rmfiles $file" ;; esac # Do a test to see if this is a libtool program. @@ -9576,7 +8326,7 @@ func_ltwrapper_scriptname "$file" relink_command= func_source $func_ltwrapper_scriptname_result - func_append rmfiles " $func_ltwrapper_scriptname_result" + rmfiles="$rmfiles $func_ltwrapper_scriptname_result" else relink_command= func_source $dir/$noexename @@ -9584,12 +8334,12 @@ # note $name still contains .exe if it was in $file originally # as does the version of $file that was added into $rmfiles - func_append rmfiles " $odir/$name $odir/${name}S.${objext}" + rmfiles="$rmfiles $objdir/$name $objdir/${name}S.${objext}" if test "$fast_install" = yes && test -n "$relink_command"; then - func_append rmfiles " $odir/lt-$name" + rmfiles="$rmfiles $objdir/lt-$name" fi if test "X$noexename" != "X$name" ; then - func_append rmfiles " $odir/lt-${noexename}.c" + rmfiles="$rmfiles $objdir/lt-${noexename}.c" fi fi fi @@ -9597,6 +8347,7 @@ esac func_show_eval "$RM $rmfiles" 'exit_status=1' done + objdir="$origobjdir" # Try to remove the ${objdir}s in the directories where we deleted files for dir in $rmdirs; do @@ -9608,16 +8359,16 @@ exit $exit_status } -{ test "$opt_mode" = uninstall || test "$opt_mode" = clean; } && +{ test "$mode" = uninstall || test "$mode" = clean; } && func_mode_uninstall ${1+"$@"} -test -z "$opt_mode" && { +test -z "$mode" && { help="$generic_help" func_fatal_help "you must specify a MODE" } test -z "$exec_cmd" && \ - func_fatal_help "invalid operation mode \`$opt_mode'" + func_fatal_help "invalid operation mode \`$mode'" if test -n "$exec_cmd"; then eval exec "$exec_cmd" diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi/m4/asmcfi.m4 --- a/Modules/_ctypes/libffi/m4/asmcfi.m4 Sat Jul 19 16:34:33 2014 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,13 +0,0 @@ -AC_DEFUN([GCC_AS_CFI_PSEUDO_OP], -[AC_CACHE_CHECK([assembler .cfi pseudo-op support], - gcc_cv_as_cfi_pseudo_op, [ - gcc_cv_as_cfi_pseudo_op=unknown - AC_TRY_COMPILE([asm (".cfi_startproc\n\t.cfi_endproc");],, - [gcc_cv_as_cfi_pseudo_op=yes], - [gcc_cv_as_cfi_pseudo_op=no]) - ]) - if test "x$gcc_cv_as_cfi_pseudo_op" = xyes; then - AC_DEFINE(HAVE_AS_CFI_PSEUDO_OP, 1, - [Define if your assembler supports .cfi_* directives.]) - fi -]) diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi/m4/ax_append_flag.m4 --- a/Modules/_ctypes/libffi/m4/ax_append_flag.m4 Sat Jul 19 16:34:33 2014 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,69 +0,0 @@ -# =========================================================================== -# http://www.gnu.org/software/autoconf-archive/ax_append_flag.html -# =========================================================================== -# -# SYNOPSIS -# -# AX_APPEND_FLAG(FLAG, [FLAGS-VARIABLE]) -# -# DESCRIPTION -# -# FLAG is appended to the FLAGS-VARIABLE shell variable, with a space -# added in between. -# -# If FLAGS-VARIABLE is not specified, the current language's flags (e.g. -# CFLAGS) is used. FLAGS-VARIABLE is not changed if it already contains -# FLAG. If FLAGS-VARIABLE is unset in the shell, it is set to exactly -# FLAG. -# -# NOTE: Implementation based on AX_CFLAGS_GCC_OPTION. -# -# LICENSE -# -# Copyright (c) 2008 Guido U. Draheim -# Copyright (c) 2011 Maarten Bosmans -# -# This program is free software: you can redistribute it and/or modify it -# under the terms of the GNU General Public License as published by the -# Free Software Foundation, either version 3 of the License, or (at your -# option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General -# Public License for more details. -# -# You should have received a copy of the GNU General Public License along -# with this program. If not, see . -# -# As a special exception, the respective Autoconf Macro's copyright owner -# gives unlimited permission to copy, distribute and modify the configure -# scripts that are the output of Autoconf when processing the Macro. You -# need not follow the terms of the GNU General Public License when using -# or distributing such scripts, even though portions of the text of the -# Macro appear in them. The GNU General Public License (GPL) does govern -# all other use of the material that constitutes the Autoconf Macro. -# -# This special exception to the GPL applies to versions of the Autoconf -# Macro released by the Autoconf Archive. When you make and distribute a -# modified version of the Autoconf Macro, you may extend this special -# exception to the GPL to apply to your modified version as well. - -#serial 2 - -AC_DEFUN([AX_APPEND_FLAG], -[AC_PREREQ(2.59)dnl for _AC_LANG_PREFIX -AS_VAR_PUSHDEF([FLAGS], [m4_default($2,_AC_LANG_PREFIX[FLAGS])])dnl -AS_VAR_SET_IF(FLAGS, - [case " AS_VAR_GET(FLAGS) " in - *" $1 "*) - AC_RUN_LOG([: FLAGS already contains $1]) - ;; - *) - AC_RUN_LOG([: FLAGS="$FLAGS $1"]) - AS_VAR_SET(FLAGS, ["AS_VAR_GET(FLAGS) $1"]) - ;; - esac], - [AS_VAR_SET(FLAGS,["$1"])]) -AS_VAR_POPDEF([FLAGS])dnl -])dnl AX_APPEND_FLAG diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi/m4/ax_cc_maxopt.m4 --- a/Modules/_ctypes/libffi/m4/ax_cc_maxopt.m4 Sat Jul 19 16:34:33 2014 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,181 +0,0 @@ -# =========================================================================== -# http://www.gnu.org/software/autoconf-archive/ax_cc_maxopt.html -# =========================================================================== -# -# SYNOPSIS -# -# AX_CC_MAXOPT -# -# DESCRIPTION -# -# Try to turn on "good" C optimization flags for various compilers and -# architectures, for some definition of "good". (In our case, good for -# FFTW and hopefully for other scientific codes. Modify as needed.) -# -# The user can override the flags by setting the CFLAGS environment -# variable. The user can also specify --enable-portable-binary in order to -# disable any optimization flags that might result in a binary that only -# runs on the host architecture. -# -# Note also that the flags assume that ANSI C aliasing rules are followed -# by the code (e.g. for gcc's -fstrict-aliasing), and that floating-point -# computations can be re-ordered as needed. -# -# Requires macros: AX_CHECK_COMPILE_FLAG, AX_COMPILER_VENDOR, -# AX_GCC_ARCHFLAG, AX_GCC_X86_CPUID. -# -# LICENSE -# -# Copyright (c) 2008 Steven G. Johnson -# Copyright (c) 2008 Matteo Frigo -# -# This program is free software: you can redistribute it and/or modify it -# under the terms of the GNU General Public License as published by the -# Free Software Foundation, either version 3 of the License, or (at your -# option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General -# Public License for more details. -# -# You should have received a copy of the GNU General Public License along -# with this program. If not, see . -# -# As a special exception, the respective Autoconf Macro's copyright owner -# gives unlimited permission to copy, distribute and modify the configure -# scripts that are the output of Autoconf when processing the Macro. You -# need not follow the terms of the GNU General Public License when using -# or distributing such scripts, even though portions of the text of the -# Macro appear in them. The GNU General Public License (GPL) does govern -# all other use of the material that constitutes the Autoconf Macro. -# -# This special exception to the GPL applies to versions of the Autoconf -# Macro released by the Autoconf Archive. When you make and distribute a -# modified version of the Autoconf Macro, you may extend this special -# exception to the GPL to apply to your modified version as well. - -#serial 13 - -AC_DEFUN([AX_CC_MAXOPT], -[ -AC_REQUIRE([AC_PROG_CC]) -AC_REQUIRE([AX_COMPILER_VENDOR]) -AC_REQUIRE([AC_CANONICAL_HOST]) - -AC_ARG_ENABLE(portable-binary, [AS_HELP_STRING([--enable-portable-binary], [disable compiler optimizations that would produce unportable binaries])], - acx_maxopt_portable=$enableval, acx_maxopt_portable=no) - -# Try to determine "good" native compiler flags if none specified via CFLAGS -if test "$ac_test_CFLAGS" != "set"; then - CFLAGS="" - case $ax_cv_c_compiler_vendor in - dec) CFLAGS="-newc -w0 -O5 -ansi_alias -ansi_args -fp_reorder -tune host" - if test "x$acx_maxopt_portable" = xno; then - CFLAGS="$CFLAGS -arch host" - fi;; - - sun) CFLAGS="-native -fast -xO5 -dalign" - if test "x$acx_maxopt_portable" = xyes; then - CFLAGS="$CFLAGS -xarch=generic" - fi;; - - hp) CFLAGS="+Oall +Optrs_ansi +DSnative" - if test "x$acx_maxopt_portable" = xyes; then - CFLAGS="$CFLAGS +DAportable" - fi;; - - ibm) if test "x$acx_maxopt_portable" = xno; then - xlc_opt="-qarch=auto -qtune=auto" - else - xlc_opt="-qtune=auto" - fi - AX_CHECK_COMPILE_FLAG($xlc_opt, - CFLAGS="-O3 -qansialias -w $xlc_opt", - [CFLAGS="-O3 -qansialias -w" - echo "******************************************************" - echo "* You seem to have the IBM C compiler. It is *" - echo "* recommended for best performance that you use: *" - echo "* *" - echo "* CFLAGS=-O3 -qarch=xxx -qtune=xxx -qansialias -w *" - echo "* ^^^ ^^^ *" - echo "* where xxx is pwr2, pwr3, 604, or whatever kind of *" - echo "* CPU you have. (Set the CFLAGS environment var. *" - echo "* and re-run configure.) For more info, man cc. *" - echo "******************************************************"]) - ;; - - intel) CFLAGS="-O3 -ansi_alias" - if test "x$acx_maxopt_portable" = xno; then - icc_archflag=unknown - icc_flags="" - case $host_cpu in - i686*|x86_64*) - # icc accepts gcc assembly syntax, so these should work: - AX_GCC_X86_CPUID(0) - AX_GCC_X86_CPUID(1) - case $ax_cv_gcc_x86_cpuid_0 in # see AX_GCC_ARCHFLAG - *:756e6547:*:*) # Intel - case $ax_cv_gcc_x86_cpuid_1 in - *6a?:*[[234]]:*:*|*6[[789b]]?:*:*:*) icc_flags="-xK";; - *f3[[347]]:*:*:*|*f4[1347]:*:*:*) icc_flags="-xP -xN -xW -xK";; - *f??:*:*:*) icc_flags="-xN -xW -xK";; - esac ;; - esac ;; - esac - if test "x$icc_flags" != x; then - for flag in $icc_flags; do - AX_CHECK_COMPILE_FLAG($flag, [icc_archflag=$flag; break]) - done - fi - AC_MSG_CHECKING([for icc architecture flag]) - AC_MSG_RESULT($icc_archflag) - if test "x$icc_archflag" != xunknown; then - CFLAGS="$CFLAGS $icc_archflag" - fi - fi - ;; - - gnu) - # default optimization flags for gcc on all systems - CFLAGS="-O3 -fomit-frame-pointer" - - # -malign-double for x86 systems - # LIBFFI -- DON'T DO THIS - CHANGES ABI - # AX_CHECK_COMPILE_FLAG(-malign-double, CFLAGS="$CFLAGS -malign-double") - - # -fstrict-aliasing for gcc-2.95+ - AX_CHECK_COMPILE_FLAG(-fstrict-aliasing, - CFLAGS="$CFLAGS -fstrict-aliasing") - - # note that we enable "unsafe" fp optimization with other compilers, too - AX_CHECK_COMPILE_FLAG(-ffast-math, CFLAGS="$CFLAGS -ffast-math") - - AX_GCC_ARCHFLAG($acx_maxopt_portable) - ;; - esac - - if test -z "$CFLAGS"; then - echo "" - echo "********************************************************" - echo "* WARNING: Don't know the best CFLAGS for this system *" - echo "* Use ./configure CFLAGS=... to specify your own flags *" - echo "* (otherwise, a default of CFLAGS=-O3 will be used) *" - echo "********************************************************" - echo "" - CFLAGS="-O3" - fi - - AX_CHECK_COMPILE_FLAG($CFLAGS, [], [ - echo "" - echo "********************************************************" - echo "* WARNING: The guessed CFLAGS don't seem to work with *" - echo "* your compiler. *" - echo "* Use ./configure CFLAGS=... to specify your own flags *" - echo "********************************************************" - echo "" - CFLAGS="" - ]) - -fi -]) diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi/m4/ax_cflags_warn_all.m4 --- a/Modules/_ctypes/libffi/m4/ax_cflags_warn_all.m4 Sat Jul 19 16:34:33 2014 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,122 +0,0 @@ -# =========================================================================== -# http://www.gnu.org/software/autoconf-archive/ax_cflags_warn_all.html -# =========================================================================== -# -# SYNOPSIS -# -# AX_CFLAGS_WARN_ALL [(shellvar [,default, [A/NA]])] -# AX_CXXFLAGS_WARN_ALL [(shellvar [,default, [A/NA]])] -# AX_FCFLAGS_WARN_ALL [(shellvar [,default, [A/NA]])] -# -# DESCRIPTION -# -# Try to find a compiler option that enables most reasonable warnings. -# -# For the GNU compiler it will be -Wall (and -ansi -pedantic) The result -# is added to the shellvar being CFLAGS, CXXFLAGS, or FCFLAGS by default. -# -# Currently this macro knows about the GCC, Solaris, Digital Unix, AIX, -# HP-UX, IRIX, NEC SX-5 (Super-UX 10), Cray J90 (Unicos 10.0.0.8), and -# Intel compilers. For a given compiler, the Fortran flags are much more -# experimental than their C equivalents. -# -# - $1 shell-variable-to-add-to : CFLAGS, CXXFLAGS, or FCFLAGS -# - $2 add-value-if-not-found : nothing -# - $3 action-if-found : add value to shellvariable -# - $4 action-if-not-found : nothing -# -# NOTE: These macros depend on AX_APPEND_FLAG. -# -# LICENSE -# -# Copyright (c) 2008 Guido U. Draheim -# Copyright (c) 2010 Rhys Ulerich -# -# This program is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License as published by the -# Free Software Foundation; either version 3 of the License, or (at your -# option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General -# Public License for more details. -# -# You should have received a copy of the GNU General Public License along -# with this program. If not, see . -# -# As a special exception, the respective Autoconf Macro's copyright owner -# gives unlimited permission to copy, distribute and modify the configure -# scripts that are the output of Autoconf when processing the Macro. You -# need not follow the terms of the GNU General Public License when using -# or distributing such scripts, even though portions of the text of the -# Macro appear in them. The GNU General Public License (GPL) does govern -# all other use of the material that constitutes the Autoconf Macro. -# -# This special exception to the GPL applies to versions of the Autoconf -# Macro released by the Autoconf Archive. When you make and distribute a -# modified version of the Autoconf Macro, you may extend this special -# exception to the GPL to apply to your modified version as well. - -#serial 14 - -AC_DEFUN([AX_FLAGS_WARN_ALL],[dnl -AS_VAR_PUSHDEF([FLAGS],[_AC_LANG_PREFIX[]FLAGS])dnl -AS_VAR_PUSHDEF([VAR],[ac_cv_[]_AC_LANG_ABBREV[]flags_warn_all])dnl -AC_CACHE_CHECK([m4_ifval($1,$1,FLAGS) for maximum warnings], -VAR,[VAR="no, unknown" -ac_save_[]FLAGS="$[]FLAGS" -for ac_arg dnl -in "-warn all % -warn all" dnl Intel - "-pedantic % -Wall" dnl GCC - "-xstrconst % -v" dnl Solaris C - "-std1 % -verbose -w0 -warnprotos" dnl Digital Unix - "-qlanglvl=ansi % -qsrcmsg -qinfo=all:noppt:noppc:noobs:nocnd" dnl AIX - "-ansi -ansiE % -fullwarn" dnl IRIX - "+ESlit % +w1" dnl HP-UX C - "-Xc % -pvctl[,]fullmsg" dnl NEC SX-5 (Super-UX 10) - "-h conform % -h msglevel 2" dnl Cray C (Unicos) - # -do FLAGS="$ac_save_[]FLAGS "`echo $ac_arg | sed -e 's,%%.*,,' -e 's,%,,'` - AC_COMPILE_IFELSE([AC_LANG_PROGRAM], - [VAR=`echo $ac_arg | sed -e 's,.*% *,,'` ; break]) -done -FLAGS="$ac_save_[]FLAGS" -]) -AS_VAR_POPDEF([FLAGS])dnl -AC_REQUIRE([AX_APPEND_FLAG]) -case ".$VAR" in - .ok|.ok,*) m4_ifvaln($3,$3) ;; - .|.no|.no,*) m4_default($4,[m4_ifval($2,[AX_APPEND_FLAG([$2], [$1])])]) ;; - *) m4_default($3,[AX_APPEND_FLAG([$VAR], [$1])]) ;; -esac -AS_VAR_POPDEF([VAR])dnl -])dnl AX_FLAGS_WARN_ALL -dnl implementation tactics: -dnl the for-argument contains a list of options. The first part of -dnl these does only exist to detect the compiler - usually it is -dnl a global option to enable -ansi or -extrawarnings. All other -dnl compilers will fail about it. That was needed since a lot of -dnl compilers will give false positives for some option-syntax -dnl like -Woption or -Xoption as they think of it is a pass-through -dnl to later compile stages or something. The "%" is used as a -dnl delimiter. A non-option comment can be given after "%%" marks -dnl which will be shown but not added to the respective C/CXXFLAGS. - -AC_DEFUN([AX_CFLAGS_WARN_ALL],[dnl -AC_LANG_PUSH([C]) -AX_FLAGS_WARN_ALL([$1], [$2], [$3], [$4]) -AC_LANG_POP([C]) -]) - -AC_DEFUN([AX_CXXFLAGS_WARN_ALL],[dnl -AC_LANG_PUSH([C++]) -AX_FLAGS_WARN_ALL([$1], [$2], [$3], [$4]) -AC_LANG_POP([C++]) -]) - -AC_DEFUN([AX_FCFLAGS_WARN_ALL],[dnl -AC_LANG_PUSH([Fortran]) -AX_FLAGS_WARN_ALL([$1], [$2], [$3], [$4]) -AC_LANG_POP([Fortran]) -]) diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi/m4/ax_check_compile_flag.m4 --- a/Modules/_ctypes/libffi/m4/ax_check_compile_flag.m4 Sat Jul 19 16:34:33 2014 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,72 +0,0 @@ -# =========================================================================== -# http://www.gnu.org/software/autoconf-archive/ax_check_compile_flag.html -# =========================================================================== -# -# SYNOPSIS -# -# AX_CHECK_COMPILE_FLAG(FLAG, [ACTION-SUCCESS], [ACTION-FAILURE], [EXTRA-FLAGS]) -# -# DESCRIPTION -# -# Check whether the given FLAG works with the current language's compiler -# or gives an error. (Warnings, however, are ignored) -# -# ACTION-SUCCESS/ACTION-FAILURE are shell commands to execute on -# success/failure. -# -# If EXTRA-FLAGS is defined, it is added to the current language's default -# flags (e.g. CFLAGS) when the check is done. The check is thus made with -# the flags: "CFLAGS EXTRA-FLAGS FLAG". This can for example be used to -# force the compiler to issue an error when a bad flag is given. -# -# NOTE: Implementation based on AX_CFLAGS_GCC_OPTION. Please keep this -# macro in sync with AX_CHECK_{PREPROC,LINK}_FLAG. -# -# LICENSE -# -# Copyright (c) 2008 Guido U. Draheim -# Copyright (c) 2011 Maarten Bosmans -# -# This program is free software: you can redistribute it and/or modify it -# under the terms of the GNU General Public License as published by the -# Free Software Foundation, either version 3 of the License, or (at your -# option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General -# Public License for more details. -# -# You should have received a copy of the GNU General Public License along -# with this program. If not, see . -# -# As a special exception, the respective Autoconf Macro's copyright owner -# gives unlimited permission to copy, distribute and modify the configure -# scripts that are the output of Autoconf when processing the Macro. You -# need not follow the terms of the GNU General Public License when using -# or distributing such scripts, even though portions of the text of the -# Macro appear in them. The GNU General Public License (GPL) does govern -# all other use of the material that constitutes the Autoconf Macro. -# -# This special exception to the GPL applies to versions of the Autoconf -# Macro released by the Autoconf Archive. When you make and distribute a -# modified version of the Autoconf Macro, you may extend this special -# exception to the GPL to apply to your modified version as well. - -#serial 2 - -AC_DEFUN([AX_CHECK_COMPILE_FLAG], -[AC_PREREQ(2.59)dnl for _AC_LANG_PREFIX -AS_VAR_PUSHDEF([CACHEVAR],[ax_cv_check_[]_AC_LANG_ABBREV[]flags_$4_$1])dnl -AC_CACHE_CHECK([whether _AC_LANG compiler accepts $1], CACHEVAR, [ - ax_check_save_flags=$[]_AC_LANG_PREFIX[]FLAGS - _AC_LANG_PREFIX[]FLAGS="$[]_AC_LANG_PREFIX[]FLAGS $4 $1" - AC_COMPILE_IFELSE([AC_LANG_PROGRAM()], - [AS_VAR_SET(CACHEVAR,[yes])], - [AS_VAR_SET(CACHEVAR,[no])]) - _AC_LANG_PREFIX[]FLAGS=$ax_check_save_flags]) -AS_IF([test x"AS_VAR_GET(CACHEVAR)" = xyes], - [m4_default([$2], :)], - [m4_default([$3], :)]) -AS_VAR_POPDEF([CACHEVAR])dnl -])dnl AX_CHECK_COMPILE_FLAGS diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi/m4/ax_compiler_vendor.m4 --- a/Modules/_ctypes/libffi/m4/ax_compiler_vendor.m4 Sat Jul 19 16:34:33 2014 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,84 +0,0 @@ -# =========================================================================== -# http://www.gnu.org/software/autoconf-archive/ax_compiler_vendor.html -# =========================================================================== -# -# SYNOPSIS -# -# AX_COMPILER_VENDOR -# -# DESCRIPTION -# -# Determine the vendor of the C/C++ compiler, e.g., gnu, intel, ibm, sun, -# hp, borland, comeau, dec, cray, kai, lcc, metrowerks, sgi, microsoft, -# watcom, etc. The vendor is returned in the cache variable -# $ax_cv_c_compiler_vendor for C and $ax_cv_cxx_compiler_vendor for C++. -# -# LICENSE -# -# Copyright (c) 2008 Steven G. Johnson -# Copyright (c) 2008 Matteo Frigo -# -# This program is free software: you can redistribute it and/or modify it -# under the terms of the GNU General Public License as published by the -# Free Software Foundation, either version 3 of the License, or (at your -# option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General -# Public License for more details. -# -# You should have received a copy of the GNU General Public License along -# with this program. If not, see . -# -# As a special exception, the respective Autoconf Macro's copyright owner -# gives unlimited permission to copy, distribute and modify the configure -# scripts that are the output of Autoconf when processing the Macro. You -# need not follow the terms of the GNU General Public License when using -# or distributing such scripts, even though portions of the text of the -# Macro appear in them. The GNU General Public License (GPL) does govern -# all other use of the material that constitutes the Autoconf Macro. -# -# This special exception to the GPL applies to versions of the Autoconf -# Macro released by the Autoconf Archive. When you make and distribute a -# modified version of the Autoconf Macro, you may extend this special -# exception to the GPL to apply to your modified version as well. - -#serial 11 - -AC_DEFUN([AX_COMPILER_VENDOR], -[AC_CACHE_CHECK([for _AC_LANG compiler vendor], ax_cv_[]_AC_LANG_ABBREV[]_compiler_vendor, - [# note: don't check for gcc first since some other compilers define __GNUC__ - vendors="intel: __ICC,__ECC,__INTEL_COMPILER - ibm: __xlc__,__xlC__,__IBMC__,__IBMCPP__ - pathscale: __PATHCC__,__PATHSCALE__ - clang: __clang__ - gnu: __GNUC__ - sun: __SUNPRO_C,__SUNPRO_CC - hp: __HP_cc,__HP_aCC - dec: __DECC,__DECCXX,__DECC_VER,__DECCXX_VER - borland: __BORLANDC__,__TURBOC__ - comeau: __COMO__ - cray: _CRAYC - kai: __KCC - lcc: __LCC__ - sgi: __sgi,sgi - microsoft: _MSC_VER - metrowerks: __MWERKS__ - watcom: __WATCOMC__ - portland: __PGI - unknown: UNKNOWN" - for ventest in $vendors; do - case $ventest in - *:) vendor=$ventest; continue ;; - *) vencpp="defined("`echo $ventest | sed 's/,/) || defined(/g'`")" ;; - esac - AC_COMPILE_IFELSE([AC_LANG_PROGRAM(,[ - #if !($vencpp) - thisisanerror; - #endif - ])], [break]) - done - ax_cv_[]_AC_LANG_ABBREV[]_compiler_vendor=`echo $vendor | cut -d: -f1` - ]) -]) diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi/m4/ax_configure_args.m4 --- a/Modules/_ctypes/libffi/m4/ax_configure_args.m4 Sat Jul 19 16:34:33 2014 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,70 +0,0 @@ -# =========================================================================== -# http://www.gnu.org/software/autoconf-archive/ax_configure_args.html -# =========================================================================== -# -# SYNOPSIS -# -# AX_CONFIGURE_ARGS -# -# DESCRIPTION -# -# Helper macro for AX_ENABLE_BUILDDIR. -# -# The traditional way of starting a subdir-configure is running the script -# with ${1+"$@"} but since autoconf 2.60 this is broken. Instead we have -# to rely on eval'ing $ac_configure_args however some old autoconf -# versions do not provide that. To ensure maximum portability of autoconf -# extension macros this helper can be AC_REQUIRE'd so that -# $ac_configure_args will alsways be present. -# -# Sadly, the traditional "exec $SHELL" of the enable_builddir macros is -# spoiled now and must be replaced by "eval + exit $?". -# -# Example: -# -# AC_DEFUN([AX_ENABLE_SUBDIR],[dnl -# AC_REQUIRE([AX_CONFIGURE_ARGS])dnl -# eval $SHELL $ac_configure_args || exit $? -# ...]) -# -# LICENSE -# -# Copyright (c) 2008 Guido U. Draheim -# -# This program is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License as published by the -# Free Software Foundation; either version 3 of the License, or (at your -# option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General -# Public License for more details. -# -# You should have received a copy of the GNU General Public License along -# with this program. If not, see . -# -# As a special exception, the respective Autoconf Macro's copyright owner -# gives unlimited permission to copy, distribute and modify the configure -# scripts that are the output of Autoconf when processing the Macro. You -# need not follow the terms of the GNU General Public License when using -# or distributing such scripts, even though portions of the text of the -# Macro appear in them. The GNU General Public License (GPL) does govern -# all other use of the material that constitutes the Autoconf Macro. -# -# This special exception to the GPL applies to versions of the Autoconf -# Macro released by the Autoconf Archive. When you make and distribute a -# modified version of the Autoconf Macro, you may extend this special -# exception to the GPL to apply to your modified version as well. - -#serial 9 - -AC_DEFUN([AX_CONFIGURE_ARGS],[ - # [$]@ is unsable in 2.60+ but earlier autoconf had no ac_configure_args - if test "${ac_configure_args+set}" != "set" ; then - ac_configure_args= - for ac_arg in ${1+"[$]@"}; do - ac_configure_args="$ac_configure_args '$ac_arg'" - done - fi -]) diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi/m4/ax_enable_builddir.m4 --- a/Modules/_ctypes/libffi/m4/ax_enable_builddir.m4 Sat Jul 19 16:34:33 2014 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,300 +0,0 @@ -# =========================================================================== -# http://www.gnu.org/software/autoconf-archive/ax_enable_builddir.html -# =========================================================================== -# -# SYNOPSIS -# -# AX_ENABLE_BUILDDIR [(dirstring-or-command [,Makefile.mk [,-all]])] -# -# DESCRIPTION -# -# If the current configure was run within the srcdir then we move all -# configure-files into a subdir and let the configure steps continue -# there. We provide an option --disable-builddir to suppress the move into -# a separate builddir. -# -# Defaults: -# -# $1 = $host (overridden with $HOST) -# $2 = Makefile.mk -# $3 = -all -# -# This macro must be called before AM_INIT_AUTOMAKE. It creates a default -# toplevel srcdir Makefile from the information found in the created -# toplevel builddir Makefile. It just copies the variables and -# rule-targets, each extended with a default rule-execution that recurses -# into the build directory of the current "HOST". You can override the -# auto-dection through `config.guess` and build-time of course, as in -# -# make HOST=i386-mingw-cross -# -# which can of course set at configure time as well using -# -# configure --host=i386-mingw-cross -# -# After the default has been created, additional rules can be appended -# that will not just recurse into the subdirectories and only ever exist -# in the srcdir toplevel makefile - these parts are read from the $2 = -# Makefile.mk file -# -# The automatic rules are usually scanning the toplevel Makefile for lines -# like '#### $host |$builddir' to recognize the place where to recurse -# into. Usually, the last one is the only one used. However, almost all -# targets have an additional "*-all" rule which makes the script to -# recurse into _all_ variants of the current HOST (!!) setting. The "-all" -# suffix can be overriden for the macro as well. -# -# a special rule is only given for things like "dist" that will copy the -# tarball from the builddir to the sourcedir (or $(PUB)) for reason of -# convenience. -# -# LICENSE -# -# Copyright (c) 2009 Guido U. Draheim -# Copyright (c) 2009 Alan Jenkins -# -# This program is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License as published by the -# Free Software Foundation; either version 3 of the License, or (at your -# option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General -# Public License for more details. -# -# You should have received a copy of the GNU General Public License along -# with this program. If not, see . -# -# As a special exception, the respective Autoconf Macro's copyright owner -# gives unlimited permission to copy, distribute and modify the configure -# scripts that are the output of Autoconf when processing the Macro. You -# need not follow the terms of the GNU General Public License when using -# or distributing such scripts, even though portions of the text of the -# Macro appear in them. The GNU General Public License (GPL) does govern -# all other use of the material that constitutes the Autoconf Macro. -# -# This special exception to the GPL applies to versions of the Autoconf -# Macro released by the Autoconf Archive. When you make and distribute a -# modified version of the Autoconf Macro, you may extend this special -# exception to the GPL to apply to your modified version as well. - -#serial 23 - -AC_DEFUN([AX_ENABLE_BUILDDIR],[ -AC_REQUIRE([AC_CANONICAL_HOST])[]dnl -AC_REQUIRE([AX_CONFIGURE_ARGS])[]dnl -AC_REQUIRE([AM_AUX_DIR_EXPAND])[]dnl -AC_BEFORE([$0],[AM_INIT_AUTOMAKE])dnl -AS_VAR_PUSHDEF([SUB],[ax_enable_builddir])dnl -AS_VAR_PUSHDEF([AUX],[ax_enable_builddir_auxdir])dnl -AS_VAR_PUSHDEF([SED],[ax_enable_builddir_sed])dnl -SUB="." -AC_ARG_ENABLE([builddir], AS_HELP_STRING( - [--disable-builddir],[disable automatic build in subdir of sources]) - ,[SUB="$enableval"], [SUB="auto"]) -if test ".$ac_srcdir_defaulted" != ".no" ; then -if test ".$srcdir" = ".." ; then - if test -f config.status ; then - AC_MSG_NOTICE(toplevel srcdir already configured... skipping subdir build) - else - test ".$SUB" = "." && SUB="." - test ".$SUB" = ".no" && SUB="." - test ".$TARGET" = "." && TARGET="$target" - test ".$SUB" = ".auto" && SUB="m4_ifval([$1], [$1],[$TARGET])" - if test ".$SUB" != ".." ; then # we know where to go and - AS_MKDIR_P([$SUB]) - echo __.$SUB.__ > $SUB/conftest.tmp - cd $SUB - if grep __.$SUB.__ conftest.tmp >/dev/null 2>/dev/null ; then - rm conftest.tmp - AC_MSG_RESULT([continue configure in default builddir "./$SUB"]) - else - AC_MSG_ERROR([could not change to default builddir "./$SUB"]) - fi - srcdir=`echo "$SUB" | - sed -e 's,^\./,,;s,[[^/]]$,&/,;s,[[^/]]*/,../,g;s,[[/]]$,,;'` - # going to restart from subdirectory location - test -f $srcdir/config.log && mv $srcdir/config.log . - test -f $srcdir/confdefs.h && mv $srcdir/confdefs.h . - test -f $srcdir/conftest.log && mv $srcdir/conftest.log . - test -f $srcdir/$cache_file && mv $srcdir/$cache_file . - AC_MSG_RESULT(....exec $SHELL $srcdir/[$]0 "--srcdir=$srcdir" "--enable-builddir=$SUB" ${1+"[$]@"}) - case "[$]0" in # restart - [/\\]*) eval $SHELL "'[$]0'" "'--srcdir=$srcdir'" "'--enable-builddir=$SUB'" $ac_configure_args ;; - *) eval $SHELL "'$srcdir/[$]0'" "'--srcdir=$srcdir'" "'--enable-builddir=$SUB'" $ac_configure_args ;; - esac ; exit $? - fi - fi -fi fi -test ".$SUB" = ".auto" && SUB="." -dnl ac_path_prog uses "set dummy" to override $@ which would defeat the "exec" -AC_PATH_PROG(SED,gsed sed, sed) -AUX="$am_aux_dir" -AS_VAR_POPDEF([SED])dnl -AS_VAR_POPDEF([AUX])dnl -AS_VAR_POPDEF([SUB])dnl -AC_CONFIG_COMMANDS([buildir],[dnl .............. config.status .............. -AS_VAR_PUSHDEF([SUB],[ax_enable_builddir])dnl -AS_VAR_PUSHDEF([TOP],[top_srcdir])dnl -AS_VAR_PUSHDEF([SRC],[ac_top_srcdir])dnl -AS_VAR_PUSHDEF([AUX],[ax_enable_builddir_auxdir])dnl -AS_VAR_PUSHDEF([SED],[ax_enable_builddir_sed])dnl -pushdef([END],[Makefile.mk])dnl -pushdef([_ALL],[ifelse([$3],,[-all],[$3])])dnl - SRC="$ax_enable_builddir_srcdir" - if test ".$SUB" = ".." ; then - if test -f "$TOP/Makefile" ; then - AC_MSG_NOTICE([skipping TOP/Makefile - left untouched]) - else - AC_MSG_NOTICE([skipping TOP/Makefile - not created]) - fi - else - if test -f "$SRC/Makefile" ; then - a=`grep "^VERSION " "$SRC/Makefile"` ; b=`grep "^VERSION " Makefile` - test "$a" != "$b" && rm "$SRC/Makefile" - fi - if test -f "$SRC/Makefile" ; then - echo "$SRC/Makefile : $SRC/Makefile.in" > $tmp/conftemp.mk - echo " []@ echo 'REMOVED,,,' >\$[]@" >> $tmp/conftemp.mk - eval "${MAKE-make} -f $tmp/conftemp.mk 2>/dev/null >/dev/null" - if grep '^REMOVED,,,' "$SRC/Makefile" >/dev/null - then rm $SRC/Makefile ; fi - cp $tmp/conftemp.mk $SRC/makefiles.mk~ ## DEBUGGING - fi - if test ! -f "$SRC/Makefile" ; then - AC_MSG_NOTICE([create TOP/Makefile guessed from local Makefile]) - x='`' ; cat >$tmp/conftemp.sed <<_EOF -/^\$/n -x -/^\$/bS -x -/\\\\\$/{H;d;} -{H;s/.*//;x;} -bM -:S -x -/\\\\\$/{h;d;} -{h;s/.*//;x;} -:M -s/\\(\\n\\) /\\1 /g -/^ /d -/^[[ ]]*[[\\#]]/d -/^VPATH *=/d -s/^srcdir *=.*/srcdir = ./ -s/^top_srcdir *=.*/top_srcdir = ./ -/[[:=]]/!d -/^\\./d -dnl Now handle rules (i.e. lines containing ":" but not " = "). -/ = /b -/ .= /b -/:/!b -s/:.*/:/ -s/ / /g -s/ \\([[a-z]][[a-z-]]*[[a-zA-Z0-9]]\\)\\([[ :]]\\)/ \\1 \\1[]_ALL\\2/g -s/^\\([[a-z]][[a-z-]]*[[a-zA-Z0-9]]\\)\\([[ :]]\\)/\\1 \\1[]_ALL\\2/ -s/ / /g -/^all all[]_ALL[[ :]]/i\\ -all-configured : all[]_ALL -dnl dist-all exists... and would make for dist-all-all -s/ [[a-zA-Z0-9-]]*[]_ALL [[a-zA-Z0-9-]]*[]_ALL[]_ALL//g -/[]_ALL[]_ALL/d -a\\ - @ HOST="\$(HOST)\" \\\\\\ - ; test ".\$\$HOST" = "." && HOST=$x sh $AUX/config.guess $x \\\\\\ - ; BUILD=$x grep "^#### \$\$HOST " Makefile | sed -e 's/.*|//' $x \\\\\\ - ; use=$x basename "\$\@" _ALL $x; n=$x echo \$\$BUILD | wc -w $x \\\\\\ - ; echo "MAKE \$\$HOST : \$\$n * \$\@"; if test "\$\$n" -eq "0" ; then : \\\\\\ - ; BUILD=$x grep "^####.*|" Makefile |tail -1| sed -e 's/.*|//' $x ; fi \\\\\\ - ; test ".\$\$BUILD" = "." && BUILD="." \\\\\\ - ; test "\$\$use" = "\$\@" && BUILD=$x echo "\$\$BUILD" | tail -1 $x \\\\\\ - ; for i in \$\$BUILD ; do test ".\$\$i" = "." && continue \\\\\\ - ; (cd "\$\$i" && test ! -f configure && \$(MAKE) \$\$use) || exit; done -dnl special rule add-on: "dist" copies the tarball to $(PUB). (source tree) -/dist[]_ALL *:/a\\ - @ HOST="\$(HOST)\" \\\\\\ - ; test ".\$\$HOST" = "." && HOST=$x sh $AUX/config.guess $x \\\\\\ - ; BUILD=$x grep "^#### \$\$HOST " Makefile | sed -e 's/.*|//' $x \\\\\\ - ; found=$x echo \$\$BUILD | wc -w $x \\\\\\ - ; echo "MAKE \$\$HOST : \$\$found \$(PACKAGE)-\$(VERSION).tar.*" \\\\\\ - ; if test "\$\$found" -eq "0" ; then : \\\\\\ - ; BUILD=$x grep "^#### .*|" Makefile |tail -1| sed -e 's/.*|//' $x \\\\\\ - ; fi ; for i in \$\$BUILD ; do test ".\$\$i" = "." && continue \\\\\\ - ; for f in \$\$i/\$(PACKAGE)-\$(VERSION).tar.* \\\\\\ - ; do test -f "\$\$f" && mv "\$\$f" \$(PUB). ; done ; break ; done -dnl special rule add-on: "dist-foo" copies all the archives to $(PUB). (source tree) -/dist-[[a-zA-Z0-9]]*[]_ALL *:/a\\ - @ HOST="\$(HOST)\" \\\\\\ - ; test ".\$\$HOST" = "." && HOST=$x sh ./config.guess $x \\\\\\ - ; BUILD=$x grep "^#### \$\$HOST " Makefile | sed -e 's/.*|//' $x \\\\\\ - ; found=$x echo \$\$BUILD | wc -w $x \\\\\\ - ; echo "MAKE \$\$HOST : \$\$found \$(PACKAGE)-\$(VERSION).*" \\\\\\ - ; if test "\$\$found" -eq "0" ; then : \\\\\\ - ; BUILD=$x grep "^#### .*|" Makefile |tail -1| sed -e 's/.*|//' $x \\\\\\ - ; fi ; for i in \$\$BUILD ; do test ".\$\$i" = "." && continue \\\\\\ - ; for f in \$\$i/\$(PACKAGE)-\$(VERSION).* \\\\\\ - ; do test -f "\$\$f" && mv "\$\$f" \$(PUB). ; done ; break ; done -dnl special rule add-on: "distclean" removes all local builddirs completely -/distclean[]_ALL *:/a\\ - @ HOST="\$(HOST)\" \\\\\\ - ; test ".\$\$HOST" = "." && HOST=$x sh $AUX/config.guess $x \\\\\\ - ; BUILD=$x grep "^#### .*|" Makefile | sed -e 's/.*|//' $x \\\\\\ - ; use=$x basename "\$\@" _ALL $x; n=$x echo \$\$BUILD | wc -w $x \\\\\\ - ; echo "MAKE \$\$HOST : \$\$n * \$\@ (all local builds)" \\\\\\ - ; test ".\$\$BUILD" = "." && BUILD="." \\\\\\ - ; for i in \$\$BUILD ; do test ".\$\$i" = "." && continue \\\\\\ - ; echo "# rm -r \$\$i"; done ; echo "# (sleep 3)" ; sleep 3 \\\\\\ - ; for i in \$\$BUILD ; do test ".\$\$i" = "." && continue \\\\\\ - ; echo "\$\$i" | grep "^/" > /dev/null && continue \\\\\\ - ; echo "\$\$i" | grep "^../" > /dev/null && continue \\\\\\ - ; echo "rm -r \$\$i"; (rm -r "\$\$i") ; done ; rm Makefile -_EOF - cp "$tmp/conftemp.sed" "$SRC/makefile.sed~" ## DEBUGGING - $SED -f $tmp/conftemp.sed Makefile >$SRC/Makefile - if test -f "$SRC/m4_ifval([$2],[$2],[END])" ; then - AC_MSG_NOTICE([extend TOP/Makefile with TOP/m4_ifval([$2],[$2],[END])]) - cat $SRC/END >>$SRC/Makefile - fi ; xxxx="####" - echo "$xxxx CONFIGURATIONS FOR TOPLEVEL MAKEFILE: " >>$SRC/Makefile - # sanity check - if grep '^; echo "MAKE ' $SRC/Makefile >/dev/null ; then - AC_MSG_NOTICE([buggy sed found - it deletes tab in "a" text parts]) - $SED -e '/^@ HOST=/s/^/ /' -e '/^; /s/^/ /' $SRC/Makefile \ - >$SRC/Makefile~ - (test -s $SRC/Makefile~ && mv $SRC/Makefile~ $SRC/Makefile) 2>/dev/null - fi - else - xxxx="\\#\\#\\#\\#" - # echo "/^$xxxx *$ax_enable_builddir_host /d" >$tmp/conftemp.sed - echo "s!^$xxxx [[^|]]* | *$SUB *\$!$xxxx ...... $SUB!" >$tmp/conftemp.sed - $SED -f "$tmp/conftemp.sed" "$SRC/Makefile" >$tmp/mkfile.tmp - cp "$tmp/conftemp.sed" "$SRC/makefiles.sed~" ## DEBUGGING - cp "$tmp/mkfile.tmp" "$SRC/makefiles.out~" ## DEBUGGING - if cmp -s "$SRC/Makefile" "$tmp/mkfile.tmp" 2>/dev/null ; then - AC_MSG_NOTICE([keeping TOP/Makefile from earlier configure]) - rm "$tmp/mkfile.tmp" - else - AC_MSG_NOTICE([reusing TOP/Makefile from earlier configure]) - mv "$tmp/mkfile.tmp" "$SRC/Makefile" - fi - fi - AC_MSG_NOTICE([build in $SUB (HOST=$ax_enable_builddir_host)]) - xxxx="####" - echo "$xxxx" "$ax_enable_builddir_host" "|$SUB" >>$SRC/Makefile - fi -popdef([END])dnl -AS_VAR_POPDEF([SED])dnl -AS_VAR_POPDEF([AUX])dnl -AS_VAR_POPDEF([SRC])dnl -AS_VAR_POPDEF([TOP])dnl -AS_VAR_POPDEF([SUB])dnl -],[dnl -ax_enable_builddir_srcdir="$srcdir" # $srcdir -ax_enable_builddir_host="$HOST" # $HOST / $host -ax_enable_builddir_version="$VERSION" # $VERSION -ax_enable_builddir_package="$PACKAGE" # $PACKAGE -ax_enable_builddir_auxdir="$ax_enable_builddir_auxdir" # $AUX -ax_enable_builddir_sed="$ax_enable_builddir_sed" # $SED -ax_enable_builddir="$ax_enable_builddir" # $SUB -])dnl -]) diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi/m4/ax_gcc_archflag.m4 --- a/Modules/_ctypes/libffi/m4/ax_gcc_archflag.m4 Sat Jul 19 16:34:33 2014 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,225 +0,0 @@ -# =========================================================================== -# http://www.gnu.org/software/autoconf-archive/ax_gcc_archflag.html -# =========================================================================== -# -# SYNOPSIS -# -# AX_GCC_ARCHFLAG([PORTABLE?], [ACTION-SUCCESS], [ACTION-FAILURE]) -# -# DESCRIPTION -# -# This macro tries to guess the "native" arch corresponding to the target -# architecture for use with gcc's -march=arch or -mtune=arch flags. If -# found, the cache variable $ax_cv_gcc_archflag is set to this flag and -# ACTION-SUCCESS is executed; otherwise $ax_cv_gcc_archflag is set to -# "unknown" and ACTION-FAILURE is executed. The default ACTION-SUCCESS is -# to add $ax_cv_gcc_archflag to the end of $CFLAGS. -# -# PORTABLE? should be either [yes] (default) or [no]. In the former case, -# the flag is set to -mtune (or equivalent) so that the architecture is -# only used for tuning, but the instruction set used is still portable. In -# the latter case, the flag is set to -march (or equivalent) so that -# architecture-specific instructions are enabled. -# -# The user can specify --with-gcc-arch= in order to override the -# macro's choice of architecture, or --without-gcc-arch to disable this. -# -# When cross-compiling, or if $CC is not gcc, then ACTION-FAILURE is -# called unless the user specified --with-gcc-arch manually. -# -# Requires macros: AX_CHECK_COMPILE_FLAG, AX_GCC_X86_CPUID -# -# (The main emphasis here is on recent CPUs, on the principle that doing -# high-performance computing on old hardware is uncommon.) -# -# LICENSE -# -# Copyright (c) 2008 Steven G. Johnson -# Copyright (c) 2008 Matteo Frigo -# Copyright (c) 2012 Tsukasa Oi -# -# This program is free software: you can redistribute it and/or modify it -# under the terms of the GNU General Public License as published by the -# Free Software Foundation, either version 3 of the License, or (at your -# option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General -# Public License for more details. -# -# You should have received a copy of the GNU General Public License along -# with this program. If not, see . -# -# As a special exception, the respective Autoconf Macro's copyright owner -# gives unlimited permission to copy, distribute and modify the configure -# scripts that are the output of Autoconf when processing the Macro. You -# need not follow the terms of the GNU General Public License when using -# or distributing such scripts, even though portions of the text of the -# Macro appear in them. The GNU General Public License (GPL) does govern -# all other use of the material that constitutes the Autoconf Macro. -# -# This special exception to the GPL applies to versions of the Autoconf -# Macro released by the Autoconf Archive. When you make and distribute a -# modified version of the Autoconf Macro, you may extend this special -# exception to the GPL to apply to your modified version as well. - -#serial 11 - -AC_DEFUN([AX_GCC_ARCHFLAG], -[AC_REQUIRE([AC_PROG_CC]) -AC_REQUIRE([AC_CANONICAL_HOST]) - -AC_ARG_WITH(gcc-arch, [AS_HELP_STRING([--with-gcc-arch=], [use architecture for gcc -march/-mtune, instead of guessing])], - ax_gcc_arch=$withval, ax_gcc_arch=yes) - -AC_MSG_CHECKING([for gcc architecture flag]) -AC_MSG_RESULT([]) -AC_CACHE_VAL(ax_cv_gcc_archflag, -[ -ax_cv_gcc_archflag="unknown" - -if test "$GCC" = yes; then - -if test "x$ax_gcc_arch" = xyes; then -ax_gcc_arch="" -if test "$cross_compiling" = no; then -case $host_cpu in - i[[3456]]86*|x86_64*) # use cpuid codes - AX_GCC_X86_CPUID(0) - AX_GCC_X86_CPUID(1) - case $ax_cv_gcc_x86_cpuid_0 in - *:756e6547:*:*) # Intel - case $ax_cv_gcc_x86_cpuid_1 in - *5[[48]]?:*:*:*) ax_gcc_arch="pentium-mmx pentium" ;; - *5??:*:*:*) ax_gcc_arch=pentium ;; - *0?6[[3456]]?:*:*:*) ax_gcc_arch="pentium2 pentiumpro" ;; - *0?6a?:*[[01]]:*:*) ax_gcc_arch="pentium2 pentiumpro" ;; - *0?6a?:*[[234]]:*:*) ax_gcc_arch="pentium3 pentiumpro" ;; - *0?6[[9de]]?:*:*:*) ax_gcc_arch="pentium-m pentium3 pentiumpro" ;; - *0?6[[78b]]?:*:*:*) ax_gcc_arch="pentium3 pentiumpro" ;; - *0?6f?:*:*:*|*1?66?:*:*:*) ax_gcc_arch="core2 pentium-m pentium3 pentiumpro" ;; - *1?6[[7d]]?:*:*:*) ax_gcc_arch="penryn core2 pentium-m pentium3 pentiumpro" ;; - *1?6[[aef]]?:*:*:*|*2?6[[5cef]]?:*:*:*) ax_gcc_arch="corei7 core2 pentium-m pentium3 pentiumpro" ;; - *1?6c?:*:*:*|*[[23]]?66?:*:*:*) ax_gcc_arch="atom core2 pentium-m pentium3 pentiumpro" ;; - *2?6[[ad]]?:*:*:*) ax_gcc_arch="corei7-avx corei7 core2 pentium-m pentium3 pentiumpro" ;; - *0?6??:*:*:*) ax_gcc_arch=pentiumpro ;; - *6??:*:*:*) ax_gcc_arch="core2 pentiumpro" ;; - ?000?f3[[347]]:*:*:*|?000?f4[1347]:*:*:*|?000?f6?:*:*:*) - case $host_cpu in - x86_64*) ax_gcc_arch="nocona pentium4 pentiumpro" ;; - *) ax_gcc_arch="prescott pentium4 pentiumpro" ;; - esac ;; - ?000?f??:*:*:*) ax_gcc_arch="pentium4 pentiumpro";; - esac ;; - *:68747541:*:*) # AMD - case $ax_cv_gcc_x86_cpuid_1 in - *5[[67]]?:*:*:*) ax_gcc_arch=k6 ;; - *5[[8d]]?:*:*:*) ax_gcc_arch="k6-2 k6" ;; - *5[[9]]?:*:*:*) ax_gcc_arch="k6-3 k6" ;; - *60?:*:*:*) ax_gcc_arch=k7 ;; - *6[[12]]?:*:*:*) ax_gcc_arch="athlon k7" ;; - *6[[34]]?:*:*:*) ax_gcc_arch="athlon-tbird k7" ;; - *67?:*:*:*) ax_gcc_arch="athlon-4 athlon k7" ;; - *6[[68a]]?:*:*:*) - AX_GCC_X86_CPUID(0x80000006) # L2 cache size - case $ax_cv_gcc_x86_cpuid_0x80000006 in - *:*:*[[1-9a-f]]??????:*) # (L2 = ecx >> 16) >= 256 - ax_gcc_arch="athlon-xp athlon-4 athlon k7" ;; - *) ax_gcc_arch="athlon-4 athlon k7" ;; - esac ;; - ?00??f[[4cef8b]]?:*:*:*) ax_gcc_arch="athlon64 k8" ;; - ?00??f5?:*:*:*) ax_gcc_arch="opteron k8" ;; - ?00??f7?:*:*:*) ax_gcc_arch="athlon-fx opteron k8" ;; - ?00??f??:*:*:*) ax_gcc_arch="k8" ;; - ?05??f??:*:*:*) ax_gcc_arch="btver1 amdfam10 k8" ;; - ?06??f??:*:*:*) ax_gcc_arch="bdver1 amdfam10 k8" ;; - *f??:*:*:*) ax_gcc_arch="amdfam10 k8" ;; - esac ;; - *:746e6543:*:*) # IDT - case $ax_cv_gcc_x86_cpuid_1 in - *54?:*:*:*) ax_gcc_arch=winchip-c6 ;; - *58?:*:*:*) ax_gcc_arch=winchip2 ;; - *6[[78]]?:*:*:*) ax_gcc_arch=c3 ;; - *69?:*:*:*) ax_gcc_arch="c3-2 c3" ;; - esac ;; - esac - if test x"$ax_gcc_arch" = x; then # fallback - case $host_cpu in - i586*) ax_gcc_arch=pentium ;; - i686*) ax_gcc_arch=pentiumpro ;; - esac - fi - ;; - - sparc*) - AC_PATH_PROG([PRTDIAG], [prtdiag], [prtdiag], [$PATH:/usr/platform/`uname -i`/sbin/:/usr/platform/`uname -m`/sbin/]) - cputype=`(((grep cpu /proc/cpuinfo | cut -d: -f2) ; ($PRTDIAG -v |grep -i sparc) ; grep -i cpu /var/run/dmesg.boot ) | head -n 1) 2> /dev/null` - cputype=`echo "$cputype" | tr -d ' -' |tr $as_cr_LETTERS $as_cr_letters` - case $cputype in - *ultrasparciv*) ax_gcc_arch="ultrasparc4 ultrasparc3 ultrasparc v9" ;; - *ultrasparciii*) ax_gcc_arch="ultrasparc3 ultrasparc v9" ;; - *ultrasparc*) ax_gcc_arch="ultrasparc v9" ;; - *supersparc*|*tms390z5[[05]]*) ax_gcc_arch="supersparc v8" ;; - *hypersparc*|*rt62[[056]]*) ax_gcc_arch="hypersparc v8" ;; - *cypress*) ax_gcc_arch=cypress ;; - esac ;; - - alphaev5) ax_gcc_arch=ev5 ;; - alphaev56) ax_gcc_arch=ev56 ;; - alphapca56) ax_gcc_arch="pca56 ev56" ;; - alphapca57) ax_gcc_arch="pca57 pca56 ev56" ;; - alphaev6) ax_gcc_arch=ev6 ;; - alphaev67) ax_gcc_arch=ev67 ;; - alphaev68) ax_gcc_arch="ev68 ev67" ;; - alphaev69) ax_gcc_arch="ev69 ev68 ev67" ;; - alphaev7) ax_gcc_arch="ev7 ev69 ev68 ev67" ;; - alphaev79) ax_gcc_arch="ev79 ev7 ev69 ev68 ev67" ;; - - powerpc*) - cputype=`((grep cpu /proc/cpuinfo | head -n 1 | cut -d: -f2 | cut -d, -f1 | sed 's/ //g') ; /usr/bin/machine ; /bin/machine; grep CPU /var/run/dmesg.boot | head -n 1 | cut -d" " -f2) 2> /dev/null` - cputype=`echo $cputype | sed -e 's/ppc//g;s/ *//g'` - case $cputype in - *750*) ax_gcc_arch="750 G3" ;; - *740[[0-9]]*) ax_gcc_arch="$cputype 7400 G4" ;; - *74[[4-5]][[0-9]]*) ax_gcc_arch="$cputype 7450 G4" ;; - *74[[0-9]][[0-9]]*) ax_gcc_arch="$cputype G4" ;; - *970*) ax_gcc_arch="970 G5 power4";; - *POWER4*|*power4*|*gq*) ax_gcc_arch="power4 970";; - *POWER5*|*power5*|*gr*|*gs*) ax_gcc_arch="power5 power4 970";; - 603ev|8240) ax_gcc_arch="$cputype 603e 603";; - *) ax_gcc_arch=$cputype ;; - esac - ax_gcc_arch="$ax_gcc_arch powerpc" - ;; -esac -fi # not cross-compiling -fi # guess arch - -if test "x$ax_gcc_arch" != x -a "x$ax_gcc_arch" != xno; then -for arch in $ax_gcc_arch; do - if test "x[]m4_default([$1],yes)" = xyes; then # if we require portable code - flags="-mtune=$arch" - # -mcpu=$arch and m$arch generate nonportable code on every arch except - # x86. And some other arches (e.g. Alpha) don't accept -mtune. Grrr. - case $host_cpu in i*86|x86_64*) flags="$flags -mcpu=$arch -m$arch";; esac - else - flags="-march=$arch -mcpu=$arch -m$arch" - fi - for flag in $flags; do - AX_CHECK_COMPILE_FLAG($flag, [ax_cv_gcc_archflag=$flag; break]) - done - test "x$ax_cv_gcc_archflag" = xunknown || break -done -fi - -fi # $GCC=yes -]) -AC_MSG_CHECKING([for gcc architecture flag]) -AC_MSG_RESULT($ax_cv_gcc_archflag) -if test "x$ax_cv_gcc_archflag" = xunknown; then - m4_default([$3],:) -else - m4_default([$2], [CFLAGS="$CFLAGS $ax_cv_gcc_archflag"]) -fi -]) diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi/m4/ax_gcc_x86_cpuid.m4 --- a/Modules/_ctypes/libffi/m4/ax_gcc_x86_cpuid.m4 Sat Jul 19 16:34:33 2014 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,79 +0,0 @@ -# =========================================================================== -# http://www.gnu.org/software/autoconf-archive/ax_gcc_x86_cpuid.html -# =========================================================================== -# -# SYNOPSIS -# -# AX_GCC_X86_CPUID(OP) -# -# DESCRIPTION -# -# On Pentium and later x86 processors, with gcc or a compiler that has a -# compatible syntax for inline assembly instructions, run a small program -# that executes the cpuid instruction with input OP. This can be used to -# detect the CPU type. -# -# On output, the values of the eax, ebx, ecx, and edx registers are stored -# as hexadecimal strings as "eax:ebx:ecx:edx" in the cache variable -# ax_cv_gcc_x86_cpuid_OP. -# -# If the cpuid instruction fails (because you are running a -# cross-compiler, or because you are not using gcc, or because you are on -# a processor that doesn't have this instruction), ax_cv_gcc_x86_cpuid_OP -# is set to the string "unknown". -# -# This macro mainly exists to be used in AX_GCC_ARCHFLAG. -# -# LICENSE -# -# Copyright (c) 2008 Steven G. Johnson -# Copyright (c) 2008 Matteo Frigo -# -# This program is free software: you can redistribute it and/or modify it -# under the terms of the GNU General Public License as published by the -# Free Software Foundation, either version 3 of the License, or (at your -# option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General -# Public License for more details. -# -# You should have received a copy of the GNU General Public License along -# with this program. If not, see . -# -# As a special exception, the respective Autoconf Macro's copyright owner -# gives unlimited permission to copy, distribute and modify the configure -# scripts that are the output of Autoconf when processing the Macro. You -# need not follow the terms of the GNU General Public License when using -# or distributing such scripts, even though portions of the text of the -# Macro appear in them. The GNU General Public License (GPL) does govern -# all other use of the material that constitutes the Autoconf Macro. -# -# This special exception to the GPL applies to versions of the Autoconf -# Macro released by the Autoconf Archive. When you make and distribute a -# modified version of the Autoconf Macro, you may extend this special -# exception to the GPL to apply to your modified version as well. - -#serial 7 - -AC_DEFUN([AX_GCC_X86_CPUID], -[AC_REQUIRE([AC_PROG_CC]) -AC_LANG_PUSH([C]) -AC_CACHE_CHECK(for x86 cpuid $1 output, ax_cv_gcc_x86_cpuid_$1, - [AC_RUN_IFELSE([AC_LANG_PROGRAM([#include ], [ - int op = $1, eax, ebx, ecx, edx; - FILE *f; - __asm__("cpuid" - : "=a" (eax), "=b" (ebx), "=c" (ecx), "=d" (edx) - : "a" (op)); - f = fopen("conftest_cpuid", "w"); if (!f) return 1; - fprintf(f, "%x:%x:%x:%x\n", eax, ebx, ecx, edx); - fclose(f); - return 0; -])], - [ax_cv_gcc_x86_cpuid_$1=`cat conftest_cpuid`; rm -f conftest_cpuid], - [ax_cv_gcc_x86_cpuid_$1=unknown; rm -f conftest_cpuid], - [ax_cv_gcc_x86_cpuid_$1=unknown])]) -AC_LANG_POP([C]) -]) diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi/m4/libtool.m4 --- a/Modules/_ctypes/libffi/m4/libtool.m4 Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/_ctypes/libffi/m4/libtool.m4 Sun Jul 20 10:52:46 2014 -0400 @@ -1,8 +1,7 @@ # libtool.m4 - Configure libtool for the host system. -*-Autoconf-*- # # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, -# 2006, 2007, 2008, 2009, 2010, 2011 Free Software -# Foundation, Inc. +# 2006, 2007, 2008 Free Software Foundation, Inc. # Written by Gordon Matzigkeit, 1996 # # This file is free software; the Free Software Foundation gives @@ -11,8 +10,7 @@ m4_define([_LT_COPYING], [dnl # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, -# 2006, 2007, 2008, 2009, 2010, 2011 Free Software -# Foundation, Inc. +# 2006, 2007, 2008 Free Software Foundation, Inc. # Written by Gordon Matzigkeit, 1996 # # This file is part of GNU Libtool. @@ -39,7 +37,7 @@ # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. ]) -# serial 57 LT_INIT +# serial 56 LT_INIT # LT_PREREQ(VERSION) @@ -68,7 +66,6 @@ # ------------------ AC_DEFUN([LT_INIT], [AC_PREREQ([2.58])dnl We use AC_INCLUDES_DEFAULT -AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT])dnl AC_BEFORE([$0], [LT_LANG])dnl AC_BEFORE([$0], [LT_OUTPUT])dnl AC_BEFORE([$0], [LTDL_INIT])dnl @@ -85,8 +82,6 @@ AC_REQUIRE([LTOBSOLETE_VERSION])dnl m4_require([_LT_PROG_LTMAIN])dnl -_LT_SHELL_INIT([SHELL=${CONFIG_SHELL-/bin/sh}]) - dnl Parse OPTIONS _LT_SET_OPTIONS([$0], [$1]) @@ -123,7 +118,7 @@ *) break;; esac done -cc_basename=`$ECHO "$cc_temp" | $SED "s%.*/%%; s%^$host_alias-%%"` +cc_basename=`$ECHO "X$cc_temp" | $Xsed -e 's%.*/%%' -e "s%^$host_alias-%%"` ]) @@ -143,11 +138,6 @@ m4_defun([_LT_SETUP], [AC_REQUIRE([AC_CANONICAL_HOST])dnl AC_REQUIRE([AC_CANONICAL_BUILD])dnl -AC_REQUIRE([_LT_PREPARE_SED_QUOTE_VARS])dnl -AC_REQUIRE([_LT_PROG_ECHO_BACKSLASH])dnl - -_LT_DECL([], [PATH_SEPARATOR], [1], [The PATH separator for the build system])dnl -dnl _LT_DECL([], [host_alias], [0], [The host system])dnl _LT_DECL([], [host], [0])dnl _LT_DECL([], [host_os], [0])dnl @@ -170,13 +160,10 @@ dnl m4_require([_LT_FILEUTILS_DEFAULTS])dnl m4_require([_LT_CHECK_SHELL_FEATURES])dnl -m4_require([_LT_PATH_CONVERSION_FUNCTIONS])dnl m4_require([_LT_CMD_RELOAD])dnl m4_require([_LT_CHECK_MAGIC_METHOD])dnl -m4_require([_LT_CHECK_SHAREDLIB_FROM_LINKLIB])dnl m4_require([_LT_CMD_OLD_ARCHIVE])dnl m4_require([_LT_CMD_GLOBAL_SYMBOLS])dnl -m4_require([_LT_WITH_SYSROOT])dnl _LT_CONFIG_LIBTOOL_INIT([ # See if we are running on zsh, and set the options which allow our @@ -192,6 +179,7 @@ _LT_CHECK_OBJDIR m4_require([_LT_TAG_COMPILER])dnl +_LT_PROG_ECHO_BACKSLASH case $host_os in aix3*) @@ -205,6 +193,23 @@ ;; esac +# Sed substitution that helps us do robust quoting. It backslashifies +# metacharacters that are still active within double-quoted strings. +sed_quote_subst='s/\([["`$\\]]\)/\\\1/g' + +# Same as above, but do not quote variable references. +double_quote_subst='s/\([["`\\]]\)/\\\1/g' + +# Sed substitution to delay expansion of an escaped shell variable in a +# double_quote_subst'ed string. +delay_variable_subst='s/\\\\\\\\\\\$/\\\\\\$/g' + +# Sed substitution to delay expansion of an escaped single quote. +delay_single_quote_subst='s/'\''/'\'\\\\\\\'\''/g' + +# Sed substitution to avoid accidental globbing in evaled expressions +no_glob_subst='s/\*/\\\*/g' + # Global variables: ofile=libtool can_build_shared=yes @@ -245,28 +250,6 @@ ])# _LT_SETUP -# _LT_PREPARE_SED_QUOTE_VARS -# -------------------------- -# Define a few sed substitution that help us do robust quoting. -m4_defun([_LT_PREPARE_SED_QUOTE_VARS], -[# Backslashify metacharacters that are still active within -# double-quoted strings. -sed_quote_subst='s/\([["`$\\]]\)/\\\1/g' - -# Same as above, but do not quote variable references. -double_quote_subst='s/\([["`\\]]\)/\\\1/g' - -# Sed substitution to delay expansion of an escaped shell variable in a -# double_quote_subst'ed string. -delay_variable_subst='s/\\\\\\\\\\\$/\\\\\\$/g' - -# Sed substitution to delay expansion of an escaped single quote. -delay_single_quote_subst='s/'\''/'\'\\\\\\\'\''/g' - -# Sed substitution to avoid accidental globbing in evaled expressions -no_glob_subst='s/\*/\\\*/g' -]) - # _LT_PROG_LTMAIN # --------------- # Note that this code is called both from `configure', and `config.status' @@ -425,7 +408,7 @@ # declaration there will have the same value as in `configure'. VARNAME # must have a single quote delimited value for this to work. m4_define([_LT_CONFIG_STATUS_DECLARE], -[$1='`$ECHO "$][$1" | $SED "$delay_single_quote_subst"`']) +[$1='`$ECHO "X$][$1" | $Xsed -e "$delay_single_quote_subst"`']) # _LT_CONFIG_STATUS_DECLARATIONS @@ -435,7 +418,7 @@ # embedded single quotes properly. In configure, this macro expands # each variable declared with _LT_DECL (and _LT_TAGDECL) into: # -# ='`$ECHO "$" | $SED "$delay_single_quote_subst"`' +# ='`$ECHO "X$" | $Xsed -e "$delay_single_quote_subst"`' m4_defun([_LT_CONFIG_STATUS_DECLARATIONS], [m4_foreach([_lt_var], m4_quote(lt_decl_all_varnames), [m4_n([_LT_CONFIG_STATUS_DECLARE(_lt_var)])])]) @@ -534,20 +517,12 @@ LTCFLAGS='$LTCFLAGS' compiler='$compiler_DEFAULT' -# A function that is used when there is no print builtin or printf. -func_fallback_echo () -{ - eval 'cat <<_LTECHO_EOF -\$[]1 -_LTECHO_EOF' -} - # Quote evaled strings. for var in lt_decl_all_varnames([[ \ ]], lt_decl_quote_varnames); do - case \`eval \\\\\$ECHO \\\\""\\\\\$\$var"\\\\"\` in + case \`eval \\\\\$ECHO "X\\\\\$\$var"\` in *[[\\\\\\\`\\"\\\$]]*) - eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"\\\$\$var\\" | \\\$SED \\"\\\$sed_quote_subst\\"\\\`\\\\\\"" + eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"X\\\$\$var\\" | \\\$Xsed -e \\"\\\$sed_quote_subst\\"\\\`\\\\\\"" ;; *) eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\"" @@ -558,9 +533,9 @@ # Double-quote double-evaled strings. for var in lt_decl_all_varnames([[ \ ]], lt_decl_dquote_varnames); do - case \`eval \\\\\$ECHO \\\\""\\\\\$\$var"\\\\"\` in + case \`eval \\\\\$ECHO "X\\\\\$\$var"\` in *[[\\\\\\\`\\"\\\$]]*) - eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"\\\$\$var\\" | \\\$SED -e \\"\\\$double_quote_subst\\" -e \\"\\\$sed_quote_subst\\" -e \\"\\\$delay_variable_subst\\"\\\`\\\\\\"" + eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"X\\\$\$var\\" | \\\$Xsed -e \\"\\\$double_quote_subst\\" -e \\"\\\$sed_quote_subst\\" -e \\"\\\$delay_variable_subst\\"\\\`\\\\\\"" ;; *) eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\"" @@ -568,38 +543,16 @@ esac done +# Fix-up fallback echo if it was mangled by the above quoting rules. +case \$lt_ECHO in +*'\\\[$]0 --fallback-echo"')dnl " + lt_ECHO=\`\$ECHO "X\$lt_ECHO" | \$Xsed -e 's/\\\\\\\\\\\\\\\[$]0 --fallback-echo"\[$]/\[$]0 --fallback-echo"/'\` + ;; +esac + _LT_OUTPUT_LIBTOOL_INIT ]) -# _LT_GENERATED_FILE_INIT(FILE, [COMMENT]) -# ------------------------------------ -# Generate a child script FILE with all initialization necessary to -# reuse the environment learned by the parent script, and make the -# file executable. If COMMENT is supplied, it is inserted after the -# `#!' sequence but before initialization text begins. After this -# macro, additional text can be appended to FILE to form the body of -# the child script. The macro ends with non-zero status if the -# file could not be fully written (such as if the disk is full). -m4_ifdef([AS_INIT_GENERATED], -[m4_defun([_LT_GENERATED_FILE_INIT],[AS_INIT_GENERATED($@)])], -[m4_defun([_LT_GENERATED_FILE_INIT], -[m4_require([AS_PREPARE])]dnl -[m4_pushdef([AS_MESSAGE_LOG_FD])]dnl -[lt_write_fail=0 -cat >$1 <<_ASEOF || lt_write_fail=1 -#! $SHELL -# Generated by $as_me. -$2 -SHELL=\${CONFIG_SHELL-$SHELL} -export SHELL -_ASEOF -cat >>$1 <<\_ASEOF || lt_write_fail=1 -AS_SHELL_SANITIZE -_AS_PREPARE -exec AS_MESSAGE_FD>&1 -_ASEOF -test $lt_write_fail = 0 && chmod +x $1[]dnl -m4_popdef([AS_MESSAGE_LOG_FD])])])# _LT_GENERATED_FILE_INIT # LT_OUTPUT # --------- @@ -609,11 +562,20 @@ AC_DEFUN([LT_OUTPUT], [: ${CONFIG_LT=./config.lt} AC_MSG_NOTICE([creating $CONFIG_LT]) -_LT_GENERATED_FILE_INIT(["$CONFIG_LT"], -[# Run this file to recreate a libtool stub with the current configuration.]) +cat >"$CONFIG_LT" <<_LTEOF +#! $SHELL +# Generated by $as_me. +# Run this file to recreate a libtool stub with the current configuration. + +lt_cl_silent=false +SHELL=\${CONFIG_SHELL-$SHELL} +_LTEOF cat >>"$CONFIG_LT" <<\_LTEOF -lt_cl_silent=false +AS_SHELL_SANITIZE +_AS_PREPARE + +exec AS_MESSAGE_FD>&1 exec AS_MESSAGE_LOG_FD>>config.log { echo @@ -639,7 +601,7 @@ m4_ifset([AC_PACKAGE_VERSION], [ AC_PACKAGE_VERSION]) configured by $[0], generated by m4_PACKAGE_STRING. -Copyright (C) 2011 Free Software Foundation, Inc. +Copyright (C) 2008 Free Software Foundation, Inc. This config.lt script is free software; the Free Software Foundation gives unlimited permision to copy, distribute and modify it." @@ -684,13 +646,15 @@ # appending to config.log, which fails on DOS, as config.log is still kept # open by configure. Here we exec the FD to /dev/null, effectively closing # config.log, so it can be properly (re)opened and appended to by config.lt. -lt_cl_success=: -test "$silent" = yes && - lt_config_lt_args="$lt_config_lt_args --quiet" -exec AS_MESSAGE_LOG_FD>/dev/null -$SHELL "$CONFIG_LT" $lt_config_lt_args || lt_cl_success=false -exec AS_MESSAGE_LOG_FD>>config.log -$lt_cl_success || AS_EXIT(1) +if test "$no_create" != yes; then + lt_cl_success=: + test "$silent" = yes && + lt_config_lt_args="$lt_config_lt_args --quiet" + exec AS_MESSAGE_LOG_FD>/dev/null + $SHELL "$CONFIG_LT" $lt_config_lt_args || lt_cl_success=false + exec AS_MESSAGE_LOG_FD>>config.log + $lt_cl_success || AS_EXIT(1) +fi ])# LT_OUTPUT @@ -753,12 +717,15 @@ # if finds mixed CR/LF and LF-only lines. Since sed operates in # text mode, it properly converts lines to CR/LF. This bash problem # is reportedly fixed, but why not run on old versions too? - sed '$q' "$ltmain" >> "$cfgfile" \ - || (rm -f "$cfgfile"; exit 1) - - _LT_PROG_REPLACE_SHELLFNS - - mv -f "$cfgfile" "$ofile" || + sed '/^# Generated shell functions inserted here/q' "$ltmain" >> "$cfgfile" \ + || (rm -f "$cfgfile"; exit 1) + + _LT_PROG_XSI_SHELLFNS + + sed -n '/^# Generated shell functions inserted here/,$p' "$ltmain" >> "$cfgfile" \ + || (rm -f "$cfgfile"; exit 1) + + mv -f "$cfgfile" "$ofile" || (rm -f "$ofile" && cp "$cfgfile" "$ofile" && rm -f "$cfgfile") chmod +x "$ofile" ], @@ -803,7 +770,6 @@ m4_case([$1], [C], [_LT_LANG(C)], [C++], [_LT_LANG(CXX)], - [Go], [_LT_LANG(GO)], [Java], [_LT_LANG(GCJ)], [Fortran 77], [_LT_LANG(F77)], [Fortran], [_LT_LANG(FC)], @@ -825,31 +791,6 @@ ])# _LT_LANG -m4_ifndef([AC_PROG_GO], [ -############################################################ -# NOTE: This macro has been submitted for inclusion into # -# GNU Autoconf as AC_PROG_GO. When it is available in # -# a released version of Autoconf we should remove this # -# macro and use it instead. # -############################################################ -m4_defun([AC_PROG_GO], -[AC_LANG_PUSH(Go)dnl -AC_ARG_VAR([GOC], [Go compiler command])dnl -AC_ARG_VAR([GOFLAGS], [Go compiler flags])dnl -_AC_ARG_VAR_LDFLAGS()dnl -AC_CHECK_TOOL(GOC, gccgo) -if test -z "$GOC"; then - if test -n "$ac_tool_prefix"; then - AC_CHECK_PROG(GOC, [${ac_tool_prefix}gccgo], [${ac_tool_prefix}gccgo]) - fi -fi -if test -z "$GOC"; then - AC_CHECK_PROG(GOC, gccgo, gccgo, false) -fi -])#m4_defun -])#m4_ifndef - - # _LT_LANG_DEFAULT_CONFIG # ----------------------- m4_defun([_LT_LANG_DEFAULT_CONFIG], @@ -880,10 +821,6 @@ m4_ifdef([LT_PROG_GCJ], [m4_define([LT_PROG_GCJ], defn([LT_PROG_GCJ])[LT_LANG(GCJ)])])])])]) -AC_PROVIDE_IFELSE([AC_PROG_GO], - [LT_LANG(GO)], - [m4_define([AC_PROG_GO], defn([AC_PROG_GO])[LT_LANG(GO)])]) - AC_PROVIDE_IFELSE([LT_PROG_RC], [LT_LANG(RC)], [m4_define([LT_PROG_RC], defn([LT_PROG_RC])[LT_LANG(RC)])]) @@ -894,13 +831,11 @@ AU_DEFUN([AC_LIBTOOL_F77], [LT_LANG(Fortran 77)]) AU_DEFUN([AC_LIBTOOL_FC], [LT_LANG(Fortran)]) AU_DEFUN([AC_LIBTOOL_GCJ], [LT_LANG(Java)]) -AU_DEFUN([AC_LIBTOOL_RC], [LT_LANG(Windows Resource)]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AC_LIBTOOL_CXX], []) dnl AC_DEFUN([AC_LIBTOOL_F77], []) dnl AC_DEFUN([AC_LIBTOOL_FC], []) dnl AC_DEFUN([AC_LIBTOOL_GCJ], []) -dnl AC_DEFUN([AC_LIBTOOL_RC], []) # _LT_TAG_COMPILER @@ -986,13 +921,7 @@ $LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \ -dynamiclib -Wl,-single_module conftest.c 2>conftest.err _lt_result=$? - # If there is a non-empty error log, and "single_module" - # appears in it, assume the flag caused a linker warning - if test -s conftest.err && $GREP single_module conftest.err; then - cat conftest.err >&AS_MESSAGE_LOG_FD - # Otherwise, if the output was created with a 0 exit code from - # the compiler, it worked. - elif test -f libconftest.dylib && test $_lt_result -eq 0; then + if test -f libconftest.dylib && test ! -s conftest.err && test $_lt_result = 0; then lt_cv_apple_cc_single_mod=yes else cat conftest.err >&AS_MESSAGE_LOG_FD @@ -1000,7 +929,6 @@ rm -rf libconftest.dylib* rm -f conftest.* fi]) - AC_CACHE_CHECK([for -exported_symbols_list linker flag], [lt_cv_ld_exported_symbols_list], [lt_cv_ld_exported_symbols_list=no @@ -1012,34 +940,6 @@ [lt_cv_ld_exported_symbols_list=no]) LDFLAGS="$save_LDFLAGS" ]) - - AC_CACHE_CHECK([for -force_load linker flag],[lt_cv_ld_force_load], - [lt_cv_ld_force_load=no - cat > conftest.c << _LT_EOF -int forced_loaded() { return 2;} -_LT_EOF - echo "$LTCC $LTCFLAGS -c -o conftest.o conftest.c" >&AS_MESSAGE_LOG_FD - $LTCC $LTCFLAGS -c -o conftest.o conftest.c 2>&AS_MESSAGE_LOG_FD - echo "$AR cru libconftest.a conftest.o" >&AS_MESSAGE_LOG_FD - $AR cru libconftest.a conftest.o 2>&AS_MESSAGE_LOG_FD - echo "$RANLIB libconftest.a" >&AS_MESSAGE_LOG_FD - $RANLIB libconftest.a 2>&AS_MESSAGE_LOG_FD - cat > conftest.c << _LT_EOF -int main() { return 0;} -_LT_EOF - echo "$LTCC $LTCFLAGS $LDFLAGS -o conftest conftest.c -Wl,-force_load,./libconftest.a" >&AS_MESSAGE_LOG_FD - $LTCC $LTCFLAGS $LDFLAGS -o conftest conftest.c -Wl,-force_load,./libconftest.a 2>conftest.err - _lt_result=$? - if test -s conftest.err && $GREP force_load conftest.err; then - cat conftest.err >&AS_MESSAGE_LOG_FD - elif test -f conftest && test $_lt_result -eq 0 && $GREP forced_load conftest >/dev/null 2>&1 ; then - lt_cv_ld_force_load=yes - else - cat conftest.err >&AS_MESSAGE_LOG_FD - fi - rm -f conftest.err libconftest.a conftest conftest.c - rm -rf conftest.dSYM - ]) case $host_os in rhapsody* | darwin1.[[012]]) _lt_dar_allow_undefined='${wl}-undefined ${wl}suppress' ;; @@ -1067,7 +967,7 @@ else _lt_dar_export_syms='~$NMEDIT -s $output_objdir/${libname}-symbols.expsym ${lib}' fi - if test "$DSYMUTIL" != ":" && test "$lt_cv_ld_force_load" = "no"; then + if test "$DSYMUTIL" != ":"; then _lt_dsymutil='~$DSYMUTIL $lib || :' else _lt_dsymutil= @@ -1077,8 +977,8 @@ ]) -# _LT_DARWIN_LINKER_FEATURES([TAG]) -# --------------------------------- +# _LT_DARWIN_LINKER_FEATURES +# -------------------------- # Checks for linker and compiler features on darwin m4_defun([_LT_DARWIN_LINKER_FEATURES], [ @@ -1087,13 +987,7 @@ _LT_TAGVAR(hardcode_direct, $1)=no _LT_TAGVAR(hardcode_automatic, $1)=yes _LT_TAGVAR(hardcode_shlibpath_var, $1)=unsupported - if test "$lt_cv_ld_force_load" = "yes"; then - _LT_TAGVAR(whole_archive_flag_spec, $1)='`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience ${wl}-force_load,$conv\"; done; func_echo_all \"$new_convenience\"`' - m4_case([$1], [F77], [_LT_TAGVAR(compiler_needs_object, $1)=yes], - [FC], [_LT_TAGVAR(compiler_needs_object, $1)=yes]) - else - _LT_TAGVAR(whole_archive_flag_spec, $1)='' - fi + _LT_TAGVAR(whole_archive_flag_spec, $1)='' _LT_TAGVAR(link_all_deplibs, $1)=yes _LT_TAGVAR(allow_undefined_flag, $1)="$_lt_dar_allow_undefined" case $cc_basename in @@ -1101,7 +995,7 @@ *) _lt_dar_can_shared=$GCC ;; esac if test "$_lt_dar_can_shared" = "yes"; then - output_verbose_link_cmd=func_echo_all + output_verbose_link_cmd=echo _LT_TAGVAR(archive_cmds, $1)="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod${_lt_dsymutil}" _LT_TAGVAR(module_cmds, $1)="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}" _LT_TAGVAR(archive_expsym_cmds, $1)="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}" @@ -1117,142 +1011,203 @@ fi ]) -# _LT_SYS_MODULE_PATH_AIX([TAGNAME]) -# ---------------------------------- +# _LT_SYS_MODULE_PATH_AIX +# ----------------------- # Links a minimal program and checks the executable # for the system default hardcoded library path. In most cases, # this is /usr/lib:/lib, but when the MPI compilers are used # the location of the communication and MPI libs are included too. # If we don't find anything, use the default library path according # to the aix ld manual. -# Store the results from the different compilers for each TAGNAME. -# Allow to override them for all tags through lt_cv_aix_libpath. m4_defun([_LT_SYS_MODULE_PATH_AIX], [m4_require([_LT_DECL_SED])dnl -if test "${lt_cv_aix_libpath+set}" = set; then - aix_libpath=$lt_cv_aix_libpath -else - AC_CACHE_VAL([_LT_TAGVAR([lt_cv_aix_libpath_], [$1])], - [AC_LINK_IFELSE([AC_LANG_PROGRAM],[ - lt_aix_libpath_sed='[ - /Import File Strings/,/^$/ { - /^0/ { - s/^0 *\([^ ]*\) *$/\1/ - p - } - }]' - _LT_TAGVAR([lt_cv_aix_libpath_], [$1])=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` - # Check for a 64-bit object if we didn't find anything. - if test -z "$_LT_TAGVAR([lt_cv_aix_libpath_], [$1])"; then - _LT_TAGVAR([lt_cv_aix_libpath_], [$1])=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` - fi],[]) - if test -z "$_LT_TAGVAR([lt_cv_aix_libpath_], [$1])"; then - _LT_TAGVAR([lt_cv_aix_libpath_], [$1])="/usr/lib:/lib" - fi - ]) - aix_libpath=$_LT_TAGVAR([lt_cv_aix_libpath_], [$1]) -fi +AC_LINK_IFELSE(AC_LANG_PROGRAM,[ +lt_aix_libpath_sed=' + /Import File Strings/,/^$/ { + /^0/ { + s/^0 *\(.*\)$/\1/ + p + } + }' +aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` +# Check for a 64-bit object if we didn't find anything. +if test -z "$aix_libpath"; then + aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` +fi],[]) +if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi ])# _LT_SYS_MODULE_PATH_AIX # _LT_SHELL_INIT(ARG) # ------------------- m4_define([_LT_SHELL_INIT], -[m4_divert_text([M4SH-INIT], [$1 -])])# _LT_SHELL_INIT - +[ifdef([AC_DIVERSION_NOTICE], + [AC_DIVERT_PUSH(AC_DIVERSION_NOTICE)], + [AC_DIVERT_PUSH(NOTICE)]) +$1 +AC_DIVERT_POP +])# _LT_SHELL_INIT # _LT_PROG_ECHO_BACKSLASH # ----------------------- -# Find how we can fake an echo command that does not interpret backslash. -# In particular, with Autoconf 2.60 or later we add some code to the start -# of the generated configure script which will find a shell with a builtin -# printf (which we can use as an echo command). +# Add some code to the start of the generated configure script which +# will find an echo command which doesn't interpret backslashes. m4_defun([_LT_PROG_ECHO_BACKSLASH], -[ECHO='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' -ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO -ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO$ECHO - -AC_MSG_CHECKING([how to print strings]) -# Test print first, because it will be a builtin if present. -if test "X`( print -r -- -n ) 2>/dev/null`" = X-n && \ - test "X`print -r -- $ECHO 2>/dev/null`" = "X$ECHO"; then - ECHO='print -r --' -elif test "X`printf %s $ECHO 2>/dev/null`" = "X$ECHO"; then - ECHO='printf %s\n' +[_LT_SHELL_INIT([ +# Check that we are running under the correct shell. +SHELL=${CONFIG_SHELL-/bin/sh} + +case X$lt_ECHO in +X*--fallback-echo) + # Remove one level of quotation (which was required for Make). + ECHO=`echo "$lt_ECHO" | sed 's,\\\\\[$]\\[$]0,'[$]0','` + ;; +esac + +ECHO=${lt_ECHO-echo} +if test "X[$]1" = X--no-reexec; then + # Discard the --no-reexec flag, and continue. + shift +elif test "X[$]1" = X--fallback-echo; then + # Avoid inline document here, it may be left over + : +elif test "X`{ $ECHO '\t'; } 2>/dev/null`" = 'X\t' ; then + # Yippee, $ECHO works! + : else - # Use this function as a fallback that always works. - func_fallback_echo () - { - eval 'cat <<_LTECHO_EOF -$[]1 -_LTECHO_EOF' - } - ECHO='func_fallback_echo' + # Restart under the correct shell. + exec $SHELL "[$]0" --no-reexec ${1+"[$]@"} fi -# func_echo_all arg... -# Invoke $ECHO with all args, space-separated. -func_echo_all () -{ - $ECHO "$*" -} - -case "$ECHO" in - printf*) AC_MSG_RESULT([printf]) ;; - print*) AC_MSG_RESULT([print -r]) ;; - *) AC_MSG_RESULT([cat]) ;; -esac - -m4_ifdef([_AS_DETECT_SUGGESTED], -[_AS_DETECT_SUGGESTED([ - test -n "${ZSH_VERSION+set}${BASH_VERSION+set}" || ( - ECHO='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' - ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO - ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO$ECHO - PATH=/empty FPATH=/empty; export PATH FPATH - test "X`printf %s $ECHO`" = "X$ECHO" \ - || test "X`print -r -- $ECHO`" = "X$ECHO" )])]) - +if test "X[$]1" = X--fallback-echo; then + # used as fallback echo + shift + cat <<_LT_EOF +[$]* +_LT_EOF + exit 0 +fi + +# The HP-UX ksh and POSIX shell print the target directory to stdout +# if CDPATH is set. +(unset CDPATH) >/dev/null 2>&1 && unset CDPATH + +if test -z "$lt_ECHO"; then + if test "X${echo_test_string+set}" != Xset; then + # find a string as large as possible, as long as the shell can cope with it + for cmd in 'sed 50q "[$]0"' 'sed 20q "[$]0"' 'sed 10q "[$]0"' 'sed 2q "[$]0"' 'echo test'; do + # expected sizes: less than 2Kb, 1Kb, 512 bytes, 16 bytes, ... + if { echo_test_string=`eval $cmd`; } 2>/dev/null && + { test "X$echo_test_string" = "X$echo_test_string"; } 2>/dev/null + then + break + fi + done + fi + + if test "X`{ $ECHO '\t'; } 2>/dev/null`" = 'X\t' && + echo_testing_string=`{ $ECHO "$echo_test_string"; } 2>/dev/null` && + test "X$echo_testing_string" = "X$echo_test_string"; then + : + else + # The Solaris, AIX, and Digital Unix default echo programs unquote + # backslashes. This makes it impossible to quote backslashes using + # echo "$something" | sed 's/\\/\\\\/g' + # + # So, first we look for a working echo in the user's PATH. + + lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR + for dir in $PATH /usr/ucb; do + IFS="$lt_save_ifs" + if (test -f $dir/echo || test -f $dir/echo$ac_exeext) && + test "X`($dir/echo '\t') 2>/dev/null`" = 'X\t' && + echo_testing_string=`($dir/echo "$echo_test_string") 2>/dev/null` && + test "X$echo_testing_string" = "X$echo_test_string"; then + ECHO="$dir/echo" + break + fi + done + IFS="$lt_save_ifs" + + if test "X$ECHO" = Xecho; then + # We didn't find a better echo, so look for alternatives. + if test "X`{ print -r '\t'; } 2>/dev/null`" = 'X\t' && + echo_testing_string=`{ print -r "$echo_test_string"; } 2>/dev/null` && + test "X$echo_testing_string" = "X$echo_test_string"; then + # This shell has a builtin print -r that does the trick. + ECHO='print -r' + elif { test -f /bin/ksh || test -f /bin/ksh$ac_exeext; } && + test "X$CONFIG_SHELL" != X/bin/ksh; then + # If we have ksh, try running configure again with it. + ORIGINAL_CONFIG_SHELL=${CONFIG_SHELL-/bin/sh} + export ORIGINAL_CONFIG_SHELL + CONFIG_SHELL=/bin/ksh + export CONFIG_SHELL + exec $CONFIG_SHELL "[$]0" --no-reexec ${1+"[$]@"} + else + # Try using printf. + ECHO='printf %s\n' + if test "X`{ $ECHO '\t'; } 2>/dev/null`" = 'X\t' && + echo_testing_string=`{ $ECHO "$echo_test_string"; } 2>/dev/null` && + test "X$echo_testing_string" = "X$echo_test_string"; then + # Cool, printf works + : + elif echo_testing_string=`($ORIGINAL_CONFIG_SHELL "[$]0" --fallback-echo '\t') 2>/dev/null` && + test "X$echo_testing_string" = 'X\t' && + echo_testing_string=`($ORIGINAL_CONFIG_SHELL "[$]0" --fallback-echo "$echo_test_string") 2>/dev/null` && + test "X$echo_testing_string" = "X$echo_test_string"; then + CONFIG_SHELL=$ORIGINAL_CONFIG_SHELL + export CONFIG_SHELL + SHELL="$CONFIG_SHELL" + export SHELL + ECHO="$CONFIG_SHELL [$]0 --fallback-echo" + elif echo_testing_string=`($CONFIG_SHELL "[$]0" --fallback-echo '\t') 2>/dev/null` && + test "X$echo_testing_string" = 'X\t' && + echo_testing_string=`($CONFIG_SHELL "[$]0" --fallback-echo "$echo_test_string") 2>/dev/null` && + test "X$echo_testing_string" = "X$echo_test_string"; then + ECHO="$CONFIG_SHELL [$]0 --fallback-echo" + else + # maybe with a smaller string... + prev=: + + for cmd in 'echo test' 'sed 2q "[$]0"' 'sed 10q "[$]0"' 'sed 20q "[$]0"' 'sed 50q "[$]0"'; do + if { test "X$echo_test_string" = "X`eval $cmd`"; } 2>/dev/null + then + break + fi + prev="$cmd" + done + + if test "$prev" != 'sed 50q "[$]0"'; then + echo_test_string=`eval $prev` + export echo_test_string + exec ${ORIGINAL_CONFIG_SHELL-${CONFIG_SHELL-/bin/sh}} "[$]0" ${1+"[$]@"} + else + # Oops. We lost completely, so just stick with echo. + ECHO=echo + fi + fi + fi + fi + fi +fi + +# Copy echo and quote the copy suitably for passing to libtool from +# the Makefile, instead of quoting the original, which is used later. +lt_ECHO=$ECHO +if test "X$lt_ECHO" = "X$CONFIG_SHELL [$]0 --fallback-echo"; then + lt_ECHO="$CONFIG_SHELL \\\$\[$]0 --fallback-echo" +fi + +AC_SUBST(lt_ECHO) +]) _LT_DECL([], [SHELL], [1], [Shell to use when invoking shell scripts]) -_LT_DECL([], [ECHO], [1], [An echo program that protects backslashes]) +_LT_DECL([], [ECHO], [1], + [An echo program that does not interpret backslashes]) ])# _LT_PROG_ECHO_BACKSLASH -# _LT_WITH_SYSROOT -# ---------------- -AC_DEFUN([_LT_WITH_SYSROOT], -[AC_MSG_CHECKING([for sysroot]) -AC_ARG_WITH([sysroot], -[ --with-sysroot[=DIR] Search for dependent libraries within DIR - (or the compiler's sysroot if not specified).], -[], [with_sysroot=no]) - -dnl lt_sysroot will always be passed unquoted. We quote it here -dnl in case the user passed a directory name. -lt_sysroot= -case ${with_sysroot} in #( - yes) - if test "$GCC" = yes; then - lt_sysroot=`$CC --print-sysroot 2>/dev/null` - fi - ;; #( - /*) - lt_sysroot=`echo "$with_sysroot" | sed -e "$sed_quote_subst"` - ;; #( - no|'') - ;; #( - *) - AC_MSG_RESULT([${with_sysroot}]) - AC_MSG_ERROR([The sysroot must be an absolute path.]) - ;; -esac - - AC_MSG_RESULT([${lt_sysroot:-no}]) -_LT_DECL([], [lt_sysroot], [0], [The root where to search for ]dnl -[dependent libraries, and in which our libraries should be installed.])]) - # _LT_ENABLE_LOCK # --------------- m4_defun([_LT_ENABLE_LOCK], @@ -1281,7 +1236,7 @@ ;; *-*-irix6*) # Find out which ABI we are using. - echo '[#]line '$LINENO' "configure"' > conftest.$ac_ext + echo '[#]line __oline__ "configure"' > conftest.$ac_ext if AC_TRY_EVAL(ac_compile); then if test "$lt_cv_prog_gnu_ld" = yes; then case `/usr/bin/file conftest.$ac_objext` in @@ -1324,14 +1279,7 @@ LD="${LD-ld} -m elf_i386_fbsd" ;; x86_64-*linux*) - case `/usr/bin/file conftest.o` in - *x86-64*) - LD="${LD-ld} -m elf32_x86_64" - ;; - *) - LD="${LD-ld} -m elf_i386" - ;; - esac + LD="${LD-ld} -m elf_i386" ;; ppc64-*linux*|powerpc64-*linux*) LD="${LD-ld} -m elf32ppclinux" @@ -1381,27 +1329,14 @@ CFLAGS="$SAVE_CFLAGS" fi ;; -*-*solaris*) +sparc*-*solaris*) # Find out which ABI we are using. echo 'int i;' > conftest.$ac_ext if AC_TRY_EVAL(ac_compile); then case `/usr/bin/file conftest.o` in *64-bit*) case $lt_cv_prog_gnu_ld in - yes*) - case $host in - i?86-*-solaris*) - LD="${LD-ld} -m elf_x86_64" - ;; - sparc*-*-solaris*) - LD="${LD-ld} -m elf64_sparc" - ;; - esac - # GNU ld 2.21 introduced _sol2 emulations. Use them if available. - if ${LD-ld} -V | grep _sol2 >/dev/null 2>&1; then - LD="${LD-ld}_sol2" - fi - ;; + yes*) LD="${LD-ld} -m elf64_sparc" ;; *) if ${LD-ld} -64 -r -o conftest2.o conftest.o >/dev/null 2>&1; then LD="${LD-ld} -64" @@ -1419,47 +1354,14 @@ ])# _LT_ENABLE_LOCK -# _LT_PROG_AR -# ----------- -m4_defun([_LT_PROG_AR], -[AC_CHECK_TOOLS(AR, [ar], false) -: ${AR=ar} -: ${AR_FLAGS=cru} -_LT_DECL([], [AR], [1], [The archiver]) -_LT_DECL([], [AR_FLAGS], [1], [Flags to create an archive]) - -AC_CACHE_CHECK([for archiver @FILE support], [lt_cv_ar_at_file], - [lt_cv_ar_at_file=no - AC_COMPILE_IFELSE([AC_LANG_PROGRAM], - [echo conftest.$ac_objext > conftest.lst - lt_ar_try='$AR $AR_FLAGS libconftest.a @conftest.lst >&AS_MESSAGE_LOG_FD' - AC_TRY_EVAL([lt_ar_try]) - if test "$ac_status" -eq 0; then - # Ensure the archiver fails upon bogus file names. - rm -f conftest.$ac_objext libconftest.a - AC_TRY_EVAL([lt_ar_try]) - if test "$ac_status" -ne 0; then - lt_cv_ar_at_file=@ - fi - fi - rm -f conftest.* libconftest.a - ]) - ]) - -if test "x$lt_cv_ar_at_file" = xno; then - archiver_list_spec= -else - archiver_list_spec=$lt_cv_ar_at_file -fi -_LT_DECL([], [archiver_list_spec], [1], - [How to feed a file listing to the archiver]) -])# _LT_PROG_AR - - # _LT_CMD_OLD_ARCHIVE # ------------------- m4_defun([_LT_CMD_OLD_ARCHIVE], -[_LT_PROG_AR +[AC_CHECK_TOOL(AR, ar, false) +test -z "$AR" && AR=ar +test -z "$AR_FLAGS" && AR_FLAGS=cru +_LT_DECL([], [AR], [1], [The archiver]) +_LT_DECL([], [AR_FLAGS], [1]) AC_CHECK_TOOL(STRIP, strip, :) test -z "$STRIP" && STRIP=: @@ -1478,27 +1380,18 @@ if test -n "$RANLIB"; then case $host_os in openbsd*) - old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB -t \$tool_oldlib" + old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB -t \$oldlib" ;; *) - old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB \$tool_oldlib" + old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB \$oldlib" ;; esac - old_archive_cmds="$old_archive_cmds~\$RANLIB \$tool_oldlib" + old_archive_cmds="$old_archive_cmds~\$RANLIB \$oldlib" fi - -case $host_os in - darwin*) - lock_old_archive_extraction=yes ;; - *) - lock_old_archive_extraction=no ;; -esac _LT_DECL([], [old_postinstall_cmds], [2]) _LT_DECL([], [old_postuninstall_cmds], [2]) _LT_TAGDECL([], [old_archive_cmds], [2], [Commands used to build an old-style archive]) -_LT_DECL([], [lock_old_archive_extraction], [0], - [Whether to use a lock for old archive extraction]) ])# _LT_CMD_OLD_ARCHIVE @@ -1523,15 +1416,15 @@ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [[^ ]]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&AS_MESSAGE_LOG_FD) + (eval echo "\"\$as_me:__oline__: $lt_compile\"" >&AS_MESSAGE_LOG_FD) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&AS_MESSAGE_LOG_FD - echo "$as_me:$LINENO: \$? = $ac_status" >&AS_MESSAGE_LOG_FD + echo "$as_me:__oline__: \$? = $ac_status" >&AS_MESSAGE_LOG_FD if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. - $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' >conftest.exp + $ECHO "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' >conftest.exp $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then $2=yes @@ -1571,7 +1464,7 @@ if test -s conftest.err; then # Append any errors to the config.log. cat conftest.err 1>&AS_MESSAGE_LOG_FD - $ECHO "$_lt_linker_boilerplate" | $SED '/^$/d' > conftest.exp + $ECHO "X$_lt_linker_boilerplate" | $Xsed -e '/^$/d' > conftest.exp $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 if diff conftest.exp conftest.er2 >/dev/null; then $2=yes @@ -1634,11 +1527,6 @@ lt_cv_sys_max_cmd_len=8192; ;; - mint*) - # On MiNT this can take a long time and run out of memory. - lt_cv_sys_max_cmd_len=8192; - ;; - amigaos*) # On AmigaOS with pdksh, this test takes hours, literally. # So we just punt and use a minimum line length of 8192. @@ -1664,11 +1552,6 @@ lt_cv_sys_max_cmd_len=196608 ;; - os2*) - # The test takes a long time on OS/2. - lt_cv_sys_max_cmd_len=8192 - ;; - osf*) # Dr. Hans Ekkehard Plesser reports seeing a kernel panic running configure # due to this test when exec_disable_arg_limit is 1 on Tru64. It is not @@ -1695,8 +1578,7 @@ ;; *) lt_cv_sys_max_cmd_len=`(getconf ARG_MAX) 2> /dev/null` - if test -n "$lt_cv_sys_max_cmd_len" && \ - test undefined != "$lt_cv_sys_max_cmd_len"; then + if test -n "$lt_cv_sys_max_cmd_len"; then lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4` lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3` else @@ -1709,8 +1591,8 @@ # If test is not a shell built-in, we'll probably end up computing a # maximum length that is only half of the actual maximum length, but # we can't tell. - while { test "X"`env echo "$teststring$teststring" 2>/dev/null` \ - = "X$teststring$teststring"; } >/dev/null 2>&1 && + while { test "X"`$SHELL [$]0 --fallback-echo "X$teststring$teststring" 2>/dev/null` \ + = "XX$teststring$teststring"; } >/dev/null 2>&1 && test $i != 17 # 1/2 MB should be enough do i=`expr $i + 1` @@ -1761,7 +1643,7 @@ lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -[#line $LINENO "configure" +[#line __oline__ "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -1802,13 +1684,7 @@ # endif #endif -/* When -fvisbility=hidden is used, assume the code has been annotated - correspondingly for the symbols needed. */ -#if defined(__GNUC__) && (((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3)) || (__GNUC__ > 3)) -int fnord () __attribute__((visibility("default"))); -#endif - -int fnord () { return 42; } +void fnord() { int i=42;} int main () { void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW); @@ -1817,11 +1693,7 @@ if (self) { if (dlsym (self,"fnord")) status = $lt_dlno_uscore; - else - { - if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore; - else puts (dlerror ()); - } + else if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore; /* dlclose (self); */ } else @@ -1997,16 +1869,16 @@ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [[^ ]]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&AS_MESSAGE_LOG_FD) + (eval echo "\"\$as_me:__oline__: $lt_compile\"" >&AS_MESSAGE_LOG_FD) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&AS_MESSAGE_LOG_FD - echo "$as_me:$LINENO: \$? = $ac_status" >&AS_MESSAGE_LOG_FD + echo "$as_me:__oline__: \$? = $ac_status" >&AS_MESSAGE_LOG_FD if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings - $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' > out/conftest.exp + $ECHO "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' > out/conftest.exp $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2 if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then _LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)=yes @@ -2165,7 +2037,6 @@ m4_require([_LT_FILEUTILS_DEFAULTS])dnl m4_require([_LT_DECL_OBJDUMP])dnl m4_require([_LT_DECL_SED])dnl -m4_require([_LT_CHECK_SHELL_FEATURES])dnl AC_MSG_CHECKING([dynamic linker characteristics]) m4_if([$1], [], [ @@ -2174,23 +2045,16 @@ darwin*) lt_awk_arg="/^libraries:/,/LR/" ;; *) lt_awk_arg="/^libraries:/" ;; esac - case $host_os in - mingw* | cegcc*) lt_sed_strip_eq="s,=\([[A-Za-z]]:\),\1,g" ;; - *) lt_sed_strip_eq="s,=/,/,g" ;; - esac - lt_search_path_spec=`$CC -print-search-dirs | awk $lt_awk_arg | $SED -e "s/^libraries://" -e $lt_sed_strip_eq` - case $lt_search_path_spec in - *\;*) + lt_search_path_spec=`$CC -print-search-dirs | awk $lt_awk_arg | $SED -e "s/^libraries://" -e "s,=/,/,g"` + if $ECHO "$lt_search_path_spec" | $GREP ';' >/dev/null ; then # if the path contains ";" then we assume it to be the separator # otherwise default to the standard path separator (i.e. ":") - it is # assumed that no part of a normal pathname contains ";" but that should # okay in the real world where ";" in dirpaths is itself problematic. - lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED 's/;/ /g'` - ;; - *) - lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED "s/$PATH_SEPARATOR/ /g"` - ;; - esac + lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED -e 's/;/ /g'` + else + lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` + fi # Ok, now we have the path, separated by spaces, we can step through it # and add multilib dir if necessary. lt_tmp_lt_search_path_spec= @@ -2203,7 +2067,7 @@ lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path" fi done - lt_search_path_spec=`$ECHO "$lt_tmp_lt_search_path_spec" | awk ' + lt_search_path_spec=`$ECHO $lt_tmp_lt_search_path_spec | awk ' BEGIN {RS=" "; FS="/|\n";} { lt_foo=""; lt_count=0; @@ -2223,13 +2087,7 @@ if (lt_foo != "") { lt_freq[[lt_foo]]++; } if (lt_freq[[lt_foo]] == 1) { print lt_foo; } }'` - # AWK program above erroneously prepends '/' to C:/dos/paths - # for these hosts. - case $host_os in - mingw* | cegcc*) lt_search_path_spec=`$ECHO "$lt_search_path_spec" |\ - $SED 's,/\([[A-Za-z]]:\),\1,g'` ;; - esac - sys_lib_search_path_spec=`$ECHO "$lt_search_path_spec" | $lt_NL2SP` + sys_lib_search_path_spec=`$ECHO $lt_search_path_spec` else sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib" fi]) @@ -2255,7 +2113,7 @@ case $host_os in aix3*) - version_type=linux # correct to gnu/linux during the next big refactor + version_type=linux library_names_spec='${libname}${release}${shared_ext}$versuffix $libname.a' shlibpath_var=LIBPATH @@ -2264,7 +2122,7 @@ ;; aix[[4-9]]*) - version_type=linux # correct to gnu/linux during the next big refactor + version_type=linux need_lib_prefix=no need_version=no hardcode_into_libs=yes @@ -2317,7 +2175,7 @@ m68k) library_names_spec='$libname.ixlibrary $libname.a' # Create ${libname}_ixlibrary.a entries in /sys/libs. - finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`func_echo_all "$lib" | $SED '\''s%^.*/\([[^/]]*\)\.ixlibrary$%\1%'\''`; test $RM /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done' + finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`$ECHO "X$lib" | $Xsed -e '\''s%^.*/\([[^/]]*\)\.ixlibrary$%\1%'\''`; test $RM /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done' ;; esac ;; @@ -2329,7 +2187,7 @@ ;; bsdi[[45]]*) - version_type=linux # correct to gnu/linux during the next big refactor + version_type=linux need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' @@ -2348,9 +2206,8 @@ need_version=no need_lib_prefix=no - case $GCC,$cc_basename in - yes,*) - # gcc + case $GCC,$host_os in + yes,cygwin* | yes,mingw* | yes,pw32* | yes,cegcc*) library_names_spec='$libname.dll.a' # DLL is installed to $(libdir)/../bin by postinstall_cmds postinstall_cmds='base_file=`basename \${file}`~ @@ -2371,83 +2228,36 @@ cygwin*) # Cygwin DLLs use 'cyg' prefix rather than 'lib' soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}' -m4_if([$1], [],[ - sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/lib/w32api"]) + sys_lib_search_path_spec="/usr/lib /lib/w32api /lib /usr/local/lib" ;; mingw* | cegcc*) # MinGW DLLs use traditional 'lib' prefix soname_spec='${libname}`echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}' + sys_lib_search_path_spec=`$CC -print-search-dirs | $GREP "^libraries:" | $SED -e "s/^libraries://" -e "s,=/,/,g"` + if $ECHO "$sys_lib_search_path_spec" | [$GREP ';[c-zC-Z]:/' >/dev/null]; then + # It is most probably a Windows format PATH printed by + # mingw gcc, but we are running on Cygwin. Gcc prints its search + # path with ; separators, and with drive letters. We can handle the + # drive letters (cygwin fileutils understands them), so leave them, + # especially as we might pass files found there to a mingw objdump, + # which wouldn't understand a cygwinified path. Ahh. + sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'` + else + sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` + fi ;; pw32*) # pw32 DLLs use 'pw' prefix rather than 'lib' library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}' ;; esac - dynamic_linker='Win32 ld.exe' ;; - *,cl*) - # Native MSVC - libname_spec='$name' - soname_spec='${libname}`echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}' - library_names_spec='${libname}.dll.lib' - - case $build_os in - mingw*) - sys_lib_search_path_spec= - lt_save_ifs=$IFS - IFS=';' - for lt_path in $LIB - do - IFS=$lt_save_ifs - # Let DOS variable expansion print the short 8.3 style file name. - lt_path=`cd "$lt_path" 2>/dev/null && cmd //C "for %i in (".") do @echo %~si"` - sys_lib_search_path_spec="$sys_lib_search_path_spec $lt_path" - done - IFS=$lt_save_ifs - # Convert to MSYS style. - sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | sed -e 's|\\\\|/|g' -e 's| \\([[a-zA-Z]]\\):| /\\1|g' -e 's|^ ||'` - ;; - cygwin*) - # Convert to unix form, then to dos form, then back to unix form - # but this time dos style (no spaces!) so that the unix form looks - # like /cygdrive/c/PROGRA~1:/cygdr... - sys_lib_search_path_spec=`cygpath --path --unix "$LIB"` - sys_lib_search_path_spec=`cygpath --path --dos "$sys_lib_search_path_spec" 2>/dev/null` - sys_lib_search_path_spec=`cygpath --path --unix "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` - ;; - *) - sys_lib_search_path_spec="$LIB" - if $ECHO "$sys_lib_search_path_spec" | [$GREP ';[c-zC-Z]:/' >/dev/null]; then - # It is most probably a Windows format PATH. - sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'` - else - sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` - fi - # FIXME: find the short name or the path components, as spaces are - # common. (e.g. "Program Files" -> "PROGRA~1") - ;; - esac - - # DLL is installed to $(libdir)/../bin by postinstall_cmds - postinstall_cmds='base_file=`basename \${file}`~ - dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~ - dldir=$destdir/`dirname \$dlpath`~ - test -d \$dldir || mkdir -p \$dldir~ - $install_prog $dir/$dlname \$dldir/$dlname' - postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~ - dlpath=$dir/\$dldll~ - $RM \$dlpath' - shlibpath_overrides_runpath=yes - dynamic_linker='Win32 link.exe' - ;; - *) - # Assume MSVC wrapper library_names_spec='${libname}`echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext} $libname.lib' - dynamic_linker='Win32 ld.exe' ;; esac + dynamic_linker='Win32 ld.exe' # FIXME: first we should search . and the directory the executable is in shlibpath_var=PATH ;; @@ -2468,7 +2278,7 @@ ;; dgux*) - version_type=linux # correct to gnu/linux during the next big refactor + version_type=linux need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname$shared_ext' @@ -2476,6 +2286,10 @@ shlibpath_var=LD_LIBRARY_PATH ;; +freebsd1*) + dynamic_linker=no + ;; + freebsd* | dragonfly*) # DragonFly does not have aout. When/if they implement a new # versioning mechanism, adjust this. @@ -2483,7 +2297,7 @@ objformat=`/usr/bin/objformat` else case $host_os in - freebsd[[23]].*) objformat=aout ;; + freebsd[[123]]*) objformat=aout ;; *) objformat=elf ;; esac fi @@ -2501,7 +2315,7 @@ esac shlibpath_var=LD_LIBRARY_PATH case $host_os in - freebsd2.*) + freebsd2*) shlibpath_overrides_runpath=yes ;; freebsd3.[[01]]* | freebsdelf3.[[01]]*) @@ -2521,26 +2335,12 @@ ;; gnu*) - version_type=linux # correct to gnu/linux during the next big refactor + version_type=linux need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH - shlibpath_overrides_runpath=no - hardcode_into_libs=yes - ;; - -haiku*) - version_type=linux # correct to gnu/linux during the next big refactor - need_lib_prefix=no - need_version=no - dynamic_linker="$host_os runtime_loader" - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - shlibpath_var=LIBRARY_PATH - shlibpath_overrides_runpath=yes - sys_lib_dlsearch_path_spec='/boot/home/config/lib /boot/common/lib /boot/system/lib' hardcode_into_libs=yes ;; @@ -2586,14 +2386,12 @@ soname_spec='${libname}${release}${shared_ext}$major' ;; esac - # HP-UX runs *really* slowly unless shared libraries are mode 555, ... + # HP-UX runs *really* slowly unless shared libraries are mode 555. postinstall_cmds='chmod 555 $lib' - # or fails outright, so override atomically: - install_override_mode=555 ;; interix[[3-9]]*) - version_type=linux # correct to gnu/linux during the next big refactor + version_type=linux need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' @@ -2609,7 +2407,7 @@ nonstopux*) version_type=nonstopux ;; *) if test "$lt_cv_prog_gnu_ld" = yes; then - version_type=linux # correct to gnu/linux during the next big refactor + version_type=linux else version_type=irix fi ;; @@ -2646,9 +2444,9 @@ dynamic_linker=no ;; -# This must be glibc/ELF. -linux* | k*bsd*-gnu | kopensolaris*-gnu) - version_type=linux # correct to gnu/linux during the next big refactor +# This must be Linux ELF. +linux* | k*bsd*-gnu) + version_type=linux need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' @@ -2656,21 +2454,16 @@ finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no - # Some binutils ld are patched to set DT_RUNPATH - AC_CACHE_VAL([lt_cv_shlibpath_overrides_runpath], - [lt_cv_shlibpath_overrides_runpath=no - save_LDFLAGS=$LDFLAGS - save_libdir=$libdir - eval "libdir=/foo; wl=\"$_LT_TAGVAR(lt_prog_compiler_wl, $1)\"; \ - LDFLAGS=\"\$LDFLAGS $_LT_TAGVAR(hardcode_libdir_flag_spec, $1)\"" - AC_LINK_IFELSE([AC_LANG_PROGRAM([],[])], - [AS_IF([ ($OBJDUMP -p conftest$ac_exeext) 2>/dev/null | grep "RUNPATH.*$libdir" >/dev/null], - [lt_cv_shlibpath_overrides_runpath=yes])]) - LDFLAGS=$save_LDFLAGS - libdir=$save_libdir - ]) - shlibpath_overrides_runpath=$lt_cv_shlibpath_overrides_runpath + save_LDFLAGS=$LDFLAGS + save_libdir=$libdir + eval "libdir=/foo; wl=\"$_LT_TAGVAR(lt_prog_compiler_wl, $1)\"; \ + LDFLAGS=\"\$LDFLAGS $_LT_TAGVAR(hardcode_libdir_flag_spec, $1)\"" + AC_LINK_IFELSE([AC_LANG_PROGRAM([],[])], + [AS_IF([ ($OBJDUMP -p conftest$ac_exeext) 2>/dev/null | grep "RUNPATH.*$libdir" >/dev/null], + [shlibpath_overrides_runpath=yes])]) + LDFLAGS=$save_LDFLAGS + libdir=$save_libdir # This implies no fast_install, which is unacceptable. # Some rework will be needed to allow for fast_install @@ -2682,9 +2475,8 @@ # Append ld.so.conf contents to the search path if test -f /etc/ld.so.conf; then - lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s 2>/dev/null", \[$]2)); skip = 1; } { if (!skip) print \[$]0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;/^[ ]*hwcap[ ]/d;s/[:, ]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;s/"//g;/^$/d' | tr '\n' ' '` + lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s 2>/dev/null", \[$]2)); skip = 1; } { if (!skip) print \[$]0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;/^[ ]*hwcap[ ]/d;s/[:, ]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;/^$/d' | tr '\n' ' '` sys_lib_dlsearch_path_spec="$sys_lib_dlsearch_path_spec $lt_ld_extra" - fi # We used to test for /lib/ld.so.1 and disable shared libraries on @@ -2715,7 +2507,7 @@ ;; newsos6) - version_type=linux # correct to gnu/linux during the next big refactor + version_type=linux library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes @@ -2784,7 +2576,7 @@ ;; solaris*) - version_type=linux # correct to gnu/linux during the next big refactor + version_type=linux need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' @@ -2809,7 +2601,7 @@ ;; sysv4 | sysv4.3*) - version_type=linux # correct to gnu/linux during the next big refactor + version_type=linux library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH @@ -2833,7 +2625,7 @@ sysv4*MP*) if test -d /usr/nec ;then - version_type=linux # correct to gnu/linux during the next big refactor + version_type=linux library_names_spec='$libname${shared_ext}.$versuffix $libname${shared_ext}.$major $libname${shared_ext}' soname_spec='$libname${shared_ext}.$major' shlibpath_var=LD_LIBRARY_PATH @@ -2864,7 +2656,7 @@ tpf*) # TPF is a cross-target only. Preferred cross-host = GNU/Linux. - version_type=linux # correct to gnu/linux during the next big refactor + version_type=linux need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' @@ -2874,7 +2666,7 @@ ;; uts4*) - version_type=linux # correct to gnu/linux during the next big refactor + version_type=linux library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH @@ -2916,8 +2708,6 @@ The last name is the one that the linker finds with -lNAME]]) _LT_DECL([], [soname_spec], [1], [[The coded name of the library, if different from the real name]]) -_LT_DECL([], [install_override_mode], [1], - [Permission mode override for installation of shared libraries]) _LT_DECL([], [postinstall_cmds], [2], [Command to use after installation of a shared archive]) _LT_DECL([], [postuninstall_cmds], [2], @@ -3030,7 +2820,6 @@ AC_REQUIRE([AC_CANONICAL_BUILD])dnl m4_require([_LT_DECL_SED])dnl m4_require([_LT_DECL_EGREP])dnl -m4_require([_LT_PROG_ECHO_BACKSLASH])dnl AC_ARG_WITH([gnu-ld], [AS_HELP_STRING([--with-gnu-ld], @@ -3152,11 +2941,6 @@ esac reload_cmds='$LD$reload_flag -o $output$reload_objs' case $host_os in - cygwin* | mingw* | pw32* | cegcc*) - if test "$GCC" != yes; then - reload_cmds=false - fi - ;; darwin*) if test "$GCC" = yes; then reload_cmds='$LTCC $LTCFLAGS -nostdlib ${wl}-r -o $output$reload_objs' @@ -3165,8 +2949,8 @@ fi ;; esac -_LT_TAGDECL([], [reload_flag], [1], [How to create reloadable object files])dnl -_LT_TAGDECL([], [reload_cmds], [2])dnl +_LT_DECL([], [reload_flag], [1], [How to create reloadable object files])dnl +_LT_DECL([], [reload_cmds], [2])dnl ])# _LT_CMD_RELOAD @@ -3218,18 +3002,16 @@ # Base MSYS/MinGW do not provide the 'file' command needed by # func_win32_libid shell function, so use a weaker test based on 'objdump', # unless we find 'file', for example because we are cross-compiling. - # func_win32_libid assumes BSD nm, so disallow it if using MS dumpbin. - if ( test "$lt_cv_nm_interface" = "BSD nm" && file / ) >/dev/null 2>&1; then + if ( file / ) >/dev/null 2>&1; then lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL' lt_cv_file_magic_cmd='func_win32_libid' else - # Keep this pattern in sync with the one in func_win32_libid. - lt_cv_deplibs_check_method='file_magic file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' + lt_cv_deplibs_check_method='file_magic file format pei*-i386(.*architecture: i386)?' lt_cv_file_magic_cmd='$OBJDUMP -f' fi ;; -cegcc*) +cegcc) # use the weaker test based on 'objdump'. See mingw*. lt_cv_deplibs_check_method='file_magic file format pe-arm-.*little(.*architecture: arm)?' lt_cv_file_magic_cmd='$OBJDUMP -f' @@ -3259,10 +3041,6 @@ lt_cv_deplibs_check_method=pass_all ;; -haiku*) - lt_cv_deplibs_check_method=pass_all - ;; - hpux10.20* | hpux11*) lt_cv_file_magic_cmd=/usr/bin/file case $host_cpu in @@ -3271,11 +3049,11 @@ lt_cv_file_magic_test_file=/usr/lib/hpux32/libc.so ;; hppa*64*) - [lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|ELF[ -][0-9][0-9])(-bit)?( [LM]SB)? shared object( file)?[, -]* PA-RISC [0-9]\.[0-9]'] + [lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|ELF-[0-9][0-9]) shared object file - PA-RISC [0-9].[0-9]'] lt_cv_file_magic_test_file=/usr/lib/pa20_64/libc.sl ;; *) - lt_cv_deplibs_check_method='file_magic (s[[0-9]][[0-9]][[0-9]]|PA-RISC[[0-9]]\.[[0-9]]) shared library' + lt_cv_deplibs_check_method='file_magic (s[[0-9]][[0-9]][[0-9]]|PA-RISC[[0-9]].[[0-9]]) shared library' lt_cv_file_magic_test_file=/usr/lib/libc.sl ;; esac @@ -3296,8 +3074,8 @@ lt_cv_deplibs_check_method=pass_all ;; -# This must be glibc/ELF. -linux* | k*bsd*-gnu | kopensolaris*-gnu) +# This must be Linux ELF. +linux* | k*bsd*-gnu) lt_cv_deplibs_check_method=pass_all ;; @@ -3375,21 +3153,6 @@ ;; esac ]) - -file_magic_glob= -want_nocaseglob=no -if test "$build" = "$host"; then - case $host_os in - mingw* | pw32*) - if ( shopt | grep nocaseglob ) >/dev/null 2>&1; then - want_nocaseglob=yes - else - file_magic_glob=`echo aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ | $SED -e "s/\(..\)/s\/[[\1]]\/[[\1]]\/g;/g"` - fi - ;; - esac -fi - file_magic_cmd=$lt_cv_file_magic_cmd deplibs_check_method=$lt_cv_deplibs_check_method test -z "$deplibs_check_method" && deplibs_check_method=unknown @@ -3397,11 +3160,7 @@ _LT_DECL([], [deplibs_check_method], [1], [Method to check whether dependent libraries are shared objects]) _LT_DECL([], [file_magic_cmd], [1], - [Command to use when deplibs_check_method = "file_magic"]) -_LT_DECL([], [file_magic_glob], [1], - [How to find potential files when deplibs_check_method = "file_magic"]) -_LT_DECL([], [want_nocaseglob], [1], - [Find potential files using nocaseglob when deplibs_check_method = "file_magic"]) + [Command to use when deplibs_check_method == "file_magic"]) ])# _LT_CHECK_MAGIC_METHOD @@ -3458,19 +3217,7 @@ NM="$lt_cv_path_NM" else # Didn't find any BSD compatible name lister, look for dumpbin. - if test -n "$DUMPBIN"; then : - # Let the user override the test. - else - AC_CHECK_TOOLS(DUMPBIN, [dumpbin "link -dump"], :) - case `$DUMPBIN -symbols /dev/null 2>&1 | sed '1q'` in - *COFF*) - DUMPBIN="$DUMPBIN -symbols" - ;; - *) - DUMPBIN=: - ;; - esac - fi + AC_CHECK_TOOLS(DUMPBIN, ["dumpbin -symbols" "link -dump -symbols"], :) AC_SUBST([DUMPBIN]) if test "$DUMPBIN" != ":"; then NM="$DUMPBIN" @@ -3483,13 +3230,13 @@ AC_CACHE_CHECK([the name lister ($NM) interface], [lt_cv_nm_interface], [lt_cv_nm_interface="BSD nm" echo "int some_variable = 0;" > conftest.$ac_ext - (eval echo "\"\$as_me:$LINENO: $ac_compile\"" >&AS_MESSAGE_LOG_FD) + (eval echo "\"\$as_me:__oline__: $ac_compile\"" >&AS_MESSAGE_LOG_FD) (eval "$ac_compile" 2>conftest.err) cat conftest.err >&AS_MESSAGE_LOG_FD - (eval echo "\"\$as_me:$LINENO: $NM \\\"conftest.$ac_objext\\\"\"" >&AS_MESSAGE_LOG_FD) + (eval echo "\"\$as_me:__oline__: $NM \\\"conftest.$ac_objext\\\"\"" >&AS_MESSAGE_LOG_FD) (eval "$NM \"conftest.$ac_objext\"" 2>conftest.err > conftest.out) cat conftest.err >&AS_MESSAGE_LOG_FD - (eval echo "\"\$as_me:$LINENO: output\"" >&AS_MESSAGE_LOG_FD) + (eval echo "\"\$as_me:__oline__: output\"" >&AS_MESSAGE_LOG_FD) cat conftest.out >&AS_MESSAGE_LOG_FD if $GREP 'External.*some_variable' conftest.out > /dev/null; then lt_cv_nm_interface="MS dumpbin" @@ -3504,67 +3251,6 @@ dnl AC_DEFUN([AM_PROG_NM], []) dnl AC_DEFUN([AC_PROG_NM], []) -# _LT_CHECK_SHAREDLIB_FROM_LINKLIB -# -------------------------------- -# how to determine the name of the shared library -# associated with a specific link library. -# -- PORTME fill in with the dynamic library characteristics -m4_defun([_LT_CHECK_SHAREDLIB_FROM_LINKLIB], -[m4_require([_LT_DECL_EGREP]) -m4_require([_LT_DECL_OBJDUMP]) -m4_require([_LT_DECL_DLLTOOL]) -AC_CACHE_CHECK([how to associate runtime and link libraries], -lt_cv_sharedlib_from_linklib_cmd, -[lt_cv_sharedlib_from_linklib_cmd='unknown' - -case $host_os in -cygwin* | mingw* | pw32* | cegcc*) - # two different shell functions defined in ltmain.sh - # decide which to use based on capabilities of $DLLTOOL - case `$DLLTOOL --help 2>&1` in - *--identify-strict*) - lt_cv_sharedlib_from_linklib_cmd=func_cygming_dll_for_implib - ;; - *) - lt_cv_sharedlib_from_linklib_cmd=func_cygming_dll_for_implib_fallback - ;; - esac - ;; -*) - # fallback: assume linklib IS sharedlib - lt_cv_sharedlib_from_linklib_cmd="$ECHO" - ;; -esac -]) -sharedlib_from_linklib_cmd=$lt_cv_sharedlib_from_linklib_cmd -test -z "$sharedlib_from_linklib_cmd" && sharedlib_from_linklib_cmd=$ECHO - -_LT_DECL([], [sharedlib_from_linklib_cmd], [1], - [Command to associate shared and link libraries]) -])# _LT_CHECK_SHAREDLIB_FROM_LINKLIB - - -# _LT_PATH_MANIFEST_TOOL -# ---------------------- -# locate the manifest tool -m4_defun([_LT_PATH_MANIFEST_TOOL], -[AC_CHECK_TOOL(MANIFEST_TOOL, mt, :) -test -z "$MANIFEST_TOOL" && MANIFEST_TOOL=mt -AC_CACHE_CHECK([if $MANIFEST_TOOL is a manifest tool], [lt_cv_path_mainfest_tool], - [lt_cv_path_mainfest_tool=no - echo "$as_me:$LINENO: $MANIFEST_TOOL '-?'" >&AS_MESSAGE_LOG_FD - $MANIFEST_TOOL '-?' 2>conftest.err > conftest.out - cat conftest.err >&AS_MESSAGE_LOG_FD - if $GREP 'Manifest Tool' conftest.out > /dev/null; then - lt_cv_path_mainfest_tool=yes - fi - rm -f conftest*]) -if test "x$lt_cv_path_mainfest_tool" != xyes; then - MANIFEST_TOOL=: -fi -_LT_DECL([], [MANIFEST_TOOL], [1], [Manifest tool])dnl -])# _LT_PATH_MANIFEST_TOOL - # LT_LIB_M # -------- @@ -3573,7 +3259,7 @@ [AC_REQUIRE([AC_CANONICAL_HOST])dnl LIBM= case $host in -*-*-beos* | *-*-cegcc* | *-*-cygwin* | *-*-haiku* | *-*-pw32* | *-*-darwin*) +*-*-beos* | *-*-cygwin* | *-*-pw32* | *-*-darwin*) # These system don't have libm, or don't need it ;; *-ncr-sysv4.3*) @@ -3601,12 +3287,7 @@ _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)= if test "$GCC" = yes; then - case $cc_basename in - nvcc*) - _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=' -Xcompiler -fno-builtin' ;; - *) - _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=' -fno-builtin' ;; - esac + _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=' -fno-builtin' _LT_COMPILER_OPTION([if $compiler supports -fno-rtti -fno-exceptions], lt_cv_prog_compiler_rtti_exceptions, @@ -3623,7 +3304,6 @@ m4_defun([_LT_CMD_GLOBAL_SYMBOLS], [AC_REQUIRE([AC_CANONICAL_HOST])dnl AC_REQUIRE([AC_PROG_CC])dnl -AC_REQUIRE([AC_PROG_AWK])dnl AC_REQUIRE([LT_PATH_NM])dnl AC_REQUIRE([LT_PATH_LD])dnl m4_require([_LT_DECL_SED])dnl @@ -3691,8 +3371,8 @@ lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^T .* \(.*\)$/extern int \1();/p' -e 's/^$symcode* .* \(.*\)$/extern char \1;/p'" # Transform an extracted symbol line into symbol name and symbol address -lt_cv_sys_global_symbol_to_c_name_address="sed -n -e 's/^: \([[^ ]]*\)[[ ]]*$/ {\\\"\1\\\", (void *) 0},/p' -e 's/^$symcode* \([[^ ]]*\) \([[^ ]]*\)$/ {\"\2\", (void *) \&\2},/p'" -lt_cv_sys_global_symbol_to_c_name_address_lib_prefix="sed -n -e 's/^: \([[^ ]]*\)[[ ]]*$/ {\\\"\1\\\", (void *) 0},/p' -e 's/^$symcode* \([[^ ]]*\) \(lib[[^ ]]*\)$/ {\"\2\", (void *) \&\2},/p' -e 's/^$symcode* \([[^ ]]*\) \([[^ ]]*\)$/ {\"lib\2\", (void *) \&\2},/p'" +lt_cv_sys_global_symbol_to_c_name_address="sed -n -e 's/^: \([[^ ]]*\) $/ {\\\"\1\\\", (void *) 0},/p' -e 's/^$symcode* \([[^ ]]*\) \([[^ ]]*\)$/ {\"\2\", (void *) \&\2},/p'" +lt_cv_sys_global_symbol_to_c_name_address_lib_prefix="sed -n -e 's/^: \([[^ ]]*\) $/ {\\\"\1\\\", (void *) 0},/p' -e 's/^$symcode* \([[^ ]]*\) \(lib[[^ ]]*\)$/ {\"\2\", (void *) \&\2},/p' -e 's/^$symcode* \([[^ ]]*\) \([[^ ]]*\)$/ {\"lib\2\", (void *) \&\2},/p'" # Handle CRLF in mingw tool chain opt_cr= @@ -3716,7 +3396,6 @@ # which start with @ or ?. lt_cv_sys_global_symbol_pipe="$AWK ['"\ " {last_section=section; section=\$ 3};"\ -" /^COFF SYMBOL TABLE/{for(i in hide) delete hide[i]};"\ " /Section length .*#relocs.*(pick any)/{hide[last_section]=1};"\ " \$ 0!~/External *\|/{next};"\ " / 0+ UNDEF /{next}; / UNDEF \([^|]\)*()/{next};"\ @@ -3729,7 +3408,6 @@ else lt_cv_sys_global_symbol_pipe="sed -n -e 's/^.*[[ ]]\($symcode$symcode*\)[[ ]][[ ]]*$ac_symprfx$sympat$opt_cr$/$symxfrm/p'" fi - lt_cv_sys_global_symbol_pipe="$lt_cv_sys_global_symbol_pipe | sed '/ __gnu_lto/d'" # Check to see that the pipe works correctly. pipe_works=no @@ -3751,7 +3429,7 @@ if AC_TRY_EVAL(ac_compile); then # Now try to grab the symbols. nlist=conftest.nm - if AC_TRY_EVAL(NM conftest.$ac_objext \| "$lt_cv_sys_global_symbol_pipe" \> $nlist) && test -s "$nlist"; then + if AC_TRY_EVAL(NM conftest.$ac_objext \| $lt_cv_sys_global_symbol_pipe \> $nlist) && test -s "$nlist"; then # Try sorting and uniquifying the output. if sort "$nlist" | uniq > "$nlist"T; then mv -f "$nlist"T "$nlist" @@ -3763,18 +3441,6 @@ if $GREP ' nm_test_var$' "$nlist" >/dev/null; then if $GREP ' nm_test_func$' "$nlist" >/dev/null; then cat <<_LT_EOF > conftest.$ac_ext -/* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests. */ -#if defined(_WIN32) || defined(__CYGWIN__) || defined(_WIN32_WCE) -/* DATA imports from DLLs on WIN32 con't be const, because runtime - relocations are performed -- see ld's documentation on pseudo-relocs. */ -# define LT@&t@_DLSYM_CONST -#elif defined(__osf__) -/* This system does not cope well with relocations in const data. */ -# define LT@&t@_DLSYM_CONST -#else -# define LT@&t@_DLSYM_CONST const -#endif - #ifdef __cplusplus extern "C" { #endif @@ -3786,7 +3452,7 @@ cat <<_LT_EOF >> conftest.$ac_ext /* The mapping between symbol names and symbols. */ -LT@&t@_DLSYM_CONST struct { +const struct { const char *name; void *address; } @@ -3812,15 +3478,15 @@ _LT_EOF # Now try linking the two files. mv conftest.$ac_objext conftstm.$ac_objext - lt_globsym_save_LIBS=$LIBS - lt_globsym_save_CFLAGS=$CFLAGS + lt_save_LIBS="$LIBS" + lt_save_CFLAGS="$CFLAGS" LIBS="conftstm.$ac_objext" CFLAGS="$CFLAGS$_LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)" if AC_TRY_EVAL(ac_link) && test -s conftest${ac_exeext}; then pipe_works=yes fi - LIBS=$lt_globsym_save_LIBS - CFLAGS=$lt_globsym_save_CFLAGS + LIBS="$lt_save_LIBS" + CFLAGS="$lt_save_CFLAGS" else echo "cannot find nm_test_func in $nlist" >&AS_MESSAGE_LOG_FD fi @@ -3853,13 +3519,6 @@ AC_MSG_RESULT(ok) fi -# Response file support. -if test "$lt_cv_nm_interface" = "MS dumpbin"; then - nm_file_list_spec='@' -elif $NM --help 2>/dev/null | grep '[[@]]FILE' >/dev/null; then - nm_file_list_spec='@' -fi - _LT_DECL([global_symbol_pipe], [lt_cv_sys_global_symbol_pipe], [1], [Take the output of nm and produce a listing of raw symbols and C names]) _LT_DECL([global_symbol_to_cdecl], [lt_cv_sys_global_symbol_to_cdecl], [1], @@ -3870,8 +3529,6 @@ _LT_DECL([global_symbol_to_c_name_address_lib_prefix], [lt_cv_sys_global_symbol_to_c_name_address_lib_prefix], [1], [Transform the output of nm in a C name address pair when lib prefix is needed]) -_LT_DECL([], [nm_file_list_spec], [1], - [Specify filename containing input files for $NM]) ]) # _LT_CMD_GLOBAL_SYMBOLS @@ -3883,6 +3540,7 @@ _LT_TAGVAR(lt_prog_compiler_pic, $1)= _LT_TAGVAR(lt_prog_compiler_static, $1)= +AC_MSG_CHECKING([for $compiler option to produce PIC]) m4_if([$1], [CXX], [ # C++ specific cases for pic, static, wl, etc. if test "$GXX" = yes; then @@ -3933,11 +3591,6 @@ # DJGPP does not support shared libraries at all _LT_TAGVAR(lt_prog_compiler_pic, $1)= ;; - haiku*) - # PIC is the default for Haiku. - # The "-static" flag exists, but is broken. - _LT_TAGVAR(lt_prog_compiler_static, $1)= - ;; interix[[3-9]]*) # Interix 3.x gcc -fpic/-fPIC options generate broken code. # Instead, we relocate shared libraries at runtime. @@ -3987,12 +3640,6 @@ ;; esac ;; - mingw* | cygwin* | os2* | pw32* | cegcc*) - # This hack is so that the source file can tell whether it is being - # built for inclusion in a dll (and should export symbols for example). - m4_if([$1], [GCJ], [], - [_LT_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT']) - ;; dgux*) case $cc_basename in ec++*) @@ -4049,7 +3696,7 @@ ;; esac ;; - linux* | k*bsd*-gnu | kopensolaris*-gnu) + linux* | k*bsd*-gnu) case $cc_basename in KCC*) # KAI C++ Compiler @@ -4082,8 +3729,8 @@ _LT_TAGVAR(lt_prog_compiler_pic, $1)= _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' ;; - xlc* | xlC* | bgxl[[cC]]* | mpixl[[cC]]*) - # IBM XL 8.0, 9.0 on PPC and BlueGene + xlc* | xlC*) + # IBM XL 8.0 on PPC _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-qpic' _LT_TAGVAR(lt_prog_compiler_static, $1)='-qstaticlink' @@ -4145,7 +3792,7 @@ ;; solaris*) case $cc_basename in - CC* | sunCC*) + CC*) # Sun C++ 4.2, 5.x and Centerline C++ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' @@ -4249,12 +3896,6 @@ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fno-common' ;; - haiku*) - # PIC is the default for Haiku. - # The "-static" flag exists, but is broken. - _LT_TAGVAR(lt_prog_compiler_static, $1)= - ;; - hpux*) # PIC is the default for 64-bit PA HP-UX, but not for 32-bit # PA HP-UX. On IA64 HP-UX, PIC is the default but the pic flag @@ -4297,15 +3938,6 @@ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' ;; esac - - case $cc_basename in - nvcc*) # Cuda Compiler Driver 2.2 - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Xlinker ' - if test -n "$_LT_TAGVAR(lt_prog_compiler_pic, $1)"; then - _LT_TAGVAR(lt_prog_compiler_pic, $1)="-Xcompiler $_LT_TAGVAR(lt_prog_compiler_pic, $1)" - fi - ;; - esac else # PORTME Check for flag to pass linker flags through the system compiler. case $host_os in @@ -4348,7 +3980,7 @@ _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' ;; - linux* | k*bsd*-gnu | kopensolaris*-gnu) + linux* | k*bsd*-gnu) case $cc_basename in # old Intel for x86_64 which still supported -KPIC. ecc*) @@ -4369,13 +4001,7 @@ _LT_TAGVAR(lt_prog_compiler_pic, $1)='--shared' _LT_TAGVAR(lt_prog_compiler_static, $1)='--static' ;; - nagfor*) - # NAG Fortran compiler - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,-Wl,,' - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-PIC' - _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' - ;; - pgcc* | pgf77* | pgf90* | pgf95* | pgfortran*) + pgcc* | pgf77* | pgf90* | pgf95*) # Portland Group compilers (*not* the Pentium gcc compiler, # which looks to be a dead project) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' @@ -4387,40 +4013,25 @@ # All Alpha code is PIC. _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' ;; - xl* | bgxl* | bgf* | mpixl*) - # IBM XL C 8.0/Fortran 10.1, 11.1 on PPC and BlueGene + xl*) + # IBM XL C 8.0/Fortran 10.1 on PPC _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-qpic' _LT_TAGVAR(lt_prog_compiler_static, $1)='-qstaticlink' ;; *) case `$CC -V 2>&1 | sed 5q` in - *Sun\ Ceres\ Fortran* | *Sun*Fortran*\ [[1-7]].* | *Sun*Fortran*\ 8.[[0-3]]*) - # Sun Fortran 8.3 passes all unrecognized flags to the linker - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' - _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' - _LT_TAGVAR(lt_prog_compiler_wl, $1)='' - ;; - *Sun\ F* | *Sun*Fortran*) - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' - _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ' - ;; *Sun\ C*) # Sun C 5.9 _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' ;; - *Intel*\ [[CF]]*Compiler*) - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' - _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' - ;; - *Portland\ Group*) - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fpic' + *Sun\ F*) + # Sun Fortran 8.3 passes all unrecognized flags to the linker + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + _LT_TAGVAR(lt_prog_compiler_wl, $1)='' ;; esac ;; @@ -4452,7 +4063,7 @@ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' case $cc_basename in - f77* | f90* | f95* | sunf77* | sunf90* | sunf95*) + f77* | f90* | f95*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ';; *) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,';; @@ -4509,11 +4120,9 @@ _LT_TAGVAR(lt_prog_compiler_pic, $1)="$_LT_TAGVAR(lt_prog_compiler_pic, $1)@&t@m4_if([$1],[],[ -DPIC],[m4_if([$1],[CXX],[ -DPIC],[])])" ;; esac - -AC_CACHE_CHECK([for $compiler option to produce PIC], - [_LT_TAGVAR(lt_cv_prog_compiler_pic, $1)], - [_LT_TAGVAR(lt_cv_prog_compiler_pic, $1)=$_LT_TAGVAR(lt_prog_compiler_pic, $1)]) -_LT_TAGVAR(lt_prog_compiler_pic, $1)=$_LT_TAGVAR(lt_cv_prog_compiler_pic, $1) +AC_MSG_RESULT([$_LT_TAGVAR(lt_prog_compiler_pic, $1)]) +_LT_TAGDECL([wl], [lt_prog_compiler_wl], [1], + [How to pass a linker flag through the compiler]) # # Check to make sure the PIC flag actually works. @@ -4532,8 +4141,6 @@ _LT_TAGDECL([pic_flag], [lt_prog_compiler_pic], [1], [Additional compiler flags for building library objects]) -_LT_TAGDECL([wl], [lt_prog_compiler_wl], [1], - [How to pass a linker flag through the compiler]) # # Check to make sure the static flag actually works. # @@ -4554,7 +4161,6 @@ m4_defun([_LT_LINKER_SHLIBS], [AC_REQUIRE([LT_PATH_LD])dnl AC_REQUIRE([LT_PATH_NM])dnl -m4_require([_LT_PATH_MANIFEST_TOOL])dnl m4_require([_LT_FILEUTILS_DEFAULTS])dnl m4_require([_LT_DECL_EGREP])dnl m4_require([_LT_DECL_SED])dnl @@ -4563,37 +4169,27 @@ AC_MSG_CHECKING([whether the $compiler linker ($LD) supports shared libraries]) m4_if([$1], [CXX], [ _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' - _LT_TAGVAR(exclude_expsyms, $1)=['_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*'] case $host_os in aix[[4-9]]*) # If we're using GNU nm, then we don't want the "-C" option. # -C means demangle to AIX nm, but means don't demangle with GNU nm - # Also, AIX nm treats weak defined symbols like other global defined - # symbols, whereas GNU nm marks them as "W". if $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then - _LT_TAGVAR(export_symbols_cmds, $1)='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W")) && ([substr](\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols' + _LT_TAGVAR(export_symbols_cmds, $1)='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && ([substr](\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols' else _LT_TAGVAR(export_symbols_cmds, $1)='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && ([substr](\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols' fi ;; pw32*) _LT_TAGVAR(export_symbols_cmds, $1)="$ltdll_cmds" - ;; + ;; cygwin* | mingw* | cegcc*) - case $cc_basename in - cl*) - _LT_TAGVAR(exclude_expsyms, $1)='_NULL_IMPORT_DESCRIPTOR|_IMPORT_DESCRIPTOR_.*' - ;; - *) - _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[[BCDGRS]][[ ]]/s/.*[[ ]]\([[^ ]]*\)/\1 DATA/;s/^.*[[ ]]__nm__\([[^ ]]*\)[[ ]][[^ ]]*/\1 DATA/;/^I[[ ]]/d;/^[[AITW]][[ ]]/s/.* //'\'' | sort | uniq > $export_symbols' - _LT_TAGVAR(exclude_expsyms, $1)=['[_]+GLOBAL_OFFSET_TABLE_|[_]+GLOBAL__[FID]_.*|[_]+head_[A-Za-z0-9_]+_dll|[A-Za-z0-9_]+_dll_iname'] - ;; - esac - ;; + _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[[BCDGRS]][[ ]]/s/.*[[ ]]\([[^ ]]*\)/\1 DATA/;/^.*[[ ]]__nm__/s/^.*[[ ]]__nm__\([[^ ]]*\)[[ ]][[^ ]]*/\1 DATA/;/^I[[ ]]/d;/^[[AITW]][[ ]]/s/.* //'\'' | sort | uniq > $export_symbols' + ;; *) _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' - ;; + ;; esac + _LT_TAGVAR(exclude_expsyms, $1)=['_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*'] ], [ runpath_var= _LT_TAGVAR(allow_undefined_flag, $1)= @@ -4608,6 +4204,7 @@ _LT_TAGVAR(hardcode_direct, $1)=no _LT_TAGVAR(hardcode_direct_absolute, $1)=no _LT_TAGVAR(hardcode_libdir_flag_spec, $1)= + _LT_TAGVAR(hardcode_libdir_flag_spec_ld, $1)= _LT_TAGVAR(hardcode_libdir_separator, $1)= _LT_TAGVAR(hardcode_minus_L, $1)=no _LT_TAGVAR(hardcode_shlibpath_var, $1)=unsupported @@ -4655,33 +4252,7 @@ esac _LT_TAGVAR(ld_shlibs, $1)=yes - - # On some targets, GNU ld is compatible enough with the native linker - # that we're better off using the native interface for both. - lt_use_gnu_ld_interface=no if test "$with_gnu_ld" = yes; then - case $host_os in - aix*) - # The AIX port of GNU ld has always aspired to compatibility - # with the native linker. However, as the warning in the GNU ld - # block says, versions before 2.19.5* couldn't really create working - # shared libraries, regardless of the interface used. - case `$LD -v 2>&1` in - *\ \(GNU\ Binutils\)\ 2.19.5*) ;; - *\ \(GNU\ Binutils\)\ 2.[[2-9]]*) ;; - *\ \(GNU\ Binutils\)\ [[3-9]]*) ;; - *) - lt_use_gnu_ld_interface=yes - ;; - esac - ;; - *) - lt_use_gnu_ld_interface=yes - ;; - esac - fi - - if test "$lt_use_gnu_ld_interface" = yes; then # If archive_cmds runs LD, not CC, wlarc should be empty wlarc='${wl}' @@ -4699,7 +4270,6 @@ fi supports_anon_versioning=no case `$LD -v 2>&1` in - *GNU\ gold*) supports_anon_versioning=yes ;; *\ [[01]].* | *\ 2.[[0-9]].* | *\ 2.10.*) ;; # catch versions < 2.11 *\ 2.11.93.0.2\ *) supports_anon_versioning=yes ;; # RH7.3 ... *\ 2.11.92.0.12\ *) supports_anon_versioning=yes ;; # Mandrake 8.2 ... @@ -4715,12 +4285,11 @@ _LT_TAGVAR(ld_shlibs, $1)=no cat <<_LT_EOF 1>&2 -*** Warning: the GNU linker, at least up to release 2.19, is reported +*** Warning: the GNU linker, at least up to release 2.9.1, is reported *** to be unable to reliably create shared libraries on AIX. *** Therefore, libtool is disabling shared libraries support. If you -*** really care for shared libraries, you may want to install binutils -*** 2.20 or above, or modify your PATH so that a non-GNU linker is found. -*** You will then need to restart the configuration process. +*** really care for shared libraries, you may want to modify your PATH +*** so that a non-GNU linker is found, and then restart. _LT_EOF fi @@ -4756,12 +4325,10 @@ # _LT_TAGVAR(hardcode_libdir_flag_spec, $1) is actually meaningless, # as there is no search path for DLLs. _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' - _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-all-symbols' _LT_TAGVAR(allow_undefined_flag, $1)=unsupported _LT_TAGVAR(always_export_symbols, $1)=no _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes - _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[[BCDGRS]][[ ]]/s/.*[[ ]]\([[^ ]]*\)/\1 DATA/;s/^.*[[ ]]__nm__\([[^ ]]*\)[[ ]][[^ ]]*/\1 DATA/;/^I[[ ]]/d;/^[[AITW]][[ ]]/s/.* //'\'' | sort | uniq > $export_symbols' - _LT_TAGVAR(exclude_expsyms, $1)=['[_]+GLOBAL_OFFSET_TABLE_|[_]+GLOBAL__[FID]_.*|[_]+head_[A-Za-z0-9_]+_dll|[A-Za-z0-9_]+_dll_iname'] + _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[[BCDGRS]][[ ]]/s/.*[[ ]]\([[^ ]]*\)/\1 DATA/'\'' | $SED -e '\''/^[[AITW]][[ ]]/s/.*[[ ]]//'\'' | sort | uniq > $export_symbols' if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' @@ -4779,11 +4346,6 @@ fi ;; - haiku*) - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' - _LT_TAGVAR(link_all_deplibs, $1)=yes - ;; - interix[[3-9]]*) _LT_TAGVAR(hardcode_direct, $1)=no _LT_TAGVAR(hardcode_shlibpath_var, $1)=no @@ -4799,7 +4361,7 @@ _LT_TAGVAR(archive_expsym_cmds, $1)='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' ;; - gnu* | linux* | tpf* | k*bsd*-gnu | kopensolaris*-gnu) + gnu* | linux* | tpf* | k*bsd*-gnu) tmp_diet=no if test "$host_os" = linux-dietlibc; then case $cc_basename in @@ -4809,16 +4371,15 @@ if $LD --help 2>&1 | $EGREP ': supported targets:.* elf' > /dev/null \ && test "$tmp_diet" = no then - tmp_addflag=' $pic_flag' + tmp_addflag= tmp_sharedflag='-shared' case $cc_basename,$host_cpu in pgcc*) # Portland Group C compiler - _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive' + _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $ECHO \"$new_convenience\"` ${wl}--no-whole-archive' tmp_addflag=' $pic_flag' ;; - pgf77* | pgf90* | pgf95* | pgfortran*) - # Portland Group f77 and f90 compilers - _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive' + pgf77* | pgf90* | pgf95*) # Portland Group f77 and f90 compilers + _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $ECHO \"$new_convenience\"` ${wl}--no-whole-archive' tmp_addflag=' $pic_flag -Mnomain' ;; ecc*,ia64* | icc*,ia64*) # Intel C compiler on ia64 tmp_addflag=' -i_dynamic' ;; @@ -4829,17 +4390,13 @@ lf95*) # Lahey Fortran 8.1 _LT_TAGVAR(whole_archive_flag_spec, $1)= tmp_sharedflag='--shared' ;; - xl[[cC]]* | bgxl[[cC]]* | mpixl[[cC]]*) # IBM XL C 8.0 on PPC (deal with xlf below) + xl[[cC]]*) # IBM XL C 8.0 on PPC (deal with xlf below) tmp_sharedflag='-qmkshrobj' tmp_addflag= ;; - nvcc*) # Cuda Compiler Driver 2.2 - _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive' - _LT_TAGVAR(compiler_needs_object, $1)=yes - ;; esac case `$CC -V 2>&1 | sed 5q` in *Sun\ C*) # Sun C 5.9 - _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive' + _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; $ECHO \"$new_convenience\"` ${wl}--no-whole-archive' _LT_TAGVAR(compiler_needs_object, $1)=yes tmp_sharedflag='-G' ;; *Sun\ F*) # Sun Fortran 8.3 @@ -4855,16 +4412,17 @@ fi case $cc_basename in - xlf* | bgf* | bgxlf* | mpixlf*) + xlf*) # IBM XL Fortran 10.1 on PPC cannot create shared libs itself _LT_TAGVAR(whole_archive_flag_spec, $1)='--whole-archive$convenience --no-whole-archive' - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' - _LT_TAGVAR(archive_cmds, $1)='$LD -shared $libobjs $deplibs $linker_flags -soname $soname -o $lib' + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)= + _LT_TAGVAR(hardcode_libdir_flag_spec_ld, $1)='-rpath $libdir' + _LT_TAGVAR(archive_cmds, $1)='$LD -shared $libobjs $deplibs $compiler_flags -soname $soname -o $lib' if test "x$supports_anon_versioning" = xyes; then _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $output_objdir/$libname.ver~ cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ echo "local: *; };" >> $output_objdir/$libname.ver~ - $LD -shared $libobjs $deplibs $linker_flags -soname $soname -version-script $output_objdir/$libname.ver -o $lib' + $LD -shared $libobjs $deplibs $compiler_flags -soname $soname -version-script $output_objdir/$libname.ver -o $lib' fi ;; esac @@ -4878,8 +4436,8 @@ _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib' wlarc= else - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' - _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' fi ;; @@ -4897,8 +4455,8 @@ _LT_EOF elif $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' - _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' else _LT_TAGVAR(ld_shlibs, $1)=no fi @@ -4944,8 +4502,8 @@ *) if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' - _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' else _LT_TAGVAR(ld_shlibs, $1)=no fi @@ -4985,10 +4543,8 @@ else # If we're using GNU nm, then we don't want the "-C" option. # -C means demangle to AIX nm, but means don't demangle with GNU nm - # Also, AIX nm treats weak defined symbols like other global - # defined symbols, whereas GNU nm marks them as "W". if $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then - _LT_TAGVAR(export_symbols_cmds, $1)='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W")) && ([substr](\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols' + _LT_TAGVAR(export_symbols_cmds, $1)='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && ([substr](\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols' else _LT_TAGVAR(export_symbols_cmds, $1)='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && ([substr](\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols' fi @@ -5075,9 +4631,9 @@ _LT_TAGVAR(allow_undefined_flag, $1)='-berok' # Determine the default libpath from the value encoded in an # empty executable. - _LT_SYS_MODULE_PATH_AIX([$1]) + _LT_SYS_MODULE_PATH_AIX _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath" - _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then func_echo_all "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag" + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then $ECHO "X${wl}${allow_undefined_flag}" | $Xsed; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag" else if test "$host_cpu" = ia64; then _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $libdir:/usr/lib:/lib' @@ -5086,19 +4642,14 @@ else # Determine the default libpath from the value encoded in an # empty executable. - _LT_SYS_MODULE_PATH_AIX([$1]) + _LT_SYS_MODULE_PATH_AIX _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath" # Warning - without using the other run time loading flags, # -berok will link without error, but may produce a broken library. _LT_TAGVAR(no_undefined_flag, $1)=' ${wl}-bernotok' _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-berok' - if test "$with_gnu_ld" = yes; then - # We only use this code for GNU lds that support --whole-archive. - _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive$convenience ${wl}--no-whole-archive' - else - # Exported symbols can be pulled into shared objects from archives - _LT_TAGVAR(whole_archive_flag_spec, $1)='$convenience' - fi + # Exported symbols can be pulled into shared objects from archives + _LT_TAGVAR(whole_archive_flag_spec, $1)='$convenience' _LT_TAGVAR(archive_cmds_need_lc, $1)=yes # This is similar to how AIX traditionally builds its shared libraries. _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname' @@ -5130,64 +4681,20 @@ # Microsoft Visual C++. # hardcode_libdir_flag_spec is actually meaningless, as there is # no search path for DLLs. - case $cc_basename in - cl*) - # Native MSVC - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)=' ' - _LT_TAGVAR(allow_undefined_flag, $1)=unsupported - _LT_TAGVAR(always_export_symbols, $1)=yes - _LT_TAGVAR(file_list_spec, $1)='@' - # Tell ltmain to make .lib files, not .a files. - libext=lib - # Tell ltmain to make .dll files, not .so files. - shrext_cmds=".dll" - # FIXME: Setting linknames here is a bad hack. - _LT_TAGVAR(archive_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $compiler_flags $deplibs -Wl,-dll~linknames=' - _LT_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then - sed -n -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' -e '1\\\!p' < $export_symbols > $output_objdir/$soname.exp; - else - sed -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' < $export_symbols > $output_objdir/$soname.exp; - fi~ - $CC -o $tool_output_objdir$soname $libobjs $compiler_flags $deplibs "@$tool_output_objdir$soname.exp" -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~ - linknames=' - # The linker will not automatically build a static lib if we build a DLL. - # _LT_TAGVAR(old_archive_from_new_cmds, $1)='true' - _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes - _LT_TAGVAR(exclude_expsyms, $1)='_NULL_IMPORT_DESCRIPTOR|_IMPORT_DESCRIPTOR_.*' - _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[[BCDGRS]][[ ]]/s/.*[[ ]]\([[^ ]]*\)/\1,DATA/'\'' | $SED -e '\''/^[[AITW]][[ ]]/s/.*[[ ]]//'\'' | sort | uniq > $export_symbols' - # Don't use ranlib - _LT_TAGVAR(old_postinstall_cmds, $1)='chmod 644 $oldlib' - _LT_TAGVAR(postlink_cmds, $1)='lt_outputfile="@OUTPUT@"~ - lt_tool_outputfile="@TOOL_OUTPUT@"~ - case $lt_outputfile in - *.exe|*.EXE) ;; - *) - lt_outputfile="$lt_outputfile.exe" - lt_tool_outputfile="$lt_tool_outputfile.exe" - ;; - esac~ - if test "$MANIFEST_TOOL" != ":" && test -f "$lt_outputfile.manifest"; then - $MANIFEST_TOOL -manifest "$lt_tool_outputfile.manifest" -outputresource:"$lt_tool_outputfile" || exit 1; - $RM "$lt_outputfile.manifest"; - fi' - ;; - *) - # Assume MSVC wrapper - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)=' ' - _LT_TAGVAR(allow_undefined_flag, $1)=unsupported - # Tell ltmain to make .lib files, not .a files. - libext=lib - # Tell ltmain to make .dll files, not .so files. - shrext_cmds=".dll" - # FIXME: Setting linknames here is a bad hack. - _LT_TAGVAR(archive_cmds, $1)='$CC -o $lib $libobjs $compiler_flags `func_echo_all "$deplibs" | $SED '\''s/ -lc$//'\''` -link -dll~linknames=' - # The linker will automatically build a .lib file if we build a DLL. - _LT_TAGVAR(old_archive_from_new_cmds, $1)='true' - # FIXME: Should let the user specify the lib program. - _LT_TAGVAR(old_archive_cmds, $1)='lib -OUT:$oldlib$oldobjs$old_deplibs' - _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes - ;; - esac + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)=' ' + _LT_TAGVAR(allow_undefined_flag, $1)=unsupported + # Tell ltmain to make .lib files, not .a files. + libext=lib + # Tell ltmain to make .dll files, not .so files. + shrext_cmds=".dll" + # FIXME: Setting linknames here is a bad hack. + _LT_TAGVAR(archive_cmds, $1)='$CC -o $lib $libobjs $compiler_flags `$ECHO "X$deplibs" | $Xsed -e '\''s/ -lc$//'\''` -link -dll~linknames=' + # The linker will automatically build a .lib file if we build a DLL. + _LT_TAGVAR(old_archive_from_new_cmds, $1)='true' + # FIXME: Should let the user specify the lib program. + _LT_TAGVAR(old_archive_cmds, $1)='lib -OUT:$oldlib$oldobjs$old_deplibs' + _LT_TAGVAR(fix_srcfile_path, $1)='`cygpath -w "$srcfile"`' + _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes ;; darwin* | rhapsody*) @@ -5200,6 +4707,10 @@ _LT_TAGVAR(hardcode_shlibpath_var, $1)=no ;; + freebsd1*) + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + # FreeBSD 2.2.[012] allows us to include c++rt0.o to get C++ constructor # support. Future versions do this automatically, but an explicit c++rt0.o # does not break anything, and helps significantly (at the cost of a little @@ -5212,7 +4723,7 @@ ;; # Unfortunately, older versions of FreeBSD 2 do not have this feature. - freebsd2.*) + freebsd2*) _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_minus_L, $1)=yes @@ -5221,7 +4732,7 @@ # FreeBSD 3 and greater uses gcc -shared to do shared libraries. freebsd* | dragonfly*) - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' + _LT_TAGVAR(archive_cmds, $1)='$CC -shared -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_shlibpath_var, $1)=no @@ -5229,7 +4740,7 @@ hpux9*) if test "$GCC" = yes; then - _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$CC -shared $pic_flag ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $libobjs $deplibs $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' + _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$CC -shared -fPIC ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $libobjs $deplibs $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' else _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$LD -b +b $install_libdir -o $output_objdir/$soname $libobjs $deplibs $linker_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' fi @@ -5244,13 +4755,14 @@ ;; hpux10*) - if test "$GCC" = yes && test "$with_gnu_ld" = no; then - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' + if test "$GCC" = yes -a "$with_gnu_ld" = no; then + _LT_TAGVAR(archive_cmds, $1)='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' else _LT_TAGVAR(archive_cmds, $1)='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags' fi if test "$with_gnu_ld" = no; then _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir' + _LT_TAGVAR(hardcode_libdir_flag_spec_ld, $1)='+b $libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=: _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_direct_absolute, $1)=yes @@ -5262,16 +4774,16 @@ ;; hpux11*) - if test "$GCC" = yes && test "$with_gnu_ld" = no; then + if test "$GCC" = yes -a "$with_gnu_ld" = no; then case $host_cpu in hppa*64*) _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' ;; ia64*) - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags' + _LT_TAGVAR(archive_cmds, $1)='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags' ;; *) - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' + _LT_TAGVAR(archive_cmds, $1)='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' ;; esac else @@ -5283,14 +4795,7 @@ _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags' ;; *) - m4_if($1, [], [ - # Older versions of the 11.00 compiler do not understand -b yet - # (HP92453-01 A.11.01.20 doesn't, HP92453-01 B.11.X.35175-35176.GP does) - _LT_LINKER_OPTION([if $CC understands -b], - _LT_TAGVAR(lt_cv_prog_compiler__b, $1), [-b], - [_LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'], - [_LT_TAGVAR(archive_cmds, $1)='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags'])], - [_LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags']) + _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' ;; esac fi @@ -5318,34 +4823,19 @@ irix5* | irix6* | nonstopux*) if test "$GCC" = yes; then - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' # Try to use the -exported_symbol ld option, if it does not # work, assume that -exports_file does not work either and # implicitly export all symbols. - # This should be the same for all languages, so no per-tag cache variable. - AC_CACHE_CHECK([whether the $host_os linker accepts -exported_symbol], - [lt_cv_irix_exported_symbol], - [save_LDFLAGS="$LDFLAGS" - LDFLAGS="$LDFLAGS -shared ${wl}-exported_symbol ${wl}foo ${wl}-update_registry ${wl}/dev/null" - AC_LINK_IFELSE( - [AC_LANG_SOURCE( - [AC_LANG_CASE([C], [[int foo (void) { return 0; }]], - [C++], [[int foo (void) { return 0; }]], - [Fortran 77], [[ - subroutine foo - end]], - [Fortran], [[ - subroutine foo - end]])])], - [lt_cv_irix_exported_symbol=yes], - [lt_cv_irix_exported_symbol=no]) - LDFLAGS="$save_LDFLAGS"]) - if test "$lt_cv_irix_exported_symbol" = yes; then - _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations ${wl}-exports_file ${wl}$export_symbols -o $lib' - fi + save_LDFLAGS="$LDFLAGS" + LDFLAGS="$LDFLAGS -shared ${wl}-exported_symbol ${wl}foo ${wl}-update_registry ${wl}/dev/null" + AC_LINK_IFELSE(int foo(void) {}, + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations ${wl}-exports_file ${wl}$export_symbols -o $lib' + ) + LDFLAGS="$save_LDFLAGS" else - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib' - _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -exports_file $export_symbols -o $lib' + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -exports_file $export_symbols -o $lib' fi _LT_TAGVAR(archive_cmds_need_lc, $1)='no' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' @@ -5407,17 +4897,17 @@ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' _LT_TAGVAR(hardcode_minus_L, $1)=yes _LT_TAGVAR(allow_undefined_flag, $1)=unsupported - _LT_TAGVAR(archive_cmds, $1)='$ECHO "LIBRARY $libname INITINSTANCE" > $output_objdir/$libname.def~$ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~echo DATA >> $output_objdir/$libname.def~echo " SINGLE NONSHARED" >> $output_objdir/$libname.def~echo EXPORTS >> $output_objdir/$libname.def~emxexp $libobjs >> $output_objdir/$libname.def~$CC -Zdll -Zcrtdll -o $lib $libobjs $deplibs $compiler_flags $output_objdir/$libname.def' + _LT_TAGVAR(archive_cmds, $1)='$ECHO "LIBRARY $libname INITINSTANCE" > $output_objdir/$libname.def~$ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~$ECHO DATA >> $output_objdir/$libname.def~$ECHO " SINGLE NONSHARED" >> $output_objdir/$libname.def~$ECHO EXPORTS >> $output_objdir/$libname.def~emxexp $libobjs >> $output_objdir/$libname.def~$CC -Zdll -Zcrtdll -o $lib $libobjs $deplibs $compiler_flags $output_objdir/$libname.def' _LT_TAGVAR(old_archive_from_new_cmds, $1)='emximp -o $output_objdir/$libname.a $output_objdir/$libname.def' ;; osf3*) if test "$GCC" = yes; then _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*' - _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' + _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' else _LT_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*' - _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib' + _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib' fi _LT_TAGVAR(archive_cmds_need_lc, $1)='no' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' @@ -5427,13 +4917,13 @@ osf4* | osf5*) # as osf3* with the addition of -msym flag if test "$GCC" = yes; then _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*' - _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $pic_flag $libobjs $deplibs $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' + _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' else _LT_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*' - _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags -msym -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib' + _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags -msym -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done; printf "%s\\n" "-hidden">> $lib.exp~ - $CC -shared${allow_undefined_flag} ${wl}-input ${wl}$lib.exp $compiler_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && $ECHO "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib~$RM $lib.exp' + $CC -shared${allow_undefined_flag} ${wl}-input ${wl}$lib.exp $compiler_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib~$RM $lib.exp' # Both c and cxx compiler support -rpath directly _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir' @@ -5446,9 +4936,9 @@ _LT_TAGVAR(no_undefined_flag, $1)=' -z defs' if test "$GCC" = yes; then wlarc='${wl}' - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag ${wl}-z ${wl}text ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' + _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-z ${wl}text ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ - $CC -shared $pic_flag ${wl}-z ${wl}text ${wl}-M ${wl}$lib.exp ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp' + $CC -shared ${wl}-z ${wl}text ${wl}-M ${wl}$lib.exp ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp' else case `$CC -V 2>&1` in *"Compilers 5.0"*) @@ -5624,38 +5114,36 @@ # Test whether the compiler implicitly links with -lc since on some # systems, -lgcc has to come before -lc. If gcc already passes -lc # to ld, don't add -lc before -lgcc. - AC_CACHE_CHECK([whether -lc should be explicitly linked in], - [lt_cv_]_LT_TAGVAR(archive_cmds_need_lc, $1), - [$RM conftest* - echo "$lt_simple_compile_test_code" > conftest.$ac_ext - - if AC_TRY_EVAL(ac_compile) 2>conftest.err; then - soname=conftest - lib=conftest - libobjs=conftest.$ac_objext - deplibs= - wl=$_LT_TAGVAR(lt_prog_compiler_wl, $1) - pic_flag=$_LT_TAGVAR(lt_prog_compiler_pic, $1) - compiler_flags=-v - linker_flags=-v - verstring= - output_objdir=. - libname=conftest - lt_save_allow_undefined_flag=$_LT_TAGVAR(allow_undefined_flag, $1) - _LT_TAGVAR(allow_undefined_flag, $1)= - if AC_TRY_EVAL(_LT_TAGVAR(archive_cmds, $1) 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1) - then - lt_cv_[]_LT_TAGVAR(archive_cmds_need_lc, $1)=no - else - lt_cv_[]_LT_TAGVAR(archive_cmds_need_lc, $1)=yes - fi - _LT_TAGVAR(allow_undefined_flag, $1)=$lt_save_allow_undefined_flag - else - cat conftest.err 1>&5 - fi - $RM conftest* - ]) - _LT_TAGVAR(archive_cmds_need_lc, $1)=$lt_cv_[]_LT_TAGVAR(archive_cmds_need_lc, $1) + AC_MSG_CHECKING([whether -lc should be explicitly linked in]) + $RM conftest* + echo "$lt_simple_compile_test_code" > conftest.$ac_ext + + if AC_TRY_EVAL(ac_compile) 2>conftest.err; then + soname=conftest + lib=conftest + libobjs=conftest.$ac_objext + deplibs= + wl=$_LT_TAGVAR(lt_prog_compiler_wl, $1) + pic_flag=$_LT_TAGVAR(lt_prog_compiler_pic, $1) + compiler_flags=-v + linker_flags=-v + verstring= + output_objdir=. + libname=conftest + lt_save_allow_undefined_flag=$_LT_TAGVAR(allow_undefined_flag, $1) + _LT_TAGVAR(allow_undefined_flag, $1)= + if AC_TRY_EVAL(_LT_TAGVAR(archive_cmds, $1) 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1) + then + _LT_TAGVAR(archive_cmds_need_lc, $1)=no + else + _LT_TAGVAR(archive_cmds_need_lc, $1)=yes + fi + _LT_TAGVAR(allow_undefined_flag, $1)=$lt_save_allow_undefined_flag + else + cat conftest.err 1>&5 + fi + $RM conftest* + AC_MSG_RESULT([$_LT_TAGVAR(archive_cmds_need_lc, $1)]) ;; esac fi @@ -5692,6 +5180,9 @@ _LT_TAGDECL([], [hardcode_libdir_flag_spec], [1], [Flag to hardcode $libdir into a binary during linking. This must work even if $libdir does not exist]) +_LT_TAGDECL([], [hardcode_libdir_flag_spec_ld], [1], + [[If ld is used when linking, flag to hardcode $libdir into a binary + during linking. This must work even if $libdir does not exist]]) _LT_TAGDECL([], [hardcode_libdir_separator], [1], [Whether we need a single "-rpath" flag with a separated argument]) _LT_TAGDECL([], [hardcode_direct], [0], @@ -5717,6 +5208,8 @@ to runtime path list]) _LT_TAGDECL([], [link_all_deplibs], [0], [Whether libtool must link a program against all its dependency libraries]) +_LT_TAGDECL([], [fix_srcfile_path], [1], + [Fix the shell variable $srcfile for the compiler]) _LT_TAGDECL([], [always_export_symbols], [0], [Set to "yes" if exported symbols are required]) _LT_TAGDECL([], [export_symbols_cmds], [2], @@ -5727,8 +5220,6 @@ [Symbols that must always be exported]) _LT_TAGDECL([], [prelink_cmds], [2], [Commands necessary for linking programs (against libraries) with templates]) -_LT_TAGDECL([], [postlink_cmds], [2], - [Commands necessary for finishing linking programs]) _LT_TAGDECL([], [file_list_spec], [1], [Specify filename containing input files]) dnl FIXME: Not yet implemented @@ -5822,15 +5313,14 @@ ])# _LT_LANG_C_CONFIG -# _LT_LANG_CXX_CONFIG([TAG]) -# -------------------------- -# Ensure that the configuration variables for a C++ compiler are suitably -# defined. These variables are subsequently used by _LT_CONFIG to write -# the compiler configuration to `libtool'. -m4_defun([_LT_LANG_CXX_CONFIG], -[m4_require([_LT_FILEUTILS_DEFAULTS])dnl -m4_require([_LT_DECL_EGREP])dnl -m4_require([_LT_PATH_MANIFEST_TOOL])dnl +# _LT_PROG_CXX +# ------------ +# Since AC_PROG_CXX is broken, in that it returns g++ if there is no c++ +# compiler, we have our own version here. +m4_defun([_LT_PROG_CXX], +[ +pushdef([AC_MSG_ERROR], [_lt_caught_CXX_error=yes]) +AC_PROG_CXX if test -n "$CXX" && ( test "X$CXX" != "Xno" && ( (test "X$CXX" = "Xg++" && `g++ -v >/dev/null 2>&1` ) || (test "X$CXX" != "Xg++"))) ; then @@ -5838,6 +5328,22 @@ else _lt_caught_CXX_error=yes fi +popdef([AC_MSG_ERROR]) +])# _LT_PROG_CXX + +dnl aclocal-1.4 backwards compatibility: +dnl AC_DEFUN([_LT_PROG_CXX], []) + + +# _LT_LANG_CXX_CONFIG([TAG]) +# -------------------------- +# Ensure that the configuration variables for a C++ compiler are suitably +# defined. These variables are subsequently used by _LT_CONFIG to write +# the compiler configuration to `libtool'. +m4_defun([_LT_LANG_CXX_CONFIG], +[AC_REQUIRE([_LT_PROG_CXX])dnl +m4_require([_LT_FILEUTILS_DEFAULTS])dnl +m4_require([_LT_DECL_EGREP])dnl AC_LANG_PUSH(C++) _LT_TAGVAR(archive_cmds_need_lc, $1)=no @@ -5849,6 +5355,7 @@ _LT_TAGVAR(hardcode_direct, $1)=no _LT_TAGVAR(hardcode_direct_absolute, $1)=no _LT_TAGVAR(hardcode_libdir_flag_spec, $1)= +_LT_TAGVAR(hardcode_libdir_flag_spec_ld, $1)= _LT_TAGVAR(hardcode_libdir_separator, $1)= _LT_TAGVAR(hardcode_minus_L, $1)=no _LT_TAGVAR(hardcode_shlibpath_var, $1)=unsupported @@ -5858,8 +5365,6 @@ _LT_TAGVAR(module_expsym_cmds, $1)= _LT_TAGVAR(link_all_deplibs, $1)=unknown _LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds -_LT_TAGVAR(reload_flag, $1)=$reload_flag -_LT_TAGVAR(reload_cmds, $1)=$reload_cmds _LT_TAGVAR(no_undefined_flag, $1)= _LT_TAGVAR(whole_archive_flag_spec, $1)= _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no @@ -5891,7 +5396,6 @@ # Allow CC to be a program name with arguments. lt_save_CC=$CC - lt_save_CFLAGS=$CFLAGS lt_save_LD=$LD lt_save_GCC=$GCC GCC=$GXX @@ -5909,7 +5413,6 @@ fi test -z "${LDCXX+set}" || LD=$LDCXX CC=${CXX-"c++"} - CFLAGS=$CXXFLAGS compiler=$CC _LT_TAGVAR(compiler, $1)=$CC _LT_CC_BASENAME([$compiler]) @@ -5931,8 +5434,8 @@ # Check if GNU C++ uses GNU ld as the underlying linker, since the # archiving commands below assume that GNU ld is being used. if test "$with_gnu_ld" = yes; then - _LT_TAGVAR(archive_cmds, $1)='$CC $pic_flag -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib' - _LT_TAGVAR(archive_expsym_cmds, $1)='$CC $pic_flag -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' + _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic' @@ -5964,7 +5467,7 @@ # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. - output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"' + output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "\-L"' else GXX=no @@ -6073,10 +5576,10 @@ _LT_TAGVAR(allow_undefined_flag, $1)='-berok' # Determine the default libpath from the value encoded in an empty # executable. - _LT_SYS_MODULE_PATH_AIX([$1]) + _LT_SYS_MODULE_PATH_AIX _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath" - _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then func_echo_all "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag" + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then $ECHO "X${wl}${allow_undefined_flag}" | $Xsed; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag" else if test "$host_cpu" = ia64; then _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $libdir:/usr/lib:/lib' @@ -6085,19 +5588,14 @@ else # Determine the default libpath from the value encoded in an # empty executable. - _LT_SYS_MODULE_PATH_AIX([$1]) + _LT_SYS_MODULE_PATH_AIX _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath" # Warning - without using the other run time loading flags, # -berok will link without error, but may produce a broken library. _LT_TAGVAR(no_undefined_flag, $1)=' ${wl}-bernotok' _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-berok' - if test "$with_gnu_ld" = yes; then - # We only use this code for GNU lds that support --whole-archive. - _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive$convenience ${wl}--no-whole-archive' - else - # Exported symbols can be pulled into shared objects from archives - _LT_TAGVAR(whole_archive_flag_spec, $1)='$convenience' - fi + # Exported symbols can be pulled into shared objects from archives + _LT_TAGVAR(whole_archive_flag_spec, $1)='$convenience' _LT_TAGVAR(archive_cmds_need_lc, $1)=yes # This is similar to how AIX traditionally builds its shared # libraries. @@ -6127,75 +5625,28 @@ ;; cygwin* | mingw* | pw32* | cegcc*) - case $GXX,$cc_basename in - ,cl* | no,cl*) - # Native MSVC - # hardcode_libdir_flag_spec is actually meaningless, as there is - # no search path for DLLs. - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)=' ' - _LT_TAGVAR(allow_undefined_flag, $1)=unsupported - _LT_TAGVAR(always_export_symbols, $1)=yes - _LT_TAGVAR(file_list_spec, $1)='@' - # Tell ltmain to make .lib files, not .a files. - libext=lib - # Tell ltmain to make .dll files, not .so files. - shrext_cmds=".dll" - # FIXME: Setting linknames here is a bad hack. - _LT_TAGVAR(archive_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $compiler_flags $deplibs -Wl,-dll~linknames=' - _LT_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then - $SED -n -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' -e '1\\\!p' < $export_symbols > $output_objdir/$soname.exp; - else - $SED -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' < $export_symbols > $output_objdir/$soname.exp; - fi~ - $CC -o $tool_output_objdir$soname $libobjs $compiler_flags $deplibs "@$tool_output_objdir$soname.exp" -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~ - linknames=' - # The linker will not automatically build a static lib if we build a DLL. - # _LT_TAGVAR(old_archive_from_new_cmds, $1)='true' - _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes - # Don't use ranlib - _LT_TAGVAR(old_postinstall_cmds, $1)='chmod 644 $oldlib' - _LT_TAGVAR(postlink_cmds, $1)='lt_outputfile="@OUTPUT@"~ - lt_tool_outputfile="@TOOL_OUTPUT@"~ - case $lt_outputfile in - *.exe|*.EXE) ;; - *) - lt_outputfile="$lt_outputfile.exe" - lt_tool_outputfile="$lt_tool_outputfile.exe" - ;; - esac~ - func_to_tool_file "$lt_outputfile"~ - if test "$MANIFEST_TOOL" != ":" && test -f "$lt_outputfile.manifest"; then - $MANIFEST_TOOL -manifest "$lt_tool_outputfile.manifest" -outputresource:"$lt_tool_outputfile" || exit 1; - $RM "$lt_outputfile.manifest"; - fi' - ;; - *) - # g++ - # _LT_TAGVAR(hardcode_libdir_flag_spec, $1) is actually meaningless, - # as there is no search path for DLLs. - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' - _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-all-symbols' - _LT_TAGVAR(allow_undefined_flag, $1)=unsupported - _LT_TAGVAR(always_export_symbols, $1)=no - _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes - - if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then - _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' - # If the export-symbols file already is a .def file (1st line - # is EXPORTS), use it as is; otherwise, prepend... - _LT_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then - cp $export_symbols $output_objdir/$soname.def; - else - echo EXPORTS > $output_objdir/$soname.def; - cat $export_symbols >> $output_objdir/$soname.def; - fi~ - $CC -shared -nostdlib $output_objdir/$soname.def $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' - else - _LT_TAGVAR(ld_shlibs, $1)=no - fi - ;; - esac - ;; + # _LT_TAGVAR(hardcode_libdir_flag_spec, $1) is actually meaningless, + # as there is no search path for DLLs. + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' + _LT_TAGVAR(allow_undefined_flag, $1)=unsupported + _LT_TAGVAR(always_export_symbols, $1)=no + _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes + + if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then + _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' + # If the export-symbols file already is a .def file (1st line + # is EXPORTS), use it as is; otherwise, prepend... + _LT_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then + cp $export_symbols $output_objdir/$soname.def; + else + echo EXPORTS > $output_objdir/$soname.def; + cat $export_symbols >> $output_objdir/$soname.def; + fi~ + $CC -shared -nostdlib $output_objdir/$soname.def $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' + else + _LT_TAGVAR(ld_shlibs, $1)=no + fi + ;; darwin* | rhapsody*) _LT_DARWIN_LINKER_FEATURES($1) ;; @@ -6218,7 +5669,7 @@ esac ;; - freebsd2.*) + freebsd[[12]]*) # C++ shared libraries reported to be fairly broken before # switch to ELF _LT_TAGVAR(ld_shlibs, $1)=no @@ -6237,11 +5688,6 @@ gnu*) ;; - haiku*) - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' - _LT_TAGVAR(link_all_deplibs, $1)=yes - ;; - hpux9*) _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=: @@ -6266,11 +5712,11 @@ # explicitly linking system object files so we need to strip them # from the output so that they don't get included in the library # dependencies. - output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $EGREP "\-L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"' + output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $EGREP "\-L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; $ECHO "X$list" | $Xsed' ;; *) if test "$GXX" = yes; then - _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$CC -shared -nostdlib $pic_flag ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' + _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$CC -shared -nostdlib -fPIC ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' else # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no @@ -6331,7 +5777,7 @@ # explicitly linking system object files so we need to strip them # from the output so that they don't get included in the library # dependencies. - output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $GREP "\-L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"' + output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $GREP "\-L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; $ECHO "X$list" | $Xsed' ;; *) if test "$GXX" = yes; then @@ -6341,10 +5787,10 @@ _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' ;; ia64*) - _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $pic_flag ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' + _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' ;; *) - _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $pic_flag ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' + _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' ;; esac fi @@ -6374,7 +5820,7 @@ case $cc_basename in CC*) # SGI C++ - _LT_TAGVAR(archive_cmds, $1)='$CC -shared -all -multigot $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib' + _LT_TAGVAR(archive_cmds, $1)='$CC -shared -all -multigot $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib' # Archives containing C++ object files must be created using # "CC -ar", where "CC" is the IRIX C++ compiler. This is @@ -6385,9 +5831,9 @@ *) if test "$GXX" = yes; then if test "$with_gnu_ld" = no; then - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' + _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' else - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` -o $lib' + _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` -o $lib' fi fi _LT_TAGVAR(link_all_deplibs, $1)=yes @@ -6398,7 +5844,7 @@ _LT_TAGVAR(inherit_rpath, $1)=yes ;; - linux* | k*bsd*-gnu | kopensolaris*-gnu) + linux* | k*bsd*-gnu) case $cc_basename in KCC*) # Kuck and Associates, Inc. (KAI) C++ Compiler @@ -6416,7 +5862,7 @@ # explicitly linking system object files so we need to strip them # from the output so that they don't get included in the library # dependencies. - output_verbose_link_cmd='templist=`$CC $CFLAGS -v conftest.$objext -o libconftest$shared_ext 2>&1 | $GREP "ld"`; rm -f libconftest$shared_ext; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"' + output_verbose_link_cmd='templist=`$CC $CFLAGS -v conftest.$objext -o libconftest$shared_ext 2>&1 | $GREP "ld"`; rm -f libconftest$shared_ext; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; $ECHO "X$list" | $Xsed' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic' @@ -6453,26 +5899,26 @@ pgCC* | pgcpp*) # Portland Group C++ compiler case `$CC -V` in - *pgCC\ [[1-5]].* | *pgcpp\ [[1-5]].*) + *pgCC\ [[1-5]]* | *pgcpp\ [[1-5]]*) _LT_TAGVAR(prelink_cmds, $1)='tpldir=Template.dir~ rm -rf $tpldir~ $CC --prelink_objects --instantiation_dir $tpldir $objs $libobjs $compile_deplibs~ - compile_command="$compile_command `find $tpldir -name \*.o | sort | $NL2SP`"' + compile_command="$compile_command `find $tpldir -name \*.o | $NL2SP`"' _LT_TAGVAR(old_archive_cmds, $1)='tpldir=Template.dir~ rm -rf $tpldir~ $CC --prelink_objects --instantiation_dir $tpldir $oldobjs$old_deplibs~ - $AR $AR_FLAGS $oldlib$oldobjs$old_deplibs `find $tpldir -name \*.o | sort | $NL2SP`~ + $AR $AR_FLAGS $oldlib$oldobjs$old_deplibs `find $tpldir -name \*.o | $NL2SP`~ $RANLIB $oldlib' _LT_TAGVAR(archive_cmds, $1)='tpldir=Template.dir~ rm -rf $tpldir~ $CC --prelink_objects --instantiation_dir $tpldir $predep_objects $libobjs $deplibs $convenience $postdep_objects~ - $CC -shared $pic_flag $predep_objects $libobjs $deplibs `find $tpldir -name \*.o | sort | $NL2SP` $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname -o $lib' + $CC -shared $pic_flag $predep_objects $libobjs $deplibs `find $tpldir -name \*.o | $NL2SP` $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='tpldir=Template.dir~ rm -rf $tpldir~ $CC --prelink_objects --instantiation_dir $tpldir $predep_objects $libobjs $deplibs $convenience $postdep_objects~ - $CC -shared $pic_flag $predep_objects $libobjs $deplibs `find $tpldir -name \*.o | sort | $NL2SP` $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname ${wl}-retain-symbols-file ${wl}$export_symbols -o $lib' + $CC -shared $pic_flag $predep_objects $libobjs $deplibs `find $tpldir -name \*.o | $NL2SP` $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname ${wl}-retain-symbols-file ${wl}$export_symbols -o $lib' ;; - *) # Version 6 and above use weak symbols + *) # Version 6 will use weak symbols _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname ${wl}-retain-symbols-file ${wl}$export_symbols -o $lib' ;; @@ -6480,7 +5926,7 @@ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}--rpath ${wl}$libdir' _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic' - _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive' + _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $ECHO \"$new_convenience\"` ${wl}--no-whole-archive' ;; cxx*) # Compaq C++ @@ -6499,9 +5945,9 @@ # explicitly linking system object files so we need to strip them # from the output so that they don't get included in the library # dependencies. - output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "ld"`; templist=`func_echo_all "$templist" | $SED "s/\(^.*ld.*\)\( .*ld .*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "X$list" | $Xsed' + output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "ld"`; templist=`$ECHO "X$templist" | $Xsed -e "s/\(^.*ld.*\)\( .*ld .*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; $ECHO "X$list" | $Xsed' ;; - xl* | mpixl* | bgxl*) + xl*) # IBM XL 8.0 on PPC, with GNU ld _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic' @@ -6521,13 +5967,13 @@ _LT_TAGVAR(archive_cmds, $1)='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-retain-symbols-file ${wl}$export_symbols' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' - _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive' + _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; $ECHO \"$new_convenience\"` ${wl}--no-whole-archive' _LT_TAGVAR(compiler_needs_object, $1)=yes # Not sure whether something based on # $CC $CFLAGS -v conftest.$objext -o libconftest$shared_ext 2>&1 # would be better. - output_verbose_link_cmd='func_echo_all' + output_verbose_link_cmd='echo' # Archives containing C++ object files must be created using # "CC -xar", where "CC" is the Sun C++ compiler. This is @@ -6596,7 +6042,7 @@ _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' _LT_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive' fi - output_verbose_link_cmd=func_echo_all + output_verbose_link_cmd=echo else _LT_TAGVAR(ld_shlibs, $1)=no fi @@ -6631,15 +6077,15 @@ case $host in osf3*) _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*' - _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $soname `test -n "$verstring" && func_echo_all "${wl}-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib' + _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $soname `test -n "$verstring" && $ECHO "X${wl}-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' ;; *) _LT_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*' - _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib' + _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done~ echo "-hidden">> $lib.exp~ - $CC -shared$allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname ${wl}-input ${wl}$lib.exp `test -n "$verstring" && $ECHO "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib~ + $CC -shared$allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname ${wl}-input ${wl}$lib.exp `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib~ $RM $lib.exp' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir' ;; @@ -6655,17 +6101,17 @@ # explicitly linking system object files so we need to strip them # from the output so that they don't get included in the library # dependencies. - output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "ld" | $GREP -v "ld:"`; templist=`func_echo_all "$templist" | $SED "s/\(^.*ld.*\)\( .*ld.*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"' + output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "ld" | $GREP -v "ld:"`; templist=`$ECHO "X$templist" | $Xsed -e "s/\(^.*ld.*\)\( .*ld.*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; $ECHO "X$list" | $Xsed' ;; *) if test "$GXX" = yes && test "$with_gnu_ld" = no; then _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*' case $host in osf3*) - _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' + _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' ;; *) - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' + _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' ;; esac @@ -6675,7 +6121,7 @@ # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. - output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"' + output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "\-L"' else # FIXME: insert proper C++ library support @@ -6711,7 +6157,7 @@ solaris*) case $cc_basename in - CC* | sunCC*) + CC*) # Sun C++ 4.2, 5.x and Centerline C++ _LT_TAGVAR(archive_cmds_need_lc,$1)=yes _LT_TAGVAR(no_undefined_flag, $1)=' -zdefs' @@ -6732,7 +6178,7 @@ esac _LT_TAGVAR(link_all_deplibs, $1)=yes - output_verbose_link_cmd='func_echo_all' + output_verbose_link_cmd='echo' # Archives containing C++ object files must be created using # "CC -xar", where "CC" is the Sun C++ compiler. This is @@ -6752,14 +6198,14 @@ if test "$GXX" = yes && test "$with_gnu_ld" = no; then _LT_TAGVAR(no_undefined_flag, $1)=' ${wl}-z ${wl}defs' if $CC --version | $GREP -v '^2\.7' > /dev/null; then - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib' + _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ - $CC -shared $pic_flag -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp' + $CC -shared -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp' # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. - output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"' + output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "\-L"' else # g++ 2.7 appears to require `-G' NOT `-shared' on this # platform. @@ -6770,7 +6216,7 @@ # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. - output_verbose_link_cmd='$CC -G $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"' + output_verbose_link_cmd='$CC -G $CFLAGS -v conftest.$objext 2>&1 | $GREP "\-L"' fi _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $wl$libdir' @@ -6824,10 +6270,6 @@ CC*) _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' - _LT_TAGVAR(old_archive_cmds, $1)='$CC -Tprelink_objects $oldobjs~ - '"$_LT_TAGVAR(old_archive_cmds, $1)" - _LT_TAGVAR(reload_cmds, $1)='$CC -Tprelink_objects $reload_objs~ - '"$_LT_TAGVAR(reload_cmds, $1)" ;; *) _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' @@ -6883,7 +6325,6 @@ fi # test -n "$compiler" CC=$lt_save_CC - CFLAGS=$lt_save_CFLAGS LDCXX=$LD LD=$lt_save_LD GCC=$lt_save_GCC @@ -6898,29 +6339,6 @@ ])# _LT_LANG_CXX_CONFIG -# _LT_FUNC_STRIPNAME_CNF -# ---------------------- -# func_stripname_cnf prefix suffix name -# strip PREFIX and SUFFIX off of NAME. -# PREFIX and SUFFIX must not contain globbing or regex special -# characters, hashes, percent signs, but SUFFIX may contain a leading -# dot (in which case that matches only a dot). -# -# This function is identical to the (non-XSI) version of func_stripname, -# except this one can be used by m4 code that may be executed by configure, -# rather than the libtool script. -m4_defun([_LT_FUNC_STRIPNAME_CNF],[dnl -AC_REQUIRE([_LT_DECL_SED]) -AC_REQUIRE([_LT_PROG_ECHO_BACKSLASH]) -func_stripname_cnf () -{ - case ${2} in - .*) func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%\\\\${2}\$%%"`;; - *) func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%${2}\$%%"`;; - esac -} # func_stripname_cnf -])# _LT_FUNC_STRIPNAME_CNF - # _LT_SYS_HIDDEN_LIBDEPS([TAGNAME]) # --------------------------------- # Figure out "hidden" library dependencies from verbose @@ -6929,7 +6347,6 @@ # objects, libraries and library flags. m4_defun([_LT_SYS_HIDDEN_LIBDEPS], [m4_require([_LT_FILEUTILS_DEFAULTS])dnl -AC_REQUIRE([_LT_FUNC_STRIPNAME_CNF])dnl # Dependencies to place before and after the object being linked: _LT_TAGVAR(predep_objects, $1)= _LT_TAGVAR(postdep_objects, $1)= @@ -6979,20 +6396,7 @@ } }; _LT_EOF -], [$1], [GO], [cat > conftest.$ac_ext <<_LT_EOF -package foo -func foo() { -} -_LT_EOF ]) - -_lt_libdeps_save_CFLAGS=$CFLAGS -case "$CC $CFLAGS " in #( -*\ -flto*\ *) CFLAGS="$CFLAGS -fno-lto" ;; -*\ -fwhopr*\ *) CFLAGS="$CFLAGS -fno-whopr" ;; -*\ -fuse-linker-plugin*\ *) CFLAGS="$CFLAGS -fno-use-linker-plugin" ;; -esac - dnl Parse the compiler output and extract the necessary dnl objects, libraries and library flags. if AC_TRY_EVAL(ac_compile); then @@ -7004,7 +6408,7 @@ pre_test_object_deps_done=no for p in `eval "$output_verbose_link_cmd"`; do - case ${prev}${p} in + case $p in -L* | -R* | -l*) # Some compilers place space between "-{L,R}" and the path. @@ -7013,22 +6417,13 @@ test $p = "-R"; then prev=$p continue + else + prev= fi - # Expand the sysroot to ease extracting the directories later. - if test -z "$prev"; then - case $p in - -L*) func_stripname_cnf '-L' '' "$p"; prev=-L; p=$func_stripname_result ;; - -R*) func_stripname_cnf '-R' '' "$p"; prev=-R; p=$func_stripname_result ;; - -l*) func_stripname_cnf '-l' '' "$p"; prev=-l; p=$func_stripname_result ;; - esac - fi - case $p in - =*) func_stripname_cnf '=' '' "$p"; p=$lt_sysroot$func_stripname_result ;; - esac if test "$pre_test_object_deps_done" = no; then - case ${prev} in - -L | -R) + case $p in + -L* | -R*) # Internal compiler library paths should come after those # provided the user. The postdeps already come after the # user supplied libs so there is no need to process them. @@ -7048,10 +6443,8 @@ _LT_TAGVAR(postdeps, $1)="${_LT_TAGVAR(postdeps, $1)} ${prev}${p}" fi fi - prev= ;; - *.lto.$objext) ;; # Ignore GCC LTO objects *.$objext) # This assumes that the test object file only shows up # once in the compiler output. @@ -7087,7 +6480,6 @@ fi $RM -f confest.$objext -CFLAGS=$_lt_libdeps_save_CFLAGS # PORTME: override above test on systems where it is broken m4_if([$1], [CXX], @@ -7124,7 +6516,7 @@ solaris*) case $cc_basename in - CC* | sunCC*) + CC*) # The more standards-conforming stlport4 library is # incompatible with the Cstd library. Avoid specifying # it if it's in CXXFLAGS. Ignore libCrun as @@ -7168,16 +6560,32 @@ ])# _LT_SYS_HIDDEN_LIBDEPS +# _LT_PROG_F77 +# ------------ +# Since AC_PROG_F77 is broken, in that it returns the empty string +# if there is no fortran compiler, we have our own version here. +m4_defun([_LT_PROG_F77], +[ +pushdef([AC_MSG_ERROR], [_lt_disable_F77=yes]) +AC_PROG_F77 +if test -z "$F77" || test "X$F77" = "Xno"; then + _lt_disable_F77=yes +fi +popdef([AC_MSG_ERROR]) +])# _LT_PROG_F77 + +dnl aclocal-1.4 backwards compatibility: +dnl AC_DEFUN([_LT_PROG_F77], []) + + # _LT_LANG_F77_CONFIG([TAG]) # -------------------------- # Ensure that the configuration variables for a Fortran 77 compiler are # suitably defined. These variables are subsequently used by _LT_CONFIG # to write the compiler configuration to `libtool'. m4_defun([_LT_LANG_F77_CONFIG], -[AC_LANG_PUSH(Fortran 77) -if test -z "$F77" || test "X$F77" = "Xno"; then - _lt_disable_F77=yes -fi +[AC_REQUIRE([_LT_PROG_F77])dnl +AC_LANG_PUSH(Fortran 77) _LT_TAGVAR(archive_cmds_need_lc, $1)=no _LT_TAGVAR(allow_undefined_flag, $1)= @@ -7187,6 +6595,7 @@ _LT_TAGVAR(hardcode_direct, $1)=no _LT_TAGVAR(hardcode_direct_absolute, $1)=no _LT_TAGVAR(hardcode_libdir_flag_spec, $1)= +_LT_TAGVAR(hardcode_libdir_flag_spec_ld, $1)= _LT_TAGVAR(hardcode_libdir_separator, $1)= _LT_TAGVAR(hardcode_minus_L, $1)=no _LT_TAGVAR(hardcode_automatic, $1)=no @@ -7195,8 +6604,6 @@ _LT_TAGVAR(module_expsym_cmds, $1)= _LT_TAGVAR(link_all_deplibs, $1)=unknown _LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds -_LT_TAGVAR(reload_flag, $1)=$reload_flag -_LT_TAGVAR(reload_cmds, $1)=$reload_cmds _LT_TAGVAR(no_undefined_flag, $1)= _LT_TAGVAR(whole_archive_flag_spec, $1)= _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no @@ -7236,9 +6643,7 @@ # Allow CC to be a program name with arguments. lt_save_CC="$CC" lt_save_GCC=$GCC - lt_save_CFLAGS=$CFLAGS CC=${F77-"f77"} - CFLAGS=$FFLAGS compiler=$CC _LT_TAGVAR(compiler, $1)=$CC _LT_CC_BASENAME([$compiler]) @@ -7292,24 +6697,38 @@ GCC=$lt_save_GCC CC="$lt_save_CC" - CFLAGS="$lt_save_CFLAGS" fi # test "$_lt_disable_F77" != yes AC_LANG_POP ])# _LT_LANG_F77_CONFIG +# _LT_PROG_FC +# ----------- +# Since AC_PROG_FC is broken, in that it returns the empty string +# if there is no fortran compiler, we have our own version here. +m4_defun([_LT_PROG_FC], +[ +pushdef([AC_MSG_ERROR], [_lt_disable_FC=yes]) +AC_PROG_FC +if test -z "$FC" || test "X$FC" = "Xno"; then + _lt_disable_FC=yes +fi +popdef([AC_MSG_ERROR]) +])# _LT_PROG_FC + +dnl aclocal-1.4 backwards compatibility: +dnl AC_DEFUN([_LT_PROG_FC], []) + + # _LT_LANG_FC_CONFIG([TAG]) # ------------------------- # Ensure that the configuration variables for a Fortran compiler are # suitably defined. These variables are subsequently used by _LT_CONFIG # to write the compiler configuration to `libtool'. m4_defun([_LT_LANG_FC_CONFIG], -[AC_LANG_PUSH(Fortran) - -if test -z "$FC" || test "X$FC" = "Xno"; then - _lt_disable_FC=yes -fi +[AC_REQUIRE([_LT_PROG_FC])dnl +AC_LANG_PUSH(Fortran) _LT_TAGVAR(archive_cmds_need_lc, $1)=no _LT_TAGVAR(allow_undefined_flag, $1)= @@ -7319,6 +6738,7 @@ _LT_TAGVAR(hardcode_direct, $1)=no _LT_TAGVAR(hardcode_direct_absolute, $1)=no _LT_TAGVAR(hardcode_libdir_flag_spec, $1)= +_LT_TAGVAR(hardcode_libdir_flag_spec_ld, $1)= _LT_TAGVAR(hardcode_libdir_separator, $1)= _LT_TAGVAR(hardcode_minus_L, $1)=no _LT_TAGVAR(hardcode_automatic, $1)=no @@ -7327,8 +6747,6 @@ _LT_TAGVAR(module_expsym_cmds, $1)= _LT_TAGVAR(link_all_deplibs, $1)=unknown _LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds -_LT_TAGVAR(reload_flag, $1)=$reload_flag -_LT_TAGVAR(reload_cmds, $1)=$reload_cmds _LT_TAGVAR(no_undefined_flag, $1)= _LT_TAGVAR(whole_archive_flag_spec, $1)= _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no @@ -7368,9 +6786,7 @@ # Allow CC to be a program name with arguments. lt_save_CC="$CC" lt_save_GCC=$GCC - lt_save_CFLAGS=$CFLAGS CC=${FC-"f95"} - CFLAGS=$FCFLAGS compiler=$CC GCC=$ac_cv_fc_compiler_gnu @@ -7426,8 +6842,7 @@ fi # test -n "$compiler" GCC=$lt_save_GCC - CC=$lt_save_CC - CFLAGS=$lt_save_CFLAGS + CC="$lt_save_CC" fi # test "$_lt_disable_FC" != yes AC_LANG_POP @@ -7464,12 +6879,10 @@ _LT_LINKER_BOILERPLATE # Allow CC to be a program name with arguments. -lt_save_CC=$CC -lt_save_CFLAGS=$CFLAGS +lt_save_CC="$CC" lt_save_GCC=$GCC GCC=yes CC=${GCJ-"gcj"} -CFLAGS=$GCJFLAGS compiler=$CC _LT_TAGVAR(compiler, $1)=$CC _LT_TAGVAR(LD, $1)="$LD" @@ -7479,8 +6892,6 @@ _LT_TAGVAR(archive_cmds_need_lc, $1)=no _LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds -_LT_TAGVAR(reload_flag, $1)=$reload_flag -_LT_TAGVAR(reload_cmds, $1)=$reload_cmds ## CAVEAT EMPTOR: ## There is no encapsulation within the following macros, do not change @@ -7500,82 +6911,10 @@ AC_LANG_RESTORE GCC=$lt_save_GCC -CC=$lt_save_CC -CFLAGS=$lt_save_CFLAGS +CC="$lt_save_CC" ])# _LT_LANG_GCJ_CONFIG -# _LT_LANG_GO_CONFIG([TAG]) -# -------------------------- -# Ensure that the configuration variables for the GNU Go compiler -# are suitably defined. These variables are subsequently used by _LT_CONFIG -# to write the compiler configuration to `libtool'. -m4_defun([_LT_LANG_GO_CONFIG], -[AC_REQUIRE([LT_PROG_GO])dnl -AC_LANG_SAVE - -# Source file extension for Go test sources. -ac_ext=go - -# Object file extension for compiled Go test sources. -objext=o -_LT_TAGVAR(objext, $1)=$objext - -# Code to be used in simple compile tests -lt_simple_compile_test_code="package main; func main() { }" - -# Code to be used in simple link tests -lt_simple_link_test_code='package main; func main() { }' - -# ltmain only uses $CC for tagged configurations so make sure $CC is set. -_LT_TAG_COMPILER - -# save warnings/boilerplate of simple test code -_LT_COMPILER_BOILERPLATE -_LT_LINKER_BOILERPLATE - -# Allow CC to be a program name with arguments. -lt_save_CC=$CC -lt_save_CFLAGS=$CFLAGS -lt_save_GCC=$GCC -GCC=yes -CC=${GOC-"gccgo"} -CFLAGS=$GOFLAGS -compiler=$CC -_LT_TAGVAR(compiler, $1)=$CC -_LT_TAGVAR(LD, $1)="$LD" -_LT_CC_BASENAME([$compiler]) - -# Go did not exist at the time GCC didn't implicitly link libc in. -_LT_TAGVAR(archive_cmds_need_lc, $1)=no - -_LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds -_LT_TAGVAR(reload_flag, $1)=$reload_flag -_LT_TAGVAR(reload_cmds, $1)=$reload_cmds - -## CAVEAT EMPTOR: -## There is no encapsulation within the following macros, do not change -## the running order or otherwise move them around unless you know exactly -## what you are doing... -if test -n "$compiler"; then - _LT_COMPILER_NO_RTTI($1) - _LT_COMPILER_PIC($1) - _LT_COMPILER_C_O($1) - _LT_COMPILER_FILE_LOCKS($1) - _LT_LINKER_SHLIBS($1) - _LT_LINKER_HARDCODE_LIBPATH($1) - - _LT_CONFIG($1) -fi - -AC_LANG_RESTORE - -GCC=$lt_save_GCC -CC=$lt_save_CC -CFLAGS=$lt_save_CFLAGS -])# _LT_LANG_GO_CONFIG - - # _LT_LANG_RC_CONFIG([TAG]) # ------------------------- # Ensure that the configuration variables for the Windows resource compiler @@ -7607,11 +6946,9 @@ # Allow CC to be a program name with arguments. lt_save_CC="$CC" -lt_save_CFLAGS=$CFLAGS lt_save_GCC=$GCC GCC= CC=${RC-"windres"} -CFLAGS= compiler=$CC _LT_TAGVAR(compiler, $1)=$CC _LT_CC_BASENAME([$compiler]) @@ -7624,8 +6961,7 @@ GCC=$lt_save_GCC AC_LANG_RESTORE -CC=$lt_save_CC -CFLAGS=$lt_save_CFLAGS +CC="$lt_save_CC" ])# _LT_LANG_RC_CONFIG @@ -7645,13 +6981,6 @@ dnl AC_DEFUN([LT_AC_PROG_GCJ], []) -# LT_PROG_GO -# ---------- -AC_DEFUN([LT_PROG_GO], -[AC_CHECK_TOOL(GOC, gccgo,) -]) - - # LT_PROG_RC # ---------- AC_DEFUN([LT_PROG_RC], @@ -7691,15 +7020,6 @@ AC_SUBST([OBJDUMP]) ]) -# _LT_DECL_DLLTOOL -# ---------------- -# Ensure DLLTOOL variable is set. -m4_defun([_LT_DECL_DLLTOOL], -[AC_CHECK_TOOL(DLLTOOL, dlltool, false) -test -z "$DLLTOOL" && DLLTOOL=dlltool -_LT_DECL([], [DLLTOOL], [1], [DLL creation program]) -AC_SUBST([DLLTOOL]) -]) # _LT_DECL_SED # ------------ @@ -7793,8 +7113,8 @@ # Try some XSI features xsi_shell=no ( _lt_dummy="a/b/c" - test "${_lt_dummy##*/},${_lt_dummy%/*},${_lt_dummy#??}"${_lt_dummy%"$_lt_dummy"}, \ - = c,a/b,b/c, \ + test "${_lt_dummy##*/},${_lt_dummy%/*},"${_lt_dummy%"$_lt_dummy"}, \ + = c,a/b,, \ && eval 'test $(( 1 + 1 )) -eq 2 \ && test "${#_lt_dummy}" -eq 5' ) >/dev/null 2>&1 \ && xsi_shell=yes @@ -7833,162 +7153,208 @@ ])# _LT_CHECK_SHELL_FEATURES -# _LT_PROG_FUNCTION_REPLACE (FUNCNAME, REPLACEMENT-BODY) -# ------------------------------------------------------ -# In `$cfgfile', look for function FUNCNAME delimited by `^FUNCNAME ()$' and -# '^} FUNCNAME ', and replace its body with REPLACEMENT-BODY. -m4_defun([_LT_PROG_FUNCTION_REPLACE], -[dnl { -sed -e '/^$1 ()$/,/^} # $1 /c\ -$1 ()\ -{\ -m4_bpatsubsts([$2], [$], [\\], [^\([ ]\)], [\\\1]) -} # Extended-shell $1 implementation' "$cfgfile" > $cfgfile.tmp \ - && mv -f "$cfgfile.tmp" "$cfgfile" \ - || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") -test 0 -eq $? || _lt_function_replace_fail=: +# _LT_PROG_XSI_SHELLFNS +# --------------------- +# Bourne and XSI compatible variants of some useful shell functions. +m4_defun([_LT_PROG_XSI_SHELLFNS], +[case $xsi_shell in + yes) + cat << \_LT_EOF >> "$cfgfile" + +# func_dirname file append nondir_replacement +# Compute the dirname of FILE. If nonempty, add APPEND to the result, +# otherwise set result to NONDIR_REPLACEMENT. +func_dirname () +{ + case ${1} in + */*) func_dirname_result="${1%/*}${2}" ;; + * ) func_dirname_result="${3}" ;; + esac +} + +# func_basename file +func_basename () +{ + func_basename_result="${1##*/}" +} + +# func_dirname_and_basename file append nondir_replacement +# perform func_basename and func_dirname in a single function +# call: +# dirname: Compute the dirname of FILE. If nonempty, +# add APPEND to the result, otherwise set result +# to NONDIR_REPLACEMENT. +# value returned in "$func_dirname_result" +# basename: Compute filename of FILE. +# value retuned in "$func_basename_result" +# Implementation must be kept synchronized with func_dirname +# and func_basename. For efficiency, we do not delegate to +# those functions but instead duplicate the functionality here. +func_dirname_and_basename () +{ + case ${1} in + */*) func_dirname_result="${1%/*}${2}" ;; + * ) func_dirname_result="${3}" ;; + esac + func_basename_result="${1##*/}" +} + +# func_stripname prefix suffix name +# strip PREFIX and SUFFIX off of NAME. +# PREFIX and SUFFIX must not contain globbing or regex special +# characters, hashes, percent signs, but SUFFIX may contain a leading +# dot (in which case that matches only a dot). +func_stripname () +{ + # pdksh 5.2.14 does not do ${X%$Y} correctly if both X and Y are + # positional parameters, so assign one to ordinary parameter first. + func_stripname_result=${3} + func_stripname_result=${func_stripname_result#"${1}"} + func_stripname_result=${func_stripname_result%"${2}"} +} + +# func_opt_split +func_opt_split () +{ + func_opt_split_opt=${1%%=*} + func_opt_split_arg=${1#*=} +} + +# func_lo2o object +func_lo2o () +{ + case ${1} in + *.lo) func_lo2o_result=${1%.lo}.${objext} ;; + *) func_lo2o_result=${1} ;; + esac +} + +# func_xform libobj-or-source +func_xform () +{ + func_xform_result=${1%.*}.lo +} + +# func_arith arithmetic-term... +func_arith () +{ + func_arith_result=$(( $[*] )) +} + +# func_len string +# STRING may not start with a hyphen. +func_len () +{ + func_len_result=${#1} +} + +_LT_EOF + ;; + *) # Bourne compatible functions. + cat << \_LT_EOF >> "$cfgfile" + +# func_dirname file append nondir_replacement +# Compute the dirname of FILE. If nonempty, add APPEND to the result, +# otherwise set result to NONDIR_REPLACEMENT. +func_dirname () +{ + # Extract subdirectory from the argument. + func_dirname_result=`$ECHO "X${1}" | $Xsed -e "$dirname"` + if test "X$func_dirname_result" = "X${1}"; then + func_dirname_result="${3}" + else + func_dirname_result="$func_dirname_result${2}" + fi +} + +# func_basename file +func_basename () +{ + func_basename_result=`$ECHO "X${1}" | $Xsed -e "$basename"` +} + +dnl func_dirname_and_basename +dnl A portable version of this function is already defined in general.m4sh +dnl so there is no need for it here. + +# func_stripname prefix suffix name +# strip PREFIX and SUFFIX off of NAME. +# PREFIX and SUFFIX must not contain globbing or regex special +# characters, hashes, percent signs, but SUFFIX may contain a leading +# dot (in which case that matches only a dot). +# func_strip_suffix prefix name +func_stripname () +{ + case ${2} in + .*) func_stripname_result=`$ECHO "X${3}" \ + | $Xsed -e "s%^${1}%%" -e "s%\\\\${2}\$%%"`;; + *) func_stripname_result=`$ECHO "X${3}" \ + | $Xsed -e "s%^${1}%%" -e "s%${2}\$%%"`;; + esac +} + +# sed scripts: +my_sed_long_opt='1s/^\(-[[^=]]*\)=.*/\1/;q' +my_sed_long_arg='1s/^-[[^=]]*=//' + +# func_opt_split +func_opt_split () +{ + func_opt_split_opt=`$ECHO "X${1}" | $Xsed -e "$my_sed_long_opt"` + func_opt_split_arg=`$ECHO "X${1}" | $Xsed -e "$my_sed_long_arg"` +} + +# func_lo2o object +func_lo2o () +{ + func_lo2o_result=`$ECHO "X${1}" | $Xsed -e "$lo2o"` +} + +# func_xform libobj-or-source +func_xform () +{ + func_xform_result=`$ECHO "X${1}" | $Xsed -e 's/\.[[^.]]*$/.lo/'` +} + +# func_arith arithmetic-term... +func_arith () +{ + func_arith_result=`expr "$[@]"` +} + +# func_len string +# STRING may not start with a hyphen. +func_len () +{ + func_len_result=`expr "$[1]" : ".*" 2>/dev/null || echo $max_cmd_len` +} + +_LT_EOF +esac + +case $lt_shell_append in + yes) + cat << \_LT_EOF >> "$cfgfile" + +# func_append var value +# Append VALUE to the end of shell variable VAR. +func_append () +{ + eval "$[1]+=\$[2]" +} +_LT_EOF + ;; + *) + cat << \_LT_EOF >> "$cfgfile" + +# func_append var value +# Append VALUE to the end of shell variable VAR. +func_append () +{ + eval "$[1]=\$$[1]\$[2]" +} + +_LT_EOF + ;; + esac ]) - - -# _LT_PROG_REPLACE_SHELLFNS -# ------------------------- -# Replace existing portable implementations of several shell functions with -# equivalent extended shell implementations where those features are available.. -m4_defun([_LT_PROG_REPLACE_SHELLFNS], -[if test x"$xsi_shell" = xyes; then - _LT_PROG_FUNCTION_REPLACE([func_dirname], [dnl - case ${1} in - */*) func_dirname_result="${1%/*}${2}" ;; - * ) func_dirname_result="${3}" ;; - esac]) - - _LT_PROG_FUNCTION_REPLACE([func_basename], [dnl - func_basename_result="${1##*/}"]) - - _LT_PROG_FUNCTION_REPLACE([func_dirname_and_basename], [dnl - case ${1} in - */*) func_dirname_result="${1%/*}${2}" ;; - * ) func_dirname_result="${3}" ;; - esac - func_basename_result="${1##*/}"]) - - _LT_PROG_FUNCTION_REPLACE([func_stripname], [dnl - # pdksh 5.2.14 does not do ${X%$Y} correctly if both X and Y are - # positional parameters, so assign one to ordinary parameter first. - func_stripname_result=${3} - func_stripname_result=${func_stripname_result#"${1}"} - func_stripname_result=${func_stripname_result%"${2}"}]) - - _LT_PROG_FUNCTION_REPLACE([func_split_long_opt], [dnl - func_split_long_opt_name=${1%%=*} - func_split_long_opt_arg=${1#*=}]) - - _LT_PROG_FUNCTION_REPLACE([func_split_short_opt], [dnl - func_split_short_opt_arg=${1#??} - func_split_short_opt_name=${1%"$func_split_short_opt_arg"}]) - - _LT_PROG_FUNCTION_REPLACE([func_lo2o], [dnl - case ${1} in - *.lo) func_lo2o_result=${1%.lo}.${objext} ;; - *) func_lo2o_result=${1} ;; - esac]) - - _LT_PROG_FUNCTION_REPLACE([func_xform], [ func_xform_result=${1%.*}.lo]) - - _LT_PROG_FUNCTION_REPLACE([func_arith], [ func_arith_result=$(( $[*] ))]) - - _LT_PROG_FUNCTION_REPLACE([func_len], [ func_len_result=${#1}]) -fi - -if test x"$lt_shell_append" = xyes; then - _LT_PROG_FUNCTION_REPLACE([func_append], [ eval "${1}+=\\${2}"]) - - _LT_PROG_FUNCTION_REPLACE([func_append_quoted], [dnl - func_quote_for_eval "${2}" -dnl m4 expansion turns \\\\ into \\, and then the shell eval turns that into \ - eval "${1}+=\\\\ \\$func_quote_for_eval_result"]) - - # Save a `func_append' function call where possible by direct use of '+=' - sed -e 's%func_append \([[a-zA-Z_]]\{1,\}\) "%\1+="%g' $cfgfile > $cfgfile.tmp \ - && mv -f "$cfgfile.tmp" "$cfgfile" \ - || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") - test 0 -eq $? || _lt_function_replace_fail=: -else - # Save a `func_append' function call even when '+=' is not available - sed -e 's%func_append \([[a-zA-Z_]]\{1,\}\) "%\1="$\1%g' $cfgfile > $cfgfile.tmp \ - && mv -f "$cfgfile.tmp" "$cfgfile" \ - || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") - test 0 -eq $? || _lt_function_replace_fail=: -fi - -if test x"$_lt_function_replace_fail" = x":"; then - AC_MSG_WARN([Unable to substitute extended shell functions in $ofile]) -fi -]) - -# _LT_PATH_CONVERSION_FUNCTIONS -# ----------------------------- -# Determine which file name conversion functions should be used by -# func_to_host_file (and, implicitly, by func_to_host_path). These are needed -# for certain cross-compile configurations and native mingw. -m4_defun([_LT_PATH_CONVERSION_FUNCTIONS], -[AC_REQUIRE([AC_CANONICAL_HOST])dnl -AC_REQUIRE([AC_CANONICAL_BUILD])dnl -AC_MSG_CHECKING([how to convert $build file names to $host format]) -AC_CACHE_VAL(lt_cv_to_host_file_cmd, -[case $host in - *-*-mingw* ) - case $build in - *-*-mingw* ) # actually msys - lt_cv_to_host_file_cmd=func_convert_file_msys_to_w32 - ;; - *-*-cygwin* ) - lt_cv_to_host_file_cmd=func_convert_file_cygwin_to_w32 - ;; - * ) # otherwise, assume *nix - lt_cv_to_host_file_cmd=func_convert_file_nix_to_w32 - ;; - esac - ;; - *-*-cygwin* ) - case $build in - *-*-mingw* ) # actually msys - lt_cv_to_host_file_cmd=func_convert_file_msys_to_cygwin - ;; - *-*-cygwin* ) - lt_cv_to_host_file_cmd=func_convert_file_noop - ;; - * ) # otherwise, assume *nix - lt_cv_to_host_file_cmd=func_convert_file_nix_to_cygwin - ;; - esac - ;; - * ) # unhandled hosts (and "normal" native builds) - lt_cv_to_host_file_cmd=func_convert_file_noop - ;; -esac -]) -to_host_file_cmd=$lt_cv_to_host_file_cmd -AC_MSG_RESULT([$lt_cv_to_host_file_cmd]) -_LT_DECL([to_host_file_cmd], [lt_cv_to_host_file_cmd], - [0], [convert $build file names to $host format])dnl - -AC_MSG_CHECKING([how to convert $build file names to toolchain format]) -AC_CACHE_VAL(lt_cv_to_tool_file_cmd, -[#assume ordinary cross tools, or native build. -lt_cv_to_tool_file_cmd=func_convert_file_noop -case $host in - *-*-mingw* ) - case $build in - *-*-mingw* ) # actually msys - lt_cv_to_tool_file_cmd=func_convert_file_msys_to_w32 - ;; - esac - ;; -esac -]) -to_tool_file_cmd=$lt_cv_to_tool_file_cmd -AC_MSG_RESULT([$lt_cv_to_tool_file_cmd]) -_LT_DECL([to_tool_file_cmd], [lt_cv_to_tool_file_cmd], - [0], [convert $build files to toolchain format])dnl -])# _LT_PATH_CONVERSION_FUNCTIONS diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi/m4/ltoptions.m4 --- a/Modules/_ctypes/libffi/m4/ltoptions.m4 Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/_ctypes/libffi/m4/ltoptions.m4 Sun Jul 20 10:52:46 2014 -0400 @@ -1,14 +1,13 @@ # Helper functions for option handling. -*- Autoconf -*- # -# Copyright (C) 2004, 2005, 2007, 2008, 2009 Free Software Foundation, -# Inc. +# Copyright (C) 2004, 2005, 2007, 2008 Free Software Foundation, Inc. # Written by Gary V. Vaughan, 2004 # # This file is free software; the Free Software Foundation gives # unlimited permission to copy and/or distribute it, with or without # modifications, as long as this notice is preserved. -# serial 7 ltoptions.m4 +# serial 6 ltoptions.m4 # This is to help aclocal find these macros, as it can't see m4_define. AC_DEFUN([LTOPTIONS_VERSION], [m4_if([1])]) @@ -126,7 +125,7 @@ [enable_win32_dll=yes case $host in -*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-cegcc*) +*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-cegcc*) AC_CHECK_TOOL(AS, as, false) AC_CHECK_TOOL(DLLTOOL, dlltool, false) AC_CHECK_TOOL(OBJDUMP, objdump, false) @@ -134,13 +133,13 @@ esac test -z "$AS" && AS=as -_LT_DECL([], [AS], [1], [Assembler program])dnl +_LT_DECL([], [AS], [0], [Assembler program])dnl test -z "$DLLTOOL" && DLLTOOL=dlltool -_LT_DECL([], [DLLTOOL], [1], [DLL creation program])dnl +_LT_DECL([], [DLLTOOL], [0], [DLL creation program])dnl test -z "$OBJDUMP" && OBJDUMP=objdump -_LT_DECL([], [OBJDUMP], [1], [Object dumper program])dnl +_LT_DECL([], [OBJDUMP], [0], [Object dumper program])dnl ])# win32-dll AU_DEFUN([AC_LIBTOOL_WIN32_DLL], @@ -326,24 +325,9 @@ # MODE is either `yes' or `no'. If omitted, it defaults to `both'. m4_define([_LT_WITH_PIC], [AC_ARG_WITH([pic], - [AS_HELP_STRING([--with-pic@<:@=PKGS@:>@], + [AS_HELP_STRING([--with-pic], [try to use only PIC/non-PIC objects @<:@default=use both@:>@])], - [lt_p=${PACKAGE-default} - case $withval in - yes|no) pic_mode=$withval ;; - *) - pic_mode=default - # Look at the argument we got. We use all the common list separators. - lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," - for lt_pkg in $withval; do - IFS="$lt_save_ifs" - if test "X$lt_pkg" = "X$lt_p"; then - pic_mode=yes - fi - done - IFS="$lt_save_ifs" - ;; - esac], + [pic_mode="$withval"], [pic_mode=default]) test -z "$pic_mode" && pic_mode=m4_default([$1], [default]) diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi/m4/ltversion.m4 --- a/Modules/_ctypes/libffi/m4/ltversion.m4 Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/_ctypes/libffi/m4/ltversion.m4 Sun Jul 20 10:52:46 2014 -0400 @@ -7,17 +7,17 @@ # unlimited permission to copy and/or distribute it, with or without # modifications, as long as this notice is preserved. -# @configure_input@ +# Generated from ltversion.in. -# serial 3337 ltversion.m4 +# serial 3012 ltversion.m4 # This file is part of GNU Libtool -m4_define([LT_PACKAGE_VERSION], [2.4.2]) -m4_define([LT_PACKAGE_REVISION], [1.3337]) +m4_define([LT_PACKAGE_VERSION], [2.2.6]) +m4_define([LT_PACKAGE_REVISION], [1.3012]) AC_DEFUN([LTVERSION_VERSION], -[macro_version='2.4.2' -macro_revision='1.3337' +[macro_version='2.2.6' +macro_revision='1.3012' _LT_DECL(, macro_version, 0, [Which release of libtool.m4 was used?]) _LT_DECL(, macro_revision, 0) ]) diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi/m4/lt~obsolete.m4 --- a/Modules/_ctypes/libffi/m4/lt~obsolete.m4 Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/_ctypes/libffi/m4/lt~obsolete.m4 Sun Jul 20 10:52:46 2014 -0400 @@ -1,13 +1,13 @@ # lt~obsolete.m4 -- aclocal satisfying obsolete definitions. -*-Autoconf-*- # -# Copyright (C) 2004, 2005, 2007, 2009 Free Software Foundation, Inc. +# Copyright (C) 2004, 2005, 2007 Free Software Foundation, Inc. # Written by Scott James Remnant, 2004. # # This file is free software; the Free Software Foundation gives # unlimited permission to copy and/or distribute it, with or without # modifications, as long as this notice is preserved. -# serial 5 lt~obsolete.m4 +# serial 4 lt~obsolete.m4 # These exist entirely to fool aclocal when bootstrapping libtool. # @@ -77,6 +77,7 @@ m4_ifndef([_LT_AC_LANG_CXX], [AC_DEFUN([_LT_AC_LANG_CXX])]) m4_ifndef([_LT_AC_LANG_F77], [AC_DEFUN([_LT_AC_LANG_F77])]) m4_ifndef([_LT_AC_LANG_GCJ], [AC_DEFUN([_LT_AC_LANG_GCJ])]) +m4_ifndef([AC_LIBTOOL_RC], [AC_DEFUN([AC_LIBTOOL_RC])]) m4_ifndef([AC_LIBTOOL_LANG_C_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_C_CONFIG])]) m4_ifndef([_LT_AC_LANG_C_CONFIG], [AC_DEFUN([_LT_AC_LANG_C_CONFIG])]) m4_ifndef([AC_LIBTOOL_LANG_CXX_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_CXX_CONFIG])]) @@ -89,10 +90,3 @@ m4_ifndef([_LT_AC_LANG_RC_CONFIG], [AC_DEFUN([_LT_AC_LANG_RC_CONFIG])]) m4_ifndef([AC_LIBTOOL_CONFIG], [AC_DEFUN([AC_LIBTOOL_CONFIG])]) m4_ifndef([_LT_AC_FILE_LTDLL_C], [AC_DEFUN([_LT_AC_FILE_LTDLL_C])]) -m4_ifndef([_LT_REQUIRED_DARWIN_CHECKS], [AC_DEFUN([_LT_REQUIRED_DARWIN_CHECKS])]) -m4_ifndef([_LT_AC_PROG_CXXCPP], [AC_DEFUN([_LT_AC_PROG_CXXCPP])]) -m4_ifndef([_LT_PREPARE_SED_QUOTE_VARS], [AC_DEFUN([_LT_PREPARE_SED_QUOTE_VARS])]) -m4_ifndef([_LT_PROG_ECHO_BACKSLASH], [AC_DEFUN([_LT_PROG_ECHO_BACKSLASH])]) -m4_ifndef([_LT_PROG_F77], [AC_DEFUN([_LT_PROG_F77])]) -m4_ifndef([_LT_PROG_FC], [AC_DEFUN([_LT_PROG_FC])]) -m4_ifndef([_LT_PROG_CXX], [AC_DEFUN([_LT_PROG_CXX])]) diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi/man/Makefile.am --- a/Modules/_ctypes/libffi/man/Makefile.am Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/_ctypes/libffi/man/Makefile.am Sun Jul 20 10:52:46 2014 -0400 @@ -2,7 +2,7 @@ AUTOMAKE_OPTIONS=foreign -EXTRA_DIST = ffi.3 ffi_call.3 ffi_prep_cif.3 ffi_prep_cif_var.3 +EXTRA_DIST = ffi.3 ffi_call.3 ffi_prep_cif.3 -man_MANS = ffi.3 ffi_call.3 ffi_prep_cif.3 ffi_prep_cif_var.3 +man_MANS = ffi.3 ffi_call.3 ffi_prep_cif.3 diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi/man/Makefile.in --- a/Modules/_ctypes/libffi/man/Makefile.in Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/_ctypes/libffi/man/Makefile.in Sun Jul 20 10:52:46 2014 -0400 @@ -1,8 +1,9 @@ -# Makefile.in generated by automake 1.12.2 from Makefile.am. +# Makefile.in generated by automake 1.11 from Makefile.am. # @configure_input@ -# Copyright (C) 1994-2012 Free Software Foundation, Inc. - +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, +# Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. @@ -14,23 +15,6 @@ @SET_MAKE@ VPATH = @srcdir@ -am__make_dryrun = \ - { \ - am__dry=no; \ - case $$MAKEFLAGS in \ - *\\[\ \ ]*) \ - echo 'am--echo: ; @echo "AM" OK' | $(MAKE) -f - 2>/dev/null \ - | grep '^AM OK$$' >/dev/null || am__dry=yes;; \ - *) \ - for am__flg in $$MAKEFLAGS; do \ - case $$am__flg in \ - *=*|--*) ;; \ - *n*) am__dry=yes; break;; \ - esac; \ - done;; \ - esac; \ - test $$am__dry = yes; \ - } pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ @@ -53,19 +37,7 @@ subdir = man DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 -am__aclocal_m4_deps = $(top_srcdir)/m4/asmcfi.m4 \ - $(top_srcdir)/m4/ax_append_flag.m4 \ - $(top_srcdir)/m4/ax_cc_maxopt.m4 \ - $(top_srcdir)/m4/ax_cflags_warn_all.m4 \ - $(top_srcdir)/m4/ax_check_compile_flag.m4 \ - $(top_srcdir)/m4/ax_compiler_vendor.m4 \ - $(top_srcdir)/m4/ax_configure_args.m4 \ - $(top_srcdir)/m4/ax_enable_builddir.m4 \ - $(top_srcdir)/m4/ax_gcc_archflag.m4 \ - $(top_srcdir)/m4/ax_gcc_x86_cpuid.m4 \ - $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \ - $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \ - $(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/acinclude.m4 \ +am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) @@ -75,11 +47,6 @@ CONFIG_CLEAN_VPATH_FILES = SOURCES = DIST_SOURCES = -am__can_run_installinfo = \ - case $$AM_UPDATE_INFO_DIR in \ - n|no|NO) false;; \ - *) (install-info --version) >/dev/null 2>&1;; \ - esac am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; am__vpath_adj = case $$p in \ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ @@ -101,12 +68,6 @@ am__base_list = \ sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' -am__uninstall_files_from_dir = { \ - test -z "$$files" \ - || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ - || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ - $(am__cd) "$$dir" && rm -f $$files; }; \ - } man3dir = $(mandir)/man3 am__installdirs = "$(DESTDIR)$(man3dir)" NROFF = nroff @@ -115,7 +76,6 @@ ACLOCAL = @ACLOCAL@ ALLOCA = @ALLOCA@ AMTAR = @AMTAR@ -AM_LTLDFLAGS = @AM_LTLDFLAGS@ AM_RUNTESTFLAGS = @AM_RUNTESTFLAGS@ AR = @AR@ AUTOCONF = @AUTOCONF@ @@ -133,7 +93,6 @@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ -DLLTOOL = @DLLTOOL@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ @@ -141,7 +100,6 @@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ -FFI_EXEC_TRAMPOLINE_TABLE = @FFI_EXEC_TRAMPOLINE_TABLE@ FGREP = @FGREP@ GREP = @GREP@ HAVE_LONG_DOUBLE = @HAVE_LONG_DOUBLE@ @@ -160,7 +118,6 @@ LTLIBOBJS = @LTLIBOBJS@ MAINT = @MAINT@ MAKEINFO = @MAKEINFO@ -MANIFEST_TOOL = @MANIFEST_TOOL@ MKDIR_P = @MKDIR_P@ NM = @NM@ NMEDIT = @NMEDIT@ @@ -173,10 +130,8 @@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ -PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ -PRTDIAG = @PRTDIAG@ RANLIB = @RANLIB@ SED = @SED@ SET_MAKE = @SET_MAKE@ @@ -189,7 +144,6 @@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ -ac_ct_AR = @ac_ct_AR@ ac_ct_CC = @ac_ct_CC@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ am__include = @am__include@ @@ -197,7 +151,6 @@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ -ax_enable_builddir_sed = @ax_enable_builddir_sed@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ @@ -223,6 +176,7 @@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ +lt_ECHO = @lt_ECHO@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ @@ -233,7 +187,6 @@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ -sys_symbol_underscore = @sys_symbol_underscore@ sysconfdir = @sysconfdir@ target = @target@ target_alias = @target_alias@ @@ -246,8 +199,8 @@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ AUTOMAKE_OPTIONS = foreign -EXTRA_DIST = ffi.3 ffi_call.3 ffi_prep_cif.3 ffi_prep_cif_var.3 -man_MANS = ffi.3 ffi_call.3 ffi_prep_cif.3 ffi_prep_cif_var.3 +EXTRA_DIST = ffi.3 ffi_call.3 ffi_prep_cif.3 +man_MANS = ffi.3 ffi_call.3 ffi_prep_cif.3 all: all-am .SUFFIXES: @@ -289,18 +242,11 @@ -rm -rf .libs _libs install-man3: $(man_MANS) @$(NORMAL_INSTALL) - @list1=''; \ - list2='$(man_MANS)'; \ - test -n "$(man3dir)" \ - && test -n "`echo $$list1$$list2`" \ - || exit 0; \ - echo " $(MKDIR_P) '$(DESTDIR)$(man3dir)'"; \ - $(MKDIR_P) "$(DESTDIR)$(man3dir)" || exit 1; \ - { for i in $$list1; do echo "$$i"; done; \ - if test -n "$$list2"; then \ - for i in $$list2; do echo "$$i"; done \ - | sed -n '/\.3[a-z]*$$/p'; \ - fi; \ + test -z "$(man3dir)" || $(MKDIR_P) "$(DESTDIR)$(man3dir)" + @list=''; test -n "$(man3dir)" || exit 0; \ + { for i in $$list; do echo "$$i"; done; \ + l2='$(man_MANS)'; for i in $$l2; do echo "$$i"; done | \ + sed -n '/\.3[a-z]*$$/p'; \ } | while read p; do \ if test -f $$p; then d=; else d="$(srcdir)/"; fi; \ echo "$$d$$p"; echo "$$p"; \ @@ -329,15 +275,15 @@ sed -n '/\.3[a-z]*$$/p'; \ } | sed -e 's,.*/,,;h;s,.*\.,,;s,^[^3][0-9a-z]*$$,3,;x' \ -e 's,\.[0-9a-z]*$$,,;$(transform);G;s,\n,.,'`; \ - dir='$(DESTDIR)$(man3dir)'; $(am__uninstall_files_from_dir) + test -z "$$files" || { \ + echo " ( cd '$(DESTDIR)$(man3dir)' && rm -f" $$files ")"; \ + cd "$(DESTDIR)$(man3dir)" && rm -f $$files; } tags: TAGS TAGS: ctags: CTAGS CTAGS: -cscope cscopelist: - distdir: $(DISTFILES) @list='$(MANS)'; if test -n "$$list"; then \ @@ -346,10 +292,10 @@ if test -f "$$d$$p"; then echo "$$d$$p"; else :; fi; done`; \ if test -n "$$list" && \ grep 'ab help2man is required to generate this page' $$list >/dev/null; then \ - echo "error: found man pages containing the 'missing help2man' replacement text:" >&2; \ + echo "error: found man pages containing the \`missing help2man' replacement text:" >&2; \ grep -l 'ab help2man is required to generate this page' $$list | sed 's/^/ /' >&2; \ echo " to fix them, install help2man, remove and regenerate the man pages;" >&2; \ - echo " typically 'make maintainer-clean' will remove them" >&2; \ + echo " typically \`make maintainer-clean' will remove them" >&2; \ exit 1; \ else :; fi; \ else :; fi @@ -399,15 +345,10 @@ installcheck: installcheck-am install-strip: - if test -z '$(STRIP)'; then \ - $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ - install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ - install; \ - else \ - $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ - install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ - "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ - fi + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install mostlyclean-generic: clean-generic: diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi/man/ffi.3 --- a/Modules/_ctypes/libffi/man/ffi.3 Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/_ctypes/libffi/man/ffi.3 Sun Jul 20 10:52:46 2014 -0400 @@ -16,15 +16,6 @@ .Fa "ffi_type **atypes" .Fc .Ft void -.Fo ffi_prep_cif_var -.Fa "ffi_cif *cif" -.Fa "ffi_abi abi" -.Fa "unsigned int nfixedargs" -.Fa "unsigned int ntotalargs" -.Fa "ffi_type *rtype" -.Fa "ffi_type **atypes" -.Fc -.Ft void .Fo ffi_call .Fa "ffi_cif *cif" .Fa "void (*fn)(void)" @@ -37,5 +28,4 @@ the called function's interface at compile time. .Sh SEE ALSO .Xr ffi_prep_cif 3 , -.Xr ffi_prep_cif_var 3 , .Xr ffi_call 3 diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi/man/ffi_prep_cif.3 --- a/Modules/_ctypes/libffi/man/ffi_prep_cif.3 Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/_ctypes/libffi/man/ffi_prep_cif.3 Sun Jul 20 10:52:46 2014 -0400 @@ -37,9 +37,7 @@ points to an .Nm ffi_type that describes the data type, size and alignment of the -return value. Note that to call a variadic function -.Nm ffi_prep_cif_var -must be used instead. +return value. .Sh RETURN VALUES Upon successful completion, .Nm ffi_prep_cif @@ -61,8 +59,8 @@ .Nm FFI_BAD_ABI will be returned. Available ABIs are defined in -.Nm . +.Nm +. .Sh SEE ALSO .Xr ffi 3 , -.Xr ffi_call 3 , -.Xr ffi_prep_cif_var 3 +.Xr ffi_call 3 diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi/man/ffi_prep_cif_var.3 --- a/Modules/_ctypes/libffi/man/ffi_prep_cif_var.3 Sat Jul 19 16:34:33 2014 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,73 +0,0 @@ -.Dd January 25, 2011 -.Dt ffi_prep_cif_var 3 -.Sh NAME -.Nm ffi_prep_cif_var -.Nd Prepare a -.Nm ffi_cif -structure for use with -.Nm ffi_call -for variadic functions. -.Sh SYNOPSIS -.In ffi.h -.Ft ffi_status -.Fo ffi_prep_cif_var -.Fa "ffi_cif *cif" -.Fa "ffi_abi abi" -.Fa "unsigned int nfixedargs" -.Fa "unsigned int ntotalargs" -.Fa "ffi_type *rtype" -.Fa "ffi_type **atypes" -.Fc -.Sh DESCRIPTION -The -.Nm ffi_prep_cif_var -function prepares a -.Nm ffi_cif -structure for use with -.Nm ffi_call -for variadic functions. -.Fa abi -specifies a set of calling conventions to use. -.Fa atypes -is an array of -.Fa ntotalargs -pointers to -.Nm ffi_type -structs that describe the data type, size and alignment of each argument. -.Fa rtype -points to an -.Nm ffi_type -that describes the data type, size and alignment of the -return value. -.Fa nfixedargs -must contain the number of fixed (non-variadic) arguments. -Note that to call a non-variadic function -.Nm ffi_prep_cif -must be used. -.Sh RETURN VALUES -Upon successful completion, -.Nm ffi_prep_cif_var -returns -.Nm FFI_OK . -It will return -.Nm FFI_BAD_TYPEDEF -if -.Fa cif -is -.Nm NULL -or -.Fa atypes -or -.Fa rtype -is malformed. If -.Fa abi -does not refer to a valid ABI, -.Nm FFI_BAD_ABI -will be returned. Available ABIs are -defined in -.Nm -. -.Sh SEE ALSO -.Xr ffi 3 , -.Xr ffi_call 3 , -.Xr ffi_prep_cif 3 diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi/missing --- a/Modules/_ctypes/libffi/missing Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/_ctypes/libffi/missing Sun Jul 20 10:52:46 2014 -0400 @@ -1,10 +1,10 @@ #! /bin/sh # Common stub for a few missing GNU programs while installing. -scriptversion=2009-04-28.21; # UTC +scriptversion=2005-06-08.21 -# Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003, 2004, 2005, 2006, -# 2008, 2009 Free Software Foundation, Inc. +# Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003, 2004, 2005 +# Free Software Foundation, Inc. # Originally by Fran,cois Pinard , 1996. # This program is free software; you can redistribute it and/or modify @@ -18,7 +18,9 @@ # GNU General Public License for more details. # You should have received a copy of the GNU General Public License -# along with this program. If not, see . +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +# 02110-1301, USA. # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a @@ -31,8 +33,6 @@ fi run=: -sed_output='s/.* --output[ =]\([^ ]*\).*/\1/p' -sed_minuso='s/.* -o \([^ ]*\).*/\1/p' # In the cases where this matters, `missing' is being run in the # srcdir already. @@ -44,7 +44,7 @@ msg="missing on your system" -case $1 in +case "$1" in --run) # Try to run requested program, and just exit if it succeeds. run= @@ -77,7 +77,6 @@ aclocal touch file \`aclocal.m4' autoconf touch file \`configure' autoheader touch file \`config.h.in' - autom4te touch the output file, or create a stub one automake touch all \`Makefile.in' files bison create \`y.tab.[ch]', if possible, from existing .[ch] flex create \`lex.yy.c', if possible, from existing .c @@ -87,9 +86,6 @@ tar try tar, gnutar, gtar, then tar without non-portable flags yacc create \`y.tab.[ch]', if possible, from existing .[ch] -Version suffixes to PROGRAM as well as the prefixes \`gnu-', \`gnu', and -\`g' are ignored when checking the name. - Send bug reports to ." exit $? ;; @@ -107,22 +103,15 @@ esac -# normalize program name to check for. -program=`echo "$1" | sed ' - s/^gnu-//; t - s/^gnu//; t - s/^g//; t'` - # Now exit if we have it, but it failed. Also exit now if we # don't have it and --version was passed (most likely to detect -# the program). This is about non-GNU programs, so use $1 not -# $program. -case $1 in - lex*|yacc*) +# the program). +case "$1" in + lex|yacc) # Not GNU programs, they don't have --version. ;; - tar*) + tar) if test -n "$run"; then echo 1>&2 "ERROR: \`tar' requires --run" exit 1 @@ -146,7 +135,7 @@ # If it does not exist, or fails to run (possibly an outdated version), # try to emulate it. -case $program in +case "$1" in aclocal*) echo 1>&2 "\ WARNING: \`$1' is $msg. You should only need it if @@ -156,7 +145,7 @@ touch aclocal.m4 ;; - autoconf*) + autoconf) echo 1>&2 "\ WARNING: \`$1' is $msg. You should only need it if you modified \`${configure_ac}'. You might want to install the @@ -165,7 +154,7 @@ touch configure ;; - autoheader*) + autoheader) echo 1>&2 "\ WARNING: \`$1' is $msg. You should only need it if you modified \`acconfig.h' or \`${configure_ac}'. You might want @@ -175,7 +164,7 @@ test -z "$files" && files="config.h" touch_files= for f in $files; do - case $f in + case "$f" in *:*) touch_files="$touch_files "`echo "$f" | sed -e 's/^[^:]*://' -e 's/:.*//'`;; *) touch_files="$touch_files $f.in";; @@ -195,7 +184,7 @@ while read f; do touch "$f"; done ;; - autom4te*) + autom4te) echo 1>&2 "\ WARNING: \`$1' is needed, but is $msg. You might have modified some files without having the @@ -203,8 +192,8 @@ You can get \`$1' as part of \`Autoconf' from any GNU archive site." - file=`echo "$*" | sed -n "$sed_output"` - test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"` + file=`echo "$*" | sed -n 's/.*--output[ =]*\([^ ]*\).*/\1/p'` + test -z "$file" && file=`echo "$*" | sed -n 's/.*-o[ ]*\([^ ]*\).*/\1/p'` if test -f "$file"; then touch $file else @@ -218,78 +207,80 @@ fi ;; - bison*|yacc*) + bison|yacc) echo 1>&2 "\ WARNING: \`$1' $msg. You should only need it if you modified a \`.y' file. You may need the \`Bison' package in order for those modifications to take effect. You can get \`Bison' from any GNU archive site." rm -f y.tab.c y.tab.h - if test $# -ne 1; then + if [ $# -ne 1 ]; then eval LASTARG="\${$#}" - case $LASTARG in + case "$LASTARG" in *.y) SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'` - if test -f "$SRCFILE"; then + if [ -f "$SRCFILE" ]; then cp "$SRCFILE" y.tab.c fi SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'` - if test -f "$SRCFILE"; then + if [ -f "$SRCFILE" ]; then cp "$SRCFILE" y.tab.h fi ;; esac fi - if test ! -f y.tab.h; then + if [ ! -f y.tab.h ]; then echo >y.tab.h fi - if test ! -f y.tab.c; then + if [ ! -f y.tab.c ]; then echo 'main() { return 0; }' >y.tab.c fi ;; - lex*|flex*) + lex|flex) echo 1>&2 "\ WARNING: \`$1' is $msg. You should only need it if you modified a \`.l' file. You may need the \`Flex' package in order for those modifications to take effect. You can get \`Flex' from any GNU archive site." rm -f lex.yy.c - if test $# -ne 1; then + if [ $# -ne 1 ]; then eval LASTARG="\${$#}" - case $LASTARG in + case "$LASTARG" in *.l) SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'` - if test -f "$SRCFILE"; then + if [ -f "$SRCFILE" ]; then cp "$SRCFILE" lex.yy.c fi ;; esac fi - if test ! -f lex.yy.c; then + if [ ! -f lex.yy.c ]; then echo 'main() { return 0; }' >lex.yy.c fi ;; - help2man*) + help2man) echo 1>&2 "\ WARNING: \`$1' is $msg. You should only need it if you modified a dependency of a manual page. You may need the \`Help2man' package in order for those modifications to take effect. You can get \`Help2man' from any GNU archive site." - file=`echo "$*" | sed -n "$sed_output"` - test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"` - if test -f "$file"; then + file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'` + if test -z "$file"; then + file=`echo "$*" | sed -n 's/.*--output=\([^ ]*\).*/\1/p'` + fi + if [ -f "$file" ]; then touch $file else test -z "$file" || exec >$file echo ".ab help2man is required to generate this page" - exit $? + exit 1 fi ;; - makeinfo*) + makeinfo) echo 1>&2 "\ WARNING: \`$1' is $msg. You should only need it if you modified a \`.texi' or \`.texinfo' file, or any other file @@ -298,17 +289,11 @@ DU, IRIX). You might want to install the \`Texinfo' package or the \`GNU make' package. Grab either from any GNU archive site." # The file to touch is that specified with -o ... - file=`echo "$*" | sed -n "$sed_output"` - test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"` + file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'` if test -z "$file"; then # ... or it is the one specified with @setfilename ... infile=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'` - file=`sed -n ' - /^@setfilename/{ - s/.* \([^ ]*\) *$/\1/ - p - q - }' $infile` + file=`sed -n '/^@setfilename/ { s/.* \([^ ]*\) *$/\1/; p; q; }' $infile` # ... or it is derived from the source name (dir/f.texi becomes f.info) test -z "$file" && file=`echo "$infile" | sed 's,.*/,,;s,.[^.]*$,,'`.info fi @@ -318,7 +303,7 @@ touch $file ;; - tar*) + tar) shift # We have already tried tar in the generic part. @@ -332,13 +317,13 @@ fi firstarg="$1" if shift; then - case $firstarg in + case "$firstarg" in *o*) firstarg=`echo "$firstarg" | sed s/o//` tar "$firstarg" "$@" && exit 0 ;; esac - case $firstarg in + case "$firstarg" in *h*) firstarg=`echo "$firstarg" | sed s/h//` tar "$firstarg" "$@" && exit 0 @@ -371,6 +356,5 @@ # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "scriptversion=" # time-stamp-format: "%:y-%02m-%02d.%02H" -# time-stamp-time-zone: "UTC" -# time-stamp-end: "; # UTC" +# time-stamp-end: "$" # End: diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi/msvcc.sh --- a/Modules/_ctypes/libffi/msvcc.sh Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/_ctypes/libffi/msvcc.sh Sun Jul 20 10:52:46 2014 -0400 @@ -42,11 +42,13 @@ # format and translated into something sensible for cl or ml. # -args="-nologo -W3" +# Disable specific warnings, and enable warnings-as-errors so we catch any +# mistranslated args. +nowarn="-wd4127 -wd4820 -wd4706 -wd4100 -wd4255 -wd4668 -wd4053 -wd4324" +args="-nologo -W3 -WX $nowarn" md=-MD cl="cl" ml="ml" -safeseh="-safeseh" output= while [ $# -gt 0 ] @@ -64,28 +66,15 @@ -m64) cl="cl" # "$MSVC/x86_amd64/cl" ml="ml64" # "$MSVC/x86_amd64/ml64" - safeseh= - shift 1 - ;; - -O0) - args="$args -Od" shift 1 ;; -O*) - # If we're optimizing, make sure we explicitly turn on some optimizations - # that are implicitly disabled by debug symbols (-Zi). - args="$args $1 -OPT:REF -OPT:ICF -INCREMENTAL:NO" + args="$args $1" shift 1 ;; -g) - # Enable debug symbol generation. - args="$args -Zi -DEBUG" - shift 1 - ;; - -DFFI_DEBUG) - # Link against debug CRT and enable runtime error checks. - args="$args -RTC1" - defines="$defines $1" + # Can't specify -RTC1 or -Zi in opt. -Gy is ok. Use -OPT:REF? + args="$args -D_DEBUG -RTC1 -Zi" md=-MDd shift 1 ;; @@ -122,8 +111,7 @@ shift 1 ;; -Wall) - # -Wall on MSVC is overzealous, and we already build with -W3. Nothing - # to do here. + args="$args -Wall" shift 1 ;; -Werror) @@ -178,7 +166,7 @@ echo "$cl -nologo -EP $includes $defines $src > $ppsrc" "$cl" -nologo -EP $includes $defines $src > $ppsrc || exit $? output="$(echo $output | sed 's%/F[dpa][^ ]*%%g')" - args="-nologo $safeseh $single $output $ppsrc" + args="-nologo -safeseh $single $output $ppsrc" echo "$ml $args" eval "\"$ml\" $args" diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi/src/aarch64/ffi.c --- a/Modules/_ctypes/libffi/src/aarch64/ffi.c Sat Jul 19 16:34:33 2014 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1076 +0,0 @@ -/* Copyright (c) 2009, 2010, 2011, 2012 ARM Ltd. - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -``Software''), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ - -#include - -#include -#include - -#include - -/* Stack alignment requirement in bytes */ -#define AARCH64_STACK_ALIGN 16 - -#define N_X_ARG_REG 8 -#define N_V_ARG_REG 8 - -#define AARCH64_FFI_WITH_V (1 << AARCH64_FFI_WITH_V_BIT) - -union _d -{ - UINT64 d; - UINT32 s[2]; -}; - -struct call_context -{ - UINT64 x [AARCH64_N_XREG]; - struct - { - union _d d[2]; - } v [AARCH64_N_VREG]; -}; - -static void * -get_x_addr (struct call_context *context, unsigned n) -{ - return &context->x[n]; -} - -static void * -get_s_addr (struct call_context *context, unsigned n) -{ -#if defined __AARCH64EB__ - return &context->v[n].d[1].s[1]; -#else - return &context->v[n].d[0].s[0]; -#endif -} - -static void * -get_d_addr (struct call_context *context, unsigned n) -{ -#if defined __AARCH64EB__ - return &context->v[n].d[1]; -#else - return &context->v[n].d[0]; -#endif -} - -static void * -get_v_addr (struct call_context *context, unsigned n) -{ - return &context->v[n]; -} - -/* Return the memory location at which a basic type would reside - were it to have been stored in register n. */ - -static void * -get_basic_type_addr (unsigned short type, struct call_context *context, - unsigned n) -{ - switch (type) - { - case FFI_TYPE_FLOAT: - return get_s_addr (context, n); - case FFI_TYPE_DOUBLE: - return get_d_addr (context, n); - case FFI_TYPE_LONGDOUBLE: - return get_v_addr (context, n); - case FFI_TYPE_UINT8: - case FFI_TYPE_SINT8: - case FFI_TYPE_UINT16: - case FFI_TYPE_SINT16: - case FFI_TYPE_UINT32: - case FFI_TYPE_SINT32: - case FFI_TYPE_INT: - case FFI_TYPE_POINTER: - case FFI_TYPE_UINT64: - case FFI_TYPE_SINT64: - return get_x_addr (context, n); - default: - FFI_ASSERT (0); - return NULL; - } -} - -/* Return the alignment width for each of the basic types. */ - -static size_t -get_basic_type_alignment (unsigned short type) -{ - switch (type) - { - case FFI_TYPE_FLOAT: - case FFI_TYPE_DOUBLE: - return sizeof (UINT64); - case FFI_TYPE_LONGDOUBLE: - return sizeof (long double); - case FFI_TYPE_UINT8: - case FFI_TYPE_SINT8: - case FFI_TYPE_UINT16: - case FFI_TYPE_SINT16: - case FFI_TYPE_UINT32: - case FFI_TYPE_INT: - case FFI_TYPE_SINT32: - case FFI_TYPE_POINTER: - case FFI_TYPE_UINT64: - case FFI_TYPE_SINT64: - return sizeof (UINT64); - - default: - FFI_ASSERT (0); - return 0; - } -} - -/* Return the size in bytes for each of the basic types. */ - -static size_t -get_basic_type_size (unsigned short type) -{ - switch (type) - { - case FFI_TYPE_FLOAT: - return sizeof (UINT32); - case FFI_TYPE_DOUBLE: - return sizeof (UINT64); - case FFI_TYPE_LONGDOUBLE: - return sizeof (long double); - case FFI_TYPE_UINT8: - return sizeof (UINT8); - case FFI_TYPE_SINT8: - return sizeof (SINT8); - case FFI_TYPE_UINT16: - return sizeof (UINT16); - case FFI_TYPE_SINT16: - return sizeof (SINT16); - case FFI_TYPE_UINT32: - return sizeof (UINT32); - case FFI_TYPE_INT: - case FFI_TYPE_SINT32: - return sizeof (SINT32); - case FFI_TYPE_POINTER: - case FFI_TYPE_UINT64: - return sizeof (UINT64); - case FFI_TYPE_SINT64: - return sizeof (SINT64); - - default: - FFI_ASSERT (0); - return 0; - } -} - -extern void -ffi_call_SYSV (unsigned (*)(struct call_context *context, unsigned char *, - extended_cif *), - struct call_context *context, - extended_cif *, - unsigned, - void (*fn)(void)); - -extern void -ffi_closure_SYSV (ffi_closure *); - -/* Test for an FFI floating point representation. */ - -static unsigned -is_floating_type (unsigned short type) -{ - return (type == FFI_TYPE_FLOAT || type == FFI_TYPE_DOUBLE - || type == FFI_TYPE_LONGDOUBLE); -} - -/* Test for a homogeneous structure. */ - -static unsigned short -get_homogeneous_type (ffi_type *ty) -{ - if (ty->type == FFI_TYPE_STRUCT && ty->elements) - { - unsigned i; - unsigned short candidate_type - = get_homogeneous_type (ty->elements[0]); - for (i =1; ty->elements[i]; i++) - { - unsigned short iteration_type = 0; - /* If we have a nested struct, we must find its homogeneous type. - If that fits with our candidate type, we are still - homogeneous. */ - if (ty->elements[i]->type == FFI_TYPE_STRUCT - && ty->elements[i]->elements) - { - iteration_type = get_homogeneous_type (ty->elements[i]); - } - else - { - iteration_type = ty->elements[i]->type; - } - - /* If we are not homogeneous, return FFI_TYPE_STRUCT. */ - if (candidate_type != iteration_type) - return FFI_TYPE_STRUCT; - } - return candidate_type; - } - - /* Base case, we have no more levels of nesting, so we - are a basic type, and so, trivially homogeneous in that type. */ - return ty->type; -} - -/* Determine the number of elements within a STRUCT. - - Note, we must handle nested structs. - - If ty is not a STRUCT this function will return 0. */ - -static unsigned -element_count (ffi_type *ty) -{ - if (ty->type == FFI_TYPE_STRUCT && ty->elements) - { - unsigned n; - unsigned elems = 0; - for (n = 0; ty->elements[n]; n++) - { - if (ty->elements[n]->type == FFI_TYPE_STRUCT - && ty->elements[n]->elements) - elems += element_count (ty->elements[n]); - else - elems++; - } - return elems; - } - return 0; -} - -/* Test for a homogeneous floating point aggregate. - - A homogeneous floating point aggregate is a homogeneous aggregate of - a half- single- or double- precision floating point type with one - to four elements. Note that this includes nested structs of the - basic type. */ - -static int -is_hfa (ffi_type *ty) -{ - if (ty->type == FFI_TYPE_STRUCT - && ty->elements[0] - && is_floating_type (get_homogeneous_type (ty))) - { - unsigned n = element_count (ty); - return n >= 1 && n <= 4; - } - return 0; -} - -/* Test if an ffi_type is a candidate for passing in a register. - - This test does not check that sufficient registers of the - appropriate class are actually available, merely that IFF - sufficient registers are available then the argument will be passed - in register(s). - - Note that an ffi_type that is deemed to be a register candidate - will always be returned in registers. - - Returns 1 if a register candidate else 0. */ - -static int -is_register_candidate (ffi_type *ty) -{ - switch (ty->type) - { - case FFI_TYPE_VOID: - case FFI_TYPE_FLOAT: - case FFI_TYPE_DOUBLE: - case FFI_TYPE_LONGDOUBLE: - case FFI_TYPE_UINT8: - case FFI_TYPE_UINT16: - case FFI_TYPE_UINT32: - case FFI_TYPE_UINT64: - case FFI_TYPE_POINTER: - case FFI_TYPE_SINT8: - case FFI_TYPE_SINT16: - case FFI_TYPE_SINT32: - case FFI_TYPE_INT: - case FFI_TYPE_SINT64: - return 1; - - case FFI_TYPE_STRUCT: - if (is_hfa (ty)) - { - return 1; - } - else if (ty->size > 16) - { - /* Too large. Will be replaced with a pointer to memory. The - pointer MAY be passed in a register, but the value will - not. This test specifically fails since the argument will - never be passed by value in registers. */ - return 0; - } - else - { - /* Might be passed in registers depending on the number of - registers required. */ - return (ty->size + 7) / 8 < N_X_ARG_REG; - } - break; - - default: - FFI_ASSERT (0); - break; - } - - return 0; -} - -/* Test if an ffi_type argument or result is a candidate for a vector - register. */ - -static int -is_v_register_candidate (ffi_type *ty) -{ - return is_floating_type (ty->type) - || (ty->type == FFI_TYPE_STRUCT && is_hfa (ty)); -} - -/* Representation of the procedure call argument marshalling - state. - - The terse state variable names match the names used in the AARCH64 - PCS. */ - -struct arg_state -{ - unsigned ngrn; /* Next general-purpose register number. */ - unsigned nsrn; /* Next vector register number. */ - unsigned nsaa; /* Next stack offset. */ -}; - -/* Initialize a procedure call argument marshalling state. */ -static void -arg_init (struct arg_state *state, unsigned call_frame_size) -{ - state->ngrn = 0; - state->nsrn = 0; - state->nsaa = 0; -} - -/* Return the number of available consecutive core argument - registers. */ - -static unsigned -available_x (struct arg_state *state) -{ - return N_X_ARG_REG - state->ngrn; -} - -/* Return the number of available consecutive vector argument - registers. */ - -static unsigned -available_v (struct arg_state *state) -{ - return N_V_ARG_REG - state->nsrn; -} - -static void * -allocate_to_x (struct call_context *context, struct arg_state *state) -{ - FFI_ASSERT (state->ngrn < N_X_ARG_REG) - return get_x_addr (context, (state->ngrn)++); -} - -static void * -allocate_to_s (struct call_context *context, struct arg_state *state) -{ - FFI_ASSERT (state->nsrn < N_V_ARG_REG) - return get_s_addr (context, (state->nsrn)++); -} - -static void * -allocate_to_d (struct call_context *context, struct arg_state *state) -{ - FFI_ASSERT (state->nsrn < N_V_ARG_REG) - return get_d_addr (context, (state->nsrn)++); -} - -static void * -allocate_to_v (struct call_context *context, struct arg_state *state) -{ - FFI_ASSERT (state->nsrn < N_V_ARG_REG) - return get_v_addr (context, (state->nsrn)++); -} - -/* Allocate an aligned slot on the stack and return a pointer to it. */ -static void * -allocate_to_stack (struct arg_state *state, void *stack, unsigned alignment, - unsigned size) -{ - void *allocation; - - /* Round up the NSAA to the larger of 8 or the natural - alignment of the argument's type. */ - state->nsaa = ALIGN (state->nsaa, alignment); - state->nsaa = ALIGN (state->nsaa, alignment); - state->nsaa = ALIGN (state->nsaa, 8); - - allocation = stack + state->nsaa; - - state->nsaa += size; - return allocation; -} - -static void -copy_basic_type (void *dest, void *source, unsigned short type) -{ - /* This is neccessary to ensure that basic types are copied - sign extended to 64-bits as libffi expects. */ - switch (type) - { - case FFI_TYPE_FLOAT: - *(float *) dest = *(float *) source; - break; - case FFI_TYPE_DOUBLE: - *(double *) dest = *(double *) source; - break; - case FFI_TYPE_LONGDOUBLE: - *(long double *) dest = *(long double *) source; - break; - case FFI_TYPE_UINT8: - *(ffi_arg *) dest = *(UINT8 *) source; - break; - case FFI_TYPE_SINT8: - *(ffi_sarg *) dest = *(SINT8 *) source; - break; - case FFI_TYPE_UINT16: - *(ffi_arg *) dest = *(UINT16 *) source; - break; - case FFI_TYPE_SINT16: - *(ffi_sarg *) dest = *(SINT16 *) source; - break; - case FFI_TYPE_UINT32: - *(ffi_arg *) dest = *(UINT32 *) source; - break; - case FFI_TYPE_INT: - case FFI_TYPE_SINT32: - *(ffi_sarg *) dest = *(SINT32 *) source; - break; - case FFI_TYPE_POINTER: - case FFI_TYPE_UINT64: - *(ffi_arg *) dest = *(UINT64 *) source; - break; - case FFI_TYPE_SINT64: - *(ffi_sarg *) dest = *(SINT64 *) source; - break; - - default: - FFI_ASSERT (0); - } -} - -static void -copy_hfa_to_reg_or_stack (void *memory, - ffi_type *ty, - struct call_context *context, - unsigned char *stack, - struct arg_state *state) -{ - unsigned elems = element_count (ty); - if (available_v (state) < elems) - { - /* There are insufficient V registers. Further V register allocations - are prevented, the NSAA is adjusted (by allocate_to_stack ()) - and the argument is copied to memory at the adjusted NSAA. */ - state->nsrn = N_V_ARG_REG; - memcpy (allocate_to_stack (state, stack, ty->alignment, ty->size), - memory, - ty->size); - } - else - { - int i; - unsigned short type = get_homogeneous_type (ty); - unsigned elems = element_count (ty); - for (i = 0; i < elems; i++) - { - void *reg = allocate_to_v (context, state); - copy_basic_type (reg, memory, type); - memory += get_basic_type_size (type); - } - } -} - -/* Either allocate an appropriate register for the argument type, or if - none are available, allocate a stack slot and return a pointer - to the allocated space. */ - -static void * -allocate_to_register_or_stack (struct call_context *context, - unsigned char *stack, - struct arg_state *state, - unsigned short type) -{ - size_t alignment = get_basic_type_alignment (type); - size_t size = alignment; - switch (type) - { - case FFI_TYPE_FLOAT: - /* This is the only case for which the allocated stack size - should not match the alignment of the type. */ - size = sizeof (UINT32); - /* Fall through. */ - case FFI_TYPE_DOUBLE: - if (state->nsrn < N_V_ARG_REG) - return allocate_to_d (context, state); - state->nsrn = N_V_ARG_REG; - break; - case FFI_TYPE_LONGDOUBLE: - if (state->nsrn < N_V_ARG_REG) - return allocate_to_v (context, state); - state->nsrn = N_V_ARG_REG; - break; - case FFI_TYPE_UINT8: - case FFI_TYPE_SINT8: - case FFI_TYPE_UINT16: - case FFI_TYPE_SINT16: - case FFI_TYPE_UINT32: - case FFI_TYPE_SINT32: - case FFI_TYPE_INT: - case FFI_TYPE_POINTER: - case FFI_TYPE_UINT64: - case FFI_TYPE_SINT64: - if (state->ngrn < N_X_ARG_REG) - return allocate_to_x (context, state); - state->ngrn = N_X_ARG_REG; - break; - default: - FFI_ASSERT (0); - } - - return allocate_to_stack (state, stack, alignment, size); -} - -/* Copy a value to an appropriate register, or if none are - available, to the stack. */ - -static void -copy_to_register_or_stack (struct call_context *context, - unsigned char *stack, - struct arg_state *state, - void *value, - unsigned short type) -{ - copy_basic_type ( - allocate_to_register_or_stack (context, stack, state, type), - value, - type); -} - -/* Marshall the arguments from FFI representation to procedure call - context and stack. */ - -static unsigned -aarch64_prep_args (struct call_context *context, unsigned char *stack, - extended_cif *ecif) -{ - int i; - struct arg_state state; - - arg_init (&state, ALIGN(ecif->cif->bytes, 16)); - - for (i = 0; i < ecif->cif->nargs; i++) - { - ffi_type *ty = ecif->cif->arg_types[i]; - switch (ty->type) - { - case FFI_TYPE_VOID: - FFI_ASSERT (0); - break; - - /* If the argument is a basic type the argument is allocated to an - appropriate register, or if none are available, to the stack. */ - case FFI_TYPE_FLOAT: - case FFI_TYPE_DOUBLE: - case FFI_TYPE_LONGDOUBLE: - case FFI_TYPE_UINT8: - case FFI_TYPE_SINT8: - case FFI_TYPE_UINT16: - case FFI_TYPE_SINT16: - case FFI_TYPE_UINT32: - case FFI_TYPE_INT: - case FFI_TYPE_SINT32: - case FFI_TYPE_POINTER: - case FFI_TYPE_UINT64: - case FFI_TYPE_SINT64: - copy_to_register_or_stack (context, stack, &state, - ecif->avalue[i], ty->type); - break; - - case FFI_TYPE_STRUCT: - if (is_hfa (ty)) - { - copy_hfa_to_reg_or_stack (ecif->avalue[i], ty, context, - stack, &state); - } - else if (ty->size > 16) - { - /* If the argument is a composite type that is larger than 16 - bytes, then the argument has been copied to memory, and - the argument is replaced by a pointer to the copy. */ - - copy_to_register_or_stack (context, stack, &state, - &(ecif->avalue[i]), FFI_TYPE_POINTER); - } - else if (available_x (&state) >= (ty->size + 7) / 8) - { - /* If the argument is a composite type and the size in - double-words is not more than the number of available - X registers, then the argument is copied into consecutive - X registers. */ - int j; - for (j = 0; j < (ty->size + 7) / 8; j++) - { - memcpy (allocate_to_x (context, &state), - &(((UINT64 *) ecif->avalue[i])[j]), - sizeof (UINT64)); - } - } - else - { - /* Otherwise, there are insufficient X registers. Further X - register allocations are prevented, the NSAA is adjusted - (by allocate_to_stack ()) and the argument is copied to - memory at the adjusted NSAA. */ - state.ngrn = N_X_ARG_REG; - - memcpy (allocate_to_stack (&state, stack, ty->alignment, - ty->size), ecif->avalue + i, ty->size); - } - break; - - default: - FFI_ASSERT (0); - break; - } - } - - return ecif->cif->aarch64_flags; -} - -ffi_status -ffi_prep_cif_machdep (ffi_cif *cif) -{ - /* Round the stack up to a multiple of the stack alignment requirement. */ - cif->bytes = - (cif->bytes + (AARCH64_STACK_ALIGN - 1)) & ~ (AARCH64_STACK_ALIGN - 1); - - /* Initialize our flags. We are interested if this CIF will touch a - vector register, if so we will enable context save and load to - those registers, otherwise not. This is intended to be friendly - to lazy float context switching in the kernel. */ - cif->aarch64_flags = 0; - - if (is_v_register_candidate (cif->rtype)) - { - cif->aarch64_flags |= AARCH64_FFI_WITH_V; - } - else - { - int i; - for (i = 0; i < cif->nargs; i++) - if (is_v_register_candidate (cif->arg_types[i])) - { - cif->aarch64_flags |= AARCH64_FFI_WITH_V; - break; - } - } - - return FFI_OK; -} - -/* Call a function with the provided arguments and capture the return - value. */ -void -ffi_call (ffi_cif *cif, void (*fn)(void), void *rvalue, void **avalue) -{ - extended_cif ecif; - - ecif.cif = cif; - ecif.avalue = avalue; - ecif.rvalue = rvalue; - - switch (cif->abi) - { - case FFI_SYSV: - { - struct call_context context; - unsigned stack_bytes; - - /* Figure out the total amount of stack space we need, the - above call frame space needs to be 16 bytes aligned to - ensure correct alignment of the first object inserted in - that space hence the ALIGN applied to cif->bytes.*/ - stack_bytes = ALIGN(cif->bytes, 16); - - memset (&context, 0, sizeof (context)); - if (is_register_candidate (cif->rtype)) - { - ffi_call_SYSV (aarch64_prep_args, &context, &ecif, stack_bytes, fn); - switch (cif->rtype->type) - { - case FFI_TYPE_VOID: - case FFI_TYPE_FLOAT: - case FFI_TYPE_DOUBLE: - case FFI_TYPE_LONGDOUBLE: - case FFI_TYPE_UINT8: - case FFI_TYPE_SINT8: - case FFI_TYPE_UINT16: - case FFI_TYPE_SINT16: - case FFI_TYPE_UINT32: - case FFI_TYPE_SINT32: - case FFI_TYPE_POINTER: - case FFI_TYPE_UINT64: - case FFI_TYPE_INT: - case FFI_TYPE_SINT64: - { - void *addr = get_basic_type_addr (cif->rtype->type, - &context, 0); - copy_basic_type (rvalue, addr, cif->rtype->type); - break; - } - - case FFI_TYPE_STRUCT: - if (is_hfa (cif->rtype)) - { - int j; - unsigned short type = get_homogeneous_type (cif->rtype); - unsigned elems = element_count (cif->rtype); - for (j = 0; j < elems; j++) - { - void *reg = get_basic_type_addr (type, &context, j); - copy_basic_type (rvalue, reg, type); - rvalue += get_basic_type_size (type); - } - } - else if ((cif->rtype->size + 7) / 8 < N_X_ARG_REG) - { - unsigned size = ALIGN (cif->rtype->size, sizeof (UINT64)); - memcpy (rvalue, get_x_addr (&context, 0), size); - } - else - { - FFI_ASSERT (0); - } - break; - - default: - FFI_ASSERT (0); - break; - } - } - else - { - memcpy (get_x_addr (&context, 8), &rvalue, sizeof (UINT64)); - ffi_call_SYSV (aarch64_prep_args, &context, &ecif, - stack_bytes, fn); - } - break; - } - - default: - FFI_ASSERT (0); - break; - } -} - -static unsigned char trampoline [] = -{ 0x70, 0x00, 0x00, 0x58, /* ldr x16, 1f */ - 0x91, 0x00, 0x00, 0x10, /* adr x17, 2f */ - 0x00, 0x02, 0x1f, 0xd6 /* br x16 */ -}; - -/* Build a trampoline. */ - -#define FFI_INIT_TRAMPOLINE(TRAMP,FUN,CTX,FLAGS) \ - ({unsigned char *__tramp = (unsigned char*)(TRAMP); \ - UINT64 __fun = (UINT64)(FUN); \ - UINT64 __ctx = (UINT64)(CTX); \ - UINT64 __flags = (UINT64)(FLAGS); \ - memcpy (__tramp, trampoline, sizeof (trampoline)); \ - memcpy (__tramp + 12, &__fun, sizeof (__fun)); \ - memcpy (__tramp + 20, &__ctx, sizeof (__ctx)); \ - memcpy (__tramp + 28, &__flags, sizeof (__flags)); \ - __clear_cache(__tramp, __tramp + FFI_TRAMPOLINE_SIZE); \ - }) - -ffi_status -ffi_prep_closure_loc (ffi_closure* closure, - ffi_cif* cif, - void (*fun)(ffi_cif*,void*,void**,void*), - void *user_data, - void *codeloc) -{ - if (cif->abi != FFI_SYSV) - return FFI_BAD_ABI; - - FFI_INIT_TRAMPOLINE (&closure->tramp[0], &ffi_closure_SYSV, codeloc, - cif->aarch64_flags); - - closure->cif = cif; - closure->user_data = user_data; - closure->fun = fun; - - return FFI_OK; -} - -/* Primary handler to setup and invoke a function within a closure. - - A closure when invoked enters via the assembler wrapper - ffi_closure_SYSV(). The wrapper allocates a call context on the - stack, saves the interesting registers (from the perspective of - the calling convention) into the context then passes control to - ffi_closure_SYSV_inner() passing the saved context and a pointer to - the stack at the point ffi_closure_SYSV() was invoked. - - On the return path the assembler wrapper will reload call context - regsiters. - - ffi_closure_SYSV_inner() marshalls the call context into ffi value - desriptors, invokes the wrapped function, then marshalls the return - value back into the call context. */ - -void -ffi_closure_SYSV_inner (ffi_closure *closure, struct call_context *context, - void *stack) -{ - ffi_cif *cif = closure->cif; - void **avalue = (void**) alloca (cif->nargs * sizeof (void*)); - void *rvalue = NULL; - int i; - struct arg_state state; - - arg_init (&state, ALIGN(cif->bytes, 16)); - - for (i = 0; i < cif->nargs; i++) - { - ffi_type *ty = cif->arg_types[i]; - - switch (ty->type) - { - case FFI_TYPE_VOID: - FFI_ASSERT (0); - break; - - case FFI_TYPE_UINT8: - case FFI_TYPE_SINT8: - case FFI_TYPE_UINT16: - case FFI_TYPE_SINT16: - case FFI_TYPE_UINT32: - case FFI_TYPE_SINT32: - case FFI_TYPE_INT: - case FFI_TYPE_POINTER: - case FFI_TYPE_UINT64: - case FFI_TYPE_SINT64: - case FFI_TYPE_FLOAT: - case FFI_TYPE_DOUBLE: - case FFI_TYPE_LONGDOUBLE: - avalue[i] = allocate_to_register_or_stack (context, stack, - &state, ty->type); - break; - - case FFI_TYPE_STRUCT: - if (is_hfa (ty)) - { - unsigned n = element_count (ty); - if (available_v (&state) < n) - { - state.nsrn = N_V_ARG_REG; - avalue[i] = allocate_to_stack (&state, stack, ty->alignment, - ty->size); - } - else - { - switch (get_homogeneous_type (ty)) - { - case FFI_TYPE_FLOAT: - { - /* Eeek! We need a pointer to the structure, - however the homogeneous float elements are - being passed in individual S registers, - therefore the structure is not represented as - a contiguous sequence of bytes in our saved - register context. We need to fake up a copy - of the structure layed out in memory - correctly. The fake can be tossed once the - closure function has returned hence alloca() - is sufficient. */ - int j; - UINT32 *p = avalue[i] = alloca (ty->size); - for (j = 0; j < element_count (ty); j++) - memcpy (&p[j], - allocate_to_s (context, &state), - sizeof (*p)); - break; - } - - case FFI_TYPE_DOUBLE: - { - /* Eeek! We need a pointer to the structure, - however the homogeneous float elements are - being passed in individual S registers, - therefore the structure is not represented as - a contiguous sequence of bytes in our saved - register context. We need to fake up a copy - of the structure layed out in memory - correctly. The fake can be tossed once the - closure function has returned hence alloca() - is sufficient. */ - int j; - UINT64 *p = avalue[i] = alloca (ty->size); - for (j = 0; j < element_count (ty); j++) - memcpy (&p[j], - allocate_to_d (context, &state), - sizeof (*p)); - break; - } - - case FFI_TYPE_LONGDOUBLE: - memcpy (&avalue[i], - allocate_to_v (context, &state), - sizeof (*avalue)); - break; - - default: - FFI_ASSERT (0); - break; - } - } - } - else if (ty->size > 16) - { - /* Replace Composite type of size greater than 16 with a - pointer. */ - memcpy (&avalue[i], - allocate_to_register_or_stack (context, stack, - &state, FFI_TYPE_POINTER), - sizeof (avalue[i])); - } - else if (available_x (&state) >= (ty->size + 7) / 8) - { - avalue[i] = get_x_addr (context, state.ngrn); - state.ngrn += (ty->size + 7) / 8; - } - else - { - state.ngrn = N_X_ARG_REG; - - avalue[i] = allocate_to_stack (&state, stack, ty->alignment, - ty->size); - } - break; - - default: - FFI_ASSERT (0); - break; - } - } - - /* Figure out where the return value will be passed, either in - registers or in a memory block allocated by the caller and passed - in x8. */ - - if (is_register_candidate (cif->rtype)) - { - /* Register candidates are *always* returned in registers. */ - - /* Allocate a scratchpad for the return value, we will let the - callee scrible the result into the scratch pad then move the - contents into the appropriate return value location for the - call convention. */ - rvalue = alloca (cif->rtype->size); - (closure->fun) (cif, rvalue, avalue, closure->user_data); - - /* Copy the return value into the call context so that it is returned - as expected to our caller. */ - switch (cif->rtype->type) - { - case FFI_TYPE_VOID: - break; - - case FFI_TYPE_UINT8: - case FFI_TYPE_UINT16: - case FFI_TYPE_UINT32: - case FFI_TYPE_POINTER: - case FFI_TYPE_UINT64: - case FFI_TYPE_SINT8: - case FFI_TYPE_SINT16: - case FFI_TYPE_INT: - case FFI_TYPE_SINT32: - case FFI_TYPE_SINT64: - case FFI_TYPE_FLOAT: - case FFI_TYPE_DOUBLE: - case FFI_TYPE_LONGDOUBLE: - { - void *addr = get_basic_type_addr (cif->rtype->type, context, 0); - copy_basic_type (addr, rvalue, cif->rtype->type); - break; - } - case FFI_TYPE_STRUCT: - if (is_hfa (cif->rtype)) - { - int i; - unsigned short type = get_homogeneous_type (cif->rtype); - unsigned elems = element_count (cif->rtype); - for (i = 0; i < elems; i++) - { - void *reg = get_basic_type_addr (type, context, i); - copy_basic_type (reg, rvalue, type); - rvalue += get_basic_type_size (type); - } - } - else if ((cif->rtype->size + 7) / 8 < N_X_ARG_REG) - { - unsigned size = ALIGN (cif->rtype->size, sizeof (UINT64)) ; - memcpy (get_x_addr (context, 0), rvalue, size); - } - else - { - FFI_ASSERT (0); - } - break; - default: - FFI_ASSERT (0); - break; - } - } - else - { - memcpy (&rvalue, get_x_addr (context, 8), sizeof (UINT64)); - (closure->fun) (cif, rvalue, avalue, closure->user_data); - } -} - diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi/src/aarch64/ffitarget.h --- a/Modules/_ctypes/libffi/src/aarch64/ffitarget.h Sat Jul 19 16:34:33 2014 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,59 +0,0 @@ -/* Copyright (c) 2009, 2010, 2011, 2012 ARM Ltd. - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -``Software''), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ - -#ifndef LIBFFI_TARGET_H -#define LIBFFI_TARGET_H - -#ifndef LIBFFI_H -#error "Please do not include ffitarget.h directly into your source. Use ffi.h instead." -#endif - -#ifndef LIBFFI_ASM -typedef unsigned long ffi_arg; -typedef signed long ffi_sarg; - -typedef enum ffi_abi - { - FFI_FIRST_ABI = 0, - FFI_SYSV, - FFI_LAST_ABI, - FFI_DEFAULT_ABI = FFI_SYSV - } ffi_abi; -#endif - -/* ---- Definitions for closures ----------------------------------------- */ - -#define FFI_CLOSURES 1 -#define FFI_TRAMPOLINE_SIZE 36 -#define FFI_NATIVE_RAW_API 0 - -/* ---- Internal ---- */ - - -#define FFI_EXTRA_CIF_FIELDS unsigned aarch64_flags - -#define AARCH64_FFI_WITH_V_BIT 0 - -#define AARCH64_N_XREG 32 -#define AARCH64_N_VREG 32 -#define AARCH64_CALL_CONTEXT_SIZE (AARCH64_N_XREG * 8 + AARCH64_N_VREG * 16) - -#endif diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi/src/aarch64/sysv.S --- a/Modules/_ctypes/libffi/src/aarch64/sysv.S Sat Jul 19 16:34:33 2014 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,307 +0,0 @@ -/* Copyright (c) 2009, 2010, 2011, 2012 ARM Ltd. - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -``Software''), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ - -#define LIBFFI_ASM -#include -#include - -#define cfi_adjust_cfa_offset(off) .cfi_adjust_cfa_offset off -#define cfi_rel_offset(reg, off) .cfi_rel_offset reg, off -#define cfi_restore(reg) .cfi_restore reg -#define cfi_def_cfa_register(reg) .cfi_def_cfa_register reg - - .text - .globl ffi_call_SYSV - .type ffi_call_SYSV, #function - -/* ffi_call_SYSV() - - Create a stack frame, setup an argument context, call the callee - and extract the result. - - The maximum required argument stack size is provided, - ffi_call_SYSV() allocates that stack space then calls the - prepare_fn to populate register context and stack. The - argument passing registers are loaded from the register - context and the callee called, on return the register passing - register are saved back to the context. Our caller will - extract the return value from the final state of the saved - register context. - - Prototype: - - extern unsigned - ffi_call_SYSV (void (*)(struct call_context *context, unsigned char *, - extended_cif *), - struct call_context *context, - extended_cif *, - unsigned required_stack_size, - void (*fn)(void)); - - Therefore on entry we have: - - x0 prepare_fn - x1 &context - x2 &ecif - x3 bytes - x4 fn - - This function uses the following stack frame layout: - - == - saved x30(lr) - x29(fp)-> saved x29(fp) - saved x24 - saved x23 - saved x22 - sp' -> saved x21 - ... - sp -> (constructed callee stack arguments) - == - - Voila! */ - -#define ffi_call_SYSV_FS (8 * 4) - - .cfi_startproc -ffi_call_SYSV: - stp x29, x30, [sp, #-16]! - cfi_adjust_cfa_offset (16) - cfi_rel_offset (x29, 0) - cfi_rel_offset (x30, 8) - - mov x29, sp - cfi_def_cfa_register (x29) - sub sp, sp, #ffi_call_SYSV_FS - - stp x21, x22, [sp, 0] - cfi_rel_offset (x21, 0 - ffi_call_SYSV_FS) - cfi_rel_offset (x22, 8 - ffi_call_SYSV_FS) - - stp x23, x24, [sp, 16] - cfi_rel_offset (x23, 16 - ffi_call_SYSV_FS) - cfi_rel_offset (x24, 24 - ffi_call_SYSV_FS) - - mov x21, x1 - mov x22, x2 - mov x24, x4 - - /* Allocate the stack space for the actual arguments, many - arguments will be passed in registers, but we assume - worst case and allocate sufficient stack for ALL of - the arguments. */ - sub sp, sp, x3 - - /* unsigned (*prepare_fn) (struct call_context *context, - unsigned char *stack, extended_cif *ecif); - */ - mov x23, x0 - mov x0, x1 - mov x1, sp - /* x2 already in place */ - blr x23 - - /* Preserve the flags returned. */ - mov x23, x0 - - /* Figure out if we should touch the vector registers. */ - tbz x23, #AARCH64_FFI_WITH_V_BIT, 1f - - /* Load the vector argument passing registers. */ - ldp q0, q1, [x21, #8*32 + 0] - ldp q2, q3, [x21, #8*32 + 32] - ldp q4, q5, [x21, #8*32 + 64] - ldp q6, q7, [x21, #8*32 + 96] -1: - /* Load the core argument passing registers. */ - ldp x0, x1, [x21, #0] - ldp x2, x3, [x21, #16] - ldp x4, x5, [x21, #32] - ldp x6, x7, [x21, #48] - - /* Don't forget x8 which may be holding the address of a return buffer. - */ - ldr x8, [x21, #8*8] - - blr x24 - - /* Save the core argument passing registers. */ - stp x0, x1, [x21, #0] - stp x2, x3, [x21, #16] - stp x4, x5, [x21, #32] - stp x6, x7, [x21, #48] - - /* Note nothing useful ever comes back in x8! */ - - /* Figure out if we should touch the vector registers. */ - tbz x23, #AARCH64_FFI_WITH_V_BIT, 1f - - /* Save the vector argument passing registers. */ - stp q0, q1, [x21, #8*32 + 0] - stp q2, q3, [x21, #8*32 + 32] - stp q4, q5, [x21, #8*32 + 64] - stp q6, q7, [x21, #8*32 + 96] -1: - /* All done, unwind our stack frame. */ - ldp x21, x22, [x29, # - ffi_call_SYSV_FS] - cfi_restore (x21) - cfi_restore (x22) - - ldp x23, x24, [x29, # - ffi_call_SYSV_FS + 16] - cfi_restore (x23) - cfi_restore (x24) - - mov sp, x29 - cfi_def_cfa_register (sp) - - ldp x29, x30, [sp], #16 - cfi_adjust_cfa_offset (-16) - cfi_restore (x29) - cfi_restore (x30) - - ret - - .cfi_endproc - .size ffi_call_SYSV, .-ffi_call_SYSV - -#define ffi_closure_SYSV_FS (8 * 2 + AARCH64_CALL_CONTEXT_SIZE) - -/* ffi_closure_SYSV - - Closure invocation glue. This is the low level code invoked directly by - the closure trampoline to setup and call a closure. - - On entry x17 points to a struct trampoline_data, x16 has been clobbered - all other registers are preserved. - - We allocate a call context and save the argument passing registers, - then invoked the generic C ffi_closure_SYSV_inner() function to do all - the real work, on return we load the result passing registers back from - the call context. - - On entry - - extern void - ffi_closure_SYSV (struct trampoline_data *); - - struct trampoline_data - { - UINT64 *ffi_closure; - UINT64 flags; - }; - - This function uses the following stack frame layout: - - == - saved x30(lr) - x29(fp)-> saved x29(fp) - saved x22 - saved x21 - ... - sp -> call_context - == - - Voila! */ - - .text - .globl ffi_closure_SYSV - .cfi_startproc -ffi_closure_SYSV: - stp x29, x30, [sp, #-16]! - cfi_adjust_cfa_offset (16) - cfi_rel_offset (x29, 0) - cfi_rel_offset (x30, 8) - - mov x29, sp - - sub sp, sp, #ffi_closure_SYSV_FS - cfi_adjust_cfa_offset (ffi_closure_SYSV_FS) - - stp x21, x22, [x29, #-16] - cfi_rel_offset (x21, 0) - cfi_rel_offset (x22, 8) - - /* Load x21 with &call_context. */ - mov x21, sp - /* Preserve our struct trampoline_data * */ - mov x22, x17 - - /* Save the rest of the argument passing registers. */ - stp x0, x1, [x21, #0] - stp x2, x3, [x21, #16] - stp x4, x5, [x21, #32] - stp x6, x7, [x21, #48] - /* Don't forget we may have been given a result scratch pad address. - */ - str x8, [x21, #64] - - /* Figure out if we should touch the vector registers. */ - ldr x0, [x22, #8] - tbz x0, #AARCH64_FFI_WITH_V_BIT, 1f - - /* Save the argument passing vector registers. */ - stp q0, q1, [x21, #8*32 + 0] - stp q2, q3, [x21, #8*32 + 32] - stp q4, q5, [x21, #8*32 + 64] - stp q6, q7, [x21, #8*32 + 96] -1: - /* Load &ffi_closure.. */ - ldr x0, [x22, #0] - mov x1, x21 - /* Compute the location of the stack at the point that the - trampoline was called. */ - add x2, x29, #16 - - bl ffi_closure_SYSV_inner - - /* Figure out if we should touch the vector registers. */ - ldr x0, [x22, #8] - tbz x0, #AARCH64_FFI_WITH_V_BIT, 1f - - /* Load the result passing vector registers. */ - ldp q0, q1, [x21, #8*32 + 0] - ldp q2, q3, [x21, #8*32 + 32] - ldp q4, q5, [x21, #8*32 + 64] - ldp q6, q7, [x21, #8*32 + 96] -1: - /* Load the result passing core registers. */ - ldp x0, x1, [x21, #0] - ldp x2, x3, [x21, #16] - ldp x4, x5, [x21, #32] - ldp x6, x7, [x21, #48] - /* Note nothing usefull is returned in x8. */ - - /* We are done, unwind our frame. */ - ldp x21, x22, [x29, #-16] - cfi_restore (x21) - cfi_restore (x22) - - mov sp, x29 - cfi_adjust_cfa_offset (-ffi_closure_SYSV_FS) - - ldp x29, x30, [sp], #16 - cfi_adjust_cfa_offset (-16) - cfi_restore (x29) - cfi_restore (x30) - - ret - .cfi_endproc - .size ffi_closure_SYSV, .-ffi_closure_SYSV diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi/src/alpha/ffi.c --- a/Modules/_ctypes/libffi/src/alpha/ffi.c Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/_ctypes/libffi/src/alpha/ffi.c Sun Jul 20 10:52:46 2014 -0400 @@ -1,6 +1,5 @@ /* ----------------------------------------------------------------------- - ffi.c - Copyright (c) 2012 Anthony Green - Copyright (c) 1998, 2001, 2007, 2008 Red Hat, Inc. + ffi.c - Copyright (c) 1998, 2001, 2007, 2008 Red Hat, Inc. Alpha Foreign Function Interface @@ -179,9 +178,6 @@ { unsigned int *tramp; - if (cif->abi != FFI_OSF) - return FFI_BAD_ABI; - tramp = (unsigned int *) &closure->tramp[0]; tramp[0] = 0x47fb0401; /* mov $27,$1 */ tramp[1] = 0xa77b0010; /* ldq $27,16($27) */ diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi/src/alpha/ffitarget.h --- a/Modules/_ctypes/libffi/src/alpha/ffitarget.h Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/_ctypes/libffi/src/alpha/ffitarget.h Sun Jul 20 10:52:46 2014 -0400 @@ -1,6 +1,5 @@ /* -----------------------------------------------------------------*-C-*- - ffitarget.h - Copyright (c) 2012 Anthony Green - Copyright (c) 1996-2003 Red Hat, Inc. + ffitarget.h - Copyright (c) 1996-2003 Red Hat, Inc. Target configuration macros for Alpha. Permission is hereby granted, free of charge, to any person obtaining @@ -28,10 +27,6 @@ #ifndef LIBFFI_TARGET_H #define LIBFFI_TARGET_H -#ifndef LIBFFI_H -#error "Please do not include ffitarget.h directly into your source. Use ffi.h instead." -#endif - #ifndef LIBFFI_ASM typedef unsigned long ffi_arg; typedef signed long ffi_sarg; diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi/src/alpha/osf.S --- a/Modules/_ctypes/libffi/src/alpha/osf.S Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/_ctypes/libffi/src/alpha/osf.S Sun Jul 20 10:52:46 2014 -0400 @@ -1,5 +1,5 @@ /* ----------------------------------------------------------------------- - osf.S - Copyright (c) 1998, 2001, 2007, 2008, 2011 Red Hat + osf.S - Copyright (c) 1998, 2001, 2007, 2008 Red Hat Alpha/OSF Foreign Function Interface @@ -299,51 +299,33 @@ #endif #ifdef __ELF__ -# define UA_SI .4byte -# define FDE_ENCODING 0x1b /* pcrel sdata4 */ -# define FDE_ENCODE(X) .4byte X-. -# define FDE_ARANGE(X) .4byte X -#elif defined __osf__ -# define UA_SI .align 0; .long -# define FDE_ENCODING 0x50 /* aligned absolute */ -# define FDE_ENCODE(X) .align 3; .quad X -# define FDE_ARANGE(X) .align 0; .quad X -#endif - -#ifdef __ELF__ .section .eh_frame,EH_FRAME_FLAGS,@progbits -#elif defined __osf__ - .data - .align 3 - .globl _GLOBAL__F_ffi_call_osf -_GLOBAL__F_ffi_call_osf: -#endif __FRAME_BEGIN__: - UA_SI $LECIE1-$LSCIE1 # Length of Common Information Entry + .4byte $LECIE1-$LSCIE1 # Length of Common Information Entry $LSCIE1: - UA_SI 0x0 # CIE Identifier Tag + .4byte 0x0 # CIE Identifier Tag .byte 0x1 # CIE Version .ascii "zR\0" # CIE Augmentation .byte 0x1 # uleb128 0x1; CIE Code Alignment Factor .byte 0x78 # sleb128 -8; CIE Data Alignment Factor .byte 26 # CIE RA Column .byte 0x1 # uleb128 0x1; Augmentation size - .byte FDE_ENCODING # FDE Encoding + .byte 0x1b # FDE Encoding (pcrel sdata4) .byte 0xc # DW_CFA_def_cfa .byte 30 # uleb128 column 30 .byte 0 # uleb128 offset 0 .align 3 $LECIE1: $LSFDE1: - UA_SI $LEFDE1-$LASFDE1 # FDE Length + .4byte $LEFDE1-$LASFDE1 # FDE Length $LASFDE1: - UA_SI $LASFDE1-__FRAME_BEGIN__ # FDE CIE offset - FDE_ENCODE($LFB1) # FDE initial location - FDE_ARANGE($LFE1-$LFB1) # FDE address range + .4byte $LASFDE1-__FRAME_BEGIN__ # FDE CIE offset + .4byte $LFB1-. # FDE initial location + .4byte $LFE1-$LFB1 # FDE address range .byte 0x0 # uleb128 0x0; Augmentation size .byte 0x4 # DW_CFA_advance_loc4 - UA_SI $LCFI1-$LFB1 + .4byte $LCFI1-$LFB1 .byte 0x9a # DW_CFA_offset, column 26 .byte 4 # uleb128 4*-8 .byte 0x8f # DW_CFA_offset, column 15 @@ -353,35 +335,32 @@ .byte 32 # uleb128 offset 32 .byte 0x4 # DW_CFA_advance_loc4 - UA_SI $LCFI2-$LCFI1 + .4byte $LCFI2-$LCFI1 .byte 0xda # DW_CFA_restore, column 26 .align 3 $LEFDE1: $LSFDE3: - UA_SI $LEFDE3-$LASFDE3 # FDE Length + .4byte $LEFDE3-$LASFDE3 # FDE Length $LASFDE3: - UA_SI $LASFDE3-__FRAME_BEGIN__ # FDE CIE offset - FDE_ENCODE($LFB2) # FDE initial location - FDE_ARANGE($LFE2-$LFB2) # FDE address range + .4byte $LASFDE3-__FRAME_BEGIN__ # FDE CIE offset + .4byte $LFB2-. # FDE initial location + .4byte $LFE2-$LFB2 # FDE address range .byte 0x0 # uleb128 0x0; Augmentation size .byte 0x4 # DW_CFA_advance_loc4 - UA_SI $LCFI5-$LFB2 + .4byte $LCFI5-$LFB2 .byte 0xe # DW_CFA_def_cfa_offset .byte 0x80,0x1 # uleb128 128 .byte 0x4 # DW_CFA_advance_loc4 - UA_SI $LCFI6-$LCFI5 + .4byte $LCFI6-$LCFI5 .byte 0x9a # DW_CFA_offset, column 26 .byte 16 # uleb128 offset 16*-8 .align 3 $LEFDE3: -#if defined __osf__ - .align 0 - .long 0 # End of Table -#endif -#if defined __ELF__ && defined __linux__ +#ifdef __linux__ .section .note.GNU-stack,"",@progbits #endif +#endif diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi/src/arm/ffi.c --- a/Modules/_ctypes/libffi/src/arm/ffi.c Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/_ctypes/libffi/src/arm/ffi.c Sun Jul 20 10:52:46 2014 -0400 @@ -1,10 +1,6 @@ /* ----------------------------------------------------------------------- - ffi.c - Copyright (c) 2011 Timothy Wall - Copyright (c) 2011 Plausible Labs Cooperative, Inc. - Copyright (c) 2011 Anthony Green - Copyright (c) 2011 Free Software Foundation - Copyright (c) 1998, 2008, 2011 Red Hat, Inc. - + ffi.c - Copyright (c) 1998, 2008 Red Hat, Inc. + ARM Foreign Function Interface Permission is hereby granted, free of charge, to any person obtaining @@ -33,20 +29,12 @@ #include -/* Forward declares. */ -static int vfp_type_p (ffi_type *); -static void layout_vfp_args (ffi_cif *); +/* ffi_prep_args is called by the assembly routine once stack space + has been allocated for the function's arguments */ -/* ffi_prep_args is called by the assembly routine once stack space - has been allocated for the function's arguments - - The vfp_space parameter is the load area for VFP regs, the return - value is cif->vfp_used (word bitset of VFP regs used for passing - arguments). These are only used for the VFP hard-float ABI. -*/ -int ffi_prep_args(char *stack, extended_cif *ecif, float *vfp_space) +void ffi_prep_args(char *stack, extended_cif *ecif) { - register unsigned int i, vi = 0; + register unsigned int i; register void **p_argv; register char *argp; register ffi_type **p_arg; @@ -65,31 +53,10 @@ i--, p_arg++) { size_t z; - size_t alignment; - - /* Allocated in VFP registers. */ - if (ecif->cif->abi == FFI_VFP - && vi < ecif->cif->vfp_nargs && vfp_type_p (*p_arg)) - { - float* vfp_slot = vfp_space + ecif->cif->vfp_args[vi++]; - if ((*p_arg)->type == FFI_TYPE_FLOAT) - *((float*)vfp_slot) = *((float*)*p_argv); - else if ((*p_arg)->type == FFI_TYPE_DOUBLE) - *((double*)vfp_slot) = *((double*)*p_argv); - else - memcpy(vfp_slot, *p_argv, (*p_arg)->size); - p_argv++; - continue; - } /* Align if necessary */ - alignment = (*p_arg)->alignment; -#ifdef _WIN32_WCE - if (alignment > 4) - alignment = 4; -#endif - if ((alignment - 1) & (unsigned) argp) { - argp = (char *) ALIGN(argp, alignment); + if (((*p_arg)->alignment - 1) & (unsigned) argp) { + argp = (char *) ALIGN(argp, (*p_arg)->alignment); } if ((*p_arg)->type == FFI_TYPE_STRUCT) @@ -136,15 +103,13 @@ p_argv++; argp += z; } - - /* Indicate the VFP registers used. */ - return ecif->cif->vfp_used; + + return; } /* Perform machine dependent cif processing */ ffi_status ffi_prep_cif_machdep(ffi_cif *cif) { - int type_code; /* Round the stack up to a multiple of 8 bytes. This isn't needed everywhere, but it is on some platforms, and it doesn't harm anything when it isn't needed. */ @@ -165,14 +130,7 @@ break; case FFI_TYPE_STRUCT: - if (cif->abi == FFI_VFP - && (type_code = vfp_type_p (cif->rtype)) != 0) - { - /* A Composite Type passed in VFP registers, either - FFI_TYPE_STRUCT_VFP_FLOAT or FFI_TYPE_STRUCT_VFP_DOUBLE. */ - cif->flags = (unsigned) type_code; - } - else if (cif->rtype->size <= 4) + if (cif->rtype->size <= 4) /* A Composite Type not larger than 4 bytes is returned in r0. */ cif->flags = (unsigned)FFI_TYPE_INT; else @@ -187,30 +145,11 @@ break; } - /* Map out the register placements of VFP register args. - The VFP hard-float calling conventions are slightly more sophisticated than - the base calling conventions, so we do it here instead of in ffi_prep_args(). */ - if (cif->abi == FFI_VFP) - layout_vfp_args (cif); - return FFI_OK; } -/* Perform machine dependent cif processing for variadic calls */ -ffi_status ffi_prep_cif_machdep_var(ffi_cif *cif, - unsigned int nfixedargs, - unsigned int ntotalargs) -{ - /* VFP variadic calls actually use the SYSV ABI */ - if (cif->abi == FFI_VFP) - cif->abi = FFI_SYSV; - - return ffi_prep_cif_machdep(cif); -} - -/* Prototypes for assembly functions, in sysv.S */ -extern void ffi_call_SYSV (void (*fn)(void), extended_cif *, unsigned, unsigned, unsigned *); -extern void ffi_call_VFP (void (*fn)(void), extended_cif *, unsigned, unsigned, unsigned *); +extern void ffi_call_SYSV(void (*)(char *, extended_cif *), extended_cif *, + unsigned, unsigned, unsigned *, void (*fn)(void)); void ffi_call(ffi_cif *cif, void (*fn)(void), void *rvalue, void **avalue) { @@ -218,8 +157,6 @@ int small_struct = (cif->flags == FFI_TYPE_INT && cif->rtype->type == FFI_TYPE_STRUCT); - int vfp_struct = (cif->flags == FFI_TYPE_STRUCT_VFP_FLOAT - || cif->flags == FFI_TYPE_STRUCT_VFP_DOUBLE); ecif.cif = cif; ecif.avalue = avalue; @@ -236,53 +173,38 @@ } else if (small_struct) ecif.rvalue = &temp; - else if (vfp_struct) - { - /* Largest case is double x 4. */ - ecif.rvalue = alloca(32); - } else ecif.rvalue = rvalue; switch (cif->abi) { case FFI_SYSV: - ffi_call_SYSV (fn, &ecif, cif->bytes, cif->flags, ecif.rvalue); + ffi_call_SYSV(ffi_prep_args, &ecif, cif->bytes, cif->flags, ecif.rvalue, + fn); + break; - - case FFI_VFP: -#ifdef __ARM_EABI__ - ffi_call_VFP (fn, &ecif, cif->bytes, cif->flags, ecif.rvalue); - break; -#endif - default: FFI_ASSERT(0); break; } if (small_struct) memcpy (rvalue, &temp, cif->rtype->size); - else if (vfp_struct) - memcpy (rvalue, ecif.rvalue, cif->rtype->size); } /** private members **/ static void ffi_prep_incoming_args_SYSV (char *stack, void **ret, - void** args, ffi_cif* cif, float *vfp_stack); + void** args, ffi_cif* cif); void ffi_closure_SYSV (ffi_closure *); -void ffi_closure_VFP (ffi_closure *); - /* This function is jumped to by the trampoline */ unsigned int -ffi_closure_SYSV_inner (closure, respp, args, vfp_args) +ffi_closure_SYSV_inner (closure, respp, args) ffi_closure *closure; void **respp; void *args; - void *vfp_args; { // our various things... ffi_cif *cif; @@ -297,7 +219,7 @@ * a structure, it will re-set RESP to point to the * structure return address. */ - ffi_prep_incoming_args_SYSV(args, respp, arg_area, cif, vfp_args); + ffi_prep_incoming_args_SYSV(args, respp, arg_area, cif); (closure->fun) (cif, *respp, arg_area, closure->user_data); @@ -307,12 +229,10 @@ /*@-exportheader@*/ static void ffi_prep_incoming_args_SYSV(char *stack, void **rvalue, - void **avalue, ffi_cif *cif, - /* Used only under VFP hard-float ABI. */ - float *vfp_stack) + void **avalue, ffi_cif *cif) /*@=exportheader@*/ { - register unsigned int i, vi = 0; + register unsigned int i; register void **p_argv; register char *argp; register ffi_type **p_arg; @@ -329,23 +249,10 @@ for (i = cif->nargs, p_arg = cif->arg_types; (i != 0); i--, p_arg++) { size_t z; - size_t alignment; - - if (cif->abi == FFI_VFP - && vi < cif->vfp_nargs && vfp_type_p (*p_arg)) - { - *p_argv++ = (void*)(vfp_stack + cif->vfp_args[vi++]); - continue; - } - alignment = (*p_arg)->alignment; + size_t alignment = (*p_arg)->alignment; if (alignment < 4) alignment = 4; -#ifdef _WIN32_WCE - else - if (alignment > 4) - alignment = 4; -#endif /* Align if necessary */ if ((alignment - 1) & (unsigned) argp) { argp = (char *) ALIGN(argp, alignment); @@ -366,237 +273,18 @@ /* How to make a trampoline. */ -extern unsigned int ffi_arm_trampoline[3]; - -#if FFI_EXEC_TRAMPOLINE_TABLE - -#include -#include -#include -#include - -extern void *ffi_closure_trampoline_table_page; - -typedef struct ffi_trampoline_table ffi_trampoline_table; -typedef struct ffi_trampoline_table_entry ffi_trampoline_table_entry; - -struct ffi_trampoline_table { - /* contigious writable and executable pages */ - vm_address_t config_page; - vm_address_t trampoline_page; - - /* free list tracking */ - uint16_t free_count; - ffi_trampoline_table_entry *free_list; - ffi_trampoline_table_entry *free_list_pool; - - ffi_trampoline_table *prev; - ffi_trampoline_table *next; -}; - -struct ffi_trampoline_table_entry { - void *(*trampoline)(); - ffi_trampoline_table_entry *next; -}; - -/* Override the standard architecture trampoline size */ -// XXX TODO - Fix -#undef FFI_TRAMPOLINE_SIZE -#define FFI_TRAMPOLINE_SIZE 12 - -/* The trampoline configuration is placed at 4080 bytes prior to the trampoline's entry point */ -#define FFI_TRAMPOLINE_CODELOC_CONFIG(codeloc) ((void **) (((uint8_t *) codeloc) - 4080)); - -/* The first 16 bytes of the config page are unused, as they are unaddressable from the trampoline page. */ -#define FFI_TRAMPOLINE_CONFIG_PAGE_OFFSET 16 - -/* Total number of trampolines that fit in one trampoline table */ -#define FFI_TRAMPOLINE_COUNT ((PAGE_SIZE - FFI_TRAMPOLINE_CONFIG_PAGE_OFFSET) / FFI_TRAMPOLINE_SIZE) - -static pthread_mutex_t ffi_trampoline_lock = PTHREAD_MUTEX_INITIALIZER; -static ffi_trampoline_table *ffi_trampoline_tables = NULL; - -static ffi_trampoline_table * -ffi_trampoline_table_alloc () -{ - ffi_trampoline_table *table = NULL; - - /* Loop until we can allocate two contigious pages */ - while (table == NULL) { - vm_address_t config_page = 0x0; - kern_return_t kt; - - /* Try to allocate two pages */ - kt = vm_allocate (mach_task_self (), &config_page, PAGE_SIZE*2, VM_FLAGS_ANYWHERE); - if (kt != KERN_SUCCESS) { - fprintf(stderr, "vm_allocate() failure: %d at %s:%d\n", kt, __FILE__, __LINE__); - break; - } - - /* Now drop the second half of the allocation to make room for the trampoline table */ - vm_address_t trampoline_page = config_page+PAGE_SIZE; - kt = vm_deallocate (mach_task_self (), trampoline_page, PAGE_SIZE); - if (kt != KERN_SUCCESS) { - fprintf(stderr, "vm_deallocate() failure: %d at %s:%d\n", kt, __FILE__, __LINE__); - break; - } - - /* Remap the trampoline table to directly follow the config page */ - vm_prot_t cur_prot; - vm_prot_t max_prot; - - kt = vm_remap (mach_task_self (), &trampoline_page, PAGE_SIZE, 0x0, FALSE, mach_task_self (), (vm_address_t) &ffi_closure_trampoline_table_page, FALSE, &cur_prot, &max_prot, VM_INHERIT_SHARE); - - /* If we lost access to the destination trampoline page, drop our config allocation mapping and retry */ - if (kt != KERN_SUCCESS) { - /* Log unexpected failures */ - if (kt != KERN_NO_SPACE) { - fprintf(stderr, "vm_remap() failure: %d at %s:%d\n", kt, __FILE__, __LINE__); - } - - vm_deallocate (mach_task_self (), config_page, PAGE_SIZE); - continue; - } - - /* We have valid trampoline and config pages */ - table = calloc (1, sizeof(ffi_trampoline_table)); - table->free_count = FFI_TRAMPOLINE_COUNT; - table->config_page = config_page; - table->trampoline_page = trampoline_page; - - /* Create and initialize the free list */ - table->free_list_pool = calloc(FFI_TRAMPOLINE_COUNT, sizeof(ffi_trampoline_table_entry)); - - uint16_t i; - for (i = 0; i < table->free_count; i++) { - ffi_trampoline_table_entry *entry = &table->free_list_pool[i]; - entry->trampoline = (void *) (table->trampoline_page + (i * FFI_TRAMPOLINE_SIZE)); - - if (i < table->free_count - 1) - entry->next = &table->free_list_pool[i+1]; - } - - table->free_list = table->free_list_pool; - } - - return table; -} - -void * -ffi_closure_alloc (size_t size, void **code) -{ - /* Create the closure */ - ffi_closure *closure = malloc(size); - if (closure == NULL) - return NULL; - - pthread_mutex_lock(&ffi_trampoline_lock); - - /* Check for an active trampoline table with available entries. */ - ffi_trampoline_table *table = ffi_trampoline_tables; - if (table == NULL || table->free_list == NULL) { - table = ffi_trampoline_table_alloc (); - if (table == NULL) { - free(closure); - return NULL; - } - - /* Insert the new table at the top of the list */ - table->next = ffi_trampoline_tables; - if (table->next != NULL) - table->next->prev = table; - - ffi_trampoline_tables = table; - } - - /* Claim the free entry */ - ffi_trampoline_table_entry *entry = ffi_trampoline_tables->free_list; - ffi_trampoline_tables->free_list = entry->next; - ffi_trampoline_tables->free_count--; - entry->next = NULL; - - pthread_mutex_unlock(&ffi_trampoline_lock); - - /* Initialize the return values */ - *code = entry->trampoline; - closure->trampoline_table = table; - closure->trampoline_table_entry = entry; - - return closure; -} - -void -ffi_closure_free (void *ptr) -{ - ffi_closure *closure = ptr; - - pthread_mutex_lock(&ffi_trampoline_lock); - - /* Fetch the table and entry references */ - ffi_trampoline_table *table = closure->trampoline_table; - ffi_trampoline_table_entry *entry = closure->trampoline_table_entry; - - /* Return the entry to the free list */ - entry->next = table->free_list; - table->free_list = entry; - table->free_count++; - - /* If all trampolines within this table are free, and at least one other table exists, deallocate - * the table */ - if (table->free_count == FFI_TRAMPOLINE_COUNT && ffi_trampoline_tables != table) { - /* Remove from the list */ - if (table->prev != NULL) - table->prev->next = table->next; - - if (table->next != NULL) - table->next->prev = table->prev; - - /* Deallocate pages */ - kern_return_t kt; - kt = vm_deallocate (mach_task_self (), table->config_page, PAGE_SIZE); - if (kt != KERN_SUCCESS) - fprintf(stderr, "vm_deallocate() failure: %d at %s:%d\n", kt, __FILE__, __LINE__); - - kt = vm_deallocate (mach_task_self (), table->trampoline_page, PAGE_SIZE); - if (kt != KERN_SUCCESS) - fprintf(stderr, "vm_deallocate() failure: %d at %s:%d\n", kt, __FILE__, __LINE__); - - /* Deallocate free list */ - free (table->free_list_pool); - free (table); - } else if (ffi_trampoline_tables != table) { - /* Otherwise, bump this table to the top of the list */ - table->prev = NULL; - table->next = ffi_trampoline_tables; - if (ffi_trampoline_tables != NULL) - ffi_trampoline_tables->prev = table; - - ffi_trampoline_tables = table; - } - - pthread_mutex_unlock (&ffi_trampoline_lock); - - /* Free the closure */ - free (closure); -} - -#else - #define FFI_INIT_TRAMPOLINE(TRAMP,FUN,CTX) \ ({ unsigned char *__tramp = (unsigned char*)(TRAMP); \ unsigned int __fun = (unsigned int)(FUN); \ unsigned int __ctx = (unsigned int)(CTX); \ - unsigned char *insns = (unsigned char *)(CTX); \ - memcpy (__tramp, ffi_arm_trampoline, sizeof ffi_arm_trampoline); \ + *(unsigned int*) &__tramp[0] = 0xe92d000f; /* stmfd sp!, {r0-r3} */ \ + *(unsigned int*) &__tramp[4] = 0xe59f0000; /* ldr r0, [pc] */ \ + *(unsigned int*) &__tramp[8] = 0xe59ff000; /* ldr pc, [pc] */ \ *(unsigned int*) &__tramp[12] = __ctx; \ *(unsigned int*) &__tramp[16] = __fun; \ - __clear_cache((&__tramp[0]), (&__tramp[19])); /* Clear data mapping. */ \ - __clear_cache(insns, insns + 3 * sizeof (unsigned int)); \ - /* Clear instruction \ - mapping. */ \ + __clear_cache((&__tramp[0]), (&__tramp[19])); \ }) -#endif /* the cif must already be prep'ed */ @@ -607,150 +295,15 @@ void *user_data, void *codeloc) { - void (*closure_func)(ffi_closure*) = NULL; + FFI_ASSERT (cif->abi == FFI_SYSV); - if (cif->abi == FFI_SYSV) - closure_func = &ffi_closure_SYSV; -#ifdef __ARM_EABI__ - else if (cif->abi == FFI_VFP) - closure_func = &ffi_closure_VFP; -#endif - else - return FFI_BAD_ABI; + FFI_INIT_TRAMPOLINE (&closure->tramp[0], \ + &ffi_closure_SYSV, \ + codeloc); -#if FFI_EXEC_TRAMPOLINE_TABLE - void **config = FFI_TRAMPOLINE_CODELOC_CONFIG(codeloc); - config[0] = closure; - config[1] = closure_func; -#else - FFI_INIT_TRAMPOLINE (&closure->tramp[0], \ - closure_func, \ - codeloc); -#endif - closure->cif = cif; closure->user_data = user_data; closure->fun = fun; return FFI_OK; } - -/* Below are routines for VFP hard-float support. */ - -static int rec_vfp_type_p (ffi_type *t, int *elt, int *elnum) -{ - switch (t->type) - { - case FFI_TYPE_FLOAT: - case FFI_TYPE_DOUBLE: - *elt = (int) t->type; - *elnum = 1; - return 1; - - case FFI_TYPE_STRUCT_VFP_FLOAT: - *elt = FFI_TYPE_FLOAT; - *elnum = t->size / sizeof (float); - return 1; - - case FFI_TYPE_STRUCT_VFP_DOUBLE: - *elt = FFI_TYPE_DOUBLE; - *elnum = t->size / sizeof (double); - return 1; - - case FFI_TYPE_STRUCT:; - { - int base_elt = 0, total_elnum = 0; - ffi_type **el = t->elements; - while (*el) - { - int el_elt = 0, el_elnum = 0; - if (! rec_vfp_type_p (*el, &el_elt, &el_elnum) - || (base_elt && base_elt != el_elt) - || total_elnum + el_elnum > 4) - return 0; - base_elt = el_elt; - total_elnum += el_elnum; - el++; - } - *elnum = total_elnum; - *elt = base_elt; - return 1; - } - default: ; - } - return 0; -} - -static int vfp_type_p (ffi_type *t) -{ - int elt, elnum; - if (rec_vfp_type_p (t, &elt, &elnum)) - { - if (t->type == FFI_TYPE_STRUCT) - { - if (elnum == 1) - t->type = elt; - else - t->type = (elt == FFI_TYPE_FLOAT - ? FFI_TYPE_STRUCT_VFP_FLOAT - : FFI_TYPE_STRUCT_VFP_DOUBLE); - } - return (int) t->type; - } - return 0; -} - -static void place_vfp_arg (ffi_cif *cif, ffi_type *t) -{ - int reg = cif->vfp_reg_free; - int nregs = t->size / sizeof (float); - int align = ((t->type == FFI_TYPE_STRUCT_VFP_FLOAT - || t->type == FFI_TYPE_FLOAT) ? 1 : 2); - /* Align register number. */ - if ((reg & 1) && align == 2) - reg++; - while (reg + nregs <= 16) - { - int s, new_used = 0; - for (s = reg; s < reg + nregs; s++) - { - new_used |= (1 << s); - if (cif->vfp_used & (1 << s)) - { - reg += align; - goto next_reg; - } - } - /* Found regs to allocate. */ - cif->vfp_used |= new_used; - cif->vfp_args[cif->vfp_nargs++] = reg; - - /* Update vfp_reg_free. */ - if (cif->vfp_used & (1 << cif->vfp_reg_free)) - { - reg += nregs; - while (cif->vfp_used & (1 << reg)) - reg += 1; - cif->vfp_reg_free = reg; - } - return; - next_reg: ; - } -} - -static void layout_vfp_args (ffi_cif *cif) -{ - int i; - /* Init VFP fields */ - cif->vfp_used = 0; - cif->vfp_nargs = 0; - cif->vfp_reg_free = 0; - memset (cif->vfp_args, -1, 16); /* Init to -1. */ - - for (i = 0; i < cif->nargs; i++) - { - ffi_type *t = cif->arg_types[i]; - if (vfp_type_p (t)) - place_vfp_arg (cif, t); - } -} diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi/src/arm/ffitarget.h --- a/Modules/_ctypes/libffi/src/arm/ffitarget.h Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/_ctypes/libffi/src/arm/ffitarget.h Sun Jul 20 10:52:46 2014 -0400 @@ -1,8 +1,5 @@ /* -----------------------------------------------------------------*-C-*- - ffitarget.h - Copyright (c) 2012 Anthony Green - Copyright (c) 2010 CodeSourcery - Copyright (c) 1996-2003 Red Hat, Inc. - + ffitarget.h - Copyright (c) 1996-2003 Red Hat, Inc. Target configuration macros for ARM. Permission is hereby granted, free of charge, to any person obtaining @@ -30,10 +27,6 @@ #ifndef LIBFFI_TARGET_H #define LIBFFI_TARGET_H -#ifndef LIBFFI_H -#error "Please do not include ffitarget.h directly into your source. Use ffi.h instead." -#endif - #ifndef LIBFFI_ASM typedef unsigned long ffi_arg; typedef signed long ffi_sarg; @@ -41,27 +34,11 @@ typedef enum ffi_abi { FFI_FIRST_ABI = 0, FFI_SYSV, - FFI_VFP, - FFI_LAST_ABI, -#ifdef __ARM_PCS_VFP - FFI_DEFAULT_ABI = FFI_VFP, -#else FFI_DEFAULT_ABI = FFI_SYSV, -#endif + FFI_LAST_ABI = FFI_DEFAULT_ABI + 1 } ffi_abi; #endif -#define FFI_EXTRA_CIF_FIELDS \ - int vfp_used; \ - short vfp_reg_free, vfp_nargs; \ - signed char vfp_args[16] \ - -/* Internally used. */ -#define FFI_TYPE_STRUCT_VFP_FLOAT (FFI_TYPE_LAST + 1) -#define FFI_TYPE_STRUCT_VFP_DOUBLE (FFI_TYPE_LAST + 2) - -#define FFI_TARGET_SPECIFIC_VARIADIC - /* ---- Definitions for closures ----------------------------------------- */ #define FFI_CLOSURES 1 @@ -69,3 +46,4 @@ #define FFI_NATIVE_RAW_API 0 #endif + diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi/src/arm/gentramp.sh --- a/Modules/_ctypes/libffi/src/arm/gentramp.sh Sat Jul 19 16:34:33 2014 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,118 +0,0 @@ -#!/bin/sh - -# ----------------------------------------------------------------------- -# gentramp.sh - Copyright (c) 2010, Plausible Labs Cooperative, Inc. -# -# ARM Trampoline Page Generator -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# ``Software''), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice shall be included -# in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, -# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT -# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -# DEALINGS IN THE SOFTWARE. -# ----------------------------------------------------------------------- - -PROGNAME=$0 - -# Each trampoline is exactly 3 instructions, or 12 bytes. If any of these values change, -# the entire arm trampoline implementation must be updated to match, too. - -# Size of an individual trampoline, in bytes -TRAMPOLINE_SIZE=12 - -# Page size, in bytes -PAGE_SIZE=4096 - -# Compute the size of the reachable config page; The first 16 bytes of the config page -# are unreachable due to our maximum pc-relative ldr offset. -PAGE_AVAIL=`expr $PAGE_SIZE - 16` - -# Compute the number of of available trampolines. -TRAMPOLINE_COUNT=`expr $PAGE_AVAIL / $TRAMPOLINE_SIZE` - -header () { - echo "# GENERATED CODE - DO NOT EDIT" - echo "# This file was generated by $PROGNAME" - echo "" - - # Write out the license header -cat << EOF -# Copyright (c) 2010, Plausible Labs Cooperative, Inc. -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# ``Software''), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice shall be included -# in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, -# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT -# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -# DEALINGS IN THE SOFTWARE. -# ----------------------------------------------------------------------- - -EOF - - # Write out the trampoline table, aligned to the page boundary - echo ".text" - echo ".align 12" - echo ".globl _ffi_closure_trampoline_table_page" - echo "_ffi_closure_trampoline_table_page:" -} - - -# WARNING - Don't modify the trampoline code size without also updating the relevent libffi code -trampoline () { - cat << END - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - -END -} - -main () { - # Write out the header - header - - # Write out the trampolines - local i=0 - while [ $i -lt ${TRAMPOLINE_COUNT} ]; do - trampoline - local i=`expr $i + 1` - done -} - -main diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi/src/arm/sysv.S --- a/Modules/_ctypes/libffi/src/arm/sysv.S Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/_ctypes/libffi/src/arm/sysv.S Sun Jul 20 10:52:46 2014 -0400 @@ -1,6 +1,5 @@ /* ----------------------------------------------------------------------- - sysv.S - Copyright (c) 1998, 2008, 2011 Red Hat, Inc. - Copyright (c) 2011 Plausible Labs Cooperative, Inc. + sysv.S - Copyright (c) 1998, 2008 Red Hat, Inc. ARM Foreign Function Interface @@ -40,11 +39,7 @@ #else #define CNAME(x) x #endif -#ifdef __APPLE__ -#define ENTRY(x) .globl _##x; _##x: -#else #define ENTRY(x) .globl CNAME(x); .type CNAME(x),%function; CNAME(x): -#endif /* __APPLE__ */ #endif #ifdef __ELF__ @@ -53,12 +48,6 @@ #define LSYM(x) x #endif -/* Use the SOFTFP return value ABI on Mac OS X, as per the iOS ABI - Function Call Guide */ -#ifdef __APPLE__ -#define __SOFTFP__ -#endif - /* We need a better way of testing for this, but for now, this is all we can do. */ @ This selects the minimum architecture level required. @@ -116,33 +105,21 @@ .align 0 .thumb .thumb_func -#ifdef __APPLE__ - ENTRY($0) -#else ENTRY(\name) -#endif bx pc nop .arm UNWIND .fnstart /* A hook to tell gdb that we've switched to ARM mode. Also used to call directly from other local arm routines. */ -#ifdef __APPLE__ -_L__$0: -#else -_L__\name: -#endif +_L__\name: .endm #else .macro ARM_FUNC_START name .text .align 0 .arm -#ifdef __APPLE__ - ENTRY($0) -#else ENTRY(\name) -#endif UNWIND .fnstart .endm #endif @@ -164,11 +141,13 @@ #endif .endm + @ r0: ffi_prep_args @ r1: &ecif @ r2: cif->bytes @ r3: fig->flags @ sp+0: ecif.rvalue + @ sp+4: fn @ This assumes we are using gas. ARM_FUNC_START ffi_call_SYSV @@ -183,23 +162,24 @@ sub sp, fp, r2 @ Place all of the ffi_prep_args in position + mov ip, r0 mov r0, sp @ r1 already set @ Call ffi_prep_args(stack, &ecif) - bl CNAME(ffi_prep_args) + call_reg(ip) @ move first 4 parameters in registers ldmia sp, {r0-r3} @ and adjust stack - sub lr, fp, sp @ cif->bytes == fp - sp - ldr ip, [fp] @ load fn() in advance - cmp lr, #16 - movhs lr, #16 - add sp, sp, lr + ldr ip, [fp, #8] + cmp ip, #16 + movhs ip, #16 + add sp, sp, ip @ call (fn) (...) + ldr ip, [fp, #28] call_reg(ip) @ Remove the space we pushed for the args @@ -244,19 +224,11 @@ #endif LSYM(Lepilogue): -#if defined (__INTERWORKING__) - ldmia sp!, {r0-r3,fp, lr} - bx lr -#else - ldmia sp!, {r0-r3,fp, pc} -#endif + RETLDM "r0-r3,fp" .ffi_call_SYSV_end: UNWIND .fnend -#ifdef __ELF__ .size CNAME(ffi_call_SYSV),.ffi_call_SYSV_end-CNAME(ffi_call_SYSV) -#endif - /* unsigned int FFI_HIDDEN @@ -272,11 +244,11 @@ stmfd sp!, {ip, lr} UNWIND .save {r0, lr} add r2, sp, #8 - UNWIND .pad #16 + .pad #16 sub sp, sp, #16 str sp, [sp, #8] add r1, sp, #8 - bl CNAME(ffi_closure_SYSV_inner) + bl ffi_closure_SYSV_inner cmp r0, #FFI_TYPE_INT beq .Lretint @@ -328,177 +300,7 @@ .ffi_closure_SYSV_end: UNWIND .fnend -#ifdef __ELF__ .size CNAME(ffi_closure_SYSV),.ffi_closure_SYSV_end-CNAME(ffi_closure_SYSV) -#endif - - -/* Below are VFP hard-float ABI call and closure implementations. - Add VFP FPU directive here. This is only compiled into the library - under EABI. */ -#ifdef __ARM_EABI__ - .fpu vfp - - @ r0: fn - @ r1: &ecif - @ r2: cif->bytes - @ r3: fig->flags - @ sp+0: ecif.rvalue - -ARM_FUNC_START ffi_call_VFP - @ Save registers - stmfd sp!, {r0-r3, fp, lr} - UNWIND .save {r0-r3, fp, lr} - mov fp, sp - UNWIND .setfp fp, sp - - @ Make room for all of the new args. - sub sp, sp, r2 - - @ Make room for loading VFP args - sub sp, sp, #64 - - @ Place all of the ffi_prep_args in position - mov r0, sp - @ r1 already set - sub r2, fp, #64 @ VFP scratch space - - @ Call ffi_prep_args(stack, &ecif, vfp_space) - bl CNAME(ffi_prep_args) - - @ Load VFP register args if needed - cmp r0, #0 - beq LSYM(Lbase_args) - - @ Load only d0 if possible - cmp r0, #3 - sub ip, fp, #64 - flddle d0, [ip] - fldmiadgt ip, {d0-d7} - -LSYM(Lbase_args): - @ move first 4 parameters in registers - ldmia sp, {r0-r3} - - @ and adjust stack - sub lr, ip, sp @ cif->bytes == (fp - 64) - sp - ldr ip, [fp] @ load fn() in advance - cmp lr, #16 - movhs lr, #16 - add sp, sp, lr - - @ call (fn) (...) - call_reg(ip) - - @ Remove the space we pushed for the args - mov sp, fp - - @ Load r2 with the pointer to storage for - @ the return value - ldr r2, [sp, #24] - - @ Load r3 with the return type code - ldr r3, [sp, #12] - - @ If the return value pointer is NULL, - @ assume no return value. - cmp r2, #0 - beq LSYM(Lepilogue_vfp) - - cmp r3, #FFI_TYPE_INT - streq r0, [r2] - beq LSYM(Lepilogue_vfp) - - cmp r3, #FFI_TYPE_SINT64 - stmeqia r2, {r0, r1} - beq LSYM(Lepilogue_vfp) - - cmp r3, #FFI_TYPE_FLOAT - fstseq s0, [r2] - beq LSYM(Lepilogue_vfp) - - cmp r3, #FFI_TYPE_DOUBLE - fstdeq d0, [r2] - beq LSYM(Lepilogue_vfp) - - cmp r3, #FFI_TYPE_STRUCT_VFP_FLOAT - cmpne r3, #FFI_TYPE_STRUCT_VFP_DOUBLE - fstmiadeq r2, {d0-d3} - -LSYM(Lepilogue_vfp): - RETLDM "r0-r3,fp" - -.ffi_call_VFP_end: - UNWIND .fnend - .size CNAME(ffi_call_VFP),.ffi_call_VFP_end-CNAME(ffi_call_VFP) - - -ARM_FUNC_START ffi_closure_VFP - fstmfdd sp!, {d0-d7} - @ r0-r3, then d0-d7 - UNWIND .pad #80 - add ip, sp, #80 - stmfd sp!, {ip, lr} - UNWIND .save {r0, lr} - add r2, sp, #72 - add r3, sp, #8 - UNWIND .pad #72 - sub sp, sp, #72 - str sp, [sp, #64] - add r1, sp, #64 - bl CNAME(ffi_closure_SYSV_inner) - - cmp r0, #FFI_TYPE_INT - beq .Lretint_vfp - - cmp r0, #FFI_TYPE_FLOAT - beq .Lretfloat_vfp - - cmp r0, #FFI_TYPE_DOUBLE - cmpne r0, #FFI_TYPE_LONGDOUBLE - beq .Lretdouble_vfp - - cmp r0, #FFI_TYPE_SINT64 - beq .Lretlonglong_vfp - - cmp r0, #FFI_TYPE_STRUCT_VFP_FLOAT - beq .Lretfloat_struct_vfp - - cmp r0, #FFI_TYPE_STRUCT_VFP_DOUBLE - beq .Lretdouble_struct_vfp - -.Lclosure_epilogue_vfp: - add sp, sp, #72 - ldmfd sp, {sp, pc} - -.Lretfloat_vfp: - flds s0, [sp] - b .Lclosure_epilogue_vfp -.Lretdouble_vfp: - fldd d0, [sp] - b .Lclosure_epilogue_vfp -.Lretint_vfp: - ldr r0, [sp] - b .Lclosure_epilogue_vfp -.Lretlonglong_vfp: - ldmia sp, {r0, r1} - b .Lclosure_epilogue_vfp -.Lretfloat_struct_vfp: - fldmiad sp, {d0-d1} - b .Lclosure_epilogue_vfp -.Lretdouble_struct_vfp: - fldmiad sp, {d0-d3} - b .Lclosure_epilogue_vfp - -.ffi_closure_VFP_end: - UNWIND .fnend - .size CNAME(ffi_closure_VFP),.ffi_closure_VFP_end-CNAME(ffi_closure_VFP) -#endif - -ENTRY(ffi_arm_trampoline) - stmfd sp!, {r0-r3} - ldr r0, [pc] - ldr pc, [pc] #if defined __ELF__ && defined __linux__ .section .note.GNU-stack,"",%progbits diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi/src/arm/trampoline.S --- a/Modules/_ctypes/libffi/src/arm/trampoline.S Sat Jul 19 16:34:33 2014 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,4450 +0,0 @@ -# GENERATED CODE - DO NOT EDIT -# This file was generated by src/arm/gentramp.sh - -# Copyright (c) 2010, Plausible Labs Cooperative, Inc. -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# Software''), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice shall be included -# in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED AS IS'', WITHOUT WARRANTY OF ANY KIND, -# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT -# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -# DEALINGS IN THE SOFTWARE. -# ----------------------------------------------------------------------- - -.text -.align 12 -.globl _ffi_closure_trampoline_table_page -_ffi_closure_trampoline_table_page: - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - - - // trampoline - // Save to stack - stmfd sp!, {r0-r3} - - // Load the context argument from the config page. - // This places the first usable config value at _ffi_closure_trampoline_table-4080 - // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc. - ldr r0, [pc, #-4092] - - // Load the jump address from the config page. - ldr pc, [pc, #-4092] - diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi/src/avr32/ffi.c --- a/Modules/_ctypes/libffi/src/avr32/ffi.c Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/_ctypes/libffi/src/avr32/ffi.c Sun Jul 20 10:52:46 2014 -0400 @@ -1,6 +1,5 @@ /* ----------------------------------------------------------------------- - ffi.c - Copyright (c) 2011 Anthony Green - Copyright (c) 2009 Bradley Smith + ffi.c - Copyright (c) 2009 Bradley Smith AVR32 Foreign Function Interface @@ -395,8 +394,7 @@ void (*fun)(ffi_cif*, void*, void**, void*), void *user_data, void *codeloc) { - if (cif->abi != FFI_SYSV) - return FFI_BAD_ABI; + FFI_ASSERT(cif->abi == FFI_SYSV); unsigned char *__tramp = (unsigned char*)(&closure->tramp[0]); unsigned int __fun = (unsigned int)(&ffi_closure_SYSV); diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi/src/avr32/ffitarget.h --- a/Modules/_ctypes/libffi/src/avr32/ffitarget.h Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/_ctypes/libffi/src/avr32/ffitarget.h Sun Jul 20 10:52:46 2014 -0400 @@ -1,6 +1,5 @@ /* -----------------------------------------------------------------*-C-*- - ffitarget.h - Copyright (c) 2012 Anthony Green - Copyright (c) 2009 Bradley Smith + ffitarget.h - Copyright (c) 2009 Bradley Smith Target configuration macros for AVR32. Permission is hereby granted, free of charge, to any person obtaining @@ -28,10 +27,6 @@ #ifndef LIBFFI_TARGET_H #define LIBFFI_TARGET_H -#ifndef LIBFFI_H -#error "Please do not include ffitarget.h directly into your source. Use ffi.h instead." -#endif - #ifndef LIBFFI_ASM typedef unsigned long ffi_arg; typedef signed long ffi_sarg; @@ -39,8 +34,8 @@ typedef enum ffi_abi { FFI_FIRST_ABI = 0, FFI_SYSV, - FFI_LAST_ABI, - FFI_DEFAULT_ABI = FFI_SYSV + FFI_DEFAULT_ABI = FFI_SYSV, + FFI_LAST_ABI = FFI_DEFAULT_ABI + 1 } ffi_abi; #endif diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi/src/bfin/ffi.c --- a/Modules/_ctypes/libffi/src/bfin/ffi.c Sat Jul 19 16:34:33 2014 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,195 +0,0 @@ -/* ----------------------------------------------------------------------- - ffi.c - Copyright (c) 2012 Alexandre K. I. de Mendonca - - Blackfin Foreign Function Interface - - Permission is hereby granted, free of charge, to any person obtaining - a copy of this software and associated documentation files (the - ``Software''), to deal in the Software without restriction, including - without limitation the rights to use, copy, modify, merge, publish, - distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to - the following conditions: - - The above copyright notice and this permission notice shall be included - in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT - HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, - WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - DEALINGS IN THE SOFTWARE. - ----------------------------------------------------------------------- */ -#include -#include - -#include -#include - -/* Maximum number of GPRs available for argument passing. */ -#define MAX_GPRARGS 3 - -/* - * Return types - */ -#define FFIBFIN_RET_VOID 0 -#define FFIBFIN_RET_BYTE 1 -#define FFIBFIN_RET_HALFWORD 2 -#define FFIBFIN_RET_INT64 3 -#define FFIBFIN_RET_INT32 4 - -/*====================================================================*/ -/* PROTOTYPE * - /*====================================================================*/ -void ffi_prep_args(unsigned char *, extended_cif *); - -/*====================================================================*/ -/* Externals */ -/* (Assembly) */ -/*====================================================================*/ - -extern void ffi_call_SYSV(unsigned, extended_cif *, void(*)(unsigned char *, extended_cif *), unsigned, void *, void(*fn)(void)); - -/*====================================================================*/ -/* Implementation */ -/* */ -/*====================================================================*/ - - -/* - * This function calculates the return type (size) based on type. - */ - -ffi_status ffi_prep_cif_machdep(ffi_cif *cif) -{ - /* --------------------------------------* - * Return handling * - * --------------------------------------*/ - switch (cif->rtype->type) { - case FFI_TYPE_VOID: - cif->flags = FFIBFIN_RET_VOID; - break; - case FFI_TYPE_UINT16: - case FFI_TYPE_SINT16: - cif->flags = FFIBFIN_RET_HALFWORD; - break; - case FFI_TYPE_UINT8: - cif->flags = FFIBFIN_RET_BYTE; - break; - case FFI_TYPE_INT: - case FFI_TYPE_UINT32: - case FFI_TYPE_SINT32: - case FFI_TYPE_FLOAT: - case FFI_TYPE_POINTER: - case FFI_TYPE_SINT8: - cif->flags = FFIBFIN_RET_INT32; - break; - case FFI_TYPE_SINT64: - case FFI_TYPE_UINT64: - case FFI_TYPE_DOUBLE: - cif->flags = FFIBFIN_RET_INT64; - break; - case FFI_TYPE_STRUCT: - if (cif->rtype->size <= 4){ - cif->flags = FFIBFIN_RET_INT32; - }else if (cif->rtype->size == 8){ - cif->flags = FFIBFIN_RET_INT64; - }else{ - //it will return via a hidden pointer in P0 - cif->flags = FFIBFIN_RET_VOID; - } - break; - default: - FFI_ASSERT(0); - break; - } - return FFI_OK; -} - -/* - * This will prepare the arguments and will call the assembly routine - * cif = the call interface - * fn = the function to be called - * rvalue = the return value - * avalue = the arguments - */ -void ffi_call(ffi_cif *cif, void(*fn)(void), void *rvalue, void **avalue) -{ - int ret_type = cif->flags; - extended_cif ecif; - ecif.cif = cif; - ecif.avalue = avalue; - ecif.rvalue = rvalue; - - switch (cif->abi) { - case FFI_SYSV: - ffi_call_SYSV(cif->bytes, &ecif, ffi_prep_args, ret_type, ecif.rvalue, fn); - break; - default: - FFI_ASSERT(0); - break; - } -} - - -/* -* This function prepares the parameters (copies them from the ecif to the stack) -* to call the function (ffi_prep_args is called by the assembly routine in file -* sysv.S, which also calls the actual function) -*/ -void ffi_prep_args(unsigned char *stack, extended_cif *ecif) -{ - register unsigned int i = 0; - void **p_argv; - unsigned char *argp; - ffi_type **p_arg; - argp = stack; - p_argv = ecif->avalue; - for (i = ecif->cif->nargs, p_arg = ecif->cif->arg_types; - (i != 0); - i--, p_arg++) { - size_t z; - z = (*p_arg)->size; - if (z < sizeof(int)) { - z = sizeof(int); - switch ((*p_arg)->type) { - case FFI_TYPE_SINT8: { - signed char v = *(SINT8 *)(* p_argv); - signed int t = v; - *(signed int *) argp = t; - } - break; - case FFI_TYPE_UINT8: { - unsigned char v = *(UINT8 *)(* p_argv); - unsigned int t = v; - *(unsigned int *) argp = t; - } - break; - case FFI_TYPE_SINT16: - *(signed int *) argp = (signed int) * (SINT16 *)(* p_argv); - break; - case FFI_TYPE_UINT16: - *(unsigned int *) argp = (unsigned int) * (UINT16 *)(* p_argv); - break; - case FFI_TYPE_STRUCT: - memcpy(argp, *p_argv, (*p_arg)->size); - break; - default: - FFI_ASSERT(0); - break; - } - } else if (z == sizeof(int)) { - *(unsigned int *) argp = (unsigned int) * (UINT32 *)(* p_argv); - } else { - memcpy(argp, *p_argv, z); - } - p_argv++; - argp += z; - } -} - - - diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi/src/bfin/ffitarget.h --- a/Modules/_ctypes/libffi/src/bfin/ffitarget.h Sat Jul 19 16:34:33 2014 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,43 +0,0 @@ -/* ----------------------------------------------------------------------- - ffitarget.h - Copyright (c) 2012 Alexandre K. I. de Mendonca - - Blackfin Foreign Function Interface - - Permission is hereby granted, free of charge, to any person obtaining - a copy of this software and associated documentation files (the - ``Software''), to deal in the Software without restriction, including - without limitation the rights to use, copy, modify, merge, publish, - distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to - the following conditions: - - The above copyright notice and this permission notice shall be included - in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT - HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, - WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - DEALINGS IN THE SOFTWARE. - ----------------------------------------------------------------------- */ - -#ifndef LIBFFI_TARGET_H -#define LIBFFI_TARGET_H - -#ifndef LIBFFI_ASM -typedef unsigned long ffi_arg; -typedef signed long ffi_sarg; - -typedef enum ffi_abi { - FFI_FIRST_ABI = 0, - FFI_SYSV, - FFI_LAST_ABI, - FFI_DEFAULT_ABI = FFI_SYSV -} ffi_abi; -#endif - -#endif - diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi/src/bfin/sysv.S --- a/Modules/_ctypes/libffi/src/bfin/sysv.S Sat Jul 19 16:34:33 2014 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,177 +0,0 @@ -/* ----------------------------------------------------------------------- - sysv.S - Copyright (c) 2012 Alexandre K. I. de Mendonca - - Blackfin Foreign Function Interface - - Permission is hereby granted, free of charge, to any person obtaining - a copy of this software and associated documentation files (the - ``Software''), to deal in the Software without restriction, including - without limitation the rights to use, copy, modify, merge, publish, - distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to - the following conditions: - - The above copyright notice and this permission notice shall be included - in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT - HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, - WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - DEALINGS IN THE SOFTWARE. - ----------------------------------------------------------------------- */ - -#define LIBFFI_ASM -#include -#include - -.text -.align 4 - - /* - There is a "feature" in the bfin toolchain that it puts a _ before funcion names - that's why the function here it's called _ffi_call_SYSV and not ffi_call_SYSV - */ - .global _ffi_call_SYSV; - .type _ffi_call_SYSV, STT_FUNC; - .func ffi_call_SYSV - - /* - cif->bytes = R0 (fp+8) - &ecif = R1 (fp+12) - ffi_prep_args = R2 (fp+16) - ret_type = stack (fp+20) - ecif.rvalue = stack (fp+24) - fn = stack (fp+28) - got (fp+32) - There is room for improvement here (we can use temporary registers - instead of saving the values in the memory) - REGS: - P5 => Stack pointer (function arguments) - R5 => cif->bytes - R4 => ret->type - - FP-20 = P3 - FP-16 = SP (parameters area) - FP-12 = SP (temp) - FP-08 = function return part 1 [R0] - FP-04 = function return part 2 [R1] - */ - -_ffi_call_SYSV: -.prologue: - LINK 20; - [FP-20] = P3; - [FP+8] = R0; - [FP+12] = R1; - [FP+16] = R2; - -.allocate_stack: - //alocate cif->bytes into the stack - R1 = [FP+8]; - R0 = SP; - R0 = R0 - R1; - R1 = 4; - R0 = R0 - R1; - [FP-12] = SP; - SP = R0; - [FP-16] = SP; - -.call_prep_args: - //get the addr of prep_args - P0 = [P3 + _ffi_prep_args@FUNCDESC_GOT17M4]; - P1 = [P0]; - P3 = [P0+4]; - R0 = [FP-16];//SP (parameter area) - R1 = [FP+12];//ecif - call (P1); - -.call_user_function: - //ajust SP so as to allow the user function access the parameters on the stack - SP = [FP-16]; //point to function parameters - R0 = [SP]; - R1 = [SP+4]; - R2 = [SP+8]; - //load user function address - P0 = FP; - P0 +=28; - P1 = [P0]; - P1 = [P1]; - P3 = [P0+4]; - /* - For functions returning aggregate values (struct) occupying more than 8 bytes, - the caller allocates the return value object on the stack and the address - of this object is passed to the callee as a hidden argument in register P0. - */ - P0 = [FP+24]; - - call (P1); - SP = [FP-12]; -.compute_return: - P2 = [FP-20]; - [FP-8] = R0; - [FP-4] = R1; - - R0 = [FP+20]; - R1 = R0 << 2; - - R0 = [P2+.rettable@GOT17M4]; - R0 = R1 + R0; - P2 = R0; - R1 = [P2]; - - P2 = [FP+-20]; - R0 = [P2+.rettable@GOT17M4]; - R0 = R1 + R0; - P2 = R0; - R0 = [FP-8]; - R1 = [FP-4]; - jump (P2); - -/* -#define FFIBFIN_RET_VOID 0 -#define FFIBFIN_RET_BYTE 1 -#define FFIBFIN_RET_HALFWORD 2 -#define FFIBFIN_RET_INT64 3 -#define FFIBFIN_RET_INT32 4 -*/ -.align 4 -.align 4 -.rettable: - .dd .epilogue - .rettable - .dd .rbyte - .rettable; - .dd .rhalfword - .rettable; - .dd .rint64 - .rettable; - .dd .rint32 - .rettable; - -.rbyte: - P0 = [FP+24]; - R0 = R0.B (Z); - [P0] = R0; - JUMP .epilogue -.rhalfword: - P0 = [FP+24]; - R0 = R0.L; - [P0] = R0; - JUMP .epilogue -.rint64: - P0 = [FP+24];// &rvalue - [P0] = R0; - [P0+4] = R1; - JUMP .epilogue -.rint32: - P0 = [FP+24]; - [P0] = R0; -.epilogue: - R0 = [FP+8]; - R1 = [FP+12]; - R2 = [FP+16]; - P3 = [FP-20]; - UNLINK; - RTS; - -.size _ffi_call_SYSV,.-_ffi_call_SYSV; -.endfunc diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi/src/closures.c --- a/Modules/_ctypes/libffi/src/closures.c Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/_ctypes/libffi/src/closures.c Sun Jul 20 10:52:46 2014 -0400 @@ -1,7 +1,6 @@ /* ----------------------------------------------------------------------- - closures.c - Copyright (c) 2007, 2009, 2010 Red Hat, Inc. - Copyright (C) 2007, 2009, 2010 Free Software Foundation, Inc - Copyright (c) 2011 Plausible Labs Cooperative, Inc. + closures.c - Copyright (c) 2007 Red Hat, Inc. + Copyright (C) 2007, 2009 Free Software Foundation, Inc Code to allocate and deallocate memory for closures. @@ -33,7 +32,7 @@ #include #include -#if !FFI_MMAP_EXEC_WRIT && !FFI_EXEC_TRAMPOLINE_TABLE +#ifndef FFI_MMAP_EXEC_WRIT # if __gnu_linux__ /* This macro indicates it may be forbidden to map anonymous memory with both write and execute permission. Code compiled when this @@ -45,7 +44,7 @@ # define FFI_MMAP_EXEC_WRIT 1 # define HAVE_MNTENT 1 # endif -# if defined(X86_WIN32) || defined(X86_WIN64) || defined(__OS2__) +# if defined(X86_WIN32) || defined(X86_WIN64) /* Windows systems may have Data Execution Protection (DEP) enabled, which requires the use of VirtualMalloc/VirtualFree to alloc/free executable memory. */ @@ -64,11 +63,7 @@ #if FFI_CLOSURES -# if FFI_EXEC_TRAMPOLINE_TABLE - -// Per-target implementation; It's unclear what can reasonable be shared between two OS/architecture implementations. - -# elif FFI_MMAP_EXEC_WRIT /* !FFI_EXEC_TRAMPOLINE_TABLE */ +# if FFI_MMAP_EXEC_WRIT #define USE_LOCKS 1 #define USE_DL_PREFIX 1 @@ -151,7 +146,7 @@ p = strchr (p + 1, ' '); if (p == NULL) break; - if (strncmp (p + 1, "selinuxfs ", 10) == 0) + if (strncmp (p + 1, "selinuxfs ", 10) != 0) { free (buf); fclose (f); @@ -172,26 +167,7 @@ #endif /* !FFI_MMAP_EXEC_SELINUX */ -/* On PaX enable kernels that have MPROTECT enable we can't use PROT_EXEC. */ -#ifdef FFI_MMAP_EXEC_EMUTRAMP_PAX -#include - -static int emutramp_enabled = -1; - -static int -emutramp_enabled_check (void) -{ - if (getenv ("FFI_DISABLE_EMUTRAMP") == NULL) - return 1; - else - return 0; -} - -#define is_emutramp_enabled() (emutramp_enabled >= 0 ? emutramp_enabled \ - : (emutramp_enabled = emutramp_enabled_check ())) -#endif /* FFI_MMAP_EXEC_EMUTRAMP_PAX */ - -#elif defined (__CYGWIN__) || defined(__INTERIX) +#elif defined (__CYGWIN__) #include @@ -200,10 +176,6 @@ #endif /* !defined(X86_WIN32) && !defined(X86_WIN64) */ -#ifndef FFI_MMAP_EXEC_EMUTRAMP_PAX -#define is_emutramp_enabled() 0 -#endif /* FFI_MMAP_EXEC_EMUTRAMP_PAX */ - /* Declare all functions defined in dlmalloc.c as static. */ static void *dlmalloc(size_t); static void dlfree(void*); @@ -221,11 +193,11 @@ static size_t dlmalloc_usable_size(void*) MAYBE_UNUSED; static void dlmalloc_stats(void) MAYBE_UNUSED; -#if !(defined(X86_WIN32) || defined(X86_WIN64) || defined(__OS2__)) || defined (__CYGWIN__) || defined(__INTERIX) +#if !(defined(X86_WIN32) || defined(X86_WIN64)) || defined (__CYGWIN__) /* Use these for mmap and munmap within dlmalloc.c. */ static void *dlmmap(void *, size_t, int, int, int, off_t); static int dlmunmap(void *, size_t); -#endif /* !(defined(X86_WIN32) || defined(X86_WIN64) || defined(__OS2__)) || defined (__CYGWIN__) || defined(__INTERIX) */ +#endif /* !(defined(X86_WIN32) || defined(X86_WIN64)) || defined (__CYGWIN__) */ #define mmap dlmmap #define munmap dlmunmap @@ -235,7 +207,7 @@ #undef mmap #undef munmap -#if !(defined(X86_WIN32) || defined(X86_WIN64) || defined(__OS2__)) || defined (__CYGWIN__) || defined(__INTERIX) +#if !(defined(X86_WIN32) || defined(X86_WIN64)) || defined (__CYGWIN__) /* A mutex used to synchronize access to *exec* variables in this file. */ static pthread_mutex_t open_temp_exec_file_mutex = PTHREAD_MUTEX_INITIALIZER; @@ -322,7 +294,7 @@ struct mntent mnt; char buf[MAXPATHLEN * 3]; - if (getmntent_r (last_mntent, &mnt, buf, sizeof (buf)) == NULL) + if (getmntent_r (last_mntent, &mnt, buf, sizeof (buf))) return -1; if (hasmntopt (&mnt, "ro") @@ -481,12 +453,6 @@ printf ("mapping in %zi\n", length); #endif - if (execfd == -1 && is_emutramp_enabled ()) - { - ptr = mmap (start, length, prot & ~PROT_EXEC, flags, fd, offset); - return ptr; - } - if (execfd == -1 && !is_selinux_enabled ()) { ptr = mmap (start, length, prot | PROT_EXEC, flags, fd, offset); @@ -556,7 +522,7 @@ } #endif -#endif /* !(defined(X86_WIN32) || defined(X86_WIN64) || defined(__OS2__)) || defined (__CYGWIN__) || defined(__INTERIX) */ +#endif /* !(defined(X86_WIN32) || defined(X86_WIN64)) || defined (__CYGWIN__) */ /* Allocate a chunk of memory with the given size. Returns a pointer to the writable address, and sets *CODE to the executable diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi/src/cris/ffi.c --- a/Modules/_ctypes/libffi/src/cris/ffi.c Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/_ctypes/libffi/src/cris/ffi.c Sun Jul 20 10:52:46 2014 -0400 @@ -153,24 +153,21 @@ return (struct_count); } -ffi_status FFI_HIDDEN -ffi_prep_cif_core (ffi_cif * cif, - ffi_abi abi, unsigned int isvariadic, - unsigned int nfixedargs, unsigned int ntotalargs, - ffi_type * rtype, ffi_type ** atypes) +ffi_status +ffi_prep_cif (ffi_cif * cif, + ffi_abi abi, unsigned int nargs, + ffi_type * rtype, ffi_type ** atypes) { unsigned bytes = 0; unsigned int i; ffi_type **ptr; FFI_ASSERT (cif != NULL); - FFI_ASSERT((!isvariadic) || (nfixedargs >= 1)); - FFI_ASSERT(nfixedargs <= ntotalargs); - FFI_ASSERT (abi > FFI_FIRST_ABI && abi < FFI_LAST_ABI); + FFI_ASSERT ((abi > FFI_FIRST_ABI) && (abi <= FFI_DEFAULT_ABI)); cif->abi = abi; cif->arg_types = atypes; - cif->nargs = ntotalargs; + cif->nargs = nargs; cif->rtype = rtype; cif->flags = 0; diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi/src/cris/ffitarget.h --- a/Modules/_ctypes/libffi/src/cris/ffitarget.h Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/_ctypes/libffi/src/cris/ffitarget.h Sun Jul 20 10:52:46 2014 -0400 @@ -1,6 +1,5 @@ /* -----------------------------------------------------------------*-C-*- - ffitarget.h - Copyright (c) 2012 Anthony Green - Copyright (c) 1996-2003 Red Hat, Inc. + ffitarget.h - Copyright (c) 1996-2003 Red Hat, Inc. Target configuration macros for CRIS. Permission is hereby granted, free of charge, to any person obtaining @@ -28,10 +27,6 @@ #ifndef LIBFFI_TARGET_H #define LIBFFI_TARGET_H -#ifndef LIBFFI_H -#error "Please do not include ffitarget.h directly into your source. Use ffi.h instead." -#endif - #ifndef LIBFFI_ASM typedef unsigned long ffi_arg; typedef signed long ffi_sarg; @@ -39,8 +34,8 @@ typedef enum ffi_abi { FFI_FIRST_ABI = 0, FFI_SYSV, - FFI_LAST_ABI, - FFI_DEFAULT_ABI = FFI_SYSV + FFI_DEFAULT_ABI = FFI_SYSV, + FFI_LAST_ABI = FFI_DEFAULT_ABI + 1 } ffi_abi; #endif diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi/src/dlmalloc.c --- a/Modules/_ctypes/libffi/src/dlmalloc.c Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/_ctypes/libffi/src/dlmalloc.c Sun Jul 20 10:52:46 2014 -0400 @@ -464,14 +464,6 @@ #define _GNU_SOURCE 1 #endif /* WIN32 */ -#ifdef __OS2__ -#define INCL_DOS -#include -#define HAVE_MMAP 1 -#define HAVE_MORECORE 0 -#define LACKS_SYS_MMAN_H -#endif /* __OS2__ */ - #if defined(DARWIN) || defined(_DARWIN) /* Mac OSX docs advise not to use sbrk; it seems better to use mmap */ #ifndef HAVE_MORECORE @@ -627,9 +619,6 @@ #include "/usr/include/malloc.h" #else /* HAVE_USR_INCLUDE_MALLOC_H */ -/* HP-UX's stdlib.h redefines mallinfo unless _STRUCT_MALLINFO is defined */ -#define _STRUCT_MALLINFO - struct mallinfo { MALLINFO_FIELD_TYPE arena; /* non-mmapped space allocated from system */ MALLINFO_FIELD_TYPE ordblks; /* number of free chunks */ @@ -1304,7 +1293,7 @@ #define IS_MMAPPED_BIT (SIZE_T_ONE) #define USE_MMAP_BIT (SIZE_T_ONE) -#if !defined(WIN32) && !defined (__OS2__) +#ifndef WIN32 #define CALL_MUNMAP(a, s) munmap((a), (s)) #define MMAP_PROT (PROT_READ|PROT_WRITE) #if !defined(MAP_ANONYMOUS) && defined(MAP_ANON) @@ -1327,42 +1316,6 @@ #endif /* MAP_ANONYMOUS */ #define DIRECT_MMAP(s) CALL_MMAP(s) - -#elif defined(__OS2__) - -/* OS/2 MMAP via DosAllocMem */ -static void* os2mmap(size_t size) { - void* ptr; - if (DosAllocMem(&ptr, size, OBJ_ANY|PAG_COMMIT|PAG_READ|PAG_WRITE) && - DosAllocMem(&ptr, size, PAG_COMMIT|PAG_READ|PAG_WRITE)) - return MFAIL; - return ptr; -} - -#define os2direct_mmap(n) os2mmap(n) - -/* This function supports releasing coalesed segments */ -static int os2munmap(void* ptr, size_t size) { - while (size) { - ULONG ulSize = size; - ULONG ulFlags = 0; - if (DosQueryMem(ptr, &ulSize, &ulFlags) != 0) - return -1; - if ((ulFlags & PAG_BASE) == 0 ||(ulFlags & PAG_COMMIT) == 0 || - ulSize > size) - return -1; - if (DosFreeMem(ptr) != 0) - return -1; - ptr = ( void * ) ( ( char * ) ptr + ulSize ); - size -= ulSize; - } - return 0; -} - -#define CALL_MMAP(s) os2mmap(s) -#define CALL_MUNMAP(a, s) os2munmap((a), (s)) -#define DIRECT_MMAP(s) os2direct_mmap(s) - #else /* WIN32 */ /* Win32 MMAP via VirtualAlloc */ @@ -1439,7 +1392,7 @@ unique mparams values are initialized only once. */ -#if !defined(WIN32) && !defined(__OS2__) +#ifndef WIN32 /* By default use posix locks */ #include #define MLOCK_T pthread_mutex_t @@ -1453,16 +1406,6 @@ static MLOCK_T magic_init_mutex = PTHREAD_MUTEX_INITIALIZER; -#elif defined(__OS2__) -#define MLOCK_T HMTX -#define INITIAL_LOCK(l) DosCreateMutexSem(0, l, 0, FALSE) -#define ACQUIRE_LOCK(l) DosRequestMutexSem(*l, SEM_INDEFINITE_WAIT) -#define RELEASE_LOCK(l) DosReleaseMutexSem(*l) -#if HAVE_MORECORE -static MLOCK_T morecore_mutex; -#endif /* HAVE_MORECORE */ -static MLOCK_T magic_init_mutex; - #else /* WIN32 */ /* Because lock-protected regions have bounded times, and there @@ -2554,15 +2497,10 @@ } RELEASE_MAGIC_INIT_LOCK(); -#if !defined(WIN32) && !defined(__OS2__) +#ifndef WIN32 mparams.page_size = malloc_getpagesize; mparams.granularity = ((DEFAULT_GRANULARITY != 0)? DEFAULT_GRANULARITY : mparams.page_size); -#elif defined (__OS2__) - /* if low-memory is used, os2munmap() would break - if it were anything other than 64k */ - mparams.page_size = 4096u; - mparams.granularity = 65536u; #else /* WIN32 */ { SYSTEM_INFO system_info; @@ -4259,7 +4197,7 @@ void dlfree(void* mem) { /* - Consolidate freed chunks with preceding or succeeding bordering + Consolidate freed chunks with preceeding or succeeding bordering free chunks, if they exist, and then place in a bin. Intermixed with special cases for top, dv, mmapped chunks, and usage errors. */ diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi/src/frv/ffitarget.h --- a/Modules/_ctypes/libffi/src/frv/ffitarget.h Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/_ctypes/libffi/src/frv/ffitarget.h Sun Jul 20 10:52:46 2014 -0400 @@ -1,6 +1,5 @@ /* -----------------------------------------------------------------*-C-*- - ffitarget.h - Copyright (c) 2012 Anthony Green - Copyright (c) 1996-2004 Red Hat, Inc. + ffitarget.h - Copyright (c) 1996-2004 Red Hat, Inc. Target configuration macros for FR-V Permission is hereby granted, free of charge, to any person obtaining @@ -28,10 +27,6 @@ #ifndef LIBFFI_TARGET_H #define LIBFFI_TARGET_H -#ifndef LIBFFI_H -#error "Please do not include ffitarget.h directly into your source. Use ffi.h instead." -#endif - /* ---- System specific configurations ----------------------------------- */ #ifndef LIBFFI_ASM @@ -40,9 +35,13 @@ typedef enum ffi_abi { FFI_FIRST_ABI = 0, + +#ifdef FRV FFI_EABI, - FFI_LAST_ABI, - FFI_DEFAULT_ABI = FFI_EABI + FFI_DEFAULT_ABI = FFI_EABI, +#endif + + FFI_LAST_ABI = FFI_DEFAULT_ABI + 1 } ffi_abi; #endif diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi/src/ia64/ffi.c --- a/Modules/_ctypes/libffi/src/ia64/ffi.c Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/_ctypes/libffi/src/ia64/ffi.c Sun Jul 20 10:52:46 2014 -0400 @@ -1,7 +1,6 @@ /* ----------------------------------------------------------------------- - ffi.c - Copyright (c) 1998, 2007, 2008, 2012 Red Hat, Inc. + ffi.c - Copyright (c) 1998, 2007, 2008 Red Hat, Inc. Copyright (c) 2000 Hewlett Packard Company - Copyright (c) 2011 Anthony Green IA64 Foreign Function Interface @@ -226,7 +225,7 @@ int flags; /* Adjust cif->bytes to include space for the bits of the ia64_args frame - that precedes the integer register portion. The estimate that the + that preceeds the integer register portion. The estimate that the generic bits did for the argument space required is good enough for the integer component. */ cif->bytes += offsetof(struct ia64_args, gp_regs[0]); @@ -325,17 +324,13 @@ case FFI_TYPE_FLOAT: if (gpcount < 8 && fpcount < 8) stf_spill (&stack->fp_regs[fpcount++], *(float *)avalue[i]); - { - UINT32 tmp; - memcpy (&tmp, avalue[i], sizeof (UINT32)); - stack->gp_regs[gpcount++] = tmp; - } + stack->gp_regs[gpcount++] = *(UINT32 *)avalue[i]; break; case FFI_TYPE_DOUBLE: if (gpcount < 8 && fpcount < 8) stf_spill (&stack->fp_regs[fpcount++], *(double *)avalue[i]); - memcpy (&stack->gp_regs[gpcount++], avalue[i], sizeof (UINT64)); + stack->gp_regs[gpcount++] = *(UINT64 *)avalue[i]; break; case FFI_TYPE_LONGDOUBLE: @@ -430,8 +425,7 @@ struct ffi_ia64_trampoline_struct *tramp; struct ia64_fd *fd; - if (cif->abi != FFI_UNIX) - return FFI_BAD_ABI; + FFI_ASSERT (cif->abi == FFI_UNIX); tramp = (struct ffi_ia64_trampoline_struct *)closure->tramp; fd = (struct ia64_fd *)(void *)ffi_closure_unix; diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi/src/ia64/ffitarget.h --- a/Modules/_ctypes/libffi/src/ia64/ffitarget.h Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/_ctypes/libffi/src/ia64/ffitarget.h Sun Jul 20 10:52:46 2014 -0400 @@ -1,6 +1,5 @@ /* -----------------------------------------------------------------*-C-*- - ffitarget.h - Copyright (c) 2012 Anthony Green - Copyright (c) 1996-2003 Red Hat, Inc. + ffitarget.h - Copyright (c) 1996-2003 Red Hat, Inc. Target configuration macros for IA-64. Permission is hereby granted, free of charge, to any person obtaining @@ -28,10 +27,6 @@ #ifndef LIBFFI_TARGET_H #define LIBFFI_TARGET_H -#ifndef LIBFFI_H -#error "Please do not include ffitarget.h directly into your source. Use ffi.h instead." -#endif - #ifndef LIBFFI_ASM typedef unsigned long long ffi_arg; typedef signed long long ffi_sarg; @@ -39,8 +34,8 @@ typedef enum ffi_abi { FFI_FIRST_ABI = 0, FFI_UNIX, /* Linux and all Unix variants use the same conventions */ - FFI_LAST_ABI, - FFI_DEFAULT_ABI = FFI_UNIX + FFI_DEFAULT_ABI = FFI_UNIX, + FFI_LAST_ABI = FFI_DEFAULT_ABI + 1 } ffi_abi; #endif diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi/src/java_raw_api.c --- a/Modules/_ctypes/libffi/src/java_raw_api.c Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/_ctypes/libffi/src/java_raw_api.c Sun Jul 20 10:52:46 2014 -0400 @@ -311,7 +311,7 @@ ffi_raw_closure *cl = (ffi_raw_closure*)user_data; ffi_java_ptrarray_to_raw (cif, avalue, raw); - (*cl->fun) (cif, rvalue, (ffi_raw*)raw, cl->user_data); + (*cl->fun) (cif, rvalue, raw, cl->user_data); ffi_java_raw_to_rvalue (cif, rvalue); } diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi/src/m32r/ffitarget.h --- a/Modules/_ctypes/libffi/src/m32r/ffitarget.h Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/_ctypes/libffi/src/m32r/ffitarget.h Sun Jul 20 10:52:46 2014 -0400 @@ -1,6 +1,5 @@ /* -----------------------------------------------------------------*-C-*- - ffitarget.h - Copyright (c) 2012 Anthony Green - Copyright (c) 2004 Renesas Technology. + ffitarget.h - Copyright (c) 2004 Renesas Technology. Target configuration macros for M32R. Permission is hereby granted, free of charge, to any person obtaining @@ -27,10 +26,6 @@ #ifndef LIBFFI_TARGET_H #define LIBFFI_TARGET_H -#ifndef LIBFFI_H -#error "Please do not include ffitarget.h directly into your source. Use ffi.h instead." -#endif - /* ---- Generic type definitions ----------------------------------------- */ #ifndef LIBFFI_ASM @@ -41,8 +36,8 @@ { FFI_FIRST_ABI = 0, FFI_SYSV, - FFI_LAST_ABI, - FFI_DEFAULT_ABI = FFI_SYSV + FFI_DEFAULT_ABI = FFI_SYSV, + FFI_LAST_ABI = FFI_DEFAULT_ABI + 1 } ffi_abi; #endif diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi/src/m68k/ffi.c --- a/Modules/_ctypes/libffi/src/m68k/ffi.c Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/_ctypes/libffi/src/m68k/ffi.c Sun Jul 20 10:52:46 2014 -0400 @@ -1,7 +1,7 @@ /* ----------------------------------------------------------------------- ffi.c - - m68k Foreign Function Interface + + m68k Foreign Function Interface ----------------------------------------------------------------------- */ #include @@ -9,17 +9,8 @@ #include #include -#ifdef __rtems__ -void rtems_cache_flush_multiple_data_lines( const void *, size_t ); -#else #include -#ifdef __MINT__ -#include -#include -#else #include -#endif -#endif void ffi_call_SYSV (extended_cif *, unsigned, unsigned, @@ -44,12 +35,8 @@ argp = stack; - if ( -#ifdef __MINT__ - (ecif->cif->rtype->type == FFI_TYPE_LONGDOUBLE) || -#endif - (((ecif->cif->rtype->type == FFI_TYPE_STRUCT) - && !ecif->cif->flags))) + if (ecif->cif->rtype->type == FFI_TYPE_STRUCT + && !ecif->cif->flags) struct_value_ptr = ecif->rvalue; else struct_value_ptr = NULL; @@ -60,12 +47,12 @@ i != 0; i--, p_arg++) { - size_t z = (*p_arg)->size; - int type = (*p_arg)->type; + size_t z; + z = (*p_arg)->size; if (z < sizeof (int)) { - switch (type) + switch ((*p_arg)->type) { case FFI_TYPE_SINT8: *(signed int *) argp = (signed int) *(SINT8 *) *p_argv; @@ -84,14 +71,7 @@ break; case FFI_TYPE_STRUCT: -#ifdef __MINT__ - if (z == 1 || z == 2) - memcpy (argp + 2, *p_argv, z); - else - memcpy (argp, *p_argv, z); -#else memcpy (argp + sizeof (int) - z, *p_argv, z); -#endif break; default: @@ -123,8 +103,6 @@ #define CIF_FLAGS_POINTER 32 #define CIF_FLAGS_STRUCT1 64 #define CIF_FLAGS_STRUCT2 128 -#define CIF_FLAGS_SINT8 256 -#define CIF_FLAGS_SINT16 512 /* Perform machine dependent cif processing */ ffi_status @@ -138,34 +116,17 @@ break; case FFI_TYPE_STRUCT: - if (cif->rtype->elements[0]->type == FFI_TYPE_STRUCT && - cif->rtype->elements[1]) - { - cif->flags = 0; - break; - } - switch (cif->rtype->size) { case 1: -#ifdef __MINT__ - cif->flags = CIF_FLAGS_STRUCT2; -#else cif->flags = CIF_FLAGS_STRUCT1; -#endif break; case 2: cif->flags = CIF_FLAGS_STRUCT2; break; -#ifdef __MINT__ - case 3: -#endif case 4: cif->flags = CIF_FLAGS_INT; break; -#ifdef __MINT__ - case 7: -#endif case 8: cif->flags = CIF_FLAGS_DINT; break; @@ -183,15 +144,9 @@ cif->flags = CIF_FLAGS_DOUBLE; break; -#if (FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE) case FFI_TYPE_LONGDOUBLE: -#ifdef __MINT__ - cif->flags = 0; -#else cif->flags = CIF_FLAGS_LDOUBLE; -#endif break; -#endif case FFI_TYPE_POINTER: cif->flags = CIF_FLAGS_POINTER; @@ -202,14 +157,6 @@ cif->flags = CIF_FLAGS_DINT; break; - case FFI_TYPE_SINT16: - cif->flags = CIF_FLAGS_SINT16; - break; - - case FFI_TYPE_SINT8: - cif->flags = CIF_FLAGS_SINT8; - break; - default: cif->flags = CIF_FLAGS_INT; break; @@ -265,26 +212,6 @@ size_t z; z = (*p_arg)->size; -#ifdef __MINT__ - if (cif->flags && - cif->rtype->type == FFI_TYPE_STRUCT && - (z == 1 || z == 2)) - { - *p_argv = (void *) (argp + 2); - - z = 4; - } - else - if (cif->flags && - cif->rtype->type == FFI_TYPE_STRUCT && - (z == 3 || z == 4)) - { - *p_argv = (void *) (argp); - - z = 4; - } - else -#endif if (z <= 4) { *p_argv = (void *) (argp + 4 - z); @@ -328,31 +255,19 @@ void *user_data, void *codeloc) { - if (cif->abi != FFI_SYSV) - return FFI_BAD_ABI; + FFI_ASSERT (cif->abi == FFI_SYSV); *(unsigned short *)closure->tramp = 0x207c; *(void **)(closure->tramp + 2) = codeloc; *(unsigned short *)(closure->tramp + 6) = 0x4ef9; - - if ( -#ifdef __MINT__ - (cif->rtype->type == FFI_TYPE_LONGDOUBLE) || -#endif - (((cif->rtype->type == FFI_TYPE_STRUCT) - && !cif->flags))) + if (cif->rtype->type == FFI_TYPE_STRUCT + && !cif->flags) *(void **)(closure->tramp + 8) = ffi_closure_struct_SYSV; else *(void **)(closure->tramp + 8) = ffi_closure_SYSV; -#ifdef __rtems__ - rtems_cache_flush_multiple_data_lines( codeloc, FFI_TRAMPOLINE_SIZE ); -#elif defined(__MINT__) - Ssystem(S_FLUSHCACHE, codeloc, FFI_TRAMPOLINE_SIZE); -#else syscall(SYS_cacheflush, codeloc, FLUSH_SCOPE_LINE, FLUSH_CACHE_BOTH, FFI_TRAMPOLINE_SIZE); -#endif closure->cif = cif; closure->user_data = user_data; @@ -360,3 +275,4 @@ return FFI_OK; } + diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi/src/m68k/ffitarget.h --- a/Modules/_ctypes/libffi/src/m68k/ffitarget.h Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/_ctypes/libffi/src/m68k/ffitarget.h Sun Jul 20 10:52:46 2014 -0400 @@ -1,6 +1,5 @@ /* -----------------------------------------------------------------*-C-*- - ffitarget.h - Copyright (c) 2012 Anthony Green - Copyright (c) 1996-2003 Red Hat, Inc. + ffitarget.h - Copyright (c) 1996-2003 Red Hat, Inc. Target configuration macros for Motorola 68K. Permission is hereby granted, free of charge, to any person obtaining @@ -28,10 +27,6 @@ #ifndef LIBFFI_TARGET_H #define LIBFFI_TARGET_H -#ifndef LIBFFI_H -#error "Please do not include ffitarget.h directly into your source. Use ffi.h instead." -#endif - #ifndef LIBFFI_ASM typedef unsigned long ffi_arg; typedef signed long ffi_sarg; @@ -39,8 +34,8 @@ typedef enum ffi_abi { FFI_FIRST_ABI = 0, FFI_SYSV, - FFI_LAST_ABI, - FFI_DEFAULT_ABI = FFI_SYSV + FFI_DEFAULT_ABI = FFI_SYSV, + FFI_LAST_ABI = FFI_DEFAULT_ABI + 1 } ffi_abi; #endif diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi/src/m68k/sysv.S --- a/Modules/_ctypes/libffi/src/m68k/sysv.S Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/_ctypes/libffi/src/m68k/sysv.S Sun Jul 20 10:52:46 2014 -0400 @@ -1,11 +1,8 @@ /* ----------------------------------------------------------------------- - - sysv.S - Copyright (c) 2012 Alan Hourihane - Copyright (c) 1998, 2012 Andreas Schwab - Copyright (c) 2008 Red Hat, Inc. - Copyright (c) 2012 Thorsten Glaser - - m68k Foreign Function Interface + sysv.S - Copyright (c) 1998 Andreas Schwab + Copyright (c) 2008 Red Hat, Inc. + + m68k Foreign Function Interface Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the @@ -44,19 +41,13 @@ #define CFI_ENDPROC() #endif -#ifdef __MINT__ -#define CALLFUNC(funcname) _ ## funcname -#else -#define CALLFUNC(funcname) funcname -#endif - .text - .globl CALLFUNC(ffi_call_SYSV) - .type CALLFUNC(ffi_call_SYSV),@function + .globl ffi_call_SYSV + .type ffi_call_SYSV,@function .align 4 -CALLFUNC(ffi_call_SYSV): +ffi_call_SYSV: CFI_STARTPROC() link %fp,#0 CFI_OFFSET(14,-8) @@ -71,18 +62,14 @@ move.l 8(%fp),-(%sp) pea 4(%sp) #if !defined __PIC__ - jsr CALLFUNC(ffi_prep_args) + jsr ffi_prep_args #else - bsr.l CALLFUNC(ffi_prep_args@PLTPC) + bsr.l ffi_prep_args@PLTPC #endif addq.l #8,%sp | Pass pointer to struct value, if any -#ifdef __MINT__ - move.l %d0,%a1 -#else move.l %a0,%a1 -#endif | Call the function move.l 24(%fp),%a0 @@ -98,12 +85,7 @@ move.l 16(%fp),%d2 | If the return value pointer is NULL, assume no return value. - | NOTE: On the mc68000, tst on an address register is not supported. -#if !defined(__mc68020__) && !defined(__mc68030__) && !defined(__mc68040__) && !defined(__mc68060__) && !defined(__mcoldfire__) - cmp.w #0, %a1 -#else tst.l %a1 -#endif jbeq noretval btst #0,%d2 @@ -121,44 +103,25 @@ retfloat: btst #2,%d2 jbeq retdouble -#if defined(__MC68881__) || defined(__HAVE_68881__) fmove.s %fp0,(%a1) -#else - move.l %d0,(%a1) -#endif jbra epilogue retdouble: btst #3,%d2 jbeq retlongdouble -#if defined(__MC68881__) || defined(__HAVE_68881__) fmove.d %fp0,(%a1) -#else - move.l %d0,(%a1)+ - move.l %d1,(%a1) -#endif jbra epilogue retlongdouble: btst #4,%d2 jbeq retpointer -#if defined(__MC68881__) || defined(__HAVE_68881__) fmove.x %fp0,(%a1) -#else - move.l %d0,(%a1)+ - move.l %d1,(%a1)+ - move.l %d2,(%a1) -#endif jbra epilogue retpointer: btst #5,%d2 jbeq retstruct1 -#ifdef __MINT__ - move.l %d0,(%a1) -#else move.l %a0,(%a1) -#endif jbra epilogue retstruct1: @@ -169,28 +132,8 @@ retstruct2: btst #7,%d2 - jbeq retsint8 + jbeq noretval move.w %d0,(%a1) - jbra epilogue - -retsint8: - btst #8,%d2 - jbeq retsint16 - | NOTE: On the mc68000, extb is not supported. 8->16, then 16->32. -#if !defined(__mc68020__) && !defined(__mc68030__) && !defined(__mc68040__) && !defined(__mc68060__) && !defined(__mcoldfire__) - ext.w %d0 - ext.l %d0 -#else - extb.l %d0 -#endif - move.l %d0,(%a1) - jbra epilogue - -retsint16: - btst #9,%d2 - jbeq noretval - ext.l %d0 - move.l %d0,(%a1) noretval: epilogue: @@ -198,13 +141,13 @@ unlk %fp rts CFI_ENDPROC() - .size CALLFUNC(ffi_call_SYSV),.-CALLFUNC(ffi_call_SYSV) + .size ffi_call_SYSV,.-ffi_call_SYSV - .globl CALLFUNC(ffi_closure_SYSV) - .type CALLFUNC(ffi_closure_SYSV), @function + .globl ffi_closure_SYSV + .type ffi_closure_SYSV, @function .align 4 -CALLFUNC(ffi_closure_SYSV): +ffi_closure_SYSV: CFI_STARTPROC() link %fp,#-12 CFI_OFFSET(14,-8) @@ -214,18 +157,16 @@ pea -12(%fp) move.l %a0,-(%sp) #if !defined __PIC__ - jsr CALLFUNC(ffi_closure_SYSV_inner) + jsr ffi_closure_SYSV_inner #else - bsr.l CALLFUNC(ffi_closure_SYSV_inner@PLTPC) + bsr.l ffi_closure_SYSV_inner@PLTPC #endif lsr.l #1,%d0 jne 1f jcc .Lcls_epilogue - | CIF_FLAGS_INT move.l -12(%fp),%d0 .Lcls_epilogue: - | no CIF_FLAGS_* unlk %fp rts 1: @@ -233,80 +174,43 @@ lsr.l #2,%d0 jne 1f jcs .Lcls_ret_float - | CIF_FLAGS_DINT move.l (%a0)+,%d0 move.l (%a0),%d1 jra .Lcls_epilogue .Lcls_ret_float: -#if defined(__MC68881__) || defined(__HAVE_68881__) fmove.s (%a0),%fp0 -#else - move.l (%a0),%d0 -#endif jra .Lcls_epilogue 1: lsr.l #2,%d0 jne 1f jcs .Lcls_ret_ldouble - | CIF_FLAGS_DOUBLE -#if defined(__MC68881__) || defined(__HAVE_68881__) fmove.d (%a0),%fp0 -#else - move.l (%a0)+,%d0 - move.l (%a0),%d1 -#endif jra .Lcls_epilogue .Lcls_ret_ldouble: -#if defined(__MC68881__) || defined(__HAVE_68881__) fmove.x (%a0),%fp0 -#else - move.l (%a0)+,%d0 - move.l (%a0)+,%d1 - move.l (%a0),%d2 -#endif jra .Lcls_epilogue 1: lsr.l #2,%d0 - jne 1f + jne .Lcls_ret_struct2 jcs .Lcls_ret_struct1 - | CIF_FLAGS_POINTER move.l (%a0),%a0 move.l %a0,%d0 jra .Lcls_epilogue .Lcls_ret_struct1: move.b (%a0),%d0 jra .Lcls_epilogue -1: - lsr.l #2,%d0 - jne 1f - jcs .Lcls_ret_sint8 - | CIF_FLAGS_STRUCT2 +.Lcls_ret_struct2: move.w (%a0),%d0 jra .Lcls_epilogue -.Lcls_ret_sint8: - move.l (%a0),%d0 - | NOTE: On the mc68000, extb is not supported. 8->16, then 16->32. -#if !defined(__mc68020__) && !defined(__mc68030__) && !defined(__mc68040__) && !defined(__mc68060__) && !defined(__mcoldfire__) - ext.w %d0 - ext.l %d0 -#else - extb.l %d0 -#endif - jra .Lcls_epilogue -1: - | CIF_FLAGS_SINT16 - move.l (%a0),%d0 - ext.l %d0 - jra .Lcls_epilogue CFI_ENDPROC() - .size CALLFUNC(ffi_closure_SYSV),.-CALLFUNC(ffi_closure_SYSV) + .size ffi_closure_SYSV,.-ffi_closure_SYSV - .globl CALLFUNC(ffi_closure_struct_SYSV) - .type CALLFUNC(ffi_closure_struct_SYSV), @function + .globl ffi_closure_struct_SYSV + .type ffi_closure_struct_SYSV, @function .align 4 -CALLFUNC(ffi_closure_struct_SYSV): +ffi_closure_struct_SYSV: CFI_STARTPROC() link %fp,#0 CFI_OFFSET(14,-8) @@ -316,14 +220,14 @@ move.l %a1,-(%sp) move.l %a0,-(%sp) #if !defined __PIC__ - jsr CALLFUNC(ffi_closure_SYSV_inner) + jsr ffi_closure_SYSV_inner #else - bsr.l CALLFUNC(ffi_closure_SYSV_inner@PLTPC) + bsr.l ffi_closure_SYSV_inner@PLTPC #endif unlk %fp rts CFI_ENDPROC() - .size CALLFUNC(ffi_closure_struct_SYSV),.-CALLFUNC(ffi_closure_struct_SYSV) + .size ffi_closure_struct_SYSV,.-ffi_closure_struct_SYSV #if defined __ELF__ && defined __linux__ .section .note.GNU-stack,"",@progbits diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi/src/metag/ffi.c --- a/Modules/_ctypes/libffi/src/metag/ffi.c Sat Jul 19 16:34:33 2014 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,330 +0,0 @@ -/* ---------------------------------------------------------------------- - ffi.c - Copyright (c) 2013 Imagination Technologies - - Meta Foreign Function Interface - Permission is hereby granted, free of charge, to any person obtaining - a copy of this software and associated documentation files (the - `Software''), to deal in the Software without restriction, including - without limitation the rights to use, copy, modify, merge, publish, - distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to - the following conditions: - - The above copyright notice and this permission notice shall be included - in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED `AS IS'', WITHOUT WARRANTY OF ANY KIND, EXPRESS - OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. - IN NO EVENT SHALL SIMON POSNJAK BE LIABLE FOR ANY CLAIM, DAMAGES OR - OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, - ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR - OTHER DEALINGS IN THE SOFTWARE. ------------------------------------------------------------------------ */ - -#include -#include - -#include - -#define MIN(a,b) (((a) < (b)) ? (a) : (b)) - -/* - * ffi_prep_args is called by the assembly routine once stack space has been - * allocated for the function's arguments - */ - -unsigned int ffi_prep_args(char *stack, extended_cif *ecif) -{ - register unsigned int i; - register void **p_argv; - register char *argp; - register ffi_type **p_arg; - - argp = stack; - - /* Store return value */ - if ( ecif->cif->flags == FFI_TYPE_STRUCT ) { - argp -= 4; - *(void **) argp = ecif->rvalue; - } - - p_argv = ecif->avalue; - - /* point to next location */ - for (i = ecif->cif->nargs, p_arg = ecif->cif->arg_types; (i != 0); i--, p_arg++, p_argv++) - { - size_t z; - - /* Move argp to address of argument */ - z = (*p_arg)->size; - argp -= z; - - /* Align if necessary */ - argp = (char *) ALIGN_DOWN(ALIGN_DOWN(argp, (*p_arg)->alignment), 4); - - if (z < sizeof(int)) { - z = sizeof(int); - switch ((*p_arg)->type) - { - case FFI_TYPE_SINT8: - *(signed int *) argp = (signed int)*(SINT8 *)(* p_argv); - break; - case FFI_TYPE_UINT8: - *(unsigned int *) argp = (unsigned int)*(UINT8 *)(* p_argv); - break; - case FFI_TYPE_SINT16: - *(signed int *) argp = (signed int)*(SINT16 *)(* p_argv); - break; - case FFI_TYPE_UINT16: - *(unsigned int *) argp = (unsigned int)*(UINT16 *)(* p_argv); - case FFI_TYPE_STRUCT: - memcpy(argp, *p_argv, (*p_arg)->size); - break; - default: - FFI_ASSERT(0); - } - } else if ( z == sizeof(int)) { - *(unsigned int *) argp = (unsigned int)*(UINT32 *)(* p_argv); - } else { - memcpy(argp, *p_argv, z); - } - } - - /* return the size of the arguments to be passed in registers, - padded to an 8 byte boundary to preserve stack alignment */ - return ALIGN(MIN(stack - argp, 6*4), 8); -} - -/* Perform machine dependent cif processing */ -ffi_status ffi_prep_cif_machdep(ffi_cif *cif) -{ - ffi_type **ptr; - unsigned i, bytes = 0; - - for (ptr = cif->arg_types, i = cif->nargs; i > 0; i--, ptr++) { - if ((*ptr)->size == 0) - return FFI_BAD_TYPEDEF; - - /* Perform a sanity check on the argument type, do this - check after the initialization. */ - FFI_ASSERT_VALID_TYPE(*ptr); - - /* Add any padding if necessary */ - if (((*ptr)->alignment - 1) & bytes) - bytes = ALIGN(bytes, (*ptr)->alignment); - - bytes += ALIGN((*ptr)->size, 4); - } - - /* Ensure arg space is aligned to an 8-byte boundary */ - bytes = ALIGN(bytes, 8); - - /* Make space for the return structure pointer */ - if (cif->rtype->type == FFI_TYPE_STRUCT) { - bytes += sizeof(void*); - - /* Ensure stack is aligned to an 8-byte boundary */ - bytes = ALIGN(bytes, 8); - } - - cif->bytes = bytes; - - /* Set the return type flag */ - switch (cif->rtype->type) { - case FFI_TYPE_VOID: - case FFI_TYPE_FLOAT: - case FFI_TYPE_DOUBLE: - cif->flags = (unsigned) cif->rtype->type; - break; - case FFI_TYPE_SINT64: - case FFI_TYPE_UINT64: - cif->flags = (unsigned) FFI_TYPE_SINT64; - break; - case FFI_TYPE_STRUCT: - /* Meta can store return values which are <= 64 bits */ - if (cif->rtype->size <= 4) - /* Returned to D0Re0 as 32-bit value */ - cif->flags = (unsigned)FFI_TYPE_INT; - else if ((cif->rtype->size > 4) && (cif->rtype->size <= 8)) - /* Returned valued is stored to D1Re0|R0Re0 */ - cif->flags = (unsigned)FFI_TYPE_DOUBLE; - else - /* value stored in memory */ - cif->flags = (unsigned)FFI_TYPE_STRUCT; - break; - default: - cif->flags = (unsigned)FFI_TYPE_INT; - break; - } - return FFI_OK; -} - -extern void ffi_call_SYSV(void (*fn)(void), extended_cif *, unsigned, unsigned, double *); - -/* - * Exported in API. Entry point - * cif -> ffi_cif object - * fn -> function pointer - * rvalue -> pointer to return value - * avalue -> vector of void * pointers pointing to memory locations holding the - * arguments - */ -void ffi_call(ffi_cif *cif, void (*fn)(void), void *rvalue, void **avalue) -{ - extended_cif ecif; - - int small_struct = (((cif->flags == FFI_TYPE_INT) || (cif->flags == FFI_TYPE_DOUBLE)) && (cif->rtype->type == FFI_TYPE_STRUCT)); - ecif.cif = cif; - ecif.avalue = avalue; - - double temp; - - /* - * If the return value is a struct and we don't have a return value address - * then we need to make one - */ - - if ((rvalue == NULL ) && (cif->flags == FFI_TYPE_STRUCT)) - ecif.rvalue = alloca(cif->rtype->size); - else if (small_struct) - ecif.rvalue = &temp; - else - ecif.rvalue = rvalue; - - switch (cif->abi) { - case FFI_SYSV: - ffi_call_SYSV(fn, &ecif, cif->bytes, cif->flags, ecif.rvalue); - break; - default: - FFI_ASSERT(0); - break; - } - - if (small_struct) - memcpy (rvalue, &temp, cif->rtype->size); -} - -/* private members */ - -static void ffi_prep_incoming_args_SYSV (char *, void **, void **, - ffi_cif*, float *); - -void ffi_closure_SYSV (ffi_closure *); - -/* Do NOT change that without changing the FFI_TRAMPOLINE_SIZE */ -extern unsigned int ffi_metag_trampoline[10]; /* 10 instructions */ - -/* end of private members */ - -/* - * __tramp: trampoline memory location - * __fun: assembly routine - * __ctx: memory location for wrapper - * - * At this point, tramp[0] == __ctx ! - */ -void ffi_init_trampoline(unsigned char *__tramp, unsigned int __fun, unsigned int __ctx) { - memcpy (__tramp, ffi_metag_trampoline, sizeof(ffi_metag_trampoline)); - *(unsigned int*) &__tramp[40] = __ctx; - *(unsigned int*) &__tramp[44] = __fun; - /* This will flush the instruction cache */ - __builtin_meta2_cachewd(&__tramp[0], 1); - __builtin_meta2_cachewd(&__tramp[47], 1); -} - - - -/* the cif must already be prepared */ - -ffi_status -ffi_prep_closure_loc (ffi_closure *closure, - ffi_cif* cif, - void (*fun)(ffi_cif*,void*,void**,void*), - void *user_data, - void *codeloc) -{ - void (*closure_func)(ffi_closure*) = NULL; - - if (cif->abi == FFI_SYSV) - closure_func = &ffi_closure_SYSV; - else - return FFI_BAD_ABI; - - ffi_init_trampoline( - (unsigned char*)&closure->tramp[0], - (unsigned int)closure_func, - (unsigned int)codeloc); - - closure->cif = cif; - closure->user_data = user_data; - closure->fun = fun; - - return FFI_OK; -} - - -/* This function is jumped to by the trampoline */ -unsigned int ffi_closure_SYSV_inner (closure, respp, args, vfp_args) - ffi_closure *closure; - void **respp; - void *args; - void *vfp_args; -{ - ffi_cif *cif; - void **arg_area; - - cif = closure->cif; - arg_area = (void**) alloca (cif->nargs * sizeof (void*)); - - /* - * This call will initialize ARG_AREA, such that each - * element in that array points to the corresponding - * value on the stack; and if the function returns - * a structure, it will re-set RESP to point to the - * structure return address. - */ - ffi_prep_incoming_args_SYSV(args, respp, arg_area, cif, vfp_args); - - (closure->fun) ( cif, *respp, arg_area, closure->user_data); - - return cif->flags; -} - -static void ffi_prep_incoming_args_SYSV(char *stack, void **rvalue, - void **avalue, ffi_cif *cif, - float *vfp_stack) -{ - register unsigned int i; - register void **p_argv; - register char *argp; - register ffi_type **p_arg; - - /* stack points to original arguments */ - argp = stack; - - /* Store return value */ - if ( cif->flags == FFI_TYPE_STRUCT ) { - argp -= 4; - *rvalue = *(void **) argp; - } - - p_argv = avalue; - - for (i = cif->nargs, p_arg = cif->arg_types; (i != 0); i--, p_arg++) { - size_t z; - size_t alignment; - - alignment = (*p_arg)->alignment; - if (alignment < 4) - alignment = 4; - if ((alignment - 1) & (unsigned)argp) - argp = (char *) ALIGN(argp, alignment); - - z = (*p_arg)->size; - *p_argv = (void*) argp; - p_argv++; - argp -= z; - } - return; -} diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi/src/metag/ffitarget.h --- a/Modules/_ctypes/libffi/src/metag/ffitarget.h Sat Jul 19 16:34:33 2014 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,53 +0,0 @@ -/* -----------------------------------------------------------------*-C-*- - ffitarget.h - Copyright (c) 2013 Imagination Technologies Ltd. - Target configuration macros for Meta - - Permission is hereby granted, free of charge, to any person obtaining - a copy of this software and associated documentation files (the - ``Software''), to deal in the Software without restriction, including - without limitation the rights to use, copy, modify, merge, publish, - distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to - the following conditions: - - The above copyright notice and this permission notice shall be included - in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT - HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, - WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - DEALINGS IN THE SOFTWARE. - - ----------------------------------------------------------------------- */ - -#ifndef LIBFFI_TARGET_H -#define LIBFFI_TARGET_H - -#ifndef LIBFFI_H -#error "Please do not include ffitarget.h directly into your source. Use ffi.h instead." -#endif - -#ifndef LIBFFI_ASM -typedef unsigned long ffi_arg; -typedef signed long ffi_sarg; - -typedef enum ffi_abi { - FFI_FIRST_ABI = 0, - FFI_SYSV, - FFI_DEFAULT_ABI = FFI_SYSV, - FFI_LAST_ABI = FFI_DEFAULT_ABI + 1, -} ffi_abi; -#endif - -/* ---- Definitions for closures ----------------------------------------- */ - -#define FFI_CLOSURES 1 -#define FFI_TRAMPOLINE_SIZE 48 -#define FFI_NATIVE_RAW_API 0 - -#endif - diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi/src/metag/sysv.S --- a/Modules/_ctypes/libffi/src/metag/sysv.S Sat Jul 19 16:34:33 2014 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,311 +0,0 @@ -/* ----------------------------------------------------------------------- - sysv.S - Copyright (c) 2013 Imagination Technologies Ltd. - - Meta Foreign Function Interface - - Permission is hereby granted, free of charge, to any person obtaining - a copy of this software and associated documentation files (the - ``Software''), to deal in the Software without restriction, including - without limitation the rights to use, copy, modify, merge, publish, - distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to - the following conditions: - - The above copyright notice and this permission notice shall be included - in all copies or substantial portions of the Software. - - - THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT - HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, - WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - DEALINGS IN THE SOFTWARE. - ----------------------------------------------------------------------- */ - -#define LIBFFI_ASM -#include -#include -#ifdef HAVE_MACHINE_ASM_H -#include -#else -#ifdef __USER_LABEL_PREFIX__ -#define CONCAT1(a, b) CONCAT2(a, b) -#define CONCAT2(a, b) a ## b - -/* Use the right prefix for global labels. */ -#define CNAME(x) CONCAT1 (__USER_LABEL_PREFIX__, x) -#else -#define CNAME(x) x -#endif -#define ENTRY(x) .globl CNAME(x); .type CNAME(x), %function; CNAME(x): -#endif - -#ifdef __ELF__ -#define LSYM(x) .x -#else -#define LSYM(x) x -#endif - -.macro call_reg x= - .text - .balign 4 - mov D1RtP, \x - swap D1RtP, PC -.endm - -! Save register arguments -.macro SAVE_ARGS - .text - .balign 4 - setl [A0StP++], D0Ar6, D1Ar5 - setl [A0StP++], D0Ar4, D1Ar3 - setl [A0StP++], D0Ar2, D1Ar1 -.endm - -! Save retrun, frame pointer and other regs -.macro SAVE_REGS regs= - .text - .balign 4 - setl [A0StP++], D0FrT, D1RtP - ! Needs to be a pair of regs - .ifnc "\regs","" - setl [A0StP++], \regs - .endif -.endm - -! Declare a global function -.macro METAG_FUNC_START name - .text - .balign 4 - ENTRY(\name) -.endm - -! Return registers from the stack. Reverse SAVE_REGS operation -.macro RET_REGS regs=, cond= - .ifnc "\regs", "" - getl \regs, [--A0StP] - .endif - getl D0FrT, D1RtP, [--A0StP] -.endm - -! Return arguments -.macro RET_ARGS - getl D0Ar2, D1Ar1, [--A0StP] - getl D0Ar4, D1Ar3, [--A0StP] - getl D0Ar6, D1Ar5, [--A0StP] -.endm - - - ! D1Ar1: fn - ! D0Ar2: &ecif - ! D1Ar3: cif->bytes - ! D0Ar4: fig->flags - ! D1Ar5: ecif.rvalue - - ! This assumes we are using GNU as -METAG_FUNC_START ffi_call_SYSV - ! Save argument registers - - SAVE_ARGS - - ! new frame - mov D0FrT, A0FrP - add A0FrP, A0StP, #0 - - ! Preserve the old frame pointer - SAVE_REGS "D1.5, D0.5" - - ! Make room for new args. cifs->bytes is the total space for input - ! and return arguments - - add A0StP, A0StP, D1Ar3 - - ! Preserve cifs->bytes & fn - mov D0.5, D1Ar3 - mov D1.5, D1Ar1 - - ! Place all of the ffi_prep_args in position - mov D1Ar1, A0StP - - ! Call ffi_prep_args(stack, &ecif) -#ifdef __PIC__ - callr D1RtP, CNAME(ffi_prep_args@PLT) -#else - callr D1RtP, CNAME(ffi_prep_args) -#endif - - ! Restore fn pointer - - ! The foreign stack should look like this - ! XXXXX XXXXXX <--- stack pointer - ! FnArgN rvalue - ! FnArgN+2 FnArgN+1 - ! FnArgN+4 FnArgN+3 - ! .... - ! - - ! A0StP now points to the first (or return) argument + 4 - - ! Preserve cif->bytes - getl D0Ar2, D1Ar1, [--A0StP] - getl D0Ar4, D1Ar3, [--A0StP] - getl D0Ar6, D1Ar5, [--A0StP] - - ! Place A0StP to the first argument again - add A0StP, A0StP, #24 ! That's because we loaded 6 regs x 4 byte each - - ! A0FrP points to the initial stack without the reserved space for the - ! cifs->bytes, whilst A0StP points to the stack after the space allocation - - ! fn was the first argument of ffi_call_SYSV. - ! The stack at this point looks like this: - ! - ! A0StP(on entry to _SYSV) -> Arg6 Arg5 | low - ! Arg4 Arg3 | - ! Arg2 Arg1 | - ! A0FrP ----> D0FrtP D1RtP | - ! D1.5 D0.5 | - ! A0StP(bf prep_args) -> FnArgn FnArgn-1 | - ! FnArgn-2FnArgn-3 | - ! ................ | <= cifs->bytes - ! FnArg4 FnArg3 | - ! A0StP (prv_A0StP+cifs->bytes) FnArg2 FnArg1 | high - ! - ! fn was in Arg1 so it's located in in A0FrP+#-0xC - ! - - ! D0Re0 contains the size of arguments stored in registers - sub A0StP, A0StP, D0Re0 - - ! Arg1 is the function pointer for the foreign call. This has been - ! preserved in D1.5 - - ! Time to call (fn). Arguments should be like this: - ! Arg1-Arg6 are loaded to regs - ! The rest of the arguments are stored in stack pointed by A0StP - - call_reg D1.5 - - ! Reset stack. - - mov A0StP, A0FrP - - ! Load Arg1 with the pointer to storage for the return type - ! This was stored in Arg5 - - getd D1Ar1, [A0FrP+#-20] - - ! Load D0Ar2 with the return type code. This was stored in Arg4 (flags) - - getd D0Ar2, [A0FrP+#-16] - - ! We are ready to start processing the return value - ! D0Re0 (and D1Re0) hold the return value - - ! If the return value is NULL, assume no return value - cmp D1Ar1, #0 - beq LSYM(Lepilogue) - - ! return INT - cmp D0Ar2, #FFI_TYPE_INT - ! Sadly, there is no setd{cc} instruction so we need to workaround that - bne .INT64 - setd [D1Ar1], D0Re0 - b LSYM(Lepilogue) - - ! return INT64 -.INT64: - cmp D0Ar2, #FFI_TYPE_SINT64 - setleq [D1Ar1], D0Re0, D1Re0 - - ! return DOUBLE - cmp D0Ar2, #FFI_TYPE_DOUBLE - setl [D1AR1++], D0Re0, D1Re0 - -LSYM(Lepilogue): - ! At this point, the stack pointer points right after the argument - ! saved area. We need to restore 4 regs, therefore we need to move - ! 16 bytes ahead. - add A0StP, A0StP, #16 - RET_REGS "D1.5, D0.5" - RET_ARGS - getd D0Re0, [A0StP] - mov A0FrP, D0FrT - swap D1RtP, PC - -.ffi_call_SYSV_end: - .size CNAME(ffi_call_SYSV),.ffi_call_SYSV_end-CNAME(ffi_call_SYSV) - - -/* - (called by ffi_metag_trampoline) - void ffi_closure_SYSV (ffi_closure*) - - (called by ffi_closure_SYSV) - unsigned int FFI_HIDDEN - ffi_closure_SYSV_inner (closure,respp, args) - ffi_closure *closure; - void **respp; - void *args; -*/ - -METAG_FUNC_START ffi_closure_SYSV - ! We assume that D1Ar1 holds the address of the - ! ffi_closure struct. We will use that to fetch the - ! arguments. The stack pointer points to an empty space - ! and it is ready to store more data. - - ! D1Ar1 is ready - ! Allocate stack space for return value - add A0StP, A0StP, #8 - ! Store it to D0Ar2 - sub D0Ar2, A0StP, #8 - - sub D1Ar3, A0FrP, #4 - - ! D1Ar3 contains the address of the original D1Ar1 argument - ! We need to subtract #4 later on - - ! Preverve D0Ar2 - mov D0.5, D0Ar2 - -#ifdef __PIC__ - callr D1RtP, CNAME(ffi_closure_SYSV_inner@PLT) -#else - callr D1RtP, CNAME(ffi_closure_SYSV_inner) -#endif - - ! Check the return value and store it to D0.5 - cmp D0Re0, #FFI_TYPE_INT - beq .Lretint - cmp D0Re0, #FFI_TYPE_DOUBLE - beq .Lretdouble -.Lclosure_epilogue: - sub A0StP, A0StP, #8 - RET_REGS "D1.5, D0.5" - RET_ARGS - swap D1RtP, PC - -.Lretint: - setd [D0.5], D0Re0 - b .Lclosure_epilogue -.Lretdouble: - setl [D0.5++], D0Re0, D1Re0 - b .Lclosure_epilogue -.ffi_closure_SYSV_end: -.size CNAME(ffi_closure_SYSV),.ffi_closure_SYSV_end-CNAME(ffi_closure_SYSV) - - -ENTRY(ffi_metag_trampoline) - SAVE_ARGS - ! New frame - mov A0FrP, A0StP - SAVE_REGS "D1.5, D0.5" - mov D0.5, PC - ! Load D1Ar1 the value of ffi_metag_trampoline - getd D1Ar1, [D0.5 + #8] - ! Jump to ffi_closure_SYSV - getd PC, [D0.5 + #12] diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi/src/microblaze/ffi.c --- a/Modules/_ctypes/libffi/src/microblaze/ffi.c Sat Jul 19 16:34:33 2014 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,321 +0,0 @@ -/* ----------------------------------------------------------------------- - ffi.c - Copyright (c) 2012, 2013 Xilinx, Inc - - MicroBlaze Foreign Function Interface - - Permission is hereby granted, free of charge, to any person obtaining - a copy of this software and associated documentation files (the - ``Software''), to deal in the Software without restriction, including - without limitation the rights to use, copy, modify, merge, publish, - distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to - the following conditions: - - The above copyright notice and this permission notice shall be included - in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT - HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, - WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - DEALINGS IN THE SOFTWARE. - ----------------------------------------------------------------------- */ - -#include -#include - -extern void ffi_call_SYSV(void (*)(void*, extended_cif*), extended_cif*, - unsigned int, unsigned int, unsigned int*, void (*fn)(void), - unsigned int, unsigned int); - -extern void ffi_closure_SYSV(void); - -#define WORD_SIZE sizeof(unsigned int) -#define ARGS_REGISTER_SIZE (WORD_SIZE * 6) -#define WORD_ALIGN(x) ALIGN(x, WORD_SIZE) - -/* ffi_prep_args is called by the assembly routine once stack space - has been allocated for the function's arguments */ -void ffi_prep_args(void* stack, extended_cif* ecif) -{ - unsigned int i; - ffi_type** p_arg; - void** p_argv; - void* stack_args_p = stack; - - p_argv = ecif->avalue; - - if (ecif == NULL || ecif->cif == NULL) { - return; /* no description to prepare */ - } - - if ((ecif->cif->rtype != NULL) && - (ecif->cif->rtype->type == FFI_TYPE_STRUCT)) - { - /* if return type is a struct which is referenced on the stack/reg5, - * by a pointer. Stored the return value pointer in r5. - */ - char* addr = stack_args_p; - memcpy(addr, &(ecif->rvalue), WORD_SIZE); - stack_args_p += WORD_SIZE; - } - - if (ecif->avalue == NULL) { - return; /* no arguments to prepare */ - } - - for (i = 0, p_arg = ecif->cif->arg_types; i < ecif->cif->nargs; - i++, p_arg++) - { - size_t size = (*p_arg)->size; - int type = (*p_arg)->type; - void* value = p_argv[i]; - char* addr = stack_args_p; - int aligned_size = WORD_ALIGN(size); - - /* force word alignment on the stack */ - stack_args_p += aligned_size; - - switch (type) - { - case FFI_TYPE_UINT8: - *(unsigned int *)addr = (unsigned int)*(UINT8*)(value); - break; - case FFI_TYPE_SINT8: - *(signed int *)addr = (signed int)*(SINT8*)(value); - break; - case FFI_TYPE_UINT16: - *(unsigned int *)addr = (unsigned int)*(UINT16*)(value); - break; - case FFI_TYPE_SINT16: - *(signed int *)addr = (signed int)*(SINT16*)(value); - break; - case FFI_TYPE_STRUCT: -#if __BIG_ENDIAN__ - /* - * MicroBlaze toolchain appears to emit: - * bsrli r5, r5, 8 (caller) - * ... - * - * ... - * bslli r5, r5, 8 (callee) - * - * For structs like "struct a { uint8_t a[3]; };", when passed - * by value. - * - * Structs like "struct b { uint16_t a; };" are also expected - * to be packed strangely in registers. - * - * This appears to be because the microblaze toolchain expects - * "struct b == uint16_t", which is only any issue for big - * endian. - * - * The following is a work around for big-endian only, for the - * above mentioned case, it will re-align the contents of a - * <= 3-byte struct value. - */ - if (size < WORD_SIZE) - { - memcpy (addr + (WORD_SIZE - size), value, size); - break; - } -#endif - case FFI_TYPE_SINT32: - case FFI_TYPE_UINT32: - case FFI_TYPE_FLOAT: - case FFI_TYPE_SINT64: - case FFI_TYPE_UINT64: - case FFI_TYPE_DOUBLE: - default: - memcpy(addr, value, aligned_size); - } - } -} - -ffi_status ffi_prep_cif_machdep(ffi_cif* cif) -{ - /* check ABI */ - switch (cif->abi) - { - case FFI_SYSV: - break; - default: - return FFI_BAD_ABI; - } - return FFI_OK; -} - -void ffi_call(ffi_cif* cif, void (*fn)(void), void* rvalue, void** avalue) -{ - extended_cif ecif; - ecif.cif = cif; - ecif.avalue = avalue; - - /* If the return value is a struct and we don't have a return */ - /* value address then we need to make one */ - if ((rvalue == NULL) && (cif->rtype->type == FFI_TYPE_STRUCT)) { - ecif.rvalue = alloca(cif->rtype->size); - } else { - ecif.rvalue = rvalue; - } - - switch (cif->abi) - { - case FFI_SYSV: - ffi_call_SYSV(ffi_prep_args, &ecif, cif->bytes, cif->flags, - ecif.rvalue, fn, cif->rtype->type, cif->rtype->size); - break; - default: - FFI_ASSERT(0); - break; - } -} - -void ffi_closure_call_SYSV(void* register_args, void* stack_args, - ffi_closure* closure, void* rvalue, - unsigned int* rtype, unsigned int* rsize) -{ - /* prepare arguments for closure call */ - ffi_cif* cif = closure->cif; - ffi_type** arg_types = cif->arg_types; - - /* re-allocate data for the args. This needs to be done in order to keep - * multi-word objects (e.g. structs) in contigious memory. Callers are not - * required to store the value of args in the lower 6 words in the stack - * (although they are allocated in the stack). - */ - char* stackclone = alloca(cif->bytes); - void** avalue = alloca(cif->nargs * sizeof(void*)); - void* struct_rvalue = NULL; - char* ptr = stackclone; - int i; - - /* copy registers into stack clone */ - int registers_used = cif->bytes; - if (registers_used > ARGS_REGISTER_SIZE) { - registers_used = ARGS_REGISTER_SIZE; - } - memcpy(stackclone, register_args, registers_used); - - /* copy stack allocated args into stack clone */ - if (cif->bytes > ARGS_REGISTER_SIZE) { - int stack_used = cif->bytes - ARGS_REGISTER_SIZE; - memcpy(stackclone + ARGS_REGISTER_SIZE, stack_args, stack_used); - } - - /* preserve struct type return pointer passing */ - if ((cif->rtype != NULL) && (cif->rtype->type == FFI_TYPE_STRUCT)) { - struct_rvalue = *((void**)ptr); - ptr += WORD_SIZE; - } - - /* populate arg pointer list */ - for (i = 0; i < cif->nargs; i++) - { - switch (arg_types[i]->type) - { - case FFI_TYPE_SINT8: - case FFI_TYPE_UINT8: -#ifdef __BIG_ENDIAN__ - avalue[i] = ptr + 3; -#else - avalue[i] = ptr; -#endif - break; - case FFI_TYPE_SINT16: - case FFI_TYPE_UINT16: -#ifdef __BIG_ENDIAN__ - avalue[i] = ptr + 2; -#else - avalue[i] = ptr; -#endif - break; - case FFI_TYPE_STRUCT: -#if __BIG_ENDIAN__ - /* - * Work around strange ABI behaviour. - * (see info in ffi_prep_args) - */ - if (arg_types[i]->size < WORD_SIZE) - { - memcpy (ptr, ptr + (WORD_SIZE - arg_types[i]->size), arg_types[i]->size); - } -#endif - avalue[i] = (void*)ptr; - break; - case FFI_TYPE_UINT64: - case FFI_TYPE_SINT64: - case FFI_TYPE_DOUBLE: - avalue[i] = ptr; - break; - case FFI_TYPE_SINT32: - case FFI_TYPE_UINT32: - case FFI_TYPE_FLOAT: - default: - /* default 4-byte argument */ - avalue[i] = ptr; - break; - } - ptr += WORD_ALIGN(arg_types[i]->size); - } - - /* set the return type info passed back to the wrapper */ - *rsize = cif->rtype->size; - *rtype = cif->rtype->type; - if (struct_rvalue != NULL) { - closure->fun(cif, struct_rvalue, avalue, closure->user_data); - /* copy struct return pointer value into function return value */ - *((void**)rvalue) = struct_rvalue; - } else { - closure->fun(cif, rvalue, avalue, closure->user_data); - } -} - -ffi_status ffi_prep_closure_loc( - ffi_closure* closure, ffi_cif* cif, - void (*fun)(ffi_cif*, void*, void**, void*), - void* user_data, void* codeloc) -{ - unsigned long* tramp = (unsigned long*)&(closure->tramp[0]); - unsigned long cls = (unsigned long)codeloc; - unsigned long fn = 0; - unsigned long fn_closure_call_sysv = (unsigned long)ffi_closure_call_SYSV; - - closure->cif = cif; - closure->fun = fun; - closure->user_data = user_data; - - switch (cif->abi) - { - case FFI_SYSV: - fn = (unsigned long)ffi_closure_SYSV; - - /* load r11 (temp) with fn */ - /* imm fn(upper) */ - tramp[0] = 0xb0000000 | ((fn >> 16) & 0xffff); - /* addik r11, r0, fn(lower) */ - tramp[1] = 0x31600000 | (fn & 0xffff); - - /* load r12 (temp) with cls */ - /* imm cls(upper) */ - tramp[2] = 0xb0000000 | ((cls >> 16) & 0xffff); - /* addik r12, r0, cls(lower) */ - tramp[3] = 0x31800000 | (cls & 0xffff); - - /* load r3 (temp) with ffi_closure_call_SYSV */ - /* imm fn_closure_call_sysv(upper) */ - tramp[4] = 0xb0000000 | ((fn_closure_call_sysv >> 16) & 0xffff); - /* addik r3, r0, fn_closure_call_sysv(lower) */ - tramp[5] = 0x30600000 | (fn_closure_call_sysv & 0xffff); - /* branch/jump to address stored in r11 (fn) */ - tramp[6] = 0x98085800; /* bra r11 */ - - break; - default: - return FFI_BAD_ABI; - } - return FFI_OK; -} diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi/src/microblaze/ffitarget.h --- a/Modules/_ctypes/libffi/src/microblaze/ffitarget.h Sat Jul 19 16:34:33 2014 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,53 +0,0 @@ -/* ----------------------------------------------------------------------- - ffitarget.h - Copyright (c) 2012, 2013 Xilinx, Inc - - Target configuration macros for MicroBlaze. - - Permission is hereby granted, free of charge, to any person obtaining - a copy of this software and associated documentation files (the - ``Software''), to deal in the Software without restriction, including - without limitation the rights to use, copy, modify, merge, publish, - distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to - the following conditions: - - The above copyright notice and this permission notice shall be included - in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT - HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, - WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - DEALINGS IN THE SOFTWARE. - ----------------------------------------------------------------------- */ - -#ifndef LIBFFI_TARGET_H -#define LIBFFI_TARGET_H - -#ifndef LIBFFI_H -#error "Please do not include ffitarget.h directly into your source. Use ffi.h instead." -#endif - -#ifndef LIBFFI_ASM -typedef unsigned long ffi_arg; -typedef signed long ffi_sarg; - -typedef enum ffi_abi { - FFI_FIRST_ABI = 0, - FFI_SYSV, - FFI_LAST_ABI, - FFI_DEFAULT_ABI = FFI_SYSV -} ffi_abi; -#endif - -/* Definitions for closures */ - -#define FFI_CLOSURES 1 -#define FFI_NATIVE_RAW_API 0 - -#define FFI_TRAMPOLINE_SIZE (4*8) - -#endif diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi/src/microblaze/sysv.S --- a/Modules/_ctypes/libffi/src/microblaze/sysv.S Sat Jul 19 16:34:33 2014 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,302 +0,0 @@ -/* ----------------------------------------------------------------------- - sysv.S - Copyright (c) 2012, 2013 Xilinx, Inc - - MicroBlaze Foreign Function Interface - - Permission is hereby granted, free of charge, to any person obtaining - a copy of this software and associated documentation files (the - ``Software''), to deal in the Software without restriction, including - without limitation the rights to use, copy, modify, merge, publish, - distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to - the following conditions: - - The above copyright notice and this permission notice shall be included - in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT - HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, - WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - DEALINGS IN THE SOFTWARE. - ----------------------------------------------------------------------- */ - -#define LIBFFI_ASM -#include -#include - - /* - * arg[0] (r5) = ffi_prep_args, - * arg[1] (r6) = &ecif, - * arg[2] (r7) = cif->bytes, - * arg[3] (r8) = cif->flags, - * arg[4] (r9) = ecif.rvalue, - * arg[5] (r10) = fn - * arg[6] (sp[0]) = cif->rtype->type - * arg[7] (sp[4]) = cif->rtype->size - */ - .text - .globl ffi_call_SYSV - .type ffi_call_SYSV, @function -ffi_call_SYSV: - /* push callee saves */ - addik r1, r1, -20 - swi r19, r1, 0 /* Frame Pointer */ - swi r20, r1, 4 /* PIC register */ - swi r21, r1, 8 /* PIC register */ - swi r22, r1, 12 /* save for locals */ - swi r23, r1, 16 /* save for locals */ - - /* save the r5-r10 registers in the stack */ - addik r1, r1, -24 /* increment sp to store 6x 32-bit words */ - swi r5, r1, 0 - swi r6, r1, 4 - swi r7, r1, 8 - swi r8, r1, 12 - swi r9, r1, 16 - swi r10, r1, 20 - - /* save function pointer */ - addik r3, r5, 0 /* copy ffi_prep_args into r3 */ - addik r22, r1, 0 /* save sp for unallocated args into r22 (callee-saved) */ - addik r23, r10, 0 /* save function address into r23 (callee-saved) */ - - /* prepare stack with allocation for n (bytes = r7) args */ - rsub r1, r7, r1 /* subtract bytes from sp */ - - /* prep args for ffi_prep_args call */ - addik r5, r1, 0 /* store stack pointer into arg[0] */ - /* r6 still holds ecif for arg[1] */ - - /* Call ffi_prep_args(stack, &ecif). */ - addik r1, r1, -4 - swi r15, r1, 0 /* store the link register in the frame */ - brald r15, r3 - nop /* branch has delay slot */ - lwi r15, r1, 0 - addik r1, r1, 4 /* restore the link register from the frame */ - /* returns calling stack pointer location */ - - /* prepare args for fn call, prep_args populates them onto the stack */ - lwi r5, r1, 0 /* arg[0] */ - lwi r6, r1, 4 /* arg[1] */ - lwi r7, r1, 8 /* arg[2] */ - lwi r8, r1, 12 /* arg[3] */ - lwi r9, r1, 16 /* arg[4] */ - lwi r10, r1, 20 /* arg[5] */ - - /* call (fn) (...). */ - addik r1, r1, -4 - swi r15, r1, 0 /* store the link register in the frame */ - brald r15, r23 - nop /* branch has delay slot */ - lwi r15, r1, 0 - addik r1, r1, 4 /* restore the link register from the frame */ - - /* Remove the space we pushed for the args. */ - addik r1, r22, 0 /* restore old SP */ - - /* restore this functions parameters */ - lwi r5, r1, 0 /* arg[0] */ - lwi r6, r1, 4 /* arg[1] */ - lwi r7, r1, 8 /* arg[2] */ - lwi r8, r1, 12 /* arg[3] */ - lwi r9, r1, 16 /* arg[4] */ - lwi r10, r1, 20 /* arg[5] */ - addik r1, r1, 24 /* decrement sp to de-allocate 6x 32-bit words */ - - /* If the return value pointer is NULL, assume no return value. */ - beqi r9, ffi_call_SYSV_end - - lwi r22, r1, 48 /* get return type (20 for locals + 28 for arg[6]) */ - lwi r23, r1, 52 /* get return size (20 for locals + 32 for arg[7]) */ - - /* Check if return type is actually a struct, do nothing */ - rsubi r11, r22, FFI_TYPE_STRUCT - beqi r11, ffi_call_SYSV_end - - /* Return 8bit */ - rsubi r11, r23, 1 - beqi r11, ffi_call_SYSV_store8 - - /* Return 16bit */ - rsubi r11, r23, 2 - beqi r11, ffi_call_SYSV_store16 - - /* Return 32bit */ - rsubi r11, r23, 4 - beqi r11, ffi_call_SYSV_store32 - - /* Return 64bit */ - rsubi r11, r23, 8 - beqi r11, ffi_call_SYSV_store64 - - /* Didnt match anything */ - bri ffi_call_SYSV_end - -ffi_call_SYSV_store64: - swi r3, r9, 0 /* store word r3 into return value */ - swi r4, r9, 4 /* store word r4 into return value */ - bri ffi_call_SYSV_end - -ffi_call_SYSV_store32: - swi r3, r9, 0 /* store word r3 into return value */ - bri ffi_call_SYSV_end - -ffi_call_SYSV_store16: -#ifdef __BIG_ENDIAN__ - shi r3, r9, 2 /* store half-word r3 into return value */ -#else - shi r3, r9, 0 /* store half-word r3 into return value */ -#endif - bri ffi_call_SYSV_end - -ffi_call_SYSV_store8: -#ifdef __BIG_ENDIAN__ - sbi r3, r9, 3 /* store byte r3 into return value */ -#else - sbi r3, r9, 0 /* store byte r3 into return value */ -#endif - bri ffi_call_SYSV_end - -ffi_call_SYSV_end: - /* callee restores */ - lwi r19, r1, 0 /* frame pointer */ - lwi r20, r1, 4 /* PIC register */ - lwi r21, r1, 8 /* PIC register */ - lwi r22, r1, 12 - lwi r23, r1, 16 - addik r1, r1, 20 - - /* return from sub-routine (with delay slot) */ - rtsd r15, 8 - nop - - .size ffi_call_SYSV, . - ffi_call_SYSV - -/* ------------------------------------------------------------------------- */ - - /* - * args passed into this function, are passed down to the callee. - * this function is the target of the closure trampoline, as such r12 is - * a pointer to the closure object. - */ - .text - .globl ffi_closure_SYSV - .type ffi_closure_SYSV, @function -ffi_closure_SYSV: - /* push callee saves */ - addik r11, r1, 28 /* save stack args start location (excluding regs/link) */ - addik r1, r1, -12 - swi r19, r1, 0 /* Frame Pointer */ - swi r20, r1, 4 /* PIC register */ - swi r21, r1, 8 /* PIC register */ - - /* store register args on stack */ - addik r1, r1, -24 - swi r5, r1, 0 - swi r6, r1, 4 - swi r7, r1, 8 - swi r8, r1, 12 - swi r9, r1, 16 - swi r10, r1, 20 - - /* setup args */ - addik r5, r1, 0 /* register_args */ - addik r6, r11, 0 /* stack_args */ - addik r7, r12, 0 /* closure object */ - addik r1, r1, -8 /* allocate return value */ - addik r8, r1, 0 /* void* rvalue */ - addik r1, r1, -8 /* allocate for reutrn type/size values */ - addik r9, r1, 0 /* void* rtype */ - addik r10, r1, 4 /* void* rsize */ - - /* call the wrap_call function */ - addik r1, r1, -28 /* allocate args + link reg */ - swi r15, r1, 0 /* store the link register in the frame */ - brald r15, r3 - nop /* branch has delay slot */ - lwi r15, r1, 0 - addik r1, r1, 28 /* restore the link register from the frame */ - -ffi_closure_SYSV_prepare_return: - lwi r9, r1, 0 /* rtype */ - lwi r10, r1, 4 /* rsize */ - addik r1, r1, 8 /* de-allocate return info values */ - - /* Check if return type is actually a struct, store 4 bytes */ - rsubi r11, r9, FFI_TYPE_STRUCT - beqi r11, ffi_closure_SYSV_store32 - - /* Return 8bit */ - rsubi r11, r10, 1 - beqi r11, ffi_closure_SYSV_store8 - - /* Return 16bit */ - rsubi r11, r10, 2 - beqi r11, ffi_closure_SYSV_store16 - - /* Return 32bit */ - rsubi r11, r10, 4 - beqi r11, ffi_closure_SYSV_store32 - - /* Return 64bit */ - rsubi r11, r10, 8 - beqi r11, ffi_closure_SYSV_store64 - - /* Didnt match anything */ - bri ffi_closure_SYSV_end - -ffi_closure_SYSV_store64: - lwi r3, r1, 0 /* store word r3 into return value */ - lwi r4, r1, 4 /* store word r4 into return value */ - /* 64 bits == 2 words, no sign extend occurs */ - bri ffi_closure_SYSV_end - -ffi_closure_SYSV_store32: - lwi r3, r1, 0 /* store word r3 into return value */ - /* 32 bits == 1 word, no sign extend occurs */ - bri ffi_closure_SYSV_end - -ffi_closure_SYSV_store16: -#ifdef __BIG_ENDIAN__ - lhui r3, r1, 2 /* store half-word r3 into return value */ -#else - lhui r3, r1, 0 /* store half-word r3 into return value */ -#endif - rsubi r11, r9, FFI_TYPE_SINT16 - bnei r11, ffi_closure_SYSV_end - sext16 r3, r3 /* fix sign extend of sint8 */ - bri ffi_closure_SYSV_end - -ffi_closure_SYSV_store8: -#ifdef __BIG_ENDIAN__ - lbui r3, r1, 3 /* store byte r3 into return value */ -#else - lbui r3, r1, 0 /* store byte r3 into return value */ -#endif - rsubi r11, r9, FFI_TYPE_SINT8 - bnei r11, ffi_closure_SYSV_end - sext8 r3, r3 /* fix sign extend of sint8 */ - bri ffi_closure_SYSV_end - -ffi_closure_SYSV_end: - addik r1, r1, 8 /* de-allocate return value */ - - /* de-allocate stored args */ - addik r1, r1, 24 - - /* callee restores */ - lwi r19, r1, 0 /* frame pointer */ - lwi r20, r1, 4 /* PIC register */ - lwi r21, r1, 8 /* PIC register */ - addik r1, r1, 12 - - /* return from sub-routine (with delay slot) */ - rtsd r15, 8 - nop - - .size ffi_closure_SYSV, . - ffi_closure_SYSV diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi/src/mips/ffi.c --- a/Modules/_ctypes/libffi/src/mips/ffi.c Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/_ctypes/libffi/src/mips/ffi.c Sun Jul 20 10:52:46 2014 -0400 @@ -1,7 +1,6 @@ /* ----------------------------------------------------------------------- - ffi.c - Copyright (c) 2011 Anthony Green - Copyright (c) 2008 David Daney - Copyright (c) 1996, 2007, 2008, 2011 Red Hat, Inc. + ffi.c - Copyright (c) 1996, 2007, 2008 Red Hat, Inc. + Copyright (c) 2008 David Daney MIPS Foreign Function Interface @@ -38,11 +37,7 @@ #endif #ifndef USE__BUILTIN___CLEAR_CACHE -# if defined(__OpenBSD__) -# include -# else -# include -# endif +#include #endif #ifdef FFI_DEBUG @@ -667,19 +662,10 @@ char *clear_location = (char *) codeloc; #if defined(FFI_MIPS_O32) - if (cif->abi != FFI_O32 && cif->abi != FFI_O32_SOFT_FLOAT) - return FFI_BAD_ABI; + FFI_ASSERT(cif->abi == FFI_O32 || cif->abi == FFI_O32_SOFT_FLOAT); fn = ffi_closure_O32; -#else -#if _MIPS_SIM ==_ABIN32 - if (cif->abi != FFI_N32 - && cif->abi != FFI_N32_SOFT_FLOAT) - return FFI_BAD_ABI; -#else - if (cif->abi != FFI_N64 - && cif->abi != FFI_N64_SOFT_FLOAT) - return FFI_BAD_ABI; -#endif +#else /* FFI_MIPS_N32 */ + FFI_ASSERT(cif->abi == FFI_N32 || cif->abi == FFI_N64); fn = ffi_closure_N32; #endif /* FFI_MIPS_O32 */ diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi/src/mips/ffitarget.h --- a/Modules/_ctypes/libffi/src/mips/ffitarget.h Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/_ctypes/libffi/src/mips/ffitarget.h Sun Jul 20 10:52:46 2014 -0400 @@ -1,6 +1,5 @@ /* -----------------------------------------------------------------*-C-*- - ffitarget.h - Copyright (c) 2012 Anthony Green - Copyright (c) 1996-2003 Red Hat, Inc. + ffitarget.h - Copyright (c) 1996-2003 Red Hat, Inc. Target configuration macros for MIPS. Permission is hereby granted, free of charge, to any person obtaining @@ -28,23 +27,11 @@ #ifndef LIBFFI_TARGET_H #define LIBFFI_TARGET_H -#ifndef LIBFFI_H -#error "Please do not include ffitarget.h directly into your source. Use ffi.h instead." -#endif - #ifdef linux # include -#elif defined(__rtems__) -/* - * Subprogram calling convention - copied from sgidefs.h - */ -#define _MIPS_SIM_ABI32 1 -#define _MIPS_SIM_NABI32 2 -#define _MIPS_SIM_ABI64 3 -#elif !defined(__OpenBSD__) +#else # include #endif - # ifndef _ABIN32 # define _ABIN32 _MIPS_SIM_NABI32 # endif @@ -56,7 +43,7 @@ # endif #if !defined(_MIPS_SIM) -# error -- something is very wrong -- +-- something is very wrong -- #else # if (_MIPS_SIM==_ABIN32 && defined(_ABIN32)) || (_MIPS_SIM==_ABI64 && defined(_ABI64)) # define FFI_MIPS_N32 @@ -64,7 +51,7 @@ # if (_MIPS_SIM==_ABIO32 && defined(_ABIO32)) # define FFI_MIPS_O32 # else -# error -- this is an unsupported platform -- +-- this is an unsupported platform -- # endif # endif #endif @@ -199,29 +186,30 @@ FFI_O32_SOFT_FLOAT, FFI_N32_SOFT_FLOAT, FFI_N64_SOFT_FLOAT, - FFI_LAST_ABI, #ifdef FFI_MIPS_O32 #ifdef __mips_soft_float - FFI_DEFAULT_ABI = FFI_O32_SOFT_FLOAT + FFI_DEFAULT_ABI = FFI_O32_SOFT_FLOAT, #else - FFI_DEFAULT_ABI = FFI_O32 + FFI_DEFAULT_ABI = FFI_O32, #endif #else # if _MIPS_SIM==_ABI64 # ifdef __mips_soft_float - FFI_DEFAULT_ABI = FFI_N64_SOFT_FLOAT + FFI_DEFAULT_ABI = FFI_N64_SOFT_FLOAT, # else - FFI_DEFAULT_ABI = FFI_N64 + FFI_DEFAULT_ABI = FFI_N64, # endif # else # ifdef __mips_soft_float - FFI_DEFAULT_ABI = FFI_N32_SOFT_FLOAT + FFI_DEFAULT_ABI = FFI_N32_SOFT_FLOAT, # else - FFI_DEFAULT_ABI = FFI_N32 + FFI_DEFAULT_ABI = FFI_N32, # endif # endif #endif + + FFI_LAST_ABI = FFI_DEFAULT_ABI + 1 } ffi_abi; #define FFI_EXTRA_CIF_FIELDS unsigned rstruct_flag diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi/src/mips/n32.S --- a/Modules/_ctypes/libffi/src/mips/n32.S Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/_ctypes/libffi/src/mips/n32.S Sun Jul 20 10:52:46 2014 -0400 @@ -43,7 +43,6 @@ #ifdef __GNUC__ .abicalls #endif - .set mips4 .text .align 2 .globl ffi_call_N32 diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi/src/moxie/eabi.S --- a/Modules/_ctypes/libffi/src/moxie/eabi.S Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/_ctypes/libffi/src/moxie/eabi.S Sun Jul 20 10:52:46 2014 -0400 @@ -1,7 +1,7 @@ /* ----------------------------------------------------------------------- - eabi.S - Copyright (c) 2012, 2013 Anthony Green + eabi.S - Copyright (c) 2004 Anthony Green - Moxie Assembly glue. + FR-V Assembly glue. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the @@ -34,68 +34,95 @@ .globl ffi_call_EABI .type ffi_call_EABI, @function - # $r0 : ffi_prep_args - # $r1 : &ecif - # $r2 : cif->bytes - # $r3 : fig->flags - # $r4 : ecif.rvalue - # $r5 : fn + # gr8 : ffi_prep_args + # gr9 : &ecif + # gr10: cif->bytes + # gr11: fig->flags + # gr12: ecif.rvalue + # gr13: fn -ffi_call_EABI: - push $sp, $r6 - push $sp, $r7 - push $sp, $r8 - dec $sp, 24 +ffi_call_EABI: + addi sp, #-80, sp + sti fp, @(sp, #24) + addi sp, #24, fp + movsg lr, gr5 - /* Store incoming args on stack. */ - sto.l 0($sp), $r0 /* ffi_prep_args */ - sto.l 4($sp), $r1 /* ecif */ - sto.l 8($sp), $r2 /* bytes */ - sto.l 12($sp), $r3 /* flags */ - sto.l 16($sp), $r4 /* &rvalue */ - sto.l 20($sp), $r5 /* fn */ + /* Make room for the new arguments. */ + /* subi sp, fp, gr10 */ + + /* Store return address and incoming args on stack. */ + sti gr5, @(fp, #8) + sti gr8, @(fp, #-4) + sti gr9, @(fp, #-8) + sti gr10, @(fp, #-12) + sti gr11, @(fp, #-16) + sti gr12, @(fp, #-20) + sti gr13, @(fp, #-24) + + sub sp, gr10, sp /* Call ffi_prep_args. */ - mov $r6, $r4 /* Save result buffer */ - mov $r7, $r5 /* Save the target fn */ - mov $r8, $r3 /* Save the flags */ - sub.l $sp, $r2 /* Allocate stack space */ - mov $r0, $sp /* We can stomp over $r0 */ - /* $r1 is already set up */ - jsra ffi_prep_args + ldi @(fp, #-4), gr4 + addi sp, #0, gr8 + ldi @(fp, #-8), gr9 +#ifdef __FRV_FDPIC__ + ldd @(gr4, gr0), gr14 + calll @(gr14, gr0) +#else + calll @(gr4, gr0) +#endif - /* Load register arguments. */ - ldo.l $r0, 0($sp) - ldo.l $r1, 4($sp) - ldo.l $r2, 8($sp) - ldo.l $r3, 12($sp) - ldo.l $r4, 16($sp) - ldo.l $r5, 20($sp) + /* ffi_prep_args returns the new stack pointer. */ + mov gr8, gr4 + + ldi @(sp, #0), gr8 + ldi @(sp, #4), gr9 + ldi @(sp, #8), gr10 + ldi @(sp, #12), gr11 + ldi @(sp, #16), gr12 + ldi @(sp, #20), gr13 + + /* Always copy the return value pointer into the hidden + parameter register. This is only strictly necessary + when we're returning an aggregate type, but it doesn't + hurt to do this all the time, and it saves a branch. */ + ldi @(fp, #-20), gr3 + + /* Use the ffi_prep_args return value for the new sp. */ + mov gr4, sp /* Call the target function. */ - jsr $r7 + ldi @(fp, -24), gr4 +#ifdef __FRV_FDPIC__ + ldd @(gr4, gr0), gr14 + calll @(gr14, gr0) +#else + calll @(gr4, gr0) +#endif - ldi.l $r7, 0xffffffff - cmp $r8, $r7 - beq retstruct + /* Store the result. */ + ldi @(fp, #-16), gr10 /* fig->flags */ + ldi @(fp, #-20), gr4 /* ecif.rvalue */ - ldi.l $r7, 4 - cmp $r8, $r7 - bgt ret2reg + /* Is the return value stored in two registers? */ + cmpi gr10, #8, icc0 + bne icc0, 0, .L2 + /* Yes, save them. */ + sti gr8, @(gr4, #0) + sti gr9, @(gr4, #4) + bra .L3 +.L2: + /* Is the return value a structure? */ + cmpi gr10, #-1, icc0 + beq icc0, 0, .L3 + /* No, save a 4 byte return value. */ + sti gr8, @(gr4, #0) +.L3: - st.l ($r6), $r0 - jmpa retdone - -ret2reg: - st.l ($r6), $r0 - sto.l 4($r6), $r1 - -retstruct: -retdone: - /* Return. */ - ldo.l $r6, -4($fp) - ldo.l $r7, -8($fp) - ldo.l $r8, -12($fp) - ret + /* Restore the stack, and return. */ + ldi @(fp, 8), gr5 + ld @(fp, gr0), fp + addi sp,#80,sp + jmpl @(gr5,gr0) .size ffi_call_EABI, .-ffi_call_EABI diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi/src/moxie/ffi.c --- a/Modules/_ctypes/libffi/src/moxie/ffi.c Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/_ctypes/libffi/src/moxie/ffi.c Sun Jul 20 10:52:46 2014 -0400 @@ -1,5 +1,5 @@ /* ----------------------------------------------------------------------- - ffi.c - Copyright (C) 2012, 2013 Anthony Green + ffi.c - Copyright (C) 2009 Anthony Green Moxie Foreign Function Interface @@ -43,12 +43,6 @@ p_argv = ecif->avalue; argp = stack; - if (ecif->cif->rtype->type == FFI_TYPE_STRUCT) - { - *(void **) argp = ecif->rvalue; - argp += 4; - } - for (i = ecif->cif->nargs, p_arg = ecif->cif->arg_types; (i != 0); i--, p_arg++) @@ -62,6 +56,17 @@ z = sizeof(void*); *(void **) argp = *p_argv; } + /* if ((*p_arg)->type == FFI_TYPE_FLOAT) + { + if (count > 24) + { + // This is going on the stack. Turn it into a double. + *(double *) argp = (double) *(float*)(* p_argv); + z = sizeof(double); + } + else + *(void **) argp = *(void **)(* p_argv); + } */ else if (z < sizeof(int)) { z = sizeof(int); @@ -142,7 +147,8 @@ } else ecif.rvalue = rvalue; - + + switch (cif->abi) { case FFI_EABI: @@ -159,25 +165,19 @@ unsigned arg4, unsigned arg5, unsigned arg6) { /* This function is called by a trampoline. The trampoline stows a - pointer to the ffi_closure object in $r7. We must save this + pointer to the ffi_closure object in gr7. We must save this pointer in a place that will persist while we do our work. */ - register ffi_closure *creg __asm__ ("$r12"); + register ffi_closure *creg __asm__ ("gr7"); ffi_closure *closure = creg; /* Arguments that don't fit in registers are found on the stack at a fixed offset above the current frame pointer. */ - register char *frame_pointer __asm__ ("$fp"); - - /* Pointer to a struct return value. */ - void *struct_rvalue = (void *) arg1; - - /* 6 words reserved for register args + 3 words from jsr */ - char *stack_args = frame_pointer + 9*4; + register char *frame_pointer __asm__ ("fp"); + char *stack_args = frame_pointer + 16; /* Lay the register arguments down in a continuous chunk of memory. */ unsigned register_args[6] = { arg1, arg2, arg3, arg4, arg5, arg6 }; - char *register_args_ptr = (char *) register_args; ffi_cif *cif = closure->cif; ffi_type **arg_types = cif->arg_types; @@ -185,12 +185,6 @@ char *ptr = (char *) register_args; int i; - /* preserve struct type return pointer passing */ - if ((cif->rtype != NULL) && (cif->rtype->type == FFI_TYPE_STRUCT)) { - ptr += 4; - register_args_ptr = (char *)®ister_args[1]; - } - /* Find the address of each argument. */ for (i = 0; i < cif->nargs; i++) { @@ -207,7 +201,6 @@ case FFI_TYPE_SINT32: case FFI_TYPE_UINT32: case FFI_TYPE_FLOAT: - case FFI_TYPE_POINTER: avalue[i] = ptr; break; case FFI_TYPE_STRUCT: @@ -223,21 +216,30 @@ /* If we've handled more arguments than fit in registers, start looking at the those passed on the stack. */ - if (ptr == ®ister_args[6]) + if (ptr == ((char *)register_args + (6*4))) ptr = stack_args; } /* Invoke the closure. */ - if (cif->rtype && (cif->rtype->type == FFI_TYPE_STRUCT)) + if (cif->rtype->type == FFI_TYPE_STRUCT) { - (closure->fun) (cif, struct_rvalue, avalue, closure->user_data); + /* The caller allocates space for the return structure, and + passes a pointer to this space in gr3. Use this value directly + as the return value. */ + register void *return_struct_ptr __asm__("gr3"); + (closure->fun) (cif, return_struct_ptr, avalue, closure->user_data); } else { /* Allocate space for the return value and call the function. */ long long rvalue; (closure->fun) (cif, &rvalue, avalue, closure->user_data); - asm ("mov $r12, %0\n ld.l $r0, ($r12)\n ldo.l $r1, 4($r12)" : : "r" (&rvalue)); + + /* Functions return 4-byte or smaller results in gr8. 8-byte + values also use gr9. We fill the both, even for small return + values, just to avoid a branch. */ + asm ("ldi @(%0, #0), gr8" : : "r" (&rvalue)); + asm ("ldi @(%0, #0), gr9" : : "r" (&((int *) &rvalue)[1])); } } @@ -248,25 +250,27 @@ void *user_data, void *codeloc) { - unsigned short *tramp = (unsigned short *) &closure->tramp[0]; + unsigned int *tramp = (unsigned int *) &closure->tramp[0]; unsigned long fn = (long) ffi_closure_eabi; unsigned long cls = (long) codeloc; - - if (cif->abi != FFI_EABI) - return FFI_BAD_ABI; + int i; fn = (unsigned long) ffi_closure_eabi; - tramp[0] = 0x01e0; /* ldi.l $r7, .... */ - tramp[1] = cls >> 16; - tramp[2] = cls & 0xffff; - tramp[3] = 0x1a00; /* jmpa .... */ - tramp[4] = fn >> 16; - tramp[5] = fn & 0xffff; + tramp[0] = 0x8cfc0000 + (fn & 0xffff); /* setlos lo(fn), gr6 */ + tramp[1] = 0x8efc0000 + (cls & 0xffff); /* setlos lo(cls), gr7 */ + tramp[2] = 0x8cf80000 + (fn >> 16); /* sethi hi(fn), gr6 */ + tramp[3] = 0x8ef80000 + (cls >> 16); /* sethi hi(cls), gr7 */ + tramp[4] = 0x80300006; /* jmpl @(gr0, gr6) */ closure->cif = cif; closure->fun = fun; closure->user_data = user_data; + /* Cache flushing. */ + for (i = 0; i < FFI_TRAMPOLINE_SIZE; i++) + __asm__ volatile ("dcf @(%0,%1)\n\tici @(%2,%1)" :: "r" (tramp), "r" (i), + "r" (codeloc)); + return FFI_OK; } diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi/src/moxie/ffitarget.h --- a/Modules/_ctypes/libffi/src/moxie/ffitarget.h Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/_ctypes/libffi/src/moxie/ffitarget.h Sun Jul 20 10:52:46 2014 -0400 @@ -1,5 +1,5 @@ /* -----------------------------------------------------------------*-C-*- - ffitarget.h - Copyright (c) 2012, 2013 Anthony Green + ffitarget.h - Copyright (c) 2009 Anthony Green Target configuration macros for Moxie Permission is hereby granted, free of charge, to any person obtaining @@ -35,18 +35,22 @@ typedef enum ffi_abi { FFI_FIRST_ABI = 0, + +#ifdef MOXIE FFI_EABI, FFI_DEFAULT_ABI = FFI_EABI, +#endif + FFI_LAST_ABI = FFI_DEFAULT_ABI + 1 } ffi_abi; #endif /* ---- Definitions for closures ----------------------------------------- */ -#define FFI_CLOSURES 1 +#define FFI_CLOSURES 0 #define FFI_NATIVE_RAW_API 0 -/* Trampolines are 12-bytes long. See ffi_prep_closure_loc. */ -#define FFI_TRAMPOLINE_SIZE (12) +/* Trampolines are 5 4-byte instructions long. */ +#define FFI_TRAMPOLINE_SIZE (5*4) #endif diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi/src/pa/ffi.c --- a/Modules/_ctypes/libffi/src/pa/ffi.c Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/_ctypes/libffi/src/pa/ffi.c Sun Jul 20 10:52:46 2014 -0400 @@ -1,11 +1,9 @@ /* ----------------------------------------------------------------------- - ffi.c - (c) 2011 Anthony Green + ffi.c - (c) 2003-2004 Randolph Chung (c) 2008 Red Hat, Inc. - (c) 2006 Free Software Foundation, Inc. - (c) 2003-2004 Randolph Chung - + HPPA Foreign Function Interface - HP-UX PA ABI support + HP-UX PA ABI support (c) 2006 Free Software Foundation, Inc. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the @@ -635,8 +633,7 @@ UINT32 *tmp; #endif - if (cif->abi != FFI_PA32) - return FFI_BAD_ABI; + FFI_ASSERT (cif->abi == FFI_PA32); /* Make a small trampoline that will branch to our handler function. Use PC-relative addressing. */ diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi/src/pa/ffitarget.h --- a/Modules/_ctypes/libffi/src/pa/ffitarget.h Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/_ctypes/libffi/src/pa/ffitarget.h Sun Jul 20 10:52:46 2014 -0400 @@ -1,6 +1,5 @@ /* -----------------------------------------------------------------*-C-*- - ffitarget.h - Copyright (c) 2012 Anthony Green - Copyright (c) 1996-2003 Red Hat, Inc. + ffitarget.h - Copyright (c) 1996-2003 Red Hat, Inc. Target configuration macros for hppa. Permission is hereby granted, free of charge, to any person obtaining @@ -28,10 +27,6 @@ #ifndef LIBFFI_TARGET_H #define LIBFFI_TARGET_H -#ifndef LIBFFI_H -#error "Please do not include ffitarget.h directly into your source. Use ffi.h instead." -#endif - /* ---- System specific configurations ----------------------------------- */ #ifndef LIBFFI_ASM @@ -43,22 +38,21 @@ #ifdef PA_LINUX FFI_PA32, - FFI_LAST_ABI, - FFI_DEFAULT_ABI = FFI_PA32 + FFI_DEFAULT_ABI = FFI_PA32, #endif #ifdef PA_HPUX FFI_PA32, - FFI_LAST_ABI, - FFI_DEFAULT_ABI = FFI_PA32 + FFI_DEFAULT_ABI = FFI_PA32, #endif #ifdef PA64_HPUX #error "PA64_HPUX FFI is not yet implemented" FFI_PA64, - FFI_LAST_ABI, - FFI_DEFAULT_ABI = FFI_PA64 + FFI_DEFAULT_ABI = FFI_PA64, #endif + + FFI_LAST_ABI = FFI_DEFAULT_ABI + 1 } ffi_abi; #endif diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi/src/powerpc/aix.S --- a/Modules/_ctypes/libffi/src/powerpc/aix.S Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/_ctypes/libffi/src/powerpc/aix.S Sun Jul 20 10:52:46 2014 -0400 @@ -1,5 +1,5 @@ /* ----------------------------------------------------------------------- - aix.S - Copyright (c) 2002, 2009 Free Software Foundation, Inc. + aix.S - Copyright (c) 2002,2009 Free Software Foundation, Inc. based on darwin.S by John Hornkvist PowerPC Assembly glue. @@ -79,8 +79,6 @@ .set f20,20 .set f21,21 - .extern .ffi_prep_args - #define LIBFFI_ASM #include #include @@ -127,7 +125,6 @@ /* Call ffi_prep_args. */ mr r4, r1 bl .ffi_prep_args - nop /* Now do the call. */ ld r0, 0(r29) @@ -137,7 +134,7 @@ mtcrf 0x40, r31 mtctr r0 /* Load all those argument registers. */ - /* We have set up a nice stack frame, just load it into registers. */ + // We have set up a nice stack frame, just load it into registers. ld r3, 40+(1*8)(r1) ld r4, 40+(2*8)(r1) ld r5, 40+(3*8)(r1) @@ -150,7 +147,7 @@ L1: /* Load all the FP registers. */ - bf 6,L2 /* 2f + 0x18 */ + bf 6,L2 // 2f + 0x18 lfd f1,-32-(13*8)(r28) lfd f2,-32-(12*8)(r28) lfd f3,-32-(11*8)(r28) @@ -229,7 +226,6 @@ /* Call ffi_prep_args. */ mr r4, r1 bl .ffi_prep_args - nop /* Now do the call. */ lwz r0, 0(r29) @@ -239,7 +235,7 @@ mtcrf 0x40, r31 mtctr r0 /* Load all those argument registers. */ - /* We have set up a nice stack frame, just load it into registers. */ + // We have set up a nice stack frame, just load it into registers. lwz r3, 20+(1*4)(r1) lwz r4, 20+(2*4)(r1) lwz r5, 20+(3*4)(r1) @@ -252,7 +248,7 @@ L1: /* Load all the FP registers. */ - bf 6,L2 /* 2f + 0x18 */ + bf 6,L2 // 2f + 0x18 lfd f1,-16-(13*8)(r28) lfd f2,-16-(12*8)(r28) lfd f3,-16-(11*8)(r28) @@ -307,7 +303,7 @@ #endif .long 0 .byte 0,0,0,1,128,4,0,0 -/* END(ffi_call_AIX) */ +//END(ffi_call_AIX) .csect .text[PR] .align 2 @@ -325,4 +321,4 @@ blr .long 0 .byte 0,0,0,0,0,0,0,0 -/* END(ffi_call_DARWIN) */ +//END(ffi_call_DARWIN) diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi/src/powerpc/aix_closure.S --- a/Modules/_ctypes/libffi/src/powerpc/aix_closure.S Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/_ctypes/libffi/src/powerpc/aix_closure.S Sun Jul 20 10:52:46 2014 -0400 @@ -79,8 +79,6 @@ .set f20,20 .set f21,21 - .extern .ffi_closure_helper_DARWIN - #define LIBFFI_ASM #define JUMPTARGET(name) name #define L(x) x @@ -167,7 +165,6 @@ /* look up the proper starting point in table */ /* by using return type as offset */ - lhz r3, 10(r3) /* load type from return type */ ld r4, LC..60(2) /* get address of jump table */ sldi r3, r3, 4 /* now multiply return type by 16 */ ld r0, 240+16(r1) /* load return address */ @@ -340,9 +337,8 @@ /* look up the proper starting point in table */ /* by using return type as offset */ - lhz r3, 6(r3) /* load type from return type */ lwz r4, LC..60(2) /* get address of jump table */ - slwi r3, r3, 4 /* now multiply return type by 16 */ + slwi r3, r3, 4 /* now multiply return type by 4 */ lwz r0, 176+8(r1) /* load return address */ add r3, r3, r4 /* add contents of table to table address */ mtctr r3 diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi/src/powerpc/asm.h --- a/Modules/_ctypes/libffi/src/powerpc/asm.h Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/_ctypes/libffi/src/powerpc/asm.h Sun Jul 20 10:52:46 2014 -0400 @@ -42,7 +42,7 @@ /* If compiled for profiling, call `_mcount' at the start of each function. */ #ifdef PROF -/* The mcount code relies on the return address being on the stack +/* The mcount code relies on a the return address being on the stack to locate our caller and so it can restore it; so store one just for its benefit. */ #ifdef PIC diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi/src/powerpc/darwin.S --- a/Modules/_ctypes/libffi/src/powerpc/darwin.S Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/_ctypes/libffi/src/powerpc/darwin.S Sun Jul 20 10:52:46 2014 -0400 @@ -1,6 +1,6 @@ /* ----------------------------------------------------------------------- darwin.S - Copyright (c) 2000 John Hornkvist - Copyright (c) 2004, 2010 Free Software Foundation, Inc. + Copyright (c) 2004 Free Software Foundation, Inc. PowerPC Assembly glue. @@ -24,92 +24,51 @@ OTHER DEALINGS IN THE SOFTWARE. ----------------------------------------------------------------------- */ -#define LIBFFI_ASM #if defined(__ppc64__) #define MODE_CHOICE(x, y) y #else #define MODE_CHOICE(x, y) x #endif -#define machine_choice MODE_CHOICE(ppc7400,ppc64) +#define g_long MODE_CHOICE(long, quad) /* usage is ".g_long" */ -; Define some pseudo-opcodes for size-independent load & store of GPRs ... -#define lgu MODE_CHOICE(lwzu, ldu) -#define lg MODE_CHOICE(lwz,ld) -#define sg MODE_CHOICE(stw,std) -#define sgu MODE_CHOICE(stwu,stdu) -#define sgux MODE_CHOICE(stwux,stdux) +#define LOG2_GPR_BYTES MODE_CHOICE(2,3) /* log2(GPR_BYTES) */ -; ... and the size of GPRs and their storage indicator. -#define GPR_BYTES MODE_CHOICE(4,8) -#define LOG2_GPR_BYTES MODE_CHOICE(2,3) /* log2(GPR_BYTES) */ -#define g_long MODE_CHOICE(long, quad) /* usage is ".g_long" */ - -; From the ABI doc: "Mac OS X ABI Function Call Guide" Version 2009-02-04. -#define LINKAGE_SIZE MODE_CHOICE(24,48) -#define PARAM_AREA MODE_CHOICE(32,64) -#define SAVED_LR_OFFSET MODE_CHOICE(8,16) /* save position for lr */ - -/* If there is any FP stuff we make space for all of the regs. */ -#define SAVED_FPR_COUNT 13 -#define FPR_SIZE 8 -#define RESULT_BYTES 16 - -/* This should be kept in step with the same value in ffi_darwin.c. */ -#define ASM_NEEDS_REGISTERS 4 -#define SAVE_REGS_SIZE (ASM_NEEDS_REGISTERS * GPR_BYTES) - +#define LIBFFI_ASM #include #include - #define JUMPTARGET(name) name #define L(x) x +.text + .align 2 +.globl _ffi_prep_args - .text +.text .align 2 - .globl _ffi_prep_args - +.globl _ffi_call_DARWIN +.text .align 2 - .globl _ffi_call_DARWIN - - /* We arrive here with: - r3 = ptr to extended cif. - r4 = -bytes. - r5 = cif flags. - r6 = ptr to return value. - r7 = fn pointer (user func). - r8 = fn pointer (ffi_prep_args). - r9 = ffi_type* for the ret val. */ - _ffi_call_DARWIN: -Lstartcode: +LFB0: mr r12,r8 /* We only need r12 until the call, - so it does not have to be saved. */ + so it doesn't have to be saved. */ LFB1: /* Save the old stack pointer as AP. */ mr r8,r1 LCFI0: - - /* Save the retval type in parents frame. */ - sg r9,(LINKAGE_SIZE+6*GPR_BYTES)(r8) - /* Allocate the stack space we need. */ - sgux r1,r1,r4 + stwux r1,r1,r4 /* Save registers we use. */ mflr r9 - sg r9,SAVED_LR_OFFSET(r8) - sg r28,-(4 * GPR_BYTES)(r8) - sg r29,-(3 * GPR_BYTES)(r8) - sg r30,-(2 * GPR_BYTES)(r8) - sg r31,-( GPR_BYTES)(r8) + stw r28,-16(r8) + stw r29,-12(r8) + stw r30,-8(r8) + stw r31,-4(r8) -#if !defined(POWERPC_DARWIN) - /* The TOC slot is reserved in the Darwin ABI and r2 is volatile. */ - sg r2,(5 * GPR_BYTES)(r1) -#endif - + stw r9,8(r8) + stw r2,20(r1) LCFI1: /* Save arguments over call. */ @@ -118,17 +77,14 @@ mr r29,r7 /* function address, */ mr r28,r8 /* our AP. */ LCFI2: - /* Call ffi_prep_args. r3 = extended cif, r4 = stack ptr copy. */ + /* Call ffi_prep_args. */ mr r4,r1 li r9,0 mtctr r12 /* r12 holds address of _ffi_prep_args. */ bctrl + lwz r2,20(r1) -#if !defined(POWERPC_DARWIN) - /* The TOC slot is reserved in the Darwin ABI and r2 is volatile. */ - lg r2,(5 * GPR_BYTES)(r1) -#endif /* Now do the call. Set up cr1 with bits 4-7 of the flags. */ mtcrf 0x40,r31 @@ -136,130 +92,71 @@ mtctr r29 /* Load all those argument registers. We have set up a nice stack frame, just load it into registers. */ - lg r3, (LINKAGE_SIZE )(r1) - lg r4, (LINKAGE_SIZE + GPR_BYTES)(r1) - lg r5, (LINKAGE_SIZE + 2 * GPR_BYTES)(r1) - lg r6, (LINKAGE_SIZE + 3 * GPR_BYTES)(r1) + lwz r3,20+(1*4)(r1) + lwz r4,20+(2*4)(r1) + lwz r5,20+(3*4)(r1) + lwz r6,20+(4*4)(r1) nop - lg r7, (LINKAGE_SIZE + 4 * GPR_BYTES)(r1) - lg r8, (LINKAGE_SIZE + 5 * GPR_BYTES)(r1) - lg r9, (LINKAGE_SIZE + 6 * GPR_BYTES)(r1) - lg r10,(LINKAGE_SIZE + 7 * GPR_BYTES)(r1) + lwz r7,20+(5*4)(r1) + lwz r8,20+(6*4)(r1) + lwz r9,20+(7*4)(r1) + lwz r10,20+(8*4)(r1) L1: - /* ... Load all the FP registers. */ + /* Load all the FP registers. */ bf 6,L2 /* No floats to load. */ - lfd f1, -SAVE_REGS_SIZE-(13*FPR_SIZE)(r28) - lfd f2, -SAVE_REGS_SIZE-(12*FPR_SIZE)(r28) - lfd f3, -SAVE_REGS_SIZE-(11*FPR_SIZE)(r28) - lfd f4, -SAVE_REGS_SIZE-(10*FPR_SIZE)(r28) + lfd f1,-16-(13*8)(r28) + lfd f2,-16-(12*8)(r28) + lfd f3,-16-(11*8)(r28) + lfd f4,-16-(10*8)(r28) nop - lfd f5, -SAVE_REGS_SIZE-( 9*FPR_SIZE)(r28) - lfd f6, -SAVE_REGS_SIZE-( 8*FPR_SIZE)(r28) - lfd f7, -SAVE_REGS_SIZE-( 7*FPR_SIZE)(r28) - lfd f8, -SAVE_REGS_SIZE-( 6*FPR_SIZE)(r28) + lfd f5,-16-(9*8)(r28) + lfd f6,-16-(8*8)(r28) + lfd f7,-16-(7*8)(r28) + lfd f8,-16-(6*8)(r28) nop - lfd f9, -SAVE_REGS_SIZE-( 5*FPR_SIZE)(r28) - lfd f10,-SAVE_REGS_SIZE-( 4*FPR_SIZE)(r28) - lfd f11,-SAVE_REGS_SIZE-( 3*FPR_SIZE)(r28) - lfd f12,-SAVE_REGS_SIZE-( 2*FPR_SIZE)(r28) + lfd f9,-16-(5*8)(r28) + lfd f10,-16-(4*8)(r28) + lfd f11,-16-(3*8)(r28) + lfd f12,-16-(2*8)(r28) nop - lfd f13,-SAVE_REGS_SIZE-( 1*FPR_SIZE)(r28) + lfd f13,-16-(1*8)(r28) L2: mr r12,r29 /* Put the target address in r12 as specified. */ mtctr r12 nop nop - /* Make the call. */ bctrl /* Now, deal with the return value. */ + mtcrf 0x01,r31 - /* m64 structure returns can occupy the same set of registers as - would be used to pass such a structure as arg0 - so take care - not to step on any possibly hot regs. */ + bt 30,L(done_return_value) + bt 29,L(fp_return_value) + stw r3,0(r30) + bf 28,L(done_return_value) + stw r4,4(r30) - /* Get the flags.. */ - mtcrf 0x03,r31 ; we need c6 & cr7 now. - ; FLAG_RETURNS_NOTHING also covers struct ret-by-ref. - bt 30,L(done_return_value) ; FLAG_RETURNS_NOTHING - bf 27,L(scalar_return_value) ; not FLAG_RETURNS_STRUCT - - /* OK, so we have a struct. */ -#if defined(__ppc64__) - bt 31,L(maybe_return_128) ; FLAG_RETURNS_128BITS, special case + /* Fall through. */ - /* OK, we have to map the return back to a mem struct. - We are about to trample the parents param area, so recover the - return type. r29 is free, since the call is done. */ - lg r29,(LINKAGE_SIZE + 6 * GPR_BYTES)(r28) - - sg r3, (LINKAGE_SIZE )(r28) - sg r4, (LINKAGE_SIZE + GPR_BYTES)(r28) - sg r5, (LINKAGE_SIZE + 2 * GPR_BYTES)(r28) - sg r6, (LINKAGE_SIZE + 3 * GPR_BYTES)(r28) - nop - sg r7, (LINKAGE_SIZE + 4 * GPR_BYTES)(r28) - sg r8, (LINKAGE_SIZE + 5 * GPR_BYTES)(r28) - sg r9, (LINKAGE_SIZE + 6 * GPR_BYTES)(r28) - sg r10,(LINKAGE_SIZE + 7 * GPR_BYTES)(r28) - /* OK, so do the block move - we trust that memcpy will not trample - the fprs... */ - mr r3,r30 ; dest - addi r4,r28,LINKAGE_SIZE ; source - /* The size is a size_t, should be long. */ - lg r5,0(r29) - /* Figure out small structs */ - cmpi 0,r5,4 - bgt L3 ; 1, 2 and 4 bytes have special rules. - cmpi 0,r5,3 - beq L3 ; not 3 - addi r4,r4,8 - subf r4,r5,r4 -L3: - bl _memcpy - - /* ... do we need the FP registers? - recover the flags.. */ - mtcrf 0x03,r31 ; we need c6 & cr7 now. - bf 29,L(done_return_value) /* No floats in the struct. */ - stfd f1, -SAVE_REGS_SIZE-(13*FPR_SIZE)(r28) - stfd f2, -SAVE_REGS_SIZE-(12*FPR_SIZE)(r28) - stfd f3, -SAVE_REGS_SIZE-(11*FPR_SIZE)(r28) - stfd f4, -SAVE_REGS_SIZE-(10*FPR_SIZE)(r28) - nop - stfd f5, -SAVE_REGS_SIZE-( 9*FPR_SIZE)(r28) - stfd f6, -SAVE_REGS_SIZE-( 8*FPR_SIZE)(r28) - stfd f7, -SAVE_REGS_SIZE-( 7*FPR_SIZE)(r28) - stfd f8, -SAVE_REGS_SIZE-( 6*FPR_SIZE)(r28) - nop - stfd f9, -SAVE_REGS_SIZE-( 5*FPR_SIZE)(r28) - stfd f10,-SAVE_REGS_SIZE-( 4*FPR_SIZE)(r28) - stfd f11,-SAVE_REGS_SIZE-( 3*FPR_SIZE)(r28) - stfd f12,-SAVE_REGS_SIZE-( 2*FPR_SIZE)(r28) - nop - stfd f13,-SAVE_REGS_SIZE-( 1*FPR_SIZE)(r28) - - mr r3,r29 ; ffi_type * - mr r4,r30 ; dest - addi r5,r28,-SAVE_REGS_SIZE-(13*FPR_SIZE) ; fprs - xor r6,r6,r6 - sg r6,(LINKAGE_SIZE + 7 * GPR_BYTES)(r28) - addi r6,r28,(LINKAGE_SIZE + 7 * GPR_BYTES) ; point to a zeroed counter. - bl _darwin64_struct_floats_to_mem - - b L(done_return_value) -#else - stw r3,0(r30) ; m32 the only struct return in reg is 4 bytes. -#endif - b L(done_return_value) +L(done_return_value): + /* Restore the registers we used and return. */ + lwz r9,8(r28) + lwz r31,-4(r28) + mtlr r9 + lwz r30,-8(r28) + lwz r29,-12(r28) + lwz r28,-16(r28) + lwz r1,0(r1) + blr L(fp_return_value): /* Do we have long double to store? */ - bf 31,L(fd_return_value) ; FLAG_RETURNS_128BITS + bf 31,L(fd_return_value) stfd f1,0(r30) - stfd f2,FPR_SIZE(r30) + stfd f2,8(r30) b L(done_return_value) L(fd_return_value): @@ -273,57 +170,21 @@ stfs f1,0(r30) b L(done_return_value) -L(scalar_return_value): - bt 29,L(fp_return_value) ; FLAG_RETURNS_FP - ; ffi_arg is defined as unsigned long. - sg r3,0(r30) ; Save the reg. - bf 28,L(done_return_value) ; not FLAG_RETURNS_64BITS - -#if defined(__ppc64__) -L(maybe_return_128): - std r3,0(r30) - bf 31,L(done_return_value) ; not FLAG_RETURNS_128BITS - std r4,8(r30) -#else - stw r4,4(r30) -#endif - - /* Fall through. */ - /* We want this at the end to simplify eh epilog computation. */ - -L(done_return_value): - /* Restore the registers we used and return. */ - lg r29,SAVED_LR_OFFSET(r28) - ; epilog - lg r31,-(1 * GPR_BYTES)(r28) - mtlr r29 - lg r30,-(2 * GPR_BYTES)(r28) - lg r29,-(3 * GPR_BYTES)(r28) - lg r28,-(4 * GPR_BYTES)(r28) - lg r1,0(r1) - blr LFE1: - .align 1 /* END(_ffi_call_DARWIN) */ /* Provide a null definition of _ffi_call_AIX. */ - .text - .globl _ffi_call_AIX +.text + .align 2 +.globl _ffi_call_AIX +.text .align 2 _ffi_call_AIX: blr /* END(_ffi_call_AIX) */ -/* EH stuff. */ - -#define EH_DATA_ALIGN_FACT MODE_CHOICE(0x7c,0x78) - - .static_data - .align LOG2_GPR_BYTES -LLFB0$non_lazy_ptr: - .g_long Lstartcode - - .section __TEXT,__eh_frame,coalesced,no_toc+strip_static_syms+live_support +.data +.section __TEXT,__eh_frame,coalesced,no_toc+strip_static_syms EH_frame1: .set L$set$0,LECIE1-LSCIE1 .long L$set$0 ; Length of Common Information Entry @@ -332,17 +193,16 @@ .byte 0x1 ; CIE Version .ascii "zR\0" ; CIE Augmentation .byte 0x1 ; uleb128 0x1; CIE Code Alignment Factor - .byte EH_DATA_ALIGN_FACT ; sleb128 -4; CIE Data Alignment Factor + .byte 0x7c ; sleb128 -4; CIE Data Alignment Factor .byte 0x41 ; CIE RA Column .byte 0x1 ; uleb128 0x1; Augmentation size - .byte 0x10 ; FDE Encoding (indirect pcrel) + .byte 0x90 ; FDE Encoding (indirect pcrel) .byte 0xc ; DW_CFA_def_cfa .byte 0x1 ; uleb128 0x1 .byte 0x0 ; uleb128 0x0 .align LOG2_GPR_BYTES LECIE1: - - .globl _ffi_call_DARWIN.eh +.globl _ffi_call_DARWIN.eh _ffi_call_DARWIN.eh: LSFDE1: .set L$set$1,LEFDE1-LASFDE1 @@ -350,11 +210,11 @@ LASFDE1: .long LASFDE1-EH_frame1 ; FDE CIE offset .g_long LLFB0$non_lazy_ptr-. ; FDE initial location - .set L$set$3,LFE1-Lstartcode + .set L$set$3,LFE1-LFB0 .g_long L$set$3 ; FDE address range .byte 0x0 ; uleb128 0x0; Augmentation size .byte 0x4 ; DW_CFA_advance_loc4 - .set L$set$4,LCFI0-Lstartcode + .set L$set$4,LCFI0-LFB1 .long L$set$4 .byte 0xd ; DW_CFA_def_cfa_register .byte 0x08 ; uleb128 0x08 @@ -379,5 +239,7 @@ .byte 0x1c ; uleb128 0x1c .align LOG2_GPR_BYTES LEFDE1: - .align 1 - +.data + .align LOG2_GPR_BYTES +LLFB0$non_lazy_ptr: + .g_long LFB0 diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi/src/powerpc/darwin_closure.S --- a/Modules/_ctypes/libffi/src/powerpc/darwin_closure.S Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/_ctypes/libffi/src/powerpc/darwin_closure.S Sun Jul 20 10:52:46 2014 -0400 @@ -1,7 +1,6 @@ /* ----------------------------------------------------------------------- - darwin_closure.S - Copyright (c) 2002, 2003, 2004, 2010, - Free Software Foundation, Inc. - based on ppc_closure.S + darwin_closure.S - Copyright (c) 2002, 2003, 2004, Free Software Foundation, + Inc. based on ppc_closure.S PowerPC Assembly glue. @@ -34,177 +33,91 @@ #define MODE_CHOICE(x, y) x #endif -#define machine_choice MODE_CHOICE(ppc7400,ppc64) +#define lgu MODE_CHOICE(lwzu, ldu) -; Define some pseudo-opcodes for size-independent load & store of GPRs ... -#define lgu MODE_CHOICE(lwzu, ldu) -#define lg MODE_CHOICE(lwz,ld) -#define sg MODE_CHOICE(stw,std) -#define sgu MODE_CHOICE(stwu,stdu) +#define g_long MODE_CHOICE(long, quad) /* usage is ".g_long" */ -; ... and the size of GPRs and their storage indicator. -#define GPR_BYTES MODE_CHOICE(4,8) -#define LOG2_GPR_BYTES MODE_CHOICE(2,3) /* log2(GPR_BYTES) */ -#define g_long MODE_CHOICE(long, quad) /* usage is ".g_long" */ - -; From the ABI doc: "Mac OS X ABI Function Call Guide" Version 2009-02-04. -#define LINKAGE_SIZE MODE_CHOICE(24,48) -#define PARAM_AREA MODE_CHOICE(32,64) - -#define SAVED_CR_OFFSET MODE_CHOICE(4,8) /* save position for CR */ -#define SAVED_LR_OFFSET MODE_CHOICE(8,16) /* save position for lr */ - -/* WARNING: if ffi_type is changed... here be monsters. - Offsets of items within the result type. */ -#define FFI_TYPE_TYPE MODE_CHOICE(6,10) -#define FFI_TYPE_ELEM MODE_CHOICE(8,16) - -#define SAVED_FPR_COUNT 13 -#define FPR_SIZE 8 -/* biggest m64 struct ret is 8GPRS + 13FPRS = 168 bytes - rounded to 16bytes = 176. */ -#define RESULT_BYTES MODE_CHOICE(16,176) - -; The whole stack frame **MUST** be 16byte-aligned. -#define SAVE_SIZE (((LINKAGE_SIZE+PARAM_AREA+SAVED_FPR_COUNT*FPR_SIZE+RESULT_BYTES)+15) & -16LL) -#define PAD_SIZE (SAVE_SIZE-(LINKAGE_SIZE+PARAM_AREA+SAVED_FPR_COUNT*FPR_SIZE+RESULT_BYTES)) - -#define PARENT_PARM_BASE (SAVE_SIZE+LINKAGE_SIZE) -#define FP_SAVE_BASE (LINKAGE_SIZE+PARAM_AREA) - -#if defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 1050 -; We no longer need the pic symbol stub for Darwin >= 9. -#define BLCLS_HELP _ffi_closure_helper_DARWIN -#define STRUCT_RETVALUE_P _darwin64_struct_ret_by_value_p -#define PASS_STR_FLOATS _darwin64_pass_struct_floats -#undef WANT_STUB -#else -#define BLCLS_HELP L_ffi_closure_helper_DARWIN$stub -#define STRUCT_RETVALUE_P L_darwin64_struct_ret_by_value_p$stub -#define PASS_STR_FLOATS L_darwin64_pass_struct_floats$stub -#define WANT_STUB -#endif - -/* m32/m64 - - The stack layout looks like this: - - | Additional params... | | Higher address - ~ ~ ~ - | Parameters (at least 8*4/8=32/64) | | NUM_GPR_ARG_REGISTERS - |--------------------------------------------| | - | TOC=R2 (AIX) Reserved (Darwin) 4/8 | | - |--------------------------------------------| | - | Reserved 2*4/8 | | - |--------------------------------------------| | - | Space for callee`s LR 4/8 | | - |--------------------------------------------| | - | Saved CR [low word for m64] 4/8 | | - |--------------------------------------------| | - | Current backchain pointer 4/8 |-/ Parent`s frame. - |--------------------------------------------| <+ <<< on entry to - | Result Bytes 16/176 | | - |--------------------------------------------| | - ~ padding to 16-byte alignment ~ ~ - |--------------------------------------------| | - | NUM_FPR_ARG_REGISTERS slots | | - | here fp13 .. fp1 13*8 | | - |--------------------------------------------| | - | R3..R10 8*4/8=32/64 | | NUM_GPR_ARG_REGISTERS - |--------------------------------------------| | - | TOC=R2 (AIX) Reserved (Darwin) 4/8 | | - |--------------------------------------------| | stack | - | Reserved [compiler,binder] 2*4/8 | | grows | - |--------------------------------------------| | down V - | Space for callees LR 4/8 | | - |--------------------------------------------| | lower addresses - | Saved CR [low word for m64] 4/8 | | - |--------------------------------------------| | stack pointer here - | Current backchain pointer 4/8 |-/ during - |--------------------------------------------| <<< call. - -*/ +#define LOG2_GPR_BYTES MODE_CHOICE(2,3) /* log2(GPR_BYTES) */ .file "darwin_closure.S" +.text + .align LOG2_GPR_BYTES +.globl _ffi_closure_ASM - .machine machine_choice - - .text - .globl _ffi_closure_ASM +.text .align LOG2_GPR_BYTES _ffi_closure_ASM: LFB1: -Lstartcode: - mflr r0 /* extract return address */ - sg r0,SAVED_LR_OFFSET(r1) /* save the return address */ + mflr r0 /* extract return address */ + stw r0,8(r1) /* save the return address */ LCFI0: - sgu r1,-SAVE_SIZE(r1) /* skip over caller save area - keep stack aligned to 16. */ + /* 24 Bytes (Linkage Area) + 32 Bytes (outgoing parameter area, always reserved) + 104 Bytes (13*8 from FPR) + 16 Bytes (result) + 176 Bytes */ + + stwu r1,-176(r1) /* skip over caller save area + keep stack aligned to 16. */ LCFI1: /* We want to build up an area for the parameters passed in registers. (both floating point and integer) */ - /* Put gpr 3 to gpr 10 in the parents outgoing area... - ... the remainder of any params that overflowed the regs will - follow here. */ - sg r3, (PARENT_PARM_BASE )(r1) - sg r4, (PARENT_PARM_BASE + GPR_BYTES )(r1) - sg r5, (PARENT_PARM_BASE + GPR_BYTES * 2)(r1) - sg r6, (PARENT_PARM_BASE + GPR_BYTES * 3)(r1) - sg r7, (PARENT_PARM_BASE + GPR_BYTES * 4)(r1) - sg r8, (PARENT_PARM_BASE + GPR_BYTES * 5)(r1) - sg r9, (PARENT_PARM_BASE + GPR_BYTES * 6)(r1) - sg r10,(PARENT_PARM_BASE + GPR_BYTES * 7)(r1) + /* We store gpr 3 to gpr 10 (aligned to 4) + in the parents outgoing area. */ + stw r3,200(r1) + stw r4,204(r1) + stw r5,208(r1) + stw r6,212(r1) + stw r7,216(r1) + stw r8,220(r1) + stw r9,224(r1) + stw r10,228(r1) - /* We save fpr 1 to fpr 14 in our own save frame. */ - stfd f1, (FP_SAVE_BASE )(r1) - stfd f2, (FP_SAVE_BASE + FPR_SIZE )(r1) - stfd f3, (FP_SAVE_BASE + FPR_SIZE * 2 )(r1) - stfd f4, (FP_SAVE_BASE + FPR_SIZE * 3 )(r1) - stfd f5, (FP_SAVE_BASE + FPR_SIZE * 4 )(r1) - stfd f6, (FP_SAVE_BASE + FPR_SIZE * 5 )(r1) - stfd f7, (FP_SAVE_BASE + FPR_SIZE * 6 )(r1) - stfd f8, (FP_SAVE_BASE + FPR_SIZE * 7 )(r1) - stfd f9, (FP_SAVE_BASE + FPR_SIZE * 8 )(r1) - stfd f10,(FP_SAVE_BASE + FPR_SIZE * 9 )(r1) - stfd f11,(FP_SAVE_BASE + FPR_SIZE * 10)(r1) - stfd f12,(FP_SAVE_BASE + FPR_SIZE * 11)(r1) - stfd f13,(FP_SAVE_BASE + FPR_SIZE * 12)(r1) + /* We save fpr 1 to fpr 13. (aligned to 8) */ + stfd f1,56(r1) + stfd f2,64(r1) + stfd f3,72(r1) + stfd f4,80(r1) + stfd f5,88(r1) + stfd f6,96(r1) + stfd f7,104(r1) + stfd f8,112(r1) + stfd f9,120(r1) + stfd f10,128(r1) + stfd f11,136(r1) + stfd f12,144(r1) + stfd f13,152(r1) /* Set up registers for the routine that actually does the work get the context pointer from the trampoline. */ - mr r3,r11 + mr r3,r11 /* Now load up the pointer to the result storage. */ - addi r4,r1,(SAVE_SIZE-RESULT_BYTES) + addi r4,r1,160 /* Now load up the pointer to the saved gpr registers. */ - addi r5,r1,PARENT_PARM_BASE + addi r5,r1,200 /* Now load up the pointer to the saved fpr registers. */ - addi r6,r1,FP_SAVE_BASE + addi r6,r1,56 /* Make the call. */ - bl BLCLS_HELP + bl Lffi_closure_helper_DARWIN$stub - /* r3 contains the rtype pointer... save it since we will need - it later. */ - sg r3,LINKAGE_SIZE(r1) ; ffi_type * result_type - lg r0,0(r3) ; size => r0 - lhz r3,FFI_TYPE_TYPE(r3) ; type => r3 - - /* The helper will have intercepted struture returns and inserted - the caller`s destination address for structs returned by ref. */ - - /* r3 contains the return type so use it to look up in a table + /* Now r3 contains the return type + so use it to look up in a table so we know how to deal with each type. */ - addi r5,r1,(SAVE_SIZE-RESULT_BYTES) /* Otherwise, our return is here. */ - bl Lget_ret_type0_addr /* Get pointer to Lret_type0 into LR. */ - mflr r4 /* Move to r4. */ - slwi r3,r3,4 /* Now multiply return type by 16. */ - add r3,r3,r4 /* Add contents of table to table address. */ - mtctr r3 - bctr /* Jump to it. */ + /* Look up the proper starting point in table + by using return type as offset. */ + addi r5,r1,160 /* Get pointer to results area. */ + bl Lget_ret_type0_addr /* Get pointer to Lret_type0 into LR. */ + mflr r4 /* Move to r4. */ + slwi r3,r3,4 /* Now multiply return type by 16. */ + add r3,r3,r4 /* Add contents of table to table address. */ + mtctr r3 + bctr /* Jump to it. */ LFE1: /* Each of the ret_typeX code fragments has to be exactly 16 bytes long (4 instructions). For cache effectiveness we align to a 16 byte boundary @@ -227,7 +140,7 @@ /* case FFI_TYPE_INT */ Lret_type1: - lg r3,0(r5) + lwz r3,0(r5) b Lfinish nop nop @@ -255,224 +168,85 @@ /* case FFI_TYPE_UINT8 */ Lret_type5: -#if defined(__ppc64__) - lbz r3,7(r5) -#else lbz r3,3(r5) -#endif b Lfinish nop nop /* case FFI_TYPE_SINT8 */ Lret_type6: -#if defined(__ppc64__) - lbz r3,7(r5) -#else lbz r3,3(r5) -#endif extsb r3,r3 b Lfinish nop /* case FFI_TYPE_UINT16 */ Lret_type7: -#if defined(__ppc64__) - lhz r3,6(r5) -#else lhz r3,2(r5) -#endif b Lfinish nop nop /* case FFI_TYPE_SINT16 */ Lret_type8: -#if defined(__ppc64__) - lha r3,6(r5) -#else lha r3,2(r5) -#endif b Lfinish nop nop /* case FFI_TYPE_UINT32 */ Lret_type9: -#if defined(__ppc64__) - lwz r3,4(r5) -#else lwz r3,0(r5) -#endif b Lfinish nop nop /* case FFI_TYPE_SINT32 */ Lret_type10: -#if defined(__ppc64__) - lwz r3,4(r5) -#else lwz r3,0(r5) -#endif b Lfinish nop nop /* case FFI_TYPE_UINT64 */ Lret_type11: -#if defined(__ppc64__) - lg r3,0(r5) - b Lfinish - nop -#else lwz r3,0(r5) lwz r4,4(r5) b Lfinish -#endif nop /* case FFI_TYPE_SINT64 */ Lret_type12: -#if defined(__ppc64__) - lg r3,0(r5) - b Lfinish - nop -#else lwz r3,0(r5) lwz r4,4(r5) b Lfinish -#endif nop /* case FFI_TYPE_STRUCT */ Lret_type13: -#if defined(__ppc64__) - lg r3,0(r5) ; we need at least this... - cmpi 0,r0,4 - bgt Lstructend ; not a special small case - b Lsmallstruct ; see if we need more. -#else - cmpi 0,r0,4 - bgt Lfinish ; not by value - lg r3,0(r5) b Lfinish -#endif + nop + nop + nop + /* case FFI_TYPE_POINTER */ Lret_type14: - lg r3,0(r5) + lwz r3,0(r5) b Lfinish nop nop -#if defined(__ppc64__) -Lsmallstruct: - beq Lfour ; continuation of Lret13. - cmpi 0,r0,3 - beq Lfinish ; don`t adjust this - can`t be any floats here... - srdi r3,r3,48 - cmpi 0,r0,2 - beq Lfinish ; .. or here .. - srdi r3,r3,8 - b Lfinish ; .. or here. - -Lfour: - lg r6,LINKAGE_SIZE(r1) ; get the result type - lg r6,FFI_TYPE_ELEM(r6) ; elements array pointer - lg r6,0(r6) ; first element - lhz r0,FFI_TYPE_TYPE(r6) ; OK go the type - cmpi 0,r0,2 ; FFI_TYPE_FLOAT - bne Lfourint - lfs f1,0(r5) ; just one float in the struct. - b Lfinish - -Lfourint: - srdi r3,r3,32 ; four bytes. - b Lfinish - -Lstructend: - lg r3,LINKAGE_SIZE(r1) ; get the result type - bl STRUCT_RETVALUE_P - cmpi 0,r3,0 - beq Lfinish ; nope. - /* Recover a pointer to the results. */ - addi r11,r1,(SAVE_SIZE-RESULT_BYTES) - lg r3,0(r11) ; we need at least this... - lg r4,8(r11) - cmpi 0,r0,16 - beq Lfinish ; special case 16 bytes we don't consider floats. - - /* OK, frustratingly, the process of saving the struct to mem might have - messed with the FPRs, so we have to re-load them :(. - We`ll use our FPRs space again - calling: - void darwin64_pass_struct_floats (ffi_type *s, char *src, - unsigned *nfpr, double **fprs) - We`ll temporarily pinch the first two slots of the param area for local - vars used by the routine. */ - xor r6,r6,r6 - addi r5,r1,PARENT_PARM_BASE ; some space - sg r6,0(r5) ; *nfpr zeroed. - addi r6,r5,8 ; **fprs - addi r3,r1,FP_SAVE_BASE ; pointer to FPRs space - sg r3,0(r6) - mr r4,r11 ; the struct is here... - lg r3,LINKAGE_SIZE(r1) ; ffi_type * result_type. - bl PASS_STR_FLOATS ; get struct floats into FPR save space. - /* See if we used any floats */ - lwz r0,(SAVE_SIZE-RESULT_BYTES)(r1) - cmpi 0,r0,0 - beq Lstructints ; nope. - /* OK load `em up... */ - lfd f1, (FP_SAVE_BASE )(r1) - lfd f2, (FP_SAVE_BASE + FPR_SIZE )(r1) - lfd f3, (FP_SAVE_BASE + FPR_SIZE * 2 )(r1) - lfd f4, (FP_SAVE_BASE + FPR_SIZE * 3 )(r1) - lfd f5, (FP_SAVE_BASE + FPR_SIZE * 4 )(r1) - lfd f6, (FP_SAVE_BASE + FPR_SIZE * 5 )(r1) - lfd f7, (FP_SAVE_BASE + FPR_SIZE * 6 )(r1) - lfd f8, (FP_SAVE_BASE + FPR_SIZE * 7 )(r1) - lfd f9, (FP_SAVE_BASE + FPR_SIZE * 8 )(r1) - lfd f10,(FP_SAVE_BASE + FPR_SIZE * 9 )(r1) - lfd f11,(FP_SAVE_BASE + FPR_SIZE * 10)(r1) - lfd f12,(FP_SAVE_BASE + FPR_SIZE * 11)(r1) - lfd f13,(FP_SAVE_BASE + FPR_SIZE * 12)(r1) - - /* point back at our saved struct. */ -Lstructints: - addi r11,r1,(SAVE_SIZE-RESULT_BYTES) - lg r3,0(r11) ; we end up picking the - lg r4,8(r11) ; first two again. - lg r5,16(r11) - lg r6,24(r11) - lg r7,32(r11) - lg r8,40(r11) - lg r9,48(r11) - lg r10,56(r11) -#endif - /* case done */ Lfinish: - addi r1,r1,SAVE_SIZE /* Restore stack pointer. */ - lg r0,SAVED_LR_OFFSET(r1) /* Get return address. */ - mtlr r0 /* Reset link register. */ + addi r1,r1,176 /* Restore stack pointer. */ + lwz r0,8(r1) /* Get return address. */ + mtlr r0 /* Reset link register. */ blr -Lendcode: - .align 1 - + /* END(ffi_closure_ASM) */ -/* EH frame stuff. */ -#define EH_DATA_ALIGN_FACT MODE_CHOICE(0x7c,0x78) -/* 176, 400 */ -#define EH_FRAME_OFFSETA MODE_CHOICE(176,0x90) -#define EH_FRAME_OFFSETB MODE_CHOICE(1,3) - - .static_data - .align LOG2_GPR_BYTES -LLFB1$non_lazy_ptr: - .g_long Lstartcode - - .section __TEXT,__eh_frame,coalesced,no_toc+strip_static_syms+live_support +.data +.section __TEXT,__eh_frame,coalesced,no_toc+strip_static_syms+live_support EH_frame1: .set L$set$0,LECIE1-LSCIE1 .long L$set$0 ; Length of Common Information Entry @@ -481,16 +255,16 @@ .byte 0x1 ; CIE Version .ascii "zR\0" ; CIE Augmentation .byte 0x1 ; uleb128 0x1; CIE Code Alignment Factor - .byte EH_DATA_ALIGN_FACT ; sleb128 -4; CIE Data Alignment Factor + .byte 0x7c ; sleb128 -4; CIE Data Alignment Factor .byte 0x41 ; CIE RA Column .byte 0x1 ; uleb128 0x1; Augmentation size - .byte 0x10 ; FDE Encoding (indirect pcrel) + .byte 0x90 ; FDE Encoding (indirect pcrel) .byte 0xc ; DW_CFA_def_cfa .byte 0x1 ; uleb128 0x1 .byte 0x0 ; uleb128 0x0 .align LOG2_GPR_BYTES LECIE1: - .globl _ffi_closure_ASM.eh +.globl _ffi_closure_ASM.eh _ffi_closure_ASM.eh: LSFDE1: .set L$set$1,LEFDE1-LASFDE1 @@ -499,78 +273,45 @@ LASFDE1: .long LASFDE1-EH_frame1 ; FDE CIE offset .g_long LLFB1$non_lazy_ptr-. ; FDE initial location - .set L$set$3,LFE1-Lstartcode + .set L$set$3,LFE1-LFB1 .g_long L$set$3 ; FDE address range .byte 0x0 ; uleb128 0x0; Augmentation size .byte 0x4 ; DW_CFA_advance_loc4 .set L$set$3,LCFI1-LCFI0 .long L$set$3 .byte 0xe ; DW_CFA_def_cfa_offset - .byte EH_FRAME_OFFSETA,EH_FRAME_OFFSETB ; uleb128 176,1/190,3 + .byte 176,1 ; uleb128 176 .byte 0x4 ; DW_CFA_advance_loc4 - .set L$set$4,LCFI0-Lstartcode + .set L$set$4,LCFI0-LFB1 .long L$set$4 .byte 0x11 ; DW_CFA_offset_extended_sf .byte 0x41 ; uleb128 0x41 .byte 0x7e ; sleb128 -2 .align LOG2_GPR_BYTES LEFDE1: - .align 1 - -#ifdef WANT_STUB - .section __TEXT,__picsymbolstub1,symbol_stubs,pure_instructions,32 - .align 5 -L_ffi_closure_helper_DARWIN$stub: +.data + .align LOG2_GPR_BYTES +LDFCM0: +.section __TEXT,__picsymbolstub1,symbol_stubs,pure_instructions,32 + .align LOG2_GPR_BYTES +Lffi_closure_helper_DARWIN$stub: +#if 1 .indirect_symbol _ffi_closure_helper_DARWIN - mflr r0 - bcl 20,31,"L00000000001$spb" -"L00000000001$spb": - mflr r11 - addis r11,r11,ha16(L_ffi_closure_helper_DARWIN$lazy_ptr-"L00000000001$spb") - mtlr r0 - lwzu r12,lo16(L_ffi_closure_helper_DARWIN$lazy_ptr-"L00000000001$spb")(r11) - mtctr r12 + mflr r0 + bcl 20,31,LO$ffi_closure_helper_DARWIN +LO$ffi_closure_helper_DARWIN: + mflr r11 + addis r11,r11,ha16(L_ffi_closure_helper_DARWIN$lazy_ptr - LO$ffi_closure_helper_DARWIN) + mtlr r0 + lgu r12,lo16(L_ffi_closure_helper_DARWIN$lazy_ptr - LO$ffi_closure_helper_DARWIN)(r11) + mtctr r12 bctr - .lazy_symbol_pointer +.lazy_symbol_pointer L_ffi_closure_helper_DARWIN$lazy_ptr: .indirect_symbol _ffi_closure_helper_DARWIN - .g_long dyld_stub_binding_helper - -#if defined(__ppc64__) - .section __TEXT,__picsymbolstub1,symbol_stubs,pure_instructions,32 - .align 5 -L_darwin64_struct_ret_by_value_p$stub: - .indirect_symbol _darwin64_struct_ret_by_value_p - mflr r0 - bcl 20,31,"L00000000002$spb" -"L00000000002$spb": - mflr r11 - addis r11,r11,ha16(L_darwin64_struct_ret_by_value_p$lazy_ptr-"L00000000002$spb") - mtlr r0 - lwzu r12,lo16(L_darwin64_struct_ret_by_value_p$lazy_ptr-"L00000000002$spb")(r11) - mtctr r12 - bctr - .lazy_symbol_pointer -L_darwin64_struct_ret_by_value_p$lazy_ptr: - .indirect_symbol _darwin64_struct_ret_by_value_p - .g_long dyld_stub_binding_helper - - .section __TEXT,__picsymbolstub1,symbol_stubs,pure_instructions,32 - .align 5 -L_darwin64_pass_struct_floats$stub: - .indirect_symbol _darwin64_pass_struct_floats - mflr r0 - bcl 20,31,"L00000000003$spb" -"L00000000003$spb": - mflr r11 - addis r11,r11,ha16(L_darwin64_pass_struct_floats$lazy_ptr-"L00000000003$spb") - mtlr r0 - lwzu r12,lo16(L_darwin64_pass_struct_floats$lazy_ptr-"L00000000003$spb")(r11) - mtctr r12 - bctr - .lazy_symbol_pointer -L_darwin64_pass_struct_floats$lazy_ptr: - .indirect_symbol _darwin64_pass_struct_floats - .g_long dyld_stub_binding_helper -# endif + .g_long dyld_stub_binding_helper #endif +.data + .align LOG2_GPR_BYTES +LLFB1$non_lazy_ptr: + .g_long LFB1 diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi/src/powerpc/ffi.c --- a/Modules/_ctypes/libffi/src/powerpc/ffi.c Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/_ctypes/libffi/src/powerpc/ffi.c Sun Jul 20 10:52:46 2014 -0400 @@ -1,9 +1,7 @@ /* ----------------------------------------------------------------------- - ffi.c - Copyright (C) 2011 Anthony Green - Copyright (C) 2011 Kyle Moffett - Copyright (C) 2008 Red Hat, Inc - Copyright (C) 2007, 2008 Free Software Foundation, Inc - Copyright (c) 1998 Geoffrey Keating + ffi.c - Copyright (c) 1998 Geoffrey Keating + Copyright (C) 2007, 2008 Free Software Foundation, Inc + Copyright (C) 2008 Red Hat, Inc PowerPC Foreign Function Interface @@ -41,33 +39,32 @@ /* The assembly depends on these exact flags. */ FLAG_RETURNS_SMST = 1 << (31-31), /* Used for FFI_SYSV small structs. */ FLAG_RETURNS_NOTHING = 1 << (31-30), /* These go in cr7 */ -#ifndef __NO_FPRS__ FLAG_RETURNS_FP = 1 << (31-29), -#endif FLAG_RETURNS_64BITS = 1 << (31-28), FLAG_RETURNS_128BITS = 1 << (31-27), /* cr6 */ - FLAG_SYSV_SMST_R4 = 1 << (31-26), /* use r4 for FFI_SYSV 8 byte structs. */ FLAG_SYSV_SMST_R3 = 1 << (31-25), /* use r3 for FFI_SYSV 4 byte structs. */ + /* Bits (31-24) through (31-19) store shift value for SMST */ FLAG_ARG_NEEDS_COPY = 1 << (31- 7), -#ifndef __NO_FPRS__ FLAG_FP_ARGUMENTS = 1 << (31- 6), /* cr1.eq; specified by ABI */ -#endif FLAG_4_GPR_ARGUMENTS = 1 << (31- 5), FLAG_RETVAL_REFERENCE = 1 << (31- 4) }; /* About the SYSV ABI. */ -#define ASM_NEEDS_REGISTERS 4 -#define NUM_GPR_ARG_REGISTERS 8 +unsigned int NUM_GPR_ARG_REGISTERS = 8; #ifndef __NO_FPRS__ -# define NUM_FPR_ARG_REGISTERS 8 +unsigned int NUM_FPR_ARG_REGISTERS = 8; +#else +unsigned int NUM_FPR_ARG_REGISTERS = 0; #endif +enum { ASM_NEEDS_REGISTERS = 4 }; + /* ffi_prep_args_SYSV is called by the assembly routine once stack space has been allocated for the function's arguments. @@ -116,12 +113,10 @@ valp gpr_base; int intarg_count; -#ifndef __NO_FPRS__ /* 'fpr_base' points at the space for fpr1, and grows upwards as we use FPR registers. */ valp fpr_base; int fparg_count; -#endif /* 'copy_space' grows down as we put structures in it. It should stay 16-byte aligned. */ @@ -130,8 +125,9 @@ /* 'next_arg' grows up as we put parameters in it. */ valp next_arg; - int i; + int i, ii MAYBE_UNUSED; ffi_type **ptr; + double double_tmp; union { void **v; char **c; @@ -147,23 +143,21 @@ size_t struct_copy_size; unsigned gprvalue; + if (ecif->cif->abi == FFI_LINUX_SOFT_FLOAT) + NUM_FPR_ARG_REGISTERS = 0; + stacktop.c = (char *) stack + bytes; gpr_base.u = stacktop.u - ASM_NEEDS_REGISTERS - NUM_GPR_ARG_REGISTERS; intarg_count = 0; -#ifndef __NO_FPRS__ - double double_tmp; fpr_base.d = gpr_base.d - NUM_FPR_ARG_REGISTERS; fparg_count = 0; copy_space.c = ((flags & FLAG_FP_ARGUMENTS) ? fpr_base.c : gpr_base.c); -#else - copy_space.c = gpr_base.c; -#endif next_arg.u = stack + 2; /* Check that everything starts aligned properly. */ - FFI_ASSERT (((unsigned long) (char *) stack & 0xF) == 0); - FFI_ASSERT (((unsigned long) copy_space.c & 0xF) == 0); - FFI_ASSERT (((unsigned long) stacktop.c & 0xF) == 0); + FFI_ASSERT (((unsigned) (char *) stack & 0xF) == 0); + FFI_ASSERT (((unsigned) copy_space.c & 0xF) == 0); + FFI_ASSERT (((unsigned) stacktop.c & 0xF) == 0); FFI_ASSERT ((bytes & 0xF) == 0); FFI_ASSERT (copy_space.c >= next_arg.c); @@ -180,28 +174,12 @@ i > 0; i--, ptr++, p_argv.v++) { - unsigned short typenum = (*ptr)->type; - - /* We may need to handle some values depending on ABI */ - if (ecif->cif->abi == FFI_LINUX_SOFT_FLOAT) { - if (typenum == FFI_TYPE_FLOAT) - typenum = FFI_TYPE_UINT32; - if (typenum == FFI_TYPE_DOUBLE) - typenum = FFI_TYPE_UINT64; - if (typenum == FFI_TYPE_LONGDOUBLE) - typenum = FFI_TYPE_UINT128; - } else if (ecif->cif->abi != FFI_LINUX) { -#if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE - if (typenum == FFI_TYPE_LONGDOUBLE) - typenum = FFI_TYPE_STRUCT; -#endif - } - - /* Now test the translated value */ - switch (typenum) { -#ifndef __NO_FPRS__ + switch ((*ptr)->type) + { case FFI_TYPE_FLOAT: /* With FFI_LINUX_SOFT_FLOAT floats are handled like UINT32. */ + if (ecif->cif->abi == FFI_LINUX_SOFT_FLOAT) + goto soft_float_prep; double_tmp = **p_argv.f; if (fparg_count >= NUM_FPR_ARG_REGISTERS) { @@ -217,6 +195,8 @@ case FFI_TYPE_DOUBLE: /* With FFI_LINUX_SOFT_FLOAT doubles are handled like UINT64. */ + if (ecif->cif->abi == FFI_LINUX_SOFT_FLOAT) + goto soft_double_prep; double_tmp = **p_argv.d; if (fparg_count >= NUM_FPR_ARG_REGISTERS) @@ -238,6 +218,43 @@ #if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE case FFI_TYPE_LONGDOUBLE: + if ((ecif->cif->abi != FFI_LINUX) + && (ecif->cif->abi != FFI_LINUX_SOFT_FLOAT)) + goto do_struct; + /* The soft float ABI for long doubles works like this, + a long double is passed in four consecutive gprs if available. + A maximum of 2 long doubles can be passed in gprs. + If we do not have 4 gprs left, the long double is passed on the + stack, 4-byte aligned. */ + if (ecif->cif->abi == FFI_LINUX_SOFT_FLOAT) + { + unsigned int int_tmp = (*p_argv.ui)[0]; + if (intarg_count >= NUM_GPR_ARG_REGISTERS - 3) + { + if (intarg_count < NUM_GPR_ARG_REGISTERS) + intarg_count += NUM_GPR_ARG_REGISTERS - intarg_count; + *next_arg.u = int_tmp; + next_arg.u++; + for (ii = 1; ii < 4; ii++) + { + int_tmp = (*p_argv.ui)[ii]; + *next_arg.u = int_tmp; + next_arg.u++; + } + } + else + { + *gpr_base.u++ = int_tmp; + for (ii = 1; ii < 4; ii++) + { + int_tmp = (*p_argv.ui)[ii]; + *gpr_base.u++ = int_tmp; + } + } + intarg_count +=4; + } + else + { double_tmp = (*p_argv.d)[0]; if (fparg_count >= NUM_FPR_ARG_REGISTERS - 1) @@ -263,40 +280,13 @@ fparg_count += 2; FFI_ASSERT (flags & FLAG_FP_ARGUMENTS); + } break; #endif -#endif /* have FPRs */ - - /* - * The soft float ABI for long doubles works like this, a long double - * is passed in four consecutive GPRs if available. A maximum of 2 - * long doubles can be passed in gprs. If we do not have 4 GPRs - * left, the long double is passed on the stack, 4-byte aligned. - */ - case FFI_TYPE_UINT128: { - unsigned int int_tmp = (*p_argv.ui)[0]; - unsigned int ii; - if (intarg_count >= NUM_GPR_ARG_REGISTERS - 3) { - if (intarg_count < NUM_GPR_ARG_REGISTERS) - intarg_count += NUM_GPR_ARG_REGISTERS - intarg_count; - *(next_arg.u++) = int_tmp; - for (ii = 1; ii < 4; ii++) { - int_tmp = (*p_argv.ui)[ii]; - *(next_arg.u++) = int_tmp; - } - } else { - *(gpr_base.u++) = int_tmp; - for (ii = 1; ii < 4; ii++) { - int_tmp = (*p_argv.ui)[ii]; - *(gpr_base.u++) = int_tmp; - } - } - intarg_count += 4; - break; - } case FFI_TYPE_UINT64: case FFI_TYPE_SINT64: + soft_double_prep: if (intarg_count == NUM_GPR_ARG_REGISTERS-1) intarg_count++; if (intarg_count >= NUM_GPR_ARG_REGISTERS) @@ -329,6 +319,9 @@ break; case FFI_TYPE_STRUCT: +#if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE + do_struct: +#endif struct_copy_size = ((*ptr)->size + 15) & ~0xF; copy_space.c -= struct_copy_size; memcpy (copy_space.c, *p_argv.c, (*ptr)->size); @@ -356,6 +349,7 @@ case FFI_TYPE_UINT32: case FFI_TYPE_SINT32: case FFI_TYPE_POINTER: + soft_float_prep: gprvalue = **p_argv.ui; @@ -372,16 +366,8 @@ /* Check that we didn't overrun the stack... */ FFI_ASSERT (copy_space.c >= next_arg.c); FFI_ASSERT (gpr_base.u <= stacktop.u - ASM_NEEDS_REGISTERS); - /* The assert below is testing that the number of integer arguments agrees - with the number found in ffi_prep_cif_machdep(). However, intarg_count - is incremeneted whenever we place an FP arg on the stack, so account for - that before our assert test. */ -#ifndef __NO_FPRS__ - if (fparg_count > NUM_FPR_ARG_REGISTERS) - intarg_count -= fparg_count - NUM_FPR_ARG_REGISTERS; FFI_ASSERT (fpr_base.u <= stacktop.u - ASM_NEEDS_REGISTERS - NUM_GPR_ARG_REGISTERS); -#endif FFI_ASSERT (flags & FLAG_4_GPR_ARGUMENTS || intarg_count <= 4); } @@ -618,6 +604,9 @@ unsigned type = cif->rtype->type; unsigned size = cif->rtype->size; + if (cif->abi == FFI_LINUX_SOFT_FLOAT) + NUM_FPR_ARG_REGISTERS = 0; + if (cif->abi != FFI_LINUX64) { /* All the machine-independent calculation of cif->bytes will be wrong. @@ -657,26 +646,13 @@ - Single/double FP values in fpr1, long double in fpr1,fpr2. - soft-float float/doubles are treated as UINT32/UINT64 respectivley. - soft-float long doubles are returned in gpr3-gpr6. */ - /* First translate for softfloat/nonlinux */ - if (cif->abi == FFI_LINUX_SOFT_FLOAT) { - if (type == FFI_TYPE_FLOAT) - type = FFI_TYPE_UINT32; - if (type == FFI_TYPE_DOUBLE) - type = FFI_TYPE_UINT64; - if (type == FFI_TYPE_LONGDOUBLE) - type = FFI_TYPE_UINT128; - } else if (cif->abi != FFI_LINUX && cif->abi != FFI_LINUX64) { -#if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE - if (type == FFI_TYPE_LONGDOUBLE) - type = FFI_TYPE_STRUCT; -#endif - } - switch (type) { -#ifndef __NO_FPRS__ #if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE case FFI_TYPE_LONGDOUBLE: + if (cif->abi != FFI_LINUX && cif->abi != FFI_LINUX64 + && cif->abi != FFI_LINUX_SOFT_FLOAT) + goto byref; flags |= FLAG_RETURNS_128BITS; /* Fall through. */ #endif @@ -684,13 +660,11 @@ flags |= FLAG_RETURNS_64BITS; /* Fall through. */ case FFI_TYPE_FLOAT: - flags |= FLAG_RETURNS_FP; + /* With FFI_LINUX_SOFT_FLOAT no fp registers are used. */ + if (cif->abi != FFI_LINUX_SOFT_FLOAT) + flags |= FLAG_RETURNS_FP; break; -#endif - case FFI_TYPE_UINT128: - flags |= FLAG_RETURNS_128BITS; - /* Fall through. */ case FFI_TYPE_UINT64: case FFI_TYPE_SINT64: flags |= FLAG_RETURNS_64BITS; @@ -725,7 +699,9 @@ } } } - +#if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE + byref: +#endif intarg_count++; flags |= FLAG_RETVAL_REFERENCE; /* Fall through. */ @@ -746,36 +722,39 @@ Stuff on the stack needs to keep proper alignment. */ for (ptr = cif->arg_types, i = cif->nargs; i > 0; i--, ptr++) { - unsigned short typenum = (*ptr)->type; - - /* We may need to handle some values depending on ABI */ - if (cif->abi == FFI_LINUX_SOFT_FLOAT) { - if (typenum == FFI_TYPE_FLOAT) - typenum = FFI_TYPE_UINT32; - if (typenum == FFI_TYPE_DOUBLE) - typenum = FFI_TYPE_UINT64; - if (typenum == FFI_TYPE_LONGDOUBLE) - typenum = FFI_TYPE_UINT128; - } else if (cif->abi != FFI_LINUX && cif->abi != FFI_LINUX64) { -#if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE - if (typenum == FFI_TYPE_LONGDOUBLE) - typenum = FFI_TYPE_STRUCT; -#endif - } - - switch (typenum) { -#ifndef __NO_FPRS__ + switch ((*ptr)->type) + { case FFI_TYPE_FLOAT: + /* With FFI_LINUX_SOFT_FLOAT floats are handled like UINT32. */ + if (cif->abi == FFI_LINUX_SOFT_FLOAT) + goto soft_float_cif; fparg_count++; /* floating singles are not 8-aligned on stack */ break; #if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE case FFI_TYPE_LONGDOUBLE: - fparg_count++; + if (cif->abi != FFI_LINUX && cif->abi != FFI_LINUX_SOFT_FLOAT) + goto do_struct; + if (cif->abi == FFI_LINUX_SOFT_FLOAT) + { + if (intarg_count >= NUM_GPR_ARG_REGISTERS - 3 + || intarg_count < NUM_GPR_ARG_REGISTERS) + /* A long double in FFI_LINUX_SOFT_FLOAT can use only + a set of four consecutive gprs. If we have not enough, + we have to adjust the intarg_count value. */ + intarg_count += NUM_GPR_ARG_REGISTERS - intarg_count; + intarg_count += 4; + break; + } + else + fparg_count++; /* Fall thru */ #endif case FFI_TYPE_DOUBLE: + /* With FFI_LINUX_SOFT_FLOAT doubles are handled like UINT64. */ + if (cif->abi == FFI_LINUX_SOFT_FLOAT) + goto soft_double_cif; fparg_count++; /* If this FP arg is going on the stack, it must be 8-byte-aligned. */ @@ -784,21 +763,10 @@ && intarg_count % 2 != 0) intarg_count++; break; -#endif - case FFI_TYPE_UINT128: - /* - * A long double in FFI_LINUX_SOFT_FLOAT can use only a set - * of four consecutive gprs. If we do not have enough, we - * have to adjust the intarg_count value. - */ - if (intarg_count >= NUM_GPR_ARG_REGISTERS - 3 - && intarg_count < NUM_GPR_ARG_REGISTERS) - intarg_count = NUM_GPR_ARG_REGISTERS; - intarg_count += 4; - break; case FFI_TYPE_UINT64: case FFI_TYPE_SINT64: + soft_double_cif: /* 'long long' arguments are passed as two words, but either both words must fit in registers or both go on the stack. If they go on the stack, they must @@ -815,6 +783,9 @@ break; case FFI_TYPE_STRUCT: +#if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE + do_struct: +#endif /* We must allocate space for a copy of these to enforce pass-by-value. Pad the space up to a multiple of 16 bytes (the maximum alignment required for anything under @@ -822,20 +793,12 @@ struct_copy_size += ((*ptr)->size + 15) & ~0xF; /* Fall through (allocate space for the pointer). */ - case FFI_TYPE_POINTER: - case FFI_TYPE_INT: - case FFI_TYPE_UINT32: - case FFI_TYPE_SINT32: - case FFI_TYPE_UINT16: - case FFI_TYPE_SINT16: - case FFI_TYPE_UINT8: - case FFI_TYPE_SINT8: + default: + soft_float_cif: /* Everything else is passed as a 4-byte word in a GPR, either the object itself or a pointer to it. */ intarg_count++; break; - default: - FFI_ASSERT (0); } } else @@ -864,29 +827,16 @@ intarg_count += ((*ptr)->size + 7) / 8; break; - case FFI_TYPE_POINTER: - case FFI_TYPE_UINT64: - case FFI_TYPE_SINT64: - case FFI_TYPE_INT: - case FFI_TYPE_UINT32: - case FFI_TYPE_SINT32: - case FFI_TYPE_UINT16: - case FFI_TYPE_SINT16: - case FFI_TYPE_UINT8: - case FFI_TYPE_SINT8: + default: /* Everything else is passed as a 8-byte word in a GPR, either the object itself or a pointer to it. */ intarg_count++; break; - default: - FFI_ASSERT (0); } } -#ifndef __NO_FPRS__ if (fparg_count != 0) flags |= FLAG_FP_ARGUMENTS; -#endif if (intarg_count > 4) flags |= FLAG_4_GPR_ARGUMENTS; if (struct_copy_size != 0) @@ -894,27 +844,21 @@ if (cif->abi != FFI_LINUX64) { -#ifndef __NO_FPRS__ /* Space for the FPR registers, if needed. */ if (fparg_count != 0) bytes += NUM_FPR_ARG_REGISTERS * sizeof (double); -#endif /* Stack space. */ if (intarg_count > NUM_GPR_ARG_REGISTERS) bytes += (intarg_count - NUM_GPR_ARG_REGISTERS) * sizeof (int); -#ifndef __NO_FPRS__ if (fparg_count > NUM_FPR_ARG_REGISTERS) bytes += (fparg_count - NUM_FPR_ARG_REGISTERS) * sizeof (double); -#endif } else { -#ifndef __NO_FPRS__ /* Space for the FPR registers, if needed. */ if (fparg_count != 0) bytes += NUM_FPR_ARG_REGISTERS64 * sizeof (double); -#endif /* Stack space. */ if (intarg_count > NUM_GPR_ARG_REGISTERS64) @@ -942,41 +886,28 @@ void ffi_call(ffi_cif *cif, void (*fn)(void), void *rvalue, void **avalue) { - /* - * The final SYSV ABI says that structures smaller or equal 8 bytes - * are returned in r3/r4. The FFI_GCC_SYSV ABI instead returns them - * in memory. - * - * Just to keep things simple for the assembly code, we will always - * bounce-buffer struct return values less than or equal to 8 bytes. - * This allows the ASM to handle SYSV small structures by directly - * writing r3 and r4 to memory without worrying about struct size. - */ - unsigned int smst_buffer[2]; extended_cif ecif; - unsigned int rsize = 0; ecif.cif = cif; ecif.avalue = avalue; - /* Ensure that we have a valid struct return value */ - ecif.rvalue = rvalue; - if (cif->rtype->type == FFI_TYPE_STRUCT) { - rsize = cif->rtype->size; - if (rsize <= 8) - ecif.rvalue = smst_buffer; - else if (!rvalue) - ecif.rvalue = alloca(rsize); - } + /* If the return value is a struct and we don't have a return */ + /* value address then we need to make one */ + + if ((rvalue == NULL) && (cif->rtype->type == FFI_TYPE_STRUCT)) + { + ecif.rvalue = alloca(cif->rtype->size); + } + else + ecif.rvalue = rvalue; + switch (cif->abi) { #ifndef POWERPC64 -# ifndef __NO_FPRS__ case FFI_SYSV: case FFI_GCC_SYSV: case FFI_LINUX: -# endif case FFI_LINUX_SOFT_FLOAT: ffi_call_SYSV (&ecif, -cif->bytes, cif->flags, ecif.rvalue, fn); break; @@ -989,10 +920,6 @@ FFI_ASSERT (0); break; } - - /* Check for a bounce-buffered return value */ - if (rvalue && ecif.rvalue == smst_buffer) - memcpy(rvalue, smst_buffer, rsize); } @@ -1022,19 +949,14 @@ #ifdef POWERPC64 void **tramp = (void **) &closure->tramp[0]; - if (cif->abi != FFI_LINUX64) - return FFI_BAD_ABI; + FFI_ASSERT (cif->abi == FFI_LINUX64); /* Copy function address and TOC from ffi_closure_LINUX64. */ memcpy (tramp, (char *) ffi_closure_LINUX64, 16); tramp[2] = codeloc; #else unsigned int *tramp; - if (! (cif->abi == FFI_GCC_SYSV - || cif->abi == FFI_SYSV - || cif->abi == FFI_LINUX - || cif->abi == FFI_LINUX_SOFT_FLOAT)) - return FFI_BAD_ABI; + FFI_ASSERT (cif->abi == FFI_GCC_SYSV || cif->abi == FFI_SYSV); tramp = (unsigned int *) &closure->tramp[0]; tramp[0] = 0x7c0802a6; /* mflr r0 */ @@ -1089,38 +1011,32 @@ void ** avalue; ffi_type ** arg_types; long i, avn; -#ifndef __NO_FPRS__ - long nf = 0; /* number of floating registers already used */ -#endif - long ng = 0; /* number of general registers already used */ + long nf; /* number of floating registers already used */ + long ng; /* number of general registers already used */ + ffi_cif * cif; + double temp; + unsigned size; - ffi_cif *cif = closure->cif; - unsigned size = cif->rtype->size; - unsigned short rtypenum = cif->rtype->type; + cif = closure->cif; + avalue = alloca (cif->nargs * sizeof (void *)); + size = cif->rtype->size; - avalue = alloca (cif->nargs * sizeof (void *)); - - /* First translate for softfloat/nonlinux */ - if (cif->abi == FFI_LINUX_SOFT_FLOAT) { - if (rtypenum == FFI_TYPE_FLOAT) - rtypenum = FFI_TYPE_UINT32; - if (rtypenum == FFI_TYPE_DOUBLE) - rtypenum = FFI_TYPE_UINT64; - if (rtypenum == FFI_TYPE_LONGDOUBLE) - rtypenum = FFI_TYPE_UINT128; - } else if (cif->abi != FFI_LINUX && cif->abi != FFI_LINUX64) { -#if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE - if (rtypenum == FFI_TYPE_LONGDOUBLE) - rtypenum = FFI_TYPE_STRUCT; -#endif - } - + nf = 0; + ng = 0; /* Copy the caller's structure return value address so that the closure returns the data directly to the caller. For FFI_SYSV the result is passed in r3/r4 if the struct size is less or equal 8 bytes. */ - if (rtypenum == FFI_TYPE_STRUCT && ((cif->abi != FFI_SYSV) || (size > 8))) { + + if ((cif->rtype->type == FFI_TYPE_STRUCT + && !((cif->abi == FFI_SYSV) && (size <= 8))) +#if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE + || (cif->rtype->type == FFI_TYPE_LONGDOUBLE + && cif->abi != FFI_LINUX && cif->abi != FFI_LINUX_SOFT_FLOAT) +#endif + ) + { rvalue = (void *) *pgr; ng++; pgr++; @@ -1131,109 +1047,10 @@ arg_types = cif->arg_types; /* Grab the addresses of the arguments from the stack frame. */ - while (i < avn) { - unsigned short typenum = arg_types[i]->type; - - /* We may need to handle some values depending on ABI */ - if (cif->abi == FFI_LINUX_SOFT_FLOAT) { - if (typenum == FFI_TYPE_FLOAT) - typenum = FFI_TYPE_UINT32; - if (typenum == FFI_TYPE_DOUBLE) - typenum = FFI_TYPE_UINT64; - if (typenum == FFI_TYPE_LONGDOUBLE) - typenum = FFI_TYPE_UINT128; - } else if (cif->abi != FFI_LINUX && cif->abi != FFI_LINUX64) { -#if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE - if (typenum == FFI_TYPE_LONGDOUBLE) - typenum = FFI_TYPE_STRUCT; -#endif - } - - switch (typenum) { -#ifndef __NO_FPRS__ - case FFI_TYPE_FLOAT: - /* unfortunately float values are stored as doubles - * in the ffi_closure_SYSV code (since we don't check - * the type in that routine). - */ - - /* there are 8 64bit floating point registers */ - - if (nf < 8) - { - double temp = pfr->d; - pfr->f = (float) temp; - avalue[i] = pfr; - nf++; - pfr++; - } - else - { - /* FIXME? here we are really changing the values - * stored in the original calling routines outgoing - * parameter stack. This is probably a really - * naughty thing to do but... - */ - avalue[i] = pst; - pst += 1; - } - break; - - case FFI_TYPE_DOUBLE: - /* On the outgoing stack all values are aligned to 8 */ - /* there are 8 64bit floating point registers */ - - if (nf < 8) - { - avalue[i] = pfr; - nf++; - pfr++; - } - else - { - if (((long) pst) & 4) - pst++; - avalue[i] = pst; - pst += 2; - } - break; - -#if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE - case FFI_TYPE_LONGDOUBLE: - if (nf < 7) - { - avalue[i] = pfr; - pfr += 2; - nf += 2; - } - else - { - if (((long) pst) & 4) - pst++; - avalue[i] = pst; - pst += 4; - nf = 8; - } - break; -#endif -#endif /* have FPRS */ - - case FFI_TYPE_UINT128: - /* - * Test if for the whole long double, 4 gprs are available. - * otherwise the stuff ends up on the stack. - */ - if (ng < 5) { - avalue[i] = pgr; - pgr += 4; - ng += 4; - } else { - avalue[i] = pst; - pst += 4; - ng = 8+4; - } - break; - + while (i < avn) + { + switch (arg_types[i]->type) + { case FFI_TYPE_SINT8: case FFI_TYPE_UINT8: /* there are 8 gpr registers used to pass values */ @@ -1269,6 +1086,7 @@ case FFI_TYPE_SINT32: case FFI_TYPE_UINT32: case FFI_TYPE_POINTER: + soft_float_closure: /* there are 8 gpr registers used to pass values */ if (ng < 8) { @@ -1284,6 +1102,9 @@ break; case FFI_TYPE_STRUCT: +#if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE + do_struct: +#endif /* Structs are passed by reference. The address will appear in a gpr if it is one of the first 8 arguments. */ if (ng < 8) @@ -1301,6 +1122,7 @@ case FFI_TYPE_SINT64: case FFI_TYPE_UINT64: + soft_double_closure: /* passing long long ints are complex, they must * be passed in suitable register pairs such as * (r3,r4) or (r5,r6) or (r6,r7), or (r7,r8) or (r9,r10) @@ -1332,8 +1154,99 @@ } break; + case FFI_TYPE_FLOAT: + /* With FFI_LINUX_SOFT_FLOAT floats are handled like UINT32. */ + if (cif->abi == FFI_LINUX_SOFT_FLOAT) + goto soft_float_closure; + /* unfortunately float values are stored as doubles + * in the ffi_closure_SYSV code (since we don't check + * the type in that routine). + */ + + /* there are 8 64bit floating point registers */ + + if (nf < 8) + { + temp = pfr->d; + pfr->f = (float) temp; + avalue[i] = pfr; + nf++; + pfr++; + } + else + { + /* FIXME? here we are really changing the values + * stored in the original calling routines outgoing + * parameter stack. This is probably a really + * naughty thing to do but... + */ + avalue[i] = pst; + pst += 1; + } + break; + + case FFI_TYPE_DOUBLE: + /* With FFI_LINUX_SOFT_FLOAT doubles are handled like UINT64. */ + if (cif->abi == FFI_LINUX_SOFT_FLOAT) + goto soft_double_closure; + /* On the outgoing stack all values are aligned to 8 */ + /* there are 8 64bit floating point registers */ + + if (nf < 8) + { + avalue[i] = pfr; + nf++; + pfr++; + } + else + { + if (((long) pst) & 4) + pst++; + avalue[i] = pst; + pst += 2; + } + break; + +#if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE + case FFI_TYPE_LONGDOUBLE: + if (cif->abi != FFI_LINUX && cif->abi != FFI_LINUX_SOFT_FLOAT) + goto do_struct; + if (cif->abi == FFI_LINUX_SOFT_FLOAT) + { /* Test if for the whole long double, 4 gprs are available. + otherwise the stuff ends up on the stack. */ + if (ng < 5) + { + avalue[i] = pgr; + pgr += 4; + ng += 4; + } + else + { + avalue[i] = pst; + pst += 4; + ng = 8; + } + break; + } + if (nf < 7) + { + avalue[i] = pfr; + pfr += 2; + nf += 2; + } + else + { + if (((long) pst) & 4) + pst++; + avalue[i] = pst; + pst += 4; + nf = 8; + } + break; +#endif + default: - FFI_ASSERT (0); + FFI_ASSERT (0); } i++; @@ -1350,9 +1263,39 @@ already used and we never have a struct with size zero. That is the reason for the subtraction of 1. See the comment in ffitarget.h about ordering. */ - if (cif->abi == FFI_SYSV && rtypenum == FFI_TYPE_STRUCT && size <= 8) + if (cif->abi == FFI_SYSV && cif->rtype->type == FFI_TYPE_STRUCT + && size <= 8) return (FFI_SYSV_TYPE_SMALL_STRUCT - 1) + size; - return rtypenum; +#if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE + else if (cif->rtype->type == FFI_TYPE_LONGDOUBLE + && cif->abi != FFI_LINUX && cif->abi != FFI_LINUX_SOFT_FLOAT) + return FFI_TYPE_STRUCT; +#endif + /* With FFI_LINUX_SOFT_FLOAT floats and doubles are handled like UINT32 + respectivley UINT64. */ + if (cif->abi == FFI_LINUX_SOFT_FLOAT) + { + switch (cif->rtype->type) + { + case FFI_TYPE_FLOAT: + return FFI_TYPE_UINT32; + break; + case FFI_TYPE_DOUBLE: + return FFI_TYPE_UINT64; + break; +#if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE + case FFI_TYPE_LONGDOUBLE: + return FFI_TYPE_UINT128; + break; +#endif + default: + return cif->rtype->type; + } + } + else + { + return cif->rtype->type; + } } int FFI_HIDDEN ffi_closure_helper_LINUX64 (ffi_closure *, void *, diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi/src/powerpc/ffi_darwin.c --- a/Modules/_ctypes/libffi/src/powerpc/ffi_darwin.c Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/_ctypes/libffi/src/powerpc/ffi_darwin.c Sun Jul 20 10:52:46 2014 -0400 @@ -3,7 +3,7 @@ Copyright (C) 1998 Geoffrey Keating Copyright (C) 2001 John Hornkvist - Copyright (C) 2002, 2006, 2007, 2009, 2010 Free Software Foundation, Inc. + Copyright (C) 2002, 2006, 2007, 2009 Free Software Foundation, Inc. FFI support for Darwin and AIX. @@ -35,17 +35,11 @@ extern void ffi_closure_ASM (void); enum { - /* The assembly depends on these exact flags. - For Darwin64 (when FLAG_RETURNS_STRUCT is set): - FLAG_RETURNS_FP indicates that the structure embeds FP data. - FLAG_RETURNS_128BITS signals a special struct size that is not - expanded for float content. */ - FLAG_RETURNS_128BITS = 1 << (31-31), /* These go in cr7 */ - FLAG_RETURNS_NOTHING = 1 << (31-30), - FLAG_RETURNS_FP = 1 << (31-29), - FLAG_RETURNS_64BITS = 1 << (31-28), - - FLAG_RETURNS_STRUCT = 1 << (31-27), /* This goes in cr6 */ + /* The assembly depends on these exact flags. */ + FLAG_RETURNS_NOTHING = 1 << (31-30), /* These go in cr7 */ + FLAG_RETURNS_FP = 1 << (31-29), + FLAG_RETURNS_64BITS = 1 << (31-28), + FLAG_RETURNS_128BITS = 1 << (31-31), FLAG_ARG_NEEDS_COPY = 1 << (31- 7), FLAG_FP_ARGUMENTS = 1 << (31- 6), /* cr1.eq; specified by ABI */ @@ -56,61 +50,43 @@ /* About the DARWIN ABI. */ enum { NUM_GPR_ARG_REGISTERS = 8, - NUM_FPR_ARG_REGISTERS = 13, - LINKAGE_AREA_GPRS = 6 + NUM_FPR_ARG_REGISTERS = 13 }; - -enum { ASM_NEEDS_REGISTERS = 4 }; /* r28-r31 */ +enum { ASM_NEEDS_REGISTERS = 4 }; /* ffi_prep_args is called by the assembly routine once stack space has been allocated for the function's arguments. - - m32/m64 The stack layout we want looks like this: | Return address from ffi_call_DARWIN | higher addresses |--------------------------------------------| - | Previous backchain pointer 4/8 | stack pointer here + | Previous backchain pointer 4 | stack pointer here |--------------------------------------------|<+ <<< on entry to - | ASM_NEEDS_REGISTERS=r28-r31 4*(4/8) | | ffi_call_DARWIN + | Saved r28-r31 4*4 | | ffi_call_DARWIN |--------------------------------------------| | - | When we have any FP activity... the | | - | FPRs occupy NUM_FPR_ARG_REGISTERS slots | | - | here fp13 .. fp1 from high to low addr. | | - ~ ~ ~ - | Parameters (at least 8*4/8=32/64) | | NUM_GPR_ARG_REGISTERS + | Parameters (at least 8*4=32) | | |--------------------------------------------| | - | TOC=R2 (AIX) Reserved (Darwin) 4/8 | | + | Space for GPR2 4 | | |--------------------------------------------| | stack | - | Reserved 2*4/8 | | grows | + | Reserved 2*4 | | grows | |--------------------------------------------| | down V - | Space for callee's LR 4/8 | | + | Space for callee's LR 4 | | |--------------------------------------------| | lower addresses - | Saved CR [low word for m64] 4/8 | | + | Saved CR 4 | | |--------------------------------------------| | stack pointer here - | Current backchain pointer 4/8 |-/ during + | Current backchain pointer 4 |-/ during |--------------------------------------------| <<< ffi_call_DARWIN */ -#if defined(POWERPC_DARWIN64) -static void -darwin64_pass_struct_by_value - (ffi_type *, char *, unsigned, unsigned *, double **, unsigned long **); -#endif - -/* This depends on GPR_SIZE = sizeof (unsigned long) */ - void ffi_prep_args (extended_cif *ecif, unsigned long *const stack) { const unsigned bytes = ecif->cif->bytes; const unsigned flags = ecif->cif->flags; const unsigned nargs = ecif->cif->nargs; -#if !defined(POWERPC_DARWIN64) const ffi_abi abi = ecif->cif->abi; -#endif /* 'stacktop' points at the previous backchain pointer. */ unsigned long *const stacktop = stack + (bytes / sizeof(unsigned long)); @@ -118,19 +94,18 @@ /* 'fpr_base' points at the space for fpr1, and grows upwards as we use FPR registers. */ double *fpr_base = (double *) (stacktop - ASM_NEEDS_REGISTERS) - NUM_FPR_ARG_REGISTERS; - int gp_count = 0, fparg_count = 0; + int fparg_count = 0; + /* 'next_arg' grows up as we put parameters in it. */ - unsigned long *next_arg = stack + LINKAGE_AREA_GPRS; /* 6 reserved positions. */ + unsigned long *next_arg = stack + 6; /* 6 reserved positions. */ int i; double double_tmp; void **p_argv = ecif->avalue; unsigned long gprvalue; ffi_type** ptr = ecif->cif->arg_types; -#if !defined(POWERPC_DARWIN64) char *dest_cpy; -#endif unsigned size_al = 0; /* Check that everything starts aligned properly. */ @@ -155,30 +130,25 @@ the size of the floating-point parameter are skipped. */ case FFI_TYPE_FLOAT: double_tmp = *(float *) *p_argv; - if (fparg_count < NUM_FPR_ARG_REGISTERS) + if (fparg_count >= NUM_FPR_ARG_REGISTERS) + *(double *)next_arg = double_tmp; + else *fpr_base++ = double_tmp; -#if defined(POWERPC_DARWIN) - *(float *)next_arg = *(float *) *p_argv; -#else - *(double *)next_arg = double_tmp; -#endif next_arg++; - gp_count++; fparg_count++; FFI_ASSERT(flags & FLAG_FP_ARGUMENTS); break; case FFI_TYPE_DOUBLE: double_tmp = *(double *) *p_argv; - if (fparg_count < NUM_FPR_ARG_REGISTERS) + if (fparg_count >= NUM_FPR_ARG_REGISTERS) + *(double *)next_arg = double_tmp; + else *fpr_base++ = double_tmp; - *(double *)next_arg = double_tmp; #ifdef POWERPC64 next_arg++; - gp_count++; #else next_arg += 2; - gp_count += 2; #endif fparg_count++; FFI_ASSERT(flags & FLAG_FP_ARGUMENTS); @@ -187,41 +157,30 @@ #if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE case FFI_TYPE_LONGDOUBLE: -# if defined(POWERPC64) && !defined(POWERPC_DARWIN64) - /* ??? This will exceed the regs count when the value starts at fp13 - and it will not put the extra bit on the stack. */ +#ifdef POWERPC64 if (fparg_count < NUM_FPR_ARG_REGISTERS) *(long double *) fpr_base++ = *(long double *) *p_argv; else *(long double *) next_arg = *(long double *) *p_argv; next_arg += 2; fparg_count += 2; -# else +#else double_tmp = ((double *) *p_argv)[0]; if (fparg_count < NUM_FPR_ARG_REGISTERS) *fpr_base++ = double_tmp; - *(double *) next_arg = double_tmp; -# if defined(POWERPC_DARWIN64) - next_arg++; - gp_count++; -# else + else + *(double *) next_arg = double_tmp; next_arg += 2; - gp_count += 2; -# endif fparg_count++; + double_tmp = ((double *) *p_argv)[1]; if (fparg_count < NUM_FPR_ARG_REGISTERS) *fpr_base++ = double_tmp; - *(double *) next_arg = double_tmp; -# if defined(POWERPC_DARWIN64) - next_arg++; - gp_count++; -# else + else + *(double *) next_arg = double_tmp; next_arg += 2; - gp_count += 2; -# endif fparg_count++; -# endif +#endif FFI_ASSERT(flags & FLAG_FP_ARGUMENTS); break; #endif @@ -233,7 +192,6 @@ #else *(long long *) next_arg = *(long long *) *p_argv; next_arg += 2; - gp_count += 2; #endif break; case FFI_TYPE_POINTER: @@ -253,35 +211,32 @@ goto putgpr; case FFI_TYPE_STRUCT: +#ifdef POWERPC64 + dest_cpy = (char *) next_arg; size_al = (*ptr)->size; -#if defined(POWERPC_DARWIN64) - next_arg = (unsigned long *)ALIGN((char *)next_arg, (*ptr)->alignment); - darwin64_pass_struct_by_value (*ptr, (char *) *p_argv, - (unsigned) size_al, - (unsigned int *) &fparg_count, - &fpr_base, &next_arg); + if ((*ptr)->elements[0]->type == 3) + size_al = ALIGN((*ptr)->size, 8); + if (size_al < 3 && abi == FFI_DARWIN) + dest_cpy += 4 - size_al; + + memcpy ((char *) dest_cpy, (char *) *p_argv, size_al); + next_arg += (size_al + 7) / 8; #else dest_cpy = (char *) next_arg; - /* If the first member of the struct is a double, then include enough - padding in the struct size to align it to double-word. */ - if ((*ptr)->elements[0]->type == FFI_TYPE_DOUBLE) - size_al = ALIGN((*ptr)->size, 8); - -# if defined(POWERPC64) - FFI_ASSERT (abi != FFI_DARWIN); - memcpy ((char *) dest_cpy, (char *) *p_argv, size_al); - next_arg += (size_al + 7) / 8; -# else /* Structures that match the basic modes (QI 1 byte, HI 2 bytes, SI 4 bytes) are aligned as if they were those modes. Structures with 3 byte in size are padded upwards. */ + size_al = (*ptr)->size; + /* If the first member of the struct is a double, then align + the struct to double-word. */ + if ((*ptr)->elements[0]->type == FFI_TYPE_DOUBLE) + size_al = ALIGN((*ptr)->size, 8); if (size_al < 3 && abi == FFI_DARWIN) dest_cpy += 4 - size_al; memcpy((char *) dest_cpy, (char *) *p_argv, size_al); next_arg += (size_al + 3) / 4; -# endif #endif break; @@ -294,7 +249,6 @@ gprvalue = *(unsigned int *) *p_argv; putgpr: *next_arg++ = gprvalue; - gp_count++; break; default: break; @@ -302,275 +256,14 @@ } /* Check that we didn't overrun the stack... */ - /* FFI_ASSERT(gpr_base <= stacktop - ASM_NEEDS_REGISTERS); - FFI_ASSERT((unsigned *)fpr_base - <= stacktop - ASM_NEEDS_REGISTERS - NUM_GPR_ARG_REGISTERS); - FFI_ASSERT(flags & FLAG_4_GPR_ARGUMENTS || intarg_count <= 4); */ + //FFI_ASSERT(gpr_base <= stacktop - ASM_NEEDS_REGISTERS); + //FFI_ASSERT((unsigned *)fpr_base + // <= stacktop - ASM_NEEDS_REGISTERS - NUM_GPR_ARG_REGISTERS); + //FFI_ASSERT(flags & FLAG_4_GPR_ARGUMENTS || intarg_count <= 4); } -#if defined(POWERPC_DARWIN64) - -/* See if we can put some of the struct into fprs. - This should not be called for structures of size 16 bytes, since these are not - broken out this way. */ -static void -darwin64_scan_struct_for_floats (ffi_type *s, unsigned *nfpr) -{ - int i; - - FFI_ASSERT (s->type == FFI_TYPE_STRUCT) - - for (i = 0; s->elements[i] != NULL; i++) - { - ffi_type *p = s->elements[i]; - switch (p->type) - { - case FFI_TYPE_STRUCT: - darwin64_scan_struct_for_floats (p, nfpr); - break; - case FFI_TYPE_LONGDOUBLE: - (*nfpr) += 2; - break; - case FFI_TYPE_DOUBLE: - case FFI_TYPE_FLOAT: - (*nfpr) += 1; - break; - default: - break; - } - } -} - -static int -darwin64_struct_size_exceeds_gprs_p (ffi_type *s, char *src, unsigned *nfpr) -{ - unsigned struct_offset=0, i; - - for (i = 0; s->elements[i] != NULL; i++) - { - char *item_base; - ffi_type *p = s->elements[i]; - /* Find the start of this item (0 for the first one). */ - if (i > 0) - struct_offset = ALIGN(struct_offset, p->alignment); - - item_base = src + struct_offset; - - switch (p->type) - { - case FFI_TYPE_STRUCT: - if (darwin64_struct_size_exceeds_gprs_p (p, item_base, nfpr)) - return 1; - break; - case FFI_TYPE_LONGDOUBLE: - if (*nfpr >= NUM_FPR_ARG_REGISTERS) - return 1; - (*nfpr) += 1; - item_base += 8; - /* FALL THROUGH */ - case FFI_TYPE_DOUBLE: - if (*nfpr >= NUM_FPR_ARG_REGISTERS) - return 1; - (*nfpr) += 1; - break; - case FFI_TYPE_FLOAT: - if (*nfpr >= NUM_FPR_ARG_REGISTERS) - return 1; - (*nfpr) += 1; - break; - default: - /* If we try and place any item, that is non-float, once we've - exceeded the 8 GPR mark, then we can't fit the struct. */ - if ((unsigned long)item_base >= 8*8) - return 1; - break; - } - /* now count the size of what we just used. */ - struct_offset += p->size; - } - return 0; -} - -/* Can this struct be returned by value? */ -int -darwin64_struct_ret_by_value_p (ffi_type *s) -{ - unsigned nfp = 0; - - FFI_ASSERT (s && s->type == FFI_TYPE_STRUCT); - - /* The largest structure we can return is 8long + 13 doubles. */ - if (s->size > 168) - return 0; - - /* We can't pass more than 13 floats. */ - darwin64_scan_struct_for_floats (s, &nfp); - if (nfp > 13) - return 0; - - /* If there are not too many floats, and the struct is - small enough to accommodate in the GPRs, then it must be OK. */ - if (s->size <= 64) - return 1; - - /* Well, we have to look harder. */ - nfp = 0; - if (darwin64_struct_size_exceeds_gprs_p (s, NULL, &nfp)) - return 0; - - return 1; -} - -void -darwin64_pass_struct_floats (ffi_type *s, char *src, - unsigned *nfpr, double **fprs) -{ - int i; - double *fpr_base = *fprs; - unsigned struct_offset = 0; - - /* We don't assume anything about the alignment of the source. */ - for (i = 0; s->elements[i] != NULL; i++) - { - char *item_base; - ffi_type *p = s->elements[i]; - /* Find the start of this item (0 for the first one). */ - if (i > 0) - struct_offset = ALIGN(struct_offset, p->alignment); - item_base = src + struct_offset; - - switch (p->type) - { - case FFI_TYPE_STRUCT: - darwin64_pass_struct_floats (p, item_base, nfpr, - &fpr_base); - break; - case FFI_TYPE_LONGDOUBLE: - if (*nfpr < NUM_FPR_ARG_REGISTERS) - *fpr_base++ = *(double *)item_base; - (*nfpr) += 1; - item_base += 8; - /* FALL THROUGH */ - case FFI_TYPE_DOUBLE: - if (*nfpr < NUM_FPR_ARG_REGISTERS) - *fpr_base++ = *(double *)item_base; - (*nfpr) += 1; - break; - case FFI_TYPE_FLOAT: - if (*nfpr < NUM_FPR_ARG_REGISTERS) - *fpr_base++ = (double) *(float *)item_base; - (*nfpr) += 1; - break; - default: - break; - } - /* now count the size of what we just used. */ - struct_offset += p->size; - } - /* Update the scores. */ - *fprs = fpr_base; -} - -/* Darwin64 special rules. - Break out a struct into params and float registers. */ -static void -darwin64_pass_struct_by_value (ffi_type *s, char *src, unsigned size, - unsigned *nfpr, double **fprs, unsigned long **arg) -{ - unsigned long *next_arg = *arg; - char *dest_cpy = (char *)next_arg; - - FFI_ASSERT (s->type == FFI_TYPE_STRUCT) - - if (!size) - return; - - /* First... special cases. */ - if (size < 3 - || (size == 4 - && s->elements[0] - && s->elements[0]->type != FFI_TYPE_FLOAT)) - { - /* Must be at least one GPR, padding is unspecified in value, - let's make it zero. */ - *next_arg = 0UL; - dest_cpy += 8 - size; - memcpy ((char *) dest_cpy, src, size); - next_arg++; - } - else if (size == 16) - { - memcpy ((char *) dest_cpy, src, size); - next_arg += 2; - } - else - { - /* now the general case, we consider embedded floats. */ - memcpy ((char *) dest_cpy, src, size); - darwin64_pass_struct_floats (s, src, nfpr, fprs); - next_arg += (size+7)/8; - } - - *arg = next_arg; -} - -double * -darwin64_struct_floats_to_mem (ffi_type *s, char *dest, double *fprs, unsigned *nf) -{ - int i; - unsigned struct_offset = 0; - - /* We don't assume anything about the alignment of the source. */ - for (i = 0; s->elements[i] != NULL; i++) - { - char *item_base; - ffi_type *p = s->elements[i]; - /* Find the start of this item (0 for the first one). */ - if (i > 0) - struct_offset = ALIGN(struct_offset, p->alignment); - item_base = dest + struct_offset; - - switch (p->type) - { - case FFI_TYPE_STRUCT: - fprs = darwin64_struct_floats_to_mem (p, item_base, fprs, nf); - break; - case FFI_TYPE_LONGDOUBLE: - if (*nf < NUM_FPR_ARG_REGISTERS) - { - *(double *)item_base = *fprs++ ; - (*nf) += 1; - } - item_base += 8; - /* FALL THROUGH */ - case FFI_TYPE_DOUBLE: - if (*nf < NUM_FPR_ARG_REGISTERS) - { - *(double *)item_base = *fprs++ ; - (*nf) += 1; - } - break; - case FFI_TYPE_FLOAT: - if (*nf < NUM_FPR_ARG_REGISTERS) - { - *(float *)item_base = (float) *fprs++ ; - (*nf) += 1; - } - break; - default: - break; - } - /* now count the size of what we just used. */ - struct_offset += p->size; - } - return fprs; -} - -#endif - /* Adjust the size of S to be correct for Darwin. - On Darwin m32, the first field of a structure has natural alignment. - On Darwin m64, all fields have natural alignment. */ + On Darwin, the first field of a structure has natural alignment. */ static void darwin_adjust_aggregate_sizes (ffi_type *s) @@ -587,29 +280,22 @@ int align; p = s->elements[i]; - if (p->type == FFI_TYPE_STRUCT) - darwin_adjust_aggregate_sizes (p); -#if defined(POWERPC_DARWIN64) - /* Natural alignment for all items. */ - align = p->alignment; -#else - /* Natrual alignment for the first item... */ - if (i == 0) - align = p->alignment; + darwin_adjust_aggregate_sizes (p); + if (i == 0 + && (p->type == FFI_TYPE_UINT64 + || p->type == FFI_TYPE_SINT64 + || p->type == FFI_TYPE_DOUBLE + || p->alignment == 8)) + align = 8; else if (p->alignment == 16 || p->alignment < 4) - /* .. subsequent items with vector or align < 4 have natural align. */ align = p->alignment; else - /* .. or align is 4. */ align = 4; -#endif - /* Pad, if necessary, before adding the current item. */ s->size = ALIGN(s->size, align) + p->size; } s->size = ALIGN(s->size, s->alignment); - /* This should not be necessary on m64, but harmless. */ if (s->elements[0]->type == FFI_TYPE_UINT64 || s->elements[0]->type == FFI_TYPE_SINT64 || s->elements[0]->type == FFI_TYPE_DOUBLE @@ -658,10 +344,10 @@ ffi_prep_cif_machdep (ffi_cif *cif) { /* All this is for the DARWIN ABI. */ - unsigned i; + int i; ffi_type **ptr; unsigned bytes; - unsigned fparg_count = 0, intarg_count = 0; + int fparg_count = 0, intarg_count = 0; unsigned flags = 0; unsigned size_al = 0; @@ -686,25 +372,16 @@ /* Space for the frame pointer, callee's LR, CR, etc, and for the asm's temp regs. */ - bytes = (LINKAGE_AREA_GPRS + ASM_NEEDS_REGISTERS) * sizeof(unsigned long); + bytes = (6 + ASM_NEEDS_REGISTERS) * sizeof(long); - /* Return value handling. - The rules m32 are as follows: + /* Return value handling. The rules are as follows: - 32-bit (or less) integer values are returned in gpr3; - - structures of size <= 4 bytes also returned in gpr3; - - 64-bit integer values [??? and structures between 5 and 8 bytes] are - returned in gpr3 and gpr4; + - Structures of size <= 4 bytes also returned in gpr3; + - 64-bit integer values and structures between 5 and 8 bytes are returned + in gpr3 and gpr4; - Single/double FP values are returned in fpr1; - Long double FP (if not equivalent to double) values are returned in fpr1 and fpr2; - m64: - - 64-bit or smaller integral values are returned in GPR3 - - Single/double FP values are returned in fpr1; - - Long double FP values are returned in fpr1 and fpr2; - m64 Structures: - - If the structure could be accommodated in registers were it to be the - first argument to a routine, then it is returned in those registers. - m32/m64 structures otherwise: - Larger structures values are allocated space and a pointer is passed as the first argument. */ switch (cif->rtype->type) @@ -733,42 +410,9 @@ break; case FFI_TYPE_STRUCT: -#if defined(POWERPC_DARWIN64) - { - /* Can we fit the struct into regs? */ - if (darwin64_struct_ret_by_value_p (cif->rtype)) - { - unsigned nfpr = 0; - flags |= FLAG_RETURNS_STRUCT; - if (cif->rtype->size != 16) - darwin64_scan_struct_for_floats (cif->rtype, &nfpr) ; - else - flags |= FLAG_RETURNS_128BITS; - /* Will be 0 for 16byte struct. */ - if (nfpr) - flags |= FLAG_RETURNS_FP; - } - else /* By ref. */ - { - flags |= FLAG_RETVAL_REFERENCE; - flags |= FLAG_RETURNS_NOTHING; - intarg_count++; - } - } -#elif defined(DARWIN_PPC) - if (cif->rtype->size <= 4) - flags |= FLAG_RETURNS_STRUCT; - else /* else by reference. */ - { - flags |= FLAG_RETVAL_REFERENCE; - flags |= FLAG_RETURNS_NOTHING; - intarg_count++; - } -#else /* assume we pass by ref. */ flags |= FLAG_RETVAL_REFERENCE; flags |= FLAG_RETURNS_NOTHING; intarg_count++; -#endif break; case FFI_TYPE_VOID: flags |= FLAG_RETURNS_NOTHING; @@ -781,83 +425,57 @@ /* The first NUM_GPR_ARG_REGISTERS words of integer arguments, and the first NUM_FPR_ARG_REGISTERS fp arguments, go in registers; the rest - goes on the stack. - ??? Structures are passed as a pointer to a copy of the structure. - Stuff on the stack needs to keep proper alignment. - For m64 the count is effectively of half-GPRs. */ + goes on the stack. Structures are passed as a pointer to a copy of + the structure. Stuff on the stack needs to keep proper alignment. */ for (ptr = cif->arg_types, i = cif->nargs; i > 0; i--, ptr++) { - unsigned align_words; switch ((*ptr)->type) { case FFI_TYPE_FLOAT: case FFI_TYPE_DOUBLE: fparg_count++; -#if !defined(POWERPC_DARWIN64) /* If this FP arg is going on the stack, it must be 8-byte-aligned. */ if (fparg_count > NUM_FPR_ARG_REGISTERS - && (intarg_count & 0x01) != 0) + && intarg_count%2 != 0) intarg_count++; -#endif break; #if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE + case FFI_TYPE_LONGDOUBLE: fparg_count += 2; /* If this FP arg is going on the stack, it must be - 16-byte-aligned. */ - if (fparg_count >= NUM_FPR_ARG_REGISTERS) -#if defined (POWERPC64) - intarg_count = ALIGN(intarg_count, 2); -#else - intarg_count = ALIGN(intarg_count, 4); -#endif + 8-byte-aligned. */ + if (fparg_count > NUM_FPR_ARG_REGISTERS + && intarg_count%2 != 0) + intarg_count++; + intarg_count +=2; break; #endif case FFI_TYPE_UINT64: case FFI_TYPE_SINT64: -#if defined(POWERPC64) - intarg_count++; -#else /* 'long long' arguments are passed as two words, but either both words must fit in registers or both go on the stack. If they go on the stack, they must be 8-byte-aligned. */ if (intarg_count == NUM_GPR_ARG_REGISTERS-1 - || (intarg_count >= NUM_GPR_ARG_REGISTERS - && (intarg_count & 0x01) != 0)) + || (intarg_count >= NUM_GPR_ARG_REGISTERS && intarg_count%2 != 0)) intarg_count++; intarg_count += 2; -#endif break; case FFI_TYPE_STRUCT: size_al = (*ptr)->size; -#if defined(POWERPC_DARWIN64) - align_words = (*ptr)->alignment >> 3; - if (align_words) - intarg_count = ALIGN(intarg_count, align_words); - /* Base size of the struct. */ + /* If the first member of the struct is a double, then align + the struct to double-word. */ + if ((*ptr)->elements[0]->type == FFI_TYPE_DOUBLE) + size_al = ALIGN((*ptr)->size, 8); +#ifdef POWERPC64 intarg_count += (size_al + 7) / 8; - /* If 16 bytes then don't worry about floats. */ - if (size_al != 16) - /* Scan through for floats to be placed in regs. */ - darwin64_scan_struct_for_floats (*ptr, &fparg_count) ; #else - align_words = (*ptr)->alignment >> 2; - if (align_words) - intarg_count = ALIGN(intarg_count, align_words); - /* If the first member of the struct is a double, then align - the struct to double-word. - if ((*ptr)->elements[0]->type == FFI_TYPE_DOUBLE) - size_al = ALIGN((*ptr)->size, 8); */ -# ifdef POWERPC64 - intarg_count += (size_al + 7) / 8; -# else intarg_count += (size_al + 3) / 4; -# endif #endif break; @@ -872,18 +490,9 @@ if (fparg_count != 0) flags |= FLAG_FP_ARGUMENTS; -#if defined(POWERPC_DARWIN64) - /* Space to image the FPR registers, if needed - which includes when they might be - used in a struct return. */ - if (fparg_count != 0 - || ((flags & FLAG_RETURNS_STRUCT) - && (flags & FLAG_RETURNS_FP))) - bytes += NUM_FPR_ARG_REGISTERS * sizeof(double); -#else /* Space for the FPR registers, if needed. */ if (fparg_count != 0) bytes += NUM_FPR_ARG_REGISTERS * sizeof(double); -#endif /* Stack space. */ #ifdef POWERPC64 @@ -897,7 +506,7 @@ bytes += NUM_GPR_ARG_REGISTERS * sizeof(long); /* The stack space allocated needs to be a multiple of 16 bytes. */ - bytes = ALIGN(bytes, 16) ; + bytes = (bytes + 15) & ~0xF; cif->flags = flags; cif->bytes = bytes; @@ -907,9 +516,8 @@ extern void ffi_call_AIX(extended_cif *, long, unsigned, unsigned *, void (*fn)(void), void (*fn2)(void)); - extern void ffi_call_DARWIN(extended_cif *, long, unsigned, unsigned *, - void (*fn)(void), void (*fn2)(void), ffi_type*); + void (*fn)(void), void (*fn2)(void)); void ffi_call (ffi_cif *cif, void (*fn)(void), void *rvalue, void **avalue) @@ -934,11 +542,11 @@ { case FFI_AIX: ffi_call_AIX(&ecif, -(long)cif->bytes, cif->flags, ecif.rvalue, fn, - FFI_FN(ffi_prep_args)); + ffi_prep_args); break; case FFI_DARWIN: ffi_call_DARWIN(&ecif, -(long)cif->bytes, cif->flags, ecif.rvalue, fn, - FFI_FN(ffi_prep_args), cif->rtype); + ffi_prep_args); break; default: FFI_ASSERT(0); @@ -958,48 +566,58 @@ } aix_fd; /* here I'd like to add the stack frame layout we use in darwin_closure.S - and aix_closure.S + and aix_clsoure.S - m32/m64 - - The stack layout looks like this: - - | Additional params... | | Higher address - ~ ~ ~ - | Parameters (at least 8*4/8=32/64) | | NUM_GPR_ARG_REGISTERS - |--------------------------------------------| | - | TOC=R2 (AIX) Reserved (Darwin) 4/8 | | - |--------------------------------------------| | - | Reserved 2*4/8 | | - |--------------------------------------------| | - | Space for callee's LR 4/8 | | - |--------------------------------------------| | - | Saved CR [low word for m64] 4/8 | | - |--------------------------------------------| | - | Current backchain pointer 4/8 |-/ Parent's frame. - |--------------------------------------------| <+ <<< on entry to ffi_closure_ASM - | Result Bytes 16 | | - |--------------------------------------------| | - ~ padding to 16-byte alignment ~ ~ - |--------------------------------------------| | - | NUM_FPR_ARG_REGISTERS slots | | - | here fp13 .. fp1 13*8 | | - |--------------------------------------------| | - | R3..R10 8*4/8=32/64 | | NUM_GPR_ARG_REGISTERS - |--------------------------------------------| | - | TOC=R2 (AIX) Reserved (Darwin) 4/8 | | - |--------------------------------------------| | stack | - | Reserved [compiler,binder] 2*4/8 | | grows | - |--------------------------------------------| | down V - | Space for callee's LR 4/8 | | - |--------------------------------------------| | lower addresses - | Saved CR [low word for m64] 4/8 | | - |--------------------------------------------| | stack pointer here - | Current backchain pointer 4/8 |-/ during - |--------------------------------------------| <<< ffi_closure_ASM. + SP previous -> +---------------------------------------+ <--- child frame + | back chain to caller 4 | + +---------------------------------------+ 4 + | saved CR 4 | + +---------------------------------------+ 8 + | saved LR 4 | + +---------------------------------------+ 12 + | reserved for compilers 4 | + +---------------------------------------+ 16 + | reserved for binders 4 | + +---------------------------------------+ 20 + | saved TOC pointer 4 | + +---------------------------------------+ 24 + | always reserved 8*4=32 (previous GPRs)| + | according to the linkage convention | + | from AIX | + +---------------------------------------+ 56 + | our FPR area 13*8=104 | + | f1 | + | . | + | f13 | + +---------------------------------------+ 160 + | result area 8 | + +---------------------------------------+ 168 + | alignement to the next multiple of 16 | +SP current --> +---------------------------------------+ 176 <- parent frame + | back chain to caller 4 | + +---------------------------------------+ 180 + | saved CR 4 | + +---------------------------------------+ 184 + | saved LR 4 | + +---------------------------------------+ 188 + | reserved for compilers 4 | + +---------------------------------------+ 192 + | reserved for binders 4 | + +---------------------------------------+ 196 + | saved TOC pointer 4 | + +---------------------------------------+ 200 + | always reserved 8*4=32 we store our | + | GPRs here | + | r3 | + | . | + | r10 | + +---------------------------------------+ 232 + | overflow part | + +---------------------------------------+ xxx + | ???? | + +---------------------------------------+ xxx */ - ffi_status ffi_prep_closure_loc (ffi_closure* closure, ffi_cif* cif, @@ -1013,44 +631,30 @@ switch (cif->abi) { - case FFI_DARWIN: + case FFI_DARWIN: - FFI_ASSERT (cif->abi == FFI_DARWIN); + FFI_ASSERT (cif->abi == FFI_DARWIN); - tramp = (unsigned int *) &closure->tramp[0]; -#if defined(POWERPC_DARWIN64) - tramp[0] = 0x7c0802a6; /* mflr r0 */ - tramp[1] = 0x429f0015; /* bcl- 20,4*cr7+so, +0x18 (L1) */ - /* We put the addresses here. */ - tramp[6] = 0x7d6802a6; /*L1: mflr r11 */ - tramp[7] = 0xe98b0000; /* ld r12,0(r11) function address */ - tramp[8] = 0x7c0803a6; /* mtlr r0 */ - tramp[9] = 0x7d8903a6; /* mtctr r12 */ - tramp[10] = 0xe96b0008; /* lwz r11,8(r11) static chain */ - tramp[11] = 0x4e800420; /* bctr */ + tramp = (unsigned int *) &closure->tramp[0]; + tramp[0] = 0x7c0802a6; /* mflr r0 */ + tramp[1] = 0x429f000d; /* bcl- 20,4*cr7+so,0x10 */ + tramp[4] = 0x7d6802a6; /* mflr r11 */ + tramp[5] = 0x818b0000; /* lwz r12,0(r11) function address */ + tramp[6] = 0x7c0803a6; /* mtlr r0 */ + tramp[7] = 0x7d8903a6; /* mtctr r12 */ + tramp[8] = 0x816b0004; /* lwz r11,4(r11) static chain */ + tramp[9] = 0x4e800420; /* bctr */ + tramp[2] = (unsigned long) ffi_closure_ASM; /* function */ + tramp[3] = (unsigned long) codeloc; /* context */ - *((unsigned long *)&tramp[2]) = (unsigned long) ffi_closure_ASM; /* function */ - *((unsigned long *)&tramp[4]) = (unsigned long) codeloc; /* context */ -#else - tramp[0] = 0x7c0802a6; /* mflr r0 */ - tramp[1] = 0x429f000d; /* bcl- 20,4*cr7+so,0x10 */ - tramp[4] = 0x7d6802a6; /* mflr r11 */ - tramp[5] = 0x818b0000; /* lwz r12,0(r11) function address */ - tramp[6] = 0x7c0803a6; /* mtlr r0 */ - tramp[7] = 0x7d8903a6; /* mtctr r12 */ - tramp[8] = 0x816b0004; /* lwz r11,4(r11) static chain */ - tramp[9] = 0x4e800420; /* bctr */ - tramp[2] = (unsigned long) ffi_closure_ASM; /* function */ - tramp[3] = (unsigned long) codeloc; /* context */ -#endif - closure->cif = cif; - closure->fun = fun; - closure->user_data = user_data; + closure->cif = cif; + closure->fun = fun; + closure->user_data = user_data; - /* Flush the icache. Only necessary on Darwin. */ - flush_range(codeloc, FFI_TRAMPOLINE_SIZE); + /* Flush the icache. Only necessary on Darwin. */ + flush_range(codeloc, FFI_TRAMPOLINE_SIZE); - break; + break; case FFI_AIX: @@ -1065,10 +669,10 @@ closure->cif = cif; closure->fun = fun; closure->user_data = user_data; - break; default: - return FFI_BAD_ABI; + + FFI_ASSERT(0); break; } return FFI_OK; @@ -1104,7 +708,7 @@ double d; } ffi_dblfl; -ffi_type * +int ffi_closure_helper_DARWIN (ffi_closure *, void *, unsigned long *, ffi_dblfl *); @@ -1115,7 +719,7 @@ up space for a return value, ffi_closure_ASM invokes the following helper function to do most of the work. */ -ffi_type * +int ffi_closure_helper_DARWIN (ffi_closure *closure, void *rvalue, unsigned long *pgr, ffi_dblfl *pfr) { @@ -1137,32 +741,16 @@ ffi_cif * cif; ffi_dblfl * end_pfr = pfr + NUM_FPR_ARG_REGISTERS; unsigned size_al; -#if defined(POWERPC_DARWIN64) - unsigned fpsused = 0; -#endif cif = closure->cif; avalue = alloca (cif->nargs * sizeof(void *)); + /* Copy the caller's structure return value address so that the closure + returns the data directly to the caller. */ if (cif->rtype->type == FFI_TYPE_STRUCT) { -#if defined(POWERPC_DARWIN64) - if (!darwin64_struct_ret_by_value_p (cif->rtype)) - { - /* Won't fit into the regs - return by ref. */ - rvalue = (void *) *pgr; - pgr++; - } -#elif defined(DARWIN_PPC) - if (cif->rtype->size > 4) - { - rvalue = (void *) *pgr; - pgr++; - } -#else /* assume we return by ref. */ rvalue = (void *) *pgr; pgr++; -#endif } i = 0; @@ -1176,7 +764,7 @@ { case FFI_TYPE_SINT8: case FFI_TYPE_UINT8: -#if defined(POWERPC64) +#ifdef POWERPC64 avalue[i] = (char *) pgr + 7; #else avalue[i] = (char *) pgr + 3; @@ -1186,7 +774,7 @@ case FFI_TYPE_SINT16: case FFI_TYPE_UINT16: -#if defined(POWERPC64) +#ifdef POWERPC64 avalue[i] = (char *) pgr + 6; #else avalue[i] = (char *) pgr + 2; @@ -1196,7 +784,7 @@ case FFI_TYPE_SINT32: case FFI_TYPE_UINT32: -#if defined(POWERPC64) +#ifdef POWERPC64 avalue[i] = (char *) pgr + 4; #else case FFI_TYPE_POINTER: @@ -1206,53 +794,34 @@ break; case FFI_TYPE_STRUCT: +#ifdef POWERPC64 size_al = arg_types[i]->size; -#if defined(POWERPC_DARWIN64) - pgr = (unsigned long *)ALIGN((char *)pgr, arg_types[i]->alignment); - if (size_al < 3 || size_al == 4) - { - avalue[i] = ((char *)pgr)+8-size_al; - if (arg_types[i]->elements[0]->type == FFI_TYPE_FLOAT - && fpsused < NUM_FPR_ARG_REGISTERS) - { - *(float *)pgr = (float) *(double *)pfr; - pfr++; - fpsused++; - } - } - else - { - if (size_al != 16) - pfr = (ffi_dblfl *) - darwin64_struct_floats_to_mem (arg_types[i], (char *)pgr, - (double *)pfr, &fpsused); - avalue[i] = pgr; - } + if (arg_types[i]->elements[0]->type == FFI_TYPE_DOUBLE) + size_al = ALIGN (arg_types[i]->size, 8); + if (size_al < 3 && cif->abi == FFI_DARWIN) + avalue[i] = (void *) pgr + 8 - size_al; + else + avalue[i] = (void *) pgr; pgr += (size_al + 7) / 8; #else + /* Structures that match the basic modes (QI 1 byte, HI 2 bytes, + SI 4 bytes) are aligned as if they were those modes. */ + size_al = arg_types[i]->size; /* If the first member of the struct is a double, then align the struct to double-word. */ if (arg_types[i]->elements[0]->type == FFI_TYPE_DOUBLE) size_al = ALIGN(arg_types[i]->size, 8); -# if defined(POWERPC64) - FFI_ASSERT (cif->abi != FFI_DARWIN); - avalue[i] = pgr; - pgr += (size_al + 7) / 8; -# else - /* Structures that match the basic modes (QI 1 byte, HI 2 bytes, - SI 4 bytes) are aligned as if they were those modes. */ if (size_al < 3 && cif->abi == FFI_DARWIN) - avalue[i] = (char*) pgr + 4 - size_al; + avalue[i] = (void*) pgr + 4 - size_al; else - avalue[i] = pgr; + avalue[i] = (void*) pgr; pgr += (size_al + 3) / 4; -# endif #endif break; case FFI_TYPE_SINT64: case FFI_TYPE_UINT64: -#if defined(POWERPC64) +#ifdef POWERPC64 case FFI_TYPE_POINTER: avalue[i] = pgr; pgr++; @@ -1355,5 +924,5 @@ (closure->fun) (cif, rvalue, avalue, closure->user_data); /* Tell ffi_closure_ASM to perform return type promotions. */ - return cif->rtype; + return cif->rtype->type; } diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi/src/powerpc/ffitarget.h --- a/Modules/_ctypes/libffi/src/powerpc/ffitarget.h Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/_ctypes/libffi/src/powerpc/ffitarget.h Sun Jul 20 10:52:46 2014 -0400 @@ -1,8 +1,6 @@ /* -----------------------------------------------------------------*-C-*- - ffitarget.h - Copyright (c) 2012 Anthony Green - Copyright (C) 2007, 2008, 2010 Free Software Foundation, Inc - Copyright (c) 1996-2003 Red Hat, Inc. - + ffitarget.h - Copyright (c) 1996-2003 Red Hat, Inc. + Copyright (C) 2007, 2008 Free Software Foundation, Inc Target configuration macros for PowerPC. Permission is hereby granted, free of charge, to any person obtaining @@ -30,28 +28,15 @@ #ifndef LIBFFI_TARGET_H #define LIBFFI_TARGET_H -#ifndef LIBFFI_H -#error "Please do not include ffitarget.h directly into your source. Use ffi.h instead." -#endif - /* ---- System specific configurations ----------------------------------- */ #if defined (POWERPC) && defined (__powerpc64__) /* linux64 */ -#ifndef POWERPC64 #define POWERPC64 -#endif -#elif defined (POWERPC_DARWIN) && defined (__ppc64__) /* Darwin64 */ -#ifndef POWERPC64 +#elif defined (POWERPC_DARWIN) && defined (__ppc64__) /* Darwin */ #define POWERPC64 -#endif -#ifndef POWERPC_DARWIN64 -#define POWERPC_DARWIN64 -#endif #elif defined (POWERPC_AIX) && defined (__64BIT__) /* AIX64 */ -#ifndef POWERPC64 #define POWERPC64 #endif -#endif #ifndef LIBFFI_ASM typedef unsigned long ffi_arg; @@ -66,14 +51,18 @@ FFI_LINUX64, FFI_LINUX, FFI_LINUX_SOFT_FLOAT, -# if defined(POWERPC64) +# ifdef POWERPC64 FFI_DEFAULT_ABI = FFI_LINUX64, -# elif defined(__NO_FPRS__) +# else +# if (!defined(__NO_FPRS__) && (__LDBL_MANT_DIG__ == 106)) + FFI_DEFAULT_ABI = FFI_LINUX, +# else +# ifdef __NO_FPRS__ FFI_DEFAULT_ABI = FFI_LINUX_SOFT_FLOAT, -# elif (__LDBL_MANT_DIG__ == 106) - FFI_DEFAULT_ABI = FFI_LINUX, -# else +# else FFI_DEFAULT_ABI = FFI_GCC_SYSV, +# endif +# endif # endif #endif @@ -119,13 +108,9 @@ #define FFI_SYSV_TYPE_SMALL_STRUCT (FFI_TYPE_LAST + 2) #if defined(POWERPC64) || defined(POWERPC_AIX) -# if defined(POWERPC_DARWIN64) -# define FFI_TRAMPOLINE_SIZE 48 -# else -# define FFI_TRAMPOLINE_SIZE 24 -# endif +#define FFI_TRAMPOLINE_SIZE 24 #else /* POWERPC || POWERPC_AIX */ -# define FFI_TRAMPOLINE_SIZE 40 +#define FFI_TRAMPOLINE_SIZE 40 #endif #ifndef LIBFFI_ASM diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi/src/powerpc/linux64.S --- a/Modules/_ctypes/libffi/src/powerpc/linux64.S Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/_ctypes/libffi/src/powerpc/linux64.S Sun Jul 20 10:52:46 2014 -0400 @@ -30,25 +30,16 @@ #include #ifdef __powerpc64__ - .hidden ffi_call_LINUX64 - .globl ffi_call_LINUX64 + .hidden ffi_call_LINUX64, .ffi_call_LINUX64 + .globl ffi_call_LINUX64, .ffi_call_LINUX64 .section ".opd","aw" .align 3 ffi_call_LINUX64: -#ifdef _CALL_LINUX - .quad .L.ffi_call_LINUX64,.TOC.@tocbase,0 - .type ffi_call_LINUX64,@function - .text -.L.ffi_call_LINUX64: -#else - .hidden .ffi_call_LINUX64 - .globl .ffi_call_LINUX64 .quad .ffi_call_LINUX64,.TOC.@tocbase,0 .size ffi_call_LINUX64,24 .type .ffi_call_LINUX64,@function .text .ffi_call_LINUX64: -#endif .LFB1: mflr %r0 std %r28, -32(%r1) @@ -67,11 +58,7 @@ /* Call ffi_prep_args64. */ mr %r4, %r1 -#ifdef _CALL_LINUX - bl ffi_prep_args64 -#else bl .ffi_prep_args64 -#endif ld %r0, 0(%r29) ld %r2, 8(%r29) @@ -150,11 +137,7 @@ .LFE1: .long 0 .byte 0,12,0,1,128,4,0,0 -#ifdef _CALL_LINUX - .size ffi_call_LINUX64,.-.L.ffi_call_LINUX64 -#else .size .ffi_call_LINUX64,.-.ffi_call_LINUX64 -#endif .section .eh_frame,EH_FRAME_FLAGS,@progbits .Lframe1: diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi/src/powerpc/linux64_closure.S --- a/Modules/_ctypes/libffi/src/powerpc/linux64_closure.S Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/_ctypes/libffi/src/powerpc/linux64_closure.S Sun Jul 20 10:52:46 2014 -0400 @@ -32,24 +32,16 @@ #ifdef __powerpc64__ FFI_HIDDEN (ffi_closure_LINUX64) - .globl ffi_closure_LINUX64 + FFI_HIDDEN (.ffi_closure_LINUX64) + .globl ffi_closure_LINUX64, .ffi_closure_LINUX64 .section ".opd","aw" .align 3 ffi_closure_LINUX64: -#ifdef _CALL_LINUX - .quad .L.ffi_closure_LINUX64,.TOC.@tocbase,0 - .type ffi_closure_LINUX64,@function - .text -.L.ffi_closure_LINUX64: -#else - FFI_HIDDEN (.ffi_closure_LINUX64) - .globl .ffi_closure_LINUX64 .quad .ffi_closure_LINUX64,.TOC.@tocbase,0 .size ffi_closure_LINUX64,24 .type .ffi_closure_LINUX64,@function .text .ffi_closure_LINUX64: -#endif .LFB1: # save general regs into parm save area std %r3, 48(%r1) @@ -99,11 +91,7 @@ addi %r6, %r1, 128 # make the call -#ifdef _CALL_LINUX - bl ffi_closure_helper_LINUX64 -#else bl .ffi_closure_helper_LINUX64 -#endif .Lret: # now r3 contains the return type @@ -206,11 +194,7 @@ .LFE1: .long 0 .byte 0,12,0,1,128,0,0,0 -#ifdef _CALL_LINUX - .size ffi_closure_LINUX64,.-.L.ffi_closure_LINUX64 -#else .size .ffi_closure_LINUX64,.-.ffi_closure_LINUX64 -#endif .section .eh_frame,EH_FRAME_FLAGS,@progbits .Lframe1: diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi/src/powerpc/ppc_closure.S --- a/Modules/_ctypes/libffi/src/powerpc/ppc_closure.S Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/_ctypes/libffi/src/powerpc/ppc_closure.S Sun Jul 20 10:52:46 2014 -0400 @@ -122,41 +122,22 @@ blr # case FFI_TYPE_FLOAT -#ifndef __NO_FPRS__ lfs %f1,112+0(%r1) mtlr %r0 addi %r1,%r1,144 -#else - nop - nop - nop -#endif blr # case FFI_TYPE_DOUBLE -#ifndef __NO_FPRS__ lfd %f1,112+0(%r1) mtlr %r0 addi %r1,%r1,144 -#else - nop - nop - nop -#endif blr # case FFI_TYPE_LONGDOUBLE -#ifndef __NO_FPRS__ lfd %f1,112+0(%r1) lfd %f2,112+8(%r1) mtlr %r0 b .Lfinish -#else - nop - nop - nop - blr -#endif # case FFI_TYPE_UINT8 lbz %r3,112+3(%r1) diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi/src/powerpc/sysv.S --- a/Modules/_ctypes/libffi/src/powerpc/sysv.S Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/_ctypes/libffi/src/powerpc/sysv.S Sun Jul 20 10:52:46 2014 -0400 @@ -83,7 +83,6 @@ nop 1: -#ifndef __NO_FPRS__ /* Load all the FP registers. */ bf- 6,2f lfd %f1,-16-(8*4)-(8*8)(%r28) @@ -95,7 +94,6 @@ lfd %f6,-16-(8*4)-(3*8)(%r28) lfd %f7,-16-(8*4)-(2*8)(%r28) lfd %f8,-16-(8*4)-(1*8)(%r28) -#endif 2: /* Make the call. */ @@ -105,9 +103,7 @@ mtcrf 0x01,%r31 /* cr7 */ bt- 31,L(small_struct_return_value) bt- 30,L(done_return_value) -#ifndef __NO_FPRS__ bt- 29,L(fp_return_value) -#endif stw %r3,0(%r30) bf+ 28,L(done_return_value) stw %r4,4(%r30) @@ -128,7 +124,6 @@ lwz %r1,0(%r1) blr -#ifndef __NO_FPRS__ L(fp_return_value): bf 28,L(float_return_value) stfd %f1,0(%r30) @@ -139,7 +134,6 @@ L(float_return_value): stfs %f1,0(%r30) b L(done_return_value) -#endif L(small_struct_return_value): extrwi %r6,%r31,2,19 /* number of bytes padding = shift/8 */ diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi/src/prep_cif.c --- a/Modules/_ctypes/libffi/src/prep_cif.c Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/_ctypes/libffi/src/prep_cif.c Sun Jul 20 10:52:46 2014 -0400 @@ -1,6 +1,5 @@ /* ----------------------------------------------------------------------- - prep_cif.c - Copyright (c) 2011, 2012 Anthony Green - Copyright (c) 1996, 1998, 2007 Red Hat, Inc. + prep_cif.c - Copyright (c) 1996, 1998, 2007 Red Hat, Inc. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the @@ -38,21 +37,17 @@ { ffi_type **ptr; - if (UNLIKELY(arg == NULL || arg->elements == NULL)) - return FFI_BAD_TYPEDEF; + FFI_ASSERT(arg != NULL); - arg->size = 0; - arg->alignment = 0; + FFI_ASSERT(arg->elements != NULL); + FFI_ASSERT(arg->size == 0); + FFI_ASSERT(arg->alignment == 0); ptr = &(arg->elements[0]); - if (UNLIKELY(ptr == 0)) - return FFI_BAD_TYPEDEF; - while ((*ptr) != NULL) { - if (UNLIKELY(((*ptr)->size == 0) - && (initialize_aggregate((*ptr)) != FFI_OK))) + if (((*ptr)->size == 0) && (initialize_aggregate((*ptr)) != FFI_OK)) return FFI_BAD_TYPEDEF; /* Perform a sanity check on the argument type */ @@ -90,38 +85,19 @@ /* Perform machine independent ffi_cif preparation, then call machine dependent routine. */ -/* For non variadic functions isvariadic should be 0 and - nfixedargs==ntotalargs. - - For variadic calls, isvariadic should be 1 and nfixedargs - and ntotalargs set as appropriate. nfixedargs must always be >=1 */ - - -ffi_status FFI_HIDDEN ffi_prep_cif_core(ffi_cif *cif, ffi_abi abi, - unsigned int isvariadic, - unsigned int nfixedargs, - unsigned int ntotalargs, - ffi_type *rtype, ffi_type **atypes) +ffi_status ffi_prep_cif(ffi_cif *cif, ffi_abi abi, unsigned int nargs, + ffi_type *rtype, ffi_type **atypes) { unsigned bytes = 0; unsigned int i; ffi_type **ptr; FFI_ASSERT(cif != NULL); - FFI_ASSERT((!isvariadic) || (nfixedargs >= 1)); - FFI_ASSERT(nfixedargs <= ntotalargs); - -#ifndef X86_WIN32 - if (! (abi > FFI_FIRST_ABI && abi < FFI_LAST_ABI)) - return FFI_BAD_ABI; -#else - if (! (abi > FFI_FIRST_ABI && abi < FFI_LAST_ABI || abi == FFI_THISCALL)) - return FFI_BAD_ABI; -#endif + FFI_ASSERT((abi > FFI_FIRST_ABI) && (abi <= FFI_DEFAULT_ABI)); cif->abi = abi; cif->arg_types = atypes; - cif->nargs = ntotalargs; + cif->nargs = nargs; cif->rtype = rtype; cif->flags = 0; @@ -134,19 +110,12 @@ FFI_ASSERT_VALID_TYPE(cif->rtype); /* x86, x86-64 and s390 stack space allocation is handled in prep_machdep. */ -#if !defined M68K && !defined X86_ANY && !defined S390 && !defined PA +#if !defined M68K && !defined __i386__ && !defined __x86_64__ && !defined S390 && !defined PA /* Make space for the return structure pointer */ if (cif->rtype->type == FFI_TYPE_STRUCT #ifdef SPARC && (cif->abi != FFI_V9 || cif->rtype->size > 32) #endif -#ifdef TILE - && (cif->rtype->size > 10 * FFI_SIZEOF_ARG) -#endif -#ifdef XTENSA - && (cif->rtype->size > 16) -#endif - ) bytes = STACK_ARG_SIZE(sizeof(void*)); #endif @@ -162,7 +131,7 @@ check after the initialization. */ FFI_ASSERT_VALID_TYPE(*ptr); -#if !defined X86_ANY && !defined S390 && !defined PA +#if !defined __i386__ && !defined __x86_64__ && !defined S390 && !defined PA #ifdef SPARC if (((*ptr)->type == FFI_TYPE_STRUCT && ((*ptr)->size > 16 || cif->abi != FFI_V9)) @@ -176,20 +145,6 @@ if (((*ptr)->alignment - 1) & bytes) bytes = ALIGN(bytes, (*ptr)->alignment); -#ifdef TILE - if (bytes < 10 * FFI_SIZEOF_ARG && - bytes + STACK_ARG_SIZE((*ptr)->size) > 10 * FFI_SIZEOF_ARG) - { - /* An argument is never split between the 10 parameter - registers and the stack. */ - bytes = 10 * FFI_SIZEOF_ARG; - } -#endif -#ifdef XTENSA - if (bytes <= 6*4 && bytes + STACK_ARG_SIZE((*ptr)->size) > 6*4) - bytes = 6*4; -#endif - bytes += STACK_ARG_SIZE((*ptr)->size); } #endif @@ -198,31 +153,10 @@ cif->bytes = bytes; /* Perform machine dependent cif processing */ -#ifdef FFI_TARGET_SPECIFIC_VARIADIC - if (isvariadic) - return ffi_prep_cif_machdep_var(cif, nfixedargs, ntotalargs); -#endif - return ffi_prep_cif_machdep(cif); } #endif /* not __CRIS__ */ -ffi_status ffi_prep_cif(ffi_cif *cif, ffi_abi abi, unsigned int nargs, - ffi_type *rtype, ffi_type **atypes) -{ - return ffi_prep_cif_core(cif, abi, 0, nargs, nargs, rtype, atypes); -} - -ffi_status ffi_prep_cif_var(ffi_cif *cif, - ffi_abi abi, - unsigned int nfixedargs, - unsigned int ntotalargs, - ffi_type *rtype, - ffi_type **atypes) -{ - return ffi_prep_cif_core(cif, abi, 1, nfixedargs, ntotalargs, rtype, atypes); -} - #if FFI_CLOSURES ffi_status diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi/src/s390/ffi.c --- a/Modules/_ctypes/libffi/src/s390/ffi.c Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/_ctypes/libffi/src/s390/ffi.c Sun Jul 20 10:52:46 2014 -0400 @@ -750,8 +750,7 @@ void *user_data, void *codeloc) { - if (cif->abi != FFI_SYSV) - return FFI_BAD_ABI; + FFI_ASSERT (cif->abi == FFI_SYSV); #ifndef __s390x__ *(short *)&closure->tramp [0] = 0x0d10; /* basr %r1,0 */ diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi/src/s390/ffitarget.h --- a/Modules/_ctypes/libffi/src/s390/ffitarget.h Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/_ctypes/libffi/src/s390/ffitarget.h Sun Jul 20 10:52:46 2014 -0400 @@ -1,6 +1,5 @@ /* -----------------------------------------------------------------*-C-*- - ffitarget.h - Copyright (c) 2012 Anthony Green - Copyright (c) 1996-2003 Red Hat, Inc. + ffitarget.h - Copyright (c) 1996-2003 Red Hat, Inc. Target configuration macros for S390. Permission is hereby granted, free of charge, to any person obtaining @@ -28,15 +27,9 @@ #ifndef LIBFFI_TARGET_H #define LIBFFI_TARGET_H -#ifndef LIBFFI_H -#error "Please do not include ffitarget.h directly into your source. Use ffi.h instead." -#endif - #if defined (__s390x__) -#ifndef S390X #define S390X #endif -#endif /* ---- System specific configurations ----------------------------------- */ @@ -47,8 +40,8 @@ typedef enum ffi_abi { FFI_FIRST_ABI = 0, FFI_SYSV, - FFI_LAST_ABI, - FFI_DEFAULT_ABI = FFI_SYSV + FFI_DEFAULT_ABI = FFI_SYSV, + FFI_LAST_ABI = FFI_DEFAULT_ABI + 1 } ffi_abi; #endif diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi/src/sh/ffi.c --- a/Modules/_ctypes/libffi/src/sh/ffi.c Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/_ctypes/libffi/src/sh/ffi.c Sun Jul 20 10:52:46 2014 -0400 @@ -1,5 +1,5 @@ /* ----------------------------------------------------------------------- - ffi.c - Copyright (c) 2002-2008, 2012 Kaz Kojima + ffi.c - Copyright (c) 2002, 2003, 2004, 2005, 2006, 2007, 2008 Kaz Kojima Copyright (c) 2008 Red Hat, Inc. SuperH Foreign Function Interface @@ -463,8 +463,7 @@ unsigned int *tramp; unsigned int insn; - if (cif->abi != FFI_SYSV) - return FFI_BAD_ABI; + FFI_ASSERT (cif->abi == FFI_GCC_SYSV); tramp = (unsigned int *) &closure->tramp[0]; /* Set T bit if the function returns a struct pointed with R2. */ diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi/src/sh/ffitarget.h --- a/Modules/_ctypes/libffi/src/sh/ffitarget.h Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/_ctypes/libffi/src/sh/ffitarget.h Sun Jul 20 10:52:46 2014 -0400 @@ -1,6 +1,5 @@ /* -----------------------------------------------------------------*-C-*- - ffitarget.h - Copyright (c) 2012 Anthony Green - Copyright (c) 1996-2003 Red Hat, Inc. + ffitarget.h - Copyright (c) 1996-2003 Red Hat, Inc. Target configuration macros for SuperH. Permission is hereby granted, free of charge, to any person obtaining @@ -28,10 +27,6 @@ #ifndef LIBFFI_TARGET_H #define LIBFFI_TARGET_H -#ifndef LIBFFI_H -#error "Please do not include ffitarget.h directly into your source. Use ffi.h instead." -#endif - /* ---- Generic type definitions ----------------------------------------- */ #ifndef LIBFFI_ASM @@ -41,8 +36,8 @@ typedef enum ffi_abi { FFI_FIRST_ABI = 0, FFI_SYSV, - FFI_LAST_ABI, - FFI_DEFAULT_ABI = FFI_SYSV + FFI_DEFAULT_ABI = FFI_SYSV, + FFI_LAST_ABI = FFI_DEFAULT_ABI + 1 } ffi_abi; #endif diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi/src/sh64/ffi.c --- a/Modules/_ctypes/libffi/src/sh64/ffi.c Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/_ctypes/libffi/src/sh64/ffi.c Sun Jul 20 10:52:46 2014 -0400 @@ -1,5 +1,5 @@ /* ----------------------------------------------------------------------- - ffi.c - Copyright (c) 2003, 2004, 2006, 2007, 2012 Kaz Kojima + ffi.c - Copyright (c) 2003, 2004, 2006, 2007 Kaz Kojima Copyright (c) 2008 Anthony Green SuperH SHmedia Foreign Function Interface @@ -302,8 +302,7 @@ { unsigned int *tramp; - if (cif->abi != FFI_SYSV) - return FFI_BAD_ABI; + FFI_ASSERT (cif->abi == FFI_GCC_SYSV); tramp = (unsigned int *) &closure->tramp[0]; /* Since ffi_closure is an aligned object, the ffi trampoline is diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi/src/sh64/ffitarget.h --- a/Modules/_ctypes/libffi/src/sh64/ffitarget.h Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/_ctypes/libffi/src/sh64/ffitarget.h Sun Jul 20 10:52:46 2014 -0400 @@ -1,6 +1,5 @@ /* -----------------------------------------------------------------*-C-*- - ffitarget.h - Copyright (c) 2012 Anthony Green - Copyright (c) 1996-2003 Red Hat, Inc. + ffitarget.h - Copyright (c) 1996-2003 Red Hat, Inc. Target configuration macros for SuperH - SHmedia. Permission is hereby granted, free of charge, to any person obtaining @@ -28,10 +27,6 @@ #ifndef LIBFFI_TARGET_H #define LIBFFI_TARGET_H -#ifndef LIBFFI_H -#error "Please do not include ffitarget.h directly into your source. Use ffi.h instead." -#endif - /* ---- Generic type definitions ----------------------------------------- */ #ifndef LIBFFI_ASM @@ -41,8 +36,8 @@ typedef enum ffi_abi { FFI_FIRST_ABI = 0, FFI_SYSV, - FFI_LAST_ABI, - FFI_DEFAULT_ABI = FFI_SYSV + FFI_DEFAULT_ABI = FFI_SYSV, + FFI_LAST_ABI = FFI_DEFAULT_ABI + 1 } ffi_abi; #define FFI_EXTRA_CIF_FIELDS long long flags2 diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi/src/sparc/ffi.c --- a/Modules/_ctypes/libffi/src/sparc/ffi.c Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/_ctypes/libffi/src/sparc/ffi.c Sun Jul 20 10:52:46 2014 -0400 @@ -1,6 +1,5 @@ /* ----------------------------------------------------------------------- - ffi.c - Copyright (c) 2011, 2013 Anthony Green - Copyright (c) 1996, 2003-2004, 2007-2008 Red Hat, Inc. + ffi.c - Copyright (c) 1996, 2003, 2004, 2007, 2008 Red Hat, Inc. SPARC Foreign Function Interface @@ -376,10 +375,6 @@ unsigned, unsigned *, void (*fn)(void)); #endif -#ifndef __GNUC__ -void ffi_flush_icache (void *, size_t); -#endif - void ffi_call(ffi_cif *cif, void (*fn)(void), void *rvalue, void **avalue) { extended_cif ecif; @@ -411,54 +406,8 @@ /* We don't yet support calling 32bit code from 64bit */ FFI_ASSERT(0); #else - if (rvalue && (cif->rtype->type == FFI_TYPE_STRUCT -#if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE - || cif->flags == FFI_TYPE_LONGDOUBLE -#endif - )) - { - /* For v8, we need an "unimp" with size of returning struct */ - /* behind "call", so we alloc some executable space for it. */ - /* l7 is used, we need to make sure v8.S doesn't use %l7. */ - unsigned int *call_struct = NULL; - ffi_closure_alloc(32, (void **)&call_struct); - if (call_struct) - { - unsigned long f = (unsigned long)fn; - call_struct[0] = 0xae10001f; /* mov %i7, %l7 */ - call_struct[1] = 0xbe10000f; /* mov %o7, %i7 */ - call_struct[2] = 0x03000000 | f >> 10; /* sethi %hi(fn), %g1 */ - call_struct[3] = 0x9fc06000 | (f & 0x3ff); /* jmp %g1+%lo(fn), %o7 */ - call_struct[4] = 0x01000000; /* nop */ - if (cif->rtype->size < 0x7f) - call_struct[5] = cif->rtype->size; /* unimp */ - else - call_struct[5] = 0x01000000; /* nop */ - call_struct[6] = 0x81c7e008; /* ret */ - call_struct[7] = 0xbe100017; /* mov %l7, %i7 */ -#ifdef __GNUC__ - asm volatile ("iflush %0; iflush %0+8; iflush %0+16; iflush %0+24" : : - "r" (call_struct) : "memory"); - /* SPARC v8 requires 5 instructions for flush to be visible */ - asm volatile ("nop; nop; nop; nop; nop"); -#else - ffi_flush_icache (call_struct, 32); -#endif - ffi_call_v8(ffi_prep_args_v8, &ecif, cif->bytes, - cif->flags, rvalue, call_struct); - ffi_closure_free(call_struct); - } - else - { - ffi_call_v8(ffi_prep_args_v8, &ecif, cif->bytes, - cif->flags, rvalue, fn); - } - } - else - { - ffi_call_v8(ffi_prep_args_v8, &ecif, cif->bytes, - cif->flags, rvalue, fn); - } + ffi_call_v8(ffi_prep_args_v8, &ecif, cif->bytes, + cif->flags, rvalue, fn); #endif break; case FFI_V9: @@ -476,6 +425,7 @@ FFI_ASSERT(0); break; } + } @@ -497,8 +447,7 @@ #ifdef SPARC64 /* Trampoline address is equal to the closure address. We take advantage of that to reduce the trampoline size by 8 bytes. */ - if (cif->abi != FFI_V9) - return FFI_BAD_ABI; + FFI_ASSERT (cif->abi == FFI_V9); fn = (unsigned long) ffi_closure_v9; tramp[0] = 0x83414000; /* rd %pc, %g1 */ tramp[1] = 0xca586010; /* ldx [%g1+16], %g5 */ @@ -507,8 +456,7 @@ *((unsigned long *) &tramp[4]) = fn; #else unsigned long ctx = (unsigned long) codeloc; - if (cif->abi != FFI_V8) - return FFI_BAD_ABI; + FFI_ASSERT (cif->abi == FFI_V8); fn = (unsigned long) ffi_closure_v8; tramp[0] = 0x03000000 | fn >> 10; /* sethi %hi(fn), %g1 */ tramp[1] = 0x05000000 | ctx >> 10; /* sethi %hi(ctx), %g2 */ @@ -520,17 +468,13 @@ closure->fun = fun; closure->user_data = user_data; - /* Flush the Icache. closure is 8 bytes aligned. */ -#ifdef __GNUC__ + /* Flush the Icache. FIXME: alignment isn't certain, assume 8 bytes */ #ifdef SPARC64 - asm volatile ("flush %0; flush %0+8" : : "r" (closure) : "memory"); + asm volatile ("flush %0" : : "r" (closure) : "memory"); + asm volatile ("flush %0" : : "r" (((char *) closure) + 8) : "memory"); #else - asm volatile ("iflush %0; iflush %0+8" : : "r" (closure) : "memory"); - /* SPARC v8 requires 5 instructions for flush to be visible */ - asm volatile ("nop; nop; nop; nop; nop"); -#endif -#else - ffi_flush_icache (closure, 16); + asm volatile ("iflush %0" : : "r" (closure) : "memory"); + asm volatile ("iflush %0" : : "r" (((char *) closure) + 8) : "memory"); #endif return FFI_OK; diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi/src/sparc/ffitarget.h --- a/Modules/_ctypes/libffi/src/sparc/ffitarget.h Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/_ctypes/libffi/src/sparc/ffitarget.h Sun Jul 20 10:52:46 2014 -0400 @@ -1,6 +1,5 @@ /* -----------------------------------------------------------------*-C-*- - ffitarget.h - Copyright (c) 2012 Anthony Green - Copyright (c) 1996-2003 Red Hat, Inc. + ffitarget.h - Copyright (c) 1996-2003 Red Hat, Inc. Target configuration macros for SPARC. Permission is hereby granted, free of charge, to any person obtaining @@ -28,17 +27,11 @@ #ifndef LIBFFI_TARGET_H #define LIBFFI_TARGET_H -#ifndef LIBFFI_H -#error "Please do not include ffitarget.h directly into your source. Use ffi.h instead." -#endif - /* ---- System specific configurations ----------------------------------- */ #if defined(__arch64__) || defined(__sparcv9) -#ifndef SPARC64 #define SPARC64 #endif -#endif #ifndef LIBFFI_ASM typedef unsigned long ffi_arg; @@ -49,12 +42,12 @@ FFI_V8, FFI_V8PLUS, FFI_V9, - FFI_LAST_ABI, #ifdef SPARC64 - FFI_DEFAULT_ABI = FFI_V9 + FFI_DEFAULT_ABI = FFI_V9, #else - FFI_DEFAULT_ABI = FFI_V8 + FFI_DEFAULT_ABI = FFI_V8, #endif + FFI_LAST_ABI = FFI_DEFAULT_ABI + 1 } ffi_abi; #endif diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi/src/sparc/v8.S --- a/Modules/_ctypes/libffi/src/sparc/v8.S Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/_ctypes/libffi/src/sparc/v8.S Sun Jul 20 10:52:46 2014 -0400 @@ -1,6 +1,5 @@ /* ----------------------------------------------------------------------- - v8.S - Copyright (c) 2013 The Written Word, Inc. - Copyright (c) 1996, 1997, 2003, 2004, 2008 Red Hat, Inc. + v8.S - Copyright (c) 1996, 1997, 2003, 2004, 2008 Red Hat, Inc. SPARC Foreign Function Interface @@ -32,39 +31,11 @@ #define STACKFRAME 96 /* Minimum stack framesize for SPARC */ #define ARGS (64+4) /* Offset of register area in frame */ -#ifndef __GNUC__ - .text - .align 8 -.globl ffi_flush_icache -.globl _ffi_flush_icache - -ffi_flush_icache: -_ffi_flush_icache: - add %o0, %o1, %o2 -#ifdef SPARC64 -1: flush %o0 -#else -1: iflush %o0 -#endif - add %o0, 8, %o0 - cmp %o0, %o2 - blt 1b - nop - nop - nop - nop - nop - retl - nop -.ffi_flush_icache_end: - .size ffi_flush_icache,.ffi_flush_icache_end-ffi_flush_icache -#endif - - .text +.text .align 8 .globl ffi_call_v8 .globl _ffi_call_v8 - + ffi_call_v8: _ffi_call_v8: .LLFB1: diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi/src/sparc/v9.S --- a/Modules/_ctypes/libffi/src/sparc/v9.S Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/_ctypes/libffi/src/sparc/v9.S Sun Jul 20 10:52:46 2014 -0400 @@ -32,7 +32,7 @@ /* Only compile this in for 64bit builds, because otherwise the object file will have inproper architecture due to used instructions. */ -#define STACKFRAME 176 /* Minimum stack framesize for SPARC 64-bit */ +#define STACKFRAME 128 /* Minimum stack framesize for SPARC */ #define STACK_BIAS 2047 #define ARGS (128) /* Offset of register area in frame */ diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi/src/tile/ffi.c --- a/Modules/_ctypes/libffi/src/tile/ffi.c Sat Jul 19 16:34:33 2014 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,355 +0,0 @@ -/* ----------------------------------------------------------------------- - ffi.c - Copyright (c) 2012 Tilera Corp. - - TILE Foreign Function Interface - - Permission is hereby granted, free of charge, to any person obtaining - a copy of this software and associated documentation files (the - ``Software''), to deal in the Software without restriction, including - without limitation the rights to use, copy, modify, merge, publish, - distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to - the following conditions: - - The above copyright notice and this permission notice shall be included - in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT - HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, - WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - DEALINGS IN THE SOFTWARE. - ----------------------------------------------------------------------- */ - -#include -#include -#include -#include -#include -#include -#include -#include - - -/* The first 10 registers are used to pass arguments and return values. */ -#define NUM_ARG_REGS 10 - -/* Performs a raw function call with the given NUM_ARG_REGS register arguments - and the specified additional stack arguments (if any). */ -extern void ffi_call_tile(ffi_sarg reg_args[NUM_ARG_REGS], - const ffi_sarg *stack_args, - size_t stack_args_bytes, - void (*fnaddr)(void)) - FFI_HIDDEN; - -/* This handles the raw call from the closure stub, cleaning up the - parameters and delegating to ffi_closure_tile_inner. */ -extern void ffi_closure_tile(void) FFI_HIDDEN; - - -ffi_status -ffi_prep_cif_machdep(ffi_cif *cif) -{ - /* We always allocate room for all registers. Even if we don't - use them as parameters, they get returned in the same array - as struct return values so we need to make room. */ - if (cif->bytes < NUM_ARG_REGS * FFI_SIZEOF_ARG) - cif->bytes = NUM_ARG_REGS * FFI_SIZEOF_ARG; - - if (cif->rtype->size > NUM_ARG_REGS * FFI_SIZEOF_ARG) - cif->flags = FFI_TYPE_STRUCT; - else - cif->flags = FFI_TYPE_INT; - - /* Nothing to do. */ - return FFI_OK; -} - - -static long -assign_to_ffi_arg(ffi_sarg *out, void *in, const ffi_type *type, - int write_to_reg) -{ - switch (type->type) - { - case FFI_TYPE_SINT8: - *out = *(SINT8 *)in; - return 1; - - case FFI_TYPE_UINT8: - *out = *(UINT8 *)in; - return 1; - - case FFI_TYPE_SINT16: - *out = *(SINT16 *)in; - return 1; - - case FFI_TYPE_UINT16: - *out = *(UINT16 *)in; - return 1; - - case FFI_TYPE_SINT32: - case FFI_TYPE_UINT32: -#ifndef __LP64__ - case FFI_TYPE_POINTER: -#endif - /* Note that even unsigned 32-bit quantities are sign extended - on tilegx when stored in a register. */ - *out = *(SINT32 *)in; - return 1; - - case FFI_TYPE_FLOAT: -#ifdef __tilegx__ - if (write_to_reg) - { - /* Properly sign extend the value. */ - union { float f; SINT32 s32; } val; - val.f = *(float *)in; - *out = val.s32; - } - else -#endif - { - *(float *)out = *(float *)in; - } - return 1; - - case FFI_TYPE_SINT64: - case FFI_TYPE_UINT64: - case FFI_TYPE_DOUBLE: -#ifdef __LP64__ - case FFI_TYPE_POINTER: -#endif - *(UINT64 *)out = *(UINT64 *)in; - return sizeof(UINT64) / FFI_SIZEOF_ARG; - - case FFI_TYPE_STRUCT: - memcpy(out, in, type->size); - return (type->size + FFI_SIZEOF_ARG - 1) / FFI_SIZEOF_ARG; - - case FFI_TYPE_VOID: - /* Must be a return type. Nothing to do. */ - return 0; - - default: - FFI_ASSERT(0); - return -1; - } -} - - -void -ffi_call(ffi_cif *cif, void (*fn)(void), void *rvalue, void **avalue) -{ - ffi_sarg * const arg_mem = alloca(cif->bytes); - ffi_sarg * const reg_args = arg_mem; - ffi_sarg * const stack_args = ®_args[NUM_ARG_REGS]; - ffi_sarg *argp = arg_mem; - ffi_type ** const arg_types = cif->arg_types; - const long num_args = cif->nargs; - long i; - - if (cif->flags == FFI_TYPE_STRUCT) - { - /* Pass a hidden pointer to the return value. We make sure there - is scratch space for the callee to store the return value even if - our caller doesn't care about it. */ - *argp++ = (intptr_t)(rvalue ? rvalue : alloca(cif->rtype->size)); - - /* No more work needed to return anything. */ - rvalue = NULL; - } - - for (i = 0; i < num_args; i++) - { - ffi_type *type = arg_types[i]; - void * const arg_in = avalue[i]; - ptrdiff_t arg_word = argp - arg_mem; - -#ifndef __tilegx__ - /* Doubleword-aligned values are always in an even-number register - pair, or doubleword-aligned stack slot if out of registers. */ - long align = arg_word & (type->alignment > FFI_SIZEOF_ARG); - argp += align; - arg_word += align; -#endif - - if (type->type == FFI_TYPE_STRUCT) - { - const size_t arg_size_in_words = - (type->size + FFI_SIZEOF_ARG - 1) / FFI_SIZEOF_ARG; - - if (arg_word < NUM_ARG_REGS && - arg_word + arg_size_in_words > NUM_ARG_REGS) - { - /* Args are not allowed to span registers and the stack. */ - argp = stack_args; - } - - memcpy(argp, arg_in, type->size); - argp += arg_size_in_words; - } - else - { - argp += assign_to_ffi_arg(argp, arg_in, arg_types[i], 1); - } - } - - /* Actually do the call. */ - ffi_call_tile(reg_args, stack_args, - cif->bytes - (NUM_ARG_REGS * FFI_SIZEOF_ARG), fn); - - if (rvalue != NULL) - assign_to_ffi_arg(rvalue, reg_args, cif->rtype, 0); -} - - -/* Template code for closure. */ -extern const UINT64 ffi_template_tramp_tile[] FFI_HIDDEN; - - -ffi_status -ffi_prep_closure_loc (ffi_closure *closure, - ffi_cif *cif, - void (*fun)(ffi_cif*, void*, void**, void*), - void *user_data, - void *codeloc) -{ -#ifdef __tilegx__ - /* TILE-Gx */ - SINT64 c; - SINT64 h; - int s; - UINT64 *out; - - if (cif->abi != FFI_UNIX) - return FFI_BAD_ABI; - - out = (UINT64 *)closure->tramp; - - c = (intptr_t)closure; - h = (intptr_t)ffi_closure_tile; - s = 0; - - /* Find the smallest shift count that doesn't lose information - (i.e. no need to explicitly insert high bits of the address that - are just the sign extension of the low bits). */ - while ((c >> s) != (SINT16)(c >> s) || (h >> s) != (SINT16)(h >> s)) - s += 16; - -#define OPS(a, b, shift) \ - (create_Imm16_X0((a) >> (shift)) | create_Imm16_X1((b) >> (shift))) - - /* Emit the moveli. */ - *out++ = ffi_template_tramp_tile[0] | OPS(c, h, s); - for (s -= 16; s >= 0; s -= 16) - *out++ = ffi_template_tramp_tile[1] | OPS(c, h, s); - -#undef OPS - - *out++ = ffi_template_tramp_tile[2]; - -#else - /* TILEPro */ - UINT64 *out; - intptr_t delta; - - if (cif->abi != FFI_UNIX) - return FFI_BAD_ABI; - - out = (UINT64 *)closure->tramp; - delta = (intptr_t)ffi_closure_tile - (intptr_t)codeloc; - - *out++ = ffi_template_tramp_tile[0] | create_JOffLong_X1(delta >> 3); -#endif - - closure->cif = cif; - closure->fun = fun; - closure->user_data = user_data; - - invalidate_icache(closure->tramp, (char *)out - closure->tramp, - getpagesize()); - - return FFI_OK; -} - - -/* This is called by the assembly wrapper for closures. This does - all of the work. On entry reg_args[0] holds the values the registers - had when the closure was invoked. On return reg_args[1] holds the register - values to be returned to the caller (many of which may be garbage). */ -void FFI_HIDDEN -ffi_closure_tile_inner(ffi_closure *closure, - ffi_sarg reg_args[2][NUM_ARG_REGS], - ffi_sarg *stack_args) -{ - ffi_cif * const cif = closure->cif; - void ** const avalue = alloca(cif->nargs * sizeof(void *)); - void *rvalue; - ffi_type ** const arg_types = cif->arg_types; - ffi_sarg * const reg_args_in = reg_args[0]; - ffi_sarg * const reg_args_out = reg_args[1]; - ffi_sarg * argp; - long i, arg_word, nargs = cif->nargs; - /* Use a union to guarantee proper alignment for double. */ - union { ffi_sarg arg[NUM_ARG_REGS]; double d; UINT64 u64; } closure_ret; - - /* Start out reading register arguments. */ - argp = reg_args_in; - - /* Copy the caller's structure return address to that the closure - returns the data directly to the caller. */ - if (cif->flags == FFI_TYPE_STRUCT) - { - /* Return by reference via hidden pointer. */ - rvalue = (void *)(intptr_t)*argp++; - arg_word = 1; - } - else - { - /* Return the value in registers. */ - rvalue = &closure_ret; - arg_word = 0; - } - - /* Grab the addresses of the arguments. */ - for (i = 0; i < nargs; i++) - { - ffi_type * const type = arg_types[i]; - const size_t arg_size_in_words = - (type->size + FFI_SIZEOF_ARG - 1) / FFI_SIZEOF_ARG; - -#ifndef __tilegx__ - /* Doubleword-aligned values are always in an even-number register - pair, or doubleword-aligned stack slot if out of registers. */ - long align = arg_word & (type->alignment > FFI_SIZEOF_ARG); - argp += align; - arg_word += align; -#endif - - if (arg_word == NUM_ARG_REGS || - (arg_word < NUM_ARG_REGS && - arg_word + arg_size_in_words > NUM_ARG_REGS)) - { - /* Switch to reading arguments from the stack. */ - argp = stack_args; - arg_word = NUM_ARG_REGS; - } - - avalue[i] = argp; - argp += arg_size_in_words; - arg_word += arg_size_in_words; - } - - /* Invoke the closure. */ - closure->fun(cif, rvalue, avalue, closure->user_data); - - if (cif->flags != FFI_TYPE_STRUCT) - { - /* Canonicalize for register representation. */ - assign_to_ffi_arg(reg_args_out, &closure_ret, cif->rtype, 1); - } -} diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi/src/tile/ffitarget.h --- a/Modules/_ctypes/libffi/src/tile/ffitarget.h Sat Jul 19 16:34:33 2014 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,65 +0,0 @@ -/* -----------------------------------------------------------------*-C-*- - ffitarget.h - Copyright (c) 2012 Tilera Corp. - Target configuration macros for TILE. - - Permission is hereby granted, free of charge, to any person obtaining - a copy of this software and associated documentation files (the - ``Software''), to deal in the Software without restriction, including - without limitation the rights to use, copy, modify, merge, publish, - distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to - the following conditions: - - The above copyright notice and this permission notice shall be included - in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT - HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, - WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - DEALINGS IN THE SOFTWARE. - ----------------------------------------------------------------------- */ - -#ifndef LIBFFI_TARGET_H -#define LIBFFI_TARGET_H - -#ifndef LIBFFI_H -#error "Please do not include ffitarget.h directly into your source. Use ffi.h instead." -#endif - -#ifndef LIBFFI_ASM - -#include - -typedef uint_reg_t ffi_arg; -typedef int_reg_t ffi_sarg; - -typedef enum ffi_abi { - FFI_FIRST_ABI = 0, - FFI_UNIX, - FFI_LAST_ABI, - FFI_DEFAULT_ABI = FFI_UNIX -} ffi_abi; -#endif - -/* ---- Definitions for closures ----------------------------------------- */ -#define FFI_CLOSURES 1 - -#ifdef __tilegx__ -/* We always pass 8-byte values, even in -m32 mode. */ -# define FFI_SIZEOF_ARG 8 -# ifdef __LP64__ -# define FFI_TRAMPOLINE_SIZE (8 * 5) /* 5 bundles */ -# else -# define FFI_TRAMPOLINE_SIZE (8 * 3) /* 3 bundles */ -# endif -#else -# define FFI_SIZEOF_ARG 4 -# define FFI_TRAMPOLINE_SIZE 8 /* 1 bundle */ -#endif -#define FFI_NATIVE_RAW_API 0 - -#endif diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi/src/tile/tile.S --- a/Modules/_ctypes/libffi/src/tile/tile.S Sat Jul 19 16:34:33 2014 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,360 +0,0 @@ -/* ----------------------------------------------------------------------- - tile.S - Copyright (c) 2011 Tilera Corp. - - Tilera TILEPro and TILE-Gx Foreign Function Interface - - Permission is hereby granted, free of charge, to any person obtaining - a copy of this software and associated documentation files (the - ``Software''), to deal in the Software without restriction, including - without limitation the rights to use, copy, modify, merge, publish, - distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to - the following conditions: - - The above copyright notice and this permission notice shall be included - in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT - HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, - WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - DEALINGS IN THE SOFTWARE. - ----------------------------------------------------------------------- */ - -#define LIBFFI_ASM -#include -#include - -/* Number of bytes in a register. */ -#define REG_SIZE FFI_SIZEOF_ARG - -/* Number of bytes in stack linkage area for backtracing. - - A note about the ABI: on entry to a procedure, sp points to a stack - slot where it must spill the return address if it's not a leaf. - REG_SIZE bytes beyond that is a slot owned by the caller which - contains the sp value that the caller had when it was originally - entered (i.e. the caller's frame pointer). */ -#define LINKAGE_SIZE (2 * REG_SIZE) - -/* The first 10 registers are used to pass arguments and return values. */ -#define NUM_ARG_REGS 10 - -#ifdef __tilegx__ -#define SW st -#define LW ld -#define BGZT bgtzt -#else -#define SW sw -#define LW lw -#define BGZT bgzt -#endif - - -/* void ffi_call_tile (int_reg_t reg_args[NUM_ARG_REGS], - const int_reg_t *stack_args, - unsigned long stack_args_bytes, - void (*fnaddr)(void)); - - On entry, REG_ARGS contain the outgoing register values, - and STACK_ARGS containts STACK_ARG_BYTES of additional values - to be passed on the stack. If STACK_ARG_BYTES is zero, then - STACK_ARGS is ignored. - - When the invoked function returns, the values of r0-r9 are - blindly stored back into REG_ARGS for the caller to examine. */ - - .section .text.ffi_call_tile, "ax", @progbits - .align 8 - .globl ffi_call_tile - FFI_HIDDEN(ffi_call_tile) -ffi_call_tile: - -/* Incoming arguments. */ -#define REG_ARGS r0 -#define INCOMING_STACK_ARGS r1 -#define STACK_ARG_BYTES r2 -#define ORIG_FNADDR r3 - -/* Temporary values. */ -#define FRAME_SIZE r10 -#define TMP r11 -#define TMP2 r12 -#define OUTGOING_STACK_ARGS r13 -#define REG_ADDR_PTR r14 -#define RETURN_REG_ADDR r15 -#define FNADDR r16 - - .cfi_startproc - { - /* Save return address. */ - SW sp, lr - .cfi_offset lr, 0 - /* Prepare to spill incoming r52. */ - addi TMP, sp, -REG_SIZE - /* Increase frame size to have room to spill r52 and REG_ARGS. - The +7 is to round up mod 8. */ - addi FRAME_SIZE, STACK_ARG_BYTES, \ - REG_SIZE + REG_SIZE + LINKAGE_SIZE + 7 - } - { - /* Round stack frame size to a multiple of 8 to satisfy ABI. */ - andi FRAME_SIZE, FRAME_SIZE, -8 - /* Compute where to spill REG_ARGS value. */ - addi TMP2, sp, -(REG_SIZE * 2) - } - { - /* Spill incoming r52. */ - SW TMP, r52 - .cfi_offset r52, -REG_SIZE - /* Set up our frame pointer. */ - move r52, sp - .cfi_def_cfa_register r52 - /* Push stack frame. */ - sub sp, sp, FRAME_SIZE - } - { - /* Prepare to set up stack linkage. */ - addi TMP, sp, REG_SIZE - /* Prepare to memcpy stack args. */ - addi OUTGOING_STACK_ARGS, sp, LINKAGE_SIZE - /* Save REG_ARGS which we will need after we call the subroutine. */ - SW TMP2, REG_ARGS - } - { - /* Set up linkage info to hold incoming stack pointer. */ - SW TMP, r52 - } - { - /* Skip stack args memcpy if we don't have any stack args (common). */ - blezt STACK_ARG_BYTES, .Ldone_stack_args_memcpy - } - -.Lmemcpy_stack_args: - { - /* Load incoming argument from stack_args. */ - LW TMP, INCOMING_STACK_ARGS - addi INCOMING_STACK_ARGS, INCOMING_STACK_ARGS, REG_SIZE - } - { - /* Store stack argument into outgoing stack argument area. */ - SW OUTGOING_STACK_ARGS, TMP - addi OUTGOING_STACK_ARGS, OUTGOING_STACK_ARGS, REG_SIZE - addi STACK_ARG_BYTES, STACK_ARG_BYTES, -REG_SIZE - } - { - BGZT STACK_ARG_BYTES, .Lmemcpy_stack_args - } -.Ldone_stack_args_memcpy: - - { - /* Copy aside ORIG_FNADDR so we can overwrite its register. */ - move FNADDR, ORIG_FNADDR - /* Prepare to load argument registers. */ - addi REG_ADDR_PTR, r0, REG_SIZE - /* Load outgoing r0. */ - LW r0, r0 - } - - /* Load up argument registers from the REG_ARGS array. */ -#define LOAD_REG(REG, PTR) \ - { \ - LW REG, PTR ; \ - addi PTR, PTR, REG_SIZE \ - } - - LOAD_REG(r1, REG_ADDR_PTR) - LOAD_REG(r2, REG_ADDR_PTR) - LOAD_REG(r3, REG_ADDR_PTR) - LOAD_REG(r4, REG_ADDR_PTR) - LOAD_REG(r5, REG_ADDR_PTR) - LOAD_REG(r6, REG_ADDR_PTR) - LOAD_REG(r7, REG_ADDR_PTR) - LOAD_REG(r8, REG_ADDR_PTR) - LOAD_REG(r9, REG_ADDR_PTR) - - { - /* Call the subroutine. */ - jalr FNADDR - } - - { - /* Restore original lr. */ - LW lr, r52 - /* Prepare to recover ARGS, which we spilled earlier. */ - addi TMP, r52, -(2 * REG_SIZE) - } - { - /* Restore ARGS, so we can fill it in with the return regs r0-r9. */ - LW RETURN_REG_ADDR, TMP - /* Prepare to restore original r52. */ - addi TMP, r52, -REG_SIZE - } - - { - /* Pop stack frame. */ - move sp, r52 - /* Restore original r52. */ - LW r52, TMP - } - -#define STORE_REG(REG, PTR) \ - { \ - SW PTR, REG ; \ - addi PTR, PTR, REG_SIZE \ - } - - /* Return all register values by reference. */ - STORE_REG(r0, RETURN_REG_ADDR) - STORE_REG(r1, RETURN_REG_ADDR) - STORE_REG(r2, RETURN_REG_ADDR) - STORE_REG(r3, RETURN_REG_ADDR) - STORE_REG(r4, RETURN_REG_ADDR) - STORE_REG(r5, RETURN_REG_ADDR) - STORE_REG(r6, RETURN_REG_ADDR) - STORE_REG(r7, RETURN_REG_ADDR) - STORE_REG(r8, RETURN_REG_ADDR) - STORE_REG(r9, RETURN_REG_ADDR) - - { - jrp lr - } - - .cfi_endproc - .size ffi_call_tile, .-ffi_call_tile - -/* ffi_closure_tile(...) - - On entry, lr points to the closure plus 8 bytes, and r10 - contains the actual return address. - - This function simply dumps all register parameters into a stack array - and passes the closure, the registers array, and the stack arguments - to C code that does all of the actual closure processing. */ - - .section .text.ffi_closure_tile, "ax", @progbits - .align 8 - .globl ffi_closure_tile - FFI_HIDDEN(ffi_closure_tile) - - .cfi_startproc -/* Room to spill all NUM_ARG_REGS incoming registers, plus frame linkage. */ -#define CLOSURE_FRAME_SIZE (((NUM_ARG_REGS * REG_SIZE * 2 + LINKAGE_SIZE) + 7) & -8) -ffi_closure_tile: - { -#ifdef __tilegx__ - st sp, lr - .cfi_offset lr, 0 -#else - /* Save return address (in r10 due to closure stub wrapper). */ - SW sp, r10 - .cfi_return_column r10 - .cfi_offset r10, 0 -#endif - /* Compute address for stack frame linkage. */ - addli r10, sp, -(CLOSURE_FRAME_SIZE - REG_SIZE) - } - { - /* Save incoming stack pointer in linkage area. */ - SW r10, sp - .cfi_offset sp, -(CLOSURE_FRAME_SIZE - REG_SIZE) - /* Push a new stack frame. */ - addli sp, sp, -CLOSURE_FRAME_SIZE - .cfi_adjust_cfa_offset CLOSURE_FRAME_SIZE - } - - { - /* Create pointer to where to start spilling registers. */ - addi r10, sp, LINKAGE_SIZE - } - - /* Spill all the incoming registers. */ - STORE_REG(r0, r10) - STORE_REG(r1, r10) - STORE_REG(r2, r10) - STORE_REG(r3, r10) - STORE_REG(r4, r10) - STORE_REG(r5, r10) - STORE_REG(r6, r10) - STORE_REG(r7, r10) - STORE_REG(r8, r10) - { - /* Save r9. */ - SW r10, r9 -#ifdef __tilegx__ - /* Pointer to closure is passed in r11. */ - move r0, r11 -#else - /* Compute pointer to the closure object. Because the closure - starts with a "jal ffi_closure_tile", we can just take the - value of lr (a phony return address pointing into the closure) - and subtract 8. */ - addi r0, lr, -8 -#endif - /* Compute a pointer to the register arguments we just spilled. */ - addi r1, sp, LINKAGE_SIZE - } - { - /* Compute a pointer to the extra stack arguments (if any). */ - addli r2, sp, CLOSURE_FRAME_SIZE + LINKAGE_SIZE - /* Call C code to deal with all of the grotty details. */ - jal ffi_closure_tile_inner - } - { - addli r10, sp, CLOSURE_FRAME_SIZE - } - { - /* Restore the return address. */ - LW lr, r10 - /* Compute pointer to registers array. */ - addli r10, sp, LINKAGE_SIZE + (NUM_ARG_REGS * REG_SIZE) - } - /* Return all the register values, which C code may have set. */ - LOAD_REG(r0, r10) - LOAD_REG(r1, r10) - LOAD_REG(r2, r10) - LOAD_REG(r3, r10) - LOAD_REG(r4, r10) - LOAD_REG(r5, r10) - LOAD_REG(r6, r10) - LOAD_REG(r7, r10) - LOAD_REG(r8, r10) - LOAD_REG(r9, r10) - { - /* Pop the frame. */ - addli sp, sp, CLOSURE_FRAME_SIZE - jrp lr - } - - .cfi_endproc - .size ffi_closure_tile, . - ffi_closure_tile - - -/* What follows are code template instructions that get copied to the - closure trampoline by ffi_prep_closure_loc. The zeroed operands - get replaced by their proper values at runtime. */ - - .section .text.ffi_template_tramp_tile, "ax", @progbits - .align 8 - .globl ffi_template_tramp_tile - FFI_HIDDEN(ffi_template_tramp_tile) -ffi_template_tramp_tile: -#ifdef __tilegx__ - { - moveli r11, 0 /* backpatched to address of containing closure. */ - moveli r10, 0 /* backpatched to ffi_closure_tile. */ - } - /* Note: the following bundle gets generated multiple times - depending on the pointer value (esp. useful for -m32 mode). */ - { shl16insli r11, r11, 0 ; shl16insli r10, r10, 0 } - { info 2+8 /* for backtracer: -> pc in lr, frame size 0 */ ; jr r10 } -#else - /* 'jal .' yields a PC-relative offset of zero so we can OR in the - right offset at runtime. */ - { move r10, lr ; jal . /* ffi_closure_tile */ } -#endif - - .size ffi_template_tramp_tile, . - ffi_template_tramp_tile diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi/src/x86/ffi.c --- a/Modules/_ctypes/libffi/src/x86/ffi.c Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/_ctypes/libffi/src/x86/ffi.c Sun Jul 20 10:52:46 2014 -0400 @@ -3,7 +3,7 @@ Copyright (c) 2002 Ranjit Mathew Copyright (c) 2002 Bo Thorsen Copyright (c) 2002 Roger Sayle - Copyright (C) 2008, 2010 Free Software Foundation, Inc. + Copyright (C) 2008 Free Software Foundation, Inc. x86 Foreign Function Interface @@ -48,18 +48,10 @@ register void **p_argv; register char *argp; register ffi_type **p_arg; -#ifdef X86_WIN32 - size_t p_stack_args[2]; - void *p_stack_data[2]; - char *argp2 = stack; - int stack_args_count = 0; - int cabi = ecif->cif->abi; -#endif argp = stack; - if ((ecif->cif->flags == FFI_TYPE_STRUCT - || ecif->cif->flags == FFI_TYPE_MS_STRUCT) + if (ecif->cif->flags == FFI_TYPE_STRUCT #ifdef X86_WIN64 && (ecif->cif->rtype->size != 1 && ecif->cif->rtype->size != 2 && ecif->cif->rtype->size != 4 && ecif->cif->rtype->size != 8) @@ -67,16 +59,6 @@ ) { *(void **) argp = ecif->rvalue; -#ifdef X86_WIN32 - /* For fastcall/thiscall this is first register-passed - argument. */ - if (cabi == FFI_THISCALL || cabi == FFI_FASTCALL) - { - p_stack_args[stack_args_count] = sizeof (void*); - p_stack_data[stack_args_count] = argp; - ++stack_args_count; - } -#endif argp += sizeof(void*); } @@ -152,24 +134,6 @@ { memcpy(argp, *p_argv, z); } - -#ifdef X86_WIN32 - /* For thiscall/fastcall convention register-passed arguments - are the first two none-floating-point arguments with a size - smaller or equal to sizeof (void*). */ - if ((cabi == FFI_THISCALL && stack_args_count < 1) - || (cabi == FFI_FASTCALL && stack_args_count < 2)) - { - if (z <= 4 - && ((*p_arg)->type != FFI_TYPE_FLOAT - && (*p_arg)->type != FFI_TYPE_STRUCT)) - { - p_stack_args[stack_args_count] = z; - p_stack_data[stack_args_count] = argp; - ++stack_args_count; - } - } -#endif p_argv++; #ifdef X86_WIN64 argp += (z + sizeof(void*) - 1) & ~(sizeof(void*) - 1); @@ -177,45 +141,7 @@ argp += z; #endif } - -#ifdef X86_WIN32 - /* We need to move the register-passed arguments for thiscall/fastcall - on top of stack, so that those can be moved to registers ecx/edx by - call-handler. */ - if (stack_args_count > 0) - { - size_t zz = (p_stack_args[0] + 3) & ~3; - char *h; - - /* Move first argument to top-stack position. */ - if (p_stack_data[0] != argp2) - { - h = alloca (zz + 1); - memcpy (h, p_stack_data[0], zz); - memmove (argp2 + zz, argp2, - (size_t) ((char *) p_stack_data[0] - (char*)argp2)); - memcpy (argp2, h, zz); - } - - argp2 += zz; - --stack_args_count; - if (zz > 4) - stack_args_count = 0; - - /* If we have a second argument, then move it on top - after the first one. */ - if (stack_args_count > 0 && p_stack_data[1] != argp2) - { - zz = p_stack_args[1]; - zz = (zz + 3) & ~3; - h = alloca (zz + 1); - h = alloca (zz + 1); - memcpy (h, p_stack_data[1], zz); - memmove (argp2 + zz, argp2, (size_t) ((char*) p_stack_data[1] - (char*)argp2)); - memcpy (argp2, h, zz); - } - } -#endif + return; } @@ -229,10 +155,12 @@ switch (cif->rtype->type) { case FFI_TYPE_VOID: +#if defined(X86) || defined (X86_WIN32) || defined(X86_FREEBSD) || defined(X86_DARWIN) || defined(X86_WIN64) case FFI_TYPE_UINT8: case FFI_TYPE_UINT16: case FFI_TYPE_SINT8: case FFI_TYPE_SINT16: +#endif #ifdef X86_WIN64 case FFI_TYPE_UINT32: case FFI_TYPE_SINT32: @@ -280,13 +208,8 @@ else #endif { -#ifdef X86_WIN32 - if (cif->abi == FFI_MS_CDECL) - cif->flags = FFI_TYPE_MS_STRUCT; - else -#endif - cif->flags = FFI_TYPE_STRUCT; - /* allocate space for return value pointer */ + cif->flags = FFI_TYPE_STRUCT; + // allocate space for return value pointer cif->bytes += ALIGN(sizeof(void*), FFI_SIZEOF_ARG); } break; @@ -311,11 +234,13 @@ } #ifdef X86_WIN64 - /* ensure space for storing four registers */ + // ensure space for storing four registers cif->bytes += 4 * sizeof(ffi_arg); #endif +#ifdef X86_DARWIN cif->bytes = (cif->bytes + 15) & ~0xF; +#endif return FFI_OK; } @@ -327,7 +252,7 @@ #elif defined(X86_WIN32) extern void ffi_call_win32(void (*)(char *, extended_cif *), extended_cif *, - unsigned, unsigned, unsigned, unsigned *, void (*fn)(void)); + unsigned, unsigned, unsigned *, void (*fn)(void)); #else extern void ffi_call_SYSV(void (*)(char *, extended_cif *), extended_cif *, unsigned, unsigned, unsigned *, void (*fn)(void)); @@ -353,8 +278,7 @@ } #else if (rvalue == NULL - && (cif->flags == FFI_TYPE_STRUCT - || cif->flags == FFI_TYPE_MS_STRUCT)) + && cif->flags == FFI_TYPE_STRUCT) { ecif.rvalue = alloca(cif->rtype->size); } @@ -367,44 +291,33 @@ { #ifdef X86_WIN64 case FFI_WIN64: - ffi_call_win64(ffi_prep_args, &ecif, cif->bytes, - cif->flags, ecif.rvalue, fn); + { + // Make copies of all struct arguments + // NOTE: not sure if responsibility should be here or in caller + unsigned int i; + for (i=0; i < cif->nargs;i++) { + size_t size = cif->arg_types[i]->size; + if ((cif->arg_types[i]->type == FFI_TYPE_STRUCT + && (size != 1 && size != 2 && size != 4 && size != 8)) +#if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE + || cif->arg_types[i]->type == FFI_TYPE_LONGDOUBLE +#endif + ) + { + void *local = alloca(size); + memcpy(local, avalue[i], size); + avalue[i] = local; + } + } + ffi_call_win64(ffi_prep_args, &ecif, cif->bytes, + cif->flags, ecif.rvalue, fn); + } break; #elif defined(X86_WIN32) case FFI_SYSV: case FFI_STDCALL: - case FFI_MS_CDECL: - ffi_call_win32(ffi_prep_args, &ecif, cif->abi, cif->bytes, cif->flags, - ecif.rvalue, fn); - break; - case FFI_THISCALL: - case FFI_FASTCALL: - { - unsigned int abi = cif->abi; - unsigned int i, passed_regs = 0; - - if (cif->flags == FFI_TYPE_STRUCT) - ++passed_regs; - - for (i=0; i < cif->nargs && passed_regs < 2;i++) - { - size_t sz; - - if (cif->arg_types[i]->type == FFI_TYPE_FLOAT - || cif->arg_types[i]->type == FFI_TYPE_STRUCT) - continue; - sz = (cif->arg_types[i]->size + 3) & ~3; - if (sz == 0 || sz > 4) - continue; - ++passed_regs; - } - if (passed_regs < 2 && abi == FFI_FASTCALL) - abi = FFI_THISCALL; - if (passed_regs < 1 && abi == FFI_THISCALL) - abi = FFI_STDCALL; - ffi_call_win32(ffi_prep_args, &ecif, abi, cif->bytes, cif->flags, - ecif.rvalue, fn); - } + ffi_call_win32(ffi_prep_args, &ecif, cif->bytes, cif->flags, + ecif.rvalue, fn); break; #else case FFI_SYSV: @@ -422,7 +335,7 @@ /** private members **/ /* The following __attribute__((regparm(1))) decorations will have no effect - on MSVC or SUNPRO_C -- standard conventions apply. */ + on MSVC - standard cdecl convention applies. */ static void ffi_prep_incoming_args_SYSV (char *stack, void **ret, void** args, ffi_cif* cif); void FFI_HIDDEN ffi_closure_SYSV (ffi_closure *) @@ -432,12 +345,8 @@ void FFI_HIDDEN ffi_closure_raw_SYSV (ffi_raw_closure *) __attribute__ ((regparm(1))); #ifdef X86_WIN32 -void FFI_HIDDEN ffi_closure_raw_THISCALL (ffi_raw_closure *) - __attribute__ ((regparm(1))); void FFI_HIDDEN ffi_closure_STDCALL (ffi_closure *) __attribute__ ((regparm(1))); -void FFI_HIDDEN ffi_closure_THISCALL (ffi_closure *) - __attribute__ ((regparm(1))); #endif #ifdef X86_WIN64 void FFI_HIDDEN ffi_closure_win64 (ffi_closure *); @@ -519,8 +428,7 @@ argp += sizeof(void *); } #else - if ( cif->flags == FFI_TYPE_STRUCT - || cif->flags == FFI_TYPE_MS_STRUCT ) { + if ( cif->flags == FFI_TYPE_STRUCT ) { *rvalue = *(void **) argp; argp += sizeof(void *); } @@ -598,33 +506,6 @@ *(unsigned int*) &__tramp[6] = __dis; /* jmp __fun */ \ } -#define FFI_INIT_TRAMPOLINE_THISCALL(TRAMP,FUN,CTX,SIZE) \ -{ unsigned char *__tramp = (unsigned char*)(TRAMP); \ - unsigned int __fun = (unsigned int)(FUN); \ - unsigned int __ctx = (unsigned int)(CTX); \ - unsigned int __dis = __fun - (__ctx + 49); \ - unsigned short __size = (unsigned short)(SIZE); \ - *(unsigned int *) &__tramp[0] = 0x8324048b; /* mov (%esp), %eax */ \ - *(unsigned int *) &__tramp[4] = 0x4c890cec; /* sub $12, %esp */ \ - *(unsigned int *) &__tramp[8] = 0x04890424; /* mov %ecx, 4(%esp) */ \ - *(unsigned char*) &__tramp[12] = 0x24; /* mov %eax, (%esp) */ \ - *(unsigned char*) &__tramp[13] = 0xb8; \ - *(unsigned int *) &__tramp[14] = __size; /* mov __size, %eax */ \ - *(unsigned int *) &__tramp[18] = 0x08244c8d; /* lea 8(%esp), %ecx */ \ - *(unsigned int *) &__tramp[22] = 0x4802e8c1; /* shr $2, %eax ; dec %eax */ \ - *(unsigned short*) &__tramp[26] = 0x0b74; /* jz 1f */ \ - *(unsigned int *) &__tramp[28] = 0x8908518b; /* 2b: mov 8(%ecx), %edx */ \ - *(unsigned int *) &__tramp[32] = 0x04c18311; /* mov %edx, (%ecx) ; add $4, %ecx */ \ - *(unsigned char*) &__tramp[36] = 0x48; /* dec %eax */ \ - *(unsigned short*) &__tramp[37] = 0xf575; /* jnz 2b ; 1f: */ \ - *(unsigned char*) &__tramp[39] = 0xb8; \ - *(unsigned int*) &__tramp[40] = __ctx; /* movl __ctx, %eax */ \ - *(unsigned char *) &__tramp[44] = 0xe8; \ - *(unsigned int*) &__tramp[45] = __dis; /* call __fun */ \ - *(unsigned char*) &__tramp[49] = 0xc2; /* ret */ \ - *(unsigned short*) &__tramp[50] = (__size + 8); /* ret (__size + 8) */ \ - } - #define FFI_INIT_TRAMPOLINE_STDCALL(TRAMP,FUN,CTX,SIZE) \ { unsigned char *__tramp = (unsigned char*)(TRAMP); \ unsigned int __fun = (unsigned int)(FUN); \ @@ -667,25 +548,12 @@ (void*)codeloc); } #ifdef X86_WIN32 - else if (cif->abi == FFI_THISCALL) - { - FFI_INIT_TRAMPOLINE_THISCALL (&closure->tramp[0], - &ffi_closure_THISCALL, - (void*)codeloc, - cif->bytes); - } else if (cif->abi == FFI_STDCALL) { FFI_INIT_TRAMPOLINE_STDCALL (&closure->tramp[0], &ffi_closure_STDCALL, (void*)codeloc, cif->bytes); } - else if (cif->abi == FFI_MS_CDECL) - { - FFI_INIT_TRAMPOLINE (&closure->tramp[0], - &ffi_closure_SYSV, - (void*)codeloc); - } #endif /* X86_WIN32 */ #endif /* !X86_WIN64 */ else @@ -714,9 +582,6 @@ int i; if (cif->abi != FFI_SYSV) { -#ifdef X86_WIN32 - if (cif->abi != FFI_THISCALL) -#endif return FFI_BAD_ABI; } @@ -731,20 +596,10 @@ FFI_ASSERT (cif->arg_types[i]->type != FFI_TYPE_LONGDOUBLE); } -#ifdef X86_WIN32 - if (cif->abi == FFI_SYSV) - { -#endif + FFI_INIT_TRAMPOLINE (&closure->tramp[0], &ffi_closure_raw_SYSV, codeloc); -#ifdef X86_WIN32 - } - else if (cif->abi == FFI_THISCALL) - { - FFI_INIT_TRAMPOLINE_THISCALL (&closure->tramp[0], &ffi_closure_raw_THISCALL, - codeloc, cif->bytes); - } -#endif + closure->cif = cif; closure->user_data = user_data; closure->fun = fun; @@ -775,9 +630,8 @@ /* If the return value is a struct and we don't have a return */ /* value address then we need to make one */ - if (rvalue == NULL - && (cif->flags == FFI_TYPE_STRUCT - || cif->flags == FFI_TYPE_MS_STRUCT)) + if ((rvalue == NULL) && + (cif->rtype->type == FFI_TYPE_STRUCT)) { ecif.rvalue = alloca(cif->rtype->size); } @@ -790,38 +644,8 @@ #ifdef X86_WIN32 case FFI_SYSV: case FFI_STDCALL: - case FFI_MS_CDECL: - ffi_call_win32(ffi_prep_args_raw, &ecif, cif->abi, cif->bytes, cif->flags, - ecif.rvalue, fn); - break; - case FFI_THISCALL: - case FFI_FASTCALL: - { - unsigned int abi = cif->abi; - unsigned int i, passed_regs = 0; - - if (cif->flags == FFI_TYPE_STRUCT) - ++passed_regs; - - for (i=0; i < cif->nargs && passed_regs < 2;i++) - { - size_t sz; - - if (cif->arg_types[i]->type == FFI_TYPE_FLOAT - || cif->arg_types[i]->type == FFI_TYPE_STRUCT) - continue; - sz = (cif->arg_types[i]->size + 3) & ~3; - if (sz == 0 || sz > 4) - continue; - ++passed_regs; - } - if (passed_regs < 2 && abi == FFI_FASTCALL) - cif->abi = abi = FFI_THISCALL; - if (passed_regs < 1 && abi == FFI_THISCALL) - cif->abi = abi = FFI_STDCALL; - ffi_call_win32(ffi_prep_args_raw, &ecif, abi, cif->bytes, cif->flags, - ecif.rvalue, fn); - } + ffi_call_win32(ffi_prep_args_raw, &ecif, cif->bytes, cif->flags, + ecif.rvalue, fn); break; #else case FFI_SYSV: diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi/src/x86/ffi64.c --- a/Modules/_ctypes/libffi/src/x86/ffi64.c Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/_ctypes/libffi/src/x86/ffi64.c Sun Jul 20 10:52:46 2014 -0400 @@ -1,9 +1,7 @@ /* ----------------------------------------------------------------------- - ffi64.c - Copyright (c) 2013 The Written Word, Inc. - Copyright (c) 2011 Anthony Green - Copyright (c) 2008, 2010 Red Hat, Inc. - Copyright (c) 2002, 2007 Bo Thorsen - + ffi64.c - Copyright (c) 2002, 2007 Bo Thorsen + Copyright (c) 2008 Red Hat, Inc. + x86-64 Foreign Function Interface Permission is hereby granted, free of charge, to any person obtaining @@ -38,29 +36,11 @@ #define MAX_GPR_REGS 6 #define MAX_SSE_REGS 8 -#if defined(__INTEL_COMPILER) -#define UINT128 __m128 -#else -#if defined(__SUNPRO_C) -#include -#define UINT128 __m128i -#else -#define UINT128 __int128_t -#endif -#endif - -union big_int_union -{ - UINT32 i32; - UINT64 i64; - UINT128 i128; -}; - struct register_args { /* Registers for argument passing. */ UINT64 gpr[MAX_GPR_REGS]; - union big_int_union sse[MAX_SSE_REGS]; + __int128_t sse[MAX_SSE_REGS]; }; extern void ffi_call_unix64 (void *args, unsigned long bytes, unsigned flags, @@ -398,7 +378,7 @@ if (align < 8) align = 8; - bytes = ALIGN (bytes, align); + bytes = ALIGN(bytes, align); bytes += cif->arg_types[i]->size; } else @@ -410,7 +390,7 @@ if (ssecount) flags |= 1 << 11; cif->flags = flags; - cif->bytes = ALIGN (bytes, 8); + cif->bytes = bytes; return FFI_OK; } @@ -446,7 +426,7 @@ /* If the return value is passed in memory, add the pointer as the first integer argument. */ if (ret_in_memory) - reg_args->gpr[gprcount++] = (unsigned long) rvalue; + reg_args->gpr[gprcount++] = (long) rvalue; avn = cif->nargs; arg_types = cif->arg_types; @@ -484,33 +464,16 @@ { case X86_64_INTEGER_CLASS: case X86_64_INTEGERSI_CLASS: - /* Sign-extend integer arguments passed in general - purpose registers, to cope with the fact that - LLVM incorrectly assumes that this will be done - (the x86-64 PS ABI does not specify this). */ - switch (arg_types[i]->type) - { - case FFI_TYPE_SINT8: - *(SINT64 *)®_args->gpr[gprcount] = (SINT64) *((SINT8 *) a); - break; - case FFI_TYPE_SINT16: - *(SINT64 *)®_args->gpr[gprcount] = (SINT64) *((SINT16 *) a); - break; - case FFI_TYPE_SINT32: - *(SINT64 *)®_args->gpr[gprcount] = (SINT64) *((SINT32 *) a); - break; - default: - reg_args->gpr[gprcount] = 0; - memcpy (®_args->gpr[gprcount], a, size < 8 ? size : 8); - } + reg_args->gpr[gprcount] = 0; + memcpy (®_args->gpr[gprcount], a, size < 8 ? size : 8); gprcount++; break; case X86_64_SSE_CLASS: case X86_64_SSEDF_CLASS: - reg_args->sse[ssecount++].i64 = *(UINT64 *) a; + reg_args->sse[ssecount++] = *(UINT64 *) a; break; case X86_64_SSESF_CLASS: - reg_args->sse[ssecount++].i32 = *(UINT32 *) a; + reg_args->sse[ssecount++] = *(UINT32 *) a; break; default: abort(); @@ -535,21 +498,12 @@ { volatile unsigned short *tramp; - /* Sanity check on the cif ABI. */ - { - int abi = cif->abi; - if (UNLIKELY (! (abi > FFI_FIRST_ABI && abi < FFI_LAST_ABI))) - return FFI_BAD_ABI; - } - tramp = (volatile unsigned short *) &closure->tramp[0]; tramp[0] = 0xbb49; /* mov , %r11 */ - *((unsigned long long * volatile) &tramp[1]) - = (unsigned long) ffi_closure_unix64; + *(void * volatile *) &tramp[1] = ffi_closure_unix64; tramp[5] = 0xba49; /* mov , %r10 */ - *((unsigned long long * volatile) &tramp[6]) - = (unsigned long) codeloc; + *(void * volatile *) &tramp[6] = codeloc; /* Set the carry bit iff the function uses any sse registers. This is clc or stc, together with the first byte of the jmp. */ @@ -588,7 +542,7 @@ { /* The return value goes in memory. Arrange for the closure return value to go directly back to the original caller. */ - rvalue = (void *) (unsigned long) reg_args->gpr[gprcount++]; + rvalue = (void *) reg_args->gpr[gprcount++]; /* We don't have to do anything in asm for the return. */ ret = FFI_TYPE_VOID; } diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi/src/x86/ffitarget.h --- a/Modules/_ctypes/libffi/src/x86/ffitarget.h Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/_ctypes/libffi/src/x86/ffitarget.h Sun Jul 20 10:52:46 2014 -0400 @@ -1,7 +1,6 @@ /* -----------------------------------------------------------------*-C-*- - ffitarget.h - Copyright (c) 2012 Anthony Green - Copyright (c) 1996-2003, 2010 Red Hat, Inc. - Copyright (C) 2008 Free Software Foundation, Inc. + ffitarget.h - Copyright (c) 1996-2003, 2010 Red Hat, Inc. + Copyright (C) 2008 Free Software Foundation, Inc. Target configuration macros for x86 and x86-64. @@ -30,15 +29,8 @@ #ifndef LIBFFI_TARGET_H #define LIBFFI_TARGET_H -#ifndef LIBFFI_H -#error "Please do not include ffitarget.h directly into your source. Use ffi.h instead." -#endif - /* ---- System specific configurations ----------------------------------- */ -/* For code common to all platforms on x86 and x86_64. */ -#define X86_ANY - #if defined (X86_64) && defined (__i386__) #undef X86_64 #define X86 @@ -46,7 +38,7 @@ #ifdef X86_WIN64 #define FFI_SIZEOF_ARG 8 -#define USE_BUILTIN_FFS 0 /* not yet implemented in mingw-64 */ +#define USE_BUILTIN_FFS 0 // not yet implemented in mingw-64 #endif /* ---- Generic type definitions ----------------------------------------- */ @@ -61,16 +53,9 @@ typedef long long ffi_sarg; #endif #else -#if defined __x86_64__ && defined __ILP32__ -#define FFI_SIZEOF_ARG 8 -#define FFI_SIZEOF_JAVA_RAW 4 -typedef unsigned long long ffi_arg; -typedef long long ffi_sarg; -#else typedef unsigned long ffi_arg; typedef signed long ffi_sarg; #endif -#endif typedef enum ffi_abi { FFI_FIRST_ABI = 0, @@ -79,32 +64,28 @@ #ifdef X86_WIN32 FFI_SYSV, FFI_STDCALL, - FFI_THISCALL, - FFI_FASTCALL, - FFI_MS_CDECL, - FFI_LAST_ABI, -#ifdef _MSC_VER - FFI_DEFAULT_ABI = FFI_MS_CDECL -#else - FFI_DEFAULT_ABI = FFI_SYSV + /* TODO: Add fastcall support for the sake of completeness */ + FFI_DEFAULT_ABI = FFI_SYSV, #endif -#elif defined(X86_WIN64) +#ifdef X86_WIN64 FFI_WIN64, - FFI_LAST_ABI, - FFI_DEFAULT_ABI = FFI_WIN64 + FFI_DEFAULT_ABI = FFI_WIN64, +#else -#else /* ---- Intel x86 and AMD x86-64 - */ +#if !defined(X86_WIN32) && (defined(__i386__) || defined(__x86_64__) || defined(__i386) || defined(__amd64)) FFI_SYSV, FFI_UNIX64, /* Unix variants all use the same ABI for x86-64 */ - FFI_LAST_ABI, #if defined(__i386__) || defined(__i386) - FFI_DEFAULT_ABI = FFI_SYSV + FFI_DEFAULT_ABI = FFI_SYSV, #else - FFI_DEFAULT_ABI = FFI_UNIX64 + FFI_DEFAULT_ABI = FFI_UNIX64, #endif #endif +#endif /* X86_WIN64 */ + + FFI_LAST_ABI = FFI_DEFAULT_ABI + 1 } ffi_abi; #endif @@ -114,14 +95,13 @@ #define FFI_TYPE_SMALL_STRUCT_1B (FFI_TYPE_LAST + 1) #define FFI_TYPE_SMALL_STRUCT_2B (FFI_TYPE_LAST + 2) #define FFI_TYPE_SMALL_STRUCT_4B (FFI_TYPE_LAST + 3) -#define FFI_TYPE_MS_STRUCT (FFI_TYPE_LAST + 4) #if defined (X86_64) || (defined (__x86_64__) && defined (X86_DARWIN)) #define FFI_TRAMPOLINE_SIZE 24 #define FFI_NATIVE_RAW_API 0 #else #ifdef X86_WIN32 -#define FFI_TRAMPOLINE_SIZE 52 +#define FFI_TRAMPOLINE_SIZE 13 #else #ifdef X86_WIN64 #define FFI_TRAMPOLINE_SIZE 29 diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi/src/x86/sysv.S --- a/Modules/_ctypes/libffi/src/x86/sysv.S Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/_ctypes/libffi/src/x86/sysv.S Sun Jul 20 10:52:46 2014 -0400 @@ -1,6 +1,5 @@ /* ----------------------------------------------------------------------- - sysv.S - Copyright (c) 2013 The Written Word, Inc. - - Copyright (c) 1996,1998,2001-2003,2005,2008,2010 Red Hat, Inc. + sysv.S - Copyright (c) 1996, 1998, 2001-2003, 2005, 2008 Red Hat, Inc. X86 Foreign Function Interface @@ -49,9 +48,6 @@ movl 16(%ebp),%ecx subl %ecx,%esp - /* Align the stack pointer to 16-bytes */ - andl $0xfffffff0, %esp - movl %esp,%eax /* Place all of the ffi_prep_args in position */ @@ -182,19 +178,9 @@ leal -24(%ebp), %edx movl %edx, -12(%ebp) /* resp */ leal 8(%ebp), %edx -#ifdef __SUNPRO_C - /* The SUNPRO compiler doesn't support GCC's regparm function - attribute, so we have to pass all three arguments to - ffi_closure_SYSV_inner on the stack. */ - movl %edx, 8(%esp) /* args = __builtin_dwarf_cfa () */ - leal -12(%ebp), %edx - movl %edx, 4(%esp) /* &resp */ - movl %eax, (%esp) /* closure */ -#else movl %edx, 4(%esp) /* args = __builtin_dwarf_cfa () */ leal -12(%ebp), %edx movl %edx, (%esp) /* &resp */ -#endif #if defined HAVE_HIDDEN_VISIBILITY_ATTRIBUTE || !defined __PIC__ call ffi_closure_SYSV_inner #else @@ -339,55 +325,23 @@ .size ffi_closure_raw_SYSV, .-ffi_closure_raw_SYSV #endif -#if defined __GNUC__ -/* Only emit dwarf unwind info when building with GNU toolchain. */ - -#if defined __PIC__ -# if defined __sun__ && defined __svr4__ -/* 32-bit Solaris 2/x86 uses datarel encoding for PIC. GNU ld before 2.22 - doesn't correctly sort .eh_frame_hdr with mixed encodings, so match this. */ -# define FDE_ENCODING 0x30 /* datarel */ -# define FDE_ENCODE(X) X@GOTOFF -# else -# define FDE_ENCODING 0x1b /* pcrel sdata4 */ -# if defined HAVE_AS_X86_PCREL -# define FDE_ENCODE(X) X-. -# else -# define FDE_ENCODE(X) X@rel -# endif -# endif -#else -# define FDE_ENCODING 0 /* absolute */ -# define FDE_ENCODE(X) X -#endif - .section .eh_frame,EH_FRAME_FLAGS,@progbits .Lframe1: .long .LECIE1-.LSCIE1 /* Length of Common Information Entry */ .LSCIE1: .long 0x0 /* CIE Identifier Tag */ .byte 0x1 /* CIE Version */ -#ifdef HAVE_AS_ASCII_PSEUDO_OP #ifdef __PIC__ .ascii "zR\0" /* CIE Augmentation */ #else .ascii "\0" /* CIE Augmentation */ #endif -#elif defined HAVE_AS_STRING_PSEUDO_OP -#ifdef __PIC__ - .string "zR" /* CIE Augmentation */ -#else - .string "" /* CIE Augmentation */ -#endif -#else -#error missing .ascii/.string -#endif .byte 0x1 /* .uleb128 0x1; CIE Code Alignment Factor */ .byte 0x7c /* .sleb128 -4; CIE Data Alignment Factor */ .byte 0x8 /* CIE RA Column */ #ifdef __PIC__ .byte 0x1 /* .uleb128 0x1; Augmentation size */ - .byte FDE_ENCODING + .byte 0x1b /* FDE Encoding (pcrel sdata4) */ #endif .byte 0xc /* DW_CFA_def_cfa */ .byte 0x4 /* .uleb128 0x4 */ @@ -400,8 +354,14 @@ .long .LEFDE1-.LASFDE1 /* FDE Length */ .LASFDE1: .long .LASFDE1-.Lframe1 /* FDE CIE offset */ - .long FDE_ENCODE(.LFB1) /* FDE initial location */ - .long .LFE1-.LFB1 /* FDE address range */ +#if defined __PIC__ && defined HAVE_AS_X86_PCREL + .long .LFB1-. /* FDE initial location */ +#elif defined __PIC__ + .long .LFB1@rel +#else + .long .LFB1 +#endif + .long .LFE1-.LFB1 /* FDE address range */ #ifdef __PIC__ .byte 0x0 /* .uleb128 0x0; Augmentation size */ #endif @@ -421,8 +381,14 @@ .long .LEFDE2-.LASFDE2 /* FDE Length */ .LASFDE2: .long .LASFDE2-.Lframe1 /* FDE CIE offset */ - .long FDE_ENCODE(.LFB2) /* FDE initial location */ - .long .LFE2-.LFB2 /* FDE address range */ +#if defined __PIC__ && defined HAVE_AS_X86_PCREL + .long .LFB2-. /* FDE initial location */ +#elif defined __PIC__ + .long .LFB2@rel +#else + .long .LFB2 +#endif + .long .LFE2-.LFB2 /* FDE address range */ #ifdef __PIC__ .byte 0x0 /* .uleb128 0x0; Augmentation size */ #endif @@ -451,8 +417,14 @@ .long .LEFDE3-.LASFDE3 /* FDE Length */ .LASFDE3: .long .LASFDE3-.Lframe1 /* FDE CIE offset */ - .long FDE_ENCODE(.LFB3) /* FDE initial location */ - .long .LFE3-.LFB3 /* FDE address range */ +#if defined __PIC__ && defined HAVE_AS_X86_PCREL + .long .LFB3-. /* FDE initial location */ +#elif defined __PIC__ + .long .LFB3@rel +#else + .long .LFB3 +#endif + .long .LFE3-.LFB3 /* FDE address range */ #ifdef __PIC__ .byte 0x0 /* .uleb128 0x0; Augmentation size */ #endif @@ -474,7 +446,6 @@ .LEFDE3: #endif -#endif #endif /* ifndef __x86_64__ */ diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi/src/x86/unix64.S --- a/Modules/_ctypes/libffi/src/x86/unix64.S Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/_ctypes/libffi/src/x86/unix64.S Sun Jul 20 10:52:46 2014 -0400 @@ -1,7 +1,6 @@ /* ----------------------------------------------------------------------- - unix64.S - Copyright (c) 2013 The Written Word, Inc. - - Copyright (c) 2008 Red Hat, Inc - - Copyright (c) 2002 Bo Thorsen + unix64.S - Copyright (c) 2002 Bo Thorsen + Copyright (c) 2008 Red Hat, Inc x86-64 Foreign Function Interface @@ -325,14 +324,7 @@ .LUW9: .size ffi_closure_unix64,.-ffi_closure_unix64 -#ifdef __GNUC__ -/* Only emit DWARF unwind info when building with the GNU toolchain. */ - -#ifdef HAVE_AS_X86_64_UNWIND_SECTION_TYPE - .section .eh_frame,"a",@unwind -#else .section .eh_frame,"a",@progbits -#endif .Lframe1: .long .LECIE1-.LSCIE1 /* CIE Length */ .LSCIE1: @@ -423,8 +415,6 @@ .align 8 .LEFDE3: -#endif /* __GNUC__ */ - #endif /* __x86_64__ */ #if defined __ELF__ && defined __linux__ diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi/src/x86/win32.S --- a/Modules/_ctypes/libffi/src/x86/win32.S Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/_ctypes/libffi/src/x86/win32.S Sun Jul 20 10:52:46 2014 -0400 @@ -45,7 +45,6 @@ ffi_call_win32 PROC NEAR, ffi_prep_args : NEAR PTR DWORD, ecif : NEAR PTR DWORD, - cif_abi : DWORD, cif_bytes : DWORD, cif_flags : DWORD, rvalue : NEAR PTR DWORD, @@ -65,19 +64,6 @@ ;; Return stack to previous state and call the function add esp, 8 - ;; Handle thiscall and fastcall - cmp cif_abi, 3 ;; FFI_THISCALL - jz do_thiscall - cmp cif_abi, 4 ;; FFI_FASTCALL - jnz do_stdcall - mov ecx, DWORD PTR [esp] - mov edx, DWORD PTR [esp+4] - add esp, 8 - jmp do_stdcall -do_thiscall: - mov ecx, DWORD PTR [esp] - add esp, 4 -do_stdcall: call fn ;; cdecl: we restore esp in the epilogue, so there's no need to @@ -108,37 +94,31 @@ dd offset ca_retfloat ;; FFI_TYPE_FLOAT dd offset ca_retdouble ;; FFI_TYPE_DOUBLE dd offset ca_retlongdouble ;; FFI_TYPE_LONGDOUBLE - dd offset ca_retuint8 ;; FFI_TYPE_UINT8 - dd offset ca_retsint8 ;; FFI_TYPE_SINT8 - dd offset ca_retuint16 ;; FFI_TYPE_UINT16 - dd offset ca_retsint16 ;; FFI_TYPE_SINT16 + dd offset ca_retint8 ;; FFI_TYPE_UINT8 + dd offset ca_retint8 ;; FFI_TYPE_SINT8 + dd offset ca_retint16 ;; FFI_TYPE_UINT16 + dd offset ca_retint16 ;; FFI_TYPE_SINT16 dd offset ca_retint ;; FFI_TYPE_UINT32 dd offset ca_retint ;; FFI_TYPE_SINT32 dd offset ca_retint64 ;; FFI_TYPE_UINT64 dd offset ca_retint64 ;; FFI_TYPE_SINT64 dd offset ca_epilogue ;; FFI_TYPE_STRUCT dd offset ca_retint ;; FFI_TYPE_POINTER - dd offset ca_retstruct1b ;; FFI_TYPE_SMALL_STRUCT_1B - dd offset ca_retstruct2b ;; FFI_TYPE_SMALL_STRUCT_2B + dd offset ca_retint8 ;; FFI_TYPE_SMALL_STRUCT_1B + dd offset ca_retint16 ;; FFI_TYPE_SMALL_STRUCT_2B dd offset ca_retint ;; FFI_TYPE_SMALL_STRUCT_4B - dd offset ca_epilogue ;; FFI_TYPE_MS_STRUCT - /* Sign/zero extend as appropriate. */ -ca_retuint8: - movzx eax, al - jmp ca_retint +ca_retint8: + ;; Load %ecx with the pointer to storage for the return value + mov ecx, rvalue + mov [ecx + 0], al + jmp ca_epilogue -ca_retsint8: - movsx eax, al - jmp ca_retint - -ca_retuint16: - movzx eax, ax - jmp ca_retint - -ca_retsint16: - movsx eax, ax - jmp ca_retint +ca_retint16: + ;; Load %ecx with the pointer to storage for the return value + mov ecx, rvalue + mov [ecx + 0], ax + jmp ca_epilogue ca_retint: ;; Load %ecx with the pointer to storage for the return value @@ -171,31 +151,11 @@ fstp TBYTE PTR [ecx] jmp ca_epilogue -ca_retstruct1b: - ;; Load %ecx with the pointer to storage for the return value - mov ecx, rvalue - mov [ecx + 0], al - jmp ca_epilogue - -ca_retstruct2b: - ;; Load %ecx with the pointer to storage for the return value - mov ecx, rvalue - mov [ecx + 0], ax - jmp ca_epilogue - ca_epilogue: ;; Epilogue code is autogenerated. ret ffi_call_win32 ENDP -ffi_closure_THISCALL PROC NEAR FORCEFRAME - sub esp, 40 - lea edx, [ebp -24] - mov [ebp - 12], edx /* resp */ - lea edx, [ebp + 12] /* account for stub return address on stack */ - jmp stub -ffi_closure_THISCALL ENDP - ffi_closure_SYSV PROC NEAR FORCEFRAME ;; the ffi_closure ctx is passed in eax by the trampoline. @@ -203,7 +163,6 @@ lea edx, [ebp - 24] mov [ebp - 12], edx ;; resp lea edx, [ebp + 8] -stub:: mov [esp + 8], edx ;; args lea edx, [ebp - 12] mov [esp + 4], edx ;; &resp @@ -220,35 +179,26 @@ dd offset cs_retfloat ;; FFI_TYPE_FLOAT dd offset cs_retdouble ;; FFI_TYPE_DOUBLE dd offset cs_retlongdouble ;; FFI_TYPE_LONGDOUBLE - dd offset cs_retuint8 ;; FFI_TYPE_UINT8 - dd offset cs_retsint8 ;; FFI_TYPE_SINT8 - dd offset cs_retuint16 ;; FFI_TYPE_UINT16 - dd offset cs_retsint16 ;; FFI_TYPE_SINT16 + dd offset cs_retint8 ;; FFI_TYPE_UINT8 + dd offset cs_retint8 ;; FFI_TYPE_SINT8 + dd offset cs_retint16 ;; FFI_TYPE_UINT16 + dd offset cs_retint16 ;; FFI_TYPE_SINT16 dd offset cs_retint ;; FFI_TYPE_UINT32 dd offset cs_retint ;; FFI_TYPE_SINT32 dd offset cs_retint64 ;; FFI_TYPE_UINT64 dd offset cs_retint64 ;; FFI_TYPE_SINT64 dd offset cs_retstruct ;; FFI_TYPE_STRUCT dd offset cs_retint ;; FFI_TYPE_POINTER - dd offset cs_retsint8 ;; FFI_TYPE_SMALL_STRUCT_1B - dd offset cs_retsint16 ;; FFI_TYPE_SMALL_STRUCT_2B + dd offset cs_retint8 ;; FFI_TYPE_SMALL_STRUCT_1B + dd offset cs_retint16 ;; FFI_TYPE_SMALL_STRUCT_2B dd offset cs_retint ;; FFI_TYPE_SMALL_STRUCT_4B - dd offset cs_retmsstruct ;; FFI_TYPE_MS_STRUCT -cs_retuint8: - movzx eax, BYTE PTR [ecx] +cs_retint8: + mov al, [ecx] jmp cs_epilogue -cs_retsint8: - movsx eax, BYTE PTR [ecx] - jmp cs_epilogue - -cs_retuint16: - movzx eax, WORD PTR [ecx] - jmp cs_epilogue - -cs_retsint16: - movsx eax, WORD PTR [ecx] +cs_retint16: + mov ax, [ecx] jmp cs_epilogue cs_retint: @@ -277,12 +227,6 @@ ;; Epilogue code is autogenerated. ret 4 -cs_retmsstruct: - ;; Caller expects us to return a pointer to the real return value. - mov eax, ecx - ;; Caller doesn't expects us to pop struct return value pointer hidden arg. - jmp cs_epilogue - cs_epilogue: ;; Epilogue code is autogenerated. ret @@ -295,16 +239,7 @@ #define RAW_CLOSURE_USER_DATA_OFFSET (RAW_CLOSURE_FUN_OFFSET + 4) #define CIF_FLAGS_OFFSET 20 -ffi_closure_raw_THISCALL PROC NEAR USES esi FORCEFRAME - sub esp, 36 - mov esi, [eax + RAW_CLOSURE_CIF_OFFSET] ;; closure->cif - mov edx, [eax + RAW_CLOSURE_USER_DATA_OFFSET] ;; closure->user_data - mov [esp + 12], edx - lea edx, [ebp + 12] - jmp stubraw -ffi_closure_raw_THISCALL ENDP - -ffi_closure_raw_SYSV PROC NEAR USES esi FORCEFRAME +ffi_closure_raw_SYSV PROC NEAR USES esi ;; the ffi_closure ctx is passed in eax by the trampoline. sub esp, 40 @@ -312,7 +247,6 @@ mov edx, [eax + RAW_CLOSURE_USER_DATA_OFFSET] ;; closure->user_data mov [esp + 12], edx ;; user_data lea edx, [ebp + 8] -stubraw:: mov [esp + 8], edx ;; raw_args lea edx, [ebp - 24] mov [esp + 4], edx ;; &res @@ -330,35 +264,26 @@ dd offset cr_retfloat ;; FFI_TYPE_FLOAT dd offset cr_retdouble ;; FFI_TYPE_DOUBLE dd offset cr_retlongdouble ;; FFI_TYPE_LONGDOUBLE - dd offset cr_retuint8 ;; FFI_TYPE_UINT8 - dd offset cr_retsint8 ;; FFI_TYPE_SINT8 - dd offset cr_retuint16 ;; FFI_TYPE_UINT16 - dd offset cr_retsint16 ;; FFI_TYPE_SINT16 + dd offset cr_retint8 ;; FFI_TYPE_UINT8 + dd offset cr_retint8 ;; FFI_TYPE_SINT8 + dd offset cr_retint16 ;; FFI_TYPE_UINT16 + dd offset cr_retint16 ;; FFI_TYPE_SINT16 dd offset cr_retint ;; FFI_TYPE_UINT32 dd offset cr_retint ;; FFI_TYPE_SINT32 dd offset cr_retint64 ;; FFI_TYPE_UINT64 dd offset cr_retint64 ;; FFI_TYPE_SINT64 dd offset cr_epilogue ;; FFI_TYPE_STRUCT dd offset cr_retint ;; FFI_TYPE_POINTER - dd offset cr_retsint8 ;; FFI_TYPE_SMALL_STRUCT_1B - dd offset cr_retsint16 ;; FFI_TYPE_SMALL_STRUCT_2B + dd offset cr_retint8 ;; FFI_TYPE_SMALL_STRUCT_1B + dd offset cr_retint16 ;; FFI_TYPE_SMALL_STRUCT_2B dd offset cr_retint ;; FFI_TYPE_SMALL_STRUCT_4B - dd offset cr_epilogue ;; FFI_TYPE_MS_STRUCT -cr_retuint8: - movzx eax, BYTE PTR [ecx] +cr_retint8: + mov al, [ecx] jmp cr_epilogue -cr_retsint8: - movsx eax, BYTE PTR [ecx] - jmp cr_epilogue - -cr_retuint16: - movzx eax, WORD PTR [ecx] - jmp cr_epilogue - -cr_retsint16: - movsx eax, WORD PTR [ecx] +cr_retint16: + mov ax, [ecx] jmp cr_epilogue cr_retint: @@ -412,34 +337,26 @@ dd offset cd_retfloat ;; FFI_TYPE_FLOAT dd offset cd_retdouble ;; FFI_TYPE_DOUBLE dd offset cd_retlongdouble ;; FFI_TYPE_LONGDOUBLE - dd offset cd_retuint8 ;; FFI_TYPE_UINT8 - dd offset cd_retsint8 ;; FFI_TYPE_SINT8 - dd offset cd_retuint16 ;; FFI_TYPE_UINT16 - dd offset cd_retsint16 ;; FFI_TYPE_SINT16 + dd offset cd_retint8 ;; FFI_TYPE_UINT8 + dd offset cd_retint8 ;; FFI_TYPE_SINT8 + dd offset cd_retint16 ;; FFI_TYPE_UINT16 + dd offset cd_retint16 ;; FFI_TYPE_SINT16 dd offset cd_retint ;; FFI_TYPE_UINT32 dd offset cd_retint ;; FFI_TYPE_SINT32 dd offset cd_retint64 ;; FFI_TYPE_UINT64 dd offset cd_retint64 ;; FFI_TYPE_SINT64 dd offset cd_epilogue ;; FFI_TYPE_STRUCT dd offset cd_retint ;; FFI_TYPE_POINTER - dd offset cd_retsint8 ;; FFI_TYPE_SMALL_STRUCT_1B - dd offset cd_retsint16 ;; FFI_TYPE_SMALL_STRUCT_2B + dd offset cd_retint8 ;; FFI_TYPE_SMALL_STRUCT_1B + dd offset cd_retint16 ;; FFI_TYPE_SMALL_STRUCT_2B dd offset cd_retint ;; FFI_TYPE_SMALL_STRUCT_4B -cd_retuint8: - movzx eax, BYTE PTR [ecx] +cd_retint8: + mov al, [ecx] jmp cd_epilogue -cd_retsint8: - movsx eax, BYTE PTR [ecx] - jmp cd_epilogue - -cd_retuint16: - movzx eax, WORD PTR [ecx] - jmp cd_epilogue - -cd_retsint16: - movsx eax, WORD PTR [ecx] +cd_retint16: + mov ax, [ecx] jmp cd_epilogue cd_retint: @@ -478,9 +395,7 @@ # This assumes we are using gas. .balign 16 .globl _ffi_call_win32 -#ifndef __OS2__ .def _ffi_call_win32; .scl 2; .type 32; .endef -#endif _ffi_call_win32: .LFB1: pushl %ebp @@ -488,7 +403,7 @@ movl %esp,%ebp .LCFI1: # Make room for all of the new args. - movl 20(%ebp),%ecx + movl 16(%ebp),%ecx subl %ecx,%esp movl %esp,%eax @@ -500,34 +415,19 @@ # Return stack to previous state and call the function addl $8,%esp - - # Handle fastcall and thiscall - cmpl $3, 16(%ebp) # FFI_THISCALL - jz .do_thiscall - cmpl $4, 16(%ebp) # FFI_FASTCALL - jnz .do_fncall - movl (%esp), %ecx - movl 4(%esp), %edx - addl $8, %esp - jmp .do_fncall -.do_thiscall: - movl (%esp), %ecx - addl $4, %esp - -.do_fncall: - + # FIXME: Align the stack to a 128-bit boundary to avoid # potential performance hits. - call *32(%ebp) + call *28(%ebp) # stdcall functions pop arguments off the stack themselves # Load %ecx with the return type code - movl 24(%ebp),%ecx + movl 20(%ebp),%ecx # If the return value pointer is NULL, assume no return value. - cmpl $0,28(%ebp) + cmpl $0,24(%ebp) jne 0f # Even if there is no space for the return value, we are @@ -560,7 +460,6 @@ .long .Lretstruct1b /* FFI_TYPE_SMALL_STRUCT_1B */ .long .Lretstruct2b /* FFI_TYPE_SMALL_STRUCT_2B */ .long .Lretstruct4b /* FFI_TYPE_SMALL_STRUCT_4B */ - .long .Lretstruct /* FFI_TYPE_MS_STRUCT */ 1: add %ecx, %ecx add %ecx, %ecx @@ -587,50 +486,50 @@ .Lretint: # Load %ecx with the pointer to storage for the return value - movl 28(%ebp),%ecx + movl 24(%ebp),%ecx movl %eax,0(%ecx) jmp .Lepilogue .Lretfloat: # Load %ecx with the pointer to storage for the return value - movl 28(%ebp),%ecx + movl 24(%ebp),%ecx fstps (%ecx) jmp .Lepilogue .Lretdouble: # Load %ecx with the pointer to storage for the return value - movl 28(%ebp),%ecx + movl 24(%ebp),%ecx fstpl (%ecx) jmp .Lepilogue .Lretlongdouble: # Load %ecx with the pointer to storage for the return value - movl 28(%ebp),%ecx + movl 24(%ebp),%ecx fstpt (%ecx) jmp .Lepilogue .Lretint64: # Load %ecx with the pointer to storage for the return value - movl 28(%ebp),%ecx + movl 24(%ebp),%ecx movl %eax,0(%ecx) movl %edx,4(%ecx) jmp .Lepilogue .Lretstruct1b: # Load %ecx with the pointer to storage for the return value - movl 28(%ebp),%ecx + movl 24(%ebp),%ecx movb %al,0(%ecx) jmp .Lepilogue .Lretstruct2b: # Load %ecx with the pointer to storage for the return value - movl 28(%ebp),%ecx + movl 24(%ebp),%ecx movw %ax,0(%ecx) jmp .Lepilogue .Lretstruct4b: # Load %ecx with the pointer to storage for the return value - movl 28(%ebp),%ecx + movl 24(%ebp),%ecx movl %eax,0(%ecx) jmp .Lepilogue @@ -643,27 +542,12 @@ popl %ebp ret .ffi_call_win32_end: - .balign 16 - .globl _ffi_closure_THISCALL -#ifndef __OS2__ - .def _ffi_closure_THISCALL; .scl 2; .type 32; .endef -#endif -_ffi_closure_THISCALL: - pushl %ebp - movl %esp, %ebp - subl $40, %esp - leal -24(%ebp), %edx - movl %edx, -12(%ebp) /* resp */ - leal 12(%ebp), %edx /* account for stub return address on stack */ - jmp .stub .LFE1: # This assumes we are using gas. .balign 16 .globl _ffi_closure_SYSV -#ifndef __OS2__ .def _ffi_closure_SYSV; .scl 2; .type 32; .endef -#endif _ffi_closure_SYSV: .LFB3: pushl %ebp @@ -674,7 +558,6 @@ leal -24(%ebp), %edx movl %edx, -12(%ebp) /* resp */ leal 8(%ebp), %edx -.stub: movl %edx, 4(%esp) /* args = __builtin_dwarf_cfa () */ leal -12(%ebp), %edx movl %edx, (%esp) /* &resp */ @@ -703,7 +586,6 @@ .long .Lcls_retstruct1 /* FFI_TYPE_SMALL_STRUCT_1B */ .long .Lcls_retstruct2 /* FFI_TYPE_SMALL_STRUCT_2B */ .long .Lcls_retstruct4 /* FFI_TYPE_SMALL_STRUCT_4B */ - .long .Lcls_retmsstruct /* FFI_TYPE_MS_STRUCT */ 1: add %eax, %eax @@ -768,12 +650,6 @@ popl %ebp ret $0x4 -.Lcls_retmsstruct: - # Caller expects us to return a pointer to the real return value. - mov %ecx, %eax - # Caller doesn't expects us to pop struct return value pointer hidden arg. - jmp .Lcls_epilogue - .Lcls_noretval: .Lcls_epilogue: movl %ebp, %esp @@ -788,27 +664,11 @@ #define RAW_CLOSURE_FUN_OFFSET (RAW_CLOSURE_CIF_OFFSET + 4) #define RAW_CLOSURE_USER_DATA_OFFSET (RAW_CLOSURE_FUN_OFFSET + 4) #define CIF_FLAGS_OFFSET 20 - .balign 16 - .globl _ffi_closure_raw_THISCALL -#ifndef __OS2__ - .def _ffi_closure_raw_THISCALL; .scl 2; .type 32; .endef -#endif -_ffi_closure_raw_THISCALL: - pushl %ebp - movl %esp, %ebp - pushl %esi - subl $36, %esp - movl RAW_CLOSURE_CIF_OFFSET(%eax), %esi /* closure->cif */ - movl RAW_CLOSURE_USER_DATA_OFFSET(%eax), %edx /* closure->user_data */ - movl %edx, 12(%esp) /* user_data */ - leal 12(%ebp), %edx /* __builtin_dwarf_cfa () */ - jmp .stubraw + # This assumes we are using gas. .balign 16 .globl _ffi_closure_raw_SYSV -#ifndef __OS2__ .def _ffi_closure_raw_SYSV; .scl 2; .type 32; .endef -#endif _ffi_closure_raw_SYSV: .LFB4: pushl %ebp @@ -822,7 +682,6 @@ movl RAW_CLOSURE_USER_DATA_OFFSET(%eax), %edx /* closure->user_data */ movl %edx, 12(%esp) /* user_data */ leal 8(%ebp), %edx /* __builtin_dwarf_cfa () */ -.stubraw: movl %edx, 8(%esp) /* raw_args */ leal -24(%ebp), %edx movl %edx, 4(%esp) /* &res */ @@ -851,7 +710,6 @@ .long .Lrcls_retstruct1 /* FFI_TYPE_SMALL_STRUCT_1B */ .long .Lrcls_retstruct2 /* FFI_TYPE_SMALL_STRUCT_2B */ .long .Lrcls_retstruct4 /* FFI_TYPE_SMALL_STRUCT_4B */ - .long .Lrcls_retstruct /* FFI_TYPE_MS_STRUCT */ 1: add %eax, %eax add %eax, %eax @@ -926,9 +784,7 @@ # This assumes we are using gas. .balign 16 .globl _ffi_closure_STDCALL -#ifndef __OS2__ .def _ffi_closure_STDCALL; .scl 2; .type 32; .endef -#endif _ffi_closure_STDCALL: .LFB5: pushl %ebp @@ -1034,9 +890,7 @@ .ffi_closure_STDCALL_end: .LFE5: -#ifndef __OS2__ .section .eh_frame,"w" -#endif .Lframe1: .LSCIE1: .long .LECIE1-.LASCIE1 /* Length of Common Information Entry */ diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi/src/x86/win64.S --- a/Modules/_ctypes/libffi/src/x86/win64.S Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/_ctypes/libffi/src/x86/win64.S Sun Jul 20 10:52:46 2014 -0400 @@ -232,18 +232,10 @@ ffi_call_win64 ENDP _TEXT ENDS END - -#else - -#ifdef SYMBOL_UNDERSCORE -#define SYMBOL_NAME(name) _##name -#else -#define SYMBOL_NAME(name) name -#endif - +#else .text -.extern SYMBOL_NAME(ffi_closure_win64_inner) +.extern _ffi_closure_win64_inner # ffi_closure_win64 will be called with these registers set: # rax points to 'closure' @@ -254,8 +246,8 @@ # call ffi_closure_win64_inner for the actual work, then return the result. # .balign 16 - .globl SYMBOL_NAME(ffi_closure_win64) -SYMBOL_NAME(ffi_closure_win64): + .globl _ffi_closure_win64 +_ffi_closure_win64: # copy register arguments onto stack test $1,%r11 jne .Lfirst_is_float @@ -295,7 +287,7 @@ mov %rax, %rcx # context is first parameter mov %rsp, %rdx # stack is second parameter add $48, %rdx # point to start of arguments - mov $SYMBOL_NAME(ffi_closure_win64_inner), %rax + mov $_ffi_closure_win64_inner, %rax callq *%rax # call the real closure function add $40, %rsp movq %rax, %xmm0 # If the closure returned a float, @@ -304,8 +296,8 @@ .ffi_closure_win64_end: .balign 16 - .globl SYMBOL_NAME(ffi_call_win64) -SYMBOL_NAME(ffi_call_win64): + .globl _ffi_call_win64 +_ffi_call_win64: # copy registers onto stack mov %r9,32(%rsp) mov %r8,24(%rsp) diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi/src/xtensa/ffi.c --- a/Modules/_ctypes/libffi/src/xtensa/ffi.c Sat Jul 19 16:34:33 2014 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,298 +0,0 @@ -/* ----------------------------------------------------------------------- - ffi.c - Copyright (c) 2013 Tensilica, Inc. - - XTENSA Foreign Function Interface - - Permission is hereby granted, free of charge, to any person obtaining - a copy of this software and associated documentation files (the - ``Software''), to deal in the Software without restriction, including - without limitation the rights to use, copy, modify, merge, publish, - distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to - the following conditions: - - The above copyright notice and this permission notice shall be included - in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT - HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, - WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - DEALINGS IN THE SOFTWARE. - ----------------------------------------------------------------------- */ - -#include -#include - -/* - |----------------------------------------| - | | - on entry to ffi_call ----> |----------------------------------------| - | caller stack frame for registers a0-a3 | - |----------------------------------------| - | | - | additional arguments | - entry of the function ---> |----------------------------------------| - | copy of function arguments a2-a7 | - | - - - - - - - - - - - - - | - | | - - The area below the entry line becomes the new stack frame for the function. - -*/ - - -#define FFI_TYPE_STRUCT_REGS FFI_TYPE_LAST - - -extern void ffi_call_SYSV(void *rvalue, unsigned rsize, unsigned flags, - void(*fn)(void), unsigned nbytes, extended_cif*); -extern void ffi_closure_SYSV(void) FFI_HIDDEN; - -ffi_status ffi_prep_cif_machdep(ffi_cif *cif) -{ - switch(cif->rtype->type) { - case FFI_TYPE_SINT8: - case FFI_TYPE_UINT8: - case FFI_TYPE_SINT16: - case FFI_TYPE_UINT16: - cif->flags = cif->rtype->type; - break; - case FFI_TYPE_VOID: - case FFI_TYPE_FLOAT: - cif->flags = FFI_TYPE_UINT32; - break; - case FFI_TYPE_DOUBLE: - case FFI_TYPE_UINT64: - case FFI_TYPE_SINT64: - cif->flags = FFI_TYPE_UINT64; // cif->rtype->type; - break; - case FFI_TYPE_STRUCT: - cif->flags = FFI_TYPE_STRUCT; //_REGS; - /* Up to 16 bytes are returned in registers */ - if (cif->rtype->size > 4 * 4) { - /* returned structure is referenced by a register; use 8 bytes - (including 4 bytes for potential additional alignment) */ - cif->flags = FFI_TYPE_STRUCT; - cif->bytes += 8; - } - break; - - default: - cif->flags = FFI_TYPE_UINT32; - break; - } - - /* Round the stack up to a full 4 register frame, just in case - (we use this size in movsp). This way, it's also a multiple of - 8 bytes for 64-bit arguments. */ - cif->bytes = ALIGN(cif->bytes, 16); - - return FFI_OK; -} - -void ffi_prep_args(extended_cif *ecif, unsigned char* stack) -{ - unsigned int i; - unsigned long *addr; - ffi_type **ptr; - - union { - void **v; - char **c; - signed char **sc; - unsigned char **uc; - signed short **ss; - unsigned short **us; - unsigned int **i; - long long **ll; - float **f; - double **d; - } p_argv; - - /* Verify that everything is aligned up properly */ - FFI_ASSERT (((unsigned long) stack & 0x7) == 0); - - p_argv.v = ecif->avalue; - addr = (unsigned long*)stack; - - /* structures with a size greater than 16 bytes are passed in memory */ - if (ecif->cif->rtype->type == FFI_TYPE_STRUCT && ecif->cif->rtype->size > 16) - { - *addr++ = (unsigned long)ecif->rvalue; - } - - for (i = ecif->cif->nargs, ptr = ecif->cif->arg_types; - i > 0; - i--, ptr++, p_argv.v++) - { - switch ((*ptr)->type) - { - case FFI_TYPE_SINT8: - *addr++ = **p_argv.sc; - break; - case FFI_TYPE_UINT8: - *addr++ = **p_argv.uc; - break; - case FFI_TYPE_SINT16: - *addr++ = **p_argv.ss; - break; - case FFI_TYPE_UINT16: - *addr++ = **p_argv.us; - break; - case FFI_TYPE_FLOAT: - case FFI_TYPE_INT: - case FFI_TYPE_UINT32: - case FFI_TYPE_SINT32: - case FFI_TYPE_POINTER: - *addr++ = **p_argv.i; - break; - case FFI_TYPE_DOUBLE: - case FFI_TYPE_UINT64: - case FFI_TYPE_SINT64: - if (((unsigned long)addr & 4) != 0) - addr++; - *(unsigned long long*)addr = **p_argv.ll; - addr += sizeof(unsigned long long) / sizeof (addr); - break; - - case FFI_TYPE_STRUCT: - { - unsigned long offs; - unsigned long size; - - if (((unsigned long)addr & 4) != 0 && (*ptr)->alignment > 4) - addr++; - - offs = (unsigned long) addr - (unsigned long) stack; - size = (*ptr)->size; - - /* Entire structure must fit the argument registers or referenced */ - if (offs < FFI_REGISTER_NARGS * 4 - && offs + size > FFI_REGISTER_NARGS * 4) - addr = (unsigned long*) (stack + FFI_REGISTER_NARGS * 4); - - memcpy((char*) addr, *p_argv.c, size); - addr += (size + 3) / 4; - break; - } - - default: - FFI_ASSERT(0); - } - } -} - - -void ffi_call(ffi_cif* cif, void(*fn)(void), void *rvalue, void **avalue) -{ - extended_cif ecif; - unsigned long rsize = cif->rtype->size; - int flags = cif->flags; - void *alloc = NULL; - - ecif.cif = cif; - ecif.avalue = avalue; - - /* Note that for structures that are returned in registers (size <= 16 bytes) - we allocate a temporary buffer and use memcpy to copy it to the final - destination. The reason is that the target address might be misaligned or - the length not a multiple of 4 bytes. Handling all those cases would be - very complex. */ - - if (flags == FFI_TYPE_STRUCT && (rsize <= 16 || rvalue == NULL)) - { - alloc = alloca(ALIGN(rsize, 4)); - ecif.rvalue = alloc; - } - else - { - ecif.rvalue = rvalue; - } - - if (cif->abi != FFI_SYSV) - FFI_ASSERT(0); - - ffi_call_SYSV (ecif.rvalue, rsize, cif->flags, fn, cif->bytes, &ecif); - - if (alloc != NULL && rvalue != NULL) - memcpy(rvalue, alloc, rsize); -} - -extern void ffi_trampoline(); -extern void ffi_cacheflush(void* start, void* end); - -ffi_status -ffi_prep_closure_loc (ffi_closure* closure, - ffi_cif* cif, - void (*fun)(ffi_cif*, void*, void**, void*), - void *user_data, - void *codeloc) -{ - /* copye trampoline to stack and patch 'ffi_closure_SYSV' pointer */ - memcpy(closure->tramp, ffi_trampoline, FFI_TRAMPOLINE_SIZE); - *(unsigned int*)(&closure->tramp[8]) = (unsigned int)ffi_closure_SYSV; - - // Do we have this function? - // __builtin___clear_cache(closer->tramp, closer->tramp + FFI_TRAMPOLINE_SIZE) - ffi_cacheflush(closure->tramp, closure->tramp + FFI_TRAMPOLINE_SIZE); - - closure->cif = cif; - closure->fun = fun; - closure->user_data = user_data; - return FFI_OK; -} - - -long FFI_HIDDEN -ffi_closure_SYSV_inner(ffi_closure *closure, void **values, void *rvalue) -{ - ffi_cif *cif; - ffi_type **arg_types; - void **avalue; - int i, areg; - - cif = closure->cif; - if (cif->abi != FFI_SYSV) - return FFI_BAD_ABI; - - areg = 0; - - int rtype = cif->rtype->type; - if (rtype == FFI_TYPE_STRUCT && cif->rtype->size > 4 * 4) - { - rvalue = *values; - areg++; - } - - cif = closure->cif; - arg_types = cif->arg_types; - avalue = alloca(cif->nargs * sizeof(void *)); - - for (i = 0; i < cif->nargs; i++) - { - if (arg_types[i]->alignment == 8 && (areg & 1) != 0) - areg++; - - // skip the entry 16,a1 framework, add 16 bytes (4 registers) - if (areg == FFI_REGISTER_NARGS) - areg += 4; - - if (arg_types[i]->type == FFI_TYPE_STRUCT) - { - int numregs = ((arg_types[i]->size + 3) & ~3) / 4; - if (areg < FFI_REGISTER_NARGS && areg + numregs > FFI_REGISTER_NARGS) - areg = FFI_REGISTER_NARGS + 4; - } - - avalue[i] = &values[areg]; - areg += (arg_types[i]->size + 3) / 4; - } - - (closure->fun)(cif, rvalue, avalue, closure->user_data); - - return rtype; -} diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi/src/xtensa/ffitarget.h --- a/Modules/_ctypes/libffi/src/xtensa/ffitarget.h Sat Jul 19 16:34:33 2014 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,53 +0,0 @@ -/* -----------------------------------------------------------------*-C-*- - ffitarget.h - Copyright (c) 2013 Tensilica, Inc. - Target configuration macros for XTENSA. - - Permission is hereby granted, free of charge, to any person obtaining - a copy of this software and associated documentation files (the - ``Software''), to deal in the Software without restriction, including - without limitation the rights to use, copy, modify, merge, publish, - distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to - the following conditions: - - The above copyright notice and this permission notice shall be included - in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT - HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, - WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - DEALINGS IN THE SOFTWARE. - ----------------------------------------------------------------------- */ - -#ifndef LIBFFI_TARGET_H -#define LIBFFI_TARGET_H - -#ifndef LIBFFI_H -#error "Please do not include ffitarget.h directly into your source. Use ffi.h instead." -#endif - -#ifndef LIBFFI_ASM -typedef unsigned long ffi_arg; -typedef signed long ffi_sarg; - -typedef enum ffi_abi { - FFI_FIRST_ABI = 0, - FFI_SYSV, - FFI_LAST_ABI, - FFI_DEFAULT_ABI = FFI_SYSV -} ffi_abi; -#endif - -#define FFI_REGISTER_NARGS 6 - -/* ---- Definitions for closures ----------------------------------------- */ - -#define FFI_CLOSURES 1 -#define FFI_NATIVE_RAW_API 0 -#define FFI_TRAMPOLINE_SIZE 24 - -#endif diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi/src/xtensa/sysv.S --- a/Modules/_ctypes/libffi/src/xtensa/sysv.S Sat Jul 19 16:34:33 2014 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,253 +0,0 @@ -/* ----------------------------------------------------------------------- - sysv.S - Copyright (c) 2013 Tensilica, Inc. - - XTENSA Foreign Function Interface - - Permission is hereby granted, free of charge, to any person obtaining - a copy of this software and associated documentation files (the - ``Software''), to deal in the Software without restriction, including - without limitation the rights to use, copy, modify, merge, publish, - distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to - the following conditions: - - The above copyright notice and this permission notice shall be included - in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT - HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, - WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - DEALINGS IN THE SOFTWARE. - ----------------------------------------------------------------------- */ - -#define LIBFFI_ASM -#include -#include - -#define ENTRY(name) .text; .globl name; .type name,@function; .align 4; name: -#define END(name) .size name , . - name - -/* Assert that the table below is in sync with ffi.h. */ - -#if FFI_TYPE_UINT8 != 5 \ - || FFI_TYPE_SINT8 != 6 \ - || FFI_TYPE_UINT16 != 7 \ - || FFI_TYPE_SINT16 != 8 \ - || FFI_TYPE_UINT32 != 9 \ - || FFI_TYPE_SINT32 != 10 \ - || FFI_TYPE_UINT64 != 11 -#error "xtensa/sysv.S out of sync with ffi.h" -#endif - - -/* ffi_call_SYSV (rvalue, rbytes, flags, (*fnaddr)(), bytes, ecif) - void *rvalue; a2 - unsigned long rbytes; a3 - unsigned flags; a4 - void (*fnaddr)(); a5 - unsigned long bytes; a6 - extended_cif* ecif) a7 -*/ - -ENTRY(ffi_call_SYSV) - - entry a1, 32 # 32 byte frame for using call8 below - - mov a10, a7 # a10(->arg0): ecif - sub a11, a1, a6 # a11(->arg1): stack pointer - mov a7, a1 # fp - movsp a1, a11 # set new sp = old_sp - bytes - - movi a8, ffi_prep_args - callx8 a8 # ffi_prep_args(ecif, stack) - - # prepare to move stack pointer back up to 6 arguments - # note that 'bytes' is already aligned - - movi a10, 6*4 - sub a11, a6, a10 - movgez a6, a10, a11 - add a6, a1, a6 - - - # we can pass up to 6 arguments in registers - # for simplicity, just load 6 arguments - # (the stack size is at least 32 bytes, so no risk to cross boundaries) - - l32i a10, a1, 0 - l32i a11, a1, 4 - l32i a12, a1, 8 - l32i a13, a1, 12 - l32i a14, a1, 16 - l32i a15, a1, 20 - - # move stack pointer - - movsp a1, a6 - - callx8 a5 # (*fn)(args...) - - # Handle return value(s) - - beqz a2, .Lexit - - movi a5, FFI_TYPE_STRUCT - bne a4, a5, .Lstore - movi a5, 16 - blt a5, a3, .Lexit - - s32i a10, a2, 0 - blti a3, 5, .Lexit - addi a3, a3, -1 - s32i a11, a2, 4 - blti a3, 8, .Lexit - s32i a12, a2, 8 - blti a3, 12, .Lexit - s32i a13, a2, 12 - -.Lexit: retw - -.Lstore: - addi a4, a4, -FFI_TYPE_UINT8 - bgei a4, 7, .Lexit # should never happen - movi a6, store_calls - add a4, a4, a4 - addx4 a6, a4, a6 # store_table + idx * 8 - jx a6 - - .align 8 -store_calls: - # UINT8 - s8i a10, a2, 0 - retw - - # SINT8 - .align 8 - s8i a10, a2, 0 - retw - - # UINT16 - .align 8 - s16i a10, a2, 0 - retw - - # SINT16 - .align 8 - s16i a10, a2, 0 - retw - - # UINT32 - .align 8 - s32i a10, a2, 0 - retw - - # SINT32 - .align 8 - s32i a10, a2, 0 - retw - - # UINT64 - .align 8 - s32i a10, a2, 0 - s32i a11, a2, 4 - retw - -END(ffi_call_SYSV) - - -/* - * void ffi_cacheflush (unsigned long start, unsigned long end) - */ - -#define EXTRA_ARGS_SIZE 24 - -ENTRY(ffi_cacheflush) - - entry a1, 16 - -1: dhwbi a2, 0 - ihi a2, 0 - addi a2, a2, 4 - blt a2, a3, 1b - - retw - -END(ffi_cacheflush) - -/* ffi_trampoline is copied to the stack */ - -ENTRY(ffi_trampoline) - - entry a1, 16 + (FFI_REGISTER_NARGS * 4) + (4 * 4) # [ 0] - j 2f # [ 3] - .align 4 # [ 6] -1: .long 0 # [ 8] -2: l32r a15, 1b # [12] - _mov a14, a0 # [15] - callx0 a15 # [18] - # [21] -END(ffi_trampoline) - -/* - * ffi_closure() - * - * a0: closure + 21 - * a14: return address (a0) - */ - -ENTRY(ffi_closure_SYSV) - - /* intentionally omitting entry here */ - - # restore return address (a0) and move pointer to closure to a10 - addi a10, a0, -21 - mov a0, a14 - - # allow up to 4 arguments as return values - addi a11, a1, 4 * 4 - - # save up to 6 arguments to stack (allocated by entry below) - s32i a2, a11, 0 - s32i a3, a11, 4 - s32i a4, a11, 8 - s32i a5, a11, 12 - s32i a6, a11, 16 - s32i a7, a11, 20 - - movi a8, ffi_closure_SYSV_inner - mov a12, a1 - callx8 a8 # .._inner(*closure, **avalue, *rvalue) - - # load up to four return arguments - l32i a2, a1, 0 - l32i a3, a1, 4 - l32i a4, a1, 8 - l32i a5, a1, 12 - - # (sign-)extend return value - movi a11, FFI_TYPE_UINT8 - bne a10, a11, 1f - extui a2, a2, 0, 8 - retw - -1: movi a11, FFI_TYPE_SINT8 - bne a10, a11, 1f - sext a2, a2, 7 - retw - -1: movi a11, FFI_TYPE_UINT16 - bne a10, a11, 1f - extui a2, a2, 0, 16 - retw - -1: movi a11, FFI_TYPE_SINT16 - bne a10, a11, 1f - sext a2, a2, 15 - -1: retw - -END(ffi_closure_SYSV) diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi/stamp-h.in --- a/Modules/_ctypes/libffi/stamp-h.in Sat Jul 19 16:34:33 2014 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -timestamp diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi/testsuite/Makefile.am --- a/Modules/_ctypes/libffi/testsuite/Makefile.am Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/_ctypes/libffi/testsuite/Makefile.am Sun Jul 20 10:52:46 2014 -0400 @@ -13,82 +13,68 @@ AM_RUNTESTFLAGS = -EXTRA_DEJAGNU_SITE_CONFIG=../local.exp - CLEANFILES = *.exe core* *.log *.sum -EXTRA_DIST = config/default.exp libffi.call/cls_19byte.c \ -libffi.call/cls_align_longdouble_split.c \ -libffi.call/closure_loc_fn0.c libffi.call/cls_schar.c \ -libffi.call/closure_fn1.c libffi.call/many2_win32.c \ -libffi.call/return_ul.c libffi.call/cls_align_double.c \ -libffi.call/return_fl2.c libffi.call/cls_1_1byte.c \ -libffi.call/cls_64byte.c libffi.call/nested_struct7.c \ -libffi.call/cls_align_sint32.c libffi.call/nested_struct2.c \ -libffi.call/ffitest.h libffi.call/nested_struct4.c \ -libffi.call/cls_multi_ushort.c libffi.call/struct3.c \ -libffi.call/cls_3byte1.c libffi.call/cls_16byte.c \ -libffi.call/struct8.c libffi.call/nested_struct8.c \ -libffi.call/cls_multi_sshort.c libffi.call/cls_3byte2.c \ -libffi.call/fastthis2_win32.c libffi.call/cls_pointer.c \ -libffi.call/err_bad_typedef.c libffi.call/cls_4_1byte.c \ -libffi.call/cls_9byte2.c libffi.call/cls_multi_schar.c \ -libffi.call/stret_medium2.c libffi.call/cls_5_1_byte.c \ -libffi.call/call.exp libffi.call/cls_double.c \ -libffi.call/cls_align_sint16.c libffi.call/cls_uint.c \ -libffi.call/return_ll1.c libffi.call/nested_struct3.c \ -libffi.call/cls_20byte1.c libffi.call/closure_fn4.c \ -libffi.call/cls_uchar.c libffi.call/struct2.c libffi.call/cls_7byte.c \ -libffi.call/strlen.c libffi.call/many.c libffi.call/testclosure.c \ -libffi.call/return_fl.c libffi.call/struct5.c \ -libffi.call/cls_12byte.c libffi.call/cls_multi_sshortchar.c \ -libffi.call/cls_align_longdouble_split2.c libffi.call/return_dbl2.c \ -libffi.call/return_fl3.c libffi.call/stret_medium.c \ -libffi.call/nested_struct6.c libffi.call/closure_fn3.c \ -libffi.call/float3.c libffi.call/many2.c \ -libffi.call/closure_stdcall.c libffi.call/cls_align_uint16.c \ -libffi.call/cls_9byte1.c libffi.call/closure_fn6.c \ -libffi.call/cls_double_va.c libffi.call/cls_align_pointer.c \ -libffi.call/cls_align_longdouble.c libffi.call/closure_fn2.c \ -libffi.call/cls_sshort.c libffi.call/many_win32.c \ -libffi.call/nested_struct.c libffi.call/cls_20byte.c \ -libffi.call/cls_longdouble.c libffi.call/cls_multi_uchar.c \ -libffi.call/return_uc.c libffi.call/closure_thiscall.c \ -libffi.call/cls_18byte.c libffi.call/cls_8byte.c \ -libffi.call/promotion.c libffi.call/struct1_win32.c \ -libffi.call/return_dbl.c libffi.call/cls_24byte.c \ -libffi.call/struct4.c libffi.call/cls_6byte.c \ -libffi.call/cls_align_uint32.c libffi.call/float.c \ -libffi.call/float1.c libffi.call/float_va.c libffi.call/negint.c \ -libffi.call/return_dbl1.c libffi.call/cls_3_1byte.c \ -libffi.call/cls_align_float.c libffi.call/return_fl1.c \ -libffi.call/nested_struct10.c libffi.call/nested_struct5.c \ -libffi.call/fastthis1_win32.c libffi.call/cls_align_sint64.c \ -libffi.call/stret_large2.c libffi.call/return_sl.c \ -libffi.call/closure_fn0.c libffi.call/cls_5byte.c \ -libffi.call/cls_2byte.c libffi.call/float2.c \ -libffi.call/cls_dbls_struct.c libffi.call/cls_sint.c \ -libffi.call/stret_large.c libffi.call/cls_ulonglong.c \ -libffi.call/cls_ushort.c libffi.call/nested_struct1.c \ -libffi.call/err_bad_abi.c libffi.call/cls_longdouble_va.c \ -libffi.call/cls_float.c libffi.call/cls_pointer_stack.c \ -libffi.call/pyobjc-tc.c libffi.call/cls_multi_ushortchar.c \ -libffi.call/struct1.c libffi.call/nested_struct9.c \ -libffi.call/huge_struct.c libffi.call/problem1.c \ -libffi.call/float4.c libffi.call/fastthis3_win32.c \ -libffi.call/return_ldl.c libffi.call/strlen2_win32.c \ -libffi.call/closure_fn5.c libffi.call/struct2_win32.c \ -libffi.call/struct6.c libffi.call/return_ll.c libffi.call/struct9.c \ -libffi.call/return_sc.c libffi.call/struct7.c \ -libffi.call/cls_align_uint64.c libffi.call/cls_4byte.c \ -libffi.call/strlen_win32.c libffi.call/cls_6_1_byte.c \ -libffi.call/cls_7_1_byte.c libffi.special/unwindtest.cc \ -libffi.special/special.exp libffi.special/unwindtest_ffi_call.cc \ -libffi.special/ffitestcxx.h lib/wrapper.exp lib/target-libpath.exp \ -lib/libffi.exp libffi.call/cls_struct_va1.c \ -libffi.call/cls_uchar_va.c libffi.call/cls_uint_va.c \ -libffi.call/cls_ulong_va.c libffi.call/cls_ushort_va.c \ -libffi.call/nested_struct11.c libffi.call/uninitialized.c \ -libffi.call/va_1.c libffi.call/va_struct1.c libffi.call/va_struct2.c \ -libffi.call/va_struct3.c - +EXTRA_DIST = libffi.special/special.exp \ +libffi.special/unwindtest_ffi_call.cc libffi.special/unwindtest.cc \ +libffi.special/ffitestcxx.h config/default.exp lib/target-libpath.exp \ +lib/libffi-dg.exp lib/wrapper.exp libffi.call/float.c \ +libffi.call/cls_multi_schar.c libffi.call/float3.c \ +libffi.call/cls_3_1byte.c libffi.call/stret_large2.c \ +libffi.call/cls_5_1_byte.c libffi.call/stret_medium.c \ +libffi.call/promotion.c libffi.call/cls_dbls_struct.c \ +libffi.call/nested_struct.c libffi.call/closure_fn1.c \ +libffi.call/cls_4_1byte.c libffi.call/cls_float.c \ +libffi.call/cls_2byte.c libffi.call/closure_fn4.c \ +libffi.call/return_fl2.c libffi.call/nested_struct7.c \ +libffi.call/cls_uint.c libffi.call/cls_align_sint64.c \ +libffi.call/float1.c libffi.call/cls_19byte.c \ +libffi.call/nested_struct1.c libffi.call/cls_4byte.c \ +libffi.call/return_fl1.c libffi.call/cls_align_pointer.c \ +libffi.call/nested_struct4.c libffi.call/nested_struct3.c \ +libffi.call/struct7.c libffi.call/nested_struct9.c \ +libffi.call/cls_sshort.c libffi.call/cls_ulonglong.c \ +libffi.call/cls_pointer_stack.c libffi.call/cls_multi_uchar.c \ +libffi.call/testclosure.c libffi.call/cls_3byte1.c \ +libffi.call/struct6.c libffi.call/return_uc.c libffi.call/return_ll1.c \ +libffi.call/cls_ushort.c libffi.call/stret_medium2.c \ +libffi.call/cls_multi_ushortchar.c libffi.call/return_dbl2.c \ +libffi.call/closure_loc_fn0.c libffi.call/return_sc.c \ +libffi.call/nested_struct8.c libffi.call/cls_7_1_byte.c \ +libffi.call/return_ll.c libffi.call/cls_pointer.c \ +libffi.call/err_bad_abi.c libffi.call/return_dbl1.c \ +libffi.call/call.exp libffi.call/ffitest.h libffi.call/strlen.c \ +libffi.call/return_sl.c libffi.call/cls_1_1byte.c \ +libffi.call/struct1.c libffi.call/cls_64byte.c libffi.call/return_ul.c \ +libffi.call/cls_double.c libffi.call/many_win32.c \ +libffi.call/cls_16byte.c libffi.call/cls_align_double.c \ +libffi.call/cls_align_uint16.c libffi.call/cls_9byte1.c \ +libffi.call/cls_multi_sshortchar.c libffi.call/cls_multi_ushort.c \ +libffi.call/closure_stdcall.c libffi.call/return_fl.c \ +libffi.call/strlen_win32.c libffi.call/return_ldl.c \ +libffi.call/cls_align_float.c libffi.call/struct3.c \ +libffi.call/cls_uchar.c libffi.call/cls_sint.c libffi.call/float2.c \ +libffi.call/cls_align_longdouble_split.c \ +libffi.call/cls_longdouble_va.c libffi.call/cls_multi_sshort.c \ +libffi.call/stret_large.c libffi.call/cls_align_sint16.c \ +libffi.call/nested_struct6.c libffi.call/cls_5byte.c \ +libffi.call/return_dbl.c libffi.call/cls_20byte.c \ +libffi.call/cls_8byte.c libffi.call/pyobjc-tc.c \ +libffi.call/cls_24byte.c libffi.call/cls_align_longdouble_split2.c \ +libffi.call/cls_6_1_byte.c libffi.call/cls_schar.c \ +libffi.call/cls_18byte.c libffi.call/closure_fn3.c \ +libffi.call/err_bad_typedef.c libffi.call/closure_fn2.c \ +libffi.call/struct2.c libffi.call/cls_3byte2.c \ +libffi.call/cls_align_longdouble.c libffi.call/cls_20byte1.c \ +libffi.call/return_fl3.c libffi.call/cls_align_uint32.c \ +libffi.call/problem1.c libffi.call/float4.c \ +libffi.call/cls_align_uint64.c libffi.call/struct9.c \ +libffi.call/closure_fn5.c libffi.call/cls_align_sint32.c \ +libffi.call/closure_fn0.c libffi.call/closure_fn6.c \ +libffi.call/struct4.c libffi.call/nested_struct2.c \ +libffi.call/cls_6byte.c libffi.call/cls_7byte.c libffi.call/many.c \ +libffi.call/struct8.c libffi.call/negint.c libffi.call/struct5.c \ +libffi.call/cls_12byte.c libffi.call/cls_double_va.c \ +libffi.call/cls_longdouble.c libffi.call/cls_9byte2.c \ +libffi.call/nested_struct10.c libffi.call/nested_struct5.c \ +libffi.call/huge_struct.c diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi/testsuite/Makefile.in --- a/Modules/_ctypes/libffi/testsuite/Makefile.in Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/_ctypes/libffi/testsuite/Makefile.in Sun Jul 20 10:52:46 2014 -0400 @@ -1,8 +1,9 @@ -# Makefile.in generated by automake 1.12.2 from Makefile.am. +# Makefile.in generated by automake 1.11 from Makefile.am. # @configure_input@ -# Copyright (C) 1994-2012 Free Software Foundation, Inc. - +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, +# Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. @@ -14,23 +15,6 @@ @SET_MAKE@ VPATH = @srcdir@ -am__make_dryrun = \ - { \ - am__dry=no; \ - case $$MAKEFLAGS in \ - *\\[\ \ ]*) \ - echo 'am--echo: ; @echo "AM" OK' | $(MAKE) -f - 2>/dev/null \ - | grep '^AM OK$$' >/dev/null || am__dry=yes;; \ - *) \ - for am__flg in $$MAKEFLAGS; do \ - case $$am__flg in \ - *=*|--*) ;; \ - *n*) am__dry=yes; break;; \ - esac; \ - done;; \ - esac; \ - test $$am__dry = yes; \ - } pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ @@ -53,19 +37,7 @@ subdir = testsuite DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 -am__aclocal_m4_deps = $(top_srcdir)/m4/asmcfi.m4 \ - $(top_srcdir)/m4/ax_append_flag.m4 \ - $(top_srcdir)/m4/ax_cc_maxopt.m4 \ - $(top_srcdir)/m4/ax_cflags_warn_all.m4 \ - $(top_srcdir)/m4/ax_check_compile_flag.m4 \ - $(top_srcdir)/m4/ax_compiler_vendor.m4 \ - $(top_srcdir)/m4/ax_configure_args.m4 \ - $(top_srcdir)/m4/ax_enable_builddir.m4 \ - $(top_srcdir)/m4/ax_gcc_archflag.m4 \ - $(top_srcdir)/m4/ax_gcc_x86_cpuid.m4 \ - $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \ - $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \ - $(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/acinclude.m4 \ +am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) @@ -75,18 +47,12 @@ CONFIG_CLEAN_VPATH_FILES = SOURCES = DIST_SOURCES = -am__can_run_installinfo = \ - case $$AM_UPDATE_INFO_DIR in \ - n|no|NO) false;; \ - *) (install-info --version) >/dev/null 2>&1;; \ - esac DEJATOOL = $(PACKAGE) RUNTESTDEFAULTFLAGS = --tool $$tool --srcdir $$srcdir DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ ALLOCA = @ALLOCA@ AMTAR = @AMTAR@ -AM_LTLDFLAGS = @AM_LTLDFLAGS@ AM_RUNTESTFLAGS = AR = @AR@ AUTOCONF = @AUTOCONF@ @@ -104,7 +70,6 @@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ -DLLTOOL = @DLLTOOL@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ @@ -112,7 +77,6 @@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ -FFI_EXEC_TRAMPOLINE_TABLE = @FFI_EXEC_TRAMPOLINE_TABLE@ FGREP = @FGREP@ GREP = @GREP@ HAVE_LONG_DOUBLE = @HAVE_LONG_DOUBLE@ @@ -131,7 +95,6 @@ LTLIBOBJS = @LTLIBOBJS@ MAINT = @MAINT@ MAKEINFO = @MAKEINFO@ -MANIFEST_TOOL = @MANIFEST_TOOL@ MKDIR_P = @MKDIR_P@ NM = @NM@ NMEDIT = @NMEDIT@ @@ -144,10 +107,8 @@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ -PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ -PRTDIAG = @PRTDIAG@ RANLIB = @RANLIB@ SED = @SED@ SET_MAKE = @SET_MAKE@ @@ -160,7 +121,6 @@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ -ac_ct_AR = @ac_ct_AR@ ac_ct_CC = @ac_ct_CC@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ am__include = @am__include@ @@ -168,7 +128,6 @@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ -ax_enable_builddir_sed = @ax_enable_builddir_sed@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ @@ -194,6 +153,7 @@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ +lt_ECHO = @lt_ECHO@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ @@ -204,7 +164,6 @@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ -sys_symbol_underscore = @sys_symbol_underscore@ sysconfdir = @sysconfdir@ target = @target@ target_alias = @target_alias@ @@ -227,82 +186,70 @@ echo $(top_srcdir)/../dejagnu/runtest ; \ else echo runtest; fi` -EXTRA_DEJAGNU_SITE_CONFIG = ../local.exp CLEANFILES = *.exe core* *.log *.sum -EXTRA_DIST = config/default.exp libffi.call/cls_19byte.c \ -libffi.call/cls_align_longdouble_split.c \ -libffi.call/closure_loc_fn0.c libffi.call/cls_schar.c \ -libffi.call/closure_fn1.c libffi.call/many2_win32.c \ -libffi.call/return_ul.c libffi.call/cls_align_double.c \ -libffi.call/return_fl2.c libffi.call/cls_1_1byte.c \ -libffi.call/cls_64byte.c libffi.call/nested_struct7.c \ -libffi.call/cls_align_sint32.c libffi.call/nested_struct2.c \ -libffi.call/ffitest.h libffi.call/nested_struct4.c \ -libffi.call/cls_multi_ushort.c libffi.call/struct3.c \ -libffi.call/cls_3byte1.c libffi.call/cls_16byte.c \ -libffi.call/struct8.c libffi.call/nested_struct8.c \ -libffi.call/cls_multi_sshort.c libffi.call/cls_3byte2.c \ -libffi.call/fastthis2_win32.c libffi.call/cls_pointer.c \ -libffi.call/err_bad_typedef.c libffi.call/cls_4_1byte.c \ -libffi.call/cls_9byte2.c libffi.call/cls_multi_schar.c \ -libffi.call/stret_medium2.c libffi.call/cls_5_1_byte.c \ -libffi.call/call.exp libffi.call/cls_double.c \ -libffi.call/cls_align_sint16.c libffi.call/cls_uint.c \ -libffi.call/return_ll1.c libffi.call/nested_struct3.c \ -libffi.call/cls_20byte1.c libffi.call/closure_fn4.c \ -libffi.call/cls_uchar.c libffi.call/struct2.c libffi.call/cls_7byte.c \ -libffi.call/strlen.c libffi.call/many.c libffi.call/testclosure.c \ -libffi.call/return_fl.c libffi.call/struct5.c \ -libffi.call/cls_12byte.c libffi.call/cls_multi_sshortchar.c \ -libffi.call/cls_align_longdouble_split2.c libffi.call/return_dbl2.c \ -libffi.call/return_fl3.c libffi.call/stret_medium.c \ -libffi.call/nested_struct6.c libffi.call/closure_fn3.c \ -libffi.call/float3.c libffi.call/many2.c \ -libffi.call/closure_stdcall.c libffi.call/cls_align_uint16.c \ -libffi.call/cls_9byte1.c libffi.call/closure_fn6.c \ -libffi.call/cls_double_va.c libffi.call/cls_align_pointer.c \ -libffi.call/cls_align_longdouble.c libffi.call/closure_fn2.c \ -libffi.call/cls_sshort.c libffi.call/many_win32.c \ -libffi.call/nested_struct.c libffi.call/cls_20byte.c \ -libffi.call/cls_longdouble.c libffi.call/cls_multi_uchar.c \ -libffi.call/return_uc.c libffi.call/closure_thiscall.c \ -libffi.call/cls_18byte.c libffi.call/cls_8byte.c \ -libffi.call/promotion.c libffi.call/struct1_win32.c \ -libffi.call/return_dbl.c libffi.call/cls_24byte.c \ -libffi.call/struct4.c libffi.call/cls_6byte.c \ -libffi.call/cls_align_uint32.c libffi.call/float.c \ -libffi.call/float1.c libffi.call/float_va.c libffi.call/negint.c \ -libffi.call/return_dbl1.c libffi.call/cls_3_1byte.c \ -libffi.call/cls_align_float.c libffi.call/return_fl1.c \ -libffi.call/nested_struct10.c libffi.call/nested_struct5.c \ -libffi.call/fastthis1_win32.c libffi.call/cls_align_sint64.c \ -libffi.call/stret_large2.c libffi.call/return_sl.c \ -libffi.call/closure_fn0.c libffi.call/cls_5byte.c \ -libffi.call/cls_2byte.c libffi.call/float2.c \ -libffi.call/cls_dbls_struct.c libffi.call/cls_sint.c \ -libffi.call/stret_large.c libffi.call/cls_ulonglong.c \ -libffi.call/cls_ushort.c libffi.call/nested_struct1.c \ -libffi.call/err_bad_abi.c libffi.call/cls_longdouble_va.c \ -libffi.call/cls_float.c libffi.call/cls_pointer_stack.c \ -libffi.call/pyobjc-tc.c libffi.call/cls_multi_ushortchar.c \ -libffi.call/struct1.c libffi.call/nested_struct9.c \ -libffi.call/huge_struct.c libffi.call/problem1.c \ -libffi.call/float4.c libffi.call/fastthis3_win32.c \ -libffi.call/return_ldl.c libffi.call/strlen2_win32.c \ -libffi.call/closure_fn5.c libffi.call/struct2_win32.c \ -libffi.call/struct6.c libffi.call/return_ll.c libffi.call/struct9.c \ -libffi.call/return_sc.c libffi.call/struct7.c \ -libffi.call/cls_align_uint64.c libffi.call/cls_4byte.c \ -libffi.call/strlen_win32.c libffi.call/cls_6_1_byte.c \ -libffi.call/cls_7_1_byte.c libffi.special/unwindtest.cc \ -libffi.special/special.exp libffi.special/unwindtest_ffi_call.cc \ -libffi.special/ffitestcxx.h lib/wrapper.exp lib/target-libpath.exp \ -lib/libffi.exp libffi.call/cls_struct_va1.c \ -libffi.call/cls_uchar_va.c libffi.call/cls_uint_va.c \ -libffi.call/cls_ulong_va.c libffi.call/cls_ushort_va.c \ -libffi.call/nested_struct11.c libffi.call/uninitialized.c \ -libffi.call/va_1.c libffi.call/va_struct1.c libffi.call/va_struct2.c \ -libffi.call/va_struct3.c +EXTRA_DIST = libffi.special/special.exp \ +libffi.special/unwindtest_ffi_call.cc libffi.special/unwindtest.cc \ +libffi.special/ffitestcxx.h config/default.exp lib/target-libpath.exp \ +lib/libffi-dg.exp lib/wrapper.exp libffi.call/float.c \ +libffi.call/cls_multi_schar.c libffi.call/float3.c \ +libffi.call/cls_3_1byte.c libffi.call/stret_large2.c \ +libffi.call/cls_5_1_byte.c libffi.call/stret_medium.c \ +libffi.call/promotion.c libffi.call/cls_dbls_struct.c \ +libffi.call/nested_struct.c libffi.call/closure_fn1.c \ +libffi.call/cls_4_1byte.c libffi.call/cls_float.c \ +libffi.call/cls_2byte.c libffi.call/closure_fn4.c \ +libffi.call/return_fl2.c libffi.call/nested_struct7.c \ +libffi.call/cls_uint.c libffi.call/cls_align_sint64.c \ +libffi.call/float1.c libffi.call/cls_19byte.c \ +libffi.call/nested_struct1.c libffi.call/cls_4byte.c \ +libffi.call/return_fl1.c libffi.call/cls_align_pointer.c \ +libffi.call/nested_struct4.c libffi.call/nested_struct3.c \ +libffi.call/struct7.c libffi.call/nested_struct9.c \ +libffi.call/cls_sshort.c libffi.call/cls_ulonglong.c \ +libffi.call/cls_pointer_stack.c libffi.call/cls_multi_uchar.c \ +libffi.call/testclosure.c libffi.call/cls_3byte1.c \ +libffi.call/struct6.c libffi.call/return_uc.c libffi.call/return_ll1.c \ +libffi.call/cls_ushort.c libffi.call/stret_medium2.c \ +libffi.call/cls_multi_ushortchar.c libffi.call/return_dbl2.c \ +libffi.call/closure_loc_fn0.c libffi.call/return_sc.c \ +libffi.call/nested_struct8.c libffi.call/cls_7_1_byte.c \ +libffi.call/return_ll.c libffi.call/cls_pointer.c \ +libffi.call/err_bad_abi.c libffi.call/return_dbl1.c \ +libffi.call/call.exp libffi.call/ffitest.h libffi.call/strlen.c \ +libffi.call/return_sl.c libffi.call/cls_1_1byte.c \ +libffi.call/struct1.c libffi.call/cls_64byte.c libffi.call/return_ul.c \ +libffi.call/cls_double.c libffi.call/many_win32.c \ +libffi.call/cls_16byte.c libffi.call/cls_align_double.c \ +libffi.call/cls_align_uint16.c libffi.call/cls_9byte1.c \ +libffi.call/cls_multi_sshortchar.c libffi.call/cls_multi_ushort.c \ +libffi.call/closure_stdcall.c libffi.call/return_fl.c \ +libffi.call/strlen_win32.c libffi.call/return_ldl.c \ +libffi.call/cls_align_float.c libffi.call/struct3.c \ +libffi.call/cls_uchar.c libffi.call/cls_sint.c libffi.call/float2.c \ +libffi.call/cls_align_longdouble_split.c \ +libffi.call/cls_longdouble_va.c libffi.call/cls_multi_sshort.c \ +libffi.call/stret_large.c libffi.call/cls_align_sint16.c \ +libffi.call/nested_struct6.c libffi.call/cls_5byte.c \ +libffi.call/return_dbl.c libffi.call/cls_20byte.c \ +libffi.call/cls_8byte.c libffi.call/pyobjc-tc.c \ +libffi.call/cls_24byte.c libffi.call/cls_align_longdouble_split2.c \ +libffi.call/cls_6_1_byte.c libffi.call/cls_schar.c \ +libffi.call/cls_18byte.c libffi.call/closure_fn3.c \ +libffi.call/err_bad_typedef.c libffi.call/closure_fn2.c \ +libffi.call/struct2.c libffi.call/cls_3byte2.c \ +libffi.call/cls_align_longdouble.c libffi.call/cls_20byte1.c \ +libffi.call/return_fl3.c libffi.call/cls_align_uint32.c \ +libffi.call/problem1.c libffi.call/float4.c \ +libffi.call/cls_align_uint64.c libffi.call/struct9.c \ +libffi.call/closure_fn5.c libffi.call/cls_align_sint32.c \ +libffi.call/closure_fn0.c libffi.call/closure_fn6.c \ +libffi.call/struct4.c libffi.call/nested_struct2.c \ +libffi.call/cls_6byte.c libffi.call/cls_7byte.c libffi.call/many.c \ +libffi.call/struct8.c libffi.call/negint.c libffi.call/struct5.c \ +libffi.call/cls_12byte.c libffi.call/cls_double_va.c \ +libffi.call/cls_longdouble.c libffi.call/cls_9byte2.c \ +libffi.call/nested_struct10.c libffi.call/nested_struct5.c \ +libffi.call/huge_struct.c all: all-am @@ -349,11 +296,9 @@ ctags: CTAGS CTAGS: -cscope cscopelist: - check-DEJAGNU: site.exp - srcdir='$(srcdir)'; export srcdir; \ + srcdir=`$(am__cd) $(srcdir) && pwd`; export srcdir; \ EXPECT=$(EXPECT); export EXPECT; \ runtest=$(RUNTEST); \ if $(SHELL) -c "$$runtest --version" > /dev/null 2>&1; then \ @@ -361,15 +306,15 @@ if $$runtest $(AM_RUNTESTFLAGS) $(RUNTESTDEFAULTFLAGS) $(RUNTESTFLAGS); \ then :; else exit_status=1; fi; \ done; \ - else echo "WARNING: could not find 'runtest'" 1>&2; :;\ + else echo "WARNING: could not find \`runtest'" 1>&2; :;\ fi; \ exit $$exit_status -site.exp: Makefile $(EXTRA_DEJAGNU_SITE_CONFIG) - @echo 'Making a new site.exp file ...' +site.exp: Makefile + @echo 'Making a new site.exp file...' @echo '## these variables are automatically generated by make ##' >site.tmp @echo '# Do not edit here. If you wish to override these values' >>site.tmp @echo '# edit the last section' >>site.tmp - @echo 'set srcdir "$(srcdir)"' >>site.tmp + @echo 'set srcdir $(srcdir)' >>site.tmp @echo "set objdir `pwd`" >>site.tmp @echo 'set build_alias "$(build_alias)"' >>site.tmp @echo 'set build_triplet $(build_triplet)' >>site.tmp @@ -377,16 +322,9 @@ @echo 'set host_triplet $(host_triplet)' >>site.tmp @echo 'set target_alias "$(target_alias)"' >>site.tmp @echo 'set target_triplet $(target_triplet)' >>site.tmp - @list='$(EXTRA_DEJAGNU_SITE_CONFIG)'; for f in $$list; do \ - echo "## Begin content included from file $$f. Do not modify. ##" \ - && cat `test -f "$$f" || echo '$(srcdir)/'`$$f \ - && echo "## End content included from file $$f. ##" \ - || exit 1; \ - done >> site.tmp - @echo "## End of auto-generated content; you can edit from here. ##" >> site.tmp - @if test -f site.exp; then \ - sed -e '1,/^## End of auto-generated content.*##/d' site.exp >> site.tmp; \ - fi + @echo '## All variables above are generated by configure. Do Not Edit ##' >>site.tmp + @test ! -f site.exp || \ + sed '1,/^## All variables above are.*##/ d' site.exp >> site.tmp @-rm -f site.bak @test ! -f site.exp || mv site.exp site.bak @mv site.tmp site.exp @@ -442,15 +380,10 @@ installcheck: installcheck-am install-strip: - if test -z '$(STRIP)'; then \ - $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ - install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ - install; \ - else \ - $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ - install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ - "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ - fi + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install mostlyclean-generic: clean-generic: diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi/testsuite/lib/libffi-dg.exp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Modules/_ctypes/libffi/testsuite/lib/libffi-dg.exp Sun Jul 20 10:52:46 2014 -0400 @@ -0,0 +1,300 @@ +# Copyright (C) 2003, 2005, 2008, 2009, 2010 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +proc load_gcc_lib { filename } { + global srcdir + load_file $srcdir/lib/$filename +} + +load_lib dg.exp +load_lib libgloss.exp +load_gcc_lib target-libpath.exp +load_gcc_lib wrapper.exp + + +# Define libffi callbacks for dg.exp. + +proc libffi-dg-test-1 { target_compile prog do_what extra_tool_flags } { + + # To get all \n in dg-output test strings to match printf output + # in a system that outputs it as \015\012 (i.e. not just \012), we + # need to change all \n into \r?\n. As there is no dejagnu flag + # or hook to do that, we simply change the text being tested. + # Unfortunately, we have to know that the variable is called + # dg-output-text and lives in the caller of libffi-dg-test, which + # is two calls up. Overriding proc dg-output would be longer and + # would necessarily have the same assumption. + upvar 2 dg-output-text output_match + + if { [llength $output_match] > 1 } { + regsub -all "\n" [lindex $output_match 1] "\r?\n" x + set output_match [lreplace $output_match 1 1 $x] + } + + # Set up the compiler flags, based on what we're going to do. + + set options [list] + switch $do_what { + "compile" { + set compile_type "assembly" + set output_file "[file rootname [file tail $prog]].s" + } + "link" { + set compile_type "executable" + set output_file "[file rootname [file tail $prog]].exe" + # The following line is needed for targets like the i960 where + # the default output file is b.out. Sigh. + } + "run" { + set compile_type "executable" + # FIXME: "./" is to cope with "." not being in $PATH. + # Should this be handled elsewhere? + # YES. + set output_file "./[file rootname [file tail $prog]].exe" + # This is the only place where we care if an executable was + # created or not. If it was, dg.exp will try to run it. + remote_file build delete $output_file; + } + default { + perror "$do_what: not a valid dg-do keyword" + return "" + } + } + + if { $extra_tool_flags != "" } { + lappend options "additional_flags=$extra_tool_flags" + } + + set comp_output [libffi_target_compile "$prog" "$output_file" "$compile_type" $options]; + + + return [list $comp_output $output_file] +} + + +proc libffi-dg-test { prog do_what extra_tool_flags } { + return [libffi-dg-test-1 target_compile $prog $do_what $extra_tool_flags] +} + +proc libffi-init { args } { + global gluefile wrap_flags; + global srcdir + global blddirffi + global objdir + global TOOL_OPTIONS + global tool + global libffi_include + global libffi_link_flags + global tool_root_dir + global ld_library_path + + set blddirffi [pwd]/.. + verbose "libffi $blddirffi" + + set gccdir [lookfor_file $tool_root_dir gcc/libgcc.a] + if {$gccdir != ""} { + set gccdir [file dirname $gccdir] + } + verbose "gccdir $gccdir" + + set ld_library_path "." + append ld_library_path ":${gccdir}" + + set compiler "${gccdir}/xgcc" + if { [is_remote host] == 0 && [which $compiler] != 0 } { + foreach i "[exec $compiler --print-multi-lib]" { + set mldir "" + regexp -- "\[a-z0-9=_/\.-\]*;" $i mldir + set mldir [string trimright $mldir "\;@"] + if { "$mldir" == "." } { + continue + } + if { [llength [glob -nocomplain ${gccdir}/${mldir}/libgcc_s*.so.*]] >= 1 } { + append ld_library_path ":${gccdir}/${mldir}" + } + } + } + # add the library path for libffi. + append ld_library_path ":${blddirffi}/.libs" + + verbose "ld_library_path: $ld_library_path" + + # Point to the Libffi headers in libffi. + set libffi_include "${blddirffi}/include" + verbose "libffi_include $libffi_include" + + set libffi_dir "${blddirffi}/.libs" + verbose "libffi_dir $libffi_dir" + if { $libffi_dir != "" } { + set libffi_dir [file dirname ${libffi_dir}] + set libffi_link_flags "-L${libffi_dir}/.libs" + } + + set_ld_library_path_env_vars + libffi_maybe_build_wrapper "${objdir}/testglue.o" +} + +proc libffi_exit { } { + global gluefile; + + if [info exists gluefile] { + file_on_build delete $gluefile; + unset gluefile; + } +} + +proc libffi_target_compile { source dest type options } { + global gluefile wrap_flags; + global srcdir + global blddirffi + global TOOL_OPTIONS + global libffi_link_flags + global libffi_include + global target_triplet + + + if { [target_info needs_status_wrapper]!="" && [info exists gluefile] } { + lappend options "libs=${gluefile}" + lappend options "ldflags=$wrap_flags" + } + + # TOOL_OPTIONS must come first, so that it doesn't override testcase + # specific options. + if [info exists TOOL_OPTIONS] { + lappend options [concat "additional_flags=$TOOL_OPTIONS" $options]; + } + + # search for ffi_mips.h in srcdir, too + lappend options "additional_flags=-I${libffi_include} -I${srcdir}/../include -I${libffi_include}/.." + lappend options "additional_flags=${libffi_link_flags}" + + # Darwin needs a stack execution allowed flag. + + if { [istarget "*-*-darwin9*"] || [istarget "*-*-darwin1*"] + || [istarget "*-*-darwin2*"] } { + lappend options "additional_flags=-Wl,-allow_stack_execute" + } + + # If you're building the compiler with --prefix set to a place + # where it's not yet installed, then the linker won't be able to + # find the libgcc used by libffi.dylib. We could pass the + # -dylib_file option, but that's complicated, and it's much easier + # to just make the linker find libgcc using -L options. + if { [string match "*-*-darwin*" $target_triplet] } { + lappend options "libs= -shared-libgcc" + } + + if { [string match "*-*-openbsd*" $target_triplet] } { + lappend options "libs= -lpthread" + } + + lappend options "libs= -lffi" + + verbose "options: $options" + return [target_compile $source $dest $type $options] +} + +# Utility routines. + +# +# search_for -- looks for a string match in a file +# +proc search_for { file pattern } { + set fd [open $file r] + while { [gets $fd cur_line]>=0 } { + if [string match "*$pattern*" $cur_line] then { + close $fd + return 1 + } + } + close $fd + return 0 +} + +# Modified dg-runtest that can cycle through a list of optimization options +# as c-torture does. +proc libffi-dg-runtest { testcases default-extra-flags } { + global runtests + + foreach test $testcases { + # If we're only testing specific files and this isn't one of + # them, skip it. + if ![runtest_file_p $runtests $test] { + continue + } + + # Look for a loop within the source code - if we don't find one, + # don't pass -funroll[-all]-loops. + global torture_with_loops torture_without_loops + if [expr [search_for $test "for*("]+[search_for $test "while*("]] { + set option_list $torture_with_loops + } else { + set option_list $torture_without_loops + } + + set nshort [file tail [file dirname $test]]/[file tail $test] + + foreach flags $option_list { + verbose "Testing $nshort, $flags" 1 + dg-test $test $flags ${default-extra-flags} + } + } +} + + +# Like check_conditional_xfail, but callable from a dg test. + +proc dg-xfail-if { args } { + set args [lreplace $args 0 0] + set selector "target [join [lindex $args 1]]" + if { [dg-process-target $selector] == "S" } { + global compiler_conditional_xfail_data + set compiler_conditional_xfail_data $args + } +} + + +# We need to make sure that additional_files and additional_sources +# are both cleared out after every test. It is not enough to clear +# them out *before* the next test run because gcc-target-compile gets +# run directly from some .exp files (outside of any test). (Those +# uses should eventually be eliminated.) + +# Because the DG framework doesn't provide a hook that is run at the +# end of a test, we must replace dg-test with a wrapper. + +if { [info procs saved-dg-test] == [list] } { + rename dg-test saved-dg-test + + proc dg-test { args } { + global additional_files + global additional_sources + global errorInfo + + if { [ catch { eval saved-dg-test $args } errmsg ] } { + set saved_info $errorInfo + set additional_files "" + set additional_sources "" + error $errmsg $saved_info + } + set additional_files "" + set additional_sources "" + } +} + +# Local Variables: +# tcl-indent-level:4 +# End: diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi/testsuite/lib/libffi.exp --- a/Modules/_ctypes/libffi/testsuite/lib/libffi.exp Sat Jul 19 16:34:33 2014 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,369 +0,0 @@ -# Copyright (C) 2003, 2005, 2008, 2009, 2010, 2011 Free Software Foundation, Inc. - -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; see the file COPYING3. If not see -# . - -proc load_gcc_lib { filename } { - global srcdir - load_file $srcdir/lib/$filename -} - -load_lib dg.exp -load_lib libgloss.exp -load_gcc_lib target-libpath.exp -load_gcc_lib wrapper.exp - - -# Define libffi callbacks for dg.exp. - -proc libffi-dg-test-1 { target_compile prog do_what extra_tool_flags } { - - # To get all \n in dg-output test strings to match printf output - # in a system that outputs it as \015\012 (i.e. not just \012), we - # need to change all \n into \r?\n. As there is no dejagnu flag - # or hook to do that, we simply change the text being tested. - # Unfortunately, we have to know that the variable is called - # dg-output-text and lives in the caller of libffi-dg-test, which - # is two calls up. Overriding proc dg-output would be longer and - # would necessarily have the same assumption. - upvar 2 dg-output-text output_match - - if { [llength $output_match] > 1 } { - regsub -all "\n" [lindex $output_match 1] "\r?\n" x - set output_match [lreplace $output_match 1 1 $x] - } - - # Set up the compiler flags, based on what we're going to do. - - set options [list] - switch $do_what { - "compile" { - set compile_type "assembly" - set output_file "[file rootname [file tail $prog]].s" - } - "link" { - set compile_type "executable" - set output_file "[file rootname [file tail $prog]].exe" - # The following line is needed for targets like the i960 where - # the default output file is b.out. Sigh. - } - "run" { - set compile_type "executable" - # FIXME: "./" is to cope with "." not being in $PATH. - # Should this be handled elsewhere? - # YES. - set output_file "./[file rootname [file tail $prog]].exe" - # This is the only place where we care if an executable was - # created or not. If it was, dg.exp will try to run it. - remote_file build delete $output_file; - } - default { - perror "$do_what: not a valid dg-do keyword" - return "" - } - } - - if { $extra_tool_flags != "" } { - lappend options "additional_flags=$extra_tool_flags" - } - - set comp_output [libffi_target_compile "$prog" "$output_file" "$compile_type" $options]; - - - return [list $comp_output $output_file] -} - - -proc libffi-dg-test { prog do_what extra_tool_flags } { - return [libffi-dg-test-1 target_compile $prog $do_what $extra_tool_flags] -} - -proc libffi-init { args } { - global gluefile wrap_flags; - global srcdir - global blddirffi - global objdir - global TOOL_OPTIONS - global tool - global libffi_include - global libffi_link_flags - global tool_root_dir - global ld_library_path - - global using_gcc - - set blddirffi [pwd]/.. - verbose "libffi $blddirffi" - - # Are we building with GCC? - set tmp [grep ../config.status "GCC='yes'"] - if { [string match $tmp "GCC='yes'"] } { - - set using_gcc "yes" - - set gccdir [lookfor_file $tool_root_dir gcc/libgcc.a] - if {$gccdir != ""} { - set gccdir [file dirname $gccdir] - } - verbose "gccdir $gccdir" - - set ld_library_path "." - append ld_library_path ":${gccdir}" - - set compiler "${gccdir}/xgcc" - if { [is_remote host] == 0 && [which $compiler] != 0 } { - foreach i "[exec $compiler --print-multi-lib]" { - set mldir "" - regexp -- "\[a-z0-9=_/\.-\]*;" $i mldir - set mldir [string trimright $mldir "\;@"] - if { "$mldir" == "." } { - continue - } - if { [llength [glob -nocomplain ${gccdir}/${mldir}/libgcc_s*.so.*]] >= 1 } { - append ld_library_path ":${gccdir}/${mldir}" - } - } - } - - } else { - - set using_gcc "no" - - } - - # add the library path for libffi. - append ld_library_path ":${blddirffi}/.libs" - - verbose "ld_library_path: $ld_library_path" - - # Point to the Libffi headers in libffi. - set libffi_include "${blddirffi}/include" - verbose "libffi_include $libffi_include" - - set libffi_dir "${blddirffi}/.libs" - verbose "libffi_dir $libffi_dir" - if { $libffi_dir != "" } { - set libffi_dir [file dirname ${libffi_dir}] - set libffi_link_flags "-L${libffi_dir}/.libs" - } - - set_ld_library_path_env_vars - libffi_maybe_build_wrapper "${objdir}/testglue.o" -} - -proc libffi_exit { } { - global gluefile; - - if [info exists gluefile] { - file_on_build delete $gluefile; - unset gluefile; - } -} - -proc libffi_target_compile { source dest type options } { - global gluefile wrap_flags; - global srcdir - global blddirffi - global TOOL_OPTIONS - global libffi_link_flags - global libffi_include - global target_triplet - - - if { [target_info needs_status_wrapper]!="" && [info exists gluefile] } { - lappend options "libs=${gluefile}" - lappend options "ldflags=$wrap_flags" - } - - # TOOL_OPTIONS must come first, so that it doesn't override testcase - # specific options. - if [info exists TOOL_OPTIONS] { - lappend options [concat "additional_flags=$TOOL_OPTIONS" $options]; - } - - # search for ffi_mips.h in srcdir, too - lappend options "additional_flags=-I${libffi_include} -I${srcdir}/../include -I${libffi_include}/.." - lappend options "additional_flags=${libffi_link_flags}" - - # Darwin needs a stack execution allowed flag. - - if { [istarget "*-*-darwin9*"] || [istarget "*-*-darwin1*"] - || [istarget "*-*-darwin2*"] } { - lappend options "additional_flags=-Wl,-allow_stack_execute" - } - - # If you're building the compiler with --prefix set to a place - # where it's not yet installed, then the linker won't be able to - # find the libgcc used by libffi.dylib. We could pass the - # -dylib_file option, but that's complicated, and it's much easier - # to just make the linker find libgcc using -L options. - if { [string match "*-*-darwin*" $target_triplet] } { - lappend options "libs= -shared-libgcc" - } - - if { [string match "*-*-openbsd*" $target_triplet] } { - lappend options "libs= -lpthread" - } - - lappend options "libs= -lffi" - - if { [string match "aarch64*-*-linux*" $target_triplet] } { - lappend options "libs= -lpthread" - } - - verbose "options: $options" - return [target_compile $source $dest $type $options] -} - -# Utility routines. - -# -# search_for -- looks for a string match in a file -# -proc search_for { file pattern } { - set fd [open $file r] - while { [gets $fd cur_line]>=0 } { - if [string match "*$pattern*" $cur_line] then { - close $fd - return 1 - } - } - close $fd - return 0 -} - -# Modified dg-runtest that can cycle through a list of optimization options -# as c-torture does. -proc libffi-dg-runtest { testcases default-extra-flags } { - global runtests - - foreach test $testcases { - # If we're only testing specific files and this isn't one of - # them, skip it. - if ![runtest_file_p $runtests $test] { - continue - } - - # Look for a loop within the source code - if we don't find one, - # don't pass -funroll[-all]-loops. - global torture_with_loops torture_without_loops - if [expr [search_for $test "for*("]+[search_for $test "while*("]] { - set option_list $torture_with_loops - } else { - set option_list $torture_without_loops - } - - set nshort [file tail [file dirname $test]]/[file tail $test] - - foreach flags $option_list { - verbose "Testing $nshort, $flags" 1 - dg-test $test $flags ${default-extra-flags} - } - } -} - - -# Like check_conditional_xfail, but callable from a dg test. - -proc dg-xfail-if { args } { - set args [lreplace $args 0 0] - set selector "target [join [lindex $args 1]]" - if { [dg-process-target $selector] == "S" } { - global compiler_conditional_xfail_data - set compiler_conditional_xfail_data $args - } -} - -proc check-flags { args } { - - # The args are within another list; pull them out. - set args [lindex $args 0] - - # The next two arguments are optional. If they were not specified, - # use the defaults. - if { [llength $args] == 2 } { - lappend $args [list "*"] - } - if { [llength $args] == 3 } { - lappend $args [list ""] - } - - # If the option strings are the defaults, or the same as the - # defaults, there is no need to call check_conditional_xfail to - # compare them to the actual options. - if { [string compare [lindex $args 2] "*"] == 0 - && [string compare [lindex $args 3] "" ] == 0 } { - set result 1 - } else { - # The target list might be an effective-target keyword, so replace - # the original list with "*-*-*", since we already know it matches. - set result [check_conditional_xfail [lreplace $args 1 1 "*-*-*"]] - } - - return $result -} - -proc dg-skip-if { args } { - # Verify the number of arguments. The last two are optional. - set args [lreplace $args 0 0] - if { [llength $args] < 2 || [llength $args] > 4 } { - error "dg-skip-if 2: need 2, 3, or 4 arguments" - } - - # Don't bother if we're already skipping the test. - upvar dg-do-what dg-do-what - if { [lindex ${dg-do-what} 1] == "N" } { - return - } - - set selector [list target [lindex $args 1]] - if { [dg-process-target $selector] == "S" } { - if [check-flags $args] { - upvar dg-do-what dg-do-what - set dg-do-what [list [lindex ${dg-do-what} 0] "N" "P"] - } - } -} - -# We need to make sure that additional_files and additional_sources -# are both cleared out after every test. It is not enough to clear -# them out *before* the next test run because gcc-target-compile gets -# run directly from some .exp files (outside of any test). (Those -# uses should eventually be eliminated.) - -# Because the DG framework doesn't provide a hook that is run at the -# end of a test, we must replace dg-test with a wrapper. - -if { [info procs saved-dg-test] == [list] } { - rename dg-test saved-dg-test - - proc dg-test { args } { - global additional_files - global additional_sources - global errorInfo - - if { [ catch { eval saved-dg-test $args } errmsg ] } { - set saved_info $errorInfo - set additional_files "" - set additional_sources "" - error $errmsg $saved_info - } - set additional_files "" - set additional_sources "" - } -} - -# Local Variables: -# tcl-indent-level:4 -# End: diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi/testsuite/lib/target-libpath.exp --- a/Modules/_ctypes/libffi/testsuite/lib/target-libpath.exp Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/_ctypes/libffi/testsuite/lib/target-libpath.exp Sun Jul 20 10:52:46 2014 -0400 @@ -25,7 +25,7 @@ set orig_ld_library_path_32_saved 0 set orig_ld_library_path_64_saved 0 set orig_dyld_library_path_saved 0 -set orig_path_saved 0 + ####################################### # proc set_ld_library_path_env_vars { } @@ -42,7 +42,6 @@ global orig_ld_library_path_32_saved global orig_ld_library_path_64_saved global orig_dyld_library_path_saved - global orig_path_saved global orig_ld_library_path global orig_ld_run_path global orig_shlib_path @@ -51,7 +50,6 @@ global orig_ld_library_path_32 global orig_ld_library_path_64 global orig_dyld_library_path - global orig_path global GCC_EXEC_PREFIX # Set the relocated compiler prefix, but only if the user hasn't specified one. @@ -102,10 +100,6 @@ set orig_dyld_library_path "$env(DYLD_LIBRARY_PATH)" set orig_dyld_library_path_saved 1 } - if [info exists env(PATH)] { - set orig_path "$env(PATH)" - set orig_path_saved 1 - } } # We need to set ld library path in the environment. Currently, @@ -175,13 +169,6 @@ } else { setenv DYLD_LIBRARY_PATH "$ld_library_path" } - if { [istarget *-*-cygwin*] || [istarget *-*-mingw*] } { - if { $orig_path_saved } { - setenv PATH "$ld_library_path:$orig_path" - } else { - setenv PATH "$ld_library_path" - } - } verbose -log "set_ld_library_path_env_vars: ld_library_path=$ld_library_path" } @@ -200,7 +187,6 @@ global orig_ld_library_path_32_saved global orig_ld_library_path_64_saved global orig_dyld_library_path_saved - global orig_path_saved global orig_ld_library_path global orig_ld_run_path global orig_shlib_path @@ -209,7 +195,6 @@ global orig_ld_library_path_32 global orig_ld_library_path_64 global orig_dyld_library_path - global orig_path if { $orig_environment_saved == 0 } { return @@ -255,11 +240,6 @@ } elseif [info exists env(DYLD_LIBRARY_PATH)] { unsetenv DYLD_LIBRARY_PATH } - if { $orig_path_saved } { - setenv PATH "$orig_path" - } elseif [info exists env(PATH)] { - unsetenv PATH - } } ####################################### diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi/testsuite/libffi.call/call.exp --- a/Modules/_ctypes/libffi/testsuite/libffi.call/call.exp Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/_ctypes/libffi/testsuite/libffi.call/call.exp Sun Jul 20 10:52:46 2014 -0400 @@ -1,4 +1,4 @@ -# Copyright (C) 2003, 2006, 2009, 2010 Free Software Foundation, Inc. +# Copyright (C) 2003, 2006, 2009 Free Software Foundation, Inc. # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -14,25 +14,20 @@ # along with this program; see the file COPYING3. If not see # . +# libffi testsuite that uses the 'dg.exp' driver. + +load_lib libffi-dg.exp + dg-init libffi-init global srcdir subdir -if { [string match $using_gcc "yes"] } { - - dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.\[cS\]]] "-O0 -W -Wall" "" - dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.\[cS\]]] "-O2" "" - dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.\[cS\]]] "-O3" "" - dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.\[cS\]]] "-Os" "" - dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.\[cS\]]] "-O2 -fomit-frame-pointer" "" - -} else { - - # Assume we are using the vendor compiler. - dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.\[cS\]]] "" "" - -} +dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.\[cS\]]] "-O0 -W -Wall" "" +dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.\[cS\]]] "-O2" "" +dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.\[cS\]]] "-O3" "" +dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.\[cS\]]] "-Os" "" +dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.\[cS\]]] "-O2 -fomit-frame-pointer" "" dg-finish diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi/testsuite/libffi.call/closure_stdcall.c --- a/Modules/_ctypes/libffi/testsuite/libffi.call/closure_stdcall.c Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/_ctypes/libffi/testsuite/libffi.call/closure_stdcall.c Sun Jul 20 10:52:46 2014 -0400 @@ -49,17 +49,9 @@ CHECK(ffi_prep_closure_loc(pcl, &cif, closure_test_stdcall, (void *) 3 /* userdata */, code) == FFI_OK); -#ifdef _MSC_VER - __asm { mov sp_pre, esp } -#else asm volatile (" movl %%esp,%0" : "=g" (sp_pre)); -#endif res = (*(closure_test_type0)code)(0, 1, 2, 3); -#ifdef _MSC_VER - __asm { mov sp_post, esp } -#else asm volatile (" movl %%esp,%0" : "=g" (sp_post)); -#endif /* { dg-output "0 1 2 3: 9" } */ printf("res: %d\n",res); diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi/testsuite/libffi.call/closure_thiscall.c --- a/Modules/_ctypes/libffi/testsuite/libffi.call/closure_thiscall.c Sat Jul 19 16:34:33 2014 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,72 +0,0 @@ -/* Area: closure_call (thiscall convention) - Purpose: Check handling when caller expects thiscall callee - Limitations: none. - PR: none. - Originator: */ - -/* { dg-do run { target i?86-*-cygwin* i?86-*-mingw* } } */ -#include "ffitest.h" - -static void -closure_test_thiscall(ffi_cif* cif __UNUSED__, void* resp, void** args, - void* userdata) -{ - *(ffi_arg*)resp = - (int)*(int *)args[0] + (int)(*(int *)args[1]) - + (int)(*(int *)args[2]) + (int)(*(int *)args[3]) - + (int)(intptr_t)userdata; - - printf("%d %d %d %d: %d\n", - (int)*(int *)args[0], (int)(*(int *)args[1]), - (int)(*(int *)args[2]), (int)(*(int *)args[3]), - (int)*(ffi_arg *)resp); - -} - -typedef int (__thiscall *closure_test_type0)(int, int, int, int); - -int main (void) -{ - ffi_cif cif; - void *code; - ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code); - ffi_type * cl_arg_types[17]; - int res; - void* sp_pre; - void* sp_post; - char buf[1024]; - - cl_arg_types[0] = &ffi_type_uint; - cl_arg_types[1] = &ffi_type_uint; - cl_arg_types[2] = &ffi_type_uint; - cl_arg_types[3] = &ffi_type_uint; - cl_arg_types[4] = NULL; - - /* Initialize the cif */ - CHECK(ffi_prep_cif(&cif, FFI_THISCALL, 4, - &ffi_type_sint, cl_arg_types) == FFI_OK); - - CHECK(ffi_prep_closure_loc(pcl, &cif, closure_test_thiscall, - (void *) 3 /* userdata */, code) == FFI_OK); - -#ifdef _MSC_VER - __asm { mov sp_pre, esp } -#else - asm volatile (" movl %%esp,%0" : "=g" (sp_pre)); -#endif - res = (*(closure_test_type0)code)(0, 1, 2, 3); -#ifdef _MSC_VER - __asm { mov sp_post, esp } -#else - asm volatile (" movl %%esp,%0" : "=g" (sp_post)); -#endif - /* { dg-output "0 1 2 3: 9" } */ - - printf("res: %d\n",res); - /* { dg-output "\nres: 9" } */ - - sprintf(buf, "mismatch: pre=%p vs post=%p", sp_pre, sp_post); - printf("stack pointer %s\n", (sp_pre == sp_post ? "match" : buf)); - /* { dg-output "\nstack pointer match" } */ - exit(0); -} diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi/testsuite/libffi.call/cls_12byte.c --- a/Modules/_ctypes/libffi/testsuite/libffi.call/cls_12byte.c Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/_ctypes/libffi/testsuite/libffi.call/cls_12byte.c Sun Jul 20 10:52:46 2014 -0400 @@ -49,15 +49,15 @@ ffi_type cls_struct_type; ffi_type* dbl_arg_types[5]; - struct cls_struct_12byte h_dbl = { 7, 4, 9 }; - struct cls_struct_12byte j_dbl = { 1, 5, 3 }; - struct cls_struct_12byte res_dbl; - cls_struct_type.size = 0; cls_struct_type.alignment = 0; cls_struct_type.type = FFI_TYPE_STRUCT; cls_struct_type.elements = cls_struct_fields; + struct cls_struct_12byte h_dbl = { 7, 4, 9 }; + struct cls_struct_12byte j_dbl = { 1, 5, 3 }; + struct cls_struct_12byte res_dbl; + cls_struct_fields[0] = &ffi_type_sint; cls_struct_fields[1] = &ffi_type_sint; cls_struct_fields[2] = &ffi_type_sint; diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi/testsuite/libffi.call/cls_16byte.c --- a/Modules/_ctypes/libffi/testsuite/libffi.call/cls_16byte.c Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/_ctypes/libffi/testsuite/libffi.call/cls_16byte.c Sun Jul 20 10:52:46 2014 -0400 @@ -50,15 +50,15 @@ ffi_type cls_struct_type; ffi_type* dbl_arg_types[5]; - struct cls_struct_16byte h_dbl = { 7, 8.0, 9 }; - struct cls_struct_16byte j_dbl = { 1, 9.0, 3 }; - struct cls_struct_16byte res_dbl; - cls_struct_type.size = 0; cls_struct_type.alignment = 0; cls_struct_type.type = FFI_TYPE_STRUCT; cls_struct_type.elements = cls_struct_fields; + struct cls_struct_16byte h_dbl = { 7, 8.0, 9 }; + struct cls_struct_16byte j_dbl = { 1, 9.0, 3 }; + struct cls_struct_16byte res_dbl; + cls_struct_fields[0] = &ffi_type_sint; cls_struct_fields[1] = &ffi_type_double; cls_struct_fields[2] = &ffi_type_sint; diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi/testsuite/libffi.call/cls_18byte.c --- a/Modules/_ctypes/libffi/testsuite/libffi.call/cls_18byte.c Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/_ctypes/libffi/testsuite/libffi.call/cls_18byte.c Sun Jul 20 10:52:46 2014 -0400 @@ -54,15 +54,15 @@ ffi_type cls_struct_type; ffi_type* dbl_arg_types[3]; - struct cls_struct_18byte g_dbl = { 1.0, 127, 126, 3.0 }; - struct cls_struct_18byte f_dbl = { 4.0, 125, 124, 5.0 }; - struct cls_struct_18byte res_dbl; - cls_struct_type.size = 0; cls_struct_type.alignment = 0; cls_struct_type.type = FFI_TYPE_STRUCT; cls_struct_type.elements = cls_struct_fields; + struct cls_struct_18byte g_dbl = { 1.0, 127, 126, 3.0 }; + struct cls_struct_18byte f_dbl = { 4.0, 125, 124, 5.0 }; + struct cls_struct_18byte res_dbl; + cls_struct_fields[0] = &ffi_type_double; cls_struct_fields[1] = &ffi_type_uchar; cls_struct_fields[2] = &ffi_type_uchar; diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi/testsuite/libffi.call/cls_19byte.c --- a/Modules/_ctypes/libffi/testsuite/libffi.call/cls_19byte.c Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/_ctypes/libffi/testsuite/libffi.call/cls_19byte.c Sun Jul 20 10:52:46 2014 -0400 @@ -57,15 +57,15 @@ ffi_type cls_struct_type; ffi_type* dbl_arg_types[3]; - struct cls_struct_19byte g_dbl = { 1.0, 127, 126, 3.0, 120 }; - struct cls_struct_19byte f_dbl = { 4.0, 125, 124, 5.0, 119 }; - struct cls_struct_19byte res_dbl; - cls_struct_type.size = 0; cls_struct_type.alignment = 0; cls_struct_type.type = FFI_TYPE_STRUCT; cls_struct_type.elements = cls_struct_fields; + struct cls_struct_19byte g_dbl = { 1.0, 127, 126, 3.0, 120 }; + struct cls_struct_19byte f_dbl = { 4.0, 125, 124, 5.0, 119 }; + struct cls_struct_19byte res_dbl; + cls_struct_fields[0] = &ffi_type_double; cls_struct_fields[1] = &ffi_type_uchar; cls_struct_fields[2] = &ffi_type_uchar; diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi/testsuite/libffi.call/cls_1_1byte.c --- a/Modules/_ctypes/libffi/testsuite/libffi.call/cls_1_1byte.c Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/_ctypes/libffi/testsuite/libffi.call/cls_1_1byte.c Sun Jul 20 10:52:46 2014 -0400 @@ -50,15 +50,15 @@ ffi_type cls_struct_type; ffi_type* dbl_arg_types[5]; - struct cls_struct_1_1byte g_dbl = { 12 }; - struct cls_struct_1_1byte f_dbl = { 178 }; - struct cls_struct_1_1byte res_dbl; - cls_struct_type.size = 0; cls_struct_type.alignment = 0; cls_struct_type.type = FFI_TYPE_STRUCT; cls_struct_type.elements = cls_struct_fields; + struct cls_struct_1_1byte g_dbl = { 12 }; + struct cls_struct_1_1byte f_dbl = { 178 }; + struct cls_struct_1_1byte res_dbl; + cls_struct_fields[0] = &ffi_type_uchar; cls_struct_fields[1] = NULL; diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi/testsuite/libffi.call/cls_20byte.c --- a/Modules/_ctypes/libffi/testsuite/libffi.call/cls_20byte.c Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/_ctypes/libffi/testsuite/libffi.call/cls_20byte.c Sun Jul 20 10:52:46 2014 -0400 @@ -50,15 +50,15 @@ ffi_type cls_struct_type; ffi_type* dbl_arg_types[5]; - struct cls_struct_20byte g_dbl = { 1.0, 2.0, 3 }; - struct cls_struct_20byte f_dbl = { 4.0, 5.0, 7 }; - struct cls_struct_20byte res_dbl; - cls_struct_type.size = 0; cls_struct_type.alignment = 0; cls_struct_type.type = FFI_TYPE_STRUCT; cls_struct_type.elements = cls_struct_fields; + struct cls_struct_20byte g_dbl = { 1.0, 2.0, 3 }; + struct cls_struct_20byte f_dbl = { 4.0, 5.0, 7 }; + struct cls_struct_20byte res_dbl; + cls_struct_fields[0] = &ffi_type_double; cls_struct_fields[1] = &ffi_type_double; cls_struct_fields[2] = &ffi_type_sint; diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi/testsuite/libffi.call/cls_20byte1.c --- a/Modules/_ctypes/libffi/testsuite/libffi.call/cls_20byte1.c Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/_ctypes/libffi/testsuite/libffi.call/cls_20byte1.c Sun Jul 20 10:52:46 2014 -0400 @@ -52,15 +52,15 @@ ffi_type cls_struct_type; ffi_type* dbl_arg_types[3]; - struct cls_struct_20byte g_dbl = { 1, 2.0, 3.0 }; - struct cls_struct_20byte f_dbl = { 4, 5.0, 7.0 }; - struct cls_struct_20byte res_dbl; - cls_struct_type.size = 0; cls_struct_type.alignment = 0; cls_struct_type.type = FFI_TYPE_STRUCT; cls_struct_type.elements = cls_struct_fields; + struct cls_struct_20byte g_dbl = { 1, 2.0, 3.0 }; + struct cls_struct_20byte f_dbl = { 4, 5.0, 7.0 }; + struct cls_struct_20byte res_dbl; + cls_struct_fields[0] = &ffi_type_sint; cls_struct_fields[1] = &ffi_type_double; cls_struct_fields[2] = &ffi_type_double; diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi/testsuite/libffi.call/cls_24byte.c --- a/Modules/_ctypes/libffi/testsuite/libffi.call/cls_24byte.c Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/_ctypes/libffi/testsuite/libffi.call/cls_24byte.c Sun Jul 20 10:52:46 2014 -0400 @@ -61,17 +61,17 @@ ffi_type cls_struct_type; ffi_type* dbl_arg_types[5]; + cls_struct_type.size = 0; + cls_struct_type.alignment = 0; + cls_struct_type.type = FFI_TYPE_STRUCT; + cls_struct_type.elements = cls_struct_fields; + struct cls_struct_24byte e_dbl = { 9.0, 2.0, 6, 5.0 }; struct cls_struct_24byte f_dbl = { 1.0, 2.0, 3, 7.0 }; struct cls_struct_24byte g_dbl = { 4.0, 5.0, 7, 9.0 }; struct cls_struct_24byte h_dbl = { 8.0, 6.0, 1, 4.0 }; struct cls_struct_24byte res_dbl; - cls_struct_type.size = 0; - cls_struct_type.alignment = 0; - cls_struct_type.type = FFI_TYPE_STRUCT; - cls_struct_type.elements = cls_struct_fields; - cls_struct_fields[0] = &ffi_type_double; cls_struct_fields[1] = &ffi_type_double; cls_struct_fields[2] = &ffi_type_sint; diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi/testsuite/libffi.call/cls_2byte.c --- a/Modules/_ctypes/libffi/testsuite/libffi.call/cls_2byte.c Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/_ctypes/libffi/testsuite/libffi.call/cls_2byte.c Sun Jul 20 10:52:46 2014 -0400 @@ -50,15 +50,15 @@ ffi_type cls_struct_type; ffi_type* dbl_arg_types[5]; - struct cls_struct_2byte g_dbl = { 12, 127 }; - struct cls_struct_2byte f_dbl = { 1, 13 }; - struct cls_struct_2byte res_dbl; - cls_struct_type.size = 0; cls_struct_type.alignment = 0; cls_struct_type.type = FFI_TYPE_STRUCT; cls_struct_type.elements = cls_struct_fields; + struct cls_struct_2byte g_dbl = { 12, 127 }; + struct cls_struct_2byte f_dbl = { 1, 13 }; + struct cls_struct_2byte res_dbl; + cls_struct_fields[0] = &ffi_type_uchar; cls_struct_fields[1] = &ffi_type_uchar; cls_struct_fields[2] = NULL; diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi/testsuite/libffi.call/cls_3_1byte.c --- a/Modules/_ctypes/libffi/testsuite/libffi.call/cls_3_1byte.c Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/_ctypes/libffi/testsuite/libffi.call/cls_3_1byte.c Sun Jul 20 10:52:46 2014 -0400 @@ -54,15 +54,15 @@ ffi_type cls_struct_type; ffi_type* dbl_arg_types[5]; - struct cls_struct_3_1byte g_dbl = { 12, 13, 14 }; - struct cls_struct_3_1byte f_dbl = { 178, 179, 180 }; - struct cls_struct_3_1byte res_dbl; - cls_struct_type.size = 0; cls_struct_type.alignment = 0; cls_struct_type.type = FFI_TYPE_STRUCT; cls_struct_type.elements = cls_struct_fields; + struct cls_struct_3_1byte g_dbl = { 12, 13, 14 }; + struct cls_struct_3_1byte f_dbl = { 178, 179, 180 }; + struct cls_struct_3_1byte res_dbl; + cls_struct_fields[0] = &ffi_type_uchar; cls_struct_fields[1] = &ffi_type_uchar; cls_struct_fields[2] = &ffi_type_uchar; diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi/testsuite/libffi.call/cls_3byte1.c --- a/Modules/_ctypes/libffi/testsuite/libffi.call/cls_3byte1.c Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/_ctypes/libffi/testsuite/libffi.call/cls_3byte1.c Sun Jul 20 10:52:46 2014 -0400 @@ -50,15 +50,15 @@ ffi_type cls_struct_type; ffi_type* dbl_arg_types[5]; - struct cls_struct_3byte g_dbl = { 12, 119 }; - struct cls_struct_3byte f_dbl = { 1, 15 }; - struct cls_struct_3byte res_dbl; - cls_struct_type.size = 0; cls_struct_type.alignment = 0; cls_struct_type.type = FFI_TYPE_STRUCT; cls_struct_type.elements = cls_struct_fields; + struct cls_struct_3byte g_dbl = { 12, 119 }; + struct cls_struct_3byte f_dbl = { 1, 15 }; + struct cls_struct_3byte res_dbl; + cls_struct_fields[0] = &ffi_type_ushort; cls_struct_fields[1] = &ffi_type_uchar; cls_struct_fields[2] = NULL; diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi/testsuite/libffi.call/cls_3byte2.c --- a/Modules/_ctypes/libffi/testsuite/libffi.call/cls_3byte2.c Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/_ctypes/libffi/testsuite/libffi.call/cls_3byte2.c Sun Jul 20 10:52:46 2014 -0400 @@ -50,15 +50,15 @@ ffi_type cls_struct_type; ffi_type* dbl_arg_types[5]; - struct cls_struct_3byte_1 g_dbl = { 15, 125 }; - struct cls_struct_3byte_1 f_dbl = { 9, 19 }; - struct cls_struct_3byte_1 res_dbl; - cls_struct_type.size = 0; cls_struct_type.alignment = 0; cls_struct_type.type = FFI_TYPE_STRUCT; cls_struct_type.elements = cls_struct_fields; + struct cls_struct_3byte_1 g_dbl = { 15, 125 }; + struct cls_struct_3byte_1 f_dbl = { 9, 19 }; + struct cls_struct_3byte_1 res_dbl; + cls_struct_fields[0] = &ffi_type_uchar; cls_struct_fields[1] = &ffi_type_ushort; cls_struct_fields[2] = NULL; diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi/testsuite/libffi.call/cls_4_1byte.c --- a/Modules/_ctypes/libffi/testsuite/libffi.call/cls_4_1byte.c Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/_ctypes/libffi/testsuite/libffi.call/cls_4_1byte.c Sun Jul 20 10:52:46 2014 -0400 @@ -56,15 +56,15 @@ ffi_type cls_struct_type; ffi_type* dbl_arg_types[5]; - struct cls_struct_4_1byte g_dbl = { 12, 13, 14, 15 }; - struct cls_struct_4_1byte f_dbl = { 178, 179, 180, 181 }; - struct cls_struct_4_1byte res_dbl; - cls_struct_type.size = 0; cls_struct_type.alignment = 0; cls_struct_type.type = FFI_TYPE_STRUCT; cls_struct_type.elements = cls_struct_fields; + struct cls_struct_4_1byte g_dbl = { 12, 13, 14, 15 }; + struct cls_struct_4_1byte f_dbl = { 178, 179, 180, 181 }; + struct cls_struct_4_1byte res_dbl; + cls_struct_fields[0] = &ffi_type_uchar; cls_struct_fields[1] = &ffi_type_uchar; cls_struct_fields[2] = &ffi_type_uchar; diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi/testsuite/libffi.call/cls_4byte.c --- a/Modules/_ctypes/libffi/testsuite/libffi.call/cls_4byte.c Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/_ctypes/libffi/testsuite/libffi.call/cls_4byte.c Sun Jul 20 10:52:46 2014 -0400 @@ -50,15 +50,15 @@ ffi_type cls_struct_type; ffi_type* dbl_arg_types[5]; - struct cls_struct_4byte g_dbl = { 127, 120 }; - struct cls_struct_4byte f_dbl = { 12, 128 }; - struct cls_struct_4byte res_dbl; - cls_struct_type.size = 0; cls_struct_type.alignment = 0; cls_struct_type.type = FFI_TYPE_STRUCT; cls_struct_type.elements = cls_struct_fields; + struct cls_struct_4byte g_dbl = { 127, 120 }; + struct cls_struct_4byte f_dbl = { 12, 128 }; + struct cls_struct_4byte res_dbl; + cls_struct_fields[0] = &ffi_type_ushort; cls_struct_fields[1] = &ffi_type_ushort; cls_struct_fields[2] = NULL; diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi/testsuite/libffi.call/cls_5_1_byte.c --- a/Modules/_ctypes/libffi/testsuite/libffi.call/cls_5_1_byte.c Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/_ctypes/libffi/testsuite/libffi.call/cls_5_1_byte.c Sun Jul 20 10:52:46 2014 -0400 @@ -58,15 +58,15 @@ ffi_type cls_struct_type; ffi_type* dbl_arg_types[5]; - struct cls_struct_5byte g_dbl = { 127, 120, 1, 3, 4 }; - struct cls_struct_5byte f_dbl = { 12, 128, 9, 3, 4 }; - struct cls_struct_5byte res_dbl = { 0, 0, 0, 0, 0 }; - cls_struct_type.size = 0; cls_struct_type.alignment = 0; cls_struct_type.type = FFI_TYPE_STRUCT; cls_struct_type.elements = cls_struct_fields; + struct cls_struct_5byte g_dbl = { 127, 120, 1, 3, 4 }; + struct cls_struct_5byte f_dbl = { 12, 128, 9, 3, 4 }; + struct cls_struct_5byte res_dbl = { 0, 0, 0, 0, 0 }; + cls_struct_fields[0] = &ffi_type_uchar; cls_struct_fields[1] = &ffi_type_uchar; cls_struct_fields[2] = &ffi_type_uchar; diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi/testsuite/libffi.call/cls_5byte.c --- a/Modules/_ctypes/libffi/testsuite/libffi.call/cls_5byte.c Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/_ctypes/libffi/testsuite/libffi.call/cls_5byte.c Sun Jul 20 10:52:46 2014 -0400 @@ -53,15 +53,15 @@ ffi_type cls_struct_type; ffi_type* dbl_arg_types[5]; - struct cls_struct_5byte g_dbl = { 127, 120, 1 }; - struct cls_struct_5byte f_dbl = { 12, 128, 9 }; - struct cls_struct_5byte res_dbl = { 0, 0, 0 }; - cls_struct_type.size = 0; cls_struct_type.alignment = 0; cls_struct_type.type = FFI_TYPE_STRUCT; cls_struct_type.elements = cls_struct_fields; + struct cls_struct_5byte g_dbl = { 127, 120, 1 }; + struct cls_struct_5byte f_dbl = { 12, 128, 9 }; + struct cls_struct_5byte res_dbl = { 0, 0, 0 }; + cls_struct_fields[0] = &ffi_type_ushort; cls_struct_fields[1] = &ffi_type_ushort; cls_struct_fields[2] = &ffi_type_uchar; diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi/testsuite/libffi.call/cls_64byte.c --- a/Modules/_ctypes/libffi/testsuite/libffi.call/cls_64byte.c Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/_ctypes/libffi/testsuite/libffi.call/cls_64byte.c Sun Jul 20 10:52:46 2014 -0400 @@ -66,17 +66,17 @@ ffi_type cls_struct_type; ffi_type* dbl_arg_types[5]; + cls_struct_type.size = 0; + cls_struct_type.alignment = 0; + cls_struct_type.type = FFI_TYPE_STRUCT; + cls_struct_type.elements = cls_struct_fields; + struct cls_struct_64byte e_dbl = { 9.0, 2.0, 6.0, 5.0, 3.0, 4.0, 8.0, 1.0 }; struct cls_struct_64byte f_dbl = { 1.0, 2.0, 3.0, 7.0, 2.0, 5.0, 6.0, 7.0 }; struct cls_struct_64byte g_dbl = { 4.0, 5.0, 7.0, 9.0, 1.0, 1.0, 2.0, 9.0 }; struct cls_struct_64byte h_dbl = { 8.0, 6.0, 1.0, 4.0, 0.0, 3.0, 3.0, 1.0 }; struct cls_struct_64byte res_dbl; - cls_struct_type.size = 0; - cls_struct_type.alignment = 0; - cls_struct_type.type = FFI_TYPE_STRUCT; - cls_struct_type.elements = cls_struct_fields; - cls_struct_fields[0] = &ffi_type_double; cls_struct_fields[1] = &ffi_type_double; cls_struct_fields[2] = &ffi_type_double; diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi/testsuite/libffi.call/cls_6_1_byte.c --- a/Modules/_ctypes/libffi/testsuite/libffi.call/cls_6_1_byte.c Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/_ctypes/libffi/testsuite/libffi.call/cls_6_1_byte.c Sun Jul 20 10:52:46 2014 -0400 @@ -60,15 +60,15 @@ ffi_type cls_struct_type; ffi_type* dbl_arg_types[5]; - struct cls_struct_6byte g_dbl = { 127, 120, 1, 3, 4, 5 }; - struct cls_struct_6byte f_dbl = { 12, 128, 9, 3, 4, 5 }; - struct cls_struct_6byte res_dbl = { 0, 0, 0, 0, 0, 0 }; - cls_struct_type.size = 0; cls_struct_type.alignment = 0; cls_struct_type.type = FFI_TYPE_STRUCT; cls_struct_type.elements = cls_struct_fields; + struct cls_struct_6byte g_dbl = { 127, 120, 1, 3, 4, 5 }; + struct cls_struct_6byte f_dbl = { 12, 128, 9, 3, 4, 5 }; + struct cls_struct_6byte res_dbl = { 0, 0, 0, 0, 0, 0 }; + cls_struct_fields[0] = &ffi_type_uchar; cls_struct_fields[1] = &ffi_type_uchar; cls_struct_fields[2] = &ffi_type_uchar; diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi/testsuite/libffi.call/cls_6byte.c --- a/Modules/_ctypes/libffi/testsuite/libffi.call/cls_6byte.c Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/_ctypes/libffi/testsuite/libffi.call/cls_6byte.c Sun Jul 20 10:52:46 2014 -0400 @@ -56,15 +56,15 @@ ffi_type cls_struct_type; ffi_type* dbl_arg_types[5]; - struct cls_struct_6byte g_dbl = { 127, 120, 1, 128 }; - struct cls_struct_6byte f_dbl = { 12, 128, 9, 127 }; - struct cls_struct_6byte res_dbl; - cls_struct_type.size = 0; cls_struct_type.alignment = 0; cls_struct_type.type = FFI_TYPE_STRUCT; cls_struct_type.elements = cls_struct_fields; + struct cls_struct_6byte g_dbl = { 127, 120, 1, 128 }; + struct cls_struct_6byte f_dbl = { 12, 128, 9, 127 }; + struct cls_struct_6byte res_dbl; + cls_struct_fields[0] = &ffi_type_ushort; cls_struct_fields[1] = &ffi_type_ushort; cls_struct_fields[2] = &ffi_type_uchar; diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi/testsuite/libffi.call/cls_7_1_byte.c --- a/Modules/_ctypes/libffi/testsuite/libffi.call/cls_7_1_byte.c Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/_ctypes/libffi/testsuite/libffi.call/cls_7_1_byte.c Sun Jul 20 10:52:46 2014 -0400 @@ -62,15 +62,15 @@ ffi_type cls_struct_type; ffi_type* dbl_arg_types[5]; - struct cls_struct_7byte g_dbl = { 127, 120, 1, 3, 4, 5, 6 }; - struct cls_struct_7byte f_dbl = { 12, 128, 9, 3, 4, 5, 6 }; - struct cls_struct_7byte res_dbl = { 0, 0, 0, 0, 0, 0, 0 }; - cls_struct_type.size = 0; cls_struct_type.alignment = 0; cls_struct_type.type = FFI_TYPE_STRUCT; cls_struct_type.elements = cls_struct_fields; + struct cls_struct_7byte g_dbl = { 127, 120, 1, 3, 4, 5, 6 }; + struct cls_struct_7byte f_dbl = { 12, 128, 9, 3, 4, 5, 6 }; + struct cls_struct_7byte res_dbl = { 0, 0, 0, 0, 0, 0, 0 }; + cls_struct_fields[0] = &ffi_type_uchar; cls_struct_fields[1] = &ffi_type_uchar; cls_struct_fields[2] = &ffi_type_uchar; diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi/testsuite/libffi.call/cls_7byte.c --- a/Modules/_ctypes/libffi/testsuite/libffi.call/cls_7byte.c Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/_ctypes/libffi/testsuite/libffi.call/cls_7byte.c Sun Jul 20 10:52:46 2014 -0400 @@ -55,15 +55,15 @@ ffi_type cls_struct_type; ffi_type* dbl_arg_types[5]; - struct cls_struct_7byte g_dbl = { 127, 120, 1, 254 }; - struct cls_struct_7byte f_dbl = { 12, 128, 9, 255 }; - struct cls_struct_7byte res_dbl; - cls_struct_type.size = 0; cls_struct_type.alignment = 0; cls_struct_type.type = FFI_TYPE_STRUCT; cls_struct_type.elements = cls_struct_fields; + struct cls_struct_7byte g_dbl = { 127, 120, 1, 254 }; + struct cls_struct_7byte f_dbl = { 12, 128, 9, 255 }; + struct cls_struct_7byte res_dbl; + cls_struct_fields[0] = &ffi_type_ushort; cls_struct_fields[1] = &ffi_type_ushort; cls_struct_fields[2] = &ffi_type_uchar; diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi/testsuite/libffi.call/cls_8byte.c --- a/Modules/_ctypes/libffi/testsuite/libffi.call/cls_8byte.c Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/_ctypes/libffi/testsuite/libffi.call/cls_8byte.c Sun Jul 20 10:52:46 2014 -0400 @@ -49,15 +49,15 @@ ffi_type cls_struct_type; ffi_type* dbl_arg_types[5]; - struct cls_struct_8byte g_dbl = { 1, 2.0 }; - struct cls_struct_8byte f_dbl = { 4, 5.0 }; - struct cls_struct_8byte res_dbl; - cls_struct_type.size = 0; cls_struct_type.alignment = 0; cls_struct_type.type = FFI_TYPE_STRUCT; cls_struct_type.elements = cls_struct_fields; + struct cls_struct_8byte g_dbl = { 1, 2.0 }; + struct cls_struct_8byte f_dbl = { 4, 5.0 }; + struct cls_struct_8byte res_dbl; + cls_struct_fields[0] = &ffi_type_sint; cls_struct_fields[1] = &ffi_type_float; cls_struct_fields[2] = NULL; diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi/testsuite/libffi.call/cls_9byte1.c --- a/Modules/_ctypes/libffi/testsuite/libffi.call/cls_9byte1.c Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/_ctypes/libffi/testsuite/libffi.call/cls_9byte1.c Sun Jul 20 10:52:46 2014 -0400 @@ -50,15 +50,15 @@ ffi_type cls_struct_type; ffi_type* dbl_arg_types[3]; - struct cls_struct_9byte h_dbl = { 7, 8.0}; - struct cls_struct_9byte j_dbl = { 1, 9.0}; - struct cls_struct_9byte res_dbl; - cls_struct_type.size = 0; cls_struct_type.alignment = 0; cls_struct_type.type = FFI_TYPE_STRUCT; cls_struct_type.elements = cls_struct_fields; + struct cls_struct_9byte h_dbl = { 7, 8.0}; + struct cls_struct_9byte j_dbl = { 1, 9.0}; + struct cls_struct_9byte res_dbl; + cls_struct_fields[0] = &ffi_type_sint; cls_struct_fields[1] = &ffi_type_double; cls_struct_fields[2] = NULL; diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi/testsuite/libffi.call/cls_9byte2.c --- a/Modules/_ctypes/libffi/testsuite/libffi.call/cls_9byte2.c Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/_ctypes/libffi/testsuite/libffi.call/cls_9byte2.c Sun Jul 20 10:52:46 2014 -0400 @@ -50,15 +50,15 @@ ffi_type cls_struct_type; ffi_type* dbl_arg_types[3]; - struct cls_struct_9byte h_dbl = { 7.0, 8}; - struct cls_struct_9byte j_dbl = { 1.0, 9}; - struct cls_struct_9byte res_dbl; - cls_struct_type.size = 0; cls_struct_type.alignment = 0; cls_struct_type.type = FFI_TYPE_STRUCT; cls_struct_type.elements = cls_struct_fields; + struct cls_struct_9byte h_dbl = { 7.0, 8}; + struct cls_struct_9byte j_dbl = { 1.0, 9}; + struct cls_struct_9byte res_dbl; + cls_struct_fields[0] = &ffi_type_double; cls_struct_fields[1] = &ffi_type_sint; cls_struct_fields[2] = NULL; diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi/testsuite/libffi.call/cls_align_double.c --- a/Modules/_ctypes/libffi/testsuite/libffi.call/cls_align_double.c Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/_ctypes/libffi/testsuite/libffi.call/cls_align_double.c Sun Jul 20 10:52:46 2014 -0400 @@ -52,15 +52,15 @@ ffi_type cls_struct_type; ffi_type* dbl_arg_types[5]; - struct cls_struct_align g_dbl = { 12, 4951, 127 }; - struct cls_struct_align f_dbl = { 1, 9320, 13 }; - struct cls_struct_align res_dbl; - cls_struct_type.size = 0; cls_struct_type.alignment = 0; cls_struct_type.type = FFI_TYPE_STRUCT; cls_struct_type.elements = cls_struct_fields; + struct cls_struct_align g_dbl = { 12, 4951, 127 }; + struct cls_struct_align f_dbl = { 1, 9320, 13 }; + struct cls_struct_align res_dbl; + cls_struct_fields[0] = &ffi_type_uchar; cls_struct_fields[1] = &ffi_type_double; cls_struct_fields[2] = &ffi_type_uchar; diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi/testsuite/libffi.call/cls_align_float.c --- a/Modules/_ctypes/libffi/testsuite/libffi.call/cls_align_float.c Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/_ctypes/libffi/testsuite/libffi.call/cls_align_float.c Sun Jul 20 10:52:46 2014 -0400 @@ -50,15 +50,15 @@ ffi_type cls_struct_type; ffi_type* dbl_arg_types[5]; - struct cls_struct_align g_dbl = { 12, 4951, 127 }; - struct cls_struct_align f_dbl = { 1, 9320, 13 }; - struct cls_struct_align res_dbl; - cls_struct_type.size = 0; cls_struct_type.alignment = 0; cls_struct_type.type = FFI_TYPE_STRUCT; cls_struct_type.elements = cls_struct_fields; + struct cls_struct_align g_dbl = { 12, 4951, 127 }; + struct cls_struct_align f_dbl = { 1, 9320, 13 }; + struct cls_struct_align res_dbl; + cls_struct_fields[0] = &ffi_type_uchar; cls_struct_fields[1] = &ffi_type_float; cls_struct_fields[2] = &ffi_type_uchar; diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi/testsuite/libffi.call/cls_align_longdouble.c --- a/Modules/_ctypes/libffi/testsuite/libffi.call/cls_align_longdouble.c Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/_ctypes/libffi/testsuite/libffi.call/cls_align_longdouble.c Sun Jul 20 10:52:46 2014 -0400 @@ -51,15 +51,15 @@ ffi_type cls_struct_type; ffi_type* dbl_arg_types[5]; - struct cls_struct_align g_dbl = { 12, 4951, 127 }; - struct cls_struct_align f_dbl = { 1, 9320, 13 }; - struct cls_struct_align res_dbl; - cls_struct_type.size = 0; cls_struct_type.alignment = 0; cls_struct_type.type = FFI_TYPE_STRUCT; cls_struct_type.elements = cls_struct_fields; + struct cls_struct_align g_dbl = { 12, 4951, 127 }; + struct cls_struct_align f_dbl = { 1, 9320, 13 }; + struct cls_struct_align res_dbl; + cls_struct_fields[0] = &ffi_type_uchar; cls_struct_fields[1] = &ffi_type_longdouble; cls_struct_fields[2] = &ffi_type_uchar; diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi/testsuite/libffi.call/cls_align_longdouble_split.c --- a/Modules/_ctypes/libffi/testsuite/libffi.call/cls_align_longdouble_split.c Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/_ctypes/libffi/testsuite/libffi.call/cls_align_longdouble_split.c Sun Jul 20 10:52:46 2014 -0400 @@ -6,7 +6,7 @@ /* { dg-excess-errors "no long double format" { xfail x86_64-*-mingw* x86_64-*-cygwin* } } */ /* { dg-do run { xfail strongarm*-*-* xscale*-*-* } } */ -/* { dg-options -mlong-double-128 { target powerpc64*-*-linux* } } */ +/* { dg-options -mlong-double-128 { target powerpc64*-*-* } } */ /* { dg-output "" { xfail x86_64-*-mingw* x86_64-*-cygwin* } } */ #include "ffitest.h" @@ -87,15 +87,15 @@ ffi_type cls_struct_type; ffi_type* dbl_arg_types[3]; - struct cls_struct_align g_dbl = { 1, 2, 3, 4, 5, 6, 7 }; - struct cls_struct_align f_dbl = { 8, 9, 10, 11, 12, 13, 14 }; - struct cls_struct_align res_dbl; - cls_struct_type.size = 0; cls_struct_type.alignment = 0; cls_struct_type.type = FFI_TYPE_STRUCT; cls_struct_type.elements = cls_struct_fields; + struct cls_struct_align g_dbl = { 1, 2, 3, 4, 5, 6, 7 }; + struct cls_struct_align f_dbl = { 8, 9, 10, 11, 12, 13, 14 }; + struct cls_struct_align res_dbl; + cls_struct_fields[0] = &ffi_type_longdouble; cls_struct_fields[1] = &ffi_type_longdouble; cls_struct_fields[2] = &ffi_type_longdouble; diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi/testsuite/libffi.call/cls_align_longdouble_split2.c --- a/Modules/_ctypes/libffi/testsuite/libffi.call/cls_align_longdouble_split2.c Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/_ctypes/libffi/testsuite/libffi.call/cls_align_longdouble_split2.c Sun Jul 20 10:52:46 2014 -0400 @@ -7,7 +7,7 @@ /* { dg-excess-errors "no long double format" { xfail x86_64-*-mingw* x86_64-*-cygwin* } } */ /* { dg-do run { xfail strongarm*-*-* } } */ -/* { dg-options -mlong-double-128 { target powerpc64*-*-linux* } } */ +/* { dg-options -mlong-double-128 { target powerpc64*-*-* } } */ /* { dg-output "" { xfail x86_64-*-mingw* x86_64-*-cygwin* } } */ #include "ffitest.h" @@ -67,15 +67,15 @@ ffi_type cls_struct_type; ffi_type* dbl_arg_types[3]; - struct cls_struct_align g_dbl = { 1, 2, 3, 4, 5, 6, 7 }; - struct cls_struct_align f_dbl = { 8, 9, 10, 11, 12, 13, 14 }; - struct cls_struct_align res_dbl; - cls_struct_type.size = 0; cls_struct_type.alignment = 0; cls_struct_type.type = FFI_TYPE_STRUCT; cls_struct_type.elements = cls_struct_fields; + struct cls_struct_align g_dbl = { 1, 2, 3, 4, 5, 6, 7 }; + struct cls_struct_align f_dbl = { 8, 9, 10, 11, 12, 13, 14 }; + struct cls_struct_align res_dbl; + cls_struct_fields[0] = &ffi_type_longdouble; cls_struct_fields[1] = &ffi_type_longdouble; cls_struct_fields[2] = &ffi_type_longdouble; diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi/testsuite/libffi.call/cls_align_pointer.c --- a/Modules/_ctypes/libffi/testsuite/libffi.call/cls_align_pointer.c Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/_ctypes/libffi/testsuite/libffi.call/cls_align_pointer.c Sun Jul 20 10:52:46 2014 -0400 @@ -54,15 +54,15 @@ ffi_type cls_struct_type; ffi_type* dbl_arg_types[5]; - struct cls_struct_align g_dbl = { 12, (void *)4951, 127 }; - struct cls_struct_align f_dbl = { 1, (void *)9320, 13 }; - struct cls_struct_align res_dbl; - cls_struct_type.size = 0; cls_struct_type.alignment = 0; cls_struct_type.type = FFI_TYPE_STRUCT; cls_struct_type.elements = cls_struct_fields; + struct cls_struct_align g_dbl = { 12, (void *)4951, 127 }; + struct cls_struct_align f_dbl = { 1, (void *)9320, 13 }; + struct cls_struct_align res_dbl; + cls_struct_fields[0] = &ffi_type_uchar; cls_struct_fields[1] = &ffi_type_pointer; cls_struct_fields[2] = &ffi_type_uchar; diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi/testsuite/libffi.call/cls_align_sint16.c --- a/Modules/_ctypes/libffi/testsuite/libffi.call/cls_align_sint16.c Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/_ctypes/libffi/testsuite/libffi.call/cls_align_sint16.c Sun Jul 20 10:52:46 2014 -0400 @@ -50,15 +50,15 @@ ffi_type cls_struct_type; ffi_type* dbl_arg_types[5]; - struct cls_struct_align g_dbl = { 12, 4951, 127 }; - struct cls_struct_align f_dbl = { 1, 9320, 13 }; - struct cls_struct_align res_dbl; - cls_struct_type.size = 0; cls_struct_type.alignment = 0; cls_struct_type.type = FFI_TYPE_STRUCT; cls_struct_type.elements = cls_struct_fields; + struct cls_struct_align g_dbl = { 12, 4951, 127 }; + struct cls_struct_align f_dbl = { 1, 9320, 13 }; + struct cls_struct_align res_dbl; + cls_struct_fields[0] = &ffi_type_uchar; cls_struct_fields[1] = &ffi_type_sshort; cls_struct_fields[2] = &ffi_type_uchar; diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi/testsuite/libffi.call/cls_align_sint32.c --- a/Modules/_ctypes/libffi/testsuite/libffi.call/cls_align_sint32.c Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/_ctypes/libffi/testsuite/libffi.call/cls_align_sint32.c Sun Jul 20 10:52:46 2014 -0400 @@ -50,15 +50,15 @@ ffi_type cls_struct_type; ffi_type* dbl_arg_types[5]; - struct cls_struct_align g_dbl = { 12, 4951, 127 }; - struct cls_struct_align f_dbl = { 1, 9320, 13 }; - struct cls_struct_align res_dbl; - cls_struct_type.size = 0; cls_struct_type.alignment = 0; cls_struct_type.type = FFI_TYPE_STRUCT; cls_struct_type.elements = cls_struct_fields; + struct cls_struct_align g_dbl = { 12, 4951, 127 }; + struct cls_struct_align f_dbl = { 1, 9320, 13 }; + struct cls_struct_align res_dbl; + cls_struct_fields[0] = &ffi_type_uchar; cls_struct_fields[1] = &ffi_type_sint; cls_struct_fields[2] = &ffi_type_uchar; diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi/testsuite/libffi.call/cls_align_sint64.c --- a/Modules/_ctypes/libffi/testsuite/libffi.call/cls_align_sint64.c Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/_ctypes/libffi/testsuite/libffi.call/cls_align_sint64.c Sun Jul 20 10:52:46 2014 -0400 @@ -51,15 +51,15 @@ ffi_type cls_struct_type; ffi_type* dbl_arg_types[5]; - struct cls_struct_align g_dbl = { 12, 4951, 127 }; - struct cls_struct_align f_dbl = { 1, 9320, 13 }; - struct cls_struct_align res_dbl; - cls_struct_type.size = 0; cls_struct_type.alignment = 0; cls_struct_type.type = FFI_TYPE_STRUCT; cls_struct_type.elements = cls_struct_fields; + struct cls_struct_align g_dbl = { 12, 4951, 127 }; + struct cls_struct_align f_dbl = { 1, 9320, 13 }; + struct cls_struct_align res_dbl; + cls_struct_fields[0] = &ffi_type_uchar; cls_struct_fields[1] = &ffi_type_sint64; cls_struct_fields[2] = &ffi_type_uchar; diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi/testsuite/libffi.call/cls_align_uint16.c --- a/Modules/_ctypes/libffi/testsuite/libffi.call/cls_align_uint16.c Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/_ctypes/libffi/testsuite/libffi.call/cls_align_uint16.c Sun Jul 20 10:52:46 2014 -0400 @@ -50,15 +50,15 @@ ffi_type cls_struct_type; ffi_type* dbl_arg_types[5]; - struct cls_struct_align g_dbl = { 12, 4951, 127 }; - struct cls_struct_align f_dbl = { 1, 9320, 13 }; - struct cls_struct_align res_dbl; - cls_struct_type.size = 0; cls_struct_type.alignment = 0; cls_struct_type.type = FFI_TYPE_STRUCT; cls_struct_type.elements = cls_struct_fields; + struct cls_struct_align g_dbl = { 12, 4951, 127 }; + struct cls_struct_align f_dbl = { 1, 9320, 13 }; + struct cls_struct_align res_dbl; + cls_struct_fields[0] = &ffi_type_uchar; cls_struct_fields[1] = &ffi_type_ushort; cls_struct_fields[2] = &ffi_type_uchar; diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi/testsuite/libffi.call/cls_align_uint32.c --- a/Modules/_ctypes/libffi/testsuite/libffi.call/cls_align_uint32.c Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/_ctypes/libffi/testsuite/libffi.call/cls_align_uint32.c Sun Jul 20 10:52:46 2014 -0400 @@ -50,15 +50,15 @@ ffi_type cls_struct_type; ffi_type* dbl_arg_types[5]; - struct cls_struct_align g_dbl = { 12, 4951, 127 }; - struct cls_struct_align f_dbl = { 1, 9320, 13 }; - struct cls_struct_align res_dbl; - cls_struct_type.size = 0; cls_struct_type.alignment = 0; cls_struct_type.type = FFI_TYPE_STRUCT; cls_struct_type.elements = cls_struct_fields; + struct cls_struct_align g_dbl = { 12, 4951, 127 }; + struct cls_struct_align f_dbl = { 1, 9320, 13 }; + struct cls_struct_align res_dbl; + cls_struct_fields[0] = &ffi_type_uchar; cls_struct_fields[1] = &ffi_type_uint; cls_struct_fields[2] = &ffi_type_uchar; diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi/testsuite/libffi.call/cls_align_uint64.c --- a/Modules/_ctypes/libffi/testsuite/libffi.call/cls_align_uint64.c Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/_ctypes/libffi/testsuite/libffi.call/cls_align_uint64.c Sun Jul 20 10:52:46 2014 -0400 @@ -52,15 +52,15 @@ ffi_type cls_struct_type; ffi_type* dbl_arg_types[5]; - struct cls_struct_align g_dbl = { 12, 4951, 127 }; - struct cls_struct_align f_dbl = { 1, 9320, 13 }; - struct cls_struct_align res_dbl; - cls_struct_type.size = 0; cls_struct_type.alignment = 0; cls_struct_type.type = FFI_TYPE_STRUCT; cls_struct_type.elements = cls_struct_fields; + struct cls_struct_align g_dbl = { 12, 4951, 127 }; + struct cls_struct_align f_dbl = { 1, 9320, 13 }; + struct cls_struct_align res_dbl; + cls_struct_fields[0] = &ffi_type_uchar; cls_struct_fields[1] = &ffi_type_uint64; cls_struct_fields[2] = &ffi_type_uchar; diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi/testsuite/libffi.call/cls_dbls_struct.c --- a/Modules/_ctypes/libffi/testsuite/libffi.call/cls_dbls_struct.c Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/_ctypes/libffi/testsuite/libffi.call/cls_dbls_struct.c Sun Jul 20 10:52:46 2014 -0400 @@ -37,8 +37,6 @@ ffi_type ts1_type; ffi_type* ts1_type_elements[4]; - Dbls arg = { 1.0, 2.0 }; - ts1_type.size = 0; ts1_type.alignment = 0; ts1_type.type = FFI_TYPE_STRUCT; @@ -50,6 +48,8 @@ cl_arg_types[0] = &ts1_type; + Dbls arg = { 1.0, 2.0 }; + /* Initialize the cif */ CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 1, &ffi_type_void, cl_arg_types) == FFI_OK); diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi/testsuite/libffi.call/cls_double_va.c --- a/Modules/_ctypes/libffi/testsuite/libffi.call/cls_double_va.c Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/_ctypes/libffi/testsuite/libffi.call/cls_double_va.c Sun Jul 20 10:52:46 2014 -0400 @@ -6,8 +6,6 @@ /* { dg-do run { xfail strongarm*-*-* xscale*-*-* } } */ /* { dg-output "" { xfail avr32*-*-* } } */ -/* { dg-output "" { xfail mips-sgi-irix6* } } PR libffi/46660 */ - #include "ffitest.h" static void @@ -36,8 +34,7 @@ arg_types[1] = &ffi_type_double; arg_types[2] = NULL; - /* This printf call is variadic */ - CHECK(ffi_prep_cif_var(&cif, FFI_DEFAULT_ABI, 1, 2, &ffi_type_sint, + CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 2, &ffi_type_sint, arg_types) == FFI_OK); args[0] = &format; @@ -45,19 +42,16 @@ args[2] = NULL; ffi_call(&cif, FFI_FN(printf), &res, args); - /* { dg-output "7.0" } */ + // { dg-output "7.0" } printf("res: %d\n", (int) res); - /* { dg-output "\nres: 4" } */ - - /* The call to cls_double_va_fn is static, so have to use a normal prep_cif */ - CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 2, &ffi_type_sint, arg_types) == FFI_OK); + // { dg-output "\nres: 4" } CHECK(ffi_prep_closure_loc(pcl, &cif, cls_double_va_fn, NULL, code) == FFI_OK); res = ((int(*)(char*, double))(code))(format, doubleArg); - /* { dg-output "\n7.0" } */ + // { dg-output "\n7.0" } printf("res: %d\n", (int) res); - /* { dg-output "\nres: 4" } */ + // { dg-output "\nres: 4" } exit(0); } diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi/testsuite/libffi.call/cls_longdouble.c --- a/Modules/_ctypes/libffi/testsuite/libffi.call/cls_longdouble.c Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/_ctypes/libffi/testsuite/libffi.call/cls_longdouble.c Sun Jul 20 10:52:46 2014 -0400 @@ -5,10 +5,8 @@ Originator: Blake Chaffin */ /* { dg-excess-errors "no long double format" { xfail x86_64-*-mingw* x86_64-*-cygwin* } } */ -/* This test is known to PASS on armv7l-unknown-linux-gnueabihf, so I have - remove the xfail for arm*-*-* below, until we know more. */ -/* { dg-do run { xfail strongarm*-*-* xscale*-*-* } } */ -/* { dg-options -mlong-double-128 { target powerpc64*-*-linux* } } */ +/* { dg-do run { xfail arm*-*-* strongarm*-*-* xscale*-*-* } } */ +/* { dg-options -mlong-double-128 { target powerpc64*-*-* } } */ /* { dg-output "" { xfail x86_64-*-mingw* x86_64-*-cygwin* } } */ #include "ffitest.h" diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi/testsuite/libffi.call/cls_longdouble_va.c --- a/Modules/_ctypes/libffi/testsuite/libffi.call/cls_longdouble_va.c Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/_ctypes/libffi/testsuite/libffi.call/cls_longdouble_va.c Sun Jul 20 10:52:46 2014 -0400 @@ -6,8 +6,6 @@ /* { dg-do run { xfail strongarm*-*-* xscale*-*-* } } */ /* { dg-output "" { xfail avr32*-*-* x86_64-*-mingw* } } */ -/* { dg-output "" { xfail mips-sgi-irix6* } } PR libffi/46660 */ - #include "ffitest.h" static void @@ -36,8 +34,7 @@ arg_types[1] = &ffi_type_longdouble; arg_types[2] = NULL; - /* This printf call is variadic */ - CHECK(ffi_prep_cif_var(&cif, FFI_DEFAULT_ABI, 1, 2, &ffi_type_sint, + CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 2, &ffi_type_sint, arg_types) == FFI_OK); args[0] = &format; @@ -45,20 +42,16 @@ args[2] = NULL; ffi_call(&cif, FFI_FN(printf), &res, args); - /* { dg-output "7.0" } */ + // { dg-output "7.0" } printf("res: %d\n", (int) res); - /* { dg-output "\nres: 4" } */ - - /* The call to cls_longdouble_va_fn is static, so have to use a normal prep_cif */ - CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 2, &ffi_type_sint, - arg_types) == FFI_OK); + // { dg-output "\nres: 4" } CHECK(ffi_prep_closure_loc(pcl, &cif, cls_longdouble_va_fn, NULL, code) == FFI_OK); res = ((int(*)(char*, long double))(code))(format, ldArg); - /* { dg-output "\n7.0" } */ + // { dg-output "\n7.0" } printf("res: %d\n", (int) res); - /* { dg-output "\nres: 4" } */ + // { dg-output "\nres: 4" } exit(0); } diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi/testsuite/libffi.call/cls_pointer.c --- a/Modules/_ctypes/libffi/testsuite/libffi.call/cls_pointer.c Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/_ctypes/libffi/testsuite/libffi.call/cls_pointer.c Sun Jul 20 10:52:46 2014 -0400 @@ -35,7 +35,7 @@ void *code; ffi_closure* pcl = ffi_closure_alloc(sizeof(ffi_closure), &code); void* args[3]; - /* ffi_type cls_pointer_type; */ +// ffi_type cls_pointer_type; ffi_type* arg_types[3]; /* cls_pointer_type.size = sizeof(void*); @@ -65,7 +65,7 @@ CHECK(ffi_prep_closure_loc(pcl, &cif, cls_pointer_gn, NULL, code) == FFI_OK); - res = (ffi_arg)(uintptr_t)((void*(*)(void*, void*))(code))(arg1, arg2); + res = (ffi_arg)((void*(*)(void*, void*))(code))(arg1, arg2); /* { dg-output "\n0x12345678 0x89abcdef: 0x9be02467" } */ printf("res: 0x%08x\n", (unsigned int) res); /* { dg-output "\nres: 0x9be02467" } */ diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi/testsuite/libffi.call/cls_pointer_stack.c --- a/Modules/_ctypes/libffi/testsuite/libffi.call/cls_pointer_stack.c Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/_ctypes/libffi/testsuite/libffi.call/cls_pointer_stack.c Sun Jul 20 10:52:46 2014 -0400 @@ -28,12 +28,11 @@ char trample6 = trample4 + ((char*)&a2)[1]; long double trample7 = (intptr_t)trample5 + (intptr_t)trample1; char trample8 = trample6 + trample2; - void* result; dummyVar = dummy_func(trample1, trample2, trample3, trample4, trample5, trample6, trample7, trample8); - result = (void*)((intptr_t)a1 + (intptr_t)a2); + void* result = (void*)((intptr_t)a1 + (intptr_t)a2); printf("0x%08x 0x%08x: 0x%08x\n", (unsigned int)(uintptr_t) a1, @@ -53,12 +52,11 @@ char trample6 = trample4 + ((char*)&a2)[1]; long double trample7 = (intptr_t)trample5 + (intptr_t)trample1; char trample8 = trample6 + trample2; - void* result; dummyVar = dummy_func(trample1, trample2, trample3, trample4, trample5, trample6, trample7, trample8); - result = (void*)((intptr_t)a1 + (intptr_t)a2); + void* result = (void*)((intptr_t)a1 + (intptr_t)a2); printf("0x%08x 0x%08x: 0x%08x\n", (unsigned int)(intptr_t) a1, @@ -98,7 +96,7 @@ void *code; ffi_closure* pcl = ffi_closure_alloc(sizeof(ffi_closure), &code); void* args[3]; - /* ffi_type cls_pointer_type; */ +// ffi_type cls_pointer_type; ffi_type* arg_types[3]; /* cls_pointer_type.size = sizeof(void*); @@ -125,18 +123,18 @@ ffi_call(&cif, FFI_FN(cls_pointer_fn1), &res, args); printf("res: 0x%08x\n", (unsigned int) res); - /* { dg-output "\n0x01234567 0x89abcdef: 0x8acf1356" } */ - /* { dg-output "\n0x8acf1356 0x01234567: 0x8bf258bd" } */ - /* { dg-output "\nres: 0x8bf258bd" } */ + // { dg-output "\n0x01234567 0x89abcdef: 0x8acf1356" } + // { dg-output "\n0x8acf1356 0x01234567: 0x8bf258bd" } + // { dg-output "\nres: 0x8bf258bd" } CHECK(ffi_prep_closure_loc(pcl, &cif, cls_pointer_gn, NULL, code) == FFI_OK); - res = (ffi_arg)(uintptr_t)((void*(*)(void*, void*))(code))(arg1, arg2); + res = (ffi_arg)((void*(*)(void*, void*))(code))(arg1, arg2); printf("res: 0x%08x\n", (unsigned int) res); - /* { dg-output "\n0x01234567 0x89abcdef: 0x8acf1356" } */ - /* { dg-output "\n0x8acf1356 0x01234567: 0x8bf258bd" } */ - /* { dg-output "\nres: 0x8bf258bd" } */ + // { dg-output "\n0x01234567 0x89abcdef: 0x8acf1356" } + // { dg-output "\n0x8acf1356 0x01234567: 0x8bf258bd" } + // { dg-output "\nres: 0x8bf258bd" } exit(0); } diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi/testsuite/libffi.call/cls_struct_va1.c --- a/Modules/_ctypes/libffi/testsuite/libffi.call/cls_struct_va1.c Sat Jul 19 16:34:33 2014 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,114 +0,0 @@ -/* Area: ffi_call, closure_call - Purpose: Test doubles passed in variable argument lists. - Limitations: none. - PR: none. - Originator: Blake Chaffin 6/6/2007 */ - -/* { dg-do run } */ -/* { dg-output "" { xfail avr32*-*-* } } */ -#include "ffitest.h" - -struct small_tag -{ - unsigned char a; - unsigned char b; -}; - -struct large_tag -{ - unsigned a; - unsigned b; - unsigned c; - unsigned d; - unsigned e; -}; - -static void -test_fn (ffi_cif* cif __UNUSED__, void* resp, - void** args, void* userdata __UNUSED__) -{ - int n = *(int*)args[0]; - struct small_tag s1 = * (struct small_tag *) args[1]; - struct large_tag l1 = * (struct large_tag *) args[2]; - struct small_tag s2 = * (struct small_tag *) args[3]; - - printf ("%d %d %d %d %d %d %d %d %d %d\n", n, s1.a, s1.b, - l1.a, l1.b, l1.c, l1.d, l1.e, - s2.a, s2.b); - * (int*) resp = 42; -} - -int -main (void) -{ - ffi_cif cif; - void *code; - ffi_closure *pcl = ffi_closure_alloc (sizeof (ffi_closure), &code); - ffi_type* arg_types[5]; - - ffi_arg res = 0; - - ffi_type s_type; - ffi_type *s_type_elements[3]; - - ffi_type l_type; - ffi_type *l_type_elements[6]; - - struct small_tag s1; - struct small_tag s2; - struct large_tag l1; - - int si; - - s_type.size = 0; - s_type.alignment = 0; - s_type.type = FFI_TYPE_STRUCT; - s_type.elements = s_type_elements; - - s_type_elements[0] = &ffi_type_uchar; - s_type_elements[1] = &ffi_type_uchar; - s_type_elements[2] = NULL; - - l_type.size = 0; - l_type.alignment = 0; - l_type.type = FFI_TYPE_STRUCT; - l_type.elements = l_type_elements; - - l_type_elements[0] = &ffi_type_uint; - l_type_elements[1] = &ffi_type_uint; - l_type_elements[2] = &ffi_type_uint; - l_type_elements[3] = &ffi_type_uint; - l_type_elements[4] = &ffi_type_uint; - l_type_elements[5] = NULL; - - arg_types[0] = &ffi_type_sint; - arg_types[1] = &s_type; - arg_types[2] = &l_type; - arg_types[3] = &s_type; - arg_types[4] = NULL; - - CHECK(ffi_prep_cif_var(&cif, FFI_DEFAULT_ABI, 1, 4, &ffi_type_sint, - arg_types) == FFI_OK); - - si = 4; - s1.a = 5; - s1.b = 6; - - s2.a = 20; - s2.b = 21; - - l1.a = 10; - l1.b = 11; - l1.c = 12; - l1.d = 13; - l1.e = 14; - - CHECK(ffi_prep_closure_loc(pcl, &cif, test_fn, NULL, code) == FFI_OK); - - res = ((int (*)(int, ...))(code))(si, s1, l1, s2); - /* { dg-output "4 5 6 10 11 12 13 14 20 21" } */ - printf("res: %d\n", (int) res); - /* { dg-output "\nres: 42" } */ - - exit(0); -} diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi/testsuite/libffi.call/cls_uchar_va.c --- a/Modules/_ctypes/libffi/testsuite/libffi.call/cls_uchar_va.c Sat Jul 19 16:34:33 2014 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,44 +0,0 @@ -/* Area: closure_call - Purpose: Test anonymous unsigned char argument. - Limitations: none. - PR: none. - Originator: ARM Ltd. */ - -/* { dg-do run } */ -#include "ffitest.h" - -typedef unsigned char T; - -static void cls_ret_T_fn(ffi_cif* cif __UNUSED__, void* resp, void** args, - void* userdata __UNUSED__) - { - *(ffi_arg *)resp = *(T *)args[0]; - - printf("%d: %d %d\n", (int)(*(ffi_arg *)resp), *(T *)args[0], *(T *)args[1]); - } - -typedef T (*cls_ret_T)(T, ...); - -int main (void) -{ - ffi_cif cif; - void *code; - ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code); - ffi_type * cl_arg_types[3]; - T res; - - cl_arg_types[0] = &ffi_type_uchar; - cl_arg_types[1] = &ffi_type_uchar; - cl_arg_types[2] = NULL; - - /* Initialize the cif */ - CHECK(ffi_prep_cif_var(&cif, FFI_DEFAULT_ABI, 1, 2, - &ffi_type_uchar, cl_arg_types) == FFI_OK); - - CHECK(ffi_prep_closure_loc(pcl, &cif, cls_ret_T_fn, NULL, code) == FFI_OK); - res = ((((cls_ret_T)code)(67, 4))); - /* { dg-output "67: 67 4" } */ - printf("res: %d\n", res); - /* { dg-output "\nres: 67" } */ - exit(0); -} diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi/testsuite/libffi.call/cls_uint_va.c --- a/Modules/_ctypes/libffi/testsuite/libffi.call/cls_uint_va.c Sat Jul 19 16:34:33 2014 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,45 +0,0 @@ -/* Area: closure_call - Purpose: Test anonymous unsigned int argument. - Limitations: none. - PR: none. - Originator: ARM Ltd. */ - -/* { dg-do run } */ - -#include "ffitest.h" - -typedef unsigned int T; - -static void cls_ret_T_fn(ffi_cif* cif __UNUSED__, void* resp, void** args, - void* userdata __UNUSED__) - { - *(T *)resp = *(T *)args[0]; - - printf("%d: %d %d\n", *(T *)resp, *(T *)args[0], *(T *)args[1]); - } - -typedef T (*cls_ret_T)(T, ...); - -int main (void) -{ - ffi_cif cif; - void *code; - ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code); - ffi_type * cl_arg_types[3]; - T res; - - cl_arg_types[0] = &ffi_type_uint; - cl_arg_types[1] = &ffi_type_uint; - cl_arg_types[2] = NULL; - - /* Initialize the cif */ - CHECK(ffi_prep_cif_var(&cif, FFI_DEFAULT_ABI, 1, 2, - &ffi_type_uint, cl_arg_types) == FFI_OK); - - CHECK(ffi_prep_closure_loc(pcl, &cif, cls_ret_T_fn, NULL, code) == FFI_OK); - res = ((((cls_ret_T)code)(67, 4))); - /* { dg-output "67: 67 4" } */ - printf("res: %d\n", res); - /* { dg-output "\nres: 67" } */ - exit(0); -} diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi/testsuite/libffi.call/cls_ulong_va.c --- a/Modules/_ctypes/libffi/testsuite/libffi.call/cls_ulong_va.c Sat Jul 19 16:34:33 2014 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,45 +0,0 @@ -/* Area: closure_call - Purpose: Test anonymous unsigned long argument. - Limitations: none. - PR: none. - Originator: ARM Ltd. */ - -/* { dg-do run } */ - -#include "ffitest.h" - -typedef unsigned long T; - -static void cls_ret_T_fn(ffi_cif* cif __UNUSED__, void* resp, void** args, - void* userdata __UNUSED__) - { - *(T *)resp = *(T *)args[0]; - - printf("%ld: %ld %ld\n", *(T *)resp, *(T *)args[0], *(T *)args[1]); - } - -typedef T (*cls_ret_T)(T, ...); - -int main (void) -{ - ffi_cif cif; - void *code; - ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code); - ffi_type * cl_arg_types[3]; - T res; - - cl_arg_types[0] = &ffi_type_ulong; - cl_arg_types[1] = &ffi_type_ulong; - cl_arg_types[2] = NULL; - - /* Initialize the cif */ - CHECK(ffi_prep_cif_var(&cif, FFI_DEFAULT_ABI, 1, 2, - &ffi_type_ulong, cl_arg_types) == FFI_OK); - - CHECK(ffi_prep_closure_loc(pcl, &cif, cls_ret_T_fn, NULL, code) == FFI_OK); - res = ((((cls_ret_T)code)(67, 4))); - /* { dg-output "67: 67 4" } */ - printf("res: %ld\n", res); - /* { dg-output "\nres: 67" } */ - exit(0); -} diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi/testsuite/libffi.call/cls_ulonglong.c --- a/Modules/_ctypes/libffi/testsuite/libffi.call/cls_ulonglong.c Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/_ctypes/libffi/testsuite/libffi.call/cls_ulonglong.c Sun Jul 20 10:52:46 2014 -0400 @@ -11,7 +11,7 @@ static void cls_ret_ulonglong_fn(ffi_cif* cif __UNUSED__, void* resp, void** args, void* userdata __UNUSED__) { - *(unsigned long long *)resp= 0xfffffffffffffffLL ^ *(unsigned long long *)args[0]; + *(unsigned long long *)resp= *(unsigned long long *)args[0]; printf("%" PRIuLL ": %" PRIuLL "\n",*(unsigned long long *)args[0], *(unsigned long long *)(resp)); @@ -34,14 +34,14 @@ &ffi_type_uint64, cl_arg_types) == FFI_OK); CHECK(ffi_prep_closure_loc(pcl, &cif, cls_ret_ulonglong_fn, NULL, code) == FFI_OK); res = (*((cls_ret_ulonglong)code))(214LL); - /* { dg-output "214: 1152921504606846761" } */ + /* { dg-output "214: 214" } */ printf("res: %" PRIdLL "\n", res); - /* { dg-output "\nres: 1152921504606846761" } */ + /* { dg-output "\nres: 214" } */ res = (*((cls_ret_ulonglong)code))(9223372035854775808LL); - /* { dg-output "\n9223372035854775808: 8070450533247928831" } */ + /* { dg-output "\n9223372035854775808: 9223372035854775808" } */ printf("res: %" PRIdLL "\n", res); - /* { dg-output "\nres: 8070450533247928831" } */ + /* { dg-output "\nres: 9223372035854775808" } */ exit(0); } diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi/testsuite/libffi.call/cls_ushort_va.c --- a/Modules/_ctypes/libffi/testsuite/libffi.call/cls_ushort_va.c Sat Jul 19 16:34:33 2014 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,44 +0,0 @@ -/* Area: closure_call - Purpose: Test anonymous unsigned short argument. - Limitations: none. - PR: none. - Originator: ARM Ltd. */ - -/* { dg-do run } */ -#include "ffitest.h" - -typedef unsigned short T; - -static void cls_ret_T_fn(ffi_cif* cif __UNUSED__, void* resp, void** args, - void* userdata __UNUSED__) - { - *(ffi_arg *)resp = *(T *)args[0]; - - printf("%d: %d %d\n", (int)(*(ffi_arg *)resp), *(T *)args[0], *(T *)args[1]); - } - -typedef T (*cls_ret_T)(T, ...); - -int main (void) -{ - ffi_cif cif; - void *code; - ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code); - ffi_type * cl_arg_types[3]; - T res; - - cl_arg_types[0] = &ffi_type_ushort; - cl_arg_types[1] = &ffi_type_ushort; - cl_arg_types[2] = NULL; - - /* Initialize the cif */ - CHECK(ffi_prep_cif_var(&cif, FFI_DEFAULT_ABI, 1, 2, - &ffi_type_ushort, cl_arg_types) == FFI_OK); - - CHECK(ffi_prep_closure_loc(pcl, &cif, cls_ret_T_fn, NULL, code) == FFI_OK); - res = ((((cls_ret_T)code)(67, 4))); - /* { dg-output "67: 67 4" } */ - printf("res: %d\n", res); - /* { dg-output "\nres: 67" } */ - exit(0); -} diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi/testsuite/libffi.call/err_bad_abi.c --- a/Modules/_ctypes/libffi/testsuite/libffi.call/err_bad_abi.c Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/_ctypes/libffi/testsuite/libffi.call/err_bad_abi.c Sun Jul 20 10:52:46 2014 -0400 @@ -4,8 +4,7 @@ PR: none. Originator: Blake Chaffin 6/6/2007 */ -/* { dg-do run } */ - +/* { dg-do run { xfail *-*-* } } */ #include "ffitest.h" static void @@ -18,9 +17,11 @@ ffi_cif cif; void *code; ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code); + void* args[1]; ffi_type* arg_types[1]; arg_types[0] = NULL; + args[0] = NULL; CHECK(ffi_prep_cif(&cif, 255, 0, &ffi_type_void, arg_types) == FFI_BAD_ABI); diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi/testsuite/libffi.call/err_bad_typedef.c --- a/Modules/_ctypes/libffi/testsuite/libffi.call/err_bad_typedef.c Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/_ctypes/libffi/testsuite/libffi.call/err_bad_typedef.c Sun Jul 20 10:52:46 2014 -0400 @@ -4,8 +4,7 @@ PR: none. Originator: Blake Chaffin 6/6/2007 */ -/* { dg-do run } */ - +/* { dg-do run { xfail *-*-* } } */ #include "ffitest.h" int main (void) @@ -13,10 +12,10 @@ ffi_cif cif; ffi_type* arg_types[1]; + arg_types[0] = NULL; + ffi_type badType = ffi_type_void; - arg_types[0] = NULL; - badType.size = 0; CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 0, &badType, diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi/testsuite/libffi.call/fastthis1_win32.c --- a/Modules/_ctypes/libffi/testsuite/libffi.call/fastthis1_win32.c Sat Jul 19 16:34:33 2014 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,50 +0,0 @@ -/* Area: ffi_call - Purpose: Check fastcall fct call on X86_WIN32 systems. - Limitations: none. - PR: none. - Originator: From the original ffitest.c */ - -/* { dg-do run { target i?86-*-cygwin* i?86-*-mingw* } } */ - -#include "ffitest.h" - -static size_t __FASTCALL__ my_fastcall_f(char *s, float a) -{ - return (size_t) ((int) strlen(s) + (int) a); -} - -int main (void) -{ - ffi_cif cif; - ffi_type *args[MAX_ARGS]; - void *values[MAX_ARGS]; - ffi_arg rint; - char *s; - float v2; - args[0] = &ffi_type_pointer; - args[1] = &ffi_type_float; - values[0] = (void*) &s; - values[1] = (void*) &v2; - - /* Initialize the cif */ - CHECK(ffi_prep_cif(&cif, FFI_FASTCALL, 2, - &ffi_type_sint, args) == FFI_OK); - - s = "a"; - v2 = 0.0; - ffi_call(&cif, FFI_FN(my_fastcall_f), &rint, values); - CHECK(rint == 1); - - s = "1234567"; - v2 = -1.0; - ffi_call(&cif, FFI_FN(my_fastcall_f), &rint, values); - CHECK(rint == 6); - - s = "1234567890123456789012345"; - v2 = 1.0; - ffi_call(&cif, FFI_FN(my_fastcall_f), &rint, values); - CHECK(rint == 26); - - printf("fastcall fct1 tests passed\n"); - exit(0); -} diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi/testsuite/libffi.call/fastthis2_win32.c --- a/Modules/_ctypes/libffi/testsuite/libffi.call/fastthis2_win32.c Sat Jul 19 16:34:33 2014 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,50 +0,0 @@ -/* Area: ffi_call - Purpose: Check fastcall fct call on X86_WIN32 systems. - Limitations: none. - PR: none. - Originator: From the original ffitest.c */ - -/* { dg-do run { target i?86-*-cygwin* i?86-*-mingw* } } */ - -#include "ffitest.h" - -static size_t __FASTCALL__ my_fastcall_f(float a, char *s) -{ - return (size_t) ((int) strlen(s) + (int) a); -} - -int main (void) -{ - ffi_cif cif; - ffi_type *args[MAX_ARGS]; - void *values[MAX_ARGS]; - ffi_arg rint; - char *s; - float v2; - args[1] = &ffi_type_pointer; - args[0] = &ffi_type_float; - values[1] = (void*) &s; - values[0] = (void*) &v2; - - /* Initialize the cif */ - CHECK(ffi_prep_cif(&cif, FFI_FASTCALL, 2, - &ffi_type_sint, args) == FFI_OK); - - s = "a"; - v2 = 0.0; - ffi_call(&cif, FFI_FN(my_fastcall_f), &rint, values); - CHECK(rint == 1); - - s = "1234567"; - v2 = -1.0; - ffi_call(&cif, FFI_FN(my_fastcall_f), &rint, values); - CHECK(rint == 6); - - s = "1234567890123456789012345"; - v2 = 1.0; - ffi_call(&cif, FFI_FN(my_fastcall_f), &rint, values); - CHECK(rint == 26); - - printf("fastcall fct2 tests passed\n"); - exit(0); -} diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi/testsuite/libffi.call/fastthis3_win32.c --- a/Modules/_ctypes/libffi/testsuite/libffi.call/fastthis3_win32.c Sat Jul 19 16:34:33 2014 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,56 +0,0 @@ -/* Area: ffi_call - Purpose: Check fastcall f call on X86_WIN32 systems. - Limitations: none. - PR: none. - Originator: From the original ffitest.c */ - -/* { dg-do run { target i?86-*-cygwin* i?86-*-mingw* } } */ - -#include "ffitest.h" - -static size_t __FASTCALL__ my_fastcall_f(float a, char *s, int i) -{ - return (size_t) ((int) strlen(s) + (int) a + i); -} - -int main (void) -{ - ffi_cif cif; - ffi_type *args[MAX_ARGS]; - void *values[MAX_ARGS]; - ffi_arg rint; - char *s; - int v1; - float v2; - args[2] = &ffi_type_sint; - args[1] = &ffi_type_pointer; - args[0] = &ffi_type_float; - values[2] = (void*) &v1; - values[1] = (void*) &s; - values[0] = (void*) &v2; - - /* Initialize the cif */ - CHECK(ffi_prep_cif(&cif, FFI_FASTCALL, 3, - &ffi_type_sint, args) == FFI_OK); - - s = "a"; - v1 = 1; - v2 = 0.0; - ffi_call(&cif, FFI_FN(my_fastcall_f), &rint, values); - CHECK(rint == 2); - - s = "1234567"; - v2 = -1.0; - v1 = -2; - ffi_call(&cif, FFI_FN(my_fastcall_f), &rint, values); - CHECK(rint == 4); - - s = "1234567890123456789012345"; - v2 = 1.0; - v1 = 2; - ffi_call(&cif, FFI_FN(my_fastcall_f), &rint, values); - CHECK(rint == 28); - - printf("fastcall fct3 tests passed\n"); - exit(0); -} diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi/testsuite/libffi.call/ffitest.h --- a/Modules/_ctypes/libffi/testsuite/libffi.call/ffitest.h Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/_ctypes/libffi/testsuite/libffi.call/ffitest.h Sun Jul 20 10:52:46 2014 -0400 @@ -15,7 +15,7 @@ #define MAX_ARGS 256 -#define CHECK(x) !(x) ? (abort(), 1) : 0 +#define CHECK(x) !(x) ? abort() : 0 /* Define __UNUSED__ that also other compilers than gcc can run the tests. */ #undef __UNUSED__ @@ -25,14 +25,6 @@ #define __UNUSED__ #endif -/* Define __FASTCALL__ so that other compilers than gcc can run the tests. */ -#undef __FASTCALL__ -#if defined _MSC_VER -#define __FASTCALL__ __fastcall -#else -#define __FASTCALL__ __attribute__((fastcall)) -#endif - /* Prefer MAP_ANON(YMOUS) to /dev/zero, since we don't need to keep a file open. */ #ifdef HAVE_MMAP_ANON @@ -75,8 +67,6 @@ #define PRIdLL "ld" #undef PRIuLL #define PRIuLL "lu" -#define PRId8 "hd" -#define PRIu8 "hu" #define PRId64 "ld" #define PRIu64 "lu" #define PRIuPTR "lu" @@ -87,28 +77,6 @@ #define PRIuPTR "lu" #endif -/* IRIX kludge. */ -#if defined(__sgi) -/* IRIX 6.5 provides all definitions, but only for C99 - compilations. */ -#define PRId8 "hhd" -#define PRIu8 "hhu" -#if (_MIPS_SZLONG == 32) -#define PRId64 "lld" -#define PRIu64 "llu" -#endif -/* This doesn't match , which always has "lld" here, but the - arguments are uint64_t, int64_t, which are unsigned long, long for - 64-bit in . */ -#if (_MIPS_SZLONG == 64) -#define PRId64 "ld" -#define PRIu64 "lu" -#endif -/* This doesn't match , which has "u" here, but the arguments - are uintptr_t, which is always unsigned long. */ -#define PRIuPTR "lu" -#endif - /* Solaris < 10 kludge. */ #if defined(__sun__) && defined(__svr4__) && !defined(PRIuPTR) #if defined(__arch64__) || defined (__x86_64__) @@ -118,15 +86,44 @@ #endif #endif -/* MSVC kludge. */ -#if defined _MSC_VER -#define PRIuPTR "lu" -#define PRIu8 "u" -#define PRId8 "d" -#define PRIu64 "I64u" -#define PRId64 "I64d" +#ifdef USING_MMAP +static inline void * +allocate_mmap (size_t size) +{ + void *page; +#if defined (HAVE_MMAP_DEV_ZERO) + static int dev_zero_fd = -1; #endif -#ifndef PRIuPTR -#define PRIuPTR "u" +#ifdef HAVE_MMAP_DEV_ZERO + if (dev_zero_fd == -1) + { + dev_zero_fd = open ("/dev/zero", O_RDONLY); + if (dev_zero_fd == -1) + { + perror ("open /dev/zero: %m"); + exit (1); + } + } #endif + + +#ifdef HAVE_MMAP_ANON + page = mmap (NULL, size, PROT_READ | PROT_WRITE | PROT_EXEC, + MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); +#endif +#ifdef HAVE_MMAP_DEV_ZERO + page = mmap (NULL, size, PROT_READ | PROT_WRITE | PROT_EXEC, + MAP_PRIVATE, dev_zero_fd, 0); +#endif + + if (page == (void *) MAP_FAILED) + { + perror ("virtual memory exhausted"); + exit (1); + } + + return page; +} + +#endif diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi/testsuite/libffi.call/float_va.c --- a/Modules/_ctypes/libffi/testsuite/libffi.call/float_va.c Sat Jul 19 16:34:33 2014 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,107 +0,0 @@ -/* Area: fp and variadics - Purpose: check fp inputs and returns work on variadics, even the fixed params - Limitations: None - PR: none - Originator: 2011-01-25 - - Intended to stress the difference in ABI on ARM vfp -*/ - -/* { dg-do run } */ - -#include - -#include "ffitest.h" - -/* prints out all the parameters, and returns the sum of them all. - * 'x' is the number of variadic parameters all of which are double in this test - */ -double float_va_fn(unsigned int x, double y,...) -{ - double total=0.0; - va_list ap; - unsigned int i; - - total+=(double)x; - total+=y; - - printf("%u: %.1f :", x, y); - - va_start(ap, y); - for(i=0;i 20100916 */ - -/* { dg-do run } */ - -#include "ffitest.h" - -#define NARGS 7 - -typedef unsigned char u8; - -#ifdef __GNUC__ -__attribute__((noinline)) -#endif -uint8_t -foo (uint8_t a, uint8_t b, uint8_t c, uint8_t d, - uint8_t e, uint8_t f, uint8_t g) -{ - return a + b + c + d + e + f + g; -} - -uint8_t -bar (uint8_t a, uint8_t b, uint8_t c, uint8_t d, - uint8_t e, uint8_t f, uint8_t g) -{ - return foo (a, b, c, d, e, f, g); -} - -int -main (void) -{ - ffi_type *ffitypes[NARGS]; - int i; - ffi_cif cif; - ffi_arg result = 0; - uint8_t args[NARGS]; - void *argptrs[NARGS]; - - for (i = 0; i < NARGS; ++i) - ffitypes[i] = &ffi_type_uint8; - - CHECK (ffi_prep_cif (&cif, FFI_DEFAULT_ABI, NARGS, - &ffi_type_uint8, ffitypes) == FFI_OK); - - for (i = 0; i < NARGS; ++i) - { - args[i] = i; - argptrs[i] = &args[i]; - } - ffi_call (&cif, FFI_FN (bar), &result, argptrs); - - CHECK (result == 21); - return 0; -} diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi/testsuite/libffi.call/many2_win32.c --- a/Modules/_ctypes/libffi/testsuite/libffi.call/many2_win32.c Sat Jul 19 16:34:33 2014 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,63 +0,0 @@ -/* Area: ffi_call - Purpose: Check stdcall many call on X86_WIN32 systems. - Limitations: none. - PR: none. - Originator: From the original ffitest.c */ - -/* { dg-do run { target i?86-*-cygwin* i?86-*-mingw* } } */ - -#include "ffitest.h" -#include - -static float __attribute__((fastcall)) fastcall_many(float f1, - float f2, - float f3, - float f4, - float f5, - float f6, - float f7, - float f8, - float f9, - float f10, - float f11, - float f12, - float f13) -{ - return ((f1/f2+f3/f4+f5/f6+f7/f8+f9/f10+f11/f12) * f13); -} - -int main (void) -{ - ffi_cif cif; - ffi_type *args[13]; - void *values[13]; - float fa[13]; - float f, ff; - unsigned long ul; - - for (ul = 0; ul < 13; ul++) - { - args[ul] = &ffi_type_float; - values[ul] = &fa[ul]; - fa[ul] = (float) ul; - } - - /* Initialize the cif */ - CHECK(ffi_prep_cif(&cif, FFI_FASTCALL, 13, - &ffi_type_float, args) == FFI_OK); - - ff = fastcall_many(fa[0], fa[1], - fa[2], fa[3], - fa[4], fa[5], - fa[6], fa[7], - fa[8], fa[9], - fa[10], fa[11], fa[12]); - - ffi_call(&cif, FFI_FN(fastcall_many), &f, values); - - if (f - ff < FLT_EPSILON) - printf("fastcall many arg tests ok!\n"); - else - CHECK(0); - exit(0); -} diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi/testsuite/libffi.call/negint.c --- a/Modules/_ctypes/libffi/testsuite/libffi.call/negint.c Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/_ctypes/libffi/testsuite/libffi.call/negint.c Sun Jul 20 10:52:46 2014 -0400 @@ -5,6 +5,7 @@ Originator: From the original ffitest.c */ /* { dg-do run } */ +/* { dg-options -O2 } */ #include "ffitest.h" diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi/testsuite/libffi.call/nested_struct.c --- a/Modules/_ctypes/libffi/testsuite/libffi.call/nested_struct.c Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/_ctypes/libffi/testsuite/libffi.call/nested_struct.c Sun Jul 20 10:52:46 2014 -0400 @@ -77,12 +77,6 @@ ffi_type cls_struct_type, cls_struct_type1, cls_struct_type2; ffi_type* dbl_arg_types[5]; - struct cls_struct_16byte1 e_dbl = { 9.0, 2.0, 6}; - struct cls_struct_16byte2 f_dbl = { 1, 2.0, 3.0}; - struct cls_struct_combined g_dbl = {{4.0, 5.0, 6}, - {3, 1.0, 8.0}}; - struct cls_struct_combined res_dbl; - cls_struct_type.size = 0; cls_struct_type.alignment = 0; cls_struct_type.type = FFI_TYPE_STRUCT; @@ -98,6 +92,12 @@ cls_struct_type2.type = FFI_TYPE_STRUCT; cls_struct_type2.elements = cls_struct_fields2; + struct cls_struct_16byte1 e_dbl = { 9.0, 2.0, 6}; + struct cls_struct_16byte2 f_dbl = { 1, 2.0, 3.0}; + struct cls_struct_combined g_dbl = {{4.0, 5.0, 6}, + {3, 1.0, 8.0}}; + struct cls_struct_combined res_dbl; + cls_struct_fields[0] = &ffi_type_double; cls_struct_fields[1] = &ffi_type_float; cls_struct_fields[2] = &ffi_type_sint; diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi/testsuite/libffi.call/nested_struct1.c --- a/Modules/_ctypes/libffi/testsuite/libffi.call/nested_struct1.c Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/_ctypes/libffi/testsuite/libffi.call/nested_struct1.c Sun Jul 20 10:52:46 2014 -0400 @@ -81,13 +81,6 @@ ffi_type cls_struct_type, cls_struct_type1, cls_struct_type2; ffi_type* dbl_arg_types[5]; - struct cls_struct_16byte1 e_dbl = { 9.0, 2.0, 6}; - struct cls_struct_16byte2 f_dbl = { 1, 2.0, 3.0}; - struct cls_struct_combined g_dbl = {{4.0, 5.0, 6}, - {3, 1.0, 8.0}}; - struct cls_struct_16byte1 h_dbl = { 3.0, 2.0, 4}; - struct cls_struct_combined res_dbl; - cls_struct_type.size = 0; cls_struct_type.alignment = 0; cls_struct_type.type = FFI_TYPE_STRUCT; @@ -103,6 +96,13 @@ cls_struct_type2.type = FFI_TYPE_STRUCT; cls_struct_type2.elements = cls_struct_fields2; + struct cls_struct_16byte1 e_dbl = { 9.0, 2.0, 6}; + struct cls_struct_16byte2 f_dbl = { 1, 2.0, 3.0}; + struct cls_struct_combined g_dbl = {{4.0, 5.0, 6}, + {3, 1.0, 8.0}}; + struct cls_struct_16byte1 h_dbl = { 3.0, 2.0, 4}; + struct cls_struct_combined res_dbl; + cls_struct_fields[0] = &ffi_type_double; cls_struct_fields[1] = &ffi_type_float; cls_struct_fields[2] = &ffi_type_sint; @@ -156,6 +156,6 @@ CHECK( res_dbl.e.ii == (e_dbl.c + f_dbl.ii + g_dbl.e.ii)); CHECK( res_dbl.e.dd == (e_dbl.a + f_dbl.dd + g_dbl.e.dd)); CHECK( res_dbl.e.ff == (e_dbl.b + f_dbl.ff + g_dbl.e.ff)); - /* CHECK( 1 == 0); */ + // CHECK( 1 == 0); exit(0); } diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi/testsuite/libffi.call/nested_struct10.c --- a/Modules/_ctypes/libffi/testsuite/libffi.call/nested_struct10.c Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/_ctypes/libffi/testsuite/libffi.call/nested_struct10.c Sun Jul 20 10:52:46 2014 -0400 @@ -67,12 +67,6 @@ ffi_type cls_struct_type, cls_struct_type1, cls_struct_type2; ffi_type* dbl_arg_types[4]; - struct A e_dbl = { 1LL, 7}; - struct B f_dbl = { 99, {12LL , 127}, 255}; - struct C g_dbl = { 2LL, 9}; - - struct B res_dbl; - cls_struct_type.size = 0; cls_struct_type.alignment = 0; cls_struct_type.type = FFI_TYPE_STRUCT; @@ -88,6 +82,12 @@ cls_struct_type2.type = FFI_TYPE_STRUCT; cls_struct_type2.elements = cls_struct_fields2; + struct A e_dbl = { 1LL, 7}; + struct B f_dbl = { 99, {12LL , 127}, 255}; + struct C g_dbl = { 2LL, 9}; + + struct B res_dbl; + cls_struct_fields[0] = &ffi_type_uint64; cls_struct_fields[1] = &ffi_type_uchar; cls_struct_fields[2] = NULL; diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi/testsuite/libffi.call/nested_struct11.c --- a/Modules/_ctypes/libffi/testsuite/libffi.call/nested_struct11.c Sat Jul 19 16:34:33 2014 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,121 +0,0 @@ -/* Area: ffi_call, closure_call - Purpose: Check parameter passing with nested structs - of a single type. This tests the special cases - for homogenous floating-point aggregates in the - AArch64 PCS. - Limitations: none. - PR: none. - Originator: ARM Ltd. */ - -/* { dg-do run } */ -#include "ffitest.h" - -typedef struct A { - float a_x; - float a_y; -} A; - -typedef struct B { - float b_x; - float b_y; -} B; - -typedef struct C { - A a; - B b; -} C; - -static C C_fn (int x, int y, int z, C source, int i, int j, int k) -{ - C result; - result.a.a_x = source.a.a_x; - result.a.a_y = source.a.a_y; - result.b.b_x = source.b.b_x; - result.b.b_y = source.b.b_y; - - printf ("%d, %d, %d, %d, %d, %d\n", x, y, z, i, j, k); - - printf ("%.1f, %.1f, %.1f, %.1f, " - "%.1f, %.1f, %.1f, %.1f\n", - source.a.a_x, source.a.a_y, - source.b.b_x, source.b.b_y, - result.a.a_x, result.a.a_y, - result.b.b_x, result.b.b_y); - - return result; -} - -int main (void) -{ - ffi_cif cif; - - ffi_type* struct_fields_source_a[3]; - ffi_type* struct_fields_source_b[3]; - ffi_type* struct_fields_source_c[3]; - ffi_type* arg_types[8]; - - ffi_type struct_type_a, struct_type_b, struct_type_c; - - struct A source_fld_a = {1.0, 2.0}; - struct B source_fld_b = {4.0, 8.0}; - int k = 1; - - struct C result; - struct C source = {source_fld_a, source_fld_b}; - - struct_type_a.size = 0; - struct_type_a.alignment = 0; - struct_type_a.type = FFI_TYPE_STRUCT; - struct_type_a.elements = struct_fields_source_a; - - struct_type_b.size = 0; - struct_type_b.alignment = 0; - struct_type_b.type = FFI_TYPE_STRUCT; - struct_type_b.elements = struct_fields_source_b; - - struct_type_c.size = 0; - struct_type_c.alignment = 0; - struct_type_c.type = FFI_TYPE_STRUCT; - struct_type_c.elements = struct_fields_source_c; - - struct_fields_source_a[0] = &ffi_type_float; - struct_fields_source_a[1] = &ffi_type_float; - struct_fields_source_a[2] = NULL; - - struct_fields_source_b[0] = &ffi_type_float; - struct_fields_source_b[1] = &ffi_type_float; - struct_fields_source_b[2] = NULL; - - struct_fields_source_c[0] = &struct_type_a; - struct_fields_source_c[1] = &struct_type_b; - struct_fields_source_c[2] = NULL; - - arg_types[0] = &ffi_type_sint32; - arg_types[1] = &ffi_type_sint32; - arg_types[2] = &ffi_type_sint32; - arg_types[3] = &struct_type_c; - arg_types[4] = &ffi_type_sint32; - arg_types[5] = &ffi_type_sint32; - arg_types[6] = &ffi_type_sint32; - arg_types[7] = NULL; - - void *args[7]; - args[0] = &k; - args[1] = &k; - args[2] = &k; - args[3] = &source; - args[4] = &k; - args[5] = &k; - args[6] = &k; - CHECK (ffi_prep_cif (&cif, FFI_DEFAULT_ABI, 7, &struct_type_c, - arg_types) == FFI_OK); - - ffi_call (&cif, FFI_FN (C_fn), &result, args); - /* { dg-output "1, 1, 1, 1, 1, 1\n" } */ - /* { dg-output "1.0, 2.0, 4.0, 8.0, 1.0, 2.0, 4.0, 8.0" } */ - CHECK (result.a.a_x == source.a.a_x); - CHECK (result.a.a_y == source.a.a_y); - CHECK (result.b.b_x == source.b.b_x); - CHECK (result.b.b_y == source.b.b_y); - exit (0); -} diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi/testsuite/libffi.call/nested_struct2.c --- a/Modules/_ctypes/libffi/testsuite/libffi.call/nested_struct2.c Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/_ctypes/libffi/testsuite/libffi.call/nested_struct2.c Sun Jul 20 10:52:46 2014 -0400 @@ -57,11 +57,6 @@ ffi_type cls_struct_type, cls_struct_type1; ffi_type* dbl_arg_types[3]; - struct A e_dbl = { 1, 7}; - struct B f_dbl = {{12 , 127}, 99}; - - struct B res_dbl; - cls_struct_type.size = 0; cls_struct_type.alignment = 0; cls_struct_type.type = FFI_TYPE_STRUCT; @@ -72,6 +67,11 @@ cls_struct_type1.type = FFI_TYPE_STRUCT; cls_struct_type1.elements = cls_struct_fields1; + struct A e_dbl = { 1, 7}; + struct B f_dbl = {{12 , 127}, 99}; + + struct B res_dbl; + cls_struct_fields[0] = &ffi_type_ulong; cls_struct_fields[1] = &ffi_type_uchar; cls_struct_fields[2] = NULL; diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi/testsuite/libffi.call/nested_struct3.c --- a/Modules/_ctypes/libffi/testsuite/libffi.call/nested_struct3.c Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/_ctypes/libffi/testsuite/libffi.call/nested_struct3.c Sun Jul 20 10:52:46 2014 -0400 @@ -58,11 +58,6 @@ ffi_type cls_struct_type, cls_struct_type1; ffi_type* dbl_arg_types[3]; - struct A e_dbl = { 1LL, 7}; - struct B f_dbl = {{12LL , 127}, 99}; - - struct B res_dbl; - cls_struct_type.size = 0; cls_struct_type.alignment = 0; cls_struct_type.type = FFI_TYPE_STRUCT; @@ -73,6 +68,11 @@ cls_struct_type1.type = FFI_TYPE_STRUCT; cls_struct_type1.elements = cls_struct_fields1; + struct A e_dbl = { 1LL, 7}; + struct B f_dbl = {{12LL , 127}, 99}; + + struct B res_dbl; + cls_struct_fields[0] = &ffi_type_uint64; cls_struct_fields[1] = &ffi_type_uchar; cls_struct_fields[2] = NULL; diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi/testsuite/libffi.call/nested_struct4.c --- a/Modules/_ctypes/libffi/testsuite/libffi.call/nested_struct4.c Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/_ctypes/libffi/testsuite/libffi.call/nested_struct4.c Sun Jul 20 10:52:46 2014 -0400 @@ -58,11 +58,6 @@ ffi_type cls_struct_type, cls_struct_type1; ffi_type* dbl_arg_types[3]; - struct A e_dbl = { 1.0, 7}; - struct B f_dbl = {{12.0 , 127}, 99}; - - struct B res_dbl; - cls_struct_type.size = 0; cls_struct_type.alignment = 0; cls_struct_type.type = FFI_TYPE_STRUCT; @@ -73,6 +68,11 @@ cls_struct_type1.type = FFI_TYPE_STRUCT; cls_struct_type1.elements = cls_struct_fields1; + struct A e_dbl = { 1.0, 7}; + struct B f_dbl = {{12.0 , 127}, 99}; + + struct B res_dbl; + cls_struct_fields[0] = &ffi_type_double; cls_struct_fields[1] = &ffi_type_uchar; cls_struct_fields[2] = NULL; diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi/testsuite/libffi.call/nested_struct5.c --- a/Modules/_ctypes/libffi/testsuite/libffi.call/nested_struct5.c Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/_ctypes/libffi/testsuite/libffi.call/nested_struct5.c Sun Jul 20 10:52:46 2014 -0400 @@ -58,11 +58,6 @@ ffi_type cls_struct_type, cls_struct_type1; ffi_type* dbl_arg_types[3]; - struct A e_dbl = { 1.0, 7}; - struct B f_dbl = {{12.0 , 127}, 99}; - - struct B res_dbl; - cls_struct_type.size = 0; cls_struct_type.alignment = 0; cls_struct_type.type = FFI_TYPE_STRUCT; @@ -73,6 +68,11 @@ cls_struct_type1.type = FFI_TYPE_STRUCT; cls_struct_type1.elements = cls_struct_fields1; + struct A e_dbl = { 1.0, 7}; + struct B f_dbl = {{12.0 , 127}, 99}; + + struct B res_dbl; + cls_struct_fields[0] = &ffi_type_longdouble; cls_struct_fields[1] = &ffi_type_uchar; cls_struct_fields[2] = NULL; diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi/testsuite/libffi.call/nested_struct6.c --- a/Modules/_ctypes/libffi/testsuite/libffi.call/nested_struct6.c Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/_ctypes/libffi/testsuite/libffi.call/nested_struct6.c Sun Jul 20 10:52:46 2014 -0400 @@ -66,12 +66,6 @@ ffi_type cls_struct_type, cls_struct_type1, cls_struct_type2; ffi_type* dbl_arg_types[4]; - struct A e_dbl = { 1.0, 7}; - struct B f_dbl = {{12.0 , 127}, 99}; - struct C g_dbl = { 2, 9}; - - struct B res_dbl; - cls_struct_type.size = 0; cls_struct_type.alignment = 0; cls_struct_type.type = FFI_TYPE_STRUCT; @@ -87,6 +81,12 @@ cls_struct_type2.type = FFI_TYPE_STRUCT; cls_struct_type2.elements = cls_struct_fields2; + struct A e_dbl = { 1.0, 7}; + struct B f_dbl = {{12.0 , 127}, 99}; + struct C g_dbl = { 2, 9}; + + struct B res_dbl; + cls_struct_fields[0] = &ffi_type_double; cls_struct_fields[1] = &ffi_type_uchar; cls_struct_fields[2] = NULL; diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi/testsuite/libffi.call/nested_struct7.c --- a/Modules/_ctypes/libffi/testsuite/libffi.call/nested_struct7.c Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/_ctypes/libffi/testsuite/libffi.call/nested_struct7.c Sun Jul 20 10:52:46 2014 -0400 @@ -58,11 +58,6 @@ ffi_type cls_struct_type, cls_struct_type1; ffi_type* dbl_arg_types[3]; - struct A e_dbl = { 1LL, 7}; - struct B f_dbl = {{12.0 , 127}, 99}; - - struct B res_dbl; - cls_struct_type.size = 0; cls_struct_type.alignment = 0; cls_struct_type.type = FFI_TYPE_STRUCT; @@ -73,6 +68,11 @@ cls_struct_type1.type = FFI_TYPE_STRUCT; cls_struct_type1.elements = cls_struct_fields1; + struct A e_dbl = { 1LL, 7}; + struct B f_dbl = {{12.0 , 127}, 99}; + + struct B res_dbl; + cls_struct_fields[0] = &ffi_type_uint64; cls_struct_fields[1] = &ffi_type_uchar; cls_struct_fields[2] = NULL; diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi/testsuite/libffi.call/nested_struct8.c --- a/Modules/_ctypes/libffi/testsuite/libffi.call/nested_struct8.c Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/_ctypes/libffi/testsuite/libffi.call/nested_struct8.c Sun Jul 20 10:52:46 2014 -0400 @@ -66,12 +66,6 @@ ffi_type cls_struct_type, cls_struct_type1, cls_struct_type2; ffi_type* dbl_arg_types[4]; - struct A e_dbl = { 1LL, 7}; - struct B f_dbl = {{12LL , 127}, 99}; - struct C g_dbl = { 2LL, 9}; - - struct B res_dbl; - cls_struct_type.size = 0; cls_struct_type.alignment = 0; cls_struct_type.type = FFI_TYPE_STRUCT; @@ -87,6 +81,12 @@ cls_struct_type2.type = FFI_TYPE_STRUCT; cls_struct_type2.elements = cls_struct_fields2; + struct A e_dbl = { 1LL, 7}; + struct B f_dbl = {{12LL , 127}, 99}; + struct C g_dbl = { 2LL, 9}; + + struct B res_dbl; + cls_struct_fields[0] = &ffi_type_uint64; cls_struct_fields[1] = &ffi_type_uchar; cls_struct_fields[2] = NULL; diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi/testsuite/libffi.call/nested_struct9.c --- a/Modules/_ctypes/libffi/testsuite/libffi.call/nested_struct9.c Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/_ctypes/libffi/testsuite/libffi.call/nested_struct9.c Sun Jul 20 10:52:46 2014 -0400 @@ -66,12 +66,6 @@ ffi_type cls_struct_type, cls_struct_type1, cls_struct_type2; ffi_type* dbl_arg_types[4]; - struct A e_dbl = { 1, 7LL}; - struct B f_dbl = {{12.0 , 127}, 99}; - struct C g_dbl = { 2, 9}; - - struct B res_dbl; - cls_struct_type.size = 0; cls_struct_type.alignment = 0; cls_struct_type.type = FFI_TYPE_STRUCT; @@ -87,6 +81,12 @@ cls_struct_type2.type = FFI_TYPE_STRUCT; cls_struct_type2.elements = cls_struct_fields2; + struct A e_dbl = { 1, 7LL}; + struct B f_dbl = {{12.0 , 127}, 99}; + struct C g_dbl = { 2, 9}; + + struct B res_dbl; + cls_struct_fields[0] = &ffi_type_uchar; cls_struct_fields[1] = &ffi_type_uint64; cls_struct_fields[2] = NULL; diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi/testsuite/libffi.call/return_dbl.c --- a/Modules/_ctypes/libffi/testsuite/libffi.call/return_dbl.c Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/_ctypes/libffi/testsuite/libffi.call/return_dbl.c Sun Jul 20 10:52:46 2014 -0400 @@ -9,7 +9,6 @@ static double return_dbl(double dbl) { - printf ("%f\n", dbl); return 2 * dbl; } int main (void) diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi/testsuite/libffi.call/return_sc.c --- a/Modules/_ctypes/libffi/testsuite/libffi.call/return_sc.c Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/_ctypes/libffi/testsuite/libffi.call/return_sc.c Sun Jul 20 10:52:46 2014 -0400 @@ -30,7 +30,7 @@ sc < (signed char) 127; sc++) { ffi_call(&cif, FFI_FN(return_sc), &rint, values); - CHECK((signed char)rint == sc); + CHECK(rint == (ffi_arg) sc); } exit(0); } diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi/testsuite/libffi.call/return_uc.c --- a/Modules/_ctypes/libffi/testsuite/libffi.call/return_uc.c Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/_ctypes/libffi/testsuite/libffi.call/return_uc.c Sun Jul 20 10:52:46 2014 -0400 @@ -32,7 +32,7 @@ uc < (unsigned char) '\xff'; uc++) { ffi_call(&cif, FFI_FN(return_uc), &rint, values); - CHECK((unsigned char)rint == uc); + CHECK(rint == (signed int) uc); } exit(0); } diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi/testsuite/libffi.call/stret_large.c --- a/Modules/_ctypes/libffi/testsuite/libffi.call/stret_large.c Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/_ctypes/libffi/testsuite/libffi.call/stret_large.c Sun Jul 20 10:52:46 2014 -0400 @@ -9,8 +9,8 @@ /* { dg-do run { xfail strongarm*-*-* xscale*-*-* } } */ #include "ffitest.h" -/* 13 FPRs: 104 bytes */ -/* 14 FPRs: 112 bytes */ +// 13 FPRs: 104 bytes +// 14 FPRs: 112 bytes typedef struct struct_108byte { double a; @@ -82,17 +82,17 @@ ffi_type cls_struct_type; ffi_type* dbl_arg_types[5]; + cls_struct_type.size = 0; + cls_struct_type.alignment = 0; + cls_struct_type.type = FFI_TYPE_STRUCT; + cls_struct_type.elements = cls_struct_fields; + struct_108byte e_dbl = { 9.0, 2.0, 6.0, 5.0, 3.0, 4.0, 8.0, 1.0, 1.0, 2.0, 3.0, 7.0, 2.0, 7 }; struct_108byte f_dbl = { 1.0, 2.0, 3.0, 7.0, 2.0, 5.0, 6.0, 7.0, 4.0, 5.0, 7.0, 9.0, 1.0, 4 }; struct_108byte g_dbl = { 4.0, 5.0, 7.0, 9.0, 1.0, 1.0, 2.0, 9.0, 8.0, 6.0, 1.0, 4.0, 0.0, 3 }; struct_108byte h_dbl = { 8.0, 6.0, 1.0, 4.0, 0.0, 3.0, 3.0, 1.0, 9.0, 2.0, 6.0, 5.0, 3.0, 2 }; struct_108byte res_dbl; - cls_struct_type.size = 0; - cls_struct_type.alignment = 0; - cls_struct_type.type = FFI_TYPE_STRUCT; - cls_struct_type.elements = cls_struct_fields; - cls_struct_fields[0] = &ffi_type_double; cls_struct_fields[1] = &ffi_type_double; cls_struct_fields[2] = &ffi_type_double; diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi/testsuite/libffi.call/stret_large2.c --- a/Modules/_ctypes/libffi/testsuite/libffi.call/stret_large2.c Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/_ctypes/libffi/testsuite/libffi.call/stret_large2.c Sun Jul 20 10:52:46 2014 -0400 @@ -9,8 +9,8 @@ /* { dg-do run { xfail strongarm*-*-* xscale*-*-* } } */ #include "ffitest.h" -/* 13 FPRs: 104 bytes */ -/* 14 FPRs: 112 bytes */ +// 13 FPRs: 104 bytes +// 14 FPRs: 112 bytes typedef struct struct_116byte { double a; @@ -84,17 +84,17 @@ ffi_type cls_struct_type; ffi_type* dbl_arg_types[5]; + cls_struct_type.size = 0; + cls_struct_type.alignment = 0; + cls_struct_type.type = FFI_TYPE_STRUCT; + cls_struct_type.elements = cls_struct_fields; + struct_116byte e_dbl = { 9.0, 2.0, 6.0, 5.0, 3.0, 4.0, 8.0, 1.0, 1.0, 2.0, 3.0, 7.0, 2.0, 5.0, 7 }; struct_116byte f_dbl = { 1.0, 2.0, 3.0, 7.0, 2.0, 5.0, 6.0, 7.0, 4.0, 5.0, 7.0, 9.0, 1.0, 6.0, 4 }; struct_116byte g_dbl = { 4.0, 5.0, 7.0, 9.0, 1.0, 1.0, 2.0, 9.0, 8.0, 6.0, 1.0, 4.0, 0.0, 7.0, 3 }; struct_116byte h_dbl = { 8.0, 6.0, 1.0, 4.0, 0.0, 3.0, 3.0, 1.0, 9.0, 2.0, 6.0, 5.0, 3.0, 8.0, 2 }; struct_116byte res_dbl; - cls_struct_type.size = 0; - cls_struct_type.alignment = 0; - cls_struct_type.type = FFI_TYPE_STRUCT; - cls_struct_type.elements = cls_struct_fields; - cls_struct_fields[0] = &ffi_type_double; cls_struct_fields[1] = &ffi_type_double; cls_struct_fields[2] = &ffi_type_double; diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi/testsuite/libffi.call/stret_medium.c --- a/Modules/_ctypes/libffi/testsuite/libffi.call/stret_medium.c Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/_ctypes/libffi/testsuite/libffi.call/stret_medium.c Sun Jul 20 10:52:46 2014 -0400 @@ -68,17 +68,17 @@ ffi_type cls_struct_type; ffi_type* dbl_arg_types[5]; + cls_struct_type.size = 0; + cls_struct_type.alignment = 0; + cls_struct_type.type = FFI_TYPE_STRUCT; + cls_struct_type.elements = cls_struct_fields; + struct_72byte e_dbl = { 9.0, 2.0, 6.0, 5.0, 3.0, 4.0, 8.0, 1.0, 7.0 }; struct_72byte f_dbl = { 1.0, 2.0, 3.0, 7.0, 2.0, 5.0, 6.0, 7.0, 4.0 }; struct_72byte g_dbl = { 4.0, 5.0, 7.0, 9.0, 1.0, 1.0, 2.0, 9.0, 3.0 }; struct_72byte h_dbl = { 8.0, 6.0, 1.0, 4.0, 0.0, 3.0, 3.0, 1.0, 2.0 }; struct_72byte res_dbl; - cls_struct_type.size = 0; - cls_struct_type.alignment = 0; - cls_struct_type.type = FFI_TYPE_STRUCT; - cls_struct_type.elements = cls_struct_fields; - cls_struct_fields[0] = &ffi_type_double; cls_struct_fields[1] = &ffi_type_double; cls_struct_fields[2] = &ffi_type_double; diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi/testsuite/libffi.call/stret_medium2.c --- a/Modules/_ctypes/libffi/testsuite/libffi.call/stret_medium2.c Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/_ctypes/libffi/testsuite/libffi.call/stret_medium2.c Sun Jul 20 10:52:46 2014 -0400 @@ -69,17 +69,17 @@ ffi_type cls_struct_type; ffi_type* dbl_arg_types[5]; + cls_struct_type.size = 0; + cls_struct_type.alignment = 0; + cls_struct_type.type = FFI_TYPE_STRUCT; + cls_struct_type.elements = cls_struct_fields; + struct_72byte e_dbl = { 9.0, 2.0, 6.0, 5.0, 3.0, 4.0, 8.0, 1.0, 7 }; struct_72byte f_dbl = { 1.0, 2.0, 3.0, 7.0, 2.0, 5.0, 6.0, 7.0, 4 }; struct_72byte g_dbl = { 4.0, 5.0, 7.0, 9.0, 1.0, 1.0, 2.0, 9.0, 3 }; struct_72byte h_dbl = { 8.0, 6.0, 1.0, 4.0, 0.0, 3.0, 3.0, 1.0, 2 }; struct_72byte res_dbl; - cls_struct_type.size = 0; - cls_struct_type.alignment = 0; - cls_struct_type.type = FFI_TYPE_STRUCT; - cls_struct_type.elements = cls_struct_fields; - cls_struct_fields[0] = &ffi_type_double; cls_struct_fields[1] = &ffi_type_double; cls_struct_fields[2] = &ffi_type_double; diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi/testsuite/libffi.call/strlen2_win32.c --- a/Modules/_ctypes/libffi/testsuite/libffi.call/strlen2_win32.c Sat Jul 19 16:34:33 2014 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,44 +0,0 @@ -/* Area: ffi_call - Purpose: Check fastcall strlen call on X86_WIN32 systems. - Limitations: none. - PR: none. - Originator: From the original ffitest.c */ - -/* { dg-do run { target i?86-*-cygwin* i?86-*-mingw* } } */ - -#include "ffitest.h" - -static size_t __FASTCALL__ my_fastcall_strlen(char *s) -{ - return (strlen(s)); -} - -int main (void) -{ - ffi_cif cif; - ffi_type *args[MAX_ARGS]; - void *values[MAX_ARGS]; - ffi_arg rint; - char *s; - args[0] = &ffi_type_pointer; - values[0] = (void*) &s; - - /* Initialize the cif */ - CHECK(ffi_prep_cif(&cif, FFI_FASTCALL, 1, - &ffi_type_sint, args) == FFI_OK); - - s = "a"; - ffi_call(&cif, FFI_FN(my_fastcall_strlen), &rint, values); - CHECK(rint == 1); - - s = "1234567"; - ffi_call(&cif, FFI_FN(my_fastcall_strlen), &rint, values); - CHECK(rint == 7); - - s = "1234567890123456789012345"; - ffi_call(&cif, FFI_FN(my_fastcall_strlen), &rint, values); - CHECK(rint == 25); - - printf("fastcall strlen tests passed\n"); - exit(0); -} diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi/testsuite/libffi.call/struct1.c --- a/Modules/_ctypes/libffi/testsuite/libffi.call/struct1.c Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/_ctypes/libffi/testsuite/libffi.call/struct1.c Sun Jul 20 10:52:46 2014 -0400 @@ -30,13 +30,6 @@ void *values[MAX_ARGS]; ffi_type ts1_type; ffi_type *ts1_type_elements[4]; - - test_structure_1 ts1_arg; - - /* This is a hack to get a properly aligned result buffer */ - test_structure_1 *ts1_result = - (test_structure_1 *) malloc (sizeof(test_structure_1)); - ts1_type.size = 0; ts1_type.alignment = 0; ts1_type.type = FFI_TYPE_STRUCT; @@ -46,6 +39,11 @@ ts1_type_elements[2] = &ffi_type_uint; ts1_type_elements[3] = NULL; + test_structure_1 ts1_arg; + /* This is a hack to get a properly aligned result buffer */ + test_structure_1 *ts1_result = + (test_structure_1 *) malloc (sizeof(test_structure_1)); + args[0] = &ts1_type; values[0] = &ts1_arg; diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi/testsuite/libffi.call/struct1_win32.c --- a/Modules/_ctypes/libffi/testsuite/libffi.call/struct1_win32.c Sat Jul 19 16:34:33 2014 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,67 +0,0 @@ -/* Area: ffi_call - Purpose: Check structures with fastcall/thiscall convention. - Limitations: none. - PR: none. - Originator: From the original ffitest.c */ - -/* { dg-do run { target i?86-*-cygwin* i?86-*-mingw* } } */ -#include "ffitest.h" - -typedef struct -{ - unsigned char uc; - double d; - unsigned int ui; -} test_structure_1; - -static test_structure_1 __FASTCALL__ struct1(test_structure_1 ts) -{ - ts.uc++; - ts.d--; - ts.ui++; - - return ts; -} - -int main (void) -{ - ffi_cif cif; - ffi_type *args[MAX_ARGS]; - void *values[MAX_ARGS]; - ffi_type ts1_type; - ffi_type *ts1_type_elements[4]; - - test_structure_1 ts1_arg; - - /* This is a hack to get a properly aligned result buffer */ - test_structure_1 *ts1_result = - (test_structure_1 *) malloc (sizeof(test_structure_1)); - - ts1_type.size = 0; - ts1_type.alignment = 0; - ts1_type.type = FFI_TYPE_STRUCT; - ts1_type.elements = ts1_type_elements; - ts1_type_elements[0] = &ffi_type_uchar; - ts1_type_elements[1] = &ffi_type_double; - ts1_type_elements[2] = &ffi_type_uint; - ts1_type_elements[3] = NULL; - - args[0] = &ts1_type; - values[0] = &ts1_arg; - - /* Initialize the cif */ - CHECK(ffi_prep_cif(&cif, FFI_FASTCALL, 1, - &ts1_type, args) == FFI_OK); - - ts1_arg.uc = '\x01'; - ts1_arg.d = 3.14159; - ts1_arg.ui = 555; - - ffi_call(&cif, FFI_FN(struct1), ts1_result, values); - - CHECK(ts1_result->ui == 556); - CHECK(ts1_result->d == 3.14159 - 1); - - free (ts1_result); - exit(0); -} diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi/testsuite/libffi.call/struct2.c --- a/Modules/_ctypes/libffi/testsuite/libffi.call/struct2.c Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/_ctypes/libffi/testsuite/libffi.call/struct2.c Sun Jul 20 10:52:46 2014 -0400 @@ -29,11 +29,6 @@ test_structure_2 ts2_arg; ffi_type ts2_type; ffi_type *ts2_type_elements[3]; - - /* This is a hack to get a properly aligned result buffer */ - test_structure_2 *ts2_result = - (test_structure_2 *) malloc (sizeof(test_structure_2)); - ts2_type.size = 0; ts2_type.alignment = 0; ts2_type.type = FFI_TYPE_STRUCT; @@ -42,6 +37,11 @@ ts2_type_elements[1] = &ffi_type_double; ts2_type_elements[2] = NULL; + + /* This is a hack to get a properly aligned result buffer */ + test_structure_2 *ts2_result = + (test_structure_2 *) malloc (sizeof(test_structure_2)); + args[0] = &ts2_type; values[0] = &ts2_arg; diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi/testsuite/libffi.call/struct2_win32.c --- a/Modules/_ctypes/libffi/testsuite/libffi.call/struct2_win32.c Sat Jul 19 16:34:33 2014 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,67 +0,0 @@ -/* Area: ffi_call - Purpose: Check structures in fastcall/stdcall function - Limitations: none. - PR: none. - Originator: From the original ffitest.c */ - -/* { dg-do run { target i?86-*-cygwin* i?86-*-mingw* } } */ -#include "ffitest.h" - -typedef struct -{ - double d1; - double d2; -} test_structure_2; - -static test_structure_2 __FASTCALL__ struct2(test_structure_2 ts) -{ - ts.d1--; - ts.d2--; - - return ts; -} - -int main (void) -{ - ffi_cif cif; - ffi_type *args[MAX_ARGS]; - void *values[MAX_ARGS]; - test_structure_2 ts2_arg; - ffi_type ts2_type; - ffi_type *ts2_type_elements[3]; - - /* This is a hack to get a properly aligned result buffer */ - test_structure_2 *ts2_result = - (test_structure_2 *) malloc (sizeof(test_structure_2)); - - ts2_type.size = 0; - ts2_type.alignment = 0; - ts2_type.type = FFI_TYPE_STRUCT; - ts2_type.elements = ts2_type_elements; - ts2_type_elements[0] = &ffi_type_double; - ts2_type_elements[1] = &ffi_type_double; - ts2_type_elements[2] = NULL; - - args[0] = &ts2_type; - values[0] = &ts2_arg; - - /* Initialize the cif */ - CHECK(ffi_prep_cif(&cif, FFI_FASTCALL, 1, &ts2_type, args) == FFI_OK); - - ts2_arg.d1 = 5.55; - ts2_arg.d2 = 6.66; - - printf ("%g\n", ts2_arg.d1); - printf ("%g\n", ts2_arg.d2); - - ffi_call(&cif, FFI_FN(struct2), ts2_result, values); - - printf ("%g\n", ts2_result->d1); - printf ("%g\n", ts2_result->d2); - - CHECK(ts2_result->d1 == 5.55 - 1); - CHECK(ts2_result->d2 == 6.66 - 1); - - free (ts2_result); - exit(0); -} diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi/testsuite/libffi.call/struct3.c --- a/Modules/_ctypes/libffi/testsuite/libffi.call/struct3.c Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/_ctypes/libffi/testsuite/libffi.call/struct3.c Sun Jul 20 10:52:46 2014 -0400 @@ -27,11 +27,6 @@ int compare_value; ffi_type ts3_type; ffi_type *ts3_type_elements[2]; - - test_structure_3 ts3_arg; - test_structure_3 *ts3_result = - (test_structure_3 *) malloc (sizeof(test_structure_3)); - ts3_type.size = 0; ts3_type.alignment = 0; ts3_type.type = FFI_TYPE_STRUCT; @@ -39,6 +34,10 @@ ts3_type_elements[0] = &ffi_type_sint; ts3_type_elements[1] = NULL; + test_structure_3 ts3_arg; + test_structure_3 *ts3_result = + (test_structure_3 *) malloc (sizeof(test_structure_3)); + args[0] = &ts3_type; values[0] = &ts3_arg; diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi/testsuite/libffi.call/struct4.c --- a/Modules/_ctypes/libffi/testsuite/libffi.call/struct4.c Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/_ctypes/libffi/testsuite/libffi.call/struct4.c Sun Jul 20 10:52:46 2014 -0400 @@ -28,22 +28,21 @@ void *values[MAX_ARGS]; ffi_type ts4_type; ffi_type *ts4_type_elements[4]; - - test_structure_4 ts4_arg; - - /* This is a hack to get a properly aligned result buffer */ - test_structure_4 *ts4_result = - (test_structure_4 *) malloc (sizeof(test_structure_4)); - ts4_type.size = 0; ts4_type.alignment = 0; ts4_type.type = FFI_TYPE_STRUCT; + test_structure_4 ts4_arg; ts4_type.elements = ts4_type_elements; ts4_type_elements[0] = &ffi_type_uint; ts4_type_elements[1] = &ffi_type_uint; ts4_type_elements[2] = &ffi_type_uint; ts4_type_elements[3] = NULL; + + /* This is a hack to get a properly aligned result buffer */ + test_structure_4 *ts4_result = + (test_structure_4 *) malloc (sizeof(test_structure_4)); + args[0] = &ts4_type; values[0] = &ts4_arg; diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi/testsuite/libffi.call/struct5.c --- a/Modules/_ctypes/libffi/testsuite/libffi.call/struct5.c Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/_ctypes/libffi/testsuite/libffi.call/struct5.c Sun Jul 20 10:52:46 2014 -0400 @@ -27,13 +27,6 @@ void *values[MAX_ARGS]; ffi_type ts5_type; ffi_type *ts5_type_elements[3]; - - test_structure_5 ts5_arg1, ts5_arg2; - - /* This is a hack to get a properly aligned result buffer */ - test_structure_5 *ts5_result = - (test_structure_5 *) malloc (sizeof(test_structure_5)); - ts5_type.size = 0; ts5_type.alignment = 0; ts5_type.type = FFI_TYPE_STRUCT; @@ -42,6 +35,12 @@ ts5_type_elements[1] = &ffi_type_schar; ts5_type_elements[2] = NULL; + test_structure_5 ts5_arg1, ts5_arg2; + + /* This is a hack to get a properly aligned result buffer */ + test_structure_5 *ts5_result = + (test_structure_5 *) malloc (sizeof(test_structure_5)); + args[0] = &ts5_type; args[1] = &ts5_type; values[0] = &ts5_arg1; diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi/testsuite/libffi.call/struct6.c --- a/Modules/_ctypes/libffi/testsuite/libffi.call/struct6.c Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/_ctypes/libffi/testsuite/libffi.call/struct6.c Sun Jul 20 10:52:46 2014 -0400 @@ -27,13 +27,6 @@ void *values[MAX_ARGS]; ffi_type ts6_type; ffi_type *ts6_type_elements[3]; - - test_structure_6 ts6_arg; - - /* This is a hack to get a properly aligned result buffer */ - test_structure_6 *ts6_result = - (test_structure_6 *) malloc (sizeof(test_structure_6)); - ts6_type.size = 0; ts6_type.alignment = 0; ts6_type.type = FFI_TYPE_STRUCT; @@ -42,6 +35,13 @@ ts6_type_elements[1] = &ffi_type_double; ts6_type_elements[2] = NULL; + + test_structure_6 ts6_arg; + + /* This is a hack to get a properly aligned result buffer */ + test_structure_6 *ts6_result = + (test_structure_6 *) malloc (sizeof(test_structure_6)); + args[0] = &ts6_type; values[0] = &ts6_arg; diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi/testsuite/libffi.call/struct7.c --- a/Modules/_ctypes/libffi/testsuite/libffi.call/struct7.c Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/_ctypes/libffi/testsuite/libffi.call/struct7.c Sun Jul 20 10:52:46 2014 -0400 @@ -29,13 +29,6 @@ void *values[MAX_ARGS]; ffi_type ts7_type; ffi_type *ts7_type_elements[4]; - - test_structure_7 ts7_arg; - - /* This is a hack to get a properly aligned result buffer */ - test_structure_7 *ts7_result = - (test_structure_7 *) malloc (sizeof(test_structure_7)); - ts7_type.size = 0; ts7_type.alignment = 0; ts7_type.type = FFI_TYPE_STRUCT; @@ -45,6 +38,13 @@ ts7_type_elements[2] = &ffi_type_double; ts7_type_elements[3] = NULL; + + test_structure_7 ts7_arg; + + /* This is a hack to get a properly aligned result buffer */ + test_structure_7 *ts7_result = + (test_structure_7 *) malloc (sizeof(test_structure_7)); + args[0] = &ts7_type; values[0] = &ts7_arg; diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi/testsuite/libffi.call/struct8.c --- a/Modules/_ctypes/libffi/testsuite/libffi.call/struct8.c Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/_ctypes/libffi/testsuite/libffi.call/struct8.c Sun Jul 20 10:52:46 2014 -0400 @@ -31,13 +31,6 @@ void *values[MAX_ARGS]; ffi_type ts8_type; ffi_type *ts8_type_elements[5]; - - test_structure_8 ts8_arg; - - /* This is a hack to get a properly aligned result buffer */ - test_structure_8 *ts8_result = - (test_structure_8 *) malloc (sizeof(test_structure_8)); - ts8_type.size = 0; ts8_type.alignment = 0; ts8_type.type = FFI_TYPE_STRUCT; @@ -48,6 +41,12 @@ ts8_type_elements[3] = &ffi_type_float; ts8_type_elements[4] = NULL; + test_structure_8 ts8_arg; + + /* This is a hack to get a properly aligned result buffer */ + test_structure_8 *ts8_result = + (test_structure_8 *) malloc (sizeof(test_structure_8)); + args[0] = &ts8_type; values[0] = &ts8_arg; diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi/testsuite/libffi.call/struct9.c --- a/Modules/_ctypes/libffi/testsuite/libffi.call/struct9.c Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/_ctypes/libffi/testsuite/libffi.call/struct9.c Sun Jul 20 10:52:46 2014 -0400 @@ -28,13 +28,6 @@ void *values[MAX_ARGS]; ffi_type ts9_type; ffi_type *ts9_type_elements[3]; - - test_structure_9 ts9_arg; - - /* This is a hack to get a properly aligned result buffer */ - test_structure_9 *ts9_result = - (test_structure_9 *) malloc (sizeof(test_structure_9)); - ts9_type.size = 0; ts9_type.alignment = 0; ts9_type.type = FFI_TYPE_STRUCT; @@ -43,6 +36,12 @@ ts9_type_elements[1] = &ffi_type_sint; ts9_type_elements[2] = NULL; + test_structure_9 ts9_arg; + + /* This is a hack to get a properly aligned result buffer */ + test_structure_9 *ts9_result = + (test_structure_9 *) malloc (sizeof(test_structure_9)); + args[0] = &ts9_type; values[0] = &ts9_arg; diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi/testsuite/libffi.call/testclosure.c --- a/Modules/_ctypes/libffi/testsuite/libffi.call/testclosure.c Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/_ctypes/libffi/testsuite/libffi.call/testclosure.c Sun Jul 20 10:52:46 2014 -0400 @@ -43,13 +43,13 @@ ffi_type cls_struct_type0; ffi_type* dbl_arg_types[5]; - struct cls_struct_combined g_dbl = {4.0, 5.0, 1.0, 8.0}; - cls_struct_type0.size = 0; cls_struct_type0.alignment = 0; cls_struct_type0.type = FFI_TYPE_STRUCT; cls_struct_type0.elements = cls_struct_fields0; + struct cls_struct_combined g_dbl = {4.0, 5.0, 1.0, 8.0}; + cls_struct_fields0[0] = &ffi_type_float; cls_struct_fields0[1] = &ffi_type_float; cls_struct_fields0[2] = &ffi_type_float; diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi/testsuite/libffi.call/uninitialized.c --- a/Modules/_ctypes/libffi/testsuite/libffi.call/uninitialized.c Sat Jul 19 16:34:33 2014 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,61 +0,0 @@ -/* { dg-do run } */ -#include "ffitest.h" - -typedef struct -{ - unsigned char uc; - double d; - unsigned int ui; -} test_structure_1; - -static test_structure_1 struct1(test_structure_1 ts) -{ - ts.uc++; - ts.d--; - ts.ui++; - - return ts; -} - -int main (void) -{ - ffi_cif cif; - ffi_type *args[MAX_ARGS]; - void *values[MAX_ARGS]; - ffi_type ts1_type; - ffi_type *ts1_type_elements[4]; - - memset(&cif, 1, sizeof(cif)); - ts1_type.size = 0; - ts1_type.alignment = 0; - ts1_type.type = FFI_TYPE_STRUCT; - ts1_type.elements = ts1_type_elements; - ts1_type_elements[0] = &ffi_type_uchar; - ts1_type_elements[1] = &ffi_type_double; - ts1_type_elements[2] = &ffi_type_uint; - ts1_type_elements[3] = NULL; - - test_structure_1 ts1_arg; - /* This is a hack to get a properly aligned result buffer */ - test_structure_1 *ts1_result = - (test_structure_1 *) malloc (sizeof(test_structure_1)); - - args[0] = &ts1_type; - values[0] = &ts1_arg; - - /* Initialize the cif */ - CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 1, - &ts1_type, args) == FFI_OK); - - ts1_arg.uc = '\x01'; - ts1_arg.d = 3.14159; - ts1_arg.ui = 555; - - ffi_call(&cif, FFI_FN(struct1), ts1_result, values); - - CHECK(ts1_result->ui == 556); - CHECK(ts1_result->d == 3.14159 - 1); - - free (ts1_result); - exit(0); -} diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi/testsuite/libffi.call/va_1.c --- a/Modules/_ctypes/libffi/testsuite/libffi.call/va_1.c Sat Jul 19 16:34:33 2014 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,196 +0,0 @@ -/* Area: ffi_call - Purpose: Test passing struct in variable argument lists. - Limitations: none. - PR: none. - Originator: ARM Ltd. */ - -/* { dg-do run } */ -/* { dg-output "" { xfail avr32*-*-* } } */ - -#include "ffitest.h" -#include - -struct small_tag -{ - unsigned char a; - unsigned char b; -}; - -struct large_tag -{ - unsigned a; - unsigned b; - unsigned c; - unsigned d; - unsigned e; -}; - -static int -test_fn (int n, ...) -{ - va_list ap; - struct small_tag s1; - struct small_tag s2; - struct large_tag l; - unsigned char uc; - signed char sc; - unsigned short us; - signed short ss; - unsigned int ui; - signed int si; - unsigned long ul; - signed long sl; - float f; - double d; - - va_start (ap, n); - s1 = va_arg (ap, struct small_tag); - l = va_arg (ap, struct large_tag); - s2 = va_arg (ap, struct small_tag); - - uc = va_arg (ap, unsigned); - sc = va_arg (ap, signed); - - us = va_arg (ap, unsigned); - ss = va_arg (ap, signed); - - ui = va_arg (ap, unsigned int); - si = va_arg (ap, signed int); - - ul = va_arg (ap, unsigned long); - sl = va_arg (ap, signed long); - - f = va_arg (ap, double); /* C standard promotes float->double - when anonymous */ - d = va_arg (ap, double); - - printf ("%u %u %u %u %u %u %u %u %u uc=%u sc=%d %u %d %u %d %lu %ld %f %f\n", - s1.a, s1.b, l.a, l.b, l.c, l.d, l.e, - s2.a, s2.b, - uc, sc, - us, ss, - ui, si, - ul, sl, - f, d); - va_end (ap); - return n + 1; -} - -int -main (void) -{ - ffi_cif cif; - void* args[15]; - ffi_type* arg_types[15]; - - ffi_type s_type; - ffi_type *s_type_elements[3]; - - ffi_type l_type; - ffi_type *l_type_elements[6]; - - struct small_tag s1; - struct small_tag s2; - struct large_tag l1; - - int n; - int res; - - unsigned char uc; - signed char sc; - unsigned short us; - signed short ss; - unsigned int ui; - signed int si; - unsigned long ul; - signed long sl; - double d1; - double f1; - - s_type.size = 0; - s_type.alignment = 0; - s_type.type = FFI_TYPE_STRUCT; - s_type.elements = s_type_elements; - - s_type_elements[0] = &ffi_type_uchar; - s_type_elements[1] = &ffi_type_uchar; - s_type_elements[2] = NULL; - - l_type.size = 0; - l_type.alignment = 0; - l_type.type = FFI_TYPE_STRUCT; - l_type.elements = l_type_elements; - - l_type_elements[0] = &ffi_type_uint; - l_type_elements[1] = &ffi_type_uint; - l_type_elements[2] = &ffi_type_uint; - l_type_elements[3] = &ffi_type_uint; - l_type_elements[4] = &ffi_type_uint; - l_type_elements[5] = NULL; - - arg_types[0] = &ffi_type_sint; - arg_types[1] = &s_type; - arg_types[2] = &l_type; - arg_types[3] = &s_type; - arg_types[4] = &ffi_type_uchar; - arg_types[5] = &ffi_type_schar; - arg_types[6] = &ffi_type_ushort; - arg_types[7] = &ffi_type_sshort; - arg_types[8] = &ffi_type_uint; - arg_types[9] = &ffi_type_sint; - arg_types[10] = &ffi_type_ulong; - arg_types[11] = &ffi_type_slong; - arg_types[12] = &ffi_type_double; - arg_types[13] = &ffi_type_double; - arg_types[14] = NULL; - - CHECK(ffi_prep_cif_var(&cif, FFI_DEFAULT_ABI, 1, 14, &ffi_type_sint, arg_types) == FFI_OK); - - s1.a = 5; - s1.b = 6; - - l1.a = 10; - l1.b = 11; - l1.c = 12; - l1.d = 13; - l1.e = 14; - - s2.a = 7; - s2.b = 8; - - n = 41; - - uc = 9; - sc = 10; - us = 11; - ss = 12; - ui = 13; - si = 14; - ul = 15; - sl = 16; - f1 = 2.12; - d1 = 3.13; - - args[0] = &n; - args[1] = &s1; - args[2] = &l1; - args[3] = &s2; - args[4] = &uc; - args[5] = ≻ - args[6] = &us; - args[7] = &ss; - args[8] = &ui; - args[9] = &si; - args[10] = &ul; - args[11] = &sl; - args[12] = &f1; - args[13] = &d1; - args[14] = NULL; - - ffi_call(&cif, FFI_FN(test_fn), &res, args); - /* { dg-output "5 6 10 11 12 13 14 7 8 uc=9 sc=10 11 12 13 14 15 16 2.120000 3.130000" } */ - printf("res: %d\n", (int) res); - /* { dg-output "\nres: 42" } */ - - return 0; -} diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi/testsuite/libffi.call/va_struct1.c --- a/Modules/_ctypes/libffi/testsuite/libffi.call/va_struct1.c Sat Jul 19 16:34:33 2014 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,121 +0,0 @@ -/* Area: ffi_call - Purpose: Test passing struct in variable argument lists. - Limitations: none. - PR: none. - Originator: ARM Ltd. */ - -/* { dg-do run } */ -/* { dg-output "" { xfail avr32*-*-* } } */ - -#include "ffitest.h" -#include - -struct small_tag -{ - unsigned char a; - unsigned char b; -}; - -struct large_tag -{ - unsigned a; - unsigned b; - unsigned c; - unsigned d; - unsigned e; -}; - -static int -test_fn (int n, ...) -{ - va_list ap; - struct small_tag s1; - struct small_tag s2; - struct large_tag l; - - va_start (ap, n); - s1 = va_arg (ap, struct small_tag); - l = va_arg (ap, struct large_tag); - s2 = va_arg (ap, struct small_tag); - printf ("%u %u %u %u %u %u %u %u %u\n", s1.a, s1.b, l.a, l.b, l.c, l.d, l.e, - s2.a, s2.b); - va_end (ap); - return n + 1; -} - -int -main (void) -{ - ffi_cif cif; - void* args[5]; - ffi_type* arg_types[5]; - - ffi_type s_type; - ffi_type *s_type_elements[3]; - - ffi_type l_type; - ffi_type *l_type_elements[6]; - - struct small_tag s1; - struct small_tag s2; - struct large_tag l1; - - int n; - int res; - - s_type.size = 0; - s_type.alignment = 0; - s_type.type = FFI_TYPE_STRUCT; - s_type.elements = s_type_elements; - - s_type_elements[0] = &ffi_type_uchar; - s_type_elements[1] = &ffi_type_uchar; - s_type_elements[2] = NULL; - - l_type.size = 0; - l_type.alignment = 0; - l_type.type = FFI_TYPE_STRUCT; - l_type.elements = l_type_elements; - - l_type_elements[0] = &ffi_type_uint; - l_type_elements[1] = &ffi_type_uint; - l_type_elements[2] = &ffi_type_uint; - l_type_elements[3] = &ffi_type_uint; - l_type_elements[4] = &ffi_type_uint; - l_type_elements[5] = NULL; - - arg_types[0] = &ffi_type_sint; - arg_types[1] = &s_type; - arg_types[2] = &l_type; - arg_types[3] = &s_type; - arg_types[4] = NULL; - - CHECK(ffi_prep_cif_var(&cif, FFI_DEFAULT_ABI, 1, 4, &ffi_type_sint, arg_types) == FFI_OK); - - s1.a = 5; - s1.b = 6; - - l1.a = 10; - l1.b = 11; - l1.c = 12; - l1.d = 13; - l1.e = 14; - - s2.a = 7; - s2.b = 8; - - n = 41; - - args[0] = &n; - args[1] = &s1; - args[2] = &l1; - args[3] = &s2; - args[4] = NULL; - - ffi_call(&cif, FFI_FN(test_fn), &res, args); - /* { dg-output "5 6 10 11 12 13 14 7 8" } */ - printf("res: %d\n", (int) res); - /* { dg-output "\nres: 42" } */ - - return 0; -} diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi/testsuite/libffi.call/va_struct2.c --- a/Modules/_ctypes/libffi/testsuite/libffi.call/va_struct2.c Sat Jul 19 16:34:33 2014 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,123 +0,0 @@ -/* Area: ffi_call - Purpose: Test passing struct in variable argument lists. - Limitations: none. - PR: none. - Originator: ARM Ltd. */ - -/* { dg-do run } */ -/* { dg-output "" { xfail avr32*-*-* } } */ - -#include "ffitest.h" -#include - -struct small_tag -{ - unsigned char a; - unsigned char b; -}; - -struct large_tag -{ - unsigned a; - unsigned b; - unsigned c; - unsigned d; - unsigned e; -}; - -static struct small_tag -test_fn (int n, ...) -{ - va_list ap; - struct small_tag s1; - struct small_tag s2; - struct large_tag l; - - va_start (ap, n); - s1 = va_arg (ap, struct small_tag); - l = va_arg (ap, struct large_tag); - s2 = va_arg (ap, struct small_tag); - printf ("%u %u %u %u %u %u %u %u %u\n", s1.a, s1.b, l.a, l.b, l.c, l.d, l.e, - s2.a, s2.b); - va_end (ap); - s1.a += s2.a; - s1.b += s2.b; - return s1; -} - -int -main (void) -{ - ffi_cif cif; - void* args[5]; - ffi_type* arg_types[5]; - - ffi_type s_type; - ffi_type *s_type_elements[3]; - - ffi_type l_type; - ffi_type *l_type_elements[6]; - - struct small_tag s1; - struct small_tag s2; - struct large_tag l1; - - int n; - struct small_tag res; - - s_type.size = 0; - s_type.alignment = 0; - s_type.type = FFI_TYPE_STRUCT; - s_type.elements = s_type_elements; - - s_type_elements[0] = &ffi_type_uchar; - s_type_elements[1] = &ffi_type_uchar; - s_type_elements[2] = NULL; - - l_type.size = 0; - l_type.alignment = 0; - l_type.type = FFI_TYPE_STRUCT; - l_type.elements = l_type_elements; - - l_type_elements[0] = &ffi_type_uint; - l_type_elements[1] = &ffi_type_uint; - l_type_elements[2] = &ffi_type_uint; - l_type_elements[3] = &ffi_type_uint; - l_type_elements[4] = &ffi_type_uint; - l_type_elements[5] = NULL; - - arg_types[0] = &ffi_type_sint; - arg_types[1] = &s_type; - arg_types[2] = &l_type; - arg_types[3] = &s_type; - arg_types[4] = NULL; - - CHECK(ffi_prep_cif_var(&cif, FFI_DEFAULT_ABI, 1, 4, &s_type, arg_types) == FFI_OK); - - s1.a = 5; - s1.b = 6; - - l1.a = 10; - l1.b = 11; - l1.c = 12; - l1.d = 13; - l1.e = 14; - - s2.a = 7; - s2.b = 8; - - n = 41; - - args[0] = &n; - args[1] = &s1; - args[2] = &l1; - args[3] = &s2; - args[4] = NULL; - - ffi_call(&cif, FFI_FN(test_fn), &res, args); - /* { dg-output "5 6 10 11 12 13 14 7 8" } */ - printf("res: %d %d\n", res.a, res.b); - /* { dg-output "\nres: 12 14" } */ - - return 0; -} diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi/testsuite/libffi.call/va_struct3.c --- a/Modules/_ctypes/libffi/testsuite/libffi.call/va_struct3.c Sat Jul 19 16:34:33 2014 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,125 +0,0 @@ -/* Area: ffi_call - Purpose: Test passing struct in variable argument lists. - Limitations: none. - PR: none. - Originator: ARM Ltd. */ - -/* { dg-do run } */ -/* { dg-output "" { xfail avr32*-*-* } } */ - -#include "ffitest.h" -#include - -struct small_tag -{ - unsigned char a; - unsigned char b; -}; - -struct large_tag -{ - unsigned a; - unsigned b; - unsigned c; - unsigned d; - unsigned e; -}; - -static struct large_tag -test_fn (int n, ...) -{ - va_list ap; - struct small_tag s1; - struct small_tag s2; - struct large_tag l; - - va_start (ap, n); - s1 = va_arg (ap, struct small_tag); - l = va_arg (ap, struct large_tag); - s2 = va_arg (ap, struct small_tag); - printf ("%u %u %u %u %u %u %u %u %u\n", s1.a, s1.b, l.a, l.b, l.c, l.d, l.e, - s2.a, s2.b); - va_end (ap); - l.a += s1.a; - l.b += s1.b; - l.c += s2.a; - l.d += s2.b; - return l; -} - -int -main (void) -{ - ffi_cif cif; - void* args[5]; - ffi_type* arg_types[5]; - - ffi_type s_type; - ffi_type *s_type_elements[3]; - - ffi_type l_type; - ffi_type *l_type_elements[6]; - - struct small_tag s1; - struct small_tag s2; - struct large_tag l1; - - int n; - struct large_tag res; - - s_type.size = 0; - s_type.alignment = 0; - s_type.type = FFI_TYPE_STRUCT; - s_type.elements = s_type_elements; - - s_type_elements[0] = &ffi_type_uchar; - s_type_elements[1] = &ffi_type_uchar; - s_type_elements[2] = NULL; - - l_type.size = 0; - l_type.alignment = 0; - l_type.type = FFI_TYPE_STRUCT; - l_type.elements = l_type_elements; - - l_type_elements[0] = &ffi_type_uint; - l_type_elements[1] = &ffi_type_uint; - l_type_elements[2] = &ffi_type_uint; - l_type_elements[3] = &ffi_type_uint; - l_type_elements[4] = &ffi_type_uint; - l_type_elements[5] = NULL; - - arg_types[0] = &ffi_type_sint; - arg_types[1] = &s_type; - arg_types[2] = &l_type; - arg_types[3] = &s_type; - arg_types[4] = NULL; - - CHECK(ffi_prep_cif_var(&cif, FFI_DEFAULT_ABI, 1, 4, &l_type, arg_types) == FFI_OK); - - s1.a = 5; - s1.b = 6; - - l1.a = 10; - l1.b = 11; - l1.c = 12; - l1.d = 13; - l1.e = 14; - - s2.a = 7; - s2.b = 8; - - n = 41; - - args[0] = &n; - args[1] = &s1; - args[2] = &l1; - args[3] = &s2; - args[4] = NULL; - - ffi_call(&cif, FFI_FN(test_fn), &res, args); - /* { dg-output "5 6 10 11 12 13 14 7 8" } */ - printf("res: %d %d %d %d %d\n", res.a, res.b, res.c, res.d, res.e); - /* { dg-output "\nres: 15 17 19 21 14" } */ - - return 0; -} diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi/testsuite/libffi.special/ffitestcxx.h --- a/Modules/_ctypes/libffi/testsuite/libffi.special/ffitestcxx.h Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/_ctypes/libffi/testsuite/libffi.special/ffitestcxx.h Sun Jul 20 10:52:46 2014 -0400 @@ -53,3 +53,44 @@ #define PRIuLL "llu" #endif +#ifdef USING_MMAP +static inline void * +allocate_mmap (size_t size) +{ + void *page; +#if defined (HAVE_MMAP_DEV_ZERO) + static int dev_zero_fd = -1; +#endif + +#ifdef HAVE_MMAP_DEV_ZERO + if (dev_zero_fd == -1) + { + dev_zero_fd = open ("/dev/zero", O_RDONLY); + if (dev_zero_fd == -1) + { + perror ("open /dev/zero: %m"); + exit (1); + } + } +#endif + + +#ifdef HAVE_MMAP_ANON + page = mmap (NULL, size, PROT_READ | PROT_WRITE | PROT_EXEC, + MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); +#endif +#ifdef HAVE_MMAP_DEV_ZERO + page = mmap (NULL, size, PROT_READ | PROT_WRITE | PROT_EXEC, + MAP_PRIVATE, dev_zero_fd, 0); +#endif + + if (page == (char *) MAP_FAILED) + { + perror ("virtual memory exhausted"); + exit (1); + } + + return page; +} + +#endif diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi/testsuite/libffi.special/special.exp --- a/Modules/_ctypes/libffi/testsuite/libffi.special/special.exp Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/_ctypes/libffi/testsuite/libffi.special/special.exp Sun Jul 20 10:52:46 2014 -0400 @@ -1,4 +1,4 @@ -# Copyright (C) 2003, 2006, 2009, 2010 Free Software Foundation, Inc. +# Copyright (C) 2003, 2006, 2009 Free Software Foundation, Inc. # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -14,6 +14,8 @@ # along with this program; see the file COPYING3. If not see # . +load_lib libffi-dg.exp + dg-init libffi-init @@ -23,14 +25,10 @@ set cxx_options " -shared-libgcc -lstdc++" -if { [string match $using_gcc "yes"] } { - - dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.cc]] $cxx_options "-O0 -W -Wall" - dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.cc]] $cxx_options "-O2" - dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.cc]] $cxx_options "-O3" - dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.cc]] $cxx_options "-Os" - -} +dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.cc]] $cxx_options "-O0 -W -Wall" +dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.cc]] $cxx_options "-O2" +dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.cc]] $cxx_options "-O3" +dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.cc]] $cxx_options "-Os" dg-finish diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi/testsuite/libffi.special/unwindtest.cc --- a/Modules/_ctypes/libffi/testsuite/libffi.special/unwindtest.cc Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/_ctypes/libffi/testsuite/libffi.special/unwindtest.cc Sun Jul 20 10:52:46 2014 -0400 @@ -5,7 +5,6 @@ Originator: Jeff Sturm */ /* { dg-do run } */ - #include "ffitestcxx.h" #if defined HAVE_STDINT_H diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi/testsuite/libffi.special/unwindtest_ffi_call.cc --- a/Modules/_ctypes/libffi/testsuite/libffi.special/unwindtest_ffi_call.cc Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/_ctypes/libffi/testsuite/libffi.special/unwindtest_ffi_call.cc Sun Jul 20 10:52:46 2014 -0400 @@ -5,7 +5,6 @@ Originator: Andreas Tobler 20061213 */ /* { dg-do run } */ - #include "ffitestcxx.h" static int checking(int a __UNUSED__, short b __UNUSED__, diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi/texinfo.tex --- a/Modules/_ctypes/libffi/texinfo.tex Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/_ctypes/libffi/texinfo.tex Sun Jul 20 10:52:46 2014 -0400 @@ -1,18 +1,18 @@ % texinfo.tex -- TeX macros to handle Texinfo files. -% +% % Load plain if necessary, i.e., if running under initex. \expandafter\ifx\csname fmtname\endcsname\relax\input plain\fi % -\def\texinfoversion{2012-06-05.14} -% -% Copyright 1985, 1986, 1988, 1990, 1991, 1992, 1993, 1994, 1995, -% 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, -% 2007, 2008, 2009, 2010, 2011, 2012 Free Software Foundation, Inc. -% -% This texinfo.tex file is free software: you can redistribute it and/or +\def\texinfoversion{2005-07-05.19} +% +% Copyright (C) 1985, 1986, 1988, 1990, 1991, 1992, 1993, 1994, 1995, +% 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005 Free Software +% Foundation, Inc. +% +% This texinfo.tex file is free software; you can redistribute it and/or % modify it under the terms of the GNU General Public License as -% published by the Free Software Foundation, either version 3 of the -% License, or (at your option) any later version. +% published by the Free Software Foundation; either version 2, or (at +% your option) any later version. % % This texinfo.tex file is distributed in the hope that it will be % useful, but WITHOUT ANY WARRANTY; without even the implied warranty @@ -20,7 +20,9 @@ % General Public License for more details. % % You should have received a copy of the GNU General Public License -% along with this program. If not, see . +% along with this texinfo.tex file; see the file COPYING. If not, write +% to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, +% Boston, MA 02110-1301, USA. % % As a special exception, when this file is read by TeX when processing % a Texinfo source document, you may use the result without @@ -28,9 +30,9 @@ % % Please try the latest version of texinfo.tex before submitting bug % reports; you can get the latest version from: -% http://ftp.gnu.org/gnu/texinfo/ (the Texinfo release area), or -% http://ftpmirror.gnu.org/texinfo/ (same, via a mirror), or -% http://www.gnu.org/software/texinfo/ (the Texinfo home page) +% http://www.gnu.org/software/texinfo/ (the Texinfo home page), or +% ftp://tug.org/tex/texinfo.tex +% (and all CTAN mirrors, see http://www.ctan.org). % The texinfo.tex in any given distribution could well be out % of date, so if that's what you're using, please check. % @@ -65,6 +67,7 @@ \everyjob{\message{[Texinfo version \texinfoversion]}% \catcode`+=\active \catcode`\_=\active} +\message{Basics,} \chardef\other=12 % We never want plain's \outer definition of \+ in Texinfo. @@ -92,13 +95,10 @@ \let\ptexnewwrite\newwrite \let\ptexnoindent=\noindent \let\ptexplus=+ -\let\ptexraggedright=\raggedright \let\ptexrbrace=\} \let\ptexslash=\/ \let\ptexstar=\* \let\ptext=\t -\let\ptextop=\top -{\catcode`\'=\active \global\let\ptexquoteright'}% active in plain's math mode % If this character appears in an error message or help string, it % starts a new line in the output. @@ -116,11 +116,10 @@ % Set up fixed words for English if not already set. \ifx\putwordAppendix\undefined \gdef\putwordAppendix{Appendix}\fi \ifx\putwordChapter\undefined \gdef\putwordChapter{Chapter}\fi -\ifx\putworderror\undefined \gdef\putworderror{error}\fi \ifx\putwordfile\undefined \gdef\putwordfile{file}\fi \ifx\putwordin\undefined \gdef\putwordin{in}\fi -\ifx\putwordIndexIsEmpty\undefined \gdef\putwordIndexIsEmpty{(Index is empty)}\fi -\ifx\putwordIndexNonexistent\undefined \gdef\putwordIndexNonexistent{(Index is nonexistent)}\fi +\ifx\putwordIndexIsEmpty\undefined \gdef\putwordIndexIsEmpty{(Index is empty)}\fi +\ifx\putwordIndexNonexistent\undefined \gdef\putwordIndexNonexistent{(Index is nonexistent)}\fi \ifx\putwordInfo\undefined \gdef\putwordInfo{Info}\fi \ifx\putwordInstanceVariableof\undefined \gdef\putwordInstanceVariableof{Instance Variable of}\fi \ifx\putwordMethodon\undefined \gdef\putwordMethodon{Method on}\fi @@ -154,25 +153,28 @@ \ifx\putwordDefopt\undefined \gdef\putwordDefopt{User Option}\fi \ifx\putwordDeffunc\undefined \gdef\putwordDeffunc{Function}\fi -% Since the category of space is not known, we have to be careful. -\chardef\spacecat = 10 -\def\spaceisspace{\catcode`\ =\spacecat} - -% sometimes characters are active, so we need control sequences. -\chardef\ampChar = `\& +% In some macros, we cannot use the `\? notation---the left quote is +% in some cases the escape char. +\chardef\backChar = `\\ \chardef\colonChar = `\: \chardef\commaChar = `\, -\chardef\dashChar = `\- \chardef\dotChar = `\. \chardef\exclamChar= `\! -\chardef\hashChar = `\# -\chardef\lquoteChar= `\` +\chardef\plusChar = `\+ \chardef\questChar = `\? -\chardef\rquoteChar= `\' \chardef\semiChar = `\; -\chardef\slashChar = `\/ \chardef\underChar = `\_ +\chardef\spaceChar = `\ % +\chardef\spacecat = 10 +\def\spaceisspace{\catcode\spaceChar=\spacecat} + +{% for help with debugging. + % example usage: \expandafter\show\activebackslash + \catcode`\! = 0 \catcode`\\ = \active + !global!def!activebackslash{\} +} + % Ignore a token. % \def\gobble#1{} @@ -201,7 +203,36 @@ % that mark overfull boxes (in case you have decided % that the text looks ok even though it passes the margin). % -\def\finalout{\overfullrule=0pt } +\def\finalout{\overfullrule=0pt} + +% @| inserts a changebar to the left of the current line. It should +% surround any changed text. This approach does *not* work if the +% change spans more than two lines of output. To handle that, we would +% have adopt a much more difficult approach (putting marks into the main +% vertical list for the beginning and end of each change). +% +\def\|{% + % \vadjust can only be used in horizontal mode. + \leavevmode + % + % Append this vertical mode material after the current line in the output. + \vadjust{% + % We want to insert a rule with the height and depth of the current + % leading; that is exactly what \strutbox is supposed to record. + \vskip-\baselineskip + % + % \vadjust-items are inserted at the left edge of the type. So + % the \llap here moves out into the left-hand margin. + \llap{% + % + % For a thicker or thinner bar, change the `1pt'. + \vrule height\baselineskip width1pt + % + % This is the space between the bar and the text. + \hskip 12pt + }% + }% +} % Sometimes it is convenient to have everything in the transcript file % and nothing on the terminal. We don't just call \tracingall here, @@ -219,7 +250,7 @@ \tracingmacros2 \tracingrestores1 \showboxbreadth\maxdimen \showboxdepth\maxdimen - \ifx\eTeXversion\thisisundefined\else % etex gives us more logging + \ifx\eTeXversion\undefined\else % etex gives us more logging \tracingscantokens1 \tracingifs1 \tracinggroups1 @@ -230,13 +261,6 @@ \errorcontextlines16 }% -% @errormsg{MSG}. Do the index-like expansions on MSG, but if things -% aren't perfect, it's not the end of the world, being an error message, -% after all. -% -\def\errormsg{\begingroup \indexnofonts \doerrormsg} -\def\doerrormsg#1{\errmessage{#1}} - % add check for \lastpenalty to plain's definitions. If the last thing % we did was a \nobreak, we don't want to insert more space. % @@ -247,6 +271,7 @@ \def\bigbreak{\ifnum\lastpenalty<10000\par\ifdim\lastskip<\bigskipamount \removelastskip\penalty-200\bigskip\fi\fi} +% For @cropmarks command. % Do @cropmarks to get crop marks. % \newif\ifcropmarks @@ -260,50 +285,6 @@ \newdimen\cornerthick \cornerthick=.3pt \newdimen\topandbottommargin \topandbottommargin=.75in -% Output a mark which sets \thischapter, \thissection and \thiscolor. -% We dump everything together because we only have one kind of mark. -% This works because we only use \botmark / \topmark, not \firstmark. -% -% A mark contains a subexpression of the \ifcase ... \fi construct. -% \get*marks macros below extract the needed part using \ifcase. -% -% Another complication is to let the user choose whether \thischapter -% (\thissection) refers to the chapter (section) in effect at the top -% of a page, or that at the bottom of a page. The solution is -% described on page 260 of The TeXbook. It involves outputting two -% marks for the sectioning macros, one before the section break, and -% one after. I won't pretend I can describe this better than DEK... -\def\domark{% - \toks0=\expandafter{\lastchapterdefs}% - \toks2=\expandafter{\lastsectiondefs}% - \toks4=\expandafter{\prevchapterdefs}% - \toks6=\expandafter{\prevsectiondefs}% - \toks8=\expandafter{\lastcolordefs}% - \mark{% - \the\toks0 \the\toks2 - \noexpand\or \the\toks4 \the\toks6 - \noexpand\else \the\toks8 - }% -} -% \topmark doesn't work for the very first chapter (after the title -% page or the contents), so we use \firstmark there -- this gets us -% the mark with the chapter defs, unless the user sneaks in, e.g., -% @setcolor (or @url, or @link, etc.) between @contents and the very -% first @chapter. -\def\gettopheadingmarks{% - \ifcase0\topmark\fi - \ifx\thischapter\empty \ifcase0\firstmark\fi \fi -} -\def\getbottomheadingmarks{\ifcase1\botmark\fi} -\def\getcolormarks{\ifcase2\topmark\fi} - -% Avoid "undefined control sequence" errors. -\def\lastchapterdefs{} -\def\lastsectiondefs{} -\def\prevchapterdefs{} -\def\prevsectiondefs{} -\def\lastcolordefs{} - % Main output routine. \chardef\PAGE = 255 \output = {\onepageout{\pagecontents\PAGE}} @@ -321,9 +302,7 @@ % % Do this outside of the \shipout so @code etc. will be expanded in % the headline as they should be, not taken literally (outputting ''code). - \ifodd\pageno \getoddheadingmarks \else \getevenheadingmarks \fi \setbox\headlinebox = \vbox{\let\hsize=\pagewidth \makeheadline}% - \ifodd\pageno \getoddfootingmarks \else \getevenfootingmarks \fi \setbox\footlinebox = \vbox{\let\hsize=\pagewidth \makefootline}% % {% @@ -332,13 +311,6 @@ % before the \shipout runs. % \indexdummies % don't expand commands in the output. - \normalturnoffactive % \ in index entries must not stay \, e.g., if - % the page break happens to be in the middle of an example. - % We don't want .vr (or whatever) entries like this: - % \entry{{\tt \indexbackslash }acronym}{32}{\code {\acronym}} - % "\acronym" won't work when it's read back in; - % it needs to be - % {\code {{\tt \backslashcurfont }acronym} \shipout\vbox{% % Do this early so pdf references go to the beginning of the page. \ifpdfmakepagedest \pdfdest name{\the\pageno} xyz\fi @@ -366,9 +338,9 @@ \pagebody{#1}% \ifdim\ht\footlinebox > 0pt % Only leave this space if the footline is nonempty. - % (We lessened \vsize for it in \oddfootingyyy.) + % (We lessened \vsize for it in \oddfootingxxx.) % The \baselineskip=24pt in plain's \makefootline has no effect. - \vskip 24pt + \vskip 2\baselineskip \unvbox\footlinebox \fi % @@ -402,7 +374,7 @@ % marginal hacks, juha@viisa.uucp (Juha Takala) \ifvoid\margin\else % marginal info is present \rlap{\kern\hsize\vbox to\z@{\kern1pt\box\margin \vss}}\fi -\dimen@=\dp#1\relax \unvbox#1\relax +\dimen@=\dp#1 \unvbox#1 \ifvoid\footins\else\vskip\skip\footins\footnoterule \unvbox\footins\fi \ifr@ggedbottom \kern-\dimen@ \vfil \fi} } @@ -424,7 +396,7 @@ % \def\parsearg{\parseargusing{}} \def\parseargusing#1#2{% - \def\argtorun{#2}% + \def\next{#2}% \begingroup \obeylines \spaceisspace @@ -443,7 +415,7 @@ \def\argremovecomment#1\comment#2\ArgTerm{\argremovec #1\c\ArgTerm} \def\argremovec#1\c#2\ArgTerm{\argcheckspaces#1\^^M\ArgTerm} -% Each occurrence of `\^^M' or `\^^M' is replaced by a single space. +% Each occurence of `\^^M' or `\^^M' is replaced by a single space. % % \argremovec might leave us with trailing space, e.g., % @end itemize @c foo @@ -455,7 +427,8 @@ \def\argcheckspacesY#1\^^M#2\^^M#3\ArgTerm{% \def\temp{#3}% \ifx\temp\empty - % Do not use \next, perhaps the caller of \parsearg uses it; reuse \temp: + % We cannot use \next here, as it holds the macro to run; + % thus we reuse \temp. \let\temp\finishparsearg \else \let\temp\argcheckspaces @@ -467,14 +440,14 @@ % If a _delimited_ argument is enclosed in braces, they get stripped; so % to get _exactly_ the rest of the line, we had to prevent such situation. % We prepended an \empty token at the very beginning and we expand it now, -% just before passing the control to \argtorun. -% (Similarly, we have to think about #3 of \argcheckspacesY above: it is +% just before passing the control to \next. +% (Similarily, we have to think about #3 of \argcheckspacesY above: it is % either the null string, or it ends with \^^M---thus there is no danger % that a pair of braces would be stripped. % % But first, we have to remove the trailing space token. % -\def\finishparsearg#1 \ArgTerm{\expandafter\argtorun\expandafter{#1}} +\def\finishparsearg#1 \ArgTerm{\expandafter\next\expandafter{#1}} % \parseargdef\foo{...} % is roughly equivalent to @@ -525,12 +498,12 @@ % used to check whether the current environment is the one expected. % % Non-false conditionals (@iftex, @ifset) don't fit into this, so they -% are not treated as environments; they don't open a group. (The +% are not treated as enviroments; they don't open a group. (The % implementation of @end takes care not to call \endgroup in this % special case.) -% At run-time, environments start with this: +% At runtime, environments start with this: \def\startenvironment#1{\begingroup\def\thisenv{#1}} % initialize \let\thisenv\empty @@ -548,7 +521,7 @@ \fi } -% Environment mismatch, #1 expected: +% Evironment mismatch, #1 expected: \def\badenverr{% \errhelp = \EMsimple \errmessage{This command can appear only \inenvironment\temp, @@ -556,7 +529,7 @@ } \def\inenvironment#1{% \ifx#1\empty - outside of any environment% + out of any environment% \else in environment \expandafter\string#1% \fi @@ -568,7 +541,7 @@ \parseargdef\end{% \if 1\csname iscond.#1\endcsname \else - % The general wording of \badenverr may not be ideal. + % The general wording of \badenverr may not be ideal, but... --kasal, 06nov03 \expandafter\checkenv\csname#1\endcsname \csname E#1\endcsname \endgroup @@ -578,6 +551,85 @@ \newhelp\EMsimple{Press RETURN to continue.} +%% Simple single-character @ commands + +% @@ prints an @ +% Kludge this until the fonts are right (grr). +\def\@{{\tt\char64}} + +% This is turned off because it was never documented +% and you can use @w{...} around a quote to suppress ligatures. +%% Define @` and @' to be the same as ` and ' +%% but suppressing ligatures. +%\def\`{{`}} +%\def\'{{'}} + +% Used to generate quoted braces. +\def\mylbrace {{\tt\char123}} +\def\myrbrace {{\tt\char125}} +\let\{=\mylbrace +\let\}=\myrbrace +\begingroup + % Definitions to produce \{ and \} commands for indices, + % and @{ and @} for the aux/toc files. + \catcode`\{ = \other \catcode`\} = \other + \catcode`\[ = 1 \catcode`\] = 2 + \catcode`\! = 0 \catcode`\\ = \other + !gdef!lbracecmd[\{]% + !gdef!rbracecmd[\}]% + !gdef!lbraceatcmd[@{]% + !gdef!rbraceatcmd[@}]% +!endgroup + +% @comma{} to avoid , parsing problems. +\let\comma = , + +% Accents: @, @dotaccent @ringaccent @ubaraccent @udotaccent +% Others are defined by plain TeX: @` @' @" @^ @~ @= @u @v @H. +\let\, = \c +\let\dotaccent = \. +\def\ringaccent#1{{\accent23 #1}} +\let\tieaccent = \t +\let\ubaraccent = \b +\let\udotaccent = \d + +% Other special characters: @questiondown @exclamdown @ordf @ordm +% Plain TeX defines: @AA @AE @O @OE @L (plus lowercase versions) @ss. +\def\questiondown{?`} +\def\exclamdown{!`} +\def\ordf{\leavevmode\raise1ex\hbox{\selectfonts\lllsize \underbar{a}}} +\def\ordm{\leavevmode\raise1ex\hbox{\selectfonts\lllsize \underbar{o}}} + +% Dotless i and dotless j, used for accents. +\def\imacro{i} +\def\jmacro{j} +\def\dotless#1{% + \def\temp{#1}% + \ifx\temp\imacro \ptexi + \else\ifx\temp\jmacro \j + \else \errmessage{@dotless can be used only with i or j}% + \fi\fi +} + +% The \TeX{} logo, as in plain, but resetting the spacing so that a +% period following counts as ending a sentence. (Idea found in latex.) +% +\edef\TeX{\TeX \spacefactor=1000 } + +% @LaTeX{} logo. Not quite the same results as the definition in +% latex.ltx, since we use a different font for the raised A; it's most +% convenient for us to use an explicitly smaller font, rather than using +% the \scriptstyle font (since we don't reset \scriptstyle and +% \scriptscriptstyle). +% +\def\LaTeX{% + L\kern-.36em + {\setbox0=\hbox{T}% + \vbox to \ht0{\hbox{\selectfonts\lllsize A}\vss}}% + \kern-.15em + \TeX +} + % Be sure we're in horizontal mode when doing a tie, since we make space % equivalent to this in @example-like environments. Otherwise, a space % at the beginning of a line will start with \penalty -- and @@ -609,7 +661,7 @@ \def\?{?\spacefactor=\endofsentencespacefactor\space} % @frenchspacing on|off says whether to put extra space after punctuation. -% +% \def\onword{on} \def\offword{off} % @@ -619,7 +671,7 @@ \else\ifx\temp\offword \plainnonfrenchspacing \else \errhelp = \EMsimple - \errmessage{Unknown @frenchspacing option `\temp', must be on|off}% + \errmessage{Unknown @frenchspacing option `\temp', must be on/off}% \fi\fi } @@ -701,6 +753,15 @@ \newdimen\mil \mil=0.001in +% Old definition--didn't work. +%\parseargdef\need{\par % +%% This method tries to make TeX break the page naturally +%% if the depth of the box does not fit. +%{\baselineskip=0pt% +%\vtop to #1\mil{\vfil}\kern -#1\mil\nobreak +%\prevdepth=-1000pt +%}} + \parseargdef\need{% % Ensure vertical mode, so we don't make a big box in the middle of a % paragraph. @@ -764,7 +825,7 @@ % @inmargin{WHICH}{TEXT} puts TEXT in the WHICH margin next to the current % paragraph. For more general purposes, use the \margin insertion -% class. WHICH is `l' or `r'. Not documented, written for gawk manual. +% class. WHICH is `l' or `r'. % \newskip\inmarginspacing \inmarginspacing=1cm \def\strutdepth{\dp\strutbox} @@ -811,51 +872,15 @@ \temp } -% @| inserts a changebar to the left of the current line. It should -% surround any changed text. This approach does *not* work if the -% change spans more than two lines of output. To handle that, we would -% have adopt a much more difficult approach (putting marks into the main -% vertical list for the beginning and end of each change). This command -% is not documented, not supported, and doesn't work. -% -\def\|{% - % \vadjust can only be used in horizontal mode. - \leavevmode - % - % Append this vertical mode material after the current line in the output. - \vadjust{% - % We want to insert a rule with the height and depth of the current - % leading; that is exactly what \strutbox is supposed to record. - \vskip-\baselineskip - % - % \vadjust-items are inserted at the left edge of the type. So - % the \llap here moves out into the left-hand margin. - \llap{% - % - % For a thicker or thinner bar, change the `1pt'. - \vrule height\baselineskip width1pt - % - % This is the space between the bar and the text. - \hskip 12pt - }% - }% -} - -% @include FILE -- \input text of FILE. +% @include file insert text of that file as input. % \def\include{\parseargusing\filenamecatcodes\includezzz} \def\includezzz#1{% \pushthisfilestack \def\thisfile{#1}% {% - \makevalueexpandable % we want to expand any @value in FILE. - \turnoffactive % and allow special characters in the expansion - \indexnofonts % Allow `@@' and other weird things in file names. - \wlog{texinfo.tex: doing @include of #1^^J}% - \edef\temp{\noexpand\input #1 }% - % - % This trickery is to read FILE outside of a group, in case it makes - % definitions, etc. + \makevalueexpandable + \def\temp{\input #1 }% \expandafter }\temp \popthisfilestack @@ -870,8 +895,6 @@ \catcode`>=\other \catcode`+=\other \catcode`-=\other - \catcode`\`=\other - \catcode`\'=\other } \def\pushthisfilestack{% @@ -887,7 +910,7 @@ \def\popthisfilestack{\errthisfilestackempty} \def\errthisfilestackempty{\errmessage{Internal error: the stack of filenames is empty.}} -% + \def\thisfile{} % @center line @@ -895,46 +918,36 @@ % \parseargdef\center{% \ifhmode - \let\centersub\centerH + \let\next\centerH \else - \let\centersub\centerV + \let\next\centerV \fi - \centersub{\hfil \ignorespaces#1\unskip \hfil}% - \let\centersub\relax % don't let the definition persist, just in case -} -\def\centerH#1{{% - \hfil\break - \advance\hsize by -\leftskip - \advance\hsize by -\rightskip - \line{#1}% - \break -}} -% -\newcount\centerpenalty -\def\centerV#1{% - % The idea here is the same as in \startdefun, \cartouche, etc.: if - % @center is the first thing after a section heading, we need to wipe - % out the negative parskip inserted by \sectionheading, but still - % prevent a page break here. - \centerpenalty = \lastpenalty - \ifnum\centerpenalty>10000 \vskip\parskip \fi - \ifnum\centerpenalty>9999 \penalty\centerpenalty \fi - \line{\kern\leftskip #1\kern\rightskip}% -} + \next{\hfil \ignorespaces#1\unskip \hfil}% +} +\def\centerH#1{% + {% + \hfil\break + \advance\hsize by -\leftskip + \advance\hsize by -\rightskip + \line{#1}% + \break + }% +} +\def\centerV#1{\line{\kern\leftskip #1\kern\rightskip}} % @sp n outputs n lines of vertical space -% + \parseargdef\sp{\vskip #1\baselineskip} % @comment ...line which is ignored... % @c is the same as @comment % @ignore ... @end ignore is another way to write a comment -% + \def\comment{\begingroup \catcode`\^^M=\other% \catcode`\@=\other \catcode`\{=\other \catcode`\}=\other% \commentxxx} {\catcode`\^^M=\other \gdef\commentxxx#1^^M{\endgroup}} -% + \let\c=\comment % @paragraphindent NCHARS @@ -1027,6 +1040,86 @@ } +% @asis just yields its argument. Used with @table, for example. +% +\def\asis#1{#1} + +% @math outputs its argument in math mode. +% +% One complication: _ usually means subscripts, but it could also mean +% an actual _ character, as in @math{@var{some_variable} + 1}. So make +% _ active, and distinguish by seeing if the current family is \slfam, +% which is what @var uses. +{ + \catcode\underChar = \active + \gdef\mathunderscore{% + \catcode\underChar=\active + \def_{\ifnum\fam=\slfam \_\else\sb\fi}% + } +} +% Another complication: we want \\ (and @\) to output a \ character. +% FYI, plain.tex uses \\ as a temporary control sequence (why?), but +% this is not advertised and we don't care. Texinfo does not +% otherwise define @\. +% +% The \mathchar is class=0=ordinary, family=7=ttfam, position=5C=\. +\def\mathbackslash{\ifnum\fam=\ttfam \mathchar"075C \else\backslash \fi} +% +\def\math{% + \tex + \mathunderscore + \let\\ = \mathbackslash + \mathactive + $\finishmath +} +\def\finishmath#1{#1$\endgroup} % Close the group opened by \tex. + +% Some active characters (such as <) are spaced differently in math. +% We have to reset their definitions in case the @math was an argument +% to a command which sets the catcodes (such as @item or @section). +% +{ + \catcode`^ = \active + \catcode`< = \active + \catcode`> = \active + \catcode`+ = \active + \gdef\mathactive{% + \let^ = \ptexhat + \let< = \ptexless + \let> = \ptexgtr + \let+ = \ptexplus + } +} + +% @bullet and @minus need the same treatment as @math, just above. +\def\bullet{$\ptexbullet$} +\def\minus{$-$} + +% @dots{} outputs an ellipsis using the current font. +% We do .5em per period so that it has the same spacing in a typewriter +% font as three actual period characters. +% +\def\dots{% + \leavevmode + \hbox to 1.5em{% + \hskip 0pt plus 0.25fil + .\hfil.\hfil.% + \hskip 0pt plus 0.5fil + }% +} + +% @enddots{} is an end-of-sentence ellipsis. +% +\def\enddots{% + \dots + \spacefactor=\endofsentencespacefactor +} + +% @comma{} is so commas can be inserted into text without messing up +% Texinfo's parsing. +% +\let\comma = , + % @refill is a no-op. \let\refill=\relax @@ -1091,8 +1184,9 @@ \newif\ifpdfmakepagedest % when pdftex is run in dvi mode, \pdfoutput is defined (so \pdfoutput=1 -% can be set). So we test for \relax and 0 as well as being undefined. -\ifx\pdfoutput\thisisundefined +% can be set). So we test for \relax and 0 as well as \undefined, +% borrowed from ifpdf.sty. +\ifx\pdfoutput\undefined \else \ifx\pdfoutput\relax \else @@ -1103,156 +1197,99 @@ \fi \fi -% PDF uses PostScript string constants for the names of xref targets, +% PDF uses PostScript string constants for the names of xref targets, to % for display in the outlines, and in other places. Thus, we have to % double any backslashes. Otherwise, a name like "\node" will be % interpreted as a newline (\n), followed by o, d, e. Not good. +% http://www.ntg.nl/pipermail/ntg-pdftex/2004-July/000654.html +% (and related messages, the final outcome is that it is up to the TeX +% user to double the backslashes and otherwise make the string valid, so +% that's we do). + +% double active backslashes. % -% See http://www.ntg.nl/pipermail/ntg-pdftex/2004-July/000654.html and -% related messages. The final outcome is that it is up to the TeX user -% to double the backslashes and otherwise make the string valid, so -% that's what we do. pdftex 1.30.0 (ca.2005) introduced a primitive to -% do this reliably, so we use it. - -% #1 is a control sequence in which to do the replacements, -% which we \xdef. -\def\txiescapepdf#1{% - \ifx\pdfescapestring\thisisundefined - % No primitive available; should we give a warning or log? - % Many times it won't matter. - \else - % The expandable \pdfescapestring primitive escapes parentheses, - % backslashes, and other special chars. - \xdef#1{\pdfescapestring{#1}}% - \fi -} - -\newhelp\nopdfimagehelp{Texinfo supports .png, .jpg, .jpeg, and .pdf images -with PDF output, and none of those formats could be found. (.eps cannot -be supported due to the design of the PDF format; use regular TeX (DVI -output) for that.)} +{\catcode`\@=0 \catcode`\\=\active + @gdef@activebackslash{@catcode`@\=@active @otherbackslash} + @gdef@activebackslashdouble{% + @catcode@backChar=@active + @let\=@doublebackslash} +} + +% To handle parens, we must adopt a different approach, since parens are +% not active characters. hyperref.dtx (which has the same problem as +% us) handles it with this amazing macro to replace tokens. I've +% tinkered with it a little for texinfo, but it's definitely from there. +% +% #1 is the tokens to replace. +% #2 is the replacement. +% #3 is the control sequence with the string. +% +\def\HyPsdSubst#1#2#3{% + \def\HyPsdReplace##1#1##2\END{% + ##1% + \ifx\\##2\\% + \else + #2% + \HyReturnAfterFi{% + \HyPsdReplace##2\END + }% + \fi + }% + \xdef#3{\expandafter\HyPsdReplace#3#1\END}% +} +\long\def\HyReturnAfterFi#1\fi{\fi#1} + +% #1 is a control sequence in which to do the replacements. +\def\backslashparens#1{% + \xdef#1{#1}% redefine it as its expansion; the definition is simply + % \lastnode when called from \setref -> \pdfmkdest. + \HyPsdSubst{(}{\backslashlparen}{#1}% + \HyPsdSubst{)}{\backslashrparen}{#1}% +} + +{\catcode\exclamChar = 0 \catcode\backChar = \other + !gdef!backslashlparen{\(}% + !gdef!backslashrparen{\)}% +} \ifpdf - % - % Color manipulation macros based on pdfcolor.tex, - % except using rgb instead of cmyk; the latter is said to render as a - % very dark gray on-screen and a very dark halftone in print, instead - % of actual black. - \def\rgbDarkRed{0.50 0.09 0.12} - \def\rgbBlack{0 0 0} - % - % k sets the color for filling (usual text, etc.); - % K sets the color for stroking (thin rules, e.g., normal _'s). - \def\pdfsetcolor#1{\pdfliteral{#1 rg #1 RG}} - % - % Set color, and create a mark which defines \thiscolor accordingly, - % so that \makeheadline knows which color to restore. - \def\setcolor#1{% - \xdef\lastcolordefs{\gdef\noexpand\thiscolor{#1}}% - \domark - \pdfsetcolor{#1}% - } - % - \def\maincolor{\rgbBlack} - \pdfsetcolor{\maincolor} - \edef\thiscolor{\maincolor} - \def\lastcolordefs{} - % - \def\makefootline{% - \baselineskip24pt - \line{\pdfsetcolor{\maincolor}\the\footline}% - } - % - \def\makeheadline{% - \vbox to 0pt{% - \vskip-22.5pt - \line{% - \vbox to8.5pt{}% - % Extract \thiscolor definition from the marks. - \getcolormarks - % Typeset the headline with \maincolor, then restore the color. - \pdfsetcolor{\maincolor}\the\headline\pdfsetcolor{\thiscolor}% - }% - \vss - }% - \nointerlineskip - } - % - % - \pdfcatalog{/PageMode /UseOutlines} - % - % #1 is image name, #2 width (might be empty/whitespace), #3 height (ditto). + \input pdfcolor + \pdfcatalog{/PageMode /UseOutlines}% \def\dopdfimage#1#2#3{% - \def\pdfimagewidth{#2}\setbox0 = \hbox{\ignorespaces #2}% - \def\pdfimageheight{#3}\setbox2 = \hbox{\ignorespaces #3}% - % - % pdftex (and the PDF format) support .pdf, .png, .jpg (among - % others). Let's try in that order, PDF first since if - % someone has a scalable image, presumably better to use that than a - % bitmap. - \let\pdfimgext=\empty - \begingroup - \openin 1 #1.pdf \ifeof 1 - \openin 1 #1.PDF \ifeof 1 - \openin 1 #1.png \ifeof 1 - \openin 1 #1.jpg \ifeof 1 - \openin 1 #1.jpeg \ifeof 1 - \openin 1 #1.JPG \ifeof 1 - \errhelp = \nopdfimagehelp - \errmessage{Could not find image file #1 for pdf}% - \else \gdef\pdfimgext{JPG}% - \fi - \else \gdef\pdfimgext{jpeg}% - \fi - \else \gdef\pdfimgext{jpg}% - \fi - \else \gdef\pdfimgext{png}% - \fi - \else \gdef\pdfimgext{PDF}% - \fi - \else \gdef\pdfimgext{pdf}% - \fi - \closein 1 - \endgroup - % - % without \immediate, ancient pdftex seg faults when the same image is + \def\imagewidth{#2}% + \def\imageheight{#3}% + % without \immediate, pdftex seg faults when the same image is % included twice. (Version 3.14159-pre-1.0-unofficial-20010704.) \ifnum\pdftexversion < 14 \immediate\pdfimage \else \immediate\pdfximage \fi - \ifdim \wd0 >0pt width \pdfimagewidth \fi - \ifdim \wd2 >0pt height \pdfimageheight \fi + \ifx\empty\imagewidth\else width \imagewidth \fi + \ifx\empty\imageheight\else height \imageheight \fi \ifnum\pdftexversion<13 - #1.\pdfimgext + #1.pdf% \else - {#1.\pdfimgext}% + {#1.pdf}% \fi \ifnum\pdftexversion < 14 \else \pdfrefximage \pdflastximage \fi} - % \def\pdfmkdest#1{{% % We have to set dummies so commands such as @code, and characters % such as \, aren't expanded when present in a section title. - \indexnofonts - \turnoffactive - \makevalueexpandable + \atdummies + \activebackslashdouble \def\pdfdestname{#1}% - \txiescapepdf\pdfdestname - \safewhatsit{\pdfdest name{\pdfdestname} xyz}% - }} + \backslashparens\pdfdestname + \pdfdest name{\pdfdestname} xyz% + }}% % % used to mark target names; must be expandable. - \def\pdfmkpgn#1{#1} - % - % by default, use a color that is dark enough to print on paper as - % nearly black, but still distinguishable for online viewing. - \def\urlcolor{\rgbDarkRed} - \def\linkcolor{\rgbDarkRed} - \def\endlink{\setcolor{\maincolor}\pdfendlink} - % + \def\pdfmkpgn#1{#1}% + % + \let\linkcolor = \Blue % was Cyan, but that seems light? + \def\endlink{\Black\pdfendlink} % Adding outlines to PDF; macros for calculating structure of outlines % come from Petr Olsak \def\expnumber#1{\expandafter\ifx\csname#1\endcsname\relax 0% @@ -1272,24 +1309,29 @@ % page number. We could generate a destination for the section % text in the case where a section has no node, but it doesn't % seem worth the trouble, since most documents are normally structured. - \edef\pdfoutlinedest{#3}% + \def\pdfoutlinedest{#3}% \ifx\pdfoutlinedest\empty \def\pdfoutlinedest{#4}% \else - \txiescapepdf\pdfoutlinedest + % Doubled backslashes in the name. + {\activebackslashdouble \xdef\pdfoutlinedest{#3}% + \backslashparens\pdfoutlinedest}% \fi % - % Also escape PDF chars in the display string. - \edef\pdfoutlinetext{#1}% - \txiescapepdf\pdfoutlinetext + % Also double the backslashes in the display string. + {\activebackslashdouble \xdef\pdfoutlinetext{#1}% + \backslashparens\pdfoutlinetext}% % \pdfoutline goto name{\pdfmkpgn{\pdfoutlinedest}}#2{\pdfoutlinetext}% } % \def\pdfmakeoutlines{% \begingroup + % Thanh's hack / proper braces in bookmarks + \edef\mylbrace{\iftrue \string{\else}\fi}\let\{=\mylbrace + \edef\myrbrace{\iffalse{\else\string}\fi}\let\}=\myrbrace + % % Read toc silently, to get counts of subentries for \pdfoutline. - \def\partentry##1##2##3##4{}% ignore parts in the outlines \def\numchapentry##1##2##3##4{% \def\thischapnum{##2}% \def\thissecnum{0}% @@ -1343,63 +1385,35 @@ % Latin 2 (0xea) gets translated to a | character. Info from % Staszek Wawrykiewicz, 19 Jan 2004 04:09:24 +0100. % - % TODO this right, we have to translate 8-bit characters to - % their "best" equivalent, based on the @documentencoding. Too - % much work for too little return. Just use the ASCII equivalents - % we use for the index sort strings. - % + % xx to do this right, we have to translate 8-bit characters to + % their "best" equivalent, based on the @documentencoding. Right + % now, I guess we'll just let the pdf reader have its way. \indexnofonts \setupdatafile - % We can have normal brace characters in the PDF outlines, unlike - % Texinfo index files. So set that up. - \def\{{\lbracecharliteral}% - \def\}{\rbracecharliteral}% - \catcode`\\=\active \otherbackslash - \input \tocreadfilename + \activebackslash + \input \jobname.toc \endgroup } - {\catcode`[=1 \catcode`]=2 - \catcode`{=\other \catcode`}=\other - \gdef\lbracecharliteral[{]% - \gdef\rbracecharliteral[}]% - ] % \def\skipspaces#1{\def\PP{#1}\def\D{|}% \ifx\PP\D\let\nextsp\relax \else\let\nextsp\skipspaces - \addtokens{\filename}{\PP}% - \advance\filenamelength by 1 + \ifx\p\space\else\addtokens{\filename}{\PP}% + \advance\filenamelength by 1 + \fi \fi \nextsp} - \def\getfilename#1{% - \filenamelength=0 - % If we don't expand the argument now, \skipspaces will get - % snagged on things like "@value{foo}". - \edef\temp{#1}% - \expandafter\skipspaces\temp|\relax - } + \def\getfilename#1{\filenamelength=0\expandafter\skipspaces#1|\relax} \ifnum\pdftexversion < 14 \let \startlink \pdfannotlink \else \let \startlink \pdfstartlink \fi - % make a live url in pdf output. \def\pdfurl#1{% \begingroup - % it seems we really need yet another set of dummies; have not - % tried to figure out what each command should do in the context - % of @url. for now, just make @/ a no-op, that's the only one - % people have actually reported a problem with. - % - \normalturnoffactive - \def\@{@}% - \let\/=\empty + \normalturnoffactive\def\@{@}% \makevalueexpandable - % do we want to go so far as to use \indexnofonts instead of just - % special-casing \var here? - \def\var##1{##1}% - % - \leavevmode\setcolor{\urlcolor}% + \leavevmode\Red \startlink attr{/Border [0 0 0]}% user{/Subtype /Link /A << /S /URI /URI (#1) >>}% \endgroup} @@ -1426,15 +1440,13 @@ {\noexpand\pdflink{\the\toksC}}\toksC={}\global\countA=0} \def\pdflink#1{% \startlink attr{/Border [0 0 0]} goto name{\pdfmkpgn{#1}} - \setcolor{\linkcolor}#1\endlink} + \linkcolor #1\endlink} \def\done{\edef\st{\global\noexpand\toksA={\the\toksB}}\st} \else - % non-pdf mode \let\pdfmkdest = \gobble \let\pdfurl = \gobble \let\endlink = \relax - \let\setcolor = \gobble - \let\pdfsetcolor = \gobble + \let\linkcolor = \relax \let\pdfmakeoutlines = \relax \fi % \ifx\pdfoutput @@ -1460,10 +1472,6 @@ \def\bf{\fam=\bffam \setfontstyle{bf}}\def\bfstylename{bf} \def\tt{\fam=\ttfam \setfontstyle{tt}} -% Unfortunately, we have to override this for titles and the like, since -% in those cases "rm" is bold. Sigh. -\def\rmisbold{\rm\def\curfontstyle{bf}} - % Texinfo sort of supports the sans serif font style, which plain TeX does not. % So we set up a \sf. \newfam\sffam @@ -1473,6 +1481,8 @@ % We don't need math for this font style. \def\ttsl{\setfontstyle{ttsl}} +% Default leading. +\newdimen\textleading \textleading = 13.2pt % Set the baselineskip to #1, and the lineskip and strut size % correspondingly. There is no deep meaning behind these magic numbers @@ -1482,13 +1492,8 @@ \def\strutheightpercent{.70833} \def\strutdepthpercent {.29167} % -% can get a sort of poor man's double spacing by redefining this. -\def\baselinefactor{1} -% -\newdimen\textleading \def\setleading#1{% - \dimen0 = #1\relax - \normalbaselineskip = \baselinefactor\dimen0 + \normalbaselineskip = #1\relax \normallineskip = \lineskipfactor\normalbaselineskip \normalbaselines \setbox\strutbox =\hbox{% @@ -1497,295 +1502,20 @@ }% } -% PDF CMaps. See also LaTeX's t1.cmap. -% -% do nothing with this by default. -\expandafter\let\csname cmapOT1\endcsname\gobble -\expandafter\let\csname cmapOT1IT\endcsname\gobble -\expandafter\let\csname cmapOT1TT\endcsname\gobble - -% if we are producing pdf, and we have \pdffontattr, then define cmaps. -% (\pdffontattr was introduced many years ago, but people still run -% older pdftex's; it's easy to conditionalize, so we do.) -\ifpdf \ifx\pdffontattr\thisisundefined \else - \begingroup - \catcode`\^^M=\active \def^^M{^^J}% Output line endings as the ^^J char. - \catcode`\%=12 \immediate\pdfobj stream {%!PS-Adobe-3.0 Resource-CMap -%%DocumentNeededResources: ProcSet (CIDInit) -%%IncludeResource: ProcSet (CIDInit) -%%BeginResource: CMap (TeX-OT1-0) -%%Title: (TeX-OT1-0 TeX OT1 0) -%%Version: 1.000 -%%EndComments -/CIDInit /ProcSet findresource begin -12 dict begin -begincmap -/CIDSystemInfo -<< /Registry (TeX) -/Ordering (OT1) -/Supplement 0 ->> def -/CMapName /TeX-OT1-0 def -/CMapType 2 def -1 begincodespacerange -<00> <7F> -endcodespacerange -8 beginbfrange -<00> <01> <0393> -<09> <0A> <03A8> -<23> <26> <0023> -<28> <3B> <0028> -<3F> <5B> <003F> -<5D> <5E> <005D> -<61> <7A> <0061> -<7B> <7C> <2013> -endbfrange -40 beginbfchar -<02> <0398> -<03> <039B> -<04> <039E> -<05> <03A0> -<06> <03A3> -<07> <03D2> -<08> <03A6> -<0B> <00660066> -<0C> <00660069> -<0D> <0066006C> -<0E> <006600660069> -<0F> <00660066006C> -<10> <0131> -<11> <0237> -<12> <0060> -<13> <00B4> -<14> <02C7> -<15> <02D8> -<16> <00AF> -<17> <02DA> -<18> <00B8> -<19> <00DF> -<1A> <00E6> -<1B> <0153> -<1C> <00F8> -<1D> <00C6> -<1E> <0152> -<1F> <00D8> -<21> <0021> -<22> <201D> -<27> <2019> -<3C> <00A1> -<3D> <003D> -<3E> <00BF> -<5C> <201C> -<5F> <02D9> -<60> <2018> -<7D> <02DD> -<7E> <007E> -<7F> <00A8> -endbfchar -endcmap -CMapName currentdict /CMap defineresource pop -end -end -%%EndResource -%%EOF - }\endgroup - \expandafter\edef\csname cmapOT1\endcsname#1{% - \pdffontattr#1{/ToUnicode \the\pdflastobj\space 0 R}% - }% -% -% \cmapOT1IT - \begingroup - \catcode`\^^M=\active \def^^M{^^J}% Output line endings as the ^^J char. - \catcode`\%=12 \immediate\pdfobj stream {%!PS-Adobe-3.0 Resource-CMap -%%DocumentNeededResources: ProcSet (CIDInit) -%%IncludeResource: ProcSet (CIDInit) -%%BeginResource: CMap (TeX-OT1IT-0) -%%Title: (TeX-OT1IT-0 TeX OT1IT 0) -%%Version: 1.000 -%%EndComments -/CIDInit /ProcSet findresource begin -12 dict begin -begincmap -/CIDSystemInfo -<< /Registry (TeX) -/Ordering (OT1IT) -/Supplement 0 ->> def -/CMapName /TeX-OT1IT-0 def -/CMapType 2 def -1 begincodespacerange -<00> <7F> -endcodespacerange -8 beginbfrange -<00> <01> <0393> -<09> <0A> <03A8> -<25> <26> <0025> -<28> <3B> <0028> -<3F> <5B> <003F> -<5D> <5E> <005D> -<61> <7A> <0061> -<7B> <7C> <2013> -endbfrange -42 beginbfchar -<02> <0398> -<03> <039B> -<04> <039E> -<05> <03A0> -<06> <03A3> -<07> <03D2> -<08> <03A6> -<0B> <00660066> -<0C> <00660069> -<0D> <0066006C> -<0E> <006600660069> -<0F> <00660066006C> -<10> <0131> -<11> <0237> -<12> <0060> -<13> <00B4> -<14> <02C7> -<15> <02D8> -<16> <00AF> -<17> <02DA> -<18> <00B8> -<19> <00DF> -<1A> <00E6> -<1B> <0153> -<1C> <00F8> -<1D> <00C6> -<1E> <0152> -<1F> <00D8> -<21> <0021> -<22> <201D> -<23> <0023> -<24> <00A3> -<27> <2019> -<3C> <00A1> -<3D> <003D> -<3E> <00BF> -<5C> <201C> -<5F> <02D9> -<60> <2018> -<7D> <02DD> -<7E> <007E> -<7F> <00A8> -endbfchar -endcmap -CMapName currentdict /CMap defineresource pop -end -end -%%EndResource -%%EOF - }\endgroup - \expandafter\edef\csname cmapOT1IT\endcsname#1{% - \pdffontattr#1{/ToUnicode \the\pdflastobj\space 0 R}% - }% -% -% \cmapOT1TT - \begingroup - \catcode`\^^M=\active \def^^M{^^J}% Output line endings as the ^^J char. - \catcode`\%=12 \immediate\pdfobj stream {%!PS-Adobe-3.0 Resource-CMap -%%DocumentNeededResources: ProcSet (CIDInit) -%%IncludeResource: ProcSet (CIDInit) -%%BeginResource: CMap (TeX-OT1TT-0) -%%Title: (TeX-OT1TT-0 TeX OT1TT 0) -%%Version: 1.000 -%%EndComments -/CIDInit /ProcSet findresource begin -12 dict begin -begincmap -/CIDSystemInfo -<< /Registry (TeX) -/Ordering (OT1TT) -/Supplement 0 ->> def -/CMapName /TeX-OT1TT-0 def -/CMapType 2 def -1 begincodespacerange -<00> <7F> -endcodespacerange -5 beginbfrange -<00> <01> <0393> -<09> <0A> <03A8> -<21> <26> <0021> -<28> <5F> <0028> -<61> <7E> <0061> -endbfrange -32 beginbfchar -<02> <0398> -<03> <039B> -<04> <039E> -<05> <03A0> -<06> <03A3> -<07> <03D2> -<08> <03A6> -<0B> <2191> -<0C> <2193> -<0D> <0027> -<0E> <00A1> -<0F> <00BF> -<10> <0131> -<11> <0237> -<12> <0060> -<13> <00B4> -<14> <02C7> -<15> <02D8> -<16> <00AF> -<17> <02DA> -<18> <00B8> -<19> <00DF> -<1A> <00E6> -<1B> <0153> -<1C> <00F8> -<1D> <00C6> -<1E> <0152> -<1F> <00D8> -<20> <2423> -<27> <2019> -<60> <2018> -<7F> <00A8> -endbfchar -endcmap -CMapName currentdict /CMap defineresource pop -end -end -%%EndResource -%%EOF - }\endgroup - \expandafter\edef\csname cmapOT1TT\endcsname#1{% - \pdffontattr#1{/ToUnicode \the\pdflastobj\space 0 R}% - }% -\fi\fi - - -% Set the font macro #1 to the font named \fontprefix#2. -% #3 is the font's design size, #4 is a scale factor, #5 is the CMap -% encoding (only OT1, OT1IT and OT1TT are allowed, or empty to omit). -% Example: -% #1 = \textrm -% #2 = \rmshape -% #3 = 10 -% #4 = \mainmagstep -% #5 = OT1 -% -\def\setfont#1#2#3#4#5{% - \font#1=\fontprefix#2#3 scaled #4 - \csname cmap#5\endcsname#1% -} -% This is what gets called when #5 of \setfont is empty. -\let\cmap\gobble -% -% (end of cmaps) +% Set the font macro #1 to the font named #2, adding on the +% specified font prefix (normally `cm'). +% #3 is the font's design size, #4 is a scale factor +\def\setfont#1#2#3#4{\font#1=\fontprefix#2#3 scaled #4} % Use cm as the default font prefix. % To specify the font prefix, you must define \fontprefix % before you read in texinfo.tex. -\ifx\fontprefix\thisisundefined +\ifx\fontprefix\undefined \def\fontprefix{cm} \fi % Support font families that don't use the same naming scheme as CM. \def\rmshape{r} -\def\rmbshape{bx} % where the normal face is bold +\def\rmbshape{bx} %where the normal face is bold \def\bfshape{b} \def\bxshape{bx} \def\ttshape{tt} @@ -1800,291 +1530,118 @@ \def\scshape{csc} \def\scbshape{csc} -% Definitions for a main text size of 11pt. (The default in Texinfo.) -% -\def\definetextfontsizexi{% % Text fonts (11.2pt, magstep1). \def\textnominalsize{11pt} \edef\mainmagstep{\magstephalf} -\setfont\textrm\rmshape{10}{\mainmagstep}{OT1} -\setfont\texttt\ttshape{10}{\mainmagstep}{OT1TT} -\setfont\textbf\bfshape{10}{\mainmagstep}{OT1} -\setfont\textit\itshape{10}{\mainmagstep}{OT1IT} -\setfont\textsl\slshape{10}{\mainmagstep}{OT1} -\setfont\textsf\sfshape{10}{\mainmagstep}{OT1} -\setfont\textsc\scshape{10}{\mainmagstep}{OT1} -\setfont\textttsl\ttslshape{10}{\mainmagstep}{OT1TT} +\setfont\textrm\rmshape{10}{\mainmagstep} +\setfont\texttt\ttshape{10}{\mainmagstep} +\setfont\textbf\bfshape{10}{\mainmagstep} +\setfont\textit\itshape{10}{\mainmagstep} +\setfont\textsl\slshape{10}{\mainmagstep} +\setfont\textsf\sfshape{10}{\mainmagstep} +\setfont\textsc\scshape{10}{\mainmagstep} +\setfont\textttsl\ttslshape{10}{\mainmagstep} \font\texti=cmmi10 scaled \mainmagstep \font\textsy=cmsy10 scaled \mainmagstep -\def\textecsize{1095} % A few fonts for @defun names and args. -\setfont\defbf\bfshape{10}{\magstep1}{OT1} -\setfont\deftt\ttshape{10}{\magstep1}{OT1TT} -\setfont\defttsl\ttslshape{10}{\magstep1}{OT1TT} +\setfont\defbf\bfshape{10}{\magstep1} +\setfont\deftt\ttshape{10}{\magstep1} +\setfont\defttsl\ttslshape{10}{\magstep1} \def\df{\let\tentt=\deftt \let\tenbf = \defbf \let\tenttsl=\defttsl \bf} % Fonts for indices, footnotes, small examples (9pt). \def\smallnominalsize{9pt} -\setfont\smallrm\rmshape{9}{1000}{OT1} -\setfont\smalltt\ttshape{9}{1000}{OT1TT} -\setfont\smallbf\bfshape{10}{900}{OT1} -\setfont\smallit\itshape{9}{1000}{OT1IT} -\setfont\smallsl\slshape{9}{1000}{OT1} -\setfont\smallsf\sfshape{9}{1000}{OT1} -\setfont\smallsc\scshape{10}{900}{OT1} -\setfont\smallttsl\ttslshape{10}{900}{OT1TT} +\setfont\smallrm\rmshape{9}{1000} +\setfont\smalltt\ttshape{9}{1000} +\setfont\smallbf\bfshape{10}{900} +\setfont\smallit\itshape{9}{1000} +\setfont\smallsl\slshape{9}{1000} +\setfont\smallsf\sfshape{9}{1000} +\setfont\smallsc\scshape{10}{900} +\setfont\smallttsl\ttslshape{10}{900} \font\smalli=cmmi9 \font\smallsy=cmsy9 -\def\smallecsize{0900} % Fonts for small examples (8pt). \def\smallernominalsize{8pt} -\setfont\smallerrm\rmshape{8}{1000}{OT1} -\setfont\smallertt\ttshape{8}{1000}{OT1TT} -\setfont\smallerbf\bfshape{10}{800}{OT1} -\setfont\smallerit\itshape{8}{1000}{OT1IT} -\setfont\smallersl\slshape{8}{1000}{OT1} -\setfont\smallersf\sfshape{8}{1000}{OT1} -\setfont\smallersc\scshape{10}{800}{OT1} -\setfont\smallerttsl\ttslshape{10}{800}{OT1TT} +\setfont\smallerrm\rmshape{8}{1000} +\setfont\smallertt\ttshape{8}{1000} +\setfont\smallerbf\bfshape{10}{800} +\setfont\smallerit\itshape{8}{1000} +\setfont\smallersl\slshape{8}{1000} +\setfont\smallersf\sfshape{8}{1000} +\setfont\smallersc\scshape{10}{800} +\setfont\smallerttsl\ttslshape{10}{800} \font\smalleri=cmmi8 \font\smallersy=cmsy8 -\def\smallerecsize{0800} % Fonts for title page (20.4pt): \def\titlenominalsize{20pt} -\setfont\titlerm\rmbshape{12}{\magstep3}{OT1} -\setfont\titleit\itbshape{10}{\magstep4}{OT1IT} -\setfont\titlesl\slbshape{10}{\magstep4}{OT1} -\setfont\titlett\ttbshape{12}{\magstep3}{OT1TT} -\setfont\titlettsl\ttslshape{10}{\magstep4}{OT1TT} -\setfont\titlesf\sfbshape{17}{\magstep1}{OT1} +\setfont\titlerm\rmbshape{12}{\magstep3} +\setfont\titleit\itbshape{10}{\magstep4} +\setfont\titlesl\slbshape{10}{\magstep4} +\setfont\titlett\ttbshape{12}{\magstep3} +\setfont\titlettsl\ttslshape{10}{\magstep4} +\setfont\titlesf\sfbshape{17}{\magstep1} \let\titlebf=\titlerm -\setfont\titlesc\scbshape{10}{\magstep4}{OT1} +\setfont\titlesc\scbshape{10}{\magstep4} \font\titlei=cmmi12 scaled \magstep3 \font\titlesy=cmsy10 scaled \magstep4 -\def\titleecsize{2074} +\def\authorrm{\secrm} +\def\authortt{\sectt} % Chapter (and unnumbered) fonts (17.28pt). \def\chapnominalsize{17pt} -\setfont\chaprm\rmbshape{12}{\magstep2}{OT1} -\setfont\chapit\itbshape{10}{\magstep3}{OT1IT} -\setfont\chapsl\slbshape{10}{\magstep3}{OT1} -\setfont\chaptt\ttbshape{12}{\magstep2}{OT1TT} -\setfont\chapttsl\ttslshape{10}{\magstep3}{OT1TT} -\setfont\chapsf\sfbshape{17}{1000}{OT1} +\setfont\chaprm\rmbshape{12}{\magstep2} +\setfont\chapit\itbshape{10}{\magstep3} +\setfont\chapsl\slbshape{10}{\magstep3} +\setfont\chaptt\ttbshape{12}{\magstep2} +\setfont\chapttsl\ttslshape{10}{\magstep3} +\setfont\chapsf\sfbshape{17}{1000} \let\chapbf=\chaprm -\setfont\chapsc\scbshape{10}{\magstep3}{OT1} +\setfont\chapsc\scbshape{10}{\magstep3} \font\chapi=cmmi12 scaled \magstep2 \font\chapsy=cmsy10 scaled \magstep3 -\def\chapecsize{1728} % Section fonts (14.4pt). \def\secnominalsize{14pt} -\setfont\secrm\rmbshape{12}{\magstep1}{OT1} -\setfont\secit\itbshape{10}{\magstep2}{OT1IT} -\setfont\secsl\slbshape{10}{\magstep2}{OT1} -\setfont\sectt\ttbshape{12}{\magstep1}{OT1TT} -\setfont\secttsl\ttslshape{10}{\magstep2}{OT1TT} -\setfont\secsf\sfbshape{12}{\magstep1}{OT1} +\setfont\secrm\rmbshape{12}{\magstep1} +\setfont\secit\itbshape{10}{\magstep2} +\setfont\secsl\slbshape{10}{\magstep2} +\setfont\sectt\ttbshape{12}{\magstep1} +\setfont\secttsl\ttslshape{10}{\magstep2} +\setfont\secsf\sfbshape{12}{\magstep1} \let\secbf\secrm -\setfont\secsc\scbshape{10}{\magstep2}{OT1} +\setfont\secsc\scbshape{10}{\magstep2} \font\seci=cmmi12 scaled \magstep1 \font\secsy=cmsy10 scaled \magstep2 -\def\sececsize{1440} % Subsection fonts (13.15pt). \def\ssecnominalsize{13pt} -\setfont\ssecrm\rmbshape{12}{\magstephalf}{OT1} -\setfont\ssecit\itbshape{10}{1315}{OT1IT} -\setfont\ssecsl\slbshape{10}{1315}{OT1} -\setfont\ssectt\ttbshape{12}{\magstephalf}{OT1TT} -\setfont\ssecttsl\ttslshape{10}{1315}{OT1TT} -\setfont\ssecsf\sfbshape{12}{\magstephalf}{OT1} +\setfont\ssecrm\rmbshape{12}{\magstephalf} +\setfont\ssecit\itbshape{10}{1315} +\setfont\ssecsl\slbshape{10}{1315} +\setfont\ssectt\ttbshape{12}{\magstephalf} +\setfont\ssecttsl\ttslshape{10}{1315} +\setfont\ssecsf\sfbshape{12}{\magstephalf} \let\ssecbf\ssecrm -\setfont\ssecsc\scbshape{10}{1315}{OT1} +\setfont\ssecsc\scbshape{10}{1315} \font\sseci=cmmi12 scaled \magstephalf \font\ssecsy=cmsy10 scaled 1315 -\def\ssececsize{1200} % Reduced fonts for @acro in text (10pt). \def\reducednominalsize{10pt} -\setfont\reducedrm\rmshape{10}{1000}{OT1} -\setfont\reducedtt\ttshape{10}{1000}{OT1TT} -\setfont\reducedbf\bfshape{10}{1000}{OT1} -\setfont\reducedit\itshape{10}{1000}{OT1IT} -\setfont\reducedsl\slshape{10}{1000}{OT1} -\setfont\reducedsf\sfshape{10}{1000}{OT1} -\setfont\reducedsc\scshape{10}{1000}{OT1} -\setfont\reducedttsl\ttslshape{10}{1000}{OT1TT} +\setfont\reducedrm\rmshape{10}{1000} +\setfont\reducedtt\ttshape{10}{1000} +\setfont\reducedbf\bfshape{10}{1000} +\setfont\reducedit\itshape{10}{1000} +\setfont\reducedsl\slshape{10}{1000} +\setfont\reducedsf\sfshape{10}{1000} +\setfont\reducedsc\scshape{10}{1000} +\setfont\reducedttsl\ttslshape{10}{1000} \font\reducedi=cmmi10 \font\reducedsy=cmsy10 -\def\reducedecsize{1000} - -\textleading = 13.2pt % line spacing for 11pt CM -\textfonts % reset the current fonts -\rm -} % end of 11pt text font size definitions, \definetextfontsizexi - - -% Definitions to make the main text be 10pt Computer Modern, with -% section, chapter, etc., sizes following suit. This is for the GNU -% Press printing of the Emacs 22 manual. Maybe other manuals in the -% future. Used with @smallbook, which sets the leading to 12pt. -% -\def\definetextfontsizex{% -% Text fonts (10pt). -\def\textnominalsize{10pt} -\edef\mainmagstep{1000} -\setfont\textrm\rmshape{10}{\mainmagstep}{OT1} -\setfont\texttt\ttshape{10}{\mainmagstep}{OT1TT} -\setfont\textbf\bfshape{10}{\mainmagstep}{OT1} -\setfont\textit\itshape{10}{\mainmagstep}{OT1IT} -\setfont\textsl\slshape{10}{\mainmagstep}{OT1} -\setfont\textsf\sfshape{10}{\mainmagstep}{OT1} -\setfont\textsc\scshape{10}{\mainmagstep}{OT1} -\setfont\textttsl\ttslshape{10}{\mainmagstep}{OT1TT} -\font\texti=cmmi10 scaled \mainmagstep -\font\textsy=cmsy10 scaled \mainmagstep -\def\textecsize{1000} - -% A few fonts for @defun names and args. -\setfont\defbf\bfshape{10}{\magstephalf}{OT1} -\setfont\deftt\ttshape{10}{\magstephalf}{OT1TT} -\setfont\defttsl\ttslshape{10}{\magstephalf}{OT1TT} -\def\df{\let\tentt=\deftt \let\tenbf = \defbf \let\tenttsl=\defttsl \bf} - -% Fonts for indices, footnotes, small examples (9pt). -\def\smallnominalsize{9pt} -\setfont\smallrm\rmshape{9}{1000}{OT1} -\setfont\smalltt\ttshape{9}{1000}{OT1TT} -\setfont\smallbf\bfshape{10}{900}{OT1} -\setfont\smallit\itshape{9}{1000}{OT1IT} -\setfont\smallsl\slshape{9}{1000}{OT1} -\setfont\smallsf\sfshape{9}{1000}{OT1} -\setfont\smallsc\scshape{10}{900}{OT1} -\setfont\smallttsl\ttslshape{10}{900}{OT1TT} -\font\smalli=cmmi9 -\font\smallsy=cmsy9 -\def\smallecsize{0900} - -% Fonts for small examples (8pt). -\def\smallernominalsize{8pt} -\setfont\smallerrm\rmshape{8}{1000}{OT1} -\setfont\smallertt\ttshape{8}{1000}{OT1TT} -\setfont\smallerbf\bfshape{10}{800}{OT1} -\setfont\smallerit\itshape{8}{1000}{OT1IT} -\setfont\smallersl\slshape{8}{1000}{OT1} -\setfont\smallersf\sfshape{8}{1000}{OT1} -\setfont\smallersc\scshape{10}{800}{OT1} -\setfont\smallerttsl\ttslshape{10}{800}{OT1TT} -\font\smalleri=cmmi8 -\font\smallersy=cmsy8 -\def\smallerecsize{0800} - -% Fonts for title page (20.4pt): -\def\titlenominalsize{20pt} -\setfont\titlerm\rmbshape{12}{\magstep3}{OT1} -\setfont\titleit\itbshape{10}{\magstep4}{OT1IT} -\setfont\titlesl\slbshape{10}{\magstep4}{OT1} -\setfont\titlett\ttbshape{12}{\magstep3}{OT1TT} -\setfont\titlettsl\ttslshape{10}{\magstep4}{OT1TT} -\setfont\titlesf\sfbshape{17}{\magstep1}{OT1} -\let\titlebf=\titlerm -\setfont\titlesc\scbshape{10}{\magstep4}{OT1} -\font\titlei=cmmi12 scaled \magstep3 -\font\titlesy=cmsy10 scaled \magstep4 -\def\titleecsize{2074} - -% Chapter fonts (14.4pt). -\def\chapnominalsize{14pt} -\setfont\chaprm\rmbshape{12}{\magstep1}{OT1} -\setfont\chapit\itbshape{10}{\magstep2}{OT1IT} -\setfont\chapsl\slbshape{10}{\magstep2}{OT1} -\setfont\chaptt\ttbshape{12}{\magstep1}{OT1TT} -\setfont\chapttsl\ttslshape{10}{\magstep2}{OT1TT} -\setfont\chapsf\sfbshape{12}{\magstep1}{OT1} -\let\chapbf\chaprm -\setfont\chapsc\scbshape{10}{\magstep2}{OT1} -\font\chapi=cmmi12 scaled \magstep1 -\font\chapsy=cmsy10 scaled \magstep2 -\def\chapecsize{1440} - -% Section fonts (12pt). -\def\secnominalsize{12pt} -\setfont\secrm\rmbshape{12}{1000}{OT1} -\setfont\secit\itbshape{10}{\magstep1}{OT1IT} -\setfont\secsl\slbshape{10}{\magstep1}{OT1} -\setfont\sectt\ttbshape{12}{1000}{OT1TT} -\setfont\secttsl\ttslshape{10}{\magstep1}{OT1TT} -\setfont\secsf\sfbshape{12}{1000}{OT1} -\let\secbf\secrm -\setfont\secsc\scbshape{10}{\magstep1}{OT1} -\font\seci=cmmi12 -\font\secsy=cmsy10 scaled \magstep1 -\def\sececsize{1200} - -% Subsection fonts (10pt). -\def\ssecnominalsize{10pt} -\setfont\ssecrm\rmbshape{10}{1000}{OT1} -\setfont\ssecit\itbshape{10}{1000}{OT1IT} -\setfont\ssecsl\slbshape{10}{1000}{OT1} -\setfont\ssectt\ttbshape{10}{1000}{OT1TT} -\setfont\ssecttsl\ttslshape{10}{1000}{OT1TT} -\setfont\ssecsf\sfbshape{10}{1000}{OT1} -\let\ssecbf\ssecrm -\setfont\ssecsc\scbshape{10}{1000}{OT1} -\font\sseci=cmmi10 -\font\ssecsy=cmsy10 -\def\ssececsize{1000} - -% Reduced fonts for @acro in text (9pt). -\def\reducednominalsize{9pt} -\setfont\reducedrm\rmshape{9}{1000}{OT1} -\setfont\reducedtt\ttshape{9}{1000}{OT1TT} -\setfont\reducedbf\bfshape{10}{900}{OT1} -\setfont\reducedit\itshape{9}{1000}{OT1IT} -\setfont\reducedsl\slshape{9}{1000}{OT1} -\setfont\reducedsf\sfshape{9}{1000}{OT1} -\setfont\reducedsc\scshape{10}{900}{OT1} -\setfont\reducedttsl\ttslshape{10}{900}{OT1TT} -\font\reducedi=cmmi9 -\font\reducedsy=cmsy9 -\def\reducedecsize{0900} - -\divide\parskip by 2 % reduce space between paragraphs -\textleading = 12pt % line spacing for 10pt CM -\textfonts % reset the current fonts -\rm -} % end of 10pt text font size definitions, \definetextfontsizex - - -% We provide the user-level command -% @fonttextsize 10 -% (or 11) to redefine the text font size. pt is assumed. -% -\def\xiword{11} -\def\xword{10} -\def\xwordpt{10pt} -% -\parseargdef\fonttextsize{% - \def\textsizearg{#1}% - %\wlog{doing @fonttextsize \textsizearg}% - % - % Set \globaldefs so that documents can use this inside @tex, since - % makeinfo 4.8 does not support it, but we need it nonetheless. - % - \begingroup \globaldefs=1 - \ifx\textsizearg\xword \definetextfontsizex - \else \ifx\textsizearg\xiword \definetextfontsizexi - \else - \errhelp=\EMsimple - \errmessage{@fonttextsize only supports `10' or `11', not `\textsizearg'} - \fi\fi - \endgroup -} - % In order for the font changes to affect most math symbols and letters, % we have to define the \textfont of the standard families. Since @@ -2124,8 +1681,8 @@ \let\tenttsl=\titlettsl \def\curfontsize{title}% \def\lsize{chap}\def\lllsize{subsec}% - \resetmathfonts \setleading{27pt}} -\def\titlefont#1{{\titlefonts\rmisbold #1}} + \resetmathfonts \setleading{25pt}} +\def\titlefont#1{{\titlefonts\rm #1}} \def\chapfonts{% \let\tenrm=\chaprm \let\tenit=\chapit \let\tensl=\chapsl \let\tenbf=\chapbf \let\tentt=\chaptt \let\smallcaps=\chapsc @@ -2176,16 +1733,6 @@ \def\lsize{smaller}\def\lllsize{smaller}% \resetmathfonts \setleading{9.5pt}} -% Fonts for short table of contents. -\setfont\shortcontrm\rmshape{12}{1000}{OT1} -\setfont\shortcontbf\bfshape{10}{\magstep1}{OT1} % no cmb12 -\setfont\shortcontsl\slshape{12}{1000}{OT1} -\setfont\shortconttt\ttshape{12}{1000}{OT1TT} - -% Define these just so they can be easily changed for other fonts. -\def\angleleft{$\langle$} -\def\angleright{$\rangle$} - % Set the fonts to use with the @small... environments. \let\smallexamplefonts = \smallfonts @@ -2199,215 +1746,53 @@ % % By the way, for comparison, here's what fits with @example (10pt): % 8.5x11=71 smallbook=60 a4=75 a5=58 +% +% I wish the USA used A4 paper. % --karl, 24jan03. + % Set up the default fonts, so we can use them for creating boxes. % -\definetextfontsizexi - - -\message{markup,} - -% Check if we are currently using a typewriter font. Since all the -% Computer Modern typewriter fonts have zero interword stretch (and -% shrink), and it is reasonable to expect all typewriter fonts to have -% this property, we can check that font parameter. -% -\def\ifmonospace{\ifdim\fontdimen3\font=0pt } - -% Markup style infrastructure. \defmarkupstylesetup\INITMACRO will -% define and register \INITMACRO to be called on markup style changes. -% \INITMACRO can check \currentmarkupstyle for the innermost -% style and the set of \ifmarkupSTYLE switches for all styles -% currently in effect. -\newif\ifmarkupvar -\newif\ifmarkupsamp -\newif\ifmarkupkey -%\newif\ifmarkupfile % @file == @samp. -%\newif\ifmarkupoption % @option == @samp. -\newif\ifmarkupcode -\newif\ifmarkupkbd -%\newif\ifmarkupenv % @env == @code. -%\newif\ifmarkupcommand % @command == @code. -\newif\ifmarkuptex % @tex (and part of @math, for now). -\newif\ifmarkupexample -\newif\ifmarkupverb -\newif\ifmarkupverbatim - -\let\currentmarkupstyle\empty - -\def\setupmarkupstyle#1{% - \csname markup#1true\endcsname - \def\currentmarkupstyle{#1}% - \markupstylesetup -} - -\let\markupstylesetup\empty - -\def\defmarkupstylesetup#1{% - \expandafter\def\expandafter\markupstylesetup - \expandafter{\markupstylesetup #1}% - \def#1% -} - -% Markup style setup for left and right quotes. -\defmarkupstylesetup\markupsetuplq{% - \expandafter\let\expandafter \temp - \csname markupsetuplq\currentmarkupstyle\endcsname - \ifx\temp\relax \markupsetuplqdefault \else \temp \fi -} - -\defmarkupstylesetup\markupsetuprq{% - \expandafter\let\expandafter \temp - \csname markupsetuprq\currentmarkupstyle\endcsname - \ifx\temp\relax \markupsetuprqdefault \else \temp \fi -} - -{ -\catcode`\'=\active -\catcode`\`=\active - -\gdef\markupsetuplqdefault{\let`\lq} -\gdef\markupsetuprqdefault{\let'\rq} - -\gdef\markupsetcodequoteleft{\let`\codequoteleft} -\gdef\markupsetcodequoteright{\let'\codequoteright} - -\gdef\markupsetnoligaturesquoteleft{\let`\noligaturesquoteleft} -} - -\let\markupsetuplqcode \markupsetcodequoteleft -\let\markupsetuprqcode \markupsetcodequoteright -% -\let\markupsetuplqexample \markupsetcodequoteleft -\let\markupsetuprqexample \markupsetcodequoteright -% -\let\markupsetuplqsamp \markupsetcodequoteleft -\let\markupsetuprqsamp \markupsetcodequoteright -% -\let\markupsetuplqverb \markupsetcodequoteleft -\let\markupsetuprqverb \markupsetcodequoteright -% -\let\markupsetuplqverbatim \markupsetcodequoteleft -\let\markupsetuprqverbatim \markupsetcodequoteright - -\let\markupsetuplqkbd \markupsetnoligaturesquoteleft - -% Allow an option to not use regular directed right quote/apostrophe -% (char 0x27), but instead the undirected quote from cmtt (char 0x0d). -% The undirected quote is ugly, so don't make it the default, but it -% works for pasting with more pdf viewers (at least evince), the -% lilypond developers report. xpdf does work with the regular 0x27. -% -\def\codequoteright{% - \expandafter\ifx\csname SETtxicodequoteundirected\endcsname\relax - \expandafter\ifx\csname SETcodequoteundirected\endcsname\relax - '% - \else \char'15 \fi - \else \char'15 \fi -} -% -% and a similar option for the left quote char vs. a grave accent. -% Modern fonts display ASCII 0x60 as a grave accent, so some people like -% the code environments to do likewise. -% -\def\codequoteleft{% - \expandafter\ifx\csname SETtxicodequotebacktick\endcsname\relax - \expandafter\ifx\csname SETcodequotebacktick\endcsname\relax - % [Knuth] pp. 380,381,391 - % \relax disables Spanish ligatures ?` and !` of \tt font. - \relax`% - \else \char'22 \fi - \else \char'22 \fi -} - -% Commands to set the quote options. -% -\parseargdef\codequoteundirected{% - \def\temp{#1}% - \ifx\temp\onword - \expandafter\let\csname SETtxicodequoteundirected\endcsname - = t% - \else\ifx\temp\offword - \expandafter\let\csname SETtxicodequoteundirected\endcsname - = \relax - \else - \errhelp = \EMsimple - \errmessage{Unknown @codequoteundirected value `\temp', must be on|off}% - \fi\fi -} -% -\parseargdef\codequotebacktick{% - \def\temp{#1}% - \ifx\temp\onword - \expandafter\let\csname SETtxicodequotebacktick\endcsname - = t% - \else\ifx\temp\offword - \expandafter\let\csname SETtxicodequotebacktick\endcsname - = \relax - \else - \errhelp = \EMsimple - \errmessage{Unknown @codequotebacktick value `\temp', must be on|off}% - \fi\fi -} - -% [Knuth] pp. 380,381,391, disable Spanish ligatures ?` and !` of \tt font. -\def\noligaturesquoteleft{\relax\lq} +\textfonts \rm + +% Define these so they can be easily changed for other fonts. +\def\angleleft{$\langle$} +\def\angleright{$\rangle$} % Count depth in font-changes, for error checks \newcount\fontdepth \fontdepth=0 -% Font commands. - -% #1 is the font command (\sl or \it), #2 is the text to slant. -% If we are in a monospaced environment, however, 1) always use \ttsl, -% and 2) do not add an italic correction. -\def\dosmartslant#1#2{% - \ifusingtt - {{\ttsl #2}\let\next=\relax}% - {\def\next{{#1#2}\futurelet\next\smartitaliccorrection}}% - \next -} -\def\smartslanted{\dosmartslant\sl} -\def\smartitalic{\dosmartslant\it} - -% Output an italic correction unless \next (presumed to be the following -% character) is such as not to need one. -\def\smartitaliccorrection{% - \ifx\next,% - \else\ifx\next-% - \else\ifx\next.% - \else\ptexslash - \fi\fi\fi - \aftersmartic -} - -% like \smartslanted except unconditionally uses \ttsl, and no ic. +% Fonts for short table of contents. +\setfont\shortcontrm\rmshape{12}{1000} +\setfont\shortcontbf\bfshape{10}{\magstep1} % no cmb12 +\setfont\shortcontsl\slshape{12}{1000} +\setfont\shortconttt\ttshape{12}{1000} + +%% Add scribe-like font environments, plus @l for inline lisp (usually sans +%% serif) and @ii for TeX italic + +% \smartitalic{ARG} outputs arg in italics, followed by an italic correction +% unless the following character is such as not to need one. +\def\smartitalicx{\ifx\next,\else\ifx\next-\else\ifx\next.\else + \ptexslash\fi\fi\fi} +\def\smartslanted#1{{\ifusingtt\ttsl\sl #1}\futurelet\next\smartitalicx} +\def\smartitalic#1{{\ifusingtt\ttsl\it #1}\futurelet\next\smartitalicx} + +% like \smartslanted except unconditionally uses \ttsl. % @var is set to this for defun arguments. -\def\ttslanted#1{{\ttsl #1}} - -% @cite is like \smartslanted except unconditionally use \sl. We never want +\def\ttslanted#1{{\ttsl #1}\futurelet\next\smartitalicx} + +% like \smartslanted except unconditionally use \sl. We never want % ttsl for book titles, do we? -\def\cite#1{{\sl #1}\futurelet\next\smartitaliccorrection} - -\def\aftersmartic{} -\def\var#1{% - \let\saveaftersmartic = \aftersmartic - \def\aftersmartic{\null\let\aftersmartic=\saveaftersmartic}% - \smartslanted{#1}% -} +\def\cite#1{{\sl #1}\futurelet\next\smartitalicx} \let\i=\smartitalic \let\slanted=\smartslanted +\let\var=\smartslanted \let\dfn=\smartslanted \let\emph=\smartitalic -% Explicit font changes: @r, @sc, undocumented @ii. -\def\r#1{{\rm #1}} % roman font -\def\sc#1{{\smallcaps#1}} % smallcaps font -\def\ii#1{{\it #1}} % italic font - -% @b, explicit bold. Also @strong. +% @b, explicit bold. \def\b#1{{\bf #1}} \let\strong=\b @@ -2439,35 +1824,21 @@ \catcode`@=\other \def\endofsentencespacefactor{3000}% default -% @t, explicit typewriter. \def\t#1{% {\tt \rawbackslash \plainfrenchspacing #1}% \null } - -% @samp. -\def\samp#1{{\setupmarkupstyle{samp}\lq\tclose{#1}\rq\null}} - -% definition of @key that produces a lozenge. Doesn't adjust to text size. -%\setfont\keyrm\rmshape{8}{1000}{OT1} -%\font\keysy=cmsy9 -%\def\key#1{{\keyrm\textfont2=\keysy \leavevmode\hbox{% -% \raise0.4pt\hbox{\angleleft}\kern-.08em\vtop{% -% \vbox{\hrule\kern-0.4pt -% \hbox{\raise0.4pt\hbox{\vphantom{\angleleft}}#1}}% -% \kern-0.4pt\hrule}% -% \kern-.06em\raise0.4pt\hbox{\angleright}}}} - -% definition of @key with no lozenge. If the current font is already -% monospace, don't change it; that way, we respect @kbdinputstyle. But -% if it isn't monospace, then use \tt. -% -\def\key#1{{\setupmarkupstyle{key}% - \nohyphenation - \ifmonospace\else\tt\fi - #1}\null} - -% ctrl is no longer a Texinfo command. +\def\samp#1{`\tclose{#1}'\null} +\setfont\keyrm\rmshape{8}{1000} +\font\keysy=cmsy9 +\def\key#1{{\keyrm\textfont2=\keysy \leavevmode\hbox{% + \raise0.4pt\hbox{\angleleft}\kern-.08em\vtop{% + \vbox{\hrule\kern-0.4pt + \hbox{\raise0.4pt\hbox{\vphantom{\angleleft}}#1}}% + \kern-0.4pt\hrule}% + \kern-.06em\raise0.4pt\hbox{\angleright}}}} +% The old definition, with no lozenge: +%\def\key #1{{\ttsl \nohyphenation \uppercase{#1}}\null} \def\ctrl #1{{\tt \rawbackslash \hat}#1} % @file, @option are the same as @samp. @@ -2494,7 +1865,7 @@ \plainfrenchspacing #1% }% - \null % reset spacefactor to 1000 + \null } % We *must* turn on hyphenation at `-' and `_' in @code. @@ -2507,14 +1878,11 @@ % and arrange explicitly to hyphenate at a dash. % -- rms. { - \catcode`\-=\active \catcode`\_=\active - \catcode`\'=\active \catcode`\`=\active - \global\let'=\rq \global\let`=\lq % default definitions + \catcode`\-=\active + \catcode`\_=\active % \global\def\code{\begingroup - \setupmarkupstyle{code}% - % The following should really be moved into \setupmarkupstyle handlers. - \catcode\dashChar=\active \catcode\underChar=\active + \catcode`\-=\active \catcode`\_=\active \ifallowcodebreaks \let-\codedash \let_\codeunder @@ -2526,8 +1894,6 @@ } } -\def\codex #1{\tclose{#1}\endgroup} - \def\realdash{-} \def\codedash{-\discretionary{}{}{}} \def\codeunder{% @@ -2541,12 +1907,13 @@ \discretionary{}{}{}}% {\_}% } +\def\codex #1{\tclose{#1}\endgroup} % An additional complication: the above will allow breaks after, e.g., % each of the four underscores in __typeof__. This is undesirable in % some manuals, especially if they don't have long identifiers in % general. @allowcodebreaks provides a way to control this. -% +% \newif\ifallowcodebreaks \allowcodebreakstrue \def\keywordtrue{true} @@ -2560,18 +1927,55 @@ \allowcodebreaksfalse \else \errhelp = \EMsimple - \errmessage{Unknown @allowcodebreaks option `\txiarg', must be true|false}% + \errmessage{Unknown @allowcodebreaks option `\txiarg'}% \fi\fi } +% @kbd is like @code, except that if the argument is just one @key command, +% then @kbd has no effect. + +% @kbdinputstyle -- arg is `distinct' (@kbd uses slanted tty font always), +% `example' (@kbd uses ttsl only inside of @example and friends), +% or `code' (@kbd uses normal tty font always). +\parseargdef\kbdinputstyle{% + \def\txiarg{#1}% + \ifx\txiarg\worddistinct + \gdef\kbdexamplefont{\ttsl}\gdef\kbdfont{\ttsl}% + \else\ifx\txiarg\wordexample + \gdef\kbdexamplefont{\ttsl}\gdef\kbdfont{\tt}% + \else\ifx\txiarg\wordcode + \gdef\kbdexamplefont{\tt}\gdef\kbdfont{\tt}% + \else + \errhelp = \EMsimple + \errmessage{Unknown @kbdinputstyle option `\txiarg'}% + \fi\fi\fi +} +\def\worddistinct{distinct} +\def\wordexample{example} +\def\wordcode{code} + +% Default is `distinct.' +\kbdinputstyle distinct + +\def\xkey{\key} +\def\kbdfoo#1#2#3\par{\def\one{#1}\def\three{#3}\def\threex{??}% +\ifx\one\xkey\ifx\threex\three \key{#2}% +\else{\tclose{\kbdfont\look}}\fi +\else{\tclose{\kbdfont\look}}\fi} + +% For @indicateurl, @env, @command quotes seem unnecessary, so use \code. +\let\indicateurl=\code +\let\env=\code +\let\command=\code + % @uref (abbreviation for `urlref') takes an optional (comma-separated) % second argument specifying the text to display and an optional third % arg as text to display instead of (rather than in addition to) the url -% itself. First (mandatory) arg is the url. -% (This \urefnobreak definition isn't used now, leaving it for a while -% for comparison.) -\def\urefnobreak#1{\dourefnobreak #1,,,\finish} -\def\dourefnobreak#1,#2,#3,#4\finish{\begingroup +% itself. First (mandatory) arg is the url. Perhaps eventually put in +% a hypertex \special here. +% +\def\uref#1{\douref #1,,,\finish} +\def\douref#1,#2,#3,#4\finish{\begingroup \unsepspaces \pdfurl{#1}% \setbox0 = \hbox{\ignorespaces #3}% @@ -2592,103 +1996,6 @@ \endlink \endgroup} -% This \urefbreak definition is the active one. -\def\urefbreak{\begingroup \urefcatcodes \dourefbreak} -\let\uref=\urefbreak -\def\dourefbreak#1{\urefbreakfinish #1,,,\finish} -\def\urefbreakfinish#1,#2,#3,#4\finish{% doesn't work in @example - \unsepspaces - \pdfurl{#1}% - \setbox0 = \hbox{\ignorespaces #3}% - \ifdim\wd0 > 0pt - \unhbox0 % third arg given, show only that - \else - \setbox0 = \hbox{\ignorespaces #2}% - \ifdim\wd0 > 0pt - \ifpdf - \unhbox0 % PDF: 2nd arg given, show only it - \else - \unhbox0\ (\urefcode{#1})% DVI: 2nd arg given, show both it and url - \fi - \else - \urefcode{#1}% only url given, so show it - \fi - \fi - \endlink -\endgroup} - -% Allow line breaks around only a few characters (only). -\def\urefcatcodes{% - \catcode\ampChar=\active \catcode\dotChar=\active - \catcode\hashChar=\active \catcode\questChar=\active - \catcode\slashChar=\active -} -{ - \urefcatcodes - % - \global\def\urefcode{\begingroup - \setupmarkupstyle{code}% - \urefcatcodes - \let&\urefcodeamp - \let.\urefcodedot - \let#\urefcodehash - \let?\urefcodequest - \let/\urefcodeslash - \codex - } - % - % By default, they are just regular characters. - \global\def&{\normalamp} - \global\def.{\normaldot} - \global\def#{\normalhash} - \global\def?{\normalquest} - \global\def/{\normalslash} -} - -% we put a little stretch before and after the breakable chars, to help -% line breaking of long url's. The unequal skips make look better in -% cmtt at least, especially for dots. -\def\urefprestretch{\urefprebreak \hskip0pt plus.13em } -\def\urefpoststretch{\urefpostbreak \hskip0pt plus.1em } -% -\def\urefcodeamp{\urefprestretch \&\urefpoststretch} -\def\urefcodedot{\urefprestretch .\urefpoststretch} -\def\urefcodehash{\urefprestretch \#\urefpoststretch} -\def\urefcodequest{\urefprestretch ?\urefpoststretch} -\def\urefcodeslash{\futurelet\next\urefcodeslashfinish} -{ - \catcode`\/=\active - \global\def\urefcodeslashfinish{% - \urefprestretch \slashChar - % Allow line break only after the final / in a sequence of - % slashes, to avoid line break between the slashes in http://. - \ifx\next/\else \urefpoststretch \fi - } -} - -% One more complication: by default we'll break after the special -% characters, but some people like to break before the special chars, so -% allow that. Also allow no breaking at all, for manual control. -% -\parseargdef\urefbreakstyle{% - \def\txiarg{#1}% - \ifx\txiarg\wordnone - \def\urefprebreak{\nobreak}\def\urefpostbreak{\nobreak} - \else\ifx\txiarg\wordbefore - \def\urefprebreak{\allowbreak}\def\urefpostbreak{\nobreak} - \else\ifx\txiarg\wordafter - \def\urefprebreak{\nobreak}\def\urefpostbreak{\allowbreak} - \else - \errhelp = \EMsimple - \errmessage{Unknown @urefbreakstyle setting `\txiarg'}% - \fi\fi\fi -} -\def\wordafter{after} -\def\wordbefore{before} -\def\wordnone{none} - -\urefbreakstyle after - % @url synonym for @uref, since that's how everyone uses it. % \let\url=\uref @@ -2710,65 +2017,34 @@ \let\email=\uref \fi -% @kbd is like @code, except that if the argument is just one @key command, -% then @kbd has no effect. -\def\kbd#1{{\setupmarkupstyle{kbd}\def\look{#1}\expandafter\kbdfoo\look??\par}} - -% @kbdinputstyle -- arg is `distinct' (@kbd uses slanted tty font always), -% `example' (@kbd uses ttsl only inside of @example and friends), -% or `code' (@kbd uses normal tty font always). -\parseargdef\kbdinputstyle{% - \def\txiarg{#1}% - \ifx\txiarg\worddistinct - \gdef\kbdexamplefont{\ttsl}\gdef\kbdfont{\ttsl}% - \else\ifx\txiarg\wordexample - \gdef\kbdexamplefont{\ttsl}\gdef\kbdfont{\tt}% - \else\ifx\txiarg\wordcode - \gdef\kbdexamplefont{\tt}\gdef\kbdfont{\tt}% - \else - \errhelp = \EMsimple - \errmessage{Unknown @kbdinputstyle setting `\txiarg'}% - \fi\fi\fi -} -\def\worddistinct{distinct} -\def\wordexample{example} -\def\wordcode{code} - -% Default is `distinct'. -\kbdinputstyle distinct - -\def\xkey{\key} -\def\kbdfoo#1#2#3\par{\def\one{#1}\def\three{#3}\def\threex{??}% -\ifx\one\xkey\ifx\threex\three \key{#2}% -\else{\tclose{\kbdfont\setupmarkupstyle{kbd}\look}}\fi -\else{\tclose{\kbdfont\setupmarkupstyle{kbd}\look}}\fi} - -% For @indicateurl, @env, @command quotes seem unnecessary, so use \code. -\let\indicateurl=\code -\let\env=\code -\let\command=\code - -% @clicksequence{File @click{} Open ...} -\def\clicksequence#1{\begingroup #1\endgroup} - -% @clickstyle @arrow (by default) -\parseargdef\clickstyle{\def\click{#1}} -\def\click{\arrow} +% Check if we are currently using a typewriter font. Since all the +% Computer Modern typewriter fonts have zero interword stretch (and +% shrink), and it is reasonable to expect all typewriter fonts to have +% this property, we can check that font parameter. +% +\def\ifmonospace{\ifdim\fontdimen3\font=0pt } % Typeset a dimension, e.g., `in' or `pt'. The only reason for the % argument is to make the input look right: @dmn{pt} instead of @dmn{}pt. % \def\dmn#1{\thinspace #1} +\def\kbd#1{\def\look{#1}\expandafter\kbdfoo\look??\par} + % @l was never documented to mean ``switch to the Lisp font'', % and it is not used as such in any manual I can find. We need it for % Polish suppressed-l. --karl, 22sep96. %\def\l#1{{\li #1}\null} +% Explicit font changes: @r, @sc, undocumented @ii. +\def\r#1{{\rm #1}} % roman font +\def\sc#1{{\smallcaps#1}} % smallcaps font +\def\ii#1{{\it #1}} % italic font + % @acronym for "FBI", "NATO", and the like. % We print this one point size smaller, since it's intended for % all-uppercase. -% +% \def\acronym#1{\doacronym #1,,\finish} \def\doacronym#1,#2,#3\finish{% {\selectfonts\lsize #1}% @@ -2776,12 +2052,11 @@ \ifx\temp\empty \else \space ({\unsepspaces \ignorespaces \temp \unskip})% \fi - \null % reset \spacefactor=1000 } % @abbr for "Comput. J." and the like. % No font change, but don't do end-of-sentence spacing. -% +% \def\abbr#1{\doabbr #1,,\finish} \def\doabbr#1,#2,#3\finish{% {\plainfrenchspacing #1}% @@ -2789,254 +2064,7 @@ \ifx\temp\empty \else \space ({\unsepspaces \ignorespaces \temp \unskip})% \fi - \null % reset \spacefactor=1000 -} - -% @asis just yields its argument. Used with @table, for example. -% -\def\asis#1{#1} - -% @math outputs its argument in math mode. -% -% One complication: _ usually means subscripts, but it could also mean -% an actual _ character, as in @math{@var{some_variable} + 1}. So make -% _ active, and distinguish by seeing if the current family is \slfam, -% which is what @var uses. -{ - \catcode`\_ = \active - \gdef\mathunderscore{% - \catcode`\_=\active - \def_{\ifnum\fam=\slfam \_\else\sb\fi}% - } -} -% Another complication: we want \\ (and @\) to output a math (or tt) \. -% FYI, plain.tex uses \\ as a temporary control sequence (for no -% particular reason), but this is not advertised and we don't care. -% -% The \mathchar is class=0=ordinary, family=7=ttfam, position=5C=\. -\def\mathbackslash{\ifnum\fam=\ttfam \mathchar"075C \else\backslash \fi} -% -\def\math{% - \tex - \mathunderscore - \let\\ = \mathbackslash - \mathactive - % make the texinfo accent commands work in math mode - \let\"=\ddot - \let\'=\acute - \let\==\bar - \let\^=\hat - \let\`=\grave - \let\u=\breve - \let\v=\check - \let\~=\tilde - \let\dotaccent=\dot - $\finishmath -} -\def\finishmath#1{#1$\endgroup} % Close the group opened by \tex. - -% Some active characters (such as <) are spaced differently in math. -% We have to reset their definitions in case the @math was an argument -% to a command which sets the catcodes (such as @item or @section). -% -{ - \catcode`^ = \active - \catcode`< = \active - \catcode`> = \active - \catcode`+ = \active - \catcode`' = \active - \gdef\mathactive{% - \let^ = \ptexhat - \let< = \ptexless - \let> = \ptexgtr - \let+ = \ptexplus - \let' = \ptexquoteright - } -} - -% @inlinefmt{FMTNAME,PROCESSED-TEXT} and @inlineraw{FMTNAME,RAW-TEXT}. -% Ignore unless FMTNAME == tex; then it is like @iftex and @tex, -% except specified as a normal braced arg, so no newlines to worry about. -% -\def\outfmtnametex{tex} -% -\long\def\inlinefmt#1{\doinlinefmt #1,\finish} -\long\def\doinlinefmt#1,#2,\finish{% - \def\inlinefmtname{#1}% - \ifx\inlinefmtname\outfmtnametex \ignorespaces #2\fi -} -% For raw, must switch into @tex before parsing the argument, to avoid -% setting catcodes prematurely. Doing it this way means that, for -% example, @inlineraw{html, foo{bar} gets a parse error instead of being -% ignored. But this isn't important because if people want a literal -% *right* brace they would have to use a command anyway, so they may as -% well use a command to get a left brace too. We could re-use the -% delimiter character idea from \verb, but it seems like overkill. -% -\long\def\inlineraw{\tex \doinlineraw} -\long\def\doinlineraw#1{\doinlinerawtwo #1,\finish} -\def\doinlinerawtwo#1,#2,\finish{% - \def\inlinerawname{#1}% - \ifx\inlinerawname\outfmtnametex \ignorespaces #2\fi - \endgroup % close group opened by \tex. -} - - -\message{glyphs,} -% and logos. - -% @@ prints an @, as does @atchar{}. -\def\@{\char64 } -\let\atchar=\@ - -% @{ @} @lbracechar{} @rbracechar{} all generate brace characters. -% Unless we're in typewriter, use \ecfont because the CM text fonts do -% not have braces, and we don't want to switch into math. -\def\mylbrace{{\ifmonospace\else\ecfont\fi \char123}} -\def\myrbrace{{\ifmonospace\else\ecfont\fi \char125}} -\let\{=\mylbrace \let\lbracechar=\{ -\let\}=\myrbrace \let\rbracechar=\} -\begingroup - % Definitions to produce \{ and \} commands for indices, - % and @{ and @} for the aux/toc files. - \catcode`\{ = \other \catcode`\} = \other - \catcode`\[ = 1 \catcode`\] = 2 - \catcode`\! = 0 \catcode`\\ = \other - !gdef!lbracecmd[\{]% - !gdef!rbracecmd[\}]% - !gdef!lbraceatcmd[@{]% - !gdef!rbraceatcmd[@}]% -!endgroup - -% @comma{} to avoid , parsing problems. -\let\comma = , - -% Accents: @, @dotaccent @ringaccent @ubaraccent @udotaccent -% Others are defined by plain TeX: @` @' @" @^ @~ @= @u @v @H. -\let\, = \ptexc -\let\dotaccent = \ptexdot -\def\ringaccent#1{{\accent23 #1}} -\let\tieaccent = \ptext -\let\ubaraccent = \ptexb -\let\udotaccent = \d - -% Other special characters: @questiondown @exclamdown @ordf @ordm -% Plain TeX defines: @AA @AE @O @OE @L (plus lowercase versions) @ss. -\def\questiondown{?`} -\def\exclamdown{!`} -\def\ordf{\leavevmode\raise1ex\hbox{\selectfonts\lllsize \underbar{a}}} -\def\ordm{\leavevmode\raise1ex\hbox{\selectfonts\lllsize \underbar{o}}} - -% Dotless i and dotless j, used for accents. -\def\imacro{i} -\def\jmacro{j} -\def\dotless#1{% - \def\temp{#1}% - \ifx\temp\imacro \ifmmode\imath \else\ptexi \fi - \else\ifx\temp\jmacro \ifmmode\jmath \else\j \fi - \else \errmessage{@dotless can be used only with i or j}% - \fi\fi -} - -% The \TeX{} logo, as in plain, but resetting the spacing so that a -% period following counts as ending a sentence. (Idea found in latex.) -% -\edef\TeX{\TeX \spacefactor=1000 } - -% @LaTeX{} logo. Not quite the same results as the definition in -% latex.ltx, since we use a different font for the raised A; it's most -% convenient for us to use an explicitly smaller font, rather than using -% the \scriptstyle font (since we don't reset \scriptstyle and -% \scriptscriptstyle). -% -\def\LaTeX{% - L\kern-.36em - {\setbox0=\hbox{T}% - \vbox to \ht0{\hbox{% - \ifx\textnominalsize\xwordpt - % for 10pt running text, \lllsize (8pt) is too small for the A in LaTeX. - % Revert to plain's \scriptsize, which is 7pt. - \count255=\the\fam $\fam\count255 \scriptstyle A$% - \else - % For 11pt, we can use our lllsize. - \selectfonts\lllsize A% - \fi - }% - \vss - }}% - \kern-.15em - \TeX -} - -% Some math mode symbols. -\def\bullet{$\ptexbullet$} -\def\geq{\ifmmode \ge\else $\ge$\fi} -\def\leq{\ifmmode \le\else $\le$\fi} -\def\minus{\ifmmode -\else $-$\fi} - -% @dots{} outputs an ellipsis using the current font. -% We do .5em per period so that it has the same spacing in the cm -% typewriter fonts as three actual period characters; on the other hand, -% in other typewriter fonts three periods are wider than 1.5em. So do -% whichever is larger. -% -\def\dots{% - \leavevmode - \setbox0=\hbox{...}% get width of three periods - \ifdim\wd0 > 1.5em - \dimen0 = \wd0 - \else - \dimen0 = 1.5em - \fi - \hbox to \dimen0{% - \hskip 0pt plus.25fil - .\hskip 0pt plus1fil - .\hskip 0pt plus1fil - .\hskip 0pt plus.5fil - }% -} - -% @enddots{} is an end-of-sentence ellipsis. -% -\def\enddots{% - \dots - \spacefactor=\endofsentencespacefactor -} - -% @point{}, @result{}, @expansion{}, @print{}, @equiv{}. -% -% Since these characters are used in examples, they should be an even number of -% \tt widths. Each \tt character is 1en, so two makes it 1em. -% -\def\point{$\star$} -\def\arrow{\leavevmode\raise.05ex\hbox to 1em{\hfil$\rightarrow$\hfil}} -\def\result{\leavevmode\raise.05ex\hbox to 1em{\hfil$\Rightarrow$\hfil}} -\def\expansion{\leavevmode\hbox to 1em{\hfil$\mapsto$\hfil}} -\def\print{\leavevmode\lower.1ex\hbox to 1em{\hfil$\dashv$\hfil}} -\def\equiv{\leavevmode\hbox to 1em{\hfil$\ptexequiv$\hfil}} - -% The @error{} command. -% Adapted from the TeXbook's \boxit. -% -\newbox\errorbox -% -{\tentt \global\dimen0 = 3em}% Width of the box. -\dimen2 = .55pt % Thickness of rules -% The text. (`r' is open on the right, `e' somewhat less so on the left.) -\setbox0 = \hbox{\kern-.75pt \reducedsf \putworderror\kern-1.5pt} -% -\setbox\errorbox=\hbox to \dimen0{\hfil - \hsize = \dimen0 \advance\hsize by -5.8pt % Space to left+right. - \advance\hsize by -2\dimen2 % Rules. - \vbox{% - \hrule height\dimen2 - \hbox{\vrule width\dimen2 \kern3pt % Space to left of text. - \vtop{\kern2.4pt \box0 \kern2.4pt}% Space above/below. - \kern3pt\vrule width\dimen2}% Space to right. - \hrule height\dimen2} - \hfil} -% -\def\error{\leavevmode\lower.7ex\copy\errorbox} +} % @pounds{} is a sterling sign, which Knuth put in the CM italic font. % @@ -3047,113 +2075,49 @@ % Theiling, which support regular, slanted, bold and bold slanted (and % "outlined" (blackboard board, sort of) versions, which we don't need). % It is available from http://www.ctan.org/tex-archive/fonts/eurosym. -% +% % Although only regular is the truly official Euro symbol, we ignore % that. The Euro is designed to be slightly taller than the regular % font height. -% +% % feymr - regular % feymo - slanted % feybr - bold % feybo - bold slanted -% +% % There is no good (free) typewriter version, to my knowledge. % A feymr10 euro is ~7.3pt wide, while a normal cmtt10 char is ~5.25pt wide. % Hmm. -% +% % Also doesn't work in math. Do we need to do math with euro symbols? % Hope not. -% -% +% +% \def\euro{{\eurofont e}} \def\eurofont{% % We set the font at each command, rather than predefining it in % \textfonts and the other font-switching commands, so that % installations which never need the symbol don't have to have the % font installed. - % + % % There is only one designed size (nominal 10pt), so we always scale % that to the current nominal size. - % + % % By the way, simply using "at 1em" works for cmr10 and the like, but % does not work for cmbx10 and other extended/shrunken fonts. - % + % \def\eurosize{\csname\curfontsize nominalsize\endcsname}% % - \ifx\curfontstyle\bfstylename + \ifx\curfontstyle\bfstylename % bold: \font\thiseurofont = \ifusingit{feybo10}{feybr10} at \eurosize - \else + \else % regular: \font\thiseurofont = \ifusingit{feymo10}{feymr10} at \eurosize \fi \thiseurofont } -% Glyphs from the EC fonts. We don't use \let for the aliases, because -% sometimes we redefine the original macro, and the alias should reflect -% the redefinition. -% -% Use LaTeX names for the Icelandic letters. -\def\DH{{\ecfont \char"D0}} % Eth -\def\dh{{\ecfont \char"F0}} % eth -\def\TH{{\ecfont \char"DE}} % Thorn -\def\th{{\ecfont \char"FE}} % thorn -% -\def\guillemetleft{{\ecfont \char"13}} -\def\guillemotleft{\guillemetleft} -\def\guillemetright{{\ecfont \char"14}} -\def\guillemotright{\guillemetright} -\def\guilsinglleft{{\ecfont \char"0E}} -\def\guilsinglright{{\ecfont \char"0F}} -\def\quotedblbase{{\ecfont \char"12}} -\def\quotesinglbase{{\ecfont \char"0D}} -% -% This positioning is not perfect (see the ogonek LaTeX package), but -% we have the precomposed glyphs for the most common cases. We put the -% tests to use those glyphs in the single \ogonek macro so we have fewer -% dummy definitions to worry about for index entries, etc. -% -% ogonek is also used with other letters in Lithuanian (IOU), but using -% the precomposed glyphs for those is not so easy since they aren't in -% the same EC font. -\def\ogonek#1{{% - \def\temp{#1}% - \ifx\temp\macrocharA\Aogonek - \else\ifx\temp\macrochara\aogonek - \else\ifx\temp\macrocharE\Eogonek - \else\ifx\temp\macrochare\eogonek - \else - \ecfont \setbox0=\hbox{#1}% - \ifdim\ht0=1ex\accent"0C #1% - \else\ooalign{\unhbox0\crcr\hidewidth\char"0C \hidewidth}% - \fi - \fi\fi\fi\fi - }% -} -\def\Aogonek{{\ecfont \char"81}}\def\macrocharA{A} -\def\aogonek{{\ecfont \char"A1}}\def\macrochara{a} -\def\Eogonek{{\ecfont \char"86}}\def\macrocharE{E} -\def\eogonek{{\ecfont \char"A6}}\def\macrochare{e} -% -% Use the ec* fonts (cm-super in outline format) for non-CM glyphs. -\def\ecfont{% - % We can't distinguish serif/sans and italic/slanted, but this - % is used for crude hacks anyway (like adding French and German - % quotes to documents typeset with CM, where we lose kerning), so - % hopefully nobody will notice/care. - \edef\ecsize{\csname\curfontsize ecsize\endcsname}% - \edef\nominalsize{\csname\curfontsize nominalsize\endcsname}% - \ifx\curfontstyle\bfstylename - % bold: - \font\thisecfont = ecb\ifusingit{i}{x}\ecsize \space at \nominalsize - \else - % regular: - \font\thisecfont = ec\ifusingit{ti}{rm}\ecsize \space at \nominalsize - \fi - \thisecfont -} - % @registeredsymbol - R in a circle. The font for the R should really % be smaller yet, but lllsize is the best we can do for now. % Adapted from the plain.tex definition of \copyright. @@ -3164,24 +2128,14 @@ }$% } -% @textdegree - the normal degrees sign. -% -\def\textdegree{$^\circ$} - % Laurent Siebenmann reports \Orb undefined with: % Textures 1.7.7 (preloaded format=plain 93.10.14) (68K) 16 APR 2004 02:38 % so we'll define it if necessary. -% -\ifx\Orb\thisisundefined +% +\ifx\Orb\undefined \def\Orb{\mathhexbox20D} \fi -% Quotes. -\chardef\quotedblleft="5C -\chardef\quotedblright=`\" -\chardef\quoteleft=`\` -\chardef\quoteright=`\' - \message{page headings,} @@ -3200,9 +2154,8 @@ \newif\ifsetshortcontentsaftertitlepage \let\setshortcontentsaftertitlepage = \setshortcontentsaftertitlepagetrue -\parseargdef\shorttitlepage{% - \begingroup \hbox{}\vskip 1.5in \chaprm \centerline{#1}% - \endgroup\page\hbox{}\page} +\parseargdef\shorttitlepage{\begingroup\hbox{}\vskip 1.5in \chaprm \centerline{#1}% + \endgroup\page\hbox{}\page} \envdef\titlepage{% % Open one extra group, as we want to close it in the middle of \Etitlepage. @@ -3262,14 +2215,17 @@ \finishedtitlepagetrue } -% Macros to be used within @titlepage: +%%% Macros to be used within @titlepage: \let\subtitlerm=\tenrm \def\subtitlefont{\subtitlerm \normalbaselineskip = 13pt \normalbaselines} +\def\authorfont{\authorrm \normalbaselineskip = 16pt \normalbaselines + \let\tt=\authortt} + \parseargdef\title{% \checkenv\titlepage - \leftline{\titlefonts\rmisbold #1} + \leftline{\titlefonts\rm #1} % print a rule at the page bottom also. \finishedtitlepagefalse \vskip4pt \hrule height 4pt width \hsize \vskip4pt @@ -3290,12 +2246,12 @@ \else \checkenv\titlepage \ifseenauthor\else \vskip 0pt plus 1filll \seenauthortrue \fi - {\secfonts\rmisbold \leftline{#1}}% + {\authorfont \leftline{#1}}% \fi } -% Set up page headings and footings. +%%% Set up page headings and footings. \let\thispage=\folio @@ -3343,39 +2299,12 @@ % % Leave some space for the footline. Hopefully ok to assume % @evenfooting will not be used by itself. - \global\advance\pageheight by -12pt - \global\advance\vsize by -12pt + \global\advance\pageheight by -\baselineskip + \global\advance\vsize by -\baselineskip } \parseargdef\everyfooting{\oddfootingxxx{#1}\evenfootingxxx{#1}} -% @evenheadingmarks top \thischapter <- chapter at the top of a page -% @evenheadingmarks bottom \thischapter <- chapter at the bottom of a page -% -% The same set of arguments for: -% -% @oddheadingmarks -% @evenfootingmarks -% @oddfootingmarks -% @everyheadingmarks -% @everyfootingmarks - -\def\evenheadingmarks{\headingmarks{even}{heading}} -\def\oddheadingmarks{\headingmarks{odd}{heading}} -\def\evenfootingmarks{\headingmarks{even}{footing}} -\def\oddfootingmarks{\headingmarks{odd}{footing}} -\def\everyheadingmarks#1 {\headingmarks{even}{heading}{#1} - \headingmarks{odd}{heading}{#1} } -\def\everyfootingmarks#1 {\headingmarks{even}{footing}{#1} - \headingmarks{odd}{footing}{#1} } -% #1 = even/odd, #2 = heading/footing, #3 = top/bottom. -\def\headingmarks#1#2#3 {% - \expandafter\let\expandafter\temp \csname get#3headingmarks\endcsname - \global\expandafter\let\csname get#1#2marks\endcsname \temp -} - -\everyheadingmarks bottom -\everyfootingmarks bottom % @headings double turns headings on for double-sided printing. % @headings single turns headings on for single-sided printing. @@ -3389,14 +2318,10 @@ \def\headings #1 {\csname HEADINGS#1\endcsname} -\def\headingsoff{% non-global headings elimination - \evenheadline={\hfil}\evenfootline={\hfil}% - \oddheadline={\hfil}\oddfootline={\hfil}% -} - -\def\HEADINGSoff{{\globaldefs=1 \headingsoff}} % global setting -\HEADINGSoff % it's the default - +\def\HEADINGSoff{% +\global\evenheadline={\hfil} \global\evenfootline={\hfil} +\global\oddheadline={\hfil} \global\oddfootline={\hfil}} +\HEADINGSoff % When we turn headings on, set the page number to 1. % For double-sided printing, put current file name in lower left corner, % chapter name on inside top of right hand pages, document @@ -3447,7 +2372,7 @@ % This produces Day Month Year style of output. % Only define if not already defined, in case a txi-??.tex file has set % up a different format (e.g., txi-cs.tex does this). -\ifx\today\thisisundefined +\ifx\today\undefined \def\today{% \number\day\space \ifcase\month @@ -3508,7 +2433,7 @@ \begingroup \advance\leftskip by-\tableindent \advance\hsize by\tableindent - \advance\rightskip by0pt plus1fil\relax + \advance\rightskip by0pt plus1fil \leavevmode\unhbox0\par \endgroup % @@ -3522,7 +2447,7 @@ % cause the example and the item to crash together. So we use this % bizarre value of 10001 as a signal to \aboveenvbreak to insert % \parskip glue after all. Section titles are handled this way also. - % + % \penalty 10001 \endgroup \itemxneedsnegativevskipfalse @@ -3616,18 +2541,9 @@ \parindent=0pt \parskip=\smallskipamount \ifdim\parskip=0pt \parskip=2pt \fi - % - % Try typesetting the item mark that if the document erroneously says - % something like @itemize @samp (intending @table), there's an error - % right away at the @itemize. It's not the best error message in the - % world, but it's better than leaving it to the @item. This means if - % the user wants an empty mark, they have to say @w{} not just @w. \def\itemcontents{#1}% - \setbox0 = \hbox{\itemcontents}% - % % @itemize with no arg is equivalent to @itemize @bullet. \ifx\itemcontents\empty\def\itemcontents{\bullet}\fi - % \let\item=\itemizeitem } @@ -3648,7 +2564,6 @@ \ifnum\lastpenalty<10000 \parskip=0in \fi \noindent \hbox to 0pt{\hss \itemcontents \kern\itemmargin}% - % \vadjust{\penalty 1200}}% not good to break after first line of item. \flushcr } @@ -3870,19 +2785,12 @@ % % @headitem starts a heading row, which we typeset in bold. % Assignments have to be global since we are inside the implicit group -% of an alignment entry. \everycr resets \everytab so we don't have to -% undo it ourselves. -\def\headitemfont{\b}% for people to use in the template row; not changeable -\def\headitem{% - \checkenv\multitable - \crcr - \global\everytab={\bf}% can't use \headitemfont since the parsing differs - \the\everytab % for the first item -}% +% of an alignment entry. Note that \everycr resets \everytab. +\def\headitem{\checkenv\multitable \crcr \global\everytab={\bf}\the\everytab}% % % A \tab used to include \hskip1sp. But then the space in a template % line is not enough. That is bad. So let's go back to just `&' until -% we again encounter the problem the 1sp was intended to solve. +% we encounter the problem it was intended to solve again. % --karl, nathan@acm.org, 20apr99. \def\tab{\checkenv\multitable &\the\everytab}% @@ -3994,18 +2902,18 @@ \setbox0=\vbox{X}\global\multitablelinespace=\the\baselineskip \global\advance\multitablelinespace by-\ht0 \fi -% Test to see if parskip is larger than space between lines of -% table. If not, do nothing. -% If so, set to same dimension as multitablelinespace. +%% Test to see if parskip is larger than space between lines of +%% table. If not, do nothing. +%% If so, set to same dimension as multitablelinespace. \ifdim\multitableparskip>\multitablelinespace \global\multitableparskip=\multitablelinespace -\global\advance\multitableparskip-7pt % to keep parskip somewhat smaller - % than skip between lines in the table. +\global\advance\multitableparskip-7pt %% to keep parskip somewhat smaller + %% than skip between lines in the table. \fi% \ifdim\multitableparskip=0pt \global\multitableparskip=\multitablelinespace -\global\advance\multitableparskip-7pt % to keep parskip somewhat smaller - % than skip between lines in the table. +\global\advance\multitableparskip-7pt %% to keep parskip somewhat smaller + %% than skip between lines in the table. \fi} @@ -4051,7 +2959,6 @@ \def\doignore#1{\begingroup % Scan in ``verbatim'' mode: - \obeylines \catcode`\@ = \other \catcode`\{ = \other \catcode`\} = \other @@ -4072,16 +2979,16 @@ \gdef\dodoignore#1{% % #1 contains the command name as a string, e.g., `ifinfo'. % - % Define a command to find the next `@end #1'. - \long\def\doignoretext##1^^M@end #1{% - \doignoretextyyy##1^^M@#1\_STOP_}% - % + % Define a command to find the next `@end #1', which must be on a line + % by itself. + \long\def\doignoretext##1^^M@end #1{\doignoretextyyy##1^^M@#1\_STOP_}% % And this command to find another #1 command, at the beginning of a % line. (Otherwise, we would consider a line `@c @ifset', for % example, to count as an @ifset for nesting.) \long\def\doignoretextyyy##1^^M@#1##2\_STOP_{\doignoreyyy{##2}\_STOP_}% % % And now expand that command. + \obeylines % \doignoretext ^^M% }% } @@ -4111,12 +3018,7 @@ } % Finish off ignored text. -{ \obeylines% - % Ignore anything after the last `@end #1'; this matters in verbatim - % environments, where otherwise the newline after an ignored conditional - % would result in a blank line in the output. - \gdef\enddoignore#1^^M{\endgroup\ignorespaces}% -} +\def\enddoignore{\endgroup\ignorespaces} % @set VAR sets the variable VAR to an empty value. @@ -4281,11 +3183,11 @@ \def\dosynindex#1#2#3{% % Only do \closeout if we haven't already done it, else we'll end up % closing the target index. - \expandafter \ifx\csname donesynindex#2\endcsname \relax + \expandafter \ifx\csname donesynindex#2\endcsname \undefined % The \closeout helps reduce unnecessary open files; the limit on the % Acorn RISC OS is a mere 16 files. \expandafter\closeout\csname#2indfile\endcsname - \expandafter\let\csname donesynindex#2\endcsname = 1 + \expandafter\let\csname\donesynindex#2\endcsname = 1 \fi % redefine \fooindfile: \expandafter\let\expandafter\temp\expandafter=\csname#3indfile\endcsname @@ -4319,41 +3221,11 @@ \escapechar = `\\ % use backslash in output files. \def\@{@}% change to @@ when we switch to @ as escape char in index files. \def\ {\realbackslash\space }% - % - % Need these unexpandable (because we define \tt as a dummy) - % definitions when @{ or @} appear in index entry text. Also, more - % complicated, when \tex is in effect and \{ is a \delimiter again. - % We can't use \lbracecmd and \rbracecmd because texindex assumes - % braces and backslashes are used only as delimiters. Perhaps we - % should define @lbrace and @rbrace commands a la @comma. - \def\{{{\tt\char123}}% - \def\}{{\tt\char125}}% - % - % I don't entirely understand this, but when an index entry is - % generated from a macro call, the \endinput which \scanmacro inserts - % causes processing to be prematurely terminated. This is, - % apparently, because \indexsorttmp is fully expanded, and \endinput - % is an expandable command. The redefinition below makes \endinput - % disappear altogether for that purpose -- although logging shows that - % processing continues to some further point. On the other hand, it - % seems \endinput does not hurt in the printed index arg, since that - % is still getting written without apparent harm. - % - % Sample source (mac-idx3.tex, reported by Graham Percival to - % help-texinfo, 22may06): - % @macro funindex {WORD} - % @findex xyz - % @end macro - % ... - % @funindex commtest - % - % The above is not enough to reproduce the bug, but it gives the flavor. - % - % Sample whatsit resulting: - % .@write3{\entry{xyz}{@folio }{@code {xyz@endinput }}} - % - % So: - \let\endinput = \empty + % Need these in case \tex is in effect and \{ is a \delimiter again. + % But can't use \lbracecmd and \rbracecmd because texindex assumes + % braces and backslashes are used only as delimiters. + \let\{ = \mylbrace + \let\} = \myrbrace % % Do the redefinitions. \commondummies @@ -4372,7 +3244,6 @@ % % Do the redefinitions. \commondummies - \otherbackslash } % Called from \indexdummies and \atdummies. @@ -4380,7 +3251,7 @@ \def\commondummies{% % % \definedummyword defines \#1 as \string\#1\space, thus effectively - % preventing its expansion. This is used only for control words, + % preventing its expansion. This is used only for control% words, % not control letters, because the \space would be incorrect for % control characters, but is needed to separate the control word % from whatever follows. @@ -4399,28 +3270,23 @@ \commondummiesnofonts % \definedummyletter\_% - \definedummyletter\-% % % Non-English letters. \definedummyword\AA \definedummyword\AE - \definedummyword\DH \definedummyword\L + \definedummyword\OE \definedummyword\O - \definedummyword\OE - \definedummyword\TH \definedummyword\aa \definedummyword\ae - \definedummyword\dh + \definedummyword\l + \definedummyword\oe + \definedummyword\o + \definedummyword\ss \definedummyword\exclamdown - \definedummyword\l - \definedummyword\o - \definedummyword\oe + \definedummyword\questiondown \definedummyword\ordf \definedummyword\ordm - \definedummyword\questiondown - \definedummyword\ss - \definedummyword\th % % Although these internal commands shouldn't show up, sometimes they do. \definedummyword\bf @@ -4436,39 +3302,21 @@ \definedummyword\TeX % % Assorted special characters. - \definedummyword\arrow \definedummyword\bullet \definedummyword\comma \definedummyword\copyright \definedummyword\registeredsymbol \definedummyword\dots \definedummyword\enddots - \definedummyword\entrybreak \definedummyword\equiv \definedummyword\error \definedummyword\euro \definedummyword\expansion - \definedummyword\geq - \definedummyword\guillemetleft - \definedummyword\guillemetright - \definedummyword\guilsinglleft - \definedummyword\guilsinglright - \definedummyword\lbracechar - \definedummyword\leq \definedummyword\minus - \definedummyword\ogonek \definedummyword\pounds \definedummyword\point \definedummyword\print - \definedummyword\quotedblbase - \definedummyword\quotedblleft - \definedummyword\quotedblright - \definedummyword\quoteleft - \definedummyword\quoteright - \definedummyword\quotesinglbase - \definedummyword\rbracechar \definedummyword\result - \definedummyword\textdegree % % We want to disable all macros so that they are not expanded by \write. \macrolist @@ -4482,72 +3330,63 @@ % \commondummiesnofonts: common to \commondummies and \indexnofonts. % -\def\commondummiesnofonts{% - % Control letters and accents. - \definedummyletter\!% - \definedummyaccent\"% - \definedummyaccent\'% - \definedummyletter\*% - \definedummyaccent\,% - \definedummyletter\.% - \definedummyletter\/% - \definedummyletter\:% - \definedummyaccent\=% - \definedummyletter\?% - \definedummyaccent\^% - \definedummyaccent\`% - \definedummyaccent\~% - \definedummyword\u - \definedummyword\v - \definedummyword\H - \definedummyword\dotaccent - \definedummyword\ogonek - \definedummyword\ringaccent - \definedummyword\tieaccent - \definedummyword\ubaraccent - \definedummyword\udotaccent - \definedummyword\dotless - % - % Texinfo font commands. - \definedummyword\b - \definedummyword\i - \definedummyword\r - \definedummyword\sansserif - \definedummyword\sc - \definedummyword\slanted - \definedummyword\t - % - % Commands that take arguments. - \definedummyword\abbr - \definedummyword\acronym - \definedummyword\anchor - \definedummyword\cite - \definedummyword\code - \definedummyword\command - \definedummyword\dfn - \definedummyword\dmn - \definedummyword\email - \definedummyword\emph - \definedummyword\env - \definedummyword\file - \definedummyword\image - \definedummyword\indicateurl - \definedummyword\inforef - \definedummyword\kbd - \definedummyword\key - \definedummyword\math - \definedummyword\option - \definedummyword\pxref - \definedummyword\ref - \definedummyword\samp - \definedummyword\strong - \definedummyword\tie - \definedummyword\uref - \definedummyword\url - \definedummyword\var - \definedummyword\verb - \definedummyword\w - \definedummyword\xref +% Better have this without active chars. +{ + \catcode`\~=\other + \gdef\commondummiesnofonts{% + % Control letters and accents. + \definedummyletter\!% + \definedummyaccent\"% + \definedummyaccent\'% + \definedummyletter\*% + \definedummyaccent\,% + \definedummyletter\.% + \definedummyletter\/% + \definedummyletter\:% + \definedummyaccent\=% + \definedummyletter\?% + \definedummyaccent\^% + \definedummyaccent\`% + \definedummyaccent\~% + \definedummyword\u + \definedummyword\v + \definedummyword\H + \definedummyword\dotaccent + \definedummyword\ringaccent + \definedummyword\tieaccent + \definedummyword\ubaraccent + \definedummyword\udotaccent + \definedummyword\dotless + % + % Texinfo font commands. + \definedummyword\b + \definedummyword\i + \definedummyword\r + \definedummyword\sc + \definedummyword\t + % + % Commands that take arguments. + \definedummyword\acronym + \definedummyword\cite + \definedummyword\code + \definedummyword\command + \definedummyword\dfn + \definedummyword\emph + \definedummyword\env + \definedummyword\file + \definedummyword\kbd + \definedummyword\key + \definedummyword\math + \definedummyword\option + \definedummyword\samp + \definedummyword\strong + \definedummyword\tie + \definedummyword\uref + \definedummyword\url + \definedummyword\var + \definedummyword\verb + \definedummyword\w + } } % \indexnofonts is used when outputting the strings to sort the index @@ -4560,7 +3399,7 @@ \def\definedummyaccent##1{\let##1\asis}% % We can just ignore other control letters. \def\definedummyletter##1{\let##1\empty}% - % All control words become @asis by default; overrides below. + % Hopefully, all control words can become @asis. \let\definedummyword\definedummyaccent % \commondummiesnofonts @@ -4572,95 +3411,60 @@ % \def\ { }% \def\@{@}% + % how to handle braces? \def\_{\normalunderscore}% - \def\-{}% @- shouldn't affect sorting - % - % Unfortunately, texindex is not prepared to handle braces in the - % content at all. So for index sorting, we map @{ and @} to strings - % starting with |, since that ASCII character is between ASCII { and }. - \def\{{|a}% - \def\lbracechar{|a}% - % - \def\}{|b}% - \def\rbracechar{|b}% % % Non-English letters. \def\AA{AA}% \def\AE{AE}% - \def\DH{DZZ}% \def\L{L}% \def\OE{OE}% \def\O{O}% - \def\TH{ZZZ}% \def\aa{aa}% \def\ae{ae}% - \def\dh{dzz}% - \def\exclamdown{!}% \def\l{l}% \def\oe{oe}% + \def\o{o}% + \def\ss{ss}% + \def\exclamdown{!}% + \def\questiondown{?}% \def\ordf{a}% \def\ordm{o}% - \def\o{o}% - \def\questiondown{?}% - \def\ss{ss}% - \def\th{zzz}% % \def\LaTeX{LaTeX}% \def\TeX{TeX}% % % Assorted special characters. % (The following {} will end up in the sort string, but that's ok.) - \def\arrow{->}% \def\bullet{bullet}% \def\comma{,}% \def\copyright{copyright}% + \def\registeredsymbol{R}% \def\dots{...}% \def\enddots{...}% \def\equiv{==}% \def\error{error}% \def\euro{euro}% \def\expansion{==>}% - \def\geq{>=}% - \def\guillemetleft{<<}% - \def\guillemetright{>>}% - \def\guilsinglleft{<}% - \def\guilsinglright{>}% - \def\leq{<=}% \def\minus{-}% + \def\pounds{pounds}% \def\point{.}% - \def\pounds{pounds}% \def\print{-|}% - \def\quotedblbase{"}% - \def\quotedblleft{"}% - \def\quotedblright{"}% - \def\quoteleft{`}% - \def\quoteright{'}% - \def\quotesinglbase{,}% - \def\registeredsymbol{R}% \def\result{=>}% - \def\textdegree{o}% - % - \expandafter\ifx\csname SETtxiindexlquoteignore\endcsname\relax - \else \indexlquoteignore \fi % % We need to get rid of all macros, leaving only the arguments (if present). % Of course this is not nearly correct, but it is the best we can do for now. % makeinfo does not expand macros in the argument to @deffn, which ends up % writing an index entry, and texindex isn't prepared for an index sort entry % that starts with \. - % + % % Since macro invocations are followed by braces, we can just redefine them % to take a single TeX argument. The case of a macro invocation that % goes to end-of-line is not handled. - % + % \macrolist } -% Undocumented (for FSFS 2nd ed.): @set txiindexlquoteignore makes us -% ignore left quotes in the sort term. -{\catcode`\`=\active - \gdef\indexlquoteignore{\let`=\empty}} - \let\indexbackslash=0 %overridden during \printindex. \let\SETmarginindex=\relax % put index entries in margin (undocumented)? @@ -4686,7 +3490,11 @@ % \edef\writeto{\csname#1indfile\endcsname}% % - \safewhatsit\dosubindwrite + \ifvmode + \dosubindsanitize + \else + \dosubindwrite + \fi }% \fi } @@ -4723,13 +3531,13 @@ \temp } -% Take care of unwanted page breaks/skips around a whatsit: +% Take care of unwanted page breaks: % % If a skip is the last thing on the list now, preserve it % by backing up by \lastskip, doing the \write, then inserting % the skip again. Otherwise, the whatsit generated by the -% \write or \pdfdest will make \lastskip zero. The result is that -% sequences like this: +% \write will make \lastskip zero. The result is that sequences +% like this: % @end defun % @tindex whatever % @defun ... @@ -4753,30 +3561,25 @@ % \edef\zeroskipmacro{\expandafter\the\csname z@skip\endcsname} % -\newskip\whatsitskip -\newcount\whatsitpenalty -% % ..., ready, GO: % -\def\safewhatsit#1{\ifhmode - #1% - \else +\def\dosubindsanitize{% % \lastskip and \lastpenalty cannot both be nonzero simultaneously. - \whatsitskip = \lastskip + \skip0 = \lastskip \edef\lastskipmacro{\the\lastskip}% - \whatsitpenalty = \lastpenalty + \count255 = \lastpenalty % % If \lastskip is nonzero, that means the last item was a % skip. And since a skip is discardable, that means this - % -\whatsitskip glue we're inserting is preceded by a + % -\skip0 glue we're inserting is preceded by a % non-discardable item, therefore it is not a potential % breakpoint, therefore no \nobreak needed. \ifx\lastskipmacro\zeroskipmacro \else - \vskip-\whatsitskip + \vskip-\skip0 \fi % - #1% + \dosubindwrite % \ifx\lastskipmacro\zeroskipmacro % If \lastskip was zero, perhaps the last item was a penalty, and @@ -4784,19 +3587,20 @@ % to re-insert the same penalty (values >10000 are used for various % signals); since we just inserted a non-discardable item, any % following glue (such as a \parskip) would be a breakpoint. For example: + % % @deffn deffn-whatever % @vindex index-whatever % Description. % would allow a break between the index-whatever whatsit % and the "Description." paragraph. - \ifnum\whatsitpenalty>9999 \penalty\whatsitpenalty \fi + \ifnum\count255>9999 \penalty\count255 \fi \else % On the other hand, if we had a nonzero \lastskip, % this make-up glue would be preceded by a non-discardable item % (the whatsit from the \write), so we must insert a \nobreak. - \nobreak\vskip\whatsitskip + \nobreak\vskip\skip0 \fi -\fi} +} % The index entry written in the file actually looks like % \entry {sortstring}{page}{topic} @@ -4838,7 +3642,6 @@ % \smallfonts \rm \tolerance = 9500 - \plainfrenchspacing \everypar = {}% don't want the \kern\-parindent from indentation suppression. % % See if the index file exists and is nonempty. @@ -4912,9 +3715,10 @@ % % A straightforward implementation would start like this: % \def\entry#1#2{... -% But this freezes the catcodes in the argument, and can cause problems to +% But this frozes the catcodes in the argument, and can cause problems to % @code, which sets - active. This problem was fixed by a kludge--- % ``-'' was active throughout whole index, but this isn't really right. +% % The right solution is to prevent \entry from swallowing the whole text. % --kasal, 21nov03 \def\entry{% @@ -4951,17 +3755,10 @@ % columns. \vskip 0pt plus1pt % - % When reading the text of entry, convert explicit line breaks - % from @* into spaces. The user might give these in long section - % titles, for instance. - \def\*{\unskip\space\ignorespaces}% - \def\entrybreak{\hfil\break}% - % % Swallow the left brace of the text (first parameter): \afterassignment\doentry \let\temp = } -\def\entrybreak{\unskip\space\ignorespaces}% \def\doentry{% \bgroup % Instead of the swallowed brace. \noindent @@ -4974,8 +3771,11 @@ % The following is kludged to not output a line of dots in the index if % there are no page numbers. The next person who breaks this will be % cursed by a Unix daemon. - \setbox\boxA = \hbox{#1}% - \ifdim\wd\boxA = 0pt + \def\tempa{{\rm }}% + \def\tempb{#1}% + \edef\tempc{\tempa}% + \edef\tempd{\tempb}% + \ifx\tempc\tempd \ % \else % @@ -4999,9 +3799,9 @@ \endgroup } -% Like plain.tex's \dotfill, except uses up at least 1 em. +% Like \dotfill except takes at least 1 em. \def\indexdotfill{\cleaders - \hbox{$\mathsurround=0pt \mkern1.5mu.\mkern1.5mu$}\hskip 1em plus 1fill} + \hbox{$\mathsurround=0pt \mkern1.5mu ${\it .}$ \mkern1.5mu$}\hskip 1em plus 1fill} \def\primary #1{\line{#1\hfil}} @@ -5111,34 +3911,6 @@ % % All done with double columns. \def\enddoublecolumns{% - % The following penalty ensures that the page builder is exercised - % _before_ we change the output routine. This is necessary in the - % following situation: - % - % The last section of the index consists only of a single entry. - % Before this section, \pagetotal is less than \pagegoal, so no - % break occurs before the last section starts. However, the last - % section, consisting of \initial and the single \entry, does not - % fit on the page and has to be broken off. Without the following - % penalty the page builder will not be exercised until \eject - % below, and by that time we'll already have changed the output - % routine to the \balancecolumns version, so the next-to-last - % double-column page will be processed with \balancecolumns, which - % is wrong: The two columns will go to the main vertical list, with - % the broken-off section in the recent contributions. As soon as - % the output routine finishes, TeX starts reconsidering the page - % break. The two columns and the broken-off section both fit on the - % page, because the two columns now take up only half of the page - % goal. When TeX sees \eject from below which follows the final - % section, it invokes the new output routine that we've set after - % \balancecolumns below; \onepageout will try to fit the two columns - % and the final section into the vbox of \pageheight (see - % \pagebody), causing an overfull box. - % - % Note that glue won't work here, because glue does not exercise the - % page builder, unlike penalties (see The TeXbook, pp. 280-281). - \penalty0 - % \output = {% % Split the last of the double-column material. Leave it on the % current page, no automatic page break. @@ -5194,22 +3966,7 @@ \message{sectioning,} % Chapters, sections, etc. -% Let's start with @part. -\outer\parseargdef\part{\partzzz{#1}} -\def\partzzz#1{% - \chapoddpage - \null - \vskip.3\vsize % move it down on the page a bit - \begingroup - \noindent \titlefonts\rmisbold #1\par % the text - \let\lastnode=\empty % no node to associate with - \writetocentry{part}{#1}{}% but put it in the toc - \headingsoff % no headline or footline on the part page - \chapoddpage - \endgroup -} - -% \unnumberedno is an oxymoron. But we count the unnumbered +% \unnumberedno is an oxymoron, of course. But we count the unnumbered % sections so that we can refer to them unambiguously in the pdf % outlines by their "section number". We avoid collisions with chapter % numbers by starting them at 10000. (If a document ever has 10000 @@ -5263,15 +4020,11 @@ \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi} -% Each @chapter defines these (using marks) as the number+name, number -% and name of the chapter. Page headings and footings can use -% these. @section does likewise. +% Each @chapter defines this as the name of the chapter. +% page headings and footings can use it. @section does likewise. +% However, they are not reliable, because we don't use marks. \def\thischapter{} -\def\thischapternum{} -\def\thischaptername{} \def\thissection{} -\def\thissectionnum{} -\def\thissectionname{} \newcount\absseclevel % used to calculate proper heading level \newcount\secbase\secbase=0 % @raisesections/@lowersections modify this count @@ -5288,8 +4041,8 @@ \chardef\maxseclevel = 3 % % A numbered section within an unnumbered changes to unnumbered too. -% To achieve this, remember the "biggest" unnum. sec. we are currently in: -\chardef\unnlevel = \maxseclevel +% To achive this, remember the "biggest" unnum. sec. we are currently in: +\chardef\unmlevel = \maxseclevel % % Trace whether the current chapter is an appendix or not: % \chapheadtype is "N" or "A", unnumbered chapters are ignored. @@ -5314,8 +4067,8 @@ % The heading type: \def\headtype{#1}% \if \headtype U% - \ifnum \absseclevel < \unnlevel - \chardef\unnlevel = \absseclevel + \ifnum \absseclevel < \unmlevel + \chardef\unmlevel = \absseclevel \fi \else % Check for appendix sections: @@ -5327,10 +4080,10 @@ \fi\fi \fi % Check for numbered within unnumbered: - \ifnum \absseclevel > \unnlevel + \ifnum \absseclevel > \unmlevel \def\headtype{U}% \else - \chardef\unnlevel = 3 + \chardef\unmlevel = 3 \fi \fi % Now print the heading: @@ -5384,9 +4137,7 @@ \gdef\chaplevelprefix{\the\chapno.}% \resetallfloatnos % - % \putwordChapter can contain complex things in translations. - \toks0=\expandafter{\putwordChapter}% - \message{\the\toks0 \space \the\chapno}% + \message{\putwordChapter\space \the\chapno}% % % Write the actual heading. \chapmacro{#1}{Ynumbered}{\the\chapno}% @@ -5397,17 +4148,15 @@ \global\let\subsubsection = \numberedsubsubsec } -\outer\parseargdef\appendix{\apphead0{#1}} % normally calls appendixzzz -% +\outer\parseargdef\appendix{\apphead0{#1}} % normally apphead0 calls appendixzzz \def\appendixzzz#1{% \global\secno=0 \global\subsecno=0 \global\subsubsecno=0 \global\advance\appendixno by 1 \gdef\chaplevelprefix{\appendixletter.}% \resetallfloatnos % - % \putwordAppendix can contain complex things in translations. - \toks0=\expandafter{\putwordAppendix}% - \message{\the\toks0 \space \appendixletter}% + \def\appendixnum{\putwordAppendix\space \appendixletter}% + \message{\appendixnum}% % \chapmacro{#1}{Yappendix}{\appendixletter}% % @@ -5416,8 +4165,7 @@ \global\let\subsubsection = \appendixsubsubsec } -% normally unnmhead0 calls unnumberedzzz: -\outer\parseargdef\unnumbered{\unnmhead0{#1}} +\outer\parseargdef\unnumbered{\unnmhead0{#1}} % normally unnmhead0 calls unnumberedzzz \def\unnumberedzzz#1{% \global\secno=0 \global\subsecno=0 \global\subsubsecno=0 \global\advance\unnumberedno by 1 @@ -5461,47 +4209,40 @@ \let\top\unnumbered % Sections. -% \outer\parseargdef\numberedsec{\numhead1{#1}} % normally calls seczzz \def\seczzz#1{% \global\subsecno=0 \global\subsubsecno=0 \global\advance\secno by 1 \sectionheading{#1}{sec}{Ynumbered}{\the\chapno.\the\secno}% } -% normally calls appendixsectionzzz: -\outer\parseargdef\appendixsection{\apphead1{#1}} +\outer\parseargdef\appendixsection{\apphead1{#1}} % normally calls appendixsectionzzz \def\appendixsectionzzz#1{% \global\subsecno=0 \global\subsubsecno=0 \global\advance\secno by 1 \sectionheading{#1}{sec}{Yappendix}{\appendixletter.\the\secno}% } \let\appendixsec\appendixsection -% normally calls unnumberedseczzz: -\outer\parseargdef\unnumberedsec{\unnmhead1{#1}} +\outer\parseargdef\unnumberedsec{\unnmhead1{#1}} % normally calls unnumberedseczzz \def\unnumberedseczzz#1{% \global\subsecno=0 \global\subsubsecno=0 \global\advance\secno by 1 \sectionheading{#1}{sec}{Ynothing}{\the\unnumberedno.\the\secno}% } % Subsections. -% -% normally calls numberedsubseczzz: -\outer\parseargdef\numberedsubsec{\numhead2{#1}} +\outer\parseargdef\numberedsubsec{\numhead2{#1}} % normally calls numberedsubseczzz \def\numberedsubseczzz#1{% \global\subsubsecno=0 \global\advance\subsecno by 1 \sectionheading{#1}{subsec}{Ynumbered}{\the\chapno.\the\secno.\the\subsecno}% } -% normally calls appendixsubseczzz: -\outer\parseargdef\appendixsubsec{\apphead2{#1}} +\outer\parseargdef\appendixsubsec{\apphead2{#1}} % normally calls appendixsubseczzz \def\appendixsubseczzz#1{% \global\subsubsecno=0 \global\advance\subsecno by 1 \sectionheading{#1}{subsec}{Yappendix}% {\appendixletter.\the\secno.\the\subsecno}% } -% normally calls unnumberedsubseczzz: -\outer\parseargdef\unnumberedsubsec{\unnmhead2{#1}} +\outer\parseargdef\unnumberedsubsec{\unnmhead2{#1}} %normally calls unnumberedsubseczzz \def\unnumberedsubseczzz#1{% \global\subsubsecno=0 \global\advance\subsecno by 1 \sectionheading{#1}{subsec}{Ynothing}% @@ -5509,25 +4250,21 @@ } % Subsubsections. -% -% normally numberedsubsubseczzz: -\outer\parseargdef\numberedsubsubsec{\numhead3{#1}} +\outer\parseargdef\numberedsubsubsec{\numhead3{#1}} % normally numberedsubsubseczzz \def\numberedsubsubseczzz#1{% \global\advance\subsubsecno by 1 \sectionheading{#1}{subsubsec}{Ynumbered}% {\the\chapno.\the\secno.\the\subsecno.\the\subsubsecno}% } -% normally appendixsubsubseczzz: -\outer\parseargdef\appendixsubsubsec{\apphead3{#1}} +\outer\parseargdef\appendixsubsubsec{\apphead3{#1}} % normally appendixsubsubseczzz \def\appendixsubsubseczzz#1{% \global\advance\subsubsecno by 1 \sectionheading{#1}{subsubsec}{Yappendix}% {\appendixletter.\the\secno.\the\subsecno.\the\subsubsecno}% } -% normally unnumberedsubsubseczzz: -\outer\parseargdef\unnumberedsubsubsec{\unnmhead3{#1}} +\outer\parseargdef\unnumberedsubsubsec{\unnmhead3{#1}} %normally unnumberedsubsubseczzz \def\unnumberedsubsubseczzz#1{% \global\advance\subsubsecno by 1 \sectionheading{#1}{subsubsec}{Ynothing}% @@ -5551,6 +4288,7 @@ % 3) Likewise, headings look best if no \parindent is used, and % if justification is not attempted. Hence \raggedright. + \def\majorheading{% {\advance\chapheadingskip by 10pt \chapbreak }% \parsearg\chapheadingzzz @@ -5559,8 +4297,8 @@ \def\chapheading{\chapbreak \parsearg\chapheadingzzz} \def\chapheadingzzz#1{% {\chapfonts \vbox{\hyphenpenalty=10000\tolerance=5000 - \parindent=0pt\ptexraggedright - \rmisbold #1\hfill}}% + \parindent=0pt\raggedright + \rm #1\hfill}}% \bigskip \par\penalty 200\relax \suppressfirstparagraphindent } @@ -5577,28 +4315,17 @@ % (including whitespace, linebreaking, etc. around it), % given all the information in convenient, parsed form. -% Args are the skip and penalty (usually negative) +%%% Args are the skip and penalty (usually negative) \def\dobreak#1#2{\par\ifdim\lastskip<#1\removelastskip\penalty#2\vskip#1\fi} +%%% Define plain chapter starts, and page on/off switching for it % Parameter controlling skip before chapter headings (if needed) + \newskip\chapheadingskip -% Define plain chapter starts, and page on/off switching for it. \def\chapbreak{\dobreak \chapheadingskip {-4000}} \def\chappager{\par\vfill\supereject} -% Because \domark is called before \chapoddpage, the filler page will -% get the headings for the next chapter, which is wrong. But we don't -% care -- we just disable all headings on the filler page. -\def\chapoddpage{% - \chappager - \ifodd\pageno \else - \begingroup - \headingsoff - \null - \chappager - \endgroup - \fi -} +\def\chapoddpage{\chappager \ifodd\pageno \else \hbox to 0pt{} \chappager\fi} \def\setchapternewpage #1 {\csname CHAPPAG#1\endcsname} @@ -5632,78 +4359,41 @@ \def\Yappendixkeyword{Yappendix} % \def\chapmacro#1#2#3{% - % Insert the first mark before the heading break (see notes for \domark). - \let\prevchapterdefs=\lastchapterdefs - \let\prevsectiondefs=\lastsectiondefs - \gdef\lastsectiondefs{\gdef\thissectionname{}\gdef\thissectionnum{}% - \gdef\thissection{}}% - % - \def\temptype{#2}% - \ifx\temptype\Ynothingkeyword - \gdef\lastchapterdefs{\gdef\thischaptername{#1}\gdef\thischapternum{}% - \gdef\thischapter{\thischaptername}}% - \else\ifx\temptype\Yomitfromtockeyword - \gdef\lastchapterdefs{\gdef\thischaptername{#1}\gdef\thischapternum{}% - \gdef\thischapter{}}% - \else\ifx\temptype\Yappendixkeyword - \toks0={#1}% - \xdef\lastchapterdefs{% - \gdef\noexpand\thischaptername{\the\toks0}% - \gdef\noexpand\thischapternum{\appendixletter}% - % \noexpand\putwordAppendix avoids expanding indigestible - % commands in some of the translations. - \gdef\noexpand\thischapter{\noexpand\putwordAppendix{} - \noexpand\thischapternum: - \noexpand\thischaptername}% - }% - \else - \toks0={#1}% - \xdef\lastchapterdefs{% - \gdef\noexpand\thischaptername{\the\toks0}% - \gdef\noexpand\thischapternum{\the\chapno}% - % \noexpand\putwordChapter avoids expanding indigestible - % commands in some of the translations. - \gdef\noexpand\thischapter{\noexpand\putwordChapter{} - \noexpand\thischapternum: - \noexpand\thischaptername}% - }% - \fi\fi\fi - % - % Output the mark. Pass it through \safewhatsit, to take care of - % the preceding space. - \safewhatsit\domark - % - % Insert the chapter heading break. \pchapsepmacro - % - % Now the second mark, after the heading break. No break points - % between here and the heading. - \let\prevchapterdefs=\lastchapterdefs - \let\prevsectiondefs=\lastsectiondefs - \domark - % {% - \chapfonts \rmisbold + \chapfonts \rm % - % Have to define \lastsection before calling \donoderef, because the + % Have to define \thissection before calling \donoderef, because the % xref code eventually uses it. On the other hand, it has to be called % after \pchapsepmacro, or the headline will change too soon. - \gdef\lastsection{#1}% + \gdef\thissection{#1}% + \gdef\thischaptername{#1}% % % Only insert the separating space if we have a chapter/appendix % number, and don't print the unnumbered ``number''. + \def\temptype{#2}% \ifx\temptype\Ynothingkeyword \setbox0 = \hbox{}% \def\toctype{unnchap}% + \gdef\thischapter{#1}% \else\ifx\temptype\Yomitfromtockeyword \setbox0 = \hbox{}% contents like unnumbered, but no toc entry \def\toctype{omit}% + \gdef\thischapter{}% \else\ifx\temptype\Yappendixkeyword \setbox0 = \hbox{\putwordAppendix{} #3\enspace}% \def\toctype{app}% + % We don't substitute the actual chapter name into \thischapter + % because we don't want its macros evaluated now. And we don't + % use \thissection because that changes with each section. + % + \xdef\thischapter{\putwordAppendix{} \appendixletter: + \noexpand\thischaptername}% \else \setbox0 = \hbox{#3\enspace}% \def\toctype{numchap}% + \xdef\thischapter{\putwordChapter{} \the\chapno: + \noexpand\thischaptername}% \fi\fi\fi % % Write the toc entry for this chapter. Must come before the @@ -5719,8 +4409,7 @@ \donoderef{#2}% % % Typeset the actual heading. - \nobreak % Avoid page breaks at the interline glue. - \vbox{\hyphenpenalty=10000 \tolerance=5000 \parindent=0pt \ptexraggedright + \vbox{\hyphenpenalty=10000 \tolerance=5000 \parindent=0pt \raggedright \hangindent=\wd0 \centerparametersmaybe \unhbox0 #1\par}% }% @@ -5744,8 +4433,8 @@ % \def\unnchfopen #1{% \chapoddpage {\chapfonts \vbox{\hyphenpenalty=10000\tolerance=5000 - \parindent=0pt\ptexraggedright - \rmisbold #1\hfill}}\bigskip \par\nobreak + \parindent=0pt\raggedright + \rm #1\hfill}}\bigskip \par\nobreak } \def\chfopen #1#2{\chapoddpage {\chapfonts \vbox to 3in{\vfil \hbox to\hsize{\hfil #2} \hbox to\hsize{\hfil #1} \vfil}}% @@ -5754,7 +4443,7 @@ \def\centerchfopen #1{% \chapoddpage {\chapfonts \vbox{\hyphenpenalty=10000\tolerance=5000 \parindent=0pt - \hfill {\rmisbold #1}\hfill}}\bigskip \par\nobreak + \hfill {\rm #1}\hfill}}\bigskip \par\nobreak } \def\CHAPFopen{% \global\let\chapmacro=\chfopen @@ -5782,110 +4471,47 @@ % the section type for xrefs (Ynumbered, Ynothing, Yappendix), #4 is the % section number. % -\def\seckeyword{sec} -% \def\sectionheading#1#2#3#4{% {% - \checkenv{}% should not be in an environment. - % % Switch to the right set of fonts. - \csname #2fonts\endcsname \rmisbold - % - \def\sectionlevel{#2}% - \def\temptype{#3}% - % - % Insert first mark before the heading break (see notes for \domark). - \let\prevsectiondefs=\lastsectiondefs - \ifx\temptype\Ynothingkeyword - \ifx\sectionlevel\seckeyword - \gdef\lastsectiondefs{\gdef\thissectionname{#1}\gdef\thissectionnum{}% - \gdef\thissection{\thissectionname}}% - \fi - \else\ifx\temptype\Yomitfromtockeyword - % Don't redefine \thissection. - \else\ifx\temptype\Yappendixkeyword - \ifx\sectionlevel\seckeyword - \toks0={#1}% - \xdef\lastsectiondefs{% - \gdef\noexpand\thissectionname{\the\toks0}% - \gdef\noexpand\thissectionnum{#4}% - % \noexpand\putwordSection avoids expanding indigestible - % commands in some of the translations. - \gdef\noexpand\thissection{\noexpand\putwordSection{} - \noexpand\thissectionnum: - \noexpand\thissectionname}% - }% - \fi - \else - \ifx\sectionlevel\seckeyword - \toks0={#1}% - \xdef\lastsectiondefs{% - \gdef\noexpand\thissectionname{\the\toks0}% - \gdef\noexpand\thissectionnum{#4}% - % \noexpand\putwordSection avoids expanding indigestible - % commands in some of the translations. - \gdef\noexpand\thissection{\noexpand\putwordSection{} - \noexpand\thissectionnum: - \noexpand\thissectionname}% - }% - \fi - \fi\fi\fi - % - % Go into vertical mode. Usually we'll already be there, but we - % don't want the following whatsit to end up in a preceding paragraph - % if the document didn't happen to have a blank line. - \par - % - % Output the mark. Pass it through \safewhatsit, to take care of - % the preceding space. - \safewhatsit\domark + \csname #2fonts\endcsname \rm % % Insert space above the heading. \csname #2headingbreak\endcsname % - % Now the second mark, after the heading break. No break points - % between here and the heading. - \let\prevsectiondefs=\lastsectiondefs - \domark + % Only insert the space after the number if we have a section number. + \def\sectionlevel{#2}% + \def\temptype{#3}% % - % Only insert the space after the number if we have a section number. \ifx\temptype\Ynothingkeyword \setbox0 = \hbox{}% \def\toctype{unn}% - \gdef\lastsection{#1}% + \gdef\thissection{#1}% \else\ifx\temptype\Yomitfromtockeyword % for @headings -- no section number, don't include in toc, - % and don't redefine \lastsection. + % and don't redefine \thissection. \setbox0 = \hbox{}% \def\toctype{omit}% \let\sectionlevel=\empty \else\ifx\temptype\Yappendixkeyword \setbox0 = \hbox{#4\enspace}% \def\toctype{app}% - \gdef\lastsection{#1}% + \gdef\thissection{#1}% \else \setbox0 = \hbox{#4\enspace}% \def\toctype{num}% - \gdef\lastsection{#1}% + \gdef\thissection{#1}% \fi\fi\fi % - % Write the toc entry (before \donoderef). See comments in \chapmacro. + % Write the toc entry (before \donoderef). See comments in \chfplain. \writetocentry{\toctype\sectionlevel}{#1}{#4}% % % Write the node reference (= pdf destination for pdftex). - % Again, see comments in \chapmacro. + % Again, see comments in \chfplain. \donoderef{#3}% % - % Interline glue will be inserted when the vbox is completed. - % That glue will be a valid breakpoint for the page, since it'll be - % preceded by a whatsit (usually from the \donoderef, or from the - % \writetocentry if there was no node). We don't want to allow that - % break, since then the whatsits could end up on page n while the - % section is on page n+1, thus toc/etc. are wrong. Debian bug 276000. - \nobreak - % % Output the actual section heading. - \vbox{\hyphenpenalty=10000 \tolerance=5000 \parindent=0pt \ptexraggedright + \vbox{\hyphenpenalty=10000 \tolerance=5000 \parindent=0pt \raggedright \hangindent=\wd0 % zero if no section number \unhbox0 #1}% }% @@ -5899,15 +4525,15 @@ % % We'll almost certainly start a paragraph next, so don't let that % glue accumulate. (Not a breakpoint because it's preceded by a - % discardable item.) However, when a paragraph is not started next - % (\startdefun, \cartouche, \center, etc.), this needs to be wiped out - % or the negative glue will cause weirdly wrong output, typically - % obscuring the section heading with something else. + % discardable item.) \vskip-\parskip - % - % This is so the last item on the main vertical list is a known - % \penalty > 10000, so \startdefun, etc., can recognize the situation - % and do the needful. + % + % This is purely so the last item on the list is a known \penalty > + % 10000. This is so \startdefun can avoid allowing breakpoints after + % section headings. Otherwise, it would insert a valid breakpoint between: + % + % @section sec-whatever + % @deffn def-whatever \penalty 10001 } @@ -5946,7 +4572,7 @@ \edef\temp{% \write\tocfile{@#1entry{#2}{#3}{\lastnode}{\noexpand\folio}}}% \temp - }% + } \fi \fi % @@ -5963,7 +4589,7 @@ % These characters do not print properly in the Computer Modern roman % fonts, so we must take special care. This is more or less redundant % with the Texinfo input format setup at the end of this file. -% +% \def\activecatcodes{% \catcode`\"=\active \catcode`\$=\active @@ -5981,7 +4607,7 @@ \def\readtocfile{% \setupdatafile \activecatcodes - \input \tocreadfilename + \input \jobname.toc } \newskip\contentsrightmargin \contentsrightmargin=1in @@ -6000,6 +4626,7 @@ % % Don't need to put `Contents' or `Short Contents' in the headline. % It is abundantly clear what they are. + \def\thischapter{}% \chapmacro{#1}{Yomitfromtoc}{}% % \savepageno = \pageno @@ -6011,16 +4638,11 @@ \ifnum \pageno>0 \global\pageno = \lastnegativepageno \fi } -% redefined for the two-volume lispref. We always output on -% \jobname.toc even if this is redefined. -% -\def\tocreadfilename{\jobname.toc} % Normal (long) toc. -% \def\contents{% \startcontents{\putwordTOC}% - \openin 1 \tocreadfilename\space + \openin 1 \jobname.toc \ifeof 1 \else \readtocfile \fi @@ -6039,7 +4661,6 @@ \def\summarycontents{% \startcontents{\putwordShortTOC}% % - \let\partentry = \shortpartentry \let\numchapentry = \shortchapentry \let\appentry = \shortchapentry \let\unnchapentry = \shortunnchapentry @@ -6059,7 +4680,7 @@ \let\numsubsubsecentry = \numsecentry \let\appsubsubsecentry = \numsecentry \let\unnsubsubsecentry = \numsecentry - \openin 1 \tocreadfilename\space + \openin 1 \jobname.toc \ifeof 1 \else \readtocfile \fi @@ -6095,19 +4716,6 @@ % The last argument is the page number. % The arguments in between are the chapter number, section number, ... -% Parts, in the main contents. Replace the part number, which doesn't -% exist, with an empty box. Let's hope all the numbers have the same width. -% Also ignore the page number, which is conventionally not printed. -\def\numeralbox{\setbox0=\hbox{8}\hbox to \wd0{\hfil}} -\def\partentry#1#2#3#4{\dochapentry{\numeralbox\labelspace#1}{}} -% -% Parts, in the short toc. -\def\shortpartentry#1#2#3#4{% - \penalty-300 - \vskip.5\baselineskip plus.15\baselineskip minus.1\baselineskip - \shortchapentry{{\bf #1}}{\numeralbox}{}{}% -} - % Chapters, in the main contents. \def\numchapentry#1#2#3#4{\dochapentry{#2\labelspace#1}{#4}} % @@ -6197,12 +4805,45 @@ \message{environments,} % @foo ... @end foo. -% @tex ... @end tex escapes into raw TeX temporarily. +% @point{}, @result{}, @expansion{}, @print{}, @equiv{}. +% +% Since these characters are used in examples, it should be an even number of +% \tt widths. Each \tt character is 1en, so two makes it 1em. +% +\def\point{$\star$} +\def\result{\leavevmode\raise.15ex\hbox to 1em{\hfil$\Rightarrow$\hfil}} +\def\expansion{\leavevmode\raise.1ex\hbox to 1em{\hfil$\mapsto$\hfil}} +\def\print{\leavevmode\lower.1ex\hbox to 1em{\hfil$\dashv$\hfil}} +\def\equiv{\leavevmode\lower.1ex\hbox to 1em{\hfil$\ptexequiv$\hfil}} + +% The @error{} command. +% Adapted from the TeXbook's \boxit. +% +\newbox\errorbox +% +{\tentt \global\dimen0 = 3em}% Width of the box. +\dimen2 = .55pt % Thickness of rules +% The text. (`r' is open on the right, `e' somewhat less so on the left.) +\setbox0 = \hbox{\kern-.75pt \tensf error\kern-1.5pt} +% +\setbox\errorbox=\hbox to \dimen0{\hfil + \hsize = \dimen0 \advance\hsize by -5.8pt % Space to left+right. + \advance\hsize by -2\dimen2 % Rules. + \vbox{% + \hrule height\dimen2 + \hbox{\vrule width\dimen2 \kern3pt % Space to left of text. + \vtop{\kern2.4pt \box0 \kern2.4pt}% Space above/below. + \kern3pt\vrule width\dimen2}% Space to right. + \hrule height\dimen2} + \hfil} +% +\def\error{\leavevmode\lower.7ex\copy\errorbox} + +% @tex ... @end tex escapes into raw Tex temporarily. % One exception: @ is still an escape character, so that @end tex works. -% But \@ or @@ will get a plain @ character. +% But \@ or @@ will get a plain tex @ character. \envdef\tex{% - \setupmarkupstyle{tex}% \catcode `\\=0 \catcode `\{=1 \catcode `\}=2 \catcode `\$=3 \catcode `\&=4 \catcode `\#=6 \catcode `\^=7 \catcode `\_=8 \catcode `\~=\active \let~=\tie @@ -6212,14 +4853,8 @@ \catcode `\|=\other \catcode `\<=\other \catcode `\>=\other - \catcode`\`=\other - \catcode`\'=\other \escapechar=`\\ % - % ' is active in math mode (mathcode"8000). So reset it, and all our - % other math active characters (just in case), to plain's definitions. - \mathactive - % \let\b=\ptexb \let\bullet=\ptexbullet \let\c=\ptexc @@ -6237,7 +4872,6 @@ \let\/=\ptexslash \let\*=\ptexstar \let\t=\ptext - \expandafter \let\csname top\endcsname=\ptextop % outer \let\frenchspacing=\plainfrenchspacing % \def\endldots{\mathinner{\ldots\ldots\ldots\ldots}}% @@ -6323,12 +4957,6 @@ \normbskip=\baselineskip \normpskip=\parskip \normlskip=\lineskip % Flag to tell @lisp, etc., not to narrow margin. \let\nonarrowing = t% - % - % If this cartouche directly follows a sectioning command, we need the - % \parskip glue (backspaced over by default) or the cartouche can - % collide with the section heading. - \ifnum\lastpenalty>10000 \vskip\parskip \penalty\lastpenalty \fi - % \vbox\bgroup \baselineskip=0pt\parskip=0pt\lineskip=0pt \carttop @@ -6342,7 +4970,7 @@ \lineskip=\normlskip \parskip=\normpskip \vskip -\parskip - \comment % For explanation, see the end of def\group. + \comment % For explanation, see the end of \def\group. } \def\Ecartouche{% \ifhmode\par\fi @@ -6359,7 +4987,6 @@ % This macro is called at the beginning of all the @example variants, % inside a group. -\newdimen\nonfillparindent \def\nonfillstart{% \aboveenvbreak \hfuzz = 12pt % Don't be fussy @@ -6367,12 +4994,7 @@ \let\par = \lisppar % don't ignore blank lines \obeylines % each line of input is a line of output \parskip = 0pt - % Turn off paragraph indentation but redefine \indent to emulate - % the normal \indent. - \nonfillparindent=\parindent \parindent = 0pt - \let\indent\nonfillindent - % \emergencystretch = 0pt % don't try to avoid overfull boxes \ifx\nonarrowing\relax \advance \leftskip by \lispnarrowing @@ -6383,24 +5005,6 @@ \let\exdent=\nofillexdent } -\begingroup -\obeyspaces -% We want to swallow spaces (but not other tokens) after the fake -% @indent in our nonfill-environments, where spaces are normally -% active and set to @tie, resulting in them not being ignored after -% @indent. -\gdef\nonfillindent{\futurelet\temp\nonfillindentcheck}% -\gdef\nonfillindentcheck{% -\ifx\temp % -\expandafter\nonfillindentgobble% -\else% -\leavevmode\nonfillindentbox% -\fi% -}% -\endgroup -\def\nonfillindentgobble#1{\nonfillindent} -\def\nonfillindentbox{\hbox to \nonfillparindent{\hss}} - % If you want all examples etc. small: @set dispenvsize small. % If you want even small examples the full size: @set dispenvsize nosmall. % This affects the following displayed environments: @@ -6411,59 +5015,53 @@ \let\SETdispenvsize\relax \def\setnormaldispenv{% \ifx\SETdispenvsize\smallword - % end paragraph for sake of leading, in case document has no blank - % line. This is redundant with what happens in \aboveenvbreak, but - % we need to do it before changing the fonts, and it's inconvenient - % to change the fonts afterward. - \ifnum \lastpenalty=10000 \else \endgraf \fi \smallexamplefonts \rm \fi } \def\setsmalldispenv{% \ifx\SETdispenvsize\nosmallword \else - \ifnum \lastpenalty=10000 \else \endgraf \fi \smallexamplefonts \rm \fi } % We often define two environments, @foo and @smallfoo. -% Let's do it in one command. #1 is the env name, #2 the definition. -\def\makedispenvdef#1#2{% - \expandafter\envdef\csname#1\endcsname {\setnormaldispenv #2}% - \expandafter\envdef\csname small#1\endcsname {\setsmalldispenv #2}% +% Let's do it by one command: +\def\makedispenv #1#2{ + \expandafter\envdef\csname#1\endcsname {\setnormaldispenv #2} + \expandafter\envdef\csname small#1\endcsname {\setsmalldispenv #2} \expandafter\let\csname E#1\endcsname \afterenvbreak \expandafter\let\csname Esmall#1\endcsname \afterenvbreak } -% Define two environment synonyms (#1 and #2) for an environment. -\def\maketwodispenvdef#1#2#3{% - \makedispenvdef{#1}{#3}% - \makedispenvdef{#2}{#3}% -} -% -% @lisp: indented, narrowed, typewriter font; -% @example: same as @lisp. +% Define two synonyms: +\def\maketwodispenvs #1#2#3{ + \makedispenv{#1}{#3} + \makedispenv{#2}{#3} +} + +% @lisp: indented, narrowed, typewriter font; @example: same as @lisp. % % @smallexample and @smalllisp: use smaller fonts. % Originally contributed by Pavel@xerox. % -\maketwodispenvdef{lisp}{example}{% +\maketwodispenvs {lisp}{example}{% \nonfillstart - \tt\setupmarkupstyle{example}% + \tt \let\kbdfont = \kbdexamplefont % Allow @kbd to do something special. - \gobble % eat return -} + \gobble % eat return +} + % @display/@smalldisplay: same as @lisp except keep current font. % -\makedispenvdef{display}{% +\makedispenv {display}{% \nonfillstart \gobble } % @format/@smallformat: same as @display except don't narrow margins. % -\makedispenvdef{format}{% +\makedispenv{format}{% \let\nonarrowing = t% \nonfillstart \gobble @@ -6482,44 +5080,18 @@ \envdef\flushright{% \let\nonarrowing = t% \nonfillstart - \advance\leftskip by 0pt plus 1fill\relax + \advance\leftskip by 0pt plus 1fill \gobble } \let\Eflushright = \afterenvbreak -% @raggedright does more-or-less normal line breaking but no right -% justification. From plain.tex. -\envdef\raggedright{% - \rightskip0pt plus2em \spaceskip.3333em \xspaceskip.5em\relax -} -\let\Eraggedright\par - -\envdef\raggedleft{% - \parindent=0pt \leftskip0pt plus2em - \spaceskip.3333em \xspaceskip.5em \parfillskip=0pt - \hbadness=10000 % Last line will usually be underfull, so turn off - % badness reporting. -} -\let\Eraggedleft\par - -\envdef\raggedcenter{% - \parindent=0pt \rightskip0pt plus1em \leftskip0pt plus1em - \spaceskip.3333em \xspaceskip.5em \parfillskip=0pt - \hbadness=10000 % Last line will usually be underfull, so turn off - % badness reporting. -} -\let\Eraggedcenter\par - - % @quotation does normal linebreaking (hence we can't use \nonfillstart) % and narrows the margins. We keep \parskip nonzero in general, since % we're doing normal filling. So, when using \aboveenvbreak and % \afterenvbreak, temporarily make \parskip 0. % -\makedispenvdef{quotation}{\quotationstart} -% -\def\quotationstart{% +\envdef\quotation{% {\parskip=0pt \aboveenvbreak}% because \aboveenvbreak inserts \parskip \parindent=0pt % @@ -6539,13 +5111,12 @@ % \def\Equotation{% \par - \ifx\quotationauthor\thisisundefined\else + \ifx\quotationauthor\undefined\else % indent a bit. \leftline{\kern 2\leftskip \sl ---\quotationauthor}% \fi {\parskip=0pt \afterenvbreak}% } -\def\Esmallquotation{\Equotation} % If we're given an argument, typeset it in bold with a colon after. \def\quotationlabel#1{% @@ -6570,16 +5141,18 @@ \do\ \do\\\do\{\do\}\do\$\do\&% \do\#\do\^\do\^^K\do\_\do\^^A\do\%\do\~% \do\<\do\>\do\|\do\@\do+\do\"% - % Don't do the quotes -- if we do, @set txicodequoteundirected and - % @set txicodequotebacktick will not have effect on @verb and - % @verbatim, and ?` and !` ligatures won't get disabled. - %\do\`\do\'% } % % [Knuth] p. 380 \def\uncatcodespecials{% \def\do##1{\catcode`##1=\other}\dospecials} % +% [Knuth] pp. 380,381,391 +% Disable Spanish ligatures ?` and !` of \tt font +\begingroup + \catcode`\`=\active\gdef`{\relax\lq} +\endgroup +% % Setup for the @verb command. % % Eight spaces for a tab @@ -6591,7 +5164,7 @@ \def\setupverb{% \tt % easiest (and conventionally used) font for verbatim \def\par{\leavevmode\endgraf}% - \setupmarkupstyle{verb}% + \catcode`\`=\active \tabeightspaces % Respect line breaks, % print special symbols as themselves, and @@ -6602,46 +5175,35 @@ % Setup for the @verbatim environment % -% Real tab expansion. +% Real tab expansion \newdimen\tabw \setbox0=\hbox{\tt\space} \tabw=8\wd0 % tab amount % -% We typeset each line of the verbatim in an \hbox, so we can handle -% tabs. The \global is in case the verbatim line starts with an accent, -% or some other command that starts with a begin-group. Otherwise, the -% entire \verbbox would disappear at the corresponding end-group, before -% it is typeset. Meanwhile, we can't have nested verbatim commands -% (can we?), so the \global won't be overwriting itself. -\newbox\verbbox -\def\starttabbox{\global\setbox\verbbox=\hbox\bgroup} -% +\def\starttabbox{\setbox0=\hbox\bgroup} \begingroup \catcode`\^^I=\active \gdef\tabexpand{% \catcode`\^^I=\active \def^^I{\leavevmode\egroup - \dimen\verbbox=\wd\verbbox % the width so far, or since the previous tab - \divide\dimen\verbbox by\tabw - \multiply\dimen\verbbox by\tabw % compute previous multiple of \tabw - \advance\dimen\verbbox by\tabw % advance to next multiple of \tabw - \wd\verbbox=\dimen\verbbox \box\verbbox \starttabbox + \dimen0=\wd0 % the width so far, or since the previous tab + \divide\dimen0 by\tabw + \multiply\dimen0 by\tabw % compute previous multiple of \tabw + \advance\dimen0 by\tabw % advance to next multiple of \tabw + \wd0=\dimen0 \box0 \starttabbox }% } \endgroup - -% start the verbatim environment. \def\setupverbatim{% \let\nonarrowing = t% \nonfillstart - \tt % easiest (and conventionally used) font for verbatim - % The \leavevmode here is for blank lines. Otherwise, we would - % never \starttabox and the \egroup would end verbatim mode. - \def\par{\leavevmode\egroup\box\verbbox\endgraf}% + % Easiest (and conventionally used) font for verbatim + \tt + \def\par{\leavevmode\egroup\box0\endgraf}% + \catcode`\`=\active \tabexpand - \setupmarkupstyle{verbatim}% % Respect line breaks, % print special symbols as themselves, and - % make each space count. - % Must do in this order: + % make each space count + % must do in this order: \obeylines \uncatcodespecials \sepspaces \everypar{\starttabbox}% } @@ -6697,8 +5259,6 @@ {% \makevalueexpandable \setupverbatim - \indexnofonts % Allow `@@' and other weird things in file names. - \wlog{texinfo.tex: doing @verbatiminclude of #1^^J}% \input #1 \afterenvbreak }% @@ -6724,35 +5284,27 @@ \endgroup } - \message{defuns,} % @defun etc. \newskip\defbodyindent \defbodyindent=.4in \newskip\defargsindent \defargsindent=50pt \newskip\deflastargmargin \deflastargmargin=18pt -\newcount\defunpenalty % Start the processing of @deffn: \def\startdefun{% \ifnum\lastpenalty<10000 \medbreak - \defunpenalty=10003 % Will keep this @deffn together with the - % following @def command, see below. \else % If there are two @def commands in a row, we'll have a \nobreak, % which is there to keep the function description together with its % header. But if there's nothing but headers, we need to allow a % break somewhere. Check specifically for penalty 10002, inserted - % by \printdefunline, instead of 10000, since the sectioning + % by \defargscommonending, instead of 10000, since the sectioning % commands also insert a nobreak penalty, and we don't want to allow % a break between a section heading and a defun. - % - % As a further refinement, we avoid "club" headers by signalling - % with penalty of 10003 after the very first @deffn in the - % sequence (see above), and penalty of 10002 after any following - % @def command. - \ifnum\lastpenalty=10002 \penalty2000 \else \defunpenalty=10002 \fi + % + \ifnum\lastpenalty=10002 \penalty2000 \fi % % Similarly, after a section heading, do not allow a break. % But do insert the glue. @@ -6770,7 +5322,7 @@ % % As above, allow line break if we have multiple x headers in a row. % It's not a great place, though. - \ifnum\lastpenalty=10002 \penalty3000 \else \defunpenalty=10002 \fi + \ifnum\lastpenalty=10002 \penalty3000 \fi % % And now, it's time to reuse the body of the original defun: \expandafter\gobbledefun#1% @@ -6785,10 +5337,10 @@ #1#2 \endheader % common ending: \interlinepenalty = 10000 - \advance\rightskip by 0pt plus 1fil\relax + \advance\rightskip by 0pt plus 1fil \endgraf \nobreak\vskip -\parskip - \penalty\defunpenalty % signal to \startdefun and \dodefunx + \penalty 10002 % signal to \startdefun and \dodefunx % Some of the @defun-type tags do not enable magic parentheses, % rendering the following check redundant. But we don't optimize. \checkparencounts @@ -6798,7 +5350,7 @@ \def\Edefun{\endgraf\medbreak} % \makedefun{deffn} creates \deffn, \deffnx and \Edeffn; -% the only thing remaining is to define \deffnheader. +% the only thing remainnig is to define \deffnheader. % \def\makedefun#1{% \expandafter\let\csname E#1\endcsname = \Edefun @@ -6815,36 +5367,13 @@ \def\domakedefun#1#2#3{% \envdef#1{% \startdefun - \doingtypefnfalse % distinguish typed functions from all else \parseargusing\activeparens{\printdefunline#3}% }% \def#2{\dodefunx#1}% \def#3% } -\newif\ifdoingtypefn % doing typed function? -\newif\ifrettypeownline % typeset return type on its own line? - -% @deftypefnnewline on|off says whether the return type of typed functions -% are printed on their own line. This affects @deftypefn, @deftypefun, -% @deftypeop, and @deftypemethod. -% -\parseargdef\deftypefnnewline{% - \def\temp{#1}% - \ifx\temp\onword - \expandafter\let\csname SETtxideftypefnnl\endcsname - = \empty - \else\ifx\temp\offword - \expandafter\let\csname SETtxideftypefnnl\endcsname - = \relax - \else - \errhelp = \EMsimple - \errmessage{Unknown @txideftypefnnl value `\temp', - must be on|off}% - \fi\fi -} - -% Untyped functions: +%%% Untyped functions: % @deffn category name args \makedefun{deffn}{\deffngeneral{}} @@ -6863,7 +5392,7 @@ \defname{#2}{}{#3}\magicamp\defunargs{#4\unskip}% } -% Typed functions: +%%% Typed functions: % @deftypefn category type name args \makedefun{deftypefn}{\deftypefngeneral{}} @@ -6878,11 +5407,10 @@ % \def\deftypefngeneral#1#2 #3 #4 #5\endheader{% \dosubind{fn}{\code{#4}}{#1}% - \doingtypefntrue \defname{#2}{#3}{#4}\defunargs{#5\unskip}% } -% Typed variables: +%%% Typed variables: % @deftypevr category type var args \makedefun{deftypevr}{\deftypecvgeneral{}} @@ -6900,7 +5428,7 @@ \defname{#2}{#3}{#4}\defunargs{#5\unskip}% } -% Untyped variables: +%%% Untyped variables: % @defvr category var args \makedefun{defvr}#1 {\deftypevrheader{#1} {} } @@ -6911,8 +5439,7 @@ % \defcvof {category of}class var args \def\defcvof#1#2 {\deftypecvof{#1}#2 {} } -% Types: - +%%% Type: % @deftp category name args \makedefun{deftp}#1 #2 #3\endheader{% \doind{tp}{\code{#2}}% @@ -6940,49 +5467,25 @@ % We are followed by (but not passed) the arguments, if any. % \def\defname#1#2#3{% - \par % Get the values of \leftskip and \rightskip as they were outside the @def... \advance\leftskip by -\defbodyindent % - % Determine if we are typesetting the return type of a typed function - % on a line by itself. - \rettypeownlinefalse - \ifdoingtypefn % doing a typed function specifically? - % then check user option for putting return type on its own line: - \expandafter\ifx\csname SETtxideftypefnnl\endcsname\relax \else - \rettypeownlinetrue - \fi - \fi - % - % How we'll format the category name. Putting it in brackets helps + % How we'll format the type name. Putting it in brackets helps % distinguish it from the body text that may end up on the next line % just below it. \def\temp{#1}% \setbox0=\hbox{\kern\deflastargmargin \ifx\temp\empty\else [\rm\temp]\fi} % - % Figure out line sizes for the paragraph shape. We'll always have at - % least two. - \tempnum = 2 - % + % Figure out line sizes for the paragraph shape. % The first line needs space for \box0; but if \rightskip is nonzero, % we need only space for the part of \box0 which exceeds it: \dimen0=\hsize \advance\dimen0 by -\wd0 \advance\dimen0 by \rightskip - % - % If doing a return type on its own line, we'll have another line. - \ifrettypeownline - \advance\tempnum by 1 - \def\maybeshapeline{0in \hsize}% - \else - \def\maybeshapeline{}% - \fi - % % The continuations: \dimen2=\hsize \advance\dimen2 by -\defargsindent - % - % The final paragraph shape: - \parshape \tempnum 0in \dimen0 \maybeshapeline \defargsindent \dimen2 - % - % Put the category name at the right margin. + % (plain.tex says that \dimen1 should be used only as global.) + \parshape 2 0in \dimen0 \defargsindent \dimen2 + % + % Put the type name to the right margin. \noindent \hbox to 0pt{% \hfil\box0 \kern-\hsize @@ -7004,16 +5507,8 @@ % . this still does not fix the ?` and !` ligatures, but so far no % one has made identifiers using them :). \df \tt - \def\temp{#2}% text of the return type - \ifx\temp\empty\else - \tclose{\temp}% typeset the return type - \ifrettypeownline - % put return type on its own line; prohibit line break following: - \hfil\vadjust{\nobreak}\break - \else - \space % type on same line, so just followed by a space - \fi - \fi % no return type + \def\temp{#2}% return value type + \ifx\temp\empty\else \tclose{\temp} \fi #3% output function name }% {\rm\enskip}% hskip 0.5 em of \tenrm @@ -7034,7 +5529,7 @@ % % On the other hand, if an argument has two dashes (for instance), we % want a way to get ttsl. Let's try @var for that. - \def\var##1{{\setupmarkupstyle{var}\ttslanted{##1}}}% + \let\var=\ttslanted #1% \sl\hyphenchar\font=45 } @@ -7114,14 +5609,12 @@ \ifnum\parencount=0 \else \badparencount \fi \ifnum\brackcount=0 \else \badbrackcount \fi } -% these should not use \errmessage; the glibc manual, at least, actually -% has such constructs (when documenting function pointers). \def\badparencount{% - \message{Warning: unbalanced parentheses in @def...}% + \errmessage{Unbalanced parentheses in @def}% \global\parencount=0 } \def\badbrackcount{% - \message{Warning: unbalanced square brackets in @def...}% + \errmessage{Unbalanced square braces in @def}% \global\brackcount=0 } @@ -7131,7 +5624,7 @@ % To do this right we need a feature of e-TeX, \scantokens, % which we arrange to emulate with a temporary file in ordinary TeX. -\ifx\eTeXversion\thisisundefined +\ifx\eTeXversion\undefined \newwrite\macscribble \def\scantokens#1{% \toks0={#1}% @@ -7142,30 +5635,26 @@ } \fi -\def\scanmacro#1{\begingroup - \newlinechar`\^^M - \let\xeatspaces\eatspaces - % - % Undo catcode changes of \startcontents and \doprintindex - % When called from @insertcopying or (short)caption, we need active - % backslash to get it printed correctly. Previously, we had - % \catcode`\\=\other instead. We'll see whether a problem appears - % with macro expansion. --kasal, 19aug04 - \catcode`\@=0 \catcode`\\=\active \escapechar=`\@ - % - % ... and for \example: - \spaceisspace - % - % The \empty here causes a following catcode 5 newline to be eaten as - % part of reading whitespace after a control sequence. It does not - % eat a catcode 13 newline. There's no good way to handle the two - % cases (untried: maybe e-TeX's \everyeof could help, though plain TeX - % would then have different behavior). See the Macro Details node in - % the manual for the workaround we recommend for macros and - % line-oriented commands. - % - \scantokens{#1\empty}% -\endgroup} +\def\scanmacro#1{% + \begingroup + \newlinechar`\^^M + \let\xeatspaces\eatspaces + % Undo catcode changes of \startcontents and \doprintindex + % When called from @insertcopying or (short)caption, we need active + % backslash to get it printed correctly. Previously, we had + % \catcode`\\=\other instead. We'll see whether a problem appears + % with macro expansion. --kasal, 19aug04 + \catcode`\@=0 \catcode`\\=\active \escapechar=`\@ + % ... and \example + \spaceisspace + % + % Append \endinput to make sure that TeX does not see the ending newline. + % + % I've verified that it is necessary both for e-TeX and for ordinary TeX + % --kasal, 29nov03 + \scantokens{#1\endinput}% + \endgroup +} \def\scanexp#1{% \edef\temp{\noexpand\scanmacro{#1}}% @@ -7193,7 +5682,7 @@ % This does \let #1 = #2, with \csnames; that is, % \let \csname#1\endcsname = \csname#2\endcsname % (except of course we have to play expansion games). -% +% \def\cslet#1#2{% \expandafter\let \csname#1\expandafter\endcsname @@ -7219,18 +5708,13 @@ % Macro bodies are absorbed as an argument in a context where % all characters are catcode 10, 11 or 12, except \ which is active -% (as in normal texinfo). It is necessary to change the definition of \ -% to recognize macro arguments; this is the job of \mbodybackslash. -% -% Non-ASCII encodings make 8-bit characters active, so un-activate -% them to avoid their expansion. Must do this non-globally, to -% confine the change to the current group. -% +% (as in normal texinfo). It is necessary to change the definition of \. + % It's necessary to have hard CRs when the macro is executed. This is -% done by making ^^M (\endlinechar) catcode 12 when reading the macro +% done by making ^^M (\endlinechar) catcode 12 when reading the macro % body, and then making it the \newlinechar in \scanmacro. -% -\def\scanctxt{% used as subroutine + +\def\scanctxt{% \catcode`\"=\other \catcode`\+=\other \catcode`\<=\other @@ -7240,16 +5724,15 @@ \catcode`\_=\other \catcode`\|=\other \catcode`\~=\other - \ifx\declaredencoding\ascii \else \setnonasciicharscatcodenonglobal\other \fi -} - -\def\scanargctxt{% used for copying and captions, not macros. +} + +\def\scanargctxt{% \scanctxt \catcode`\\=\other \catcode`\^^M=\other } -\def\macrobodyctxt{% used for @macro definitions +\def\macrobodyctxt{% \scanctxt \catcode`\{=\other \catcode`\}=\other @@ -7257,56 +5740,32 @@ \usembodybackslash } -\def\macroargctxt{% used when scanning invocations +\def\macroargctxt{% \scanctxt - \catcode`\\=0 -} -% why catcode 0 for \ in the above? To recognize \\ \{ \} as "escapes" -% for the single characters \ { }. Thus, we end up with the "commands" -% that would be written @\ @{ @} in a Texinfo document. -% -% We already have @{ and @}. For @\, we define it here, and only for -% this purpose, to produce a typewriter backslash (so, the @\ that we -% define for @math can't be used with @macro calls): -% -\def\\{\normalbackslash}% -% -% We would like to do this for \, too, since that is what makeinfo does. -% But it is not possible, because Texinfo already has a command @, for a -% cedilla accent. Documents must use @comma{} instead. -% -% \anythingelse will almost certainly be an error of some kind. - + \catcode`\\=\other +} % \mbodybackslash is the definition of \ in @macro bodies. % It maps \foo\ => \csname macarg.foo\endcsname => #N % where N is the macro parameter number. % We define \csname macarg.\endcsname to be \realbackslash, so % \\ in macro replacement text gets you a backslash. -% + {\catcode`@=0 @catcode`@\=@active @gdef@usembodybackslash{@let\=@mbodybackslash} @gdef@mbodybackslash#1\{@csname macarg.#1@endcsname} } \expandafter\def\csname macarg.\endcsname{\realbackslash} -\def\margbackslash#1{\char`\#1 } - \def\macro{\recursivefalse\parsearg\macroxxx} \def\rmacro{\recursivetrue\parsearg\macroxxx} \def\macroxxx#1{% - \getargs{#1}% now \macname is the macname and \argl the arglist + \getargs{#1}% now \macname is the macname and \argl the arglist \ifx\argl\empty % no arguments - \paramno=0\relax + \paramno=0% \else \expandafter\parsemargdef \argl;% - \if\paramno>256\relax - \ifx\eTeXversion\thisisundefined - \errhelp = \EMsimple - \errmessage{You need eTeX to compile a file with macros with more than 256 arguments} - \fi - \fi \fi \if1\csname ismacro.\the\macname\endcsname \message{Warning: redefining \the\macname}% @@ -7353,269 +5812,46 @@ % an opening brace, and that opening brace is not consumed. \def\getargs#1{\getargsxxx#1{}} \def\getargsxxx#1#{\getmacname #1 \relax\getmacargs} -\def\getmacname#1 #2\relax{\macname={#1}} +\def\getmacname #1 #2\relax{\macname={#1}} \def\getmacargs#1{\def\argl{#1}} -% For macro processing make @ a letter so that we can make Texinfo private macro names. -\edef\texiatcatcode{\the\catcode`\@} -\catcode `@=11\relax - % Parse the optional {params} list. Set up \paramno and \paramlist -% so \defmacro knows what to do. Define \macarg.BLAH for each BLAH -% in the params list to some hook where the argument si to be expanded. If -% there are less than 10 arguments that hook is to be replaced by ##N where N -% is the position in that list, that is to say the macro arguments are to be -% defined `a la TeX in the macro body. -% +% so \defmacro knows what to do. Define \macarg.blah for each blah +% in the params list, to be ##N where N is the position in that list. % That gets used by \mbodybackslash (above). -% + % We need to get `macro parameter char #' into several definitions. -% The technique used is stolen from LaTeX: let \hash be something +% The technique used is stolen from LaTeX: let \hash be something % unexpandable, insert that wherever you need a #, and then redefine % it to # just before using the token list produced. % % The same technique is used to protect \eatspaces till just before % the macro is used. -% -% If there are 10 or more arguments, a different technique is used, where the -% hook remains in the body, and when macro is to be expanded the body is -% processed again to replace the arguments. -% -% In that case, the hook is \the\toks N-1, and we simply set \toks N-1 to the -% argument N value and then \edef the body (nothing else will expand because of -% the catcode regime underwhich the body was input). -% -% If you compile with TeX (not eTeX), and you have macros with 10 or more -% arguments, you need that no macro has more than 256 arguments, otherwise an -% error is produced. -\def\parsemargdef#1;{% - \paramno=0\def\paramlist{}% - \let\hash\relax - \let\xeatspaces\relax - \parsemargdefxxx#1,;,% - % In case that there are 10 or more arguments we parse again the arguments - % list to set new definitions for the \macarg.BLAH macros corresponding to - % each BLAH argument. It was anyhow needed to parse already once this list - % in order to count the arguments, and as macros with at most 9 arguments - % are by far more frequent than macro with 10 or more arguments, defining - % twice the \macarg.BLAH macros does not cost too much processing power. - \ifnum\paramno<10\relax\else - \paramno0\relax - \parsemmanyargdef@@#1,;,% 10 or more arguments - \fi -} + +\def\parsemargdef#1;{\paramno=0\def\paramlist{}% + \let\hash\relax\let\xeatspaces\relax\parsemargdefxxx#1,;,} \def\parsemargdefxxx#1,{% \if#1;\let\next=\relax \else \let\next=\parsemargdefxxx - \advance\paramno by 1 + \advance\paramno by 1% \expandafter\edef\csname macarg.\eatspaces{#1}\endcsname {\xeatspaces{\hash\the\paramno}}% \edef\paramlist{\paramlist\hash\the\paramno,}% \fi\next} -\def\parsemmanyargdef@@#1,{% - \if#1;\let\next=\relax - \else - \let\next=\parsemmanyargdef@@ - \edef\tempb{\eatspaces{#1}}% - \expandafter\def\expandafter\tempa - \expandafter{\csname macarg.\tempb\endcsname}% - % Note that we need some extra \noexpand\noexpand, this is because we - % don't want \the to be expanded in the \parsermacbody as it uses an - % \xdef . - \expandafter\edef\tempa - {\noexpand\noexpand\noexpand\the\toks\the\paramno}% - \advance\paramno by 1\relax - \fi\next} - % These two commands read recursive and nonrecursive macro bodies. % (They're different since rec and nonrec macros end differently.) -% - -\catcode `\@\texiatcatcode + \long\def\parsemacbody#1@end macro% {\xdef\temp{\eatcr{#1}}\endgroup\defmacro}% \long\def\parsermacbody#1@end rmacro% {\xdef\temp{\eatcr{#1}}\endgroup\defmacro}% -\catcode `\@=11\relax - -\let\endargs@\relax -\let\nil@\relax -\def\nilm@{\nil@}% -\long\def\nillm@{\nil@}% - -% This macro is expanded during the Texinfo macro expansion, not during its -% definition. It gets all the arguments values and assigns them to macros -% macarg.ARGNAME -% -% #1 is the macro name -% #2 is the list of argument names -% #3 is the list of argument values -\def\getargvals@#1#2#3{% - \def\macargdeflist@{}% - \def\saveparamlist@{#2}% Need to keep a copy for parameter expansion. - \def\paramlist{#2,\nil@}% - \def\macroname{#1}% - \begingroup - \macroargctxt - \def\argvaluelist{#3,\nil@}% - \def\@tempa{#3}% - \ifx\@tempa\empty - \setemptyargvalues@ - \else - \getargvals@@ - \fi -} - -% -\def\getargvals@@{% - \ifx\paramlist\nilm@ - % Some sanity check needed here that \argvaluelist is also empty. - \ifx\argvaluelist\nillm@ - \else - \errhelp = \EMsimple - \errmessage{Too many arguments in macro `\macroname'!}% - \fi - \let\next\macargexpandinbody@ - \else - \ifx\argvaluelist\nillm@ - % No more arguments values passed to macro. Set remaining named-arg - % macros to empty. - \let\next\setemptyargvalues@ - \else - % pop current arg name into \@tempb - \def\@tempa##1{\pop@{\@tempb}{\paramlist}##1\endargs@}% - \expandafter\@tempa\expandafter{\paramlist}% - % pop current argument value into \@tempc - \def\@tempa##1{\longpop@{\@tempc}{\argvaluelist}##1\endargs@}% - \expandafter\@tempa\expandafter{\argvaluelist}% - % Here \@tempb is the current arg name and \@tempc is the current arg value. - % First place the new argument macro definition into \@tempd - \expandafter\macname\expandafter{\@tempc}% - \expandafter\let\csname macarg.\@tempb\endcsname\relax - \expandafter\def\expandafter\@tempe\expandafter{% - \csname macarg.\@tempb\endcsname}% - \edef\@tempd{\long\def\@tempe{\the\macname}}% - \push@\@tempd\macargdeflist@ - \let\next\getargvals@@ - \fi - \fi - \next -} - -\def\push@#1#2{% - \expandafter\expandafter\expandafter\def - \expandafter\expandafter\expandafter#2% - \expandafter\expandafter\expandafter{% - \expandafter#1#2}% -} - -% Replace arguments by their values in the macro body, and place the result -% in macro \@tempa -\def\macvalstoargs@{% - % To do this we use the property that token registers that are \the'ed - % within an \edef expand only once. So we are going to place all argument - % values into respective token registers. - % - % First we save the token context, and initialize argument numbering. - \begingroup - \paramno0\relax - % Then, for each argument number #N, we place the corresponding argument - % value into a new token list register \toks#N - \expandafter\putargsintokens@\saveparamlist@,;,% - % Then, we expand the body so that argument are replaced by their - % values. The trick for values not to be expanded themselves is that they - % are within tokens and that tokens expand only once in an \edef . - \edef\@tempc{\csname mac.\macroname .body\endcsname}% - % Now we restore the token stack pointer to free the token list registers - % which we have used, but we make sure that expanded body is saved after - % group. - \expandafter - \endgroup - \expandafter\def\expandafter\@tempa\expandafter{\@tempc}% - } - -\def\macargexpandinbody@{% - %% Define the named-macro outside of this group and then close this group. - \expandafter - \endgroup - \macargdeflist@ - % First the replace in body the macro arguments by their values, the result - % is in \@tempa . - \macvalstoargs@ - % Then we point at the \norecurse or \gobble (for recursive) macro value - % with \@tempb . - \expandafter\let\expandafter\@tempb\csname mac.\macroname .recurse\endcsname - % Depending on whether it is recursive or not, we need some tailing - % \egroup . - \ifx\@tempb\gobble - \let\@tempc\relax - \else - \let\@tempc\egroup - \fi - % And now we do the real job: - \edef\@tempd{\noexpand\@tempb{\macroname}\noexpand\scanmacro{\@tempa}\@tempc}% - \@tempd -} - -\def\putargsintokens@#1,{% - \if#1;\let\next\relax - \else - \let\next\putargsintokens@ - % First we allocate the new token list register, and give it a temporary - % alias \@tempb . - \toksdef\@tempb\the\paramno - % Then we place the argument value into that token list register. - \expandafter\let\expandafter\@tempa\csname macarg.#1\endcsname - \expandafter\@tempb\expandafter{\@tempa}% - \advance\paramno by 1\relax - \fi - \next -} - -% Save the token stack pointer into macro #1 -\def\texisavetoksstackpoint#1{\edef#1{\the\@cclvi}} -% Restore the token stack pointer from number in macro #1 -\def\texirestoretoksstackpoint#1{\expandafter\mathchardef\expandafter\@cclvi#1\relax} -% newtoks that can be used non \outer . -\def\texinonouternewtoks{\alloc@ 5\toks \toksdef \@cclvi} - -% Tailing missing arguments are set to empty -\def\setemptyargvalues@{% - \ifx\paramlist\nilm@ - \let\next\macargexpandinbody@ - \else - \expandafter\setemptyargvaluesparser@\paramlist\endargs@ - \let\next\setemptyargvalues@ - \fi - \next -} - -\def\setemptyargvaluesparser@#1,#2\endargs@{% - \expandafter\def\expandafter\@tempa\expandafter{% - \expandafter\def\csname macarg.#1\endcsname{}}% - \push@\@tempa\macargdeflist@ - \def\paramlist{#2}% -} - -% #1 is the element target macro -% #2 is the list macro -% #3,#4\endargs@ is the list value -\def\pop@#1#2#3,#4\endargs@{% - \def#1{#3}% - \def#2{#4}% -} -\long\def\longpop@#1#2#3,#4\endargs@{% - \long\def#1{#3}% - \long\def#2{#4}% -} - -% This defines a Texinfo @macro. There are eight cases: recursive and -% nonrecursive macros of zero, one, up to nine, and many arguments. + +% This defines the macro itself. There are six cases: recursive and +% nonrecursive macros of zero, one, and many arguments. % Much magic with \expandafter here. % \xdef is used so that macro definitions will survive the file % they're defined in; @include reads the file inside a group. -% \def\defmacro{% \let\hash=##% convert placeholders to macro parameter chars \ifrecursive @@ -7630,25 +5866,17 @@ \expandafter\noexpand\csname\the\macname xxx\endcsname}% \expandafter\xdef\csname\the\macname xxx\endcsname##1{% \egroup\noexpand\scanmacro{\temp}}% - \else - \ifnum\paramno<10\relax % at most 9 - \expandafter\xdef\csname\the\macname\endcsname{% - \bgroup\noexpand\macroargctxt - \noexpand\csname\the\macname xx\endcsname}% - \expandafter\xdef\csname\the\macname xx\endcsname##1{% - \expandafter\noexpand\csname\the\macname xxx\endcsname ##1,}% - \expandafter\expandafter - \expandafter\xdef - \expandafter\expandafter - \csname\the\macname xxx\endcsname - \paramlist{\egroup\noexpand\scanmacro{\temp}}% - \else % 10 or more - \expandafter\xdef\csname\the\macname\endcsname{% - \noexpand\getargvals@{\the\macname}{\argl}% - }% - \global\expandafter\let\csname mac.\the\macname .body\endcsname\temp - \global\expandafter\let\csname mac.\the\macname .recurse\endcsname\gobble - \fi + \else % many + \expandafter\xdef\csname\the\macname\endcsname{% + \bgroup\noexpand\macroargctxt + \noexpand\csname\the\macname xx\endcsname}% + \expandafter\xdef\csname\the\macname xx\endcsname##1{% + \expandafter\noexpand\csname\the\macname xxx\endcsname ##1,}% + \expandafter\expandafter + \expandafter\xdef + \expandafter\expandafter + \csname\the\macname xxx\endcsname + \paramlist{\egroup\noexpand\scanmacro{\temp}}% \fi \else \ifcase\paramno @@ -7665,51 +5893,39 @@ \egroup \noexpand\norecurse{\the\macname}% \noexpand\scanmacro{\temp}\egroup}% - \else % at most 9 - \ifnum\paramno<10\relax - \expandafter\xdef\csname\the\macname\endcsname{% - \bgroup\noexpand\macroargctxt - \expandafter\noexpand\csname\the\macname xx\endcsname}% - \expandafter\xdef\csname\the\macname xx\endcsname##1{% - \expandafter\noexpand\csname\the\macname xxx\endcsname ##1,}% - \expandafter\expandafter - \expandafter\xdef - \expandafter\expandafter - \csname\the\macname xxx\endcsname - \paramlist{% - \egroup - \noexpand\norecurse{\the\macname}% - \noexpand\scanmacro{\temp}\egroup}% - \else % 10 or more: - \expandafter\xdef\csname\the\macname\endcsname{% - \noexpand\getargvals@{\the\macname}{\argl}% - }% - \global\expandafter\let\csname mac.\the\macname .body\endcsname\temp - \global\expandafter\let\csname mac.\the\macname .recurse\endcsname\norecurse - \fi + \else % many + \expandafter\xdef\csname\the\macname\endcsname{% + \bgroup\noexpand\macroargctxt + \expandafter\noexpand\csname\the\macname xx\endcsname}% + \expandafter\xdef\csname\the\macname xx\endcsname##1{% + \expandafter\noexpand\csname\the\macname xxx\endcsname ##1,}% + \expandafter\expandafter + \expandafter\xdef + \expandafter\expandafter + \csname\the\macname xxx\endcsname + \paramlist{% + \egroup + \noexpand\norecurse{\the\macname}% + \noexpand\scanmacro{\temp}\egroup}% \fi \fi} -\catcode `\@\texiatcatcode\relax - \def\norecurse#1{\bgroup\cslet{#1}{macsave.#1}} % \braceorline decides whether the next nonwhitespace character is a % {. If so it reads up to the closing }, if not, it reads the whole % line. Whatever was read is then fed to the next control sequence -% as an argument (by \parsebrace or \parsearg). -% -\def\braceorline#1{\let\macnamexxx=#1\futurelet\nchar\braceorlinexxx} +% as an argument (by \parsebrace or \parsearg) +\def\braceorline#1{\let\next=#1\futurelet\nchar\braceorlinexxx} \def\braceorlinexxx{% \ifx\nchar\bgroup\else \expandafter\parsearg - \fi \macnamexxx} + \fi \next} % @alias. % We need some trickery to remove the optional spaces around the equal -% sign. Make them active and then expand them all to nothing. -% +% sign. Just make them active and then expand them all to nothing. \def\alias{\parseargusing\obeyspaces\aliasxxx} \def\aliasxxx #1{\aliasyyy#1\relax} \def\aliasyyy #1=#2\relax{% @@ -7725,13 +5941,13 @@ \message{cross references,} \newwrite\auxfile + \newif\ifhavexrefs % True if xref values are known. \newif\ifwarnedxrefs % True if we warned once that they aren't known. % @inforef is relatively simple. \def\inforef #1{\inforefzzz #1,,,,**} -\def\inforefzzz #1,#2,#3,#4**{% - \putwordSee{} \putwordInfo{} \putwordfile{} \file{\ignorespaces #3{}}, +\def\inforefzzz #1,#2,#3,#4**{\putwordSee{} \putwordInfo{} \putwordfile{} \file{\ignorespaces #3{}}, node \samp{\ignorespaces#1{}}} % @node's only job in TeX is to define \lastnode, which is used in @@ -7770,7 +5986,7 @@ % \setref{NAME}{SNT} defines a cross-reference point NAME (a node or an % anchor), which consists of three parts: -% 1) NAME-title - the current sectioning name taken from \lastsection, +% 1) NAME-title - the current sectioning name taken from \thissection, % or the anchor name. % 2) NAME-snt - section number and type, passed as the SNT arg, or % empty for anchors. @@ -7789,35 +6005,14 @@ \write\auxfile{@xrdef{#1-% #1 of \setref, expanded by the \edef ##1}{##2}}% these are parameters of \writexrdef }% - \toks0 = \expandafter{\lastsection}% + \toks0 = \expandafter{\thissection}% \immediate \writexrdef{title}{\the\toks0 }% \immediate \writexrdef{snt}{\csname #2\endcsname}% \Ynumbered etc. - \safewhatsit{\writexrdef{pg}{\folio}}% will be written later, at \shipout + \writexrdef{pg}{\folio}% will be written later, during \shipout }% \fi } -% @xrefautosectiontitle on|off says whether @section(ing) names are used -% automatically in xrefs, if the third arg is not explicitly specified. -% This was provided as a "secret" @set xref-automatic-section-title -% variable, now it's official. -% -\parseargdef\xrefautomaticsectiontitle{% - \def\temp{#1}% - \ifx\temp\onword - \expandafter\let\csname SETxref-automatic-section-title\endcsname - = \empty - \else\ifx\temp\offword - \expandafter\let\csname SETxref-automatic-section-title\endcsname - = \relax - \else - \errhelp = \EMsimple - \errmessage{Unknown @xrefautomaticsectiontitle value `\temp', - must be on|off}% - \fi\fi -} - -% % @xref, @pxref, and @ref generate cross-references. For \xrefX, #1 is % the node name, #2 the name of the Info cross-reference, #3 the printed % node name, #4 the name of the Info file, #5 the name of the printed @@ -7826,41 +6021,26 @@ \def\pxref#1{\putwordsee{} \xrefX[#1,,,,,,,]} \def\xref#1{\putwordSee{} \xrefX[#1,,,,,,,]} \def\ref#1{\xrefX[#1,,,,,,,]} -% -\newbox\toprefbox -\newbox\printedrefnamebox -\newbox\infofilenamebox -\newbox\printedmanualbox -% \def\xrefX[#1,#2,#3,#4,#5,#6]{\begingroup \unsepspaces - % - % Get args without leading/trailing spaces. + \def\printedmanual{\ignorespaces #5}% \def\printedrefname{\ignorespaces #3}% - \setbox\printedrefnamebox = \hbox{\printedrefname\unskip}% - % - \def\infofilename{\ignorespaces #4}% - \setbox\infofilenamebox = \hbox{\infofilename\unskip}% - % - \def\printedmanual{\ignorespaces #5}% - \setbox\printedmanualbox = \hbox{\printedmanual\unskip}% - % - % If the printed reference name (arg #3) was not explicitly given in - % the @xref, figure out what we want to use. - \ifdim \wd\printedrefnamebox = 0pt + \setbox1=\hbox{\printedmanual\unskip}% + \setbox0=\hbox{\printedrefname\unskip}% + \ifdim \wd0 = 0pt % No printed node name was explicitly given. - \expandafter\ifx\csname SETxref-automatic-section-title\endcsname \relax - % Not auto section-title: use node name inside the square brackets. + \expandafter\ifx\csname SETxref-automatic-section-title\endcsname\relax + % Use the node name inside the square brackets. \def\printedrefname{\ignorespaces #1}% \else - % Auto section-title: use chapter/section title inside - % the square brackets if we have it. - \ifdim \wd\printedmanualbox > 0pt - % It is in another manual, so we don't have it; use node name. + % Use the actual chapter/section title appear inside + % the square brackets. Use the real section title if we have it. + \ifdim \wd1 > 0pt + % It is in another manual, so we don't have it. \def\printedrefname{\ignorespaces #1}% \else \ifhavexrefs - % We (should) know the real title if we have the xref values. + % We know the real title if we have the xref values. \def\printedrefname{\refx{#1-title}{}}% \else % Otherwise just copy the Info node name. @@ -7872,32 +6052,22 @@ % % Make link in pdf output. \ifpdf - {\indexnofonts - \turnoffactive - \makevalueexpandable - % This expands tokens, so do it after making catcode changes, so _ - % etc. don't get their TeX definitions. This ignores all spaces in - % #4, including (wrongly) those in the middle of the filename. - \getfilename{#4}% + \leavevmode + \getfilename{#4}% + {\turnoffactive + % See comments at \activebackslashdouble. + {\activebackslashdouble \xdef\pdfxrefdest{#1}% + \backslashparens\pdfxrefdest}% % - % This (wrongly) does not take account of leading or trailing - % spaces in #1, which should be ignored. - \edef\pdfxrefdest{#1}% - \ifx\pdfxrefdest\empty - \def\pdfxrefdest{Top}% no empty targets + \ifnum\filenamelength>0 + \startlink attr{/Border [0 0 0]}% + goto file{\the\filename.pdf} name{\pdfxrefdest}% \else - \txiescapepdf\pdfxrefdest % escape PDF special chars - \fi - % - \leavevmode - \startlink attr{/Border [0 0 0]}% - \ifnum\filenamelength>0 - goto file{\the\filename.pdf} name{\pdfxrefdest}% - \else - goto name{\pdfmkpgn{\pdfxrefdest}}% + \startlink attr{/Border [0 0 0]}% + goto name{\pdfmkpgn{\pdfxrefdest}}% \fi }% - \setcolor{\linkcolor}% + \linkcolor \fi % % Float references are printed completely differently: "Figure 1.2" @@ -7914,42 +6084,29 @@ \iffloat\Xthisreftitle % If the user specified the print name (third arg) to the ref, % print it instead of our usual "Figure 1.2". - \ifdim\wd\printedrefnamebox = 0pt - \refx{#1-snt}{}% + \ifdim\wd0 = 0pt + \refx{#1-snt}% \else \printedrefname \fi % - % If the user also gave the printed manual name (fifth arg), append + % if the user also gave the printed manual name (fifth arg), append % "in MANUALNAME". - \ifdim \wd\printedmanualbox > 0pt + \ifdim \wd1 > 0pt \space \putwordin{} \cite{\printedmanual}% \fi \else % node/anchor (non-float) references. - % - % If we use \unhbox to print the node names, TeX does not insert - % empty discretionaries after hyphens, which means that it will not - % find a line break at a hyphen in a node names. Since some manuals - % are best written with fairly long node names, containing hyphens, - % this is a loss. Therefore, we give the text of the node name - % again, so it is as if TeX is seeing it for the first time. - % - \ifdim \wd\printedmanualbox > 0pt - % Cross-manual reference with a printed manual name. - % - \crossmanualxref{\cite{\printedmanual\unskip}}% % - \else\ifdim \wd\infofilenamebox > 0pt - % Cross-manual reference with only an info filename (arg 4), no - % printed manual name (arg 5). This is essentially the same as - % the case above; we output the filename, since we have nothing else. - % - \crossmanualxref{\code{\infofilename\unskip}}% - % + % If we use \unhbox0 and \unhbox1 to print the node names, TeX does not + % insert empty discretionaries after hyphens, which means that it will + % not find a line break at a hyphen in a node names. Since some manuals + % are best written with fairly long node names, containing hyphens, this + % is a loss. Therefore, we give the text of the node name again, so it + % is as if TeX is seeing it for the first time. + \ifdim \wd1 > 0pt + \putwordsection{} ``\printedrefname'' \putwordin{} \cite{\printedmanual}% \else - % Reference within this manual. - % % _ (for example) has to be the character _ for the purposes of the % control sequence corresponding to the node, but it has to expand % into the usual \leavevmode...\vrule stuff for purposes of @@ -7961,7 +6118,7 @@ \setbox2 = \hbox{\ignorespaces \refx{#1-snt}{}}% \ifdim \wd2 > 0pt \refx{#1-snt}\space\fi }% - % output the `[mynode]' via the macro below so it can be overridden. + % output the `[mynode]' via a macro so it can be overridden. \xrefprintnodename\printedrefname % % But we always want a comma and a space: @@ -7969,37 +6126,11 @@ % % output the `page 3'. \turnoffactive \putwordpage\tie\refx{#1-pg}{}% - \fi\fi + \fi \fi \endlink \endgroup} -% Output a cross-manual xref to #1. Used just above (twice). -% -% Only include the text "Section ``foo'' in" if the foo is neither -% missing or Top. Thus, @xref{,,,foo,The Foo Manual} outputs simply -% "see The Foo Manual", the idea being to refer to the whole manual. -% -% But, this being TeX, we can't easily compare our node name against the -% string "Top" while ignoring the possible spaces before and after in -% the input. By adding the arbitrary 7sp below, we make it much less -% likely that a real node name would have the same width as "Top" (e.g., -% in a monospaced font). Hopefully it will never happen in practice. -% -% For the same basic reason, we retypeset the "Top" at every -% reference, since the current font is indeterminate. -% -\def\crossmanualxref#1{% - \setbox\toprefbox = \hbox{Top\kern7sp}% - \setbox2 = \hbox{\ignorespaces \printedrefname \unskip \kern7sp}% - \ifdim \wd2 > 7sp % nonempty? - \ifdim \wd2 = \wd\toprefbox \else % same as Top? - \putwordSection{} ``\printedrefname'' \putwordin{}\space - \fi - \fi - #1% -} - % This macro is called from \xrefX for the `[nodename]' part of xref % output. It's a separate macro only so it can be changed more easily, % since square brackets don't work well in some documents. Particularly @@ -8050,8 +6181,7 @@ \angleleft un\-de\-fined\angleright \iflinks \ifhavexrefs - {\toks0 = {#1}% avoid expansion of possibly-complex value - \message{\linenumber Undefined cross reference `\the\toks0'.}}% + \message{\linenumber Undefined cross reference `#1'.}% \else \ifwarnedxrefs\else \global\warnedxrefstrue @@ -8071,18 +6201,10 @@ % collisions). But if this is a float type, we have more work to do. % \def\xrdef#1#2{% - {% The node name might contain 8-bit characters, which in our current - % implementation are changed to commands like @'e. Don't let these - % mess up the control sequence name. - \indexnofonts - \turnoffactive - \xdef\safexrefname{#1}% - }% - % - \expandafter\gdef\csname XR\safexrefname\endcsname{#2}% remember this xref + \expandafter\gdef\csname XR#1\endcsname{#2}% remember this xref value. % % Was that xref control sequence that we just defined for a float? - \expandafter\iffloat\csname XR\safexrefname\endcsname + \expandafter\iffloat\csname XR#1\endcsname % it was a float, and we have the (safe) float type in \iffloattype. \expandafter\let\expandafter\floatlist \csname floatlist\iffloattype\endcsname @@ -8097,8 +6219,7 @@ % % Remember this xref in the control sequence \floatlistFLOATTYPE, % for later use in \listoffloats. - \expandafter\xdef\csname floatlist\iffloattype\endcsname{\the\toks0 - {\safexrefname}}% + \expandafter\xdef\csname floatlist\iffloattype\endcsname{\the\toks0{#1}}% \fi } @@ -8202,7 +6323,6 @@ \input\jobname.#1 \endgroup} - \message{insertions,} % including footnotes. @@ -8215,7 +6335,7 @@ % space to prevent strange expansion errors.) \def\supereject{\par\penalty -20000\footnoteno =0 } -% @footnotestyle is meaningful for Info output only. +% @footnotestyle is meaningful for info output only. \let\footnotestyle=\comment {\catcode `\@=11 @@ -8278,8 +6398,6 @@ % expands into a box, it must come within the paragraph, lest it % provide a place where TeX can split the footnote. \footstrut - % - % Invoke rest of plain TeX footnote routine. \futurelet\next\fo@t } }%end \catcode `\@=11 @@ -8287,7 +6405,7 @@ % In case a @footnote appears in a vbox, save the footnote text and create % the real \insert just after the vbox finished. Otherwise, the insertion % would be lost. -% Similarly, if a @footnote appears inside an alignment, save the footnote +% Similarily, if a @footnote appears inside an alignment, save the footnote % text to a box and make the \insert when a row of the table is finished. % And the same can be done for other insert classes. --kasal, 16nov03. @@ -8367,7 +6485,7 @@ it from ftp://tug.org/tex/epsf.tex.} % \def\image#1{% - \ifx\epsfbox\thisisundefined + \ifx\epsfbox\undefined \ifwarnednoepsf \else \errhelp = \noepsfhelp \errmessage{epsf.tex not found, images will be ignored}% @@ -8383,7 +6501,7 @@ % #2 is (optional) width, #3 is (optional) height. % #4 is (ignored optional) html alt text. % #5 is (ignored optional) extension. -% #6 is just the usual extra ignored arg for parsing stuff. +% #6 is just the usual extra ignored arg for parsing this stuff. \newif\ifimagevmode \def\imagexxx#1,#2,#3,#4,#5,#6\finish{\begingroup \catcode`\^^M = 5 % in case we're inside an example @@ -8391,30 +6509,15 @@ % If the image is by itself, center it. \ifvmode \imagevmodetrue - \else \ifx\centersub\centerV - % for @center @image, we need a vbox so we can have our vertical space - \imagevmodetrue - \vbox\bgroup % vbox has better behavior than vtop herev - \fi\fi - % - \ifimagevmode - \nobreak\medskip + \nobreak\bigskip % Usually we'll have text after the image which will insert % \parskip glue, so insert it here too to equalize the space % above and below. \nobreak\vskip\parskip \nobreak + \line\bgroup\hss \fi % - % Leave vertical mode so that indentation from an enclosing - % environment such as @quotation is respected. - % However, if we're at the top level, we don't want the - % normal paragraph indentation. - % On the other hand, if we are in the case of @center @image, we don't - % want to start a paragraph, which will create a hsize-width box and - % eradicate the centering. - \ifx\centersub\centerV\else \noindent \fi - % % Output the image. \ifpdf \dopdfimage{#1}{#2}{#3}% @@ -8425,10 +6528,7 @@ \epsfbox{#1.eps}% \fi % - \ifimagevmode - \medskip % space after a standalone image - \fi - \ifx\centersub\centerV \egroup \fi + \ifimagevmode \hss \egroup \bigbreak \fi % space after the image \endgroup} @@ -8495,13 +6595,13 @@ \global\advance\floatno by 1 % {% - % This magic value for \lastsection is output by \setref as the + % This magic value for \thissection is output by \setref as the % XREFLABEL-title value. \xrefX uses it to distinguish float % labels (which have a completely different output format) from % node and anchor labels. And \xrdef uses it to construct the % lists of floats. % - \edef\lastsection{\floatmagic=\safefloattype}% + \edef\thissection{\floatmagic=\safefloattype}% \setref{\floatlabel}{Yfloat}% }% \fi @@ -8569,7 +6669,6 @@ % caption if specified, else the full caption if specified, else nothing. {% \atdummies - % % since we read the caption text in the macro world, where ^^M % is turned into a normal character, we have to scan it back, so % we don't write the literal three characters "^^M" into the aux file. @@ -8590,9 +6689,8 @@ % % place the captured inserts % - % BEWARE: when the floats start floating, we have to issue warning - % whenever an insert appears inside a float which could possibly - % float. --kasal, 26may04 + % BEWARE: when the floats start float, we have to issue warning whenever an + % insert appears inside a float which could possibly float. --kasal, 26may04 % \checkinserts } @@ -8636,7 +6734,7 @@ % #1 is the control sequence we are passed; we expand into a conditional % which is true if #1 represents a float ref. That is, the magic -% \lastsection value which we \setref above. +% \thissection value which we \setref above. % \def\iffloat#1{\expandafter\doiffloat#1==\finish} % @@ -8697,909 +6795,39 @@ \writeentry }} - \message{localization,} - -% For single-language documents, @documentlanguage is usually given very -% early, just after @documentencoding. Single argument is the language -% (de) or locale (de_DE) abbreviation. -% -{ - \catcode`\_ = \active - \globaldefs=1 -\parseargdef\documentlanguage{\begingroup - \let_=\normalunderscore % normal _ character for filenames +% and i18n. + +% @documentlanguage is usually given very early, just after +% @setfilename. If done too late, it may not override everything +% properly. Single argument is the language abbreviation. +% It would be nice if we could set up a hyphenation file here. +% +\parseargdef\documentlanguage{% \tex % read txi-??.tex file in plain TeX. - % Read the file by the name they passed if it exists. + % Read the file if it exists. \openin 1 txi-#1.tex \ifeof 1 - \documentlanguagetrywithoutunderscore{#1_\finish}% + \errhelp = \nolanghelp + \errmessage{Cannot read language file txi-#1.tex}% \else - \globaldefs = 1 % everything in the txi-LL files needs to persist \input txi-#1.tex \fi \closein 1 - \endgroup % end raw TeX -\endgroup} -% -% If they passed de_DE, and txi-de_DE.tex doesn't exist, -% try txi-de.tex. -% -\gdef\documentlanguagetrywithoutunderscore#1_#2\finish{% - \openin 1 txi-#1.tex - \ifeof 1 - \errhelp = \nolanghelp - \errmessage{Cannot read language file txi-#1.tex}% - \else - \globaldefs = 1 % everything in the txi-LL files needs to persist - \input txi-#1.tex - \fi - \closein 1 -} -}% end of special _ catcode -% + \endgroup +} \newhelp\nolanghelp{The given language definition file cannot be found or -is empty. Maybe you need to install it? Putting it in the current -directory should work if nowhere else does.} - -% This macro is called from txi-??.tex files; the first argument is the -% \language name to set (without the "\lang@" prefix), the second and -% third args are \{left,right}hyphenmin. -% -% The language names to pass are determined when the format is built. -% See the etex.log file created at that time, e.g., -% /usr/local/texlive/2008/texmf-var/web2c/pdftex/etex.log. -% -% With TeX Live 2008, etex now includes hyphenation patterns for all -% available languages. This means we can support hyphenation in -% Texinfo, at least to some extent. (This still doesn't solve the -% accented characters problem.) -% -\catcode`@=11 -\def\txisetlanguage#1#2#3{% - % do not set the language if the name is undefined in the current TeX. - \expandafter\ifx\csname lang@#1\endcsname \relax - \message{no patterns for #1}% - \else - \global\language = \csname lang@#1\endcsname - \fi - % but there is no harm in adjusting the hyphenmin values regardless. - \global\lefthyphenmin = #2\relax - \global\righthyphenmin = #3\relax -} - -% Helpers for encodings. -% Set the catcode of characters 128 through 255 to the specified number. -% -\def\setnonasciicharscatcode#1{% - \count255=128 - \loop\ifnum\count255<256 - \global\catcode\count255=#1\relax - \advance\count255 by 1 - \repeat -} - -\def\setnonasciicharscatcodenonglobal#1{% - \count255=128 - \loop\ifnum\count255<256 - \catcode\count255=#1\relax - \advance\count255 by 1 - \repeat -} - -% @documentencoding sets the definition of non-ASCII characters -% according to the specified encoding. -% -\parseargdef\documentencoding{% - % Encoding being declared for the document. - \def\declaredencoding{\csname #1.enc\endcsname}% - % - % Supported encodings: names converted to tokens in order to be able - % to compare them with \ifx. - \def\ascii{\csname US-ASCII.enc\endcsname}% - \def\latnine{\csname ISO-8859-15.enc\endcsname}% - \def\latone{\csname ISO-8859-1.enc\endcsname}% - \def\lattwo{\csname ISO-8859-2.enc\endcsname}% - \def\utfeight{\csname UTF-8.enc\endcsname}% - % - \ifx \declaredencoding \ascii - \asciichardefs - % - \else \ifx \declaredencoding \lattwo - \setnonasciicharscatcode\active - \lattwochardefs - % - \else \ifx \declaredencoding \latone - \setnonasciicharscatcode\active - \latonechardefs - % - \else \ifx \declaredencoding \latnine - \setnonasciicharscatcode\active - \latninechardefs - % - \else \ifx \declaredencoding \utfeight - \setnonasciicharscatcode\active - \utfeightchardefs - % - \else - \message{Unknown document encoding #1, ignoring.}% - % - \fi % utfeight - \fi % latnine - \fi % latone - \fi % lattwo - \fi % ascii -} - -% A message to be logged when using a character that isn't available -% the default font encoding (OT1). -% -\def\missingcharmsg#1{\message{Character missing in OT1 encoding: #1.}} - -% Take account of \c (plain) vs. \, (Texinfo) difference. -\def\cedilla#1{\ifx\c\ptexc\c{#1}\else\,{#1}\fi} - -% First, make active non-ASCII characters in order for them to be -% correctly categorized when TeX reads the replacement text of -% macros containing the character definitions. -\setnonasciicharscatcode\active -% -% Latin1 (ISO-8859-1) character definitions. -\def\latonechardefs{% - \gdef^^a0{\tie} - \gdef^^a1{\exclamdown} - \gdef^^a2{\missingcharmsg{CENT SIGN}} - \gdef^^a3{{\pounds}} - \gdef^^a4{\missingcharmsg{CURRENCY SIGN}} - \gdef^^a5{\missingcharmsg{YEN SIGN}} - \gdef^^a6{\missingcharmsg{BROKEN BAR}} - \gdef^^a7{\S} - \gdef^^a8{\"{}} - \gdef^^a9{\copyright} - \gdef^^aa{\ordf} - \gdef^^ab{\guillemetleft} - \gdef^^ac{$\lnot$} - \gdef^^ad{\-} - \gdef^^ae{\registeredsymbol} - \gdef^^af{\={}} - % - \gdef^^b0{\textdegree} - \gdef^^b1{$\pm$} - \gdef^^b2{$^2$} - \gdef^^b3{$^3$} - \gdef^^b4{\'{}} - \gdef^^b5{$\mu$} - \gdef^^b6{\P} - % - \gdef^^b7{$^.$} - \gdef^^b8{\cedilla\ } - \gdef^^b9{$^1$} - \gdef^^ba{\ordm} - % - \gdef^^bb{\guillemetright} - \gdef^^bc{$1\over4$} - \gdef^^bd{$1\over2$} - \gdef^^be{$3\over4$} - \gdef^^bf{\questiondown} - % - \gdef^^c0{\`A} - \gdef^^c1{\'A} - \gdef^^c2{\^A} - \gdef^^c3{\~A} - \gdef^^c4{\"A} - \gdef^^c5{\ringaccent A} - \gdef^^c6{\AE} - \gdef^^c7{\cedilla C} - \gdef^^c8{\`E} - \gdef^^c9{\'E} - \gdef^^ca{\^E} - \gdef^^cb{\"E} - \gdef^^cc{\`I} - \gdef^^cd{\'I} - \gdef^^ce{\^I} - \gdef^^cf{\"I} - % - \gdef^^d0{\DH} - \gdef^^d1{\~N} - \gdef^^d2{\`O} - \gdef^^d3{\'O} - \gdef^^d4{\^O} - \gdef^^d5{\~O} - \gdef^^d6{\"O} - \gdef^^d7{$\times$} - \gdef^^d8{\O} - \gdef^^d9{\`U} - \gdef^^da{\'U} - \gdef^^db{\^U} - \gdef^^dc{\"U} - \gdef^^dd{\'Y} - \gdef^^de{\TH} - \gdef^^df{\ss} - % - \gdef^^e0{\`a} - \gdef^^e1{\'a} - \gdef^^e2{\^a} - \gdef^^e3{\~a} - \gdef^^e4{\"a} - \gdef^^e5{\ringaccent a} - \gdef^^e6{\ae} - \gdef^^e7{\cedilla c} - \gdef^^e8{\`e} - \gdef^^e9{\'e} - \gdef^^ea{\^e} - \gdef^^eb{\"e} - \gdef^^ec{\`{\dotless i}} - \gdef^^ed{\'{\dotless i}} - \gdef^^ee{\^{\dotless i}} - \gdef^^ef{\"{\dotless i}} - % - \gdef^^f0{\dh} - \gdef^^f1{\~n} - \gdef^^f2{\`o} - \gdef^^f3{\'o} - \gdef^^f4{\^o} - \gdef^^f5{\~o} - \gdef^^f6{\"o} - \gdef^^f7{$\div$} - \gdef^^f8{\o} - \gdef^^f9{\`u} - \gdef^^fa{\'u} - \gdef^^fb{\^u} - \gdef^^fc{\"u} - \gdef^^fd{\'y} - \gdef^^fe{\th} - \gdef^^ff{\"y} -} - -% Latin9 (ISO-8859-15) encoding character definitions. -\def\latninechardefs{% - % Encoding is almost identical to Latin1. - \latonechardefs - % - \gdef^^a4{\euro} - \gdef^^a6{\v S} - \gdef^^a8{\v s} - \gdef^^b4{\v Z} - \gdef^^b8{\v z} - \gdef^^bc{\OE} - \gdef^^bd{\oe} - \gdef^^be{\"Y} -} - -% Latin2 (ISO-8859-2) character definitions. -\def\lattwochardefs{% - \gdef^^a0{\tie} - \gdef^^a1{\ogonek{A}} - \gdef^^a2{\u{}} - \gdef^^a3{\L} - \gdef^^a4{\missingcharmsg{CURRENCY SIGN}} - \gdef^^a5{\v L} - \gdef^^a6{\'S} - \gdef^^a7{\S} - \gdef^^a8{\"{}} - \gdef^^a9{\v S} - \gdef^^aa{\cedilla S} - \gdef^^ab{\v T} - \gdef^^ac{\'Z} - \gdef^^ad{\-} - \gdef^^ae{\v Z} - \gdef^^af{\dotaccent Z} - % - \gdef^^b0{\textdegree} - \gdef^^b1{\ogonek{a}} - \gdef^^b2{\ogonek{ }} - \gdef^^b3{\l} - \gdef^^b4{\'{}} - \gdef^^b5{\v l} - \gdef^^b6{\'s} - \gdef^^b7{\v{}} - \gdef^^b8{\cedilla\ } - \gdef^^b9{\v s} - \gdef^^ba{\cedilla s} - \gdef^^bb{\v t} - \gdef^^bc{\'z} - \gdef^^bd{\H{}} - \gdef^^be{\v z} - \gdef^^bf{\dotaccent z} - % - \gdef^^c0{\'R} - \gdef^^c1{\'A} - \gdef^^c2{\^A} - \gdef^^c3{\u A} - \gdef^^c4{\"A} - \gdef^^c5{\'L} - \gdef^^c6{\'C} - \gdef^^c7{\cedilla C} - \gdef^^c8{\v C} - \gdef^^c9{\'E} - \gdef^^ca{\ogonek{E}} - \gdef^^cb{\"E} - \gdef^^cc{\v E} - \gdef^^cd{\'I} - \gdef^^ce{\^I} - \gdef^^cf{\v D} - % - \gdef^^d0{\DH} - \gdef^^d1{\'N} - \gdef^^d2{\v N} - \gdef^^d3{\'O} - \gdef^^d4{\^O} - \gdef^^d5{\H O} - \gdef^^d6{\"O} - \gdef^^d7{$\times$} - \gdef^^d8{\v R} - \gdef^^d9{\ringaccent U} - \gdef^^da{\'U} - \gdef^^db{\H U} - \gdef^^dc{\"U} - \gdef^^dd{\'Y} - \gdef^^de{\cedilla T} - \gdef^^df{\ss} - % - \gdef^^e0{\'r} - \gdef^^e1{\'a} - \gdef^^e2{\^a} - \gdef^^e3{\u a} - \gdef^^e4{\"a} - \gdef^^e5{\'l} - \gdef^^e6{\'c} - \gdef^^e7{\cedilla c} - \gdef^^e8{\v c} - \gdef^^e9{\'e} - \gdef^^ea{\ogonek{e}} - \gdef^^eb{\"e} - \gdef^^ec{\v e} - \gdef^^ed{\'{\dotless{i}}} - \gdef^^ee{\^{\dotless{i}}} - \gdef^^ef{\v d} - % - \gdef^^f0{\dh} - \gdef^^f1{\'n} - \gdef^^f2{\v n} - \gdef^^f3{\'o} - \gdef^^f4{\^o} - \gdef^^f5{\H o} - \gdef^^f6{\"o} - \gdef^^f7{$\div$} - \gdef^^f8{\v r} - \gdef^^f9{\ringaccent u} - \gdef^^fa{\'u} - \gdef^^fb{\H u} - \gdef^^fc{\"u} - \gdef^^fd{\'y} - \gdef^^fe{\cedilla t} - \gdef^^ff{\dotaccent{}} -} - -% UTF-8 character definitions. -% -% This code to support UTF-8 is based on LaTeX's utf8.def, with some -% changes for Texinfo conventions. It is included here under the GPL by -% permission from Frank Mittelbach and the LaTeX team. -% -\newcount\countUTFx -\newcount\countUTFy -\newcount\countUTFz - -\gdef\UTFviiiTwoOctets#1#2{\expandafter - \UTFviiiDefined\csname u8:#1\string #2\endcsname} -% -\gdef\UTFviiiThreeOctets#1#2#3{\expandafter - \UTFviiiDefined\csname u8:#1\string #2\string #3\endcsname} -% -\gdef\UTFviiiFourOctets#1#2#3#4{\expandafter - \UTFviiiDefined\csname u8:#1\string #2\string #3\string #4\endcsname} - -\gdef\UTFviiiDefined#1{% - \ifx #1\relax - \message{\linenumber Unicode char \string #1 not defined for Texinfo}% - \else - \expandafter #1% - \fi -} - -\begingroup - \catcode`\~13 - \catcode`\"12 - - \def\UTFviiiLoop{% - \global\catcode\countUTFx\active - \uccode`\~\countUTFx - \uppercase\expandafter{\UTFviiiTmp}% - \advance\countUTFx by 1 - \ifnum\countUTFx < \countUTFy - \expandafter\UTFviiiLoop - \fi} - - \countUTFx = "C2 - \countUTFy = "E0 - \def\UTFviiiTmp{% - \xdef~{\noexpand\UTFviiiTwoOctets\string~}} - \UTFviiiLoop - - \countUTFx = "E0 - \countUTFy = "F0 - \def\UTFviiiTmp{% - \xdef~{\noexpand\UTFviiiThreeOctets\string~}} - \UTFviiiLoop - - \countUTFx = "F0 - \countUTFy = "F4 - \def\UTFviiiTmp{% - \xdef~{\noexpand\UTFviiiFourOctets\string~}} - \UTFviiiLoop -\endgroup - -\begingroup - \catcode`\"=12 - \catcode`\<=12 - \catcode`\.=12 - \catcode`\,=12 - \catcode`\;=12 - \catcode`\!=12 - \catcode`\~=13 - - \gdef\DeclareUnicodeCharacter#1#2{% - \countUTFz = "#1\relax - %\wlog{\space\space defining Unicode char U+#1 (decimal \the\countUTFz)}% - \begingroup - \parseXMLCharref - \def\UTFviiiTwoOctets##1##2{% - \csname u8:##1\string ##2\endcsname}% - \def\UTFviiiThreeOctets##1##2##3{% - \csname u8:##1\string ##2\string ##3\endcsname}% - \def\UTFviiiFourOctets##1##2##3##4{% - \csname u8:##1\string ##2\string ##3\string ##4\endcsname}% - \expandafter\expandafter\expandafter\expandafter - \expandafter\expandafter\expandafter - \gdef\UTFviiiTmp{#2}% - \endgroup} - - \gdef\parseXMLCharref{% - \ifnum\countUTFz < "A0\relax - \errhelp = \EMsimple - \errmessage{Cannot define Unicode char value < 00A0}% - \else\ifnum\countUTFz < "800\relax - \parseUTFviiiA,% - \parseUTFviiiB C\UTFviiiTwoOctets.,% - \else\ifnum\countUTFz < "10000\relax - \parseUTFviiiA;% - \parseUTFviiiA,% - \parseUTFviiiB E\UTFviiiThreeOctets.{,;}% - \else - \parseUTFviiiA;% - \parseUTFviiiA,% - \parseUTFviiiA!% - \parseUTFviiiB F\UTFviiiFourOctets.{!,;}% - \fi\fi\fi - } - - \gdef\parseUTFviiiA#1{% - \countUTFx = \countUTFz - \divide\countUTFz by 64 - \countUTFy = \countUTFz - \multiply\countUTFz by 64 - \advance\countUTFx by -\countUTFz - \advance\countUTFx by 128 - \uccode `#1\countUTFx - \countUTFz = \countUTFy} - - \gdef\parseUTFviiiB#1#2#3#4{% - \advance\countUTFz by "#10\relax - \uccode `#3\countUTFz - \uppercase{\gdef\UTFviiiTmp{#2#3#4}}} -\endgroup - -\def\utfeightchardefs{% - \DeclareUnicodeCharacter{00A0}{\tie} - \DeclareUnicodeCharacter{00A1}{\exclamdown} - \DeclareUnicodeCharacter{00A3}{\pounds} - \DeclareUnicodeCharacter{00A8}{\"{ }} - \DeclareUnicodeCharacter{00A9}{\copyright} - \DeclareUnicodeCharacter{00AA}{\ordf} - \DeclareUnicodeCharacter{00AB}{\guillemetleft} - \DeclareUnicodeCharacter{00AD}{\-} - \DeclareUnicodeCharacter{00AE}{\registeredsymbol} - \DeclareUnicodeCharacter{00AF}{\={ }} - - \DeclareUnicodeCharacter{00B0}{\ringaccent{ }} - \DeclareUnicodeCharacter{00B4}{\'{ }} - \DeclareUnicodeCharacter{00B8}{\cedilla{ }} - \DeclareUnicodeCharacter{00BA}{\ordm} - \DeclareUnicodeCharacter{00BB}{\guillemetright} - \DeclareUnicodeCharacter{00BF}{\questiondown} - - \DeclareUnicodeCharacter{00C0}{\`A} - \DeclareUnicodeCharacter{00C1}{\'A} - \DeclareUnicodeCharacter{00C2}{\^A} - \DeclareUnicodeCharacter{00C3}{\~A} - \DeclareUnicodeCharacter{00C4}{\"A} - \DeclareUnicodeCharacter{00C5}{\AA} - \DeclareUnicodeCharacter{00C6}{\AE} - \DeclareUnicodeCharacter{00C7}{\cedilla{C}} - \DeclareUnicodeCharacter{00C8}{\`E} - \DeclareUnicodeCharacter{00C9}{\'E} - \DeclareUnicodeCharacter{00CA}{\^E} - \DeclareUnicodeCharacter{00CB}{\"E} - \DeclareUnicodeCharacter{00CC}{\`I} - \DeclareUnicodeCharacter{00CD}{\'I} - \DeclareUnicodeCharacter{00CE}{\^I} - \DeclareUnicodeCharacter{00CF}{\"I} - - \DeclareUnicodeCharacter{00D0}{\DH} - \DeclareUnicodeCharacter{00D1}{\~N} - \DeclareUnicodeCharacter{00D2}{\`O} - \DeclareUnicodeCharacter{00D3}{\'O} - \DeclareUnicodeCharacter{00D4}{\^O} - \DeclareUnicodeCharacter{00D5}{\~O} - \DeclareUnicodeCharacter{00D6}{\"O} - \DeclareUnicodeCharacter{00D8}{\O} - \DeclareUnicodeCharacter{00D9}{\`U} - \DeclareUnicodeCharacter{00DA}{\'U} - \DeclareUnicodeCharacter{00DB}{\^U} - \DeclareUnicodeCharacter{00DC}{\"U} - \DeclareUnicodeCharacter{00DD}{\'Y} - \DeclareUnicodeCharacter{00DE}{\TH} - \DeclareUnicodeCharacter{00DF}{\ss} - - \DeclareUnicodeCharacter{00E0}{\`a} - \DeclareUnicodeCharacter{00E1}{\'a} - \DeclareUnicodeCharacter{00E2}{\^a} - \DeclareUnicodeCharacter{00E3}{\~a} - \DeclareUnicodeCharacter{00E4}{\"a} - \DeclareUnicodeCharacter{00E5}{\aa} - \DeclareUnicodeCharacter{00E6}{\ae} - \DeclareUnicodeCharacter{00E7}{\cedilla{c}} - \DeclareUnicodeCharacter{00E8}{\`e} - \DeclareUnicodeCharacter{00E9}{\'e} - \DeclareUnicodeCharacter{00EA}{\^e} - \DeclareUnicodeCharacter{00EB}{\"e} - \DeclareUnicodeCharacter{00EC}{\`{\dotless{i}}} - \DeclareUnicodeCharacter{00ED}{\'{\dotless{i}}} - \DeclareUnicodeCharacter{00EE}{\^{\dotless{i}}} - \DeclareUnicodeCharacter{00EF}{\"{\dotless{i}}} - - \DeclareUnicodeCharacter{00F0}{\dh} - \DeclareUnicodeCharacter{00F1}{\~n} - \DeclareUnicodeCharacter{00F2}{\`o} - \DeclareUnicodeCharacter{00F3}{\'o} - \DeclareUnicodeCharacter{00F4}{\^o} - \DeclareUnicodeCharacter{00F5}{\~o} - \DeclareUnicodeCharacter{00F6}{\"o} - \DeclareUnicodeCharacter{00F8}{\o} - \DeclareUnicodeCharacter{00F9}{\`u} - \DeclareUnicodeCharacter{00FA}{\'u} - \DeclareUnicodeCharacter{00FB}{\^u} - \DeclareUnicodeCharacter{00FC}{\"u} - \DeclareUnicodeCharacter{00FD}{\'y} - \DeclareUnicodeCharacter{00FE}{\th} - \DeclareUnicodeCharacter{00FF}{\"y} - - \DeclareUnicodeCharacter{0100}{\=A} - \DeclareUnicodeCharacter{0101}{\=a} - \DeclareUnicodeCharacter{0102}{\u{A}} - \DeclareUnicodeCharacter{0103}{\u{a}} - \DeclareUnicodeCharacter{0104}{\ogonek{A}} - \DeclareUnicodeCharacter{0105}{\ogonek{a}} - \DeclareUnicodeCharacter{0106}{\'C} - \DeclareUnicodeCharacter{0107}{\'c} - \DeclareUnicodeCharacter{0108}{\^C} - \DeclareUnicodeCharacter{0109}{\^c} - \DeclareUnicodeCharacter{0118}{\ogonek{E}} - \DeclareUnicodeCharacter{0119}{\ogonek{e}} - \DeclareUnicodeCharacter{010A}{\dotaccent{C}} - \DeclareUnicodeCharacter{010B}{\dotaccent{c}} - \DeclareUnicodeCharacter{010C}{\v{C}} - \DeclareUnicodeCharacter{010D}{\v{c}} - \DeclareUnicodeCharacter{010E}{\v{D}} - - \DeclareUnicodeCharacter{0112}{\=E} - \DeclareUnicodeCharacter{0113}{\=e} - \DeclareUnicodeCharacter{0114}{\u{E}} - \DeclareUnicodeCharacter{0115}{\u{e}} - \DeclareUnicodeCharacter{0116}{\dotaccent{E}} - \DeclareUnicodeCharacter{0117}{\dotaccent{e}} - \DeclareUnicodeCharacter{011A}{\v{E}} - \DeclareUnicodeCharacter{011B}{\v{e}} - \DeclareUnicodeCharacter{011C}{\^G} - \DeclareUnicodeCharacter{011D}{\^g} - \DeclareUnicodeCharacter{011E}{\u{G}} - \DeclareUnicodeCharacter{011F}{\u{g}} - - \DeclareUnicodeCharacter{0120}{\dotaccent{G}} - \DeclareUnicodeCharacter{0121}{\dotaccent{g}} - \DeclareUnicodeCharacter{0124}{\^H} - \DeclareUnicodeCharacter{0125}{\^h} - \DeclareUnicodeCharacter{0128}{\~I} - \DeclareUnicodeCharacter{0129}{\~{\dotless{i}}} - \DeclareUnicodeCharacter{012A}{\=I} - \DeclareUnicodeCharacter{012B}{\={\dotless{i}}} - \DeclareUnicodeCharacter{012C}{\u{I}} - \DeclareUnicodeCharacter{012D}{\u{\dotless{i}}} - - \DeclareUnicodeCharacter{0130}{\dotaccent{I}} - \DeclareUnicodeCharacter{0131}{\dotless{i}} - \DeclareUnicodeCharacter{0132}{IJ} - \DeclareUnicodeCharacter{0133}{ij} - \DeclareUnicodeCharacter{0134}{\^J} - \DeclareUnicodeCharacter{0135}{\^{\dotless{j}}} - \DeclareUnicodeCharacter{0139}{\'L} - \DeclareUnicodeCharacter{013A}{\'l} - - \DeclareUnicodeCharacter{0141}{\L} - \DeclareUnicodeCharacter{0142}{\l} - \DeclareUnicodeCharacter{0143}{\'N} - \DeclareUnicodeCharacter{0144}{\'n} - \DeclareUnicodeCharacter{0147}{\v{N}} - \DeclareUnicodeCharacter{0148}{\v{n}} - \DeclareUnicodeCharacter{014C}{\=O} - \DeclareUnicodeCharacter{014D}{\=o} - \DeclareUnicodeCharacter{014E}{\u{O}} - \DeclareUnicodeCharacter{014F}{\u{o}} - - \DeclareUnicodeCharacter{0150}{\H{O}} - \DeclareUnicodeCharacter{0151}{\H{o}} - \DeclareUnicodeCharacter{0152}{\OE} - \DeclareUnicodeCharacter{0153}{\oe} - \DeclareUnicodeCharacter{0154}{\'R} - \DeclareUnicodeCharacter{0155}{\'r} - \DeclareUnicodeCharacter{0158}{\v{R}} - \DeclareUnicodeCharacter{0159}{\v{r}} - \DeclareUnicodeCharacter{015A}{\'S} - \DeclareUnicodeCharacter{015B}{\'s} - \DeclareUnicodeCharacter{015C}{\^S} - \DeclareUnicodeCharacter{015D}{\^s} - \DeclareUnicodeCharacter{015E}{\cedilla{S}} - \DeclareUnicodeCharacter{015F}{\cedilla{s}} - - \DeclareUnicodeCharacter{0160}{\v{S}} - \DeclareUnicodeCharacter{0161}{\v{s}} - \DeclareUnicodeCharacter{0162}{\cedilla{t}} - \DeclareUnicodeCharacter{0163}{\cedilla{T}} - \DeclareUnicodeCharacter{0164}{\v{T}} - - \DeclareUnicodeCharacter{0168}{\~U} - \DeclareUnicodeCharacter{0169}{\~u} - \DeclareUnicodeCharacter{016A}{\=U} - \DeclareUnicodeCharacter{016B}{\=u} - \DeclareUnicodeCharacter{016C}{\u{U}} - \DeclareUnicodeCharacter{016D}{\u{u}} - \DeclareUnicodeCharacter{016E}{\ringaccent{U}} - \DeclareUnicodeCharacter{016F}{\ringaccent{u}} - - \DeclareUnicodeCharacter{0170}{\H{U}} - \DeclareUnicodeCharacter{0171}{\H{u}} - \DeclareUnicodeCharacter{0174}{\^W} - \DeclareUnicodeCharacter{0175}{\^w} - \DeclareUnicodeCharacter{0176}{\^Y} - \DeclareUnicodeCharacter{0177}{\^y} - \DeclareUnicodeCharacter{0178}{\"Y} - \DeclareUnicodeCharacter{0179}{\'Z} - \DeclareUnicodeCharacter{017A}{\'z} - \DeclareUnicodeCharacter{017B}{\dotaccent{Z}} - \DeclareUnicodeCharacter{017C}{\dotaccent{z}} - \DeclareUnicodeCharacter{017D}{\v{Z}} - \DeclareUnicodeCharacter{017E}{\v{z}} - - \DeclareUnicodeCharacter{01C4}{D\v{Z}} - \DeclareUnicodeCharacter{01C5}{D\v{z}} - \DeclareUnicodeCharacter{01C6}{d\v{z}} - \DeclareUnicodeCharacter{01C7}{LJ} - \DeclareUnicodeCharacter{01C8}{Lj} - \DeclareUnicodeCharacter{01C9}{lj} - \DeclareUnicodeCharacter{01CA}{NJ} - \DeclareUnicodeCharacter{01CB}{Nj} - \DeclareUnicodeCharacter{01CC}{nj} - \DeclareUnicodeCharacter{01CD}{\v{A}} - \DeclareUnicodeCharacter{01CE}{\v{a}} - \DeclareUnicodeCharacter{01CF}{\v{I}} - - \DeclareUnicodeCharacter{01D0}{\v{\dotless{i}}} - \DeclareUnicodeCharacter{01D1}{\v{O}} - \DeclareUnicodeCharacter{01D2}{\v{o}} - \DeclareUnicodeCharacter{01D3}{\v{U}} - \DeclareUnicodeCharacter{01D4}{\v{u}} - - \DeclareUnicodeCharacter{01E2}{\={\AE}} - \DeclareUnicodeCharacter{01E3}{\={\ae}} - \DeclareUnicodeCharacter{01E6}{\v{G}} - \DeclareUnicodeCharacter{01E7}{\v{g}} - \DeclareUnicodeCharacter{01E8}{\v{K}} - \DeclareUnicodeCharacter{01E9}{\v{k}} - - \DeclareUnicodeCharacter{01F0}{\v{\dotless{j}}} - \DeclareUnicodeCharacter{01F1}{DZ} - \DeclareUnicodeCharacter{01F2}{Dz} - \DeclareUnicodeCharacter{01F3}{dz} - \DeclareUnicodeCharacter{01F4}{\'G} - \DeclareUnicodeCharacter{01F5}{\'g} - \DeclareUnicodeCharacter{01F8}{\`N} - \DeclareUnicodeCharacter{01F9}{\`n} - \DeclareUnicodeCharacter{01FC}{\'{\AE}} - \DeclareUnicodeCharacter{01FD}{\'{\ae}} - \DeclareUnicodeCharacter{01FE}{\'{\O}} - \DeclareUnicodeCharacter{01FF}{\'{\o}} - - \DeclareUnicodeCharacter{021E}{\v{H}} - \DeclareUnicodeCharacter{021F}{\v{h}} - - \DeclareUnicodeCharacter{0226}{\dotaccent{A}} - \DeclareUnicodeCharacter{0227}{\dotaccent{a}} - \DeclareUnicodeCharacter{0228}{\cedilla{E}} - \DeclareUnicodeCharacter{0229}{\cedilla{e}} - \DeclareUnicodeCharacter{022E}{\dotaccent{O}} - \DeclareUnicodeCharacter{022F}{\dotaccent{o}} - - \DeclareUnicodeCharacter{0232}{\=Y} - \DeclareUnicodeCharacter{0233}{\=y} - \DeclareUnicodeCharacter{0237}{\dotless{j}} - - \DeclareUnicodeCharacter{02DB}{\ogonek{ }} - - \DeclareUnicodeCharacter{1E02}{\dotaccent{B}} - \DeclareUnicodeCharacter{1E03}{\dotaccent{b}} - \DeclareUnicodeCharacter{1E04}{\udotaccent{B}} - \DeclareUnicodeCharacter{1E05}{\udotaccent{b}} - \DeclareUnicodeCharacter{1E06}{\ubaraccent{B}} - \DeclareUnicodeCharacter{1E07}{\ubaraccent{b}} - \DeclareUnicodeCharacter{1E0A}{\dotaccent{D}} - \DeclareUnicodeCharacter{1E0B}{\dotaccent{d}} - \DeclareUnicodeCharacter{1E0C}{\udotaccent{D}} - \DeclareUnicodeCharacter{1E0D}{\udotaccent{d}} - \DeclareUnicodeCharacter{1E0E}{\ubaraccent{D}} - \DeclareUnicodeCharacter{1E0F}{\ubaraccent{d}} - - \DeclareUnicodeCharacter{1E1E}{\dotaccent{F}} - \DeclareUnicodeCharacter{1E1F}{\dotaccent{f}} - - \DeclareUnicodeCharacter{1E20}{\=G} - \DeclareUnicodeCharacter{1E21}{\=g} - \DeclareUnicodeCharacter{1E22}{\dotaccent{H}} - \DeclareUnicodeCharacter{1E23}{\dotaccent{h}} - \DeclareUnicodeCharacter{1E24}{\udotaccent{H}} - \DeclareUnicodeCharacter{1E25}{\udotaccent{h}} - \DeclareUnicodeCharacter{1E26}{\"H} - \DeclareUnicodeCharacter{1E27}{\"h} - - \DeclareUnicodeCharacter{1E30}{\'K} - \DeclareUnicodeCharacter{1E31}{\'k} - \DeclareUnicodeCharacter{1E32}{\udotaccent{K}} - \DeclareUnicodeCharacter{1E33}{\udotaccent{k}} - \DeclareUnicodeCharacter{1E34}{\ubaraccent{K}} - \DeclareUnicodeCharacter{1E35}{\ubaraccent{k}} - \DeclareUnicodeCharacter{1E36}{\udotaccent{L}} - \DeclareUnicodeCharacter{1E37}{\udotaccent{l}} - \DeclareUnicodeCharacter{1E3A}{\ubaraccent{L}} - \DeclareUnicodeCharacter{1E3B}{\ubaraccent{l}} - \DeclareUnicodeCharacter{1E3E}{\'M} - \DeclareUnicodeCharacter{1E3F}{\'m} - - \DeclareUnicodeCharacter{1E40}{\dotaccent{M}} - \DeclareUnicodeCharacter{1E41}{\dotaccent{m}} - \DeclareUnicodeCharacter{1E42}{\udotaccent{M}} - \DeclareUnicodeCharacter{1E43}{\udotaccent{m}} - \DeclareUnicodeCharacter{1E44}{\dotaccent{N}} - \DeclareUnicodeCharacter{1E45}{\dotaccent{n}} - \DeclareUnicodeCharacter{1E46}{\udotaccent{N}} - \DeclareUnicodeCharacter{1E47}{\udotaccent{n}} - \DeclareUnicodeCharacter{1E48}{\ubaraccent{N}} - \DeclareUnicodeCharacter{1E49}{\ubaraccent{n}} - - \DeclareUnicodeCharacter{1E54}{\'P} - \DeclareUnicodeCharacter{1E55}{\'p} - \DeclareUnicodeCharacter{1E56}{\dotaccent{P}} - \DeclareUnicodeCharacter{1E57}{\dotaccent{p}} - \DeclareUnicodeCharacter{1E58}{\dotaccent{R}} - \DeclareUnicodeCharacter{1E59}{\dotaccent{r}} - \DeclareUnicodeCharacter{1E5A}{\udotaccent{R}} - \DeclareUnicodeCharacter{1E5B}{\udotaccent{r}} - \DeclareUnicodeCharacter{1E5E}{\ubaraccent{R}} - \DeclareUnicodeCharacter{1E5F}{\ubaraccent{r}} - - \DeclareUnicodeCharacter{1E60}{\dotaccent{S}} - \DeclareUnicodeCharacter{1E61}{\dotaccent{s}} - \DeclareUnicodeCharacter{1E62}{\udotaccent{S}} - \DeclareUnicodeCharacter{1E63}{\udotaccent{s}} - \DeclareUnicodeCharacter{1E6A}{\dotaccent{T}} - \DeclareUnicodeCharacter{1E6B}{\dotaccent{t}} - \DeclareUnicodeCharacter{1E6C}{\udotaccent{T}} - \DeclareUnicodeCharacter{1E6D}{\udotaccent{t}} - \DeclareUnicodeCharacter{1E6E}{\ubaraccent{T}} - \DeclareUnicodeCharacter{1E6F}{\ubaraccent{t}} - - \DeclareUnicodeCharacter{1E7C}{\~V} - \DeclareUnicodeCharacter{1E7D}{\~v} - \DeclareUnicodeCharacter{1E7E}{\udotaccent{V}} - \DeclareUnicodeCharacter{1E7F}{\udotaccent{v}} - - \DeclareUnicodeCharacter{1E80}{\`W} - \DeclareUnicodeCharacter{1E81}{\`w} - \DeclareUnicodeCharacter{1E82}{\'W} - \DeclareUnicodeCharacter{1E83}{\'w} - \DeclareUnicodeCharacter{1E84}{\"W} - \DeclareUnicodeCharacter{1E85}{\"w} - \DeclareUnicodeCharacter{1E86}{\dotaccent{W}} - \DeclareUnicodeCharacter{1E87}{\dotaccent{w}} - \DeclareUnicodeCharacter{1E88}{\udotaccent{W}} - \DeclareUnicodeCharacter{1E89}{\udotaccent{w}} - \DeclareUnicodeCharacter{1E8A}{\dotaccent{X}} - \DeclareUnicodeCharacter{1E8B}{\dotaccent{x}} - \DeclareUnicodeCharacter{1E8C}{\"X} - \DeclareUnicodeCharacter{1E8D}{\"x} - \DeclareUnicodeCharacter{1E8E}{\dotaccent{Y}} - \DeclareUnicodeCharacter{1E8F}{\dotaccent{y}} - - \DeclareUnicodeCharacter{1E90}{\^Z} - \DeclareUnicodeCharacter{1E91}{\^z} - \DeclareUnicodeCharacter{1E92}{\udotaccent{Z}} - \DeclareUnicodeCharacter{1E93}{\udotaccent{z}} - \DeclareUnicodeCharacter{1E94}{\ubaraccent{Z}} - \DeclareUnicodeCharacter{1E95}{\ubaraccent{z}} - \DeclareUnicodeCharacter{1E96}{\ubaraccent{h}} - \DeclareUnicodeCharacter{1E97}{\"t} - \DeclareUnicodeCharacter{1E98}{\ringaccent{w}} - \DeclareUnicodeCharacter{1E99}{\ringaccent{y}} - - \DeclareUnicodeCharacter{1EA0}{\udotaccent{A}} - \DeclareUnicodeCharacter{1EA1}{\udotaccent{a}} - - \DeclareUnicodeCharacter{1EB8}{\udotaccent{E}} - \DeclareUnicodeCharacter{1EB9}{\udotaccent{e}} - \DeclareUnicodeCharacter{1EBC}{\~E} - \DeclareUnicodeCharacter{1EBD}{\~e} - - \DeclareUnicodeCharacter{1ECA}{\udotaccent{I}} - \DeclareUnicodeCharacter{1ECB}{\udotaccent{i}} - \DeclareUnicodeCharacter{1ECC}{\udotaccent{O}} - \DeclareUnicodeCharacter{1ECD}{\udotaccent{o}} - - \DeclareUnicodeCharacter{1EE4}{\udotaccent{U}} - \DeclareUnicodeCharacter{1EE5}{\udotaccent{u}} - - \DeclareUnicodeCharacter{1EF2}{\`Y} - \DeclareUnicodeCharacter{1EF3}{\`y} - \DeclareUnicodeCharacter{1EF4}{\udotaccent{Y}} - - \DeclareUnicodeCharacter{1EF8}{\~Y} - \DeclareUnicodeCharacter{1EF9}{\~y} - - \DeclareUnicodeCharacter{2013}{--} - \DeclareUnicodeCharacter{2014}{---} - \DeclareUnicodeCharacter{2018}{\quoteleft} - \DeclareUnicodeCharacter{2019}{\quoteright} - \DeclareUnicodeCharacter{201A}{\quotesinglbase} - \DeclareUnicodeCharacter{201C}{\quotedblleft} - \DeclareUnicodeCharacter{201D}{\quotedblright} - \DeclareUnicodeCharacter{201E}{\quotedblbase} - \DeclareUnicodeCharacter{2022}{\bullet} - \DeclareUnicodeCharacter{2026}{\dots} - \DeclareUnicodeCharacter{2039}{\guilsinglleft} - \DeclareUnicodeCharacter{203A}{\guilsinglright} - \DeclareUnicodeCharacter{20AC}{\euro} - - \DeclareUnicodeCharacter{2192}{\expansion} - \DeclareUnicodeCharacter{21D2}{\result} - - \DeclareUnicodeCharacter{2212}{\minus} - \DeclareUnicodeCharacter{2217}{\point} - \DeclareUnicodeCharacter{2261}{\equiv} -}% end of \utfeightchardefs - - -% US-ASCII character definitions. -\def\asciichardefs{% nothing need be done - \relax -} - -% Make non-ASCII characters printable again for compatibility with -% existing Texinfo documents that may use them, even without declaring a -% document encoding. -% -\setnonasciicharscatcode \other - - -\message{formatting,} - +is empty. Maybe you need to install it? In the current directory +should work if nowhere else does.} + + +% @documentencoding should change something in TeX eventually, most +% likely, but for now just recognize it. +\let\documentencoding = \comment + + +% Page size parameters. +% \newdimen\defaultparindent \defaultparindent = 15pt \chapheadingskip = 15pt plus 4pt minus 2pt @@ -9609,10 +6837,10 @@ % Prevent underfull vbox error messages. \vbadness = 10000 -% Don't be very finicky about underfull hboxes, either. -\hbadness = 6666 - -% Following George Bush, get rid of widows and orphans. +% Don't be so finicky about underfull hboxes, either. +\hbadness = 2000 + +% Following George Bush, just get rid of widows and orphans. \widowpenalty=10000 \clubpenalty=10000 @@ -9659,10 +6887,6 @@ \ifpdf \pdfpageheight #7\relax \pdfpagewidth #8\relax - % if we don't reset these, they will remain at "1 true in" of - % whatever layout pdftex was dumped with. - \pdfhorigin = 1 true in - \pdfvorigin = 1 true in \fi % \setleading{\textleading} @@ -9677,7 +6901,7 @@ \textleading = 13.2pt % % If page is nothing but text, make it come out even. - \internalpagesizes{607.2pt}{6in}% that's 46 lines + \internalpagesizes{46\baselineskip}{6in}% {\voffset}{.25in}% {\bindingoffset}{36pt}% {11in}{8.5in}% @@ -9689,7 +6913,7 @@ \textleading = 12pt % \internalpagesizes{7.5in}{5in}% - {-.2in}{0in}% + {\voffset}{.25in}% {\bindingoffset}{16pt}% {9.25in}{7in}% % @@ -9733,7 +6957,7 @@ % \global\normaloffset = -6mm % \global\bindingoffset = 10mm % @end tex - \internalpagesizes{673.2pt}{160mm}% that's 51 lines + \internalpagesizes{51\baselineskip}{160mm} {\voffset}{\hoffset}% {\bindingoffset}{44pt}% {297mm}{210mm}% @@ -9798,7 +7022,7 @@ \parskip = 3pt plus 2pt minus 1pt \setleading{\textleading}% % - \dimen0 = #1\relax + \dimen0 = #1 \advance\dimen0 by \voffset % \dimen2 = \hsize @@ -9817,21 +7041,25 @@ \message{and turning on texinfo input format.} -\def^^L{\par} % remove \outer, so ^L can appear in an @comment - -% DEL is a comment character, in case @c does not suffice. -\catcode`\^^? = 14 - % Define macros to output various characters with catcode for normal text. -\catcode`\"=\other \def\normaldoublequote{"} -\catcode`\$=\other \def\normaldollar{$}%$ font-lock fix -\catcode`\+=\other \def\normalplus{+} -\catcode`\<=\other \def\normalless{<} -\catcode`\>=\other \def\normalgreater{>} -\catcode`\^=\other \def\normalcaret{^} -\catcode`\_=\other \def\normalunderscore{_} -\catcode`\|=\other \def\normalverticalbar{|} -\catcode`\~=\other \def\normaltilde{~} +\catcode`\"=\other +\catcode`\~=\other +\catcode`\^=\other +\catcode`\_=\other +\catcode`\|=\other +\catcode`\<=\other +\catcode`\>=\other +\catcode`\+=\other +\catcode`\$=\other +\def\normaldoublequote{"} +\def\normaltilde{~} +\def\normalcaret{^} +\def\normalunderscore{_} +\def\normalverticalbar{|} +\def\normalless{<} +\def\normalgreater{>} +\def\normalplus{+} +\def\normaldollar{$}%$ font-lock fix % This macro is used to make a character print one way in \tt % (where it can probably be output as-is), and another way in other fonts, @@ -9889,13 +7117,6 @@ % \otherifyactive is called near the end of this file. \def\otherifyactive{\catcode`+=\other \catcode`\_=\other} -% Used sometimes to turn off (effectively) the active characters even after -% parsing them. -\def\turnoffactive{% - \normalturnoffactive - \otherbackslash -} - \catcode`\@=0 % \backslashcurfont outputs one backslash character in current font, @@ -9903,52 +7124,45 @@ \global\chardef\backslashcurfont=`\\ \global\let\rawbackslashxx=\backslashcurfont % let existing .??s files work +% \rawbackslash defines an active \ to do \backslashcurfont. +% \otherbackslash defines an active \ to be a literal `\' character with +% catcode other. +{\catcode`\\=\active + @gdef@rawbackslash{@let\=@backslashcurfont} + @gdef@otherbackslash{@let\=@realbackslash} +} + % \realbackslash is an actual character `\' with catcode other, and % \doublebackslash is two of them (for the pdf outlines). {\catcode`\\=\other @gdef@realbackslash{\} @gdef@doublebackslash{\\}} -% In texinfo, backslash is an active character; it prints the backslash -% in fixed width font. -\catcode`\\=\active % @ for escape char from now on. - -% The story here is that in math mode, the \char of \backslashcurfont -% ends up printing the roman \ from the math symbol font (because \char -% in math mode uses the \mathcode, and plain.tex sets -% \mathcode`\\="026E). It seems better for @backslashchar{} to always -% print a typewriter backslash, hence we use an explicit \mathchar, -% which is the decimal equivalent of "715c (class 7, e.g., use \fam; -% ignored family value; char position "5C). We can't use " for the -% usual hex value because it has already been made active. -@def@normalbackslash{{@tt @ifmmode @mathchar29020 @else @backslashcurfont @fi}} -@let@backslashchar = @normalbackslash % @backslashchar{} is for user documents. - -% On startup, @fixbackslash assigns: -% @let \ = @normalbackslash -% \rawbackslash defines an active \ to do \backslashcurfont. -% \otherbackslash defines an active \ to be a literal `\' character with -% catcode other. We switch back and forth between these. -@gdef@rawbackslash{@let\=@backslashcurfont} -@gdef@otherbackslash{@let\=@realbackslash} - -% Same as @turnoffactive except outputs \ as {\tt\char`\\} instead of -% the literal character `\'. -% -@def@normalturnoffactive{% +% \normalbackslash outputs one backslash in fixed width font. +\def\normalbackslash{{\tt\backslashcurfont}} + +\catcode`\\=\active + +% Used sometimes to turn off (effectively) the active characters +% even after parsing them. +@def@turnoffactive{% @let"=@normaldoublequote - @let$=@normaldollar %$ font-lock fix - @let+=@normalplus - @let<=@normalless - @let>=@normalgreater - @let\=@normalbackslash + @let\=@realbackslash + @let~=@normaltilde @let^=@normalcaret @let_=@normalunderscore @let|=@normalverticalbar - @let~=@normaltilde - @markupsetuplqdefault - @markupsetuprqdefault + @let<=@normalless + @let>=@normalgreater + @let+=@normalplus + @let$=@normaldollar %$ font-lock fix @unsepspaces } +% Same as @turnoffactive except outputs \ as {\tt\char`\\} instead of +% the literal character `\'. (Thus, \ is not expandable when this is in +% effect.) +% +@def@normalturnoffactive{@turnoffactive @let\=@normalbackslash} + % Make _ and + \other characters, temporarily. % This is canceled by @fixbackslash. @otherifyactive @@ -9961,7 +7175,7 @@ @global@let\ = @eatinput % On the other hand, perhaps the file did not have a `\input texinfo'. Then -% the first `\' in the file would cause an error. This macro tries to fix +% the first `\{ in the file would cause an error. This macro tries to fix % that, assuming it is called before the first `\' could plausibly occur. % Also turn back on active characters that might appear in the input % file name, in case not using a pre-dumped format. @@ -9975,28 +7189,11 @@ % Say @foo, not \foo, in error messages. @escapechar = `@@ -% These (along with & and #) are made active for url-breaking, so need -% active definitions as the normal characters. -@def@normaldot{.} -@def@normalquest{?} -@def@normalslash{/} - % These look ok in all fonts, so just make them not special. -% @hashchar{} gets its own user-level command, because of #line. -@catcode`@& = @other @def@normalamp{&} -@catcode`@# = @other @def@normalhash{#} -@catcode`@% = @other @def@normalpercent{%} - -@let @hashchar = @normalhash - -@c Finally, make ` and ' active, so that txicodequoteundirected and -@c txicodequotebacktick work right in, e.g., @w{@code{`foo'}}. If we -@c don't make ` and ' active, @code will not get them as active chars. -@c Do this last of all since we use ` in the previous @catcode assignments. -@catcode`@'=@active -@catcode`@`=@active -@markupsetuplqdefault -@markupsetuprqdefault +@catcode`@& = @other +@catcode`@# = @other +@catcode`@% = @other + @c Local variables: @c eval: (add-hook 'write-file-hooks 'time-stamp) diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi_osx/x86/darwin64.S --- a/Modules/_ctypes/libffi_osx/x86/darwin64.S Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/_ctypes/libffi_osx/x86/darwin64.S Sun Jul 20 10:52:46 2014 -0400 @@ -45,7 +45,6 @@ _ffi_call_unix64: LUW0: movq (%rsp), %r10 /* Load return address. */ - movq %rdi, %r12 /* Save a copy of the register area. */ leaq (%rdi, %rsi), %rax /* Find local stack base. */ movq %rdx, (%rax) /* Save flags. */ movq %rcx, 8(%rax) /* Save raddr. */ @@ -53,8 +52,7 @@ movq %r10, 24(%rax) /* Relocate return address. */ movq %rax, %rbp /* Finalize local stack frame. */ LUW1: - /* movq %rdi, %r10 // Save a copy of the register area. */ - movq %r12, %r10 + movq %rdi, %r10 /* Save a copy of the register area. */ movq %r8, %r11 /* Save a copy of the target fn. */ movl %r9d, %eax /* Set number of SSE registers. */ @@ -257,7 +255,7 @@ ret .align 3 Lld_int8: - movzbl -24(%rsp), %eax + movzbl -24(%rsp), %eax ret .align 3 Lld_int16: diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi_osx/x86/x86-darwin.S --- a/Modules/_ctypes/libffi_osx/x86/x86-darwin.S Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/_ctypes/libffi_osx/x86/x86-darwin.S Sun Jul 20 10:52:46 2014 -0400 @@ -198,12 +198,8 @@ je Lcls_retldouble cmpl $FFI_TYPE_SINT64, %eax je Lcls_retllong - cmpl $FFI_TYPE_UINT8, %eax - je Lcls_retstruct1 cmpl $FFI_TYPE_SINT8, %eax je Lcls_retstruct1 - cmpl $FFI_TYPE_UINT16, %eax - je Lcls_retstruct2 cmpl $FFI_TYPE_SINT16, %eax je Lcls_retstruct2 cmpl $FFI_TYPE_STRUCT, %eax diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi_osx/x86/x86-ffi64.c --- a/Modules/_ctypes/libffi_osx/x86/x86-ffi64.c Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/_ctypes/libffi_osx/x86/x86-ffi64.c Sun Jul 20 10:52:46 2014 -0400 @@ -152,42 +152,12 @@ case FFI_TYPE_UINT64: case FFI_TYPE_SINT64: case FFI_TYPE_POINTER: -#if 0 if (byte_offset + type->size <= 4) classes[0] = X86_64_INTEGERSI_CLASS; else classes[0] = X86_64_INTEGER_CLASS; return 1; -#else - { - int size = byte_offset + type->size; - - if (size <= 4) - { - classes[0] = X86_64_INTEGERSI_CLASS; - return 1; - } - else if (size <= 8) - { - classes[0] = X86_64_INTEGER_CLASS; - return 1; - } - else if (size <= 12) - { - classes[0] = X86_64_INTEGER_CLASS; - classes[1] = X86_64_INTEGERSI_CLASS; - return 2; - } - else if (size <= 16) - { - classes[0] = classes[1] = X86_64_INTEGERSI_CLASS; - return 2; - } - else - FFI_ASSERT (0); - } -#endif case FFI_TYPE_FLOAT: if (byte_offset == 0) @@ -243,21 +213,6 @@ byte_offset += (*ptr)->size; } - if (words > 2) - { - /* When size > 16 bytes, if the first one isn't - X86_64_SSE_CLASS or any other ones aren't - X86_64_SSEUP_CLASS, everything should be passed in - memory. */ - if (classes[0] != X86_64_SSE_CLASS) - return 0; - - for (i = 1; i < words; i++) - if (classes[i] != X86_64_SSEUP_CLASS) - return 0; - } - - /* Final merger cleanup. */ for (i = 0; i < words; i++) { @@ -269,20 +224,13 @@ /* The X86_64_SSEUP_CLASS should be always preceded by X86_64_SSE_CLASS. */ if (classes[i] == X86_64_SSEUP_CLASS - && classes[i - 1] != X86_64_SSE_CLASS - && classes[i - 1] != X86_64_SSEUP_CLASS) - { - FFI_ASSERT(i != 0); + && (i == 0 || classes[i - 1] != X86_64_SSE_CLASS)) classes[i] = X86_64_SSE_CLASS; - } /* X86_64_X87UP_CLASS should be preceded by X86_64_X87_CLASS. */ if (classes[i] == X86_64_X87UP_CLASS - && classes[i - 1] != X86_64_X87_CLASS) - { - FFI_ASSERT(i != 0); + && (i == 0 || classes[i - 1] != X86_64_X87_CLASS)) classes[i] = X86_64_SSE_CLASS; - } } return words; @@ -421,7 +369,6 @@ cif->flags = flags; cif->bytes = bytes; - cif->bytes = ALIGN(bytes,8); return FFI_OK; } @@ -502,61 +449,7 @@ case X86_64_INTEGER_CLASS: case X86_64_INTEGERSI_CLASS: reg_args->gpr[gprcount] = 0; - switch (arg_types[i]->type) { - case FFI_TYPE_SINT8: - { - int8_t shortval = *(int8_t*)a; - int64_t actval = (int64_t)shortval; - reg_args->gpr[gprcount] = actval; - /*memcpy (®_args->gpr[gprcount], &actval, 8);*/ - break; - } - - case FFI_TYPE_SINT16: - { - int16_t shortval = *(int16_t*)a; - int64_t actval = (int64_t)shortval; - memcpy (®_args->gpr[gprcount], &actval, 8); - break; - } - - case FFI_TYPE_SINT32: - { - int32_t shortval = *(int32_t*)a; - int64_t actval = (int64_t)shortval; - memcpy (®_args->gpr[gprcount], &actval, 8); - break; - } - - case FFI_TYPE_UINT8: - { - u_int8_t shortval = *(u_int8_t*)a; - u_int64_t actval = (u_int64_t)shortval; - /*memcpy (®_args->gpr[gprcount], &actval, 8);*/ - reg_args->gpr[gprcount] = actval; - break; - } - - case FFI_TYPE_UINT16: - { - u_int16_t shortval = *(u_int16_t*)a; - u_int64_t actval = (u_int64_t)shortval; - memcpy (®_args->gpr[gprcount], &actval, 8); - break; - } - - case FFI_TYPE_UINT32: - { - u_int32_t shortval = *(u_int32_t*)a; - u_int64_t actval = (u_int64_t)shortval; - memcpy (®_args->gpr[gprcount], &actval, 8); - break; - } - - default: - //memcpy (®_args->gpr[gprcount], a, size < 8 ? size : 8); - reg_args->gpr[gprcount] = *(int64_t*)a; - } + memcpy (®_args->gpr[gprcount], a, size < 8 ? size : 8); gprcount++; break; @@ -612,15 +505,12 @@ return FFI_OK; } -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wmissing-prototypes" int ffi_closure_unix64_inner( ffi_closure* closure, void* rvalue, RegisterArgs* reg_args, char* argp) -#pragma clang diagnostic pop { ffi_cif* cif = closure->cif; void** avalue = alloca(cif->nargs * sizeof(void *)); @@ -731,4 +621,4 @@ return ret; } -#endif /* __x86_64__ */ +#endif /* __x86_64__ */ \ No newline at end of file diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/libffi_osx/x86/x86-ffi_darwin.c --- a/Modules/_ctypes/libffi_osx/x86/x86-ffi_darwin.c Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/_ctypes/libffi_osx/x86/x86-ffi_darwin.c Sun Jul 20 10:52:46 2014 -0400 @@ -35,8 +35,6 @@ /* ffi_prep_args is called by the assembly routine once stack space has been allocated for the function's arguments */ -void ffi_prep_args(char *stack, extended_cif *ecif); - void ffi_prep_args(char *stack, extended_cif *ecif) { register unsigned int i; @@ -435,4 +433,4 @@ } #endif -#endif // __i386__ +#endif // __i386__ \ No newline at end of file diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ctypes/stgdict.c --- a/Modules/_ctypes/stgdict.c Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/_ctypes/stgdict.c Sun Jul 20 10:52:46 2014 -0400 @@ -343,7 +343,7 @@ isPacked = PyObject_GetAttrString(type, "_pack_"); if (isPacked) { - pack = _PyInt_AsInt(isPacked); + pack = PyInt_AsLong(isPacked); if (pack < 0 || PyErr_Occurred()) { Py_XDECREF(isPacked); PyErr_SetString(PyExc_ValueError, @@ -518,12 +518,7 @@ sprintf(buf, "%s:%s:", fieldfmt, fieldname); ptr = stgdict->format; - if (dict->shape != NULL) { - stgdict->format = _ctypes_alloc_format_string_with_shape( - dict->ndim, dict->shape, stgdict->format, buf); - } else { - stgdict->format = _ctypes_alloc_format_string(stgdict->format, buf); - } + stgdict->format = _ctypes_alloc_format_string(stgdict->format, buf); PyMem_Free(ptr); PyMem_Free(buf); diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_curses_panel.c --- a/Modules/_curses_panel.c Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/_curses_panel.c Sun Jul 20 10:52:46 2014 -0400 @@ -293,18 +293,9 @@ static PyObject * PyCursesPanel_set_panel_userptr(PyCursesPanelObject *self, PyObject *obj) { - PyObject *oldobj; - int rc; - PyCursesInitialised; Py_INCREF(obj); - oldobj = (PyObject *) panel_userptr(self->pan); - rc = set_panel_userptr(self->pan, (void*)obj); - if (rc == ERR) { - /* In case of an ncurses error, decref the new object again */ - Py_DECREF(obj); - } - Py_XDECREF(oldobj); - return PyCursesCheckERR(rc, "set_panel_userptr"); + return PyCursesCheckERR(set_panel_userptr(self->pan, (void*)obj), + "set_panel_userptr"); } static PyObject * diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_cursesmodule.c --- a/Modules/_cursesmodule.c Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/_cursesmodule.c Sun Jul 20 10:52:46 2014 -0400 @@ -885,9 +885,7 @@ } if (rtn == ERR) { /* getch() returns ERR in nodelay mode */ - PyErr_CheckSignals(); - if (!PyErr_Occurred()) - PyErr_SetString(PyCursesError, "no input"); + PyErr_SetString(PyCursesError, "no input"); return NULL; } else if (rtn<=255) { return Py_BuildValue("c", rtn); diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_elementtree.c --- a/Modules/_elementtree.c Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/_elementtree.c Sun Jul 20 10:52:46 2014 -0400 @@ -2338,10 +2338,7 @@ PyObject* sprefix = NULL; PyObject* suri = NULL; - if (uri) - suri = makestring(uri, strlen(uri)); - else - suri = PyString_FromStringAndSize("", 0); + suri = makestring(uri, strlen(uri)); if (!suri) return; @@ -2430,8 +2427,6 @@ if (PyUnicode_GET_SIZE(u) != 256) { Py_DECREF(u); - PyErr_SetString(PyExc_ValueError, - "multi-byte encodings are not supported"); return XML_STATUS_ERROR; } @@ -2739,10 +2734,10 @@ target->events = events; /* clear out existing events */ - Py_CLEAR(target->start_event_obj); - Py_CLEAR(target->end_event_obj); - Py_CLEAR(target->start_ns_event_obj); - Py_CLEAR(target->end_ns_event_obj); + Py_XDECREF(target->start_event_obj); target->start_event_obj = NULL; + Py_XDECREF(target->end_event_obj); target->end_event_obj = NULL; + Py_XDECREF(target->start_ns_event_obj); target->start_ns_event_obj = NULL; + Py_XDECREF(target->end_ns_event_obj); target->end_ns_event_obj = NULL; if (event_set == Py_None) { /* default is "end" only */ diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_functoolsmodule.c --- a/Modules/_functoolsmodule.c Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/_functoolsmodule.c Sun Jul 20 10:52:46 2014 -0400 @@ -290,10 +290,10 @@ } PyObject * -partial_setstate(partialobject *pto, PyObject *state) +partial_setstate(partialobject *pto, PyObject *args) { PyObject *fn, *fnargs, *kw, *dict; - if (!PyArg_ParseTuple(state, "OOOO", + if (!PyArg_ParseTuple(args, "(OOOO):__setstate__", &fn, &fnargs, &kw, &dict)) return NULL; Py_XDECREF(pto->fn); @@ -317,7 +317,7 @@ static PyMethodDef partial_methods[] = { {"__reduce__", (PyCFunction)partial_reduce, METH_NOARGS}, - {"__setstate__", (PyCFunction)partial_setstate, METH_O}, + {"__setstate__", (PyCFunction)partial_setstate, METH_VARARGS}, {NULL, NULL} /* sentinel */ }; diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_hashopenssl.c --- a/Modules/_hashopenssl.c Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/_hashopenssl.c Sun Jul 20 10:52:46 2014 -0400 @@ -37,8 +37,6 @@ /* EVP is the preferred interface to hashing in OpenSSL */ #include -#include -#include #define MUNCH_SIZE INT_MAX @@ -69,7 +67,7 @@ #define DEFINE_CONSTS_FOR_NEW(Name) \ - static PyObject *CONST_ ## Name ## _name_obj = NULL; \ + static PyObject *CONST_ ## Name ## _name_obj; \ static EVP_MD_CTX CONST_new_ ## Name ## _ctx; \ static EVP_MD_CTX *CONST_new_ ## Name ## _ctx_p = NULL; @@ -479,7 +477,6 @@ } if (!PyArg_Parse(name_obj, "s", &name)) { - PyBuffer_Release(&view); PyErr_SetString(PyExc_TypeError, "name must be a string"); return NULL; } @@ -493,225 +490,6 @@ return ret_obj; } - -#if (OPENSSL_VERSION_NUMBER >= 0x10000000 && !defined(OPENSSL_NO_HMAC) \ - && !defined(OPENSSL_NO_SHA)) - -#define PY_PBKDF2_HMAC 1 - -/* Improved implementation of PKCS5_PBKDF2_HMAC() - * - * PKCS5_PBKDF2_HMAC_fast() hashes the password exactly one time instead of - * `iter` times. Today (2013) the iteration count is typically 100,000 or - * more. The improved algorithm is not subject to a Denial-of-Service - * vulnerability with overly large passwords. - * - * Also OpenSSL < 1.0 don't provide PKCS5_PBKDF2_HMAC(), only - * PKCS5_PBKDF2_SHA1. - */ -static int -PKCS5_PBKDF2_HMAC_fast(const char *pass, int passlen, - const unsigned char *salt, int saltlen, - int iter, const EVP_MD *digest, - int keylen, unsigned char *out) -{ - unsigned char digtmp[EVP_MAX_MD_SIZE], *p, itmp[4]; - int cplen, j, k, tkeylen, mdlen; - unsigned long i = 1; - HMAC_CTX hctx_tpl, hctx; - - mdlen = EVP_MD_size(digest); - if (mdlen < 0) - return 0; - - HMAC_CTX_init(&hctx_tpl); - HMAC_CTX_init(&hctx); - p = out; - tkeylen = keylen; - if (!HMAC_Init_ex(&hctx_tpl, pass, passlen, digest, NULL)) { - HMAC_CTX_cleanup(&hctx_tpl); - return 0; - } - while(tkeylen) { - if(tkeylen > mdlen) - cplen = mdlen; - else - cplen = tkeylen; - /* We are unlikely to ever use more than 256 blocks (5120 bits!) - * but just in case... - */ - itmp[0] = (unsigned char)((i >> 24) & 0xff); - itmp[1] = (unsigned char)((i >> 16) & 0xff); - itmp[2] = (unsigned char)((i >> 8) & 0xff); - itmp[3] = (unsigned char)(i & 0xff); - if (!HMAC_CTX_copy(&hctx, &hctx_tpl)) { - HMAC_CTX_cleanup(&hctx_tpl); - return 0; - } - if (!HMAC_Update(&hctx, salt, saltlen) - || !HMAC_Update(&hctx, itmp, 4) - || !HMAC_Final(&hctx, digtmp, NULL)) { - HMAC_CTX_cleanup(&hctx_tpl); - HMAC_CTX_cleanup(&hctx); - return 0; - } - HMAC_CTX_cleanup(&hctx); - memcpy(p, digtmp, cplen); - for (j = 1; j < iter; j++) { - if (!HMAC_CTX_copy(&hctx, &hctx_tpl)) { - HMAC_CTX_cleanup(&hctx_tpl); - return 0; - } - if (!HMAC_Update(&hctx, digtmp, mdlen) - || !HMAC_Final(&hctx, digtmp, NULL)) { - HMAC_CTX_cleanup(&hctx_tpl); - HMAC_CTX_cleanup(&hctx); - return 0; - } - HMAC_CTX_cleanup(&hctx); - for (k = 0; k < cplen; k++) { - p[k] ^= digtmp[k]; - } - } - tkeylen-= cplen; - i++; - p+= cplen; - } - HMAC_CTX_cleanup(&hctx_tpl); - return 1; -} - -/* LCOV_EXCL_START */ -static PyObject * -_setException(PyObject *exc) -{ - unsigned long errcode; - const char *lib, *func, *reason; - - errcode = ERR_peek_last_error(); - if (!errcode) { - PyErr_SetString(exc, "unknown reasons"); - return NULL; - } - ERR_clear_error(); - - lib = ERR_lib_error_string(errcode); - func = ERR_func_error_string(errcode); - reason = ERR_reason_error_string(errcode); - - if (lib && func) { - PyErr_Format(exc, "[%s: %s] %s", lib, func, reason); - } - else if (lib) { - PyErr_Format(exc, "[%s] %s", lib, reason); - } - else { - PyErr_SetString(exc, reason); - } - return NULL; -} -/* LCOV_EXCL_STOP */ - -PyDoc_STRVAR(pbkdf2_hmac__doc__, -"pbkdf2_hmac(hash_name, password, salt, iterations, dklen=None) -> key\n\ -\n\ -Password based key derivation function 2 (PKCS #5 v2.0) with HMAC as\n\ -pseudorandom function."); - -static PyObject * -pbkdf2_hmac(PyObject *self, PyObject *args, PyObject *kwdict) -{ - static char *kwlist[] = {"hash_name", "password", "salt", "iterations", - "dklen", NULL}; - PyObject *key_obj = NULL, *dklen_obj = Py_None; - char *name, *key; - Py_buffer password, salt; - long iterations, dklen; - int retval; - const EVP_MD *digest; - - if (!PyArg_ParseTupleAndKeywords(args, kwdict, "ss*s*l|O:pbkdf2_hmac", - kwlist, &name, &password, &salt, - &iterations, &dklen_obj)) { - return NULL; - } - - digest = EVP_get_digestbyname(name); - if (digest == NULL) { - PyErr_SetString(PyExc_ValueError, "unsupported hash type"); - goto end; - } - - if (password.len > INT_MAX) { - PyErr_SetString(PyExc_OverflowError, - "password is too long."); - goto end; - } - - if (salt.len > INT_MAX) { - PyErr_SetString(PyExc_OverflowError, - "salt is too long."); - goto end; - } - - if (iterations < 1) { - PyErr_SetString(PyExc_ValueError, - "iteration value must be greater than 0."); - goto end; - } - if (iterations > INT_MAX) { - PyErr_SetString(PyExc_OverflowError, - "iteration value is too great."); - goto end; - } - - if (dklen_obj == Py_None) { - dklen = EVP_MD_size(digest); - } else { - dklen = PyLong_AsLong(dklen_obj); - if ((dklen == -1) && PyErr_Occurred()) { - goto end; - } - } - if (dklen < 1) { - PyErr_SetString(PyExc_ValueError, - "key length must be greater than 0."); - goto end; - } - if (dklen > INT_MAX) { - /* INT_MAX is always smaller than dkLen max (2^32 - 1) * hLen */ - PyErr_SetString(PyExc_OverflowError, - "key length is too great."); - goto end; - } - - key_obj = PyBytes_FromStringAndSize(NULL, dklen); - if (key_obj == NULL) { - goto end; - } - key = PyBytes_AS_STRING(key_obj); - - Py_BEGIN_ALLOW_THREADS - retval = PKCS5_PBKDF2_HMAC_fast((char*)password.buf, (int)password.len, - (unsigned char *)salt.buf, (int)salt.len, - iterations, digest, dklen, - (unsigned char *)key); - Py_END_ALLOW_THREADS - - if (!retval) { - Py_CLEAR(key_obj); - _setException(PyExc_ValueError); - goto end; - } - - end: - PyBuffer_Release(&password); - PyBuffer_Release(&salt); - return key_obj; -} - -#endif - /* * This macro generates constructor function definitions for specific * hash algorithms. These constructors are much faster than calling @@ -746,15 +524,12 @@ " hash object; optionally initialized with a string") \ } -/* used in the init function to setup a constructor: initialize OpenSSL - constructor constants if they haven't been initialized already. */ +/* used in the init function to setup a constructor */ #define INIT_CONSTRUCTOR_CONSTANTS(NAME) do { \ - if (CONST_ ## NAME ## _name_obj == NULL) { \ CONST_ ## NAME ## _name_obj = PyString_FromString(#NAME); \ - if (EVP_get_digestbyname(#NAME)) { \ - CONST_new_ ## NAME ## _ctx_p = &CONST_new_ ## NAME ## _ctx; \ - EVP_DigestInit(CONST_new_ ## NAME ## _ctx_p, EVP_get_digestbyname(#NAME)); \ - } \ + if (EVP_get_digestbyname(#NAME)) { \ + CONST_new_ ## NAME ## _ctx_p = &CONST_new_ ## NAME ## _ctx; \ + EVP_DigestInit(CONST_new_ ## NAME ## _ctx_p, EVP_get_digestbyname(#NAME)); \ } \ } while (0); @@ -779,10 +554,6 @@ CONSTRUCTOR_METH_DEF(sha384), CONSTRUCTOR_METH_DEF(sha512), #endif -#ifdef PY_PBKDF2_HMAC - {"pbkdf2_hmac", (PyCFunction)pbkdf2_hmac, METH_VARARGS|METH_KEYWORDS, - pbkdf2_hmac__doc__}, -#endif {NULL, NULL} /* Sentinel */ }; diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_heapqmodule.c --- a/Modules/_heapqmodule.c Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/_heapqmodule.c Sun Jul 20 10:52:46 2014 -0400 @@ -35,14 +35,12 @@ static int _siftdown(PyListObject *heap, Py_ssize_t startpos, Py_ssize_t pos) { - PyObject *newitem, *parent, *olditem; + PyObject *newitem, *parent; int cmp; Py_ssize_t parentpos; - Py_ssize_t size; assert(PyList_Check(heap)); - size = PyList_GET_SIZE(heap); - if (pos >= size) { + if (pos >= PyList_GET_SIZE(heap)) { PyErr_SetString(PyExc_IndexError, "index out of range"); return -1; } @@ -59,24 +57,12 @@ Py_DECREF(newitem); return -1; } - if (size != PyList_GET_SIZE(heap)) { - Py_DECREF(newitem); - PyErr_SetString(PyExc_RuntimeError, - "list changed size during iteration"); - return -1; - } if (cmp == 0) break; Py_INCREF(parent); - olditem = PyList_GET_ITEM(heap, pos); + Py_DECREF(PyList_GET_ITEM(heap, pos)); PyList_SET_ITEM(heap, pos, parent); - Py_DECREF(olditem); pos = parentpos; - if (size != PyList_GET_SIZE(heap)) { - PyErr_SetString(PyExc_RuntimeError, - "list changed size during iteration"); - return -1; - } } Py_DECREF(PyList_GET_ITEM(heap, pos)); PyList_SET_ITEM(heap, pos, newitem); @@ -86,14 +72,12 @@ static int _siftup(PyListObject *heap, Py_ssize_t pos) { - Py_ssize_t startpos, endpos, childpos, rightpos, limit; + Py_ssize_t startpos, endpos, childpos, rightpos; int cmp; - PyObject *newitem, *tmp, *olditem; - Py_ssize_t size; + PyObject *newitem, *tmp; assert(PyList_Check(heap)); - size = PyList_GET_SIZE(heap); - endpos = size; + endpos = PyList_GET_SIZE(heap); startpos = pos; if (pos >= endpos) { PyErr_SetString(PyExc_IndexError, "index out of range"); @@ -103,10 +87,9 @@ Py_INCREF(newitem); /* Bubble up the smaller child until hitting a leaf. */ - limit = endpos / 2; /* smallest pos that has no child */ - while (pos < limit) { + childpos = 2*pos + 1; /* leftmost child position */ + while (childpos < endpos) { /* Set childpos to index of smaller child. */ - childpos = 2*pos + 1; /* leftmost child position */ rightpos = childpos + 1; if (rightpos < endpos) { cmp = cmp_lt( @@ -119,27 +102,16 @@ if (cmp == 0) childpos = rightpos; } - if (size != PyList_GET_SIZE(heap)) { - Py_DECREF(newitem); - PyErr_SetString(PyExc_RuntimeError, - "list changed size during iteration"); - return -1; - } /* Move the smaller child up. */ tmp = PyList_GET_ITEM(heap, childpos); Py_INCREF(tmp); - olditem = PyList_GET_ITEM(heap, pos); + Py_DECREF(PyList_GET_ITEM(heap, pos)); PyList_SET_ITEM(heap, pos, tmp); - Py_DECREF(olditem); pos = childpos; - if (size != PyList_GET_SIZE(heap)) { - PyErr_SetString(PyExc_RuntimeError, - "list changed size during iteration"); - return -1; - } + childpos = 2*pos + 1; } - /* The leaf at pos is empty now. Put newitem there, and bubble + /* The leaf at pos is empty now. Put newitem there, and and bubble it up to its final resting place (by sifting its parents down). */ Py_DECREF(PyList_GET_ITEM(heap, pos)); PyList_SET_ITEM(heap, pos, newitem); @@ -169,7 +141,7 @@ } PyDoc_STRVAR(heappush_doc, -"heappush(heap, item) -> None. Push item onto heap, maintaining the heap invariant."); +"Push item onto heap, maintaining the heap invariant."); static PyObject * heappop(PyObject *self, PyObject *heap) @@ -237,7 +209,7 @@ } PyDoc_STRVAR(heapreplace_doc, -"heapreplace(heap, item) -> value. Pop and return the current smallest value, and add the new item.\n\ +"Pop and return the current smallest value, and add the new item.\n\ \n\ This is more efficient than heappop() followed by heappush(), and can be\n\ more appropriate when using a fixed-size heap. Note that the value\n\ @@ -284,7 +256,7 @@ } PyDoc_STRVAR(heappushpop_doc, -"heappushpop(heap, item) -> value. Push item on the heap, then pop and return the smallest item\n\ +"Push item on the heap, then pop and return the smallest item\n\ from the heap. The combined action runs more efficiently than\n\ heappush() followed by a separate call to heappop()."); @@ -439,7 +411,7 @@ static int _siftupmax(PyListObject *heap, Py_ssize_t pos) { - Py_ssize_t startpos, endpos, childpos, rightpos, limit; + Py_ssize_t startpos, endpos, childpos, rightpos; int cmp; PyObject *newitem, *tmp; @@ -454,10 +426,9 @@ Py_INCREF(newitem); /* Bubble up the smaller child until hitting a leaf. */ - limit = endpos / 2; /* smallest pos that has no child */ - while (pos < limit) { + childpos = 2*pos + 1; /* leftmost child position */ + while (childpos < endpos) { /* Set childpos to index of smaller child. */ - childpos = 2*pos + 1; /* leftmost child position */ rightpos = childpos + 1; if (rightpos < endpos) { cmp = cmp_lt( @@ -476,9 +447,10 @@ Py_DECREF(PyList_GET_ITEM(heap, pos)); PyList_SET_ITEM(heap, pos, tmp); pos = childpos; + childpos = 2*pos + 1; } - /* The leaf at pos is empty now. Put newitem there, and bubble + /* The leaf at pos is empty now. Put newitem there, and and bubble it up to its final resting place (by sifting its parents down). */ Py_DECREF(PyList_GET_ITEM(heap, pos)); PyList_SET_ITEM(heap, pos, newitem); diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_io/_iomodule.c --- a/Modules/_io/_iomodule.c Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/_io/_iomodule.c Sun Jul 20 10:52:46 2014 -0400 @@ -58,8 +58,8 @@ "\n" "At the top of the I/O hierarchy is the abstract base class IOBase. It\n" "defines the basic interface to a stream. Note, however, that there is no\n" -"separation between reading and writing to streams; implementations are\n" -"allowed to raise an IOError if they do not support a given operation.\n" +"seperation between reading and writing to streams; implementations are\n" +"allowed to throw an IOError if they do not support a given operation.\n" "\n" "Extending IOBase is RawIOBase which deals simply with the reading and\n" "writing of raw bytes to a stream. FileIO subclasses RawIOBase to provide\n" @@ -300,10 +300,9 @@ int text = 0, binary = 0, universal = 0; char rawmode[5], *m; - int line_buffering; - long isatty; + int line_buffering, isatty; - PyObject *raw, *modeobj = NULL, *buffer, *wrapper, *result = NULL; + PyObject *raw, *modeobj = NULL, *buffer = NULL, *wrapper = NULL; if (!PyArg_ParseTupleAndKeywords(args, kwds, "O|sizzzi:open", kwlist, &file, &mode, &buffering, @@ -416,7 +415,6 @@ "Osi", file, rawmode, closefd); if (raw == NULL) return NULL; - result = raw; modeobj = PyUnicode_FromString(mode); if (modeobj == NULL) @@ -445,12 +443,12 @@ #ifdef HAVE_STRUCT_STAT_ST_BLKSIZE { struct stat st; - int fileno; + long fileno; PyObject *res = PyObject_CallMethod(raw, "fileno", NULL); if (res == NULL) goto error; - fileno = _PyInt_AsInt(res); + fileno = PyInt_AsLong(res); Py_DECREF(res); if (fileno == -1 && PyErr_Occurred()) goto error; @@ -475,7 +473,7 @@ } Py_DECREF(modeobj); - return result; + return raw; } /* wraps into a buffered file */ @@ -496,16 +494,15 @@ buffer = PyObject_CallFunction(Buffered_class, "Oi", raw, buffering); } + Py_CLEAR(raw); if (buffer == NULL) goto error; - result = buffer; - Py_DECREF(raw); /* if binary, returns the buffered file */ if (binary) { Py_DECREF(modeobj); - return result; + return buffer; } /* wraps into a TextIOWrapper */ @@ -514,32 +511,20 @@ buffer, encoding, errors, newline, line_buffering); + Py_CLEAR(buffer); if (wrapper == NULL) goto error; - result = wrapper; - Py_DECREF(buffer); if (PyObject_SetAttrString(wrapper, "mode", modeobj) < 0) goto error; Py_DECREF(modeobj); - return result; + return wrapper; error: - if (result != NULL) { - PyObject *exc, *val, *tb, *close_result; - PyErr_Fetch(&exc, &val, &tb); - close_result = PyObject_CallMethod(result, "close", NULL); - if (close_result != NULL) { - Py_DECREF(close_result); - PyErr_Restore(exc, val, tb); - } else { - Py_XDECREF(exc); - Py_XDECREF(val); - Py_XDECREF(tb); - } - Py_DECREF(result); - } + Py_XDECREF(raw); Py_XDECREF(modeobj); + Py_XDECREF(buffer); + Py_XDECREF(wrapper); return NULL; } diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_io/_iomodule.h --- a/Modules/_io/_iomodule.h Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/_io/_iomodule.h Sun Jul 20 10:52:46 2014 -0400 @@ -57,11 +57,6 @@ int translated, int universal, PyObject *readnl, Py_UNICODE *start, Py_UNICODE *end, Py_ssize_t *consumed); -/* Return 1 if an EnvironmentError with errno == EINTR is set (and then - clears the error indicator), 0 otherwise. - Should only be called when PyErr_Occurred() is true. -*/ -extern int _PyIO_trap_eintr(void); #define DEFAULT_BUFFER_SIZE (8 * 1024) /* bytes */ @@ -77,7 +72,7 @@ PyObject *filename; /* Not used, but part of the IOError object */ Py_ssize_t written; } PyBlockingIOErrorObject; -extern PyObject *PyExc_BlockingIOError; +PyAPI_DATA(PyObject *) PyExc_BlockingIOError; /* * Offset type for positioning. diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_io/bufferedio.c --- a/Modules/_io/bufferedio.c Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/_io/bufferedio.c Sun Jul 20 10:52:46 2014 -0400 @@ -386,17 +386,6 @@ Py_TYPE(self)->tp_free((PyObject *)self); } -static PyObject * -buffered_sizeof(buffered *self, void *unused) -{ - Py_ssize_t res; - - res = sizeof(buffered); - if (self->buffer) - res += self->buffer_size; - return PyLong_FromSsize_t(res); -} - static int buffered_traverse(buffered *self, visitproc visit, void *arg) { @@ -455,7 +444,7 @@ static PyObject * buffered_close(buffered *self, PyObject *args) { - PyObject *res = NULL, *exc = NULL, *val, *tb; + PyObject *res = NULL; int r; CHECK_INITIALIZED(self) @@ -475,25 +464,13 @@ res = PyObject_CallMethodObjArgs((PyObject *)self, _PyIO_str_flush, NULL); if (!ENTER_BUFFERED(self)) return NULL; - if (res == NULL) - PyErr_Fetch(&exc, &val, &tb); - else - Py_DECREF(res); + if (res == NULL) { + goto end; + } + Py_XDECREF(res); res = PyObject_CallMethodObjArgs(self->raw, _PyIO_str_close, NULL); - if (exc != NULL) { - if (res != NULL) { - Py_CLEAR(res); - PyErr_Restore(exc, val, tb); - } - else { - Py_DECREF(exc); - Py_XDECREF(val); - Py_XDECREF(tb); - } - } - end: LEAVE_BUFFERED(self) return res; @@ -722,8 +699,8 @@ clears the error indicator), 0 otherwise. Should only be called when PyErr_Occurred() is true. */ -int -_PyIO_trap_eintr(void) +static int +_trap_eintr(void) { static PyObject *eintr_int = NULL; PyObject *typ, *val, *tb; @@ -1308,7 +1285,7 @@ */ do { res = PyObject_CallMethodObjArgs(self->raw, _PyIO_str_readinto, memobj, NULL); - } while (res == NULL && _PyIO_trap_eintr()); + } while (res == NULL && _trap_eintr()); Py_DECREF(memobj); if (res == NULL) return -1; @@ -1583,7 +1560,6 @@ {"seek", (PyCFunction)buffered_seek, METH_VARARGS}, {"tell", (PyCFunction)buffered_tell, METH_NOARGS}, {"truncate", (PyCFunction)buffered_truncate, METH_VARARGS}, - {"__sizeof__", (PyCFunction)buffered_sizeof, METH_NOARGS}, {NULL, NULL} }; @@ -1683,7 +1659,7 @@ self->ok = 0; self->detached = 0; - if (!PyArg_ParseTupleAndKeywords(args, kwds, "O|nn:BufferedWriter", kwlist, + if (!PyArg_ParseTupleAndKeywords(args, kwds, "O|nn:BufferedReader", kwlist, &raw, &buffer_size, &max_buffer_size)) { return -1; } @@ -1735,7 +1711,7 @@ errno = 0; res = PyObject_CallMethodObjArgs(self->raw, _PyIO_str_write, memobj, NULL); errnum = errno; - } while (res == NULL && _PyIO_trap_eintr()); + } while (res == NULL && _trap_eintr()); Py_DECREF(memobj); if (res == NULL) return -1; @@ -1976,7 +1952,6 @@ {"flush", (PyCFunction)buffered_flush, METH_NOARGS}, {"seek", (PyCFunction)buffered_seek, METH_VARARGS}, {"tell", (PyCFunction)buffered_tell, METH_NOARGS}, - {"__sizeof__", (PyCFunction)buffered_sizeof, METH_NOARGS}, {NULL, NULL} }; @@ -2129,14 +2104,9 @@ static PyObject * _forward_call(buffered *self, const char *name, PyObject *args) { - PyObject *func, *ret; - if (self == NULL) { - PyErr_SetString(PyExc_ValueError, - "I/O operation on uninitialized object"); - return NULL; - } + PyObject *func = PyObject_GetAttrString((PyObject *)self, name); + PyObject *ret; - func = PyObject_GetAttrString((PyObject *)self, name); if (func == NULL) { PyErr_SetString(PyExc_AttributeError, name); return NULL; @@ -2321,7 +2291,7 @@ self->ok = 0; self->detached = 0; - if (!PyArg_ParseTupleAndKeywords(args, kwds, "O|nn:BufferedRandom", kwlist, + if (!PyArg_ParseTupleAndKeywords(args, kwds, "O|nn:BufferedReader", kwlist, &raw, &buffer_size, &max_buffer_size)) { return -1; } @@ -2377,7 +2347,6 @@ {"readline", (PyCFunction)buffered_readline, METH_VARARGS}, {"peek", (PyCFunction)buffered_peek, METH_VARARGS}, {"write", (PyCFunction)bufferedwriter_write, METH_VARARGS}, - {"__sizeof__", (PyCFunction)buffered_sizeof, METH_NOARGS}, {NULL, NULL} }; diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_io/bytesio.c --- a/Modules/_io/bytesio.c Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/_io/bytesio.c Sun Jul 20 10:52:46 2014 -0400 @@ -106,7 +106,7 @@ } /* Internal routine for writing a string of bytes to the buffer of a BytesIO - object. Returns the number of bytes written, or -1 on error. */ + object. Returns the number of bytes wrote, or -1 on error. */ static Py_ssize_t write_bytes(bytesio *self, const char *bytes, Py_ssize_t len) { @@ -156,20 +156,10 @@ } } -PyDoc_STRVAR(readable_doc, -"readable() -> bool. Returns True if the IO object can be read."); - -PyDoc_STRVAR(writable_doc, -"writable() -> bool. Returns True if the IO object can be written."); - -PyDoc_STRVAR(seekable_doc, -"seekable() -> bool. Returns True if the IO object can be seeked."); - /* Generic getter for the writable, readable and seekable properties */ static PyObject * -return_not_closed(bytesio *self) +return_true(bytesio *self) { - CHECK_CLOSED(self); Py_RETURN_TRUE; } @@ -804,17 +794,6 @@ return 0; } -static PyObject * -bytesio_sizeof(bytesio *self, void *unused) -{ - Py_ssize_t res; - - res = sizeof(bytesio); - if (self->buf) - res += self->buf_size; - return PyLong_FromSsize_t(res); -} - static int bytesio_traverse(bytesio *self, visitproc visit, void *arg) { @@ -837,9 +816,9 @@ }; static struct PyMethodDef bytesio_methods[] = { - {"readable", (PyCFunction)return_not_closed, METH_NOARGS, readable_doc}, - {"seekable", (PyCFunction)return_not_closed, METH_NOARGS, seekable_doc}, - {"writable", (PyCFunction)return_not_closed, METH_NOARGS, writable_doc}, + {"readable", (PyCFunction)return_true, METH_NOARGS, NULL}, + {"seekable", (PyCFunction)return_true, METH_NOARGS, NULL}, + {"writable", (PyCFunction)return_true, METH_NOARGS, NULL}, {"close", (PyCFunction)bytesio_close, METH_NOARGS, close_doc}, {"flush", (PyCFunction)bytesio_flush, METH_NOARGS, flush_doc}, {"isatty", (PyCFunction)bytesio_isatty, METH_NOARGS, isatty_doc}, @@ -856,7 +835,6 @@ {"truncate", (PyCFunction)bytesio_truncate, METH_VARARGS, truncate_doc}, {"__getstate__", (PyCFunction)bytesio_getstate, METH_NOARGS, NULL}, {"__setstate__", (PyCFunction)bytesio_setstate, METH_O, NULL}, - {"__sizeof__", (PyCFunction)bytesio_sizeof, METH_NOARGS, NULL}, {NULL, NULL} /* sentinel */ }; diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_io/fileio.c --- a/Modules/_io/fileio.c Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/_io/fileio.c Sun Jul 20 10:52:46 2014 -0400 @@ -47,7 +47,6 @@ int fd; unsigned int readable : 1; unsigned int writable : 1; - unsigned int appending : 1; signed int seekable : 2; /* -1 means unknown */ unsigned int closefd : 1; PyObject *weakreflist; @@ -125,7 +124,6 @@ self->fd = -1; self->readable = 0; self->writable = 0; - self->appending = 0; self->seekable = -1; self->closefd = 1; self->weakreflist = NULL; @@ -139,15 +137,22 @@ directories, so we need a check. */ static int -dircheck(fileio* self, PyObject *nameobj) +dircheck(fileio* self, const char *name) { #if defined(HAVE_FSTAT) && defined(S_IFDIR) && defined(EISDIR) struct stat buf; if (self->fd < 0) return 0; if (fstat(self->fd, &buf) == 0 && S_ISDIR(buf.st_mode)) { - errno = EISDIR; - PyErr_SetFromErrnoWithFilenameObject(PyExc_IOError, nameobj); + char *msg = strerror(EISDIR); + PyObject *exc; + if (internal_close(self)) + return -1; + + exc = PyObject_CallFunction(PyExc_IOError, "(iss)", + EISDIR, msg, name); + PyErr_SetObject(PyExc_IOError, exc); + Py_XDECREF(exc); return -1; } #endif @@ -186,21 +191,16 @@ Py_UNICODE *widename = NULL; #endif int ret = 0; - int rwa = 0, plus = 0; + int rwa = 0, plus = 0, append = 0; int flags = 0; int fd = -1; int closefd = 1; - int fd_is_own = 0; assert(PyFileIO_Check(oself)); if (self->fd >= 0) { - if (self->closefd) { - /* Have to close the existing file first. */ - if (internal_close(self) < 0) - return -1; - } - else - self->fd = -1; + /* Have to close the existing file first. */ + if (internal_close(self) < 0) + return -1; } if (!PyArg_ParseTupleAndKeywords(args, kwds, "O|si:fileio", @@ -213,7 +213,7 @@ return -1; } - fd = _PyLong_AsInt(nameobj); + fd = PyLong_AsLong(nameobj); if (fd < 0) { if (!PyErr_Occurred()) { PyErr_SetString(PyExc_ValueError, @@ -281,8 +281,8 @@ goto bad_mode; rwa = 1; self->writable = 1; - self->appending = 1; - flags |= O_APPEND | O_CREAT; + flags |= O_CREAT; + append = 1; break; case 'b': break; @@ -313,6 +313,11 @@ flags |= O_BINARY; #endif +#ifdef O_APPEND + if (append) + flags |= O_APPEND; +#endif + if (fd >= 0) { if (check_fd(fd)) goto error; @@ -336,7 +341,6 @@ #endif self->fd = open(name, flags, 0666); Py_END_ALLOW_THREADS - fd_is_own = 1; if (self->fd < 0) { #ifdef MS_WINDOWS if (widename != NULL) @@ -346,29 +350,31 @@ PyErr_SetFromErrnoWithFilename(PyExc_IOError, name); goto error; } + if(dircheck(self, name) < 0) + goto error; } - if (dircheck(self, nameobj) < 0) - goto error; if (PyObject_SetAttrString((PyObject *)self, "name", nameobj) < 0) goto error; - if (self->appending) { + if (append) { /* For consistent behaviour, we explicitly seek to the end of file (otherwise, it might be done only on the first write()). */ PyObject *pos = portable_lseek(self->fd, NULL, 2); - if (pos == NULL) + if (pos == NULL) { + if (closefd) { + close(self->fd); + self->fd = -1; + } goto error; + } Py_DECREF(pos); } goto done; error: - if (!fd_is_own) - self->fd = -1; - ret = -1; done: @@ -527,7 +533,7 @@ { PyObject *result; Py_ssize_t total = 0; - Py_ssize_t n; + int n; if (self->fd < 0) return err_closed(); @@ -549,37 +555,27 @@ } if (PyBytes_GET_SIZE(result) < (Py_ssize_t)newsize) { - if (_PyBytes_Resize(&result, newsize) < 0) - return NULL; /* result has been freed */ + if (_PyBytes_Resize(&result, newsize) < 0) { + if (total == 0) { + Py_DECREF(result); + return NULL; + } + PyErr_Clear(); + break; + } } Py_BEGIN_ALLOW_THREADS errno = 0; - n = newsize - total; -#if defined(MS_WIN64) || defined(MS_WINDOWS) - if (n > INT_MAX) - n = INT_MAX; n = read(self->fd, PyBytes_AS_STRING(result) + total, - (int)n); -#else - n = read(self->fd, - PyBytes_AS_STRING(result) + total, - n); -#endif + newsize - total); Py_END_ALLOW_THREADS if (n == 0) break; if (n < 0) { - if (errno == EINTR) { - if (PyErr_CheckSignals()) { - Py_DECREF(result); - return NULL; - } - continue; - } + if (total > 0) + break; if (errno == EAGAIN) { - if (total > 0) - break; Py_DECREF(result); Py_RETURN_NONE; } @@ -593,6 +589,7 @@ if (PyBytes_GET_SIZE(result) > total) { if (_PyBytes_Resize(&result, total) < 0) { /* This should never happen, but just in case */ + Py_DECREF(result); return NULL; } } @@ -649,8 +646,10 @@ } if (n != size) { - if (_PyBytes_Resize(&bytes, n) < 0) + if (_PyBytes_Resize(&bytes, n) < 0) { + Py_DECREF(bytes); return NULL; + } } return (PyObject *) bytes; @@ -886,13 +885,7 @@ static char * mode_string(fileio *self) { - if (self->appending) { - if (self->readable) - return "ab+"; - else - return "ab"; - } - else if (self->readable) { + if (self->readable) { if (self->writable) return "rb+"; else diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_io/iobase.c --- a/Modules/_io/iobase.c Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/_io/iobase.c Sun Jul 20 10:52:46 2014 -0400 @@ -41,8 +41,8 @@ "bytes. bytearrays are accepted too, and in some cases (such as\n" "readinto) needed. Text I/O classes work with str data.\n" "\n" - "Note that calling any method (except additional calls to close(),\n" - "which are ignored) on a closed stream should raise a ValueError.\n" + "Note that calling any method (even inquiries) on a closed stream is\n" + "undefined. Implementations may raise IOError in this case.\n" "\n" "IOBase (and its subclasses) support the iterator protocol, meaning\n" "that an IOBase object can be iterated over yielding the lines in a\n" @@ -74,7 +74,7 @@ PyDoc_STRVAR(iobase_seek_doc, "Change stream position.\n" "\n" - "Change the stream position to the given byte offset. The offset is\n" + "Change the stream position to byte offset offset. offset is\n" "interpreted relative to the position indicated by whence. Values\n" "for whence are:\n" "\n" @@ -437,7 +437,7 @@ "\n" "If limit is specified, at most limit bytes will be read.\n" "\n" - "The line terminator is always b'\\n' for binary files; for text\n" + "The line terminator is always b'\n' for binary files; for text\n" "files, the newlines argument to open can be used to select the line\n" "terminator(s) recognized.\n"); @@ -468,14 +468,8 @@ if (has_peek) { PyObject *readahead = PyObject_CallMethod(self, "peek", "i", 1); - if (readahead == NULL) { - /* NOTE: PyErr_SetFromErrno() calls PyErr_CheckSignals() - when EINTR occurs so we needn't do it ourselves. */ - if (_PyIO_trap_eintr()) { - continue; - } + if (readahead == NULL) goto fail; - } if (!PyBytes_Check(readahead)) { PyErr_Format(PyExc_IOError, "peek() should have returned a bytes object, " @@ -508,14 +502,8 @@ } b = PyObject_CallMethod(self, "read", "n", nreadahead); - if (b == NULL) { - /* NOTE: PyErr_SetFromErrno() calls PyErr_CheckSignals() - when EINTR occurs so we needn't do it ourselves. */ - if (_PyIO_trap_eintr()) { - continue; - } + if (b == NULL) goto fail; - } if (!PyBytes_Check(b)) { PyErr_Format(PyExc_IOError, "read() should have returned a bytes object, " @@ -660,10 +648,7 @@ break; /* Stop Iteration */ } - res = NULL; - do { - res = PyObject_CallMethodObjArgs(self, _PyIO_str_write, line, NULL); - } while (res == NULL && _PyIO_trap_eintr()); + res = PyObject_CallMethodObjArgs(self, _PyIO_str_write, line, NULL); Py_DECREF(line); if (res == NULL) { Py_DECREF(iter); @@ -826,11 +811,6 @@ PyObject *data = PyObject_CallMethod(self, "read", "i", DEFAULT_BUFFER_SIZE); if (!data) { - /* NOTE: PyErr_SetFromErrno() calls PyErr_CheckSignals() - when EINTR occurs so we needn't do it ourselves. */ - if (_PyIO_trap_eintr()) { - continue; - } Py_DECREF(chunks); return NULL; } diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_io/stringio.c --- a/Modules/_io/stringio.c Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/_io/stringio.c Sun Jul 20 10:52:46 2014 -0400 @@ -632,21 +632,10 @@ } /* Properties and pseudo-properties */ - -PyDoc_STRVAR(stringio_readable_doc, -"readable() -> bool. Returns True if the IO object can be read."); - -PyDoc_STRVAR(stringio_writable_doc, -"writable() -> bool. Returns True if the IO object can be written."); - -PyDoc_STRVAR(stringio_seekable_doc, -"seekable() -> bool. Returns True if the IO object can be seeked."); - static PyObject * stringio_seekable(stringio *self, PyObject *args) { CHECK_INITIALIZED(self); - CHECK_CLOSED(self); Py_RETURN_TRUE; } @@ -654,7 +643,6 @@ stringio_readable(stringio *self, PyObject *args) { CHECK_INITIALIZED(self); - CHECK_CLOSED(self); Py_RETURN_TRUE; } @@ -662,7 +650,6 @@ stringio_writable(stringio *self, PyObject *args) { CHECK_INITIALIZED(self); - CHECK_CLOSED(self); Py_RETURN_TRUE; } @@ -830,9 +817,9 @@ {"seek", (PyCFunction)stringio_seek, METH_VARARGS, stringio_seek_doc}, {"write", (PyCFunction)stringio_write, METH_O, stringio_write_doc}, - {"seekable", (PyCFunction)stringio_seekable, METH_NOARGS, stringio_seekable_doc}, - {"readable", (PyCFunction)stringio_readable, METH_NOARGS, stringio_readable_doc}, - {"writable", (PyCFunction)stringio_writable, METH_NOARGS, stringio_writable_doc}, + {"seekable", (PyCFunction)stringio_seekable, METH_NOARGS}, + {"readable", (PyCFunction)stringio_readable, METH_NOARGS}, + {"writable", (PyCFunction)stringio_writable, METH_NOARGS}, {"__getstate__", (PyCFunction)stringio_getstate, METH_NOARGS}, {"__setstate__", (PyCFunction)stringio_setstate, METH_O}, diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_io/textio.c --- a/Modules/_io/textio.c Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/_io/textio.c Sun Jul 20 10:52:46 2014 -0400 @@ -236,21 +236,6 @@ Py_TYPE(self)->tp_free((PyObject *)self); } -static int -check_decoded(PyObject *decoded) -{ - if (decoded == NULL) - return -1; - if (!PyUnicode_Check(decoded)) { - PyErr_Format(PyExc_TypeError, - "decoder should return a string result, not '%.200s'", - Py_TYPE(decoded)->tp_name); - Py_DECREF(decoded); - return -1; - } - return 0; -} - #define SEEN_CR 1 #define SEEN_LF 2 #define SEEN_CRLF 4 @@ -280,9 +265,15 @@ Py_INCREF(output); } - if (check_decoded(output) < 0) + if (output == NULL) return NULL; + if (!PyUnicode_Check(output)) { + PyErr_SetString(PyExc_TypeError, + "decoder should return a string result"); + goto error; + } + output_len = PyUnicode_GET_SIZE(output); if (self->pendingcr && (final || output_len > 0)) { Py_UNICODE *out; @@ -631,22 +622,15 @@ "errors determines the strictness of encoding and decoding (see the\n" "codecs.register) and defaults to \"strict\".\n" "\n" - "newline controls how line endings are handled. It can be None, '',\n" - "'\\n', '\\r', and '\\r\\n'. It works as follows:\n" - "\n" - "* On input, if newline is None, universal newlines mode is\n" - " enabled. Lines in the input can end in '\\n', '\\r', or '\\r\\n', and\n" - " these are translated into '\\n' before being returned to the\n" - " caller. If it is '', universal newline mode is enabled, but line\n" - " endings are returned to the caller untranslated. If it has any of\n" - " the other legal values, input lines are only terminated by the given\n" - " string, and the line ending is returned to the caller untranslated.\n" - "\n" - "* On output, if newline is None, any '\\n' characters written are\n" - " translated to the system default line separator, os.linesep. If\n" - " newline is '', no translation takes place. If newline is any of the\n" - " other legal values, any '\\n' characters written are translated to\n" - " the given string.\n" + "newline can be None, '', '\\n', '\\r', or '\\r\\n'. It controls the\n" + "handling of line endings. If it is None, universal newlines is\n" + "enabled. With this enabled, on input, the lines endings '\\n', '\\r',\n" + "or '\\r\\n' are translated to '\\n' before being returned to the\n" + "caller. Conversely, on output, '\\n' is translated to the system\n" + "default line seperator, os.linesep. If newline is any other of its\n" + "legal values, that newline becomes the newline when the file is read\n" + "and it is returned untranslated. On output, '\\n' is converted to the\n" + "newline.\n" "\n" "If line_buffering is True, a call to flush is implied when a call to\n" "write contains a newline character." @@ -1022,11 +1006,8 @@ res = PyObject_CallMethod(buffer, "seekable", NULL); if (res == NULL) goto error; - r = PyObject_IsTrue(res); + self->seekable = self->telling = PyObject_IsTrue(res); Py_DECREF(res); - if (r < 0) - goto error; - self->seekable = self->telling = r; self->encoding_start_of_stream = 0; if (self->seekable && self->encoder) { @@ -1222,11 +1203,8 @@ Py_DECREF(pending); if (b == NULL) return -1; - ret = NULL; - do { - ret = PyObject_CallMethodObjArgs(self->buffer, - _PyIO_str_write, b, NULL); - } while (ret == NULL && _PyIO_trap_eintr()); + ret = PyObject_CallMethodObjArgs(self->buffer, + _PyIO_str_write, b, NULL); Py_DECREF(b); if (ret == NULL) return -1; @@ -1426,12 +1404,7 @@ Py_DECREF(chunk_size); if (input_chunk == NULL) goto fail; - if (!PyBytes_Check(input_chunk)) { - PyErr_Format(PyExc_TypeError, - "underlying read1() should have returned a bytes object, " - "not '%.200s'", Py_TYPE(input_chunk)->tp_name); - goto fail; - } + assert(PyBytes_Check(input_chunk)); eof = (PyBytes_Size(input_chunk) == 0); @@ -1444,7 +1417,8 @@ _PyIO_str_decode, input_chunk, eof ? Py_True : Py_False, NULL); } - if (check_decoded(decoded_chars) < 0) + /* TODO sanity check: isinstance(decoded_chars, unicode) */ + if (decoded_chars == NULL) goto fail; textiowrapper_set_decoded_chars(self, decoded_chars); if (PyUnicode_GET_SIZE(decoded_chars) > 0) @@ -1457,14 +1431,7 @@ PyObject *next_input = PyNumber_Add(dec_buffer, input_chunk); if (next_input == NULL) goto fail; - if (!PyBytes_Check(next_input)) { - PyErr_Format(PyExc_TypeError, - "decoder getstate() should have returned a bytes " - "object, not '%.200s'", - Py_TYPE(next_input)->tp_name); - Py_DECREF(next_input); - goto fail; - } + assert (PyBytes_Check(next_input)); Py_DECREF(dec_buffer); Py_CLEAR(self->snapshot); self->snapshot = Py_BuildValue("NN", dec_flags, next_input); @@ -1510,7 +1477,7 @@ decoded = PyObject_CallMethodObjArgs(self->decoder, _PyIO_str_decode, bytes, Py_True, NULL); Py_DECREF(bytes); - if (check_decoded(decoded) < 0) + if (decoded == NULL) goto fail; result = textiowrapper_get_decoded_chars(self, -1); @@ -1541,14 +1508,8 @@ /* Keep reading chunks until we have n characters to return */ while (remaining > 0) { res = textiowrapper_read_chunk(self); - if (res < 0) { - /* NOTE: PyErr_SetFromErrno() calls PyErr_CheckSignals() - when EINTR occurs so we needn't do it ourselves. */ - if (_PyIO_trap_eintr()) { - continue; - } + if (res < 0) goto fail; - } if (res == 0) /* EOF */ break; if (chunks == NULL) { @@ -1707,14 +1668,8 @@ while (!self->decoded_chars || !PyUnicode_GET_SIZE(self->decoded_chars)) { res = textiowrapper_read_chunk(self); - if (res < 0) { - /* NOTE: PyErr_SetFromErrno() calls PyErr_CheckSignals() - when EINTR occurs so we needn't do it ourselves. */ - if (_PyIO_trap_eintr()) { - continue; - } + if (res < 0) goto error; - } if (res == 0) break; } @@ -2130,14 +2085,7 @@ if (input_chunk == NULL) goto fail; - if (!PyBytes_Check(input_chunk)) { - PyErr_Format(PyExc_TypeError, - "underlying read() should have returned a bytes " - "object, not '%.200s'", - Py_TYPE(input_chunk)->tp_name); - Py_DECREF(input_chunk); - goto fail; - } + assert (PyBytes_Check(input_chunk)); self->snapshot = Py_BuildValue("iN", cookie.dec_flags, input_chunk); if (self->snapshot == NULL) { @@ -2148,7 +2096,7 @@ decoded = PyObject_CallMethod(self->decoder, "decode", "Oi", input_chunk, (int)cookie.need_eof); - if (check_decoded(decoded) < 0) + if (decoded == NULL) goto fail; textiowrapper_set_decoded_chars(self, decoded); @@ -2271,9 +2219,10 @@ int dec_flags; PyObject *decoded = PyObject_CallMethod( - self->decoder, "decode", "s#", input, (Py_ssize_t)1); - if (check_decoded(decoded) < 0) + self->decoder, "decode", "s#", input, 1); + if (decoded == NULL) goto fail; + assert (PyUnicode_Check(decoded)); chars_decoded += PyUnicode_GET_SIZE(decoded); Py_DECREF(decoded); @@ -2305,8 +2254,9 @@ /* We didn't get enough decoded data; signal EOF to get more. */ PyObject *decoded = PyObject_CallMethod( self->decoder, "decode", "si", "", /* final = */ 1); - if (check_decoded(decoded) < 0) + if (decoded == NULL) goto fail; + assert (PyUnicode_Check(decoded)); chars_decoded += PyUnicode_GET_SIZE(decoded); Py_DECREF(decoded); cookie.need_eof = 1; @@ -2465,31 +2415,19 @@ Py_DECREF(res); if (r < 0) return NULL; - + if (r > 0) { Py_RETURN_NONE; /* stream already closed */ } else { - PyObject *exc = NULL, *val, *tb; res = PyObject_CallMethod((PyObject *)self, "flush", NULL); - if (res == NULL) - PyErr_Fetch(&exc, &val, &tb); + if (res == NULL) { + return NULL; + } else Py_DECREF(res); - res = PyObject_CallMethod(self->buffer, "close", NULL); - if (exc != NULL) { - if (res != NULL) { - Py_CLEAR(res); - PyErr_Restore(exc, val, tb); - } - else { - Py_DECREF(exc); - Py_XDECREF(val); - Py_XDECREF(tb); - } - } - return res; + return PyObject_CallMethod(self->buffer, "close", NULL); } } diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_json.c --- a/Modules/_json.c Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/_json.c Sun Jul 20 10:52:46 2014 -0400 @@ -524,10 +524,16 @@ } #ifdef Py_UNICODE_WIDE /* Surrogate pair */ - if ((c & 0xfc00) == 0xd800 && end + 6 < len && - buf[next++] == '\\' && - buf[next++] == 'u') { + if ((c & 0xfc00) == 0xd800) { Py_UNICODE c2 = 0; + if (end + 6 >= len) { + raise_errmsg("Unpaired high surrogate", pystr, end - 5); + goto bail; + } + if (buf[next++] != '\\' || buf[next++] != 'u') { + raise_errmsg("Unpaired high surrogate", pystr, end - 5); + goto bail; + } end += 6; /* Decode 4 hex digits */ for (; next < end; next++) { @@ -548,10 +554,15 @@ goto bail; } } - if ((c2 & 0xfc00) == 0xdc00) - c = 0x10000 + (((c - 0xd800) << 10) | (c2 - 0xdc00)); - else - end -= 6; + if ((c2 & 0xfc00) != 0xdc00) { + raise_errmsg("Unpaired high surrogate", pystr, end - 5); + goto bail; + } + c = 0x10000 + (((c - 0xd800) << 10) | (c2 - 0xdc00)); + } + else if ((c & 0xfc00) == 0xdc00) { + raise_errmsg("Unpaired low surrogate", pystr, end - 5); + goto bail; } #endif } @@ -692,9 +703,16 @@ } #ifdef Py_UNICODE_WIDE /* Surrogate pair */ - if ((c & 0xfc00) == 0xd800 && end + 6 < len && - buf[next++] == '\\' && buf[next++] == 'u') { + if ((c & 0xfc00) == 0xd800) { Py_UNICODE c2 = 0; + if (end + 6 >= len) { + raise_errmsg("Unpaired high surrogate", pystr, end - 5); + goto bail; + } + if (buf[next++] != '\\' || buf[next++] != 'u') { + raise_errmsg("Unpaired high surrogate", pystr, end - 5); + goto bail; + } end += 6; /* Decode 4 hex digits */ for (; next < end; next++) { @@ -715,10 +733,15 @@ goto bail; } } - if ((c2 & 0xfc00) == 0xdc00) - c = 0x10000 + (((c - 0xd800) << 10) | (c2 - 0xdc00)); - else - end -= 6; + if ((c2 & 0xfc00) != 0xdc00) { + raise_errmsg("Unpaired high surrogate", pystr, end - 5); + goto bail; + } + c = 0x10000 + (((c - 0xd800) << 10) | (c2 - 0xdc00)); + } + else if ((c & 0xfc00) == 0xdc00) { + raise_errmsg("Unpaired low surrogate", pystr, end - 5); + goto bail; } #endif } @@ -1009,7 +1032,7 @@ while (idx <= end_idx) { /* read key */ if (str[idx] != '"') { - raise_errmsg("Expecting property name enclosed in double quotes", pystr, idx); + raise_errmsg("Expecting property name", pystr, idx); goto bail; } key = scanstring_unicode(pystr, idx + 1, strict, &next_idx); @@ -1020,7 +1043,7 @@ /* skip whitespace between key and : delimiter, read :, skip whitespace */ while (idx <= end_idx && IS_WHITESPACE(str[idx])) idx++; if (idx > end_idx || str[idx] != ':') { - raise_errmsg("Expecting ':' delimiter", pystr, idx); + raise_errmsg("Expecting : delimiter", pystr, idx); goto bail; } idx++; @@ -1052,7 +1075,7 @@ break; } else if (str[idx] != ',') { - raise_errmsg("Expecting ',' delimiter", pystr, idx); + raise_errmsg("Expecting , delimiter", pystr, idx); goto bail; } idx++; @@ -1213,7 +1236,7 @@ break; } else if (str[idx] != ',') { - raise_errmsg("Expecting ',' delimiter", pystr, idx); + raise_errmsg("Expecting , delimiter", pystr, idx); goto bail; } idx++; @@ -1468,10 +1491,6 @@ PyObject *res; char *str = PyString_AS_STRING(pystr); Py_ssize_t length = PyString_GET_SIZE(pystr); - if (idx < 0) { - PyErr_SetString(PyExc_ValueError, "idx cannot be negative"); - return NULL; - } if (idx >= length) { PyErr_SetNone(PyExc_StopIteration); return NULL; @@ -1559,10 +1578,6 @@ PyObject *res; Py_UNICODE *str = PyUnicode_AS_UNICODE(pystr); Py_ssize_t length = PyUnicode_GET_SIZE(pystr); - if (idx < 0) { - PyErr_SetString(PyExc_ValueError, "idx cannot be negative"); - return NULL; - } if (idx >= length) { PyErr_SetNone(PyExc_StopIteration); return NULL; @@ -1710,15 +1725,8 @@ Py_DECREF(s->encoding); s->encoding = tmp; } - if (s->encoding == NULL) + if (s->encoding == NULL || !PyString_Check(s->encoding)) goto bail; - if (!PyString_Check(s->encoding)) { - PyErr_Format(PyExc_TypeError, - "encoding must be a string, not %.80s", - Py_TYPE(s->encoding)->tp_name); - goto bail; - } - /* All of these will fail "gracefully" so we don't need to verify them */ s->strict = PyObject_GetAttrString(ctx, "strict"); @@ -2209,6 +2217,8 @@ static PyObject *empty_array = NULL; PyObject *ident = NULL; PyObject *s_fast = NULL; + Py_ssize_t num_items; + PyObject **seq_items; Py_ssize_t i; if (open_array == NULL || close_array == NULL || empty_array == NULL) { @@ -2222,7 +2232,8 @@ s_fast = PySequence_Fast(seq, "_iterencode_list needs a sequence"); if (s_fast == NULL) return -1; - if (PySequence_Fast_GET_SIZE(s_fast) == 0) { + num_items = PySequence_Fast_GET_SIZE(s_fast); + if (num_items == 0) { Py_DECREF(s_fast); return PyList_Append(rval, empty_array); } @@ -2243,6 +2254,7 @@ } } + seq_items = PySequence_Fast_ITEMS(s_fast); if (PyList_Append(rval, open_array)) goto bail; if (s->indent != Py_None) { @@ -2254,8 +2266,8 @@ buf += newline_indent */ } - for (i = 0; i < PySequence_Fast_GET_SIZE(s_fast); i++) { - PyObject *obj = PySequence_Fast_GET_ITEM(s_fast, i); + for (i = 0; i < num_items; i++) { + PyObject *obj = seq_items[i]; if (i) { if (PyList_Append(rval, s->item_separator)) goto bail; diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_math.c --- a/Modules/_math.c Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/_math.c Sun Jul 20 10:52:46 2014 -0400 @@ -189,27 +189,6 @@ significant loss of precision that arises from direct evaluation when x is small. */ -#ifdef HAVE_LOG1P - -double -_Py_log1p(double x) -{ - /* Some platforms supply a log1p function but don't respect the sign of - zero: log1p(-0.0) gives 0.0 instead of the correct result of -0.0. - - To save fiddling with configure tests and platform checks, we handle the - special case of zero input directly on all platforms. - */ - if (x == 0.0) { - return x; - } - else { - return log1p(x); - } -} - -#else - double _Py_log1p(double x) { @@ -251,5 +230,3 @@ return log(1.+x); } } - -#endif /* ifdef HAVE_LOG1P */ diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_math.h --- a/Modules/_math.h Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/_math.h Sun Jul 20 10:52:46 2014 -0400 @@ -36,6 +36,10 @@ #define m_expm1 _Py_expm1 #endif -/* Use the substitute from _math.c on all platforms: - it includes workarounds for buggy handling of zeros. */ +#ifdef HAVE_LOG1P +#define m_log1p log1p +#else +/* if the system doesn't have log1p, use the substitute + function defined in Modules/_math.c. */ #define m_log1p _Py_log1p +#endif diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_multiprocessing/multiprocessing.c --- a/Modules/_multiprocessing/multiprocessing.c Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/_multiprocessing/multiprocessing.c Sun Jul 20 10:52:46 2014 -0400 @@ -8,7 +8,7 @@ #include "multiprocessing.h" -#if (defined(CMSG_LEN) && defined(SCM_RIGHTS)) +#ifdef SCM_RIGHTS #define HAVE_FD_TRANSFER 1 #else #define HAVE_FD_TRANSFER 0 @@ -63,7 +63,7 @@ break; default: PyErr_Format(PyExc_RuntimeError, - "unknown error number %d", num); + "unkown error number %d", num); } return NULL; } diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_multiprocessing/semaphore.c --- a/Modules/_multiprocessing/semaphore.c Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/_multiprocessing/semaphore.c Sun Jul 20 10:52:46 2014 -0400 @@ -197,13 +197,6 @@ #define SEM_GETVALUE(sem, pval) sem_getvalue(sem, pval) #define SEM_UNLINK(name) sem_unlink(name) -/* OS X 10.4 defines SEM_FAILED as -1 instead of (sem_t *)-1; this gives - compiler warnings, and (potentially) undefined behaviour. */ -#ifdef __APPLE__ -# undef SEM_FAILED -# define SEM_FAILED ((sem_t *)-1) -#endif - #ifndef HAVE_SEM_UNLINK # define sem_unlink(name) 0 #endif diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_multiprocessing/socket_connection.c --- a/Modules/_multiprocessing/socket_connection.c Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/_multiprocessing/socket_connection.c Sun Jul 20 10:52:46 2014 -0400 @@ -8,10 +8,6 @@ #include "multiprocessing.h" -#if defined(HAVE_POLL) && !defined(HAVE_BROKEN_POLL) -# include "poll.h" -#endif - #ifdef MS_WINDOWS # define WRITE(h, buffer, length) send((SOCKET)h, buffer, length, 0) # define READ(h, buffer, length) recv((SOCKET)h, buffer, length, 0) @@ -23,21 +19,6 @@ #endif /* - * Wrapper for PyErr_CheckSignals() which can be called without the GIL - */ - -static int -check_signals(void) -{ - PyGILState_STATE state; - int res; - state = PyGILState_Ensure(); - res = PyErr_CheckSignals(); - PyGILState_Release(state); - return res; -} - -/* * Send string to file descriptor */ @@ -49,14 +30,8 @@ while (length > 0) { res = WRITE(h, p, length); - if (res < 0) { - if (errno == EINTR) { - if (check_signals() < 0) - return MP_EXCEPTION_HAS_BEEN_SET; - continue; - } + if (res < 0) return MP_SOCKET_ERROR; - } length -= res; p += res; } @@ -77,16 +52,12 @@ while (remaining > 0) { temp = READ(h, p, remaining); - if (temp < 0) { - if (errno == EINTR) { - if (check_signals() < 0) - return MP_EXCEPTION_HAS_BEEN_SET; - continue; - } - return temp; - } - else if (temp == 0) { - return remaining == length ? MP_END_OF_FILE : MP_EARLY_END_OF_FILE; + if (temp <= 0) { + if (temp == 0) + return remaining == length ? + MP_END_OF_FILE : MP_EARLY_END_OF_FILE; + else + return temp; } remaining -= temp; p += temp; @@ -146,7 +117,7 @@ conn_recv_string(ConnectionObject *conn, char *buffer, size_t buflength, char **newbuffer, size_t maxlength) { - Py_ssize_t res; + int res; UINT32 ulength; *newbuffer = NULL; @@ -161,23 +132,20 @@ if (ulength > maxlength) return MP_BAD_MESSAGE_LENGTH; - if (ulength > buflength) { - *newbuffer = buffer = PyMem_Malloc((size_t)ulength); - if (buffer == NULL) + if (ulength <= buflength) { + Py_BEGIN_ALLOW_THREADS + res = _conn_recvall(conn->handle, buffer, (size_t)ulength); + Py_END_ALLOW_THREADS + return res < 0 ? res : ulength; + } else { + *newbuffer = PyMem_Malloc((size_t)ulength); + if (*newbuffer == NULL) return MP_MEMORY_ERROR; + Py_BEGIN_ALLOW_THREADS + res = _conn_recvall(conn->handle, *newbuffer, (size_t)ulength); + Py_END_ALLOW_THREADS + return res < 0 ? (Py_ssize_t)res : (Py_ssize_t)ulength; } - - Py_BEGIN_ALLOW_THREADS - res = _conn_recvall(conn->handle, buffer, (size_t)ulength); - Py_END_ALLOW_THREADS - - if (res >= 0) { - res = (Py_ssize_t)ulength; - } else if (*newbuffer != NULL) { - PyMem_Free(*newbuffer); - *newbuffer = NULL; - } - return res; } /* @@ -187,41 +155,6 @@ static int conn_poll(ConnectionObject *conn, double timeout, PyThreadState *_save) { -#if defined(HAVE_POLL) && !defined(HAVE_BROKEN_POLL) - int res; - struct pollfd p; - - p.fd = (int)conn->handle; - p.events = POLLIN | POLLPRI; - p.revents = 0; - - if (timeout < 0) { - do { - res = poll(&p, 1, -1); - } while (res < 0 && errno == EINTR); - } else { - res = poll(&p, 1, (int)(timeout * 1000 + 0.5)); - if (res < 0 && errno == EINTR) { - /* We were interrupted by a signal. Just indicate a - timeout even though we are early. */ - return FALSE; - } - } - - if (res < 0) { - return MP_SOCKET_ERROR; - } else if (p.revents & (POLLNVAL|POLLERR)) { - Py_BLOCK_THREADS - PyErr_SetString(PyExc_IOError, "poll() gave POLLNVAL or POLLERR"); - Py_UNBLOCK_THREADS - return MP_EXCEPTION_HAS_BEEN_SET; - } else if (p.revents != 0) { - return TRUE; - } else { - assert(res == 0); - return FALSE; - } -#else int res; fd_set rfds; @@ -241,19 +174,12 @@ FD_SET((SOCKET)conn->handle, &rfds); if (timeout < 0.0) { - do { - res = select((int)conn->handle+1, &rfds, NULL, NULL, NULL); - } while (res < 0 && errno == EINTR); + res = select((int)conn->handle+1, &rfds, NULL, NULL, NULL); } else { struct timeval tv; tv.tv_sec = (long)timeout; tv.tv_usec = (long)((timeout - tv.tv_sec) * 1e6 + 0.5); res = select((int)conn->handle+1, &rfds, NULL, NULL, &tv); - if (res < 0 && errno == EINTR) { - /* We were interrupted by a signal. Just indicate a - timeout even though we are early. */ - return FALSE; - } } if (res < 0) { @@ -264,7 +190,6 @@ assert(res == 0); return FALSE; } -#endif } /* diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_multiprocessing/win32_functions.c --- a/Modules/_multiprocessing/win32_functions.c Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/_multiprocessing/win32_functions.c Sun Jul 20 10:52:46 2014 -0400 @@ -244,7 +244,6 @@ Py_INCREF(&Win32Type); WIN32_CONSTANT(F_DWORD, ERROR_ALREADY_EXISTS); - WIN32_CONSTANT(F_DWORD, ERROR_NO_DATA); WIN32_CONSTANT(F_DWORD, ERROR_PIPE_BUSY); WIN32_CONSTANT(F_DWORD, ERROR_PIPE_CONNECTED); WIN32_CONSTANT(F_DWORD, ERROR_SEM_TIMEOUT); diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_randommodule.c --- a/Modules/_randommodule.c Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/_randommodule.c Sun Jul 20 10:52:46 2014 -0400 @@ -400,7 +400,7 @@ long i, j; PyObject *iobj; PyObject *remobj; - unsigned long *mt, tmp, nonzero; + unsigned long *mt, tmp; if (!PyInt_Check(n) && !PyLong_Check(n)) { PyErr_Format(PyExc_TypeError, "jumpahead requires an " @@ -427,23 +427,8 @@ mt[j] = tmp; } - nonzero = 0; - for (i = 1; i < N; i++) { + for (i = 0; i < N; i++) mt[i] += i+1; - mt[i] &= 0xffffffffUL; /* for WORDSIZE > 32 machines */ - nonzero |= mt[i]; - } - - /* Ensure the state is nonzero: in the unlikely event that mt[1] through - mt[N-1] are all zero, set the MSB of mt[0] (see issue #14591). In the - normal case, we fall back to the pre-issue 14591 behaviour for mt[0]. */ - if (nonzero) { - mt[0] += 1; - mt[0] &= 0xffffffffUL; /* for WORDSIZE > 32 machines */ - } - else { - mt[0] = 0x80000000UL; - } self->index = N; Py_INCREF(Py_None); diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_sqlite/connection.c --- a/Modules/_sqlite/connection.c Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/_sqlite/connection.c Sun Jul 20 10:52:46 2014 -0400 @@ -152,10 +152,7 @@ Py_INCREF(isolation_level); } self->isolation_level = NULL; - if (pysqlite_connection_set_isolation_level(self, isolation_level) < 0) { - Py_DECREF(isolation_level); - return -1; - } + pysqlite_connection_set_isolation_level(self, isolation_level); Py_DECREF(isolation_level); self->statement_cache = (pysqlite_Cache*)PyObject_CallFunction((PyObject*)&pysqlite_CacheType, "Oi", self, cached_statements); @@ -369,7 +366,8 @@ if (self->apsw_connection) { ret = PyObject_CallMethod(self->apsw_connection, "close", ""); Py_XDECREF(ret); - Py_CLEAR(self->apsw_connection); + Py_XDECREF(self->apsw_connection); + self->apsw_connection = NULL; self->db = NULL; } else { Py_BEGIN_ALLOW_THREADS @@ -540,40 +538,39 @@ } } -static int -_pysqlite_set_result(sqlite3_context* context, PyObject* py_val) +void _pysqlite_set_result(sqlite3_context* context, PyObject* py_val) { - if (py_val == Py_None) { + long longval; + const char* buffer; + Py_ssize_t buflen; + PyObject* stringval; + + if ((!py_val) || PyErr_Occurred()) { + sqlite3_result_null(context); + } else if (py_val == Py_None) { sqlite3_result_null(context); } else if (PyInt_Check(py_val)) { - sqlite3_result_int64(context, (sqlite_int64)PyInt_AsLong(py_val)); - } else if (PyLong_Check(py_val)) { - sqlite_int64 value = _pysqlite_long_as_int64(py_val); - if (value == -1 && PyErr_Occurred()) - return -1; - sqlite3_result_int64(context, value); + longval = PyInt_AsLong(py_val); + sqlite3_result_int64(context, (PY_LONG_LONG)longval); } else if (PyFloat_Check(py_val)) { sqlite3_result_double(context, PyFloat_AsDouble(py_val)); } else if (PyBuffer_Check(py_val)) { - const char* buffer; - Py_ssize_t buflen; if (PyObject_AsCharBuffer(py_val, &buffer, &buflen) != 0) { PyErr_SetString(PyExc_ValueError, "could not convert BLOB to buffer"); - return -1; + } else { + sqlite3_result_blob(context, buffer, buflen, SQLITE_TRANSIENT); } - sqlite3_result_blob(context, buffer, buflen, SQLITE_TRANSIENT); } else if (PyString_Check(py_val)) { sqlite3_result_text(context, PyString_AsString(py_val), -1, SQLITE_TRANSIENT); } else if (PyUnicode_Check(py_val)) { - PyObject * stringval = PyUnicode_AsUTF8String(py_val); - if (!stringval) - return -1; - sqlite3_result_text(context, PyString_AsString(stringval), -1, SQLITE_TRANSIENT); - Py_DECREF(stringval); + stringval = PyUnicode_AsUTF8String(py_val); + if (stringval) { + sqlite3_result_text(context, PyString_AsString(stringval), -1, SQLITE_TRANSIENT); + Py_DECREF(stringval); + } } else { - return -1; + /* TODO: raise error */ } - return 0; } PyObject* _pysqlite_build_py_params(sqlite3_context *context, int argc, sqlite3_value** argv) @@ -583,6 +580,7 @@ sqlite3_value* cur_value; PyObject* cur_py_value; const char* val_str; + PY_LONG_LONG val_int; Py_ssize_t buflen; void* raw_buffer; @@ -595,7 +593,8 @@ cur_value = argv[i]; switch (sqlite3_value_type(argv[i])) { case SQLITE_INTEGER: - cur_py_value = _pysqlite_long_from_int64(sqlite3_value_int64(cur_value)); + val_int = sqlite3_value_int64(cur_value); + cur_py_value = PyInt_FromLong((long)val_int); break; case SQLITE_FLOAT: cur_py_value = PyFloat_FromDouble(sqlite3_value_double(cur_value)); @@ -646,7 +645,6 @@ PyObject* args; PyObject* py_func; PyObject* py_retval = NULL; - int ok; #ifdef WITH_THREAD PyGILState_STATE threadstate; @@ -662,12 +660,10 @@ Py_DECREF(args); } - ok = 0; if (py_retval) { - ok = _pysqlite_set_result(context, py_retval) == 0; + _pysqlite_set_result(context, py_retval); Py_DECREF(py_retval); - } - if (!ok) { + } else { if (_enable_callback_tracebacks) { PyErr_Print(); } else { @@ -747,9 +743,8 @@ void _pysqlite_final_callback(sqlite3_context* context) { - PyObject* function_result; + PyObject* function_result = NULL; PyObject** aggregate_instance; - int ok; #ifdef WITH_THREAD PyGILState_STATE threadstate; @@ -766,23 +761,21 @@ } function_result = PyObject_CallMethod(*aggregate_instance, "finalize", ""); - Py_DECREF(*aggregate_instance); - - ok = 0; - if (function_result) { - ok = _pysqlite_set_result(context, function_result) == 0; - Py_DECREF(function_result); - } - if (!ok) { + if (!function_result) { if (_enable_callback_tracebacks) { PyErr_Print(); } else { PyErr_Clear(); } _sqlite3_result_error(context, "user-defined aggregate's 'finalize' method raised error", -1); + } else { + _pysqlite_set_result(context, function_result); } error: + Py_XDECREF(*aggregate_instance); + Py_XDECREF(function_result); + #ifdef WITH_THREAD PyGILState_Release(threadstate); #endif @@ -939,9 +932,7 @@ rc = SQLITE_DENY; } else { if (PyInt_Check(ret)) { - rc = _PyInt_AsInt(ret); - if (rc == -1 && PyErr_Occurred()) - rc = SQLITE_DENY; + rc = (int)PyInt_AsLong(ret); } else { rc = SQLITE_DENY; } @@ -973,7 +964,7 @@ } /* abort query if error occurred */ - rc = 1; + rc = 1; } else { rc = (int)PyObject_IsTrue(ret); Py_DECREF(ret); @@ -1343,7 +1334,6 @@ PyGILState_STATE gilstate; #endif PyObject* retval = NULL; - long longval; int result = 0; #ifdef WITH_THREAD gilstate = PyGILState_Ensure(); @@ -1367,17 +1357,10 @@ goto finally; } - longval = PyLong_AsLongAndOverflow(retval, &result); - if (longval == -1 && PyErr_Occurred()) { - PyErr_Clear(); + result = PyInt_AsLong(retval); + if (PyErr_Occurred()) { result = 0; } - else if (!result) { - if (longval > 0) - result = 1; - else if (longval < 0) - result = -1; - } finally: Py_XDECREF(string1); diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_sqlite/cursor.c --- a/Modules/_sqlite/cursor.c Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/_sqlite/cursor.c Sun Jul 20 10:52:46 2014 -0400 @@ -26,6 +26,14 @@ #include "util.h" #include "sqlitecompat.h" +/* used to decide wether to call PyInt_FromLong or PyLong_FromLongLong */ +#ifndef INT32_MIN +#define INT32_MIN (-2147483647 - 1) +#endif +#ifndef INT32_MAX +#define INT32_MAX 2147483647 +#endif + PyObject* pysqlite_cursor_iternext(pysqlite_Cursor* self); static char* errmsg_fetch_across_rollback = "Cursor needed to be reset because of commit/rollback and can no longer be fetched from."; @@ -231,7 +239,8 @@ if (converter != Py_None) { Py_DECREF(converter); } - Py_CLEAR(self->row_cast_map); + Py_XDECREF(self->row_cast_map); + self->row_cast_map = NULL; return -1; } @@ -259,17 +268,16 @@ } } -PyObject* pysqlite_unicode_from_string(const char* val_str, Py_ssize_t size, int optimize) +PyObject* pysqlite_unicode_from_string(const char* val_str, int optimize) { const char* check; - Py_ssize_t pos; int is_ascii = 0; if (optimize) { is_ascii = 1; check = val_str; - for (pos = 0; pos < size; pos++) { + while (*check) { if (*check & 0x80) { is_ascii = 0; break; @@ -280,9 +288,9 @@ } if (is_ascii) { - return PyString_FromStringAndSize(val_str, size); + return PyString_FromString(val_str); } else { - return PyUnicode_DecodeUTF8(val_str, size, NULL); + return PyUnicode_DecodeUTF8(val_str, strlen(val_str), NULL); } } @@ -298,6 +306,7 @@ PyObject* row; PyObject* item = NULL; int coltype; + PY_LONG_LONG intval; PyObject* converter; PyObject* converted; Py_ssize_t nbytes; @@ -356,16 +365,20 @@ Py_INCREF(Py_None); converted = Py_None; } else if (coltype == SQLITE_INTEGER) { - converted = _pysqlite_long_from_int64(sqlite3_column_int64(self->statement->st, i)); + intval = sqlite3_column_int64(self->statement->st, i); + if (intval < INT32_MIN || intval > INT32_MAX) { + converted = PyLong_FromLongLong(intval); + } else { + converted = PyInt_FromLong((long)intval); + } } else if (coltype == SQLITE_FLOAT) { converted = PyFloat_FromDouble(sqlite3_column_double(self->statement->st, i)); } else if (coltype == SQLITE_TEXT) { val_str = (const char*)sqlite3_column_text(self->statement->st, i); - nbytes = sqlite3_column_bytes(self->statement->st, i); if ((self->connection->text_factory == (PyObject*)&PyUnicode_Type) || (self->connection->text_factory == pysqlite_OptimizedUnicode)) { - converted = pysqlite_unicode_from_string(val_str, nbytes, + converted = pysqlite_unicode_from_string(val_str, self->connection->text_factory == pysqlite_OptimizedUnicode ? 1 : 0); if (!converted) { @@ -378,9 +391,9 @@ PyErr_SetString(pysqlite_OperationalError, buf); } } else if (self->connection->text_factory == (PyObject*)&PyString_Type) { - converted = PyString_FromStringAndSize(val_str, nbytes); + converted = PyString_FromString(val_str); } else { - converted = PyObject_CallFunction(self->connection->text_factory, "s#", val_str, nbytes); + converted = PyObject_CallFunction(self->connection->text_factory, "s", val_str); } } else { /* coltype == SQLITE_BLOB */ @@ -428,14 +441,9 @@ if (cur->closed) { PyErr_SetString(pysqlite_ProgrammingError, "Cannot operate on a closed cursor."); return 0; + } else { + return pysqlite_check_thread(cur->connection) && pysqlite_check_connection(cur->connection); } - - if (cur->locked) { - PyErr_SetString(pysqlite_ProgrammingError, "Recursive use of cursors not allowed."); - return 0; - } - - return pysqlite_check_thread(cur->connection) && pysqlite_check_connection(cur->connection); } PyObject* _pysqlite_query_execute(pysqlite_Cursor* self, int multiple, PyObject* args) @@ -451,33 +459,34 @@ PyObject* func_args; PyObject* result; int numcols; + PY_LONG_LONG lastrowid; int statement_type; PyObject* descriptor; PyObject* second_argument = NULL; int allow_8bit_chars; if (!check_cursor(self)) { - goto error; + return NULL; } - self->locked = 1; self->reset = 0; /* Make shooting yourself in the foot with not utf-8 decodable 8-bit-strings harder */ allow_8bit_chars = ((self->connection->text_factory != (PyObject*)&PyUnicode_Type) && (self->connection->text_factory != pysqlite_OptimizedUnicode)); - Py_CLEAR(self->next_row); + Py_XDECREF(self->next_row); + self->next_row = NULL; if (multiple) { /* executemany() */ if (!PyArg_ParseTuple(args, "OO", &operation, &second_argument)) { - goto error; + return NULL; } if (!PyString_Check(operation) && !PyUnicode_Check(operation)) { PyErr_SetString(PyExc_ValueError, "operation parameter must be str or unicode"); - goto error; + return NULL; } if (PyIter_Check(second_argument)) { @@ -488,23 +497,23 @@ /* sequence */ parameters_iter = PyObject_GetIter(second_argument); if (!parameters_iter) { - goto error; + return NULL; } } } else { /* execute() */ if (!PyArg_ParseTuple(args, "O|O", &operation, &second_argument)) { - goto error; + return NULL; } if (!PyString_Check(operation) && !PyUnicode_Check(operation)) { PyErr_SetString(PyExc_ValueError, "operation parameter must be str or unicode"); - goto error; + return NULL; } parameters_list = PyList_New(0); if (!parameters_list) { - goto error; + return NULL; } if (second_argument == NULL) { @@ -730,11 +739,10 @@ Py_DECREF(self->lastrowid); if (!multiple && statement_type == STATEMENT_INSERT) { - sqlite_int64 lastrowid; Py_BEGIN_ALLOW_THREADS lastrowid = sqlite3_last_insert_rowid(self->connection->db); Py_END_ALLOW_THREADS - self->lastrowid = _pysqlite_long_from_int64(lastrowid); + self->lastrowid = PyInt_FromLong((long)lastrowid); } else { Py_INCREF(Py_None); self->lastrowid = Py_None; @@ -751,8 +759,7 @@ * ROLLBACK could have happened */ #ifdef SQLITE_VERSION_NUMBER #if SQLITE_VERSION_NUMBER >= 3002002 - if (self->connection && self->connection->db) - self->connection->inTransaction = !sqlite3_get_autocommit(self->connection->db); + self->connection->inTransaction = !sqlite3_get_autocommit(self->connection->db); #endif #endif @@ -761,8 +768,6 @@ Py_XDECREF(parameters_iter); Py_XDECREF(parameters_list); - self->locked = 0; - if (PyErr_Occurred()) { self->rowcount = -1L; return NULL; @@ -894,7 +899,8 @@ if (!self->next_row) { if (self->statement) { (void)pysqlite_statement_reset(self->statement); - Py_CLEAR(self->statement); + Py_DECREF(self->statement); + self->statement = NULL; } return NULL; } diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_sqlite/cursor.h --- a/Modules/_sqlite/cursor.h Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/_sqlite/cursor.h Sun Jul 20 10:52:46 2014 -0400 @@ -42,7 +42,6 @@ pysqlite_Statement* statement; int closed; int reset; - int locked; int initialized; /* the next row to be returned, NULL if no next row available */ diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_sqlite/row.c --- a/Modules/_sqlite/row.c Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/_sqlite/row.c Sun Jul 20 10:52:46 2014 -0400 @@ -64,16 +64,9 @@ return 0; } -PyObject* pysqlite_row_item(pysqlite_Row* self, Py_ssize_t idx) -{ - PyObject* item = PyTuple_GetItem(self->data, idx); - Py_XINCREF(item); - return item; -} - PyObject* pysqlite_row_subscript(pysqlite_Row* self, PyObject* idx) { - Py_ssize_t _idx; + long _idx; char* key; int nitems, i; char* compare_key; @@ -85,17 +78,11 @@ if (PyInt_Check(idx)) { _idx = PyInt_AsLong(idx); - if (_idx < 0) - _idx += PyTuple_GET_SIZE(self->data); item = PyTuple_GetItem(self->data, _idx); Py_XINCREF(item); return item; } else if (PyLong_Check(idx)) { - _idx = PyNumber_AsSsize_t(idx, PyExc_IndexError); - if (_idx == -1 && PyErr_Occurred()) - return NULL; - if (_idx < 0) - _idx += PyTuple_GET_SIZE(self->data); + _idx = PyLong_AsLong(idx); item = PyTuple_GetItem(self->data, _idx); Py_XINCREF(item); return item; @@ -212,14 +199,6 @@ /* mp_ass_subscript */ (objobjargproc)0, }; -static PySequenceMethods pysqlite_row_as_sequence = { - /* sq_length */ (lenfunc)pysqlite_row_length, - /* sq_concat */ 0, - /* sq_repeat */ 0, - /* sq_item */ (ssizeargfunc)pysqlite_row_item, -}; - - static PyMethodDef pysqlite_row_methods[] = { {"keys", (PyCFunction)pysqlite_row_keys, METH_NOARGS, PyDoc_STR("Returns the keys of the row.")}, @@ -273,6 +252,5 @@ { pysqlite_RowType.tp_new = PyType_GenericNew; pysqlite_RowType.tp_as_mapping = &pysqlite_row_as_mapping; - pysqlite_RowType.tp_as_sequence = &pysqlite_row_as_sequence; return PyType_Ready(&pysqlite_RowType); } diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_sqlite/statement.c --- a/Modules/_sqlite/statement.c Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/_sqlite/statement.c Sun Jul 20 10:52:46 2014 -0400 @@ -26,7 +26,6 @@ #include "connection.h" #include "microprotocols.h" #include "prepare_protocol.h" -#include "util.h" #include "sqlitecompat.h" /* prototypes */ @@ -102,6 +101,8 @@ int pysqlite_statement_bind_parameter(pysqlite_Statement* self, int pos, PyObject* parameter, int allow_8bit_chars) { int rc = SQLITE_OK; + long longval; + PY_LONG_LONG longlongval; const char* buffer; char* string; Py_ssize_t buflen; @@ -152,30 +153,26 @@ } switch (paramtype) { - case TYPE_INT: { - long longval = PyInt_AsLong(parameter); - rc = sqlite3_bind_int64(self->st, pos, longval); + case TYPE_INT: + longval = PyInt_AsLong(parameter); + rc = sqlite3_bind_int64(self->st, pos, (sqlite_int64)longval); break; - } - case TYPE_LONG: { - sqlite_int64 value = _pysqlite_long_as_int64(parameter); - if (value == -1 && PyErr_Occurred()) - rc = -1; - else - rc = sqlite3_bind_int64(self->st, pos, (sqlite_int64)value); + case TYPE_LONG: + longlongval = PyLong_AsLongLong(parameter); + /* in the overflow error case, longlongval is -1, and an exception is set */ + rc = sqlite3_bind_int64(self->st, pos, (sqlite_int64)longlongval); break; - } case TYPE_FLOAT: rc = sqlite3_bind_double(self->st, pos, PyFloat_AsDouble(parameter)); break; case TYPE_STRING: - PyString_AsStringAndSize(parameter, &string, &buflen); - rc = sqlite3_bind_text(self->st, pos, string, buflen, SQLITE_TRANSIENT); + string = PyString_AS_STRING(parameter); + rc = sqlite3_bind_text(self->st, pos, string, -1, SQLITE_TRANSIENT); break; case TYPE_UNICODE: stringval = PyUnicode_AsUTF8String(parameter); - PyString_AsStringAndSize(stringval, &string, &buflen); - rc = sqlite3_bind_text(self->st, pos, string, buflen, SQLITE_TRANSIENT); + string = PyString_AsString(stringval); + rc = sqlite3_bind_text(self->st, pos, string, -1, SQLITE_TRANSIENT); Py_DECREF(stringval); break; case TYPE_BUFFER: @@ -201,7 +198,7 @@ return 1; } - if (PyInt_CheckExact(obj) || PyLong_CheckExact(obj) + if (PyInt_CheckExact(obj) || PyLong_CheckExact(obj) || PyFloat_CheckExact(obj) || PyString_CheckExact(obj) || PyUnicode_CheckExact(obj) || PyBuffer_Check(obj)) { return 0; diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_sqlite/util.c --- a/Modules/_sqlite/util.c Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/_sqlite/util.c Sun Jul 20 10:52:46 2014 -0400 @@ -104,69 +104,3 @@ return errorcode; } -#ifdef WORDS_BIGENDIAN -# define IS_LITTLE_ENDIAN 0 -#else -# define IS_LITTLE_ENDIAN 1 -#endif - -PyObject * -_pysqlite_long_from_int64(sqlite_int64 value) -{ -#ifdef HAVE_LONG_LONG -# if SIZEOF_LONG_LONG < 8 - if (value > PY_LLONG_MAX || value < PY_LLONG_MIN) { - return _PyLong_FromByteArray(&value, sizeof(value), - IS_LITTLE_ENDIAN, 1 /* signed */); - } -# endif -# if SIZEOF_LONG < SIZEOF_LONG_LONG - if (value > LONG_MAX || value < LONG_MIN) - return PyLong_FromLongLong(value); -# endif -#else -# if SIZEOF_LONG < 8 - if (value > LONG_MAX || value < LONG_MIN) { - return _PyLong_FromByteArray(&value, sizeof(value), - IS_LITTLE_ENDIAN, 1 /* signed */); - } -# endif -#endif - return PyInt_FromLong(value); -} - -sqlite_int64 -_pysqlite_long_as_int64(PyObject * py_val) -{ - int overflow; -#ifdef HAVE_LONG_LONG - PY_LONG_LONG value = PyLong_AsLongLongAndOverflow(py_val, &overflow); -#else - long value = PyLong_AsLongAndOverflow(py_val, &overflow); -#endif - if (value == -1 && PyErr_Occurred()) - return -1; - if (!overflow) { -#ifdef HAVE_LONG_LONG -# if SIZEOF_LONG_LONG > 8 - if (-0x8000000000000000LL <= value && value <= 0x7FFFFFFFFFFFFFFFLL) -# endif -#else -# if SIZEOF_LONG > 8 - if (-0x8000000000000000L <= value && value <= 0x7FFFFFFFFFFFFFFFL) -# endif -#endif - return value; - } - else if (sizeof(value) < sizeof(sqlite_int64)) { - sqlite_int64 int64val; - if (_PyLong_AsByteArray((PyLongObject *)py_val, - (unsigned char *)&int64val, sizeof(int64val), - IS_LITTLE_ENDIAN, 1 /* signed */) >= 0) { - return int64val; - } - } - PyErr_SetString(PyExc_OverflowError, - "Python int too large to convert to SQLite INTEGER"); - return -1; -} diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_sqlite/util.h --- a/Modules/_sqlite/util.h Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/_sqlite/util.h Sun Jul 20 10:52:46 2014 -0400 @@ -35,8 +35,4 @@ * Returns the error code (0 means no error occurred). */ int _pysqlite_seterror(sqlite3* db, sqlite3_stmt* st); - -PyObject * _pysqlite_long_from_int64(sqlite_int64 value); -sqlite_int64 _pysqlite_long_as_int64(PyObject * value); - #endif diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_sre.c --- a/Modules/_sre.c Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/_sre.c Sun Jul 20 10:52:46 2014 -0400 @@ -272,7 +272,7 @@ if (cursize < minsize) { void* stack; cursize = minsize+minsize/4+1024; - TRACE(("allocate/grow stack %" PY_FORMAT_SIZE_T "d\n", cursize)); + TRACE(("allocate/grow stack %d\n", cursize)); stack = PyMem_REALLOC(state->data_stack, cursize); if (!stack) { data_stack_dealloc(state); @@ -459,7 +459,7 @@ } else { /* (32 bits per code word) */ - if (ch < 256 && (set[ch >> 5] & (1u << (ch & 31)))) + if (ch < 256 && (set[ch >> 5] & (1 << (ch & 31)))) return ok; set += 8; } @@ -498,7 +498,7 @@ block = -1; set += 64; if (block >=0 && - (set[block*8 + ((ch & 255)>>5)] & (1u << (ch & 31)))) + (set[block*8 + ((ch & 255)>>5)] & (1 << (ch & 31)))) return ok; set += count*8; } @@ -524,7 +524,7 @@ Py_ssize_t i; /* adjust end */ - if (maxcount < end - ptr && maxcount != SRE_MAXREPEAT) + if (maxcount < end - ptr && maxcount != 65535) end = ptr + maxcount; switch (pattern[0]) { @@ -592,13 +592,12 @@ if (!i) break; } - TRACE(("|%p|%p|COUNT %" PY_FORMAT_SIZE_T "d\n", pattern, ptr, + TRACE(("|%p|%p|COUNT %d\n", pattern, ptr, (SRE_CHAR*) state->ptr - ptr)); return (SRE_CHAR*) state->ptr - ptr; } - TRACE(("|%p|%p|COUNT %" PY_FORMAT_SIZE_T "d\n", pattern, ptr, - ptr - (SRE_CHAR*) state->ptr)); + TRACE(("|%p|%p|COUNT %d\n", pattern, ptr, ptr - (SRE_CHAR*) state->ptr)); return ptr - (SRE_CHAR*) state->ptr; } @@ -685,10 +684,9 @@ #define DATA_STACK_ALLOC(state, type, ptr) \ do { \ alloc_pos = state->data_stack_base; \ - TRACE(("allocating %s in %" PY_FORMAT_SIZE_T "d " \ - "(%" PY_FORMAT_SIZE_T "d)\n", \ + TRACE(("allocating %s in %d (%d)\n", \ SFY(type), alloc_pos, sizeof(type))); \ - if (sizeof(type) > state->data_stack_size - alloc_pos) { \ + if (state->data_stack_size < alloc_pos+sizeof(type)) { \ int j = data_stack_grow(state, sizeof(type)); \ if (j < 0) return j; \ if (ctx_pos != -1) \ @@ -700,16 +698,15 @@ #define DATA_STACK_LOOKUP_AT(state, type, ptr, pos) \ do { \ - TRACE(("looking up %s at %" PY_FORMAT_SIZE_T "d\n", SFY(type), pos)); \ + TRACE(("looking up %s at %d\n", SFY(type), pos)); \ ptr = (type*)(state->data_stack+pos); \ } while (0) #define DATA_STACK_PUSH(state, data, size) \ do { \ - TRACE(("copy data in %p to %" PY_FORMAT_SIZE_T "d " \ - "(%" PY_FORMAT_SIZE_T "d)\n", \ + TRACE(("copy data in %p to %d (%d)\n", \ data, state->data_stack_base, size)); \ - if (size > state->data_stack_size - state->data_stack_base) { \ + if (state->data_stack_size < state->data_stack_base+size) { \ int j = data_stack_grow(state, size); \ if (j < 0) return j; \ if (ctx_pos != -1) \ @@ -721,8 +718,7 @@ #define DATA_STACK_POP(state, data, size, discard) \ do { \ - TRACE(("copy data to %p from %" PY_FORMAT_SIZE_T "d " \ - "(%" PY_FORMAT_SIZE_T "d)\n", \ + TRACE(("copy data to %p from %d (%d)\n", \ data, state->data_stack_base-size, size)); \ memcpy(data, state->data_stack+state->data_stack_base-size, size); \ if (discard) \ @@ -731,8 +727,7 @@ #define DATA_STACK_POP_DISCARD(state, size) \ do { \ - TRACE(("discard data from %" PY_FORMAT_SIZE_T "d " \ - "(%" PY_FORMAT_SIZE_T "d)\n", \ + TRACE(("discard data from %d (%d)\n", \ state->data_stack_base-size, size)); \ state->data_stack_base -= size; \ } while(0) @@ -836,9 +831,8 @@ /* optimization info block */ /* <1=skip> <2=flags> <3=min> ... */ if (ctx->pattern[3] && (end - ctx->ptr) < ctx->pattern[3]) { - TRACE(("reject (got %" PY_FORMAT_SIZE_T "d chars, " - "need %" PY_FORMAT_SIZE_T "d)\n", - (end - ctx->ptr), (Py_ssize_t) ctx->pattern[3])); + TRACE(("reject (got %d chars, need %d)\n", + (end - ctx->ptr), ctx->pattern[3])); RETURN_FAILURE; } ctx->pattern += ctx->pattern[1] + 1; @@ -1034,7 +1028,7 @@ TRACE(("|%p|%p|REPEAT_ONE %d %d\n", ctx->pattern, ctx->ptr, ctx->pattern[1], ctx->pattern[2])); - if ((Py_ssize_t) ctx->pattern[1] > end - ctx->ptr) + if (ctx->ptr + ctx->pattern[1] > end) RETURN_FAILURE; /* cannot match */ state->ptr = ctx->ptr; @@ -1117,7 +1111,7 @@ TRACE(("|%p|%p|MIN_REPEAT_ONE %d %d\n", ctx->pattern, ctx->ptr, ctx->pattern[1], ctx->pattern[2])); - if ((Py_ssize_t) ctx->pattern[1] > end - ctx->ptr) + if (ctx->ptr + ctx->pattern[1] > end) RETURN_FAILURE; /* cannot match */ state->ptr = ctx->ptr; @@ -1145,7 +1139,7 @@ } else { /* general case */ LASTMARK_SAVE(); - while ((Py_ssize_t)ctx->pattern[2] == SRE_MAXREPEAT + while ((Py_ssize_t)ctx->pattern[2] == 65535 || ctx->count <= (Py_ssize_t)ctx->pattern[2]) { state->ptr = ctx->ptr; DO_JUMP(JUMP_MIN_REPEAT_ONE,jump_min_repeat_one, @@ -1213,10 +1207,10 @@ ctx->count = ctx->u.rep->count+1; - TRACE(("|%p|%p|MAX_UNTIL %" PY_FORMAT_SIZE_T "d\n", ctx->pattern, + TRACE(("|%p|%p|MAX_UNTIL %d\n", ctx->pattern, ctx->ptr, ctx->count)); - if (ctx->count < (Py_ssize_t) ctx->u.rep->pattern[1]) { + if (ctx->count < ctx->u.rep->pattern[1]) { /* not enough matches */ ctx->u.rep->count = ctx->count; DO_JUMP(JUMP_MAX_UNTIL_1, jump_max_until_1, @@ -1230,8 +1224,8 @@ RETURN_FAILURE; } - if ((ctx->count < (Py_ssize_t) ctx->u.rep->pattern[2] || - ctx->u.rep->pattern[2] == SRE_MAXREPEAT) && + if ((ctx->count < ctx->u.rep->pattern[2] || + ctx->u.rep->pattern[2] == 65535) && state->ptr != ctx->u.rep->last_ptr) { /* we may have enough matches, but if we can match another item, do so */ @@ -1276,10 +1270,10 @@ ctx->count = ctx->u.rep->count+1; - TRACE(("|%p|%p|MIN_UNTIL %" PY_FORMAT_SIZE_T "d %p\n", ctx->pattern, + TRACE(("|%p|%p|MIN_UNTIL %d %p\n", ctx->pattern, ctx->ptr, ctx->count, ctx->u.rep->pattern)); - if (ctx->count < (Py_ssize_t) ctx->u.rep->pattern[1]) { + if (ctx->count < ctx->u.rep->pattern[1]) { /* not enough matches */ ctx->u.rep->count = ctx->count; DO_JUMP(JUMP_MIN_UNTIL_1, jump_min_until_1, @@ -1308,18 +1302,13 @@ LASTMARK_RESTORE(); - if ((ctx->count >= (Py_ssize_t) ctx->u.rep->pattern[2] - && ctx->u.rep->pattern[2] != SRE_MAXREPEAT) || - state->ptr == ctx->u.rep->last_ptr) + if (ctx->count >= ctx->u.rep->pattern[2] + && ctx->u.rep->pattern[2] != 65535) RETURN_FAILURE; ctx->u.rep->count = ctx->count; - /* zero-width match protection */ - DATA_PUSH(&ctx->u.rep->last_ptr); - ctx->u.rep->last_ptr = state->ptr; DO_JUMP(JUMP_MIN_UNTIL_3,jump_min_until_3, ctx->u.rep->pattern+3); - DATA_POP(&ctx->u.rep->last_ptr); if (ret) { RETURN_ON_ERROR(ret); RETURN_SUCCESS; @@ -1489,8 +1478,7 @@ TRACE(("|%p|%p|JUMP_ASSERT_NOT\n", ctx->pattern, ctx->ptr)); goto jump_assert_not; case JUMP_NONE: - TRACE(("|%p|%p|RETURN %" PY_FORMAT_SIZE_T "d\n", ctx->pattern, - ctx->ptr, ret)); + TRACE(("|%p|%p|RETURN %d\n", ctx->pattern, ctx->ptr, ret)); break; } @@ -1539,8 +1527,7 @@ pattern += 1 + pattern[1]; } - TRACE(("prefix = %p %" PY_FORMAT_SIZE_T "d %" PY_FORMAT_SIZE_T "d\n", - prefix, prefix_len, prefix_skip)); + TRACE(("prefix = %p %d %d\n", prefix, prefix_len, prefix_skip)); TRACE(("charset = %p\n", charset)); #if defined(USE_FAST_SEARCH) @@ -1649,7 +1636,7 @@ static PyObject * sre_codesize(PyObject* self, PyObject *unused) { - return PyInt_FromSize_t(sizeof(SRE_CODE)); + return Py_BuildValue("l", sizeof(SRE_CODE)); } static PyObject * @@ -1875,62 +1862,18 @@ PyObject_DEL(self); } -static int -check_args_size(const char *name, PyObject* args, PyObject* kw, int n) -{ - Py_ssize_t m = PyTuple_GET_SIZE(args) + (kw ? PyDict_Size(kw) : 0); - if (m <= n) - return 1; - PyErr_Format(PyExc_TypeError, - "%s() takes at most %d positional arguments (%zd given)", - name, n, m); - return 0; -} - -static PyObject* -fix_string_param(PyObject *string, PyObject *string2, const char *oldname) -{ - if (string2 != NULL) { - char buf[100]; - if (string != NULL) { - PyErr_Format(PyExc_TypeError, - "Argument given by name ('%s') and position (1)", - oldname); - return NULL; - } - sprintf(buf, "The '%s' keyword parameter name is deprecated. " - "Use 'string' instead.", oldname); - if (PyErr_Warn(PyExc_DeprecationWarning, buf) < 0) - return NULL; - return string2; - } - if (string == NULL) { - PyErr_SetString(PyExc_TypeError, - "Required argument 'string' (pos 1) not found"); - return NULL; - } - return string; -} - static PyObject* pattern_match(PatternObject* self, PyObject* args, PyObject* kw) { SRE_STATE state; int status; - PyObject *string = NULL, *string2 = NULL; + PyObject* string; Py_ssize_t start = 0; Py_ssize_t end = PY_SSIZE_T_MAX; - static char* kwlist[] = { "string", "pos", "endpos", "pattern", NULL }; - if (!check_args_size("match", args, kw, 3)) - return NULL; - - if (!PyArg_ParseTupleAndKeywords(args, kw, "|OnnO:match", kwlist, - &string, &start, &end, &string2)) - return NULL; - - string = fix_string_param(string, string2, "pattern"); - if (!string) + static char* kwlist[] = { "pattern", "pos", "endpos", NULL }; + if (!PyArg_ParseTupleAndKeywords(args, kw, "O|nn:match", kwlist, + &string, &start, &end)) return NULL; string = state_init(&state, self, string, start, end); @@ -1964,19 +1907,12 @@ SRE_STATE state; int status; - PyObject *string = NULL, *string2 = NULL; + PyObject* string; Py_ssize_t start = 0; Py_ssize_t end = PY_SSIZE_T_MAX; - static char* kwlist[] = { "string", "pos", "endpos", "pattern", NULL }; - if (!check_args_size("search", args, kw, 3)) - return NULL; - - if (!PyArg_ParseTupleAndKeywords(args, kw, "|OnnO:search", kwlist, - &string, &start, &end, &string2)) - return NULL; - - string = fix_string_param(string, string2, "pattern"); - if (!string) + static char* kwlist[] = { "pattern", "pos", "endpos", NULL }; + if (!PyArg_ParseTupleAndKeywords(args, kw, "O|nn:search", kwlist, + &string, &start, &end)) return NULL; string = state_init(&state, self, string, start, end); @@ -2106,19 +2042,12 @@ int status; Py_ssize_t i, b, e; - PyObject *string = NULL, *string2 = NULL; + PyObject* string; Py_ssize_t start = 0; Py_ssize_t end = PY_SSIZE_T_MAX; - static char* kwlist[] = { "string", "pos", "endpos", "source", NULL }; - if (!check_args_size("findall", args, kw, 3)) - return NULL; - - if (!PyArg_ParseTupleAndKeywords(args, kw, "|OnnO:findall", kwlist, - &string, &start, &end, &string2)) - return NULL; - - string = fix_string_param(string, string2, "source"); - if (!string) + static char* kwlist[] = { "source", "pos", "endpos", NULL }; + if (!PyArg_ParseTupleAndKeywords(args, kw, "O|nn:findall", kwlist, + &string, &start, &end)) return NULL; string = state_init(&state, self, string, start, end); @@ -2243,18 +2172,11 @@ Py_ssize_t i; void* last; - PyObject *string = NULL, *string2 = NULL; + PyObject* string; Py_ssize_t maxsplit = 0; - static char* kwlist[] = { "string", "maxsplit", "source", NULL }; - if (!check_args_size("split", args, kw, 2)) - return NULL; - - if (!PyArg_ParseTupleAndKeywords(args, kw, "|OnO:split", kwlist, - &string, &maxsplit, &string2)) - return NULL; - - string = fix_string_param(string, string2, "source"); - if (!string) + static char* kwlist[] = { "source", "maxsplit", NULL }; + if (!PyArg_ParseTupleAndKeywords(args, kw, "O|n:split", kwlist, + &string, &maxsplit)) return NULL; string = state_init(&state, self, string, 0, PY_SSIZE_T_MAX); @@ -2526,7 +2448,7 @@ return NULL; if (subn) - return Py_BuildValue("Nn", item, n); + return Py_BuildValue("Ni", item, n); return item; @@ -2624,7 +2546,7 @@ PyDoc_STRVAR(pattern_search_doc, "search(string[, pos[, endpos]]) --> match object or None.\n\ Scan through string looking for a match, and return a corresponding\n\ - match object instance. Return None if no position in the string matches."); + MatchObject instance. Return None if no position in the string matches."); PyDoc_STRVAR(pattern_split_doc, "split(string[, maxsplit = 0]) --> list.\n\ @@ -2753,13 +2675,6 @@ PyObject *o = PyList_GET_ITEM(code, i); unsigned long value = PyInt_Check(o) ? (unsigned long)PyInt_AsLong(o) : PyLong_AsUnsignedLong(o); - if (value == (unsigned long)-1 && PyErr_Occurred()) { - if (PyErr_ExceptionMatches(PyExc_OverflowError)) { - PyErr_SetString(PyExc_OverflowError, - "regular expression code size limit exceeded"); - } - break; - } self->code[i] = (SRE_CODE) value; if ((unsigned long) self->code[i] != value) { PyErr_SetString(PyExc_OverflowError, @@ -2818,7 +2733,8 @@ \_________\_____/ / \____________/ - It also helps that SRE_CODE is always an unsigned type. + It also helps that SRE_CODE is always an unsigned type, either 2 bytes or 4 + bytes wide (the latter if Python is compiled for "wide" unicode support). */ /* Defining this one enables tracing of the validator */ @@ -2856,7 +2772,7 @@ skip = *code; \ VTRACE(("%lu (skip to %p)\n", \ (unsigned long)skip, code+skip)); \ - if (skip-adj > end-code) \ + if (code+skip-adj < code || code+skip-adj > end)\ FAIL; \ code++; \ } while (0) @@ -2889,7 +2805,7 @@ case SRE_OP_CHARSET: offset = 32/sizeof(SRE_CODE); /* 32-byte bitmap */ - if (offset > end-code) + if (code+offset < code || code+offset > end) FAIL; code += offset; break; @@ -2897,7 +2813,7 @@ case SRE_OP_BIGCHARSET: GET_ARG; /* Number of blocks */ offset = 256/sizeof(SRE_CODE); /* 256-byte table */ - if (offset > end-code) + if (code+offset < code || code+offset > end) FAIL; /* Make sure that each byte points to a valid block */ for (i = 0; i < 256; i++) { @@ -2906,7 +2822,7 @@ } code += offset; offset = arg * 32/sizeof(SRE_CODE); /* 32-byte bitmap times arg */ - if (offset > end-code) + if (code+offset < code || code+offset > end) FAIL; code += offset; break; @@ -3057,11 +2973,11 @@ GET_ARG; prefix_len = arg; GET_ARG; /* prefix skip */ /* Here comes the prefix string */ - if (prefix_len > newcode-code) + if (code+prefix_len < code || code+prefix_len > newcode) FAIL; code += prefix_len; /* And here comes the overlap table */ - if (prefix_len > newcode-code) + if (code+prefix_len < code || code+prefix_len > newcode) FAIL; /* Each overlap value should be < prefix_len */ for (i = 0; i < prefix_len; i++) { @@ -3119,8 +3035,10 @@ GET_ARG; max = arg; if (min > max) FAIL; - if (max > SRE_MAXREPEAT) +#ifdef Py_UNICODE_WIDE + if (max > 65535) FAIL; +#endif if (!_validate_inner(code, code+skip-4, groups)) FAIL; code += skip-4; @@ -3138,8 +3056,10 @@ GET_ARG; max = arg; if (min > max) FAIL; - if (max > SRE_MAXREPEAT) +#ifdef Py_UNICODE_WIDE + if (max > 65535) FAIL; +#endif if (!_validate_inner(code, code+skip-3, groups)) FAIL; code += skip-3; @@ -3190,7 +3110,7 @@ to allow arbitrary jumps anywhere in the code; so we just look for a JUMP opcode preceding our skip target. */ - if (skip >= 3 && skip-3 < end-code && + if (skip >= 3 && code+skip-3 >= code && code[skip-3] == SRE_OP_JUMP) { VTRACE(("both then and else parts present\n")); @@ -3466,7 +3386,7 @@ } /* mark is -1 if group is undefined */ - return PyInt_FromSsize_t(self->mark[index*2]); + return Py_BuildValue("i", self->mark[index*2]); } static PyObject* @@ -3489,7 +3409,7 @@ } /* mark is -1 if group is undefined */ - return PyInt_FromSsize_t(self->mark[index*2+1]); + return Py_BuildValue("i", self->mark[index*2+1]); } LOCAL(PyObject*) @@ -3622,54 +3542,14 @@ #endif } -PyDoc_STRVAR(match_doc, -"The result of re.match() and re.search().\n\ -Match objects always have a boolean value of True."); - -PyDoc_STRVAR(match_group_doc, -"group([group1, ...]) -> str or tuple.\n\ - Return subgroup(s) of the match by indices or names.\n\ - For 0 returns the entire match."); - -PyDoc_STRVAR(match_start_doc, -"start([group=0]) -> int.\n\ - Return index of the start of the substring matched by group."); - -PyDoc_STRVAR(match_end_doc, -"end([group=0]) -> int.\n\ - Return index of the end of the substring matched by group."); - -PyDoc_STRVAR(match_span_doc, -"span([group]) -> tuple.\n\ - For MatchObject m, return the 2-tuple (m.start(group), m.end(group))."); - -PyDoc_STRVAR(match_groups_doc, -"groups([default=None]) -> tuple.\n\ - Return a tuple containing all the subgroups of the match, from 1.\n\ - The default argument is used for groups\n\ - that did not participate in the match"); - -PyDoc_STRVAR(match_groupdict_doc, -"groupdict([default=None]) -> dict.\n\ - Return a dictionary containing all the named subgroups of the match,\n\ - keyed by the subgroup name. The default argument is used for groups\n\ - that did not participate in the match"); - -PyDoc_STRVAR(match_expand_doc, -"expand(template) -> str.\n\ - Return the string obtained by doing backslash substitution\n\ - on the string template, as done by the sub() method."); - -static PyMethodDef match_methods[] = { - {"group", (PyCFunction) match_group, METH_VARARGS, match_group_doc}, - {"start", (PyCFunction) match_start, METH_VARARGS, match_start_doc}, - {"end", (PyCFunction) match_end, METH_VARARGS, match_end_doc}, - {"span", (PyCFunction) match_span, METH_VARARGS, match_span_doc}, - {"groups", (PyCFunction) match_groups, METH_VARARGS|METH_KEYWORDS, - match_groups_doc}, - {"groupdict", (PyCFunction) match_groupdict, METH_VARARGS|METH_KEYWORDS, - match_groupdict_doc}, - {"expand", (PyCFunction) match_expand, METH_O, match_expand_doc}, +static struct PyMethodDef match_methods[] = { + {"group", (PyCFunction) match_group, METH_VARARGS}, + {"start", (PyCFunction) match_start, METH_VARARGS}, + {"end", (PyCFunction) match_end, METH_VARARGS}, + {"span", (PyCFunction) match_span, METH_VARARGS}, + {"groups", (PyCFunction) match_groups, METH_VARARGS|METH_KEYWORDS}, + {"groupdict", (PyCFunction) match_groupdict, METH_VARARGS|METH_KEYWORDS}, + {"expand", (PyCFunction) match_expand, METH_O}, {"__copy__", (PyCFunction) match_copy, METH_NOARGS}, {"__deepcopy__", (PyCFunction) match_deepcopy, METH_O}, {NULL, NULL} @@ -3679,7 +3559,7 @@ match_lastindex_get(MatchObject *self) { if (self->lastindex >= 0) - return PyInt_FromSsize_t(self->lastindex); + return Py_BuildValue("i", self->lastindex); Py_INCREF(Py_None); return Py_None; } @@ -3749,7 +3629,7 @@ 0, /* tp_setattro */ 0, /* tp_as_buffer */ Py_TPFLAGS_DEFAULT, - match_doc, /* tp_doc */ + 0, /* tp_doc */ 0, /* tp_traverse */ 0, /* tp_clear */ 0, /* tp_richcompare */ @@ -4015,12 +3895,6 @@ Py_DECREF(x); } - x = PyLong_FromUnsignedLong(SRE_MAXREPEAT); - if (x) { - PyDict_SetItemString(d, "MAXREPEAT", x); - Py_DECREF(x); - } - x = PyString_FromString(copyright); if (x) { PyDict_SetItemString(d, "copyright", x); diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_ssl.c --- a/Modules/_ssl.c Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/_ssl.c Sun Jul 20 10:52:46 2014 -0400 @@ -18,8 +18,6 @@ #ifdef WITH_THREAD #include "pythread.h" - - #define PySSL_BEGIN_ALLOW_THREADS { \ PyThreadState *_save = NULL; \ if (_ssl_locks_count>0) {_save = PyEval_SaveThread();} @@ -273,7 +271,6 @@ char *errstr = NULL; int ret; int verification_mode; - long options; self = PyObject_New(PySSLObject, &PySSL_Type); /* Create new object */ if (self == NULL) @@ -284,7 +281,6 @@ self->ssl = NULL; self->ctx = NULL; self->Socket = NULL; - self->shutdown_seen_zero = 0; /* Make sure the SSL error state is initialized */ (void) ERR_get_state(); @@ -373,10 +369,7 @@ } /* ssl compatibility */ - options = SSL_OP_ALL & ~SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS; - if (proto_version != PY_SSL_VERSION_SSL2) - options |= SSL_OP_NO_SSLv2; - SSL_CTX_set_options(self->ctx, options); + SSL_CTX_set_options(self->ctx, SSL_OP_ALL); verification_mode = SSL_VERIFY_NONE; if (certreq == PY_SSL_CERT_OPTIONAL) @@ -650,20 +643,15 @@ goto fail1; } /* now, there's typically a dangling RDN */ - if (rdn != NULL) { - if (PyList_GET_SIZE(rdn) > 0) { - rdnt = PyList_AsTuple(rdn); - Py_DECREF(rdn); - if (rdnt == NULL) - goto fail0; - retcode = PyList_Append(dn, rdnt); - Py_DECREF(rdnt); - if (retcode < 0) - goto fail0; - } - else { - Py_DECREF(rdn); - } + if ((rdn != NULL) && (PyList_Size(rdn) > 0)) { + rdnt = PyList_AsTuple(rdn); + Py_DECREF(rdn); + if (rdnt == NULL) + goto fail0; + retcode = PyList_Append(dn, rdnt); + Py_DECREF(rdnt); + if (retcode < 0) + goto fail0; } /* convert list to tuple */ @@ -692,7 +680,7 @@ int i, j; PyObject *peer_alt_names = Py_None; - PyObject *v = NULL, *t; + PyObject *v, *t; X509_EXTENSION *ext = NULL; GENERAL_NAMES *names = NULL; GENERAL_NAME *name; @@ -744,16 +732,13 @@ ext->value->length)); for(j = 0; j < sk_GENERAL_NAME_num(names); j++) { + /* get a rendering of each name in the set of names */ - int gntype; - ASN1_STRING *as = NULL; name = sk_GENERAL_NAME_value(names, j); - gntype = name->type; - switch (gntype) { - case GEN_DIRNAME: - /* we special-case DirName as a tuple of - tuples of attributes */ + if (name->type == GEN_DIRNAME) { + + /* we special-case DirName as a tuple of tuples of attributes */ t = PyTuple_New(2); if (t == NULL) { @@ -773,61 +758,11 @@ goto fail; } PyTuple_SET_ITEM(t, 1, v); - break; - case GEN_EMAIL: - case GEN_DNS: - case GEN_URI: - /* GENERAL_NAME_print() doesn't handle NULL bytes in ASN1_string - correctly, CVE-2013-4238 */ - t = PyTuple_New(2); - if (t == NULL) - goto fail; - switch (gntype) { - case GEN_EMAIL: - v = PyString_FromString("email"); - as = name->d.rfc822Name; - break; - case GEN_DNS: - v = PyString_FromString("DNS"); - as = name->d.dNSName; - break; - case GEN_URI: - v = PyString_FromString("URI"); - as = name->d.uniformResourceIdentifier; - break; - } - if (v == NULL) { - Py_DECREF(t); - goto fail; - } - PyTuple_SET_ITEM(t, 0, v); - v = PyString_FromStringAndSize((char *)ASN1_STRING_data(as), - ASN1_STRING_length(as)); - if (v == NULL) { - Py_DECREF(t); - goto fail; - } - PyTuple_SET_ITEM(t, 1, v); - break; + } else { - default: /* for everything else, we use the OpenSSL print form */ - switch (gntype) { - /* check for new general name type */ - case GEN_OTHERNAME: - case GEN_X400: - case GEN_EDIPARTY: - case GEN_IPADD: - case GEN_RID: - break; - default: - if (PyErr_Warn(PyExc_RuntimeWarning, - "Unknown general name type") == -1) { - goto fail; - } - break; - } + (void) BIO_reset(biobuf); GENERAL_NAME_print(biobuf, name); len = BIO_gets(biobuf, buf, sizeof(buf)-1); @@ -853,7 +788,6 @@ goto fail; } PyTuple_SET_ITEM(t, 1, v); - break; } /* and add that rendering to the list */ @@ -1065,7 +999,6 @@ int len; int verification; PyObject *binary_mode = Py_None; - int b; if (!PyArg_ParseTuple(args, "|O:peer_certificate", &binary_mode)) return NULL; @@ -1073,10 +1006,7 @@ if (!self->peer_cert) Py_RETURN_NONE; - b = PyObject_IsTrue(binary_mode); - if (b < 0) - return NULL; - if (b) { + if (PyObject_IsTrue(binary_mode)) { /* return cert in DER-encoded format */ unsigned char *bytes_buf = NULL; @@ -1252,12 +1182,6 @@ if (!PyArg_ParseTuple(args, "s*:write", &buf)) return NULL; - if (buf.len > INT_MAX) { - PyErr_Format(PyExc_OverflowError, - "string longer than %d bytes", INT_MAX); - goto error; - } - /* just in case the blocking state of the socket has been changed */ nonblocking = (self->Socket->sock_timeout >= 0.0); BIO_set_nbio(SSL_get_rbio(self->ssl), nonblocking); @@ -1279,7 +1203,7 @@ } do { PySSL_BEGIN_ALLOW_THREADS - len = SSL_write(self->ssl, buf.buf, (int)buf.len); + len = SSL_write(self->ssl, buf.buf, buf.len); err = SSL_get_error(self->ssl, len); PySSL_END_ALLOW_THREADS if (PyErr_CheckSignals()) { @@ -1461,7 +1385,7 @@ * Otherwise OpenSSL might read in too much data, * eating clear text data that happens to be * transmitted after the SSL shutdown. - * Should be safe to call repeatedly every time this + * Should be safe to call repeatedly everytime this * function is used and the shutdown_seen_zero != 0 * condition is met. */ @@ -1625,10 +1549,9 @@ \n\ Queries the entropy gather daemon (EGD) on the socket named by 'path'.\n\ Returns number of bytes read. Raises SSLError if connection to EGD\n\ -fails or if it does not provide enough data to seed PRNG."); +fails or if it does provide enough data to seed PRNG."); -#endif /* HAVE_OPENSSL_RAND */ - +#endif /* List of functions exported by this module. */ @@ -1656,21 +1579,9 @@ static PyThread_type_lock *_ssl_locks = NULL; -#if OPENSSL_VERSION_NUMBER >= 0x10000000 -/* use new CRYPTO_THREADID API. */ -static void -_ssl_threadid_callback(CRYPTO_THREADID *id) -{ - CRYPTO_THREADID_set_numeric(id, - (unsigned long)PyThread_get_thread_ident()); -} -#else -/* deprecated CRYPTO_set_id_callback() API. */ -static unsigned long -_ssl_thread_id_function (void) { +static unsigned long _ssl_thread_id_function (void) { return PyThread_get_thread_ident(); } -#endif static void _ssl_thread_locking_function (int mode, int n, const char *file, int line) { /* this function is needed to perform locking on shared data @@ -1721,11 +1632,7 @@ } } CRYPTO_set_locking_callback(_ssl_thread_locking_function); -#if OPENSSL_VERSION_NUMBER >= 0x10000000 - CRYPTO_THREADID_set_callback(_ssl_threadid_callback); -#else CRYPTO_set_id_callback(_ssl_thread_id_function); -#endif } return 1; } @@ -1840,5 +1747,4 @@ r = PyString_FromString(SSLeay_version(SSLEAY_VERSION)); if (r == NULL || PyModule_AddObject(m, "OPENSSL_VERSION", r)) return; - } diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_struct.c --- a/Modules/_struct.c Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/_struct.c Sun Jul 20 10:52:46 2014 -0400 @@ -1371,28 +1371,13 @@ assert(PyStruct_Check(self)); - if (!PyArg_ParseTupleAndKeywords(args, kwds, "O:Struct", kwlist, + if (!PyArg_ParseTupleAndKeywords(args, kwds, "S:Struct", kwlist, &o_format)) return -1; - if (PyString_Check(o_format)) { - Py_INCREF(o_format); - Py_CLEAR(soself->s_format); - soself->s_format = o_format; - } - else if (PyUnicode_Check(o_format)) { - PyObject *str = PyUnicode_AsEncodedString(o_format, "ascii", NULL); - if (str == NULL) - return -1; - Py_CLEAR(soself->s_format); - soself->s_format = str; - } - else { - PyErr_Format(PyExc_TypeError, - "Struct() argument 1 must be string, not %s", - Py_TYPE(o_format)->tp_name); - return -1; - } + Py_INCREF(o_format); + Py_CLEAR(soself->s_format); + soself->s_format = o_format; ret = prepare_s(soself); return ret; @@ -1454,7 +1439,6 @@ static PyObject * s_unpack(PyObject *self, PyObject *inputstr) { - Py_buffer buf; char *start; Py_ssize_t len; PyObject *args=NULL, *result; @@ -1470,17 +1454,12 @@ args = PyTuple_Pack(1, inputstr); if (args == NULL) return NULL; - if (!PyArg_ParseTuple(args, "s*:unpack", &buf)) + if (!PyArg_ParseTuple(args, "s#:unpack", &start, &len)) goto fail; - start = buf.buf; - len = buf.len; - if (soself->s_size != len) { - PyBuffer_Release(&buf); + if (soself->s_size != len) goto fail; - } result = s_unpack_internal(soself, start); Py_DECREF(args); - PyBuffer_Release(&buf); return result; fail: @@ -1503,24 +1482,24 @@ s_unpack_from(PyObject *self, PyObject *args, PyObject *kwds) { static char *kwlist[] = {"buffer", "offset", 0}; - static char *fmt = "z*|n:unpack_from"; - Py_buffer buf; +#if (PY_VERSION_HEX < 0x02050000) + static char *fmt = "z#|i:unpack_from"; +#else + static char *fmt = "z#|n:unpack_from"; +#endif Py_ssize_t buffer_len = 0, offset = 0; char *buffer = NULL; PyStructObject *soself = (PyStructObject *)self; - PyObject *result; assert(PyStruct_Check(self)); assert(soself->s_codes != NULL); if (!PyArg_ParseTupleAndKeywords(args, kwds, fmt, kwlist, - &buf, &offset)) + &buffer, &buffer_len, &offset)) return NULL; - buffer = buf.buf; - buffer_len = buf.len; + if (buffer == NULL) { PyErr_Format(StructError, "unpack_from requires a buffer argument"); - PyBuffer_Release(&buf); return NULL; } @@ -1531,12 +1510,9 @@ PyErr_Format(StructError, "unpack_from requires a buffer of at least %zd bytes", soself->s_size); - PyBuffer_Release(&buf); return NULL; } - result = s_unpack_internal(soself, buffer + offset); - PyBuffer_Release(&buf); - return result; + return s_unpack_internal(soself, buffer + offset); } @@ -1627,7 +1603,7 @@ if (PyTuple_GET_SIZE(args) != soself->s_len) { PyErr_Format(StructError, - "pack expected %zd items for packing (got %zd)", soself->s_len, PyTuple_GET_SIZE(args)); + "pack requires exactly %zd arguments", soself->s_len); return NULL; } @@ -1666,19 +1642,9 @@ assert(soself->s_codes != NULL); if (PyTuple_GET_SIZE(args) != (soself->s_len + 2)) { - if (PyTuple_GET_SIZE(args) == 0) { - PyErr_Format(StructError, - "pack_into expected buffer argument"); - } - else if (PyTuple_GET_SIZE(args) == 1) { - PyErr_Format(StructError, - "pack_into expected offset argument"); - } - else { - PyErr_Format(StructError, - "pack_into expected %zd items for packing (got %zd)", - soself->s_len, (PyTuple_GET_SIZE(args) - 2)); - } + PyErr_Format(StructError, + "pack_into requires exactly %zd arguments", + (soself->s_len + 2)); return NULL; } @@ -1727,18 +1693,6 @@ return PyInt_FromSsize_t(self->s_size); } -PyDoc_STRVAR(s_sizeof__doc__, -"S.__sizeof__() -> size of S in memory, in bytes"); - -static PyObject * -s_sizeof(PyStructObject *self, void *unused) -{ - Py_ssize_t size; - - size = sizeof(PyStructObject) + sizeof(formatcode) * (self->s_len + 1); - return PyLong_FromSsize_t(size); -} - /* List of functions */ static struct PyMethodDef s_methods[] = { @@ -1747,7 +1701,6 @@ {"unpack", s_unpack, METH_O, s_unpack__doc__}, {"unpack_from", (PyCFunction)s_unpack_from, METH_VARARGS|METH_KEYWORDS, s_unpack_from__doc__}, - {"__sizeof__", (PyCFunction)s_sizeof, METH_NOARGS, s_sizeof__doc__}, {NULL, NULL} /* sentinel */ }; diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_testcapimodule.c --- a/Modules/_testcapimodule.c Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/_testcapimodule.c Sun Jul 20 10:52:46 2014 -0400 @@ -1118,7 +1118,7 @@ if (!PyArg_ParseTuple(args, "u#|s", &unicode, &length, &errors)) return NULL; - decimal_length = length * 10; /* len('􏿿') */ + decimal_length = length * 7; /* len('€') */ decimal = PyBytes_FromStringAndSize(NULL, decimal_length); if (decimal == NULL) return NULL; @@ -1687,96 +1687,6 @@ Py_RETURN_NONE; } -#ifdef WITH_THREAD -typedef struct { - PyThread_type_lock start_event; - PyThread_type_lock exit_event; - PyObject *callback; -} test_c_thread_t; - -static void -temporary_c_thread(void *data) -{ - test_c_thread_t *test_c_thread = data; - PyGILState_STATE state; - PyObject *res; - - PyThread_release_lock(test_c_thread->start_event); - - /* Allocate a Python thread state for this thread */ - state = PyGILState_Ensure(); - - res = PyObject_CallFunction(test_c_thread->callback, "", NULL); - Py_CLEAR(test_c_thread->callback); - - if (res == NULL) { - PyErr_Print(); - } - else { - Py_DECREF(res); - } - - /* Destroy the Python thread state for this thread */ - PyGILState_Release(state); - - PyThread_release_lock(test_c_thread->exit_event); - - PyThread_exit_thread(); -} - -static PyObject * -call_in_temporary_c_thread(PyObject *self, PyObject *callback) -{ - PyObject *res = NULL; - test_c_thread_t test_c_thread; - long thread; - - PyEval_InitThreads(); - - test_c_thread.start_event = PyThread_allocate_lock(); - test_c_thread.exit_event = PyThread_allocate_lock(); - test_c_thread.callback = NULL; - if (!test_c_thread.start_event || !test_c_thread.exit_event) { - PyErr_SetString(PyExc_RuntimeError, "could not allocate lock"); - goto exit; - } - - Py_INCREF(callback); - test_c_thread.callback = callback; - - PyThread_acquire_lock(test_c_thread.start_event, 1); - PyThread_acquire_lock(test_c_thread.exit_event, 1); - - thread = PyThread_start_new_thread(temporary_c_thread, &test_c_thread); - if (thread == -1) { - PyErr_SetString(PyExc_RuntimeError, "unable to start the thread"); - PyThread_release_lock(test_c_thread.start_event); - PyThread_release_lock(test_c_thread.exit_event); - goto exit; - } - - PyThread_acquire_lock(test_c_thread.start_event, 1); - PyThread_release_lock(test_c_thread.start_event); - - Py_BEGIN_ALLOW_THREADS - PyThread_acquire_lock(test_c_thread.exit_event, 1); - PyThread_release_lock(test_c_thread.exit_event); - Py_END_ALLOW_THREADS - - Py_INCREF(Py_None); - res = Py_None; - -exit: - Py_CLEAR(test_c_thread.callback); - if (test_c_thread.start_event) - PyThread_free_lock(test_c_thread.start_event); - if (test_c_thread.exit_event) - PyThread_free_lock(test_c_thread.exit_event); - return res; -} -#endif /* WITH_THREAD */ - - static PyMethodDef TestMethods[] = { {"raise_exception", raise_exception, METH_VARARGS}, {"test_config", (PyCFunction)test_config, METH_NOARGS}, @@ -1835,10 +1745,6 @@ {"make_exception_with_doc", (PyCFunction)make_exception_with_doc, METH_VARARGS | METH_KEYWORDS}, {"sequence_delitem", (PyCFunction)sequence_delitem, METH_VARARGS}, -#ifdef WITH_THREAD - {"call_in_temporary_c_thread", call_in_temporary_c_thread, METH_O, - PyDoc_STR("set_error_class(error_class) -> None")}, -#endif {NULL, NULL} /* sentinel */ }; @@ -1907,7 +1813,7 @@ ; test_structmembers *ob; const char *s = NULL; - int string_len = 0; + Py_ssize_t string_len = 0; ob = PyObject_New(test_structmembers, type); if (ob == NULL) return NULL; diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/_tkinter.c --- a/Modules/_tkinter.c Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/_tkinter.c Sun Jul 20 10:52:46 2014 -0400 @@ -47,10 +47,6 @@ #define PyBool_FromLong PyInt_FromLong #endif -#define CHECK_SIZE(size, elemsize) \ - ((size_t)(size) <= (size_t)INT_MAX && \ - (size_t)(size) <= UINT_MAX / (size_t)(elemsize)) - /* Starting with Tcl 8.4, many APIs offer const-correctness. Unfortunately, making _tkinter correct for this API means to break earlier versions. USE_COMPAT_CONST allows to make _tkinter work with both 8.4 and @@ -382,7 +378,7 @@ char **argv = NULL; int fvStore[ARGSZ]; int *fv = NULL; - Py_ssize_t argc = 0, fvc = 0, i; + int argc = 0, fvc = 0, i; char *res = NULL; if (!(tmp = PyList_New(0))) @@ -404,12 +400,8 @@ argc = PyTuple_Size(args); if (argc > ARGSZ) { - if (!CHECK_SIZE(argc, sizeof(char *))) { - PyErr_SetString(PyExc_OverflowError, "tuple is too long"); - goto finally; - } - argv = (char **)ckalloc((size_t)argc * sizeof(char *)); - fv = (int *)ckalloc((size_t)argc * sizeof(int)); + argv = (char **)ckalloc(argc * sizeof(char *)); + fv = (int *)ckalloc(argc * sizeof(int)); if (argv == NULL || fv == NULL) { PyErr_NoMemory(); goto finally; @@ -456,70 +448,6 @@ -#ifdef Py_USING_UNICODE -static PyObject * -unicode_FromTclStringAndSize(const char *s, Py_ssize_t size) -{ - PyObject *r = PyUnicode_DecodeUTF8(s, size, NULL); - if (!r && PyErr_ExceptionMatches(PyExc_UnicodeDecodeError)) { - /* Tcl encodes null character as \xc0\x80 */ - if (memchr(s, '\xc0', size)) { - char *buf, *q; - const char *e = s + size; - PyErr_Clear(); - q = buf = (char *)PyMem_Malloc(size); - if (buf == NULL) { - PyErr_NoMemory(); - return NULL; - } - while (s != e) { - if (s + 1 != e && s[0] == '\xc0' && s[1] == '\x80') { - *q++ = '\0'; - s += 2; - } - else - *q++ = *s++; - } - s = buf; - size = q - s; - r = PyUnicode_DecodeUTF8(s, size, NULL); - PyMem_Free(buf); - } - } - return r; -} -#endif - -static PyObject * -fromTclStringAndSize(const char *s, Py_ssize_t size) -{ - PyObject *r; -#ifdef Py_USING_UNICODE - Py_ssize_t i; - /* If Tcl string contains any bytes with the top bit set, - it's UTF-8 and we should decode it to Unicode */ - for (i = 0; i < size; i++) - if (s[i] & 0x80) - break; - if (i != size) { - /* It isn't an ASCII string. */ - r = unicode_FromTclStringAndSize(s, size); - if (r) - return r; - PyErr_Clear(); - } -#endif - r = PyString_FromStringAndSize(s, size); - return r; -} - -static PyObject * -fromTclString(const char *s) -{ - return fromTclStringAndSize(s, strlen(s)); -} - - static PyObject * Split(char *list) { @@ -619,33 +547,6 @@ return Split(PyString_AsString(arg)); /* Fall through, returning arg. */ } - else if (PyUnicode_Check(arg)) { - int argc; - char **argv; - char *list; - PyObject *s = PyUnicode_AsUTF8String(arg); - - if (s == NULL) { - Py_INCREF(arg); - return arg; - } - list = PyString_AsString(s); - - if (list == NULL || - Tcl_SplitList((Tcl_Interp *)NULL, list, &argc, &argv) != TCL_OK) { - Py_DECREF(s); - Py_INCREF(arg); - return arg; - } - Tcl_Free(FREECAST argv); - if (argc > 1) { - PyObject *v = Split(list); - Py_DECREF(s); - return v; - } - Py_DECREF(s); - /* Fall through, returning arg. */ - } Py_INCREF(arg); return arg; } @@ -905,10 +806,27 @@ static PyObject * PyTclObject_string(PyTclObject *self, void *ignored) { + char *s; + int i, len; if (!self->string) { - int len; - char *s = Tcl_GetStringFromObj(self->value, &len); - self->string = fromTclStringAndSize(s, len); + s = Tcl_GetStringFromObj(self->value, &len); + for (i = 0; i < len; i++) + if (s[i] & 0x80) + break; +#ifdef Py_USING_UNICODE + if (i == len) + /* It is an ASCII string. */ + self->string = PyString_FromStringAndSize(s, len); + else { + self->string = PyUnicode_DecodeUTF8(s, len, "strict"); + if (!self->string) { + PyErr_Clear(); + self->string = PyString_FromStringAndSize(s, len); + } + } +#else + self->string = PyString_FromStringAndSize(s, len); +#endif if (!self->string) return NULL; } @@ -930,7 +848,7 @@ } /* XXX Could chache result if it is non-ASCII. */ s = Tcl_GetStringFromObj(self->value, &len); - return unicode_FromTclStringAndSize(s, len); + return PyUnicode_DecodeUTF8(s, len, "strict"); } #endif @@ -1023,16 +941,6 @@ 0, /*tp_is_gc*/ }; -#if PY_SIZE_MAX > INT_MAX -#define CHECK_STRING_LENGTH(s) do { \ - if (s != NULL && strlen(s) >= INT_MAX) { \ - PyErr_SetString(PyExc_OverflowError, "string is too long"); \ - return NULL; \ - } } while(0) -#else -#define CHECK_STRING_LENGTH(s) -#endif - static Tcl_Obj* AsObj(PyObject *value) { @@ -1048,18 +956,12 @@ else if (PyFloat_Check(value)) return Tcl_NewDoubleObj(PyFloat_AS_DOUBLE(value)); else if (PyTuple_Check(value)) { - Tcl_Obj **argv; - Py_ssize_t size, i; - - size = PyTuple_Size(value); - if (!CHECK_SIZE(size, sizeof(Tcl_Obj *))) { - PyErr_SetString(PyExc_OverflowError, "tuple is too long"); - return NULL; - } - argv = (Tcl_Obj **) ckalloc(((size_t)size) * sizeof(Tcl_Obj *)); + Tcl_Obj **argv = (Tcl_Obj**) + ckalloc(PyTuple_Size(value)*sizeof(Tcl_Obj*)); + int i; if(!argv) return 0; - for (i = 0; i < size; i++) + for(i=0;i= size) outbuf = (Tcl_UniChar*)ckalloc(allocsize); /* Else overflow occurred, and we take the next exit */ @@ -1092,10 +987,8 @@ for (i = 0; i < size; i++) { if (inbuf[i] >= 0x10000) { /* Tcl doesn't do UTF-16, yet. */ - PyErr_Format(Tkinter_TclError, - "character U+%x is above the range " - "(U+0000-U+FFFF) allowed by Tcl", - (int)inbuf[i]); + PyErr_SetString(PyExc_ValueError, + "unsupported character"); ckfree(FREECAST outbuf); return NULL; } @@ -1132,7 +1025,30 @@ TkappObject *app = (TkappObject*)tkapp; if (value->typePtr == NULL) { - result = fromTclStringAndSize(value->bytes, value->length); + /* If the result contains any bytes with the top bit set, + it's UTF-8 and we should decode it to Unicode */ +#ifdef Py_USING_UNICODE + int i; + char *s = value->bytes; + int len = value->length; + for (i = 0; i < len; i++) { + if (value->bytes[i] & 0x80) + break; + } + + if (i == value->length) + result = PyString_FromStringAndSize(s, len); + else { + /* Convert UTF-8 to Unicode string */ + result = PyUnicode_DecodeUTF8(s, len, "strict"); + if (result == NULL) { + PyErr_Clear(); + result = PyString_FromStringAndSize(s, len); + } + } +#else + result = PyString_FromStringAndSize(value->bytes, value->length); +#endif return result; } @@ -1253,7 +1169,7 @@ Tkapp_CallArgs(PyObject *args, Tcl_Obj** objStore, int *pobjc) { Tcl_Obj **objv = objStore; - Py_ssize_t objc = 0, i; + int objc = 0, i; if (args == NULL) /* do nothing */; @@ -1268,11 +1184,7 @@ objc = PyTuple_Size(args); if (objc > ARGSZ) { - if (!CHECK_SIZE(objc, sizeof(Tcl_Obj *))) { - PyErr_SetString(PyExc_OverflowError, "tuple is too long"); - return NULL; - } - objv = (Tcl_Obj **)ckalloc(((size_t)objc) * sizeof(Tcl_Obj *)); + objv = (Tcl_Obj **)ckalloc(objc * sizeof(char *)); if (objv == NULL) { PyErr_NoMemory(); objc = 0; @@ -1309,8 +1221,8 @@ Tkapp_CallResult(TkappObject *self) { PyObject *res = NULL; - Tcl_Obj *value = Tcl_GetObjResult(self->interp); if(self->wantobjects) { + Tcl_Obj *value = Tcl_GetObjResult(self->interp); /* Not sure whether the IncrRef is necessary, but something may overwrite the interpreter result while we are converting it. */ @@ -1318,9 +1230,33 @@ res = FromObj((PyObject*)self, value); Tcl_DecrRefCount(value); } else { - int len; - const char *s = Tcl_GetStringFromObj(value, &len); - res = fromTclStringAndSize(s, len); + const char *s = Tcl_GetStringResult(self->interp); + const char *p = s; + + /* If the result contains any bytes with the top bit set, + it's UTF-8 and we should decode it to Unicode */ +#ifdef Py_USING_UNICODE + while (*p != '\0') { + if (*p & 0x80) + break; + p++; + } + + if (*p == '\0') + res = PyString_FromStringAndSize(s, (int)(p-s)); + else { + /* Convert UTF-8 to Unicode string */ + p = strchr(p, '\0'); + res = PyUnicode_DecodeUTF8(s, (int)(p-s), "strict"); + if (res == NULL) { + PyErr_Clear(); + res = PyString_FromStringAndSize(s, (int)(p-s)); + } + } +#else + p = strchr(p, '\0'); + res = PyString_FromStringAndSize(s, (int)(p-s)); +#endif } return res; } @@ -1498,7 +1434,6 @@ if (!PyArg_ParseTuple(args, "s:eval", &script)) return NULL; - CHECK_STRING_LENGTH(script); CHECK_TCL_APPARTMENT; ENTER_TCL @@ -1545,7 +1480,6 @@ if (!PyArg_ParseTuple(args, "s:evalfile", &fileName)) return NULL; - CHECK_STRING_LENGTH(fileName); CHECK_TCL_APPARTMENT; ENTER_TCL @@ -1567,10 +1501,9 @@ PyObject *res = NULL; int err; - if (!PyArg_ParseTuple(args, "s:record", &script)) + if (!PyArg_ParseTuple(args, "s", &script)) return NULL; - CHECK_STRING_LENGTH(script); CHECK_TCL_APPARTMENT; ENTER_TCL @@ -1591,7 +1524,6 @@ if (!PyArg_ParseTuple(args, "s:adderrorinfo", &msg)) return NULL; - CHECK_STRING_LENGTH(msg); CHECK_TCL_APPARTMENT; ENTER_TCL @@ -1627,28 +1559,16 @@ static int varname_converter(PyObject *in, void *_out) { - char *s; char **out = (char**)_out; if (PyString_Check(in)) { - if (PyString_Size(in) > INT_MAX) { - PyErr_SetString(PyExc_OverflowError, "string is too long"); - return 0; - } - s = PyString_AsString(in); - if (strlen(s) != PyString_Size(in)) { - PyErr_SetString(PyExc_ValueError, "null character in string"); - return 0; - } - *out = s; + *out = PyString_AsString(in); return 1; } if (PyTclObject_Check(in)) { *out = PyTclObject_TclString(in); return 1; } - PyErr_Format(PyExc_TypeError, - "must be str or Tcl_Obj, not %.50s", - in->ob_type->tp_name); + /* XXX: Should give diagnostics. */ return 0; } @@ -1734,11 +1654,8 @@ PyObject *res = NULL; Tcl_Obj *newval, *ok; - switch (PyTuple_GET_SIZE(args)) { - case 2: - if (!PyArg_ParseTuple(args, "O&O:setvar", - varname_converter, &name1, &newValue)) - return NULL; + if (PyArg_ParseTuple(args, "O&O:setvar", + varname_converter, &name1, &newValue)) { /* XXX Acquire tcl lock??? */ newval = AsObj(newValue); if (newval == NULL) @@ -1754,29 +1671,27 @@ Py_INCREF(res); } LEAVE_OVERLAP_TCL - break; - case 3: - if (!PyArg_ParseTuple(args, "ssO:setvar", - &name1, &name2, &newValue)) + } + else { + PyErr_Clear(); + if (PyArg_ParseTuple(args, "ssO:setvar", + &name1, &name2, &newValue)) { + /* XXX must hold tcl lock already??? */ + newval = AsObj(newValue); + ENTER_TCL + ok = Tcl_SetVar2Ex(Tkapp_Interp(self), name1, name2, newval, flags); + ENTER_OVERLAP + if (!ok) + Tkinter_Error(self); + else { + res = Py_None; + Py_INCREF(res); + } + LEAVE_OVERLAP_TCL + } + else { return NULL; - CHECK_STRING_LENGTH(name1); - CHECK_STRING_LENGTH(name2); - /* XXX must hold tcl lock already??? */ - newval = AsObj(newValue); - ENTER_TCL - ok = Tcl_SetVar2Ex(Tkapp_Interp(self), name1, name2, newval, flags); - ENTER_OVERLAP - if (!ok) - Tkinter_Error(self); - else { - res = Py_None; - Py_INCREF(res); } - LEAVE_OVERLAP_TCL - break; - default: - PyErr_SetString(PyExc_TypeError, "setvar requires 2 to 3 arguments"); - return NULL; } return res; } @@ -1806,7 +1721,6 @@ varname_converter, &name1, &name2)) return NULL; - CHECK_STRING_LENGTH(name2); ENTER_TCL tres = Tcl_GetVar2Ex(Tkapp_Interp(self), name1, name2, flags); ENTER_OVERLAP @@ -1817,9 +1731,7 @@ res = FromObj(self, tres); } else { - int len; - char *s = Tcl_GetStringFromObj(tres, &len); - res = PyString_FromStringAndSize(s, len); + res = PyString_FromString(Tcl_GetString(tres)); } } LEAVE_OVERLAP_TCL @@ -1850,8 +1762,6 @@ if (!PyArg_ParseTuple(args, "s|s:unsetvar", &name1, &name2)) return NULL; - CHECK_STRING_LENGTH(name1); - CHECK_STRING_LENGTH(name2); ENTER_TCL code = Tcl_UnsetVar2(Tkapp_Interp(self), name1, name2, flags); ENTER_OVERLAP @@ -1896,7 +1806,6 @@ } if (!PyArg_ParseTuple(args, "s:getint", &s)) return NULL; - CHECK_STRING_LENGTH(s); if (Tcl_GetInt(Tkapp_Interp(self), s, &v) == TCL_ERROR) return Tkinter_Error(self); return Py_BuildValue("i", v); @@ -1917,7 +1826,6 @@ } if (!PyArg_ParseTuple(args, "s:getdouble", &s)) return NULL; - CHECK_STRING_LENGTH(s); if (Tcl_GetDouble(Tkapp_Interp(self), s, &v) == TCL_ERROR) return Tkinter_Error(self); return Py_BuildValue("d", v); @@ -1938,7 +1846,6 @@ } if (!PyArg_ParseTuple(args, "s:getboolean", &s)) return NULL; - CHECK_STRING_LENGTH(s); if (Tcl_GetBoolean(Tkapp_Interp(self), s, &v) == TCL_ERROR) return Tkinter_Error(self); return PyBool_FromLong(v); @@ -1954,7 +1861,6 @@ if (!PyArg_ParseTuple(args, "s:exprstring", &s)) return NULL; - CHECK_STRING_LENGTH(s); CHECK_TCL_APPARTMENT; ENTER_TCL @@ -1963,7 +1869,7 @@ if (retval == TCL_ERROR) res = Tkinter_Error(self); else - res = PyString_FromString(Tkapp_Result(self)); + res = Py_BuildValue("s", Tkapp_Result(self)); LEAVE_OVERLAP_TCL return res; } @@ -1979,7 +1885,6 @@ if (!PyArg_ParseTuple(args, "s:exprlong", &s)) return NULL; - CHECK_STRING_LENGTH(s); CHECK_TCL_APPARTMENT; ENTER_TCL @@ -2003,7 +1908,6 @@ if (!PyArg_ParseTuple(args, "s:exprdouble", &s)) return NULL; - CHECK_STRING_LENGTH(s); CHECK_TCL_APPARTMENT; PyFPE_START_PROTECT("Tkapp_ExprDouble", return 0) ENTER_TCL @@ -2028,7 +1932,6 @@ if (!PyArg_ParseTuple(args, "s:exprboolean", &s)) return NULL; - CHECK_STRING_LENGTH(s); CHECK_TCL_APPARTMENT; ENTER_TCL retval = Tcl_ExprBoolean(Tkapp_Interp(self), s, &v); @@ -2049,39 +1952,19 @@ char *list; int argc; char **argv; - PyObject *arg, *v; + PyObject *v; int i; - if (!PyArg_ParseTuple(args, "O:splitlist", &arg)) - return NULL; - if (PyTclObject_Check(arg)) { - int objc; - Tcl_Obj **objv; - if (Tcl_ListObjGetElements(Tkapp_Interp(self), - ((PyTclObject*)arg)->value, - &objc, &objv) == TCL_ERROR) { - return Tkinter_Error(self); + if (PyTuple_Size(args) == 1) { + v = PyTuple_GetItem(args, 0); + if (PyTuple_Check(v)) { + Py_INCREF(v); + return v; } - if (!(v = PyTuple_New(objc))) - return NULL; - for (i = 0; i < objc; i++) { - PyObject *s = FromObj(self, objv[i]); - if (!s || PyTuple_SetItem(v, i, s)) { - Py_DECREF(v); - return NULL; - } - } - return v; } - if (PyTuple_Check(arg)) { - Py_INCREF(arg); - return arg; - } - if (!PyArg_ParseTuple(args, "et:splitlist", "utf-8", &list)) return NULL; - CHECK_STRING_LENGTH(list); if (Tcl_SplitList(Tkapp_Interp(self), list, &argc, &argv) == TCL_ERROR) { PyMem_Free(list); @@ -2109,41 +1992,18 @@ static PyObject * Tkapp_Split(PyObject *self, PyObject *args) { - PyObject *arg, *v; + PyObject *v; char *list; - if (!PyArg_ParseTuple(args, "O:split", &arg)) - return NULL; - if (PyTclObject_Check(arg)) { - Tcl_Obj *value = ((PyTclObject*)arg)->value; - int objc; - Tcl_Obj **objv; - int i; - if (Tcl_ListObjGetElements(Tkapp_Interp(self), value, - &objc, &objv) == TCL_ERROR) { - return FromObj(self, value); + if (PyTuple_Size(args) == 1) { + PyObject* o = PyTuple_GetItem(args, 0); + if (PyTuple_Check(o)) { + o = SplitObj(o); + return o; } - if (objc == 0) - return PyString_FromString(""); - if (objc == 1) - return FromObj(self, objv[0]); - if (!(v = PyTuple_New(objc))) - return NULL; - for (i = 0; i < objc; i++) { - PyObject *s = FromObj(self, objv[i]); - if (!s || PyTuple_SetItem(v, i, s)) { - Py_DECREF(v); - return NULL; - } - } - return v; } - if (PyTuple_Check(arg)) - return SplitObj(arg); - if (!PyArg_ParseTuple(args, "et:split", "utf-8", &list)) return NULL; - CHECK_STRING_LENGTH(list); v = Split(list); PyMem_Free(list); return v; @@ -2205,7 +2065,7 @@ return PythonCmd_Error(interp); for (i = 0; i < (argc - 1); i++) { - PyObject *s = fromTclString(argv[i + 1]); + PyObject *s = PyString_FromString(argv[i + 1]); if (!s || PyTuple_SetItem(arg, i, s)) { Py_DECREF(arg); return PythonCmd_Error(interp); @@ -2289,7 +2149,6 @@ if (!PyArg_ParseTuple(args, "sO:createcommand", &cmdName, &func)) return NULL; - CHECK_STRING_LENGTH(cmdName); if (!PyCallable_Check(func)) { PyErr_SetString(PyExc_TypeError, "command not callable"); return NULL; @@ -2353,7 +2212,6 @@ if (!PyArg_ParseTuple(args, "s:deletecommand", &cmdName)) return NULL; - CHECK_STRING_LENGTH(cmdName); #ifdef WITH_THREAD if (self->threaded && self->thread_id != Tcl_GetCurrentThread()) { @@ -2863,7 +2721,7 @@ if (!PyArg_ParseTuple(args, ":interpaddr")) return NULL; - return PyLong_FromVoidPtr(Tkapp_Interp(self)); + return PyInt_FromLong((long)Tkapp_Interp(self)); } static PyObject * @@ -3162,10 +3020,6 @@ &interactive, &wantobjects, &wantTk, &sync, &use)) return NULL; - CHECK_STRING_LENGTH(screenName); - CHECK_STRING_LENGTH(baseName); - CHECK_STRING_LENGTH(className); - CHECK_STRING_LENGTH(use); return (PyObject *) Tkapp_New(screenName, baseName, className, interactive, wantobjects, wantTk, diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/arraymodule.c --- a/Modules/arraymodule.c Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/arraymodule.c Sun Jul 20 10:52:46 2014 -0400 @@ -1533,19 +1533,6 @@ PyDoc_STRVAR(reduce_doc, "Return state information for pickling."); static PyObject * -array_sizeof(arrayobject *self, PyObject *unused) -{ - Py_ssize_t res; - res = sizeof(arrayobject) + self->allocated * self->ob_descr->itemsize; - return PyLong_FromSsize_t(res); -} - -PyDoc_STRVAR(sizeof_doc, -"__sizeof__() -> int\n\ -\n\ -Size of the array in memory, in bytes."); - -static PyObject * array_get_typecode(arrayobject *a, void *closure) { char tc = a->ob_descr->typecode; @@ -1619,8 +1606,6 @@ #endif {"write", (PyCFunction)array_tofile_as_write, METH_O, tofile_doc}, - {"__sizeof__", (PyCFunction)array_sizeof, METH_NOARGS, - sizeof_doc}, {NULL, NULL} /* sentinel */ }; diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/audioop.c --- a/Modules/audioop.c Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/audioop.c Sun Jul 20 10:52:46 2014 -0400 @@ -24,21 +24,6 @@ #endif #endif -static const int maxvals[] = {0, 0x7F, 0x7FFF, 0x7FFFFF, 0x7FFFFFFF}; -static const int minvals[] = {0, -0x80, -0x8000, -0x800000, -0x80000000}; -static const unsigned int masks[] = {0, 0xFF, 0xFFFF, 0xFFFFFF, 0xFFFFFFFF}; - -static int -fbound(double val, double minval, double maxval) -{ - if (val > maxval) - val = maxval; - else if (val < minval + 1) - val = minval; - return val; -} - - /* Code shamelessly stolen from sox, 12.17.7, g711.c ** (c) Craig Reese, Joe Campbell and Jeff Poskanzer 1989 */ @@ -360,7 +345,7 @@ signed char *cp; int len, size, val = 0; int i; - unsigned int absval, max = 0; + int max = 0; if ( !PyArg_ParseTuple(args, "s#i:max", &cp, &len, &size) ) return 0; @@ -370,14 +355,10 @@ if ( size == 1 ) val = (int)*CHARP(cp, i); else if ( size == 2 ) val = (int)*SHORTP(cp, i); else if ( size == 4 ) val = (int)*LONGP(cp, i); - if (val < 0) absval = (-val); - else absval = val; - if (absval > max) max = absval; + if ( val < 0 ) val = (-val); + if ( val > max ) max = val; } - if (max <= INT_MAX) - return PyInt_FromLong(max); - else - return PyLong_FromUnsignedLong(max); + return PyInt_FromLong(max); } static PyObject * @@ -386,7 +367,7 @@ signed char *cp; int len, size, val = 0; int i; - int min = 0x7fffffff, max = -0x80000000; + int min = 0x7fffffff, max = -0x7fffffff; if (!PyArg_ParseTuple(args, "s#i:minmax", &cp, &len, &size)) return NULL; @@ -423,7 +404,7 @@ if ( len == 0 ) val = 0; else - val = (int)floor(avg / (double)(len/size)); + val = (int)(avg / (double)(len/size)); return PyInt_FromLong(val); } @@ -433,7 +414,6 @@ signed char *cp; int len, size, val = 0; int i; - unsigned int res; double sum_squares = 0.0; if ( !PyArg_ParseTuple(args, "s#i:rms", &cp, &len, &size) ) @@ -447,13 +427,10 @@ sum_squares += (double)val*(double)val; } if ( len == 0 ) - res = 0; + val = 0; else - res = (unsigned int)sqrt(sum_squares / (double)(len/size)); - if (res <= INT_MAX) - return PyInt_FromLong(res); - else - return PyLong_FromUnsignedLong(res); + val = (int)sqrt(sum_squares / (double)(len/size)); + return PyInt_FromLong(val); } static double _sum2(short *a, short *b, int len) @@ -643,49 +620,52 @@ int len, size, val = 0, prevval = 0, prevextremevalid = 0, prevextreme = 0; int i; - double sum = 0.0; - unsigned int avg; - int diff, prevdiff, nextreme = 0; + double avg = 0.0; + int diff, prevdiff, extremediff, nextreme = 0; if ( !PyArg_ParseTuple(args, "s#i:avgpp", &cp, &len, &size) ) return 0; if (!audioop_check_parameters(len, size)) return NULL; - if (len <= size*2) - return PyInt_FromLong(0); + /* Compute first delta value ahead. Also automatically makes us + ** skip the first extreme value + */ if ( size == 1 ) prevval = (int)*CHARP(cp, 0); else if ( size == 2 ) prevval = (int)*SHORTP(cp, 0); else if ( size == 4 ) prevval = (int)*LONGP(cp, 0); - prevdiff = 17; /* Anything != 0, 1 */ + if ( size == 1 ) val = (int)*CHARP(cp, size); + else if ( size == 2 ) val = (int)*SHORTP(cp, size); + else if ( size == 4 ) val = (int)*LONGP(cp, size); + prevdiff = val - prevval; + for ( i=size; i max ) - max = extremediff; - } - prevextremevalid = 1; - prevextreme = prevval; + diff = val - prevval; + if ( diff*prevdiff < 0 ) { + /* Derivative changed sign. Compute difference to + ** last extreme value and remember. + */ + if ( prevextremevalid ) { + extremediff = prevval - prevextreme; + if ( extremediff < 0 ) + extremediff = -extremediff; + if ( extremediff > max ) + max = extremediff; } - prevval = val; + prevextremevalid = 1; + prevextreme = prevval; + } + prevval = val; + if ( diff != 0 ) prevdiff = diff; - } } - if (max <= INT_MAX) - return PyInt_FromLong(max); - else - return PyLong_FromUnsignedLong(max); + return PyInt_FromLong(max); } static PyObject * @@ -771,7 +749,7 @@ { signed char *cp, *ncp; int len, size, val = 0; - double factor, fval, maxval, minval; + double factor, fval, maxval; PyObject *rv; int i; @@ -780,8 +758,13 @@ if (!audioop_check_parameters(len, size)) return NULL; - maxval = (double) maxvals[size]; - minval = (double) minvals[size]; + if ( size == 1 ) maxval = (double) 0x7f; + else if ( size == 2 ) maxval = (double) 0x7fff; + else if ( size == 4 ) maxval = (double) 0x7fffffff; + else { + PyErr_SetString(AudioopError, "Size should be 1, 2 or 4"); + return 0; + } rv = PyString_FromStringAndSize(NULL, len); if ( rv == 0 ) @@ -794,7 +777,9 @@ else if ( size == 2 ) val = (int)*SHORTP(cp, i); else if ( size == 4 ) val = (int)*LONGP(cp, i); fval = (double)val*factor; - val = (int)floor(fbound(fval, minval, maxval)); + if ( fval > maxval ) fval = maxval; + else if ( fval < -maxval ) fval = -maxval; + val = (int)fval; if ( size == 1 ) *CHARP(ncp, i) = (signed char)val; else if ( size == 2 ) *SHORTP(ncp, i) = (short)val; else if ( size == 4 ) *LONGP(ncp, i) = (Py_Int32)val; @@ -807,7 +792,7 @@ { signed char *cp, *ncp; int len, size, val1 = 0, val2 = 0; - double fac1, fac2, fval, maxval, minval; + double fac1, fac2, fval, maxval; PyObject *rv; int i; @@ -821,8 +806,13 @@ return NULL; } - maxval = (double) maxvals[size]; - minval = (double) minvals[size]; + if ( size == 1 ) maxval = (double) 0x7f; + else if ( size == 2 ) maxval = (double) 0x7fff; + else if ( size == 4 ) maxval = (double) 0x7fffffff; + else { + PyErr_SetString(AudioopError, "Size should be 1, 2 or 4"); + return 0; + } rv = PyString_FromStringAndSize(NULL, len/2); if ( rv == 0 ) @@ -838,7 +828,9 @@ else if ( size == 2 ) val2 = (int)*SHORTP(cp, i+2); else if ( size == 4 ) val2 = (int)*LONGP(cp, i+4); fval = (double)val1*fac1 + (double)val2*fac2; - val1 = (int)floor(fbound(fval, minval, maxval)); + if ( fval > maxval ) fval = maxval; + else if ( fval < -maxval ) fval = -maxval; + val1 = (int)fval; if ( size == 1 ) *CHARP(ncp, i/2) = (signed char)val1; else if ( size == 2 ) *SHORTP(ncp, i/2) = (short)val1; else if ( size == 4 ) *LONGP(ncp, i/2)= (Py_Int32)val1; @@ -851,7 +843,7 @@ { signed char *cp, *ncp; int len, size, val1, val2, val = 0; - double fac1, fac2, fval, maxval, minval; + double fac1, fac2, fval, maxval; PyObject *rv; int i; @@ -861,8 +853,13 @@ if (!audioop_check_parameters(len, size)) return NULL; - maxval = (double) maxvals[size]; - minval = (double) minvals[size]; + if ( size == 1 ) maxval = (double) 0x7f; + else if ( size == 2 ) maxval = (double) 0x7fff; + else if ( size == 4 ) maxval = (double) 0x7fffffff; + else { + PyErr_SetString(AudioopError, "Size should be 1, 2 or 4"); + return 0; + } if (len > INT_MAX/2) { PyErr_SetString(PyExc_MemoryError, @@ -882,10 +879,14 @@ else if ( size == 4 ) val = (int)*LONGP(cp, i); fval = (double)val*fac1; - val1 = (int)floor(fbound(fval, minval, maxval)); + if ( fval > maxval ) fval = maxval; + else if ( fval < -maxval ) fval = -maxval; + val1 = (int)fval; fval = (double)val*fac2; - val2 = (int)floor(fbound(fval, minval, maxval)); + if ( fval > maxval ) fval = maxval; + else if ( fval < -maxval ) fval = -maxval; + val2 = (int)fval; if ( size == 1 ) *CHARP(ncp, i*2) = (signed char)val1; else if ( size == 2 ) *SHORTP(ncp, i*2) = (short)val1; @@ -902,7 +903,7 @@ audioop_add(PyObject *self, PyObject *args) { signed char *cp1, *cp2, *ncp; - int len1, len2, size, val1 = 0, val2 = 0, minval, maxval, newval; + int len1, len2, size, val1 = 0, val2 = 0, maxval, newval; PyObject *rv; int i; @@ -916,8 +917,13 @@ return 0; } - maxval = maxvals[size]; - minval = minvals[size]; + if ( size == 1 ) maxval = 0x7f; + else if ( size == 2 ) maxval = 0x7fff; + else if ( size == 4 ) maxval = 0x7fffffff; + else { + PyErr_SetString(AudioopError, "Size should be 1, 2 or 4"); + return 0; + } rv = PyString_FromStringAndSize(NULL, len1); if ( rv == 0 ) @@ -933,19 +939,12 @@ else if ( size == 2 ) val2 = (int)*SHORTP(cp2, i); else if ( size == 4 ) val2 = (int)*LONGP(cp2, i); - if (size < 4) { - newval = val1 + val2; - /* truncate in case of overflow */ - if (newval > maxval) - newval = maxval; - else if (newval < minval) - newval = minval; - } - else { - double fval = (double)val1 + (double)val2; - /* truncate in case of overflow */ - newval = (int)floor(fbound(fval, minval, maxval)); - } + newval = val1 + val2; + /* truncate in case of overflow */ + if (newval > maxval) newval = maxval; + else if (newval < -maxval) newval = -maxval; + else if (size == 4 && (newval^val1) < 0 && (newval^val2) < 0) + newval = val1 > 0 ? maxval : - maxval; if ( size == 1 ) *CHARP(ncp, i) = (signed char)newval; else if ( size == 2 ) *SHORTP(ncp, i) = (short)newval; @@ -958,8 +957,7 @@ audioop_bias(PyObject *self, PyObject *args) { signed char *cp, *ncp; - int len, size; - unsigned int val = 0, mask; + int len, size, val = 0; PyObject *rv; int i; int bias; @@ -976,20 +974,15 @@ return 0; ncp = (signed char *)PyString_AsString(rv); - mask = masks[size]; for ( i=0; i < len; i += size ) { - if ( size == 1 ) val = (unsigned int)(unsigned char)*CHARP(cp, i); - else if ( size == 2 ) val = (unsigned int)(unsigned short)*SHORTP(cp, i); - else if ( size == 4 ) val = (unsigned int)(Py_UInt32)*LONGP(cp, i); + if ( size == 1 ) val = (int)*CHARP(cp, i); + else if ( size == 2 ) val = (int)*SHORTP(cp, i); + else if ( size == 4 ) val = (int)*LONGP(cp, i); - val += (unsigned int)bias; - /* wrap around in case of overflow */ - val &= mask; - - if ( size == 1 ) *CHARP(ncp, i) = (signed char)(unsigned char)val; - else if ( size == 2 ) *SHORTP(ncp, i) = (short)(unsigned short)val; - else if ( size == 4 ) *LONGP(ncp, i) = (Py_Int32)(Py_UInt32)val; + if ( size == 1 ) *CHARP(ncp, i) = (signed char)(val+bias); + else if ( size == 2 ) *SHORTP(ncp, i) = (short)(val+bias); + else if ( size == 4 ) *LONGP(ncp, i) = (Py_Int32)(val+bias); } return rv; } @@ -1016,15 +1009,15 @@ ncp = (unsigned char *)PyString_AsString(rv); for ( i=0; i < len; i += size ) { - if ( size == 1 ) val = ((int)*CHARP(cp, i)) << 24; - else if ( size == 2 ) val = ((int)*SHORTP(cp, i)) << 16; - else if ( size == 4 ) val = (int)*LONGP(cp, i); + if ( size == 1 ) val = ((int)*CHARP(cp, i)) << 8; + else if ( size == 2 ) val = (int)*SHORTP(cp, i); + else if ( size == 4 ) val = ((int)*LONGP(cp, i)) >> 16; j = len - i - size; - if ( size == 1 ) *CHARP(ncp, j) = (signed char)(val >> 24); - else if ( size == 2 ) *SHORTP(ncp, j) = (short)(val >> 16); - else if ( size == 4 ) *LONGP(ncp, j) = (Py_Int32)val; + if ( size == 1 ) *CHARP(ncp, j) = (signed char)(val >> 8); + else if ( size == 2 ) *SHORTP(ncp, j) = (short)(val); + else if ( size == 4 ) *LONGP(ncp, j) = (Py_Int32)(val<<16); } return rv; } @@ -1058,13 +1051,13 @@ ncp = (unsigned char *)PyString_AsString(rv); for ( i=0, j=0; i < len; i += size, j += size2 ) { - if ( size == 1 ) val = ((int)*CHARP(cp, i)) << 24; - else if ( size == 2 ) val = ((int)*SHORTP(cp, i)) << 16; - else if ( size == 4 ) val = (int)*LONGP(cp, i); + if ( size == 1 ) val = ((int)*CHARP(cp, i)) << 8; + else if ( size == 2 ) val = (int)*SHORTP(cp, i); + else if ( size == 4 ) val = ((int)*LONGP(cp, i)) >> 16; - if ( size2 == 1 ) *CHARP(ncp, j) = (signed char)(val >> 24); - else if ( size2 == 2 ) *SHORTP(ncp, j) = (short)(val >> 16); - else if ( size2 == 4 ) *LONGP(ncp, j) = (Py_Int32)val; + if ( size2 == 1 ) *CHARP(ncp, j) = (signed char)(val >> 8); + else if ( size2 == 2 ) *SHORTP(ncp, j) = (short)(val); + else if ( size2 == 4 ) *LONGP(ncp, j) = (Py_Int32)(val<<16); } return rv; } @@ -1127,10 +1120,6 @@ d = gcd(inrate, outrate); inrate /= d; outrate /= d; - /* divide weightA and weightB by their greatest common divisor */ - d = gcd(weightA, weightB); - weightA /= d; - weightA /= d; if ((size_t)nchannels > PY_SIZE_MAX/sizeof(int)) { PyErr_SetString(PyExc_MemoryError, @@ -1170,9 +1159,7 @@ } /* str <- Space for the output buffer. */ - if (len == 0) - str = PyString_FromStringAndSize(NULL, 0); - else { + { /* There are len input frames, so we need (mathematically) ceiling(len*outrate/inrate) output frames, and each frame requires bytes_per_frame bytes. Computing this @@ -1187,11 +1174,12 @@ else str = PyString_FromStringAndSize(NULL, q * outrate * bytes_per_frame); - } - if (str == NULL) { - PyErr_SetString(PyExc_MemoryError, - "not enough memory for output buffer"); - goto exit; + + if (str == NULL) { + PyErr_SetString(PyExc_MemoryError, + "not enough memory for output buffer"); + goto exit; + } } ncp = PyString_AsString(str); @@ -1226,32 +1214,32 @@ for (chan = 0; chan < nchannels; chan++) { prev_i[chan] = cur_i[chan]; if (size == 1) - cur_i[chan] = ((int)*CHARP(cp, 0)) << 24; + cur_i[chan] = ((int)*CHARP(cp, 0)) << 8; else if (size == 2) - cur_i[chan] = ((int)*SHORTP(cp, 0)) << 16; + cur_i[chan] = (int)*SHORTP(cp, 0); else if (size == 4) - cur_i[chan] = (int)*LONGP(cp, 0); + cur_i[chan] = ((int)*LONGP(cp, 0)) >> 16; cp += size; /* implements a simple digital filter */ - cur_i[chan] = (int)( - ((double)weightA * (double)cur_i[chan] + - (double)weightB * (double)prev_i[chan]) / - ((double)weightA + (double)weightB)); + cur_i[chan] = + (weightA * cur_i[chan] + + weightB * prev_i[chan]) / + (weightA + weightB); } len--; d += outrate; } while (d >= 0) { for (chan = 0; chan < nchannels; chan++) { - cur_o = (int)(((double)prev_i[chan] * (double)d + - (double)cur_i[chan] * (double)(outrate - d)) / - (double)outrate); + cur_o = (prev_i[chan] * d + + cur_i[chan] * (outrate - d)) / + outrate; if (size == 1) - *CHARP(ncp, 0) = (signed char)(cur_o >> 24); + *CHARP(ncp, 0) = (signed char)(cur_o >> 8); else if (size == 2) - *SHORTP(ncp, 0) = (short)(cur_o >> 16); + *SHORTP(ncp, 0) = (short)(cur_o); else if (size == 4) - *LONGP(ncp, 0) = (Py_Int32)(cur_o); + *LONGP(ncp, 0) = (Py_Int32)(cur_o<<16); ncp += size; } d -= inrate; @@ -1310,7 +1298,7 @@ &cp, &len, &size) ) return 0; - if (!audioop_check_size(size)) + if (!audioop_check_parameters(len, size)) return NULL; if (len > INT_MAX/size) { @@ -1379,7 +1367,7 @@ &cp, &len, &size) ) return 0; - if (!audioop_check_size(size)) + if (!audioop_check_parameters(len, size)) return NULL; if (len > INT_MAX/size) { @@ -1521,7 +1509,7 @@ &cp, &len, &size, &state) ) return 0; - if (!audioop_check_size(size)) + if (!audioop_check_parameters(len, size)) return NULL; /* Decode state, should have (value, step) */ diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/binascii.c --- a/Modules/binascii.c Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/binascii.c Sun Jul 20 10:52:46 2014 -0400 @@ -320,10 +320,12 @@ } *ascii_data++ = '\n'; /* Append a courtesy newline */ - /* rv is cleared on error */ - (void)_PyString_Resize(&rv, + if (_PyString_Resize(&rv, (ascii_data - - (unsigned char *)PyString_AS_STRING(rv))); + (unsigned char *)PyString_AS_STRING(rv))) < 0) { + Py_DECREF(rv); + rv = NULL; + } PyBuffer_Release(&pbin); return rv; } @@ -450,8 +452,10 @@ ** string instead; _PyString_Resize() won't do this for us. */ if (bin_len > 0) { - /* rv is cleared on error */ - (void)_PyString_Resize(&rv, bin_len); + if (_PyString_Resize(&rv, bin_len) < 0) { + Py_DECREF(rv); + rv = NULL; + } } else { Py_DECREF(rv); @@ -518,10 +522,12 @@ } *ascii_data++ = '\n'; /* Append a courtesy newline */ - /* rv is cleared on error */ - (void)_PyString_Resize(&rv, + if (_PyString_Resize(&rv, (ascii_data - - (unsigned char *)PyString_AS_STRING(rv))); + (unsigned char *)PyString_AS_STRING(rv))) < 0) { + Py_DECREF(rv); + rv = NULL; + } PyBuffer_Release(&pbuf); return rv; } @@ -595,10 +601,13 @@ Py_DECREF(rv); return NULL; } - /* rv is cleared on error */ if (_PyString_Resize(&rv, (bin_data - - (unsigned char *)PyString_AS_STRING(rv))) == 0) { + (unsigned char *)PyString_AS_STRING(rv))) < 0) { + Py_DECREF(rv); + rv = NULL; + } + if (rv) { PyObject *rrv = Py_BuildValue("Oi", rv, done); PyBuffer_Release(&pascii); Py_DECREF(rv); @@ -663,10 +672,12 @@ } } } - /* rv is cleared on error */ - (void)_PyString_Resize(&rv, + if (_PyString_Resize(&rv, (out_data - - (unsigned char *)PyString_AS_STRING(rv))); + (unsigned char *)PyString_AS_STRING(rv))) < 0) { + Py_DECREF(rv); + rv = NULL; + } PyBuffer_Release(&pbuf); return rv; } @@ -718,10 +729,12 @@ leftchar <<= (6-leftbits); *ascii_data++ = table_b2a_hqx[leftchar & 0x3f]; } - /* rv is cleared on error */ - (void)_PyString_Resize(&rv, + if (_PyString_Resize(&rv, (ascii_data - - (unsigned char *)PyString_AS_STRING(rv))); + (unsigned char *)PyString_AS_STRING(rv))) < 0) { + Py_DECREF(rv); + rv = NULL; + } PyBuffer_Release(&pbin); return rv; } @@ -783,7 +796,7 @@ if ( --out_len_left < 0 ) { \ if ( out_len > PY_SSIZE_T_MAX / 2) return PyErr_NoMemory(); \ if (_PyString_Resize(&rv, 2*out_len) < 0) \ - { PyBuffer_Release(&pin); return NULL; } \ + { Py_DECREF(rv); PyBuffer_Release(&pin); return NULL; } \ out_data = (unsigned char *)PyString_AS_STRING(rv) \ + out_len; \ out_len_left = out_len-1; \ @@ -833,10 +846,12 @@ OUTBYTE(in_byte); } } - /* rv is cleared on error */ - (void)_PyString_Resize(&rv, + if (_PyString_Resize(&rv, (out_data - - (unsigned char *)PyString_AS_STRING(rv))); + (unsigned char *)PyString_AS_STRING(rv))) < 0) { + Py_DECREF(rv); + rv = NULL; + } PyBuffer_Release(&pin); return rv; } diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/bsddb.h --- a/Modules/bsddb.h Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/bsddb.h Sun Jul 20 10:52:46 2014 -0400 @@ -61,7 +61,7 @@ * * http://www.python.org/peps/pep-0291.html * - * This module contains 7 types: + * This module contains 6 types: * * DB (Database) * DBCursor (Database Cursor) @@ -69,7 +69,6 @@ * DBTxn (An explicit database transaction) * DBLock (A lock handle) * DBSequence (Sequence) - * DBSite (Site) * * New datatypes: * @@ -110,7 +109,7 @@ #error "eek! DBVER can't handle minor versions > 9" #endif -#define PY_BSDDB_VERSION "5.3.0" +#define PY_BSDDB_VERSION "4.8.4.1" /* Python object definitions */ @@ -130,9 +129,6 @@ struct DBLogCursorObject; /* Forward declaration */ struct DBTxnObject; /* Forward declaration */ struct DBSequenceObject; /* Forward declaration */ -#if (DBVER >= 52) -struct DBSiteObject; /* Forward declaration */ -#endif typedef struct { PyObject_HEAD @@ -144,9 +140,6 @@ struct DBObject *children_dbs; struct DBTxnObject *children_txns; struct DBLogCursorObject *children_logcursors; -#if (DBVER >= 52) - struct DBSiteObject *children_sites; -#endif PyObject *private_obj; PyObject *rep_transport; PyObject *in_weakreflist; /* List of weak references */ @@ -161,14 +154,15 @@ struct behaviourFlags moduleFlags; struct DBTxnObject *txn; struct DBCursorObject *children_cursors; +#if (DBVER >=43) struct DBSequenceObject *children_sequences; +#endif struct DBObject **sibling_prev_p; struct DBObject *sibling_next; struct DBObject **sibling_prev_p_txn; struct DBObject *sibling_next_txn; PyObject* associateCallback; PyObject* btCompareCallback; - PyObject* dupCompareCallback; int primaryDBType; PyObject *private_obj; PyObject *in_weakreflist; /* List of weak references */ @@ -213,16 +207,6 @@ PyObject *in_weakreflist; /* List of weak references */ } DBLogCursorObject; -#if (DBVER >= 52) -typedef struct DBSiteObject { - PyObject_HEAD - DB_SITE *site; - DBEnvObject *env; - struct DBSiteObject **sibling_prev_p; - struct DBSiteObject *sibling_next; - PyObject *in_weakreflist; /* List of weak references */ -} DBSiteObject; -#endif typedef struct { PyObject_HEAD @@ -232,6 +216,7 @@ } DBLockObject; +#if (DBVER >= 43) typedef struct DBSequenceObject { PyObject_HEAD DB_SEQUENCE* sequence; @@ -243,6 +228,7 @@ struct DBSequenceObject *sibling_next_txn; PyObject *in_weakreflist; /* List of weak references */ } DBSequenceObject; +#endif /* API structure for use by C code */ @@ -250,7 +236,7 @@ /* To access the structure from an external module, use code like the following (error checking missed out for clarity): - // If you are using Python before 2.7: + // If you are using Python before 3.2: BSDDB_api* bsddb_api; PyObject* mod; PyObject* cobj; @@ -263,7 +249,7 @@ Py_DECREF(mod); - // If you are using Python 2.7 or up: (except Python 3.0, unsupported) + // If you are using Python 3.2 or up: BSDDB_api* bsddb_api; // Use "bsddb3._pybsddb.api" if you're using @@ -271,14 +257,10 @@ bsddb_api = (void **)PyCapsule_Import("bsddb._bsddb.api", 1); - Check "api_version" number before trying to use the API. - The structure's members must not be changed. */ -#define PYBSDDB_API_VERSION 1 typedef struct { - unsigned int api_version; /* Type objects */ PyTypeObject* db_type; PyTypeObject* dbcursor_type; @@ -286,7 +268,9 @@ PyTypeObject* dbenv_type; PyTypeObject* dbtxn_type; PyTypeObject* dblock_type; +#if (DBVER >= 43) PyTypeObject* dbsequence_type; +#endif /* Functions */ int (*makeDBError)(int err); @@ -305,9 +289,9 @@ #define DBEnvObject_Check(v) ((v)->ob_type == bsddb_api->dbenv_type) #define DBTxnObject_Check(v) ((v)->ob_type == bsddb_api->dbtxn_type) #define DBLockObject_Check(v) ((v)->ob_type == bsddb_api->dblock_type) -#define DBSequenceObject_Check(v) \ - ((bsddb_api->dbsequence_type) && \ - ((v)->ob_type == bsddb_api->dbsequence_type)) +#if (DBVER >= 43) +#define DBSequenceObject_Check(v) ((v)->ob_type == bsddb_api->dbsequence_type) +#endif #endif /* COMPILING_BSDDB_C */ diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/bz2module.c --- a/Modules/bz2module.c Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/bz2module.c Sun Jul 20 10:52:46 2014 -0400 @@ -41,8 +41,23 @@ #define MODE_READ_EOF 2 #define MODE_WRITE 3 +#define BZ2FileObject_Check(v) (Py_TYPE(v) == &BZ2File_Type) -#ifndef BZ_CONFIG_ERROR + +#ifdef BZ_CONFIG_ERROR + +#if SIZEOF_LONG >= 8 +#define BZS_TOTAL_OUT(bzs) \ + (((long)bzs->total_out_hi32 << 32) + bzs->total_out_lo32) +#elif SIZEOF_LONG_LONG >= 8 +#define BZS_TOTAL_OUT(bzs) \ + (((PY_LONG_LONG)bzs->total_out_hi32 << 32) + bzs->total_out_lo32) +#else +#define BZS_TOTAL_OUT(bzs) \ + bzs->total_out_lo32 +#endif + +#else /* ! BZ_CONFIG_ERROR */ #define BZ2_bzRead bzRead #define BZ2_bzReadOpen bzReadOpen @@ -57,6 +72,8 @@ #define BZ2_bzDecompressInit bzDecompressInit #define BZ2_bzDecompressEnd bzDecompressEnd +#define BZS_TOTAL_OUT(bzs) bzs->total_out + #endif /* ! BZ_CONFIG_ERROR */ @@ -73,8 +90,6 @@ #define RELEASE_LOCK(obj) #endif -#define MIN(X, Y) (((X) < (Y)) ? (X) : (Y)) - /* Bits in f_newlinetypes */ #define NEWLINE_UNKNOWN 0 /* No newline seen, yet */ #define NEWLINE_CR 1 /* \r newline seen */ @@ -219,20 +234,6 @@ return currentsize + (currentsize >> 3) + 6; } -static int -Util_GrowBuffer(PyObject **buf) -{ - size_t size = PyString_GET_SIZE(*buf); - size_t new_size = Util_NewBufferSize(size); - if (new_size > size) { - return _PyString_Resize(buf, new_size); - } else { /* overflow */ - PyErr_SetString(PyExc_OverflowError, - "Unable to allocate buffer - output too large"); - return -1; - } -} - /* This is a hacked version of Python's fileobject.c:get_line(). */ static PyObject * Util_GetLine(BZ2FileObject *f, int n) @@ -732,8 +733,7 @@ } else { /* Grow the big buffer */ - if (_PyString_Resize(&big_buffer, buffersize)) - goto error; + _PyString_Resize(&big_buffer, buffersize); buffer = PyString_AS_STRING(big_buffer); } continue; @@ -1207,16 +1207,12 @@ 0, NULL, NULL); break; } - if (self->file) { - if (self->fp) - PyFile_DecUseCount((PyFileObject *)self->file); - ret = PyObject_CallMethod(self->file, "close", NULL); - } else { - Py_INCREF(Py_None); - ret = Py_None; + if (self->fp) { + PyFile_DecUseCount((PyFileObject *)self->file); + self->fp = NULL; } - self->fp = NULL; self->mode = MODE_CLOSED; + ret = PyObject_CallMethod(self->file, "close", NULL); if (bzerror != BZ_OK) { Util_CatchBZ2Error(bzerror); Py_XDECREF(ret); @@ -1484,9 +1480,10 @@ 0, NULL, NULL); break; } - if (self->fp != NULL && self->file != NULL) + if (self->fp) { PyFile_DecUseCount((PyFileObject *)self->file); - self->fp = NULL; + self->fp = NULL; + } Util_DropReadAhead(self); Py_XDECREF(self->file); Py_TYPE(self)->tp_free((PyObject *)self); @@ -1611,16 +1608,20 @@ BZ2Comp_compress(BZ2CompObject *self, PyObject *args) { Py_buffer pdata; - size_t input_left; - size_t output_size = 0; + char *data; + int datasize; + int bufsize = SMALLCHUNK; + PY_LONG_LONG totalout; PyObject *ret = NULL; bz_stream *bzs = &self->bzs; int bzerror; if (!PyArg_ParseTuple(args, "s*:compress", &pdata)) return NULL; + data = pdata.buf; + datasize = pdata.len; - if (pdata.len == 0) { + if (datasize == 0) { PyBuffer_Release(&pdata); return PyString_FromString(""); } @@ -1632,52 +1633,40 @@ goto error; } - ret = PyString_FromStringAndSize(NULL, SMALLCHUNK); + ret = PyString_FromStringAndSize(NULL, bufsize); if (!ret) goto error; - bzs->next_in = pdata.buf; - bzs->avail_in = MIN(pdata.len, UINT_MAX); - input_left = pdata.len - bzs->avail_in; + bzs->next_in = data; + bzs->avail_in = datasize; + bzs->next_out = BUF(ret); + bzs->avail_out = bufsize; - bzs->next_out = BUF(ret); - bzs->avail_out = PyString_GET_SIZE(ret); + totalout = BZS_TOTAL_OUT(bzs); for (;;) { - char *saved_next_out; - Py_BEGIN_ALLOW_THREADS - saved_next_out = bzs->next_out; bzerror = BZ2_bzCompress(bzs, BZ_RUN); - output_size += bzs->next_out - saved_next_out; Py_END_ALLOW_THREADS - if (bzerror != BZ_RUN_OK) { Util_CatchBZ2Error(bzerror); goto error; } - if (bzs->avail_in == 0) { - if (input_left == 0) - break; /* no more input data */ - bzs->avail_in = MIN(input_left, UINT_MAX); - input_left -= bzs->avail_in; - } + if (bzs->avail_in == 0) + break; /* no more input data */ if (bzs->avail_out == 0) { - size_t buffer_left = PyString_GET_SIZE(ret) - output_size; - if (buffer_left == 0) { - if (Util_GrowBuffer(&ret) < 0) { - BZ2_bzCompressEnd(bzs); - goto error; - } - bzs->next_out = BUF(ret) + output_size; - buffer_left = PyString_GET_SIZE(ret) - output_size; + bufsize = Util_NewBufferSize(bufsize); + if (_PyString_Resize(&ret, bufsize) < 0) { + BZ2_bzCompressEnd(bzs); + goto error; } - bzs->avail_out = MIN(buffer_left, UINT_MAX); + bzs->next_out = BUF(ret) + (BZS_TOTAL_OUT(bzs) + - totalout); + bzs->avail_out = bufsize - (bzs->next_out - BUF(ret)); } } - if (_PyString_Resize(&ret, output_size) < 0) - goto error; + _PyString_Resize(&ret, (Py_ssize_t)(BZS_TOTAL_OUT(bzs) - totalout)); RELEASE_LOCK(self); PyBuffer_Release(&pdata); @@ -1700,34 +1689,33 @@ static PyObject * BZ2Comp_flush(BZ2CompObject *self) { - size_t output_size = 0; + int bufsize = SMALLCHUNK; PyObject *ret = NULL; bz_stream *bzs = &self->bzs; + PY_LONG_LONG totalout; int bzerror; ACQUIRE_LOCK(self); if (!self->running) { - PyErr_SetString(PyExc_ValueError, "object was already flushed"); + PyErr_SetString(PyExc_ValueError, "object was already " + "flushed"); goto error; } self->running = 0; - ret = PyString_FromStringAndSize(NULL, SMALLCHUNK); + ret = PyString_FromStringAndSize(NULL, bufsize); if (!ret) goto error; bzs->next_out = BUF(ret); - bzs->avail_out = PyString_GET_SIZE(ret); + bzs->avail_out = bufsize; + + totalout = BZS_TOTAL_OUT(bzs); for (;;) { - char *saved_next_out; - Py_BEGIN_ALLOW_THREADS - saved_next_out = bzs->next_out; bzerror = BZ2_bzCompress(bzs, BZ_FINISH); - output_size += bzs->next_out - saved_next_out; Py_END_ALLOW_THREADS - if (bzerror == BZ_STREAM_END) { break; } else if (bzerror != BZ_FINISH_OK) { @@ -1735,20 +1723,18 @@ goto error; } if (bzs->avail_out == 0) { - size_t buffer_left = PyString_GET_SIZE(ret) - output_size; - if (buffer_left == 0) { - if (Util_GrowBuffer(&ret) < 0) - goto error; - bzs->next_out = BUF(ret) + output_size; - buffer_left = PyString_GET_SIZE(ret) - output_size; - } - bzs->avail_out = MIN(buffer_left, UINT_MAX); + bufsize = Util_NewBufferSize(bufsize); + if (_PyString_Resize(&ret, bufsize) < 0) + goto error; + bzs->next_out = BUF(ret); + bzs->next_out = BUF(ret) + (BZS_TOTAL_OUT(bzs) + - totalout); + bzs->avail_out = bufsize - (bzs->next_out - BUF(ret)); } } - if (output_size != PyString_GET_SIZE(ret)) - if (_PyString_Resize(&ret, output_size) < 0) - goto error; + if (bzs->avail_out != 0) + _PyString_Resize(&ret, (Py_ssize_t)(BZS_TOTAL_OUT(bzs) - totalout)); RELEASE_LOCK(self); return ret; @@ -1913,14 +1899,18 @@ BZ2Decomp_decompress(BZ2DecompObject *self, PyObject *args) { Py_buffer pdata; - size_t input_left; - size_t output_size = 0; + char *data; + int datasize; + int bufsize = SMALLCHUNK; + PY_LONG_LONG totalout; PyObject *ret = NULL; bz_stream *bzs = &self->bzs; int bzerror; if (!PyArg_ParseTuple(args, "s*:decompress", &pdata)) return NULL; + data = pdata.buf; + datasize = pdata.len; ACQUIRE_LOCK(self); if (!self->running) { @@ -1929,65 +1919,52 @@ goto error; } - ret = PyString_FromStringAndSize(NULL, SMALLCHUNK); + ret = PyString_FromStringAndSize(NULL, bufsize); if (!ret) goto error; - bzs->next_in = pdata.buf; - bzs->avail_in = MIN(pdata.len, UINT_MAX); - input_left = pdata.len - bzs->avail_in; + bzs->next_in = data; + bzs->avail_in = datasize; + bzs->next_out = BUF(ret); + bzs->avail_out = bufsize; - bzs->next_out = BUF(ret); - bzs->avail_out = PyString_GET_SIZE(ret); + totalout = BZS_TOTAL_OUT(bzs); for (;;) { - char *saved_next_out; - Py_BEGIN_ALLOW_THREADS - saved_next_out = bzs->next_out; bzerror = BZ2_bzDecompress(bzs); - output_size += bzs->next_out - saved_next_out; Py_END_ALLOW_THREADS - if (bzerror == BZ_STREAM_END) { - self->running = 0; - input_left += bzs->avail_in; - if (input_left != 0) { + if (bzs->avail_in != 0) { Py_DECREF(self->unused_data); self->unused_data = - PyString_FromStringAndSize(bzs->next_in, input_left); - if (self->unused_data == NULL) - goto error; + PyString_FromStringAndSize(bzs->next_in, + bzs->avail_in); } + self->running = 0; break; } if (bzerror != BZ_OK) { Util_CatchBZ2Error(bzerror); goto error; } - if (bzs->avail_in == 0) { - if (input_left == 0) - break; /* no more input data */ - bzs->avail_in = MIN(input_left, UINT_MAX); - input_left -= bzs->avail_in; - } + if (bzs->avail_in == 0) + break; /* no more input data */ if (bzs->avail_out == 0) { - size_t buffer_left = PyString_GET_SIZE(ret) - output_size; - if (buffer_left == 0) { - if (Util_GrowBuffer(&ret) < 0) { - BZ2_bzDecompressEnd(bzs); - goto error; - } - bzs->next_out = BUF(ret) + output_size; - buffer_left = PyString_GET_SIZE(ret) - output_size; + bufsize = Util_NewBufferSize(bufsize); + if (_PyString_Resize(&ret, bufsize) < 0) { + BZ2_bzDecompressEnd(bzs); + goto error; } - bzs->avail_out = MIN(buffer_left, UINT_MAX); + bzs->next_out = BUF(ret); + bzs->next_out = BUF(ret) + (BZS_TOTAL_OUT(bzs) + - totalout); + bzs->avail_out = bufsize - (bzs->next_out - BUF(ret)); } } - if (output_size != PyString_GET_SIZE(ret)) - if (_PyString_Resize(&ret, output_size) < 0) - goto error; + if (bzs->avail_out != 0) + _PyString_Resize(&ret, (Py_ssize_t)(BZS_TOTAL_OUT(bzs) - totalout)); RELEASE_LOCK(self); PyBuffer_Release(&pdata); @@ -2134,10 +2111,10 @@ bz2_compress(PyObject *self, PyObject *args, PyObject *kwargs) { int compresslevel=9; - int action; Py_buffer pdata; - size_t input_left; - size_t output_size = 0; + char *data; + int datasize; + int bufsize; PyObject *ret = NULL; bz_stream _bzs; bz_stream *bzs = &_bzs; @@ -2148,6 +2125,8 @@ kwlist, &pdata, &compresslevel)) return NULL; + data = pdata.buf; + datasize = pdata.len; if (compresslevel < 1 || compresslevel > 9) { PyErr_SetString(PyExc_ValueError, @@ -2156,7 +2135,11 @@ return NULL; } - ret = PyString_FromStringAndSize(NULL, SMALLCHUNK); + /* Conforming to bz2 manual, this is large enough to fit compressed + * data in one shot. We will check it later anyway. */ + bufsize = datasize + (datasize/100+1) + 600; + + ret = PyString_FromStringAndSize(NULL, bufsize); if (!ret) { PyBuffer_Release(&pdata); return NULL; @@ -2164,12 +2147,10 @@ memset(bzs, 0, sizeof(bz_stream)); - bzs->next_in = pdata.buf; - bzs->avail_in = MIN(pdata.len, UINT_MAX); - input_left = pdata.len - bzs->avail_in; - + bzs->next_in = data; + bzs->avail_in = datasize; bzs->next_out = BUF(ret); - bzs->avail_out = PyString_GET_SIZE(ret); + bzs->avail_out = bufsize; bzerror = BZ2_bzCompressInit(bzs, compresslevel, 0, 0); if (bzerror != BZ_OK) { @@ -2179,53 +2160,36 @@ return NULL; } - action = input_left > 0 ? BZ_RUN : BZ_FINISH; - for (;;) { - char *saved_next_out; - Py_BEGIN_ALLOW_THREADS - saved_next_out = bzs->next_out; - bzerror = BZ2_bzCompress(bzs, action); - output_size += bzs->next_out - saved_next_out; + bzerror = BZ2_bzCompress(bzs, BZ_FINISH); Py_END_ALLOW_THREADS - if (bzerror == BZ_STREAM_END) { break; - } else if (bzerror != BZ_RUN_OK && bzerror != BZ_FINISH_OK) { + } else if (bzerror != BZ_FINISH_OK) { BZ2_bzCompressEnd(bzs); Util_CatchBZ2Error(bzerror); PyBuffer_Release(&pdata); Py_DECREF(ret); return NULL; } - if (action == BZ_RUN && bzs->avail_in == 0) { - if (input_left == 0) { - action = BZ_FINISH; - } else { - bzs->avail_in = MIN(input_left, UINT_MAX); - input_left -= bzs->avail_in; + if (bzs->avail_out == 0) { + bufsize = Util_NewBufferSize(bufsize); + if (_PyString_Resize(&ret, bufsize) < 0) { + BZ2_bzCompressEnd(bzs); + PyBuffer_Release(&pdata); + Py_DECREF(ret); + return NULL; } - } - if (bzs->avail_out == 0) { - size_t buffer_left = PyString_GET_SIZE(ret) - output_size; - if (buffer_left == 0) { - if (Util_GrowBuffer(&ret) < 0) { - BZ2_bzCompressEnd(bzs); - PyBuffer_Release(&pdata); - return NULL; - } - bzs->next_out = BUF(ret) + output_size; - buffer_left = PyString_GET_SIZE(ret) - output_size; - } - bzs->avail_out = MIN(buffer_left, UINT_MAX); + bzs->next_out = BUF(ret) + BZS_TOTAL_OUT(bzs); + bzs->avail_out = bufsize - (bzs->next_out - BUF(ret)); } } - if (output_size != PyString_GET_SIZE(ret)) - _PyString_Resize(&ret, output_size); /* Sets ret to NULL on failure. */ + if (bzs->avail_out != 0) + _PyString_Resize(&ret, (Py_ssize_t)BZS_TOTAL_OUT(bzs)); + BZ2_bzCompressEnd(bzs); - BZ2_bzCompressEnd(bzs); PyBuffer_Release(&pdata); return ret; } @@ -2241,8 +2205,9 @@ bz2_decompress(PyObject *self, PyObject *args) { Py_buffer pdata; - size_t input_left; - size_t output_size = 0; + char *data; + int datasize; + int bufsize = SMALLCHUNK; PyObject *ret; bz_stream _bzs; bz_stream *bzs = &_bzs; @@ -2250,13 +2215,15 @@ if (!PyArg_ParseTuple(args, "s*:decompress", &pdata)) return NULL; + data = pdata.buf; + datasize = pdata.len; - if (pdata.len == 0) { + if (datasize == 0) { PyBuffer_Release(&pdata); return PyString_FromString(""); } - ret = PyString_FromStringAndSize(NULL, SMALLCHUNK); + ret = PyString_FromStringAndSize(NULL, bufsize); if (!ret) { PyBuffer_Release(&pdata); return NULL; @@ -2264,12 +2231,10 @@ memset(bzs, 0, sizeof(bz_stream)); - bzs->next_in = pdata.buf; - bzs->avail_in = MIN(pdata.len, UINT_MAX); - input_left = pdata.len - bzs->avail_in; - + bzs->next_in = data; + bzs->avail_in = datasize; bzs->next_out = BUF(ret); - bzs->avail_out = PyString_GET_SIZE(ret); + bzs->avail_out = bufsize; bzerror = BZ2_bzDecompressInit(bzs, 0, 0); if (bzerror != BZ_OK) { @@ -2280,14 +2245,9 @@ } for (;;) { - char *saved_next_out; - Py_BEGIN_ALLOW_THREADS - saved_next_out = bzs->next_out; bzerror = BZ2_bzDecompress(bzs); - output_size += bzs->next_out - saved_next_out; Py_END_ALLOW_THREADS - if (bzerror == BZ_STREAM_END) { break; } else if (bzerror != BZ_OK) { @@ -2298,37 +2258,31 @@ return NULL; } if (bzs->avail_in == 0) { - if (input_left == 0) { + BZ2_bzDecompressEnd(bzs); + PyErr_SetString(PyExc_ValueError, + "couldn't find end of stream"); + PyBuffer_Release(&pdata); + Py_DECREF(ret); + return NULL; + } + if (bzs->avail_out == 0) { + bufsize = Util_NewBufferSize(bufsize); + if (_PyString_Resize(&ret, bufsize) < 0) { BZ2_bzDecompressEnd(bzs); - PyErr_SetString(PyExc_ValueError, - "couldn't find end of stream"); PyBuffer_Release(&pdata); Py_DECREF(ret); return NULL; } - bzs->avail_in = MIN(input_left, UINT_MAX); - input_left -= bzs->avail_in; - } - if (bzs->avail_out == 0) { - size_t buffer_left = PyString_GET_SIZE(ret) - output_size; - if (buffer_left == 0) { - if (Util_GrowBuffer(&ret) < 0) { - BZ2_bzDecompressEnd(bzs); - PyBuffer_Release(&pdata); - return NULL; - } - bzs->next_out = BUF(ret) + output_size; - buffer_left = PyString_GET_SIZE(ret) - output_size; - } - bzs->avail_out = MIN(buffer_left, UINT_MAX); + bzs->next_out = BUF(ret) + BZS_TOTAL_OUT(bzs); + bzs->avail_out = bufsize - (bzs->next_out - BUF(ret)); } } - if (output_size != PyString_GET_SIZE(ret)) - _PyString_Resize(&ret, output_size); /* Sets ret to NULL on failure. */ - + if (bzs->avail_out != 0) + _PyString_Resize(&ret, (Py_ssize_t)BZS_TOTAL_OUT(bzs)); BZ2_bzDecompressEnd(bzs); PyBuffer_Release(&pdata); + return ret; } diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/cPickle.c --- a/Modules/cPickle.c Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/cPickle.c Sun Jul 20 10:52:46 2014 -0400 @@ -139,15 +139,15 @@ typedef struct { PyObject_HEAD - Py_ssize_t length; /* number of initial slots in data currently used */ - Py_ssize_t size; /* number of slots in data allocated */ + int length; /* number of initial slots in data currently used */ + int size; /* number of slots in data allocated */ PyObject **data; } Pdata; static void Pdata_dealloc(Pdata *self) { - Py_ssize_t i; + int i; PyObject **p; for (i = self->length, p = self->data; --i >= 0; p++) { @@ -193,9 +193,9 @@ * number of items, this is a (non-erroneous) NOP. */ static int -Pdata_clear(Pdata *self, Py_ssize_t clearto) +Pdata_clear(Pdata *self, int clearto) { - Py_ssize_t i; + int i; PyObject **p; if (clearto < 0) return stackUnderflow(); @@ -214,17 +214,18 @@ static int Pdata_grow(Pdata *self) { - Py_ssize_t bigger; - Py_ssize_t nbytes; - + int bigger; + size_t nbytes; PyObject **tmp; - if (self->size > (PY_SSIZE_T_MAX >> 1)) + bigger = self->size << 1; + if (bigger <= 0) /* was 0, or new value overflows */ goto nomemory; - bigger = self->size << 1; - if (bigger > (PY_SSIZE_T_MAX / sizeof(PyObject *))) + if ((int)(size_t)bigger != bigger) goto nomemory; - nbytes = bigger * sizeof(PyObject *); + nbytes = (size_t)bigger * sizeof(PyObject *); + if (nbytes / sizeof(PyObject *) != (size_t)bigger) + goto nomemory; tmp = realloc(self->data, nbytes); if (tmp == NULL) goto nomemory; @@ -279,10 +280,10 @@ static PyObject * -Pdata_popTuple(Pdata *self, Py_ssize_t start) +Pdata_popTuple(Pdata *self, int start) { PyObject *r; - Py_ssize_t i, j, l; + int i, j, l; l = self->length-start; r = PyTuple_New(l); @@ -296,10 +297,10 @@ } static PyObject * -Pdata_popList(Pdata *self, Py_ssize_t start) +Pdata_popList(Pdata *self, int start) { PyObject *r; - Py_ssize_t i, j, l; + int i, j, l; l=self->length-start; if (!( r=PyList_New(l))) return NULL; @@ -324,7 +325,8 @@ #define FREE_ARG_TUP(self) { \ if (Py_REFCNT(self->arg) > 1) { \ - Py_CLEAR(self->arg); \ + Py_DECREF(self->arg); \ + self->arg=NULL; \ } \ } @@ -345,9 +347,9 @@ int bin; int fast; /* Fast mode doesn't save in memo, don't use if circ ref */ - Py_ssize_t (*write_func)(struct Picklerobject *, const char *, Py_ssize_t); + int (*write_func)(struct Picklerobject *, const char *, Py_ssize_t); char *write_buf; - Py_ssize_t buf_size; + int buf_size; PyObject *dispatch_table; int fast_container; /* count nested container dumps */ PyObject *fast_memo; @@ -371,12 +373,12 @@ PyObject *mark; PyObject *pers_func; PyObject *last_string; - Py_ssize_t *marks; - Py_ssize_t num_marks; - Py_ssize_t marks_size; + int *marks; + int num_marks; + int marks_size; Py_ssize_t (*read_func)(struct Unpicklerobject *, char **, Py_ssize_t); Py_ssize_t (*readline_func)(struct Unpicklerobject *, char **); - Py_ssize_t buf_size; + int buf_size; char *buf; PyObject *find_class; } Unpicklerobject; @@ -422,7 +424,7 @@ return NULL; } -static Py_ssize_t +static int write_file(Picklerobject *self, const char *s, Py_ssize_t n) { size_t nbyteswritten; @@ -431,6 +433,11 @@ return 0; } + if (n > INT_MAX) { + /* String too large */ + return -1; + } + PyFile_IncUseCount((PyFileObject *)self->file); Py_BEGIN_ALLOW_THREADS nbyteswritten = fwrite(s, sizeof(char), n, self->fp); @@ -441,44 +448,40 @@ return -1; } - return n; + return (int)n; } -static Py_ssize_t +static int write_cStringIO(Picklerobject *self, const char *s, Py_ssize_t n) { - Py_ssize_t len = n; - if (s == NULL) { return 0; } - while (n > INT_MAX) { - if (PycStringIO->cwrite((PyObject *)self->file, s, INT_MAX) != INT_MAX) { - return -1; - } - n -= INT_MAX; - } - if (PycStringIO->cwrite((PyObject *)self->file, s, n) != n) { return -1; } - return len; + return (int)n; } -static Py_ssize_t +static int write_none(Picklerobject *self, const char *s, Py_ssize_t n) { if (s == NULL) return 0; - return n; + if (n > INT_MAX) return -1; + return (int)n; } -static Py_ssize_t -write_other(Picklerobject *self, const char *s, Py_ssize_t n) +static int +write_other(Picklerobject *self, const char *s, Py_ssize_t _n) { PyObject *py_str = 0, *junk = 0; - + int n; + + if (_n > INT_MAX) + return -1; + n = (int)_n; if (s == NULL) { if (!( self->buf_size )) return 0; py_str = PyString_FromStringAndSize(self->write_buf, @@ -487,7 +490,7 @@ return -1; } else { - if (self->buf_size && n > WRITE_BUF_SIZE - self->buf_size) { + if (self->buf_size && (n + self->buf_size) > WRITE_BUF_SIZE) { if (write_other(self, NULL, 0) < 0) return -1; } @@ -528,7 +531,7 @@ size_t nbytesread; if (self->buf_size == 0) { - Py_ssize_t size; + int size; size = ((n < 32) ? 32 : n); if (!( self->buf = (char *)malloc(size))) { @@ -572,7 +575,7 @@ static Py_ssize_t readline_file(Unpicklerobject *self, char **s) { - Py_ssize_t i; + int i; if (self->buf_size == 0) { if (!( self->buf = (char *)malloc(40))) { @@ -584,7 +587,7 @@ i = 0; while (1) { - Py_ssize_t bigger; + int bigger; char *newbuf; for (; i < (self->buf_size - 1); i++) { if (feof(self->fp) || @@ -594,13 +597,13 @@ return i + 1; } } - if (self->buf_size > (PY_SSIZE_T_MAX >> 1)) { + bigger = self->buf_size << 1; + if (bigger <= 0) { /* overflow */ PyErr_NoMemory(); return -1; } - bigger = self->buf_size << 1; newbuf = (char *)realloc(self->buf, bigger); - if (newbuf == NULL) { + if (!newbuf) { PyErr_NoMemory(); return -1; } @@ -613,63 +616,30 @@ static Py_ssize_t read_cStringIO(Unpicklerobject *self, char **s, Py_ssize_t n) { - Py_ssize_t len = n; - char *start, *end = NULL; - - while (1) { - int k; - char *ptr; - if (n > INT_MAX) - k = INT_MAX; - else - k = (int)n; - if (PycStringIO->cread((PyObject *)self->file, &ptr, k) != k) { - PyErr_SetNone(PyExc_EOFError); - return -1; - } - if (end == NULL) - start = ptr; - else if (ptr != end) { - /* non-continuous area */ - return -1; - } - if (n <= INT_MAX) - break; - end = ptr + INT_MAX; - n -= INT_MAX; - } - - *s = start; - - return len; + char *ptr; + + if (PycStringIO->cread((PyObject *)self->file, &ptr, n) != n) { + PyErr_SetNone(PyExc_EOFError); + return -1; + } + + *s = ptr; + + return n; } static Py_ssize_t readline_cStringIO(Unpicklerobject *self, char **s) { - Py_ssize_t n = 0; - char *start = NULL, *end = NULL; - - while (1) { - int k; - char *ptr; - if ((k = PycStringIO->creadline((PyObject *)self->file, &ptr)) < 0) { - return -1; - } - n += k; - if (end == NULL) - start = ptr; - else if (ptr != end) { - /* non-continuous area */ - return -1; - } - if (k == 0 || ptr[k - 1] == '\n') - break; - end = ptr + k; - } - - *s = start; + Py_ssize_t n; + char *ptr; + + if ((n = PycStringIO->creadline((PyObject *)self->file, &ptr)) < 0) { + return -1; + } + + *s = ptr; return n; } @@ -730,7 +700,7 @@ * The caller is responsible for free()'ing the return value. */ static char * -pystrndup(const char *s, Py_ssize_t n) +pystrndup(const char *s, int n) { char *r = (char *)malloc(n+1); if (r == NULL) @@ -745,7 +715,7 @@ get(Picklerobject *self, PyObject *id) { PyObject *value, *mv; - Py_ssize_t c_value; + long c_value; char s[30]; size_t len; @@ -765,8 +735,7 @@ if (!self->bin) { s[0] = GET; - PyOS_snprintf(s + 1, sizeof(s) - 1, - "%" PY_FORMAT_SIZE_T "d\n", c_value); + PyOS_snprintf(s + 1, sizeof(s) - 1, "%ld\n", c_value); len = strlen(s); } else if (Pdata_Check(self->file)) { @@ -811,7 +780,8 @@ put2(Picklerobject *self, PyObject *ob) { char c_str[30]; - Py_ssize_t len, p; + int p; + size_t len; int res = -1; PyObject *py_ob_id = 0, *memo_len = 0, *t = 0; @@ -848,8 +818,7 @@ if (!self->bin) { c_str[0] = PUT; - PyOS_snprintf(c_str + 1, sizeof(c_str) - 1, - "%" PY_FORMAT_SIZE_T "d\n", p); + PyOS_snprintf(c_str + 1, sizeof(c_str) - 1, "%d\n", p); len = strlen(c_str); } else if (Pdata_Check(self->file)) { @@ -1025,7 +994,7 @@ { char c_str[32]; long l = PyInt_AS_LONG((PyIntObject *)args); - Py_ssize_t len = 0; + int len = 0; if (!self->bin #if SIZEOF_LONG > 4 @@ -1232,7 +1201,7 @@ static int save_string(Picklerobject *self, PyObject *args, int doput) { - Py_ssize_t size, len; + int size, len; PyObject *repr=0; if ((size = PyString_Size(args)) < 0) @@ -1479,7 +1448,7 @@ static int store_tuple_elements(Picklerobject *self, PyObject *t, int len) { - Py_ssize_t i; + int i; int res = -1; /* guilty until proved innocent */ assert(PyTuple_Size(t) == len); @@ -1508,7 +1477,7 @@ save_tuple(Picklerobject *self, PyObject *args) { PyObject *py_tuple_id = NULL; - Py_ssize_t len, i; + int len, i; int res = -1; static char tuple = TUPLE; @@ -1721,7 +1690,7 @@ { int res = -1; char s[3]; - Py_ssize_t len; + int len; PyObject *iter; if (self->fast && !fast_save_enter(self, args)) @@ -1974,7 +1943,7 @@ { int res = -1; char s[3]; - Py_ssize_t len; + int len; if (self->fast && !fast_save_enter(self, args)) goto finally; @@ -2058,7 +2027,7 @@ if ((getinitargs_func = PyObject_GetAttr(args, __getinitargs___str))) { PyObject *element = 0; - Py_ssize_t i, len; + int i, len; if (!( class_args = PyObject_Call(getinitargs_func, empty_tuple, NULL))) @@ -2320,8 +2289,7 @@ save_pers(Picklerobject *self, PyObject *args, PyObject *f) { PyObject *pid = 0; - Py_ssize_t size; - int res = -1; + int size, res = -1; static char persid = PERSID, binpersid = BINPERSID; @@ -2463,7 +2431,7 @@ if (use_newobj) { PyObject *cls; PyObject *newargtup; - Py_ssize_t n, i; + int n, i; /* Sanity checks. */ n = PyTuple_Size(argtup); @@ -2847,7 +2815,7 @@ static PyObject * Pickle_getvalue(Picklerobject *self, PyObject *args) { - Py_ssize_t l, i, rsize, ssize, clear=1, lm; + int l, i, rsize, ssize, clear=1, lm; long ik; PyObject *k, *r; char *s, *p, *have_get; @@ -3346,7 +3314,7 @@ return global; } -static Py_ssize_t +static int marker(Unpicklerobject *self) { if (self->num_marks < 1) { @@ -3377,8 +3345,7 @@ { PyObject *py_int = 0; char *endptr, *s; - Py_ssize_t len; - int res = -1; + int len, res = -1; long l; if ((len = self->readline_func(self, &s)) < 0) return -1; @@ -3510,8 +3477,7 @@ { PyObject *l = 0; char *end, *s; - Py_ssize_t len; - int res = -1; + int len, res = -1; if ((len = self->readline_func(self, &s)) < 0) return -1; if (len < 2) return bad_readline(); @@ -3575,8 +3541,7 @@ { PyObject *py_float = 0; char *endptr, *s; - Py_ssize_t len; - int res = -1; + int len, res = -1; double d; if ((len = self->readline_func(self, &s)) < 0) return -1; @@ -3632,8 +3597,7 @@ load_string(Unpicklerobject *self) { PyObject *str = 0; - Py_ssize_t len; - int res = -1; + int len, res = -1; char *s, *p; if ((len = self->readline_func(self, &s)) < 0) return -1; @@ -3642,19 +3606,17 @@ /* Strip outermost quotes */ - while (len > 0 && s[len-1] <= ' ') + while (s[len-1] <= ' ') len--; - if (len > 1 && s[0]=='"' && s[len-1]=='"') { + if(s[0]=='"' && s[len-1]=='"'){ s[len-1] = '\0'; p = s + 1 ; len -= 2; - } - else if (len > 1 && s[0]=='\'' && s[len-1]=='\'') { + } else if(s[0]=='\'' && s[len-1]=='\''){ s[len-1] = '\0'; p = s + 1 ; len -= 2; - } - else + } else goto insecure; /********************************************/ @@ -3677,7 +3639,7 @@ load_binstring(Unpicklerobject *self) { PyObject *py_string = 0; - Py_ssize_t l; + long l; char *s; if (self->read_func(self, &s, 4) < 0) return -1; @@ -3729,17 +3691,20 @@ load_unicode(Unpicklerobject *self) { PyObject *str = 0; - Py_ssize_t len; + int len, res = -1; char *s; if ((len = self->readline_func(self, &s)) < 0) return -1; if (len < 1) return bad_readline(); if (!( str = PyUnicode_DecodeRawUnicodeEscape(s, len - 1, NULL))) - return -1; + goto finally; PDATA_PUSH(self->stack, str, -1); return 0; + + finally: + return res; } #endif @@ -3749,7 +3714,7 @@ load_binunicode(Unpicklerobject *self) { PyObject *unicode; - Py_ssize_t l; + long l; char *s; if (self->read_func(self, &s, 4) < 0) return -1; @@ -3780,7 +3745,7 @@ load_tuple(Unpicklerobject *self) { PyObject *tup; - Py_ssize_t i; + int i; if ((i = marker(self)) < 0) return -1; if (!( tup=Pdata_popTuple(self->stack, i))) return -1; @@ -3833,7 +3798,7 @@ load_list(Unpicklerobject *self) { PyObject *list = 0; - Py_ssize_t i; + int i; if ((i = marker(self)) < 0) return -1; if (!( list=Pdata_popList(self->stack, i))) return -1; @@ -3845,7 +3810,7 @@ load_dict(Unpicklerobject *self) { PyObject *dict, *key, *value; - Py_ssize_t i, j, k; + int i, j, k; if ((i = marker(self)) < 0) return -1; j=self->stack->length; @@ -3921,7 +3886,7 @@ load_obj(Unpicklerobject *self) { PyObject *class, *tup, *obj=0; - Py_ssize_t i; + int i; if ((i = marker(self)) < 0) return -1; if (!( tup=Pdata_popTuple(self->stack, i+1))) return -1; @@ -3942,7 +3907,7 @@ load_inst(Unpicklerobject *self) { PyObject *tup, *class=0, *obj=0, *module_name, *class_name; - Py_ssize_t i, len; + int i, len; char *s; if ((i = marker(self)) < 0) return -1; @@ -4028,7 +3993,7 @@ load_global(Unpicklerobject *self) { PyObject *class = 0, *module_name = 0, *class_name = 0; - Py_ssize_t len; + int len; char *s; if ((len = self->readline_func(self, &s)) < 0) return -1; @@ -4059,7 +4024,7 @@ load_persid(Unpicklerobject *self) { PyObject *pid = 0; - Py_ssize_t len; + int len; char *s; if (self->pers_func) { @@ -4137,7 +4102,7 @@ static int load_pop(Unpicklerobject *self) { - Py_ssize_t len = self->stack->length; + int len = self->stack->length; /* Note that we split the (pickle.py) stack into two stacks, an object stack and a mark stack. We have to be clever and @@ -4162,7 +4127,7 @@ static int load_pop_mark(Unpicklerobject *self) { - Py_ssize_t i; + int i; if ((i = marker(self)) < 0) return -1; @@ -4177,7 +4142,7 @@ load_dup(Unpicklerobject *self) { PyObject *last; - Py_ssize_t len; + int len; if ((len = self->stack->length) <= 0) return stackUnderflow(); last=self->stack->data[len-1]; @@ -4191,7 +4156,7 @@ load_get(Unpicklerobject *self) { PyObject *py_str = 0, *value = 0; - Py_ssize_t len; + int len; char *s; int rc; @@ -4249,7 +4214,7 @@ PyObject *py_key = 0, *value = 0; unsigned char c; char *s; - Py_ssize_t key; + long key; int rc; if (self->read_func(self, &s, 4) < 0) return -1; @@ -4352,7 +4317,7 @@ load_put(Unpicklerobject *self) { PyObject *py_str = 0, *value = 0; - Py_ssize_t len, l; + int len, l; char *s; if ((l = self->readline_func(self, &s)) < 0) return -1; @@ -4372,7 +4337,7 @@ PyObject *py_key = 0, *value = 0; unsigned char key; char *s; - Py_ssize_t len; + int len; if (self->read_func(self, &s, 1) < 0) return -1; if (!( (len=self->stack->length) > 0 )) return stackUnderflow(); @@ -4391,10 +4356,10 @@ load_long_binput(Unpicklerobject *self) { PyObject *py_key = 0, *value = 0; - Py_ssize_t key; + long key; unsigned char c; char *s; - Py_ssize_t len; + int len; if (self->read_func(self, &s, 4) < 0) return -1; if (!( len=self->stack->length )) return stackUnderflow(); @@ -4417,10 +4382,10 @@ static int -do_append(Unpicklerobject *self, Py_ssize_t x) +do_append(Unpicklerobject *self, int x) { PyObject *value = 0, *list = 0, *append_method = 0; - Py_ssize_t len, i; + int len, i; len=self->stack->length; if (!( len >= x && x > 0 )) return stackUnderflow(); @@ -4486,11 +4451,11 @@ } -static Py_ssize_t -do_setitems(Unpicklerobject *self, Py_ssize_t x) +static int +do_setitems(Unpicklerobject *self, int x) { PyObject *value = 0, *key = 0, *dict = 0; - Py_ssize_t len, i, r=0; + int len, i, r=0; if (!( (len=self->stack->length) >= x && x > 0 )) return stackUnderflow(); @@ -4531,8 +4496,8 @@ PyObject *state, *inst, *slotstate; PyObject *__setstate__; PyObject *d_key, *d_value; + Py_ssize_t i; int res = -1; - Py_ssize_t i; /* Stack is ... instance, state. We want to leave instance at * the stack top, possibly mutated via instance.__setstate__(state). @@ -4631,7 +4596,7 @@ static int load_mark(Unpicklerobject *self) { - Py_ssize_t s; + int s; /* Note that we split the (pickle.py) stack into two stacks, an object stack and a mark stack. Here we push a mark onto the @@ -4639,14 +4604,14 @@ */ if ((self->num_marks + 1) >= self->marks_size) { - Py_ssize_t *marks; + int *marks; s=self->marks_size+20; if (s <= self->num_marks) s=self->num_marks + 1; if (self->marks == NULL) - marks=(Py_ssize_t *)malloc(s * sizeof(Py_ssize_t)); + marks=(int *)malloc(s * sizeof(int)); else - marks=(Py_ssize_t *)realloc(self->marks, - s * sizeof(Py_ssize_t)); + marks=(int *)realloc(self->marks, + s * sizeof(int)); if (!marks) { PyErr_NoMemory(); return -1; @@ -5016,7 +4981,7 @@ static int noload_obj(Unpicklerobject *self) { - Py_ssize_t i; + int i; if ((i = marker(self)) < 0) return -1; return Pdata_clear(self->stack, i+1); @@ -5026,7 +4991,7 @@ static int noload_inst(Unpicklerobject *self) { - Py_ssize_t i; + int i; char *s; if ((i = marker(self)) < 0) return -1; @@ -5103,7 +5068,7 @@ static int noload_appends(Unpicklerobject *self) { - Py_ssize_t i; + int i; if ((i = marker(self)) < 0) return -1; return Pdata_clear(self->stack, i); } @@ -5117,7 +5082,7 @@ static int noload_setitems(Unpicklerobject *self) { - Py_ssize_t i; + int i; if ((i = marker(self)) < 0) return -1; return Pdata_clear(self->stack, i); } diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/cStringIO.c --- a/Modules/cStringIO.c Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/cStringIO.c Sun Jul 20 10:52:46 2014 -0400 @@ -66,7 +66,9 @@ PyObject_HEAD char *buf; Py_ssize_t pos, string_size; - Py_buffer pbuf; + /* We store a reference to the object here in order to keep + the buffer alive during the lifetime of the Iobject. */ + PyObject *pbuf; } Iobject; /* IOobject (common) methods */ @@ -125,16 +127,12 @@ static PyObject * IO_getval(IOobject *self, PyObject *args) { PyObject *use_pos=Py_None; - int b; Py_ssize_t s; if (!IO__opencheck(self)) return NULL; if (!PyArg_UnpackTuple(args,"getval", 0, 1,&use_pos)) return NULL; - b = PyObject_IsTrue(use_pos); - if (b < 0) - return NULL; - if (b) { + if (PyObject_IsTrue(use_pos)) { s=self->pos; if (s > self->string_size) s=self->string_size; } @@ -168,15 +166,10 @@ n = l; if (n < 0) n=0; } - if (n > INT_MAX) { - PyErr_SetString(PyExc_OverflowError, - "length too large"); - return -1; - } *output=((IOobject*)self)->buf + ((IOobject*)self)->pos; ((IOobject*)self)->pos += n; - return (int)n; + return n; } static PyObject * @@ -195,30 +188,26 @@ static int IO_creadline(PyObject *self, char **output) { - char *n, *start, *end; - Py_ssize_t len; + char *n, *s; + Py_ssize_t l; if (!IO__opencheck(IOOOBJECT(self))) return -1; - n = start = ((IOobject*)self)->buf + ((IOobject*)self)->pos; - end = ((IOobject*)self)->buf + ((IOobject*)self)->string_size; - while (n < end && *n != '\n') - n++; + for (n = ((IOobject*)self)->buf + ((IOobject*)self)->pos, + s = ((IOobject*)self)->buf + ((IOobject*)self)->string_size; + n < s && *n != '\n'; n++); - if (n < end) n++; + if (n < s) n++; - len = n - start; - if (len > INT_MAX) - len = INT_MAX; + *output=((IOobject*)self)->buf + ((IOobject*)self)->pos; + l = n - ((IOobject*)self)->buf - ((IOobject*)self)->pos; - *output=start; - - assert(IOOOBJECT(self)->pos <= PY_SSIZE_T_MAX - len); + assert(IOOOBJECT(self)->pos <= PY_SSIZE_T_MAX - l); assert(IOOOBJECT(self)->pos >= 0); assert(IOOOBJECT(self)->string_size >= 0); - ((IOobject*)self)->pos += len; - return (int)len; + ((IOobject*)self)->pos += l; + return (int)l; } static PyObject * @@ -246,9 +235,9 @@ int n; char *output; PyObject *result, *line; - Py_ssize_t hint = 0, length = 0; + int hint = 0, length = 0; - if (!PyArg_ParseTuple(args, "|n:readlines", &hint)) return NULL; + if (!PyArg_ParseTuple(args, "|i:readlines", &hint)) return NULL; result = PyList_New(0); if (!result) @@ -384,41 +373,31 @@ static int -O_cwrite(PyObject *self, const char *c, Py_ssize_t len) { - Py_ssize_t newpos; +O_cwrite(PyObject *self, const char *c, Py_ssize_t l) { + Py_ssize_t newl; Oobject *oself; char *newbuf; if (!IO__opencheck(IOOOBJECT(self))) return -1; oself = (Oobject *)self; - if (len > INT_MAX) { - PyErr_SetString(PyExc_OverflowError, - "length too large"); - return -1; - } - assert(len >= 0); - if (oself->pos >= PY_SSIZE_T_MAX - len) { - PyErr_SetString(PyExc_OverflowError, - "new position too large"); - return -1; - } - newpos = oself->pos + len; - if (newpos >= oself->buf_size) { - size_t newsize = oself->buf_size; - newsize *= 2; - if (newsize <= (size_t)newpos || newsize > PY_SSIZE_T_MAX) { - assert(newpos < PY_SSIZE_T_MAX - 1); - newsize = newpos + 1; + newl = oself->pos+l; + if (newl >= oself->buf_size) { + oself->buf_size *= 2; + if (oself->buf_size <= newl) { + assert(newl + 1 < INT_MAX); + oself->buf_size = (int)(newl+1); } - newbuf = (char*)realloc(oself->buf, newsize); + newbuf = (char*)realloc(oself->buf, oself->buf_size); if (!newbuf) { PyErr_SetString(PyExc_MemoryError,"out of memory"); + free(oself->buf); + oself->buf = 0; + oself->buf_size = oself->pos = 0; return -1; - } - oself->buf_size = (Py_ssize_t)newsize; + } oself->buf = newbuf; - } + } if (oself->string_size < oself->pos) { /* In case of overseek, pad with null bytes the buffer region between @@ -433,27 +412,26 @@ (oself->pos - oself->string_size) * sizeof(char)); } - memcpy(oself->buf + oself->pos, c, len); + memcpy(oself->buf+oself->pos,c,l); - oself->pos = newpos; + assert(oself->pos + l < INT_MAX); + oself->pos += (int)l; if (oself->string_size < oself->pos) { oself->string_size = oself->pos; } - return (int)len; + return (int)l; } static PyObject * O_write(Oobject *self, PyObject *args) { - Py_buffer buf; - int result; + char *c; + int l; - if (!PyArg_ParseTuple(args, "s*:write", &buf)) return NULL; + if (!PyArg_ParseTuple(args, "t#:write", &c, &l)) return NULL; - result = O_cwrite((PyObject*)self, buf.buf, buf.len); - PyBuffer_Release(&buf); - if (result < 0) return NULL; + if (O_cwrite((PyObject*)self,c,l) < 0) return NULL; Py_INCREF(Py_None); return Py_None; @@ -606,7 +584,7 @@ static PyObject * I_close(Iobject *self, PyObject *unused) { - PyBuffer_Release(&self->pbuf); + Py_CLEAR(self->pbuf); self->buf = NULL; self->pos = self->string_size = 0; @@ -635,7 +613,7 @@ static void I_dealloc(Iobject *self) { - PyBuffer_Release(&self->pbuf); + Py_XDECREF(self->pbuf); PyObject_Del(self); } @@ -680,26 +658,25 @@ static PyObject * newIobject(PyObject *s) { Iobject *self; - Py_buffer buf; - PyObject *args; - int result; + char *buf; + Py_ssize_t size; - args = Py_BuildValue("(O)", s); - if (args == NULL) + if (PyUnicode_Check(s)) { + if (PyObject_AsCharBuffer(s, (const char **)&buf, &size) != 0) return NULL; - result = PyArg_ParseTuple(args, "s*:StringIO", &buf); - Py_DECREF(args); - if (!result) - return NULL; + } + else if (PyObject_AsReadBuffer(s, (const void **)&buf, &size)) { + PyErr_Format(PyExc_TypeError, "expected read buffer, %.200s found", + s->ob_type->tp_name); + return NULL; + } self = PyObject_New(Iobject, &Itype); - if (!self) { - PyBuffer_Release(&buf); - return NULL; - } - self->buf=buf.buf; - self->string_size=buf.len; - self->pbuf=buf; + if (!self) return NULL; + Py_INCREF(s); + self->buf=buf; + self->string_size=size; + self->pbuf=s; self->pos=0; return (PyObject*)self; diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/cdmodule.c --- a/Modules/cdmodule.c Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/cdmodule.c Sun Jul 20 10:52:46 2014 -0400 @@ -535,8 +535,10 @@ /* no sense in keeping the callbacks, so remove them */ for (i = 0; i < NCALLBACKS; i++) { - Py_CLEAR(self->ob_cdcallbacks[i].ob_cdcallback); - Py_CLEAR(self->ob_cdcallbacks[i].ob_cdcallbackarg); + Py_XDECREF(self->ob_cdcallbacks[i].ob_cdcallback); + self->ob_cdcallbacks[i].ob_cdcallback = NULL; + Py_XDECREF(self->ob_cdcallbacks[i].ob_cdcallbackarg); + self->ob_cdcallbacks[i].ob_cdcallbackarg = NULL; } Py_INCREF(Py_None); @@ -586,9 +588,11 @@ CDremovecallback(self->ob_cdparser, (CDDATATYPES) type); - Py_CLEAR(self->ob_cdcallbacks[type].ob_cdcallback); + Py_XDECREF(self->ob_cdcallbacks[type].ob_cdcallback); + self->ob_cdcallbacks[type].ob_cdcallback = NULL; - Py_CLEAR(self->ob_cdcallbacks[type].ob_cdcallbackarg); + Py_XDECREF(self->ob_cdcallbacks[type].ob_cdcallbackarg); + self->ob_cdcallbacks[type].ob_cdcallbackarg = NULL; Py_INCREF(Py_None); return Py_None; @@ -664,8 +668,10 @@ int i; for (i = 0; i < NCALLBACKS; i++) { - Py_CLEAR(self->ob_cdcallbacks[i].ob_cdcallback); - Py_CLEAR(self->ob_cdcallbacks[i].ob_cdcallbackarg); + Py_XDECREF(self->ob_cdcallbacks[i].ob_cdcallback); + self->ob_cdcallbacks[i].ob_cdcallback = NULL; + Py_XDECREF(self->ob_cdcallbacks[i].ob_cdcallbackarg); + self->ob_cdcallbacks[i].ob_cdcallbackarg = NULL; } CDdeleteparser(self->ob_cdparser); PyObject_Del(self); diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/cmathmodule.c --- a/Modules/cmathmodule.c Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/cmathmodule.c Sun Jul 20 10:52:46 2014 -0400 @@ -1006,13 +1006,6 @@ else errno = 0; } - else if (phi == 0.0) { - /* Workaround for buggy results with phi=-0.0 on OS X 10.8. See - bugs.python.org/issue18513. */ - z.real = r; - z.imag = r * phi; - errno = 0; - } else { z.real = r * cos(phi); z.imag = r * sin(phi); diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/dbmmodule.c --- a/Modules/dbmmodule.c Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/dbmmodule.c Sun Jul 20 10:52:46 2014 -0400 @@ -168,13 +168,11 @@ dbm_contains(register dbmobject *dp, PyObject *v) { datum key, val; - char *ptr; - Py_ssize_t size; - if (PyString_AsStringAndSize(v, &ptr, &size)) + if (PyString_AsStringAndSize(v, (char **)&key.dptr, + (Py_ssize_t *)&key.dsize)) { return -1; - key.dptr = ptr; - key.dsize = size; + } /* Expand check_dbmobject_open to return -1 */ if (dp->di_dbm == NULL) { diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/errnomodule.c --- a/Modules/errnomodule.c Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/errnomodule.c Sun Jul 20 10:52:46 2014 -0400 @@ -783,9 +783,6 @@ #ifdef WSAN inscode(d, ds, de, "WSAN", WSAN, "Error WSAN"); #endif -#ifdef ENOTSUP - inscode(d, ds, de, "ENOTSUP", ENOTSUP, "Operation not supported"); -#endif Py_DECREF(de); } diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/expat/COPYING --- a/Modules/expat/COPYING Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/expat/COPYING Sun Jul 20 10:52:46 2014 -0400 @@ -1,6 +1,5 @@ Copyright (c) 1998, 1999, 2000 Thai Open Source Software Center Ltd and Clark Cooper -Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006 Expat maintainers. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/expat/amigaconfig.h --- a/Modules/expat/amigaconfig.h Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/expat/amigaconfig.h Sun Jul 20 10:52:46 2014 -0400 @@ -10,12 +10,66 @@ /* Define to 1 if you have the header file. */ #undef HAVE_CHECK_H +/* Define to 1 if you have the header file. */ +#undef HAVE_DLFCN_H + +/* Define to 1 if you have the header file. */ +#define HAVE_FCNTL_H 1 + +/* Define to 1 if you have the `getpagesize' function. */ +#undef HAVE_GETPAGESIZE + +/* Define to 1 if you have the header file. */ +#define HAVE_INTTYPES_H 1 + /* Define to 1 if you have the `memmove' function. */ #define HAVE_MEMMOVE 1 +/* Define to 1 if you have the header file. */ +#undef HAVE_MEMORY_H + +/* Define to 1 if you have a working `mmap' system call. */ +#undef HAVE_MMAP + +/* Define to 1 if you have the header file. */ +#define HAVE_STDINT_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STDLIB_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STRINGS_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STRING_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_STAT_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_TYPES_H 1 + /* Define to 1 if you have the header file. */ #define HAVE_UNISTD_H 1 +/* Define to the address where bug reports for this package should be sent. */ +#define PACKAGE_BUGREPORT "expat-bugs@mail.libexpat.org" + +/* Define to the full name of this package. */ +#define PACKAGE_NAME "expat" + +/* Define to the full name and version of this package. */ +#define PACKAGE_STRING "expat 1.95.8" + +/* Define to the one symbol short name of this package. */ +#undef PACKAGE_TARNAME + +/* Define to the version of this package. */ +#define PACKAGE_VERSION "1.95.8" + +/* Define to 1 if you have the ANSI C header files. */ +#define STDC_HEADERS 1 + /* whether byteorder is bigendian */ #define WORDS_BIGENDIAN @@ -29,4 +83,14 @@ /* Define to make XML Namespaces functionality available. */ #define XML_NS +/* Define to empty if `const' does not conform to ANSI C. */ +#undef const + +/* Define to `long' if does not define. */ +#undef off_t + +/* Define to `unsigned' if does not define. */ +#undef size_t + + #endif /* AMIGACONFIG_H */ diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/expat/ascii.h --- a/Modules/expat/ascii.h Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/expat/ascii.h Sun Jul 20 10:52:46 2014 -0400 @@ -83,10 +83,3 @@ #define ASCII_LSQB 0x5B #define ASCII_RSQB 0x5D #define ASCII_UNDERSCORE 0x5F -#define ASCII_LPAREN 0x28 -#define ASCII_RPAREN 0x29 -#define ASCII_FF 0x0C -#define ASCII_SLASH 0x2F -#define ASCII_HASH 0x23 -#define ASCII_PIPE 0x7C -#define ASCII_COMMA 0x2C diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/expat/expat.h --- a/Modules/expat/expat.h Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/expat/expat.h Sun Jul 20 10:52:46 2014 -0400 @@ -742,29 +742,6 @@ XMLPARSEAPI(int) XML_GetIdAttributeIndex(XML_Parser parser); -#ifdef XML_ATTR_INFO -/* Source file byte offsets for the start and end of attribute names and values. - The value indices are exclusive of surrounding quotes; thus in a UTF-8 source - file an attribute value of "blah" will yield: - info->valueEnd - info->valueStart = 4 bytes. -*/ -typedef struct { - XML_Index nameStart; /* Offset to beginning of the attribute name. */ - XML_Index nameEnd; /* Offset after the attribute name's last byte. */ - XML_Index valueStart; /* Offset to beginning of the attribute value. */ - XML_Index valueEnd; /* Offset after the attribute value's last byte. */ -} XML_AttrInfo; - -/* Returns an array of XML_AttrInfo structures for the attribute/value pairs - passed in last call to the XML_StartElementHandler that were specified - in the start-tag rather than defaulted. Each attribute/value pair counts - as 1; thus the number of entries in the array is - XML_GetSpecifiedAttributeCount(parser) / 2. -*/ -XMLPARSEAPI(const XML_AttrInfo *) -XML_GetAttributeInfo(XML_Parser parser); -#endif - /* Parses some input. Returns XML_STATUS_ERROR if a fatal error is detected. The last call to XML_Parse must have isFinal true; len may be zero for this call (or any other). @@ -906,17 +883,6 @@ XML_SetParamEntityParsing(XML_Parser parser, enum XML_ParamEntityParsing parsing); -/* Sets the hash salt to use for internal hash calculations. - Helps in preventing DoS attacks based on predicting hash - function behavior. This must be called before parsing is started. - Returns 1 if successful, 0 when called after parsing has started. -*/ -XMLPARSEAPI(int) -XML_SetHashSalt(XML_Parser parser, - unsigned long hash_salt); - -#define XML_HAS_SET_HASH_SALT /* Python Only: Defined for pyexpat.c. */ - /* If XML_Parse or XML_ParseBuffer have returned XML_STATUS_ERROR, then XML_GetErrorCode returns information about the error. */ @@ -1017,9 +983,7 @@ XML_FEATURE_MIN_SIZE, XML_FEATURE_SIZEOF_XML_CHAR, XML_FEATURE_SIZEOF_XML_LCHAR, - XML_FEATURE_NS, - XML_FEATURE_LARGE_SIZE, - XML_FEATURE_ATTR_INFO + XML_FEATURE_NS /* Additional features must be added to the end of this enum. */ }; @@ -1039,7 +1003,7 @@ change to major or minor version. */ #define XML_MAJOR_VERSION 2 -#define XML_MINOR_VERSION 1 +#define XML_MINOR_VERSION 0 #define XML_MICRO_VERSION 0 #ifdef __cplusplus diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/expat/expat_external.h --- a/Modules/expat/expat_external.h Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/expat/expat_external.h Sun Jul 20 10:52:46 2014 -0400 @@ -38,9 +38,9 @@ system headers may assume the cdecl convention. */ #ifndef XMLCALL -#if defined(_MSC_VER) +#if defined(XML_USE_MSC_EXTENSIONS) #define XMLCALL __cdecl -#elif defined(__GNUC__) && defined(__i386) && !defined(__INTEL_COMPILER) +#elif defined(__GNUC__) && defined(__i386) #define XMLCALL __attribute__((cdecl)) #else /* For any platform which uses this definition and supports more than diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/expat/internal.h --- a/Modules/expat/internal.h Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/expat/internal.h Sun Jul 20 10:52:46 2014 -0400 @@ -20,7 +20,7 @@ and therefore subject to change. */ -#if defined(__GNUC__) && defined(__i386__) && !defined(__MINGW32__) +#if defined(__GNUC__) && defined(__i386__) /* We'll use this version by default only where we know it helps. regparm() generates warnings on Solaris boxes. See SF bug #692878. diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/expat/pyexpatns.h --- a/Modules/expat/pyexpatns.h Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/expat/pyexpatns.h Sun Jul 20 10:52:46 2014 -0400 @@ -97,7 +97,6 @@ #define XML_SetEntityDeclHandler PyExpat_XML_SetEntityDeclHandler #define XML_SetExternalEntityRefHandler PyExpat_XML_SetExternalEntityRefHandler #define XML_SetExternalEntityRefHandlerArg PyExpat_XML_SetExternalEntityRefHandlerArg -#define XML_SetHashSalt PyExpat_XML_SetHashSalt #define XML_SetNamespaceDeclHandler PyExpat_XML_SetNamespaceDeclHandler #define XML_SetNotationDeclHandler PyExpat_XML_SetNotationDeclHandler #define XML_SetNotStandaloneHandler PyExpat_XML_SetNotStandaloneHandler diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/expat/watcomconfig.h --- a/Modules/expat/watcomconfig.h Sat Jul 19 16:34:33 2014 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,47 +0,0 @@ -/* expat_config.h for use with Open Watcom 1.5 and above. */ - -#ifndef WATCOMCONFIG_H -#define WATCOMCONFIG_H - -#ifdef __NT__ -#define WIN32_LEAN_AND_MEAN -#include -#undef WIN32_LEAN_AND_MEAN -#endif - -/* 1234 = LIL_ENDIAN, 4321 = BIGENDIAN */ -#define BYTEORDER 1234 - -/* Define to 1 if you have the `memmove' function. */ -#define HAVE_MEMMOVE 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_UNISTD_H 1 - -/* Define to the address where bug reports for this package should be sent. */ -#define PACKAGE_BUGREPORT "expat-bugs@mail.libexpat.org" - -/* Define to the full name of this package. */ -#define PACKAGE_NAME "expat" - -/* Define to the full name and version of this package. */ -#define PACKAGE_STRING "expat 2.0.0" - -/* Define to the one symbol short name of this package. */ -#undef PACKAGE_TARNAME - -/* Define to the version of this package. */ -#define PACKAGE_VERSION "2.0.0" - -/* Define to specify how much context to retain around the current parse - point. */ -#define XML_CONTEXT_BYTES 1024 - -/* Define to make parameter entity parsing functionality available. */ -#define XML_DTD 1 - -/* Define to make XML Namespaces functionality available. */ -#define XML_NS 1 - -#endif - diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/expat/xmlparse.c --- a/Modules/expat/xmlparse.c Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/expat/xmlparse.c Sun Jul 20 10:52:46 2014 -0400 @@ -2,27 +2,22 @@ See the file COPYING for copying permission. */ -#include -#include /* memset(), memcpy() */ -#include -#include /* UINT_MAX */ -#include /* time() */ - #define XML_BUILDING_EXPAT 1 #ifdef COMPILED_FROM_DSP #include "winconfig.h" #elif defined(MACOS_CLASSIC) #include "macconfig.h" -#elif defined(__amigaos__) +#elif defined(__amigaos4__) #include "amigaconfig.h" -#elif defined(__WATCOMC__) -#include "watcomconfig.h" #elif defined(HAVE_EXPAT_CONFIG_H) #include #endif /* ndef COMPILED_FROM_DSP */ -#include "ascii.h" +#include +#include /* memset(), memcpy() */ +#include + #include "expat.h" #ifdef XML_UNICODE @@ -31,8 +26,7 @@ #define XmlGetInternalEncoding XmlGetUtf16InternalEncoding #define XmlGetInternalEncodingNS XmlGetUtf16InternalEncodingNS #define XmlEncode XmlUtf16Encode -/* Using pointer subtraction to convert to integer type. */ -#define MUST_CONVERT(enc, s) (!(enc)->isUtf16 || (((char *)(s) - (char *)NULL) & 1)) +#define MUST_CONVERT(enc, s) (!(enc)->isUtf16 || (((unsigned long)s) & 1)) typedef unsigned short ICHAR; #else #define XML_ENCODE_MAX XML_UTF8_ENCODE_MAX @@ -329,15 +323,15 @@ static enum XML_Error initializeEncoding(XML_Parser parser); static enum XML_Error -doProlog(XML_Parser parser, const ENCODING *enc, const char *s, - const char *end, int tok, const char *next, const char **nextPtr, +doProlog(XML_Parser parser, const ENCODING *enc, const char *s, + const char *end, int tok, const char *next, const char **nextPtr, XML_Bool haveMore); static enum XML_Error -processInternalEntity(XML_Parser parser, ENTITY *entity, +processInternalEntity(XML_Parser parser, ENTITY *entity, XML_Bool betweenDecl); static enum XML_Error doContent(XML_Parser parser, int startTagLevel, const ENCODING *enc, - const char *start, const char *end, const char **endPtr, + const char *start, const char *end, const char **endPtr, XML_Bool haveMore); static enum XML_Error doCdataSection(XML_Parser parser, const ENCODING *, const char **startPtr, @@ -355,7 +349,7 @@ addBinding(XML_Parser parser, PREFIX *prefix, const ATTRIBUTE_ID *attId, const XML_Char *uri, BINDING **bindingsPtr); static int -defineAttribute(ELEMENT_TYPE *type, ATTRIBUTE_ID *, XML_Bool isCdata, +defineAttribute(ELEMENT_TYPE *type, ATTRIBUTE_ID *, XML_Bool isCdata, XML_Bool isId, const XML_Char *dfltValue, XML_Parser parser); static enum XML_Error storeAttributeValue(XML_Parser parser, const ENCODING *, XML_Bool isCdata, @@ -393,13 +387,12 @@ static void dtdDestroy(DTD *p, XML_Bool isDocEntity, const XML_Memory_Handling_Suite *ms); static int -dtdCopy(XML_Parser oldParser, - DTD *newDtd, const DTD *oldDtd, const XML_Memory_Handling_Suite *ms); +dtdCopy(DTD *newDtd, const DTD *oldDtd, const XML_Memory_Handling_Suite *ms); static int -copyEntityTable(XML_Parser oldParser, - HASH_TABLE *, STRING_POOL *, const HASH_TABLE *); +copyEntityTable(HASH_TABLE *, STRING_POOL *, const HASH_TABLE *); + static NAMED * -lookup(XML_Parser parser, HASH_TABLE *table, KEY name, size_t createSize); +lookup(HASH_TABLE *table, KEY name, size_t createSize); static void FASTCALL hashTableInit(HASH_TABLE *, const XML_Memory_Handling_Suite *ms); static void FASTCALL hashTableClear(HASH_TABLE *); @@ -432,15 +425,11 @@ getElementType(XML_Parser parser, const ENCODING *enc, const char *ptr, const char *end); -static unsigned long generate_hash_secret_salt(void); -static XML_Bool startParsing(XML_Parser parser); - static XML_Parser parserCreate(const XML_Char *encodingName, const XML_Memory_Handling_Suite *memsuite, const XML_Char *nameSep, DTD *dtd); - static void parserInit(XML_Parser parser, const XML_Char *encodingName); @@ -540,9 +529,6 @@ NS_ATT *m_nsAtts; unsigned long m_nsAttsVersion; unsigned char m_nsAttsPower; -#ifdef XML_ATTR_INFO - XML_AttrInfo *m_attInfo; -#endif POSITION m_position; STRING_POOL m_tempPool; STRING_POOL m_temp2Pool; @@ -556,7 +542,6 @@ XML_Bool m_useForeignDTD; enum XML_ParamEntityParsing m_paramEntityParsing; #endif - unsigned long m_hash_secret_salt; }; #define MALLOC(s) (parser->m_mem.malloc_fcn((s))) @@ -651,7 +636,6 @@ #define nsAtts (parser->m_nsAtts) #define nsAttsVersion (parser->m_nsAttsVersion) #define nsAttsPower (parser->m_nsAttsPower) -#define attInfo (parser->m_attInfo) #define tempPool (parser->m_tempPool) #define temp2Pool (parser->m_temp2Pool) #define groupConnector (parser->m_groupConnector) @@ -665,7 +649,6 @@ #define useForeignDTD (parser->m_useForeignDTD) #define paramEntityParsing (parser->m_paramEntityParsing) #endif /* XML_DTD */ -#define hash_secret_salt (parser->m_hash_secret_salt) XML_Parser XMLCALL XML_ParserCreate(const XML_Char *encodingName) @@ -682,43 +665,28 @@ } static const XML_Char implicitContext[] = { - ASCII_x, ASCII_m, ASCII_l, ASCII_EQUALS, ASCII_h, ASCII_t, ASCII_t, ASCII_p, - ASCII_COLON, ASCII_SLASH, ASCII_SLASH, ASCII_w, ASCII_w, ASCII_w, - ASCII_PERIOD, ASCII_w, ASCII_3, ASCII_PERIOD, ASCII_o, ASCII_r, ASCII_g, - ASCII_SLASH, ASCII_X, ASCII_M, ASCII_L, ASCII_SLASH, ASCII_1, ASCII_9, - ASCII_9, ASCII_8, ASCII_SLASH, ASCII_n, ASCII_a, ASCII_m, ASCII_e, - ASCII_s, ASCII_p, ASCII_a, ASCII_c, ASCII_e, '\0' + 'x', 'm', 'l', '=', 'h', 't', 't', 'p', ':', '/', '/', + 'w', 'w', 'w', '.', 'w', '3', '.', 'o', 'r', 'g', '/', + 'X', 'M', 'L', '/', '1', '9', '9', '8', '/', + 'n', 'a', 'm', 'e', 's', 'p', 'a', 'c', 'e', '\0' }; -static unsigned long -generate_hash_secret_salt(void) -{ - unsigned int seed = time(NULL) % UINT_MAX; - srand(seed); - return rand(); -} - -static XML_Bool /* only valid for root parser */ -startParsing(XML_Parser parser) -{ - /* hash functions must be initialized before setContext() is called */ - if (hash_secret_salt == 0) - hash_secret_salt = generate_hash_secret_salt(); - if (ns) { - /* implicit context only set for root parser, since child - parsers (i.e. external entity parsers) will inherit it - */ - return setContext(parser, implicitContext); - } - return XML_TRUE; -} - XML_Parser XMLCALL XML_ParserCreate_MM(const XML_Char *encodingName, const XML_Memory_Handling_Suite *memsuite, const XML_Char *nameSep) { - return parserCreate(encodingName, memsuite, nameSep, NULL); + XML_Parser parser = parserCreate(encodingName, memsuite, nameSep, NULL); + if (parser != NULL && ns) { + /* implicit context only set for root parser, since child + parsers (i.e. external entity parsers) will inherit it + */ + if (!setContext(parser, implicitContext)) { + XML_ParserFree(parser); + return NULL; + } + } + return parser; } static XML_Parser @@ -763,20 +731,9 @@ FREE(parser); return NULL; } -#ifdef XML_ATTR_INFO - attInfo = (XML_AttrInfo*)MALLOC(attsSize * sizeof(XML_AttrInfo)); - if (attInfo == NULL) { - FREE(atts); - FREE(parser); - return NULL; - } -#endif dataBuf = (XML_Char *)MALLOC(INIT_DATA_BUF_SIZE * sizeof(XML_Char)); if (dataBuf == NULL) { FREE(atts); -#ifdef XML_ATTR_INFO - FREE(attInfo); -#endif FREE(parser); return NULL; } @@ -789,9 +746,6 @@ if (_dtd == NULL) { FREE(dataBuf); FREE(atts); -#ifdef XML_ATTR_INFO - FREE(attInfo); -#endif FREE(parser); return NULL; } @@ -807,7 +761,7 @@ unknownEncodingHandler = NULL; unknownEncodingHandlerData = NULL; - namespaceSeparator = ASCII_EXCL; + namespaceSeparator = '!'; ns = XML_FALSE; ns_triplets = XML_FALSE; @@ -906,7 +860,6 @@ useForeignDTD = XML_FALSE; paramEntityParsing = XML_PARAM_ENTITY_PARSING_NEVER; #endif - hash_secret_salt = 0; } /* moves list of bindings to freeBindingList */ @@ -954,7 +907,7 @@ poolClear(&temp2Pool); parserInit(parser, encodingName); dtdReset(_dtd, &parser->m_mem); - return XML_TRUE; + return setContext(parser, implicitContext); } enum XML_Status XMLCALL @@ -1023,12 +976,6 @@ int oldInEntityValue = prologState.inEntityValue; #endif XML_Bool oldns_triplets = ns_triplets; - /* Note that the new parser shares the same hash secret as the old - parser, so that dtdCopy and copyEntityTable can lookup values - from hash tables associated with either parser without us having - to worry which hash secrets each table has. - */ - unsigned long oldhash_secret_salt = hash_secret_salt; #ifdef XML_DTD if (!context) @@ -1082,14 +1029,13 @@ externalEntityRefHandlerArg = oldExternalEntityRefHandlerArg; defaultExpandInternalEntities = oldDefaultExpandInternalEntities; ns_triplets = oldns_triplets; - hash_secret_salt = oldhash_secret_salt; parentParser = oldParser; #ifdef XML_DTD paramEntityParsing = oldParamEntityParsing; prologState.inEntityValue = oldInEntityValue; if (context) { #endif /* XML_DTD */ - if (!dtdCopy(oldParser, _dtd, oldDtd, &parser->m_mem) + if (!dtdCopy(_dtd, oldDtd, &parser->m_mem) || !setContext(parser, context)) { XML_ParserFree(parser); return NULL; @@ -1178,9 +1124,6 @@ #endif /* XML_DTD */ dtdDestroy(_dtd, (XML_Bool)!parentParser, &parser->m_mem); FREE((void *)atts); -#ifdef XML_ATTR_INFO - FREE((void *)attInfo); -#endif FREE(groupConnector); FREE(buffer); FREE(dataBuf); @@ -1261,14 +1204,6 @@ return idAttIndex; } -#ifdef XML_ATTR_INFO -const XML_AttrInfo * XMLCALL -XML_GetAttributeInfo(XML_Parser parser) -{ - return attInfo; -} -#endif - void XMLCALL XML_SetElementHandler(XML_Parser parser, XML_StartElementHandler start, @@ -1485,17 +1420,6 @@ #endif } -int XMLCALL -XML_SetHashSalt(XML_Parser parser, - unsigned long hash_salt) -{ - /* block after XML_Parse()/XML_ParseBuffer() has been called */ - if (ps_parsing == XML_PARSING || ps_parsing == XML_SUSPENDED) - return 0; - hash_secret_salt = hash_salt; - return 1; -} - enum XML_Status XMLCALL XML_Parse(XML_Parser parser, const char *s, int len, int isFinal) { @@ -1506,11 +1430,6 @@ case XML_FINISHED: errorCode = XML_ERROR_FINISHED; return XML_STATUS_ERROR; - case XML_INITIALIZED: - if (parentParser == NULL && !startParsing(parser)) { - errorCode = XML_ERROR_NO_MEMORY; - return XML_STATUS_ERROR; - } default: ps_parsing = XML_PARSING; } @@ -1534,7 +1453,7 @@ XmlUpdatePosition(encoding, positionPtr, bufferPtr, &position); positionPtr = bufferPtr; return XML_STATUS_SUSPENDED; - case XML_INITIALIZED: + case XML_INITIALIZED: case XML_PARSING: ps_parsing = XML_FINISHED; /* fall through */ @@ -1569,13 +1488,11 @@ break; case XML_INITIALIZED: case XML_PARSING: + result = XML_STATUS_OK; if (isFinal) { ps_parsing = XML_FINISHED; - return XML_STATUS_OK; + return result; } - /* fall through */ - default: - result = XML_STATUS_OK; } } @@ -1590,11 +1507,15 @@ : (char *)REALLOC(buffer, len * 2)); if (temp == NULL) { errorCode = XML_ERROR_NO_MEMORY; + return XML_STATUS_ERROR; + } + buffer = temp; + if (!buffer) { + errorCode = XML_ERROR_NO_MEMORY; eventPtr = eventEndPtr = NULL; processor = errorProcessor; return XML_STATUS_ERROR; } - buffer = temp; bufferLim = buffer + len * 2; } memcpy(buffer, end, nLeftOver); @@ -1632,11 +1553,6 @@ case XML_FINISHED: errorCode = XML_ERROR_FINISHED; return XML_STATUS_ERROR; - case XML_INITIALIZED: - if (parentParser == NULL && !startParsing(parser)) { - errorCode = XML_ERROR_NO_MEMORY; - return XML_STATUS_ERROR; - } default: ps_parsing = XML_PARSING; } @@ -1660,7 +1576,7 @@ case XML_SUSPENDED: result = XML_STATUS_SUSPENDED; break; - case XML_INITIALIZED: + case XML_INITIALIZED: case XML_PARSING: if (isFinal) { ps_parsing = XML_FINISHED; @@ -1750,8 +1666,6 @@ bufferPtr = buffer = newBuf; #endif /* not defined XML_CONTEXT_BYTES */ } - eventPtr = eventEndPtr = NULL; - positionPtr = NULL; } return bufferEnd; } @@ -1809,7 +1723,7 @@ case XML_SUSPENDED: result = XML_STATUS_SUSPENDED; break; - case XML_INITIALIZED: + case XML_INITIALIZED: case XML_PARSING: if (ps_finalBuffer) { ps_parsing = XML_FINISHED; @@ -2034,12 +1948,6 @@ #ifdef XML_NS {XML_FEATURE_NS, XML_L("XML_NS"), 0}, #endif -#ifdef XML_LARGE_SIZE - {XML_FEATURE_LARGE_SIZE, XML_L("XML_LARGE_SIZE"), 0}, -#endif -#ifdef XML_ATTR_INFO - {XML_FEATURE_ATTR_INFO, XML_L("XML_ATTR_INFO"), 0}, -#endif {XML_FEATURE_END, NULL, 0} }; @@ -2102,7 +2010,7 @@ const char *end, const char **endPtr) { - enum XML_Error result = doContent(parser, 0, encoding, start, end, + enum XML_Error result = doContent(parser, 0, encoding, start, end, endPtr, (XML_Bool)!ps_finalBuffer); if (result == XML_ERROR_NONE) { if (!storeRawNames(parser)) @@ -2184,7 +2092,7 @@ if (result != XML_ERROR_NONE) return result; switch (ps_parsing) { - case XML_SUSPENDED: + case XML_SUSPENDED: *endPtr = next; return XML_ERROR_NONE; case XML_FINISHED: @@ -2218,7 +2126,7 @@ const char *end, const char **endPtr) { - enum XML_Error result = doContent(parser, 1, encoding, start, end, + enum XML_Error result = doContent(parser, 1, encoding, start, end, endPtr, (XML_Bool)!ps_finalBuffer); if (result == XML_ERROR_NONE) { if (!storeRawNames(parser)) @@ -2237,7 +2145,7 @@ XML_Bool haveMore) { /* save one level of indirection */ - DTD * const dtd = _dtd; + DTD * const dtd = _dtd; const char **eventPP; const char **eventEndPP; @@ -2268,8 +2176,8 @@ } else if (defaultHandler) reportDefault(parser, enc, s, end); - /* We are at the end of the final buffer, should we check for - XML_SUSPENDED, XML_FINISHED? + /* We are at the end of the final buffer, should we check for + XML_SUSPENDED, XML_FINISHED? */ if (startTagLevel == 0) return XML_ERROR_NO_ELEMENTS; @@ -2323,7 +2231,7 @@ next - enc->minBytesPerChar); if (!name) return XML_ERROR_NO_MEMORY; - entity = (ENTITY *)lookup(parser, &dtd->generalEntities, name, 0); + entity = (ENTITY *)lookup(&dtd->generalEntities, name, 0); poolDiscard(&dtd->pool); /* First, determine if a check for an existing declaration is needed; if yes, check that the entity exists, and that it is internal, @@ -2620,8 +2528,8 @@ } else if (defaultHandler) reportDefault(parser, enc, s, end); - /* We are at the end of the final buffer, should we check for - XML_SUSPENDED, XML_FINISHED? + /* We are at the end of the final buffer, should we check for + XML_SUSPENDED, XML_FINISHED? */ if (startTagLevel == 0) { *eventPP = end; @@ -2634,29 +2542,26 @@ *nextPtr = end; return XML_ERROR_NONE; case XML_TOK_DATA_CHARS: - { - XML_CharacterDataHandler charDataHandler = characterDataHandler; - if (charDataHandler) { - if (MUST_CONVERT(enc, s)) { - for (;;) { - ICHAR *dataPtr = (ICHAR *)dataBuf; - XmlConvert(enc, &s, next, &dataPtr, (ICHAR *)dataBufEnd); - *eventEndPP = s; - charDataHandler(handlerArg, dataBuf, - (int)(dataPtr - (ICHAR *)dataBuf)); - if (s == next) - break; - *eventPP = s; - } + if (characterDataHandler) { + if (MUST_CONVERT(enc, s)) { + for (;;) { + ICHAR *dataPtr = (ICHAR *)dataBuf; + XmlConvert(enc, &s, next, &dataPtr, (ICHAR *)dataBufEnd); + *eventEndPP = s; + characterDataHandler(handlerArg, dataBuf, + (int)(dataPtr - (ICHAR *)dataBuf)); + if (s == next) + break; + *eventPP = s; } - else - charDataHandler(handlerArg, - (XML_Char *)s, - (int)((XML_Char *)next - (XML_Char *)s)); } - else if (defaultHandler) - reportDefault(parser, enc, s, next); + else + characterDataHandler(handlerArg, + (XML_Char *)s, + (int)((XML_Char *)next - (XML_Char *)s)); } + else if (defaultHandler) + reportDefault(parser, enc, s, next); break; case XML_TOK_PI: if (!reportProcessingInstruction(parser, enc, s, next)) @@ -2673,7 +2578,7 @@ } *eventPP = s = next; switch (ps_parsing) { - case XML_SUSPENDED: + case XML_SUSPENDED: *nextPtr = next; return XML_ERROR_NONE; case XML_FINISHED: @@ -2713,12 +2618,12 @@ const XML_Char *localPart; /* lookup the element type name */ - elementType = (ELEMENT_TYPE *)lookup(parser, &dtd->elementTypes, tagNamePtr->str,0); + elementType = (ELEMENT_TYPE *)lookup(&dtd->elementTypes, tagNamePtr->str,0); if (!elementType) { const XML_Char *name = poolCopyString(&dtd->pool, tagNamePtr->str); if (!name) return XML_ERROR_NO_MEMORY; - elementType = (ELEMENT_TYPE *)lookup(parser, &dtd->elementTypes, name, + elementType = (ELEMENT_TYPE *)lookup(&dtd->elementTypes, name, sizeof(ELEMENT_TYPE)); if (!elementType) return XML_ERROR_NO_MEMORY; @@ -2732,44 +2637,23 @@ if (n + nDefaultAtts > attsSize) { int oldAttsSize = attsSize; ATTRIBUTE *temp; -#ifdef XML_ATTR_INFO - XML_AttrInfo *temp2; -#endif attsSize = n + nDefaultAtts + INIT_ATTS_SIZE; temp = (ATTRIBUTE *)REALLOC((void *)atts, attsSize * sizeof(ATTRIBUTE)); if (temp == NULL) return XML_ERROR_NO_MEMORY; atts = temp; -#ifdef XML_ATTR_INFO - temp2 = (XML_AttrInfo *)REALLOC((void *)attInfo, attsSize * sizeof(XML_AttrInfo)); - if (temp2 == NULL) - return XML_ERROR_NO_MEMORY; - attInfo = temp2; -#endif if (n > oldAttsSize) XmlGetAttributes(enc, attStr, n, atts); } appAtts = (const XML_Char **)atts; for (i = 0; i < n; i++) { - ATTRIBUTE *currAtt = &atts[i]; -#ifdef XML_ATTR_INFO - XML_AttrInfo *currAttInfo = &attInfo[i]; -#endif /* add the name and value to the attribute list */ - ATTRIBUTE_ID *attId = getAttributeId(parser, enc, currAtt->name, - currAtt->name - + XmlNameLength(enc, currAtt->name)); + ATTRIBUTE_ID *attId = getAttributeId(parser, enc, atts[i].name, + atts[i].name + + XmlNameLength(enc, atts[i].name)); if (!attId) return XML_ERROR_NO_MEMORY; -#ifdef XML_ATTR_INFO - currAttInfo->nameStart = parseEndByteIndex - (parseEndPtr - currAtt->name); - currAttInfo->nameEnd = currAttInfo->nameStart + - XmlNameLength(enc, currAtt->name); - currAttInfo->valueStart = parseEndByteIndex - - (parseEndPtr - currAtt->valuePtr); - currAttInfo->valueEnd = parseEndByteIndex - (parseEndPtr - currAtt->valueEnd); -#endif /* Detect duplicate attributes by their QNames. This does not work when namespace processing is turned on and different prefixes for the same namespace are used. For this case we have a check further down. @@ -2908,9 +2792,11 @@ if (s[-1] == 2) { /* prefixed */ ATTRIBUTE_ID *id; const BINDING *b; - unsigned long uriHash = hash_secret_salt; + unsigned long uriHash = 0; ((XML_Char *)s)[-1] = 0; /* clear flag */ - id = (ATTRIBUTE_ID *)lookup(parser, &dtd->attributeIds, s, 0); + id = (ATTRIBUTE_ID *)lookup(&dtd->attributeIds, s, 0); + if (!id) + return XML_ERROR_NO_MEMORY; b = id->prefix->binding; if (!b) return XML_ERROR_UNBOUND_PREFIX; @@ -2922,7 +2808,7 @@ return XML_ERROR_NO_MEMORY; uriHash = CHAR_HASH(uriHash, c); } - while (*s++ != XML_T(ASCII_COLON)) + while (*s++ != XML_T(':')) ; do { /* copies null terminator */ const XML_Char c = *s; @@ -2932,7 +2818,7 @@ } while (*s++); { /* Check hash table for duplicate of expanded name (uriName). - Derived from code in lookup(parser, HASH_TABLE *table, ...). + Derived from code in lookup(HASH_TABLE *table, ...). */ unsigned char step = 0; unsigned long mask = nsAttsSize - 1; @@ -2996,7 +2882,7 @@ if (!binding) return XML_ERROR_UNBOUND_PREFIX; localPart = tagNamePtr->str; - while (*localPart++ != XML_T(ASCII_COLON)) + while (*localPart++ != XML_T(':')) ; } else if (dtd->defaultPrefix.binding) { @@ -3051,29 +2937,25 @@ const XML_Char *uri, BINDING **bindingsPtr) { static const XML_Char xmlNamespace[] = { - ASCII_h, ASCII_t, ASCII_t, ASCII_p, ASCII_COLON, ASCII_SLASH, ASCII_SLASH, - ASCII_w, ASCII_w, ASCII_w, ASCII_PERIOD, ASCII_w, ASCII_3, ASCII_PERIOD, - ASCII_o, ASCII_r, ASCII_g, ASCII_SLASH, ASCII_X, ASCII_M, ASCII_L, - ASCII_SLASH, ASCII_1, ASCII_9, ASCII_9, ASCII_8, ASCII_SLASH, - ASCII_n, ASCII_a, ASCII_m, ASCII_e, ASCII_s, ASCII_p, ASCII_a, ASCII_c, - ASCII_e, '\0' + 'h', 't', 't', 'p', ':', '/', '/', + 'w', 'w', 'w', '.', 'w', '3', '.', 'o', 'r', 'g', '/', + 'X', 'M', 'L', '/', '1', '9', '9', '8', '/', + 'n', 'a', 'm', 'e', 's', 'p', 'a', 'c', 'e', '\0' }; - static const int xmlLen = + static const int xmlLen = (int)sizeof(xmlNamespace)/sizeof(XML_Char) - 1; static const XML_Char xmlnsNamespace[] = { - ASCII_h, ASCII_t, ASCII_t, ASCII_p, ASCII_COLON, ASCII_SLASH, ASCII_SLASH, - ASCII_w, ASCII_w, ASCII_w, ASCII_PERIOD, ASCII_w, ASCII_3, ASCII_PERIOD, - ASCII_o, ASCII_r, ASCII_g, ASCII_SLASH, ASCII_2, ASCII_0, ASCII_0, - ASCII_0, ASCII_SLASH, ASCII_x, ASCII_m, ASCII_l, ASCII_n, ASCII_s, - ASCII_SLASH, '\0' + 'h', 't', 't', 'p', ':', '/', '/', + 'w', 'w', 'w', '.', 'w', '3', '.', 'o', 'r', 'g', '/', + '2', '0', '0', '0', '/', 'x', 'm', 'l', 'n', 's', '/', '\0' }; - static const int xmlnsLen = + static const int xmlnsLen = (int)sizeof(xmlnsNamespace)/sizeof(XML_Char) - 1; XML_Bool mustBeXML = XML_FALSE; XML_Bool isXML = XML_TRUE; XML_Bool isXMLNS = XML_TRUE; - + BINDING *b; int len; @@ -3082,13 +2964,13 @@ return XML_ERROR_UNDECLARING_PREFIX; if (prefix->name - && prefix->name[0] == XML_T(ASCII_x) - && prefix->name[1] == XML_T(ASCII_m) - && prefix->name[2] == XML_T(ASCII_l)) { + && prefix->name[0] == XML_T('x') + && prefix->name[1] == XML_T('m') + && prefix->name[2] == XML_T('l')) { /* Not allowed to bind xmlns */ - if (prefix->name[3] == XML_T(ASCII_n) - && prefix->name[4] == XML_T(ASCII_s) + if (prefix->name[3] == XML_T('n') + && prefix->name[4] == XML_T('s') && prefix->name[5] == XML_T('\0')) return XML_ERROR_RESERVED_PREFIX_XMLNS; @@ -3100,7 +2982,7 @@ if (isXML && (len > xmlLen || uri[len] != xmlNamespace[len])) isXML = XML_FALSE; - if (!mustBeXML && isXMLNS + if (!mustBeXML && isXMLNS && (len > xmlnsLen || uri[len] != xmlnsNamespace[len])) isXMLNS = XML_FALSE; } @@ -3242,29 +3124,26 @@ reportDefault(parser, enc, s, next); break; case XML_TOK_DATA_CHARS: - { - XML_CharacterDataHandler charDataHandler = characterDataHandler; - if (charDataHandler) { - if (MUST_CONVERT(enc, s)) { - for (;;) { - ICHAR *dataPtr = (ICHAR *)dataBuf; - XmlConvert(enc, &s, next, &dataPtr, (ICHAR *)dataBufEnd); - *eventEndPP = next; - charDataHandler(handlerArg, dataBuf, - (int)(dataPtr - (ICHAR *)dataBuf)); - if (s == next) - break; - *eventPP = s; - } + if (characterDataHandler) { + if (MUST_CONVERT(enc, s)) { + for (;;) { + ICHAR *dataPtr = (ICHAR *)dataBuf; + XmlConvert(enc, &s, next, &dataPtr, (ICHAR *)dataBufEnd); + *eventEndPP = next; + characterDataHandler(handlerArg, dataBuf, + (int)(dataPtr - (ICHAR *)dataBuf)); + if (s == next) + break; + *eventPP = s; } - else - charDataHandler(handlerArg, - (XML_Char *)s, - (int)((XML_Char *)next - (XML_Char *)s)); } - else if (defaultHandler) - reportDefault(parser, enc, s, next); + else + characterDataHandler(handlerArg, + (XML_Char *)s, + (int)((XML_Char *)next - (XML_Char *)s)); } + else if (defaultHandler) + reportDefault(parser, enc, s, next); break; case XML_TOK_INVALID: *eventPP = next; @@ -3311,7 +3190,7 @@ const char *end, const char **endPtr) { - enum XML_Error result = doIgnoreSection(parser, encoding, &start, end, + enum XML_Error result = doIgnoreSection(parser, encoding, &start, end, endPtr, (XML_Bool)!ps_finalBuffer); if (result != XML_ERROR_NONE) return result; @@ -3593,7 +3472,7 @@ const char *next = start; eventPtr = start; - for (;;) { + for (;;) { tok = XmlPrologTok(encoding, start, end, &next); eventEndPtr = next; if (tok <= 0) { @@ -3621,7 +3500,7 @@ if (result != XML_ERROR_NONE) return result; switch (ps_parsing) { - case XML_SUSPENDED: + case XML_SUSPENDED: *nextPtr = next; return XML_ERROR_NONE; case XML_FINISHED: @@ -3686,7 +3565,7 @@ } processor = prologProcessor; - return doProlog(parser, encoding, s, end, tok, next, + return doProlog(parser, encoding, s, end, tok, next, nextPtr, (XML_Bool)!ps_finalBuffer); } @@ -3736,7 +3615,7 @@ { const char *next = s; int tok = XmlPrologTok(encoding, s, end, &next); - return doProlog(parser, encoding, s, end, tok, next, + return doProlog(parser, encoding, s, end, tok, next, nextPtr, (XML_Bool)!ps_finalBuffer); } @@ -3751,30 +3630,26 @@ XML_Bool haveMore) { #ifdef XML_DTD - static const XML_Char externalSubsetName[] = { ASCII_HASH , '\0' }; + static const XML_Char externalSubsetName[] = { '#' , '\0' }; #endif /* XML_DTD */ - static const XML_Char atypeCDATA[] = - { ASCII_C, ASCII_D, ASCII_A, ASCII_T, ASCII_A, '\0' }; - static const XML_Char atypeID[] = { ASCII_I, ASCII_D, '\0' }; - static const XML_Char atypeIDREF[] = - { ASCII_I, ASCII_D, ASCII_R, ASCII_E, ASCII_F, '\0' }; - static const XML_Char atypeIDREFS[] = - { ASCII_I, ASCII_D, ASCII_R, ASCII_E, ASCII_F, ASCII_S, '\0' }; - static const XML_Char atypeENTITY[] = - { ASCII_E, ASCII_N, ASCII_T, ASCII_I, ASCII_T, ASCII_Y, '\0' }; - static const XML_Char atypeENTITIES[] = { ASCII_E, ASCII_N, - ASCII_T, ASCII_I, ASCII_T, ASCII_I, ASCII_E, ASCII_S, '\0' }; + static const XML_Char atypeCDATA[] = { 'C', 'D', 'A', 'T', 'A', '\0' }; + static const XML_Char atypeID[] = { 'I', 'D', '\0' }; + static const XML_Char atypeIDREF[] = { 'I', 'D', 'R', 'E', 'F', '\0' }; + static const XML_Char atypeIDREFS[] = { 'I', 'D', 'R', 'E', 'F', 'S', '\0' }; + static const XML_Char atypeENTITY[] = { 'E', 'N', 'T', 'I', 'T', 'Y', '\0' }; + static const XML_Char atypeENTITIES[] = + { 'E', 'N', 'T', 'I', 'T', 'I', 'E', 'S', '\0' }; static const XML_Char atypeNMTOKEN[] = { - ASCII_N, ASCII_M, ASCII_T, ASCII_O, ASCII_K, ASCII_E, ASCII_N, '\0' }; - static const XML_Char atypeNMTOKENS[] = { ASCII_N, ASCII_M, ASCII_T, - ASCII_O, ASCII_K, ASCII_E, ASCII_N, ASCII_S, '\0' }; - static const XML_Char notationPrefix[] = { ASCII_N, ASCII_O, ASCII_T, - ASCII_A, ASCII_T, ASCII_I, ASCII_O, ASCII_N, ASCII_LPAREN, '\0' }; - static const XML_Char enumValueSep[] = { ASCII_PIPE, '\0' }; - static const XML_Char enumValueStart[] = { ASCII_LPAREN, '\0' }; + 'N', 'M', 'T', 'O', 'K', 'E', 'N', '\0' }; + static const XML_Char atypeNMTOKENS[] = { + 'N', 'M', 'T', 'O', 'K', 'E', 'N', 'S', '\0' }; + static const XML_Char notationPrefix[] = { + 'N', 'O', 'T', 'A', 'T', 'I', 'O', 'N', '(', '\0' }; + static const XML_Char enumValueSep[] = { '|', '\0' }; + static const XML_Char enumValueStart[] = { '(', '\0' }; /* save one level of indirection */ - DTD * const dtd = _dtd; + DTD * const dtd = _dtd; const char **eventPP; const char **eventEndPP; @@ -3881,8 +3756,7 @@ case XML_ROLE_DOCTYPE_PUBLIC_ID: #ifdef XML_DTD useForeignDTD = XML_FALSE; - declEntity = (ENTITY *)lookup(parser, - &dtd->paramEntities, + declEntity = (ENTITY *)lookup(&dtd->paramEntities, externalSubsetName, sizeof(ENTITY)); if (!declEntity) @@ -3890,17 +3764,15 @@ #endif /* XML_DTD */ dtd->hasParamEntityRefs = XML_TRUE; if (startDoctypeDeclHandler) { - XML_Char *pubId; if (!XmlIsPublicId(enc, s, next, eventPP)) return XML_ERROR_PUBLICID; - pubId = poolStoreString(&tempPool, enc, - s + enc->minBytesPerChar, - next - enc->minBytesPerChar); - if (!pubId) + doctypePubid = poolStoreString(&tempPool, enc, + s + enc->minBytesPerChar, + next - enc->minBytesPerChar); + if (!doctypePubid) return XML_ERROR_NO_MEMORY; - normalizePublicId(pubId); + normalizePublicId((XML_Char *)doctypePubid); poolFinish(&tempPool); - doctypePubid = pubId; handleDefault = XML_FALSE; goto alreadyChecked; } @@ -3939,8 +3811,7 @@ XML_Bool hadParamEntityRefs = dtd->hasParamEntityRefs; dtd->hasParamEntityRefs = XML_TRUE; if (paramEntityParsing && externalEntityRefHandler) { - ENTITY *entity = (ENTITY *)lookup(parser, - &dtd->paramEntities, + ENTITY *entity = (ENTITY *)lookup(&dtd->paramEntities, externalSubsetName, sizeof(ENTITY)); if (!entity) @@ -3955,8 +3826,8 @@ entity->publicId)) return XML_ERROR_EXTERNAL_ENTITY_HANDLING; if (dtd->paramEntityRead) { - if (!dtd->standalone && - notStandaloneHandler && + if (!dtd->standalone && + notStandaloneHandler && !notStandaloneHandler(handlerArg)) return XML_ERROR_NOT_STANDALONE; } @@ -3984,7 +3855,7 @@ XML_Bool hadParamEntityRefs = dtd->hasParamEntityRefs; dtd->hasParamEntityRefs = XML_TRUE; if (paramEntityParsing && externalEntityRefHandler) { - ENTITY *entity = (ENTITY *)lookup(parser, &dtd->paramEntities, + ENTITY *entity = (ENTITY *)lookup(&dtd->paramEntities, externalSubsetName, sizeof(ENTITY)); if (!entity) @@ -4084,11 +3955,11 @@ 0, parser)) return XML_ERROR_NO_MEMORY; if (attlistDeclHandler && declAttributeType) { - if (*declAttributeType == XML_T(ASCII_LPAREN) - || (*declAttributeType == XML_T(ASCII_N) - && declAttributeType[1] == XML_T(ASCII_O))) { + if (*declAttributeType == XML_T('(') + || (*declAttributeType == XML_T('N') + && declAttributeType[1] == XML_T('O'))) { /* Enumerated or Notation type */ - if (!poolAppendChar(&tempPool, XML_T(ASCII_RPAREN)) + if (!poolAppendChar(&tempPool, XML_T(')')) || !poolAppendChar(&tempPool, XML_T('\0'))) return XML_ERROR_NO_MEMORY; declAttributeType = tempPool.start; @@ -4121,11 +3992,11 @@ declAttributeIsCdata, XML_FALSE, attVal, parser)) return XML_ERROR_NO_MEMORY; if (attlistDeclHandler && declAttributeType) { - if (*declAttributeType == XML_T(ASCII_LPAREN) - || (*declAttributeType == XML_T(ASCII_N) - && declAttributeType[1] == XML_T(ASCII_O))) { + if (*declAttributeType == XML_T('(') + || (*declAttributeType == XML_T('N') + && declAttributeType[1] == XML_T('O'))) { /* Enumerated or Notation type */ - if (!poolAppendChar(&tempPool, XML_T(ASCII_RPAREN)) + if (!poolAppendChar(&tempPool, XML_T(')')) || !poolAppendChar(&tempPool, XML_T('\0'))) return XML_ERROR_NO_MEMORY; declAttributeType = tempPool.start; @@ -4198,8 +4069,7 @@ break; #else /* XML_DTD */ if (!declEntity) { - declEntity = (ENTITY *)lookup(parser, - &dtd->paramEntities, + declEntity = (ENTITY *)lookup(&dtd->paramEntities, externalSubsetName, sizeof(ENTITY)); if (!declEntity) @@ -4274,7 +4144,7 @@ const XML_Char *name = poolStoreString(&dtd->pool, enc, s, next); if (!name) return XML_ERROR_NO_MEMORY; - declEntity = (ENTITY *)lookup(parser, &dtd->generalEntities, name, + declEntity = (ENTITY *)lookup(&dtd->generalEntities, name, sizeof(ENTITY)); if (!declEntity) return XML_ERROR_NO_MEMORY; @@ -4306,7 +4176,7 @@ const XML_Char *name = poolStoreString(&dtd->pool, enc, s, next); if (!name) return XML_ERROR_NO_MEMORY; - declEntity = (ENTITY *)lookup(parser, &dtd->paramEntities, + declEntity = (ENTITY *)lookup(&dtd->paramEntities, name, sizeof(ENTITY)); if (!declEntity) return XML_ERROR_NO_MEMORY; @@ -4395,7 +4265,7 @@ switch (tok) { case XML_TOK_PARAM_ENTITY_REF: /* PE references in internal subset are - not allowed within declarations. */ + not allowed within declarations. */ return XML_ERROR_PARAM_ENTITY_REF; case XML_TOK_XML_DECL: return XML_ERROR_MISPLACED_XML_PI; @@ -4453,14 +4323,14 @@ } break; case XML_ROLE_GROUP_SEQUENCE: - if (groupConnector[prologState.level] == ASCII_PIPE) + if (groupConnector[prologState.level] == '|') return XML_ERROR_SYNTAX; - groupConnector[prologState.level] = ASCII_COMMA; + groupConnector[prologState.level] = ','; if (dtd->in_eldecl && elementDeclHandler) handleDefault = XML_FALSE; break; case XML_ROLE_GROUP_CHOICE: - if (groupConnector[prologState.level] == ASCII_COMMA) + if (groupConnector[prologState.level] == ',') return XML_ERROR_SYNTAX; if (dtd->in_eldecl && !groupConnector[prologState.level] @@ -4472,7 +4342,7 @@ if (elementDeclHandler) handleDefault = XML_FALSE; } - groupConnector[prologState.level] = ASCII_PIPE; + groupConnector[prologState.level] = '|'; break; case XML_ROLE_PARAM_ENTITY_REF: #ifdef XML_DTD @@ -4488,7 +4358,7 @@ next - enc->minBytesPerChar); if (!name) return XML_ERROR_NO_MEMORY; - entity = (ENTITY *)lookup(parser, &dtd->paramEntities, name, 0); + entity = (ENTITY *)lookup(&dtd->paramEntities, name, 0); poolDiscard(&dtd->pool); /* first, determine if a check for an existing declaration is needed; if yes, check that the entity exists, and that it is internal, @@ -4516,7 +4386,7 @@ return XML_ERROR_RECURSIVE_ENTITY_REF; if (entity->textPtr) { enum XML_Error result; - XML_Bool betweenDecl = + XML_Bool betweenDecl = (role == XML_ROLE_PARAM_ENTITY_REF ? XML_TRUE : XML_FALSE); result = processInternalEntity(parser, entity, betweenDecl); if (result != XML_ERROR_NONE) @@ -4711,7 +4581,7 @@ reportDefault(parser, enc, s, next); switch (ps_parsing) { - case XML_SUSPENDED: + case XML_SUSPENDED: *nextPtr = next; return XML_ERROR_NONE; case XML_FINISHED: @@ -4781,7 +4651,7 @@ } eventPtr = s = next; switch (ps_parsing) { - case XML_SUSPENDED: + case XML_SUSPENDED: *nextPtr = next; return XML_ERROR_NONE; case XML_FINISHED: @@ -4824,12 +4694,12 @@ #ifdef XML_DTD if (entity->is_param) { int tok = XmlPrologTok(internalEncoding, textStart, textEnd, &next); - result = doProlog(parser, internalEncoding, textStart, textEnd, tok, + result = doProlog(parser, internalEncoding, textStart, textEnd, tok, next, &next, XML_FALSE); } - else + else #endif /* XML_DTD */ - result = doContent(parser, tagLevel, internalEncoding, textStart, + result = doContent(parser, tagLevel, internalEncoding, textStart, textEnd, &next, XML_FALSE); if (result == XML_ERROR_NONE) { @@ -4869,13 +4739,13 @@ #ifdef XML_DTD if (entity->is_param) { int tok = XmlPrologTok(internalEncoding, textStart, textEnd, &next); - result = doProlog(parser, internalEncoding, textStart, textEnd, tok, + result = doProlog(parser, internalEncoding, textStart, textEnd, tok, next, &next, XML_FALSE); } else #endif /* XML_DTD */ - result = doContent(parser, openEntity->startTagLevel, internalEncoding, - textStart, textEnd, &next, XML_FALSE); + result = doContent(parser, openEntity->startTagLevel, internalEncoding, + textStart, textEnd, &next, XML_FALSE); if (result != XML_ERROR_NONE) return result; @@ -4896,7 +4766,7 @@ int tok; processor = prologProcessor; tok = XmlPrologTok(encoding, s, end, &next); - return doProlog(parser, encoding, s, end, tok, next, nextPtr, + return doProlog(parser, encoding, s, end, tok, next, nextPtr, (XML_Bool)!ps_finalBuffer); } else @@ -4905,8 +4775,8 @@ processor = contentProcessor; /* see externalEntityContentProcessor vs contentProcessor */ return doContent(parser, parentParser ? 1 : 0, encoding, s, end, - nextPtr, (XML_Bool)!ps_finalBuffer); - } + nextPtr, (XML_Bool)!ps_finalBuffer); + } } static enum XML_Error PTRCALL @@ -5012,7 +4882,7 @@ next - enc->minBytesPerChar); if (!name) return XML_ERROR_NO_MEMORY; - entity = (ENTITY *)lookup(parser, &dtd->generalEntities, name, 0); + entity = (ENTITY *)lookup(&dtd->generalEntities, name, 0); poolDiscard(&temp2Pool); /* First, determine if a check for an existing declaration is needed; if yes, check that the entity exists, and that it is internal. @@ -5059,7 +4929,7 @@ if (!entity->textPtr) { if (enc == encoding) eventPtr = ptr; - return XML_ERROR_ATTRIBUTE_EXTERNAL_ENTITY_REF; + return XML_ERROR_ATTRIBUTE_EXTERNAL_ENTITY_REF; } else { enum XML_Error result; @@ -5121,7 +4991,7 @@ result = XML_ERROR_NO_MEMORY; goto endEntityValue; } - entity = (ENTITY *)lookup(parser, &dtd->paramEntities, name, 0); + entity = (ENTITY *)lookup(&dtd->paramEntities, name, 0); poolDiscard(&tempPool); if (!entity) { /* not a well-formedness error - see XML 1.0: WFC Entity Declared */ @@ -5402,7 +5272,7 @@ DTD * const dtd = _dtd; /* save one level of indirection */ const XML_Char *name; for (name = elementType->name; *name; name++) { - if (*name == XML_T(ASCII_COLON)) { + if (*name == XML_T(':')) { PREFIX *prefix; const XML_Char *s; for (s = elementType->name; s != name; s++) { @@ -5411,7 +5281,7 @@ } if (!poolAppendChar(&dtd->pool, XML_T('\0'))) return 0; - prefix = (PREFIX *)lookup(parser, &dtd->prefixes, poolStart(&dtd->pool), + prefix = (PREFIX *)lookup(&dtd->prefixes, poolStart(&dtd->pool), sizeof(PREFIX)); if (!prefix) return 0; @@ -5440,7 +5310,7 @@ return NULL; /* skip quotation mark - its storage will be re-used (like in name[-1]) */ ++name; - id = (ATTRIBUTE_ID *)lookup(parser, &dtd->attributeIds, name, sizeof(ATTRIBUTE_ID)); + id = (ATTRIBUTE_ID *)lookup(&dtd->attributeIds, name, sizeof(ATTRIBUTE_ID)); if (!id) return NULL; if (id->name != name) @@ -5449,23 +5319,23 @@ poolFinish(&dtd->pool); if (!ns) ; - else if (name[0] == XML_T(ASCII_x) - && name[1] == XML_T(ASCII_m) - && name[2] == XML_T(ASCII_l) - && name[3] == XML_T(ASCII_n) - && name[4] == XML_T(ASCII_s) - && (name[5] == XML_T('\0') || name[5] == XML_T(ASCII_COLON))) { + else if (name[0] == XML_T('x') + && name[1] == XML_T('m') + && name[2] == XML_T('l') + && name[3] == XML_T('n') + && name[4] == XML_T('s') + && (name[5] == XML_T('\0') || name[5] == XML_T(':'))) { if (name[5] == XML_T('\0')) id->prefix = &dtd->defaultPrefix; else - id->prefix = (PREFIX *)lookup(parser, &dtd->prefixes, name + 6, sizeof(PREFIX)); + id->prefix = (PREFIX *)lookup(&dtd->prefixes, name + 6, sizeof(PREFIX)); id->xmlns = XML_TRUE; } else { int i; for (i = 0; name[i]; i++) { /* attributes without prefix are *not* in the default namespace */ - if (name[i] == XML_T(ASCII_COLON)) { + if (name[i] == XML_T(':')) { int j; for (j = 0; j < i; j++) { if (!poolAppendChar(&dtd->pool, name[j])) @@ -5473,8 +5343,10 @@ } if (!poolAppendChar(&dtd->pool, XML_T('\0'))) return NULL; - id->prefix = (PREFIX *)lookup(parser, &dtd->prefixes, poolStart(&dtd->pool), + id->prefix = (PREFIX *)lookup(&dtd->prefixes, poolStart(&dtd->pool), sizeof(PREFIX)); + if (!id->prefix) + return NULL; if (id->prefix->name == poolStart(&dtd->pool)) poolFinish(&dtd->pool); else @@ -5487,7 +5359,7 @@ return id; } -#define CONTEXT_SEP XML_T(ASCII_FF) +#define CONTEXT_SEP XML_T('\f') static const XML_Char * getContext(XML_Parser parser) @@ -5499,7 +5371,7 @@ if (dtd->defaultPrefix.binding) { int i; int len; - if (!poolAppendChar(&tempPool, XML_T(ASCII_EQUALS))) + if (!poolAppendChar(&tempPool, XML_T('='))) return NULL; len = dtd->defaultPrefix.binding->uriLen; if (namespaceSeparator) @@ -5525,7 +5397,7 @@ for (s = prefix->name; *s; s++) if (!poolAppendChar(&tempPool, *s)) return NULL; - if (!poolAppendChar(&tempPool, XML_T(ASCII_EQUALS))) + if (!poolAppendChar(&tempPool, XML_T('='))) return NULL; len = prefix->binding->uriLen; if (namespaceSeparator) @@ -5569,7 +5441,7 @@ ENTITY *e; if (!poolAppendChar(&tempPool, XML_T('\0'))) return XML_FALSE; - e = (ENTITY *)lookup(parser, &dtd->generalEntities, poolStart(&tempPool), 0); + e = (ENTITY *)lookup(&dtd->generalEntities, poolStart(&tempPool), 0); if (e) e->open = XML_TRUE; if (*s != XML_T('\0')) @@ -5577,14 +5449,14 @@ context = s; poolDiscard(&tempPool); } - else if (*s == XML_T(ASCII_EQUALS)) { + else if (*s == XML_T('=')) { PREFIX *prefix; if (poolLength(&tempPool) == 0) prefix = &dtd->defaultPrefix; else { if (!poolAppendChar(&tempPool, XML_T('\0'))) return XML_FALSE; - prefix = (PREFIX *)lookup(parser, &dtd->prefixes, poolStart(&tempPool), + prefix = (PREFIX *)lookup(&dtd->prefixes, poolStart(&tempPool), sizeof(PREFIX)); if (!prefix) return XML_FALSE; @@ -5748,7 +5620,7 @@ The new DTD has already been initialized. */ static int -dtdCopy(XML_Parser oldParser, DTD *newDtd, const DTD *oldDtd, const XML_Memory_Handling_Suite *ms) +dtdCopy(DTD *newDtd, const DTD *oldDtd, const XML_Memory_Handling_Suite *ms) { HASH_TABLE_ITER iter; @@ -5763,7 +5635,7 @@ name = poolCopyString(&(newDtd->pool), oldP->name); if (!name) return 0; - if (!lookup(oldParser, &(newDtd->prefixes), name, sizeof(PREFIX))) + if (!lookup(&(newDtd->prefixes), name, sizeof(PREFIX))) return 0; } @@ -5785,7 +5657,7 @@ if (!name) return 0; ++name; - newA = (ATTRIBUTE_ID *)lookup(oldParser, &(newDtd->attributeIds), name, + newA = (ATTRIBUTE_ID *)lookup(&(newDtd->attributeIds), name, sizeof(ATTRIBUTE_ID)); if (!newA) return 0; @@ -5795,7 +5667,7 @@ if (oldA->prefix == &oldDtd->defaultPrefix) newA->prefix = &newDtd->defaultPrefix; else - newA->prefix = (PREFIX *)lookup(oldParser, &(newDtd->prefixes), + newA->prefix = (PREFIX *)lookup(&(newDtd->prefixes), oldA->prefix->name, 0); } } @@ -5814,7 +5686,7 @@ name = poolCopyString(&(newDtd->pool), oldE->name); if (!name) return 0; - newE = (ELEMENT_TYPE *)lookup(oldParser, &(newDtd->elementTypes), name, + newE = (ELEMENT_TYPE *)lookup(&(newDtd->elementTypes), name, sizeof(ELEMENT_TYPE)); if (!newE) return 0; @@ -5828,14 +5700,14 @@ } if (oldE->idAtt) newE->idAtt = (ATTRIBUTE_ID *) - lookup(oldParser, &(newDtd->attributeIds), oldE->idAtt->name, 0); + lookup(&(newDtd->attributeIds), oldE->idAtt->name, 0); newE->allocDefaultAtts = newE->nDefaultAtts = oldE->nDefaultAtts; if (oldE->prefix) - newE->prefix = (PREFIX *)lookup(oldParser, &(newDtd->prefixes), + newE->prefix = (PREFIX *)lookup(&(newDtd->prefixes), oldE->prefix->name, 0); for (i = 0; i < newE->nDefaultAtts; i++) { newE->defaultAtts[i].id = (ATTRIBUTE_ID *) - lookup(oldParser, &(newDtd->attributeIds), oldE->defaultAtts[i].id->name, 0); + lookup(&(newDtd->attributeIds), oldE->defaultAtts[i].id->name, 0); newE->defaultAtts[i].isCdata = oldE->defaultAtts[i].isCdata; if (oldE->defaultAtts[i].value) { newE->defaultAtts[i].value @@ -5849,15 +5721,13 @@ } /* Copy the entity tables. */ - if (!copyEntityTable(oldParser, - &(newDtd->generalEntities), + if (!copyEntityTable(&(newDtd->generalEntities), &(newDtd->pool), &(oldDtd->generalEntities))) return 0; #ifdef XML_DTD - if (!copyEntityTable(oldParser, - &(newDtd->paramEntities), + if (!copyEntityTable(&(newDtd->paramEntities), &(newDtd->pool), &(oldDtd->paramEntities))) return 0; @@ -5880,8 +5750,7 @@ } /* End dtdCopy */ static int -copyEntityTable(XML_Parser oldParser, - HASH_TABLE *newTable, +copyEntityTable(HASH_TABLE *newTable, STRING_POOL *newPool, const HASH_TABLE *oldTable) { @@ -5900,7 +5769,7 @@ name = poolCopyString(newPool, oldE->name); if (!name) return 0; - newE = (ENTITY *)lookup(oldParser, newTable, name, sizeof(ENTITY)); + newE = (ENTITY *)lookup(newTable, name, sizeof(ENTITY)); if (!newE) return 0; if (oldE->systemId) { @@ -5958,16 +5827,16 @@ } static unsigned long FASTCALL -hash(XML_Parser parser, KEY s) +hash(KEY s) { - unsigned long h = hash_secret_salt; + unsigned long h = 0; while (*s) h = CHAR_HASH(h, *s++); return h; } static NAMED * -lookup(XML_Parser parser, HASH_TABLE *table, KEY name, size_t createSize) +lookup(HASH_TABLE *table, KEY name, size_t createSize) { size_t i; if (table->size == 0) { @@ -5984,10 +5853,10 @@ return NULL; } memset(table->v, 0, tsize); - i = hash(parser, name) & ((unsigned long)table->size - 1); + i = hash(name) & ((unsigned long)table->size - 1); } else { - unsigned long h = hash(parser, name); + unsigned long h = hash(name); unsigned long mask = (unsigned long)table->size - 1; unsigned char step = 0; i = h & mask; @@ -6013,7 +5882,7 @@ memset(newV, 0, tsize); for (i = 0; i < table->size; i++) if (table->v[i]) { - unsigned long newHash = hash(parser, table->v[i]->name); + unsigned long newHash = hash(table->v[i]->name); size_t j = newHash & newMask; step = 0; while (newV[j]) { @@ -6234,13 +6103,12 @@ } if (pool->blocks && pool->start == pool->blocks->s) { int blockSize = (int)(pool->end - pool->start)*2; - BLOCK *temp = (BLOCK *) + pool->blocks = (BLOCK *) pool->mem->realloc_fcn(pool->blocks, (offsetof(BLOCK, s) + blockSize * sizeof(XML_Char))); - if (temp == NULL) + if (pool->blocks == NULL) return XML_FALSE; - pool->blocks = temp; pool->blocks->size = blockSize; pool->ptr = pool->blocks->s + (pool->ptr - pool->start); pool->start = pool->blocks->s; @@ -6389,7 +6257,7 @@ if (!name) return NULL; - ret = (ELEMENT_TYPE *) lookup(parser, &dtd->elementTypes, name, sizeof(ELEMENT_TYPE)); + ret = (ELEMENT_TYPE *) lookup(&dtd->elementTypes, name, sizeof(ELEMENT_TYPE)); if (!ret) return NULL; if (ret->name != name) diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/expat/xmlrole.c --- a/Modules/expat/xmlrole.c Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/expat/xmlrole.c Sun Jul 20 10:52:46 2014 -0400 @@ -2,22 +2,20 @@ See the file COPYING for copying permission. */ -#include - #ifdef COMPILED_FROM_DSP #include "winconfig.h" #elif defined(MACOS_CLASSIC) #include "macconfig.h" -#elif defined(__amigaos__) +#elif defined(__amigaos4__) #include "amigaconfig.h" -#elif defined(__WATCOMC__) -#include "watcomconfig.h" #else #ifdef HAVE_EXPAT_CONFIG_H #include #endif #endif /* ndef COMPILED_FROM_DSP */ +#include + #include "expat_external.h" #include "internal.h" #include "xmlrole.h" @@ -55,16 +53,12 @@ ASCII_I, ASCII_D, ASCII_R, ASCII_E, ASCII_F, '\0' }; static const char KW_IDREFS[] = { ASCII_I, ASCII_D, ASCII_R, ASCII_E, ASCII_F, ASCII_S, '\0' }; -#ifdef XML_DTD static const char KW_IGNORE[] = { ASCII_I, ASCII_G, ASCII_N, ASCII_O, ASCII_R, ASCII_E, '\0' }; -#endif static const char KW_IMPLIED[] = { ASCII_I, ASCII_M, ASCII_P, ASCII_L, ASCII_I, ASCII_E, ASCII_D, '\0' }; -#ifdef XML_DTD static const char KW_INCLUDE[] = { ASCII_I, ASCII_N, ASCII_C, ASCII_L, ASCII_U, ASCII_D, ASCII_E, '\0' }; -#endif static const char KW_NDATA[] = { ASCII_N, ASCII_D, ASCII_A, ASCII_T, ASCII_A, '\0' }; static const char KW_NMTOKEN[] = { diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/expat/xmltok.c --- a/Modules/expat/xmltok.c Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/expat/xmltok.c Sun Jul 20 10:52:46 2014 -0400 @@ -2,22 +2,20 @@ See the file COPYING for copying permission. */ -#include - #ifdef COMPILED_FROM_DSP #include "winconfig.h" #elif defined(MACOS_CLASSIC) #include "macconfig.h" -#elif defined(__amigaos__) +#elif defined(__amigaos4__) #include "amigaconfig.h" -#elif defined(__WATCOMC__) -#include "watcomconfig.h" #else #ifdef HAVE_EXPAT_CONFIG_H #include #endif #endif /* ndef COMPILED_FROM_DSP */ +#include + #include "expat_external.h" #include "internal.h" #include "xmltok.h" @@ -297,9 +295,7 @@ #endif #define PREFIX(ident) normal_ ## ident -#define XML_TOK_IMPL_C #include "xmltok_impl.c" -#undef XML_TOK_IMPL_C #undef MINBPC #undef BYTE_TYPE @@ -696,9 +692,7 @@ #define IS_NMSTRT_CHAR(enc, p, n) (0) #define IS_NMSTRT_CHAR_MINBPC(enc, p) LITTLE2_IS_NMSTRT_CHAR_MINBPC(enc, p) -#define XML_TOK_IMPL_C #include "xmltok_impl.c" -#undef XML_TOK_IMPL_C #undef MINBPC #undef BYTE_TYPE @@ -837,9 +831,7 @@ #define IS_NMSTRT_CHAR(enc, p, n) (0) #define IS_NMSTRT_CHAR_MINBPC(enc, p) BIG2_IS_NMSTRT_CHAR_MINBPC(enc, p) -#define XML_TOK_IMPL_C #include "xmltok_impl.c" -#undef XML_TOK_IMPL_C #undef MINBPC #undef BYTE_TYPE @@ -1345,7 +1337,7 @@ ENCODING * XmlInitUnknownEncoding(void *mem, int *table, - CONVERTER convert, + CONVERTER convert, void *userData) { int i; @@ -1584,7 +1576,7 @@ if (ptr[0] == '\0') { /* 0 isn't a legal data character. Furthermore a document entity can only start with ASCII characters. So the only - way this can fail to be big-endian UTF-16 is if it is an + way this can fail to be big-endian UTF-16 if it it's an external parsed general entity that's labelled as UTF-16LE. */ @@ -1618,9 +1610,7 @@ #define NS(x) x #define ns(x) x -#define XML_TOK_NS_C #include "xmltok_ns.c" -#undef XML_TOK_NS_C #undef NS #undef ns @@ -1629,9 +1619,7 @@ #define NS(x) x ## NS #define ns(x) x ## _ns -#define XML_TOK_NS_C #include "xmltok_ns.c" -#undef XML_TOK_NS_C #undef NS #undef ns @@ -1639,7 +1627,7 @@ ENCODING * XmlInitUnknownEncodingNS(void *mem, int *table, - CONVERTER convert, + CONVERTER convert, void *userData) { ENCODING *enc = XmlInitUnknownEncoding(mem, table, convert, userData); diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/expat/xmltok_impl.c --- a/Modules/expat/xmltok_impl.c Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/expat/xmltok_impl.c Sun Jul 20 10:52:46 2014 -0400 @@ -2,9 +2,6 @@ See the file COPYING for copying permission. */ -/* This file is included! */ -#ifdef XML_TOK_IMPL_C - #ifndef IS_INVALID_CHAR #define IS_INVALID_CHAR(enc, ptr, n) (0) #endif @@ -885,7 +882,7 @@ const char **nextTokPtr) { if (ptr == end) - return XML_TOK_PARTIAL; + return -XML_TOK_PERCENT; switch (BYTE_TYPE(enc, ptr)) { CHECK_NMSTRT_CASES(enc, ptr, end, nextTokPtr) case BT_S: case BT_LF: case BT_CR: case BT_PERCNT: @@ -1780,4 +1777,3 @@ #undef CHECK_NMSTRT_CASE #undef CHECK_NMSTRT_CASES -#endif /* XML_TOK_IMPL_C */ diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/expat/xmltok_ns.c --- a/Modules/expat/xmltok_ns.c Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/expat/xmltok_ns.c Sun Jul 20 10:52:46 2014 -0400 @@ -1,10 +1,3 @@ -/* Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd - See the file COPYING for copying permission. -*/ - -/* This file is included! */ -#ifdef XML_TOK_NS_C - const ENCODING * NS(XmlGetUtf8InternalEncoding)(void) { @@ -111,5 +104,3 @@ encoding, standalone); } - -#endif /* XML_TOK_NS_C */ diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/fcntlmodule.c --- a/Modules/fcntlmodule.c Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/fcntlmodule.c Sun Jul 20 10:52:46 2014 -0400 @@ -27,7 +27,7 @@ } -/* fcntl(fd, op, [arg]) */ +/* fcntl(fd, opt, [arg]) */ static PyObject * fcntl_fcntl(PyObject *self, PyObject *args) @@ -77,12 +77,11 @@ } PyDoc_STRVAR(fcntl_doc, -"fcntl(fd, op, [arg])\n\ +"fcntl(fd, opt, [arg])\n\ \n\ -Perform the operation op on file descriptor fd. The values used\n\ -for op are operating system dependent, and are available\n\ -as constants in the fcntl module, using the same names as used in\n\ -the relevant C header files. The argument arg is optional, and\n\ +Perform the requested operation on file descriptor fd. The operation\n\ +is defined by op and is operating system dependent. These constants are\n\ +available from the fcntl module. The argument arg is optional, and\n\ defaults to 0; it may be an int or a string. If arg is given as a string,\n\ the return value of fcntl is a string of that length, containing the\n\ resulting value put in the arg buffer by the operating system. The length\n\ @@ -91,7 +90,7 @@ corresponding to the return value of the fcntl call in the C code."); -/* ioctl(fd, op, [arg]) */ +/* ioctl(fd, opt, [arg]) */ static PyObject * fcntl_ioctl(PyObject *self, PyObject *args) @@ -105,7 +104,7 @@ whereas the system expects it to be a 32bit bit field value regardless of it being passed as an int or unsigned long on various platforms. See the termios.TIOCSWINSZ constant across - platforms for an example of this. + platforms for an example of thise. If any of the 64bit platforms ever decide to use more than 32bits in their unsigned long ioctl codes this will break and need @@ -213,12 +212,11 @@ } PyDoc_STRVAR(ioctl_doc, -"ioctl(fd, op[, arg[, mutate_flag]])\n\ +"ioctl(fd, opt[, arg[, mutate_flag]])\n\ \n\ -Perform the operation op on file descriptor fd. The values used for op\n\ -are operating system dependent, and are available as constants in the\n\ -fcntl or termios library modules, using the same names as used in the\n\ -relevant C header files.\n\ +Perform the requested operation on file descriptor fd. The operation is\n\ +defined by opt and is operating system dependent. Typically these codes are\n\ +retrieved from the fcntl or termios library modules.\n\ \n\ The argument arg is optional, and defaults to 0; it may be an int or a\n\ buffer containing character data (most likely a string or an array). \n\ @@ -301,7 +299,7 @@ "flock(fd, operation)\n\ \n\ Perform the lock operation op on file descriptor fd. See the Unix \n\ -manual page for flock(2) for details. (On some systems, this function is\n\ +manual page for flock(3) for details. (On some systems, this function is\n\ emulated using fcntl().)"); diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/flmodule.c --- a/Modules/flmodule.c Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/flmodule.c Sun Jul 20 10:52:46 2014 -0400 @@ -97,8 +97,10 @@ { int i, n; - Py_CLEAR(g->ob_callback); - Py_CLEAR(g->ob_callback_arg); + Py_XDECREF(g->ob_callback); + g->ob_callback = NULL; + Py_XDECREF(g->ob_callback_arg); + g->ob_callback_arg = NULL; if (allgenerics == NULL) return; /* No objects known yet */ n = PyList_Size(allgenerics); @@ -130,8 +132,10 @@ /* The object is now unreachable for do_forms and check_forms, so delete it from the list of known objects */ - Py_CLEAR(g->ob_callback); - Py_CLEAR(g->ob_callback_arg); + Py_XDECREF(g->ob_callback); + g->ob_callback = NULL; + Py_XDECREF(g->ob_callback_arg); + g->ob_callback_arg = NULL; PyList_SetItem(allgenerics, i, (PyObject *)NULL); nfreeslots++; } diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/gcmodule.c --- a/Modules/gcmodule.c Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/gcmodule.c Sun Jul 20 10:52:46 2014 -0400 @@ -111,46 +111,6 @@ http://mail.python.org/pipermail/python-dev/2008-June/080579.html */ -/* - NOTE: about untracking of mutable objects. - - Certain types of container cannot participate in a reference cycle, and - so do not need to be tracked by the garbage collector. Untracking these - objects reduces the cost of garbage collections. However, determining - which objects may be untracked is not free, and the costs must be - weighed against the benefits for garbage collection. - - There are two possible strategies for when to untrack a container: - - i) When the container is created. - ii) When the container is examined by the garbage collector. - - Tuples containing only immutable objects (integers, strings etc, and - recursively, tuples of immutable objects) do not need to be tracked. - The interpreter creates a large number of tuples, many of which will - not survive until garbage collection. It is therefore not worthwhile - to untrack eligible tuples at creation time. - - Instead, all tuples except the empty tuple are tracked when created. - During garbage collection it is determined whether any surviving tuples - can be untracked. A tuple can be untracked if all of its contents are - already not tracked. Tuples are examined for untracking in all garbage - collection cycles. It may take more than one cycle to untrack a tuple. - - Dictionaries containing only immutable objects also do not need to be - tracked. Dictionaries are untracked when created. If a tracked item is - inserted into a dictionary (either as a key or value), the dictionary - becomes tracked. During a full garbage collection (all generations), - the collector will untrack any dictionaries whose contents are not - tracked. - - The module provides the python function is_tracked(obj), which returns - the CURRENT tracking status of the object. Subsequent garbage - collections may change the tracking status of the object. - - Untracking of certain containers was introduced in issue #4688, and - the algorithm was refined in response to issue #14775. -*/ /* set for debugging information */ #define DEBUG_STATS (1<<0) /* print collection statistics */ @@ -476,6 +436,9 @@ if (PyTuple_CheckExact(op)) { _PyTuple_MaybeUntrack(op); } + else if (PyDict_CheckExact(op)) { + _PyDict_MaybeUntrack(op); + } } else { /* This *may* be unreachable. To make progress, @@ -515,20 +478,6 @@ return 0; } -/* Try to untrack all currently tracked dictionaries */ -static void -untrack_dicts(PyGC_Head *head) -{ - PyGC_Head *next, *gc = head->gc.gc_next; - while (gc != head) { - PyObject *op = FROM_GC(gc); - next = gc->gc.gc_next; - if (PyDict_CheckExact(op)) - _PyDict_MaybeUntrack(op); - gc = next; - } -} - /* Move the objects in unreachable with __del__ methods into `finalizers`. * Objects moved into `finalizers` have gc_refs set to GC_REACHABLE; the * objects remaining in unreachable are left at GC_TENTATIVELY_UNREACHABLE. @@ -941,9 +890,6 @@ gc_list_merge(young, old); } else { - /* We only untrack dicts in full collections, to avoid quadratic - dict build-up. See issue #14775. */ - untrack_dicts(young); long_lived_pending = 0; long_lived_total = gc_list_size(young); } diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/getaddrinfo.c --- a/Modules/getaddrinfo.c Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/getaddrinfo.c Sun Jul 20 10:52:46 2014 -0400 @@ -430,7 +430,7 @@ break; #ifdef ENABLE_IPV6 case AF_INET6: - pfx = ((struct in6_addr *)pton)->s6_addr[0]; + pfx = ((struct in6_addr *)pton)->s6_addr8[0]; if (pfx == 0 || pfx == 0xfe || pfx == 0xff) pai->ai_flags &= ~AI_CANONNAME; break; diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/getnameinfo.c --- a/Modules/getnameinfo.c Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/getnameinfo.c Sun Jul 20 10:52:46 2014 -0400 @@ -161,7 +161,7 @@ break; #ifdef ENABLE_IPV6 case AF_INET6: - pfx = ((struct sockaddr_in6 *)sa)->sin6_addr.s6_addr[0]; + pfx = ((struct sockaddr_in6 *)sa)->sin6_addr.s6_addr8[0]; if (pfx == 0 || pfx == 0xfe || pfx == 0xff) flags |= NI_NUMERICHOST; break; diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/getpath.c --- a/Modules/getpath.c Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/getpath.c Sun Jul 20 10:52:46 2014 -0400 @@ -335,27 +335,12 @@ return 1; } - /* Check to see if argv[0] is in the build directory. "pybuilddir.txt" - is written by setup.py and contains the relative path to the location - of shared library modules. */ + /* Check to see if argv[0] is in the build directory */ strcpy(exec_prefix, argv0_path); - joinpath(exec_prefix, "pybuilddir.txt"); + joinpath(exec_prefix, "Modules/Setup"); if (isfile(exec_prefix)) { - FILE *f = fopen(exec_prefix, "r"); - if (f == NULL) - errno = 0; - else { - char rel_builddir_path[MAXPATHLEN+1]; - size_t n; - n = fread(rel_builddir_path, 1, MAXPATHLEN, f); - rel_builddir_path[n] = '\0'; - fclose(f); - if (n >= 0) { - strcpy(exec_prefix, argv0_path); - joinpath(exec_prefix, rel_builddir_path); - return -1; - } - } + reduce(exec_prefix); + return -1; } /* Search from argv0_path, until root is found */ diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/grpmodule.c --- a/Modules/grpmodule.c Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/grpmodule.c Sun Jul 20 10:52:46 2014 -0400 @@ -3,15 +3,15 @@ #include "Python.h" #include "structseq.h" -#include "posixmodule.h" +#include #include static PyStructSequence_Field struct_group_type_fields[] = { {"gr_name", "group name"}, {"gr_passwd", "password"}, - {"gr_gid", "group id"}, - {"gr_mem", "group members"}, + {"gr_gid", "group id"}, + {"gr_mem", "group memebers"}, {0} }; @@ -70,7 +70,7 @@ Py_INCREF(Py_None); } #endif - SET(setIndex++, _PyInt_FromGid(p->gr_gid)); + SET(setIndex++, PyInt_FromLong((long) p->gr_gid)); SET(setIndex++, w); #undef SET @@ -86,25 +86,17 @@ grp_getgrgid(PyObject *self, PyObject *pyo_id) { PyObject *py_int_id; - gid_t gid; + unsigned int gid; struct group *p; py_int_id = PyNumber_Int(pyo_id); if (!py_int_id) - return NULL; - if (!_Py_Gid_Converter(py_int_id, &gid)) { - Py_DECREF(py_int_id); - return NULL; - } + return NULL; + gid = PyInt_AS_LONG(py_int_id); Py_DECREF(py_int_id); if ((p = getgrgid(gid)) == NULL) { - if (gid < 0) - PyErr_Format(PyExc_KeyError, - "getgrgid(): gid not found: %ld", (long)gid); - else - PyErr_Format(PyExc_KeyError, - "getgrgid(): gid not found: %lu", (unsigned long)gid); + PyErr_Format(PyExc_KeyError, "getgrgid(): gid not found: %d", gid); return NULL; } return mkgrent(p); @@ -121,7 +113,7 @@ if (!py_str_name) return NULL; name = PyString_AS_STRING(py_str_name); - + if ((p = getgrnam(name)) == NULL) { PyErr_Format(PyExc_KeyError, "getgrnam(): name not found: %s", name); Py_DECREF(py_str_name); diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/itertoolsmodule.c --- a/Modules/itertoolsmodule.c Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/itertoolsmodule.c Sun Jul 20 10:52:46 2014 -0400 @@ -401,31 +401,14 @@ return 0; } -static void -teedataobject_safe_decref(PyObject *obj) -{ - while (obj && Py_TYPE(obj) == &teedataobject_type && - Py_REFCNT(obj) == 1) { - PyObject *nextlink = ((teedataobject *)obj)->nextlink; - ((teedataobject *)obj)->nextlink = NULL; - Py_DECREF(obj); - obj = nextlink; - } - Py_XDECREF(obj); -} - static int teedataobject_clear(teedataobject *tdo) { int i; - PyObject *tmp; - Py_CLEAR(tdo->it); for (i=0 ; inumread ; i++) Py_CLEAR(tdo->values[i]); - tmp = tdo->nextlink; - tdo->nextlink = NULL; - teedataobject_safe_decref(tmp); + Py_CLEAR(tdo->nextlink); return 0; } @@ -492,8 +475,6 @@ if (to->index >= LINKCELLS) { link = teedataobject_jumplink(to->dataobj); - if (link == NULL) - return NULL; Py_DECREF(to->dataobj); to->dataobj = (teedataobject *)link; to->index = 0; @@ -922,13 +903,11 @@ } ok = PyObject_IsTrue(good); Py_DECREF(good); - if (ok == 0) { + if (!ok) { lz->start = 1; return item; } Py_DECREF(item); - if (ok < 0) - return NULL; } } @@ -1064,11 +1043,10 @@ } ok = PyObject_IsTrue(good); Py_DECREF(good); - if (ok > 0) + if (ok) return item; Py_DECREF(item); - if (ok == 0) - lz->stop = 1; + lz->stop = 1; return NULL; } @@ -1241,22 +1219,19 @@ Py_ssize_t oldnext; PyObject *(*iternext)(PyObject *); - if (it == NULL) - return NULL; - iternext = *Py_TYPE(it)->tp_iternext; while (lz->cnt < lz->next) { item = iternext(it); if (item == NULL) - goto empty; + return NULL; Py_DECREF(item); lz->cnt++; } if (stop != -1 && lz->cnt >= stop) - goto empty; + return NULL; item = iternext(it); if (item == NULL) - goto empty; + return NULL; lz->cnt++; oldnext = lz->next; /* The (size_t) cast below avoids the danger of undefined @@ -1265,10 +1240,6 @@ if (lz->next < oldnext || (stop != -1 && lz->next > stop)) lz->next = stop; return item; - -empty: - Py_CLEAR(lz->it); - return NULL; } PyDoc_STRVAR(islice_doc, @@ -3030,11 +3001,9 @@ ok = PyObject_IsTrue(good); Py_DECREF(good); } - if (ok > 0) + if (ok) return item; Py_DECREF(item); - if (ok < 0) - return NULL; } } @@ -3175,11 +3144,9 @@ ok = PyObject_IsTrue(good); Py_DECREF(good); } - if (ok == 0) + if (!ok) return item; Py_DECREF(item); - if (ok < 0) - return NULL; } } @@ -3433,10 +3400,10 @@ Return a count object whose .next() method returns consecutive values.\n\ Equivalent to:\n\n\ def count(firstval=0, step=1):\n\ - x = firstval\n\ - while 1:\n\ - yield x\n\ - x += step\n"); + x = firstval\n\ + while 1:\n\ + yield x\n\ + x += step\n"); static PyTypeObject count_type = { PyVarObject_HEAD_INIT(NULL, 0) @@ -3683,17 +3650,14 @@ { repeatobject *ro; PyObject *element; - Py_ssize_t cnt = -1, n_kwds = 0; + Py_ssize_t cnt = -1; static char *kwargs[] = {"object", "times", NULL}; if (!PyArg_ParseTupleAndKeywords(args, kwds, "O|n:repeat", kwargs, &element, &cnt)) return NULL; - if (kwds != NULL) - n_kwds = PyDict_Size(kwds); - /* Does user supply times argument? */ - if ((PyTuple_Size(args) + n_kwds == 2) && cnt < 0) + if (PyTuple_Size(args) == 2 && cnt < 0) cnt = 0; ro = (repeatobject *)type->tp_alloc(type, 0); diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/main.c --- a/Modules/main.c Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/main.c Sun Jul 20 10:52:46 2014 -0400 @@ -40,7 +40,7 @@ static int orig_argc; /* command line options */ -#define BASE_OPTS "3bBc:dEhiJm:OQ:RsStuUvVW:xX?" +#define BASE_OPTS "3bBc:dEhiJm:OQ:sStuUvVW:xX?" #ifndef RISCOS #define PROGRAM_OPTS BASE_OPTS @@ -71,9 +71,6 @@ -m mod : run library module as a script (terminates option list)\n\ -O : optimize generated bytecode slightly; also PYTHONOPTIMIZE=x\n\ -OO : remove doc-strings in addition to the -O optimizations\n\ --R : use a pseudo-random salt to make hash() values of various types be\n\ - unpredictable between separate invocations of the interpreter, as\n\ - a defense against denial-of-service attacks\n\ -Q arg : division options: -Qold (default), -Qwarn, -Qwarnall, -Qnew\n\ -s : don't add user site directory to sys.path; also PYTHONNOUSERSITE\n\ -S : don't imply 'import site' on initialization\n\ @@ -105,12 +102,6 @@ PYTHONCASEOK : ignore case in 'import' statements (Windows).\n\ PYTHONIOENCODING: Encoding[:errors] used for stdin/stdout/stderr.\n\ "; -static char *usage_6 = "\ -PYTHONHASHSEED: if this variable is set to 'random', the effect is the same\n\ - as specifying the -R option: a random value is used to seed the hashes of\n\ - str, bytes and datetime objects. It can also be set to an integer\n\ - in the range [0,4294967295] to get hash values with a predictable seed.\n\ -"; static int @@ -127,7 +118,6 @@ fputs(usage_3, f); fprintf(f, usage_4, DELIM); fprintf(f, usage_5, DELIM, PYTHONHOMEHELP); - fputs(usage_6, f); } #if defined(__VMS) if (exitcode == 0) { @@ -262,34 +252,7 @@ Py_RISCOSWimpFlag = 0; #endif - /* Hash randomization needed early for all string operations - (including -W and -X options). */ - _PyOS_opterr = 0; /* prevent printing the error in 1st pass */ - while ((c = _PyOS_GetOpt(argc, argv, PROGRAM_OPTS)) != EOF) { - if (c == 'm' || c == 'c') { - /* -c / -m is the last option: following arguments are - not interpreter options. */ - break; - } - switch (c) { - case 'E': - Py_IgnoreEnvironmentFlag++; - break; - case 'R': - Py_HashRandomizationFlag++; - break; - } - } - /* The variable is only tested for existence here; _PyRandom_Init will - check its value further. */ - if (!Py_HashRandomizationFlag && - (p = Py_GETENV("PYTHONHASHSEED")) && *p != '\0') - Py_HashRandomizationFlag = 1; - - _PyRandom_Init(); - PySys_ResetWarnOptions(); - _PyOS_ResetGetOpt(); while ((c = _PyOS_GetOpt(argc, argv, PROGRAM_OPTS)) != EOF) { if (c == 'c') { @@ -383,7 +346,7 @@ break; case 'E': - /* Already handled above */ + Py_IgnoreEnvironmentFlag++; break; case 't': @@ -426,10 +389,6 @@ PySys_AddWarnOption(_PyOS_optarg); break; - case 'R': - /* Already handled above */ - break; - /* This space reserved for other options */ default: @@ -584,7 +543,7 @@ sts = PyRun_SimpleStringFlags(command, &cf) != 0; free(command); } else if (module) { - sts = (RunModule(module, 1) != 0); + sts = RunModule(module, 1); free(module); } else { diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/mathmodule.c --- a/Modules/mathmodule.c Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/mathmodule.c Sun Jul 20 10:52:46 2014 -0400 @@ -1277,33 +1277,23 @@ { /* If it is long, do it ourselves. */ if (PyLong_Check(arg)) { - double x, result; + double x; Py_ssize_t e; - - /* Negative or zero inputs give a ValueError. */ - if (Py_SIZE(arg) <= 0) { + x = _PyLong_Frexp((PyLongObject *)arg, &e); + if (x == -1.0 && PyErr_Occurred()) + return NULL; + if (x <= 0.0) { PyErr_SetString(PyExc_ValueError, "math domain error"); return NULL; } - - x = PyLong_AsDouble(arg); - if (x == -1.0 && PyErr_Occurred()) { - if (!PyErr_ExceptionMatches(PyExc_OverflowError)) - return NULL; - /* Here the conversion to double overflowed, but it's possible - to compute the log anyway. Clear the exception and continue. */ - PyErr_Clear(); - x = _PyLong_Frexp((PyLongObject *)arg, &e); - if (x == -1.0 && PyErr_Occurred()) - return NULL; - /* Value is ~= x * 2**e, so the log ~= log(x) + log(2) * e. */ - result = func(x) + func(2.0) * e; - } - else - /* Successfully converted x to a double. */ - result = func(x); - return PyFloat_FromDouble(result); + /* Special case for log(1), to make sure we get an + exact result there. */ + if (e == 1 && x == 0.5) + return PyFloat_FromDouble(0.0); + /* Value is ~= x * 2**e, so the log ~= log(x) + log(2) * e. */ + x = func(x) + func(2.0) * e; + return PyFloat_FromDouble(x); } /* Else let libm handle it by itself. */ diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/md5module.c --- a/Modules/md5module.c Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/md5module.c Sun Jul 20 10:52:46 2014 -0400 @@ -51,25 +51,12 @@ md5_update(md5object *self, PyObject *args) { Py_buffer view; - Py_ssize_t n; - unsigned char *buf; if (!PyArg_ParseTuple(args, "s*:update", &view)) return NULL; - n = view.len; - buf = (unsigned char *) view.buf; - while (n > 0) { - Py_ssize_t nbytes; - if (n > INT_MAX) - nbytes = INT_MAX; - else - nbytes = n; - md5_append(&self->md5, buf, - Py_SAFE_DOWNCAST(nbytes, Py_ssize_t, unsigned int)); - buf += nbytes; - n -= nbytes; - } + md5_append(&self->md5, (unsigned char*)view.buf, + Py_SAFE_DOWNCAST(view.len, Py_ssize_t, unsigned int)); PyBuffer_Release(&view); Py_RETURN_NONE; @@ -275,8 +262,6 @@ { md5object *md5p; Py_buffer view = { 0 }; - Py_ssize_t n; - unsigned char *buf; if (!PyArg_ParseTuple(args, "|s*:new", &view)) return NULL; @@ -286,18 +271,9 @@ return NULL; } - n = view.len; - buf = (unsigned char *) view.buf; - while (n > 0) { - Py_ssize_t nbytes; - if (n > INT_MAX) - nbytes = INT_MAX; - else - nbytes = n; - md5_append(&md5p->md5, buf, - Py_SAFE_DOWNCAST(nbytes, Py_ssize_t, unsigned int)); - buf += nbytes; - n -= nbytes; + if (view.len > 0) { + md5_append(&md5p->md5, (unsigned char*)view.buf, + Py_SAFE_DOWNCAST(view.len, Py_ssize_t, unsigned int)); } PyBuffer_Release(&view); diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/mmapmodule.c --- a/Modules/mmapmodule.c Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/mmapmodule.c Sun Jul 20 10:52:46 2014 -0400 @@ -1188,22 +1188,19 @@ # endif if (fd != -1 && fstat(fd, &st) == 0 && S_ISREG(st.st_mode)) { if (map_size == 0) { - if (st.st_size == 0) { - PyErr_SetString(PyExc_ValueError, - "cannot mmap an empty file"); - return NULL; - } + off_t calc_size; if (offset >= st.st_size) { PyErr_SetString(PyExc_ValueError, "mmap offset is greater than file size"); return NULL; } - if (st.st_size - offset > PY_SSIZE_T_MAX) { + calc_size = st.st_size - offset; + map_size = calc_size; + if (map_size != calc_size) { PyErr_SetString(PyExc_ValueError, "mmap length is too large"); - return NULL; - } - map_size = (Py_ssize_t) (st.st_size - offset); + return NULL; + } } else if (offset + (size_t)map_size > st.st_size) { PyErr_SetString(PyExc_ValueError, "mmap length is greater than file size"); @@ -1386,25 +1383,17 @@ } size = (((PY_LONG_LONG) high) << 32) + low; - if (size == 0) { - PyErr_SetString(PyExc_ValueError, - "cannot mmap an empty file"); - Py_DECREF(m_obj); - return NULL; - } if (offset >= size) { PyErr_SetString(PyExc_ValueError, "mmap offset is greater than file size"); Py_DECREF(m_obj); return NULL; } - if (size - offset > PY_SSIZE_T_MAX) { - PyErr_SetString(PyExc_ValueError, - "mmap length is too large"); - Py_DECREF(m_obj); - return NULL; - } - m_obj->size = (Py_ssize_t) (size - offset); + if (offset - size > PY_SSIZE_T_MAX) + /* Map area too large to fit in memory */ + m_obj->size = (Py_ssize_t) -1; + else + m_obj->size = (Py_ssize_t) (size - offset); } else { m_obj->size = map_size; size = offset + map_size; diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/operator.c --- a/Modules/operator.c Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/operator.c Sun Jul 20 10:52:46 2014 -0400 @@ -235,132 +235,6 @@ #define spam2o(OP,ALTOP,DOC) {#OP, op_##OP, METH_O, PyDoc_STR(DOC)}, \ {#ALTOP, op_##OP, METH_O, PyDoc_STR(DOC)}, - - -/* compare_digest **********************************************************/ - -/* - * timing safe compare - * - * Returns 1 of the strings are equal. - * In case of len(a) != len(b) the function tries to keep the timing - * dependent on the length of b. CPU cache locally may still alter timing - * a bit. - */ -static int -_tscmp(const unsigned char *a, const unsigned char *b, - Py_ssize_t len_a, Py_ssize_t len_b) -{ - /* The volatile type declarations make sure that the compiler has no - * chance to optimize and fold the code in any way that may change - * the timing. - */ - volatile Py_ssize_t length; - volatile const unsigned char *left; - volatile const unsigned char *right; - Py_ssize_t i; - unsigned char result; - - /* loop count depends on length of b */ - length = len_b; - left = NULL; - right = b; - - /* don't use else here to keep the amount of CPU instructions constant, - * volatile forces re-evaluation - * */ - if (len_a == length) { - left = *((volatile const unsigned char**)&a); - result = 0; - } - if (len_a != length) { - left = b; - result = 1; - } - - for (i=0; i < length; i++) { - result |= *left++ ^ *right++; - } - - return (result == 0); -} - -PyDoc_STRVAR(compare_digest__doc__, -"compare_digest(a, b) -> bool\n" -"\n" -"Return 'a == b'. This function uses an approach designed to prevent\n" -"timing analysis, making it appropriate for cryptography.\n" -"a and b must both be of the same type: either str (ASCII only),\n" -"or any type that supports the buffer protocol (e.g. bytes).\n" -"\n" -"Note: If a and b are of different lengths, or if an error occurs,\n" -"a timing attack could theoretically reveal information about the\n" -"types and lengths of a and b--but not their values.\n"); - -static PyObject* -compare_digest(PyObject *self, PyObject *args) -{ - PyObject *a, *b; - int rc; - - if (!PyArg_ParseTuple(args, "OO:compare_digest", &a, &b)) { - return NULL; - } - - /* Unicode string */ - if (PyUnicode_Check(a) && PyUnicode_Check(b)) { - rc = _tscmp((const unsigned char *)PyUnicode_AS_DATA(a), - (const unsigned char *)PyUnicode_AS_DATA(b), - PyUnicode_GET_DATA_SIZE(a), - PyUnicode_GET_DATA_SIZE(b)); - } - /* fallback to buffer interface for bytes, bytesarray and other */ - else { - Py_buffer view_a; - Py_buffer view_b; - - if (PyObject_CheckBuffer(a) == 0 && PyObject_CheckBuffer(b) == 0) { - PyErr_Format(PyExc_TypeError, - "unsupported operand types(s) or combination of types: " - "'%.100s' and '%.100s'", - Py_TYPE(a)->tp_name, Py_TYPE(b)->tp_name); - return NULL; - } - - if (PyObject_GetBuffer(a, &view_a, PyBUF_SIMPLE) == -1) { - return NULL; - } - if (view_a.ndim > 1) { - PyErr_SetString(PyExc_BufferError, - "Buffer must be single dimension"); - PyBuffer_Release(&view_a); - return NULL; - } - - if (PyObject_GetBuffer(b, &view_b, PyBUF_SIMPLE) == -1) { - PyBuffer_Release(&view_a); - return NULL; - } - if (view_b.ndim > 1) { - PyErr_SetString(PyExc_BufferError, - "Buffer must be single dimension"); - PyBuffer_Release(&view_a); - PyBuffer_Release(&view_b); - return NULL; - } - - rc = _tscmp((const unsigned char*)view_a.buf, - (const unsigned char*)view_b.buf, - view_a.len, - view_b.len); - - PyBuffer_Release(&view_a); - PyBuffer_Release(&view_b); - } - - return PyBool_FromLong(rc); -} - static struct PyMethodDef operator_methods[] = { spam1o(isCallable, @@ -444,8 +318,6 @@ spam2(gt,__gt__, "gt(a, b) -- Same as a>b.") spam2(ge,__ge__, "ge(a, b) -- Same as a>=b.") - {"_compare_digest", (PyCFunction)compare_digest, METH_VARARGS, - compare_digest__doc__}, {NULL, NULL} /* sentinel */ }; @@ -540,8 +412,8 @@ "itemgetter(item, ...) --> itemgetter object\n\ \n\ Return a callable object that fetches the given item(s) from its operand.\n\ -After f = itemgetter(2), the call f(r) returns r[2].\n\ -After g = itemgetter(2, 5, 3), the call g(r) returns (r[2], r[5], r[3])"); +After, f=itemgetter(2), the call f(r) returns r[2].\n\ +After, g=itemgetter(2,5,3), the call g(r) returns (r[2], r[5], r[3])"); static PyTypeObject itemgetter_type = { PyVarObject_HEAD_INIT(NULL, 0) @@ -720,9 +592,9 @@ "attrgetter(attr, ...) --> attrgetter object\n\ \n\ Return a callable object that fetches the given attribute(s) from its operand.\n\ -After f = attrgetter('name'), the call f(r) returns r.name.\n\ -After g = attrgetter('name', 'date'), the call g(r) returns (r.name, r.date).\n\ -After h = attrgetter('name.first', 'name.last'), the call h(r) returns\n\ +After, f=attrgetter('name'), the call f(r) returns r.name.\n\ +After, g=attrgetter('name', 'date'), the call g(r) returns (r.name, r.date).\n\ +After, h=attrgetter('name.first', 'name.last'), the call h(r) returns\n\ (r.name.first, r.name.last)."); static PyTypeObject attrgetter_type = { @@ -852,8 +724,8 @@ "methodcaller(name, ...) --> methodcaller object\n\ \n\ Return a callable object that calls the given method on its operand.\n\ -After f = methodcaller('name'), the call f(r) returns r.name().\n\ -After g = methodcaller('name', 'date', foo=1), the call g(r) returns\n\ +After, f = methodcaller('name'), the call f(r) returns r.name().\n\ +After, g = methodcaller('name', 'date', foo=1), the call g(r) returns\n\ r.name('date', foo=1)."); static PyTypeObject methodcaller_type = { diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/ossaudiodev.c --- a/Modules/ossaudiodev.c Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/ossaudiodev.c Sun Jul 20 10:52:46 2014 -0400 @@ -215,7 +215,7 @@ */ /* _do_ioctl_1() is a private helper function used for the OSS ioctls -- - SNDCTL_DSP_{SETFMT,CHANNELS,SPEED} -- that are called from C + SNDCTL_DSP_{SETFMT,CHANNELS,SPEED} -- that that are called from C like this: ioctl(fd, SNDCTL_DSP_cmd, &arg) @@ -490,6 +490,7 @@ { int wanted_fmt, wanted_channels, wanted_rate, strict=0; int fmt, channels, rate; + PyObject * rv; /* return tuple (fmt, channels, rate) */ if (!PyArg_ParseTuple(args, "iii|i:setparameters", &wanted_fmt, &wanted_channels, &wanted_rate, @@ -531,7 +532,13 @@ /* Construct the return value: a (fmt, channels, rate) tuple that tells what the audio hardware was actually set to. */ - return Py_BuildValue("(iii)", fmt, channels, rate); + rv = PyTuple_New(3); + if (rv == NULL) + return NULL; + PyTuple_SET_ITEM(rv, 0, PyInt_FromLong(fmt)); + PyTuple_SET_ITEM(rv, 1, PyInt_FromLong(channels)); + PyTuple_SET_ITEM(rv, 2, PyInt_FromLong(rate)); + return rv; } static int diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/parsermodule.c --- a/Modules/parsermodule.c Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/parsermodule.c Sun Jul 20 10:52:46 2014 -0400 @@ -169,33 +169,9 @@ static void parser_free(PyST_Object *st); -static PyObject* parser_sizeof(PyST_Object *, void *); static int parser_compare(PyST_Object *left, PyST_Object *right); static PyObject *parser_getattr(PyObject *self, char *name); -static PyObject* parser_compilest(PyST_Object *, PyObject *, PyObject *); -static PyObject* parser_isexpr(PyST_Object *, PyObject *, PyObject *); -static PyObject* parser_issuite(PyST_Object *, PyObject *, PyObject *); -static PyObject* parser_st2list(PyST_Object *, PyObject *, PyObject *); -static PyObject* parser_st2tuple(PyST_Object *, PyObject *, PyObject *); - -#define PUBLIC_METHOD_TYPE (METH_VARARGS|METH_KEYWORDS) - -static PyMethodDef -parser_methods[] = { - {"compile", (PyCFunction)parser_compilest, PUBLIC_METHOD_TYPE, - PyDoc_STR("Compile this ST object into a code object.")}, - {"isexpr", (PyCFunction)parser_isexpr, PUBLIC_METHOD_TYPE, - PyDoc_STR("Determines if this ST object was created from an expression.")}, - {"issuite", (PyCFunction)parser_issuite, PUBLIC_METHOD_TYPE, - PyDoc_STR("Determines if this ST object was created from a suite.")}, - {"tolist", (PyCFunction)parser_st2list, PUBLIC_METHOD_TYPE, - PyDoc_STR("Creates a list-tree representation of this ST.")}, - {"totuple", (PyCFunction)parser_st2tuple, PUBLIC_METHOD_TYPE, - PyDoc_STR("Creates a tuple-tree representation of this ST.")}, - {"__sizeof__", (PyCFunction)parser_sizeof, METH_NOARGS, - PyDoc_STR("Returns size in memory, in bytes.")}, - {NULL, NULL, 0, NULL} -}; + static PyTypeObject PyST_Type = { @@ -224,14 +200,7 @@ Py_TPFLAGS_DEFAULT, /* tp_flags */ /* __doc__ */ - "Intermediate representation of a Python parse tree.", - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - parser_methods, /* tp_methods */ + "Intermediate representation of a Python parse tree." }; /* PyST_Type */ @@ -350,14 +319,10 @@ int lineno = 0; int col_offset = 0; if (line_option != NULL) { - lineno = PyObject_IsTrue(line_option); - if (lineno < 0) - return NULL; + lineno = (PyObject_IsTrue(line_option) != 0) ? 1 : 0; } if (col_option != NULL) { - col_offset = PyObject_IsTrue(col_option); - if (col_offset < 0) - return NULL; + col_offset = (PyObject_IsTrue(col_option) != 0) ? 1 : 0; } /* * Convert ST into a tuple representation. Use Guido's function, @@ -405,14 +370,10 @@ int lineno = 0; int col_offset = 0; if (line_option != 0) { - lineno = PyObject_IsTrue(line_option); - if (lineno < 0) - return NULL; + lineno = PyObject_IsTrue(line_option) ? 1 : 0; } - if (col_option != 0) { - col_offset = PyObject_IsTrue(col_option); - if (col_offset < 0) - return NULL; + if (col_option != NULL) { + col_offset = (PyObject_IsTrue(col_option) != 0) ? 1 : 0; } /* * Convert ST into a tuple representation. Use Guido's function, @@ -533,6 +494,25 @@ } +#define PUBLIC_METHOD_TYPE (METH_VARARGS|METH_KEYWORDS) + +static PyMethodDef +parser_methods[] = { + {"compile", (PyCFunction)parser_compilest, PUBLIC_METHOD_TYPE, + PyDoc_STR("Compile this ST object into a code object.")}, + {"isexpr", (PyCFunction)parser_isexpr, PUBLIC_METHOD_TYPE, + PyDoc_STR("Determines if this ST object was created from an expression.")}, + {"issuite", (PyCFunction)parser_issuite, PUBLIC_METHOD_TYPE, + PyDoc_STR("Determines if this ST object was created from a suite.")}, + {"tolist", (PyCFunction)parser_st2list, PUBLIC_METHOD_TYPE, + PyDoc_STR("Creates a list-tree representation of this ST.")}, + {"totuple", (PyCFunction)parser_st2tuple, PUBLIC_METHOD_TYPE, + PyDoc_STR("Creates a tuple-tree representation of this ST.")}, + + {NULL, NULL, 0, NULL} +}; + + static PyObject* parser_getattr(PyObject *self, char *name) { @@ -698,7 +678,7 @@ err_string("parse tree does not use a valid start symbol"); } } - /* Make sure we raise an exception on all errors. We should never + /* Make sure we throw an exception on all errors. We should never * get this, but we'd do well to be sure something is done. */ if (st == NULL && !PyErr_Occurred()) @@ -715,15 +695,6 @@ return parser_tuple2st(self, args, kw); } -static PyObject * -parser_sizeof(PyST_Object *st, void *unused) -{ - Py_ssize_t res; - - res = sizeof(PyST_Object) + _PyNode_SizeOf(st->st_node); - return PyLong_FromSsize_t(res); -} - /* node* build_node_children() * @@ -813,7 +784,7 @@ else if (!ISNONTERMINAL(type)) { /* * It has to be one or the other; this is an error. - * Raise an exception. + * Throw an exception. */ PyObject *err = Py_BuildValue("os", elem, "unknown node type."); PyErr_SetObject(parser_error, err); @@ -863,7 +834,7 @@ if (ISTERMINAL(num)) { /* * The tuple is simple, but it doesn't start with a start symbol. - * Raise an exception now and be done with it. + * Throw an exception now and be done with it. */ tuple = Py_BuildValue("os", tuple, "Illegal syntax-tree; cannot start with terminal symbol."); diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/posixmodule.c --- a/Modules/posixmodule.c Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/posixmodule.c Sun Jul 20 10:52:46 2014 -0400 @@ -27,9 +27,6 @@ #include "Python.h" #include "structseq.h" -#ifndef MS_WINDOWS -#include "posixmodule.h" -#endif #if defined(__VMS) # include @@ -350,133 +347,9 @@ #endif #endif - -#ifndef MS_WINDOWS -PyObject * -_PyInt_FromUid(uid_t uid) -{ - if (uid <= LONG_MAX) - return PyInt_FromLong(uid); - return PyLong_FromUnsignedLong(uid); -} - -PyObject * -_PyInt_FromGid(gid_t gid) -{ - if (gid <= LONG_MAX) - return PyInt_FromLong(gid); - return PyLong_FromUnsignedLong(gid); -} - -int -_Py_Uid_Converter(PyObject *obj, void *p) -{ - int overflow; - long result; - if (PyFloat_Check(obj)) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float"); - return 0; - } - result = PyLong_AsLongAndOverflow(obj, &overflow); - if (overflow < 0) - goto OverflowDown; - if (!overflow && result == -1) { - /* error or -1 */ - if (PyErr_Occurred()) - return 0; - *(uid_t *)p = (uid_t)-1; - } - else { - /* unsigned uid_t */ - unsigned long uresult; - if (overflow > 0) { - uresult = PyLong_AsUnsignedLong(obj); - if (PyErr_Occurred()) { - if (PyErr_ExceptionMatches(PyExc_OverflowError)) - goto OverflowUp; - return 0; - } - } else { - if (result < 0) - goto OverflowDown; - uresult = result; - } - if (sizeof(uid_t) < sizeof(long) && - (unsigned long)(uid_t)uresult != uresult) - goto OverflowUp; - *(uid_t *)p = (uid_t)uresult; - } - return 1; - -OverflowDown: - PyErr_SetString(PyExc_OverflowError, - "user id is less than minimum"); - return 0; - -OverflowUp: - PyErr_SetString(PyExc_OverflowError, - "user id is greater than maximum"); - return 0; -} - -int -_Py_Gid_Converter(PyObject *obj, void *p) -{ - int overflow; - long result; - if (PyFloat_Check(obj)) { - PyErr_SetString(PyExc_TypeError, - "integer argument expected, got float"); - return 0; - } - result = PyLong_AsLongAndOverflow(obj, &overflow); - if (overflow < 0) - goto OverflowDown; - if (!overflow && result == -1) { - /* error or -1 */ - if (PyErr_Occurred()) - return 0; - *(gid_t *)p = (gid_t)-1; - } - else { - /* unsigned gid_t */ - unsigned long uresult; - if (overflow > 0) { - uresult = PyLong_AsUnsignedLong(obj); - if (PyErr_Occurred()) { - if (PyErr_ExceptionMatches(PyExc_OverflowError)) - goto OverflowUp; - return 0; - } - } else { - if (result < 0) - goto OverflowDown; - uresult = result; - } - if (sizeof(gid_t) < sizeof(long) && - (unsigned long)(gid_t)uresult != uresult) - goto OverflowUp; - *(gid_t *)p = (gid_t)uresult; - } - return 1; - -OverflowDown: - PyErr_SetString(PyExc_OverflowError, - "group id is less than minimum"); - return 0; - -OverflowUp: - PyErr_SetString(PyExc_OverflowError, - "group id is greater than maximum"); - return 0; -} -#endif /* MS_WINDOWS */ - - #if defined _MSC_VER && _MSC_VER >= 1400 /* Microsoft CRT in VS2005 and higher will verify that a filehandle is - * valid and raise an assertion if it isn't. + * valid and throw an assertion if it isn't. * Normally, an invalid fd is likely to be a C program error and therefore * an assertion can be useful, but it does contradict the POSIX standard * which for write(2) states: @@ -568,10 +441,9 @@ #endif /* Return a dictionary corresponding to the POSIX environment table */ -#if defined(WITH_NEXT_FRAMEWORK) || (defined(__APPLE__) && defined(Py_ENABLE_SHARED)) +#ifdef WITH_NEXT_FRAMEWORK /* On Darwin/MacOSX a shared library or framework has no access to -** environ directly, we must obtain it with _NSGetEnviron(). See also -** man environ(7). +** environ directly, we must obtain it with _NSGetEnviron(). */ #include static char **environ; @@ -591,7 +463,7 @@ d = PyDict_New(); if (d == NULL) return NULL; -#if defined(WITH_NEXT_FRAMEWORK) || (defined(__APPLE__) && defined(Py_ENABLE_SHARED)) +#ifdef WITH_NEXT_FRAMEWORK if (environ == NULL) environ = *_NSGetEnviron(); #endif @@ -1433,13 +1305,8 @@ PyStructSequence_SET_ITEM(v, 2, PyInt_FromLong((long)st->st_dev)); #endif PyStructSequence_SET_ITEM(v, 3, PyInt_FromLong((long)st->st_nlink)); -#if defined(MS_WINDOWS) - PyStructSequence_SET_ITEM(v, 4, PyInt_FromLong(0)); - PyStructSequence_SET_ITEM(v, 5, PyInt_FromLong(0)); -#else - PyStructSequence_SET_ITEM(v, 4, _PyInt_FromUid(st->st_uid)); - PyStructSequence_SET_ITEM(v, 5, _PyInt_FromGid(st->st_gid)); -#endif + PyStructSequence_SET_ITEM(v, 4, PyInt_FromLong((long)st->st_uid)); + PyStructSequence_SET_ITEM(v, 5, PyInt_FromLong((long)st->st_gid)); #ifdef HAVE_LARGEFILE_SUPPORT PyStructSequence_SET_ITEM(v, 6, PyLong_FromLongLong((PY_LONG_LONG)st->st_size)); @@ -2016,16 +1883,14 @@ posix_chown(PyObject *self, PyObject *args) { char *path = NULL; - uid_t uid; - gid_t gid; + long uid, gid; int res; - if (!PyArg_ParseTuple(args, "etO&O&:chown", + if (!PyArg_ParseTuple(args, "etll:chown", Py_FileSystemDefaultEncoding, &path, - _Py_Uid_Converter, &uid, - _Py_Gid_Converter, &gid)) + &uid, &gid)) return NULL; Py_BEGIN_ALLOW_THREADS - res = chown(path, uid, gid); + res = chown(path, (uid_t) uid, (gid_t) gid); Py_END_ALLOW_THREADS if (res < 0) return posix_error_with_allocated_filename(path); @@ -2045,15 +1910,12 @@ posix_fchown(PyObject *self, PyObject *args) { int fd; - uid_t uid; - gid_t gid; + long uid, gid; int res; - if (!PyArg_ParseTuple(args, "iO&O&:fchown", &fd, - _Py_Uid_Converter, &uid, - _Py_Gid_Converter, &gid)) + if (!PyArg_ParseTuple(args, "ill:chown", &fd, &uid, &gid)) return NULL; Py_BEGIN_ALLOW_THREADS - res = fchown(fd, uid, gid); + res = fchown(fd, (uid_t) uid, (gid_t) gid); Py_END_ALLOW_THREADS if (res < 0) return posix_error(); @@ -2071,16 +1933,14 @@ posix_lchown(PyObject *self, PyObject *args) { char *path = NULL; - uid_t uid; - gid_t gid; + long uid, gid; int res; - if (!PyArg_ParseTuple(args, "etO&O&:lchown", + if (!PyArg_ParseTuple(args, "etll:lchown", Py_FileSystemDefaultEncoding, &path, - _Py_Uid_Converter, &uid, - _Py_Gid_Converter, &gid)) + &uid, &gid)) return NULL; Py_BEGIN_ALLOW_THREADS - res = lchown(path, uid, gid); + res = lchown(path, (uid_t) uid, (gid_t) gid); Py_END_ALLOW_THREADS if (res < 0) return posix_error_with_allocated_filename(path); @@ -2096,9 +1956,7 @@ "getcwd() -> path\n\n\ Return a string representing the current working directory."); -#if (defined(__sun) && defined(__SVR4)) || \ - defined(__OpenBSD__) || \ - defined(__NetBSD__) +#if (defined(__sun) && defined(__SVR4)) || defined(__OpenBSD__) /* Issue 9185: getcwd() returns NULL/ERANGE indefinitely. */ static PyObject * posix_getcwd(PyObject *self, PyObject *noargs) @@ -3983,7 +3841,7 @@ static PyObject * posix_getegid(PyObject *self, PyObject *noargs) { - return _PyInt_FromGid(getegid()); + return PyInt_FromLong((long)getegid()); } #endif @@ -3996,7 +3854,7 @@ static PyObject * posix_geteuid(PyObject *self, PyObject *noargs) { - return _PyInt_FromUid(geteuid()); + return PyInt_FromLong((long)geteuid()); } #endif @@ -4009,7 +3867,7 @@ static PyObject * posix_getgid(PyObject *self, PyObject *noargs) { - return _PyInt_FromGid(getgid()); + return PyInt_FromLong((long)getgid()); } #endif @@ -4054,34 +3912,6 @@ gid_t* alt_grouplist = grouplist; int n; -#ifdef __APPLE__ - /* Issue #17557: As of OS X 10.8, getgroups(2) no longer raises EINVAL if - * there are more groups than can fit in grouplist. Therefore, on OS X - * always first call getgroups with length 0 to get the actual number - * of groups. - */ - n = getgroups(0, NULL); - if (n < 0) { - return posix_error(); - } else if (n <= MAX_GROUPS) { - /* groups will fit in existing array */ - alt_grouplist = grouplist; - } else { - alt_grouplist = PyMem_Malloc(n * sizeof(gid_t)); - if (alt_grouplist == NULL) { - errno = EINVAL; - return posix_error(); - } - } - - n = getgroups(n, alt_grouplist); - if (n == -1) { - if (alt_grouplist != grouplist) { - PyMem_Free(alt_grouplist); - } - return posix_error(); - } -#else n = getgroups(MAX_GROUPS, grouplist); if (n < 0) { if (errno == EINVAL) { @@ -4108,13 +3938,11 @@ return posix_error(); } } -#endif - result = PyList_New(n); if (result != NULL) { int i; for (i = 0; i < n; ++i) { - PyObject *o = _PyInt_FromGid(alt_grouplist[i]); + PyObject *o = PyInt_FromLong((long)alt_grouplist[i]); if (o == NULL) { Py_DECREF(result); result = NULL; @@ -4143,22 +3971,12 @@ posix_initgroups(PyObject *self, PyObject *args) { char *username; -#ifdef __APPLE__ - int gid; -#else - gid_t gid; -#endif - -#ifdef __APPLE__ - if (!PyArg_ParseTuple(args, "si:initgroups", &username, - &gid)) -#else - if (!PyArg_ParseTuple(args, "sO&:initgroups", &username, - _Py_Gid_Converter, &gid)) -#endif - return NULL; - - if (initgroups(username, gid) == -1) + long gid; + + if (!PyArg_ParseTuple(args, "sl:initgroups", &username, &gid)) + return NULL; + + if (initgroups(username, (gid_t) gid) == -1) return PyErr_SetFromErrno(PyExc_OSError); Py_INCREF(Py_None); @@ -4272,7 +4090,7 @@ static PyObject * posix_getuid(PyObject *self, PyObject *noargs) { - return _PyInt_FromUid(getuid()); + return PyInt_FromLong((long)getuid()); } #endif @@ -4408,7 +4226,6 @@ return NULL; attributes = GetFileAttributesA(path); - PyMem_Free(path); if (attributes == INVALID_FILE_ATTRIBUTES) Py_RETURN_FALSE; @@ -5919,9 +5736,15 @@ static PyObject * posix_setuid(PyObject *self, PyObject *args) { + long uid_arg; uid_t uid; - if (!PyArg_ParseTuple(args, "O&:setuid", _Py_Uid_Converter, &uid)) - return NULL; + if (!PyArg_ParseTuple(args, "l:setuid", &uid_arg)) + return NULL; + uid = uid_arg; + if (uid != uid_arg) { + PyErr_SetString(PyExc_OverflowError, "user id too big"); + return NULL; + } if (setuid(uid) < 0) return posix_error(); Py_INCREF(Py_None); @@ -5938,9 +5761,15 @@ static PyObject * posix_seteuid (PyObject *self, PyObject *args) { + long euid_arg; uid_t euid; - if (!PyArg_ParseTuple(args, "O&:seteuid", _Py_Uid_Converter, &euid)) - return NULL; + if (!PyArg_ParseTuple(args, "l", &euid_arg)) + return NULL; + euid = euid_arg; + if (euid != euid_arg) { + PyErr_SetString(PyExc_OverflowError, "user id too big"); + return NULL; + } if (seteuid(euid) < 0) { return posix_error(); } else { @@ -5958,9 +5787,15 @@ static PyObject * posix_setegid (PyObject *self, PyObject *args) { + long egid_arg; gid_t egid; - if (!PyArg_ParseTuple(args, "O&:setegid", _Py_Gid_Converter, &egid)) - return NULL; + if (!PyArg_ParseTuple(args, "l", &egid_arg)) + return NULL; + egid = egid_arg; + if (egid != egid_arg) { + PyErr_SetString(PyExc_OverflowError, "group id too big"); + return NULL; + } if (setegid(egid) < 0) { return posix_error(); } else { @@ -5978,11 +5813,23 @@ static PyObject * posix_setreuid (PyObject *self, PyObject *args) { + long ruid_arg, euid_arg; uid_t ruid, euid; - if (!PyArg_ParseTuple(args, "O&O&:setreuid", - _Py_Uid_Converter, &ruid, - _Py_Uid_Converter, &euid)) - return NULL; + if (!PyArg_ParseTuple(args, "ll", &ruid_arg, &euid_arg)) + return NULL; + if (ruid_arg == -1) + ruid = (uid_t)-1; /* let the compiler choose how -1 fits */ + else + ruid = ruid_arg; /* otherwise, assign from our long */ + if (euid_arg == -1) + euid = (uid_t)-1; + else + euid = euid_arg; + if ((euid_arg != -1 && euid != euid_arg) || + (ruid_arg != -1 && ruid != ruid_arg)) { + PyErr_SetString(PyExc_OverflowError, "user id too big"); + return NULL; + } if (setreuid(ruid, euid) < 0) { return posix_error(); } else { @@ -6000,11 +5847,23 @@ static PyObject * posix_setregid (PyObject *self, PyObject *args) { + long rgid_arg, egid_arg; gid_t rgid, egid; - if (!PyArg_ParseTuple(args, "O&O&:setregid", - _Py_Gid_Converter, &rgid, - _Py_Gid_Converter, &egid)) - return NULL; + if (!PyArg_ParseTuple(args, "ll", &rgid_arg, &egid_arg)) + return NULL; + if (rgid_arg == -1) + rgid = (gid_t)-1; /* let the compiler choose how -1 fits */ + else + rgid = rgid_arg; /* otherwise, assign from our long */ + if (egid_arg == -1) + egid = (gid_t)-1; + else + egid = egid_arg; + if ((egid_arg != -1 && egid != egid_arg) || + (rgid_arg != -1 && rgid != rgid_arg)) { + PyErr_SetString(PyExc_OverflowError, "group id too big"); + return NULL; + } if (setregid(rgid, egid) < 0) { return posix_error(); } else { @@ -6022,9 +5881,15 @@ static PyObject * posix_setgid(PyObject *self, PyObject *args) { + long gid_arg; gid_t gid; - if (!PyArg_ParseTuple(args, "O&:setgid", _Py_Gid_Converter, &gid)) - return NULL; + if (!PyArg_ParseTuple(args, "l:setgid", &gid_arg)) + return NULL; + gid = gid_arg; + if (gid != gid_arg) { + PyErr_SetString(PyExc_OverflowError, "group id too big"); + return NULL; + } if (setgid(gid) < 0) return posix_error(); Py_INCREF(Py_None); @@ -6057,13 +5922,35 @@ elem = PySequence_GetItem(groups, i); if (!elem) return NULL; - if (!PyInt_Check(elem) && !PyLong_Check(elem)) { - PyErr_SetString(PyExc_TypeError, - "groups must be integers"); - Py_DECREF(elem); - return NULL; + if (!PyInt_Check(elem)) { + if (!PyLong_Check(elem)) { + PyErr_SetString(PyExc_TypeError, + "groups must be integers"); + Py_DECREF(elem); + return NULL; + } else { + unsigned long x = PyLong_AsUnsignedLong(elem); + if (PyErr_Occurred()) { + PyErr_SetString(PyExc_TypeError, + "group id too big"); + Py_DECREF(elem); + return NULL; + } + grouplist[i] = x; + /* read back to see if it fits in gid_t */ + if (grouplist[i] != x) { + PyErr_SetString(PyExc_TypeError, + "group id too big"); + Py_DECREF(elem); + return NULL; + } + } } else { - if (!_Py_Gid_Converter(elem, &grouplist[i])) { + long x = PyInt_AsLong(elem); + grouplist[i] = x; + if (grouplist[i] != x) { + PyErr_SetString(PyExc_TypeError, + "group id too big"); Py_DECREF(elem); return NULL; } @@ -6581,12 +6468,8 @@ "close(fd)\n\n\ Close a file descriptor (for low level IO)."); -/* -The underscore at end of function name avoids a name clash with the libc -function posix_close. -*/ -static PyObject * -posix_close_(PyObject *self, PyObject *args) +static PyObject * +posix_close(PyObject *self, PyObject *args) { int fd, res; if (!PyArg_ParseTuple(args, "i:close", &fd)) @@ -6667,8 +6550,7 @@ PyDoc_STRVAR(posix_lseek__doc__, "lseek(fd, pos, how) -> newpos\n\n\ -Set the current position of a file descriptor.\n\ -Return the new cursor position in bytes, starting from the beginning."); +Set the current position of a file descriptor."); static PyObject * posix_lseek(PyObject *self, PyObject *args) @@ -6849,35 +6731,8 @@ PyMem_FREE(mode); return NULL; } - if (!_PyVerify_fd(fd)) { - PyMem_FREE(mode); + if (!_PyVerify_fd(fd)) return posix_error(); - } -#if defined(HAVE_FSTAT) && defined(S_IFDIR) && defined(EISDIR) - { - struct stat buf; - const char *msg; - PyObject *exc; - if (fstat(fd, &buf) == 0 && S_ISDIR(buf.st_mode)) { - PyMem_FREE(mode); - msg = strerror(EISDIR); - exc = PyObject_CallFunction(PyExc_IOError, "(isO)", - EISDIR, msg, ""); - if (exc) { - PyErr_SetObject(PyExc_IOError, exc); - Py_DECREF(exc); - } - return NULL; - } - } -#endif - /* The dummy filename used here must be kept in sync with the value - tested against in gzip.GzipFile.__init__() - see issue #13781. */ - f = PyFile_FromFile(NULL, "", orgmode, fclose); - if (f == NULL) { - PyMem_FREE(mode); - return NULL; - } Py_BEGIN_ALLOW_THREADS #if !defined(MS_WINDOWS) && defined(HAVE_FCNTL_H) if (mode[0] == 'a') { @@ -6900,9 +6755,9 @@ PyMem_FREE(mode); if (fp == NULL) return posix_error(); - /* We now know we will succeed, so initialize the file object. */ - ((PyFileObject *)f)->f_fp = fp; - PyFile_SetBufSize(f, bufsize); + f = PyFile_FromFile(fp, "", orgmode, fclose); + if (f != NULL) + PyFile_SetBufSize(f, bufsize); return f; } @@ -8681,35 +8536,117 @@ } #endif -PyDoc_STRVAR(posix_urandom__doc__, +#ifdef MS_WINDOWS + +PyDoc_STRVAR(win32_urandom__doc__, "urandom(n) -> str\n\n\ -Return n random bytes suitable for cryptographic use."); - -static PyObject * -posix_urandom(PyObject *self, PyObject *args) -{ - Py_ssize_t size; - PyObject *result; - int ret; - - /* Read arguments */ - if (!PyArg_ParseTuple(args, "n:urandom", &size)) - return NULL; - if (size < 0) +Return a string of n random bytes suitable for cryptographic use."); + +typedef BOOL (WINAPI *CRYPTACQUIRECONTEXTA)(HCRYPTPROV *phProv,\ + LPCSTR pszContainer, LPCSTR pszProvider, DWORD dwProvType,\ + DWORD dwFlags ); +typedef BOOL (WINAPI *CRYPTGENRANDOM)(HCRYPTPROV hProv, DWORD dwLen,\ + BYTE *pbBuffer ); + +static CRYPTGENRANDOM pCryptGenRandom = NULL; +/* This handle is never explicitly released. Instead, the operating + system will release it when the process terminates. */ +static HCRYPTPROV hCryptProv = 0; + +static PyObject* +win32_urandom(PyObject *self, PyObject *args) +{ + int howMany; + PyObject* result; + + /* Read arguments */ + if (! PyArg_ParseTuple(args, "i:urandom", &howMany)) + return NULL; + if (howMany < 0) return PyErr_Format(PyExc_ValueError, "negative argument not allowed"); - result = PyBytes_FromStringAndSize(NULL, size); - if (result == NULL) - return NULL; - - ret = _PyOS_URandom(PyBytes_AS_STRING(result), - PyBytes_GET_SIZE(result)); - if (ret == -1) { - Py_DECREF(result); - return NULL; + + if (hCryptProv == 0) { + HINSTANCE hAdvAPI32 = NULL; + CRYPTACQUIRECONTEXTA pCryptAcquireContext = NULL; + + /* Obtain handle to the DLL containing CryptoAPI + This should not fail */ + hAdvAPI32 = GetModuleHandle("advapi32.dll"); + if(hAdvAPI32 == NULL) + return win32_error("GetModuleHandle", NULL); + + /* Obtain pointers to the CryptoAPI functions + This will fail on some early versions of Win95 */ + pCryptAcquireContext = (CRYPTACQUIRECONTEXTA)GetProcAddress( + hAdvAPI32, + "CryptAcquireContextA"); + if (pCryptAcquireContext == NULL) + return PyErr_Format(PyExc_NotImplementedError, + "CryptAcquireContextA not found"); + + pCryptGenRandom = (CRYPTGENRANDOM)GetProcAddress( + hAdvAPI32, "CryptGenRandom"); + if (pCryptGenRandom == NULL) + return PyErr_Format(PyExc_NotImplementedError, + "CryptGenRandom not found"); + + /* Acquire context */ + if (! pCryptAcquireContext(&hCryptProv, NULL, NULL, + PROV_RSA_FULL, CRYPT_VERIFYCONTEXT)) + return win32_error("CryptAcquireContext", NULL); + } + + /* Allocate bytes */ + result = PyString_FromStringAndSize(NULL, howMany); + if (result != NULL) { + /* Get random data */ + memset(PyString_AS_STRING(result), 0, howMany); /* zero seed */ + if (! pCryptGenRandom(hCryptProv, howMany, (unsigned char*) + PyString_AS_STRING(result))) { + Py_DECREF(result); + return win32_error("CryptGenRandom", NULL); + } } return result; } +#endif + +#ifdef __VMS +/* Use openssl random routine */ +#include +PyDoc_STRVAR(vms_urandom__doc__, +"urandom(n) -> str\n\n\ +Return a string of n random bytes suitable for cryptographic use."); + +static PyObject* +vms_urandom(PyObject *self, PyObject *args) +{ + int howMany; + PyObject* result; + + /* Read arguments */ + if (! PyArg_ParseTuple(args, "i:urandom", &howMany)) + return NULL; + if (howMany < 0) + return PyErr_Format(PyExc_ValueError, + "negative argument not allowed"); + + /* Allocate bytes */ + result = PyString_FromStringAndSize(NULL, howMany); + if (result != NULL) { + /* Get random data */ + if (RAND_pseudo_bytes((unsigned char*) + PyString_AS_STRING(result), + howMany) < 0) { + Py_DECREF(result); + return PyErr_Format(PyExc_ValueError, + "RAND_pseudo_bytes"); + } + } + return result; +} +#endif #ifdef HAVE_SETRESUID PyDoc_STRVAR(posix_setresuid__doc__, @@ -8719,11 +8656,9 @@ static PyObject* posix_setresuid (PyObject *self, PyObject *args) { - uid_t ruid, euid, suid; - if (!PyArg_ParseTuple(args, "O&O&O&:setresuid", - _Py_Uid_Converter, &ruid, - _Py_Uid_Converter, &euid, - _Py_Uid_Converter, &suid)) + /* We assume uid_t is no larger than a long. */ + long ruid, euid, suid; + if (!PyArg_ParseTuple(args, "lll", &ruid, &euid, &suid)) return NULL; if (setresuid(ruid, euid, suid) < 0) return posix_error(); @@ -8739,11 +8674,9 @@ static PyObject* posix_setresgid (PyObject *self, PyObject *args) { - gid_t rgid, egid, sgid; - if (!PyArg_ParseTuple(args, "O&O&O&:setresgid", - _Py_Gid_Converter, &rgid, - _Py_Gid_Converter, &egid, - _Py_Gid_Converter, &sgid)) + /* We assume uid_t is no larger than a long. */ + long rgid, egid, sgid; + if (!PyArg_ParseTuple(args, "lll", &rgid, &egid, &sgid)) return NULL; if (setresgid(rgid, egid, sgid) < 0) return posix_error(); @@ -8760,11 +8693,14 @@ posix_getresuid (PyObject *self, PyObject *noargs) { uid_t ruid, euid, suid; + long l_ruid, l_euid, l_suid; if (getresuid(&ruid, &euid, &suid) < 0) return posix_error(); - return Py_BuildValue("(NNN)", _PyInt_FromUid(ruid), - _PyInt_FromUid(euid), - _PyInt_FromUid(suid)); + /* Force the values into long's as we don't know the size of uid_t. */ + l_ruid = ruid; + l_euid = euid; + l_suid = suid; + return Py_BuildValue("(lll)", l_ruid, l_euid, l_suid); } #endif @@ -8777,11 +8713,14 @@ posix_getresgid (PyObject *self, PyObject *noargs) { uid_t rgid, egid, sgid; + long l_rgid, l_egid, l_sgid; if (getresgid(&rgid, &egid, &sgid) < 0) return posix_error(); - return Py_BuildValue("(NNN)", _PyInt_FromGid(rgid), - _PyInt_FromGid(egid), - _PyInt_FromGid(sgid)); + /* Force the values into long's as we don't know the size of uid_t. */ + l_rgid = rgid; + l_egid = egid; + l_sgid = sgid; + return Py_BuildValue("(lll)", l_rgid, l_egid, l_sgid); } #endif @@ -8990,7 +8929,7 @@ {"tcsetpgrp", posix_tcsetpgrp, METH_VARARGS, posix_tcsetpgrp__doc__}, #endif /* HAVE_TCSETPGRP */ {"open", posix_open, METH_VARARGS, posix_open__doc__}, - {"close", posix_close_, METH_VARARGS, posix_close__doc__}, + {"close", posix_close, METH_VARARGS, posix_close__doc__}, {"closerange", posix_closerange, METH_VARARGS, posix_closerange__doc__}, {"dup", posix_dup, METH_VARARGS, posix_dup__doc__}, {"dup2", posix_dup2, METH_VARARGS, posix_dup2__doc__}, @@ -9094,6 +9033,12 @@ #ifdef HAVE_GETLOADAVG {"getloadavg", posix_getloadavg, METH_NOARGS, posix_getloadavg__doc__}, #endif + #ifdef MS_WINDOWS + {"urandom", win32_urandom, METH_VARARGS, win32_urandom__doc__}, + #endif + #ifdef __VMS + {"urandom", vms_urandom, METH_VARARGS, vms_urandom__doc__}, + #endif #ifdef HAVE_SETRESUID {"setresuid", posix_setresuid, METH_VARARGS, posix_setresuid__doc__}, #endif @@ -9106,7 +9051,7 @@ #ifdef HAVE_GETRESGID {"getresgid", posix_getresgid, METH_NOARGS, posix_getresgid__doc__}, #endif - {"urandom", posix_urandom, METH_VARARGS, posix_urandom__doc__}, + {NULL, NULL} /* Sentinel */ }; diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/posixmodule.h --- a/Modules/posixmodule.h Sat Jul 19 16:34:33 2014 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,25 +0,0 @@ -/* Declarations shared between the different POSIX-related modules */ - -#ifndef Py_POSIXMODULE_H -#define Py_POSIXMODULE_H -#ifdef __cplusplus -extern "C" { -#endif - -#ifdef HAVE_SYS_TYPES_H -#include -#endif - -#ifndef Py_LIMITED_API -#ifndef MS_WINDOWS -PyAPI_FUNC(PyObject *) _PyInt_FromUid(uid_t); -PyAPI_FUNC(PyObject *) _PyInt_FromGid(gid_t); -PyAPI_FUNC(int) _Py_Uid_Converter(PyObject *, void *); -PyAPI_FUNC(int) _Py_Gid_Converter(PyObject *, void *); -#endif /* MS_WINDOWS */ -#endif - -#ifdef __cplusplus -} -#endif -#endif /* !Py_POSIXMODULE_H */ diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/pwdmodule.c --- a/Modules/pwdmodule.c Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/pwdmodule.c Sun Jul 20 10:52:46 2014 -0400 @@ -3,8 +3,8 @@ #include "Python.h" #include "structseq.h" -#include "posixmodule.h" +#include #include static PyStructSequence_Field struct_pwd_type_fields[] = { @@ -73,8 +73,8 @@ #else SETS(setIndex++, p->pw_passwd); #endif - PyStructSequence_SET_ITEM(v, setIndex++, _PyInt_FromUid(p->pw_uid)); - PyStructSequence_SET_ITEM(v, setIndex++, _PyInt_FromGid(p->pw_gid)); + SETI(setIndex++, p->pw_uid); + SETI(setIndex++, p->pw_gid); #ifdef __VMS SETS(setIndex++, ""); #else @@ -103,21 +103,13 @@ static PyObject * pwd_getpwuid(PyObject *self, PyObject *args) { - uid_t uid; + unsigned int uid; struct passwd *p; - if (!PyArg_ParseTuple(args, "O&:getpwuid", _Py_Uid_Converter, &uid)) { - if (PyErr_ExceptionMatches(PyExc_OverflowError)) - PyErr_Format(PyExc_KeyError, - "getpwuid(): uid not found"); + if (!PyArg_ParseTuple(args, "I:getpwuid", &uid)) return NULL; - } if ((p = getpwuid(uid)) == NULL) { - if (uid < 0) - PyErr_Format(PyExc_KeyError, - "getpwuid(): uid not found: %ld", (long)uid); - else - PyErr_Format(PyExc_KeyError, - "getpwuid(): uid not found: %lu", (unsigned long)uid); + PyErr_Format(PyExc_KeyError, + "getpwuid(): uid not found: %d", uid); return NULL; } return mkpwent(p); diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/pyexpat.c --- a/Modules/pyexpat.c Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/pyexpat.c Sun Jul 20 10:52:46 2014 -0400 @@ -976,7 +976,7 @@ void *buf = XML_GetBuffer(self->itself, BUF_SIZE); if (buf == NULL) { Py_XDECREF(readmethod); - return get_parse_result(self, 0); + return PyErr_NoMemory(); } bytes_read = readinst(buf, BUF_SIZE, readmethod); @@ -1174,16 +1174,13 @@ xmlparse_UseForeignDTD(xmlparseobject *self, PyObject *args) { PyObject *flagobj = NULL; - int flag = 1; + XML_Bool flag = XML_TRUE; enum XML_Error rc; - if (!PyArg_ParseTuple(args, "|O:UseForeignDTD", &flagobj)) + if (!PyArg_UnpackTuple(args, "UseForeignDTD", 0, 1, &flagobj)) return NULL; - if (flagobj != NULL) { - flag = PyObject_IsTrue(flagobj); - if (flag < 0) - return NULL; - } - rc = XML_UseForeignDTD(self->itself, flag ? XML_TRUE : XML_FALSE); + if (flagobj != NULL) + flag = PyObject_IsTrue(flagobj) ? XML_TRUE : XML_FALSE; + rc = XML_UseForeignDTD(self->itself, flag); if (rc != XML_ERROR_NONE) { return set_error(self, rc); } @@ -1252,13 +1249,6 @@ if (_u_string == NULL) return result; - if (PyUnicode_GET_SIZE(_u_string) != 256) { - Py_DECREF(_u_string); - PyErr_SetString(PyExc_ValueError, - "multi-byte encodings are not supported"); - return result; - } - for (i = 0; i < 256; i++) { /* Stupid to access directly, but fast */ Py_UNICODE c = _u_string->str[i]; @@ -1312,13 +1302,6 @@ else { self->itself = XML_ParserCreate(encoding); } -#if ((XML_MAJOR_VERSION >= 2) && (XML_MINOR_VERSION >= 1)) || defined(XML_HAS_SET_HASH_SALT) - /* This feature was added upstream in libexpat 2.1.0. Our expat copy - * has a backport of this feature where we also define XML_HAS_SET_HASH_SALT - * to indicate that we can still use it. */ - XML_SetHashSalt(self->itself, - (unsigned long)_Py_HashSecret.prefix); -#endif self->intern = intern; Py_XINCREF(self->intern); #ifdef Py_TPFLAGS_HAVE_GC @@ -1559,10 +1542,7 @@ return -1; } if (strcmp(name, "buffer_text") == 0) { - int b = PyObject_IsTrue(v); - if (b < 0) - return -1; - if (b) { + if (PyObject_IsTrue(v)) { if (self->buffer == NULL) { self->buffer = malloc(self->buffer_size); if (self->buffer == NULL) { @@ -1581,39 +1561,39 @@ return 0; } if (strcmp(name, "namespace_prefixes") == 0) { - int b = PyObject_IsTrue(v); - if (b < 0) - return -1; - self->ns_prefixes = b; + if (PyObject_IsTrue(v)) + self->ns_prefixes = 1; + else + self->ns_prefixes = 0; XML_SetReturnNSTriplet(self->itself, self->ns_prefixes); return 0; } if (strcmp(name, "ordered_attributes") == 0) { - int b = PyObject_IsTrue(v); - if (b < 0) - return -1; - self->ordered_attributes = b; + if (PyObject_IsTrue(v)) + self->ordered_attributes = 1; + else + self->ordered_attributes = 0; return 0; } if (strcmp(name, "returns_unicode") == 0) { - int b = PyObject_IsTrue(v); - if (b < 0) - return -1; + if (PyObject_IsTrue(v)) { #ifndef Py_USING_UNICODE - if (b) { PyErr_SetString(PyExc_ValueError, "Unicode support not available"); return -1; +#else + self->returns_unicode = 1; +#endif } -#endif - self->returns_unicode = b; + else + self->returns_unicode = 0; return 0; } if (strcmp(name, "specified_attributes") == 0) { - int b = PyObject_IsTrue(v); - if (b < 0) - return -1; - self->specified_attributes = b; + if (PyObject_IsTrue(v)) + self->specified_attributes = 1; + else + self->specified_attributes = 0; return 0; } diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/readline.c --- a/Modules/readline.c Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/readline.c Sun Jul 20 10:52:46 2014 -0400 @@ -54,16 +54,14 @@ * with the "real" readline and cannot be detected at compile-time, * hence we use a runtime check to detect if we're using libedit * - * Currently there is one known API incompatibility: + * Currently there is one know API incompatibility: * - 'get_history' has a 1-based index with GNU readline, and a 0-based - * index with older versions of libedit's emulation. + * index with libedit's emulation. * - Note that replace_history and remove_history use a 0-based index - * with both implementations. + * with both implementation. */ static int using_libedit_emulation = 0; static const char libedit_version_tag[] = "EditLine wrapper"; - -static int libedit_history_start = 0; #endif /* __APPLE__ */ static void @@ -71,10 +69,6 @@ int num_matches, int max_length); -/* Memory allocated for rl_completer_word_break_characters - (see issue #17289 for the motivation). */ -static char *completer_word_break_characters; - /* Exported function to send one line to readline's init file parser */ static PyObject * @@ -206,7 +200,8 @@ if (!PyArg_ParseTuple(args, buf, &function)) return NULL; if (function == Py_None) { - Py_CLEAR(*hook_var); + Py_XDECREF(*hook_var); + *hook_var = NULL; } else if (PyCallable_Check(function)) { PyObject *tmp = *hook_var; @@ -349,20 +344,12 @@ { char *break_chars; - if (!PyArg_ParseTuple(args, "s:set_completer_delims", &break_chars)) { + if(!PyArg_ParseTuple(args, "s:set_completer_delims", &break_chars)) { return NULL; } - /* Keep a reference to the allocated memory in the module state in case - some other module modifies rl_completer_word_break_characters - (see issue #17289). */ - free(completer_word_break_characters); - completer_word_break_characters = strdup(break_chars); - if (completer_word_break_characters) { - rl_completer_word_break_characters = completer_word_break_characters; - Py_RETURN_NONE; - } - else - return PyErr_NoMemory(); + free((void*)rl_completer_word_break_characters); + rl_completer_word_break_characters = strdup(break_chars); + Py_RETURN_NONE; } PyDoc_STRVAR(doc_set_completer_delims, @@ -556,21 +543,21 @@ return NULL; #ifdef __APPLE__ if (using_libedit_emulation) { - /* Older versions of libedit's readline emulation - * use 0-based indexes, while readline and newer - * versions of libedit use 1-based indexes. + /* Libedit emulation uses 0-based indexes, + * the real one uses 1-based indexes, + * adjust the index to ensure that Python + * code doesn't have to worry about the + * difference. */ int length = _py_get_history_length(); - - idx = idx - 1 + libedit_history_start; + idx --; /* * Apple's readline emulation crashes when * the index is out of range, therefore * test for that and fail gracefully. */ - if (idx < (0 + libedit_history_start) - || idx >= (length + libedit_history_start)) { + if (idx < 0 || idx >= length) { Py_RETURN_NONE; } } @@ -749,22 +736,14 @@ } static int -#if defined(_RL_FUNCTION_TYPEDEF) on_startup_hook(void) -#else -on_startup_hook() -#endif { return on_hook(startup_hook); } #ifdef HAVE_RL_PRE_INPUT_HOOK static int -#if defined(_RL_FUNCTION_TYPEDEF) on_pre_input_hook(void) -#else -on_pre_input_hook() -#endif { return on_hook(pre_input_hook); } @@ -859,7 +838,7 @@ * before calling the normal completer */ static char ** -flex_complete(const char *text, int start, int end) +flex_complete(char *text, int start, int end) { #ifdef HAVE_RL_COMPLETION_APPEND_CHARACTER rl_completion_append_character ='\0'; @@ -892,17 +871,6 @@ */ if (using_libedit_emulation) rl_initialize(); - - /* Detect if libedit's readline emulation uses 0-based - * indexing or 1-based indexing. - */ - add_history("1"); - if (history_get(1) == NULL) { - libedit_history_start = 0; - } else { - libedit_history_start = 1; - } - clear_history(); #endif /* __APPLE__ */ using_history(); @@ -918,15 +886,14 @@ rl_bind_key_in_map ('\t', rl_complete, emacs_meta_keymap); rl_bind_key_in_map ('\033', rl_complete, emacs_meta_keymap); /* Set our hook functions */ - rl_startup_hook = on_startup_hook; + rl_startup_hook = (Function *)on_startup_hook; #ifdef HAVE_RL_PRE_INPUT_HOOK - rl_pre_input_hook = on_pre_input_hook; + rl_pre_input_hook = (Function *)on_pre_input_hook; #endif /* Set our completion function */ - rl_attempted_completion_function = flex_complete; + rl_attempted_completion_function = (CPPFunction *)flex_complete; /* Set Python word break characters */ - completer_word_break_characters = - rl_completer_word_break_characters = + rl_completer_word_break_characters = strdup(" \t\n`~!@#$%^&*()-=+[{]}\\|;:'\",<>/?"); /* All nonalphanums except '.' */ @@ -939,7 +906,7 @@ */ #ifdef __APPLE__ if (using_libedit_emulation) - rl_read_init_file(NULL); + rl_read_init_file(NULL); else #endif /* __APPLE__ */ rl_initialize(); @@ -1110,8 +1077,11 @@ if (length > 0) #ifdef __APPLE__ if (using_libedit_emulation) { - /* handle older 0-based or newer 1-based indexing */ - line = history_get(length + libedit_history_start - 1)->line; + /* + * Libedit's emulation uses 0-based indexes, + * the real readline uses 1-based indexes. + */ + line = history_get(length - 1)->line; } else #endif /* __APPLE__ */ line = history_get(length)->line; @@ -1167,6 +1137,8 @@ if (m == NULL) return; + + PyOS_ReadlineFunctionPointer = call_readline; setup_readline(); } diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/resource.c --- a/Modules/resource.c Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/resource.c Sun Jul 20 10:52:46 2014 -0400 @@ -145,9 +145,10 @@ { struct rlimit rl; int resource; - PyObject *limits, *curobj, *maxobj; + PyObject *curobj, *maxobj; - if (!PyArg_ParseTuple(args, "iO:setrlimit", &resource, &limits)) + if (!PyArg_ParseTuple(args, "i(OO):setrlimit", + &resource, &curobj, &maxobj)) return NULL; if (resource < 0 || resource >= RLIM_NLIMITS) { @@ -156,36 +157,23 @@ return NULL; } - limits = PySequence_Tuple(limits); - if (!limits) - /* Here limits is a borrowed reference */ - return NULL; - - if (PyTuple_GET_SIZE(limits) != 2) { - PyErr_SetString(PyExc_ValueError, - "expected a tuple of 2 integers"); - goto error; - } - curobj = PyTuple_GET_ITEM(limits, 0); - maxobj = PyTuple_GET_ITEM(limits, 1); - #if !defined(HAVE_LARGEFILE_SUPPORT) rl.rlim_cur = PyInt_AsLong(curobj); if (rl.rlim_cur == (rlim_t)-1 && PyErr_Occurred()) - goto error; + return NULL; rl.rlim_max = PyInt_AsLong(maxobj); if (rl.rlim_max == (rlim_t)-1 && PyErr_Occurred()) - goto error; + return NULL; #else /* The limits are probably bigger than a long */ rl.rlim_cur = PyLong_Check(curobj) ? PyLong_AsLongLong(curobj) : PyInt_AsLong(curobj); if (rl.rlim_cur == (rlim_t)-1 && PyErr_Occurred()) - goto error; + return NULL; rl.rlim_max = PyLong_Check(maxobj) ? PyLong_AsLongLong(maxobj) : PyInt_AsLong(maxobj); if (rl.rlim_max == (rlim_t)-1 && PyErr_Occurred()) - goto error; + return NULL; #endif rl.rlim_cur = rl.rlim_cur & RLIM_INFINITY; @@ -199,15 +187,10 @@ "not allowed to raise maximum limit"); else PyErr_SetFromErrno(ResourceError); - goto error; + return NULL; } - Py_DECREF(limits); Py_INCREF(Py_None); return Py_None; - - error: - Py_DECREF(limits); - return NULL; } static PyObject * diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/selectmodule.c --- a/Modules/selectmodule.c Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/selectmodule.c Sun Jul 20 10:52:46 2014 -0400 @@ -71,7 +71,8 @@ { int i; for (i = 0; i < FD_SETSIZE + 1 && fd2obj[i].sentinel >= 0; i++) { - Py_CLEAR(fd2obj[i].obj); + Py_XDECREF(fd2obj[i].obj); + fd2obj[i].obj = NULL; } fd2obj[0].sentinel = -1; } @@ -86,6 +87,7 @@ int i; int max = -1; int index = 0; + int len = -1; PyObject* fast_seq = NULL; PyObject* o = NULL; @@ -96,7 +98,9 @@ if (!fast_seq) return -1; - for (i = 0; i < PySequence_Fast_GET_SIZE(fast_seq); i++) { + len = PySequence_Fast_GET_SIZE(fast_seq); + + for (i = 0; i < len; i++) { SOCKET v; /* any intervening fileno() calls could decr this refcnt */ @@ -317,7 +321,6 @@ int ufd_uptodate; int ufd_len; struct pollfd *ufds; - int poll_running; } pollObject; static PyTypeObject poll_Type; @@ -343,35 +346,14 @@ i = pos = 0; while (PyDict_Next(self->dict, &pos, &key, &value)) { - assert(i < self->ufd_len); - /* Never overflow */ - self->ufds[i].fd = (int)PyInt_AsLong(key); - self->ufds[i].events = (short)(unsigned short)PyInt_AsLong(value); + self->ufds[i].fd = PyInt_AsLong(key); + self->ufds[i].events = (short)PyInt_AsLong(value); i++; } - assert(i == self->ufd_len); self->ufd_uptodate = 1; return 1; } -static int -ushort_converter(PyObject *obj, void *ptr) -{ - unsigned long uval; - - uval = PyLong_AsUnsignedLong(obj); - if (uval == (unsigned long)-1 && PyErr_Occurred()) - return 0; - if (uval > USHRT_MAX) { - PyErr_SetString(PyExc_OverflowError, - "Python int too large for C unsigned short"); - return 0; - } - - *(unsigned short *)ptr = Py_SAFE_DOWNCAST(uval, unsigned long, unsigned short); - return 1; -} - PyDoc_STRVAR(poll_register_doc, "register(fd [, eventmask] ) -> None\n\n\ Register a file descriptor with the polling object.\n\ @@ -383,12 +365,12 @@ poll_register(pollObject *self, PyObject *args) { PyObject *o, *key, *value; - int fd; - unsigned short events = POLLIN | POLLPRI | POLLOUT; + int fd, events = POLLIN | POLLPRI | POLLOUT; int err; - if (!PyArg_ParseTuple(args, "O|O&:register", &o, ushort_converter, &events)) + if (!PyArg_ParseTuple(args, "O|i:register", &o, &events)) { return NULL; + } fd = PyObject_AsFileDescriptor(o); if (fd == -1) return NULL; @@ -426,12 +408,12 @@ poll_modify(pollObject *self, PyObject *args) { PyObject *o, *key, *value; - int fd; - unsigned short events; + int fd, events; int err; - if (!PyArg_ParseTuple(args, "OO&:modify", &o, ushort_converter, &events)) + if (!PyArg_ParseTuple(args, "Oi:modify", &o, &events)) { return NULL; + } fd = PyObject_AsFileDescriptor(o); if (fd == -1) return NULL; @@ -524,33 +506,22 @@ tout = PyNumber_Int(tout); if (!tout) return NULL; - timeout = _PyInt_AsInt(tout); + timeout = PyInt_AsLong(tout); Py_DECREF(tout); if (timeout == -1 && PyErr_Occurred()) return NULL; } - /* Avoid concurrent poll() invocation, issue 8865 */ - if (self->poll_running) { - PyErr_SetString(PyExc_RuntimeError, - "concurrent poll() invocation"); - return NULL; - } - /* Ensure the ufd array is up to date */ if (!self->ufd_uptodate) if (update_ufd_array(self) == 0) return NULL; - self->poll_running = 1; - /* call poll() */ Py_BEGIN_ALLOW_THREADS poll_result = poll(self->ufds, self->ufd_len, timeout); Py_END_ALLOW_THREADS - self->poll_running = 0; - if (poll_result < 0) { PyErr_SetFromErrno(SelectError); return NULL; @@ -627,7 +598,6 @@ array pointed to by ufds matches the contents of the dictionary. */ self->ufd_uptodate = 0; self->ufds = NULL; - self->poll_running = 0; self->dict = PyDict_New(); if (self->dict == NULL) { Py_DECREF(self); @@ -1232,23 +1202,6 @@ # error uintptr_t does not match int, long, or long long! #endif -/* - * kevent is not standard and its members vary across BSDs. - */ -#if !defined(__OpenBSD__) -# define IDENT_TYPE T_UINTPTRT -# define IDENT_CAST Py_intptr_t -# define DATA_TYPE T_INTPTRT -# define DATA_FMT_UNIT INTPTRT_FMT_UNIT -# define IDENT_AsType PyLong_AsUintptr_t -#else -# define IDENT_TYPE T_UINT -# define IDENT_CAST int -# define DATA_TYPE T_INT -# define DATA_FMT_UNIT "i" -# define IDENT_AsType PyLong_AsUnsignedLong -#endif - /* Unfortunately, we can't store python objects in udata, because * kevents in the kernel can be removed without warning, which would * forever lose the refcount on the object stored with it. @@ -1256,11 +1209,11 @@ #define KQ_OFF(x) offsetof(kqueue_event_Object, x) static struct PyMemberDef kqueue_event_members[] = { - {"ident", IDENT_TYPE, KQ_OFF(e.ident)}, + {"ident", T_UINTPTRT, KQ_OFF(e.ident)}, {"filter", T_SHORT, KQ_OFF(e.filter)}, {"flags", T_USHORT, KQ_OFF(e.flags)}, {"fflags", T_UINT, KQ_OFF(e.fflags)}, - {"data", DATA_TYPE, KQ_OFF(e.data)}, + {"data", T_INTPTRT, KQ_OFF(e.data)}, {"udata", T_UINTPTRT, KQ_OFF(e.udata)}, {NULL} /* Sentinel */ }; @@ -1286,7 +1239,7 @@ PyObject *pfd; static char *kwlist[] = {"ident", "filter", "flags", "fflags", "data", "udata", NULL}; - static char *fmt = "O|hHI" DATA_FMT_UNIT UINTPTRT_FMT_UNIT ":kevent"; + static char *fmt = "O|hhi" INTPTRT_FMT_UNIT UINTPTRT_FMT_UNIT ":kevent"; EV_SET(&(self->e), 0, EVFILT_READ, EV_ADD, 0, 0, 0); /* defaults */ @@ -1296,12 +1249,8 @@ return -1; } - if (PyLong_Check(pfd) -#if IDENT_TYPE == T_UINT - && PyLong_AsUnsignedLong(pfd) <= UINT_MAX -#endif - ) { - self->e.ident = IDENT_AsType(pfd); + if (PyLong_Check(pfd)) { + self->e.ident = PyLong_AsUintptr_t(pfd); } else { self->e.ident = PyObject_AsFileDescriptor(pfd); @@ -1329,10 +1278,10 @@ Py_TYPE(s)->tp_name, Py_TYPE(o)->tp_name); return NULL; } - if (((result = (IDENT_CAST)(s->e.ident - o->e.ident)) == 0) && + if (((result = s->e.ident - o->e.ident) == 0) && ((result = s->e.filter - o->e.filter) == 0) && ((result = s->e.flags - o->e.flags) == 0) && - ((result = (int)(s->e.fflags - o->e.fflags)) == 0) && + ((result = s->e.fflags - o->e.fflags) == 0) && ((result = s->e.data - o->e.data) == 0) && ((result = s->e.udata - o->e.udata) == 0) ) { @@ -1787,7 +1736,7 @@ static PyMethodDef select_methods[] = { {"select", select_select, METH_VARARGS, select_doc}, -#if defined(HAVE_POLL) && !defined(HAVE_BROKEN_POLL) +#ifdef HAVE_POLL {"poll", select_poll, METH_NOARGS, poll_doc}, #endif /* HAVE_POLL */ {0, 0}, /* sentinel */ @@ -1819,7 +1768,7 @@ PyModule_AddIntConstant(m, "PIPE_BUF", PIPE_BUF); #endif -#if defined(HAVE_POLL) && !defined(HAVE_BROKEN_POLL) +#if defined(HAVE_POLL) #ifdef __APPLE__ if (select_have_broken_poll()) { if (PyObject_DelAttrString(m, "poll") == -1) { diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/shamodule.c --- a/Modules/shamodule.c Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/shamodule.c Sun Jul 20 10:52:46 2014 -0400 @@ -429,25 +429,12 @@ SHA_update(SHAobject *self, PyObject *args) { Py_buffer view; - Py_ssize_t n; - unsigned char *buf; if (!PyArg_ParseTuple(args, "s*:update", &view)) return NULL; - n = view.len; - buf = (unsigned char *) view.buf; - while (n > 0) { - Py_ssize_t nbytes; - if (n > INT_MAX) - nbytes = INT_MAX; - else - nbytes = n; - sha_update(self, buf, - Py_SAFE_DOWNCAST(nbytes, Py_ssize_t, unsigned int)); - buf += nbytes; - n -= nbytes; - } + sha_update(self, (unsigned char*)view.buf, + Py_SAFE_DOWNCAST(view.len, Py_ssize_t, unsigned int)); PyBuffer_Release(&view); Py_RETURN_NONE; @@ -549,8 +536,6 @@ static char *kwlist[] = {"string", NULL}; SHAobject *new; Py_buffer view = { 0 }; - Py_ssize_t n; - unsigned char *buf; if (!PyArg_ParseTupleAndKeywords(args, kwdict, "|s*:new", kwlist, &view)) { @@ -569,21 +554,10 @@ PyBuffer_Release(&view); return NULL; } - - n = view.len; - buf = (unsigned char *) view.buf; - while (n > 0) { - Py_ssize_t nbytes; - if (n > INT_MAX) - nbytes = INT_MAX; - else - nbytes = n; - sha_update(new, buf, - Py_SAFE_DOWNCAST(nbytes, Py_ssize_t, unsigned int)); - buf += nbytes; - n -= nbytes; + if (view.len > 0) { + sha_update(new, (unsigned char*)view.buf, + Py_SAFE_DOWNCAST(view.len, Py_ssize_t, unsigned int)); } - PyBuffer_Release(&view); return (PyObject *)new; diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/signalmodule.c --- a/Modules/signalmodule.c Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/signalmodule.c Sun Jul 20 10:52:46 2014 -0400 @@ -321,10 +321,7 @@ Handlers[sig_num].tripped = 0; Py_INCREF(obj); Handlers[sig_num].func = obj; - if (old_handler != NULL) - return old_handler; - else - Py_RETURN_NONE; + return old_handler; } PyDoc_STRVAR(signal_doc, @@ -352,13 +349,8 @@ return NULL; } old_handler = Handlers[sig_num].func; - if (old_handler != NULL) { - Py_INCREF(old_handler); - return old_handler; - } - else { - Py_RETURN_NONE; - } + Py_INCREF(old_handler); + return old_handler; } PyDoc_STRVAR(getsignal_doc, @@ -415,7 +407,7 @@ return NULL; } #endif - if (fd != -1 && (!_PyVerify_fd(fd) || fstat(fd, &buf) != 0)) { + if (fd != -1 && fstat(fd, &buf) != 0) { PyErr_SetString(PyExc_ValueError, "invalid fd"); return NULL; } @@ -980,32 +972,14 @@ return 0; } -static void -_clear_pending_signals(void) -{ - int i; - if (!is_tripped) - return; - is_tripped = 0; - for (i = 1; i < NSIG; ++i) { - Handlers[i].tripped = 0; - } -} - void PyOS_AfterFork(void) { - /* Clear the signal flags after forking so that they aren't handled - * in both processes if they came in just before the fork() but before - * the interpreter had an opportunity to call the handlers. issue9535. */ - _clear_pending_signals(); #ifdef WITH_THREAD - /* PyThread_ReInitTLS() must be called early, to make sure that the TLS API - * can be called safely. */ - PyThread_ReInitTLS(); PyEval_ReInitThreads(); main_thread = PyThread_get_thread_ident(); main_pid = getpid(); _PyImport_ReInitLock(); + PyThread_ReInitTLS(); #endif } diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/socketmodule.c --- a/Modules/socketmodule.c Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/socketmodule.c Sun Jul 20 10:52:46 2014 -0400 @@ -92,7 +92,6 @@ #include "Python.h" #include "structmember.h" -#include "timefuncs.h" #undef MAX #define MAX(x, y) ((x) < (y) ? (y) : (x)) @@ -474,17 +473,6 @@ return NULL; } -#ifdef MS_WINDOWS -#ifndef WSAEAGAIN -#define WSAEAGAIN WSAEWOULDBLOCK -#endif -#define CHECK_ERRNO(expected) \ - (WSAGetLastError() == WSA ## expected) -#else -#define CHECK_ERRNO(expected) \ - (errno == expected) -#endif - /* Convenience function to raise an error according to errno and return a NULL pointer from a function. */ @@ -673,7 +661,7 @@ after they've reacquired the interpreter lock. Returns 1 on timeout, -1 on error, 0 otherwise. */ static int -internal_select_ex(PySocketSockObject *s, int writing, double interval) +internal_select(PySocketSockObject *s, int writing) { int n; @@ -685,10 +673,6 @@ if (s->sock_fd < 0) return 0; - /* Handling this condition here simplifies the select loops */ - if (interval < 0.0) - return 1; - /* Prefer poll, if available, since you can poll() any fd * which can't be done with select(). */ #ifdef HAVE_POLL @@ -700,7 +684,7 @@ pollfd.events = writing ? POLLOUT : POLLIN; /* s->sock_timeout is in seconds, timeout in ms */ - timeout = (int)(interval * 1000 + 0.5); + timeout = (int)(s->sock_timeout * 1000 + 0.5); n = poll(&pollfd, 1, timeout); } #else @@ -708,8 +692,8 @@ /* Construct the arguments to select */ fd_set fds; struct timeval tv; - tv.tv_sec = (int)interval; - tv.tv_usec = (int)((interval - tv.tv_sec) * 1e6); + tv.tv_sec = (int)s->sock_timeout; + tv.tv_usec = (int)((s->sock_timeout - tv.tv_sec) * 1e6); FD_ZERO(&fds); FD_SET(s->sock_fd, &fds); @@ -728,48 +712,6 @@ return 0; } -static int -internal_select(PySocketSockObject *s, int writing) -{ - return internal_select_ex(s, writing, s->sock_timeout); -} - -/* - Two macros for automatic retry of select() in case of false positives - (for example, select() could indicate a socket is ready for reading - but the data then discarded by the OS because of a wrong checksum). - Here is an example of use: - - BEGIN_SELECT_LOOP(s) - Py_BEGIN_ALLOW_THREADS - timeout = internal_select_ex(s, 0, interval); - if (!timeout) - outlen = recv(s->sock_fd, cbuf, len, flags); - Py_END_ALLOW_THREADS - if (timeout == 1) { - PyErr_SetString(socket_timeout, "timed out"); - return -1; - } - END_SELECT_LOOP(s) -*/ -#define BEGIN_SELECT_LOOP(s) \ - { \ - double deadline, interval = s->sock_timeout; \ - int has_timeout = s->sock_timeout > 0.0; \ - if (has_timeout) { \ - deadline = _PyTime_FloatTime() + s->sock_timeout; \ - } \ - while (1) { \ - errno = 0; - -#define END_SELECT_LOOP(s) \ - if (!has_timeout || \ - (!CHECK_ERRNO(EWOULDBLOCK) && !CHECK_ERRNO(EAGAIN))) \ - break; \ - interval = deadline - _PyTime_FloatTime(); \ - } \ - } - /* Initialize a new socket object. */ static double defaulttimeout = -1.0; /* Default timeout for new sockets */ @@ -819,7 +761,7 @@ /* Lock to allow python interpreter to continue, but only allow one thread to be in gethostbyname or getaddrinfo */ #if defined(USE_GETHOSTBYNAME_LOCK) || defined(USE_GETADDRINFO_LOCK) -static PyThread_type_lock netdb_lock; +PyThread_type_lock netdb_lock; #endif @@ -1086,10 +1028,10 @@ PyObject *ret = NULL; if (addrobj) { a = (struct sockaddr_in6 *)addr; - ret = Py_BuildValue("OiII", + ret = Py_BuildValue("Oiii", addrobj, ntohs(a->sin6_port), - ntohl(a->sin6_flowinfo), + a->sin6_flowinfo, a->sin6_scope_id); Py_DECREF(addrobj); } @@ -1340,8 +1282,7 @@ { struct sockaddr_in6* addr; char *host; - int port, result; - unsigned int flowinfo, scope_id; + int port, flowinfo, scope_id, result; flowinfo = scope_id = 0; if (!PyTuple_Check(args)) { PyErr_Format( @@ -1351,7 +1292,7 @@ Py_TYPE(args)->tp_name); return 0; } - if (!PyArg_ParseTuple(args, "eti|II", + if (!PyArg_ParseTuple(args, "eti|ii", "idna", &host, &port, &flowinfo, &scope_id)) { return 0; @@ -1368,15 +1309,9 @@ "getsockaddrarg: port must be 0-65535."); return 0; } - if (flowinfo > 0xfffff) { - PyErr_SetString( - PyExc_OverflowError, - "getsockaddrarg: flowinfo must be 0-1048575."); - return 0; - } addr->sin6_family = s->sock_family; addr->sin6_port = htons((short)port); - addr->sin6_flowinfo = htonl(flowinfo); + addr->sin6_flowinfo = flowinfo; addr->sin6_scope_id = scope_id; *len_ret = sizeof *addr; return 1; @@ -1714,9 +1649,8 @@ if (!IS_SELECTABLE(s)) return select_error(); - BEGIN_SELECT_LOOP(s) Py_BEGIN_ALLOW_THREADS - timeout = internal_select_ex(s, 0, interval); + timeout = internal_select(s, 0); if (!timeout) newfd = accept(s->sock_fd, SAS2SA(&addrbuf), &addrlen); Py_END_ALLOW_THREADS @@ -1725,7 +1659,6 @@ PyErr_SetString(socket_timeout, "timed out"); return NULL; } - END_SELECT_LOOP(s) #ifdef MS_WINDOWS if (newfd == INVALID_SOCKET) @@ -1773,7 +1706,7 @@ static PyObject * sock_setblocking(PySocketSockObject *s, PyObject *arg) { - long block; + int block; block = PyInt_AsLong(arg); if (block == -1 && PyErr_Occurred()) @@ -2303,7 +2236,7 @@ int backlog; int res; - backlog = _PyInt_AsInt(arg); + backlog = PyInt_AsLong(arg); if (backlog == -1 && PyErr_Occurred()) return NULL; Py_BEGIN_ALLOW_THREADS @@ -2415,9 +2348,8 @@ } #ifndef __VMS - BEGIN_SELECT_LOOP(s) Py_BEGIN_ALLOW_THREADS - timeout = internal_select_ex(s, 0, interval); + timeout = internal_select(s, 0); if (!timeout) outlen = recv(s->sock_fd, cbuf, len, flags); Py_END_ALLOW_THREADS @@ -2426,7 +2358,6 @@ PyErr_SetString(socket_timeout, "timed out"); return -1; } - END_SELECT_LOOP(s) if (outlen < 0) { /* Note: the call to errorhandler() ALWAYS indirectly returned NULL, so ignore its return value */ @@ -2448,9 +2379,8 @@ segment = remaining; } - BEGIN_SELECT_LOOP(s) Py_BEGIN_ALLOW_THREADS - timeout = internal_select_ex(s, 0, interval); + timeout = internal_select(s, 0); if (!timeout) nread = recv(s->sock_fd, read_buf, segment, flags); Py_END_ALLOW_THREADS @@ -2459,8 +2389,6 @@ PyErr_SetString(socket_timeout, "timed out"); return -1; } - END_SELECT_LOOP(s) - if (nread < 0) { s->errorhandler(); return -1; @@ -2624,10 +2552,9 @@ return -1; } - BEGIN_SELECT_LOOP(s) Py_BEGIN_ALLOW_THREADS memset(&addrbuf, 0, addrlen); - timeout = internal_select_ex(s, 0, interval); + timeout = internal_select(s, 0); if (!timeout) { #ifndef MS_WINDOWS #if defined(PYOS_OS2) && !defined(PYCC_GCC) @@ -2648,7 +2575,6 @@ PyErr_SetString(socket_timeout, "timed out"); return -1; } - END_SELECT_LOOP(s) if (n < 0) { s->errorhandler(); return -1; @@ -2732,6 +2658,7 @@ &recvlen, &flags)) return NULL; buflen = buf.len; + assert(buf.buf != 0 && buflen > 0); if (recvlen < 0) { PyErr_SetString(PyExc_ValueError, @@ -2741,10 +2668,6 @@ if (recvlen == 0) { /* If nbytes was not specified, use the buffer's length */ recvlen = buflen; - } else if (recvlen > buflen) { - PyErr_SetString(PyExc_ValueError, - "nbytes is greater than the length of the buffer"); - goto error; } readlen = sock_recvfrom_guts(s, buf.buf, recvlen, flags, &addr); @@ -2789,9 +2712,8 @@ buf = pbuf.buf; len = pbuf.len; - BEGIN_SELECT_LOOP(s) Py_BEGIN_ALLOW_THREADS - timeout = internal_select_ex(s, 1, interval); + timeout = internal_select(s, 1); if (!timeout) #ifdef __VMS n = sendsegmented(s->sock_fd, buf, len, flags); @@ -2799,14 +2721,13 @@ n = send(s->sock_fd, buf, len, flags); #endif Py_END_ALLOW_THREADS + + PyBuffer_Release(&pbuf); + if (timeout == 1) { - PyBuffer_Release(&pbuf); PyErr_SetString(socket_timeout, "timed out"); return NULL; } - END_SELECT_LOOP(s) - - PyBuffer_Release(&pbuf); if (n < 0) return s->errorhandler(); return PyInt_FromLong((long)n); @@ -2840,9 +2761,8 @@ } do { - BEGIN_SELECT_LOOP(s) Py_BEGIN_ALLOW_THREADS - timeout = internal_select_ex(s, 1, interval); + timeout = internal_select(s, 1); n = -1; if (!timeout) { #ifdef __VMS @@ -2857,7 +2777,6 @@ PyErr_SetString(socket_timeout, "timed out"); return NULL; } - END_SELECT_LOOP(s) /* PyErr_CheckSignals() might change errno */ saved_errno = errno; /* We must run our signal handlers before looping again. @@ -2937,20 +2856,17 @@ return NULL; } - BEGIN_SELECT_LOOP(s) Py_BEGIN_ALLOW_THREADS - timeout = internal_select_ex(s, 1, interval); + timeout = internal_select(s, 1); if (!timeout) n = sendto(s->sock_fd, buf, len, flags, SAS2SA(&addrbuf), addrlen); Py_END_ALLOW_THREADS + PyBuffer_Release(&pbuf); if (timeout == 1) { - PyBuffer_Release(&pbuf); PyErr_SetString(socket_timeout, "timed out"); return NULL; } - END_SELECT_LOOP(s) - PyBuffer_Release(&pbuf); if (n < 0) return s->errorhandler(); return PyInt_FromLong((long)n); @@ -2971,7 +2887,7 @@ int how; int res; - how = _PyInt_AsInt(arg); + how = PyInt_AsLong(arg); if (how == -1 && PyErr_Occurred()) return NULL; Py_BEGIN_ALLOW_THREADS @@ -4167,30 +4083,17 @@ "getaddrinfo() argument 1 must be string or None"); return NULL; } - if (PyInt_Check(pobj) || PyLong_Check(pobj)) { - long value = PyLong_AsLong(pobj); - if (value == -1 && PyErr_Occurred()) - return NULL; - PyOS_snprintf(pbuf, sizeof(pbuf), "%ld", value); + if (PyInt_Check(pobj)) { + PyOS_snprintf(pbuf, sizeof(pbuf), "%ld", PyInt_AsLong(pobj)); pptr = pbuf; } else if (PyString_Check(pobj)) { pptr = PyString_AsString(pobj); } else if (pobj == Py_None) { pptr = (char *)NULL; } else { - PyErr_SetString(socket_error, - "getaddrinfo() argument 2 must be integer or string"); + PyErr_SetString(socket_error, "Int or String expected"); goto err; } -#if defined(__APPLE__) && defined(AI_NUMERICSERV) - if ((flags & AI_NUMERICSERV) && (pptr == NULL || (pptr[0] == '0' && pptr[1] == 0))) { - /* On OSX upto at least OSX 10.8 getaddrinfo crashes - * if AI_NUMERICSERV is set and the servname is NULL or "0". - * This workaround avoids a segfault in libsystem. - */ - pptr = "00"; - } -#endif memset(&hints, 0, sizeof(hints)); hints.ai_family = family; hints.ai_socktype = socktype; @@ -4253,8 +4156,7 @@ PyObject *sa = (PyObject *)NULL; int flags; char *hostp; - int port; - unsigned int flowinfo, scope_id; + int port, flowinfo, scope_id; char hbuf[NI_MAXHOST], pbuf[NI_MAXSERV]; struct addrinfo hints, *res = NULL; int error; @@ -4268,14 +4170,9 @@ "getnameinfo() argument 1 must be a tuple"); return NULL; } - if (!PyArg_ParseTuple(sa, "si|II", + if (!PyArg_ParseTuple(sa, "si|ii", &hostp, &port, &flowinfo, &scope_id)) return NULL; - if (flowinfo > 0xfffff) { - PyErr_SetString(PyExc_OverflowError, - "getsockaddrarg: flowinfo must be 0-1048575."); - return NULL; - } PyOS_snprintf(pbuf, sizeof(pbuf), "%d", port); memset(&hints, 0, sizeof(hints)); hints.ai_family = AF_UNSPEC; @@ -4309,7 +4206,7 @@ { struct sockaddr_in6 *sin6; sin6 = (struct sockaddr_in6 *)res->ai_addr; - sin6->sin6_flowinfo = htonl(flowinfo); + sin6->sin6_flowinfo = flowinfo; sin6->sin6_scope_id = scope_id; break; } diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/sre.h --- a/Modules/sre.h Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/sre.h Sun Jul 20 10:52:46 2014 -0400 @@ -14,21 +14,11 @@ #include "sre_constants.h" /* size of a code word (must be unsigned short or larger, and - large enough to hold a UCS4 character) */ -#ifdef Py_USING_UNICODE -# define SRE_CODE Py_UCS4 -# if SIZEOF_SIZE_T > 4 -# define SRE_MAXREPEAT (~(SRE_CODE)0) -# else -# define SRE_MAXREPEAT ((SRE_CODE)PY_SSIZE_T_MAX) -# endif + large enough to hold a Py_UNICODE character) */ +#ifdef Py_UNICODE_WIDE +#define SRE_CODE Py_UCS4 #else -# define SRE_CODE unsigned int -# if SIZEOF_SIZE_T > SIZEOF_INT -# define SRE_MAXREPEAT (~(SRE_CODE)0) -# else -# define SRE_MAXREPEAT ((SRE_CODE)PY_SSIZE_T_MAX) -# endif +#define SRE_CODE unsigned short #endif typedef struct { diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/stropmodule.c --- a/Modules/stropmodule.c Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/stropmodule.c Sun Jul 20 10:52:46 2014 -0400 @@ -593,7 +593,7 @@ char* e; char* p; char* q; - Py_ssize_t i, j; + Py_ssize_t i, j, old_j; PyObject* out; char* string; Py_ssize_t stringlen; @@ -610,29 +610,30 @@ } /* First pass: determine size of output string */ - i = j = 0; /* j: current column; i: total of previous lines */ + i = j = old_j = 0; /* j: current column; i: total of previous lines */ e = string + stringlen; for (p = string; p < e; p++) { if (*p == '\t') { - Py_ssize_t incr = tabsize - (j%tabsize); - if (j > PY_SSIZE_T_MAX - incr) - goto overflow; - j += incr; + j += tabsize - (j%tabsize); + if (old_j > j) { + PyErr_SetString(PyExc_OverflowError, + "new string is too long"); + return NULL; + } + old_j = j; } else { - if (j > PY_SSIZE_T_MAX - 1) - goto overflow; j++; if (*p == '\n') { - if (i > PY_SSIZE_T_MAX - j) - goto overflow; i += j; j = 0; } } } - if (i > PY_SSIZE_T_MAX - j) - goto overflow; + if ((i + j) < 0) { + PyErr_SetString(PyExc_OverflowError, "new string is too long"); + return NULL; + } /* Second pass: create output string and fill it */ out = PyString_FromStringAndSize(NULL, i+j); @@ -657,9 +658,6 @@ } return out; - overflow: - PyErr_SetString(PyExc_OverflowError, "result is too long"); - return NULL; } diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/svmodule.c --- a/Modules/svmodule.c Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/svmodule.c Sun Jul 20 10:52:46 2014 -0400 @@ -279,7 +279,8 @@ (void)svUnlockCaptureData(self->ob_svideo->ob_svideo, self->ob_capture); self->ob_capture = NULL; - Py_CLEAR(self->ob_svideo); + Py_DECREF(self->ob_svideo); + self->ob_svideo = NULL; } PyObject_Del(self); } diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/symtablemodule.c --- a/Modules/symtablemodule.c Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/symtablemodule.c Sun Jul 20 10:52:46 2014 -0400 @@ -33,7 +33,7 @@ st = Py_SymtableString(str, filename, start); if (st == NULL) return NULL; - t = (PyObject *)st->st_top; + t = st->st_symbols; Py_INCREF(t); PyMem_Free((void *)st->st_future); PySymtable_Free(st); @@ -52,9 +52,6 @@ { PyObject *m; - if (PyType_Ready(&PySTEntry_Type) < 0) - return; - m = Py_InitModule("_symtable", symtable_methods); if (m == NULL) return; diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/threadmodule.c --- a/Modules/threadmodule.c Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/threadmodule.c Sun Jul 20 10:52:46 2014 -0400 @@ -56,12 +56,12 @@ } PyDoc_STRVAR(acquire_doc, -"acquire([wait]) -> bool\n\ +"acquire([wait]) -> None or bool\n\ (acquire_lock() is an obsolete synonym)\n\ \n\ Lock the lock. Without argument, this blocks if the lock is already\n\ locked (even by the same thread), waiting for another thread to release\n\ -the lock, and return True once the lock is acquired.\n\ +the lock, and return None once the lock is acquired.\n\ With an argument, this will only block if the argument is true,\n\ and the return value reflects whether the lock is acquired.\n\ The blocking operation is not interruptible."); @@ -618,8 +618,6 @@ PyErr_Clear(); else { PyObject *file; - PyObject *exc, *value, *tb; - PyErr_Fetch(&exc, &value, &tb); PySys_WriteStderr( "Unhandled exception in thread started by "); file = PySys_GetObject("stderr"); @@ -628,7 +626,6 @@ else PyObject_Print(boot->func, stderr, 0); PySys_WriteStderr("\n"); - PyErr_Restore(exc, value, tb); PyErr_PrintEx(0); } } diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/timemodule.c --- a/Modules/timemodule.c Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/timemodule.c Sun Jul 20 10:52:46 2014 -0400 @@ -96,7 +96,7 @@ static double floattime(void); /* For Y2K check */ -static PyObject *moddict = NULL; +static PyObject *moddict; /* Exposed in timefuncs.h. */ time_t @@ -858,11 +858,6 @@ /* Accept 2-digit dates unless PYTHONY2K is set and non-empty */ p = Py_GETENV("PYTHONY2K"); PyModule_AddIntConstant(m, "accept2dyear", (long) (!p || !*p)); - /* If an embedded interpreter is shutdown and reinitialized the old - moddict was not decrefed on shutdown and the next import of this - module leads to a leak. Conditionally decref here to prevent that. - */ - Py_XDECREF(moddict); /* Squirrel away the module's dictionary for the y2k check */ moddict = PyModule_GetDict(m); Py_INCREF(moddict); @@ -1056,9 +1051,4 @@ return 0; } -/* export floattime to socketmodule.c */ -PyAPI_FUNC(double) -_PyTime_FloatTime(void) -{ - return floattime(); -} + diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/unicodedata.c --- a/Modules/unicodedata.c Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/unicodedata.c Sun Jul 20 10:52:46 2014 -0400 @@ -274,7 +274,7 @@ PyDoc_STRVAR(unicodedata_bidirectional__doc__, "bidirectional(unichr)\n\ \n\ -Returns the bidirectional class assigned to the Unicode character\n\ +Returns the bidirectional category assigned to the Unicode character\n\ unichr as string. If no such value is defined, an empty string is\n\ returned."); @@ -506,7 +506,7 @@ stackptr = 0; isize = PyUnicode_GET_SIZE(input); - /* Overallocate at most 10 characters. */ + /* Overallocate atmost 10 characters. */ space = (isize > 10 ? 10 : isize) + isize; result = PyUnicode_FromUnicode(NULL, space); if (!result) @@ -520,7 +520,7 @@ while(stackptr) { Py_UNICODE code = stack[--stackptr]; /* Hangul Decomposition adds three characters in - a single step, so we need at least that much room. */ + a single step, so we need atleast that much room. */ if (space < 3) { Py_ssize_t newsize = PyString_GET_SIZE(result) + 10; space += 10; diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/zipimport.c --- a/Modules/zipimport.c Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/zipimport.c Sun Jul 20 10:52:46 2014 -0400 @@ -709,12 +709,7 @@ "'%.200s'", archive); return NULL; } - - if (fseek(fp, -22, SEEK_END) == -1) { - fclose(fp); - PyErr_Format(ZipImportError, "can't read Zip file: %s", archive); - return NULL; - } + fseek(fp, -22, SEEK_END); header_position = ftell(fp); if (fread(endof_central_dir, 1, 22, fp) != 22) { fclose(fp); @@ -748,13 +743,11 @@ PyObject *t; int err; - if (fseek(fp, header_offset, 0) == -1) /* Start of file header */ - goto fseek_error; + fseek(fp, header_offset, 0); /* Start of file header */ l = PyMarshal_ReadLongFromFile(fp); if (l != 0x02014B50) break; /* Bad: Central Dir File Header */ - if (fseek(fp, header_offset + 10, 0) == -1) - goto fseek_error; + fseek(fp, header_offset + 10, 0); compress = PyMarshal_ReadShortFromFile(fp); time = PyMarshal_ReadShortFromFile(fp); date = PyMarshal_ReadShortFromFile(fp); @@ -765,8 +758,7 @@ header_size = 46 + name_size + PyMarshal_ReadShortFromFile(fp) + PyMarshal_ReadShortFromFile(fp); - if (fseek(fp, header_offset + 42, 0) == -1) - goto fseek_error; + fseek(fp, header_offset + 42, 0); file_offset = PyMarshal_ReadLongFromFile(fp) + arc_offset; if (name_size > MAXPATHLEN) name_size = MAXPATHLEN; @@ -798,11 +790,6 @@ PySys_WriteStderr("# zipimport: found %ld names in %s\n", count, archive); return files; -fseek_error: - fclose(fp); - Py_XDECREF(files); - PyErr_Format(ZipImportError, "can't read Zip file: %s", archive); - return NULL; error: fclose(fp); Py_XDECREF(files); @@ -870,12 +857,7 @@ } /* Check to make sure the local file header is correct */ - if (fseek(fp, file_offset, 0) == -1) { - fclose(fp); - PyErr_Format(ZipImportError, "can't read Zip file: %s", archive); - return NULL; - } - + fseek(fp, file_offset, 0); l = PyMarshal_ReadLongFromFile(fp); if (l != 0x04034B50) { /* Bad: Local File Header */ @@ -885,12 +867,7 @@ fclose(fp); return NULL; } - if (fseek(fp, file_offset + 26, 0) == -1) { - fclose(fp); - PyErr_Format(ZipImportError, "can't read Zip file: %s", archive); - return NULL; - } - + fseek(fp, file_offset + 26, 0); l = 30 + PyMarshal_ReadShortFromFile(fp) + PyMarshal_ReadShortFromFile(fp); /* local header size */ file_offset += l; /* Start of file data */ @@ -904,13 +881,8 @@ buf = PyString_AsString(raw_data); err = fseek(fp, file_offset, 0); - if (err == 0) { + if (err == 0) bytes_read = fread(buf, 1, data_size, fp); - } else { - fclose(fp); - PyErr_Format(ZipImportError, "can't read Zip file: %s", archive); - return NULL; - } fclose(fp); if (err || bytes_read != data_size) { PyErr_SetString(PyExc_IOError, diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/zlib/deflate.c --- a/Modules/zlib/deflate.c Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/zlib/deflate.c Sun Jul 20 10:52:46 2014 -0400 @@ -163,7 +163,7 @@ /* =========================================================================== * Update a hash value with the given input byte - * IN assertion: all calls to UPDATE_HASH are made with consecutive + * IN assertion: all calls to to UPDATE_HASH are made with consecutive * input characters, so that a running hash key can be computed from the * previous key instead of complete recalculation each time. */ @@ -176,7 +176,7 @@ * the previous length of the hash chain. * If this file is compiled with -DFASTEST, the compression level is forced * to 1, and no hash chains are maintained. - * IN assertion: all calls to INSERT_STRING are made with consecutive + * IN assertion: all calls to to INSERT_STRING are made with consecutive * input characters and the first MIN_MATCH bytes of str are valid * (except for the last MIN_MATCH-1 bytes of the input file). */ diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/zlib/zlib.h --- a/Modules/zlib/zlib.h Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/zlib/zlib.h Sun Jul 20 10:52:46 2014 -0400 @@ -764,7 +764,7 @@ inflateSync returns Z_OK if a full flush point has been found, Z_BUF_ERROR if no more input was provided, Z_DATA_ERROR if no flush point has been found, or Z_STREAM_ERROR if the stream structure was inconsistent. In the success - case, the application may save the current value of total_in which + case, the application may save the current current value of total_in which indicates where valid compressed data was found. In the error case, the application may repeatedly call inflateSync, providing more input each time, until success or end of the input data. diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Modules/zlibmodule.c --- a/Modules/zlibmodule.c Sat Jul 19 16:34:33 2014 -0700 +++ b/Modules/zlibmodule.c Sun Jul 20 10:52:46 2014 -0400 @@ -101,7 +101,7 @@ PyDoc_STRVAR(compressobj__doc__, "compressobj([level]) -- Return a compressor object.\n" "\n" -"Optional arg level is the compression level, in 0-9."); +"Optional arg level is the compression level, in 1-9."); PyDoc_STRVAR(decompressobj__doc__, "decompressobj([wbits]) -- Return a decompressor object.\n" @@ -132,7 +132,7 @@ PyDoc_STRVAR(compress__doc__, "compress(string[, level]) -- Returned compressed string.\n" "\n" -"Optional arg level is the compression level, in 0-9."); +"Optional arg level is the compression level, in 1-9."); static PyObject * PyZlib_compress(PyObject *self, PyObject *args) @@ -467,49 +467,6 @@ return RetVal; } -/* Helper for objdecompress() and unflush(). Saves any unconsumed input data in - self->unused_data or self->unconsumed_tail, as appropriate. */ -static int -save_unconsumed_input(compobject *self, int err) -{ - if (err == Z_STREAM_END) { - /* The end of the compressed data has been reached. Store the leftover - input data in self->unused_data. */ - if (self->zst.avail_in > 0) { - Py_ssize_t old_size = PyString_GET_SIZE(self->unused_data); - Py_ssize_t new_size; - PyObject *new_data; - if (self->zst.avail_in > PY_SSIZE_T_MAX - old_size) { - PyErr_NoMemory(); - return -1; - } - new_size = old_size + self->zst.avail_in; - new_data = PyString_FromStringAndSize(NULL, new_size); - if (new_data == NULL) - return -1; - Py_MEMCPY(PyString_AS_STRING(new_data), - PyString_AS_STRING(self->unused_data), old_size); - Py_MEMCPY(PyString_AS_STRING(new_data) + old_size, - self->zst.next_in, self->zst.avail_in); - Py_DECREF(self->unused_data); - self->unused_data = new_data; - self->zst.avail_in = 0; - } - } - if (self->zst.avail_in > 0 || PyString_GET_SIZE(self->unconsumed_tail)) { - /* This code handles two distinct cases: - 1. Output limit was reached. Save leftover input in unconsumed_tail. - 2. All input data was consumed. Clear unconsumed_tail. */ - PyObject *new_data = PyString_FromStringAndSize( - (char *)self->zst.next_in, self->zst.avail_in); - if (new_data == NULL) - return -1; - Py_DECREF(self->unconsumed_tail); - self->unconsumed_tail = new_data; - } - return 0; -} - PyDoc_STRVAR(decomp_decompress__doc__, "decompress(data, max_length) -- Return a string containing the decompressed\n" "version of the data.\n" @@ -584,20 +541,43 @@ Py_END_ALLOW_THREADS } - if (save_unconsumed_input(self, err) < 0) { + if(max_length) { + /* Not all of the compressed data could be accommodated in a buffer of + the specified size. Return the unconsumed tail in an attribute. */ + Py_DECREF(self->unconsumed_tail); + self->unconsumed_tail = PyString_FromStringAndSize((char *)self->zst.next_in, + self->zst.avail_in); + } + else if (PyString_GET_SIZE(self->unconsumed_tail) > 0) { + /* All of the compressed data was consumed. Clear unconsumed_tail. */ + Py_DECREF(self->unconsumed_tail); + self->unconsumed_tail = PyString_FromStringAndSize("", 0); + } + if(!self->unconsumed_tail) { Py_DECREF(RetVal); RetVal = NULL; goto error; } - /* This is the logical place to call inflateEnd, but the old behaviour of - only calling it on flush() is preserved. */ - - if (err != Z_STREAM_END && err != Z_OK && err != Z_BUF_ERROR) { + /* The end of the compressed data has been reached, so set the + unused_data attribute to a string containing the remainder of the + data in the string. Note that this is also a logical place to call + inflateEnd, but the old behaviour of only calling it on flush() is + preserved. + */ + if (err == Z_STREAM_END) { + Py_XDECREF(self->unused_data); /* Free original empty string */ + self->unused_data = PyString_FromStringAndSize( + (char *)self->zst.next_in, self->zst.avail_in); + if (self->unused_data == NULL) { + Py_DECREF(RetVal); + goto error; + } /* We will only get Z_BUF_ERROR if the output buffer was full but there wasn't more output when we tried again, so it is not an error condition. */ + } else if (err != Z_OK && err != Z_BUF_ERROR) { zlib_error(self->zst, err, "while decompressing"); Py_DECREF(RetVal); RetVal = NULL; @@ -830,8 +810,6 @@ ENTER_ZLIB start_total_out = self->zst.total_out; - self->zst.avail_in = PyString_GET_SIZE(self->unconsumed_tail); - self->zst.next_in = (Byte *)PyString_AS_STRING(self->unconsumed_tail); self->zst.avail_out = length; self->zst.next_out = (Byte *)PyString_AS_STRING(retval); @@ -853,12 +831,6 @@ Py_END_ALLOW_THREADS } - if (save_unconsumed_input(self, err) < 0) { - Py_DECREF(retval); - retval = NULL; - goto error; - } - /* If flushmode is Z_FINISH, we also have to call deflateEnd() to free various data structures. Note we should only get Z_STREAM_END when flushmode is Z_FINISH */ @@ -872,7 +844,6 @@ goto error; } } - _PyString_Resize(&retval, self->zst.total_out - start_total_out); error: @@ -1039,7 +1010,7 @@ "zlib library, which is based on GNU zip.\n" "\n" "adler32(string[, start]) -- Compute an Adler-32 checksum.\n" -"compress(string[, level]) -- Compress string, with compression level in 0-9.\n" +"compress(string[, level]) -- Compress string, with compression level in 1-9.\n" "compressobj([level]) -- Return a compressor object.\n" "crc32(string[, start]) -- Compute a CRC-32 checksum.\n" "decompress(string,[wbits],[bufsize]) -- Decompresses a compressed string.\n" diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Objects/abstract.c --- a/Objects/abstract.c Sat Jul 19 16:34:33 2014 -0700 +++ b/Objects/abstract.c Sun Jul 20 10:52:46 2014 -0400 @@ -126,7 +126,7 @@ PyErr_Clear(); return defaultvalue; } - rv = PyNumber_Check(ro) ? PyInt_AsSsize_t(ro) : defaultvalue; + rv = PyLong_Check(ro) ? PyLong_AsSsize_t(ro) : defaultvalue; Py_DECREF(ro); return rv; } @@ -2617,8 +2617,10 @@ return null_error(); func = PyObject_GetAttrString(o, name); - if (func == NULL) - return NULL; + if (func == NULL) { + PyErr_SetString(PyExc_AttributeError, name); + return 0; + } if (!PyCallable_Check(func)) { type_error("attribute of type '%.200s' is not callable", func); @@ -2654,8 +2656,10 @@ return null_error(); func = PyObject_GetAttrString(o, name); - if (func == NULL) - return NULL; + if (func == NULL) { + PyErr_SetString(PyExc_AttributeError, name); + return 0; + } if (!PyCallable_Check(func)) { type_error("attribute of type '%.200s' is not callable", func); diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Objects/bufferobject.c --- a/Objects/bufferobject.c Sat Jul 19 16:34:33 2014 -0700 +++ b/Objects/bufferobject.c Sun Jul 20 10:52:46 2014 -0400 @@ -88,7 +88,7 @@ *size = count; else *size = self->b_size; - if (*size > count - offset) + if (offset + *size > count) *size = count - offset; } return 1; @@ -334,20 +334,10 @@ return -1; p = (unsigned char *) ptr; len = size; - /* - We make the hash of the empty buffer be 0, rather than using - (prefix ^ suffix), since this slightly obfuscates the hash secret - */ - if (len == 0) { - self->b_hash = 0; - return 0; - } - x = _Py_HashSecret.prefix; - x ^= *p << 7; + x = *p << 7; while (--len >= 0) x = (1000003*x) ^ *p++; x ^= size; - x ^= _Py_HashSecret.suffix; if (x == -1) x = -2; self->b_hash = x; @@ -802,16 +792,6 @@ return size; } -static int buffer_getbuffer(PyBufferObject *self, Py_buffer *buf, int flags) -{ - void *ptr; - Py_ssize_t size; - if (!get_buf(self, &ptr, &size, ANY_BUFFER)) - return -1; - return PyBuffer_FillInfo(buf, (PyObject*)self, ptr, size, - self->b_readonly, flags); -} - static PySequenceMethods buffer_as_sequence = { (lenfunc)buffer_length, /*sq_length*/ (binaryfunc)buffer_concat, /*sq_concat*/ @@ -833,7 +813,6 @@ (writebufferproc)buffer_getwritebuf, (segcountproc)buffer_getsegcount, (charbufferproc)buffer_getcharbuf, - (getbufferproc)buffer_getbuffer, }; PyTypeObject PyBuffer_Type = { @@ -856,7 +835,7 @@ PyObject_GenericGetAttr, /* tp_getattro */ 0, /* tp_setattro */ &buffer_as_buffer, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GETCHARBUFFER | Py_TPFLAGS_HAVE_NEWBUFFER, /* tp_flags */ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GETCHARBUFFER, /* tp_flags */ buffer_doc, /* tp_doc */ 0, /* tp_traverse */ 0, /* tp_clear */ diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Objects/bytearrayobject.c --- a/Objects/bytearrayobject.c Sat Jul 19 16:34:33 2014 -0700 +++ b/Objects/bytearrayobject.c Sun Jul 20 10:52:46 2014 -0400 @@ -636,14 +636,8 @@ needed = 0; } else if (values == (PyObject *)self || !PyByteArray_Check(values)) { + /* Make a copy and call this function recursively */ int err; - if (PyNumber_Check(values) || PyUnicode_Check(values)) { - PyErr_SetString(PyExc_TypeError, - "can assign only bytes, buffers, or iterables " - "of ints in range(0, 256)"); - return -1; - } - /* Make a copy and call this function recursively */ values = PyByteArray_FromObject(values); if (values == NULL) return -1; @@ -994,8 +988,10 @@ *p++ = *quote_postfix++; } *p = '\0'; - /* v is cleared on error */ - (void)_PyString_Resize(&v, (p - PyString_AS_STRING(v))); + if (_PyString_Resize(&v, (p - PyString_AS_STRING(v)))) { + Py_DECREF(v); + return NULL; + } return v; } } @@ -2300,10 +2296,8 @@ } bytearray_obj = PyByteArray_FromStringAndSize(NULL, buf_size); - if (bytearray_obj == NULL) { - Py_DECREF(it); + if (bytearray_obj == NULL) return NULL; - } buf = PyByteArray_AS_STRING(bytearray_obj); while ((item = PyIter_Next(it)) != NULL) { @@ -2336,10 +2330,8 @@ return NULL; } - if (bytearray_setslice(self, Py_SIZE(self), Py_SIZE(self), bytearray_obj) == -1) { - Py_DECREF(bytearray_obj); + if (bytearray_setslice(self, Py_SIZE(self), Py_SIZE(self), bytearray_obj) == -1) return NULL; - } Py_DECREF(bytearray_obj); Py_RETURN_NONE; @@ -2653,7 +2645,7 @@ } PyDoc_STRVAR(splitlines__doc__, -"B.splitlines(keepends=False) -> list of lines\n\ +"B.splitlines([keepends]) -> list of lines\n\ \n\ Return a list of the lines in B, breaking at line boundaries.\n\ Line breaks are not included in the resulting list unless keepends\n\ diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Objects/classobject.c --- a/Objects/classobject.c Sat Jul 19 16:34:33 2014 -0700 +++ b/Objects/classobject.c Sun Jul 20 10:52:46 2014 -0400 @@ -225,16 +225,10 @@ class_getattr(register PyClassObject *op, PyObject *name) { register PyObject *v; - register char *sname; + register char *sname = PyString_AsString(name); PyClassObject *klass; descrgetfunc f; - if (!PyString_Check(name)) { - PyErr_SetString(PyExc_TypeError, "attribute name must be a string"); - return NULL; - } - - sname = PyString_AsString(name); if (sname[0] == '_' && sname[1] == '_') { if (strcmp(sname, "__dict__") == 0) { if (PyEval_GetRestricted()) { @@ -342,10 +336,6 @@ "classes are read-only in restricted mode"); return -1; } - if (!PyString_Check(name)) { - PyErr_SetString(PyExc_TypeError, "attribute name must be a string"); - return -1; - } sname = PyString_AsString(name); if (sname[0] == '_' && sname[1] == '_') { Py_ssize_t n = PyString_Size(name); @@ -709,14 +699,7 @@ instance_getattr1(register PyInstanceObject *inst, PyObject *name) { register PyObject *v; - register char *sname; - - if (!PyString_Check(name)) { - PyErr_SetString(PyExc_TypeError, "attribute name must be a string"); - return NULL; - } - - sname = PyString_AsString(name); + register char *sname = PyString_AsString(name); if (sname[0] == '_' && sname[1] == '_') { if (strcmp(sname, "__dict__") == 0) { if (PyEval_GetRestricted()) { @@ -827,14 +810,7 @@ instance_setattr(PyInstanceObject *inst, PyObject *name, PyObject *v) { PyObject *func, *args, *res, *tmp; - char *sname; - - if (!PyString_Check(name)) { - PyErr_SetString(PyExc_TypeError, "attribute name must be a string"); - return -1; - } - - sname = PyString_AsString(name); + char *sname = PyString_AsString(name); if (sname[0] == '_' && sname[1] == '_') { Py_ssize_t n = PyString_Size(name); if (sname[n-1] == '_' && sname[n-2] == '_') { diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Objects/complexobject.c --- a/Objects/complexobject.c Sat Jul 19 16:34:33 2014 -0700 +++ b/Objects/complexobject.c Sun Jul 20 10:52:46 2014 -0400 @@ -885,7 +885,7 @@ PyDoc_STRVAR(complex_conjugate_doc, "complex.conjugate() -> complex\n" "\n" -"Return the complex conjugate of its argument. (3-4j).conjugate() == 3+4j."); +"Returns the complex conjugate of its argument. (3-4j).conjugate() == 3+4j."); static PyObject * complex_getnewargs(PyComplexObject *v) @@ -897,7 +897,7 @@ PyDoc_STRVAR(complex__format__doc, "complex.__format__() -> str\n" "\n" -"Convert to a string according to format_spec."); +"Converts to a string according to format_spec."); static PyObject * complex__format__(PyObject* self, PyObject* args) diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Objects/descrobject.c --- a/Objects/descrobject.c Sat Jul 19 16:34:33 2014 -0700 +++ b/Objects/descrobject.c Sun Jul 20 10:52:46 2014 -0400 @@ -254,51 +254,14 @@ classmethoddescr_call(PyMethodDescrObject *descr, PyObject *args, PyObject *kwds) { - Py_ssize_t argc; - PyObject *self, *func, *result; + PyObject *func, *result; - /* Make sure that the first argument is acceptable as 'self' */ - assert(PyTuple_Check(args)); - argc = PyTuple_GET_SIZE(args); - if (argc < 1) { - PyErr_Format(PyExc_TypeError, - "descriptor '%s' of '%.100s' " - "object needs an argument", - descr_name((PyDescrObject *)descr), - descr->d_type->tp_name); - return NULL; - } - self = PyTuple_GET_ITEM(args, 0); - if (!PyType_Check(self)) { - PyErr_Format(PyExc_TypeError, - "descriptor '%s' requires a type " - "but received a '%.100s'", - descr_name((PyDescrObject *)descr), - self->ob_type->tp_name); - return NULL; - } - if (!PyType_IsSubtype((PyTypeObject *)self, descr->d_type)) { - PyErr_Format(PyExc_TypeError, - "descriptor '%s' " - "requires a subtype of '%.100s' " - "but received '%.100s", - descr_name((PyDescrObject *)descr), - descr->d_type->tp_name, - self->ob_type->tp_name); - return NULL; - } - - func = PyCFunction_New(descr->d_method, self); + func = PyCFunction_New(descr->d_method, (PyObject *)descr->d_type); if (func == NULL) return NULL; - args = PyTuple_GetSlice(args, 1, argc); - if (args == NULL) { - Py_DECREF(func); - return NULL; - } + result = PyEval_CallObjectWithKeywords(func, args, kwds); Py_DECREF(func); - Py_DECREF(args); return result; } @@ -1363,25 +1326,21 @@ "\n" "fget is a function to be used for getting an attribute value, and likewise\n" "fset is a function for setting, and fdel a function for del'ing, an\n" -"attribute. Typical use is to define a managed attribute x:\n\n" +"attribute. Typical use is to define a managed attribute x:\n" "class C(object):\n" " def getx(self): return self._x\n" " def setx(self, value): self._x = value\n" " def delx(self): del self._x\n" " x = property(getx, setx, delx, \"I'm the 'x' property.\")\n" "\n" -"Decorators make defining new properties or modifying existing ones easy:\n\n" +"Decorators make defining new properties or modifying existing ones easy:\n" "class C(object):\n" " @property\n" -" def x(self):\n" -" \"I am the 'x' property.\"\n" -" return self._x\n" +" def x(self): return self._x\n" " @x.setter\n" -" def x(self, value):\n" -" self._x = value\n" +" def x(self, value): self._x = value\n" " @x.deleter\n" -" def x(self):\n" -" del self._x\n" +" def x(self): del self._x\n" ); static int diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Objects/dictobject.c --- a/Objects/dictobject.c Sat Jul 19 16:34:33 2014 -0700 +++ b/Objects/dictobject.c Sun Jul 20 10:52:46 2014 -0400 @@ -502,16 +502,27 @@ _PyObject_GC_UNTRACK(op); } + /* -Internal routine to insert a new item into the table when you have entry object. -Used by insertdict. +Internal routine to insert a new item into the table. +Used both by the internal resize routine and by the public insert routine. +Eats a reference to key and one to value. +Returns -1 if an error occurred, or 0 on success. */ static int -insertdict_by_entry(register PyDictObject *mp, PyObject *key, long hash, - PyDictEntry *ep, PyObject *value) +insertdict(register PyDictObject *mp, PyObject *key, long hash, PyObject *value) { PyObject *old_value; - + register PyDictEntry *ep; + typedef PyDictEntry *(*lookupfunc)(PyDictObject *, PyObject *, long); + + assert(mp->ma_lookup != NULL); + ep = mp->ma_lookup(mp, key, hash); + if (ep == NULL) { + Py_DECREF(key); + Py_DECREF(value); + return -1; + } MAINTAIN_TRACKING(mp, key, value); if (ep->me_value != NULL) { old_value = ep->me_value; @@ -534,28 +545,6 @@ return 0; } - -/* -Internal routine to insert a new item into the table. -Used both by the internal resize routine and by the public insert routine. -Eats a reference to key and one to value. -Returns -1 if an error occurred, or 0 on success. -*/ -static int -insertdict(register PyDictObject *mp, PyObject *key, long hash, PyObject *value) -{ - register PyDictEntry *ep; - - assert(mp->ma_lookup != NULL); - ep = mp->ma_lookup(mp, key, hash); - if (ep == NULL) { - Py_DECREF(key); - Py_DECREF(value); - return -1; - } - return insertdict_by_entry(mp, key, hash, ep, value); -} - /* Internal routine used by dictresize() to insert an item which is known to be absent from the dict. This routine also assumes that @@ -749,26 +738,42 @@ return ep->me_value; } -static int -dict_set_item_by_hash_or_entry(register PyObject *op, PyObject *key, - long hash, PyDictEntry *ep, PyObject *value) +/* CAUTION: PyDict_SetItem() must guarantee that it won't resize the + * dictionary if it's merely replacing the value for an existing key. + * This means that it's safe to loop over a dictionary with PyDict_Next() + * and occasionally replace a value -- but you can't insert new keys or + * remove them. + */ +int +PyDict_SetItem(register PyObject *op, PyObject *key, PyObject *value) { register PyDictObject *mp; + register long hash; register Py_ssize_t n_used; + if (!PyDict_Check(op)) { + PyErr_BadInternalCall(); + return -1; + } + assert(key); + assert(value); mp = (PyDictObject *)op; + if (PyString_CheckExact(key)) { + hash = ((PyStringObject *)key)->ob_shash; + if (hash == -1) + hash = PyObject_Hash(key); + } + else { + hash = PyObject_Hash(key); + if (hash == -1) + return -1; + } assert(mp->ma_fill <= mp->ma_mask); /* at least one empty slot */ n_used = mp->ma_used; Py_INCREF(value); Py_INCREF(key); - if (ep == NULL) { - if (insertdict(mp, key, hash, value) != 0) - return -1; - } - else { - if (insertdict_by_entry(mp, key, hash, ep, value) != 0) - return -1; - } + if (insertdict(mp, key, hash, value) != 0) + return -1; /* If we added a key, we can safely resize. Otherwise just return! * If fill >= 2/3 size, adjust size. Normally, this doubles or * quaduples the size, but it's also possible for the dict to shrink @@ -788,36 +793,6 @@ return dictresize(mp, (mp->ma_used > 50000 ? 2 : 4) * mp->ma_used); } -/* CAUTION: PyDict_SetItem() must guarantee that it won't resize the - * dictionary if it's merely replacing the value for an existing key. - * This means that it's safe to loop over a dictionary with PyDict_Next() - * and occasionally replace a value -- but you can't insert new keys or - * remove them. - */ -int -PyDict_SetItem(register PyObject *op, PyObject *key, PyObject *value) -{ - register long hash; - - if (!PyDict_Check(op)) { - PyErr_BadInternalCall(); - return -1; - } - assert(key); - assert(value); - if (PyString_CheckExact(key)) { - hash = ((PyStringObject *)key)->ob_shash; - if (hash == -1) - hash = PyObject_Hash(key); - } - else { - hash = PyObject_Hash(key); - if (hash == -1) - return -1; - } - return dict_set_item_by_hash_or_entry(op, key, hash, NULL, value); -} - int PyDict_DelItem(PyObject *op, PyObject *key) { @@ -1353,50 +1328,49 @@ if (d == NULL) return NULL; - if (PyDict_CheckExact(d) && ((PyDictObject *)d)->ma_used == 0) { - if (PyDict_CheckExact(seq)) { - PyDictObject *mp = (PyDictObject *)d; - PyObject *oldvalue; - Py_ssize_t pos = 0; - PyObject *key; - long hash; - - if (dictresize(mp, Py_SIZE(seq))) { + if (PyDict_CheckExact(d) && PyDict_CheckExact(seq)) { + PyDictObject *mp = (PyDictObject *)d; + PyObject *oldvalue; + Py_ssize_t pos = 0; + PyObject *key; + long hash; + + if (dictresize(mp, Py_SIZE(seq))) { + Py_DECREF(d); + return NULL; + } + + while (_PyDict_Next(seq, &pos, &key, &oldvalue, &hash)) { + Py_INCREF(key); + Py_INCREF(value); + if (insertdict(mp, key, hash, value)) { Py_DECREF(d); return NULL; } - - while (_PyDict_Next(seq, &pos, &key, &oldvalue, &hash)) { - Py_INCREF(key); - Py_INCREF(value); - if (insertdict(mp, key, hash, value)) { - Py_DECREF(d); - return NULL; - } - } - return d; } - if (PyAnySet_CheckExact(seq)) { - PyDictObject *mp = (PyDictObject *)d; - Py_ssize_t pos = 0; - PyObject *key; - long hash; - - if (dictresize(mp, PySet_GET_SIZE(seq))) { + return d; + } + + if (PyDict_CheckExact(d) && PyAnySet_CheckExact(seq)) { + PyDictObject *mp = (PyDictObject *)d; + Py_ssize_t pos = 0; + PyObject *key; + long hash; + + if (dictresize(mp, PySet_GET_SIZE(seq))) { + Py_DECREF(d); + return NULL; + } + + while (_PySet_NextEntry(seq, &pos, &key, &hash)) { + Py_INCREF(key); + Py_INCREF(value); + if (insertdict(mp, key, hash, value)) { Py_DECREF(d); return NULL; } - - while (_PySet_NextEntry(seq, &pos, &key, &hash)) { - Py_INCREF(key); - Py_INCREF(value); - if (insertdict(mp, key, hash, value)) { - Py_DECREF(d); - return NULL; - } - } - return d; } + return d; } it = PyObject_GetIter(seq); @@ -1983,9 +1957,9 @@ return NULL; val = ep->me_value; if (val == NULL) { - if (dict_set_item_by_hash_or_entry((PyObject*)mp, key, hash, ep, - failobj) == 0) - val = failobj; + val = failobj; + if (PyDict_SetItem((PyObject*)mp, key, failobj)) + val = NULL; } Py_XINCREF(val); return val; @@ -2193,9 +2167,9 @@ "D.values() -> list of D's values"); PyDoc_STRVAR(update__doc__, -"D.update([E, ]**F) -> None. Update D from dict/iterable E and F.\n" -"If E present and has a .keys() method, does: for k in E: D[k] = E[k]\n\ -If E present and lacks .keys() method, does: for (k, v) in E: D[k] = v\n\ +"D.update(E, **F) -> None. Update D from dict/iterable E and F.\n" +"If E has a .keys() method, does: for k in E: D[k] = E[k]\n\ +If E lacks .keys() method, does: for (k, v) in E: D[k] = v\n\ In either case, this is followed by: for k in F: D[k] = F[k]"); PyDoc_STRVAR(fromkeys__doc__, @@ -2919,10 +2893,6 @@ return NULL; seq_str = PyObject_Repr(seq); - if (seq_str == NULL) { - Py_DECREF(seq); - return NULL; - } result = PyString_FromFormat("%s(%s)", Py_TYPE(dv)->tp_name, PyString_AS_STRING(seq_str)); Py_DECREF(seq_str); diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Objects/exceptions.c --- a/Objects/exceptions.c Sat Jul 19 16:34:33 2014 -0700 +++ b/Objects/exceptions.c Sun Jul 20 10:52:46 2014 -0400 @@ -306,8 +306,7 @@ return -1; } seq = PySequence_Tuple(val); - if (!seq) - return -1; + if (!seq) return -1; Py_CLEAR(self->args); self->args = seq; return 0; @@ -349,7 +348,8 @@ if (PyDict_DelItemString(self->dict, "message") < 0) return -1; } - Py_CLEAR(self->message); + Py_XDECREF(self->message); + self->message = NULL; return 0; } @@ -773,8 +773,7 @@ * file name given to EnvironmentError. */ if (PyTuple_GET_SIZE(args) == 2 && self->filename) { args = PyTuple_New(3); - if (!args) - return NULL; + if (!args) return NULL; tmp = PyTuple_GET_ITEM(self->args, 0); Py_INCREF(tmp); @@ -1072,8 +1071,7 @@ if (lenargs == 2) { info = PyTuple_GET_ITEM(args, 1); info = PySequence_Tuple(info); - if (!info) - return -1; + if (!info) return -1; if (PyTuple_GET_SIZE(info) != 4) { /* not a very good error message, but it's what Python 2.4 gives */ @@ -1169,11 +1167,9 @@ str = PyObject_Str(self->msg); else str = PyObject_Str(Py_None); - if (!str) - return NULL; + if (!str) return NULL; /* Don't fiddle with non-string return (shouldn't happen anyway) */ - if (!PyString_Check(str)) - return str; + if (!PyString_Check(str)) return str; /* XXX -- do all the additional formatting with filename and lineno here */ @@ -1648,10 +1644,6 @@ PyObject *reason_str = NULL; PyObject *encoding_str = NULL; - if (!uself->object) - /* Not properly initialized. */ - return PyUnicode_FromString(""); - /* Get reason and encoding as strings, which they might not be if they've been modified after we were contructed. */ reason_str = PyObject_Str(uself->reason); @@ -1737,10 +1729,6 @@ PyObject *reason_str = NULL; PyObject *encoding_str = NULL; - if (!uself->object) - /* Not properly initialized. */ - return PyUnicode_FromString(""); - /* Get reason and encoding as strings, which they might not be if they've been modified after we were contructed. */ reason_str = PyObject_Str(uself->reason); @@ -1838,10 +1826,6 @@ PyObject *result = NULL; PyObject *reason_str = NULL; - if (!uself->object) - /* Not properly initialized. */ - return PyUnicode_FromString(""); - /* Get reason as a string, which it might not be if it's been modified after we were contructed. */ reason_str = PyObject_Str(uself->reason); @@ -2127,8 +2111,7 @@ m = Py_InitModule4("exceptions", functions, exceptions_doc, (PyObject *)NULL, PYTHON_API_VERSION); - if (m == NULL) - return; + if (m == NULL) return; bltinmod = PyImport_ImportModule("__builtin__"); if (bltinmod == NULL) @@ -2220,6 +2203,7 @@ Py_FatalError("init of pre-allocated RuntimeError failed"); Py_DECREF(args_tuple); } + Py_DECREF(bltinmod); } diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Objects/fileobject.c --- a/Objects/fileobject.c Sat Jul 19 16:34:33 2014 -0700 +++ b/Objects/fileobject.c Sun Jul 20 10:52:46 2014 -0400 @@ -493,10 +493,9 @@ PyObject * PyFile_FromString(char *name, char *mode) { - extern int fclose(FILE *); PyFileObject *f; - f = (PyFileObject *)PyFile_FromFile((FILE *)NULL, name, mode, fclose); + f = (PyFileObject *)PyFile_FromFile((FILE *)NULL, name, mode, NULL); if (f != NULL) { if (open_the_file(f, name, mode) == NULL) { Py_DECREF(f); @@ -636,13 +635,11 @@ static PyObject * file_repr(PyFileObject *f) { - PyObject *ret = NULL; - PyObject *name = NULL; if (PyUnicode_Check(f->f_name)) { #ifdef Py_USING_UNICODE - const char *name_str; - name = PyUnicode_AsUnicodeEscapeString(f->f_name); - name_str = name ? PyString_AsString(name) : "?"; + PyObject *ret = NULL; + PyObject *name = PyUnicode_AsUnicodeEscapeString(f->f_name); + const char *name_str = name ? PyString_AsString(name) : "?"; ret = PyString_FromFormat("<%s file u'%s', mode '%s' at %p>", f->f_fp == NULL ? "closed" : "open", name_str, @@ -652,16 +649,11 @@ return ret; #endif } else { - name = PyObject_Repr(f->f_name); - if (name == NULL) - return NULL; - ret = PyString_FromFormat("<%s file %s, mode '%s' at %p>", + return PyString_FromFormat("<%s file '%s', mode '%s' at %p>", f->f_fp == NULL ? "closed" : "open", - PyString_AsString(name), + PyString_AsString(f->f_name), PyString_AsString(f->f_mode), f); - Py_XDECREF(name); - return ret; } } @@ -1080,23 +1072,12 @@ return NULL; bytesread = 0; for (;;) { - int interrupted; FILE_BEGIN_ALLOW_THREADS(f) errno = 0; chunksize = Py_UniversalNewlineFread(BUF(v) + bytesread, buffersize - bytesread, f->f_fp, (PyObject *)f); - interrupted = ferror(f->f_fp) && errno == EINTR; FILE_END_ALLOW_THREADS(f) - if (interrupted) { - clearerr(f->f_fp); - if (PyErr_CheckSignals()) { - Py_DECREF(v); - return NULL; - } - } if (chunksize == 0) { - if (interrupted) - continue; if (!ferror(f->f_fp)) break; clearerr(f->f_fp); @@ -1111,7 +1092,7 @@ return NULL; } bytesread += chunksize; - if (bytesread < buffersize && !interrupted) { + if (bytesread < buffersize) { clearerr(f->f_fp); break; } @@ -1152,23 +1133,12 @@ ntodo = pbuf.len; ndone = 0; while (ntodo > 0) { - int interrupted; FILE_BEGIN_ALLOW_THREADS(f) errno = 0; nnow = Py_UniversalNewlineFread(ptr+ndone, ntodo, f->f_fp, (PyObject *)f); - interrupted = ferror(f->f_fp) && errno == EINTR; FILE_END_ALLOW_THREADS(f) - if (interrupted) { - clearerr(f->f_fp); - if (PyErr_CheckSignals()) { - PyBuffer_Release(&pbuf); - return NULL; - } - } if (nnow == 0) { - if (interrupted) - continue; if (!ferror(f->f_fp)) break; PyErr_SetFromErrno(PyExc_IOError); @@ -1456,25 +1426,8 @@ *buf++ = c; if (c == '\n') break; } - if (c == EOF) { - if (ferror(fp) && errno == EINTR) { - FUNLOCKFILE(fp); - FILE_ABORT_ALLOW_THREADS(f) - f->f_newlinetypes = newlinetypes; - f->f_skipnextlf = skipnextlf; - - if (PyErr_CheckSignals()) { - Py_DECREF(v); - return NULL; - } - /* We executed Python signal handlers and got no exception. - * Now back to reading the line where we left off. */ - clearerr(fp); - continue; - } - if (skipnextlf) - newlinetypes |= NEWLINE_CR; - } + if ( c == EOF && skipnextlf ) + newlinetypes |= NEWLINE_CR; } else /* If not universal newlines use the normal loop */ while ((c = GETC(fp)) != EOF && (*buf++ = c) != '\n' && @@ -1488,16 +1441,6 @@ break; if (c == EOF) { if (ferror(fp)) { - if (errno == EINTR) { - if (PyErr_CheckSignals()) { - Py_DECREF(v); - return NULL; - } - /* We executed Python signal handlers and got no exception. - * Now back to reading the line where we left off. */ - clearerr(fp); - continue; - } PyErr_SetFromErrno(PyExc_IOError); clearerr(fp); Py_DECREF(v); @@ -1673,7 +1616,7 @@ size_t totalread = 0; char *p, *q, *end; int err; - int shortread = 0; /* bool, did the previous read come up short? */ + int shortread = 0; if (f->f_fp == NULL) return err_closed(); @@ -1703,14 +1646,6 @@ sizehint = 0; if (!ferror(f->f_fp)) break; - if (errno == EINTR) { - if (PyErr_CheckSignals()) { - goto error; - } - clearerr(f->f_fp); - shortread = 0; - continue; - } PyErr_SetFromErrno(PyExc_IOError); clearerr(f->f_fp); goto error; @@ -1804,7 +1739,6 @@ const char *s; Py_ssize_t n, n2; PyObject *encoded = NULL; - int err_flag = 0, err; if (f->f_fp == NULL) return err_closed(); @@ -1817,6 +1751,7 @@ n = pbuf.len; } else { + const char *encoding, *errors; PyObject *text; if (!PyArg_ParseTuple(args, "O", &text)) return NULL; @@ -1824,9 +1759,7 @@ if (PyString_Check(text)) { s = PyString_AS_STRING(text); n = PyString_GET_SIZE(text); -#ifdef Py_USING_UNICODE } else if (PyUnicode_Check(text)) { - const char *encoding, *errors; if (f->f_encoding != Py_None) encoding = PyString_AS_STRING(f->f_encoding); else @@ -1840,7 +1773,6 @@ return NULL; s = PyString_AS_STRING(encoded); n = PyString_GET_SIZE(encoded); -#endif } else { if (PyObject_AsCharBuffer(text, &s, &n)) return NULL; @@ -1850,16 +1782,11 @@ FILE_BEGIN_ALLOW_THREADS(f) errno = 0; n2 = fwrite(s, 1, n, f->f_fp); - if (n2 != n || ferror(f->f_fp)) { - err_flag = 1; - err = errno; - } FILE_END_ALLOW_THREADS(f) Py_XDECREF(encoded); if (f->f_binary) PyBuffer_Release(&pbuf); - if (err_flag) { - errno = err; + if (n2 != n) { PyErr_SetFromErrno(PyExc_IOError); clearerr(f->f_fp); return NULL; @@ -1941,13 +1868,13 @@ PyObject *v = PyList_GET_ITEM(list, i); if (!PyString_Check(v)) { const char *buffer; - int res; - if (f->f_binary) { - res = PyObject_AsReadBuffer(v, (const void**)&buffer, &len); - } else { - res = PyObject_AsCharBuffer(v, &buffer, &len); - } - if (res) { + if (((f->f_binary && + PyObject_AsReadBuffer(v, + (const void**)&buffer, + &len)) || + PyObject_AsCharBuffer(v, + &buffer, + &len))) { PyErr_SetString(PyExc_TypeError, "writelines() argument must be a sequence of strings"); goto error; @@ -2665,10 +2592,10 @@ PyObject *meth; if (PyInt_Check(o)) { - fd = _PyInt_AsInt(o); + fd = PyInt_AsLong(o); } else if (PyLong_Check(o)) { - fd = _PyLong_AsInt(o); + fd = PyLong_AsLong(o); } else if ((meth = PyObject_GetAttrString(o, "fileno")) != NULL) { @@ -2678,11 +2605,11 @@ return -1; if (PyInt_Check(fno)) { - fd = _PyInt_AsInt(fno); + fd = PyInt_AsLong(fno); Py_DECREF(fno); } else if (PyLong_Check(fno)) { - fd = _PyLong_AsInt(fno); + fd = PyLong_AsLong(fno); Py_DECREF(fno); } else { diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Objects/floatobject.c --- a/Objects/floatobject.c Sat Jul 19 16:34:33 2014 -0700 +++ b/Objects/floatobject.c Sun Jul 20 10:52:46 2014 -0400 @@ -1086,16 +1086,6 @@ char *buf, *buf_end, shortbuf[100], *mybuf=shortbuf; int decpt, sign, val, halfway_case; PyObject *result = NULL; - _Py_SET_53BIT_PRECISION_HEADER; - - /* Easy path for the common case ndigits == 0. */ - if (ndigits == 0) { - rounded = round(x); - if (fabs(rounded - x) == 0.5) - /* halfway between two integers; use round-away-from-zero */ - rounded = x + (x > 0.0 ? 0.5 : -0.5); - return PyFloat_FromDouble(rounded); - } /* The basic idea is very simple: convert and round the double to a decimal string using _Py_dg_dtoa, then convert that decimal string @@ -1152,9 +1142,7 @@ halfway_case = 0; /* round to a decimal string; use an extra place for halfway case */ - _Py_SET_53BIT_PRECISION_START; buf = _Py_dg_dtoa(x, 3, ndigits+halfway_case, &decpt, &sign, &buf_end); - _Py_SET_53BIT_PRECISION_END; if (buf == NULL) { PyErr_NoMemory(); return NULL; @@ -1198,9 +1186,7 @@ /* and convert the resulting string back to a double */ errno = 0; - _Py_SET_53BIT_PRECISION_START; rounded = _Py_dg_strtod(mybuf, NULL); - _Py_SET_53BIT_PRECISION_END; if (errno == ERANGE && fabs(rounded) >= 1.) PyErr_SetString(PyExc_OverflowError, "rounded value too large to represent"); @@ -1783,9 +1769,9 @@ PyDoc_STRVAR(float_as_integer_ratio_doc, "float.as_integer_ratio() -> (int, int)\n" "\n" -"Return a pair of integers, whose ratio is exactly equal to the original\n" +"Returns a pair of integers, whose ratio is exactly equal to the original\n" "float and with a positive denominator.\n" -"Raise OverflowError on infinities and a ValueError on NaNs.\n" +"Raises OverflowError on infinities and a ValueError on NaNs.\n" "\n" ">>> (10.0).as_integer_ratio()\n" "(10, 1)\n" @@ -1970,7 +1956,7 @@ "'IEEE, big-endian' or 'IEEE, little-endian', and in addition can only be\n" "one of the latter two if it appears to match the underlying C reality.\n" "\n" -"Override the automatic determination of C-level floating point type.\n" +"Overrides the automatic determination of C-level floating point type.\n" "This affects how floats are converted to and from binary strings."); static PyObject * @@ -2017,9 +2003,9 @@ static PyMethodDef float_methods[] = { {"conjugate", (PyCFunction)float_float, METH_NOARGS, - "Return self, the complex conjugate of any float."}, + "Returns self, the complex conjugate of any float."}, {"__trunc__", (PyCFunction)float_trunc, METH_NOARGS, - "Return the Integral closest to x between 0 and x."}, + "Returns the Integral closest to x between 0 and x."}, {"as_integer_ratio", (PyCFunction)float_as_integer_ratio, METH_NOARGS, float_as_integer_ratio_doc}, {"fromhex", (PyCFunction)float_fromhex, @@ -2027,14 +2013,14 @@ {"hex", (PyCFunction)float_hex, METH_NOARGS, float_hex_doc}, {"is_integer", (PyCFunction)float_is_integer, METH_NOARGS, - "Return True if the float is an integer."}, + "Returns True if the float is an integer."}, #if 0 {"is_inf", (PyCFunction)float_is_inf, METH_NOARGS, - "Return True if the float is positive or negative infinite."}, + "Returns True if the float is positive or negative infinite."}, {"is_finite", (PyCFunction)float_is_finite, METH_NOARGS, - "Return True if the float is finite, neither infinite nor NaN."}, + "Returns True if the float is finite, neither infinite nor NaN."}, {"is_nan", (PyCFunction)float_is_nan, METH_NOARGS, - "Return True if the float is not a number (NaN)."}, + "Returns True if the float is not a number (NaN)."}, #endif {"__getnewargs__", (PyCFunction)float_getnewargs, METH_NOARGS}, {"__getformat__", (PyCFunction)float_getformat, diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Objects/frameobject.c --- a/Objects/frameobject.c Sat Jul 19 16:34:33 2014 -0700 +++ b/Objects/frameobject.c Sun Jul 20 10:52:46 2014 -0400 @@ -214,7 +214,6 @@ case SETUP_LOOP: case SETUP_EXCEPT: case SETUP_FINALLY: - case SETUP_WITH: blockstack[blockstack_top++] = addr; in_finally[blockstack_top-1] = 0; break; @@ -222,7 +221,7 @@ case POP_BLOCK: assert(blockstack_top > 0); setup_op = code[blockstack[blockstack_top-1]]; - if (setup_op == SETUP_FINALLY || setup_op == SETUP_WITH) { + if (setup_op == SETUP_FINALLY) { in_finally[blockstack_top-1] = 1; } else { @@ -237,7 +236,7 @@ * be seeing such an END_FINALLY.) */ if (blockstack_top > 0) { setup_op = code[blockstack[blockstack_top-1]]; - if (setup_op == SETUP_FINALLY || setup_op == SETUP_WITH) { + if (setup_op == SETUP_FINALLY) { blockstack_top--; } } @@ -299,7 +298,6 @@ case SETUP_LOOP: case SETUP_EXCEPT: case SETUP_FINALLY: - case SETUP_WITH: delta_iblock++; break; diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Objects/funcobject.c --- a/Objects/funcobject.c Sat Jul 19 16:34:33 2014 -0700 +++ b/Objects/funcobject.c Sun Jul 20 10:52:46 2014 -0400 @@ -784,7 +784,9 @@ static int sm_clear(staticmethod *sm) { - Py_CLEAR(sm->sm_callable); + Py_XDECREF(sm->sm_callable); + sm->sm_callable = NULL; + return 0; } diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Objects/genobject.c --- a/Objects/genobject.c Sat Jul 19 16:34:33 2014 -0700 +++ b/Objects/genobject.c Sun Jul 20 10:52:46 2014 -0400 @@ -76,7 +76,6 @@ /* Generators always return to their most recent caller, not * necessarily their creator. */ - f->f_tstate = tstate; Py_XINCREF(tstate->frame); assert(f->f_back == NULL); f->f_back = tstate->frame; @@ -90,8 +89,6 @@ * cycle. */ assert(f->f_back == tstate->frame); Py_CLEAR(f->f_back); - /* Clear the borrowed reference to the thread state */ - f->f_tstate = NULL; /* If the generator just returned (as opposed to yielding), signal * that the generator is exhausted. */ @@ -123,7 +120,7 @@ } PyDoc_STRVAR(close_doc, -"close() -> raise GeneratorExit inside generator."); +"close(arg) -> raise GeneratorExit inside generator."); static PyObject * gen_close(PyGenObject *gen, PyObject *args) diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Objects/intobject.c --- a/Objects/intobject.c Sat Jul 19 16:34:33 2014 -0700 +++ b/Objects/intobject.c Sun Jul 20 10:52:46 2014 -0400 @@ -189,20 +189,6 @@ return val; } -int -_PyInt_AsInt(PyObject *obj) -{ - long result = PyInt_AsLong(obj); - if (result == -1 && PyErr_Occurred()) - return -1; - if (result > INT_MAX || result < INT_MIN) { - PyErr_SetString(PyExc_OverflowError, - "Python int too large to convert to C int"); - return -1; - } - return (int)result; -} - Py_ssize_t PyInt_AsSsize_t(register PyObject *op) { @@ -1073,14 +1059,8 @@ if (!PyArg_ParseTupleAndKeywords(args, kwds, "|Oi:int", kwlist, &x, &base)) return NULL; - if (x == NULL) { - if (base != -909) { - PyErr_SetString(PyExc_TypeError, - "int() missing string argument"); - return NULL; - } + if (x == NULL) return PyInt_FromLong(0L); - } if (base == -909) return PyNumber_Int(x); if (PyString_Check(x)) { @@ -1354,20 +1334,15 @@ }; PyDoc_STRVAR(int_doc, -"int(x=0) -> int or long\n\ -int(x, base=10) -> int or long\n\ +"int(x[, base]) -> integer\n\ \n\ -Convert a number or string to an integer, or return 0 if no arguments\n\ -are given. If x is floating point, the conversion truncates towards zero.\n\ -If x is outside the integer range, the function returns a long instead.\n\ -\n\ -If x is not a number or if base is given, then x must be a string or\n\ -Unicode object representing an integer literal in the given base. The\n\ -literal can be preceded by '+' or '-' and be surrounded by whitespace.\n\ -The base defaults to 10. Valid bases are 0 and 2-36. Base 0 means to\n\ -interpret the base from the string as an integer literal.\n\ ->>> int('0b100', base=0)\n\ -4"); +Convert a string or number to an integer, if possible. A floating point\n\ +argument will be truncated towards zero (this does not include a string\n\ +representation of a floating point number!) When converting a string, use\n\ +the optional base. It is an error to supply a base when converting a\n\ +non-string. If base is zero, the proper base is guessed based on the\n\ +string content. If the argument is outside the integer range a\n\ +long object will be returned instead."); static PyNumberMethods int_as_number = { (binaryfunc)int_add, /*nb_add*/ diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Objects/listsort.txt --- a/Objects/listsort.txt Sat Jul 19 16:34:33 2014 -0700 +++ b/Objects/listsort.txt Sun Jul 20 10:52:46 2014 -0400 @@ -60,7 +60,6 @@ /sort: ascending data 3sort: ascending, then 3 random exchanges +sort: ascending, then 10 random at the end - %sort: ascending, then randomly replace 1% of elements w/ random values ~sort: many duplicates =sort: all equal !sort: worst case scenario @@ -100,13 +99,11 @@ The algorithms are effectively identical in these cases, except that timsort does one less compare in \sort. - Now for the more interesting cases. Where lg(x) is the logarithm of x to - the base 2 (e.g., lg(8)=3), lg(n!) is the information-theoretic limit for - the best any comparison-based sorting algorithm can do on average (across - all permutations). When a method gets significantly below that, it's - either astronomically lucky, or is finding exploitable structure in the - data. - + Now for the more interesting cases. lg(n!) is the information-theoretic + limit for the best any comparison-based sorting algorithm can do on + average (across all permutations). When a method gets significantly + below that, it's either astronomically lucky, or is finding exploitable + structure in the data. n lg(n!) *sort 3sort +sort %sort ~sort !sort ------- ------- ------ ------- ------- ------ ------- -------- @@ -253,7 +250,7 @@ ---------------- If N < 64, minrun is N. IOW, binary insertion sort is used for the whole array then; it's hard to beat that given the overheads of trying something -fancier (see note BINSORT). +fancier. When N is a power of 2, testing on random data showed that minrun values of 16, 32, 64 and 128 worked about equally well. At 256 the data-movement cost @@ -381,10 +378,10 @@ Merge Memory ------------ -Merging adjacent runs of lengths A and B in-place, and in linear time, is -difficult. Theoretical constructions are known that can do it, but they're -too difficult and slow for practical use. But if we have temp memory equal -to min(A, B), it's easy. +Merging adjacent runs of lengths A and B in-place is very difficult. +Theoretical constructions are known that can do it, but they're too difficult +and slow for practical use. But if we have temp memory equal to min(A, B), +it's easy. If A is smaller (function merge_lo), copy A to a temp array, leave B alone, and then we can do the obvious merge algorithm left to right, from the temp @@ -459,10 +456,10 @@ After finding such a k, the region of uncertainty is reduced to 2**(k-1) - 1 consecutive elements, and a straight binary search requires exactly k-1 -additional comparisons to nail it (see note REGION OF UNCERTAINTY). Then we -copy all the B's up to that point in one chunk, and then copy A[0]. Note -that no matter where A[0] belongs in B, the combination of galloping + binary -search finds it in no more than about 2*lg(B) comparisons. +additional comparisons to nail it. Then we copy all the B's up to that +point in one chunk, and then copy A[0]. Note that no matter where A[0] +belongs in B, the combination of galloping + binary search finds it in no +more than about 2*lg(B) comparisons. If we did a straight binary search, we could find it in no more than ceiling(lg(B+1)) comparisons -- but straight binary search takes that many @@ -575,11 +572,11 @@ The description above was for merge_lo. merge_hi has to merge "from the other end", and really needs to gallop starting at the last element in a run instead of the first. Galloping from the first still works, but does more -comparisons than it should (this is significant -- I timed it both ways). For -this reason, the gallop_left() and gallop_right() (see note LEFT OR RIGHT) -functions have a "hint" argument, which is the index at which galloping -should begin. So galloping can actually start at any index, and proceed at -offsets of 1, 3, 7, 15, ... or -1, -3, -7, -15, ... from the starting index. +comparisons than it should (this is significant -- I timed it both ways). +For this reason, the gallop_left() and gallop_right() functions have a +"hint" argument, which is the index at which galloping should begin. So +galloping can actually start at any index, and proceed at offsets of 1, 3, +7, 15, ... or -1, -3, -7, -15, ... from the starting index. In the code as I type it's always called with either 0 or n-1 (where n is the # of elements in a run). It's tempting to try to do something fancier, @@ -678,78 +675,3 @@ [2, 1]. Gratifyingly, timsort doesn't do any special-casing, so had to be taught how to deal with mixtures of ascending and descending runs efficiently in all cases. - - -NOTES ------ - -BINSORT -A "binary insertion sort" is just like a textbook insertion sort, but instead -of locating the correct position of the next item via linear (one at a time) -search, an equivalent to Python's bisect.bisect_right is used to find the -correct position in logarithmic time. Most texts don't mention this -variation, and those that do usually say it's not worth the bother: insertion -sort remains quadratic (expected and worst cases) either way. Speeding the -search doesn't reduce the quadratic data movement costs. - -But in CPython's case, comparisons are extraordinarily expensive compared to -moving data, and the details matter. Moving objects is just copying -pointers. Comparisons can be arbitrarily expensive (can invoke arbitary -user-supplied Python code), but even in simple cases (like 3 < 4) _all_ -decisions are made at runtime: what's the type of the left comparand? the -type of the right? do they need to be coerced to a common type? where's the -code to compare these types? And so on. Even the simplest Python comparison -triggers a large pile of C-level pointer dereferences, conditionals, and -function calls. - -So cutting the number of compares is almost always measurably helpful in -CPython, and the savings swamp the quadratic-time data movement costs for -reasonable minrun values. - - -LEFT OR RIGHT -gallop_left() and gallop_right() are akin to the Python bisect module's -bisect_left() and bisect_right(): they're the same unless the slice they're -searching contains a (at least one) value equal to the value being searched -for. In that case, gallop_left() returns the position immediately before the -leftmost equal value, and gallop_right() the position immediately after the -rightmost equal value. The distinction is needed to preserve stability. In -general, when merging adjacent runs A and B, gallop_left is used to search -thru B for where an element from A belongs, and gallop_right to search thru A -for where an element from B belongs. - - -REGION OF UNCERTAINTY -Two kinds of confusion seem to be common about the claim that after finding -a k such that - - B[2**(k-1) - 1] < A[0] <= B[2**k - 1] - -then a binary search requires exactly k-1 tries to find A[0]'s proper -location. For concreteness, say k=3, so B[3] < A[0] <= B[7]. - -The first confusion takes the form "OK, then the region of uncertainty is at -indices 3, 4, 5, 6 and 7: that's 5 elements, not the claimed 2**(k-1) - 1 = -3"; or the region is viewed as a Python slice and the objection is "but that's -the slice B[3:7], so has 7-3 = 4 elements". Resolution: we've already -compared A[0] against B[3] and against B[7], so A[0]'s correct location is -already known wrt _both_ endpoints. What remains is to find A[0]'s correct -location wrt B[4], B[5] and B[6], which spans 3 elements. Or in general, the -slice (leaving off both endpoints) (2**(k-1)-1)+1 through (2**k-1)-1 -inclusive = 2**(k-1) through (2**k-1)-1 inclusive, which has - (2**k-1)-1 - 2**(k-1) + 1 = - 2**k-1 - 2**(k-1) = - 2*2**k-1 - 2**(k-1) = - (2-1)*2**(k-1) - 1 = - 2**(k-1) - 1 -elements. - -The second confusion: "k-1 = 2 binary searches can find the correct location -among 2**(k-1) = 4 elements, but you're only applying it to 3 elements: we -could make this more efficient by arranging for the region of uncertainty to -span 2**(k-1) elements." Resolution: that confuses "elements" with -"locations". In a slice with N elements, there are N+1 _locations_. In the -example, with the region of uncertainty B[4], B[5], B[6], there are 4 -locations: before B[4], between B[4] and B[5], between B[5] and B[6], and -after B[6]. In general, across 2**(k-1)-1 elements, there are 2**(k-1) -locations. That's why k-1 binary searches are necessary and sufficient. diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Objects/longobject.c --- a/Objects/longobject.c Sat Jul 19 16:34:33 2014 -0700 +++ b/Objects/longobject.c Sun Jul 20 10:52:46 2014 -0400 @@ -339,24 +339,6 @@ return result; } -/* Get a C int from a long int object or any object that has an __int__ - method. Return -1 and set an error if overflow occurs. */ - -int -_PyLong_AsInt(PyObject *obj) -{ - int overflow; - long result = PyLong_AsLongAndOverflow(obj, &overflow); - if (overflow || result > INT_MAX || result < INT_MIN) { - /* XXX: could be cute and give a different - message for overflow == -1 */ - PyErr_SetString(PyExc_OverflowError, - "Python int too large to convert to C int"); - return -1; - } - return (int)result; -} - /* Get a Py_ssize_t from a long int object. Returns -1 and sets an error condition if overflow occurs. */ @@ -3474,16 +3456,10 @@ goto Done; } - /* Reduce base by modulus in some cases: - 1. If base < 0. Forcing the base non-negative makes things easier. - 2. If base is obviously larger than the modulus. The "small - exponent" case later can multiply directly by base repeatedly, - while the "large exponent" case multiplies directly by base 31 - times. It can be unboundedly faster to multiply by - base % modulus instead. - We could _always_ do this reduction, but l_divmod() isn't cheap, - so we only do it when it buys something. */ - if (Py_SIZE(a) < 0 || Py_SIZE(a) > Py_SIZE(c)) { + /* if base < 0: + base = base % modulus + Having the base positive just makes things easier. */ + if (Py_SIZE(a) < 0) { if (l_divmod(a, c, NULL, &temp) < 0) goto Error; Py_DECREF(a); @@ -4011,14 +3987,8 @@ if (!PyArg_ParseTupleAndKeywords(args, kwds, "|Oi:long", kwlist, &x, &base)) return NULL; - if (x == NULL) { - if (base != -909) { - PyErr_SetString(PyExc_TypeError, - "long() missing string argument"); - return NULL; - } + if (x == NULL) return PyLong_FromLong(0L); - } if (base == -909) return PyNumber_Long(x); else if (PyString_Check(x)) { @@ -4251,19 +4221,13 @@ }; PyDoc_STRVAR(long_doc, -"long(x=0) -> long\n\ -long(x, base=10) -> long\n\ +"long(x[, base]) -> integer\n\ \n\ -Convert a number or string to a long integer, or return 0L if no arguments\n\ -are given. If x is floating point, the conversion truncates towards zero.\n\ -\n\ -If x is not a number or if base is given, then x must be a string or\n\ -Unicode object representing an integer literal in the given base. The\n\ -literal can be preceded by '+' or '-' and be surrounded by whitespace.\n\ -The base defaults to 10. Valid bases are 0 and 2-36. Base 0 means to\n\ -interpret the base from the string as an integer literal.\n\ ->>> int('0b100', base=0)\n\ -4L"); +Convert a string or number to a long integer, if possible. A floating\n\ +point argument will be truncated towards zero (this does not include a\n\ +string representation of a floating point number!) When converting a\n\ +string, use the optional base. It is an error to supply a base when\n\ +converting a non-string."); static PyNumberMethods long_as_number = { (binaryfunc)long_add, /*nb_add*/ diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Objects/moduleobject.c --- a/Objects/moduleobject.c Sat Jul 19 16:34:33 2014 -0700 +++ b/Objects/moduleobject.c Sun Jul 20 10:52:46 2014 -0400 @@ -122,8 +122,7 @@ if (s[0] == '_' && s[1] != '_') { if (Py_VerboseFlag > 1) PySys_WriteStderr("# clear[1] %s\n", s); - if (PyDict_SetItem(d, key, Py_None) != 0) - PyErr_Clear(); + PyDict_SetItem(d, key, Py_None); } } } @@ -136,8 +135,7 @@ if (s[0] != '_' || strcmp(s, "__builtins__") != 0) { if (Py_VerboseFlag > 1) PySys_WriteStderr("# clear[2] %s\n", s); - if (PyDict_SetItem(d, key, Py_None) != 0) - PyErr_Clear(); + PyDict_SetItem(d, key, Py_None); } } } diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Objects/object.c --- a/Objects/object.c Sat Jul 19 16:34:33 2014 -0700 +++ b/Objects/object.c Sun Jul 20 10:52:46 2014 -0400 @@ -474,7 +474,7 @@ PyObject *func; PyObject *str; int unicode_method_found = 0; - static PyObject *unicodestr = NULL; + static PyObject *unicodestr; if (v == NULL) { res = PyString_FromString(""); @@ -491,11 +491,6 @@ if (PyInstance_Check(v)) { /* We're an instance of a classic class */ /* Try __unicode__ from the instance -- alas we have no type */ - if (!unicodestr) { - unicodestr = PyString_InternFromString("__unicode__"); - if (!unicodestr) - return NULL; - } func = PyObject_GetAttr(v, unicodestr); if (func != NULL) { unicode_method_found = 1; @@ -1099,8 +1094,6 @@ return -1; } -_Py_HashSecret_t _Py_HashSecret; - long PyObject_Hash(PyObject *v) { @@ -2116,10 +2109,8 @@ if (PyType_Ready(&PySet_Type) < 0) Py_FatalError("Can't initialize set type"); -#ifdef Py_USING_UNICODE if (PyType_Ready(&PyUnicode_Type) < 0) Py_FatalError("Can't initialize unicode type"); -#endif if (PyType_Ready(&PySlice_Type) < 0) Py_FatalError("Can't initialize slice type"); @@ -2203,18 +2194,6 @@ if (PyType_Ready(&PyFile_Type) < 0) Py_FatalError("Can't initialize file type"); - - if (PyType_Ready(&PyCapsule_Type) < 0) - Py_FatalError("Can't initialize capsule type"); - - if (PyType_Ready(&PyCell_Type) < 0) - Py_FatalError("Can't initialize cell type"); - - if (PyType_Ready(&PyCallIter_Type) < 0) - Py_FatalError("Can't initialize call iter type"); - - if (PyType_Ready(&PySeqIter_Type) < 0) - Py_FatalError("Can't initialize sequence iterator type"); } @@ -2445,18 +2424,6 @@ _PyTrash_delete_later = op; } -/* The equivalent API, using per-thread state recursion info */ -void -_PyTrash_thread_deposit_object(PyObject *op) -{ - PyThreadState *tstate = PyThreadState_GET(); - assert(PyObject_IS_GC(op)); - assert(_Py_AS_GC(op)->gc.gc_refs == _PyGC_REFS_UNTRACKED); - assert(op->ob_refcnt == 0); - _Py_AS_GC(op)->gc.gc_prev = (PyGC_Head *) tstate->trash_delete_later; - tstate->trash_delete_later = op; -} - /* Dealloccate all the objects in the _PyTrash_delete_later list. Called when * the call-stack unwinds again. */ @@ -2483,31 +2450,6 @@ } } -/* The equivalent API, using per-thread state recursion info */ -void -_PyTrash_thread_destroy_chain(void) -{ - PyThreadState *tstate = PyThreadState_GET(); - while (tstate->trash_delete_later) { - PyObject *op = tstate->trash_delete_later; - destructor dealloc = Py_TYPE(op)->tp_dealloc; - - tstate->trash_delete_later = - (PyObject*) _Py_AS_GC(op)->gc.gc_prev; - - /* Call the deallocator directly. This used to try to - * fool Py_DECREF into calling it indirectly, but - * Py_DECREF was already called on this object, and in - * assorted non-release builds calling Py_DECREF again ends - * up distorting allocation statistics. - */ - assert(op->ob_refcnt == 0); - ++tstate->trash_delete_nesting; - (*dealloc)(op); - --tstate->trash_delete_nesting; - } -} - #ifdef __cplusplus } #endif diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Objects/obmalloc.c --- a/Objects/obmalloc.c Sat Jul 19 16:34:33 2014 -0700 +++ b/Objects/obmalloc.c Sun Jul 20 10:52:46 2014 -0400 @@ -2,13 +2,6 @@ #ifdef WITH_PYMALLOC -#ifdef HAVE_MMAP - #include - #ifdef MAP_ANONYMOUS - #define ARENAS_USE_MMAP - #endif -#endif - #ifdef WITH_VALGRIND #include @@ -82,8 +75,7 @@ * Allocation strategy abstract: * * For small requests, the allocator sub-allocates blocks of memory. - * Requests greater than SMALL_REQUEST_THRESHOLD bytes are routed to the - * system's allocator. + * Requests greater than 256 bytes are routed to the system's allocator. * * Small requests are grouped in size classes spaced 8 bytes apart, due * to the required valid alignment of the returned address. Requests of @@ -115,11 +107,10 @@ * 57-64 64 7 * 65-72 72 8 * ... ... ... - * 497-504 504 62 - * 505-512 512 63 + * 241-248 248 30 + * 249-256 256 31 * - * 0, SMALL_REQUEST_THRESHOLD + 1 and up: routed to the underlying - * allocator. + * 0, 257 and up: routed to the underlying allocator. */ /*==========================================================================*/ @@ -152,13 +143,10 @@ * 1) ALIGNMENT <= SMALL_REQUEST_THRESHOLD <= 256 * 2) SMALL_REQUEST_THRESHOLD is evenly divisible by ALIGNMENT * - * Note: a size threshold of 512 guarantees that newly created dictionaries - * will be allocated from preallocated memory pools on 64-bit. - * * Although not required, for better performance and space efficiency, * it is recommended that SMALL_REQUEST_THRESHOLD is set to a power of 2. */ -#define SMALL_REQUEST_THRESHOLD 512 +#define SMALL_REQUEST_THRESHOLD 256 #define NB_SMALL_SIZE_CLASSES (SMALL_REQUEST_THRESHOLD / ALIGNMENT) /* @@ -186,15 +174,15 @@ /* * The allocator sub-allocates blocks of memory (called arenas) aligned * on a page boundary. This is a reserved virtual address space for the - * current process (obtained through a malloc()/mmap() call). In no way this - * means that the memory arenas will be used entirely. A malloc() is - * usually an address range reservation for bytes, unless all pages within - * this space are referenced subsequently. So malloc'ing big blocks and not - * using them does not mean "wasting memory". It's an addressable range - * wastage... + * current process (obtained through a malloc call). In no way this means + * that the memory arenas will be used entirely. A malloc() is usually + * an address range reservation for bytes, unless all pages within this + * space are referenced subsequently. So malloc'ing big blocks and not using + * them does not mean "wasting memory". It's an addressable range wastage... * - * Arenas are allocated with mmap() on systems supporting anonymous memory - * mappings to reduce heap fragmentation. + * Therefore, allocating arenas with malloc is not optimal, because there is + * some address space wastage, but this is the most portable way to request + * memory from the system across various platforms. */ #define ARENA_SIZE (256 << 10) /* 256KB */ @@ -452,9 +440,6 @@ , PT(48), PT(49), PT(50), PT(51), PT(52), PT(53), PT(54), PT(55) #if NB_SMALL_SIZE_CLASSES > 56 , PT(56), PT(57), PT(58), PT(59), PT(60), PT(61), PT(62), PT(63) -#if NB_SMALL_SIZE_CLASSES > 64 -#error "NB_SMALL_SIZE_CLASSES should be less than 64" -#endif /* NB_SMALL_SIZE_CLASSES > 64 */ #endif /* NB_SMALL_SIZE_CLASSES > 56 */ #endif /* NB_SMALL_SIZE_CLASSES > 48 */ #endif /* NB_SMALL_SIZE_CLASSES > 40 */ @@ -540,8 +525,6 @@ { struct arena_object* arenaobj; uint excess; /* number of bytes above pool alignment */ - void *address; - int err; #ifdef PYMALLOC_DEBUG if (Py_GETENV("PYTHONMALLOCSTATS")) @@ -594,15 +577,8 @@ arenaobj = unused_arena_objects; unused_arena_objects = arenaobj->nextarena; assert(arenaobj->address == 0); -#ifdef ARENAS_USE_MMAP - address = mmap(NULL, ARENA_SIZE, PROT_READ|PROT_WRITE, - MAP_PRIVATE|MAP_ANONYMOUS, -1, 0); - err = (address == MAP_FAILED); -#else - address = malloc(ARENA_SIZE); - err = (address == 0); -#endif - if (err) { + arenaobj->address = (uptr)malloc(ARENA_SIZE); + if (arenaobj->address == 0) { /* The allocation failed: return NULL after putting the * arenaobj back. */ @@ -610,7 +586,6 @@ unused_arena_objects = arenaobj; return NULL; } - arenaobj->address = (uptr)address; ++narenas_currently_allocated; #ifdef PYMALLOC_DEBUG @@ -1079,11 +1054,7 @@ unused_arena_objects = ao; /* Free the entire arena. */ -#ifdef ARENAS_USE_MMAP - munmap((void *)ao->address, ARENA_SIZE); -#else free((void *)ao->address); -#endif ao->address = 0; /* mark unassociated */ --narenas_currently_allocated; @@ -1742,7 +1713,7 @@ k = 3; do { size_t nextvalue = value / 10; - unsigned int digit = (unsigned int)(value - nextvalue * 10); + uint digit = (uint)(value - nextvalue * 10); value = nextvalue; buf[i--] = (char)(digit + '0'); --k; diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Objects/rangeobject.c --- a/Objects/rangeobject.c Sat Jul 19 16:34:33 2014 -0700 +++ b/Objects/rangeobject.c Sun Jul 20 10:52:46 2014 -0400 @@ -37,30 +37,6 @@ return 0UL; } -/* Return a stop value suitable for reconstructing the xrange from - * a (start, stop, step) triple. Used in range_repr and range_reduce. - * Computes start + len * step, clipped to the range [LONG_MIN, LONG_MAX]. - */ -static long -get_stop_for_range(rangeobject *r) -{ - long last; - - if (r->len == 0) - return r->start; - - /* The tricky bit is avoiding overflow. We first compute the last entry in - the xrange, start + (len - 1) * step, which is guaranteed to lie within - the range of a long, and then add step to it. See the range_reverse - comments for an explanation of the casts below. - */ - last = (long)(r->start + (unsigned long)(r->len - 1) * r->step); - if (r->step > 0) - return last > LONG_MAX - r->step ? LONG_MAX : last + r->step; - else - return last < LONG_MIN - r->step ? LONG_MIN : last + r->step; -} - static PyObject * range_new(PyTypeObject *type, PyObject *args, PyObject *kw) { @@ -104,8 +80,7 @@ } PyDoc_STRVAR(range_doc, -"xrange(stop) -> xrange object\n\ -xrange(start, stop[, step]) -> xrange object\n\ +"xrange([start,] stop[, step]) -> xrange object\n\ \n\ Like range(), but instead of returning a list, returns an object that\n\ generates the numbers in the range on demand. For looping, this is \n\ @@ -137,17 +112,17 @@ if (r->start == 0 && r->step == 1) rtn = PyString_FromFormat("xrange(%ld)", - get_stop_for_range(r)); + r->start + r->len * r->step); else if (r->step == 1) rtn = PyString_FromFormat("xrange(%ld, %ld)", r->start, - get_stop_for_range(r)); + r->start + r->len * r->step); else rtn = PyString_FromFormat("xrange(%ld, %ld, %ld)", r->start, - get_stop_for_range(r), + r->start + r->len * r->step, r->step); return rtn; } @@ -156,9 +131,9 @@ static PyObject * range_reduce(rangeobject *r, PyObject *args) { - return Py_BuildValue("(O(lll))", Py_TYPE(r), + return Py_BuildValue("(O(iii))", Py_TYPE(r), r->start, - get_stop_for_range(r), + r->start + r->len * r->step, r->step); } diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Objects/setobject.c --- a/Objects/setobject.c Sat Jul 19 16:34:33 2014 -0700 +++ b/Objects/setobject.c Sun Jul 20 10:52:46 2014 -0400 @@ -212,6 +212,7 @@ set_insert_key(register PySetObject *so, PyObject *key, long hash) { register setentry *entry; + typedef setentry *(*lookupfunc)(PySetObject *, PyObject *, long); assert(so->lookup != NULL); entry = so->lookup(so, key, hash); @@ -1796,8 +1797,12 @@ PyObject *r1, *r2; if(!PyAnySet_Check(w)) { - Py_INCREF(Py_NotImplemented); - return Py_NotImplemented; + if (op == Py_EQ) + Py_RETURN_FALSE; + if (op == Py_NE) + Py_RETURN_TRUE; + PyErr_SetString(PyExc_TypeError, "can only compare to a set"); + return NULL; } switch (op) { case Py_EQ: diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Objects/sliceobject.c --- a/Objects/sliceobject.c Sat Jul 19 16:34:33 2014 -0700 +++ b/Objects/sliceobject.c Sun Jul 20 10:52:46 2014 -0400 @@ -211,8 +211,7 @@ } PyDoc_STRVAR(slice_doc, -"slice(stop)\n\ -slice(start, stop[, step])\n\ +"slice([start,] stop[, step])\n\ \n\ Create a slice object. This is used for extended slicing (e.g. a[0:10:2])."); diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Objects/stringlib/formatter.h --- a/Objects/stringlib/formatter.h Sat Jul 19 16:34:33 2014 -0700 +++ b/Objects/stringlib/formatter.h Sun Jul 20 10:52:46 2014 -0400 @@ -73,7 +73,7 @@ get_integer(STRINGLIB_CHAR **ptr, STRINGLIB_CHAR *end, Py_ssize_t *result) { - Py_ssize_t accumulator, digitval; + Py_ssize_t accumulator, digitval, oldaccumulator; int numdigits; accumulator = numdigits = 0; for (;;(*ptr)++, numdigits++) { @@ -83,17 +83,19 @@ if (digitval < 0) break; /* - Detect possible overflow before it happens: - - accumulator * 10 + digitval > PY_SSIZE_T_MAX if and only if - accumulator > (PY_SSIZE_T_MAX - digitval) / 10. + This trick was copied from old Unicode format code. It's cute, + but would really suck on an old machine with a slow divide + implementation. Fortunately, in the normal case we do not + expect too many digits. */ - if (accumulator > (PY_SSIZE_T_MAX - digitval) / 10) { + oldaccumulator = accumulator; + accumulator *= 10; + if ((accumulator+10)/10 != oldaccumulator+1) { PyErr_Format(PyExc_ValueError, "Too many decimal digits in format string"); return -1; } - accumulator = accumulator * 10 + digitval; + accumulator += digitval; } *result = accumulator; return numdigits; @@ -180,9 +182,8 @@ Py_ssize_t consumed; int align_specified = 0; - int fill_char_specified = 0; - format->fill_char = ' '; + format->fill_char = '\0'; format->align = default_align; format->alternate = 0; format->sign = '\0'; @@ -196,7 +197,6 @@ if (end-ptr >= 2 && is_alignment_token(ptr[1])) { format->align = ptr[1]; format->fill_char = ptr[0]; - fill_char_specified = 1; align_specified = 1; ptr += 2; } @@ -220,7 +220,7 @@ } /* The special case for 0-padding (backwards compat) */ - if (!fill_char_specified && end-ptr >= 1 && ptr[0] == '0') { + if (format->fill_char == '\0' && end-ptr >= 1 && ptr[0] == '0') { format->fill_char = '0'; if (!align_specified) { format->align = '='; @@ -717,7 +717,8 @@ /* Write into that space. First the padding. */ p = fill_padding(STRINGLIB_STR(result), len, - format->fill_char, lpad, rpad); + format->fill_char=='\0'?' ':format->fill_char, + lpad, rpad); /* Then the source string. */ memcpy(p, STRINGLIB_STR(value), len * sizeof(STRINGLIB_CHAR)); @@ -894,7 +895,8 @@ /* Populate the memory. */ fill_number(STRINGLIB_STR(result), &spec, pnumeric_chars, n_digits, - prefix, format->fill_char, &locale, format->type == 'X'); + prefix, format->fill_char == '\0' ? ' ' : format->fill_char, + &locale, format->type == 'X'); done: Py_XDECREF(tmp); @@ -928,7 +930,7 @@ Py_ssize_t n_total; int has_decimal; double val; - Py_ssize_t precision; + Py_ssize_t precision = format->precision; Py_ssize_t default_precision = 6; STRINGLIB_CHAR type = format->type; int add_pct = 0; @@ -947,12 +949,6 @@ from a hard-code pseudo-locale */ LocaleInfo locale; - if (format->precision > INT_MAX) { - PyErr_SetString(PyExc_ValueError, "precision too big"); - goto done; - } - precision = (int)format->precision; - /* Alternate is not allowed on floats. */ if (format->alternate) { PyErr_SetString(PyExc_ValueError, @@ -1048,7 +1044,8 @@ /* Populate the memory. */ fill_number(STRINGLIB_STR(result), &spec, p, n_digits, NULL, - format->fill_char, &locale, 0); + format->fill_char == '\0' ? ' ' : format->fill_char, &locale, + 0); done: PyMem_Free(buf); @@ -1083,7 +1080,7 @@ Py_ssize_t n_im_total; int re_has_decimal; int im_has_decimal; - Py_ssize_t precision; + Py_ssize_t precision = format->precision; Py_ssize_t default_precision = 6; STRINGLIB_CHAR type = format->type; STRINGLIB_CHAR *p_re; @@ -1112,12 +1109,6 @@ from a hard-code pseudo-locale */ LocaleInfo locale; - if (format->precision > INT_MAX) { - PyErr_SetString(PyExc_ValueError, "precision too big"); - goto done; - } - precision = (int)format->precision; - /* Alternate is not allowed on complex. */ if (format->alternate) { PyErr_SetString(PyExc_ValueError, @@ -1264,7 +1255,8 @@ /* Populate the memory. First, the padding. */ p = fill_padding(STRINGLIB_STR(result), n_re_total + n_im_total + 1 + add_parens * 2, - format->fill_char, lpad, rpad); + format->fill_char=='\0' ? ' ' : format->fill_char, + lpad, rpad); if (add_parens) *p++ = '('; diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Objects/stringlib/string_format.h --- a/Objects/stringlib/string_format.h Sat Jul 19 16:34:33 2014 -0700 +++ b/Objects/stringlib/string_format.h Sun Jul 20 10:52:46 2014 -0400 @@ -197,6 +197,7 @@ { Py_ssize_t accumulator = 0; Py_ssize_t digitval; + Py_ssize_t oldaccumulator; STRINGLIB_CHAR *p; /* empty string is an error */ @@ -208,17 +209,19 @@ if (digitval < 0) return -1; /* - Detect possible overflow before it happens: - - accumulator * 10 + digitval > PY_SSIZE_T_MAX if and only if - accumulator > (PY_SSIZE_T_MAX - digitval) / 10. + This trick was copied from old Unicode format code. It's cute, + but would really suck on an old machine with a slow divide + implementation. Fortunately, in the normal case we do not + expect too many digits. */ - if (accumulator > (PY_SSIZE_T_MAX - digitval) / 10) { + oldaccumulator = accumulator; + accumulator *= 10; + if ((accumulator+10)/10 != oldaccumulator+1) { PyErr_Format(PyExc_ValueError, "Too many decimal digits in format string"); return -1; } - accumulator = accumulator * 10 + digitval; + accumulator += digitval; } return accumulator; } diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Objects/stringlib/transmogrify.h --- a/Objects/stringlib/transmogrify.h Sat Jul 19 16:34:33 2014 -0700 +++ b/Objects/stringlib/transmogrify.h Sun Jul 20 10:52:46 2014 -0400 @@ -15,7 +15,7 @@ { const char *e, *p; char *q; - Py_ssize_t i, j; + size_t i, j; PyObject *u; int tabsize = 8; @@ -25,31 +25,35 @@ /* First pass: determine size of output string */ i = j = 0; e = STRINGLIB_STR(self) + STRINGLIB_LEN(self); - for (p = STRINGLIB_STR(self); p < e; p++) { + for (p = STRINGLIB_STR(self); p < e; p++) if (*p == '\t') { if (tabsize > 0) { - Py_ssize_t incr = tabsize - (j % tabsize); - if (j > PY_SSIZE_T_MAX - incr) - goto overflow; - j += incr; + j += tabsize - (j % tabsize); + if (j > PY_SSIZE_T_MAX) { + PyErr_SetString(PyExc_OverflowError, + "result is too long"); + return NULL; + } } } else { - if (j > PY_SSIZE_T_MAX - 1) - goto overflow; j++; if (*p == '\n' || *p == '\r') { - if (i > PY_SSIZE_T_MAX - j) - goto overflow; i += j; j = 0; + if (i > PY_SSIZE_T_MAX) { + PyErr_SetString(PyExc_OverflowError, + "result is too long"); + return NULL; + } } } + + if ((i + j) > PY_SSIZE_T_MAX) { + PyErr_SetString(PyExc_OverflowError, "result is too long"); + return NULL; } - if (i > PY_SSIZE_T_MAX - j) - goto overflow; - /* Second pass: create output string and fill it */ u = STRINGLIB_NEW(NULL, i + j); if (!u) @@ -58,7 +62,7 @@ j = 0; q = STRINGLIB_STR(u); - for (p = STRINGLIB_STR(self); p < e; p++) { + for (p = STRINGLIB_STR(self); p < e; p++) if (*p == '\t') { if (tabsize > 0) { i = tabsize - (j % tabsize); @@ -73,12 +77,8 @@ if (*p == '\n' || *p == '\r') j = 0; } - } - + return u; - overflow: - PyErr_SetString(PyExc_OverflowError, "result too long"); - return NULL; } Py_LOCAL_INLINE(PyObject *) diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Objects/stringobject.c --- a/Objects/stringobject.c Sat Jul 19 16:34:33 2014 -0700 +++ b/Objects/stringobject.c Sun Jul 20 10:52:46 2014 -0400 @@ -726,10 +726,6 @@ errors); goto failed; } - /* skip \x */ - if (s < end && isxdigit(Py_CHARMASK(s[0]))) - s++; /* and a hexdigit */ - break; #ifndef Py_USING_UNICODE case 'u': case 'U': @@ -748,8 +744,8 @@ UTF-8 bytes may follow. */ } } - if (p-buf < newlen) - _PyString_Resize(&v, p - buf); /* v is cleared on error */ + if (p-buf < newlen && _PyString_Resize(&v, p - buf)) + goto failed; return v; failed: Py_DECREF(v); @@ -882,9 +878,9 @@ size -= chunk_size; } #ifdef __VMS - if (size) fwrite(data, (size_t)size, 1, fp); + if (size) fwrite(data, (int)size, 1, fp); #else - fwrite(data, 1, (size_t)size, fp); + fwrite(data, 1, (int)size, fp); #endif Py_END_ALLOW_THREADS return 0; @@ -1255,6 +1251,7 @@ PyStringObject *a = (PyStringObject*) o1; PyStringObject *b = (PyStringObject*) o2; return Py_SIZE(a) == Py_SIZE(b) + && *a->ob_sval == *b->ob_sval && memcmp(a->ob_sval, b->ob_sval, Py_SIZE(a)) == 0; } @@ -1265,27 +1262,14 @@ register unsigned char *p; register long x; -#ifdef Py_DEBUG - assert(_Py_HashSecret_Initialized); -#endif if (a->ob_shash != -1) return a->ob_shash; len = Py_SIZE(a); - /* - We make the hash of the empty string be 0, rather than using - (prefix ^ suffix), since this slightly obfuscates the hash secret - */ - if (len == 0) { - a->ob_shash = 0; - return 0; - } p = (unsigned char *) a->ob_sval; - x = _Py_HashSecret.prefix; - x ^= *p << 7; + x = *p << 7; while (--len >= 0) x = (1000003*x) ^ *p++; x ^= Py_SIZE(a); - x ^= _Py_HashSecret.suffix; if (x == -1) x = -2; a->ob_shash = x; @@ -2331,7 +2315,7 @@ } Py_LOCAL_INLINE(Py_ssize_t) -countchar(const char *target, Py_ssize_t target_len, char c, Py_ssize_t maxcount) +countchar(const char *target, int target_len, char c, Py_ssize_t maxcount) { Py_ssize_t count=0; const char *start=target; @@ -3091,25 +3075,24 @@ i = 0; /* chars up to and including most recent \n or \r */ j = 0; /* chars since most recent \n or \r (use in tab calculations) */ e = PyString_AS_STRING(self) + PyString_GET_SIZE(self); /* end of input */ - for (p = PyString_AS_STRING(self); p < e; p++) { - if (*p == '\t') { - if (tabsize > 0) { - incr = tabsize - (j % tabsize); - if (j > PY_SSIZE_T_MAX - incr) - goto overflow1; - j += incr; - } + for (p = PyString_AS_STRING(self); p < e; p++) + if (*p == '\t') { + if (tabsize > 0) { + incr = tabsize - (j % tabsize); + if (j > PY_SSIZE_T_MAX - incr) + goto overflow1; + j += incr; } - else { - if (j > PY_SSIZE_T_MAX - 1) + } + else { + if (j > PY_SSIZE_T_MAX - 1) + goto overflow1; + j++; + if (*p == '\n' || *p == '\r') { + if (i > PY_SSIZE_T_MAX - j) goto overflow1; - j++; - if (*p == '\n' || *p == '\r') { - if (i > PY_SSIZE_T_MAX - j) - goto overflow1; - i += j; - j = 0; - } + i += j; + j = 0; } } @@ -3125,26 +3108,25 @@ q = PyString_AS_STRING(u); /* next output char */ qe = PyString_AS_STRING(u) + PyString_GET_SIZE(u); /* end of output */ - for (p = PyString_AS_STRING(self); p < e; p++) { - if (*p == '\t') { - if (tabsize > 0) { - i = tabsize - (j % tabsize); - j += i; - while (i--) { - if (q >= qe) - goto overflow2; - *q++ = ' '; - } + for (p = PyString_AS_STRING(self); p < e; p++) + if (*p == '\t') { + if (tabsize > 0) { + i = tabsize - (j % tabsize); + j += i; + while (i--) { + if (q >= qe) + goto overflow2; + *q++ = ' '; } } - else { - if (q >= qe) - goto overflow2; - *q++ = *p; - j++; - if (*p == '\n' || *p == '\r') - j = 0; - } + } + else { + if (q >= qe) + goto overflow2; + *q++ = *p; + j++; + if (*p == '\n' || *p == '\r') + j = 0; } return u; @@ -3550,7 +3532,7 @@ PyDoc_STRVAR(splitlines__doc__, -"S.splitlines(keepends=False) -> list of strings\n\ +"S.splitlines([keepends]) -> list of strings\n\ \n\ Return a list of the lines in S, breaking at line boundaries.\n\ Line breaks are not included in the resulting list unless keepends\n\ @@ -3804,7 +3786,7 @@ }; PyDoc_STRVAR(string_doc, -"str(object='') -> string\n\ +"str(object) -> string\n\ \n\ Return a nice string representation of the object.\n\ If the argument is a string, the return value is the same object."); @@ -3860,7 +3842,8 @@ if (*pv == NULL) return; if (w == NULL || !PyString_Check(*pv)) { - Py_CLEAR(*pv); + Py_DECREF(*pv); + *pv = NULL; return; } v = string_concat((PyStringObject *) *pv, w); @@ -4258,8 +4241,8 @@ arglen = -1; argidx = -2; } - if (Py_TYPE(args)->tp_as_mapping && Py_TYPE(args)->tp_as_mapping->mp_subscript && - !PyTuple_Check(args) && !PyObject_TypeCheck(args, &PyBaseString_Type)) + if (Py_TYPE(args)->tp_as_mapping && !PyTuple_Check(args) && + !PyObject_TypeCheck(args, &PyBaseString_Type)) dict = args; while (--fmtcnt >= 0) { if (*fmt != '%') { @@ -4359,9 +4342,7 @@ "* wants int"); goto error; } - width = PyInt_AsSsize_t(v); - if (width == -1 && PyErr_Occurred()) - goto error; + width = PyInt_AsLong(v); if (width < 0) { flags |= F_LJUST; width = -width; @@ -4375,7 +4356,7 @@ c = Py_CHARMASK(*fmt++); if (!isdigit(c)) break; - if (width > (PY_SSIZE_T_MAX - ((int)c - '0')) / 10) { + if ((width*10) / 10 != width) { PyErr_SetString( PyExc_ValueError, "width too big"); @@ -4398,9 +4379,7 @@ "* wants int"); goto error; } - prec = _PyInt_AsInt(v); - if (prec == -1 && PyErr_Occurred()) - goto error; + prec = PyInt_AsLong(v); if (prec < 0) prec = 0; if (--fmtcnt >= 0) @@ -4412,7 +4391,7 @@ c = Py_CHARMASK(*fmt++); if (!isdigit(c)) break; - if (prec > (INT_MAX - ((int)c - '0')) / 10) { + if ((prec*10) / 10 != prec) { PyErr_SetString( PyExc_ValueError, "prec too big"); @@ -4497,10 +4476,7 @@ } else { iobj = PyNumber_Int(v); - if (iobj==NULL) { - PyErr_Clear(); - iobj = PyNumber_Long(v); - } + if (iobj==NULL) iobj = PyNumber_Long(v); } if (iobj!=NULL) { if (PyInt_Check(iobj)) { @@ -4790,9 +4766,12 @@ PyString_Fini(void) { int i; - for (i = 0; i < UCHAR_MAX + 1; i++) - Py_CLEAR(characters[i]); - Py_CLEAR(nullstring); + for (i = 0; i < UCHAR_MAX + 1; i++) { + Py_XDECREF(characters[i]); + characters[i] = NULL; + } + Py_XDECREF(nullstring); + nullstring = NULL; } void _Py_ReleaseInternedStrings(void) @@ -4842,5 +4821,6 @@ "mortal/immortal\n", mortal_size, immortal_size); Py_DECREF(keys); PyDict_Clear(interned); - Py_CLEAR(interned); + Py_DECREF(interned); + interned = NULL; } diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Objects/structseq.c --- a/Objects/structseq.c Sat Jul 19 16:34:33 2014 -0700 +++ b/Objects/structseq.c Sun Jul 20 10:52:46 2014 -0400 @@ -175,33 +175,32 @@ if (min_len != max_len) { if (len < min_len) { PyErr_Format(PyExc_TypeError, - "%.500s() takes an at least %zd-sequence (%zd-sequence given)", - type->tp_name, min_len, len); - Py_DECREF(arg); - return NULL; + "%.500s() takes an at least %zd-sequence (%zd-sequence given)", + type->tp_name, min_len, len); + Py_DECREF(arg); + return NULL; } if (len > max_len) { PyErr_Format(PyExc_TypeError, - "%.500s() takes an at most %zd-sequence (%zd-sequence given)", - type->tp_name, max_len, len); - Py_DECREF(arg); - return NULL; + "%.500s() takes an at most %zd-sequence (%zd-sequence given)", + type->tp_name, max_len, len); + Py_DECREF(arg); + return NULL; } } else { if (len != min_len) { PyErr_Format(PyExc_TypeError, - "%.500s() takes a %zd-sequence (%zd-sequence given)", - type->tp_name, min_len, len); - Py_DECREF(arg); - return NULL; + "%.500s() takes a %zd-sequence (%zd-sequence given)", + type->tp_name, min_len, len); + Py_DECREF(arg); + return NULL; } } res = (PyStructSequence*) PyStructSequence_New(type); if (res == NULL) { - Py_DECREF(arg); return NULL; } for (i = 0; i < len; ++i) { diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Objects/tupleobject.c --- a/Objects/tupleobject.c Sat Jul 19 16:34:33 2014 -0700 +++ b/Objects/tupleobject.c Sun Jul 20 10:52:46 2014 -0400 @@ -192,10 +192,8 @@ va_start(vargs, n); result = PyTuple_New(n); - if (result == NULL) { - va_end(vargs); + if (result == NULL) return NULL; - } items = ((PyTupleObject *)result)->ob_item; for (i = 0; i < n; i++) { o = va_arg(vargs, PyObject *); @@ -881,7 +879,8 @@ _Py_ForgetReference((PyObject *) v); /* DECREF items deleted by shrinkage */ for (i = newsize; i < oldsize; i++) { - Py_CLEAR(v->ob_item[i]); + Py_XDECREF(v->ob_item[i]); + v->ob_item[i] = NULL; } sv = PyObject_GC_Resize(PyTupleObject, v, newsize); if (sv == NULL) { @@ -927,7 +926,8 @@ #if PyTuple_MAXSAVESIZE > 0 /* empty tuples are used all over the place and applications may * rely on the fact that an empty tuple is a singleton. */ - Py_CLEAR(free_list[0]); + Py_XDECREF(free_list[0]); + free_list[0] = NULL; (void)PyTuple_ClearFreeList(); #endif diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Objects/typeobject.c --- a/Objects/typeobject.c Sat Jul 19 16:34:33 2014 -0700 +++ b/Objects/typeobject.c Sun Jul 20 10:52:46 2014 -0400 @@ -225,7 +225,6 @@ type_set_name(PyTypeObject *type, PyObject *value, void *context) { PyHeapTypeObject* et; - PyObject *tmp; if (!(type->tp_flags & Py_TPFLAGS_HEAPTYPE)) { PyErr_Format(PyExc_TypeError, @@ -254,13 +253,10 @@ Py_INCREF(value); - /* Wait until et is a sane state before Py_DECREF'ing the old et->ht_name - value. (Bug #16447.) */ - tmp = et->ht_name; + Py_DECREF(et->ht_name); et->ht_name = value; type->tp_name = PyString_AS_STRING(value); - Py_DECREF(tmp); return 0; } @@ -331,15 +327,11 @@ abc.ABCMeta.__new__, so this function doesn't do anything special to update subclasses. */ - int abstract, res; + int res; if (value != NULL) { - abstract = PyObject_IsTrue(value); - if (abstract < 0) - return -1; res = PyDict_SetItemString(type->tp_dict, "__abstractmethods__", value); } else { - abstract = 0; res = PyDict_DelItemString(type->tp_dict, "__abstractmethods__"); if (res && PyErr_ExceptionMatches(PyExc_KeyError)) { PyErr_SetString(PyExc_AttributeError, "__abstractmethods__"); @@ -348,10 +340,12 @@ } if (res == 0) { PyType_Modified(type); - if (abstract) + if (value && PyObject_IsTrue(value)) { type->tp_flags |= Py_TPFLAGS_IS_ABSTRACT; - else + } + else { type->tp_flags &= ~Py_TPFLAGS_IS_ABSTRACT; + } } return res; } @@ -690,10 +684,8 @@ mod = NULL; } name = type_name(type, NULL); - if (name == NULL) { - Py_XDECREF(mod); + if (name == NULL) return NULL; - } if (type->tp_flags & Py_TPFLAGS_HEAPTYPE) kind = "class"; @@ -884,13 +876,8 @@ assert(base); } - /* Clear the instance dict (if any), to break cycles involving only - __dict__ slots (as in the case 'self.__dict__ is self'). */ - if (type->tp_dictoffset != base->tp_dictoffset) { - PyObject **dictptr = _PyObject_GetDictPtr(self); - if (dictptr && *dictptr) - Py_CLEAR(*dictptr); - } + /* There's no need to clear the instance dict (if any); + the collector will call its tp_clear handler. */ if (baseclear) return baseclear(self); @@ -902,7 +889,6 @@ { PyTypeObject *type, *base; destructor basedealloc; - PyThreadState *tstate = PyThreadState_GET(); /* Extract the type; we expect it to be a heap type */ type = Py_TYPE(self); @@ -952,10 +938,8 @@ /* See explanation at end of function for full disclosure */ PyObject_GC_UnTrack(self); ++_PyTrash_delete_nesting; - ++ tstate->trash_delete_nesting; Py_TRASHCAN_SAFE_BEGIN(self); --_PyTrash_delete_nesting; - -- tstate->trash_delete_nesting; /* DO NOT restore GC tracking at this point. weakref callbacks * (if any, and whether directly here or indirectly in something we * call) may trigger GC, and if self is tracked at that point, it @@ -1029,15 +1013,15 @@ assert(basedealloc); basedealloc(self); + PyType_Modified(type); + /* Can't reference self beyond this point */ Py_DECREF(type); endlabel: ++_PyTrash_delete_nesting; - ++ tstate->trash_delete_nesting; Py_TRASHCAN_SAFE_END(self); --_PyTrash_delete_nesting; - -- tstate->trash_delete_nesting; /* Explanation of the weirdness around the trashcan macros: @@ -2543,13 +2527,6 @@ PyObject *meta_attribute, *attribute; descrgetfunc meta_get; - if (!PyString_Check(name)) { - PyErr_Format(PyExc_TypeError, - "attribute name must be string, not '%.200s'", - name->ob_type->tp_name); - return NULL; - } - /* Initialize this type (we'll assume the metatype is initialized) */ if (type->tp_dict == NULL) { if (PyType_Ready(type) < 0) @@ -2730,16 +2707,15 @@ for heaptypes. */ assert(type->tp_flags & Py_TPFLAGS_HEAPTYPE); - /* We need to invalidate the method cache carefully before clearing - the dict, so that other objects caught in a reference cycle - don't start calling destroyed methods. - - Otherwise, the only field we need to clear is tp_mro, which is - part of a hard cycle (its first element is the class itself) that - won't be broken otherwise (it's a tuple and tuples don't have a + /* The only field we need to clear is tp_mro, which is part of a + hard cycle (its first element is the class itself) that won't + be broken otherwise (it's a tuple and tuples don't have a tp_clear handler). None of the other fields need to be cleared, and here's why: + tp_dict: + It is a dict, so the collector will call its tp_clear. + tp_cache: Not used; if it were, it would be a dict. @@ -2756,9 +2732,6 @@ A tuple of strings can't be part of a cycle. */ - PyType_Modified(type); - if (type->tp_dict) - PyDict_Clear(type->tp_dict); Py_CLEAR(type->tp_mro); return 0; @@ -2901,14 +2874,14 @@ type->tp_init != object_init) { err = PyErr_WarnEx(PyExc_DeprecationWarning, - "object() takes no parameters", + "object.__new__() takes no parameters", 1); } else if (type->tp_new != object_new || type->tp_init == object_init) { PyErr_SetString(PyExc_TypeError, - "object() takes no parameters"); + "object.__new__() takes no parameters"); err = -1; } } @@ -2988,10 +2961,8 @@ mod = NULL; } name = type_name(type, NULL); - if (name == NULL) { - Py_XDECREF(mod); + if (name == NULL) return NULL; - } if (mod != NULL && strcmp(PyString_AS_STRING(mod), "__builtin__")) rtn = PyString_FromFormat("<%s.%s object at %p>", PyString_AS_STRING(mod), @@ -3011,7 +2982,7 @@ unaryfunc f; f = Py_TYPE(self)->tp_repr; - if (f == NULL) + if (f == NULL || f == object_str) f = object_repr; return f(self); } @@ -3580,7 +3551,6 @@ for (; meth->ml_name != NULL; meth++) { PyObject *descr; - int err; if (PyDict_GetItemString(dict, meth->ml_name) && !(meth->ml_flags & METH_COEXIST)) continue; @@ -3604,10 +3574,9 @@ } if (descr == NULL) return -1; - err = PyDict_SetItemString(dict, meth->ml_name, descr); + if (PyDict_SetItemString(dict, meth->ml_name, descr) < 0) + return -1; Py_DECREF(descr); - if (err < 0) - return -1; } return 0; } @@ -5799,16 +5768,15 @@ } -/* -Table mapping __foo__ names to tp_foo offsets and slot_tp_foo wrapper functions. - -The table is ordered by offsets relative to the 'PyHeapTypeObject' structure, -which incorporates the additional structures used for numbers, sequences and -mappings. Note that multiple names may map to the same slot (e.g. __eq__, -__ne__ etc. all map to tp_richcompare) and one name may map to multiple slots -(e.g. __str__ affects tp_str as well as tp_repr). The table is terminated with -an all-zero entry. (This table is further initialized in init_slotdefs().) -*/ +/* Table mapping __foo__ names to tp_foo offsets and slot_tp_foo wrapper + functions. The offsets here are relative to the 'PyHeapTypeObject' + structure, which incorporates the additional structures used for numbers, + sequences and mappings. + Note that multiple names may map to the same slot (e.g. __eq__, + __ne__ etc. all map to tp_richcompare) and one name may map to multiple + slots (e.g. __str__ affects tp_str as well as tp_repr). The table is + terminated with an all-zero entry. (This table is further initialized and + sorted in init_slotdefs() below.) */ typedef struct wrapperbase slotdef; @@ -5858,57 +5826,57 @@ "x." NAME "(y) <==> " DOC) static slotdef slotdefs[] = { - TPSLOT("__str__", tp_print, NULL, NULL, ""), - TPSLOT("__repr__", tp_print, NULL, NULL, ""), - TPSLOT("__getattribute__", tp_getattr, NULL, NULL, ""), - TPSLOT("__getattr__", tp_getattr, NULL, NULL, ""), - TPSLOT("__setattr__", tp_setattr, NULL, NULL, ""), - TPSLOT("__delattr__", tp_setattr, NULL, NULL, ""), - TPSLOT("__cmp__", tp_compare, _PyObject_SlotCompare, wrap_cmpfunc, - "x.__cmp__(y) <==> cmp(x,y)"), - TPSLOT("__repr__", tp_repr, slot_tp_repr, wrap_unaryfunc, - "x.__repr__() <==> repr(x)"), - TPSLOT("__hash__", tp_hash, slot_tp_hash, wrap_hashfunc, - "x.__hash__() <==> hash(x)"), - FLSLOT("__call__", tp_call, slot_tp_call, (wrapperfunc)wrap_call, - "x.__call__(...) <==> x(...)", PyWrapperFlag_KEYWORDS), - TPSLOT("__str__", tp_str, slot_tp_str, wrap_unaryfunc, - "x.__str__() <==> str(x)"), - TPSLOT("__getattribute__", tp_getattro, slot_tp_getattr_hook, - wrap_binaryfunc, "x.__getattribute__('name') <==> x.name"), - TPSLOT("__getattr__", tp_getattro, slot_tp_getattr_hook, NULL, ""), - TPSLOT("__setattr__", tp_setattro, slot_tp_setattro, wrap_setattr, - "x.__setattr__('name', value) <==> x.name = value"), - TPSLOT("__delattr__", tp_setattro, slot_tp_setattro, wrap_delattr, - "x.__delattr__('name') <==> del x.name"), - TPSLOT("__lt__", tp_richcompare, slot_tp_richcompare, richcmp_lt, - "x.__lt__(y) <==> x x<=y"), - TPSLOT("__eq__", tp_richcompare, slot_tp_richcompare, richcmp_eq, - "x.__eq__(y) <==> x==y"), - TPSLOT("__ne__", tp_richcompare, slot_tp_richcompare, richcmp_ne, - "x.__ne__(y) <==> x!=y"), - TPSLOT("__gt__", tp_richcompare, slot_tp_richcompare, richcmp_gt, - "x.__gt__(y) <==> x>y"), - TPSLOT("__ge__", tp_richcompare, slot_tp_richcompare, richcmp_ge, - "x.__ge__(y) <==> x>=y"), - TPSLOT("__iter__", tp_iter, slot_tp_iter, wrap_unaryfunc, - "x.__iter__() <==> iter(x)"), - TPSLOT("next", tp_iternext, slot_tp_iternext, wrap_next, - "x.next() -> the next value, or raise StopIteration"), - TPSLOT("__get__", tp_descr_get, slot_tp_descr_get, wrap_descr_get, - "descr.__get__(obj[, type]) -> value"), - TPSLOT("__set__", tp_descr_set, slot_tp_descr_set, wrap_descr_set, - "descr.__set__(obj, value)"), - TPSLOT("__delete__", tp_descr_set, slot_tp_descr_set, - wrap_descr_delete, "descr.__delete__(obj)"), - FLSLOT("__init__", tp_init, slot_tp_init, (wrapperfunc)wrap_init, - "x.__init__(...) initializes x; " - "see help(type(x)) for signature", - PyWrapperFlag_KEYWORDS), - TPSLOT("__new__", tp_new, slot_tp_new, NULL, ""), - TPSLOT("__del__", tp_del, slot_tp_del, NULL, ""), + SQSLOT("__len__", sq_length, slot_sq_length, wrap_lenfunc, + "x.__len__() <==> len(x)"), + /* Heap types defining __add__/__mul__ have sq_concat/sq_repeat == NULL. + The logic in abstract.c always falls back to nb_add/nb_multiply in + this case. Defining both the nb_* and the sq_* slots to call the + user-defined methods has unexpected side-effects, as shown by + test_descr.notimplemented() */ + SQSLOT("__add__", sq_concat, NULL, wrap_binaryfunc, + "x.__add__(y) <==> x+y"), + SQSLOT("__mul__", sq_repeat, NULL, wrap_indexargfunc, + "x.__mul__(n) <==> x*n"), + SQSLOT("__rmul__", sq_repeat, NULL, wrap_indexargfunc, + "x.__rmul__(n) <==> n*x"), + SQSLOT("__getitem__", sq_item, slot_sq_item, wrap_sq_item, + "x.__getitem__(y) <==> x[y]"), + SQSLOT("__getslice__", sq_slice, slot_sq_slice, wrap_ssizessizeargfunc, + "x.__getslice__(i, j) <==> x[i:j]\n\ + \n\ + Use of negative indices is not supported."), + SQSLOT("__setitem__", sq_ass_item, slot_sq_ass_item, wrap_sq_setitem, + "x.__setitem__(i, y) <==> x[i]=y"), + SQSLOT("__delitem__", sq_ass_item, slot_sq_ass_item, wrap_sq_delitem, + "x.__delitem__(y) <==> del x[y]"), + SQSLOT("__setslice__", sq_ass_slice, slot_sq_ass_slice, + wrap_ssizessizeobjargproc, + "x.__setslice__(i, j, y) <==> x[i:j]=y\n\ + \n\ + Use of negative indices is not supported."), + SQSLOT("__delslice__", sq_ass_slice, slot_sq_ass_slice, wrap_delslice, + "x.__delslice__(i, j) <==> del x[i:j]\n\ + \n\ + Use of negative indices is not supported."), + SQSLOT("__contains__", sq_contains, slot_sq_contains, wrap_objobjproc, + "x.__contains__(y) <==> y in x"), + SQSLOT("__iadd__", sq_inplace_concat, NULL, + wrap_binaryfunc, "x.__iadd__(y) <==> x+=y"), + SQSLOT("__imul__", sq_inplace_repeat, NULL, + wrap_indexargfunc, "x.__imul__(y) <==> x*=y"), + + MPSLOT("__len__", mp_length, slot_mp_length, wrap_lenfunc, + "x.__len__() <==> len(x)"), + MPSLOT("__getitem__", mp_subscript, slot_mp_subscript, + wrap_binaryfunc, + "x.__getitem__(y) <==> x[y]"), + MPSLOT("__setitem__", mp_ass_subscript, slot_mp_ass_subscript, + wrap_objobjargproc, + "x.__setitem__(i, y) <==> x[i]=y"), + MPSLOT("__delitem__", mp_ass_subscript, slot_mp_ass_subscript, + wrap_delitem, + "x.__delitem__(y) <==> del x[y]"), + BINSLOT("__add__", nb_add, slot_nb_add, "+"), RBINSLOT("__radd__", nb_add, slot_nb_add, @@ -5966,6 +5934,8 @@ "oct(x)"), UNSLOT("__hex__", nb_hex, slot_nb_hex, wrap_unaryfunc, "hex(x)"), + NBSLOT("__index__", nb_index, slot_nb_index, wrap_unaryfunc, + "x[y:z] <==> x[y.__index__():z.__index__()]"), IBSLOT("__iadd__", nb_inplace_add, slot_nb_inplace_add, wrap_binaryfunc, "+="), IBSLOT("__isub__", nb_inplace_subtract, slot_nb_inplace_subtract, @@ -5996,57 +5966,58 @@ slot_nb_inplace_floor_divide, wrap_binaryfunc, "//"), IBSLOT("__itruediv__", nb_inplace_true_divide, slot_nb_inplace_true_divide, wrap_binaryfunc, "/"), - NBSLOT("__index__", nb_index, slot_nb_index, wrap_unaryfunc, - "x[y:z] <==> x[y.__index__():z.__index__()]"), - MPSLOT("__len__", mp_length, slot_mp_length, wrap_lenfunc, - "x.__len__() <==> len(x)"), - MPSLOT("__getitem__", mp_subscript, slot_mp_subscript, - wrap_binaryfunc, - "x.__getitem__(y) <==> x[y]"), - MPSLOT("__setitem__", mp_ass_subscript, slot_mp_ass_subscript, - wrap_objobjargproc, - "x.__setitem__(i, y) <==> x[i]=y"), - MPSLOT("__delitem__", mp_ass_subscript, slot_mp_ass_subscript, - wrap_delitem, - "x.__delitem__(y) <==> del x[y]"), - SQSLOT("__len__", sq_length, slot_sq_length, wrap_lenfunc, - "x.__len__() <==> len(x)"), - /* Heap types defining __add__/__mul__ have sq_concat/sq_repeat == NULL. - The logic in abstract.c always falls back to nb_add/nb_multiply in - this case. Defining both the nb_* and the sq_* slots to call the - user-defined methods has unexpected side-effects, as shown by - test_descr.notimplemented() */ - SQSLOT("__add__", sq_concat, NULL, wrap_binaryfunc, - "x.__add__(y) <==> x+y"), - SQSLOT("__mul__", sq_repeat, NULL, wrap_indexargfunc, - "x.__mul__(n) <==> x*n"), - SQSLOT("__rmul__", sq_repeat, NULL, wrap_indexargfunc, - "x.__rmul__(n) <==> n*x"), - SQSLOT("__getitem__", sq_item, slot_sq_item, wrap_sq_item, - "x.__getitem__(y) <==> x[y]"), - SQSLOT("__getslice__", sq_slice, slot_sq_slice, wrap_ssizessizeargfunc, - "x.__getslice__(i, j) <==> x[i:j]\n\ - \n\ - Use of negative indices is not supported."), - SQSLOT("__setitem__", sq_ass_item, slot_sq_ass_item, wrap_sq_setitem, - "x.__setitem__(i, y) <==> x[i]=y"), - SQSLOT("__delitem__", sq_ass_item, slot_sq_ass_item, wrap_sq_delitem, - "x.__delitem__(y) <==> del x[y]"), - SQSLOT("__setslice__", sq_ass_slice, slot_sq_ass_slice, - wrap_ssizessizeobjargproc, - "x.__setslice__(i, j, y) <==> x[i:j]=y\n\ - \n\ - Use of negative indices is not supported."), - SQSLOT("__delslice__", sq_ass_slice, slot_sq_ass_slice, wrap_delslice, - "x.__delslice__(i, j) <==> del x[i:j]\n\ - \n\ - Use of negative indices is not supported."), - SQSLOT("__contains__", sq_contains, slot_sq_contains, wrap_objobjproc, - "x.__contains__(y) <==> y in x"), - SQSLOT("__iadd__", sq_inplace_concat, NULL, - wrap_binaryfunc, "x.__iadd__(y) <==> x+=y"), - SQSLOT("__imul__", sq_inplace_repeat, NULL, - wrap_indexargfunc, "x.__imul__(y) <==> x*=y"), + + TPSLOT("__str__", tp_str, slot_tp_str, wrap_unaryfunc, + "x.__str__() <==> str(x)"), + TPSLOT("__str__", tp_print, NULL, NULL, ""), + TPSLOT("__repr__", tp_repr, slot_tp_repr, wrap_unaryfunc, + "x.__repr__() <==> repr(x)"), + TPSLOT("__repr__", tp_print, NULL, NULL, ""), + TPSLOT("__cmp__", tp_compare, _PyObject_SlotCompare, wrap_cmpfunc, + "x.__cmp__(y) <==> cmp(x,y)"), + TPSLOT("__hash__", tp_hash, slot_tp_hash, wrap_hashfunc, + "x.__hash__() <==> hash(x)"), + FLSLOT("__call__", tp_call, slot_tp_call, (wrapperfunc)wrap_call, + "x.__call__(...) <==> x(...)", PyWrapperFlag_KEYWORDS), + TPSLOT("__getattribute__", tp_getattro, slot_tp_getattr_hook, + wrap_binaryfunc, "x.__getattribute__('name') <==> x.name"), + TPSLOT("__getattribute__", tp_getattr, NULL, NULL, ""), + TPSLOT("__getattr__", tp_getattro, slot_tp_getattr_hook, NULL, ""), + TPSLOT("__getattr__", tp_getattr, NULL, NULL, ""), + TPSLOT("__setattr__", tp_setattro, slot_tp_setattro, wrap_setattr, + "x.__setattr__('name', value) <==> x.name = value"), + TPSLOT("__setattr__", tp_setattr, NULL, NULL, ""), + TPSLOT("__delattr__", tp_setattro, slot_tp_setattro, wrap_delattr, + "x.__delattr__('name') <==> del x.name"), + TPSLOT("__delattr__", tp_setattr, NULL, NULL, ""), + TPSLOT("__lt__", tp_richcompare, slot_tp_richcompare, richcmp_lt, + "x.__lt__(y) <==> x x<=y"), + TPSLOT("__eq__", tp_richcompare, slot_tp_richcompare, richcmp_eq, + "x.__eq__(y) <==> x==y"), + TPSLOT("__ne__", tp_richcompare, slot_tp_richcompare, richcmp_ne, + "x.__ne__(y) <==> x!=y"), + TPSLOT("__gt__", tp_richcompare, slot_tp_richcompare, richcmp_gt, + "x.__gt__(y) <==> x>y"), + TPSLOT("__ge__", tp_richcompare, slot_tp_richcompare, richcmp_ge, + "x.__ge__(y) <==> x>=y"), + TPSLOT("__iter__", tp_iter, slot_tp_iter, wrap_unaryfunc, + "x.__iter__() <==> iter(x)"), + TPSLOT("next", tp_iternext, slot_tp_iternext, wrap_next, + "x.next() -> the next value, or raise StopIteration"), + TPSLOT("__get__", tp_descr_get, slot_tp_descr_get, wrap_descr_get, + "descr.__get__(obj[, type]) -> value"), + TPSLOT("__set__", tp_descr_set, slot_tp_descr_set, wrap_descr_set, + "descr.__set__(obj, value)"), + TPSLOT("__delete__", tp_descr_set, slot_tp_descr_set, + wrap_descr_delete, "descr.__delete__(obj)"), + FLSLOT("__init__", tp_init, slot_tp_init, (wrapperfunc)wrap_init, + "x.__init__(...) initializes x; " + "see help(type(x)) for signature", + PyWrapperFlag_KEYWORDS), + TPSLOT("__new__", tp_new, slot_tp_new, NULL, ""), + TPSLOT("__del__", tp_del, slot_tp_del, NULL, ""), {NULL} }; @@ -6158,8 +6129,7 @@ } continue; } - if (Py_TYPE(descr) == &PyWrapperDescr_Type && - ((PyWrapperDescrObject *)descr)->d_base->name_strobj == p->name_strobj) { + if (Py_TYPE(descr) == &PyWrapperDescr_Type) { void **tptr = resolve_slotdups(type, p->name_strobj); if (tptr == NULL || tptr == ptr) generic = p->function; @@ -6227,6 +6197,21 @@ return 0; } +/* Comparison function for qsort() to compare slotdefs by their offset, and + for equal offset by their address (to force a stable sort). */ +static int +slotdef_cmp(const void *aa, const void *bb) +{ + const slotdef *a = (const slotdef *)aa, *b = (const slotdef *)bb; + int c = a->offset - b->offset; + if (c != 0) + return c; + else + /* Cannot use a-b, as this gives off_t, + which may lose precision when converted to int. */ + return (a > b) ? 1 : (a < b) ? -1 : 0; +} + /* Initialize the slotdefs table by adding interned string objects for the names and sorting the entries. */ static void @@ -6238,12 +6223,12 @@ if (initialized) return; for (p = slotdefs; p->name; p++) { - /* Slots must be ordered by their offset in the PyHeapTypeObject. */ - assert(!p[1].name || p->offset <= p[1].offset); p->name_strobj = PyString_InternFromString(p->name); if (!p->name_strobj) Py_FatalError("Out of memory interning slotdef names"); } + qsort((void *)slotdefs, (size_t)(p-slotdefs), sizeof(slotdef), + slotdef_cmp); initialized = 1; } @@ -6666,8 +6651,8 @@ } PyDoc_STRVAR(super_doc, +"super(type) -> unbound super object\n" "super(type, obj) -> bound super object; requires isinstance(obj, type)\n" -"super(type) -> unbound super object\n" "super(type, type2) -> bound super object; requires issubclass(type2, type)\n" "Typical use to call a cooperative superclass method:\n" "class C(B):\n" diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Objects/unicodeobject.c --- a/Objects/unicodeobject.c Sat Jul 19 16:34:33 2014 -0700 +++ b/Objects/unicodeobject.c Sun Jul 20 10:52:46 2014 -0400 @@ -82,9 +82,8 @@ /* --- Globals ------------------------------------------------------------ -NOTE: In the interpreter's initialization phase, some globals are currently - initialized dynamically as needed. In the process Unicode objects may - be created before the Unicode type is ready. + The globals are initialized by the _PyUnicode_Init() API and should + not be used before calling that API. */ @@ -94,27 +93,15 @@ #endif /* Free list for Unicode objects */ -static PyUnicodeObject *free_list = NULL; -static int numfree = 0; +static PyUnicodeObject *free_list; +static int numfree; /* The empty Unicode object is shared to improve performance. */ -static PyUnicodeObject *unicode_empty = NULL; - -#define _Py_RETURN_UNICODE_EMPTY() \ - do { \ - if (unicode_empty != NULL) \ - Py_INCREF(unicode_empty); \ - else { \ - unicode_empty = _PyUnicode_New(0); \ - if (unicode_empty != NULL) \ - Py_INCREF(unicode_empty); \ - } \ - return (PyObject *)unicode_empty; \ - } while (0) +static PyUnicodeObject *unicode_empty; /* Single character Unicode strings in the Latin-1 range are being shared as well. */ -static PyUnicodeObject *unicode_latin1[256] = {NULL}; +static PyUnicodeObject *unicode_latin1[256]; /* Default encoding to use and assume when NULL is passed as encoding parameter; it is initialized by _PyUnicode_Init(). @@ -123,7 +110,7 @@ PyUnicode_GetDefaultEncoding() APIs to access this global. */ -static char unicode_default_encoding[100 + 1] = "ascii"; +static char unicode_default_encoding[100]; /* Fast detection of the most frequent whitespace characters */ const unsigned char _Py_ascii_whitespace[] = { @@ -217,7 +204,7 @@ #define BLOOM_MASK unsigned long -static BLOOM_MASK bloom_linebreak = ~(BLOOM_MASK)0; +static BLOOM_MASK bloom_linebreak; #define BLOOM_ADD(mask, ch) ((mask |= (1UL << ((ch) & (BLOOM_WIDTH - 1))))) #define BLOOM(mask, ch) ((mask & (1UL << ((ch) & (BLOOM_WIDTH - 1))))) @@ -461,8 +448,10 @@ if (u != NULL) { /* Optimization for empty strings */ - if (size == 0) - _Py_RETURN_UNICODE_EMPTY(); + if (size == 0 && unicode_empty != NULL) { + Py_INCREF(unicode_empty); + return (PyObject *)unicode_empty; + } /* Single character Unicode objects in the Latin-1 range are shared when using this constructor */ @@ -508,8 +497,10 @@ if (u != NULL) { /* Optimization for empty strings */ - if (size == 0) - _Py_RETURN_UNICODE_EMPTY(); + if (size == 0 && unicode_empty != NULL) { + Py_INCREF(unicode_empty); + return (PyObject *)unicode_empty; + } /* Single characters are shared when using this constructor. Restrict to ASCII, since the input must be UTF-8. */ @@ -547,37 +538,6 @@ return PyUnicode_FromStringAndSize(u, size); } -/* _Py_UNICODE_NEXT is a private macro used to retrieve the character pointed - * by 'ptr', possibly combining surrogate pairs on narrow builds. - * 'ptr' and 'end' must be Py_UNICODE*, with 'ptr' pointing at the character - * that should be returned and 'end' pointing to the end of the buffer. - * ('end' is used on narrow builds to detect a lone surrogate at the - * end of the buffer that should be returned unchanged.) - * The ptr and end arguments should be side-effect free and ptr must an lvalue. - * The type of the returned char is always Py_UCS4. - * - * Note: the macro advances ptr to next char, so it might have side-effects - * (especially if used with other macros). - */ - -/* helper macros used by _Py_UNICODE_NEXT */ -#define _Py_UNICODE_IS_HIGH_SURROGATE(ch) (0xD800 <= ch && ch <= 0xDBFF) -#define _Py_UNICODE_IS_LOW_SURROGATE(ch) (0xDC00 <= ch && ch <= 0xDFFF) -/* Join two surrogate characters and return a single Py_UCS4 value. */ -#define _Py_UNICODE_JOIN_SURROGATES(high, low) \ - (((((Py_UCS4)(high) & 0x03FF) << 10) | \ - ((Py_UCS4)(low) & 0x03FF)) + 0x10000) - -#ifdef Py_UNICODE_WIDE -#define _Py_UNICODE_NEXT(ptr, end) *(ptr)++ -#else -#define _Py_UNICODE_NEXT(ptr, end) \ - (((_Py_UNICODE_IS_HIGH_SURROGATE(*(ptr)) && (ptr) < (end)) && \ - _Py_UNICODE_IS_LOW_SURROGATE((ptr)[1])) ? \ - ((ptr) += 2,_Py_UNICODE_JOIN_SURROGATES((ptr)[-2], (ptr)[-1])) : \ - (Py_UCS4)*(ptr)++) -#endif - #ifdef HAVE_WCHAR_H #if (Py_UNICODE_SIZE == 2) && defined(SIZEOF_WCHAR_T) && (SIZEOF_WCHAR_T == 4) @@ -771,25 +731,8 @@ switch (*f) { case 'c': - { - int ordinal = va_arg(count, int); -#ifdef Py_UNICODE_WIDE - if (ordinal < 0 || ordinal > 0x10ffff) { - PyErr_SetString(PyExc_OverflowError, - "%c arg not in range(0x110000) " - "(wide Python build)"); - goto fail; - } -#else - if (ordinal < 0 || ordinal > 0xffff) { - PyErr_SetString(PyExc_OverflowError, - "%c arg not in range(0x10000) " - "(narrow Python build)"); - goto fail; - } -#endif + (void)va_arg(count, int); /* fall through... */ - } case '%': n++; break; @@ -1219,10 +1162,13 @@ } /* Convert to Unicode */ - if (len == 0) - _Py_RETURN_UNICODE_EMPTY(); - - v = PyUnicode_Decode(s, len, encoding, errors); + if (len == 0) { + Py_INCREF(unicode_empty); + v = (PyObject *)unicode_empty; + } + else + v = PyUnicode_Decode(s, len, encoding, errors); + return v; onError: @@ -1435,7 +1381,7 @@ Py_DECREF(v); strncpy(unicode_default_encoding, encoding, - sizeof(unicode_default_encoding) - 1); + sizeof(unicode_default_encoding)); return 0; onError: @@ -1671,7 +1617,6 @@ (base64buffer >> (base64bits-16)); base64bits -= 16; base64buffer &= (1 << base64bits) - 1; /* clear high bits */ - assert(outCh <= 0xffff); if (surrogate) { /* expecting a second surrogate */ if (outCh >= 0xDC00 && outCh <= 0xDFFF) { @@ -1738,7 +1683,6 @@ inShift = 1; shiftOutStart = p; base64bits = 0; - base64buffer = 0; } } else if (DECODE_DIRECT(ch)) { /* character decodes as itself */ @@ -1917,7 +1861,7 @@ illegal prefix. See RFC 3629 for details */ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* 00-0F */ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, @@ -2273,7 +2217,7 @@ #endif PyObject *errorHandler = NULL; PyObject *exc = NULL; - + q = (unsigned char *)s; e = q + size; @@ -2328,7 +2272,7 @@ /* On narrow builds we split characters outside the BMP into two codepoints => count how much extra space we need. */ #ifndef Py_UNICODE_WIDE - for (qq = q; e - qq >= 4; qq += 4) + for (qq = q; qq < e; qq += 4) if (qq[iorder[2]] != 0 || qq[iorder[3]] != 0) pairs++; #endif @@ -2620,12 +2564,9 @@ } /* UTF-16 code pair: */ - if (e - q < 2) { - q -= 2; - if (consumed) - break; + if (q >= e) { errmsg = "unexpected end of data"; - startinpos = ((const char *)q)-starts; + startinpos = (((const char *)q)-2)-starts; endinpos = ((const char *)e)-starts; goto utf16Error; } @@ -2788,6 +2729,7 @@ Py_ssize_t startinpos; Py_ssize_t endinpos; Py_ssize_t outpos; + int i; PyUnicodeObject *v; Py_UNICODE *p; const char *end; @@ -2873,19 +2815,29 @@ message = "truncated \\UXXXXXXXX escape"; hexescape: chr = 0; - if (end - s < digits) { - /* count only hex digits */ - for (; s < end; ++s) { - c = (unsigned char)*s; - if (!Py_ISXDIGIT(c)) - goto error; + outpos = p-PyUnicode_AS_UNICODE(v); + if (s+digits>end) { + endinpos = size; + if (unicode_decode_call_errorhandler( + errors, &errorHandler, + "unicodeescape", "end of string in escape sequence", + starts, size, &startinpos, &endinpos, &exc, &s, + &v, &outpos, &p)) + goto onError; + goto nextByte; + } + for (i = 0; i < digits; ++i) { + c = (unsigned char) s[i]; + if (!isxdigit(c)) { + endinpos = (s+i+1)-starts; + if (unicode_decode_call_errorhandler( + errors, &errorHandler, + "unicodeescape", message, + starts, size, &startinpos, &endinpos, &exc, &s, + &v, &outpos, &p)) + goto onError; + goto nextByte; } - goto error; - } - for (; digits--; ++s) { - c = (unsigned char)*s; - if (!Py_ISXDIGIT(c)) - goto error; chr = (chr<<4) & ~0xF; if (c >= '0' && c <= '9') chr += c - '0'; @@ -2894,6 +2846,7 @@ else chr += 10 + c - 'A'; } + s += i; if (chr == 0xffffffff && PyErr_Occurred()) /* _decoding_error will have already written into the target buffer. */ @@ -2914,8 +2867,14 @@ *p++ = 0xDC00 + (Py_UNICODE) (chr & 0x03FF); #endif } else { - message = "illegal Unicode character"; - goto error; + endinpos = s-starts; + outpos = p-PyUnicode_AS_UNICODE(v); + if (unicode_decode_call_errorhandler( + errors, &errorHandler, + "unicodeescape", "illegal Unicode character", + starts, size, &startinpos, &endinpos, &exc, &s, + &v, &outpos, &p)) + goto onError; } break; @@ -2937,18 +2896,32 @@ /* found a name. look it up in the unicode database */ message = "unknown Unicode character name"; s++; - if (s - start - 1 <= INT_MAX && - ucnhash_CAPI->getcode(NULL, start, (int)(s-start-1), &chr)) + if (ucnhash_CAPI->getcode(NULL, start, (int)(s-start-1), &chr)) goto store; } } - goto error; + endinpos = s-starts; + outpos = p-PyUnicode_AS_UNICODE(v); + if (unicode_decode_call_errorhandler( + errors, &errorHandler, + "unicodeescape", message, + starts, size, &startinpos, &endinpos, &exc, &s, + &v, &outpos, &p)) + goto onError; + break; default: if (s > end) { message = "\\ at end of string"; s--; - goto error; + endinpos = s-starts; + outpos = p-PyUnicode_AS_UNICODE(v); + if (unicode_decode_call_errorhandler( + errors, &errorHandler, + "unicodeescape", message, + starts, size, &startinpos, &endinpos, &exc, &s, + &v, &outpos, &p)) + goto onError; } else { *p++ = '\\'; @@ -2956,18 +2929,8 @@ } break; } - continue; - - error: - endinpos = s-starts; - outpos = p-PyUnicode_AS_UNICODE(v); - if (unicode_decode_call_errorhandler( - errors, &errorHandler, - "unicodeescape", message, - starts, size, &startinpos, &endinpos, &exc, &s, - &v, &outpos, &p)) - goto onError; - continue; + nextByte: + ; } if (_PyUnicode_Resize(&v, p - PyUnicode_AS_UNICODE(v)) < 0) goto onError; @@ -3426,34 +3389,37 @@ end = s + size; while (s < end) { - if (end-s < Py_UNICODE_SIZE) { - endinpos = end-starts; - reason = "truncated input"; - goto error; - } memcpy(p, s, sizeof(Py_UNICODE)); -#ifdef Py_UNICODE_WIDE /* We have to sanity check the raw data, otherwise doom looms for some malformed UCS-4 data. */ - if (*p > unimax || *p < 0) { - endinpos = s - starts + Py_UNICODE_SIZE; - reason = "illegal code point (> 0x10FFFF)"; - goto error; - } + if ( +#ifdef Py_UNICODE_WIDE + *p > unimax || *p < 0 || #endif - p++; - s += Py_UNICODE_SIZE; - continue; - - error: - startinpos = s - starts; - outpos = p - PyUnicode_AS_UNICODE(v); - if (unicode_decode_call_errorhandler( - errors, &errorHandler, - "unicode_internal", reason, - starts, size, &startinpos, &endinpos, &exc, &s, - &v, &outpos, &p)) { - goto onError; + end-s < Py_UNICODE_SIZE + ) + { + startinpos = s - starts; + if (end-s < Py_UNICODE_SIZE) { + endinpos = end-starts; + reason = "truncated input"; + } + else { + endinpos = s - starts + Py_UNICODE_SIZE; + reason = "illegal code point (> 0x10FFFF)"; + } + outpos = p - PyUnicode_AS_UNICODE(v); + if (unicode_decode_call_errorhandler( + errors, &errorHandler, + "unicode_internal", reason, + starts, size, &startinpos, &endinpos, &exc, &s, + &v, &outpos, &p)) { + goto onError; + } + } + else { + p++; + s += Py_UNICODE_SIZE; } } @@ -3520,7 +3486,8 @@ goto onError; return; onError: - Py_CLEAR(*exceptionObject); + Py_DECREF(*exceptionObject); + *exceptionObject = NULL; } } @@ -3674,22 +3641,26 @@ case 4: /* xmlcharrefreplace */ respos = str-PyString_AS_STRING(res); /* determine replacement size (temporarily (mis)uses p) */ - for (p = collstart, repsize = 0; p < collend;) { - Py_UCS4 ch = _Py_UNICODE_NEXT(p, collend); - if (ch < 10) + for (p = collstart, repsize = 0; p < collend; ++p) { + if (*p<10) repsize += 2+1+1; - else if (ch < 100) + else if (*p<100) repsize += 2+2+1; - else if (ch < 1000) + else if (*p<1000) repsize += 2+3+1; - else if (ch < 10000) + else if (*p<10000) repsize += 2+4+1; - else if (ch < 100000) +#ifndef Py_UNICODE_WIDE + else repsize += 2+5+1; - else if (ch < 1000000) +#else + else if (*p<100000) + repsize += 2+5+1; + else if (*p<1000000) repsize += 2+6+1; else repsize += 2+7+1; +#endif } requiredsize = respos+repsize+(endp-collend); if (requiredsize > ressize) { @@ -3701,9 +3672,8 @@ ressize = requiredsize; } /* generate replacement (temporarily (mis)uses p) */ - for (p = collstart; p < collend;) { - Py_UCS4 ch = _Py_UNICODE_NEXT(p, collend); - str += sprintf(str, "&#%d;", (int)ch); + for (p = collstart; p < collend; ++p) { + str += sprintf(str, "&#%d;", (int)*p); } p = collend; break; @@ -4148,60 +4118,46 @@ if (PyErr_ExceptionMatches(PyExc_LookupError)) { /* No mapping found means: mapping is undefined. */ PyErr_Clear(); - goto Undefined; + x = Py_None; + Py_INCREF(x); } else goto onError; } /* Apply mapping */ - if (x == Py_None) - goto Undefined; if (PyInt_Check(x)) { long value = PyInt_AS_LONG(x); - if (value == 0xFFFE) - goto Undefined; - if (value < 0 || value > 0x10FFFF) { + if (value < 0 || value > 65535) { PyErr_SetString(PyExc_TypeError, - "character mapping must be in range(0x110000)"); + "character mapping must be in range(65536)"); Py_DECREF(x); goto onError; } - -#ifndef Py_UNICODE_WIDE - if (value > 0xFFFF) { - /* see the code for 1-n mapping below */ - if (extrachars < 2) { - /* resize first */ - Py_ssize_t oldpos = p - PyUnicode_AS_UNICODE(v); - Py_ssize_t needed = 10 - extrachars; - extrachars += needed; - /* XXX overflow detection missing */ - if (_PyUnicode_Resize(&v, - PyUnicode_GET_SIZE(v) + needed) < 0) { - Py_DECREF(x); - goto onError; - } - p = PyUnicode_AS_UNICODE(v) + oldpos; - } - value -= 0x10000; - *p++ = 0xD800 | (value >> 10); - *p++ = 0xDC00 | (value & 0x3FF); - extrachars -= 2; + *p++ = (Py_UNICODE)value; + } + else if (x == Py_None) { + /* undefined mapping */ + outpos = p-PyUnicode_AS_UNICODE(v); + startinpos = s-starts; + endinpos = startinpos+1; + if (unicode_decode_call_errorhandler( + errors, &errorHandler, + "charmap", "character maps to ", + starts, size, &startinpos, &endinpos, &exc, &s, + &v, &outpos, &p)) { + Py_DECREF(x); + goto onError; } - else -#endif - *p++ = (Py_UNICODE)value; + Py_DECREF(x); + continue; } else if (PyUnicode_Check(x)) { Py_ssize_t targetsize = PyUnicode_GET_SIZE(x); - if (targetsize == 1) { + if (targetsize == 1) /* 1-1 mapping */ - Py_UNICODE value = *PyUnicode_AS_UNICODE(x); - if (value == 0xFFFE) - goto Undefined; - *p++ = value; - } + *p++ = *PyUnicode_AS_UNICODE(x); + else if (targetsize > 1) { /* 1-n mapping */ if (targetsize > extrachars) { @@ -4235,20 +4191,6 @@ } Py_DECREF(x); ++s; - continue; -Undefined: - /* undefined mapping */ - Py_XDECREF(x); - outpos = p-PyUnicode_AS_UNICODE(v); - startinpos = s-starts; - endinpos = startinpos+1; - if (unicode_decode_call_errorhandler( - errors, &errorHandler, - "charmap", "character maps to ", - starts, size, &startinpos, &endinpos, &exc, &s, - &v, &outpos, &p)) { - goto onError; - } } } if (p - PyUnicode_AS_UNICODE(v) < PyUnicode_GET_SIZE(v)) @@ -4678,20 +4620,11 @@ *inpos = collendpos; break; case 4: /* xmlcharrefreplace */ - /* generate replacement */ - for (collpos = collstartpos; collpos < collendpos;) { + /* generate replacement (temporarily (mis)uses p) */ + for (collpos = collstartpos; collpos < collendpos; ++collpos) { char buffer[2+29+1+1]; char *cp; - Py_UCS4 ch = p[collpos++]; -#ifndef Py_UNICODE_WIDE - if ((0xD800 <= ch && ch <= 0xDBFF) && - (collpos < collendpos) && - (0xDC00 <= p[collpos] && p[collpos] <= 0xDFFF)) { - ch = ((((ch & 0x03FF) << 10) | - ((Py_UCS4)p[collpos++] & 0x03FF)) + 0x10000); - } -#endif - sprintf(buffer, "&#%d;", (int)ch); + sprintf(buffer, "&#%d;", (int)p[collpos]); for (cp = buffer; *cp; ++cp) { x = charmapencode_output(*cp, mapping, res, respos); if (x==enc_EXCEPTION) @@ -4825,7 +4758,8 @@ goto onError; return; onError: - Py_CLEAR(*exceptionObject); + Py_DECREF(*exceptionObject); + *exceptionObject = NULL; } } @@ -5105,11 +5039,10 @@ break; case 4: /* xmlcharrefreplace */ /* generate replacement (temporarily (mis)uses p) */ - for (p = collstart; p < collend;) { + for (p = collstart; p < collend; ++p) { char buffer[2+29+1+1]; char *cp; - Py_UCS4 ch = _Py_UNICODE_NEXT(p, collend); - sprintf(buffer, "&#%d;", (int)ch); + sprintf(buffer, "&#%d;", (int)*p); if (charmaptranslate_makespace(&res, &str, (str-PyUnicode_AS_UNICODE(res))+strlen(buffer)+(endp-collend))) goto onError; @@ -5260,10 +5193,8 @@ break; case 4: /* xmlcharrefreplace */ /* generate replacement (temporarily (mis)uses p) */ - for (p = collstart; p < collend;) { - Py_UCS4 ch = _Py_UNICODE_NEXT(p, collend); - output += sprintf(output, "&#%d;", ch); - } + for (p = collstart; p < collend; ++p) + output += sprintf(output, "&#%d;", (int)*p); p = collend; break; default: @@ -5618,7 +5549,7 @@ PyObject *item; Py_ssize_t i; - fseq = PySequence_Fast(seq, "can only join an iterable"); + fseq = PySequence_Fast(seq, ""); if (fseq == NULL) { return NULL; } @@ -6433,7 +6364,7 @@ to the default encoding. errors may be given to set a different error\n\ handling scheme. Default is 'strict' meaning that encoding errors raise\n\ a UnicodeDecodeError. Other possible values are 'ignore' and 'replace'\n\ -as well as any other name registered with codecs.register_error that is\n\ +as well as any other name registerd with codecs.register_error that is\n\ able to handle UnicodeDecodeErrors."); static PyObject * @@ -6607,27 +6538,14 @@ register Py_UNICODE *p; register long x; -#ifdef Py_DEBUG - assert(_Py_HashSecret_Initialized); -#endif if (self->hash != -1) return self->hash; len = PyUnicode_GET_SIZE(self); - /* - We make the hash of the empty string be 0, rather than using - (prefix ^ suffix), since this slightly obfuscates the hash secret - */ - if (len == 0) { - self->hash = 0; - return 0; - } p = PyUnicode_AS_UNICODE(self); - x = _Py_HashSecret.prefix; - x ^= *p << 7; + x = *p << 7; while (--len >= 0) x = (1000003*x) ^ *p++; x ^= PyUnicode_GET_SIZE(self); - x ^= _Py_HashSecret.suffix; if (x == -1) x = -2; self->hash = x; @@ -7590,7 +7508,7 @@ } PyDoc_STRVAR(splitlines__doc__, - "S.splitlines(keepends=False) -> list of strings\n\ + "S.splitlines([keepends]) -> list of strings\n\ \n\ Return a list of the lines in S, breaking at line boundaries.\n\ Line breaks are not included in the resulting list unless keepends\n\ @@ -7866,6 +7784,10 @@ static PyMethodDef unicode_methods[] = { + + /* Order is according to common usage: often used methods should + appear first, since lookup is done sequentially. */ + {"encode", (PyCFunction) unicode_encode, METH_VARARGS | METH_KEYWORDS, encode__doc__}, {"replace", (PyCFunction) unicode_replace, METH_VARARGS, replace__doc__}, {"split", (PyCFunction) unicode_split, METH_VARARGS, split__doc__}, @@ -8344,8 +8266,8 @@ arglen = -1; argidx = -2; } - if (Py_TYPE(args)->tp_as_mapping && Py_TYPE(args)->tp_as_mapping->mp_subscript && - !PyTuple_Check(args) && !PyObject_TypeCheck(args, &PyBaseString_Type)) + if (Py_TYPE(args)->tp_as_mapping && !PyTuple_Check(args) && + !PyObject_TypeCheck(args, &PyBaseString_Type)) dict = args; while (--fmtcnt >= 0) { @@ -8449,9 +8371,7 @@ "* wants int"); goto onError; } - width = PyInt_AsSsize_t(v); - if (width == -1 && PyErr_Occurred()) - goto onError; + width = PyInt_AsLong(v); if (width < 0) { flags |= F_LJUST; width = -width; @@ -8465,7 +8385,7 @@ c = *fmt++; if (c < '0' || c > '9') break; - if (width > (PY_SSIZE_T_MAX - ((int)c - '0')) / 10) { + if ((width*10) / 10 != width) { PyErr_SetString(PyExc_ValueError, "width too big"); goto onError; @@ -8486,9 +8406,7 @@ "* wants int"); goto onError; } - prec = _PyInt_AsInt(v); - if (prec == -1 && PyErr_Occurred()) - goto onError; + prec = PyInt_AsLong(v); if (prec < 0) prec = 0; if (--fmtcnt >= 0) @@ -8500,7 +8418,7 @@ c = *fmt++; if (c < '0' || c > '9') break; - if (prec > (INT_MAX - ((int)c - '0')) / 10) { + if ((prec*10) / 10 != prec) { PyErr_SetString(PyExc_ValueError, "prec too big"); goto onError; @@ -8832,8 +8750,7 @@ } PyDoc_STRVAR(unicode_doc, - "unicode(object='') -> unicode object\n\ -unicode(string[, encoding[, errors]]) -> unicode object\n\ + "unicode(string [, encoding[, errors]]) -> object\n\ \n\ Create a new Unicode object from the given encoded string.\n\ encoding defaults to the current default string encoding.\n\ @@ -8887,6 +8804,8 @@ void _PyUnicode_Init(void) { + int i; + /* XXX - move this array to unicodectype.c ? */ Py_UNICODE linebreak[] = { 0x000A, /* LINE FEED */ @@ -8900,12 +8819,15 @@ }; /* Init the implementation */ - if (!unicode_empty) { - unicode_empty = _PyUnicode_New(0); - if (!unicode_empty) - return; - } - + free_list = NULL; + numfree = 0; + unicode_empty = _PyUnicode_New(0); + if (!unicode_empty) + return; + + strcpy(unicode_default_encoding, "ascii"); + for (i = 0; i < 256; i++) + unicode_latin1[i] = NULL; if (PyType_Ready(&PyUnicode_Type) < 0) Py_FatalError("Can't initialize 'unicode'"); @@ -8915,12 +8837,6 @@ ); PyType_Ready(&EncodingMapType); - - if (PyType_Ready(&PyFieldNameIter_Type) < 0) - Py_FatalError("Can't initialize field name iterator type"); - - if (PyType_Ready(&PyFormatterIter_Type) < 0) - Py_FatalError("Can't initialize formatter iter type"); } /* Finalize the Unicode implementation */ @@ -8950,11 +8866,15 @@ { int i; - Py_CLEAR(unicode_empty); - - for (i = 0; i < 256; i++) - Py_CLEAR(unicode_latin1[i]); - + Py_XDECREF(unicode_empty); + unicode_empty = NULL; + + for (i = 0; i < 256; i++) { + if (unicode_latin1[i]) { + Py_DECREF(unicode_latin1[i]); + unicode_latin1[i] = NULL; + } + } (void)PyUnicode_ClearFreeList(); } diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Objects/weakrefobject.c --- a/Objects/weakrefobject.c Sat Jul 19 16:34:33 2014 -0700 +++ b/Objects/weakrefobject.c Sun Jul 20 10:52:46 2014 -0400 @@ -52,8 +52,9 @@ { PyObject *callback = self->wr_callback; - if (self->wr_object != Py_None) { - PyWeakReference **list = GET_WEAKREFS_LISTPTR(self->wr_object); + if (PyWeakref_GET_OBJECT(self) != Py_None) { + PyWeakReference **list = GET_WEAKREFS_LISTPTR( + PyWeakref_GET_OBJECT(self)); if (*list == self) /* If 'self' is the end of the list (and thus self->wr_next == NULL) @@ -167,21 +168,13 @@ PyErr_Clear(); else if (PyString_Check(nameobj)) name = PyString_AS_STRING(nameobj); - if (name != NULL) { - PyOS_snprintf(buffer, sizeof(buffer), - "", - self, - Py_TYPE(PyWeakref_GET_OBJECT(self))->tp_name, - PyWeakref_GET_OBJECT(self), - name); - } - else { - PyOS_snprintf(buffer, sizeof(buffer), - "", - self, - Py_TYPE(PyWeakref_GET_OBJECT(self))->tp_name, - PyWeakref_GET_OBJECT(self)); - } + PyOS_snprintf(buffer, sizeof(buffer), + name ? "" + : "", + self, + Py_TYPE(PyWeakref_GET_OBJECT(self))->tp_name, + PyWeakref_GET_OBJECT(self), + name); Py_XDECREF(nameobj); } return PyString_FromString(buffer); @@ -194,19 +187,15 @@ static PyObject * weakref_richcompare(PyWeakReference* self, PyWeakReference* other, int op) { - if ((op != Py_EQ && op != Py_NE) || self->ob_type != other->ob_type) { + if (op != Py_EQ || self->ob_type != other->ob_type) { Py_INCREF(Py_NotImplemented); return Py_NotImplemented; } if (PyWeakref_GET_OBJECT(self) == Py_None || PyWeakref_GET_OBJECT(other) == Py_None) { - int res = (self == other); - if (op == Py_NE) - res = !res; - if (res) - Py_RETURN_TRUE; - else - Py_RETURN_FALSE; + PyObject *res = self==other ? Py_True : Py_False; + Py_INCREF(res); + return res; } return PyObject_RichCompare(PyWeakref_GET_OBJECT(self), PyWeakref_GET_OBJECT(other), op); diff -r 9cd3ab7c09d1 -r 9ac347a7f375 PC/VC6/bz2.dsp --- a/PC/VC6/bz2.dsp Sat Jul 19 16:34:33 2014 -0700 +++ b/PC/VC6/bz2.dsp Sun Jul 20 10:52:46 2014 -0400 @@ -44,7 +44,7 @@ # PROP Target_Dir "" F90=df.exe # ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "Py_BUILD_CORE_MODULE" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c -# ADD CPP /nologo /MD /W3 /GX /Zi /O2 /I "..\..\Include" /I ".." /I "..\..\..\bzip2-1.0.6" /D "Py_BUILD_CORE_MODULE" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /YX /FD /c +# ADD CPP /nologo /MD /W3 /GX /Zi /O2 /I "..\..\Include" /I ".." /I "..\..\..\bzip2-1.0.5" /D "Py_BUILD_CORE_MODULE" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /YX /FD /c # ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32 # ADD MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32 # ADD BASE RSC /l 0x409 /d "NDEBUG" @@ -54,7 +54,7 @@ # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /machine:I386 -# ADD LINK32 ..\..\..\bzip2-1.0.6\libbz2.lib /nologo /base:"0x1D170000" /subsystem:windows /dll /debug /machine:I386 /nodefaultlib:"libc" /out:"./bz2.pyd" +# ADD LINK32 ..\..\..\bzip2-1.0.5\libbz2.lib /nologo /base:"0x1D170000" /subsystem:windows /dll /debug /machine:I386 /nodefaultlib:"libc" /out:"./bz2.pyd" # SUBTRACT LINK32 /pdb:none /nodefaultlib !ELSEIF "$(CFG)" == "bz2 - Win32 Debug" @@ -72,7 +72,7 @@ # PROP Target_Dir "" F90=df.exe # ADD BASE CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /D "Py_BUILD_CORE_MODULE" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c -# ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /I "..\..\Include" /I ".." /I "..\..\..\bzip2-1.0.6" /D "Py_BUILD_CORE_MODULE" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /YX /FD /c +# ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /I "..\..\Include" /I ".." /I "..\..\..\bzip2-1.0.5" /D "Py_BUILD_CORE_MODULE" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /YX /FD /c # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32 # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32 # ADD BASE RSC /l 0x409 /d "_DEBUG" @@ -82,7 +82,7 @@ # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /debug /machine:I386 /pdbtype:sept -# ADD LINK32 ..\..\..\bzip2-1.0.6\libbz2.lib /nologo /base:"0x1D170000" /subsystem:windows /dll /debug /machine:I386 /nodefaultlib:"msvcrt" /nodefaultlib:"libc" /out:"./bz2_d.pyd" /pdbtype:sept +# ADD LINK32 ..\..\..\bzip2-1.0.5\libbz2.lib /nologo /base:"0x1D170000" /subsystem:windows /dll /debug /machine:I386 /nodefaultlib:"msvcrt" /nodefaultlib:"libc" /out:"./bz2_d.pyd" /pdbtype:sept # SUBTRACT LINK32 /pdb:none !ENDIF diff -r 9cd3ab7c09d1 -r 9ac347a7f375 PC/VC6/pythoncore.dsp --- a/PC/VC6/pythoncore.dsp Sat Jul 19 16:34:33 2014 -0700 +++ b/PC/VC6/pythoncore.dsp Sun Jul 20 10:52:46 2014 -0400 @@ -663,10 +663,6 @@ # End Source File # Begin Source File -SOURCE=..\..\Python\random.c -# End Source File -# Begin Source File - SOURCE=..\..\Objects\rangeobject.c # End Source File # Begin Source File diff -r 9cd3ab7c09d1 -r 9ac347a7f375 PC/VC6/readme.txt --- a/PC/VC6/readme.txt Sat Jul 19 16:34:33 2014 -0700 +++ b/PC/VC6/readme.txt Sun Jul 20 10:52:46 2014 -0400 @@ -120,14 +120,14 @@ Download the source from the python.org copy into the dist directory: - svn export http://svn.python.org/projects/external/bzip2-1.0.6 + svn export http://svn.python.org/projects/external/bzip2-1.0.5 And requires building bz2 first. - cd dist\bzip2-1.0.6 + cd dist\bzip2-1.0.5 nmake -f makefile.msc - All of this managed to build bzip2-1.0.6\libbz2.lib, which the Python + All of this managed to build bzip2-1.0.5\libbz2.lib, which the Python project links in. diff -r 9cd3ab7c09d1 -r 9ac347a7f375 PC/VS7.1/pythoncore.vcproj --- a/PC/VS7.1/pythoncore.vcproj Sat Jul 19 16:34:33 2014 -0700 +++ b/PC/VS7.1/pythoncore.vcproj Sun Jul 20 10:52:46 2014 -0400 @@ -767,9 +767,6 @@ RelativePath="..\..\Python\pythonrun.c"> - - - - diff -r 9cd3ab7c09d1 -r 9ac347a7f375 PC/_subprocess.c --- a/PC/_subprocess.c Sat Jul 19 16:34:33 2014 -0700 +++ b/PC/_subprocess.c Sun Jul 20 10:52:46 2014 -0400 @@ -331,7 +331,7 @@ PyObject* values; char* p; - /* convert environment dictionary to windows environment string */ + /* convert environment dictionary to windows enviroment string */ if (! PyMapping_Check(environment)) { PyErr_SetString( PyExc_TypeError, "environment must be dictionary or None"); @@ -367,8 +367,7 @@ vsize + 1 + 1; if (totalsize > PyString_GET_SIZE(out)) { int offset = p - PyString_AS_STRING(out); - if (_PyString_Resize(&out, totalsize + 1024)) - goto exit; + _PyString_Resize(&out, totalsize + 1024); p = PyString_AS_STRING(out) + offset; } memcpy(p, PyString_AS_STRING(key), ksize); @@ -384,7 +383,7 @@ _PyString_Resize(&out, p - PyString_AS_STRING(out)); /* PyObject_Print(out, stdout, 0); */ -exit: + Py_XDECREF(keys); Py_XDECREF(values); @@ -671,5 +670,4 @@ defint(d, "WAIT_OBJECT_0", WAIT_OBJECT_0); defint(d, "CREATE_NEW_CONSOLE", CREATE_NEW_CONSOLE); defint(d, "CREATE_NEW_PROCESS_GROUP", CREATE_NEW_PROCESS_GROUP); - defint(d, "STILL_ACTIVE", STILL_ACTIVE); } diff -r 9cd3ab7c09d1 -r 9ac347a7f375 PC/_winreg.c --- a/PC/_winreg.c Sat Jul 19 16:34:33 2014 -0700 +++ b/PC/_winreg.c Sun Jul 20 10:52:46 2014 -0400 @@ -753,8 +753,7 @@ Py_ssize_t i,j; switch (typ) { case REG_DWORD: - if (value != Py_None && - !(PyInt_Check(value) || PyLong_Check(value))) + if (value != Py_None && !PyInt_Check(value)) return FALSE; *retDataBuf = (BYTE *)PyMem_NEW(DWORD, 1); if (*retDataBuf==NULL){ @@ -766,10 +765,10 @@ DWORD zero = 0; memcpy(*retDataBuf, &zero, sizeof(DWORD)); } - else { - DWORD d = PyLong_AsUnsignedLong(value); - memcpy(*retDataBuf, &d, sizeof(DWORD)); - } + else + memcpy(*retDataBuf, + &PyInt_AS_LONG((PyIntObject *)value), + sizeof(DWORD)); break; case REG_SZ: case REG_EXPAND_SZ: @@ -883,14 +882,12 @@ /* ALSO handle ALL unknown data types here. Even if we can't support it natively, we should handle the bits. */ default: - if (value == Py_None) { + if (value == Py_None) *retDataSize = 0; - *retDataBuf = NULL; - } else { void *src_buf; PyBufferProcs *pb = value->ob_type->tp_as_buffer; - if (pb == NULL || pb->bf_getreadbuffer == NULL) { + if (pb==NULL) { PyErr_Format(PyExc_TypeError, "Objects of type '%s' can not " "be used as binary registry values", @@ -898,11 +895,9 @@ return FALSE; } *retDataSize = (*pb->bf_getreadbuffer)(value, 0, &src_buf); - if (*retDataSize < 0) { - return FALSE; - } - *retDataBuf = (BYTE *)PyMem_NEW(char, *retDataSize); - if (*retDataBuf == NULL){ + *retDataBuf = (BYTE *)PyMem_NEW(char, + *retDataSize); + if (*retDataBuf==NULL){ PyErr_NoMemory(); return FALSE; } @@ -922,9 +917,9 @@ switch (typ) { case REG_DWORD: if (retDataSize == 0) - obData = Py_BuildValue("k", 0); + obData = Py_BuildValue("i", 0); else - obData = Py_BuildValue("k", + obData = Py_BuildValue("i", *(int *)retDataBuf); break; case REG_SZ: @@ -952,10 +947,8 @@ fixupMultiSZ(str, retDataBuf, retDataSize); obData = PyList_New(s); - if (obData == NULL) { - free(str); + if (obData == NULL) return NULL; - } for (index = 0; index < s; index++) { size_t len = _mbstrlen(str[index]); @@ -963,7 +956,6 @@ PyErr_SetString(PyExc_OverflowError, "registry string is too long for a Python string"); Py_DECREF(obData); - free(str); return NULL; } PyList_SetItem(obData, diff -r 9cd3ab7c09d1 -r 9ac347a7f375 PC/pyconfig.h --- a/PC/pyconfig.h Sat Jul 19 16:34:33 2014 -0700 +++ b/PC/pyconfig.h Sun Jul 20 10:52:46 2014 -0400 @@ -342,7 +342,7 @@ # define SIZEOF_FPOS_T 8 # define SIZEOF_HKEY 8 # define SIZEOF_SIZE_T 8 -/* configure.ac defines HAVE_LARGEFILE_SUPPORT iff HAVE_LONG_LONG, +/* configure.in defines HAVE_LARGEFILE_SUPPORT iff HAVE_LONG_LONG, sizeof(off_t) > sizeof(long), and sizeof(PY_LONG_LONG) >= sizeof(off_t). On Win64 the second condition is not true, but if fpos_t replaces off_t then this is true. The uses of HAVE_LARGEFILE_SUPPORT imply that Win64 diff -r 9cd3ab7c09d1 -r 9ac347a7f375 PC/python_nt.rc --- a/PC/python_nt.rc Sat Jul 19 16:34:33 2014 -0700 +++ b/PC/python_nt.rc Sun Jul 20 10:52:46 2014 -0400 @@ -61,7 +61,7 @@ VALUE "FileDescription", "Python Core\0" VALUE "FileVersion", PYTHON_VERSION VALUE "InternalName", "Python DLL\0" - VALUE "LegalCopyright", "Copyright 2001-2014 Python Software Foundation. Copyright 2000 BeOpen.com. Copyright 1995-2001 CNRI. Copyright 1991-1995 SMC.\0" + VALUE "LegalCopyright", "Copyright 2001-2008 Python Software Foundation. Copyright 2000 BeOpen.com. Copyright 1995-2001 CNRI. Copyright 1991-1995 SMC.\0" VALUE "OriginalFilename", PYTHON_DLL_NAME "\0" VALUE "ProductName", "Python\0" VALUE "ProductVersion", PYTHON_VERSION diff -r 9cd3ab7c09d1 -r 9ac347a7f375 PCbuild/build_ssl.py --- a/PCbuild/build_ssl.py Sat Jul 19 16:34:33 2014 -0700 +++ b/PCbuild/build_ssl.py Sun Jul 20 10:52:46 2014 -0400 @@ -64,13 +64,37 @@ print(" Please install ActivePerl and ensure it appears on your path") return None -# Fetch SSL directory from VC properties -def get_ssl_dir(): - propfile = (os.path.join(os.path.dirname(__file__), 'pyproject.vsprops')) - with open(propfile) as f: - m = re.search('openssl-([^"]+)"', f.read()) - return "..\..\openssl-"+m.group(1) - +# Locate the best SSL directory given a few roots to look into. +def find_best_ssl_dir(sources): + candidates = [] + for s in sources: + try: + # note: do not abspath s; the build will fail if any + # higher up directory name has spaces in it. + fnames = os.listdir(s) + except os.error: + fnames = [] + for fname in fnames: + fqn = os.path.join(s, fname) + if os.path.isdir(fqn) and fname.startswith("openssl-"): + candidates.append(fqn) + # Now we have all the candidates, locate the best. + best_parts = [] + best_name = None + for c in candidates: + parts = re.split("[.-]", os.path.basename(c))[1:] + # eg - openssl-0.9.7-beta1 - ignore all "beta" or any other qualifiers + if len(parts) >= 4: + continue + if parts > best_parts: + best_parts = parts + best_name = c + if best_name is not None: + print("Found an SSL directory at '%s'" % (best_name,)) + else: + print("Could not find an SSL directory in '%s'" % (sources,)) + sys.stdout.flush() + return best_name def create_makefile64(makefile, m32): """Create and fix makefile for 64bit @@ -166,7 +190,7 @@ print("No Perl installation was found. Existing Makefiles are used.") sys.stdout.flush() # Look for SSL 2 levels up from pcbuild - ie, same place zlib etc all live. - ssl_dir = get_ssl_dir() + ssl_dir = find_best_ssl_dir(("..\\..",)) if ssl_dir is None: sys.exit(1) @@ -207,9 +231,9 @@ # Now run make. if arch == "amd64": - rc = os.system("nasm -f win64 -DNEAR -Ox -g ms\\uptable.asm") + rc = os.system(r"ml64 -c -Foms\uptable.obj ms\uptable.asm") if rc: - print("nasm assembler has failed.") + print("ml64 assembler has failed.") sys.exit(rc) shutil.copy(r"crypto\buildinf_%s.h" % arch, r"crypto\buildinf.h") diff -r 9cd3ab7c09d1 -r 9ac347a7f375 PCbuild/bz2.vcproj --- a/PCbuild/bz2.vcproj Sat Jul 19 16:34:33 2014 -0700 +++ b/PCbuild/bz2.vcproj Sun Jul 20 10:52:46 2014 -0400 @@ -532,7 +532,7 @@ - - @@ -1874,4 +1870,4 @@ - \ No newline at end of file + diff -r 9cd3ab7c09d1 -r 9ac347a7f375 PCbuild/readme.txt --- a/PCbuild/readme.txt Sat Jul 19 16:34:33 2014 -0700 +++ b/PCbuild/readme.txt Sun Jul 20 10:52:46 2014 -0400 @@ -1,7 +1,7 @@ Building Python using VC++ 9.0 ------------------------------ -This directory is used to build Python for Win32 and x64 platforms, e.g. +This directory is used to build Python for Win32 and x64 platforms, e.g. Windows 2000, XP, Vista and Windows Server 2008. In order to build 32-bit debug and release executables, Microsoft Visual C++ 2008 Express Edition is required at the very least. In order to build 64-bit debug and release @@ -27,7 +27,7 @@ The solution is configured to build the projects in the correct order. "Build Solution" or F7 takes care of dependencies except for x64 builds. To make -cross compiling x64 builds on a 32bit OS possible the x64 builds require a +cross compiling x64 builds on a 32bit OS possible the x64 builds require a 32bit version of Python. NOTE: @@ -37,7 +37,7 @@ running a Python core buildbot test slave; see SUBPROJECTS below) When using the Debug setting, the output files have a _d added to -their name: python27_d.dll, python_d.exe, parser_d.pyd, and so on. Both +their name: python30_d.dll, python_d.exe, parser_d.pyd, and so on. Both the build and rt batch files accept a -d option for debug builds. The 32bit builds end up in the solution folder PCbuild while the x64 builds @@ -47,7 +47,7 @@ Legacy support -------------- -You can find build directories for older versions of Visual Studio and +You can find build directories for older versions of Visual Studio and Visual C++ in the PC directory. The legacy build directories are no longer actively maintained and may not work out of the box. @@ -64,7 +64,7 @@ Visual Studio 2008 uses version 9 of the C runtime (MSVCRT9). The executables are linked to a CRT "side by side" assembly which must be present on the target -machine. This is available under the VC/Redist folder of your visual studio +machine. This is avalible under the VC/Redist folder of your visual studio distribution. On XP and later operating systems that support side-by-side assemblies it is not enough to have the msvcrt90.dll present, it has to be there as a whole assembly, that is, a folder with the .dll @@ -105,34 +105,44 @@ Python-controlled subprojects that wrap external projects: _bsddb Wraps Berkeley DB 4.7.25, which is currently built by _bsddb.vcproj. - project. + project (see below). _sqlite3 - Wraps SQLite 3.6.21, which is currently built by sqlite3.vcproj. + Wraps SQLite 3.6.21, which is currently built by sqlite3.vcproj (see below). _tkinter Wraps the Tk windowing system. Unlike _bsddb and _sqlite3, there's no corresponding tcltk.vcproj-type project that builds Tcl/Tk from vcproj's within our pcbuild.sln, which means this module expects to find a pre-built Tcl/Tk in either ..\..\tcltk for 32-bit or ..\..\tcltk64 for 64-bit (relative to this directory). See below for instructions to build - Tcl/Tk. + Tcl/Tk. bz2 Python wrapper for the libbz2 compression library. Homepage http://sources.redhat.com/bzip2/ Download the source from the python.org copy into the dist directory: - svn export http://svn.python.org/projects/external/bzip2-1.0.6 + svn export http://svn.python.org/projects/external/bzip2-1.0.5 ** NOTE: if you use the Tools\buildbot\external(-amd64).bat approach for obtaining external sources then you don't need to manually get the source above via subversion. ** + A custom pre-link step in the bz2 project settings should manage to + build bzip2-1.0.5\libbz2.lib by magic before bz2.pyd (or bz2_d.pyd) is + linked in PCbuild\. + However, the bz2 project is not smart enough to remove anything under + bzip2-1.0.5\ when you do a clean, so if you want to rebuild bzip2.lib + you need to clean up bzip2-1.0.5\ by hand. + + All of this managed to build libbz2.lib in + bzip2-1.0.5\$platform-$configuration\, which the Python project links in. + _ssl Python wrapper for the secure sockets library. Get the source code through - svn export http://svn.python.org/projects/external/openssl-1.0.1h + svn export http://svn.python.org/projects/external/openssl-0.9.8l ** NOTE: if you use the Tools\buildbot\external(-amd64).bat approach for obtaining external sources then you don't need to manually get the source @@ -144,16 +154,18 @@ You must install the NASM assembler from http://nasm.sf.net - for x86 builds. Put nasm.exe anywhere in your PATH. + for x86 builds. Put nasmw.exe anywhere in your PATH. + Note: recent releases of nasm only have nasm.exe. Just rename it to + nasmw.exe. You can also install ActivePerl from http://www.activestate.com/activeperl/ - if you like to use the official sources instead of the files from + if you like to use the official sources instead of the files from python's subversion repository. The svn version contains pre-build makefiles and assembly files. The build process makes sure that no patented algorithms are included. - For now RC5, MDC2 and IDEA are excluded from the build. You may have + For now RC5, MDC2 and IDEA are excluded from the build. You may have to manually remove $(OBJ_D)\i_*.obj from ms\nt.mak if the build process complains about missing files or forbidden IDEA. Again the files provided in the subversion repository are already fixed. @@ -174,16 +186,16 @@ this by hand. The subprojects above wrap external projects Python doesn't control, and as -such, a little more work is required in order to download the relevant source +such, a little more work is required in order to download the relevant source files for each project before they can be built. The buildbots do this each -time they're built, so the easiest approach is to run either external.bat or +time they're built, so the easiest approach is to run either external.bat or external-amd64.bat in the ..\Tools\buildbot directory from ..\, i.e.: C:\..\svn.python.org\projects\python\trunk\PCbuild>cd .. C:\..\svn.python.org\projects\python\trunk>Tools\buildbot\external.bat This extracts all the external subprojects from http://svn.python.org/external -via Subversion (so you'll need an svn.exe on your PATH) and places them in +via Subversion (so you'll need an svn.exe on your PATH) and places them in ..\.. (relative to this directory). The external(-amd64).bat scripts will also build a debug build of Tcl/Tk; there aren't any equivalent batch files for building release versions of Tcl/Tk lying around in the Tools\buildbot @@ -226,7 +238,7 @@ junction as follows (using the directory structure above as an example): C:\..\python\trunk\external <- already exists and has built versions - of the external subprojects + of the external subprojects C:\..\python\branches\py3k>linkd.exe external ..\..\trunk\external Link created at: external @@ -239,9 +251,19 @@ Building for Itanium -------------------- +NOTE: Official support for Itanium builds have been dropped from the build. Please contact us and provide patches if you are interested in Itanium builds. +The project files support a ReleaseItanium configuration which creates +Win64/Itanium binaries. For this to work, you need to install the Platform +SDK, in particular the 64-bit support. This includes an Itanium compiler +(future releases of the SDK likely include an AMD64 compiler as well). +In addition, you need the Visual Studio plugin for external C compilers, +from http://sf.net/projects/vsextcomp. The plugin will wrap cl.exe, to +locate the proper target compiler, and convert compiler options +accordingly. The project files require atleast version 0.9. + Building for AMD64 ------------------ @@ -261,7 +283,7 @@ The solution has two configurations for PGO. The PGInstrument configuration must be build first. The PGInstrument binaries are -linked against a profiling library and contain extra debug +lniked against a profiling library and contain extra debug information. The PGUpdate configuration takes the profiling data and generates optimized binaries. @@ -269,22 +291,22 @@ creates the PGI files, runs the unit test suite or PyBench with the PGI python and finally creates the optimized files. -http://msdn.microsoft.com/en-us/library/e7k32f4k(VS.90).aspx +http://msdn2.microsoft.com/en-us/library/e7k32f4k(VS.90).aspx Static library -------------- The solution has no configuration for static libraries. However it is easy -it build a static library instead of a DLL. You simply have to set the +it build a static library instead of a DLL. You simply have to set the "Configuration Type" to "Static Library (.lib)" and alter the preprocessor macro "Py_ENABLE_SHARED" to "Py_NO_ENABLE_SHARED". You may also have to -change the "Runtime Library" from "Multi-threaded DLL (/MD)" to +change the "Runtime Library" from "Multi-threaded DLL (/MD)" to "Multi-threaded (/MT)". Visual Studio properties ------------------------ -The PCbuild solution makes heavy use of Visual Studio property files +The PCbuild solution makes heavy use of Visual Studio property files (*.vsprops). The properties can be viewed and altered in the Property Manager (View -> Other Windows -> Property Manager). diff -r 9cd3ab7c09d1 -r 9ac347a7f375 PCbuild/rt.bat --- a/PCbuild/rt.bat Sat Jul 19 16:34:33 2014 -0700 +++ b/PCbuild/rt.bat Sun Jul 20 10:52:46 2014 -0400 @@ -30,7 +30,7 @@ set suffix= set qmode= set dashO= -set tcltk=tcltk +set tcltk= :CheckOpts if "%1"=="-O" (set dashO=-O) & shift & goto CheckOpts @@ -38,7 +38,7 @@ if "%1"=="-d" (set suffix=_d) & shift & goto CheckOpts if "%1"=="-x64" (set prefix=amd64) & (set tcltk=tcltk64) & shift & goto CheckOpts -PATH %PATH%;%~dp0..\..\%tcltk%\bin +PATH %PATH%;..\..\%tcltk%\bin set exe=%prefix%\python%suffix% set cmd=%exe% %dashO% -Wd -3 -E -tt ../lib/test/regrtest.py %1 %2 %3 %4 %5 %6 %7 %8 %9 if defined qmode goto Qmode diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Parser/asdl_c.py --- a/Parser/asdl_c.py Sat Jul 19 16:34:33 2014 -0700 +++ b/Parser/asdl_c.py Sun Jul 20 10:52:46 2014 -0400 @@ -977,7 +977,7 @@ class StaticVisitor(PickleVisitor): - CODE = '''Very simple, always emit this static code. Override CODE''' + CODE = '''Very simple, always emit this static code. Overide CODE''' def visit(self, object): self.emit(self.CODE, 0, reflow=False) @@ -1033,7 +1033,7 @@ self.emit("case %s:" % t.name, 2) self.emit("Py_INCREF(%s_singleton);" % t.name, 3) self.emit("return %s_singleton;" % t.name, 3) - self.emit("default:", 2) + self.emit("default:" % name, 2) self.emit('/* should never happen, but just in case ... */', 3) code = "PyErr_Format(PyExc_SystemError, \"unknown %s found\");" % name self.emit(code, 3, reflow=False) @@ -1117,18 +1117,10 @@ mod_ty PyAST_obj2mod(PyObject* ast, PyArena* arena, int mode) { mod_ty res; - PyObject *req_type[3]; - char *req_name[3]; + PyObject *req_type[] = {(PyObject*)Module_type, (PyObject*)Expression_type, + (PyObject*)Interactive_type}; + char *req_name[] = {"Module", "Expression", "Interactive"}; int isinstance; - - req_type[0] = (PyObject*)Module_type; - req_type[1] = (PyObject*)Expression_type; - req_type[2] = (PyObject*)Interactive_type; - - req_name[0] = "Module"; - req_name[1] = "Expression"; - req_name[2] = "Interactive"; - assert(0 <= mode && mode <= 2); init_types(); diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Parser/myreadline.c --- a/Parser/myreadline.c Sat Jul 19 16:34:33 2014 -0700 +++ b/Parser/myreadline.c Sun Jul 20 10:52:46 2014 -0400 @@ -40,10 +40,6 @@ my_fgets(char *buf, int len, FILE *fp) { char *p; -#ifdef MS_WINDOWS - int i; -#endif - while (1) { if (PyOS_InputHook != NULL) (void)(PyOS_InputHook)(); @@ -53,24 +49,32 @@ if (p != NULL) return 0; /* No error */ #ifdef MS_WINDOWS - /* Ctrl-C anywhere on the line or Ctrl-Z if the only character - on a line will set ERROR_OPERATION_ABORTED. Under normal - circumstances Ctrl-C will also have caused the SIGINT handler - to fire. This signal fires in another thread and is not - guaranteed to have occurred before this point in the code. - - Therefore: check in a small loop to see if the trigger has - fired, in which case assume this is a Ctrl-C event. If it - hasn't fired within 10ms assume that this is a Ctrl-Z on its - own or that the signal isn't going to fire for some other - reason and drop through to check for EOF. + /* In the case of a Ctrl+C or some other external event + interrupting the operation: + Win2k/NT: ERROR_OPERATION_ABORTED is the most recent Win32 + error code (and feof() returns TRUE). + Win9x: Ctrl+C seems to have no effect on fgets() returning + early - the signal handler is called, but the fgets() + only returns "normally" (ie, when Enter hit or feof()) */ if (GetLastError()==ERROR_OPERATION_ABORTED) { - for (i = 0; i < 10; i++) { - if (PyOS_InterruptOccurred()) - return 1; - Sleep(1); + /* Signals come asynchronously, so we sleep a brief + moment before checking if the handler has been + triggered (we cant just return 1 before the + signal handler has been called, as the later + signal may be treated as a separate interrupt). + */ + Sleep(1); + if (PyOS_InterruptOccurred()) { + return 1; /* Interrupt */ } + /* Either the sleep wasn't long enough (need a + short loop retrying?) or not interrupted at all + (in which case we should revisit the whole thing!) + Logging some warning would be nice. assert is not + viable as under the debugger, the various dialogs + mean the condition is not true. + */ } #endif /* MS_WINDOWS */ if (feof(fp)) { diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Parser/node.c --- a/Parser/node.c Sat Jul 19 16:34:33 2014 -0700 +++ b/Parser/node.c Sun Jul 20 10:52:46 2014 -0400 @@ -114,7 +114,6 @@ /* Forward */ static void freechildren(node *); -static Py_ssize_t sizeofchildren(node *n); void @@ -126,16 +125,6 @@ } } -Py_ssize_t -_PyNode_SizeOf(node *n) -{ - Py_ssize_t res = 0; - - if (n != NULL) - res = sizeof(node) + sizeofchildren(n); - return res; -} - static void freechildren(node *n) { @@ -147,18 +136,3 @@ if (STR(n) != NULL) PyObject_FREE(STR(n)); } - -static Py_ssize_t -sizeofchildren(node *n) -{ - Py_ssize_t res = 0; - int i; - for (i = NCH(n); --i >= 0; ) - res += sizeofchildren(CHILD(n, i)); - if (n->n_child != NULL) - /* allocated size of n->n_child array */ - res += XXXROUNDUP(NCH(n)) * sizeof(node); - if (STR(n) != NULL) - res += strlen(STR(n)) + 1; - return res; -} diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Parser/parsetok.c --- a/Parser/parsetok.c Sat Jul 19 16:34:33 2014 -0700 +++ b/Parser/parsetok.c Sun Jul 20 10:52:46 2014 -0400 @@ -131,7 +131,7 @@ { parser_state *ps; node *n; - int started = 0; + int started = 0, handling_import = 0, handling_with = 0; if ((ps = PyParser_New(g, start)) == NULL) { fprintf(stderr, "no mem for new parser\n"); @@ -163,6 +163,7 @@ } if (type == ENDMARKER && started) { type = NEWLINE; /* Add an extra newline */ + handling_with = handling_import = 0; started = 0; /* Add the right number of dedent tokens, except if a certain flag is given -- diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Parser/tokenizer.c --- a/Parser/tokenizer.c Sat Jul 19 16:34:33 2014 -0700 +++ b/Parser/tokenizer.c Sun Jul 20 10:52:46 2014 -0400 @@ -277,11 +277,8 @@ tok->encoding = cs; tok->decoding_state = -1; } - else { - PyErr_Format(PyExc_SyntaxError, - "encoding problem: %s", cs); + else PyMem_FREE(cs); - } #else /* Without Unicode support, we cannot process the coding spec. Since there @@ -292,12 +289,15 @@ } } else { /* then, compare cs with BOM */ r = (strcmp(tok->encoding, cs) == 0); - if (!r) - PyErr_Format(PyExc_SyntaxError, - "encoding problem: %s with BOM", cs); PyMem_FREE(cs); } } + if (!r) { + cs = tok->encoding; + if (!cs) + cs = "with BOM"; + PyErr_Format(PyExc_SyntaxError, "encoding problem: %s", cs); + } return r; } @@ -400,12 +400,6 @@ buf = PyObject_CallObject(tok->decoding_readline, NULL); if (buf == NULL) return error_ret(tok); - if (!PyUnicode_Check(buf)) { - Py_DECREF(buf); - PyErr_SetString(PyExc_SyntaxError, - "codec did not return a unicode object"); - return error_ret(tok); - } } else { tok->decoding_buffer = NULL; if (PyString_CheckExact(buf)) @@ -534,7 +528,7 @@ "Non-ASCII character '\\x%.2x' " "in file %.200s on line %i, " "but no encoding declared; " - "see http://python.org/dev/peps/pep-0263/ for details", + "see http://www.python.org/peps/pep-0263.html for details", badchar, tok->filename, tok->lineno + 1); PyErr_SetString(PyExc_SyntaxError, buf); return error_ret(tok); @@ -1500,24 +1494,15 @@ } while (isdigit(c)); } if (c == 'e' || c == 'E') { - int e; - exponent: - e = c; + exponent: /* Exponent part */ c = tok_nextc(tok); - if (c == '+' || c == '-') { + if (c == '+' || c == '-') c = tok_nextc(tok); - if (!isdigit(c)) { - tok->done = E_TOKEN; - tok_backup(tok, c); - return ERRORTOKEN; - } - } else if (!isdigit(c)) { + if (!isdigit(c)) { + tok->done = E_TOKEN; tok_backup(tok, c); - tok_backup(tok, e); - *p_start = tok->start; - *p_end = tok->cur; - return NUMBER; + return ERRORTOKEN; } do { c = tok_nextc(tok); diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Python/Python-ast.c --- a/Python/Python-ast.c Sat Jul 19 16:34:33 2014 -0700 +++ b/Python/Python-ast.c Sun Jul 20 10:52:46 2014 -0400 @@ -6749,18 +6749,10 @@ mod_ty PyAST_obj2mod(PyObject* ast, PyArena* arena, int mode) { mod_ty res; - PyObject *req_type[3]; - char *req_name[3]; + PyObject *req_type[] = {(PyObject*)Module_type, (PyObject*)Expression_type, + (PyObject*)Interactive_type}; + char *req_name[] = {"Module", "Expression", "Interactive"}; int isinstance; - - req_type[0] = (PyObject*)Module_type; - req_type[1] = (PyObject*)Expression_type; - req_type[2] = (PyObject*)Interactive_type; - - req_name[0] = "Module"; - req_name[1] = "Expression"; - req_name[2] = "Interactive"; - assert(0 <= mode && mode <= 2); init_types(); diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Python/ast.c --- a/Python/ast.c Sat Jul 19 16:34:33 2014 -0700 +++ b/Python/ast.c Sun Jul 20 10:52:46 2014 -0400 @@ -37,7 +37,7 @@ static expr_ty ast_for_call(struct compiling *, const node *, expr_ty); static PyObject *parsenumber(struct compiling *, const char *); -static PyObject *parsestr(struct compiling *, const node *n, const char *); +static PyObject *parsestr(struct compiling *, const char *); static PyObject *parsestrplus(struct compiling *, const node *n); #ifndef LINENO @@ -930,7 +930,7 @@ return NULL; assert(TYPE(CHILD(n, 1)) == funcdef || - TYPE(CHILD(n, 1)) == classdef); + TYPE(CHILD(n, 1)) == classdef); if (TYPE(CHILD(n, 1)) == funcdef) { thing = ast_for_funcdef(c, CHILD(n, 1), decorator_seq); @@ -1744,19 +1744,14 @@ NCH(ppower) == 1 && TYPE((patom = CHILD(ppower, 0))) == atom && TYPE((pnum = CHILD(patom, 0))) == NUMBER) { - PyObject *pynum; char *s = PyObject_MALLOC(strlen(STR(pnum)) + 2); if (s == NULL) return NULL; s[0] = '-'; strcpy(s + 1, STR(pnum)); - pynum = parsenumber(c, s); - PyObject_FREE(s); - if (!pynum) - return NULL; - - PyArena_AddPyObject(c->c_arena, pynum); - return Num(pynum, LINENO(n), n->n_col_offset, c->c_arena); + PyObject_FREE(STR(pnum)); + STR(pnum) = s; + return ast_for_atom(c, patom); } expression = ast_for_expr(c, CHILD(n, 1)); @@ -3297,8 +3292,8 @@ return ast_for_funcdef(c, ch, NULL); case classdef: return ast_for_classdef(c, ch, NULL); - case decorated: - return ast_for_decorated(c, ch); + case decorated: + return ast_for_decorated(c, ch); default: PyErr_Format(PyExc_SystemError, "unhandled small_stmt: TYPE=%d NCH=%d\n", @@ -3387,8 +3382,8 @@ /* check for integer overflow */ if (len > PY_SIZE_MAX / 6) return NULL; - /* "" (2 bytes) may become "\U000000E4" (10 bytes), or 1:5 - "\ä" (3 bytes) may become "\u005c\U000000E4" (16 bytes), or ~1:6 */ + /* "" (2 bytes) may become "\U000000E4" (10 bytes), or 1:5 + "\ä" (3 bytes) may become "\u005c\U000000E4" (16 bytes), or ~1:6 */ u = PyString_FromStringAndSize((char *)NULL, len * 6); if (u == NULL) return NULL; @@ -3418,8 +3413,8 @@ sprintf(p, "\\U%02x%02x%02x%02x", r[i + 0] & 0xFF, r[i + 1] & 0xFF, - r[i + 2] & 0xFF, - r[i + 3] & 0xFF); + r[i + 2] & 0xFF, + r[i + 3] & 0xFF); p += 10; } Py_DECREF(w); @@ -3444,14 +3439,13 @@ * parsestr parses it, and returns the decoded Python string object. */ static PyObject * -parsestr(struct compiling *c, const node *n, const char *s) +parsestr(struct compiling *c, const char *s) { - size_t len, i; + size_t len; int quote = Py_CHARMASK(*s); int rawmode = 0; int need_encoding; int unicode = c->c_future_unicode; - int bytes = 0; if (isalpha(quote) || quote == '_') { if (quote == 'u' || quote == 'U') { @@ -3461,7 +3455,6 @@ if (quote == 'b' || quote == 'B') { quote = *++s; unicode = 0; - bytes = 1; } if (quote == 'r' || quote == 'R') { quote = *++s; @@ -3491,16 +3484,6 @@ return NULL; } } - if (Py_Py3kWarningFlag && bytes) { - for (i = 0; i < len; i++) { - if ((unsigned char)s[i] > 127) { - if (!ast_warn(c, n, - "non-ascii bytes literals not supported in 3.x")) - return NULL; - break; - } - } - } #ifdef Py_USING_UNICODE if (unicode || Py_UnicodeFlag) { return decode_unicode(c, s, len, rawmode, c->c_encoding); @@ -3543,11 +3526,11 @@ PyObject *v; int i; REQ(CHILD(n, 0), STRING); - if ((v = parsestr(c, n, STR(CHILD(n, 0)))) != NULL) { + if ((v = parsestr(c, STR(CHILD(n, 0)))) != NULL) { /* String literal concatenation */ for (i = 1; i < NCH(n); i++) { PyObject *s; - s = parsestr(c, n, STR(CHILD(n, i))); + s = parsestr(c, STR(CHILD(n, i))); if (s == NULL) goto onError; if (PyString_Check(v) && PyString_Check(s)) { diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Python/bltinmodule.c --- a/Python/bltinmodule.c Sat Jul 19 16:34:33 2014 -0700 +++ b/Python/bltinmodule.c Sun Jul 20 10:52:46 2014 -0400 @@ -53,12 +53,8 @@ PyDoc_STRVAR(import_doc, "__import__(name, globals={}, locals={}, fromlist=[], level=-1) -> module\n\ \n\ -Import a module. Because this function is meant for use by the Python\n\ -interpreter and not for general use it is better to use\n\ -importlib.import_module() to programmatically import a module.\n\ -\n\ -The globals argument is only used to determine the context;\n\ -they are not modified. The locals argument is unused. The fromlist\n\ +Import a module. The globals are only used to determine the context;\n\ +they are not modified. The locals are currently unused. The fromlist\n\ should be a list of names to emulate ``from name import ...'', or an\n\ empty list to emulate ``import name''.\n\ When importing a module from a package, note that __import__('A.B', ...)\n\ @@ -120,8 +116,7 @@ PyDoc_STRVAR(all_doc, "all(iterable) -> bool\n\ \n\ -Return True if bool(x) is True for all values x in the iterable.\n\ -If the iterable is empty, return True."); +Return True if bool(x) is True for all values x in the iterable."); static PyObject * builtin_any(PyObject *self, PyObject *v) @@ -163,8 +158,7 @@ PyDoc_STRVAR(any_doc, "any(iterable) -> bool\n\ \n\ -Return True if bool(x) is True for any x in the iterable.\n\ -If the iterable is empty, return False."); +Return True if bool(x) is True for any x in the iterable."); static PyObject * builtin_apply(PyObject *self, PyObject *args) @@ -315,7 +309,7 @@ ok = PyObject_IsTrue(good); Py_DECREF(good); } - if (ok > 0) { + if (ok) { if (j < len) PyList_SET_ITEM(result, j, item); else { @@ -326,11 +320,8 @@ } ++j; } - else { + else Py_DECREF(item); - if (ok < 0) - goto Fail_result_it; - } } @@ -525,8 +516,6 @@ mod_ty mod; arena = PyArena_New(); - if (arena == NULL) - return NULL; mod = PyAST_obj2mod(cmd, arena, mode); if (mod == NULL) { PyArena_Free(arena); @@ -1323,7 +1312,7 @@ PyDoc_STRVAR(len_doc, "len(object) -> integer\n\ \n\ -Return the number of items of a sequence or collection."); +Return the number of items of a sequence or mapping."); static PyObject * @@ -1589,7 +1578,6 @@ Py_CLEAR(str_newline); return NULL; } -#ifdef Py_USING_UNICODE unicode_newline = PyUnicode_FromString("\n"); if (unicode_newline == NULL) { Py_CLEAR(str_newline); @@ -1603,7 +1591,6 @@ Py_CLEAR(unicode_space); return NULL; } -#endif } if (!PyArg_ParseTupleAndKeywords(dummy_args, kwds, "|OOO:print", kwlist, &sep, &end, &file)) @@ -2006,8 +1993,7 @@ } PyDoc_STRVAR(range_doc, -"range(stop) -> list of integers\n\ -range(start, stop[, step]) -> list of integers\n\ +"range([start,] stop[, step]) -> list of integers\n\ \n\ Return a list containing an arithmetic progression of integers.\n\ range(i, j) returns [i, i+1, i+2, ..., j-1]; start (!) defaults to 0.\n\ @@ -2434,9 +2420,9 @@ PyDoc_STRVAR(sum_doc, "sum(sequence[, start]) -> value\n\ \n\ -Return the sum of a sequence of numbers (NOT strings) plus the value\n\ +Returns the sum of a sequence of numbers (NOT strings) plus the value\n\ of parameter 'start' (which defaults to 0). When the sequence is\n\ -empty, return start."); +empty, returns start."); static PyObject * @@ -2792,15 +2778,12 @@ } ok = PyObject_IsTrue(good); Py_DECREF(good); - if (ok > 0) { + if (ok) { if (PyTuple_SetItem(result, j++, item) < 0) goto Fail_1; } - else { + else Py_DECREF(item); - if (ok < 0) - goto Fail_1; - } } if (_PyTuple_Resize(&result, j) < 0) @@ -2862,7 +2845,7 @@ ok = PyObject_IsTrue(good); Py_DECREF(good); } - if (ok > 0) { + if (ok) { Py_ssize_t reslen; if (!PyString_Check(item)) { PyErr_SetString(PyExc_TypeError, "can't filter str to str:" @@ -2928,8 +2911,6 @@ } } Py_DECREF(item); - if (ok < 0) - goto Fail_1; } if (j < outlen) @@ -2990,7 +2971,7 @@ ok = PyObject_IsTrue(good); Py_DECREF(good); } - if (ok > 0) { + if (ok) { Py_ssize_t reslen; if (!PyUnicode_Check(item)) { PyErr_SetString(PyExc_TypeError, @@ -3045,8 +3026,6 @@ } } Py_DECREF(item); - if (ok < 0) - goto Fail_1; } if (j < outlen) diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Python/ceval.c --- a/Python/ceval.c Sat Jul 19 16:34:33 2014 -0700 +++ b/Python/ceval.c Sun Jul 20 10:52:46 2014 -0400 @@ -355,12 +355,6 @@ if (interpreter_lock) { int err = errno; PyThread_acquire_lock(interpreter_lock, 1); - /* _Py_Finalizing is protected by the GIL */ - if (_Py_Finalizing && tstate != _Py_Finalizing) { - PyThread_release_lock(interpreter_lock); - PyThread_exit_thread(); - assert(0); /* unreachable */ - } errno = err; } #endif @@ -1024,13 +1018,6 @@ /* Other threads may run now */ PyThread_acquire_lock(interpreter_lock, 1); - - /* Check if we should make a quick exit. */ - if (_Py_Finalizing && _Py_Finalizing != tstate) { - PyThread_release_lock(interpreter_lock); - PyThread_exit_thread(); - } - if (PyThreadState_Swap(tstate) != NULL) Py_FatalError("ceval: orphan tstate"); @@ -3253,7 +3240,8 @@ if (co->co_flags & CO_GENERATOR) { /* Don't need to keep the reference to f_back, it will be set * when the generator is resumed. */ - Py_CLEAR(f->f_back); + Py_XDECREF(f->f_back); + f->f_back = NULL; PCALL(PCALL_GENERATOR); diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Python/codecs.c --- a/Python/codecs.c Sat Jul 19 16:34:33 2014 -0700 +++ b/Python/codecs.c Sun Jul 20 10:52:46 2014 -0400 @@ -521,7 +521,7 @@ Py_UNICODE res = Py_UNICODE_REPLACEMENT_CHARACTER; if (PyUnicodeDecodeError_GetEnd(exc, &end)) return NULL; - return Py_BuildValue("(u#n)", &res, (Py_ssize_t)1, end); + return Py_BuildValue("(u#n)", &res, 1, end); } else if (PyObject_IsInstance(exc, PyExc_UnicodeTranslateError)) { PyObject *res; @@ -556,7 +556,6 @@ PyObject *res; Py_UNICODE *p; Py_UNICODE *startp; - Py_UNICODE *e; Py_UNICODE *outp; int ressize; if (PyUnicodeEncodeError_GetStart(exc, &start)) @@ -566,31 +565,26 @@ if (!(object = PyUnicodeEncodeError_GetObject(exc))) return NULL; startp = PyUnicode_AS_UNICODE(object); - e = startp + end; - for (p = startp+start, ressize = 0; p < e;) { - Py_UCS4 ch = *p++; + for (p = startp+start, ressize = 0; p < startp+end; ++p) { + if (*p<10) + ressize += 2+1+1; + else if (*p<100) + ressize += 2+2+1; + else if (*p<1000) + ressize += 2+3+1; + else if (*p<10000) + ressize += 2+4+1; #ifndef Py_UNICODE_WIDE - if ((0xD800 <= ch && ch <= 0xDBFF) && - (p < e) && - (0xDC00 <= *p && *p <= 0xDFFF)) { - ch = ((((ch & 0x03FF) << 10) | - ((Py_UCS4)*p++ & 0x03FF)) + 0x10000); - } -#endif - if (ch < 10) - ressize += 2+1+1; - else if (ch < 100) - ressize += 2+2+1; - else if (ch < 1000) - ressize += 2+3+1; - else if (ch < 10000) - ressize += 2+4+1; - else if (ch < 100000) + else ressize += 2+5+1; - else if (ch < 1000000) +#else + else if (*p<100000) + ressize += 2+5+1; + else if (*p<1000000) ressize += 2+6+1; else ressize += 2+7+1; +#endif } /* allocate replacement */ res = PyUnicode_FromUnicode(NULL, ressize); @@ -599,41 +593,40 @@ return NULL; } /* generate replacement */ - for (p = startp+start, outp = PyUnicode_AS_UNICODE(res); p < e;) { + for (p = startp+start, outp = PyUnicode_AS_UNICODE(res); + p < startp+end; ++p) { + Py_UNICODE c = *p; int digits; int base; - Py_UCS4 ch = *p++; -#ifndef Py_UNICODE_WIDE - if ((0xD800 <= ch && ch <= 0xDBFF) && - (p < startp+end) && - (0xDC00 <= *p && *p <= 0xDFFF)) { - ch = ((((ch & 0x03FF) << 10) | - ((Py_UCS4)*p++ & 0x03FF)) + 0x10000); - } -#endif *outp++ = '&'; *outp++ = '#'; - if (ch < 10) { + if (*p<10) { digits = 1; base = 1; } - else if (ch < 100) { + else if (*p<100) { digits = 2; base = 10; } - else if (ch < 1000) { + else if (*p<1000) { digits = 3; base = 100; } - else if (ch < 10000) { + else if (*p<10000) { digits = 4; base = 1000; } - else if (ch < 100000) { +#ifndef Py_UNICODE_WIDE + else { digits = 5; base = 10000; } - else if (ch < 1000000) { +#else + else if (*p<100000) { + digits = 5; + base = 10000; + } + else if (*p<1000000) { digits = 6; base = 100000; } @@ -641,9 +634,10 @@ digits = 7; base = 1000000; } +#endif while (digits-->0) { - *outp++ = '0' + ch/base; - ch %= base; + *outp++ = '0' + c/base; + c %= base; base /= 10; } *outp++ = ';'; diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Python/compile.c --- a/Python/compile.c Sat Jul 19 16:34:33 2014 -0700 +++ b/Python/compile.c Sun Jul 20 10:52:46 2014 -0400 @@ -221,11 +221,8 @@ } plen = strlen(p); - if (plen + nlen >= PY_SSIZE_T_MAX - 1) { - PyErr_SetString(PyExc_OverflowError, - "private identifier too large to be mangled"); - return NULL; - } + assert(1 <= PY_SSIZE_T_MAX - nlen); + assert(1 + nlen <= PY_SSIZE_T_MAX - plen); ident = PyString_FromStringAndSize(NULL, 1 + nlen + plen); if (!ident) @@ -362,31 +359,14 @@ static PyObject * dictbytype(PyObject *src, int scope_type, int flag, int offset) { - Py_ssize_t i = offset, scope, num_keys, key_i; + Py_ssize_t pos = 0, i = offset, scope; PyObject *k, *v, *dest = PyDict_New(); - PyObject *sorted_keys; assert(offset >= 0); if (dest == NULL) return NULL; - /* Sort the keys so that we have a deterministic order on the indexes - saved in the returned dictionary. These indexes are used as indexes - into the free and cell var storage. Therefore if they aren't - deterministic, then the generated bytecode is not deterministic. - */ - sorted_keys = PyDict_Keys(src); - if (sorted_keys == NULL) - return NULL; - if (PyList_Sort(sorted_keys) != 0) { - Py_DECREF(sorted_keys); - return NULL; - } - num_keys = PyList_GET_SIZE(sorted_keys); - - for (key_i = 0; key_i < num_keys; key_i++) { - k = PyList_GET_ITEM(sorted_keys, key_i); - v = PyDict_GetItem(src, k); + while (PyDict_Next(src, &pos, &k, &v)) { /* XXX this should probably be a macro in symtable.h */ assert(PyInt_Check(v)); scope = (PyInt_AS_LONG(v) >> SCOPE_OFF) & SCOPE_MASK; @@ -394,14 +374,12 @@ if (scope == scope_type || PyInt_AS_LONG(v) & flag) { PyObject *tuple, *item = PyInt_FromLong(i); if (item == NULL) { - Py_DECREF(sorted_keys); Py_DECREF(dest); return NULL; } i++; tuple = PyTuple_Pack(2, k, k->ob_type); if (!tuple || PyDict_SetItem(dest, tuple, item) < 0) { - Py_DECREF(sorted_keys); Py_DECREF(item); Py_DECREF(dest); Py_XDECREF(tuple); @@ -411,7 +389,6 @@ Py_DECREF(tuple); } } - Py_DECREF(sorted_keys); return dest; } @@ -3483,16 +3460,12 @@ target_depth = depth; if (instr->i_opcode == FOR_ITER) { target_depth = depth-2; - } - else if (instr->i_opcode == SETUP_FINALLY || - instr->i_opcode == SETUP_EXCEPT) { + } else if (instr->i_opcode == SETUP_FINALLY || + instr->i_opcode == SETUP_EXCEPT) { target_depth = depth+3; if (target_depth > maxdepth) maxdepth = target_depth; } - else if (instr->i_opcode == JUMP_IF_TRUE_OR_POP || - instr->i_opcode == JUMP_IF_FALSE_OR_POP) - depth = depth - 1; maxdepth = stackdepth_walk(c, instr->i_target, target_depth, maxdepth); if (instr->i_opcode == JUMP_ABSOLUTE || diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Python/dtoa.c --- a/Python/dtoa.c Sat Jul 19 16:34:33 2014 -0700 +++ b/Python/dtoa.c Sun Jul 20 10:52:46 2014 -0400 @@ -204,24 +204,7 @@ MAX_ABS_EXP in absolute value get truncated to +-MAX_ABS_EXP. MAX_ABS_EXP should fit into an int. */ #ifndef MAX_ABS_EXP -#define MAX_ABS_EXP 1100000000U -#endif -/* Bound on length of pieces of input strings in _Py_dg_strtod; specifically, - this is used to bound the total number of digits ignoring leading zeros and - the number of digits that follow the decimal point. Ideally, MAX_DIGITS - should satisfy MAX_DIGITS + 400 < MAX_ABS_EXP; that ensures that the - exponent clipping in _Py_dg_strtod can't affect the value of the output. */ -#ifndef MAX_DIGITS -#define MAX_DIGITS 1000000000U -#endif - -/* Guard against trying to use the above values on unusual platforms with ints - * of width less than 32 bits. */ -#if MAX_ABS_EXP > INT_MAX -#error "MAX_ABS_EXP should fit in an int" -#endif -#if MAX_DIGITS > INT_MAX -#error "MAX_DIGITS should fit in an int" +#define MAX_ABS_EXP 19999U #endif /* The following definition of Storeinc is appropriate for MIPS processors. @@ -1515,7 +1498,6 @@ Long L; BCinfo bc; Bigint *bb, *bb1, *bd, *bd0, *bs, *delta; - size_t ndigits, fraclen; dval(&rv) = 0.; @@ -1538,53 +1520,40 @@ c = *++s; lz = s != s1; - /* Point s0 at the first nonzero digit (if any). fraclen will be the - number of digits between the decimal point and the end of the - digit string. ndigits will be the total number of digits ignoring - leading zeros. */ + /* Point s0 at the first nonzero digit (if any). nd0 will be the position + of the point relative to s0. nd will be the total number of digits + ignoring leading zeros. */ s0 = s1 = s; while ('0' <= c && c <= '9') c = *++s; - ndigits = s - s1; - fraclen = 0; + nd0 = nd = s - s1; /* Parse decimal point and following digits. */ if (c == '.') { c = *++s; - if (!ndigits) { + if (!nd) { s1 = s; while (c == '0') c = *++s; lz = lz || s != s1; - fraclen += (s - s1); + nd0 -= s - s1; s0 = s; } s1 = s; while ('0' <= c && c <= '9') c = *++s; - ndigits += s - s1; - fraclen += s - s1; + nd += s - s1; } - /* Now lz is true if and only if there were leading zero digits, and - ndigits gives the total number of digits ignoring leading zeros. A - valid input must have at least one digit. */ - if (!ndigits && !lz) { + /* Now lz is true if and only if there were leading zero digits, and nd + gives the total number of digits ignoring leading zeros. A valid input + must have at least one digit. */ + if (!nd && !lz) { if (se) *se = (char *)s00; goto parse_error; } - /* Range check ndigits and fraclen to make sure that they, and values - computed with them, can safely fit in an int. */ - if (ndigits > MAX_DIGITS || fraclen > MAX_DIGITS) { - if (se) - *se = (char *)s00; - goto parse_error; - } - nd = (int)ndigits; - nd0 = (int)ndigits - (int)fraclen; - /* Parse exponent. */ e = 0; if (c == 'e' || c == 'E') { @@ -1917,20 +1886,20 @@ bd2++; /* At this stage bd5 - bb5 == e == bd2 - bb2 + bbe, bb2 - bs2 == 1, - and bs == 1, so: + and bs == 1, so: tdv == bd * 10**e = bd * 2**(bbe - bb2 + bd2) * 5**(bd5 - bb5) srv == bb * 2**bbe = bb * 2**(bbe - bb2 + bb2) - 0.5 ulp(srv) == 2**(bbe-1) = bs * 2**(bbe - bb2 + bs2) + 0.5 ulp(srv) == 2**(bbe-1) = bs * 2**(bbe - bb2 + bs2) - It follows that: + It follows that: M * tdv = bd * 2**bd2 * 5**bd5 M * srv = bb * 2**bb2 * 5**bb5 M * 0.5 ulp(srv) = bs * 2**bs2 * 5**bb5 - for some constant M. (Actually, M == 2**(bb2 - bbe) * 5**bb5, but - this fact is not needed below.) + for some constant M. (Actually, M == 2**(bb2 - bbe) * 5**bb5, but + this fact is not needed below.) */ /* Remove factor of 2**i, where i = min(bb2, bd2, bs2). */ diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Python/future.c --- a/Python/future.c Sat Jul 19 16:34:33 2014 -0700 +++ b/Python/future.c Sun Jul 20 10:52:46 2014 -0400 @@ -59,6 +59,13 @@ { int i, found_docstring = 0, done = 0, prev_line = 0; + static PyObject *future; + if (!future) { + future = PyString_InternFromString("__future__"); + if (!future) + return 0; + } + if (!(mod->kind == Module_kind || mod->kind == Interactive_kind)) return 1; @@ -85,9 +92,7 @@ */ if (s->kind == ImportFrom_kind) { - identifier modname = s->v.ImportFrom.module; - if (modname && PyString_GET_SIZE(modname) == 10 && - !strcmp(PyString_AS_STRING(modname), "__future__")) { + if (s->v.ImportFrom.module == future) { if (done) { PyErr_SetString(PyExc_SyntaxError, ERR_LATE_FUTURE); diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Python/getargs.c --- a/Python/getargs.c Sat Jul 19 16:34:33 2014 -0700 +++ b/Python/getargs.c Sun Jul 20 10:52:46 2014 -0400 @@ -1410,7 +1410,7 @@ *errmsg = "convertible to a buffer"; return count; } - PyBuffer_FillInfo(view, arg, buf, count, 1, 0); + PyBuffer_FillInfo(view, NULL, buf, count, 1, 0); return 0; } @@ -1837,7 +1837,6 @@ assert(min >= 0); assert(min <= max); if (!PyTuple_Check(args)) { - va_end(vargs); PyErr_SetString(PyExc_SystemError, "PyArg_UnpackTuple() argument list is not a tuple"); return 0; diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Python/getcopyright.c --- a/Python/getcopyright.c Sat Jul 19 16:34:33 2014 -0700 +++ b/Python/getcopyright.c Sun Jul 20 10:52:46 2014 -0400 @@ -4,7 +4,7 @@ static char cprt[] = "\ -Copyright (c) 2001-2014 Python Software Foundation.\n\ +Copyright (c) 2001-2011 Python Software Foundation.\n\ All Rights Reserved.\n\ \n\ Copyright (c) 2000 BeOpen.com.\n\ diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Python/getopt.c --- a/Python/getopt.c Sat Jul 19 16:34:33 2014 -0700 +++ b/Python/getopt.c Sun Jul 20 10:52:46 2014 -0400 @@ -37,18 +37,10 @@ int _PyOS_opterr = 1; /* generate error messages */ int _PyOS_optind = 1; /* index into argv array */ char *_PyOS_optarg = NULL; /* optional argument */ -static char *opt_ptr = ""; - -void _PyOS_ResetGetOpt(void) -{ - _PyOS_opterr = 1; - _PyOS_optind = 1; - _PyOS_optarg = NULL; - opt_ptr = ""; -} int _PyOS_GetOpt(int argc, char **argv, char *optstring) { + static char *opt_ptr = ""; char *ptr; int option; @@ -86,19 +78,17 @@ opt_ptr = &argv[_PyOS_optind++][1]; } - if ((option = *opt_ptr++) == '\0') + if ( (option = *opt_ptr++) == '\0') return -1; if (option == 'J') { - if (_PyOS_opterr) - fprintf(stderr, "-J is reserved for Jython\n"); + fprintf(stderr, "-J is reserved for Jython\n"); return '_'; } if (option == 'X') { - if (_PyOS_opterr) - fprintf(stderr, - "-X is reserved for implementation-specific arguments\n"); + fprintf(stderr, + "-X is reserved for implementation-specific arguments\n"); return '_'; } @@ -119,7 +109,7 @@ if (_PyOS_optind >= argc) { if (_PyOS_opterr) fprintf(stderr, - "Argument expected for the -%c option\n", option); + "Argument expected for the -%c option\n", option); return '_'; } diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Python/import.c --- a/Python/import.c Sat Jul 19 16:34:33 2014 -0700 +++ b/Python/import.c Sun Jul 20 10:52:46 2014 -0400 @@ -114,34 +114,6 @@ }; #endif -#ifdef MS_WINDOWS -static int isdir(char *path) { - DWORD rv; - /* see issue1293 and issue3677: - * stat() on Windows doesn't recognise paths like - * "e:\\shared\\" and "\\\\whiterab-c2znlh\\shared" as dirs. - * Also reference issue6727: - * stat() on Windows is broken and doesn't resolve symlinks properly. - */ - rv = GetFileAttributesA(path); - return rv != INVALID_FILE_ATTRIBUTES && rv & FILE_ATTRIBUTE_DIRECTORY; -} -#else -#ifdef HAVE_STAT -static int isdir(char *path) { - struct stat statbuf; - return stat(path, &statbuf) == 0 && S_ISDIR(statbuf.st_mode); -} -#else -#ifdef RISCOS -/* with RISCOS, isdir is in unixstuff */ -#else -int isdir(char *path) { - return 0; -} -#endif /* RISCOS */ -#endif /* HAVE_STAT */ -#endif /* MS_WINDOWS */ /* Initialize things */ @@ -904,17 +876,12 @@ remove the file. */ static void -write_compiled_module(PyCodeObject *co, char *cpathname, struct stat *srcstat, time_t mtime) +write_compiled_module(PyCodeObject *co, char *cpathname, struct stat *srcstat) { FILE *fp; + time_t mtime = srcstat->st_mtime; #ifdef MS_WINDOWS /* since Windows uses different permissions */ mode_t mode = srcstat->st_mode & ~S_IEXEC; - /* Issue #6074: We ensure user write access, so we can delete it later - * when the source file changes. (On POSIX, this only requires write - * access to the directory, on Windows, we need write access to the file - * as well) - */ - mode |= _S_IWRITE; #else mode_t mode = srcstat->st_mode & ~S_IXUSR & ~S_IXGRP & ~S_IXOTH; #endif @@ -938,9 +905,9 @@ (void) unlink(cpathname); return; } - /* Now write the true mtime (as a 32-bit field) */ + /* Now write the true mtime */ fseek(fp, 4L, 0); - assert(mtime <= 0xFFFFFFFF); + assert(mtime < LONG_MAX); PyMarshal_WriteLongToFile((long)mtime, fp, Py_MARSHAL_VERSION); fflush(fp); fclose(fp); @@ -992,38 +959,6 @@ return 1; } -#ifdef MS_WINDOWS - -/* Seconds between 1.1.1601 and 1.1.1970 */ -static __int64 secs_between_epochs = 11644473600; - -/* Get mtime from file pointer. */ - -static time_t -win32_mtime(FILE *fp, char *pathname) -{ - __int64 filetime; - HANDLE fh; - BY_HANDLE_FILE_INFORMATION file_information; - - fh = (HANDLE)_get_osfhandle(fileno(fp)); - if (fh == INVALID_HANDLE_VALUE || - !GetFileInformationByHandle(fh, &file_information)) { - PyErr_Format(PyExc_RuntimeError, - "unable to get file status from '%s'", - pathname); - return -1; - } - /* filetime represents the number of 100ns intervals since - 1.1.1601 (UTC). Convert to seconds since 1.1.1970 (UTC). */ - filetime = (__int64)file_information.ftLastWriteTime.dwHighDateTime << 32 | - file_information.ftLastWriteTime.dwLowDateTime; - return filetime / 10000000 - secs_between_epochs; -} - -#endif /* #ifdef MS_WINDOWS */ - - /* Load a source module from a given file and return its module object WITH INCREMENTED REFERENCE COUNT. If there's a matching byte-compiled file, use that instead. */ @@ -1033,11 +968,10 @@ { struct stat st; FILE *fpc; - char *buf; + char buf[MAXPATHLEN+1]; char *cpathname; - PyCodeObject *co = NULL; + PyCodeObject *co; PyObject *m; - time_t mtime; if (fstat(fileno(fp), &st) != 0) { PyErr_Format(PyExc_RuntimeError, @@ -1045,36 +979,27 @@ pathname); return NULL; } - -#ifdef MS_WINDOWS - mtime = win32_mtime(fp, pathname); - if (mtime == (time_t)-1 && PyErr_Occurred()) +#if SIZEOF_TIME_T > 4 + /* Python's .pyc timestamp handling presumes that the timestamp fits + in 4 bytes. This will be fine until sometime in the year 2038, + when a 4-byte signed time_t will overflow. + */ + if (st.st_mtime >> 32) { + PyErr_SetString(PyExc_OverflowError, + "modification time overflows a 4 byte field"); return NULL; -#else - mtime = st.st_mtime; + } #endif - if (sizeof mtime > 4) { - /* Python's .pyc timestamp handling presumes that the timestamp fits - in 4 bytes. Since the code only does an equality comparison, - ordering is not important and we can safely ignore the higher bits - (collisions are extremely unlikely). - */ - mtime &= 0xFFFFFFFF; - } - buf = PyMem_MALLOC(MAXPATHLEN+1); - if (buf == NULL) { - return PyErr_NoMemory(); - } cpathname = make_compiled_pathname(pathname, buf, (size_t)MAXPATHLEN + 1); if (cpathname != NULL && - (fpc = check_compiled_module(pathname, mtime, cpathname))) { + (fpc = check_compiled_module(pathname, st.st_mtime, cpathname))) { co = read_compiled_module(cpathname, fpc); fclose(fpc); if (co == NULL) - goto error_exit; + return NULL; if (update_compiled_module(co, pathname) < 0) - goto error_exit; + return NULL; if (Py_VerboseFlag) PySys_WriteStderr("import %s # precompiled from %s\n", name, cpathname); @@ -1083,29 +1008,20 @@ else { co = parse_source_module(pathname, fp); if (co == NULL) - goto error_exit; + return NULL; if (Py_VerboseFlag) PySys_WriteStderr("import %s # from %s\n", name, pathname); if (cpathname) { PyObject *ro = PySys_GetObject("dont_write_bytecode"); - int b = (ro == NULL) ? 0 : PyObject_IsTrue(ro); - if (b < 0) - goto error_exit; - if (!b) - write_compiled_module(co, cpathname, &st, mtime); + if (ro == NULL || !PyObject_IsTrue(ro)) + write_compiled_module(co, cpathname, &st); } } m = PyImport_ExecCodeModuleEx(name, (PyObject *)co, pathname); Py_DECREF(co); - PyMem_FREE(buf); return m; - -error_exit: - Py_XDECREF(co); - PyMem_FREE(buf); - return NULL; } @@ -1125,7 +1041,7 @@ PyObject *file = NULL; PyObject *path = NULL; int err; - char *buf = NULL; + char buf[MAXPATHLEN+1]; FILE *fp = NULL; struct filedescr *fdp; @@ -1147,13 +1063,8 @@ err = PyDict_SetItemString(d, "__path__", path); if (err != 0) goto error; - buf = PyMem_MALLOC(MAXPATHLEN+1); - if (buf == NULL) { - PyErr_NoMemory(); - goto error; - } buf[0] = '\0'; - fdp = find_module(name, "__init__", path, buf, MAXPATHLEN+1, &fp, NULL); + fdp = find_module(name, "__init__", path, buf, sizeof(buf), &fp, NULL); if (fdp == NULL) { if (PyErr_ExceptionMatches(PyExc_ImportError)) { PyErr_Clear(); @@ -1171,8 +1082,6 @@ error: m = NULL; cleanup: - if (buf) - PyMem_FREE(buf); Py_XDECREF(path); Py_XDECREF(file); return m; @@ -1298,10 +1207,13 @@ char *filemode; FILE *fp = NULL; PyObject *path_hooks, *path_importer_cache; +#ifndef RISCOS + struct stat statbuf; +#endif static struct filedescr fd_frozen = {"", "", PY_FROZEN}; static struct filedescr fd_builtin = {"", "", C_BUILTIN}; static struct filedescr fd_package = {"", "", PKG_DIRECTORY}; - char *name; + char name[MAXPATHLEN+1]; #if defined(PYOS_OS2) size_t saved_len; size_t saved_namelen; @@ -1315,11 +1227,6 @@ "module name is too long"); return NULL; } - name = PyMem_MALLOC(MAXPATHLEN+1); - if (name == NULL) { - PyErr_NoMemory(); - return NULL; - } strcpy(name, subname); /* sys.meta_path import hook */ @@ -1331,7 +1238,7 @@ PyErr_SetString(PyExc_RuntimeError, "sys.meta_path must be a list of " "import hooks"); - goto error_exit; + return NULL; } Py_INCREF(meta_path); /* zap guard */ npath = PyList_Size(meta_path); @@ -1344,13 +1251,12 @@ path : Py_None); if (loader == NULL) { Py_DECREF(meta_path); - goto error_exit; /* true error */ + return NULL; /* true error */ } if (loader != Py_None) { /* a loader was found */ *p_loader = loader; Py_DECREF(meta_path); - PyMem_FREE(name); return &importhookdescr; } Py_DECREF(loader); @@ -1364,7 +1270,7 @@ if (PyString_Size(path) + 1 + strlen(name) >= (size_t)buflen) { PyErr_SetString(PyExc_ImportError, "full frozen module name too long"); - goto error_exit; + return NULL; } strcpy(buf, PyString_AsString(path)); strcat(buf, "."); @@ -1372,22 +1278,19 @@ strcpy(name, buf); if (find_frozen(name) != NULL) { strcpy(buf, name); - PyMem_FREE(name); return &fd_frozen; } PyErr_Format(PyExc_ImportError, "No frozen submodule named %.200s", name); - goto error_exit; + return NULL; } if (path == NULL) { if (is_builtin(name)) { strcpy(buf, name); - PyMem_FREE(name); return &fd_builtin; } if ((find_frozen(name)) != NULL) { strcpy(buf, name); - PyMem_FREE(name); return &fd_frozen; } @@ -1395,7 +1298,6 @@ fp = PyWin_FindRegisteredModule(name, &fdp, buf, buflen); if (fp != NULL) { *p_fp = fp; - PyMem_FREE(name); return fdp; } #endif @@ -1404,7 +1306,7 @@ if (path == NULL || !PyList_Check(path)) { PyErr_SetString(PyExc_RuntimeError, "sys.path must be a list of directory names"); - goto error_exit; + return NULL; } path_hooks = PySys_GetObject("path_hooks"); @@ -1412,14 +1314,14 @@ PyErr_SetString(PyExc_RuntimeError, "sys.path_hooks must be a list of " "import hooks"); - goto error_exit; + return NULL; } path_importer_cache = PySys_GetObject("path_importer_cache"); if (path_importer_cache == NULL || !PyDict_Check(path_importer_cache)) { PyErr_SetString(PyExc_RuntimeError, "sys.path_importer_cache must be a dict"); - goto error_exit; + return NULL; } npath = PyList_Size(path); @@ -1428,13 +1330,13 @@ PyObject *copy = NULL; PyObject *v = PyList_GetItem(path, i); if (!v) - goto error_exit; + return NULL; #ifdef Py_USING_UNICODE if (PyUnicode_Check(v)) { copy = PyUnicode_Encode(PyUnicode_AS_UNICODE(v), PyUnicode_GET_SIZE(v), Py_FileSystemDefaultEncoding, NULL); if (copy == NULL) - goto error_exit; + return NULL; v = copy; } else @@ -1460,7 +1362,7 @@ path_hooks, v); if (importer == NULL) { Py_XDECREF(copy); - goto error_exit; + return NULL; } /* Note: importer is a borrowed reference */ if (importer != Py_None) { @@ -1470,11 +1372,10 @@ "s", fullname); Py_XDECREF(copy); if (loader == NULL) - goto error_exit; /* error */ + return NULL; /* error */ if (loader != Py_None) { /* a loader was found */ *p_loader = loader; - PyMem_FREE(name); return &importhookdescr; } Py_DECREF(loader); @@ -1494,11 +1395,12 @@ /* Check for package import (buf holds a directory name, and there's an __init__ module in that directory */ - if (isdir(buf) && /* it's an existing directory */ +#ifdef HAVE_STAT + if (stat(buf, &statbuf) == 0 && /* it exists */ + S_ISDIR(statbuf.st_mode) && /* it's a directory */ case_ok(buf, len, namelen, name)) { /* case matches */ if (find_init_module(buf)) { /* and has __init__.py */ Py_XDECREF(copy); - PyMem_FREE(name); return &fd_package; } else { @@ -1509,10 +1411,32 @@ if (PyErr_Warn(PyExc_ImportWarning, warnstr)) { Py_XDECREF(copy); - goto error_exit; + return NULL; } } } +#else + /* XXX How are you going to test for directories? */ +#ifdef RISCOS + if (isdir(buf) && + case_ok(buf, len, namelen, name)) { + if (find_init_module(buf)) { + Py_XDECREF(copy); + return &fd_package; + } + else { + char warnstr[MAXPATHLEN+80]; + sprintf(warnstr, "Not importing directory " + "'%.*s': missing __init__.py", + MAXPATHLEN, buf); + if (PyErr_Warn(PyExc_ImportWarning, + warnstr)) { + Py_XDECREF(copy); + return NULL; + } + } +#endif +#endif #if defined(PYOS_OS2) /* take a snapshot of the module spec for restoration * after the 8 character DLL hackery @@ -1584,15 +1508,10 @@ if (fp == NULL) { PyErr_Format(PyExc_ImportError, "No module named %.200s", name); - goto error_exit; + return NULL; } *p_fp = fp; - PyMem_FREE(name); return fdp; - -error_exit: - PyMem_FREE(name); - return NULL; } /* Helpers for main.c @@ -2199,7 +2118,7 @@ import_module_level(char *name, PyObject *globals, PyObject *locals, PyObject *fromlist, int level) { - char *buf; + char buf[MAXPATHLEN+1]; Py_ssize_t buflen = 0; PyObject *parent, *head, *next, *tail; @@ -2213,18 +2132,14 @@ return NULL; } - buf = PyMem_MALLOC(MAXPATHLEN+1); - if (buf == NULL) { - return PyErr_NoMemory(); - } parent = get_parent(globals, buf, &buflen, level); if (parent == NULL) - goto error_exit; + return NULL; head = load_next(parent, level < 0 ? Py_None : parent, &name, buf, &buflen); if (head == NULL) - goto error_exit; + return NULL; tail = head; Py_INCREF(tail); @@ -2233,7 +2148,7 @@ Py_DECREF(tail); if (next == NULL) { Py_DECREF(head); - goto error_exit; + return NULL; } tail = next; } @@ -2245,38 +2160,26 @@ Py_DECREF(head); PyErr_SetString(PyExc_ValueError, "Empty module name"); - goto error_exit; + return NULL; } if (fromlist != NULL) { - int b = (fromlist == Py_None) ? 0 : PyObject_IsTrue(fromlist); - if (b < 0) { - Py_DECREF(tail); - Py_DECREF(head); - goto error_exit; - } - if (!b) + if (fromlist == Py_None || !PyObject_IsTrue(fromlist)) fromlist = NULL; } if (fromlist == NULL) { Py_DECREF(tail); - PyMem_FREE(buf); return head; } Py_DECREF(head); if (!ensure_fromlist(tail, fromlist, buf, buflen, 0)) { Py_DECREF(tail); - goto error_exit; + return NULL; } - PyMem_FREE(buf); return tail; - -error_exit: - PyMem_FREE(buf); - return NULL; } PyObject * @@ -2666,7 +2569,7 @@ } else { PyObject *path, *loader = NULL; - char *buf; + char buf[MAXPATHLEN+1]; struct filedescr *fdp; FILE *fp = NULL; @@ -2681,16 +2584,11 @@ } } - buf = PyMem_MALLOC(MAXPATHLEN+1); - if (buf == NULL) { - return PyErr_NoMemory(); - } buf[0] = '\0'; fdp = find_module(fullname, subname, path, buf, MAXPATHLEN+1, &fp, &loader); Py_XDECREF(path); if (fdp == NULL) { - PyMem_FREE(buf); if (!PyErr_ExceptionMatches(PyExc_ImportError)) return NULL; PyErr_Clear(); @@ -2705,7 +2603,6 @@ Py_XDECREF(m); m = NULL; } - PyMem_FREE(buf); } return m; @@ -2723,7 +2620,7 @@ PyObject *modules = PyImport_GetModuleDict(); PyObject *path = NULL, *loader = NULL, *existing_m = NULL; char *name, *subname; - char *buf; + char buf[MAXPATHLEN+1]; struct filedescr *fdp; FILE *fp = NULL; PyObject *newm; @@ -2783,11 +2680,6 @@ if (path == NULL) PyErr_Clear(); } - buf = PyMem_MALLOC(MAXPATHLEN+1); - if (buf == NULL) { - Py_XDECREF(path); - return PyErr_NoMemory(); - } buf[0] = '\0'; fdp = find_module(name, subname, path, buf, MAXPATHLEN+1, &fp, &loader); Py_XDECREF(path); @@ -2795,7 +2687,6 @@ if (fdp == NULL) { Py_XDECREF(loader); imp_modules_reloading_clear(); - PyMem_FREE(buf); return NULL; } @@ -2813,7 +2704,6 @@ PyDict_SetItemString(modules, name, m); } imp_modules_reloading_clear(); - PyMem_FREE(buf); return newm; } @@ -2944,27 +2834,19 @@ extern int fclose(FILE *); PyObject *fob, *ret; struct filedescr *fdp; - char *pathname; + char pathname[MAXPATHLEN+1]; FILE *fp = NULL; - pathname = PyMem_MALLOC(MAXPATHLEN+1); - if (pathname == NULL) { - return PyErr_NoMemory(); - } pathname[0] = '\0'; if (path == Py_None) path = NULL; fdp = find_module(NULL, name, path, pathname, MAXPATHLEN+1, &fp, NULL); - if (fdp == NULL) { - PyMem_FREE(pathname); + if (fdp == NULL) return NULL; - } if (fp != NULL) { fob = PyFile_FromFile(fp, pathname, fdp->mode, fclose); - if (fob == NULL) { - PyMem_FREE(pathname); + if (fob == NULL) return NULL; - } } else { fob = Py_None; @@ -2973,7 +2855,6 @@ ret = Py_BuildValue("Os(ssi)", fob, pathname, fdp->suffix, fdp->mode, fdp->type); Py_DECREF(fob); - PyMem_FREE(pathname); return ret; } @@ -3321,11 +3202,49 @@ PyErr_SetString(PyExc_ImportError, "empty pathname"); return -1; } else { - if(isdir(path)) { - PyErr_SetString(PyExc_ImportError, - "existing directory"); - return -1; +#ifndef RISCOS +#ifndef MS_WINDOWS + struct stat statbuf; + int rv; + + rv = stat(path, &statbuf); + if (rv == 0) { + /* it exists */ + if (S_ISDIR(statbuf.st_mode)) { + /* it's a directory */ + PyErr_SetString(PyExc_ImportError, + "existing directory"); + return -1; + } } +#else /* MS_WINDOWS */ + DWORD rv; + /* see issue1293 and issue3677: + * stat() on Windows doesn't recognise paths like + * "e:\\shared\\" and "\\\\whiterab-c2znlh\\shared" as dirs. + */ + rv = GetFileAttributesA(path); + if (rv != INVALID_FILE_ATTRIBUTES) { + /* it exists */ + if (rv & FILE_ATTRIBUTE_DIRECTORY) { + /* it's a directory */ + PyErr_SetString(PyExc_ImportError, + "existing directory"); + return -1; + } + } +#endif +#else /* RISCOS */ + if (object_exists(path)) { + /* it exists */ + if (isdir(path)) { + /* it's a directory */ + PyErr_SetString(PyExc_ImportError, + "existing directory"); + return -1; + } + } +#endif } return 0; } diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Python/marshal.c --- a/Python/marshal.c Sat Jul 19 16:34:33 2014 -0700 +++ b/Python/marshal.c Sun Jul 20 10:52:46 2014 -0400 @@ -88,7 +88,7 @@ } static void -w_string(const char *s, Py_ssize_t n, WFILE *p) +w_string(char *s, int n, WFILE *p) { if (p->fp != NULL) { fwrite(s, 1, n, p->fp); @@ -126,28 +126,6 @@ } #endif -#define SIZE32_MAX 0x7FFFFFFF - -#if SIZEOF_SIZE_T > 4 -# define W_SIZE(n, p) do { \ - if ((n) > SIZE32_MAX) { \ - (p)->depth--; \ - (p)->error = WFERR_UNMARSHALLABLE; \ - return; \ - } \ - w_long((long)(n), p); \ - } while(0) -#else -# define W_SIZE w_long -#endif - -static void -w_pstring(const char *s, Py_ssize_t n, WFILE *p) -{ - W_SIZE(n, p); - w_string(s, n, p); -} - /* We assume that Python longs are stored internally in base some power of 2**15; for the sake of portability we'll always read and write them in base exactly 2**15. */ @@ -181,11 +159,6 @@ d >>= PyLong_MARSHAL_SHIFT; l++; } while (d != 0); - if (l > SIZE32_MAX) { - p->depth--; - p->error = WFERR_UNMARSHALLABLE; - return; - } w_long((long)(Py_SIZE(ob) > 0 ? l : -l), p); for (i=0; i < n-1; i++) { @@ -271,7 +244,7 @@ n = strlen(buf); w_byte(TYPE_FLOAT, p); w_byte((int)n, p); - w_string(buf, n, p); + w_string(buf, (int)n, p); PyMem_Free(buf); } } @@ -304,7 +277,7 @@ } n = strlen(buf); w_byte((int)n, p); - w_string(buf, n, p); + w_string(buf, (int)n, p); PyMem_Free(buf); buf = PyOS_double_to_string(PyComplex_ImagAsDouble(v), 'g', 17, 0, NULL); @@ -314,7 +287,7 @@ } n = strlen(buf); w_byte((int)n, p); - w_string(buf, n, p); + w_string(buf, (int)n, p); PyMem_Free(buf); } } @@ -345,7 +318,15 @@ else { w_byte(TYPE_STRING, p); } - w_pstring(PyBytes_AS_STRING(v), PyString_GET_SIZE(v), p); + n = PyString_GET_SIZE(v); + if (n > INT_MAX) { + /* huge strings are not supported */ + p->depth--; + p->error = WFERR_UNMARSHALLABLE; + return; + } + w_long((long)n, p); + w_string(PyString_AS_STRING(v), (int)n, p); } #ifdef Py_USING_UNICODE else if (PyUnicode_CheckExact(v)) { @@ -357,14 +338,21 @@ return; } w_byte(TYPE_UNICODE, p); - w_pstring(PyString_AS_STRING(utf8), PyString_GET_SIZE(utf8), p); + n = PyString_GET_SIZE(utf8); + if (n > INT_MAX) { + p->depth--; + p->error = WFERR_UNMARSHALLABLE; + return; + } + w_long((long)n, p); + w_string(PyString_AS_STRING(utf8), (int)n, p); Py_DECREF(utf8); } #endif else if (PyTuple_CheckExact(v)) { w_byte(TYPE_TUPLE, p); n = PyTuple_Size(v); - W_SIZE(n, p); + w_long((long)n, p); for (i = 0; i < n; i++) { w_object(PyTuple_GET_ITEM(v, i), p); } @@ -372,7 +360,7 @@ else if (PyList_CheckExact(v)) { w_byte(TYPE_LIST, p); n = PyList_GET_SIZE(v); - W_SIZE(n, p); + w_long((long)n, p); for (i = 0; i < n; i++) { w_object(PyList_GET_ITEM(v, i), p); } @@ -402,7 +390,7 @@ p->error = WFERR_UNMARSHALLABLE; return; } - W_SIZE(n, p); + w_long((long)n, p); it = PyObject_GetIter(v); if (it == NULL) { p->depth--; @@ -444,7 +432,13 @@ PyBufferProcs *pb = v->ob_type->tp_as_buffer; w_byte(TYPE_STRING, p); n = (*pb->bf_getreadbuffer)(v, 0, (void **)&s); - w_pstring(s, n, p); + if (n > INT_MAX) { + p->depth--; + p->error = WFERR_UNMARSHALLABLE; + return; + } + w_long((long)n, p); + w_string(s, (int)n, p); } else { w_byte(TYPE_UNKNOWN, p); @@ -486,14 +480,14 @@ #define r_byte(p) ((p)->fp ? getc((p)->fp) : rs_byte(p)) -static Py_ssize_t -r_string(char *s, Py_ssize_t n, RFILE *p) +static int +r_string(char *s, int n, RFILE *p) { if (p->fp != NULL) /* The result fits into int because it must be <=n. */ - return fread(s, 1, n, p->fp); + return (int)fread(s, 1, n, p->fp); if (p->end - p->ptr < n) - n = p->end - p->ptr; + n = (int)(p->end - p->ptr); memcpy(s, p->ptr, n); p->ptr += n; return n; @@ -569,14 +563,14 @@ r_PyLong(RFILE *p) { PyLongObject *ob; - long n, size, i; - int j, md, shorts_in_top_digit; + int size, i, j, md, shorts_in_top_digit; + long n; digit d; n = r_long(p); if (n == 0) return (PyObject *)_PyLong_New(0); - if (n < -SIZE32_MAX || n > SIZE32_MAX) { + if (n < -INT_MAX || n > INT_MAX) { PyErr_SetString(PyExc_ValueError, "bad marshal data (long size out of range)"); return NULL; @@ -697,7 +691,7 @@ char buf[256]; double dx; n = r_byte(p); - if (n == EOF || r_string(buf, n, p) != n) { + if (n == EOF || r_string(buf, (int)n, p) != n) { PyErr_SetString(PyExc_EOFError, "EOF read where object expected"); retval = NULL; @@ -738,7 +732,7 @@ char buf[256]; Py_complex c; n = r_byte(p); - if (n == EOF || r_string(buf, n, p) != n) { + if (n == EOF || r_string(buf, (int)n, p) != n) { PyErr_SetString(PyExc_EOFError, "EOF read where object expected"); retval = NULL; @@ -751,7 +745,7 @@ break; } n = r_byte(p); - if (n == EOF || r_string(buf, n, p) != n) { + if (n == EOF || r_string(buf, (int)n, p) != n) { PyErr_SetString(PyExc_EOFError, "EOF read where object expected"); retval = NULL; @@ -801,7 +795,7 @@ case TYPE_INTERNED: case TYPE_STRING: n = r_long(p); - if (n < 0 || n > SIZE32_MAX) { + if (n < 0 || n > INT_MAX) { PyErr_SetString(PyExc_ValueError, "bad marshal data (string size out of range)"); retval = NULL; break; @@ -811,7 +805,7 @@ retval = NULL; break; } - if (r_string(PyString_AS_STRING(v), n, p) != n) { + if (r_string(PyString_AS_STRING(v), (int)n, p) != n) { Py_DECREF(v); PyErr_SetString(PyExc_EOFError, "EOF read where object expected"); @@ -846,7 +840,7 @@ char *buffer; n = r_long(p); - if (n < 0 || n > SIZE32_MAX) { + if (n < 0 || n > INT_MAX) { PyErr_SetString(PyExc_ValueError, "bad marshal data (unicode size out of range)"); retval = NULL; break; @@ -856,7 +850,7 @@ retval = PyErr_NoMemory(); break; } - if (r_string(buffer, n, p) != n) { + if (r_string(buffer, (int)n, p) != n) { PyMem_DEL(buffer); PyErr_SetString(PyExc_EOFError, "EOF read where object expected"); @@ -872,12 +866,12 @@ case TYPE_TUPLE: n = r_long(p); - if (n < 0 || n > SIZE32_MAX) { + if (n < 0 || n > INT_MAX) { PyErr_SetString(PyExc_ValueError, "bad marshal data (tuple size out of range)"); retval = NULL; break; } - v = PyTuple_New(n); + v = PyTuple_New((int)n); if (v == NULL) { retval = NULL; break; @@ -892,19 +886,19 @@ v = NULL; break; } - PyTuple_SET_ITEM(v, i, v2); + PyTuple_SET_ITEM(v, (int)i, v2); } retval = v; break; case TYPE_LIST: n = r_long(p); - if (n < 0 || n > SIZE32_MAX) { + if (n < 0 || n > INT_MAX) { PyErr_SetString(PyExc_ValueError, "bad marshal data (list size out of range)"); retval = NULL; break; } - v = PyList_New(n); + v = PyList_New((int)n); if (v == NULL) { retval = NULL; break; @@ -919,7 +913,7 @@ v = NULL; break; } - PyList_SET_ITEM(v, i, v2); + PyList_SET_ITEM(v, (int)i, v2); } retval = v; break; @@ -951,7 +945,7 @@ case TYPE_SET: case TYPE_FROZENSET: n = r_long(p); - if (n < 0 || n > SIZE32_MAX) { + if (n < 0 || n > INT_MAX) { PyErr_SetString(PyExc_ValueError, "bad marshal data (set size out of range)"); retval = NULL; break; @@ -1140,8 +1134,12 @@ if (filesize > 0 && filesize <= REASONABLE_FILE_LIMIT) { char* pBuf = (char *)PyMem_MALLOC(filesize); if (pBuf != NULL) { - size_t n = fread(pBuf, 1, (size_t)filesize, fp); - PyObject* v = PyMarshal_ReadObjectFromString(pBuf, n); + PyObject* v; + size_t n; + /* filesize must fit into an int, because it + is smaller than REASONABLE_FILE_LIMIT */ + n = fread(pBuf, 1, (int)filesize, fp); + v = PyMarshal_ReadObjectFromString(pBuf, n); PyMem_FREE(pBuf); return v; } diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Python/peephole.c --- a/Python/peephole.c Sat Jul 19 16:34:33 2014 -0700 +++ b/Python/peephole.c Sun Jul 20 10:52:46 2014 -0400 @@ -128,14 +128,25 @@ newconst = PyNumber_Subtract(v, w); break; case BINARY_SUBSCR: + newconst = PyObject_GetItem(v, w); /* #5057: if v is unicode, there might be differences between - wide and narrow builds in cases like '\U00012345'[0] or - '\U00012345abcdef'[3], so it's better to skip the optimization - in order to produce compatible pycs. - */ - if (PyUnicode_Check(v)) - return 0; - newconst = PyObject_GetItem(v, w); + wide and narrow builds in cases like u'\U00012345'[0]. + Wide builds will return a non-BMP char, whereas narrow builds + will return a surrogate. In both the cases skip the + optimization in order to produce compatible pycs. + */ + if (newconst != NULL && + PyUnicode_Check(v) && PyUnicode_Check(newconst)) { + Py_UNICODE ch = PyUnicode_AS_UNICODE(newconst)[0]; +#ifdef Py_UNICODE_WIDE + if (ch > 0xFFFF) { +#else + if (ch >= 0xD800 && ch <= 0xDFFF) { +#endif + Py_DECREF(newconst); + return 0; + } + } break; case BINARY_LSHIFT: newconst = PyNumber_Lshift(v, w); @@ -334,7 +345,7 @@ codestr = (unsigned char *)memcpy(codestr, PyString_AS_STRING(code), codelen); - /* Verify that RETURN_VALUE terminates the codestring. This allows + /* Verify that RETURN_VALUE terminates the codestring. This allows the various transformation patterns to look ahead several instructions without additional checks to make sure they are not looking beyond the end of the code string. @@ -432,8 +443,8 @@ case BUILD_LIST: j = GETARG(codestr, i); h = i - 3 * j; - if (h >= 0 && - j <= lastlc && + if (h >= 0 && + j <= lastlc && ((opcode == BUILD_TUPLE && ISBASICBLOCK(blocks, h, 3*(j+1))) || (opcode == BUILD_LIST && @@ -477,8 +488,8 @@ case BINARY_AND: case BINARY_XOR: case BINARY_OR: - if (lastlc >= 2 && - ISBASICBLOCK(blocks, i-6, 7) && + if (lastlc >= 2 && + ISBASICBLOCK(blocks, i-6, 7) && fold_binops_on_constants(&codestr[i-6], consts)) { i -= 2; assert(codestr[i] == LOAD_CONST); @@ -487,13 +498,13 @@ break; /* Fold unary ops on constants. - LOAD_CONST c1 UNARY_OP --> LOAD_CONST unary_op(c) */ + LOAD_CONST c1 UNARY_OP --> LOAD_CONST unary_op(c) */ case UNARY_NEGATIVE: case UNARY_CONVERT: case UNARY_INVERT: - if (lastlc >= 1 && - ISBASICBLOCK(blocks, i-3, 4) && - fold_unaryops_on_constants(&codestr[i-3], consts)) { + if (lastlc >= 1 && + ISBASICBLOCK(blocks, i-3, 4) && + fold_unaryops_on_constants(&codestr[i-3], consts)) { i -= 2; assert(codestr[i] == LOAD_CONST); cumlc = 1; @@ -519,7 +530,8 @@ tgt = GETJUMPTGT(codestr, i); j = codestr[tgt]; if (CONDITIONAL_JUMP(j)) { - /* NOTE: all possible jumps here are absolute! */ + /* NOTE: all possible jumps here are + absolute! */ if (JUMPS_ON_TRUE(j) == JUMPS_ON_TRUE(opcode)) { /* The second jump will be taken iff the first is. */ @@ -530,10 +542,13 @@ SETARG(codestr, i, tgttgt); goto reoptimize_current; } else { - /* The second jump is not taken if the first is (so - jump past it), and all conditional jumps pop their - argument when they're not taken (so change the - first jump to pop its argument when it's taken). */ + /* The second jump is not taken + if the first is (so jump past + it), and all conditional + jumps pop their argument when + they're not taken (so change + the first jump to pop its + argument when it's taken). */ if (JUMPS_ON_TRUE(opcode)) codestr[i] = POP_JUMP_IF_TRUE; else @@ -569,8 +584,8 @@ if (opcode == JUMP_FORWARD) /* JMP_ABS can go backwards */ opcode = JUMP_ABSOLUTE; if (!ABSOLUTE_JUMP(opcode)) - tgttgt -= i + 3; /* Calc relative jump addr */ - if (tgttgt < 0) /* No backward relative jumps */ + tgttgt -= i + 3; /* Calc relative jump addr */ + if (tgttgt < 0) /* No backward relative jumps */ continue; codestr[i] = opcode; SETARG(codestr, i, tgttgt); diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Python/pyarena.c --- a/Python/pyarena.c Sat Jul 19 16:34:33 2014 -0700 +++ b/Python/pyarena.c Sun Jul 20 10:52:46 2014 -0400 @@ -159,6 +159,7 @@ void PyArena_Free(PyArena *arena) { + int r; assert(arena); #if defined(Py_DEBUG) /* @@ -175,6 +176,12 @@ assert(arena->a_objects->ob_refcnt == 1); */ + /* Clear all the elements from the list. This is necessary + to guarantee that they will be DECREFed. */ + r = PyList_SetSlice(arena->a_objects, + 0, PyList_GET_SIZE(arena->a_objects), NULL); + assert(r == 0); + assert(PyList_GET_SIZE(arena->a_objects) == 0); Py_DECREF(arena->a_objects); free(arena); } diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Python/pystate.c --- a/Python/pystate.c Sat Jul 19 16:34:33 2014 -0700 +++ b/Python/pystate.c Sun Jul 20 10:52:46 2014 -0400 @@ -22,9 +22,6 @@ #endif #endif -#ifdef __cplusplus -extern "C" { -#endif #ifdef WITH_THREAD #include "pythread.h" @@ -33,6 +30,10 @@ #define HEAD_LOCK() PyThread_acquire_lock(head_mutex, WAIT_LOCK) #define HEAD_UNLOCK() PyThread_release_lock(head_mutex) +#ifdef __cplusplus +extern "C" { +#endif + /* The single PyInterpreterState used by this process' GILState implementation */ @@ -192,9 +193,6 @@ tstate->c_profileobj = NULL; tstate->c_traceobj = NULL; - tstate->trash_delete_nesting = 0; - tstate->trash_delete_later = NULL; - if (init) _PyThreadState_Init(tstate); @@ -315,9 +313,9 @@ Py_FatalError( "PyThreadState_DeleteCurrent: no current tstate"); _PyThreadState_Current = NULL; + tstate_delete_common(tstate); if (autoInterpreterState && PyThread_get_key_value(autoTLSkey) == tstate) PyThread_delete_key_value(autoTLSkey); - tstate_delete_common(tstate); PyEval_ReleaseLock(); } #endif /* WITH_THREAD */ @@ -656,10 +654,10 @@ PyEval_SaveThread(); } -#endif /* WITH_THREAD */ - #ifdef __cplusplus } #endif +#endif /* WITH_THREAD */ + diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Python/pythonrun.c --- a/Python/pythonrun.c Sat Jul 19 16:34:33 2014 -0700 +++ b/Python/pythonrun.c Sun Jul 20 10:52:46 2014 -0400 @@ -89,14 +89,6 @@ true divisions (which they will be in 2.3). */ int _Py_QnewFlag = 0; int Py_NoUserSiteDirectory = 0; /* for -s and site.py */ -int Py_HashRandomizationFlag = 0; /* for -R and PYTHONHASHSEED */ - -PyThreadState *_Py_Finalizing = NULL; - - -/* Hack to force loading of object files */ -int (*_PyOS_mystrnicmp_hack)(const char *, const char *, Py_ssize_t) = \ - PyOS_mystrnicmp; /* Python/pystrcmp.o */ /* PyModule_GetWarningsModule is no longer necessary as of 2.6 since _warnings is builtin. This API should not be used. */ @@ -165,7 +157,6 @@ if (initialized) return; initialized = 1; - _Py_Finalizing = NULL; if ((p = Py_GETENV("PYTHONDEBUG")) && *p != '\0') Py_DebugFlag = add_flag(Py_DebugFlag, p); @@ -175,12 +166,6 @@ Py_OptimizeFlag = add_flag(Py_OptimizeFlag, p); if ((p = Py_GETENV("PYTHONDONTWRITEBYTECODE")) && *p != '\0') Py_DontWriteBytecodeFlag = add_flag(Py_DontWriteBytecodeFlag, p); - /* The variable is only tested for existence here; _PyRandom_Init will - check its value further. */ - if ((p = Py_GETENV("PYTHONHASHSEED")) && *p != '\0') - Py_HashRandomizationFlag = add_flag(Py_HashRandomizationFlag, p); - - _PyRandom_Init(); interp = PyInterpreterState_New(); if (interp == NULL) @@ -425,16 +410,12 @@ * the threads created via Threading. */ call_sys_exitfunc(); + initialized = 0; /* Get current thread state and interpreter pointer */ tstate = PyThreadState_GET(); interp = tstate->interp; - /* Remaining threads (e.g. daemon threads) will automatically exit - after taking the GIL (in PyEval_RestoreThread()). */ - _Py_Finalizing = tstate; - initialized = 0; - /* Disable signal handling */ PyOS_FiniInterrupts(); @@ -919,20 +900,19 @@ { PyObject *m, *d, *v; const char *ext; - int set_file_name = 0, len, ret = -1; + int set_file_name = 0, ret, len; m = PyImport_AddModule("__main__"); if (m == NULL) return -1; - Py_INCREF(m); d = PyModule_GetDict(m); if (PyDict_GetItemString(d, "__file__") == NULL) { PyObject *f = PyString_FromString(filename); if (f == NULL) - goto done; + return -1; if (PyDict_SetItemString(d, "__file__", f) < 0) { Py_DECREF(f); - goto done; + return -1; } set_file_name = 1; Py_DECREF(f); @@ -945,6 +925,7 @@ fclose(fp); if ((fp = fopen(filename, "rb")) == NULL) { fprintf(stderr, "python: Can't reopen .pyc file\n"); + ret = -1; goto done; } /* Turn on optimization if a .pyo file is given */ @@ -957,6 +938,7 @@ } if (v == NULL) { PyErr_Print(); + ret = -1; goto done; } Py_DECREF(v); @@ -966,7 +948,6 @@ done: if (set_file_name && PyDict_DelItemString(d, "__file__")) PyErr_Clear(); - Py_DECREF(m); return ret; } @@ -1001,67 +982,55 @@ return PyArg_ParseTuple(err, "O(ziiz)", message, filename, lineno, offset, text); - *message = NULL; + /* new style errors. `err' is an instance */ - /* new style errors. `err' is an instance */ - *message = PyObject_GetAttrString(err, "msg"); - if (!*message) + if (! (v = PyObject_GetAttrString(err, "msg"))) + goto finally; + *message = v; + + if (!(v = PyObject_GetAttrString(err, "filename"))) + goto finally; + if (v == Py_None) + *filename = NULL; + else if (! (*filename = PyString_AsString(v))) goto finally; - v = PyObject_GetAttrString(err, "filename"); - if (!v) - goto finally; - if (v == Py_None) { - Py_DECREF(v); - *filename = NULL; - } - else { - *filename = PyString_AsString(v); - Py_DECREF(v); - if (!*filename) - goto finally; - } - - v = PyObject_GetAttrString(err, "lineno"); - if (!v) + Py_DECREF(v); + if (!(v = PyObject_GetAttrString(err, "lineno"))) goto finally; hold = PyInt_AsLong(v); Py_DECREF(v); + v = NULL; if (hold < 0 && PyErr_Occurred()) goto finally; *lineno = (int)hold; - v = PyObject_GetAttrString(err, "offset"); - if (!v) + if (!(v = PyObject_GetAttrString(err, "offset"))) goto finally; if (v == Py_None) { *offset = -1; Py_DECREF(v); + v = NULL; } else { hold = PyInt_AsLong(v); Py_DECREF(v); + v = NULL; if (hold < 0 && PyErr_Occurred()) goto finally; *offset = (int)hold; } - v = PyObject_GetAttrString(err, "text"); - if (!v) + if (!(v = PyObject_GetAttrString(err, "text"))) goto finally; - if (v == Py_None) { - Py_DECREF(v); + if (v == Py_None) *text = NULL; - } - else { - *text = PyString_AsString(v); - Py_DECREF(v); - if (!*text) - goto finally; - } + else if (! (*text = PyString_AsString(v))) + goto finally; + Py_DECREF(v); return 1; finally: - Py_XDECREF(*message); + Py_XDECREF(v); return 0; } diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Python/random.c --- a/Python/random.c Sat Jul 19 16:34:33 2014 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,312 +0,0 @@ -#include "Python.h" -#ifdef MS_WINDOWS -#include -#else -#include -#endif - -#ifdef Py_DEBUG -int _Py_HashSecret_Initialized = 0; -#else -static int _Py_HashSecret_Initialized = 0; -#endif - -#ifdef MS_WINDOWS -typedef BOOL (WINAPI *CRYPTACQUIRECONTEXTA)(HCRYPTPROV *phProv,\ - LPCSTR pszContainer, LPCSTR pszProvider, DWORD dwProvType,\ - DWORD dwFlags ); -typedef BOOL (WINAPI *CRYPTGENRANDOM)(HCRYPTPROV hProv, DWORD dwLen,\ - BYTE *pbBuffer ); - -static CRYPTGENRANDOM pCryptGenRandom = NULL; -/* This handle is never explicitly released. Instead, the operating - system will release it when the process terminates. */ -static HCRYPTPROV hCryptProv = 0; - -static int -win32_urandom_init(int raise) -{ - HINSTANCE hAdvAPI32 = NULL; - CRYPTACQUIRECONTEXTA pCryptAcquireContext = NULL; - - /* Obtain handle to the DLL containing CryptoAPI. This should not fail. */ - hAdvAPI32 = GetModuleHandle("advapi32.dll"); - if(hAdvAPI32 == NULL) - goto error; - - /* Obtain pointers to the CryptoAPI functions. This will fail on some early - versions of Win95. */ - pCryptAcquireContext = (CRYPTACQUIRECONTEXTA)GetProcAddress( - hAdvAPI32, "CryptAcquireContextA"); - if (pCryptAcquireContext == NULL) - goto error; - - pCryptGenRandom = (CRYPTGENRANDOM)GetProcAddress(hAdvAPI32, - "CryptGenRandom"); - if (pCryptGenRandom == NULL) - goto error; - - /* Acquire context */ - if (! pCryptAcquireContext(&hCryptProv, NULL, NULL, - PROV_RSA_FULL, CRYPT_VERIFYCONTEXT)) - goto error; - - return 0; - -error: - if (raise) - PyErr_SetFromWindowsErr(0); - else - Py_FatalError("Failed to initialize Windows random API (CryptoGen)"); - return -1; -} - -/* Fill buffer with size pseudo-random bytes generated by the Windows CryptoGen - API. Return 0 on success, or -1 on error. */ -static int -win32_urandom(unsigned char *buffer, Py_ssize_t size, int raise) -{ - Py_ssize_t chunk; - - if (hCryptProv == 0) - { - if (win32_urandom_init(raise) == -1) - return -1; - } - - while (size > 0) - { - chunk = size > INT_MAX ? INT_MAX : size; - if (!pCryptGenRandom(hCryptProv, chunk, buffer)) - { - /* CryptGenRandom() failed */ - if (raise) - PyErr_SetFromWindowsErr(0); - else - Py_FatalError("Failed to initialized the randomized hash " - "secret using CryptoGen)"); - return -1; - } - buffer += chunk; - size -= chunk; - } - return 0; -} -#endif /* MS_WINDOWS */ - - -#ifdef __VMS -/* Use openssl random routine */ -#include -static int -vms_urandom(unsigned char *buffer, Py_ssize_t size, int raise) -{ - if (RAND_pseudo_bytes(buffer, size) < 0) { - if (raise) { - PyErr_Format(PyExc_ValueError, - "RAND_pseudo_bytes"); - } else { - Py_FatalError("Failed to initialize the randomized hash " - "secret using RAND_pseudo_bytes"); - } - return -1; - } - return 0; -} -#endif /* __VMS */ - - -#if !defined(MS_WINDOWS) && !defined(__VMS) - -/* Read size bytes from /dev/urandom into buffer. - Call Py_FatalError() on error. */ -static void -dev_urandom_noraise(char *buffer, Py_ssize_t size) -{ - int fd; - Py_ssize_t n; - - assert (0 < size); - - fd = open("/dev/urandom", O_RDONLY); - if (fd < 0) - Py_FatalError("Failed to open /dev/urandom"); - - while (0 < size) - { - do { - n = read(fd, buffer, (size_t)size); - } while (n < 0 && errno == EINTR); - if (n <= 0) - { - /* stop on error or if read(size) returned 0 */ - Py_FatalError("Failed to read bytes from /dev/urandom"); - break; - } - buffer += n; - size -= (Py_ssize_t)n; - } - close(fd); -} - -/* Read size bytes from /dev/urandom into buffer. - Return 0 on success, raise an exception and return -1 on error. */ -static int -dev_urandom_python(char *buffer, Py_ssize_t size) -{ - int fd; - Py_ssize_t n; - - if (size <= 0) - return 0; - - Py_BEGIN_ALLOW_THREADS - fd = open("/dev/urandom", O_RDONLY); - Py_END_ALLOW_THREADS - if (fd < 0) - { - if (errno == ENOENT || errno == ENXIO || - errno == ENODEV || errno == EACCES) - PyErr_SetString(PyExc_NotImplementedError, - "/dev/urandom (or equivalent) not found"); - else - PyErr_SetFromErrno(PyExc_OSError); - return -1; - } - - Py_BEGIN_ALLOW_THREADS - do { - do { - n = read(fd, buffer, (size_t)size); - } while (n < 0 && errno == EINTR); - if (n <= 0) - break; - buffer += n; - size -= (Py_ssize_t)n; - } while (0 < size); - Py_END_ALLOW_THREADS - - if (n <= 0) - { - /* stop on error or if read(size) returned 0 */ - if (n < 0) - PyErr_SetFromErrno(PyExc_OSError); - else - PyErr_Format(PyExc_RuntimeError, - "Failed to read %zi bytes from /dev/urandom", - size); - close(fd); - return -1; - } - close(fd); - return 0; -} -#endif /* !defined(MS_WINDOWS) && !defined(__VMS) */ - -/* Fill buffer with pseudo-random bytes generated by a linear congruent - generator (LCG): - - x(n+1) = (x(n) * 214013 + 2531011) % 2^32 - - Use bits 23..16 of x(n) to generate a byte. */ -static void -lcg_urandom(unsigned int x0, unsigned char *buffer, size_t size) -{ - size_t index; - unsigned int x; - - x = x0; - for (index=0; index < size; index++) { - x *= 214013; - x += 2531011; - /* modulo 2 ^ (8 * sizeof(int)) */ - buffer[index] = (x >> 16) & 0xff; - } -} - -/* Fill buffer with size pseudo-random bytes from the operating system random - number generator (RNG). It is suitable for for most cryptographic purposes - except long living private keys for asymmetric encryption. - - Return 0 on success, raise an exception and return -1 on error. */ -int -_PyOS_URandom(void *buffer, Py_ssize_t size) -{ - if (size < 0) { - PyErr_Format(PyExc_ValueError, - "negative argument not allowed"); - return -1; - } - if (size == 0) - return 0; - -#ifdef MS_WINDOWS - return win32_urandom((unsigned char *)buffer, size, 1); -#else -# ifdef __VMS - return vms_urandom((unsigned char *)buffer, size, 1); -# else - return dev_urandom_python((char*)buffer, size); -# endif -#endif -} - -void -_PyRandom_Init(void) -{ - char *env; - void *secret = &_Py_HashSecret; - Py_ssize_t secret_size = sizeof(_Py_HashSecret_t); - - if (_Py_HashSecret_Initialized) - return; - _Py_HashSecret_Initialized = 1; - - /* - By default, hash randomization is disabled, and only - enabled if PYTHONHASHSEED is set to non-empty or if - "-R" is provided at the command line: - */ - if (!Py_HashRandomizationFlag) { - /* Disable the randomized hash: */ - memset(secret, 0, secret_size); - return; - } - - /* - Hash randomization is enabled. Generate a per-process secret, - using PYTHONHASHSEED if provided. - */ - - env = Py_GETENV("PYTHONHASHSEED"); - if (env && *env != '\0' && strcmp(env, "random") != 0) { - char *endptr = env; - unsigned long seed; - seed = strtoul(env, &endptr, 10); - if (*endptr != '\0' - || seed > 4294967295UL - || (errno == ERANGE && seed == ULONG_MAX)) - { - Py_FatalError("PYTHONHASHSEED must be \"random\" or an integer " - "in range [0; 4294967295]"); - } - if (seed == 0) { - /* disable the randomized hash */ - memset(secret, 0, secret_size); - } - else { - lcg_urandom(seed, (unsigned char*)secret, secret_size); - } - } - else { -#ifdef MS_WINDOWS - (void)win32_urandom((unsigned char *)secret, secret_size, 0); -#else /* #ifdef MS_WINDOWS */ -# ifdef __VMS - vms_urandom((unsigned char *)secret, secret_size, 0); -# else - dev_urandom_noraise((char*)secret, secret_size); -# endif -#endif - } -} diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Python/symtable.c --- a/Python/symtable.c Sat Jul 19 16:34:33 2014 -0700 +++ b/Python/symtable.c Sun Jul 20 10:52:46 2014 -0400 @@ -22,18 +22,16 @@ void *key, int lineno) { PySTEntryObject *ste = NULL; - PyObject *k = NULL; + PyObject *k; k = PyLong_FromVoidPtr(key); if (k == NULL) goto fail; ste = PyObject_New(PySTEntryObject, &PySTEntry_Type); - if (ste == NULL) { - Py_DECREF(k); + if (ste == NULL) goto fail; - } ste->ste_table = st; - ste->ste_id = k; /* ste owns reference to k */ + ste->ste_id = k; ste->ste_name = name; Py_INCREF(name); @@ -468,7 +466,7 @@ */ if (PyDict_SetItem(scope, name, w) < 0) goto error; - if (PyDict_DelItem(free, name) < 0) + if (!PyDict_DelItem(free, name) < 0) goto error; } success = 1; @@ -504,7 +502,7 @@ case OPT_BARE_EXEC: PyOS_snprintf(buf, sizeof(buf), "unqualified exec is not allowed in function " - "'%.100s' because it %s", + "'%.100s' it %s", PyString_AS_STRING(ste->ste_name), trailer); break; default: diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Python/sysmodule.c --- a/Python/sysmodule.c Sat Jul 19 16:34:33 2014 -0700 +++ b/Python/sysmodule.c Sun Jul 20 10:52:46 2014 -0400 @@ -219,7 +219,7 @@ \n\ Exit the interpreter by raising SystemExit(status).\n\ If the status is omitted or None, it defaults to zero (i.e., success).\n\ -If the status is an integer, it will be used as the system exit status.\n\ +If the status is numeric, it will be used as the system exit status.\n\ If it is another kind of object, it will be printed and the system\n\ exit status will be one (i.e., failure)." ); @@ -367,7 +367,8 @@ result = call_trampoline(tstate, callback, frame, what, arg); if (result == NULL) { PyEval_SetTrace(NULL, NULL); - Py_CLEAR(frame->f_trace); + Py_XDECREF(frame->f_trace); + frame->f_trace = NULL; return -1; } if (result != Py_None) { @@ -615,10 +616,6 @@ PyStructSequence_SET_ITEM(version, pos++, PyInt_FromLong(ver.wSuiteMask)); PyStructSequence_SET_ITEM(version, pos++, PyInt_FromLong(ver.wProductType)); - if (PyErr_Occurred()) { - Py_DECREF(version); - return NULL; - } return version; } @@ -1096,7 +1093,7 @@ hexversion -- version information encoded as a single integer\n\ copyright -- copyright notice pertaining to this interpreter\n\ platform -- platform identifier\n\ -executable -- absolute path of the executable binary of the Python interpreter\n\ +executable -- pathname of this Python interpreter\n\ prefix -- prefix used to find the Python library\n\ exec_prefix -- prefix used to find the machine-specific Python library\n\ float_repr_style -- string indicating the style of repr() output for floats\n\ @@ -1212,7 +1209,6 @@ {"unicode", "-U"}, /* {"skip_first", "-x"}, */ {"bytes_warning", "-b"}, - {"hash_randomization", "-R"}, {0} }; @@ -1221,9 +1217,9 @@ flags__doc__, /* doc */ flags_fields, /* fields */ #ifdef RISCOS - 17 + 16 #else - 16 + 15 #endif }; @@ -1260,11 +1256,9 @@ SetFlag(Py_UnicodeFlag); /* SetFlag(skipfirstline); */ SetFlag(Py_BytesWarningFlag); - SetFlag(Py_HashRandomizationFlag); #undef SetFlag if (PyErr_Occurred()) { - Py_DECREF(seq); return NULL; } return seq; diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Python/thread.c --- a/Python/thread.c Sat Jul 19 16:34:33 2014 -0700 +++ b/Python/thread.c Sun Jul 20 10:52:46 2014 -0400 @@ -24,7 +24,7 @@ #include #ifdef __sgi -#ifndef HAVE_PTHREAD_H /* XXX Need to check in configure.ac */ +#ifndef HAVE_PTHREAD_H /* XXX Need to check in configure.in */ #undef _POSIX_THREADS #endif #endif diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Python/thread_pthread.h --- a/Python/thread_pthread.h Sat Jul 19 16:34:33 2014 -0700 +++ b/Python/thread_pthread.h Sun Jul 20 10:52:46 2014 -0400 @@ -145,7 +145,6 @@ PyThread__init_thread(void) { #if defined(_AIX) && defined(__GNUC__) - extern void pthread_init(void); pthread_init(); #endif } @@ -242,9 +241,9 @@ PyThread_exit_thread(void) { dprintf(("PyThread_exit_thread called\n")); - if (!initialized) + if (!initialized) { exit(0); - pthread_exit(0); + } } #ifdef USE_SEMAPHORES @@ -285,7 +284,6 @@ sem_t *thelock = (sem_t *)lock; int status, error = 0; - (void) error; /* silence unused-but-set-variable warning */ dprintf(("PyThread_free_lock(%p) called\n", lock)); if (!thelock) @@ -316,7 +314,6 @@ sem_t *thelock = (sem_t *)lock; int status, error = 0; - (void) error; /* silence unused-but-set-variable warning */ dprintf(("PyThread_acquire_lock(%p, %d) called\n", lock, waitflag)); do { @@ -344,7 +341,6 @@ sem_t *thelock = (sem_t *)lock; int status, error = 0; - (void) error; /* silence unused-but-set-variable warning */ dprintf(("PyThread_release_lock(%p) called\n", lock)); status = sem_post(thelock); @@ -395,7 +391,6 @@ pthread_lock *thelock = (pthread_lock *)lock; int status, error = 0; - (void) error; /* silence unused-but-set-variable warning */ dprintf(("PyThread_free_lock(%p) called\n", lock)); status = pthread_mutex_destroy( &thelock->mut ); @@ -447,7 +442,6 @@ pthread_lock *thelock = (pthread_lock *)lock; int status, error = 0; - (void) error; /* silence unused-but-set-variable warning */ dprintf(("PyThread_release_lock(%p) called\n", lock)); status = pthread_mutex_lock( &thelock->mut ); diff -r 9cd3ab7c09d1 -r 9ac347a7f375 README --- a/README Sat Jul 19 16:34:33 2014 -0700 +++ b/README Sun Jul 20 10:52:46 2014 -0400 @@ -1,8 +1,8 @@ -This is Python version 2.7.8 +This is Python version 2.7.2 ============================ -Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, -2012, 2013, 2014 Python Software Foundation. All rights reserved. +Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 +Python Software Foundation. All rights reserved. Copyright (c) 2000 BeOpen.com. All rights reserved. @@ -89,13 +89,6 @@ primarily for documentation authors, translators, and people with special formatting requirements. -If you would like to contribute to the development of Python, relevant -documentation is available at: - - http://docs.python.org/devguide/ - -For information about building Python's documentation, refer to Doc/README.txt. - Web sites --------- @@ -248,7 +241,7 @@ - NeXT - Irix 4 and --with-sgi-dl - Linux 1 -- Systems defining __d6_pthread_create (configure.ac) +- Systems defining __d6_pthread_create (configure.in) - Systems defining PY_PTHREAD_D4, PY_PTHREAD_D6, or PY_PTHREAD_D7 in thread_pthread.h - Systems using --with-dl-dld @@ -687,10 +680,10 @@ threads to work properly. Below is a table of those options, collected by Bill Janssen. We would love to automate this process more, but the information below is not enough to write a patch for the -configure.ac file, so manual intervention is required. If you patch -the configure.ac file and are confident that the patch works, please +configure.in file, so manual intervention is required. If you patch +the configure.in file and are confident that the patch works, please send in the patch. (Don't bother patching the configure script itself --- it is regenerated each time the configure.ac file changes.) +-- it is regenerated each time the configure.in file changes.) Compiler switches for threads ............................. @@ -1208,7 +1201,7 @@ Tools/ Some useful programs written in Python pyconfig.h.in Source from which pyconfig.h is created (GNU autoheader output) configure Configuration shell script (GNU autoconf output) -configure.ac Configuration specification (input for GNU autoconf) +configure.in Configuration specification (input for GNU autoconf) install-sh Shell script used to install files setup.py Python script used to build extension modules diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Tools/buildbot/build-amd64.bat --- a/Tools/buildbot/build-amd64.bat Sat Jul 19 16:34:33 2014 -0700 +++ b/Tools/buildbot/build-amd64.bat Sun Jul 20 10:52:46 2014 -0400 @@ -1,5 +1,4 @@ @rem Used by the buildbot "compile" step. -set HOST_PYTHON="%CD%\PCbuild\amd64\python_d.exe" cmd /c Tools\buildbot\external-amd64.bat call "%VS90COMNTOOLS%\..\..\VC\vcvarsall.bat" x86_amd64 cmd /c Tools\buildbot\clean-amd64.bat diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Tools/buildbot/external-amd64.bat --- a/Tools/buildbot/external-amd64.bat Sat Jul 19 16:34:33 2014 -0700 +++ b/Tools/buildbot/external-amd64.bat Sun Jul 20 10:52:46 2014 -0400 @@ -5,24 +5,16 @@ call "%VS90COMNTOOLS%\..\..\VC\vcvarsall.bat" x86_amd64 if not exist tcltk64\bin\tcl85g.dll ( - cd tcl-8.5.15.0\win + cd tcl-8.5.2.1\win nmake -f makefile.vc COMPILERFLAGS=-DWINVER=0x0500 DEBUG=1 MACHINE=AMD64 INSTALLDIR=..\..\tcltk64 clean all nmake -f makefile.vc COMPILERFLAGS=-DWINVER=0x0500 DEBUG=1 MACHINE=AMD64 INSTALLDIR=..\..\tcltk64 install cd ..\.. ) if not exist tcltk64\bin\tk85g.dll ( - cd tk-8.5.15.0\win - nmake -f makefile.vc COMPILERFLAGS=-DWINVER=0x0500 OPTS=noxp DEBUG=1 MACHINE=AMD64 INSTALLDIR=..\..\tcltk64 TCLDIR=..\..\tcl-8.5.15.0 clean - nmake -f makefile.vc COMPILERFLAGS=-DWINVER=0x0500 OPTS=noxp DEBUG=1 MACHINE=AMD64 INSTALLDIR=..\..\tcltk64 TCLDIR=..\..\tcl-8.5.15.0 all - nmake -f makefile.vc COMPILERFLAGS=-DWINVER=0x0500 OPTS=noxp DEBUG=1 MACHINE=AMD64 INSTALLDIR=..\..\tcltk64 TCLDIR=..\..\tcl-8.5.15.0 install + cd tk-8.5.2.0\win + nmake -f makefile.vc COMPILERFLAGS=-DWINVER=0x0500 OPTS=noxp DEBUG=1 MACHINE=AMD64 INSTALLDIR=..\..\tcltk64 TCLDIR=..\..\tcl-8.5.2.1 clean + nmake -f makefile.vc COMPILERFLAGS=-DWINVER=0x0500 OPTS=noxp DEBUG=1 MACHINE=AMD64 INSTALLDIR=..\..\tcltk64 TCLDIR=..\..\tcl-8.5.2.1 all + nmake -f makefile.vc COMPILERFLAGS=-DWINVER=0x0500 OPTS=noxp DEBUG=1 MACHINE=AMD64 INSTALLDIR=..\..\tcltk64 TCLDIR=..\..\tcl-8.5.2.1 install cd ..\.. ) - -if not exist tcltk64\lib\tix8.4.3\tix84g.dll ( - cd tix-8.4.3.5\win - nmake -f python.mak DEBUG=1 MACHINE=AMD64 COMPILERFLAGS=-DWINVER=0x0500 TCL_DIR=..\..\tcl-8.5.15.0 TK_DIR=..\..\tk-8.5.15.0 INSTALL_DIR=..\..\tcltk64 clean - nmake -f python.mak DEBUG=1 MACHINE=AMD64 COMPILERFLAGS=-DWINVER=0x0500 TCL_DIR=..\..\tcl-8.5.15.0 TK_DIR=..\..\tk-8.5.15.0 INSTALL_DIR=..\..\tcltk64 all - nmake -f python.mak DEBUG=1 MACHINE=AMD64 COMPILERFLAGS=-DWINVER=0x0500 TCL_DIR=..\..\tcl-8.5.15.0 TK_DIR=..\..\tk-8.5.15.0 INSTALL_DIR=..\..\tcltk64 install - cd ..\.. -) \ No newline at end of file diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Tools/buildbot/external-common.bat --- a/Tools/buildbot/external-common.bat Sat Jul 19 16:34:33 2014 -0700 +++ b/Tools/buildbot/external-common.bat Sun Jul 20 10:52:46 2014 -0400 @@ -4,31 +4,24 @@ cd .. @rem XXX: If you need to force the buildbots to start from a fresh environment, uncomment @rem the following, check it in, then check it out, comment it out, then check it back in. -@rem if exist bzip2-1.0.6 rd /s/q bzip2-1.0.6 +@rem if exist bzip2-1.0.5 rd /s/q bzip2-1.0.5 @rem if exist tcltk rd /s/q tcltk @rem if exist tcltk64 rd /s/q tcltk64 @rem if exist tcl8.4.12 rd /s/q tcl8.4.12 @rem if exist tcl8.4.16 rd /s/q tcl8.4.16 @rem if exist tcl-8.4.18.1 rd /s/q tcl-8.4.18.1 -@rem if exist tcl-8.5.2.1 rd /s/q tcl-8.5.2.1 -@rem if exist tcl-8.5.15.0 rd /s/q tcl-8.5.15.0 @rem if exist tk8.4.12 rd /s/q tk8.4.12 @rem if exist tk8.4.16 rd /s/q tk8.4.16 @rem if exist tk-8.4.18.1 rd /s/q tk-8.4.18.1 -@rem if exist tk-8.5.2.0 rd /s/q tk-8.5.2.0 -@rem if exist tk-8.5.15.0 rd /s/q tk-8.5.15.0 -@rem if exist tix-8.4.3.5 rd /s/q tix-8.4.3.5 @rem if exist db-4.4.20 rd /s/q db-4.4.20 @rem if exist db-4.7.25.0 rd /s/q db-4.7.25.0 -@rem if exist openssl-0.9.8y rd /s/q openssl-0.9.8y -@rem if exist openssl-1.0.1g rd /s/q openssl-1.0.1g -@rem if exist openssl-1.0.1h rd /s/q openssl-1.0.1h -@rem if exist sqlite-3.6.21 rd /s/q sqlite-3.6.21 +@rem if exist openssl-0.9.8l rd /s/q openssl-0.9.8l +@rem if exist sqlite-3.6.21 rd /s/q sqlite-3.6.21 @rem bzip -if not exist bzip2-1.0.6 ( - rd /s/q bzip2-1.0.5 - svn export http://svn.python.org/projects/external/bzip2-1.0.6 +if not exist bzip2-1.0.5 ( + rd /s/q bzip2-1.0.3 + svn export http://svn.python.org/projects/external/bzip2-1.0.5 ) @rem Berkeley DB @@ -36,16 +29,14 @@ if not exist db-4.7.25.0 svn export http://svn.python.org/projects/external/db-4.7.25.0 @rem OpenSSL -if exist openssl-1.0.1g rd /s/q openssl-1.0.1g -if not exist openssl-1.0.1h svn export http://svn.python.org/projects/external/openssl-1.0.1h +if not exist openssl-0.9.8l svn export http://svn.python.org/projects/external/openssl-0.9.8l @rem tcl/tk -if not exist tcl-8.5.15.0 ( - rd /s/q tcltk tcltk64 tcl-8.5.2.1 tk-8.5.2.0 - svn export http://svn.python.org/projects/external/tcl-8.5.15.0 +if not exist tcl-8.5.2.1 ( + rd /s/q tcltk tcltk64 + svn export http://svn.python.org/projects/external/tcl-8.5.2.1 ) -if not exist tk-8.5.15.0 svn export http://svn.python.org/projects/external/tk-8.5.15.0 -if not exist tix-8.4.3.5 svn export http://svn.python.org/projects/external/tix-8.4.3.5 +if not exist tk-8.5.2.0 svn export http://svn.python.org/projects/external/tk-8.5.2.0 @rem sqlite3 if not exist sqlite-3.6.21 ( diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Tools/buildbot/external.bat --- a/Tools/buildbot/external.bat Sat Jul 19 16:34:33 2014 -0700 +++ b/Tools/buildbot/external.bat Sun Jul 20 10:52:46 2014 -0400 @@ -6,24 +6,16 @@ if not exist tcltk\bin\tcl85g.dll ( @rem all and install need to be separate invocations, otherwise nmakehlp is not found on install - cd tcl-8.5.15.0\win - nmake -f makefile.vc COMPILERFLAGS=-DWINVER=0x0500 DEBUG=1 INSTALLDIR=..\..\tcltk clean all + cd tcl-8.5.2.1\win + nmake -f makefile.vc COMPILERFLAGS=-DWINVER=0x0500 DEBUG=1 INSTALLDIR=..\..\tcltk clean all nmake -f makefile.vc DEBUG=1 INSTALLDIR=..\..\tcltk install cd ..\.. ) if not exist tcltk\bin\tk85g.dll ( - cd tk-8.5.15.0\win - nmake -f makefile.vc COMPILERFLAGS=-DWINVER=0x0500 OPTS=noxp DEBUG=1 INSTALLDIR=..\..\tcltk TCLDIR=..\..\tcl-8.5.15.0 clean - nmake -f makefile.vc COMPILERFLAGS=-DWINVER=0x0500 OPTS=noxp DEBUG=1 INSTALLDIR=..\..\tcltk TCLDIR=..\..\tcl-8.5.15.0 all - nmake -f makefile.vc COMPILERFLAGS=-DWINVER=0x0500 OPTS=noxp DEBUG=1 INSTALLDIR=..\..\tcltk TCLDIR=..\..\tcl-8.5.15.0 install + cd tk-8.5.2.0\win + nmake -f makefile.vc COMPILERFLAGS=-DWINVER=0x0500 OPTS=noxp DEBUG=1 INSTALLDIR=..\..\tcltk TCLDIR=..\..\tcl-8.5.2.1 clean + nmake -f makefile.vc COMPILERFLAGS=-DWINVER=0x0500 OPTS=noxp DEBUG=1 INSTALLDIR=..\..\tcltk TCLDIR=..\..\tcl-8.5.2.1 all + nmake -f makefile.vc COMPILERFLAGS=-DWINVER=0x0500 OPTS=noxp DEBUG=1 INSTALLDIR=..\..\tcltk TCLDIR=..\..\tcl-8.5.2.1 install cd ..\.. ) - -if not exist tcltk\lib\tix8.4.3\tix84g.dll ( - cd tix-8.4.3.5\win - nmake -f python.mak DEBUG=1 MACHINE=IX86 COMPILERFLAGS=-DWINVER=0x0500 TCL_DIR=..\..\tcl-8.5.15.0 TK_DIR=..\..\tk-8.5.15.0 INSTALL_DIR=..\..\tcltk clean - nmake -f python.mak DEBUG=1 MACHINE=IX86 COMPILERFLAGS=-DWINVER=0x0500 TCL_DIR=..\..\tcl-8.5.15.0 TK_DIR=..\..\tk-8.5.15.0 INSTALL_DIR=..\..\tcltk all - nmake -f python.mak DEBUG=1 MACHINE=IX86 COMPILERFLAGS=-DWINVER=0x0500 TCL_DIR=..\..\tcl-8.5.15.0 TK_DIR=..\..\tk-8.5.15.0 INSTALL_DIR=..\..\tcltk install - cd ..\.. -) diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Tools/buildbot/test-amd64.bat --- a/Tools/buildbot/test-amd64.bat Sat Jul 19 16:34:33 2014 -0700 +++ b/Tools/buildbot/test-amd64.bat Sun Jul 20 10:52:46 2014 -0400 @@ -1,3 +1,3 @@ @rem Used by the buildbot "test" step. cd PCbuild -call rt.bat -d -q -x64 -uall -rwW %1 %2 %3 %4 %5 %6 %7 %8 %9 +call rt.bat -q -d -x64 -uall -rw diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Tools/buildbot/test.bat --- a/Tools/buildbot/test.bat Sat Jul 19 16:34:33 2014 -0700 +++ b/Tools/buildbot/test.bat Sun Jul 20 10:52:46 2014 -0400 @@ -1,3 +1,3 @@ @rem Used by the buildbot "test" step. cd PCbuild -call rt.bat -d -q -uall -rwW %1 %2 %3 %4 %5 %6 %7 %8 %9 +call rt.bat -d -q -uall -rwW diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Tools/freeze/checkextensions_win32.py --- a/Tools/freeze/checkextensions_win32.py Sat Jul 19 16:34:33 2014 -0700 +++ b/Tools/freeze/checkextensions_win32.py Sun Jul 20 10:52:46 2014 -0400 @@ -3,7 +3,7 @@ Under Windows it is unlikely the .obj files are of use, as special compiler options are needed (primarily to toggle the behavior of "public" symbols. -I don't consider it worth parsing the MSVC makefiles for compiler options. Even if +I dont consider it worth parsing the MSVC makefiles for compiler options. Even if we get it just right, a specific freeze application may have specific compiler options anyway (eg, to enable or disable specific functionality) @@ -14,7 +14,7 @@ your own). * This description can include: - The MSVC .dsp file for the extension. The .c source file names - are extracted from there. + are extraced from there. - Specific compiler/linker options - Flag to indicate if Unicode compilation is expected. diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Tools/freeze/makefreeze.py --- a/Tools/freeze/makefreeze.py Sat Jul 19 16:34:33 2014 -0700 +++ b/Tools/freeze/makefreeze.py Sun Jul 20 10:52:46 2014 -0400 @@ -62,7 +62,7 @@ outfp.write('\t{"%s", M_%s, %d},\n' % (mod, mangled, size)) outfp.write('\n') # The following modules have a NULL code pointer, indicating - # that the frozen program should not search for them on the host + # that the prozen program should not search for them on the host # system. Importing them will *always* raise an ImportError. # The zero value size is never used. for mod in fail_import: diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Tools/gdb/libpython.py --- a/Tools/gdb/libpython.py Sat Jul 19 16:34:33 2014 -0700 +++ b/Tools/gdb/libpython.py Sun Jul 20 10:52:46 2014 -0400 @@ -39,39 +39,30 @@ The module also extends gdb with some python-specific commands. ''' - -# NOTE: some gdbs are linked with Python 3, so this file should be dual-syntax -# compatible (2.6+ and 3.0+). See #19308. - -from __future__ import print_function, with_statement +from __future__ import with_statement import gdb -import os import sys -if sys.version_info[0] >= 3: - unichr = chr - xrange = range - long = int - # Look up the gdb.Type for some standard types: _type_char_ptr = gdb.lookup_type('char').pointer() # char* _type_unsigned_char_ptr = gdb.lookup_type('unsigned char').pointer() # unsigned char* _type_void_ptr = gdb.lookup_type('void').pointer() # void* +_type_size_t = gdb.lookup_type('size_t') SIZEOF_VOID_P = _type_void_ptr.sizeof -Py_TPFLAGS_HEAPTYPE = (1 << 9) +Py_TPFLAGS_HEAPTYPE = (1L << 9) -Py_TPFLAGS_INT_SUBCLASS = (1 << 23) -Py_TPFLAGS_LONG_SUBCLASS = (1 << 24) -Py_TPFLAGS_LIST_SUBCLASS = (1 << 25) -Py_TPFLAGS_TUPLE_SUBCLASS = (1 << 26) -Py_TPFLAGS_STRING_SUBCLASS = (1 << 27) -Py_TPFLAGS_UNICODE_SUBCLASS = (1 << 28) -Py_TPFLAGS_DICT_SUBCLASS = (1 << 29) -Py_TPFLAGS_BASE_EXC_SUBCLASS = (1 << 30) -Py_TPFLAGS_TYPE_SUBCLASS = (1 << 31) +Py_TPFLAGS_INT_SUBCLASS = (1L << 23) +Py_TPFLAGS_LONG_SUBCLASS = (1L << 24) +Py_TPFLAGS_LIST_SUBCLASS = (1L << 25) +Py_TPFLAGS_TUPLE_SUBCLASS = (1L << 26) +Py_TPFLAGS_STRING_SUBCLASS = (1L << 27) +Py_TPFLAGS_UNICODE_SUBCLASS = (1L << 28) +Py_TPFLAGS_DICT_SUBCLASS = (1L << 29) +Py_TPFLAGS_BASE_EXC_SUBCLASS = (1L << 30) +Py_TPFLAGS_TYPE_SUBCLASS = (1L << 31) MAX_OUTPUT_LEN=1024 @@ -90,7 +81,7 @@ def safe_range(val): # As per range, but don't trust the value too much: cap it to a safety # threshold in case the data was corrupted - return xrange(safety_limit(int(val))) + return xrange(safety_limit(val)) class StringTruncated(RuntimeError): @@ -302,8 +293,8 @@ # class return cls - #print('tp_flags = 0x%08x' % tp_flags) - #print('tp_name = %r' % tp_name) + #print 'tp_flags = 0x%08x' % tp_flags + #print 'tp_name = %r' % tp_name name_map = {'bool': PyBoolObjectPtr, 'classobj': PyClassObjectPtr, @@ -419,15 +410,11 @@ self.address) def _PyObject_VAR_SIZE(typeobj, nitems): - if _PyObject_VAR_SIZE._type_size_t is None: - _PyObject_VAR_SIZE._type_size_t = gdb.lookup_type('size_t') - return ( ( typeobj.field('tp_basicsize') + nitems * typeobj.field('tp_itemsize') + (SIZEOF_VOID_P - 1) ) & ~(SIZEOF_VOID_P - 1) - ).cast(_PyObject_VAR_SIZE._type_size_t) -_PyObject_VAR_SIZE._type_size_t = None + ).cast(_type_size_t) class HeapTypeObjectPtr(PyObjectPtr): _typename = 'PyObject' @@ -627,7 +614,7 @@ def iteritems(self): ''' Yields a sequence of (PyObjectPtr key, PyObjectPtr value) pairs, - analogous to dict.iteritems() + analagous to dict.iteritems() ''' for i in safe_range(self.field('ma_mask') + 1): ep = self.field('ma_table') + i @@ -768,14 +755,14 @@ ''' ob_size = long(self.field('ob_size')) if ob_size == 0: - return 0 + return 0L ob_digit = self.field('ob_digit') if gdb.lookup_type('digit').sizeof == 2: - SHIFT = 15 + SHIFT = 15L else: - SHIFT = 30 + SHIFT = 30L digits = [long(ob_digit[i]) * 2**(SHIFT*i) for i in safe_range(abs(ob_size))] @@ -784,12 +771,6 @@ result = -result return result - def write_repr(self, out, visited): - # This ensures the trailing 'L' is printed when gdb is linked - # with a Python 3 interpreter. - out.write(repr(self.proxyval(visited)).rstrip('L')) - out.write('L') - class PyNoneStructPtr(PyObjectPtr): """ @@ -805,7 +786,7 @@ class PyFrameObjectPtr(PyObjectPtr): _typename = 'PyFrameObject' - def __init__(self, gdbval, cast_to=None): + def __init__(self, gdbval, cast_to): PyObjectPtr.__init__(self, gdbval, cast_to) if not self.is_optimized_out(): @@ -839,7 +820,7 @@ the global variables of this frame ''' if self.is_optimized_out(): - return () + return pyop_globals = self.pyop_field('f_globals') return pyop_globals.iteritems() @@ -850,7 +831,7 @@ the builtin variables ''' if self.is_optimized_out(): - return () + return pyop_builtins = self.pyop_field('f_builtins') return pyop_builtins.iteritems() @@ -985,19 +966,11 @@ field_ob_size = self.field('ob_size') field_ob_sval = self.field('ob_sval') char_ptr = field_ob_sval.address.cast(_type_unsigned_char_ptr) - # When gdb is linked with a Python 3 interpreter, this is really - # a latin-1 mojibake decoding of the original string... return ''.join([chr(char_ptr[i]) for i in safe_range(field_ob_size)]) def proxyval(self, visited): return str(self) - def write_repr(self, out, visited): - val = repr(self.proxyval(visited)) - if sys.version_info[0] >= 3: - val = val.encode('ascii', 'backslashreplace').decode('ascii') - out.write(val) - class PyTupleObjectPtr(PyObjectPtr): _typename = 'PyTupleObject' @@ -1096,15 +1069,6 @@ result = u''.join([_unichr(ucs) for ucs in Py_UNICODEs]) return result - def write_repr(self, out, visited): - val = repr(self.proxyval(visited)) - if sys.version_info[0] >= 3: - val = val.encode('ascii', 'backslashreplace').decode('ascii') - # This ensures the 'u' prefix is printed when gdb is linked - # with a Python 3 interpreter. - out.write('u') - out.write(val.lstrip('u')) - def int_from_int(gdbval): return int(str(gdbval)) @@ -1241,20 +1205,7 @@ def get_pyop(self): try: f = self._gdbframe.read_var('f') - frame = PyFrameObjectPtr.from_pyobject_ptr(f) - if not frame.is_optimized_out(): - return frame - # gdb is unable to get the "f" argument of PyEval_EvalFrameEx() - # because it was "optimized out". Try to get "f" from the frame - # of the caller, PyEval_EvalCodeEx(). - orig_frame = frame - caller = self._gdbframe.older() - if caller: - f = caller.read_var('f') - frame = PyFrameObjectPtr.from_pyobject_ptr(f) - if not frame.is_optimized_out(): - return frame - return orig_frame + return PyFrameObjectPtr.from_pyobject_ptr(f) except ValueError: return None @@ -1284,9 +1235,7 @@ pyop = self.get_pyop() if pyop: sys.stdout.write('#%i %s\n' % (self.get_index(), pyop.get_truncated_repr(MAX_OUTPUT_LEN))) - if not pyop.is_optimized_out(): - line = pyop.current_line() - sys.stdout.write(' %s\n' % line.strip()) + sys.stdout.write(pyop.current_line()) else: sys.stdout.write('#%i (unable to read python frame information)\n' % self.get_index()) else: @@ -1328,12 +1277,12 @@ frame = Frame.get_selected_python_frame() if not frame: - print('Unable to locate python frame') + print 'Unable to locate python frame' return pyop = frame.get_pyop() - if not pyop or pyop.is_optimized_out(): - print('Unable to read information on python frame') + if not pyop: + print 'Unable to read information on python frame' return filename = pyop.filename() @@ -1383,9 +1332,9 @@ frame = iter_frame if move_up: - print('Unable to find an older python frame') + print 'Unable to find an older python frame' else: - print('Unable to find a newer python frame') + print 'Unable to find a newer python frame' class PyUp(gdb.Command): 'Select and print the python stack frame that called this one (if any)' @@ -1448,23 +1397,23 @@ frame = Frame.get_selected_python_frame() if not frame: - print('Unable to locate python frame') + print 'Unable to locate python frame' return pyop_frame = frame.get_pyop() if not pyop_frame: - print('Unable to read information on python frame') + print 'Unable to read information on python frame' return pyop_var, scope = pyop_frame.get_var_by_name(name) if pyop_var: - print('%s %r = %s' + print ('%s %r = %s' % (scope, name, pyop_var.get_truncated_repr(MAX_OUTPUT_LEN))) else: - print('%r not found' % name) + print '%r not found' % name PyPrint() @@ -1482,16 +1431,16 @@ frame = Frame.get_selected_python_frame() if not frame: - print('Unable to locate python frame') + print 'Unable to locate python frame' return pyop_frame = frame.get_pyop() if not pyop_frame: - print('Unable to read information on python frame') + print 'Unable to read information on python frame' return for pyop_name, pyop_value in pyop_frame.iter_locals(): - print('%s = %s' + print ('%s = %s' % (pyop_name.proxyval(set()), pyop_value.get_truncated_repr(MAX_OUTPUT_LEN))) diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Tools/i18n/makelocalealias.py --- a/Tools/i18n/makelocalealias.py Sat Jul 19 16:34:33 2014 -0700 +++ b/Tools/i18n/makelocalealias.py Sun Jul 20 10:52:46 2014 -0400 @@ -23,12 +23,6 @@ if line[:1] == '#': continue locale, alias = line.split() - # Fix non-standard locale names, e.g. ks_IN@devanagari.UTF-8 - if '@' in alias: - alias_lang, _, alias_mod = alias.partition('@') - if '.' in alias_mod: - alias_mod, _, alias_enc = alias_mod.partition('.') - alias = alias_lang + '.' + alias_enc + '@' + alias_mod # Strip ':' if locale[-1] == ':': locale = locale[:-1] diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Tools/i18n/msgfmt.py --- a/Tools/i18n/msgfmt.py Sat Jul 19 16:34:33 2014 -0700 +++ b/Tools/i18n/msgfmt.py Sun Jul 20 10:52:46 2014 -0400 @@ -25,9 +25,8 @@ Display version information and exit. """ +import sys import os -import sys -import ast import getopt import struct import array @@ -144,7 +143,7 @@ # This is a message with plural forms elif l.startswith('msgid_plural'): if section != ID: - print >> sys.stderr, 'msgid_plural not preceded by msgid on %s:%d' %\ + print >> sys.stderr, 'msgid_plural not preceeded by msgid on %s:%d' %\ (infile, lno) sys.exit(1) l = l[12:] @@ -171,7 +170,8 @@ l = l.strip() if not l: continue - l = ast.literal_eval(l) + # XXX: Does this always follow Python escape semantics? + l = eval(l) if section == ID: msgid += l elif section == STR: diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Tools/i18n/pygettext.py --- a/Tools/i18n/pygettext.py Sat Jul 19 16:34:33 2014 -0700 +++ b/Tools/i18n/pygettext.py Sun Jul 20 10:52:46 2014 -0400 @@ -1,6 +1,6 @@ #! /usr/bin/env python # -*- coding: iso-8859-1 -*- -# Originally written by Barry Warsaw +# Originally written by Barry Warsaw # # Minimally patched to make it even more xgettext compatible # by Peter Funk @@ -208,7 +208,6 @@ def make_escapes(pass_iso8859): global escapes - escapes = [chr(i) for i in range(256)] if pass_iso8859: # Allow iso-8859 characters to pass through so that e.g. 'msgid # "Hhe"' would result not result in 'msgid "H\366he"'. Otherwise we @@ -216,9 +215,11 @@ mod = 128 else: mod = 256 - for i in range(mod): - if not(32 <= i <= 126): - escapes[i] = "\\%03o" % i + for i in range(256): + if 32 <= (i % mod) <= 126: + escapes.append(chr(i)) + else: + escapes.append("\\%03o" % i) escapes[ord('\\')] = '\\\\' escapes[ord('\t')] = '\\t' escapes[ord('\r')] = '\\r' @@ -592,7 +593,7 @@ fp.close() # calculate escapes - make_escapes(not options.escape) + make_escapes(options.escape) # calculate all keywords options.keywords.extend(default_keywords) diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Tools/msi/msi.py --- a/Tools/msi/msi.py Sat Jul 19 16:34:33 2014 -0700 +++ b/Tools/msi/msi.py Sun Jul 20 10:52:46 2014 -0400 @@ -177,8 +177,6 @@ have_mingw = build_mingw_lib(lib_file, def_file, dll_file, mingw_lib) # Determine the target architecture -if os.system("nmake /nologo /c /f msisupport.mak") != 0: - raise RuntimeError("'nmake /f msisupport.mak' failed") dll_path = os.path.join(srcdir, PCBUILD, dll_file) msilib.set_arch_from_file(dll_path) if msilib.pe_type(dll_path) != msilib.pe_type("msisupport.dll"): @@ -376,6 +374,8 @@ # UpdateEditIDLE sets the REGISTRY.tcl component into # the installed/uninstalled state according to both the # Extensions and TclTk features. + if os.system("nmake /nologo /c /f msisupport.mak") != 0: + raise "'nmake /f msisupport.mak' failed" add_data(db, "Binary", [("Script", msilib.Binary("msisupport.dll"))]) # See "Custom Action Type 1" if msilib.Win64: @@ -445,10 +445,6 @@ ("SetDLLDirToTarget", 'DLLDIR=""', 751), ]) - # Prepend TARGETDIR to the system path, and remove it on uninstall. - add_data(db, "Environment", - [("PathAddition", "=-*Path", "[TARGETDIR];[~]", "REGISTRY.path")]) - # Execute Sequences add_data(db, "InstallExecuteSequence", [("InitialTargetDir", 'TARGETDIR=""', 750), @@ -499,7 +495,7 @@ exit_dialog = PyDialog(db, "ExitDialog", x, y, w, h, modal, title, "Finish", "Finish", "Finish") - exit_dialog.title("Complete the [ProductName] Installer") + exit_dialog.title("Completing the [ProductName] Installer") exit_dialog.back("< Back", "Finish", active = 0) exit_dialog.cancel("Cancel", "Back", active = 0) exit_dialog.text("Acknowledgements", 135, 95, 220, 120, 0x30003, @@ -672,11 +668,11 @@ c=features.xbutton("Advanced", "Advanced", None, 0.30) c.event("SpawnDialog", "AdvancedDlg") - c=features.text("ItemDescription", 140, 180, 210, 40, 3, + c=features.text("ItemDescription", 140, 180, 210, 30, 3, "Multiline description of the currently selected item.") c.mapping("SelectionDescription","Text") - c=features.text("ItemSize", 140, 225, 210, 33, 3, + c=features.text("ItemSize", 140, 210, 210, 45, 3, "The size of the currently selected item.") c.mapping("SelectionSize", "Text") @@ -830,7 +826,7 @@ # (i.e. additional Python libraries) need to follow the parent feature. # Features that have no advertisement trigger (e.g. the test suite) # must not support advertisement - global default_feature, tcltk, htmlfiles, tools, testsuite, ext_feature, private_crt, prepend_path + global default_feature, tcltk, htmlfiles, tools, testsuite, ext_feature, private_crt default_feature = Feature(db, "DefaultFeature", "Python", "Python Interpreter and Libraries", 1, directory = "TARGETDIR") @@ -855,15 +851,6 @@ testsuite = Feature(db, "Testsuite", "Test suite", "Python test suite (Lib/test/)", 11, parent = default_feature, attributes=2|8) - # prepend_path is an additional feature which is to be off by default. - # Since the default level for the above features is 1, this needs to be - # at least level higher. - prepend_path = Feature(db, "PrependPath", "Add python.exe to Path", - "Prepend [TARGETDIR] to the system Path variable. " - "This allows you to type 'python' into a command " - "prompt without needing the full path.", 13, - parent = default_feature, attributes=2|8, - level=2) def extract_msvcr90(): # Find the redistributable files @@ -1035,12 +1022,8 @@ lib.add_file("zipdir.zip") if dir=='tests' and parent.physical=='distutils': lib.add_file("Setup.sample") - if dir=='audiodata': - lib.glob("*.*") if dir=='decimaltestdata': lib.glob("*.decTest") - if dir=='imghdrdata': - lib.glob("*.*") if dir=='xmltestdata': lib.glob("*.xml") lib.add_file("test.xml.out") @@ -1051,7 +1034,6 @@ lib.add_file("idle.bat") if dir=="Icons": lib.glob("*.gif") - lib.glob("*.ico") lib.add_file("idle.icns") if dir=="command" and parent.physical=="distutils": lib.glob("wininst*.exe") @@ -1186,8 +1168,6 @@ "InstallPath"), ("REGISTRY.doc", msilib.gen_uuid(), "TARGETDIR", registry_component, None, "Documentation"), - ("REGISTRY.path", msilib.gen_uuid(), "TARGETDIR", registry_component, None, - None), ("REGISTRY.def", msilib.gen_uuid(), "TARGETDIR", registry_component, None, None)] + tcldata) # See "FeatureComponents Table". @@ -1204,7 +1184,6 @@ add_data(db, "FeatureComponents", [(default_feature.id, "REGISTRY"), (htmlfiles.id, "REGISTRY.doc"), - (prepend_path.id, "REGISTRY.path"), (ext_feature.id, "REGISTRY.def")] + tcldata ) @@ -1413,10 +1392,7 @@ # certname (from config.py) should be (a substring of) # the certificate subject, e.g. "Python Software Foundation" if certname: - os.system('signtool sign /n "%s" ' - '/t http://timestamp.verisign.com/scripts/timestamp.dll ' - '/d "Python %s" ' - '%s' % (certname, full_current_version, msiname)) + os.system('signtool sign /n "%s" /t http://timestamp.verisign.com/scripts/timestamp.dll %s' % (certname, msiname)) if pdbzip: build_pdbzip() diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Tools/msi/msilib.py --- a/Tools/msi/msilib.py Sat Jul 19 16:34:33 2014 -0700 +++ b/Tools/msi/msilib.py Sun Jul 20 10:52:46 2014 -0400 @@ -305,7 +305,7 @@ t.create(db) # Fill the validation table add_data(db, "_Validation", schema._Validation_records) - # Initialize the summary information, allowing at most 20 properties + # Initialize the summary information, allowing atmost 20 properties si = db.GetSummaryInformation(20) si.SetProperty(PID_TITLE, "Installation Database") si.SetProperty(PID_SUBJECT, ProductName) @@ -516,7 +516,7 @@ def add_file(self, file, src=None, version=None, language=None): """Add a file to the current component of the directory, starting a new one - if there is no current component. By default, the file name in the source + one if there is no current component. By default, the file name in the source and the file table will be identical. If the src file is specified, it is interpreted relative to the current directory. Optionally, a version and a language can be specified for the entry in the File table.""" diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Tools/msi/uuids.py --- a/Tools/msi/uuids.py Sat Jul 19 16:34:33 2014 -0700 +++ b/Tools/msi/uuids.py Sun Jul 20 10:52:46 2014 -0400 @@ -55,15 +55,4 @@ '2.7.1150':'{32939827-d8e5-470a-b126-870db3c69fdf}', # 2.7.1 '2.7.2121':'{B2E1F06E-F719-4786-972A-488A336EB2A0}', # 2.7.2rc1 '2.7.2150':'{2E295B5B-1AD4-4d36-97C2-A316084722CF}', # 2.7.2 - '2.7.3121':'{1ACB88BF-1425-4f11-B664-6C89A3D7699C}', # 2.7.3rc1 - '2.7.3122':'{B12311BE-6364-4b2a-A49A-551EEE10F3E4}', # 2.7.3rc2 - '2.7.3150':'{C0C31BCC-56FB-42a7-8766-D29E1BD74C7C}', # 2.7.3 - '2.7.4121':'{47F45F45-72D7-4e54-AF41-26767EDE95CF}', # 2.7.4rc1 - '2.7.4150':'{84ADC96C-B7E0-4938-9D6E-2B640D5DA224}', # 2.7.4 - '2.7.5150':'{DBDD570E-0952-475f-9453-AB88F3DD5659}', # 2.7.5 - '2.7.6121':'{D1EBC07F-A7B1-4163-83DB-AE813CEF392F}', # 2.7.6rc1 - '2.7.6150':'{C3CC4DF5-39A5-4027-B136-2B3E1F5AB6E2}', # 2.7.6 - '2.7.7121':'{5E0D187D-238B-4e96-9C75-C4CF141F5385}', # 2.7.7rc1 - '2.7.7150':'{049CA433-77A0-4e48-AC76-180A282C4E10}', # 2.7.7 - '2.7.8150':'{61121B12-88BD-4261-A6EE-AB32610A56DD}', # 2.7.8 } diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Tools/pybench/CommandLine.py --- a/Tools/pybench/CommandLine.py Sat Jul 19 16:34:33 2014 -0700 +++ b/Tools/pybench/CommandLine.py Sun Jul 20 10:52:46 2014 -0400 @@ -458,7 +458,7 @@ handler = getattr(self, handlername) except AttributeError: if value == '': - # count the number of occurrences + # count the number of occurances if values.has_key(optionname): values[optionname] = values[optionname] + 1 else: diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Tools/pybench/README --- a/Tools/pybench/README Sat Jul 19 16:34:33 2014 -0700 +++ b/Tools/pybench/README Sun Jul 20 10:52:46 2014 -0400 @@ -3,7 +3,7 @@ PYBENCH - A Python Benchmark Suite ________________________________________________________________________ - Extendable suite of low-level benchmarks for measuring + Extendable suite of of low-level benchmarks for measuring the performance of the Python implementation (interpreter, compiler or VM). diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Tools/pybench/systimes.py --- a/Tools/pybench/systimes.py Sat Jul 19 16:34:33 2014 -0700 +++ b/Tools/pybench/systimes.py Sun Jul 20 10:52:46 2014 -0400 @@ -5,7 +5,7 @@ This module implements various different strategies for measuring performance timings. It tries to choose the best available method - based on the platform and available tools. + based on the platforma and available tools. On Windows, it is recommended to have the Mark Hammond win32 package installed. Alternatively, the Thomas Heller ctypes diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Tools/pynche/DetailsViewer.py --- a/Tools/pynche/DetailsViewer.py Sat Jul 19 16:34:33 2014 -0700 +++ b/Tools/pynche/DetailsViewer.py Sun Jul 20 10:52:46 2014 -0400 @@ -26,7 +26,7 @@ other side. Thus if red were at 238 and 25 were added to it, red would have the value 7. - Preserve Distance + Preseve Distance When the increment or decrement would send any of the tied variations out of bounds, all tied variations are wrapped as one, so as to preserve the distance between them. Thus if green and blue were tied, diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Tools/scripts/byext.py --- a/Tools/scripts/byext.py Sat Jul 19 16:34:33 2014 -0700 +++ b/Tools/scripts/byext.py Sun Jul 20 10:52:46 2014 -0400 @@ -2,8 +2,6 @@ """Show file statistics by extension.""" -from __future__ import print_function - import os import sys diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Tools/scripts/findnocoding.py --- a/Tools/scripts/findnocoding.py Sat Jul 19 16:34:33 2014 -0700 +++ b/Tools/scripts/findnocoding.py Sun Jul 20 10:52:46 2014 -0400 @@ -32,13 +32,13 @@ "no sophisticated Python source file search will be done.") -decl_re = re.compile(r'^[ \t\f]*#.*coding[:=][ \t]*([-\w.]+)') +decl_re = re.compile(r"coding[=:]\s*([-\w.]+)") def get_declaration(line): - match = decl_re.match(line) + match = decl_re.search(line) if match: return match.group(1) - return b'' + return '' def has_correct_encoding(text, codec): try: diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Tools/scripts/fixnotice.py --- a/Tools/scripts/fixnotice.py Sat Jul 19 16:34:33 2014 -0700 +++ b/Tools/scripts/fixnotice.py Sun Jul 20 10:52:46 2014 -0400 @@ -2,7 +2,7 @@ """(Ostensibly) fix copyright notices in files. -Actually, this script will simply replace a block of text in a file from one +Actually, this sript will simply replace a block of text in a file from one string to another. It will only do this once though, i.e. not globally throughout the file. It writes a backup file and then does an os.rename() dance for atomicity. diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Tools/scripts/gprof2html.py --- a/Tools/scripts/gprof2html.py Sat Jul 19 16:34:33 2014 -0700 +++ b/Tools/scripts/gprof2html.py Sun Jul 20 10:52:46 2014 -0400 @@ -1,4 +1,4 @@ -#! /usr/bin/env python +#! /usr/bin/env python2.3 """Transform gprof(1) output into useful HTML.""" diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Tools/scripts/h2py.py --- a/Tools/scripts/h2py.py Sat Jul 19 16:34:33 2014 -0700 +++ b/Tools/scripts/h2py.py Sun Jul 20 10:52:46 2014 -0400 @@ -58,12 +58,6 @@ raise KeyError except KeyError: searchdirs=['/usr/include'] - try: - searchdirs.insert(0, os.path.join('/usr/include', - os.environ['MULTIARCH'])) - except KeyError: - pass - def main(): global filedict diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Tools/scripts/ifdef.py --- a/Tools/scripts/ifdef.py Sat Jul 19 16:34:33 2014 -0700 +++ b/Tools/scripts/ifdef.py Sun Jul 20 10:52:46 2014 -0400 @@ -9,11 +9,11 @@ # options. On standard output it writes a copy of the input file(s) # minus those code sections that are suppressed by the selected # combination of defined/undefined symbols. The #if(n)def/#else/#else -# lines themselves (if the #if(n)def tests for one of the mentioned +# lines themselfs (if the #if(n)def tests for one of the mentioned # names) are removed as well. # Features: Arbitrary nesting of recognized and unrecognized -# preprocessor statements works correctly. Unrecognized #if* commands +# preprocesor statements works correctly. Unrecognized #if* commands # are left in place, so it will never remove too much, only too # little. It does accept whitespace around the '#' character. diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Tools/scripts/patchcheck.py --- a/Tools/scripts/patchcheck.py Sat Jul 19 16:34:33 2014 -0700 +++ b/Tools/scripts/patchcheck.py Sun Jul 20 10:52:46 2014 -0400 @@ -36,20 +36,6 @@ return decorated_fxn -def mq_patches_applied(): - """Check if there are any applied MQ patches.""" - cmd = 'hg qapplied' - st = subprocess.Popen(cmd.split(), - stdout=subprocess.PIPE, - stderr=subprocess.PIPE) - try: - bstdout, _ = st.communicate() - return st.returncode == 0 and bstdout - finally: - st.stdout.close() - st.stderr.close() - - @status("Getting the list of files that have been added/changed", info=lambda x: n_files_str(len(x))) def changed_files(): @@ -57,8 +43,6 @@ if os.path.isdir(os.path.join(SRCDIR, '.hg')): vcs = 'hg' cmd = 'hg status --added --modified --no-status' - if mq_patches_applied(): - cmd += ' --rev qparent' elif os.path.isdir('.svn'): vcs = 'svn' cmd = 'svn status --quiet --non-interactive --ignore-externals' @@ -144,13 +128,13 @@ @status("Misc/ACKS updated", modal=True) def credit_given(file_paths): """Check if Misc/ACKS has been changed.""" - return os.path.join('Misc', 'ACKS') in file_paths + return 'Misc/ACKS' in file_paths @status("Misc/NEWS updated", modal=True) def reported_news(file_paths): """Check if Misc/NEWS has been changed.""" - return os.path.join('Misc', 'NEWS') in file_paths + return 'Misc/NEWS' in file_paths def main(): @@ -158,8 +142,7 @@ python_files = [fn for fn in file_paths if fn.endswith('.py')] c_files = [fn for fn in file_paths if fn.endswith(('.c', '.h'))] doc_files = [fn for fn in file_paths if fn.startswith('Doc')] - misc_files = {os.path.join('Misc', 'ACKS'), os.path.join('Misc', 'NEWS')}\ - & set(file_paths) + special_files = {'Misc/ACKS', 'Misc/NEWS'} & set(file_paths) # PEP 8 whitespace rules enforcement. normalize_whitespace(python_files) # C rules enforcement. @@ -169,15 +152,14 @@ # Docs updated. docs_modified(doc_files) # Misc/ACKS changed. - credit_given(misc_files) + credit_given(special_files) # Misc/NEWS changed. - reported_news(misc_files) + reported_news(special_files) # Test suite run and passed. if python_files or c_files: - end = " and check for refleaks?" if c_files else "?" print - print "Did you run the test suite" + end + print "Did you run the test suite?" if __name__ == '__main__': diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Tools/scripts/pathfix.py --- a/Tools/scripts/pathfix.py Sat Jul 19 16:34:33 2014 -0700 +++ b/Tools/scripts/pathfix.py Sun Jul 20 10:52:46 2014 -0400 @@ -135,7 +135,7 @@ except os.error, msg: err('%s: rename failed (%r)\n' % (filename, msg)) return 1 - # Return success + # Return succes return 0 def fixline(line): diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Tools/scripts/pindent.py --- a/Tools/scripts/pindent.py Sat Jul 19 16:34:33 2014 -0700 +++ b/Tools/scripts/pindent.py Sun Jul 20 10:52:46 2014 -0400 @@ -76,14 +76,11 @@ # - realign comments # - optionally do much more thorough reformatting, a la C indent -from __future__ import print_function - # Defaults STEPSIZE = 8 TABSIZE = 8 -EXPANDTABS = False +EXPANDTABS = 0 -import io import re import sys @@ -92,8 +89,7 @@ next['while'] = next['for'] = 'else', 'end' next['try'] = 'except', 'finally' next['except'] = 'except', 'else', 'finally', 'end' -next['else'] = next['finally'] = next['with'] = \ - next['def'] = next['class'] = 'end' +next['else'] = next['finally'] = next['def'] = next['class'] = 'end' next['end'] = () start = 'if', 'while', 'for', 'try', 'with', 'def', 'class' @@ -109,11 +105,11 @@ self.expandtabs = expandtabs self._write = fpo.write self.kwprog = re.compile( - r'^(?:\s|\\\n)*(?P[a-z]+)' - r'((?:\s|\\\n)+(?P[a-zA-Z_]\w*))?' + r'^\s*(?P[a-z]+)' + r'(\s+(?P[a-zA-Z_]\w*))?' r'[^\w]') self.endprog = re.compile( - r'^(?:\s|\\\n)*#?\s*end\s+(?P[a-z]+)' + r'^\s*#?\s*end\s+(?P[a-z]+)' r'(\s+(?P[a-zA-Z_]\w*))?' r'[^\w]') self.wsprog = re.compile(r'^[ \t]*') @@ -129,7 +125,7 @@ def readline(self): line = self.fpi.readline() - if line: self.lineno += 1 + if line: self.lineno = self.lineno + 1 # end if return line # end def readline @@ -147,24 +143,27 @@ line2 = self.readline() if not line2: break # end if - line += line2 + line = line + line2 # end while return line # end def getline - def putline(self, line, indent): + def putline(self, line, indent = None): + if indent is None: + self.write(line) + return + # end if tabs, spaces = divmod(indent*self.indentsize, self.tabsize) - i = self.wsprog.match(line).end() - line = line[i:] - if line[:1] not in ('\n', '\r', ''): - line = '\t'*tabs + ' '*spaces + line + i = 0 + m = self.wsprog.match(line) + if m: i = m.end() # end if - self.write(line) + self.write('\t'*tabs + ' '*spaces + line[i:]) # end def putline def reformat(self): stack = [] - while True: + while 1: line = self.getline() if not line: break # EOF # end if @@ -174,9 +173,10 @@ kw2 = m.group('kw') if not stack: self.error('unexpected end') - elif stack.pop()[0] != kw2: + elif stack[-1][0] != kw2: self.error('unmatched end') # end if + del stack[-1:] self.putline(line, len(stack)) continue # end if @@ -208,23 +208,23 @@ def delete(self): begin_counter = 0 end_counter = 0 - while True: + while 1: line = self.getline() if not line: break # EOF # end if m = self.endprog.match(line) if m: - end_counter += 1 + end_counter = end_counter + 1 continue # end if m = self.kwprog.match(line) if m: kw = m.group('kw') if kw in start: - begin_counter += 1 + begin_counter = begin_counter + 1 # end if # end if - self.write(line) + self.putline(line) # end while if begin_counter - end_counter < 0: sys.stderr.write('Warning: input contained more end tags than expected\n') @@ -234,12 +234,17 @@ # end def delete def complete(self): + self.indentsize = 1 stack = [] todo = [] - currentws = thisid = firstkw = lastkw = topid = '' - while True: + thisid = '' + current, firstkw, lastkw, topid = 0, '', '', '' + while 1: line = self.getline() - i = self.wsprog.match(line).end() + i = 0 + m = self.wsprog.match(line) + if m: i = m.end() + # end if m = self.endprog.match(line) if m: thiskw = 'end' @@ -264,9 +269,7 @@ thiskw = '' # end if # end if - indentws = line[:i] - indent = len(indentws.expandtabs(self.tabsize)) - current = len(currentws.expandtabs(self.tabsize)) + indent = len(line[:i].expandtabs(self.tabsize)) while indent < current: if firstkw: if topid: @@ -275,11 +278,11 @@ else: s = '# end %s\n' % firstkw # end if - self.write(currentws + s) + self.putline(s, current) firstkw = lastkw = '' # end if - currentws, firstkw, lastkw, topid = stack.pop() - current = len(currentws.expandtabs(self.tabsize)) + current, firstkw, lastkw, topid = stack[-1] + del stack[-1] # end while if indent == current and firstkw: if thiskw == 'end': @@ -294,18 +297,18 @@ else: s = '# end %s\n' % firstkw # end if - self.write(currentws + s) + self.putline(s, current) firstkw = lastkw = topid = '' # end if # end if if indent > current: - stack.append((currentws, firstkw, lastkw, topid)) + stack.append((current, firstkw, lastkw, topid)) if thiskw and thiskw not in start: # error thiskw = '' # end if - currentws, firstkw, lastkw, topid = \ - indentws, thiskw, thiskw, thisid + current, firstkw, lastkw, topid = \ + indent, thiskw, thiskw, thisid # end if if thiskw: if thiskw in start: @@ -323,6 +326,7 @@ self.write(line) # end while # end def complete + # end class PythonIndenter # Simplified user interface @@ -348,86 +352,116 @@ pi.reformat() # end def reformat_filter +class StringReader: + def __init__(self, buf): + self.buf = buf + self.pos = 0 + self.len = len(self.buf) + # end def __init__ + def read(self, n = 0): + if n <= 0: + n = self.len - self.pos + else: + n = min(n, self.len - self.pos) + # end if + r = self.buf[self.pos : self.pos + n] + self.pos = self.pos + n + return r + # end def read + def readline(self): + i = self.buf.find('\n', self.pos) + return self.read(i + 1 - self.pos) + # end def readline + def readlines(self): + lines = [] + line = self.readline() + while line: + lines.append(line) + line = self.readline() + # end while + return lines + # end def readlines + # seek/tell etc. are left as an exercise for the reader +# end class StringReader + +class StringWriter: + def __init__(self): + self.buf = '' + # end def __init__ + def write(self, s): + self.buf = self.buf + s + # end def write + def getvalue(self): + return self.buf + # end def getvalue +# end class StringWriter + def complete_string(source, stepsize = STEPSIZE, tabsize = TABSIZE, expandtabs = EXPANDTABS): - input = io.BytesIO(source) - output = io.BytesIO() + input = StringReader(source) + output = StringWriter() pi = PythonIndenter(input, output, stepsize, tabsize, expandtabs) pi.complete() return output.getvalue() # end def complete_string def delete_string(source, stepsize = STEPSIZE, tabsize = TABSIZE, expandtabs = EXPANDTABS): - input = io.BytesIO(source) - output = io.BytesIO() + input = StringReader(source) + output = StringWriter() pi = PythonIndenter(input, output, stepsize, tabsize, expandtabs) pi.delete() return output.getvalue() # end def delete_string def reformat_string(source, stepsize = STEPSIZE, tabsize = TABSIZE, expandtabs = EXPANDTABS): - input = io.BytesIO(source) - output = io.BytesIO() + input = StringReader(source) + output = StringWriter() pi = PythonIndenter(input, output, stepsize, tabsize, expandtabs) pi.reformat() return output.getvalue() # end def reformat_string -def make_backup(filename): - import os, os.path - backup = filename + '~' - if os.path.lexists(backup): - try: - os.remove(backup) - except os.error: - print("Can't remove backup %r" % (backup,), file=sys.stderr) - # end try - # end if - try: - os.rename(filename, backup) - except os.error: - print("Can't rename %r to %r" % (filename, backup), file=sys.stderr) - # end try -# end def make_backup - def complete_file(filename, stepsize = STEPSIZE, tabsize = TABSIZE, expandtabs = EXPANDTABS): - with open(filename, 'r') as f: - source = f.read() - # end with + source = open(filename, 'r').read() result = complete_string(source, stepsize, tabsize, expandtabs) if source == result: return 0 # end if - make_backup(filename) - with open(filename, 'w') as f: - f.write(result) - # end with + import os + try: os.rename(filename, filename + '~') + except os.error: pass + # end try + f = open(filename, 'w') + f.write(result) + f.close() return 1 # end def complete_file def delete_file(filename, stepsize = STEPSIZE, tabsize = TABSIZE, expandtabs = EXPANDTABS): - with open(filename, 'r') as f: - source = f.read() - # end with + source = open(filename, 'r').read() result = delete_string(source, stepsize, tabsize, expandtabs) if source == result: return 0 # end if - make_backup(filename) - with open(filename, 'w') as f: - f.write(result) - # end with + import os + try: os.rename(filename, filename + '~') + except os.error: pass + # end try + f = open(filename, 'w') + f.write(result) + f.close() return 1 # end def delete_file def reformat_file(filename, stepsize = STEPSIZE, tabsize = TABSIZE, expandtabs = EXPANDTABS): - with open(filename, 'r') as f: - source = f.read() - # end with + source = open(filename, 'r').read() result = reformat_string(source, stepsize, tabsize, expandtabs) if source == result: return 0 # end if - make_backup(filename) - with open(filename, 'w') as f: - f.write(result) - # end with + import os + try: os.rename(filename, filename + '~') + except os.error: pass + # end try + f = open(filename, 'w') + f.write(result) + f.close() return 1 # end def reformat_file @@ -440,7 +474,7 @@ -r : reformat a completed program (use #end directives) -s stepsize: indentation step (default %(STEPSIZE)d) -t tabsize : the worth in spaces of a tab (default %(TABSIZE)d) --e : expand TABs into spaces (default OFF) +-e : expand TABs into spaces (defailt OFF) [file] ... : files are changed in place, with backups in file~ If no files are specified or a single - is given, the program acts as a filter (reads stdin, writes stdout). @@ -483,7 +517,7 @@ elif o == '-t': tabsize = int(a) elif o == '-e': - expandtabs = True + expandtabs = 1 # end if # end for if not action: diff -r 9cd3ab7c09d1 -r 9ac347a7f375 Tools/scripts/serve.py --- a/Tools/scripts/serve.py Sat Jul 19 16:34:33 2014 -0700 +++ b/Tools/scripts/serve.py Sun Jul 20 10:52:46 2014 -0400 @@ -2,7 +2,7 @@ ''' Small wsgiref based web server. Takes a path to serve from and an optional port number (defaults to 8000), then tries to serve files. -Mime types are guessed from the file names, 404 errors are raised +Mime types are guessed from the file names, 404 errors are thrown if the file is not found. Used for the make serve target in Doc. ''' import sys diff -r 9cd3ab7c09d1 -r 9ac347a7f375 config.guess --- a/config.guess Sat Jul 19 16:34:33 2014 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1558 +0,0 @@ -#! /bin/sh -# Attempt to guess a canonical system name. -# Copyright 1992-2013 Free Software Foundation, Inc. - -timestamp='2013-06-10' - -# This file is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, see . -# -# As a special exception to the GNU General Public License, if you -# distribute this file as part of a program that contains a -# configuration script generated by Autoconf, you may include it under -# the same distribution terms that you use for the rest of that -# program. This Exception is an additional permission under section 7 -# of the GNU General Public License, version 3 ("GPLv3"). -# -# Originally written by Per Bothner. -# -# You can get the latest version of this script from: -# http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD -# -# Please send patches with a ChangeLog entry to config-patches@gnu.org. - - -me=`echo "$0" | sed -e 's,.*/,,'` - -usage="\ -Usage: $0 [OPTION] - -Output the configuration name of the system \`$me' is run on. - -Operation modes: - -h, --help print this help, then exit - -t, --time-stamp print date of last modification, then exit - -v, --version print version number, then exit - -Report bugs and patches to ." - -version="\ -GNU config.guess ($timestamp) - -Originally written by Per Bothner. -Copyright 1992-2013 Free Software Foundation, Inc. - -This is free software; see the source for copying conditions. There is NO -warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." - -help=" -Try \`$me --help' for more information." - -# Parse command line -while test $# -gt 0 ; do - case $1 in - --time-stamp | --time* | -t ) - echo "$timestamp" ; exit ;; - --version | -v ) - echo "$version" ; exit ;; - --help | --h* | -h ) - echo "$usage"; exit ;; - -- ) # Stop option processing - shift; break ;; - - ) # Use stdin as input. - break ;; - -* ) - echo "$me: invalid option $1$help" >&2 - exit 1 ;; - * ) - break ;; - esac -done - -if test $# != 0; then - echo "$me: too many arguments$help" >&2 - exit 1 -fi - -trap 'exit 1' 1 2 15 - -# CC_FOR_BUILD -- compiler used by this script. Note that the use of a -# compiler to aid in system detection is discouraged as it requires -# temporary files to be created and, as you can see below, it is a -# headache to deal with in a portable fashion. - -# Historically, `CC_FOR_BUILD' used to be named `HOST_CC'. We still -# use `HOST_CC' if defined, but it is deprecated. - -# Portable tmp directory creation inspired by the Autoconf team. - -set_cc_for_build=' -trap "exitcode=\$?; (rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null) && exit \$exitcode" 0 ; -trap "rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null; exit 1" 1 2 13 15 ; -: ${TMPDIR=/tmp} ; - { tmp=`(umask 077 && mktemp -d "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } || - { test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir $tmp) ; } || - { tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir $tmp) && echo "Warning: creating insecure temp directory" >&2 ; } || - { echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; } ; -dummy=$tmp/dummy ; -tmpfiles="$dummy.c $dummy.o $dummy.rel $dummy" ; -case $CC_FOR_BUILD,$HOST_CC,$CC in - ,,) echo "int x;" > $dummy.c ; - for c in cc gcc c89 c99 ; do - if ($c -c -o $dummy.o $dummy.c) >/dev/null 2>&1 ; then - CC_FOR_BUILD="$c"; break ; - fi ; - done ; - if test x"$CC_FOR_BUILD" = x ; then - CC_FOR_BUILD=no_compiler_found ; - fi - ;; - ,,*) CC_FOR_BUILD=$CC ;; - ,*,*) CC_FOR_BUILD=$HOST_CC ;; -esac ; set_cc_for_build= ;' - -# This is needed to find uname on a Pyramid OSx when run in the BSD universe. -# (ghazi@noc.rutgers.edu 1994-08-24) -if (test -f /.attbin/uname) >/dev/null 2>&1 ; then - PATH=$PATH:/.attbin ; export PATH -fi - -UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown -UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown -UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown -UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown - -case "${UNAME_SYSTEM}" in -Linux|GNU|GNU/*) - # If the system lacks a compiler, then just pick glibc. - # We could probably try harder. - LIBC=gnu - - eval $set_cc_for_build - cat <<-EOF > $dummy.c - #include - #if defined(__UCLIBC__) - LIBC=uclibc - #elif defined(__dietlibc__) - LIBC=dietlibc - #else - LIBC=gnu - #endif - EOF - eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^LIBC'` - ;; -esac - -# Note: order is significant - the case branches are not exclusive. - -case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in - *:NetBSD:*:*) - # NetBSD (nbsd) targets should (where applicable) match one or - # more of the tuples: *-*-netbsdelf*, *-*-netbsdaout*, - # *-*-netbsdecoff* and *-*-netbsd*. For targets that recently - # switched to ELF, *-*-netbsd* would select the old - # object file format. This provides both forward - # compatibility and a consistent mechanism for selecting the - # object file format. - # - # Note: NetBSD doesn't particularly care about the vendor - # portion of the name. We always set it to "unknown". - sysctl="sysctl -n hw.machine_arch" - UNAME_MACHINE_ARCH=`(/sbin/$sysctl 2>/dev/null || \ - /usr/sbin/$sysctl 2>/dev/null || echo unknown)` - case "${UNAME_MACHINE_ARCH}" in - armeb) machine=armeb-unknown ;; - arm*) machine=arm-unknown ;; - sh3el) machine=shl-unknown ;; - sh3eb) machine=sh-unknown ;; - sh5el) machine=sh5le-unknown ;; - *) machine=${UNAME_MACHINE_ARCH}-unknown ;; - esac - # The Operating System including object format, if it has switched - # to ELF recently, or will in the future. - case "${UNAME_MACHINE_ARCH}" in - arm*|i386|m68k|ns32k|sh3*|sparc|vax) - eval $set_cc_for_build - if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \ - | grep -q __ELF__ - then - # Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout). - # Return netbsd for either. FIX? - os=netbsd - else - os=netbsdelf - fi - ;; - *) - os=netbsd - ;; - esac - # The OS release - # Debian GNU/NetBSD machines have a different userland, and - # thus, need a distinct triplet. However, they do not need - # kernel version information, so it can be replaced with a - # suitable tag, in the style of linux-gnu. - case "${UNAME_VERSION}" in - Debian*) - release='-gnu' - ;; - *) - release=`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'` - ;; - esac - # Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM: - # contains redundant information, the shorter form: - # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used. - echo "${machine}-${os}${release}" - exit ;; - *:Bitrig:*:*) - UNAME_MACHINE_ARCH=`arch | sed 's/Bitrig.//'` - echo ${UNAME_MACHINE_ARCH}-unknown-bitrig${UNAME_RELEASE} - exit ;; - *:OpenBSD:*:*) - UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'` - echo ${UNAME_MACHINE_ARCH}-unknown-openbsd${UNAME_RELEASE} - exit ;; - *:ekkoBSD:*:*) - echo ${UNAME_MACHINE}-unknown-ekkobsd${UNAME_RELEASE} - exit ;; - *:SolidBSD:*:*) - echo ${UNAME_MACHINE}-unknown-solidbsd${UNAME_RELEASE} - exit ;; - macppc:MirBSD:*:*) - echo powerpc-unknown-mirbsd${UNAME_RELEASE} - exit ;; - *:MirBSD:*:*) - echo ${UNAME_MACHINE}-unknown-mirbsd${UNAME_RELEASE} - exit ;; - alpha:OSF1:*:*) - case $UNAME_RELEASE in - *4.0) - UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'` - ;; - *5.*) - UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'` - ;; - esac - # According to Compaq, /usr/sbin/psrinfo has been available on - # OSF/1 and Tru64 systems produced since 1995. I hope that - # covers most systems running today. This code pipes the CPU - # types through head -n 1, so we only detect the type of CPU 0. - ALPHA_CPU_TYPE=`/usr/sbin/psrinfo -v | sed -n -e 's/^ The alpha \(.*\) processor.*$/\1/p' | head -n 1` - case "$ALPHA_CPU_TYPE" in - "EV4 (21064)") - UNAME_MACHINE="alpha" ;; - "EV4.5 (21064)") - UNAME_MACHINE="alpha" ;; - "LCA4 (21066/21068)") - UNAME_MACHINE="alpha" ;; - "EV5 (21164)") - UNAME_MACHINE="alphaev5" ;; - "EV5.6 (21164A)") - UNAME_MACHINE="alphaev56" ;; - "EV5.6 (21164PC)") - UNAME_MACHINE="alphapca56" ;; - "EV5.7 (21164PC)") - UNAME_MACHINE="alphapca57" ;; - "EV6 (21264)") - UNAME_MACHINE="alphaev6" ;; - "EV6.7 (21264A)") - UNAME_MACHINE="alphaev67" ;; - "EV6.8CB (21264C)") - UNAME_MACHINE="alphaev68" ;; - "EV6.8AL (21264B)") - UNAME_MACHINE="alphaev68" ;; - "EV6.8CX (21264D)") - UNAME_MACHINE="alphaev68" ;; - "EV6.9A (21264/EV69A)") - UNAME_MACHINE="alphaev69" ;; - "EV7 (21364)") - UNAME_MACHINE="alphaev7" ;; - "EV7.9 (21364A)") - UNAME_MACHINE="alphaev79" ;; - esac - # A Pn.n version is a patched version. - # A Vn.n version is a released version. - # A Tn.n version is a released field test version. - # A Xn.n version is an unreleased experimental baselevel. - # 1.2 uses "1.2" for uname -r. - echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[PVTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` - # Reset EXIT trap before exiting to avoid spurious non-zero exit code. - exitcode=$? - trap '' 0 - exit $exitcode ;; - Alpha\ *:Windows_NT*:*) - # How do we know it's Interix rather than the generic POSIX subsystem? - # Should we change UNAME_MACHINE based on the output of uname instead - # of the specific Alpha model? - echo alpha-pc-interix - exit ;; - 21064:Windows_NT:50:3) - echo alpha-dec-winnt3.5 - exit ;; - Amiga*:UNIX_System_V:4.0:*) - echo m68k-unknown-sysv4 - exit ;; - *:[Aa]miga[Oo][Ss]:*:*) - echo ${UNAME_MACHINE}-unknown-amigaos - exit ;; - *:[Mm]orph[Oo][Ss]:*:*) - echo ${UNAME_MACHINE}-unknown-morphos - exit ;; - *:OS/390:*:*) - echo i370-ibm-openedition - exit ;; - *:z/VM:*:*) - echo s390-ibm-zvmoe - exit ;; - *:OS400:*:*) - echo powerpc-ibm-os400 - exit ;; - arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*) - echo arm-acorn-riscix${UNAME_RELEASE} - exit ;; - arm*:riscos:*:*|arm*:RISCOS:*:*) - echo arm-unknown-riscos - exit ;; - SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*) - echo hppa1.1-hitachi-hiuxmpp - exit ;; - Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*) - # akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE. - if test "`(/bin/universe) 2>/dev/null`" = att ; then - echo pyramid-pyramid-sysv3 - else - echo pyramid-pyramid-bsd - fi - exit ;; - NILE*:*:*:dcosx) - echo pyramid-pyramid-svr4 - exit ;; - DRS?6000:unix:4.0:6*) - echo sparc-icl-nx6 - exit ;; - DRS?6000:UNIX_SV:4.2*:7* | DRS?6000:isis:4.2*:7*) - case `/usr/bin/uname -p` in - sparc) echo sparc-icl-nx7; exit ;; - esac ;; - s390x:SunOS:*:*) - echo ${UNAME_MACHINE}-ibm-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` - exit ;; - sun4H:SunOS:5.*:*) - echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` - exit ;; - sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*) - echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` - exit ;; - i86pc:AuroraUX:5.*:* | i86xen:AuroraUX:5.*:*) - echo i386-pc-auroraux${UNAME_RELEASE} - exit ;; - i86pc:SunOS:5.*:* | i86xen:SunOS:5.*:*) - eval $set_cc_for_build - SUN_ARCH="i386" - # If there is a compiler, see if it is configured for 64-bit objects. - # Note that the Sun cc does not turn __LP64__ into 1 like gcc does. - # This test works for both compilers. - if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then - if (echo '#ifdef __amd64'; echo IS_64BIT_ARCH; echo '#endif') | \ - (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \ - grep IS_64BIT_ARCH >/dev/null - then - SUN_ARCH="x86_64" - fi - fi - echo ${SUN_ARCH}-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` - exit ;; - sun4*:SunOS:6*:*) - # According to config.sub, this is the proper way to canonicalize - # SunOS6. Hard to guess exactly what SunOS6 will be like, but - # it's likely to be more like Solaris than SunOS4. - echo sparc-sun-solaris3`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` - exit ;; - sun4*:SunOS:*:*) - case "`/usr/bin/arch -k`" in - Series*|S4*) - UNAME_RELEASE=`uname -v` - ;; - esac - # Japanese Language versions have a version number like `4.1.3-JL'. - echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'` - exit ;; - sun3*:SunOS:*:*) - echo m68k-sun-sunos${UNAME_RELEASE} - exit ;; - sun*:*:4.2BSD:*) - UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null` - test "x${UNAME_RELEASE}" = "x" && UNAME_RELEASE=3 - case "`/bin/arch`" in - sun3) - echo m68k-sun-sunos${UNAME_RELEASE} - ;; - sun4) - echo sparc-sun-sunos${UNAME_RELEASE} - ;; - esac - exit ;; - aushp:SunOS:*:*) - echo sparc-auspex-sunos${UNAME_RELEASE} - exit ;; - # The situation for MiNT is a little confusing. The machine name - # can be virtually everything (everything which is not - # "atarist" or "atariste" at least should have a processor - # > m68000). The system name ranges from "MiNT" over "FreeMiNT" - # to the lowercase version "mint" (or "freemint"). Finally - # the system name "TOS" denotes a system which is actually not - # MiNT. But MiNT is downward compatible to TOS, so this should - # be no problem. - atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*) - echo m68k-atari-mint${UNAME_RELEASE} - exit ;; - atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*) - echo m68k-atari-mint${UNAME_RELEASE} - exit ;; - *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*) - echo m68k-atari-mint${UNAME_RELEASE} - exit ;; - milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*) - echo m68k-milan-mint${UNAME_RELEASE} - exit ;; - hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*) - echo m68k-hades-mint${UNAME_RELEASE} - exit ;; - *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*) - echo m68k-unknown-mint${UNAME_RELEASE} - exit ;; - m68k:machten:*:*) - echo m68k-apple-machten${UNAME_RELEASE} - exit ;; - powerpc:machten:*:*) - echo powerpc-apple-machten${UNAME_RELEASE} - exit ;; - RISC*:Mach:*:*) - echo mips-dec-mach_bsd4.3 - exit ;; - RISC*:ULTRIX:*:*) - echo mips-dec-ultrix${UNAME_RELEASE} - exit ;; - VAX*:ULTRIX*:*:*) - echo vax-dec-ultrix${UNAME_RELEASE} - exit ;; - 2020:CLIX:*:* | 2430:CLIX:*:*) - echo clipper-intergraph-clix${UNAME_RELEASE} - exit ;; - mips:*:*:UMIPS | mips:*:*:RISCos) - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c -#ifdef __cplusplus -#include /* for printf() prototype */ - int main (int argc, char *argv[]) { -#else - int main (argc, argv) int argc; char *argv[]; { -#endif - #if defined (host_mips) && defined (MIPSEB) - #if defined (SYSTYPE_SYSV) - printf ("mips-mips-riscos%ssysv\n", argv[1]); exit (0); - #endif - #if defined (SYSTYPE_SVR4) - printf ("mips-mips-riscos%ssvr4\n", argv[1]); exit (0); - #endif - #if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD) - printf ("mips-mips-riscos%sbsd\n", argv[1]); exit (0); - #endif - #endif - exit (-1); - } -EOF - $CC_FOR_BUILD -o $dummy $dummy.c && - dummyarg=`echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` && - SYSTEM_NAME=`$dummy $dummyarg` && - { echo "$SYSTEM_NAME"; exit; } - echo mips-mips-riscos${UNAME_RELEASE} - exit ;; - Motorola:PowerMAX_OS:*:*) - echo powerpc-motorola-powermax - exit ;; - Motorola:*:4.3:PL8-*) - echo powerpc-harris-powermax - exit ;; - Night_Hawk:*:*:PowerMAX_OS | Synergy:PowerMAX_OS:*:*) - echo powerpc-harris-powermax - exit ;; - Night_Hawk:Power_UNIX:*:*) - echo powerpc-harris-powerunix - exit ;; - m88k:CX/UX:7*:*) - echo m88k-harris-cxux7 - exit ;; - m88k:*:4*:R4*) - echo m88k-motorola-sysv4 - exit ;; - m88k:*:3*:R3*) - echo m88k-motorola-sysv3 - exit ;; - AViiON:dgux:*:*) - # DG/UX returns AViiON for all architectures - UNAME_PROCESSOR=`/usr/bin/uname -p` - if [ $UNAME_PROCESSOR = mc88100 ] || [ $UNAME_PROCESSOR = mc88110 ] - then - if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx ] || \ - [ ${TARGET_BINARY_INTERFACE}x = x ] - then - echo m88k-dg-dgux${UNAME_RELEASE} - else - echo m88k-dg-dguxbcs${UNAME_RELEASE} - fi - else - echo i586-dg-dgux${UNAME_RELEASE} - fi - exit ;; - M88*:DolphinOS:*:*) # DolphinOS (SVR3) - echo m88k-dolphin-sysv3 - exit ;; - M88*:*:R3*:*) - # Delta 88k system running SVR3 - echo m88k-motorola-sysv3 - exit ;; - XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3) - echo m88k-tektronix-sysv3 - exit ;; - Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD) - echo m68k-tektronix-bsd - exit ;; - *:IRIX*:*:*) - echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'` - exit ;; - ????????:AIX?:[12].1:2) # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX. - echo romp-ibm-aix # uname -m gives an 8 hex-code CPU id - exit ;; # Note that: echo "'`uname -s`'" gives 'AIX ' - i*86:AIX:*:*) - echo i386-ibm-aix - exit ;; - ia64:AIX:*:*) - if [ -x /usr/bin/oslevel ] ; then - IBM_REV=`/usr/bin/oslevel` - else - IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} - fi - echo ${UNAME_MACHINE}-ibm-aix${IBM_REV} - exit ;; - *:AIX:2:3) - if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c - #include - - main() - { - if (!__power_pc()) - exit(1); - puts("powerpc-ibm-aix3.2.5"); - exit(0); - } -EOF - if $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` - then - echo "$SYSTEM_NAME" - else - echo rs6000-ibm-aix3.2.5 - fi - elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then - echo rs6000-ibm-aix3.2.4 - else - echo rs6000-ibm-aix3.2 - fi - exit ;; - *:AIX:*:[4567]) - IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'` - if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then - IBM_ARCH=rs6000 - else - IBM_ARCH=powerpc - fi - if [ -x /usr/bin/oslevel ] ; then - IBM_REV=`/usr/bin/oslevel` - else - IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} - fi - echo ${IBM_ARCH}-ibm-aix${IBM_REV} - exit ;; - *:AIX:*:*) - echo rs6000-ibm-aix - exit ;; - ibmrt:4.4BSD:*|romp-ibm:BSD:*) - echo romp-ibm-bsd4.4 - exit ;; - ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC BSD and - echo romp-ibm-bsd${UNAME_RELEASE} # 4.3 with uname added to - exit ;; # report: romp-ibm BSD 4.3 - *:BOSX:*:*) - echo rs6000-bull-bosx - exit ;; - DPX/2?00:B.O.S.:*:*) - echo m68k-bull-sysv3 - exit ;; - 9000/[34]??:4.3bsd:1.*:*) - echo m68k-hp-bsd - exit ;; - hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*) - echo m68k-hp-bsd4.4 - exit ;; - 9000/[34678]??:HP-UX:*:*) - HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` - case "${UNAME_MACHINE}" in - 9000/31? ) HP_ARCH=m68000 ;; - 9000/[34]?? ) HP_ARCH=m68k ;; - 9000/[678][0-9][0-9]) - if [ -x /usr/bin/getconf ]; then - sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null` - sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null` - case "${sc_cpu_version}" in - 523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0 - 528) HP_ARCH="hppa1.1" ;; # CPU_PA_RISC1_1 - 532) # CPU_PA_RISC2_0 - case "${sc_kernel_bits}" in - 32) HP_ARCH="hppa2.0n" ;; - 64) HP_ARCH="hppa2.0w" ;; - '') HP_ARCH="hppa2.0" ;; # HP-UX 10.20 - esac ;; - esac - fi - if [ "${HP_ARCH}" = "" ]; then - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c - - #define _HPUX_SOURCE - #include - #include - - int main () - { - #if defined(_SC_KERNEL_BITS) - long bits = sysconf(_SC_KERNEL_BITS); - #endif - long cpu = sysconf (_SC_CPU_VERSION); - - switch (cpu) - { - case CPU_PA_RISC1_0: puts ("hppa1.0"); break; - case CPU_PA_RISC1_1: puts ("hppa1.1"); break; - case CPU_PA_RISC2_0: - #if defined(_SC_KERNEL_BITS) - switch (bits) - { - case 64: puts ("hppa2.0w"); break; - case 32: puts ("hppa2.0n"); break; - default: puts ("hppa2.0"); break; - } break; - #else /* !defined(_SC_KERNEL_BITS) */ - puts ("hppa2.0"); break; - #endif - default: puts ("hppa1.0"); break; - } - exit (0); - } -EOF - (CCOPTS= $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null) && HP_ARCH=`$dummy` - test -z "$HP_ARCH" && HP_ARCH=hppa - fi ;; - esac - if [ ${HP_ARCH} = "hppa2.0w" ] - then - eval $set_cc_for_build - - # hppa2.0w-hp-hpux* has a 64-bit kernel and a compiler generating - # 32-bit code. hppa64-hp-hpux* has the same kernel and a compiler - # generating 64-bit code. GNU and HP use different nomenclature: - # - # $ CC_FOR_BUILD=cc ./config.guess - # => hppa2.0w-hp-hpux11.23 - # $ CC_FOR_BUILD="cc +DA2.0w" ./config.guess - # => hppa64-hp-hpux11.23 - - if echo __LP64__ | (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | - grep -q __LP64__ - then - HP_ARCH="hppa2.0w" - else - HP_ARCH="hppa64" - fi - fi - echo ${HP_ARCH}-hp-hpux${HPUX_REV} - exit ;; - ia64:HP-UX:*:*) - HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` - echo ia64-hp-hpux${HPUX_REV} - exit ;; - 3050*:HI-UX:*:*) - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c - #include - int - main () - { - long cpu = sysconf (_SC_CPU_VERSION); - /* The order matters, because CPU_IS_HP_MC68K erroneously returns - true for CPU_PA_RISC1_0. CPU_IS_PA_RISC returns correct - results, however. */ - if (CPU_IS_PA_RISC (cpu)) - { - switch (cpu) - { - case CPU_PA_RISC1_0: puts ("hppa1.0-hitachi-hiuxwe2"); break; - case CPU_PA_RISC1_1: puts ("hppa1.1-hitachi-hiuxwe2"); break; - case CPU_PA_RISC2_0: puts ("hppa2.0-hitachi-hiuxwe2"); break; - default: puts ("hppa-hitachi-hiuxwe2"); break; - } - } - else if (CPU_IS_HP_MC68K (cpu)) - puts ("m68k-hitachi-hiuxwe2"); - else puts ("unknown-hitachi-hiuxwe2"); - exit (0); - } -EOF - $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` && - { echo "$SYSTEM_NAME"; exit; } - echo unknown-hitachi-hiuxwe2 - exit ;; - 9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* ) - echo hppa1.1-hp-bsd - exit ;; - 9000/8??:4.3bsd:*:*) - echo hppa1.0-hp-bsd - exit ;; - *9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*) - echo hppa1.0-hp-mpeix - exit ;; - hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* ) - echo hppa1.1-hp-osf - exit ;; - hp8??:OSF1:*:*) - echo hppa1.0-hp-osf - exit ;; - i*86:OSF1:*:*) - if [ -x /usr/sbin/sysversion ] ; then - echo ${UNAME_MACHINE}-unknown-osf1mk - else - echo ${UNAME_MACHINE}-unknown-osf1 - fi - exit ;; - parisc*:Lites*:*:*) - echo hppa1.1-hp-lites - exit ;; - C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*) - echo c1-convex-bsd - exit ;; - C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*) - if getsysinfo -f scalar_acc - then echo c32-convex-bsd - else echo c2-convex-bsd - fi - exit ;; - C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*) - echo c34-convex-bsd - exit ;; - C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*) - echo c38-convex-bsd - exit ;; - C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*) - echo c4-convex-bsd - exit ;; - CRAY*Y-MP:*:*:*) - echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' - exit ;; - CRAY*[A-Z]90:*:*:*) - echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \ - | sed -e 's/CRAY.*\([A-Z]90\)/\1/' \ - -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ \ - -e 's/\.[^.]*$/.X/' - exit ;; - CRAY*TS:*:*:*) - echo t90-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' - exit ;; - CRAY*T3E:*:*:*) - echo alphaev5-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' - exit ;; - CRAY*SV1:*:*:*) - echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' - exit ;; - *:UNICOS/mp:*:*) - echo craynv-cray-unicosmp${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' - exit ;; - F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*) - FUJITSU_PROC=`uname -m | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` - FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` - FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'` - echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" - exit ;; - 5000:UNIX_System_V:4.*:*) - FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` - FUJITSU_REL=`echo ${UNAME_RELEASE} | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/ /_/'` - echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" - exit ;; - i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*) - echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE} - exit ;; - sparc*:BSD/OS:*:*) - echo sparc-unknown-bsdi${UNAME_RELEASE} - exit ;; - *:BSD/OS:*:*) - echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE} - exit ;; - *:FreeBSD:*:*) - UNAME_PROCESSOR=`/usr/bin/uname -p` - case ${UNAME_PROCESSOR} in - amd64) - echo x86_64-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; - *) - echo ${UNAME_PROCESSOR}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; - esac - exit ;; - i*:CYGWIN*:*) - echo ${UNAME_MACHINE}-pc-cygwin - exit ;; - *:MINGW64*:*) - echo ${UNAME_MACHINE}-pc-mingw64 - exit ;; - *:MINGW*:*) - echo ${UNAME_MACHINE}-pc-mingw32 - exit ;; - i*:MSYS*:*) - echo ${UNAME_MACHINE}-pc-msys - exit ;; - i*:windows32*:*) - # uname -m includes "-pc" on this system. - echo ${UNAME_MACHINE}-mingw32 - exit ;; - i*:PW*:*) - echo ${UNAME_MACHINE}-pc-pw32 - exit ;; - *:Interix*:*) - case ${UNAME_MACHINE} in - x86) - echo i586-pc-interix${UNAME_RELEASE} - exit ;; - authenticamd | genuineintel | EM64T) - echo x86_64-unknown-interix${UNAME_RELEASE} - exit ;; - IA64) - echo ia64-unknown-interix${UNAME_RELEASE} - exit ;; - esac ;; - [345]86:Windows_95:* | [345]86:Windows_98:* | [345]86:Windows_NT:*) - echo i${UNAME_MACHINE}-pc-mks - exit ;; - 8664:Windows_NT:*) - echo x86_64-pc-mks - exit ;; - i*:Windows_NT*:* | Pentium*:Windows_NT*:*) - # How do we know it's Interix rather than the generic POSIX subsystem? - # It also conflicts with pre-2.0 versions of AT&T UWIN. Should we - # UNAME_MACHINE based on the output of uname instead of i386? - echo i586-pc-interix - exit ;; - i*:UWIN*:*) - echo ${UNAME_MACHINE}-pc-uwin - exit ;; - amd64:CYGWIN*:*:* | x86_64:CYGWIN*:*:*) - echo x86_64-unknown-cygwin - exit ;; - p*:CYGWIN*:*) - echo powerpcle-unknown-cygwin - exit ;; - prep*:SunOS:5.*:*) - echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` - exit ;; - *:GNU:*:*) - # the GNU system - echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-${LIBC}`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'` - exit ;; - *:GNU/*:*:*) - # other systems with GNU libc and userland - echo ${UNAME_MACHINE}-unknown-`echo ${UNAME_SYSTEM} | sed 's,^[^/]*/,,' | tr '[A-Z]' '[a-z]'``echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`-${LIBC} - exit ;; - i*86:Minix:*:*) - echo ${UNAME_MACHINE}-pc-minix - exit ;; - aarch64:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} - exit ;; - aarch64_be:Linux:*:*) - UNAME_MACHINE=aarch64_be - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} - exit ;; - alpha:Linux:*:*) - case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in - EV5) UNAME_MACHINE=alphaev5 ;; - EV56) UNAME_MACHINE=alphaev56 ;; - PCA56) UNAME_MACHINE=alphapca56 ;; - PCA57) UNAME_MACHINE=alphapca56 ;; - EV6) UNAME_MACHINE=alphaev6 ;; - EV67) UNAME_MACHINE=alphaev67 ;; - EV68*) UNAME_MACHINE=alphaev68 ;; - esac - objdump --private-headers /bin/sh | grep -q ld.so.1 - if test "$?" = 0 ; then LIBC="gnulibc1" ; fi - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} - exit ;; - arc:Linux:*:* | arceb:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} - exit ;; - arm*:Linux:*:*) - eval $set_cc_for_build - if echo __ARM_EABI__ | $CC_FOR_BUILD -E - 2>/dev/null \ - | grep -q __ARM_EABI__ - then - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} - else - if echo __ARM_PCS_VFP | $CC_FOR_BUILD -E - 2>/dev/null \ - | grep -q __ARM_PCS_VFP - then - echo ${UNAME_MACHINE}-unknown-linux-${LIBC}eabi - else - echo ${UNAME_MACHINE}-unknown-linux-${LIBC}eabihf - fi - fi - exit ;; - avr32*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} - exit ;; - cris:Linux:*:*) - echo ${UNAME_MACHINE}-axis-linux-${LIBC} - exit ;; - crisv32:Linux:*:*) - echo ${UNAME_MACHINE}-axis-linux-${LIBC} - exit ;; - frv:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} - exit ;; - hexagon:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} - exit ;; - i*86:Linux:*:*) - echo ${UNAME_MACHINE}-pc-linux-${LIBC} - exit ;; - ia64:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} - exit ;; - m32r*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} - exit ;; - m68*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} - exit ;; - mips:Linux:*:* | mips64:Linux:*:*) - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c - #undef CPU - #undef ${UNAME_MACHINE} - #undef ${UNAME_MACHINE}el - #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL) - CPU=${UNAME_MACHINE}el - #else - #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB) - CPU=${UNAME_MACHINE} - #else - CPU= - #endif - #endif -EOF - eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^CPU'` - test x"${CPU}" != x && { echo "${CPU}-unknown-linux-${LIBC}"; exit; } - ;; - or1k:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} - exit ;; - or32:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} - exit ;; - padre:Linux:*:*) - echo sparc-unknown-linux-${LIBC} - exit ;; - parisc64:Linux:*:* | hppa64:Linux:*:*) - echo hppa64-unknown-linux-${LIBC} - exit ;; - parisc:Linux:*:* | hppa:Linux:*:*) - # Look for CPU level - case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in - PA7*) echo hppa1.1-unknown-linux-${LIBC} ;; - PA8*) echo hppa2.0-unknown-linux-${LIBC} ;; - *) echo hppa-unknown-linux-${LIBC} ;; - esac - exit ;; - ppc64:Linux:*:*) - echo powerpc64-unknown-linux-${LIBC} - exit ;; - ppc:Linux:*:*) - echo powerpc-unknown-linux-${LIBC} - exit ;; - ppc64le:Linux:*:*) - echo powerpc64le-unknown-linux-${LIBC} - exit ;; - ppcle:Linux:*:*) - echo powerpcle-unknown-linux-${LIBC} - exit ;; - s390:Linux:*:* | s390x:Linux:*:*) - echo ${UNAME_MACHINE}-ibm-linux-${LIBC} - exit ;; - sh64*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} - exit ;; - sh*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} - exit ;; - sparc:Linux:*:* | sparc64:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} - exit ;; - tile*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} - exit ;; - vax:Linux:*:*) - echo ${UNAME_MACHINE}-dec-linux-${LIBC} - exit ;; - x86_64:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} - exit ;; - xtensa*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} - exit ;; - i*86:DYNIX/ptx:4*:*) - # ptx 4.0 does uname -s correctly, with DYNIX/ptx in there. - # earlier versions are messed up and put the nodename in both - # sysname and nodename. - echo i386-sequent-sysv4 - exit ;; - i*86:UNIX_SV:4.2MP:2.*) - # Unixware is an offshoot of SVR4, but it has its own version - # number series starting with 2... - # I am not positive that other SVR4 systems won't match this, - # I just have to hope. -- rms. - # Use sysv4.2uw... so that sysv4* matches it. - echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION} - exit ;; - i*86:OS/2:*:*) - # If we were able to find `uname', then EMX Unix compatibility - # is probably installed. - echo ${UNAME_MACHINE}-pc-os2-emx - exit ;; - i*86:XTS-300:*:STOP) - echo ${UNAME_MACHINE}-unknown-stop - exit ;; - i*86:atheos:*:*) - echo ${UNAME_MACHINE}-unknown-atheos - exit ;; - i*86:syllable:*:*) - echo ${UNAME_MACHINE}-pc-syllable - exit ;; - i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.[02]*:*) - echo i386-unknown-lynxos${UNAME_RELEASE} - exit ;; - i*86:*DOS:*:*) - echo ${UNAME_MACHINE}-pc-msdosdjgpp - exit ;; - i*86:*:4.*:* | i*86:SYSTEM_V:4.*:*) - UNAME_REL=`echo ${UNAME_RELEASE} | sed 's/\/MP$//'` - if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then - echo ${UNAME_MACHINE}-univel-sysv${UNAME_REL} - else - echo ${UNAME_MACHINE}-pc-sysv${UNAME_REL} - fi - exit ;; - i*86:*:5:[678]*) - # UnixWare 7.x, OpenUNIX and OpenServer 6. - case `/bin/uname -X | grep "^Machine"` in - *486*) UNAME_MACHINE=i486 ;; - *Pentium) UNAME_MACHINE=i586 ;; - *Pent*|*Celeron) UNAME_MACHINE=i686 ;; - esac - echo ${UNAME_MACHINE}-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION} - exit ;; - i*86:*:3.2:*) - if test -f /usr/options/cb.name; then - UNAME_REL=`sed -n 's/.*Version //p' /dev/null >/dev/null ; then - UNAME_REL=`(/bin/uname -X|grep Release|sed -e 's/.*= //')` - (/bin/uname -X|grep i80486 >/dev/null) && UNAME_MACHINE=i486 - (/bin/uname -X|grep '^Machine.*Pentium' >/dev/null) \ - && UNAME_MACHINE=i586 - (/bin/uname -X|grep '^Machine.*Pent *II' >/dev/null) \ - && UNAME_MACHINE=i686 - (/bin/uname -X|grep '^Machine.*Pentium Pro' >/dev/null) \ - && UNAME_MACHINE=i686 - echo ${UNAME_MACHINE}-pc-sco$UNAME_REL - else - echo ${UNAME_MACHINE}-pc-sysv32 - fi - exit ;; - pc:*:*:*) - # Left here for compatibility: - # uname -m prints for DJGPP always 'pc', but it prints nothing about - # the processor, so we play safe by assuming i586. - # Note: whatever this is, it MUST be the same as what config.sub - # prints for the "djgpp" host, or else GDB configury will decide that - # this is a cross-build. - echo i586-pc-msdosdjgpp - exit ;; - Intel:Mach:3*:*) - echo i386-pc-mach3 - exit ;; - paragon:*:*:*) - echo i860-intel-osf1 - exit ;; - i860:*:4.*:*) # i860-SVR4 - if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then - echo i860-stardent-sysv${UNAME_RELEASE} # Stardent Vistra i860-SVR4 - else # Add other i860-SVR4 vendors below as they are discovered. - echo i860-unknown-sysv${UNAME_RELEASE} # Unknown i860-SVR4 - fi - exit ;; - mini*:CTIX:SYS*5:*) - # "miniframe" - echo m68010-convergent-sysv - exit ;; - mc68k:UNIX:SYSTEM5:3.51m) - echo m68k-convergent-sysv - exit ;; - M680?0:D-NIX:5.3:*) - echo m68k-diab-dnix - exit ;; - M68*:*:R3V[5678]*:*) - test -r /sysV68 && { echo 'm68k-motorola-sysv'; exit; } ;; - 3[345]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4400:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0 | SDS2:*:4.0:3.0 | SHG2:*:4.0:3.0 | S7501*:*:4.0:3.0) - OS_REL='' - test -r /etc/.relid \ - && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` - /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ - && { echo i486-ncr-sysv4.3${OS_REL}; exit; } - /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ - && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;; - 3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*) - /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ - && { echo i486-ncr-sysv4; exit; } ;; - NCR*:*:4.2:* | MPRAS*:*:4.2:*) - OS_REL='.3' - test -r /etc/.relid \ - && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` - /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ - && { echo i486-ncr-sysv4.3${OS_REL}; exit; } - /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ - && { echo i586-ncr-sysv4.3${OS_REL}; exit; } - /bin/uname -p 2>/dev/null | /bin/grep pteron >/dev/null \ - && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;; - m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*) - echo m68k-unknown-lynxos${UNAME_RELEASE} - exit ;; - mc68030:UNIX_System_V:4.*:*) - echo m68k-atari-sysv4 - exit ;; - TSUNAMI:LynxOS:2.*:*) - echo sparc-unknown-lynxos${UNAME_RELEASE} - exit ;; - rs6000:LynxOS:2.*:*) - echo rs6000-unknown-lynxos${UNAME_RELEASE} - exit ;; - PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.[02]*:*) - echo powerpc-unknown-lynxos${UNAME_RELEASE} - exit ;; - SM[BE]S:UNIX_SV:*:*) - echo mips-dde-sysv${UNAME_RELEASE} - exit ;; - RM*:ReliantUNIX-*:*:*) - echo mips-sni-sysv4 - exit ;; - RM*:SINIX-*:*:*) - echo mips-sni-sysv4 - exit ;; - *:SINIX-*:*:*) - if uname -p 2>/dev/null >/dev/null ; then - UNAME_MACHINE=`(uname -p) 2>/dev/null` - echo ${UNAME_MACHINE}-sni-sysv4 - else - echo ns32k-sni-sysv - fi - exit ;; - PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort - # says - echo i586-unisys-sysv4 - exit ;; - *:UNIX_System_V:4*:FTX*) - # From Gerald Hewes . - # How about differentiating between stratus architectures? -djm - echo hppa1.1-stratus-sysv4 - exit ;; - *:*:*:FTX*) - # From seanf@swdc.stratus.com. - echo i860-stratus-sysv4 - exit ;; - i*86:VOS:*:*) - # From Paul.Green@stratus.com. - echo ${UNAME_MACHINE}-stratus-vos - exit ;; - *:VOS:*:*) - # From Paul.Green@stratus.com. - echo hppa1.1-stratus-vos - exit ;; - mc68*:A/UX:*:*) - echo m68k-apple-aux${UNAME_RELEASE} - exit ;; - news*:NEWS-OS:6*:*) - echo mips-sony-newsos6 - exit ;; - R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*) - if [ -d /usr/nec ]; then - echo mips-nec-sysv${UNAME_RELEASE} - else - echo mips-unknown-sysv${UNAME_RELEASE} - fi - exit ;; - BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only. - echo powerpc-be-beos - exit ;; - BeMac:BeOS:*:*) # BeOS running on Mac or Mac clone, PPC only. - echo powerpc-apple-beos - exit ;; - BePC:BeOS:*:*) # BeOS running on Intel PC compatible. - echo i586-pc-beos - exit ;; - BePC:Haiku:*:*) # Haiku running on Intel PC compatible. - echo i586-pc-haiku - exit ;; - x86_64:Haiku:*:*) - echo x86_64-unknown-haiku - exit ;; - SX-4:SUPER-UX:*:*) - echo sx4-nec-superux${UNAME_RELEASE} - exit ;; - SX-5:SUPER-UX:*:*) - echo sx5-nec-superux${UNAME_RELEASE} - exit ;; - SX-6:SUPER-UX:*:*) - echo sx6-nec-superux${UNAME_RELEASE} - exit ;; - SX-7:SUPER-UX:*:*) - echo sx7-nec-superux${UNAME_RELEASE} - exit ;; - SX-8:SUPER-UX:*:*) - echo sx8-nec-superux${UNAME_RELEASE} - exit ;; - SX-8R:SUPER-UX:*:*) - echo sx8r-nec-superux${UNAME_RELEASE} - exit ;; - Power*:Rhapsody:*:*) - echo powerpc-apple-rhapsody${UNAME_RELEASE} - exit ;; - *:Rhapsody:*:*) - echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE} - exit ;; - *:Darwin:*:*) - UNAME_PROCESSOR=`uname -p` || UNAME_PROCESSOR=unknown - eval $set_cc_for_build - if test "$UNAME_PROCESSOR" = unknown ; then - UNAME_PROCESSOR=powerpc - fi - if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then - if (echo '#ifdef __LP64__'; echo IS_64BIT_ARCH; echo '#endif') | \ - (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \ - grep IS_64BIT_ARCH >/dev/null - then - case $UNAME_PROCESSOR in - i386) UNAME_PROCESSOR=x86_64 ;; - powerpc) UNAME_PROCESSOR=powerpc64 ;; - esac - fi - fi - echo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE} - exit ;; - *:procnto*:*:* | *:QNX:[0123456789]*:*) - UNAME_PROCESSOR=`uname -p` - if test "$UNAME_PROCESSOR" = "x86"; then - UNAME_PROCESSOR=i386 - UNAME_MACHINE=pc - fi - echo ${UNAME_PROCESSOR}-${UNAME_MACHINE}-nto-qnx${UNAME_RELEASE} - exit ;; - *:QNX:*:4*) - echo i386-pc-qnx - exit ;; - NEO-?:NONSTOP_KERNEL:*:*) - echo neo-tandem-nsk${UNAME_RELEASE} - exit ;; - NSE-*:NONSTOP_KERNEL:*:*) - echo nse-tandem-nsk${UNAME_RELEASE} - exit ;; - NSR-?:NONSTOP_KERNEL:*:*) - echo nsr-tandem-nsk${UNAME_RELEASE} - exit ;; - *:NonStop-UX:*:*) - echo mips-compaq-nonstopux - exit ;; - BS2000:POSIX*:*:*) - echo bs2000-siemens-sysv - exit ;; - DS/*:UNIX_System_V:*:*) - echo ${UNAME_MACHINE}-${UNAME_SYSTEM}-${UNAME_RELEASE} - exit ;; - *:Plan9:*:*) - # "uname -m" is not consistent, so use $cputype instead. 386 - # is converted to i386 for consistency with other x86 - # operating systems. - if test "$cputype" = "386"; then - UNAME_MACHINE=i386 - else - UNAME_MACHINE="$cputype" - fi - echo ${UNAME_MACHINE}-unknown-plan9 - exit ;; - *:TOPS-10:*:*) - echo pdp10-unknown-tops10 - exit ;; - *:TENEX:*:*) - echo pdp10-unknown-tenex - exit ;; - KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*) - echo pdp10-dec-tops20 - exit ;; - XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*) - echo pdp10-xkl-tops20 - exit ;; - *:TOPS-20:*:*) - echo pdp10-unknown-tops20 - exit ;; - *:ITS:*:*) - echo pdp10-unknown-its - exit ;; - SEI:*:*:SEIUX) - echo mips-sei-seiux${UNAME_RELEASE} - exit ;; - *:DragonFly:*:*) - echo ${UNAME_MACHINE}-unknown-dragonfly`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` - exit ;; - *:*VMS:*:*) - UNAME_MACHINE=`(uname -p) 2>/dev/null` - case "${UNAME_MACHINE}" in - A*) echo alpha-dec-vms ; exit ;; - I*) echo ia64-dec-vms ; exit ;; - V*) echo vax-dec-vms ; exit ;; - esac ;; - *:XENIX:*:SysV) - echo i386-pc-xenix - exit ;; - i*86:skyos:*:*) - echo ${UNAME_MACHINE}-pc-skyos`echo ${UNAME_RELEASE}` | sed -e 's/ .*$//' - exit ;; - i*86:rdos:*:*) - echo ${UNAME_MACHINE}-pc-rdos - exit ;; - i*86:AROS:*:*) - echo ${UNAME_MACHINE}-pc-aros - exit ;; - x86_64:VMkernel:*:*) - echo ${UNAME_MACHINE}-unknown-esx - exit ;; -esac - -eval $set_cc_for_build -cat >$dummy.c < -# include -#endif -main () -{ -#if defined (sony) -#if defined (MIPSEB) - /* BFD wants "bsd" instead of "newsos". Perhaps BFD should be changed, - I don't know.... */ - printf ("mips-sony-bsd\n"); exit (0); -#else -#include - printf ("m68k-sony-newsos%s\n", -#ifdef NEWSOS4 - "4" -#else - "" -#endif - ); exit (0); -#endif -#endif - -#if defined (__arm) && defined (__acorn) && defined (__unix) - printf ("arm-acorn-riscix\n"); exit (0); -#endif - -#if defined (hp300) && !defined (hpux) - printf ("m68k-hp-bsd\n"); exit (0); -#endif - -#if defined (NeXT) -#if !defined (__ARCHITECTURE__) -#define __ARCHITECTURE__ "m68k" -#endif - int version; - version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`; - if (version < 4) - printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version); - else - printf ("%s-next-openstep%d\n", __ARCHITECTURE__, version); - exit (0); -#endif - -#if defined (MULTIMAX) || defined (n16) -#if defined (UMAXV) - printf ("ns32k-encore-sysv\n"); exit (0); -#else -#if defined (CMU) - printf ("ns32k-encore-mach\n"); exit (0); -#else - printf ("ns32k-encore-bsd\n"); exit (0); -#endif -#endif -#endif - -#if defined (__386BSD__) - printf ("i386-pc-bsd\n"); exit (0); -#endif - -#if defined (sequent) -#if defined (i386) - printf ("i386-sequent-dynix\n"); exit (0); -#endif -#if defined (ns32000) - printf ("ns32k-sequent-dynix\n"); exit (0); -#endif -#endif - -#if defined (_SEQUENT_) - struct utsname un; - - uname(&un); - - if (strncmp(un.version, "V2", 2) == 0) { - printf ("i386-sequent-ptx2\n"); exit (0); - } - if (strncmp(un.version, "V1", 2) == 0) { /* XXX is V1 correct? */ - printf ("i386-sequent-ptx1\n"); exit (0); - } - printf ("i386-sequent-ptx\n"); exit (0); - -#endif - -#if defined (vax) -# if !defined (ultrix) -# include -# if defined (BSD) -# if BSD == 43 - printf ("vax-dec-bsd4.3\n"); exit (0); -# else -# if BSD == 199006 - printf ("vax-dec-bsd4.3reno\n"); exit (0); -# else - printf ("vax-dec-bsd\n"); exit (0); -# endif -# endif -# else - printf ("vax-dec-bsd\n"); exit (0); -# endif -# else - printf ("vax-dec-ultrix\n"); exit (0); -# endif -#endif - -#if defined (alliant) && defined (i860) - printf ("i860-alliant-bsd\n"); exit (0); -#endif - - exit (1); -} -EOF - -$CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null && SYSTEM_NAME=`$dummy` && - { echo "$SYSTEM_NAME"; exit; } - -# Apollos put the system type in the environment. - -test -d /usr/apollo && { echo ${ISP}-apollo-${SYSTYPE}; exit; } - -# Convex versions that predate uname can use getsysinfo(1) - -if [ -x /usr/convex/getsysinfo ] -then - case `getsysinfo -f cpu_type` in - c1*) - echo c1-convex-bsd - exit ;; - c2*) - if getsysinfo -f scalar_acc - then echo c32-convex-bsd - else echo c2-convex-bsd - fi - exit ;; - c34*) - echo c34-convex-bsd - exit ;; - c38*) - echo c38-convex-bsd - exit ;; - c4*) - echo c4-convex-bsd - exit ;; - esac -fi - -cat >&2 < in order to provide the needed -information to handle your system. - -config.guess timestamp = $timestamp - -uname -m = `(uname -m) 2>/dev/null || echo unknown` -uname -r = `(uname -r) 2>/dev/null || echo unknown` -uname -s = `(uname -s) 2>/dev/null || echo unknown` -uname -v = `(uname -v) 2>/dev/null || echo unknown` - -/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null` -/bin/uname -X = `(/bin/uname -X) 2>/dev/null` - -hostinfo = `(hostinfo) 2>/dev/null` -/bin/universe = `(/bin/universe) 2>/dev/null` -/usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null` -/bin/arch = `(/bin/arch) 2>/dev/null` -/usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null` -/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null` - -UNAME_MACHINE = ${UNAME_MACHINE} -UNAME_RELEASE = ${UNAME_RELEASE} -UNAME_SYSTEM = ${UNAME_SYSTEM} -UNAME_VERSION = ${UNAME_VERSION} -EOF - -exit 1 - -# Local variables: -# eval: (add-hook 'write-file-hooks 'time-stamp) -# time-stamp-start: "timestamp='" -# time-stamp-format: "%:y-%02m-%02d" -# time-stamp-end: "'" -# End: diff -r 9cd3ab7c09d1 -r 9ac347a7f375 config.sub --- a/config.sub Sat Jul 19 16:34:33 2014 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1791 +0,0 @@ -#! /bin/sh -# Configuration validation subroutine script. -# Copyright 1992-2013 Free Software Foundation, Inc. - -timestamp='2013-08-10' - -# This file is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, see . -# -# As a special exception to the GNU General Public License, if you -# distribute this file as part of a program that contains a -# configuration script generated by Autoconf, you may include it under -# the same distribution terms that you use for the rest of that -# program. This Exception is an additional permission under section 7 -# of the GNU General Public License, version 3 ("GPLv3"). - - -# Please send patches with a ChangeLog entry to config-patches@gnu.org. -# -# Configuration subroutine to validate and canonicalize a configuration type. -# Supply the specified configuration type as an argument. -# If it is invalid, we print an error message on stderr and exit with code 1. -# Otherwise, we print the canonical config type on stdout and succeed. - -# You can get the latest version of this script from: -# http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub;hb=HEAD - -# This file is supposed to be the same for all GNU packages -# and recognize all the CPU types, system types and aliases -# that are meaningful with *any* GNU software. -# Each package is responsible for reporting which valid configurations -# it does not support. The user should be able to distinguish -# a failure to support a valid configuration from a meaningless -# configuration. - -# The goal of this file is to map all the various variations of a given -# machine specification into a single specification in the form: -# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM -# or in some cases, the newer four-part form: -# CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM -# It is wrong to echo any other type of specification. - -me=`echo "$0" | sed -e 's,.*/,,'` - -usage="\ -Usage: $0 [OPTION] CPU-MFR-OPSYS - $0 [OPTION] ALIAS - -Canonicalize a configuration name. - -Operation modes: - -h, --help print this help, then exit - -t, --time-stamp print date of last modification, then exit - -v, --version print version number, then exit - -Report bugs and patches to ." - -version="\ -GNU config.sub ($timestamp) - -Copyright 1992-2013 Free Software Foundation, Inc. - -This is free software; see the source for copying conditions. There is NO -warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." - -help=" -Try \`$me --help' for more information." - -# Parse command line -while test $# -gt 0 ; do - case $1 in - --time-stamp | --time* | -t ) - echo "$timestamp" ; exit ;; - --version | -v ) - echo "$version" ; exit ;; - --help | --h* | -h ) - echo "$usage"; exit ;; - -- ) # Stop option processing - shift; break ;; - - ) # Use stdin as input. - break ;; - -* ) - echo "$me: invalid option $1$help" - exit 1 ;; - - *local*) - # First pass through any local machine types. - echo $1 - exit ;; - - * ) - break ;; - esac -done - -case $# in - 0) echo "$me: missing argument$help" >&2 - exit 1;; - 1) ;; - *) echo "$me: too many arguments$help" >&2 - exit 1;; -esac - -# Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any). -# Here we must recognize all the valid KERNEL-OS combinations. -maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'` -case $maybe_os in - nto-qnx* | linux-gnu* | linux-android* | linux-dietlibc | linux-newlib* | \ - linux-musl* | linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | \ - knetbsd*-gnu* | netbsd*-gnu* | \ - kopensolaris*-gnu* | \ - storm-chaos* | os2-emx* | rtmk-nova*) - os=-$maybe_os - basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'` - ;; - android-linux) - os=-linux-android - basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`-unknown - ;; - *) - basic_machine=`echo $1 | sed 's/-[^-]*$//'` - if [ $basic_machine != $1 ] - then os=`echo $1 | sed 's/.*-/-/'` - else os=; fi - ;; -esac - -### Let's recognize common machines as not being operating systems so -### that things like config.sub decstation-3100 work. We also -### recognize some manufacturers as not being operating systems, so we -### can provide default operating systems below. -case $os in - -sun*os*) - # Prevent following clause from handling this invalid input. - ;; - -dec* | -mips* | -sequent* | -encore* | -pc532* | -sgi* | -sony* | \ - -att* | -7300* | -3300* | -delta* | -motorola* | -sun[234]* | \ - -unicom* | -ibm* | -next | -hp | -isi* | -apollo | -altos* | \ - -convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\ - -c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \ - -harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \ - -apple | -axis | -knuth | -cray | -microblaze*) - os= - basic_machine=$1 - ;; - -bluegene*) - os=-cnk - ;; - -sim | -cisco | -oki | -wec | -winbond) - os= - basic_machine=$1 - ;; - -scout) - ;; - -wrs) - os=-vxworks - basic_machine=$1 - ;; - -chorusos*) - os=-chorusos - basic_machine=$1 - ;; - -chorusrdb) - os=-chorusrdb - basic_machine=$1 - ;; - -hiux*) - os=-hiuxwe2 - ;; - -sco6) - os=-sco5v6 - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -sco5) - os=-sco3.2v5 - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -sco4) - os=-sco3.2v4 - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -sco3.2.[4-9]*) - os=`echo $os | sed -e 's/sco3.2./sco3.2v/'` - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -sco3.2v[4-9]*) - # Don't forget version if it is 3.2v4 or newer. - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -sco5v6*) - # Don't forget version if it is 3.2v4 or newer. - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -sco*) - os=-sco3.2v2 - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -udk*) - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -isc) - os=-isc2.2 - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -clix*) - basic_machine=clipper-intergraph - ;; - -isc*) - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -lynx*178) - os=-lynxos178 - ;; - -lynx*5) - os=-lynxos5 - ;; - -lynx*) - os=-lynxos - ;; - -ptx*) - basic_machine=`echo $1 | sed -e 's/86-.*/86-sequent/'` - ;; - -windowsnt*) - os=`echo $os | sed -e 's/windowsnt/winnt/'` - ;; - -psos*) - os=-psos - ;; - -mint | -mint[0-9]*) - basic_machine=m68k-atari - os=-mint - ;; -esac - -# Decode aliases for certain CPU-COMPANY combinations. -case $basic_machine in - # Recognize the basic CPU types without company name. - # Some are omitted here because they have special meanings below. - 1750a | 580 \ - | a29k \ - | aarch64 | aarch64_be \ - | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \ - | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \ - | am33_2.0 \ - | arc | arceb \ - | arm | arm[bl]e | arme[lb] | armv[2-8] | armv[3-8][lb] | armv7[arm] \ - | avr | avr32 \ - | be32 | be64 \ - | bfin \ - | c4x | c8051 | clipper \ - | d10v | d30v | dlx | dsp16xx \ - | epiphany \ - | fido | fr30 | frv \ - | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \ - | hexagon \ - | i370 | i860 | i960 | ia64 \ - | ip2k | iq2000 \ - | le32 | le64 \ - | lm32 \ - | m32c | m32r | m32rle | m68000 | m68k | m88k \ - | maxq | mb | microblaze | microblazeel | mcore | mep | metag \ - | mips | mipsbe | mipseb | mipsel | mipsle \ - | mips16 \ - | mips64 | mips64el \ - | mips64octeon | mips64octeonel \ - | mips64orion | mips64orionel \ - | mips64r5900 | mips64r5900el \ - | mips64vr | mips64vrel \ - | mips64vr4100 | mips64vr4100el \ - | mips64vr4300 | mips64vr4300el \ - | mips64vr5000 | mips64vr5000el \ - | mips64vr5900 | mips64vr5900el \ - | mipsisa32 | mipsisa32el \ - | mipsisa32r2 | mipsisa32r2el \ - | mipsisa64 | mipsisa64el \ - | mipsisa64r2 | mipsisa64r2el \ - | mipsisa64sb1 | mipsisa64sb1el \ - | mipsisa64sr71k | mipsisa64sr71kel \ - | mipsr5900 | mipsr5900el \ - | mipstx39 | mipstx39el \ - | mn10200 | mn10300 \ - | moxie \ - | mt \ - | msp430 \ - | nds32 | nds32le | nds32be \ - | nios | nios2 | nios2eb | nios2el \ - | ns16k | ns32k \ - | open8 \ - | or1k | or32 \ - | pdp10 | pdp11 | pj | pjl \ - | powerpc | powerpc64 | powerpc64le | powerpcle \ - | pyramid \ - | rl78 | rx \ - | score \ - | sh | sh[1234] | sh[24]a | sh[24]aeb | sh[23]e | sh[34]eb | sheb | shbe | shle | sh[1234]le | sh3ele \ - | sh64 | sh64le \ - | sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet | sparclite \ - | sparcv8 | sparcv9 | sparcv9b | sparcv9v \ - | spu \ - | tahoe | tic4x | tic54x | tic55x | tic6x | tic80 | tron \ - | ubicom32 \ - | v850 | v850e | v850e1 | v850e2 | v850es | v850e2v3 \ - | we32k \ - | x86 | xc16x | xstormy16 | xtensa \ - | z8k | z80) - basic_machine=$basic_machine-unknown - ;; - c54x) - basic_machine=tic54x-unknown - ;; - c55x) - basic_machine=tic55x-unknown - ;; - c6x) - basic_machine=tic6x-unknown - ;; - m6811 | m68hc11 | m6812 | m68hc12 | m68hcs12x | picochip) - basic_machine=$basic_machine-unknown - os=-none - ;; - m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65 | z8k) - ;; - ms1) - basic_machine=mt-unknown - ;; - - strongarm | thumb | xscale) - basic_machine=arm-unknown - ;; - xgate) - basic_machine=$basic_machine-unknown - os=-none - ;; - xscaleeb) - basic_machine=armeb-unknown - ;; - - xscaleel) - basic_machine=armel-unknown - ;; - - # We use `pc' rather than `unknown' - # because (1) that's what they normally are, and - # (2) the word "unknown" tends to confuse beginning users. - i*86 | x86_64) - basic_machine=$basic_machine-pc - ;; - # Object if more than one company name word. - *-*-*) - echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 - exit 1 - ;; - # Recognize the basic CPU types with company name. - 580-* \ - | a29k-* \ - | aarch64-* | aarch64_be-* \ - | alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \ - | alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \ - | alphapca5[67]-* | alpha64pca5[67]-* | arc-* | arceb-* \ - | arm-* | armbe-* | armle-* | armeb-* | armv*-* \ - | avr-* | avr32-* \ - | be32-* | be64-* \ - | bfin-* | bs2000-* \ - | c[123]* | c30-* | [cjt]90-* | c4x-* \ - | c8051-* | clipper-* | craynv-* | cydra-* \ - | d10v-* | d30v-* | dlx-* \ - | elxsi-* \ - | f30[01]-* | f700-* | fido-* | fr30-* | frv-* | fx80-* \ - | h8300-* | h8500-* \ - | hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \ - | hexagon-* \ - | i*86-* | i860-* | i960-* | ia64-* \ - | ip2k-* | iq2000-* \ - | le32-* | le64-* \ - | lm32-* \ - | m32c-* | m32r-* | m32rle-* \ - | m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \ - | m88110-* | m88k-* | maxq-* | mcore-* | metag-* \ - | microblaze-* | microblazeel-* \ - | mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \ - | mips16-* \ - | mips64-* | mips64el-* \ - | mips64octeon-* | mips64octeonel-* \ - | mips64orion-* | mips64orionel-* \ - | mips64r5900-* | mips64r5900el-* \ - | mips64vr-* | mips64vrel-* \ - | mips64vr4100-* | mips64vr4100el-* \ - | mips64vr4300-* | mips64vr4300el-* \ - | mips64vr5000-* | mips64vr5000el-* \ - | mips64vr5900-* | mips64vr5900el-* \ - | mipsisa32-* | mipsisa32el-* \ - | mipsisa32r2-* | mipsisa32r2el-* \ - | mipsisa64-* | mipsisa64el-* \ - | mipsisa64r2-* | mipsisa64r2el-* \ - | mipsisa64sb1-* | mipsisa64sb1el-* \ - | mipsisa64sr71k-* | mipsisa64sr71kel-* \ - | mipsr5900-* | mipsr5900el-* \ - | mipstx39-* | mipstx39el-* \ - | mmix-* \ - | mt-* \ - | msp430-* \ - | nds32-* | nds32le-* | nds32be-* \ - | nios-* | nios2-* | nios2eb-* | nios2el-* \ - | none-* | np1-* | ns16k-* | ns32k-* \ - | open8-* \ - | orion-* \ - | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \ - | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* \ - | pyramid-* \ - | rl78-* | romp-* | rs6000-* | rx-* \ - | sh-* | sh[1234]-* | sh[24]a-* | sh[24]aeb-* | sh[23]e-* | sh[34]eb-* | sheb-* | shbe-* \ - | shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \ - | sparc-* | sparc64-* | sparc64b-* | sparc64v-* | sparc86x-* | sparclet-* \ - | sparclite-* \ - | sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | sv1-* | sx?-* \ - | tahoe-* \ - | tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \ - | tile*-* \ - | tron-* \ - | ubicom32-* \ - | v850-* | v850e-* | v850e1-* | v850es-* | v850e2-* | v850e2v3-* \ - | vax-* \ - | we32k-* \ - | x86-* | x86_64-* | xc16x-* | xps100-* \ - | xstormy16-* | xtensa*-* \ - | ymp-* \ - | z8k-* | z80-*) - ;; - # Recognize the basic CPU types without company name, with glob match. - xtensa*) - basic_machine=$basic_machine-unknown - ;; - # Recognize the various machine names and aliases which stand - # for a CPU type and a company and sometimes even an OS. - 386bsd) - basic_machine=i386-unknown - os=-bsd - ;; - 3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc) - basic_machine=m68000-att - ;; - 3b*) - basic_machine=we32k-att - ;; - a29khif) - basic_machine=a29k-amd - os=-udi - ;; - abacus) - basic_machine=abacus-unknown - ;; - adobe68k) - basic_machine=m68010-adobe - os=-scout - ;; - alliant | fx80) - basic_machine=fx80-alliant - ;; - altos | altos3068) - basic_machine=m68k-altos - ;; - am29k) - basic_machine=a29k-none - os=-bsd - ;; - amd64) - basic_machine=x86_64-pc - ;; - amd64-*) - basic_machine=x86_64-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - amdahl) - basic_machine=580-amdahl - os=-sysv - ;; - amiga | amiga-*) - basic_machine=m68k-unknown - ;; - amigaos | amigados) - basic_machine=m68k-unknown - os=-amigaos - ;; - amigaunix | amix) - basic_machine=m68k-unknown - os=-sysv4 - ;; - apollo68) - basic_machine=m68k-apollo - os=-sysv - ;; - apollo68bsd) - basic_machine=m68k-apollo - os=-bsd - ;; - aros) - basic_machine=i386-pc - os=-aros - ;; - aux) - basic_machine=m68k-apple - os=-aux - ;; - balance) - basic_machine=ns32k-sequent - os=-dynix - ;; - blackfin) - basic_machine=bfin-unknown - os=-linux - ;; - blackfin-*) - basic_machine=bfin-`echo $basic_machine | sed 's/^[^-]*-//'` - os=-linux - ;; - bluegene*) - basic_machine=powerpc-ibm - os=-cnk - ;; - c54x-*) - basic_machine=tic54x-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - c55x-*) - basic_machine=tic55x-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - c6x-*) - basic_machine=tic6x-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - c90) - basic_machine=c90-cray - os=-unicos - ;; - cegcc) - basic_machine=arm-unknown - os=-cegcc - ;; - convex-c1) - basic_machine=c1-convex - os=-bsd - ;; - convex-c2) - basic_machine=c2-convex - os=-bsd - ;; - convex-c32) - basic_machine=c32-convex - os=-bsd - ;; - convex-c34) - basic_machine=c34-convex - os=-bsd - ;; - convex-c38) - basic_machine=c38-convex - os=-bsd - ;; - cray | j90) - basic_machine=j90-cray - os=-unicos - ;; - craynv) - basic_machine=craynv-cray - os=-unicosmp - ;; - cr16 | cr16-*) - basic_machine=cr16-unknown - os=-elf - ;; - crds | unos) - basic_machine=m68k-crds - ;; - crisv32 | crisv32-* | etraxfs*) - basic_machine=crisv32-axis - ;; - cris | cris-* | etrax*) - basic_machine=cris-axis - ;; - crx) - basic_machine=crx-unknown - os=-elf - ;; - da30 | da30-*) - basic_machine=m68k-da30 - ;; - decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn) - basic_machine=mips-dec - ;; - decsystem10* | dec10*) - basic_machine=pdp10-dec - os=-tops10 - ;; - decsystem20* | dec20*) - basic_machine=pdp10-dec - os=-tops20 - ;; - delta | 3300 | motorola-3300 | motorola-delta \ - | 3300-motorola | delta-motorola) - basic_machine=m68k-motorola - ;; - delta88) - basic_machine=m88k-motorola - os=-sysv3 - ;; - dicos) - basic_machine=i686-pc - os=-dicos - ;; - djgpp) - basic_machine=i586-pc - os=-msdosdjgpp - ;; - dpx20 | dpx20-*) - basic_machine=rs6000-bull - os=-bosx - ;; - dpx2* | dpx2*-bull) - basic_machine=m68k-bull - os=-sysv3 - ;; - ebmon29k) - basic_machine=a29k-amd - os=-ebmon - ;; - elxsi) - basic_machine=elxsi-elxsi - os=-bsd - ;; - encore | umax | mmax) - basic_machine=ns32k-encore - ;; - es1800 | OSE68k | ose68k | ose | OSE) - basic_machine=m68k-ericsson - os=-ose - ;; - fx2800) - basic_machine=i860-alliant - ;; - genix) - basic_machine=ns32k-ns - ;; - gmicro) - basic_machine=tron-gmicro - os=-sysv - ;; - go32) - basic_machine=i386-pc - os=-go32 - ;; - h3050r* | hiux*) - basic_machine=hppa1.1-hitachi - os=-hiuxwe2 - ;; - h8300hms) - basic_machine=h8300-hitachi - os=-hms - ;; - h8300xray) - basic_machine=h8300-hitachi - os=-xray - ;; - h8500hms) - basic_machine=h8500-hitachi - os=-hms - ;; - harris) - basic_machine=m88k-harris - os=-sysv3 - ;; - hp300-*) - basic_machine=m68k-hp - ;; - hp300bsd) - basic_machine=m68k-hp - os=-bsd - ;; - hp300hpux) - basic_machine=m68k-hp - os=-hpux - ;; - hp3k9[0-9][0-9] | hp9[0-9][0-9]) - basic_machine=hppa1.0-hp - ;; - hp9k2[0-9][0-9] | hp9k31[0-9]) - basic_machine=m68000-hp - ;; - hp9k3[2-9][0-9]) - basic_machine=m68k-hp - ;; - hp9k6[0-9][0-9] | hp6[0-9][0-9]) - basic_machine=hppa1.0-hp - ;; - hp9k7[0-79][0-9] | hp7[0-79][0-9]) - basic_machine=hppa1.1-hp - ;; - hp9k78[0-9] | hp78[0-9]) - # FIXME: really hppa2.0-hp - basic_machine=hppa1.1-hp - ;; - hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893) - # FIXME: really hppa2.0-hp - basic_machine=hppa1.1-hp - ;; - hp9k8[0-9][13679] | hp8[0-9][13679]) - basic_machine=hppa1.1-hp - ;; - hp9k8[0-9][0-9] | hp8[0-9][0-9]) - basic_machine=hppa1.0-hp - ;; - hppa-next) - os=-nextstep3 - ;; - hppaosf) - basic_machine=hppa1.1-hp - os=-osf - ;; - hppro) - basic_machine=hppa1.1-hp - os=-proelf - ;; - i370-ibm* | ibm*) - basic_machine=i370-ibm - ;; - i*86v32) - basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` - os=-sysv32 - ;; - i*86v4*) - basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` - os=-sysv4 - ;; - i*86v) - basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` - os=-sysv - ;; - i*86sol2) - basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` - os=-solaris2 - ;; - i386mach) - basic_machine=i386-mach - os=-mach - ;; - i386-vsta | vsta) - basic_machine=i386-unknown - os=-vsta - ;; - iris | iris4d) - basic_machine=mips-sgi - case $os in - -irix*) - ;; - *) - os=-irix4 - ;; - esac - ;; - isi68 | isi) - basic_machine=m68k-isi - os=-sysv - ;; - m68knommu) - basic_machine=m68k-unknown - os=-linux - ;; - m68knommu-*) - basic_machine=m68k-`echo $basic_machine | sed 's/^[^-]*-//'` - os=-linux - ;; - m88k-omron*) - basic_machine=m88k-omron - ;; - magnum | m3230) - basic_machine=mips-mips - os=-sysv - ;; - merlin) - basic_machine=ns32k-utek - os=-sysv - ;; - microblaze*) - basic_machine=microblaze-xilinx - ;; - mingw64) - basic_machine=x86_64-pc - os=-mingw64 - ;; - mingw32) - basic_machine=i686-pc - os=-mingw32 - ;; - mingw32ce) - basic_machine=arm-unknown - os=-mingw32ce - ;; - miniframe) - basic_machine=m68000-convergent - ;; - *mint | -mint[0-9]* | *MiNT | *MiNT[0-9]*) - basic_machine=m68k-atari - os=-mint - ;; - mips3*-*) - basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'` - ;; - mips3*) - basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown - ;; - monitor) - basic_machine=m68k-rom68k - os=-coff - ;; - morphos) - basic_machine=powerpc-unknown - os=-morphos - ;; - msdos) - basic_machine=i386-pc - os=-msdos - ;; - ms1-*) - basic_machine=`echo $basic_machine | sed -e 's/ms1-/mt-/'` - ;; - msys) - basic_machine=i686-pc - os=-msys - ;; - mvs) - basic_machine=i370-ibm - os=-mvs - ;; - nacl) - basic_machine=le32-unknown - os=-nacl - ;; - ncr3000) - basic_machine=i486-ncr - os=-sysv4 - ;; - netbsd386) - basic_machine=i386-unknown - os=-netbsd - ;; - netwinder) - basic_machine=armv4l-rebel - os=-linux - ;; - news | news700 | news800 | news900) - basic_machine=m68k-sony - os=-newsos - ;; - news1000) - basic_machine=m68030-sony - os=-newsos - ;; - news-3600 | risc-news) - basic_machine=mips-sony - os=-newsos - ;; - necv70) - basic_machine=v70-nec - os=-sysv - ;; - next | m*-next ) - basic_machine=m68k-next - case $os in - -nextstep* ) - ;; - -ns2*) - os=-nextstep2 - ;; - *) - os=-nextstep3 - ;; - esac - ;; - nh3000) - basic_machine=m68k-harris - os=-cxux - ;; - nh[45]000) - basic_machine=m88k-harris - os=-cxux - ;; - nindy960) - basic_machine=i960-intel - os=-nindy - ;; - mon960) - basic_machine=i960-intel - os=-mon960 - ;; - nonstopux) - basic_machine=mips-compaq - os=-nonstopux - ;; - np1) - basic_machine=np1-gould - ;; - neo-tandem) - basic_machine=neo-tandem - ;; - nse-tandem) - basic_machine=nse-tandem - ;; - nsr-tandem) - basic_machine=nsr-tandem - ;; - op50n-* | op60c-*) - basic_machine=hppa1.1-oki - os=-proelf - ;; - openrisc | openrisc-*) - basic_machine=or32-unknown - ;; - os400) - basic_machine=powerpc-ibm - os=-os400 - ;; - OSE68000 | ose68000) - basic_machine=m68000-ericsson - os=-ose - ;; - os68k) - basic_machine=m68k-none - os=-os68k - ;; - pa-hitachi) - basic_machine=hppa1.1-hitachi - os=-hiuxwe2 - ;; - paragon) - basic_machine=i860-intel - os=-osf - ;; - parisc) - basic_machine=hppa-unknown - os=-linux - ;; - parisc-*) - basic_machine=hppa-`echo $basic_machine | sed 's/^[^-]*-//'` - os=-linux - ;; - pbd) - basic_machine=sparc-tti - ;; - pbb) - basic_machine=m68k-tti - ;; - pc532 | pc532-*) - basic_machine=ns32k-pc532 - ;; - pc98) - basic_machine=i386-pc - ;; - pc98-*) - basic_machine=i386-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - pentium | p5 | k5 | k6 | nexgen | viac3) - basic_machine=i586-pc - ;; - pentiumpro | p6 | 6x86 | athlon | athlon_*) - basic_machine=i686-pc - ;; - pentiumii | pentium2 | pentiumiii | pentium3) - basic_machine=i686-pc - ;; - pentium4) - basic_machine=i786-pc - ;; - pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*) - basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - pentiumpro-* | p6-* | 6x86-* | athlon-*) - basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*) - basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - pentium4-*) - basic_machine=i786-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - pn) - basic_machine=pn-gould - ;; - power) basic_machine=power-ibm - ;; - ppc | ppcbe) basic_machine=powerpc-unknown - ;; - ppc-* | ppcbe-*) - basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - ppcle | powerpclittle | ppc-le | powerpc-little) - basic_machine=powerpcle-unknown - ;; - ppcle-* | powerpclittle-*) - basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - ppc64) basic_machine=powerpc64-unknown - ;; - ppc64-*) basic_machine=powerpc64-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - ppc64le | powerpc64little | ppc64-le | powerpc64-little) - basic_machine=powerpc64le-unknown - ;; - ppc64le-* | powerpc64little-*) - basic_machine=powerpc64le-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - ps2) - basic_machine=i386-ibm - ;; - pw32) - basic_machine=i586-unknown - os=-pw32 - ;; - rdos | rdos64) - basic_machine=x86_64-pc - os=-rdos - ;; - rdos32) - basic_machine=i386-pc - os=-rdos - ;; - rom68k) - basic_machine=m68k-rom68k - os=-coff - ;; - rm[46]00) - basic_machine=mips-siemens - ;; - rtpc | rtpc-*) - basic_machine=romp-ibm - ;; - s390 | s390-*) - basic_machine=s390-ibm - ;; - s390x | s390x-*) - basic_machine=s390x-ibm - ;; - sa29200) - basic_machine=a29k-amd - os=-udi - ;; - sb1) - basic_machine=mipsisa64sb1-unknown - ;; - sb1el) - basic_machine=mipsisa64sb1el-unknown - ;; - sde) - basic_machine=mipsisa32-sde - os=-elf - ;; - sei) - basic_machine=mips-sei - os=-seiux - ;; - sequent) - basic_machine=i386-sequent - ;; - sh) - basic_machine=sh-hitachi - os=-hms - ;; - sh5el) - basic_machine=sh5le-unknown - ;; - sh64) - basic_machine=sh64-unknown - ;; - sparclite-wrs | simso-wrs) - basic_machine=sparclite-wrs - os=-vxworks - ;; - sps7) - basic_machine=m68k-bull - os=-sysv2 - ;; - spur) - basic_machine=spur-unknown - ;; - st2000) - basic_machine=m68k-tandem - ;; - stratus) - basic_machine=i860-stratus - os=-sysv4 - ;; - strongarm-* | thumb-*) - basic_machine=arm-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - sun2) - basic_machine=m68000-sun - ;; - sun2os3) - basic_machine=m68000-sun - os=-sunos3 - ;; - sun2os4) - basic_machine=m68000-sun - os=-sunos4 - ;; - sun3os3) - basic_machine=m68k-sun - os=-sunos3 - ;; - sun3os4) - basic_machine=m68k-sun - os=-sunos4 - ;; - sun4os3) - basic_machine=sparc-sun - os=-sunos3 - ;; - sun4os4) - basic_machine=sparc-sun - os=-sunos4 - ;; - sun4sol2) - basic_machine=sparc-sun - os=-solaris2 - ;; - sun3 | sun3-*) - basic_machine=m68k-sun - ;; - sun4) - basic_machine=sparc-sun - ;; - sun386 | sun386i | roadrunner) - basic_machine=i386-sun - ;; - sv1) - basic_machine=sv1-cray - os=-unicos - ;; - symmetry) - basic_machine=i386-sequent - os=-dynix - ;; - t3e) - basic_machine=alphaev5-cray - os=-unicos - ;; - t90) - basic_machine=t90-cray - os=-unicos - ;; - tile*) - basic_machine=$basic_machine-unknown - os=-linux-gnu - ;; - tx39) - basic_machine=mipstx39-unknown - ;; - tx39el) - basic_machine=mipstx39el-unknown - ;; - toad1) - basic_machine=pdp10-xkl - os=-tops20 - ;; - tower | tower-32) - basic_machine=m68k-ncr - ;; - tpf) - basic_machine=s390x-ibm - os=-tpf - ;; - udi29k) - basic_machine=a29k-amd - os=-udi - ;; - ultra3) - basic_machine=a29k-nyu - os=-sym1 - ;; - v810 | necv810) - basic_machine=v810-nec - os=-none - ;; - vaxv) - basic_machine=vax-dec - os=-sysv - ;; - vms) - basic_machine=vax-dec - os=-vms - ;; - vpp*|vx|vx-*) - basic_machine=f301-fujitsu - ;; - vxworks960) - basic_machine=i960-wrs - os=-vxworks - ;; - vxworks68) - basic_machine=m68k-wrs - os=-vxworks - ;; - vxworks29k) - basic_machine=a29k-wrs - os=-vxworks - ;; - w65*) - basic_machine=w65-wdc - os=-none - ;; - w89k-*) - basic_machine=hppa1.1-winbond - os=-proelf - ;; - xbox) - basic_machine=i686-pc - os=-mingw32 - ;; - xps | xps100) - basic_machine=xps100-honeywell - ;; - xscale-* | xscalee[bl]-*) - basic_machine=`echo $basic_machine | sed 's/^xscale/arm/'` - ;; - ymp) - basic_machine=ymp-cray - os=-unicos - ;; - z8k-*-coff) - basic_machine=z8k-unknown - os=-sim - ;; - z80-*-coff) - basic_machine=z80-unknown - os=-sim - ;; - none) - basic_machine=none-none - os=-none - ;; - -# Here we handle the default manufacturer of certain CPU types. It is in -# some cases the only manufacturer, in others, it is the most popular. - w89k) - basic_machine=hppa1.1-winbond - ;; - op50n) - basic_machine=hppa1.1-oki - ;; - op60c) - basic_machine=hppa1.1-oki - ;; - romp) - basic_machine=romp-ibm - ;; - mmix) - basic_machine=mmix-knuth - ;; - rs6000) - basic_machine=rs6000-ibm - ;; - vax) - basic_machine=vax-dec - ;; - pdp10) - # there are many clones, so DEC is not a safe bet - basic_machine=pdp10-unknown - ;; - pdp11) - basic_machine=pdp11-dec - ;; - we32k) - basic_machine=we32k-att - ;; - sh[1234] | sh[24]a | sh[24]aeb | sh[34]eb | sh[1234]le | sh[23]ele) - basic_machine=sh-unknown - ;; - sparc | sparcv8 | sparcv9 | sparcv9b | sparcv9v) - basic_machine=sparc-sun - ;; - cydra) - basic_machine=cydra-cydrome - ;; - orion) - basic_machine=orion-highlevel - ;; - orion105) - basic_machine=clipper-highlevel - ;; - mac | mpw | mac-mpw) - basic_machine=m68k-apple - ;; - pmac | pmac-mpw) - basic_machine=powerpc-apple - ;; - *-unknown) - # Make sure to match an already-canonicalized machine name. - ;; - *) - echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 - exit 1 - ;; -esac - -# Here we canonicalize certain aliases for manufacturers. -case $basic_machine in - *-digital*) - basic_machine=`echo $basic_machine | sed 's/digital.*/dec/'` - ;; - *-commodore*) - basic_machine=`echo $basic_machine | sed 's/commodore.*/cbm/'` - ;; - *) - ;; -esac - -# Decode manufacturer-specific aliases for certain operating systems. - -if [ x"$os" != x"" ] -then -case $os in - # First match some system type aliases - # that might get confused with valid system types. - # -solaris* is a basic system type, with this one exception. - -auroraux) - os=-auroraux - ;; - -solaris1 | -solaris1.*) - os=`echo $os | sed -e 's|solaris1|sunos4|'` - ;; - -solaris) - os=-solaris2 - ;; - -svr4*) - os=-sysv4 - ;; - -unixware*) - os=-sysv4.2uw - ;; - -gnu/linux*) - os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'` - ;; - # First accept the basic system types. - # The portable systems comes first. - # Each alternative MUST END IN A *, to match a version number. - # -sysv* is not here because it comes later, after sysvr4. - -gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \ - | -*vms* | -sco* | -esix* | -isc* | -aix* | -cnk* | -sunos | -sunos[34]*\ - | -hpux* | -unos* | -osf* | -luna* | -dgux* | -auroraux* | -solaris* \ - | -sym* | -kopensolaris* | -plan9* \ - | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \ - | -aos* | -aros* \ - | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ - | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ - | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \ - | -bitrig* | -openbsd* | -solidbsd* \ - | -ekkobsd* | -kfreebsd* | -freebsd* | -riscix* | -lynxos* \ - | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \ - | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \ - | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \ - | -chorusos* | -chorusrdb* | -cegcc* \ - | -cygwin* | -msys* | -pe* | -psos* | -moss* | -proelf* | -rtems* \ - | -mingw32* | -mingw64* | -linux-gnu* | -linux-android* \ - | -linux-newlib* | -linux-musl* | -linux-uclibc* \ - | -uxpv* | -beos* | -mpeix* | -udk* \ - | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \ - | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \ - | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \ - | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \ - | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \ - | -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \ - | -skyos* | -haiku* | -rdos* | -toppers* | -drops* | -es*) - # Remember, each alternative MUST END IN *, to match a version number. - ;; - -qnx*) - case $basic_machine in - x86-* | i*86-*) - ;; - *) - os=-nto$os - ;; - esac - ;; - -nto-qnx*) - ;; - -nto*) - os=`echo $os | sed -e 's|nto|nto-qnx|'` - ;; - -sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \ - | -windows* | -osx | -abug | -netware* | -os9* | -beos* | -haiku* \ - | -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*) - ;; - -mac*) - os=`echo $os | sed -e 's|mac|macos|'` - ;; - -linux-dietlibc) - os=-linux-dietlibc - ;; - -linux*) - os=`echo $os | sed -e 's|linux|linux-gnu|'` - ;; - -sunos5*) - os=`echo $os | sed -e 's|sunos5|solaris2|'` - ;; - -sunos6*) - os=`echo $os | sed -e 's|sunos6|solaris3|'` - ;; - -opened*) - os=-openedition - ;; - -os400*) - os=-os400 - ;; - -wince*) - os=-wince - ;; - -osfrose*) - os=-osfrose - ;; - -osf*) - os=-osf - ;; - -utek*) - os=-bsd - ;; - -dynix*) - os=-bsd - ;; - -acis*) - os=-aos - ;; - -atheos*) - os=-atheos - ;; - -syllable*) - os=-syllable - ;; - -386bsd) - os=-bsd - ;; - -ctix* | -uts*) - os=-sysv - ;; - -nova*) - os=-rtmk-nova - ;; - -ns2 ) - os=-nextstep2 - ;; - -nsk*) - os=-nsk - ;; - # Preserve the version number of sinix5. - -sinix5.*) - os=`echo $os | sed -e 's|sinix|sysv|'` - ;; - -sinix*) - os=-sysv4 - ;; - -tpf*) - os=-tpf - ;; - -triton*) - os=-sysv3 - ;; - -oss*) - os=-sysv3 - ;; - -svr4) - os=-sysv4 - ;; - -svr3) - os=-sysv3 - ;; - -sysvr4) - os=-sysv4 - ;; - # This must come after -sysvr4. - -sysv*) - ;; - -ose*) - os=-ose - ;; - -es1800*) - os=-ose - ;; - -xenix) - os=-xenix - ;; - -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) - os=-mint - ;; - -aros*) - os=-aros - ;; - -zvmoe) - os=-zvmoe - ;; - -dicos*) - os=-dicos - ;; - -nacl*) - ;; - -none) - ;; - *) - # Get rid of the `-' at the beginning of $os. - os=`echo $os | sed 's/[^-]*-//'` - echo Invalid configuration \`$1\': system \`$os\' not recognized 1>&2 - exit 1 - ;; -esac -else - -# Here we handle the default operating systems that come with various machines. -# The value should be what the vendor currently ships out the door with their -# machine or put another way, the most popular os provided with the machine. - -# Note that if you're going to try to match "-MANUFACTURER" here (say, -# "-sun"), then you have to tell the case statement up towards the top -# that MANUFACTURER isn't an operating system. Otherwise, code above -# will signal an error saying that MANUFACTURER isn't an operating -# system, and we'll never get to this point. - -case $basic_machine in - score-*) - os=-elf - ;; - spu-*) - os=-elf - ;; - *-acorn) - os=-riscix1.2 - ;; - arm*-rebel) - os=-linux - ;; - arm*-semi) - os=-aout - ;; - c4x-* | tic4x-*) - os=-coff - ;; - c8051-*) - os=-elf - ;; - hexagon-*) - os=-elf - ;; - tic54x-*) - os=-coff - ;; - tic55x-*) - os=-coff - ;; - tic6x-*) - os=-coff - ;; - # This must come before the *-dec entry. - pdp10-*) - os=-tops20 - ;; - pdp11-*) - os=-none - ;; - *-dec | vax-*) - os=-ultrix4.2 - ;; - m68*-apollo) - os=-domain - ;; - i386-sun) - os=-sunos4.0.2 - ;; - m68000-sun) - os=-sunos3 - ;; - m68*-cisco) - os=-aout - ;; - mep-*) - os=-elf - ;; - mips*-cisco) - os=-elf - ;; - mips*-*) - os=-elf - ;; - or1k-*) - os=-elf - ;; - or32-*) - os=-coff - ;; - *-tti) # must be before sparc entry or we get the wrong os. - os=-sysv3 - ;; - sparc-* | *-sun) - os=-sunos4.1.1 - ;; - *-be) - os=-beos - ;; - *-haiku) - os=-haiku - ;; - *-ibm) - os=-aix - ;; - *-knuth) - os=-mmixware - ;; - *-wec) - os=-proelf - ;; - *-winbond) - os=-proelf - ;; - *-oki) - os=-proelf - ;; - *-hp) - os=-hpux - ;; - *-hitachi) - os=-hiux - ;; - i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent) - os=-sysv - ;; - *-cbm) - os=-amigaos - ;; - *-dg) - os=-dgux - ;; - *-dolphin) - os=-sysv3 - ;; - m68k-ccur) - os=-rtu - ;; - m88k-omron*) - os=-luna - ;; - *-next ) - os=-nextstep - ;; - *-sequent) - os=-ptx - ;; - *-crds) - os=-unos - ;; - *-ns) - os=-genix - ;; - i370-*) - os=-mvs - ;; - *-next) - os=-nextstep3 - ;; - *-gould) - os=-sysv - ;; - *-highlevel) - os=-bsd - ;; - *-encore) - os=-bsd - ;; - *-sgi) - os=-irix - ;; - *-siemens) - os=-sysv4 - ;; - *-masscomp) - os=-rtu - ;; - f30[01]-fujitsu | f700-fujitsu) - os=-uxpv - ;; - *-rom68k) - os=-coff - ;; - *-*bug) - os=-coff - ;; - *-apple) - os=-macos - ;; - *-atari*) - os=-mint - ;; - *) - os=-none - ;; -esac -fi - -# Here we handle the case where we know the os, and the CPU type, but not the -# manufacturer. We pick the logical manufacturer. -vendor=unknown -case $basic_machine in - *-unknown) - case $os in - -riscix*) - vendor=acorn - ;; - -sunos*) - vendor=sun - ;; - -cnk*|-aix*) - vendor=ibm - ;; - -beos*) - vendor=be - ;; - -hpux*) - vendor=hp - ;; - -mpeix*) - vendor=hp - ;; - -hiux*) - vendor=hitachi - ;; - -unos*) - vendor=crds - ;; - -dgux*) - vendor=dg - ;; - -luna*) - vendor=omron - ;; - -genix*) - vendor=ns - ;; - -mvs* | -opened*) - vendor=ibm - ;; - -os400*) - vendor=ibm - ;; - -ptx*) - vendor=sequent - ;; - -tpf*) - vendor=ibm - ;; - -vxsim* | -vxworks* | -windiss*) - vendor=wrs - ;; - -aux*) - vendor=apple - ;; - -hms*) - vendor=hitachi - ;; - -mpw* | -macos*) - vendor=apple - ;; - -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) - vendor=atari - ;; - -vos*) - vendor=stratus - ;; - esac - basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"` - ;; -esac - -echo $basic_machine$os -exit - -# Local variables: -# eval: (add-hook 'write-file-hooks 'time-stamp) -# time-stamp-start: "timestamp='" -# time-stamp-format: "%:y-%02m-%02d" -# time-stamp-end: "'" -# End: diff -r 9cd3ab7c09d1 -r 9ac347a7f375 configure --- a/configure Sat Jul 19 16:34:33 2014 -0700 +++ b/configure Sun Jul 20 10:52:46 2014 -0400 @@ -1,12 +1,14 @@ #! /bin/sh -# From configure.ac Revision. +# From configure.in Revision. # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.69 for python 2.7. +# Generated by GNU Autoconf 2.67 for python 2.7. # # Report bugs to . # # -# Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc. +# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, +# 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software +# Foundation, Inc. # # # This configure script is free software; the Free Software Foundation @@ -90,7 +92,6 @@ IFS=" "" $as_nl" # Find who we are. Look in the path if we contain no directory separator. -as_myself= case $0 in #(( *[\\/]* ) as_myself=$0 ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR @@ -135,31 +136,6 @@ # CDPATH. (unset CDPATH) >/dev/null 2>&1 && unset CDPATH -# Use a proper internal environment variable to ensure we don't fall - # into an infinite loop, continuously re-executing ourselves. - if test x"${_as_can_reexec}" != xno && test "x$CONFIG_SHELL" != x; then - _as_can_reexec=no; export _as_can_reexec; - # We cannot yet assume a decent shell, so we have to provide a -# neutralization value for shells without unset; and this also -# works around shells that cannot unset nonexistent variables. -# Preserve -v and -x to the replacement shell. -BASH_ENV=/dev/null -ENV=/dev/null -(unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV -case $- in # (((( - *v*x* | *x*v* ) as_opts=-vx ;; - *v* ) as_opts=-v ;; - *x* ) as_opts=-x ;; - * ) as_opts= ;; -esac -exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"} -# Admittedly, this is quite paranoid, since all the known shells bail -# out after a failed `exec'. -$as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2 -as_fn_exit 255 - fi - # We don't want this to propagate to other subprocesses. - { _as_can_reexec=; unset _as_can_reexec;} if test "x$CONFIG_SHELL" = x; then as_bourne_compatible="if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then : emulate sh @@ -193,8 +169,7 @@ else exitcode=1; echo positional parameters were not saved. fi -test x\$exitcode = x0 || exit 1 -test -x / || exit 1" +test x\$exitcode = x0 || exit 1" as_suggested=" as_lineno_1=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_1a=\$LINENO as_lineno_2=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_2a=\$LINENO eval 'test \"x\$as_lineno_1'\$as_run'\" != \"x\$as_lineno_2'\$as_run'\" && @@ -239,25 +214,14 @@ if test "x$CONFIG_SHELL" != x; then : - export CONFIG_SHELL - # We cannot yet assume a decent shell, so we have to provide a -# neutralization value for shells without unset; and this also -# works around shells that cannot unset nonexistent variables. -# Preserve -v and -x to the replacement shell. -BASH_ENV=/dev/null -ENV=/dev/null -(unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV -case $- in # (((( - *v*x* | *x*v* ) as_opts=-vx ;; - *v* ) as_opts=-v ;; - *x* ) as_opts=-x ;; - * ) as_opts= ;; -esac -exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"} -# Admittedly, this is quite paranoid, since all the known shells bail -# out after a failed `exec'. -$as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2 -exit 255 + # We cannot yet assume a decent shell, so we have to provide a + # neutralization value for shells without unset; and this also + # works around shells that cannot unset nonexistent variables. + BASH_ENV=/dev/null + ENV=/dev/null + (unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV + export CONFIG_SHELL + exec "$CONFIG_SHELL" "$as_myself" ${1+"$@"} fi if test x$as_have_required = xno; then : @@ -360,14 +324,6 @@ } # as_fn_mkdir_p - -# as_fn_executable_p FILE -# ----------------------- -# Test if FILE is an executable regular file. -as_fn_executable_p () -{ - test -f "$1" && test -x "$1" -} # as_fn_executable_p # as_fn_append VAR VALUE # ---------------------- # Append the text in VALUE to the end of the definition contained in VAR. Take @@ -489,10 +445,6 @@ chmod +x "$as_me.lineno" || { $as_echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2; as_fn_exit 1; } - # If we had to re-execute with $CONFIG_SHELL, we're ensured to have - # already done that, so ensure we don't try to do so again and fall - # in an infinite loop. This has already happened in practice. - _as_can_reexec=no; export _as_can_reexec # Don't try to exec as it changes $[0], causing all sort of problems # (the dirname of $[0] is not the place where we might find the # original and so on. Autoconf is especially sensitive to this). @@ -527,16 +479,16 @@ # ... but there are two gotchas: # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. - # In both cases, we have to default to `cp -pR'. + # In both cases, we have to default to `cp -p'. ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || - as_ln_s='cp -pR' + as_ln_s='cp -p' elif ln conf$$.file conf$$ 2>/dev/null; then as_ln_s=ln else - as_ln_s='cp -pR' - fi -else - as_ln_s='cp -pR' + as_ln_s='cp -p' + fi +else + as_ln_s='cp -p' fi rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file rmdir conf$$.dir 2>/dev/null @@ -548,8 +500,28 @@ as_mkdir_p=false fi -as_test_x='test -x' -as_executable_p=as_fn_executable_p +if test -x / >/dev/null 2>&1; then + as_test_x='test -x' +else + if ls -dL / >/dev/null 2>&1; then + as_ls_L_option=L + else + as_ls_L_option= + fi + as_test_x=' + eval sh -c '\'' + if test -d "$1"; then + test -d "$1/."; + else + case $1 in #( + -*)set "./$1";; + esac; + case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in #(( + ???[sx]*):;;*)false;;esac;fi + '\'' sh + ' +fi +as_executable_p=$as_test_x # Sed expression to map a string onto a valid CPP name. as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" @@ -644,8 +616,6 @@ USE_THREAD_MODULE SIGNAL_OBJS USE_SIGNAL_MODULE -TCLTK_LIBS -TCLTK_INCLUDES LIBFFI_INCLUDEDIR PKG_CONFIG SHLIBS @@ -662,7 +632,6 @@ BASECFLAGS OPT LN -MKDIR_P INSTALL_DATA INSTALL_SCRIPT INSTALL_PROGRAM @@ -670,10 +639,8 @@ HGBRANCH HGTAG HGVERSION -BASECPPFLAGS SVNVERSION ARFLAGS -ac_ct_AR AR RANLIB GNULD @@ -689,8 +656,6 @@ EGREP GREP CPP -MULTIARCH -ac_ct_CXX MAINCC CXX OBJEXT @@ -705,7 +670,6 @@ EXTRAMACHDEPPATH EXTRAPLATDIR SGI_ABI -_PYTHON_HOST_PLATFORM MACHDEP FRAMEWORKINSTALLAPPSPREFIX FRAMEWORKUNIXTOOLSPREFIX @@ -724,15 +688,6 @@ CONFIG_ARGS SOVERSION VERSION -PYTHON_FOR_BUILD -host_os -host_vendor -host_cpu -host -build_os -build_vendor -build_cpu -build target_alias host_alias build_alias @@ -788,8 +743,6 @@ with_libs with_system_expat with_system_ffi -with_tcltk_includes -with_tcltk_libs with_dbmliborder with_signal_module with_dec_threads @@ -1221,7 +1174,7 @@ $as_echo "$as_me: WARNING: you should use --build, --host, --target" >&2 expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null && $as_echo "$as_me: WARNING: invalid host type: $ac_option" >&2 - : "${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option}" + : ${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option} ;; esac @@ -1272,6 +1225,8 @@ if test "x$host_alias" != x; then if test "x$build_alias" = x; then cross_compiling=maybe + $as_echo "$as_me: WARNING: if you wanted to set the --build type, don't use --host. + If a cross compiler is detected then cross compile mode will be used" >&2 elif test "x$build_alias" != "x$host_alias"; then cross_compiling=yes fi @@ -1413,10 +1368,6 @@ _ACEOF cat <<\_ACEOF - -System types: - --build=BUILD configure for building on BUILD [guessed] - --host=HOST cross-compile to build programs to run on HOST [BUILD] _ACEOF fi @@ -1463,10 +1414,6 @@ --with-system-expat build pyexpat module using an installed expat library --with-system-ffi build _ctypes module using an installed ffi library - --with-tcltk-includes='-I...' - override search for Tcl and Tk include files - --with-tcltk-libs='-L...' - override search for Tcl and Tk libs --with-dbmliborder=db1:db2:... order to check db backends for dbm. Valid value is a colon separated string with the backend names @@ -1564,9 +1511,9 @@ if $ac_init_version; then cat <<\_ACEOF python configure 2.7 -generated by GNU Autoconf 2.69 - -Copyright (C) 2012 Free Software Foundation, Inc. +generated by GNU Autoconf 2.67 + +Copyright (C) 2010 Free Software Foundation, Inc. This configure script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it. _ACEOF @@ -1610,7 +1557,7 @@ ac_retval=1 fi - eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} as_fn_set_status $ac_retval } # ac_fn_c_try_compile @@ -1647,7 +1594,7 @@ ac_retval=1 fi - eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} as_fn_set_status $ac_retval } # ac_fn_c_try_cpp @@ -1660,10 +1607,10 @@ ac_fn_c_check_header_mongrel () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - if eval \${$3+:} false; then : + if eval "test \"\${$3+set}\"" = set; then : { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } -if eval \${$3+:} false; then : +if eval "test \"\${$3+set}\"" = set; then : $as_echo_n "(cached) " >&6 fi eval ac_res=\$$3 @@ -1730,7 +1677,7 @@ esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } -if eval \${$3+:} false; then : +if eval "test \"\${$3+set}\"" = set; then : $as_echo_n "(cached) " >&6 else eval "$3=\$ac_header_compiler" @@ -1739,7 +1686,7 @@ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } fi - eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} } # ac_fn_c_check_header_mongrel @@ -1780,7 +1727,7 @@ ac_retval=$ac_status fi rm -rf conftest.dSYM conftest_ipa8_conftest.oo - eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} as_fn_set_status $ac_retval } # ac_fn_c_try_run @@ -1794,7 +1741,7 @@ as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } -if eval \${$3+:} false; then : +if eval "test \"\${$3+set}\"" = set; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext @@ -1812,7 +1759,7 @@ eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } - eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} } # ac_fn_c_check_header_compile @@ -1843,7 +1790,7 @@ test ! -s conftest.err } && test -s conftest$ac_exeext && { test "$cross_compiling" = yes || - test -x conftest$ac_exeext + $as_test_x conftest$ac_exeext }; then : ac_retval=0 else @@ -1857,7 +1804,7 @@ # interfere with the next link command; also delete a directory that is # left behind by Apple's compiler. We do this before executing the actions. rm -rf conftest.dSYM conftest_ipa8_conftest.oo - eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} as_fn_set_status $ac_retval } # ac_fn_c_try_link @@ -1871,7 +1818,7 @@ as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } -if eval \${$3+:} false; then : +if eval "test \"\${$3+set}\"" = set; then : $as_echo_n "(cached) " >&6 else eval "$3=no" @@ -1912,7 +1859,7 @@ eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } - eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} } # ac_fn_c_check_type @@ -1925,7 +1872,7 @@ as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack { $as_echo "$as_me:${as_lineno-$LINENO}: checking for uint$2_t" >&5 $as_echo_n "checking for uint$2_t... " >&6; } -if eval \${$3+:} false; then : +if eval "test \"\${$3+set}\"" = set; then : $as_echo_n "(cached) " >&6 else eval "$3=no" @@ -1940,8 +1887,7 @@ main () { static int test_array [1 - 2 * !((($ac_type) -1 >> ($2 / 2 - 1)) >> ($2 / 2 - 1) == 3)]; -test_array [0] = 0; -return test_array [0]; +test_array [0] = 0 ; return 0; @@ -1966,7 +1912,7 @@ eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } - eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} } # ac_fn_c_find_uintX_t @@ -1979,7 +1925,7 @@ as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack { $as_echo "$as_me:${as_lineno-$LINENO}: checking for int$2_t" >&5 $as_echo_n "checking for int$2_t... " >&6; } -if eval \${$3+:} false; then : +if eval "test \"\${$3+set}\"" = set; then : $as_echo_n "(cached) " >&6 else eval "$3=no" @@ -1995,8 +1941,7 @@ main () { static int test_array [1 - 2 * !(0 < ($ac_type) ((((($ac_type) 1 << N) << N) - 1) * 2 + 1))]; -test_array [0] = 0; -return test_array [0]; +test_array [0] = 0 ; return 0; @@ -2012,8 +1957,7 @@ { static int test_array [1 - 2 * !(($ac_type) ((((($ac_type) 1 << N) << N) - 1) * 2 + 1) < ($ac_type) ((((($ac_type) 1 << N) << N) - 1) * 2 + 2))]; -test_array [0] = 0; -return test_array [0]; +test_array [0] = 0 ; return 0; @@ -2042,7 +1986,7 @@ eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } - eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} } # ac_fn_c_find_intX_t @@ -2063,8 +2007,7 @@ main () { static int test_array [1 - 2 * !(($2) >= 0)]; -test_array [0] = 0; -return test_array [0]; +test_array [0] = 0 ; return 0; @@ -2080,8 +2023,7 @@ main () { static int test_array [1 - 2 * !(($2) <= $ac_mid)]; -test_array [0] = 0; -return test_array [0]; +test_array [0] = 0 ; return 0; @@ -2107,8 +2049,7 @@ main () { static int test_array [1 - 2 * !(($2) < 0)]; -test_array [0] = 0; -return test_array [0]; +test_array [0] = 0 ; return 0; @@ -2124,8 +2065,7 @@ main () { static int test_array [1 - 2 * !(($2) >= $ac_mid)]; -test_array [0] = 0; -return test_array [0]; +test_array [0] = 0 ; return 0; @@ -2159,8 +2099,7 @@ main () { static int test_array [1 - 2 * !(($2) <= $ac_mid)]; -test_array [0] = 0; -return test_array [0]; +test_array [0] = 0 ; return 0; @@ -2224,7 +2163,7 @@ rm -f conftest.val fi - eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} as_fn_set_status $ac_retval } # ac_fn_c_compute_int @@ -2237,7 +2176,7 @@ as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } -if eval \${$3+:} false; then : +if eval "test \"\${$3+set}\"" = set; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext @@ -2292,7 +2231,7 @@ eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } - eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} } # ac_fn_c_check_func @@ -2305,7 +2244,7 @@ as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2.$3" >&5 $as_echo_n "checking for $2.$3... " >&6; } -if eval \${$4+:} false; then : +if eval "test \"\${$4+set}\"" = set; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext @@ -2349,7 +2288,7 @@ eval ac_res=\$$4 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } - eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} } # ac_fn_c_check_member @@ -2364,7 +2303,7 @@ as_decl_use=`echo $2|sed -e 's/(/((/' -e 's/)/) 0&/' -e 's/,/) 0& (/g'` { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $as_decl_name is declared" >&5 $as_echo_n "checking whether $as_decl_name is declared... " >&6; } -if eval \${$3+:} false; then : +if eval "test \"\${$3+set}\"" = set; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext @@ -2395,7 +2334,7 @@ eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } - eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} } # ac_fn_c_check_decl cat >config.log <<_ACEOF @@ -2403,7 +2342,7 @@ running configure, to aid debugging if configure makes a mistake. It was created by python $as_me 2.7, which was -generated by GNU Autoconf 2.69. Invocation command line was +generated by GNU Autoconf 2.67. Invocation command line was $ $0 $@ @@ -2661,7 +2600,7 @@ || { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "failed to load site script $ac_site_file -See \`config.log' for more details" "$LINENO" 5; } +See \`config.log' for more details" "$LINENO" 5 ; } fi done @@ -2754,134 +2693,6 @@ ac_config_headers="$ac_config_headers pyconfig.h" -ac_aux_dir= -for ac_dir in "$srcdir" "$srcdir/.." "$srcdir/../.."; do - if test -f "$ac_dir/install-sh"; then - ac_aux_dir=$ac_dir - ac_install_sh="$ac_aux_dir/install-sh -c" - break - elif test -f "$ac_dir/install.sh"; then - ac_aux_dir=$ac_dir - ac_install_sh="$ac_aux_dir/install.sh -c" - break - elif test -f "$ac_dir/shtool"; then - ac_aux_dir=$ac_dir - ac_install_sh="$ac_aux_dir/shtool install -c" - break - fi -done -if test -z "$ac_aux_dir"; then - as_fn_error $? "cannot find install-sh, install.sh, or shtool in \"$srcdir\" \"$srcdir/..\" \"$srcdir/../..\"" "$LINENO" 5 -fi - -# These three variables are undocumented and unsupported, -# and are intended to be withdrawn in a future Autoconf release. -# They can cause serious problems if a builder's source tree is in a directory -# whose full name contains unusual characters. -ac_config_guess="$SHELL $ac_aux_dir/config.guess" # Please don't use this var. -ac_config_sub="$SHELL $ac_aux_dir/config.sub" # Please don't use this var. -ac_configure="$SHELL $ac_aux_dir/configure" # Please don't use this var. - - -# Make sure we can run config.sub. -$SHELL "$ac_aux_dir/config.sub" sun4 >/dev/null 2>&1 || - as_fn_error $? "cannot run $SHELL $ac_aux_dir/config.sub" "$LINENO" 5 - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking build system type" >&5 -$as_echo_n "checking build system type... " >&6; } -if ${ac_cv_build+:} false; then : - $as_echo_n "(cached) " >&6 -else - ac_build_alias=$build_alias -test "x$ac_build_alias" = x && - ac_build_alias=`$SHELL "$ac_aux_dir/config.guess"` -test "x$ac_build_alias" = x && - as_fn_error $? "cannot guess build type; you must specify one" "$LINENO" 5 -ac_cv_build=`$SHELL "$ac_aux_dir/config.sub" $ac_build_alias` || - as_fn_error $? "$SHELL $ac_aux_dir/config.sub $ac_build_alias failed" "$LINENO" 5 - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_build" >&5 -$as_echo "$ac_cv_build" >&6; } -case $ac_cv_build in -*-*-*) ;; -*) as_fn_error $? "invalid value of canonical build" "$LINENO" 5;; -esac -build=$ac_cv_build -ac_save_IFS=$IFS; IFS='-' -set x $ac_cv_build -shift -build_cpu=$1 -build_vendor=$2 -shift; shift -# Remember, the first character of IFS is used to create $*, -# except with old shells: -build_os=$* -IFS=$ac_save_IFS -case $build_os in *\ *) build_os=`echo "$build_os" | sed 's/ /-/g'`;; esac - - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking host system type" >&5 -$as_echo_n "checking host system type... " >&6; } -if ${ac_cv_host+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test "x$host_alias" = x; then - ac_cv_host=$ac_cv_build -else - ac_cv_host=`$SHELL "$ac_aux_dir/config.sub" $host_alias` || - as_fn_error $? "$SHELL $ac_aux_dir/config.sub $host_alias failed" "$LINENO" 5 -fi - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_host" >&5 -$as_echo "$ac_cv_host" >&6; } -case $ac_cv_host in -*-*-*) ;; -*) as_fn_error $? "invalid value of canonical host" "$LINENO" 5;; -esac -host=$ac_cv_host -ac_save_IFS=$IFS; IFS='-' -set x $ac_cv_host -shift -host_cpu=$1 -host_vendor=$2 -shift; shift -# Remember, the first character of IFS is used to create $*, -# except with old shells: -host_os=$* -IFS=$ac_save_IFS -case $host_os in *\ *) host_os=`echo "$host_os" | sed 's/ /-/g'`;; esac - - - - - -if test "$cross_compiling" = yes; then - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for python interpreter for cross build" >&5 -$as_echo_n "checking for python interpreter for cross build... " >&6; } - if test -z "$PYTHON_FOR_BUILD"; then - for interp in python$PACKAGE_VERSION python2 python; do - which $interp >/dev/null 2>&1 || continue - if $interp -c 'import sys;sys.exit(not (sys.version_info[:2] >= (2,7) and sys.version_info[0] < 3))'; then - break - fi - interp= - done - if test x$interp = x; then - as_fn_error $? "python$PACKAGE_VERSION interpreter not found" "$LINENO" 5 - fi - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $interp" >&5 -$as_echo "$interp" >&6; } - PYTHON_FOR_BUILD='_PYTHON_PROJECT_BASE=$(abs_builddir) _PYTHON_HOST_PLATFORM=$(_PYTHON_HOST_PLATFORM) PYTHONPATH=$(shell test -f pybuilddir.txt && echo $(abs_builddir)/`cat pybuilddir.txt`:)$(srcdir)/Lib:$(srcdir)/Lib/plat-$(MACHDEP) '$interp - fi -elif test "$cross_compiling" = maybe; then - as_fn_error $? "Cross compiling required --host=HOST-TUPLE and --build=ARCH" "$LINENO" 5 -else - PYTHON_FOR_BUILD='./$(BUILDPYTHON) -E' -fi - - if test "$prefix" != "/"; then prefix=`echo "$prefix" | sed -e 's/\/$//g'` @@ -2989,7 +2800,6 @@ -ARCH_RUN_32BIT="" UNIVERSAL_ARCHS="32-bit" @@ -3171,25 +2981,6 @@ $as_echo_n "checking MACHDEP... " >&6; } if test -z "$MACHDEP" then - # avoid using uname for cross builds - if test "$cross_compiling" = yes; then - # ac_sys_system and ac_sys_release are only used for setting - # `define_xopen_source' in the case statement below. For the - # current supported cross builds, this macro is not adjusted. - case "$host" in - *-*-linux*) - ac_sys_system=Linux - ;; - *-*-cygwin*) - ac_sys_system=Cygwin - ;; - *) - # for now, limit cross builds to known configurations - MACHDEP="unknown" - as_fn_error $? "cross build not supported for $host" "$LINENO" 5 - esac - ac_sys_release= - else ac_sys_system=`uname -s` if test "$ac_sys_system" = "AIX" \ -o "$ac_sys_system" = "UnixWare" -o "$ac_sys_system" = "OpenUNIX"; then @@ -3197,44 +2988,20 @@ else ac_sys_release=`uname -r` fi - fi - ac_md_system=`echo $ac_sys_system | - tr -d '/ ' | tr '[A-Z]' '[a-z]'` - ac_md_release=`echo $ac_sys_release | - tr -d '/ ' | sed 's/^[A-Z]\.//' | sed 's/\..*//'` - MACHDEP="$ac_md_system$ac_md_release" - - case $MACHDEP in + ac_md_system=`echo $ac_sys_system | + tr -d '/ ' | tr '[A-Z]' '[a-z]'` + ac_md_release=`echo $ac_sys_release | + tr -d '/ ' | sed 's/^[A-Z]\.//' | sed 's/\..*//'` + MACHDEP="$ac_md_system$ac_md_release" + + case $MACHDEP in linux*) MACHDEP="linux2";; cygwin*) MACHDEP="cygwin";; darwin*) MACHDEP="darwin";; atheos*) MACHDEP="atheos";; irix646) MACHDEP="irix6";; '') MACHDEP="unknown";; - esac -fi - - -if test "$cross_compiling" = yes; then - case "$host" in - *-*-linux*) - case "$host_cpu" in - arm*) - _host_cpu=arm - ;; - *) - _host_cpu=$host_cpu - esac - ;; - *-*-cygwin*) - _host_cpu= - ;; - *) - # for now, limit cross builds to known configurations - MACHDEP="unknown" - as_fn_error $? "cross build not supported for $host" "$LINENO" 5 esac - _PYTHON_HOST_PLATFORM="$MACHDEP${_host_cpu:+-$_host_cpu}" fi # Some systems cannot stand _XOPEN_SOURCE being defined at all; they @@ -3391,6 +3158,12 @@ CONFIGURE_MACOSX_DEPLOYMENT_TARGET= EXPORT_MACOSX_DEPLOYMENT_TARGET='#' +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking machine type as reported by uname -m" >&5 +$as_echo_n "checking machine type as reported by uname -m... " >&6; } +ac_sys_machine=`uname -m` +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_sys_machine" >&5 +$as_echo "$ac_sys_machine" >&6; } + # checks for alternative programs # compiler flags are generated in two sets, BASECFLAGS and OPT. OPT is just @@ -3455,39 +3228,6 @@ (it is also a good idea to do 'make clean' before compiling)" "$LINENO" 5 fi -if test "$MACHDEP" = "irix6" && test "$CC" != "gcc"; then - # Normally, MIPSpro CC treats #error directives as warnings, which means - # a successful exit code is returned (0). This is a problem because IRIX - # has a bunch of system headers with this guard at the top: - # - # #ifndef __c99 - # #error This header file is to be used only for c99 mode compilations - # #else - # - # When autoconf tests for such a header, like stdint.h, this happens: - # - # configure:4619: cc -c conftest.c >&5 - # cc-1035 cc: WARNING File = /usr/include/stdint.h, Line = 5 - # #error directive: This header file is to be used only for c99 mode - # compilations - # - # #error This header file is to be used only for c99 mode compilations - # ^ - # - # configure:4619: $? = 0 - # configure:4619: result: yes - # - # Therefore, we use `-diag_error 1035` to have the compiler treat the - # warning as an error, which causes cc to return a non-zero result, - # which autoconf can interpret correctly. - CFLAGS="$CFLAGS -diag_error 1035" - # Whilst we're here, we might as well make sure CXX defaults to something - # sensible if we're not using gcc. - if test -z "$CXX"; then - CXX="CC" - fi -fi - # If the user set CFLAGS, use this instead of the automatically # determined setting preset_cflags="$CFLAGS" @@ -3501,7 +3241,7 @@ set dummy ${ac_tool_prefix}gcc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_CC+:} false; then : +if test "${ac_cv_prog_CC+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then @@ -3513,7 +3253,7 @@ IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_CC="${ac_tool_prefix}gcc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -3541,7 +3281,7 @@ set dummy gcc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_ac_ct_CC+:} false; then : +if test "${ac_cv_prog_ac_ct_CC+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_CC"; then @@ -3553,7 +3293,7 @@ IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_CC="gcc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -3594,7 +3334,7 @@ set dummy ${ac_tool_prefix}cc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_CC+:} false; then : +if test "${ac_cv_prog_CC+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then @@ -3606,7 +3346,7 @@ IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_CC="${ac_tool_prefix}cc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -3634,7 +3374,7 @@ set dummy cc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_CC+:} false; then : +if test "${ac_cv_prog_CC+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then @@ -3647,7 +3387,7 @@ IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then ac_prog_rejected=yes continue @@ -3693,7 +3433,7 @@ set dummy $ac_tool_prefix$ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_CC+:} false; then : +if test "${ac_cv_prog_CC+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then @@ -3705,7 +3445,7 @@ IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_CC="$ac_tool_prefix$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -3737,7 +3477,7 @@ set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_ac_ct_CC+:} false; then : +if test "${ac_cv_prog_ac_ct_CC+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_CC"; then @@ -3749,7 +3489,7 @@ IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_CC="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -3792,7 +3532,7 @@ test -z "$CC" && { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "no acceptable C compiler found in \$PATH -See \`config.log' for more details" "$LINENO" 5; } +See \`config.log' for more details" "$LINENO" 5 ; } # Provide some information about the compiler. $as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler version" >&5 @@ -3907,7 +3647,7 @@ { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error 77 "C compiler cannot create executables -See \`config.log' for more details" "$LINENO" 5; } +See \`config.log' for more details" "$LINENO" 5 ; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } @@ -3950,7 +3690,7 @@ { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "cannot compute suffix of executables: cannot compile and link -See \`config.log' for more details" "$LINENO" 5; } +See \`config.log' for more details" "$LINENO" 5 ; } fi rm -f conftest conftest$ac_cv_exeext { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_exeext" >&5 @@ -4009,7 +3749,7 @@ $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "cannot run C compiled programs. If you meant to cross compile, use \`--host'. -See \`config.log' for more details" "$LINENO" 5; } +See \`config.log' for more details" "$LINENO" 5 ; } fi fi fi @@ -4020,7 +3760,7 @@ ac_clean_files=$ac_clean_files_save { $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of object files" >&5 $as_echo_n "checking for suffix of object files... " >&6; } -if ${ac_cv_objext+:} false; then : +if test "${ac_cv_objext+set}" = set; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext @@ -4061,7 +3801,7 @@ { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "cannot compute suffix of object files: cannot compile -See \`config.log' for more details" "$LINENO" 5; } +See \`config.log' for more details" "$LINENO" 5 ; } fi rm -f conftest.$ac_cv_objext conftest.$ac_ext fi @@ -4071,7 +3811,7 @@ ac_objext=$OBJEXT { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C compiler" >&5 $as_echo_n "checking whether we are using the GNU C compiler... " >&6; } -if ${ac_cv_c_compiler_gnu+:} false; then : +if test "${ac_cv_c_compiler_gnu+set}" = set; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext @@ -4108,7 +3848,7 @@ ac_save_CFLAGS=$CFLAGS { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC accepts -g" >&5 $as_echo_n "checking whether $CC accepts -g... " >&6; } -if ${ac_cv_prog_cc_g+:} false; then : +if test "${ac_cv_prog_cc_g+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_save_c_werror_flag=$ac_c_werror_flag @@ -4186,7 +3926,7 @@ fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CC option to accept ISO C89" >&5 $as_echo_n "checking for $CC option to accept ISO C89... " >&6; } -if ${ac_cv_prog_cc_c89+:} false; then : +if test "${ac_cv_prog_cc_c89+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_cv_prog_cc_c89=no @@ -4195,7 +3935,8 @@ /* end confdefs.h. */ #include #include -struct stat; +#include +#include /* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */ struct buf { int x; }; FILE * (*rcsopen) (struct buf *, struct stat *, int); @@ -4320,12 +4061,11 @@ if test -z "$CXX" then case "$CC" in - gcc) if test -n "$ac_tool_prefix"; then - # Extract the first word of "${ac_tool_prefix}g++", so it can be a program name with args. -set dummy ${ac_tool_prefix}g++; ac_word=$2 + gcc) # Extract the first word of "g++", so it can be a program name with args. +set dummy g++; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_CXX+:} false; then : +if test "${ac_cv_path_CXX+set}" = set; then : $as_echo_n "(cached) " >&6 else case $CXX in @@ -4339,7 +4079,7 @@ IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_path_CXX="$as_dir/$ac_word$ac_exec_ext" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -4348,6 +4088,7 @@ done IFS=$as_save_IFS + test -z "$ac_cv_path_CXX" && ac_cv_path_CXX="g++" ;; esac fi @@ -4360,70 +4101,12 @@ $as_echo "no" >&6; } fi - -fi -if test -z "$ac_cv_path_CXX"; then - ac_pt_CXX=$CXX - # Extract the first word of "g++", so it can be a program name with args. -set dummy g++; ac_word=$2 + ;; + cc) # Extract the first word of "c++", so it can be a program name with args. +set dummy c++; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_ac_pt_CXX+:} false; then : - $as_echo_n "(cached) " >&6 -else - case $ac_pt_CXX in - [\\/]* | ?:[\\/]*) - ac_cv_path_ac_pt_CXX="$ac_pt_CXX" # Let the user override the test with a path. - ;; - *) - as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in notfound -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_path_ac_pt_CXX="$as_dir/$ac_word$ac_exec_ext" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - - ;; -esac -fi -ac_pt_CXX=$ac_cv_path_ac_pt_CXX -if test -n "$ac_pt_CXX"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_pt_CXX" >&5 -$as_echo "$ac_pt_CXX" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - if test "x$ac_pt_CXX" = x; then - CXX="g++" - else - case $cross_compiling:$ac_tool_warned in -yes:) -{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 -$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} -ac_tool_warned=yes ;; -esac - CXX=$ac_pt_CXX - fi -else - CXX="$ac_cv_path_CXX" -fi - ;; - cc) if test -n "$ac_tool_prefix"; then - # Extract the first word of "${ac_tool_prefix}c++", so it can be a program name with args. -set dummy ${ac_tool_prefix}c++; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_CXX+:} false; then : +if test "${ac_cv_path_CXX+set}" = set; then : $as_echo_n "(cached) " >&6 else case $CXX in @@ -4437,7 +4120,7 @@ IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_path_CXX="$as_dir/$ac_word$ac_exec_ext" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -4446,6 +4129,7 @@ done IFS=$as_save_IFS + test -z "$ac_cv_path_CXX" && ac_cv_path_CXX="c++" ;; esac fi @@ -4458,63 +4142,6 @@ $as_echo "no" >&6; } fi - -fi -if test -z "$ac_cv_path_CXX"; then - ac_pt_CXX=$CXX - # Extract the first word of "c++", so it can be a program name with args. -set dummy c++; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_ac_pt_CXX+:} false; then : - $as_echo_n "(cached) " >&6 -else - case $ac_pt_CXX in - [\\/]* | ?:[\\/]*) - ac_cv_path_ac_pt_CXX="$ac_pt_CXX" # Let the user override the test with a path. - ;; - *) - as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in notfound -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_path_ac_pt_CXX="$as_dir/$ac_word$ac_exec_ext" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - - ;; -esac -fi -ac_pt_CXX=$ac_cv_path_ac_pt_CXX -if test -n "$ac_pt_CXX"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_pt_CXX" >&5 -$as_echo "$ac_pt_CXX" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - if test "x$ac_pt_CXX" = x; then - CXX="c++" - else - case $cross_compiling:$ac_tool_warned in -yes:) -{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 -$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} -ac_tool_warned=yes ;; -esac - CXX=$ac_pt_CXX - fi -else - CXX="$ac_cv_path_CXX" -fi ;; esac if test "$CXX" = "notfound" @@ -4524,14 +4151,13 @@ fi if test -z "$CXX" then - if test -n "$ac_tool_prefix"; then - for ac_prog in $CCC c++ g++ gcc CC cxx cc++ cl - do - # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. -set dummy $ac_tool_prefix$ac_prog; ac_word=$2 + for ac_prog in $CCC c++ g++ gcc CC cxx cc++ cl +do + # Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_CXX+:} false; then : +if test "${ac_cv_prog_CXX+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$CXX"; then @@ -4543,8 +4169,8 @@ IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_CXX="$ac_tool_prefix$ac_prog" + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_CXX="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi @@ -4564,65 +4190,9 @@ fi - test -n "$CXX" && break - done -fi -if test -z "$CXX"; then - ac_ct_CXX=$CXX - for ac_prog in $CCC c++ g++ gcc CC cxx cc++ cl -do - # Extract the first word of "$ac_prog", so it can be a program name with args. -set dummy $ac_prog; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_ac_ct_CXX+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$ac_ct_CXX"; then - ac_cv_prog_ac_ct_CXX="$ac_ct_CXX" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_ac_ct_CXX="$ac_prog" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -ac_ct_CXX=$ac_cv_prog_ac_ct_CXX -if test -n "$ac_ct_CXX"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CXX" >&5 -$as_echo "$ac_ct_CXX" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - - test -n "$ac_ct_CXX" && break -done - - if test "x$ac_ct_CXX" = x; then - CXX="notfound" - else - case $cross_compiling:$ac_tool_warned in -yes:) -{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 -$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} -ac_tool_warned=yes ;; -esac - CXX=$ac_ct_CXX - fi -fi + test -n "$CXX" && break +done +test -n "$CXX" || CXX="notfound" if test "$CXX" = "notfound" then @@ -4643,9 +4213,6 @@ " >&2;} fi -MULTIARCH=$($CC --print-multiarch 2>/dev/null) - - # checks for UNIX variants that set C preprocessor variables @@ -4661,7 +4228,7 @@ CPP= fi if test -z "$CPP"; then - if ${ac_cv_prog_CPP+:} false; then : + if test "${ac_cv_prog_CPP+set}" = set; then : $as_echo_n "(cached) " >&6 else # Double quotes because CPP needs to be expanded @@ -4777,7 +4344,7 @@ { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "C preprocessor \"$CPP\" fails sanity check -See \`config.log' for more details" "$LINENO" 5; } +See \`config.log' for more details" "$LINENO" 5 ; } fi ac_ext=c @@ -4789,7 +4356,7 @@ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for grep that handles long lines and -e" >&5 $as_echo_n "checking for grep that handles long lines and -e... " >&6; } -if ${ac_cv_path_GREP+:} false; then : +if test "${ac_cv_path_GREP+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -z "$GREP"; then @@ -4803,7 +4370,7 @@ for ac_prog in grep ggrep; do for ac_exec_ext in '' $ac_executable_extensions; do ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext" - as_fn_executable_p "$ac_path_GREP" || continue + { test -f "$ac_path_GREP" && $as_test_x "$ac_path_GREP"; } || continue # Check for GNU ac_path_GREP and select it if it is found. # Check for GNU $ac_path_GREP case `"$ac_path_GREP" --version 2>&1` in @@ -4852,7 +4419,7 @@ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for egrep" >&5 $as_echo_n "checking for egrep... " >&6; } -if ${ac_cv_path_EGREP+:} false; then : +if test "${ac_cv_path_EGREP+set}" = set; then : $as_echo_n "(cached) " >&6 else if echo a | $GREP -E '(a|b)' >/dev/null 2>&1 @@ -4869,7 +4436,7 @@ for ac_prog in egrep; do for ac_exec_ext in '' $ac_executable_extensions; do ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext" - as_fn_executable_p "$ac_path_EGREP" || continue + { test -f "$ac_path_EGREP" && $as_test_x "$ac_path_EGREP"; } || continue # Check for GNU ac_path_EGREP and select it if it is found. # Check for GNU $ac_path_EGREP case `"$ac_path_EGREP" --version 2>&1` in @@ -4919,7 +4486,7 @@ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ANSI C header files" >&5 $as_echo_n "checking for ANSI C header files... " >&6; } -if ${ac_cv_header_stdc+:} false; then : +if test "${ac_cv_header_stdc+set}" = set; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext @@ -5048,7 +4615,7 @@ ac_fn_c_check_header_mongrel "$LINENO" "minix/config.h" "ac_cv_header_minix_config_h" "$ac_includes_default" -if test "x$ac_cv_header_minix_config_h" = xyes; then : +if test "x$ac_cv_header_minix_config_h" = x""yes; then : MINIX=yes else MINIX= @@ -5070,14 +4637,14 @@ { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether it is safe to define __EXTENSIONS__" >&5 $as_echo_n "checking whether it is safe to define __EXTENSIONS__... " >&6; } -if ${ac_cv_safe_to_define___extensions__+:} false; then : - $as_echo_n "(cached) " >&6 -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -# define __EXTENSIONS__ 1 - $ac_includes_default +if test "${ac_cv_safe_to_define___extensions__+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +# define __EXTENSIONS__ 1 + $ac_includes_default int main () { @@ -5285,34 +4852,36 @@ $as_echo_n "checking for --enable-profiling... " >&6; } # Check whether --enable-profiling was given. if test "${enable_profiling+set}" = set; then : - enableval=$enable_profiling; -fi - -if test "x$enable_profiling" = xyes; then - ac_save_cc="$CC" - CC="$CC -pg" + enableval=$enable_profiling; ac_save_cc="$CC" + CC="$CC -pg" + if test "$cross_compiling" = yes; then : + ac_enable_profiling="no" +else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main() { return 0; } _ACEOF -if ac_fn_c_try_link "$LINENO"; then : - -else - enable_profiling=no -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext - CC="$ac_save_cc" -else - enable_profiling=no -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $enable_profiling" >&5 -$as_echo "$enable_profiling" >&6; } - -if test "x$enable_profiling" = xyes; then - BASECFLAGS="-pg $BASECFLAGS" - LDFLAGS="-pg $LDFLAGS" -fi +if ac_fn_c_try_run "$LINENO"; then : + ac_enable_profiling="yes" +else + ac_enable_profiling="no" +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext +fi + + CC="$ac_save_cc" +fi + +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_enable_profiling" >&5 +$as_echo "$ac_enable_profiling" >&6; } + +case "$ac_enable_profiling" in + "yes") + BASECFLAGS="-pg $BASECFLAGS" + LDFLAGS="-pg $LDFLAGS" + ;; +esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking LDLIBRARY" >&5 $as_echo_n "checking LDLIBRARY... " >&6; } @@ -5326,7 +4895,7 @@ if test "$enable_framework" then LDLIBRARY='$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)' - RUNSHARED=DYLD_FRAMEWORK_PATH=`pwd`${DYLD_FRAMEWORK_PATH:+:${DYLD_FRAMEWORK_PATH}} + RUNSHARED=DYLD_FRAMEWORK_PATH="`pwd`:$DYLD_FRAMEWORK_PATH" BLDLIBRARY='' else BLDLIBRARY='$(LDLIBRARY)' @@ -5348,13 +4917,13 @@ SunOS*) LDLIBRARY='libpython$(VERSION).so' BLDLIBRARY='-Wl,-R,$(LIBDIR) -L. -lpython$(VERSION)' - RUNSHARED=LD_LIBRARY_PATH=`pwd`${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}} + RUNSHARED=LD_LIBRARY_PATH=`pwd`:${LD_LIBRARY_PATH} INSTSONAME="$LDLIBRARY".$SOVERSION ;; Linux*|GNU*|NetBSD*|FreeBSD*|DragonFly*|OpenBSD*) LDLIBRARY='libpython$(VERSION).so' BLDLIBRARY='-L. -lpython$(VERSION)' - RUNSHARED=LD_LIBRARY_PATH=`pwd`${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}} + RUNSHARED=LD_LIBRARY_PATH=`pwd`:${LD_LIBRARY_PATH} case $ac_sys_system in FreeBSD*) SOVERSION=`echo $SOVERSION|cut -d "." -f 1` @@ -5372,12 +4941,12 @@ ;; esac BLDLIBRARY='-Wl,+b,$(LIBDIR) -L. -lpython$(VERSION)' - RUNSHARED=SHLIB_PATH=`pwd`${SHLIB_PATH:+:${SHLIB_PATH}} + RUNSHARED=SHLIB_PATH=`pwd`:${SHLIB_PATH} ;; OSF*) LDLIBRARY='libpython$(VERSION).so' BLDLIBRARY='-rpath $(LIBDIR) -L. -lpython$(VERSION)' - RUNSHARED=LD_LIBRARY_PATH=`pwd`${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}} + RUNSHARED=LD_LIBRARY_PATH=`pwd`:${LD_LIBRARY_PATH} ;; atheos*) LDLIBRARY='libpython$(VERSION).so' @@ -5387,11 +4956,11 @@ Darwin*) LDLIBRARY='libpython$(VERSION).dylib' BLDLIBRARY='-L. -lpython$(VERSION)' - RUNSHARED=DYLD_LIBRARY_PATH=`pwd`${DYLD_LIBRARY_PATH:+:${DYLD_LIBRARY_PATH}} + RUNSHARED='DYLD_LIBRARY_PATH=`pwd`:${DYLD_LIBRARY_PATH}' ;; AIX*) LDLIBRARY='libpython$(VERSION).so' - RUNSHARED=LIBPATH=`pwd`${LIBPATH:+:${LIBPATH}} + RUNSHARED=LIBPATH=`pwd`:${LIBPATH} ;; esac @@ -5404,10 +4973,6 @@ esac fi -if test "$cross_compiling" = yes; then - RUNSHARED= -fi - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LDLIBRARY" >&5 $as_echo "$LDLIBRARY" >&6; } @@ -5416,7 +4981,7 @@ set dummy ${ac_tool_prefix}ranlib; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_RANLIB+:} false; then : +if test "${ac_cv_prog_RANLIB+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$RANLIB"; then @@ -5428,7 +4993,7 @@ IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_RANLIB="${ac_tool_prefix}ranlib" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -5456,7 +5021,7 @@ set dummy ranlib; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_ac_ct_RANLIB+:} false; then : +if test "${ac_cv_prog_ac_ct_RANLIB+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_RANLIB"; then @@ -5468,7 +5033,7 @@ IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_RANLIB="ranlib" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -5504,14 +5069,13 @@ fi -if test -n "$ac_tool_prefix"; then - for ac_prog in ar aal - do - # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. -set dummy $ac_tool_prefix$ac_prog; ac_word=$2 +for ac_prog in ar aal +do + # Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_AR+:} false; then : +if test "${ac_cv_prog_AR+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$AR"; then @@ -5523,8 +5087,8 @@ IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_AR="$ac_tool_prefix$ac_prog" + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_AR="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi @@ -5544,22 +5108,28 @@ fi - test -n "$AR" && break - done -fi -if test -z "$AR"; then - ac_ct_AR=$AR - for ac_prog in ar aal -do - # Extract the first word of "$ac_prog", so it can be a program name with args. -set dummy $ac_prog; ac_word=$2 + test -n "$AR" && break +done +test -n "$AR" || AR="ar" + + +# tweak ARFLAGS only if the user didn't set it on the command line + +if test -z "$ARFLAGS" +then + ARFLAGS="rc" +fi + + +# Extract the first word of "svnversion", so it can be a program name with args. +set dummy svnversion; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_ac_ct_AR+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$ac_ct_AR"; then - ac_cv_prog_ac_ct_AR="$ac_ct_AR" # Let the user override the test. +if test "${ac_cv_prog_SVNVERSION+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$SVNVERSION"; then + ac_cv_prog_SVNVERSION="$SVNVERSION" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH @@ -5567,8 +5137,8 @@ IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_ac_ct_AR="$ac_prog" + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_SVNVERSION="found" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi @@ -5576,52 +5146,38 @@ done IFS=$as_save_IFS -fi -fi -ac_ct_AR=$ac_cv_prog_ac_ct_AR -if test -n "$ac_ct_AR"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_AR" >&5 -$as_echo "$ac_ct_AR" >&6; } + test -z "$ac_cv_prog_SVNVERSION" && ac_cv_prog_SVNVERSION="not-found" +fi +fi +SVNVERSION=$ac_cv_prog_SVNVERSION +if test -n "$SVNVERSION"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $SVNVERSION" >&5 +$as_echo "$SVNVERSION" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi - test -n "$ac_ct_AR" && break -done - - if test "x$ac_ct_AR" = x; then - AR="ar" - else - case $cross_compiling:$ac_tool_warned in -yes:) -{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 -$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} -ac_tool_warned=yes ;; -esac - AR=$ac_ct_AR - fi -fi - - -# tweak ARFLAGS only if the user didn't set it on the command line - -if test -z "$ARFLAGS" -then - ARFLAGS="rc" -fi - - -# Extract the first word of "svnversion", so it can be a program name with args. -set dummy svnversion; ac_word=$2 +if test $SVNVERSION = found +then + SVNVERSION="svnversion \$(srcdir)" +else + SVNVERSION="echo Unversioned directory" +fi + + + + +# Extract the first word of "hg", so it can be a program name with args. +set dummy hg; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_SVNVERSION+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$SVNVERSION"; then - ac_cv_prog_SVNVERSION="$SVNVERSION" # Let the user override the test. +if test "${ac_cv_prog_HAS_HG+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$HAS_HG"; then + ac_cv_prog_HAS_HG="$HAS_HG" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH @@ -5629,69 +5185,7 @@ IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_SVNVERSION="found" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - - test -z "$ac_cv_prog_SVNVERSION" && ac_cv_prog_SVNVERSION="not-found" -fi -fi -SVNVERSION=$ac_cv_prog_SVNVERSION -if test -n "$SVNVERSION"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $SVNVERSION" >&5 -$as_echo "$SVNVERSION" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - -if test $SVNVERSION = found -then - SVNVERSION="svnversion \$(srcdir)" -else - SVNVERSION="echo Unversioned directory" -fi - - -if test "$abs_srcdir" != "$abs_builddir"; then - # If we're building out-of-tree make sure Include (in the current dir) - # gets picked up before its $srcdir counterpart in order for Python-ast.h - # and graminit.h to get picked up from the correct directory. - # (A side effect of this is that these resources will automatically be - # regenerated when building out-of-tree, regardless of whether or not - # the $srcdir counterpart is up-to-date. This is an acceptable trade - # off.) - BASECPPFLAGS="-IInclude" -else - BASECPPFLAGS="" -fi - - - - -# Extract the first word of "hg", so it can be a program name with args. -set dummy hg; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_HAS_HG+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$HAS_HG"; then - ac_cv_prog_HAS_HG="$HAS_HG" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_HAS_HG="found" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -5732,6 +5226,35 @@ INSTALL="${srcdir}/install-sh -c" fi esac +ac_aux_dir= +for ac_dir in "$srcdir" "$srcdir/.." "$srcdir/../.."; do + if test -f "$ac_dir/install-sh"; then + ac_aux_dir=$ac_dir + ac_install_sh="$ac_aux_dir/install-sh -c" + break + elif test -f "$ac_dir/install.sh"; then + ac_aux_dir=$ac_dir + ac_install_sh="$ac_aux_dir/install.sh -c" + break + elif test -f "$ac_dir/shtool"; then + ac_aux_dir=$ac_dir + ac_install_sh="$ac_aux_dir/shtool install -c" + break + fi +done +if test -z "$ac_aux_dir"; then + as_fn_error $? "cannot find install-sh, install.sh, or shtool in \"$srcdir\" \"$srcdir/..\" \"$srcdir/../..\"" "$LINENO" 5 +fi + +# These three variables are undocumented and unsupported, +# and are intended to be withdrawn in a future Autoconf release. +# They can cause serious problems if a builder's source tree is in a directory +# whose full name contains unusual characters. +ac_config_guess="$SHELL $ac_aux_dir/config.guess" # Please don't use this var. +ac_config_sub="$SHELL $ac_aux_dir/config.sub" # Please don't use this var. +ac_configure="$SHELL $ac_aux_dir/configure" # Please don't use this var. + + # Find a good install program. We prefer a C program (faster), # so one script is as good as another. But avoid the broken or # incompatible versions: @@ -5749,7 +5272,7 @@ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for a BSD-compatible install" >&5 $as_echo_n "checking for a BSD-compatible install... " >&6; } if test -z "$INSTALL"; then -if ${ac_cv_path_install+:} false; then : +if test "${ac_cv_path_install+set}" = set; then : $as_echo_n "(cached) " >&6 else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR @@ -5769,7 +5292,7 @@ # by default. for ac_prog in ginstall scoinst install; do for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_prog$ac_exec_ext"; then + if { test -f "$as_dir/$ac_prog$ac_exec_ext" && $as_test_x "$as_dir/$ac_prog$ac_exec_ext"; }; then if test $ac_prog = install && grep dspmsg "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then # AIX install. It has an incompatible calling convention. @@ -5825,48 +5348,6 @@ test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for a thread-safe mkdir -p" >&5 -$as_echo_n "checking for a thread-safe mkdir -p... " >&6; } -if test -z "$MKDIR_P"; then - if ${ac_cv_path_mkdir+:} false; then : - $as_echo_n "(cached) " >&6 -else - as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH$PATH_SEPARATOR/opt/sfw/bin -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_prog in mkdir gmkdir; do - for ac_exec_ext in '' $ac_executable_extensions; do - as_fn_executable_p "$as_dir/$ac_prog$ac_exec_ext" || continue - case `"$as_dir/$ac_prog$ac_exec_ext" --version 2>&1` in #( - 'mkdir (GNU coreutils) '* | \ - 'mkdir (coreutils) '* | \ - 'mkdir (fileutils) '4.1*) - ac_cv_path_mkdir=$as_dir/$ac_prog$ac_exec_ext - break 3;; - esac - done - done - done -IFS=$as_save_IFS - -fi - - test -d ./--version && rmdir ./--version - if test "${ac_cv_path_mkdir+set}" = set; then - MKDIR_P="$ac_cv_path_mkdir -p" - else - # As a last resort, use the slow shell script. Don't cache a - # value for MKDIR_P within a source directory, because that will - # break other packages using the cache if that directory is - # removed, or if the value is a relative name. - MKDIR_P="$ac_install_sh -d" - fi -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $MKDIR_P" >&5 -$as_echo "$MKDIR_P" >&6; } - # Not every filesystem supports hard links @@ -5979,7 +5460,7 @@ $as_echo_n "checking whether $CC accepts -fno-strict-aliasing... " >&6; } ac_save_cc="$CC" CC="$CC -fno-strict-aliasing" - if ${ac_cv_no_strict_aliasing_ok+:} false; then : + if test "${ac_cv_no_strict_aliasing_ok+set}" = set; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext @@ -6012,7 +5493,7 @@ # if using gcc on alpha, use -mieee to get (near) full IEEE 754 # support. Without this, treatment of subnormals doesn't follow # the standard. - case $host in + case $ac_sys_machine in alpha*) BASECFLAGS="$BASECFLAGS -mieee" ;; @@ -6045,14 +5526,8 @@ # Calculate the right deployment target for this build. # - cur_target_major=`sw_vers -productVersion | \ - sed 's/\([0-9]*\)\.\([0-9]*\).*/\1/'` - cur_target_minor=`sw_vers -productVersion | \ - sed 's/\([0-9]*\)\.\([0-9]*\).*/\2/'` - cur_target="${cur_target_major}.${cur_target_minor}" - if test ${cur_target_major} -eq 10 && \ - test ${cur_target_minor} -ge 3 - then + cur_target=`sw_vers -productVersion | sed 's/\(10\.[0-9]*\).*/\1/'` + if test ${cur_target} '>' 10.2; then cur_target=10.3 if test ${enable_universalsdk}; then if test "${UNIVERSAL_ARCHS}" = "all"; then @@ -6175,7 +5650,7 @@ { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC accepts -OPT:Olimit=0" >&5 $as_echo_n "checking whether $CC accepts -OPT:Olimit=0... " >&6; } -if ${ac_cv_opt_olimit_ok+:} false; then : +if test "${ac_cv_opt_olimit_ok+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_save_cc="$CC" @@ -6210,11 +5685,6 @@ # environment? Darwin*) ;; - # XXX thankfully this useless troublemaker of a flag has been - # eradicated in the 3.x line. For now, make sure it isn't picked - # up by any of our other platforms that use CC. - AIX*|SunOS*|HP-UX*|IRIX*) - ;; *) BASECFLAGS="$BASECFLAGS -OPT:Olimit=0" ;; @@ -6222,7 +5692,7 @@ else { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC accepts -Olimit 1500" >&5 $as_echo_n "checking whether $CC accepts -Olimit 1500... " >&6; } - if ${ac_cv_olimit_ok+:} false; then : + if test "${ac_cv_olimit_ok+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_save_cc="$CC" @@ -6251,14 +5721,7 @@ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_olimit_ok" >&5 $as_echo "$ac_cv_olimit_ok" >&6; } if test $ac_cv_olimit_ok = yes; then - case $ac_sys_system in - # Issue #16534: On HP-UX ac_cv_olimit_ok=yes is a false positive. - HP-UX*) - ;; - *) - BASECFLAGS="$BASECFLAGS -Olimit 1500" - ;; - esac + BASECFLAGS="$BASECFLAGS -Olimit 1500" fi fi @@ -6268,7 +5731,7 @@ { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether gcc supports ParseTuple __format__" >&5 $as_echo_n "checking whether gcc supports ParseTuple __format__... " >&6; } save_CFLAGS=$CFLAGS - CFLAGS="$CFLAGS -Werror -Wformat" + CFLAGS="$CFLAGS -Werror" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ @@ -6307,7 +5770,7 @@ # options before we can check whether -Kpthread improves anything. { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether pthreads are available without options" >&5 $as_echo_n "checking whether pthreads are available without options... " >&6; } -if ${ac_cv_pthread_is_default+:} false; then : +if test "${ac_cv_pthread_is_default+set}" = set; then : $as_echo_n "(cached) " >&6 else if test "$cross_compiling" = yes; then : @@ -6316,7 +5779,6 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ -#include #include void* routine(void* p){return NULL;} @@ -6361,7 +5823,7 @@ # function available. { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC accepts -Kpthread" >&5 $as_echo_n "checking whether $CC accepts -Kpthread... " >&6; } -if ${ac_cv_kpthread+:} false; then : +if test "${ac_cv_kpthread+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_save_cc="$CC" @@ -6372,7 +5834,6 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ -#include #include void* routine(void* p){return NULL;} @@ -6411,7 +5872,7 @@ # function available. { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC accepts -Kthread" >&5 $as_echo_n "checking whether $CC accepts -Kthread... " >&6; } -if ${ac_cv_kthread+:} false; then : +if test "${ac_cv_kthread+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_save_cc="$CC" @@ -6422,7 +5883,6 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ -#include #include void* routine(void* p){return NULL;} @@ -6461,7 +5921,7 @@ # function available. { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC accepts -pthread" >&5 $as_echo_n "checking whether $CC accepts -pthread... " >&6; } -if ${ac_cv_pthread+:} false; then : +if test "${ac_cv_thread+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_save_cc="$CC" @@ -6472,7 +5932,6 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ -#include #include void* routine(void* p){return NULL;} @@ -6547,7 +6006,7 @@ # checks for header files { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ANSI C header files" >&5 $as_echo_n "checking for ANSI C header files... " >&6; } -if ${ac_cv_header_stdc+:} false; then : +if test "${ac_cv_header_stdc+set}" = set; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext @@ -6657,9 +6116,9 @@ fi -for ac_header in asm/types.h conio.h direct.h dlfcn.h errno.h \ +for ac_header in asm/types.h conio.h curses.h direct.h dlfcn.h errno.h \ fcntl.h grp.h \ -ieeefp.h io.h langinfo.h libintl.h poll.h process.h pthread.h \ +ieeefp.h io.h langinfo.h libintl.h ncurses.h poll.h process.h pthread.h \ shadow.h signal.h stdint.h stropts.h termios.h thread.h \ unistd.h utime.h \ sys/audioio.h sys/bsdtty.h sys/epoll.h sys/event.h sys/file.h sys/loadavg.h \ @@ -6668,7 +6127,7 @@ sys/termio.h sys/time.h \ sys/times.h sys/types.h sys/un.h sys/utsname.h sys/wait.h pty.h libutil.h \ sys/resource.h netpacket/packet.h sysexits.h bluetooth.h \ -bluetooth/bluetooth.h linux/tipc.h spawn.h util.h alloca.h +bluetooth/bluetooth.h linux/tipc.h spawn.h util.h do : as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default" @@ -6686,7 +6145,7 @@ as_ac_Header=`$as_echo "ac_cv_header_dirent_$ac_hdr" | $as_tr_sh` { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_hdr that defines DIR" >&5 $as_echo_n "checking for $ac_hdr that defines DIR... " >&6; } -if eval \${$as_ac_Header+:} false; then : +if eval "test \"\${$as_ac_Header+set}\"" = set; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext @@ -6726,7 +6185,7 @@ if test $ac_header_dirent = dirent.h; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing opendir" >&5 $as_echo_n "checking for library containing opendir... " >&6; } -if ${ac_cv_search_opendir+:} false; then : +if test "${ac_cv_search_opendir+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_func_search_save_LIBS=$LIBS @@ -6760,11 +6219,11 @@ fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext - if ${ac_cv_search_opendir+:} false; then : + if test "${ac_cv_search_opendir+set}" = set; then : break fi done -if ${ac_cv_search_opendir+:} false; then : +if test "${ac_cv_search_opendir+set}" = set; then : else ac_cv_search_opendir=no @@ -6783,7 +6242,7 @@ else { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing opendir" >&5 $as_echo_n "checking for library containing opendir... " >&6; } -if ${ac_cv_search_opendir+:} false; then : +if test "${ac_cv_search_opendir+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_func_search_save_LIBS=$LIBS @@ -6817,11 +6276,11 @@ fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext - if ${ac_cv_search_opendir+:} false; then : + if test "${ac_cv_search_opendir+set}" = set; then : break fi done -if ${ac_cv_search_opendir+:} false; then : +if test "${ac_cv_search_opendir+set}" = set; then : else ac_cv_search_opendir=no @@ -6841,7 +6300,7 @@ { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether sys/types.h defines makedev" >&5 $as_echo_n "checking whether sys/types.h defines makedev... " >&6; } -if ${ac_cv_header_sys_types_h_makedev+:} false; then : +if test "${ac_cv_header_sys_types_h_makedev+set}" = set; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext @@ -6869,7 +6328,7 @@ if test $ac_cv_header_sys_types_h_makedev = no; then ac_fn_c_check_header_mongrel "$LINENO" "sys/mkdev.h" "ac_cv_header_sys_mkdev_h" "$ac_includes_default" -if test "x$ac_cv_header_sys_mkdev_h" = xyes; then : +if test "x$ac_cv_header_sys_mkdev_h" = x""yes; then : $as_echo "#define MAJOR_IN_MKDEV 1" >>confdefs.h @@ -6879,7 +6338,7 @@ if test $ac_cv_header_sys_mkdev_h = no; then ac_fn_c_check_header_mongrel "$LINENO" "sys/sysmacros.h" "ac_cv_header_sys_sysmacros_h" "$ac_includes_default" -if test "x$ac_cv_header_sys_sysmacros_h" = xyes; then : +if test "x$ac_cv_header_sys_sysmacros_h" = x""yes; then : $as_echo "#define MAJOR_IN_SYSMACROS 1" >>confdefs.h @@ -6890,6 +6349,25 @@ fi +# On Solaris, term.h requires curses.h +for ac_header in term.h +do : + ac_fn_c_check_header_compile "$LINENO" "term.h" "ac_cv_header_term_h" " +#ifdef HAVE_CURSES_H +#include +#endif + +" +if test "x$ac_cv_header_term_h" = x""yes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_TERM_H 1 +_ACEOF + +fi + +done + + # On Linux, netlink.h requires asm/types.h for ac_header in linux/netlink.h do : @@ -6902,7 +6380,7 @@ #endif " -if test "x$ac_cv_header_linux_netlink_h" = xyes; then : +if test "x$ac_cv_header_linux_netlink_h" = x""yes; then : cat >>confdefs.h <<_ACEOF #define HAVE_LINUX_NETLINK_H 1 _ACEOF @@ -7065,7 +6543,7 @@ # Type availability checks ac_fn_c_check_type "$LINENO" "mode_t" "ac_cv_type_mode_t" "$ac_includes_default" -if test "x$ac_cv_type_mode_t" = xyes; then : +if test "x$ac_cv_type_mode_t" = x""yes; then : else @@ -7076,7 +6554,7 @@ fi ac_fn_c_check_type "$LINENO" "off_t" "ac_cv_type_off_t" "$ac_includes_default" -if test "x$ac_cv_type_off_t" = xyes; then : +if test "x$ac_cv_type_off_t" = x""yes; then : else @@ -7087,7 +6565,7 @@ fi ac_fn_c_check_type "$LINENO" "pid_t" "ac_cv_type_pid_t" "$ac_includes_default" -if test "x$ac_cv_type_pid_t" = xyes; then : +if test "x$ac_cv_type_pid_t" = x""yes; then : else @@ -7103,7 +6581,7 @@ _ACEOF ac_fn_c_check_type "$LINENO" "size_t" "ac_cv_type_size_t" "$ac_includes_default" -if test "x$ac_cv_type_size_t" = xyes; then : +if test "x$ac_cv_type_size_t" = x""yes; then : else @@ -7115,7 +6593,7 @@ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for uid_t in sys/types.h" >&5 $as_echo_n "checking for uid_t in sys/types.h... " >&6; } -if ${ac_cv_type_uid_t+:} false; then : +if test "${ac_cv_type_uid_t+set}" = set; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext @@ -7143,21 +6621,6 @@ fi - -# There are two separate checks for each of the exact-width integer types we -# need. First we check whether the type is available using the usual -# AC_CHECK_TYPE macro with the default includes (which includes -# and where available). We then also use the special type checks of -# the form AC_TYPE_UINT32_T, which in the case that uint32_t is not available -# directly, #define's uint32_t to be a suitable type. - -ac_fn_c_check_type "$LINENO" "uint32_t" "ac_cv_type_uint32_t" "$ac_includes_default" -if test "x$ac_cv_type_uint32_t" = xyes; then : - -$as_echo "#define HAVE_UINT32_T 1" >>confdefs.h - -fi - ac_fn_c_find_uintX_t "$LINENO" "32" "ac_cv_c_uint32_t" case $ac_cv_c_uint32_t in #( no|yes) ;; #( @@ -7172,14 +6635,6 @@ ;; esac - -ac_fn_c_check_type "$LINENO" "uint64_t" "ac_cv_type_uint64_t" "$ac_includes_default" -if test "x$ac_cv_type_uint64_t" = xyes; then : - -$as_echo "#define HAVE_UINT64_T 1" >>confdefs.h - -fi - ac_fn_c_find_uintX_t "$LINENO" "64" "ac_cv_c_uint64_t" case $ac_cv_c_uint64_t in #( no|yes) ;; #( @@ -7194,14 +6649,6 @@ ;; esac - -ac_fn_c_check_type "$LINENO" "int32_t" "ac_cv_type_int32_t" "$ac_includes_default" -if test "x$ac_cv_type_int32_t" = xyes; then : - -$as_echo "#define HAVE_INT32_T 1" >>confdefs.h - -fi - ac_fn_c_find_intX_t "$LINENO" "32" "ac_cv_c_int32_t" case $ac_cv_c_int32_t in #( no|yes) ;; #( @@ -7213,14 +6660,6 @@ ;; esac - -ac_fn_c_check_type "$LINENO" "int64_t" "ac_cv_type_int64_t" "$ac_includes_default" -if test "x$ac_cv_type_int64_t" = xyes; then : - -$as_echo "#define HAVE_INT64_T 1" >>confdefs.h - -fi - ac_fn_c_find_intX_t "$LINENO" "64" "ac_cv_c_int64_t" case $ac_cv_c_int64_t in #( no|yes) ;; #( @@ -7232,9 +6671,8 @@ ;; esac - ac_fn_c_check_type "$LINENO" "ssize_t" "ac_cv_type_ssize_t" "$ac_includes_default" -if test "x$ac_cv_type_ssize_t" = xyes; then : +if test "x$ac_cv_type_ssize_t" = x""yes; then : $as_echo "#define HAVE_SSIZE_T 1" >>confdefs.h @@ -7249,7 +6687,7 @@ # This bug is HP SR number 8606223364. { $as_echo "$as_me:${as_lineno-$LINENO}: checking size of int" >&5 $as_echo_n "checking size of int... " >&6; } -if ${ac_cv_sizeof_int+:} false; then : +if test "${ac_cv_sizeof_int+set}" = set; then : $as_echo_n "(cached) " >&6 else if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (int))" "ac_cv_sizeof_int" "$ac_includes_default"; then : @@ -7259,7 +6697,7 @@ { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error 77 "cannot compute sizeof (int) -See \`config.log' for more details" "$LINENO" 5; } +See \`config.log' for more details" "$LINENO" 5 ; } else ac_cv_sizeof_int=0 fi @@ -7282,7 +6720,7 @@ # This bug is HP SR number 8606223364. { $as_echo "$as_me:${as_lineno-$LINENO}: checking size of long" >&5 $as_echo_n "checking size of long... " >&6; } -if ${ac_cv_sizeof_long+:} false; then : +if test "${ac_cv_sizeof_long+set}" = set; then : $as_echo_n "(cached) " >&6 else if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (long))" "ac_cv_sizeof_long" "$ac_includes_default"; then : @@ -7292,7 +6730,7 @@ { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error 77 "cannot compute sizeof (long) -See \`config.log' for more details" "$LINENO" 5; } +See \`config.log' for more details" "$LINENO" 5 ; } else ac_cv_sizeof_long=0 fi @@ -7315,7 +6753,7 @@ # This bug is HP SR number 8606223364. { $as_echo "$as_me:${as_lineno-$LINENO}: checking size of void *" >&5 $as_echo_n "checking size of void *... " >&6; } -if ${ac_cv_sizeof_void_p+:} false; then : +if test "${ac_cv_sizeof_void_p+set}" = set; then : $as_echo_n "(cached) " >&6 else if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (void *))" "ac_cv_sizeof_void_p" "$ac_includes_default"; then : @@ -7325,7 +6763,7 @@ { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error 77 "cannot compute sizeof (void *) -See \`config.log' for more details" "$LINENO" 5; } +See \`config.log' for more details" "$LINENO" 5 ; } else ac_cv_sizeof_void_p=0 fi @@ -7348,7 +6786,7 @@ # This bug is HP SR number 8606223364. { $as_echo "$as_me:${as_lineno-$LINENO}: checking size of short" >&5 $as_echo_n "checking size of short... " >&6; } -if ${ac_cv_sizeof_short+:} false; then : +if test "${ac_cv_sizeof_short+set}" = set; then : $as_echo_n "(cached) " >&6 else if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (short))" "ac_cv_sizeof_short" "$ac_includes_default"; then : @@ -7358,7 +6796,7 @@ { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error 77 "cannot compute sizeof (short) -See \`config.log' for more details" "$LINENO" 5; } +See \`config.log' for more details" "$LINENO" 5 ; } else ac_cv_sizeof_short=0 fi @@ -7381,7 +6819,7 @@ # This bug is HP SR number 8606223364. { $as_echo "$as_me:${as_lineno-$LINENO}: checking size of float" >&5 $as_echo_n "checking size of float... " >&6; } -if ${ac_cv_sizeof_float+:} false; then : +if test "${ac_cv_sizeof_float+set}" = set; then : $as_echo_n "(cached) " >&6 else if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (float))" "ac_cv_sizeof_float" "$ac_includes_default"; then : @@ -7391,7 +6829,7 @@ { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error 77 "cannot compute sizeof (float) -See \`config.log' for more details" "$LINENO" 5; } +See \`config.log' for more details" "$LINENO" 5 ; } else ac_cv_sizeof_float=0 fi @@ -7414,7 +6852,7 @@ # This bug is HP SR number 8606223364. { $as_echo "$as_me:${as_lineno-$LINENO}: checking size of double" >&5 $as_echo_n "checking size of double... " >&6; } -if ${ac_cv_sizeof_double+:} false; then : +if test "${ac_cv_sizeof_double+set}" = set; then : $as_echo_n "(cached) " >&6 else if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (double))" "ac_cv_sizeof_double" "$ac_includes_default"; then : @@ -7424,7 +6862,7 @@ { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error 77 "cannot compute sizeof (double) -See \`config.log' for more details" "$LINENO" 5; } +See \`config.log' for more details" "$LINENO" 5 ; } else ac_cv_sizeof_double=0 fi @@ -7447,7 +6885,7 @@ # This bug is HP SR number 8606223364. { $as_echo "$as_me:${as_lineno-$LINENO}: checking size of fpos_t" >&5 $as_echo_n "checking size of fpos_t... " >&6; } -if ${ac_cv_sizeof_fpos_t+:} false; then : +if test "${ac_cv_sizeof_fpos_t+set}" = set; then : $as_echo_n "(cached) " >&6 else if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (fpos_t))" "ac_cv_sizeof_fpos_t" "$ac_includes_default"; then : @@ -7457,7 +6895,7 @@ { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error 77 "cannot compute sizeof (fpos_t) -See \`config.log' for more details" "$LINENO" 5; } +See \`config.log' for more details" "$LINENO" 5 ; } else ac_cv_sizeof_fpos_t=0 fi @@ -7480,7 +6918,7 @@ # This bug is HP SR number 8606223364. { $as_echo "$as_me:${as_lineno-$LINENO}: checking size of size_t" >&5 $as_echo_n "checking size of size_t... " >&6; } -if ${ac_cv_sizeof_size_t+:} false; then : +if test "${ac_cv_sizeof_size_t+set}" = set; then : $as_echo_n "(cached) " >&6 else if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (size_t))" "ac_cv_sizeof_size_t" "$ac_includes_default"; then : @@ -7490,7 +6928,7 @@ { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error 77 "cannot compute sizeof (size_t) -See \`config.log' for more details" "$LINENO" 5; } +See \`config.log' for more details" "$LINENO" 5 ; } else ac_cv_sizeof_size_t=0 fi @@ -7513,7 +6951,7 @@ # This bug is HP SR number 8606223364. { $as_echo "$as_me:${as_lineno-$LINENO}: checking size of pid_t" >&5 $as_echo_n "checking size of pid_t... " >&6; } -if ${ac_cv_sizeof_pid_t+:} false; then : +if test "${ac_cv_sizeof_pid_t+set}" = set; then : $as_echo_n "(cached) " >&6 else if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (pid_t))" "ac_cv_sizeof_pid_t" "$ac_includes_default"; then : @@ -7523,7 +6961,7 @@ { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error 77 "cannot compute sizeof (pid_t) -See \`config.log' for more details" "$LINENO" 5; } +See \`config.log' for more details" "$LINENO" 5 ; } else ac_cv_sizeof_pid_t=0 fi @@ -7573,7 +7011,7 @@ # This bug is HP SR number 8606223364. { $as_echo "$as_me:${as_lineno-$LINENO}: checking size of long long" >&5 $as_echo_n "checking size of long long... " >&6; } -if ${ac_cv_sizeof_long_long+:} false; then : +if test "${ac_cv_sizeof_long_long+set}" = set; then : $as_echo_n "(cached) " >&6 else if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (long long))" "ac_cv_sizeof_long_long" "$ac_includes_default"; then : @@ -7583,7 +7021,7 @@ { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error 77 "cannot compute sizeof (long long) -See \`config.log' for more details" "$LINENO" 5; } +See \`config.log' for more details" "$LINENO" 5 ; } else ac_cv_sizeof_long_long=0 fi @@ -7634,7 +7072,7 @@ # This bug is HP SR number 8606223364. { $as_echo "$as_me:${as_lineno-$LINENO}: checking size of long double" >&5 $as_echo_n "checking size of long double... " >&6; } -if ${ac_cv_sizeof_long_double+:} false; then : +if test "${ac_cv_sizeof_long_double+set}" = set; then : $as_echo_n "(cached) " >&6 else if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (long double))" "ac_cv_sizeof_long_double" "$ac_includes_default"; then : @@ -7644,7 +7082,7 @@ { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error 77 "cannot compute sizeof (long double) -See \`config.log' for more details" "$LINENO" 5; } +See \`config.log' for more details" "$LINENO" 5 ; } else ac_cv_sizeof_long_double=0 fi @@ -7695,7 +7133,7 @@ # This bug is HP SR number 8606223364. { $as_echo "$as_me:${as_lineno-$LINENO}: checking size of _Bool" >&5 $as_echo_n "checking size of _Bool... " >&6; } -if ${ac_cv_sizeof__Bool+:} false; then : +if test "${ac_cv_sizeof__Bool+set}" = set; then : $as_echo_n "(cached) " >&6 else if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (_Bool))" "ac_cv_sizeof__Bool" "$ac_includes_default"; then : @@ -7705,7 +7143,7 @@ { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error 77 "cannot compute sizeof (_Bool) -See \`config.log' for more details" "$LINENO" 5; } +See \`config.log' for more details" "$LINENO" 5 ; } else ac_cv_sizeof__Bool=0 fi @@ -7731,7 +7169,7 @@ #include #endif " -if test "x$ac_cv_type_uintptr_t" = xyes; then : +if test "x$ac_cv_type_uintptr_t" = x""yes; then : cat >>confdefs.h <<_ACEOF #define HAVE_UINTPTR_T 1 @@ -7743,7 +7181,7 @@ # This bug is HP SR number 8606223364. { $as_echo "$as_me:${as_lineno-$LINENO}: checking size of uintptr_t" >&5 $as_echo_n "checking size of uintptr_t... " >&6; } -if ${ac_cv_sizeof_uintptr_t+:} false; then : +if test "${ac_cv_sizeof_uintptr_t+set}" = set; then : $as_echo_n "(cached) " >&6 else if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (uintptr_t))" "ac_cv_sizeof_uintptr_t" "$ac_includes_default"; then : @@ -7753,7 +7191,7 @@ { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error 77 "cannot compute sizeof (uintptr_t) -See \`config.log' for more details" "$LINENO" 5; } +See \`config.log' for more details" "$LINENO" 5 ; } else ac_cv_sizeof_uintptr_t=0 fi @@ -7779,7 +7217,7 @@ # This bug is HP SR number 8606223364. { $as_echo "$as_me:${as_lineno-$LINENO}: checking size of off_t" >&5 $as_echo_n "checking size of off_t... " >&6; } -if ${ac_cv_sizeof_off_t+:} false; then : +if test "${ac_cv_sizeof_off_t+set}" = set; then : $as_echo_n "(cached) " >&6 else if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (off_t))" "ac_cv_sizeof_off_t" " @@ -7794,7 +7232,7 @@ { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error 77 "cannot compute sizeof (off_t) -See \`config.log' for more details" "$LINENO" 5; } +See \`config.log' for more details" "$LINENO" 5 ; } else ac_cv_sizeof_off_t=0 fi @@ -7838,7 +7276,7 @@ # This bug is HP SR number 8606223364. { $as_echo "$as_me:${as_lineno-$LINENO}: checking size of time_t" >&5 $as_echo_n "checking size of time_t... " >&6; } -if ${ac_cv_sizeof_time_t+:} false; then : +if test "${ac_cv_sizeof_time_t+set}" = set; then : $as_echo_n "(cached) " >&6 else if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (time_t))" "ac_cv_sizeof_time_t" " @@ -7856,7 +7294,7 @@ { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error 77 "cannot compute sizeof (time_t) -See \`config.log' for more details" "$LINENO" 5; } +See \`config.log' for more details" "$LINENO" 5 ; } else ac_cv_sizeof_time_t=0 fi @@ -7912,7 +7350,7 @@ # This bug is HP SR number 8606223364. { $as_echo "$as_me:${as_lineno-$LINENO}: checking size of pthread_t" >&5 $as_echo_n "checking size of pthread_t... " >&6; } -if ${ac_cv_sizeof_pthread_t+:} false; then : +if test "${ac_cv_sizeof_pthread_t+set}" = set; then : $as_echo_n "(cached) " >&6 else if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (pthread_t))" "ac_cv_sizeof_pthread_t" " @@ -7927,7 +7365,7 @@ { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error 77 "cannot compute sizeof (pthread_t) -See \`config.log' for more details" "$LINENO" 5; } +See \`config.log' for more details" "$LINENO" 5 ; } else ac_cv_sizeof_pthread_t=0 fi @@ -7992,6 +7430,7 @@ esac +ARCH_RUN_32BIT="" case $ac_sys_system/$ac_sys_release in Darwin/[01567]\..*) @@ -8217,14 +7656,15 @@ # Use -undefined dynamic_lookup whenever possible (10.3 and later). # This allows an extension to be used in any Python - dep_target_major=`echo ${MACOSX_DEPLOYMENT_TARGET} | \ - sed 's/\([0-9]*\)\.\([0-9]*\).*/\1/'` - dep_target_minor=`echo ${MACOSX_DEPLOYMENT_TARGET} | \ - sed 's/\([0-9]*\)\.\([0-9]*\).*/\2/'` - if test ${dep_target_major} -eq 10 && \ - test ${dep_target_minor} -le 2 + if test ${MACOSX_DEPLOYMENT_TARGET} '>' 10.2 then - # building for OS X 10.0 through 10.2 + if test "${enable_universalsdk}"; then + LDFLAGS="${UNIVERSAL_ARCH_FLAGS} -isysroot ${UNIVERSALSDK} ${LDFLAGS}" + fi + LDSHARED='$(CC) -bundle -undefined dynamic_lookup' + LDCXXSHARED='$(CXX) -bundle -undefined dynamic_lookup' + BLDSHARED="$LDSHARED" + else LDSHARED='$(CC) -bundle' LDCXXSHARED='$(CXX) -bundle' if test "$enable_framework" ; then @@ -8238,14 +7678,6 @@ LDSHARED="$LDSHARED "'-bundle_loader $(BINDIR)/python$(VERSION)$(EXE)' LDCXXSHARED="$LDCXXSHARED "'-bundle_loader $(BINDIR)/python$(VERSION)$(EXE)' fi - else - # building for OS X 10.3 and later - if test "${enable_universalsdk}"; then - LDFLAGS="${UNIVERSAL_ARCH_FLAGS} -isysroot ${UNIVERSALSDK} ${LDFLAGS}" - fi - LDSHARED='$(CC) -bundle -undefined dynamic_lookup' - LDCXXSHARED='$(CXX) -bundle -undefined dynamic_lookup' - BLDSHARED="$LDSHARED" fi ;; Linux*|GNU*|QNX*) @@ -8445,7 +7877,7 @@ # checks for libraries { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlopen in -ldl" >&5 $as_echo_n "checking for dlopen in -ldl... " >&6; } -if ${ac_cv_lib_dl_dlopen+:} false; then : +if test "${ac_cv_lib_dl_dlopen+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS @@ -8479,7 +7911,7 @@ fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dl_dlopen" >&5 $as_echo "$ac_cv_lib_dl_dlopen" >&6; } -if test "x$ac_cv_lib_dl_dlopen" = xyes; then : +if test "x$ac_cv_lib_dl_dlopen" = x""yes; then : cat >>confdefs.h <<_ACEOF #define HAVE_LIBDL 1 _ACEOF @@ -8490,7 +7922,7 @@ # Dynamic linking for SunOS/Solaris and SYSV { $as_echo "$as_me:${as_lineno-$LINENO}: checking for shl_load in -ldld" >&5 $as_echo_n "checking for shl_load in -ldld... " >&6; } -if ${ac_cv_lib_dld_shl_load+:} false; then : +if test "${ac_cv_lib_dld_shl_load+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS @@ -8524,7 +7956,7 @@ fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dld_shl_load" >&5 $as_echo "$ac_cv_lib_dld_shl_load" >&6; } -if test "x$ac_cv_lib_dld_shl_load" = xyes; then : +if test "x$ac_cv_lib_dld_shl_load" = x""yes; then : cat >>confdefs.h <<_ACEOF #define HAVE_LIBDLD 1 _ACEOF @@ -8538,7 +7970,7 @@ if test "$with_threads" = "yes" -o -z "$with_threads"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing sem_init" >&5 $as_echo_n "checking for library containing sem_init... " >&6; } -if ${ac_cv_search_sem_init+:} false; then : +if test "${ac_cv_search_sem_init+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_func_search_save_LIBS=$LIBS @@ -8572,11 +8004,11 @@ fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext - if ${ac_cv_search_sem_init+:} false; then : + if test "${ac_cv_search_sem_init+set}" = set; then : break fi done -if ${ac_cv_search_sem_init+:} false; then : +if test "${ac_cv_search_sem_init+set}" = set; then : else ac_cv_search_sem_init=no @@ -8599,7 +8031,7 @@ # check if we need libintl for locale functions { $as_echo "$as_me:${as_lineno-$LINENO}: checking for textdomain in -lintl" >&5 $as_echo_n "checking for textdomain in -lintl... " >&6; } -if ${ac_cv_lib_intl_textdomain+:} false; then : +if test "${ac_cv_lib_intl_textdomain+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS @@ -8633,7 +8065,7 @@ fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_intl_textdomain" >&5 $as_echo "$ac_cv_lib_intl_textdomain" >&6; } -if test "x$ac_cv_lib_intl_textdomain" = xyes; then : +if test "x$ac_cv_lib_intl_textdomain" = x""yes; then : $as_echo "#define WITH_LIBINTL 1" >>confdefs.h @@ -8680,7 +8112,7 @@ # BeOS' sockets are stashed in libnet. { $as_echo "$as_me:${as_lineno-$LINENO}: checking for t_open in -lnsl" >&5 $as_echo_n "checking for t_open in -lnsl... " >&6; } -if ${ac_cv_lib_nsl_t_open+:} false; then : +if test "${ac_cv_lib_nsl_t_open+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS @@ -8714,13 +8146,13 @@ fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_nsl_t_open" >&5 $as_echo "$ac_cv_lib_nsl_t_open" >&6; } -if test "x$ac_cv_lib_nsl_t_open" = xyes; then : +if test "x$ac_cv_lib_nsl_t_open" = x""yes; then : LIBS="-lnsl $LIBS" fi # SVR4 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for socket in -lsocket" >&5 $as_echo_n "checking for socket in -lsocket... " >&6; } -if ${ac_cv_lib_socket_socket+:} false; then : +if test "${ac_cv_lib_socket_socket+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS @@ -8754,7 +8186,7 @@ fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_socket_socket" >&5 $as_echo "$ac_cv_lib_socket_socket" >&6; } -if test "x$ac_cv_lib_socket_socket" = xyes; then : +if test "x$ac_cv_lib_socket_socket" = x""yes; then : LIBS="-lsocket $LIBS" fi # SVR4 sockets @@ -8763,7 +8195,7 @@ BeOS*) { $as_echo "$as_me:${as_lineno-$LINENO}: checking for socket in -lnet" >&5 $as_echo_n "checking for socket in -lnet... " >&6; } -if ${ac_cv_lib_net_socket+:} false; then : +if test "${ac_cv_lib_net_socket+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS @@ -8797,7 +8229,7 @@ fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_net_socket" >&5 $as_echo "$ac_cv_lib_net_socket" >&6; } -if test "x$ac_cv_lib_net_socket" = xyes; then : +if test "x$ac_cv_lib_net_socket" = x""yes; then : LIBS="-lnet $LIBS" fi # BeOS @@ -8825,7 +8257,7 @@ set dummy ${ac_tool_prefix}pkg-config; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_PKG_CONFIG+:} false; then : +if test "${ac_cv_path_PKG_CONFIG+set}" = set; then : $as_echo_n "(cached) " >&6 else case $PKG_CONFIG in @@ -8839,7 +8271,7 @@ IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_path_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -8868,7 +8300,7 @@ set dummy pkg-config; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_ac_pt_PKG_CONFIG+:} false; then : +if test "${ac_cv_path_ac_pt_PKG_CONFIG+set}" = set; then : $as_echo_n "(cached) " >&6 else case $ac_pt_PKG_CONFIG in @@ -8882,7 +8314,7 @@ IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_path_ac_pt_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -8956,46 +8388,6 @@ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $with_system_ffi" >&5 $as_echo "$with_system_ffi" >&6; } -# Check for --with-tcltk-includes=path and --with-tcltk-libs=path - - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for --with-tcltk-includes" >&5 -$as_echo_n "checking for --with-tcltk-includes... " >&6; } - -# Check whether --with-tcltk-includes was given. -if test "${with_tcltk_includes+set}" = set; then : - withval=$with_tcltk_includes; -else - with_tcltk_includes="default" -fi - -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $with_tcltk_includes" >&5 -$as_echo "$with_tcltk_includes" >&6; } -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for --with-tcltk-libs" >&5 -$as_echo_n "checking for --with-tcltk-libs... " >&6; } - -# Check whether --with-tcltk-libs was given. -if test "${with_tcltk_libs+set}" = set; then : - withval=$with_tcltk_libs; -else - with_tcltk_libs="default" -fi - -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $with_tcltk_libs" >&5 -$as_echo "$with_tcltk_libs" >&6; } -if test "x$with_tcltk_includes" = xdefault || test "x$with_tcltk_libs" = xdefault -then - if test "x$with_tcltk_includes" != "x$with_tcltk_libs" - then - as_fn_error $? "use both --with-tcltk-includes='...' and --with-tcltk-libs='...' or neither" "$LINENO" 5 - fi - TCLTK_INCLUDES="" - TCLTK_LIBS="" -else - TCLTK_INCLUDES="$with_tcltk_includes" - TCLTK_LIBS="$with_tcltk_libs" -fi - # Check for --with-dbmliborder { $as_echo "$as_me:${as_lineno-$LINENO}: checking for --with-dbmliborder" >&5 $as_echo_n "checking for --with-dbmliborder... " >&6; } @@ -9176,7 +8568,7 @@ $as_echo "#define _REENTRANT 1" >>confdefs.h ac_fn_c_check_header_mongrel "$LINENO" "cthreads.h" "ac_cv_header_cthreads_h" "$ac_includes_default" -if test "x$ac_cv_header_cthreads_h" = xyes; then : +if test "x$ac_cv_header_cthreads_h" = x""yes; then : $as_echo "#define WITH_THREAD 1" >>confdefs.h $as_echo "#define C_THREADS 1" >>confdefs.h @@ -9189,7 +8581,7 @@ else ac_fn_c_check_header_mongrel "$LINENO" "mach/cthreads.h" "ac_cv_header_mach_cthreads_h" "$ac_includes_default" -if test "x$ac_cv_header_mach_cthreads_h" = xyes; then : +if test "x$ac_cv_header_mach_cthreads_h" = x""yes; then : $as_echo "#define WITH_THREAD 1" >>confdefs.h $as_echo "#define C_THREADS 1" >>confdefs.h @@ -9227,8 +8619,6 @@ $as_echo_n "checking for pthread_create in -lpthread... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ - -#include #include void * start_routine (void *arg) { exit (0); } @@ -9253,7 +8643,7 @@ LIBS=$_libs ac_fn_c_check_func "$LINENO" "pthread_detach" "ac_cv_func_pthread_detach" -if test "x$ac_cv_func_pthread_detach" = xyes; then : +if test "x$ac_cv_func_pthread_detach" = x""yes; then : $as_echo "#define WITH_THREAD 1" >>confdefs.h posix_threads=yes @@ -9261,7 +8651,7 @@ else ac_fn_c_check_header_mongrel "$LINENO" "atheos/threads.h" "ac_cv_header_atheos_threads_h" "$ac_includes_default" -if test "x$ac_cv_header_atheos_threads_h" = xyes; then : +if test "x$ac_cv_header_atheos_threads_h" = x""yes; then : $as_echo "#define WITH_THREAD 1" >>confdefs.h @@ -9271,7 +8661,7 @@ else ac_fn_c_check_header_mongrel "$LINENO" "kernel/OS.h" "ac_cv_header_kernel_OS_h" "$ac_includes_default" -if test "x$ac_cv_header_kernel_OS_h" = xyes; then : +if test "x$ac_cv_header_kernel_OS_h" = x""yes; then : $as_echo "#define WITH_THREAD 1" >>confdefs.h @@ -9282,7 +8672,7 @@ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pthread_create in -lpthreads" >&5 $as_echo_n "checking for pthread_create in -lpthreads... " >&6; } -if ${ac_cv_lib_pthreads_pthread_create+:} false; then : +if test "${ac_cv_lib_pthreads_pthread_create+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS @@ -9316,7 +8706,7 @@ fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_pthreads_pthread_create" >&5 $as_echo "$ac_cv_lib_pthreads_pthread_create" >&6; } -if test "x$ac_cv_lib_pthreads_pthread_create" = xyes; then : +if test "x$ac_cv_lib_pthreads_pthread_create" = x""yes; then : $as_echo "#define WITH_THREAD 1" >>confdefs.h posix_threads=yes @@ -9326,7 +8716,7 @@ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pthread_create in -lc_r" >&5 $as_echo_n "checking for pthread_create in -lc_r... " >&6; } -if ${ac_cv_lib_c_r_pthread_create+:} false; then : +if test "${ac_cv_lib_c_r_pthread_create+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS @@ -9360,7 +8750,7 @@ fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_c_r_pthread_create" >&5 $as_echo "$ac_cv_lib_c_r_pthread_create" >&6; } -if test "x$ac_cv_lib_c_r_pthread_create" = xyes; then : +if test "x$ac_cv_lib_c_r_pthread_create" = x""yes; then : $as_echo "#define WITH_THREAD 1" >>confdefs.h posix_threads=yes @@ -9370,7 +8760,7 @@ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for __pthread_create_system in -lpthread" >&5 $as_echo_n "checking for __pthread_create_system in -lpthread... " >&6; } -if ${ac_cv_lib_pthread___pthread_create_system+:} false; then : +if test "${ac_cv_lib_pthread___pthread_create_system+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS @@ -9404,7 +8794,7 @@ fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_pthread___pthread_create_system" >&5 $as_echo "$ac_cv_lib_pthread___pthread_create_system" >&6; } -if test "x$ac_cv_lib_pthread___pthread_create_system" = xyes; then : +if test "x$ac_cv_lib_pthread___pthread_create_system" = x""yes; then : $as_echo "#define WITH_THREAD 1" >>confdefs.h posix_threads=yes @@ -9414,7 +8804,7 @@ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pthread_create in -lcma" >&5 $as_echo_n "checking for pthread_create in -lcma... " >&6; } -if ${ac_cv_lib_cma_pthread_create+:} false; then : +if test "${ac_cv_lib_cma_pthread_create+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS @@ -9448,7 +8838,7 @@ fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_cma_pthread_create" >&5 $as_echo "$ac_cv_lib_cma_pthread_create" >&6; } -if test "x$ac_cv_lib_cma_pthread_create" = xyes; then : +if test "x$ac_cv_lib_cma_pthread_create" = x""yes; then : $as_echo "#define WITH_THREAD 1" >>confdefs.h posix_threads=yes @@ -9488,7 +8878,7 @@ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for usconfig in -lmpc" >&5 $as_echo_n "checking for usconfig in -lmpc... " >&6; } -if ${ac_cv_lib_mpc_usconfig+:} false; then : +if test "${ac_cv_lib_mpc_usconfig+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS @@ -9522,7 +8912,7 @@ fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_mpc_usconfig" >&5 $as_echo "$ac_cv_lib_mpc_usconfig" >&6; } -if test "x$ac_cv_lib_mpc_usconfig" = xyes; then : +if test "x$ac_cv_lib_mpc_usconfig" = x""yes; then : $as_echo "#define WITH_THREAD 1" >>confdefs.h LIBS="$LIBS -lmpc" @@ -9534,7 +8924,7 @@ if test "$posix_threads" != "yes"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for thr_create in -lthread" >&5 $as_echo_n "checking for thr_create in -lthread... " >&6; } -if ${ac_cv_lib_thread_thr_create+:} false; then : +if test "${ac_cv_lib_thread_thr_create+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS @@ -9568,7 +8958,7 @@ fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_thread_thr_create" >&5 $as_echo "$ac_cv_lib_thread_thr_create" >&6; } -if test "x$ac_cv_lib_thread_thr_create" = xyes; then : +if test "x$ac_cv_lib_thread_thr_create" = x""yes; then : $as_echo "#define WITH_THREAD 1" >>confdefs.h LIBS="$LIBS -lthread" @@ -9613,7 +9003,7 @@ { $as_echo "$as_me:${as_lineno-$LINENO}: checking if PTHREAD_SCOPE_SYSTEM is supported" >&5 $as_echo_n "checking if PTHREAD_SCOPE_SYSTEM is supported... " >&6; } - if ${ac_cv_pthread_system_supported+:} false; then : + if test "${ac_cv_pthread_system_supported+set}" = set; then : $as_echo_n "(cached) " >&6 else if test "$cross_compiling" = yes; then : @@ -9621,9 +9011,7 @@ else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ - - #include - #include +#include void *foo(void *parm) { return NULL; } @@ -9658,7 +9046,7 @@ for ac_func in pthread_sigmask do : ac_fn_c_check_func "$LINENO" "pthread_sigmask" "ac_cv_func_pthread_sigmask" -if test "x$ac_cv_func_pthread_sigmask" = xyes; then : +if test "x$ac_cv_func_pthread_sigmask" = x""yes; then : cat >>confdefs.h <<_ACEOF #define HAVE_PTHREAD_SIGMASK 1 _ACEOF @@ -9672,17 +9060,6 @@ fi done - for ac_func in pthread_atfork -do : - ac_fn_c_check_func "$LINENO" "pthread_atfork" "ac_cv_func_pthread_atfork" -if test "x$ac_cv_func_pthread_atfork" = xyes; then : - cat >>confdefs.h <<_ACEOF -#define HAVE_PTHREAD_ATFORK 1 -_ACEOF - -fi -done - fi @@ -9707,20 +9084,28 @@ esac else + if test "$cross_compiling" = yes; then : + + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + ipv6=no + +else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* AF_INET6 available check */ #include #include -int -main () -{ -int domain = AF_INET6; - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : +main() +{ + if (socket(AF_INET6, SOCK_STREAM, 0) < 0) + exit(1); + else + exit(0); +} + +_ACEOF +if ac_fn_c_try_run "$LINENO"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } @@ -9733,7 +9118,10 @@ ipv6=no fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext +fi + if test "$ipv6" = "yes"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking if RFC2553 API is available" >&5 @@ -10048,7 +9436,7 @@ $as_echo "$with_valgrind" >&6; } if test "$with_valgrind" != no; then ac_fn_c_check_header_mongrel "$LINENO" "valgrind/valgrind.h" "ac_cv_header_valgrind_valgrind_h" "$ac_includes_default" -if test "x$ac_cv_header_valgrind_valgrind_h" = xyes; then : +if test "x$ac_cv_header_valgrind_valgrind_h" = x""yes; then : $as_echo "#define WITH_VALGRIND 1" >>confdefs.h @@ -10092,7 +9480,7 @@ for ac_func in dlopen do : ac_fn_c_check_func "$LINENO" "dlopen" "ac_cv_func_dlopen" -if test "x$ac_cv_func_dlopen" = xyes; then : +if test "x$ac_cv_func_dlopen" = x""yes; then : cat >>confdefs.h <<_ACEOF #define HAVE_DLOPEN 1 _ACEOF @@ -10158,7 +9546,7 @@ clock confstr ctermid execv fchmod fchown fork fpathconf ftime ftruncate \ gai_strerror getgroups getlogin getloadavg getpeername getpgid getpid \ getpriority getresuid getresgid getpwent getspnam getspent getsid getwd \ - initgroups kill killpg lchmod lchown lstat mkfifo mknod mktime mmap \ + initgroups kill killpg lchmod lchown lstat mkfifo mknod mktime \ mremap nice pathconf pause plock poll pthread_init \ putenv readlink realpath \ select sem_open sem_timedwait sem_getvalue sem_unlink setegid seteuid \ @@ -10422,7 +9810,7 @@ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for flock declaration" >&5 $as_echo_n "checking for flock declaration... " >&6; } -if ${ac_cv_flock_decl+:} false; then : +if test "${ac_cv_flock_decl+set}" = set; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext @@ -10452,7 +9840,7 @@ for ac_func in flock do : ac_fn_c_check_func "$LINENO" "flock" "ac_cv_func_flock" -if test "x$ac_cv_func_flock" = xyes; then : +if test "x$ac_cv_func_flock" = x""yes; then : cat >>confdefs.h <<_ACEOF #define HAVE_FLOCK 1 _ACEOF @@ -10460,7 +9848,7 @@ else { $as_echo "$as_me:${as_lineno-$LINENO}: checking for flock in -lbsd" >&5 $as_echo_n "checking for flock in -lbsd... " >&6; } -if ${ac_cv_lib_bsd_flock+:} false; then : +if test "${ac_cv_lib_bsd_flock+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS @@ -10494,7 +9882,7 @@ fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_bsd_flock" >&5 $as_echo "$ac_cv_lib_bsd_flock" >&6; } -if test "x$ac_cv_lib_bsd_flock" = xyes; then : +if test "x$ac_cv_lib_bsd_flock" = x""yes; then : $as_echo "#define HAVE_FLOCK 1" >>confdefs.h @@ -10571,7 +9959,7 @@ set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_TRUE+:} false; then : +if test "${ac_cv_prog_TRUE+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$TRUE"; then @@ -10583,7 +9971,7 @@ IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_TRUE="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -10611,7 +9999,7 @@ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for inet_aton in -lc" >&5 $as_echo_n "checking for inet_aton in -lc... " >&6; } -if ${ac_cv_lib_c_inet_aton+:} false; then : +if test "${ac_cv_lib_c_inet_aton+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS @@ -10645,12 +10033,12 @@ fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_c_inet_aton" >&5 $as_echo "$ac_cv_lib_c_inet_aton" >&6; } -if test "x$ac_cv_lib_c_inet_aton" = xyes; then : +if test "x$ac_cv_lib_c_inet_aton" = x""yes; then : $ac_cv_prog_TRUE else { $as_echo "$as_me:${as_lineno-$LINENO}: checking for inet_aton in -lresolv" >&5 $as_echo_n "checking for inet_aton in -lresolv... " >&6; } -if ${ac_cv_lib_resolv_inet_aton+:} false; then : +if test "${ac_cv_lib_resolv_inet_aton+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS @@ -10684,7 +10072,7 @@ fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_resolv_inet_aton" >&5 $as_echo "$ac_cv_lib_resolv_inet_aton" >&6; } -if test "x$ac_cv_lib_resolv_inet_aton" = xyes; then : +if test "x$ac_cv_lib_resolv_inet_aton" = x""yes; then : cat >>confdefs.h <<_ACEOF #define HAVE_LIBRESOLV 1 _ACEOF @@ -10701,7 +10089,7 @@ # exit Python { $as_echo "$as_me:${as_lineno-$LINENO}: checking for chflags" >&5 $as_echo_n "checking for chflags... " >&6; } -if ${ac_cv_have_chflags+:} false; then : +if test "${ac_cv_have_chflags+set}" = set; then : $as_echo_n "(cached) " >&6 else if test "$cross_compiling" = yes; then : @@ -10735,7 +10123,7 @@ $as_echo "$ac_cv_have_chflags" >&6; } if test "$ac_cv_have_chflags" = cross ; then ac_fn_c_check_func "$LINENO" "chflags" "ac_cv_func_chflags" -if test "x$ac_cv_func_chflags" = xyes; then : +if test "x$ac_cv_func_chflags" = x""yes; then : ac_cv_have_chflags="yes" else ac_cv_have_chflags="no" @@ -10750,7 +10138,7 @@ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for lchflags" >&5 $as_echo_n "checking for lchflags... " >&6; } -if ${ac_cv_have_lchflags+:} false; then : +if test "${ac_cv_have_lchflags+set}" = set; then : $as_echo_n "(cached) " >&6 else if test "$cross_compiling" = yes; then : @@ -10784,7 +10172,7 @@ $as_echo "$ac_cv_have_lchflags" >&6; } if test "$ac_cv_have_lchflags" = cross ; then ac_fn_c_check_func "$LINENO" "lchflags" "ac_cv_func_lchflags" -if test "x$ac_cv_func_lchflags" = xyes; then : +if test "x$ac_cv_func_lchflags" = x""yes; then : ac_cv_have_lchflags="yes" else ac_cv_have_lchflags="no" @@ -10808,7 +10196,7 @@ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for inflateCopy in -lz" >&5 $as_echo_n "checking for inflateCopy in -lz... " >&6; } -if ${ac_cv_lib_z_inflateCopy+:} false; then : +if test "${ac_cv_lib_z_inflateCopy+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS @@ -10842,7 +10230,7 @@ fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_z_inflateCopy" >&5 $as_echo "$ac_cv_lib_z_inflateCopy" >&6; } -if test "x$ac_cv_lib_z_inflateCopy" = xyes; then : +if test "x$ac_cv_lib_z_inflateCopy" = x""yes; then : $as_echo "#define HAVE_ZLIB_COPY 1" >>confdefs.h @@ -10985,7 +10373,7 @@ for ac_func in openpty do : ac_fn_c_check_func "$LINENO" "openpty" "ac_cv_func_openpty" -if test "x$ac_cv_func_openpty" = xyes; then : +if test "x$ac_cv_func_openpty" = x""yes; then : cat >>confdefs.h <<_ACEOF #define HAVE_OPENPTY 1 _ACEOF @@ -10993,7 +10381,7 @@ else { $as_echo "$as_me:${as_lineno-$LINENO}: checking for openpty in -lutil" >&5 $as_echo_n "checking for openpty in -lutil... " >&6; } -if ${ac_cv_lib_util_openpty+:} false; then : +if test "${ac_cv_lib_util_openpty+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS @@ -11027,13 +10415,13 @@ fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_util_openpty" >&5 $as_echo "$ac_cv_lib_util_openpty" >&6; } -if test "x$ac_cv_lib_util_openpty" = xyes; then : +if test "x$ac_cv_lib_util_openpty" = x""yes; then : $as_echo "#define HAVE_OPENPTY 1" >>confdefs.h LIBS="$LIBS -lutil" else { $as_echo "$as_me:${as_lineno-$LINENO}: checking for openpty in -lbsd" >&5 $as_echo_n "checking for openpty in -lbsd... " >&6; } -if ${ac_cv_lib_bsd_openpty+:} false; then : +if test "${ac_cv_lib_bsd_openpty+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS @@ -11067,7 +10455,7 @@ fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_bsd_openpty" >&5 $as_echo "$ac_cv_lib_bsd_openpty" >&6; } -if test "x$ac_cv_lib_bsd_openpty" = xyes; then : +if test "x$ac_cv_lib_bsd_openpty" = x""yes; then : $as_echo "#define HAVE_OPENPTY 1" >>confdefs.h LIBS="$LIBS -lbsd" fi @@ -11082,7 +10470,7 @@ for ac_func in forkpty do : ac_fn_c_check_func "$LINENO" "forkpty" "ac_cv_func_forkpty" -if test "x$ac_cv_func_forkpty" = xyes; then : +if test "x$ac_cv_func_forkpty" = x""yes; then : cat >>confdefs.h <<_ACEOF #define HAVE_FORKPTY 1 _ACEOF @@ -11090,7 +10478,7 @@ else { $as_echo "$as_me:${as_lineno-$LINENO}: checking for forkpty in -lutil" >&5 $as_echo_n "checking for forkpty in -lutil... " >&6; } -if ${ac_cv_lib_util_forkpty+:} false; then : +if test "${ac_cv_lib_util_forkpty+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS @@ -11124,13 +10512,13 @@ fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_util_forkpty" >&5 $as_echo "$ac_cv_lib_util_forkpty" >&6; } -if test "x$ac_cv_lib_util_forkpty" = xyes; then : +if test "x$ac_cv_lib_util_forkpty" = x""yes; then : $as_echo "#define HAVE_FORKPTY 1" >>confdefs.h LIBS="$LIBS -lutil" else { $as_echo "$as_me:${as_lineno-$LINENO}: checking for forkpty in -lbsd" >&5 $as_echo_n "checking for forkpty in -lbsd... " >&6; } -if ${ac_cv_lib_bsd_forkpty+:} false; then : +if test "${ac_cv_lib_bsd_forkpty+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS @@ -11164,7 +10552,7 @@ fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_bsd_forkpty" >&5 $as_echo "$ac_cv_lib_bsd_forkpty" >&6; } -if test "x$ac_cv_lib_bsd_forkpty" = xyes; then : +if test "x$ac_cv_lib_bsd_forkpty" = x""yes; then : $as_echo "#define HAVE_FORKPTY 1" >>confdefs.h LIBS="$LIBS -lbsd" fi @@ -11181,7 +10569,7 @@ for ac_func in memmove do : ac_fn_c_check_func "$LINENO" "memmove" "ac_cv_func_memmove" -if test "x$ac_cv_func_memmove" = xyes; then : +if test "x$ac_cv_func_memmove" = x""yes; then : cat >>confdefs.h <<_ACEOF #define HAVE_MEMMOVE 1 _ACEOF @@ -11205,7 +10593,7 @@ ac_fn_c_check_func "$LINENO" "dup2" "ac_cv_func_dup2" -if test "x$ac_cv_func_dup2" = xyes; then : +if test "x$ac_cv_func_dup2" = x""yes; then : $as_echo "#define HAVE_DUP2 1" >>confdefs.h else @@ -11218,7 +10606,7 @@ fi ac_fn_c_check_func "$LINENO" "getcwd" "ac_cv_func_getcwd" -if test "x$ac_cv_func_getcwd" = xyes; then : +if test "x$ac_cv_func_getcwd" = x""yes; then : $as_echo "#define HAVE_GETCWD 1" >>confdefs.h else @@ -11231,7 +10619,7 @@ fi ac_fn_c_check_func "$LINENO" "strdup" "ac_cv_func_strdup" -if test "x$ac_cv_func_strdup" = xyes; then : +if test "x$ac_cv_func_strdup" = x""yes; then : $as_echo "#define HAVE_STRDUP 1" >>confdefs.h else @@ -11247,7 +10635,7 @@ for ac_func in getpgrp do : ac_fn_c_check_func "$LINENO" "getpgrp" "ac_cv_func_getpgrp" -if test "x$ac_cv_func_getpgrp" = xyes; then : +if test "x$ac_cv_func_getpgrp" = x""yes; then : cat >>confdefs.h <<_ACEOF #define HAVE_GETPGRP 1 _ACEOF @@ -11275,7 +10663,7 @@ for ac_func in setpgrp do : ac_fn_c_check_func "$LINENO" "setpgrp" "ac_cv_func_setpgrp" -if test "x$ac_cv_func_setpgrp" = xyes; then : +if test "x$ac_cv_func_setpgrp" = x""yes; then : cat >>confdefs.h <<_ACEOF #define HAVE_SETPGRP 1 _ACEOF @@ -11303,7 +10691,7 @@ for ac_func in gettimeofday do : ac_fn_c_check_func "$LINENO" "gettimeofday" "ac_cv_func_gettimeofday" -if test "x$ac_cv_func_gettimeofday" = xyes; then : +if test "x$ac_cv_func_gettimeofday" = x""yes; then : cat >>confdefs.h <<_ACEOF #define HAVE_GETTIMEOFDAY 1 _ACEOF @@ -11405,21 +10793,15 @@ then { $as_echo "$as_me:${as_lineno-$LINENO}: checking getaddrinfo bug" >&5 $as_echo_n "checking getaddrinfo bug... " >&6; } - if ${ac_cv_buggy_getaddrinfo+:} false; then : + if test "${ac_cv_buggy_getaddrinfo+set}" = set; then : $as_echo_n "(cached) " >&6 else if test "$cross_compiling" = yes; then : - -if test "${enable_ipv6+set}" = set; then - ac_cv_buggy_getaddrinfo="no -- configured with --(en|dis)able-ipv6" -else ac_cv_buggy_getaddrinfo=yes -fi -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -#include +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + #include #include #include @@ -11540,7 +10922,7 @@ for ac_func in getnameinfo do : ac_fn_c_check_func "$LINENO" "getnameinfo" "ac_cv_func_getnameinfo" -if test "x$ac_cv_func_getnameinfo" = xyes; then : +if test "x$ac_cv_func_getnameinfo" = x""yes; then : cat >>confdefs.h <<_ACEOF #define HAVE_GETNAMEINFO 1 _ACEOF @@ -11552,7 +10934,7 @@ # checks for structures { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether time.h and sys/time.h may both be included" >&5 $as_echo_n "checking whether time.h and sys/time.h may both be included... " >&6; } -if ${ac_cv_header_time+:} false; then : +if test "${ac_cv_header_time+set}" = set; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext @@ -11587,7 +10969,7 @@ { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether struct tm is in sys/time.h or time.h" >&5 $as_echo_n "checking whether struct tm is in sys/time.h or time.h... " >&6; } -if ${ac_cv_struct_tm+:} false; then : +if test "${ac_cv_struct_tm+set}" = set; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext @@ -11624,7 +11006,7 @@ #include <$ac_cv_struct_tm> " -if test "x$ac_cv_member_struct_tm_tm_zone" = xyes; then : +if test "x$ac_cv_member_struct_tm_tm_zone" = x""yes; then : cat >>confdefs.h <<_ACEOF #define HAVE_STRUCT_TM_TM_ZONE 1 @@ -11640,7 +11022,7 @@ else ac_fn_c_check_decl "$LINENO" "tzname" "ac_cv_have_decl_tzname" "#include " -if test "x$ac_cv_have_decl_tzname" = xyes; then : +if test "x$ac_cv_have_decl_tzname" = x""yes; then : ac_have_decl=1 else ac_have_decl=0 @@ -11652,7 +11034,7 @@ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for tzname" >&5 $as_echo_n "checking for tzname... " >&6; } -if ${ac_cv_var_tzname+:} false; then : +if test "${ac_cv_var_tzname+set}" = set; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext @@ -11688,7 +11070,7 @@ fi ac_fn_c_check_member "$LINENO" "struct stat" "st_rdev" "ac_cv_member_struct_stat_st_rdev" "$ac_includes_default" -if test "x$ac_cv_member_struct_stat_st_rdev" = xyes; then : +if test "x$ac_cv_member_struct_stat_st_rdev" = x""yes; then : cat >>confdefs.h <<_ACEOF #define HAVE_STRUCT_STAT_ST_RDEV 1 @@ -11698,7 +11080,7 @@ fi ac_fn_c_check_member "$LINENO" "struct stat" "st_blksize" "ac_cv_member_struct_stat_st_blksize" "$ac_includes_default" -if test "x$ac_cv_member_struct_stat_st_blksize" = xyes; then : +if test "x$ac_cv_member_struct_stat_st_blksize" = x""yes; then : cat >>confdefs.h <<_ACEOF #define HAVE_STRUCT_STAT_ST_BLKSIZE 1 @@ -11708,7 +11090,7 @@ fi ac_fn_c_check_member "$LINENO" "struct stat" "st_flags" "ac_cv_member_struct_stat_st_flags" "$ac_includes_default" -if test "x$ac_cv_member_struct_stat_st_flags" = xyes; then : +if test "x$ac_cv_member_struct_stat_st_flags" = x""yes; then : cat >>confdefs.h <<_ACEOF #define HAVE_STRUCT_STAT_ST_FLAGS 1 @@ -11718,7 +11100,7 @@ fi ac_fn_c_check_member "$LINENO" "struct stat" "st_gen" "ac_cv_member_struct_stat_st_gen" "$ac_includes_default" -if test "x$ac_cv_member_struct_stat_st_gen" = xyes; then : +if test "x$ac_cv_member_struct_stat_st_gen" = x""yes; then : cat >>confdefs.h <<_ACEOF #define HAVE_STRUCT_STAT_ST_GEN 1 @@ -11728,7 +11110,7 @@ fi ac_fn_c_check_member "$LINENO" "struct stat" "st_birthtime" "ac_cv_member_struct_stat_st_birthtime" "$ac_includes_default" -if test "x$ac_cv_member_struct_stat_st_birthtime" = xyes; then : +if test "x$ac_cv_member_struct_stat_st_birthtime" = x""yes; then : cat >>confdefs.h <<_ACEOF #define HAVE_STRUCT_STAT_ST_BIRTHTIME 1 @@ -11738,7 +11120,7 @@ fi ac_fn_c_check_member "$LINENO" "struct stat" "st_blocks" "ac_cv_member_struct_stat_st_blocks" "$ac_includes_default" -if test "x$ac_cv_member_struct_stat_st_blocks" = xyes; then : +if test "x$ac_cv_member_struct_stat_st_blocks" = x""yes; then : cat >>confdefs.h <<_ACEOF #define HAVE_STRUCT_STAT_ST_BLOCKS 1 @@ -11760,7 +11142,7 @@ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for time.h that defines altzone" >&5 $as_echo_n "checking for time.h that defines altzone... " >&6; } -if ${ac_cv_header_time_altzone+:} false; then : +if test "${ac_cv_header_time_altzone+set}" = set; then : $as_echo_n "(cached) " >&6 else @@ -11824,7 +11206,7 @@ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for addrinfo" >&5 $as_echo_n "checking for addrinfo... " >&6; } -if ${ac_cv_struct_addrinfo+:} false; then : +if test "${ac_cv_struct_addrinfo+set}" = set; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext @@ -11856,7 +11238,7 @@ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for sockaddr_storage" >&5 $as_echo_n "checking for sockaddr_storage... " >&6; } -if ${ac_cv_struct_sockaddr_storage+:} false; then : +if test "${ac_cv_struct_sockaddr_storage+set}" = set; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext @@ -11892,7 +11274,7 @@ { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether char is unsigned" >&5 $as_echo_n "checking whether char is unsigned... " >&6; } -if ${ac_cv_c_char_unsigned+:} false; then : +if test "${ac_cv_c_char_unsigned+set}" = set; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext @@ -11902,8 +11284,7 @@ main () { static int test_array [1 - 2 * !(((char) -1) < 0)]; -test_array [0] = 0; -return test_array [0]; +test_array [0] = 0 ; return 0; @@ -11925,20 +11306,20 @@ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for an ANSI C-conforming const" >&5 $as_echo_n "checking for an ANSI C-conforming const... " >&6; } -if ${ac_cv_c_const+:} false; then : - $as_echo_n "(cached) " >&6 -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ - +if test "${ac_cv_c_const+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ +/* FIXME: Include the comments suggested by Paul. */ #ifndef __cplusplus - /* Ultrix mips cc rejects this sort of thing. */ + /* Ultrix mips cc rejects this. */ typedef int charset[2]; - const charset cs = { 0, 0 }; + const charset cs; /* SunOS 4.1.1 cc rejects this. */ char const *const *pcpcc; char **ppc; @@ -11955,9 +11336,8 @@ ++pcpcc; ppc = (char**) pcpcc; pcpcc = (char const *const *) ppc; - { /* SCO 3.2v4 cc rejects this sort of thing. */ - char tx; - char *t = &tx; + { /* SCO 3.2v4 cc rejects this. */ + char *t; char const *s = 0 ? (char *) 0 : (char const *) 0; *t++ = 0; @@ -11973,10 +11353,10 @@ iptr p = 0; ++p; } - { /* AIX XL C 1.02.0.0 rejects this sort of thing, saying + { /* AIX XL C 1.02.0.0 rejects this saying "k.c", line 2.27: 1506-025 (S) Operand must be a modifiable lvalue. */ - struct s { int j; const int *ap[3]; } bx; - struct s *b = &bx; b->j = 5; + struct s { int j; const int *ap[3]; }; + struct s *b; b->j = 5; } { /* ULTRIX-32 V3.1 (Rev 9) vcc rejects this */ const int foo = 10; @@ -12214,7 +11594,7 @@ ac_fn_c_check_func "$LINENO" "gethostbyname_r" "ac_cv_func_gethostbyname_r" -if test "x$ac_cv_func_gethostbyname_r" = xyes; then : +if test "x$ac_cv_func_gethostbyname_r" = x""yes; then : $as_echo "#define HAVE_GETHOSTBYNAME_R 1" >>confdefs.h @@ -12345,7 +11725,7 @@ for ac_func in gethostbyname do : ac_fn_c_check_func "$LINENO" "gethostbyname" "ac_cv_func_gethostbyname" -if test "x$ac_cv_func_gethostbyname" = xyes; then : +if test "x$ac_cv_func_gethostbyname" = x""yes; then : cat >>confdefs.h <<_ACEOF #define HAVE_GETHOSTBYNAME 1 _ACEOF @@ -12367,12 +11747,12 @@ # Linux requires this for correct f.p. operations ac_fn_c_check_func "$LINENO" "__fpu_control" "ac_cv_func___fpu_control" -if test "x$ac_cv_func___fpu_control" = xyes; then : +if test "x$ac_cv_func___fpu_control" = x""yes; then : else { $as_echo "$as_me:${as_lineno-$LINENO}: checking for __fpu_control in -lieee" >&5 $as_echo_n "checking for __fpu_control in -lieee... " >&6; } -if ${ac_cv_lib_ieee___fpu_control+:} false; then : +if test "${ac_cv_lib_ieee___fpu_control+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS @@ -12406,7 +11786,7 @@ fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_ieee___fpu_control" >&5 $as_echo "$ac_cv_lib_ieee___fpu_control" >&6; } -if test "x$ac_cv_lib_ieee___fpu_control" = xyes; then : +if test "x$ac_cv_lib_ieee___fpu_control" = x""yes; then : cat >>confdefs.h <<_ACEOF #define HAVE_LIBIEEE 1 _ACEOF @@ -12501,7 +11881,7 @@ { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether C doubles are little-endian IEEE 754 binary64" >&5 $as_echo_n "checking whether C doubles are little-endian IEEE 754 binary64... " >&6; } -if ${ac_cv_little_endian_double+:} false; then : +if test "${ac_cv_little_endian_double+set}" = set; then : $as_echo_n "(cached) " >&6 else @@ -12543,7 +11923,7 @@ { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether C doubles are big-endian IEEE 754 binary64" >&5 $as_echo_n "checking whether C doubles are big-endian IEEE 754 binary64... " >&6; } -if ${ac_cv_big_endian_double+:} false; then : +if test "${ac_cv_big_endian_double+set}" = set; then : $as_echo_n "(cached) " >&6 else @@ -12589,7 +11969,7 @@ # conversions work. { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether C doubles are ARM mixed-endian IEEE 754 binary64" >&5 $as_echo_n "checking whether C doubles are ARM mixed-endian IEEE 754 binary64... " >&6; } -if ${ac_cv_mixed_endian_double+:} false; then : +if test "${ac_cv_mixed_endian_double+set}" = set; then : $as_echo_n "(cached) " >&6 else @@ -12737,7 +12117,7 @@ # -0. on some architectures. { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether tanh preserves the sign of zero" >&5 $as_echo_n "checking whether tanh preserves the sign of zero... " >&6; } -if ${ac_cv_tanh_preserves_zero_sign+:} false; then : +if test "${ac_cv_tanh_preserves_zero_sign+set}" = set; then : $as_echo_n "(cached) " >&6 else @@ -12805,7 +12185,7 @@ ac_fn_c_check_decl "$LINENO" "isinf" "ac_cv_have_decl_isinf" "#include " -if test "x$ac_cv_have_decl_isinf" = xyes; then : +if test "x$ac_cv_have_decl_isinf" = x""yes; then : ac_have_decl=1 else ac_have_decl=0 @@ -12816,7 +12196,7 @@ _ACEOF ac_fn_c_check_decl "$LINENO" "isnan" "ac_cv_have_decl_isnan" "#include " -if test "x$ac_cv_have_decl_isnan" = xyes; then : +if test "x$ac_cv_have_decl_isnan" = x""yes; then : ac_have_decl=1 else ac_have_decl=0 @@ -12827,7 +12207,7 @@ _ACEOF ac_fn_c_check_decl "$LINENO" "isfinite" "ac_cv_have_decl_isfinite" "#include " -if test "x$ac_cv_have_decl_isfinite" = xyes; then : +if test "x$ac_cv_have_decl_isfinite" = x""yes; then : ac_have_decl=1 else ac_have_decl=0 @@ -12847,7 +12227,7 @@ # sem_open results in a 'Signal 12' error. { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether POSIX semaphores are enabled" >&5 $as_echo_n "checking whether POSIX semaphores are enabled... " >&6; } -if ${ac_cv_posix_semaphores_enabled+:} false; then : +if test "${ac_cv_posix_semaphores_enabled+set}" = set; then : $as_echo_n "(cached) " >&6 else if test "$cross_compiling" = yes; then : @@ -12898,7 +12278,7 @@ # Multiprocessing check for broken sem_getvalue { $as_echo "$as_me:${as_lineno-$LINENO}: checking for broken sem_getvalue" >&5 $as_echo_n "checking for broken sem_getvalue... " >&6; } -if ${ac_cv_broken_sem_getvalue+:} false; then : +if test "${ac_cv_broken_sem_getvalue+set}" = set; then : $as_echo_n "(cached) " >&6 else if test "$cross_compiling" = yes; then : @@ -12963,7 +12343,7 @@ 15|30) ;; *) - as_fn_error $? "bad value $enable_big_digits for --enable-big-digits; value should be 15 or 30" "$LINENO" 5 ;; + as_fn_error $? "bad value $enable_big_digits for --enable-big-digits; value should be 15 or 30" "$LINENO" 5 ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: result: $enable_big_digits" >&5 $as_echo "$enable_big_digits" >&6; } @@ -12981,7 +12361,7 @@ # check for wchar.h ac_fn_c_check_header_mongrel "$LINENO" "wchar.h" "ac_cv_header_wchar_h" "$ac_includes_default" -if test "x$ac_cv_header_wchar_h" = xyes; then : +if test "x$ac_cv_header_wchar_h" = x""yes; then : $as_echo "#define HAVE_WCHAR_H 1" >>confdefs.h @@ -13004,7 +12384,7 @@ # This bug is HP SR number 8606223364. { $as_echo "$as_me:${as_lineno-$LINENO}: checking size of wchar_t" >&5 $as_echo_n "checking size of wchar_t... " >&6; } -if ${ac_cv_sizeof_wchar_t+:} false; then : +if test "${ac_cv_sizeof_wchar_t+set}" = set; then : $as_echo_n "(cached) " >&6 else if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (wchar_t))" "ac_cv_sizeof_wchar_t" "#include @@ -13015,7 +12395,7 @@ { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error 77 "cannot compute sizeof (wchar_t) -See \`config.log' for more details" "$LINENO" 5; } +See \`config.log' for more details" "$LINENO" 5 ; } else ac_cv_sizeof_wchar_t=0 fi @@ -13070,7 +12450,7 @@ # check whether wchar_t is signed or not { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether wchar_t is signed" >&5 $as_echo_n "checking whether wchar_t is signed... " >&6; } - if ${ac_cv_wchar_t_signed+:} false; then : + if test "${ac_cv_wchar_t_signed+set}" = set; then : $as_echo_n "(cached) " >&6 else @@ -13134,8 +12514,7 @@ $as_echo "#define Py_UNICODE_SIZE 4" >>confdefs.h ;; -no) ;; # To allow --disable-unicode -*) as_fn_error $? "invalid value for --enable-unicode. Use either ucs2 or ucs4 (lowercase)." "$LINENO" 5 ;; +*) as_fn_error $? "invalid value for --enable-unicode. Use either ucs2 or ucs4 (lowercase)." "$LINENO" 5 ;; esac @@ -13182,7 +12561,7 @@ # check for endianness { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether byte ordering is bigendian" >&5 $as_echo_n "checking whether byte ordering is bigendian... " >&6; } -if ${ac_cv_c_bigendian+:} false; then : +if test "${ac_cv_c_bigendian+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_cv_c_bigendian=unknown @@ -13401,7 +12780,7 @@ ;; #( *) as_fn_error $? "unknown endianness - presetting ac_cv_c_bigendian=no (or yes) will help" "$LINENO" 5 ;; + presetting ac_cv_c_bigendian=no (or yes) will help" "$LINENO" 5 ;; esac @@ -13409,7 +12788,7 @@ # or fills with zeros (like the Cray J90, according to Tim Peters). { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether right shift extends the sign bit" >&5 $as_echo_n "checking whether right shift extends the sign bit... " >&6; } -if ${ac_cv_rshift_extends_sign+:} false; then : +if test "${ac_cv_rshift_extends_sign+set}" = set; then : $as_echo_n "(cached) " >&6 else @@ -13448,7 +12827,7 @@ # check for getc_unlocked and related locking functions { $as_echo "$as_me:${as_lineno-$LINENO}: checking for getc_unlocked() and friends" >&5 $as_echo_n "checking for getc_unlocked() and friends... " >&6; } -if ${ac_cv_have_getc_unlocked+:} false; then : +if test "${ac_cv_have_getc_unlocked+set}" = set; then : $as_echo_n "(cached) " >&6 else @@ -13546,7 +12925,7 @@ # check for readline 2.1 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for rl_callback_handler_install in -lreadline" >&5 $as_echo_n "checking for rl_callback_handler_install in -lreadline... " >&6; } -if ${ac_cv_lib_readline_rl_callback_handler_install+:} false; then : +if test "${ac_cv_lib_readline_rl_callback_handler_install+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS @@ -13580,7 +12959,7 @@ fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_readline_rl_callback_handler_install" >&5 $as_echo "$ac_cv_lib_readline_rl_callback_handler_install" >&6; } -if test "x$ac_cv_lib_readline_rl_callback_handler_install" = xyes; then : +if test "x$ac_cv_lib_readline_rl_callback_handler_install" = x""yes; then : $as_echo "#define HAVE_RL_CALLBACK 1" >>confdefs.h @@ -13632,7 +13011,7 @@ # check for readline 4.0 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for rl_pre_input_hook in -lreadline" >&5 $as_echo_n "checking for rl_pre_input_hook in -lreadline... " >&6; } -if ${ac_cv_lib_readline_rl_pre_input_hook+:} false; then : +if test "${ac_cv_lib_readline_rl_pre_input_hook+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS @@ -13666,7 +13045,7 @@ fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_readline_rl_pre_input_hook" >&5 $as_echo "$ac_cv_lib_readline_rl_pre_input_hook" >&6; } -if test "x$ac_cv_lib_readline_rl_pre_input_hook" = xyes; then : +if test "x$ac_cv_lib_readline_rl_pre_input_hook" = x""yes; then : $as_echo "#define HAVE_RL_PRE_INPUT_HOOK 1" >>confdefs.h @@ -13676,7 +13055,7 @@ # also in 4.0 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for rl_completion_display_matches_hook in -lreadline" >&5 $as_echo_n "checking for rl_completion_display_matches_hook in -lreadline... " >&6; } -if ${ac_cv_lib_readline_rl_completion_display_matches_hook+:} false; then : +if test "${ac_cv_lib_readline_rl_completion_display_matches_hook+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS @@ -13710,7 +13089,7 @@ fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_readline_rl_completion_display_matches_hook" >&5 $as_echo "$ac_cv_lib_readline_rl_completion_display_matches_hook" >&6; } -if test "x$ac_cv_lib_readline_rl_completion_display_matches_hook" = xyes; then : +if test "x$ac_cv_lib_readline_rl_completion_display_matches_hook" = x""yes; then : $as_echo "#define HAVE_RL_COMPLETION_DISPLAY_MATCHES_HOOK 1" >>confdefs.h @@ -13720,7 +13099,7 @@ # check for readline 4.2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for rl_completion_matches in -lreadline" >&5 $as_echo_n "checking for rl_completion_matches in -lreadline... " >&6; } -if ${ac_cv_lib_readline_rl_completion_matches+:} false; then : +if test "${ac_cv_lib_readline_rl_completion_matches+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS @@ -13754,7 +13133,7 @@ fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_readline_rl_completion_matches" >&5 $as_echo "$ac_cv_lib_readline_rl_completion_matches" >&6; } -if test "x$ac_cv_lib_readline_rl_completion_matches" = xyes; then : +if test "x$ac_cv_lib_readline_rl_completion_matches" = x""yes; then : $as_echo "#define HAVE_RL_COMPLETION_MATCHES 1" >>confdefs.h @@ -13795,7 +13174,7 @@ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for broken nice()" >&5 $as_echo_n "checking for broken nice()... " >&6; } -if ${ac_cv_broken_nice+:} false; then : +if test "${ac_cv_broken_nice+set}" = set; then : $as_echo_n "(cached) " >&6 else @@ -13836,7 +13215,7 @@ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for broken poll()" >&5 $as_echo_n "checking for broken poll()... " >&6; } -if ${ac_cv_broken_poll+:} false; then : +if test "${ac_cv_broken_poll+set}" = set; then : $as_echo_n "(cached) " >&6 else if test "$cross_compiling" = yes; then : @@ -13891,7 +13270,7 @@ #include <$ac_cv_struct_tm> " -if test "x$ac_cv_member_struct_tm_tm_zone" = xyes; then : +if test "x$ac_cv_member_struct_tm_tm_zone" = x""yes; then : cat >>confdefs.h <<_ACEOF #define HAVE_STRUCT_TM_TM_ZONE 1 @@ -13907,7 +13286,7 @@ else ac_fn_c_check_decl "$LINENO" "tzname" "ac_cv_have_decl_tzname" "#include " -if test "x$ac_cv_have_decl_tzname" = xyes; then : +if test "x$ac_cv_have_decl_tzname" = x""yes; then : ac_have_decl=1 else ac_have_decl=0 @@ -13919,7 +13298,7 @@ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for tzname" >&5 $as_echo_n "checking for tzname... " >&6; } -if ${ac_cv_var_tzname+:} false; then : +if test "${ac_cv_var_tzname+set}" = set; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext @@ -13958,7 +13337,7 @@ # check tzset(3) exists and works like we expect it to { $as_echo "$as_me:${as_lineno-$LINENO}: checking for working tzset()" >&5 $as_echo_n "checking for working tzset()... " >&6; } -if ${ac_cv_working_tzset+:} false; then : +if test "${ac_cv_working_tzset+set}" = set; then : $as_echo_n "(cached) " >&6 else @@ -14055,7 +13434,7 @@ # Look for subsecond timestamps in struct stat { $as_echo "$as_me:${as_lineno-$LINENO}: checking for tv_nsec in struct stat" >&5 $as_echo_n "checking for tv_nsec in struct stat... " >&6; } -if ${ac_cv_stat_tv_nsec+:} false; then : +if test "${ac_cv_stat_tv_nsec+set}" = set; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext @@ -14092,7 +13471,7 @@ # Look for BSD style subsecond timestamps in struct stat { $as_echo "$as_me:${as_lineno-$LINENO}: checking for tv_nsec2 in struct stat" >&5 $as_echo_n "checking for tv_nsec2 in struct stat... " >&6; } -if ${ac_cv_stat_tv_nsec2+:} false; then : +if test "${ac_cv_stat_tv_nsec2+set}" = set; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext @@ -14126,47 +13505,10 @@ fi -# first curses configure check -ac_save_cppflags="$CPPFLAGS" -CPPFLAGS="$CPPFLAGS -I/usr/include/ncursesw" - -for ac_header in curses.h ncurses.h -do : - as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` -ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default" -if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : - cat >>confdefs.h <<_ACEOF -#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 -_ACEOF - -fi - -done - - -# On Solaris, term.h requires curses.h -for ac_header in term.h -do : - ac_fn_c_check_header_compile "$LINENO" "term.h" "ac_cv_header_term_h" " -#ifdef HAVE_CURSES_H -#include -#endif - -" -if test "x$ac_cv_header_term_h" = xyes; then : - cat >>confdefs.h <<_ACEOF -#define HAVE_TERM_H 1 -_ACEOF - -fi - -done - - # On HP/UX 11.0, mvwdelch is a block with a return statement { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether mvwdelch is an expression" >&5 $as_echo_n "checking whether mvwdelch is an expression... " >&6; } -if ${ac_cv_mvwdelch_is_expression+:} false; then : +if test "${ac_cv_mvwdelch_is_expression+set}" = set; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext @@ -14203,7 +13545,7 @@ { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether WINDOW has _flags" >&5 $as_echo_n "checking whether WINDOW has _flags... " >&6; } -if ${ac_cv_window_has_flags+:} false; then : +if test "${ac_cv_window_has_flags+set}" = set; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext @@ -14316,116 +13658,46 @@ fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -# last curses configure check -CPPFLAGS=$ac_save_cppflags - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for device files" >&5 -$as_echo "$as_me: checking for device files" >&6;} - -if test "x$cross_compiling" = xyes; then - if test "${ac_cv_file__dev_ptmx+set}" != set; then - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for /dev/ptmx" >&5 -$as_echo_n "checking for /dev/ptmx... " >&6; } - { $as_echo "$as_me:${as_lineno-$LINENO}: result: not set" >&5 -$as_echo "not set" >&6; } - as_fn_error $? "set ac_cv_file__dev_ptmx to yes/no in your CONFIG_SITE file when cross compiling" "$LINENO" 5 - fi - if test "${ac_cv_file__dev_ptc+set}" != set; then - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for /dev/ptc" >&5 -$as_echo_n "checking for /dev/ptc... " >&6; } - { $as_echo "$as_me:${as_lineno-$LINENO}: result: not set" >&5 -$as_echo "not set" >&6; } - as_fn_error $? "set ac_cv_file__dev_ptc to yes/no in your CONFIG_SITE file when cross compiling" "$LINENO" 5 - fi -fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for /dev/ptmx" >&5 $as_echo_n "checking for /dev/ptmx... " >&6; } -if ${ac_cv_file__dev_ptmx+:} false; then : - $as_echo_n "(cached) " >&6 -else - test "$cross_compiling" = yes && - as_fn_error $? "cannot check for file existence when cross compiling" "$LINENO" 5 -if test -r "/dev/ptmx"; then - ac_cv_file__dev_ptmx=yes -else - ac_cv_file__dev_ptmx=no -fi -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_file__dev_ptmx" >&5 -$as_echo "$ac_cv_file__dev_ptmx" >&6; } -if test "x$ac_cv_file__dev_ptmx" = xyes; then : - -fi - -if test "x$ac_cv_file__dev_ptmx" = xyes; then + +if test -r /dev/ptmx +then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } $as_echo "#define HAVE_DEV_PTMX 1" >>confdefs.h -fi +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for /dev/ptc" >&5 $as_echo_n "checking for /dev/ptc... " >&6; } -if ${ac_cv_file__dev_ptc+:} false; then : - $as_echo_n "(cached) " >&6 -else - test "$cross_compiling" = yes && - as_fn_error $? "cannot check for file existence when cross compiling" "$LINENO" 5 -if test -r "/dev/ptc"; then - ac_cv_file__dev_ptc=yes -else - ac_cv_file__dev_ptc=no -fi -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_file__dev_ptc" >&5 -$as_echo "$ac_cv_file__dev_ptc" >&6; } -if test "x$ac_cv_file__dev_ptc" = xyes; then : - -fi - -if test "x$ac_cv_file__dev_ptc" = xyes; then + +if test -r /dev/ptc +then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } $as_echo "#define HAVE_DEV_PTC 1" >>confdefs.h +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } fi if test "$have_long_long" = yes then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for %lld and %llu printf() format support" >&5 $as_echo_n "checking for %lld and %llu printf() format support... " >&6; } - if ${ac_cv_have_long_long_format+:} false; then : + if test "${ac_cv_have_long_long_format+set}" = set; then : $as_echo_n "(cached) " >&6 else if test "$cross_compiling" = yes; then : - ac_cv_have_long_long_format="cross -- assuming no" - if test x$GCC = xyes; then - save_CFLAGS=$CFLAGS - CFLAGS="$CFLAGS -Werror -Wformat" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - - #include - #include - -int -main () -{ - - char *buffer; - sprintf(buffer, "%lld", (long long)123); - sprintf(buffer, "%lld", (long long)-123); - sprintf(buffer, "%llu", (unsigned long long)123); - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - ac_cv_have_long_long_format=yes - -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - CFLAGS=$save_CFLAGS - fi + ac_cv_have_long_long_format=no else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ @@ -14492,7 +13764,7 @@ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for %zd printf() format support" >&5 $as_echo_n "checking for %zd printf() format support... " >&6; } -if ${ac_cv_have_size_t_format+:} false; then : +if test "${ac_cv_have_size_t_format+set}" = set; then : $as_echo_n "(cached) " >&6 else if test "$cross_compiling" = yes; then : @@ -14565,7 +13837,7 @@ #endif " -if test "x$ac_cv_type_socklen_t" = xyes; then : +if test "x$ac_cv_type_socklen_t" = x""yes; then : else @@ -14670,21 +13942,10 @@ :end' >>confcache if diff "$cache_file" confcache >/dev/null 2>&1; then :; else if test -w "$cache_file"; then - if test "x$cache_file" != "x/dev/null"; then + test "x$cache_file" != "x/dev/null" && { $as_echo "$as_me:${as_lineno-$LINENO}: updating cache $cache_file" >&5 $as_echo "$as_me: updating cache $cache_file" >&6;} - if test ! -f "$cache_file" || test -h "$cache_file"; then - cat confcache >"$cache_file" - else - case $cache_file in #( - */* | ?:*) - mv -f confcache "$cache_file"$$ && - mv -f "$cache_file"$$ "$cache_file" ;; #( - *) - mv -f confcache "$cache_file" ;; - esac - fi - fi + cat confcache >$cache_file else { $as_echo "$as_me:${as_lineno-$LINENO}: not updating unwritable cache $cache_file" >&5 $as_echo "$as_me: not updating unwritable cache $cache_file" >&6;} @@ -14717,7 +13978,7 @@ -: "${CONFIG_STATUS=./config.status}" +: ${CONFIG_STATUS=./config.status} ac_write_fail=0 ac_clean_files_save=$ac_clean_files ac_clean_files="$ac_clean_files $CONFIG_STATUS" @@ -14818,7 +14079,6 @@ IFS=" "" $as_nl" # Find who we are. Look in the path if we contain no directory separator. -as_myself= case $0 in #(( *[\\/]* ) as_myself=$0 ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR @@ -15014,16 +14274,16 @@ # ... but there are two gotchas: # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. - # In both cases, we have to default to `cp -pR'. + # In both cases, we have to default to `cp -p'. ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || - as_ln_s='cp -pR' + as_ln_s='cp -p' elif ln conf$$.file conf$$ 2>/dev/null; then as_ln_s=ln else - as_ln_s='cp -pR' - fi -else - as_ln_s='cp -pR' + as_ln_s='cp -p' + fi +else + as_ln_s='cp -p' fi rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file rmdir conf$$.dir 2>/dev/null @@ -15083,16 +14343,28 @@ as_mkdir_p=false fi - -# as_fn_executable_p FILE -# ----------------------- -# Test if FILE is an executable regular file. -as_fn_executable_p () -{ - test -f "$1" && test -x "$1" -} # as_fn_executable_p -as_test_x='test -x' -as_executable_p=as_fn_executable_p +if test -x / >/dev/null 2>&1; then + as_test_x='test -x' +else + if ls -dL / >/dev/null 2>&1; then + as_ls_L_option=L + else + as_ls_L_option= + fi + as_test_x=' + eval sh -c '\'' + if test -d "$1"; then + test -d "$1/."; + else + case $1 in #( + -*)set "./$1";; + esac; + case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in #(( + ???[sx]*):;;*)false;;esac;fi + '\'' sh + ' +fi +as_executable_p=$as_test_x # Sed expression to map a string onto a valid CPP name. as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" @@ -15114,7 +14386,7 @@ # values after options handling. ac_log=" This file was extended by python $as_me 2.7, which was -generated by GNU Autoconf 2.69. Invocation command line was +generated by GNU Autoconf 2.67. Invocation command line was CONFIG_FILES = $CONFIG_FILES CONFIG_HEADERS = $CONFIG_HEADERS @@ -15176,17 +14448,16 @@ ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ python config.status 2.7 -configured by $0, generated by GNU Autoconf 2.69, +configured by $0, generated by GNU Autoconf 2.67, with options \\"\$ac_cs_config\\" -Copyright (C) 2012 Free Software Foundation, Inc. +Copyright (C) 2010 Free Software Foundation, Inc. This config.status script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it." ac_pwd='$ac_pwd' srcdir='$srcdir' INSTALL='$INSTALL' -MKDIR_P='$MKDIR_P' test -n "\$AWK" || AWK=awk _ACEOF @@ -15269,7 +14540,7 @@ _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 if \$ac_cs_recheck; then - set X $SHELL '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion + set X '$SHELL' '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion shift \$as_echo "running CONFIG_SHELL=$SHELL \$*" >&6 CONFIG_SHELL='$SHELL' @@ -15309,7 +14580,7 @@ "Misc/python.pc") CONFIG_FILES="$CONFIG_FILES Misc/python.pc" ;; "Modules/ld_so_aix") CONFIG_FILES="$CONFIG_FILES Modules/ld_so_aix" ;; - *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;; + *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5 ;; esac done @@ -15331,10 +14602,9 @@ # after its creation but before its name has been assigned to `$tmp'. $debug || { - tmp= ac_tmp= + tmp= trap 'exit_status=$? - : "${ac_tmp:=$tmp}" - { test ! -d "$ac_tmp" || rm -fr "$ac_tmp"; } && exit $exit_status + { test -z "$tmp" || test ! -d "$tmp" || rm -fr "$tmp"; } && exit $exit_status ' 0 trap 'as_fn_exit 1' 1 2 13 15 } @@ -15342,13 +14612,12 @@ { tmp=`(umask 077 && mktemp -d "./confXXXXXX") 2>/dev/null` && - test -d "$tmp" + test -n "$tmp" && test -d "$tmp" } || { tmp=./conf$$-$RANDOM (umask 077 && mkdir "$tmp") } || as_fn_error $? "cannot create a temporary directory in ." "$LINENO" 5 -ac_tmp=$tmp # Set up the scripts for CONFIG_FILES section. # No need to generate them if there are no CONFIG_FILES. @@ -15370,7 +14639,7 @@ ac_cs_awk_cr=$ac_cr fi -echo 'BEGIN {' >"$ac_tmp/subs1.awk" && +echo 'BEGIN {' >"$tmp/subs1.awk" && _ACEOF @@ -15398,7 +14667,7 @@ rm -f conf$$subs.sh cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 -cat >>"\$ac_tmp/subs1.awk" <<\\_ACAWK && +cat >>"\$tmp/subs1.awk" <<\\_ACAWK && _ACEOF sed -n ' h @@ -15446,7 +14715,7 @@ rm -f conf$$subs.awk cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 _ACAWK -cat >>"\$ac_tmp/subs1.awk" <<_ACAWK && +cat >>"\$tmp/subs1.awk" <<_ACAWK && for (key in S) S_is_set[key] = 1 FS = "" @@ -15478,7 +14747,7 @@ sed "s/$ac_cr\$//; s/$ac_cr/$ac_cs_awk_cr/g" else cat -fi < "$ac_tmp/subs1.awk" > "$ac_tmp/subs.awk" \ +fi < "$tmp/subs1.awk" > "$tmp/subs.awk" \ || as_fn_error $? "could not setup config files machinery" "$LINENO" 5 _ACEOF @@ -15512,7 +14781,7 @@ # No need to generate them if there are no CONFIG_HEADERS. # This happens for instance with `./config.status Makefile'. if test -n "$CONFIG_HEADERS"; then -cat >"$ac_tmp/defines.awk" <<\_ACAWK || +cat >"$tmp/defines.awk" <<\_ACAWK || BEGIN { _ACEOF @@ -15524,8 +14793,8 @@ # handling of long lines. ac_delim='%!_!# ' for ac_last_try in false false :; do - ac_tt=`sed -n "/$ac_delim/p" confdefs.h` - if test -z "$ac_tt"; then + ac_t=`sed -n "/$ac_delim/p" confdefs.h` + if test -z "$ac_t"; then break elif $ac_last_try; then as_fn_error $? "could not make $CONFIG_HEADERS" "$LINENO" 5 @@ -15626,7 +14895,7 @@ esac case $ac_mode$ac_tag in :[FHL]*:*);; - :L* | :C*:*) as_fn_error $? "invalid tag \`$ac_tag'" "$LINENO" 5;; + :L* | :C*:*) as_fn_error $? "invalid tag \`$ac_tag'" "$LINENO" 5 ;; :[FH]-) ac_tag=-:-;; :[FH]*) ac_tag=$ac_tag:$ac_tag.in;; esac @@ -15645,7 +14914,7 @@ for ac_f do case $ac_f in - -) ac_f="$ac_tmp/stdin";; + -) ac_f="$tmp/stdin";; *) # Look for the file first in the build tree, then in the source tree # (if the path is not absolute). The absolute path cannot be DOS-style, # because $ac_f cannot contain `:'. @@ -15654,7 +14923,7 @@ [\\/$]*) false;; *) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";; esac || - as_fn_error 1 "cannot find input file: \`$ac_f'" "$LINENO" 5;; + as_fn_error 1 "cannot find input file: \`$ac_f'" "$LINENO" 5 ;; esac case $ac_f in *\'*) ac_f=`$as_echo "$ac_f" | sed "s/'/'\\\\\\\\''/g"`;; esac as_fn_append ac_file_inputs " '$ac_f'" @@ -15680,8 +14949,8 @@ esac case $ac_tag in - *:-:* | *:-) cat >"$ac_tmp/stdin" \ - || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;; + *:-:* | *:-) cat >"$tmp/stdin" \ + || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;; esac ;; esac @@ -15755,11 +15024,6 @@ [\\/$]* | ?:[\\/]* ) ac_INSTALL=$INSTALL ;; *) ac_INSTALL=$ac_top_build_prefix$INSTALL ;; esac - ac_MKDIR_P=$MKDIR_P - case $MKDIR_P in - [\\/$]* | ?:[\\/]* ) ;; - */*) ac_MKDIR_P=$ac_top_build_prefix$MKDIR_P ;; - esac _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 @@ -15814,25 +15078,23 @@ s&@abs_builddir@&$ac_abs_builddir&;t t s&@abs_top_builddir@&$ac_abs_top_builddir&;t t s&@INSTALL@&$ac_INSTALL&;t t -s&@MKDIR_P@&$ac_MKDIR_P&;t t $ac_datarootdir_hack " -eval sed \"\$ac_sed_extra\" "$ac_file_inputs" | $AWK -f "$ac_tmp/subs.awk" \ - >$ac_tmp/out || as_fn_error $? "could not create $ac_file" "$LINENO" 5 +eval sed \"\$ac_sed_extra\" "$ac_file_inputs" | $AWK -f "$tmp/subs.awk" >$tmp/out \ + || as_fn_error $? "could not create $ac_file" "$LINENO" 5 test -z "$ac_datarootdir_hack$ac_datarootdir_seen" && - { ac_out=`sed -n '/\${datarootdir}/p' "$ac_tmp/out"`; test -n "$ac_out"; } && - { ac_out=`sed -n '/^[ ]*datarootdir[ ]*:*=/p' \ - "$ac_tmp/out"`; test -z "$ac_out"; } && + { ac_out=`sed -n '/\${datarootdir}/p' "$tmp/out"`; test -n "$ac_out"; } && + { ac_out=`sed -n '/^[ ]*datarootdir[ ]*:*=/p' "$tmp/out"`; test -z "$ac_out"; } && { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file contains a reference to the variable \`datarootdir' which seems to be undefined. Please make sure it is defined" >&5 $as_echo "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir' which seems to be undefined. Please make sure it is defined" >&2;} - rm -f "$ac_tmp/stdin" + rm -f "$tmp/stdin" case $ac_file in - -) cat "$ac_tmp/out" && rm -f "$ac_tmp/out";; - *) rm -f "$ac_file" && mv "$ac_tmp/out" "$ac_file";; + -) cat "$tmp/out" && rm -f "$tmp/out";; + *) rm -f "$ac_file" && mv "$tmp/out" "$ac_file";; esac \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;; @@ -15843,20 +15105,20 @@ if test x"$ac_file" != x-; then { $as_echo "/* $configure_input */" \ - && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs" - } >"$ac_tmp/config.h" \ + && eval '$AWK -f "$tmp/defines.awk"' "$ac_file_inputs" + } >"$tmp/config.h" \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 - if diff "$ac_file" "$ac_tmp/config.h" >/dev/null 2>&1; then + if diff "$ac_file" "$tmp/config.h" >/dev/null 2>&1; then { $as_echo "$as_me:${as_lineno-$LINENO}: $ac_file is unchanged" >&5 $as_echo "$as_me: $ac_file is unchanged" >&6;} else rm -f "$ac_file" - mv "$ac_tmp/config.h" "$ac_file" \ + mv "$tmp/config.h" "$ac_file" \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 fi else $as_echo "/* $configure_input */" \ - && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs" \ + && eval '$AWK -f "$tmp/defines.awk"' "$ac_file_inputs" \ || as_fn_error $? "could not create -" "$LINENO" 5 fi ;; diff -r 9cd3ab7c09d1 -r 9ac347a7f375 configure.ac --- a/configure.ac Sat Jul 19 16:34:33 2014 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,4585 +0,0 @@ -dnl *********************************************** -dnl * Please run autoreconf to test your changes! * -dnl *********************************************** - -# Set VERSION so we only need to edit in one place (i.e., here) -m4_define(PYTHON_VERSION, 2.7) - -AC_PREREQ(2.65) - -AC_REVISION($Revision$) -AC_INIT(python, PYTHON_VERSION, http://bugs.python.org/) -AC_CONFIG_SRCDIR([Include/object.h]) -AC_CONFIG_HEADER(pyconfig.h) - -AC_CANONICAL_HOST -AC_SUBST(build) -AC_SUBST(host) - -if test "$cross_compiling" = yes; then - AC_MSG_CHECKING([for python interpreter for cross build]) - if test -z "$PYTHON_FOR_BUILD"; then - for interp in python$PACKAGE_VERSION python2 python; do - which $interp >/dev/null 2>&1 || continue - if $interp -c 'import sys;sys.exit(not (sys.version_info@<:@:2@:>@ >= (2,7) and sys.version_info@<:@0@:>@ < 3))'; then - break - fi - interp= - done - if test x$interp = x; then - AC_MSG_ERROR([python$PACKAGE_VERSION interpreter not found]) - fi - AC_MSG_RESULT($interp) - PYTHON_FOR_BUILD='_PYTHON_PROJECT_BASE=$(abs_builddir) _PYTHON_HOST_PLATFORM=$(_PYTHON_HOST_PLATFORM) PYTHONPATH=$(shell test -f pybuilddir.txt && echo $(abs_builddir)/`cat pybuilddir.txt`:)$(srcdir)/Lib:$(srcdir)/Lib/plat-$(MACHDEP) '$interp - fi -elif test "$cross_compiling" = maybe; then - AC_MSG_ERROR([Cross compiling required --host=HOST-TUPLE and --build=ARCH]) -else - PYTHON_FOR_BUILD='./$(BUILDPYTHON) -E' -fi -AC_SUBST(PYTHON_FOR_BUILD) - -dnl Ensure that if prefix is specified, it does not end in a slash. If -dnl it does, we get path names containing '//' which is both ugly and -dnl can cause trouble. - -dnl Last slash shouldn't be stripped if prefix=/ -if test "$prefix" != "/"; then - prefix=`echo "$prefix" | sed -e 's/\/$//g'` -fi - -dnl This is for stuff that absolutely must end up in pyconfig.h. -dnl Please use pyport.h instead, if possible. -AH_TOP([ -#ifndef Py_PYCONFIG_H -#define Py_PYCONFIG_H -]) -AH_BOTTOM([ -/* Define the macros needed if on a UnixWare 7.x system. */ -#if defined(__USLC__) && defined(__SCO_VERSION__) -#define STRICT_SYSV_CURSES /* Don't use ncurses extensions */ -#endif - -#endif /*Py_PYCONFIG_H*/ -]) - -# We don't use PACKAGE_ variables, and they cause conflicts -# with other autoconf-based packages that include Python.h -grep -v 'define PACKAGE_' confdefs.h.new -rm confdefs.h -mv confdefs.h.new confdefs.h - -AC_SUBST(VERSION) -VERSION=PYTHON_VERSION - -AC_SUBST(SOVERSION) -SOVERSION=1.0 - -# The later defininition of _XOPEN_SOURCE disables certain features -# on Linux, so we need _GNU_SOURCE to re-enable them (makedev, tm_zone). -AC_DEFINE(_GNU_SOURCE, 1, [Define on Linux to activate all library features]) - -# The later defininition of _XOPEN_SOURCE and _POSIX_C_SOURCE disables -# certain features on NetBSD, so we need _NETBSD_SOURCE to re-enable -# them. -AC_DEFINE(_NETBSD_SOURCE, 1, [Define on NetBSD to activate all library features]) - -# The later defininition of _XOPEN_SOURCE and _POSIX_C_SOURCE disables -# certain features on FreeBSD, so we need __BSD_VISIBLE to re-enable -# them. -AC_DEFINE(__BSD_VISIBLE, 1, [Define on FreeBSD to activate all library features]) - -# The later defininition of _XOPEN_SOURCE and _POSIX_C_SOURCE disables -# u_int on Irix 5.3. Defining _BSD_TYPES brings it back. -AC_DEFINE(_BSD_TYPES, 1, [Define on Irix to enable u_int]) - -# The later defininition of _XOPEN_SOURCE and _POSIX_C_SOURCE disables -# certain features on Mac OS X, so we need _DARWIN_C_SOURCE to re-enable -# them. -AC_DEFINE(_DARWIN_C_SOURCE, 1, [Define on Darwin to activate all library features]) - - -define_xopen_source=yes - -# Arguments passed to configure. -AC_SUBST(CONFIG_ARGS) -CONFIG_ARGS="$ac_configure_args" - -AC_MSG_CHECKING([for --enable-universalsdk]) -AC_ARG_ENABLE(universalsdk, - AS_HELP_STRING([--enable-universalsdk@<:@=SDKDIR@:>@], [Build against Mac OS X 10.4u SDK (ppc/i386)]), -[ - case $enableval in - yes) - enableval=/Developer/SDKs/MacOSX10.4u.sdk - if test ! -d "${enableval}" - then - enableval=/ - fi - ;; - esac - case $enableval in - no) - UNIVERSALSDK= - enable_universalsdk= - ;; - *) - UNIVERSALSDK=$enableval - if test ! -d "${UNIVERSALSDK}" - then - AC_MSG_ERROR([--enable-universalsdk specifies non-existing SDK: ${UNIVERSALSDK}]) - fi - ;; - esac - -],[ - UNIVERSALSDK= - enable_universalsdk= -]) -if test -n "${UNIVERSALSDK}" -then - AC_MSG_RESULT(${UNIVERSALSDK}) -else - AC_MSG_RESULT(no) -fi -AC_SUBST(UNIVERSALSDK) - -AC_SUBST(ARCH_RUN_32BIT) -ARCH_RUN_32BIT="" - -UNIVERSAL_ARCHS="32-bit" -AC_SUBST(LIPO_32BIT_FLAGS) -AC_MSG_CHECKING(for --with-universal-archs) -AC_ARG_WITH(universal-archs, - AS_HELP_STRING([--with-universal-archs=ARCH], [select architectures for universal build ("32-bit", "64-bit", "3-way", "intel" or "all")]), -[ - AC_MSG_RESULT($withval) - UNIVERSAL_ARCHS="$withval" - if test "${enable_universalsdk}" ; then - : - else - AC_MSG_ERROR([--with-universal-archs without --enable-universalsdk. See Mac/README]) - fi -], -[ - AC_MSG_RESULT(32-bit) -]) - - - -AC_ARG_WITH(framework-name, - AS_HELP_STRING([--with-framework-name=FRAMEWORK], - [specify an alternate name of the framework built with --enable-framework]), -[ - if test "${enable_framework}"; then - : - else - AC_MSG_ERROR([--with-framework-name without --enable-framework. See Mac/README]) - fi - PYTHONFRAMEWORK=${withval} - PYTHONFRAMEWORKDIR=${withval}.framework - PYTHONFRAMEWORKIDENTIFIER=org.python.`echo $withval | tr '[A-Z]' '[a-z]'` - ],[ - PYTHONFRAMEWORK=Python - PYTHONFRAMEWORKDIR=Python.framework - PYTHONFRAMEWORKIDENTIFIER=org.python.python -]) -dnl quadrigraphs "@<:@" and "@:>@" produce "[" and "]" in the output -AC_ARG_ENABLE(framework, - AS_HELP_STRING([--enable-framework@<:@=INSTALLDIR@:>@], [Build (MacOSX|Darwin) framework]), -[ - case $enableval in - yes) - enableval=/Library/Frameworks - esac - case $enableval in - no) - PYTHONFRAMEWORK= - PYTHONFRAMEWORKDIR=no-framework - PYTHONFRAMEWORKPREFIX= - PYTHONFRAMEWORKINSTALLDIR= - FRAMEWORKINSTALLFIRST= - FRAMEWORKINSTALLLAST= - FRAMEWORKALTINSTALLFIRST= - FRAMEWORKALTINSTALLLAST= - if test "x${prefix}" = "xNONE"; then - FRAMEWORKUNIXTOOLSPREFIX="${ac_default_prefix}" - else - FRAMEWORKUNIXTOOLSPREFIX="${prefix}" - fi - enable_framework= - ;; - *) - PYTHONFRAMEWORKPREFIX="${enableval}" - PYTHONFRAMEWORKINSTALLDIR=$PYTHONFRAMEWORKPREFIX/$PYTHONFRAMEWORKDIR - FRAMEWORKINSTALLFIRST="frameworkinstallstructure" - FRAMEWORKALTINSTALLFIRST="frameworkinstallstructure bininstall maninstall" - FRAMEWORKINSTALLLAST="frameworkinstallmaclib frameworkinstallapps frameworkinstallunixtools" - FRAMEWORKALTINSTALLLAST="frameworkinstallmaclib frameworkinstallapps frameworkaltinstallunixtools" - FRAMEWORKINSTALLAPPSPREFIX="/Applications" - - if test "x${prefix}" = "xNONE" ; then - FRAMEWORKUNIXTOOLSPREFIX="${ac_default_prefix}" - - else - FRAMEWORKUNIXTOOLSPREFIX="${prefix}" - fi - - case "${enableval}" in - /System*) - FRAMEWORKINSTALLAPPSPREFIX="/Applications" - if test "${prefix}" = "NONE" ; then - # See below - FRAMEWORKUNIXTOOLSPREFIX="/usr" - fi - ;; - - /Library*) - FRAMEWORKINSTALLAPPSPREFIX="/Applications" - ;; - - */Library/Frameworks) - MDIR="`dirname "${enableval}"`" - MDIR="`dirname "${MDIR}"`" - FRAMEWORKINSTALLAPPSPREFIX="${MDIR}/Applications" - - if test "${prefix}" = "NONE"; then - # User hasn't specified the - # --prefix option, but wants to install - # the framework in a non-default location, - # ensure that the compatibility links get - # installed relative to that prefix as well - # instead of in /usr/local. - FRAMEWORKUNIXTOOLSPREFIX="${MDIR}" - fi - ;; - - *) - FRAMEWORKINSTALLAPPSPREFIX="/Applications" - ;; - esac - - prefix=$PYTHONFRAMEWORKINSTALLDIR/Versions/$VERSION - - # Add files for Mac specific code to the list of output - # files: - AC_CONFIG_FILES(Mac/Makefile) - AC_CONFIG_FILES(Mac/PythonLauncher/Makefile) - AC_CONFIG_FILES(Mac/IDLE/Makefile) - AC_CONFIG_FILES(Mac/Resources/framework/Info.plist) - AC_CONFIG_FILES(Mac/Resources/app/Info.plist) - esac - ],[ - PYTHONFRAMEWORK= - PYTHONFRAMEWORKDIR=no-framework - PYTHONFRAMEWORKPREFIX= - PYTHONFRAMEWORKINSTALLDIR= - FRAMEWORKINSTALLFIRST= - FRAMEWORKINSTALLLAST= - FRAMEWORKALTINSTALLFIRST= - FRAMEWORKALTINSTALLLAST= - if test "x${prefix}" = "xNONE" ; then - FRAMEWORKUNIXTOOLSPREFIX="${ac_default_prefix}" - else - FRAMEWORKUNIXTOOLSPREFIX="${prefix}" - fi - enable_framework= - -]) -AC_SUBST(PYTHONFRAMEWORK) -AC_SUBST(PYTHONFRAMEWORKIDENTIFIER) -AC_SUBST(PYTHONFRAMEWORKDIR) -AC_SUBST(PYTHONFRAMEWORKPREFIX) -AC_SUBST(PYTHONFRAMEWORKINSTALLDIR) -AC_SUBST(FRAMEWORKINSTALLFIRST) -AC_SUBST(FRAMEWORKINSTALLLAST) -AC_SUBST(FRAMEWORKALTINSTALLFIRST) -AC_SUBST(FRAMEWORKALTINSTALLLAST) -AC_SUBST(FRAMEWORKUNIXTOOLSPREFIX) -AC_SUBST(FRAMEWORKINSTALLAPPSPREFIX) - -##AC_ARG_WITH(dyld, -## AS_HELP_STRING([--with-dyld], -## [Use (OpenStep|Rhapsody) dynamic linker])) -## -# Set name for machine-dependent library files -AC_SUBST(MACHDEP) -AC_MSG_CHECKING(MACHDEP) -if test -z "$MACHDEP" -then - # avoid using uname for cross builds - if test "$cross_compiling" = yes; then - # ac_sys_system and ac_sys_release are only used for setting - # `define_xopen_source' in the case statement below. For the - # current supported cross builds, this macro is not adjusted. - case "$host" in - *-*-linux*) - ac_sys_system=Linux - ;; - *-*-cygwin*) - ac_sys_system=Cygwin - ;; - *) - # for now, limit cross builds to known configurations - MACHDEP="unknown" - AC_MSG_ERROR([cross build not supported for $host]) - esac - ac_sys_release= - else - ac_sys_system=`uname -s` - if test "$ac_sys_system" = "AIX" \ - -o "$ac_sys_system" = "UnixWare" -o "$ac_sys_system" = "OpenUNIX"; then - ac_sys_release=`uname -v` - else - ac_sys_release=`uname -r` - fi - fi - ac_md_system=`echo $ac_sys_system | - tr -d '[/ ]' | tr '[[A-Z]]' '[[a-z]]'` - ac_md_release=`echo $ac_sys_release | - tr -d '[/ ]' | sed 's/^[[A-Z]]\.//' | sed 's/\..*//'` - MACHDEP="$ac_md_system$ac_md_release" - - case $MACHDEP in - linux*) MACHDEP="linux2";; - cygwin*) MACHDEP="cygwin";; - darwin*) MACHDEP="darwin";; - atheos*) MACHDEP="atheos";; - irix646) MACHDEP="irix6";; - '') MACHDEP="unknown";; - esac -fi - -AC_SUBST(_PYTHON_HOST_PLATFORM) -if test "$cross_compiling" = yes; then - case "$host" in - *-*-linux*) - case "$host_cpu" in - arm*) - _host_cpu=arm - ;; - *) - _host_cpu=$host_cpu - esac - ;; - *-*-cygwin*) - _host_cpu= - ;; - *) - # for now, limit cross builds to known configurations - MACHDEP="unknown" - AC_MSG_ERROR([cross build not supported for $host]) - esac - _PYTHON_HOST_PLATFORM="$MACHDEP${_host_cpu:+-$_host_cpu}" -fi - -# Some systems cannot stand _XOPEN_SOURCE being defined at all; they -# disable features if it is defined, without any means to access these -# features as extensions. For these systems, we skip the definition of -# _XOPEN_SOURCE. Before adding a system to the list to gain access to -# some feature, make sure there is no alternative way to access this -# feature. Also, when using wildcards, make sure you have verified the -# need for not defining _XOPEN_SOURCE on all systems matching the -# wildcard, and that the wildcard does not include future systems -# (which may remove their limitations). -dnl quadrigraphs "@<:@" and "@:>@" produce "[" and "]" in the output -case $ac_sys_system/$ac_sys_release in - # On OpenBSD, select(2) is not available if _XOPEN_SOURCE is defined, - # even though select is a POSIX function. Reported by J. Ribbens. - # Reconfirmed for OpenBSD 3.3 by Zachary Hamm, for 3.4 by Jason Ish. - # In addition, Stefan Krah confirms that issue #1244610 exists through - # OpenBSD 4.6, but is fixed in 4.7. - OpenBSD/2.* | OpenBSD/3.* | OpenBSD/4.@<:@0123456@:>@) - define_xopen_source=no - # OpenBSD undoes our definition of __BSD_VISIBLE if _XOPEN_SOURCE is - # also defined. This can be overridden by defining _BSD_SOURCE - # As this has a different meaning on Linux, only define it on OpenBSD - AC_DEFINE(_BSD_SOURCE, 1, [Define on OpenBSD to activate all library features]) - ;; - OpenBSD/*) - # OpenBSD undoes our definition of __BSD_VISIBLE if _XOPEN_SOURCE is - # also defined. This can be overridden by defining _BSD_SOURCE - # As this has a different meaning on Linux, only define it on OpenBSD - AC_DEFINE(_BSD_SOURCE, 1, [Define on OpenBSD to activate all library features]) - ;; - # Defining _XOPEN_SOURCE on NetBSD version prior to the introduction of - # _NETBSD_SOURCE disables certain features (eg. setgroups). Reported by - # Marc Recht - NetBSD/1.5 | NetBSD/1.5.* | NetBSD/1.6 | NetBSD/1.6.* | NetBSD/1.6@<:@A-S@:>@) - define_xopen_source=no;; - # From the perspective of Solaris, _XOPEN_SOURCE is not so much a - # request to enable features supported by the standard as a request - # to disable features not supported by the standard. The best way - # for Python to use Solaris is simply to leave _XOPEN_SOURCE out - # entirely and define __EXTENSIONS__ instead. - SunOS/*) - define_xopen_source=no;; - # On UnixWare 7, u_long is never defined with _XOPEN_SOURCE, - # but used in /usr/include/netinet/tcp.h. Reported by Tim Rice. - # Reconfirmed for 7.1.4 by Martin v. Loewis. - OpenUNIX/8.0.0| UnixWare/7.1.@<:@0-4@:>@) - define_xopen_source=no;; - # On OpenServer 5, u_short is never defined with _XOPEN_SOURCE, - # but used in struct sockaddr.sa_family. Reported by Tim Rice. - SCO_SV/3.2) - define_xopen_source=no;; - # On FreeBSD 4, the math functions C89 does not cover are never defined - # with _XOPEN_SOURCE and __BSD_VISIBLE does not re-enable them. - FreeBSD/4.*) - define_xopen_source=no;; - # On MacOS X 10.2, a bug in ncurses.h means that it craps out if - # _XOPEN_EXTENDED_SOURCE is defined. Apparently, this is fixed in 10.3, which - # identifies itself as Darwin/7.* - # On Mac OS X 10.4, defining _POSIX_C_SOURCE or _XOPEN_SOURCE - # disables platform specific features beyond repair. - # On Mac OS X 10.3, defining _POSIX_C_SOURCE or _XOPEN_SOURCE - # has no effect, don't bother defining them - Darwin/@<:@6789@:>@.*) - define_xopen_source=no;; - Darwin/1@<:@0-9@:>@.*) - define_xopen_source=no;; - # On AIX 4 and 5.1, mbstate_t is defined only when _XOPEN_SOURCE == 500 but - # used in wcsnrtombs() and mbsnrtowcs() even if _XOPEN_SOURCE is not defined - # or has another value. By not (re)defining it, the defaults come in place. - AIX/4) - define_xopen_source=no;; - AIX/5) - if test `uname -r` -eq 1; then - define_xopen_source=no - fi - ;; - # On QNX 6.3.2, defining _XOPEN_SOURCE prevents netdb.h from - # defining NI_NUMERICHOST. - QNX/6.3.2) - define_xopen_source=no - ;; - -esac - -if test $define_xopen_source = yes -then - AC_DEFINE(_XOPEN_SOURCE, 600, - Define to the level of X/Open that your system supports) - - # On Tru64 Unix 4.0F, defining _XOPEN_SOURCE also requires - # definition of _XOPEN_SOURCE_EXTENDED and _POSIX_C_SOURCE, or else - # several APIs are not declared. Since this is also needed in some - # cases for HP-UX, we define it globally. - AC_DEFINE(_XOPEN_SOURCE_EXTENDED, 1, - Define to activate Unix95-and-earlier features) - - AC_DEFINE(_POSIX_C_SOURCE, 200112L, Define to activate features from IEEE Stds 1003.1-2001) - -fi - -# -# SGI compilers allow the specification of the both the ABI and the -# ISA on the command line. Depending on the values of these switches, -# different and often incompatable code will be generated. -# -# The SGI_ABI variable can be used to modify the CC and LDFLAGS and -# thus supply support for various ABI/ISA combinations. The MACHDEP -# variable is also adjusted. -# -AC_SUBST(SGI_ABI) -if test ! -z "$SGI_ABI" -then - CC="cc $SGI_ABI" - LDFLAGS="$SGI_ABI $LDFLAGS" - MACHDEP=`echo "${MACHDEP}${SGI_ABI}" | sed 's/ *//g'` -fi -AC_MSG_RESULT($MACHDEP) - -# And add extra plat-mac for darwin -AC_SUBST(EXTRAPLATDIR) -AC_SUBST(EXTRAMACHDEPPATH) -AC_MSG_CHECKING(EXTRAPLATDIR) -if test -z "$EXTRAPLATDIR" -then - case $MACHDEP in - darwin) - EXTRAPLATDIR="\$(PLATMACDIRS)" - EXTRAMACHDEPPATH="\$(PLATMACPATH)" - ;; - *) - EXTRAPLATDIR="" - EXTRAMACHDEPPATH="" - ;; - esac -fi -AC_MSG_RESULT($EXTRAPLATDIR) - -# Record the configure-time value of MACOSX_DEPLOYMENT_TARGET, -# it may influence the way we can build extensions, so distutils -# needs to check it -AC_SUBST(CONFIGURE_MACOSX_DEPLOYMENT_TARGET) -AC_SUBST(EXPORT_MACOSX_DEPLOYMENT_TARGET) -CONFIGURE_MACOSX_DEPLOYMENT_TARGET= -EXPORT_MACOSX_DEPLOYMENT_TARGET='#' - -# checks for alternative programs - -# compiler flags are generated in two sets, BASECFLAGS and OPT. OPT is just -# for debug/optimization stuff. BASECFLAGS is for flags that are required -# just to get things to compile and link. Users are free to override OPT -# when running configure or make. The build should not break if they do. -# BASECFLAGS should generally not be messed with, however. - -# XXX shouldn't some/most/all of this code be merged with the stuff later -# on that fiddles with OPT and BASECFLAGS? -AC_MSG_CHECKING(for --without-gcc) -AC_ARG_WITH(gcc, - AS_HELP_STRING([--without-gcc], [never use gcc]), -[ - case $withval in - no) CC=${CC:-cc} - without_gcc=yes;; - yes) CC=gcc - without_gcc=no;; - *) CC=$withval - without_gcc=$withval;; - esac], [ - case $ac_sys_system in - AIX*) CC=${CC:-xlc_r} - without_gcc=;; - BeOS*) - case $BE_HOST_CPU in - ppc) - CC=mwcc - without_gcc=yes - BASECFLAGS="$BASECFLAGS -export pragma" - OPT="$OPT -O" - LDFLAGS="$LDFLAGS -nodup" - ;; - x86) - CC=gcc - without_gcc=no - OPT="$OPT -O" - ;; - *) - AC_MSG_ERROR([Unknown BeOS platform "$BE_HOST_CPU"]) - ;; - esac - AR="\$(srcdir)/Modules/ar_beos" - RANLIB=: - ;; - *) without_gcc=no;; - esac]) -AC_MSG_RESULT($without_gcc) - -# If the user switches compilers, we can't believe the cache -if test ! -z "$ac_cv_prog_CC" -a ! -z "$CC" -a "$CC" != "$ac_cv_prog_CC" -then - AC_MSG_ERROR([cached CC is different -- throw away $cache_file -(it is also a good idea to do 'make clean' before compiling)]) -fi - -if test "$MACHDEP" = "irix6" && test "$CC" != "gcc"; then - # Normally, MIPSpro CC treats #error directives as warnings, which means - # a successful exit code is returned (0). This is a problem because IRIX - # has a bunch of system headers with this guard at the top: - # - # #ifndef __c99 - # #error This header file is to be used only for c99 mode compilations - # #else - # - # When autoconf tests for such a header, like stdint.h, this happens: - # - # configure:4619: cc -c conftest.c >&5 - # cc-1035 cc: WARNING File = /usr/include/stdint.h, Line = 5 - # #error directive: This header file is to be used only for c99 mode - # compilations - # - # #error This header file is to be used only for c99 mode compilations - # ^ - # - # configure:4619: $? = 0 - # configure:4619: result: yes - # - # Therefore, we use `-diag_error 1035` to have the compiler treat the - # warning as an error, which causes cc to return a non-zero result, - # which autoconf can interpret correctly. - CFLAGS="$CFLAGS -diag_error 1035" - # Whilst we're here, we might as well make sure CXX defaults to something - # sensible if we're not using gcc. - if test -z "$CXX"; then - CXX="CC" - fi -fi - -# If the user set CFLAGS, use this instead of the automatically -# determined setting -preset_cflags="$CFLAGS" -AC_PROG_CC -if test ! -z "$preset_cflags" -then - CFLAGS=$preset_cflags -fi - -AC_SUBST(CXX) -AC_SUBST(MAINCC) -AC_MSG_CHECKING(for --with-cxx-main=) -AC_ARG_WITH(cxx_main, - AS_HELP_STRING([--with-cxx-main=], - [compile main() and link python executable with C++ compiler]), -[ - - case $withval in - no) with_cxx_main=no - MAINCC='$(CC)';; - yes) with_cxx_main=yes - MAINCC='$(CXX)';; - *) with_cxx_main=yes - MAINCC=$withval - if test -z "$CXX" - then - CXX=$withval - fi;; - esac], [ - with_cxx_main=no - MAINCC='$(CC)' -]) -AC_MSG_RESULT($with_cxx_main) - -preset_cxx="$CXX" -if test -z "$CXX" -then - case "$CC" in - gcc) AC_PATH_TOOL(CXX, [g++], [g++], [notfound]) ;; - cc) AC_PATH_TOOL(CXX, [c++], [c++], [notfound]) ;; - esac - if test "$CXX" = "notfound" - then - CXX="" - fi -fi -if test -z "$CXX" -then - AC_CHECK_TOOLS(CXX, $CCC c++ g++ gcc CC cxx cc++ cl, notfound) - if test "$CXX" = "notfound" - then - CXX="" - fi -fi -if test "$preset_cxx" != "$CXX" -then - AC_MSG_WARN([ - - By default, distutils will build C++ extension modules with "$CXX". - If this is not intended, then set CXX on the configure command line. - ]) -fi - -MULTIARCH=$($CC --print-multiarch 2>/dev/null) -AC_SUBST(MULTIARCH) - - -# checks for UNIX variants that set C preprocessor variables -AC_USE_SYSTEM_EXTENSIONS - -# Check for unsupported systems -case $ac_sys_system/$ac_sys_release in -atheos*|Linux*/1*) - echo This system \($ac_sys_system/$ac_sys_release\) is no longer supported. - echo See README for details. - exit 1;; -esac - -AC_EXEEXT -AC_MSG_CHECKING(for --with-suffix) -AC_ARG_WITH(suffix, - AS_HELP_STRING([--with-suffix=.exe], [set executable suffix]), -[ - case $withval in - no) EXEEXT=;; - yes) EXEEXT=.exe;; - *) EXEEXT=$withval;; - esac]) -AC_MSG_RESULT($EXEEXT) - -# Test whether we're running on a non-case-sensitive system, in which -# case we give a warning if no ext is given -AC_SUBST(BUILDEXEEXT) -AC_MSG_CHECKING(for case-insensitive build directory) -if test ! -d CaseSensitiveTestDir; then -mkdir CaseSensitiveTestDir -fi - -if test -d casesensitivetestdir -then - AC_MSG_RESULT(yes) - BUILDEXEEXT=.exe -else - AC_MSG_RESULT(no) - BUILDEXEEXT=$EXEEXT -fi -rmdir CaseSensitiveTestDir - -case $MACHDEP in -bsdos*) - case $CC in - gcc) CC="$CC -D_HAVE_BSDI";; - esac;; -esac - -case $ac_sys_system in -hp*|HP*) - case $CC in - cc|*/cc) CC="$CC -Ae";; - esac;; -SunOS*) - # Some functions have a prototype only with that define, e.g. confstr - AC_DEFINE(__EXTENSIONS__, 1, [Defined on Solaris to see additional function prototypes.]) - ;; -esac - - -AC_SUBST(LIBRARY) -AC_MSG_CHECKING(LIBRARY) -if test -z "$LIBRARY" -then - LIBRARY='libpython$(VERSION).a' -fi -AC_MSG_RESULT($LIBRARY) - -# LDLIBRARY is the name of the library to link against (as opposed to the -# name of the library into which to insert object files). BLDLIBRARY is also -# the library to link against, usually. On Mac OS X frameworks, BLDLIBRARY -# is blank as the main program is not linked directly against LDLIBRARY. -# LDLIBRARYDIR is the path to LDLIBRARY, which is made in a subdirectory. On -# systems without shared libraries, LDLIBRARY is the same as LIBRARY -# (defined in the Makefiles). On Cygwin LDLIBRARY is the import library, -# DLLLIBRARY is the shared (i.e., DLL) library. -# -# RUNSHARED is used to run shared python without installed libraries -# -# INSTSONAME is the name of the shared library that will be use to install -# on the system - some systems like version suffix, others don't -AC_SUBST(LDLIBRARY) -AC_SUBST(DLLLIBRARY) -AC_SUBST(BLDLIBRARY) -AC_SUBST(LDLIBRARYDIR) -AC_SUBST(INSTSONAME) -AC_SUBST(RUNSHARED) -LDLIBRARY="$LIBRARY" -BLDLIBRARY='$(LDLIBRARY)' -INSTSONAME='$(LDLIBRARY)' -DLLLIBRARY='' -LDLIBRARYDIR='' -RUNSHARED='' - -# LINKCC is the command that links the python executable -- default is $(CC). -# If CXX is set, and if it is needed to link a main function that was -# compiled with CXX, LINKCC is CXX instead. Always using CXX is undesirable: -# python might then depend on the C++ runtime -# This is altered for AIX in order to build the export list before -# linking. -AC_SUBST(LINKCC) -AC_MSG_CHECKING(LINKCC) -if test -z "$LINKCC" -then - LINKCC='$(PURIFY) $(MAINCC)' - case $ac_sys_system in - AIX*) - exp_extra="\"\"" - if test $ac_sys_release -ge 5 -o \ - $ac_sys_release -eq 4 -a `uname -r` -ge 2 ; then - exp_extra="." - fi - LINKCC="\$(srcdir)/Modules/makexp_aix Modules/python.exp $exp_extra \$(LIBRARY); $LINKCC";; - QNX*) - # qcc must be used because the other compilers do not - # support -N. - LINKCC=qcc;; - esac -fi -AC_MSG_RESULT($LINKCC) - -# GNULD is set to "yes" if the GNU linker is used. If this goes wrong -# make sure we default having it set to "no": this is used by -# distutils.unixccompiler to know if it should add --enable-new-dtags -# to linker command lines, and failing to detect GNU ld simply results -# in the same bahaviour as before. -AC_SUBST(GNULD) -AC_MSG_CHECKING(for GNU ld) -ac_prog=ld -if test "$GCC" = yes; then - ac_prog=`$CC -print-prog-name=ld` -fi -case `"$ac_prog" -V 2>&1 < /dev/null` in - *GNU*) - GNULD=yes;; - *) - GNULD=no;; -esac -AC_MSG_RESULT($GNULD) - -AC_MSG_CHECKING(for --enable-shared) -AC_ARG_ENABLE(shared, - AS_HELP_STRING([--enable-shared], [disable/enable building shared python library])) - -if test -z "$enable_shared" -then - case $ac_sys_system in - CYGWIN* | atheos*) - enable_shared="yes";; - *) - enable_shared="no";; - esac -fi -AC_MSG_RESULT($enable_shared) - -AC_MSG_CHECKING(for --enable-profiling) -AC_ARG_ENABLE(profiling, - AS_HELP_STRING([--enable-profiling], [enable C-level code profiling])) -if test "x$enable_profiling" = xyes; then - ac_save_cc="$CC" - CC="$CC -pg" - AC_LINK_IFELSE([AC_LANG_SOURCE([[int main() { return 0; }]])], - [], - [enable_profiling=no]) - CC="$ac_save_cc" -else - enable_profiling=no -fi -AC_MSG_RESULT($enable_profiling) - -if test "x$enable_profiling" = xyes; then - BASECFLAGS="-pg $BASECFLAGS" - LDFLAGS="-pg $LDFLAGS" -fi - -AC_MSG_CHECKING(LDLIBRARY) - -# MacOSX framework builds need more magic. LDLIBRARY is the dynamic -# library that we build, but we do not want to link against it (we -# will find it with a -framework option). For this reason there is an -# extra variable BLDLIBRARY against which Python and the extension -# modules are linked, BLDLIBRARY. This is normally the same as -# LDLIBRARY, but empty for MacOSX framework builds. -if test "$enable_framework" -then - LDLIBRARY='$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)' - RUNSHARED=DYLD_FRAMEWORK_PATH=`pwd`${DYLD_FRAMEWORK_PATH:+:${DYLD_FRAMEWORK_PATH}} - BLDLIBRARY='' -else - BLDLIBRARY='$(LDLIBRARY)' -fi - -# Other platforms follow -if test $enable_shared = "yes"; then - AC_DEFINE(Py_ENABLE_SHARED, 1, [Defined if Python is built as a shared library.]) - case $ac_sys_system in - BeOS*) - LDLIBRARY='libpython$(VERSION).so' - ;; - CYGWIN*) - LDLIBRARY='libpython$(VERSION).dll.a' - DLLLIBRARY='libpython$(VERSION).dll' - ;; - SunOS*) - LDLIBRARY='libpython$(VERSION).so' - BLDLIBRARY='-Wl,-R,$(LIBDIR) -L. -lpython$(VERSION)' - RUNSHARED=LD_LIBRARY_PATH=`pwd`${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}} - INSTSONAME="$LDLIBRARY".$SOVERSION - ;; - Linux*|GNU*|NetBSD*|FreeBSD*|DragonFly*|OpenBSD*) - LDLIBRARY='libpython$(VERSION).so' - BLDLIBRARY='-L. -lpython$(VERSION)' - RUNSHARED=LD_LIBRARY_PATH=`pwd`${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}} - case $ac_sys_system in - FreeBSD*) - SOVERSION=`echo $SOVERSION|cut -d "." -f 1` - ;; - esac - INSTSONAME="$LDLIBRARY".$SOVERSION - ;; - hp*|HP*) - case `uname -m` in - ia64) - LDLIBRARY='libpython$(VERSION).so' - ;; - *) - LDLIBRARY='libpython$(VERSION).sl' - ;; - esac - BLDLIBRARY='-Wl,+b,$(LIBDIR) -L. -lpython$(VERSION)' - RUNSHARED=SHLIB_PATH=`pwd`${SHLIB_PATH:+:${SHLIB_PATH}} - ;; - OSF*) - LDLIBRARY='libpython$(VERSION).so' - BLDLIBRARY='-rpath $(LIBDIR) -L. -lpython$(VERSION)' - RUNSHARED=LD_LIBRARY_PATH=`pwd`${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}} - ;; - atheos*) - LDLIBRARY='libpython$(VERSION).so' - BLDLIBRARY='-L. -lpython$(VERSION)' - RUNSHARED=DLL_PATH=`pwd`:${DLL_PATH:-/atheos/sys/libs:/atheos/autolnk/lib} - ;; - Darwin*) - LDLIBRARY='libpython$(VERSION).dylib' - BLDLIBRARY='-L. -lpython$(VERSION)' - RUNSHARED=DYLD_LIBRARY_PATH=`pwd`${DYLD_LIBRARY_PATH:+:${DYLD_LIBRARY_PATH}} - ;; - AIX*) - LDLIBRARY='libpython$(VERSION).so' - RUNSHARED=LIBPATH=`pwd`${LIBPATH:+:${LIBPATH}} - ;; - - esac -else # shared is disabled - case $ac_sys_system in - CYGWIN*) - BLDLIBRARY='$(LIBRARY)' - LDLIBRARY='libpython$(VERSION).dll.a' - ;; - esac -fi - -if test "$cross_compiling" = yes; then - RUNSHARED= -fi - -AC_MSG_RESULT($LDLIBRARY) - -AC_PROG_RANLIB -AC_SUBST(AR) -AC_CHECK_TOOLS(AR, ar aal, ar) - -# tweak ARFLAGS only if the user didn't set it on the command line -AC_SUBST(ARFLAGS) -if test -z "$ARFLAGS" -then - ARFLAGS="rc" -fi - -AC_SUBST(SVNVERSION) -AC_CHECK_PROG(SVNVERSION, svnversion, found, not-found) -if test $SVNVERSION = found -then - SVNVERSION="svnversion \$(srcdir)" -else - SVNVERSION="echo Unversioned directory" -fi - -AC_SUBST(BASECPPFLAGS) -if test "$abs_srcdir" != "$abs_builddir"; then - # If we're building out-of-tree make sure Include (in the current dir) - # gets picked up before its $srcdir counterpart in order for Python-ast.h - # and graminit.h to get picked up from the correct directory. - # (A side effect of this is that these resources will automatically be - # regenerated when building out-of-tree, regardless of whether or not - # the $srcdir counterpart is up-to-date. This is an acceptable trade - # off.) - BASECPPFLAGS="-IInclude" -else - BASECPPFLAGS="" -fi - -AC_SUBST(HGVERSION) -AC_SUBST(HGTAG) -AC_SUBST(HGBRANCH) -AC_CHECK_PROG(HAS_HG, hg, found, not-found) -if test $HAS_HG = found -then - HGVERSION="hg id -i \$(srcdir)" - HGTAG="hg id -t \$(srcdir)" - HGBRANCH="hg id -b \$(srcdir)" -else - HGVERSION="" - HGTAG="" - HGBRANCH="" -fi - -case $MACHDEP in -bsdos*|hp*|HP*) - # install -d does not work on BSDI or HP-UX - if test -z "$INSTALL" - then - INSTALL="${srcdir}/install-sh -c" - fi -esac -AC_PROG_INSTALL -AC_PROG_MKDIR_P - -# Not every filesystem supports hard links -AC_SUBST(LN) -if test -z "$LN" ; then - case $ac_sys_system in - BeOS*) LN="ln -s";; - CYGWIN*) LN="ln -s";; - atheos*) LN="ln -s";; - *) LN=ln;; - esac -fi - -# Check for --with-pydebug -AC_MSG_CHECKING(for --with-pydebug) -AC_ARG_WITH(pydebug, - AS_HELP_STRING([--with-pydebug], [build with Py_DEBUG defined]), -[ -if test "$withval" != no -then - AC_DEFINE(Py_DEBUG, 1, - [Define if you want to build an interpreter with many run-time checks.]) - AC_MSG_RESULT(yes); - Py_DEBUG='true' -else AC_MSG_RESULT(no); Py_DEBUG='false' -fi], -[AC_MSG_RESULT(no)]) - -# XXX Shouldn't the code above that fiddles with BASECFLAGS and OPT be -# merged with this chunk of code? - -# Optimizer/debugger flags -# ------------------------ -# (The following bit of code is complicated enough - please keep things -# indented properly. Just pretend you're editing Python code. ;-) - -# There are two parallel sets of case statements below, one that checks to -# see if OPT was set and one that does BASECFLAGS setting based upon -# compiler and platform. BASECFLAGS tweaks need to be made even if the -# user set OPT. - -# tweak OPT based on compiler and platform, only if the user didn't set -# it on the command line -AC_SUBST(OPT) -if test "${OPT-unset}" = "unset" -then - case $GCC in - yes) - if test "$CC" != 'g++' ; then - STRICT_PROTO="-Wstrict-prototypes" - fi - # For gcc 4.x we need to use -fwrapv so lets check if its supported - if "$CC" -v --help 2>/dev/null |grep -- -fwrapv > /dev/null; then - WRAP="-fwrapv" - fi - - # Clang also needs -fwrapv - case $CC in - *clang*) WRAP="-fwrapv" - ;; - esac - - case $ac_cv_prog_cc_g in - yes) - if test "$Py_DEBUG" = 'true' ; then - # Optimization messes up debuggers, so turn it off for - # debug builds. - OPT="-g -O0 -Wall $STRICT_PROTO" - else - OPT="-g $WRAP -O3 -Wall $STRICT_PROTO" - fi - ;; - *) - OPT="-O3 -Wall $STRICT_PROTO" - ;; - esac - case $ac_sys_system in - SCO_SV*) OPT="$OPT -m486 -DSCO5" - ;; - esac - ;; - - *) - OPT="-O" - ;; - esac -fi - -AC_SUBST(BASECFLAGS) - -# The -arch flags for universal builds on OSX -UNIVERSAL_ARCH_FLAGS= -AC_SUBST(UNIVERSAL_ARCH_FLAGS) - -# tweak BASECFLAGS based on compiler and platform -case $GCC in -yes) - # Python violates C99 rules, by casting between incompatible - # pointer types. GCC may generate bad code as a result of that, - # so use -fno-strict-aliasing if supported. - AC_MSG_CHECKING(whether $CC accepts -fno-strict-aliasing) - ac_save_cc="$CC" - CC="$CC -fno-strict-aliasing" - AC_CACHE_VAL(ac_cv_no_strict_aliasing_ok, - AC_COMPILE_IFELSE( - [AC_LANG_PROGRAM([[]], [[]])], - [ac_cv_no_strict_aliasing_ok=yes], - [ac_cv_no_strict_aliasing_ok=no])) - CC="$ac_save_cc" - AC_MSG_RESULT($ac_cv_no_strict_aliasing_ok) - if test $ac_cv_no_strict_aliasing_ok = yes - then - BASECFLAGS="$BASECFLAGS -fno-strict-aliasing" - fi - - # if using gcc on alpha, use -mieee to get (near) full IEEE 754 - # support. Without this, treatment of subnormals doesn't follow - # the standard. - case $host in - alpha*) - BASECFLAGS="$BASECFLAGS -mieee" - ;; - esac - - case $ac_sys_system in - SCO_SV*) - BASECFLAGS="$BASECFLAGS -m486 -DSCO5" - ;; - # is there any other compiler on Darwin besides gcc? - Darwin*) - # -Wno-long-double, -no-cpp-precomp, and -mno-fused-madd - # used to be here, but non-Apple gcc doesn't accept them. - if test "${CC}" = gcc - then - AC_MSG_CHECKING(which compiler should be used) - case "${UNIVERSALSDK}" in - */MacOSX10.4u.sdk) - # Build using 10.4 SDK, force usage of gcc when the - # compiler is gcc, otherwise the user will get very - # confusing error messages when building on OSX 10.6 - CC=gcc-4.0 - CPP=cpp-4.0 - ;; - esac - AC_MSG_RESULT($CC) - fi - - # Calculate the right deployment target for this build. - # - cur_target_major=`sw_vers -productVersion | \ - sed 's/\([[0-9]]*\)\.\([[0-9]]*\).*/\1/'` - cur_target_minor=`sw_vers -productVersion | \ - sed 's/\([[0-9]]*\)\.\([[0-9]]*\).*/\2/'` - cur_target="${cur_target_major}.${cur_target_minor}" - if test ${cur_target_major} -eq 10 && \ - test ${cur_target_minor} -ge 3 - then - cur_target=10.3 - if test ${enable_universalsdk}; then - if test "${UNIVERSAL_ARCHS}" = "all"; then - # Ensure that the default platform for a - # 4-way universal build is OSX 10.5, - # that's the first OS release where - # 4-way builds make sense. - cur_target='10.5' - - elif test "${UNIVERSAL_ARCHS}" = "3-way"; then - cur_target='10.5' - - elif test "${UNIVERSAL_ARCHS}" = "intel"; then - cur_target='10.5' - - elif test "${UNIVERSAL_ARCHS}" = "64-bit"; then - cur_target='10.5' - fi - else - if test `/usr/bin/arch` = "i386"; then - # On Intel macs default to a deployment - # target of 10.4, that's the first OSX - # release with Intel support. - cur_target="10.4" - fi - fi - fi - CONFIGURE_MACOSX_DEPLOYMENT_TARGET=${MACOSX_DEPLOYMENT_TARGET-${cur_target}} - - # Make sure that MACOSX_DEPLOYMENT_TARGET is set in the - # environment with a value that is the same as what we'll use - # in the Makefile to ensure that we'll get the same compiler - # environment during configure and build time. - MACOSX_DEPLOYMENT_TARGET="$CONFIGURE_MACOSX_DEPLOYMENT_TARGET" - export MACOSX_DEPLOYMENT_TARGET - EXPORT_MACOSX_DEPLOYMENT_TARGET='' - - if test "${enable_universalsdk}"; then - UNIVERSAL_ARCH_FLAGS="" - if test "$UNIVERSAL_ARCHS" = "32-bit" ; then - UNIVERSAL_ARCH_FLAGS="-arch ppc -arch i386" - ARCH_RUN_32BIT="" - LIPO_32BIT_FLAGS="" - - elif test "$UNIVERSAL_ARCHS" = "64-bit" ; then - UNIVERSAL_ARCH_FLAGS="-arch ppc64 -arch x86_64" - LIPO_32BIT_FLAGS="" - ARCH_RUN_32BIT="true" - - elif test "$UNIVERSAL_ARCHS" = "all" ; then - UNIVERSAL_ARCH_FLAGS="-arch i386 -arch ppc -arch ppc64 -arch x86_64" - LIPO_32BIT_FLAGS="-extract ppc7400 -extract i386" - ARCH_RUN_32BIT="/usr/bin/arch -i386 -ppc" - - elif test "$UNIVERSAL_ARCHS" = "intel" ; then - UNIVERSAL_ARCH_FLAGS="-arch i386 -arch x86_64" - LIPO_32BIT_FLAGS="-extract i386" - ARCH_RUN_32BIT="/usr/bin/arch -i386" - - elif test "$UNIVERSAL_ARCHS" = "3-way" ; then - UNIVERSAL_ARCH_FLAGS="-arch i386 -arch ppc -arch x86_64" - LIPO_32BIT_FLAGS="-extract ppc7400 -extract i386" - ARCH_RUN_32BIT="/usr/bin/arch -i386 -ppc" - - else - AC_MSG_ERROR([proper usage is --with-universal-arch=32-bit|64-bit|all|intel|3-way]) - - fi - - - CFLAGS="${UNIVERSAL_ARCH_FLAGS} ${CFLAGS}" - if test "${UNIVERSALSDK}" != "/" - then - CPPFLAGS="-isysroot ${UNIVERSALSDK} ${CPPFLAGS}" - LDFLAGS="-isysroot ${UNIVERSALSDK} ${LDFLAGS}" - CFLAGS="-isysroot ${UNIVERSALSDK} ${CFLAGS}" - fi - - fi - - - ;; - OSF*) - BASECFLAGS="$BASECFLAGS -mieee" - ;; - esac - ;; - -*) - case $ac_sys_system in - OpenUNIX*|UnixWare*) - BASECFLAGS="$BASECFLAGS -K pentium,host,inline,loop_unroll,alloca " - ;; - OSF*) - BASECFLAGS="$BASECFLAGS -ieee -std" - ;; - SCO_SV*) - BASECFLAGS="$BASECFLAGS -belf -Ki486 -DSCO5" - ;; - esac - ;; -esac - -if test "$Py_DEBUG" = 'true'; then - : -else - OPT="-DNDEBUG $OPT" -fi - -if test "$ac_arch_flags" -then - BASECFLAGS="$BASECFLAGS $ac_arch_flags" -fi - -# disable check for icc since it seems to pass, but generates a warning -if test "$CC" = icc -then - ac_cv_opt_olimit_ok=no -fi - -AC_MSG_CHECKING(whether $CC accepts -OPT:Olimit=0) -AC_CACHE_VAL(ac_cv_opt_olimit_ok, -[ac_save_cc="$CC" -CC="$CC -OPT:Olimit=0" -AC_COMPILE_IFELSE( - [AC_LANG_PROGRAM([[]], [[]])], - [ac_cv_opt_olimit_ok=yes], - [ac_cv_opt_olimit_ok=no] - ) -CC="$ac_save_cc"]) -AC_MSG_RESULT($ac_cv_opt_olimit_ok) -if test $ac_cv_opt_olimit_ok = yes; then - case $ac_sys_system in - # XXX is this branch needed? On MacOSX 10.2.2 the result of the - # olimit_ok test is "no". Is it "yes" in some other Darwin-esque - # environment? - Darwin*) - ;; - # XXX thankfully this useless troublemaker of a flag has been - # eradicated in the 3.x line. For now, make sure it isn't picked - # up by any of our other platforms that use CC. - AIX*|SunOS*|HP-UX*|IRIX*) - ;; - *) - BASECFLAGS="$BASECFLAGS -OPT:Olimit=0" - ;; - esac -else - AC_MSG_CHECKING(whether $CC accepts -Olimit 1500) - AC_CACHE_VAL(ac_cv_olimit_ok, - [ac_save_cc="$CC" - CC="$CC -Olimit 1500" - AC_COMPILE_IFELSE( - [AC_LANG_PROGRAM([[]], [[]])], - [ac_cv_olimit_ok=yes], - [ac_cv_olimit_ok=no] - ) - CC="$ac_save_cc"]) - AC_MSG_RESULT($ac_cv_olimit_ok) - if test $ac_cv_olimit_ok = yes; then - case $ac_sys_system in - # Issue #16534: On HP-UX ac_cv_olimit_ok=yes is a false positive. - HP-UX*) - ;; - *) - BASECFLAGS="$BASECFLAGS -Olimit 1500" - ;; - esac - fi -fi - -# Check whether GCC supports PyArg_ParseTuple format -if test "$GCC" = "yes" -then - AC_MSG_CHECKING(whether gcc supports ParseTuple __format__) - save_CFLAGS=$CFLAGS - CFLAGS="$CFLAGS -Werror -Wformat" - AC_COMPILE_IFELSE([ - AC_LANG_PROGRAM([[void f(char*,...)__attribute((format(PyArg_ParseTuple, 1, 2)));]], [[]]) - ],[ - AC_DEFINE(HAVE_ATTRIBUTE_FORMAT_PARSETUPLE, 1, - [Define if GCC supports __attribute__((format(PyArg_ParseTuple, 2, 3)))]) - AC_MSG_RESULT(yes) - ],[ - AC_MSG_RESULT(no) - ]) - CFLAGS=$save_CFLAGS -fi - -# On some compilers, pthreads are available without further options -# (e.g. MacOS X). On some of these systems, the compiler will not -# complain if unaccepted options are passed (e.g. gcc on Mac OS X). -# So we have to see first whether pthreads are available without -# options before we can check whether -Kpthread improves anything. -AC_MSG_CHECKING(whether pthreads are available without options) -AC_CACHE_VAL(ac_cv_pthread_is_default, -[AC_RUN_IFELSE([AC_LANG_SOURCE([[ -#include -#include - -void* routine(void* p){return NULL;} - -int main(){ - pthread_t p; - if(pthread_create(&p,NULL,routine,NULL)!=0) - return 1; - (void)pthread_detach(p); - return 0; -} -]])],[ - ac_cv_pthread_is_default=yes - ac_cv_kthread=no - ac_cv_pthread=no -],[ac_cv_pthread_is_default=no],[ac_cv_pthread_is_default=no]) -]) -AC_MSG_RESULT($ac_cv_pthread_is_default) - - -if test $ac_cv_pthread_is_default = yes -then - ac_cv_kpthread=no -else -# -Kpthread, if available, provides the right #defines -# and linker options to make pthread_create available -# Some compilers won't report that they do not support -Kpthread, -# so we need to run a program to see whether it really made the -# function available. -AC_MSG_CHECKING(whether $CC accepts -Kpthread) -AC_CACHE_VAL(ac_cv_kpthread, -[ac_save_cc="$CC" -CC="$CC -Kpthread" -AC_RUN_IFELSE([AC_LANG_SOURCE([[ -#include -#include - -void* routine(void* p){return NULL;} - -int main(){ - pthread_t p; - if(pthread_create(&p,NULL,routine,NULL)!=0) - return 1; - (void)pthread_detach(p); - return 0; -} -]])],[ac_cv_kpthread=yes],[ac_cv_kpthread=no],[ac_cv_kpthread=no]) -CC="$ac_save_cc"]) -AC_MSG_RESULT($ac_cv_kpthread) -fi - -if test $ac_cv_kpthread = no -a $ac_cv_pthread_is_default = no -then -# -Kthread, if available, provides the right #defines -# and linker options to make pthread_create available -# Some compilers won't report that they do not support -Kthread, -# so we need to run a program to see whether it really made the -# function available. -AC_MSG_CHECKING(whether $CC accepts -Kthread) -AC_CACHE_VAL(ac_cv_kthread, -[ac_save_cc="$CC" -CC="$CC -Kthread" -AC_RUN_IFELSE([AC_LANG_SOURCE([[ -#include -#include - -void* routine(void* p){return NULL;} - -int main(){ - pthread_t p; - if(pthread_create(&p,NULL,routine,NULL)!=0) - return 1; - (void)pthread_detach(p); - return 0; -} -]])],[ac_cv_kthread=yes],[ac_cv_kthread=no],[ac_cv_kthread=no]) -CC="$ac_save_cc"]) -AC_MSG_RESULT($ac_cv_kthread) -fi - -if test $ac_cv_kthread = no -a $ac_cv_pthread_is_default = no -then -# -pthread, if available, provides the right #defines -# and linker options to make pthread_create available -# Some compilers won't report that they do not support -pthread, -# so we need to run a program to see whether it really made the -# function available. -AC_MSG_CHECKING(whether $CC accepts -pthread) -AC_CACHE_VAL(ac_cv_pthread, -[ac_save_cc="$CC" -CC="$CC -pthread" -AC_RUN_IFELSE([AC_LANG_SOURCE([[ -#include -#include - -void* routine(void* p){return NULL;} - -int main(){ - pthread_t p; - if(pthread_create(&p,NULL,routine,NULL)!=0) - return 1; - (void)pthread_detach(p); - return 0; -} -]])],[ac_cv_pthread=yes],[ac_cv_pthread=no],[ac_cv_pthread=no]) -CC="$ac_save_cc"]) -AC_MSG_RESULT($ac_cv_pthread) -fi - -# If we have set a CC compiler flag for thread support then -# check if it works for CXX, too. -ac_cv_cxx_thread=no -if test ! -z "$CXX" -then -AC_MSG_CHECKING(whether $CXX also accepts flags for thread support) -ac_save_cxx="$CXX" - -if test "$ac_cv_kpthread" = "yes" -then - CXX="$CXX -Kpthread" - ac_cv_cxx_thread=yes -elif test "$ac_cv_kthread" = "yes" -then - CXX="$CXX -Kthread" - ac_cv_cxx_thread=yes -elif test "$ac_cv_pthread" = "yes" -then - CXX="$CXX -pthread" - ac_cv_cxx_thread=yes -fi - -if test $ac_cv_cxx_thread = yes -then - echo 'void foo();int main(){foo();}void foo(){}' > conftest.$ac_ext - $CXX -c conftest.$ac_ext 2>&5 - if $CXX -o conftest$ac_exeext conftest.$ac_objext 2>&5 \ - && test -s conftest$ac_exeext && ./conftest$ac_exeext - then - ac_cv_cxx_thread=yes - else - ac_cv_cxx_thread=no - fi - rm -fr conftest* -fi -AC_MSG_RESULT($ac_cv_cxx_thread) -fi -CXX="$ac_save_cxx" - -dnl # check for ANSI or K&R ("traditional") preprocessor -dnl AC_MSG_CHECKING(for C preprocessor type) -dnl AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ -dnl #define spam(name, doc) {#name, &name, #name "() -- " doc} -dnl int foo; -dnl struct {char *name; int *addr; char *doc;} desc = spam(foo, "something"); -dnl ]], [[;]])],[cpp_type=ansi],[AC_DEFINE(HAVE_OLD_CPP) cpp_type=traditional]) -dnl AC_MSG_RESULT($cpp_type) - -# checks for header files -AC_HEADER_STDC -AC_CHECK_HEADERS(asm/types.h conio.h direct.h dlfcn.h errno.h \ -fcntl.h grp.h \ -ieeefp.h io.h langinfo.h libintl.h poll.h process.h pthread.h \ -shadow.h signal.h stdint.h stropts.h termios.h thread.h \ -unistd.h utime.h \ -sys/audioio.h sys/bsdtty.h sys/epoll.h sys/event.h sys/file.h sys/loadavg.h \ -sys/lock.h sys/mkdev.h sys/modem.h \ -sys/param.h sys/poll.h sys/select.h sys/socket.h sys/statvfs.h sys/stat.h \ -sys/termio.h sys/time.h \ -sys/times.h sys/types.h sys/un.h sys/utsname.h sys/wait.h pty.h libutil.h \ -sys/resource.h netpacket/packet.h sysexits.h bluetooth.h \ -bluetooth/bluetooth.h linux/tipc.h spawn.h util.h alloca.h) -AC_HEADER_DIRENT -AC_HEADER_MAJOR - -# On Linux, netlink.h requires asm/types.h -AC_CHECK_HEADERS(linux/netlink.h,,,[ -#ifdef HAVE_ASM_TYPES_H -#include -#endif -#ifdef HAVE_SYS_SOCKET_H -#include -#endif -]) - -# checks for typedefs -was_it_defined=no -AC_MSG_CHECKING(for clock_t in time.h) -AC_EGREP_HEADER(clock_t, time.h, was_it_defined=yes, [ - AC_DEFINE(clock_t, long, [Define to 'long' if doesn't define.]) -]) -AC_MSG_RESULT($was_it_defined) - -# Check whether using makedev requires defining _OSF_SOURCE -AC_MSG_CHECKING(for makedev) -AC_LINK_IFELSE([AC_LANG_PROGRAM([[ -#if defined(MAJOR_IN_MKDEV) -#include -#elif defined(MAJOR_IN_SYSMACROS) -#include -#else -#include -#endif ]], [[ makedev(0, 0) ]])], -[ac_cv_has_makedev=yes], -[ac_cv_has_makedev=no]) -if test "$ac_cv_has_makedev" = "no"; then - # we didn't link, try if _OSF_SOURCE will allow us to link - AC_LINK_IFELSE([AC_LANG_PROGRAM([[ -#define _OSF_SOURCE 1 -#include - ]], [[ makedev(0, 0) ]])], -[ac_cv_has_makedev=yes], -[ac_cv_has_makedev=no]) - if test "$ac_cv_has_makedev" = "yes"; then - AC_DEFINE(_OSF_SOURCE, 1, [Define _OSF_SOURCE to get the makedev macro.]) - fi -fi -AC_MSG_RESULT($ac_cv_has_makedev) -if test "$ac_cv_has_makedev" = "yes"; then - AC_DEFINE(HAVE_MAKEDEV, 1, [Define this if you have the makedev macro.]) -fi - -# Enabling LFS on Solaris (2.6 to 9) with gcc 2.95 triggers a bug in -# the system headers: If _XOPEN_SOURCE and _LARGEFILE_SOURCE are -# defined, but the compiler does not support pragma redefine_extname, -# and _LARGEFILE64_SOURCE is not defined, the headers refer to 64-bit -# structures (such as rlimit64) without declaring them. As a -# work-around, disable LFS on such configurations - -use_lfs=yes -AC_MSG_CHECKING(Solaris LFS bug) -AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ -#define _LARGEFILE_SOURCE 1 -#define _FILE_OFFSET_BITS 64 -#include -]], [[struct rlimit foo;]])],[sol_lfs_bug=no],[sol_lfs_bug=yes]) -AC_MSG_RESULT($sol_lfs_bug) -if test "$sol_lfs_bug" = "yes"; then - use_lfs=no -fi - -if test "$use_lfs" = "yes"; then -# Two defines needed to enable largefile support on various platforms -# These may affect some typedefs -case $ac_sys_system/$ac_sys_release in -AIX*) - AC_DEFINE(_LARGE_FILES, 1, - [This must be defined on AIX systems to enable large file support.]) - ;; -esac -AC_DEFINE(_LARGEFILE_SOURCE, 1, -[This must be defined on some systems to enable large file support.]) -AC_DEFINE(_FILE_OFFSET_BITS, 64, -[This must be set to 64 on some systems to enable large file support.]) -fi - -# Add some code to confdefs.h so that the test for off_t works on SCO -cat >> confdefs.h <<\EOF -#if defined(SCO_DS) -#undef _OFF_T -#endif -EOF - -# Type availability checks -AC_TYPE_MODE_T -AC_TYPE_OFF_T -AC_TYPE_PID_T -AC_DEFINE_UNQUOTED([RETSIGTYPE],[void],[assume C89 semantics that RETSIGTYPE is always void]) -AC_TYPE_SIZE_T -AC_TYPE_UID_T - -# There are two separate checks for each of the exact-width integer types we -# need. First we check whether the type is available using the usual -# AC_CHECK_TYPE macro with the default includes (which includes -# and where available). We then also use the special type checks of -# the form AC_TYPE_UINT32_T, which in the case that uint32_t is not available -# directly, #define's uint32_t to be a suitable type. - -AC_CHECK_TYPE(uint32_t, - AC_DEFINE(HAVE_UINT32_T, 1, [Define if your compiler provides uint32_t.]),,) -AC_TYPE_UINT32_T - -AC_CHECK_TYPE(uint64_t, - AC_DEFINE(HAVE_UINT64_T, 1, [Define if your compiler provides uint64_t.]),,) -AC_TYPE_UINT64_T - -AC_CHECK_TYPE(int32_t, - AC_DEFINE(HAVE_INT32_T, 1, [Define if your compiler provides int32_t.]),,) -AC_TYPE_INT32_T - -AC_CHECK_TYPE(int64_t, - AC_DEFINE(HAVE_INT64_T, 1, [Define if your compiler provides int64_t.]),,) -AC_TYPE_INT64_T - -AC_CHECK_TYPE(ssize_t, - AC_DEFINE(HAVE_SSIZE_T, 1, [Define if your compiler provides ssize_t]),,) - -# Sizes of various common basic types -# ANSI C requires sizeof(char) == 1, so no need to check it -AC_CHECK_SIZEOF(int, 4) -AC_CHECK_SIZEOF(long, 4) -AC_CHECK_SIZEOF(void *, 4) -AC_CHECK_SIZEOF(short, 2) -AC_CHECK_SIZEOF(float, 4) -AC_CHECK_SIZEOF(double, 8) -AC_CHECK_SIZEOF(fpos_t, 4) -AC_CHECK_SIZEOF(size_t, 4) -AC_CHECK_SIZEOF(pid_t, 4) - -AC_MSG_CHECKING(for long long support) -have_long_long=no -AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[long long x; x = (long long)0;]])],[ - AC_DEFINE(HAVE_LONG_LONG, 1, [Define this if you have the type long long.]) - have_long_long=yes -],[]) -AC_MSG_RESULT($have_long_long) -if test "$have_long_long" = yes ; then -AC_CHECK_SIZEOF(long long, 8) -fi - -AC_MSG_CHECKING(for long double support) -have_long_double=no -AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[long double x; x = (long double)0;]])],[ - AC_DEFINE(HAVE_LONG_DOUBLE, 1, [Define this if you have the type long double.]) - have_long_double=yes -],[]) -AC_MSG_RESULT($have_long_double) -if test "$have_long_double" = yes ; then -AC_CHECK_SIZEOF(long double, 12) -fi - -AC_MSG_CHECKING(for _Bool support) -have_c99_bool=no -AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[_Bool x; x = (_Bool)0;]])],[ - AC_DEFINE(HAVE_C99_BOOL, 1, [Define this if you have the type _Bool.]) - have_c99_bool=yes -],[]) -AC_MSG_RESULT($have_c99_bool) -if test "$have_c99_bool" = yes ; then -AC_CHECK_SIZEOF(_Bool, 1) -fi - -AC_CHECK_TYPES(uintptr_t, - [AC_CHECK_SIZEOF(uintptr_t, 4)], - [], [#ifdef HAVE_STDINT_H - #include - #endif - #ifdef HAVE_INTTYPES_H - #include - #endif]) - -AC_CHECK_SIZEOF(off_t, [], [ -#ifdef HAVE_SYS_TYPES_H -#include -#endif -]) - -AC_MSG_CHECKING(whether to enable large file support) -if test "$have_long_long" = yes -then -if test "$ac_cv_sizeof_off_t" -gt "$ac_cv_sizeof_long" -a \ - "$ac_cv_sizeof_long_long" -ge "$ac_cv_sizeof_off_t"; then - AC_DEFINE(HAVE_LARGEFILE_SUPPORT, 1, - [Defined to enable large file support when an off_t is bigger than a long - and long long is available and at least as big as an off_t. You may need - to add some flags for configuration and compilation to enable this mode. - (For Solaris and Linux, the necessary defines are already defined.)]) - AC_MSG_RESULT(yes) -else - AC_MSG_RESULT(no) -fi -else - AC_MSG_RESULT(no) -fi - -AC_CHECK_SIZEOF(time_t, [], [ -#ifdef HAVE_SYS_TYPES_H -#include -#endif -#ifdef HAVE_TIME_H -#include -#endif -]) - -# if have pthread_t then define SIZEOF_PTHREAD_T -ac_save_cc="$CC" -if test "$ac_cv_kpthread" = "yes" -then CC="$CC -Kpthread" -elif test "$ac_cv_kthread" = "yes" -then CC="$CC -Kthread" -elif test "$ac_cv_pthread" = "yes" -then CC="$CC -pthread" -fi -AC_MSG_CHECKING(for pthread_t) -have_pthread_t=no -AC_COMPILE_IFELSE([ - AC_LANG_PROGRAM([[#include ]], [[pthread_t x; x = *(pthread_t*)0;]]) -],[have_pthread_t=yes],[]) -AC_MSG_RESULT($have_pthread_t) -if test "$have_pthread_t" = yes ; then - AC_CHECK_SIZEOF(pthread_t, [], [ -#ifdef HAVE_PTHREAD_H -#include -#endif - ]) -fi -CC="$ac_save_cc" - -AC_MSG_CHECKING(for --enable-toolbox-glue) -AC_ARG_ENABLE(toolbox-glue, - AS_HELP_STRING([--enable-toolbox-glue], [disable/enable MacOSX glue code for extensions])) - -if test -z "$enable_toolbox_glue" -then - case $ac_sys_system/$ac_sys_release in - Darwin/*) - enable_toolbox_glue="yes";; - *) - enable_toolbox_glue="no";; - esac -fi -case "$enable_toolbox_glue" in -yes) - extra_machdep_objs="Python/mactoolboxglue.o" - extra_undefs="-u _PyMac_Error" - AC_DEFINE(USE_TOOLBOX_OBJECT_GLUE, 1, - [Define if you want to use MacPython modules on MacOSX in unix-Python.]) - ;; -*) - extra_machdep_objs="" - extra_undefs="" - ;; -esac -AC_MSG_RESULT($enable_toolbox_glue) - - -AC_SUBST(OTHER_LIBTOOL_OPT) -case $ac_sys_system/$ac_sys_release in - Darwin/@<:@01567@:>@\..*) - OTHER_LIBTOOL_OPT="-prebind -seg1addr 0x10000000" - ;; - Darwin/*) - OTHER_LIBTOOL_OPT="" - ;; -esac - - -AC_SUBST(LIBTOOL_CRUFT) -case $ac_sys_system/$ac_sys_release in - Darwin/@<:@01567@:>@\..*) - LIBTOOL_CRUFT="-framework System -lcc_dynamic" - if test "${enable_universalsdk}"; then - : - else - LIBTOOL_CRUFT="${LIBTOOL_CRUFT} -arch_only `/usr/bin/arch`" - fi - LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -install_name $(PYTHONFRAMEWORKINSTALLDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)' - LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -compatibility_version $(VERSION) -current_version $(VERSION)';; - Darwin/*) - gcc_version=`gcc -dumpversion` - if test ${gcc_version} '<' 4.0 - then - LIBTOOL_CRUFT="-lcc_dynamic" - else - LIBTOOL_CRUFT="" - fi - AC_RUN_IFELSE([AC_LANG_SOURCE([[ - #include - int main(int argc, char*argv[]) - { - if (sizeof(long) == 4) { - return 0; - } else { - return 1; - } - } - ]])],[ac_osx_32bit=yes],[ac_osx_32bit=no],[ac_osx_32bit=yes]) - - if test "${ac_osx_32bit}" = "yes"; then - case `/usr/bin/arch` in - i386) - MACOSX_DEFAULT_ARCH="i386" - ;; - ppc) - MACOSX_DEFAULT_ARCH="ppc" - ;; - *) - AC_MSG_ERROR([Unexpected output of 'arch' on OSX]) - ;; - esac - else - case `/usr/bin/arch` in - i386) - MACOSX_DEFAULT_ARCH="x86_64" - ;; - ppc) - MACOSX_DEFAULT_ARCH="ppc64" - ;; - *) - AC_MSG_ERROR([Unexpected output of 'arch' on OSX]) - ;; - esac - - #ARCH_RUN_32BIT="true" - fi - - LIBTOOL_CRUFT=$LIBTOOL_CRUFT" -lSystem -lSystemStubs -arch_only ${MACOSX_DEFAULT_ARCH}" - LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -install_name $(PYTHONFRAMEWORKINSTALLDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)' - LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -compatibility_version $(VERSION) -current_version $(VERSION)';; -esac - -AC_MSG_CHECKING(for --enable-framework) -if test "$enable_framework" -then - BASECFLAGS="$BASECFLAGS -fno-common -dynamic" - # -F. is needed to allow linking to the framework while - # in the build location. - AC_DEFINE(WITH_NEXT_FRAMEWORK, 1, - [Define if you want to produce an OpenStep/Rhapsody framework - (shared library plus accessory files).]) - AC_MSG_RESULT(yes) - if test $enable_shared = "yes" - then - AC_MSG_ERROR([Specifying both --enable-shared and --enable-framework is not supported, use only --enable-framework instead. See Mac/README.]) - fi -else - AC_MSG_RESULT(no) -fi - -AC_MSG_CHECKING(for dyld) -case $ac_sys_system/$ac_sys_release in - Darwin/*) - AC_DEFINE(WITH_DYLD, 1, - [Define if you want to use the new-style (Openstep, Rhapsody, MacOS) - dynamic linker (dyld) instead of the old-style (NextStep) dynamic - linker (rld). Dyld is necessary to support frameworks.]) - AC_MSG_RESULT(always on for Darwin) - ;; - *) - AC_MSG_RESULT(no) - ;; -esac - -# Set info about shared libraries. -AC_SUBST(SO) -AC_SUBST(LDSHARED) -AC_SUBST(LDCXXSHARED) -AC_SUBST(BLDSHARED) -AC_SUBST(CCSHARED) -AC_SUBST(LINKFORSHARED) -# SO is the extension of shared libraries `(including the dot!) -# -- usually .so, .sl on HP-UX, .dll on Cygwin -AC_MSG_CHECKING(SO) -if test -z "$SO" -then - case $ac_sys_system in - hp*|HP*) - case `uname -m` in - ia64) SO=.so;; - *) SO=.sl;; - esac - ;; - CYGWIN*) SO=.dll;; - *) SO=.so;; - esac -else - # this might also be a termcap variable, see #610332 - echo - echo '=====================================================================' - echo '+ +' - echo '+ WARNING: You have set SO in your environment. +' - echo '+ Do you really mean to change the extension for shared libraries? +' - echo '+ Continuing in 10 seconds to let you to ponder. +' - echo '+ +' - echo '=====================================================================' - sleep 10 -fi -AC_MSG_RESULT($SO) - -AC_DEFINE_UNQUOTED(SHLIB_EXT, "$SO", [Define this to be extension of shared libraries (including the dot!).]) -# LDSHARED is the ld *command* used to create shared library -# -- "cc -G" on SunOS 5.x, "ld -shared" on IRIX 5 -# (Shared libraries in this instance are shared modules to be loaded into -# Python, as opposed to building Python itself as a shared library.) -AC_MSG_CHECKING(LDSHARED) -if test -z "$LDSHARED" -then - case $ac_sys_system/$ac_sys_release in - AIX*) - BLDSHARED="\$(srcdir)/Modules/ld_so_aix \$(CC) -bI:\$(srcdir)/Modules/python.exp" - LDSHARED="\$(BINLIBDEST)/config/ld_so_aix \$(CC) -bI:\$(BINLIBDEST)/config/python.exp" - ;; - BeOS*) - BLDSHARED="\$(srcdir)/Modules/ld_so_beos $LDLIBRARY" - LDSHARED="\$(BINLIBDEST)/config/ld_so_beos \$(LIBDIR)/$LDLIBRARY" - ;; - IRIX/5*) LDSHARED="ld -shared";; - IRIX*/6*) LDSHARED="ld ${SGI_ABI} -shared -all";; - SunOS/5*) - if test "$GCC" = "yes" ; then - LDSHARED='$(CC) -shared' - LDCXXSHARED='$(CXX) -shared' - else - LDSHARED='$(CC) -G' - LDCXXSHARED='$(CXX) -G' - fi ;; - hp*|HP*) - if test "$GCC" = "yes" ; then - LDSHARED='$(CC) -shared' - LDCXXSHARED='$(CXX) -shared' - else - LDSHARED='ld -b' - fi ;; - OSF*) LDSHARED="ld -shared -expect_unresolved \"*\"";; - Darwin/1.3*) - LDSHARED='$(CC) -bundle' - LDCXXSHARED='$(CXX) -bundle' - if test "$enable_framework" ; then - # Link against the framework. All externals should be defined. - BLDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)' - LDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)' - LDCXXSHARED="$LDCXXSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)' - else - # No framework. Ignore undefined symbols, assuming they come from Python - LDSHARED="$LDSHARED -undefined suppress" - LDCXXSHARED="$LDCXXSHARED -undefined suppress" - fi ;; - Darwin/1.4*|Darwin/5.*|Darwin/6.*) - LDSHARED='$(CC) -bundle' - LDCXXSHARED='$(CXX) -bundle' - if test "$enable_framework" ; then - # Link against the framework. All externals should be defined. - BLDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)' - LDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)' - LDCXXSHARED="$LDCXXSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)' - else - # No framework, use the Python app as bundle-loader - BLDSHARED="$LDSHARED "'-bundle_loader $(BUILDPYTHON)' - LDSHARED="$LDSHARED "'-bundle_loader $(BINDIR)/python$(VERSION)$(EXE)' - LDCXXSHARED="$LDCXXSHARED "'-bundle_loader $(BINDIR)/python$(VERSION)$(EXE)' - fi ;; - Darwin/*) - # Use -undefined dynamic_lookup whenever possible (10.3 and later). - # This allows an extension to be used in any Python - - dep_target_major=`echo ${MACOSX_DEPLOYMENT_TARGET} | \ - sed 's/\([[0-9]]*\)\.\([[0-9]]*\).*/\1/'` - dep_target_minor=`echo ${MACOSX_DEPLOYMENT_TARGET} | \ - sed 's/\([[0-9]]*\)\.\([[0-9]]*\).*/\2/'` - if test ${dep_target_major} -eq 10 && \ - test ${dep_target_minor} -le 2 - then - # building for OS X 10.0 through 10.2 - LDSHARED='$(CC) -bundle' - LDCXXSHARED='$(CXX) -bundle' - if test "$enable_framework" ; then - # Link against the framework. All externals should be defined. - BLDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)' - LDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)' - LDCXXSHARED="$LDCXXSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)' - else - # No framework, use the Python app as bundle-loader - BLDSHARED="$LDSHARED "'-bundle_loader $(BUILDPYTHON)' - LDSHARED="$LDSHARED "'-bundle_loader $(BINDIR)/python$(VERSION)$(EXE)' - LDCXXSHARED="$LDCXXSHARED "'-bundle_loader $(BINDIR)/python$(VERSION)$(EXE)' - fi - else - # building for OS X 10.3 and later - if test "${enable_universalsdk}"; then - LDFLAGS="${UNIVERSAL_ARCH_FLAGS} -isysroot ${UNIVERSALSDK} ${LDFLAGS}" - fi - LDSHARED='$(CC) -bundle -undefined dynamic_lookup' - LDCXXSHARED='$(CXX) -bundle -undefined dynamic_lookup' - BLDSHARED="$LDSHARED" - fi - ;; - Linux*|GNU*|QNX*) - LDSHARED='$(CC) -shared' - LDCXXSHARED='$(CXX) -shared';; - BSD/OS*/4*) - LDSHARED="gcc -shared" - LDCXXSHARED="g++ -shared";; - FreeBSD*) - if [[ "`$CC -dM -E - &1 | grep export-dynamic >/dev/null - then - LINKFORSHARED="-Xlinker --export-dynamic" - fi;; - esac;; - CYGWIN*) - if test $enable_shared = "no" - then - LINKFORSHARED='-Wl,--out-implib=$(LDLIBRARY)' - fi;; - QNX*) - # -Wl,-E causes the symbols to be added to the dynamic - # symbol table so that they can be found when a module - # is loaded. -N 2048K causes the stack size to be set - # to 2048 kilobytes so that the stack doesn't overflow - # when running test_compile.py. - LINKFORSHARED='-Wl,-E -N 2048K';; - esac -fi -AC_MSG_RESULT($LINKFORSHARED) - - -AC_SUBST(CFLAGSFORSHARED) -AC_MSG_CHECKING(CFLAGSFORSHARED) -if test ! "$LIBRARY" = "$LDLIBRARY" -then - case $ac_sys_system in - CYGWIN*) - # Cygwin needs CCSHARED when building extension DLLs - # but not when building the interpreter DLL. - CFLAGSFORSHARED='';; - *) - CFLAGSFORSHARED='$(CCSHARED)' - esac -fi -AC_MSG_RESULT($CFLAGSFORSHARED) - -# SHLIBS are libraries (except -lc and -lm) to link to the python shared -# library (with --enable-shared). -# For platforms on which shared libraries are not allowed to have unresolved -# symbols, this must be set to $(LIBS) (expanded by make). We do this even -# if it is not required, since it creates a dependency of the shared library -# to LIBS. This, in turn, means that applications linking the shared libpython -# don't need to link LIBS explicitly. The default should be only changed -# on systems where this approach causes problems. -AC_SUBST(SHLIBS) -AC_MSG_CHECKING(SHLIBS) -case "$ac_sys_system" in - *) - SHLIBS='$(LIBS)';; -esac -AC_MSG_RESULT($SHLIBS) - - -# checks for libraries -AC_CHECK_LIB(dl, dlopen) # Dynamic linking for SunOS/Solaris and SYSV -AC_CHECK_LIB(dld, shl_load) # Dynamic linking for HP-UX - -# only check for sem_init if thread support is requested -if test "$with_threads" = "yes" -o -z "$with_threads"; then - AC_SEARCH_LIBS(sem_init, pthread rt posix4) # 'Real Time' functions on Solaris - # posix4 on Solaris 2.6 - # pthread (first!) on Linux -fi - -# check if we need libintl for locale functions -AC_CHECK_LIB(intl, textdomain, - AC_DEFINE(WITH_LIBINTL, 1, - [Define to 1 if libintl is needed for locale functions.])) - -# checks for system dependent C++ extensions support -case "$ac_sys_system" in - AIX*) AC_MSG_CHECKING(for genuine AIX C++ extensions support) - AC_LINK_IFELSE([ - AC_LANG_PROGRAM([[#include ]], - [[loadAndInit("", 0, "")]]) - ],[ - AC_DEFINE(AIX_GENUINE_CPLUSPLUS, 1, - [Define for AIX if your compiler is a genuine IBM xlC/xlC_r - and you want support for AIX C++ shared extension modules.]) - AC_MSG_RESULT(yes) - ],[ - AC_MSG_RESULT(no) - ]);; - *) ;; -esac - -# Most SVR4 platforms (e.g. Solaris) need -lsocket and -lnsl. -# BeOS' sockets are stashed in libnet. -AC_CHECK_LIB(nsl, t_open, [LIBS="-lnsl $LIBS"]) # SVR4 -AC_CHECK_LIB(socket, socket, [LIBS="-lsocket $LIBS"], [], $LIBS) # SVR4 sockets - -case "$ac_sys_system" in -BeOS*) -AC_CHECK_LIB(net, socket, [LIBS="-lnet $LIBS"], [], $LIBS) # BeOS -;; -esac - -AC_MSG_CHECKING(for --with-libs) -AC_ARG_WITH(libs, - AS_HELP_STRING([--with-libs='lib1 ...'], [link against additional libs]), -[ -AC_MSG_RESULT($withval) -LIBS="$withval $LIBS" -], -[AC_MSG_RESULT(no)]) - -AC_PATH_TOOL([PKG_CONFIG], [pkg-config]) - -# Check for use of the system expat library -AC_MSG_CHECKING(for --with-system-expat) -AC_ARG_WITH(system_expat, - AS_HELP_STRING([--with-system-expat], [build pyexpat module using an installed expat library]), - [], - [with_system_expat="no"]) - -AC_MSG_RESULT($with_system_expat) - -# Check for use of the system libffi library -AC_MSG_CHECKING(for --with-system-ffi) -AC_ARG_WITH(system_ffi, - AS_HELP_STRING([--with-system-ffi], [build _ctypes module using an installed ffi library]), - [], - [with_system_ffi="no"]) - -if test "$with_system_ffi" = "yes" && test -n "$PKG_CONFIG"; then - LIBFFI_INCLUDEDIR="`"$PKG_CONFIG" libffi --cflags-only-I 2>/dev/null | sed -e 's/^-I//;s/ *$//'`" -else - LIBFFI_INCLUDEDIR="" -fi -AC_SUBST(LIBFFI_INCLUDEDIR) - -AC_MSG_RESULT($with_system_ffi) - -# Check for --with-tcltk-includes=path and --with-tcltk-libs=path -AC_SUBST(TCLTK_INCLUDES) -AC_SUBST(TCLTK_LIBS) -AC_MSG_CHECKING(for --with-tcltk-includes) -AC_ARG_WITH(tcltk-includes, - AS_HELP_STRING([--with-tcltk-includes='-I...'], [override search for Tcl and Tk include files]), - [], - [with_tcltk_includes="default"]) -AC_MSG_RESULT($with_tcltk_includes) -AC_MSG_CHECKING(for --with-tcltk-libs) -AC_ARG_WITH(tcltk-libs, - AS_HELP_STRING([--with-tcltk-libs='-L...'], [override search for Tcl and Tk libs]), - [], - [with_tcltk_libs="default"]) -AC_MSG_RESULT($with_tcltk_libs) -if test "x$with_tcltk_includes" = xdefault || test "x$with_tcltk_libs" = xdefault -then - if test "x$with_tcltk_includes" != "x$with_tcltk_libs" - then - AC_MSG_ERROR([use both --with-tcltk-includes='...' and --with-tcltk-libs='...' or neither]) - fi - TCLTK_INCLUDES="" - TCLTK_LIBS="" -else - TCLTK_INCLUDES="$with_tcltk_includes" - TCLTK_LIBS="$with_tcltk_libs" -fi - -# Check for --with-dbmliborder -AC_MSG_CHECKING(for --with-dbmliborder) -AC_ARG_WITH(dbmliborder, - AS_HELP_STRING([--with-dbmliborder=db1:db2:...], [order to check db backends for dbm. Valid value is a colon separated string with the backend names `ndbm', `gdbm' and `bdb'.]), -[ -if test x$with_dbmliborder = xyes -then -AC_MSG_ERROR([proper usage is --with-dbmliborder=db1:db2:...]) -else - for db in `echo $with_dbmliborder | sed 's/:/ /g'`; do - if test x$db != xndbm && test x$db != xgdbm && test x$db != xbdb - then - AC_MSG_ERROR([proper usage is --with-dbmliborder=db1:db2:...]) - fi - done -fi]) -AC_MSG_RESULT($with_dbmliborder) - -# Determine if signalmodule should be used. -AC_SUBST(USE_SIGNAL_MODULE) -AC_SUBST(SIGNAL_OBJS) -AC_MSG_CHECKING(for --with-signal-module) -AC_ARG_WITH(signal-module, - AS_HELP_STRING([--with-signal-module], [disable/enable signal module])) - -if test -z "$with_signal_module" -then with_signal_module="yes" -fi -AC_MSG_RESULT($with_signal_module) - -if test "${with_signal_module}" = "yes"; then - USE_SIGNAL_MODULE="" - SIGNAL_OBJS="" -else - USE_SIGNAL_MODULE="#" - SIGNAL_OBJS="Parser/intrcheck.o Python/sigcheck.o" -fi - -# This is used to generate Setup.config -AC_SUBST(USE_THREAD_MODULE) -USE_THREAD_MODULE="" - -AC_MSG_CHECKING(for --with-dec-threads) -AC_SUBST(LDLAST) -AC_ARG_WITH(dec-threads, - AS_HELP_STRING([--with-dec-threads], [use DEC Alpha/OSF1 thread-safe libraries]), -[ -AC_MSG_RESULT($withval) -LDLAST=-threads -if test "${with_thread+set}" != set; then - with_thread="$withval"; -fi], -[AC_MSG_RESULT(no)]) - -# Templates for things AC_DEFINEd more than once. -# For a single AC_DEFINE, no template is needed. -AH_TEMPLATE(C_THREADS,[Define if you have the Mach cthreads package]) -AH_TEMPLATE(_REENTRANT, - [Define to force use of thread-safe errno, h_errno, and other functions]) -AH_TEMPLATE(WITH_THREAD, - [Define if you want to compile in rudimentary thread support]) - -AC_MSG_CHECKING(for --with-threads) -dnl quadrigraphs "@<:@" and "@:>@" produce "[" and "]" in the output -AC_ARG_WITH(threads, - AS_HELP_STRING([--with(out)-threads@<:@=DIRECTORY@:>@], [disable/enable thread support])) - -# --with-thread is deprecated, but check for it anyway -dnl quadrigraphs "@<:@" and "@:>@" produce "[" and "]" in the output -AC_ARG_WITH(thread, - AS_HELP_STRING([--with(out)-thread@<:@=DIRECTORY@:>@], [deprecated; use --with(out)-threads]), - [with_threads=$with_thread]) - -if test -z "$with_threads" -then with_threads="yes" -fi -AC_MSG_RESULT($with_threads) - -AC_SUBST(THREADOBJ) -if test "$with_threads" = "no" -then - USE_THREAD_MODULE="#" -elif test "$ac_cv_pthread_is_default" = yes -then - AC_DEFINE(WITH_THREAD) - # Defining _REENTRANT on system with POSIX threads should not hurt. - AC_DEFINE(_REENTRANT) - posix_threads=yes - THREADOBJ="Python/thread.o" -elif test "$ac_cv_kpthread" = "yes" -then - CC="$CC -Kpthread" - if test "$ac_cv_cxx_thread" = "yes"; then - CXX="$CXX -Kpthread" - fi - AC_DEFINE(WITH_THREAD) - posix_threads=yes - THREADOBJ="Python/thread.o" -elif test "$ac_cv_kthread" = "yes" -then - CC="$CC -Kthread" - if test "$ac_cv_cxx_thread" = "yes"; then - CXX="$CXX -Kthread" - fi - AC_DEFINE(WITH_THREAD) - posix_threads=yes - THREADOBJ="Python/thread.o" -elif test "$ac_cv_pthread" = "yes" -then - CC="$CC -pthread" - if test "$ac_cv_cxx_thread" = "yes"; then - CXX="$CXX -pthread" - fi - AC_DEFINE(WITH_THREAD) - posix_threads=yes - THREADOBJ="Python/thread.o" -else - if test ! -z "$with_threads" -a -d "$with_threads" - then LDFLAGS="$LDFLAGS -L$with_threads" - fi - if test ! -z "$withval" -a -d "$withval" - then LDFLAGS="$LDFLAGS -L$withval" - fi - - # According to the POSIX spec, a pthreads implementation must - # define _POSIX_THREADS in unistd.h. Some apparently don't - # (e.g. gnu pth with pthread emulation) - AC_MSG_CHECKING(for _POSIX_THREADS in unistd.h) - AC_EGREP_CPP(yes, - [ -#include -#ifdef _POSIX_THREADS -yes -#endif - ], unistd_defines_pthreads=yes, unistd_defines_pthreads=no) - AC_MSG_RESULT($unistd_defines_pthreads) - - AC_DEFINE(_REENTRANT) - AC_CHECK_HEADER(cthreads.h, [AC_DEFINE(WITH_THREAD) - AC_DEFINE(C_THREADS) - AC_DEFINE(HURD_C_THREADS, 1, - [Define if you are using Mach cthreads directly under /include]) - LIBS="$LIBS -lthreads" - THREADOBJ="Python/thread.o"],[ - AC_CHECK_HEADER(mach/cthreads.h, [AC_DEFINE(WITH_THREAD) - AC_DEFINE(C_THREADS) - AC_DEFINE(MACH_C_THREADS, 1, - [Define if you are using Mach cthreads under mach /]) - THREADOBJ="Python/thread.o"],[ - AC_MSG_CHECKING(for --with-pth) - AC_ARG_WITH([pth], - AS_HELP_STRING([--with-pth], [use GNU pth threading libraries]), - [AC_MSG_RESULT($withval) - AC_DEFINE([WITH_THREAD]) - AC_DEFINE([HAVE_PTH], 1, - [Define if you have GNU PTH threads.]) - LIBS="-lpth $LIBS" - THREADOBJ="Python/thread.o"], - [AC_MSG_RESULT(no) - - # Just looking for pthread_create in libpthread is not enough: - # on HP/UX, pthread.h renames pthread_create to a different symbol name. - # So we really have to include pthread.h, and then link. - _libs=$LIBS - LIBS="$LIBS -lpthread" - AC_MSG_CHECKING([for pthread_create in -lpthread]) - AC_LINK_IFELSE([AC_LANG_PROGRAM([[ -#include -#include - -void * start_routine (void *arg) { exit (0); }]], [[ -pthread_create (NULL, NULL, start_routine, NULL)]])],[ - AC_MSG_RESULT(yes) - AC_DEFINE(WITH_THREAD) - posix_threads=yes - THREADOBJ="Python/thread.o"],[ - LIBS=$_libs - AC_CHECK_FUNC(pthread_detach, [AC_DEFINE(WITH_THREAD) - posix_threads=yes - THREADOBJ="Python/thread.o"],[ - AC_CHECK_HEADER(atheos/threads.h, [AC_DEFINE(WITH_THREAD) - AC_DEFINE(ATHEOS_THREADS, 1, - [Define this if you have AtheOS threads.]) - THREADOBJ="Python/thread.o"],[ - AC_CHECK_HEADER(kernel/OS.h, [AC_DEFINE(WITH_THREAD) - AC_DEFINE(BEOS_THREADS, 1, - [Define this if you have BeOS threads.]) - THREADOBJ="Python/thread.o"],[ - AC_CHECK_LIB(pthreads, pthread_create, [AC_DEFINE(WITH_THREAD) - posix_threads=yes - LIBS="$LIBS -lpthreads" - THREADOBJ="Python/thread.o"], [ - AC_CHECK_LIB(c_r, pthread_create, [AC_DEFINE(WITH_THREAD) - posix_threads=yes - LIBS="$LIBS -lc_r" - THREADOBJ="Python/thread.o"], [ - AC_CHECK_LIB(pthread, __pthread_create_system, [AC_DEFINE(WITH_THREAD) - posix_threads=yes - LIBS="$LIBS -lpthread" - THREADOBJ="Python/thread.o"], [ - AC_CHECK_LIB(cma, pthread_create, [AC_DEFINE(WITH_THREAD) - posix_threads=yes - LIBS="$LIBS -lcma" - THREADOBJ="Python/thread.o"],[ - USE_THREAD_MODULE="#"]) - ])])])])])])])])])]) - - AC_CHECK_LIB(mpc, usconfig, [AC_DEFINE(WITH_THREAD) - LIBS="$LIBS -lmpc" - THREADOBJ="Python/thread.o" - USE_THREAD_MODULE=""]) - - if test "$posix_threads" != "yes"; then - AC_CHECK_LIB(thread, thr_create, [AC_DEFINE(WITH_THREAD) - LIBS="$LIBS -lthread" - THREADOBJ="Python/thread.o" - USE_THREAD_MODULE=""]) - fi - - if test "$USE_THREAD_MODULE" != "#" - then - # If the above checks didn't disable threads, (at least) OSF1 - # needs this '-threads' argument during linking. - case $ac_sys_system in - OSF1) LDLAST=-threads;; - esac - fi -fi - -if test "$posix_threads" = "yes"; then - if test "$unistd_defines_pthreads" = "no"; then - AC_DEFINE(_POSIX_THREADS, 1, - [Define if you have POSIX threads, - and your system does not define that.]) - fi - - # Bug 662787: Using semaphores causes unexplicable hangs on Solaris 8. - case $ac_sys_system/$ac_sys_release in - SunOS/5.6) AC_DEFINE(HAVE_PTHREAD_DESTRUCTOR, 1, - [Defined for Solaris 2.6 bug in pthread header.]) - ;; - SunOS/5.8) AC_DEFINE(HAVE_BROKEN_POSIX_SEMAPHORES, 1, - [Define if the Posix semaphores do not work on your system]) - ;; - AIX/*) AC_DEFINE(HAVE_BROKEN_POSIX_SEMAPHORES, 1, - [Define if the Posix semaphores do not work on your system]) - ;; - esac - - AC_MSG_CHECKING(if PTHREAD_SCOPE_SYSTEM is supported) - AC_CACHE_VAL(ac_cv_pthread_system_supported, - [AC_RUN_IFELSE([AC_LANG_SOURCE([[ - #include - #include - void *foo(void *parm) { - return NULL; - } - main() { - pthread_attr_t attr; - pthread_t id; - if (pthread_attr_init(&attr)) exit(-1); - if (pthread_attr_setscope(&attr, PTHREAD_SCOPE_SYSTEM)) exit(-1); - if (pthread_create(&id, &attr, foo, NULL)) exit(-1); - exit(0); - }]])], - [ac_cv_pthread_system_supported=yes], - [ac_cv_pthread_system_supported=no], - [ac_cv_pthread_system_supported=no]) - ]) - AC_MSG_RESULT($ac_cv_pthread_system_supported) - if test "$ac_cv_pthread_system_supported" = "yes"; then - AC_DEFINE(PTHREAD_SYSTEM_SCHED_SUPPORTED, 1, [Defined if PTHREAD_SCOPE_SYSTEM supported.]) - fi - AC_CHECK_FUNCS(pthread_sigmask, - [case $ac_sys_system in - CYGWIN*) - AC_DEFINE(HAVE_BROKEN_PTHREAD_SIGMASK, 1, - [Define if pthread_sigmask() does not work on your system.]) - ;; - esac]) - AC_CHECK_FUNCS(pthread_atfork) -fi - - -# Check for enable-ipv6 -AH_TEMPLATE(ENABLE_IPV6, [Define if --enable-ipv6 is specified]) -AC_MSG_CHECKING([if --enable-ipv6 is specified]) -AC_ARG_ENABLE(ipv6, -[ --enable-ipv6 Enable ipv6 (with ipv4) support - --disable-ipv6 Disable ipv6 support], -[ case "$enableval" in - no) - AC_MSG_RESULT(no) - ipv6=no - ;; - *) AC_MSG_RESULT(yes) - AC_DEFINE(ENABLE_IPV6) - ipv6=yes - ;; - esac ], - -[ -dnl the check does not work on cross compilation case... - AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ /* AF_INET6 available check */ -#include -#include ]], -[[int domain = AF_INET6;]])],[ - AC_MSG_RESULT(yes) - ipv6=yes -],[ - AC_MSG_RESULT(no) - ipv6=no -]) - -if test "$ipv6" = "yes"; then - AC_MSG_CHECKING(if RFC2553 API is available) - AC_COMPILE_IFELSE([ - AC_LANG_PROGRAM([[#include -#include ]], - [[struct sockaddr_in6 x; - x.sin6_scope_id;]]) - ],[ - AC_MSG_RESULT(yes) - ipv6=yes - ],[ - AC_MSG_RESULT(no, IPv6 disabled) - ipv6=no - ]) -fi - -if test "$ipv6" = "yes"; then - AC_DEFINE(ENABLE_IPV6) -fi -]) - -ipv6type=unknown -ipv6lib=none -ipv6trylibc=no - -if test "$ipv6" = "yes"; then - AC_MSG_CHECKING([ipv6 stack type]) - for i in inria kame linux-glibc linux-inet6 solaris toshiba v6d zeta; - do - case $i in - inria) - dnl http://www.kame.net/ - AC_EGREP_CPP(yes, [ -#include -#ifdef IPV6_INRIA_VERSION -yes -#endif], - [ipv6type=$i]) - ;; - kame) - dnl http://www.kame.net/ - AC_EGREP_CPP(yes, [ -#include -#ifdef __KAME__ -yes -#endif], - [ipv6type=$i; - ipv6lib=inet6 - ipv6libdir=/usr/local/v6/lib - ipv6trylibc=yes]) - ;; - linux-glibc) - dnl http://www.v6.linux.or.jp/ - AC_EGREP_CPP(yes, [ -#include -#if defined(__GLIBC__) && ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 1) || (__GLIBC__ > 2)) -yes -#endif], - [ipv6type=$i; - ipv6trylibc=yes]) - ;; - linux-inet6) - dnl http://www.v6.linux.or.jp/ - if test -d /usr/inet6; then - ipv6type=$i - ipv6lib=inet6 - ipv6libdir=/usr/inet6/lib - BASECFLAGS="-I/usr/inet6/include $BASECFLAGS" - fi - ;; - solaris) - if test -f /etc/netconfig; then - if $GREP -q tcp6 /etc/netconfig; then - ipv6type=$i - ipv6trylibc=yes - fi - fi - ;; - toshiba) - AC_EGREP_CPP(yes, [ -#include -#ifdef _TOSHIBA_INET6 -yes -#endif], - [ipv6type=$i; - ipv6lib=inet6; - ipv6libdir=/usr/local/v6/lib]) - ;; - v6d) - AC_EGREP_CPP(yes, [ -#include -#ifdef __V6D__ -yes -#endif], - [ipv6type=$i; - ipv6lib=v6; - ipv6libdir=/usr/local/v6/lib; - BASECFLAGS="-I/usr/local/v6/include $BASECFLAGS"]) - ;; - zeta) - AC_EGREP_CPP(yes, [ -#include -#ifdef _ZETA_MINAMI_INET6 -yes -#endif], - [ipv6type=$i; - ipv6lib=inet6; - ipv6libdir=/usr/local/v6/lib]) - ;; - esac - if test "$ipv6type" != "unknown"; then - break - fi - done - AC_MSG_RESULT($ipv6type) -fi - -if test "$ipv6" = "yes" -a "$ipv6lib" != "none"; then - if test -d $ipv6libdir -a -f $ipv6libdir/lib$ipv6lib.a; then - LIBS="-L$ipv6libdir -l$ipv6lib $LIBS" - echo "using lib$ipv6lib" - else - if test $ipv6trylibc = "yes"; then - echo "using libc" - else - echo 'Fatal: no $ipv6lib library found. cannot continue.' - echo "You need to fetch lib$ipv6lib.a from appropriate" - echo 'ipv6 kit and compile beforehand.' - exit 1 - fi - fi -fi - -AC_MSG_CHECKING(for OSX 10.5 SDK or later) -AC_COMPILE_IFELSE([ - AC_LANG_PROGRAM([[#include ]], [[FSIORefNum fRef = 0]]) -],[ - AC_DEFINE(HAVE_OSX105_SDK, 1, [Define if compiling using MacOS X 10.5 SDK or later.]) - AC_MSG_RESULT(yes) -],[ - AC_MSG_RESULT(no) -]) - -# Check for --with-doc-strings -AC_MSG_CHECKING(for --with-doc-strings) -AC_ARG_WITH(doc-strings, - AS_HELP_STRING([--with(out)-doc-strings], [disable/enable documentation strings])) - -if test -z "$with_doc_strings" -then with_doc_strings="yes" -fi -if test "$with_doc_strings" != "no" -then - AC_DEFINE(WITH_DOC_STRINGS, 1, - [Define if you want documentation strings in extension modules]) -fi -AC_MSG_RESULT($with_doc_strings) - -# Check for Python-specific malloc support -AC_MSG_CHECKING(for --with-tsc) -AC_ARG_WITH(tsc, - AS_HELP_STRING([--with(out)-tsc],[enable/disable timestamp counter profile]),[ -if test "$withval" != no -then - AC_DEFINE(WITH_TSC, 1, - [Define to profile with the Pentium timestamp counter]) - AC_MSG_RESULT(yes) -else AC_MSG_RESULT(no) -fi], -[AC_MSG_RESULT(no)]) - -# Check for Python-specific malloc support -AC_MSG_CHECKING(for --with-pymalloc) -AC_ARG_WITH(pymalloc, - AS_HELP_STRING([--with(out)-pymalloc], [disable/enable specialized mallocs])) - -if test -z "$with_pymalloc" -then with_pymalloc="yes" -fi -if test "$with_pymalloc" != "no" -then - AC_DEFINE(WITH_PYMALLOC, 1, - [Define if you want to compile in Python-specific mallocs]) -fi -AC_MSG_RESULT($with_pymalloc) - -# Check for Valgrind support -AC_MSG_CHECKING([for --with-valgrind]) -AC_ARG_WITH([valgrind], - AS_HELP_STRING([--with-valgrind], [Enable Valgrind support]),, - with_valgrind=no) -AC_MSG_RESULT([$with_valgrind]) -if test "$with_valgrind" != no; then - AC_CHECK_HEADER([valgrind/valgrind.h], - [AC_DEFINE([WITH_VALGRIND], 1, [Define if you want pymalloc to be disabled when running under valgrind])], - [AC_MSG_ERROR([Valgrind support requested but headers not available])] - ) -fi - -# Check for --with-wctype-functions -AC_MSG_CHECKING(for --with-wctype-functions) -AC_ARG_WITH(wctype-functions, - AS_HELP_STRING([--with-wctype-functions], [use wctype.h functions]), -[ -if test "$withval" != no -then - AC_DEFINE(WANT_WCTYPE_FUNCTIONS, 1, - [Define if you want wctype.h functions to be used instead of the - one supplied by Python itself. (see Include/unicodectype.h).]) - AC_MSG_RESULT(yes) -else AC_MSG_RESULT(no) -fi], -[AC_MSG_RESULT(no)]) - -# -I${DLINCLDIR} is added to the compile rule for importdl.o -AC_SUBST(DLINCLDIR) -DLINCLDIR=. - -# the dlopen() function means we might want to use dynload_shlib.o. some -# platforms, such as AIX, have dlopen(), but don't want to use it. -AC_CHECK_FUNCS(dlopen) - -# DYNLOADFILE specifies which dynload_*.o file we will use for dynamic -# loading of modules. -AC_SUBST(DYNLOADFILE) -AC_MSG_CHECKING(DYNLOADFILE) -if test -z "$DYNLOADFILE" -then - case $ac_sys_system/$ac_sys_release in - AIX*) # Use dynload_shlib.c and dlopen() if we have it; otherwise dynload_aix.c - if test "$ac_cv_func_dlopen" = yes - then DYNLOADFILE="dynload_shlib.o" - else DYNLOADFILE="dynload_aix.o" - fi - ;; - BeOS*) DYNLOADFILE="dynload_beos.o";; - hp*|HP*) DYNLOADFILE="dynload_hpux.o";; - # Use dynload_next.c only on 10.2 and below, which don't have native dlopen() - Darwin/@<:@0156@:>@\..*) DYNLOADFILE="dynload_next.o";; - atheos*) DYNLOADFILE="dynload_atheos.o";; - *) - # use dynload_shlib.c and dlopen() if we have it; otherwise stub - # out any dynamic loading - if test "$ac_cv_func_dlopen" = yes - then DYNLOADFILE="dynload_shlib.o" - else DYNLOADFILE="dynload_stub.o" - fi - ;; - esac -fi -AC_MSG_RESULT($DYNLOADFILE) -if test "$DYNLOADFILE" != "dynload_stub.o" -then - AC_DEFINE(HAVE_DYNAMIC_LOADING, 1, - [Defined when any dynamic module loading is enabled.]) -fi - -# MACHDEP_OBJS can be set to platform-specific object files needed by Python - -AC_SUBST(MACHDEP_OBJS) -AC_MSG_CHECKING(MACHDEP_OBJS) -if test -z "$MACHDEP_OBJS" -then - MACHDEP_OBJS=$extra_machdep_objs -else - MACHDEP_OBJS="$MACHDEP_OBJS $extra_machdep_objs" -fi -AC_MSG_RESULT(MACHDEP_OBJS) - -# checks for library functions -AC_CHECK_FUNCS(alarm setitimer getitimer bind_textdomain_codeset chown \ - clock confstr ctermid execv fchmod fchown fork fpathconf ftime ftruncate \ - gai_strerror getgroups getlogin getloadavg getpeername getpgid getpid \ - getpriority getresuid getresgid getpwent getspnam getspent getsid getwd \ - initgroups kill killpg lchmod lchown lstat mkfifo mknod mktime mmap \ - mremap nice pathconf pause plock poll pthread_init \ - putenv readlink realpath \ - select sem_open sem_timedwait sem_getvalue sem_unlink setegid seteuid \ - setgid \ - setlocale setregid setreuid setsid setpgid setpgrp setuid setvbuf snprintf \ - setlocale setregid setreuid setresuid setresgid \ - setsid setpgid setpgrp setuid setvbuf snprintf \ - sigaction siginterrupt sigrelse strftime \ - sysconf tcgetpgrp tcsetpgrp tempnam timegm times tmpfile tmpnam tmpnam_r \ - truncate uname unsetenv utimes waitpid wait3 wait4 wcscoll _getpty) - -# For some functions, having a definition is not sufficient, since -# we want to take their address. -AC_MSG_CHECKING(for chroot) -AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include ]], [[void *x=chroot]])], - [AC_DEFINE(HAVE_CHROOT, 1, Define if you have the 'chroot' function.) - AC_MSG_RESULT(yes)], - [AC_MSG_RESULT(no) -]) -AC_MSG_CHECKING(for link) -AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include ]], [[void *x=link]])], - [AC_DEFINE(HAVE_LINK, 1, Define if you have the 'link' function.) - AC_MSG_RESULT(yes)], - [AC_MSG_RESULT(no) -]) -AC_MSG_CHECKING(for symlink) -AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include ]], [[void *x=symlink]])], - [AC_DEFINE(HAVE_SYMLINK, 1, Define if you have the 'symlink' function.) - AC_MSG_RESULT(yes)], - [AC_MSG_RESULT(no) -]) -AC_MSG_CHECKING(for fchdir) -AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include ]], [[void *x=fchdir]])], - [AC_DEFINE(HAVE_FCHDIR, 1, Define if you have the 'fchdir' function.) - AC_MSG_RESULT(yes)], - [AC_MSG_RESULT(no) -]) -AC_MSG_CHECKING(for fsync) -AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include ]], [[void *x=fsync]])], - [AC_DEFINE(HAVE_FSYNC, 1, Define if you have the 'fsync' function.) - AC_MSG_RESULT(yes)], - [AC_MSG_RESULT(no) -]) -AC_MSG_CHECKING(for fdatasync) -AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include ]], [[void *x=fdatasync]])], - [AC_DEFINE(HAVE_FDATASYNC, 1, Define if you have the 'fdatasync' function.) - AC_MSG_RESULT(yes)], - [AC_MSG_RESULT(no) -]) -AC_MSG_CHECKING(for epoll) -AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include ]], [[void *x=epoll_create]])], - [AC_DEFINE(HAVE_EPOLL, 1, Define if you have the 'epoll' functions.) - AC_MSG_RESULT(yes)], - [AC_MSG_RESULT(no) -]) -AC_MSG_CHECKING(for kqueue) -AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ -#include -#include - ]], [[int x=kqueue()]])], - [AC_DEFINE(HAVE_KQUEUE, 1, Define if you have the 'kqueue' functions.) - AC_MSG_RESULT(yes)], - [AC_MSG_RESULT(no) -]) -# On some systems (eg. FreeBSD 5), we would find a definition of the -# functions ctermid_r, setgroups in the library, but no prototype -# (e.g. because we use _XOPEN_SOURCE). See whether we can take their -# address to avoid compiler warnings and potential miscompilations -# because of the missing prototypes. - -AC_MSG_CHECKING(for ctermid_r) -AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ -#include -]], [[void* p = ctermid_r]])], - [AC_DEFINE(HAVE_CTERMID_R, 1, Define if you have the 'ctermid_r' function.) - AC_MSG_RESULT(yes)], - [AC_MSG_RESULT(no) -]) - -AC_CACHE_CHECK([for flock declaration], [ac_cv_flock_decl], - [AC_COMPILE_IFELSE( - [AC_LANG_PROGRAM( - [#include ], - [void* p = flock] - )], - [ac_cv_flock_decl=yes], - [ac_cv_flock_decl=no] - ) -]) -if test "x${ac_cv_flock_decl}" = xyes; then - AC_CHECK_FUNCS(flock,, - AC_CHECK_LIB(bsd,flock, - [AC_DEFINE(HAVE_FLOCK) - AC_DEFINE(FLOCK_NEEDS_LIBBSD, 1, Define if flock needs to be linked with bsd library.) - ]) - ) -fi - -AC_MSG_CHECKING(for getpagesize) -AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ -#include -]], [[void* p = getpagesize]])], - [AC_DEFINE(HAVE_GETPAGESIZE, 1, Define if you have the 'getpagesize' function.) - AC_MSG_RESULT(yes)], - [AC_MSG_RESULT(no) -]) - -AC_MSG_CHECKING(for broken unsetenv) -AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ -#include -]], [[int res = unsetenv("DUMMY")]])], - [AC_MSG_RESULT(no)], - [AC_DEFINE(HAVE_BROKEN_UNSETENV, 1, Define if `unsetenv` does not return an int.) - AC_MSG_RESULT(yes) -]) - -dnl check for true -AC_CHECK_PROGS(TRUE, true, /bin/true) - -dnl On some systems (e.g. Solaris 9), hstrerror and inet_aton are in -lresolv -dnl On others, they are in the C library, so we to take no action -AC_CHECK_LIB(c, inet_aton, [$ac_cv_prog_TRUE], - AC_CHECK_LIB(resolv, inet_aton) -) - -# On Tru64, chflags seems to be present, but calling it will -# exit Python -AC_CACHE_CHECK([for chflags], [ac_cv_have_chflags], [dnl -AC_RUN_IFELSE([AC_LANG_SOURCE([[ -#include -#include -int main(int argc, char*argv[]) -{ - if(chflags(argv[0], 0) != 0) - return 1; - return 0; -} -]])], -[ac_cv_have_chflags=yes], -[ac_cv_have_chflags=no], -[ac_cv_have_chflags=cross]) -]) -if test "$ac_cv_have_chflags" = cross ; then - AC_CHECK_FUNC([chflags], [ac_cv_have_chflags="yes"], [ac_cv_have_chflags="no"]) -fi -if test "$ac_cv_have_chflags" = yes ; then - AC_DEFINE(HAVE_CHFLAGS, 1, [Define to 1 if you have the 'chflags' function.]) -fi - -AC_CACHE_CHECK([for lchflags], [ac_cv_have_lchflags], [dnl -AC_RUN_IFELSE([AC_LANG_SOURCE([[ -#include -#include -int main(int argc, char*argv[]) -{ - if(lchflags(argv[0], 0) != 0) - return 1; - return 0; -} -]])],[ac_cv_have_lchflags=yes],[ac_cv_have_lchflags=no],[ac_cv_have_lchflags=cross]) -]) -if test "$ac_cv_have_lchflags" = cross ; then - AC_CHECK_FUNC([lchflags], [ac_cv_have_lchflags="yes"], [ac_cv_have_lchflags="no"]) -fi -if test "$ac_cv_have_lchflags" = yes ; then - AC_DEFINE(HAVE_LCHFLAGS, 1, [Define to 1 if you have the 'lchflags' function.]) -fi - -dnl Check if system zlib has *Copy() functions -dnl -dnl On MacOSX the linker will search for dylibs on the entire linker path -dnl before searching for static libraries. setup.py adds -Wl,-search_paths_first -dnl to revert to a more traditional unix behaviour and make it possible to -dnl override the system libz with a local static library of libz. Temporarily -dnl add that flag to our CFLAGS as well to ensure that we check the version -dnl of libz that will be used by setup.py. -dnl The -L/usr/local/lib is needed as wel to get the same compilation -dnl environment as setup.py (and leaving it out can cause configure to use the -dnl wrong version of the library) -case $ac_sys_system/$ac_sys_release in -Darwin/*) - _CUR_CFLAGS="${CFLAGS}" - _CUR_LDFLAGS="${LDFLAGS}" - CFLAGS="${CFLAGS} -Wl,-search_paths_first" - LDFLAGS="${LDFLAGS} -Wl,-search_paths_first -L/usr/local/lib" - ;; -esac - -AC_CHECK_LIB(z, inflateCopy, AC_DEFINE(HAVE_ZLIB_COPY, 1, [Define if the zlib library has inflateCopy])) - -case $ac_sys_system/$ac_sys_release in -Darwin/*) - CFLAGS="${_CUR_CFLAGS}" - LDFLAGS="${_CUR_LDFLAGS}" - ;; -esac - -AC_MSG_CHECKING(for hstrerror) -AC_LINK_IFELSE([AC_LANG_PROGRAM([[ -#include -]], [[void* p = hstrerror; hstrerror(0)]])], - [AC_DEFINE(HAVE_HSTRERROR, 1, Define if you have the 'hstrerror' function.) - AC_MSG_RESULT(yes)], - [AC_MSG_RESULT(no) -]) - -AC_MSG_CHECKING(for inet_aton) -AC_LINK_IFELSE([AC_LANG_PROGRAM([[ -#include -#include -#include -#include -]], [[void* p = inet_aton;inet_aton(0,0)]])], - [AC_DEFINE(HAVE_INET_ATON, 1, Define if you have the 'inet_aton' function.) - AC_MSG_RESULT(yes)], - [AC_MSG_RESULT(no) -]) - -AC_MSG_CHECKING(for inet_pton) -AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ -#include -#include -#include -#include -]], [[void* p = inet_pton]])], - [AC_DEFINE(HAVE_INET_PTON, 1, Define if you have the 'inet_pton' function.) - AC_MSG_RESULT(yes)], - [AC_MSG_RESULT(no) -]) - -# On some systems, setgroups is in unistd.h, on others, in grp.h -AC_MSG_CHECKING(for setgroups) -AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ -#include -#ifdef HAVE_GRP_H -#include -#endif -]], [[void* p = setgroups]])], - [AC_DEFINE(HAVE_SETGROUPS, 1, Define if you have the 'setgroups' function.) - AC_MSG_RESULT(yes)], - [AC_MSG_RESULT(no) -]) - -# check for openpty and forkpty - -AC_CHECK_FUNCS(openpty,, - AC_CHECK_LIB(util,openpty, - [AC_DEFINE(HAVE_OPENPTY) LIBS="$LIBS -lutil"], - AC_CHECK_LIB(bsd,openpty, [AC_DEFINE(HAVE_OPENPTY) LIBS="$LIBS -lbsd"]) - ) -) -AC_CHECK_FUNCS(forkpty,, - AC_CHECK_LIB(util,forkpty, - [AC_DEFINE(HAVE_FORKPTY) LIBS="$LIBS -lutil"], - AC_CHECK_LIB(bsd,forkpty, [AC_DEFINE(HAVE_FORKPTY) LIBS="$LIBS -lbsd"]) - ) -) - -# Stuff for expat. -AC_CHECK_FUNCS(memmove) - -# check for long file support functions -AC_CHECK_FUNCS(fseek64 fseeko fstatvfs ftell64 ftello statvfs) - -AC_REPLACE_FUNCS(dup2 getcwd strdup) -AC_CHECK_FUNCS(getpgrp, - AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include ]], [[getpgrp(0);]])], - [AC_DEFINE(GETPGRP_HAVE_ARG, 1, [Define if getpgrp() must be called as getpgrp(0).])], - []) -) -AC_CHECK_FUNCS(setpgrp, - AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include ]], [[setpgrp(0,0);]])], - [AC_DEFINE(SETPGRP_HAVE_ARG, 1, [Define if setpgrp() must be called as setpgrp(0, 0).])], - []) -) -AC_CHECK_FUNCS(gettimeofday, - AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include ]], - [[gettimeofday((struct timeval*)0,(struct timezone*)0);]])], - [], - [AC_DEFINE(GETTIMEOFDAY_NO_TZ, 1, - [Define if gettimeofday() does not have second (timezone) argument - This is the case on Motorola V4 (R40V4.2)]) - ]) -) - -AC_MSG_CHECKING(for major, minor, and makedev) -AC_LINK_IFELSE([AC_LANG_PROGRAM([[ -#if defined(MAJOR_IN_MKDEV) -#include -#elif defined(MAJOR_IN_SYSMACROS) -#include -#else -#include -#endif -]], [[ - makedev(major(0),minor(0)); -]])],[ - AC_DEFINE(HAVE_DEVICE_MACROS, 1, - [Define to 1 if you have the device macros.]) - AC_MSG_RESULT(yes) -],[ - AC_MSG_RESULT(no) -]) - -# On OSF/1 V5.1, getaddrinfo is available, but a define -# for [no]getaddrinfo in netdb.h. -AC_MSG_CHECKING(for getaddrinfo) -AC_LINK_IFELSE([AC_LANG_PROGRAM([[ -#include -#include -#include -#include -]], [[getaddrinfo(NULL, NULL, NULL, NULL);]])], -[have_getaddrinfo=yes], -[have_getaddrinfo=no]) -AC_MSG_RESULT($have_getaddrinfo) -if test $have_getaddrinfo = yes -then - AC_MSG_CHECKING(getaddrinfo bug) - AC_CACHE_VAL(ac_cv_buggy_getaddrinfo, - AC_RUN_IFELSE([AC_LANG_SOURCE([[[ -#include -#include -#include -#include -#include -#include - -int main() -{ - int passive, gaierr, inet4 = 0, inet6 = 0; - struct addrinfo hints, *ai, *aitop; - char straddr[INET6_ADDRSTRLEN], strport[16]; - - for (passive = 0; passive <= 1; passive++) { - memset(&hints, 0, sizeof(hints)); - hints.ai_family = AF_UNSPEC; - hints.ai_flags = passive ? AI_PASSIVE : 0; - hints.ai_socktype = SOCK_STREAM; - hints.ai_protocol = IPPROTO_TCP; - if ((gaierr = getaddrinfo(NULL, "54321", &hints, &aitop)) != 0) { - (void)gai_strerror(gaierr); - goto bad; - } - for (ai = aitop; ai; ai = ai->ai_next) { - if (ai->ai_addr == NULL || - ai->ai_addrlen == 0 || - getnameinfo(ai->ai_addr, ai->ai_addrlen, - straddr, sizeof(straddr), strport, sizeof(strport), - NI_NUMERICHOST|NI_NUMERICSERV) != 0) { - goto bad; - } - switch (ai->ai_family) { - case AF_INET: - if (strcmp(strport, "54321") != 0) { - goto bad; - } - if (passive) { - if (strcmp(straddr, "0.0.0.0") != 0) { - goto bad; - } - } else { - if (strcmp(straddr, "127.0.0.1") != 0) { - goto bad; - } - } - inet4++; - break; - case AF_INET6: - if (strcmp(strport, "54321") != 0) { - goto bad; - } - if (passive) { - if (strcmp(straddr, "::") != 0) { - goto bad; - } - } else { - if (strcmp(straddr, "::1") != 0) { - goto bad; - } - } - inet6++; - break; - case AF_UNSPEC: - goto bad; - break; - default: - /* another family support? */ - break; - } - } - } - - if (!(inet4 == 0 || inet4 == 2)) - goto bad; - if (!(inet6 == 0 || inet6 == 2)) - goto bad; - - if (aitop) - freeaddrinfo(aitop); - return 0; - - bad: - if (aitop) - freeaddrinfo(aitop); - return 1; -} -]]])], -[ac_cv_buggy_getaddrinfo=no], -[ac_cv_buggy_getaddrinfo=yes], -[ -if test "${enable_ipv6+set}" = set; then - ac_cv_buggy_getaddrinfo="no -- configured with --(en|dis)able-ipv6" -else - ac_cv_buggy_getaddrinfo=yes -fi])) -fi - -AC_MSG_RESULT($ac_cv_buggy_getaddrinfo) - -if test $have_getaddrinfo = no -o "$ac_cv_buggy_getaddrinfo" = yes -then - if test $ipv6 = yes - then - echo 'Fatal: You must get working getaddrinfo() function.' - echo ' or you can specify "--disable-ipv6"'. - exit 1 - fi -else - AC_DEFINE(HAVE_GETADDRINFO, 1, [Define if you have the getaddrinfo function.]) -fi - -AC_CHECK_FUNCS(getnameinfo) - -# checks for structures -AC_HEADER_TIME -AC_STRUCT_TM -AC_STRUCT_TIMEZONE -AC_CHECK_MEMBERS([struct stat.st_rdev]) -AC_CHECK_MEMBERS([struct stat.st_blksize]) -AC_CHECK_MEMBERS([struct stat.st_flags]) -AC_CHECK_MEMBERS([struct stat.st_gen]) -AC_CHECK_MEMBERS([struct stat.st_birthtime]) -AC_STRUCT_ST_BLOCKS - -AC_MSG_CHECKING(for time.h that defines altzone) -AC_CACHE_VAL(ac_cv_header_time_altzone,[ - AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include ]], [[return altzone;]])], - [ac_cv_header_time_altzone=yes], - [ac_cv_header_time_altzone=no]) - ]) -AC_MSG_RESULT($ac_cv_header_time_altzone) -if test $ac_cv_header_time_altzone = yes; then - AC_DEFINE(HAVE_ALTZONE, 1, [Define this if your time.h defines altzone.]) -fi - -was_it_defined=no -AC_MSG_CHECKING(whether sys/select.h and sys/time.h may both be included) -AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ -#include -#include -#include -]], [[;]])],[ - AC_DEFINE(SYS_SELECT_WITH_SYS_TIME, 1, - [Define if you can safely include both and - (which you can't on SCO ODT 3.0).]) - was_it_defined=yes -],[]) -AC_MSG_RESULT($was_it_defined) - -AC_MSG_CHECKING(for addrinfo) -AC_CACHE_VAL(ac_cv_struct_addrinfo, -AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include ]], [[struct addrinfo a]])], - [ac_cv_struct_addrinfo=yes], - [ac_cv_struct_addrinfo=no])) -AC_MSG_RESULT($ac_cv_struct_addrinfo) -if test $ac_cv_struct_addrinfo = yes; then - AC_DEFINE(HAVE_ADDRINFO, 1, [struct addrinfo (netdb.h)]) -fi - -AC_MSG_CHECKING(for sockaddr_storage) -AC_CACHE_VAL(ac_cv_struct_sockaddr_storage, -AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ -# include -# include ]], [[struct sockaddr_storage s]])], - [ac_cv_struct_sockaddr_storage=yes], - [ac_cv_struct_sockaddr_storage=no])) -AC_MSG_RESULT($ac_cv_struct_sockaddr_storage) -if test $ac_cv_struct_sockaddr_storage = yes; then - AC_DEFINE(HAVE_SOCKADDR_STORAGE, 1, [struct sockaddr_storage (sys/socket.h)]) -fi - -# checks for compiler characteristics - -AC_C_CHAR_UNSIGNED -AC_C_CONST - -works=no -AC_MSG_CHECKING(for working volatile) -AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[volatile int x; x = 0;]])], - [works=yes], - [AC_DEFINE(volatile, , [Define to empty if the keyword does not work.])] -) -AC_MSG_RESULT($works) - -works=no -AC_MSG_CHECKING(for working signed char) -AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[signed char c;]])], - [works=yes], - [AC_DEFINE(signed, , [Define to empty if the keyword does not work.])] -) -AC_MSG_RESULT($works) - -have_prototypes=no -AC_MSG_CHECKING(for prototypes) -AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[int foo(int x) { return 0; }]], [[return foo(10);]])], - [AC_DEFINE(HAVE_PROTOTYPES, 1, - [Define if your compiler supports function prototype]) - have_prototypes=yes], - [] -) -AC_MSG_RESULT($have_prototypes) - -works=no -AC_MSG_CHECKING(for variable length prototypes and stdarg.h) -AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ -#include -int foo(int x, ...) { - va_list va; - va_start(va, x); - va_arg(va, int); - va_arg(va, char *); - va_arg(va, double); - return 0; -} -]], [[return foo(10, "", 3.14);]])],[ - AC_DEFINE(HAVE_STDARG_PROTOTYPES, 1, - [Define if your compiler supports variable length function prototypes - (e.g. void fprintf(FILE *, char *, ...);) *and* ]) - works=yes -],[]) -AC_MSG_RESULT($works) - -# check for socketpair -AC_MSG_CHECKING(for socketpair) -AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ -#include -#include -]], [[void *x=socketpair]])], - [AC_DEFINE(HAVE_SOCKETPAIR, 1, [Define if you have the 'socketpair' function.]) - AC_MSG_RESULT(yes)], - [AC_MSG_RESULT(no)] -) - -# check if sockaddr has sa_len member -AC_MSG_CHECKING(if sockaddr has sa_len member) -AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include -#include ]], [[struct sockaddr x; -x.sa_len = 0;]])], - [AC_MSG_RESULT(yes) - AC_DEFINE(HAVE_SOCKADDR_SA_LEN, 1, [Define if sockaddr has sa_len member])], - [AC_MSG_RESULT(no)] -) - -va_list_is_array=no -AC_MSG_CHECKING(whether va_list is an array) -AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ -#ifdef HAVE_STDARG_PROTOTYPES -#include -#else -#include -#endif -]], [[va_list list1, list2; list1 = list2;]])],[],[ - AC_DEFINE(VA_LIST_IS_ARRAY, 1, [Define if a va_list is an array of some kind]) - va_list_is_array=yes -]) -AC_MSG_RESULT($va_list_is_array) - -# sigh -- gethostbyname_r is a mess; it can have 3, 5 or 6 arguments :-( -AH_TEMPLATE(HAVE_GETHOSTBYNAME_R, - [Define this if you have some version of gethostbyname_r()]) - -AC_CHECK_FUNC(gethostbyname_r, [ - AC_DEFINE(HAVE_GETHOSTBYNAME_R) - AC_MSG_CHECKING([gethostbyname_r with 6 args]) - OLD_CFLAGS=$CFLAGS - CFLAGS="$CFLAGS $MY_CPPFLAGS $MY_THREAD_CPPFLAGS $MY_CFLAGS" - AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ -# include - ]], [[ - char *name; - struct hostent *he, *res; - char buffer[2048]; - int buflen = 2048; - int h_errnop; - - (void) gethostbyname_r(name, he, buffer, buflen, &res, &h_errnop) - ]])],[ - AC_DEFINE(HAVE_GETHOSTBYNAME_R) - AC_DEFINE(HAVE_GETHOSTBYNAME_R_6_ARG, 1, - [Define this if you have the 6-arg version of gethostbyname_r().]) - AC_MSG_RESULT(yes) - ],[ - AC_MSG_RESULT(no) - AC_MSG_CHECKING([gethostbyname_r with 5 args]) - AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ -# include - ]], [[ - char *name; - struct hostent *he; - char buffer[2048]; - int buflen = 2048; - int h_errnop; - - (void) gethostbyname_r(name, he, buffer, buflen, &h_errnop) - ]])], - [ - AC_DEFINE(HAVE_GETHOSTBYNAME_R) - AC_DEFINE(HAVE_GETHOSTBYNAME_R_5_ARG, 1, - [Define this if you have the 5-arg version of gethostbyname_r().]) - AC_MSG_RESULT(yes) - ], [ - AC_MSG_RESULT(no) - AC_MSG_CHECKING([gethostbyname_r with 3 args]) - AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ -# include - ]], [[ - char *name; - struct hostent *he; - struct hostent_data data; - - (void) gethostbyname_r(name, he, &data); - ]])], - [ - AC_DEFINE(HAVE_GETHOSTBYNAME_R) - AC_DEFINE(HAVE_GETHOSTBYNAME_R_3_ARG, 1, - [Define this if you have the 3-arg version of gethostbyname_r().]) - AC_MSG_RESULT(yes) - ], [ - AC_MSG_RESULT(no) - ]) - ]) - ]) - CFLAGS=$OLD_CFLAGS -], [ - AC_CHECK_FUNCS(gethostbyname) -]) -AC_SUBST(HAVE_GETHOSTBYNAME_R_6_ARG) -AC_SUBST(HAVE_GETHOSTBYNAME_R_5_ARG) -AC_SUBST(HAVE_GETHOSTBYNAME_R_3_ARG) -AC_SUBST(HAVE_GETHOSTBYNAME_R) -AC_SUBST(HAVE_GETHOSTBYNAME) - -# checks for system services -# (none yet) - -# Linux requires this for correct f.p. operations -AC_CHECK_FUNC(__fpu_control, - [], - [AC_CHECK_LIB(ieee, __fpu_control) -]) - -# Check for --with-fpectl -AC_MSG_CHECKING(for --with-fpectl) -AC_ARG_WITH(fpectl, - AS_HELP_STRING([--with-fpectl], [enable SIGFPE catching]), -[ -if test "$withval" != no -then - AC_DEFINE(WANT_SIGFPE_HANDLER, 1, - [Define if you want SIGFPE handled (see Include/pyfpe.h).]) - AC_MSG_RESULT(yes) -else AC_MSG_RESULT(no) -fi], -[AC_MSG_RESULT(no)]) - -# check for --with-libm=... -AC_SUBST(LIBM) -case $ac_sys_system in -Darwin) ;; -BeOS) ;; -*) LIBM=-lm -esac -AC_MSG_CHECKING(for --with-libm=STRING) -AC_ARG_WITH(libm, - AS_HELP_STRING([--with-libm=STRING], [math library]), -[ -if test "$withval" = no -then LIBM= - AC_MSG_RESULT(force LIBM empty) -elif test "$withval" != yes -then LIBM=$withval - AC_MSG_RESULT(set LIBM="$withval") -else AC_MSG_ERROR([proper usage is --with-libm=STRING]) -fi], -[AC_MSG_RESULT(default LIBM="$LIBM")]) - -# check for --with-libc=... -AC_SUBST(LIBC) -AC_MSG_CHECKING(for --with-libc=STRING) -AC_ARG_WITH(libc, - AS_HELP_STRING([--with-libc=STRING], [C library]), -[ -if test "$withval" = no -then LIBC= - AC_MSG_RESULT(force LIBC empty) -elif test "$withval" != yes -then LIBC=$withval - AC_MSG_RESULT(set LIBC="$withval") -else AC_MSG_ERROR([proper usage is --with-libc=STRING]) -fi], -[AC_MSG_RESULT(default LIBC="$LIBC")]) - -# ************************************************** -# * Check for various properties of floating point * -# ************************************************** - -AC_MSG_CHECKING(whether C doubles are little-endian IEEE 754 binary64) -AC_CACHE_VAL(ac_cv_little_endian_double, [ -AC_RUN_IFELSE([AC_LANG_SOURCE([[ -#include -int main() { - double x = 9006104071832581.0; - if (memcmp(&x, "\x05\x04\x03\x02\x01\xff\x3f\x43", 8) == 0) - return 0; - else - return 1; -} -]])], -[ac_cv_little_endian_double=yes], -[ac_cv_little_endian_double=no], -[ac_cv_little_endian_double=no])]) -AC_MSG_RESULT($ac_cv_little_endian_double) -if test "$ac_cv_little_endian_double" = yes -then - AC_DEFINE(DOUBLE_IS_LITTLE_ENDIAN_IEEE754, 1, - [Define if C doubles are 64-bit IEEE 754 binary format, stored - with the least significant byte first]) -fi - -AC_MSG_CHECKING(whether C doubles are big-endian IEEE 754 binary64) -AC_CACHE_VAL(ac_cv_big_endian_double, [ -AC_RUN_IFELSE([AC_LANG_SOURCE([[ -#include -int main() { - double x = 9006104071832581.0; - if (memcmp(&x, "\x43\x3f\xff\x01\x02\x03\x04\x05", 8) == 0) - return 0; - else - return 1; -} -]])], -[ac_cv_big_endian_double=yes], -[ac_cv_big_endian_double=no], -[ac_cv_big_endian_double=no])]) -AC_MSG_RESULT($ac_cv_big_endian_double) -if test "$ac_cv_big_endian_double" = yes -then - AC_DEFINE(DOUBLE_IS_BIG_ENDIAN_IEEE754, 1, - [Define if C doubles are 64-bit IEEE 754 binary format, stored - with the most significant byte first]) -fi - -# Some ARM platforms use a mixed-endian representation for doubles. -# While Python doesn't currently have full support for these platforms -# (see e.g., issue 1762561), we can at least make sure that float <-> string -# conversions work. -AC_MSG_CHECKING(whether C doubles are ARM mixed-endian IEEE 754 binary64) -AC_CACHE_VAL(ac_cv_mixed_endian_double, [ -AC_RUN_IFELSE([AC_LANG_SOURCE([[ -#include -int main() { - double x = 9006104071832581.0; - if (memcmp(&x, "\x01\xff\x3f\x43\x05\x04\x03\x02", 8) == 0) - return 0; - else - return 1; -} -]])], -[ac_cv_mixed_endian_double=yes], -[ac_cv_mixed_endian_double=no], -[ac_cv_mixed_endian_double=no])]) -AC_MSG_RESULT($ac_cv_mixed_endian_double) -if test "$ac_cv_mixed_endian_double" = yes -then - AC_DEFINE(DOUBLE_IS_ARM_MIXED_ENDIAN_IEEE754, 1, - [Define if C doubles are 64-bit IEEE 754 binary format, stored - in ARM mixed-endian order (byte order 45670123)]) -fi - -# The short float repr introduced in Python 3.1 requires the -# correctly-rounded string <-> double conversion functions from -# Python/dtoa.c, which in turn require that the FPU uses 53-bit -# rounding; this is a problem on x86, where the x87 FPU has a default -# rounding precision of 64 bits. For gcc/x86, we can fix this by -# using inline assembler to get and set the x87 FPU control word. - -# This inline assembler syntax may also work for suncc and icc, -# so we try it on all platforms. - -AC_MSG_CHECKING(whether we can use gcc inline assembler to get and set x87 control word) -AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[ - unsigned short cw; - __asm__ __volatile__ ("fnstcw %0" : "=m" (cw)); - __asm__ __volatile__ ("fldcw %0" : : "m" (cw)); -]])],[have_gcc_asm_for_x87=yes],[have_gcc_asm_for_x87=no]) -AC_MSG_RESULT($have_gcc_asm_for_x87) -if test "$have_gcc_asm_for_x87" = yes -then - AC_DEFINE(HAVE_GCC_ASM_FOR_X87, 1, - [Define if we can use gcc inline assembler to get and set x87 control word]) -fi - -# Detect whether system arithmetic is subject to x87-style double -# rounding issues. The result of this test has little meaning on non -# IEEE 754 platforms. On IEEE 754, test should return 1 if rounding -# mode is round-to-nearest and double rounding issues are present, and -# 0 otherwise. See http://bugs.python.org/issue2937 for more info. -AC_MSG_CHECKING(for x87-style double rounding) -# $BASECFLAGS may affect the result -ac_save_cc="$CC" -CC="$CC $BASECFLAGS" -AC_RUN_IFELSE([AC_LANG_SOURCE([[ -#include -#include -int main() { - volatile double x, y, z; - /* 1./(1-2**-53) -> 1+2**-52 (correct), 1.0 (double rounding) */ - x = 0.99999999999999989; /* 1-2**-53 */ - y = 1./x; - if (y != 1.) - exit(0); - /* 1e16+2.99999 -> 1e16+2. (correct), 1e16+4. (double rounding) */ - x = 1e16; - y = 2.99999; - z = x + y; - if (z != 1e16+4.) - exit(0); - /* both tests show evidence of double rounding */ - exit(1); -} -]])], -[ac_cv_x87_double_rounding=no], -[ac_cv_x87_double_rounding=yes], -[ac_cv_x87_double_rounding=no]) -CC="$ac_save_cc" -AC_MSG_RESULT($ac_cv_x87_double_rounding) -if test "$ac_cv_x87_double_rounding" = yes -then - AC_DEFINE(X87_DOUBLE_ROUNDING, 1, - [Define if arithmetic is subject to x87-style double rounding issue]) -fi - -# ************************************ -# * Check for mathematical functions * -# ************************************ - -LIBS_SAVE=$LIBS -LIBS="$LIBS $LIBM" - -# On FreeBSD 6.2, it appears that tanh(-0.) returns 0. instead of -# -0. on some architectures. -AC_MSG_CHECKING(whether tanh preserves the sign of zero) -AC_CACHE_VAL(ac_cv_tanh_preserves_zero_sign, [ -AC_RUN_IFELSE([AC_LANG_SOURCE([[ -#include -#include -int main() { - /* return 0 if either negative zeros don't exist - on this platform or if negative zeros exist - and tanh(-0.) == -0. */ - if (atan2(0., -1.) == atan2(-0., -1.) || - atan2(tanh(-0.), -1.) == atan2(-0., -1.)) exit(0); - else exit(1); -} -]])], -[ac_cv_tanh_preserves_zero_sign=yes], -[ac_cv_tanh_preserves_zero_sign=no], -[ac_cv_tanh_preserves_zero_sign=no])]) -AC_MSG_RESULT($ac_cv_tanh_preserves_zero_sign) -if test "$ac_cv_tanh_preserves_zero_sign" = yes -then - AC_DEFINE(TANH_PRESERVES_ZERO_SIGN, 1, - [Define if tanh(-0.) is -0., or if platform doesn't have signed zeros]) -fi - -AC_CHECK_FUNCS([acosh asinh atanh copysign erf erfc expm1 finite gamma]) -AC_CHECK_FUNCS([hypot lgamma log1p round tgamma]) -AC_CHECK_DECLS([isinf, isnan, isfinite], [], [], [[#include ]]) - -LIBS=$LIBS_SAVE - -# For multiprocessing module, check that sem_open -# actually works. For FreeBSD versions <= 7.2, -# the kernel module that provides POSIX semaphores -# isn't loaded by default, so an attempt to call -# sem_open results in a 'Signal 12' error. -AC_MSG_CHECKING(whether POSIX semaphores are enabled) -AC_CACHE_VAL(ac_cv_posix_semaphores_enabled, -AC_RUN_IFELSE([AC_LANG_SOURCE([[ -#include -#include -#include -#include -#include - -int main(void) { - sem_t *a = sem_open("/autoconf", O_CREAT, S_IRUSR|S_IWUSR, 0); - if (a == SEM_FAILED) { - perror("sem_open"); - return 1; - } - sem_close(a); - sem_unlink("/autoconf"); - return 0; -} -]])], -[ac_cv_posix_semaphores_enabled=yes], -[ac_cv_posix_semaphores_enabled=no], -[ac_cv_posix_semaphores_enabled=yes]) -) -AC_MSG_RESULT($ac_cv_posix_semaphores_enabled) -if test $ac_cv_posix_semaphores_enabled = no -then - AC_DEFINE(POSIX_SEMAPHORES_NOT_ENABLED, 1, - [Define if POSIX semaphores aren't enabled on your system]) -fi - -# Multiprocessing check for broken sem_getvalue -AC_MSG_CHECKING(for broken sem_getvalue) -AC_CACHE_VAL(ac_cv_broken_sem_getvalue, -AC_RUN_IFELSE([AC_LANG_SOURCE([[ -#include -#include -#include -#include -#include - -int main(void){ - sem_t *a = sem_open("/autocftw", O_CREAT, S_IRUSR|S_IWUSR, 0); - int count; - int res; - if(a==SEM_FAILED){ - perror("sem_open"); - return 1; - - } - res = sem_getvalue(a, &count); - sem_close(a); - sem_unlink("/autocftw"); - return res==-1 ? 1 : 0; -} -]])], -[ac_cv_broken_sem_getvalue=no], -[ac_cv_broken_sem_getvalue=yes], -[ac_cv_broken_sem_getvalue=yes]) -) -AC_MSG_RESULT($ac_cv_broken_sem_getvalue) -if test $ac_cv_broken_sem_getvalue = yes -then - AC_DEFINE(HAVE_BROKEN_SEM_GETVALUE, 1, - [define to 1 if your sem_getvalue is broken.]) -fi - -# determine what size digit to use for Python's longs -AC_MSG_CHECKING([digit size for Python's longs]) -AC_ARG_ENABLE(big-digits, -AS_HELP_STRING([--enable-big-digits@<:@=BITS@:>@],[use big digits for Python longs [[BITS=30]]]), -[case $enable_big_digits in -yes) - enable_big_digits=30 ;; -no) - enable_big_digits=15 ;; -[15|30]) - ;; -*) - AC_MSG_ERROR([bad value $enable_big_digits for --enable-big-digits; value should be 15 or 30]) ;; -esac -AC_MSG_RESULT($enable_big_digits) -AC_DEFINE_UNQUOTED(PYLONG_BITS_IN_DIGIT, $enable_big_digits, [Define as the preferred size in bits of long digits]) -], -[AC_MSG_RESULT(no value specified)]) - -# check for wchar.h -AC_CHECK_HEADER(wchar.h, [ - AC_DEFINE(HAVE_WCHAR_H, 1, - [Define if the compiler provides a wchar.h header file.]) - wchar_h="yes" -], -wchar_h="no" -) - -# determine wchar_t size -if test "$wchar_h" = yes -then - AC_CHECK_SIZEOF(wchar_t, 4, [#include ]) -fi - -AC_MSG_CHECKING(for UCS-4 tcl) -have_ucs4_tcl=no -AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ -#include -#if TCL_UTF_MAX != 6 -# error "NOT UCS4_TCL" -#endif]], [[]])],[ - AC_DEFINE(HAVE_UCS4_TCL, 1, [Define this if you have tcl and TCL_UTF_MAX==6]) - have_ucs4_tcl=yes -],[]) -AC_MSG_RESULT($have_ucs4_tcl) - -# check whether wchar_t is signed or not -if test "$wchar_h" = yes -then - # check whether wchar_t is signed or not - AC_MSG_CHECKING(whether wchar_t is signed) - AC_CACHE_VAL(ac_cv_wchar_t_signed, [ - AC_RUN_IFELSE([AC_LANG_SOURCE([[ - #include - int main() - { - /* Success: exit code 0 */ - exit((((wchar_t) -1) < ((wchar_t) 0)) ? 0 : 1); - } - ]])], - [ac_cv_wchar_t_signed=yes], - [ac_cv_wchar_t_signed=no], - [ac_cv_wchar_t_signed=yes])]) - AC_MSG_RESULT($ac_cv_wchar_t_signed) -fi - -AC_MSG_CHECKING(what type to use for unicode) -dnl quadrigraphs "@<:@" and "@:>@" produce "[" and "]" in the output -AC_ARG_ENABLE(unicode, - AS_HELP_STRING([--enable-unicode@<:@=ucs@<:@24@:>@@:>@], [Enable Unicode strings (default is ucs2)]), - [], - [enable_unicode=yes]) - -if test $enable_unicode = yes -then - # Without any arguments, Py_UNICODE defaults to two-byte mode - case "$have_ucs4_tcl" in - yes) enable_unicode="ucs4" - ;; - *) enable_unicode="ucs2" - ;; - esac -fi - -AH_TEMPLATE(Py_UNICODE_SIZE, - [Define as the size of the unicode type.]) -case "$enable_unicode" in -ucs2) unicode_size="2" - AC_DEFINE(Py_UNICODE_SIZE,2) - ;; -ucs4) unicode_size="4" - AC_DEFINE(Py_UNICODE_SIZE,4) - ;; -no) ;; # To allow --disable-unicode -*) AC_MSG_ERROR([invalid value for --enable-unicode. Use either ucs2 or ucs4 (lowercase).]) ;; -esac - -AH_TEMPLATE(PY_UNICODE_TYPE, - [Define as the integral type used for Unicode representation.]) - -AC_SUBST(UNICODE_OBJS) -if test "$enable_unicode" = "no" -then - UNICODE_OBJS="" - AC_MSG_RESULT(not used) -else - UNICODE_OBJS="Objects/unicodeobject.o Objects/unicodectype.o" - AC_DEFINE(Py_USING_UNICODE, 1, - [Define if you want to have a Unicode type.]) - - # wchar_t is only usable if it maps to an unsigned type - if test "$unicode_size" = "$ac_cv_sizeof_wchar_t" \ - -a "$ac_cv_wchar_t_signed" = "no" - then - PY_UNICODE_TYPE="wchar_t" - AC_DEFINE(HAVE_USABLE_WCHAR_T, 1, - [Define if you have a useable wchar_t type defined in wchar.h; useable - means wchar_t must be an unsigned type with at least 16 bits. (see - Include/unicodeobject.h).]) - AC_DEFINE(PY_UNICODE_TYPE,wchar_t) - elif test "$ac_cv_sizeof_short" = "$unicode_size" - then - PY_UNICODE_TYPE="unsigned short" - AC_DEFINE(PY_UNICODE_TYPE,unsigned short) - elif test "$ac_cv_sizeof_long" = "$unicode_size" - then - PY_UNICODE_TYPE="unsigned long" - AC_DEFINE(PY_UNICODE_TYPE,unsigned long) - else - PY_UNICODE_TYPE="no type found" - fi - AC_MSG_RESULT($PY_UNICODE_TYPE) -fi - -# check for endianness -AC_C_BIGENDIAN - -# Check whether right shifting a negative integer extends the sign bit -# or fills with zeros (like the Cray J90, according to Tim Peters). -AC_MSG_CHECKING(whether right shift extends the sign bit) -AC_CACHE_VAL(ac_cv_rshift_extends_sign, [ -AC_RUN_IFELSE([AC_LANG_SOURCE([[ -int main() -{ - exit(((-1)>>3 == -1) ? 0 : 1); -} -]])], -[ac_cv_rshift_extends_sign=yes], -[ac_cv_rshift_extends_sign=no], -[ac_cv_rshift_extends_sign=yes])]) -AC_MSG_RESULT($ac_cv_rshift_extends_sign) -if test "$ac_cv_rshift_extends_sign" = no -then - AC_DEFINE(SIGNED_RIGHT_SHIFT_ZERO_FILLS, 1, - [Define if i>>j for signed int i does not extend the sign bit - when i < 0]) -fi - -# check for getc_unlocked and related locking functions -AC_MSG_CHECKING(for getc_unlocked() and friends) -AC_CACHE_VAL(ac_cv_have_getc_unlocked, [ -AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include ]], [[ - FILE *f = fopen("/dev/null", "r"); - flockfile(f); - getc_unlocked(f); - funlockfile(f); -]])],[ac_cv_have_getc_unlocked=yes],[ac_cv_have_getc_unlocked=no])]) -AC_MSG_RESULT($ac_cv_have_getc_unlocked) -if test "$ac_cv_have_getc_unlocked" = yes -then - AC_DEFINE(HAVE_GETC_UNLOCKED, 1, - [Define this if you have flockfile(), getc_unlocked(), and funlockfile()]) -fi - -# check where readline lives -# save the value of LIBS so we don't actually link Python with readline -LIBS_no_readline=$LIBS - -# On some systems we need to link readline to a termcap compatible -# library. NOTE: Keep the precedence of listed libraries synchronised -# with setup.py. -py_cv_lib_readline=no -AC_MSG_CHECKING([how to link readline libs]) -for py_libtermcap in "" ncursesw ncurses curses termcap; do - if test -z "$py_libtermcap"; then - READLINE_LIBS="-lreadline" - else - READLINE_LIBS="-lreadline -l$py_libtermcap" - fi - LIBS="$READLINE_LIBS $LIBS_no_readline" - AC_LINK_IFELSE( - [AC_LANG_CALL([],[readline])], - [py_cv_lib_readline=yes]) - if test $py_cv_lib_readline = yes; then - break - fi -done -# Uncomment this line if you want to use READINE_LIBS in Makefile or scripts -#AC_SUBST([READLINE_LIBS]) -if test $py_cv_lib_readline = no; then - AC_MSG_RESULT([none]) -else - AC_MSG_RESULT([$READLINE_LIBS]) - AC_DEFINE(HAVE_LIBREADLINE, 1, - [Define if you have the readline library (-lreadline).]) -fi - -# check for readline 2.1 -AC_CHECK_LIB(readline, rl_callback_handler_install, - AC_DEFINE(HAVE_RL_CALLBACK, 1, - [Define if you have readline 2.1]), ,$READLINE_LIBS) - -# check for readline 2.2 -AC_PREPROC_IFELSE([AC_LANG_SOURCE([[#include ]])], - [have_readline=yes], - [have_readline=no] -) -if test $have_readline = yes -then - AC_EGREP_HEADER([extern int rl_completion_append_character;], - [readline/readline.h], - AC_DEFINE(HAVE_RL_COMPLETION_APPEND_CHARACTER, 1, - [Define if you have readline 2.2]), ) - AC_EGREP_HEADER([extern int rl_completion_suppress_append;], - [readline/readline.h], - AC_DEFINE(HAVE_RL_COMPLETION_SUPPRESS_APPEND, 1, - [Define if you have rl_completion_suppress_append]), ) -fi - -# check for readline 4.0 -AC_CHECK_LIB(readline, rl_pre_input_hook, - AC_DEFINE(HAVE_RL_PRE_INPUT_HOOK, 1, - [Define if you have readline 4.0]), ,$READLINE_LIBS) - -# also in 4.0 -AC_CHECK_LIB(readline, rl_completion_display_matches_hook, - AC_DEFINE(HAVE_RL_COMPLETION_DISPLAY_MATCHES_HOOK, 1, - [Define if you have readline 4.0]), ,$READLINE_LIBS) - -# check for readline 4.2 -AC_CHECK_LIB(readline, rl_completion_matches, - AC_DEFINE(HAVE_RL_COMPLETION_MATCHES, 1, - [Define if you have readline 4.2]), ,$READLINE_LIBS) - -# also in readline 4.2 -AC_PREPROC_IFELSE([AC_LANG_SOURCE([[#include ]])], - [have_readline=yes], - [have_readline=no] -) -if test $have_readline = yes -then - AC_EGREP_HEADER([extern int rl_catch_signals;], - [readline/readline.h], - AC_DEFINE(HAVE_RL_CATCH_SIGNAL, 1, - [Define if you can turn off readline's signal handling.]), ) -fi - -# End of readline checks: restore LIBS -LIBS=$LIBS_no_readline - -AC_MSG_CHECKING(for broken nice()) -AC_CACHE_VAL(ac_cv_broken_nice, [ -AC_RUN_IFELSE([AC_LANG_SOURCE([[ -int main() -{ - int val1 = nice(1); - if (val1 != -1 && val1 == nice(2)) - exit(0); - exit(1); -} -]])], -[ac_cv_broken_nice=yes], -[ac_cv_broken_nice=no], -[ac_cv_broken_nice=no])]) -AC_MSG_RESULT($ac_cv_broken_nice) -if test "$ac_cv_broken_nice" = yes -then - AC_DEFINE(HAVE_BROKEN_NICE, 1, - [Define if nice() returns success/failure instead of the new priority.]) -fi - -AC_MSG_CHECKING(for broken poll()) -AC_CACHE_VAL(ac_cv_broken_poll, -AC_RUN_IFELSE([AC_LANG_SOURCE([[ -#include - -int main() -{ - struct pollfd poll_struct = { 42, POLLIN|POLLPRI|POLLOUT, 0 }; - int poll_test; - - close (42); - - poll_test = poll(&poll_struct, 1, 0); - if (poll_test < 0) - return 0; - else if (poll_test == 0 && poll_struct.revents != POLLNVAL) - return 0; - else - return 1; -} -]])], -[ac_cv_broken_poll=yes], -[ac_cv_broken_poll=no], -[ac_cv_broken_poll=no])) -AC_MSG_RESULT($ac_cv_broken_poll) -if test "$ac_cv_broken_poll" = yes -then - AC_DEFINE(HAVE_BROKEN_POLL, 1, - [Define if poll() sets errno on invalid file descriptors.]) -fi - -# Before we can test tzset, we need to check if struct tm has a tm_zone -# (which is not required by ISO C or UNIX spec) and/or if we support -# tzname[] -AC_STRUCT_TIMEZONE - -# check tzset(3) exists and works like we expect it to -AC_MSG_CHECKING(for working tzset()) -AC_CACHE_VAL(ac_cv_working_tzset, [ -AC_RUN_IFELSE([AC_LANG_SOURCE([[ -#include -#include -#include - -#if HAVE_TZNAME -extern char *tzname[]; -#endif - -int main() -{ - /* Note that we need to ensure that not only does tzset(3) - do 'something' with localtime, but it works as documented - in the library reference and as expected by the test suite. - This includes making sure that tzname is set properly if - tm->tm_zone does not exist since it is the alternative way - of getting timezone info. - - Red Hat 6.2 doesn't understand the southern hemisphere - after New Year's Day. - */ - - time_t groundhogday = 1044144000; /* GMT-based */ - time_t midyear = groundhogday + (365 * 24 * 3600 / 2); - - putenv("TZ=UTC+0"); - tzset(); - if (localtime(&groundhogday)->tm_hour != 0) - exit(1); -#if HAVE_TZNAME - /* For UTC, tzname[1] is sometimes "", sometimes " " */ - if (strcmp(tzname[0], "UTC") || - (tzname[1][0] != 0 && tzname[1][0] != ' ')) - exit(1); -#endif - - putenv("TZ=EST+5EDT,M4.1.0,M10.5.0"); - tzset(); - if (localtime(&groundhogday)->tm_hour != 19) - exit(1); -#if HAVE_TZNAME - if (strcmp(tzname[0], "EST") || strcmp(tzname[1], "EDT")) - exit(1); -#endif - - putenv("TZ=AEST-10AEDT-11,M10.5.0,M3.5.0"); - tzset(); - if (localtime(&groundhogday)->tm_hour != 11) - exit(1); -#if HAVE_TZNAME - if (strcmp(tzname[0], "AEST") || strcmp(tzname[1], "AEDT")) - exit(1); -#endif - -#if HAVE_STRUCT_TM_TM_ZONE - if (strcmp(localtime(&groundhogday)->tm_zone, "AEDT")) - exit(1); - if (strcmp(localtime(&midyear)->tm_zone, "AEST")) - exit(1); -#endif - - exit(0); -} -]])], -[ac_cv_working_tzset=yes], -[ac_cv_working_tzset=no], -[ac_cv_working_tzset=no])]) -AC_MSG_RESULT($ac_cv_working_tzset) -if test "$ac_cv_working_tzset" = yes -then - AC_DEFINE(HAVE_WORKING_TZSET, 1, - [Define if tzset() actually switches the local timezone in a meaningful way.]) -fi - -# Look for subsecond timestamps in struct stat -AC_MSG_CHECKING(for tv_nsec in struct stat) -AC_CACHE_VAL(ac_cv_stat_tv_nsec, -AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include ]], [[ -struct stat st; -st.st_mtim.tv_nsec = 1; -]])], -[ac_cv_stat_tv_nsec=yes], -[ac_cv_stat_tv_nsec=no])) -AC_MSG_RESULT($ac_cv_stat_tv_nsec) -if test "$ac_cv_stat_tv_nsec" = yes -then - AC_DEFINE(HAVE_STAT_TV_NSEC, 1, - [Define if you have struct stat.st_mtim.tv_nsec]) -fi - -# Look for BSD style subsecond timestamps in struct stat -AC_MSG_CHECKING(for tv_nsec2 in struct stat) -AC_CACHE_VAL(ac_cv_stat_tv_nsec2, -AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include ]], [[ -struct stat st; -st.st_mtimespec.tv_nsec = 1; -]])], -[ac_cv_stat_tv_nsec2=yes], -[ac_cv_stat_tv_nsec2=no])) -AC_MSG_RESULT($ac_cv_stat_tv_nsec2) -if test "$ac_cv_stat_tv_nsec2" = yes -then - AC_DEFINE(HAVE_STAT_TV_NSEC2, 1, - [Define if you have struct stat.st_mtimensec]) -fi - -# first curses configure check -ac_save_cppflags="$CPPFLAGS" -CPPFLAGS="$CPPFLAGS -I/usr/include/ncursesw" - -AC_CHECK_HEADERS(curses.h ncurses.h) - -# On Solaris, term.h requires curses.h -AC_CHECK_HEADERS(term.h,,,[ -#ifdef HAVE_CURSES_H -#include -#endif -]) - -# On HP/UX 11.0, mvwdelch is a block with a return statement -AC_MSG_CHECKING(whether mvwdelch is an expression) -AC_CACHE_VAL(ac_cv_mvwdelch_is_expression, -AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include ]], [[ - int rtn; - rtn = mvwdelch(0,0,0); -]])], -[ac_cv_mvwdelch_is_expression=yes], -[ac_cv_mvwdelch_is_expression=no])) -AC_MSG_RESULT($ac_cv_mvwdelch_is_expression) - -if test "$ac_cv_mvwdelch_is_expression" = yes -then - AC_DEFINE(MVWDELCH_IS_EXPRESSION, 1, - [Define if mvwdelch in curses.h is an expression.]) -fi - -AC_MSG_CHECKING(whether WINDOW has _flags) -AC_CACHE_VAL(ac_cv_window_has_flags, -AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include ]], [[ - WINDOW *w; - w->_flags = 0; -]])], -[ac_cv_window_has_flags=yes], -[ac_cv_window_has_flags=no])) -AC_MSG_RESULT($ac_cv_window_has_flags) - - -if test "$ac_cv_window_has_flags" = yes -then - AC_DEFINE(WINDOW_HAS_FLAGS, 1, - [Define if WINDOW in curses.h offers a field _flags.]) -fi - -AC_MSG_CHECKING(for is_term_resized) -AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include ]], [[void *x=is_term_resized]])], - [AC_DEFINE(HAVE_CURSES_IS_TERM_RESIZED, 1, Define if you have the 'is_term_resized' function.) - AC_MSG_RESULT(yes)], - [AC_MSG_RESULT(no)] -) - -AC_MSG_CHECKING(for resize_term) -AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include ]], [[void *x=resize_term]])], - [AC_DEFINE(HAVE_CURSES_RESIZE_TERM, 1, Define if you have the 'resize_term' function.) - AC_MSG_RESULT(yes)], - [AC_MSG_RESULT(no)] -) - -AC_MSG_CHECKING(for resizeterm) -AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include ]], [[void *x=resizeterm]])], - [AC_DEFINE(HAVE_CURSES_RESIZETERM, 1, Define if you have the 'resizeterm' function.) - AC_MSG_RESULT(yes)], - [AC_MSG_RESULT(no)] -) -# last curses configure check -CPPFLAGS=$ac_save_cppflags - -AC_MSG_NOTICE([checking for device files]) - -dnl NOTE: Inform user how to proceed with files when cross compiling. -if test "x$cross_compiling" = xyes; then - if test "${ac_cv_file__dev_ptmx+set}" != set; then - AC_MSG_CHECKING([for /dev/ptmx]) - AC_MSG_RESULT([not set]) - AC_MSG_ERROR([set ac_cv_file__dev_ptmx to yes/no in your CONFIG_SITE file when cross compiling]) - fi - if test "${ac_cv_file__dev_ptc+set}" != set; then - AC_MSG_CHECKING([for /dev/ptc]) - AC_MSG_RESULT([not set]) - AC_MSG_ERROR([set ac_cv_file__dev_ptc to yes/no in your CONFIG_SITE file when cross compiling]) - fi -fi - -AC_CHECK_FILE(/dev/ptmx, [], []) -if test "x$ac_cv_file__dev_ptmx" = xyes; then - AC_DEFINE(HAVE_DEV_PTMX, 1, - [Define to 1 if you have the /dev/ptmx device file.]) -fi -AC_CHECK_FILE(/dev/ptc, [], []) -if test "x$ac_cv_file__dev_ptc" = xyes; then - AC_DEFINE(HAVE_DEV_PTC, 1, - [Define to 1 if you have the /dev/ptc device file.]) -fi - -if test "$have_long_long" = yes -then - AC_MSG_CHECKING(for %lld and %llu printf() format support) - AC_CACHE_VAL(ac_cv_have_long_long_format, - AC_RUN_IFELSE([AC_LANG_SOURCE([[[ - #include - #include - #include - - #ifdef HAVE_SYS_TYPES_H - #include - #endif - - int main() - { - char buffer[256]; - - if (sprintf(buffer, "%lld", (long long)123) < 0) - return 1; - if (strcmp(buffer, "123")) - return 1; - - if (sprintf(buffer, "%lld", (long long)-123) < 0) - return 1; - if (strcmp(buffer, "-123")) - return 1; - - if (sprintf(buffer, "%llu", (unsigned long long)123) < 0) - return 1; - if (strcmp(buffer, "123")) - return 1; - - return 0; - } - ]]])], - [ac_cv_have_long_long_format=yes], - [ac_cv_have_long_long_format=no], - [ac_cv_have_long_long_format="cross -- assuming no" - if test x$GCC = xyes; then - save_CFLAGS=$CFLAGS - CFLAGS="$CFLAGS -Werror -Wformat" - AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ - #include - #include - ]], [[ - char *buffer; - sprintf(buffer, "%lld", (long long)123); - sprintf(buffer, "%lld", (long long)-123); - sprintf(buffer, "%llu", (unsigned long long)123); - ]])], - ac_cv_have_long_long_format=yes - ) - CFLAGS=$save_CFLAGS - fi]) - ) - AC_MSG_RESULT($ac_cv_have_long_long_format) -fi - -if test "$ac_cv_have_long_long_format" = yes -then - AC_DEFINE(PY_FORMAT_LONG_LONG, "ll", - [Define to printf format modifier for long long type]) -fi - -if test $ac_sys_system = Darwin -then - LIBS="$LIBS -framework CoreFoundation" -fi - - -AC_CACHE_CHECK([for %zd printf() format support], ac_cv_have_size_t_format, [dnl -AC_RUN_IFELSE([AC_LANG_SOURCE([[ -#include -#include -#include - -#ifdef HAVE_SYS_TYPES_H -#include -#endif - -#ifdef HAVE_SSIZE_T -typedef ssize_t Py_ssize_t; -#elif SIZEOF_VOID_P == SIZEOF_LONG -typedef long Py_ssize_t; -#else -typedef int Py_ssize_t; -#endif - -int main() -{ - char buffer[256]; - - if(sprintf(buffer, "%zd", (size_t)123) < 0) - return 1; - - if (strcmp(buffer, "123")) - return 1; - - if (sprintf(buffer, "%zd", (Py_ssize_t)-123) < 0) - return 1; - - if (strcmp(buffer, "-123")) - return 1; - - return 0; -} -]])], -[ac_cv_have_size_t_format=yes], -[ac_cv_have_size_t_format=no], -[ac_cv_have_size_t_format="cross -- assuming yes" -])]) -if test "$ac_cv_have_size_t_format" != no ; then - AC_DEFINE(PY_FORMAT_SIZE_T, "z", - [Define to printf format modifier for Py_ssize_t]) -fi - -AC_CHECK_TYPE(socklen_t,, - AC_DEFINE(socklen_t,int, - [Define to `int' if does not define.]),[ -#ifdef HAVE_SYS_TYPES_H -#include -#endif -#ifdef HAVE_SYS_SOCKET_H -#include -#endif -]) - -case $ac_sys_system in -AIX*) - AC_DEFINE(HAVE_BROKEN_PIPE_BUF, 1, [Define if the system reports an invalid PIPE_BUF value.]) ;; -esac - - -AC_SUBST(THREADHEADERS) - -for h in `(cd $srcdir;echo Python/thread_*.h)` -do - THREADHEADERS="$THREADHEADERS \$(srcdir)/$h" -done - -AC_SUBST(SRCDIRS) -SRCDIRS="Parser Grammar Objects Python Modules Mac" -AC_MSG_CHECKING(for build directories) -for dir in $SRCDIRS; do - if test ! -d $dir; then - mkdir $dir - fi -done -AC_MSG_RESULT(done) - -# generate output files -AC_CONFIG_FILES(Makefile.pre Modules/Setup.config Misc/python.pc) -AC_CONFIG_FILES([Modules/ld_so_aix], [chmod +x Modules/ld_so_aix]) -AC_OUTPUT - -echo "creating Modules/Setup" -if test ! -f Modules/Setup -then - cp $srcdir/Modules/Setup.dist Modules/Setup -fi - -echo "creating Modules/Setup.local" -if test ! -f Modules/Setup.local -then - echo "# Edit this file for local setup changes" >Modules/Setup.local -fi - -echo "creating Makefile" -$SHELL $srcdir/Modules/makesetup -c $srcdir/Modules/config.c.in \ - -s Modules Modules/Setup.config \ - Modules/Setup.local Modules/Setup - -case $ac_sys_system in -BeOS) - AC_MSG_WARN([ - - Support for BeOS is deprecated as of Python 2.6. - See PEP 11 for the gory details. - ]) - ;; -*) ;; -esac - -mv config.c Modules diff -r 9cd3ab7c09d1 -r 9ac347a7f375 configure.in --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/configure.in Sun Jul 20 10:52:46 2014 -0400 @@ -0,0 +1,4355 @@ +dnl *********************************************** +dnl * Please run autoreconf to test your changes! * +dnl *********************************************** + +# Set VERSION so we only need to edit in one place (i.e., here) +m4_define(PYTHON_VERSION, 2.7) + +AC_PREREQ(2.65) + +AC_REVISION($Revision$) +AC_INIT(python, PYTHON_VERSION, http://bugs.python.org/) +AC_CONFIG_SRCDIR([Include/object.h]) +AC_CONFIG_HEADER(pyconfig.h) + +dnl Ensure that if prefix is specified, it does not end in a slash. If +dnl it does, we get path names containing '//' which is both ugly and +dnl can cause trouble. + +dnl Last slash shouldn't be stripped if prefix=/ +if test "$prefix" != "/"; then + prefix=`echo "$prefix" | sed -e 's/\/$//g'` +fi + +dnl This is for stuff that absolutely must end up in pyconfig.h. +dnl Please use pyport.h instead, if possible. +AH_TOP([ +#ifndef Py_PYCONFIG_H +#define Py_PYCONFIG_H +]) +AH_BOTTOM([ +/* Define the macros needed if on a UnixWare 7.x system. */ +#if defined(__USLC__) && defined(__SCO_VERSION__) +#define STRICT_SYSV_CURSES /* Don't use ncurses extensions */ +#endif + +#endif /*Py_PYCONFIG_H*/ +]) + +# We don't use PACKAGE_ variables, and they cause conflicts +# with other autoconf-based packages that include Python.h +grep -v 'define PACKAGE_' confdefs.h.new +rm confdefs.h +mv confdefs.h.new confdefs.h + +AC_SUBST(VERSION) +VERSION=PYTHON_VERSION + +AC_SUBST(SOVERSION) +SOVERSION=1.0 + +# The later defininition of _XOPEN_SOURCE disables certain features +# on Linux, so we need _GNU_SOURCE to re-enable them (makedev, tm_zone). +AC_DEFINE(_GNU_SOURCE, 1, [Define on Linux to activate all library features]) + +# The later defininition of _XOPEN_SOURCE and _POSIX_C_SOURCE disables +# certain features on NetBSD, so we need _NETBSD_SOURCE to re-enable +# them. +AC_DEFINE(_NETBSD_SOURCE, 1, [Define on NetBSD to activate all library features]) + +# The later defininition of _XOPEN_SOURCE and _POSIX_C_SOURCE disables +# certain features on FreeBSD, so we need __BSD_VISIBLE to re-enable +# them. +AC_DEFINE(__BSD_VISIBLE, 1, [Define on FreeBSD to activate all library features]) + +# The later defininition of _XOPEN_SOURCE and _POSIX_C_SOURCE disables +# u_int on Irix 5.3. Defining _BSD_TYPES brings it back. +AC_DEFINE(_BSD_TYPES, 1, [Define on Irix to enable u_int]) + +# The later defininition of _XOPEN_SOURCE and _POSIX_C_SOURCE disables +# certain features on Mac OS X, so we need _DARWIN_C_SOURCE to re-enable +# them. +AC_DEFINE(_DARWIN_C_SOURCE, 1, [Define on Darwin to activate all library features]) + + +define_xopen_source=yes + +# Arguments passed to configure. +AC_SUBST(CONFIG_ARGS) +CONFIG_ARGS="$ac_configure_args" + +AC_MSG_CHECKING([for --enable-universalsdk]) +AC_ARG_ENABLE(universalsdk, + AS_HELP_STRING([--enable-universalsdk@<:@=SDKDIR@:>@], [Build against Mac OS X 10.4u SDK (ppc/i386)]), +[ + case $enableval in + yes) + enableval=/Developer/SDKs/MacOSX10.4u.sdk + if test ! -d "${enableval}" + then + enableval=/ + fi + ;; + esac + case $enableval in + no) + UNIVERSALSDK= + enable_universalsdk= + ;; + *) + UNIVERSALSDK=$enableval + if test ! -d "${UNIVERSALSDK}" + then + AC_MSG_ERROR([--enable-universalsdk specifies non-existing SDK: ${UNIVERSALSDK}]) + fi + ;; + esac + +],[ + UNIVERSALSDK= + enable_universalsdk= +]) +if test -n "${UNIVERSALSDK}" +then + AC_MSG_RESULT(${UNIVERSALSDK}) +else + AC_MSG_RESULT(no) +fi +AC_SUBST(UNIVERSALSDK) + +AC_SUBST(ARCH_RUN_32BIT) + +UNIVERSAL_ARCHS="32-bit" +AC_SUBST(LIPO_32BIT_FLAGS) +AC_MSG_CHECKING(for --with-universal-archs) +AC_ARG_WITH(universal-archs, + AS_HELP_STRING([--with-universal-archs=ARCH], [select architectures for universal build ("32-bit", "64-bit", "3-way", "intel" or "all")]), +[ + AC_MSG_RESULT($withval) + UNIVERSAL_ARCHS="$withval" + if test "${enable_universalsdk}" ; then + : + else + AC_MSG_ERROR([--with-universal-archs without --enable-universalsdk. See Mac/README]) + fi +], +[ + AC_MSG_RESULT(32-bit) +]) + + + +AC_ARG_WITH(framework-name, + AS_HELP_STRING([--with-framework-name=FRAMEWORK], + [specify an alternate name of the framework built with --enable-framework]), +[ + if test "${enable_framework}"; then + : + else + AC_MSG_ERROR([--with-framework-name without --enable-framework. See Mac/README]) + fi + PYTHONFRAMEWORK=${withval} + PYTHONFRAMEWORKDIR=${withval}.framework + PYTHONFRAMEWORKIDENTIFIER=org.python.`echo $withval | tr '[A-Z]' '[a-z]'` + ],[ + PYTHONFRAMEWORK=Python + PYTHONFRAMEWORKDIR=Python.framework + PYTHONFRAMEWORKIDENTIFIER=org.python.python +]) +dnl quadrigraphs "@<:@" and "@:>@" produce "[" and "]" in the output +AC_ARG_ENABLE(framework, + AS_HELP_STRING([--enable-framework@<:@=INSTALLDIR@:>@], [Build (MacOSX|Darwin) framework]), +[ + case $enableval in + yes) + enableval=/Library/Frameworks + esac + case $enableval in + no) + PYTHONFRAMEWORK= + PYTHONFRAMEWORKDIR=no-framework + PYTHONFRAMEWORKPREFIX= + PYTHONFRAMEWORKINSTALLDIR= + FRAMEWORKINSTALLFIRST= + FRAMEWORKINSTALLLAST= + FRAMEWORKALTINSTALLFIRST= + FRAMEWORKALTINSTALLLAST= + if test "x${prefix}" = "xNONE"; then + FRAMEWORKUNIXTOOLSPREFIX="${ac_default_prefix}" + else + FRAMEWORKUNIXTOOLSPREFIX="${prefix}" + fi + enable_framework= + ;; + *) + PYTHONFRAMEWORKPREFIX="${enableval}" + PYTHONFRAMEWORKINSTALLDIR=$PYTHONFRAMEWORKPREFIX/$PYTHONFRAMEWORKDIR + FRAMEWORKINSTALLFIRST="frameworkinstallstructure" + FRAMEWORKALTINSTALLFIRST="frameworkinstallstructure bininstall maninstall" + FRAMEWORKINSTALLLAST="frameworkinstallmaclib frameworkinstallapps frameworkinstallunixtools" + FRAMEWORKALTINSTALLLAST="frameworkinstallmaclib frameworkinstallapps frameworkaltinstallunixtools" + FRAMEWORKINSTALLAPPSPREFIX="/Applications" + + if test "x${prefix}" = "xNONE" ; then + FRAMEWORKUNIXTOOLSPREFIX="${ac_default_prefix}" + + else + FRAMEWORKUNIXTOOLSPREFIX="${prefix}" + fi + + case "${enableval}" in + /System*) + FRAMEWORKINSTALLAPPSPREFIX="/Applications" + if test "${prefix}" = "NONE" ; then + # See below + FRAMEWORKUNIXTOOLSPREFIX="/usr" + fi + ;; + + /Library*) + FRAMEWORKINSTALLAPPSPREFIX="/Applications" + ;; + + */Library/Frameworks) + MDIR="`dirname "${enableval}"`" + MDIR="`dirname "${MDIR}"`" + FRAMEWORKINSTALLAPPSPREFIX="${MDIR}/Applications" + + if test "${prefix}" = "NONE"; then + # User hasn't specified the + # --prefix option, but wants to install + # the framework in a non-default location, + # ensure that the compatibility links get + # installed relative to that prefix as well + # instead of in /usr/local. + FRAMEWORKUNIXTOOLSPREFIX="${MDIR}" + fi + ;; + + *) + FRAMEWORKINSTALLAPPSPREFIX="/Applications" + ;; + esac + + prefix=$PYTHONFRAMEWORKINSTALLDIR/Versions/$VERSION + + # Add files for Mac specific code to the list of output + # files: + AC_CONFIG_FILES(Mac/Makefile) + AC_CONFIG_FILES(Mac/PythonLauncher/Makefile) + AC_CONFIG_FILES(Mac/IDLE/Makefile) + AC_CONFIG_FILES(Mac/Resources/framework/Info.plist) + AC_CONFIG_FILES(Mac/Resources/app/Info.plist) + esac + ],[ + PYTHONFRAMEWORK= + PYTHONFRAMEWORKDIR=no-framework + PYTHONFRAMEWORKPREFIX= + PYTHONFRAMEWORKINSTALLDIR= + FRAMEWORKINSTALLFIRST= + FRAMEWORKINSTALLLAST= + FRAMEWORKALTINSTALLFIRST= + FRAMEWORKALTINSTALLLAST= + if test "x${prefix}" = "xNONE" ; then + FRAMEWORKUNIXTOOLSPREFIX="${ac_default_prefix}" + else + FRAMEWORKUNIXTOOLSPREFIX="${prefix}" + fi + enable_framework= + +]) +AC_SUBST(PYTHONFRAMEWORK) +AC_SUBST(PYTHONFRAMEWORKIDENTIFIER) +AC_SUBST(PYTHONFRAMEWORKDIR) +AC_SUBST(PYTHONFRAMEWORKPREFIX) +AC_SUBST(PYTHONFRAMEWORKINSTALLDIR) +AC_SUBST(FRAMEWORKINSTALLFIRST) +AC_SUBST(FRAMEWORKINSTALLLAST) +AC_SUBST(FRAMEWORKALTINSTALLFIRST) +AC_SUBST(FRAMEWORKALTINSTALLLAST) +AC_SUBST(FRAMEWORKUNIXTOOLSPREFIX) +AC_SUBST(FRAMEWORKINSTALLAPPSPREFIX) + +##AC_ARG_WITH(dyld, +## AS_HELP_STRING([--with-dyld], +## [Use (OpenStep|Rhapsody) dynamic linker])) +## +# Set name for machine-dependent library files +AC_SUBST(MACHDEP) +AC_MSG_CHECKING(MACHDEP) +if test -z "$MACHDEP" +then + ac_sys_system=`uname -s` + if test "$ac_sys_system" = "AIX" \ + -o "$ac_sys_system" = "UnixWare" -o "$ac_sys_system" = "OpenUNIX"; then + ac_sys_release=`uname -v` + else + ac_sys_release=`uname -r` + fi + ac_md_system=`echo $ac_sys_system | + tr -d '[/ ]' | tr '[[A-Z]]' '[[a-z]]'` + ac_md_release=`echo $ac_sys_release | + tr -d '[/ ]' | sed 's/^[[A-Z]]\.//' | sed 's/\..*//'` + MACHDEP="$ac_md_system$ac_md_release" + + case $MACHDEP in + linux*) MACHDEP="linux2";; + cygwin*) MACHDEP="cygwin";; + darwin*) MACHDEP="darwin";; + atheos*) MACHDEP="atheos";; + irix646) MACHDEP="irix6";; + '') MACHDEP="unknown";; + esac +fi + +# Some systems cannot stand _XOPEN_SOURCE being defined at all; they +# disable features if it is defined, without any means to access these +# features as extensions. For these systems, we skip the definition of +# _XOPEN_SOURCE. Before adding a system to the list to gain access to +# some feature, make sure there is no alternative way to access this +# feature. Also, when using wildcards, make sure you have verified the +# need for not defining _XOPEN_SOURCE on all systems matching the +# wildcard, and that the wildcard does not include future systems +# (which may remove their limitations). +dnl quadrigraphs "@<:@" and "@:>@" produce "[" and "]" in the output +case $ac_sys_system/$ac_sys_release in + # On OpenBSD, select(2) is not available if _XOPEN_SOURCE is defined, + # even though select is a POSIX function. Reported by J. Ribbens. + # Reconfirmed for OpenBSD 3.3 by Zachary Hamm, for 3.4 by Jason Ish. + # In addition, Stefan Krah confirms that issue #1244610 exists through + # OpenBSD 4.6, but is fixed in 4.7. + OpenBSD/2.* | OpenBSD/3.* | OpenBSD/4.@<:@0123456@:>@) + define_xopen_source=no + # OpenBSD undoes our definition of __BSD_VISIBLE if _XOPEN_SOURCE is + # also defined. This can be overridden by defining _BSD_SOURCE + # As this has a different meaning on Linux, only define it on OpenBSD + AC_DEFINE(_BSD_SOURCE, 1, [Define on OpenBSD to activate all library features]) + ;; + OpenBSD/*) + # OpenBSD undoes our definition of __BSD_VISIBLE if _XOPEN_SOURCE is + # also defined. This can be overridden by defining _BSD_SOURCE + # As this has a different meaning on Linux, only define it on OpenBSD + AC_DEFINE(_BSD_SOURCE, 1, [Define on OpenBSD to activate all library features]) + ;; + # Defining _XOPEN_SOURCE on NetBSD version prior to the introduction of + # _NETBSD_SOURCE disables certain features (eg. setgroups). Reported by + # Marc Recht + NetBSD/1.5 | NetBSD/1.5.* | NetBSD/1.6 | NetBSD/1.6.* | NetBSD/1.6@<:@A-S@:>@) + define_xopen_source=no;; + # From the perspective of Solaris, _XOPEN_SOURCE is not so much a + # request to enable features supported by the standard as a request + # to disable features not supported by the standard. The best way + # for Python to use Solaris is simply to leave _XOPEN_SOURCE out + # entirely and define __EXTENSIONS__ instead. + SunOS/*) + define_xopen_source=no;; + # On UnixWare 7, u_long is never defined with _XOPEN_SOURCE, + # but used in /usr/include/netinet/tcp.h. Reported by Tim Rice. + # Reconfirmed for 7.1.4 by Martin v. Loewis. + OpenUNIX/8.0.0| UnixWare/7.1.@<:@0-4@:>@) + define_xopen_source=no;; + # On OpenServer 5, u_short is never defined with _XOPEN_SOURCE, + # but used in struct sockaddr.sa_family. Reported by Tim Rice. + SCO_SV/3.2) + define_xopen_source=no;; + # On FreeBSD 4, the math functions C89 does not cover are never defined + # with _XOPEN_SOURCE and __BSD_VISIBLE does not re-enable them. + FreeBSD/4.*) + define_xopen_source=no;; + # On MacOS X 10.2, a bug in ncurses.h means that it craps out if + # _XOPEN_EXTENDED_SOURCE is defined. Apparently, this is fixed in 10.3, which + # identifies itself as Darwin/7.* + # On Mac OS X 10.4, defining _POSIX_C_SOURCE or _XOPEN_SOURCE + # disables platform specific features beyond repair. + # On Mac OS X 10.3, defining _POSIX_C_SOURCE or _XOPEN_SOURCE + # has no effect, don't bother defining them + Darwin/@<:@6789@:>@.*) + define_xopen_source=no;; + Darwin/1@<:@0-9@:>@.*) + define_xopen_source=no;; + # On AIX 4 and 5.1, mbstate_t is defined only when _XOPEN_SOURCE == 500 but + # used in wcsnrtombs() and mbsnrtowcs() even if _XOPEN_SOURCE is not defined + # or has another value. By not (re)defining it, the defaults come in place. + AIX/4) + define_xopen_source=no;; + AIX/5) + if test `uname -r` -eq 1; then + define_xopen_source=no + fi + ;; + # On QNX 6.3.2, defining _XOPEN_SOURCE prevents netdb.h from + # defining NI_NUMERICHOST. + QNX/6.3.2) + define_xopen_source=no + ;; + +esac + +if test $define_xopen_source = yes +then + AC_DEFINE(_XOPEN_SOURCE, 600, + Define to the level of X/Open that your system supports) + + # On Tru64 Unix 4.0F, defining _XOPEN_SOURCE also requires + # definition of _XOPEN_SOURCE_EXTENDED and _POSIX_C_SOURCE, or else + # several APIs are not declared. Since this is also needed in some + # cases for HP-UX, we define it globally. + AC_DEFINE(_XOPEN_SOURCE_EXTENDED, 1, + Define to activate Unix95-and-earlier features) + + AC_DEFINE(_POSIX_C_SOURCE, 200112L, Define to activate features from IEEE Stds 1003.1-2001) + +fi + +# +# SGI compilers allow the specification of the both the ABI and the +# ISA on the command line. Depending on the values of these switches, +# different and often incompatable code will be generated. +# +# The SGI_ABI variable can be used to modify the CC and LDFLAGS and +# thus supply support for various ABI/ISA combinations. The MACHDEP +# variable is also adjusted. +# +AC_SUBST(SGI_ABI) +if test ! -z "$SGI_ABI" +then + CC="cc $SGI_ABI" + LDFLAGS="$SGI_ABI $LDFLAGS" + MACHDEP=`echo "${MACHDEP}${SGI_ABI}" | sed 's/ *//g'` +fi +AC_MSG_RESULT($MACHDEP) + +# And add extra plat-mac for darwin +AC_SUBST(EXTRAPLATDIR) +AC_SUBST(EXTRAMACHDEPPATH) +AC_MSG_CHECKING(EXTRAPLATDIR) +if test -z "$EXTRAPLATDIR" +then + case $MACHDEP in + darwin) + EXTRAPLATDIR="\$(PLATMACDIRS)" + EXTRAMACHDEPPATH="\$(PLATMACPATH)" + ;; + *) + EXTRAPLATDIR="" + EXTRAMACHDEPPATH="" + ;; + esac +fi +AC_MSG_RESULT($EXTRAPLATDIR) + +# Record the configure-time value of MACOSX_DEPLOYMENT_TARGET, +# it may influence the way we can build extensions, so distutils +# needs to check it +AC_SUBST(CONFIGURE_MACOSX_DEPLOYMENT_TARGET) +AC_SUBST(EXPORT_MACOSX_DEPLOYMENT_TARGET) +CONFIGURE_MACOSX_DEPLOYMENT_TARGET= +EXPORT_MACOSX_DEPLOYMENT_TARGET='#' + +AC_MSG_CHECKING(machine type as reported by uname -m) +ac_sys_machine=`uname -m` +AC_MSG_RESULT($ac_sys_machine) + +# checks for alternative programs + +# compiler flags are generated in two sets, BASECFLAGS and OPT. OPT is just +# for debug/optimization stuff. BASECFLAGS is for flags that are required +# just to get things to compile and link. Users are free to override OPT +# when running configure or make. The build should not break if they do. +# BASECFLAGS should generally not be messed with, however. + +# XXX shouldn't some/most/all of this code be merged with the stuff later +# on that fiddles with OPT and BASECFLAGS? +AC_MSG_CHECKING(for --without-gcc) +AC_ARG_WITH(gcc, + AS_HELP_STRING([--without-gcc], [never use gcc]), +[ + case $withval in + no) CC=${CC:-cc} + without_gcc=yes;; + yes) CC=gcc + without_gcc=no;; + *) CC=$withval + without_gcc=$withval;; + esac], [ + case $ac_sys_system in + AIX*) CC=${CC:-xlc_r} + without_gcc=;; + BeOS*) + case $BE_HOST_CPU in + ppc) + CC=mwcc + without_gcc=yes + BASECFLAGS="$BASECFLAGS -export pragma" + OPT="$OPT -O" + LDFLAGS="$LDFLAGS -nodup" + ;; + x86) + CC=gcc + without_gcc=no + OPT="$OPT -O" + ;; + *) + AC_MSG_ERROR([Unknown BeOS platform "$BE_HOST_CPU"]) + ;; + esac + AR="\$(srcdir)/Modules/ar_beos" + RANLIB=: + ;; + *) without_gcc=no;; + esac]) +AC_MSG_RESULT($without_gcc) + +# If the user switches compilers, we can't believe the cache +if test ! -z "$ac_cv_prog_CC" -a ! -z "$CC" -a "$CC" != "$ac_cv_prog_CC" +then + AC_MSG_ERROR([cached CC is different -- throw away $cache_file +(it is also a good idea to do 'make clean' before compiling)]) +fi + +# If the user set CFLAGS, use this instead of the automatically +# determined setting +preset_cflags="$CFLAGS" +AC_PROG_CC +if test ! -z "$preset_cflags" +then + CFLAGS=$preset_cflags +fi + +AC_SUBST(CXX) +AC_SUBST(MAINCC) +AC_MSG_CHECKING(for --with-cxx-main=) +AC_ARG_WITH(cxx_main, + AS_HELP_STRING([--with-cxx-main=], + [compile main() and link python executable with C++ compiler]), +[ + + case $withval in + no) with_cxx_main=no + MAINCC='$(CC)';; + yes) with_cxx_main=yes + MAINCC='$(CXX)';; + *) with_cxx_main=yes + MAINCC=$withval + if test -z "$CXX" + then + CXX=$withval + fi;; + esac], [ + with_cxx_main=no + MAINCC='$(CC)' +]) +AC_MSG_RESULT($with_cxx_main) + +preset_cxx="$CXX" +if test -z "$CXX" +then + case "$CC" in + gcc) AC_PATH_PROG(CXX, [g++], [g++], [notfound]) ;; + cc) AC_PATH_PROG(CXX, [c++], [c++], [notfound]) ;; + esac + if test "$CXX" = "notfound" + then + CXX="" + fi +fi +if test -z "$CXX" +then + AC_CHECK_PROGS(CXX, $CCC c++ g++ gcc CC cxx cc++ cl, notfound) + if test "$CXX" = "notfound" + then + CXX="" + fi +fi +if test "$preset_cxx" != "$CXX" +then + AC_MSG_WARN([ + + By default, distutils will build C++ extension modules with "$CXX". + If this is not intended, then set CXX on the configure command line. + ]) +fi + + +# checks for UNIX variants that set C preprocessor variables +AC_USE_SYSTEM_EXTENSIONS + +# Check for unsupported systems +case $ac_sys_system/$ac_sys_release in +atheos*|Linux*/1*) + echo This system \($ac_sys_system/$ac_sys_release\) is no longer supported. + echo See README for details. + exit 1;; +esac + +AC_EXEEXT +AC_MSG_CHECKING(for --with-suffix) +AC_ARG_WITH(suffix, + AS_HELP_STRING([--with-suffix=.exe], [set executable suffix]), +[ + case $withval in + no) EXEEXT=;; + yes) EXEEXT=.exe;; + *) EXEEXT=$withval;; + esac]) +AC_MSG_RESULT($EXEEXT) + +# Test whether we're running on a non-case-sensitive system, in which +# case we give a warning if no ext is given +AC_SUBST(BUILDEXEEXT) +AC_MSG_CHECKING(for case-insensitive build directory) +if test ! -d CaseSensitiveTestDir; then +mkdir CaseSensitiveTestDir +fi + +if test -d casesensitivetestdir +then + AC_MSG_RESULT(yes) + BUILDEXEEXT=.exe +else + AC_MSG_RESULT(no) + BUILDEXEEXT=$EXEEXT +fi +rmdir CaseSensitiveTestDir + +case $MACHDEP in +bsdos*) + case $CC in + gcc) CC="$CC -D_HAVE_BSDI";; + esac;; +esac + +case $ac_sys_system in +hp*|HP*) + case $CC in + cc|*/cc) CC="$CC -Ae";; + esac;; +SunOS*) + # Some functions have a prototype only with that define, e.g. confstr + AC_DEFINE(__EXTENSIONS__, 1, [Defined on Solaris to see additional function prototypes.]) + ;; +esac + + +AC_SUBST(LIBRARY) +AC_MSG_CHECKING(LIBRARY) +if test -z "$LIBRARY" +then + LIBRARY='libpython$(VERSION).a' +fi +AC_MSG_RESULT($LIBRARY) + +# LDLIBRARY is the name of the library to link against (as opposed to the +# name of the library into which to insert object files). BLDLIBRARY is also +# the library to link against, usually. On Mac OS X frameworks, BLDLIBRARY +# is blank as the main program is not linked directly against LDLIBRARY. +# LDLIBRARYDIR is the path to LDLIBRARY, which is made in a subdirectory. On +# systems without shared libraries, LDLIBRARY is the same as LIBRARY +# (defined in the Makefiles). On Cygwin LDLIBRARY is the import library, +# DLLLIBRARY is the shared (i.e., DLL) library. +# +# RUNSHARED is used to run shared python without installed libraries +# +# INSTSONAME is the name of the shared library that will be use to install +# on the system - some systems like version suffix, others don't +AC_SUBST(LDLIBRARY) +AC_SUBST(DLLLIBRARY) +AC_SUBST(BLDLIBRARY) +AC_SUBST(LDLIBRARYDIR) +AC_SUBST(INSTSONAME) +AC_SUBST(RUNSHARED) +LDLIBRARY="$LIBRARY" +BLDLIBRARY='$(LDLIBRARY)' +INSTSONAME='$(LDLIBRARY)' +DLLLIBRARY='' +LDLIBRARYDIR='' +RUNSHARED='' + +# LINKCC is the command that links the python executable -- default is $(CC). +# If CXX is set, and if it is needed to link a main function that was +# compiled with CXX, LINKCC is CXX instead. Always using CXX is undesirable: +# python might then depend on the C++ runtime +# This is altered for AIX in order to build the export list before +# linking. +AC_SUBST(LINKCC) +AC_MSG_CHECKING(LINKCC) +if test -z "$LINKCC" +then + LINKCC='$(PURIFY) $(MAINCC)' + case $ac_sys_system in + AIX*) + exp_extra="\"\"" + if test $ac_sys_release -ge 5 -o \ + $ac_sys_release -eq 4 -a `uname -r` -ge 2 ; then + exp_extra="." + fi + LINKCC="\$(srcdir)/Modules/makexp_aix Modules/python.exp $exp_extra \$(LIBRARY); $LINKCC";; + QNX*) + # qcc must be used because the other compilers do not + # support -N. + LINKCC=qcc;; + esac +fi +AC_MSG_RESULT($LINKCC) + +# GNULD is set to "yes" if the GNU linker is used. If this goes wrong +# make sure we default having it set to "no": this is used by +# distutils.unixccompiler to know if it should add --enable-new-dtags +# to linker command lines, and failing to detect GNU ld simply results +# in the same bahaviour as before. +AC_SUBST(GNULD) +AC_MSG_CHECKING(for GNU ld) +ac_prog=ld +if test "$GCC" = yes; then + ac_prog=`$CC -print-prog-name=ld` +fi +case `"$ac_prog" -V 2>&1 < /dev/null` in + *GNU*) + GNULD=yes;; + *) + GNULD=no;; +esac +AC_MSG_RESULT($GNULD) + +AC_MSG_CHECKING(for --enable-shared) +AC_ARG_ENABLE(shared, + AS_HELP_STRING([--enable-shared], [disable/enable building shared python library])) + +if test -z "$enable_shared" +then + case $ac_sys_system in + CYGWIN* | atheos*) + enable_shared="yes";; + *) + enable_shared="no";; + esac +fi +AC_MSG_RESULT($enable_shared) + +AC_MSG_CHECKING(for --enable-profiling) +AC_ARG_ENABLE(profiling, + AS_HELP_STRING([--enable-profiling], [enable C-level code profiling]), +[ac_save_cc="$CC" + CC="$CC -pg" + AC_RUN_IFELSE([AC_LANG_SOURCE([[int main() { return 0; }]])], + [ac_enable_profiling="yes"], + [ac_enable_profiling="no"], + [ac_enable_profiling="no"]) + CC="$ac_save_cc"]) +AC_MSG_RESULT($ac_enable_profiling) + +case "$ac_enable_profiling" in + "yes") + BASECFLAGS="-pg $BASECFLAGS" + LDFLAGS="-pg $LDFLAGS" + ;; +esac + +AC_MSG_CHECKING(LDLIBRARY) + +# MacOSX framework builds need more magic. LDLIBRARY is the dynamic +# library that we build, but we do not want to link against it (we +# will find it with a -framework option). For this reason there is an +# extra variable BLDLIBRARY against which Python and the extension +# modules are linked, BLDLIBRARY. This is normally the same as +# LDLIBRARY, but empty for MacOSX framework builds. +if test "$enable_framework" +then + LDLIBRARY='$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)' + RUNSHARED=DYLD_FRAMEWORK_PATH="`pwd`:$DYLD_FRAMEWORK_PATH" + BLDLIBRARY='' +else + BLDLIBRARY='$(LDLIBRARY)' +fi + +# Other platforms follow +if test $enable_shared = "yes"; then + AC_DEFINE(Py_ENABLE_SHARED, 1, [Defined if Python is built as a shared library.]) + case $ac_sys_system in + BeOS*) + LDLIBRARY='libpython$(VERSION).so' + ;; + CYGWIN*) + LDLIBRARY='libpython$(VERSION).dll.a' + DLLLIBRARY='libpython$(VERSION).dll' + ;; + SunOS*) + LDLIBRARY='libpython$(VERSION).so' + BLDLIBRARY='-Wl,-R,$(LIBDIR) -L. -lpython$(VERSION)' + RUNSHARED=LD_LIBRARY_PATH=`pwd`:${LD_LIBRARY_PATH} + INSTSONAME="$LDLIBRARY".$SOVERSION + ;; + Linux*|GNU*|NetBSD*|FreeBSD*|DragonFly*|OpenBSD*) + LDLIBRARY='libpython$(VERSION).so' + BLDLIBRARY='-L. -lpython$(VERSION)' + RUNSHARED=LD_LIBRARY_PATH=`pwd`:${LD_LIBRARY_PATH} + case $ac_sys_system in + FreeBSD*) + SOVERSION=`echo $SOVERSION|cut -d "." -f 1` + ;; + esac + INSTSONAME="$LDLIBRARY".$SOVERSION + ;; + hp*|HP*) + case `uname -m` in + ia64) + LDLIBRARY='libpython$(VERSION).so' + ;; + *) + LDLIBRARY='libpython$(VERSION).sl' + ;; + esac + BLDLIBRARY='-Wl,+b,$(LIBDIR) -L. -lpython$(VERSION)' + RUNSHARED=SHLIB_PATH=`pwd`:${SHLIB_PATH} + ;; + OSF*) + LDLIBRARY='libpython$(VERSION).so' + BLDLIBRARY='-rpath $(LIBDIR) -L. -lpython$(VERSION)' + RUNSHARED=LD_LIBRARY_PATH=`pwd`:${LD_LIBRARY_PATH} + ;; + atheos*) + LDLIBRARY='libpython$(VERSION).so' + BLDLIBRARY='-L. -lpython$(VERSION)' + RUNSHARED=DLL_PATH=`pwd`:${DLL_PATH:-/atheos/sys/libs:/atheos/autolnk/lib} + ;; + Darwin*) + LDLIBRARY='libpython$(VERSION).dylib' + BLDLIBRARY='-L. -lpython$(VERSION)' + RUNSHARED='DYLD_LIBRARY_PATH=`pwd`:${DYLD_LIBRARY_PATH}' + ;; + AIX*) + LDLIBRARY='libpython$(VERSION).so' + RUNSHARED=LIBPATH=`pwd`:${LIBPATH} + ;; + + esac +else # shared is disabled + case $ac_sys_system in + CYGWIN*) + BLDLIBRARY='$(LIBRARY)' + LDLIBRARY='libpython$(VERSION).dll.a' + ;; + esac +fi + +AC_MSG_RESULT($LDLIBRARY) + +AC_PROG_RANLIB +AC_SUBST(AR) +AC_CHECK_PROGS(AR, ar aal, ar) + +# tweak ARFLAGS only if the user didn't set it on the command line +AC_SUBST(ARFLAGS) +if test -z "$ARFLAGS" +then + ARFLAGS="rc" +fi + +AC_SUBST(SVNVERSION) +AC_CHECK_PROG(SVNVERSION, svnversion, found, not-found) +if test $SVNVERSION = found +then + SVNVERSION="svnversion \$(srcdir)" +else + SVNVERSION="echo Unversioned directory" +fi + +AC_SUBST(HGVERSION) +AC_SUBST(HGTAG) +AC_SUBST(HGBRANCH) +AC_CHECK_PROG(HAS_HG, hg, found, not-found) +if test $HAS_HG = found +then + HGVERSION="hg id -i \$(srcdir)" + HGTAG="hg id -t \$(srcdir)" + HGBRANCH="hg id -b \$(srcdir)" +else + HGVERSION="" + HGTAG="" + HGBRANCH="" +fi + +case $MACHDEP in +bsdos*|hp*|HP*) + # install -d does not work on BSDI or HP-UX + if test -z "$INSTALL" + then + INSTALL="${srcdir}/install-sh -c" + fi +esac +AC_PROG_INSTALL + +# Not every filesystem supports hard links +AC_SUBST(LN) +if test -z "$LN" ; then + case $ac_sys_system in + BeOS*) LN="ln -s";; + CYGWIN*) LN="ln -s";; + atheos*) LN="ln -s";; + *) LN=ln;; + esac +fi + +# Check for --with-pydebug +AC_MSG_CHECKING(for --with-pydebug) +AC_ARG_WITH(pydebug, + AS_HELP_STRING([--with-pydebug], [build with Py_DEBUG defined]), +[ +if test "$withval" != no +then + AC_DEFINE(Py_DEBUG, 1, + [Define if you want to build an interpreter with many run-time checks.]) + AC_MSG_RESULT(yes); + Py_DEBUG='true' +else AC_MSG_RESULT(no); Py_DEBUG='false' +fi], +[AC_MSG_RESULT(no)]) + +# XXX Shouldn't the code above that fiddles with BASECFLAGS and OPT be +# merged with this chunk of code? + +# Optimizer/debugger flags +# ------------------------ +# (The following bit of code is complicated enough - please keep things +# indented properly. Just pretend you're editing Python code. ;-) + +# There are two parallel sets of case statements below, one that checks to +# see if OPT was set and one that does BASECFLAGS setting based upon +# compiler and platform. BASECFLAGS tweaks need to be made even if the +# user set OPT. + +# tweak OPT based on compiler and platform, only if the user didn't set +# it on the command line +AC_SUBST(OPT) +if test "${OPT-unset}" = "unset" +then + case $GCC in + yes) + if test "$CC" != 'g++' ; then + STRICT_PROTO="-Wstrict-prototypes" + fi + # For gcc 4.x we need to use -fwrapv so lets check if its supported + if "$CC" -v --help 2>/dev/null |grep -- -fwrapv > /dev/null; then + WRAP="-fwrapv" + fi + + # Clang also needs -fwrapv + case $CC in + *clang*) WRAP="-fwrapv" + ;; + esac + + case $ac_cv_prog_cc_g in + yes) + if test "$Py_DEBUG" = 'true' ; then + # Optimization messes up debuggers, so turn it off for + # debug builds. + OPT="-g -O0 -Wall $STRICT_PROTO" + else + OPT="-g $WRAP -O3 -Wall $STRICT_PROTO" + fi + ;; + *) + OPT="-O3 -Wall $STRICT_PROTO" + ;; + esac + case $ac_sys_system in + SCO_SV*) OPT="$OPT -m486 -DSCO5" + ;; + esac + ;; + + *) + OPT="-O" + ;; + esac +fi + +AC_SUBST(BASECFLAGS) + +# The -arch flags for universal builds on OSX +UNIVERSAL_ARCH_FLAGS= +AC_SUBST(UNIVERSAL_ARCH_FLAGS) + +# tweak BASECFLAGS based on compiler and platform +case $GCC in +yes) + # Python violates C99 rules, by casting between incompatible + # pointer types. GCC may generate bad code as a result of that, + # so use -fno-strict-aliasing if supported. + AC_MSG_CHECKING(whether $CC accepts -fno-strict-aliasing) + ac_save_cc="$CC" + CC="$CC -fno-strict-aliasing" + AC_CACHE_VAL(ac_cv_no_strict_aliasing_ok, + AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM([[]], [[]])], + [ac_cv_no_strict_aliasing_ok=yes], + [ac_cv_no_strict_aliasing_ok=no])) + CC="$ac_save_cc" + AC_MSG_RESULT($ac_cv_no_strict_aliasing_ok) + if test $ac_cv_no_strict_aliasing_ok = yes + then + BASECFLAGS="$BASECFLAGS -fno-strict-aliasing" + fi + + # if using gcc on alpha, use -mieee to get (near) full IEEE 754 + # support. Without this, treatment of subnormals doesn't follow + # the standard. + case $ac_sys_machine in + alpha*) + BASECFLAGS="$BASECFLAGS -mieee" + ;; + esac + + case $ac_sys_system in + SCO_SV*) + BASECFLAGS="$BASECFLAGS -m486 -DSCO5" + ;; + # is there any other compiler on Darwin besides gcc? + Darwin*) + # -Wno-long-double, -no-cpp-precomp, and -mno-fused-madd + # used to be here, but non-Apple gcc doesn't accept them. + if test "${CC}" = gcc + then + AC_MSG_CHECKING(which compiler should be used) + case "${UNIVERSALSDK}" in + */MacOSX10.4u.sdk) + # Build using 10.4 SDK, force usage of gcc when the + # compiler is gcc, otherwise the user will get very + # confusing error messages when building on OSX 10.6 + CC=gcc-4.0 + CPP=cpp-4.0 + ;; + esac + AC_MSG_RESULT($CC) + fi + + # Calculate the right deployment target for this build. + # + cur_target=`sw_vers -productVersion | sed 's/\(10\.[[0-9]]*\).*/\1/'` + if test ${cur_target} '>' 10.2; then + cur_target=10.3 + if test ${enable_universalsdk}; then + if test "${UNIVERSAL_ARCHS}" = "all"; then + # Ensure that the default platform for a + # 4-way universal build is OSX 10.5, + # that's the first OS release where + # 4-way builds make sense. + cur_target='10.5' + + elif test "${UNIVERSAL_ARCHS}" = "3-way"; then + cur_target='10.5' + + elif test "${UNIVERSAL_ARCHS}" = "intel"; then + cur_target='10.5' + + elif test "${UNIVERSAL_ARCHS}" = "64-bit"; then + cur_target='10.5' + fi + else + if test `/usr/bin/arch` = "i386"; then + # On Intel macs default to a deployment + # target of 10.4, that's the first OSX + # release with Intel support. + cur_target="10.4" + fi + fi + fi + CONFIGURE_MACOSX_DEPLOYMENT_TARGET=${MACOSX_DEPLOYMENT_TARGET-${cur_target}} + + # Make sure that MACOSX_DEPLOYMENT_TARGET is set in the + # environment with a value that is the same as what we'll use + # in the Makefile to ensure that we'll get the same compiler + # environment during configure and build time. + MACOSX_DEPLOYMENT_TARGET="$CONFIGURE_MACOSX_DEPLOYMENT_TARGET" + export MACOSX_DEPLOYMENT_TARGET + EXPORT_MACOSX_DEPLOYMENT_TARGET='' + + if test "${enable_universalsdk}"; then + UNIVERSAL_ARCH_FLAGS="" + if test "$UNIVERSAL_ARCHS" = "32-bit" ; then + UNIVERSAL_ARCH_FLAGS="-arch ppc -arch i386" + ARCH_RUN_32BIT="" + LIPO_32BIT_FLAGS="" + + elif test "$UNIVERSAL_ARCHS" = "64-bit" ; then + UNIVERSAL_ARCH_FLAGS="-arch ppc64 -arch x86_64" + LIPO_32BIT_FLAGS="" + ARCH_RUN_32BIT="true" + + elif test "$UNIVERSAL_ARCHS" = "all" ; then + UNIVERSAL_ARCH_FLAGS="-arch i386 -arch ppc -arch ppc64 -arch x86_64" + LIPO_32BIT_FLAGS="-extract ppc7400 -extract i386" + ARCH_RUN_32BIT="/usr/bin/arch -i386 -ppc" + + elif test "$UNIVERSAL_ARCHS" = "intel" ; then + UNIVERSAL_ARCH_FLAGS="-arch i386 -arch x86_64" + LIPO_32BIT_FLAGS="-extract i386" + ARCH_RUN_32BIT="/usr/bin/arch -i386" + + elif test "$UNIVERSAL_ARCHS" = "3-way" ; then + UNIVERSAL_ARCH_FLAGS="-arch i386 -arch ppc -arch x86_64" + LIPO_32BIT_FLAGS="-extract ppc7400 -extract i386" + ARCH_RUN_32BIT="/usr/bin/arch -i386 -ppc" + + else + AC_MSG_ERROR([proper usage is --with-universal-arch=32-bit|64-bit|all|intel|3-way]) + + fi + + + CFLAGS="${UNIVERSAL_ARCH_FLAGS} ${CFLAGS}" + if test "${UNIVERSALSDK}" != "/" + then + CPPFLAGS="-isysroot ${UNIVERSALSDK} ${CPPFLAGS}" + LDFLAGS="-isysroot ${UNIVERSALSDK} ${LDFLAGS}" + CFLAGS="-isysroot ${UNIVERSALSDK} ${CFLAGS}" + fi + + fi + + + ;; + OSF*) + BASECFLAGS="$BASECFLAGS -mieee" + ;; + esac + ;; + +*) + case $ac_sys_system in + OpenUNIX*|UnixWare*) + BASECFLAGS="$BASECFLAGS -K pentium,host,inline,loop_unroll,alloca " + ;; + OSF*) + BASECFLAGS="$BASECFLAGS -ieee -std" + ;; + SCO_SV*) + BASECFLAGS="$BASECFLAGS -belf -Ki486 -DSCO5" + ;; + esac + ;; +esac + +if test "$Py_DEBUG" = 'true'; then + : +else + OPT="-DNDEBUG $OPT" +fi + +if test "$ac_arch_flags" +then + BASECFLAGS="$BASECFLAGS $ac_arch_flags" +fi + +# disable check for icc since it seems to pass, but generates a warning +if test "$CC" = icc +then + ac_cv_opt_olimit_ok=no +fi + +AC_MSG_CHECKING(whether $CC accepts -OPT:Olimit=0) +AC_CACHE_VAL(ac_cv_opt_olimit_ok, +[ac_save_cc="$CC" +CC="$CC -OPT:Olimit=0" +AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM([[]], [[]])], + [ac_cv_opt_olimit_ok=yes], + [ac_cv_opt_olimit_ok=no] + ) +CC="$ac_save_cc"]) +AC_MSG_RESULT($ac_cv_opt_olimit_ok) +if test $ac_cv_opt_olimit_ok = yes; then + case $ac_sys_system in + # XXX is this branch needed? On MacOSX 10.2.2 the result of the + # olimit_ok test is "no". Is it "yes" in some other Darwin-esque + # environment? + Darwin*) + ;; + *) + BASECFLAGS="$BASECFLAGS -OPT:Olimit=0" + ;; + esac +else + AC_MSG_CHECKING(whether $CC accepts -Olimit 1500) + AC_CACHE_VAL(ac_cv_olimit_ok, + [ac_save_cc="$CC" + CC="$CC -Olimit 1500" + AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM([[]], [[]])], + [ac_cv_olimit_ok=yes], + [ac_cv_olimit_ok=no] + ) + CC="$ac_save_cc"]) + AC_MSG_RESULT($ac_cv_olimit_ok) + if test $ac_cv_olimit_ok = yes; then + BASECFLAGS="$BASECFLAGS -Olimit 1500" + fi +fi + +# Check whether GCC supports PyArg_ParseTuple format +if test "$GCC" = "yes" +then + AC_MSG_CHECKING(whether gcc supports ParseTuple __format__) + save_CFLAGS=$CFLAGS + CFLAGS="$CFLAGS -Werror" + AC_COMPILE_IFELSE([ + AC_LANG_PROGRAM([[void f(char*,...)__attribute((format(PyArg_ParseTuple, 1, 2)));]], [[]]) + ],[ + AC_DEFINE(HAVE_ATTRIBUTE_FORMAT_PARSETUPLE, 1, + [Define if GCC supports __attribute__((format(PyArg_ParseTuple, 2, 3)))]) + AC_MSG_RESULT(yes) + ],[ + AC_MSG_RESULT(no) + ]) + CFLAGS=$save_CFLAGS +fi + +# On some compilers, pthreads are available without further options +# (e.g. MacOS X). On some of these systems, the compiler will not +# complain if unaccepted options are passed (e.g. gcc on Mac OS X). +# So we have to see first whether pthreads are available without +# options before we can check whether -Kpthread improves anything. +AC_MSG_CHECKING(whether pthreads are available without options) +AC_CACHE_VAL(ac_cv_pthread_is_default, +[AC_RUN_IFELSE([AC_LANG_SOURCE([[ +#include + +void* routine(void* p){return NULL;} + +int main(){ + pthread_t p; + if(pthread_create(&p,NULL,routine,NULL)!=0) + return 1; + (void)pthread_detach(p); + return 0; +} +]])],[ + ac_cv_pthread_is_default=yes + ac_cv_kthread=no + ac_cv_pthread=no +],[ac_cv_pthread_is_default=no],[ac_cv_pthread_is_default=no]) +]) +AC_MSG_RESULT($ac_cv_pthread_is_default) + + +if test $ac_cv_pthread_is_default = yes +then + ac_cv_kpthread=no +else +# -Kpthread, if available, provides the right #defines +# and linker options to make pthread_create available +# Some compilers won't report that they do not support -Kpthread, +# so we need to run a program to see whether it really made the +# function available. +AC_MSG_CHECKING(whether $CC accepts -Kpthread) +AC_CACHE_VAL(ac_cv_kpthread, +[ac_save_cc="$CC" +CC="$CC -Kpthread" +AC_RUN_IFELSE([AC_LANG_SOURCE([[ +#include + +void* routine(void* p){return NULL;} + +int main(){ + pthread_t p; + if(pthread_create(&p,NULL,routine,NULL)!=0) + return 1; + (void)pthread_detach(p); + return 0; +} +]])],[ac_cv_kpthread=yes],[ac_cv_kpthread=no],[ac_cv_kpthread=no]) +CC="$ac_save_cc"]) +AC_MSG_RESULT($ac_cv_kpthread) +fi + +if test $ac_cv_kpthread = no -a $ac_cv_pthread_is_default = no +then +# -Kthread, if available, provides the right #defines +# and linker options to make pthread_create available +# Some compilers won't report that they do not support -Kthread, +# so we need to run a program to see whether it really made the +# function available. +AC_MSG_CHECKING(whether $CC accepts -Kthread) +AC_CACHE_VAL(ac_cv_kthread, +[ac_save_cc="$CC" +CC="$CC -Kthread" +AC_RUN_IFELSE([AC_LANG_SOURCE([[ +#include + +void* routine(void* p){return NULL;} + +int main(){ + pthread_t p; + if(pthread_create(&p,NULL,routine,NULL)!=0) + return 1; + (void)pthread_detach(p); + return 0; +} +]])],[ac_cv_kthread=yes],[ac_cv_kthread=no],[ac_cv_kthread=no]) +CC="$ac_save_cc"]) +AC_MSG_RESULT($ac_cv_kthread) +fi + +if test $ac_cv_kthread = no -a $ac_cv_pthread_is_default = no +then +# -pthread, if available, provides the right #defines +# and linker options to make pthread_create available +# Some compilers won't report that they do not support -pthread, +# so we need to run a program to see whether it really made the +# function available. +AC_MSG_CHECKING(whether $CC accepts -pthread) +AC_CACHE_VAL(ac_cv_thread, +[ac_save_cc="$CC" +CC="$CC -pthread" +AC_RUN_IFELSE([AC_LANG_SOURCE([[ +#include + +void* routine(void* p){return NULL;} + +int main(){ + pthread_t p; + if(pthread_create(&p,NULL,routine,NULL)!=0) + return 1; + (void)pthread_detach(p); + return 0; +} +]])],[ac_cv_pthread=yes],[ac_cv_pthread=no],[ac_cv_pthread=no]) +CC="$ac_save_cc"]) +AC_MSG_RESULT($ac_cv_pthread) +fi + +# If we have set a CC compiler flag for thread support then +# check if it works for CXX, too. +ac_cv_cxx_thread=no +if test ! -z "$CXX" +then +AC_MSG_CHECKING(whether $CXX also accepts flags for thread support) +ac_save_cxx="$CXX" + +if test "$ac_cv_kpthread" = "yes" +then + CXX="$CXX -Kpthread" + ac_cv_cxx_thread=yes +elif test "$ac_cv_kthread" = "yes" +then + CXX="$CXX -Kthread" + ac_cv_cxx_thread=yes +elif test "$ac_cv_pthread" = "yes" +then + CXX="$CXX -pthread" + ac_cv_cxx_thread=yes +fi + +if test $ac_cv_cxx_thread = yes +then + echo 'void foo();int main(){foo();}void foo(){}' > conftest.$ac_ext + $CXX -c conftest.$ac_ext 2>&5 + if $CXX -o conftest$ac_exeext conftest.$ac_objext 2>&5 \ + && test -s conftest$ac_exeext && ./conftest$ac_exeext + then + ac_cv_cxx_thread=yes + else + ac_cv_cxx_thread=no + fi + rm -fr conftest* +fi +AC_MSG_RESULT($ac_cv_cxx_thread) +fi +CXX="$ac_save_cxx" + +dnl # check for ANSI or K&R ("traditional") preprocessor +dnl AC_MSG_CHECKING(for C preprocessor type) +dnl AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ +dnl #define spam(name, doc) {#name, &name, #name "() -- " doc} +dnl int foo; +dnl struct {char *name; int *addr; char *doc;} desc = spam(foo, "something"); +dnl ]], [[;]])],[cpp_type=ansi],[AC_DEFINE(HAVE_OLD_CPP) cpp_type=traditional]) +dnl AC_MSG_RESULT($cpp_type) + +# checks for header files +AC_HEADER_STDC +AC_CHECK_HEADERS(asm/types.h conio.h curses.h direct.h dlfcn.h errno.h \ +fcntl.h grp.h \ +ieeefp.h io.h langinfo.h libintl.h ncurses.h poll.h process.h pthread.h \ +shadow.h signal.h stdint.h stropts.h termios.h thread.h \ +unistd.h utime.h \ +sys/audioio.h sys/bsdtty.h sys/epoll.h sys/event.h sys/file.h sys/loadavg.h \ +sys/lock.h sys/mkdev.h sys/modem.h \ +sys/param.h sys/poll.h sys/select.h sys/socket.h sys/statvfs.h sys/stat.h \ +sys/termio.h sys/time.h \ +sys/times.h sys/types.h sys/un.h sys/utsname.h sys/wait.h pty.h libutil.h \ +sys/resource.h netpacket/packet.h sysexits.h bluetooth.h \ +bluetooth/bluetooth.h linux/tipc.h spawn.h util.h) +AC_HEADER_DIRENT +AC_HEADER_MAJOR + +# On Solaris, term.h requires curses.h +AC_CHECK_HEADERS(term.h,,,[ +#ifdef HAVE_CURSES_H +#include +#endif +]) + +# On Linux, netlink.h requires asm/types.h +AC_CHECK_HEADERS(linux/netlink.h,,,[ +#ifdef HAVE_ASM_TYPES_H +#include +#endif +#ifdef HAVE_SYS_SOCKET_H +#include +#endif +]) + +# checks for typedefs +was_it_defined=no +AC_MSG_CHECKING(for clock_t in time.h) +AC_EGREP_HEADER(clock_t, time.h, was_it_defined=yes, [ + AC_DEFINE(clock_t, long, [Define to 'long' if doesn't define.]) +]) +AC_MSG_RESULT($was_it_defined) + +# Check whether using makedev requires defining _OSF_SOURCE +AC_MSG_CHECKING(for makedev) +AC_LINK_IFELSE([AC_LANG_PROGRAM([[ +#if defined(MAJOR_IN_MKDEV) +#include +#elif defined(MAJOR_IN_SYSMACROS) +#include +#else +#include +#endif ]], [[ makedev(0, 0) ]])], +[ac_cv_has_makedev=yes], +[ac_cv_has_makedev=no]) +if test "$ac_cv_has_makedev" = "no"; then + # we didn't link, try if _OSF_SOURCE will allow us to link + AC_LINK_IFELSE([AC_LANG_PROGRAM([[ +#define _OSF_SOURCE 1 +#include + ]], [[ makedev(0, 0) ]])], +[ac_cv_has_makedev=yes], +[ac_cv_has_makedev=no]) + if test "$ac_cv_has_makedev" = "yes"; then + AC_DEFINE(_OSF_SOURCE, 1, [Define _OSF_SOURCE to get the makedev macro.]) + fi +fi +AC_MSG_RESULT($ac_cv_has_makedev) +if test "$ac_cv_has_makedev" = "yes"; then + AC_DEFINE(HAVE_MAKEDEV, 1, [Define this if you have the makedev macro.]) +fi + +# Enabling LFS on Solaris (2.6 to 9) with gcc 2.95 triggers a bug in +# the system headers: If _XOPEN_SOURCE and _LARGEFILE_SOURCE are +# defined, but the compiler does not support pragma redefine_extname, +# and _LARGEFILE64_SOURCE is not defined, the headers refer to 64-bit +# structures (such as rlimit64) without declaring them. As a +# work-around, disable LFS on such configurations + +use_lfs=yes +AC_MSG_CHECKING(Solaris LFS bug) +AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ +#define _LARGEFILE_SOURCE 1 +#define _FILE_OFFSET_BITS 64 +#include +]], [[struct rlimit foo;]])],[sol_lfs_bug=no],[sol_lfs_bug=yes]) +AC_MSG_RESULT($sol_lfs_bug) +if test "$sol_lfs_bug" = "yes"; then + use_lfs=no +fi + +if test "$use_lfs" = "yes"; then +# Two defines needed to enable largefile support on various platforms +# These may affect some typedefs +case $ac_sys_system/$ac_sys_release in +AIX*) + AC_DEFINE(_LARGE_FILES, 1, + [This must be defined on AIX systems to enable large file support.]) + ;; +esac +AC_DEFINE(_LARGEFILE_SOURCE, 1, +[This must be defined on some systems to enable large file support.]) +AC_DEFINE(_FILE_OFFSET_BITS, 64, +[This must be set to 64 on some systems to enable large file support.]) +fi + +# Add some code to confdefs.h so that the test for off_t works on SCO +cat >> confdefs.h <<\EOF +#if defined(SCO_DS) +#undef _OFF_T +#endif +EOF + +# Type availability checks +AC_TYPE_MODE_T +AC_TYPE_OFF_T +AC_TYPE_PID_T +AC_DEFINE_UNQUOTED([RETSIGTYPE],[void],[assume C89 semantics that RETSIGTYPE is always void]) +AC_TYPE_SIZE_T +AC_TYPE_UID_T +AC_TYPE_UINT32_T +AC_TYPE_UINT64_T +AC_TYPE_INT32_T +AC_TYPE_INT64_T +AC_CHECK_TYPE(ssize_t, + AC_DEFINE(HAVE_SSIZE_T, 1, [Define if your compiler provides ssize_t]),,) + +# Sizes of various common basic types +# ANSI C requires sizeof(char) == 1, so no need to check it +AC_CHECK_SIZEOF(int, 4) +AC_CHECK_SIZEOF(long, 4) +AC_CHECK_SIZEOF(void *, 4) +AC_CHECK_SIZEOF(short, 2) +AC_CHECK_SIZEOF(float, 4) +AC_CHECK_SIZEOF(double, 8) +AC_CHECK_SIZEOF(fpos_t, 4) +AC_CHECK_SIZEOF(size_t, 4) +AC_CHECK_SIZEOF(pid_t, 4) + +AC_MSG_CHECKING(for long long support) +have_long_long=no +AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[long long x; x = (long long)0;]])],[ + AC_DEFINE(HAVE_LONG_LONG, 1, [Define this if you have the type long long.]) + have_long_long=yes +],[]) +AC_MSG_RESULT($have_long_long) +if test "$have_long_long" = yes ; then +AC_CHECK_SIZEOF(long long, 8) +fi + +AC_MSG_CHECKING(for long double support) +have_long_double=no +AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[long double x; x = (long double)0;]])],[ + AC_DEFINE(HAVE_LONG_DOUBLE, 1, [Define this if you have the type long double.]) + have_long_double=yes +],[]) +AC_MSG_RESULT($have_long_double) +if test "$have_long_double" = yes ; then +AC_CHECK_SIZEOF(long double, 12) +fi + +AC_MSG_CHECKING(for _Bool support) +have_c99_bool=no +AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[_Bool x; x = (_Bool)0;]])],[ + AC_DEFINE(HAVE_C99_BOOL, 1, [Define this if you have the type _Bool.]) + have_c99_bool=yes +],[]) +AC_MSG_RESULT($have_c99_bool) +if test "$have_c99_bool" = yes ; then +AC_CHECK_SIZEOF(_Bool, 1) +fi + +AC_CHECK_TYPES(uintptr_t, + [AC_CHECK_SIZEOF(uintptr_t, 4)], + [], [#ifdef HAVE_STDINT_H + #include + #endif + #ifdef HAVE_INTTYPES_H + #include + #endif]) + +AC_CHECK_SIZEOF(off_t, [], [ +#ifdef HAVE_SYS_TYPES_H +#include +#endif +]) + +AC_MSG_CHECKING(whether to enable large file support) +if test "$have_long_long" = yes +then +if test "$ac_cv_sizeof_off_t" -gt "$ac_cv_sizeof_long" -a \ + "$ac_cv_sizeof_long_long" -ge "$ac_cv_sizeof_off_t"; then + AC_DEFINE(HAVE_LARGEFILE_SUPPORT, 1, + [Defined to enable large file support when an off_t is bigger than a long + and long long is available and at least as big as an off_t. You may need + to add some flags for configuration and compilation to enable this mode. + (For Solaris and Linux, the necessary defines are already defined.)]) + AC_MSG_RESULT(yes) +else + AC_MSG_RESULT(no) +fi +else + AC_MSG_RESULT(no) +fi + +AC_CHECK_SIZEOF(time_t, [], [ +#ifdef HAVE_SYS_TYPES_H +#include +#endif +#ifdef HAVE_TIME_H +#include +#endif +]) + +# if have pthread_t then define SIZEOF_PTHREAD_T +ac_save_cc="$CC" +if test "$ac_cv_kpthread" = "yes" +then CC="$CC -Kpthread" +elif test "$ac_cv_kthread" = "yes" +then CC="$CC -Kthread" +elif test "$ac_cv_pthread" = "yes" +then CC="$CC -pthread" +fi +AC_MSG_CHECKING(for pthread_t) +have_pthread_t=no +AC_COMPILE_IFELSE([ + AC_LANG_PROGRAM([[#include ]], [[pthread_t x; x = *(pthread_t*)0;]]) +],[have_pthread_t=yes],[]) +AC_MSG_RESULT($have_pthread_t) +if test "$have_pthread_t" = yes ; then + AC_CHECK_SIZEOF(pthread_t, [], [ +#ifdef HAVE_PTHREAD_H +#include +#endif + ]) +fi +CC="$ac_save_cc" + +AC_MSG_CHECKING(for --enable-toolbox-glue) +AC_ARG_ENABLE(toolbox-glue, + AS_HELP_STRING([--enable-toolbox-glue], [disable/enable MacOSX glue code for extensions])) + +if test -z "$enable_toolbox_glue" +then + case $ac_sys_system/$ac_sys_release in + Darwin/*) + enable_toolbox_glue="yes";; + *) + enable_toolbox_glue="no";; + esac +fi +case "$enable_toolbox_glue" in +yes) + extra_machdep_objs="Python/mactoolboxglue.o" + extra_undefs="-u _PyMac_Error" + AC_DEFINE(USE_TOOLBOX_OBJECT_GLUE, 1, + [Define if you want to use MacPython modules on MacOSX in unix-Python.]) + ;; +*) + extra_machdep_objs="" + extra_undefs="" + ;; +esac +AC_MSG_RESULT($enable_toolbox_glue) + + +AC_SUBST(OTHER_LIBTOOL_OPT) +case $ac_sys_system/$ac_sys_release in + Darwin/@<:@01567@:>@\..*) + OTHER_LIBTOOL_OPT="-prebind -seg1addr 0x10000000" + ;; + Darwin/*) + OTHER_LIBTOOL_OPT="" + ;; +esac + + +ARCH_RUN_32BIT="" +AC_SUBST(LIBTOOL_CRUFT) +case $ac_sys_system/$ac_sys_release in + Darwin/@<:@01567@:>@\..*) + LIBTOOL_CRUFT="-framework System -lcc_dynamic" + if test "${enable_universalsdk}"; then + : + else + LIBTOOL_CRUFT="${LIBTOOL_CRUFT} -arch_only `/usr/bin/arch`" + fi + LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -install_name $(PYTHONFRAMEWORKINSTALLDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)' + LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -compatibility_version $(VERSION) -current_version $(VERSION)';; + Darwin/*) + gcc_version=`gcc -dumpversion` + if test ${gcc_version} '<' 4.0 + then + LIBTOOL_CRUFT="-lcc_dynamic" + else + LIBTOOL_CRUFT="" + fi + AC_RUN_IFELSE([AC_LANG_SOURCE([[ + #include + int main(int argc, char*argv[]) + { + if (sizeof(long) == 4) { + return 0; + } else { + return 1; + } + } + ]])],[ac_osx_32bit=yes],[ac_osx_32bit=no],[ac_osx_32bit=yes]) + + if test "${ac_osx_32bit}" = "yes"; then + case `/usr/bin/arch` in + i386) + MACOSX_DEFAULT_ARCH="i386" + ;; + ppc) + MACOSX_DEFAULT_ARCH="ppc" + ;; + *) + AC_MSG_ERROR([Unexpected output of 'arch' on OSX]) + ;; + esac + else + case `/usr/bin/arch` in + i386) + MACOSX_DEFAULT_ARCH="x86_64" + ;; + ppc) + MACOSX_DEFAULT_ARCH="ppc64" + ;; + *) + AC_MSG_ERROR([Unexpected output of 'arch' on OSX]) + ;; + esac + + #ARCH_RUN_32BIT="true" + fi + + LIBTOOL_CRUFT=$LIBTOOL_CRUFT" -lSystem -lSystemStubs -arch_only ${MACOSX_DEFAULT_ARCH}" + LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -install_name $(PYTHONFRAMEWORKINSTALLDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)' + LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -compatibility_version $(VERSION) -current_version $(VERSION)';; +esac + +AC_MSG_CHECKING(for --enable-framework) +if test "$enable_framework" +then + BASECFLAGS="$BASECFLAGS -fno-common -dynamic" + # -F. is needed to allow linking to the framework while + # in the build location. + AC_DEFINE(WITH_NEXT_FRAMEWORK, 1, + [Define if you want to produce an OpenStep/Rhapsody framework + (shared library plus accessory files).]) + AC_MSG_RESULT(yes) + if test $enable_shared = "yes" + then + AC_MSG_ERROR([Specifying both --enable-shared and --enable-framework is not supported, use only --enable-framework instead. See Mac/README.]) + fi +else + AC_MSG_RESULT(no) +fi + +AC_MSG_CHECKING(for dyld) +case $ac_sys_system/$ac_sys_release in + Darwin/*) + AC_DEFINE(WITH_DYLD, 1, + [Define if you want to use the new-style (Openstep, Rhapsody, MacOS) + dynamic linker (dyld) instead of the old-style (NextStep) dynamic + linker (rld). Dyld is necessary to support frameworks.]) + AC_MSG_RESULT(always on for Darwin) + ;; + *) + AC_MSG_RESULT(no) + ;; +esac + +# Set info about shared libraries. +AC_SUBST(SO) +AC_SUBST(LDSHARED) +AC_SUBST(LDCXXSHARED) +AC_SUBST(BLDSHARED) +AC_SUBST(CCSHARED) +AC_SUBST(LINKFORSHARED) +# SO is the extension of shared libraries `(including the dot!) +# -- usually .so, .sl on HP-UX, .dll on Cygwin +AC_MSG_CHECKING(SO) +if test -z "$SO" +then + case $ac_sys_system in + hp*|HP*) + case `uname -m` in + ia64) SO=.so;; + *) SO=.sl;; + esac + ;; + CYGWIN*) SO=.dll;; + *) SO=.so;; + esac +else + # this might also be a termcap variable, see #610332 + echo + echo '=====================================================================' + echo '+ +' + echo '+ WARNING: You have set SO in your environment. +' + echo '+ Do you really mean to change the extension for shared libraries? +' + echo '+ Continuing in 10 seconds to let you to ponder. +' + echo '+ +' + echo '=====================================================================' + sleep 10 +fi +AC_MSG_RESULT($SO) + +AC_DEFINE_UNQUOTED(SHLIB_EXT, "$SO", [Define this to be extension of shared libraries (including the dot!).]) +# LDSHARED is the ld *command* used to create shared library +# -- "cc -G" on SunOS 5.x, "ld -shared" on IRIX 5 +# (Shared libraries in this instance are shared modules to be loaded into +# Python, as opposed to building Python itself as a shared library.) +AC_MSG_CHECKING(LDSHARED) +if test -z "$LDSHARED" +then + case $ac_sys_system/$ac_sys_release in + AIX*) + BLDSHARED="\$(srcdir)/Modules/ld_so_aix \$(CC) -bI:\$(srcdir)/Modules/python.exp" + LDSHARED="\$(BINLIBDEST)/config/ld_so_aix \$(CC) -bI:\$(BINLIBDEST)/config/python.exp" + ;; + BeOS*) + BLDSHARED="\$(srcdir)/Modules/ld_so_beos $LDLIBRARY" + LDSHARED="\$(BINLIBDEST)/config/ld_so_beos \$(LIBDIR)/$LDLIBRARY" + ;; + IRIX/5*) LDSHARED="ld -shared";; + IRIX*/6*) LDSHARED="ld ${SGI_ABI} -shared -all";; + SunOS/5*) + if test "$GCC" = "yes" ; then + LDSHARED='$(CC) -shared' + LDCXXSHARED='$(CXX) -shared' + else + LDSHARED='$(CC) -G' + LDCXXSHARED='$(CXX) -G' + fi ;; + hp*|HP*) + if test "$GCC" = "yes" ; then + LDSHARED='$(CC) -shared' + LDCXXSHARED='$(CXX) -shared' + else + LDSHARED='ld -b' + fi ;; + OSF*) LDSHARED="ld -shared -expect_unresolved \"*\"";; + Darwin/1.3*) + LDSHARED='$(CC) -bundle' + LDCXXSHARED='$(CXX) -bundle' + if test "$enable_framework" ; then + # Link against the framework. All externals should be defined. + BLDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)' + LDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)' + LDCXXSHARED="$LDCXXSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)' + else + # No framework. Ignore undefined symbols, assuming they come from Python + LDSHARED="$LDSHARED -undefined suppress" + LDCXXSHARED="$LDCXXSHARED -undefined suppress" + fi ;; + Darwin/1.4*|Darwin/5.*|Darwin/6.*) + LDSHARED='$(CC) -bundle' + LDCXXSHARED='$(CXX) -bundle' + if test "$enable_framework" ; then + # Link against the framework. All externals should be defined. + BLDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)' + LDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)' + LDCXXSHARED="$LDCXXSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)' + else + # No framework, use the Python app as bundle-loader + BLDSHARED="$LDSHARED "'-bundle_loader $(BUILDPYTHON)' + LDSHARED="$LDSHARED "'-bundle_loader $(BINDIR)/python$(VERSION)$(EXE)' + LDCXXSHARED="$LDCXXSHARED "'-bundle_loader $(BINDIR)/python$(VERSION)$(EXE)' + fi ;; + Darwin/*) + # Use -undefined dynamic_lookup whenever possible (10.3 and later). + # This allows an extension to be used in any Python + + if test ${MACOSX_DEPLOYMENT_TARGET} '>' 10.2 + then + if test "${enable_universalsdk}"; then + LDFLAGS="${UNIVERSAL_ARCH_FLAGS} -isysroot ${UNIVERSALSDK} ${LDFLAGS}" + fi + LDSHARED='$(CC) -bundle -undefined dynamic_lookup' + LDCXXSHARED='$(CXX) -bundle -undefined dynamic_lookup' + BLDSHARED="$LDSHARED" + else + LDSHARED='$(CC) -bundle' + LDCXXSHARED='$(CXX) -bundle' + if test "$enable_framework" ; then + # Link against the framework. All externals should be defined. + BLDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)' + LDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)' + LDCXXSHARED="$LDCXXSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)' + else + # No framework, use the Python app as bundle-loader + BLDSHARED="$LDSHARED "'-bundle_loader $(BUILDPYTHON)' + LDSHARED="$LDSHARED "'-bundle_loader $(BINDIR)/python$(VERSION)$(EXE)' + LDCXXSHARED="$LDCXXSHARED "'-bundle_loader $(BINDIR)/python$(VERSION)$(EXE)' + fi + fi + ;; + Linux*|GNU*|QNX*) + LDSHARED='$(CC) -shared' + LDCXXSHARED='$(CXX) -shared';; + BSD/OS*/4*) + LDSHARED="gcc -shared" + LDCXXSHARED="g++ -shared";; + FreeBSD*) + if [[ "`$CC -dM -E - &1 | grep export-dynamic >/dev/null + then + LINKFORSHARED="-Xlinker --export-dynamic" + fi;; + esac;; + CYGWIN*) + if test $enable_shared = "no" + then + LINKFORSHARED='-Wl,--out-implib=$(LDLIBRARY)' + fi;; + QNX*) + # -Wl,-E causes the symbols to be added to the dynamic + # symbol table so that they can be found when a module + # is loaded. -N 2048K causes the stack size to be set + # to 2048 kilobytes so that the stack doesn't overflow + # when running test_compile.py. + LINKFORSHARED='-Wl,-E -N 2048K';; + esac +fi +AC_MSG_RESULT($LINKFORSHARED) + + +AC_SUBST(CFLAGSFORSHARED) +AC_MSG_CHECKING(CFLAGSFORSHARED) +if test ! "$LIBRARY" = "$LDLIBRARY" +then + case $ac_sys_system in + CYGWIN*) + # Cygwin needs CCSHARED when building extension DLLs + # but not when building the interpreter DLL. + CFLAGSFORSHARED='';; + *) + CFLAGSFORSHARED='$(CCSHARED)' + esac +fi +AC_MSG_RESULT($CFLAGSFORSHARED) + +# SHLIBS are libraries (except -lc and -lm) to link to the python shared +# library (with --enable-shared). +# For platforms on which shared libraries are not allowed to have unresolved +# symbols, this must be set to $(LIBS) (expanded by make). We do this even +# if it is not required, since it creates a dependency of the shared library +# to LIBS. This, in turn, means that applications linking the shared libpython +# don't need to link LIBS explicitly. The default should be only changed +# on systems where this approach causes problems. +AC_SUBST(SHLIBS) +AC_MSG_CHECKING(SHLIBS) +case "$ac_sys_system" in + *) + SHLIBS='$(LIBS)';; +esac +AC_MSG_RESULT($SHLIBS) + + +# checks for libraries +AC_CHECK_LIB(dl, dlopen) # Dynamic linking for SunOS/Solaris and SYSV +AC_CHECK_LIB(dld, shl_load) # Dynamic linking for HP-UX + +# only check for sem_init if thread support is requested +if test "$with_threads" = "yes" -o -z "$with_threads"; then + AC_SEARCH_LIBS(sem_init, pthread rt posix4) # 'Real Time' functions on Solaris + # posix4 on Solaris 2.6 + # pthread (first!) on Linux +fi + +# check if we need libintl for locale functions +AC_CHECK_LIB(intl, textdomain, + AC_DEFINE(WITH_LIBINTL, 1, + [Define to 1 if libintl is needed for locale functions.])) + +# checks for system dependent C++ extensions support +case "$ac_sys_system" in + AIX*) AC_MSG_CHECKING(for genuine AIX C++ extensions support) + AC_LINK_IFELSE([ + AC_LANG_PROGRAM([[#include ]], + [[loadAndInit("", 0, "")]]) + ],[ + AC_DEFINE(AIX_GENUINE_CPLUSPLUS, 1, + [Define for AIX if your compiler is a genuine IBM xlC/xlC_r + and you want support for AIX C++ shared extension modules.]) + AC_MSG_RESULT(yes) + ],[ + AC_MSG_RESULT(no) + ]);; + *) ;; +esac + +# Most SVR4 platforms (e.g. Solaris) need -lsocket and -lnsl. +# BeOS' sockets are stashed in libnet. +AC_CHECK_LIB(nsl, t_open, [LIBS="-lnsl $LIBS"]) # SVR4 +AC_CHECK_LIB(socket, socket, [LIBS="-lsocket $LIBS"], [], $LIBS) # SVR4 sockets + +case "$ac_sys_system" in +BeOS*) +AC_CHECK_LIB(net, socket, [LIBS="-lnet $LIBS"], [], $LIBS) # BeOS +;; +esac + +AC_MSG_CHECKING(for --with-libs) +AC_ARG_WITH(libs, + AS_HELP_STRING([--with-libs='lib1 ...'], [link against additional libs]), +[ +AC_MSG_RESULT($withval) +LIBS="$withval $LIBS" +], +[AC_MSG_RESULT(no)]) + +AC_PATH_TOOL([PKG_CONFIG], [pkg-config]) + +# Check for use of the system expat library +AC_MSG_CHECKING(for --with-system-expat) +AC_ARG_WITH(system_expat, + AS_HELP_STRING([--with-system-expat], [build pyexpat module using an installed expat library]), + [], + [with_system_expat="no"]) + +AC_MSG_RESULT($with_system_expat) + +# Check for use of the system libffi library +AC_MSG_CHECKING(for --with-system-ffi) +AC_ARG_WITH(system_ffi, + AS_HELP_STRING([--with-system-ffi], [build _ctypes module using an installed ffi library]), + [], + [with_system_ffi="no"]) + +if test "$with_system_ffi" = "yes" && test -n "$PKG_CONFIG"; then + LIBFFI_INCLUDEDIR="`"$PKG_CONFIG" libffi --cflags-only-I 2>/dev/null | sed -e 's/^-I//;s/ *$//'`" +else + LIBFFI_INCLUDEDIR="" +fi +AC_SUBST(LIBFFI_INCLUDEDIR) + +AC_MSG_RESULT($with_system_ffi) + +# Check for --with-dbmliborder +AC_MSG_CHECKING(for --with-dbmliborder) +AC_ARG_WITH(dbmliborder, + AS_HELP_STRING([--with-dbmliborder=db1:db2:...], [order to check db backends for dbm. Valid value is a colon separated string with the backend names `ndbm', `gdbm' and `bdb'.]), +[ +if test x$with_dbmliborder = xyes +then +AC_MSG_ERROR([proper usage is --with-dbmliborder=db1:db2:...]) +else + for db in `echo $with_dbmliborder | sed 's/:/ /g'`; do + if test x$db != xndbm && test x$db != xgdbm && test x$db != xbdb + then + AC_MSG_ERROR([proper usage is --with-dbmliborder=db1:db2:...]) + fi + done +fi]) +AC_MSG_RESULT($with_dbmliborder) + +# Determine if signalmodule should be used. +AC_SUBST(USE_SIGNAL_MODULE) +AC_SUBST(SIGNAL_OBJS) +AC_MSG_CHECKING(for --with-signal-module) +AC_ARG_WITH(signal-module, + AS_HELP_STRING([--with-signal-module], [disable/enable signal module])) + +if test -z "$with_signal_module" +then with_signal_module="yes" +fi +AC_MSG_RESULT($with_signal_module) + +if test "${with_signal_module}" = "yes"; then + USE_SIGNAL_MODULE="" + SIGNAL_OBJS="" +else + USE_SIGNAL_MODULE="#" + SIGNAL_OBJS="Parser/intrcheck.o Python/sigcheck.o" +fi + +# This is used to generate Setup.config +AC_SUBST(USE_THREAD_MODULE) +USE_THREAD_MODULE="" + +AC_MSG_CHECKING(for --with-dec-threads) +AC_SUBST(LDLAST) +AC_ARG_WITH(dec-threads, + AS_HELP_STRING([--with-dec-threads], [use DEC Alpha/OSF1 thread-safe libraries]), +[ +AC_MSG_RESULT($withval) +LDLAST=-threads +if test "${with_thread+set}" != set; then + with_thread="$withval"; +fi], +[AC_MSG_RESULT(no)]) + +# Templates for things AC_DEFINEd more than once. +# For a single AC_DEFINE, no template is needed. +AH_TEMPLATE(C_THREADS,[Define if you have the Mach cthreads package]) +AH_TEMPLATE(_REENTRANT, + [Define to force use of thread-safe errno, h_errno, and other functions]) +AH_TEMPLATE(WITH_THREAD, + [Define if you want to compile in rudimentary thread support]) + +AC_MSG_CHECKING(for --with-threads) +dnl quadrigraphs "@<:@" and "@:>@" produce "[" and "]" in the output +AC_ARG_WITH(threads, + AS_HELP_STRING([--with(out)-threads@<:@=DIRECTORY@:>@], [disable/enable thread support])) + +# --with-thread is deprecated, but check for it anyway +dnl quadrigraphs "@<:@" and "@:>@" produce "[" and "]" in the output +AC_ARG_WITH(thread, + AS_HELP_STRING([--with(out)-thread@<:@=DIRECTORY@:>@], [deprecated; use --with(out)-threads]), + [with_threads=$with_thread]) + +if test -z "$with_threads" +then with_threads="yes" +fi +AC_MSG_RESULT($with_threads) + +AC_SUBST(THREADOBJ) +if test "$with_threads" = "no" +then + USE_THREAD_MODULE="#" +elif test "$ac_cv_pthread_is_default" = yes +then + AC_DEFINE(WITH_THREAD) + # Defining _REENTRANT on system with POSIX threads should not hurt. + AC_DEFINE(_REENTRANT) + posix_threads=yes + THREADOBJ="Python/thread.o" +elif test "$ac_cv_kpthread" = "yes" +then + CC="$CC -Kpthread" + if test "$ac_cv_cxx_thread" = "yes"; then + CXX="$CXX -Kpthread" + fi + AC_DEFINE(WITH_THREAD) + posix_threads=yes + THREADOBJ="Python/thread.o" +elif test "$ac_cv_kthread" = "yes" +then + CC="$CC -Kthread" + if test "$ac_cv_cxx_thread" = "yes"; then + CXX="$CXX -Kthread" + fi + AC_DEFINE(WITH_THREAD) + posix_threads=yes + THREADOBJ="Python/thread.o" +elif test "$ac_cv_pthread" = "yes" +then + CC="$CC -pthread" + if test "$ac_cv_cxx_thread" = "yes"; then + CXX="$CXX -pthread" + fi + AC_DEFINE(WITH_THREAD) + posix_threads=yes + THREADOBJ="Python/thread.o" +else + if test ! -z "$with_threads" -a -d "$with_threads" + then LDFLAGS="$LDFLAGS -L$with_threads" + fi + if test ! -z "$withval" -a -d "$withval" + then LDFLAGS="$LDFLAGS -L$withval" + fi + + # According to the POSIX spec, a pthreads implementation must + # define _POSIX_THREADS in unistd.h. Some apparently don't + # (e.g. gnu pth with pthread emulation) + AC_MSG_CHECKING(for _POSIX_THREADS in unistd.h) + AC_EGREP_CPP(yes, + [ +#include +#ifdef _POSIX_THREADS +yes +#endif + ], unistd_defines_pthreads=yes, unistd_defines_pthreads=no) + AC_MSG_RESULT($unistd_defines_pthreads) + + AC_DEFINE(_REENTRANT) + AC_CHECK_HEADER(cthreads.h, [AC_DEFINE(WITH_THREAD) + AC_DEFINE(C_THREADS) + AC_DEFINE(HURD_C_THREADS, 1, + [Define if you are using Mach cthreads directly under /include]) + LIBS="$LIBS -lthreads" + THREADOBJ="Python/thread.o"],[ + AC_CHECK_HEADER(mach/cthreads.h, [AC_DEFINE(WITH_THREAD) + AC_DEFINE(C_THREADS) + AC_DEFINE(MACH_C_THREADS, 1, + [Define if you are using Mach cthreads under mach /]) + THREADOBJ="Python/thread.o"],[ + AC_MSG_CHECKING(for --with-pth) + AC_ARG_WITH([pth], + AS_HELP_STRING([--with-pth], [use GNU pth threading libraries]), + [AC_MSG_RESULT($withval) + AC_DEFINE([WITH_THREAD]) + AC_DEFINE([HAVE_PTH], 1, + [Define if you have GNU PTH threads.]) + LIBS="-lpth $LIBS" + THREADOBJ="Python/thread.o"], + [AC_MSG_RESULT(no) + + # Just looking for pthread_create in libpthread is not enough: + # on HP/UX, pthread.h renames pthread_create to a different symbol name. + # So we really have to include pthread.h, and then link. + _libs=$LIBS + LIBS="$LIBS -lpthread" + AC_MSG_CHECKING([for pthread_create in -lpthread]) + AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include + +void * start_routine (void *arg) { exit (0); }]], [[ +pthread_create (NULL, NULL, start_routine, NULL)]])],[ + AC_MSG_RESULT(yes) + AC_DEFINE(WITH_THREAD) + posix_threads=yes + THREADOBJ="Python/thread.o"],[ + LIBS=$_libs + AC_CHECK_FUNC(pthread_detach, [AC_DEFINE(WITH_THREAD) + posix_threads=yes + THREADOBJ="Python/thread.o"],[ + AC_CHECK_HEADER(atheos/threads.h, [AC_DEFINE(WITH_THREAD) + AC_DEFINE(ATHEOS_THREADS, 1, + [Define this if you have AtheOS threads.]) + THREADOBJ="Python/thread.o"],[ + AC_CHECK_HEADER(kernel/OS.h, [AC_DEFINE(WITH_THREAD) + AC_DEFINE(BEOS_THREADS, 1, + [Define this if you have BeOS threads.]) + THREADOBJ="Python/thread.o"],[ + AC_CHECK_LIB(pthreads, pthread_create, [AC_DEFINE(WITH_THREAD) + posix_threads=yes + LIBS="$LIBS -lpthreads" + THREADOBJ="Python/thread.o"], [ + AC_CHECK_LIB(c_r, pthread_create, [AC_DEFINE(WITH_THREAD) + posix_threads=yes + LIBS="$LIBS -lc_r" + THREADOBJ="Python/thread.o"], [ + AC_CHECK_LIB(pthread, __pthread_create_system, [AC_DEFINE(WITH_THREAD) + posix_threads=yes + LIBS="$LIBS -lpthread" + THREADOBJ="Python/thread.o"], [ + AC_CHECK_LIB(cma, pthread_create, [AC_DEFINE(WITH_THREAD) + posix_threads=yes + LIBS="$LIBS -lcma" + THREADOBJ="Python/thread.o"],[ + USE_THREAD_MODULE="#"]) + ])])])])])])])])])]) + + AC_CHECK_LIB(mpc, usconfig, [AC_DEFINE(WITH_THREAD) + LIBS="$LIBS -lmpc" + THREADOBJ="Python/thread.o" + USE_THREAD_MODULE=""]) + + if test "$posix_threads" != "yes"; then + AC_CHECK_LIB(thread, thr_create, [AC_DEFINE(WITH_THREAD) + LIBS="$LIBS -lthread" + THREADOBJ="Python/thread.o" + USE_THREAD_MODULE=""]) + fi + + if test "$USE_THREAD_MODULE" != "#" + then + # If the above checks didn't disable threads, (at least) OSF1 + # needs this '-threads' argument during linking. + case $ac_sys_system in + OSF1) LDLAST=-threads;; + esac + fi +fi + +if test "$posix_threads" = "yes"; then + if test "$unistd_defines_pthreads" = "no"; then + AC_DEFINE(_POSIX_THREADS, 1, + [Define if you have POSIX threads, + and your system does not define that.]) + fi + + # Bug 662787: Using semaphores causes unexplicable hangs on Solaris 8. + case $ac_sys_system/$ac_sys_release in + SunOS/5.6) AC_DEFINE(HAVE_PTHREAD_DESTRUCTOR, 1, + [Defined for Solaris 2.6 bug in pthread header.]) + ;; + SunOS/5.8) AC_DEFINE(HAVE_BROKEN_POSIX_SEMAPHORES, 1, + [Define if the Posix semaphores do not work on your system]) + ;; + AIX/*) AC_DEFINE(HAVE_BROKEN_POSIX_SEMAPHORES, 1, + [Define if the Posix semaphores do not work on your system]) + ;; + esac + + AC_MSG_CHECKING(if PTHREAD_SCOPE_SYSTEM is supported) + AC_CACHE_VAL(ac_cv_pthread_system_supported, + [AC_RUN_IFELSE([AC_LANG_SOURCE([[#include + void *foo(void *parm) { + return NULL; + } + main() { + pthread_attr_t attr; + pthread_t id; + if (pthread_attr_init(&attr)) exit(-1); + if (pthread_attr_setscope(&attr, PTHREAD_SCOPE_SYSTEM)) exit(-1); + if (pthread_create(&id, &attr, foo, NULL)) exit(-1); + exit(0); + }]])], + [ac_cv_pthread_system_supported=yes], + [ac_cv_pthread_system_supported=no], + [ac_cv_pthread_system_supported=no]) + ]) + AC_MSG_RESULT($ac_cv_pthread_system_supported) + if test "$ac_cv_pthread_system_supported" = "yes"; then + AC_DEFINE(PTHREAD_SYSTEM_SCHED_SUPPORTED, 1, [Defined if PTHREAD_SCOPE_SYSTEM supported.]) + fi + AC_CHECK_FUNCS(pthread_sigmask, + [case $ac_sys_system in + CYGWIN*) + AC_DEFINE(HAVE_BROKEN_PTHREAD_SIGMASK, 1, + [Define if pthread_sigmask() does not work on your system.]) + ;; + esac]) +fi + + +# Check for enable-ipv6 +AH_TEMPLATE(ENABLE_IPV6, [Define if --enable-ipv6 is specified]) +AC_MSG_CHECKING([if --enable-ipv6 is specified]) +AC_ARG_ENABLE(ipv6, +[ --enable-ipv6 Enable ipv6 (with ipv4) support + --disable-ipv6 Disable ipv6 support], +[ case "$enableval" in + no) + AC_MSG_RESULT(no) + ipv6=no + ;; + *) AC_MSG_RESULT(yes) + AC_DEFINE(ENABLE_IPV6) + ipv6=yes + ;; + esac ], + +[ +dnl the check does not work on cross compilation case... + AC_RUN_IFELSE([AC_LANG_SOURCE([[ /* AF_INET6 available check */ +#include +#include +main() +{ + if (socket(AF_INET6, SOCK_STREAM, 0) < 0) + exit(1); + else + exit(0); +} +]])],[ + AC_MSG_RESULT(yes) + ipv6=yes +],[ + AC_MSG_RESULT(no) + ipv6=no +],[ + AC_MSG_RESULT(no) + ipv6=no +]) + +if test "$ipv6" = "yes"; then + AC_MSG_CHECKING(if RFC2553 API is available) + AC_COMPILE_IFELSE([ + AC_LANG_PROGRAM([[#include +#include ]], + [[struct sockaddr_in6 x; + x.sin6_scope_id;]]) + ],[ + AC_MSG_RESULT(yes) + ipv6=yes + ],[ + AC_MSG_RESULT(no, IPv6 disabled) + ipv6=no + ]) +fi + +if test "$ipv6" = "yes"; then + AC_DEFINE(ENABLE_IPV6) +fi +]) + +ipv6type=unknown +ipv6lib=none +ipv6trylibc=no + +if test "$ipv6" = "yes"; then + AC_MSG_CHECKING([ipv6 stack type]) + for i in inria kame linux-glibc linux-inet6 solaris toshiba v6d zeta; + do + case $i in + inria) + dnl http://www.kame.net/ + AC_EGREP_CPP(yes, [ +#include +#ifdef IPV6_INRIA_VERSION +yes +#endif], + [ipv6type=$i]) + ;; + kame) + dnl http://www.kame.net/ + AC_EGREP_CPP(yes, [ +#include +#ifdef __KAME__ +yes +#endif], + [ipv6type=$i; + ipv6lib=inet6 + ipv6libdir=/usr/local/v6/lib + ipv6trylibc=yes]) + ;; + linux-glibc) + dnl http://www.v6.linux.or.jp/ + AC_EGREP_CPP(yes, [ +#include +#if defined(__GLIBC__) && ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 1) || (__GLIBC__ > 2)) +yes +#endif], + [ipv6type=$i; + ipv6trylibc=yes]) + ;; + linux-inet6) + dnl http://www.v6.linux.or.jp/ + if test -d /usr/inet6; then + ipv6type=$i + ipv6lib=inet6 + ipv6libdir=/usr/inet6/lib + BASECFLAGS="-I/usr/inet6/include $BASECFLAGS" + fi + ;; + solaris) + if test -f /etc/netconfig; then + if $GREP -q tcp6 /etc/netconfig; then + ipv6type=$i + ipv6trylibc=yes + fi + fi + ;; + toshiba) + AC_EGREP_CPP(yes, [ +#include +#ifdef _TOSHIBA_INET6 +yes +#endif], + [ipv6type=$i; + ipv6lib=inet6; + ipv6libdir=/usr/local/v6/lib]) + ;; + v6d) + AC_EGREP_CPP(yes, [ +#include +#ifdef __V6D__ +yes +#endif], + [ipv6type=$i; + ipv6lib=v6; + ipv6libdir=/usr/local/v6/lib; + BASECFLAGS="-I/usr/local/v6/include $BASECFLAGS"]) + ;; + zeta) + AC_EGREP_CPP(yes, [ +#include +#ifdef _ZETA_MINAMI_INET6 +yes +#endif], + [ipv6type=$i; + ipv6lib=inet6; + ipv6libdir=/usr/local/v6/lib]) + ;; + esac + if test "$ipv6type" != "unknown"; then + break + fi + done + AC_MSG_RESULT($ipv6type) +fi + +if test "$ipv6" = "yes" -a "$ipv6lib" != "none"; then + if test -d $ipv6libdir -a -f $ipv6libdir/lib$ipv6lib.a; then + LIBS="-L$ipv6libdir -l$ipv6lib $LIBS" + echo "using lib$ipv6lib" + else + if test $ipv6trylibc = "yes"; then + echo "using libc" + else + echo 'Fatal: no $ipv6lib library found. cannot continue.' + echo "You need to fetch lib$ipv6lib.a from appropriate" + echo 'ipv6 kit and compile beforehand.' + exit 1 + fi + fi +fi + +AC_MSG_CHECKING(for OSX 10.5 SDK or later) +AC_COMPILE_IFELSE([ + AC_LANG_PROGRAM([[#include ]], [[FSIORefNum fRef = 0]]) +],[ + AC_DEFINE(HAVE_OSX105_SDK, 1, [Define if compiling using MacOS X 10.5 SDK or later.]) + AC_MSG_RESULT(yes) +],[ + AC_MSG_RESULT(no) +]) + +# Check for --with-doc-strings +AC_MSG_CHECKING(for --with-doc-strings) +AC_ARG_WITH(doc-strings, + AS_HELP_STRING([--with(out)-doc-strings], [disable/enable documentation strings])) + +if test -z "$with_doc_strings" +then with_doc_strings="yes" +fi +if test "$with_doc_strings" != "no" +then + AC_DEFINE(WITH_DOC_STRINGS, 1, + [Define if you want documentation strings in extension modules]) +fi +AC_MSG_RESULT($with_doc_strings) + +# Check for Python-specific malloc support +AC_MSG_CHECKING(for --with-tsc) +AC_ARG_WITH(tsc, + AS_HELP_STRING([--with(out)-tsc],[enable/disable timestamp counter profile]),[ +if test "$withval" != no +then + AC_DEFINE(WITH_TSC, 1, + [Define to profile with the Pentium timestamp counter]) + AC_MSG_RESULT(yes) +else AC_MSG_RESULT(no) +fi], +[AC_MSG_RESULT(no)]) + +# Check for Python-specific malloc support +AC_MSG_CHECKING(for --with-pymalloc) +AC_ARG_WITH(pymalloc, + AS_HELP_STRING([--with(out)-pymalloc], [disable/enable specialized mallocs])) + +if test -z "$with_pymalloc" +then with_pymalloc="yes" +fi +if test "$with_pymalloc" != "no" +then + AC_DEFINE(WITH_PYMALLOC, 1, + [Define if you want to compile in Python-specific mallocs]) +fi +AC_MSG_RESULT($with_pymalloc) + +# Check for Valgrind support +AC_MSG_CHECKING([for --with-valgrind]) +AC_ARG_WITH([valgrind], + AS_HELP_STRING([--with-valgrind], [Enable Valgrind support]),, + with_valgrind=no) +AC_MSG_RESULT([$with_valgrind]) +if test "$with_valgrind" != no; then + AC_CHECK_HEADER([valgrind/valgrind.h], + [AC_DEFINE([WITH_VALGRIND], 1, [Define if you want pymalloc to be disabled when running under valgrind])], + [AC_MSG_ERROR([Valgrind support requested but headers not available])] + ) +fi + +# Check for --with-wctype-functions +AC_MSG_CHECKING(for --with-wctype-functions) +AC_ARG_WITH(wctype-functions, + AS_HELP_STRING([--with-wctype-functions], [use wctype.h functions]), +[ +if test "$withval" != no +then + AC_DEFINE(WANT_WCTYPE_FUNCTIONS, 1, + [Define if you want wctype.h functions to be used instead of the + one supplied by Python itself. (see Include/unicodectype.h).]) + AC_MSG_RESULT(yes) +else AC_MSG_RESULT(no) +fi], +[AC_MSG_RESULT(no)]) + +# -I${DLINCLDIR} is added to the compile rule for importdl.o +AC_SUBST(DLINCLDIR) +DLINCLDIR=. + +# the dlopen() function means we might want to use dynload_shlib.o. some +# platforms, such as AIX, have dlopen(), but don't want to use it. +AC_CHECK_FUNCS(dlopen) + +# DYNLOADFILE specifies which dynload_*.o file we will use for dynamic +# loading of modules. +AC_SUBST(DYNLOADFILE) +AC_MSG_CHECKING(DYNLOADFILE) +if test -z "$DYNLOADFILE" +then + case $ac_sys_system/$ac_sys_release in + AIX*) # Use dynload_shlib.c and dlopen() if we have it; otherwise dynload_aix.c + if test "$ac_cv_func_dlopen" = yes + then DYNLOADFILE="dynload_shlib.o" + else DYNLOADFILE="dynload_aix.o" + fi + ;; + BeOS*) DYNLOADFILE="dynload_beos.o";; + hp*|HP*) DYNLOADFILE="dynload_hpux.o";; + # Use dynload_next.c only on 10.2 and below, which don't have native dlopen() + Darwin/@<:@0156@:>@\..*) DYNLOADFILE="dynload_next.o";; + atheos*) DYNLOADFILE="dynload_atheos.o";; + *) + # use dynload_shlib.c and dlopen() if we have it; otherwise stub + # out any dynamic loading + if test "$ac_cv_func_dlopen" = yes + then DYNLOADFILE="dynload_shlib.o" + else DYNLOADFILE="dynload_stub.o" + fi + ;; + esac +fi +AC_MSG_RESULT($DYNLOADFILE) +if test "$DYNLOADFILE" != "dynload_stub.o" +then + AC_DEFINE(HAVE_DYNAMIC_LOADING, 1, + [Defined when any dynamic module loading is enabled.]) +fi + +# MACHDEP_OBJS can be set to platform-specific object files needed by Python + +AC_SUBST(MACHDEP_OBJS) +AC_MSG_CHECKING(MACHDEP_OBJS) +if test -z "$MACHDEP_OBJS" +then + MACHDEP_OBJS=$extra_machdep_objs +else + MACHDEP_OBJS="$MACHDEP_OBJS $extra_machdep_objs" +fi +AC_MSG_RESULT(MACHDEP_OBJS) + +# checks for library functions +AC_CHECK_FUNCS(alarm setitimer getitimer bind_textdomain_codeset chown \ + clock confstr ctermid execv fchmod fchown fork fpathconf ftime ftruncate \ + gai_strerror getgroups getlogin getloadavg getpeername getpgid getpid \ + getpriority getresuid getresgid getpwent getspnam getspent getsid getwd \ + initgroups kill killpg lchmod lchown lstat mkfifo mknod mktime \ + mremap nice pathconf pause plock poll pthread_init \ + putenv readlink realpath \ + select sem_open sem_timedwait sem_getvalue sem_unlink setegid seteuid \ + setgid \ + setlocale setregid setreuid setsid setpgid setpgrp setuid setvbuf snprintf \ + setlocale setregid setreuid setresuid setresgid \ + setsid setpgid setpgrp setuid setvbuf snprintf \ + sigaction siginterrupt sigrelse strftime \ + sysconf tcgetpgrp tcsetpgrp tempnam timegm times tmpfile tmpnam tmpnam_r \ + truncate uname unsetenv utimes waitpid wait3 wait4 wcscoll _getpty) + +# For some functions, having a definition is not sufficient, since +# we want to take their address. +AC_MSG_CHECKING(for chroot) +AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include ]], [[void *x=chroot]])], + [AC_DEFINE(HAVE_CHROOT, 1, Define if you have the 'chroot' function.) + AC_MSG_RESULT(yes)], + [AC_MSG_RESULT(no) +]) +AC_MSG_CHECKING(for link) +AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include ]], [[void *x=link]])], + [AC_DEFINE(HAVE_LINK, 1, Define if you have the 'link' function.) + AC_MSG_RESULT(yes)], + [AC_MSG_RESULT(no) +]) +AC_MSG_CHECKING(for symlink) +AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include ]], [[void *x=symlink]])], + [AC_DEFINE(HAVE_SYMLINK, 1, Define if you have the 'symlink' function.) + AC_MSG_RESULT(yes)], + [AC_MSG_RESULT(no) +]) +AC_MSG_CHECKING(for fchdir) +AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include ]], [[void *x=fchdir]])], + [AC_DEFINE(HAVE_FCHDIR, 1, Define if you have the 'fchdir' function.) + AC_MSG_RESULT(yes)], + [AC_MSG_RESULT(no) +]) +AC_MSG_CHECKING(for fsync) +AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include ]], [[void *x=fsync]])], + [AC_DEFINE(HAVE_FSYNC, 1, Define if you have the 'fsync' function.) + AC_MSG_RESULT(yes)], + [AC_MSG_RESULT(no) +]) +AC_MSG_CHECKING(for fdatasync) +AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include ]], [[void *x=fdatasync]])], + [AC_DEFINE(HAVE_FDATASYNC, 1, Define if you have the 'fdatasync' function.) + AC_MSG_RESULT(yes)], + [AC_MSG_RESULT(no) +]) +AC_MSG_CHECKING(for epoll) +AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include ]], [[void *x=epoll_create]])], + [AC_DEFINE(HAVE_EPOLL, 1, Define if you have the 'epoll' functions.) + AC_MSG_RESULT(yes)], + [AC_MSG_RESULT(no) +]) +AC_MSG_CHECKING(for kqueue) +AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ +#include +#include + ]], [[int x=kqueue()]])], + [AC_DEFINE(HAVE_KQUEUE, 1, Define if you have the 'kqueue' functions.) + AC_MSG_RESULT(yes)], + [AC_MSG_RESULT(no) +]) +# On some systems (eg. FreeBSD 5), we would find a definition of the +# functions ctermid_r, setgroups in the library, but no prototype +# (e.g. because we use _XOPEN_SOURCE). See whether we can take their +# address to avoid compiler warnings and potential miscompilations +# because of the missing prototypes. + +AC_MSG_CHECKING(for ctermid_r) +AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ +#include +]], [[void* p = ctermid_r]])], + [AC_DEFINE(HAVE_CTERMID_R, 1, Define if you have the 'ctermid_r' function.) + AC_MSG_RESULT(yes)], + [AC_MSG_RESULT(no) +]) + +AC_CACHE_CHECK([for flock declaration], [ac_cv_flock_decl], + [AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM( + [#include ], + [void* p = flock] + )], + [ac_cv_flock_decl=yes], + [ac_cv_flock_decl=no] + ) +]) +if test "x${ac_cv_flock_decl}" = xyes; then + AC_CHECK_FUNCS(flock,, + AC_CHECK_LIB(bsd,flock, + [AC_DEFINE(HAVE_FLOCK) + AC_DEFINE(FLOCK_NEEDS_LIBBSD, 1, Define if flock needs to be linked with bsd library.) + ]) + ) +fi + +AC_MSG_CHECKING(for getpagesize) +AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ +#include +]], [[void* p = getpagesize]])], + [AC_DEFINE(HAVE_GETPAGESIZE, 1, Define if you have the 'getpagesize' function.) + AC_MSG_RESULT(yes)], + [AC_MSG_RESULT(no) +]) + +AC_MSG_CHECKING(for broken unsetenv) +AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ +#include +]], [[int res = unsetenv("DUMMY")]])], + [AC_MSG_RESULT(no)], + [AC_DEFINE(HAVE_BROKEN_UNSETENV, 1, Define if `unsetenv` does not return an int.) + AC_MSG_RESULT(yes) +]) + +dnl check for true +AC_CHECK_PROGS(TRUE, true, /bin/true) + +dnl On some systems (e.g. Solaris 9), hstrerror and inet_aton are in -lresolv +dnl On others, they are in the C library, so we to take no action +AC_CHECK_LIB(c, inet_aton, [$ac_cv_prog_TRUE], + AC_CHECK_LIB(resolv, inet_aton) +) + +# On Tru64, chflags seems to be present, but calling it will +# exit Python +AC_CACHE_CHECK([for chflags], [ac_cv_have_chflags], [dnl +AC_RUN_IFELSE([AC_LANG_SOURCE([[ +#include +#include +int main(int argc, char*argv[]) +{ + if(chflags(argv[0], 0) != 0) + return 1; + return 0; +} +]])], +[ac_cv_have_chflags=yes], +[ac_cv_have_chflags=no], +[ac_cv_have_chflags=cross]) +]) +if test "$ac_cv_have_chflags" = cross ; then + AC_CHECK_FUNC([chflags], [ac_cv_have_chflags="yes"], [ac_cv_have_chflags="no"]) +fi +if test "$ac_cv_have_chflags" = yes ; then + AC_DEFINE(HAVE_CHFLAGS, 1, [Define to 1 if you have the 'chflags' function.]) +fi + +AC_CACHE_CHECK([for lchflags], [ac_cv_have_lchflags], [dnl +AC_RUN_IFELSE([AC_LANG_SOURCE([[ +#include +#include +int main(int argc, char*argv[]) +{ + if(lchflags(argv[0], 0) != 0) + return 1; + return 0; +} +]])],[ac_cv_have_lchflags=yes],[ac_cv_have_lchflags=no],[ac_cv_have_lchflags=cross]) +]) +if test "$ac_cv_have_lchflags" = cross ; then + AC_CHECK_FUNC([lchflags], [ac_cv_have_lchflags="yes"], [ac_cv_have_lchflags="no"]) +fi +if test "$ac_cv_have_lchflags" = yes ; then + AC_DEFINE(HAVE_LCHFLAGS, 1, [Define to 1 if you have the 'lchflags' function.]) +fi + +dnl Check if system zlib has *Copy() functions +dnl +dnl On MacOSX the linker will search for dylibs on the entire linker path +dnl before searching for static libraries. setup.py adds -Wl,-search_paths_first +dnl to revert to a more traditional unix behaviour and make it possible to +dnl override the system libz with a local static library of libz. Temporarily +dnl add that flag to our CFLAGS as well to ensure that we check the version +dnl of libz that will be used by setup.py. +dnl The -L/usr/local/lib is needed as wel to get the same compilation +dnl environment as setup.py (and leaving it out can cause configure to use the +dnl wrong version of the library) +case $ac_sys_system/$ac_sys_release in +Darwin/*) + _CUR_CFLAGS="${CFLAGS}" + _CUR_LDFLAGS="${LDFLAGS}" + CFLAGS="${CFLAGS} -Wl,-search_paths_first" + LDFLAGS="${LDFLAGS} -Wl,-search_paths_first -L/usr/local/lib" + ;; +esac + +AC_CHECK_LIB(z, inflateCopy, AC_DEFINE(HAVE_ZLIB_COPY, 1, [Define if the zlib library has inflateCopy])) + +case $ac_sys_system/$ac_sys_release in +Darwin/*) + CFLAGS="${_CUR_CFLAGS}" + LDFLAGS="${_CUR_LDFLAGS}" + ;; +esac + +AC_MSG_CHECKING(for hstrerror) +AC_LINK_IFELSE([AC_LANG_PROGRAM([[ +#include +]], [[void* p = hstrerror; hstrerror(0)]])], + [AC_DEFINE(HAVE_HSTRERROR, 1, Define if you have the 'hstrerror' function.) + AC_MSG_RESULT(yes)], + [AC_MSG_RESULT(no) +]) + +AC_MSG_CHECKING(for inet_aton) +AC_LINK_IFELSE([AC_LANG_PROGRAM([[ +#include +#include +#include +#include +]], [[void* p = inet_aton;inet_aton(0,0)]])], + [AC_DEFINE(HAVE_INET_ATON, 1, Define if you have the 'inet_aton' function.) + AC_MSG_RESULT(yes)], + [AC_MSG_RESULT(no) +]) + +AC_MSG_CHECKING(for inet_pton) +AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ +#include +#include +#include +#include +]], [[void* p = inet_pton]])], + [AC_DEFINE(HAVE_INET_PTON, 1, Define if you have the 'inet_pton' function.) + AC_MSG_RESULT(yes)], + [AC_MSG_RESULT(no) +]) + +# On some systems, setgroups is in unistd.h, on others, in grp.h +AC_MSG_CHECKING(for setgroups) +AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ +#include +#ifdef HAVE_GRP_H +#include +#endif +]], [[void* p = setgroups]])], + [AC_DEFINE(HAVE_SETGROUPS, 1, Define if you have the 'setgroups' function.) + AC_MSG_RESULT(yes)], + [AC_MSG_RESULT(no) +]) + +# check for openpty and forkpty + +AC_CHECK_FUNCS(openpty,, + AC_CHECK_LIB(util,openpty, + [AC_DEFINE(HAVE_OPENPTY) LIBS="$LIBS -lutil"], + AC_CHECK_LIB(bsd,openpty, [AC_DEFINE(HAVE_OPENPTY) LIBS="$LIBS -lbsd"]) + ) +) +AC_CHECK_FUNCS(forkpty,, + AC_CHECK_LIB(util,forkpty, + [AC_DEFINE(HAVE_FORKPTY) LIBS="$LIBS -lutil"], + AC_CHECK_LIB(bsd,forkpty, [AC_DEFINE(HAVE_FORKPTY) LIBS="$LIBS -lbsd"]) + ) +) + +# Stuff for expat. +AC_CHECK_FUNCS(memmove) + +# check for long file support functions +AC_CHECK_FUNCS(fseek64 fseeko fstatvfs ftell64 ftello statvfs) + +AC_REPLACE_FUNCS(dup2 getcwd strdup) +AC_CHECK_FUNCS(getpgrp, + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include ]], [[getpgrp(0);]])], + [AC_DEFINE(GETPGRP_HAVE_ARG, 1, [Define if getpgrp() must be called as getpgrp(0).])], + []) +) +AC_CHECK_FUNCS(setpgrp, + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include ]], [[setpgrp(0,0);]])], + [AC_DEFINE(SETPGRP_HAVE_ARG, 1, [Define if setpgrp() must be called as setpgrp(0, 0).])], + []) +) +AC_CHECK_FUNCS(gettimeofday, + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include ]], + [[gettimeofday((struct timeval*)0,(struct timezone*)0);]])], + [], + [AC_DEFINE(GETTIMEOFDAY_NO_TZ, 1, + [Define if gettimeofday() does not have second (timezone) argument + This is the case on Motorola V4 (R40V4.2)]) + ]) +) + +AC_MSG_CHECKING(for major, minor, and makedev) +AC_LINK_IFELSE([AC_LANG_PROGRAM([[ +#if defined(MAJOR_IN_MKDEV) +#include +#elif defined(MAJOR_IN_SYSMACROS) +#include +#else +#include +#endif +]], [[ + makedev(major(0),minor(0)); +]])],[ + AC_DEFINE(HAVE_DEVICE_MACROS, 1, + [Define to 1 if you have the device macros.]) + AC_MSG_RESULT(yes) +],[ + AC_MSG_RESULT(no) +]) + +# On OSF/1 V5.1, getaddrinfo is available, but a define +# for [no]getaddrinfo in netdb.h. +AC_MSG_CHECKING(for getaddrinfo) +AC_LINK_IFELSE([AC_LANG_PROGRAM([[ +#include +#include +#include +#include +]], [[getaddrinfo(NULL, NULL, NULL, NULL);]])], +[have_getaddrinfo=yes], +[have_getaddrinfo=no]) +AC_MSG_RESULT($have_getaddrinfo) +if test $have_getaddrinfo = yes +then + AC_MSG_CHECKING(getaddrinfo bug) + AC_CACHE_VAL(ac_cv_buggy_getaddrinfo, + AC_RUN_IFELSE([AC_LANG_SOURCE([[[ +#include +#include +#include +#include +#include + +int main() +{ + int passive, gaierr, inet4 = 0, inet6 = 0; + struct addrinfo hints, *ai, *aitop; + char straddr[INET6_ADDRSTRLEN], strport[16]; + + for (passive = 0; passive <= 1; passive++) { + memset(&hints, 0, sizeof(hints)); + hints.ai_family = AF_UNSPEC; + hints.ai_flags = passive ? AI_PASSIVE : 0; + hints.ai_socktype = SOCK_STREAM; + hints.ai_protocol = IPPROTO_TCP; + if ((gaierr = getaddrinfo(NULL, "54321", &hints, &aitop)) != 0) { + (void)gai_strerror(gaierr); + goto bad; + } + for (ai = aitop; ai; ai = ai->ai_next) { + if (ai->ai_addr == NULL || + ai->ai_addrlen == 0 || + getnameinfo(ai->ai_addr, ai->ai_addrlen, + straddr, sizeof(straddr), strport, sizeof(strport), + NI_NUMERICHOST|NI_NUMERICSERV) != 0) { + goto bad; + } + switch (ai->ai_family) { + case AF_INET: + if (strcmp(strport, "54321") != 0) { + goto bad; + } + if (passive) { + if (strcmp(straddr, "0.0.0.0") != 0) { + goto bad; + } + } else { + if (strcmp(straddr, "127.0.0.1") != 0) { + goto bad; + } + } + inet4++; + break; + case AF_INET6: + if (strcmp(strport, "54321") != 0) { + goto bad; + } + if (passive) { + if (strcmp(straddr, "::") != 0) { + goto bad; + } + } else { + if (strcmp(straddr, "::1") != 0) { + goto bad; + } + } + inet6++; + break; + case AF_UNSPEC: + goto bad; + break; + default: + /* another family support? */ + break; + } + } + } + + if (!(inet4 == 0 || inet4 == 2)) + goto bad; + if (!(inet6 == 0 || inet6 == 2)) + goto bad; + + if (aitop) + freeaddrinfo(aitop); + return 0; + + bad: + if (aitop) + freeaddrinfo(aitop); + return 1; +} +]]])], +[ac_cv_buggy_getaddrinfo=no], +[ac_cv_buggy_getaddrinfo=yes], +[ac_cv_buggy_getaddrinfo=yes])) +fi + +AC_MSG_RESULT($ac_cv_buggy_getaddrinfo) + +if test $have_getaddrinfo = no -o "$ac_cv_buggy_getaddrinfo" = yes +then + if test $ipv6 = yes + then + echo 'Fatal: You must get working getaddrinfo() function.' + echo ' or you can specify "--disable-ipv6"'. + exit 1 + fi +else + AC_DEFINE(HAVE_GETADDRINFO, 1, [Define if you have the getaddrinfo function.]) +fi + +AC_CHECK_FUNCS(getnameinfo) + +# checks for structures +AC_HEADER_TIME +AC_STRUCT_TM +AC_STRUCT_TIMEZONE +AC_CHECK_MEMBERS([struct stat.st_rdev]) +AC_CHECK_MEMBERS([struct stat.st_blksize]) +AC_CHECK_MEMBERS([struct stat.st_flags]) +AC_CHECK_MEMBERS([struct stat.st_gen]) +AC_CHECK_MEMBERS([struct stat.st_birthtime]) +AC_STRUCT_ST_BLOCKS + +AC_MSG_CHECKING(for time.h that defines altzone) +AC_CACHE_VAL(ac_cv_header_time_altzone,[ + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include ]], [[return altzone;]])], + [ac_cv_header_time_altzone=yes], + [ac_cv_header_time_altzone=no]) + ]) +AC_MSG_RESULT($ac_cv_header_time_altzone) +if test $ac_cv_header_time_altzone = yes; then + AC_DEFINE(HAVE_ALTZONE, 1, [Define this if your time.h defines altzone.]) +fi + +was_it_defined=no +AC_MSG_CHECKING(whether sys/select.h and sys/time.h may both be included) +AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ +#include +#include +#include +]], [[;]])],[ + AC_DEFINE(SYS_SELECT_WITH_SYS_TIME, 1, + [Define if you can safely include both and + (which you can't on SCO ODT 3.0).]) + was_it_defined=yes +],[]) +AC_MSG_RESULT($was_it_defined) + +AC_MSG_CHECKING(for addrinfo) +AC_CACHE_VAL(ac_cv_struct_addrinfo, +AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include ]], [[struct addrinfo a]])], + [ac_cv_struct_addrinfo=yes], + [ac_cv_struct_addrinfo=no])) +AC_MSG_RESULT($ac_cv_struct_addrinfo) +if test $ac_cv_struct_addrinfo = yes; then + AC_DEFINE(HAVE_ADDRINFO, 1, [struct addrinfo (netdb.h)]) +fi + +AC_MSG_CHECKING(for sockaddr_storage) +AC_CACHE_VAL(ac_cv_struct_sockaddr_storage, +AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ +# include +# include ]], [[struct sockaddr_storage s]])], + [ac_cv_struct_sockaddr_storage=yes], + [ac_cv_struct_sockaddr_storage=no])) +AC_MSG_RESULT($ac_cv_struct_sockaddr_storage) +if test $ac_cv_struct_sockaddr_storage = yes; then + AC_DEFINE(HAVE_SOCKADDR_STORAGE, 1, [struct sockaddr_storage (sys/socket.h)]) +fi + +# checks for compiler characteristics + +AC_C_CHAR_UNSIGNED +AC_C_CONST + +works=no +AC_MSG_CHECKING(for working volatile) +AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[volatile int x; x = 0;]])], + [works=yes], + [AC_DEFINE(volatile, , [Define to empty if the keyword does not work.])] +) +AC_MSG_RESULT($works) + +works=no +AC_MSG_CHECKING(for working signed char) +AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[signed char c;]])], + [works=yes], + [AC_DEFINE(signed, , [Define to empty if the keyword does not work.])] +) +AC_MSG_RESULT($works) + +have_prototypes=no +AC_MSG_CHECKING(for prototypes) +AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[int foo(int x) { return 0; }]], [[return foo(10);]])], + [AC_DEFINE(HAVE_PROTOTYPES, 1, + [Define if your compiler supports function prototype]) + have_prototypes=yes], + [] +) +AC_MSG_RESULT($have_prototypes) + +works=no +AC_MSG_CHECKING(for variable length prototypes and stdarg.h) +AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ +#include +int foo(int x, ...) { + va_list va; + va_start(va, x); + va_arg(va, int); + va_arg(va, char *); + va_arg(va, double); + return 0; +} +]], [[return foo(10, "", 3.14);]])],[ + AC_DEFINE(HAVE_STDARG_PROTOTYPES, 1, + [Define if your compiler supports variable length function prototypes + (e.g. void fprintf(FILE *, char *, ...);) *and* ]) + works=yes +],[]) +AC_MSG_RESULT($works) + +# check for socketpair +AC_MSG_CHECKING(for socketpair) +AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ +#include +#include +]], [[void *x=socketpair]])], + [AC_DEFINE(HAVE_SOCKETPAIR, 1, [Define if you have the 'socketpair' function.]) + AC_MSG_RESULT(yes)], + [AC_MSG_RESULT(no)] +) + +# check if sockaddr has sa_len member +AC_MSG_CHECKING(if sockaddr has sa_len member) +AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include +#include ]], [[struct sockaddr x; +x.sa_len = 0;]])], + [AC_MSG_RESULT(yes) + AC_DEFINE(HAVE_SOCKADDR_SA_LEN, 1, [Define if sockaddr has sa_len member])], + [AC_MSG_RESULT(no)] +) + +va_list_is_array=no +AC_MSG_CHECKING(whether va_list is an array) +AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ +#ifdef HAVE_STDARG_PROTOTYPES +#include +#else +#include +#endif +]], [[va_list list1, list2; list1 = list2;]])],[],[ + AC_DEFINE(VA_LIST_IS_ARRAY, 1, [Define if a va_list is an array of some kind]) + va_list_is_array=yes +]) +AC_MSG_RESULT($va_list_is_array) + +# sigh -- gethostbyname_r is a mess; it can have 3, 5 or 6 arguments :-( +AH_TEMPLATE(HAVE_GETHOSTBYNAME_R, + [Define this if you have some version of gethostbyname_r()]) + +AC_CHECK_FUNC(gethostbyname_r, [ + AC_DEFINE(HAVE_GETHOSTBYNAME_R) + AC_MSG_CHECKING([gethostbyname_r with 6 args]) + OLD_CFLAGS=$CFLAGS + CFLAGS="$CFLAGS $MY_CPPFLAGS $MY_THREAD_CPPFLAGS $MY_CFLAGS" + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ +# include + ]], [[ + char *name; + struct hostent *he, *res; + char buffer[2048]; + int buflen = 2048; + int h_errnop; + + (void) gethostbyname_r(name, he, buffer, buflen, &res, &h_errnop) + ]])],[ + AC_DEFINE(HAVE_GETHOSTBYNAME_R) + AC_DEFINE(HAVE_GETHOSTBYNAME_R_6_ARG, 1, + [Define this if you have the 6-arg version of gethostbyname_r().]) + AC_MSG_RESULT(yes) + ],[ + AC_MSG_RESULT(no) + AC_MSG_CHECKING([gethostbyname_r with 5 args]) + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ +# include + ]], [[ + char *name; + struct hostent *he; + char buffer[2048]; + int buflen = 2048; + int h_errnop; + + (void) gethostbyname_r(name, he, buffer, buflen, &h_errnop) + ]])], + [ + AC_DEFINE(HAVE_GETHOSTBYNAME_R) + AC_DEFINE(HAVE_GETHOSTBYNAME_R_5_ARG, 1, + [Define this if you have the 5-arg version of gethostbyname_r().]) + AC_MSG_RESULT(yes) + ], [ + AC_MSG_RESULT(no) + AC_MSG_CHECKING([gethostbyname_r with 3 args]) + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ +# include + ]], [[ + char *name; + struct hostent *he; + struct hostent_data data; + + (void) gethostbyname_r(name, he, &data); + ]])], + [ + AC_DEFINE(HAVE_GETHOSTBYNAME_R) + AC_DEFINE(HAVE_GETHOSTBYNAME_R_3_ARG, 1, + [Define this if you have the 3-arg version of gethostbyname_r().]) + AC_MSG_RESULT(yes) + ], [ + AC_MSG_RESULT(no) + ]) + ]) + ]) + CFLAGS=$OLD_CFLAGS +], [ + AC_CHECK_FUNCS(gethostbyname) +]) +AC_SUBST(HAVE_GETHOSTBYNAME_R_6_ARG) +AC_SUBST(HAVE_GETHOSTBYNAME_R_5_ARG) +AC_SUBST(HAVE_GETHOSTBYNAME_R_3_ARG) +AC_SUBST(HAVE_GETHOSTBYNAME_R) +AC_SUBST(HAVE_GETHOSTBYNAME) + +# checks for system services +# (none yet) + +# Linux requires this for correct f.p. operations +AC_CHECK_FUNC(__fpu_control, + [], + [AC_CHECK_LIB(ieee, __fpu_control) +]) + +# Check for --with-fpectl +AC_MSG_CHECKING(for --with-fpectl) +AC_ARG_WITH(fpectl, + AS_HELP_STRING([--with-fpectl], [enable SIGFPE catching]), +[ +if test "$withval" != no +then + AC_DEFINE(WANT_SIGFPE_HANDLER, 1, + [Define if you want SIGFPE handled (see Include/pyfpe.h).]) + AC_MSG_RESULT(yes) +else AC_MSG_RESULT(no) +fi], +[AC_MSG_RESULT(no)]) + +# check for --with-libm=... +AC_SUBST(LIBM) +case $ac_sys_system in +Darwin) ;; +BeOS) ;; +*) LIBM=-lm +esac +AC_MSG_CHECKING(for --with-libm=STRING) +AC_ARG_WITH(libm, + AS_HELP_STRING([--with-libm=STRING], [math library]), +[ +if test "$withval" = no +then LIBM= + AC_MSG_RESULT(force LIBM empty) +elif test "$withval" != yes +then LIBM=$withval + AC_MSG_RESULT(set LIBM="$withval") +else AC_MSG_ERROR([proper usage is --with-libm=STRING]) +fi], +[AC_MSG_RESULT(default LIBM="$LIBM")]) + +# check for --with-libc=... +AC_SUBST(LIBC) +AC_MSG_CHECKING(for --with-libc=STRING) +AC_ARG_WITH(libc, + AS_HELP_STRING([--with-libc=STRING], [C library]), +[ +if test "$withval" = no +then LIBC= + AC_MSG_RESULT(force LIBC empty) +elif test "$withval" != yes +then LIBC=$withval + AC_MSG_RESULT(set LIBC="$withval") +else AC_MSG_ERROR([proper usage is --with-libc=STRING]) +fi], +[AC_MSG_RESULT(default LIBC="$LIBC")]) + +# ************************************************** +# * Check for various properties of floating point * +# ************************************************** + +AC_MSG_CHECKING(whether C doubles are little-endian IEEE 754 binary64) +AC_CACHE_VAL(ac_cv_little_endian_double, [ +AC_RUN_IFELSE([AC_LANG_SOURCE([[ +#include +int main() { + double x = 9006104071832581.0; + if (memcmp(&x, "\x05\x04\x03\x02\x01\xff\x3f\x43", 8) == 0) + return 0; + else + return 1; +} +]])], +[ac_cv_little_endian_double=yes], +[ac_cv_little_endian_double=no], +[ac_cv_little_endian_double=no])]) +AC_MSG_RESULT($ac_cv_little_endian_double) +if test "$ac_cv_little_endian_double" = yes +then + AC_DEFINE(DOUBLE_IS_LITTLE_ENDIAN_IEEE754, 1, + [Define if C doubles are 64-bit IEEE 754 binary format, stored + with the least significant byte first]) +fi + +AC_MSG_CHECKING(whether C doubles are big-endian IEEE 754 binary64) +AC_CACHE_VAL(ac_cv_big_endian_double, [ +AC_RUN_IFELSE([AC_LANG_SOURCE([[ +#include +int main() { + double x = 9006104071832581.0; + if (memcmp(&x, "\x43\x3f\xff\x01\x02\x03\x04\x05", 8) == 0) + return 0; + else + return 1; +} +]])], +[ac_cv_big_endian_double=yes], +[ac_cv_big_endian_double=no], +[ac_cv_big_endian_double=no])]) +AC_MSG_RESULT($ac_cv_big_endian_double) +if test "$ac_cv_big_endian_double" = yes +then + AC_DEFINE(DOUBLE_IS_BIG_ENDIAN_IEEE754, 1, + [Define if C doubles are 64-bit IEEE 754 binary format, stored + with the most significant byte first]) +fi + +# Some ARM platforms use a mixed-endian representation for doubles. +# While Python doesn't currently have full support for these platforms +# (see e.g., issue 1762561), we can at least make sure that float <-> string +# conversions work. +AC_MSG_CHECKING(whether C doubles are ARM mixed-endian IEEE 754 binary64) +AC_CACHE_VAL(ac_cv_mixed_endian_double, [ +AC_RUN_IFELSE([AC_LANG_SOURCE([[ +#include +int main() { + double x = 9006104071832581.0; + if (memcmp(&x, "\x01\xff\x3f\x43\x05\x04\x03\x02", 8) == 0) + return 0; + else + return 1; +} +]])], +[ac_cv_mixed_endian_double=yes], +[ac_cv_mixed_endian_double=no], +[ac_cv_mixed_endian_double=no])]) +AC_MSG_RESULT($ac_cv_mixed_endian_double) +if test "$ac_cv_mixed_endian_double" = yes +then + AC_DEFINE(DOUBLE_IS_ARM_MIXED_ENDIAN_IEEE754, 1, + [Define if C doubles are 64-bit IEEE 754 binary format, stored + in ARM mixed-endian order (byte order 45670123)]) +fi + +# The short float repr introduced in Python 3.1 requires the +# correctly-rounded string <-> double conversion functions from +# Python/dtoa.c, which in turn require that the FPU uses 53-bit +# rounding; this is a problem on x86, where the x87 FPU has a default +# rounding precision of 64 bits. For gcc/x86, we can fix this by +# using inline assembler to get and set the x87 FPU control word. + +# This inline assembler syntax may also work for suncc and icc, +# so we try it on all platforms. + +AC_MSG_CHECKING(whether we can use gcc inline assembler to get and set x87 control word) +AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[ + unsigned short cw; + __asm__ __volatile__ ("fnstcw %0" : "=m" (cw)); + __asm__ __volatile__ ("fldcw %0" : : "m" (cw)); +]])],[have_gcc_asm_for_x87=yes],[have_gcc_asm_for_x87=no]) +AC_MSG_RESULT($have_gcc_asm_for_x87) +if test "$have_gcc_asm_for_x87" = yes +then + AC_DEFINE(HAVE_GCC_ASM_FOR_X87, 1, + [Define if we can use gcc inline assembler to get and set x87 control word]) +fi + +# Detect whether system arithmetic is subject to x87-style double +# rounding issues. The result of this test has little meaning on non +# IEEE 754 platforms. On IEEE 754, test should return 1 if rounding +# mode is round-to-nearest and double rounding issues are present, and +# 0 otherwise. See http://bugs.python.org/issue2937 for more info. +AC_MSG_CHECKING(for x87-style double rounding) +# $BASECFLAGS may affect the result +ac_save_cc="$CC" +CC="$CC $BASECFLAGS" +AC_RUN_IFELSE([AC_LANG_SOURCE([[ +#include +#include +int main() { + volatile double x, y, z; + /* 1./(1-2**-53) -> 1+2**-52 (correct), 1.0 (double rounding) */ + x = 0.99999999999999989; /* 1-2**-53 */ + y = 1./x; + if (y != 1.) + exit(0); + /* 1e16+2.99999 -> 1e16+2. (correct), 1e16+4. (double rounding) */ + x = 1e16; + y = 2.99999; + z = x + y; + if (z != 1e16+4.) + exit(0); + /* both tests show evidence of double rounding */ + exit(1); +} +]])], +[ac_cv_x87_double_rounding=no], +[ac_cv_x87_double_rounding=yes], +[ac_cv_x87_double_rounding=no]) +CC="$ac_save_cc" +AC_MSG_RESULT($ac_cv_x87_double_rounding) +if test "$ac_cv_x87_double_rounding" = yes +then + AC_DEFINE(X87_DOUBLE_ROUNDING, 1, + [Define if arithmetic is subject to x87-style double rounding issue]) +fi + +# ************************************ +# * Check for mathematical functions * +# ************************************ + +LIBS_SAVE=$LIBS +LIBS="$LIBS $LIBM" + +# On FreeBSD 6.2, it appears that tanh(-0.) returns 0. instead of +# -0. on some architectures. +AC_MSG_CHECKING(whether tanh preserves the sign of zero) +AC_CACHE_VAL(ac_cv_tanh_preserves_zero_sign, [ +AC_RUN_IFELSE([AC_LANG_SOURCE([[ +#include +#include +int main() { + /* return 0 if either negative zeros don't exist + on this platform or if negative zeros exist + and tanh(-0.) == -0. */ + if (atan2(0., -1.) == atan2(-0., -1.) || + atan2(tanh(-0.), -1.) == atan2(-0., -1.)) exit(0); + else exit(1); +} +]])], +[ac_cv_tanh_preserves_zero_sign=yes], +[ac_cv_tanh_preserves_zero_sign=no], +[ac_cv_tanh_preserves_zero_sign=no])]) +AC_MSG_RESULT($ac_cv_tanh_preserves_zero_sign) +if test "$ac_cv_tanh_preserves_zero_sign" = yes +then + AC_DEFINE(TANH_PRESERVES_ZERO_SIGN, 1, + [Define if tanh(-0.) is -0., or if platform doesn't have signed zeros]) +fi + +AC_CHECK_FUNCS([acosh asinh atanh copysign erf erfc expm1 finite gamma]) +AC_CHECK_FUNCS([hypot lgamma log1p round tgamma]) +AC_CHECK_DECLS([isinf, isnan, isfinite], [], [], [[#include ]]) + +LIBS=$LIBS_SAVE + +# For multiprocessing module, check that sem_open +# actually works. For FreeBSD versions <= 7.2, +# the kernel module that provides POSIX semaphores +# isn't loaded by default, so an attempt to call +# sem_open results in a 'Signal 12' error. +AC_MSG_CHECKING(whether POSIX semaphores are enabled) +AC_CACHE_VAL(ac_cv_posix_semaphores_enabled, +AC_RUN_IFELSE([AC_LANG_SOURCE([[ +#include +#include +#include +#include +#include + +int main(void) { + sem_t *a = sem_open("/autoconf", O_CREAT, S_IRUSR|S_IWUSR, 0); + if (a == SEM_FAILED) { + perror("sem_open"); + return 1; + } + sem_close(a); + sem_unlink("/autoconf"); + return 0; +} +]])], +[ac_cv_posix_semaphores_enabled=yes], +[ac_cv_posix_semaphores_enabled=no], +[ac_cv_posix_semaphores_enabled=yes]) +) +AC_MSG_RESULT($ac_cv_posix_semaphores_enabled) +if test $ac_cv_posix_semaphores_enabled = no +then + AC_DEFINE(POSIX_SEMAPHORES_NOT_ENABLED, 1, + [Define if POSIX semaphores aren't enabled on your system]) +fi + +# Multiprocessing check for broken sem_getvalue +AC_MSG_CHECKING(for broken sem_getvalue) +AC_CACHE_VAL(ac_cv_broken_sem_getvalue, +AC_RUN_IFELSE([AC_LANG_SOURCE([[ +#include +#include +#include +#include +#include + +int main(void){ + sem_t *a = sem_open("/autocftw", O_CREAT, S_IRUSR|S_IWUSR, 0); + int count; + int res; + if(a==SEM_FAILED){ + perror("sem_open"); + return 1; + + } + res = sem_getvalue(a, &count); + sem_close(a); + sem_unlink("/autocftw"); + return res==-1 ? 1 : 0; +} +]])], +[ac_cv_broken_sem_getvalue=no], +[ac_cv_broken_sem_getvalue=yes], +[ac_cv_broken_sem_getvalue=yes]) +) +AC_MSG_RESULT($ac_cv_broken_sem_getvalue) +if test $ac_cv_broken_sem_getvalue = yes +then + AC_DEFINE(HAVE_BROKEN_SEM_GETVALUE, 1, + [define to 1 if your sem_getvalue is broken.]) +fi + +# determine what size digit to use for Python's longs +AC_MSG_CHECKING([digit size for Python's longs]) +AC_ARG_ENABLE(big-digits, +AS_HELP_STRING([--enable-big-digits@<:@=BITS@:>@],[use big digits for Python longs [[BITS=30]]]), +[case $enable_big_digits in +yes) + enable_big_digits=30 ;; +no) + enable_big_digits=15 ;; +[15|30]) + ;; +*) + AC_MSG_ERROR([bad value $enable_big_digits for --enable-big-digits; value should be 15 or 30]) ;; +esac +AC_MSG_RESULT($enable_big_digits) +AC_DEFINE_UNQUOTED(PYLONG_BITS_IN_DIGIT, $enable_big_digits, [Define as the preferred size in bits of long digits]) +], +[AC_MSG_RESULT(no value specified)]) + +# check for wchar.h +AC_CHECK_HEADER(wchar.h, [ + AC_DEFINE(HAVE_WCHAR_H, 1, + [Define if the compiler provides a wchar.h header file.]) + wchar_h="yes" +], +wchar_h="no" +) + +# determine wchar_t size +if test "$wchar_h" = yes +then + AC_CHECK_SIZEOF(wchar_t, 4, [#include ]) +fi + +AC_MSG_CHECKING(for UCS-4 tcl) +have_ucs4_tcl=no +AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ +#include +#if TCL_UTF_MAX != 6 +# error "NOT UCS4_TCL" +#endif]], [[]])],[ + AC_DEFINE(HAVE_UCS4_TCL, 1, [Define this if you have tcl and TCL_UTF_MAX==6]) + have_ucs4_tcl=yes +],[]) +AC_MSG_RESULT($have_ucs4_tcl) + +# check whether wchar_t is signed or not +if test "$wchar_h" = yes +then + # check whether wchar_t is signed or not + AC_MSG_CHECKING(whether wchar_t is signed) + AC_CACHE_VAL(ac_cv_wchar_t_signed, [ + AC_RUN_IFELSE([AC_LANG_SOURCE([[ + #include + int main() + { + /* Success: exit code 0 */ + exit((((wchar_t) -1) < ((wchar_t) 0)) ? 0 : 1); + } + ]])], + [ac_cv_wchar_t_signed=yes], + [ac_cv_wchar_t_signed=no], + [ac_cv_wchar_t_signed=yes])]) + AC_MSG_RESULT($ac_cv_wchar_t_signed) +fi + +AC_MSG_CHECKING(what type to use for unicode) +dnl quadrigraphs "@<:@" and "@:>@" produce "[" and "]" in the output +AC_ARG_ENABLE(unicode, + AS_HELP_STRING([--enable-unicode@<:@=ucs@<:@24@:>@@:>@], [Enable Unicode strings (default is ucs2)]), + [], + [enable_unicode=yes]) + +if test $enable_unicode = yes +then + # Without any arguments, Py_UNICODE defaults to two-byte mode + case "$have_ucs4_tcl" in + yes) enable_unicode="ucs4" + ;; + *) enable_unicode="ucs2" + ;; + esac +fi + +AH_TEMPLATE(Py_UNICODE_SIZE, + [Define as the size of the unicode type.]) +case "$enable_unicode" in +ucs2) unicode_size="2" + AC_DEFINE(Py_UNICODE_SIZE,2) + ;; +ucs4) unicode_size="4" + AC_DEFINE(Py_UNICODE_SIZE,4) + ;; +*) AC_MSG_ERROR([invalid value for --enable-unicode. Use either ucs2 or ucs4 (lowercase).]) ;; +esac + +AH_TEMPLATE(PY_UNICODE_TYPE, + [Define as the integral type used for Unicode representation.]) + +AC_SUBST(UNICODE_OBJS) +if test "$enable_unicode" = "no" +then + UNICODE_OBJS="" + AC_MSG_RESULT(not used) +else + UNICODE_OBJS="Objects/unicodeobject.o Objects/unicodectype.o" + AC_DEFINE(Py_USING_UNICODE, 1, + [Define if you want to have a Unicode type.]) + + # wchar_t is only usable if it maps to an unsigned type + if test "$unicode_size" = "$ac_cv_sizeof_wchar_t" \ + -a "$ac_cv_wchar_t_signed" = "no" + then + PY_UNICODE_TYPE="wchar_t" + AC_DEFINE(HAVE_USABLE_WCHAR_T, 1, + [Define if you have a useable wchar_t type defined in wchar.h; useable + means wchar_t must be an unsigned type with at least 16 bits. (see + Include/unicodeobject.h).]) + AC_DEFINE(PY_UNICODE_TYPE,wchar_t) + elif test "$ac_cv_sizeof_short" = "$unicode_size" + then + PY_UNICODE_TYPE="unsigned short" + AC_DEFINE(PY_UNICODE_TYPE,unsigned short) + elif test "$ac_cv_sizeof_long" = "$unicode_size" + then + PY_UNICODE_TYPE="unsigned long" + AC_DEFINE(PY_UNICODE_TYPE,unsigned long) + else + PY_UNICODE_TYPE="no type found" + fi + AC_MSG_RESULT($PY_UNICODE_TYPE) +fi + +# check for endianness +AC_C_BIGENDIAN + +# Check whether right shifting a negative integer extends the sign bit +# or fills with zeros (like the Cray J90, according to Tim Peters). +AC_MSG_CHECKING(whether right shift extends the sign bit) +AC_CACHE_VAL(ac_cv_rshift_extends_sign, [ +AC_RUN_IFELSE([AC_LANG_SOURCE([[ +int main() +{ + exit(((-1)>>3 == -1) ? 0 : 1); +} +]])], +[ac_cv_rshift_extends_sign=yes], +[ac_cv_rshift_extends_sign=no], +[ac_cv_rshift_extends_sign=yes])]) +AC_MSG_RESULT($ac_cv_rshift_extends_sign) +if test "$ac_cv_rshift_extends_sign" = no +then + AC_DEFINE(SIGNED_RIGHT_SHIFT_ZERO_FILLS, 1, + [Define if i>>j for signed int i does not extend the sign bit + when i < 0]) +fi + +# check for getc_unlocked and related locking functions +AC_MSG_CHECKING(for getc_unlocked() and friends) +AC_CACHE_VAL(ac_cv_have_getc_unlocked, [ +AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include ]], [[ + FILE *f = fopen("/dev/null", "r"); + flockfile(f); + getc_unlocked(f); + funlockfile(f); +]])],[ac_cv_have_getc_unlocked=yes],[ac_cv_have_getc_unlocked=no])]) +AC_MSG_RESULT($ac_cv_have_getc_unlocked) +if test "$ac_cv_have_getc_unlocked" = yes +then + AC_DEFINE(HAVE_GETC_UNLOCKED, 1, + [Define this if you have flockfile(), getc_unlocked(), and funlockfile()]) +fi + +# check where readline lives +# save the value of LIBS so we don't actually link Python with readline +LIBS_no_readline=$LIBS + +# On some systems we need to link readline to a termcap compatible +# library. NOTE: Keep the precedence of listed libraries synchronised +# with setup.py. +py_cv_lib_readline=no +AC_MSG_CHECKING([how to link readline libs]) +for py_libtermcap in "" ncursesw ncurses curses termcap; do + if test -z "$py_libtermcap"; then + READLINE_LIBS="-lreadline" + else + READLINE_LIBS="-lreadline -l$py_libtermcap" + fi + LIBS="$READLINE_LIBS $LIBS_no_readline" + AC_LINK_IFELSE( + [AC_LANG_CALL([],[readline])], + [py_cv_lib_readline=yes]) + if test $py_cv_lib_readline = yes; then + break + fi +done +# Uncomment this line if you want to use READINE_LIBS in Makefile or scripts +#AC_SUBST([READLINE_LIBS]) +if test $py_cv_lib_readline = no; then + AC_MSG_RESULT([none]) +else + AC_MSG_RESULT([$READLINE_LIBS]) + AC_DEFINE(HAVE_LIBREADLINE, 1, + [Define if you have the readline library (-lreadline).]) +fi + +# check for readline 2.1 +AC_CHECK_LIB(readline, rl_callback_handler_install, + AC_DEFINE(HAVE_RL_CALLBACK, 1, + [Define if you have readline 2.1]), ,$READLINE_LIBS) + +# check for readline 2.2 +AC_PREPROC_IFELSE([AC_LANG_SOURCE([[#include ]])], + [have_readline=yes], + [have_readline=no] +) +if test $have_readline = yes +then + AC_EGREP_HEADER([extern int rl_completion_append_character;], + [readline/readline.h], + AC_DEFINE(HAVE_RL_COMPLETION_APPEND_CHARACTER, 1, + [Define if you have readline 2.2]), ) + AC_EGREP_HEADER([extern int rl_completion_suppress_append;], + [readline/readline.h], + AC_DEFINE(HAVE_RL_COMPLETION_SUPPRESS_APPEND, 1, + [Define if you have rl_completion_suppress_append]), ) +fi + +# check for readline 4.0 +AC_CHECK_LIB(readline, rl_pre_input_hook, + AC_DEFINE(HAVE_RL_PRE_INPUT_HOOK, 1, + [Define if you have readline 4.0]), ,$READLINE_LIBS) + +# also in 4.0 +AC_CHECK_LIB(readline, rl_completion_display_matches_hook, + AC_DEFINE(HAVE_RL_COMPLETION_DISPLAY_MATCHES_HOOK, 1, + [Define if you have readline 4.0]), ,$READLINE_LIBS) + +# check for readline 4.2 +AC_CHECK_LIB(readline, rl_completion_matches, + AC_DEFINE(HAVE_RL_COMPLETION_MATCHES, 1, + [Define if you have readline 4.2]), ,$READLINE_LIBS) + +# also in readline 4.2 +AC_PREPROC_IFELSE([AC_LANG_SOURCE([[#include ]])], + [have_readline=yes], + [have_readline=no] +) +if test $have_readline = yes +then + AC_EGREP_HEADER([extern int rl_catch_signals;], + [readline/readline.h], + AC_DEFINE(HAVE_RL_CATCH_SIGNAL, 1, + [Define if you can turn off readline's signal handling.]), ) +fi + +# End of readline checks: restore LIBS +LIBS=$LIBS_no_readline + +AC_MSG_CHECKING(for broken nice()) +AC_CACHE_VAL(ac_cv_broken_nice, [ +AC_RUN_IFELSE([AC_LANG_SOURCE([[ +int main() +{ + int val1 = nice(1); + if (val1 != -1 && val1 == nice(2)) + exit(0); + exit(1); +} +]])], +[ac_cv_broken_nice=yes], +[ac_cv_broken_nice=no], +[ac_cv_broken_nice=no])]) +AC_MSG_RESULT($ac_cv_broken_nice) +if test "$ac_cv_broken_nice" = yes +then + AC_DEFINE(HAVE_BROKEN_NICE, 1, + [Define if nice() returns success/failure instead of the new priority.]) +fi + +AC_MSG_CHECKING(for broken poll()) +AC_CACHE_VAL(ac_cv_broken_poll, +AC_RUN_IFELSE([AC_LANG_SOURCE([[ +#include + +int main() +{ + struct pollfd poll_struct = { 42, POLLIN|POLLPRI|POLLOUT, 0 }; + int poll_test; + + close (42); + + poll_test = poll(&poll_struct, 1, 0); + if (poll_test < 0) + return 0; + else if (poll_test == 0 && poll_struct.revents != POLLNVAL) + return 0; + else + return 1; +} +]])], +[ac_cv_broken_poll=yes], +[ac_cv_broken_poll=no], +[ac_cv_broken_poll=no])) +AC_MSG_RESULT($ac_cv_broken_poll) +if test "$ac_cv_broken_poll" = yes +then + AC_DEFINE(HAVE_BROKEN_POLL, 1, + [Define if poll() sets errno on invalid file descriptors.]) +fi + +# Before we can test tzset, we need to check if struct tm has a tm_zone +# (which is not required by ISO C or UNIX spec) and/or if we support +# tzname[] +AC_STRUCT_TIMEZONE + +# check tzset(3) exists and works like we expect it to +AC_MSG_CHECKING(for working tzset()) +AC_CACHE_VAL(ac_cv_working_tzset, [ +AC_RUN_IFELSE([AC_LANG_SOURCE([[ +#include +#include +#include + +#if HAVE_TZNAME +extern char *tzname[]; +#endif + +int main() +{ + /* Note that we need to ensure that not only does tzset(3) + do 'something' with localtime, but it works as documented + in the library reference and as expected by the test suite. + This includes making sure that tzname is set properly if + tm->tm_zone does not exist since it is the alternative way + of getting timezone info. + + Red Hat 6.2 doesn't understand the southern hemisphere + after New Year's Day. + */ + + time_t groundhogday = 1044144000; /* GMT-based */ + time_t midyear = groundhogday + (365 * 24 * 3600 / 2); + + putenv("TZ=UTC+0"); + tzset(); + if (localtime(&groundhogday)->tm_hour != 0) + exit(1); +#if HAVE_TZNAME + /* For UTC, tzname[1] is sometimes "", sometimes " " */ + if (strcmp(tzname[0], "UTC") || + (tzname[1][0] != 0 && tzname[1][0] != ' ')) + exit(1); +#endif + + putenv("TZ=EST+5EDT,M4.1.0,M10.5.0"); + tzset(); + if (localtime(&groundhogday)->tm_hour != 19) + exit(1); +#if HAVE_TZNAME + if (strcmp(tzname[0], "EST") || strcmp(tzname[1], "EDT")) + exit(1); +#endif + + putenv("TZ=AEST-10AEDT-11,M10.5.0,M3.5.0"); + tzset(); + if (localtime(&groundhogday)->tm_hour != 11) + exit(1); +#if HAVE_TZNAME + if (strcmp(tzname[0], "AEST") || strcmp(tzname[1], "AEDT")) + exit(1); +#endif + +#if HAVE_STRUCT_TM_TM_ZONE + if (strcmp(localtime(&groundhogday)->tm_zone, "AEDT")) + exit(1); + if (strcmp(localtime(&midyear)->tm_zone, "AEST")) + exit(1); +#endif + + exit(0); +} +]])], +[ac_cv_working_tzset=yes], +[ac_cv_working_tzset=no], +[ac_cv_working_tzset=no])]) +AC_MSG_RESULT($ac_cv_working_tzset) +if test "$ac_cv_working_tzset" = yes +then + AC_DEFINE(HAVE_WORKING_TZSET, 1, + [Define if tzset() actually switches the local timezone in a meaningful way.]) +fi + +# Look for subsecond timestamps in struct stat +AC_MSG_CHECKING(for tv_nsec in struct stat) +AC_CACHE_VAL(ac_cv_stat_tv_nsec, +AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include ]], [[ +struct stat st; +st.st_mtim.tv_nsec = 1; +]])], +[ac_cv_stat_tv_nsec=yes], +[ac_cv_stat_tv_nsec=no])) +AC_MSG_RESULT($ac_cv_stat_tv_nsec) +if test "$ac_cv_stat_tv_nsec" = yes +then + AC_DEFINE(HAVE_STAT_TV_NSEC, 1, + [Define if you have struct stat.st_mtim.tv_nsec]) +fi + +# Look for BSD style subsecond timestamps in struct stat +AC_MSG_CHECKING(for tv_nsec2 in struct stat) +AC_CACHE_VAL(ac_cv_stat_tv_nsec2, +AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include ]], [[ +struct stat st; +st.st_mtimespec.tv_nsec = 1; +]])], +[ac_cv_stat_tv_nsec2=yes], +[ac_cv_stat_tv_nsec2=no])) +AC_MSG_RESULT($ac_cv_stat_tv_nsec2) +if test "$ac_cv_stat_tv_nsec2" = yes +then + AC_DEFINE(HAVE_STAT_TV_NSEC2, 1, + [Define if you have struct stat.st_mtimensec]) +fi + +# On HP/UX 11.0, mvwdelch is a block with a return statement +AC_MSG_CHECKING(whether mvwdelch is an expression) +AC_CACHE_VAL(ac_cv_mvwdelch_is_expression, +AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include ]], [[ + int rtn; + rtn = mvwdelch(0,0,0); +]])], +[ac_cv_mvwdelch_is_expression=yes], +[ac_cv_mvwdelch_is_expression=no])) +AC_MSG_RESULT($ac_cv_mvwdelch_is_expression) + +if test "$ac_cv_mvwdelch_is_expression" = yes +then + AC_DEFINE(MVWDELCH_IS_EXPRESSION, 1, + [Define if mvwdelch in curses.h is an expression.]) +fi + +AC_MSG_CHECKING(whether WINDOW has _flags) +AC_CACHE_VAL(ac_cv_window_has_flags, +AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include ]], [[ + WINDOW *w; + w->_flags = 0; +]])], +[ac_cv_window_has_flags=yes], +[ac_cv_window_has_flags=no])) +AC_MSG_RESULT($ac_cv_window_has_flags) + + +if test "$ac_cv_window_has_flags" = yes +then + AC_DEFINE(WINDOW_HAS_FLAGS, 1, + [Define if WINDOW in curses.h offers a field _flags.]) +fi + +AC_MSG_CHECKING(for is_term_resized) +AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include ]], [[void *x=is_term_resized]])], + [AC_DEFINE(HAVE_CURSES_IS_TERM_RESIZED, 1, Define if you have the 'is_term_resized' function.) + AC_MSG_RESULT(yes)], + [AC_MSG_RESULT(no)] +) + +AC_MSG_CHECKING(for resize_term) +AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include ]], [[void *x=resize_term]])], + [AC_DEFINE(HAVE_CURSES_RESIZE_TERM, 1, Define if you have the 'resize_term' function.) + AC_MSG_RESULT(yes)], + [AC_MSG_RESULT(no)] +) + +AC_MSG_CHECKING(for resizeterm) +AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include ]], [[void *x=resizeterm]])], + [AC_DEFINE(HAVE_CURSES_RESIZETERM, 1, Define if you have the 'resizeterm' function.) + AC_MSG_RESULT(yes)], + [AC_MSG_RESULT(no)] +) + +AC_MSG_CHECKING(for /dev/ptmx) + +if test -r /dev/ptmx +then + AC_MSG_RESULT(yes) + AC_DEFINE(HAVE_DEV_PTMX, 1, + [Define if we have /dev/ptmx.]) +else + AC_MSG_RESULT(no) +fi + +AC_MSG_CHECKING(for /dev/ptc) + +if test -r /dev/ptc +then + AC_MSG_RESULT(yes) + AC_DEFINE(HAVE_DEV_PTC, 1, + [Define if we have /dev/ptc.]) +else + AC_MSG_RESULT(no) +fi + +if test "$have_long_long" = yes +then + AC_MSG_CHECKING(for %lld and %llu printf() format support) + AC_CACHE_VAL(ac_cv_have_long_long_format, + AC_RUN_IFELSE([AC_LANG_SOURCE([[[ + #include + #include + #include + + #ifdef HAVE_SYS_TYPES_H + #include + #endif + + int main() + { + char buffer[256]; + + if (sprintf(buffer, "%lld", (long long)123) < 0) + return 1; + if (strcmp(buffer, "123")) + return 1; + + if (sprintf(buffer, "%lld", (long long)-123) < 0) + return 1; + if (strcmp(buffer, "-123")) + return 1; + + if (sprintf(buffer, "%llu", (unsigned long long)123) < 0) + return 1; + if (strcmp(buffer, "123")) + return 1; + + return 0; + } + ]]])], + [ac_cv_have_long_long_format=yes], + [ac_cv_have_long_long_format=no], + [ac_cv_have_long_long_format=no]) + ) + AC_MSG_RESULT($ac_cv_have_long_long_format) +fi + +if test "$ac_cv_have_long_long_format" = yes +then + AC_DEFINE(PY_FORMAT_LONG_LONG, "ll", + [Define to printf format modifier for long long type]) +fi + +if test $ac_sys_system = Darwin +then + LIBS="$LIBS -framework CoreFoundation" +fi + + +AC_CACHE_CHECK([for %zd printf() format support], ac_cv_have_size_t_format, [dnl +AC_RUN_IFELSE([AC_LANG_SOURCE([[ +#include +#include +#include + +#ifdef HAVE_SYS_TYPES_H +#include +#endif + +#ifdef HAVE_SSIZE_T +typedef ssize_t Py_ssize_t; +#elif SIZEOF_VOID_P == SIZEOF_LONG +typedef long Py_ssize_t; +#else +typedef int Py_ssize_t; +#endif + +int main() +{ + char buffer[256]; + + if(sprintf(buffer, "%zd", (size_t)123) < 0) + return 1; + + if (strcmp(buffer, "123")) + return 1; + + if (sprintf(buffer, "%zd", (Py_ssize_t)-123) < 0) + return 1; + + if (strcmp(buffer, "-123")) + return 1; + + return 0; +} +]])], +[ac_cv_have_size_t_format=yes], +[ac_cv_have_size_t_format=no], +[ac_cv_have_size_t_format="cross -- assuming yes" +])]) +if test "$ac_cv_have_size_t_format" != no ; then + AC_DEFINE(PY_FORMAT_SIZE_T, "z", + [Define to printf format modifier for Py_ssize_t]) +fi + +AC_CHECK_TYPE(socklen_t,, + AC_DEFINE(socklen_t,int, + [Define to `int' if does not define.]),[ +#ifdef HAVE_SYS_TYPES_H +#include +#endif +#ifdef HAVE_SYS_SOCKET_H +#include +#endif +]) + +case $ac_sys_system in +AIX*) + AC_DEFINE(HAVE_BROKEN_PIPE_BUF, 1, [Define if the system reports an invalid PIPE_BUF value.]) ;; +esac + + +AC_SUBST(THREADHEADERS) + +for h in `(cd $srcdir;echo Python/thread_*.h)` +do + THREADHEADERS="$THREADHEADERS \$(srcdir)/$h" +done + +AC_SUBST(SRCDIRS) +SRCDIRS="Parser Grammar Objects Python Modules Mac" +AC_MSG_CHECKING(for build directories) +for dir in $SRCDIRS; do + if test ! -d $dir; then + mkdir $dir + fi +done +AC_MSG_RESULT(done) + +# generate output files +AC_CONFIG_FILES(Makefile.pre Modules/Setup.config Misc/python.pc) +AC_CONFIG_FILES([Modules/ld_so_aix], [chmod +x Modules/ld_so_aix]) +AC_OUTPUT + +echo "creating Modules/Setup" +if test ! -f Modules/Setup +then + cp $srcdir/Modules/Setup.dist Modules/Setup +fi + +echo "creating Modules/Setup.local" +if test ! -f Modules/Setup.local +then + echo "# Edit this file for local setup changes" >Modules/Setup.local +fi + +echo "creating Makefile" +$SHELL $srcdir/Modules/makesetup -c $srcdir/Modules/config.c.in \ + -s Modules Modules/Setup.config \ + Modules/Setup.local Modules/Setup + +case $ac_sys_system in +BeOS) + AC_MSG_WARN([ + + Support for BeOS is deprecated as of Python 2.6. + See PEP 11 for the gory details. + ]) + ;; +*) ;; +esac + +mv config.c Modules diff -r 9cd3ab7c09d1 -r 9ac347a7f375 pyconfig.h.in --- a/pyconfig.h.in Sat Jul 19 16:34:33 2014 -0700 +++ b/pyconfig.h.in Sun Jul 20 10:52:46 2014 -0400 @@ -1,4 +1,4 @@ -/* pyconfig.h.in. Generated from configure.ac by autoheader. */ +/* pyconfig.h.in. Generated from configure.in by autoheader. */ #ifndef Py_PYCONFIG_H @@ -55,9 +55,6 @@ /* Define to 1 if you have the `alarm' function. */ #undef HAVE_ALARM -/* Define to 1 if you have the header file. */ -#undef HAVE_ALLOCA_H - /* Define this if your time.h defines altzone. */ #undef HAVE_ALTZONE @@ -164,10 +161,10 @@ /* Define to 1 if you have the device macros. */ #undef HAVE_DEVICE_MACROS -/* Define to 1 if you have the /dev/ptc device file. */ +/* Define if we have /dev/ptc. */ #undef HAVE_DEV_PTC -/* Define to 1 if you have the /dev/ptmx device file. */ +/* Define if we have /dev/ptmx. */ #undef HAVE_DEV_PTMX /* Define to 1 if you have the header file. */ @@ -373,12 +370,6 @@ /* Define to 1 if you have the `initgroups' function. */ #undef HAVE_INITGROUPS -/* Define if your compiler provides int32_t. */ -#undef HAVE_INT32_T - -/* Define if your compiler provides int64_t. */ -#undef HAVE_INT64_T - /* Define to 1 if you have the header file. */ #undef HAVE_INTTYPES_H @@ -475,9 +466,6 @@ /* Define to 1 if you have the `mktime' function. */ #undef HAVE_MKTIME -/* Define to 1 if you have the `mmap' function. */ -#undef HAVE_MMAP - /* Define to 1 if you have the `mremap' function. */ #undef HAVE_MREMAP @@ -523,9 +511,6 @@ /* Define if you have GNU PTH threads. */ #undef HAVE_PTH -/* Define to 1 if you have the `pthread_atfork' function. */ -#undef HAVE_PTHREAD_ATFORK - /* Defined for Solaris 2.6 bug in pthread header. */ #undef HAVE_PTHREAD_DESTRUCTOR @@ -862,12 +847,6 @@ /* Define this if you have tcl and TCL_UTF_MAX==6 */ #undef HAVE_UCS4_TCL -/* Define if your compiler provides uint32_t. */ -#undef HAVE_UINT32_T - -/* Define if your compiler provides uint64_t. */ -#undef HAVE_UINT64_T - /* Define to 1 if the system has the type `uintptr_t'. */ #undef HAVE_UINTPTR_T diff -r 9cd3ab7c09d1 -r 9ac347a7f375 setup.py --- a/setup.py Sat Jul 19 16:34:33 2014 -0700 +++ b/setup.py Sun Jul 20 10:52:46 2014 -0400 @@ -17,20 +17,8 @@ from distutils.command.install_lib import install_lib from distutils.spawn import find_executable -cross_compiling = "_PYTHON_HOST_PLATFORM" in os.environ - -def get_platform(): - # cross build - if "_PYTHON_HOST_PLATFORM" in os.environ: - return os.environ["_PYTHON_HOST_PLATFORM"] - # Get value of sys.platform - if sys.platform.startswith('osf1'): - return 'osf1' - return sys.platform -host_platform = get_platform() - # Were we compiled --with-pydebug or with #define Py_DEBUG? -COMPILED_WITH_PYDEBUG = ('--with-pydebug' in sysconfig.get_config_var("CONFIG_ARGS")) +COMPILED_WITH_PYDEBUG = hasattr(sys, 'gettotalrefcount') # This global variable is used to hold the list of modules to be disabled. disabled_module_list = [] @@ -59,9 +47,7 @@ """ Returns True if 'path' can be located in an OSX SDK """ - return ( (path.startswith('/usr/') and not path.startswith('/usr/local')) - or path.startswith('/System/') - or path.startswith('/Library/') ) + return (path.startswith('/usr/') and not path.startswith('/usr/local')) or path.startswith('/System/') def find_file(filename, std_dirs, paths): """Searches for the directory where a given file is located, @@ -74,7 +60,7 @@ 'paths' is a list of additional locations to check; if the file is found in one of them, the resulting list will contain the directory. """ - if host_platform == 'darwin': + if sys.platform == 'darwin': # Honor the MacOSX SDK setting when one was specified. # An SDK is a directory with the same structure as a real # system, but with only header files and libraries. @@ -84,7 +70,7 @@ for dir in std_dirs: f = os.path.join(dir, filename) - if host_platform == 'darwin' and is_macosx_sdk_path(dir): + if sys.platform == 'darwin' and is_macosx_sdk_path(dir): f = os.path.join(sysroot, dir[1:], filename) if os.path.exists(f): return [] @@ -93,7 +79,7 @@ for dir in paths: f = os.path.join(dir, filename) - if host_platform == 'darwin' and is_macosx_sdk_path(dir): + if sys.platform == 'darwin' and is_macosx_sdk_path(dir): f = os.path.join(sysroot, dir[1:], filename) if os.path.exists(f): @@ -107,7 +93,7 @@ if result is None: return None - if host_platform == 'darwin': + if sys.platform == 'darwin': sysroot = macosx_sdk_root() # Check whether the found file is in one of the standard directories @@ -116,7 +102,7 @@ # Ensure path doesn't end with path separator p = p.rstrip(os.sep) - if host_platform == 'darwin' and is_macosx_sdk_path(p): + if sys.platform == 'darwin' and is_macosx_sdk_path(p): if os.path.join(sysroot, p[1:]) == dirname: return [ ] @@ -129,7 +115,7 @@ # Ensure path doesn't end with path separator p = p.rstrip(os.sep) - if host_platform == 'darwin' and is_macosx_sdk_path(p): + if sys.platform == 'darwin' and is_macosx_sdk_path(p): if os.path.join(sysroot, p[1:]) == dirname: return [ p ] @@ -186,8 +172,8 @@ # Platform-dependent module source and include directories incdirlist = [] - - if host_platform == 'darwin' and ("--disable-toolbox-glue" not in + platform = self.get_platform() + if platform == 'darwin' and ("--disable-toolbox-glue" not in sysconfig.get_config_var("CONFIG_ARGS")): # Mac OS X also includes some mac-specific modules macmoddir = os.path.join(srcdir, 'Mac/Modules') @@ -200,7 +186,7 @@ # Python header files headers = [sysconfig.get_config_h_filename()] - headers += glob(os.path.join(sysconfig.get_path('include'), "*.h")) + headers += glob(os.path.join(sysconfig.get_path('platinclude'), "*.h")) for ext in self.extensions[:]: ext.sources = [ find_module_file(filename, moddirlist) for filename in ext.sources ] @@ -300,7 +286,7 @@ ext.name) return - if host_platform == 'darwin' and ( + if self.get_platform() == 'darwin' and ( sys.maxint > 2**32 and '-arch' in ext.extra_link_args): # Don't bother doing an import check when an extension was # build with an explicit '-arch' flag on OSX. That's currently @@ -314,18 +300,13 @@ # Workaround for Cygwin: Cygwin currently has fork issues when many # modules have been imported - if host_platform == 'cygwin': + if self.get_platform() == 'cygwin': self.announce('WARNING: skipping import check for Cygwin-based "%s"' % ext.name) return ext_filename = os.path.join( self.build_lib, self.get_ext_filename(self.get_ext_fullname(ext.name))) - - # Don't try to load extensions for cross builds - if cross_compiling: - return - try: imp.load_dynamic(ext.name, ext_filename) except ImportError, why: @@ -357,41 +338,24 @@ level=3) self.failed.append(ext.name) + def get_platform(self): + # Get value of sys.platform + for platform in ['cygwin', 'beos', 'darwin', 'atheos', 'osf1']: + if sys.platform.startswith(platform): + return platform + return sys.platform + def add_multiarch_paths(self): # Debian/Ubuntu multiarch support. # https://wiki.ubuntu.com/MultiarchSpec - cc = sysconfig.get_config_var('CC') + if not find_executable('dpkg-architecture'): + return tmpfile = os.path.join(self.build_temp, 'multiarch') if not os.path.exists(self.build_temp): os.makedirs(self.build_temp) ret = os.system( - '%s -print-multiarch > %s 2> /dev/null' % (cc, tmpfile)) - multiarch_path_component = '' - try: - if ret >> 8 == 0: - with open(tmpfile) as fp: - multiarch_path_component = fp.readline().strip() - finally: - os.unlink(tmpfile) - - if multiarch_path_component != '': - add_dir_to_list(self.compiler.library_dirs, - '/usr/lib/' + multiarch_path_component) - add_dir_to_list(self.compiler.include_dirs, - '/usr/include/' + multiarch_path_component) - return - - if not find_executable('dpkg-architecture'): - return - opt = '' - if cross_compiling: - opt = '-t' + sysconfig.get_config_var('HOST_GNU_TYPE') - tmpfile = os.path.join(self.build_temp, 'multiarch') - if not os.path.exists(self.build_temp): - os.makedirs(self.build_temp) - ret = os.system( - 'dpkg-architecture %s -qDEB_HOST_MULTIARCH > %s 2> /dev/null' % - (opt, tmpfile)) + 'dpkg-architecture -qDEB_HOST_MULTIARCH > %s 2> /dev/null' % + tmpfile) try: if ret >> 8 == 0: with open(tmpfile) as fp: @@ -403,45 +367,10 @@ finally: os.unlink(tmpfile) - def add_gcc_paths(self): - gcc = sysconfig.get_config_var('CC') - tmpfile = os.path.join(self.build_temp, 'gccpaths') - if not os.path.exists(self.build_temp): - os.makedirs(self.build_temp) - ret = os.system('%s -E -v - %s 1>/dev/null' % (gcc, tmpfile)) - is_gcc = False - in_incdirs = False - inc_dirs = [] - lib_dirs = [] - try: - if ret >> 8 == 0: - with open(tmpfile) as fp: - for line in fp.readlines(): - if line.startswith("gcc version"): - is_gcc = True - elif line.startswith("#include <...>"): - in_incdirs = True - elif line.startswith("End of search list"): - in_incdirs = False - elif is_gcc and line.startswith("LIBRARY_PATH"): - for d in line.strip().split("=")[1].split(":"): - d = os.path.normpath(d) - if '/gcc/' not in d: - add_dir_to_list(self.compiler.library_dirs, - d) - elif is_gcc and in_incdirs and '/gcc/' not in line: - add_dir_to_list(self.compiler.include_dirs, - line.strip()) - finally: - os.unlink(tmpfile) - def detect_modules(self): # Ensure that /usr/local is always used - if not cross_compiling: - add_dir_to_list(self.compiler.library_dirs, '/usr/local/lib') - add_dir_to_list(self.compiler.include_dirs, '/usr/local/include') - if cross_compiling: - self.add_gcc_paths() + add_dir_to_list(self.compiler.library_dirs, '/usr/local/lib') + add_dir_to_list(self.compiler.include_dirs, '/usr/local/include') self.add_multiarch_paths() # Add paths specified in the environment variables LDFLAGS and @@ -497,42 +426,32 @@ # lib_dirs and inc_dirs are used to search for files; # if a file is found in one of those directories, it can # be assumed that no additional -I,-L directives are needed. - inc_dirs = self.compiler.include_dirs[:] - lib_dirs = self.compiler.library_dirs[:] - if not cross_compiling: - for d in ( - '/usr/include', - ): - add_dir_to_list(inc_dirs, d) - for d in ( - '/lib64', '/usr/lib64', - '/lib', '/usr/lib', - ): - add_dir_to_list(lib_dirs, d) + lib_dirs = self.compiler.library_dirs + [ + '/lib64', '/usr/lib64', + '/lib', '/usr/lib', + ] + inc_dirs = self.compiler.include_dirs + ['/usr/include'] exts = [] missing = [] config_h = sysconfig.get_config_h_filename() config_h_vars = sysconfig.parse_config_h(open(config_h)) + platform = self.get_platform() srcdir = sysconfig.get_config_var('srcdir') # Check for AtheOS which has libraries in non-standard locations - if host_platform == 'atheos': + if platform == 'atheos': lib_dirs += ['/system/libs', '/atheos/autolnk/lib'] lib_dirs += os.getenv('LIBRARY_PATH', '').split(os.pathsep) inc_dirs += ['/system/include', '/atheos/autolnk/include'] inc_dirs += os.getenv('C_INCLUDE_PATH', '').split(os.pathsep) # OSF/1 and Unixware have some stuff in /usr/ccs/lib (like -ldb) - if host_platform in ['osf1', 'unixware7', 'openunix8']: + if platform in ['osf1', 'unixware7', 'openunix8']: lib_dirs += ['/usr/ccs/lib'] - # HP-UX11iv3 keeps files in lib/hpux folders. - if host_platform == 'hp-ux11': - lib_dirs += ['/usr/lib/hpux64', '/usr/lib/hpux32'] - - if host_platform == 'darwin': + if platform == 'darwin': # This should work on any unixy platform ;-) # If the user has bothered specifying additional -I and -L flags # in OPT and LDFLAGS we might as well use them here. @@ -551,7 +470,7 @@ # Check for MacOS X, which doesn't need libm.a at all math_libs = ['m'] - if host_platform in ['darwin', 'beos']: + if platform in ['darwin', 'beos']: math_libs = [] # XXX Omitted modules: gl, pure, dl, SGI-specific modules @@ -623,7 +542,7 @@ locale_libs = ['intl'] else: locale_libs = [] - if host_platform == 'darwin': + if platform == 'darwin': locale_extra_link_args = ['-framework', 'CoreFoundation'] else: locale_extra_link_args = [] @@ -665,7 +584,7 @@ exts.append( Extension('cPickle', ['cPickle.c']) ) # Memory-mapped files (also works on Win32). - if host_platform not in ['atheos']: + if platform not in ['atheos']: exts.append( Extension('mmap', ['mmapmodule.c']) ) else: missing.append('mmap') @@ -730,12 +649,10 @@ elif self.compiler.find_library_file(lib_dirs, 'curses'): curses_library = 'curses' - if host_platform == 'darwin': + if platform == 'darwin': os_release = int(os.uname()[2].split('.')[0]) dep_target = sysconfig.get_config_var('MACOSX_DEPLOYMENT_TARGET') - if (dep_target and - (tuple(int(n) for n in dep_target.split('.')[0:2]) - < (10, 5) ) ): + if dep_target and dep_target.split('.') < ['10', '5']: os_release = 8 if os_release < 9: # MacOSX 10.4 has a broken readline. Don't try to build @@ -744,7 +661,7 @@ if find_file('readline/rlconf.h', inc_dirs, []) is None: do_readline = False if do_readline: - if host_platform == 'darwin' and os_release < 9: + if platform == 'darwin' and os_release < 9: # In every directory on the search path search for a dynamic # library and then a static library, instead of first looking # for dynamic libraries on the entiry path. @@ -782,9 +699,8 @@ exts.append( Extension('_csv', ['_csv.c']) ) # socket(2) - exts.append( Extension('_socket', ['socketmodule.c', 'timemodule.c'], - depends=['socketmodule.h'], - libraries=math_libs) ) + exts.append( Extension('_socket', ['socketmodule.c'], + depends = ['socketmodule.h']) ) # Detect SSL support for the socket module (via _ssl) search_for_ssl_incs_in = [ '/usr/local/ssl/include', @@ -823,7 +739,7 @@ inc_dirs + search_for_ssl_incs_in) if opensslv_h: name = os.path.join(opensslv_h[0], 'openssl/opensslv.h') - if host_platform == 'darwin' and is_macosx_sdk_path(name): + if sys.platform == 'darwin' and is_macosx_sdk_path(name): name = os.path.join(macosx_sdk_root(), name[1:]) try: incfile = open(name, 'r') @@ -883,8 +799,8 @@ # a release. Most open source OSes come with one or more # versions of BerkeleyDB already installed. - max_db_ver = (5, 3) - min_db_ver = (4, 3) + max_db_ver = (4, 8) + min_db_ver = (4, 1) db_setup_debug = False # verbose debug prints from this script? def allow_db_ver(db_ver): @@ -905,12 +821,8 @@ return True def gen_db_minor_ver_nums(major): - if major == 5: + if major == 4: for x in range(max_db_ver[1]+1): - if allow_db_ver((5, x)): - yield x - elif major == 4: - for x in range(9): if allow_db_ver((4, x)): yield x elif major == 3: @@ -951,9 +863,6 @@ db_inc_paths.append('/pkg/db-3.%d/include' % x) db_inc_paths.append('/opt/db-3.%d/include' % x) - if cross_compiling: - db_inc_paths = [] - # Add some common subdirectories for Sleepycat DB to the list, # based on the standard include directories. This way DB3/4 gets # picked up when it is installed in a non-standard prefix and @@ -974,7 +883,7 @@ db_ver_inc_map = {} - if host_platform == 'darwin': + if sys.platform == 'darwin': sysroot = macosx_sdk_root() class db_found(Exception): pass @@ -984,7 +893,7 @@ for d in inc_dirs + db_inc_paths: f = os.path.join(d, "db.h") - if host_platform == 'darwin' and is_macosx_sdk_path(d): + if sys.platform == 'darwin' and is_macosx_sdk_path(d): f = os.path.join(sysroot, d[1:], "db.h") if db_setup_debug: print "db: looking for db.h in", f @@ -1034,7 +943,7 @@ db_incdir.replace("include", 'lib'), ] - if host_platform != 'darwin': + if sys.platform != 'darwin': db_dirs_to_check = filter(os.path.isdir, db_dirs_to_check) else: @@ -1102,8 +1011,6 @@ '/usr/local/include/sqlite', '/usr/local/include/sqlite3', ] - if cross_compiling: - sqlite_inc_paths = [] MIN_SQLITE_VERSION_NUMBER = (3, 0, 8) MIN_SQLITE_VERSION = ".".join([str(x) for x in MIN_SQLITE_VERSION_NUMBER]) @@ -1111,20 +1018,20 @@ # Scan the default include directories before the SQLite specific # ones. This allows one to override the copy of sqlite on OSX, # where /usr/include contains an old version of sqlite. - if host_platform == 'darwin': + if sys.platform == 'darwin': sysroot = macosx_sdk_root() - for d_ in inc_dirs + sqlite_inc_paths: - d = d_ - if host_platform == 'darwin' and is_macosx_sdk_path(d): - d = os.path.join(sysroot, d[1:]) + for d in inc_dirs + sqlite_inc_paths: + f = os.path.join(d, "sqlite3.h") - f = os.path.join(d, "sqlite3.h") + if sys.platform == 'darwin' and is_macosx_sdk_path(d): + f = os.path.join(sysroot, d[1:], "sqlite3.h") + if os.path.exists(f): if sqlite_setup_debug: print "sqlite: found %s"%f incf = open(f).read() m = re.search( - r'\s*.*#\s*.*define\s.*SQLITE_VERSION\W*"([\d\.]*)"', incf) + r'\s*.*#\s*.*define\s.*SQLITE_VERSION\W*"(.*)"', incf) if m: sqlite_version = m.group(1) sqlite_version_tuple = tuple([int(x) @@ -1166,7 +1073,7 @@ '_sqlite/util.c', ] sqlite_defines = [] - if host_platform != "win32": + if sys.platform != "win32": sqlite_defines.append(('MODULE_NAME', '"sqlite3"')) else: sqlite_defines.append(('MODULE_NAME', '\\"sqlite3\\"')) @@ -1174,7 +1081,7 @@ # Comment this out if you want the sqlite3 module to be able to load extensions. sqlite_defines.append(("SQLITE_OMIT_LOAD_EXTENSION", "1")) - if host_platform == 'darwin': + if sys.platform == 'darwin': # In every directory on the search path search for a dynamic # library and then a static library, instead of first looking # for dynamic libraries on the entire path. @@ -1189,6 +1096,7 @@ include_dirs=["Modules/_sqlite", sqlite_incdir], library_dirs=sqlite_libdir, + runtime_library_dirs=sqlite_libdir, extra_link_args=sqlite_extra_link_args, libraries=["sqlite3",])) else: @@ -1207,7 +1115,7 @@ # when attempting to compile and it will fail. f = "/usr/include/db.h" - if host_platform == 'darwin': + if sys.platform == 'darwin': if is_macosx_sdk_path(f): sysroot = macosx_sdk_root() f = os.path.join(sysroot, f[1:]) @@ -1220,7 +1128,7 @@ ### XXX this should be fixed to not be platform-dependent ### but I don't have direct access to an osf1 platform and ### seemed to be muffing the search somehow - libraries = host_platform == "osf1" and ['db'] or None + libraries = platform == "osf1" and ['db'] or None if libraries is not None: exts.append(Extension('bsddb185', ['bsddbmodule.c'], libraries=libraries)) @@ -1233,7 +1141,7 @@ dbm_order = ['gdbm'] # The standard Unix dbm module: - if host_platform not in ['cygwin']: + if platform not in ['cygwin']: config_args = [arg.strip("'") for arg in sysconfig.get_config_var("CONFIG_ARGS").split()] dbm_args = [arg for arg in config_args @@ -1246,14 +1154,10 @@ for cand in dbm_order: if cand == "ndbm": if find_file("ndbm.h", inc_dirs, []) is not None: - # Some systems have -lndbm, others have -lgdbm_compat, - # others don't have either + # Some systems have -lndbm, others don't if self.compiler.find_library_file(lib_dirs, 'ndbm'): ndbm_libs = ['ndbm'] - elif self.compiler.find_library_file(lib_dirs, - 'gdbm_compat'): - ndbm_libs = ['gdbm_compat'] else: ndbm_libs = [] print "building dbm using ndbm" @@ -1315,17 +1219,17 @@ missing.append('gdbm') # Unix-only modules - if host_platform not in ['win32']: + if platform not in ['win32']: # Steen Lumholt's termios module exts.append( Extension('termios', ['termios.c']) ) # Jeremy Hylton's rlimit interface - if host_platform not in ['atheos']: + if platform not in ['atheos']: exts.append( Extension('resource', ['resource.c']) ) else: missing.append('resource') # Sun yellow pages. Some systems have the functions in libc. - if (host_platform not in ['cygwin', 'atheos', 'qnx6'] and + if (platform not in ['cygwin', 'atheos', 'qnx6'] and find_file('rpcsvc/yp_prot.h', inc_dirs, []) is not None): if (self.compiler.find_library_file(lib_dirs, 'nsl')): libs = ['nsl'] @@ -1341,19 +1245,15 @@ # Curses support, requiring the System V version of curses, often # provided by the ncurses library. panel_library = 'panel' - curses_incs = None if curses_library.startswith('ncurses'): if curses_library == 'ncursesw': # Bug 1464056: If _curses.so links with ncursesw, # _curses_panel.so must link with panelw. panel_library = 'panelw' curses_libs = [curses_library] - curses_incs = find_file('curses.h', inc_dirs, - [os.path.join(d, 'ncursesw') for d in inc_dirs]) exts.append( Extension('_curses', ['_cursesmodule.c'], - include_dirs = curses_incs, libraries = curses_libs) ) - elif curses_library == 'curses' and host_platform != 'darwin': + elif curses_library == 'curses' and platform != 'darwin': # OSX has an old Berkeley curses, not good enough for # the _curses module. if (self.compiler.find_library_file(lib_dirs, 'terminfo')): @@ -1372,7 +1272,6 @@ if (module_enabled(exts, '_curses') and self.compiler.find_library_file(lib_dirs, panel_library)): exts.append( Extension('_curses_panel', ['_curses_panel.c'], - include_dirs = curses_incs, libraries = [panel_library] + curses_libs) ) else: missing.append('_curses_panel') @@ -1395,8 +1294,6 @@ zlib_h = zlib_inc[0] + '/zlib.h' version = '"0.0.0"' version_req = '"1.1.3"' - if host_platform == 'darwin' and is_macosx_sdk_path(zlib_h): - zlib_h = os.path.join(macosx_sdk_root(), zlib_h[1:]) fp = open(zlib_h) while 1: line = fp.readline() @@ -1407,7 +1304,7 @@ break if version >= version_req: if (self.compiler.find_library_file(lib_dirs, 'z')): - if host_platform == "darwin": + if sys.platform == "darwin": zlib_extra_link_args = ('-Wl,-search_paths_first',) else: zlib_extra_link_args = () @@ -1439,7 +1336,7 @@ # Gustavo Niemeyer's bz2 module. if (self.compiler.find_library_file(lib_dirs, 'bz2')): - if host_platform == "darwin": + if sys.platform == "darwin": bz2_extra_link_args = ('-Wl,-search_paths_first',) else: bz2_extra_link_args = () @@ -1465,7 +1362,6 @@ define_macros = [] expat_lib = ['expat'] expat_sources = [] - expat_depends = [] else: expat_inc = [os.path.join(os.getcwd(), srcdir, 'Modules', 'expat')] define_macros = [ @@ -1475,25 +1371,12 @@ expat_sources = ['expat/xmlparse.c', 'expat/xmlrole.c', 'expat/xmltok.c'] - expat_depends = ['expat/ascii.h', - 'expat/asciitab.h', - 'expat/expat.h', - 'expat/expat_config.h', - 'expat/expat_external.h', - 'expat/internal.h', - 'expat/latin1tab.h', - 'expat/utf8tab.h', - 'expat/xmlrole.h', - 'expat/xmltok.h', - 'expat/xmltok_impl.h' - ] exts.append(Extension('pyexpat', define_macros = define_macros, include_dirs = expat_inc, libraries = expat_lib, - sources = ['pyexpat.c'] + expat_sources, - depends = expat_depends, + sources = ['pyexpat.c'] + expat_sources )) # Fredrik Lundh's cElementTree module. Note that this also @@ -1506,8 +1389,6 @@ include_dirs = expat_inc, libraries = expat_lib, sources = ['_elementtree.c'], - depends = ['pyexpat.c'] + expat_sources + - expat_depends, )) else: missing.append('_elementtree') @@ -1528,7 +1409,7 @@ if sys.maxint == 0x7fffffff: # This requires sizeof(int) == sizeof(long) == sizeof(char*) dl_inc = find_file('dlfcn.h', [], inc_dirs) - if (dl_inc is not None) and (host_platform not in ['atheos']): + if (dl_inc is not None) and (platform not in ['atheos']): exts.append( Extension('dl', ['dlmodule.c']) ) else: missing.append('dl') @@ -1539,29 +1420,29 @@ self.detect_ctypes(inc_dirs, lib_dirs) # Richard Oudkerk's multiprocessing module - if host_platform == 'win32': # Windows + if platform == 'win32': # Windows macros = dict() libraries = ['ws2_32'] - elif host_platform == 'darwin': # Mac OSX + elif platform == 'darwin': # Mac OSX macros = dict() libraries = [] - elif host_platform == 'cygwin': # Cygwin + elif platform == 'cygwin': # Cygwin macros = dict() libraries = [] - elif host_platform in ('freebsd4', 'freebsd5', 'freebsd6', 'freebsd7', 'freebsd8'): + elif platform in ('freebsd4', 'freebsd5', 'freebsd6', 'freebsd7', 'freebsd8'): # FreeBSD's P1003.1b semaphore support is very experimental # and has many known problems. (as of June 2008) macros = dict() libraries = [] - elif host_platform.startswith('openbsd'): + elif platform.startswith('openbsd'): macros = dict() libraries = [] - elif host_platform.startswith('netbsd'): + elif platform.startswith('netbsd'): macros = dict() libraries = [] @@ -1569,7 +1450,7 @@ macros = dict() libraries = ['rt'] - if host_platform == 'win32': + if platform == 'win32': multiprocessing_srcs = [ '_multiprocessing/multiprocessing.c', '_multiprocessing/semaphore.c', '_multiprocessing/pipe_connection.c', @@ -1596,26 +1477,26 @@ # Platform-specific libraries - if host_platform == 'linux2': + if platform == 'linux2': # Linux-specific modules exts.append( Extension('linuxaudiodev', ['linuxaudiodev.c']) ) else: missing.append('linuxaudiodev') - if (host_platform in ('linux2', 'freebsd4', 'freebsd5', 'freebsd6', + if (platform in ('linux2', 'freebsd4', 'freebsd5', 'freebsd6', 'freebsd7', 'freebsd8') - or host_platform.startswith("gnukfreebsd")): + or platform.startswith("gnukfreebsd")): exts.append( Extension('ossaudiodev', ['ossaudiodev.c']) ) else: missing.append('ossaudiodev') - if host_platform == 'sunos5': + if platform == 'sunos5': # SunOS specific modules exts.append( Extension('sunaudiodev', ['sunaudiodev.c']) ) else: missing.append('sunaudiodev') - if host_platform == 'darwin': + if platform == 'darwin': # _scproxy exts.append(Extension("_scproxy", [os.path.join(srcdir, "Mac/Modules/_scproxy.c")], extra_link_args= [ @@ -1624,7 +1505,7 @@ ])) - if host_platform == 'darwin' and ("--disable-toolbox-glue" not in + if platform == 'darwin' and ("--disable-toolbox-glue" not in sysconfig.get_config_var("CONFIG_ARGS")): if int(os.uname()[2].split('.')[0]) >= 8: @@ -1729,47 +1610,8 @@ if '_tkinter' not in [e.name for e in self.extensions]: missing.append('_tkinter') -## # Uncomment these lines if you want to play with xxmodule.c -## ext = Extension('xx', ['xxmodule.c']) -## self.extensions.append(ext) - return missing - def detect_tkinter_explicitly(self): - # Build _tkinter using explicit locations for Tcl/Tk. - # - # This is enabled when both arguments are given to ./configure: - # - # --with-tcltk-includes="-I/path/to/tclincludes \ - # -I/path/to/tkincludes" - # --with-tcltk-libs="-L/path/to/tcllibs -ltclm.n \ - # -L/path/to/tklibs -ltkm.n" - # - # These values can also be specified or overriden via make: - # make TCLTK_INCLUDES="..." TCLTK_LIBS="..." - # - # This can be useful for building and testing tkinter with multiple - # versions of Tcl/Tk. Note that a build of Tk depends on a particular - # build of Tcl so you need to specify both arguments and use care when - # overriding. - - # The _TCLTK variables are created in the Makefile sharedmods target. - tcltk_includes = os.environ.get('_TCLTK_INCLUDES') - tcltk_libs = os.environ.get('_TCLTK_LIBS') - if not (tcltk_includes and tcltk_libs): - # Resume default configuration search. - return 0 - - extra_compile_args = tcltk_includes.split() - extra_link_args = tcltk_libs.split() - ext = Extension('_tkinter', ['_tkinter.c', 'tkappinit.c'], - define_macros=[('WITH_APPINIT', 1)], - extra_compile_args = extra_compile_args, - extra_link_args = extra_link_args, - ) - self.extensions.append(ext) - return 1 - def detect_tkinter_darwin(self, inc_dirs, lib_dirs): # The _tkinter module, using frameworks. Since frameworks are quite # different the UNIX search logic is not sharable. @@ -1852,20 +1694,15 @@ self.extensions.append(ext) return 1 + def detect_tkinter(self, inc_dirs, lib_dirs): # The _tkinter module. - # Check whether --with-tcltk-includes and --with-tcltk-libs were - # configured or passed into the make target. If so, use these values - # to build tkinter and bypass the searches for Tcl and TK in standard - # locations. - if self.detect_tkinter_explicitly(): - return - # Rather than complicate the code below, detecting and building # AquaTk is a separate method. Only one Tkinter will be built on # Darwin - either AquaTk, if it is found, or X11 based Tk. - if (host_platform == 'darwin' and + platform = self.get_platform() + if (platform == 'darwin' and self.detect_tkinter_darwin(inc_dirs, lib_dirs)): return @@ -1888,7 +1725,7 @@ # Check for the include files on Debian and {Free,Open}BSD, where # they're put in /usr/include/{tcl,tk}X.Y dotversion = version - if '.' not in dotversion and "bsd" in host_platform.lower(): + if '.' not in dotversion and "bsd" in sys.platform.lower(): # OpenBSD and FreeBSD use Tcl/Tk library names like libtcl83.a, # but the include subdirs are named like .../include/tcl8.3. dotversion = dotversion[:-1] + '.' + dotversion[-1] @@ -1914,7 +1751,7 @@ include_dirs.append(dir) # Check for various platform-specific directories - if host_platform == 'sunos5': + if platform == 'sunos5': include_dirs.append('/usr/openwin/include') added_lib_dirs.append('/usr/openwin/lib') elif os.path.exists('/usr/X11R6/include'): @@ -1930,7 +1767,7 @@ added_lib_dirs.append('/usr/X11/lib') # If Cygwin, then verify that X is installed before proceeding - if host_platform == 'cygwin': + if platform == 'cygwin': x11_inc = find_file('X11/Xlib.h', [], include_dirs) if x11_inc is None: return @@ -1949,11 +1786,11 @@ libs.append('tk'+ version) libs.append('tcl'+ version) - if host_platform in ['aix3', 'aix4']: + if platform in ['aix3', 'aix4']: libs.append('ld') # Finally, link with the X11 libraries (not appropriate on cygwin) - if host_platform != "cygwin": + if platform != "cygwin": libs.append('X11') ext = Extension('_tkinter', ['_tkinter.c', 'tkappinit.c'], @@ -1964,6 +1801,10 @@ ) self.extensions.append(ext) +## # Uncomment these lines if you want to play with xxmodule.c +## ext = Extension('xx', ['xxmodule.c']) +## self.extensions.append(ext) + # XXX handle these, but how to detect? # *** Uncomment and edit for PIL (TkImaging) extension only: # -DWITH_PIL -I../Extensions/Imaging/libImaging tkImaging.c \ @@ -2001,7 +1842,7 @@ def configure_ctypes(self, ext): if not self.use_system_libffi: - if host_platform == 'darwin': + if sys.platform == 'darwin': return self.configure_ctypes_darwin(ext) srcdir = sysconfig.get_config_var('srcdir') @@ -2019,10 +1860,7 @@ ffi_configfile): from distutils.dir_util import mkpath mkpath(ffi_builddir) - config_args = [arg for arg in sysconfig.get_config_var("CONFIG_ARGS").split() - if (('--host=' in arg) or ('--build=' in arg))] - if not self.verbose: - config_args.append("-q") + config_args = [] # Pass empty CFLAGS because we'll just append the resulting # CFLAGS to Python's; -g or -O2 is to be avoided. @@ -2064,7 +1902,7 @@ '_ctypes/cfield.c'] depends = ['_ctypes/ctypes.h'] - if host_platform == 'darwin': + if sys.platform == 'darwin': sources.append('_ctypes/malloc_closure.c') sources.append('_ctypes/darwin/dlfcn_simple.c') extra_compile_args.append('-DMACOSX') @@ -2072,7 +1910,7 @@ # XXX Is this still needed? ## extra_link_args.extend(['-read_only_relocs', 'warning']) - elif host_platform == 'sunos5': + elif sys.platform == 'sunos5': # XXX This shouldn't be necessary; it appears that some # of the assembler code is non-PIC (i.e. it has relocations # when it shouldn't. The proper fix would be to rewrite @@ -2083,7 +1921,7 @@ # finding some -z option for the Sun compiler. extra_link_args.append('-mimpure-text') - elif host_platform.startswith('hp-ux'): + elif sys.platform.startswith('hp-ux'): extra_link_args.append('-fPIC') ext = Extension('_ctypes', @@ -2100,7 +1938,7 @@ if not '--with-system-ffi' in sysconfig.get_config_var("CONFIG_ARGS"): return - if host_platform == 'darwin': + if sys.platform == 'darwin': # OS X 10.5 comes with libffi.dylib; the include files are # in /usr/include/ffi inc_dirs.append('/usr/include/ffi')